Skip to content

CLN: Remove unnecessary uses of pd. in tests #18277

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 2 commits into from
Nov 15, 2017

Conversation

jschendel
Copy link
Member

  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

  • Mostly edits along the lines of pd.Series -> Series for things that were already imported and had redundant uses of pd.

  • I cleaned some of the import statements, but I didn't import anything new, though that could be done in the future for further cleaning.

  • Was able to shorten some multi-line statements for a net deletion of ~100 lines without changing the content of any tests.

  • Only did the base level tests and tests/indexing so far.

@codecov
Copy link

codecov bot commented Nov 14, 2017

Codecov Report

Merging #18277 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18277      +/-   ##
==========================================
- Coverage    91.4%   91.38%   -0.02%     
==========================================
  Files         164      164              
  Lines       49878    49878              
==========================================
- Hits        45590    45581       -9     
- Misses       4288     4297       +9
Flag Coverage Δ
#multiple 89.19% <ø> (ø) ⬆️
#single 39.41% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.8% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69472f9...440e6ab. Read the comment docs.

@codecov
Copy link

codecov bot commented Nov 14, 2017

Codecov Report

Merging #18277 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18277      +/-   ##
==========================================
- Coverage    91.4%   91.38%   -0.02%     
==========================================
  Files         164      164              
  Lines       49880    49880              
==========================================
- Hits        45591    45583       -8     
- Misses       4289     4297       +8
Flag Coverage Δ
#multiple 89.19% <ø> (ø) ⬆️
#single 39.42% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.8% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.48% <0%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63e8527...92ddd5e. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

happy to take this (one small comment). Ideally we could add a linting test for these, something along the lines of (of course have to augment with things we check for, which would things like DataFrame, Index, etc.).

you could start off but explicity using just certain files / dirs for now (IOW as you do them).

you can put this after the np.testing checks
grep -r -E --include '*.py' 'pd\.Series' pandas/tests/

@@ -418,7 +415,7 @@ def test_mixed_integer_from_list(self):
def test_unsortable(self):
# GH 13714
arr = np.array([1, 2, datetime.now(), 0, 3], dtype=object)
if compat.PY2 and not pd._np_version_under1p10:
if compat.PY2 and not compat.numpy._np_version_under1p10:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would import _np_version.... directly up top

@jreback jreback added the Code Style Code style, linting, code_checks label Nov 14, 2017
@jreback jreback added this to the 0.22.0 milestone Nov 14, 2017
@jreback
Copy link
Contributor

jreback commented Nov 14, 2017

@jschendel just that one change is fine for now. the lint checks can be in a followup (or here if you can/want).

@jschendel jschendel force-pushed the remove-unnecessary-pd branch from 440e6ab to 92ddd5e Compare November 14, 2017 16:14
@jschendel
Copy link
Member Author

@jreback : made the one change. not familiar with the lint checks, so I'll hold off until a followup.

@jreback jreback merged commit fa4ebd4 into pandas-dev:master Nov 15, 2017
@jreback
Copy link
Contributor

jreback commented Nov 15, 2017

thanks @jschendel would love to come back with something that we can add to ci/lint.sh to check the codebase automatically.

@jschendel jschendel deleted the remove-unnecessary-pd branch November 16, 2017 00:20
@@ -1013,7 +1009,7 @@ def test_tab_complete_warning(self, ip):
pytest.importorskip('IPython', minversion="6.0.0")
from IPython.core.completer import provisionalcompleter

code = "import pandas as pd; c = pd.Categorical([])"
code = "import pandas as pd; c = Categorical([])"
Copy link
Member

Choose a reason for hiding this comment

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

@jschendel @jreback why is removing pd OK here? We have a couple tests with this pattern that look fishy to me, but they are passing on master so im confused

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