bugGNU Octave - Bugs: bug #65010, compatibility: colormaps now...

 
 

bug #65010: compatibility: colormaps now default to 256 colors in matlab

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Mon 11 Dec 2023 02:57:32 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  10.1.0 (current default)
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 03 Jan 2024 05:06:02 AM UTC, comment #15: 

built, passed a check, and subsequently playing with the numbers in graphics.cc or viridis tripped the test, so went ahead and pushed to https://hg.savannah.gnu.org/hgweb/octave/rev/f030e572b715

Nicholas Jankowski <nrjank>
Group Member
Wed 03 Jan 2024 04:20:45 AM UTC, comment #14: 

would the simple test attached sufficiently check the intended feature or is there somewhere else it would be better inserted and/or with more detail?


diff -r ea5158206032 -r f030e572b715 libinterp/corefcn/graphics.cc
--- a/libinterp/corefcn/graphics.cc        Tue Jan 02 17:37:01 2024 -0800
+++ b/libinterp/corefcn/graphics.cc        Tue Jan 02 23:10:12 2024 -0500
@@ -412,6 +412,18 @@
   return cmap;
 }

+/*
+## Test default colormap returns as 256 color viridis
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   hax = axes ("parent", hf);
+%!   assert (get (hax, "colormap"), viridis (256), eps);
+%! unwind_protect_cleanup
+%!   delete (hf);
+%! end_unwind_protect
+*/
+
 static double
 default_screendepth ()
 {


(my slow test machine is rebuilding from scratch now so i haven't verified yet that it would have caught the sombrero issue)


(file #55512)

Nicholas Jankowski <nrjank>
Group Member
Wed 03 Jan 2024 03:32:17 AM UTC, comment #13: 

ahh, makes sense.  missed that and no tests to fail it. I guess we could add one. other than size viridis doesn't have any nice predictable values to compare, but could set then gets this map and checks assert(map, viridis(256))

Nicholas Jankowski <nrjank>
Group Member
Wed 03 Jan 2024 01:40:58 AM UTC, comment #12: 

@Nicholas: I fixed the problem in this changeset https://hg.savannah.gnu.org/hgweb/octave/rev/ea5158206032.

The issue was that you took the colormap values in Octave which are arranged as 256 rows x 3 columns and put those in C++ which expects everything to be formatted like a Fortran vector (that is, the rows are stacked on top of each other.)  I just converted between the two with the '(:)' indexing to form one big column-vector.

Marking bug as Fixed again and closing report.

Rik <rik5>
Group administrator
Tue 02 Jan 2024 10:49:02 PM UTC, comment #11: 

Thanks for catching this.  It is a regression and should be fixed.  Re-opening bug report.

Rik <rik5>
Group administrator
Sun 31 Dec 2023 02:55:50 PM UTC, comment #10: 

I have a comment on this. When I run

sombrero

I get colors like in the attached image. The colors become correct when I additionally run

colormap('default')

Comes with changeset 32647:dfb9b770ae77. Any idea?


Hg200 <hg200>
Tue 26 Dec 2023 09:50:51 PM UTC, comment #9: 

I don't think it's worth the effort to graft the BIST tests over.  We haven't seen any trouble from these functions in a very long time.

Rik <rik5>
Group administrator
Tue 26 Dec 2023 09:28:45 PM UTC, comment #8: 

thanks.  most of the BISTs could probably be grafted onto stable (adjusted back to 64).  worth doing?

Nicholas Jankowski <nrjank>
Group Member
Tue 26 Dec 2023 09:21:32 PM UTC, comment #7: 

I reviewed and the change looks good.  I made one modification which was to remove the BIST test on too many inputs.  See https://hg.savannah.gnu.org/hgweb/octave/rev/8dfe116fb0fe.  The reasoning is that the BIST tests should check what is particular to the m-file they are in, but the test on number of inputs was actually checking the behavior of the interpreter.  I didn't see that we had an explicit test of the interpreter for this behavior so I added some in this changeset https://hg.savannah.gnu.org/hgweb/octave/rev/9f0a15acdaea.

Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Tue 26 Dec 2023 04:32:09 AM UTC, comment #6: 

everything i could find just reused the same published 256 color map we were using.  updated  all of the color map defaults to 256 colors including the graphics.cc map.  pushed to https://hg.savannah.gnu.org/hgweb/octave/rev/dfb9b770ae77
on default. also added BISTs to all of the color maps. probably not comprehensive, but at least checks the current input validation. builds and passes a make check. That should satisfy issues on this report. Marking as ready for test. Will continue input validation improvement over on bug #65011.

Nicholas Jankowski <nrjank>
Group Member
Mon 25 Dec 2023 04:02:33 AM UTC, comment #5: 

nevermind. just realized the viridis/turbo R source is only 256 points. I'll peek around a bit more later to see if there is an algorithm.

Nicholas Jankowski <nrjank>
Group Member
Mon 25 Dec 2023 02:44:11 AM UTC, comment #4: 

thanks for the pointer. about done with this (updated # but also added tests to all the colormap fns.) but noticed in graphics.cc that the values there don't quite match the values produced by  viridis.m.  the graphics.cc version also has higher precision. i assume that's from interpolation, but even the start/end values are a bit different.  both functions express a desire for an algorithmic implementation. I'll at least go peak at the viridis source and try to make them consistent.

Nicholas Jankowski <nrjank>
Group Member
Wed 13 Dec 2023 04:34:29 PM UTC, comment #3: 

You're grepping skills are probably adequate, but the default is hard to find.  See libinterp/corefcn/graphics.cc:140.  There is a coding note to read there, but we can't just call the Octave interpreter to get the viridis colormap, so the values are hardcoded.

Rik <rik5>
Group administrator
Tue 12 Dec 2023 04:20:16 PM UTC, comment #2: 

where is DefaultFigureColormap defined? my grep'ing skills are apparently lacking

Nicholas Jankowski <nrjank>
Group Member
Mon 11 Dec 2023 07:58:10 PM UTC, comment #1: 

This is super easy to change, and I don't see a particular downside to maintaining Matlab compatibility here.  This feature should be announced in the NEWS file as well though because programmers may be using the defaults and it will be changing underneath them.

Rik <rik5>
Group administrator
Mon 11 Dec 2023 02:57:32 PM UTC, original submission:  

as of 2019b, Matlab colormaps use 256 colors as the default rather than the previous 64 (which is currently used by matlab).

e.g., https://www.mathworks.com/help/matlab/ref/spring.html :

"R2019b: Colormaps have 256 colors by default
Starting in R2019b, colormaps have 256 colors by default.

In R2019a and previous releases, the default size is 64."

In most of the colormaps this should involve changing the one line containing the current default value of 64, then adjusting BISTs, docstrings, defaultColorMap, and seeing if anything dependent expected that default size of 64x3.

Nicholas Jankowski <nrjank>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55512:  default_colormap_BIST_bug65010.diff added by nrjank (966B - application/octet-stream)
file #55493:  sombrero.png added by hg200 (63KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by hg200 (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by nrjank (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 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-03 nrjank Attached File- Added default_colormap_BIST_bug65010.diff, #55512
    2024-01-03 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2024-01-02 rik5 StatusFixed Confirmed
        Open/ClosedClosed Open
    2023-12-31 hg200 Attached File- Added sombrero.png, #55493
    2023-12-26 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2023-12-26 nrjank StatusConfirmed Ready For Test
    2023-12-11 rik5 Priority5 - Normal 3 - Low
        StatusNone Confirmed
        Planned ReleaseNone 10.1.0 (current default)

    Back to the top

    Powered by Savane 3.13-04b1.
    Corresponding source code