Skip to content

validate_edge_index_and_features

validate_edge_index_and_features(func)

Decorator function to check the validity of an edge_index and edge_features.

Source code in mlx_graphs/utils/validators.py
def validate_edge_index_and_features(func):
    """Decorator function to check the validity of an edge_index and edge_features."""

    @functools.wraps(func)
    @validate_edge_index
    def wrapper(edge_index, edge_features=None, *args, **kwargs):
        if edge_features is not None:
            if edge_index.shape[1] != edge_features.shape[0]:
                raise ValueError(
                    "edge_features must be 1 per edge ",
                    f"(got {edge_index.shape[1]} edges",
                    f"and {edge_features.shape[0]} features)",
                )
        return func(edge_index, edge_features, *args, **kwargs)

    return wrapper

from mlx_graphs.utils.validators import validate_edge_index_and_features · mlx_graphs/utils/validators.py