Skip to content

Commit 53ce902

Browse files
committed
ENH: Use Numpy bridge with array of dimension 1
Allow the use of the function GetImageFromArray with arrays of dimension 1. The previous assert prevented the use of the Numpy bridge for the dimension 1 even if this dimension was wrapped.
1 parent 7900a8b commit 53ce902

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/Bridge/NumPy/wrapping/PyBuffer.i.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
if not HAVE_NUMPY:
8282
raise ImportError('Numpy not available.')
8383

84-
assert ndarr.ndim in ( 2, 3, 4 ), \
85-
"Only arrays of 2, 3 or 4 dimensions are supported."
84+
assert ndarr.ndim in ( 1, 2, 3, 4 ), \
85+
"Only arrays of 1, 2, 3 or 4 dimensions are supported."
8686
if not ndarr.flags['C_CONTIGUOUS'] and not ndarr.flags['F_CONTIGUOUS']:
8787
ndarr = np.ascontiguousarray(ndarr)
8888

@@ -91,7 +91,7 @@
9191
imgview = itkPyBuffer@PyBufferTypes@._GetImageViewFromArray( ndarr, ndarr.shape[-2::-1], ndarr.shape[-1] )
9292
else:
9393
imgview = itkPyBuffer@PyBufferTypes@._GetImageViewFromArray( ndarr, ndarr.shape[-1:0:-1], ndarr.shape[0] )
94-
elif ndarr.ndim in ( 2, 3 ):
94+
elif ndarr.ndim in ( 1, 2, 3 ):
9595
imgview = itkPyBuffer@PyBufferTypes@._GetImageViewFromArray( ndarr, ndarr.shape[::-1], 1)
9696

9797
# Keep a reference

0 commit comments

Comments
 (0)