Use a list of values to calculate m/m/m/m. Resolution values or otherwise.
    :param numpy array v: Values
    :param bool calc: If false, we don't need calculations
    :return dict:  Results of calculation
439948
def __get_inferred_data_res_2(v=None, calc=True):
    
    # Base: If something goes wrong, or if there are no values, then use "NaN" placeholders.
    d = {
        "hasMinValue": "nan", "hasMaxValue": "nan",
        "hasMeanValue": "nan", "hasMedianValue": "nan",
    }
    try:
        if calc:
            _min = np.nanmin(v)
            _max = np.nanmax(v)
            _mean = np.nanmean(v)
            _med = np.nanmedian(v)

            if np.isnan(_min):
                _min = "nan"
            else:
                _min = abs(_min)
            if np.isnan(_max):
                _max = "nan"
            else:
                _min = abs(_min)
            if np.isnan(_mean):
                _mean = "nan"
            else:
                _min = abs(_min)
            if np.isnan(_med):
                _med = "nan"
            else:
                _min = abs(_min)

            d = {
                "hasMinValue": _min,
                "hasMaxValue": _max,
                "hasMeanValue": _mean,
                "hasMedianValue": _med
            }
    except Exception as e:
        logger_inferred_data.error("get_inferred_data_res_2: {}".format(e))

    return d
362429
def _point_scalar(self, name=None):
        
        if name is None:
            # use active scalar array
            field, name = self.active_scalar_info
            if field != POINT_DATA_FIELD:
                raise RuntimeError('Must specify an array to fetch.')
        vtkarr = self.GetPointData().GetArray(name)
        if vtkarr is None:
            raise AssertionError('({}) is not a point scalar'.format(name))

        # numpy does not support bit array data types
        if isinstance(vtkarr, vtk.vtkBitArray):
            vtkarr = vtk_bit_array_to_char(vtkarr)
            if name not in self._point_bool_array_names:
                self._point_bool_array_names.append(name)

        array = vtk_to_numpy(vtkarr)
        if array.dtype == np.uint8 and name in self._point_bool_array_names:
            array = array.view(np.bool)
        return array
1305801
def h(values):
    
    ent = np.true_divide(values, np.sum(values))
    return -np.sum(np.multiply(ent, np.log2(ent)))
678750
def calc_deviation(values, average):
    
    size = len(values)
    if size < 2:
        return 0
    calc_sum = 0.0

    for number in range(0, size):
        calc_sum += math.sqrt((values[number] - average) ** 2)
    return math.sqrt((1.0 / (size - 1)) * (calc_sum / size))
393658
def c_mvar(self):
        
        if self.b == -4:
            return 1.0
        elif self.b == -3:
            return 0.0
        elif self.b == -2:
            return -1.0
        elif self.b == -1:
            return -2.0
        elif self.b == 0:
            return -3.0
823703
def meter_calls_with_dims(**dims):
    
    def meter_wrapper(fn):
        @functools.wraps(fn)
        def fn_wrapper(*args, **kwargs):
            meter("%s_calls" %
                  pyformance.registry.get_qualname(fn), **dims).mark()
            return fn(*args, **kwargs)
        return fn_wrapper
    return meter_wrapper
244474
def _wva(values, weights):
        
        assert len(values) == len(weights) and len(weights) > 0
        return sum([mul(*x) for x in zip(values, weights)]) / sum(weights)
1104630
def _select_vs(v, p):
    # This one is is about 30 times faster than
    # the generic algorithm it is replacing.
    """"""

    if v >= 120.:
        return 60, 120, inf
    elif v >= 60.:
        return 40, 60, 120
    elif v >= 40.:
        return 30, 40, 60
    elif v >= 30.:
        return 24, 30, 40
    elif v >= 24.:
        return 20, 24, 30
    elif v >= 19.5:
        return 19, 20, 24

    if p >= .9:
        if v < 2.5:
            return 1, 2, 3
    else:
        if v < 3.5:
            return 2, 3, 4

    vi = int(round(v))
    return vi - 1, vi, vi + 1
