LBL-EESA / fastkde

Other
50 stars 10 forks source link

Fix Python 3 bug with integer division #10

Closed rlwastro closed 2 years ago

rlwastro commented 2 years ago

The midPointAccessor variable, which is used various places in the code (mainly but not exclusively in verbose prints), is supposed to be a tuple of integers to index the array. But the form used for the division:

(tp-1)/2

produces a floating point result in Python 3. And a tuple of floats is no longer allowed as an index to a numpy array. The fix is to force integer division (which is clearly the intent here):

(tp-1)//2

This fix was made 3 places in the code. It fixes an error in the print statements when beVerbose=True is specified.

rlwastro commented 2 years ago

If you are still trying to maintain compatibility with Python 2.7, you could add this at the top of the module:

from __future__ import division

taobrienlbl commented 2 years ago

This is awesome, thanks so much @rlwastro!