Skip to content

Commit

Permalink
fix decorator_utils: improved the implementation of handle_methods de…
Browse files Browse the repository at this point in the history
…corator to handle cases where the 1st argument is an iterable
  • Loading branch information
YushaArif99 committed Aug 17, 2024
1 parent cb8ef58 commit 95848bc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ivy/utils/decorator_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,20 @@ def extract_function_name(s):

@functools.wraps(fn)
def wrapper(*args, **kwargs):
if ivy.is_array(args[0]):
array_like = args[0]
if isinstance(array_like, (list, tuple)):
array_like = array_like[0]

if ivy.is_array(array_like):
return fn(*args, **kwargs)
else:
pattern = r"_bknd_|_bknd|_frnt_|_frnt"
fn_name = extract_function_name(re.sub(pattern, "", fn.__name__))
new_fn = getattr(args[0], fn_name)
return new_fn(*args[1:], **kwargs)
try:
new_fn = getattr(array_like, fn_name)
return new_fn(*args[1:], **kwargs)
except AttributeError:
return fn(*args, **kwargs)

return wrapper

Expand Down

0 comments on commit 95848bc

Please sign in to comment.