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

Newer versions of numpy (>= 1.12.0) does not accept float as array index #22

Open
Mestrace opened this issue Mar 26, 2018 · 0 comments
Open

Comments

@Mestrace
Copy link

Encountered this problem on pyBN/pyBN/classes/factor.py, method reduce_factor
` 585 """
586 exp_len = len(self.cpt)/float(self.card[rv])
--> 587 new_cpt = np.zeros((exp_len,))
588
589 val_idx = self.bn.F[rv]['values'].index(val)

TypeError: 'float' object cannot be interpreted as an index`

In line 587, the exp_len will be type float and the newer version of numpy does not accept it.

From numpy release note:

DeprecationWarning to error

Indexing with floats raises IndexError, e.g., a[0, 0.0].
Indexing with non-integer array_like raises IndexError, e.g., a['1', '2']
Indexing with multiple ellipsis raises IndexError, e.g., a[..., ...].
Non-integers used as index values raise TypeError, e.g., in reshape, take, and specifying reduce axis.

I reinstall the numpy==1.11.3 and that fixed the problem. But I suggest that the type should be cast to int, and there might be other places that has the same problem, too.

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

1 participant