File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 25
25
26
26
See :mod:`nibabel.tests.test_proxy_api` for proxy API conformance checks.
27
27
"""
28
+ from __future__ import annotations
29
+
30
+ import typing as ty
28
31
import warnings
29
32
from contextlib import contextmanager
30
33
from threading import RLock
31
34
32
35
import numpy as np
36
+ import numpy .typing as npt
33
37
34
38
from . import openers
35
39
from .fileslice import canonical_slicers , fileslice
53
57
KEEP_FILE_OPEN_DEFAULT = False
54
58
55
59
56
- class ArrayProxy :
60
+ class ArrayLike (ty .Protocol ):
61
+ """Protocol for numpy ndarray-like objects
62
+
63
+ This is more stringent than :class:`numpy.typing.ArrayLike`, but guarantees
64
+ access to shape, ndim and slicing.
65
+ """
66
+
67
+ shape : tuple [int , ...]
68
+ ndim : int
69
+
70
+ def __array__ (self , dtype : npt .DTypeLike | None = None , / ) -> npt .NDArray :
71
+ ...
72
+
73
+ def __getitem__ (self , key , / ) -> npt .NDArray :
74
+ ...
75
+
76
+
77
+ class ArrayProxy (ArrayLike ):
57
78
"""Class to act as proxy for the array that can be read from a file
58
79
59
80
The array proxy allows us to freeze the passed fileobj and header such that
You can’t perform that action at this time.
0 commit comments