Example #1
0
    def dependents_func():
        a = zfit.pdf.Gauss(var1, var2, obs='obs1').sample(n=500,
                                                          limits=(-5, 5)) * 5.
        b = z.constant(3.) + 4 * var1
        c = 5. * b * var3
        d = b * var2 + a
        e = d * 3.
        return a, b, c, d, e

        assert get_dependents_auto(
            e, [a, b, c, d, var1, var2, var3]) == [a, b, d, var1, var2]
        assert get_dependents_auto(e, [var1, var2, var3]) == [var1, var2]
        assert get_dependents_auto(
            c, [a, b, d, var1, var2, var3]) == [b, var1, var3]
        return True
Example #2
0
 def _get_dependents(self):
     dependents = self._simple_func_dependents
     if dependents is None:
         independent_params = tf.get_collection("zfit_independent")
         dependents = get_dependents_auto(tensor=self.value(), candidates=independent_params)
         self._simple_func_dependents = dependents
     return dependents
Example #3
0
def test_get_dependents():
    var1 = zfit.Parameter('var1', 1.)
    var2 = zfit.Parameter('var2', 2.)
    var3 = zfit.Parameter('var3', 3.)
    a = zfit.pdf.Gauss(var1, var2, obs='obs1').sample(n=500,
                                                      limits=(-5, 5)) * 5.
    b = ztf.constant(3.) + 4 * var1
    c = 5. * b * var3
    d = b * var2 + a
    e = d * 3.
    zfit.run(e)
    assert get_dependents_auto(
        e, [a, b, c, d, var1, var2, var3]) == [a, b, d, var1, var2]
    assert get_dependents_auto(e, [var1, var2, var3]) == [var1, var2]
    assert get_dependents_auto(c,
                               [a, b, d, var1, var2, var3]) == [b, var1, var3]