Mercurial > hg > octave-terminal
changeset 8526:17e0ad741fac
reshape: improve error message
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Jan 2009 14:58:49 -0500 |
parents | bf6befcfa70a |
children | 6b074f37e8d7 |
files | liboctave/Array.cc liboctave/ChangeLog liboctave/Sparse.cc src/ChangeLog src/data.cc |
diffstat | 5 files changed, 23 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -442,7 +442,9 @@ if (dimensions.numel () == new_dims.numel ()) retval = Array<T> (*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;
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2009-01-15 John W. Eaton <jwe@octave.org> + + * Sparse.cc (Sparse<T>::reshape): Include mismatched dimensions in + error message. + * Array.cc (Array<T>::reshape): Likewise. + From Robert Millan <rmh@aybabtu.com>. + 2009-01-14 Jaroslav Hajek <highegg@gmail.com> * Array.h (Array<T>::rep, Array<T>::dimensions): Make protected.
--- 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;
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-01-15 John W. Eaton <jwe@octave.org> + + * data.cc (Freshape): Include mismatched dimensions in error message. + From Robert Millan <rmh@aybabtu.com>. + 2009-01-14 Jaroslav Hajek <highegg@gmail.com> * ov.cc (octave_value::maybe_economize): New method.
--- 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; }