Skip to content

Commit c2adaf7

Browse files
jschendelharisbal
authored and
harisbal
committed
TST: Remove duplicate TimdeltaIndex tests (pandas-dev#19509)
1 parent da6f51e commit c2adaf7

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

pandas/tests/indexes/timedeltas/test_astype.py

+6-43
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,20 @@
22

33
import numpy as np
44

5-
import pandas as pd
65
import pandas.util.testing as tm
76
from pandas import (TimedeltaIndex, timedelta_range, Int64Index, Float64Index,
8-
Index, Timedelta)
7+
Index, Timedelta, NaT)
98

10-
from ..datetimelike import DatetimeLike
119

12-
13-
class TestTimedeltaIndex(DatetimeLike):
14-
_holder = TimedeltaIndex
10+
class TestTimedeltaIndex(object):
1511
_multiprocess_can_split_ = True
1612

17-
def test_numeric_compat(self):
18-
# Dummy method to override super's version; this test is now done
19-
# in test_arithmetic.py
20-
pass
21-
22-
def setup_method(self, method):
23-
self.indices = dict(index=tm.makeTimedeltaIndex(10))
24-
self.setup_indices()
25-
26-
def create_index(self):
27-
return pd.to_timedelta(range(5), unit='d') + pd.offsets.Hour(1)
28-
2913
def test_astype(self):
3014
# GH 13149, GH 13209
31-
idx = TimedeltaIndex([1e14, 'NaT', pd.NaT, np.NaN])
15+
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN])
3216

3317
result = idx.astype(object)
34-
expected = Index([Timedelta('1 days 03:46:40')] + [pd.NaT] * 3,
18+
expected = Index([Timedelta('1 days 03:46:40')] + [NaT] * 3,
3519
dtype=object)
3620
tm.assert_index_equal(result, expected)
3721

@@ -51,7 +35,7 @@ def test_astype(self):
5135

5236
def test_astype_timedelta64(self):
5337
# GH 13149, GH 13209
54-
idx = TimedeltaIndex([1e14, 'NaT', pd.NaT, np.NaN])
38+
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN])
5539

5640
result = idx.astype('timedelta64')
5741
expected = Float64Index([1e+14] + [np.NaN] * 3, dtype='float64')
@@ -69,28 +53,7 @@ def test_astype_timedelta64(self):
6953
float, 'datetime64', 'datetime64[ns]'])
7054
def test_astype_raises(self, dtype):
7155
# GH 13149, GH 13209
72-
idx = TimedeltaIndex([1e14, 'NaT', pd.NaT, np.NaN])
56+
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN])
7357
msg = 'Cannot cast TimedeltaIndex to dtype'
7458
with tm.assert_raises_regex(TypeError, msg):
7559
idx.astype(dtype)
76-
77-
def test_pickle_compat_construction(self):
78-
pass
79-
80-
def test_shift(self):
81-
# test shift for TimedeltaIndex
82-
# err8083
83-
84-
drange = self.create_index()
85-
result = drange.shift(1)
86-
expected = TimedeltaIndex(['1 days 01:00:00', '2 days 01:00:00',
87-
'3 days 01:00:00',
88-
'4 days 01:00:00', '5 days 01:00:00'],
89-
freq='D')
90-
tm.assert_index_equal(result, expected)
91-
92-
result = drange.shift(3, freq='2D 1s')
93-
expected = TimedeltaIndex(['6 days 01:00:03', '7 days 01:00:03',
94-
'8 days 01:00:03', '9 days 01:00:03',
95-
'10 days 01:00:03'], freq='D')
96-
tm.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)