Skip to content

Sourcery refactored master branch #1

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

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 Mar 22, 2022

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 pruthvirajg March 22, 2022 12:07
Copy link
Author

@sourcery-ai sourcery-ai bot left a 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.

Comment on lines -31 to +34
for i in range(number_vertices-1):
for _ in range(number_vertices-1):
for (u, v) in edges:
relax(graph, u, v)
for (u, v) in edges:
if dist[v] > dist[u] + graph[u][v]:
return False # there exists a negative cycle
return True
return all(dist[v] <= dist[u] + graph[u][v] for (u, v) in edges)
Copy link
Author

Choose a reason for hiding this comment

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

Function bellman_ford refactored with the following changes:

This removes the following comments ( why? ):

# there exists a negative cycle

Comment on lines -40 to +37
if bellman_ford(graph, s):
return dist
return "Graph contains a negative cycle"
return dist if bellman_ford(graph, s) else "Graph contains a negative cycle"
Copy link
Author

Choose a reason for hiding this comment

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

Function get_distances refactored with the following changes:

table = [[0]*M for i in range(total+1)]
table = [[0]*M for _ in range(total+1)]
Copy link
Author

Choose a reason for hiding this comment

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

Function coinchange refactored with the following changes:

Comment on lines -11 to +16
graph = dict()
graph = {}
with open(file) as f:
for l in f:
(u, v, w) = l.split()
if int(u) not in graph:
graph[int(u)] = dict()
graph[int(u)] = {}
Copy link
Author

Choose a reason for hiding this comment

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

Function read_graph refactored with the following changes:

Comment on lines -23 to +27
dist = dict()
Q = list()

for v in graph:
dist[v] = inf
Q = []

dist = {v: inf for v in graph}
dist[s] = 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 dijkstra refactored with the following changes:

Comment on lines -21 to +25
for j in range(0, len(weights)):
for j in range(len(weights)):
Copy link
Author

Choose a reason for hiding this comment

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

Function knapsack refactored with the following changes:

cache = [[0 for j in range(n + 1)] for i in range(m + 1)]
cache = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
Copy link
Author

Choose a reason for hiding this comment

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

Function longest_common_subsequence refactored with the following changes:

Comment on lines -13 to +16
for j in range(0, i):
if nums[i] > nums[j]:
if cache[j] + 1 > cache[i]:
cache[i] = cache[j] + 1
location[i] = j
for j in range(i):
if nums[i] > nums[j] and cache[j] + 1 > cache[i]:
cache[i] = cache[j] + 1
location[i] = j
Copy link
Author

Choose a reason for hiding this comment

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

Function longest_increasing_subsequence refactored with the following changes:

return max([item for rows in copy_matrix for item in rows])
return max(item for rows in copy_matrix for item in rows)
Copy link
Author

Choose a reason for hiding this comment

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

Function find_sub_matrix_size refactored with the following changes:

raise Exception("Edge (%s, %s) already added in the graph" % (u, v))
raise Exception(f"Edge ({u}, {v}) already added in the graph")
Copy link
Author

Choose a reason for hiding this comment

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

Function digraph.add_edge refactored with the following changes:

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

Successfully merging this pull request may close these issues.

0 participants