Calculates deviance information Criterion
514676
def _calc_dic(self):
        """"""

        # Find mean deviance
        mean_deviance = np.mean(self.db.trace('deviance')(), axis=0)

        # Set values of all parameters to their mean
        for stochastic in self.stochastics:

            # Calculate mean of paramter
            try:
                mean_value = np.mean(
                    self.db.trace(
                        stochastic.__name__)(
                    ),
                    axis=0)

                # Set current value to mean
                stochastic.value = mean_value

            except KeyError:
                print_(
                    "No trace available for %s. DIC value may not be valid." %
                    stochastic.__name__)
            except TypeError:
                print_(
                    "Not able to calculate DIC: invalid stochastic %s" %
                    stochastic.__name__)
                return None

        # Return twice deviance minus deviance at means
        return 2 * mean_deviance - self.deviance
919929
def _compute(self):
        ''''''
        tendencies = self._temperature_tendencies()
        if 'q' in self.state:
            # in a model with active water vapor, this flux should affect
            #  water vapor tendency, NOT air temperature tendency!
            tendencies['Tatm'] *= 0.
            Pa_per_hPa = 100.
            air_mass_per_area = self.Tatm.domain.lev.delta[...,-1] * Pa_per_hPa / const.g
            specific_humidity_tendency = 0.*self.q
            specific_humidity_tendency[...,-1,np.newaxis] = self.LHF/const.Lhvap / air_mass_per_area
            tendencies['q'] = specific_humidity_tendency
        return tendencies
131766
def _get_stddevs(self, C, stddev_types, num_sites, mag_conversion_sigma):
        
        assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
                   for stddev_type in stddev_types)

        sigma = np.zeros(num_sites) + C['sigma'] * np.log(10)
        sigma = np.sqrt(sigma ** 2 + (C['a'] ** 2) * (mag_conversion_sigma ** 2))
        stddevs = [sigma for _ in stddev_types]

        return stddevs
198313
def entropy_calc(item, POP):
    
    try:
        result = 0
        for i in item.keys():
            likelihood = item[i] / POP[i]
            if likelihood != 0:
                result += likelihood * math.log(likelihood, 2)
        return -result
    except Exception:
        return "None"
276536
def deviation( inputValues )
      raise "'inputValues' must not be nil" if inputValues.nil?
      raise "'inputValues' must be an Array" if not inputValues.is_a?(Array)
      raise "'inputValues' must have at least two elements" if inputValues.length < 2
      value = inputValues[0].to_f - inputValues[1].to_f
      value.abs
   end
370416
def uinit(self, ushape):
        """"""

        if  self.opt['Y0'] is None:
            return np.zeros(ushape, dtype=self.dtype)
        else:
            # If initial Y is non-zero, initial U is chosen so that
            # the relevant dual optimality criterion (see (3.10) in
            # boyd-2010-distributed) is satisfied.
            Yss = np.sqrt(np.sum(self.Y**2, axis=self.S.ndim, keepdims=True))
            return (self.lmbda/self.rho)*sl.zdivide(self.Y, Yss)
832183
function calculateStatsPerFile(messages) {
    return messages.reduce((stat, message) => {
        if (message.fatal || message.severity === 2) {
            stat.errorCount++;
            if (message.fix) {
                stat.fixableErrorCount++;
            }
        } else {
            stat.warningCount++;
            if (message.fix) {
                stat.fixableWarningCount++;
            }
        }
        return stat;
    }, {
        errorCount: 0,
        warningCount: 0,
        fixableErrorCount: 0,
        fixableWarningCount: 0
    });
}
425764
def _determine_nTrackIterations(self,nTrackIterations):
        """"""
        if not nTrackIterations is None:
            self.nTrackIterations= nTrackIterations
            return None
        if numpy.fabs(self.misalignment(quantity=False)) < 1./180.*numpy.pi:
            self.nTrackIterations= 0
        elif numpy.fabs(self.misalignment(quantity=False)) >= 1./180.*numpy.pi \
                and numpy.fabs(self.misalignment(quantity=False)) < 3./180.*numpy.pi:
            self.nTrackIterations= 1
        elif numpy.fabs(self.misalignment(quantity=False)) >= 3./180.*numpy.pi:
            self.nTrackIterations= 2
        return None
