From 7b8c028a800aff2357625263852a542bf7e61d56 Mon Sep 17 00:00:00 2001 From: Philipp Schlegel Date: Thu, 29 Aug 2024 09:51:22 +0100 Subject: [PATCH] Settings: add name attribute (for error message) --- navis/plotting/settings.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/navis/plotting/settings.py b/navis/plotting/settings.py index 007f19ef..3737f987 100644 --- a/navis/plotting/settings.py +++ b/navis/plotting/settings.py @@ -17,11 +17,12 @@ class Settings: # We can define synonyms for arguments, so that they can be used interchangeably _synonyms: List[Tuple] = field(default_factory=list) + _name = "Settings" def __setattr__(self, key, value, check_valid=False): if check_valid and key not in self.properties: raise AttributeError( - f"The '{key}' argument is invalid. Valid arguments are: {', '.join(self.properties)}" + f"The '{key}' argument is invalid for {self._name}. Valid arguments are: {', '.join(self.properties)}" ) self.__dict__[key] = value @@ -71,6 +72,8 @@ def pop(self, key, default=None): class BasePlottingSettings(Settings): """Plotting parameters common to all functions/backends.""" + _name = "BasePlottingSettings" + # For TreeNeurons soma: bool = True radius: bool = True @@ -122,6 +125,8 @@ class BasePlottingSettings(Settings): class Matplotlib2dSettings(BasePlottingSettings): """Additional plotting parameters for Matplotlib 2d backend.""" + _name = "matplotlib backend" + method: Literal["2d", "3d", "3d_complex"] = "3d" group_neurons: bool = False autoscale: bool = True @@ -143,6 +148,8 @@ class Matplotlib2dSettings(BasePlottingSettings): class PlotlySettings(BasePlottingSettings): """Additional plotting parameters for Plotly backend.""" + _name = "plotly backend" + fig: Optional[Union["plotly.Figure", dict]] = None inline: bool = True title: Optional[str] = None @@ -159,6 +166,8 @@ class PlotlySettings(BasePlottingSettings): class VispySettings(BasePlottingSettings): """Additional plotting parameters for Vispy backend.""" + _name = "vispy backend" + clear: bool = False center: bool = True combine: bool = False @@ -175,6 +184,8 @@ class VispySettings(BasePlottingSettings): class OctarineSettings(BasePlottingSettings): """Additional plotting parameters for Octarine backend.""" + _name = "octarine backend" + clear: bool = False center: bool = True viewer: Optional[Union["octarine.Viewer", Literal["new"]]] = None @@ -196,7 +207,7 @@ class OctarineSettings(BasePlottingSettings): "show", "size", "offscreen", - "scatter_kws" + "scatter_kws", ) @@ -204,6 +215,8 @@ class OctarineSettings(BasePlottingSettings): class K3dSettings(BasePlottingSettings): """Additional plotting parameters for K3d backend.""" + _name = "k3d backend" + height: int = 600 inline: bool = True legend_group: Optional[str] = None