pafoster / pyitlib

A library of information-theoretic methods for data analysis and machine learning, implemented in Python and NumPy.
MIT License
90 stars 17 forks source link

Futurize the code (add Python 3 and Python 2 compatibility) #4

Closed multimeric closed 5 years ago

multimeric commented 5 years ago

Basically what I did here was run futurize -w . --stage2 on the code, see http://python-future.org/futurize.html for details.

The main changes are importing the new range function and using that instead of xrange, and also importing old_div, which mimics Python2's division for both Python 2 and 3. What would be preferable is to from __future__ import division (which enables Python 3's division), and then using either // or / depending on if you want integer division or not. See here for details. I'm not really able to tell from your code which kind of division you want. I assume it's not floor division //, but I'm not certain.