refactor: rename "decimal" variable in Decimal parameter

This commit is contained in:
Matthias
2026-02-06 20:13:36 +01:00
parent f6e465a0ba
commit 600b6a7d23
+7 -7
View File
@@ -259,8 +259,8 @@ class DecimalParameter(NumericParameter):
:param load: Load parameter value from {space}_params. :param load: Load parameter value from {space}_params.
:param kwargs: Extra parameters to optuna's NumericParameter. :param kwargs: Extra parameters to optuna's NumericParameter.
""" """
self._decimals = decimals self.decimals = decimals
default = round(default, self._decimals) default = round(default, self.decimals)
super().__init__( super().__init__(
low=low, high=high, default=default, space=space, optimize=optimize, load=load, **kwargs low=low, high=high, default=default, space=space, optimize=optimize, load=load, **kwargs
@@ -272,7 +272,7 @@ class DecimalParameter(NumericParameter):
@value.setter @value.setter
def value(self, new_value: float): def value(self, new_value: float):
self._value = round(new_value, self._decimals) self._value = round(new_value, self.decimals)
def get_space(self, name: str) -> "SKDecimal": def get_space(self, name: str) -> "SKDecimal":
""" """
@@ -280,7 +280,7 @@ class DecimalParameter(NumericParameter):
:param name: A name of parameter field. :param name: A name of parameter field.
""" """
return SKDecimal( return SKDecimal(
low=self.low, high=self.high, decimals=self._decimals, name=name, **self._space_params low=self.low, high=self.high, decimals=self.decimals, name=name, **self._space_params
) )
@property @property
@@ -292,9 +292,9 @@ class DecimalParameter(NumericParameter):
calculating 100ds of indicators. calculating 100ds of indicators.
""" """
if self.can_optimize(): if self.can_optimize():
low = int(self.low * pow(10, self._decimals)) low = int(self.low * pow(10, self.decimals))
high = int(self.high * pow(10, self._decimals)) + 1 high = int(self.high * pow(10, self.decimals)) + 1
return [round(n * pow(0.1, self._decimals), self._decimals) for n in range(low, high)] return [round(n * pow(0.1, self.decimals), self.decimals) for n in range(low, high)]
else: else:
return [self.value] return [self.value]