-
-
Notifications
You must be signed in to change notification settings - Fork 46.1k
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
Add wildcard pattern matching algorithm using FFT #12014
Add wildcard pattern matching algorithm using FFT #12014
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.
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.
for more information, see https://pre-commit.ci
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.
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.
from numpy.fft import fft, ifft | ||
|
||
|
||
def preprocess_text_and_pattern(text: str, pattern: str) -> tuple[list[int], list[int]]: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function preprocess_text_and_pattern
|
||
return text_int, pattern_int | ||
|
||
def fft_convolution(a: list[int], b: list[int]) -> np.ndarray: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function fft_convolution
Please provide descriptive name for the parameter: a
Please provide descriptive name for the parameter: b
return np.real(ifft(A * B)) | ||
|
||
|
||
def compute_a_fft(text_int: list[int], pattern_int: list[int]) -> np.ndarray: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function compute_a_fft
c276c58
to
9d6751c
Compare
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.
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.
from numpy.fft import fft, ifft | ||
|
||
|
||
def preprocess_text_and_pattern(text: str, pattern: str) -> tuple[list[int], list[int]]: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function preprocess_text_and_pattern
|
||
return text_int, pattern_int | ||
|
||
def fft_convolution(first_seq: list[int], second_seq: list[int]) -> np.ndarray: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function fft_convolution
|
||
|
||
|
||
def compute_a_fft(text_int: list[int], pattern_int: list[int]) -> np.ndarray: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function compute_a_fft
cfa099f
to
f4efe93
Compare
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.
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.
from numpy.fft import fft, ifft | ||
|
||
|
||
def preprocess_text_and_pattern(text: str, pattern: str) -> tuple[list[int], list[int]]: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function preprocess_text_and_pattern
|
||
return text_int, pattern_int | ||
|
||
def fft_convolution(first_seq: list[int], second_seq: list[int]) -> np.ndarray: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function fft_convolution
|
||
|
||
|
||
def compute_a_fft(text_int: list[int], pattern_int: list[int]) -> np.ndarray: |
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.
As there is no test file in this pull request nor any test function or class in the file strings/wildcard_pattern_matching_fft.py
, please provide doctest for the function compute_a_fft
for more information, see https://pre-commit.ci
Closing require_tests PRs to prepare for Hacktoberfest |
Description
This algorithm uses Fast Fourier Transform (FFT) to implement a wildcard pattern matching functionality. It efficiently finds occurrences of a given pattern, which may include wildcards, within a text string. The overall time complexity of the algorithm is O((n+m) log (n+m)), where n is the length of the text and m is the length of the pattern.
Change Summary
Checklist
References
For more information on Fast Fourier Transform and its applications, you can visit the following resources: