Skip to content

Commit 2d276df

Browse files
committed
MAINT: normalize array-like arg of full(), a few others
1 parent 318ca62 commit 2d276df

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

torch_np/_wrapper.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,12 @@ def empty_like(
307307

308308
@normalizer
309309
def full(
310-
shape, fill_value, dtype: DTypeLike = None, order="C", *, like: SubokLike = None
310+
shape, fill_value: ArrayLike, dtype: DTypeLike = None, order="C", *, like: SubokLike = None
311311
):
312312
if isinstance(shape, int):
313313
shape = (shape,)
314314
if order != "C":
315315
raise NotImplementedError
316-
fill_value = asarray(fill_value).get()
317316
result = _impl.full(shape, fill_value, dtype=dtype)
318317
return _helpers.array_from(result)
319318

@@ -471,18 +470,18 @@ def where(
471470
###### module-level queries of object properties
472471

473472

474-
def ndim(a):
475-
a = asarray(a).get()
473+
@normalizer
474+
def ndim(a : ArrayLike):
476475
return a.ndim
477476

478477

479-
def shape(a):
480-
a = asarray(a).get()
478+
@normalizer
479+
def shape(a: ArrayLike):
481480
return tuple(a.shape)
482481

483482

484-
def size(a, axis=None):
485-
a = asarray(a).get()
483+
@normalizer
484+
def size(a: ArrayLike, axis=None):
486485
if axis is None:
487486
return a.numel()
488487
else:

0 commit comments

Comments
 (0)