[Numpy-discussion] Simplifying array()
jmiller at stsci.edu
Thu Jan 13 08:17:20 CST 2005
On Thu, 2005-01-13 at 10:26 -0500, Colin J. Williams wrote:
> 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.
That's fair. The docstring for NumArray needs beefing up along the same
lines as Rory's work on array(). I initially liked Florian's idea of
frombuffer() but since I can't think of how it's not identical to
NumArray(), I'm not sure there's any point.
> Rory leaves in type and typecode. It would be good to eliminate this
> apparent overlap. Why not
> deprecate and then drop type?
Some people like type. I don't want to touch this.
> 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?
The patch has a new docstring which spells out the array() construction
algorithm. Lists of arrays would be seen as "numerical sequences".
> Is the function asarray redundant?
Yes, but it's clear and also needed for backward compatibility with
Numeric. Besides, it's not just redundant, it's an idiom...
> 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.
Fair enough. Backward compatibility dictates not *requiring* a bool,
but using it as a default is fine.
More information about the Numpy-discussion