Spaces:
Sleeping
Sleeping
Delete utils.py
Browse files
utils.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
import matplotlib.pyplot as plt
|
| 2 |
-
|
| 3 |
-
def validate_inputs(input_data):
|
| 4 |
-
"""
|
| 5 |
-
Validate input data for required fields and ranges.
|
| 6 |
-
"""
|
| 7 |
-
required_fields = [
|
| 8 |
-
"project_name", "phase", "task", "current_progress",
|
| 9 |
-
"task_expected_duration", "task_actual_duration", "workforce_gap",
|
| 10 |
-
"workforce_shift_hours", "weather_impact_score", "weather_condition",
|
| 11 |
-
"weather_forecast_date"
|
| 12 |
-
]
|
| 13 |
-
for field in required_fields:
|
| 14 |
-
if not input_data[field]:
|
| 15 |
-
return f"Please select or fill in {field.replace('_', ' ').lower()}"
|
| 16 |
-
if not (0 <= input_data["current_progress"] <= 100):
|
| 17 |
-
return "Current progress must be between 0 and 100"
|
| 18 |
-
if not (0 <= input_data["workforce_gap"] <= 100):
|
| 19 |
-
return "Workforce gap must be between 0 and 100"
|
| 20 |
-
if not (0 <= input_data["weather_impact_score"] <= 100):
|
| 21 |
-
return "Weather impact score must be between 0 and 100"
|
| 22 |
-
return None
|
| 23 |
-
|
| 24 |
-
def generate_heatmap(delay_probability, label):
|
| 25 |
-
"""
|
| 26 |
-
Generate a bar chart to visualize delay probability.
|
| 27 |
-
"""
|
| 28 |
-
fig, ax = plt.subplots(figsize=(8, 2))
|
| 29 |
-
color = 'red' if delay_probability > 75 else 'yellow' if delay_probability > 50 else 'green'
|
| 30 |
-
ax.barh([label], [delay_probability], color=color, edgecolor='black')
|
| 31 |
-
ax.set_xlim(0, 100)
|
| 32 |
-
ax.set_xlabel("Delay Probability (%)")
|
| 33 |
-
ax.set_title("Delay Risk Heatmap")
|
| 34 |
-
plt.tight_layout()
|
| 35 |
-
return fig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|