-
Notifications
You must be signed in to change notification settings - Fork 117
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 #63
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.
print("running %s ..." % example_name, end="") | ||
print(f"running {example_name} ...", end="") |
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 worker
refactored with the following changes:
- Replace interpolated string formatting with f-string [×2] (
replace-interpolation-with-fstring
)
for i in range(n_rotations): | ||
for _ in range(n_rotations): |
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 rotating_cube_2_axis
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
x, y, z = [random.uniform(0, 1) for i in range(3)] | ||
x, y, z = [random.uniform(0, 1) for _ in range(3)] |
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 random_pnt
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
loc = TopLoc_Location(trsf) | ||
return loc | ||
return TopLoc_Location(trsf) |
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 location_from_vector
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
"http://m-selig.ae.illinois.edu/ads/coord_seligFmt/%s.dat" % self.profile | ||
f"http://m-selig.ae.illinois.edu/ads/coord_seligFmt/{self.profile}.dat" |
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 UiucAirfoil.make_shape
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
for i in range(0, 40): | ||
for i in range(40): |
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 faircurve
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
face = n_sided.Face() | ||
return face | ||
return n_sided.Face() |
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 make_n_sided
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if isinstance(pt, list) or isinstance(pt, tuple): | ||
if isinstance(pt, (list, tuple)): | ||
for i in pt: | ||
poly.Add(i) | ||
else: | ||
poly.Add(pt) | ||
poly.Build() | ||
poly.Close() | ||
result = poly.Wire() | ||
return result | ||
return poly.Wire() |
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 make_closed_polygon
refactored with the following changes:
- Merge isinstance calls (
merge-isinstance
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
edges = [i for i in TopologyExplorer(poly).edges()] | ||
edges = list(TopologyExplorer(poly).edges()) |
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 geom_plate
refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension
)
print("Goal: %s radius: %s" % (i, rcs.curr_radius)) | ||
print(f"Goal: {i} radius: {rcs.curr_radius}") |
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 solve_radius
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
face = make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-6) | ||
return face | ||
return make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-6) |
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 build_geom_plate
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
shp = cut.Shape() | ||
return shp | ||
return cut.Shape() |
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 boolean_cut
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
f3 = boolean_cut(f, f2) | ||
return f3 | ||
return boolean_cut(f, f2) |
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 make_face_to_contour_from
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
shape = feature_maker.Shape() | ||
return shape | ||
return feature_maker.Shape() |
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 add_feature
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
fuse = BRepAlgoAPI_Fuse(base, torus).Shape() | ||
return fuse | ||
return BRepAlgoAPI_Fuse(base, torus).Shape() |
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 boolean_fuse
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
# Remove the revolved shape | ||
cut = BRepAlgoAPI_Cut(base, moved_shape).Shape() | ||
return cut | ||
return BRepAlgoAPI_Cut(base, moved_shape).Shape() |
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 revolved_cut
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
This removes the following comments ( why? ):
# Remove the revolved shape
revolved_shape = revolved_cut(fused_shape) | ||
return revolved_shape | ||
return revolved_cut(fused_shape) |
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 generate_demo
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
cut_2 = BRepAlgoAPI_Cut(cut_1, rounding_cut_2).Shape() | ||
|
||
return cut_2 | ||
return BRepAlgoAPI_Cut(cut_1, rounding_cut_2).Shape() |
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 round_tooth
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
for i in range(0, 8): | ||
for i in range(8): |
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 clone_tooth
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
for i in range(0, mounting_hole_count): | ||
for i in range(mounting_hole_count): |
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 mounting_holes
refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range
)
if inter_1.Point(1).X() > 0: | ||
p1 = inter_1.Point(1) | ||
else: | ||
p1 = inter_1.Point(2) | ||
|
||
if inter_2.Point(1).X() > 0: | ||
p2 = inter_2.Point(1) | ||
else: | ||
p2 = inter_2.Point(2) | ||
|
||
if inter_3.Point(1).X() > 0: | ||
p3 = inter_3.Point(1) | ||
else: | ||
p3 = inter_3.Point(2) | ||
|
||
if inter_4.Point(1).X() > 0: | ||
p4 = inter_4.Point(1) | ||
else: | ||
p4 = inter_4.Point(2) | ||
|
||
p1 = inter_1.Point(1) if inter_1.Point(1).X() > 0 else inter_1.Point(2) | ||
p2 = inter_2.Point(1) if inter_2.Point(1).X() > 0 else inter_2.Point(2) | ||
p3 = inter_3.Point(1) if inter_3.Point(1).X() > 0 else inter_3.Point(2) | ||
p4 = inter_4.Point(1) if inter_4.Point(1).X() > 0 else inter_4.Point(2) |
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 cut_out
refactored with the following changes:
- Replace if statement with if expression [×4] (
assign-if-exp
) - Replace range(0, x) with range(x) (
remove-zero-from-range
)
sprocket = cut_out(mountable_disc) | ||
return sprocket | ||
return cut_out(mountable_disc) |
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 build_sprocket
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
_str_slices.append(":" + str(i * n) + " ") | ||
_str_slices.append(f":{str(i * n)} ") | ||
elif i == n_procs: | ||
# does a little extra work if the number of slices | ||
# isn't divisible by n_procs | ||
slices.append(z_slices[(i - 1) * n :]) | ||
_str_slices.append(str((i - 1) * n) + ": ") | ||
_str_slices.append(f"{str((i - 1) * n)}: ") | ||
print("last slice", len(z_slices[(i - 1) * n :])) | ||
else: | ||
slices.append(z_slices[(i - 1) * n : i * n]) | ||
_str_slices.append(" %s:%s " % ((i - 1) * n, i * n)) | ||
_str_slices.append(f" {(i - 1) * n}:{i * n} ") |
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 run
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Replace interpolated string formatting with f-string [×3] (
replace-interpolation-with-fstring
)
arr = np.random.uniform(-spread / 2.0, spread / 2.0, (n, 3)) | ||
for i in arr: | ||
yield i | ||
yield from np.random.uniform(-spread / 2.0, spread / 2.0, (n, 3)) | ||
except ImportError: | ||
n_ = n / 100 | ||
warnings.warn( | ||
"Numpy could not be imported... this example will run very SLOW" | ||
"drawing {} rather than {} lines".format(n_, n) | ||
f"Numpy could not be imported... this example will run very SLOWdrawing {n_} rather than {n} lines" | ||
) | ||
for i in range(n_): | ||
for _ in range(n_): |
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 generate_points
refactored with the following changes:
- Inline variable that is immediately yielded (
inline-immediately-yielded-variable
) - Replace yield inside for loop with yield from (
yield-from
) - Replace call to format with f-string (
use-fstring-for-formatting
) - Replace unused for index with underscore (
for-index-underscore
)
if buttons == QtCore.Qt.LeftButton and not modifiers == QtCore.Qt.ShiftModifier: | ||
if ( | ||
buttons == QtCore.Qt.LeftButton | ||
and modifiers != QtCore.Qt.ShiftModifier | ||
): | ||
self.current_action = ON_DYN_ROT | ||
|
||
# dynamic zoom | ||
elif ( | ||
buttons == QtCore.Qt.RightButton | ||
and not modifiers == QtCore.Qt.ShiftModifier | ||
and modifiers != QtCore.Qt.ShiftModifier | ||
): | ||
self.current_action = ON_DYN_ZOOM | ||
|
||
# dynamic panning | ||
elif buttons == QtCore.Qt.MidButton: | ||
self.current_action = ON_DYN_PAN | ||
|
||
# zoom window, overpaints rectangle | ||
elif buttons == QtCore.Qt.RightButton and modifiers == QtCore.Qt.ShiftModifier: | ||
elif buttons == QtCore.Qt.RightButton: | ||
self.current_action = ON_ZOOM_AREA | ||
|
||
# select area | ||
elif buttons == QtCore.Qt.LeftButton and modifiers == QtCore.Qt.ShiftModifier: | ||
elif buttons == QtCore.Qt.LeftButton: |
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 GLWidget.mouseMoveEvent
refactored with the following changes:
- Simplify logical expression using De Morgan identities [×2] (
de-morgan
) - Remove redundant conditional [×2] (
remove-redundant-if
)
This removes the following comments ( why? ):
# dynamic zoom
# select area
# zoom window, overpaints rectangle
# dynamic panning
if self._have_pyqt5: | ||
delta = event.angleDelta().y() | ||
else: | ||
delta = event.delta() | ||
|
||
if delta > 0: | ||
self.zoom_factor = 1.3 | ||
else: | ||
self.zoom_factor = 0.7 | ||
delta = event.angleDelta().y() if self._have_pyqt5 else event.delta() | ||
self.zoom_factor = 1.3 if delta > 0 else 0.7 |
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 GLWidget.wheelEvent
refactored with the following changes:
- Replace if statement with if expression [×2] (
assign-if-exp
)
if abs(dx) <= tolerance and abs(dy) <= tolerance: | ||
# zooming at a near nil value can segfault the opengl viewer | ||
pass | ||
else: | ||
if not self.is_right_mouse_button_surpressed: | ||
coords = [ | ||
self.point_on_mouse_press[0], | ||
self.point_on_mouse_press[1], | ||
self.point_on_mouse_move[0], | ||
self.point_on_mouse_move[1], | ||
] | ||
self._display.ZoomArea(*coords) | ||
if ( | ||
abs(dx) > tolerance or abs(dy) > tolerance | ||
) and not self.is_right_mouse_button_surpressed: | ||
coords = [ | ||
self.point_on_mouse_press[0], | ||
self.point_on_mouse_press[1], | ||
self.point_on_mouse_move[0], | ||
self.point_on_mouse_move[1], | ||
] | ||
self._display.ZoomArea(*coords) |
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 GLWidget.on_zoom_area
refactored with the following changes:
- Swap if/else to remove empty if body (
remove-pass-body
) - Merge nested if conditions (
merge-nested-ifs
)
This removes the following comments ( why? ):
# zooming at a near nil value can segfault the opengl viewer
perform_action = False | ||
|
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 GLWidget._dispatch_camera_command_actions
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
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!