Skip to content

Commit

Permalink
Update plots.py for PathLike to string handling error (#3261)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Romano <[email protected]>
  • Loading branch information
jeinstei and paulromano authored Jan 16, 2025
1 parent 32662b4 commit bd874f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion openmc/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit bd874f1

Please sign in to comment.