From 47e5fb1c8e5b9db43ab135fbad700d1e26250e50 Mon Sep 17 00:00:00 2001 From: Taoning Wang Date: Wed, 25 Oct 2023 12:10:15 -0700 Subject: [PATCH] fix deserilization in GlazingSystem.from_json --- frads/window.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frads/window.py b/frads/window.py index 84172d1..e0fcc58 100644 --- a/frads/window.py +++ b/frads/window.py @@ -136,7 +136,21 @@ def from_json(cls, path: Union[str, Path]): """Load a glazing system from a JSON file.""" with open(path, "r") as f: data = json.load(f) - return cls(**data) + layers = data.pop("layers") + layer_instances = [] + for layer in layers: + rgb = layer.pop("rgb") + layer_instances.append(Layer(rgb=PaneRGB(**rgb), **layer)) + gaps = data.pop("gaps") + gap_instances = [] + for gap in gaps: + gas_instances = [] + gases = gap.pop("gas") + for gs in gases: + gas_instances.append(Gas(**gs)) + gap_instances.append(Gap(gas=gas_instances, **gap)) + return cls(layers=layer_instances, gaps=gap_instances, **data) + def get_brtdfunc(self) -> pr.Primitive: """Get a BRTDfunc primitive for the glazing system."""