Skip to content

Commit 8d62d78

Browse files
committed
Improve type hinting slightly
1 parent f5553ad commit 8d62d78

4 files changed

Lines changed: 18 additions & 9 deletions

File tree

avstack/calibration.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
from __future__ import annotations
22

33
import json
4+
from typing import Union
45

56
import numpy as np
67

7-
from avstack.geometry.refchoc import ReferenceDecoder, ReferenceFrame
8+
from avstack.geometry.refchoc import (
9+
PassiveReferenceFrame,
10+
ReferenceDecoder,
11+
ReferenceFrame,
12+
)
813

914

1015
class CalibrationEncoder(json.JSONEncoder):
@@ -161,7 +166,7 @@ def allclose(self, other: RadarCalibration):
161166
class CameraCalibration(Calibration):
162167
def __init__(
163168
self,
164-
reference: ReferenceFrame,
169+
reference: Union[PassiveReferenceFrame, ReferenceFrame],
165170
P: np.ndarray,
166171
img_shape: tuple,
167172
focal_length: float = None,

avstack/modules/tracking/base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime
2-
from typing import List
2+
from typing import List, Union
33

44
import numpy as np
55

@@ -95,7 +95,12 @@ def tracks_active(self):
9595
return DataContainer(self.frame, self.timestamp, trks_active, self.name)
9696

9797
@apply_hooks
98-
def __call__(self, detections, platform: ReferenceFrame, **kwargs):
98+
def __call__(
99+
self,
100+
detections,
101+
platform: Union[PassiveReferenceFrame, ReferenceFrame],
102+
**kwargs,
103+
):
99104
if not isinstance(detections, DataContainer):
100105
raise ValueError(
101106
f"Detections are {type(detections)}, must be DataContainer"

avstack/modules/tracking/tracker3d.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .base import _TrackingAlgorithm
1212
from .tracks import (
1313
BasicBoxTrack3D,
14-
BasicJointBoxTrack,
1514
XyzFromRazelRrtTrack,
1615
XyzFromRazelTrack,
1716
XyzFromXyzTrack,
@@ -251,7 +250,7 @@ def track(self, detections, platform, **kwargs):
251250
lone_3d_to_det_map[i_det - len(fused_detections)]
252251
]
253252
self.tracks.append(
254-
BasicJointBoxTrack(self.timestamp, None, d3d, platform, o3d)
253+
BasicJointBoxTrack3D(self.timestamp, None, d3d, platform, o3d)
255254
)
256255
# ----- unassigned from the 2D to 2D step
257256
for i_det in assign_sol_3.unassigned_rows:
@@ -262,13 +261,13 @@ def track(self, detections, platform, **kwargs):
262261
obj_types_3d[lone_fused_to_det_map[i_det][1]],
263262
)
264263
self.tracks.append(
265-
BasicJointBoxTrack(self.timestamp, d2d, d3d, platform, o2d)
264+
BasicJointBoxTrack3D(self.timestamp, d2d, d3d, platform, o2d)
266265
)
267266
else:
268267
d2d = lone_2d[i_det - len(lone_fused)]
269268
o2d = obj_types_2d[lone_2d_to_det_map[i_det - len(lone_fused)]]
270269
self.tracks.append(
271-
BasicJointBoxTrack(self.timestamp, d2d, None, platform, o2d)
270+
BasicJointBoxTrack3D(self.timestamp, d2d, None, platform, o2d)
272271
)
273272

274273
# -- prune dead tracks

tests/modules/fusion/test_fusion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_ci_fusion_base_naive_bayes():
4040
assert np.allclose(P_f, P)
4141

4242

43-
def test_fusion_into_boxtrack():
43+
def test_fusion_into_BoxTrack3D():
4444
tracks = get_n_tracks(n_tracks=4)
4545
fuser = fusion.CovarianceIntersectionFusionToBox()
4646
fused_out = fuser(tracks)

0 commit comments

Comments
 (0)