arr_out = round_array(array_in)

    Rounds an array and recasts it to int. Also works on scalars.
182769
def round_array(array_in):
    
    if isinstance(array_in, ndarray):
        return np.round(array_in).astype(int)
    else:
        return int(np.round(array_in))
833892
function recurse( out, arr, depth ) {
	var len = arr.length,
		val,
		i;

	for ( i = 0; i < len; i++ ) {
		val = arr[ i ];
		if ( depth && isArray( val ) ) {
			recurse( out, val, depth-1 );
		} else {
			out.push( val );
		}
	}
	return out;
}
1133394
function arraySpliceOut(mutate, at, arr) {
    var newLen = arr.length - 1;
    var i = 0;
    var g = 0;
    var out = arr;
    if (mutate) {
        i = g = at;
    } else {
        out = new Array(newLen);
        while (i < at) {
            out[g++] = arr[i++];
        }
    }
    ++i;
    while (i <= newLen) {
        out[g++] = arr[i++];
    }if (mutate) {
        out.length = newLen;
    }
    return out;
}
392163
function fromScaling(out, v) {
  out[0] = v[0];
  out[1] = 0;
  out[2] = 0;

  out[3] = 0;
  out[4] = v[1];
  out[5] = 0;

  out[6] = 0;
  out[7] = 0;
  out[8] = 1;
  return out;
}
499096
function flatten() {
    var arr = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        arr[_i] = arguments[_i];
    }
    var i = 0;
    var result = [];
    while (i < arr.length) {
        var itm = arr[i];
        if (is_1.isArray(itm))
            result = result.concat(flatten.apply(void 0, itm));
        else
            result = result.concat([itm]);
        i++;
    }
    return result;
}
576669
function flatten(matrix) {
    const res = [];

    // If the given matrix is not a matrix but a scalar.
    if (!Array.isArray(matrix)) {
        matrix = [
            [matrix]
        ];
    }

    matrix.forEach((row) => {
        // If the given matrix is a vector.
        if (!Array.isArray(row)) {
            row = [row];
        }

        row.forEach((elem) => {
            res.push(elem.real);
            res.push(elem.imag);
        });
    });
    return res;
}
1208235
def sround(x, precision=0):
    
    sr = StochasticRound(precision=precision)
    return sr.round(x)
279401
function(arr, i) {
			var ret = arr.slice(0);
			for (var j = 0; j < i; j++) {
				ret = [ret[ret.length - 1]].concat(ret.slice(0, ret.length - 1));
			}
			return ret;
		}
839366
function subIndex(arr, index) {
  if (!Array.isArray(arr)) {
    var arrType = typeof arr;
    var stringifiedArr = String(arr);

    throw new TypeError(
      'Expected an array, but got ' +
      (stringifiedArr === arrType ? stringifiedArr : stringifiedArr + ' (' + arrType + ')') +
      '.'
    );
  }

  if (arr.length === 0) {
    throw new Error('Expected a non-empty array, but got [].');
  }

  var indexType = typeof index;
  var stringifiedIndex = String(index);

  if (indexType !== 'number') {
    throw new TypeError(
      'Expected an index of array (integer), but got ' +
      (stringifiedIndex === indexType ? stringifiedIndex : stringifiedIndex + ' (' + indexType + ')') +
      '.'
    );
  }

  if (!isFinite(index) || Math.floor(index) !== index) {
    throw new Error('Expected an index of array (integer), but got ' + String(index) + '.');
  }

  if (index < 0) {
    throw new Error('Expected an index of array (positive integer), but got ' + String(index) + '.');
  }

  var arrLength = arr.length;

  if (index >= arrLength) {
    throw new Error(
      'Expected an index of array, but got ' +
      String(index) +
      ' that exceeds the last index of the array (' + (arrLength - 1) + ').');
  }

  if (arr.length === 1) {
    return null;
  }

  if (index === 0) {
    return 1;
  }

  return index - 1;
}
405829
function transpose(out, a) {
  // If we are transposing ourselves we can skip a few steps but have to cache some values
  if (out === a) {
    var a1 = a[1]
    out[1] = a[2]
    out[2] = a1
  } else {
    out[0] = a[0]
    out[1] = a[2]
    out[2] = a[1]
    out[3] = a[3]
  }

  return out
}
601453
def to_int(self):
        
        coord = [int(round(x)) for x in self.xy_coord()]
        return self.from_xy(coord[0], coord[1], coord[2], coord[3])
967728
def roundup(x, order):
    '''
    '''
    return x if x % 10**order == 0 else x + 10**order - x % 10**order
1171966
function flatten( arr ) {
	var tmp;
	var out;
	var i;
	var j;
	
	out = [];
	for ( i = 0; i < arr.length; i++ ) {
		tmp = arr[ i ];
		if ( tmp ) {
			for ( j = 0; j < tmp.length; j++ ) {
				out.push( tmp[ j ] );
			}
		}
	}
	return out;
}
1189823
function inverse(out, a) {
  out[0] = 1.0 / a[0]
  out[1] = 1.0 / a[1]
  out[2] = 1.0 / a[2]
  return out
}
1062594
def round_value(val)
      remainder = val % self.step_size
      unprecised = if (remainder * 2) >= self.step_size
                      (val - remainder) + self.step_size
                    else
                      val - remainder
                    end
      if self.step_size < 1
        precision = -Math.log10(self.step_size).floor
        (unprecised * (10 ** precision)).to_i.to_f / (10 ** precision)
      else
        unprecised
      end      
    end
569208
def teachers_round(x):
    '''
    
    '''
    if ((x > 0) and (x % 1 >= 0.5)) or ((x < 0) and (x % 1 > 0.5)):
        return int(np.ceil(x))
    else:
        return int(np.floor(x))
555630
def as_square_array(arr):
    
    arr = np.atleast_2d(arr)
    if len(arr.shape) != 2 or arr.shape[0] != arr.shape[1]:
        raise ValueError("Expected square array")
    return arr