[PYTHON MATRIX-SIG] Functions and names

Chris Chase S1A chris.chase@jhuapl.edu
Mon, 26 Feb 1996 14:30:43 -0500


>>>>> "Konrad" == Konrad HINSEN <hinsenk@ere.umontreal.ca> writes:


Chase>    current array representation.  Besides, I think it is more
Chase>    natural to return a copy of the indexed elements rather
Chase>    than a reference when using a general index vector.

Konrad> Indeed, but this creates the unpleasant situation that an expression
Konrad> like  a[i,j] returns either a copy or a reference, depending on the
Konrad> values of i and j. Having references at all is confusing enough, but
Konrad> this would certainly cause some headaches.

This was not my suggestion.  My suggestion kept the current behavior.
I suggested a different access method or attribute called 'subarray'
allowing the use of a general index vector that would return a copy.

Konrad> Personally I'd prefer to have standard indexing always return a copy
Konrad> (that is the safer option) and provide an alternative syntax for
Konrad> obtaining a reference. Then standard indexing could again allow
Konrad> general index vectors.

Personally, I currently only care that general index vectors be
supported for both subscription and assignment.

Chase>    I specifically said that the function I was describing overwrites
Chase>    elements in the target array rather than making room.  True it is not

Konrad> Then allowing general index vectors in indexed assignments should
Konrad> be all you need, right?

One only needs slices.  The insertion functionality I suggested only
requires one to specify the starting position.  Normally, the user
would have to compute the slice ending position and check to see if
the input array will fit (if not the input array could be sliced to
fit). I was suggesting a insertion function that would handle options
of wrap-around versus truncation versus just error signaling.  It is
very convenient for manipulating block regions of arrays (like placing
one image inside another image).  Perhaps a better name than "insert"
would be "place"?

Chase> I do not like this.  Perhaps an attribute 'collapse' would
Chase> work?  E.g.

Chase> a.collapse[i1, i2, ..., i3, i4]

Konrad> If that can be done, fine. So what should the value of "collapse" be
Konrad> before subscripting? I can't see a way to make this work.

Chase>    It would have to be an object containing a reference to the
Chase>    array 'a'.  It would have the special property that the
Chase>    ellipses index, '...', collapses missing dimensions.
Chase>    Otherwise it would act like a normal array.  Since this is a
Chase>    special kind of access to the array object, a

Konrad> So effectively you want to introduce a second array type with
Konrad> a slightly different behaviour. 

Konrad> I don't think this is a good idea. There would be no way to
Konrad> stop users from just writing a.collapse and assign the result
Konrad> to variables, return it from library functions etc. Suddenly
Konrad> there are two array types in free circulation that behave
Konrad> almost, but not quite, identically.

I was not sure that it was a good solution for this reason.  I
suggested an attribute because attributes can support the indexing
syntax whereas functions can not.


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

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