Skip to content

Commit 078c533

Browse files
committed
the tests too
1 parent 995aeb9 commit 078c533

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

tests/test_maths.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import pytest
77
import scipy.stats as st
88

9-
import pyhdtoolkit.maths.nonconvex_phase_sync as nps
10-
119
from pyhdtoolkit.maths import stats_fitting
1210
from pyhdtoolkit.maths import utils as mutils
1311

@@ -16,51 +14,6 @@
1614
REF_DISTRIBUTIONS = deepcopy(stats_fitting.DISTRIBUTIONS)
1715

1816

19-
class TestPhaseReconstructor:
20-
"""
21-
Only testing that the final result is good, considering if anything in between goes wrong the
22-
end result will be way off. Introduced noise doesn't have more than 1 degree stdev,
23-
as the highest I've found in LHC was 0.7270 for the low-low bpm combination. Number of BPMs
24-
varyto emulate different machines, 569 is here specifically because it's how many we have in
25-
the LHC right now (minus shenanigans of double plane BPMs).
26-
"""
27-
28-
@pytest.mark.parametrize("input_matrix", [np.random.rand(250, 250), np.random.rand(2, 10)])
29-
@pytest.mark.parametrize("expected_exception", [ValueError])
30-
def test_non_hermitian_input(self, input_matrix, expected_exception):
31-
with pytest.raises(expected_exception):
32-
_ = nps.PhaseReconstructor(input_matrix)
33-
34-
@pytest.mark.flaky(max_runs=3, min_passes=1)
35-
@pytest.mark.parametrize("noise_stdev_degrees", [0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 1])
36-
@pytest.mark.parametrize("n_bpms", [50, 250, 500, 569, 750])
37-
def test_reconstructor_matrix(self, noise_stdev_degrees, n_bpms):
38-
signal = _create_random_phase_values(low=0, high=80, n_values=n_bpms, dist="uniform")
39-
m_meas = _create_meas_matrix_from_values_array(signal)
40-
m_noise = _create_2d_gaussian_noise(mean=0, stdev=noise_stdev_degrees, shape=m_meas.shape)
41-
c_hermitian = np.exp(1j * np.deg2rad(m_meas + m_noise))
42-
43-
pr = nps.PhaseReconstructor(c_hermitian)
44-
assert isinstance(pr.reconstructor_matrix, np.ndarray)
45-
assert pr.reconstructor_matrix.shape == c_hermitian.shape
46-
47-
@pytest.mark.flaky(max_runs=3, min_passes=1)
48-
@pytest.mark.parametrize("noise_stdev_degrees", [0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 1])
49-
@pytest.mark.parametrize("n_bpms", [50, 250, 500, 569, 750])
50-
def test_reconstruction(self, noise_stdev_degrees, n_bpms):
51-
signal = _create_random_phase_values(low=0, high=80, n_values=n_bpms, dist="uniform")
52-
m_meas = _create_meas_matrix_from_values_array(signal)
53-
m_noise = _create_2d_gaussian_noise(mean=0, stdev=noise_stdev_degrees, shape=m_meas.shape)
54-
m_noised_meas = m_meas + m_noise
55-
c_hermitian = np.exp(1j * np.deg2rad(m_noised_meas))
56-
pr = nps.PhaseReconstructor(c_hermitian)
57-
complex_eigenvector_method_result = pr.reconstruct_complex_phases_evm()
58-
reconstructed = np.abs(
59-
pr.convert_complex_result_to_phase_values(complex_eigenvector_method_result, deg=True)
60-
).reshape(n_bpms)
61-
assert np.allclose(reconstructed, signal, atol=0.1, rtol=1e-1)
62-
63-
6417
@pytest.mark.parametrize(
6518
"input_dict",
6619
[

0 commit comments

Comments
 (0)