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
if __name__ == "__main__" : | ||
if __name__ == "__main__": | ||
explain_out = os.path.join(explain_out, '0 Specific Subjects') | ||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
model_names = [] | ||
for checkpoint in model_checkpoints: | ||
model_names.append(os.path.basename(checkpoint).split('.')[0]) | ||
|
||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
model_names = [ | ||
os.path.basename(checkpoint).split('.')[0] | ||
for checkpoint in model_checkpoints | ||
] | ||
|
||
if len(sys.argv) > 1: | ||
modelID = int(sys.argv[1]) | ||
print("Only explaining Model ID : "+str(modelID) +" "+ model_names[modelID]) | ||
print(f"Only explaining Model ID : {modelID} {model_names[modelID]}") | ||
model_names = [model_names[modelID]] | ||
model_checkpoints = [model_checkpoints[modelID]] | ||
print(str(len(model_checkpoints))+" model(s) explaining") | ||
print(f"{len(model_checkpoints)} model(s) explaining") |
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 136-169
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Use f-string instead of string concatenation [×4] (
use-fstring-for-concatenation
) - Replace if statement with if expression (
assign-if-exp
) - Remove unnecessary calls to
str()
from formatted values in f-strings [×2] (remove-str-from-fstring
)
if __name__ == "__main__" : | ||
if __name__ == "__main__": | ||
explain_out = os.path.join(explain_out, '0 Specific Subjects') | ||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
model_names = [] | ||
for checkpoint in model_checkpoints: | ||
model_names.append(os.path.basename(checkpoint).split('.')[0]) | ||
|
||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
model_names = [ | ||
os.path.basename(checkpoint).split('.')[0] | ||
for checkpoint in model_checkpoints | ||
] |
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 115-182
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Replace if statement with if expression (
assign-if-exp
)
|
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.
Found the following improvement in Lines 133-133
:
if __name__ == "__main__" : | ||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
if __name__ == "__main__": | ||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") |
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 82-110
refactored with the following changes:
- Remove unnecessary calls to
enumerate
when the index is not used (remove-unused-enumerate
)
if __name__ == "__main__" : | ||
if __name__ == "__main__": | ||
explain_out = os.path.join(explain_out, '0 Specific Subjects') | ||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
model_names = [] | ||
for checkpoint in model_checkpoints: | ||
model_names.append(os.path.basename(checkpoint).split('.')[0]) | ||
|
||
device = torch.device("cuda:0" if torch.cuda.is_available() and useCuda else "cpu") | ||
model_names = [ | ||
os.path.basename(checkpoint).split('.')[0] | ||
for checkpoint in model_checkpoints | ||
] | ||
|
||
if len(sys.argv) > 1: | ||
modelID = int(sys.argv[1]) | ||
print("Only explaining Model ID : "+str(modelID) +" "+ model_names[modelID]) | ||
print(f"Only explaining Model ID : {modelID} {model_names[modelID]}") | ||
model_names = [model_names[modelID]] | ||
model_checkpoints = [model_checkpoints[modelID]] | ||
print(str(len(model_checkpoints))+" model(s) explaining") | ||
print(f"{len(model_checkpoints)} model(s) explaining") |
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 148-302
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Use f-string instead of string concatenation [×4] (
use-fstring-for-concatenation
) - Remove unnecessary calls to
str()
from formatted values in f-strings [×2] (remove-str-from-fstring
)
print(str(ex)) | ||
|
||
print(ex) | ||
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 6-44
refactored with the following changes:
- Remove unnecessary call to
str()
withinprint()
(remove-str-from-print
) - Merge dictionary assignment with declaration [×4] (
merge-dict-assign
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.61%.
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!