Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __getattr__(self, name):
try:
return self.attrs[name]
except KeyError:
raise AttributeError('NetCDF: attribute {} not found'
.format(type(self).__name__, name))
def __setattr__(self, name, value):
if self._initialized and name not in self.__dict__:
self.attrs[name] = value
else:
object.__setattr__(self, name, value)
class Variable(core.BaseVariable, HasAttributesMixin):
_cls_name = 'h5netcdf.legacyapi.Variable'
def chunking(self):
chunks = self._h5ds.chunks
if chunks is None:
return 'contiguous'
else:
return chunks
def filters(self):
complevel = self._h5ds.compression_opts
return {'complevel': 0 if complevel is None else complevel,
'fletcher32': self._h5ds.fletcher32,
'shuffle': self._h5ds.shuffle,
'zlib': self._h5ds.compression == 'gzip'}
_cls_name = 'h5netcdf.Variable'
def __repr__(self):
if self._parent._root._closed:
return '' % self._cls_name
header = ('<%s %r: dimensions %s, shape %s, dtype %s>' %
(self._cls_name, self.name, self.dimensions, self.shape,
self.dtype))
return '\n'.join([header] +
['Attributes:'] +
[' %s: %r' % (k, v)
for k, v in self.attrs.items()])
class Variable(BaseVariable):
@property
def chunks(self):
return self._h5ds.chunks
@property
def compression(self):
return self._h5ds.compression
@property
def compression_opts(self):
return self._h5ds.compression_opts
@property
def fletcher32(self):
return self._h5ds.fletcher32