[SciPy-user] SciPy-user Digest, Vol 29, Issue 11

Brendan Simons brendansimons at yahoo.ca
Fri Jan 6 07:22:48 CST 2006


On 6-Jan-06, at 3:01 AM, Travis wrote:

> I can't think of a good reason except that's the way Numeric did it.
> I don't think a change in this behavior would hurt anybody.
>
> But let's be clear.   A 0d array and a size-0 array are two different
> things.
>
> A 0d array actually has room for one element while a size-0 array has
> one of the dimensions as 0. I just checked, and numarray returns a
> size-0 array.

Right, my mistake.  I meant a size 0 array.

>
> I can change this.

Great!  That would be very helpful to me.

>
> But, note also that if another object is referencing a you can't do a
> resize like this:
>
> i.e.
>
> a = numpy.ones(5)
> b = a
> a.resize(...)  will give an error because the object a has more  
> than one
> reference to it.

Oh, I hadn't realized this.  I can work around that limitation, but  
it might not be apparent to future users.
I can't comment about the relative merits of malloc approaches, but I  
certainly don't want to sacrifice the performance of numpy for this  
use case.
>
> The point of resize is to be able to modify the size of the memory
> pointer for the array.  You can't do this is another array is using  
> the
> same memory pointer (which it might be if this array has more than one
> reference).

So the memory address belongs to the reference, and not the array  
itself?  *Looks embarassed for not understanding better how things work*

>
> If you really need the numarray ability to swap out the memory address
> of the array for another one, then you might as well use the resize
> function:
>
> a = resize(a,(0,))   # which we will have to fix to make work  
> right ;-)
>

The global resize function will change the memory address of all  
references to the array then?  If so, that sounds like an adequate  
solution, thanks.

Brendan
--
Brendan Simons, Project Engineer
Stern Laboratories, Hamilton Ontario

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scipy.net/pipermail/scipy-user/attachments/20060106/79611f7c/attachment.htm


More information about the SciPy-user mailing list