3. PyRates.tests¶
Documentation of all test functions that are included in PyRates. YAML-based model definitions are loaded from model_templates.test_resources.
3.1. Notes on Testing¶
Static type checking
MyPy is used to statically check types. To test, if everything works out, run:
MYPYPATH=./stubs/ mypy –strict-optional –ignore-missing-imports core
If you get no output, all type checks are successful. Some issues are ignored using the comment tag
# type: ignore
These issues may be too complicated for mypy to recognise them properly - or too complicated to fix immediately, but might need fixing, nevertheless.
Running tests with py.test
We use py.test for testing.
Make sure you have pytest installed.
Usage:
- from within PyCharm
select py.test as default testing framework
right-click on tests and select “run py.test in tests”
- from the console
navigate to the PyRates base directory
run pytest tests
3.2. Backend Parser Tests¶
Test suite for basic parser module functionality.
- tests.test_backend_parser.test_1_1_expression_parser_init()[source]¶
Testing initializations of different expression parsers:
See also
ExpressionParser
Detailed documentation of expression parser attributes and methods.
NPExpressionParser
Documentation of the numpy-based expression parser
- tests.test_backend_parser.test_1_2_expression_parser_parsing_exceptions()[source]¶
Testing error handling of different erroneous parser instantiations:
See also
ExpressionParser
Detailed documentation of expression parser attributes and methods.
LambdaExpressionParser
Documentation of a non-symbolic expression parser.
- tests.test_backend_parser.test_1_3_expression_parser_math_ops()[source]¶
Testing handling of mathematical operations by expression parsers:
See also
ExpressionParser
Detailed documentation of expression parser attributes and methods.
LambdaExpressionParser
Documentation of a non-symbolic expression parser.
- tests.test_backend_parser.test_1_4_expression_parser_funcs()[source]¶
Testing handling of function calls by expression parsers:
See also
ExpressionParser
Detailed documentation of expression parser attributes and methods.
LambdaExpressionParser
Documentation of a non-symbolic expression parser.
- tests.test_backend_parser.test_1_5_expression_parser_indexing()[source]¶
Testing handling of indexing operations by expression parsers:
See also
ExpressionParser
Detailed documentation of expression parser attributes and methods.
LambdaExpressionParser
Documentation of a non-symbolic expression parser.
3.3. Backend Simulations Tests¶
Test suite for basic backend simulation functionalities.
- tests.test_backend_simulations.nmrse(x: ndarray, y: ndarray) float | ndarray [source]¶
Calculates the normalized root mean squared error of two vectors of equal length. :param x: Arrays to calculate the nmrse between. :param y: Arrays to calculate the nmrse between.
- Returns:
Normalized root mean squared error.
- Return type:
float
- tests.test_backend_simulations.test_2_1_operator()[source]¶
Testing operator functionality of compute graph class:
See also
- :method:`add_operator`
Detailed documentation of method for adding operations to instance of ComputeGraph.
- tests.test_backend_simulations.test_2_2_node()[source]¶
Testing node functionality of compute graph class.
See also
- :method:`add_node`
Detailed documentation of method for adding nodes to instance of ComputeGraph.
- tests.test_backend_simulations.test_2_3_edge()[source]¶
Testing edge functionality of compute graph class.
See also
- :method:`add_edge`
Detailed documentation of add_edge method of `ComputeGraph`class.
- tests.test_backend_simulations.test_2_4_solver()[source]¶
Testing different numerical solvers of pyrates.
See also
- :method:`_solve`
Detailed documentation of how to numerical integration is performed by the NumpyBackend.
- :method:`run`
Detailed documentation of the method that needs to be called to solve differential equations in the
None
- tests.test_backend_simulations.test_2_5_inputs_outputs()[source]¶
Tests the input-output interface of the run method in circuits of different hierarchical depth.
See also
- tests.test_backend_simulations.test_2_6_vectorization()[source]¶
Tests whether a Jansen-Rit-based circuit with and without vectorization of mathematical operations yields identical results.
See also
3.4. Frontend YAML Parser Tests¶
3.5. Pre-defined Models Tests¶
Test suite for accurate behavior of models provided under pyrates.model_templates
- tests.test_implemented_models.nmrse(x: ndarray, y: ndarray) float | ndarray [source]¶
Calculates the normalized root mean squared error of two vectors of equal length. :param x: Arrays to calculate the nmrse between. :param y: Arrays to calculate the nmrse between.
- Returns:
Normalized root mean squared error.
- Return type:
float
- tests.test_implemented_models.test_3_1_jansenrit()[source]¶
Testing accuracy of Jansen-Rit model implementations:
- tests.test_implemented_models.test_3_2_qif_theta()[source]¶
Testing accuracy of mean-field representation of QIF population and theta neuron model.