OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 Donald Stufft |
| 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at |
| 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. |
| 14 from __future__ import absolute_import, division, print_function |
| 15 |
| 16 |
| 17 class Infinity(object): |
| 18 |
| 19 def __repr__(self): |
| 20 return "Infinity" |
| 21 |
| 22 def __hash__(self): |
| 23 return hash(repr(self)) |
| 24 |
| 25 def __lt__(self, other): |
| 26 return False |
| 27 |
| 28 def __le__(self, other): |
| 29 return False |
| 30 |
| 31 def __eq__(self, other): |
| 32 return isinstance(other, self.__class__) |
| 33 |
| 34 def __ne__(self, other): |
| 35 return not isinstance(other, self.__class__) |
| 36 |
| 37 def __gt__(self, other): |
| 38 return True |
| 39 |
| 40 def __ge__(self, other): |
| 41 return True |
| 42 |
| 43 def __neg__(self): |
| 44 return NegativeInfinity |
| 45 |
| 46 Infinity = Infinity() |
| 47 |
| 48 |
| 49 class NegativeInfinity(object): |
| 50 |
| 51 def __repr__(self): |
| 52 return "-Infinity" |
| 53 |
| 54 def __hash__(self): |
| 55 return hash(repr(self)) |
| 56 |
| 57 def __lt__(self, other): |
| 58 return True |
| 59 |
| 60 def __le__(self, other): |
| 61 return True |
| 62 |
| 63 def __eq__(self, other): |
| 64 return isinstance(other, self.__class__) |
| 65 |
| 66 def __ne__(self, other): |
| 67 return not isinstance(other, self.__class__) |
| 68 |
| 69 def __gt__(self, other): |
| 70 return False |
| 71 |
| 72 def __ge__(self, other): |
| 73 return False |
| 74 |
| 75 def __neg__(self): |
| 76 return Infinity |
| 77 |
| 78 NegativeInfinity = NegativeInfinity() |
OLD | NEW |