Skip to content

InMemoryFeatureStore

InMemoryFeatureStore()

Bases: FeatureStore

A FeatureStore keeping its arrays in memory (as mx.array).

Example:

from mlx_graphs.data import InMemoryFeatureStore

feature_store = InMemoryFeatureStore.from_data(data)
feature_store.get_tensor(attr_name="x", index=mx.array([0, 3]))

Methods:

Name Description
from_data

A store holding the array attributes of a

Source code in mlx_graphs/data/feature_store.py
def __init__(self):
    self._store: dict[tuple, mx.array] = {}

from_data classmethod

from_data(data: Any, attrs: Optional[list[str]] = None) -> InMemoryFeatureStore

A store holding the array attributes of a GraphData (all but edge_index unless attrs lists the ones to keep).

Source code in mlx_graphs/data/feature_store.py
@classmethod
def from_data(
    cls, data: Any, attrs: Optional[list[str]] = None
) -> "InMemoryFeatureStore":
    """A store holding the array attributes of a
    :class:`~mlx_graphs.data.GraphData` (all but ``edge_index`` unless
    ``attrs`` lists the ones to keep)."""
    store = cls()
    for name, value in _graph_arrays(data, attrs).items():
        store.put_tensor(value, attr_name=name)
    return store

from mlx_graphs.data import InMemoryFeatureStore · mlx_graphs/data/feature_store.py