diff options
| author | Tomas Jusko | 2022-01-27 22:02:13 +0100 |
|---|---|---|
| committer | Tomas Jusko | 2022-01-27 22:02:13 +0100 |
| commit | 310ab2f682d69417f096e1bf33a698074450f878 (patch) | |
| tree | 2e031074d3cf2446685070475c2f935c7bec6538 | |
| parent | ea5d6cf1ccbcc8fa97128c568d009013b434fe8f (diff) | |
| download | pyecsca-310ab2f682d69417f096e1bf33a698074450f878.tar.gz pyecsca-310ab2f682d69417f096e1bf33a698074450f878.tar.zst pyecsca-310ab2f682d69417f096e1bf33a698074450f878.zip | |
Started stacked traces tests
| -rw-r--r-- | test/sca/test_stacked_combine.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/sca/test_stacked_combine.py b/test/sca/test_stacked_combine.py new file mode 100644 index 0000000..d319e5a --- /dev/null +++ b/test/sca/test_stacked_combine.py @@ -0,0 +1,32 @@ +from unittest import TestCase + +import numpy as np +from pyecsca.sca import ( + Trace, + StackedTraces, + GPUTraceManager, +) + + +class StackedCombineTests(TestCase): + def setUp(self): + self.samples = np.random.rand(16, 32) + self.st_traces = StackedTraces(self.samples) + + def test_fromarray(self): + max_len = self.samples.shape[1] + min_len = max_len // 2 + jagged_samples = [ + t[min_len:np.random.randint(max_len)] + for t + in self.samples + ] + min_len = min(map(len, jagged_samples)) + stacked = StackedTraces.fromarray(jagged_samples) + + self.assertIsInstance(stacked, StackedTraces) + self.assertTupleEqual( + stacked.samples.shape, + (self.samples.shape[0], min_len) + ) + self.assertTrue((stacked.samples, self.samples[:,:min_len]).all()) |
