Unified interface for PyTorch Geometric Hypergraph Learning
Project description
pyg-hyper: Unified PyTorch Geometric Hypergraph Learning
Unified interface for all pyg-hyper components, providing convenient access to hypergraph datasets, neural network layers, self-supervised learning methods, and benchmarking protocols.
Prerequisites
This package requires PyTorch Geometric to be installed:
pip install torch torch-geometric
Installation
Install all components
pip install pyg-hyper[all]
Or with uv:
uv add pyg-hyper[all]
Install Specific Components
# Data only
pip install pyg-hyper[data]
# Neural networks only
pip install pyg-hyper[nn]
# Self-supervised learning
pip install pyg-hyper[ssl]
# Benchmarking
pip install pyg-hyper[bench]
# Combine multiple
pip install pyg-hyper[data,nn]
Quick Start
Import Style
Import directly from each sub-package:
from pyg_hyper.data.datasets import CoraCocitation
from pyg_hyper.bench import NodeClassificationProtocol, SingleRunEvaluator
from pyg_hyper.ssl import TriCL, TriCLEncoder
Dataset Loading
from pyg_hyper.data.datasets import CoraCocitation
dataset = CoraCocitation()
data = dataset[0]
print(data) # HyperData with x, hyperedge_index, y
SSL Training & Evaluation
from pyg_hyper.data.datasets import CoraCocitation
from pyg_hyper.ssl import TriCL, TriCLEncoder
from pyg_hyper.bench import SSLLinearEvaluationProtocol
dataset = CoraCocitation()
data = dataset[0]
# Build encoder and SSL model
encoder = TriCLEncoder(
in_dim=data.num_node_features,
edge_dim=64,
node_dim=64,
num_layers=2,
)
model = TriCL(encoder=encoder, proj_dim=64)
# Get embeddings for downstream evaluation
embeddings = model.get_embeddings(data) # [num_nodes, node_dim]
# Linear evaluation
protocol = SSLLinearEvaluationProtocol(seed=42)
split = protocol.split_data(data)
metrics = protocol.evaluate(
embeddings=embeddings,
labels=data.y,
train_mask=split["train_mask"],
val_mask=split["val_mask"],
test_mask=split["test_mask"],
)
print(f"Test Accuracy: {metrics['test_accuracy']:.4f}")
Architecture
This is a pure meta-package that provides:
- ✅ Unified import interface via lazy loading
- ✅ Zero import overhead (loads only what you use)
- ✅ Independent versioning of sub-packages
- ✅ Maximum flexibility (install only what you need)
Sub-Packages
| Package | Description | Version |
|---|---|---|
| pyg-hyper-data | Hypergraph datasets (11 datasets) | 0.1.1 |
| pyg-hyper-nn | Neural network layers | 0.1.1 |
| pyg-hyper-ssl | Self-supervised learning | 0.1.1 |
| pyg-hyper-bench | Benchmarking framework | 0.1.1 |
Development
Setup
# Clone repository
git clone https://github.com/nishide-dev/pyg-hyper.git
cd pyg-hyper
# Install with dev dependencies
uv sync --all-extras
# Install pre-commit hooks
uv run pre-commit install
Code Quality
# Lint
uv run ruff check src/ tests/
# Format
uv run ruff format src/ tests/
# Type check
uv run ty check src/
Testing
# Run all tests
uv run pytest tests/ -v
# Run only import tests
uv run pytest tests/test_imports.py -v
# Run only integration tests
uv run pytest tests/ -v -m integration
# With coverage
uv run pytest tests/ --cov=pyg_hyper --cov-report=html
Pre-commit Hooks
Automatically run code quality checks before commits:
ruff-lint: Linting with auto-fixruff-format: Code formattingty-check: Type checking
Install hooks:
uv run pre-commit install
Run manually:
uv run pre-commit run --all-files
CI/CD
GitHub Actions
- CI Pipeline: Code quality, import tests, integration tests
- Publish Pipeline: Automatic publishing to TestPyPI (main branch) and PyPI (tags)
Publishing
# TestPyPI (automatic on push to main)
uv publish --index testpypi
# PyPI (automatic on tag v*)
git tag v0.1.0
git push origin v0.1.0
License
MIT License - See LICENSE file for details.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Run pre-commit hooks
- Submit a pull request
Citation
If you use pyg-hyper in your research, please cite:
@software{pyg_hyper,
title = {pyg-hyper: Unified PyTorch Geometric Hypergraph Learning},
author = {Ryusei Nishide},
year = {2026},
url = {https://github.com/nishide-dev/pyg-hyper}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyg_hyper-0.1.2.tar.gz.
File metadata
- Download URL: pyg_hyper-0.1.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52cc4ebe3222eb5e6da0c544fd124f7f86bc6dd22b59b327c8eb52ec5a805ede
|
|
| MD5 |
f2f7c397f5b6266077b257bc589d8b97
|
|
| BLAKE2b-256 |
9a28a2fc8dec20f0292de5e28fbb7b41383b7c3ab3c4661c78915cf264c3f750
|
File details
Details for the file pyg_hyper-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pyg_hyper-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b20b61a1a64613f7493330fc53fce1e71fc18c749c1ce0373512f89a540dbbc3
|
|
| MD5 |
dcba59cafc805380b0952e43ac9ef213
|
|
| BLAKE2b-256 |
d0f847b5ddf09c062f19c091390c71a7d4951cfa266539bb05331618cbb13999
|