diff options
author | Stefan van der Walt <sjvdwalt@gmail.com> | 2012-05-07 16:19:47 -0700 |
---|---|---|
committer | Stefan van der Walt <sjvdwalt@gmail.com> | 2012-05-07 16:19:47 -0700 |
commit | 084eed79b7064d6e351281a75d0f0baecc6d851a (patch) | |
tree | 134ee3390abac160073c44697ddc463e54b7733e | |
parent | d609dffc97c024eb1c827a7da3e4f5098cf48b1e (diff) | |
parent | 6c95a007ad8f661e6ab0185a16e6782c7ba158d5 (diff) | |
download | numpy-084eed79b7064d6e351281a75d0f0baecc6d851a.tar.gz |
Merge pull request #272 from mwiebe/datetime64_compare
BUG: umath: greater_equal ufunc was using the wrong type resolver
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_datetime.py | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 7e8ed1d2b..2d8e4360e 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -387,7 +387,7 @@ defdict = { 'greater_equal' : Ufunc(2, 1, None, docstrings.get('numpy.core.umath.greater_equal'), - None, + 'PyUFunc_SimpleBinaryComparisonTypeResolver', TD(all, out='?'), ), 'less' : diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index 842bb9bc4..f062645d2 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -960,6 +960,22 @@ class TestDateTime(TestCase): # float / M8 assert_raises(TypeError, np.divide, 1.5, dta) + def test_datetime_compare(self): + # Test all the comparison operators + a = np.datetime64('2000-03-12T18:00:00.000000-0600') + b = np.array(['2000-03-12T18:00:00.000000-0600', + '2000-03-12T17:59:59.999999-0600', + '2000-03-12T18:00:00.000001-0600', + '1970-01-11T12:00:00.909090-0600', + '2016-01-11T12:00:00.909090-0600'], + dtype='datetime64[us]') + assert_equal(np.equal(a, b), [1, 0, 0, 0, 0]) + assert_equal(np.not_equal(a, b), [0, 1, 1, 1, 1]) + assert_equal(np.less(a, b), [0, 0, 1, 0, 1]) + assert_equal(np.less_equal(a, b), [1, 0, 1, 0, 1]) + assert_equal(np.greater(a, b), [0, 1, 0, 1, 0]) + assert_equal(np.greater_equal(a, b), [1, 1, 0, 1, 0]) + def test_datetime_minmax(self): # The metadata of the result should become the GCD # of the operand metadata |