Skip to content

Commit

Permalink
Re #1790 Minor niceness and clarity to comparison methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Dec 22, 2024
1 parent 02c3628 commit 3e9e646
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
12 changes: 8 additions & 4 deletions herbert_core/utilities/classes/@hashable/eq.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
% obj2 Object on right-hand side
%
% See also equal_to_tol
if ~isa(obj2,class(obj1))
iseq = false;

% use generic overloadable methods to compare object's size and shape
% as they are overloadable and may be different for children
iseq = eq_to_tol_type_equal(obj1,obj2,'','');
if ~iseq
return;
end
if ~all(size(obj1)==size(obj2))
iseq = false;
iseq = eq_to_tol_shape_equal(obj1,obj2,'','',false);
if ~iseq
return;
end

for i=1:numel(obj1)
[~,hash1] = build_hash(obj1(i));
[~,hash2] = build_hash(obj2(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
% Compare single pair of hashable objects
%
% internal procedure used by equal_to_toll method to compare
% single pair of hashable objects
% single pair of hashable objects from possible array of such objects
%
% Input:
% obj -- first object to compare
% other_obj -- second object to compare
Expand Down
21 changes: 0 additions & 21 deletions herbert_core/utilities/classes/@serializable/ne.m

This file was deleted.

9 changes: 6 additions & 3 deletions herbert_core/utilities/classes/@serializable/serializable.m
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,12 @@
iseq = equal_to_tol(obj1,obj2);
end

% Return logical variable stating if two serializable objects are
% unequal or not
isne = ne (obj1, obj2)
function isne = ne (obj1, obj2)
% Return logical variable stating if two serializable objects are
% unequal or not. Should be optimized for comparing ne.
isne = ~equal_to_tol(obj1,obj2);
end


% Return logical variable stating if two serializable objects are equal
% or not given some conditions of their equality.
Expand Down

0 comments on commit 3e9e646

Please sign in to comment.