Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Apr 16, 2023

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:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from camer0nluo April 16, 2023 01:15
print('Number of subsets: {}'.format(len(solutions)))
print(f'Number of subsets: {len(solutions)}')
Copy link
Author

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:

for x in range(0, 20):
for x in range(20):
Copy link
Author

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:

Comment on lines -26 to -31
difference = (
((p2.x - origin.x) * (p1.y - origin.y))
- ((p1.x - origin.x) * (p2.y - origin.y))
return ((p2.x - origin.x) * (p1.y - origin.y)) - (
(p1.x - origin.x) * (p2.y - origin.y)
)

return difference
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ConvexHull._get_orientation refactored with the following changes:

Comment on lines -54 to +59
# get the first point (initial max) to use to compare with others
p1 = None
for p in points:
if p is point:
continue
else:
p1 = p
break

p1 = next((p for p in points if p is not point), None)
far_point = p1

for p2 in points:
# ensure we aren't comparing to self or pivot point
if p2 is point or p2 is p1:
continue
else:
direction = self._get_orientation(point, far_point, p2)
if direction > 0:
far_point = p2
direction = self._get_orientation(point, far_point, p2)
if direction > 0:
far_point = p2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ConvexHull.compute_hull refactored with the following changes:

This removes the following comments ( why? ):

# get the first point (initial max) to use to compare with others
# ensure we aren't comparing to self or pivot point

Comment on lines -32 to +34
else:
# path compression
self.hierarchy[item_id] = self.find(self.hierarchy[item_id])
return self.hierarchy[item_id]
# path compression
self.hierarchy[item_id] = self.find(self.hierarchy[item_id])
return self.hierarchy[item_id]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DisjointSets.find refactored with the following changes:

if n <= 2:
return 1

return fib(n - 1) + fib(n - 2)
return 1 if n <= 2 else fib(n - 1) + fib(n - 2)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fib refactored with the following changes:

for v in self.adjacency_list:
yield v
yield from self.adjacency_list
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DirectedGraph.get_vertex refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

Comment on lines -39 to +38
for u in self.adjacency_list[vertex]:
yield u
yield from self.adjacency_list[vertex]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DirectedGraph.get_neighbor refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

Comment on lines -56 to +54
for u in reversed_list[vertex]:
yield u
yield from reversed_list[vertex]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DirectedGraph.get_reverse_neighbor refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

Comment on lines -173 to +170
for u in self.get_neighbor(v):
if u not in statuses:
to_visit.append(u)

to_visit.extend(u for u in self.get_neighbor(v) if u not in statuses)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DirectedGraph.topological_sort refactored with the following changes:

Comment on lines -187 to +181
components = self.scc_dfs_reverse_pass(stack)

return components
return self.scc_dfs_reverse_pass(stack)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DirectedGraph.strongly_connected_components refactored with the following changes:

for i in range(vertices):
self.adjacency_matrix.append([0] * vertices)
self.adjacency_matrix.extend([0] * vertices for _ in range(vertices))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UndirectedGraph.__init__ refactored with the following changes:

Comment on lines -107 to +108
colorings = {}
to_visit = queue.Queue()
to_visit.put(0)
colorings[0] = 0

colorings = {0: 0}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UndirectedGraph.is_bipartite refactored with the following changes:

for e in self.adjacency_list[vertex]:
yield e
yield from self.adjacency_list[vertex]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GraphUndirectedWeighted.get_neighbor refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

Comment on lines -28 to +27
for v in range(self.vertex_count):
yield v
yield from range(self.vertex_count)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GraphUndirectedWeighted.get_vertex refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

output += str(current) + " -> "
output += f"{str(current)} -> "
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LinkedList.__str__ refactored with the following changes:

count = 0
for line in sys.stdin:
count += 1

count = sum(1 for _ in sys.stdin)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 3-6 refactored with the following changes:

return "%s->%s:%s" % (self.source, self.sink, self.capacity)
return f"{self.source}->{self.sink}:{self.capacity}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Edge.__repr__ refactored with the following changes:

found = False
for j in arr2:
if i == j:
found = True
break
found = any(i == j for j in arr2)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function contain_same_ints refactored with the following changes:

  • Use any() instead of for loop (use-any)

found = False
for j in arr2:
if i == j:
found = True
found = any(i == j for j in arr2)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function contain_same_ints refactored with the following changes:

  • Use any() instead of for loop (use-any)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
0 participants