bugGNU Octave - Bugs: bug #43017, "text" command does not...

 
 

bug #43017: "text" command does not work with empty matrix to indicate empty line

Submitted by:  Hartmut <hardy>
Submitted on:  Mon 18 Aug 2014 07:47:58 PM UTC  
 
Category: Plotting with OpenGLSeverity: 3 - Normal
Priority: 3 - LowItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.8.2Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 29 Sep 2015 07:50:39 PM UTC, comment #9:

@Harmut: Thanks for the extensive testing. Octave generally likes to think of itself as a superset of Matlab, rather than bug-for-bug compatible. Therefore, it doesn't bother me at all that Octave offers more functionality when it comes to multiple objects and multi-line strings. I changed the FIXME comment to just a NOTE to explain the differnce. Thanks to your testing, which shows Octave is compatible, I deleted the other two FIXME comments. See this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/50bf240978e6).

Rik <rik5>
Project Administrator
Tue 29 Sep 2015 06:54:51 PM UTC, comment #8:

Thanks for the elegant patch, Rik!

Seems that I was a couple of hours too late with my testing, this time. But I HAVE tested your patch, and observed that it fully fixes the topic of this bug. And I couldn't find any harmful sideeffects of this patch either. Now it's pushed to the repository, anyways. So far so good.

But I also stumbled across the three "Fixme, is it Matlab compatible?" comments in the test section of text.m . And I did run those three tests on Matlab, to check for Matlab compatibility. Doing this, I observed several incompatiblities which I will list in the remainder of this post. Maybe you, Rik, could give me some feedback if it's worth posting a seperate bug report about any of those.

But first the details. I run the following script both in Matlab 2013b and in 2014b:

The result in Matlab 2013b was:

The result in Matlab 2014b was:

The result with Octave 4.0.0 with your latest patch (of this bug report) applied is:

From this I have drawn the following conclusions:

  • The second "fixme test" ("Multiple objects with same multi-line string which has empty cell") isn't Matlab compatible at all. I needed to add two numbers to the code, in order to make it work: h = text ([0.7, 0.7, 0.7], [0.3, 0.5, 0.7], {'Line1'; []; 'Line3'}); This means: If you give Matlab a cell array with three entries and only two x-y-coordinates (as does the original test), it will throw an error ("Each string specified must have a corresponding set of coordinates"). Octave currently does NOT throw this error. Instead Octave will plot each text line twice! So Octave is more tolerant, but produces unexpected results. Shall I open a seperate bug report for this? (A)
  • The first "fixme test" produces cell results with Octave. This is the same result as Matlab 2014b. In Matlab 2013b the result was still a char. So I would consider this (currently) Matlab compatible -> OK.
  • The second "fixme test" (corrected, as discussed above) produces cell results with Octave. But both in Matlab 2013b and 2014b it produces character arrays as results. So this is NOT Matlab compatible right now. Shall I open a seperate bug report for this? (B)
  • The third "fixme test" produces character array as result, in Octave as well as in Matlab 2013b and 2014b. So this test is fully Matlab compatible right now. This means you could remove the comment "## FIXME: is return value really char in Matlab?" in the current source code of this Octave test. (C)

Let me know if you think it's useful to open a new bug report for any of the two real incompatiblities (A or B) listed above. If you like to, go ahead and just remove the fixme comment in the third test (C).

Hartmut <hardy>
Tue 29 Sep 2015 01:30:41 PM UTC, comment #7:

I pushed the changeset to the development branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/ecca28364445). Closing report.

Rik <rik5>
Project Administrator
Sun 27 Sep 2015 05:16:16 AM UTC, comment #6:

Attached is a different way of tackling the problem that is faster because it does not use for loops. It seems to work for me, but please apply it and check for yourself. If good, I will add a ChangeLog message and commit it.

(file #34994)

Rik <rik5>
Project Administrator
Sat 26 Sep 2015 07:14:49 PM UTC, comment #5:

Ooops, yes. Very simple "text" commands like this don't work any more with this first patch:

close all, text(0.5, 0.5, 'Hello')

It seemFs to me that you try to index a cell array (with curly brackets) in your patch. This one works fine with your patch for example:

close all, text(0.5, 0.5, {'Hello'})

But single line texts aren't necessarily a cell array :( Plus: Even multi-line texts can still be a character array. This one should also be preserved to work (and doesn't with this first patch):

close all, text(0.5, 0.5, ['Hello'; '12345'])

Suggestion: Could you maybe change this patch, such that it starts to look for emtpy strings (using the cell array indexing, that currently throws an error) ONLY IF the whole text object is surely a cell array? In all other cases (i.e. having character arrays) there cannot be an empty line in there anyways, because array cannot have missing elements! So there is nothing to fix for those other cases with character arrays.

Hartmut <hardy>
Sat 26 Sep 2015 06:50:38 PM UTC, comment #4:

Well, there is a problem, with this patch.
Use for example, the code from bug #46037

I get a lot of errors. Back to square 1.

Avinoam Kalma <avinoam>
Project Member
Thu 24 Sep 2015 07:29:27 PM UTC, comment #3:

Thank you for this patch, Avinoam.

I have tested the behavior of this patch. And yes, it seems to properly fix the described behavior in this bug report :)

I cannot judge if this patch would have any side effects. To judge this, I do not understand enough of the code in text.m.

I would be happy to see this patch included into the next release of Octave (unless someone has a good reason why it shouldn't).

Hartmut <hardy>
Fri 18 Sep 2015 10:11:29 PM UTC, comment #2:

Here is a simple patch which searches for an empty string ([] or '')
and replace it with ''.

Please review.

(file #34924)

Avinoam Kalma <avinoam>
Project Member
Mon 18 Aug 2014 09:17:56 PM UTC, comment #1:

Octave expects the inputs to text() to be strings. For a workaround, use an empty string ('') rather than an empty matrix ([]).

I've marked this as a compatibility bug.

Rik <rik5>
Project Administrator
Mon 18 Aug 2014 07:47:58 PM UTC, original submission:

Here is an example to demonstrate the unwanted behavior:

The second text block is NOT properly displayed. This happens with gnuplot as well as with fltk. But in Matlab this works fine.

Hartmut <hardy>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #34994:  patch.text added by rik5 (4KiB - text/plain)
file #34924:  bug43017.cs added by avinoam (1KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by avinoam (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by hardy (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 29 Sep 2015 01:30:41 PM UTCrik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Sun 27 Sep 2015 05:16:16 AM UTCrik5Attached File-=>Added patch.text, #34994
      StatusConfirmed=>Patch Submitted
    Fri 18 Sep 2015 10:11:29 PM UTCavinoamAttached File-=>Added bug43017.cs, #34924
    Fri 26 Sep 2014 03:26:43 AM UTCrik5StatusNone=>Confirmed
    Fri 26 Sep 2014 03:26:42 AM UTCrik5Priority5 - Normal=>3 - Low
    Mon 18 Aug 2014 09:18:19 PM UTCrik5Summary"text" command does not work with empty lines=>"text" command does not work with empty matrix to indicate empty line
    Mon 18 Aug 2014 09:17:56 PM UTCrik5Item GroupIncorrect Result=>Matlab Compatibility

    Back to the top


    Powered by Savane 3.1-cleanup1