-
-
Save feriat/3210ff8fdca3a40e4fed to your computer and use it in GitHub Desktop.
DataJoy mini bug with __builtin__
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class llist(__builtin__.list): | |
"""Special list for Ordered Models. Element -1 is -Inf, Final element is Inf. | |
-------------------------------------------------------- | |
EXAMPLE: | |
x = llist([12.,14,2.2]) | |
x[1] | |
>>>14 | |
x[-1], x[3] | |
>>>(-inf, inf) | |
x[-2] | |
>>>IndexError: Not supported index -2 was called. | |
""" | |
def __getitem__(self, l): | |
if l == -1: | |
return -np.inf | |
elif l == len(self): | |
return np.inf | |
elif l < -1 or l > len(self): | |
raise IndexError, "Not supported index %i was called."%l | |
else: | |
return super(llist,self).__getitem__(l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "CNOP.py", line 13, in <module> | |
class llist(__builtin__.list): | |
NameError: name '__builtin__' is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment