forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Tests and Helpers for Datetime/Period Arrays (pandas-dev#23502)
- Loading branch information
1 parent
1ef6cac
commit a67987b
Showing
12 changed files
with
132 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Tests for DatetimeArray | ||
""" | ||
import operator | ||
|
||
import numpy as np | ||
|
||
import pandas as pd | ||
from pandas.core.arrays import DatetimeArrayMixin as DatetimeArray | ||
import pandas.util.testing as tm | ||
|
||
|
||
class TestDatetimeArrayComparisons(object): | ||
# TODO: merge this into tests/arithmetic/test_datetime64 once it is | ||
# sufficiently robust | ||
|
||
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 | ||
assert arr.tz == dti.tz | ||
|
||
right = dti | ||
|
||
expected = np.ones(len(arr), dtype=bool) | ||
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) | ||
|
||
result = op(other, arr) | ||
tm.assert_numpy_array_equal(result, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters