Mercurial > octave
changeset 23592:80e3bfb7bd5a
maint: Deprecate is_vector and replace with isvector.
* Array.h (is_vector): Use OCTAVE_DEPRECATED macro around function.
* Array.h (isvector): New function.
* dim-vector.h (is_vector): Use OCTAVE_DEPRECATED macro around function.
* dim-vector.h (isvector): New function.
* idx-vector.h (is_vector): Use OCTAVE_DEPRECATED macro around function.
* idx-vector.h (isvector): New function.
* cellfun.cc, data.cc, dot.cc, filter.cc, utils.cc, ov-class.cc, ov-java.cc,
Array-util.cc, Array-util.h, Array.cc, Range.cc, Sparse.cc, idx-vector.cc,
oct-string.cc: Replace instances of is_vector with isvector.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 13 Jun 2017 20:51:14 -0700 |
parents | a990b6d740c4 |
children | a8361bc2361a |
files | libinterp/corefcn/cellfun.cc libinterp/corefcn/data.cc libinterp/corefcn/dot.cc libinterp/corefcn/filter.cc libinterp/corefcn/utils.cc libinterp/octave-value/ov-class.cc libinterp/octave-value/ov-java.cc liboctave/array/Array-util.cc liboctave/array/Array-util.h liboctave/array/Array.cc liboctave/array/Array.h liboctave/array/Range.cc liboctave/array/Sparse.cc liboctave/array/dim-vector.h liboctave/array/idx-vector.cc liboctave/array/idx-vector.h liboctave/util/oct-string.cc |
diffstat | 17 files changed, 35 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/cellfun.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/corefcn/cellfun.cc Tue Jun 13 20:51:14 2017 -0700 @@ -2197,7 +2197,7 @@ { octave_idx_type n = lb.numel (); Cell retval (1, n); - if (array.is_vector () && (dim == -1 + if (array.isvector () && (dim == -1 || (dim == 0 && array.columns () == 1) || (dim == 1 && array.rows () == 1))) {
--- a/libinterp/corefcn/data.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/corefcn/data.cc Tue Jun 13 20:51:14 2017 -0700 @@ -6780,7 +6780,7 @@ } else { - if (! arg.dims ().is_vector ()) + if (! arg.dims ().isvector ()) error ("issorted: needs a vector"); retval = args(0).issorted (smode) != UNSORTED;
--- a/libinterp/corefcn/dot.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/corefcn/dot.cc Tue Jun 13 20:51:14 2017 -0700 @@ -98,7 +98,7 @@ dim_vector dimx = argx.dims (); dim_vector dimy = argy.dims (); bool match = dimx == dimy; - if (! match && nargin == 2 && dimx.is_vector () && dimy.is_vector ()) + if (! match && nargin == 2 && dimx.isvector () && dimy.isvector ()) { // Change to column vectors. dimx = dimx.redim (1);
--- a/libinterp/corefcn/filter.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/corefcn/filter.cc Tue Jun 13 20:51:14 2017 -0700 @@ -388,7 +388,7 @@ { si = args(3).xfloat_complex_array_value (x_si_errmsg); - if (si.is_vector () && x.is_vector ()) + if (si.isvector () && x.isvector ()) si = si.reshape (dim_vector (si.numel (), 1)); } @@ -423,7 +423,7 @@ { si = args(3).xcomplex_array_value (x_si_errmsg); - if (si.is_vector () && x.is_vector ()) + if (si.isvector () && x.isvector ()) si = si.reshape (dim_vector (si.numel (), 1)); } @@ -461,7 +461,7 @@ { si = args(3).xfloat_array_value (x_si_errmsg); - if (si.is_vector () && x.is_vector ()) + if (si.isvector () && x.isvector ()) si = si.reshape (dim_vector (si.numel (), 1)); } @@ -496,7 +496,7 @@ { si = args(3).xarray_value (x_si_errmsg); - if (si.is_vector () && x.is_vector ()) + if (si.isvector () && x.isvector ()) si = si.reshape (dim_vector (si.numel (), 1)); }
--- a/libinterp/corefcn/utils.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/corefcn/utils.cc Tue Jun 13 20:51:14 2017 -0700 @@ -1147,7 +1147,7 @@ // We support dimensions to be specified by any vector, even if it's a // vector of dimensions 0x1, 1x0, 1x1x0, or 1x1x6. If the vector ends // up being empty, the final dimensions end up being 0x0. - if (! a.dims ().is_vector ()) + if (! a.dims ().isvector ()) error ("%s (A): use %s (size (A)) instead", warn_for, warn_for); const Array<octave_idx_type> v = a.octave_idx_type_vector_value ();
--- a/libinterp/octave-value/ov-class.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/octave-value/ov-class.cc Tue Jun 13 20:51:14 2017 -0700 @@ -304,7 +304,7 @@ octave_value_list lv = octave::feval (meth.function_value (), args, 1); if (lv.length () <= 0 - || ! lv(0).is_matrix_type () || ! lv(0).dims ().is_vector ()) + || ! lv(0).is_matrix_type () || ! lv(0).dims ().isvector ()) error ("@%s/size: invalid return value", class_name ().c_str ()); retval = lv(0).matrix_value ();
--- a/libinterp/octave-value/ov-java.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/libinterp/octave-value/ov-java.cc Tue Jun 13 20:51:14 2017 -0700 @@ -1521,7 +1521,7 @@ jobj = array; jcls = jni_env->GetObjectClass (jobj); } - else if (val.numel () > 1 && val.dims ().is_vector ()) + else if (val.numel () > 1 && val.dims ().isvector ()) { // FIXME: Is there any way to avoid code duplication here without // using a macro?
--- a/liboctave/array/Array-util.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/Array-util.cc Tue Jun 13 20:51:14 2017 -0700 @@ -135,7 +135,7 @@ } bool -is_vector (const dim_vector& dim) +isvector (const dim_vector& dim) { int m = 0; int n = dim.ndims ();
--- a/liboctave/array/Array-util.h Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/Array-util.h Tue Jun 13 20:51:14 2017 -0700 @@ -43,7 +43,7 @@ extern OCTAVE_API bool is_scalar (const dim_vector& dim); -extern OCTAVE_API bool is_vector (const dim_vector& dim); +extern OCTAVE_API bool isvector (const dim_vector& dim); extern OCTAVE_API bool any_ones (const Array<octave_idx_type>& arr);
--- a/liboctave/array/Array.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/Array.cc Tue Jun 13 20:51:14 2017 -0700 @@ -1400,7 +1400,7 @@ octave_idx_type l, u; bool col_vec = ndims () == 2 && columns () == 1 && rows () != 1; - if (i.is_scalar () && i(0) == n-1 && dimensions.is_vector ()) + if (i.is_scalar () && i(0) == n-1 && dimensions.isvector ()) { // Stack "pop" operation. resize1 (n-1);
--- a/liboctave/array/Array.h Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/Array.h Tue Jun 13 20:51:14 2017 -0700 @@ -564,7 +564,11 @@ bool is_empty (void) const { return isempty (); } - bool is_vector (void) const { return dimensions.is_vector (); } + bool isvector (void) const { return dimensions.isvector (); } + + OCTAVE_DEPRECATED ("use 'isvector' instead") + bool is_vector (void) const + { return isvector (); } bool is_nd_vector (void) const { return dimensions.is_nd_vector (); }
--- a/liboctave/array/Range.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/Range.cc Tue Jun 13 20:51:14 2017 -0700 @@ -139,7 +139,7 @@ octave_idx_type il = i.length (n); // taken from Array.cc. - if (n != 1 && rd.is_vector ()) + if (n != 1 && rd.isvector ()) rd = dim_vector (1, il); retval.clear (rd);
--- a/liboctave/array/Sparse.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/Sparse.cc Tue Jun 13 20:51:14 2017 -0700 @@ -1456,7 +1456,7 @@ mx_inline_sub (nz_new, retval.xridx (), ridx () + li, lb); retval.xcidx (1) = nz_new; } - else if (idx.is_permutation (nel) && idx.is_vector ()) + else if (idx.is_permutation (nel) && idx.isvector ()) { if (idx.is_range () && idx.increment () == -1) { @@ -1654,7 +1654,7 @@ } } } - else if (nc == 1 && idx_j.is_colon_equiv (nc) && idx_i.is_vector ()) + else if (nc == 1 && idx_j.is_colon_equiv (nc) && idx_i.isvector ()) { // It's actually vector indexing. The 1D index is specialized for that. retval = index (idx_i); @@ -2157,7 +2157,7 @@ } } - else if (nc == 1 && idx_j.is_colon_equiv (nc) && idx_i.is_vector ()) + else if (nc == 1 && idx_j.is_colon_equiv (nc) && idx_i.isvector ()) { // It's just vector indexing. The 1D assign is specialized for that. assign (idx_i, rhs);
--- a/liboctave/array/dim-vector.h Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/dim-vector.h Tue Jun 13 20:51:14 2017 -0700 @@ -423,11 +423,15 @@ return dim_vector (1, numel ()); } - bool is_vector (void) const + bool isvector (void) const { return (ndims () == 2 && (xelem (0) == 1 || xelem (1) == 1)); } + OCTAVE_DEPRECATED ("use 'isvector' instead") + bool is_vector (void) const + { return isvector (); } + bool is_nd_vector (void) const { int num_non_one = 0;
--- a/liboctave/array/idx-vector.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/idx-vector.cc Tue Jun 13 20:51:14 2017 -0700 @@ -1273,9 +1273,9 @@ } bool -idx_vector::is_vector (void) const +idx_vector::isvector (void) const { - return idx_class () != class_vector || orig_dimensions ().is_vector (); + return idx_class () != class_vector || orig_dimensions ().isvector (); } octave_idx_type
--- a/liboctave/array/idx-vector.h Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/array/idx-vector.h Tue Jun 13 20:51:14 2017 -0700 @@ -1021,7 +1021,11 @@ // necessary to mutate the index. const octave_idx_type * raw (void); - bool is_vector (void) const; + bool isvector (void) const; + + OCTAVE_DEPRECATED ("use 'isvector' instead") + bool is_vector (void) const + { return isvector (); } // FIXME: these are here for compatibility. They should be removed // when no longer in use.
--- a/liboctave/util/oct-string.cc Tue Jun 13 18:36:18 2017 -0400 +++ b/liboctave/util/oct-string.cc Tue Jun 13 20:51:14 2017 -0700 @@ -102,7 +102,7 @@ bool sizes_cmp (const Array<char>& str_a, const char *str_b) { - return (str_a.is_vector () && str_a.rows () == 1 + return (str_a.isvector () && str_a.rows () == 1 && str_a.numel () == strlen<Array<char>> (str_b)); }