Hi Jarrod, I was wondering if someone knowledgeable would please look into the behavior of concatenate() with subclasses of ndarray. I posted at scipy-dev some work on a subclass that handles units, and when two of these are concatenated, a regular ndarray is returned rather than another instance of the subclass. This behavior was discussed a while back at http://thread.gmane.org/gmane.comp.python.numeric.general/14494 . It resurfaced on enthought-dev in Sept-2007, at which point Travis responded (I hope he doesnt mind being quoted):
> there should be no array creation functions which do not > call __array_finalize__ if it is defined, and therefore, the described > behavior is a bug that should be reported. The concatentate code should > also respect the sub-type of the arrays being concatenated (it seems to > as I look at the code...) > > However, the larger question of priority occurs in mixed concatenation > cases which are probably being encountered. In such cases, the > sub-type with the largest priority will be the resulting type (and if > it's not your class then your __array_finalize__ will not be called). > I wonder if this was what was being encountered rather than a > "limitation of NumPy" I encountered the problem again over the weekend with the package I am working on, which can be checked out from: "hg clone \ http://dale.chess.cornell.edu/~darren/cgi-bin/hgwebdir.cgi/quantities \ quantities" it installs in the usual way. The concat issue can the be reproduced by doing: [~] |1> from quantities import NDQuantity udunits(3): Already initialized from file "/usr/lib64/python2.5/site-packages/quantities/quantities-data/udunits.dat" [~] |2> J=NDQuantity([1.,2.,3.],'J') [~] |3> J <3> NDQuantity([ 1., 2., 3.]), kg * m^2 / s^2 [~] |4> import numpy [~] |5> numpy.concatenate([J,J]) <5> array([ 1., 2., 3., 1., 2., 3.]) Maybe this is an issue with my code, and not numpy, but since others have reported the problem before me, perhaps someone could please have a look before releasing 1.2? I dont think array priority is the problem, since I see the issue concatenating two of the same array subtypes. Regards, Darren On Monday 04 August 2008 01:45:51 pm Jarrod Millman wrote: > Here are the remaining tasks that I am aware of that need to be done > before tagging 1.2.0b1 on the 8th. > > Median > ====== > The call signature for median needs to change from > def median(a, axis=0, out=None, overwrite_input=False): > to > def median(a, axis=None, out=None, overwrite_input=False): > in both numpy/ma/extras.py and numpy/lib/function_base.py > > Histogram > ======== > The call signature for histogram needs to change from > def histogram(a, bins=10, range=None, normed=False, weights=None, > new=False): to > def histogram(a, bins=10, range=None, normed=False, weights=None, > new=True): in numpy/lib/function_base.py > > Documentation > ============ > The documentation project needs to merge in its changes. Stefan will > take care of this on the 5th. > > Please let me know ASAP if there is anything I am missing. > > Thanks, _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion