mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Merge branch 'develop' into documentation
This commit is contained in:
commit
9b1f60c00e
6 changed files with 32 additions and 16 deletions
|
@ -19,19 +19,17 @@ Please add docstrings to any new function, class or method you implement. The do
|
|||
|
||||
### Tests
|
||||
When implementing a new feature or fixing a bug please add meaningful tests to the files in the `tests` directory which cover the new code.
|
||||
We follow the [PEP8](https://peps.python.org/pep-0008/) code style which is checked by `flake8`.
|
||||
For all pull requests tests are executed for the most recent python releases via
|
||||
```
|
||||
pytest -vv -Werror
|
||||
pytest --nbmake examples/*.ipynb
|
||||
flake8 --ignore=E501,W503 --exclude=__init__.py pyerrors
|
||||
```
|
||||
requiring `pytest`, `pytest-cov`, `pytest-benchmark`, `hypothesis` and `nbmake`. To install the test dependencies one can run `pip install pyerrors[test]`
|
||||
The tests require `pytest`, `pytest-cov`, `pytest-benchmark`, `hypothesis`, `nbmake` and `flake8`. To install the test dependencies one can run `pip install pyerrors[test]`.
|
||||
Please make sure that all tests pass for a new pull requests.
|
||||
|
||||
To get a coverage report in html run
|
||||
```
|
||||
pytest --cov=pyerrors --cov-report html
|
||||
```
|
||||
The linter `flake8` is executed with the command
|
||||
```
|
||||
flake8 --ignore=E501,W503 --exclude=__init__.py pyerrors
|
||||
```
|
||||
Please make sure that all tests pass for a new pull requests.
|
||||
|
|
12
README.md
12
README.md
|
@ -4,13 +4,14 @@
|
|||
|
||||
- **Documentation:** https://fjosw.github.io/pyerrors/pyerrors.html
|
||||
- **Examples:** https://github.com/fjosw/pyerrors/tree/develop/examples
|
||||
- **Changelog:** https://github.com/fjosw/pyerrors/blob/develop/CHANGELOG.md
|
||||
- **Bug reports:** https://github.com/fjosw/pyerrors/issues
|
||||
|
||||
## Installation
|
||||
Install the most recent release using pip and [pypi](https://pypi.org/project/pyerrors/):
|
||||
```bash
|
||||
pip install pyerrors # Fresh install
|
||||
pip install -U pyerrors # Update
|
||||
python -m pip install pyerrors # Fresh install
|
||||
python -m pip install -U pyerrors # Update
|
||||
```
|
||||
Install the most recent release using conda and [conda-forge](https://anaconda.org/conda-forge/pyerrors):
|
||||
```bash
|
||||
|
@ -20,3 +21,10 @@ conda update -c conda-forge pyerrors # Update
|
|||
|
||||
## Contributing
|
||||
We appreciate all contributions to the code, the documentation and the examples. If you want to get involved please have a look at our [contribution guideline](https://github.com/fjosw/pyerrors/blob/develop/CONTRIBUTING.md).
|
||||
|
||||
## Citing pyerrors
|
||||
If you use `pyerrors` for research that leads to a publication we suggest citing the following papers:
|
||||
- Fabian Joswig, Simon Kuberski, Justus T. Kuhlmann, Jan Neuendorf, *pyerrors: a python framework for error analysis of Monte Carlo data*. Comput.Phys.Commun. 288 (2023) 108750.
|
||||
- Ulli Wolff, *Monte Carlo errors with less errors*. Comput.Phys.Commun. 156 (2004) 143-153, Comput.Phys.Commun. 176 (2007) 383 (erratum).
|
||||
- Alberto Ramos, *Automatic differentiation for error analysis of Monte Carlo data*. Comput.Phys.Commun. 238 (2019) 19-35.
|
||||
- Stefan Schaefer, Rainer Sommer, Francesco Virotta, *Critical slowing down and error analysis in lattice QCD simulations*. Nucl.Phys.B 845 (2011) 93-119.
|
||||
|
|
|
@ -27,8 +27,8 @@ There exist similar publicly available implementations of gamma method error ana
|
|||
|
||||
Install the most recent release using pip and [pypi](https://pypi.org/project/pyerrors/):
|
||||
```bash
|
||||
pip install pyerrors # Fresh install
|
||||
pip install -U pyerrors # Update
|
||||
python -m pip install pyerrors # Fresh install
|
||||
python -m pip install -U pyerrors # Update
|
||||
```
|
||||
Install the most recent release using conda and [conda-forge](https://anaconda.org/conda-forge/pyerrors):
|
||||
```bash
|
||||
|
@ -37,7 +37,7 @@ conda update -c conda-forge pyerrors # Update
|
|||
```
|
||||
Install the current `develop` version:
|
||||
```bash
|
||||
pip install git+https://github.com/fjosw/pyerrors.git@develop
|
||||
python -m pip install git+https://github.com/fjosw/pyerrors.git@develop
|
||||
```
|
||||
|
||||
## Basic example
|
||||
|
@ -108,6 +108,7 @@ my_sum.details()
|
|||
> · Ensemble 'ensemble_name' : 1000 configurations (from 1 to 1000)
|
||||
|
||||
```
|
||||
The `gamma_method` is not automatically called after every intermediate step in order to prevent computational overhead.
|
||||
|
||||
We use the following definition of the integrated autocorrelation time established in [Madras & Sokal 1988](https://link.springer.com/article/10.1007/BF01022990)
|
||||
$$\tau_\mathrm{int}=\frac{1}{2}+\sum_{t=1}^{W}\rho(t)\geq \frac{1}{2}\,.$$
|
||||
|
@ -305,7 +306,7 @@ print(my_derived_cobs)
|
|||
# The `Covobs` class
|
||||
In many projects, auxiliary data that is not based on Monte Carlo chains enters. Examples are experimentally determined mesons masses which are used to set the scale or renormalization constants. These numbers come with an error that has to be propagated through the analysis. The `Covobs` class allows to define such quantities in `pyerrors`. Furthermore, external input might consist of correlated quantities. An example are the parameters of an interpolation formula, which are defined via mean values and a covariance matrix between all parameters. The contribution of the interpolation formula to the error of a derived quantity therefore might depend on the complete covariance matrix.
|
||||
|
||||
This concept is built into the definition of `Covobs`. In `pyerrors`, external input is defined by $M$ mean values, a $M\times M$ covariance matrix, where $M=1$ is permissible, and a name that uniquely identifies the covariance matrix. Below, we define the pion mass, based on its mean value and error, 134.9768(5). Note, that the square of the error enters `cov_Obs`, since the second argument of this function is the covariance matrix of the `Covobs`.
|
||||
This concept is built into the definition of `Covobs`. In `pyerrors`, external input is defined by $M$ mean values, a $M\times M$ covariance matrix, where $M=1$ is permissible, and a name that uniquely identifies the covariance matrix. Below, we define the pion mass, based on its mean value and error, 134.9768(5). **Note, that the square of the error enters `cov_Obs`**, since the second argument of this function is the covariance matrix of the `Covobs`.
|
||||
|
||||
```python
|
||||
import pyerrors.obs as pe
|
||||
|
@ -387,11 +388,12 @@ def func(a, x):
|
|||
|
||||
`pyerrors` also supports correlated fits which can be triggered via the parameter `correlated_fit=True`.
|
||||
Details about how the required covariance matrix is estimated can be found in `pyerrors.obs.covariance`.
|
||||
Direct visualizations of the performed fits can be triggered via `resplot=True` or `qqplot=True`.
|
||||
|
||||
Direct visualizations of the performed fits can be triggered via `resplot=True` or `qqplot=True`. For all available options see `pyerrors.fits.least_squares`.
|
||||
For all available options including combined fits to multiple datasets see `pyerrors.fits.least_squares`.
|
||||
|
||||
## Total least squares fits
|
||||
`pyerrors` can also fit data with errors on both the dependent and independent variables using the total least squares method also referred to orthogonal distance regression as implemented in [scipy](https://docs.scipy.org/doc/scipy/reference/odr.html), see `pyerrors.fits.least_squares`. The syntax is identical to the standard least squares case, the only difference being that `x` also has to be a `list` or `numpy.array` of `Obs`.
|
||||
`pyerrors` can also fit data with errors on both the dependent and independent variables using the total least squares method also referred to as orthogonal distance regression as implemented in [scipy](https://docs.scipy.org/doc/scipy/reference/odr.html), see `pyerrors.fits.least_squares`. The syntax is identical to the standard least squares case, the only difference being that `x` also has to be a `list` or `numpy.array` of `Obs`.
|
||||
|
||||
For the full API see `pyerrors.fits` for fits and `pyerrors.roots` for finding roots of functions.
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -26,7 +26,7 @@ setup(name='pyerrors',
|
|||
packages=find_packages(),
|
||||
python_requires='>=3.8.0',
|
||||
install_requires=['numpy>=1.24', 'autograd>=1.6.2', 'numdifftools>=0.9.41', 'matplotlib>=3.7', 'scipy>=1.10', 'iminuit>=2.21', 'h5py>=3.8', 'lxml>=4.9', 'python-rapidjson>=1.10', 'pandas>=2.0'],
|
||||
extras_require={'test': ['pytest', 'pytest-cov', 'pytest-benchmark', 'hypothesis']},
|
||||
extras_require={'test': ['pytest', 'pytest-cov', 'pytest-benchmark', 'hypothesis', 'nbmake', 'flake8']},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Science/Research',
|
||||
|
|
|
@ -58,12 +58,16 @@ def test_modify_correlator():
|
|||
for pad in [0, 2]:
|
||||
corr = pe.Corr(corr_content, padding=[pad, pad])
|
||||
corr.roll(np.random.randint(100))
|
||||
corr.deriv(variant="forward")
|
||||
corr.deriv(variant="symmetric")
|
||||
corr.deriv(variant="forward")
|
||||
corr.deriv(variant="backward")
|
||||
corr.deriv(variant="improved")
|
||||
corr.deriv(variant="log")
|
||||
corr.deriv().deriv()
|
||||
corr.second_deriv(variant="symmetric")
|
||||
corr.second_deriv(variant="big_symmetric")
|
||||
corr.second_deriv(variant="improved")
|
||||
corr.second_deriv(variant="log")
|
||||
corr.second_deriv().second_deriv()
|
||||
|
||||
for i, e in enumerate(corr.content):
|
||||
|
|
|
@ -18,3 +18,7 @@ def test_obs_errorbar():
|
|||
pe.errorbar(x_obs, y_obs, marker="x", ms=2, xerr=xerr, yerr=yerr)
|
||||
|
||||
plt.close('all')
|
||||
|
||||
|
||||
def test_print_config():
|
||||
pe.print_config()
|
||||
|
|
Loading…
Add table
Reference in a new issue