DmitrMakeev commited on
Commit
7369bc4
·
verified ·
1 Parent(s): 21f1a9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -21
app.py CHANGED
@@ -729,24 +729,13 @@ EC_COEFFICIENTS = {
729
 
730
 
731
 
732
- # Список питательных веществ
733
  nutrients_stencil = [
734
- 'N (NO3-)',
735
- 'N (NH4+)',
736
- 'P',
737
- 'K',
738
- 'Mg',
739
- 'Ca',
740
- 'S',
741
- 'Fe',
742
- 'Zn',
743
- 'B',
744
- 'Mn',
745
- 'Cu',
746
- 'Mo',
747
  ]
748
 
749
-
750
  class Composition:
751
  def __init__(self, name='', vector=None):
752
  self.name = name
@@ -846,15 +835,20 @@ class Composition:
846
  return '\n\n'.join((description, table))
847
 
848
 
849
- # Ваш калькулятор удобрений
850
  class NutrientCalculator:
851
  def __init__(self, volume_liters=1.0):
852
  self.volume = volume_liters
853
- self.target_profile = BASE_PROFILE.copy()
 
 
 
 
854
  self.fertilizers = {
855
- name: Composition.from_dict({name: content})
856
  for name, content in NUTRIENT_CONTENT_IN_FERTILIZERS.items()
857
  }
 
858
  self.total_ec = 0.0
859
  self.best_solution = None
860
  self.min_difference = float('inf')
@@ -869,7 +863,6 @@ class NutrientCalculator:
869
  # Целевой профиль как объект Composition
870
  self.target_composition = Composition('Target Profile', list(self.target_profile.values()))
871
 
872
-
873
  def calculate(self):
874
  try:
875
  self.actual_profile = {k: 0.0 for k in self.target_profile}
@@ -992,8 +985,6 @@ class NutrientCalculator:
992
  print(f"Ошибка при выводе отчёта: {str(e)}")
993
  raise
994
 
995
-
996
-
997
  if __name__ == "__main__":
998
  try:
999
  calculator = NutrientCalculator(volume_liters=VOLUME_LITERS)
 
729
 
730
 
731
 
732
+ # Список всех питательных веществ
733
  nutrients_stencil = [
734
+ 'N (NO3-)', 'N (NH4+)', 'P', 'K', 'Mg', 'Ca', 'S',
735
+ 'Fe', 'Zn', 'B', 'Mn', 'Cu', 'Mo'
 
 
 
 
 
 
 
 
 
 
 
736
  ]
737
 
738
+ # Класс для работы с составами удобрений
739
  class Composition:
740
  def __init__(self, name='', vector=None):
741
  self.name = name
 
835
  return '\n\n'.join((description, table))
836
 
837
 
838
+ # Основной класс калькулятора удобрений
839
  class NutrientCalculator:
840
  def __init__(self, volume_liters=1.0):
841
  self.volume = volume_liters
842
+
843
+ # Целевой профиль (дополнен нулями для отсутствующих элементов)
844
+ self.target_profile = {nutrient: BASE_PROFILE.get(nutrient, 0.0) for nutrient in nutrients_stencil}
845
+
846
+ # Удобрения (дополнены нулями для отсутствующих элементов)
847
  self.fertilizers = {
848
+ name: Composition.from_dict({name: {nutrient: content.get(nutrient, 0.0) for nutrient in nutrients_stencil}})
849
  for name, content in NUTRIENT_CONTENT_IN_FERTILIZERS.items()
850
  }
851
+
852
  self.total_ec = 0.0
853
  self.best_solution = None
854
  self.min_difference = float('inf')
 
863
  # Целевой профиль как объект Composition
864
  self.target_composition = Composition('Target Profile', list(self.target_profile.values()))
865
 
 
866
  def calculate(self):
867
  try:
868
  self.actual_profile = {k: 0.0 for k in self.target_profile}
 
985
  print(f"Ошибка при выводе отчёта: {str(e)}")
986
  raise
987
 
 
 
988
  if __name__ == "__main__":
989
  try:
990
  calculator = NutrientCalculator(volume_liters=VOLUME_LITERS)