提交 8226f64c authored 作者: Brendan Murphy's avatar Brendan Murphy 提交者: Ricardo Vieira

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.
上级 51430183
...@@ -1403,18 +1403,37 @@ class TestMinMax: ...@@ -1403,18 +1403,37 @@ class TestMinMax:
# check_grad_max(data, eval_outputs(grad(max_and_argmax(n, # check_grad_max(data, eval_outputs(grad(max_and_argmax(n,
# axis=1)[0], n)),axis=1) # axis=1)[0], n)),axis=1)
@pytest.mark.parametrize(
"dtype",
(
"uint8",
"uint16",
"uint32",
pytest.param("uint64", marks=pytest.mark.xfail(reason="Fails due to #770")),
),
)
def test_uint(self, dtype):
itype = np.iinfo(dtype)
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype)
n = as_tensor_variable(data)
assert min(n).dtype == dtype
i_min = eval_outputs(min(n))
assert i_min == itype.min
assert max(n).dtype == dtype
i_max = eval_outputs(max(n))
assert i_max == itype.max
@pytest.mark.xfail(reason="Fails due to #770") @pytest.mark.xfail(reason="Fails due to #770")
def test_uint(self): def test_uint64_special_value(self):
for dtype in ("uint8", "uint16", "uint32", "uint64"): """Example from issue #770"""
itype = np.iinfo(dtype) dtype = "uint64"
data = np.array([itype.min + 3, itype.min, itype.max - 5, itype.max], dtype) data = np.array([0, 9223372036854775], dtype=dtype)
n = as_tensor_variable(data) n = as_tensor_variable(data)
assert min(n).dtype == dtype
i = eval_outputs(min(n)) i_max = eval_outputs(max(n))
assert i == itype.min assert i_max == data.max()
assert max(n).dtype == dtype
i = eval_outputs(max(n))
assert i == itype.max
def test_bool(self): def test_bool(self):
data = np.array([True, False], "bool") data = np.array([True, False], "bool")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论