Files
PolyCubeCounting/python/polycube_encoder.py
2024-02-06 17:32:04 +01:00

12 lines
321 B
Python

from json import JSONEncoder
from typing import Any
from polycube import PolyCube
class PolyCubeEncdoder(JSONEncoder):
def default(self, o: Any) -> Any:
if isinstance(o, PolyCube):
return list(o.cubes)
elif isinstance(o, set):
return list(o)
return super().default(o)