def crossingover(self, other): """ pre: isinstance(other, SvgStamp) pre: isinstance(self, SvgStamp) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = SvgStamp(self.get_trunk(), self.max_states) self.dw, self.dh = 1.0, 1.0 cross_sequence = model_random.crossing_sequence(2) if self.theme == other.theme: new_one.theme = self.theme[:] new_one.mapping = model_random.crossingover_nativeelement_list( self.mapping, other.mapping) else: if cross_sequence[0]: new_one.theme = other.theme[:] new_one.mapping = other.mapping[:] else: new_one.theme = self.theme[:] new_one.mapping = self.mapping[:] if self.max_states == other.max_states: new_one.max_states = self.max_states new_one.repeating = model_random.crossingover_nativeelement_list( self.repeating, other.repeating) return new_one
def crossingover_base(self, new_one, other, cross_lenght): """ pre: isinstance(new_one, Layer) pre: isinstance(other, Layer) pre: cross_lenght >= 0 """ cross_sequence = model_random.crossing_sequence(cross_lenght + 1) new_one.random_seed = self.random_seed \ if cross_sequence[cross_lenght] else other.random_seed return cross_sequence
def crossingover(self, other): """Returns either a copy of self or a copy of other. pre: isinstance(other, Color) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ randseq = model_random.crossing_sequence(1) return self.copy() if randseq[0] else other.copy()
def crossingover(self, other): """ pre: isinstance(other, SquareGridSampler) pre: isinstance(self, SquareGridSampler) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = SquareGridSampler(self.get_trunk()) cross_sequence = model_random.crossing_sequence(1) new_one.tiles = self.tiles if cross_sequence[0] else other.tiles return new_one
def crossingover(self, other): """ pre: isinstance(other, FilledCyclicStamp) pre: isinstance(self, FilledCyclicStamp) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = FilledCyclicStamp(self.get_trunk(), -1) cross_sequence = model_random.crossing_sequence(2) new_one.order = self.order if cross_sequence[0] else other.order new_one.radius = self.radius if cross_sequence[1] else other.radius return new_one
def crossingover(self, other): """ pre: isinstance(other, FlipModifier) pre: isinstance(self, FlipModifier) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = FlipModifier(self.get_trunk()) cross_sequence = model_random.crossing_sequence(2) new_one.xFlip = self.xFlip if cross_sequence[0] else other.xFlip new_one.yFlip = self.yFlip if cross_sequence[1] else other.yFlip return new_one
def crossingover(self, other): """ pre: isinstance(self, MaskMerger) pre: isinstance(other, MaskMerger) # check for distinct references, needs to copy content, not references post: __return__ is not self """ new_one = MaskMerger(self.get_trunk()) crossing = model_random.crossing_sequence(4) new_one.left_operator = other.left_operator if crossing[0] \ else self.left_operator new_one.left_alphablending = other.left_alphablending if crossing[2] \ else self.left_alphablending return new_one
def crossingover(self, other): """ pre: isinstance(other, BorderModifier) pre: isinstance(self, BorderModifier) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = BorderModifier(self.get_trunk()) cross_sequence = model_random.crossing_sequence(2) new_one.border_weight = self.border_weight if cross_sequence[ 0] else other.border_weight new_one.border_alpha = self.border_alpha if cross_sequence[ 1] else other.border_alpha return new_one
def crossingover(self, other): """ pre: isinstance(other, DiskStamp) pre: isinstance(self, DiskStamp) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = DiskStamp(self.get_trunk(), -1) cross_sequence = model_random.crossing_sequence(4) new_one.order = self.order if cross_sequence[0] else other.order new_one.radius = self.radius if cross_sequence[1] else other.radius new_one.scale = self.scale if cross_sequence[2] else other.scale new_one.dim_out = self.dim_out if cross_sequence[3] else other.dim_out return new_one
def crossingover(self, other): """ pre: isinstance(other, MaskModifier) pre: isinstance(self, MaskModifier) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = MaskModifier(self.get_trunk()) crossing = model_random.crossing_sequence(2) new_one.alpha1 = other.alpha1 if crossing[0] else self.alpha1 new_one.alpha2 = other.alpha2 if crossing[0] else self.alpha2 new_one.center = self.center.crossingover(other.center) new_one.direction = self.direction.crossingover(other.direction) return new_one
def crossingover(self, other): """ pre: isinstance(other, LogarithmicSpiralSampler) pre: isinstance(self, LogarithmicSpiralSampler) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = LogarithmicSpiralSampler(self.get_trunk()) cross_sequence = model_random.crossing_sequence(6) new_one.x_center = self.x_center if cross_sequence[0] else other.x_center new_one.y_center = self.y_center if cross_sequence[1] else other.y_center new_one.steps = self.steps if cross_sequence[2] else other.steps new_one.turns = self.turns if cross_sequence[3] else other.turns new_one.a = self.a if cross_sequence[4] else other.a new_one.b = self.b if cross_sequence[5] else other.b return new_one
def crossingover(self, other): """ pre: isinstance(other, FermatSpiralSampler) pre: isinstance(self, FermatSpiralSampler) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = FermatSpiralSampler(self.get_trunk()) cross_sequence = model_random.crossing_sequence(6) new_one.x_center = self.x_center if cross_sequence[ 0] else other.x_center new_one.y_center = self.y_center if cross_sequence[ 1] else other.y_center new_one.start = self.start if cross_sequence[2] else other.start new_one.end = self.end if cross_sequence[3] else other.end new_one.angle = self.angle if cross_sequence[4] else other.angle new_one.c = self.c if cross_sequence[5] else other.c return new_one
def crossingover(self, other): """ pre: isinstance(other, StarStamp) pre: isinstance(self, StarStamp) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = StarStamp(self.get_trunk(), -1) cross_sequence = model_random.crossing_sequence(6) new_one.order = self.order if cross_sequence[0] else other.order new_one.radius = self.radius if cross_sequence[1] else other.radius new_one.scatter = self.scatter if cross_sequence[2] else other.scatter new_one.start_angle = self.start_angle if cross_sequence[ 3] else other.start_angle new_one.line_width = self.line_width if cross_sequence[ 4] else other.line_width new_one.random_seed = self.random_seed \ if cross_sequence[5] else other.random_seed return new_one
def crossingover(self, other): """ pre: isinstance(other, AffineIfsSampler) pre: isinstance(self, AffineIfsSampler) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = AffineIfsSampler(self.get_trunk()) cross_sequence = model_random.crossing_sequence(7+MAX_TRANSFORMATIONS) new_one.symmetry = self.symmetry if cross_sequence[0] else other.symmetry new_one.Dn = self.Dn if cross_sequence[1] else other.Dn new_one.random_seed = self.random_seed if cross_sequence[2] else other.random_seed new_one.orbits = self.orbits if cross_sequence[3] else other.orbits new_one.x_stamp_size = self.x_stamp_size if cross_sequence[4] else other.x_stamp_size new_one.y_stamp_size = self.y_stamp_size if cross_sequence[5] else other.y_stamp_size new_one.num_transformations = self.num_transformations \ if cross_sequence[6] else other.num_transformations new_one._fill_pol_transf() len_self = self.num_transformations len_other = other.num_transformations min_rows = min([len_self, len_other]) longest = self.pol_transf if len_self >= len_other else other.pol_transf for row in range(new_one.num_transformations): if row < min_rows: if cross_sequence[7+row]: for col in range(len(other.pol_transf[row])): new_one.pol_transf[row][col] = other.pol_transf[row][col] else: for col in range(len(self.pol_transf[row])): new_one.pol_transf[row][col] = self.pol_transf[row][col] else: for col in range(len(longest[row])): new_one.pol_transf[row][col] = longest[row][col] # new_one._prepare_transient_members() return new_one
def crossingover(self, other): """ pre: isinstance(other, GlyphStamp) pre: isinstance(self, GlyphStamp) # check for distinct references, needs to copy content, not references post: __return__ is not self post: __return__ is not other post: model_locus.unique_check(__return__, self, other) == '' """ new_one = GlyphStamp(self.get_trunk(), self.max_states) cross_sequence = model_random.crossing_sequence(3) new_one.size = other.size if cross_sequence[0] else self.size new_one.family = self.family if cross_sequence[1] else other.family if cross_sequence[2]: new_one.category_list = other.category_list[:] new_one.unichr_list = other.unichr_list[:] new_one.mapping = other.mapping[:] else: new_one.category_list = self.category_list[:] new_one.unichr_list = self.unichr_list[:] new_one.mapping = self.mapping[:] return new_one