astropy/astropy — pull request #564 by eteq (2012-12-16 03:39:41+00:00)
Title: Allow arrays in Quantity

This PR enables arrays in `Quantity` (e.g. `` u.km * np.array([1,2,3])``).

It does *not* allow adding arrays to units for the same reason we disallowed it for scalars: the operation is not well-defined (e.g. how do you match the dimensions).

There is one thing that is missing, though. ``np.array([1,2,3]) * u.km`` currently does *not* work. This is because it uses the numpy `__mul__` method, which tries to do element-wise operations. So the result is an array with dtype object, because `__rmul__` on `Unit` or `Quantity` gets called with the *elements* of the array instead of the whole array. Does anyone know how to fix this up? @mdboom, @iguananaut, or @taldcroft, perhaps?