A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Unidata/netcdf4-python/issues/919 below:

Assignment 2d numpy array to 3d variable with first dimension of length 1 has changed behavior · Issue #919 · Unidata/netcdf4-python · GitHub

In version 1.5.1 the following code errors:

We are assigning a shape (100, 100) array to a (1, 100, 100) variable.
Not sure if this is supposed to work but it did in the past.

import netCDF4
import numpy as np

with netCDF4.Dataset('test.nc','w') as f:
    f.createDimension('time',1)
    f.createDimension('lat',100)
    f.createDimension('lon',100)

    f.createVariable('v1',np.float,('time', 'lon','lat',))
    arr = np.arange(100*100).reshape((100, 100))
    f['v1'][:] = arr
  File "01-160948.py", line 11, in <module>
    f['v1'][:] = arr
  File "netCDF4/_netCDF4.pyx", line 4796, in netCDF4._netCDF4.Variable.__setitem__
  File "/home/cpa/.pyenv/versions/miniconda2-4.3.30/envs/libsat/lib/python3.6/site-packages/netCDF4/utils.py", line 352, in _StartCountStride
    datashapenew = datashapenew + (datashape[i],)
IndexError: tuple index out of range

It works up to version 1.5.0.1


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4