Re: [Numpy-discussion] missing array type
by Tim Hochberg other posts by this author
Feb 28 2006 2:05PM messages near this date
Re: [Numpy-discussion] missing array type
|
Re: [Numpy-discussion] missing array type
Sasha wrote:
> On 2/28/06, Colin J. Williams <cjw@[...].ca> wrote:
>
>
> >...
> >
> >
> >>>Would it not be better to have def zeroes(..., zeroStrides= False):
> >>>and a= zeros(..., zeroStrides= True)?
> >>>
> >>>
> >>>
> >>>
> >>This is equivalent to what I proposed: xzeros(shape) and xones(shape)
> >>functions as a shorthand to ndarray(shape, strides=(0,)*len(shape))
> >>
> >>
> >>
> >>
> >Wot, more names to remember? [sorry, I can't give you the graphic to go
> >aling with this. :-) ]
> >
> >
>
> Oh, please - you don't have to be so emphatic. Your solution above
> (adding zeroStrides parameter) would require a much more arbitrary
> name to remember. Even worse, someone will write zeros(shape, int,
> False, True) to mean zeros(shape, dtype=int, fortran=False,
> zeroStrides=True) and anyone reading that code will have to look up
> the manual to understand what each boolean means.
>
> Boolean parameters are generally considered bad design. For example,
> it would be much better to have array(..., memory_layout='Fortran')
> instead of current array(...,fortran=True). (Well, fortran=True is
> not that bad, but fortran=False is really puzzling - if it is not
> fortran - what is it?) Arguably even better solution would be
> array(..., strides = fortran_strides(shape)), but that's a different
> story.
>
>
I agree with this.
> The names xzeros and xones are a natural choice because the
> functionality they provide is very similar to what xrange provides
> compared to range: memory saving way to achieve the same result.
>
>
But not this.
I don't think using xrange as a template for naming anything is a good
idea. If xrange were being added to Python now, it would almost
certainly be called irange and live in itertools. I have a strong
suspicion that the *name* xrange will go the way of the dodo eventually,
although the functionality will survive in some other form.
Also, while I can see how there might well be some good uses for
zero-stride arrays, I'm having a hard time getting excited by by xzeros
and xones. The only applications I can come up with can already be done
in more efficient ways without using xones and xzeros.
[Let me apologize in advance if I missed a compelling example earlier in
this thread -- I just got back from vacation and I may have missed
something in my email reading frenzy]
-tim
-------------------------------------------------------
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
|