HIF refactor and added from_hif_dict/to_hif_dict - #51
Open
viniciusdutra314 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_hifremain 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:
hif_schema_v0.1.0.jsonin the test suite, usingjsonschemaas a development dependency.TypedDictdefinitions representing the HIF structures in Python’s type system.Some typing features used here are not included in Python 3.10’s standard
typingmodule. To preserve support for Python 3.10,typing_extensionsis 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
Validation
black --check .ruff check .pytestpython -m buildtwine check dist/*Checklist