Skip to content

Commit 02eedcc

Browse files
authored
Merge pull request #55 from NavAbility/minifix/doc_changes
Fixing tests
2 parents 885f1c9 + ce90862 commit 02eedcc

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"marshmallow==3.14.0",
3434
"numpy>=1.21",
3535
# Dev/test dependencies
36-
"black==21.9b0",
36+
"black>=22.3.0", # REF: https://github.com/psf/black/issues/2634
3737
"flake8==4.0.1",
3838
"pytest==6.2.5",
3939
"pytest-asyncio==0.18.1",

src/navability/entities/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Point2Point2Range,
1717
Pose2AprilTag4Corners,
1818
Pose2Point2BearingRange,
19+
Pose2Point2Range,
1920
Pose2Pose2,
2021
Prior,
2122
PriorPoint2,

src/navability/entities/factor/inferencetypes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,28 @@ def dumps(self):
163163
# TODO: Deserializing this.
164164

165165

166+
"""
167+
Create a Pose2->Point2 range factor with a 1D distribution:
168+
- range: The range from the pose to the point.
169+
"""
170+
171+
172+
@dataclass
173+
class Pose2Point2Range(InferenceType):
174+
Z: Distribution
175+
176+
def __repr__(self):
177+
return f"<{self.__class__.__name__}(Z={str(self.Z)})>"
178+
179+
def dump(self):
180+
return ZSchema().dump(self)
181+
182+
def dumps(self):
183+
return ZSchema().dumps(self)
184+
185+
# TODO: Deserializing this.
186+
187+
166188
"""
167189
Create a Pose2->Point2 bearing+range factor with 1D distributions:
168190
- bearing: The bearing from the pose to the point.

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
NavAbilityHttpsClient,
1818
NavAbilityWebsocketClient,
1919
Normal,
20-
Point2Point2Range,
2120
Pose2Point2BearingRange,
21+
Pose2Point2Range,
2222
Pose2Pose2,
2323
Prior,
2424
PriorPoint2,
@@ -204,9 +204,9 @@ async def example_2d_graph(
204204
),
205205
Factor(
206206
"x0l0f1",
207-
"Point2Point2Range",
207+
"Pose2Point2Range",
208208
["x0", "l0"],
209-
FactorData(fnc=Point2Point2Range(Normal(5, 0.1)).dump()), # Range
209+
FactorData(fnc=Pose2Point2Range(Normal(5, 0.1)).dump()), # Range
210210
),
211211
Factor(
212212
"x0l0f2",

tests/test_inference_types_serialization.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Point2Point2Range,
1010
Pose2AprilTag4Corners,
1111
Pose2Point2BearingRange,
12+
Pose2Point2Range,
1213
Pose2Pose2,
1314
Prior,
1415
PriorPoint2,
@@ -101,6 +102,16 @@ def test_point2point2range():
101102
pass
102103

103104

105+
def test_pose2point2range():
106+
pose = Pose2Point2Range(Normal(89.44271909999159, 3))
107+
dumped = pose.dumps()
108+
assert (
109+
dumped
110+
== '{"Z": {"_type": "IncrementalInference.PackedNormal", "mu": 89.44271909999159, "sigma": 3.0}}' # noqa: E501, B950
111+
)
112+
pass
113+
114+
104115
def test_pose2point2bearingrange():
105116
pose = Pose2Point2BearingRange(Normal(0, 0.03), Normal(0.5, 0.1))
106117
dumped = pose.dumps()

0 commit comments

Comments
 (0)