[PYTHON MATRIX-SIG] First impressions from the docs
Konrad Hinsen
hinsen@physik.rwth-aachen.de
Mon, 12 Aug 1996 21:18:07 +0200
I couldn't resist downloading the new Numerical Python packageeven
though I don't have the Python 1.4 source code yet. So I'lljust
comment on what I read in the documentation for now:
In general, the current function set is a big step forward. I
expectthat I can now replace most awkward constructions in my
applicationcode by something more concise and more efficient. More on
that whenI am finished...
I would like to see more flexibility in the constructor if it iscalled
with a non-sequence first argument. It should try to dosomething
meaningful whenever possible. If presented with a file,for example, it
should assume a text file with numbers and doits best to turn it into
an array (this is very important forreading data produced by other
programs). And for argumentsthat have no type/class with special
meaning, it should calla method toArray() if it exists.I do realize
that reading from a file intelligently is a non-trivialproblem, and
therefore the best solution is probably to provide afunction hook
similar to the one for array printing. Thatgives everyone ample
opportunity to play with array reading code.I have a function (in
Python) that reads 1D and 2D arrays wellenough for me, but it is not
very efficient. That could be astarting point for a more sophisticated
version.
I wonder what exactly resize() does. First, I don't understand whyit
is less efficient than reshape(); if the size remains the same,
itshould perform exactly the same operation. But I really wonder
what"strange" things can happen if I am not "careful". As long as
theshape argument makes sense (i.e. contains no negative numbers)
theresult should be well defined.
The function diagonal() is a typical example of a function thatwould
benefit from J-style function ranks. As it is defined now,it assumes
that higher-rank arrays are to be treated as arraysof 2D subarrays
(i.e. function rank 2). This is a useful function,but a "true"
higher-rank diagonal (the list of elements for whichall indices are
equal), corresponding to function rank infinity,is also useful. The
same applies to trace().
The axis defaults for sort() and argsort() should be 0.
There are two methods that I would like to see as functions:
shape()and asType(). Both occur commonly in numerical algorithms,
wheretheir argument might be a rank-0 array (i.e. a
scalar).(Alternatively the two methods could be added to the
Pythonscalar types, but I am not sure if Guido would approve such
achange.)
I still think that in the general spirit of Python, the defaultmath
module used by Numeric should be umath, not fast_umath.For someone who
doesn't know all the details, it is betterto be slow than to be wrong.
More when I have the code running...
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. 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
=================