Skip to content

TST: prepare conftest for #25637 #26596

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

Merged
merged 3 commits into from
Jun 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,19 +376,25 @@ def unique_nulls_fixture(request):
FixedOffset(0), FixedOffset(-300), timezone.utc,
timezone(timedelta(hours=1)),
timezone(timedelta(hours=-1), name='foo')]
TIMEZONE_IDS = ['None', 'UTC', 'US/Eastern', 'Asia/Tokyp',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls don’t merge things until i look

this is duplicating too much code here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the point of of these extras?

Copy link
Member

@gfyoung gfyoung Jun 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback : This is carried over from #25637 (and I think a lot of other conversations in other PR's), and the justification was given as a link in the PR description. I leave it here below for convenience:

#25637 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe so but that other has not been reviewed at all

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not done in a nice way

these should simply be tuples of timezone and id and unpacked when needed

can u do a PR to fix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and to be honest these may not even be needed to do it like this it’s a lot more verbose

Copy link
Member

@gfyoung gfyoung Jun 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unpacking option seems to overcomplicate as you mentioned. Alternatively, we can just do a list comprehension and pull the __repr__ (or __str__) on the elements of TIMEZONES. That would still keep the IDs but be less "duplicative".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i think a nice function would be fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback: this is not done in a nice way

I disagree. Compare the outputs of @gfyoung's PR with the state I introduced.

I made the IDs explicit precisely because the strs/reprs yields a useless, ugly mix of stuff. Saving these 4 lines is not worth the added hassle when actually debugging tz-tests with pytest -v.

'dateutil/US/Pacific', 'dateutil/Asia/Singapore',
'dateutil.tz.tzutz()', 'dateutil.tz.tzlocal()',
'pytz.FixedOffset(300)', 'pytz.FixedOffset(0)',
'pytz.FixedOffset(-300)', 'datetime.timezone.utc',
'datetime.timezone.+1', 'datetime.timezone.-1.named']


@td.parametrize_fixture_doc(str(TIMEZONES))
@pytest.fixture(params=TIMEZONES)
@td.parametrize_fixture_doc(str(TIMEZONE_IDS))
@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS)
def tz_naive_fixture(request):
"""
Fixture for trying timezones including default (None): {0}
"""
return request.param


@td.parametrize_fixture_doc(str(TIMEZONES[1:]))
@pytest.fixture(params=TIMEZONES[1:])
@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:]))
@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:])
def tz_aware_fixture(request):
"""
Fixture for trying explicit timezones: {0}
Expand All @@ -398,6 +404,8 @@ def tz_aware_fixture(request):

# ----------------------------------------------------------------
# Dtypes
# ----------------------------------------------------------------

UNSIGNED_INT_DTYPES = ["uint8", "uint16", "uint32", "uint64"]
UNSIGNED_EA_INT_DTYPES = ["UInt8", "UInt16", "UInt32", "UInt64"]
SIGNED_INT_DTYPES = [int, "int8", "int16", "int32", "int64"]
Expand All @@ -409,16 +417,16 @@ def tz_aware_fixture(request):
COMPLEX_DTYPES = [complex, "complex64", "complex128"]
STRING_DTYPES = [str, 'str', 'U']

DATETIME_DTYPES = ['datetime64[ns]', 'M8[ns]']
TIMEDELTA_DTYPES = ['timedelta64[ns]', 'm8[ns]']
DATETIME64_DTYPES = ['datetime64[ns]', 'M8[ns]']
TIMEDELTA64_DTYPES = ['timedelta64[ns]', 'm8[ns]']

BOOL_DTYPES = [bool, 'bool']
BYTES_DTYPES = [bytes, 'bytes']
OBJECT_DTYPES = [object, 'object']

ALL_REAL_DTYPES = FLOAT_DTYPES + ALL_INT_DTYPES
ALL_NUMPY_DTYPES = (ALL_REAL_DTYPES + COMPLEX_DTYPES + STRING_DTYPES +
DATETIME_DTYPES + TIMEDELTA_DTYPES + BOOL_DTYPES +
DATETIME64_DTYPES + TIMEDELTA64_DTYPES + BOOL_DTYPES +
OBJECT_DTYPES + BYTES_DTYPES)


Expand Down