Return the actual cause of a mechanism.
332114
def find_actual_cause(self, mechanism, purviews=False):
        """"""
        return self.find_causal_link(Direction.CAUSE, mechanism, purviews)
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)
747054
def order(self, mechanism, purview):
        
        if self is Direction.CAUSE:
            return purview, mechanism
        elif self is Direction.EFFECT:
            return mechanism, purview

        from . import validate
        return validate.direction(self)
412219
def effect_mip(self, mechanism, purview):
        
        return self.find_mip(Direction.EFFECT, mechanism, purview)
584924
def cause_info(self, mechanism, purview):
        """"""
        return repertoire_distance(
            Direction.CAUSE,
            self.cause_repertoire(mechanism, purview),
            self.unconstrained_cause_repertoire(purview)
        )
503176
function(rs, fs) {
        var restriction = [];

        for (var i = 0; i < rs.length; i++) {
            var rule = rs[i], matches = false;

            for (var j = 0; j < rule.causes.length; j++) {
                var cause = rule.causes[j];

                for (var k = 0; k < fs.length; k++) {
                    var fact = fs[k];

                    if (this.causeMatchesFact(cause, fact)) {
                        matches = true;
                        break;
                    }
                }

                if (matches) {
                    restriction.push(rule);
                    break;
                }
            }
        }

        return restriction;
    }
1146080
def fmt_concept(concept):
    """"""

    def fmt_cause_or_effect(x):  # pylint: disable=missing-docstring
        return box(indent(fmt_ria(x.ria, verbose=False, mip=True), amount=1))

    cause = header('MIC', fmt_cause_or_effect(concept.cause))
    effect = header('MIE', fmt_cause_or_effect(concept.effect))
    ce = side_by_side(cause, effect)

    mechanism = fmt_mechanism(concept.mechanism, concept.node_labels)
    title = 'Concept: Mechanism = {}, {} = {}'.format(
        mechanism, SMALL_PHI, fmt_number(concept.phi))

    # Only center headers for high-verbosity output
    center = config.REPR_VERBOSITY is HIGH

    return header(title, ce, HEADER_BAR_2, HEADER_BAR_2, center=center)
1098036
def get(user)
      mechanism = user.mechanism
      raise InvalidMechanism.new(mechanism) if !SOURCES.has_key?(mechanism)
      SOURCES[mechanism].new(user)
    end
1341550
def server_mechanisms(self):
        """"""
        return [mech for mech in self.mechs.values()
                if isinstance(mech, ServerMechanism)]
1369791
def cause_mip(self, mechanism, purview):
        
        return self.find_mip(Direction.CAUSE, mechanism, purview)
103711
def getMechanismName(self):
        """"""
        if self._server_side:
            mech = self._authenticator.current_mech
            return mech.getMechanismName() if mech else None
        else:
            return getattr(self._authenticator, 'authMech', None)
739787
function() {
        if (this.explicit) {
            return this.valid;
        } else if (this.causedBy === undefined || this.causedBy.length == 0) {
            return undefined;
        } else {
            var valid,
                causes = this.causedBy,
                explicitFact;
            for (var i = 0; i < causes.length; i++) {
                valid = true;
                for (var j = 0; j < causes[i].length; j++) {
                    explicitFact = causes[i][j];
                    valid = valid && explicitFact.valid;
                }
                if (valid) {
                    return true;
                }
            }
            return false;
        }
    }
481434
def cause_repertoire(self, mechanism, purview):
        """"""
        return self.repertoire(Direction.CAUSE, mechanism, purview)
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
93438
def mechanism(self, mechanism):
        
        allowed_values = ["connector", "direct"]
        if mechanism not in allowed_values:
            raise ValueError(
                "Invalid value for `mechanism` ({0}), must be one of {1}"
                .format(mechanism, allowed_values)
            )

        self._mechanism = mechanism
697249
def object(self):
        """"""
        if self.type == EntryType.category:
            return self.category
        elif self.type == EntryType.event:
            return self.event
        elif self.type == EntryType.session:
            return self.session
        elif self.type == EntryType.contribution:
            return self.contribution
        elif self.type == EntryType.subcontribution:
            return self.subcontribution
956178
def get_error_message(self):
        
        error_reason = self.get_error_reason()
        if error_reason:
            error_message = error_reason.get('pod') or None
            if error_message:
                return "Error in pod: %s" % error_message
            plugin = error_reason.get('plugin')[0] or None
            error_message = error_reason.get('plugin')[1] or None
            if error_message:
                # Plugin has non-empty error description
                return "Error in plugin %s: %s" % (plugin, error_message)
            else:
                return "Error in plugin %s" % plugin