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

Suggestion: don't use import scipy as sp as a convention. #1

Open
WarrenWeckesser opened this issue May 7, 2018 · 1 comment
Open

Comments

@WarrenWeckesser
Copy link

WarrenWeckesser commented May 7, 2018

Nicolas, this looks like a fantastic book. Thanks for sharing it.

I have one suggestion. In the "Conventions" section of the Preface, you include

import scipy as sp

as one of the imports. In fact, there is almost never a good reason to do this. All the "good stuff" in scipy is in the subpackages, and these must be explicitly imported (e.g. import scipy.ndimage, or common variations such as from scipy import ndimage, import scipy.ndimage as ndi, etc.).

The top level scipy namespace imports names from numpy, so you could use names such as sp.array and sp.linspace, but a better style is to just use the numpy namespace for that. I think many SciPy and NumPy developers now think that importing all of numpy into the scipy namespace was an API mistake, and using the scipy namespace that way should be discouraged. The only reason I can think of for ever importing just the top level name scipy is to access the version as scipy.__version__, and that's not a sufficient reason for including its import in the conventions for your book. So you could (and probably should) drop the line import scipy as sp from your list of conventions.

@rougier
Copy link
Owner

rougier commented May 9, 2018

Thanks Warren. I realize that I never do it myself. I'll correct it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants