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

🩹 Fix matrix provider #1190

Merged
merged 3 commits into from
Nov 28, 2022
Merged

Conversation

jsnel
Copy link
Member

@jsnel jsnel commented Nov 28, 2022

This PR is meant to fix an issue with grouping inadvertently introduced in PR #1175

Change summary

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 🚧 Added changes to changelog (mandatory for all PR's)
  • 🧪 Adds new tests for the feature (mandatory for ✨ feature and 🩹 bug fix PR's)

Closes issues

closes #XXXX

More in line with main prior to 1175
Excessive extra (wasted) computation
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 28, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 7.21 ⭐ 7.60 ⭐ 0.39 👎
Method Length 63.91 🙂 64.91 🙂 1.00 👎
Working memory 9.30 🙂 9.38 🙂 0.08 👎
Quality 63.46% 🙂 62.52% 🙂 -0.94% 👎
Other metrics Before After Change
Lines 692 703 11
Changed files Quality Before Quality After Quality Change
glotaran/optimization/matrix_provider.py 63.46% 🙂 62.52% 🙂 -0.94% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
glotaran/optimization/matrix_provider.py MatrixProvider.combine_megacomplex_matrices 19 😞 203 😞 11 😞 39.11% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
glotaran/optimization/matrix_provider.py MatrixProvider.apply_relations 14 🙂 181 😞 13 😞 41.51% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/optimization/matrix_provider.py MatrixProviderLinked.align_matrices 13 🙂 179 😞 12 😞 44.11% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/optimization/matrix_provider.py MatrixProviderLinked.calculate_aligned_matrices 11 🙂 192 😞 12 😞 44.78% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/optimization/matrix_provider.py MatrixProviderUnlinked.calculate_full_matrices 10 🙂 119 🙂 13 😞 51.60% 🙂 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

Binder 👈 Launch a binder notebook on branch jsnel/pyglotaran/experiment/fix_matrix_provider

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2022

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

Benchmark diff v0.6.0 vs. main

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [6c3c390e]       [a1bdb839]
     <v0.6.0>                   
!      54.4±0.6ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
!       58.7±30ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
!      55.3±0.4ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
!       60.7±30ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
!        65.7±1ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
!      71.3±0.8ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
!        65.7±1ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
!        72.0±6ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             203M             210M     1.03  IntegrationTwoDatasets.peakmem_optimize
-      1.97±0.06s       1.18±0.03s     0.60  IntegrationTwoDatasets.time_optimize

Benchmark diff main vs. PR

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [a1bdb839]       [5927e23f]
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
           failed           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             210M             205M     0.98  IntegrationTwoDatasets.peakmem_optimize
       1.18±0.03s       1.17±0.02s     0.99  IntegrationTwoDatasets.time_optimize

@codecov
Copy link

codecov bot commented Nov 28, 2022

Codecov Report

Base: 87.6% // Head: 87.6% // Increases project coverage by +0.0% 🎉

Coverage data is based on head (5927e23) compared to base (a1bdb83).
Patch coverage: 100.0% of modified lines in pull request are covered.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1190   +/-   ##
=====================================
  Coverage   87.6%   87.6%           
=====================================
  Files        104     104           
  Lines       4947    4954    +7     
  Branches     820     821    +1     
=====================================
+ Hits        4337    4344    +7     
  Misses       493     493           
  Partials     117     117           
Impacted Files Coverage Δ
glotaran/optimization/matrix_provider.py 94.0% <100.0%> (+0.1%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jsnel jsnel force-pushed the experiment/fix_matrix_provider branch from d19d7e6 to e60842f Compare November 28, 2022 01:05
Since this fixed a bug introduced within the 0.7.0 development cycle (so after 0.6.0 but before 0.7.0) the change is included in a 'hidden' manner (not rendered unless you look at the source code of the MD file)
@jsnel jsnel marked this pull request as ready for review November 28, 2022 01:17
@sonarqubecloud
Copy link

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 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Collaborator

@ism200 ism200 left a comment

Choose a reason for hiding this comment

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

thank you for fixing the bug

@ism200
Copy link
Collaborator

ism200 commented Nov 28, 2022

thank you for fixing the bug

Copy link
Member

@s-weigand s-weigand left a comment

Choose a reason for hiding this comment

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

@jsnel Thanks a lot for debugging this
I tested it with the case study that brought the problem to light and this fix restores the results from before #1175
image
🎉

@jsnel jsnel merged commit 105ac8d into glotaran:main Nov 28, 2022
@jsnel jsnel deleted the experiment/fix_matrix_provider branch November 28, 2022 19:38
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.

3 participants