Skip to content

Commit

Permalink
BUG: umath: greater_equal ufunc was using the wrong type resolver, fa…
Browse files Browse the repository at this point in the history
…iled with datetime64

This bug was found by running the pandas master against numpy master.
  • Loading branch information
mwiebe committed May 7, 2012
1 parent d609dff commit 6c95a00
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/core/code_generators/generate_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def english_upper(s):
'greater_equal' :
Ufunc(2, 1, None,
docstrings.get('numpy.core.umath.greater_equal'),
None,
'PyUFunc_SimpleBinaryComparisonTypeResolver',
TD(all, out='?'),
),
'less' :
Expand Down
16 changes: 16 additions & 0 deletions numpy/core/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,22 @@ def test_datetime_divide(self):
# 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
Expand Down

0 comments on commit 6c95a00

Please sign in to comment.