-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement OtherSensor.from_json()
- Loading branch information
unexcellent
committed
Nov 11, 2024
1 parent
6885445
commit a3a9da0
Showing
4 changed files
with
60 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from ._sensor_without_intrinsics import _SensorWithoutIntrinsics | ||
|
||
|
||
class OtherSensor(_SensorWithoutIntrinsics): | ||
"""A sensor that is not represented by the available options.""" |
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,46 @@ | ||
# Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from raillabel.format import OtherSensor | ||
from raillabel.json_format import JSONCoordinateSystem, JSONStreamOther | ||
|
||
# == Fixtures ========================= | ||
|
||
|
||
@pytest.fixture | ||
def other_json(transform_json) -> tuple[JSONStreamOther, JSONCoordinateSystem]: | ||
return ( | ||
JSONStreamOther( | ||
type="other", | ||
uri="/path/to/sensor/data", | ||
description="A very nice generic sensor", | ||
), | ||
JSONCoordinateSystem( | ||
parent="base", type="sensor", pose_wrt_parent=transform_json, children=[] | ||
), | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def other(transform) -> dict: | ||
return OtherSensor( | ||
extrinsics=transform, | ||
uri="/path/to/sensor/data", | ||
description="A very nice generic sensor", | ||
) | ||
|
||
|
||
# == Tests ============================ | ||
|
||
|
||
def test_from_json(other, other_json): | ||
actual = OtherSensor.from_json(other_json[0], other_json[1]) | ||
assert actual == other | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main([__file__, "--disable-pytest-warnings", "--cache-clear", "-v"]) |