Skip to content

Commit 26e0b59

Browse files
Split up TestMinMax::test_uint
I split this test up to test uint64 separately, since this is the case discussed in Issue pymc-devs#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 6f2bbe2 commit 26e0b59

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

tests/tensor/test_math.py

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

1405+
@pytest.mark.parametrize("dtype", ("uint8", "uint16", "uint32"))
1406+
def test_uint(self, dtype):
1407+
itype = np.iinfo(dtype)
1408+
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype)
1409+
n = as_tensor_variable(data)
1410+
1411+
assert min(n).dtype == dtype
1412+
i_min = eval_outputs(min(n))
1413+
assert i_min == itype.min
1414+
1415+
assert max(n).dtype == dtype
1416+
i_max = eval_outputs(max(n))
1417+
assert i_max == itype.max
1418+
14051419
@pytest.mark.xfail(reason="Fails due to #770")
1406-
def test_uint(self):
1407-
for dtype in ("uint8", "uint16", "uint32", "uint64"):
1408-
itype = np.iinfo(dtype)
1409-
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype)
1410-
n = as_tensor_variable(data)
1411-
assert min(n).dtype == dtype
1412-
i = eval_outputs(min(n))
1413-
assert i == itype.min
1414-
assert max(n).dtype == dtype
1415-
i = eval_outputs(max(n))
1416-
assert i == itype.max
1420+
def test_uint64(self):
1421+
dtype = "uint64"
1422+
itype = np.iinfo(dtype)
1423+
1424+
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype)
1425+
n = as_tensor_variable(data)
1426+
1427+
assert min(n).dtype == dtype
1428+
i_min = eval_outputs(min(n))
1429+
assert i_min == itype.min
1430+
1431+
assert max(n).dtype == dtype
1432+
i_max = eval_outputs(max(n))
1433+
assert i_max == itype.max
1434+
1435+
i_max = eval_outputs(max(n))
1436+
assert i_max == data.max()
1437+
1438+
@pytest.mark.xfail(reason="Fails due to #770")
1439+
def test_uint64_special_value(self):
1440+
dtype = "uint64"
1441+
data = np.array([0, 9223372036854775], dtype=dtype)
1442+
n = as_tensor_variable(data)
1443+
1444+
i_max = eval_outputs(max(n))
1445+
assert i_max == data.max()
14171446

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

0 commit comments

Comments
 (0)