ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> numpy-discussion
numpy-discussion
Re: [Numpy-discussion] missing array type
by Travis Oliphant other posts by this author
Feb 28 2006 12:19PM messages near this date
Re: [Numpy-discussion] missing array type | Re: [Numpy-discussion] missing array type
Sasha wrote:

> >>>b = array([1])
> >>>ndarray((5,), strides=(0,), buffer=b)
> >>>        
> >>>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: buffer is too small for requested array
> 
> I would think memory-saving is the only justification for allowing
> zero strides.
> 
> What use does your change enable?
>   
> 
I was just simplifying the PyArray_CheckStrides code. 
I didn't try to actually enable creating 0-stride arrays in 
PyArray_NewFromDescr.
I don't mind if it is enabled though.   I just haven't done it yet.

I agree that 0-stride arrays are a "can-of-worms", and I also do not see 
changing ufunc behavior.  The current behavior is understandable and 
exactly what one would expect with zero-stride and multiple dimensioned 
arrays.  

i.e.

b = arange(5);
b.strides = 0
add(b,1,b)

where b has shape (5,) and stride (0,) would add 1 to the first element 
of b 5 times.  Since all elements of the array b are obtained from the 
first element (that's what stride=0 means), you end up with an array of 
all 5's.   This may not be useful, I agree, but it is understandable and 
changing it would be too much of an exception.   If somebody is creating 
0-stride arrays on their own, then they must know what they are doing.

-Travis








-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Alan G Isaac
Sasha
David M. Cooke
Sasha
Tim Hochberg
Colin J. Williams
Sasha
Travis Oliphant
Sasha
Travis Oliphant
Christopher Barker
Sasha
Sasha
Travis Oliphant
Sasha
Alan G Isaac

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved