doh! I followed the example on the Wiki which does not define the class
attribute in the class scope, but in __new__. Adding the declaration to
the class scope seems to work.
Pierre GM wrote:
On Thursday 29 March 2007 12:04:51 Bryce Hendrix wrote:
I spoke too soon, this code fails with the example you gave:
mmh, I tried to use the class you linked to last time: the only modifications
I gave are listed below
__array_priority__ = 10.0
default_unit = "meters"
def __array_finalize__(self, obj):
self.units = getattr(obj,'units',UnitArray.default_unit)
then I used that for testing:
meters = "meters"
feet = "feet"
unit_ary_1 = UnitArray(numpy.array((1,2,3)), units=meters)
unit_ary_2 = UnitArray(numpy.array((1,2,3)), units=meters)
unit_ary_3 = UnitArray(numpy.array((1,2,3)), units=feet)
new_unit_ary = numpy.concatenate([unit_ary_1, unit_ary_2])
And it seems to work. Could you be a bit more specific ?
Numpy-discussion mailing list