MCPcopy Create free account
hub / github.com/PageBot/PageBot / __le__

Method __le__

Lib/pagebot/toolbox/units.py:734–757  ·  view source on GitHub ↗

Answers the boolean result how self compares to rendered u. >>> u = pt(20) >>> u <= 20 True >>> u <= 19 False >>> u <= pt(20) # Compare with different unit instances of same class True >>> u <= mm(20) # Compare with unit instance of di

(self, u)

Source from the content-addressed store, hash-verified

732 return True
733
734 def __le__(self, u):
735 """Answers the boolean result how self compares to rendered u.
736
737 >>> u = pt(20)
738 >>> u <= 20
739 True
740 >>> u <= 19
741 False
742 >>> u <= pt(20) # Compare with different unit instances of same class
743 True
744 >>> u <= mm(20) # Compare with unit instance of different class.
745 True
746 >>> u <= mm(2) # Compare with unit instance of different class.
747 False
748 >>> u <= [] # All other situations are not matching
749 False
750 """
751 if isinstance(u, (int, float)): # One is a scalar, just compare
752 return self.rv <= u
753 if isUnit(u):
754 if isinstance(u, self.__class__):
755 return self.rv <= u.rv
756 return self.pt <= u.pt # Incompatible unit types, compare via points
757 return False
758
759 def __lt__(self, u):
760 """Answers the boolean result how self compares to rendered u.

Callers

nothing calls this directly

Calls 1

isUnitFunction · 0.85

Tested by

no test coverage detected