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

PE, RPE and related optimisations #926

Merged
merged 27 commits into from
Mar 11, 2024
Merged

PE, RPE and related optimisations #926

merged 27 commits into from
Mar 11, 2024

Conversation

shawnlaffan
Copy link
Owner

No description provided.

Use a global precalc to get all the range inverse
scores, set to zero if the branch length is zero.
This avoids a lot of operations when summing the
local range weights.
remove one variable
Use refaliasing and postfix for loops,
and remove a Biodiverse::Utils call.
This takes time to calculate and is generally not needed
by most calcs that depend on _calc_pe.

Instead we can calculate it within calc_pe_lists,
which is the user-facing calc that provides it.
The CANAPE tests were triggering undef warnings.
…with first path

Reduces the work done in the xsub.
The Tree class has a method to get a hash of lengths.
This is cached so later calls are very cheap.

By using this we can avoid many repeated calls
to the get_length method.  As fast as it is,
they can add up across randomisations.
…state var

Minor optimisation but avoids sub call costs.

The state var should be rarely needed but we might
as well not create a new one every time.
We have already calculated the count of labels
unique to set 2 so if that is zero then we can
return early.
This way we take advantage of any of the calc_abc variants
We can calculate the weighted branch lengths
from the local ranges and globally weighted
branch lengths.  This avoids much repeated
summation and thus time.
The element count is needed many times
so store it in a scalar instead of
repeatedly getting it from the array.
The central variant currently needs special handling
but this will be removed in a future commit.
Call calc_phylo_rpe2 where possible,
otherwise process the branches ourselves.

This moves the special case logic out of calc_phylo_rpe2.
The deleted branch was only needed by calc_phylo_rpe_central,
and it now contains the same logic.
Avoid list overheads.

We only have three options anyway.
These have large time overheads in some cases but are
not always needed.  For example the user might only need
the PE scores.
Most of the time _calc_pe will have been called previously
so the cache will exist.  However there are occasions where
this is not done, for example the range weighted phylo
turnover calcs.

That calc has also now been simplified.
@shawnlaffan shawnlaffan merged commit ddc901f into master Mar 11, 2024
8 checks passed
@shawnlaffan shawnlaffan deleted the rpe_2024 branch March 11, 2024 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant