generic function for mutating dplyr-style joins
328796
def mutating_join(*args, **kwargs):
  
  # candidate for improvement
  left = args[0]
  right = args[1]
  if 'by' in kwargs:
    left_cols, right_cols = get_join_cols(kwargs['by'])
  else:
    left_cols, right_cols = None, None
  if 'suffixes' in kwargs:
    dsuffixes = kwargs['suffixes']
  else:
    dsuffixes = ('_x', '_y')
  if left._grouped_on:
    outDf = (DplyFrame((left >> ungroup())
                       .merge(right, how=kwargs['how'], left_on=left_cols, 
                              right_on=right_cols, suffixes=dsuffixes))
             .regroup(left._grouped_on))
  else:
    outDf = DplyFrame(left.merge(right, how=kwargs['how'], left_on=left_cols, 
                                 right_on=right_cols, suffixes=dsuffixes))
  return outDf
830917
def juggle_types(data):
    """"""
    # Data is a list of lists (2D) and not a single column table (1D)
    if isinstance(data[0], list):
        return [[force_int(col) for col in row] for row in data]

    # Data is 1D
    elif isinstance(data, list):
        return [force_int(i) for i in data]
    else:
        return data
543138
function Join(Table $table, JoinType $join, Condition $condition, $prepend = false)
    {
        $result = $this->Duplicate();
        if ($prepend)
        {
            array_unshift($result->tables, $table);
            array_unshift($result->joins, $join);
            array_unshift($result->conditions, $condition);
        }
        else
        {    
            $result->tables[] = $table;
            $result->joins[] = $join;
            $result->conditions[] = $condition;
        }
        return $result;
    }
576359
def batch_mutate(self, mutation_map, consistency_level):
    
    self._seqid += 1
    d = self._reqs[self._seqid] = defer.Deferred()
    self.send_batch_mutate(mutation_map, consistency_level)
    return d
414534
def mutates(f):
    '''
    '''
    @wraps(f)
    def wrapper(self, *args, **kwargs):
        if self.read_only:
            raise ReadOnlyException()
        self.next_generation()
        return f(self, *args, **kwargs)
    return wrapper
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.')
718608
def _transform_fast(self, func, func_nm):
        
        if isinstance(func, str):
            func = getattr(self, func)

        ids, _, ngroup = self.grouper.group_info
        cast = self._transform_should_cast(func_nm)
        out = algorithms.take_1d(func()._values, ids)
        if cast:
            out = self._try_cast(out, self.obj)
        return Series(out, index=self.obj.index, name=self.obj.name)
1088868
function _concat(a, b, mutate) {
	var aHeight = a.height;
	var bHeight = b.height;

	if (aHeight === 0 && bHeight === 0) {
		return [a, b];
	}

	if (aHeight !== 1 || bHeight !== 1) {
		if (aHeight === bHeight) {
			a = (0, _util.nodeCopy)(a, mutate);
			b = (0, _util.nodeCopy)(b, mutate);
			let tuple = _concat((0, _util.last)(a), (0, _util.first)(b), mutate);
			let a0 = tuple[0];
			let b0 = tuple[1];
			insertRight(a, a0);
			insertLeft(b, b0);
		} else if (aHeight > bHeight) {
			a = (0, _util.nodeCopy)(a, mutate);
			let tuple = _concat((0, _util.last)(a), b, mutate);
			let a0 = tuple[0];
			let b0 = tuple[1];
			insertRight(a, a0);
			b = (0, _util.parentise)(b0, b0.height + 1);
		} else {
			b = (0, _util.nodeCopy)(b, mutate);
			var tuple = _concat(a, (0, _util.first)(b), mutate);
			var left = tuple[0].length === 0 ? 0 : 1;
			var right = left === 0 ? 1 : 0;
			insertLeft(b, tuple[left]);
			a = (0, _util.parentise)(tuple[right], tuple[right].height + 1);
		}
	}

	// Check if balancing is needed and return based on that.
	if (a.length === 0 || b.length === 0) {
		return [a, b];
	}

	var toRemove = calcToRemove(a, b);
	if (toRemove <= _const.E) {
		return [a, b];
	}
	return shuffle(a, b, toRemove);
}
1125337
private void appendJoin(StringBuffer where, StringBuffer buf, Join join)
    {
        buf.append(",");
        appendTableWithJoins(join.right, where, buf);
        if (where.length() > 0)
        {
            where.append(" AND ");
        }
        join.appendJoinEqualities(where);
    }
