Return true if the colum is a dimension
541005
def is_error(self):
        """"""
        from ambry.valuetype.core import ROLE
        return self.role == ROLE.ERROR
956654
private void checkColumnSingletons(DoubleMatrix1D c,
			DoubleMatrix2D A, DoubleMatrix1D b, 
			DoubleMatrix1D lb, DoubleMatrix1D ub, 
			DoubleMatrix1D ylb, DoubleMatrix1D yub,
			DoubleMatrix1D zlb, DoubleMatrix1D zub) {
		for(short col=0; col<this.vColPositions.length; col++){
			if(vColPositions[col].length == 1){
				short row = vColPositions[col][0];
				log.debug("found column singleton at row " + row + ", col " + col);
				short[] vRowPositionsRow = vRowPositions[row];
				if(vRowPositionsRow.length < 2){
					continue;//this is a fixed variable
				}

				double ARcol = A.getQuick(row, col);
				double cCol = c.getQuick(col);
				boolean isCColNz = !isZero(cCol);
				double lbCol = lb.getQuick(col);
				double ubCol = ub.getQuick(col);
				boolean isLBUnbounded = isLBUnbounded(lbCol); 
				boolean isUBUnbounded = isUBUnbounded(ubCol);
				
				if(isLBUnbounded || isUBUnbounded){
					//bound on one of the optimal Lagrange multipliers.
					if(isLBUnbounded){
						if(isUBUnbounded){
							//table 2, row 1
							zlb.setQuick(col, 0);
							zub.setQuick(col, 0);
							ylb.setQuick(row, cCol / ARcol);
							yub.setQuick(row, cCol / ARcol);
						}else{
							if(ARcol > 0){
								//table 2, row 4
								zub.setQuick(col, 0);
								ylb.setQuick(row, cCol / ARcol);
							}else{
								//table 2, row 5
								zub.setQuick(col, 0);
								yub.setQuick(row, cCol / ARcol);
							}
						}
					}else{
						if(isUBUnbounded){
							if(ARcol > 0){
								//table 2, row 2
								zlb.setQuick(col, 0);
								yub.setQuick(row, cCol / ARcol);
							}else{
								//table 2, row 3
								zlb.setQuick(col, 0);
								ylb.setQuick(row, cCol / ARcol);
							}
						}
					}
					
					if(isLBUnbounded && isUBUnbounded){
						//free column singleton: one constraint and	one variable 
						//is removed from the problem without generating any fill-ins in A, 
						//although	the objective function is modified
						log.debug("free column singleton");
						//substitution into the objective function
						short[] xi = new short[vRowPositionsRow.length-1];
						double[] mi = new double[vRowPositionsRow.length - 1];
						int cntXi = 0;
						for (int j = 0; j < vRowPositionsRow.length; j++) {
							short nzJ = vRowPositionsRow[j];
							if (nzJ != col){
								xi[cntXi] = nzJ;
								mi[cntXi] = -A.getQuick(row, nzJ) / ARcol;
								cntXi++;
								if (isCColNz){
									c.setQuick(nzJ, c.getQuick(nzJ) - cCol * A.getQuick(row, nzJ) / ARcol);
								}
							}
						}
						//see Andersen & Andersen, eq (10) [that is incorrect!]
						addToPresolvingStack(new LinearDependency(col, xi, mi, b.getQuick(row)));
						for(short j = 0; j < vRowPositionsRow.length; j++){
							short column = vRowPositionsRow[j];//the nz column index
							if(column!=col && vColPositions[column].length == 1){
								//this is also a column singleton, we do not want an empty final column
								//so we fix the value of the variable
								//@TODO: fix this for unbounded bounds
								if(c.getQuick(column)<0){
									lb.setQuick(column, ub.getQuick(column));
								}else if(c.getQuick(column)>0){
									ub.setQuick(column, lb.getQuick(column));
								}else{
									ub.setQuick(column, lb.getQuick(column));
								}
								log.debug("found fixed variables: x[" + column + "]="+lb.getQuick(column));
								addToPresolvingStack(new LinearDependency(column, null, null, lb.getQuick(column)));
								pruneFixedVariable(column, c, A, b, lb, ub, ylb, yub, zlb, zub);
							}
							changeColumnsLengthPosition(column, vColPositions[column].length, vColPositions[column].length-1);
							vColPositions[column] = removeElementFromSortedArray(vColPositions[column], row);
							A.setQuick(row, column, 0.);
						}
						changeRowsLengthPosition(row, vRowPositions[row].length, 0);
						vRowPositions[row] = new short[]{};
						if(vColPositions[col].length > 0){
							log.debug("Expected empty column "+col+" but was not empty");
							throw new IllegalStateException("Expected empty column "+col+" but was not empty");
						}
						vColPositions[col] = new short[]{};
						ylb.setQuick(row, cCol / ARcol);//ok, but jet stated above
						yub.setQuick(row, cCol / ARcol);//ok, but jet stated above
						b.setQuick(row, 0);
						lb.setQuick(col, this.unboundedLBValue);
						ub.setQuick(col, this.unboundedUBValue);
						c.setQuick(col, 0);
						this.someReductionDone = true;
						continue;
					}
				}
				
				double impliedL;
				double impliedU;
				if(ARcol>0){
					impliedL = (b.getQuick(row) - h[row])/ARcol + ubCol;
					impliedU = (b.getQuick(row) - g[row])/ARcol + lbCol;
				}else{
					impliedL = (b.getQuick(row) - g[row])/ARcol + ubCol;
					impliedU = (b.getQuick(row) - h[row])/ARcol + lbCol;
				}
				boolean ifl = impliedL > lbCol;//do not use =, it will cause a loop
				boolean ifu = impliedU < ubCol;//do not use =, it will cause a loop
				if(ifl){
				  lb.setQuick(col, impliedL);//tighten the bounds
				  lbCol = impliedL;
				  this.someReductionDone = true;
				}
				if(ifu){
				  ub.setQuick(col, impliedU);//tighten the bounds
				  ubCol = impliedU;
				  this.someReductionDone = true;
				}
				boolean isImpliedFree = (ifl && ifu) || (isZero(impliedL - lbCol) && isZero(impliedU - ubCol));
								
				if(vRowPositionsRow.length == 2 || isImpliedFree){
					//substitution
					short y = -1;
					double q=0., m=0.;
					short[] xi = new short[vRowPositionsRow.length-1];
					double[] mi = new double[vRowPositionsRow.length-1];
					StringBuffer sb = new StringBuffer("x["+col+"]=");
					q = b.getQuick(row)/ARcol;
					sb.append(q);
					int cntXi = 0;
					for(int j=0; j<vRowPositionsRow.length; j++){
						short nzJ = vRowPositionsRow[j];  
						if(nzJ != col){
							double ARnzJ = A.getQuick(row, nzJ);
							m = -ARnzJ/ARcol;
							xi[cntXi] = nzJ;
							mi[cntXi] = m;
							cntXi++;
							sb.append(" + " + m + "*x["+nzJ+"]");
							if(isCColNz){
								//the objective function is modified
								double cc = c.getQuick(col) * ARnzJ / ARcol;
								c.setQuick(nzJ, c.getQuick(nzJ) - cc);
							}
							y = nzJ;
						}
					}
					addToPresolvingStack(new LinearDependency(col, xi, mi, q));
					
					if(vRowPositionsRow.length == 2){
					//NOTE: the row and the column are removed
						log.debug("doubleton equation combined with a column singleton: " + sb.toString());
						//x = m*y + q, x column singleton
						//addToDoubletonMap(col, y, m, q);
						//the bounds on the variable y are modified so	that the feasible region is unchanged even if the bounds on x are removed
						//y = x/m - q/m
						double lbY = lb.getQuick(y);
						double ubY = ub.getQuick(y);
						boolean isLBYUnbounded = isLBUnbounded(lbY);
						boolean isUBYUnbounded = isLBUnbounded(ubY);
						if(m>0){
							if(!isLBUnbounded){
								double l = lbCol/m - q/m;
								lb.setQuick(y, (isLBYUnbounded)? l : Math.max(lbY, l));
							}
							if(!isUBUnbounded){
								double u = ubCol/m - q/m;
								ub.setQuick(y, (isUBYUnbounded)? u : Math.min(ubY, u));
							}
						}else{
							if(!isUBUnbounded){
								double u = ubCol/m - q/m;
								lb.setQuick(y, (isLBYUnbounded)? u : Math.max(lbY, u));
							}
							if(!isLBUnbounded){
								double l = lbCol/m - q/m;
								ub.setQuick(y, (isUBYUnbounded)? l : Math.min(ubY, l));
							}
						}
						if(vColPositions[y].length == 1){
							//this is also a column singleton, we do not want an empty final column
							//so we fix the value of the variable
							if(c.getQuick(y)<0){
								if(isUBUnbounded(ub.getQuick(y))){
									throw new RuntimeException("unbounded problem");
								}
								lb.setQuick(y, ub.getQuick(y));
							}else if(c.getQuick(y)>0){
								if(isLBUnbounded(lb.getQuick(y))){
									throw new RuntimeException("unbounded problem");
								}
								ub.setQuick(y, lb.getQuick(y));
							}else{
								//any value is good
								if(isLBUnbounded(lb.getQuick(y)) && isUBUnbounded(ub.getQuick(y))){
									throw new RuntimeException("unbounded problem");
								}else if(!isLBUnbounded(lb.getQuick(y)) && !isUBUnbounded(ub.getQuick(y))){
									double d = (ub.getQuick(y)-lb.getQuick(y))/2;
									lb.setQuick(y, d);
									ub.setQuick(y, d);
								}else if(!isLBUnbounded(lb.getQuick(y))){
									ub.setQuick(y, lb.getQuick(y));
								}else{
									lb.setQuick(y, ub.getQuick(y));
								}
							}
						}
						//remove the bounds on col
						lb.setQuick(col, this.unboundedLBValue);
						ub.setQuick(col, this.unboundedUBValue);
						//remove the variable
						A.setQuick(row, col, 0.);
						A.setQuick(row, y, 0.);
						b.setQuick(row, 0.);
						changeColumnsLengthPosition(col, vColPositions[col].length, 0);
						vColPositions[col] = new short[]{};
						vRowPositionsRow = removeElementFromSortedArray(vRowPositionsRow, col);//just to have vRowPositionsRow[0] 
						changeRowsLengthPosition(row, vRowPositionsRow.length+1, vRowPositionsRow.length);
						changeColumnsLengthPosition(vRowPositionsRow[0], vColPositions[vRowPositionsRow[0]].length, vColPositions[vRowPositionsRow[0]].length-1);
						vColPositions[vRowPositionsRow[0]] = removeElementFromSortedArray(vColPositions[vRowPositionsRow[0]], row);
						vRowPositions[row] = new short[]{};
						this.someReductionDone = true;
						continue;
					} else {
						//NOTE: one constraint and	one variable is removed from the problem 
						//without generating any fill-ins in A, 
						//although the objective function is modified
						log.debug("implied free column singletons: " + sb.toString());
						ylb.setQuick(row, c.getQuick(col) / A.getQuick(row, col));//ok, but already stated above 
						yub.setQuick(row, c.getQuick(col) / A.getQuick(row, col));//ok, but already stated above
						for(short cc=0; cc<vRowPositions[row].length; cc++){
							short column = vRowPositions[row][cc];
							if(column == col){
								continue;
							}
							if(vColPositions[column].length == 1){
								//this is also a column singleton, we do not want an empty final column
								//so we fix the value of the variable
								if(c.getQuick(column)<0){
									//no problem of unbounded bound, this is an implied free column
									if(isUBUnbounded(ub.getQuick(column))){
										throw new RuntimeException("unbounded problem");
									}
									lb.setQuick(column, ub.getQuick(column));
								}else if(c.getQuick(column)>0){
									//no problem of unbounded bound, this is an implied free column
									if(isLBUnbounded(lb.getQuick(column))){
										throw new RuntimeException("unbounded problem");
									}
									ub.setQuick(column, lb.getQuick(column));
								}else{
									//no problem of unbounded bound, this is an implied free column
									if(isLBUnbounded(lb.getQuick(column)) || isUBUnbounded(ub.getQuick(column))){
										throw new RuntimeException("unbounded problem");
									}
									double d = (ub.getQuick(y) - lb.getQuick(y)) / 2;
									lb.setQuick(y, d);
									ub.setQuick(y, d);
								}
								log.debug("found fixed variables: x[" + column + "]="+lb.getQuick(column));
								addToPresolvingStack(new LinearDependency(column, null, null, lb.getQuick(column)));
								pruneFixedVariable(column, c, A, b, lb, ub, ylb, yub, zlb, zub);
							}
							changeColumnsLengthPosition(column, vColPositions[column].length, vColPositions[column].length-1);
							vColPositions[column] = removeElementFromSortedArray(vColPositions[column], row);
							A.setQuick(row, column, 0.);
						}
						A.setQuick(row, col, 0.);
						b.setQuick(row, 0);
						lb.setQuick(col, this.unboundedLBValue);
						ub.setQuick(col, this.unboundedUBValue);
						c.setQuick(col, 0);
						changeColumnsLengthPosition(col, vColPositions[col].length, 0);
						vColPositions[col] = new short[]{};
						changeRowsLengthPosition(row, vRowPositions[row].length, 0);
						vRowPositions[row] = new short[]{};
						this.someReductionDone = true;
						//checkProgress(c, A, b, lb, ub, ylb, yub, zlb, zub);
						continue;
					}
				}
			}		
		}
	}
