arkindex-base-worker 0.4.0rc2__py3-none-any.whl → 0.4.0rc4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {arkindex_base_worker-0.4.0rc2.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/METADATA +15 -14
  2. arkindex_base_worker-0.4.0rc4.dist-info/RECORD +60 -0
  3. {arkindex_base_worker-0.4.0rc2.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/WHEEL +1 -1
  4. arkindex_worker/cache.py +1 -1
  5. arkindex_worker/worker/__init__.py +1 -2
  6. arkindex_worker/worker/base.py +1 -1
  7. arkindex_worker/worker/classification.py +1 -1
  8. arkindex_worker/worker/corpus.py +21 -6
  9. arkindex_worker/worker/entity.py +1 -1
  10. arkindex_worker/worker/task.py +1 -2
  11. arkindex_worker/worker/training.py +1 -1
  12. tests/test_dataset_worker.py +1 -1
  13. tests/test_elements_worker/{test_classifications.py → test_classification.py} +87 -1
  14. tests/test_elements_worker/test_corpus.py +32 -1
  15. tests/test_elements_worker/test_dataset.py +1 -1
  16. tests/test_elements_worker/test_element.py +427 -0
  17. tests/test_elements_worker/test_element_create_multiple.py +715 -0
  18. tests/test_elements_worker/test_element_create_single.py +528 -0
  19. tests/test_elements_worker/test_element_list_children.py +969 -0
  20. tests/test_elements_worker/test_element_list_parents.py +530 -0
  21. tests/test_elements_worker/{test_entities.py → test_entity_create.py} +1 -154
  22. tests/test_elements_worker/test_entity_list_and_check.py +160 -0
  23. tests/test_elements_worker/test_image.py +2 -1
  24. tests/test_elements_worker/test_metadata.py +1 -1
  25. tests/test_elements_worker/test_task.py +1 -1
  26. tests/test_elements_worker/test_transcription_create.py +873 -0
  27. tests/test_elements_worker/test_transcription_create_with_elements.py +951 -0
  28. tests/test_elements_worker/test_transcription_list.py +450 -0
  29. tests/test_elements_worker/test_version.py +60 -0
  30. tests/test_elements_worker/test_worker.py +526 -89
  31. tests/test_image.py +181 -198
  32. arkindex_base_worker-0.4.0rc2.dist-info/RECORD +0 -52
  33. tests/test_elements_worker/test_elements.py +0 -3704
  34. tests/test_elements_worker/test_transcriptions.py +0 -2252
  35. {arkindex_base_worker-0.4.0rc2.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/LICENSE +0 -0
  36. {arkindex_base_worker-0.4.0rc2.dist-info → arkindex_base_worker-0.4.0rc4.dist-info}/top_level.txt +0 -0
tests/test_image.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import logging
2
2
  import math
3
- import unittest
4
3
  import uuid
5
4
  from io import BytesIO
6
5
  from operator import attrgetter
@@ -219,74 +218,33 @@ def test_open_image_rotate_mirror(rotation_angle, mirrored, expected_path):
219
218
  assert _root_mean_square(expected, actual) <= 15.0
220
219
 
221
220
 
222
- class TestTrimPolygon(unittest.TestCase):
223
- def test_trim_polygon_partially_outside_image(self):
224
- bad_polygon = [
225
- [99, 200],
226
- [197, 224],
227
- [120, 251],
228
- [232, 350],
229
- [312, 364],
230
- [325, 310],
231
- [318, 295],
232
- [296, 260],
233
- [352, 259],
234
- [106, 210],
235
- [197, 206],
236
- [99, 200],
237
- ]
238
- expected_polygon = [
239
- [99, 200],
240
- [197, 224],
241
- [120, 251],
242
- [232, 300],
243
- [312, 300],
244
- [325, 300],
245
- [318, 295],
246
- [296, 260],
247
- [352, 259],
248
- [106, 210],
249
- [197, 206],
250
- [99, 200],
251
- ]
252
- assert (
253
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
254
- == expected_polygon
255
- )
256
-
257
- def test_trim_polygon_good_polygon(self):
258
- good_polygon = (
259
- (12, 56),
260
- (29, 60),
261
- (35, 61),
262
- (42, 59),
263
- (58, 57),
264
- (65, 61),
265
- (72, 57),
266
- (12, 56),
267
- )
268
- expected_polygon = [
269
- [12, 56],
270
- [29, 60],
271
- [35, 61],
272
- [42, 59],
273
- [58, 57],
274
- [65, 61],
275
- [72, 57],
276
- [12, 56],
277
- ]
278
- assert (
279
- trim_polygon(good_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
280
- == expected_polygon
281
- )
282
-
283
- def test_trim_polygon_invalid_polygon(self):
284
- """
285
- An assertion error is raised the polygon input isn't a list or tuple
286
- """
287
- bad_polygon = {
288
- "polygon": [
289
- [99, 200],
221
+ @pytest.mark.parametrize(
222
+ ("polygon", "error"),
223
+ [
224
+ # Polygon input isn't a list or tuple
225
+ (
226
+ {
227
+ "polygon": [
228
+ [99, 200],
229
+ [25, 224],
230
+ [0, 0],
231
+ [0, 300],
232
+ [102, 300],
233
+ [260, 300],
234
+ [288, 295],
235
+ [296, 260],
236
+ [352, 259],
237
+ [106, 210],
238
+ [197, 206],
239
+ [99, 208],
240
+ ]
241
+ },
242
+ "Input polygon must be a valid list or tuple of points.",
243
+ ),
244
+ # Point coordinates are not integers
245
+ (
246
+ [
247
+ [9.9, 200],
290
248
  [25, 224],
291
249
  [0, 0],
292
250
  [0, 300],
@@ -297,136 +255,161 @@ class TestTrimPolygon(unittest.TestCase):
297
255
  [352, 259],
298
256
  [106, 210],
299
257
  [197, 206],
300
- [99, 208],
301
- ]
302
- }
303
- with pytest.raises(
304
- AssertionError,
305
- match="Input polygon must be a valid list or tuple of points.",
306
- ):
307
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
308
-
309
- def test_trim_polygon_negative_coordinates(self):
310
- """
311
- Negative coordinates are ignored and replaced by 0 with no error being thrown
312
- """
313
- bad_polygon = [
314
- [99, 200],
315
- [25, 224],
316
- [-8, -52],
317
- [-12, 350],
318
- [102, 364],
319
- [260, 310],
320
- [288, 295],
321
- [296, 260],
322
- [352, 259],
323
- [106, 210],
324
- [197, 206],
325
- [99, 200],
326
- ]
327
- expected_polygon = [
328
- [99, 200],
329
- [25, 224],
330
- [0, 0],
331
- [0, 300],
332
- [102, 300],
333
- [260, 300],
334
- [288, 295],
335
- [296, 260],
336
- [352, 259],
337
- [106, 210],
338
- [197, 206],
339
- [99, 200],
340
- ]
341
- assert (
342
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
343
- == expected_polygon
344
- )
258
+ [99, 20.8],
259
+ ],
260
+ "Polygon point coordinates must be integers.",
261
+ ),
262
+ # Point coordinates are not lists or tuples
263
+ (
264
+ [
265
+ [12, 56],
266
+ [29, 60],
267
+ [35, 61],
268
+ "[42, 59]",
269
+ [58, 57],
270
+ [65, 61],
271
+ [72, 57],
272
+ [12, 56],
273
+ ],
274
+ "Polygon points must be tuples or lists.",
275
+ ),
276
+ # Point coordinates are not lists or tuples of length 2
277
+ (
278
+ [
279
+ [12, 56],
280
+ [29, 60, 3],
281
+ [35, 61],
282
+ [42, 59],
283
+ [58, 57],
284
+ [65, 61],
285
+ [72, 57],
286
+ [12, 56],
287
+ ],
288
+ "Polygon points must be tuples or lists of 2 elements.",
289
+ ),
290
+ # None of the polygon's points are inside the image
291
+ (
292
+ [
293
+ [999, 200],
294
+ [1097, 224],
295
+ [1020, 251],
296
+ [1232, 350],
297
+ [1312, 364],
298
+ [1325, 310],
299
+ [1318, 295],
300
+ [1296, 260],
301
+ [1352, 259],
302
+ [1006, 210],
303
+ [997, 206],
304
+ [999, 200],
305
+ ],
306
+ "This polygon is entirely outside the image's bounds.",
307
+ ),
308
+ ],
309
+ )
310
+ def test_trim_polygon_errors(polygon, error):
311
+ with pytest.raises(AssertionError, match=error):
312
+ trim_polygon(polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
345
313
 
346
- def test_trim_polygon_outside_image_error(self):
347
- """
348
- An assertion error is raised when none of the polygon's points are inside the image
349
- """
350
- bad_polygon = [
351
- [999, 200],
352
- [1097, 224],
353
- [1020, 251],
354
- [1232, 350],
355
- [1312, 364],
356
- [1325, 310],
357
- [1318, 295],
358
- [1296, 260],
359
- [1352, 259],
360
- [1006, 210],
361
- [997, 206],
362
- [999, 200],
363
- ]
364
- with pytest.raises(
365
- AssertionError, match="This polygon is entirely outside the image's bounds."
366
- ):
367
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
368
-
369
- def test_trim_polygon_float_coordinates(self):
370
- """
371
- An assertion error is raised when point coordinates are not integers
372
- """
373
- bad_polygon = [
374
- [9.9, 200],
375
- [25, 224],
376
- [0, 0],
377
- [0, 300],
378
- [102, 300],
379
- [260, 300],
380
- [288, 295],
381
- [296, 260],
382
- [352, 259],
383
- [106, 210],
384
- [197, 206],
385
- [99, 20.8],
386
- ]
387
- with pytest.raises(
388
- AssertionError, match="Polygon point coordinates must be integers."
389
- ):
390
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
391
-
392
- def test_trim_polygon_invalid_points_1(self):
393
- """
394
- An assertion error is raised when point coordinates are not lists or tuples
395
- """
396
- bad_polygon = [
397
- [12, 56],
398
- [29, 60],
399
- [35, 61],
400
- "[42, 59]",
401
- [58, 57],
402
- [65, 61],
403
- [72, 57],
404
- [12, 56],
405
- ]
406
- with pytest.raises(
407
- AssertionError, match="Polygon points must be tuples or lists."
408
- ):
409
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
410
-
411
- def test_trim_polygon_invalid_points_2(self):
412
- """
413
- An assertion error is raised when point coordinates are not lists or tuples of length 2
414
- """
415
- bad_polygon = [
416
- [12, 56],
417
- [29, 60, 3],
418
- [35, 61],
419
- [42, 59],
420
- [58, 57],
421
- [65, 61],
422
- [72, 57],
423
- [12, 56],
424
- ]
425
- with pytest.raises(
426
- AssertionError,
427
- match="Polygon points must be tuples or lists of 2 elements.",
428
- ):
429
- trim_polygon(bad_polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
314
+
315
+ def test_trim_polygon_negative_coordinates():
316
+ """
317
+ Negative coordinates are ignored and replaced by 0 with no error being thrown
318
+ """
319
+ polygon = [
320
+ [99, 200],
321
+ [25, 224],
322
+ [-8, -52],
323
+ [-12, 350],
324
+ [102, 364],
325
+ [260, 310],
326
+ [288, 295],
327
+ [296, 260],
328
+ [352, 259],
329
+ [106, 210],
330
+ [197, 206],
331
+ [99, 200],
332
+ ]
333
+ expected_polygon = [
334
+ [99, 200],
335
+ [25, 224],
336
+ [0, 0],
337
+ [0, 300],
338
+ [102, 300],
339
+ [260, 300],
340
+ [288, 295],
341
+ [296, 260],
342
+ [352, 259],
343
+ [106, 210],
344
+ [197, 206],
345
+ [99, 200],
346
+ ]
347
+ assert (
348
+ trim_polygon(polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
349
+ == expected_polygon
350
+ )
351
+
352
+
353
+ def test_trim_polygon_partially_outside_image():
354
+ polygon = [
355
+ [99, 200],
356
+ [197, 224],
357
+ [120, 251],
358
+ [232, 350],
359
+ [312, 364],
360
+ [325, 310],
361
+ [318, 295],
362
+ [296, 260],
363
+ [352, 259],
364
+ [106, 210],
365
+ [197, 206],
366
+ [99, 200],
367
+ ]
368
+ expected_polygon = [
369
+ [99, 200],
370
+ [197, 224],
371
+ [120, 251],
372
+ [232, 300],
373
+ [312, 300],
374
+ [325, 300],
375
+ [318, 295],
376
+ [296, 260],
377
+ [352, 259],
378
+ [106, 210],
379
+ [197, 206],
380
+ [99, 200],
381
+ ]
382
+ assert (
383
+ trim_polygon(polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
384
+ == expected_polygon
385
+ )
386
+
387
+
388
+ def test_trim_polygon():
389
+ polygon = (
390
+ (12, 56),
391
+ (29, 60),
392
+ (35, 61),
393
+ (42, 59),
394
+ (58, 57),
395
+ (65, 61),
396
+ (72, 57),
397
+ (12, 56),
398
+ )
399
+ expected_polygon = [
400
+ [12, 56],
401
+ [29, 60],
402
+ [35, 61],
403
+ [42, 59],
404
+ [58, 57],
405
+ [65, 61],
406
+ [72, 57],
407
+ [12, 56],
408
+ ]
409
+ assert (
410
+ trim_polygon(polygon, TEST_IMAGE["width"], TEST_IMAGE["height"])
411
+ == expected_polygon
412
+ )
430
413
 
431
414
 
432
415
  @pytest.mark.parametrize(
@@ -1,52 +0,0 @@
1
- arkindex_worker/__init__.py,sha256=OlgCtTC9MaWeejviY0a3iQpALcRQGMVArFVVYwTF6I8,162
2
- arkindex_worker/cache.py,sha256=FTlB0coXofn5zTNRTcVIvh709mcw4a1bPGqkwWjKs3w,11248
3
- arkindex_worker/image.py,sha256=oEgVCrSHiGh3D5-UXfM6PvT17TttSxC0115irpvB3Dw,18581
4
- arkindex_worker/models.py,sha256=bPQzGZNs5a6z6DEcygsa8T33VOqPlMUbwKzHqlKzwbw,9923
5
- arkindex_worker/utils.py,sha256=q1EeLdC6ebYIH-C0LOAqw2cNpjCjVoP-Vbr-39mF4w0,9884
6
- arkindex_worker/worker/__init__.py,sha256=4kj94AbdACO-q7w0krmv2QkCWbP7vLLgZk9sowZUBNw,15880
7
- arkindex_worker/worker/base.py,sha256=hIorYsLy88xR4-dhIsaQHbWCz5FMoja-gfRPCJhT3eY,19843
8
- arkindex_worker/worker/classification.py,sha256=ECm1cnQPOj_9m-CoO0e182ElSySAUOoyddHrORbShhc,10951
9
- arkindex_worker/worker/corpus.py,sha256=s9bCxOszJMwRq1WWAmKjWq888mjDfbaJ18Wo7h-rNOw,1827
10
- arkindex_worker/worker/dataset.py,sha256=LwzKwNFX4FqfLxh29LSvJydPwRw3VHaB1wjuFhUshsE,5267
11
- arkindex_worker/worker/element.py,sha256=Qvvq9kJnAHNATHW7zi96eIY1x-0MsR-T5rrSJg6e9Y4,45309
12
- arkindex_worker/worker/entity.py,sha256=qGjQvOVXfP84rER0Dkui6q-rb9nTWerHVG0Z5voB8pU,15229
13
- arkindex_worker/worker/image.py,sha256=t_Az6IGnj0EZyvcA4XxfPikOUjn_pztgsyxTkFZhaXU,621
14
- arkindex_worker/worker/metadata.py,sha256=VRajtd2kaBvar9GercX4knvR6l1WFYjoCdJWU9ccKgk,7291
15
- arkindex_worker/worker/process.py,sha256=I1rBt3Y8bV4zcPr8N1E2NRZ0UClSTqhExsO9CPcP41E,1012
16
- arkindex_worker/worker/task.py,sha256=1O9zrWXxe3na3TOcoHX5Pxn1875v7EU08BSsCPnb62g,1519
17
- arkindex_worker/worker/training.py,sha256=qnBFEk11JOWWPLTbjF-lZ9iFBdTPpQzZAzQ9a03J1j4,10874
18
- arkindex_worker/worker/transcription.py,sha256=52RY9kYsiR1sz9FxOigyo12Ker3VDbQ4U42gK9DpR3g,21146
19
- arkindex_worker/worker/version.py,sha256=JIT7OI3Mo7RPkNrjOB9hfqrsG-FYygz_zi4l8PbkuAo,1960
20
- hooks/pre_gen_project.py,sha256=xQJERv3vv9VzIqcBHI281eeWLWREXUF4mMw7PvJHHXM,269
21
- tests/__init__.py,sha256=DG--S6IpGl399rzSAjDdHL76CkOIeZIjajCcyUSDhOQ,241
22
- tests/conftest.py,sha256=2ocZ2x-mZQrNe9zvWwhWk2_4ExdaBHIB74SvtDlExRE,21580
23
- tests/test_base_worker.py,sha256=2EIYcd_3f9O0zB5WiGIQV0Cn9wndLvnEnSfcAE1qWWU,30607
24
- tests/test_cache.py,sha256=ii0gyr0DrG7ChEs7pmT8hMdSguAOAcCze4bRMiFQxuk,10640
25
- tests/test_dataset_worker.py,sha256=r5SWdXSWKXGBFAgH6ouF2Nk-k6lLJ6SgXjKYD2Vu_Es,22088
26
- tests/test_element.py,sha256=2G9M15TLxQRmvrWM9Kw2ucnElh4kSv_oF_5FYwwAxTY,13181
27
- tests/test_image.py,sha256=J3jqB5OhcdCpB6n0UnwivxrMlne8YjFLXhq1gBMANrs,26711
28
- tests/test_merge.py,sha256=TuOeUS0UCz66DPOQFFhc4NQBxIjZL9f5czi4XnvGrr4,8270
29
- tests/test_utils.py,sha256=_WJUPnt-pM_TQ0er4yjPZy-u_LePrHq1lxwk_teky7M,2544
30
- tests/test_elements_worker/__init__.py,sha256=Fh4nkbbyJSMv_VtjQxnWrOqTnxXaaWI8S9WU0VrzCHs,179
31
- tests/test_elements_worker/test_classifications.py,sha256=fXZ8cSzIWwZ6LHsY7tKsy9-Pp9fKyKUStIXS4ViBcek,27779
32
- tests/test_elements_worker/test_cli.py,sha256=a23i1pUDbXi23MUtbWwGEcLLrmc_YlrbDgOG3h66wLM,2620
33
- tests/test_elements_worker/test_corpus.py,sha256=c_LUHvkJIYgk_wXF06VQPNOoWfiZ06XpjOXrJ7MRiBc,4479
34
- tests/test_elements_worker/test_dataset.py,sha256=lSXqubhg1EEq2Y2goE8Y2RYaqIpM9Iejq6fGNW2BczU,11411
35
- tests/test_elements_worker/test_elements.py,sha256=JZmqddzxuEFhGNnYj8iE4kA7mODYbMGNf7STnA8CVL4,115496
36
- tests/test_elements_worker/test_entities.py,sha256=oav2dtvWWavQe1l3Drbxw1Ta2ocUJEVxJfDQ_r6-rYQ,36181
37
- tests/test_elements_worker/test_image.py,sha256=_E3UGdDOwTo1MW5KMS81PrdeSPBPWinWYoQPNy2F9Ro,2077
38
- tests/test_elements_worker/test_metadata.py,sha256=cm2NNaXxBYmYMkPexSPVTAqb2skDTB4mliwQCLz8Y98,22293
39
- tests/test_elements_worker/test_task.py,sha256=7Sr3fbjdgWUXJUhJEiC9CwnbhQIQX3rCInmHMIrmA38,5573
40
- tests/test_elements_worker/test_training.py,sha256=Qxi9EzGr_uKcn2Fh5aE6jNrq1K8QKLiOiSew4upASPs,8721
41
- tests/test_elements_worker/test_transcriptions.py,sha256=FNY6E26iTKqe7LP9LO72By4oV4g9hBIZYTU9BAc_w7I,77060
42
- tests/test_elements_worker/test_worker.py,sha256=AuFDyqncIusT-rMMY4sEay9MqGvoNuSuZQq-5rHN02U,10803
43
- worker-demo/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- worker-demo/tests/conftest.py,sha256=XzNMNeg6pmABUAH8jN6eZTlZSFGLYjS3-DTXjiRN6Yc,1002
45
- worker-demo/tests/test_worker.py,sha256=3DLd4NRK4bfyatG5P_PK4k9P9tJHx9XQq5_ryFEEFVg,304
46
- worker-demo/worker_demo/__init__.py,sha256=2BPomV8ZMNf3YXJgloatKeHQCE6QOkwmsHGkO6MkQuM,125
47
- worker-demo/worker_demo/worker.py,sha256=Rt-DjWa5iBP08k58NDZMfeyPuFbtNcbX6nc5jFX7GNo,440
48
- arkindex_base_worker-0.4.0rc2.dist-info/LICENSE,sha256=NVshRi1efwVezMfW7xXYLrdDr2Li1AfwfGOd5WuH1kQ,1063
49
- arkindex_base_worker-0.4.0rc2.dist-info/METADATA,sha256=Akdq43GSmQL2Sr7VpaBGMjKlQtb1z8lIEUUBqoXoWg8,3304
50
- arkindex_base_worker-0.4.0rc2.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
51
- arkindex_base_worker-0.4.0rc2.dist-info/top_level.txt,sha256=58NuslgxQC2vT4DiqZEgO4JqJRrYa2yeNI9QvkbfGQU,40
52
- arkindex_base_worker-0.4.0rc2.dist-info/RECORD,,