mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 23:00:25 +01:00
Merge branch 'develop' into feature/rwf
This commit is contained in:
commit
78254020f8
6 changed files with 99 additions and 48 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -2,30 +2,39 @@
|
||||||
|
|
||||||
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.0.0] - 2021-??-??
|
## [2.0.0] - 2022-??-??
|
||||||
### Added
|
### Added
|
||||||
|
- The possibility to work with Monte Carlo histories which are evenly or unevenly spaced was added.
|
||||||
|
- `cov_Obs` added as a possibility to propagate the error of non Monte Carlo data together with Monte Carlo data.
|
||||||
- `CObs` class added which can handle complex valued Markov chain Monte Carlo data and the corresponding error propagation.
|
- `CObs` class added which can handle complex valued Markov chain Monte Carlo data and the corresponding error propagation.
|
||||||
- Matrix to matrix operations like the matrix inverse now also work for complex matrices and matrices containing entries that are not `Obs` but `float` or `int`.
|
- Matrix to matrix operations like the matrix inverse now also work for complex matrices and matrices containing entries that are not `Obs` but `float` or `int`.
|
||||||
- The possibility to work with Monte Carlo histories which are evenly or unevenly spaced was added.
|
- Support for a new `json.gz` file format was added
|
||||||
- The Corr class now has additional methods like `reverse`, `T_symmetry`, `correlate` and `reweight`.
|
- The Corr class now has additional methods like `reverse`, `T_symmetry`, `correlate` and `reweight`.
|
||||||
- `linalg` module now has explicit functions `inv` and `cholesky`.
|
- `Corr.m_eff` can now cope with periodic and anti-periodic correlation functions
|
||||||
|
- Forward, backward and improved variants of the first and second derivative were added to the `Corr` class
|
||||||
|
- The `linalg` module now has explicit functions `inv` and `cholesky`.
|
||||||
- `Obs` objects now have methods `is_zero` and `is_zero_within_error` as well as overloaded comparison operations.
|
- `Obs` objects now have methods `is_zero` and `is_zero_within_error` as well as overloaded comparison operations.
|
||||||
- Functions to convert Obs data to or from jackknife was added.
|
- Functions to convert Obs data to or from jackknife was added.
|
||||||
- Alternative matrix multiplication routine `jack_matmul` was added to `linalg` module which makes use of the jackknife approximation and is much faster for large matrices.
|
- Alternative matrix multiplication routine `jack_matmul` was added to `linalg` module which makes use of the jackknife approximation and is much faster for large matrices.
|
||||||
- Additional input routines for npr data added to `input.hadrons`.
|
- Additional input routines for npr data added to `input.hadrons`.
|
||||||
|
- The `sfcf` and `openQCD` input modules can now handle all recent file type versions.
|
||||||
|
- `extract_t0` can now visualize the extraction on the fly
|
||||||
|
- Module added which provides the Dirac gamma matrices in the Grid convention.
|
||||||
- Version number added.
|
- Version number added.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- The internal bookkeeping system for ensembles/replica was changed. The separator for replica is now `|`.
|
- The internal bookkeeping system for ensembles/replica was changed. The separator for replica is now `|`.
|
||||||
- The fit functions were renamed to `least_squares` and `total_least_squares`.
|
- The fit functions were renamed to `least_squares` and `total_least_squares`.
|
||||||
|
- The output of the fit functions is now a dedicated results class which keeps track of all relevant information
|
||||||
- The fit functions can now deal with provided covariance matrices.
|
- The fit functions can now deal with provided covariance matrices.
|
||||||
- The convention for the fit range in the Corr class has been changed.
|
- The convention for the fit range in the Corr class has been changed.
|
||||||
- Obs.print was renamed to Obs.details and the output was improved.
|
- Various method of the `Corr` class were renamed
|
||||||
|
- `Obs.print` was renamed to `Obs.details` and the output was improved.
|
||||||
- The default value for `Corr.prange` is now `None`.
|
- The default value for `Corr.prange` is now `None`.
|
||||||
- The `input` module was restructured to contain one submodule per data source.
|
- The `input` module was restructured to contain one submodule per data source.
|
||||||
- Performance of Obs.__init__ improved.
|
- Performance of Obs.__init__ improved.
|
||||||
|
|
||||||
### Deprecated
|
### Removed
|
||||||
- The function `plot_corrs` was deprecated as all its functionality is now contained within `Corr.show`
|
- The function `plot_corrs` was deprecated as all its functionality is now contained within `Corr.show`
|
||||||
- The kwarg `bias_correction` in `derived_observable` was removed
|
- The kwarg `bias_correction` in `derived_observable` was removed
|
||||||
- Obs no longer have an attribute `e_Q`
|
- Obs no longer have an attribute `e_Q`
|
||||||
|
|
|
@ -376,6 +376,24 @@ class Corr:
|
||||||
"""Reverse the time ordering of the Corr"""
|
"""Reverse the time ordering of the Corr"""
|
||||||
return Corr(self.content[:: -1])
|
return Corr(self.content[:: -1])
|
||||||
|
|
||||||
|
def thin(self, spacing=2, offset=0):
|
||||||
|
"""Thin out a correlator to suppress correlations
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
spacing : int
|
||||||
|
Keep only every 'spacing'th entry of the correlator
|
||||||
|
offset : int
|
||||||
|
Offset the equal spacing
|
||||||
|
"""
|
||||||
|
new_content = []
|
||||||
|
for t in range(self.T):
|
||||||
|
if (offset + t) % spacing != 0:
|
||||||
|
new_content.append(None)
|
||||||
|
else:
|
||||||
|
new_content.append(self.content[t])
|
||||||
|
return Corr(new_content)
|
||||||
|
|
||||||
def correlate(self, partner):
|
def correlate(self, partner):
|
||||||
"""Correlate the correlator with another correlator or Obs
|
"""Correlate the correlator with another correlator or Obs
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,9 @@ def create_json_string(ol, description='', indent=1):
|
||||||
names.append(key)
|
names.append(key)
|
||||||
idl.append(value)
|
idl.append(value)
|
||||||
my_obs = Obs(samples, names, idl)
|
my_obs = Obs(samples, names, idl)
|
||||||
|
my_obs._covobs = obs._covobs
|
||||||
|
for name in obs._covobs:
|
||||||
|
my_obs.names.append(name)
|
||||||
my_obs.reweighted = obs.reweighted
|
my_obs.reweighted = obs.reweighted
|
||||||
my_obs.is_merged = obs.is_merged
|
my_obs.is_merged = obs.is_merged
|
||||||
return my_obs
|
return my_obs
|
||||||
|
|
|
@ -283,3 +283,11 @@ def test_hankel():
|
||||||
corr.Hankel(2)
|
corr.Hankel(2)
|
||||||
corr.Hankel(6, periodic=True)
|
corr.Hankel(6, periodic=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_thin():
|
||||||
|
c = pe.Corr([pe.pseudo_Obs(i, .1, 'test') for i in range(10)])
|
||||||
|
c *= pe.cov_Obs(1., .1, '#ren')
|
||||||
|
thin = c.thin()
|
||||||
|
thin.fit(lambda a, x: a[0] * x)
|
||||||
|
c.thin(offset=1)
|
||||||
|
c.thin(3, offset=1)
|
||||||
|
|
|
@ -244,46 +244,10 @@ def test_json_dict_io():
|
||||||
os.remove(fname + '.json.gz')
|
os.remove(fname + '.json.gz')
|
||||||
|
|
||||||
|
|
||||||
def test_openqcd():
|
def test_renorm_deriv_of_corr(tmp_path):
|
||||||
path = './tests//data/openqcd_test/'
|
c = pe.Corr([pe.pseudo_Obs(i, .1, 'test') for i in range(10)])
|
||||||
prefix = 'sfqcd'
|
c *= pe.cov_Obs(1., .1, '#ren')
|
||||||
postfix = '.rwms'
|
c = c.deriv()
|
||||||
|
pe.input.json.dump_to_json(c, (tmp_path / 'test').as_posix())
|
||||||
# sfqcd-1.6: Trajectories instead of confignumbers are printed to file.
|
recover = pe.input.json.load_json((tmp_path / 'test').as_posix())
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix)
|
assert np.all([o == 0 for o in (c - recover)[1:-1]])
|
||||||
repname = list(rwfo[0].idl.keys())[0]
|
|
||||||
assert(rwfo[0].idl[repname] == range(1, 13))
|
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[1], r_stop=[12])
|
|
||||||
assert(rwfo[0].idl[repname] == range(1, 13))
|
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[3], r_stop=[8])
|
|
||||||
assert(rwfo[0].idl[repname] == range(3, 9))
|
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[2], r_stop=[6])
|
|
||||||
assert(rwfo[0].idl[repname] == range(2, 7))
|
|
||||||
rwfs = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[1], r_stop=[12], r_step=2)
|
|
||||||
assert(rwfs[0].idl[repname] == range(1, 12, 2))
|
|
||||||
rwfs = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[2], r_stop=[12], r_step=2)
|
|
||||||
assert(rwfs[0].idl[repname] == range(2, 13, 2))
|
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix)
|
|
||||||
assert((rwfo[0].r_values[repname] + rwfo[0].deltas[repname][1]) == (rwfs[0].r_values[repname] + rwfs[0].deltas[repname][0]))
|
|
||||||
|
|
||||||
o = pe.pseudo_Obs(1., .01, repname, samples=12)
|
|
||||||
pe.reweight(rwfo[0], [o])
|
|
||||||
|
|
||||||
o = pe.pseudo_Obs(1., .01, repname, samples=6)
|
|
||||||
pe.reweight(rwfo[0], [o])
|
|
||||||
o.idl[repname] = range(2, 13, 2)
|
|
||||||
pe.reweight(rwfo[0], [o])
|
|
||||||
pe.reweight(rwfs[0], [o])
|
|
||||||
|
|
||||||
files = ['openqcd2r1.ms1.dat']
|
|
||||||
names = ['openqcd2|r1']
|
|
||||||
|
|
||||||
# TM with 2 Hasenbusch factors and 2 sources each + RHMC with one source, openQCD 2.0
|
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='2.0', files=files, names=names)
|
|
||||||
assert(len(rwfo) == 2)
|
|
||||||
assert(rwfo[0].value == 0.9999974970236312)
|
|
||||||
assert(rwfo[1].value == 1.184681251089919)
|
|
||||||
repname = list(rwfo[0].idl.keys())[0]
|
|
||||||
assert(rwfo[0].idl[repname] == range(1, 10))
|
|
||||||
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='2.0', files=files, names=names, r_start=[1], r_stop=[8])
|
|
||||||
assert(rwfo[0].idl[repname] == range(1, 9))
|
|
49
tests/openQCD_in_test.py
Normal file
49
tests/openQCD_in_test.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import os
|
||||||
|
import numpy as np
|
||||||
|
import pyerrors as pe
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def test_openqcd():
|
||||||
|
path = './tests//data/openqcd_test/'
|
||||||
|
prefix = 'sfqcd'
|
||||||
|
postfix = '.rwms'
|
||||||
|
|
||||||
|
# sfqcd-1.6: Trajectories instead of confignumbers are printed to file.
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix)
|
||||||
|
repname = list(rwfo[0].idl.keys())[0]
|
||||||
|
assert(rwfo[0].idl[repname] == range(1, 13))
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[1], r_stop=[12])
|
||||||
|
assert(rwfo[0].idl[repname] == range(1, 13))
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[3], r_stop=[8])
|
||||||
|
assert(rwfo[0].idl[repname] == range(3, 9))
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[2], r_stop=[6])
|
||||||
|
assert(rwfo[0].idl[repname] == range(2, 7))
|
||||||
|
rwfs = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[1], r_stop=[12], r_step=2)
|
||||||
|
assert(rwfs[0].idl[repname] == range(1, 12, 2))
|
||||||
|
rwfs = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix, r_start=[2], r_stop=[12], r_step=2)
|
||||||
|
assert(rwfs[0].idl[repname] == range(2, 13, 2))
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='1.6', postfix=postfix)
|
||||||
|
assert((rwfo[0].r_values[repname] + rwfo[0].deltas[repname][1]) == (rwfs[0].r_values[repname] + rwfs[0].deltas[repname][0]))
|
||||||
|
|
||||||
|
o = pe.pseudo_Obs(1., .01, repname, samples=12)
|
||||||
|
pe.reweight(rwfo[0], [o])
|
||||||
|
|
||||||
|
o = pe.pseudo_Obs(1., .01, repname, samples=6)
|
||||||
|
pe.reweight(rwfo[0], [o])
|
||||||
|
o.idl[repname] = range(2, 13, 2)
|
||||||
|
pe.reweight(rwfo[0], [o])
|
||||||
|
pe.reweight(rwfs[0], [o])
|
||||||
|
|
||||||
|
files = ['openqcd2r1.ms1.dat']
|
||||||
|
names = ['openqcd2|r1']
|
||||||
|
|
||||||
|
# TM with 2 Hasenbusch factors and 2 sources each + RHMC with one source, openQCD 2.0
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='2.0', files=files, names=names)
|
||||||
|
assert(len(rwfo) == 2)
|
||||||
|
assert(rwfo[0].value == 0.9999974970236312)
|
||||||
|
assert(rwfo[1].value == 1.184681251089919)
|
||||||
|
repname = list(rwfo[0].idl.keys())[0]
|
||||||
|
assert(rwfo[0].idl[repname] == range(1, 10))
|
||||||
|
rwfo = pe.input.openQCD.read_rwms(path, prefix, version='2.0', files=files, names=names, r_start=[1], r_stop=[8])
|
||||||
|
assert(rwfo[0].idl[repname] == range(1, 9))
|
Loading…
Add table
Reference in a new issue