Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d9e7a3
docs: fix griffe warnings
ddevin96 Jun 4, 2026
f333fc2
docs: fix spaces and not correct rendering
ddevin96 Jun 5, 2026
409f1d2
fix: fix lines more than 100
ddevin96 Jun 5, 2026
e3198a2
fix: fix lines more than 100
ddevin96 Jun 5, 2026
d529c78
fix: fix lines more than 100
ddevin96 Jun 5, 2026
c40097c
fix: fix lines more than 100
ddevin96 Jun 5, 2026
217d4ba
fix: fix lines more than 100
ddevin96 Jun 5, 2026
519e24b
fix: fix lines more than 100
ddevin96 Jun 5, 2026
7a80af8
fix: fix lines more than 100
ddevin96 Jun 5, 2026
c578fd2
fix: fix lines more than 100
ddevin96 Jun 5, 2026
f6f4e7c
fix: fix lines more than 100
ddevin96 Jun 5, 2026
8f5d129
fix: fix lines more than 100
ddevin96 Jun 5, 2026
32dbb29
fix: remove rule for formatting - changed pr template
ddevin96 Jun 5, 2026
7a74a10
fix: add color to output on success
ddevin96 Jun 8, 2026
ab7eeaa
fix: fix lines more than 100
ddevin96 Jun 9, 2026
e62510a
fix: strange function appeared
ddevin96 Jun 9, 2026
598b981
fix: wrong rebased comment
ddevin96 Jun 10, 2026
55104ac
fix: small rebase fix
ddevin96 Jun 10, 2026
8f6e8fe
chore: fix warning in docs
ddevin96 Jun 11, 2026
d4790e6
chore: remove empyy lines in docstring
ddevin96 Jun 11, 2026
e9a7ca9
docs: fix return variables for tuples
ddevin96 Jun 11, 2026
efe810f
fix: fix PR comments
ddevin96 Jun 11, 2026
66e6706
docs: good formatting docstring
ddevin96 Jun 11, 2026
4de7ab7
fix: fix docstrings
ddevin96 Jun 11, 2026
ad07a24
fix: fix re
ddevin96 Jun 11, 2026
c0eb054
fix: formatting
ddevin96 Jun 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### All Submissions
### All submissions

- [ ] Have you followed the guidelines in our [Contributing](../../CONTRIBUTING.md) document?
- [ ] Have you checked to ensure there are no other open [Pull Requests](../../../pulls) for the same changes?
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
make build
- name: Check docstrings
continue-on-error: true # TODO: remove when all docstring issues are fixed
run: |
make docstring-check
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ setup-tensorboard:
@echo '=== Setup TensorBoard ==='
$(UV) pip install -e ".[tensorboard]"

check: lint format typecheck
check: typecheck format lint docstring-check

format:
@echo '=== Formatting ==='
Expand Down Expand Up @@ -73,8 +73,6 @@ si-test:
@echo '=== Running single integration test for $(T) ==='
$(UV) run $(PYTEST) -n auto -s $(PROJECT_NAME)/integration_tests/$(T) -m "integration"



