def test_Plotter_with_styles(): p = Plotter() p2 = p.with_styles() assert p is not p2 assert p.default_theme is not p2.default_theme p3 = p.with_styles(show_steps=True) assert p3.default_theme.show_steps assert not p.default_theme.show_steps
def test_plotter_customizations(pipeline, monkeypatch): ## default URL # url = Theme.kw_legend["URL"] dot = str(pipeline.plot()) assert url in dot, dot ## New active_plotter # with active_plotter_plugged(Plotter(theme=Theme(kw_legend={"URL": None}))): dot = str(pipeline.plot()) assert "legend" not in dot, dot assert url not in dot, dot ## URL --> plotter in args # url1 = "http://example.1.org" dot = str( pipeline.plot(plotter=Plotter(theme=Theme( kw_legend={"URL": url1})))) assert url1 in dot, dot assert url not in dot, dot dot = str(pipeline.plot()) assert url in dot, dot url2 = "http://example.2.org" with active_plotter_plugged(Plotter(theme=Theme(kw_legend={"URL": url2}))): dot = str(pipeline.plot()) assert url2 in dot, dot assert url not in dot, dot dot = str(pipeline.plot()) assert url in dot, dot assert url1 not in dot, dot ## URL --> plotter in args # dot = str( pipeline.plot(plotter=Plotter(theme=Theme(kw_legend={"URL": None})))) assert "legend" not in dot, dot dot = str( pipeline.plot(plotter=Plotter(theme=Theme(kw_legend={"URL": url2})))) assert url2 in dot, dot assert url not in dot, dot
def test_plotter_dill(): plotter = Plotter() dill.dumps(plotter)
def test_plotter_pickle(): plotter = Plotter() pickle.dumps(plotter)
raise AssertionError("Failed pydot formats: %s" % "".join(sorted(dupe_errs))) def _check_common_end(s1, s2, clip_index): __tracebackhide__ = True # pylint: disable=unused-variable s1, s2 = s1[clip_index:], s2[clip_index:] ## Locate the index where they start to differ. # for i, (c1, c2) in enumerate(zip(reversed(s1), reversed(s2))): if c1 != c2: s1, s2 = s1[-i - 16:], s2[-i - 16:] assert s1 == s2 @active_plotter_plugged(Plotter(show_steps=True)) def test_plotters_hierarchy(pipeline: Pipeline, inputs, outputs): # Plotting original network, no plan. base_dot = str(pipeline.plot(inputs=inputs, outputs=outputs)) assert base_dot assert f"digraph {pipeline.name} {{" in str(base_dot) # graph-name assert f"label=<{pipeline.name}>;" in str(base_dot) # graph-label # Just smoke-test plotting of operations str(pipeline.ops[0].plot()) sol = pipeline.compute(inputs, outputs) # Plotting of pipeline must remains the same. pipeline_dot = str(pipeline.plot(inputs=inputs, outputs=outputs)) assert pipeline_dot == base_dot