Skip to content

Let Episode.frames_at_indices accept NumPy integer indices #308

Closed

Description

@kstonekuan

Current behavior

Episode.frames_at_indices() copies the requested indices, excludes Python booleans, then requires every value to satisfy isinstance(value, int).

NumPy integer scalars don't satisfy that check:

>>> isinstance(np.int64(3), int)
False

A list or array of frame indices obtained from NumPy is rejected with frame indices must be integers, even though the values are integral and HFlow already uses NumPy arrays for channel data. The existing end-to-end coverage passes only Python integers at tests/test_end_to_end.py:166-188.

Verified against main at fbfd553.

Pattern to copy

Catalog timestamp normalization converts NumPy scalars to Python scalars before applying the integer and boolean rules at src/hflow/catalog.py:413-458. Keep the same normalization order here so np.bool_ doesn't become an accepted integer.

What to build

Normalize supported NumPy integer scalars before validating, sorting, hashing, and indexing the requested frames.

Definition of done

  1. Python int, np.int32, np.int64, and unsigned NumPy integer indices are accepted when their values are valid.
  2. bool and np.bool_ remain refused.
  3. Floating-point values, including integral-looking values such as 3.0, remain refused.
  4. Negative, duplicate, descending, and out-of-range indices keep their current errors.
  5. Normalized NumPy indices produce the same extracted paths and log timestamps as equivalent Python indices.
  6. Extend the existing exact-frame behavioral test. Don't add tests for NumPy's own conversion behavior.
  7. No cache-key or extracted-frame layout changes.
  8. No new dependency or transform behavior-version bump is needed.

Non-goals

  • Accepting fractional indices
  • Sorting or deduplicating caller input
  • Changing ffmpeg selection behavior
  • Changing the public return type

Validation

uv run ruff check --fix
uv run ruff format
uv run ty check
uv run pytest -q tests/test_end_to_end.py
uv run pytest -q

Activity

  1. Sahas-Divi commented on Aug 31, 2026

    @Sahas-Divi

    Hi, I would like to take up this issue please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions