Beispiel #1
0
 def get_args(self):
     """
     :param to_root: If True, find all args of this experiment down to the root experiment.
         If False, just return the args that differentiate this variant from its parent.
     :return: A dictionary of arguments to the experiment
     """
     return infer_derived_arg_values(self.function)
Beispiel #2
0
def test_get_derived_function_args():
    def f(a, b=1):
        return a + b

    g = partial(f, a=2)
    h = partial(g, b=3)
    j = partial(h, c=4)

    with raises(
            AssertionError
    ):  # AssertionError: Arguments ('a',) require values but are not given any.
        infer_derived_arg_values(f)
    assert list(infer_derived_arg_values(g).items()) == [('a', 2), ('b', 1)]
    assert list(infer_derived_arg_values(h).items()) == [('a', 2), ('b', 3)]
    with raises(AssertionError):
        infer_derived_arg_values(j)

    assert f(**infer_derived_arg_values(g)) == g()
    assert f(**infer_derived_arg_values(h)) == h()
Beispiel #3
0
 def get_args(self):
     """
     :return: An OrderedDict of arguments to the experiment
     """
     return infer_derived_arg_values(self.function)