Skip to content

Fix HIF roundtrip test expectation#174

Merged
eggpig merged 1 commit into
pybind11from
fix/hif-roundtrip-test-expectation
Jun 8, 2026
Merged

Fix HIF roundtrip test expectation#174
eggpig merged 1 commit into
pybind11from
fix/hif-roundtrip-test-expectation

Conversation

@eggpig

@eggpig eggpig commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR updates the HIF roundtrip test to assert the current HIF conversion semantics correctly.

The failing assertion expected the original HIF node id ("n1") to appear in hg.v_property[*]["name"]. That expectation does not match the implementation. In hif_to_hypergraph, v_property[*]["name"] is populated from the HIF node attribute selected by node_label, which defaults to "name". For this test fixture, the input node is:

{"node": "n1", "weight": 1.0, "attrs": {"name": "Node A"}}

So the EasyGraph vertex property name should be "Node A", while the original HIF node id "n1" is preserved separately in hg.custom_hif_nodes and in the exported HIF JSON.

Root Cause

The test mixed two different HIF concepts:

  • node: the HIF node identifier, for example "n1".
  • attrs.name: a user-facing node attribute, for example "Node A".

The implementation preserves both, but stores them in different places. The test was checking the HIF id in the EasyGraph attribute-name field.

Changes

  • Assert that hg.v_property[*]["name"] preserves attrs.name as "Node A" / "Node B".
  • Assert that the original HIF node ids "n1" / "n2" are preserved in hg.custom_hif_nodes.
  • Assert that exported HIF JSON still contains the original node ids after roundtrip.
  • Format the touched test file with Black/isort and remove the unused os import.

Validation

  • /tmp/easygraph-ci-smoke-clean-venv/bin/python -m pytest easygraph/tests/test_hif.py -q --disable-warnings
    • 2 passed
  • /tmp/easygraph-ci-smoke-clean-venv/bin/python -m pytest easygraph -q --disable-warnings
    • 813 passed, 2 skipped
  • /tmp/easygraph-ci-smoke-clean-venv/bin/python -m black --check easygraph/tests/test_hif.py
  • /tmp/easygraph-ci-smoke-clean-venv/bin/python -m isort --check-only easygraph/tests/test_hif.py
  • git diff --check

@eggpig eggpig marked this pull request as ready for review June 8, 2026 07:20
@eggpig eggpig merged commit 75572cc into pybind11 Jun 8, 2026
12 checks passed
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