octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63181] Empty logical array with []


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #63181] Empty logical array with []
Date: Sat, 8 Oct 2022 10:07:42 -0400 (EDT)

Follow-up Comment #3, bug #63181 (project octave):

I'm finding odd comments in Octave's source. E.g. in data.cc, the comments
with this test:

/*
## Tests for bug #47298
## Matlab requires the size to be a row vector.  In that logic, it supports
## n to be a 1x0 vector (returns 0x0) but not a 0x1 vector.  Octave supports
## any vector and therefore must support 0x1, 1x0, and 0x0x1 (but not 0x1x1).
%!test <*47298>
%! fcns = {@zeros, @ones, @inf, @nan, @NA, @i, @pi, @e};
%! for idx = 1:numel (fcns)
%!   fcn = fcns{idx};
%!   assert (fcn (zeros (1, 0)), zeros (0, 0));
%!   assert (fcn (zeros (0, 1)), zeros (0, 0));
%!   assert (fcn (zeros (0, 1, 1)), zeros (0, 0));
%!   fail ([func2str(fcn) " ([])"]);
%!   fail ([func2str(fcn) " (zeros (0, 0, 1))"]);
%! endfor
*/


I'd understand the comment to list that a 0x1x1 input would not work. But
since trailing singleton dimensions don't matter, how is that different from a
0x1 input (which is listed as supported)? And indeed, one of the tests checks
that input with those dimensions *does* work...

Additionally in utils.cc:

  void get_dimensions (const octave_value& a, const char *warn_for,
                       dim_vector& dim)
  {
    // 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 ().isvector ())
      error ("%s (A): use %s (size (A)) instead", warn_for, warn_for);


Here some examples are listed that are supposedly passing. But
`dim_vector::isvector` is only returning `true` for *non-empty* "real" vectors
along the first or second dimension.

Which is wrong? The comments or the implemented behavior?



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63181>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]