[Numpy-discussion] adding a .M attribute to the array.

Paul F Dubois paul at pfdubois.com
Wed Mar 6 11:49:22 CST 2002


I believe the correct solution is a major upgrade to Matrix.py along the
lines of what is done in MA; that is, to craft an object that uses
Numeric for its implementation but which defines all its own operators
in a manner that is semantically sensible for the type of object it is. 

Such an upgrade could subsequently be improved by using different
underlying software for various operations, or even more sophisticated
changes such as using a transposed attribute to lazily evaluate
transposes in a cleaner way than Numeric does it. Also an upgrade to
Numarray would then be virtually painless.

If you have never looked at MA, please examine source file
Packages/MA/Lib/MA.py before commenting. This file is fairly complex and
the required changes to Matrix.py would be considerably simpler; but you
can verify that it is fairly straightforward to do. On my project we
have done something similar to create a "climate data variable" object.

Such a design includes an "exit" function to allow the instance to
cheaply view itself as the underlying Numeric array. (In MA, this is
"filled", which makes a Numeric array by replacing missing values, but
if there are no missing values returns the underlying Numeric array).

I'm willing to do this for the community but it would have a side
effect; if anyone has been doing "from Matrix import *" they would
suddenly get a lot more names imported that would conflict with any
imported from Numeric.






More information about the Numpy-discussion mailing list