[API] (minor change) Allow multiple axes in `expand_dims`
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
This looks good to me! On Mon, Dec 2, 2019 at 11:13 AM Sebastian Berg <sebastian@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@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
participants (2)
-
Sebastian Berg
-
Stephan Hoyer