Skip to content

Commit 95a2e56

Browse files
committed
test that the lineshape fitting function fits correctly, and not that it just runs as expected
1 parent 1c052df commit 95a2e56

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

nmrglue/analysis/tests/test_analysis_linesh.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import numpy as np
2-
3-
4-
import nmrglue as ng
5-
from nmrglue.analysis.linesh import fit_spectrum
6-
2+
from nmrglue.analysis.linesh import fit_spectrum, sim_NDregion
73

84
def test_fit_spectrum():
9-
_bb = np.random.uniform(0, 77, size=65536)
105
lineshapes = ['g']
116
params = [[(13797.0, 2.2495075273313034)],
127
[(38979.0, 5.8705185693227664)],
@@ -26,9 +21,12 @@ def test_fit_spectrum():
2621
(49007.0,), (54774.0,)]
2722
rIDs = [1, 2, 3, 4, 5, 6, 7]
2823
box_width = (5,)
29-
error_flag = False
30-
verb = False
3124

32-
params_best, amp_best, iers = ng.linesh.fit_spectrum(
33-
_bb, lineshapes, params, amps, bounds, ampbounds, centers,
34-
rIDs, box_width, error_flag, verb=False)
25+
generated_data = sim_NDregion(shape=(65536,), lineshapes=['g'], params=params, amps=amps)
26+
27+
params_best, amp_best, iers = fit_spectrum(
28+
generated_data, lineshapes, params, amps, bounds, ampbounds, centers,
29+
rIDs, box_width, error_flag=False, verb=False)
30+
31+
assert np.allclose(params_best, params, rtol=1e-4)
32+
assert np.allclose(amp_best, amps, rtol=1e-4)

0 commit comments

Comments
 (0)