def get_random_parents(self, rng: Random) -> Tuple[bytes, bytes]: """ Get parents from self.parents plus a random choice from self.parents_any to make it 3 in total. Using tuple as return type to make it explicit that the length is always 2. """ assert len(self.must_include) <= 1 fill = rng.ordered_sample(self.can_include, 2 - len(self.must_include)) p1, p2 = self.must_include[:] + fill return p1, p2
def get_random_parents(self, rng: Random) -> Tuple[bytes, bytes, bytes]: """ Get parents from self.parents plus a random choice from self.parents_any to make it 3 in total. Return type is tuple just to make it clear that the length is always 3. """ assert 1 <= len(self.parents) <= 3 more_parents = rng.ordered_sample(self.parents_any, 3 - len(self.parents)) p1, p2, p3 = self.parents[:] + more_parents return p1, p2, p3