-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: Collect/Use arithmetic test fixtures #22645
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
907cf59
4b254d2
d614598
247e7b8
d935afc
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 |
---|---|---|
|
@@ -28,14 +28,32 @@ def zero(request): | |
return request.param | ||
|
||
|
||
# ------------------------------------------------------------------ | ||
# Vector Fixtures | ||
|
||
@pytest.fixture(params=[pd.Float64Index(np.arange(5, dtype='float64')), | ||
pd.Int64Index(np.arange(5, dtype='int64')), | ||
pd.UInt64Index(np.arange(5, dtype='uint64'))], | ||
pd.UInt64Index(np.arange(5, dtype='uint64')), | ||
pd.RangeIndex(5)], | ||
ids=lambda x: type(x).__name__) | ||
def idx(request): | ||
def numeric_idx(request): | ||
""" | ||
Several types of numeric-dtypes Index objects | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture | ||
def tdser(): | ||
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. should conform / rename these at some point (e.g. have been using: timedelta_series) for something like this |
||
""" | ||
Return a Series with dtype='timedelta64[ns]', including a NaT. | ||
""" | ||
return pd.Series(['59 Days', '59 Days', 'NaT'], dtype='timedelta64[ns]') | ||
|
||
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. these 2 fixtures should be pushed up to pandas/conftest.py as well |
||
|
||
# ------------------------------------------------------------------ | ||
# Scalar Fixtures | ||
|
||
@pytest.fixture(params=[pd.Timedelta('5m4s').to_pytimedelta(), | ||
pd.Timedelta('5m4s'), | ||
pd.Timedelta('5m4s').to_timedelta64()], | ||
|
@@ -47,6 +65,72 @@ def scalar_td(request): | |
return request.param | ||
|
||
|
||
@pytest.fixture(params=[pd.offsets.Day(3), | ||
pd.offsets.Hour(72), | ||
pd.Timedelta(days=3).to_pytimedelta(), | ||
pd.Timedelta('72:00:00'), | ||
np.timedelta64(3, 'D'), | ||
np.timedelta64(72, 'h')]) | ||
def three_days(request): | ||
""" | ||
Several timedelta-like and DateOffset objects that each represent | ||
a 3-day timedelta | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[pd.offsets.Hour(2), | ||
pd.offsets.Minute(120), | ||
pd.Timedelta(hours=2).to_pytimedelta(), | ||
pd.Timedelta(seconds=2 * 3600), | ||
np.timedelta64(2, 'h'), | ||
np.timedelta64(120, 'm')]) | ||
def two_hours(request): | ||
""" | ||
Several timedelta-like and DateOffset objects that each represent | ||
a 2-hour timedelta | ||
""" | ||
return request.param | ||
|
||
|
||
_common_mismatch = [pd.offsets.YearBegin(2), | ||
pd.offsets.MonthBegin(1), | ||
pd.offsets.Minute()] | ||
|
||
|
||
@pytest.fixture(params=[pd.Timedelta(minutes=30).to_pytimedelta(), | ||
np.timedelta64(30, 's'), | ||
pd.Timedelta(seconds=30)] + _common_mismatch) | ||
def not_hourly(request): | ||
""" | ||
Several timedelta-like and DateOffset instances that are _not_ | ||
compatible with Hourly frequencies. | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[np.timedelta64(4, 'h'), | ||
pd.Timedelta(hours=23).to_pytimedelta(), | ||
pd.Timedelta('23:00:00')] + _common_mismatch) | ||
def not_daily(request): | ||
""" | ||
Several timedelta-like and DateOffset instances that are _not_ | ||
compatible with Daily frequencies. | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[np.timedelta64(365, 'D'), | ||
pd.Timedelta(days=365).to_pytimedelta(), | ||
pd.Timedelta(days=365)] + _common_mismatch) | ||
def mismatched_freq(request): | ||
""" | ||
Several timedelta-like and DateOffset instances that are _not_ | ||
compatible with Monthly or Annual frequencies. | ||
""" | ||
return request.param | ||
|
||
|
||
# ------------------------------------------------------------------ | ||
|
||
@pytest.fixture(params=[pd.Index, pd.Series, pd.DataFrame], | ||
|
@@ -59,6 +143,18 @@ def box(request): | |
return request.param | ||
|
||
|
||
@pytest.fixture(params=[pd.Index, | ||
pd.Series, | ||
pytest.param(pd.DataFrame, | ||
marks=pytest.mark.xfail(strict=True))], | ||
ids=lambda x: x.__name__) | ||
def box_df_fail(request): | ||
""" | ||
Fixture equivalent to `box` fixture but xfailing the DataFrame case. | ||
""" | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[ | ||
pd.Index, | ||
pd.Series, | ||
|
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.
numeric_index (can be future PR)