-
Notifications
You must be signed in to change notification settings - Fork 8
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 #36
base: master
Are you sure you want to change the base?
Conversation
sections = [] | ||
for material in a.materials.keys(): | ||
sections.append('*SOLID SECTION, ELSET={0}, MATERIAL={0}\n'.format(material)) | ||
sections = [ | ||
'*SOLID SECTION, ELSET={0}, MATERIAL={0}\n'.format(material) | ||
for material in a.materials.keys() | ||
] | ||
|
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 Material.add_sections
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
abaqus_format = ['\n** -------------------------------------------------------------\n'] | ||
abaqus_format.append('**\n** STEP: {0}\n**\n'.format(step_name)) | ||
abaqus_format = [ | ||
'\n** -------------------------------------------------------------\n', | ||
'**\n** STEP: {0}\n**\n'.format(step_name), | ||
] | ||
|
||
nlgeom = modules['step_options']['nlgeom'] | ||
increment = modules['step_options']['inc'] | ||
abaqus_format.append('*Step, name={0}, nlgeom={1}, inc={2}\n' | ||
.format(step_name, nlgeom, increment)) | ||
for module_name, module_items in modules.items(): | ||
if module_name == 'step_options': | ||
continue |
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 Procedure.__format
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Extract guard clause from elif block (
guard
) - Merge append into list declaration (
merge-list-append
)
ax = parsed_options['ax'] if parsed_options['ax'] else plt.figure().add_subplot() | ||
ax = parsed_options['ax'] or plt.figure().add_subplot() |
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 plot_grain_characteristic
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
if edge_sum > 0: | ||
orientation = 'cw' | ||
else: | ||
orientation = 'ccw' | ||
return orientation | ||
return 'cw' if edge_sum > 0 else 'ccw' |
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 polygon_orientation
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for vertex in range(n_branch - 1): | ||
for _ in range(n_branch - 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 branches2boundary
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
ax = method_options['ax'] if method_options['ax'] else plt.figure().add_subplot() | ||
ax = method_options['ax'] or plt.figure().add_subplot() |
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 Polygon.plot
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
)
node_groups = {} | ||
for group_name in group_names: | ||
node_groups[group_name] = mesh.getGroupArr(1, group_name).toNumPyArray() | ||
node_groups = { | ||
group_name: mesh.getGroupArr(1, group_name).toNumPyArray() | ||
for group_name in group_names | ||
} | ||
|
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 get_nodes
refactored with the following changes:
- Convert for loop into dictionary comprehension (
dict-comprehension
)
repr_OOF = "QuadSkeleton(left_right_periodicity={1}, " \ | ||
return "QuadSkeleton(left_right_periodicity={1}, " \ | ||
"top_bottom_periodicity={2})".format(self.leftright_periodicity, | ||
self.topbottom_periodicity) | ||
return repr_OOF |
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 QuadSkeletonGeometry.__repr__
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
repr_OOF = "TriSkeleton(arrangement='{0}', left_right_periodicity={1}, " \ | ||
return "TriSkeleton(arrangement='{0}', left_right_periodicity={1}, " \ | ||
"top_bottom_periodicity={2})".format(self.arrangement, | ||
self.leftright_periodicity, | ||
self.topbottom_periodicity) | ||
return repr_OOF |
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 TriSkeletonGeometry.__repr__
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if args: | ||
image = args[0] | ||
else: | ||
image = self.original_image | ||
image = args[0] if args else self.original_image |
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.initial_segmentation
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.07%.
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! Let us know what you think of it by mentioning @sourcery-ai in a comment. |
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: