[ 86s] ============================= test session starts ==============================
[ 86s] platform linux -- Python 3.8.16, pytest-7.2.0, pluggy-1.0.0 -- /usr/bin/python3.8
[ 86s] cachedir: .pytest_cache
[ 86s] hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/abuild/rpmbuild/BUILD/ndindex-1.6/.hypothesis/examples')
[ 86s] rootdir: /home/abuild/rpmbuild/BUILD/ndindex-1.6
[ 86s] plugins: hypothesis-6.61.2
[ 87s] collecting ... collected 105 items
...
[ 240s] _____________________ test_integerarray_reduce_hypothesis ______________________
[ 240s]
[ 240s] a = array([], shape=(1, 0), dtype=int64), idx = array([2, 0])
[ 240s] raw_func = <function <lambda> at 0x7f2b91ac30d0>
[ 240s] ndindex_func = <function test_integerarray_reduce_hypothesis.<locals>.<lambda> at 0x7f2b91b063a0>
[ 240s] same_exception = True, assert_equal = <function assert_equal at 0x7f2b91ac3040>
[ 240s]
[ 240s] def check_same(a, idx, raw_func=lambda a, idx: a[idx],
[ 240s] ndindex_func=lambda a, index: a[index.raw],
[ 240s] same_exception=True, assert_equal=assert_equal):
[ 240s] """
[ 240s] Check that a raw index idx produces the same result on an array a before
[ 240s] and after being transformed by ndindex.
[ 240s]
[ 240s] Tests that raw_func(a, idx) == ndindex_func(a, ndindex(idx)) or that they
[ 240s] raise the same exception. If same_exception=False, it will still check
[ 240s] that they both raise an exception, but will not require the exception type
[ 240s] and message to be the same.
[ 240s]
[ 240s] By default, raw_func(a, idx) is a[idx] and ndindex_func(a, index) is
[ 240s] a[index.raw].
[ 240s]
[ 240s] The assert_equal argument changes the function used to test equality. By
[ 240s] default it is the custom assert_equal() function in this file that extends
[ 240s] numpy.testing.assert_equal. If the func functions return something other
[ 240s] than arrays, assert_equal should be set to something else, like
[ 240s]
[ 240s] def assert_equal(x, y):
[ 240s] assert x == y
[ 240s]
[ 240s] """
[ 240s] exception = None
[ 240s] try:
[ 240s] # Handle list indices that NumPy treats as tuple indices with a
[ 240s] # deprecation warning. We want to test against the post-deprecation
[ 240s] # behavior.
[ 240s] e_inner = None
[ 240s] try:
[ 240s] try:
[ 240s] a_raw = raw_func(a, idx)
[ 240s] except Warning as w:
[ 240s] # In NumPy < 1.23, this is a FutureWarning. In 1.23 the
[ 240s] # deprecation was removed and lists are always interpreted as
[ 240s] # array indices.
[ 240s] if ("Using a non-tuple sequence for multidimensional indexing is deprecated" in w.args[0]): # pragma: no cover
[ 240s] idx = array(idx)
[ 240s] a_raw = raw_func(a, idx)
[ 240s] elif "Out of bound index found. This was previously ignored when the indexing result contained no elements. In the future the index error will be raised. This error occurs either due to an empty slice, or if an array has zero elements even before indexing." in w.args[0]:
[ 240s] same_exception = False
[ 240s] raise IndexError
[ 240s] else: # pragma: no cover
[ 240s] fail(f"Unexpected warning raised: {w}")
[ 240s] except Exception:
[ 240s] _, e_inner, _ = sys.exc_info()
[ 240s] if e_inner:
[ 240s] raise e_inner
[ 240s] except Exception as e:
[ 240s] exception = e
[ 240s]
[ 240s] try:
[ 240s] index = ndindex(idx)
[ 240s] > a_ndindex = ndindex_func(a, index)
[ 240s]
[ 240s] ndindex/tests/helpers.py:238:
[ 240s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 240s]
[ 240s] a = array([], shape=(1, 0), dtype=int64), x = IntegerArray([2, 0])
[ 240s]
[ 240s] > check_same(a, index.raw, ndindex_func=lambda a, x: a[x.reduce(shape).raw])
[ 240s]
[ 240s] ndindex/tests/test_integerarray.py:65:
[ 240s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 240s]
[ 240s] self = IntegerArray([2, 0]), shape = (1, 0), axis = 0
[ 240s]
[ 240s] def reduce(self, shape=None, axis=0):
[ 240s] """
[ 240s] Reduce an `IntegerArray` index on an array of shape `shape`.
[ 240s]
[ 240s] The result will either be `IndexError` if the index is invalid for the
[ 240s] given shape, an `IntegerArray` index where the values are all
[ 240s] nonnegative, or, if `self` is a scalar array index (`self.shape ==
[ 240s] ()`), an `Integer` whose value is nonnegative.
[ 240s]
[ 240s] >>> from ndindex import IntegerArray
[ 240s] >>> idx = IntegerArray([-5, 2])
[ 240s] >>> idx.reduce((3,))
[ 240s] Traceback (most recent call last):
[ 240s] ...
[ 240s] IndexError: index -5 is out of bounds for axis 0 with size 3
[ 240s] >>> idx.reduce((9,))
[ 240s] IntegerArray([4, 2])
[ 240s]
[ 240s] See Also
[ 240s] ========
[ 240s]
[ 240s] .NDIndex.reduce
[ 240s] .Tuple.reduce
[ 240s] .Slice.reduce
[ 240s] .ellipsis.reduce
[ 240s] .Newaxis.reduce
[ 240s] .Integer.reduce
[ 240s] .BooleanArray.reduce
[ 240s]
[ 240s] """
[ 240s] if self.shape == ():
[ 240s] return Integer(self.array).reduce(shape, axis=axis)
[ 240s]
[ 240s] if shape is None:
[ 240s] return self
[ 240s]
[ 240s] shape = asshape(shape, axis=axis)
[ 240s]
[ 240s] size = shape[axis]
[ 240s] new_array = self.array.copy()
[ 240s] out_of_bounds = (new_array >= size) | ((-size > new_array) & (new_array < 0))
[ 240s] if out_of_bounds.any():
[ 240s] > raise IndexError(f"index {new_array[out_of_bounds].flat[0]} is out of bounds for axis {axis} with size {size}")
[ 240s] E IndexError: index 2 is out of bounds for axis 0 with size 1
[ 240s]
[ 240s] ndindex/integerarray.py:96: IndexError
[ 240s]
[ 240s] During handling of the above exception, another exception occurred:
[ 240s]
[ 240s] @example(array([2, 0]), (1, 0))
[ 240s] > @example(array(0), 1)
[ 240s]
[ 240s] ndindex/tests/test_integerarray.py:54:
[ 240s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 240s] /usr/lib/python3.8/site-packages/hypothesis/core.py:979: in _raise_to_user
[ 240s] raise the_error_hypothesis_found
[ 240s] ndindex/tests/test_integerarray.py:65: in test_integerarray_reduce_hypothesis
[ 240s] check_same(a, index.raw, ndindex_func=lambda a, x: a[x.reduce(shape).raw])
[ 240s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 240s]
[ 240s] a = array([], shape=(1, 0), dtype=int64), idx = array([2, 0])
[ 240s] raw_func = <function <lambda> at 0x7f2b91ac30d0>
[ 240s] ndindex_func = <function test_integerarray_reduce_hypothesis.<locals>.<lambda> at 0x7f2b91b063a0>
[ 240s] same_exception = True, assert_equal = <function assert_equal at 0x7f2b91ac3040>
[ 240s]
[ 240s] def check_same(a, idx, raw_func=lambda a, idx: a[idx],
[ 240s] ndindex_func=lambda a, index: a[index.raw],
[ 240s] same_exception=True, assert_equal=assert_equal):
[ 240s] """
[ 240s] Check that a raw index idx produces the same result on an array a before
[ 240s] and after being transformed by ndindex.
[ 240s]
[ 240s] Tests that raw_func(a, idx) == ndindex_func(a, ndindex(idx)) or that they
[ 240s] raise the same exception. If same_exception=False, it will still check
[ 240s] that they both raise an exception, but will not require the exception type
[ 240s] and message to be the same.
[ 240s]
[ 240s] By default, raw_func(a, idx) is a[idx] and ndindex_func(a, index) is
[ 240s] a[index.raw].
[ 240s]
[ 240s] The assert_equal argument changes the function used to test equality. By
[ 240s] default it is the custom assert_equal() function in this file that extends
[ 240s] numpy.testing.assert_equal. If the func functions return something other
[ 240s] than arrays, assert_equal should be set to something else, like
[ 240s]
[ 240s] def assert_equal(x, y):
[ 240s] assert x == y
[ 240s]
[ 240s] """
[ 240s] exception = None
[ 240s] try:
[ 240s] # Handle list indices that NumPy treats as tuple indices with a
[ 240s] # deprecation warning. We want to test against the post-deprecation
[ 240s] # behavior.
[ 240s] e_inner = None
[ 240s] try:
[ 240s] try:
[ 240s] a_raw = raw_func(a, idx)
[ 240s] except Warning as w:
[ 240s] # In NumPy < 1.23, this is a FutureWarning. In 1.23 the
[ 240s] # deprecation was removed and lists are always interpreted as
[ 240s] # array indices.
[ 240s] if ("Using a non-tuple sequence for multidimensional indexing is deprecated" in w.args[0]): # pragma: no cover
[ 240s] idx = array(idx)
[ 240s] a_raw = raw_func(a, idx)
[ 240s] elif "Out of bound index found. This was previously ignored when the indexing result contained no elements. In the future the index error will be raised. This error occurs either due to an empty slice, or if an array has zero elements even before indexing." in w.args[0]:
[ 240s] same_exception = False
[ 240s] raise IndexError
[ 240s] else: # pragma: no cover
[ 240s] fail(f"Unexpected warning raised: {w}")
[ 240s] except Exception:
[ 240s] _, e_inner, _ = sys.exc_info()
[ 240s] if e_inner:
[ 240s] raise e_inner
[ 240s] except Exception as e:
[ 240s] exception = e
[ 240s]
[ 240s] try:
[ 240s] index = ndindex(idx)
[ 240s] a_ndindex = ndindex_func(a, index)
[ 240s] except Exception as e:
[ 240s] if not exception:
[ 240s] > fail(f"Raw form does not raise but ndindex form does ({e!r}): {index})") # pragma: no cover
[ 240s] E Failed: Raw form does not raise but ndindex form does (IndexError('index 2 is out of bounds for axis 0 with size 1')): IntegerArray([2 0]))
[ 240s] E Falsifying explicit example: test_integerarray_reduce_hypothesis(
[ 240s] E idx=array([2, 0]),
[ 240s] E shape=(1, 0),
[ 240s] E )
[ 240s]
[ 240s] ndindex/tests/helpers.py:241: Failed