forked from airbusgeo/playground-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_utils.py
59 lines (40 loc) · 1.76 KB
/
test_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# flake8: noqa: E501
import pytest
import numpy as np
from pygeos import box
from playground_metrics.utils.deprecation_utils import deprecated
from playground_metrics.utils.iou_utils import add_confidence_from_max_iou
def test_deprecation_no_docstring():
@deprecated('Reason')
def some_deprecated_function():
print('Some text')
with pytest.warns(DeprecationWarning):
some_deprecated_function()
print(some_deprecated_function.__doc__)
assert some_deprecated_function.__doc__ == """
.. warning::
The function ``some_deprecated_function`` is deprecated and may not work anymore or disappear in the future.
Reason for deprecation: *Reason*
"""
def test_deprecation_docstring():
@deprecated('Reason')
def some_deprecated_function():
"""Some docstring"""
print('Some text')
with pytest.warns(DeprecationWarning):
some_deprecated_function()
print(some_deprecated_function.__doc__)
assert some_deprecated_function.__doc__ == """
.. warning::
The function ``some_deprecated_function`` is deprecated and may not work anymore or disappear in the future.
Reason for deprecation: *Reason*
Some docstring"""
def test_confidence_from_max_iou_bbox():
detections = np.array([[box(0, 0, 9, 5)],
[box(23, 13, 29, 18)]])
ground_truths = np.array([[box(5, 2, 15, 9)],
[box(18, 10, 26, 15)]])
res = add_confidence_from_max_iou(detections, ground_truths)
assert np.all(res == np.array([[box(0, 0, 9, 5), 0.11650485436893204],
[box(23, 13, 29, 18), 0.09375]],
dtype=object))