def _value_to_ratio(self, value): """Convert from value to ratio.""" return ( math_tools.sign(value) * (2 / math.pi) * math.acos(math.exp(-(math.pi * math.sqrt(abs(value))) / (2 * math.sqrt(self.sensitivity)))) )
def __pow__(self, other): if isinstance(other, Infinity): raise object # todo elif is_floatable(other): s = math_tools.sign(other) if s==0: raise InfinityRaceError else: if self.direction==1: if s==1: return self if s==-1: return 0 else: #self.direction == -1 if is_nonfractional(other): if s==-1: return 0 if s==1: if s % 2 == 0: return Infinity() else: return Infinity(-1) else: # is_nonfractional(other) is False raise ValueError("Negative number cannot be raised " "to a fractional power")
def __pow__(self, other): if isinstance(other, Infinity): raise object # todo elif is_floatable(other): s = math_tools.sign(other) if s == 0: raise InfinityRaceError else: if self.direction == 1: if s == 1: return self if s == -1: return 0 else: #self.direction == -1 if is_nonfractional(other): if s == -1: return 0 if s == 1: if s % 2 == 0: return Infinity() else: return Infinity(-1) else: # is_nonfractional(other) is False raise ValueError("Negative number cannot be raised " "to a fractional power")
def _ratio_to_value(self, ratio): """Convert from ratio to value.""" return ( self.sensitivity * math_tools.sign(ratio) * (4 / math.pi ** 2) * math.log(math.cos(ratio * math.pi / 2)) ** 2 )
def __div__(self, other): if isinstance(other, Infinity): raise InfinityRaceError elif is_floatable(other): s = math_tools.sign(other) if s==0: raise InfinityRaceError else: return Infinity(direction=self.direction * s)
def __div__(self, other): if isinstance(other, Infinity): raise InfinityRaceError elif is_floatable(other): s = math_tools.sign(other) if s == 0: raise InfinityRaceError else: return Infinity(direction=self.direction * s)
def _value_to_ratio(self, value): '''Convert from value to ratio.''' return math_tools.sign(value) * \ (2 / math.pi) * \ math.acos( math.exp( - (math.pi * math.sqrt(abs(value))) / \ (2 * math.sqrt(self.sensitivity)) ) )
def _ratio_to_value(self, ratio): '''Convert from ratio to value.''' return self.sensitivity * \ math_tools.sign(ratio) * \ (4 / math.pi**2) * \ math.log(math.cos(ratio * math.pi / 2))**2