Skip to content

Commit 7e03807

Browse files
committed
ENH: Add ndim to ArrayProxy protocol
1 parent 7877add commit 7e03807

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

nibabel/arrayproxy.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ def header(self):
232232
def shape(self):
233233
return self._shape
234234

235+
@property
236+
def ndim(self):
237+
return len(self.shape)
238+
235239
@property
236240
def dtype(self):
237241
return self._dtype

nibabel/ecat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,10 @@ def __init__(self, subheader):
680680
def shape(self):
681681
return self._shape
682682

683+
@property
684+
def ndim(self):
685+
return len(self.shape)
686+
683687
@property
684688
def is_proxy(self):
685689
return True

nibabel/minc1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ def __init__(self, minc_file):
252252
def shape(self):
253253
return self._shape
254254

255+
@property
256+
def ndim(self):
257+
return len(self.shape)
258+
255259
@property
256260
def is_proxy(self):
257261
return True

nibabel/parrec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ def __init__(self, file_like, header, mmap=True, scaling='dv'):
622622
def shape(self):
623623
return self._shape
624624

625+
@property
626+
def ndim(self):
627+
return len(self.shape)
628+
625629
@property
626630
def dtype(self):
627631
return self._dtype

0 commit comments

Comments
 (0)