diff --git a/swiftsimio/metadata/objects.py b/swiftsimio/metadata/objects.py index b47a7938..db0cdcec 100644 --- a/swiftsimio/metadata/objects.py +++ b/swiftsimio/metadata/objects.py @@ -377,7 +377,9 @@ def __init__(self, base_mass_table: np.array, mass_units: unyt.unyt_quantity): # TODO: Extract these names from the files themselves if possible. - for index, name in metadata.particle_types.particle_name_underscores.items(): + for index, name in enumerate( + metadata.particle_types.particle_name_underscores.values() + ): try: setattr( self, diff --git a/tests/test_data.py b/tests/test_data.py index 1cc32d3e..232864d2 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -12,7 +12,7 @@ import h5py -from unyt import K +from unyt import K, Msun from numpy import logical_and, isclose, float64 from numpy import array as numpy_array @@ -53,8 +53,8 @@ def test_time_metadata(filename): @requires("cosmological_volume.hdf5") def test_temperature_units(filename): """ - This tests checks if we correctly read in temperature units. Based on a past bug, to make - sure we never break this again. + This tests checks if we correctly read in temperature units. Based + on a past bug, to make sure we never break this again. """ data = load(filename) @@ -63,6 +63,19 @@ def test_temperature_units(filename): return +@requires("cosmological_volume.hdf5") +def test_initial_mass_table(filename): + """ + This tests checks if we correctly read in the initial mass table. Based + on a past bug, to make sure we never break this again. + """ + + data = load(filename) + data.metadata.initial_mass_table.gas.convert_to_units(Msun) + + return + + @requires("cosmological_volume.hdf5") def test_units(filename): """