diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2548255f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Release + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build: + name: Build sdist and wheel + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + name: Checkout repository + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + + - name: Build wheel and source tarball + run: python3 -m build + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + if-no-files-found: error + + publish: + needs: [build] + name: Upload to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pyerrors + permissions: + id-token: write + + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Sanity check + run: ls -la dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index b59bb577..d019608c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## [2.13.0] - 2024-11-03 + +### Added +- Allow providing lower triangular matrix constructed from a Cholesky decomposition in least squares function for correlated fits. + +### Fixed +- Corrected bug that prevented combined fits with multiple x-obs in some cases. + ## [2.12.0] - 2024-08-22 ### Changed diff --git a/README.md b/README.md index aa669ad5..7937da4d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![pytest](https://github.com/fjosw/pyerrors/actions/workflows/pytest.yml/badge.svg)](https://github.com/fjosw/pyerrors/actions/workflows/pytest.yml) [![](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![arXiv](https://img.shields.io/badge/arXiv-2209.14371-b31b1b.svg)](https://arxiv.org/abs/2209.14371) [![DOI](https://img.shields.io/badge/DOI-10.1016%2Fj.cpc.2023.108750-blue)](https://doi.org/10.1016/j.cpc.2023.108750) +[![](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![arXiv](https://img.shields.io/badge/arXiv-2209.14371-b31b1b.svg)](https://arxiv.org/abs/2209.14371) [![DOI](https://img.shields.io/badge/DOI-10.1016%2Fj.cpc.2023.108750-blue)](https://doi.org/10.1016/j.cpc.2023.108750) # pyerrors `pyerrors` is a python framework for error computation and propagation of Markov chain Monte Carlo data from lattice field theory and statistical mechanics simulations. @@ -14,11 +14,6 @@ Install the most recent release using pip and [pypi](https://pypi.org/project/py 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 -conda install -c conda-forge pyerrors # Fresh install -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). diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index de1addfd..21a11533 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -862,7 +862,7 @@ class Corr: raise Exception("prange must be a list or array with two values") if not ((isinstance(prange[0], int)) and (isinstance(prange[1], int))): raise Exception("Start and end point must be integers") - if not (0 <= prange[0] <= self.T and 0 <= prange[1] <= self.T and prange[0] < prange[1]): + if not (0 <= prange[0] <= self.T and 0 <= prange[1] <= self.T and prange[0] <= prange[1]): raise Exception("Start and end point must define a range in the interval 0,T") self.prange = prange diff --git a/pyerrors/obs.py b/pyerrors/obs.py index a1c2fd55..0caecfdc 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -856,15 +856,12 @@ class Obs: def __pow__(self, y): if isinstance(y, Obs): - return derived_observable(lambda x: x[0] ** x[1], [self, y]) + return derived_observable(lambda x, **kwargs: x[0] ** x[1], [self, y], man_grad=[y.value * self.value ** (y.value - 1), self.value ** y.value * np.log(self.value)]) else: - return derived_observable(lambda x: x[0] ** y, [self]) + return derived_observable(lambda x, **kwargs: x[0] ** y, [self], man_grad=[y * self.value ** (y - 1)]) def __rpow__(self, y): - if isinstance(y, Obs): - return derived_observable(lambda x: x[0] ** x[1], [y, self]) - else: - return derived_observable(lambda x: y ** x[0], [self]) + return derived_observable(lambda x, **kwargs: y ** x[0], [self], man_grad=[y ** self.value * np.log(y)]) def __abs__(self): return derived_observable(lambda x: anp.abs(x[0]), [self]) diff --git a/pyerrors/version.py b/pyerrors/version.py index 9b9dc340..941c31df 100644 --- a/pyerrors/version.py +++ b/pyerrors/version.py @@ -1 +1 @@ -__version__ = "2.13.0-dev" +__version__ = "2.14.0-dev" diff --git a/tests/obs_test.py b/tests/obs_test.py index 726ecffa..8b82213f 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -461,6 +461,18 @@ def test_cobs_overloading(): obs / cobs +def test_pow(): + data = [1, 2.341, pe.pseudo_Obs(4.8, 0.48, "test_obs"), pe.cov_Obs(1.1, 0.3 ** 2, "test_cov_obs")] + + for d in data: + assert d * d == d ** 2 + assert d * d * d == d ** 3 + + for d2 in data: + assert np.log(d ** d2) == d2 * np.log(d) + assert (d ** d2) ** (1 / d2) == d + + def test_reweighting(): my_obs = pe.Obs([np.random.rand(1000)], ['t']) assert not my_obs.reweighted