Skip to content

Addition of tests for the custom diagonalization functionality.  #220

Description

@petergthatsme

The goal here is to create tests for the recently added custom diagonalization functionality, which allows users to determine what libraries are used for Hamiltonian diagonalization of the systems they define.

The current test suite is located here. Assuming pytest is installed (if not, can run pip install pytest), to run tests defined in a specific file, one can simply execute (from a directory above):

pytest -v --pyargs ./tests/test_noise.py

which, here will run tests outlined in test_noise.py.

One approach to implement this feature, would thus, be the following:

  1. Create a file scqubits/tests/diag_tests.py and add relevant imports (to see what's needed one can look at the other files in the tests folder).

  2. Look at an example notebook that shows how the custom diagonalization functionality can be used.

  3. Pick a few examples from the notebook shown in (2), and/or dream up a few of your own, and create the corresponding test functions (see other files in tests folder for examples of what these should look like). So for example inside a given test function, one might create a qubit object, while passing in a particular diagonalization method, e.g., evals_method='evals_scipy_sparse', and then perform the diagonalization. Ideally it should also include a comparison to a default case, where a custom method has not been chosen.

  4. Use pytest to be sure that the everything is working correctly.

One important thing that should be handled properly is the fact that some of the custom diaognalization methods depend on the existence of specific libraries/packages on the user's system (e.g. primme, cupy, jax). The tests should then only tests methods that rely on this optinal packages if they are present on the user's system - if they are not installed, a simple warning should be printed along the lines of e.g., "Package primme not installed; skipping test".

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions