def test_CompressionSequenceAbs(arraySize=255, delta=0.1):
    actionArray = [("delta", delta), ("zip", 0), ("base64", 0),
                   ("debase64", 0), ("unzip", "int8")]
    for coding in ["int8", "int16", "int32", "int64", "float32", "float64"]:
        actionArray[4] = ("unzip", coding)
        arrayInput = pd.Series(np.arange(0, arraySize, 1, dtype=coding))
        inputSize = getSize(arrayInput)
        tic = time.perf_counter()
        arrayC = compressArray(arrayInput, actionArray, True)
        toc = time.perf_counter()
        compSize = getSize(arrayC["history"][2])
        print("test_CompressionSequenceRel: {}\t{}\t{:04f}\t{}\t{}\t{}".format(
            coding, arraySize, toc - tic, inputSize, compSize / inputSize,
            (arrayC["array"] - arrayInput).sum() / inputSize))
def test_CompressionSampleDeltaCode(arraySize=10000, scale=255, delta=1):
    actionArray = [("delta", delta), ("code", 0), ("zip", 0), ("base64", 0),
                   ("debase64", 0), ("unzip", "int8"), ("decode", 0)]
    for coding in ["float32", "float64"]:
        #actionArray[5]=("unzip",coding)
        arrayInput = pd.Series(
            (np.random.random_sample(size=arraySize) * scale).astype(coding))
        inputSize = getSize(arrayInput)
        tic = time.perf_counter()
        arrayC = compressArray(arrayInput, actionArray, True)
        toc = time.perf_counter()
        compSize = getSize(arrayC["history"][3])
        print("test_CompressionSampleRel: {}\t{}\t{:04f}\t{}\t{}\t{}".format(
            coding, arraySize, toc - tic, inputSize, compSize / inputSize,
            np.sqrt(((arrayC["array"] - arrayInput)**2).sum() / arraySize)))
def test_CompressionSample0(arraySize=10000, scale=255):
    actionArray = [("zip", 0), ("base64", 0), ("debase64", 0),
                   ("unzip", "int8")]
    for coding in ["int8", "int16", "int32", "int64", "float32", "float64"]:
        actionArray[3] = ("unzip", coding)
        arrayInput = pd.Series(
            (np.random.random_sample(size=arraySize) * scale).astype(coding))
        inputSize = getSize(arrayInput)
        tic = time.perf_counter()
        arrayC = compressArray(arrayInput, actionArray, True)
        toc = time.perf_counter()
        compSize = getSize(arrayC["history"][1])
        print("test_Compression0: {}\t{}\t{:04f}\t{}\t{}\t{}".format(
            coding, arraySize, toc - tic, inputSize, compSize / inputSize,
            (arrayC["array"] - arrayInput).sum()))
def test_CompressionSampleRel(arraySize=10000, scale=255, nBits=7):
    actionArray = [("relative", nBits), ("zip", 0), ("base64", 0),
                   ("debase64", 0), ("unzip", "int8")]
    for coding in ["float32", "float64"]:
        actionArray[4] = ("unzip", coding)
        arrayInput = pd.Series(
            (np.random.random_sample(size=arraySize) * scale).astype(coding))
        inputSize = getSize(arrayInput)
        tic = time.perf_counter()
        arrayC = compressArray(arrayInput, actionArray, True)
        toc = time.perf_counter()
        compSize = getSize(arrayC["history"][2])
        print("test_CompressionSampleRel: {}\t{}\t{:04f}\t{}\t{}\t{}".format(
            coding, arraySize, toc - tic, inputSize, compSize / inputSize,
            (np.abs(arrayC["array"] - arrayInput) /
             (arrayC["array"] + arrayInput)).sum() / arraySize))