summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2023-11-05 10:35:46 +0100
committerNao Pross <np@0hm.ch>2023-11-05 10:40:09 +0100
commit1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4 (patch)
treee682b5ed5ecd2d0de0be84b924595477a898ad9e
parentFix MyFinitePoset (diff)
downloadact4e-1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4.tar.gz
act4e-1a0cde2c2bfde11872d2a2e20d7f140da03d3ec4.zip
Fix (new) bug in MyFiniteSetProduct to pass TestFiniteMapRepresentation
Bug was caused by YAML bugfix
-rw-r--r--src/act4e_solutions/sets_product.py20
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]]: