forked from J08nY/pyecsca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_filter.py
49 lines (38 loc) · 1.1 KB
/
test_filter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import pytest
from pyecsca.sca import (
Trace,
filter_lowpass,
filter_highpass,
filter_bandpass,
filter_bandstop,
)
@pytest.fixture()
def trace():
return Trace(
np.array(
[5, 12, 15, 13, 15, 11, 7, 2, -4, -8, -10, -8, -13, -9, -11, -8, -5],
dtype=np.dtype("i1"),
),
None,
)
def test_lowpass(trace, plot):
result = filter_lowpass(trace, 100, 20)
assert result is not None
assert len(trace.samples) == len(result.samples)
plot(trace, result)
def test_highpass(trace, plot):
result = filter_highpass(trace, 128, 20)
assert result is not None
assert len(trace.samples) == len(result.samples)
plot(trace, result)
def test_bandpass(trace, plot):
result = filter_bandpass(trace, 128, 20, 60)
assert result is not None
assert len(trace.samples) == len(result.samples)
plot(trace, result)
def test_bandstop(trace, plot):
result = filter_bandstop(trace, 128, 20, 60)
assert result is not None
assert len(trace.samples) == len(result.samples)
plot(trace, result)