etkeys / cs417-in-python Goto Github PK
View Code? Open in Web Editor NEWThe C++ work I did in my CS417 undergrad course but reworked in python...because #learning #justForFun
License: MIT License
The C++ work I did in my CS417 undergrad course but reworked in python...because #learning #justForFun
License: MIT License
SOR solver and Jacobi solver use almost identical code in __init__
and _create_guess
. Can SOR be changed to inherit from Jacobi?
Currently, the result vector is always printed. Because of this CI/CD steps redirect stdout to /dev/null. Add an option to control if the result vector should be printed or not. This can make it so CI/CD work can show more interesting result stats without the almost pointless result vector.
src.solvers.__init__.get_solver_instance_by_name
Right now, its a simple if..elif
block the does the mapping of a string to the actual Solver implementor. There should be a more expressive way to do this. Perhaps a dictionary mapping?
Perhaps use a form of get_solver_list
to map _Solver.get_solver_name()
to the actual instance?
Currently, entry_point tests use subprocess calls to run and retrive results. This is slow and code coverage does not detect the code has been tested.
This article suggest using mock patching to substitute sys argv. The approach should remove the need to have subprocess run tests.
Because each problem can or must be solved with a specific solver, solve
action must be able to accept an identifier that corresponds to a specific solver to use.
tests.entry_points.make_tests.TestMakeEntryPoint._setup_with_directory
The real goal of this function is to act as a "setup" or "teardown" type method. Currently it only implements a "delete directory" operation, but it isn't really only for use with test_with_directory
.
Part of assignment 3 uses an omega.def
file to pass in the omega value to use. matrix_operations.load_files()
and matrix_operations.write_files()
needs to be updated to handle the conversion process from legacy to new format and for retrieve omega as a float
type where needed.
The ComplexResult
class was introduced to handle solvers that produced divergent solutions, the LAME_CONVERGENT
caveat. Going forward, a ComplexResult type of structure will be needed but all LAME_CONVERGENT
results should just raise a custom DivergentSolutionError
exception.
Also, a new exit code should be created to indicate to CLI that the solver produced a divergent solution which is different than a general error.
Crout matrix decomposition, an alternative implementation for LU Decomposition that should use GaussianSolver
to calculate the back solve vector.
Should add github actions to double check output.
Original implementation
Original implementation
Original comment from gussuan_tests
See gaussian_tests and ludecomposition_tests.
These functions have a pattern that is repeated.
Can this pattern be generalized?
Currently a random temp directory is created. With the export directory as a constant, more testing can be automated.
Why keep the "test_" prefix?
matrix_operations.create_random_diagonal_dominate
has a history of randomly failing on rare cases. This is due to how the random numbers and math sums work out. I would say the tests fail 1 out of 20 times.
Need to figure out what is going on and fix it.
There are TODO
comments in the python source code. These comments should be removed and converted to issues.
Need to add additional pytests to Jacobi solver for __init__
and _create_guess
.
src.matrix_operations.to_reduced_row_echelon
; While this function is only used by GaussianSolver, it's not hurting anything by staying where it is.src.solve.main
; Additional printing output was added in a1.0. This comment was never removed.Be sure to use numpy.random.default_rng()
Currently, to run individual tests requires a command like this:
python -m unittest tests.matrix_operations_tests.TestMatrixOperations.test_XXXXXXXXX
The TestMatrixOperations
bit seems excessive. If a module only contains one class, then the TestXXXXXX
class serves no purpose. What can be done to restructure the tests to remove the need to have the TestXXXXXXX
class???
Possibly change to pytest? It seems to use a class-less paradigm. For reference, see thefuck (especially this module that defines a special _args
method to use in a fixtures that takes overrides to default parameter to supply to a test.
Original comment from [gaussian_tests](https://github.com/etkeys/cs417-in-python/blob/a2.0/python/tests/solvers/gaussian_tests.py#L50].
Some of the data for test cases don't really need to use floats to define the values in a matrix. But in order for calculations and comparisons to work correctly a matrix must be explicitly created using dtype=float
(see ludecomposition_tests for example). Without explicity using dtype=float
, datatype of the matrix is implied. This can cause unexpected behavior when using np.array()
. When creating a matrix from test data, all tests should be able to call a general function that will call np.array
with dtype=float
.
This method still uses iteration to find find a result, but the starting point is somewhat arbitrary. It's the function f(x)
and f'(x)
that are the focus of this solver.
https://www.w3schools.com/python/numpy_array_reshape.asp
Some reshape operations explicitly use array dimensions. For example, when calculating two norm. It's possible to pass -1
and numpy will figure it out.
Should provide methods that handle the reshaping it reshaping needs to occur.
exp_dir is hard coded to /tmp/makemat
. What if the this location changes or how this location is determined changes? This value should be made a constant so at least there is one sole source for this value.
Also, the scripts in python/.scripts
hard code this value and some of the test data in tests/test_data
. How can these values be updated to some constant that is defined some where else?
#49 created the DivergenSolution
exception. But main
doesn't handle this exception. The exception is handled by solve
which prints the error but only returns false. When this happens main
will exit with 1
instead of 3
. Should refactor main
, make
, and solve
so that the applicable exit codes are used.
Original comment from make_tests.test_with_from_legacy
If you look at the test cases in tests/entry_points, the make use of subprocess.run
. For each test function, they define their own call of subprocess.run
. Can a reusable method be defined such that tests don't need to call subprocess.run
explicitly?
Development for Assignment 3 create the ComplexResult
object. This object is flexible enough that all solver should return this type of object, not just iterative solvers.
Add steps to check the following solvers against assignment 3 data set using .scripts/run-assignments.bash
Looking at the python example for SOR method shows that numpy has the ability to do norm calcuations. See if matrix_operations.two_norm_err
can use this process instead of self-implemented calculation instead.
tests.entry_points.make_tests.test_with_size
only validates that the make entry point succeeded; however it does nothing to validate the size of the matrix and vector definitions created are the size given.
src.solvers.__init__
This function hard codes checks for matA
and matb
in kwargs
, but not all solvers have these as a requirement or have additional inputs as a requirement. Need to find a better way to validate that kwargs
has the required input based on the solver's needs.
This function is not needed as python printing does a good job of printing matrices already.
See TestGaussian
During refactoring of tests for pre-assignment-3, attempted to reduce direct use of numpy
library and instead tried to leverage functions in matrix_operations
. In test_ludecomposition.py
, there is a use of numpy.ones()
function which doesn't have a wrapper methon in matrix_operations
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.