Skip to content

atleast_Nd should only accept one positional argument #1290

Closed
@ricardoV94

Description

@ricardoV94

If you call atleast_Nd(x, 1) it will treat 1 as an array. This was very surprising, if someone wants to call it on multiple arrays they can use a loop.

def atleast_Nd(
*arys: np.ndarray | TensorVariable, n: int = 1, left: bool = True
) -> TensorVariable:
"""Convert inputs to arrays with at least `n` dimensions."""
res = []
for ary in arys:
ary = as_tensor(ary)
if ary.ndim >= n:
result = ary
else:
result = (
shape_padleft(ary, n - ary.ndim)
if left
else shape_padright(ary, n - ary.ndim)
)
res.append(result)
if len(res) == 1:
return res[0]
else:
return res

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions