maroba / findiff

Python package for numerical derivatives and partial differential equations in any number of dimensions.
MIT License
420 stars 60 forks source link

Future warning when using sequences for indexing #18

Closed sabian2008 closed 5 years ago

sabian2008 commented 5 years ago

For the latest versions of Python 3 (tested in python 3.6.8), initializing a FinDiff class displays a FutureWarning due to the usage of sequences instead of tuples for array indexing. I found several examples of this in operators.py, most of them in the FinDiff class definition.

Minor refactoring enclosing sequences with tuple() should fix this warning (and possible silent error in future versions of Python).

The full warning reads:

/usr/local/lib/python3.6/site-packages/findiff/findiff.py:242: 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. yd[ref_multi_slice] += w * y[off_multi_slice]

maroba commented 5 years ago

Thanks for the notification! I updated to code to replace the deprecated use of non-tuple sequences. Version 0.6.3 is now available at pypi.

sabian2008 commented 5 years ago

Thanks for the notification! I updated to code to replace the deprecated use of non-tuple sequences. Version 0.6.3 is now available at pypi.

That was fast! Thanks a lot! Just updated from pypi and can confirm it works as expected for my use case.