The cause ratio of the ``purview`` given ``mechanism``.
334080
def cause_ratio(self, mechanism, purview):
        """"""
        return self._ratio(Direction.CAUSE, mechanism, purview)
866961
def ratio(self):
        """"""
        return 2.0 * self.matches() / (len(self.seq1) + len(self.seq2))
966370
def mechanism_indices(self, direction):
        """"""
        return {
            Direction.CAUSE: self.effect_indices,
            Direction.EFFECT: self.cause_indices
        }[direction]
1344957
def nice_true_ces(tc):
    """"""
    cause_list = []
    next_list = []
    cause = '<--'
    effect = '-->'
    for event in tc:
        if event.direction == Direction.CAUSE:
            cause_list.append(["{0:.4f}".format(round(event.alpha, 4)),
                               event.mechanism, cause, event.purview])
        elif event.direction == Direction.EFFECT:
            next_list.append(["{0:.4f}".format(round(event.alpha, 4)),
                              event.mechanism, effect, event.purview])
        else:
            validate.direction(event.direction)

    true_list = [(cause_list[event], next_list[event])
                 for event in range(len(cause_list))]
    return true_list
1068772
def key(self, direction, mechanism, purviews=False, _prefix=None):
        """"""
        return (_prefix, direction, mechanism, purviews)
1319910
def _ratio(self, key):
        ''''''
        total = float(self._total_votes())
        try:
            return math.floor(self[key] / total * 100)
        except ZeroDivisionError:
            return float(0)
30988
def _get_bmdl_ratio(self, models):
        """"""
        bmdls = [model.output["BMDL"] for model in models if model.output["BMDL"] > 0]

        return max(bmdls) / min(bmdls) if len(bmdls) > 0 else 0
3237
function getView(t, v) {
                    if (v !== null && v !== undefined && this.numPrecision !== -1 && zebkit.isNumber(v)) {
                        v = v.toFixed(this.numPrecision);
                    }
                    return this.$super(t, v);
                }
353956
function Ratio() {
        Channel.apply(this, arguments);
        this.dataType = NUMBER | PERCENT;
        this.cssType = NUMBER;
        this.range = [0, 1];
        this.filter = CLAMP;
        this.initial = 1;
    }
150456
def _get_mechanism(self, sites, rup, imt, C):
        
        Fn, Fr = self._get_fault_type_dummy_variables(sites, rup, imt)
        return (C['b9'] * Fn) + (C['b10'] * Fr)
1050494
def compute(mechanism, subsystem, purviews, cause_purviews,
                effect_purviews):
        
        concept = subsystem.concept(mechanism,
                                    purviews=purviews,
                                    cause_purviews=cause_purviews,
                                    effect_purviews=effect_purviews)
        # Don't serialize the subsystem.
        # This is replaced on the other side of the queue, and ensures
        # that all concepts in the CES reference the same subsystem.
        concept.subsystem = None
        return concept
760281
private void determineFramePal(int index) {
		if ((inMode != InputMode.VOBSUB && inMode != InputMode.SUPIFO)
				|| configuration.getPaletteMode() != PaletteMode.KEEP_EXISTING) {
			// get the primary color from the source palette
			int rgbSrc[] = subtitleStream.getPalette().getRGB(
					subtitleStream.getPrimaryColorIndex());

			// match with primary color from 16 color target palette
			// note: skip index 0 , primary colors at even positions
			// special treatment for index 1: white
			Palette trgPallete = currentDVDPalette;
			int minDistance = 0xffffff; // init > 0xff*0xff*3 = 0x02fa03
			int colIdx = 0;
			for (int idx = 1; idx < trgPallete.getSize(); idx += 2) {
				int rgb[] = trgPallete.getRGB(idx);
				// distance vector (skip sqrt)
				int rd = rgbSrc[0] - rgb[0];
				int gd = rgbSrc[1] - rgb[1];
				int bd = rgbSrc[2] - rgb[2];
				int distance = rd * rd + gd * gd + bd * bd;
				// new minimum distance ?
				if (distance < minDistance) {
					colIdx = idx;
					minDistance = distance;
					if (minDistance == 0) {
						break;
					}
				}
				// special treatment for index 1 (white)
				if (idx == 1) {
					idx--; // -> continue with index = 2
				}
			}

			// set new frame palette
			int palFrame[] = new int[4];
			palFrame[0] = 0; // black - transparent color
			palFrame[1] = colIdx; // primary color
			if (colIdx == 1) {
				palFrame[2] = colIdx + 2; // special handling: white + dark grey
			} else {
				palFrame[2] = colIdx + 1; // darker version of primary color
			}
			palFrame[3] = 0; // black - opaque

			subVobTrg.setAlpha(DEFAULT_ALPHA);
			subVobTrg.setPal(palFrame);

			trgPal = SupDvdUtil.decodePalette(subVobTrg, trgPallete);
		}
	}
1197845
def deriv2(self, p):
        
        from statsmodels.tools.numdiff import approx_fprime_cs
        # TODO: workaround proplem with numdiff for 1d
        return np.diag(approx_fprime_cs(p, self.deriv))
716639
def irreducible_causes(self):
        """"""
        return tuple(link for link in self
                     if link.direction is Direction.CAUSE)
1257663
def directed_account(transition, direction, mechanisms=False, purviews=False,
                     allow_neg=False):
    """"""
    if mechanisms is False:
        mechanisms = utils.powerset(transition.mechanism_indices(direction),
                                    nonempty=True)
    links = [
        transition.find_causal_link(direction, mechanism, purviews=purviews,
                                    allow_neg=allow_neg)
        for mechanism in mechanisms]

    # Filter out causal links with zero alpha
    return DirectedAccount(filter(None, links))
478435
def expand_cause_repertoire(self, repertoire, new_purview=None):
        
        return self.expand_repertoire(Direction.CAUSE, repertoire,
                                      new_purview)
637463
def feasible_ratio(self, solutions):
        
        raise NotImplementedError('Solution class disappeared')
        count = np.zeros(len(solutions[0]))
        for x in solutions:
            count += x.unrepaired == x
        return count / float(len(solutions))