Skip to content

Commit

Permalink
Handle repeated values in files_in and warn user
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaponte committed Jun 7, 2024
1 parent 5129362 commit 1944309
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion invisible_cities/cities/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ def proxy(**kwds):
conf.files_in = [conf.files_in]

globbed_files = map(glob, map(expandvars, conf.files_in))
conf.files_in = sorted(f for fs in globbed_files for f in fs)
globbed_files = sorted(f for fs in globbed_files for f in fs)
if len(set(globbed_files)) != len(globbed_files):
warnings.warn("files_in contains repeated values. Ignoring duplicate files.", UserWarning)
globbed_files = sorted(set(globbed_files))

conf.files_in = globbed_files
conf.file_out = expandvars(conf.file_out)

conf.event_range = event_range(conf)
Expand Down
1 change: 1 addition & 0 deletions invisible_cities/cities/components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def write_config_file(filename, **kwargs):
, ["electrons_511keV_z250_RWF.h5" , "electrons_1250keV_z250_RWF.h5", "electrons_2500keV_z250_RWF.h5"] )
)
)
@mark.filterwarnings("ignore:files_in contains repeated values")
def test_city_files_in(case_, files_in, expected, config_tmpdir, ICDATADIR):
"""
Check that all possible files_in inputs are handled properly:
Expand Down

0 comments on commit 1944309

Please sign in to comment.