mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-24 13:20:43 +08:00
Fix montage2d doctest
This commit is contained in:
+22
-21
@@ -51,31 +51,32 @@ def montage2d(arr_in, fill='mean', rescale_intensity=False, grid_shape=None):
|
||||
>>> import numpy as np
|
||||
>>> from skimage.util.montage import montage2d
|
||||
>>> arr_in = np.arange(3 * 2 * 2).reshape(3, 2, 2)
|
||||
>>> print(arr_in) # doctest: +NORMALIZE_WHITESPACE
|
||||
[[[ 0 1]
|
||||
[ 2 3]]
|
||||
[[ 4 5]
|
||||
[ 6 7]]
|
||||
[[ 8 9]
|
||||
[10 11]]]
|
||||
>>> arr_in # doctest: +NORMALIZE_WHITESPACE
|
||||
array([[[ 0, 1],
|
||||
[ 2, 3]],
|
||||
[[ 4, 5],
|
||||
[ 6, 7]],
|
||||
[[ 8, 9],
|
||||
[10, 11]]])
|
||||
>>> arr_out = montage2d(arr_in)
|
||||
>>> print(arr_out.shape)
|
||||
>>> arr_out.shape
|
||||
(4, 4)
|
||||
>>> print(arr_out)
|
||||
[[ 0. 1. 4. 5. ]
|
||||
[ 2. 3. 6. 7. ]
|
||||
[ 8. 9. 5.5 5.5]
|
||||
[ 10. 11. 5.5 5.5]]
|
||||
>>> print(arr_in.mean())
|
||||
>>> arr_out
|
||||
array([[ 0. , 1. , 4. , 5. ],
|
||||
[ 2. , 3. , 6. , 7. ],
|
||||
[ 8. , 9. , 5.5, 5.5],
|
||||
[ 10. , 11. , 5.5, 5.5]])
|
||||
>>> arr_in.mean()
|
||||
5.5
|
||||
>>> arr_out_nonsquare = montage2d(arr_in, grid_shape=(3, 4))
|
||||
>>> print(arr_out_nonsquare)
|
||||
[[ 0. 1. 4. 5. ]
|
||||
[ 2. 3. 6. 7. ]
|
||||
[ 8. 9. 10. 11. ]]
|
||||
>>> print(arr_out_nonsquare.shape)
|
||||
(3, 4)
|
||||
>>> arr_out_nonsquare = montage2d(arr_in, grid_shape=(1, 3))
|
||||
>>> arr_out_nonsquare
|
||||
array([[ 0., 1., 4., 5., 8., 9.],
|
||||
[ 2., 3., 6., 7., 10., 11.]])
|
||||
>>> arr_out_nonsquare.shape
|
||||
(2, 6)
|
||||
|
||||
"""
|
||||
|
||||
assert arr_in.ndim == 3
|
||||
|
||||
n_images, height, width = arr_in.shape
|
||||
|
||||
Reference in New Issue
Block a user