Esempio n. 1
0
    def __init__(self, io, early_config, io_config, name):
        try:
            config_lp = None
            library = pressio.instance()
            self._io = pressio.get_io(library, io.encode())
            if not self._io:
                raise PressioException.from_library(library)

            if name is not None:
                pressio.compressor_set_name(self._io, name.encode())

            early_config_lp = _python_to_pressio(early_config)
            pressio.io_set_options(self._io, early_config_lp)
            pressio.options_free(early_config_lp)

            config_lp = pressio.io_get_options(self._io)
            config_lp = _python_to_pressio(io_config, config_lp)

            pressio.io_set_options(self._io, config_lp)
        finally:
            pressio.release(library)
            pressio.options_free(config_lp)
Esempio n. 2
0
sz_options = pressio.compressor_get_options(compressor)
metrics_ids = pressio.vector_string([b'time', b'size'])
metrics = pressio.new_metrics(library, metrics_ids)

pressio.options_set_string(sz_options, b"sz:error_bound_mode_str", b'abs')
pressio.options_set_double(sz_options, b"sz:abs_err_bound", 0.5)

pressio.compressor_check_options(compressor, sz_options)
pressio.compressor_set_options(compressor, sz_options)
pressio.compressor_set_metrics(compressor, metrics)

data = np.random.rand(300, 300, 300)
with tempfile.NamedTemporaryFile() as tmp:
    data.tofile(tmp)

    posix_io = pressio.get_io(library, b'posix')

    #configure read
    posix_options = pressio.io_get_options(posix_io)
    pressio.options_set_string(posix_options, b'io:path',
                               bytes(tmp.name, 'ascii'))
    pressio.io_set_options(posix_io, posix_options)

    #configure template buffer
    dims = pressio.vector_uint64_t([300, 300, 300])
    input_template = pressio.data_new_empty(pressio.double_dtype, dims)

    #preform read
    input_data = pressio.io_read(posix_io, input_template)

    compressed_data = pressio.data_new_empty(pressio.byte_dtype,