Skip to content

Commit c81bb9e

Browse files
committed
MAINT: use normalizations across namespace functions
nuke asarray_replacer as no longer used.
1 parent ff394e9 commit c81bb9e

File tree

3 files changed

+160
-182
lines changed

3 files changed

+160
-182
lines changed

torch_np/_funcs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def wrapped(*args, **kwds):
131131
# 5. axes : live in _impl or in types? several ways of handling them
132132
# 6. keepdims : peel off, postprocess
133133
# 7. OutLike : normal & keyword-only, peel off, postprocess
134-
# 8. *args
134+
# 8. [LOOKS OK] *args
135135

136136
# finally, pass normalized arguments through
137137
result = func(*ba.args, **ba.kwargs)
@@ -145,7 +145,6 @@ def wrapped(*args, **kwds):
145145

146146
@normalizer
147147
def nonzero(a: ArrayLike):
148-
# (tensor,) = _helpers.to_tensors(a)
149148
result = a.nonzero(as_tuple=True)
150149
return _helpers.tuple_arrays_from(result)
151150

torch_np/_ndarray.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -470,25 +470,6 @@ def maybe_set_base(tensor, base):
470470
return ndarray._from_tensor_and_base(tensor, base)
471471

472472

473-
class asarray_replacer:
474-
def __init__(self, dispatch="one"):
475-
if dispatch not in ["one", "two"]:
476-
raise ValueError("ararray_replacer: unknown dispatch %s" % dispatch)
477-
self._dispatch = dispatch
478-
479-
def __call__(self, func):
480-
if self._dispatch == "one":
481-
482-
@functools.wraps(func)
483-
def wrapped(x, *args, **kwds):
484-
x_tensor = asarray(x).get()
485-
return asarray(func(x_tensor, *args, **kwds))
486-
487-
return wrapped
488-
else:
489-
raise ValueError
490-
491-
492473
###### dtype routines
493474

494475

0 commit comments

Comments
 (0)