Return a vector with the elements rounded to the given number of digits.
972010
def get_rounded(self, digits):
        
        result = self.copy()
        result.round(digits)
        return result
168624
def round(self, digits=0):
        
        self._left = round(self._left, digits)
        self._bottom = round(self._bottom, digits)
        self._width = round(self._width, digits)
        self._height = round(self._height, digits)
714839
function _Vector(dimension, data) {
  if (!dimension || !Number.isInteger(dimension))
    throw new TypeError('Dimension of the array must be an integer.');

  var _values;
  if (!data || data === undefined)
    _values = [];
  else if (!util.isNumberArray(data))
    throw new TypeError('Invalid values for vector.');
  else
    _values = data;

  if (_values.length < dimension) {
    var zeros = Array(dimension - _values.length).fill(0);
    _values = _values.concat(zeros);
  } else if (_values.length > dimension) {
    _values = _values.slice(0, dimension);
  }

  readonly(this, "dimension", dimension);
  readonly(this, "values", _values);
  readonly(this, "magnitude", _magnitudeOf(_values));
}
129734
function round(num, places) {
    const n = Math.pow(10, places);
    return Math.round(num * n) / n;
}
148301
def round(self, eps=1e-14, rmax=100000):
        
        c = matrix()
        c.tt = self.tt.round(eps, rmax)
        c.n = self.n.copy()
        c.m = self.m.copy()
        return c
962295
def round_to_scale(number, precision):
    """"""
    if precision < 1:
        return round_to_float(number, precision)
    return round_to_int(number, precision)
237128
def round_figures(x, n):
    """"""
    return round(x, int(n - math.ceil(math.log10(abs(x)))))
1233559
def roundlist (inlist,digits):
    
    if type(inlist[0]) in [IntType, FloatType]:
        inlist = [inlist]
    l = inlist*1
    for i in range(len(l)):
        for j in range(len(l[i])):
            if type(l[i][j])==FloatType:
                l[i][j] = round(l[i][j],digits)
    return l
361503
def to_digital(d, num):
    
    if not isinstance(num, int) or not 1 < num < 10:
        raise ValueError('digital num must between 1 and 10')

    d = int(d)
    result = []
    x = d % num
    d = d - x
    result.append(str(x))
    while d > 0:
        d = d // num
        x = d % num
        d = d - x
        result.append(str(x))
    return ''.join(result[::-1])
424733
function roundToPrecision(numStr, scale, fixedDecimalScale) {
  //if number is empty don't do anything return empty string
  if (['', '-'].indexOf(numStr) !== -1) return numStr;
  var shoudHaveDecimalSeparator = numStr.indexOf('.') !== -1 && scale;

  var _splitDecimal = splitDecimal(numStr),
      beforeDecimal = _splitDecimal.beforeDecimal,
      afterDecimal = _splitDecimal.afterDecimal,
      hasNagation = _splitDecimal.hasNagation;

  var roundedDecimalParts = parseFloat("0.".concat(afterDecimal || '0')).toFixed(scale).split('.');
  var intPart = beforeDecimal.split('').reverse().reduce(function (roundedStr, current, idx) {
    if (roundedStr.length > idx) {
      return (Number(roundedStr[0]) + Number(current)).toString() + roundedStr.substring(1, roundedStr.length);
    }

    return current + roundedStr;
  }, roundedDecimalParts[0]);
  var decimalPart = limitToScale(roundedDecimalParts[1] || '', Math.min(scale, afterDecimal.length), fixedDecimalScale);
  var negation = hasNagation ? '-' : '';
  var decimalSeparator = shoudHaveDecimalSeparator ? '.' : '';
  return "".concat(negation).concat(intPart).concat(decimalSeparator).concat(decimalPart);
}
233128
def hex(self):
        """"""

        sign = '-' if self._sign() else ''
        e = self._exponent()
        if isinstance(e, six.string_types):
            return sign + e

        m = self._significand()
        _, digits, _ = _mpfr_get_str2(
            16,
            0,
            m,
            ROUND_TIES_TO_EVEN,
        )
        # only print the number of digits that are actually necessary
        n = 1 + (self.precision - 1) // 4
        assert all(c == '0' for c in digits[n:])
        result = '%s0x0.%sp%+d' % (sign, digits[:n], e)
        return result
322243
def _round(num):
    
    deci = num - math.floor(num)
    if deci > 0.8:
        return int(math.floor(num) + 1)
    else:
        return int(math.floor(num))
1225139
def generate(length):
    """"""
    if not isinstance(length, int) or length < 2:
        raise TypeError('length must be a positive integer greater than 1.')

    # first digit cannot be 0
    digits = [random.randint(1, 9)]

    for i in range(length-2):
        digits.append(random.randint(0, 9))
    digits.append(get_check_digit(''.join(map(str, digits))))

    return ''.join(map(str, digits))
128277
def orthogonal_vector(v):
    """"""
    if v[1] != 0 or v[2] != 0:
        c = (1, 0, 0)
    else:
        c = (0, 1, 0)
    return np.cross(v, c)
157439
def numdiff(fun, args):
    """"""

    # vectorized version

    epsilon = 1e-8
    args = list(args)
    v0 = fun(*args)
    N = v0.shape[0]
    l_v = len(v0)
    dvs = []
    for i, a in enumerate(args):
        l_a = (a).shape[1]
        dv = numpy.zeros((N, l_v, l_a))
        nargs = list(args)  #.copy()
        for j in range(l_a):
            xx = args[i].copy()
            xx[:, j] += epsilon
            nargs[i] = xx
            dv[:, :, j] = (fun(*nargs) - v0) / epsilon
        dvs.append(dv)
    return [v0] + dvs
995231
def g_subset(g, atwts, atwt,
            digits=_DEF.SYMM_ATWT_ROUND_DIGITS):
    

    # Imports
    import numpy as np

    # Ensure g and atwts are n-D vectors
    g = make_nd_vec(g, nd=None, t=np.float64, norm=False)
    atwts = make_nd_vec(atwts, nd=None, t=np.float64, norm=False)

    # Ensure dims match (should already be checked at object creation...)
    if not (len(g) == 3*len(atwts)):
        raise ValueError("Dim mismatch [len(g) != 3*len(ats)].")
    ## end if

    # Pull into coordinate groups
    co = np.split(g, g.shape[0] // 3)

    # Filter by the indicated atomic weight
    cf = [c for (c,a) in zip(co, atwts) if \
                    np.round(a, digits) == np.round(atwt, digits)]

    # Expand back to single vector, if possible
    if not cf == []:
        g_sub = np.concatenate(cf, axis=0)
        g_sub = g_sub.reshape((g_sub.shape[0],1))
    else:
        g_sub = []
    ## end if

    # Return the subset
    return g_sub
590091
def number(v):
    """"""
    if nodesetp(v):
        v = string(v)
    try:
        return float(v)
    except ValueError:
        return float('NaN')