From 735e0f0065e8692343e3f896c95313f662afcf8d Mon Sep 17 00:00:00 2001 From: Jesper Sandvig Mariegaard <34088801+jsmariegaard@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:38:26 +0100 Subject: [PATCH] NotImplemented --- modelskill/skill.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modelskill/skill.py b/modelskill/skill.py index 37442f6be..d52006974 100644 --- a/modelskill/skill.py +++ b/modelskill/skill.py @@ -69,6 +69,11 @@ def _get_plot_df(self, level: int | str = 0) -> pd.DataFrame: # return gdf.explore(column=column, **kwargs) + def __call__(self, *args: Any, **kwds: Any) -> Any: + raise NotImplementedError( + "It is not possible to call plot directly (has no default)! Use one of the plot methods explicitly e.g. plot.line() or plot.bar()" + ) + def line( self, level: int | str = 0, @@ -281,6 +286,11 @@ def _deprecated_warning(method, field): # type: ignore FutureWarning, ) + def __call__(self, *args: Any, **kwds: Any) -> Any: + raise NotImplementedError( + "It is not possible to call plot directly on SkillTable! Select metric first (which gives a plotable SkillArray)" + ) + def line(self, field, **kwargs): # type: ignore self._deprecated_warning("line", field) # type: ignore return self.skilltable[field].plot.line(**kwargs) @@ -312,7 +322,7 @@ class SkillArray: def __init__(self, data: pd.DataFrame) -> None: self.data = data self._ser = data.iloc[:, -1] # last column is the metric - + self.plot = SkillArrayPlotter(self) """Plot using the SkillArrayPlotter @@ -511,12 +521,10 @@ def _repr_html_(self) -> Any: return self._df._repr_html_() @overload - def __getitem__(self, key: Hashable | int) -> SkillArray: - ... + def __getitem__(self, key: Hashable | int) -> SkillArray: ... @overload - def __getitem__(self, key: Iterable[Hashable]) -> SkillTable: - ... + def __getitem__(self, key: Iterable[Hashable]) -> SkillTable: ... def __getitem__( self, key: Hashable | Iterable[Hashable] @@ -559,7 +567,7 @@ def iloc(self, *args, **kwargs): # type: ignore @property def loc(self, *args, **kwargs): # type: ignore - return self.data.loc(*args, **kwargs) + return self.data.loc(*args, **kwargs) def sort_index(self, *args, **kwargs) -> SkillTable: # type: ignore """Sort by index (level) e.g. sorting by observation