def test_time():
    # Tests performance on random data, ignoring compression ratio
    data = np.random.rand(101, 101, 10001)
    compressed = st_hosvd.compress_tucker(data,
                                          0,
                                          rank=(22, 21, 19),
                                          print_progress=True)
    decompressed = st_hosvd.decompress_tucker(compressed)
    print_difference(data, decompressed)
    st_hosvd.print_compression_rate_tucker(data, compressed)
    plot_comparison(data, decompressed)
def compress_mauna_kea():

    data = load_mauna_kea()
    compressed = st_hosvd.compress_tucker(data,
                                          0.025,
                                          print_progress=True,
                                          use_pure_gramian=True)
    print(
        "Relative error:",
        custom_norm(st_hosvd.decompress_tucker(compressed).__isub__(data)) /
        custom_norm(data))
    st_hosvd.print_compression_rate_tucker(data, compressed)
def test_compression_ratio_tucker():

    print("=" * 20 + " Phase 1 " + "=" * 20)
    data = load_pavia_centre()
    compressed1 = st_hosvd.compress_tucker(data,
                                           0.025,
                                           reshape=False,
                                           method="tucker")
    decompressed = st_hosvd.decompress_tucker(compressed1)
    st_hosvd.print_compression_rate_tucker(data, compressed1)
    print_difference(data, decompressed)
    """
def compare_times():

    data = load_cuprite()
    original_size = data.dtype.itemsize * data.size

    st_hosvd.print_compression_rate_tucker(
        data, st_hosvd.compress_tucker(data, 0.025))
    start = time()
    compressed = st_hosvd.compress_quantize2(
        st_hosvd.compress_tucker(data, 0.025))
    print("Time for compression:", time() - start)
    start = time()
    decompressed = st_hosvd.decompress_tucker(
        st_hosvd.decompress_quantize2(compressed))
    print("Time for decompression:", time() - start)
    st_hosvd.print_compression_rate_quantize2(data, compressed)
    print_difference(data, decompressed)

    start = time()
    compressed = other_compression.compress_jpeg(data, 50)
    print("Time for compression:", time() - start)
    start = time()
    decompressed = other_compression.decompress_jpeg(compressed)
    print("Time for decompression:", time() - start)
    print("Compressed size:",
          other_compression.get_compress_jpeg_size(compressed))
    print("Compression ratio:",
          other_compression.get_compress_jpeg_size(compressed) / original_size)
    print_difference(data, decompressed)

    start = time()
    compressed = other_compression.compress_video(data, 28)
    print("Time for compression:", time() - start)
    start = time()
    decompressed = other_compression.decompress_video(compressed)
    print("Time for decompression:", time() - start)
    print("Compressed size:",
          other_compression.get_compress_video_size(compressed))
    print(
        "Compression ratio:",
        other_compression.get_compress_video_size(compressed) / original_size)
    print_difference(data, decompressed)