-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST: Remove dupe TimdeltaIndex tests from indexes/timedeltas/test_astype.py #19509
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,36 +2,20 @@ | |||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
import numpy as np | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
import pandas as pd | ||||||||||||||||||||||||||||||||||||||||||
import pandas.util.testing as tm | ||||||||||||||||||||||||||||||||||||||||||
from pandas import (TimedeltaIndex, timedelta_range, Int64Index, Float64Index, | ||||||||||||||||||||||||||||||||||||||||||
Index, Timedelta) | ||||||||||||||||||||||||||||||||||||||||||
Index, Timedelta, NaT) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
from ..datetimelike import DatetimeLike | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
class TestTimedeltaIndex(DatetimeLike): | ||||||||||||||||||||||||||||||||||||||||||
_holder = TimedeltaIndex | ||||||||||||||||||||||||||||||||||||||||||
class TestTimedeltaIndex(object): | ||||||||||||||||||||||||||||||||||||||||||
_multiprocess_can_split_ = True | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def test_numeric_compat(self): | ||||||||||||||||||||||||||||||||||||||||||
# Dummy method to override super's version; this test is now done | ||||||||||||||||||||||||||||||||||||||||||
# in test_arithmetic.py | ||||||||||||||||||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def setup_method(self, method): | ||||||||||||||||||||||||||||||||||||||||||
self.indices = dict(index=tm.makeTimedeltaIndex(10)) | ||||||||||||||||||||||||||||||||||||||||||
self.setup_indices() | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def create_index(self): | ||||||||||||||||||||||||||||||||||||||||||
return pd.to_timedelta(range(5), unit='d') + pd.offsets.Hour(1) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def test_astype(self): | ||||||||||||||||||||||||||||||||||||||||||
# GH 13149, GH 13209 | ||||||||||||||||||||||||||||||||||||||||||
idx = TimedeltaIndex([1e14, 'NaT', pd.NaT, np.NaN]) | ||||||||||||||||||||||||||||||||||||||||||
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN]) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
result = idx.astype(object) | ||||||||||||||||||||||||||||||||||||||||||
expected = Index([Timedelta('1 days 03:46:40')] + [pd.NaT] * 3, | ||||||||||||||||||||||||||||||||||||||||||
expected = Index([Timedelta('1 days 03:46:40')] + [NaT] * 3, | ||||||||||||||||||||||||||||||||||||||||||
dtype=object) | ||||||||||||||||||||||||||||||||||||||||||
tm.assert_index_equal(result, expected) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
@@ -51,7 +35,7 @@ def test_astype(self): | |||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def test_astype_timedelta64(self): | ||||||||||||||||||||||||||||||||||||||||||
# GH 13149, GH 13209 | ||||||||||||||||||||||||||||||||||||||||||
idx = TimedeltaIndex([1e14, 'NaT', pd.NaT, np.NaN]) | ||||||||||||||||||||||||||||||||||||||||||
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN]) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
result = idx.astype('timedelta64') | ||||||||||||||||||||||||||||||||||||||||||
expected = Float64Index([1e+14] + [np.NaN] * 3, dtype='float64') | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -69,28 +53,7 @@ def test_astype_timedelta64(self): | |||||||||||||||||||||||||||||||||||||||||
float, 'datetime64', 'datetime64[ns]']) | ||||||||||||||||||||||||||||||||||||||||||
def test_astype_raises(self, dtype): | ||||||||||||||||||||||||||||||||||||||||||
# GH 13149, GH 13209 | ||||||||||||||||||||||||||||||||||||||||||
idx = TimedeltaIndex([1e14, 'NaT', pd.NaT, np.NaN]) | ||||||||||||||||||||||||||||||||||||||||||
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN]) | ||||||||||||||||||||||||||||||||||||||||||
msg = 'Cannot cast TimedeltaIndex to dtype' | ||||||||||||||||||||||||||||||||||||||||||
with tm.assert_raises_regex(TypeError, msg): | ||||||||||||||||||||||||||||||||||||||||||
idx.astype(dtype) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def test_pickle_compat_construction(self): | ||||||||||||||||||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def test_shift(self): | ||||||||||||||||||||||||||||||||||||||||||
# test shift for TimedeltaIndex | ||||||||||||||||||||||||||||||||||||||||||
# err8083 | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note that this same test is also in pandas/pandas/tests/indexes/timedeltas/test_timedelta.py Lines 35 to 36 in 69cd5fb
pandas/pandas/tests/indexes/timedeltas/test_arithmetic.py Lines 170 to 187 in 69cd5fb
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
drange = self.create_index() | ||||||||||||||||||||||||||||||||||||||||||
result = drange.shift(1) | ||||||||||||||||||||||||||||||||||||||||||
expected = TimedeltaIndex(['1 days 01:00:00', '2 days 01:00:00', | ||||||||||||||||||||||||||||||||||||||||||
'3 days 01:00:00', | ||||||||||||||||||||||||||||||||||||||||||
'4 days 01:00:00', '5 days 01:00:00'], | ||||||||||||||||||||||||||||||||||||||||||
freq='D') | ||||||||||||||||||||||||||||||||||||||||||
tm.assert_index_equal(result, expected) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
result = drange.shift(3, freq='2D 1s') | ||||||||||||||||||||||||||||||||||||||||||
expected = TimedeltaIndex(['6 days 01:00:03', '7 days 01:00:03', | ||||||||||||||||||||||||||||||||||||||||||
'8 days 01:00:03', '9 days 01:00:03', | ||||||||||||||||||||||||||||||||||||||||||
'10 days 01:00:03'], freq='D') | ||||||||||||||||||||||||||||||||||||||||||
tm.assert_index_equal(result, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove any of these
_multi precess_can_split
, they are really oldThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually let's do that separately.