Skip to content

visualize

from cascaqit import visualize

visualize

visualize(
    source: object,
    *,
    program: ProgramContextSource | None = None,
    profile: ProfileSelection = "auto",
    output: OutputPath | None = None,
    title: str | None = None,
    language: Literal["en", "zh"] = "en",
) -> ExperimentReport

Build a standard report from existing results and return ExperimentReport. Source determines available content: single ResultIR, scan or batch results, variational results, problem results, layer experiments, gradients, sampled objectives, and VQE stability or sampling benchmarks have supported paths. This reads saved results without rerunning an experiment or optimization.

profile="auto" chooses the report type. Explicit digital, analog, hybrid, sweep, comparison, batch, algorithm or problem profiles must match the source. Program context is supported only for a single ResultIR and can supply its design information; one program context cannot be attached to a whole comparison.

Comparisons accept a {label: result} mapping containing at least two results, all ResultIR or all ProblemExecutionResult. Further checks determine comparability, such as problem identity and logical order. Merely putting two results into a dictionary does not establish a valid comparison. Title overrides the report title and must be a nonempty string when supplied.

from cascaqit import Circuit, visualize

circuit = Circuit(1).h(0).measure_all()
result = circuit.run(shots=16, seed=7)
report = visualize(result, program=circuit)
assert report.profile == "digital"
html = report.to_html(language="zh")
assert 'id="report-language"' in html

Supplying output immediately saves HTML. Use a string or PathLike ending in .html; its parent directory must already exist and an existing file is overwritten. Language accepts en or zh, defaults to en, and selects the initial language for that save. The report object does not retain a language preference: pass language="zh" again to later report.to_html() or report.save() calls.

Unsupported source types raise TypeError. Invalid language, profile, title or output paths generally raise ValueError; file writes can also raise system errors. Report HTML switches prose and chart labels together while preserving API identifiers, raw diagnostics and JSON values. See Standard experiment reports.