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

Exit early from candidates without passing propperties #212

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

JoranAngevaare
Copy link
Owner

Exit early if candidates do not pass.

Intro

In this PR, we fix an issue relating to evaluating regions in the analyze.merge_candidate_regions.Merger and (especially) analyze.merge_candidate_regions.MergerCached. In these methods, a list of regions is evaluated if:

  1. The region passes a predefined criterion
  2. The region can be expanded by merging adjacent/overlapping other regions

To achieve this, we first sort all available regions based on if they pass the predefined criterion, and then the size of the region. Then we can iteratively start performing the second step (expanding the region).

Issue

One advised method (also see the example notebook) is to add a set of small regions that could overlap/be adjacent to a passing region to get a large region. However, to save computational expense, we often cache the results of these small regions as nan-values (such that they don't pass the predefined criterion). This is done in MergerCached.set_all_caches_as_false. The issue resides in these regions. Since while we indeed correctly sort the available regions and iteratively resolve them, we did not check if the remaining candidates have would pass the predefined criterion.

This resulted in the small regions also being evaluated (if they would be merge-able during step 2) without explicitly checking step 1.

Solution

This PR adds a check that step 1 is performed every time we consider a new candidate before we continue with step 2.

Effect

This is particularly relevant when adding regions and using MergerCached.set_all_caches_as_false. For the Merger-class the effect is minimal (when adding small regions there is no method to tell the Merger method to consider the regions any differently from other regions).

@coveralls
Copy link

coveralls commented Jan 13, 2025

Pull Request Test Coverage Report for Build 12751078136

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.05%) to 87.182%

Files with Coverage Reduction New Missed Lines %
optim_esm_tools/analyze/merge_candidate_regions.py 2 79.75%
Totals Coverage Status
Change from base Build 12631339290: -0.05%
Covered Lines: 2707
Relevant Lines: 3105

💛 - Coveralls

@JoranAngevaare JoranAngevaare merged commit 3634612 into master Jan 14, 2025
11 checks passed
@JoranAngevaare JoranAngevaare deleted the early_exit_non_passing_regions branch January 14, 2025 08:31
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.

2 participants