Skip to content
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

TST: tests for maybe_promote (precursor to #23982) #25637

Merged
merged 26 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ca8f96b
TST: tests for maybe_promote (precursor to #23982)
h-vetinari Feb 24, 2019
a881929
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari May 13, 2019
e14d8a2
Fix tabs vs. spaces
h-vetinari May 13, 2019
bc10a87
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari May 14, 2019
ab328c0
fix conftest
h-vetinari May 14, 2019
80d4081
more conftest merge conflict artefact fixes
h-vetinari May 14, 2019
4a2327c
lint
h-vetinari May 14, 2019
a205ea9
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari May 30, 2019
79299af
Review (jreback)
h-vetinari May 30, 2019
1b18fde
Add docstring to _check_promote
h-vetinari May 30, 2019
ff3be04
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari May 31, 2019
9fec7f9
doc improvements
h-vetinari May 31, 2019
bf8c02d
fix c&p artefact
h-vetinari May 31, 2019
595012c
Introduce parametrized fixture for box-variants; override where required
h-vetinari May 31, 2019
f89e8b4
improve docstring for box-fixture
h-vetinari May 31, 2019
4317f77
fix comments
h-vetinari May 31, 2019
c0b4a3f
fix fixture docstrings
h-vetinari May 31, 2019
d6001a7
docstring updates
h-vetinari May 31, 2019
f73740b
add ids for box-fixture
h-vetinari Jun 1, 2019
895fcb5
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari Jun 1, 2019
200365e
lint
h-vetinari Jun 1, 2019
bb36925
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari Jun 5, 2019
a97d29b
break out function to make _check_promote even more branchless
h-vetinari Jun 5, 2019
8c982f2
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari Jun 10, 2019
a1add65
Refactor with reduced any_numpy_dtype fixture (review jreback)
h-vetinari Jun 10, 2019
636b1f1
Merge remote-tracking branch 'upstream/master' into tst_maybe_promote…
h-vetinari Jun 21, 2019
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
65 changes: 58 additions & 7 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,28 +367,39 @@ def unique_nulls_fixture(request):
TIMEZONES = [None, 'UTC', 'US/Eastern', 'Asia/Tokyo', 'dateutil/US/Pacific',
'dateutil/Asia/Singapore', tzutc(), tzlocal(), FixedOffset(300),
FixedOffset(0), FixedOffset(-300)]
TIMEZONE_IDS = ['None', 'UTC', 'US/Eastern', 'Asia/Tokyp',
'dateutil/US/Pacific', 'dateutil/Asia/Singapore',
'dateutil.tz.tzutz()', 'dateutil.tz.tzlocal()',
'pytz.FixedOffset(300)', 'pytz.FixedOffset(0)',
'pytz.FixedOffset(-300)']


@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}
"""
return request.param


# Generate cartesian product of tz_aware_fixture:
tz_aware_fixture2 = tz_aware_fixture


# ----------------------------------------------------------------
# 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 @@ -400,16 +411,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]']
Copy link
Member

Choose a reason for hiding this comment

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

Rationale for renames?

Is this necessary given how massive the diff is already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can split off the conftest-related things, of course.

Regarding your specific point: The rename is really important IMO, because the DATETIME_DTYPES (as-is) have nothing to do with datetime.dateime or other such things.

However, when reading a test that is being fed by a datetime_dtype fixture, one could easily think that this tests datetime.datetime.

The current state in conftest specifically contains only DATETIME64_DTYPES, and I believe this distinction is used in many parts of the code base as well.

Copy link
Member

@gfyoung gfyoung May 31, 2019

Choose a reason for hiding this comment

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

Got it. I'm thinking that we should separate this out. The more we can condense this PR, the better.

But hold off on making that PR for the moment (just one more question re: some of other things you've changed for conftest.py)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can change the DATETIME_DTYPES -> DATETIME64_DTYPES in a precursor of course, but the actual change that precipitates the necessity is the introduction of datetime64_dtype, which wouldn't be used before this PR. Would you want me to introduce the fixtures with the conftest-precursor, or in this PR?


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 * PY3) # bytes only for PY3


Expand All @@ -424,6 +435,46 @@ def string_dtype(request):
return request.param


@pytest.fixture(params=BYTES_DTYPES)
def bytes_dtype(request):
"""Parametrized fixture for bytes dtypes.

* bytes
* 'bytes'
"""
return request.param


@pytest.fixture(params=OBJECT_DTYPES)
def object_dtype(request):
"""Parametrized fixture for object dtypes.

* object
* 'object'
"""
return request.param


@pytest.fixture(params=DATETIME64_DTYPES)
def datetime64_dtype(request):
"""Parametrized fixture for datetime/timedelta dtypes.

* 'datetime64[ns]'
* 'M8[ns]'
"""
return request.param


@pytest.fixture(params=TIMEDELTA64_DTYPES)
def timedelta64_dtype(request):
"""Parametrized fixture for datetime/timedelta dtypes.

* 'timedelta64[ns]'
* 'm8[ns]'
"""
return request.param


@pytest.fixture(params=FLOAT_DTYPES)
def float_dtype(request):
"""
Expand Down
Loading