Skip to content

Commit

Permalink
Use numpy typing
Browse files Browse the repository at this point in the history
  • Loading branch information
cphyc committed Sep 6, 2023
1 parent 9384474 commit f3f7878
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions yt/frontends/rockstar/data_structures.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import glob
import os
from functools import cached_property
from typing import List, Optional
from typing import Any, List, Optional

import numpy as np

Expand All @@ -20,7 +20,7 @@ class RockstarBinaryFile(HaloCatalogFile):
header: dict
_position_offset: int
_member_offset: int
_Npart: np.array
_Npart: "np.ndarray[Any, np.dtype[np.int64]]"
_ids_halos: List[int]
_file_size: int

Expand All @@ -46,7 +46,9 @@ def __init__(self, ds, io, filename, file_id, range):

super().__init__(ds, io, filename, file_id, range)

def _read_member(self, ihalo: int) -> Optional[np.array]:
def _read_member(
self, ihalo: int
) -> Optional["np.ndarray[Any, np.dtype[np.int64]]"]:
if ihalo not in self._ids_halos:
return None

Expand All @@ -59,7 +61,7 @@ def _read_member(self, ihalo: int) -> Optional[np.array]:
ids = np.fromfile(f, dtype=np.int64, count=self._Npart[ind_halo])
return ids

def _read_particle_positions(self, ptype, f=None):
def _read_particle_positions(self, ptype: str, f=None):
"""
Read all particle positions in this file.
"""
Expand Down

0 comments on commit f3f7878

Please sign in to comment.