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

DEP: Remove paeth_predictor #2773

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions pypdf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,6 @@ def ord_(b: Union[int, str, bytes]) -> Union[int, bytes]:
WHITESPACES_AS_REGEXP = b"[" + WHITESPACES_AS_BYTES + b"]"


def paeth_predictor(left: int, up: int, up_left: int) -> int:
p = left + up - up_left
dist_left = abs(p - left)
dist_up = abs(p - up)
dist_up_left = abs(p - up_left)

if dist_left <= dist_up and dist_left <= dist_up_left:
return left
elif dist_up <= dist_up_left:
return up
else:
return up_left


def deprecate(msg: str, stacklevel: int = 3) -> None:
warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel)

Expand Down
18 changes: 0 additions & 18 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,6 @@ def test_deprecate_no_replacement():
assert warn[0].message.args[0] == error_msg


@pytest.mark.parametrize(
("left", "up", "upleft", "expected"),
[
(0, 0, 0, 0),
(1, 0, 0, 1),
(0, 1, 0, 1),
(0, 0, 1, 0),
(1, 2, 3, 1),
(2, 1, 3, 1),
(1, 3, 2, 2),
(3, 1, 2, 2),
(3, 2, 1, 3),
],
)
def test_paeth_predictor(left, up, upleft, expected):
assert pypdf._utils.paeth_predictor(left, up, upleft) == expected


@pytest.mark.parametrize(
("dat", "pos", "to_read", "expected", "expected_pos"),
[
Expand Down
Loading