Skip to content

Commit 523efa7

Browse files
committed
mypy
1 parent 8ca8689 commit 523efa7

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

openptv_python/track.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def angle_acc(start: np.ndarray, pred: np.ndarray, cand: np.ndarray) -> np.ndarr
253253
acc = np.linalg.norm(v0 - v1)
254254

255255
if np.all(v0 == -v1):
256-
angle = 200
256+
angle = 200.0
257257
elif np.all(v0 == v1):
258258
angle = 0
259259
else:

tests/test_tracking_ground_truth.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from contextlib import ExitStack, redirect_stdout
88
from dataclasses import dataclass
99
from pathlib import Path
10+
from typing import cast
1011
from unittest.mock import patch
1112

1213
import numpy as np
@@ -186,7 +187,8 @@ def _make_bounds(*, dv_limit: float, dacc: float, dangle: float) -> dict[str, fl
186187

187188

188189
def _rounded_position(pos: np.ndarray) -> tuple[float, float, float]:
189-
return tuple(round(float(value), 5) for value in pos)
190+
values = tuple(round(float(value), 5) for value in pos)
191+
return cast(tuple[float, float, float], values)
190192

191193

192194
def _snapshot_graph(snapshot):
@@ -359,7 +361,7 @@ def _write_synthetic_tracking_fixture(
359361

360362
for frame_index, frame_num in enumerate(FRAMES):
361363
frame = Frame(3, 16)
362-
cam_targets = [[] for _ in range(3)]
364+
cam_targets: list[list[Target]] = [[] for _ in range(3)]
363365
correspond_indices = {
364366
track_id: [CORRES_NONE] * 4
365367
for track_id, positions in tracks.items()
@@ -427,7 +429,9 @@ def _write_synthetic_tracking_fixture(
427429
correspond_indices[track_id],
428430
dtype=np.int32,
429431
)
430-
frame.path_info[row_index].x = tracks[track_id][frame_index]
432+
position = tracks[track_id][frame_index]
433+
assert position is not None
434+
frame.path_info[row_index].x = position
431435

432436
write_path_frame(
433437
frame.correspond,
@@ -446,7 +450,10 @@ def _snapshot_tracking_outputs() -> dict[
446450
int, list[tuple[int, int, tuple[int, int, int, int], tuple[float, float, float]]]
447451
]:
448452
"""Read the written tracking outputs into a stable frame-by-frame snapshot."""
449-
snapshots = {}
453+
snapshots: dict[
454+
int,
455+
list[tuple[int, int, tuple[int, int, int, int], tuple[float, float, float]]],
456+
] = {}
450457
for frame in FRAMES:
451458
correspond, path_info = read_path_frame(
452459
"res/particles",
@@ -458,8 +465,14 @@ def _snapshot_tracking_outputs() -> dict[
458465
(
459466
int(path.prev_frame),
460467
int(path.next_frame),
461-
tuple(int(value) for value in correspond[idx].p),
462-
tuple(round(float(value), 5) for value in path.x),
468+
cast(
469+
tuple[int, int, int, int],
470+
tuple(int(value) for value in correspond[idx].p),
471+
),
472+
cast(
473+
tuple[float, float, float],
474+
tuple(round(float(value), 5) for value in path.x),
475+
),
463476
)
464477
for idx, path in enumerate(path_info)
465478
]

0 commit comments

Comments
 (0)