From bd874f1b3ebf0e75851da750dd179593a0f7e7f0 Mon Sep 17 00:00:00 2001 From: Joshua Einstein-Curtis <33426885+jeinstei@users.noreply.github.com> Date: Thu, 16 Jan 2025 09:38:19 -0600 Subject: [PATCH] Update plots.py for PathLike to string handling error (#3261) Co-authored-by: Paul Romano --- openmc/plots.py | 3 ++- tests/unit_tests/test_plots.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openmc/plots.py b/openmc/plots.py index 7532d9d5cb..2bb3ef65f4 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -250,9 +250,10 @@ def voxel_to_vtk(voxel_file: PathLike, output: PathLike = 'plot.vti'): writer.SetInputData(grid) else: writer.SetInput(grid) + output = str(output) if not output.endswith(".vti"): output += ".vti" - writer.SetFileName(str(output)) + writer.SetFileName(output) writer.Write() return output diff --git a/tests/unit_tests/test_plots.py b/tests/unit_tests/test_plots.py index a1e15016a2..4efc12c932 100644 --- a/tests/unit_tests/test_plots.py +++ b/tests/unit_tests/test_plots.py @@ -90,7 +90,7 @@ def test_voxel_plot(run_in_tmpdir): assert Path('test_voxel_plot.vti').is_file() vox_plot.filename = 'h5_voxel_plot' - vox_plot.to_vtk('another_test_voxel_plot.vti') + vox_plot.to_vtk(Path('another_test_voxel_plot.vti')) assert Path('h5_voxel_plot.h5').is_file() assert Path('another_test_voxel_plot.vti').is_file()