Beispiel #1
0
def _from_data_option(x):
    lp = pressio.option_get_data(x)
    if pressio.data_dtype(lp) == pressio.byte_dtype:
        ret = pressio.io_data_to_bytes(lp)
    else:
        ret = pressio.io_data_to_numpy(lp)
    pressio.data_free(lp)
    return ret
Beispiel #2
0
    def encode(self, uncompressed):
        """perform compression

        params:
            uncompressed: np.ndarray - the data to be compressed
        """
        uncompressed_lp = None
        compressed_lp = None
        try:
            uncompressed_lp = pressio.io_data_from_numpy(uncompressed)
            compressed_lp = pressio.data_new_empty(pressio.byte_dtype,
                                                   pressio.vector_uint64_t())

            rc = pressio.compressor_compress(self._compressor, uncompressed_lp,
                                             compressed_lp)
            if rc:
                raise PressioException.from_compressor(self._compressor)

            comp = pressio.io_data_to_bytes(compressed_lp)
        finally:
            pressio.data_free(uncompressed_lp)
            pressio.data_free(compressed_lp)
        return comp