Skip to content

Commit 8226f64

Browse files
brendan-m-murphyricardoV94
authored andcommitted
Split up TestMinMax::test_uint
I split this test up to test uint64 separately, since this is the case discussed in Issue #770. I also added a test for the exact example used in that issue. The uint dtypes with lower precision should pass. The uint64 case started passing for me locally on Mac OSX, but still fails on CI. I'm not sure why this is, but at least the test will be more specific now if it fails in the future.
1 parent 5143018 commit 8226f64

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

tests/tensor/test_math.py

+30-11
Original file line numberDiff line numberDiff line change
@@ -1403,18 +1403,37 @@ def _grad_list(self):
14031403
# check_grad_max(data, eval_outputs(grad(max_and_argmax(n,
14041404
# axis=1)[0], n)),axis=1)
14051405

1406+
@pytest.mark.parametrize(
1407+
"dtype",
1408+
(
1409+
"uint8",
1410+
"uint16",
1411+
"uint32",
1412+
pytest.param("uint64", marks=pytest.mark.xfail(reason="Fails due to #770")),
1413+
),
1414+
)
1415+
def test_uint(self, dtype):
1416+
itype = np.iinfo(dtype)
1417+
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype)
1418+
n = as_tensor_variable(data)
1419+
1420+
assert min(n).dtype == dtype
1421+
i_min = eval_outputs(min(n))
1422+
assert i_min == itype.min
1423+
1424+
assert max(n).dtype == dtype
1425+
i_max = eval_outputs(max(n))
1426+
assert i_max == itype.max
1427+
14061428
@pytest.mark.xfail(reason="Fails due to #770")
1407-
def test_uint(self):
1408-
for dtype in ("uint8", "uint16", "uint32", "uint64"):
1409-
itype = np.iinfo(dtype)
1410-
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype)
1411-
n = as_tensor_variable(data)
1412-
assert min(n).dtype == dtype
1413-
i = eval_outputs(min(n))
1414-
assert i == itype.min
1415-
assert max(n).dtype == dtype
1416-
i = eval_outputs(max(n))
1417-
assert i == itype.max
1429+
def test_uint64_special_value(self):
1430+
"""Example from issue #770"""
1431+
dtype = "uint64"
1432+
data = np.array([0, 9223372036854775], dtype=dtype)
1433+
n = as_tensor_variable(data)
1434+
1435+
i_max = eval_outputs(max(n))
1436+
assert i_max == data.max()
14181437

14191438
def test_bool(self):
14201439
data = np.array([True, False], "bool")

0 commit comments

Comments
 (0)