Skip to content

Commit

Permalink
CI: pytest for swapped operand operations
Browse files Browse the repository at this point in the history
Add test to cover swapped operand operations on MultiVector-s.
Esp. the fix for #426.
  • Loading branch information
trundev committed Dec 9, 2024
1 parent dcaa727 commit 5fb1081
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clifford/test/test_clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,24 @@ def test_right_multiplication_matrix(self, algebra, rng): # noqa: F811
res2 = layout.MultiVector(value=b_right@a.value)
np.testing.assert_almost_equal(res.value, res2.value)

@pytest.mark.parametrize('func', [
operator.add,
operator.sub,
operator.mul,
operator.xor, # outer product
operator.or_, # inner product
])
def test_swapped_operands(self, algebra, rng, func):

Check warning on line 751 in clifford/test/test_clifford.py

View workflow job for this annotation

GitHub Actions / lint | Python 3.8

F811 redefinition of unused 'rng' from line 15
layout = algebra
for _ in range(10):
mv = layout.randomMV(rng=rng)
mv2 = layout.randomMV(rng=rng)
# Convert first operand to MVArray. This provokes use of operation with
# swapped operands: MultiVector.__rmul__, __ror__, etc.
ma = clifford.MVArray(mv)
np.testing.assert_equal(func(ma, mv2), func(mv, mv2))
np.testing.assert_equal(func(mv2, ma), func(mv2, mv))


class TestPrettyRepr:
""" Test ipython pretty printing, with tidy line wrapping """
Expand Down

0 comments on commit 5fb1081

Please sign in to comment.