From cf9c95fdf5fc132dc0b469c2ad1f69cd098b8c9a Mon Sep 17 00:00:00 2001 From: Sebastian Stammler Date: Thu, 20 Jul 2023 16:42:11 +0200 Subject: [PATCH] Give more useful information for list updater --- simframe/frame/group.py | 12 +++++++++++- simframe/frame/updater.py | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/simframe/frame/group.py b/simframe/frame/group.py index 837009a..be34704 100644 --- a/simframe/frame/group.py +++ b/simframe/frame/group.py @@ -256,7 +256,17 @@ def _createupdatefromlist(self, ls): ------- func : callable Function that is reduced by and .""" - 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) diff --git a/simframe/frame/updater.py b/simframe/frame/updater.py index f2ccff5..bac7de0 100644 --- a/simframe/frame/updater.py +++ b/simframe/frame/updater.py @@ -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)