[PYTHON MATRIX-SIG] Final conventions for alpha2

Konrad Hinsen hinsen@physik.rwth-aachen.de
Sun, 18 Aug 1996 09:59:11 +0200

   Everytime one wanted to evaluate the fft (or whatever) of multiple
   one-dimensional signals at once. In genetic algorithms (GAs, what I would

Obviously, but how often does this occur? (Of course I am not
asking how often such code gets executed, but how often you have to
type such a function call.) In all of my array code, which is not
just Python code but also a few MB of APL code, such applications
are extremely rare. Even if such an operation is central to GA
applications, that doesn't mean that the majority of array functions
in a complete program (i.e. including setup or reading of input
arrays, analysis, output formatting, etc.) would benefit from a
default axis of -1.

But of course you can convince me that I am wrong by sending me a few
complete programs that do something useful and that need an axis
specification of -1 in the majority of axis-related operations.

   I am afraid I do not understand what you mean by structural and
   non-structural operations.  In particular, why is take() structural and
   argsort() non-structural? For take(a,argsort(a)) to make sense, both
   should have the same defaults, whatever the dimensions of a.

Basically a structural operation is one that acts on or modifies
the shape of an array, as opposed to a non-structural operation
that cares mostly about the values of the array elements.
take() is clearly structural (it doesn't care at all about the
values of array elements), whereas argsort is not (the values
matter a lot, and intrinsically it can't deal with higher-rank
arrays). And I am sure that for most applications of take()
a default axis of 0 is appropriate, whereas most applications
of argsort() would benefit from -1.

Of course that means that take(a,argsort(a)) doesn't do anything
useful. But in what situation would you use it anyway? To sort the 1D
subarrays of a, you would write sort(a) (which being non-structural
should have a default axis of -1).  Using take() makes sense e.g. if
you only want a subset of the elements, but I can't believe that this
is a frequent operation. Besides, my APL experience tells me that
argsort() is never used on anything but a rank-1 array.


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. A                | 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