[Numpy-discussion] Making NumPy accessible to everyone (or no-one) (was Numpy-discussion Digest, Vol 19, Issue 44)

Bruce Southey bsouthey@gmail....
Thu Apr 10 08:26:36 CDT 2008


Alexander Michael wrote:
> On Thu, Apr 10, 2008 at 6:55 AM, Stéfan van der Walt <stefan@sun.ac.za> wrote:
>   
>> Hi Joe, all
>>
>>  On 10/04/2008, Joe Harrington <jh@physics.ucf.edu> wrote:
>>  > > Absolutely.  Let's please standardize on:
>>  >  > import numpy as np
>>  >  > import scipy as sp
>>  >
>>  >  I hope we do NOT standardize on these abbreviations.  While a few may
>>  >  have discussed it at a sprint, it hasn't seen broad discussion and
>>  >  there are reasons to prefer the other practice (numpy as N, scipy as
>>  >  S, pylab as P).
>>
>>  "N" is a very unfortunate choice of abbreviation, given that so many
>>  algorithms use it to indicate the number of elements in things.  "np"
>>  is much safer and, like Jarrod mentioned, also only takes two keys to
>>  type.  Sebastian, a simple regexp replace should fix your problem
>>  (investment in hundreds of lines of N.* usage).
>>     
>
> Hey! I use np *all the time* as an abbreviation for "number of points". I don't
> really see what the problem is with using numpy.whatever in library code and
> published scripts and whatever you want in one-off throw-away scripts. It's easy
> to setup a shortcut key in almost any editor to alleviate the typing burden, if
> that is the main objection. If you have a section of an algorithm that you are
> trying to make look as much like text-book pseudocode as possible, than you
> can't do better than "from numpy import whatever" both for clarity and python
> coding convention. You can also say "d = numpy.dot" in the local scope at the
> top of your algorithm so you can write "d(x,y)" in the algorithm itself for very
> pithy code that doesn't require a FAQ to understand.
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>   
Hi,
I would prefer that the user has the choice and we have to remember that 
Python is dynamic typed. It is one thing to address experienced users 
but it takes time to get experienced. Also, some people may be just 
using some other code without knowing numpy is being used. That means 
users can  'import numpy as np' either directly or indirectly and 
somewhere further in their code entry 'np=1'. Python will be quite happy 
until the code wants a numpy function - a harsh but important lesson to 
learn.

Readability (and debugging) is another situation where numpy is more 
informative than np (which is better than N) especially if someone is 
not familiar with numpy.

Regards
Bruce



More information about the Numpy-discussion mailing list