From 14b134e942b18dcf3955c4a5f690774497b92911 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 16 Nov 2023 22:29:09 +0100 Subject: Fix bug when uptolevel is None --- src/act4e_solutions/semicategory_representation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/act4e_solutions/semicategory_representation.py b/src/act4e_solutions/semicategory_representation.py index 9012c4f..4ab9909 100644 --- a/src/act4e_solutions/semicategory_representation.py +++ b/src/act4e_solutions/semicategory_representation.py @@ -37,10 +37,13 @@ class MySemiCategory(Generic[OD, MD], I.SemiCategory[ROD, RMD]): def add_object(self, ob: ROD): self._objects[ob.label] = ob + def get_object(self, label: str): + return self._objects[label] + def add_morphism(self, source: str, target: str, mor: RMD): if not (source, target) in self._morphisms[0].keys(): self._morphisms[0][source, target] = [] - self._morphisms[0][(source, target)].append(mor) + self._morphisms[0][source, target].append(mor) def objects(self, uptolevel: Optional[int] = None) -> EnumerableSet[ROD]: return MyFiniteSet(self._objects.values()) @@ -100,7 +103,7 @@ class MySemiCategory(Generic[OD, MD], I.SemiCategory[ROD, RMD]): return morphisms - morphisms = all_morphisms(ob1.label, ob2.label, uptolevel) + morphisms = all_morphisms(ob1.label, ob2.label, uptolevel or 0) return MyFiniteSet(morphisms) def compose(self, ob1: ROD, ob2: ROD, ob3: ROD, m1: RMD, m2: RMD) -> RMD: -- cgit v1.2.1