def test_binary():
    ops = [
        ex.Add, ex.Subtract, ex.Multiply, ex.Divide, ex.Power, ex.Maximum,
        ex.Minimum,
    ]
    confs = itertools.product(shapes, ops)
    for shape, op in confs:
        print('%s shape=%s' % (op.__name__.ljust(20), shape))
        lhs_array = np.random.normal(size=shape).astype(dp.float_)
        rhs_array = np.random.normal(size=shape).astype(dp.float_)
        if op is ex.Power:
            lhs_array = np.fabs(lhs_array)
        if op is ex.Divide:
            rhs_array[np.fabs(rhs_array) < eps] = eps
            rhs_array[np.fabs(rhs_array) < eps] = eps
        lhs_src = BPropableSource(lhs_array)
        rhs_src = BPropableSource(rhs_array)
        sink = op()(lhs_src, rhs_src)

        for src, x0 in [(lhs_src, lhs_array), (rhs_src, rhs_array)]:
            f, f_grad = graph_funs(src, sink)
            g_approx = approx_fprime(x0, f)
            g_true = f_grad(x0)
            assert gradclose(g_true, g_approx)
dataset/ETHPy150Open andersbll/deeppy/test/unit/expr/test_elementwise.py/test_binary/original