[PYTHON MATRIX-SIG] Functions and names

Konrad HINSEN hinsenk@ere.umontreal.ca
Sat, 24 Feb 1996 09:38:58 -0500


   I often use map projections (e.g. azimuthal) to represent regularly
   sampled data on a sphere (latitude/longitude or azimuth/elevation
   coordinates), i.e. data is a 2D array on a regularly sampled lat/lon
   grid.  One way to map data onto the map projection is to compute the
   lat/lon coordinate of each pixel in the map.  Suppose the map is to be
   an NxM image for a particular projection and that the NxM arrays 'lat'
   and 'lon' contain the latitude and longitude coordinates of each pixel
   in map.  'lat' and 'lon' then are converted to indexes according to the
   grid sampling.

   Then mapped indexing produces the desired map image:

   map = data.mapped(lat,lon)

I think I understand this now. In fact, I was planning to include this
feature in my function proposal, but under "mapping functions" (yet
to be written) rather than "indexing", because it is just a special
case of array mapping with simple indexing as the function to be
applied.

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

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

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

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

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

   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.

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

So effectively you want to introduce a second array type with a slightly
different behaviour. I don't think this is a good idea. There would
be no way to stop users from just writing a.collapse and assign the
result to variables, return it from library functions etc. Suddenly
there are two array types in free circulation that behave almost, but
not quite, identically.

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------

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

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