Skip to content

Commit

Permalink
Re #1790 subtle bug in serializable preventing overloading to_struct …
Browse files Browse the repository at this point in the history
…in case of recursion.
  • Loading branch information
abuts committed Dec 18, 2024
1 parent 10b881c commit e6d6ccb
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@
% Current version of class definition
ver = 1;
end
function flds = hashableFields(~)
% Return cellarray of properties defining the class hash for
% comparison
flds = {'det_bank', 'filename'};
end

function flds = saveableFields(~)
% Return cellarray of properties defining the class
Expand Down
5 changes: 4 additions & 1 deletion herbert_core/utilities/classes/@hashable/eq.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
% Return a logical variable stating if two serializable objects are equal or not
%
% >> [iseq, mess] = eq (obj1, obj2)
% >> [iseq, mess] = eq (obj1, obj2, p1, p2, ...)
%
% Input:
% ------
Expand All @@ -11,6 +10,10 @@
% obj2 Object on right-hand side
%
% See also equal_to_tol
if ~isa(obj2,class(obj1))
iseq = false;
return;
end
if ~all(size(obj1)==size(obj2))
iseq = false;
return;
Expand Down
5 changes: 5 additions & 0 deletions herbert_core/utilities/classes/@hashable/ne.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
%
% See also equal_to_tol

% classes are different
if ~isa(obj2,class(obj1))
isneq = true;
return;
end
% sizes of objects are different
if ~all(size(obj1)==size(obj2))
isneq = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
if isstruct(val)
if isfield(val,'serial_name')
% Structure is one that has been created by to_struct
val = serializable.from_struct (val);
val = obj.from_struct (val);
end
end
obj.(field_name) = val;
Expand Down
Loading

0 comments on commit e6d6ccb

Please sign in to comment.