8000 FutureWarning when using slice. · Issue #833 · Unidata/netcdf4-python · GitHub
[go: up one dir, main page]

Skip to content

FutureWarning when using slice. #833

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

Closed
brorfred opened this issue Aug 19, 2018 · 2 comments
Closed

FutureWarning when using slice. #833

brorfred opened this issue Aug 19, 2018 · 2 comments

Comments

@brorfred
Copy link
brorfred commented Aug 19, 2018

Dear all,

Numpy recently turned on a deprecation warning for indexing with lists containing None (arr[[None, 0]], numpy/numpy#9686). This seems to be biting netCDF4 when using the 'slice' command. The following code works fine.

Aarr = np.zeros((100,100))
aslice = (slice(5,7,-1), slice(5,7))
Aarr[aslice]

result:

Out[192]: 
array([[0., 0.],
       [0., 0.]])

But an analogous case with netCDF4

#curl -O https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A20021852018181.L3m_CU_PAR_par_9km.nc

nc = netCDF4.Dataset("A20021852018181.L3m_CU_PAR_par_9km.nc")
aslice = (slice(5,7,-1), slice(5,7))
nc.variables["par"][aslice]

triggers the warning

/Users/bror/anaconda3/bin/ipython3w: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. 

/Bror Jonsson

@jswhit
Copy link
Collaborator
jswhit commented Aug 19, 2018

Confirmed. Will take some digging to see where this warning is being emitted.

jswhit pushed a commit that referenced this issue Aug 20, 2018
fix numpy deprecation warning for non-tuple slices (issue #833)
@jswhit
Copy link
Collaborator
jswhit commented Aug 20, 2018

Fixed by pull request #834 - thanks for the report!

@jswhit jswhit closed this as completed Aug 20, 2018
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

2 participants
0