800560
def constraint_join(cfg_nodes):
    """"""
    r = 0
    for e in cfg_nodes:
        r = r | constraint_table[e]
    return r
560454
function joinOnce($table_or_column, $on_clause_or_column = null, $join_type = self::JOIN) {
		if ($table_or_column instanceof QueryJoin) {
			$join = clone $table_or_column;
		} else {
			if (null === $on_clause_or_column) {
				if ($join_type == self::JOIN || $join_type == self::INNER_JOIN) {
					foreach ($this->extraTables as &$table) {
						if ($table == $table_or_column) {
							return $this;
						}
					}
					$this->addTable($table_or_column);
					return $this;
				}
				$on_clause_or_column = '1 = 1';
			}
			$join = new QueryJoin($table_or_column, $on_clause_or_column, $join_type);
		}
		foreach ($this->joins as &$existing_join) {
			if ($join->getTable() == $existing_join->getTable()) {
				if ($join->getAlias() != $existing_join->getAlias()) {
					// tables match, but aliases don't match
					continue;
				}
				// tables match, and aliases match or there are no aliases
				return $this;
			}
		}
		$this->joins[] = $join;
		return $this;
	}
426287
def cupy_wrapper(func):
    

    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        args = list(args)
        for n, a in enumerate(args):
            if isinstance(a, np.ndarray):
                args[n] = cp.asarray(a)
        for k, v in kwargs.items():
            if isinstance(v, np.ndarray):
                kwargs[k] = cp.asarray(v)
        rtn = func(*args, **kwargs)
        if isinstance(rtn, (list, tuple)):
            for n, a in enumerate(rtn):
                if isinstance(a, cp.core.core.ndarray):
                    rtn[n] = cp.asnumpy(a)
        else:
            if isinstance(rtn, cp.core.core.ndarray):
                rtn = cp.asnumpy(rtn)
        return rtn
    return wrapped
738465
def mutate(self,p_i,func_set,term_set): #, max_depth=2
        """"""
        self.point_mutate(p_i,func_set,term_set)
1013293
def derive_data(data):
    

    for s_name, values in data.items():
        # setup holding variable

        # Sum all variants that have been called
        total_called_variants = 0
        for value_name in ['TOTAL_SNPS', 'TOTAL_COMPLEX_INDELS', 'TOTAL_MULTIALLELIC_SNPS', 'TOTAL_INDELS']:
            total_called_variants = total_called_variants + int(values[value_name])
        values['total_called_variants'] = total_called_variants

        # Sum all variants that have been called and are known
        total_called_variants_known = 0
        for value_name in ['NUM_IN_DB_SNP', 'NUM_IN_DB_SNP_COMPLEX_INDELS', 'NUM_IN_DB_SNP_MULTIALLELIC']:
            total_called_variants_known = total_called_variants_known + int(values[value_name])
        total_called_variants_known = total_called_variants_known + int(values['TOTAL_INDELS']) - int(values['NOVEL_INDELS'])
        values['total_called_variants_known'] = total_called_variants_known

        # Extrapolate the total novel variants
        values['total_called_variants_novel'] = total_called_variants - total_called_variants_known
1059216
function mutator (Glide, Components, Events) {
  /**
   * Merge instance transformers with collection of default transformers.
   * It's important that the Rtl component be last on the list,
   * so it reflects all previous transformations.
   *
   * @type {Array}
   */
  var TRANSFORMERS = [Gap, Grow, Peeking, Focusing].concat(Glide._t, [Rtl]);

  return {
    /**
     * Piplines translate value with registered transformers.
     *
     * @param  {Number} translate
     * @return {Number}
     */
    mutate: function mutate(translate) {
      for (var i = 0; i < TRANSFORMERS.length; i++) {
        var transformer = TRANSFORMERS[i];

        if (isFunction(transformer) && isFunction(transformer().modify)) {
          translate = transformer(Glide, Components, Events).modify(translate);
        } else {
          warn('Transformer should be a function that returns an object with `modify()` method');
        }
      }

      return translate;
    }
  };
}
595659
def _compile_update_from(self, query):
        
        if not query.joins:
            return ""

        froms = []

        for join in query.joins:
            froms.append(self.wrap_table(join.table))

        if len(froms):
            return " FROM %s" % ", ".join(froms)

        return ""
896501
def mutable(function):
    ''''''

    def wrapper(self, *args, **kwargs):
        state = self._get_state()
        return function(self, state, *args, **kwargs)

    return wrapper