[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63515] logical should convert char and string
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #63515] logical should convert char and strings instead of throwing an error for Matlab compatibility |
Date: |
Wed, 11 Jan 2023 16:16:21 -0500 (EST) |
Follow-up Comment #7, bug #63515 (project octave):
There are only two instances in libinterp that I can find:
operators/op-bm-b.cc:82: boolNDArray v2 = a2.bool_array_value (true);
operators/op-bm-bm.cc:123: boolNDArray v2 = a2.bool_array_value (true);
If I look at the code in op-bm-b.cc I find
static octave_value
oct_assignop_conv_and_assign (octave_base_value& a1,
const octave_value_list& idx,
const octave_base_value& a2)
{
octave_bool_matrix& v1 = dynamic_cast<octave_bool_matrix&> (a1);
// FIXME: perhaps add a warning for this conversion
// if the values are not all 0 or 1?
boolNDArray v2 = a2.bool_array_value (true);
v1.assign (idx, v2);
return octave_value ();
}
There is a FIXME note about warning if the conversion was from an array like
you mentioned such as [1, 1, 2, 3]. However, these files are for operator
functions that are only called when both objects are already logical values
(either bool matrix or bool). So, any testing on conversion from octave_value
to a strongly typed bool class won't result in anything and is wasted effort.
Or, I should say I think this is the correct interpretation of these bits of
code.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63515>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/