From 256a0bad0749831a29fd8f94a0b4bc9e1e254471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 3 Nov 2013 09:55:06 +0100 Subject: [PATCH] Fix montage2d doctest --- skimage/util/montage.py | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/skimage/util/montage.py b/skimage/util/montage.py index 805b78a8..4bc6aca8 100644 --- a/skimage/util/montage.py +++ b/skimage/util/montage.py @@ -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