diff --git a/pyerrors/input/sfcf.py b/pyerrors/input/sfcf.py index c91c8fcb..94aa1948 100644 --- a/pyerrors/input/sfcf.py +++ b/pyerrors/input/sfcf.py @@ -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: - name_ls = kwargs.get("files") + 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: diff --git a/tests/sfcf_in_test.py b/tests/sfcf_in_test.py index 5759ccf9..f92126f9 100644 --- a/tests/sfcf_in_test.py +++ b/tests/sfcf_in_test.py @@ -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")