| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -7,4 +7,4 @@ | |
| parser.add_argument('-n', '--name', metavar='name', | ||
| default='World', help='Name to greet') | ||
| args = parser.parse_args() | ||
| print('Hello, ' + args.name + '!') | ||
| print(f'Hello, {args.name}!') | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityLines 10-10 refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -8,7 +8,7 @@ def main(): | |
| parser.add_argument('-n', '--name', metavar='name', | ||
| default='World', help='Name to greet') | ||
| args = parser.parse_args() | ||
| print('Hello, ' + args.name + '!') | ||
| print(f'Hello, {args.name}!') | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -11,7 +11,7 @@ def get_args(): | |
|
|
||
| def main(): | ||
| args = get_args() | ||
| print('Hello, ' + args.name + '!') | ||
| print(f'Hello, {args.name}!') | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -21,7 +21,7 @@ def main(): | |
| """Make a jazz noise here""" | ||
|
|
||
| args = get_args() | ||
| print('Hello, ' + args.name + '!') | ||
| print(f'Hello, {args.name}!') | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
|
|
||
| # -------------------------------------------------- | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -42,7 +42,7 @@ def main(): | |
| elif num == 2: | ||
| bringing = ' and '.join(items) | ||
| else: | ||
| items[-1] = 'and ' + items[-1] | ||
| items[-1] = f'and {items[-1]}' | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| bringing = ', '.join(items) | ||
|
|
||
| print('You are bringing {}.'.format(bringing)) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -26,9 +26,7 @@ def main(): | |
| '6': '4', '7': '3', '8': '2', '9': '1', '0': '5'} | ||
|
|
||
| # Method 2: for loop to build new string | ||
| new_text = '' | ||
| for char in args.text: | ||
| new_text += jumper.get(char, char) | ||
| new_text = ''.join(jumper.get(char, char) for char in args.text) | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| print(new_text) | ||
|
|
||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -26,9 +26,7 @@ def main(): | |
| '6': '4', '7': '3', '8': '2', '9': '1', '0': '5'} | ||
|
|
||
| # Method 3: for loop to build new list | ||
| new_text = [] | ||
| for char in args.text: | ||
| new_text.append(jumper.get(char, char)) | ||
| new_text = [jumper.get(char, char) for char in args.text] | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| print(''.join(new_text)) | ||
|
|
||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -34,10 +34,7 @@ def main(): | |
|
|
||
| args = get_args() | ||
|
|
||
| lookup = {} | ||
| for line in args.file: | ||
| lookup[line[0].upper()] = line.rstrip() | ||
|
|
||
| lookup = {line[0].upper(): line.rstrip() for line in args.file} | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| for letter in args.letter: | ||
| if letter.upper() in lookup: | ||
| print(lookup[letter.upper()]) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -43,12 +43,14 @@ def verse(bottle): | |
| s1 = '' if bottle == 1 else 's' | ||
| s2 = '' if next_bottle == 1 else 's' | ||
| num_next = 'No more' if next_bottle == 0 else next_bottle | ||
| return '\n'.join([ | ||
| f'{bottle} bottle{s1} of beer on the wall,', | ||
| f'{bottle} bottle{s1} of beer,', | ||
| f'Take one down, pass it around,', | ||
| f'{num_next} bottle{s2} of beer on the wall!', | ||
| ]) | ||
| return '\n'.join( | ||
| [ | ||
| f'{bottle} bottle{s1} of beer on the wall,', | ||
| f'{bottle} bottle{s1} of beer,', | ||
| 'Take one down, pass it around,', | ||
| f'{num_next} bottle{s2} of beer on the wall!', | ||
| ] | ||
| ) | ||
|
Comment thread
Comment on lines
-46
to
+53
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction verse refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
|
|
||
| # -------------------------------------------------- | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -39,10 +39,7 @@ def main(): | |
| random.seed(args.seed) | ||
|
|
||
| # Method 1: Iterate each character, add to list | ||
| ransom = [] | ||
| for char in args.text: | ||
| ransom.append(choose(char)) | ||
|
|
||
| ransom = [choose(char) for char in args.text] | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| print(''.join(ransom)) | ||
|
|
||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -39,10 +39,7 @@ def main(): | |
| random.seed(args.seed) | ||
|
|
||
| # Method 3: Iterate each character, add to a str | ||
| ransom = '' | ||
| for char in args.text: | ||
| ransom += choose(char) | ||
|
|
||
| ransom = ''.join(choose(char) for char in args.text) | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| print(''.join(ransom)) | ||
|
|
||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -76,7 +76,7 @@ def verse(day): | |
| lines.extend(reversed(gifts[:day])) | ||
|
|
||
| if day > 1: | ||
| lines[-1] = 'And ' + lines[-1].lower() | ||
| lines[-1] = f'And {lines[-1].lower()}' | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction verse refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| return '\n'.join(lines) | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -77,7 +77,7 @@ def verse(day): | |
| lines.extend(reversed(gifts[:day])) | ||
|
|
||
| if day > 1: | ||
| lines[-1] = 'And ' + lines[-1].lower() | ||
| lines[-1] = f'And {lines[-1].lower()}' | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction verse refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| return '\n'.join(lines) | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -98,7 +98,7 @@ def test_all(): | |
| os.remove(out_file) | ||
|
|
||
| try: | ||
| out = getoutput(cmd + f' -o {out_file}').rstrip() | ||
| out = getoutput(f'{cmd} -o {out_file}').rstrip() | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction test_all refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| assert out == '' | ||
| assert os.path.isfile(out_file) | ||
| output = open(out_file).read().rstrip() | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -44,21 +44,17 @@ def stemmer(word): | |
| vowels = 'aeiou' | ||
| consonants = ''.join( | ||
| [c for c in string.ascii_lowercase if c not in vowels]) | ||
| pattern = ( | ||
| '([' + consonants + ']+)?' # capture one or more, optional | ||
| '([' + vowels + '])' # capture at least one vowel | ||
| '(.*)' # capture zero or more of anything | ||
| ) | ||
| pattern = (((f'([{consonants}' + ']+)?' # capture one or more, optional | ||
| '([') + vowels) + '])' # capture at least one vowel | ||
| '(.*)') | ||
| pattern = f'([{consonants}]+)?([{vowels}])(.*)' | ||
|
|
||
| match = re.match(pattern, word) | ||
| if match: | ||
| p1 = match.group(1) or '' | ||
| p2 = match.group(2) or '' | ||
| p3 = match.group(3) or '' | ||
| return (p1, p2 + p3) | ||
| else: | ||
| if not (match := re.match(pattern, word)): | ||
| return (word, '') | ||
| p1 = match.group(1) or '' | ||
| p2 = match.group(2) or '' | ||
| p3 = match.group(3) or '' | ||
| return (p1, p2 + p3) | ||
|
Comment thread
Comment on lines
-47
to
+57
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction stemmer refactored with the following changes:
This removes the following comments ( why? ): # capture zero or more of anything
Sorry, something went wrong.
All reactions
|
||
|
|
||
|
|
||
| # -------------------------------------------------- | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -39,9 +39,9 @@ def stemmer(word): | |
| """Return leading consonants (if any), and 'stem' of word""" | ||
|
|
||
| word = word.lower() | ||
| vowel_pos = list(map(word.index, filter(lambda v: v in word, 'aeiou'))) | ||
|
|
||
| if vowel_pos: | ||
| if vowel_pos := list( | ||
| map(word.index, filter(lambda v: v in word, 'aeiou')) | ||
| ): | ||
|
Comment thread
Comment on lines
-42
to
+44
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction stemmer refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| first_vowel = min(vowel_pos) | ||
| return (word[:first_vowel], word[first_vowel:]) | ||
| else: | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -41,9 +41,10 @@ def fry(word): | |
| if word.lower() == 'you': | ||
| return word[0] + "'all" | ||
|
|
||
| if word.endswith('ing'): | ||
| if any(map(lambda c: c.lower() in 'aeiouy', word[:-3])): | ||
| return word[:-1] + "'" | ||
| if word.endswith('ing') and any( | ||
| map(lambda c: c.lower() in 'aeiouy', word[:-3]) | ||
| ): | ||
| return word[:-1] + "'" | ||
|
Comment thread
Comment on lines
-44
to
+47
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction fry refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| return word | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -60,7 +60,7 @@ def run_file(file): | |
| """run with file""" | ||
|
|
||
| assert os.path.isfile(file) | ||
| expected_file = file + '.out' | ||
| expected_file = f'{file}.out' | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction run_file refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| assert os.path.isfile(expected_file) | ||
| expected = open(expected_file).read() | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -48,7 +48,7 @@ def main(): | |
| pos = placeholder[1:-1] | ||
| article = 'an' if pos.lower()[0] in 'aeiou' else 'a' | ||
| answer = inputs.pop(0) if inputs else input(tmpl.format(article, pos)) | ||
| text = text[0:start] + answer + text[stop + 1:] | ||
| text = text[:start] + answer + text[stop + 1:] | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| had_placeholders = True | ||
|
|
||
| if had_placeholders: | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -85,8 +85,7 @@ def read_csv(fh): | |
| for row in csv.DictReader(fh, delimiter=','): | ||
| name, reps = row.get('exercise'), row.get('reps') | ||
| if name and reps: | ||
| match = re.match(r'(\d+)-(\d+)', reps) | ||
| if match: | ||
| if match := re.match(r'(\d+)-(\d+)', reps): | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction read_csv refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| low, high = map(int, match.groups()) | ||
| exercises.append((name, low, high)) | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -5,8 +5,5 @@ | |
|
|
||
| with open('inputs/exercises.csv') as fh: | ||
| reader = csv.DictReader(fh, delimiter=',') | ||
| records = [] | ||
| for rec in reader: | ||
| records.append(rec) | ||
|
|
||
| records = list(reader) | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityLines 8-11 refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| pprint(records) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -69,9 +69,10 @@ def main(): | |
| def format_board(board): | ||
| """Format the board""" | ||
|
|
||
| cells = [] | ||
| for i, char in enumerate(board, start=1): | ||
| cells.append(str(i) if char == '.' else char) | ||
| cells = [ | ||
| str(i) if char == '.' else char | ||
| for i, char in enumerate(board, start=1) | ||
| ] | ||
|
Comment thread
Comment on lines
-72
to
+75
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction format_board refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| bar = '-------------' | ||
| cells_tmpl = '| {} | {} | {} |' | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -220,7 +220,7 @@ def test_losing(): | |
| """test losing boards""" | ||
|
|
||
| losing_board = list('XXOO.....') | ||
| for i in range(10): | ||
| for _ in range(10): | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction test_losing refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| random.shuffle(losing_board) | ||
| out = getoutput(f'{prg} -b {"".join(losing_board)}').splitlines() | ||
| assert out[-1].strip() == 'No winner.' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -63,6 +63,6 @@ def test_losing(): | |
|
|
||
| losing_state = list('XXOO.....') | ||
|
|
||
| for i in range(10): | ||
| for _ in range(10): | ||
| random.shuffle(losing_state) | ||
| assert find_winner(''.join(losing_state)) == None | ||
| assert find_winner(''.join(losing_state)) is None | ||
|
Comment thread
Comment on lines
-66
to
+68
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction test_losing refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -22,7 +22,7 @@ def main(): | |
| """Make a jazz noise here""" | ||
|
|
||
| args = get_args() | ||
| print('Hello, ' + args.name + '!') | ||
| print(f'Hello, {args.name}!') | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
|
|
||
| # -------------------------------------------------- | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -180,8 +180,7 @@ def get_defaults(): | |
| defaults = {} | ||
| if os.path.isfile(rc): | ||
| for line in open(rc): | ||
| match = re.match('([^=]+)=([^=]+)', line) | ||
| if match: | ||
| if match := re.match('([^=]+)=([^=]+)', line): | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction get_defaults refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| key, val = map(str.strip, match.groups()) | ||
| if key and val: | ||
| defaults[key] = val | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -74,7 +74,7 @@ def test_space(): | |
| word = random.choice([' ', '\t']) | ||
| rv, out = getstatusoutput(f'{prg} "{word}"') | ||
| assert rv == 0 | ||
| assert out == f'input is space.' | ||
| assert out == 'input is space.' | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction test_space refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
|
|
||
| # -------------------------------------------------- | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -108,9 +108,12 @@ def run(input_seq, codons, expected): | |
| random_file = random_filename() | ||
| try: | ||
| flip = random.randint(0, 1) | ||
| out_file, out_arg = (random_file, | ||
| '-o ' + random_file) if flip == 1 else ('out.txt', | ||
| '') | ||
| out_file, out_arg = ( | ||
| (random_file, f'-o {random_file}') | ||
| if flip == 1 | ||
| else ('out.txt', '') | ||
| ) | ||
|
|
||
|
Comment thread
Comment on lines
-111
to
+116
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction run refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| print(f'{prg} -c {codons} {out_arg} {input_seq}') | ||
| rv, output = getstatusoutput(f'{prg} -c {codons} {out_arg} {input_seq}') | ||
|
|
||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -105,7 +105,7 @@ def test_defaults(): | |
| def test_options(): | ||
| """runs on good input""" | ||
|
|
||
| out_file = random_string() + '.fasta' | ||
| out_file = f'{random_string()}.fasta' | ||
|
Comment thread
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction test_options refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| try: | ||
| if os.path.isfile(out_file): | ||
| os.remove(out_file) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -65,15 +65,14 @@ def main(): | |
| out_file = os.path.join(args.outdir, basename) | ||
| print(f'{i:3}: {basename}') | ||
|
|
||
| out_fh = open(out_file, 'wt') | ||
| num_taken = 0 | ||
| with open(out_file, 'wt') as out_fh: | ||
| num_taken = 0 | ||
|
|
||
| for rec in SeqIO.parse(fh, 'fasta'): | ||
| if random.random() <= args.pct: | ||
| num_taken += 1 | ||
| SeqIO.write(rec, out_fh, 'fasta') | ||
| for rec in SeqIO.parse(fh, 'fasta'): | ||
| if random.random() <= args.pct: | ||
| num_taken += 1 | ||
| SeqIO.write(rec, out_fh, 'fasta') | ||
|
|
||
| out_fh.close() | ||
|
Comment thread
Comment on lines
-68
to
-76
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction main refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
| total_num += num_taken | ||
|
|
||
| num_files = len(args.file) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -123,10 +123,10 @@ def test_options(): | |
| files = os.listdir(out_dir) | ||
| assert len(files) == 3 | ||
|
|
||
| seqs_written = 0 | ||
| for file in files: | ||
| seqs_written += len( | ||
| list(SeqIO.parse(os.path.join(out_dir, file), 'fasta'))) | ||
| seqs_written = sum( | ||
| len(list(SeqIO.parse(os.path.join(out_dir, file), 'fasta'))) | ||
| for file in files | ||
| ) | ||
|
Comment thread
Comment on lines
-126
to
+129
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityFunction test_options refactored with the following changes:
Sorry, something went wrong.
All reactions
|
||
|
|
||
| assert seqs_written == 27688 | ||
| finally: | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityLines 9-9 refactored with the following changes:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.