Skip to content

Conversation

jonathanberthias
Copy link

Hello! I've added a test to ensure all basic binary operations work across all 3 types of expressions: Expr, GenExpr and MatrixExpr. Here were the failures before the changes in this PR:

FAILED tests/test_matrix_variable.py::test_binop[add-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[sub-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[mul-var-matvar] - NotImplementedError
FAILED tests/test_matrix_variable.py::test_binop[mul-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[truediv-var-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[truediv-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'

These failed in various places. The most common cause of errors was that GenExpr dunder methods can't handle MatrixExpr.

With the changes, all of these cases pass. Note that the test doesn't really check the result is correct, just that the operations do not crash. I expect the other tests in the test suite to ensure correctness.

Fixes #1066

Currently failing:
FAILED tests/test_matrix_variable.py::test_binop[add-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[sub-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[mul-var-matvar] - NotImplementedError
FAILED tests/test_matrix_variable.py::test_binop[mul-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[truediv-var-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
FAILED tests/test_matrix_variable.py::test_binop[truediv-genexpr-matvar] - AttributeError: 'MatrixExpr' object has no attribute 'getOp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when adding MatrixExpr to GenExpr
1 participant