Closed DanPuzzuoli closed 1 year ago
@DanPuzzuoli Is this branch going to be merged to the main branch?
@DanPuzzuoli Is this branch going to be merged to the main branch?
Yes - this is the start of making arraylias-related changes to main
.
Thanks for the suggestion @to24toro - I think that makes the function a bit cleaner.
Changes:
lib
method in the test cases to array_library
to be very explicit, and have made them class methods.libraries
method of test_array_backends
to array_libraries
.
Summary
Adds the global instances of numpy/scipy aliases into dynamics, as well as an updated way to write tests for multiple array backends.
Details and comments
In the end the biggest change is to the test infrastructure provided in
test/dynamics/common.py
. The existing solution we have been using for writing test classes for multiple array backends uses inheritance. This has worked pretty well, but given that are going to be making large scale changes to tests, it would be nice if this could be implemented with a single decorator, which would make it easy to add/remove array backends from test cases without having to create a bunch of test classes manually.The new decorator
test_array_backends
incommon.py
aims to achieve this by automating the creation of the subclasses for testing different array backends. It is a little bit "hacky" as it needs to dynamically create new classes, and the implemented solution is the one way I could find to do this. One minor issue is that the subclasses generated bytest_array_backends
have methodsasarray
, etc, that the original test class needs to make use of but does not define. (Basically the original test class does not need to be a well-defined class - it can be written to rely on the functionality that gets added to it by the decorator.) A result of this is thatno-member
warnings get raised by the linter for the test class that is being decorated bytest_array_backends
. It would be nice to figure out a way to do this more "properly" to get rid of this, but I think I can also live with it.