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

Sourcery refactored master branch #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Oct 19, 2022

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from endolith October 19, 2022 18:51
file_format = sf.format_info + ' ' + sf.subtype_info
file_format = f'{sf.format_info} {sf.subtype_info}'
Copy link
Author

Choose a reason for hiding this comment

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

Function analyze refactored with the following changes:

Copy link
Owner

Choose a reason for hiding this comment

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

This just re-orders the conditionals to put pass first? 🤔

soundfile['format'] = sf.format_info + ' ' + sf.subtype_info
soundfile['format'] = f'{sf.format_info} {sf.subtype_info}'
Copy link
Author

Choose a reason for hiding this comment

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

Function load_dict refactored with the following changes:

Copy link
Owner

Choose a reason for hiding this comment

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

@sourcery-ai I don't see a "simplify conditional" in this file.

waveform_analysis/thd.py Show resolved Hide resolved
Comment on lines -28 to -37
responses = {}

# ANSI S1.4-1983 Table AI "A weighting"
responses['A'] = np.array((-70.4, -63.4, -56.7, -50.5, -44.7, -39.4, -34.6,
-30.2, -26.2, -22.5, -19.1, -16.1, -13.4, -10.9,
-8.6, -6.6, -4.8, -3.2, -1.9, -0.8, 0.0, +0.6,
+1.0, +1.2, +1.3, +1.2, +1.0, +0.5, -0.1, -1.1,
-2.5, -4.3, -6.6, -9.3, -12.4, -15.8, -19.3, -23.1,
-26.9, -30.8, -34.7,
))
Copy link
Author

Choose a reason for hiding this comment

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

Lines 28-37 refactored with the following changes:

This removes the following comments ( why? ):

# ANSI S1.4-1983 Table AI "A weighting"

Copy link
Owner

Choose a reason for hiding this comment

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

no, bad

waveform_analysis/tests/test_ABC_weighting.py Show resolved Hide resolved
@sourcery-ai
Copy link
Author

sourcery-ai bot commented Oct 19, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 5.55 ⭐ 5.57 ⭐ 0.02 👎
Method Length 102.89 🙂 102.74 🙂 -0.15 👍
Working memory 8.83 🙂 9.12 🙂 0.29 👎
Quality 62.67% 🙂 62.43% 🙂 -0.24% 👎
Other metrics Before After Change
Lines 876 911 35
Changed files Quality Before Quality After Quality Change
scripts/wave_analyzer.py 49.21% 😞 48.19% 😞 -1.02% 👎
waveform_analysis/_common.py 68.47% 🙂 68.44% 🙂 -0.03% 👎
waveform_analysis/thd.py 64.06% 🙂 64.06% 🙂 0.00%
waveform_analysis/tests/test_ABC_weighting.py 71.12% 🙂 71.24% 🙂 0.12% 👍
waveform_analysis/weighting_filters/ABC_weighting.py 61.34% 🙂 61.48% 🙂 0.14% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
scripts/wave_analyzer.py analyze 23 😞 366 ⛔ 18 ⛔ 20.79% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
waveform_analysis/weighting_filters/ABC_weighting.py _derive_coefficients 2 ⭐ 351 ⛔ 10 😞 49.87% 😞 Try splitting into smaller methods. Extract out complex expressions
waveform_analysis/tests/test_ABC_weighting.py TestABCWeighting.test_freq_resp 3 ⭐ 186 😞 11 😞 54.63% 🙂 Try splitting into smaller methods. Extract out complex expressions
waveform_analysis/_common.py load_dict 5 ⭐ 180 😞 9 🙂 57.13% 🙂 Try splitting into smaller methods
waveform_analysis/weighting_filters/ABC_weighting.py ABC_weighting 3 ⭐ 142 😞 10 😞 60.80% 🙂 Try splitting into smaller methods. 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!

waveform_analysis/thd.py Show resolved Hide resolved
waveform_analysis/tests/test_ABC_weighting.py Show resolved Hide resolved
Comment on lines -28 to -37
responses = {}

# ANSI S1.4-1983 Table AI "A weighting"
responses['A'] = np.array((-70.4, -63.4, -56.7, -50.5, -44.7, -39.4, -34.6,
-30.2, -26.2, -22.5, -19.1, -16.1, -13.4, -10.9,
-8.6, -6.6, -4.8, -3.2, -1.9, -0.8, 0.0, +0.6,
+1.0, +1.2, +1.3, +1.2, +1.0, +0.5, -0.1, -1.1,
-2.5, -4.3, -6.6, -9.3, -12.4, -15.8, -19.3, -23.1,
-26.9, -30.8, -34.7,
))
Copy link
Owner

Choose a reason for hiding this comment

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

no, bad

soundfile['format'] = sf.format_info + ' ' + sf.subtype_info
soundfile['format'] = f'{sf.format_info} {sf.subtype_info}'
Copy link
Owner

Choose a reason for hiding this comment

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

@sourcery-ai I don't see a "simplify conditional" in this file.

file_format = sf.format_info + ' ' + sf.subtype_info
file_format = f'{sf.format_info} {sf.subtype_info}'
Copy link
Owner

Choose a reason for hiding this comment

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

This just re-orders the conditionals to put pass first? 🤔

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.

None yet

1 participant