octave-maintainers
[Top][All Lists]
Advanced

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

Re: turning "Octave:broadcast" warning off by default


From: Carnë Draug
Subject: Re: turning "Octave:broadcast" warning off by default
Date: Fri, 20 Feb 2015 23:36:35 +0000

On 19 February 2015 at 18:07, Olaf Till <address@hidden> wrote:
> On Thu, Feb 19, 2015 at 12:57:58PM +0000, Carnë Draug wrote:
>> On 19 February 2015 at 12:36, Moreno Marzolla
>> <address@hidden> wrote:
>> > On 19/02/2015 11:59, Carnë Draug wrote:
>> >>
>> >> Hi
>> >>
>> >> automatic broadcast was introduced in 3.6 and at the time we enabled
>> >> warnings by default because it was very new.  This is not true anymore.
>> >> Should we turn it off by default for 4.0?
>> >
>> >
>> > Will the "Octave:broadcast" warning ID be still available?
>>
>> Yes.
>>
>> > I am not very
>> > good at keeping track whether long expressions return a row or column
>> > vector, so automatic broadcasting introduced problems
>
> Similarly to this, I had the impression that it's easy to trigger
> broadcasting inadvertently. Maybe the warning should be left on by
> default for this reason.

My experience when I accidentally trigger broadcasting, is that the code
nevers goes too far after it.  After all, suddenly there's an extra
dimension which will usually breaks the rest of the code.

> Are you sure the warning was only there
> because broadcasting was new?

That was my impression, yes. Why else would we throw warnings for using valid
syntax?


On 19 February 2015 at 18:49, Juan Pablo Carbajal <address@hidden> wrote:
> On Thu, Feb 19, 2015 at 7:30 PM, Nir Krakauer <address@hidden> wrote:
>> I'd prefer having the warning turned off by default.
>
> People that come from matlab to use Octave need to know if they are
> unexpectedly triggering broadcasting. This is one of the reasons for
> the warning to be there. For these people, it is indeed a "thing that
> is wrong". In this way we avoid complaints form new matlab-trained
> user.
>
> For Octvae users, used to broadcasting, it is a minor effort to add
> warning("off","Octave:broadcast");
> in their .octaverc files
>

The problem is not the trouble of adding 'warning("off","Octave:broadcast")'
to my own octaverc.

The problem is requiring every developer to add it to all the function he
writes.  We are not talking about something questionable such as converting
numbers to string, or add/minus 32 to change case (which by the way, does
not issue warning by default)

    octave-cli-3.8.2> char ("word" - 32)
    ans = WORD

we are talking about a very valid Octave syntax and it's ridiculous having
to declare its use beforehand.  It either is a valid and recommended syntax,
in which case we can use it and does not print warnings, or it is not, in
which case we just go back to calling bsxfun.

> For people, like me, who are force to share code with matlab users,
> the warning is not completely useless (I activate it locally for that
> code) in case they inadvertently used the coolest syntax.

We also do not issue warnings to "++", "--", "+=", and double quotes by
default.  Why should broadcasting be any different?


On 19 February 2015 at 21:03, Philip Nienhuis <address@hidden> wrote:
> Jordi Gutiérrez Hermoso wrote:
>>
>> On Thu, 2015-02-19 at 19:57 +0100, Philip Nienhuis wrote:
>>>
>>> IIRC the warning is also there because Octave strives for Matlab
>>> compatibility. Automatic broadcasting isn't ML-compatible AFAIK.
>>
>>
>> I always take "Matlab-compatible" to mean, "if it works in Matlab, it
>> works in
>> Octave". I don't usually take it to mean "if it breaks in Matlab it
>> must also break in Octave".
>
> If Matlab code gets run in Octave and then is subject to automatic
> broadcasting, it may "work" (in the sense of "runs w/o error messages) but
> there's no guarantee it'll yield the same (correct or not) results as in
> Matlab. Right?

No, wrong.  It will return exactly the same results as Matlab.  Unless you
count throwing an error as a "result".  If the function in Matlab works
with the input you give it, then there is no automatic broadcasting done.

Automatic broadcast only happens in cases that in Matlab would cause an
error.  If the code works in Matlab, then it works the same way in Octave.


----


The only reason I see are "this caused an error in Matlab, why does Octave
not complain?"  The reason is simply that it is valid Octave syntax.
Matlab will also throw errors for not using line continuation.  We do not,
and why should we?  It is valid syntax.  Similarly, automatic brodcasting is
Octave syntax so why are we throwing them?

It is all fine if the users do not want to use that syntax and enable
warnings for them.  But it is not fine, if that will affect how developers
write their code.  We do not start all our functions with:

    warning ("off", "Octave:matlab-incompatible", "local");

so why do we need to do it for broadcasting?

Carnë



reply via email to

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