Skip to content

Conversation

mcawezome
Copy link

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@algorithms-keeper algorithms-keeper bot added the require type hints https://docs.python.org/3/library/typing.html label Nov 13, 2024
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

True
"""

def __init__(self, key):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: key

3
"""

def __init__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

self.min_node = None
self.total_nodes = 0

def insert(self, key):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: insert. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: key

self.total_nodes += 1
return new_node

def _insert_into_circular_list(self, base_node, node_to_insert):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: _insert_into_circular_list. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: base_node

Please provide type hint for the parameter: node_to_insert

base_node.right = node_to_insert
return base_node

def extract_min(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: extract_min. If the function does not return a value, please provide the type hint as: def function() -> None:

child_node.parent = None
child_node.marked = False

def _cascading_cut(self, current_node):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: _cascading_cut. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: current_node

self._cut(current_node, parent_node)
self._cascading_cut(parent_node)

def delete(self, node):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: delete. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

self.decrease_key(node, float("-inf"))
self.extract_min()

def find_min(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: find_min. If the function does not return a value, please provide the type hint as: def function() -> None:

"""
return self.min_node.key if self.min_node else None

def is_empty(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: is_empty. If the function does not return a value, please provide the type hint as: def function() -> None:

"""
return self.min_node is None

def merge(self, other_heap):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: merge. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: other_heap

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Nov 13, 2024
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Nov 17, 2024
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

True
"""

def __init__(self, key) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: key

self.min_node = Node(None)
self.total_nodes = 0

def insert(self, key) -> Node:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: key

self.total_nodes += 1
return new_node

def _insert_into_circular_list(self, base_node, node_to_insert) -> Node:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: base_node

Please provide type hint for the parameter: node_to_insert

self.total_nodes -= 1
return min_node.key

def _consolidate(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: _consolidate. If the function does not return a value, please provide the type hint as: def function() -> None:

):
self.min_node = degree_table[degree]

def decrease_key(self, node, new_key):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: decrease_key. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

Please provide type hint for the parameter: new_key

if node.key < self.min_node.key:
self.min_node = node

def _cut(self, child_node, parent_node):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: _cut. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: child_node

Please provide type hint for the parameter: parent_node

child_node.parent = Node(None)
child_node.marked = False

def _cascading_cut(self, current_node) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: current_node

self._cut(current_node, parent_node)
self._cascading_cut(parent_node)

def delete(self, node) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: node

"""
return self.min_node.key is None

def merge(self, other_heap) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other_heap

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

True
"""

def __init__(self, key) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: key

self.min_node = Node(None)
self.total_nodes = 0

def insert(self, key) -> Node:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: key

self.total_nodes += 1
return new_node

def _insert_into_circular_list(self, base_node, node_to_insert) -> Node:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: base_node

Please provide type hint for the parameter: node_to_insert

self.total_nodes -= 1
return min_node.key

def _consolidate(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: _consolidate. If the function does not return a value, please provide the type hint as: def function() -> None:

):
self.min_node = degree_table[degree]

def decrease_key(self, node, new_key):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: decrease_key. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

Please provide type hint for the parameter: new_key

if node.key < self.min_node.key:
self.min_node = node

def _cut(self, child_node, parent_node):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: _cut. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: child_node

Please provide type hint for the parameter: parent_node

child_node.parent = Node(None)
child_node.marked = False

def _cascading_cut(self, current_node) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: current_node

self._cut(current_node, parent_node)
self._cascading_cut(parent_node)

def delete(self, node) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: node

"""
return self.min_node.key is None

def merge(self, other_heap) -> None:

Choose a reason for hiding this comment

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

Please provide type hint for the parameter: other_heap

@algorithms-keeper algorithms-keeper bot removed the require type hints https://docs.python.org/3/library/typing.html label Nov 17, 2024
@algorithms-keeper algorithms-keeper bot added require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html labels Nov 18, 2024
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

becoming a child of its current parent)
"""

def __init__(self, val):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: val

self.degree = 0
self.mark = False

def add_sibling(self, node):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file data_structures/heap/fibonacci_heap.py, please provide doctest for the function add_sibling

Please provide return type hint for the function: add_sibling. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

self.right.left = node
self.right = node

def add_child(self, node):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file data_structures/heap/fibonacci_heap.py, please provide doctest for the function add_child

Please provide return type hint for the function: add_child. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

self.child.add_sibling(node)
self.degree += 1

def remove(self):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file data_structures/heap/fibonacci_heap.py, please provide doctest for the function remove

Please provide return type hint for the function: remove. If the function does not return a value, please provide the type hint as: def function() -> None:

3
"""

def __init__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

if degree_table[degree].val < self.min_node.val:
self.min_node = degree_table[degree]

def decrease_key(self, node, new_val):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: decrease_key. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

Please provide type hint for the parameter: new_val

if node.val < self.min_node.val:
self.min_node = node

def __cut(self, node, parent):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __cut. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

Please provide type hint for the parameter: parent

node.mark = False
self.min_node.add_sibling(node)

def __cascading_cut(self, node):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __cascading_cut. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

self.__cut(node, parent)
self.__cascading_cut(parent)

def __str__(self):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: __str__. If the function does not return a value, please provide the type hint as: def function() -> None:

if not self.min_node:
return "Empty heap"

def print_tree(node, level=0):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: print_tree. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: node

Please provide type hint for the parameter: level

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Nov 21, 2024
@mcawezome
Copy link
Author

Re uploading in new PR

@mcawezome mcawezome closed this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants