def create_nonimplemented_method(op_name, klass):
    """
    Creates a new method that raises NotImplementedError.
    """

    def new_method(self, *args):
        raise NotImplementedError(
            'Special method %s has not been implemented for PyMC variables.' %
            op_name)
    new_method.__name__ = '__' + op_name + '__'
    setattr(
        klass,
        new_method.__name__,
        UnboundMethodType(
            new_method,
            None,
            klass))
Creates a new method that raises NotImplementedError.