From 1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sun, 5 Nov 2023 10:35:46 +0100 Subject: Fix (new) bug in MyFiniteSetProduct to pass TestFiniteMapRepresentation Bug was caused by YAML bugfix --- src/act4e_solutions/sets_product.py | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src/act4e_solutions') diff --git a/src/act4e_solutions/sets_product.py b/src/act4e_solutions/sets_product.py index 42b8640..508fd45 100644 --- a/src/act4e_solutions/sets_product.py +++ b/src/act4e_solutions/sets_product.py @@ -19,7 +19,7 @@ class MyFiniteSetProduct(I.FiniteSetProduct[C, E]): return prod(map(lambda c: c.size(), self._components)) def contains(self, x: E) -> bool: - if type(x) != type(self._components): + if not isinstance(x, Iterable): return False if len(x) != len(self._components): @@ -27,6 +27,7 @@ class MyFiniteSetProduct(I.FiniteSetProduct[C, E]): for (e, s) in zip(x, self._components): if not s.contains(e): + print(f"{s} does not contain {e}") return False return True @@ -42,26 +43,9 @@ class MyFiniteSetProduct(I.FiniteSetProduct[C, E]): def save(self, h: I.IOHelper, x: E) -> I.ConcreteRepr: return cast(I.ConcreteRepr, x) - # raise NotImplementedError - # return {"elements": [e for e in self.elements()]} def load(self, h: I.IOHelper, o: I.ConcreteRepr): return cast(E, o) - # raise NotImplementedError - # if not isinstance(o, dict): - # raise I.InvalidFormat() - - # if not "elements" in o: - # raise I.InvalidFormat() - - # nsets = len(o["elements"][0]) - # components = [[] for _ in range(nsets)] - # for elements in o["elements"]: - # for c, e in zip(components, elements): - # if not e in c: - # c.append(e) - - # return MyFiniteSetProduct(components) # Product behaviour def components(self) -> Sequence[I.FiniteSet[C]]: -- cgit v1.2.1