bugGNU Octave - Bugs: bug #66885, Saving `object` type is a problem

 
 

bug #66885: Saving `object` type is a problem

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Sat 08 Mar 2025 11:29:41 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 10.0.90 Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 16 Mar 2025 12:34:07 AM UTC, comment #4: 

Andreas,

As it was mentioned elsewhere (discourse?), a current workaround is to add

save_default_options ("-mat7-binary")
octave_core_file_options ("-mat7-binary")


to .octaverc.

I am not sure what could be contras for using that instead of "-binary".

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 15 Mar 2025 06:44:59 PM UTC, comment #3: 

This is becoming quite an issue, since there is an increasing number of objects being introduced in various packages (this is especially so for the statistics package).
Even a workaround that would allow `saveobj` and `loadobj` static methods to be called from `save` and `load` accordingly would be a huge improvement, despite the extra work required to implement these in every classdef out there.

Skipping an object instead of aborting the whole saving process is paramount of course.

Andreas Bertsatos <pr0m1th3as>
Mon 10 Mar 2025 01:49:43 AM UTC, comment #2: 

There is already a bug report on long term plans to implement saving of objects.  Is it okay to re-purpose this bug report to be about not aborting save if an object is encountered?

I agree that Octave should do what it can and if you ask it to save 100 variables, and only one of them is an object, then it should save 99 variables and just emit a warning that it wasn't able to do one of them.

I found a quick hack to do this for saving.  The resulting file, in text format, has the name and type of the variable but no other information.  However, reading a file and skipping over null items like this is still a problem.

Rik <rik5>
Group administrator
Sat 08 Mar 2025 11:36:22 PM UTC, comment #1: 

Forgot to paste the octave version:

octave:1> ver
----------------------------------------------------------------------
GNU Octave Version: 10.0.91 (hg id: cfa7231809eb)
GNU Octave License: GNU General Public License
Operating System: Linux 6.13.5-200.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Feb 27 15:07:31 UTC 2025 x86_64
----------------------------------------------------------------------
Package Name  | Version | Installation directory
--------------+---------+-----------------------
  statistics  |   1.7.3 | /home/dmitri/.local/share/octave/api-v60/packages/statistics-1.7.3
-version-

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 08 Mar 2025 11:29:41 PM UTC, original submission:  

Currently with

octave:1> pkg load statistics
octave:2> x1 = burrrnd (1, 2, 1, 100, 1);
octave:3> x2 = burrrnd (1, 0.5, 2, 100, 1);
octave:4> pd = fitdist ([x1; x2], "burr", "By", [ones(100,1); 2*ones(100,1)]);
octave:5> whos
Variables visible from the current scope:

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         pd          1x2                          0  BurrDistribution
         x1        100x1                        800  double
         x2        100x1                        800  double

Total is 202 elements using 1600 bytes

octave:6> save d1.txt
error: octave_base_value::save_ascii(): wrong type argument 'object'
octave:7> save -binary d1.bin
error: octave_base_value::save_binary(): wrong type argument 'object'
octave:8> save -hdf5 d1.hdf5
error: octave_base_value::save_binary(): wrong type argument 'object'
octave:9> save -7 d1.m7
warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned, including private and protected ones.
warning: struct: converting a classdef object into a struct overrides the access restrictions defined for properties. All properties are returned, including private and protected ones.
octave:10>

And the results are:

$ ls -gG d1*
-rw-r--r--. 1   33 Mar  8 16:59 d1.bin.saving_in_progress
-rw-r--r--. 1 2543 Mar  8 17:00 d1.hdf5.saving_in_progress
-rw-r--r--. 1 4368 Mar  8 17:00 d1.m7
-rw-r--r--. 1   98 Mar  8 16:59 d1.txt.saving_in_progress


What is particularly bad that (at least in the most used cases of txt and binary) entire saving is aborted as soon as "object" is encountered. This will a bigger problem in real-life situation where workspace is large, so user would need to explicitly save all the "good" variables.

Dmitri.
-- 

Dmitri A. Sergatskov <dasergatskov>

 

(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 pr0m1th3as (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dasergatskov (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.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.14-7003.
    Corresponding source code