5555
5656
5757class ParameterType (Enum ):
58- # pyre-fixme[35]: Target cannot be annotated.
59- BOOL : int = 0
60- # pyre-fixme[35]: Target cannot be annotated.
61- INT : int = 1
62- # pyre-fixme[35]: Target cannot be annotated.
63- FLOAT : int = 2
64- # pyre-fixme[35]: Target cannot be annotated.
65- STRING : int = 3
58+ BOOL = 0
59+ INT = 1
60+ FLOAT = 2
61+ STRING = 3
6662
6763 @property
6864 def is_numeric (self ) -> bool :
@@ -71,10 +67,7 @@ def is_numeric(self) -> bool:
7167
7268TParameterType = Union [type [int ], type [float ], type [str ], type [bool ]]
7369
74- # pyre: PARAMETER_PYTHON_TYPE_MAP is declared to have type
75- # pyre: `Dict[ParameterType, Union[Type[bool], Type[float], Type[int],
76- # pyre: Type[str]]]` but is used as type `Dict[ParameterType,
77- # pyre-fixme[9]: Type[Union[float, str]]]`.
70+ # pyre-fixme[9]: Pyre collapses individual type[] values into Type[Union[...]].
7871PARAMETER_PYTHON_TYPE_MAP : dict [ParameterType , TParameterType ] = {
7972 ParameterType .INT : int ,
8073 ParameterType .FLOAT : float ,
@@ -87,9 +80,7 @@ def is_numeric(self) -> bool:
8780] = tuple (PARAMETER_PYTHON_TYPE_MAP .values ())
8881
8982
90- # pyre-fixme[24]: Generic type `type` expects 1 type parameter, use `typing.Type` to
91- # avoid runtime subscripting errors.
92- def _get_parameter_type (python_type : type ) -> ParameterType :
83+ def _get_parameter_type (python_type : type [Any ]) -> ParameterType :
9384 """Given a Python type, retrieve corresponding Ax ``ParameterType``."""
9485 for param_type , py_type in PARAMETER_PYTHON_TYPE_MAP .items ():
9586 if py_type == python_type :
@@ -236,9 +227,8 @@ def dependents(self) -> dict[TParamValue, list[str]]:
236227 "Only fixed and choice hierarchical parameters are currently supported."
237228 )
238229
239- # pyre-fixme[7]: Expected `Parameter` but got implicit return value of `None`.
240- def clone (self ) -> Self :
241- pass
230+ @abstractmethod
231+ def clone (self ) -> Self : ...
242232
243233 def disable (self , default_value : TParamValue ) -> None :
244234 """
@@ -541,9 +531,7 @@ def set_digits(self, digits: int | None) -> RangeParameter:
541531 # Re-scale min and max to new digits definition
542532 cast_lower = self .cast (self ._lower )
543533 cast_upper = self .cast (self ._upper )
544- # `<=` is not supported for operand types `Union[float, int]` and `int`.
545- # pyre-ignore [58]
546- if cast_lower >= cast_upper :
534+ if float (cast_lower ) >= float (cast_upper ):
547535 raise UserInputError (
548536 f"Lower bound { cast_lower } is >= upper bound { cast_upper } ."
549537 )
@@ -1304,13 +1292,7 @@ class DerivedParameter(Parameter):
13041292 extendable to non-linear functions.
13051293 """
13061294
1307- # pyre-fixme [13]: Uninitialized attribute [13]: Attribute `_intercept` is
1308- # declared in class `DerivedParameter` to have type `float` but is never
1309- # initialized.
13101295 _intercept : float
1311- # pyre-fixme [13]: Uninitialized attribute [13]: Attribute
1312- # `_parameter_names_to_weights` is declared in class `DerivedParameter` to#
1313- # have type `typing.Dict[str, float]` but is never initialized.
13141296 _parameter_names_to_weights : dict [str , float ]
13151297
13161298 def __init__ (
@@ -1343,6 +1325,8 @@ def __init__(
13431325 self ._parameter_type = parameter_type # Set first so validation works
13441326 self ._is_fidelity = is_fidelity
13451327 self ._target_value = target_value
1328+ self ._intercept = 0.0
1329+ self ._parameter_names_to_weights = {}
13461330
13471331 # Parse expression and validate type constraint (reuses set_expression_str)
13481332 self .set_expression_str (expression_str )
0 commit comments