Skip to content

Commit d006b5f

Browse files
author
Jeff Whitaker
committed
remove old for loop syntax
1 parent aa04241 commit d006b5f

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

src/netCDF4/_netCDF4.pyx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ cdef _get_att_names(int grpid, int varid):
15931593
ierr = nc_inq_varnatts(grpid, varid, &numatts)
15941594
_ensure_nc_success(ierr, err_cls=AttributeError)
15951595
attslist = []
1596-
for n from 0 <= n < numatts:
1596+
for n in range(numatts):
15971597
with nogil:
15981598
ierr = nc_inq_attname(grpid, varid, n, namstring)
15991599
_ensure_nc_success(ierr, err_cls=AttributeError)
@@ -1868,7 +1868,7 @@ cdef _get_types(group):
18681868
enumtypes = dict()
18691869

18701870
if ntypes > 0:
1871-
for n from 0 <= n < ntypes:
1871+
for n in range(ntypes):
18721872
xtype = typeids[n]
18731873
with nogil:
18741874
ierr = nc_inq_user_type(_grpid, xtype, namstring,
@@ -1930,9 +1930,9 @@ cdef _get_dims(group):
19301930
ierr = nc_inq_dimids(_grpid, &numdims, dimids, 0)
19311931
_ensure_nc_success(ierr)
19321932
else:
1933-
for n from 0 <= n < numdims:
1933+
for n in range(numdims):
19341934
dimids[n] = n
1935-
for n from 0 <= n < numdims:
1935+
for n in range(numdims):
19361936
with nogil:
19371937
ierr = nc_inq_dimname(_grpid, dimids[n], namstring)
19381938
_ensure_nc_success(ierr)
@@ -1959,7 +1959,7 @@ cdef _get_grps(group):
19591959
with nogil:
19601960
ierr = nc_inq_grps(_grpid, NULL, grpids)
19611961
_ensure_nc_success(ierr)
1962-
for n from 0 <= n < numgrps:
1962+
for n in range(numgrps):
19631963
with nogil:
19641964
ierr = nc_inq_grpname(grpids[n], namstring)
19651965
_ensure_nc_success(ierr)
@@ -1994,10 +1994,10 @@ cdef _get_vars(group, bint auto_complex=False):
19941994
ierr = nc_inq_varids(_grpid, &numvars, varids)
19951995
_ensure_nc_success(ierr)
19961996
else:
1997-
for n from 0 <= n < numvars:
1997+
for n in range(numvars):
19981998
varids[n] = n
19991999
# loop over variables.
2000-
for n from 0 <= n < numvars:
2000+
for n in range(numvars):
20012001
varid = varids[n]
20022002
# get variable name.
20032003
with nogil:
@@ -3761,7 +3761,7 @@ returns `True` if the `Dimension` instance is unlimited, `False` otherwise."""
37613761
ierr = nc_inq_unlimdims(self._grpid, &numunlimdims, unlimdimids)
37623762
_ensure_nc_success(ierr)
37633763
unlimdim_ids = []
3764-
for n from 0 <= n < numunlimdims:
3764+
for n in range(numunlimdims):
37653765
unlimdim_ids.append(unlimdimids[n])
37663766
free(unlimdimids)
37673767
if dimid in unlimdim_ids:
@@ -4155,7 +4155,7 @@ behavior is similar to Fortran or Matlab, but different than numpy.
41554155
# find dimension ids.
41564156
if ndims:
41574157
dimids = <int *>malloc(sizeof(int) * ndims)
4158-
for n from 0 <= n < ndims:
4158+
for n in range(ndims):
41594159
dimids[n] = dimensions[n]._dimid
41604160
# go into define mode if it's a netCDF 3 compatible
41614161
# file format. Be careful to exit define mode before
@@ -4289,7 +4289,7 @@ behavior is similar to Fortran or Matlab, but different than numpy.
42894289
if grp.data_model != 'NETCDF4': grp._enddef()
42904290
raise ValueError('chunksizes must be a sequence with the same length as dimensions')
42914291
chunksizesp = <size_t *>malloc(sizeof(size_t) * ndims)
4292-
for n from 0 <= n < ndims:
4292+
for n in range(ndims):
42934293
if not dimensions[n].isunlimited() and \
42944294
chunksizes[n] > dimensions[n].size:
42954295
msg = 'chunksize cannot exceed dimension size'
@@ -4813,7 +4813,7 @@ each dimension is returned."""
48134813
ierr = nc_inq_var_chunking(self._grpid, self._varid, &icontiguous, chunksizesp)
48144814
_ensure_nc_success(ierr)
48154815
chunksizes=[]
4816-
for n from 0 <= n < ndims:
4816+
for n in range(ndims):
48174817
chunksizes.append(chunksizesp[n])
48184818
free(chunksizesp)
48194819
if icontiguous:
@@ -5343,7 +5343,7 @@ rename a `Variable` attribute named `oldname` to `newname`."""
53435343
count = [1]*ndims
53445344
startp = <size_t *>malloc(sizeof(size_t) * ndims)
53455345
countp = <size_t *>malloc(sizeof(size_t) * ndims)
5346-
for n from 0 <= n < ndims:
5346+
for n in range(ndims):
53475347
startp[n] = start[n]
53485348
countp[n] = count[n]
53495349
if self.dtype == str: # VLEN string
@@ -5769,7 +5769,7 @@ NC_CHAR).
57695769
startp = <size_t *>malloc(sizeof(size_t) * ndims)
57705770
countp = <size_t *>malloc(sizeof(size_t) * ndims)
57715771
stridep = <ptrdiff_t *>malloc(sizeof(ptrdiff_t) * ndims)
5772-
for n from 0 <= n < ndims:
5772+
for n in range(ndims):
57735773
count[n] = abs(count[n]) # make -1 into +1
57745774
countp[n] = count[n]
57755775
# for neg strides, reverse order (then flip that axis after data read in)
@@ -5912,7 +5912,7 @@ NC_CHAR).
59125912
startp = <size_t *>malloc(sizeof(size_t) * ndims)
59135913
countp = <size_t *>malloc(sizeof(size_t) * ndims)
59145914
stridep = <ptrdiff_t *>malloc(sizeof(ptrdiff_t) * ndims)
5915-
for n from 0 <= n < ndims:
5915+
for n in range(ndims):
59165916
count[n] = abs(count[n]) # make -1 into +1
59175917
countp[n] = count[n]
59185918
# for neg strides, reverse order (then flip that axis after data read in)
@@ -6254,7 +6254,7 @@ cdef _def_compound(grp, object dt, object dtype_name):
62546254
else: # nested array compound element
62556255
ndims = len(format.shape)
62566256
dim_sizes = <int *>malloc(sizeof(int) * ndims)
6257-
for n from 0 <= n < ndims:
6257+
for n in range(ndims):
62586258
dim_sizes[n] = format.shape[n]
62596259
if format.subdtype[0].kind != 'V': # primitive type.
62606260
try:
@@ -6332,7 +6332,7 @@ cdef _read_compound(group, nc_type xtype, endian=None):
63326332
names = []
63336333
formats = []
63346334
offsets = []
6335-
for nf from 0 <= nf < nfields:
6335+
for nf in range(nfields):
63366336
with nogil:
63376337
ierr = nc_inq_compound_field(_grpid,
63386338
xtype,
@@ -6360,7 +6360,7 @@ cdef _read_compound(group, nc_type xtype, endian=None):
63606360
# if numdims=0, not an array.
63616361
field_shape = ()
63626362
if numdims != 0:
6363-
for ndim from 0 <= ndim < numdims:
6363+
for ndim in range(numdims):
63646364
field_shape = field_shape + (dim_sizes[ndim],)
63656365
free(dim_sizes)
63666366
# check to see if this field is a nested compound type.
@@ -6614,7 +6614,7 @@ cdef _read_enum(group, nc_type xtype, endian=None):
66146614
# loop over members, build dict.
66156615
enum_dict = {}
66166616
enum_val = numpy.empty(1,dt)
6617-
for nmem from 0 <= nmem < nmembers:
6617+
for nmem in range(nmembers):
66186618
with nogil:
66196619
ierr = nc_inq_enum_member(grpid, xtype, nmem, \
66206620
enum_namstring,PyArray_DATA(enum_val))

0 commit comments

Comments
 (0)