[Numpy-discussion] [SciPy-Dev] Hamming etc. windows are wrong

Robert Kern robert.kern at gmail.com
Sat Sep 27 06:37:12 EDT 2014


On Sat, Sep 27, 2014 at 1:10 AM, Jerry <lanceboyle at qwest.net> wrote:

> I don't recall what I had imported, but probably scipy, as in "import
> scipy", or maybe "import scipy as sc." I do believe that I was working
> interactively so I don't have any actual evidence at this point.
>
> But I just had this thought—maybe I was in numpy and not scipy. For some
> reason both numpy and scipy provide a hamming function (why?) so maybe I was
> using the numpy version by accident which IIRC does not have the second
> argument.
>
> My sample code is in Octave. 8^)

scipy's hamming() function is scipy.signal.hamming(). It's in the
subpackage, and you need to import it like so:

  from scipy import signal
  signal.hamming(...)

There *is* a scipy.hamming() function as well, which is just an alias
for numpy.hamming().

  [~]
  |1> import scipy

  [~]
  |2> import numpy

  [~]
  |3> scipy.hamming is numpy.hamming
  True

Explaining why is a long story, but let's just say "historical
reasons" and leave it at that. You almost never want to just "import
scipy". All of the scipy goodness is in the subpackages.

-- 
Robert Kern



More information about the NumPy-Discussion mailing list