def test_numpy_dtypes(self):
np = pytest.importorskip("numpy")
dtypes = np.typecodes["AllInteger"]
for dtype in dtypes:
dtype = np.dtype(dtype).type
shortcuts.check_integer(dtype(1))
# The integer check is strict. The
# type must match, even if numerically
# the number is an integer.
msg = "Expected an integer but got"
dtypes = (np.typecodes["AllFloat"] +
np.typecodes["Complex"])
for dtype in dtypes:
dtype = np.dtype(dtype).type
assert_raises(TypeError, msg, shortcuts.check_integer, dtype(1))
评论列表
文章目录