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.
np.lookfor('create array')
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.
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.
The big reason though is that I was trying to use it "in production" with MCC and it just really wasn't up for the task. It became a nightmare to debug and had major stability issues; I couldn't keep it running for more than a few hours. The logged errors were cryptic null-pointer exceptions from deep down the stack and the input that caused those conditions would run fine upon restarting the process. A real nightmare to deal with.
Eventually I realized that I'd spent a solid two days worth of work trying to fix it with no end in sight and decided that splitting off all the logic into a twisted service wrapping NumPy could be done in less time than I was probably going to continue spending messing with Matlab/MCC. Took about a day to do that, and mostly because some of the math was slightly beyond me so I had to use some significant caution.
Ran like a dream after that for months.
* language features are mostly about matrix manipulation
* OO and functional programming are rudimentary at best
* you will avoid newer features because they are buggy and your colleagues will probably have older versions anyway.
* you might dislike the crashing IDE
* MATLAB is essentially a niche language compared to the universality of python.
The reasons to use Matlab: * your program structure is going to be simple probably a single algorithm applied to many matrices or a few files(streams)
* toolboxes
* toolboxes
* toolboxes
* Simulink
Matlab is also not open source and rather expensive. There is GNU Octave which is free and mostly compatible with Matlab.
It is really nice having a full on general purpose programming language to use right next to your scientific code.
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.
> 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...