Mutates current section.
437758
def mutate(self):
        """"""
        section = self.section
        project_name = self.project_name

        section.project_name = project_name

        self.contribute_runtime_dir()

        main = section.main_process
        main.set_naming_params(prefix='[%s] ' % project_name)

        main.set_pid_file(
            self.get_pid_filepath(),
            before_priv_drop=False,  # For vacuum to cleanup properly.
            safe=True,
        )

        section.master_process.set_basic_params(
            fifo_file=self.get_fifo_filepath(),
        )

        # todo maybe autoreload in debug

        apps = section.applications
        apps.set_basic_params(
            manage_script_name=True,
        )

        self.contribute_error_pages()
        self.contribute_static()
824182
public void incrementCurrentSection()
    {
        if (runner_controlled_sections) 
        {
            // assume the current run object is at least a JavaProcessRunner!
            rollback_section = current_section;
            current_section = getCurrentSection().incrementCurrentSection(current_section);
        }
        else
        {
            // as previously 
            rollback_section = current_section;
            current_section++;
        }
    }
1281543
private void mutateUp(@NotNull final Deque<ChildReferenceTransient> stack, MutableNode node) {
        while (!stack.isEmpty()) {
            final ChildReferenceTransient parent = stack.pop();
            final MutableNode mutableParent = parent.mutate(this);
            mutableParent.setChild(parent.firstByte, node);
            node = mutableParent;
        }
    }
1041829
def mutate(self, config):
        

        if config.single_structural_mutation:
            div = max(1,(config.node_add_prob + config.node_delete_prob +
                         config.conn_add_prob + config.conn_delete_prob))
            r = random()
            if r < (config.node_add_prob/div):
                self.mutate_add_node(config)
            elif r < ((config.node_add_prob + config.node_delete_prob)/div):
                self.mutate_delete_node(config)
            elif r < ((config.node_add_prob + config.node_delete_prob +
                       config.conn_add_prob)/div):
                self.mutate_add_connection(config)
            elif r < ((config.node_add_prob + config.node_delete_prob +
                       config.conn_add_prob + config.conn_delete_prob)/div):
                self.mutate_delete_connection()
        else:
            if random() < config.node_add_prob:
                self.mutate_add_node(config)

            if random() < config.node_delete_prob:
                self.mutate_delete_node(config)

            if random() < config.conn_add_prob:
                self.mutate_add_connection(config)

            if random() < config.conn_delete_prob:
                self.mutate_delete_connection()

        # Mutate connection genes.
        for cg in self.connections.values():
            cg.mutate(config)

        # Mutate node genes (bias, response, etc.).
        for ng in self.nodes.values():
            ng.mutate(config)
946553
function mutateDOM(contexts) {
    var length = contexts.length;
    var index, context, parent, childrenLength, oldOrder, newOrder;
    var moves, movesLength, move, beforeElement;
    var moving = {};

    for (index = 0; index < length; index++) {
        context = contexts[index];
        parent = context.parent;
        childrenLength = context.children.length;

        oldOrder = parent.children;
        newOrder = new Array(childrenLength);
        while (childrenLength--) {
            newOrder[childrenLength] = context.children[childrenLength].node;
        }

        moves = diff(oldOrder, newOrder);

        movesLength = moves.length;
        while (movesLength--) {
            moving[getID(moves[movesLength].element)] = moves[movesLength].index;
        }

        movesLength = moves.length;
        while (movesLength--) {
            move = moves[movesLength];
            beforeElement = newOrder[move.index + 1] || null;

            while (true) {
                if (beforeElement && (moving[getID(beforeElement)] !== undefined)) {
                    // The element we're inserting this one before is going to be moved—but has not
                    // been moved yet, take its place.
                    beforeElement = newOrder[moving[getID(beforeElement)] + 1];
                } else {
                    break;
                }
            }

            moving[getID(move.element)] = undefined;
            parent.insertBefore(move.element, beforeElement);
        }
    }
}
184420
function mutate(Component, title, api = {}) {
  class Mutated extends React.Component {
    constructor(props, context) {
      super(props);

      this.ToRender = Component;
      const mutations = context.mutations;

      if (!mutations || !mutations[title]) {
        return;
      }

      // Convert old style mutations to new style mutations
      if (!Array.isArray(mutations[title])) {
        mutations[title] = [mutations[title]];
      }

      // Apply all mutations to the component
      for (let mut of mutations[title]) {
        this.ToRender = mut(this.ToRender, api);
      }
    }

    render() {
      const ToRender = this.ToRender;
      return <ToRender {...this.props} />;
    }
  }

  Mutated.contextTypes = {
    mutations: PropTypes.object
  };

  return Mutated;
}
257159
public synchronized void replaceSegments(Collection<Segment> segments, Segment segment) {
    // Update the segment descriptor and lock the segment.
    segment.descriptor().update(System.currentTimeMillis());
    segment.descriptor().lock();

    // Iterate through old segments and remove them from the segments list.
    for (Segment oldSegment : segments) {
      if (!this.segments.containsKey(oldSegment.index())) {
        throw new IllegalArgumentException("unknown segment at index: " + oldSegment.index());
      }
      this.segments.remove(oldSegment.index());
    }

    // Put the new segment in the segments list.
    this.segments.put(segment.index(), segment);

    resetCurrentSegment();
  }
