Skip to content

IndexError for window_length / 2 with __future__ division #14

@alexklibisz

Description

@alexklibisz

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.

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