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.

87 lines
2.0KB

  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. from __future__ import absolute_import, division, print_function
  5. class InfinityType(object):
  6. def __repr__(self):
  7. # type: () -> str
  8. return "Infinity"
  9. def __hash__(self):
  10. # type: () -> int
  11. return hash(repr(self))
  12. def __lt__(self, other):
  13. # type: (object) -> bool
  14. return False
  15. def __le__(self, other):
  16. # type: (object) -> bool
  17. return False
  18. def __eq__(self, other):
  19. # type: (object) -> bool
  20. return isinstance(other, self.__class__)
  21. def __ne__(self, other):
  22. # type: (object) -> bool
  23. return not isinstance(other, self.__class__)
  24. def __gt__(self, other):
  25. # type: (object) -> bool
  26. return True
  27. def __ge__(self, other):
  28. # type: (object) -> bool
  29. return True
  30. def __neg__(self):
  31. # type: (object) -> NegativeInfinityType
  32. return NegativeInfinity
  33. Infinity = InfinityType()
  34. class NegativeInfinityType(object):
  35. def __repr__(self):
  36. # type: () -> str
  37. return "-Infinity"
  38. def __hash__(self):
  39. # type: () -> int
  40. return hash(repr(self))
  41. def __lt__(self, other):
  42. # type: (object) -> bool
  43. return True
  44. def __le__(self, other):
  45. # type: (object) -> bool
  46. return True
  47. def __eq__(self, other):
  48. # type: (object) -> bool
  49. return isinstance(other, self.__class__)
  50. def __ne__(self, other):
  51. # type: (object) -> bool
  52. return not isinstance(other, self.__class__)
  53. def __gt__(self, other):
  54. # type: (object) -> bool
  55. return False
  56. def __ge__(self, other):
  57. # type: (object) -> bool
  58. return False
  59. def __neg__(self):
  60. # type: (object) -> InfinityType
  61. return Infinity
  62. NegativeInfinity = NegativeInfinityType()