27929
def arange_col(n, dtype=int):
    
    return np.reshape(np.arange(n, dtype = dtype), (n, 1))
482705
def isSquare(matrix):
    
    try:
        try:
            dim1, dim2 = matrix.shape
        except AttributeError:
            dim1, dim2 = _np.array(matrix).shape
    except ValueError:
        return False
    if dim1 == dim2:
        return True
    return False
888662
def exists_dimension(dimension_name,**kwargs):
    
    try:
        dimension = db.DBSession.query(Dimension).filter(Dimension.name==dimension_name).one()
        # At this point the dimension exists
        return True
    except NoResultFound:
        # The dimension does not exist
        raise False
250359
private boolean checkForNaNs(NumberVector vec) {
    for(int i = 0, d = vec.getDimensionality(); i < d; i++) {
      double v = vec.doubleValue(i);
      if(v != v) { // NaN!
        return true;
      }
    }
    return false;
  }
421923
def _compute_ndim(row_loc, col_loc):
    
    row_scaler = is_scalar(row_loc)
    col_scaler = is_scalar(col_loc)

    if row_scaler and col_scaler:
        ndim = 0
    elif row_scaler ^ col_scaler:
        ndim = 1
    else:
        ndim = 2

    return ndim
585088
def _get_col_dimstr(tdim, is_string=False):
    
    dimstr = ''
    if tdim is None:
        dimstr = 'array[bad TDIM]'
    else:
        if is_string:
            if len(tdim) > 1:
                dimstr = [str(d) for d in tdim[1:]]
        else:
            if len(tdim) > 1 or tdim[0] > 1:
                dimstr = [str(d) for d in tdim]
        if dimstr != '':
            dimstr = ','.join(dimstr)
            dimstr = 'array[%s]' % dimstr

    return dimstr
55770
private boolean isSelectAllColumns() {
    String columnProjection = this.getInputColumnProjection();
    if (columnProjection == null || columnProjection.trim().equals("*") || columnProjection.contains(".*")) {
      return true;
    }
    return false;
  }
96562
def _dimension(rank0, rankt, dim, singular_values):
        
        if dim is None or (isinstance(dim, float) and dim == 1.0):
            return min(rank0, rankt)
        if isinstance(dim, float):
            return np.searchsorted(VAMPModel._cumvar(singular_values), dim) + 1
        else:
            return np.min([rank0, rankt, dim])
1193365
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
    var otherDimIndex = 1 - dimIndex;
    return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
}
679334
boolean isUniqueWithColumns(int[] cols) {

        if (constType != UNIQUE || core.mainCols.length != cols.length) {
            return false;
        }

        return ArrayUtil.haveEqualSets(core.mainCols, cols, cols.length);
    }
910838
def format_dimension(dimension):
        """"""
        result = ""
        if "type" in dimension.attrib:
            result += "[R" if dimension.attrib["type"] == "row" else "[C"
        else:
            result += "[C"
        if "index" in dimension.attrib:
            result += ":" + dimension.attrib["index"]

        result += "] " + re.sub("\s+", " ", dimension.text.replace("\n", " "))
        return result
883861
public boolean hasColumn(String columnName) {
        Integer idx = columnNamesIndex.get(columnName);
        return idx != null;
    }
268547
function checkDimension(i) {
  const ln = checkNumber(i);
  let li;

  if (i >= tokensLength ||
      !ln ||
      i + ln >= tokensLength) return 0;

  return (li = checkUnit(i + ln)) ? ln + li : 0;
}
526048
public boolean hasColumnName(String columnName) {
		for (FieldType fieldType : fieldTypes) {
			if (fieldType.getColumnName().equals(columnName)) {
				return true;
			}
		}
		return false;
	}
609600
public boolean areDimensionsRightAligned(int[] otherDims) {
    for (int i = 1; i < otherDims.length + 1; i++) {
      if (otherDims[otherDims.length - i] != dimensions[dimensions.length - i]) {
        return false;
      }
    }
    return true;
  }