[Numpy-discussion] Re: Trying out Numeric3
xscottg at yahoo.com
Sat Mar 26 13:37:13 CST 2005
--- Stephen Walton <stephen.walton at csun.edu> wrote:
> Scott Gilbert wrote:
> >It's nice because it fits with the rest of the array semantics and
> >a consistant system:
> > Array3D = zeros((1, 1, 1))
> > Array2D = Array3D
> > Array1D = Array2D
> > Array0D = Array1D
> Hmm...in both Numeric3 and numarray, the last line creates a Python
> scalar. Array2D and Array1D by contrast are not only arrays, but they
> are views of Array3D.
I should have been clear that I wasn't describing what any of the array
packages do today. The views thing is a different can of worms (I think
they should be copy-on-write copies by default and views only when
explicitly asked for).
> Is what you're saying is that you want Array0D to
> be a rank-0 array after the above?
Yes. I think it fits the pattern and is consistant. There are also cases
where it is useful.
Array operations form a nice little calculus. Returning non-mutable
scalars in place of rank-0 arrays is like having (2 - 1 == 1) while (2 - 1
- 1 == a donut). 0 looks like a donut, but it's a different food group.
> > Array0D[()] = 1
> Of course, this generates an error at present: "TypeError: object does
> not support item assignment" since it is a Python int. Moreover, it
> isn't a view, so that Array0D doesn't change after the assignment to
> Array3D. Is this also slated to be changed/fixed using rank 0 arrays?
> Would Array0D.shape be () in that case?
Array0D.shape would be an empty tuple () in that case.
I can't say what either Numeric3 or Numarray will do. The last time I read
the Numeric3 PEP, it looked like there were going to be several special
types of scalars.
More information about the Numpy-discussion