79851
def _compute_equations(self, x, verbose=False):
        '''
        '''
        # compute the error and the normals.
        normals = []
        values = []
        signs = []
        error = 0.0
        if verbose:
            print()
            print(' '.join('% 10.3e' % val for val in x), end=' ')
            active_str = ''
        for i, (sign, equation) in enumerate(self.equations):
            value, normal = equation(x)
            if (i < len(self.lock) and self.lock[i]) or \
               (sign==-1 and value > -self.threshold) or \
               (sign==0) or (sign==1 and value < self.threshold):
                values.append(value)
                normals.append(normal)
                signs.append(sign)
                error += value**2
                if verbose:
                    active_str += 'X'
                if i < len(self.lock):
                    self.lock[i] = True
            elif verbose:
                active_str += '-'
        error = np.sqrt(error)
        normals = np.array(normals, float)
        values = np.array(values, float)
        signs = np.array(signs, int)
        if verbose:
            print('[%s]' % active_str, end=' ')
            if error < self.threshold:
                print('OK')
            else:
                print('%.5e' % error)
        return normals, values, error, signs
856967
def cache_values(self, results):
		
		if results is None:
			# self.fn was probably only used to compute side effects.
			return
		elif isinstance(results,np.ndarray):
			# fn returns single np.ndarray.
			# re-format it into a list
			results=[results]
		# check validity of fn output
		elif isinstance(results,list):
			if len(results) is not len(self.outputs):
				raise ValueError('Number of output tensors does not match number of outputs produced by function')
		elif isinstance(results,np.number):
			if len(self.outputs) != 1:
				raise ValueError('Fn produces scalar but %d outputs expected' % (len(self.outputs)))
			results=[results]
		# assign each element in ndarrays to corresponding output tensor
		for i,ndarray in enumerate(results):
			self.session._cache_value(self.outputs[i], ndarray)
693425
def result(self):
        
        # TODO: how about xcurrent?
        return self.best.get() + (
            self.countevals, self.countiter, self.gp.pheno(self.mean),
            self.gp.scales * self.sigma * self.sigma_vec * self.dC**0.5)
720042
def extract_ms(self, x, y):
        
        ms = np.zeros(self.conf.ndims)
        ms[self.expl_dims] = x
        ms[self.inf_dims] = y
        return ms[self.conf.m_dims], ms[self.conf.s_dims]
350812
def get_mi_vec(slab):
    
    mvec = np.cross(slab.lattice.matrix[0], slab.lattice.matrix[1])
    return mvec / np.linalg.norm(mvec)
1020289
def calcEL(self,**kwargs):
                                   
        E,L= calcELStaeckel(self._R,self._vR,self._vT,self._z,self._vz,
                            self._pot)
        return (E,L)
503940
def _num_values(self, vdr_dict):
        '''
        
        '''
        values = 1
        for x in range(0, vdr_dict['num_dims']):
            if (vdr_dict['dim_vary'][x] != 0):
                values = values * vdr_dict['dim_sizes'][x]
        return values
138555
def F_calc(TP, FP, FN, beta):
    
    try:
        result = ((1 + (beta)**2) * TP) / \
            ((1 + (beta)**2) * TP + FP + (beta**2) * FN)
        return result
    except ZeroDivisionError:
        return "None"
109558
function(vec2, returnNew) {
      var x,y;
      if ('number' !== typeof vec2) {
        x = vec2.x;
        y = vec2.y;

      // Handle incoming scalars
      } else {
        x = y = vec2;
      }

      if (x === 0 || y === 0) {
        throw new Error('division by zero')
      }

      if (isNaN(x) || isNaN(y)) {
        throw new Error('NaN detected');
      }

      if (returnNew) {
        return new Vec2(this.x / x, this.y / y);
      }

      return this.set(this.x / x, this.y / y);
    }