From ccb5f3cecabd113de0346a6ed654c7a3994ff21f Mon Sep 17 00:00:00 2001 From: Youjia Li Date: Wed, 11 Sep 2024 00:15:20 -0500 Subject: [PATCH] cleaned up comments --- src/pnetcdf/_Variable.pyx | 4 ++-- src/pnetcdf/_utils.pyx | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pnetcdf/_Variable.pyx b/src/pnetcdf/_Variable.pyx index 6acdc9b..815ec5a 100644 --- a/src/pnetcdf/_Variable.pyx +++ b/src/pnetcdf/_Variable.pyx @@ -675,8 +675,8 @@ cdef class Variable: data = np.tile(data,datashape) # reshape data array if needed to conform with start,count,stride. if data.ndim != len(datashape) or\ - (data.shape != datashape and data.ndim > 1): # issue #1083 - # create a view so shape in caller is not modified (issue 90) + (data.shape != datashape and data.ndim > 1): + # create a view so shape in caller is not modified try: # if extra singleton dims, just reshape data = data.view() data.shape = tuple(datashape) diff --git a/src/pnetcdf/_utils.pyx b/src/pnetcdf/_utils.pyx index 651635c..222e8e5 100644 --- a/src/pnetcdf/_utils.pyx +++ b/src/pnetcdf/_utils.pyx @@ -206,12 +206,12 @@ cdef _set_att(file, int varid, name, value,\ file_id = file._ncid # put attribute value into a np array. value_arr = np.array(value) - if value_arr.ndim > 1: # issue #841 + if value_arr.ndim > 1: raise ValueError('multi-dimensional array attributes not supported') N = value_arr.size if value_arr.dtype.char in ['S','U']: - # don't allow string array attributes in NETCDF3 files. + # don't allow string array attributes if N > 1: msg='array string attributes not supported' if not value_arr.shape: @@ -221,7 +221,7 @@ cdef _set_att(file, int varid, name, value,\ dats = _strencode(''.join(value_arr1.tolist())) lenarr = len(dats) datstring = dats - # TODO: resolve the special case when set attribute to none(\177) + # TODO: resolve the special case when set attribute to none with nogil: ierr = ncmpi_put_att_text(file_id, varid, attname, lenarr, datstring) _check_err(ierr, err_cls=AttributeError) @@ -551,7 +551,7 @@ cdef _StartCountStride(elem, shape, dimensions=None, file=None, datashape=None, try: dimname = dimensions[i] unlim = unlimd[dimname] - except IndexError: # more slices than dimensions (issue 371) + except IndexError: unlim = False else: unlim = False @@ -616,7 +616,6 @@ cdef _StartCountStride(elem, shape, dimensions=None, file=None, datashape=None, ee = False if ee and len(e) == len(ee) and (e == np.arange(start,stop,step)).all(): # don't convert to slice unless abs(stride) == 1 - # (nc_get_vars is very slow, issue #680) newElem.append(slice(start,stop,step)) else: newElem.append(e) @@ -648,7 +647,7 @@ cdef _StartCountStride(elem, shape, dimensions=None, file=None, datashape=None, else: sdim.append(1) - # broadcast data shape when assigned to full variable (issue #919) + # broadcast data shape when assigned to full variable try: fullslice = elem.count(slice(None,None,None)) == len(elem) except: # fails if elem contains a numpy array. @@ -656,7 +655,6 @@ cdef _StartCountStride(elem, shape, dimensions=None, file=None, datashape=None, if fullslice and datashape and put and not hasunlim: datashape = broadcasted_shape(shape, datashape) - # pad datashape with zeros for dimensions not being sliced (issue #906) # only used when data covers slice over subset of dimensions if datashape and len(datashape) != len(elem) and\ len(datashape) == sum(1 for e in elem if type(e) == slice):