11 from builtins
import range
18 from numbers
import Number
22 def _areInstancesOfNumber( a, b ):
23 return ( isinstance( a, Number )
and isinstance( b, Number ) )
25 def _areOfTypeListOrTuple( a, b ):
26 return ( ( type( a )
in ( list, tuple ) )
and ( type( b )
in ( list, tuple ) ))
28 def _haveEqualLength( a, b ):
29 return ( len( a ) == len( b ) )
32 def _areEqual( a, b, epsilon ):
33 return ( abs( a - b ) < epsilon )
35 def _isLessThan( a, b ):
47 if ( _areInstancesOfNumber( a, b ) ):
48 result = _areEqual( a, b, epsilon )
50 elif ( _areOfTypeListOrTuple( a, b ) ):
51 if ( _haveEqualLength( a, b ) ):
53 for i
in range( 0, len( a ) ):
54 result = compareFloatEqual ( a[i], b[i], epsilon )
59 Logging_error(
"Only lists or tuples of equal length can be compared!" )
62 Logging_error(
"Only numbers can be compared!" )
75 if ( _areInstancesOfNumber( a, b ) ):
76 result = _isLessThan( a, b )
78 elif ( _areOfTypeListOrTuple( a, b ) ):
79 if ( _haveEqualLength( a, b ) ):
80 for i
in range( 0, len( a ) ):
81 result = compareFloatLessThan ( a[i], b[i] )
86 Logging_error(
"Only lists or tuples of equal length can be compared!" )
89 Logging_error(
"Only numbers can be compared!" )
107 from .Logging
import error
as Logging_error, warning
as Logging_warning, info
as Logging_info
def compareFloatEqual(a, b, epsilon=0.0001)
Compare the given float values or lists of float values for equality.
def compareFloatLessThan(a, b)
Compare the two given float values if the first is less than the second.
def compareFloatLessThanOrEqual(a, b, epsilon=0.0001)
Compare the two given float values if the first is less than or equal to the second.