Skip to content

Commit

Permalink
Reverting some doc modifications to follow the library standard
Browse files Browse the repository at this point in the history
  • Loading branch information
gbg141 committed Jun 3, 2024
1 parent 867c470 commit fd0c20d
Show file tree
Hide file tree
Showing 8 changed files with 502 additions and 450 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
args: [ --fix ]
- id: ruff-format

- repo: https://github.com/numpy/numpydoc
rev: v1.6.0
hooks:
- id: numpydoc-validation
# - repo: https://github.com/numpy/numpydoc
# rev: v1.6.0
# hooks:
# - id: numpydoc-validation
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ dependencies=[
"jupyterlab",
"rich",
"rootutils",
"toponetx @ git+https://github.com/pyt-team/TopoNetX.git",
"topomodelx @ git+https://github.com/pyt-team/TopoModelX.git",
"topoembedx @ git+https://github.com/pyt-team/TopoEmbedX.git",
#"toponetx @ git+https://github.com/pyt-team/TopoNetX.git",
#"topomodelx @ git+https://github.com/pyt-team/TopoModelX.git",
#"topoembedx @ git+https://github.com/pyt-team/TopoEmbedX.git",
"lightning",
]

Expand Down
23 changes: 10 additions & 13 deletions topobenchmarkx/data/load/base.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from abc import ABC, abstractmethod

import torch_geometric
from omegaconf import DictConfig


class AbstractLoader(ABC):
"""
Abstract class that provides an interface to load data.
"""Abstract class that provides an interface to load data.
Parameters
----------
parameters : DictConfig
Configuration parameters.
Args:
parameters (DictConfig): Configuration parameters.
"""

def __init__(self, parameters: DictConfig):
Expand All @@ -20,13 +18,12 @@ def __repr__(self) -> str:
return f"{self.__class__.__name__}(parameters={self.cfg})"

@abstractmethod
def load(self) -> torch_geometric.data.Data:
"""
Load data into Data.
def load(
self,
) -> torch_geometric.data.Data:
"""Load data into Data.
Raises
------
NotImplementedError
If the method is not implemented.
Raises:
NotImplementedError: If the method is not implemented.
"""
raise NotImplementedError
123 changes: 55 additions & 68 deletions topobenchmarkx/data/load/loaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

import numpy as np
import torch_geometric
from omegaconf import DictConfig
Expand All @@ -21,29 +22,24 @@


class GraphLoader(AbstractLoader):
"""
Loader for graph datasets.
Parameters
----------
parameters : DictConfig
Configuration parameters. The parameters must contain the following keys:
- data_dir (str): The directory where the dataset is stored.
- data_name (str): The name of the dataset.
- data_type (str): The type of the dataset.
- split_type (str): The type of split to be used. It can be "fixed", "random", or "k-fold".
If split_type is "random", the parameters must also contain the following keys:
- data_seed (int): The seed for the split.
- data_split_dir (str): The directory where the split is stored.
- train_prop (float): The proportion of the training set.
If split_type is "k-fold", the parameters must also contain the following keys:
- data_split_dir (str): The directory where the split is stored.
- k (int): The number of folds.
- data_seed (int): The seed for the split.
The parameters can be defined in a yaml file and then loaded using `omegaconf.OmegaConf.load('path/to/dataset/config.yaml')`.
r"""Loader for graph datasets.
Args:
parameters (DictConfig): Configuration parameters. The parameters must contain the following keys:
- data_dir (str): The directory where the dataset is stored.
- data_name (str): The name of the dataset.
- data_type (str): The type of the dataset.
- split_type (str): The type of split to be used. It can be "fixed", "random", or "k-fold".
If split_type is "random", the parameters must also contain the following keys:
- data_seed (int): The seed for the split.
- data_split_dir (str): The directory where the split is stored.
- train_prop (float): The proportion of the training set.
If split_type is "k-fold", the parameters must also contain the following keys:
- data_split_dir (str): The directory where the split is stored.
- k (int): The number of folds.
- data_seed (int): The seed for the split.
The parameters can be defined in a yaml file and then loaded using `omegaconf.OmegaConf.load('path/to/dataset/config.yaml')`.
"""

def __init__(self, parameters: DictConfig, **kwargs):
Expand All @@ -54,13 +50,10 @@ def __repr__(self) -> str:
return f"{self.__class__.__name__}(parameters={self.parameters})"

def load(self) -> tuple[torch_geometric.data.Dataset, str]:
"""
Load graph dataset.
r"""Load graph dataset.
Returns
-------
tuple[torch_geometric.data.Dataset, str]
A tuple containing the loaded dataset and the data directory.
Returns:
DataloadDataset: DataloadDataset object containing the loaded data.
"""
# Define the path to the data directory
root_data_dir = self.parameters["data_dir"]
Expand Down Expand Up @@ -142,78 +135,72 @@ def load(self) -> tuple[torch_geometric.data.Dataset, str]:


class CellComplexLoader(AbstractLoader):
"""
Loader for cell complex datasets.
r"""Loader for cell complex datasets.
Parameters
----------
parameters : DictConfig
Configuration parameters.
Args:
parameters (DictConfig): Configuration parameters.
"""

def __init__(self, parameters: DictConfig):
super().__init__(parameters)
self.parameters = parameters

def load(self) -> torch_geometric.data.Dataset:
"""
Load cell complex dataset.
def load(
self,
) -> torch_geometric.data.Dataset:
r"""Load cell complex dataset.
Returns
-------
torch_geometric.data.Dataset
A torch_geometric.data.Dataset object containing the loaded data.
Args:
None
Returns:
torch_geometric.data.Dataset: torch_geometric.data.Dataset object containing the loaded data.
"""
return load_cell_complex_dataset(self.parameters)


class SimplicialLoader(AbstractLoader):
"""
Loader for simplicial datasets.
r"""Loader for simplicial datasets.
Parameters
----------
parameters : DictConfig
Configuration parameters.
Args:
parameters (DictConfig): Configuration parameters.
"""

def __init__(self, parameters: DictConfig):
super().__init__(parameters)
self.parameters = parameters

def load(self) -> torch_geometric.data.Dataset:
"""
Load simplicial dataset.
def load(
self,
) -> torch_geometric.data.Dataset:
r"""Load simplicial dataset.
Returns
-------
torch_geometric.data.Dataset
A torch_geometric.data.Dataset object containing the loaded data.
Args:
None
Returns:
torch_geometric.data.Dataset: torch_geometric.data.Dataset object containing the loaded data.
"""
return load_simplicial_dataset(self.parameters)


class HypergraphLoader(AbstractLoader):
"""
Loader for hypergraph datasets.
r"""Loader for hypergraph datasets.
Parameters
----------
parameters : DictConfig
Configuration parameters.
Args:
parameters (DictConfig): Configuration parameters.
"""

def __init__(self, parameters: DictConfig):
super().__init__(parameters)
self.parameters = parameters

def load(self) -> torch_geometric.data.Dataset:
"""
Load hypergraph dataset.
def load(
self,
) -> torch_geometric.data.Dataset:
r"""Load hypergraph dataset.
Returns
-------
torch_geometric.data.Dataset
A torch_geometric.data.Dataset object containing the loaded data.
Args:
None
Returns:
torch_geometric.data.Dataset: torch_geometric.data.Dataset object containing the loaded data.
"""
return load_hypergraph_pickle_dataset(self.parameters)
Loading

0 comments on commit fd0c20d

Please sign in to comment.