Skip to content

Commit

Permalink
Fix python3 slice issue(setitem) and flake8 (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadeau4 committed Jun 20, 2018
1 parent e2a12a8 commit f32c86b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Src/Cdunifmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3089,14 +3089,20 @@ static int PyCdunifVariableObject_ass_subscript(PyCdunifVariableObject *self,
if (PySlice_Check(index)) {
Py_ssize_t slicelen;
int length;
if( self->dimensions[0] == self->file->recdim ){
length = INT_MAX;
if( self->dimids[0]== self->file->recdim &&
self->dimensions[0] == 0){
length = INT_MAX;
} else {
length = self->dimensions[0];
}
PySlice_GetIndicesEx((PySliceObject *) index, length,
&indices->start, &indices->stop, &indices->stride,
&slicelen);

if(indices->stop == indices->start){
indices->stop = indices->start + indices->stride;
}
return PyCdunifVariable_WriteArray(self, indices, value);
}
if (PyTuple_Check(index)) {
Expand Down
2 changes: 1 addition & 1 deletion regrid2/Lib/esmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def __call__(self, srcField=None, dstField=None, zero_region=None):
# default is keep the masked values intact
zeroregion = ESMF.Region.SELECT
if self.regridMethod == CONSERVE:
zeroregion = None # will initalize to zero
zeroregion = None # will initalize to zero

self.regridHandle(
srcfield=srcField.field,
Expand Down
2 changes: 1 addition & 1 deletion regrid2/Lib/mvESMFRegrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def apply(self, srcData, dstData, rootPe, globalIndexing=False, **args):

zero_region = ESMF.Region.SELECT
if 'zero_region' in args.keys():
zero_region=args.get('zero_region')
zero_region = args.get('zero_region')

self.srcFld.field.data[:] = srcData.T
self.dstFld.field.data[:] = dstData.T
Expand Down

0 comments on commit f32c86b

Please sign in to comment.