-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from kba/test-points-xywh
fix/test utility coordination translation functions
- Loading branch information
Showing
3 changed files
with
56 additions
and
14 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
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
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,29 @@ | ||
from test.base import TestCase, main | ||
from ocrd.utils import ( | ||
points_from_xywh, | ||
xywh_from_points, | ||
polygon_from_points | ||
) | ||
|
||
class TestResolver(TestCase): | ||
|
||
# def runTest(self): | ||
|
||
def test_points_from_xywh(self): | ||
self.assertEqual( | ||
points_from_xywh({'x': 100, 'y': 100, 'w': 100, 'h': 100}), | ||
'100,100 200,100 200,200 100,200' | ||
) | ||
|
||
def test_xywh_from_points(self): | ||
self.assertEqual( | ||
xywh_from_points('100,100 200,100 200,200 100,200'), | ||
{'x': 100, 'y': 100, 'w': 100, 'h': 100}) | ||
|
||
def test_polygon_from_points(self): | ||
self.assertEqual( | ||
polygon_from_points('100,100 200,100 200,200 100,200'), | ||
[[100, 100], [200, 100], [200, 200], [100, 200]]) | ||
|
||
if __name__ == '__main__': | ||
main() |