Skip to content

Conversation

@yuxizhe
Copy link
Contributor

@yuxizhe yuxizhe commented Nov 5, 2025

No description provided.

@yifanfeng97 yifanfeng97 requested a review from Copilot November 5, 2025 15:11
@yifanfeng97 yifanfeng97 merged commit ccf3e54 into iMoonLab:main Nov 5, 2025
15 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for HIF (Hypergraph Interchange Format) import/export functionality to the HypergraphDB class, enabling standardized data exchange with other hypergraph tools.

  • Implements to_hif(), save_as_hif(), from_hif(), and load_from_hif() methods for HIF format support
  • Adds comprehensive test coverage for HIF export/import, roundtrip conversion, and attribute preservation
  • Updates documentation in README and API docs to describe the new HIF functionality

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
hyperdb/hypergraph.py Adds HIF format export/import methods with incidence-based format handling
tests/test_hypergraph.py Adds three test functions covering HIF export/import, roundtrip, and attribute preservation
docs/api/index.md Documents new HIF-related methods in persistence operations table
docs/api/index.zh.md Chinese documentation for HIF functionality with usage examples
README.md Adds HIF format save/load examples to the persistence section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


# Find edge in edges array
edge_12 = next(
(e for e in hif_data["edges"] if "1" in str(e["edge"]) and "2" in str(e["edge"])),
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String-based edge matching is fragile and could produce false positives. For example, edge IDs '10_11' and '21_22' would both match when looking for edges containing '1' and '2'. Use exact comparison instead: if e['edge'] == '1_2' or set(str(e['edge']).split('_')) == {'1', '2'}.

Suggested change
(e for e in hif_data["edges"] if "1" in str(e["edge"]) and "2" in str(e["edge"])),
(
e
for e in hif_data["edges"]
if (
(isinstance(e["edge"], (tuple, list)) and set(e["edge"]) == {1, 2})
or
(isinstance(e["edge"], str) and set(e["edge"].split("_")) == {"1", "2"})
)
),

Copilot uses AI. Check for mistakes.
e_data = self._e_data[e_tuple]

# Extract attrs (all fields except weight)
e_attrs = {k: v for k, v in e_data.items() if k != "weight"}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment to 'e_attrs' is unnecessary as it is redefined before this value is used.

Suggested change
e_attrs = {k: v for k, v in e_data.items() if k != "weight"}

Copilot uses AI. Check for mistakes.
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.

2 participants