Skip to content

Commit

Permalink
fix deserilization in GlazingSystem.from_json
Browse files Browse the repository at this point in the history
  • Loading branch information
Taoning Wang committed Oct 25, 2023
1 parent b99f962 commit 47e5fb1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frads/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 47e5fb1

Please sign in to comment.