changeset 983:15371ff780a0

image-tiling - better error reporting
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 23 Aug 2010 16:06:23 -0400
parents 3463c1761a94
children 5badf36a6daf
files pylearn/io/image_tiling.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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[