diff --git a/src/modelskill/comparison/_collection.py b/src/modelskill/comparison/_collection.py index 3d1cad9bd..40bb97f06 100644 --- a/src/modelskill/comparison/_collection.py +++ b/src/modelskill/comparison/_collection.py @@ -107,9 +107,6 @@ def _name(self) -> str: def _unit_text(self) -> str: # Picking the first one is arbitrary, but it should be the same for all # we could check that they are all the same, but let's assume that they are - # for cmp in self: - # if cmp._unit_text != text: - # warnings.warn(f"Unit text is inconsistent: {text} vs {cmp._unit_text}") return self[0]._unit_text @property diff --git a/src/modelskill/comparison/_comparison.py b/src/modelskill/comparison/_comparison.py index 8838184e5..f0bf5d536 100644 --- a/src/modelskill/comparison/_comparison.py +++ b/src/modelskill/comparison/_comparison.py @@ -116,12 +116,6 @@ def _parse_dataset(data: xr.Dataset) -> xr.Dataset: data.attrs["gtype"] = str(GeometryType.NODE) else: data.attrs["gtype"] = str(GeometryType.POINT) - # assert "gtype" in data.attrs, "data must have a gtype attribute" - # assert data.attrs["gtype"] in [ - # str(GeometryType.POINT), - # str(GeometryType.TRACK), - # ], f"data attribute 'gtype' must be one of {GeometryType.POINT} or {GeometryType.TRACK}" - if "color" not in data["Observation"].attrs: data["Observation"].attrs["color"] = "black" @@ -614,17 +608,6 @@ def time(self) -> pd.DatetimeIndex: """time of compared data as pandas DatetimeIndex""" return self.data.time.to_index() - # TODO: Should we keep these? (renamed to start_time and end_time) - # @property - # def start(self) -> pd.Timestamp: - # """start pd.Timestamp of compared data""" - # return self.time[0] - - # @property - # def end(self) -> pd.Timestamp: - # """end pd.Timestamp of compared data""" - # return self.time[-1] - @property def x(self) -> Any: """x-coordinate""" diff --git a/src/modelskill/settings.py b/src/modelskill/settings.py index 73e7063ba..28d03fc5b 100644 --- a/src/modelskill/settings.py +++ b/src/modelskill/settings.py @@ -192,19 +192,6 @@ def _describe_option_short(pat: str = "", _print_desc: bool = True) -> str | Non return s -def _describe_option(pat: str = "", _print_desc: bool = True) -> str | None: - keys = _select_options(pat) - if len(keys) == 0: - raise OptionError("No such keys(s)") - - s = "\n".join([_build_option_description(k) for k in keys]) - - if _print_desc: - print(s) - return None - return s - - def reset_option(pat: str = "", silent: bool = False) -> None: """Reset one or more options (matching a pattern) to the default value @@ -337,11 +324,6 @@ def _build_option_description(k: str) -> str: return s -# temporary disabled -# get_option = _get_option -# set_option = _set_option -# reset_option = _reset_option -# describe_option = _describe_option options = OptionsContainer(_global_settings) @@ -453,22 +435,11 @@ def inner(x) -> None: ) # a list can be used as a tuple -def is_callable(obj) -> bool: - if not callable(obj): - raise ValueError("Value must be a callable") - return True - - def is_positive(value) -> None: if not (np.isreal(value) and value > 0): raise ValueError("Value must be a number greater than 0") -def is_nonnegative(value) -> None: - if not (np.isreal(value) and value >= 0): - raise ValueError("Value must be a non-negative number") - - def is_between_0_and_1(value) -> None: if not (np.isreal(value) and value >= 0 and value <= 1): raise ValueError("Value must be a number between 0 and 1") diff --git a/src/modelskill/skill.py b/src/modelskill/skill.py index d16bda8dd..b41cf75d1 100644 --- a/src/modelskill/skill.py +++ b/src/modelskill/skill.py @@ -56,21 +56,6 @@ def _get_plot_df(self, level: int | str = 0) -> pd.DataFrame: df = ser.to_frame() return df - # TODO hide this for now until we are certain about the API - # def map(self, **kwargs): - # if "model" in self.skillarray.data.index.names: - # n_models = len(self.skillarray.data.reset_index().model.unique()) - # if n_models > 1: - # raise ValueError( - # "map() is only possible for single model skill. Use .sel(model=...) to select a single model." - # ) - - # gdf = self.skillarray.to_geodataframe() - # column = self.skillarray.name - # kwargs = {"marker_kwds": {"radius": 10}} | kwargs - - # 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()" diff --git a/src/modelskill/timeseries/_timeseries.py b/src/modelskill/timeseries/_timeseries.py index bba5d78f7..c53de27d0 100644 --- a/src/modelskill/timeseries/_timeseries.py +++ b/src/modelskill/timeseries/_timeseries.py @@ -274,10 +274,6 @@ def _coordinate_values(self, coord: str) -> None | float | np.ndarray: vals = self.data[coord].values return np.atleast_1d(vals)[0] if vals.ndim == 0 else vals - @property - def _is_modelresult(self) -> bool: - return bool(self.data[self.name].attrs["kind"] == "model") - @property def values(self) -> np.ndarray: """Values as numpy array""" diff --git a/src/modelskill/utils.py b/src/modelskill/utils.py index 43435dd93..892d6ae89 100644 --- a/src/modelskill/utils.py +++ b/src/modelskill/utils.py @@ -4,7 +4,7 @@ import numpy as np import pandas as pd import xarray as xr -from collections.abc import Hashable, Iterable +from collections.abc import Hashable _RESERVED_NAMES = ["Observation", "time", "x", "y", "z"] @@ -67,52 +67,6 @@ def rename_coords_pd(df: pd.DataFrame) -> pd.DataFrame: return df.rename(columns=mapping) -# def get_item_name_and_idx( -# item_names: List[str], item: int | str | None = None -# ) -> Tuple[str, int]: -# """Returns the name and index of the requested variable, provided -# either as either a str or int. - -# Examples -# -------- -# >>> get_item_name_and_idx(['a', 'b', 'c'], 1) -# ('b', 1) -# >>> get_item_name_and_idx(['a', 'b', 'c'], 'a') -# ('a', 0) -# >>> get_item_name_and_idx(['a', 'b', 'c'], -1) -# ('c', 2) -# """ -# n_items = len(item_names) -# if item is None: -# if n_items == 1: -# return item_names[0], 0 -# else: -# raise ValueError( -# f"item must be specified when more than one item available. Available items: {item_names}" -# ) -# if isinstance(item, int): -# if item < 0: # Handle negative indices -# item = n_items + item -# if (item < 0) or (item >= n_items): -# raise IndexError(f"item {item} out of range (0, {n_items-1})") -# return item_names[item], item -# elif isinstance(item, str): -# if item not in item_names: -# raise KeyError(f"item must be one of {item_names}, got {item}.") -# return item, item_names.index(item) -# else: -# raise TypeError("item must be int or string") - - -def is_iterable_not_str(obj): - """Check if an object is an iterable but not a string.""" - if isinstance(obj, str): - return False - if isinstance(obj, Iterable): - return True - return False - - def make_unique_index( df_index: pd.DatetimeIndex, offset_duplicates: float = 0.001, warn: bool = True ) -> pd.DatetimeIndex: