bugGNU Octave - Bugs: bug #44684, num2str produces additional blank...

 
 

bug #44684: num2str produces additional blank lines

Submitted by:  None
Submitted on:  Wed 01 Apr 2015 10:19:30 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 3 - LowItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: MTOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 17 Jun 2015 03:00:08 PM UTC, comment #5:

The patches solves the issue (according to the test provided).

It also solves bug #45174

(file #34246)

Juan Pablo Carbajal <juanpi>
Project Member
Fri 15 May 2015 05:04:49 AM UTC, comment #4:

It turned out to be a different problem related to single quotes. I pushed a cset which fixes it here (http://hg.savannah.gnu.org/hgweb/octave/rev/ea5fdb2ae637).

Rik <rik5>
Project Administrator
Thu 07 May 2015 08:12:01 PM UTC, comment #3:

The patch I attach should solve the issue. I think that the problem was due to the parsing of the format string, which could result in adding a "\n" at the end of already terminated lines.

The modified version does not make any test fail and remove the additional blank lines in the examples of the original post.

(file #33957)

Massimiliano Fasi <mfasi>
Wed 01 Apr 2015 04:05:59 PM UTC, comment #2:

num2str is not very flexible, as it says itself in the help string. If you have a more complicated format use sprintf().

but

works for me.

Rik <rik5>
Project Administrator
Wed 01 Apr 2015 12:14:27 PM UTC, comment #1:

Behaves the same in dev.

num2str appears to expect a single format argument, which it then applies that format to all values in the columns.

In addition matlab appears to cater for multiple format specifiers in the format string, although the documentation (as I read it) doesn't explicitly say so.

John Donoghue <lostbard>
Project Member
Wed 01 Apr 2015 10:19:30 AM UTC, original submission:

Using Octave-3.8.1 from standard Ubuntu 14.04 repositories (64-bit OS)

I have found some weird behavior of num2str function. Sometimes it produces additional blank line.

c = [
-0.00000 0.71500 -0.00000
-0.00000 -0.71500 0.00000
1.23760 -1.40040 0.00000
-1.23760 -1.40040 0.00000
];

% Produces additional blank line
num2str(c,'%3.8f %3.8f %3.8f \n')

% Also produces additional blank line
num2str(c(1:3,:),'%3.8f %3.8f %3.8f \n')

% However, this does not produce the blank line
num2str(c(3:4,:),'%3.8f %3.8f %3.8f \n')

When I use larger matrix (more rows), the problem repeats after every 3 lines - it is probably some general problem, independent on what exactly is on the 3rd line...

Also affects Octave 3.8.2, Matlab doesn't have this problem

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #34246:  num2str.diff added by juanpi (2KiB - text/x-patch)
file #33957:  bugfix_44684.patch added by mfasi (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by juanpi (Updated the item)
  • -unavailable- added by mfasi (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by lostbard (Posted a comment)
  • -unavailable- added by None (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 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 17 Jun 2015 03:00:08 PM UTCjuanpiAttached File-=>Added num2str.diff, #34246
    Fri 15 May 2015 05:04:49 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Thu 07 May 2015 08:12:01 PM UTCmfasiAttached File-=>Added bugfix_44684.patch, #33957
    Wed 01 Apr 2015 04:05:59 PM UTCrik5Priority5 - Normal=>3 - Low
    Wed 01 Apr 2015 12:14:27 PM UTClostbardItem GroupIncorrect Result=>Matlab Compatibility
      StatusNone=>Confirmed
      Release3.8.1=>dev

    Back to the top


    Powered by Savane 3.1-cleanup1