-
Notifications
You must be signed in to change notification settings - Fork 4
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 Starbot ⭐ refactored AgainstEntropy/NLOS-Track #4
base: main
Are you sure you want to change the base?
Conversation
assert model_name in ['PAC_Net', 'P_Net', 'C_Net', 'baseline'] | ||
assert model_name in {'PAC_Net', 'P_Net', 'C_Net', 'baseline'} |
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 PAC_Cell.__init__
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
assert model_name in ['PAC_Net', 'P_Net', 'C_Net', 'baseline'] | ||
assert model_name in {'PAC_Net', 'P_Net', 'C_Net', 'baseline'} |
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 PAC_Net_Base.__init__
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
hx = self.warmup_rnn(fx)[1] # (2, B, D) | ||
|
||
return hx | ||
return self.warmup_rnn(fx)[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 C_Net.warm_up
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# (2, B, D)
dist_cfgs['distributed'] = True if world_size > 1 else False | ||
dist_cfgs['distributed'] = world_size > 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 main
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
if phase == 'train': | ||
if phase == 'test': | ||
return full_dataset | ||
elif phase == 'train': | ||
train_size = int(len(full_dataset) * train_ratio) | ||
val_size = len(full_dataset) - train_size | ||
return random_split(full_dataset, [train_size, val_size]) | ||
elif phase == 'test': | ||
return full_dataset |
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 split_dataset
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
)
for step in range(len_loader): | ||
for _ in range(len_loader): |
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 Trainer_tracking.train
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
logger.info(f'Performance on validation set at epoch: {epoch + 1}\n' + res_table.get_string()) | ||
logger.info( | ||
f'Performance on validation set at epoch: {epoch + 1}\n{res_table.get_string()}' | ||
) | ||
|
||
return (self.val_metrics['x_loss'], self.val_metrics['v_loss']), \ | ||
(self.val_metrics['pcm'], self.val_metrics['area'], self.val_metrics['dtw']) | ||
(self.val_metrics['pcm'], self.val_metrics['area'], self.val_metrics['dtw']) |
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 Trainer_tracking.val
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
assert phase in ['train', 'val'] | ||
assert phase in {'train', 'val'} |
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 Trainer_tracking.test_plot
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
)
fig.colorbar(line, ax=ax, ticks=idxs[::int(len(idxs) / 10)], label='step') | ||
fig.colorbar(line, ax=ax, ticks=idxs[::len(idxs) // 10], label='step') |
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 draw_route
refactored with the following changes:
- Simplify division expressions (
simplify-division
)
assert return_mode in ['plt_fig', 'fig_array', None] | ||
assert return_mode in {'plt_fig', 'fig_array', None} |
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 draw_routes
refactored with the following changes:
- Use set when checking membership of a collection of literals (
collection-into-set
) - Simplify division expressions (
simplify-division
)
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
main
branch, then run: