Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -824,9 +824,12 @@ class NutrientCalculator:
|
|
| 824 |
def _apply(self, fert_name, main_element, required_ppm):
|
| 825 |
if required_ppm <= 0:
|
| 826 |
return
|
| 827 |
-
|
| 828 |
try:
|
| 829 |
-
content = self.fertilizers[fert_name]
|
|
|
|
|
|
|
|
|
|
| 830 |
grams = (required_ppm * self.volume) / (content * 1000)
|
| 831 |
|
| 832 |
if fert_name not in self.results:
|
|
@@ -852,7 +855,7 @@ class NutrientCalculator:
|
|
| 852 |
self.results[fert_name]['вклад в EC'] += fert_ec
|
| 853 |
self.total_ec += fert_ec
|
| 854 |
except KeyError as e:
|
| 855 |
-
print(f"Ошибка:
|
| 856 |
raise
|
| 857 |
|
| 858 |
def _compensate_element(self, element):
|
|
@@ -865,8 +868,7 @@ class NutrientCalculator:
|
|
| 865 |
candidates = []
|
| 866 |
for fert_name, fert_data in self.fertilizers.items():
|
| 867 |
if element in fert_data:
|
| 868 |
-
weight =
|
| 869 |
-
if w['fert'] == fert_name), 0.1)
|
| 870 |
candidates.append({
|
| 871 |
'name': fert_name,
|
| 872 |
'weight': weight,
|
|
@@ -1000,8 +1002,6 @@ if __name__ == "__main__":
|
|
| 1000 |
except Exception as e:
|
| 1001 |
print(f"Критическая ошибка: {str(e)}")
|
| 1002 |
|
| 1003 |
-
|
| 1004 |
-
|
| 1005 |
@app.route('/calculation', methods=['POST'])
|
| 1006 |
def handle_calculation():
|
| 1007 |
try:
|
|
|
|
| 824 |
def _apply(self, fert_name, main_element, required_ppm):
|
| 825 |
if required_ppm <= 0:
|
| 826 |
return
|
| 827 |
+
|
| 828 |
try:
|
| 829 |
+
content = self.fertilizers[fert_name].get(main_element, 0)
|
| 830 |
+
if content == 0:
|
| 831 |
+
raise KeyError(f"Элемент {main_element} отсутствует в удобрении {fert_name}")
|
| 832 |
+
|
| 833 |
grams = (required_ppm * self.volume) / (content * 1000)
|
| 834 |
|
| 835 |
if fert_name not in self.results:
|
|
|
|
| 855 |
self.results[fert_name]['вклад в EC'] += fert_ec
|
| 856 |
self.total_ec += fert_ec
|
| 857 |
except KeyError as e:
|
| 858 |
+
print(f"Ошибка: {str(e)}")
|
| 859 |
raise
|
| 860 |
|
| 861 |
def _compensate_element(self, element):
|
|
|
|
| 868 |
candidates = []
|
| 869 |
for fert_name, fert_data in self.fertilizers.items():
|
| 870 |
if element in fert_data:
|
| 871 |
+
weight = self.compensation_weights.get(fert_name, {}).get("weight", 0.1)
|
|
|
|
| 872 |
candidates.append({
|
| 873 |
'name': fert_name,
|
| 874 |
'weight': weight,
|
|
|
|
| 1002 |
except Exception as e:
|
| 1003 |
print(f"Критическая ошибка: {str(e)}")
|
| 1004 |
|
|
|
|
|
|
|
| 1005 |
@app.route('/calculation', methods=['POST'])
|
| 1006 |
def handle_calculation():
|
| 1007 |
try:
|