def truncate(self, size): """Truncate the main dimension to be `size` rows. If the main dimension previously was larger than this `size`, the extra data is lost. If the main dimension previously was shorter, it is extended, and the extended part is filled with the default values. The truncation operation can only be applied to *enlargeable* datasets, else a `TypeError` will be raised. .. Warning:: If you are using the HDF5 1.6.x series, and due to limitations of them, `size` must be greater than zero (i.e. the dataset can not be completely emptied). A `ValueError` will be issued if you are using HDF5 1.6.x and try to pass a zero size to this method. HDF5 1.8.x doesn't undergo this problem. """ # A non-enlargeable arrays (Array, CArray) cannot be truncated if self.extdim < 0: raise TypeError("non-enlargeable datasets cannot be truncated") if (size > 0 or (size == 0 and whichLibVersion("hdf5")[1] >= "1.8.0")): self._g_truncate(size) else: raise ValueError(""" `size` must be greater than 0 if you are using HDF5 < 1.8.0. With HDF5 1.8.0 and higher, `size` can also be 0 or greater.""")
def __init__(self, complevel=0, complib=default_complib, shuffle=True, fletcher32=False, _new=True): if not (0 <= complevel <= 9): raise ValueError("compression level must be between 0 and 9") if _new and complevel > 0: # These checks are not performed when loading filters from disk. if complib not in all_complibs: raise ValueError( "compression library ``%s`` is not supported; " "it must be one of: %s" % (complib, ", ".join(all_complibs))) if utilsExtension.whichLibVersion(complib) is None: warnings.warn( "compression library ``%s`` is not available; " "using ``%s`` instead" % (complib, default_complib), FiltersWarning) complib = default_complib # always available complevel = int(complevel) complib = str(complib) shuffle = bool(shuffle) fletcher32 = bool(fletcher32) if complevel == 0: # Override some inputs when compression is not enabled. complib = None # make it clear there is no compression shuffle = False # shuffling and not compressing makes no sense elif complib not in all_complibs: # Do not try to use a meaningful level for unsupported libs. complevel = -1 self.complevel = complevel """The compression level (0 disables compression).""" self.complib = complib """ The compression filter used (irrelevant when compression is not enabled). """ self.shuffle = shuffle """Whether the *Shuffle* filter is active or not.""" self.fletcher32 = fletcher32 """Whether the *Fletcher32* filter is active or not."""
def __init__( self, complevel=0, complib=default_complib, shuffle=True, fletcher32=False, _new=True ): if not (0 <= complevel <= 9): raise ValueError("compression level must be between 0 and 9") if _new and complevel > 0: # These checks are not performed when loading filters from disk. if complib not in all_complibs: raise ValueError( "compression library ``%s`` is not supported; " "it must be one of: %s" % (complib, ", ".join(all_complibs)) ) if utilsExtension.whichLibVersion(complib) is None: warnings.warn( "compression library ``%s`` is not available; " "using ``%s`` instead" % (complib, default_complib), FiltersWarning ) complib = default_complib # always available complevel = int(complevel) complib = str(complib) shuffle = bool(shuffle) fletcher32 = bool(fletcher32) if complevel == 0: # Override some inputs when compression is not enabled. complib = None # make it clear there is no compression shuffle = False # shuffling and not compressing makes no sense elif complib not in all_complibs: # Do not try to use a meaningful level for unsupported libs. complevel = -1 self.complevel = complevel """The compression level (0 disables compression).""" self.complib = complib """ The compression filter used (irrelevant when compression is not enabled). """ self.shuffle = shuffle """Whether the *Shuffle* filter is active or not.""" self.fletcher32 = fletcher32 """Whether the *Fletcher32* filter is active or not."""
def __init__( self, complevel=0, complib=default_complib, shuffle=True, fletcher32=False, _new=True ): """ Create a new `Filters` instance. `complevel` Specifies a compression level for data. The allowed range is 0-9. A value of 0 (the default) disables compression. `complib` Specifies the compression library to be used. Right now, 'zlib' (the default), 'lzo', 'bzip2' and 'blosc' are supported. Specifying a compression library which is not available in the system issues a `FiltersWarning` and sets the library to the default one. `shuffle` Whether or not to use the *Shuffle* filter in the HDF5 library. This is normally used to improve the compression ratio. A false value disables shuffling and a true one enables it. The default value depends on whether compression is enabled or not; if compression is enabled, shuffling defaults to be enabled, else shuffling is disabled. Shuffling can only be used when compression is enabled. `fletcher32` Whether or not to use the *Fletcher32* filter in the HDF5 library. This is used to add a checksum on each data chunk. A false value (the default) disables the checksum. """ if not (0 <= complevel <= 9): raise ValueError("compression level must be between 0 and 9") if _new and complevel > 0: # These checks are not performed when loading filters from disk. if complib not in all_complibs: raise ValueError( "compression library ``%s`` is not supported; " "it must be one of: %s" % (complib, ", ".join(all_complibs)) ) if utilsExtension.whichLibVersion(complib) is None: warnings.warn( "compression library ``%s`` is not available; " "using ``%s`` instead" % (complib, default_complib), FiltersWarning ) complib = default_complib # always available complevel = int(complevel) complib = str(complib) shuffle = bool(shuffle) fletcher32 = bool(fletcher32) if complevel == 0: # Override some inputs when compression is not enabled. complib = None # make it clear there is no compression shuffle = False # shuffling and not compressing makes no sense elif complib not in all_complibs: # Do not try to use a meaningful level for unsupported libs. complevel = -1 self.complevel = complevel """The compression level (0 disables compression).""" self.complib = complib """ The compression filter used (irrelevant when compression is not enabled). """ self.shuffle = shuffle """Whether the *Shuffle* filter is active or not.""" self.fletcher32 = fletcher32 """Whether the *Fletcher32* filter is active or not."""
def __init__(self, complevel=0, complib=default_complib, shuffle=True, fletcher32=False, _new=True): """ Create a new `Filters` instance. `complevel` Specifies a compression level for data. The allowed range is 0-9. A value of 0 (the default) disables compression. `complib` Specifies the compression library to be used. Right now, 'zlib' (the default), 'lzo' and 'bzip2' are supported. Specifying a compression library which is not available in the system issues a `FiltersWarning` and sets the library to the default one. `shuffle` Whether or not to use the *Shuffle* filter in the HDF5 library. This is normally used to improve the compression ratio. A false value disables shuffling and a true one enables it. The default value depends on whether compression is enabled or not; if compression is enabled, shuffling defaults to be enabled, else shuffling is disabled. Shuffling can only be used when compression is enabled. `fletcher32` Whether or not to use the *Fletcher32* filter in the HDF5 library. This is used to add a checksum on each data chunk. A false value (the default) disables the checksum. """ if not (0 <= complevel <= 9): raise ValueError("compression level must be between 0 and 9") if _new and complevel > 0: # These checks are not performed when loading filters from disk. if complib not in all_complibs: raise ValueError( "compression library ``%s`` is not supported; " "it must be one of: %s" % (complib, ", ".join(all_complibs))) if utilsExtension.whichLibVersion(complib) is None: warnings.warn( "compression library ``%s`` is not available; " "using ``%s`` instead" % (complib, default_complib), FiltersWarning) complib = default_complib # always available complevel = int(complevel) complib = str(complib) shuffle = bool(shuffle) fletcher32 = bool(fletcher32) if complevel == 0: # Override some inputs when compression is not enabled. complib = None # make it clear there is no compression shuffle = False # shuffling and not compressing makes no sense elif complib not in all_complibs: # Do not try to use a meaningful level for unsupported libs. complevel = -1 self.complevel = complevel """The compression level (0 disables compression).""" self.complib = complib """ The compression filter used (irrelevant when compression is not enabled). """ self.shuffle = shuffle """Whether the *Shuffle* filter is active or not.""" self.fletcher32 = fletcher32 """Whether the *Fletcher32* filter is active or not."""