391014
def fstat_sig(self):
        """"""
        return 1.0 - scs.f.cdf(self.fstat, self.df_reg, self.df_err)
1280584
def data_check(self, participant):
        """"""
        infos = participant.infos()
        return len([info for info in infos if info.chosen]) * 2 == len(infos)
93777
def systemInformationType2():
    """"""
    a = L2PseudoLength(l2pLength=0x16)
    b = TpPd(pd=0x6)
    c = MessageType(mesType=0x1a)  # 00011010
    d = NeighbourCellsDescription()
    e = NccPermitted()
    f = RachControlParameters()
    packet = a / b / c / d / e / f
    return packet
656993
def _det_inference(self):
        
        # 2 random effects with complete design -> gp2KronSum
        # TODO: add check for low-rankness, use GP3KronSumLR and GP2KronSumLR when possible
        if (self.n_randEffs==2) and (~sp.isnan(self.Y).any()):
            rv = 'GP2KronSum'
        else:
            rv = 'GP'
        return rv
891773
def effect_info(self, mechanism, purview):
        """"""
        return repertoire_distance(
            Direction.EFFECT,
            self.effect_repertoire(mechanism, purview),
            self.unconstrained_effect_repertoire(purview)
        )
800691
def common_items_ratio(pronac, dt):
    
    segment_id = get_segment_id(str(pronac))
    metrics = data.common_items_metrics.to_dict(orient='index')[segment_id]
    ratio = common_items_percentage(pronac, segment_common_items(segment_id))

    # constant that defines the threshold to verify if a project
    # is an outlier.
    k = 1.5

    threshold = metrics['mean'] - k * metrics['std']
    uncommon_items = get_uncommon_items(pronac)

    pronac_filter = data.all_items['PRONAC'] == pronac
    uncommon_items_filter = (
        data.all_items['idPlanilhaItens']
        .isin(uncommon_items)
    )
    items_filter = (pronac_filter & uncommon_items_filter)

    filtered_items = (
        data
        .all_items[items_filter]
        .drop_duplicates(subset='idPlanilhaItens')
    )
    uncommon_items = add_info_to_uncommon_items(filtered_items, uncommon_items)

    return {
        'is_outlier': ratio < threshold,
        'valor': ratio,
        'maximo_esperado': metrics['mean'],
        'desvio_padrao': metrics['std'],
        'items_incomuns': uncommon_items,
        'items_comuns_que_o_projeto_nao_possui': get_common_items_not_present(pronac),
    }
1247392
def anomalous_score(self):
        
        return self._anomalous if self._anomalous else 1. / len(self._graph.reviewers)
988924
def compute_lower_upper_errors(sample, num_sigma=1):
    
    if num_sigma > 3:
        raise ValueError("Number of sigma-constraints restircted to three. %s not valid" % num_sigma)
    num = len(sample)
    num_threshold1 = int(round((num-1)*0.833))
    num_threshold2 = int(round((num-1)*0.977249868))
    num_threshold3 = int(round((num-1)*0.998650102))

    median = np.median(sample)
    sorted_sample = np.sort(sample)
    if num_sigma > 0:
        upper_sigma1 = sorted_sample[num_threshold1-1]
        lower_sigma1 = sorted_sample[num-num_threshold1-1]
    else:
        return median, [[]]
    if num_sigma > 1:
        upper_sigma2 = sorted_sample[num_threshold2-1]
        lower_sigma2 = sorted_sample[num-num_threshold2-1]
    else:
        return median, [[median-lower_sigma1, upper_sigma1-median]]
    if num_sigma > 2:
        upper_sigma3 = sorted_sample[num_threshold3-1]
        lower_sigma3 = sorted_sample[num-num_threshold3-1]
        return median, [[median-lower_sigma1, upper_sigma1-median], [median-lower_sigma2, upper_sigma2-median],
                      [median-lower_sigma3, upper_sigma3-median]]
    else:
        return median, [[median-lower_sigma1, upper_sigma1-median], [median-lower_sigma2, upper_sigma2-median]]
212899
def _condition_number(self):
        """"""
        ev = np.linalg.eig(np.matmul(self.xwins.swapaxes(1, 2), self.xwins))[0]
        return np.sqrt(ev.max(axis=1) / ev.min(axis=1))