You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make merging of Event, Epoch, SpikeTrainList and array annotations independent of how quantities handles np.concatenate #1978
Currently, np.concatenate and the functions built on it (np.hstack, np.vstack, np.stack, np.append) drop the units of Quantity arguments: they join the bare magnitudes, without converting units, and return a dimensionless result. Neo relies on this in several places by first rescaling the arguments to common units and then multiplying the result by those units:
python-quantities/python-quantities#293 (planned for quantities 0.18.0) makes these functions keep the units, converting all the arguments to the units of the first. With that change, the result above becomes ms**2, and test_Epoch_merge, test_Event_merge and TestSpikeTrainList::test_multiplexed fail.
A form that works with both behaviours, and doesn't depend on rescaling earlier, is to convert explicitly and stack the magnitudes:
The result of rescale() is discarded, so array annotations from others are joined with no unit conversion and then labelled with the units of self_ann. For example, merging a quantity annotation of 1 * pq.s with one of 500 * pq.ms gives [1, 500] s. The first np.concatenate has the same problem when the others have different units from each other. The explicit form above fixes this too.
Activity