def a(): return 5 def b(a): return a * 5 def c(a, b): return a * b composer = Composer().update(a, b, c) # Call any result composer.c() # 125 composer.a() # 5 composer.graphviz().render("intro.gv", format="png") # Some pure functions def get_car_prices(): df = pd.DataFrame( dict( model=[ choice(["corolla", "beetle", "ferrari"]) for _ in range(10) ], price=[random() * 100_000 + 50000 for _ in range(10)], )) return df
def test_basic_links(): composer = Composer().update(a=lambda: 5, c=lambda b: b * 2).link(b="a") assert composer.c() == 10
def test_default_arguments(): composer = Composer().update(c=lambda a, b=3: a + b).update_parameters(a=1) assert composer.c() == 4 composer = Composer().update(c=lambda a, b=3: a + b).update_parameters(a=1, b=2) assert composer.c() == 3