mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
implement explicit type checks
This commit is contained in:
parent
f60e623073
commit
815e885a58
2 changed files with 25 additions and 2 deletions
|
@ -237,8 +237,14 @@ def read_sfcf_multi(path, prefix, name_list, quarks_list=['.*'], corr_type_list=
|
|||
if "files" in kwargs:
|
||||
files = kwargs.get("files")
|
||||
if isinstance(files, list):
|
||||
if isinstance(files[0], list):
|
||||
if all(isinstance(f, list) for f in files):
|
||||
files = files[i]
|
||||
elif all(isinstance(f, str) for f in files):
|
||||
files = files
|
||||
else:
|
||||
raise TypeError("files has to be of type list[list[str]] or list[str]!")
|
||||
else:
|
||||
raise TypeError("files has to be of type list[list[str]] or list[str]!")
|
||||
|
||||
else:
|
||||
files = []
|
||||
|
@ -313,7 +319,10 @@ def read_sfcf_multi(path, prefix, name_list, quarks_list=['.*'], corr_type_list=
|
|||
w = specs[3]
|
||||
w2 = specs[4]
|
||||
if "files" in kwargs:
|
||||
if isinstance(kwargs.get("files"), list) and all(isinstance(f, str) for f in kwargs.get("files")):
|
||||
name_ls = kwargs.get("files")
|
||||
else:
|
||||
raise TypeError("In append mode, files has to be of type list[str]!")
|
||||
else:
|
||||
name_ls = ls
|
||||
for exc in name_ls:
|
||||
|
|
|
@ -144,6 +144,13 @@ def test_c_bi_files(tmp_path):
|
|||
assert f_A[2].value == -41.025094911185185
|
||||
|
||||
|
||||
def test_c_bi_files_int_fail(tmp_path):
|
||||
build_test_environment(str(tmp_path), "c", 10, 3)
|
||||
with pytest.raises(TypeError):
|
||||
sfin.read_sfcf(str(tmp_path) + "/data_c", "data_c", "f_A", quarks="lquark lquark", wf=0, version="2.0c",
|
||||
files=[[range(1, 11, 2)], [range(2, 11, 2)], [range(1, 11, 2)]])
|
||||
|
||||
|
||||
def test_c_bib(tmp_path):
|
||||
build_test_environment(str(tmp_path), "c", 5, 3)
|
||||
f_V0 = sfin.read_sfcf(str(tmp_path) + "/data_c", "data_c", "F_V0", quarks="lquark lquark", wf=0, wf2=0, version="2.0c", corr_type="bib")
|
||||
|
@ -291,6 +298,13 @@ def test_a_bi_files(tmp_path):
|
|||
assert f_A[2].value == -41.025094911185185
|
||||
|
||||
|
||||
def test_a_bi_files_int_fail(tmp_path):
|
||||
build_test_environment(str(tmp_path), "a", 10, 3)
|
||||
with pytest.raises(TypeError):
|
||||
sfin.read_sfcf(str(tmp_path) + "/data_a", "data_a", "f_A", quarks="lquark lquark", wf=0, version="2.0a",
|
||||
files=[[range(1, 11, 2)], [range(2, 11, 2)], [range(1, 11, 2)]])
|
||||
|
||||
|
||||
def test_a_bib(tmp_path):
|
||||
build_test_environment(str(tmp_path), "a", 5, 3)
|
||||
f_V0 = sfin.read_sfcf(str(tmp_path) + "/data_a", "data_a", "F_V0", quarks="lquark lquark", wf=0, wf2=0, version="2.0a", corr_type="bib")
|
||||
|
|
Loading…
Add table
Reference in a new issue