File tree Expand file tree Collapse file tree 2 files changed +14
-19
lines changed Expand file tree Collapse file tree 2 files changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -4355,28 +4355,22 @@ def empty_like(
4355
4355
4356
4356
4357
4357
def atleast_Nd (
4358
- * arys : np .ndarray | TensorVariable , n : int = 1 , left : bool = True
4358
+ arry : np .ndarray | TensorVariable , * , n : int = 1 , left : bool = True
4359
4359
) -> TensorVariable :
4360
- """Convert inputs to arrays with at least `n` dimensions."""
4361
- res = []
4362
- for ary in arys :
4363
- ary = as_tensor (ary )
4360
+ """Convert input to an array with at least `n` dimensions."""
4364
4361
4365
- if ary .ndim >= n :
4366
- result = ary
4367
- else :
4368
- result = (
4369
- shape_padleft (ary , n - ary .ndim )
4370
- if left
4371
- else shape_padright (ary , n - ary .ndim )
4372
- )
4362
+ arry = as_tensor (arry )
4373
4363
4374
- res .append (result )
4375
-
4376
- if len (res ) == 1 :
4377
- return res [0 ]
4364
+ if arry .ndim >= n :
4365
+ result = arry
4378
4366
else :
4379
- return res
4367
+ result = (
4368
+ shape_padleft (arry , n - arry .ndim )
4369
+ if left
4370
+ else shape_padright (arry , n - arry .ndim )
4371
+ )
4372
+
4373
+ return result
4380
4374
4381
4375
4382
4376
atleast_1d = partial (atleast_Nd , n = 1 )
Original file line number Diff line number Diff line change @@ -4364,7 +4364,8 @@ def test_atleast_Nd():
4364
4364
4365
4365
for n in range (1 , 3 ):
4366
4366
ary1 , ary2 = dscalar (), dvector ()
4367
- res_ary1 , res_ary2 = atleast_Nd (ary1 , ary2 , n = n )
4367
+ res_ary1 = atleast_Nd (ary1 , n = n )
4368
+ res_ary2 = atleast_Nd (ary2 , n = n )
4368
4369
4369
4370
assert res_ary1 .ndim == n
4370
4371
if n == ary2 .ndim :
You can’t perform that action at this time.
0 commit comments