diff --git a/README.md b/README.md index 8f54af128e..2fe5e5399f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Flake8](https://img.shields.io/badge/Flake8-passed-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml) [![Pytest](https://img.shields.io/badge/Pytest-passed-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml) [![Coverage](https://img.shields.io/badge/Coverage-99%25-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml) -[![Mypy](https://img.shields.io/badge/Mypy-1424%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml) +[![Mypy](https://img.shields.io/badge/Mypy-1423%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml) # RuFaS: Ruminant Farm Systems diff --git a/RUFAS/biophysical/animal/data_types/herd_statistics.py b/RUFAS/biophysical/animal/data_types/herd_statistics.py index 44475ededb..be3d3de66f 100644 --- a/RUFAS/biophysical/animal/data_types/herd_statistics.py +++ b/RUFAS/biophysical/animal/data_types/herd_statistics.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from RUFAS.biophysical.animal import animal_constants -from RUFAS.biophysical.animal.data_types.animal_typed_dicts import SoldAnimalTypedDict +from RUFAS.biophysical.animal.data_types.animal_typed_dicts import SoldAnimalTypedDict, StillbornCalfTypedDict from RUFAS.biophysical.animal.data_types.animal_types import AnimalType @@ -19,18 +19,20 @@ class HerdStatistics: Count statistics of culled animals, categorized by specified culling reasons, (unitless). num_cow_for_parity : dict[str, int] Count of cows for each parity class, (unitless). - avg_daily_cow_milking : float - Average number of milking cows per day, (unitless). + stillborn_calf_info : list[StillbornCalfTypedDict] + Details about stillborn calves including relevant attributes. sold_calves_info : list[SoldAnimalTypedDict] Details about sold calves including relevant attributes. - sold_heiferIIIs_info : list[SoldAnimalTypedDict] - Detailed information on sold animals categorized as "Heifer III". sold_heiferIIs_info : list[SoldAnimalTypedDict] Detailed information about sold animals categorized as "Heifer II". + sold_heiferIIIs_info : list[SoldAnimalTypedDict] + Detailed information on sold animals categorized as "Heifer III". sold_cows_info : list[SoldAnimalTypedDict] Comprehensive details of sold cows including relevant attributes. sold_and_died_cows_info : list[SoldAnimalTypedDict] Information concerning cows that were either sold or died. + total_enteric_methane : dict[AnimalType, dict[str, float]] + Total amount of enteric methane, grouped by animal types and methods (g/day). herd_num : int Total number of animals in the herd, (unitless). calf_num : int @@ -93,6 +95,8 @@ class HerdStatistics: Total number of semen units used for cows, (unitless). ed_period_h : int Estrus detection (ED) period for heifers, (simulation days). + ed_period : int + Estrus detection (ED) period for cows, (simulation days). open_cow_num : int Total number of open (non-pregnant) cows, (unitless). preg_cow_num : int @@ -103,6 +107,8 @@ class HerdStatistics: Number of cows actively milking in the herd, (unitless). dry_cow_num : int Number of dry cows (non-milking) in the herd, (unitless). + animals_deaths_by_stage : dict[AnimalType, int] + Count of animal deaths categorized by their stages. dry_cow_percent : float Percentage of dry cows in the herd, (unitless). milking_cow_percent : float @@ -111,16 +117,6 @@ class HerdStatistics: Percentage of pregnant cows in the herd, (unitless). non_preg_cow_percent : float Percentage of non-pregnant cows in the herd, (unitless). - daily_milk_production : float - Average daily milk production, (kg). - herd_milk_fat_kg : float - Total quantity of milk fat in the herd's milk production, (kg). - herd_milk_fat_percent : float - Percentage of milk fat in the herd's milk production, (unitless). - herd_milk_protein_kg : float - Total quantity of milk protein in the herd's milk production, (kg). - herd_milk_protein_percent : float - Percentage of milk protein in the herd's milk production, (unitless). avg_days_in_milk : float Average number of days in milk, (simulation days). avg_days_in_preg : float @@ -150,8 +146,16 @@ class HerdStatistics: Percentage statistics of culled animals, categorized by culling reasons, (unitless). percent_cow_for_parity : dict[str, float] Percentage of cows available for each parity class, calculated based on total counts, (unitless). - total_enteric_methane : dict[AnimalType, dict[str, float]] - Total amount of enteric methane, grouped by animal types and methods (g/day). + daily_milk_production : float + Average daily milk production, (kg). + herd_milk_fat_kg : float + Total quantity of milk fat in the herd's milk production, (kg). + herd_milk_fat_percent : float + Percentage of milk fat in the herd's milk production, (unitless). + herd_milk_protein_kg : float + Total quantity of milk protein in the herd's milk production, (kg). + herd_milk_protein_percent : float + Percentage of milk protein in the herd's milk production, (unitless). """ @@ -159,16 +163,15 @@ class HerdStatistics: cull_reason_stats: dict[str, int] num_cow_for_parity: dict[str, int] - avg_daily_cow_milking = 0.0 + stillborn_calf_info: list[StillbornCalfTypedDict] sold_calves_info: list[SoldAnimalTypedDict] - sold_heiferIIIs_info: list[SoldAnimalTypedDict] sold_heiferIIs_info: list[SoldAnimalTypedDict] + sold_heiferIIIs_info: list[SoldAnimalTypedDict] sold_cows_info: list[SoldAnimalTypedDict] sold_and_died_cows_info: list[SoldAnimalTypedDict] total_enteric_methane: dict[AnimalType, dict[str, float]] - # TODO: Maybe break this list down into smaller lists GitHub Issue #1215 herd_num = 0 calf_num = 0 heiferI_num = 0 @@ -191,9 +194,9 @@ class HerdStatistics: heiferIII_percent = 0.0 cow_percent = 0.0 + CIDR_count = 0 preg_check_num_h = 0 preg_check_num = 0 - CIDR_count = 0 GnRH_injection_num_h = 0 GnRH_injection_num = 0 PGF_injection_num_h = 0 @@ -212,16 +215,13 @@ class HerdStatistics: milking_cow_num = 0 dry_cow_num = 0 + animals_deaths_by_stage: dict[AnimalType, int] + dry_cow_percent = 0.0 milking_cow_percent = 0.0 preg_cow_percent = 0.0 non_preg_cow_percent = 0.0 - daily_milk_production = 0.0 - herd_milk_fat_kg = 0.0 - herd_milk_fat_percent = 0.0 - herd_milk_protein_kg = 0.0 - herd_milk_protein_percent = 0.0 avg_days_in_milk = 0.0 avg_days_in_preg = 0.0 avg_cow_body_weight = 0.0 @@ -240,7 +240,11 @@ class HerdStatistics: cull_reason_stats_percent: dict[str, float] percent_cow_for_parity: dict[str, float] - animals_deaths_by_stage: dict[AnimalType, int] + daily_milk_production = 0.0 + herd_milk_fat_kg = 0.0 + herd_milk_fat_percent = 0.0 + herd_milk_protein_kg = 0.0 + herd_milk_protein_percent = 0.0 def __init__(self) -> None: """ @@ -326,7 +330,6 @@ def reset_daily_stats(self) -> None: self.heiferIII_percent = 0.0 self.cow_percent = 0.0 - # TODO: Check if all the following variables need to reset daily GitHub Issue #1215 self.CIDR_count = 0 self.preg_check_num_h = 0 self.preg_check_num = 0 @@ -334,6 +337,7 @@ def reset_daily_stats(self) -> None: self.GnRH_injection_num = 0 self.PGF_injection_num_h = 0 self.PGF_injection_num = 0 + self.ai_num_h = 0 self.ai_num = 0 self.semen_num_h = 0 @@ -347,16 +351,20 @@ def reset_daily_stats(self) -> None: self.milking_cow_num = 0 self.dry_cow_num = 0 + self.animals_deaths_by_stage: dict[AnimalType, int] = { + AnimalType.CALF: 0, + AnimalType.HEIFER_I: 0, + AnimalType.HEIFER_II: 0, + AnimalType.HEIFER_III: 0, + AnimalType.LAC_COW: 0, + AnimalType.DRY_COW: 0, + } + self.preg_cow_percent = 0.0 self.dry_cow_percent = 0.0 self.milking_cow_percent = 0.0 self.non_preg_cow_percent = 0.0 - self.daily_milk_production = 0.0 - self.herd_milk_fat_kg = 0.0 - self.herd_milk_fat_percent = 0.0 - self.herd_milk_protein_kg = 0.0 - self.herd_milk_protein_percent = 0.0 self.avg_days_in_milk = 0.0 self.avg_days_in_preg = 0.0 self.avg_cow_body_weight = 0.0 @@ -368,14 +376,11 @@ def reset_daily_stats(self) -> None: self.avg_cow_culling_age = 0.0 self.avg_mature_body_weight = 0.0 - self.animals_deaths_by_stage: dict[AnimalType, int] = { - AnimalType.CALF: 0, - AnimalType.HEIFER_I: 0, - AnimalType.HEIFER_II: 0, - AnimalType.HEIFER_III: 0, - AnimalType.LAC_COW: 0, - AnimalType.DRY_COW: 0, - } + self.daily_milk_production = 0.0 + self.herd_milk_fat_kg = 0.0 + self.herd_milk_fat_percent = 0.0 + self.herd_milk_protein_kg = 0.0 + self.herd_milk_protein_percent = 0.0 def reset_parity(self) -> None: """Resets parity-based attributes.""" diff --git a/changelog.md b/changelog.md index fa8ace3d4e..1840ac3768 100644 --- a/changelog.md +++ b/changelog.md @@ -35,6 +35,8 @@ v1.0.0 - [2791](https://github.com/RuminantFarmSystems/MASM/pull/2791) - [minor change] [Animal] [NoInputChange] [NoOutputChange] Updates ration percentage values in example feed files to sum to exactly 100. - [2804](https://github.com/RuminantFarmSystems/MASM/pull/2804) - [minor change] [Tests] [NoInputChange] [NoOutputChange] Clears all mypy errors in test_field.py. - [2819](https://github.com/RuminantFarmSystems/MASM/pull/2819) - [minor change] [Tests] [NoInputChange] [NoOutputChange] Clears all mypy errors in test_input_manager.py. +- [2809](https://github.com/RuminantFarmSystems/MASM/pull/2809) - [minor change] [Animal] [NoInputChange] [NoOutputChange] Reorders grouping of attributes in some HerdStatistics methods, updates docstrings. + ### v1.0.0 - [2081](https://github.com/RuminantFarmSystems/MASM/pull/2081) - [minor change] [Crop & Soil] Break down the `_setup_field()` function in `FieldManager`. diff --git a/tests/test_biophysical/test_animal/test_data_types/test_herd_statistics.py b/tests/test_biophysical/test_animal/test_data_types/test_herd_statistics.py index eb683eeba7..b859d8aabd 100644 --- a/tests/test_biophysical/test_animal/test_data_types/test_herd_statistics.py +++ b/tests/test_biophysical/test_animal/test_data_types/test_herd_statistics.py @@ -26,7 +26,6 @@ def test_initialization(herd_statistics: HerdStatistics) -> None: assert herd_statistics.sold_cows_info == [] assert herd_statistics.herd_num == 0 assert herd_statistics.calf_num == 0 - assert herd_statistics.avg_daily_cow_milking == 0.0 def test_reset_daily_stats(herd_statistics: HerdStatistics) -> None: