Skip to content

Commit

Permalink
🎨 More robust temp converter
Browse files Browse the repository at this point in the history
  • Loading branch information
je-cook committed Dec 4, 2023
1 parent 5bbd969 commit fe120ed
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bluemira/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ def _mutate_value(
obj=None,
) -> MaterialProperty:
if isinstance(value, dict):
if "temp_min" not in value and "temp_min_celsius" in value:
value["temp_max"] = to_kelvin(value["temp_max_celsius"])
value["temp_min"] = to_kelvin(value["temp_min_celsius"])
for k in ("temp_min_celsius", "temp_max_celsius"):
del value[k]
# Convert temp_*_celsius to temp_*
if change := {"temp_min_celsius", "temp_max_celsius"}.intersection(value):
if {"temp_min", "temp_max"}.difference(value) != {}:
for key in change:
value[key.rsplit("_", 1)[0]] = to_kelvin(value[key])
for key in change:
del value[key]
# empty dictionary
value = MaterialProperty(**value, obj=obj) if value else self._default

Expand Down

0 comments on commit fe120ed

Please sign in to comment.