Skip to content

Commit 56d7c8b

Browse files
committed
Make type hints more backward compatible.
1 parent 77b6346 commit 56d7c8b

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

velociraptor/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,14 @@
3030
from velociraptor.catalogue.catalogue import VelociraptorCatalogue
3131
from velociraptor.__version__ import __version__
3232

33-
try:
34-
from types import EllipsisType # python3.10+
35-
except ImportError:
36-
from typing import Any as EllipsisType # better choice for this?
3733
from typing import Union
38-
from numpy.typing import NDArray
3934

4035

4136
def load(
4237
filename: str,
4338
disregard_units: bool = False,
4439
registration_file_path: Union[str, None] = None,
45-
mask: Union[EllipsisType, NDArray[bool], int] = Ellipsis
40+
mask: slice = Ellipsis
4641
) -> VelociraptorCatalogue:
4742
"""
4843
Loads a velociraptor catalogue, producing a VelociraptorCatalogue

velociraptor/catalogue/catalogue.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import numpy as np
1111

1212
from typing import Union, Callable, List, Dict
13-
from numpy.typing import NDArray
14-
# from types import EllipsisType # requires python 3.10+
15-
import builtins # use 'builtins.ellipsis' instead
1613

1714
from velociraptor.units import VelociraptorUnits
1815
from velociraptor.catalogue.derived import DerivedQuantities
@@ -171,7 +168,7 @@ def generate_sub_catalogue(
171168
registration_function: Callable,
172169
units: VelociraptorUnits,
173170
field_metadata: List[VelociraptorFieldMetadata],
174-
mask: Union['builtins.ellipsis', NDArray[bool], int] = Ellipsis
171+
mask: slice = Ellipsis
175172
):
176173
"""
177174
Generates a sub-catalogue object with the correct properties set.
@@ -262,7 +259,7 @@ def __init__(
262259
filename: str,
263260
disregard_units: bool = False,
264261
extra_registration_functions: Union[None, Dict[str, Callable]] = None,
265-
mask: Union['builtins.ellipsis', NDArray[bool], int] = Ellipsis,
262+
mask: slice = Ellipsis,
266263
):
267264
"""
268265
Initialise the velociraptor catalogue with all of the available
@@ -290,7 +287,7 @@ def __init__(
290287
conform to the registration function API. This is an advanced
291288
feature.
292289
293-
mask: Union['builtins.ellipsis', NDArray[bool], int], optional
290+
mask: slice, optional
294291
If a boolean array is provided, it is used to mask all catalogue
295292
arrays. If an int is provided, catalogue arrays are masked to the
296293
single corresponding element. Default: Ellipsis (``...``).

0 commit comments

Comments
 (0)