From 5c7cc4cce4f068dfe1b0f22b24612176d82c61a9 Mon Sep 17 00:00:00 2001 From: Haris Mahmood Date: Mon, 2 Sep 2024 13:52:15 +0500 Subject: [PATCH] fix: Handled a case in handle_methods where attribute retrieved is actually not a callable and is all we need to return without calling it e.g. when calling .data on a class object --- ivy/utils/decorator_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ivy/utils/decorator_utils.py b/ivy/utils/decorator_utils.py index 2dbc92d1e8bc..7f2785ede136 100644 --- a/ivy/utils/decorator_utils.py +++ b/ivy/utils/decorator_utils.py @@ -169,6 +169,8 @@ def wrapper(*args, **kwargs): fn_name = extract_function_name(re.sub(pattern, "", fn.__name__)) try: new_fn = getattr(array_like, fn_name) + if not callable(new_fn): + return new_fn return new_fn(*args[1:], **kwargs) except AttributeError: return fn(*args, **kwargs) @@ -418,7 +420,7 @@ def transpose_wrapper(self, *args, **kwargs): # TODO: temp fix for `ivy.inplace_update`. Dont quite understand the way this function -# has been implemented in the backends as it seems to also have ivy.Array specific logic. +# has been implemented in the backends as it seems to also have ivy.Array specific logic # In the case where both x, and val are arrays, it simply returns x (why??) # perhaps we can rewrite it in a cleaner format and then remove this fix def dummy_inplace_update(x, val, /, *, ensure_in_backend=False, keep_input_dtype=False):