Skip to content

Commit 3010bdc

Browse files
Use func instead of __code__ to identify decorated functions (#213)
1 parent 449622b commit 3010bdc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fink_utils/spark/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,15 @@ def expand_function_from_string(df, str_func):
343343
module = importlib.import_module(module_name)
344344
filter_func = getattr(module, filter_name, None)
345345

346-
if hasattr(filter_func, "__code__"):
347-
ninput = filter_func.__code__.co_argcount
348-
# Note: This works only with `struct` fields - not `array`
349-
argnames = filter_func.__code__.co_varnames[:ninput]
350-
else:
346+
if hasattr(filter_func, "func"):
351347
# Assume decorated function (typically ZTF)
352348
ninput = filter_func.func.__code__.co_argcount
353349
# Note: This works only with `struct` fields - not `array`
354350
argnames = filter_func.func.__code__.co_varnames[:ninput]
351+
else:
352+
ninput = filter_func.__code__.co_argcount
353+
# Note: This works only with `struct` fields - not `array`
354+
argnames = filter_func.__code__.co_varnames[:ninput]
355355

356356
colnames = []
357357
for argname in argnames:

0 commit comments

Comments
 (0)