-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
raillabel_providerkit/validation/validate_empty_frames/__init__.py
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,3 @@ | ||
# Copyright DB Netz AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
"""Package for validating a scene for empty frames.""" |
26 changes: 26 additions & 0 deletions
26
raillabel_providerkit/validation/validate_empty_frames/validate_empty_frames.py
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,26 @@ | ||
# Copyright DB Netz AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import List | ||
|
||
import raillabel | ||
|
||
|
||
def validate_empty_frames(scene: raillabel.Scene) -> List[str]: | ||
"""Validate whether all frames of a scene have at least one annotation. | ||
Parameters | ||
---------- | ||
scene : raillabel.Scene | ||
Scene, that should be validated. | ||
Returns | ||
------- | ||
list[str] | ||
list of all onthology errors in the scene. If an empty list is returned, then there are no | ||
errors present. | ||
""" | ||
|
||
|
||
def _is_frame_empty(frame: raillabel.format.Frame) -> bool: | ||
return len(frame.annotations) == 0 |
40 changes: 40 additions & 0 deletions
40
.../test_raillabel_providerkit/validation/validate_empty_frame/test_validate_empty_frames.py
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,40 @@ | ||
# Copyright DB Netz AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
import pytest | ||
import raillabel | ||
|
||
sys.path.append(str(Path(__file__).parent.parent.parent.parent.parent)) | ||
from raillabel_providerkit.validation.validate_empty_frames.validate_empty_frames import ( | ||
_is_frame_empty, | ||
) | ||
|
||
# == Tests ============================ | ||
|
||
def test_is_frame_empty__true(): | ||
frame = raillabel.format.Frame(uid=0, annotations={}) | ||
assert _is_frame_empty(frame) | ||
|
||
def test_is_frame_empty__false(): | ||
frame = raillabel.format.Frame( | ||
uid=0, annotations={ | ||
"581b0df1-c4cf-4a97-828e-13dd740defe5": raillabel.format.Bbox( | ||
uid=None, | ||
object=None, | ||
sensor=None, | ||
attributes=None, | ||
pos=raillabel.format.Point2d(0, 0), | ||
size=raillabel.format.Size2d(0, 0), | ||
) | ||
} | ||
) | ||
assert not _is_frame_empty(frame) | ||
|
||
|
||
if __name__ == "__main__": | ||
os.system("clear") | ||
pytest.main([__file__, "--disable-pytest-warnings", "--cache-clear", "-v"]) |