Merge branch 'develop' into documentation

This commit is contained in:
fjosw 2022-02-23 16:24:25 +00:00
commit 8ac1edaf95
2 changed files with 11 additions and 1 deletions

View file

@ -628,7 +628,7 @@ class Corr:
function : obj function : obj
function to fit to the data. See fits.least_squares for details. function to fit to the data. See fits.least_squares for details.
fitrange : list fitrange : list
Range in which the function is to be fitted to the data. Two element list containing the timeslices on which the fit is supposed to start and stop.
If not specified, self.prange or all timeslices are used. If not specified, self.prange or all timeslices are used.
silent : bool silent : bool
Decides whether output is printed to the standard output. Decides whether output is printed to the standard output.
@ -641,6 +641,11 @@ class Corr:
fitrange = self.prange fitrange = self.prange
else: else:
fitrange = [0, self.T - 1] fitrange = [0, self.T - 1]
else:
if not isinstance(fitrange, list):
raise Exception("fitrange has to be a list with two elements")
if len(fitrange) != 2:
raise Exception("fitrange has to have exactly two elements [fit_start, fit_stop]")
xs = [x for x in range(fitrange[0], fitrange[1] + 1) if not self.content[x] is None] xs = [x for x in range(fitrange[0], fitrange[1] + 1) if not self.content[x] is None]
ys = [self.content[x][0] for x in range(fitrange[0], fitrange[1] + 1) if not self.content[x] is None] ys = [self.content[x][0] for x in range(fitrange[0], fitrange[1] + 1) if not self.content[x] is None]

View file

@ -135,6 +135,11 @@ def test_fit_correlator():
assert fit_res[0] == my_corr[0] assert fit_res[0] == my_corr[0]
assert fit_res[1] == my_corr[1] - my_corr[0] assert fit_res[1] == my_corr[1] - my_corr[0]
with pytest.raises(Exception):
my_corr.fit(f, "from 0 to 3")
with pytest.raises(Exception):
my_corr.fit(f, [0, 2, 3])
def test_plateau(): def test_plateau():
my_corr = pe.correlators.Corr([pe.pseudo_Obs(1.01324, 0.05, 't'), pe.pseudo_Obs(1.042345, 0.008, 't')]) my_corr = pe.correlators.Corr([pe.pseudo_Obs(1.01324, 0.05, 't'), pe.pseudo_Obs(1.042345, 0.008, 't')])