[Numpy-discussion] array, asarray as contiguous and friends
Travis Oliphant
oliphant at ee.byu.edu
Thu Mar 23 14:27:05 CST 2006
Tim Hochberg wrote:
>
> That makes some sense.
>
>>
>> The ndmin is very handy as atested to by the uses of atleast_1d or
>> atleast_2d in numpy library code. It was added later as an
>> optimization step because of the number of library routines that were
>> using it. I've since used it several times to simplify code.
>
>
> OK, I'll take your word for it.
Not necessarily sane advice :-) --- I might be overstating things. I
know that atleast_1d and atleast_2d are used all over the place in scipy.
This makes sense and I can certainly understand it. I'm willing to
modify things to give narrow interfaces.
Right now, since the requesting both fortran and contiguous does not
make sense, setting the fortran flag to false enforces C-style
contiguous while setting it to True enforces fortran-style. Setting it
to None (the default) specifies you don't care and the behavior will be
to create C-style contiguous for new arrays and use the striding
specified by the array if it's already an array. I admit that it is
arguable whether or not the fortran flag should be overloaded like this
or not.
There are now ascontiguous and asfortran functions with fairly minimal
interfaces to make it simpler.
There is also a check to make sure that array is called with no more
than 2 non keyword arguments. Thus, you won't be able to confuse which
flag is which.
-Travis
More information about the Numpy-discussion
mailing list