diff --git a/CHANGELOG.md b/CHANGELOG.md index b21f618d2..7ead9b6d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Wrong use of `tolerance` argument in constraints user guide - Errors with generics and type aliases in documentation - Deduplication bug in substance_data hypothesis strategy +- Parameter classes are now slotted due to `cached_property` attrs support ### Removed - Conda install instructions and version badge diff --git a/baybe/parameters/base.py b/baybe/parameters/base.py index c795b5812..19d5d50af 100644 --- a/baybe/parameters/base.py +++ b/baybe/parameters/base.py @@ -13,11 +13,8 @@ from baybe.utils import SerialMixin, get_base_structure_hook, unstructure_base from baybe.utils.serialization import converter -# TODO: Reactive slots in all classes once cached_property is supported: -# https://github.com/python-attrs/attrs/issues/164 - -@define(frozen=True, slots=False) +@define(frozen=True) class Parameter(ABC, SerialMixin): """Abstract base class for all parameters. @@ -48,12 +45,10 @@ def is_in_range(self, item: Any) -> bool: """ -@define(frozen=True, slots=False) +@define(frozen=True) class DiscreteParameter(Parameter, ABC): """Abstract class for discrete parameters.""" - # TODO [15280]: needs to be refactored - # class variables is_discrete: ClassVar[bool] = True # See base class. diff --git a/baybe/parameters/categorical.py b/baybe/parameters/categorical.py index 8992ae27e..88c5d782d 100644 --- a/baybe/parameters/categorical.py +++ b/baybe/parameters/categorical.py @@ -13,7 +13,7 @@ from baybe.parameters.validation import validate_unique_values -@define(frozen=True, slots=False) +@define(frozen=True) class CategoricalParameter(DiscreteParameter): """Parameter class for categorical parameters.""" @@ -55,7 +55,7 @@ def comp_df(self) -> pd.DataFrame: # noqa: D102 return comp_df -@define(frozen=True, slots=False) +@define(frozen=True) class TaskParameter(CategoricalParameter): """Parameter class for task parameters.""" diff --git a/baybe/parameters/custom.py b/baybe/parameters/custom.py index 03fc6c92a..2352f99fb 100644 --- a/baybe/parameters/custom.py +++ b/baybe/parameters/custom.py @@ -14,7 +14,7 @@ from baybe.utils import df_uncorrelated_features, eq_dataframe -@define(frozen=True, slots=False) +@define(frozen=True) class CustomDiscreteParameter(DiscreteParameter): """Custom parameters. diff --git a/baybe/parameters/numerical.py b/baybe/parameters/numerical.py index 867a80d03..f7d2ae845 100644 --- a/baybe/parameters/numerical.py +++ b/baybe/parameters/numerical.py @@ -15,7 +15,7 @@ from baybe.utils import DTypeFloatNumpy, InfiniteIntervalError, Interval, convert_bounds -@define(frozen=True, slots=False) +@define(frozen=True) class NumericalDiscreteParameter(DiscreteParameter): """Parameter class for discrete numerical parameters (a.k.a. setpoints).""" @@ -94,7 +94,7 @@ def is_in_range(self, item: float) -> bool: # noqa: D102 return any(differences_acceptable) -@define(frozen=True, slots=False) +@define(frozen=True) class NumericalContinuousParameter(Parameter): """Parameter class for continuous numerical parameters.""" diff --git a/baybe/parameters/substance.py b/baybe/parameters/substance.py index abd77c005..88508504a 100644 --- a/baybe/parameters/substance.py +++ b/baybe/parameters/substance.py @@ -39,7 +39,7 @@ """Type alias for SMILES strings.""" -@define(frozen=True, slots=False) +@define(frozen=True) class SubstanceParameter(DiscreteParameter): """Generic substances that are treated with cheminformatics descriptors. diff --git a/pyproject.toml b/pyproject.toml index 642f43457..a87371c03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ keywords = [ ] dynamic = ['version'] dependencies = [ - "attrs>=22.2.0", + "attrs>=24.1.0", "botorch>=0.8.1", "cattrs>=23.2.0", "exceptiongroup",