[Numpy-discussion] Simplifying array()
Colin J. Williams
cjw at sympatico.ca
Thu Jan 13 07:27:16 CST 2005
Todd Miller wrote:
>Someone (way to go Rory!) recently posted a patch (woohoo!) for
>numarray which I think bears a little discussion since it involves
>the re-write of a fundamental numarray function: array().
>The patch fixes a number of bugs and deconvolutes the logic of array().
>The patch is here if you want to look at it yourself:
>One item I thought needed some discussion was the removal of two
>> * array() does too much. E.g., handling file/memory instances for
>> 'sequence'. There's fromfile for the former, and users needing
>> the latter functionality should be clued up enough to
>> instantiate NumArray directly.
>I agree with this myself. Does anyone care if they will no longer be
>able to construct an array from a file or buffer object using array()
>rather than fromfile() or NumArray(), respectively? Is a deprecation
>process necessary to remove them?
I would suggest deprecation on the way to removal. For the newcomer,
who is not yet "clued up"
some advice on the instantiation of NumArray would help. Currently,
neither the word "class" or
"NumArray" appear in the doc index.
Rory leaves in type and typecode. It would be good to eliminate this
apparent overlap. Why not
deprecate and then drop type? As a compromise, either could be accepted
as a NumArray.__init__
argument, since it is easy to distinguish between them.
It would be good to clarify the acceptable content of a sequence. A
list, perhaps with sublists, of
numbers is clear enough but what about a sequence of NumArray instances
or even a sequence
of numbers, mixed with NumArray instances?
Is the function asarray redundant?
I suggest that the copy parameter be of the BoolType. This probably has
no practical impact but
it is consistent with current Python usage and makes it clear that this
is a Yes/No parameter,
rather than specifying a number of copies.
>I think strings.py and records.py also have "over-stuffed" array()
>functions... so consistency bids us to streamline those as well.
Thanks to Rory for initiating this.
More information about the Numpy-discussion