Skip to content

Commit 4c0a654

Browse files
committed
update
1 parent d59aa96 commit 4c0a654

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

teaser/data/dataclass.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class DataClass(object):
2929
construction_data : ConstructionData
3030
The prefix of this parameter indicates which statistical data about building
3131
elements should be used. Its type is the enum class ConstructionData.
32+
To utilize custom TypeElements via a JSON file via parameter custom_path_type_elements (cf. below)
33+
use ConstructionData.custom.
3234
custom_path_type_elements: str or Path
3335
Custom path to JSON file of TypeElements. Default: None
3436
custom_path_material_templates: str or Path
@@ -64,10 +66,12 @@ def __init__(self,
6466

6567
"""Construct DataClass."""
6668
self.element_bind = None
67-
if custom_path_type_elements:
68-
self.path_tb = custom_path_type_elements
69-
elif not custom_path_type_elements and construction_data.is_custom():
70-
raise KeyError("Provide path to custom type elements .json file")
69+
if construction_data.is_custom():
70+
if custom_path_type_elements:
71+
self.path_tb = custom_path_type_elements
72+
elif not custom_path_type_elements:
73+
raise KeyError("Provide path to custom type elements JSON file "
74+
"or change ConstructionData to a known construction type")
7175
elif construction_data.is_iwu():
7276
self.path_tb = utils.get_full_path(
7377
"data/input/inputdata/TypeElements_IWU.json"
@@ -112,7 +116,7 @@ def __init__(self,
112116

113117
def load_tb_binding(self):
114118
"""Load TypeBuildingElement json into binding classes."""
115-
if self.path_tb.endswith("json"):
119+
if str(self.path_tb).endswith("json"):
116120
if os.path.isfile(self.path_tb):
117121
try:
118122
with open(self.path_tb, "r") as f:
@@ -127,7 +131,7 @@ def load_tb_binding(self):
127131

128132
def load_uc_binding(self):
129133
"""Load UseConditions json into binding classes."""
130-
if self.path_uc.endswith("json"):
134+
if str(self.path_uc).endswith("json"):
131135
if os.path.isfile(self.path_uc):
132136
try:
133137
with open(self.path_uc, "r") as f:
@@ -142,7 +146,7 @@ def load_uc_binding(self):
142146

143147
def load_mat_binding(self):
144148
"""Load MaterialTemplates json into binding classes."""
145-
if self.path_mat.endswith("json"):
149+
if str(self.path_mat).endswith("json"):
146150
if os.path.isfile(self.path_mat):
147151
try:
148152
with open(self.path_mat, "r") as f:

teaser/data/utilities.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class ConstructionData(Enum):
7777
The ConstructionData enumeration combines the former parameters “method” and “construction_type”.
7878
The prefix of each value is used to select the appropriate json file as input data.
7979
The complete value is used to search for the appropriate element within the json file.
80+
To utilize custom TypeElements via a JSON file via parameter custom_path_type_elements (cf. below)
81+
use ConstructionData.custom.
8082
"""
8183
iwu_heavy = "iwu_heavy"
8284
iwu_light = "iwu_light"
@@ -91,7 +93,7 @@ class ConstructionData(Enum):
9193
kfw_70 = "kfw_70"
9294
kfw_85 = "kfw_85"
9395
kfw_100 = "kfw_100"
94-
custom = "Custom"
96+
custom = "custom"
9597

9698
def get_prefix(self):
9799
parts = self.value.split("_", 2)
@@ -114,8 +116,7 @@ def is_kfw(self):
114116
return self.get_prefix() == "kfw"
115117

116118
def is_custom(self):
117-
if not any(s in self.value for s in ["iwu", "tabula_de", "tabula_dk", "kfw"]):
118-
return "custom" in self.value
119+
return self.value == "custom"
119120

120121
# Dictionary that maps GeometryData enumeration values to their corresponding building classes.
121122
geometries = {

0 commit comments

Comments
 (0)