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 pretty_format_numerical for negative values #1192

Merged
merged 5 commits into from
Nov 30, 2022

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Nov 29, 2022

While working on the extras I discovered that I implemented pretty_format_numerical with a stupid bug that breaks it's functionality when confronted with negative values (not to myself use abs when comparing absolute values 🤦‍♀️).
We didn't encounter it because:
a) It is only used for t-values
b) The unit tests for it only used positive numbers (100% line coverage != bug free)🤦‍♀️

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)

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 29, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 7.05 ⭐ 7.12 ⭐ 0.07 👎
Method Length 49.44 ⭐ 54.94 ⭐ 5.50 👎
Working memory 6.65 🙂 6.66 🙂 0.01 👎
Quality 75.62% 74.64% 🙂 -0.98% 👎
Other metrics Before After Change
Lines 295 314 19
Changed files Quality Before Quality After Quality Change
glotaran/utils/sanitize.py 72.42% 🙂 71.71% 🙂 -0.71% 👎
glotaran/utils/test/test_sanitize.py 87.86% ⭐ 86.52% ⭐ -1.34% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
glotaran/utils/sanitize.py sanitize_dict_values 20 😞 95 🙂 9 🙂 53.85% 🙂 Refactor to reduce nesting
glotaran/utils/sanitize.py sanitize_dict_keys 12 🙂 93 🙂 10 😞 58.47% 🙂 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 s-weigand/pyglotaran/fix-pretty_format_numerical

@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 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]       [14afaff3]
     <v0.6.0>                   
!      45.8±0.2ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, False)
!      48.0±0.4ms           failed      n/a  BenchmarkOptimize.time_optimize(False, False, True)
!      45.6±0.4ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, False)
!      47.9±0.3ms           failed      n/a  BenchmarkOptimize.time_optimize(False, True, True)
!      55.7±0.4ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, False)
!        67.4±5ms           failed      n/a  BenchmarkOptimize.time_optimize(True, False, True)
!      55.3±0.4ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, False)
!        63.4±3ms           failed      n/a  BenchmarkOptimize.time_optimize(True, True, True)
             205M             207M     1.01  IntegrationTwoDatasets.peakmem_optimize
-      1.91±0.05s       1.01±0.02s     0.53  IntegrationTwoDatasets.time_optimize

Benchmark diff main vs. PR

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [14afaff3]       [ba7ab9fc]
           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)
             207M             207M     1.00  IntegrationTwoDatasets.peakmem_optimize
       1.01±0.02s       1.01±0.03s     1.00  IntegrationTwoDatasets.time_optimize

@codecov
Copy link

codecov bot commented Nov 29, 2022

Codecov Report

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

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

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1192   +/-   ##
=====================================
  Coverage   87.6%   87.6%           
=====================================
  Files        104     104           
  Lines       4954    4959    +5     
  Branches     821     823    +2     
=====================================
+ Hits        4344    4349    +5     
  Misses       493     493           
  Partials     117     117           
Impacted Files Coverage Δ
glotaran/utils/sanitize.py 64.9% <100.0%> (+2.4%) ⬆️

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.

@s-weigand s-weigand force-pushed the fix-pretty_format_numerical branch from d680f53 to ba7ab9f Compare November 30, 2022 01:20
@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
0.0% 0.0% Duplication

@jsnel jsnel merged commit a2c6846 into glotaran:main Nov 30, 2022
@s-weigand s-weigand deleted the fix-pretty_format_numerical branch December 2, 2022 10:26
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