Пример #1
0
def test_compression():
    for cur_type in (np.int8, np.int16, np.int32, np.int64,
                     np.uint8, np.uint16, np.uint32, np.uint64):
        compressed = pypolycomp.diffrle_compress(np.array([1, 1, 1, 2, 3],
                                                          dtype=cur_type))
        assert np.all(compressed == np.array([1, 2, 0, 2, 1],
                                             dtype=cur_type))
Пример #2
0
def test_decompression():
    for cur_type in (np.int8, np.int16, np.int32, np.int64, np.uint8,
                     np.uint16, np.uint32, np.uint64):
        input_values = np.array(np.random.randint(100, size=1000),
                                dtype=cur_type)
        compressed = pypolycomp.diffrle_compress(input_values)
        output_values = pypolycomp.diffrle_decompress(compressed)
        assert np.all(input_values == output_values)
Пример #3
0
def test_decompression():
    for cur_type in (np.int8, np.int16, np.int32, np.int64,
                     np.uint8, np.uint16, np.uint32, np.uint64):
        input_values = np.array(np.random.randint(100, size=1000),
                                dtype=cur_type)
        compressed = pypolycomp.diffrle_compress(input_values)
        output_values = pypolycomp.diffrle_decompress(compressed)
        assert np.all(input_values == output_values)
Пример #4
0
def compress_and_encode_diffrle(parser, table, samples_format, samples, debug):
    """Save "samples" in a binary table (differenced RLE compression)

    This function is called by "compress_to_FITS_table".
    """

    # Remove unused parameters
    del parser
    del debug

    compr_samples = ppc.diffrle_compress(samples)
    return (pyfits.BinTableHDU.from_columns([
        pyfits.Column(name=table, format=samples_format, array=compr_samples)
    ]), compr_samples.itemsize * compr_samples.size)
Пример #5
0
def compress_and_encode_diffrle(parser, table, samples_format, samples, debug):
    """Save "samples" in a binary table (differenced RLE compression)

    This function is called by "compress_to_FITS_table".
    """

    # Remove unused parameters
    del parser
    del debug

    compr_samples = ppc.diffrle_compress(samples)
    return (pyfits.BinTableHDU.from_columns([
        pyfits.Column(name=table, format=samples_format,
                      array=compr_samples)]),
            compr_samples.itemsize * compr_samples.size)
Пример #6
0
def test_compression():
    for cur_type in (np.int8, np.int16, np.int32, np.int64, np.uint8,
                     np.uint16, np.uint32, np.uint64):
        compressed = pypolycomp.diffrle_compress(
            np.array([1, 1, 1, 2, 3], dtype=cur_type))
        assert np.all(compressed == np.array([1, 2, 0, 2, 1], dtype=cur_type))