[PYTHON MATRIX-SIG] RubberIndex

Chris Chase S1A chris.chase@jhuapl.edu
Mon, 26 Feb 1996 12:41:00 -0500


>>>>> "James" == James Hugunin <jjh@Goldilocks.LCS.MIT.EDU> writes:

James> Just a quick point:

James>   If 'a' has rank 3, then
James>   a[0] = 1

James>   This implementation still allows an array to be used anywhere where a
James>   sequence object (e.g. list) is used.  

James> This is not true.  

My statement was that it could be used anywhere a sequence object is
used, a list being an example of a sequence object.  

James> In order to be able to use an array anywhere a list is used,

You will never be able to use the current array implementation
everywhere that a list is used because array has different definitions
for operators (e.g. *, +) and array can not support 'del' without
having to copy all of its elements.  If you want to use an array as a
list then use a.toList() (the toList() method would not be needed if
arrays were a subclass of lists).

James> a[0] for a rank 3 array must return a rank 2 array, because
James> this is how it works for multidimensional lists currently.

"must"?  Why?  As far as I can tell the hierarchical indexing for
arrays was a convenience for those used to working lists, because it
duplicates behavior already provided by a[0,...] indexing.

I was suggesting a different behavior for arrays as sequence objects.
My suggestion regarded supporting the use of flattened indexing for
both selection and assignment.  This specific solution for flattened
indexing is supported in all the array languages that I have had
exposure to (e.g. Matlab, IDL, Tela, Yorick). To me this is more
important than the hierarchical indexing scheme so that an array looks
like a list (but does not act like a list for other purposes).

As an alternative, a 'flat' (or 'flattened') array attribute could be
supported.

An aside: I know that Konrad Hinsen prefers functions to methods and
attributes so that the same code will work for both scalars and
arrays.  But this is similar to the list analogy above.  scalars will
never work in all array code because scalars are neither sequences nor
dictionary types.  The first time one attempts to subscript a scalar
an error will be produced.  Certainly we don't want subscription to be
a function rather than a method.  Rather than jump onto the everything
is a function bandwagon we may need to rethink the relationship
between scalars and arrays.  What is the entire scope of code where
scalars and arrays need to be interchangeable?

Chris


=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================