Skip to content

Test the determinism contract of hflow.testing.joint_sine_parameters #34

Closed

Description

@kstonekuan

Current behavior

joint_sine_parameters (src/hflow/testing.py:220) is a public function in hflow.testing with a determinism contract in its docstring ("derived only from the spec"), and the synthetic-episode generator depends on it (src/hflow/testing.py:545). It has zero direct test coverage: nothing pins the contract that the same SyntheticEpisodeSpec always produces the same parameters, which is what makes synthetic test episodes reproducible across runs and machines.

Proposed change

Add a small behavioral test in tests/ covering the function's contract:

  • Determinism: two calls with specs sharing the same seed and joint_count return identical parameters.
  • Frequency span: the first joint gets JOINT_SINE_MIN_FREQUENCY_HZ, the last joint gets JOINT_SINE_MAX_FREQUENCY_HZ, and frequencies are evenly spaced between them.
  • Edge case: joint_count=1 returns a single pair at the minimum frequency (the max(spec.joint_count - 1, 1) guard).
  • Phase range: every phase is in [0, 2*pi).

Definition of done

  • The test asserts the observable contract above, not implementation details (per CONTRIBUTING.md: no tests that only assert how a helper is built internally).
  • Place it alongside the closest existing behavioral tests for hflow.testing.

Validation

uv run pytest -q
uv run ruff check --fix && uv run ruff format
uv run ty check
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions