Exemple #1
0
 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))))
     )
Exemple #2
0
 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")            
Exemple #3
0
 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")
Exemple #4
0
 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
     )
Exemple #5
0
 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)
Exemple #6
0
 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)
Exemple #7
0
 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))
                )
            )
Exemple #8
0
 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))
                )
            )
Exemple #9
0
 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
Exemple #10
0
 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