Support passing Path objects to Summary()

This commit is contained in:
Paul Romano 2022-08-15 12:33:24 -05:00
parent 28b8f9ecc5
commit c252930c49

View file

@ -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')