From abd4ed586893f840aa41ef0b8bdc304736e54c20 Mon Sep 17 00:00:00 2001 From: robjmcgibbon Date: Tue, 8 Oct 2024 12:24:08 +0200 Subject: [PATCH 1/3] Update mass table initialisation --- swiftsimio/metadata/objects.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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, From a7290f87ab83ee4db6e7ea7f7595c842a1efe0f9 Mon Sep 17 00:00:00 2001 From: robjmcgibbon Date: Tue, 8 Oct 2024 12:48:03 +0200 Subject: [PATCH 2/3] Add test --- tests/test_data.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index 1cc32d3e..c6ce8055 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) @@ -62,6 +62,18 @@ 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): From a7a341d530ed8b660497595c1718492b76eeae9f Mon Sep 17 00:00:00 2001 From: robjmcgibbon Date: Tue, 8 Oct 2024 12:50:57 +0200 Subject: [PATCH 3/3] Format --- tests/test_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_data.py b/tests/test_data.py index c6ce8055..232864d2 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -62,6 +62,7 @@ def test_temperature_units(filename): return + @requires("cosmological_volume.hdf5") def test_initial_mass_table(filename): """