Anselmoo / spectrafit

📊📈🔬 SpectraFit is a command-line and Jupyter-notebook tool for quick data-fitting based on the regular expression of distribution functions.
https://anselmoo.github.io/spectrafit/
BSD 3-Clause "New" or "Revised" License
25 stars 7 forks source link

refactor: :recycle: Refactor dictionary comprehension for generating report #1600

Closed Anselmoo closed 1 week ago

Anselmoo commented 1 week ago

All PR-Submissions:


New ✨✨ Feature-Submissions:


Changes to ⚙️ Core-Features:


Summary by Sourcery

Refactor the report generation function to use dictionary comprehension, enhancing code readability and maintainability.

Enhancements:

semanticdiff-com[bot] commented 1 week ago

Review changes with SemanticDiff.

Analyzed 1 of 1 files.

Overall, the semantic diff is 32% smaller than the GitHub diff.

Filename Status
:heavy_check_mark: spectrafit/report.py 31.34% smaller
sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request refactors the generate_report method in the spectrafit/report.py file. The main change is the use of a dictionary comprehension to initialize the report dictionary, replacing the previous approach of initializing an empty dictionary and then adding key-value pairs.

File-Level Changes

Change Details Files
Refactored the initialization of the 'report' dictionary using a dictionary comprehension
  • Replaced the empty dictionary initialization and subsequent assignments with a single dictionary comprehension
  • Moved the 'Fit Statistics' and 'Variables and Values' assignments into the dictionary comprehension
  • Kept the conditional assignment of 'Correlations of Components' outside the dictionary comprehension
spectrafit/report.py

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
sonarcloud[bot] commented 1 week ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (cd9c6ce) to head (bf9c347). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1600 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 44 44 Lines 4466 4464 -2 ========================================= - Hits 4466 4464 -2 ``` | [Flag](https://app.codecov.io/gh/Anselmoo/spectrafit/pull/1600/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anselm+Hahn) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/Anselmoo/spectrafit/pull/1600/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anselm+Hahn) | `100.00% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anselm+Hahn#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/Anselmoo/spectrafit/pull/1600?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anselm+Hahn) | Coverage Δ | | |---|---|---| | [spectrafit/report.py](https://app.codecov.io/gh/Anselmoo/spectrafit/pull/1600?src=pr&el=tree&filepath=spectrafit%2Freport.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anselm+Hahn#diff-c3BlY3RyYWZpdC9yZXBvcnQucHk=) | `100.00% <100.00%> (ø)` | |