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

[WIP] Fix Cropper.crop_positions returning negative coordinates #171

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ tox
portray
wheel
twine
hypothesis
-r requirements.txt
11 changes: 10 additions & 1 deletion tests/test_autocrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from glob import glob
import shutil

import pytest # noqa: F401
import pytest
import cv2
import numpy as np
from hypothesis import given, example, strategies as st

from autocrop.autocrop import gamma, Cropper

Expand Down Expand Up @@ -77,6 +78,14 @@ def test_adjust_boundaries(values, expected_result):
assert result == expected_result


@given(*[st.integers(min_value=0, max_value=500)] * 4)
@example(13, 280, 26, 33)
def test_crop_positions(x, y, w, h):
c = Cropper()
result = c._crop_positions(500, 500, x, y, w, h)
assert all(pos >= 0 for pos in result)


@pytest.mark.slow
@pytest.mark.parametrize(
"height, width",
Expand Down