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 #1
base: master
Are you sure you want to change the base?
Conversation
return np.asarray([x for x in dp.process_sequence(frames)]) | ||
return np.asarray(list(dp.process_sequence(frames))) | ||
|
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 _dataprocessor_to_function
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
return np.asarray([x for x in dp]) | ||
return np.asarray(list(dp)) | ||
|
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 _source_to_function
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
if not funname in alldps: | ||
if funname not in alldps: | ||
if issubclass(cls, Source): | ||
exec('%s = _source_to_function(%s)' % (funname, clsname)) | ||
exec(f'{funname} = _source_to_function({clsname})') | ||
else: | ||
exec('%s = _dataprocessor_to_function(%s)' % (funname, clsname)) | ||
exec(f'{funname} = _dataprocessor_to_function({clsname})') | ||
|
||
__all__.append(clsname) | ||
__all__.append(funname) | ||
__all__.extend((clsname, funname)) |
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.
Lines 94-101
refactored with the following changes:
- Merge consecutive list appends into a single extend (
merge-list-appends-into-extend
) - Simplify logical expression using De Morgan identities (
de-morgan
) - Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
if frame.ndim > 1: | ||
mono_frame = frame.mean(1) | ||
else: | ||
mono_frame = frame | ||
return mono_frame | ||
return frame.mean(1) if frame.ndim > 1 else frame |
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 Mono.process_frame
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if not 'next' in dir(samples): | ||
samples = (x for x in [samples]) | ||
if 'next' not in dir(samples): | ||
samples = iter([samples]) | ||
|
||
# nhop cannot be less than 1 for normal behavior | ||
noverlap = self.nwin - self.nhop | ||
|
||
buf = samples.next().copy() | ||
while len(buf) < self.nwin: | ||
buf = np.concatenate((buf, samples.next())) | ||
|
||
frame = buf[:self.nwin] | ||
buf = buf[self.nwin:] | ||
|
||
while True: | ||
yield frame.copy() | ||
frame[:noverlap] = frame[self.nhop:] | ||
|
||
try: | ||
while len(buf) < self.nhop: | ||
buf = np.concatenate((buf, samples.next())) | ||
except StopIteration: | ||
break | ||
|
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 Framer.process_sequence
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
) - Simplify generator expression (
simplify-generator
) - Replace unused for index with underscore (
for-index-underscore
)
mono_frames = np.array([x for x in gen]) | ||
mono_frames = np.array(list(gen)) |
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 TestSimpleComponents.test_mono
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
test_frames = np.array([x for x in gen]) | ||
test_frames = np.array(list(gen)) |
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 TestSimpleComponents.test_fft_ifft_perfect_reconstruction
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
|
||
class DP(DataProcessor): | ||
def process_frame(self, frame): | ||
return 2 * frame | ||
|
||
frames = np.random.rand(50, 2); | ||
dpframes = np.asarray([x for x in DP().process_sequence(frames)]) | ||
dpframes = np.asarray(list(DP().process_sequence(frames))) |
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 TestDataProcessor.test_process_frame
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
|
||
class DP(DataProcessor): | ||
def process_sequence(self, frames): | ||
for frame in frames: | ||
yield 2 * frame | ||
|
||
frames = np.random.rand(50, 2); | ||
dpframes = np.asarray([x for x in DP().process_sequence(frames)]) | ||
dpframes = np.asarray(list(DP().process_sequence(frames))) |
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 TestDataProcessor.test_iter
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
@@ -38,14 +40,15 @@ def process_sequence(self, frames): | |||
|
|||
class TestPipeline(unittest.TestCase): | |||
def test_pipeline(self): | |||
|
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 TestPipeline.test_pipeline
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.36%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
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! |
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:Help us improve this pull request!