sandialabs / pyGSTi

A python implementation of Gate Set Tomography
http://www.pygsti.info
Apache License 2.0
132 stars 55 forks source link

Help pytest find tests #362

Closed rileyjmurray closed 8 months ago

rileyjmurray commented 8 months ago

This should resolve #361.

This branch has latest develop as its base. It had 6 failing tests when I started. Five of those failing tests were due to a wrong version of a dependency (qibo) I got when I installed pyGSTi. The other failing test was due to a missing dependency. I've modified this last failing test so that it handles the missing dependency gracefully. I'd like it if the other five tests also gracefully handled a wrong dependency version, but I'll put that off for now as issue #363.

The initial change I made in this PR was just to pytest.ini. Then I needed to fix some broken tests.

rileyjmurray commented 8 months ago

Documenting where I am on this. Here are the currently failing tests.

=========================================================================== short test summary info ===========================================================================
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_copy - NotImplementedError: to_dense(...) not implemented for LinearOperator objects!
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_deriv_wrt_params - AttributeError: 'LinearOperator' object has no attribute 'size'
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_diamonddist - NotImplementedError: to_dense(...) not implemented for LinearOperator objects!
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_frobeniusdist - NotImplementedError: to_dense(...) not implemented for LinearOperator objects!
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_jtracedist - NotImplementedError: to_dense(...) not implemented for LinearOperator objects!
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_pickle - NotImplementedError: to_dense(...) not implemented for LinearOperator objects!
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_raise_on_invalid_method - AssertionError: `dim` must be a perfect square: 2 is not
FAILED test/unit/modelmembers/test_operation.py::LinearOpTester::test_tosparse - NotImplementedError: to_sparse(...) not implemented for LinearOperator objects!

FAILED test/unit/objects/test_objectivefns.py::RawObjectiveFunctionTester::test_value - AttributeError: 'RawObjectiveFunctionTester' object has no attribute 'objfns'
FAILED test/unit/objects/test_objectivefns.py::RawObjectiveFunctionTester::test_derivative - AttributeError: 'RawObjectiveFunctionTester' object has no attribute 'objfns'
FAILED test/unit/objects/test_objectivefns.py::RawObjectiveFunctionTester::test_hessian - AttributeError: 'RawObjectiveFunctionTester' object has no attribute 'objfns'

FAILED test/unit/objects/test_objectivefns.py::TimeIndependentMDSObjectiveFunctionTester::test_builder - AttributeError: 'TimeIndependentMDSObjectiveFunctionTester' object has no attribute 'objfns'
FAILED test/unit/objects/test_objectivefns.py::TimeIndependentMDSObjectiveFunctionTester::test_value - AttributeError: 'TimeIndependentMDSObjectiveFunctionTester' object has no attribute 'objfns'
FAILED test/unit/objects/test_objectivefns.py::TimeIndependentMDSObjectiveFunctionTester::test_derivative - AttributeError: 'TimeIndependentMDSObjectiveFunctionTester' object has no attribute 'objfns'
FAILED test/unit/objects/test_objectivefns.py::TimeIndependentMDSObjectiveFunctionTester::test_approximate_hessian - AttributeError: 'TimeIndependentMDSObjectiveFunctionTester' object has no attribute 'enable_hessian_tests'
FAILED test/unit/objects/test_objectivefns.py::TimeIndependentMDSObjectiveFunctionTester::test_hessian - AttributeError: 'TimeIndependentMDSObjectiveFunctionTester' object has no attribute 'enable_hessian_tests'

FAILED test/unit/objects/test_objectivefns.py::TimeDependentMDSObjectiveFunctionTester::test_lsvec - AttributeError: 'TimeDependentMDSObjectiveFunctionTester' object has no attribute 'objfns'
FAILED test/unit/objects/test_objectivefns.py::TimeDependentMDSObjectiveFunctionTester::test_dlsvec - AttributeError: 'TimeDependentMDSObjectiveFunctionTester' object has no attribute 'objfns'
================================================== 18 failed, 1820 passed, 76 skipped, 159435 warnings in 212.70s (0:03:32) ===================================================
rileyjmurray commented 8 months ago

It seems that all failing tests mentioned in my last comment where due to incomplete classes having the Tester suffix. I changed Tester to TesterBase on the offending classes. I also added a function that raises a NotImplementedError to clearly indicate that these classes are in fact base classes.

rileyjmurray commented 8 months ago

IMO this is ready to merge.

sserita commented 8 months ago

Thanks, I'll try to look at this in the next few days.