-
Notifications
You must be signed in to change notification settings - Fork 2
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 #5
base: master
Are you sure you want to change the base?
Conversation
ids_train = df_train['img'] | ||
return ids_train | ||
return df_train['img'] |
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 ImageProcessor.split_data
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
assert phase == "train" or phase == "valid", r"phase has to be either'train' or 'valid'" | ||
assert phase in ["train", "valid"], r"phase has to be either'train' or 'valid'" |
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 DataGenerator.__init__
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
) - Replace if statement with if expression (
assign-if-exp
)
if self._phase == "train": | ||
img_path = './input/images/{}.png'.format(id) | ||
mask_path = './input/masks/{}.npy'.format(id) | ||
else: | ||
img_path = './input/images/{}.png'.format(id) | ||
mask_path = './input/masks/{}.npy'.format(id) | ||
|
||
mask_path = f'./input/masks/{id}.npy' | ||
img_path = f'./input/images/{id}.png' |
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 DataGenerator.get_image_paths
refactored with the following changes:
- Hoist repeated code outside conditional statement [×2] (
hoist-statement-from-if
) - Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
for i in range(self._batch_size): | ||
for _ in range(self._batch_size): | ||
indices.append(self._index) | ||
self._index += 1 | ||
self._totalcount += 1 | ||
self._index = self._index % self._len | ||
self._index %= self._len |
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 DataGenerator.__next__
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
) - Replace assignment with augmented assignment (
aug-assign
)
plt.imsave('./results/pred_{}.png'.format(i), im) | ||
plt.imsave('./results/gt_{}.png'.format(i), gt) | ||
plt.imsave(f'./results/pred_{i}.png', im) | ||
plt.imsave(f'./results/gt_{i}.png', gt) |
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 predict_model
refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting
)
i = 0 | ||
output = x | ||
for _, layer in self._modules.items(): | ||
for i, (_, layer) in enumerate(self._modules.items()): | ||
output = layer(output) | ||
if i % 2 == 0: | ||
output = cat([skip.pop(), output], 1) | ||
i += 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 Decoder.forward
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
if features_out: | ||
return output, output_bottleneck | ||
else: | ||
return output | ||
return (output, output_bottleneck) if features_out 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 Segmentation_model.forward
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
assert mode=="max" or mode=="min", "mode can only be /'min/' or /'max/'" | ||
assert mode in ["max", "min"], "mode can only be /'min/' or /'max/'" |
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 EarlyStoppingCallback.__init__
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
assert mode=="max" or mode=="min", "mode can only be /'min/' or /'max/'" | ||
assert mode in ["max", "min"], "mode can only be /'min/' or /'max/'" |
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 ModelCheckPointCallback.__init__
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
if self.entire_model: | ||
to_save = model | ||
else: | ||
to_save = model.state_dict() | ||
to_save = model if self.entire_model else model.state_dict() |
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 ModelCheckPointCallback.step
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
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!