Skip to content

Slice indices are not integers #3

Description

@mavrix93

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions