File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -4247,6 +4247,17 @@ def expand_dims(
4247
4247
4248
4248
Insert a new axis that will appear at the `axis` position in the expanded
4249
4249
array shape.
4250
+
4251
+ Parameters
4252
+ ----------
4253
+ a :
4254
+ The input array.
4255
+ axis :
4256
+ Position in the expanded axes where the new axis is placed.
4257
+ If `axis` is empty, `a` will be returned immediately.
4258
+ Returns
4259
+ -------
4260
+ `a` with a new axis at the `axis` position.
4250
4261
"""
4251
4262
a = as_tensor (a )
4252
4263
@@ -4256,6 +4267,9 @@ def expand_dims(
4256
4267
out_ndim = len (axis ) + a .ndim
4257
4268
axis = np .core .numeric .normalize_axis_tuple (axis , out_ndim )
4258
4269
4270
+ if not axis :
4271
+ return a
4272
+
4259
4273
dim_it = iter (range (a .ndim ))
4260
4274
pattern = ["x" if ax in axis else next (dim_it ) for ax in range (out_ndim )]
4261
4275
You can’t perform that action at this time.
0 commit comments