1237336
def mutate(self, chromosomes, p_mutate):
        
        assert 0 <= p_mutate <= 1
        
        for chromosome in chromosomes:
            chromosome.mutate(p_mutate)
1070842
def set_version(self, version='0.0.0', save=True):
        """"""
        self.set(self.DEFAULT_SECTION_NAME, 'version', version, save=save)
1340378
def point_mutate(self,p_i,func_set,term_set):
        """"""
        # point mutation
        x = self.random_state.randint(len(p_i))
        arity = p_i[x].arity[p_i[x].in_type]
        # find eligible replacements based on arity and type
        reps = [n for n in func_set+term_set
                if n.arity[n.in_type]==arity and n.out_type==p_i[x].out_type
                and n.in_type==p_i[x].in_type]

        tmp = reps[self.random_state.randint(len(reps))]
        tmp_p = p_i[:]
        p_i[x] = tmp
        if not self.is_valid_program(p_i):
            print("old:",tmp_p)
            print("new:",p_i)
            raise ValueError('Mutation produced an invalid program.')
900511
def _add_section(self, node):
        
        self._filldown(node.lineno)

        # push a new context onto stack
        self.context.append(node.name)
        self._update_current_context()

        for _ in map(self.visit, iter_child_nodes(node)):
            pass

        # restore current context
        self.context.pop()
        self._update_current_context()
261409
def replace(self, new):
        """"""
        assert self.parent is not None, str(self)
        assert new is not None
        if not isinstance(new, list):
            new = [new]
        l_children = []
        found = False
        for ch in self.parent.children:
            if ch is self:
                assert not found, (self.parent.children, self, new)
                if new is not None:
                    l_children.extend(new)
                found = True
            else:
                l_children.append(ch)
        assert found, (self.children, self, new)
        self.parent.changed()
        self.parent.children = l_children
        for x in new:
            x.parent = self.parent
        self.parent = None
430182
def _DoRepeatedSection(args, context, callback, trace):
    """"""
    
    block = args
    
    items = context.PushSection(block.section_name, block.pre_formatters)
    if items:
        if not isinstance(items, list):
            raise EvaluationError('Expected a list; got %s' % type(items))
        
        last_index = len(items) - 1
        statements = block.Statements()
        alt_statements = block.Statements('alternates with')
        try:
            i = 0
            while True:
                context.Next()
                # Execute the statements in the block for every item in the list.
                # Execute the alternate block on every iteration except the last.  Each
                # item could be an atom (string, integer, etc.) or a dictionary.
                _Execute(statements, context, callback, trace)
                if i != last_index:
                    _Execute(alt_statements, context, callback, trace)
                i += 1
        except StopIteration:
            pass
    
    else:
        _Execute(block.Statements('or'), context, callback, trace)
    
    context.Pop()
1186730
def add_section(self, section):
        
        self._sections = self._ensure_append(section, self._sections)
515272
void expandCurrentFolder() {

        if (m_currentFolder != null) {
            m_treeContainer.setChildrenAllowed(m_currentFolder, true);
            m_fileTree.expandItem(m_currentFolder);
        }
    }
1001489
def set(self, section, option, value):
        """"""
        with self._lock:
            self._set(section, option, value)
268510
def preprocess_section(self, section):
    
    codeblock_opened = False
    current_section = None
    content = self._preprocess_refs(section)
    lines = []
    for line in content.split('\n'):
      if line.startswith("```"):
        codeblock_opened = (not codeblock_opened)
      if not line:
        current_section = None
      elif not codeblock_opened:
        line, current_section = self._preprocess_line(line, current_section)
      lines.append(line)
    section.content = '\n'.join(lines)