diff options
Diffstat (limited to 'src/act4e_solutions/sets_representation.py')
-rw-r--r-- | src/act4e_solutions/sets_representation.py | 11 |
1 files changed, 9 insertions, 2 deletions
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() |