-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e9f86d
commit e1364ed
Showing
1 changed file
with
35 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,35 @@ | ||
import math | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pytest | ||
|
||
from cleedpy.preprocessing import lorentzian_smoothing, preprocessing_loop | ||
from tests.curves_helper import curve_a, curve_a_smoothed, curve_b | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"curve, vi, expected", | ||
[ | ||
(np.array(curve_a()), 4, np.array(curve_a_smoothed())), | ||
], | ||
) | ||
def test_lorentzian_smoothing(curve, vi, expected): | ||
l_curve = lorentzian_smoothing(curve, vi) | ||
|
||
x_values = curve[:, 0] | ||
y_values = curve[:, 1] | ||
plt.plot(x_values, y_values, marker="o", color="g", label="Input: Initial curve") | ||
|
||
x_values = l_curve[:, 0] | ||
y_values = l_curve[:, 1] | ||
plt.plot(x_values, y_values, marker="x", color="r", label="Output: Smoothed curve") | ||
|
||
y_min = 0 | ||
y_max = 0.0110 | ||
y_step = 0.0005 | ||
plt.ylim(y_min, y_max) | ||
plt.yticks(np.arange(y_min, y_max + y_step, y_step)) | ||
plt.grid() | ||
plt.legend() | ||
plt.savefig("test_lorentzian_smoothing_output.png") | ||
|
||
assert np.allclose(expected, l_curve) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"the_curve, exp_curve, shift, r_factor, vi, expected", | ||
[ | ||
([curve_a(), curve_b()], [curve_a(), curve_b()], 1, "r2_factor", 4, 0), | ||
], | ||
) | ||
def test_preprocessing_loop(the_curve, exp_curve, shift, r_factor, vi, expected): | ||
assert math.isclose( | ||
expected, | ||
preprocessing_loop( | ||
np.array(the_curve), np.array(exp_curve), shift, r_factor, vi | ||
), | ||
abs_tol=5, | ||
) | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pytest | ||
|
||
from cleedpy.preprocessing import lorentzian_smoothing | ||
from tests.curves_helper import curve_a, curve_a_smoothed | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"curve, vi, expected", | ||
[ | ||
(np.array(curve_a()), 4, np.array(curve_a_smoothed())), | ||
], | ||
) | ||
def test_lorentzian_smoothing(curve, vi, expected): | ||
l_curve = lorentzian_smoothing(curve, vi) | ||
|
||
x_values = curve[:, 0] | ||
y_values = curve[:, 1] | ||
plt.plot(x_values, y_values, marker="o", color="g", label="Input: Initial curve") | ||
|
||
x_values = l_curve[:, 0] | ||
y_values = l_curve[:, 1] | ||
plt.plot(x_values, y_values, marker="x", color="r", label="Output: Smoothed curve") | ||
|
||
y_min = 0 | ||
y_max = 0.0110 | ||
y_step = 0.0005 | ||
plt.ylim(y_min, y_max) | ||
plt.yticks(np.arange(y_min, y_max + y_step, y_step)) | ||
plt.grid() | ||
plt.legend() | ||
plt.savefig("test_lorentzian_smoothing_output.png") | ||
|
||
assert np.allclose(expected, l_curve) |