Skip to content

HIF refactor and added from_hif_dict/to_hif_dict - #51

Open
viniciusdutra314 wants to merge 2 commits into
HGX-Team:mainfrom
viniciusdutra314:hif_refactor
Open

HIF refactor and added from_hif_dict/to_hif_dict#51
viniciusdutra314 wants to merge 2 commits into
HGX-Team:mainfrom
viniciusdutra314:hif_refactor

Conversation

@viniciusdutra314

Copy link
Copy Markdown

Summary

I recently started my master’s thesis on community detection in hypergraphs. Because I use several hypergraph libraries together, HIF compatibility is important for interoperability across the hypergraph ecosystem.

This PR refactors the HIF serialization module and adds dictionary-based conversion through from_hif_dict and to_hif_dict , inspired by XGI’s interface. These functions now contain the core serialization and deserialization logic, while read_hif  and write_hif remain backward-compatible wrappers responsible only for file I/O.

The dictionary interface allows applications to exchange HIF data entirely in memory, without unnecessary intermediate files.

While reviewing the repository history, I found that the existing implementation appeared to target an early version of HIF and had no dedicated tests or validation against the official JSON Schema. This PR updates the implementation for HIF v0.1.0 and adds:

  • Validation of generated dictionaries against hif_schema_v0.1.0.json in the test suite, using jsonschema as a development dependency.
  • Round-trip tests for directed and undirected hypergraphs.
  • Coverage for metadata, weights, incidences, isolated nodes, empty edges, invalid input, and edge-ID collisions.
  • Public TypedDict definitions representing the HIF structures in Python’s type system.
  • Static type checking with basedpyright.

Some typing features used here are not included in Python 3.10’s standard typing module. To preserve support for Python 3.10, typing_extensions is included conditionally for Python versions earlier than 3.11.

This is a relatively large change, but it is limited to HIF serialization and deserialization. I am happy to adjust it according to the maintainers’ preferences. Working on it was also a valuable opportunity for me to study the HIF format in depth.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor/maintenance

Validation

  • black --check .
  • ruff check .
  • pytest
  • python -m build
  • twine check dist/*

Checklist

  • Added or updated tests for behavior changes
  • [x ] Updated docs for user-facing changes
  • [ x] Kept changes focused and scoped

@viniciusdutra314 viniciusdutra314 changed the title Hif refactor HIF refactor and added from_hif_dict/to_hif_dict Aug 13, 2026
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