# HG changeset patch
# User James Bergstra <bergstrj@iro.umontreal.ca>
# Date 1282593983 14400
# Node ID 15371ff780a0f77fefb6257e5908545014ab6d0c
# Parent  3463c1761a942242d0c11735a903a312c832a53a
image-tiling - better error reporting

diff -r 3463c1761a94 -r 15371ff780a0 pylearn/io/image_tiling.py
--- a/pylearn/io/image_tiling.py	Mon May 10 00:27:02 2010 -0400
+++ b/pylearn/io/image_tiling.py	Mon Aug 23 16:06:23 2010 -0400
@@ -87,9 +87,16 @@
             for tile_col in xrange(tile_shape[1]):
                 if tile_row * tile_shape[1] + tile_col < X.shape[0]:
                     if scale_rows_to_unit_interval:
-                        this_img = scale_to_unit_interval(
-                                X[tile_row * tile_shape[1] + tile_col].reshape(img_shape),
-                                eps=min_dynamic_range)
+                        try:
+                            this_img = scale_to_unit_interval(
+                                    X[tile_row * tile_shape[1] + tile_col].reshape(img_shape),
+                                    eps=min_dynamic_range)
+                        except ValueError:
+                            raise ValueError('Failed to reshape array of shape %s to shape %s'
+                                    % (
+                                        X[tile_row*tile_shape[1] + tile_col].shape
+                                        , img_shape
+                                        ))
                     else:
                         this_img = X[tile_row * tile_shape[1] + tile_col].reshape(img_shape)
                     out_array[