diff --git a/pyerrors/input/openQCD.py b/pyerrors/input/openQCD.py index d02b6280..a1b4e61d 100644 --- a/pyerrors/input/openQCD.py +++ b/pyerrors/input/openQCD.py @@ -210,7 +210,7 @@ def extract_t0(path, prefix, dtr_read, xmin, crossing to be included in the linear fit. (Default: 5) r_start : list list which contains the first config to be read for each replicum. - r_stop: list + r_stop : list list which contains the last config to be read for each replicum. plaquette : bool If true extract the plaquette estimate of t0 instead. @@ -367,37 +367,37 @@ def read_qtop(path, prefix, c, dtr_cnfg=1, version="1.2", **kwargs): Parameters ---------- - path: + path : str path of the measurement files - prefix: + prefix : str prefix of the measurement files, e.g. _id0_r0.ms.dat - c: double + c : double Smearing radius in units of the lattice extent, c = sqrt(8 t0) / L - dtr_cnfg: int + dtr_cnfg : int (optional) parameter that specifies the number of trajectories between two configs. if it is not set, the distance between two measurements in the file is assumed to be the distance between two configurations. - steps: int + steps : int (optional) (maybe only necessary for openQCD2.0) nt step size, guessed if not given - version: str + version : str version string of the openQCD (sfqcd) version used to create the ensemble - L: int + L : int spatial length of the lattice in L/a. HAS to be set if version != sfqcd, since openQCD does not provide this in the header - r_start: list + r_start : list offset of the first ensemble, making it easier to match later on with other Obs - r_stop: list + r_stop : list last configurations that need to be read (per replicum) - files: list + files : list specify the exact files that need to be read from path, practical if e.g. only one replicum is needed - names: list + names : list Alternative labeling for replicas/ensembles. Has to have the appropriate length """ @@ -545,11 +545,19 @@ def read_qtop(path, prefix, c, dtr_cnfg=1, version="1.2", **kwargs): def read_qtop_sector(target=0, **kwargs): - """target: int - specifies the topological sector to be reweighted to (default 0) - q_top: Obs - alternatively takes args of read_qtop method as kwargs + """Constructs reweighting factors to a specified topological sector. + + Parameters + ---------- + target : int + Specifies the topological sector to be reweighted to (default 0) + q_top : Obs + Alternatively takes args of read_qtop method as kwargs """ + + if not isinstance(target, int): + raise Exception("'target' has to be an integer.") + if "q_top" in kwargs: qtop = kwargs.get("q_top") else: diff --git a/pyerrors/misc.py b/pyerrors/misc.py index 7e52d795..f7fa0af3 100644 --- a/pyerrors/misc.py +++ b/pyerrors/misc.py @@ -79,7 +79,7 @@ def _assert_equal_properties(ol, otype=Obs): if not isinstance(o, otype): raise Exception("Wrong data type in list.") if not ol[0].is_merged == o.is_merged: - raise Exception("All Obs in list have to be defined on the same set of configs.") + raise Exception("All Obs in list have to have the same state 'is_merged'.") if not ol[0].reweighted == o.reweighted: raise Exception("All Obs in list have to have the same property 'reweighted'.") if not ol[0].e_content == o.e_content: diff --git a/tests/io_test.py b/tests/io_test.py index b6989f60..88f0a3ae 100644 --- a/tests/io_test.py +++ b/tests/io_test.py @@ -98,11 +98,11 @@ def test_json_corr_io(): for obs_list in [my_list, rw_list]: for tag in [None, "test"]: obs_list[3].tag = tag - for fp in [0, 2]: - for bp in [0, 7]: - for corr_tag in [None, 'my_Corr_tag']: + for pad in [0, 2]: + for corr_tag in [None, 'my_Corr_tag']: + for prange in [None, [3, 6]]: for gap in [False, True]: - my_corr = pe.Corr(obs_list, padding=[fp, bp]) + my_corr = pe.Corr(obs_list, padding=[pad, pad], prange=prange) my_corr.tag = corr_tag if gap: my_corr.content[4] = None @@ -114,6 +114,7 @@ def test_json_corr_io(): if entry is None: assert recover[index] is None assert my_corr.tag == recover.tag + assert my_corr.prange == recover.prange assert my_corr.reweighted == recover.reweighted @@ -123,13 +124,15 @@ def test_json_corr_2d_io(): for tag in [None, "test"]: obs_list[3][0, 1].tag = tag for padding in [0, 1]: - my_corr = pe.Corr(obs_list, padding=[padding, padding]) - my_corr.tag = tag - pe.input.json.dump_to_json(my_corr, 'corr') - recover = pe.input.json.load_json('corr') - os.remove('corr.json.gz') - assert np.all([np.all([o.is_zero() for o in q]) for q in [x.ravel() for x in (my_corr - recover) if x is not None]]) - for index, entry in enumerate(my_corr): - if entry is None: - assert recover[index] is None - assert my_corr.tag == recover.tag + for prange in [None, [3, 6]]: + my_corr = pe.Corr(obs_list, padding=[padding, padding], prange=prange) + my_corr.tag = tag + pe.input.json.dump_to_json(my_corr, 'corr') + recover = pe.input.json.load_json('corr') + os.remove('corr.json.gz') + assert np.all([np.all([o.is_zero() for o in q]) for q in [x.ravel() for x in (my_corr - recover) if x is not None]]) + for index, entry in enumerate(my_corr): + if entry is None: + assert recover[index] is None + assert my_corr.tag == recover.tag + assert my_corr.prange == recover.prange