-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Implement maximally-specific/strict fixtures for arithmetic tests #23734
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
86f3810
implement tm.to_array, maximally-specific fixtures
jbrockmendel 375fdb4
Merge branch 'master' of https://github.com/pandas-dev/pandas into box
jbrockmendel f8a3988
implement box4b, box5b
jbrockmendel 27c2ce1
Merge branch 'master' of https://github.com/pandas-dev/pandas into box
jbrockmendel df74b6b
Merge branch 'master' of https://github.com/pandas-dev/pandas into box
jbrockmendel 9c07638
better names
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -5,9 +5,6 @@ | |
import pandas as pd | ||
|
||
from pandas.compat import long | ||
from pandas.core.arrays import ( | ||
PeriodArray, DatetimeArrayMixin as DatetimeArray, | ||
TimedeltaArrayMixin as TimedeltaArray) | ||
import pandas.util.testing as tm | ||
|
||
|
||
|
@@ -174,44 +171,64 @@ def box_df_fail(request): | |
return request.param | ||
|
||
|
||
@pytest.fixture(params=[(pd.Index, False), | ||
(pd.Series, False), | ||
@pytest.fixture(params=[pd.Index, | ||
pd.Series, | ||
(pd.DataFrame, False), | ||
pytest.param((pd.DataFrame, True), | ||
marks=pytest.mark.xfail(strict=True))], | ||
(pd.DataFrame, True), | ||
tm.to_array], | ||
ids=id_func) | ||
def box_transpose_fail(request): | ||
def box_and_transpose(request): | ||
""" | ||
Fixture similar to `box` but testing both transpose cases for DataFrame, | ||
with the tranpose=True case xfailed. | ||
Like `box4`, but the DataFrame case with box transpose=True and | ||
transpose=False | ||
""" | ||
# GH#23620 | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[pd.Index, pd.Series, pd.DataFrame, PeriodArray], | ||
@pytest.fixture(params=[pd.Index, | ||
pd.Series, | ||
(pd.DataFrame, False), | ||
pytest.param((pd.DataFrame, True), | ||
marks=pytest.mark.xfail(strict=True)), | ||
tm.to_array], | ||
ids=id_func) | ||
def box_with_period(request): | ||
def box_transpose_fail(request): | ||
""" | ||
Like `box`, but specific to PeriodDtype for also testing PeriodArray | ||
Like `box_and_transpose`, but xfailing the transposed DataFrame case | ||
""" | ||
# GH#23620 | ||
return request.param | ||
|
||
|
||
@pytest.fixture(params=[pd.Index, pd.Series, pd.DataFrame, DatetimeArray], | ||
ids=id_func) | ||
def box_with_datetime(request): | ||
""" | ||
Like `box`, but specific to datetime64 for also testing DatetimeArray | ||
""" | ||
return request.param | ||
# Construct tuples of the form (box, tz) over all our box classes and | ||
# the timezones in tz_naive_fixture. We then xfail the cases where the box | ||
# is a DataFrame-with-transpose and the timezone is not tz-naive (i.e. None) | ||
boxes = [pd.Index, | ||
pd.Series, | ||
(pd.DataFrame, False), | ||
(pd.DataFrame, True), | ||
tm.to_array] | ||
|
||
# copied from pandas.conftest tz_naive_fixture | ||
TIMEZONES = [None, 'UTC', 'US/Eastern', 'Asia/Tokyo', 'dateutil/US/Pacific', | ||
'dateutil/Asia/Singapore'] | ||
|
||
@pytest.fixture(params=[pd.Index, pd.Series, pd.DataFrame, TimedeltaArray], | ||
ids=id_func) | ||
def box_with_timedelta(request): | ||
params = [(x, y) for x in boxes for y in TIMEZONES] | ||
for n in range(len(params)): | ||
tup = params[n] | ||
if isinstance(tup[0], tuple) and tup[0][1] is True and tup[1] is not None: | ||
# i.e. (DataFrame, True, tzinfo) excluding the no-tzinfo case | ||
param = pytest.param(tup, marks=pytest.mark.xfail(strict=True)) | ||
params[n] = param | ||
|
||
|
||
@pytest.fixture(params=params) | ||
def box_transpose_and_tz(request): | ||
""" | ||
Like `box`, but specific to timedelta64 for also testing TimedeltaArray | ||
Fixture to test over Index, Series, DataFrame, and pandas Array, also | ||
providing timezones, xfailing timezone-aware cases with transposed | ||
DataFrame | ||
""" | ||
return request.param | ||
|
||
|
@@ -224,3 +241,8 @@ def box_with_array(request): | |
classes | ||
""" | ||
return request.param | ||
|
||
|
||
# aliases so we can use the same fixture twice in a test | ||
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 need self-obvious names |
||
box_with_array2 = box_with_array | ||
box_and_transpose2 = box_and_transpose |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
so my comment above was fairly general in nature. I don't think you need to test tz's other than [None, 'UTC'] or maybe use 'US/Eastern' rather than UTC to make sure that no times are shifted.
you actually just care if there IS a timezone or not.