Skip to content

Fix viz.py type hints: optional waypoints + rotate_90cc annotations#95

Open
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
lonexreb:fix/viz-optional-types-and-rotate90cc-annotations
Open

Fix viz.py type hints: optional waypoints + rotate_90cc annotations#95
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
lonexreb:fix/viz-optional-types-and-rotate90cc-annotations

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented May 4, 2026

Problem

Two small type-annotation hygiene nits in src/alpamayo_r1/visualization/viz.py:

1. viz_waypoints_pai annotates non-optional but accepts None.

Signature:

def viz_waypoints_pai(
    intr_df: pd.DataFrame,
    extr_df: pd.DataFrame,
    image,
    waypoints_gt: np.ndarray,
    waypoints_pred: np.ndarray,
):

Docstring:

waypoints_gt: Ground-truth waypoint tensor, or None to skip.
waypoints_pred: Predicted waypoint tensor, or None to skip.

Body:

if waypoints_gt is not None: ...
if waypoints_pred is not None: ...

Type checkers reject the documented None usage outright.

2. rotate_90cc has no annotations.

def rotate_90cc(xy):
    """Rotate 2D coordinates 90 degrees counter-clockwise: (x, y) -> (-y, x)."""
    return np.stack([-xy[1], xy[0]], axis=0)

The neighboring make_image_grid is fully annotated; rotate_90cc is the odd one out.

Fix

Pure typing/docstring change. No runtime behavior change.

  • Update viz_waypoints_pai parameters to np.ndarray | None.
  • Annotate rotate_90cc as xy: np.ndarray -> np.ndarray and add a short Args/Returns block noting the expected (2, N) shape.

Two small type-annotation hygiene nits in
src/alpamayo_r1/visualization/viz.py:

- viz_waypoints_pai declares `waypoints_gt: np.ndarray` and
  `waypoints_pred: np.ndarray` (non-Optional), but the docstring
  explicitly says "or None to skip" for both, and the body guards
  `if waypoints_gt is not None` / `if waypoints_pred is not None`
  before drawing. Update the annotations to `np.ndarray | None` so
  type checkers agree with the documented contract.

- rotate_90cc has no annotations on either parameter or return value.
  Add `xy: np.ndarray -> np.ndarray` and a short docstring noting the
  expected shape, matching the style of make_image_grid above it.

Pure typing/docstring change. No runtime behavior change.

Signed-off-by: lonexreb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant