Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mass table initialisation #206

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading