-
Notifications
You must be signed in to change notification settings - Fork 3
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 #34
Conversation
tokens = [] | ||
for attr in ["note", "vel", "ctl", "val"]: | ||
if hasattr(self, attr): | ||
tokens.append("%s%i" % (attr[0], getattr(self, attr))) | ||
tokens = [ | ||
"%s%i" % (attr[0], getattr(self, attr)) | ||
for attr in ["note", "vel", "ctl", "val"] | ||
if hasattr(self, attr) | ||
] | ||
|
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.
Function Note.__str__ refactored with the following changes:
- Convert for loop into list comprehension
if self.vel == 0: | ||
vv = " " | ||
else: | ||
vv = "{:02X}".format(self.vel - 1) | ||
if self.module == 0: | ||
mmmm = " " | ||
else: | ||
mmmm = "{:04X}".format(self.module - 1) | ||
vv = " " if self.vel == 0 else "{:02X}".format(self.vel - 1) | ||
mmmm = " " if self.module == 0 else "{:04X}".format(self.module - 1) |
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.
Function Note.tabular_repr refactored with the following changes:
- Split conditional into multiple branches
- Merge duplicate blocks in conditional
- Remove redundant conditional
- Replace if statement with if expression
for track_no in range(self.tracks): | ||
for _ in range(self.tracks): |
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.
Function Pattern.clear refactored with the following changes:
- Replace unused for index with underscore
for chunk in pattern.iff_chunks(): | ||
yield chunk | ||
yield from pattern.iff_chunks() | ||
yield (b"PEND", b"") | ||
for i, module in enumerate(self.modules): | ||
if module is not None: | ||
for chunk in module.iff_chunks(): | ||
yield chunk | ||
yield from module.iff_chunks() |
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.
Function Project.chunks refactored with the following changes:
- Simplify sequence comparison
- Replace yield inside for loop with yield from
pattern_lines = [] | ||
for index, pattern in active_patterns: | ||
pattern_lines.append( | ||
PatternLine(index, pattern.source or index, line - pattern.x) | ||
) | ||
pattern_lines = [ | ||
PatternLine(index, pattern.source or index, line - pattern.x) | ||
for index, pattern in active_patterns | ||
] | ||
|
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.
Function Project.pattern_lines refactored with the following changes:
- Convert for loop into list comprehension
if chunk.chnm == 1: | ||
elif chunk.chnm == 1: |
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.
Function MultiCtl.load_chunk refactored with the following changes:
- Simplify conditional into switch-like form
if gains and len(gains) == 1: | ||
gain = list(gains).pop() | ||
else: | ||
gain = 256 | ||
gain = list(gains).pop() if gains and len(gains) == 1 else 256 |
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.
Function MultiCtl.macro refactored with the following changes:
- Replace if statement with if expression
for chunk in self.nv_curve.chunks(): | ||
yield chunk | ||
for chunk in super(MultiSynth, self).specialized_iff_chunks(): | ||
yield chunk | ||
for chunk in self.vv_curve.chunks(): | ||
yield chunk | ||
yield from self.nv_curve.chunks() | ||
yield from super(MultiSynth, self).specialized_iff_chunks() | ||
yield from self.vv_curve.chunks() |
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.
Function MultiSynth.specialized_iff_chunks refactored with the following changes:
- Replace yield inside for loop with yield from
for chunk in iter: | ||
yield chunk | ||
for chunk in super(Sampler, self).specialized_iff_chunks(): | ||
yield chunk | ||
yield from iter | ||
yield from super(Sampler, self).specialized_iff_chunks() | ||
for i, sample in enumerate(self.samples): | ||
if sample is not None: | ||
for chunk in self.sample_chunks(i, sample): | ||
yield chunk | ||
yield from self.sample_chunks(i, sample) |
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.
Function Sampler.specialized_iff_chunks refactored with the following changes:
- Replace yield inside for loop with yield from
for chunk in self.harmonic_freqs.chunks(): | ||
yield chunk | ||
for chunk in self.harmonic_volumes.chunks(): | ||
yield chunk | ||
for chunk in self.harmonic_widths.chunks(): | ||
yield chunk | ||
for chunk in self.harmonic_types.chunks(): | ||
yield chunk | ||
for chunk in super(SpectraVoice, self).specialized_iff_chunks(): | ||
yield chunk | ||
yield from self.harmonic_freqs.chunks() | ||
yield from self.harmonic_volumes.chunks() | ||
yield from self.harmonic_widths.chunks() | ||
yield from self.harmonic_types.chunks() | ||
yield from super(SpectraVoice, self).specialized_iff_chunks() |
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.
Function SpectraVoice.specialized_iff_chunks refactored with the following changes:
- Replace yield inside for loop with yield from
for chunk in super(VorbisPlayer, self).specialized_iff_chunks(): | ||
yield chunk | ||
yield from super(VorbisPlayer, self).specialized_iff_chunks() |
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.
Function VorbisPlayer.specialized_iff_chunks refactored with the following changes:
- Replace yield inside for loop with yield from
for chunk in self.curve.chunks(): | ||
yield chunk | ||
for chunk in super(WaveShaper, self).specialized_iff_chunks(): | ||
yield chunk | ||
yield from self.curve.chunks() | ||
yield from super(WaveShaper, self).specialized_iff_chunks() |
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.
Function WaveShaper.specialized_iff_chunks refactored with the following changes:
- Replace yield inside for loop with yield from
if self._index > 0: | ||
self.object = Module(index=self._index) | ||
else: | ||
self.object = Output() | ||
self.object = Module(index=self._index) if self._index > 0 else Output() |
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.
Function ModuleReader.process_chunks refactored with the following changes:
- Replace if statement with if expression
self._controller_keys = list( | ||
self._controller_keys = [ | ||
name | ||
for name, controller in new_module.controllers.items() | ||
if controller.attached(new_module) | ||
) | ||
] | ||
|
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.
Function ModuleReader.process_STYP refactored with the following changes:
- Replace list(), dict() or set() with comprehension
links = self.object.incoming_links | ||
if len(data) > 0: | ||
link_count = len(data) // 4 | ||
structure = "<" + "i" * link_count | ||
links = self.object.incoming_links |
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.
Function ModuleReader.process_SLNK refactored with the following changes:
- Move assignments closer to their usage
rv/tools/patch_decompiler.py
Outdated
return ( | ||
return (( | ||
(p[0] == q[0] and abs(p[1] - q[1]) == 1) | ||
or (p[1] == q[1] and abs(p[0] - q[0]) == 1) | ||
) and not ((abs(p[0] - q[0]) == 1) and abs(p[1] - q[1]) == 1) | ||
)) and (abs(p[0] - q[0]) != 1 or abs(p[1] - q[1]) != 1) |
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.
Function module_layout.is_neighbour refactored with the following changes:
- Simplify logical expression
for i in range(n - 1): | ||
for _ in range(n - 1): |
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.
Function module_layout.sample refactored with the following changes:
- Replace unused for index with underscore
return sum([(s[i] - head[i]) ** 2 for i in range(2)]) | ||
return sum((s[i] - head[i]) ** 2 for i in range(2)) |
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.
Function module_layout.compactness.err refactored with the following changes:
- Replace unneeded comprehension with generator
for i in range(tries): | ||
for _ in range(tries): |
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.
Function module_layout.best refactored with the following changes:
- Replace unused for index with underscore
npatches = len(list(set([patch["name"] for patch in patches]))) | ||
npatches = len(list({patch["name"] for patch in patches})) |
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.
Function main refactored with the following changes:
- Replace unneeded comprehension with generator
- Replace list(), dict() or set() with comprehension
c6963ab
to
280aec9
Compare
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: