On 1/5/07, Russell E Owen <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > "Sebastian Haase" <[EMAIL PROTECTED]> wrote: > > > On 1/4/07, Sebastian Haase <[EMAIL PROTECTED]> wrote: > > <snip> > > > >>> N.__version__ > > > '1.0.2.dev3487' > > > > > > in any case: inside the script it somehow generated a nan --- is > > > there a bug in numpy !? > > > > No bug here ! see below ! > > > > > I remember that there was some discussion about resize !? > > > What should I add to the Scipy Wiki numarray page about this ? > > > ( http://www.scipy.org/Converting_from_numarray ) > > > > > > > OK - the reference problem in my interactive shell came from the > > implicit '_' variable that always references the last result. But > > maybe even more worry some for the converting from numarray is this: > > >>> a = N.array([5]) > > >>> 999 # to kill '_' - reference > > 999 > > >>> a.resize(2) > > >>> a > > [5 0] > > > > in numarray you would get > > >>> a = na.array([5]) > > >>> a.resize(2) > > [5 5] > > >>> a > > [5 5] > > > > !! why is numpy filling with 0s and numarray repeats (cycles I think > > is more what it does !) the last element(s) ?? > > > > How did numeric do this ? > > Here's what I get for Numeric 24.2: > > >>> import Numeric as N > >>> a = N.array([5]) > >>> a > array([5]) > >>> a.resize(2) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ValueError: cannot resize an array that has been referenced or is > referencing > another array in this way. Use the resize function. > >>> N.resize(a, 2) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-pac > kages/Numeric/Numeric.py", line 422, in resize > total_size = multiply.reduce(new_shape) > ValueError: dimension not in array > >>> N.resize(a, [2]) > array([5, 5]) > Thanks for testing -- to be complete I will append my tests for numarray and numpy. I would consider the different result of function vs. method a bug !! Please comment , Sebastian.
>>> import numarray as na >>> import numpy as N >>> a = na.array([5]) >>> a.resize(2) [5 5] >>> a [5 5] >>> a = na.array([5]) >>> na.resize(a,2) [5 5] >>> a [5] >>> a = N.array([5]) >>> a.resize(2) >>> a [5 0] >>> a = N.array([5]) >>> N.resize(a, 2) [5 5] >>> a [5] ### Note: [5 5] vs. [5 0] !!! _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion