[bug #68172] any() and all() should work only on numeric or logical args
Thomas <[email protected]>
| Newsgroups | gmane.comp.gnu.octave.bugs |
|---|---|
| Message-ID | <[email protected]> |
Please use the bug tracker to post updates to a bug report. The mailing list is intended as a read-only notification stream. Info posted to this mailing list address won't appear in the tracker database where it is most useful.
Follow-up Comment #5, bug #68172 (group octave):
Thanks for running the tests Nicholas.
> not familiar with the classdef code, but would it be better to handle this as
> better input validation in any and all rather than within classdef
> overloads?
I didn't change any classdef code specifically, I changed it so that if a type
does not override the `any` and `all` methods in `octave_base_value`, then
`any` and `all` won't work on the aforementioned type. At a high level, this
is essentially saying: if you don't specify explicitly how `any` and `all`
work for a type, then it won't work. Since there is no specified override for
`any` and `all` in `octave_classdef` (the classdef type), it won't work on a
classdef object.
The input validation in `all` just relies on the virtual method call to be
present (same with `any`):
DEFUN (all, args, ,
doc: /* -*- texinfo -*-
{
[...dim and vecdim stuff...]
octave_value retval = arg.all (dim);
[...more dim and vecdim stuff...]
return retval;
}
The problem with a Cell array is that `octave_cell` (in ov-cell.h/cc) inherits
from `octave_base_matrix`, where the latter overrides `any` and `all`.
Technically, only subclasses of `octave_base_matrix` that are one of the data
types that you've posted (in comment #3) should override `any` and `all`.
I've attached a patch that should fix the issue, but it's a little more
involved than I hoped initially. Unlike the first patch, there's a higher
chance of something breaking with this second patch. Going to add some tests
to `data.cc` to make sure I won't cause any regressions, but `make check`
passes at a first glance for me.
(file #58396)
_______________________________________________________
Additional Item Attachment:
Name: bug68172_v2.patch Size: 11KiB
<https://file.savannah.gnu.org/file/bug68172_v2.patch?file_id=58396>
AGPL NOTICE
These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-9b684d621d606340ec3f8b1a290873daf3ff5474.tar.gz
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68172>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCacQZgAAKCRCqLAuaBUf3 TiS2AQCGOEi/g5C0p+qoQfnopL5n3woqBP+EC/wxbgWvgBNuPgEAv+OuyYe9okis ZliyJLPHzJqpk53DwtffumimHwMuLA4= =su54 -----END PGP SIGNATURE-----