Skip to content

Commit

Permalink
Make parameter classes slotted
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Jan 4, 2024
1 parent 4d0ef0e commit 8d645aa
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions baybe/parameters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions baybe/parameters/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion baybe/parameters/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions baybe/parameters/numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""

Expand Down Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion baybe/parameters/substance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8d645aa

Please sign in to comment.