Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bwohlberg committed May 10, 2024
1 parent f2231d5 commit cec4a26
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scico/util.py
Expand Up @@ -235,24 +235,26 @@ def apply_decorator(
indent = " " * 4 * level
if seen is None:
seen = defaultdict(int)
# Iterate over objects in module
for obj_name in dir(module):
obj = getattr(module, obj_name)
if hasattr(obj, "__module__") and obj.__module__[0:5] == "scico":
qualname = obj.__module__ + "." + obj.__qualname__
if isinstance(obj, (types.FunctionType, PjitFunction)):
if not seen[qualname]:
if not seen[qualname]: # avoid multiple applications of decorator
setattr(module, obj_name, decorator(obj))
seen[qualname] += 1
if verbose:
print(f"{indent}Function: {qualname}")
elif isinstance(obj, type):
if verbose:
print(f"{indent}Class: {qualname}")
# Iterate over class attributes
for attr_name in dir(obj):
attr = getattr(obj, attr_name)
if isinstance(attr, types.FunctionType):
qualname = attr.__module__ + "." + attr.__qualname__
if not seen[qualname]:
if not seen[qualname]: # avoid multiple applications of decorator
setattr(obj, attr_name, decorator(attr))
seen[qualname] += 1
if verbose:
Expand Down

0 comments on commit cec4a26

Please sign in to comment.