glotaran / pyglotaran-examples

This repository hold examples showcasing the use of the pyglotaran package
MIT License
5 stars 7 forks source link

🩹🗑️ Fixed usage of deprecated functionality and syntax #52

Closed s-weigand closed 2 years ago

s-weigand commented 2 years ago

This upgrades the model files to use the pyglotaran 0.5.0 syntax and the script files to use the pyglotaran-extras 0.5.0rc1 syntax.

Best reviewed commit by commit.

All deprecations up to the current main of pyglotaran were removed.

s-weigand commented 2 years ago

Maybe the functionality from scripts/run_examples.py to throw errors on deprecations would be nice to have in the pyglotaran_extras, since it allows you to fix them step by step mostly at model parsing time or import time. The only exception is code that comes after the optimization, e.g. plotting functions, but you wouldn't need for the plots to finish.

s-weigand commented 2 years ago

I made it a draft for now, since we have no consistency check on the examples themselves. I guess the best place to implement that functionality would be a separate repository, where we could also implement it as an action. What do you think?

jsnel commented 2 years ago

I suggest borrowing from the pyglotaran repo the Run Examples + Compare results actions, and compare the incoming PR against main against the latest released version of the software and/or (optionally) main.

s-weigand commented 2 years ago

The problem is that the result comparison code lives inside of pyglotaran, so we either add the result consistency checking action to the pyglotaran repo or make it a standalone repo (my preferred solution).

jsnel commented 2 years ago

The problem is that the result comparison code lives inside of pyglotaran, so we either add the result consistency checking action to the pyglotaran repo or make it a standalone repo (my preferred solution).

Let's do that (make it a stand alone repo). Do we use pyglotaran-validation for this, or yet another repo?

jsnel commented 2 years ago

This PR has been stale for some time, but it would be nice to have the examples updates to non-deprecated code. Perhaps to work around the validation issues, we can do a one time manual check.

s-weigand commented 2 years ago

This PR has been stale for some time, but it would be nice to have the examples updates to non-deprecated code. Perhaps to work around the validation issues, we can do a one time manual check.

I will factor out the validation code to a separate repository this weekend since this is a blocker for a potential release of pyglotaran=0.7.0 (see due deprecations for 0.7.0)

sourcery-ai[bot] commented 2 years ago

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 1.09 ⭐ 1.13 ⭐ 0.04 👎
Method Length 124.95 😞 127.50 😞 2.55 👎
Working memory 13.02 😞 12.96 😞 -0.06 👍
Quality 52.88% 🙂 52.58% 🙂 -0.30% 👎
Other metrics Before After Change
Lines 1139 1129 -10
Changed files Quality Before Quality After Quality Change
pyglotaran_examples/ex_doas_beta/ex_doas_beta.py 59.62% 🙂 59.16% 🙂 -0.46% 👎
pyglotaran_examples/ex_doas_beta/ex_doas_beta_ascii.py 59.62% 🙂 59.61% 🙂 -0.01% 👎
pyglotaran_examples/ex_spectral_constraints/ex_spectral_constraints.py 48.48% 😞 48.36% 😞 -0.12% 👎
pyglotaran_examples/ex_spectral_guidance/ex_spectral_guidance.py 80.76% ⭐ 80.47% ⭐ -0.29% 👎
pyglotaran_examples/ex_two_datasets/ex_two_datasets.py 36.53% 😞 36.47% 😞 -0.06% 👎
pyglotaran_examples/quick_start/quickstart.py 50.52% 🙂 50.45% 🙂 -0.07% 👎
pyglotaran_examples/study_fluorescence/target_analysis_script.py 38.79% 😞 38.82% 😞 0.03% 👍
pyglotaran_examples/study_transient_absorption/target_analysis_script.py 45.88% 😞 45.77% 😞 -0.11% 👎
pyglotaran_examples/study_transient_absorption/two_dataset_analysis.py 38.47% 😞 38.40% 😞 -0.07% 👎
pyglotaran_examples/test/simultaneous_analysis_3d_disp/sim_analysis_script_3d_disp.py 44.15% 😞 43.87% 😞 -0.28% 👎
pyglotaran_examples/test/simultaneous_analysis_3d_nodisp/sim_analysis_script_3d.py 44.15% 😞 43.87% 😞 -0.28% 👎
pyglotaran_examples/test/simultaneous_analysis_3d_weight/sim_analysis_script_3d_weight.py 44.05% 😞 43.78% 😞 -0.27% 👎
pyglotaran_examples/test/simultaneous_analysis_6d_disp/sim_analysis_script_6d_disp.py 39.04% 😞 38.84% 😞 -0.20% 👎
scripts/run_examples.py 78.80% ⭐ 76.82% ⭐ -1.98% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
scripts/run_examples.py script_run_wrapper 11 🙂 178 😞 49.78% 😞 Try splitting into smaller methods
pyglotaran_examples/ex_doas_beta/ex_doas_beta.py run_doas_model 1 ⭐ 284 ⛔ 10 😞 52.78% 🙂 Try splitting into smaller methods. Extract out complex expressions
pyglotaran_examples/ex_doas_beta/ex_doas_beta_ascii.py run_doas_model 1 ⭐ 276 ⛔ 10 😞 53.09% 🙂 Try splitting into smaller methods. Extract out complex expressions
pyglotaran_examples/ex_spectral_guidance/ex_spectral_guidance.py load_and_plot_results 0 ⭐ 143 😞 5 ⭐ 75.32% ⭐ Try splitting into smaller methods
scripts/run_examples.py github_format_warning 0 ⭐ 33 ⭐ 10 😞 79.25% ⭐ Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

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!