Hi all,
For a ndarray-subclass I'm working on I extended the array_wrap and
array_finalize
functions<https://github.com/sunpy/sunpy/blob/master/sunpy/map/basemap.py#L145-165>
so
that operations like __sub__() would return a new instance of the subclass,
instead of an ndarray (although I still haven't completely figured this out
yet <http://mail.scipy.org/pipermail/scipy-user/2011-August/030179.html>.)
One side-effect of this, however, is that now other operations which should
*not* return a subclass (such as std) are returning one;
def __array_finalize__(self, obj):
"""Finishes instantiation of the new map object"""
if obj is None:
return
if hasattr(obj, 'header'):
self.header = obj.header
# preserve object properties
properties = self.get_properties(obj.header)
for attr, value in list(properties.items()):
setattr(self, attr, getattr(obj, attr, value))
self.center = obj.center
self.scale = obj.scale
self.units = obj.units
def __array_wrap__(self, out_arr, context=None):
"""Returns a wrapped instance of a Map object"""
return np.ndarray.__array_wrap__(self, out_arr, context)
I'm sure it is simply a coding error on my part, but so far I havne't been
able to track it down.
Any ideas?
Thanks,
Keith
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion