Skip to content

Commit 8d645aa

Browse files
committed
Make parameter classes slotted
1 parent 4d0ef0e commit 8d645aa

File tree

7 files changed

+10
-14
lines changed

7 files changed

+10
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Wrong use of `tolerance` argument in constraints user guide
2424
- Errors with generics and type aliases in documentation
2525
- Deduplication bug in substance_data hypothesis strategy
26+
- Parameter classes are now slotted due to `cached_property` attrs support
2627

2728
### Removed
2829
- Conda install instructions and version badge

baybe/parameters/base.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
from baybe.utils import SerialMixin, get_base_structure_hook, unstructure_base
1414
from baybe.utils.serialization import converter
1515

16-
# TODO: Reactive slots in all classes once cached_property is supported:
17-
# https://github.com/python-attrs/attrs/issues/164
1816

19-
20-
@define(frozen=True, slots=False)
17+
@define(frozen=True)
2118
class Parameter(ABC, SerialMixin):
2219
"""Abstract base class for all parameters.
2320
@@ -48,12 +45,10 @@ def is_in_range(self, item: Any) -> bool:
4845
"""
4946

5047

51-
@define(frozen=True, slots=False)
48+
@define(frozen=True)
5249
class DiscreteParameter(Parameter, ABC):
5350
"""Abstract class for discrete parameters."""
5451

55-
# TODO [15280]: needs to be refactored
56-
5752
# class variables
5853
is_discrete: ClassVar[bool] = True
5954
# See base class.

baybe/parameters/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from baybe.parameters.validation import validate_unique_values
1414

1515

16-
@define(frozen=True, slots=False)
16+
@define(frozen=True)
1717
class CategoricalParameter(DiscreteParameter):
1818
"""Parameter class for categorical parameters."""
1919

@@ -55,7 +55,7 @@ def comp_df(self) -> pd.DataFrame: # noqa: D102
5555
return comp_df
5656

5757

58-
@define(frozen=True, slots=False)
58+
@define(frozen=True)
5959
class TaskParameter(CategoricalParameter):
6060
"""Parameter class for task parameters."""
6161

baybe/parameters/custom.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from baybe.utils import df_uncorrelated_features, eq_dataframe
1515

1616

17-
@define(frozen=True, slots=False)
17+
@define(frozen=True)
1818
class CustomDiscreteParameter(DiscreteParameter):
1919
"""Custom parameters.
2020

baybe/parameters/numerical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from baybe.utils import DTypeFloatNumpy, InfiniteIntervalError, Interval, convert_bounds
1616

1717

18-
@define(frozen=True, slots=False)
18+
@define(frozen=True)
1919
class NumericalDiscreteParameter(DiscreteParameter):
2020
"""Parameter class for discrete numerical parameters (a.k.a. setpoints)."""
2121

@@ -94,7 +94,7 @@ def is_in_range(self, item: float) -> bool: # noqa: D102
9494
return any(differences_acceptable)
9595

9696

97-
@define(frozen=True, slots=False)
97+
@define(frozen=True)
9898
class NumericalContinuousParameter(Parameter):
9999
"""Parameter class for continuous numerical parameters."""
100100

baybe/parameters/substance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"""Type alias for SMILES strings."""
4040

4141

42-
@define(frozen=True, slots=False)
42+
@define(frozen=True)
4343
class SubstanceParameter(DiscreteParameter):
4444
"""Generic substances that are treated with cheminformatics descriptors.
4545

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ keywords = [
2929
]
3030
dynamic = ['version']
3131
dependencies = [
32-
"attrs>=22.2.0",
32+
"attrs>=24.1.0",
3333
"botorch>=0.8.1",
3434
"cattrs>=23.2.0",
3535
"exceptiongroup",

0 commit comments

Comments
 (0)