From d079235ae6eae6d2d9701517e7d9b39e8979ef83 Mon Sep 17 00:00:00 2001 From: Jaewook Lee Date: Tue, 7 May 2024 16:56:28 +0200 Subject: [PATCH] add __call__ to ShowOption --- gustaf/helpers/options.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gustaf/helpers/options.py b/gustaf/helpers/options.py index 4a497b10..aafac64d 100644 --- a/gustaf/helpers/options.py +++ b/gustaf/helpers/options.py @@ -351,6 +351,32 @@ def __contains__(self, key): """ return key in self._options + def __call__(self, **kwargs): + """A short-cut to update(), but it returns helpee object. + This is mainly to support one-line/inline visualizations. + + Parameters + ---------- + kwargs: **kwargs + + Returns + ------- + helpee: Any + + Example + ------- + .. code-block:: python + + gus.show( + mesh1.show_options(c="red"), + mesh2.show_options(c="green"), + mesh3.show_options(c="blue"), + ) + """ + self.update(**kwargs) + + return self._helpee + def get(self, key, default=None): """ Gets value from key and default. Similar to dict.get(),