8000 TST: Tests and Helpers for Datetime/Period Arrays by jbrockmendel · Pull Request #23502 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: Tests and Helpers for Datetime/Period Arrays #23502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 9, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
parametrize test
  • Loading branch information
jbrockmendel committed Nov 5, 2018
commit caedb95f5b756ef0b208f4de1dd398a117ec9f70
41 changes: 15 additions & 26 deletions pandas/tests/arrays/test_datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ class TestDatetimeArrayComparisons(object):
# TODO: merge this into tests/arithmetic/test_datetime64 once it is
# sufficiently robust

def test_cmp_dt64_arraylike_tznaive(self):
def test_cmp_dt64_arraylike_tznaive(self, all_compare_operators):
# arbitrary tz-naive DatetimeIndex
opname = all_compare_operators.strip('_')
op = getattr(operator, opname)

dti = pd.date_range('2016-01-1', freq='MS', periods=9, tz=None)
arr = DatetimeArray(dti)
assert arr.freq == dti.freq
Expand All @@ -24,31 +27,17 @@ def test_cmp_dt64_arraylike_tznaive(self):
right = dti

expected = np.ones(len(arr), dtype=bool)

for op in [operator.eq, operator.le, operator.ge]:
result = op(arr, arr)
if opname in ['ne', 'gt', 'lt']:
# for these the comparisons should be all-False
expected = ~expected

result = op(arr, arr)
tm.assert_numpy_array_equal(result, expected)
for other in [right, np.array(right)]:
# TODO: add list and tuple, and object-dtype once those
# are fixed in the constructor
result = op(arr, other)
tm.assert_numpy_array_equal(result, expected)
for other in [right, np.array(right)]:
# TODO: add list and tuple, and object-dtype once those
# are fixed in the constructor
result = op(arr, other)
tm.assert_numpy_array_equal(result, expected)

result = op(other, arr)
tm.assert_numpy_array_equal(result, expected)

# !=, <, >
expected = np.zeros(len(dti), dtype=bool)
tm.assert_numpy_array_equal(arr != arr, expected)

for op in [operator.ne, operator.lt, operator.gt]:
result = op(arr, arr)
result = op(other, arr)
tm.assert_numpy_array_equal(result, expected)
for other in [right, np.array(right)]:
# TODO: add list and tuple, and object-dtype once those
# are fixed in the constructor
result = op(arr, other)
tm.assert_numpy_array_equal(result, expected)

result = op(other, arr)
tm.assert_numpy_array_equal(result, expected)
0