lucastheis / c2s

A toolbox for inferring spikes from calcium traces.
http://c2s.readthedocs.org
MIT License
22 stars 13 forks source link

IndexError for window_length / 2 with __future__ division #14

Open alexklibisz opened 7 years ago

alexklibisz commented 7 years ago

I get the following error when calling c2s.train:

File "/raid/alex-scratch/pyenvs/py2ml/local/lib/python2.7/site-packages/c2s/c2s.py", line 362, in train
    output_mask[1, window_length / 2] = True
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

Referring to this line: https://github.com/lucastheis/c2s/blob/master/c2s/c2s.py#L362

This change seems to fix it:

output_mask[1, int(window_length / 2)] = True

I believe it happens because another library I'm using uses from __future__ import division, which makes any division return a float.

It would be a trivial fix to cast all the indexes that use division to integers, but I'm not sure if that would change the behavior in a way that matters for other functionality.