-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
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.
Due to GitHub API limits, only the first 60 comments can be shown.
@@ -6,6 +6,7 @@ Create a database suitable for use with MKDA toolbox | |||
@copyright: University of Warwick 2013-2014 | |||
""" | |||
|
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 36-50
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Merge dictionary assignment with declaration (
merge-dict-assign
) - Replace
dict()
with{}
(dict-literal
)
@@ -7,6 +7,7 @@ specification. The path to feat directory must be passed as first argument. | |||
@copyright: University of Warwick 2013-2014 | |||
""" | |||
|
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 28-28
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
print('Downloading ' + nidmpack) | ||
print(f'Downloading {nidmpack}') |
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 14-14
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
out_dirname = out_dirname+".nidm" | ||
out_dirname = f"{out_dirname}.nidm" | ||
else: | ||
out_dirname = out_dirname+".nidm.zip" | ||
out_dirname = f"{out_dirname}.nidm.zip" | ||
out_dir = os.path.join(out_path, out_dirname) | ||
|
||
# Quit if output path already exists and user doesn't want to overwrite | ||
# it | ||
if os.path.exists(out_dir): | ||
msg = out_dir+" already exists, overwrite?" | ||
if not input("%s (y/N) " % msg).lower() == 'y': | ||
msg = f"{out_dir} already exists, overwrite?" | ||
if input(f"{msg} (y/N) ").lower() != 'y': |
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 NIDMExporter.__init__
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Simplify logical expression using De Morgan identities (
de-morgan
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
if not export_file: | ||
export_dir = None | ||
else: | ||
export_dir = self.export_dir | ||
|
||
export_dir = None if not export_file else self.export_dir |
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 NIDMExporter.add_object
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
filename = 'Contrast' + self.num + '.nii.gz' | ||
filename = f'Contrast{self.num}.nii.gz' | ||
self.file = NIDMFile(self.id, contrast_file, filename, sha=sha, | ||
fmt=fmt) | ||
self.coord_space = coord_space | ||
self.type = NIDM_CONTRAST_MAP | ||
self.prov_type = PROV['Entity'] | ||
if label is None: | ||
if self.name: | ||
self.label = "Contrast Map: " + self.name | ||
else: | ||
self.label = None | ||
self.label = f"Contrast Map: {self.name}" if self.name else 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 ContrastMap.__init__
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Replace if statement with if expression (
assign-if-exp
)
def get_query(klass, oid=None): | ||
if oid is None: | ||
oid_var = "?oid" | ||
else: | ||
oid_var = "<" + str(oid) + ">" | ||
|
||
query = """ | ||
def get_query(cls, oid=None): | ||
oid_var = "?oid" if oid is None else f"<{str(oid)}>" | ||
return ( | ||
""" | ||
prefix nidm_ContrastMap: <http://purl.org/nidash/nidm#NIDM_0000002> | ||
|
||
SELECT DISTINCT * WHERE { | ||
""" + oid_var + """ a nidm_ContrastMap: ; | ||
""" | ||
+ oid_var | ||
+ """ a nidm_ContrastMap: ; |
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 ContrastMap.get_query
refactored with the following changes:
- The first argument to class methods should be
cls
(class-method-first-arg-name
) - Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
def get_query(klass, oid=None): | ||
if oid is None: | ||
oid_var = "?oid" | ||
else: | ||
oid_var = "<" + str(oid) + ">" | ||
|
||
query = """ | ||
def get_query(cls, oid=None): | ||
oid_var = "?oid" if oid is None else f"<{str(oid)}>" | ||
return ( | ||
""" | ||
prefix nidm_ContrastExplainedMeanSquareMap: <http://purl.org/nidash/nidm#NIDM_\ | ||
0000163> | ||
|
||
SELECT DISTINCT * WHERE { | ||
""" + oid_var + """ a nidm_ContrastExplainedMeanSquareMap: ; | ||
""" | ||
+ oid_var | ||
+ """ a nidm_ContrastExplainedMeanSquareMap: ; |
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 ContrastExplainedMeanSquareMap.get_query
refactored with the following changes:
- The first argument to class methods should be
cls
(class-method-first-arg-name
) - Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
std_filename = "ContrastStandardError" + self.num + ".nii.gz" | ||
std_filename = f"ContrastStandardError{self.num}.nii.gz" |
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 ContrastStdErrMap.__init__
refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
def get_query(klass, oid=None): | ||
if oid is None: | ||
oid_var = "?oid" | ||
else: | ||
oid_var = "<" + str(oid) + ">" | ||
|
||
query = """ | ||
def get_query(cls, oid=None): | ||
oid_var = "?oid" if oid is None else f"<{str(oid)}>" | ||
return ( | ||
""" | ||
prefix nidm_ContrastStandardErrorMap: <http://purl.org/nidash/nidm#NIDM_000001\ | ||
3> | ||
prefix nidm_ContrastVarianceMap: <http://purl.org/nidash/nidm#NIDM_0000135> | ||
|
||
SELECT DISTINCT * WHERE { | ||
""" + oid_var + """ a nidm_ContrastStandardErrorMap: ; | ||
""" | ||
+ oid_var | ||
+ """ a nidm_ContrastStandardErrorMap: ; | ||
rdfs:label ?label ; | ||
prov:atLocation ?filepath ; | ||
nfo:fileName ?filename ; | ||
dct:format ?fmt ; | ||
crypto:sha512 ?sha . | ||
|
||
OPTIONAL {""" + oid_var + """ prov:wasDerivedFrom ?derfrom_id . | ||
OPTIONAL {""" | ||
+ oid_var | ||
+ """ prov:wasDerivedFrom ?derfrom_id . |
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 ContrastStdErrMap.get_query
refactored with the following changes:
- The first argument to class methods should be
cls
(class-method-first-arg-name
) - Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation
)
Hello @sourcery-ai[bot]! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
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!