'For Models that take optional arguments for defining their bounding
box, we create a subclass of _BoundingBox with a ``__call__`` method
that supports those additional arguments.
Takes the function\'s Signature as an argument since that is already
computed in _create_bounding_box_property, so no need to duplicate that
effort.'

def _create_bounding_box_subclass(cls, func, sig):

    def __call__(self, **kwargs):
        return func(self._model, **kwargs)
    kwargs = []
    for (idx, param) in enumerate(sig.parameters.values()):
        if (idx == 0):
            continue
        if (param.default is param.empty):
            raise ModelDefinitionError(u'The    bounding_box    method    for    {0}    is    not    correctly    defined:    If    defined    as    a    method    all    arguments    to    that    method    (besides    self)    must    be    keyword    arguments    with    default    values    that    can    be    used    to    compute    a    default    bounding    box.'.format(cls.name))
        kwargs.append((param.name, param.default))
    __call__ = make_function_with_signature(__call__, (u'self',), kwargs)
    return type(str(u'_{0}BoundingBox'.format(cls.name)), (_BoundingBox,), {u'__call__': __call__})
