Merge branch 'develop' into ci/add_python_3.14

This commit is contained in:
Fabian Joswig 2024-12-18 18:03:19 +01:00 committed by GitHub
commit fb39000284
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 84 additions and 14 deletions

58
.github/workflows/release.yml vendored Normal file
View file

@ -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

View file

@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file. 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 ## [2.12.0] - 2024-08-22
### Changed ### Changed

View file

@ -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
`pyerrors` is a python framework for error computation and propagation of Markov chain Monte Carlo data from lattice field theory and statistical mechanics simulations. `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 pyerrors # Fresh install
python -m pip install -U pyerrors # Update 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 ## 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). 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).

View file

@ -862,7 +862,7 @@ class Corr:
raise Exception("prange must be a list or array with two values") raise Exception("prange must be a list or array with two values")
if not ((isinstance(prange[0], int)) and (isinstance(prange[1], int))): if not ((isinstance(prange[0], int)) and (isinstance(prange[1], int))):
raise Exception("Start and end point must be integers") 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") raise Exception("Start and end point must define a range in the interval 0,T")
self.prange = prange self.prange = prange

View file

@ -856,15 +856,12 @@ class Obs:
def __pow__(self, y): def __pow__(self, y):
if isinstance(y, Obs): 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: 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): def __rpow__(self, y):
if isinstance(y, Obs): return derived_observable(lambda x, **kwargs: y ** x[0], [self], man_grad=[y ** self.value * np.log(y)])
return derived_observable(lambda x: x[0] ** x[1], [y, self])
else:
return derived_observable(lambda x: y ** x[0], [self])
def __abs__(self): def __abs__(self):
return derived_observable(lambda x: anp.abs(x[0]), [self]) return derived_observable(lambda x: anp.abs(x[0]), [self])

View file

@ -1 +1 @@
__version__ = "2.13.0-dev" __version__ = "2.14.0-dev"

View file

@ -461,6 +461,18 @@ def test_cobs_overloading():
obs / cobs 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(): def test_reweighting():
my_obs = pe.Obs([np.random.rand(1000)], ['t']) my_obs = pe.Obs([np.random.rand(1000)], ['t'])
assert not my_obs.reweighted assert not my_obs.reweighted