7

Possible Duplicate:
Relationship between scipy and numpy

For instance, NumPy has window functions bartlett, blackman, hamming, hanning, kaiser, while SciPy has these and several more, but they seem to produce identical output.

NumPy has numpy.fft.fft2(a, s=None, axes=(-2, -1)).

SciPy has scipy.fftpack.fft2(x, shape=None, axes=(-2, -1), overwrite_x=0).

Why are there duplicates? Just for backwards compatibility? If so, why are they defined differently in different places? Which should I prefer when writing something new?

Community
  • 1
  • 1
endolith
  • 25,479
  • 34
  • 128
  • 192
  • 5
    Please see http://stackoverflow.com/questions/6200910/relationship-between-scipy-and-numpy – NPE May 26 '12 at 12:10
  • @aix: This isn't about numpy functions transcluded into scipy. It's about stuff that exists independently in both, and my questions aren't answered by those answers – endolith May 26 '12 at 15:29

1 Answers1

20

From the SciPy FAQ:

In an ideal world, NumPy would contain nothing but the array data type and the most basic operations: indexing, sorting, reshaping, basic elementwise functions, et cetera. All numerical code would reside in SciPy. However, one of NumPy’s important goals is compatibility, so NumPy tries to retain all features supported by either of its predecessors. Thus NumPy contains some linear algebra functions, even though these more properly belong in SciPy. In any case, SciPy contains more fully-featured versions of the linear algebra modules, as well as many other numerical algorithms. If you are doing scientific computing with python, you should probably install both NumPy and SciPy. Most new features belong in SciPy rather than NumPy.

So yes, the duplicates are for backwards compatibility. In general, they give the same result. However, as the FAQ states, new features are usually implemented into SciPy, but not necessarily NumPy. This includes bug fixes. I have found, for example, that numpy.linalg.eig returned incorrect eigenvalues for a complex matrix, whereas scipy.linalg.eig returned correct ones.

In general, I prefer stick with the "ideal world" scenario from the FAQ: I use NumPy for the basic array manipulations, and SciPy for all my linear algebra. This way I don't run into any surprises.

gökçe
  • 23
  • 5
SethMMorton
  • 45,752
  • 12
  • 65
  • 86