Skip to content

Commit

Permalink
Merge pull request #1063 from roboflow/get_data_item_tests
Browse files Browse the repository at this point in the history
`get_data_item` unit tests
  • Loading branch information
SkalskiP authored Mar 28, 2024
2 parents 69563b8 + dc5f841 commit 7132c03
Showing 1 changed file with 58 additions and 10 deletions.
68 changes: 58 additions & 10 deletions test/detection/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ def test_merge_data(
"test_1": [1],
},
DoesNotRaise(),
), # single data dict with a single field name and list values
), # data dict with a single list field and integer index
(
{
"test_1": np.array([1, 2, 3]),
Expand All @@ -1055,7 +1055,7 @@ def test_merge_data(
"test_1": np.array([1]),
},
DoesNotRaise(),
), # single data dict with a single field name and np.array values as 1D arrays
), # data dict with a single np.array field and integer index
(
{
"test_1": [1, 2, 3],
Expand All @@ -1065,7 +1065,7 @@ def test_merge_data(
"test_1": [1, 2],
},
DoesNotRaise(),
), # single data dict with a single field name and list values
), # data dict with a single list field and slice index
(
{
"test_1": np.array([1, 2, 3]),
Expand All @@ -1075,7 +1075,7 @@ def test_merge_data(
"test_1": np.array([1, 2]),
},
DoesNotRaise(),
), # single data dict with a single field name and np.array values as 1D arrays
), # data dict with a single np.array field and slice index
(
{
"test_1": [1, 2, 3],
Expand All @@ -1085,7 +1085,7 @@ def test_merge_data(
"test_1": [3],
},
DoesNotRaise(),
), # single data dict with a single field name and list values
), # data dict with a single list field and negative integer index
(
{
"test_1": np.array([1, 2, 3]),
Expand All @@ -1095,7 +1095,7 @@ def test_merge_data(
"test_1": np.array([3]),
},
DoesNotRaise(),
), # single data dict with a single field name and np.array values as 1D arrays
), # data dict with a single np.array field and negative integer index
(
{
"test_1": [1, 2, 3],
Expand All @@ -1105,7 +1105,7 @@ def test_merge_data(
"test_1": [1, 3],
},
DoesNotRaise(),
), # single data dict with a single field name and list values
), # data dict with a single list field and integer list index
(
{
"test_1": np.array([1, 2, 3]),
Expand All @@ -1115,7 +1115,7 @@ def test_merge_data(
"test_1": np.array([1, 3]),
},
DoesNotRaise(),
), # single data dict with a single field name and np.array values as 1D arrays
), # data dict with a single np.array field and integer list index
(
{
"test_1": [1, 2, 3],
Expand All @@ -1125,7 +1125,7 @@ def test_merge_data(
"test_1": [1, 3],
},
DoesNotRaise(),
), # single data dict with a single field name and list values
), # data dict with a single list field and integer np.array index
(
{
"test_1": np.array([1, 2, 3]),
Expand All @@ -1135,7 +1135,55 @@ def test_merge_data(
"test_1": np.array([1, 3]),
},
DoesNotRaise(),
),
), # data dict with a single np.array field and integer np.array index
(
{
"test_1": np.array([1, 2, 3]),
},
np.array([True, True, True]),
{
"test_1": np.array([1, 2, 3]),
},
DoesNotRaise(),
), # data dict with a single np.array field and all-true bool np.array index
(
{
"test_1": np.array([1, 2, 3]),
},
np.array([False, False, False]),
{
"test_1": np.array([]),
},
DoesNotRaise(),
), # data dict with a single np.array field and all-false bool np.array index
(
{
"test_1": np.array([1, 2, 3]),
},
np.array([False, True, False]),
{
"test_1": np.array([2]),
},
DoesNotRaise(),
), # data dict with a single np.array field and mixed bool np.array index
(
{"test_1": np.array([1, 2, 3]), "test_2": ["a", "b", "c"]},
0,
{"test_1": np.array([1]), "test_2": ["a"]},
DoesNotRaise(),
), # data dict with two fields and integer index
(
{"test_1": np.array([1, 2, 3]), "test_2": ["a", "b", "c"]},
-1,
{"test_1": np.array([3]), "test_2": ["c"]},
DoesNotRaise(),
), # data dict with two fields and negative integer index
(
{"test_1": np.array([1, 2, 3]), "test_2": ["a", "b", "c"]},
np.array([False, True, False]),
{"test_1": np.array([2]), "test_2": ["b"]},
DoesNotRaise(),
), # data dict with two fields and mixed bool np.array index
],
)
def test_get_data_item(
Expand Down

0 comments on commit 7132c03

Please sign in to comment.