Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index and other optimisations #922

Merged
merged 24 commits into from
Feb 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
11a9bbe
Indices: optimise _calc_endemism_absolute
shawnlaffan Feb 23, 2024
501bd7b
Minor optimisations in _calc_endemism_hier_part
shawnlaffan Feb 23, 2024
f9bcf98
TreeNode.pm: use a linear scan for get_hash_lists_below
shawnlaffan Feb 23, 2024
1e7deb8
Add an array args version of set_basedata_ref
shawnlaffan Feb 23, 2024
4dec15f
Trees: clone_without_caches also clears parameters
shawnlaffan Feb 23, 2024
965c1ad
Common::get_zscore_from_comp_results - avoid a lot of grepping
shawnlaffan Feb 23, 2024
6ee1109
optimise Tree::convert_comparisons_to_significances
shawnlaffan Feb 23, 2024
80bc505
optimise Spatial::convert_comparisons_to_significances
shawnlaffan Feb 23, 2024
81f38b3
Indices: add a hierarchical mode flag
shawnlaffan Feb 23, 2024
1c6a509
Indices: Support hierarchical calculations
shawnlaffan Feb 23, 2024
5d6a8b4
Indices: calc_labels_not_on_tree: return early if nothing to work with
shawnlaffan Feb 23, 2024
67f655e
Indices: add a hierarchical variant of get_path_lengths_to_root_node
shawnlaffan Feb 23, 2024
6d9c553
Indices: _calc_endemism_hier_part: avoid some method calls
shawnlaffan Feb 23, 2024
8a69ac2
Indices: _calc_endemism_hier_part: refactor some variables
shawnlaffan Feb 23, 2024
a37dbb3
delete commented code
shawnlaffan Feb 23, 2024
9b1846d
Indices: refactor hierarchical node details
shawnlaffan Feb 24, 2024
744c430
Squeeze a little more performance out of compare_lists_by_item
shawnlaffan Feb 24, 2024
7586528
TreeNode::add_to_lists: optimise
shawnlaffan Feb 24, 2024
0c34d12
Cluster spatial calcs: add lists by ref
shawnlaffan Feb 24, 2024
4168546
compare_lists_by_item: lift a var outside the loop
shawnlaffan Feb 24, 2024
b2ee3ed
Indices: cache the current results from each sub
shawnlaffan Feb 24, 2024
e173a47
Indices: reuse whole and central endemism results when appropriate
shawnlaffan Feb 24, 2024
16a4f86
formatting
shawnlaffan Feb 24, 2024
62fd8a1
simplify by using List::Util::any
shawnlaffan Feb 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
simplify by using List::Util::any
shawnlaffan committed Feb 24, 2024
commit 62fd8a1eab94b9f7d43e2024627f3ac74dcee807
14 changes: 4 additions & 10 deletions lib/Biodiverse/Indices.pm
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use warnings;
#use Data::Dumper;
use Scalar::Util qw /blessed weaken/;
use List::MoreUtils qw /uniq/;
use List::Util qw /sum/;
use List::Util qw /sum any/;
use English ( -no_match_vars );
use Ref::Util qw { :all };
use JSON::MaybeXS;
@@ -795,15 +795,9 @@ sub parse_dependencies_for_calc {

foreach my $required_arg ( sort @$reqd_args_a ) {
my $re = qr /^($required_arg)$/;
my $is_defined;
CALC_ARG:
foreach
my $calc_arg ( sort grep { $_ =~ $re } keys %$calc_args ) {
if ( defined $calc_args->{$calc_arg} ) {
$is_defined++;
last CALC_ARG;
}
}
my $is_defined
= any { $_ =~ $re && defined $calc_args->{$_}}
sort keys %$calc_args;

if ( !$is_defined ) {
Biodiverse::Indices::MissingRequiredArguments->throw(