-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix cases of inconsistent namespacing in tests #37838
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
Fix cases of inconsistent namespacing in tests #37838
Conversation
Sometimes e.g. Series and pd.Series are used in the same test file. This fixes some of these cases, generally by using the explicitly imported class.
pandas/tests/arithmetic/conftest.py
Outdated
@@ -82,7 +82,7 @@ def zero(request): | |||
-------- | |||
>>> arr = pd.RangeIndex(5) | |||
>>> arr / zeros | |||
Float64Index([nan, inf, inf, inf, inf], dtype='float64') | |||
pd.Float64Index([nan, inf, inf, inf, inf], dtype='float64') |
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 one needs to stay as it is because doctest
will check that the output matches the output from arr / zeros
, so for this file it's probably best to import Float64Index
at the top and then use that consistently (rather than using pd.Float64Index
)
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.
I've reverted this now, and imported Float64Index
directly (along with some other indexes used in the same place)
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.
Thanks @lpkirwin
@@ -2,6 +2,7 @@ | |||
import pytest | |||
|
|||
import pandas as pd | |||
from pandas import Float64Index, Int64Index, RangeIndex, UInt64Index |
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 is to be consistent with one of the docstrings, which uses Float64Index
rather than pd.Float64Index
so ideally we would add these to the pre-commit rules that checks this. these are likley inconsistent in more places. so this PR is ok, but would prefer that you change them across the entire codebase so that we are enforcing the rule. (and it may make sense to not change everything, e.g. do just Grouper, or just the Index ones). I am not sure how big a change this is. |
For context, this follows on from @dsaxton 's work on making the namespace using more consistent. Will modify the |
It's not too big, should get them done today along with the expanded CI check (see MarcoGorelli/PyDataGlobal2020-sprint#1 ) |
ok sounds great. feel free to merge these on green. |
Thanks @lpkirwin |
Sometimes e.g. Series and pd.Series are used
in the same test file. This fixes some of these
cases, generally by using the explicitly
imported class.
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff