diff options
author | Nao Pross <np@0hm.ch> | 2023-11-05 10:35:46 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2023-11-05 10:40:09 +0100 |
commit | 1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4 (patch) | |
tree | e682b5ed5ecd2d0de0be84b924595477a898ad9e /src | |
parent | Fix MyFinitePoset (diff) | |
download | act4e-1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4.tar.gz act4e-1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4.zip |
Fix (new) bug in MyFiniteSetProduct to pass TestFiniteMapRepresentation
Bug was caused by YAML bugfix
Diffstat (limited to '')
-rw-r--r-- | src/act4e_solutions/sets_product.py | 20 |
1 files changed, 2 insertions, 18 deletions
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]]: |