From c252930c4990fa71e3f00ec7d3e90dd4df7116d1 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 15 Aug 2022 12:33:24 -0500 Subject: [PATCH] Support passing Path objects to Summary() --- openmc/summary.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openmc/summary.py b/openmc/summary.py index 41bae7f26b..43224334d0 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -14,6 +14,11 @@ _VERSION_SUMMARY = 6 class Summary: """Summary of model used in a simulation. + Parameters + ---------- + filename : str or path-like + Path to file to load + Attributes ---------- date_and_time : str @@ -33,8 +38,9 @@ class Summary: """ def __init__(self, filename): + filename = str(filename) if not filename.endswith(('.h5', '.hdf5')): - msg = 'Unable to open "{0}" which is not an HDF5 summary file' + msg = f'Unable to open "{filename}" which is not an HDF5 summary file' raise ValueError(msg) self._f = h5py.File(filename, 'r')