
Introduction to NumPy - sebg
http://www.python-course.eu/numpy.php
======
kkuduk
Well, this is pretty basic stuff, for people interested a little bit more in
NumPy I recommend SciPy lectures: <http://scipy-
lectures.github.com/intro/numpy/index.html> [http://scipy-
lectures.github.com/advanced/advanced_numpy/ind...](http://scipy-
lectures.github.com/advanced/advanced_numpy/index.html)

~~~
jofer
At the moment, scipy-lectures is probably the best comprehensive introduction
to the scientific python ecosystem.

If you're looking for a more detailed overview of just numpy, the original
numpy book (<http://www.tramy.us/numpybook.pdf> ) is quite good, as well.

------
cgopalan
For people who are not satisfied with knowing just Numpy and want to delve
into its applications, I would recommend Wes McKinney's book "Python for data
analysis":

<http://shop.oreilly.com/product/0636920023784.do>

I have the book and its been great reading so far. Ch 4 gives a nice
introduction to Numpy (about 30 pages). Concise but also useful for immediate
real-world usage.

~~~
jofer
Beyond that, pandas (Wes McKinney's library that the book partly focuses on)
is really, really fantastic. It has rapidly become a central part of the
scientific python ecosystem.

------
mertd
\- First example is a bit unfair to vanilla python. A better implementation
would be the following, which is two times faster (than the given vanilla
example):

    
    
      from itertools import izip
    
      X = xrange(10000000)
      Y = xrange(10000000)
    
      Z = [x + y for x,y in izip(X,Y)]
    

\- You didn't mention the difference between flatten() and ravel(). flatten()
always makes an explicit copy, ravel() doesn't.

\- _"Arrays must have the same shape to be concatenated with concatenate()."_

Except for the concatenation axis obviously.

~~~
fijal
vanilla CPython to be precise. PyPy is drastically faster on stuff like that.

------
jlgreco
In my experience the best way to ramp up on NumPy is to just dive right in and
attempt to translate a modestly sized Matlab program to NumPy. The
documentation, at least as it was a year ago, seems more geared towards that
kind of learning

~~~
pekk
Out of curiosity, why not use Matlab?

~~~
nightski
Can't speak for him but personally I find Matlab to be rather expensive for
commercial use and it totally falls apart when you need to do anything outside
of numerical computation.

It is really nice having a full on general purpose programming language to use
right next to your scientific code.

~~~
jofer
Don't forget maintainability.

Anything moderately complex in matlab quickly becomes a maintainability
nightmare, in my experience. Matlab discourages modularity (functions have to
be either one line or in a separate file), and writing tests of any sort is
unnecessarily difficult in Matlab.

Beyond that, Numpy is remarkably clean once you know how to use it. How many
times do you see "tile" and "repmat" calls in matlab just to multiply two
matrices? Numpy's broadcasting is a simple but remarkably useful feature.

Finally, numpy gives you much tighter control over memory usage than matlab
does. This was actually the main reason I switched, personally. I didn't
realize how much I was missing for quite awhile.

~~~
apl

      > functions have to be either one line or in a separate file
    

Hasn't been true for a while now. You can have sub-routines and scope-local
functions within functions now; embedding a procedure within a script is, of
course, still impossible. So the situation has improved _ever_ so slightly...

~~~
jofer
Good point. I was thinking of lacking functions within scripts, which is quite
annoying for small projects, but not a major problem for larger things.

------
Schiphol
[Sage](sagemath.org) provides a very nice, unified approach to NumPy, SciPy,
Maxima, Octave (if it is installed), and most other open source mathematical
package -- with the very important exception of [Gambit](gambit-project.org).

