Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slice indices are not integers #3

Open
mavrix93 opened this issue May 10, 2017 · 3 comments
Open

Slice indices are not integers #3

mavrix93 opened this issue May 10, 2017 · 3 comments

Comments

@mavrix93
Copy link

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
Copy link

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
Copy link

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants