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