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

import numpy as np #392

Closed
kain88-de opened this issue Aug 9, 2015 · 7 comments · Fixed by #421
Closed

import numpy as np #392

kain88-de opened this issue Aug 9, 2015 · 7 comments · Fixed by #421
Assignees
Milestone

Comments

@kain88-de
Copy link
Member

I've noticed that numpy is always imported with it's full name instead of the more standart import numpy as np. I'm incredibly used to that from other projects (anything in the python scientific stack) and my own code. I write np.<function i want to use> all the time and then wonder why my code-linter is lighting the line with an error. It would be nice to adopt the more standart import numpy as np in the whole library.

@mnmelo
Copy link
Member

mnmelo commented Aug 9, 2015

I for one also use numpy.function instead of the shorter standard, and was happy when saw MDAnalysis does the same.
I prefer the extra readability, and, of course, by now I'm too used to it to, so that weighs on my opinion too.

In any case, I do see it's a widespread standard, one which saves three keystrokes per function call, and I won't make much of a fuss if the majority of the devs vote to switch to that.

@tylerjereddy
Copy link
Member

I still use the explicit numpy.function fairly regularly in my own work. I always felt it was consistent with the explicit over implicit zen of python. That said, the shorthand is becoming something of a standard. I can see arguments both ways. When pandas is abbreviated as pd and scipy as sp and numpy as np, it can sometimes seem to get a little out of hand!

@hainm
Copy link
Contributor

hainm commented Aug 9, 2015

np is commonly used so I think it's fine to use it.

@dotsdl
Copy link
Member

dotsdl commented Aug 20, 2015

I am for this change as well. Unless there are objections, I suggest adding this to 0.12.

@dotsdl dotsdl added this to the 0.12 milestone Aug 20, 2015
@dotsdl dotsdl self-assigned this Aug 20, 2015
@richardjgowers
Copy link
Member

I think I've been changing numpy to np where I've been getting annoyed with long lines, so I guess I'm in favour.

I think it'd be good to make a wiki page with some sort of loose style guide which includes stuff like this.

@orbeckst orbeckst mentioned this issue Aug 28, 2015
11 tasks
@orbeckst
Copy link
Member

orbeckst commented Sep 8, 2015

There seems to be a consensus (or at least no fierce opposition) for using

import numpy as np

so let's do that.

While we are at it, we should probably also avoid direct imports of numpy objects

from numpy import sin, cos

and consistently use

import numpy as np
np.sin(...)

instead.

I don't think that any of the other major packages are used as extensively in MDAnalysis so I would prefer keeping long versions of scipy, biopython and friends. We might have used import networkx as nx somewhere, though, so I can't claim that everything is 100% consistent. if anyone has strong feelings about this, change it back to networkx ;-).

@kain88-de
Copy link
Member Author

@orbeckst

I started preparing a PR to change the usage of numpy consistently. I should be through with the revision of all changes today or tomorrow.

@orbeckst orbeckst assigned kain88-de and unassigned dotsdl Sep 8, 2015
kain88-de added a commit to kain88-de/mdanalysis that referenced this issue Sep 8, 2015
kain88-de added a commit to kain88-de/mdanalysis that referenced this issue Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants