Skip to content

Commit f7e527b

Browse files
klapomtezzele
authored andcommitted
Bug fixing the I/O operations for mrCOSTS
1 parent 1f3d403 commit f7e527b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pydmd/mrcosts.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,16 @@ def to_netcdf(self, filename, filepath="."):
575575
576576
"""
577577
for c in self._costs_array:
578+
fname = ".".join(
579+
(
580+
filename,
581+
f"window={c.window_length:}",
582+
"nc",
583+
)
584+
)
585+
fpath = os.path.join(filepath, fname)
578586
c.to_xarray().to_netcdf(
579-
filepath.join(
580-
(
581-
filename,
582-
f"window={c.window_length:}",
583-
"nc",
584-
)
585-
),
587+
fpath,
586588
engine="h5netcdf",
587589
invalid_netcdf=True,
588590
)

tests/test_mrcosts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_netcdf(tmp_path):
293293
"""
294294
# Move the I/O tests to the temporary test directory.
295295
mrc.to_netcdf("tests", filepath=tmp_path)
296-
file_list = glob.glob("*tests*.nc")
296+
file_list = glob.glob(os.path.join(tmp_path, "*tests*.nc"))
297297
mrc_from_file = mrCOSTS()
298298
mrc_from_file.from_netcdf(file_list)
299299

0 commit comments

Comments
 (0)