mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
small change in read parameters, made tests available for auto-testing
This commit is contained in:
parent
5062f030c4
commit
a33d6897f0
2 changed files with 39 additions and 46 deletions
|
@ -9,8 +9,7 @@ from ..obs import Obs
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
def read_sfcf(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0,
|
def read_sfcf(path, prefix, name, quarks='.*', corr_type = 'bi', noffset=0, wf=0, wf2=0, version="1.0c", **kwargs):
|
||||||
version="1.0c", **kwargs):
|
|
||||||
"""Read sfcf c format from given folder structure.
|
"""Read sfcf c format from given folder structure.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -30,13 +29,10 @@ def read_sfcf(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0,
|
||||||
im: bool
|
im: bool
|
||||||
if True, read imaginary instead of real part
|
if True, read imaginary instead of real part
|
||||||
of the correlation function.
|
of the correlation function.
|
||||||
b2b: bool
|
corr_type : str
|
||||||
if True, read a time-dependent boundary-to-boundary
|
change between bi (boundary - inner) (default) bib (boundary - inner - boundary) and bb (boundary - boundary)
|
||||||
correlation function
|
correlator types
|
||||||
single: bool
|
names : list
|
||||||
if True, read time independent boundary to boundary
|
|
||||||
correlation function
|
|
||||||
names: list
|
|
||||||
Alternative labeling for replicas/ensembles.
|
Alternative labeling for replicas/ensembles.
|
||||||
Has to have the appropriate length
|
Has to have the appropriate length
|
||||||
ens_name : str
|
ens_name : str
|
||||||
|
@ -55,8 +51,6 @@ def read_sfcf(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0,
|
||||||
check_configs:
|
check_configs:
|
||||||
list of list of supposed configs, eg. [range(1,1000)]
|
list of list of supposed configs, eg. [range(1,1000)]
|
||||||
for one replicum with 1000 configs
|
for one replicum with 1000 configs
|
||||||
TODO:
|
|
||||||
- whats going on with files here?
|
|
||||||
"""
|
"""
|
||||||
if kwargs.get('im'):
|
if kwargs.get('im'):
|
||||||
im = 1
|
im = 1
|
||||||
|
@ -65,18 +59,18 @@ def read_sfcf(path, prefix, name, quarks='.*', noffset=0, wf=0, wf2=0,
|
||||||
im = 0
|
im = 0
|
||||||
part = 'real'
|
part = 'real'
|
||||||
|
|
||||||
if kwargs.get('single'):
|
|
||||||
b2b = 1
|
|
||||||
single = 1
|
|
||||||
else:
|
|
||||||
if kwargs.get('b2b'):
|
|
||||||
b2b = 1
|
|
||||||
else:
|
|
||||||
b2b = 0
|
|
||||||
single = 0
|
|
||||||
if "replica" in kwargs:
|
if "replica" in kwargs:
|
||||||
reps = kwargs.get("replica")
|
reps = kwargs.get("replica")
|
||||||
|
|
||||||
|
if corr_type == 'bb':
|
||||||
|
b2b = True
|
||||||
|
single = True
|
||||||
|
elif corr_type == 'bib':
|
||||||
|
b2b = True
|
||||||
|
single = False
|
||||||
|
else:
|
||||||
|
b2b = False
|
||||||
|
single = False
|
||||||
# due to higher usage in current projects,
|
# due to higher usage in current projects,
|
||||||
# compact file format is default
|
# compact file format is default
|
||||||
compact = True
|
compact = True
|
||||||
|
|
|
@ -7,43 +7,42 @@ import pyerrors as pe
|
||||||
import pyerrors.input.openQCD as qcdin
|
import pyerrors.input.openQCD as qcdin
|
||||||
import pyerrors.input.sfcf as sfin
|
import pyerrors.input.sfcf as sfin
|
||||||
import shutil
|
import shutil
|
||||||
import pytest
|
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
def build_test_environment(type, cfgs, reps):
|
def build_test_environment(env_type, cfgs, reps):
|
||||||
if type == "o":
|
if env_type == "o":
|
||||||
for i in range(2,cfgs+1):
|
for i in range(2,cfgs+1):
|
||||||
shutil.copytree("data/sfcf_test/data_o/test_r0/cfg1","data/sfcf_test/data_o/test_r0/cfg"+str(i))
|
shutil.copytree("tests/data/sfcf_test/data_o/test_r0/cfg1","tests/data/sfcf_test/data_o/test_r0/cfg"+str(i))
|
||||||
for i in range(1,reps):
|
for i in range(1,reps):
|
||||||
shutil.copytree("data/sfcf_test/data_o/test_r0", "data/sfcf_test/data_o/test_r"+str(i))
|
shutil.copytree("tests/data/sfcf_test/data_o/test_r0", "tests/data/sfcf_test/data_o/test_r"+str(i))
|
||||||
elif type == "c":
|
elif env_type == "c":
|
||||||
for i in range(2,cfgs+1):
|
for i in range(2,cfgs+1):
|
||||||
shutil.copy("data/sfcf_test/data_c/data_c_r0/data_c_r0_n1","data/sfcf_test/data_c/data_c_r0/data_c_r0_n"+str(i))
|
shutil.copy("tests/data/sfcf_test/data_c/data_c_r0/data_c_r0_n1","tests/data/sfcf_test/data_c/data_c_r0/data_c_r0_n"+str(i))
|
||||||
for i in range(1,reps):
|
for i in range(1,reps):
|
||||||
os.mkdir("data/sfcf_test/data_c/data_c_r"+str(i))
|
os.mkdir("tests/data/sfcf_test/data_c/data_c_r"+str(i))
|
||||||
for j in range(1,cfgs+1):
|
for j in range(1,cfgs+1):
|
||||||
shutil.copy("data/sfcf_test/data_c/data_c_r0/data_c_r0_n1","data/sfcf_test/data_c/data_c_r"+str(i)+"/data_c_r"+str(i)+"_n"+str(j))
|
shutil.copy("tests/data/sfcf_test/data_c/data_c_r0/data_c_r0_n1","tests/data/sfcf_test/data_c/data_c_r"+str(i)+"/data_c_r"+str(i)+"_n"+str(j))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clean_test_environment(type, cfgs, reps):
|
def clean_test_environment(env_type, cfgs, reps):
|
||||||
if type == "o":
|
if env_type == "o":
|
||||||
for i in range(1,reps):
|
for i in range(1,reps):
|
||||||
shutil.rmtree("data/sfcf_test/data_o/test_r"+str(i))
|
shutil.rmtree("tests/data/sfcf_test/data_o/test_r"+str(i))
|
||||||
for i in range(2,cfgs+1):
|
for i in range(2,cfgs+1):
|
||||||
shutil.rmtree("data/sfcf_test/data_o/test_r0/cfg"+str(i))
|
shutil.rmtree("tests/data/sfcf_test/data_o/test_r0/cfg"+str(i))
|
||||||
elif type == "c":
|
elif env_type == "c":
|
||||||
for i in range(1,reps):
|
for i in range(1,reps):
|
||||||
shutil.rmtree("data/sfcf_test/data_c/data_c_r"+str(i))
|
shutil.rmtree("tests/data/sfcf_test/data_c/data_c_r"+str(i))
|
||||||
for i in range(2,cfgs+1):
|
for i in range(2,cfgs+1):
|
||||||
os.remove("data/sfcf_test/data_c/data_c_r0/data_c_r0_n"+str(i))
|
os.remove("tests/data/sfcf_test/data_c/data_c_r0/data_c_r0_n"+str(i))
|
||||||
|
|
||||||
|
|
||||||
def test_o_bb():
|
def test_o_bb():
|
||||||
build_test_environment("o",5,3)
|
build_test_environment("o",5,3)
|
||||||
f_1 = sfin.read_sfcf("data/sfcf_test/data_o", "test", "f_1",quarks="lquark lquark", wf = 0, wf2=0, version = "2.0", single = True)
|
f_1 = sfin.read_sfcf("tests/data/sfcf_test/data_o", "test", "f_1",quarks="lquark lquark", wf = 0, wf2=0, version = "2.0", single = True)
|
||||||
print(f_1)
|
print(f_1)
|
||||||
clean_test_environment("o",5,3)
|
clean_test_environment("o",5,3)
|
||||||
assert len(f_1) == 1
|
assert len(f_1) == 1
|
||||||
|
@ -51,7 +50,7 @@ def test_o_bb():
|
||||||
|
|
||||||
def test_o_bi():
|
def test_o_bi():
|
||||||
build_test_environment("o",5,3)
|
build_test_environment("o",5,3)
|
||||||
f_A = sfin.read_sfcf("data/sfcf_test/data_o", "test", "f_A",quarks="lquark lquark", wf = 0, version = "2.0")
|
f_A = sfin.read_sfcf("tests/data/sfcf_test/data_o", "test", "f_A",quarks="lquark lquark", wf = 0, version = "2.0")
|
||||||
print(f_A)
|
print(f_A)
|
||||||
clean_test_environment("o",5,3)
|
clean_test_environment("o",5,3)
|
||||||
assert len(f_A) == 3
|
assert len(f_A) == 3
|
||||||
|
@ -61,7 +60,7 @@ def test_o_bi():
|
||||||
|
|
||||||
def test_o_bib():
|
def test_o_bib():
|
||||||
build_test_environment("o",5,3)
|
build_test_environment("o",5,3)
|
||||||
f_V0 = sfin.read_sfcf("data/sfcf_test/data_o", "test", "F_V0",quarks="lquark lquark", wf = 0, wf2 = 0, version = "2.0", b2b = True)
|
f_V0 = sfin.read_sfcf("tests/data/sfcf_test/data_o", "test", "F_V0",quarks="lquark lquark", wf = 0, wf2 = 0, version = "2.0", b2b = True)
|
||||||
print(f_V0)
|
print(f_V0)
|
||||||
clean_test_environment("o",5,3)
|
clean_test_environment("o",5,3)
|
||||||
assert len(f_V0) == 3
|
assert len(f_V0) == 3
|
||||||
|
@ -71,7 +70,7 @@ def test_o_bib():
|
||||||
|
|
||||||
def test_c_bb():
|
def test_c_bb():
|
||||||
build_test_environment("c",5,3)
|
build_test_environment("c",5,3)
|
||||||
f_1 = sfin.read_sfcf("data/sfcf_test/data_c", "data_c", "f_1", quarks="lquark lquark", wf = 0, wf2=0, version = "2.0c", single = True)
|
f_1 = sfin.read_sfcf("tests/data/sfcf_test/data_c", "data_c", "f_1", quarks="lquark lquark", wf = 0, wf2=0, version = "2.0c", single = True)
|
||||||
print(f_1)
|
print(f_1)
|
||||||
clean_test_environment("c",5,3)
|
clean_test_environment("c",5,3)
|
||||||
assert len(f_1) == 1
|
assert len(f_1) == 1
|
||||||
|
@ -79,7 +78,7 @@ def test_c_bb():
|
||||||
|
|
||||||
def test_c_bi():
|
def test_c_bi():
|
||||||
build_test_environment("c",5,3)
|
build_test_environment("c",5,3)
|
||||||
f_A = sfin.read_sfcf("data/sfcf_test/data_c", "data_c", "f_A", quarks="lquark lquark", wf = 0, version = "2.0c")
|
f_A = sfin.read_sfcf("tests/data/sfcf_test/data_c", "data_c", "f_A", quarks="lquark lquark", wf = 0, version = "2.0c")
|
||||||
print(f_A)
|
print(f_A)
|
||||||
clean_test_environment("c",5,3)
|
clean_test_environment("c",5,3)
|
||||||
assert len(f_A) == 3
|
assert len(f_A) == 3
|
||||||
|
@ -89,7 +88,7 @@ def test_c_bi():
|
||||||
|
|
||||||
def test_c_bib():
|
def test_c_bib():
|
||||||
build_test_environment("c",5,3)
|
build_test_environment("c",5,3)
|
||||||
f_V0 = sfin.read_sfcf("data/sfcf_test/data_c", "data_c", "F_V0",quarks="lquark lquark", wf = 0, wf2 = 0, version = "2.0c", b2b = True)
|
f_V0 = sfin.read_sfcf("tests/data/sfcf_test/data_c", "data_c", "F_V0",quarks="lquark lquark", wf = 0, wf2 = 0, version = "2.0c", b2b = True)
|
||||||
print(f_V0)
|
print(f_V0)
|
||||||
clean_test_environment("c",5,3)
|
clean_test_environment("c",5,3)
|
||||||
assert len(f_V0) == 3
|
assert len(f_V0) == 3
|
||||||
|
@ -99,7 +98,7 @@ def test_c_bib():
|
||||||
|
|
||||||
def test_a_bb():
|
def test_a_bb():
|
||||||
build_test_environment("a",5,3)
|
build_test_environment("a",5,3)
|
||||||
f_1 = sfin.read_sfcf("data/sfcf_test/data_a", "data_a", "f_1", quarks="lquark lquark", wf = 0, wf2=0, version = "2.0a", single = True)
|
f_1 = sfin.read_sfcf("tests/data/sfcf_test/data_a", "data_a", "f_1", quarks="lquark lquark", wf = 0, wf2=0, version = "2.0a", single = True)
|
||||||
print(f_1)
|
print(f_1)
|
||||||
clean_test_environment("a",5,3)
|
clean_test_environment("a",5,3)
|
||||||
assert len(f_1) == 1
|
assert len(f_1) == 1
|
||||||
|
@ -107,7 +106,7 @@ def test_a_bb():
|
||||||
|
|
||||||
def test_a_bi():
|
def test_a_bi():
|
||||||
build_test_environment("a",5,3)
|
build_test_environment("a",5,3)
|
||||||
f_A = sfin.read_sfcf("data/sfcf_test/data_a", "data_a", "f_A", quarks="lquark lquark", wf = 0, version = "2.0a")
|
f_A = sfin.read_sfcf("tests/data/sfcf_test/data_a", "data_a", "f_A", quarks="lquark lquark", wf = 0, version = "2.0a")
|
||||||
print(f_A)
|
print(f_A)
|
||||||
clean_test_environment("a",5,3)
|
clean_test_environment("a",5,3)
|
||||||
assert len(f_A) == 3
|
assert len(f_A) == 3
|
||||||
|
@ -117,7 +116,7 @@ def test_a_bi():
|
||||||
|
|
||||||
def test_a_bib():
|
def test_a_bib():
|
||||||
build_test_environment("a",5,3)
|
build_test_environment("a",5,3)
|
||||||
f_V0 = sfin.read_sfcf("data/sfcf_test/data_a", "data_a", "F_V0",quarks="lquark lquark", wf = 0, wf2 = 0, version = "2.0a", b2b = True)
|
f_V0 = sfin.read_sfcf("tests/data/sfcf_test/data_a", "data_a", "F_V0",quarks="lquark lquark", wf = 0, wf2 = 0, version = "2.0a", b2b = True)
|
||||||
print(f_V0)
|
print(f_V0)
|
||||||
clean_test_environment("a",5,3)
|
clean_test_environment("a",5,3)
|
||||||
assert len(f_V0) == 3
|
assert len(f_V0) == 3
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue