Skip to content

Commit

Permalink
Matrix.pm: use lower precision in summary stats
Browse files Browse the repository at this point in the history
"%6g" precision should be sufficient, while also
speeding up the summary stats calculation.

Update some test expectations accordingly.
  • Loading branch information
shawnlaffan committed Sep 26, 2023
1 parent 41e4b4a commit 4f19969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/Biodiverse/Matrix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ sub get_summary_stats {
my %data;
\my %top_level = $self->{BYELEMENT};
foreach my $href (values %top_level) {
$data{$_}++ for values %$href;
# round to save time and space - approximate vals should be OK for this
$data{0 + sprintf "%-6g", $_}++ for values %$href;
}
my %r;
my $stats
Expand Down
20 changes: 10 additions & 10 deletions t/26-Cluster2.t
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ sub test_phylo_rw_turnover_mx {
my $mx = $mx_arr->[0];

my %expected = (
PCT975 => 0.8059701493,
PCT95 => 0.8059701493,
PCT975 => 0.80597,
PCT95 => 0.80597,
MIN => 0,
PCT025 => 0,
PCT05 => 0,
MAX => 0.8059701493,
MEAN => 0.3751810522,
SD => 0.3047706206,
MAX => 0.80597,
MEAN => 0.3751808,
SD => 0.3047705823,
);

my $stats = $mx->get_summary_stats;
Expand Down Expand Up @@ -197,14 +197,14 @@ sub test_rw_turnover_mx {
my $mx = $mx_arr->[0];

my %expected = (
PCT975 => 0.8333333333,
PCT95 => 0.8333333333,
PCT975 => 0.833333,
PCT95 => 0.833333,
MIN => 0,
PCT025 => 0,
PCT05 => 0,
MAX => 0.8333333333,
MEAN => 0.3923076923,
SD => 0.316227766,
MAX => 0.833333,
MEAN => 0.3923075333,
SD => 0.3162277347,
);

my $stats = $mx->get_summary_stats;
Expand Down

0 comments on commit 4f19969

Please sign in to comment.