Skip to content

Commit

Permalink
Removes _close_ds functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pwolfram committed Mar 22, 2017
1 parent 9d52ce3 commit 3ddf9c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ def _read_attributes(h5netcdf_var):
_extract_h5nc_encoding = functools.partial(_extract_nc4_variable_encoding,
lsd_okay=False, backend='h5netcdf')

def _close_ds(ds):
# netCDF4 only allows closing the root group
ds = find_root(ds)
if not ds._closed:
ds.close()

def _open_h5netcdf_group(filename, mode, group):
import h5netcdf.legacyapi
ds = h5netcdf.legacyapi.Dataset(filename, mode=mode)
Expand Down Expand Up @@ -162,5 +156,8 @@ def sync(self):

def close(self):
if self._isopen:
_close_ds(self.ds)
# netCDF4 only allows closing the root group
ds = find_root(self.ds)
if not ds._closed:
ds.close()
self._isopen = False
11 changes: 4 additions & 7 deletions xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@ def _extract_nc4_variable_encoding(variable, raise_on_invalid=False,

return encoding

def _close_ds(ds):
# netCDF4 only allows closing the root group
ds = find_root(ds)
if ds._isopen:
ds.close()


def _open_netcdf4_group(filename, mode, group=None, **kwargs):
import netCDF4 as nc4
Expand Down Expand Up @@ -342,5 +336,8 @@ def sync(self):

def close(self):
if self._isopen:
_close_ds(self.ds)
# netCDF4 only allows closing the root group
ds = find_root(self.ds)
if ds._isopen:
ds.close()
self._isopen = False

0 comments on commit 3ddf9c1

Please sign in to comment.