Skip to content

Commit

Permalink
as discussed, simplify the code by treating png/webp cases the same a…
Browse files Browse the repository at this point in the history
…s geojsons, as filenames should have already the same logic in theory?
  • Loading branch information
charlienegri committed Feb 10, 2025
1 parent 2b6506f commit 7b97efc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 1 addition & 6 deletions pyaerocom/aeroval/experiment_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,7 @@ def _info_from_contour_dir_file(file: pathlib.PosixPath):
spl = os.path.basename(file.name).split(suffix)[0].split("_")

if len(spl) == 3:
if suffix == ".png" or suffix == ".webp":
name = spl[0]
var_name = spl[1]
per = spl[2]
return (name, var_name, per)
elif suffix == ".geojson":
if suffix == ".geojson" or suffix == ".png" or suffix == ".webp":
name = spl[1]
var_name = spl[0]
per = spl[2]
Expand Down
8 changes: 4 additions & 4 deletions tests/aeroval/test_experiment_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ def test_ExperimentOutput__info_from_map_file_error(filename: str):


def test_ExperimentOutput__info_from_contour_dir_file_webp():
file = pathlib.PosixPath("path/to/name_vertical_period.webp")
file = pathlib.PosixPath("path/to/var_name_period.webp")
output = ExperimentOutput._info_from_contour_dir_file(file)
assert output == ("name", "vertical", "period")
assert output == ("name", "var", "period")


def test_ExperimentOutput__info_from_contour_dir_file_geojson():
file = pathlib.PosixPath("path/to/var_model_period.geojson")
file = pathlib.PosixPath("path/to/var_name_period.geojson")
output = ExperimentOutput._info_from_contour_dir_file(file)
assert output == ("model", "var", "period")
assert output == ("name", "var", "period")


def test_ExperimentOutput__info_from_contour_dir_file_error():
Expand Down

0 comments on commit 7b97efc

Please sign in to comment.