mattjj / pyhsmm

MIT License
545 stars 172 forks source link

Python 2 and 3 operator / conflict #70

Closed tamlhp closed 7 years ago

tamlhp commented 7 years ago

In examples/svi.py line 43: data.shape[0] / training_size

In python 3, it will be not zero. In python 2, it will be zero.

However, installing pyhsmm via python3 will raise error: File "/private/var/folders/qb/6xg3bmv51cq_z6y21zdx3tzc00393b/T/pip-build-ycgo8jfr/pyhsmm/setup.py", line 11, in from urllib import urlretrieve ImportError: cannot import name 'urlretrieve'

because in python3, it becomes urllib.request

Solution Suggestion: from future import division or use a / (b*1.0)

http://stackoverflow.com/questions/1267869/how-can-i-force-division-to-be-floating-point-in-python-division-keeps-rounding

mattjj commented 7 years ago

Thanks! We have that in almost every other file, but it got deleted from svi.py by dea45c7, which was presumably a Python 3 compatibility commit (here's the line getting removed). Not sure why that happened, but it's a good idea to put it back!