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

👌 Improve ParameterGroup markdown rendering #918

Merged
merged 3 commits into from
Dec 1, 2021

Conversation

s-weigand
Copy link
Member

@s-weigand s-weigand commented Nov 30, 2021

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.

Please provide enough information so that others can review your pull request:

Explain the details for making this change. What existing problem does the pull request solve?.

Change summary

  • Table headers in markdown don't use a mix of abbreviations and spelled out names but only spelled out names
  • Expression column doesn't evidently render as latex when 2 or more parameters are present
  • Numbers get formatted as .3e by default
  • User can decide on the float precision of the markdown table by passing float_format

Checklist

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

Closes issues

closes #916

@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran/improve-parametergroup-markdown

@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2021

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

Benchmark diff v0.5.0rc1 vs. main

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [d05c042a]       [db9d46d6]
     <v0.5.0rc1>                 
         75.8±1ms       82.3±0.9ms     1.09  BenchmarkOptimize.time_optimize(False, False, False)
         135±40ms         162±20ms    ~1.20  BenchmarkOptimize.time_optimize(False, False, True)
         77.8±1ms         82.6±1ms     1.06  BenchmarkOptimize.time_optimize(False, True, False)
         158±20ms         176±30ms    ~1.11  BenchmarkOptimize.time_optimize(False, True, True)
         96.6±2ms         99.9±2ms     1.03  BenchmarkOptimize.time_optimize(True, False, False)
         111±30ms         109±20ms     0.98  BenchmarkOptimize.time_optimize(True, False, True)
         96.0±2ms          102±2ms     1.06  BenchmarkOptimize.time_optimize(True, True, False)
       100.0±20ms         110±20ms     1.10  BenchmarkOptimize.time_optimize(True, True, True)
             191M             199M     1.04  IntegrationTwoDatasets.peakmem_optimize
+      2.01±0.04s       2.46±0.09s     1.22  IntegrationTwoDatasets.time_optimize

Benchmark diff main vs. PR

Parametrized benchmark signatures:

BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)

All benchmarks:

       before           after         ratio
     [88111bb1]       [db9d46d6]
         84.8±2ms       82.3±0.9ms     0.97  BenchmarkOptimize.time_optimize(False, False, False)
         160±20ms         162±20ms     1.02  BenchmarkOptimize.time_optimize(False, False, True)
         85.1±2ms         82.6±1ms     0.97  BenchmarkOptimize.time_optimize(False, True, False)
          179±5ms         176±30ms     0.98  BenchmarkOptimize.time_optimize(False, True, True)
          103±1ms         99.9±2ms     0.97  BenchmarkOptimize.time_optimize(True, False, False)
          111±1ms         109±20ms     0.98  BenchmarkOptimize.time_optimize(True, False, True)
        104±0.9ms          102±2ms     0.98  BenchmarkOptimize.time_optimize(True, True, False)
         143±50ms         110±20ms    ~0.77  BenchmarkOptimize.time_optimize(True, True, True)
             193M             199M     1.03  IntegrationTwoDatasets.peakmem_optimize
        2.50±0.1s       2.46±0.09s     0.98  IntegrationTwoDatasets.time_optimize

@codecov
Copy link

codecov bot commented Nov 30, 2021

Codecov Report

Merging #918 (db9d46d) into main (88111bb) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #918   +/-   ##
=====================================
  Coverage   85.1%   85.1%           
=====================================
  Files         85      85           
  Lines       4793    4796    +3     
  Branches     920     921    +1     
=====================================
+ Hits        4079    4082    +3     
  Misses       562     562           
  Partials     152     152           
Impacted Files Coverage Δ
glotaran/parameter/parameter.py 95.5% <100.0%> (+<0.1%) ⬆️
glotaran/parameter/parameter_group.py 88.1% <100.0%> (ø)

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 88111bb...db9d46d. Read the comment docs.

jsnel
jsnel previously approved these changes Nov 30, 2021
Copy link
Member

@jsnel jsnel left a comment

Choose a reason for hiding this comment

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

Reviewed ok!

@s-weigand
Copy link
Member Author

s-weigand commented Nov 30, 2021

Using the kinetic parameters

kinetic: 
    - 0.5
    - 0.3
    - ["3", {expr: "$kinetic.expression_parameter+2*$input.1"}]
    - ["expression_parameter", 0.1]

Old render
grafik

New render
grafik

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 30, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 3.21 ⭐ 3.22 ⭐ 0.01 👎
Method Length 31.75 ⭐ 32.33 ⭐ 0.58 👎
Working memory 6.43 🙂 6.44 🙂 0.01 👎
Quality 81.20% 80.96% -0.24% 👎
Other metrics Before After Change
Lines 1370 1397 27
Changed files Quality Before Quality After Quality Change
glotaran/parameter/parameter.py 84.83% ⭐ 84.60% ⭐ -0.23% 👎
glotaran/parameter/parameter_group.py 75.69% ⭐ 75.47% ⭐ -0.22% 👎
glotaran/parameter/test/test_parameter_group_rendering.py 87.06% ⭐ 85.79% ⭐ -1.27% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
glotaran/parameter/parameter.py Parameter.markdown 13 🙂 148 😞 11 😞 48.86% 😞 Try splitting into smaller methods. Extract out complex expressions
glotaran/parameter/parameter_group.py ParameterGroup.from_dataframe 14 🙂 134 😞 10 😞 51.47% 🙂 Try splitting into smaller methods. Extract out complex expressions
glotaran/parameter/parameter_group.py ParameterGroup.markdown 3 ⭐ 128 😞 11 😞 60.51% 🙂 Try splitting into smaller methods. Extract out complex expressions
glotaran/parameter/parameter.py Parameter.__init__ 1 ⭐ 70 🙂 16 ⛔ 63.36% 🙂 Extract out complex expressions
glotaran/parameter/parameter_group.py ParameterGroup.__repr__ 6 ⭐ 72 🙂 12 😞 63.49% 🙂 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!

@sonarcloud
Copy link

sonarcloud bot commented Nov 30, 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 0 Code Smells

No Coverage information No Coverage information
1.5% 1.5% Duplication

Copy link
Member

@jsnel jsnel left a comment

Choose a reason for hiding this comment

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

👍

@jsnel jsnel merged commit 910b832 into glotaran:main Dec 1, 2021
@jsnel jsnel deleted the improve-parametergroup-markdown branch December 1, 2021 07:29
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.

🐛 Improve ParameterGroup markdown rendering
2 participants