From 7b1a41e589dbd2894382bbc2879eab46aed7f759 Mon Sep 17 00:00:00 2001 From: Terencio Agozzino Date: Fri, 9 Apr 2021 10:14:47 +0200 Subject: [PATCH] fix: add cache for local KG --- pyrdf2vec/graphs/kg.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyrdf2vec/graphs/kg.py b/pyrdf2vec/graphs/kg.py index db4488ce..5fc773a2 100644 --- a/pyrdf2vec/graphs/kg.py +++ b/pyrdf2vec/graphs/kg.py @@ -406,6 +406,9 @@ def _fill_hops(self, entities: Entities) -> None: hops = self._res2hops(Vertex(entity), res) self._entity_hops.update({entity: hops}) + @cachedmethod( + operator.attrgetter("cache"), key=partial(hashkey, "_get_hops") + ) def _get_hops(self, vertex: Vertex, is_reverse: bool = False) -> List[Hop]: """Returns the hops of a vertex for a local Knowledge Graph.