Commit e8b50c60 authored by Tatuya Kamada's avatar Tatuya Kamada

simulation: Test the divergence with epsilon span on Float Divergence Tester by default

Before:
 Float Divergence Tester does not test the divergence even if Divergence Provider is ON

After:
 Float Divergence Tester test the divergence with epsilon span if Divergence Provider is ON

We needed the following condition to test the divergence on Float Divergence
Tester:

"Divergence Provider is ON"  AND
("Absolute Tolerance has some value"  OR
 "Relative Tolerance has some value" )

However this default behavior was not consistent with other testers, and
difficult to notice from the user interface.
Thus test the divergence by default with the epsilon span which is defined in
FloatDivergenceTester class.
parent d28d8f2d
...@@ -117,14 +117,23 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin): ...@@ -117,14 +117,23 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin):
# XXX we should use appropriate property sheets and getter methods # XXX we should use appropriate property sheets and getter methods
# for these properties. # for these properties.
# Maybe, but beware of default values of quantity when doing so # Maybe, but beware of default values of quantity when doing so
absolute_tolerance_min = self.getProperty('quantity_range_min') tolerance_base = self.getProperty('tolerance_base')
# If torelance_base is None, check the divergece with epsilon-span by default
# If torelance_base is not None, we can use tolerance_base (absolute has priority)
if tolerance_base is None:
absolute_tolerance_min = self.getProperty('quantity_range_min') or -epsilon
else:
absolute_tolerance_min = self.getProperty('quantity_range_min')
if absolute_tolerance_min is not None and \ if absolute_tolerance_min is not None and \
delta < (absolute_tolerance_min or - epsilon): delta < (absolute_tolerance_min or - epsilon):
return ( return (
prevision_value, decision_value, prevision_value, decision_value,
explanation_start + 'is less than ${value}.', explanation_start + 'is less than ${value}.',
getMappingDict(value=absolute_tolerance_min)) getMappingDict(value=absolute_tolerance_min))
absolute_tolerance_max = self.getProperty('quantity_range_max') if tolerance_base is None:
absolute_tolerance_max = self.getProperty('quantity_range_max') or epsilon
else:
absolute_tolerance_max = self.getProperty('quantity_range_max')
if absolute_tolerance_max is not None and \ if absolute_tolerance_max is not None and \
delta > (absolute_tolerance_max or epsilon): delta > (absolute_tolerance_max or epsilon):
return ( return (
...@@ -132,7 +141,6 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin): ...@@ -132,7 +141,6 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin):
explanation_start + 'is larger than ${value}.', explanation_start + 'is larger than ${value}.',
getMappingDict(value=absolute_tolerance_max)) getMappingDict(value=absolute_tolerance_max))
tolerance_base = self.getProperty('tolerance_base')
base = None base = None
if tolerance_base == 'resource_quantity_precision': if tolerance_base == 'resource_quantity_precision':
# Precision of this movement's resource base unit quantity # Precision of this movement's resource base unit quantity
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment