def CalculateDOM(self, value): """ This method calculates the degree of membership for a particular value :param value: :return: """ # Test for the case where the left or right offsets are zero # (to prevent divide by zero errors below) if (Utils.IsEqual(self._rightOffset, 0.0) and (Utils.IsEqual(self._peakPoint, value))) or \ (Utils.IsEqual(self._leftOffset, 0.0) and (Utils.IsEqual(self._peakPoint, value))): return 1.0 # Find DOM if left of center elif (value <= self._peakPoint) and (value > (self._peakPoint - self._leftOffset)): grad = 1.0 / self._leftOffset return grad * (value - (self._peakPoint - self._leftOffset)) # Find DOM if right of center and less than center + right offset elif (value > self._peakPoint) and (value <= self._peakPoint + self._rightOffset): return 1.0 # out of range of this FLV, return zero else: return 0.0
def test_SpecifyThatDecimalValuesCanBeCompared(self): value = 1.23456789 self.assertEqual(Utils.IsEqual(value, value + Utils.EPSILON / 2), True) self.assertEqual(Utils.IsEqual(value, value + Utils.EPSILON * 2), False)