[Numpy-discussion] [API] (minor change) Allow multiple axes in `expand_dims`

Stephan Hoyer shoyer at gmail.com
Mon Dec 2 14:40:10 EST 2019


This looks good to me!

On Mon, Dec 2, 2019 at 11:13 AM Sebastian Berg <sebastian at sipsolutions.net>
wrote:

> Hi all,
>
> Pull request 14051:
>
> https://github.com/numpy/numpy/pull/14051
>
> means that `np.expand_dims` now accepts multiple axes in the `axis`
> argument. As before, the axis signal where a new axis is in the output
> array. From the new tests:
>
> a = np.empty((3, 3, 3))
> np.expand_dims(a, axis=(0, 1, 2)).shape == (1, 1, 1, 3, 3, 3)
> np.expand_dims(a, axis=(0, -1, -2)).shape == (1, 3, 3, 3, 1, 1)
> np.expand_dims(a, axis=(0, 3, 5)).shape == (1, 3, 3, 1, 3, 1)
> np.expand_dims(a, axis=(0, -3, -5)).shape == (1, 1, 3, 1, 3, 3)
>
> We believe this is an uncontroversial generalization, but pinging the
> mailing list since it is an API change. If anyone is concerned please I
> will be happy to revert, otherwise this is expected to be included in
> 1.18.
>
> Cheers,
>
> Sebastian
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20191202/718ba0c8/attachment.html>


More information about the NumPy-Discussion mailing list