mirror of
https://github.com/fjosw/pyerrors.git
synced 2026-04-15 01:01:38 +02:00
[Fix] Handle platform-dependent rank-deficient warning in ODR tests
This commit is contained in:
parent
5084894ef9
commit
92d5b59430
1 changed files with 8 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import warnings
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import autograd.numpy as anp
|
import autograd.numpy as anp
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
@ -476,7 +477,9 @@ def test_total_least_squares_vanishing_chisquare():
|
||||||
x = [pe.pseudo_Obs(1.0, 0.1, 'x0'), pe.pseudo_Obs(2.0, 0.1, 'x1')]
|
x = [pe.pseudo_Obs(1.0, 0.1, 'x0'), pe.pseudo_Obs(2.0, 0.1, 'x1')]
|
||||||
y = [pe.pseudo_Obs(1.0, 0.1, 'y0'), pe.pseudo_Obs(2.0, 0.1, 'y1')]
|
y = [pe.pseudo_Obs(1.0, 0.1, 'y0'), pe.pseudo_Obs(2.0, 0.1, 'y1')]
|
||||||
|
|
||||||
with pytest.warns(RuntimeWarning, match="rank deficient"):
|
# Rank-deficient warning may or may not fire depending on platform/solver numerics.
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings("ignore", message="ODR fit is rank deficient", category=RuntimeWarning)
|
||||||
out = pe.total_least_squares(x, y, func, silent=True)
|
out = pe.total_least_squares(x, y, func, silent=True)
|
||||||
assert len(out.fit_parameters) == 2
|
assert len(out.fit_parameters) == 2
|
||||||
|
|
||||||
|
|
@ -525,7 +528,10 @@ def test_r_value_persistence():
|
||||||
assert np.isclose(fitp[1].value, fitp[1].r_values['a'])
|
assert np.isclose(fitp[1].value, fitp[1].r_values['a'])
|
||||||
assert np.isclose(fitp[1].value, fitp[1].r_values['b'])
|
assert np.isclose(fitp[1].value, fitp[1].r_values['b'])
|
||||||
|
|
||||||
fitp = pe.fits.total_least_squares(y, y, f)
|
# Rank-deficient warning may or may not fire depending on platform/solver numerics.
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings("ignore", message="ODR fit is rank deficient", category=RuntimeWarning)
|
||||||
|
fitp = pe.fits.total_least_squares(y, y, f)
|
||||||
|
|
||||||
assert np.isclose(fitp[0].value, fitp[0].r_values['a'])
|
assert np.isclose(fitp[0].value, fitp[0].r_values['a'])
|
||||||
assert np.isclose(fitp[0].value, fitp[0].r_values['b'])
|
assert np.isclose(fitp[0].value, fitp[0].r_values['b'])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue