Skip to content

Commit ba1bea4

Browse files
committed
Test halo accessor
1 parent 0ef1e4d commit ba1bea4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

yt/frontends/rockstar/data_structures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import glob
22
import os
33
from functools import cached_property
4-
from typing import Optional
4+
from typing import List, Optional
55

66
import numpy as np
77

@@ -21,7 +21,7 @@ class RockstarBinaryFile(HaloCatalogFile):
2121
_position_offset: int
2222
_member_offset: int
2323
_Npart: np.array
24-
_ids_halos: list[int]
24+
_ids_halos: List[int]
2525
_file_size: int
2626

2727
def __init__(self, ds, io, filename, file_id, range):

yt/frontends/rockstar/tests/test_outputs.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,23 @@ def test_particle_selection():
3838
ds = data_dir_load(r1)
3939
psc = ParticleSelectionComparison(ds)
4040
psc.run_defaults()
41+
42+
43+
@requires_file(r1)
44+
def test_halo_loading():
45+
ds = data_dir_load(r1)
46+
47+
for halo_id, Npart in zip(
48+
ds.r["halos", "particle_identifier"],
49+
ds.r["halos", "num_p"],
50+
):
51+
halo = ds.halo("halos", halo_id)
52+
assert halo is not None
53+
54+
# Try accessing properties
55+
halo.position
56+
halo.velocity
57+
halo.mass
58+
59+
# Make sure we can access the member particles
60+
assert len(halo.member_ids) == Npart

0 commit comments

Comments
 (0)