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

FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated #6667

Closed
lucianopaz opened this issue Dec 11, 2018 · 3 comments

Comments

@lucianopaz
Copy link
Contributor

@lucianopaz lucianopaz commented Dec 11, 2018

While using pymc3 I ran into some FutureWarning's while performing advanced indexing on a tensor variable. This is a minimal code that reproduces the warning (treated as an exception) along with its traceback.

import warnings
import numpy as np
import theano
from theano import tensor


theano.config.compute_test_value = 'raise'

with warnings.catch_warnings(record=True) as w:
    # Cause all warnings to always be triggered.
    warnings.simplefilter("error")
    n = 10
    size = 1000

    a = np.random.randn(n)
    inds = np.random.randint(0, n, size=size)

    A = tensor.dvector('A')
    A.tag.test_value = a
    B = A[inds, None]

The traceback is the following

  File "/home/lpaz/Dropbox/Luciano/issue pymc3/theano_warn.py", line 28, in <module>
    B = A[inds, None]

  File "/home/lpaz/anaconda3/lib/python3.6/site-packages/theano/tensor/var.py", line 572, in __getitem__
    return theano.tensor.subtensor.advanced_subtensor(self, *args)

  File "/home/lpaz/anaconda3/lib/python3.6/site-packages/theano/gof/op.py", line 674, in __call__
    required = thunk()

  File "/home/lpaz/anaconda3/lib/python3.6/site-packages/theano/gof/op.py", line 892, in rval
    r = p(n, [x[0] for x in i], o)

  File "/home/lpaz/anaconda3/lib/python3.6/site-packages/theano/tensor/subtensor.py", line 2190, in perform
    rval = inputs[0].__getitem__(inputs[1:])

 FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use
`arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index,
`arr[np.array(seq)]`, which will result either in an error or a different result.
@nouiz

This comment has been minimized.

Copy link
Member

@nouiz nouiz commented Dec 11, 2018

@lucianopaz

This comment has been minimized.

Copy link
Contributor Author

@lucianopaz lucianopaz commented Dec 11, 2018

The version of numpy that I'm using is 1.15.4. This does not break theano, it's a regular warning. I just treated it as an exception with this block

with warnings.catch_warnings(record=True) as w:
    # Cause all warnings to always be triggered.
    warnings.simplefilter("error")

to get the full traceback to what was actually raising the warning

@lucianopaz

This comment has been minimized.

Copy link
Contributor Author

@lucianopaz lucianopaz commented Nov 8, 2019

Closed by #6703

@lucianopaz lucianopaz closed this Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.