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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Sebastian Berg
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
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [API] (minor change) Allow multiple axes in `expand_dims`

Stephan Hoyer-2
This looks good to me!

On Mon, Dec 2, 2019 at 11:13 AM Sebastian Berg <[hidden email]> 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
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion