Spaces:
Sleeping
Sleeping
Update app/data_validation.py
Browse files- app/data_validation.py +14 -10
app/data_validation.py
CHANGED
|
@@ -263,17 +263,13 @@ class DataValidation:
|
|
| 263 |
messages.append(f"People Load #{i+1}: Name is required.")
|
| 264 |
|
| 265 |
# Check numeric fields
|
| 266 |
-
if person.get("
|
| 267 |
is_valid = False
|
| 268 |
-
messages.append(f"People Load #{i+1}:
|
| 269 |
|
| 270 |
-
if person.get("
|
| 271 |
is_valid = False
|
| 272 |
-
messages.append(f"People Load #{i+1}:
|
| 273 |
-
|
| 274 |
-
if person.get("latent_heat", 0) < 0:
|
| 275 |
-
is_valid = False
|
| 276 |
-
messages.append(f"People Load #{i+1}: Latent heat must be non-negative.")
|
| 277 |
|
| 278 |
# Check lighting loads
|
| 279 |
lighting = internal_loads.get("lighting", [])
|
|
@@ -291,6 +287,10 @@ class DataValidation:
|
|
| 291 |
if light.get("usage_factor", 0) < 0 or light.get("usage_factor", 0) > 1:
|
| 292 |
is_valid = False
|
| 293 |
messages.append(f"Lighting Load #{i+1}: Usage factor must be between 0 and 1.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
# Check equipment loads
|
| 296 |
equipment = internal_loads.get("equipment", [])
|
|
@@ -312,6 +312,10 @@ class DataValidation:
|
|
| 312 |
if equip.get("radiation_fraction", 0) < 0 or equip.get("radiation_fraction", 0) > 1:
|
| 313 |
is_valid = False
|
| 314 |
messages.append(f"Equipment Load #{i+1}: Radiation fraction must be between 0 and 1.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
return is_valid, messages
|
| 317 |
|
|
@@ -417,7 +421,7 @@ class DataValidation:
|
|
| 417 |
Boolean indicating whether validation succeeded
|
| 418 |
"""
|
| 419 |
if data_key not in session_state:
|
| 420 |
-
st.error(f"No {data_key.replace('_', ' ')} data found.")
|
| 421 |
return False
|
| 422 |
|
| 423 |
# Validate data
|
|
@@ -487,4 +491,4 @@ if __name__ == "__main__":
|
|
| 487 |
data_validation.validate_building_info,
|
| 488 |
"building_info",
|
| 489 |
"Building information is valid!"
|
| 490 |
-
)
|
|
|
|
| 263 |
messages.append(f"People Load #{i+1}: Name is required.")
|
| 264 |
|
| 265 |
# Check numeric fields
|
| 266 |
+
if person.get("num_people", 0) < 0:
|
| 267 |
is_valid = False
|
| 268 |
+
messages.append(f"People Load #{i+1}: Number of people must be non-negative.")
|
| 269 |
|
| 270 |
+
if person.get("hours_in_operation", 0) <= 0:
|
| 271 |
is_valid = False
|
| 272 |
+
messages.append(f"People Load #{i+1}: Hours in operation must be positive.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
|
| 274 |
# Check lighting loads
|
| 275 |
lighting = internal_loads.get("lighting", [])
|
|
|
|
| 287 |
if light.get("usage_factor", 0) < 0 or light.get("usage_factor", 0) > 1:
|
| 288 |
is_valid = False
|
| 289 |
messages.append(f"Lighting Load #{i+1}: Usage factor must be between 0 and 1.")
|
| 290 |
+
|
| 291 |
+
if light.get("hours_in_operation", 0) <= 0:
|
| 292 |
+
is_valid = False
|
| 293 |
+
messages.append(f"Lighting Load #{i+1}: Hours in operation must be positive.")
|
| 294 |
|
| 295 |
# Check equipment loads
|
| 296 |
equipment = internal_loads.get("equipment", [])
|
|
|
|
| 312 |
if equip.get("radiation_fraction", 0) < 0 or equip.get("radiation_fraction", 0) > 1:
|
| 313 |
is_valid = False
|
| 314 |
messages.append(f"Equipment Load #{i+1}: Radiation fraction must be between 0 and 1.")
|
| 315 |
+
|
| 316 |
+
if equip.get("hours_in_operation", 0) <= 0:
|
| 317 |
+
is_valid = False
|
| 318 |
+
messages.append(f"Equipment Load #{i+1}: Hours in operation must be positive.")
|
| 319 |
|
| 320 |
return is_valid, messages
|
| 321 |
|
|
|
|
| 421 |
Boolean indicating whether validation succeeded
|
| 422 |
"""
|
| 423 |
if data_key not in session_state:
|
| 424 |
+
st.error(f"No {data_key.replace('_', ' ').title()} data found.")
|
| 425 |
return False
|
| 426 |
|
| 427 |
# Validate data
|
|
|
|
| 491 |
data_validation.validate_building_info,
|
| 492 |
"building_info",
|
| 493 |
"Building information is valid!"
|
| 494 |
+
)
|