Skip to content

CLN: unify numpy.random-related imports #37053

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

Closed
onshek opened this issue Oct 11, 2020 · 7 comments · Fixed by #37117 or #37492
Closed

CLN: unify numpy.random-related imports #37053

onshek opened this issue Oct 11, 2020 · 7 comments · Fixed by #37117 or #37492
Assignees
Labels
Clean Testing pandas testing functions or related to the test suite
Milestone

Comments

@onshek
Copy link
Contributor

onshek commented Oct 11, 2020

Location of the imports

import numpy as np
from numpy.random import randn

Imports problem

All numpy-related imports are only about numpy.random including randint, choice, normal, etc
Part of numpy.random-related imports use aliases

Suggested fix for imports

eg: import numpy as np
 && np.ranom.randn --> from numpy.random import randn
from numpy.random import randn --> import numpy as np
 && np.ranom.randn

@jreback
Copy link
Contributor

jreback commented Oct 11, 2020

yeah this would be fine to change
but if we do then pls implement a code_check to enforce this

@onshek
Copy link
Contributor Author

onshek commented Oct 12, 2020

yeah this would be fine to change
but if we do then pls implement a code_check to enforce this

Do you mean adding a new code_check to check the whole package instead of the single file?

@jreback
Copy link
Contributor

jreback commented Oct 12, 2020

yes see code_check.sh

@onshek
Copy link
Contributor Author

onshek commented Oct 13, 2020

take

@onshek onshek changed the title ENH: unify numpy-related imports in pandas/tests/plotting/test_hist_method.py ENH: unify numpy-related imports in pandas/tests/plotting Oct 13, 2020
@mroeschke
Copy link
Member

My 2 cents; I would actually prefer to standardize in the other direction.

i.e. use np.random.choice() directly instead of from np.random import choice; choice()

@jreback
Copy link
Contributor

jreback commented Oct 13, 2020

sorry i think i misread the top

we always want fully qualified things eg

np.random.randn

no aliases for these

@onshek
Copy link
Contributor Author

onshek commented Oct 14, 2020

Um...it seems I did the opposite. will be corrected later.

@onshek onshek changed the title ENH: unify numpy-related imports in pandas/tests/plotting ENH: unify numpy-related imports Oct 14, 2020
@onshek onshek changed the title ENH: unify numpy-related imports CLN: unify numpy-related imports Oct 14, 2020
@onshek onshek changed the title CLN: unify numpy-related imports CLN: unify numpy.random-related imports Oct 14, 2020
@jreback jreback added this to the 1.2 milestone Oct 30, 2020
@jreback jreback added the Testing pandas testing functions or related to the test suite label Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Testing pandas testing functions or related to the test suite
Projects
None yet
4 participants