Skip to content

Commit

Permalink
Merge pull request #58 from Parallel-NetCDF/cmt_clean
Browse files Browse the repository at this point in the history
cleaned up comments
  • Loading branch information
wkliao authored Sep 11, 2024
2 parents a60aa15 + ccb5f3c commit 32c3272
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/pnetcdf/_Variable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions src/pnetcdf/_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -648,15 +647,14 @@ 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.
fullslice = False
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):
Expand Down

0 comments on commit 32c3272

Please sign in to comment.