# HG changeset patch # User John W. Eaton # Date 1232049529 18000 # Node ID 17e0ad741fac363cfe72d8b0290a6e9bc379f4e7 # Parent bf6befcfa70add2114d72d5bad62b6cccd6f0ef2 reshape: improve error message diff --git a/liboctave/Array.cc b/liboctave/Array.cc --- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -442,7 +442,9 @@ if (dimensions.numel () == new_dims.numel ()) retval = Array (*this, new_dims); else - (*current_liboctave_error_handler) ("reshape: size mismatch"); + (*current_liboctave_error_handler) + ("reshape: size mismatch (%s != %s)", dimensions.str (), + new_dims.str ()); } else retval = *this; diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2009-01-15 John W. Eaton + + * Sparse.cc (Sparse::reshape): Include mismatched dimensions in + error message. + * Array.cc (Array::reshape): Likewise. + From Robert Millan . + 2009-01-14 Jaroslav Hajek * Array.h (Array::rep, Array::dimensions): Make protected. diff --git a/liboctave/Sparse.cc b/liboctave/Sparse.cc --- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -796,7 +796,9 @@ retval.xcidx(k+1) = new_nnz; } else - (*current_liboctave_error_handler) ("reshape: size mismatch"); + (*current_liboctave_error_handler) + ("reshape: size mismatch (%s != %s)", dimensions.str (), + new_dims.str ()); } else retval = *this; diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-01-15 John W. Eaton + + * data.cc (Freshape): Include mismatched dimensions in error message. + From Robert Millan . + 2009-01-14 Jaroslav Hajek * ov.cc (octave_value::maybe_economize): New method. diff --git a/src/data.cc b/src/data.cc --- a/src/data.cc +++ b/src/data.cc @@ -4537,10 +4537,12 @@ octave_value arg = args(0); - if (new_dims.numel () == arg.numel ()) - retval = (new_dims == arg.dims ()) ? arg : arg.reshape (new_dims); + dim_vector dims = arg.dims (); + + if (new_dims.numel () == dims.numel ()) + retval = (new_dims == dims) ? arg : arg.reshape (new_dims); else - error ("reshape: size mismatch"); + error ("reshape: size mismatch (%s != %s)", dims.str (), new_dims.str ()); return retval; }