mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 17:05:57 +08:00
make doctests pass with nose
This commit is contained in:
+16
-11
@@ -28,7 +28,7 @@ def block_view(arr, block):
|
||||
Examples
|
||||
--------
|
||||
>>> import numpy as np
|
||||
>>> import block_view
|
||||
>>> from skimage.util.array_views import block_view
|
||||
>>> A = np.arange(4*4).reshape(4,4)
|
||||
>>> A
|
||||
array([[ 0, 1, 2, 3],
|
||||
@@ -47,28 +47,29 @@ def block_view(arr, block):
|
||||
[ 6, 7, 8, 9, 10, 11],
|
||||
[12, 13, 14, 15, 16, 17],
|
||||
[18, 19, 20, 21, 22, 23]],
|
||||
|
||||
<BLANKLINE>
|
||||
[[24, 25, 26, 27, 28, 29],
|
||||
[30, 31, 32, 33, 34, 35],
|
||||
[36, 37, 38, 39, 40, 41],
|
||||
[42, 43, 44, 45, 46, 47]],
|
||||
|
||||
<BLANKLINE>
|
||||
[[48, 49, 50, 51, 52, 53],
|
||||
[54, 55, 56, 57, 58, 59],
|
||||
[60, 61, 62, 63, 64, 65],
|
||||
[66, 67, 68, 69, 70, 71]],
|
||||
|
||||
<BLANKLINE>
|
||||
[[72, 73, 74, 75, 76, 77],
|
||||
[78, 79, 80, 81, 82, 83],
|
||||
[84, 85, 86, 87, 88, 89],
|
||||
[90, 91, 92, 93, 94, 95]]])
|
||||
>>> B = block_view(A, block=(1,2,2))
|
||||
>>> B.shape
|
||||
>>> (4, 2, 3, 1, 2, 2)
|
||||
(4, 2, 3, 1, 2, 2)
|
||||
>>> B[2:, 0, 2]
|
||||
array([[[[52, 53],
|
||||
[58, 59]]],
|
||||
|
||||
<BLANKLINE>
|
||||
<BLANKLINE>
|
||||
[[[76, 77],
|
||||
[82, 83]]]])
|
||||
"""
|
||||
@@ -87,6 +88,8 @@ def block_view(arr, block):
|
||||
if block_shape.size < arr.ndim:
|
||||
raise ValueError('block ndim smaller than input array ndim')
|
||||
|
||||
arr = np.ascontiguousarray(arr)
|
||||
|
||||
# -- checking that the block view is compatible
|
||||
# with the shape of the input array
|
||||
A_shape = np.array(arr.shape).astype(np.int)
|
||||
@@ -147,7 +150,7 @@ def rolling_view(arr, window):
|
||||
Examples
|
||||
--------
|
||||
>>> import numpy as np
|
||||
>>> import rolling_view
|
||||
>>> from skimage.util.array_views import rolling_view
|
||||
>>> A = np.arange(10)
|
||||
>>> A
|
||||
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
@@ -180,18 +183,18 @@ def rolling_view(arr, window):
|
||||
[ 4, 5, 6],
|
||||
[ 8, 9, 10],
|
||||
[12, 13, 14]],
|
||||
|
||||
<BLANKLINE>
|
||||
[[ 1, 2, 3],
|
||||
[ 5, 6, 7],
|
||||
[ 9, 10, 11],
|
||||
[13, 14, 15]]],
|
||||
|
||||
|
||||
<BLANKLINE>
|
||||
<BLANKLINE>
|
||||
[[[ 4, 5, 6],
|
||||
[ 8, 9, 10],
|
||||
[12, 13, 14],
|
||||
[16, 17, 18]],
|
||||
|
||||
<BLANKLINE>
|
||||
[[ 5, 6, 7],
|
||||
[ 9, 10, 11],
|
||||
[13, 14, 15],
|
||||
@@ -206,6 +209,8 @@ def rolling_view(arr, window):
|
||||
if not (len(window) == arr.ndim):
|
||||
raise ValueError('array dimension and window length dont match')
|
||||
|
||||
arr = np.ascontiguousarray(arr)
|
||||
|
||||
# -- defining some variables
|
||||
arr_shape = np.array(arr.shape)
|
||||
window_shape = np.array(window, dtype=arr_shape.dtype)
|
||||
|
||||
Reference in New Issue
Block a user