8000 Merge pull request #4982 from charris/gh-2941 · numpy/numpy@2059cce · GitHub
[go: up one dir, main page]

Skip to content

Commit 2059cce

Browse files
committed
Merge pull request #4982 from charris/gh-2941
Fixup of PR #4921
2 parents 5ce8e06 + 9cd4dc2 commit 2059cce

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

numpy/core/src/umath/funcs.inc.src

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ npy_ObjectPower(PyObject *x, PyObject *y)
5555
return PyNumber_Power(x, y, Py_None);
5656
}
5757

58-
59-
#if defined(NPY_PY3K)
6058
/**begin repeat
6159
* #Kind = Max, Min#
6260
* #OP = Py_GE, Py_LE#
@@ -82,33 +80,6 @@ npy_Object@Kind@(PyObject *i1, PyObject *i2)
8280
}
8381
/**end repeat**/
8482

85-
#else
86-
/**begin repeat
87-
* #Kind = Max, Min#
88-
* #OP = >=, <=#
89-
*/
90-
static PyObject *
91-
npy_Object@Kind@(PyObject *i1, PyObject *i2)
92-
{
93-
PyObject *result;
94-
int cmp;
95-
96-
if (PyObject_Cmp(i1, i2, &cmp) < 0) {
97-
return NULL;
98-
}
99-
if (cmp @OP@ 0) {
100-
result = i1;
101-
}
102-
else {
103-
result = i2;
104-
}
105-
Py_INCREF(result);
106-
return result;
107-
}
108-
/**end repeat**/
109-
#endif
110-
111-
11283
/* Emulates Python's 'a or b' behavior */
11384
static PyObject *
11485
npy_ObjectLogicalOr(PyObject *i1, PyObject *i2)

numpy/core/tests/test_umath.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,17 @@ def test_float_nans(self):
540540
out = np.array([nan, nan, nan])
541541
assert_equal(np.maximum(arg1, arg2), out)
542542

543+
def test_object_nans(self):
544+
# Multiple checks to give this a chance to
545+
# fail if cmp is used instead of rich compare.
546+
# Failure cannot be guaranteed.
547+
for i in range(1):
548+
x = np.array(float('nan'), np.object)
549+
y = 1.0
550+
z = np.array(float('nan'), np.object)
551+
assert_(np.maximum(x, y) == 1.0)
552+
assert_(np.maximum(z, y) == 1.0)
553+
543554
def test_complex_nans(self):
544555
nan = np.nan
545556
for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)] :
@@ -587,6 +598,17 @@ def test_float_nans(self):
587598
out = np.array([nan, nan, nan])
588599
assert_equal(np.minimum(arg1, arg2), out)
589600

601+
def test_object_nans(self):
602+
# Multiple checks to give this a chance to
603+
# fail if cmp is used instead of rich compare.
604+
# Failure cannot be guaranteed.
605+
for i in range(1):
606+
x = np.array(float('nan'), np.object)
607+
y = 1.0
608+
z = np.array(float('nan'), np.object)
609+
assert_(np.minimum(x, y) == 1.0)
610+
assert_(np.minimum(z, y) == 1.0)
611+
590612
def test_complex_nans(self):
591613
nan = np.nan
592614
for cnan in [complex(nan, 0), complex(0, nan), complex(nan, nan)] :

0 commit comments

Comments
 (0)
0