import numpy as np
from pysz import compress, decompress


def test_compress_decompress():
    a = np.linspace(0, 100, num=1000000).reshape((100, 100, 100)).astype(np.float32)
    tolerance = 0.0001
    compressed = compress(a, tolerance=tolerance)

    recovered = decompress(compressed, a.shape, a.dtype)
    
    assert(a.shape == recovered.shape)
    assert(np.allclose(a, recovered, atol=tolerance))


test_compress_decompress()

[((216, 248), 'pysz.compress', 'compress', (['a'], {'tolerance': 'tolerance'}), '(a, tolerance=tolerance)\n', (224, 248), False, 'from pysz import compress, decompress\n'), ((266, 306), 'pysz.decompress', 'decompress', (['compressed', 'a.shape', 'a.dtype'], {}), '(compressed, a.shape, a.dtype)\n', (276, 306), False, 'from pysz import compress, decompress\n'), ((362, 403), 'numpy.allclose', 'np.allclose', (['a', 'recovered'], {'atol': 'tolerance'}), '(a, recovered, atol=tolerance)\n', (373, 403), True, 'import numpy as np\n'), ((99, 131), 'numpy.linspace', 'np.linspace', (['(0)', '(100)'], {'num': '(1000000)'}), '(0, 100, num=1000000)\n', (110, 131), True, 'import numpy as np\n')]