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

 
 

bug #44684: num2str produces additional blank lines

Submitter:  None
Submitted:  Wed 01 Apr 2015 10:19:30 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  MT Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group 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().


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


but


sprintf ('%3.8f %3.8f %3.8f \n', c)


works for me.

Rik <rik5>
Group 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>
Group 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 Files:
   
   
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
  • -email is unavailable- added by juanpi (Updated the item)
  • -email is unavailable- added by mfasi (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-17 juanpi Attached File- Added num2str.diff, #34246
    2015-05-15 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-05-07 mfasi Attached File- Added bugfix_44684.patch, #33957
    2015-04-01 rik5 Priority5 - Normal 3 - Low
    2015-04-01 lostbard Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
        Release3.8.1 dev

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code