[Numpy-discussion] missing array type
Sasha
ndarray at mac.com
Tue Feb 28 10:38:03 CST 2006
On 2/28/06, Colin J. Williams <cjw at sympatico.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.
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.
More information about the Numpy-discussion
mailing list