Skip to content

test: add equal-objects-equal-hash tests and enforce static: dict[str… - #32

Merged
jeqcho merged 1 commit into
robocurve:mainfrom
Adityakk9031:#30
Jul 25, 2026
Merged

test: add equal-objects-equal-hash tests and enforce static: dict[str…#32
jeqcho merged 1 commit into
robocurve:mainfrom
Adityakk9031:#30

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Closes #30

Summary

Follow-up to #26 closing the two hashability gaps identified in #30:

  1. Equal-Objects-Equal-Hash Invariant: Updated test_instances_and_realizations_are_hashable to construct two independent but value-equal instances/realizations (a == b), asserting hash(a) == hash(b) and dict key lookup {a: "x"}[b] == "x". This guards against identity-hashing regressions.
  2. Tightened static Field Type: Changed TaskInstance.static annotation from dict[str, Any] to dict[str, Scalar] (hashable scalars only) so unhashable structures (e.g. lists) cannot be inserted into static.
  3. Spec-Wide Hashing Verification: Added an assertion loop traversing all task instances across SPECS to verify hash(instance) succeeds for all 50 instances.

Changes

  • instances.py: Tightened static field type annotation from dict[str, Any] to dict[str, Scalar].
  • embodiment.py: Typed _render() return signature as np.ndarray[Any, Any] to satisfy mypy generic requirements.
  • test_instances.py: Added equal-object hash checks, dict lookup assertions, and spec-wide SPECS hash iteration.

Verification

  • pytest --cov passed 377/377 tests with 100.00% statement & branch coverage.
  • ruff check . & ruff format --check . passed cleanly.
  • mypy strict type checking passed with 0 issues.

@Adityakk9031

Copy link
Copy Markdown
Contributor Author

@jeqcho have a look

@jeqcho
jeqcho merged commit a6b3982 into robocurve:main Jul 25, 2026
9 checks passed
@jeqcho

jeqcho commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. Hashing every spec in SPECS rather than a sample is what makes the invariant hold for specs nobody has written yet.

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.

Hashability follow-ups: equal-objects-equal-hash test, and static: dict[str, Any] can silently reintroduce unhashability

2 participants