Hi, I'm a very frequent user of the following "unsqueeze" function, which I initially copied from scipy/stats/models/robust/scale.py and which seems to be also present in scikits.statsmodels.tools.unsqueeze. Would it be possible to include it natively to numpy?
def unsqueeze(data, axis, oldshape): """ Unsqueeze a collapsed array >>> from numpy import mean >>> from numpy.random import standard_normal >>> x = standard_normal((3,4,5)) >>> m = mean(x, axis=1) >>> m.shape (3, 5) >>> m = unsqueeze(m, 1, x.shape) >>> m.shape (3, 1, 5) """ if axis is None: return data newshape = list(oldshape) newshape[axis] = 1 return data.reshape(newshape) Cheers, -- .~. Yannick COPIN (o:>* Doctus cum libro /V\ Institut de physique nucléaire de Lyon // \\ Université de Lyon - CNRS-IN2P3 /( )\ AIM: YnCopin ICQ: 236931013 ^`~'^ http://snovae.in2p3.fr/ycopin/ _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion