From da2e878bf982ea2a0fe7727b68dfa211409973bb Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 17 Oct 2023 15:03:23 +0200 Subject: Something weird is going on here --- src/act4e_solutions/sets_representation.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/act4e_solutions/sets_representation.py') diff --git a/src/act4e_solutions/sets_representation.py b/src/act4e_solutions/sets_representation.py index 9e231c1..627b408 100644 --- a/src/act4e_solutions/sets_representation.py +++ b/src/act4e_solutions/sets_representation.py @@ -61,5 +61,12 @@ class SolFiniteSetRepresentation(I.FiniteSetRepresentation): raise I.InvalidFormat() def save(self, h: I.IOHelper, f: I.FiniteSet[Any]) -> I.FiniteSet_desc: - all_elements = [f.save(h, e) for e in f.elements()] - return {"elements": all_elements} + if isinstance(f, MyFiniteSetProduct): + return {"product": [{"elements": c.elements()} for c in f.components()]} + + elif isinstance(f, MyFiniteSet): + all_elements = [f.save(h, e) for e in f.elements()] + return {"elements": all_elements} + + else: + raise I.InvalidFormat() -- cgit v1.2.1