Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -892,14 +892,14 @@ class NutrientCalculator:
|
|
892 |
self._apply(candidate['name'], element, ppm_to_apply)
|
893 |
})
|
894 |
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
|
904 |
def calculate_ec(self):
|
905 |
return round(self.total_ec, 2)
|
|
|
892 |
self._apply(candidate['name'], element, ppm_to_apply)
|
893 |
})
|
894 |
|
895 |
+
if not candidates:
|
896 |
+
raise ValueError(f"Нет удобрений для элемента {element}")
|
897 |
+
|
898 |
+
total_weight = sum(abs(c['weight']) for c in candidates) # Берем модуль весов
|
899 |
+
for candidate in candidates:
|
900 |
+
share = abs(candidate['weight']) / total_weight # Используем модуль веса
|
901 |
+
ppm_to_apply = needed * share
|
902 |
+
self._apply(candidate['name'], element, ppm_to_apply)
|
903 |
|
904 |
def calculate_ec(self):
|
905 |
return round(self.total_ec, 2)
|