bugGNU Octave - Bugs: bug #56047, dlmread with NaN as range...

 
 

bug #56047: dlmread with NaN as range parameter returns an empty array

Submitter:  Steffen <steffen>
Submitted:  Mon 01 Apr 2019 02:02:59 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  - Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 03 Apr 2019 10:32:22 PM UTC, comment #5: 

I added a test for NaN inputs in the RANGE input, and also added documentation suggesting to use Inf as the equivalent of "end" when building a range specification.  See https://hg.savannah.gnu.org/hgweb/octave/rev/2d36701216e9.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Tue 02 Apr 2019 11:23:02 PM UTC, comment #4: 

I'm also of the opinion that NaN doesn't make intuitive sense when trying to specify a square region of an array.  Regardless of what Matlab does, I think we should produce an error or warning so the programmer can check their values.  Incidentally, The Mathworks is now trying to deprecated dlmread in favor of 'readmatrix'.

Rik <rik5>
Group administrator
Tue 02 Apr 2019 08:42:30 PM UTC, comment #3: 

Like I said, I don't know if this is a bug or not. I only said that NaN doesn't make much intuitive sense to me, specifying a very large number or Inf as the number of columns makes more sense to me. That's just my personal opinion.

Before we go documenting or changing anything, it would still be helpful to know

> What does Matlab do with a range parameter of NaN?


Or more generally, does Matlab dlmread/csvread offer a documented way to use the range syntax, but specify the equivalent of the 'end' keyword in either the row or column position? I don't see this clearly documented anywhere.

Mike Miller <mtmiller>
Group Member
Tue 02 Apr 2019 09:57:09 AM UTC, comment #2: 

Okay, I get it. Maybe a hint or example in the dlmread documentation would be helpful?

Steffen <steffen>
Mon 01 Apr 2019 04:26:42 PM UTC, comment #1: 

Thank you for your report. I don't know if this is a bug or not.

Since you didn't explicitly show the difference, in Octave 4.2.1 and earlier I see


>> data = dlmread ("foo.txt", ",")
data =

   0.7246355   0.9038270   0.2715474   0.0537131   0.0062652   0.6589647
   0.5013773   0.7448110   0.9847691   0.6116570   0.3918950   0.8894601
   0.1572770   0.2567405   0.1690453   0.5567996   0.0110273   0.2038035
   0.1387583   0.5858817   0.5020694   0.4169618   0.8551791   0.0294324
   0.5909749   0.9383733   0.8427086   0.4166940   0.3021889   0.8196946
   0.8825450   0.8234280   0.3286623   0.2107583   0.9080787   0.1634514

>> size (data)
ans =

   6   6

>> data = dlmread ("foo.txt", ",", [1, 1, NaN, 2])
data =

   0.74481   0.98477
   0.25674   0.16905
   0.58588   0.50207
   0.93837   0.84271
   0.82343   0.32866


That is, NaN is a synonym for the last row or column.

In Octave 4.2.2


>> data = dlmread ("foo.txt", ",", [1, 1, NaN, 2])
data = [](0x0)


But, in Octave 4.2.2 and current versions of Octave (highly recommended to upgrade), you can use Inf instead of NaN to get the behavior that you want. Using a parameter of Inf makes more intuitive sense to me than NaN.

What does Matlab do with a range parameter of NaN?

Mike Miller <mtmiller>
Group Member
Mon 01 Apr 2019 02:02:59 PM UTC, original submission:  

Since Ocatve 4.2.2 dlmread() with the parameter NaN returns a empty matrix. In Octave 4.2.1 this parameter work fine.

data=dlmread(File,',',[1,1,NaN,34]);

Steffen <steffen>

 

(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 steffen (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-03 rik5 StatusNeed Info Fixed
        Open/ClosedOpen Closed
        Release5.1.0 dev
    2019-04-02 rik5 Operating SystemMicrosoft Windows Any
    2019-04-02 mtmiller Release4.2.2 5.1.0
    2019-04-01 mtmiller Severity3 - Normal 2 - Minor
        Item GroupOther Incorrect Result
        StatusNone Need Info
        Summarydlmread() - NaN / different file length dlmread with NaN as range parameter returns an empty array

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code