Fix lower limit checking of FloatRange

compatible used sys.float_info.min (smallest representable positive
float) instead of -sys.float_info.max.
so FloatRanges -500,10 and -10,10 were two-way compatible
Since it is correctly set in __init__, no need for the guard here

Change-Id: If693fa69a8b2de1aa52ce702bd282a84a8f4c55a
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31056
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft
2023-05-09 08:20:21 +02:00
parent 3a3ca0372b
commit 259970249a
2 changed files with 3 additions and 3 deletions

View File

@ -274,9 +274,8 @@ class FloatRange(HasUnit, DataType):
def compatible(self, other):
if not isinstance(other, (FloatRange, ScaledInteger)):
raise WrongTypeError('incompatible datatypes')
# avoid infinity
other.validate(max(sys.float_info.min, self.min))
other.validate(min(sys.float_info.max, self.max))
other.validate(self.min)
other.validate(self.max)
class IntRange(DataType):

View File

@ -658,6 +658,7 @@ def test_get_datatype():
(FloatRange(-10, 10), FloatRange()),
(IntRange(-10, 10), FloatRange()),
(IntRange(-10, 10), IntRange(-20, 10)),
(FloatRange(-10, 10), FloatRange(-15, 10)),
(StringType(), StringType(isUTF8=True)),
(StringType(10, 10), StringType()),
(ArrayOf(StringType(), 3, 5), ArrayOf(StringType(), 3, 6)),