diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fcb475fcf..17b19caaf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +- Parameter classes are now slotted due to `cached_property` attrs support + ## [0.10.0] - 2024-08-02 ### Breaking Changes - Providing an explicit `batch_size` is now mandatory when asking for recommendations diff --git a/baybe/parameters/base.py b/baybe/parameters/base.py index 4eef14a657..bfa13b8b2b 100644 --- a/baybe/parameters/base.py +++ b/baybe/parameters/base.py @@ -24,11 +24,7 @@ from baybe.searchspace.core import SearchSpace from baybe.searchspace.discrete import SubspaceDiscrete -# 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. @@ -79,12 +75,10 @@ def to_searchspace(self) -> SearchSpace: return SearchSpace.from_parameter(self) -@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 encoding: ParameterEncoding | None = field(init=False, default=None) """An optional encoding for the parameter.""" diff --git a/baybe/parameters/categorical.py b/baybe/parameters/categorical.py index dc47a57ff9..d44521d6f4 100644 --- a/baybe/parameters/categorical.py +++ b/baybe/parameters/categorical.py @@ -14,7 +14,7 @@ from baybe.utils.numerical import DTypeFloatNumpy -@define(frozen=True, slots=False) +@define(frozen=True) class CategoricalParameter(DiscreteParameter): """Parameter class for categorical parameters.""" @@ -60,7 +60,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 aa9b721c66..120f6c6591 100644 --- a/baybe/parameters/custom.py +++ b/baybe/parameters/custom.py @@ -16,7 +16,7 @@ from baybe.utils.numerical import DTypeFloatNumpy -@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 93dbb8e7fc..3040b3a67d 100644 --- a/baybe/parameters/numerical.py +++ b/baybe/parameters/numerical.py @@ -16,7 +16,7 @@ from baybe.utils.numerical import DTypeFloatNumpy -@define(frozen=True, slots=False) +@define(frozen=True) class NumericalDiscreteParameter(DiscreteParameter): """Parameter class for discrete numerical parameters (a.k.a. setpoints).""" @@ -97,7 +97,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(ContinuousParameter): """Parameter class for continuous numerical parameters.""" diff --git a/baybe/parameters/substance.py b/baybe/parameters/substance.py index 40a741238f..f4b21860e6 100644 --- a/baybe/parameters/substance.py +++ b/baybe/parameters/substance.py @@ -23,7 +23,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 974e4f9c70..fdb67dbff3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ keywords = [ ] dynamic = ['version'] dependencies = [ - "attrs>=22.2.0", + "attrs>=24.1.0", "botorch>=0.9.3,<1", "cattrs>=23.2.0", "exceptiongroup",