From 1de822115579e40775d8a7e5d4a5b7bb225e8f0b Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Fri, 8 Mar 2024 19:09:37 +1100 Subject: [PATCH] Tests: change precision approach in Cluster2 --- t/26-Cluster2.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/26-Cluster2.t b/t/26-Cluster2.t index 54d712e59..08519c079 100644 --- a/t/26-Cluster2.t +++ b/t/26-Cluster2.t @@ -250,6 +250,7 @@ sub test_cluster_node_calcs { is [sort keys %$node_hash1], [sort keys %$node_hash2], 'paranoia check: same node names'; + my $prec = 1e10; my (%aggregate1, %aggregate2); foreach my $node_name (sort keys %$node_hash1) { my $node1 = $node_hash1->{$node_name}; @@ -258,8 +259,8 @@ sub test_cluster_node_calcs { foreach my $list_name (sort grep {$_ !~ /NODE_VALUES/}$node1->get_hash_lists) { my $ref1 = $node1->get_list_ref_aa($list_name); my $ref2 = $node2->get_list_ref_aa($list_name); - my $snapped1 = {map {$_ => sprintf "%.10f", $ref1->{$_}} keys %$ref1}; - my $snapped2 = {map {$_ => sprintf "%.10f", $ref2->{$_}} keys %$ref2}; + my $snapped1 = {map {$_ => int ($ref1->{$_} * $prec)/$prec} keys %$ref1}; + my $snapped2 = {map {$_ => int ($ref2->{$_} * $prec)/$prec} keys %$ref2}; $aggregate1{$node_name}{$list_name} = $snapped1; $aggregate2{$node_name}{$list_name} = $snapped2; }