def get_matching_kwargs(func, kwargs):
    """Takes a function and keyword arguments and returns the ones that can be passed."""
    if inspect.isclass(func):
        func = func.__init__
    try:
        argspec = inspect.getargspec(func)
        if argspec.keywords is not None:
            return kwargs.copy()
        else:
            matching_kwargs = dict((k, kwargs[k]) for k in argspec.args if kwargs in k)
            return matching_kwargs
    except TypeError:
        # Class has no init function
        return {}
dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/utils/helpful_functions.py/get_matching_kwargs/swapped operands of `in`