summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Kathiresan <ganesh3597@gmail.com>2021-03-20 17:01:43 +0530
committerGanesh Kathiresan <ganesh3597@gmail.com>2021-03-20 17:01:43 +0530
commitc78d9a0bb1429f3c4d56d8687ae54cbbe7158838 (patch)
treead4e5826002b9a47defb2635a92cb7d492652a6a
parentbbb143646cbaad2866ed401ca3c795f083285f78 (diff)
downloadnumpy-c78d9a0bb1429f3c4d56d8687ae54cbbe7158838.tar.gz
TST: Division tests for unsigned ints
-rw-r--r--numpy/core/tests/test_umath.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 2249c866c..b31b84d0c 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -250,13 +250,22 @@ class TestDivision:
assert_equal(x % 100, [5, 10, 90, 0, 95, 90, 10, 0, 80])
@pytest.mark.parametrize("input_dtype",
- [np.int8, np.int16, np.int32, np.int64])
+ np.sctypes['int'] + np.sctypes['uint'])
def test_division_int_boundary(self, input_dtype):
iinfo = np.iinfo(input_dtype)
+ # Unsigned:
+ # Create list with 0, 25th, 50th, 75th percentile and max
+ if iinfo.min == 0:
+ lst = [0, iinfo.max//4, iinfo.max//2,
+ int(iinfo.max/1.33), iinfo.max]
+ divisors = [iinfo.max//4, iinfo.max//2,
+ int(iinfo.max/1.33), iinfo.max]
+ # Signed:
# Create list with min, 25th percentile, 0, 75th percentile, max
- lst = [iinfo.min, iinfo.min//2, 0, iinfo.max//2, iinfo.max]
- divisors = [iinfo.min, iinfo.min//2, iinfo.max//2, iinfo.max]
+ else:
+ lst = [iinfo.min, iinfo.min//2, 0, iinfo.max//2, iinfo.max]
+ divisors = [iinfo.min, iinfo.min//2, iinfo.max//2, iinfo.max]
a = np.array(lst, dtype=input_dtype)
for divisor in divisors:
@@ -926,7 +935,7 @@ class TestSpecialFloats:
assert_raises(FloatingPointError, np.log, np.float32(-np.inf))
assert_raises(FloatingPointError, np.log, np.float32(-1.0))
- # See https://github.com/numpy/numpy/issues/18005
+ # See https://github.com/numpy/numpy/issues/18005
with assert_no_warnings():
a = np.array(1e9, dtype='float32')
np.log(a)