-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Update operations on DW Operations. #688
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0227e9b
Merge pull request #655 from aperture-data/release-0.4.56
luisremis 286bbd9
Merge pull request #660 from aperture-data/release-0.4.57
luisremis ab9dbd8
Merge pull request #664 from aperture-data/release-0.4.58
luisremis c30110e
fix: update pre-commit CI to use python 3.12 (#676)
ad-claw000 db3be0a
test: add initial suite of tests for Images.py (#674)
ad-claw000 0ced2ff
fix: Update operations on DW Operations.
ad-claw000 5fc0bb2
test: add tests for DW Operations
ad-claw000 23c49d2
fix: address review comments on Operations PR
ad-claw000 fde49d7
fix(ops): validate resize arguments and update resolve logic
ad-claw000 7c6c772
chore: auto-format via pre-commit
ad-claw000 3d5be27
test: update chained ops and add negative tests for resize
ad-claw000 1e60b94
test: add test for Images.resolve with resize scale
ad-claw000 501e730
test: add missing tests for operations based on review
ad-claw000 19b0999
Address PR 688 review comments
ad-claw000 d830c30
test: add test for empty operations
ad-claw000 3a1346b
Merge branch 'develop' into fix/issue-160 and resolve conflicts
luisremis 38cd6b5
style: auto-format via pre-commit
luisremis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import pytest | ||
| from aperturedb.Operations import Operations | ||
|
|
||
|
|
||
| class TestOperations: | ||
| def test_empty_operations(self): | ||
| op = Operations() | ||
| assert op.get_operations_arr() == [] | ||
|
|
||
| def test_resize_width_height(self): | ||
| op = Operations().resize(width=100, height=200) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "resize", "width": 100, "height": 200}] | ||
|
|
||
| def test_resize_scale(self): | ||
| op = Operations().resize(scale=0.5) | ||
| assert op.get_operations_arr() == [{"type": "resize", "scale": 0.5}] | ||
|
|
||
| def test_rotate(self): | ||
| op = Operations().rotate(angle=90) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "rotate", "angle": 90, "resize": False}] | ||
|
|
||
| def test_rotate_resize(self): | ||
| op = Operations().rotate(angle=90, resize=True) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "rotate", "angle": 90, "resize": True}] | ||
|
|
||
| def test_flip(self): | ||
| op = Operations().flip(code="horizontal") | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "flip", "code": "horizontal"}] | ||
|
|
||
| def test_crop(self): | ||
| op = Operations().crop(x=10, y=20, width=100, height=200) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "crop", "x": 10, "y": 20, "width": 100, "height": 200}] | ||
|
|
||
| def test_interval(self): | ||
| op = Operations().interval(start=0, stop=100, step=2) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "interval", "start": 0, "stop": 100, "step": 2}] | ||
|
|
||
| def test_threshold(self): | ||
| op = Operations().threshold(value=128) | ||
| assert op.get_operations_arr() == [{"type": "threshold", "value": 128}] | ||
|
|
||
| def test_preview(self): | ||
| op = Operations().preview(max_frame_count=10, max_time_fraction=0.5) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "preview", "max_frame_count": 10, "max_time_fraction": 0.5}] | ||
|
|
||
| def test_preview_all_args(self): | ||
| op = Operations().preview(max_frame_count=10, max_time_fraction=0.5, | ||
| max_time_offset="00:00:10", max_size_mb=10.5) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "preview", "max_frame_count": 10, "max_time_fraction": 0.5, "max_time_offset": "00:00:10", "max_size_mb": 10.5}] | ||
|
|
||
| def test_chained_operations(self): | ||
| op = Operations().resize(width=100, height=100).rotate( | ||
| angle=90).crop(x=0, y=0, width=50, height=50) | ||
| assert op.get_operations_arr() == [ | ||
| {"type": "resize", "width": 100, "height": 100}, | ||
| {"type": "rotate", "angle": 90, "resize": False}, | ||
| {"type": "crop", "x": 0, "y": 0, "width": 50, "height": 50} | ||
| ] | ||
|
|
||
| def test_resize_invalid_args(self): | ||
| with pytest.raises(ValueError, match="Provide either 'scale' or both 'width' and 'height'"): | ||
| Operations().resize() | ||
| with pytest.raises(ValueError, match="Provide either 'scale' or both 'width' and 'height'"): | ||
| Operations().resize(width=100) | ||
| with pytest.raises(ValueError, match="Provide either 'scale' or both 'width' and 'height', but not a mix"): | ||
| Operations().resize(width=100, height=100, scale=0.5) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.