# If the first argument is run...
ifeq ($(firstword $(MAKECMDGOALS)),run)
# use the rest as arguments for run...
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ HyperBench declares compatibility ranges for direct dependencies in `pyproject.t

| Dependency | Supported range | Notes |
| --- | --- | --- |
| mkdocstrings[python] | `>=1.0.4,<2.0.0` | |
| mkdocstrings\[python\] | `>=1.0.4,<2.0.0` | |
| pre-commit | `>=4.5.1,<5.0.0` | |
| pytest | `>=9.0.3,<10.0.0` | |
| pytest-cov | `>=7.1.0,<8.0.0` | |
Expand Down
3 changes: 2 additions & 1 deletion examples/early_stopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
train_dataset.enrich_node_features(
enricher=LaplacianPositionalEncodingEnricher(
num_features=num_features,
# In transductive setting, use total number of nodes to ensure consistent encoding across splits
# In transductive setting, use total number of nodes to ensure consistent encoding
# across splits
# as the train dataset contain all nodes but may have no hyperedges where they appear
num_nodes=train_dataset.hdata.num_nodes,
),
Expand Down
3 changes: 2 additions & 1 deletion examples/external_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
train_dataset.enrich_node_features(
enricher=LaplacianPositionalEncodingEnricher(
num_features=num_features,
# In transductive setting, use total number of nodes to ensure consistent encoding across splits
# In transductive setting, use total number of nodes to ensure consistent encoding
# across splits
# as the train dataset contain all nodes but may have no hyperedges where they appear
num_nodes=train_dataset.hdata.num_nodes,
),
Expand Down
5 changes: 4 additions & 1 deletion hyperbench/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@

warnings.filterwarnings(
"ignore",
message="ignore:Failing to pass a value to the 'type_params' parameter of 'typing._eval_type' is deprecated.*",
message=(
"ignore:Failing to pass a value to the 'type_params' parameter of "
"'typing._eval_type' is deprecated.*"
),
)
143 changes: 91 additions & 52 deletions hyperbench/data/dataset.py

Large diffs are not rendered by default.

115 changes: 76 additions & 39 deletions hyperbench/data/enricher.py

Large diffs are not rendered by default.

43 changes: 30 additions & 13 deletions hyperbench/data/hif.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@


class HIFProcessor:
"""A utility class to process HIF hypergraph data into `HData` format."""
"""
A utility class to process HIF hypergraph data into `HData` format.
"""

@staticmethod
def transform_attrs(
Expand All @@ -34,11 +36,13 @@ def transform_attrs(
) -> Tensor:
"""
Extract and encode numeric attributes to tensor.

Non-numeric attributes are discarded. Missing attributes are filled with ``0.0``.

Args:
attrs: Dictionary of attributes
attr_keys: Optional list of attribute keys to encode. If provided, ensures consistent ordering and fill missing with ``0.0``.
attr_keys: Optional list of attribute keys to encode. If provided,
ensures consistent ordering and fill missing with ``0.0``.

Returns:
attrs: Tensor of numeric attribute values
Expand Down Expand Up @@ -67,7 +71,6 @@ def process_hypergraph(cls, hypergraph: HIFHypergraph) -> HData:
Returns:
hdata: The processed hypergraph data.
"""

num_nodes = len(hypergraph.nodes)
x = cls.__process_x(hypergraph, num_nodes)

Expand All @@ -93,7 +96,8 @@ def process_hypergraph(cls, hypergraph: HIFHypergraph) -> HData:
)

if hyperedge_id not in hyperedge_id_to_idx:
# Hyperedges start from 0 and are assigned IDs in the order they are first encountered in incidences
# Hyperedges start from 0 and are assigned IDs in the order they are
# first encountered in incidences
hyperedge_id_to_idx[hyperedge_id] = len(hyperedge_id_to_idx)

node_ids.append(node_id_to_idx[node_id])
Expand Down Expand Up @@ -244,7 +248,9 @@ def __process_hyperedge_weights(


class HIFLoader:
"""A utility class to load hypergraphs from HIF format."""
"""
A utility class to load hypergraphs from HIF format.
"""

@classmethod
def load_from_url(cls, url: str, save_on_disk: bool = False) -> HData:
Expand All @@ -263,7 +269,8 @@ def load_from_url(cls, url: str, save_on_disk: bool = False) -> HData:
response = requests.get(url, timeout=20)
if response.status_code != 200:
raise ValueError(
f"Failed to download dataset from URL {url!r} with status code {response.status_code}"
f"Failed to download dataset from URL {url!r} "
f"with status code {response.status_code}"
)

if not url.endswith((".json.zst", ".json")):
Expand All @@ -273,7 +280,9 @@ def load_from_url(cls, url: str, save_on_disk: bool = False) -> HData:

if os.path.basename(url).count(".") > 2:
raise ValueError(
f"URL {url!r} has an unexpected filename format. Expected at most one dot in the base filename before the extension (e.g., dataset.json or dataset.json.zst)."
f"URL {url!r} has an unexpected filename format. "
"Expected at most one dot in the base filename before the "
"extension (e.g., dataset.json or dataset.json.zst)."
)

if url.endswith(".json.zst"):
Expand All @@ -298,7 +307,8 @@ def load_from_url(cls, url: str, save_on_disk: bool = False) -> HData:
@classmethod
def load_from_path(cls, filepath: str) -> HData:
"""
Load a hypergraph from a local file path pointing to a .json or .json.zst file in HIF format.
Load a hypergraph from a local file path pointing to a .json or .json.zst file in HIF
format.

Args:
filepath: The local file path to the .json or .json.zst file
Expand Down Expand Up @@ -337,7 +347,10 @@ def load_by_name(
hif_data = from_zst_file_to_json(zst_filename)
return cls.__process_hif_data(hif_data, dataset_name)

github_url = f"https://raw.githubusercontent.com/hypernetwork-research-group/datasets/{GITHUB_COMMIT_SHA}/{dataset_name}.json.zst"
github_url = (
f"https://raw.githubusercontent.com/hypernetwork-research-group/datasets/"
f"{GITHUB_COMMIT_SHA}/{dataset_name}.json.zst"
)
response = requests.get(github_url, timeout=20)
if response.status_code == 200:
dataset_bytes = response.content
Expand All @@ -348,15 +361,17 @@ def load_by_name(
return hdata

warnings.warn(
f"GitHub raw download failed for dataset {dataset_name!r} with status code {response.status_code}\n"
f"GitHub raw download failed for dataset {dataset_name!r} "
f"with status code {response.status_code}\n"
"Falling back to Hugging Face Hub download for dataset",
category=UserWarning,
stacklevel=2,
)

if hf_sha is None:
raise ValueError(
f"Failed to download dataset {dataset_name!r} from GitHub with status code {response.status_code} "
f"Failed to download dataset {dataset_name!r} from GitHub "
f"with status code {response.status_code} "
f"and no SHA provided for Hugging Face Hub fallback."
)

Expand Down Expand Up @@ -384,7 +399,8 @@ def load_by_name(
shutil.copyfile(downloaded_path, zst_filename)
except Exception as e:
raise ValueError(
f"Failed to save downloaded dataset {dataset_name!r} to disk at {zst_filename!r}: {e!s}."
f"Failed to save downloaded dataset {dataset_name!r} to disk at "
f"{zst_filename!r}: {e!s}."
) from e

if os.path.isdir(hf_cache_dir):
Expand All @@ -394,7 +410,8 @@ def load_by_name(
shutil.rmtree(os.path.join(hf_cache_dir, ".locks", path_prefix))
except Exception as e:
warnings.warn(
f"Failed to clean up Hugging Face Hub cache after downloading dataset {dataset_name!r}: {e!s}.",
f"Failed to clean up Hugging Face Hub cache after downloading "
f"dataset {dataset_name!r}: {e!s}.",
category=UserWarning,
stacklevel=2,
)
Expand Down
16 changes: 9 additions & 7 deletions hyperbench/data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ def collate(self, batch: list[HData]) -> HData:
"""
Collates a list of `HData` objects into a single batched `HData` object.

This function combines multiple separate samples into a single batched representation suitable for mini-batch training.
It handles:
- Concatenating node features from all samples.
- Concatenating and offsetting hyperedges from all samples.
- Concatenating hyperedge attributes from all samples, if present.
- Concatenating hyperedge weights from all samples, if present.
This function combines multiple separate samples into a single batched representation
suitable for mini-batch training.

Handles:
- Concatenating node features from all samples.
- Concatenating and offsetting hyperedges from all samples.
- Concatenating hyperedge attributes from all samples, if present.
- Concatenating hyperedge weights from all samples, if present.

Examples:
Given ``batch = [HData_0, HData_1]``:
Expand All @@ -56,7 +58,7 @@ def collate(self, batch: list[HData]) -> HData:
- ``HData_0`` (3 nodes, 2 hyperedges):

>>> hyperedge_index = [[0, 1, 1, 2], # Nodes 0, 1, 1, 2
... [0, 0, 1, 1]] # Hyperedge 0 contains {0,1}, Hyperedge 1 contains {1,2}
... [0, 0, 1, 1]] # HE 0 contains {0,1}, HE 1 contains {1,2}

- ``HData_1`` (2 nodes, 1 hyperedge):

Expand Down
Loading
Loading