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

Wavelet tree #4267

Merged
merged 29 commits into from Jun 8, 2021
Merged

Wavelet tree #4267

merged 29 commits into from Jun 8, 2021

Conversation

@anirudnits
Copy link
Contributor

@anirudnits anirudnits commented Mar 14, 2021

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • 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 have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

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.



class Node:
def __init__(self, n):

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 descriptive name for the parameter: n

Please provide type hint for the parameter: n

self.left: Optional[Node] = None
self.right: Optional[Node] = None

def __repr__(self):

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

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

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, i: int) -> int:

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

Please provide descriptive name for the parameter: i

return rank_from_start(node.right, num, i - node.map_left[i])


def rank(node: Node, num: int, i: int, j: int) -> int:

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

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

return rank_till_j - rank_before_i


def quantile(node: Node, k: int, i: int, j: int) -> int:

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

Please provide descriptive name for the parameter: k

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

)


def range_counting(node: Node, i: int, j: int, x: int, y: int) -> int:

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

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

return left + right


def main():

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

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

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.



class Node:
def __init__(self, length):

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: length

self.left: Optional[Node] = None
self.right: Optional[Node] = None

def __repr__(self):

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

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

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, index: int) -> int:

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

data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
return rank_till_end - rank_before_start


def quantile(node: Node, k: int, start: int, end: int) -> int:

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

Please provide descriptive name for the parameter: k

)


def range_counting(node: Node, start: int, end: int, x: int, y: int) -> int:

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

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

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.

data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, index: int) -> int:

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

data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
Add doctests to placate the algorithm-bot, thanks to @cclauss.

Co-authored-by: Christian Clauss <cclauss@me.com>
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

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.

data_structures/binary_tree/wavelet_tree.py Outdated Show resolved Hide resolved
return root


def rank_from_start(node: Node, num: int, index: int) -> int:

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

data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
data_structures/binary_tree/wavelet_tree.py Show resolved Hide resolved
@cclauss
Copy link
Member

@cclauss cclauss commented Apr 7, 2021

Let's get a review from @dhruvmanila first...

@dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Apr 7, 2021

Thanks for the heads up! I will take a look at it today.

@anirudnits
Copy link
Contributor Author

@anirudnits anirudnits commented Apr 24, 2021

Just following up for any updates on this.

@anirudnits
Copy link
Contributor Author

@anirudnits anirudnits commented May 29, 2021

Just following up for any updates.

@anirudnits
Copy link
Contributor Author

@anirudnits anirudnits commented Jun 8, 2021

@cclauss @dhruvmanila just following up for any updates on this PR.

@cclauss
Copy link
Member

@cclauss cclauss commented Jun 8, 2021

Close and reopen to rebase…

@cclauss cclauss closed this Jun 8, 2021
@cclauss cclauss reopened this Jun 8, 2021
cclauss
cclauss approved these changes Jun 8, 2021
@cclauss cclauss merged commit b743e44 into TheAlgorithms:master Jun 8, 2021
4 checks passed
shermanhui added a commit to shermanhui/Python that referenced this issue Oct 22, 2021
* Added the matrix_exponentiation.py file in maths directory

* Implemented the requested changes

* Update matrix_exponentiation.py

* resolve merge conflict with upstream branch

* add new line at end of file

* add wavelet_tree

* fix isort issue

* updating DIRECTORY.md

* fix variable names in wavelet_tree and correct typo

* Add type hints and variable renaming

* Update data_structures/binary_tree/wavelet_tree.py

Add doctests to placate the algorithm-bot, thanks to @cclauss.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Move doctest to individual functions and reformat code

* Move common test array to the global scope and reuse in tests

* MMove test array to global scope and minor linting changes

* Correct the failing pytest tests

* MUse built-in list for type annotation

* Update wavelet_tree.py

* types-requests

* updating DIRECTORY.md

* Update wavelet_tree.py

* # type: ignore

* # type: ignore

* Update decrypt_caesar_with_chi_squared.py

* ,

* Update decrypt_caesar_with_chi_squared.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Aniruddha Bhattacharjee <aniruddha@Aniruddhas-MacBook-Air.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants