Args:
            factor (int): number of times the input will be rotated by 90 degrees.
966995
def apply(self, img, factor=0, **params):
        
        return np.ascontiguousarray(np.rot90(img, factor))
874546
def _get_factors(self, element):
        
        if not element.kdims:
            xfactors, yfactors = [element.label], []
        else:
            factors = [key for key in element.groupby(element.kdims).data.keys()]
            if element.ndims > 1:
                factors = sorted(factors)
            factors = [tuple(d.pprint_value(k) for d, k in zip(element.kdims, key))
                       for key in factors]
            factors = [f[0] if len(f) == 1 else f for f in factors]
            xfactors, yfactors = factors, []
        return (yfactors, xfactors) if self.invert_axes else (xfactors, yfactors)
399471
def _capture(f, t, t0, factor):
    '''
    
    '''
    n_per_sec = len(t) / t[-1]

    # len of one split:
    n = int(t0 * factor * n_per_sec)
    s = len(f) // n
    m = s * n
    f = f[:m]
    ff = np.split(f, s)
    m = np.mean(ff, axis=1)

    return np.std(m)
119386
def vol_prefactor(n, p=2.):
    

    p *= 1.  # convert to float in case user inputs an integer
    f = (2 * special.gamma(1./p + 1.))**n / special.gamma(n/p + 1)

    return f
917103
public static FactorGraph createFromFactors(List<Factor> factors) {
    VariableNumMap allVars = VariableNumMap.EMPTY;
    for (int i = 0; i < factors.size(); i++) {
      allVars = allVars.union(factors.get(i).getVars());
    }

    String[] factorNames = new String[factors.size()];
    for (int i = 0; i < factors.size(); i++) {
      factorNames[i] = "factor-" + i;
    }
    return new FactorGraph(allVars, factors.toArray(new Factor[factors.size()]), factorNames,
        VariableNumMap.EMPTY, Assignment.EMPTY, null);
  }
773349
def factor_coeff(cls, ops, kwargs):
    """"""
    coeffs, nops = zip(*map(_coeff_term, ops))
    coeff = 1
    for c in coeffs:
        coeff *= c
    if coeff == 1:
        return nops, coeffs
    else:
        return coeff * cls.create(*nops, **kwargs)
827292
public static List<DiscreteFactor> coerceToDiscrete(Collection<Factor> factors) {
    List<DiscreteFactor> returnFactors = Lists.newArrayList();
    for (Factor factor : factors) {
      returnFactors.add(factor.coerceToDiscrete());
    }
    return returnFactors;
  }
1054809
def __separate_scalar_factor(monomial):
    
    scalar_factor = 1
    if is_number_type(monomial):
        return S.One, monomial
    if monomial == 0:
        return S.One, 0
    comm_factors, _ = split_commutative_parts(monomial)
    if len(comm_factors) > 0:
        if isinstance(comm_factors[0], Number):
            scalar_factor = comm_factors[0]
    if scalar_factor != 1:
        return monomial / scalar_factor, scalar_factor
    else:
        return monomial, scalar_factor
17701
def rebalance(self):
        

        # Compute norms along columns for each factor matrix
        norms = [sci.linalg.norm(f, axis=0) for f in self.factors]

        # Multiply norms across all modes
        lam = sci.multiply.reduce(norms) ** (1/self.ndim)

        # Update factors
        self.factors = [f * (lam / fn) for f, fn in zip(self.factors, norms)]
        return self
724666
private static int[] getFactors(int _value, int _max) {
      final int factors[] = new int[MAX_GROUP_SIZE];
      int factorIdx = 0;

      for (int possibleFactor = 1; possibleFactor <= _max; possibleFactor++) {
         if ((_value % possibleFactor) == 0) {
            factors[factorIdx++] = possibleFactor;
         }
      }

      return (Arrays.copyOf(factors, factorIdx));
   }
868346
def _rotate(self, angles, dj_matrix, gm=None, r0=None, omega=None):
        """"""
        if dj_matrix is None:
            dj_matrix = _shtools.djpi2(self.lmax + 1)

        # The coefficients need to be 4pi normalized with csphase = 1
        coeffs = _shtools.SHRotateRealCoef(
            self.to_array(normalization='4pi', csphase=1), angles, dj_matrix)

        # Convert 4pi normalized coefficients to the same normalization
        # as the unrotated coefficients.
        if self.normalization != '4pi' or self.csphase != 1:
            temp = _convert(coeffs, normalization_in='4pi', csphase=1,
                            normalization_out=self.normalization,
                            csphase_out=self.csphase)
            return SHGravCoeffs.from_array(
                temp, normalization=self.normalization,
                csphase=self.csphase, copy=False, gm=gm, r0=r0, omega=omega)
        else:
            return SHGravCoeffs.from_array(coeffs, gm=gm, r0=r0, omega=omega,
                                           copy=False)
1307600
def Mult(self, x, factor):
        
        self.d[x] = self.d.get(x, 0) * factor
1004459
private int gradientUpdate(List<TensorBuilder> factors,
      List<TensorBuilder> unaryFactors, double stepSize) {
    // The best assignment, as computed from only the unary factors.
    int[] variableNums = new int[unaryFactors.size()];
    int[] variableSizes = new int[unaryFactors.size()];
    int[] variableValues = new int[unaryFactors.size()];
    locallyDecodeFactors(unaryFactors, variableNums, variableSizes, variableValues);

    // Identify where unary factors disagree with larger factors to compute the
    // subgradient.
    List<Integer> variableDisagreementList = Lists.newArrayList();
    List<Integer> factorDisagreementList = Lists.newArrayList();
    List<Integer> factorValueList = Lists.newArrayList();
    for (int i = 0; i < factors.size(); i++) {
      TensorBuilder factor = factors.get(i);
      int[] bestFactorValues = factor.keyNumToDimKey(factor.getLargestValues(1)[0]);
      int[] factorVariableNums = factor.getDimensionNumbers();

      for (int j = 0; j < factorVariableNums.length; j++) {
        int index = Arrays.binarySearch(variableNums, factorVariableNums[j]);
        if (bestFactorValues[j] != variableValues[index]) {
          // Factor and unary assignments disagree on variableNums[index].
          // Store the disagreement, used later to compute the subgradient.
          variableDisagreementList.add(index);
          factorDisagreementList.add(i);
          factorValueList.add(bestFactorValues[j]);

          /*
          System.out.println("Disagreement " + Arrays.toString(factorVariableNums) + "=" + Arrays.toString(bestFactorValues) + ", "
              + variableNums[index] + "=" + variableValues[index]);
              */
        }
      }
    }

    // Update the factor lagrange multipliers based on the disagreements.
    // For each disagreement, the subgradient update decreases the weight of
    // each factor's maximum weight assignment, and increases the weight of
    // the disagreeing factor's maximum weight assignment.
    for (int i = 0; i < variableDisagreementList.size(); i++) {
      int variableIndex = variableDisagreementList.get(i);
      int factorNum = factorDisagreementList.get(i);

      TensorBuilder factor = factors.get(factorNum);
      TensorBuilder unaryFactor = unaryFactors.get(variableIndex);

      int variableNum = variableNums[variableIndex];
      int variableSize = variableSizes[variableIndex];
      int bestFactorValue = factorValueList.get(i);
      int bestUnaryValue = variableValues[variableIndex];

      SparseTensor unaryGradient = SparseTensor.singleElement(new int[] { variableNum },
          new int[] { variableSize }, new int[] { bestUnaryValue }, 1);
      SparseTensor factorGradient = SparseTensor.singleElement(new int[] { variableNum },
          new int[] { variableSize }, new int[] { bestFactorValue }, 1);

      unaryFactor.incrementWithMultiplier(unaryGradient, -1.0 * stepSize);
      unaryFactor.incrementWithMultiplier(factorGradient, stepSize);
      factor.incrementWithMultiplier(unaryGradient, stepSize);
      factor.incrementWithMultiplier(factorGradient, -1.0 * stepSize);
    }

    return variableDisagreementList.size();
  }
760022
public static void addColTimes(DenseDoubleMatrix2D matrix, long diag, long fromRow, long col,
			double factor) {
		long rows = matrix.getRowCount();
		for (long row = fromRow; row < rows; row++) {
			matrix.setDouble(matrix.getDouble(row, col) - factor * matrix.getDouble(row, diag),
					row, col);
		}
	}
1103745
def upsample(self, factor):
        
        
        self.checkforpilimage()
        
        if type(factor) != type(0):
            raise RuntimeError, "Upsample factor must be an integer !"
        
        if self.verbose:
            print "Upsampling by a factor of %i" % factor
        self.pilimage = self.pilimage.resize((self.pilimage.size[0] * factor, self.pilimage.size[1] * factor))
        self.upsamplefactor = factor
        
        self.draw = None
977053
public static void addRowTimes(Matrix matrix, long diag, long fromCol, long row, double factor) {
		long cols = matrix.getColumnCount();
		for (long col = fromCol; col < cols; col++) {
			matrix.setAsDouble(
					matrix.getAsDouble(row, col) - factor * matrix.getAsDouble(diag, col), row, col);
		}
	}
8486
def phi( n ):
  """"""

  assert isinstance( n, integer_types )

  if n < 3: return 1

  result = 1
  ff = factorization( n )
  for f in ff:
    e = f[1]
    if e > 1:
      result = result * f[0] ** (e-1) * ( f[0] - 1 )
    else:
      result = result * ( f[0] - 1 )
  return result