Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add id warning on save_safe_struct #327

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions oct2py/_pyeval.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ function save_safe_struct(output_file, result, err)
% NOTE: result is cell{1,1} containing other data
% warning('off', 'Octave:classdef-to-struct');
try
warn_state = warning('off', 'all');
save('-v6', '-mat-binary', output_file, 'result', 'err');
warning(warn_state);
catch ME
warning(warn_state);
% handle failure in passing user defined object
acceptable_types = {'double', 'char', 'logical', 'sparse'};
if isstruct(result{1,1})
Expand All @@ -135,7 +138,11 @@ function save_safe_struct(output_file, result, err)
for i = 1:numel(fields)
field_value = struct_in.(fields{i});
if ~is_acceptable_type(field_value, acceptable_types)
warning('Skipping field "%s" as it is not an acceptable type.', fields{i});
warning(...
'oct2py:pyeval:save_safe_struct:UnacceptableType', ...
'Skipping field "%s" as it is not an acceptable type.', ...
fields{i} ...
);
struct_out = rmfield(struct_out, fields{i});
elseif isstruct(field_value)
struct_out.(fields{i}) = clean_struct(field_value, acceptable_types);
Expand All @@ -149,7 +156,11 @@ function save_safe_struct(output_file, result, err)
cell_out = cell_in;
for i = 1:numel(cell_in)
if ~is_acceptable_type(cell_in{i}, acceptable_types)
warning('Skipping cell content at index {%d} as it is not an acceptable type.', i);
warning(...
'oct2py:pyeval:save_safe_struct:UnacceptableType', ...
'Skipping cell content at index {%d} as it is not an acceptable type.', ...
i ...
);
cell_out{i} = [];
elseif isstruct(cell_in{i})
cell_out{i} = clean_struct(cell_in{i}, acceptable_types);
Expand Down
Loading