NumPy error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jason

    #1

    NumPy error

    Hello:

    I am using the following versions of Python and packages on Windows XP
    (SP2):

    Python 2.4.2
    NumPy 0.9.4.win32-py2.4
    SciPy 0.4.4 for Python 2.4 and Pentium 4/SSE2

    In the Python Shell I am running the following:
    [color=blue][color=green][color=darkred]
    >>> from scipy.optimize import fmin
    >>> def rosen(x):[/color][/color][/color]
    return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)
    [color=blue][color=green][color=darkred]
    >>> x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
    >>> xopt = fmin(rosen, x0)[/color][/color][/color]

    I get the following error:

    Traceback (most recent call last):
    File "<pyshell#6 >", line 1, in -toplevel-
    xopt = fmin(rosen, x0)
    File "C:\Python24\Li b\site-packages\scipy\ optimize\optimi ze.py", line 191,
    in fmin
    sim = Num.zeros((N+1, N),x0.dtypechar )
    AttributeError: 'numpy.ndarray' object has no attribute 'dtypechar'

    Any idea what the problem might be?

    Thanks.


  • Diez B. Roggisch

    #2
    Re: NumPy error

    jason wrote:
    [color=blue]
    > Hello:
    >
    > I am using the following versions of Python and packages on Windows XP
    > (SP2):
    >
    > Python 2.4.2
    > NumPy 0.9.4.win32-py2.4
    > SciPy 0.4.4 for Python 2.4 and Pentium 4/SSE2[/color]

    I fell for that yesterday. Cost me two hours. You have to install NumPy
    0.9.2. Make sure you cleaned up the site-packages, and if you build stuff
    yourself, a clean rebuild is necessary.

    Regards,

    Diez

    Comment

    • jason

      #3
      Re: NumPy error

      Thanks.

      After executing the first line, I now get:
      [color=blue][color=green][color=darkred]
      >>> from scipy.optimize import fmin[/color][/color][/color]
      Overwriting fft=<function fft at 0x012116F0> from scipy.fftpack.b asic (was
      <function fft at 0x011C8A70> from numpy.dft.fftpa ck)
      Overwriting ifft=<function ifft at 0x01211730> from scipy.fftpack.b asic (was
      <function inverse_fft at 0x011C8AB0> from numpy.dft.fftpa ck)

      And then I get the following result:
      [color=blue][color=green][color=darkred]
      >>> xopt = fmin(rosen, x0)[/color][/color][/color]
      Optimization terminated successfully.
      Current function value: 0.000066
      Iterations: 141
      Function evaluations: 243
      [color=blue][color=green][color=darkred]
      >>> print xopt[/color][/color][/color]
      [ 0.99910115 0.99820923 0.99646346 0.99297555 0.98600385]

      Two questions:
      1. does the "overwriting... " message make sense?
      I uninstalled scipy and numpy and re-installed them.

      2. has the algorithm (accuracy level) changed? the result seems different
      from that reported in

      on page 12.

      Thanks again.

      "Diez B. Roggisch" <deets@nospam.w eb.de> wrote in message
      news:44mgs1F2to 82U1@uni-berlin.de...[color=blue]
      > jason wrote:
      >[color=green]
      >> Hello:
      >>
      >> I am using the following versions of Python and packages on Windows XP
      >> (SP2):
      >>
      >> Python 2.4.2
      >> NumPy 0.9.4.win32-py2.4
      >> SciPy 0.4.4 for Python 2.4 and Pentium 4/SSE2[/color]
      >
      > I fell for that yesterday. Cost me two hours. You have to install NumPy
      > 0.9.2. Make sure you cleaned up the site-packages, and if you build stuff
      > yourself, a clean rebuild is necessary.
      >
      > Regards,
      >
      > Diez[/color]


      Comment

      • Diez B. Roggisch

        #4
        Re: NumPy error

        >>>> from scipy.optimize import fmin[color=blue]
        > Overwriting fft=<function fft at 0x012116F0> from scipy.fftpack.b asic (was
        > <function fft at 0x011C8A70> from numpy.dft.fftpa ck)
        > Overwriting ifft=<function ifft at 0x01211730> from scipy.fftpack.b asic (was
        > <function inverse_fft at 0x011C8AB0> from numpy.dft.fftpa ck)
        >
        > And then I get the following result:
        >[color=green][color=darkred]
        >>>> xopt = fmin(rosen, x0)[/color][/color]
        > Optimization terminated successfully.
        > Current function value: 0.000066
        > Iterations: 141
        > Function evaluations: 243
        >[color=green][color=darkred]
        >>>> print xopt[/color][/color]
        > [ 0.99910115 0.99820923 0.99646346 0.99297555 0.98600385]
        >
        > Two questions:
        > 1. does the "overwriting... " message make sense?
        > I uninstalled scipy and numpy and re-installed them.[/color]

        I get that too - and I have no clue what it means, but I consider it a
        left-over warning or something like that.
        [color=blue]
        >
        > 2. has the algorithm (accuracy level) changed? the result seems different
        > from that reported in
        > http://www.scipy.org/Wiki/Documentat...y_tutorial.pdf
        > on page 12.[/color]

        No idea.

        Diez

        Comment

        • Robert Kern

          #5
          Re: NumPy error

          jason wrote:[color=blue]
          > Thanks.
          >
          > After executing the first line, I now get:
          >[color=green][color=darkred]
          >>>>from scipy.optimize import fmin[/color][/color]
          >
          > Overwriting fft=<function fft at 0x012116F0> from scipy.fftpack.b asic (was
          > <function fft at 0x011C8A70> from numpy.dft.fftpa ck)
          > Overwriting ifft=<function ifft at 0x01211730> from scipy.fftpack.b asic (was
          > <function inverse_fft at 0x011C8AB0> from numpy.dft.fftpa ck)
          >
          > And then I get the following result:
          >[color=green][color=darkred]
          >>>>xopt = fmin(rosen, x0)[/color][/color]
          >
          > Optimization terminated successfully.
          > Current function value: 0.000066
          > Iterations: 141
          > Function evaluations: 243
          >[color=green][color=darkred]
          >>>>print xopt[/color][/color]
          >
          > [ 0.99910115 0.99820923 0.99646346 0.99297555 0.98600385]
          >
          > Two questions:
          > 1. does the "overwriting... " message make sense?[/color]

          It's replacing the fft() and ifft() functions in numpy with the optimized
          functions in scipy. I don't think we're doing that anymore in SVN scipy.
          [color=blue]
          > I uninstalled scipy and numpy and re-installed them.
          >
          > 2. has the algorithm (accuracy level) changed? the result seems different
          > from that reported in
          > http://www.scipy.org/Wiki/Documentat...y_tutorial.pdf
          > on page 12.[/color]

          It is different. We're not really sure why. The simplex method is not an
          algorithm known for its robustness.

          Sorry about the confusion with dtypechar. Our releases of numpy and scipy got
          out of sync.

          --
          Robert Kern
          robert.kern@gma il.com

          "In the fields of hell where the grass grows high
          Are the graves of dreams allowed to die."
          -- Richard Harter

          Comment

          Working...