magicpy
magicpy copied to clipboard
TypeError: 'float' object cannot be interpreted as an integer
Every time I try to run ./example.sh, this happens:
Traceback (most recent call last):
File "/home/user/magicpy/magicpy.py", line 53, in <module>
pattern = gen_pattern(pattern_width, depth_map.size[1])
File "/home/user/magicpy/magicpy.py", line 27, in gen_pattern
return numpy.random.randint(0, 256, (width, height))
File "mtrand.pyx", line 765, in numpy.random.mtrand.RandomState.randint
File "_bounded_integers.pyx", line 1256, in numpy.random._bounded_integers._rand_int64
TypeError: 'float' object cannot be interpreted as an integer
This is related to the fact, that the calculation of the patterns with returned a float value, replace:
pattern_width = depth_map.size[0] / args.pattern_div
with:
pattern_width = int(depth_map.size[0] / args.pattern_div)
You are almost certainly are using Python 3 the code is written for Python 2, you'll need to fix few more things:
- Replace
xrangewithrange - Cast values from the
patternarray to int, since Numpy uses a differentintinternally.:int(pattern[x, y])