File size: 928 Bytes
079c32c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import random
import numpy as np
from ding.utils.compression_helper import get_data_compressor, get_data_decompressor

import pytest


@pytest.mark.unittest
class TestCompression():

    def get_step_data(self):
        return {'input': [random.randint(10, 100) for i in range(100)]}

    def testnaive(self):
        compress_names = ['lz4', 'zlib', 'none']
        for s in compress_names:
            compressor = get_data_compressor(s)
            decompressor = get_data_decompressor(s)
            data = self.get_step_data()
            assert data == decompressor(compressor(data))

    def test_arr_to_st(self):
        data = np.random.randint(0, 255, (96, 96, 3), dtype=np.uint8)
        compress_names = ['jpeg']
        for s in compress_names:
            compressor = get_data_compressor(s)
            decompressor = get_data_decompressor(s)
            assert data.shape == decompressor(compressor(data)).shape