-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Refactor pandas/tests/base - part3 #30147
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 19 commits
4d1750c
3d04ff2
89d84b4
199896f
e269b09
baab827
28291f1
589ae3b
2bbc3fd
b3d0252
53db63f
891b24c
8f0fdf6
69a0a0d
0fce4c5
b7892fa
471f217
baa4965
7562479
85b16cb
87e0a5b
3979b3d
452335a
8bf1142
c1e9f28
d9bea94
87247a5
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 |
---|---|---|
|
@@ -7,37 +7,16 @@ | |
from pandas.core.dtypes.generic import ABCDateOffset | ||
|
||
import pandas as pd | ||
from pandas import ( | ||
DatetimeIndex, | ||
Index, | ||
PeriodIndex, | ||
Series, | ||
Timestamp, | ||
bdate_range, | ||
date_range, | ||
) | ||
from pandas import DatetimeIndex, Index, Series, Timestamp, bdate_range, date_range | ||
import pandas._testing as tm | ||
from pandas.tests.base.test_ops import Ops | ||
|
||
from pandas.tseries.offsets import BDay, BMonthEnd, CDay, Day, Hour | ||
|
||
START, END = datetime(2009, 1, 1), datetime(2010, 1, 1) | ||
|
||
|
||
class TestDatetimeIndexOps(Ops): | ||
def setup_method(self, method): | ||
super().setup_method(method) | ||
mask = lambda x: (isinstance(x, DatetimeIndex) or isinstance(x, PeriodIndex)) | ||
self.is_valid_objs = [o for o in self.objs if mask(o)] | ||
self.not_valid_objs = [o for o in self.objs if not mask(o)] | ||
|
||
def test_ops_properties(self): | ||
f = lambda x: isinstance(x, DatetimeIndex) | ||
self.check_ops_properties(DatetimeIndex._field_ops, f) | ||
self.check_ops_properties(DatetimeIndex._object_ops, f) | ||
self.check_ops_properties(DatetimeIndex._bool_ops, f) | ||
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. Already tested in 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. Good catch. test_dt_namespace_accessor could use a good refactor if youre up to it (separate PR) |
||
|
||
def test_ops_properties_basic(self): | ||
class TestDatetimeIndexOps: | ||
def test_ops_properties_basic(self, datetime_series): | ||
|
||
# sanity check that the behavior didn't change | ||
# GH#7206 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,11 @@ | |
import pytest | ||
|
||
import pandas as pd | ||
from pandas import DatetimeIndex, Index, NaT, PeriodIndex, Series | ||
from pandas import Index, NaT, PeriodIndex, Series | ||
import pandas._testing as tm | ||
from pandas.core.arrays import PeriodArray | ||
from pandas.tests.base.test_ops import Ops | ||
|
||
|
||
class TestPeriodIndexOps(Ops): | ||
def setup_method(self, method): | ||
super().setup_method(method) | ||
mask = lambda x: (isinstance(x, DatetimeIndex) or isinstance(x, PeriodIndex)) | ||
self.is_valid_objs = [o for o in self.objs if mask(o)] | ||
self.not_valid_objs = [o for o in self.objs if not mask(o)] | ||
|
||
def test_ops_properties(self): | ||
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. Already tested in |
||
f = lambda x: isinstance(x, PeriodIndex) | ||
self.check_ops_properties(PeriodArray._field_ops, f) | ||
self.check_ops_properties(PeriodArray._object_ops, f) | ||
self.check_ops_properties(PeriodArray._bool_ops, f) | ||
|
||
class TestPeriodIndexOps: | ||
def test_resolution(self): | ||
for freq, expected in zip( | ||
["A", "Q", "M", "D", "H", "T", "S", "L", "U"], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,13 @@ | |
import pandas as pd | ||
from pandas import Series, TimedeltaIndex, timedelta_range | ||
import pandas._testing as tm | ||
from pandas.tests.base.test_ops import Ops | ||
|
||
from pandas.tseries.offsets import Day, Hour | ||
|
||
|
||
class TestTimedeltaIndexOps(Ops): | ||
def setup_method(self, method): | ||
super().setup_method(method) | ||
mask = lambda x: isinstance(x, TimedeltaIndex) | ||
self.is_valid_objs = [o for o in self.objs if mask(o)] | ||
self.not_valid_objs = [] | ||
|
||
def test_ops_properties(self): | ||
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. Already tested in |
||
f = lambda x: isinstance(x, TimedeltaIndex) | ||
self.check_ops_properties(TimedeltaIndex._field_ops, f) | ||
self.check_ops_properties(TimedeltaIndex._object_ops, f) | ||
|
||
class TestTimedeltaIndexOps: | ||
def test_value_counts_unique(self): | ||
# GH 7735 | ||
|
||
idx = timedelta_range("1 days 09:00:00", freq="H", periods=10) | ||
# create repeated values, 'n'th element is repeated by n+1 times | ||
idx = TimedeltaIndex(np.repeat(idx.values, range(1, len(idx) + 1))) | ||
|
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.
This method was only used in pandas/tests/indexes. I could remove all tests where it was used though as they were redundant (already tested in
pandas/tests/series/test_datetime_values.py::test_dt_namespace_accessor
)