You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can't guarantee that Tuple.reduce is fully canonical like with slices #82, because there are too many combinations. But we can test that it removes any redundant terms. Something like
diff --git a/ndindex/tests/test_tuple.py b/ndindex/tests/test_tuple.py
index c8a53a4..3a02961 100644
--- a/ndindex/tests/test_tuple.py+++ b/ndindex/tests/test_tuple.py@@ -10,7 +10,7 @@ from pytest import raises
from ..ndindex import ndindex
from ..tuple import Tuple
from ..integer import Integer
-from .helpers import check_same, Tuples, prod, short_shapes, iterslice+from .helpers import assert_equal, check_same, Tuples, prod, short_shapes, iterslice
def test_tuple_constructor():
# Test things in the Tuple constructor that are not tested by the other
@@ -131,6 +131,12 @@ def test_tuple_reduce_hypothesis(t, shape):
if isinstance(reduced, Tuple):
assert len(reduced.args) != 1
assert reduced == () or reduced.args[-1] != ...
+ args = reduced.args+ for i in range(len(args)):+ a_index = a[index.raw]+ idx = Tuple(*(args[0:i] + args[i+1:]))+ # Is there a better way to do assert not equal?+ raises((IndexError, AssertionError), lambda: assert_equal(a_index, a[idx.raw]))
# TODO: Check the other properties from the Tuple.reduce docstring.
def test_tuple_reduce_explicit():
The problem is that this leads to some odd cases which aren't straightforward to match, for example, (..., False) and False are equivalent for shape (0,) because the added 0 to the shape from the False is the same on the left or right. Similarly for (..., None) and None for shape (1,).
The text was updated successfully, but these errors were encountered:
And for something like shape (2, 1), (..., None) and (slice(None), None) are equivalent, but not just None. So there's the question of which is better.
We can't guarantee that Tuple.reduce is fully canonical like with slices #82, because there are too many combinations. But we can test that it removes any redundant terms. Something like
The problem is that this leads to some odd cases which aren't straightforward to match, for example,
(..., False)
andFalse
are equivalent for shape(0,)
because the added0
to the shape from theFalse
is the same on the left or right. Similarly for(..., None)
andNone
for shape(1,)
.The text was updated successfully, but these errors were encountered: