Exemplo n.º 1
0
def test_basic_report():
    r = Report()

    r.widget(None)
    with pytest.raises(pydantic.error_wrappers.ValidationError):
        r.header(None)
    r.header("Some header")
    r.header("Some header", description="Some description")
    with pytest.raises(pydantic.error_wrappers.ValidationError):
        r.text(None)
    r.text("Some text")
    r.text("Some header", description="Some description")

    assert len(r.elements) == 5
    config = r.get_configuration()
    assert isinstance(config, ReportConfiguration)
    assert len(config.elements) == 5
Exemplo n.º 2
0
from vizno.renderers.code import CodeContent
from vizno.renderers.latex import LatexContent
from vizno.renderers.mathjax import MathJaxContent
from vizno.report import Report

xs = [random.random() for _ in range(100)]
ys = [x + random.random() * 0.1 for x in xs]

r = Report(
    title="The demo report",
    description="This demo report showcases the capabilities of vizno.",
)

r.header(
    "Python plotting libraries",
    description="""
`vizno` supports all the common Python plotting libraries.
""",
)

f = plt.figure()
ax = f.add_subplot(111)
ax.plot(xs, ys, ".")
ax.set_xlabel("Label")

r.widget(
    f,
    name="Matplotlib",
    description="A [matplotlib](https://matplotlib.org/) figure",
    layout={"width": 6},
)