File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 1313 qSimpleRegret ,
1414 qUpperConfidenceBound ,
1515)
16- from baybe .acquisition .adapter import AdapterModel
17- from baybe .acquisition .partial import PartialAcquisitionFunction
1816
1917EI = ExpectedImprovement
2018qEI = qExpectedImprovement
5553 "PI" ,
5654 "qPI" ,
5755 "qSR" ,
58- # -----------------------------
59- # Helpers
60- "AdapterModel" ,
61- "PartialAcquisitionFunction" ,
6256]
Original file line number Diff line number Diff line change 1010import pandas as pd
1111from attrs import define
1212
13- from baybe .acquisition .adapter import AdapterModel
1413from baybe .serialization .core import (
1514 converter ,
1615 get_base_structure_hook ,
1716 unstructure_base ,
1817)
1918from baybe .serialization .mixin import SerialMixin
2019from baybe .surrogates .base import Surrogate
21- from baybe .utils .basic import filter_attributes
22- from baybe .utils .dataframe import to_tensor
20+ from baybe .utils .basic import classproperty , filter_attributes
2321
2422
2523@define (frozen = True )
@@ -29,8 +27,7 @@ class AcquisitionFunction(ABC, SerialMixin):
2927 _abbreviation : ClassVar [str ]
3028 """An alternative name for type resolution."""
3129
32- @classmethod
33- @property
30+ @classproperty
3431 def is_mc (cls ) -> bool :
3532 """Flag indicating whether this is a Monte-Carlo acquisition function."""
3633 return cls ._abbreviation .startswith ("q" )
@@ -44,6 +41,9 @@ def to_botorch(
4441 """Create the botorch-ready representation of the function."""
4542 import botorch .acquisition as botorch_analytical_acqf
4643
44+ from baybe .acquisition .adapter import AdapterModel
45+ from baybe .utils .dataframe import to_tensor
46+
4747 acqf_cls = getattr (botorch_analytical_acqf , self .__class__ .__name__ )
4848 fields_dict = filter_attributes (object = self , callable_ = acqf_cls .__init__ )
4949
Original file line number Diff line number Diff line change @@ -128,3 +128,18 @@ def filter_attributes(
128128 for p in params
129129 if (p not in ignore ) and hasattr (object , p )
130130 }
131+
132+
133+ class classproperty :
134+ """A decorator to make class properties.
135+
136+ A class property combines the characteristics of @property and @classmethod. The
137+ simple chaining of these two existing decorators is deprecated and causes mypy
138+ issues.
139+ """
140+
141+ def __init__ (self , fn : Callable ) -> None :
142+ self .fn = fn
143+
144+ def __get__ (self , _ , cl : type ):
145+ return self .fn (cl )
You can’t perform that action at this time.
0 commit comments