fix: DecimalParameter shouldn't have floating point errors
closes #12152
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user