summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorNico Schlömer <nico.schloemer@gmail.com>2019-12-18 22:14:26 +0100
committerMatti Picus <matti.picus@gmail.com>2019-12-18 23:14:26 +0200
commit6d69a9e163858de5d0ea2ae810b8febc7eec1dbc (patch)
treeb72168795c83084f309e7993d06eb91c7dbebffd /numpy
parent0cea652454fdd04fb90266865792281ef5404b8c (diff)
downloadnumpy-6d69a9e163858de5d0ea2ae810b8febc7eec1dbc.tar.gz
MAINT: Fix randint 0d limits and other 0d cleanups (#15126)
* MAINT: only treat 0d case separately in randint, simplify some tests
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_machar.py2
-rw-r--r--numpy/core/tests/test_multiarray.py2
-rw-r--r--numpy/random/_bounded_integers.pyx.in3
-rw-r--r--numpy/testing/tests/test_utils.py6
4 files changed, 6 insertions, 7 deletions
diff --git a/numpy/core/tests/test_machar.py b/numpy/core/tests/test_machar.py
index ab8800c09..64a0ffa3d 100644
--- a/numpy/core/tests/test_machar.py
+++ b/numpy/core/tests/test_machar.py
@@ -16,7 +16,7 @@ class TestMachAr(object):
# underflow
try:
hiprec = ntypes.float96
- MachAr(lambda v:array([v], hiprec))
+ MachAr(lambda v: array(v, hiprec))
except AttributeError:
# Fixme, this needs to raise a 'skip' exception.
"Skipping test: no ntypes.float96 available on this platform."
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index ae4e89d5b..d801dbf91 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -7564,8 +7564,8 @@ class TestConversion(object):
# gh-9972 means that these aren't always the same
int_funcs = (int, lambda x: x.__int__())
for int_func in int_funcs:
+ assert_equal(int_func(np.array(0)), 0)
assert_equal(int_func(np.array([1])), 1)
- assert_equal(int_func(np.array([0])), 0)
assert_equal(int_func(np.array([[42]])), 42)
assert_raises(TypeError, int_func, np.array([1, 2]))
diff --git a/numpy/random/_bounded_integers.pyx.in b/numpy/random/_bounded_integers.pyx.in
index 7e19471e4..9e639b53b 100644
--- a/numpy/random/_bounded_integers.pyx.in
+++ b/numpy/random/_bounded_integers.pyx.in
@@ -314,8 +314,7 @@ cdef object _rand_{{nptype}}(object low, object high, object size,
high_arr = <np.ndarray>np.array(high, copy=False)
low_ndim = np.PyArray_NDIM(low_arr)
high_ndim = np.PyArray_NDIM(high_arr)
- if ((low_ndim == 0 or (low_ndim == 1 and low_arr.size == 1 and size is not None)) and
- (high_ndim == 0 or (high_ndim == 1 and high_arr.size == 1 and size is not None))):
+ if low_ndim == 0 and high_ndim == 0:
low = int(low_arr)
high = int(high_arr)
# Subtract 1 since internal generator produces on closed interval [low, high]
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index 44f93a693..d14d4090c 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -608,9 +608,9 @@ class TestApproxEqual(object):
def setup(self):
self._assert_func = assert_approx_equal
- def test_simple_arrays(self):
- x = np.array([1234.22])
- y = np.array([1234.23])
+ def test_simple_0d_arrays(self):
+ x = np.array(1234.22)
+ y = np.array(1234.23)
self._assert_func(x, y, significant=5)
self._assert_func(x, y, significant=6)