From 9589820253f7ae75ae8f1ec15fef02e9eea2d599 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 15:35:37 +0100 Subject: [PATCH 1/9] tests: coverage for all derivative variants extended. --- tests/correlators_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/correlators_test.py b/tests/correlators_test.py index cc08544c..c5b530cb 100644 --- a/tests/correlators_test.py +++ b/tests/correlators_test.py @@ -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): From db79cb2d9575aaf435fa6ca89cfdc373270d65c8 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 15:44:06 +0100 Subject: [PATCH 2/9] tests: test for print_config added. --- tests/misc_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/misc_test.py b/tests/misc_test.py index 3211a806..99bb5056 100644 --- a/tests/misc_test.py +++ b/tests/misc_test.py @@ -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() From 47bb746b636260ca9884a230191bb3185bfaebde Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 15:53:33 +0100 Subject: [PATCH 3/9] docs: citing pyerrors section added to README. --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index ddb08471..3e686e51 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,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. From 5b024c73794acfc2375ab25f55e1b6992dd7b769 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 16:06:00 +0100 Subject: [PATCH 4/9] build: nbmake added to test build option in setup.py. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b41b95b3..7a19394c 100644 --- a/setup.py +++ b/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']}, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', From c47e1ccac70e7c7873ebf07d6a484be9393c012a Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 16:06:55 +0100 Subject: [PATCH 5/9] build: flake8 added to test build option in setup.py. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7a19394c..ab038e8d 100644 --- a/setup.py +++ b/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', 'nbmake']}, + extras_require={'test': ['pytest', 'pytest-cov', 'pytest-benchmark', 'hypothesis', 'nbmake', 'flake8']}, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', From bf25ecf2ee1c12cce457fd2cb94e105b5d6d20c8 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 16:11:25 +0100 Subject: [PATCH 6/9] docs: Contributing guidelines clarified. --- CONTRIBUTING.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 86267ae2..d4160430 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. From e73e393695ecf761844640474f9c7909018a0e3d Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 16:12:00 +0100 Subject: [PATCH 7/9] docs: pip installation instructions changed. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e686e51..84eb37dd 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ ## 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 From 305b458d1954b17a9b7b234755e1f9aaa31149f2 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 16:13:32 +0100 Subject: [PATCH 8/9] docs: link to Changelog added to README. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 84eb37dd..e3436706 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ - **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 From 2cd076dbd7aa636c123006b35f854adba0ff6afa Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 10 Jul 2023 16:33:09 +0100 Subject: [PATCH 9/9] docs: details in documentation clarified. --- pyerrors/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pyerrors/__init__.py b/pyerrors/__init__.py index 9abd9935..df2c983a 100644 --- a/pyerrors/__init__.py +++ b/pyerrors/__init__.py @@ -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.