Skip to content

Commit

Permalink
Merge pull request #206 from SWIFTSIM/load_mass_table
Browse files Browse the repository at this point in the history
Fix mass table initialisation
  • Loading branch information
JBorrow authored Oct 9, 2024
2 parents b40b144 + a7a341d commit 6e624b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion swiftsimio/metadata/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 16 additions & 3 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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):
"""
Expand Down

0 comments on commit 6e624b3

Please sign in to comment.