Compression/ppma#14810
Conversation
There was a problem hiding this 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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
| Core class for PPM compression algorithm containing compression and decompression. | ||
| """ | ||
|
|
||
| def __init__(self, max_order: int = 2, alphabet_size: int = 256): |
There was a problem hiding this comment.
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:
| defaultdict(lambda: defaultdict(int)) for _ in range(max_order + 1) | ||
| ] | ||
|
|
||
| def encode_text(self, text: str) -> dict: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function encode_text
|
|
||
| return {"readable_output": output, "ranges": output_ranges} | ||
|
|
||
| def decode_text(self, ranges: list) -> str: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function decode_text
|
|
||
| return decoded_text | ||
|
|
||
| def _get_context_probs(self, order: int, context: str) -> tuple[dict, int]: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function _get_context_probs
|
|
||
| return dict(counts), total_count | ||
|
|
||
| def process_char(self, char: str) -> tuple: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function process_char
|
|
||
| return output, output_ranges | ||
|
|
||
| def _update_models(self, char: str) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function _update_models
| (self.history + char)[-self.max_order :] if self.max_order > 0 else "" | ||
| ) | ||
|
|
||
| def __reset_memory(self) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function __reset_memory
| defaultdict(lambda: defaultdict(int)) for _ in range(self.max_order + 1) | ||
| ] | ||
|
|
||
| def __str__(self) -> str: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function __str__
There was a problem hiding this 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 reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto 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.
| defaultdict(lambda: defaultdict(int)) for _ in range(max_order + 1) | ||
| ] | ||
|
|
||
| def encode_text(self, text: str) -> dict: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function encode_text
|
|
||
| return {"readable_output": output, "ranges": output_ranges} | ||
|
|
||
| def decode_text(self, ranges: list) -> str: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function decode_text
|
|
||
| return decoded_text | ||
|
|
||
| def _get_context_probs(self, order: int, context: str) -> tuple[dict, int]: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function _get_context_probs
|
|
||
| return dict(counts), total_count | ||
|
|
||
| def process_char(self, char: str) -> tuple: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function process_char
|
|
||
| return output, output_ranges | ||
|
|
||
| def _update_models(self, char: str) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function _update_models
| (self.history + char)[-self.max_order :] if self.max_order > 0 else "" | ||
| ) | ||
|
|
||
| def __reset_memory(self) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function __reset_memory
| defaultdict(lambda: defaultdict(int)) for _ in range(self.max_order + 1) | ||
| ] | ||
|
|
||
| def __str__(self) -> str: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file data_compression/ppma.py, please provide doctest for the function __str__
Describe your change:
Checklist: