Answers the boolean result how self compares to rendered u. >>> u = pt(20) >>> u < 21 True >>> u < 20 False >>> u < pt(21) # Compare with different unit instances of same class True >>> u < mm(20) # Compare with unit instance of differ
(self, u)
| 757 | return False |
| 758 | |
| 759 | def __lt__(self, u): |
| 760 | """Answers the boolean result how self compares to rendered u. |
| 761 | |
| 762 | >>> u = pt(20) |
| 763 | >>> u < 21 |
| 764 | True |
| 765 | >>> u < 20 |
| 766 | False |
| 767 | >>> u < pt(21) # Compare with different unit instances of same class |
| 768 | True |
| 769 | >>> u < mm(20) # Compare with unit instance of different class. |
| 770 | True |
| 771 | >>> u < mm(2) # Compare with unit instance of different class. |
| 772 | False |
| 773 | >>> u < [] # All other situations are not matching |
| 774 | False |
| 775 | """ |
| 776 | if isinstance(u, (int, float)): # One is a scalar, just compare |
| 777 | return self.rv < u |
| 778 | if isUnit(u): |
| 779 | if isinstance(u, self.__class__): |
| 780 | return self.rv < u.rv |
| 781 | return self.pt < u.pt # Incompatible unit types, compare via points |
| 782 | return False |
| 783 | |
| 784 | def __ge__(self, u): |
| 785 | """Answers the boolean result how self compares to rendered u. |