Skip to content

Commit

Permalink
implement suggestion for dealing with _Unsigned attribute in issue #656
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed May 8, 2017
1 parent 37f582b commit 98e19ab
Show file tree
Hide file tree
Showing 3 changed files with 5,224 additions and 5,090 deletions.
4 changes: 3 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version 1.2.8a0 (tag XXXX)
version 1.2.8a0 (not yet released)
===========================
* recognize _Unsigned attribute used by netcdf-java to designate unsigned
integer data stored with a signed integer type in netcdf-3.
* add Dataset init memory parameter to allow loading a file from memory

version 1.2.7 (tag v1.2.7rel)
Expand Down
10,303 changes: 5,214 additions & 5,089 deletions netCDF4/_netCDF4.c

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions netCDF4/_netCDF4.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3822,6 +3822,13 @@ rename a `netCDF4.Variable` attribute named `oldname` to `newname`."""
# else if variable has only add_offset attributes, rescale.
elif hasattr(self, 'add_offset') and self.add_offset != 0.0:
data = data + self.add_offset

# if attribute _Unsigned is True, and variable has signed integer
# dtype, return view with corresponding unsigned dtype (issue #656)
is_unsigned = getattr(self, '_Unsigned', False)
if is_unsigned and data.dtype.str[1] == 'i':
data = data.view('u'+data.dtype.str[2])

return data

def _toma(self,data):
Expand Down

0 comments on commit 98e19ab

Please sign in to comment.