11import 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
84def 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