[PYTHON MATRIX-SIG] Final conventions for alpha2

Konrad HINSEN hinsenk@ere.umontreal.ca
Fri, 16 Aug 1996 13:28:05 -0400


> After reading all of the discussion over what are the appropriate axes
> for the various operations, I've become convinced that there is no
> obvious choice.  Therefore I think it is really important to have a
> single default axis so that at least people will only have one rule to
> remember.

I'd rather remember a more complicated rule than type explicit axis
specifications for almost every function!

> Because I can't possibly conceive of doing "fft" and its ilk with a
> default axis other than -1, every function in NumPy will have a default
> axis of -1 (or -2 for matrix operations).  This currently includes all

Could it be that you have a special bias for FFT? I don't consider
FFTs so fundamental that they should set the default for all
array functions. Statistically most functions would best have
a default of 0, those that should have another default are the
exceptions.

> I wish I could come up with a better compromise, but I myself was
> finding it hard to remember what the default axes were for different
> operations, and that's just intolerable.

Using -1 for everything is more intolerable than anything else.
A quick glance at my existing code shows that I would need
an explicit axis specifications for 80% of my function calls!

Actually the default axis discussion has a long history in the APL
community. The original APL allowed axis specifications in the same
style as Python now does. The default axis was always zero, but for
reduce and accuulate an alternate form with a default of -1 was
provided. The various problems with this approach (and other
limitations in APL) led to the rank concept in J. For most
applications there is not much difference between function ranks and
axis specifications, since the effect for simple arrays is rather
similar. But J also gave up the "the same default for everyone"
rule. However, it is possible to inquire about the default rank
of any J function, which helps to reduce confusion and bad memory
problems ;-)

> I will add keyword arguments to all of the functions that accept an axis
> so that you can at least write concatenate([a,b], axis=0) which I think
> is much more readable than the non-keyword alternative.

Definitely. But what happens to dot(), which needs two axes?

Konrad.

-------------------------------------------------------------------------------
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
=================