mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Warning messages promoted to RuntimeWarnings
This commit is contained in:
parent
8488df00fd
commit
4ca6f8ea49
3 changed files with 9 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
|||
import warnings
|
||||
import numpy as np
|
||||
import autograd.numpy as anp
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -130,7 +131,7 @@ class Corr:
|
|||
raise Exception("Can not symmetrize odd T")
|
||||
|
||||
if np.argmax(np.abs(self.content)) != 0:
|
||||
print('Warning: correlator does not seem to be symmetric around x0=0.')
|
||||
warnings.warn("Correlator does not seem to be symmetric around x0=0.", RuntimeWarning)
|
||||
|
||||
newcontent = [self.content[0]]
|
||||
for t in range(1, self.T):
|
||||
|
@ -148,7 +149,7 @@ class Corr:
|
|||
raise Exception("Can not symmetrize odd T")
|
||||
|
||||
if not all([o.zero_within_error() for o in self.content[0]]):
|
||||
print('Warning: correlator does not seem to be anti-symmetric around x0=0.')
|
||||
warnings.warn("Correlator does not seem to be anti-symmetric around x0=0.", RuntimeWarning)
|
||||
|
||||
newcontent = [self.content[0]]
|
||||
for t in range(1, self.T):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
import warnings
|
||||
import numpy as np
|
||||
import autograd.numpy as anp
|
||||
import scipy.optimize
|
||||
|
@ -300,7 +301,7 @@ def odr_fit(x, y, func, silent=False, **kwargs):
|
|||
P_phi = A @ np.linalg.inv(A.T @ A) @ A.T
|
||||
expected_chisquare = np.trace((np.identity(P_phi.shape[0]) - P_phi) @ W @ cov @ W)
|
||||
if expected_chisquare <= 0.0:
|
||||
print('Warning, negative expected_chisquare.')
|
||||
warnings.warn("Negative expected_chisquare.", RuntimeWarning)
|
||||
expected_chisquare = np.abs(expected_chisquare)
|
||||
result_dict['chisquare/expected_chisquare'] = odr_chisquare(np.concatenate((output.beta, output.xplus.ravel()))) / expected_chisquare
|
||||
if not silent:
|
||||
|
@ -611,9 +612,7 @@ def error_band(x, func, beta):
|
|||
"""Returns the error band for an array of sample values x, for given fit function func with optimized parameters beta."""
|
||||
cov = covariance_matrix(beta)
|
||||
if np.any(np.abs(cov - cov.T) > 1000 * np.finfo(np.float64).eps):
|
||||
print('Warning, Covariance matrix is not symmetric within floating point precision')
|
||||
print('cov - cov.T:')
|
||||
print(cov - cov.T)
|
||||
warnings.warn("Covariance matrix is not symmetric within floating point precision", RuntimeWarning)
|
||||
|
||||
deriv = []
|
||||
for i, item in enumerate(x):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
import warnings
|
||||
import pickle
|
||||
import numpy as np
|
||||
import autograd.numpy as anp # Thinly-wrapped numpy
|
||||
|
@ -784,9 +785,9 @@ def correlate(obs_a, obs_b):
|
|||
raise Exception('Shapes of ensemble', name, 'do not fit')
|
||||
|
||||
if obs_a.reweighted == 1:
|
||||
print('Warning: The first observable is already reweighted.')
|
||||
warnings.warn("The first observable is already reweighted.", RuntimeWarning)
|
||||
if obs_b.reweighted == 1:
|
||||
print('Warning: The second observable is already reweighted.')
|
||||
warnings.warn("The second observable is already reweighted.", RuntimeWarning)
|
||||
|
||||
new_samples = []
|
||||
for name in sorted(obs_a.names):
|
||||
|
|
Loading…
Add table
Reference in a new issue