mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
Vectorized gamma_method (#207)
* feat: vectorized gamma_method function added. * feat: vectorized gamma method generalized to also work on other objects like Corr or Fit_result. * feat: alias gamma_method for vectorized gamma_method added. * docs: example 5 updated to include vectorized gamma_method. * docs: output of example 5 updated.
This commit is contained in:
parent
6b7846486d
commit
1e438356fd
3 changed files with 76 additions and 46 deletions
|
@ -1032,6 +1032,22 @@ class CObs:
|
|||
return f"({self.real:{format_type}}{self.imag:+{significance}}j)"
|
||||
|
||||
|
||||
def gamma_method(x, **kwargs):
|
||||
"""Vectorized version of the gamma_method applicable to lists or arrays of Obs.
|
||||
|
||||
See docstring of pe.Obs.gamma_method for details.
|
||||
"""
|
||||
return np.vectorize(lambda o: o.gm(**kwargs))(x)
|
||||
|
||||
|
||||
def gm(x, **kwargs):
|
||||
"""Short version of the vectorized gamma_method.
|
||||
|
||||
See docstring of pe.Obs.gamma_method for details
|
||||
"""
|
||||
return gamma_method(x, **kwargs)
|
||||
|
||||
|
||||
def _format_uncertainty(value, dvalue, significance=2):
|
||||
"""Creates a string of a value and its error in paranthesis notation, e.g., 13.02(45)"""
|
||||
if dvalue == 0.0 or (not np.isfinite(dvalue)):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue