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

Improvements to application of clp_penalties (equal area) #801

Merged
merged 2 commits into from
Sep 4, 2021

Conversation

jsnel
Copy link
Member

@jsnel jsnel commented Aug 29, 2021

This fix reproduces the area penalty behavior that was in v0.4.1 when multiple datasets are involved.

The 'equal area penalty' is calculated on a per dataset basis.

Change summary

  • Calculate in calculate_clp_penalties the clp penalties on a per dataset level

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 👌 Closes issue (mandatory for ✨ feature and 🩹 bug fix PR's)

Closes issues

closes #800

@jsnel jsnel marked this pull request as draft August 29, 2021 23:21
@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on branch jsnel/pyglotaran/refactor/800_clp_penalties_equal_area

@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #801 (b3e85b6) into staging (fe7d75c) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           staging    #801   +/-   ##
=======================================
  Coverage     84.4%   84.5%           
=======================================
  Files           75      75           
  Lines         4195    4200    +5     
  Branches       755     756    +1     
=======================================
+ Hits          3544    3549    +5     
  Misses         518     518           
  Partials       133     133           
Impacted Files Coverage Δ
glotaran/analysis/problem_grouped.py 96.0% <ø> (ø)
glotaran/analysis/problem_ungrouped.py 93.8% <ø> (ø)
glotaran/model/clp_penalties.py 31.9% <ø> (ø)
glotaran/analysis/util.py 91.3% <100.0%> (+0.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe7d75c...b3e85b6. Read the comment docs.

Copy link
Member

@joernweissenborn joernweissenborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsnel i officially grant you code ownership of this function 😉

This fix reproduces the area penalty behavior that was in v0.4.1 with multiple datasets with the same spectral axis.

For multiple datasets with different axes a more elaborate solution is required, see glotaran#800 for discussion.
@jsnel jsnel force-pushed the refactor/800_clp_penalties_equal_area branch from 52d1aaa to b309dd0 Compare September 4, 2021 00:31
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Sep 4, 2021

This pull request introduces 1 alert when merging b309dd0 into fe7d75c - view on LGTM.com

new alerts:

  • 1 for Wrong number of arguments in a call

Add reference to dataset_models to calculate_clp_penalties to calculate clp_penalties per dataset (axis)
@jsnel jsnel force-pushed the refactor/800_clp_penalties_equal_area branch from b309dd0 to b3e85b6 Compare September 4, 2021 00:43
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 4, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 4, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.28%.

Quality metrics Before After Change
Complexity 6.22 ⭐ 6.24 ⭐ 0.02 👎
Method Length 80.66 🙂 81.92 🙂 1.26 👎
Working memory 10.38 😞 10.41 😞 0.03 👎
Quality 62.84% 🙂 62.56% 🙂 -0.28% 👎
Other metrics Before After Change
Lines 1070 1105 35
Changed files Quality Before Quality After Quality Change
glotaran/analysis/problem_grouped.py 57.20% 🙂 57.20% 🙂 0.00%
glotaran/analysis/problem_ungrouped.py 67.78% 🙂 67.75% 🙂 -0.03% 👎
glotaran/analysis/util.py 67.90% 🙂 66.64% 🙂 -1.26% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
glotaran/analysis/problem_grouped.py GroupedProblem._append_to_grouped_bag 12 🙂 269 ⛔ 23 ⛔ 29.09% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/analysis/problem_ungrouped.py UngroupedProblem._calculate_residual 13 🙂 214 ⛔ 12 😞 41.40% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/analysis/problem_grouped.py GroupedProblem.init_bag 10 🙂 174 😞 16 ⛔ 41.86% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/analysis/problem_grouped.py GroupedProblem._index_independent_residual 8 ⭐ 137 😞 14 😞 49.89% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/analysis/problem_grouped.py GroupedProblem._index_dependent_residual 8 ⭐ 123 😞 15 😞 50.28% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2021

Benchmark is done. Checkout the benchmark result page.
Benchmark differences below 5% might be due to CI noise.

Benchmark diff

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [dc00e6da]       [b3e85b61]
     <v0.4.0>                   
-     42.7±0.09ms       31.8±0.1ms     0.74  BenchmarkOptimize.time_optimize(False, False, False)
-       245±0.9ms       37.0±0.4ms     0.15  BenchmarkOptimize.time_optimize(False, False, True)
-      63.1±0.4ms       52.6±0.3ms     0.83  BenchmarkOptimize.time_optimize(False, True, False)
-      64.8±0.3ms       56.2±0.3ms     0.87  BenchmarkOptimize.time_optimize(False, True, True)
       42.9±0.1ms       41.0±0.3ms     0.96  BenchmarkOptimize.time_optimize(True, False, False)
-       244±0.7ms        79.5±40ms     0.33  BenchmarkOptimize.time_optimize(True, False, True)
       62.8±0.3ms       63.4±0.3ms     1.01  BenchmarkOptimize.time_optimize(True, True, False)
       64.8±0.3ms        67.4±40ms     1.04  BenchmarkOptimize.time_optimize(True, True, True)
             179M             177M     0.98  IntegrationTwoDatasets.peakmem_create_result
             196M             192M     0.98  IntegrationTwoDatasets.peakmem_optimize
-         201±2ms          159±2ms     0.79  IntegrationTwoDatasets.time_create_result
-      4.34±0.03s       1.61±0.06s     0.37  IntegrationTwoDatasets.time_optimize

@jsnel jsnel marked this pull request as ready for review September 4, 2021 00:53
@jsnel jsnel merged commit 2a6b3e6 into glotaran:staging Sep 4, 2021
@jsnel jsnel deleted the refactor/800_clp_penalties_equal_area branch September 4, 2021 00:56
jsnel added a commit that referenced this pull request Sep 16, 2021
* Calculate clp_penalties per datasets like in v0.4.1

Add reference to dataset_models to calculate_clp_penalties to calculate clp_penalties per dataset (axis)
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