[Numpy-discussion] Please help with subclassing numpy.ndarray
Jeremy Conlin
jeremit0 at gmail.com
Sun Feb 4 20:22:44 EST 2007
I have subclassed the numpy.ndarray object, but need some help setting
some attributes. I have read http://scipy.org/Subclasses but it
doesn't provide the answer I am looking for.
I create an instance of the class in my __new__ method as:
import numpy
class MyClass(numpy.ndarray):
__new__(self,…):
# Some stuff here
H, edges = numpy.histogramdd(…)
return H
This sets H as the instance of my object. I would also like to have
edges be an attribute of MyClass. I can't do:
self.edges = edges
because the object hasn't been instantiated yet. Can someone show me
how I can also keep the information from the variable edges?
Thanks,
Jeremy
More information about the NumPy-Discussion
mailing list