Add rule to :attr:`R` with initial weight.

        :param rule: rule to be added
        :type rule: `~creamas.core.rule.Rule`
        :param float weight: initial weight for the rule
        :raises TypeError: if rule is not subclass of :py:class:`Rule`
        :returns: ``True`` if rule was successfully added, otherwise ``False``.
        :rtype bool:

def add_rule(self, rule, weight):
        """Add rule to :attr:`R` with initial weight.

        :param rule: rule to be added
        :type rule: `~creamas.core.rule.Rule`
        :param float weight: initial weight for the rule
        :raises TypeError: if rule is not subclass of :py:class:`Rule`
        :returns: ``True`` if rule was successfully added, otherwise ``False``.
        :rtype bool:
        """
        if not issubclass(rule.__class__, (Rule, RuleLeaf)):
            raise TypeError(
                "Rule to add ({}) must be derived from {} or {}."
                .format(rule.__class__, Rule, RuleLeaf))
        if rule not in self._R:
            self._R.append(rule)
            self._W.append(weight)
            return True
        return False