Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@with_phil
def __array__(self, dtype=None):
""" Create a Numpy array containing the whole dataset. DON'T THINK
THIS MEANS DATASETS ARE INTERCHANGEABLE WITH ARRAYS. For one thing,
you have to read the whole dataset every time this method is called.
"""
arr = numpy.empty(self.shape, dtype=self.dtype if dtype is None else dtype)
# Special case for (0,)*-shape datasets
if numpy.product(self.shape, dtype=numpy.ulonglong) == 0:
return arr
self.read_direct(arr)
return arr
@with_phil
def filename(self):
"""File name on disk"""
return filename_decode(h5f.get_name(self.id))
@with_phil
def __repr__(self):
if not self._id:
return ""
return "" % id(self._id)
@with_phil
def shuffle(self):
"""Shuffle filter present (T/F)"""
return 'shuffle' in self._filters
@with_phil
def __eq__(self, other):
return hash(self) == hash(other)
@with_phil
def flush(self):
""" Flush the dataset data and metadata to the file.
If the dataset is chunked, raw data chunks are written to the file.
This is part of the SWMR features and only exist when the HDF5
library version >=1.9.178
"""
self._id.flush()
@with_phil
def __getitem__(self, name):
""" Open an object in the file """
if isinstance(name, h5r.Reference):
oid = h5r.dereference(name, self.id)
if oid is None:
raise ValueError("Invalid HDF5 object reference")
else:
oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
otype = h5i.get_type(oid)
if otype == h5i.GROUP:
return Group(oid)
elif otype == h5i.DATASET:
return dataset.Dataset(oid, readonly=(self.file.mode == 'r'))
elif otype == h5i.DATATYPE:
@with_phil
def __iter__(self):
""" Iterate over the dimensions. """
for i in range(len(self)):
yield self[i]
@with_phil
def libver(self):
"""File format version bounds (2-tuple: low, high)"""
bounds = self.id.get_access_plist().get_libver_bounds()
return tuple(libver_dict_r[x] for x in bounds)
@with_phil
def __len__(self):
""" Number of dimensions associated with the dataset. """
return len(Dataset(self._id).shape)