random method incompatible with numpy.int64
Issue #39
closed
The random
method raises an exception if the argument is a numpy.int64
:
>>> from lea import *
>>> from numpy import int64
>>> tuples = list(zip(range(10), range(10, 20)))
>>> leagen = Lea.fromValFreqs(*tuples)
>>> leagen.random(10)
(0, 4, 4, 7, 5, 7, 2, 3, 9, 7)
>>> npint = int64(10)
>>> leagen.random(npint)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/ali/.virtualenvs/unicity/lib/python3.5/site-packages/lea/lea.py",
line 1719, in random
return tuple(islice(self.randomIter(),n))
ValueError: Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.
(reported by Ali Farzanehfar)
Comments (7)
-
reporter -
reporter Coerce argument of itertools.islice to int (refs
#39)→ <<cset a786cb11a499>>
-
reporter Coerce argument of itertools.islice to int (refs
#39)→ <<cset a4d2f88d29c5>>
-
reporter - changed status to resolved
-
reporter - changed status to closed
-
reporter Coerce argument of itertools.islice to int (refs
#39)→ <<cset 12c76a1ce385>>
-
reporter Coerce argument of itertools.islice to int (refs
#39)→ <<cset 5429506abbb4>>
- Log in to comment
A possible workaround is to invoke Python's
int
function:The correction in Lea should update the
random
method to make this call on its argument.