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 2525
2626See :mod:`nibabel.tests.test_proxy_api` for proxy API conformance checks. 
2727""" 
28+ from  __future__ import  annotations 
29+ 
30+ import  typing  as  ty 
2831import  warnings 
2932from  contextlib  import  contextmanager 
3033from  threading  import  RLock 
3134
3235import  numpy  as  np 
36+ import  numpy .typing  as  npt 
3337
3438from  . import  openers 
3539from  .fileslice  import  canonical_slicers , fileslice 
5357KEEP_FILE_OPEN_DEFAULT  =  False 
5458
5559
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 ):
5778    """Class to act as proxy for the array that can be read from a file 
5879
5980    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