Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 259b6e3

Browse files
committed
MAINT: changes from review
1 parent d593826 commit 259b6e3

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

numpy/core/src/umath/loops.c.src

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,16 +1245,6 @@ NPY_NO_EXPORT void
12451245
}
12461246
}
12471247

1248-
1249-
NPY_NO_EXPORT void
1250-
@TYPE@_isnan(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
1251-
{
1252-
UNARY_LOOP {
1253-
const @type@ in1 = *(@type@ *)ip1;
1254-
*((npy_bool *)op1) = (in1 == NPY_DATETIME_NAT);
1255-
}
1256-
}
1257-
12581248
NPY_NO_EXPORT void
12591249
@TYPE@_isinf(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
12601250
{

numpy/core/src/umath/loops.h.src

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,7 @@ NPY_NO_EXPORT void
480480
NPY_NO_EXPORT void
481481
@TYPE@_isinf(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func));
482482

483-
NPY_NO_EXPORT void
484-
@TYPE@_isnan(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func));
483+
#define @TYPE@_isnan @TYPE@_isnat
485484

486485
NPY_NO_EXPORT void
487486
@TYPE@__ones_like(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(data));

numpy/core/tests/test_datetime.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,19 +2242,19 @@ def test_isfinite_scalar(self):
22422242

22432243
@pytest.mark.parametrize('unit', ['Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms',
22442244
'us', 'ns', 'ps', 'fs', 'as'])
2245-
def test_isxx_units(self, unit):
2245+
@pytest.mark.parametrize('dstr', ['<datetime64[%s]', '>datetime64[%s]',
2246+
'<timedelta64[%s]', '>timedelta64[%s]'])
2247+
def test_isfinite_isinf_isnan_units(self, unit, dstr):
22462248
'''check isfinite, isinf, isnan for all units of <M, >M, <m, >m dtypes
22472249
'''
22482250
arr_val = [123, -321, "NaT"]
2249-
dstr = ['<datetime64[%s]', '>datetime64[%s]',
2250-
'<timedelta64[%s]', '>timedelta64[%s]']
2251-
for arr in [np.array(arr_val, dtype= s % unit) for s in dstr]:
2252-
pos = np.array([True, True, False])
2253-
neg = np.array([False, False, True])
2254-
false = np.array([False, False, False])
2255-
assert_equal(np.isfinite(arr), pos)
2256-
assert_equal(np.isinf(arr), false)
2257-
assert_equal(np.isnan(arr), neg)
2251+
arr = np.array(arr_val, dtype= dstr % unit)
2252+
pos = np.array([True, True, False])
2253+
neg = np.array([False, False, True])
2254+
false = np.array([False, False, False])
2255+
assert_equal(np.isfinite(arr), pos)
2256+
assert_equal(np.isinf(arr), false)
2257+
assert_equal(np.isnan(arr), neg)
22582258

22592259
def test_corecursive_input(self):
22602260
# construct a co-recursive list

numpy/testing/_private/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ def assert_equal(actual, desired, err_msg='', verbose=True):
387387
raise AssertionError(msg)
388388

389389
except (TypeError, ValueError, NotImplementedError, DeprecationWarning):
390+
# version 1.18:
391+
# datetime64/timedelta64 used to raise since they had no isnan
392+
# implementation. Now they do, but raise a DeprecationWarning when
393+
# compared to 0. When that restriction is removed, they will still
394+
# raise an error when signbit is called.
390395
pass
391396

392397
try:

0 commit comments

Comments
 (0)