-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assert that bounding box and mag are aligned (#211)
* Assert that bounding box and mag are aligned * Add tests * Remove unused imports * Run black * Merge branch 'master' into fix-in-mag
- Loading branch information
1 parent
263b452
commit b5dee90
Showing
2 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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,31 @@ | ||
from wkcuber.api.bounding_box import BoundingBox, Mag | ||
import pytest | ||
|
||
|
||
def test_align_with_mag(): | ||
|
||
assert BoundingBox((1, 1, 1), (10, 10, 10)).align_with_mag(Mag(2)) == BoundingBox( | ||
topleft=(0, 0, 0), size=(12, 12, 12) | ||
) | ||
assert BoundingBox((1, 1, 1), (9, 9, 9)).align_with_mag(Mag(2)) == BoundingBox( | ||
topleft=(0, 0, 0), size=(10, 10, 10) | ||
) | ||
assert BoundingBox((1, 1, 1), (9, 9, 9)).align_with_mag(Mag(4)) == BoundingBox( | ||
topleft=(0, 0, 0), size=(12, 12, 12) | ||
) | ||
assert BoundingBox((1, 2, 3), (9, 9, 9)).align_with_mag(Mag(2)) == BoundingBox( | ||
topleft=(0, 2, 2), size=(10, 10, 10) | ||
) | ||
|
||
|
||
def test_in_mag(): | ||
|
||
with pytest.raises(AssertionError): | ||
BoundingBox((1, 2, 3), (9, 9, 9)).in_mag(Mag(2)) | ||
|
||
with pytest.raises(AssertionError): | ||
BoundingBox((2, 2, 2), (9, 9, 9)).in_mag(Mag(2)) | ||
|
||
assert BoundingBox((2, 2, 2), (10, 10, 10)).in_mag(Mag(2)) == BoundingBox( | ||
topleft=(1, 1, 1), size=(5, 5, 5) | ||
) |
This file contains 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