|
2 | 2 |
|
3 | 3 | from pyfastpfor import * |
4 | 4 | import numpy as np |
| 5 | +import pytest |
5 | 6 | import random |
6 | 7 | import time |
7 | 8 | random.seed(0) |
8 | 9 |
|
| 10 | +# Be careful changing these numbers: If the array size |
| 11 | +# is too large there will be an integer overflow. |
| 12 | +ARRAY_SIZES = [1, 8, 64, 1024, 1024 * 1024 * 4] |
| 13 | +MAX_VALUES = [256, 512, 2048] |
| 14 | + |
| 15 | + |
| 16 | +@pytest.mark.parametrize("maxVal", MAX_VALUES) |
| 17 | +@pytest.mark.parametrize("arrSize", ARRAY_SIZES) |
| 18 | +def test_codecs_roundtrip(arrSize, maxVal): |
| 19 | + codecList = getCodecList() |
9 | 20 |
|
10 | | -def oneTest(arrSize, maxVal, codecList): |
11 | 21 | inpSmall = np.array(np.random.randint( |
12 | 22 | 0, maxVal, arrSize), dtype=np.uint32).ravel() |
13 | 23 | inpPrefSum = np.array(inpSmall, dtype=np.uint32, copy=True).ravel() |
@@ -38,9 +48,9 @@ def oneTest(arrSize, maxVal, codecList): |
38 | 48 | for diffType in range(3): |
39 | 49 |
|
40 | 50 | if diffType == 0: |
41 | | - inp = np.array([e for e in inpSmall], dtype=np.uint32).ravel() |
| 51 | + inp = np.array(inpSmall, dtype=np.uint32, copy=True).ravel() |
42 | 52 | else: |
43 | | - inp = np.array([e for e in inpPrefSum], dtype=np.uint32).ravel() |
| 53 | + inp = np.array(inpPrefSum, dtype=np.uint32, copy=True).ravel() |
44 | 54 |
|
45 | 55 | if diffType == 1: |
46 | 56 | delta1(inp, arrSize) |
@@ -77,20 +87,4 @@ def oneTest(arrSize, maxVal, codecList): |
77 | 87 |
|
78 | 88 |
|
79 | 89 | if __name__ == '__main__': |
80 | | - |
81 | | - codecList = getCodecList() |
82 | | - |
83 | | - # Be careful changing these numbers: If the array size |
84 | | - # is too large there will be an integer overflow. |
85 | | - arraySizes = [1, 8, 64, 1024, 1024 * 1024 * 4] |
86 | | - maxValues = [256, 512, 2048] |
87 | | - |
88 | | - i = 0 |
89 | | - for arraySize in arraySizes: |
90 | | - for maxValue in maxValues: |
91 | | - print("--------------------------------------------------------------------------------") |
92 | | - print(" Test Case %d/%d" % (i, len(arraySizes)*len(maxValues))) |
93 | | - print("--------------------------------------------------------------------------------") |
94 | | - oneTest(arraySize, maxValue, codecList) |
95 | | - print("\n") |
96 | | - i += 1 |
| 90 | + raise SystemExit(pytest.main([__file__, "-v"])) |
0 commit comments