Numerical Python FAQ

Why Numerical Python?

If x and y are Numerical Python arrays, then the speed of the operation x + y is close to the speed of doing it in C if the arrays are big enough. Thus, Python can be extended with a full scientific array language with sophisticated indexing and shaping operations and yet be closer to the speed of a compiled language than to the speed of Python itself.

Assignment doesn't make a copy?

Right. The statement y=x just creates a new name for the same array object. While consistent with Python, this is upsetting to users of other array languages. Likewise, x[i:j] is not a copy. Please read the manual.

Why do I get an error using comparison operators?

In the past, == and != silently gave a wrong answer. Now it is an error. Some people believe == should return array results as >=, >, <, and <= do if used with Python 2.1 or later. However, we have decided not to do this because x == y is frequently misleading with floating-point arrays, and == is often (mistakenly) used both in that sense and in the sense of "is". See the function allclose for comparing integer or floating arrays and getting a single true or false result. See the functions equal and not_equal for array results.

To compare an Numeric array x with None, use x is None or x is not None.

Note that x > y does not mean "true if all x are greater than all y"; it returns an array of 1's and 0's.

The Modulus Operator isn't the same as Python's

>>> array([-1])%3
array([-1])

compare this to python's number implementation
>>> -1%3
2

The modulus operator (%) uses the C rules for negative arguments, not the new Python rules. This was done for speed originally. Although it might be desirable to change it, it would break existing code.

How do I create Numpy arrays in C extensions?

Please read the fine manual, which has a lengthy section on this topic. You will not get anything to work if you don't. You need to know the secret handshake to get access to the Numeric C API. 

I get an error message about n32 / o32 on SGI

A numpy user who ran into this consulted Martin von Loewe. The user said, "It is indeed an SGI thing, two different (perhaps n/o for new/old) binary formats for files, libraries, etc; both formats are supported by IRIX64. The KEY hint from Martin von Loewe (for installing Python2.0) was that usually all libraries are installed in both versions, so all I had to do was to find "siblings" of those libs that did not work, and link them to the names that python expected. "

What about dealing with missing observations?

An optional package "MA", distributed with Numpy and documented in the manual, is designed to be an almost drop-in replacement for Numeric, allowing you to do operations and function calls without involving array entries that are invalid, including sums, averages, division, etc. Note that MA differs from Numpy in that slices are copies, not references.

How do I install on Windows?

The zip files on Windows are source file distributions and require you to have a C compiler. Follow the directions in the top level README after you unpack it.

The .exe files are  Windows installers of the sort that you are used to; but if you want the full set of optional packages you need to download the entire set of .exe files, one for each of the additional packages.  Some of the optional packages depend on other ones.

How do I install on MacIntosh?

Installing from source on a MacIntosh now works. The setup_all script will work starting with 20.1.1. For now you have to do the extra packages separately.

How do I become a "developer"?

Write to one of the current developers and describe your experience and interests. The current developers act as a committee of equal peers and will discuss your request. Paul Dubois (dubois at users.sourceforge.net) serves as the chairperson of this group and has veto power over requests for enhancements.

There are different communities of users with different goals and aspirations. To keep Numerical as useful as possible to as many people as possible, we are taking a conservative approach to growth, applying Bertrand Meyer's famous hope for Eiffel that it would "grow no faster than the rate of inflation."