bugGNU Octave - Bugs: bug #40575, Saving cells containing matrices...

 
 

bug #40575: Saving cells containing matrices with NA fails to load

Submitted by:  None
Submitted on:  Thu 14 Nov 2013 04:07:03 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: MattOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.4
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.

 

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

Sat 16 Nov 2013 02:39:15 PM UTC, comment #8:

The problem with loading/saving NA values in text format has been solved, so I think it would be useful to find any code that transmutes NaNs to NAs, but probably not essential. I did a few simple tests on the command line and the NA behavior appears to be correct.

Rik <rik5>
Project Administrator
Fri 15 Nov 2013 08:02:55 AM UTC, comment #7:

In reply to comment 4, if you think this would help octave I can try to dig further to find out where NaNs transform to NAs.

However once you get save working for NA, if for most operational use, NAs work the same way as NaNs, then maybe it's not that big a deal.

I don't know enough about how NA works to evaluate such a thing. I do know that isnan() evaluates to true on NAs and that they do propagate. NaNs appear to dominate NAs in most calculations so it is odd.

Matt <seventhunders>
Thu 14 Nov 2013 06:03:50 PM UTC, comment #6:

I fixed the problem in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/079da800451b). The fix will be a part of Octave-3.8.0 which is due out in just a few weeks.

Rik <rik5>
Project Administrator
Thu 14 Nov 2013 03:40:27 PM UTC, comment #5:

The problem is likely to be in the code for handling complex numbers in text files. I can save and restore NA values in ordinary real values.

Rik <rik5>
Project Administrator
Thu 14 Nov 2013 07:32:31 AM UTC, comment #4:

If you provide some code that reproduces the problem with generating unexpecte NA values, then maybe someone can fix it.

For the other problem, I'll try to take a look at it and see why NAs fail to load in text files.

John W. Eaton <jwe>
Project Administrator
Thu 14 Nov 2013 07:23:27 AM UTC, comment #3:

The code is very complex unfortunately and I'm not the author of it. I am merely hacking it until it conforms to octave. The original array is actually initialized to all zeros.

However both NaNs and Infs are deliberately introduced to mark certain elements as unused. Of course Matlab does not have NA, so that was not used.

I have to conclude that there are octave functions, built in or not that actually produce NAs, perhaps from NaNs. In the code I notice things like fliplr() and sort() and isinf() and isnan() being used. What happens to sort if there are NaNs in the array for example?

It would take a bit of work to skin out, but I can verify this much. The array is filled with 0s prior to a section of code that loads the array with mathematical quantities derived from another array that contains some NaNs. After this process, NAs are produced.

Matt <seventhunders>
Thu 14 Nov 2013 06:39:01 AM UTC, comment #2:

It looks to me like there are only a few ways you could generate NA. You can read NA from a file. You can generate NA by reading it from a string with str2double. Or you can generate it by extrapolating with an interpolation function like interp1. It might also be possible for the glpk linear programming solver to return NA in some cases. Which are you using? For compatibility, maybe one or more of these functions should return NaN instead of NA.

John W. Eaton <jwe>
Project Administrator
Thu 14 Nov 2013 06:12:05 AM UTC, comment #1:

Confirmed. This is still present on the development branch. However, the problem seems to be limited only to the text format. If you can save the data in another format--matlab binary (since you're starting with a Matlab project), octave binary, hdf5--then the data will load correctly.

Alternatively, you could just open the text file in an editor and do a search and replace with NA -> NaN. Then the file will also load.

Rik <rik5>
Project Administrator
Thu 14 Nov 2013 04:07:03 AM UTC, original submission:

If your cell array contains matrices with NA (not NaN), and you save it as ascii (is this the default?), you can not load it in again.

Here is a simple example

This fails with the error:
error: load: failed to load matrix constant
error: load: trouble reading ascii file ''
error: load: reading file
error: load: cell array element had unexpected name
error: load: failed to load cell element
error: load: trouble reading ascii file 'bad'
error: load: reading file bad
error: called from:

I have run across several bugs in trying to convert a large complex matlab project into octave. For some reason some of the converted Matlab code is filling some columns of my matrices with NA's instead of NaNs. I am now faced with the prospect of flushing out the NAs and replacing them with NaNs to get this to work.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by seventhunders (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 14 Nov 2013 06:03:50 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Thu 14 Nov 2013 06:12:05 AM UTCrik5StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1