Skip to content

Commit

Permalink
minor fixes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arogozhnikov committed Nov 9, 2022
1 parent 5e0bb81 commit c1f52fc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def unpack_and_pack_against_numpy(x, ps, pattern: str):
# neither failed, check results are identical
assert np.allclose(asnumpy(packed), asnumpy(x))
assert np.allclose(asnumpy(packed_np), asnumpy(x))
assert len(packed) == len(packed_np)
for a, b in zip(asnumpy(packed), packed_np):
assert np.allclose(a, b)
assert len(unpacked) == len(unpacked_np)
for a, b in zip(unpacked, unpacked_np):
assert np.allclose(asnumpy(a), b)



class CaptureException:
Expand Down Expand Up @@ -130,6 +131,8 @@ def selfcheck(self):


cases = [
# NB: in all cases unpacked axis is of length 5.
# that's actively used in tests below
UnpackTestCase((5,), '*'),
UnpackTestCase((5, 7), '* seven'),
UnpackTestCase((7, 5), 'seven *'),
Expand All @@ -150,6 +153,8 @@ def test_pack_unpack_with_numpy():
# all correct, no minus 1
unpack_and_pack(x, [[2], [1], [2]], pattern)
# no -1, asking for wrong shapes
with pytest.raises(BaseException):
unpack_and_pack(x, [[2], [1], [2]], pattern + ' non_existent_axis')
with pytest.raises(BaseException):
unpack_and_pack(x, [[2], [1], [1]], pattern)
with pytest.raises(BaseException):
Expand Down

0 comments on commit c1f52fc

Please sign in to comment.