Skip to content

Commit

Permalink
rand reintegration tests: change numeric tolerance to 1e-8
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlaffan committed Feb 25, 2024
1 parent f1d872d commit a046fe1
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions t/11-BaseData-reintegrate-after-rand.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use warnings;

use English qw { -no_match_vars };
use Data::Dumper;
use List::Util 1.45 qw /uniq/;
use List::Util 1.45 qw /uniq pairmap/;
use rlib;

use Data::Section::Simple qw(
Expand Down Expand Up @@ -589,10 +589,14 @@ sub check_integrated_matches_single_run_spatial {
my %l_args = (element => $group, list => $list_name);
my $lr_orig = $sp_orig->get_list_ref (%l_args);
my $lr_integr = $sp_integr->get_list_ref (%l_args);
my %diffs = pairmap {$a => abs ($b - $lr_orig->{$a}) < 1e-8} %$lr_integr;
my %exp;
@exp{keys %$lr_orig} = (1) x keys %$lr_orig;

is (
$lr_integr,
$lr_orig,
"integrated matches single run, $group, $list_name"
\%diffs,
\%exp,
"integrated within tolerance, single run, $group, $list_name"
);
}
}
Expand All @@ -604,6 +608,7 @@ sub check_integrated_matches_single_run_cluster {
my ($cl_orig, $cl_integr) = @args{qw /orig integr/};

my $object_name = $cl_integr->get_name;
my $tol = 1e-8;

subtest "randomisation cluster lists incremented correctly, $object_name" => sub {
my $to_nodes = $cl_integr->get_node_refs;
Expand All @@ -617,19 +622,17 @@ sub check_integrated_matches_single_run_cluster {
my %l_args = (list => $list_name);
my $lr_orig = $orig_node->get_list_ref (%l_args);
my $lr_integr = $to_node->get_list_ref (%l_args);
#is ( # needed for debug, disable once completed
# join (' ', sort keys %$lr_integr),
# join (' ', sort keys %$lr_orig),
# "keys match for $list_name, node $node_name",
#);
compare_hash_vals (
hash_got => $lr_integr,
hash_exp => $lr_orig,
tolerance => 1e-10,
descr_suffix
=> "integrated matches single run, "
. "$object_name, $node_name, $list_name"

my %diffs = pairmap {$a => abs ($b - $lr_orig->{$a}) < $tol} %$lr_integr;
my %exp;
@exp{keys %$lr_orig} = (1) x keys %$lr_orig;

is (
\%diffs,
\%exp,
"integrated within tolerance, single run, $node_name, $list_name"
);

}
}
};
Expand Down

0 comments on commit a046fe1

Please sign in to comment.