Sub-classing NumArray - two questions

  • Thread starter Colin J. Williams
  • Start date
C

Colin J. Williams

numarray is a package which is under development and intended to replace
Numeric, an efficient and operational package.

One of the classes in numarray is NumArray. As currently implemented,
instances of this class are instantiated using factory functions. This
appears to restrict the sub-classing of NumArray

Examples: a sub-class Matrix, an array restricted to two dimensions, or
a sub-class Mix, which combines the NumArray with RecArray (another
class in the numarray package), or even a sub-class of matrix, Symmetric
(to use more efficient storage)

These cannot readily be built using factory functions. This has been
discussed on the NumPy list
(http://lists.sourceforge.net/lists/listinfo/numpy-discussion) and the
question was posed:

Q1
Can someone please explain what the "new-classes standard" is?
(Obviously meeting it is not one of our current goals)

Another related question:

Q2
It seems that certain flaws were perceived in Numeric (NumPy),
developed in 1997 by Jim Hugunin. Development of numarray was
started to produce an array package which could become a standard
Python package. What were the flaws seen in Numeric?

Colin W.

Background from the NumPY list:

Regarding the "new-classes standard", I can't find much in either the
Python docs or Alex Martelli's "Python in a Nutshell". One of the new
features is a __new__ constructor.

The Python array module doesn't formally have a class and thus it can't
be sub-classed. It uses a factory function to create instance objects.

Martelli, in PIAN p74, writes of factory functions being useful when one
wishes to create instances of different classes depending on some
condition or for the reuse of an existing instance.

In the Python Cookbook p173, he proposes the use of a factory function
to get around the limitations of Python 2.1 and earlier. On page 179,
he refers to the use of a factory method, again to work around
limitations before Python 2.2.

My rough and ready definition would include the ability to create an
instance and initialize
the data in one step.

cjw
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top