Skip to content

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

Conversation

lpkirwin
Copy link
Contributor

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.

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Liam Kirwin added 2 commits November 14, 2020 17:46
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.
@@ -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')
Copy link
Member

@MarcoGorelli MarcoGorelli Nov 14, 2020

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)

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've reverted this now, and imported Float64Index directly (along with some other indexes used in the same place)

Copy link
Member

@MarcoGorelli MarcoGorelli left a 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
Copy link
Member

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

@jreback
Copy link
Contributor

jreback commented Nov 14, 2020

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.

@MarcoGorelli
Copy link
Member

For context, this follows on from @dsaxton 's work on making the namespace using more consistent. Will modify the scripts/check_for_inconsistent_pandas_namespace.py file accordingly once this and the rest of the fixes of these kind are in

@jreback jreback added the Code Style Code style, linting, code_checks label Nov 14, 2020
@MarcoGorelli
Copy link
Member

I am not sure how big a change this is.

It's not too big, should get them done today along with the expanded CI check (see MarcoGorelli/PyDataGlobal2020-sprint#1 )

@jreback
Copy link
Contributor

jreback commented Nov 14, 2020

I am not sure how big a change this is.

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.

@jreback jreback added this to the 1.2 milestone Nov 14, 2020
@MarcoGorelli
Copy link
Member

Thanks @lpkirwin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants