fix: DecimalParameter shouldn't have floating point errors

closes #12152
This commit is contained in:
Matthias
2025-08-24 17:03:55 +02:00
parent b4796cbf73
commit eaf6abecc8
+8 -1
View File
@@ -225,7 +225,6 @@ class RealParameter(NumericParameter):
class DecimalParameter(NumericParameter): class DecimalParameter(NumericParameter):
default: float default: float
value: float
def __init__( def __init__(
self, self,
@@ -259,6 +258,14 @@ class DecimalParameter(NumericParameter):
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
) )
@property
def value(self) -> float:
return self._value
@value.setter
def value(self, new_value: float):
self._value = round(new_value, self._decimals)
def get_space(self, name: str) -> "SKDecimal": def get_space(self, name: str) -> "SKDecimal":
""" """
Create optimization space. Create optimization space.