You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6KB

  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. class InfinityType:
  5. def __repr__(self) -> str:
  6. return "Infinity"
  7. def __hash__(self) -> int:
  8. return hash(repr(self))
  9. def __lt__(self, other: object) -> bool:
  10. return False
  11. def __le__(self, other: object) -> bool:
  12. return False
  13. def __eq__(self, other: object) -> bool:
  14. return isinstance(other, self.__class__)
  15. def __ne__(self, other: object) -> bool:
  16. return not isinstance(other, self.__class__)
  17. def __gt__(self, other: object) -> bool:
  18. return True
  19. def __ge__(self, other: object) -> bool:
  20. return True
  21. def __neg__(self: object) -> "NegativeInfinityType":
  22. return NegativeInfinity
  23. Infinity = InfinityType()
  24. class NegativeInfinityType:
  25. def __repr__(self) -> str:
  26. return "-Infinity"
  27. def __hash__(self) -> int:
  28. return hash(repr(self))
  29. def __lt__(self, other: object) -> bool:
  30. return True
  31. def __le__(self, other: object) -> bool:
  32. return True
  33. def __eq__(self, other: object) -> bool:
  34. return isinstance(other, self.__class__)
  35. def __ne__(self, other: object) -> bool:
  36. return not isinstance(other, self.__class__)
  37. def __gt__(self, other: object) -> bool:
  38. return False
  39. def __ge__(self, other: object) -> bool:
  40. return False
  41. def __neg__(self: object) -> InfinityType:
  42. return Infinity
  43. NegativeInfinity = NegativeInfinityType()