bugGNU Octave - Bugs: bug #64287, Calling colormap after colorbar...

 
 

bug #64287: Calling colormap after colorbar causes error

Submitter:  Arun Giridhar <arungiridhar>
Submitted:  Fri 09 Jun 2023 12:23:26 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * stable Operating System:  * Any
Fixed Release:  8.3.0 Planned Release:  8.3.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 11 Jun 2023 11:12:06 PM UTC, comment #7: 

I tagged the BIST test with this bug number so that if it ever starts to fail again we can re-visit this report.  See http://hg.savannah.gnu.org/hgweb/octave/rev/abf64c84fe66.

Rik <rik5>
Group administrator
Sun 11 Jun 2023 12:09:19 PM UTC, comment #6: 

Done: https://hg.savannah.gnu.org/hgweb/octave/rev/13a2062926b6

It took some experimenting but it finally passes with an empty second argument and fails with a non-existent variable as an argument.

Closing as Fixed but it can be reopened if necessary.

Arun Giridhar <arungiridhar>
Group Member
Sun 11 Jun 2023 12:03:23 AM UTC, comment #5: 

I'm away from a PC for another week or so (typing on a phone screen currently). So, I can't run tests myself.
Do I understand correctly that the error is thrown from inside a callback function? In that case, something like you are proposing might be the only way to "catch" that error.

Markus Mützel <mmuetzel>
Group administrator
Sat 10 Jun 2023 01:28:35 PM UTC, comment #4: 

This works properly, but it looks complicated. Is there a simpler way?


%!test
%! lasterror ("reset");
%! unwind_protect
%!   hf = figure ("visible", "off");
%!   imagesc (reshape (1:100, 10, 10));
%!   colorbar;
%!   colormap (flip (gray (32)));
%!   colorbar;
%! unwind_protect_cleanup
%!   close (hf);
%! end_unwind_protect
%! assert (isempty (lasterr))


Gives:


octave:1> test colorbar
error: 'd' undefined near line 491, column 21
error: called from
    colorbar>cb_colormap at line 491 column 7
    colormap at line 133 column 10
    __test__ at line 8 column 4
    test at line 682 column 11
***** test
 lasterror ("reset");
 unwind_protect
   hf = figure ("visible", "off");
   imagesc (reshape (1:100, 10, 10));
   colorbar;
   colormap (flip (gray (32)));
   colorbar;
 unwind_protect_cleanup
   close (hf);
 end_unwind_protect
 assert (isempty (lasterr))
!!!!! test failed
assert (isempty (lasterr)) failed


Arun Giridhar <arungiridhar>
Group Member
Sat 10 Jun 2023 01:21:48 PM UTC, comment #3: 

I've not written a BIST for a graphics function before. Here is an attempt:


%!test
%! hf = figure ("visible", "off");
%! try
%!   imagesc (reshape (1:100, 10, 10));
%!   colorbar;
%!   colormap (flip (gray (32)));
%!   colorbar;
%! catch
%!   assert (false);
%! end_try_catch
%! close (hf);


The hope was that the "undefined variable" error would cause the catch section to be executed, which would cause an assertion failure, but testing it still says all tests passed even after giving the error:


octave:1> test colorbar
error: 'd' undefined near line 491, column 21
error: called from
    colorbar>cb_colormap at line 491 column 7
    colormap at line 133 column 10
    __test__ at line 7 column 4
    test at line 682 column 11
PASSES 8 out of 8 tests


How to change that?

Arun Giridhar <arungiridhar>
Group Member
Sat 10 Jun 2023 12:17:39 PM UTC, comment #2: 

Thanks for the quick fix.

Do you think it would make sense to add a BIST that ensures that this post of the code won't break again in the future? Maybe (a variation of) the motivating example on Discourse?

Markus Mützel <mmuetzel>
Group administrator
Fri 09 Jun 2023 12:29:13 AM UTC, comment #1: 

Patched with: https://hg.savannah.gnu.org/hgweb/octave/rev/d617fca340fc

Marking as ready for test.

Arun Giridhar <arungiridhar>
Group Member
Fri 09 Jun 2023 12:23:26 AM UTC, original submission:  

Calling colorbar and then changing the size of the colormap causes an "undefined variable d" error inside colorbar. See https://octave.discourse.group/t/colorbar-error-from-colormap/4591 for details.

This is to get a bug number for the fix, which I'll push next.

Arun Giridhar <arungiridhar>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by arungiridhar (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-06-11 arungiridhar StatusReady For Test Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 8.3.0
    2023-06-09 arungiridhar StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.13-5190.
    Corresponding source code