serializer.py
717 B · python · 23 lines
1from typing import Any, Dict, TYPE_CHECKING2from mrlypy.two.serializer import to_dict_2d, from_dict_2d34if TYPE_CHECKING:5 from .models import Cell6d67def to_dict_6d(cell: "Cell6d") -> Dict[str, Any]:8 data = to_dict_2d(cell._cell)9 data["projection"] = cell.projection10 data["orientation"] = cell.orientation11 data["start"] = cell.start12 return data1314def from_dict_6d(data: Dict[str, Any]) -> "Cell6d":15 from .models import Cell6d16 from mrlypy.two.models import Cell2d17 cell_2d = from_dict_2d(data)18 return Cell6d(19 cell=cell_2d,20 projection=data.get("projection", "iso"),21 orientation=data.get("orientation", "vertical"),22 start=data.get("start", 1),23 )