bugGNU Octave - Bugs: bug #36393, "warning" control syntax...

 
 

bug #36393: "warning" control syntax difference between Matlab and Octave 3.6.1

Submitter:  None
Submitted:  Fri 04 May 2012 10:10:48 AM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Stefan Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 30 Dec 2014 06:23:55 AM UTC, comment #2: 

I checked in the following changeset.

  http://hg.savannah.gnu.org/hgweb/octave/rev/93fbdbcb3349

Thanks for the patch (and sorry that it was ignored for so long) but I chose to solve the problem in a slightly different way by introducing a few new helper functions instead of calling warning recursively.

The test adds new tests including the test from this report.

The behavior appears to be compatible to Matlab now, so I'm closing the report.

John W. Eaton <jwe>
Group administrator
Sun 19 Jan 2014 09:20:38 PM UTC, comment #1: 

Thanks for your bug report and patch. Are you able to test this behavior in 3.8.0 or the development version of Octave? I don't know how much the warning functions have changed since 3.6.1 but it would be best if you could rebase your patch against the current development version.

So it sounds like you're saying if you pass in a struct array to the warning function to set the state of one or more IDs, it should combine it with the current warning state array instead of overwriting it. If the struct passed in is "all", does it clear all identifiers from the warning state array?

Mike Miller <mtmiller>
Group Member
Fri 04 May 2012 10:10:48 AM UTC, original submission:  

Matlab's "warning" command has (apparently undocumented) functionality to update the warning status according to a structure array passed as the first argument. The following code, found for example in ode15s.m, can be used to temporarily switch off particular warnings:


w0 = warning;
warnoffId = 'MATLAB:singularMatrix';
warnstat = warning('query',warnoffId);
warnoff = warnstat;
warnoff.state = 'off';

warning(warnoff); %update warning status
% ... do things without warnings thrown
warning(warnstat); %reset warning status
w = warning;


Note that 'MATLAB:singularMatrix' is not listed explicitly in w0 before setting it to 'off' (i.e., it is handled implicitly under 'all' : 'on').

Behavior in Matlab (R2007b - last version I have for testing): No change of "warning":


>> isequal(w,w0)
ans = 1


Behavior in Octave 3.6.1: "warning" is overwritten completely by warnstat:


octave:2> w0
w0 =

  1x14 struct array containing the fields:

    identifier
    state

octave:3> w
w =

  scalar structure containing the fields:

    identifier: 1x21 sq_string
    state: 1x2 sq_string


This breaks the warning system of Octave, such that virtually every subsequent command spams the console with warning messages.

I attach a function overloading "warning" that outlines a fix for this issue, such that MATLAB code using this functionality runs correctly in Octave.

Note that even with the overloaded "warning" command, the status after the above example is different (but equivalent):


octave:2> isequal(w,w0)
ans = 0


This is due to the fact that even


octave:2> warning('on',ID)


behaves differently in Matlab and Octave. Matlab will just remove ID from the warning structure array, so that ID is handled implicitly under 'all' : 'on', while Octave appends ID to the warning structure, with status 'on', regardless of the state of 'all'.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #25902:  bug_36393.patch added by smueller (4KiB - application/octet-stream - This patch of error.cc fixes bug 36393)
file #25779:  warning.m added by None (271B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by smueller (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-12-30 jwe StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2014-01-19 mtmiller CategoryNone Octave Function
        Severity3 - Normal 1 - Wish
        StatusNone Patch Submitted
        Release3.6.1 dev
        Operating SystemMac OS Any
    2012-05-22 smueller Attached File- Added bug_36393.patch, #25902
    2012-05-04 None Attached File- Added warning.m, #25779

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code