Coverage for pybeepop/beepop/brood.py: 79%
29 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-30 13:34 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-30 13:34 +0000
1"""BeePop+ Brood Module.
3This module contains the Brood class that represents capped honey bee brood
4(pupae) in the colony simulation. Brood represents the pupal stage where
5developing bees undergo metamorphosis from larvae to adults within sealed
6wax cells.
8The Brood stage is critical for varroa mite reproduction, as mites enter
9cells before capping and reproduce during the pupal development period.
10This makes brood cells the primary site of mite population growth within
11the colony.
12"""
14from pybeepop.beepop.bee import Bee
15from pybeepop.beepop.mite import Mite
18class Brood(Bee):
19 """Capped brood (pupal) stage honey bee class representing developing pupae.
21 This class models capped honey bee brood during the pupal development stage.
22 Brood cells are sealed with wax caps and contain developing bees undergoing
23 metamorphosis from larvae to adults. This stage is critical for varroa mite
24 reproduction as mites breed within the sealed cells.
26 Brood development takes a fixed number of days (species and caste dependent)
27 before emerging as adult bees. The presence of mites in brood cells affects
28 the health and longevity of emerging adults.
30 Attributes:
31 number (int): Population count for this brood cohort (inherited from Bee)
32 age (float): Development age in days (inherited from Bee)
33 alive (bool): Whether this cohort is alive (inherited from Bee)
34 mites (Mite): Varroa mites reproducing within these brood cells
35 prop_virgins (float): Proportion of virgin mites in this brood (0.0-1.0)
36 """
38 def __init__(self, number=0):
39 """Initialize a new Brood cohort.
41 Creates a capped brood population with specified initial size and
42 default attributes for mite infestation and reproductive status.
44 Args:
45 number (int, optional): Initial population size for this brood
46 cohort. Defaults to 0.
47 """
48 super().__init__(number)
49 self.mites = Mite() # Initialize with empty Mite object
50 self.prop_virgins = 0.0
52 def reset(self):
53 super().reset()
54 self.mites = Mite() # Initialize with empty Mite object
55 self.prop_virgins = 0.0
57 def get_mites(self):
58 return self.mites
60 def set_mites(self, the_mites):
61 if isinstance(the_mites, Mite):
62 self.mites = the_mites
63 elif isinstance(the_mites, (int, float)):
64 self.mites = Mite(0, the_mites) # Assume non-resistant
65 else:
66 self.mites = Mite()
68 def set_prop_virgins(self, prop):
69 if prop < 0:
70 self.prop_virgins = 0
71 elif prop > 1:
72 self.prop_virgins = 1
73 else:
74 self.prop_virgins = prop
76 def get_prop_virgins(self):
77 return self.prop_virgins
79 def __str__(self):
80 return (
81 f"Brood(number={self.number}, mites={self.mites}, "
82 f"prop_virgins={self.prop_virgins}, alive={self.alive})"
83 )