Skip to content

Sourcery Starbot ⭐ refactored jaekookang/p2fa_py3 #8

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

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

Conversation

SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

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

git fetch https://github.com/sourcery-ai-bot/p2fa_py3 master
git merge --ff-only FETCH_HEAD
git reset HEAD^

if len(val) == 0:
if not val:
Copy link
Author

Choose a reason for hiding this comment

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

Function getopt2 refactored with the following changes:

Comment on lines -47 to +48
if wave_end is not None:
soxopts += " " + str(float(wave_end) - float(wave_start))
if wave_end is not None:
soxopts += " " + str(float(wave_end) - float(wave_start))
Copy link
Author

Choose a reason for hiding this comment

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

Function prep_wav refactored with the following changes:

Comment on lines -131 to +136
fw = open(mlffile, 'w')
fw.write('#!MLF!#\n')
fw.write('"*/tmp.lab"\n')
for wrd in words:
fw.write(wrd + '\n')
fw.write('.\n')
fw.close()
with open(mlffile, 'w') as fw:
fw.write('#!MLF!#\n')
fw.write('"*/tmp.lab"\n')
for wrd in words:
fw.write(wrd + '\n')
fw.write('.\n')
Copy link
Author

Choose a reason for hiding this comment

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

Function write_input_mlf refactored with the following changes:

Comment on lines -239 to +238
def write_text_grid(outfile, word_alignments, state_alignments=None) :
def write_text_grid(outfile, word_alignments, state_alignments=None):
Copy link
Author

Choose a reason for hiding this comment

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

Function write_text_grid refactored with the following changes:

fw = open(os.path.join(TEMP_DIR, 'codetr.scp'), 'w')
fw.write(wavfile + ' ' + os.path.join(TEMP_DIR, 'tmp.plp') + '\n')
fw.close()
fw = open(os.path.join(TEMP_DIR, 'test.scp'), 'w')
fw.write(os.path.join(TEMP_DIR, 'tmp.plp') + '\n')
fw.close()
with open(os.path.join(TEMP_DIR, 'codetr.scp'), 'w') as fw:
fw.write(wavfile + ' ' + os.path.join(TEMP_DIR, 'tmp.plp') + '\n')
with open(os.path.join(TEMP_DIR, 'test.scp'), 'w') as fw:
fw.write(os.path.join(TEMP_DIR, 'tmp.plp') + '\n')
Copy link
Author

Choose a reason for hiding this comment

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

Function prep_scp refactored with the following changes:

Comment on lines -349 to +344
if state_align:
salign = ' -f -y lab'
else:
salign = ''

salign = ' -f -y lab' if state_align else ''
Copy link
Author

Choose a reason for hiding this comment

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

Function viterbi refactored with the following changes:

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 29, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 11.35 🙂 11.42 🙂 0.07 👎
Method Length 118.59 🙂 117.59 🙂 -1.00 👍
Working memory 15.83 ⛔ 15.89 ⛔ 0.06 👎
Quality 43.42% 😞 43.07% 😞 -0.35% 👎
Other metrics Before After Change
Lines 434 425 -9
Changed files Quality Before Quality After Quality Change
bin/p2fa 76.45% ⭐ 76.62% ⭐ 0.17% 👍
p2fa/align.py 41.51% 😞 41.09% 😞 -0.42% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
p2fa/align.py align 17 🙂 323 ⛔ 25 ⛔ 22.38% ⛔ Try splitting into smaller methods. Extract out complex expressions
p2fa/align.py prep_mlf 20 😞 223 ⛔ 23 ⛔ 25.12% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
p2fa/align.py write_text_grid 14 🙂 516 ⛔ 11 😞 35.03% 😞 Try splitting into smaller methods. Extract out complex expressions
p2fa/align.py read_aligned_mlf 9 🙂 196 😞 17 ⛔ 39.94% 😞 Try splitting into smaller methods. Extract out complex expressions
p2fa/align.py prep_wav 12 🙂 178 😞 14 😞 42.09% 😞 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!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

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.

1 participant