Skip to content

Commit

Permalink
Give more useful information for list updater
Browse files Browse the repository at this point in the history
  • Loading branch information
stammler committed Jul 20, 2023
1 parent e1fea4c commit cf9c95f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion simframe/frame/group.py
Expand Up @@ -256,7 +256,17 @@ def _createupdatefromlist(self, ls):
-------
func : callable
Function that is reduced by <self> and <ls>."""
return partial(_dummyupdatewithlist, self, ls)

# To give meaningful information a new class of partial is created
# with a new __repr__ method
class list_updater(partial):

def __repr__(self):
return type(self).__name__

f = list_updater(_dummyupdatewithlist, self, ls)
f.__doc__ = f"The attributes in this group are updated in the order: \n{ls}."
return f

def _toc(self):
ret = _toc_tree(self)
Expand Down
8 changes: 4 additions & 4 deletions simframe/frame/updater.py
Expand Up @@ -43,13 +43,13 @@ def __str__(self):
# Source/Docstring
try:
source = inspect.getsource(self._func)
cat = colorize("Source:", color="red") + "\n"
cat = colorize("Source:", color="red")
except:
source = self._func.__doc__
cat = colorize("Docstring:", color="red") + "\n"
cat = colorize("Docstring:", color="red")
if source is not None:
s += cat
s += source
s += cat + "\n"
s += source + "\n"
# File
try:
fn = inspect.getfile(self._func)
Expand Down

0 comments on commit cf9c95f

Please sign in to comment.