isadoranun / FATS

MIT License
75 stars 40 forks source link

Slice indices are not integers #3

Open mavrix93 opened 7 years ago

mavrix93 commented 7 years ago

Hello,

I found bugs in some classes for feature extractions. The issue is with slice indices which should be integers (but the are floats). For example this error:

/usr/local/lib/python2.7/dist-packages/FATS/FeatureFunctionLib.pyc in fit(self, data) 27 sorted_mag = np.sort(magnitude) 28 ---> 29 return (np.median(sorted_mag[-math.ceil(0.05 N):]) - 30 np.median(sorted_mag[0:math.ceil(0.05 N)])) / 2.0 31 # return sorted_mag[10]

TypeError: slice indices must be integers or None or have an index method

Method math.ceil returns floats. So it would be sufficient to wrap it by int().

Another example in the file lomb.py line 150: wk1 = wk1[1:nout+1]
wk2 = wk2[1:nout+1]

since variable "nout" is float it should look like this: wk1 = wk1[1:int(nout)+1]
wk2 = wk2[1:int(nout)+1]

This version works for me.

I would like to use this library in my package, so I would be grateful to have these little bugs fixed.

Thank you.

ipashchenko commented 7 years ago

Hi, @mavrix93 ! I think that is because you are using Python2 and math.ceil returns a float in Python2. In Python3 it returns an integer and all is OK. Actually, setup.py indicates that Python2 is supported.

kiranvarmas commented 6 years ago

@ipashchenko how did u import the FATS in python3? I believe we get a syntax error when trying to import the FATS in python 3 as the code is written in python2 and the print is a statement in py2 where as py3 expects print to be a function. Could you share if you applied any fix while importing into python3?

ipashchenko commented 6 years ago

@kiranvarmas , i ended-up re-writing FATS to this. Here is an example usage (with tsfresh) to calculate features for OGLE and Kepler data.