Registry / serialization / wavedrom

wavedrom

JSON →
library2.0.3.post3pypypi✓ verified 87d ago

The `wavedrom` Python library provides a command-line utility and programmatic API for generating digital waveform diagrams from WaveJSON/WaveJSON5 input. It's compatible with the WaveDrom JavaScript library specification, allowing users to define waveform signals in a simple JSON format and render them into SVG images. The current version is 2.0.3.post3, with active maintenance and occasional releases addressing bugs and minor features.

pip install wavedrom
INSTALL
IMPORT
SIG · WAVEDROM
W
wavedrom
serializationpythonv2.0.3.post3
Install
3.6s avg
Import
—
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.0.3.post3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.7MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 3.6s · import 0.000s · 24MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WaveDrom
✓ from wavedrom import WaveDrom
✗ from wavedrom.render import render_wavedrom_svg
render
✓ from wavedrom import render
✗ from wavedrom.render import render_wavedrom_svg
render_file
✓ from wavedrom import render_file
✗ from wavedrom.render import render_wavedrom_svg

This quickstart demonstrates how to programmatically render a WaveJSON string into an SVG image using the `render_wavedrom_svg` function. The input is a multi-line string containing the WaveJSON specification.

import json from wavedrom.render import render_wavedrom_svg # Define your WaveJSON/WaveJSON5 data as a string wavejson_data = ''' { "signal": [ { "name": "clk", "wave": "p.....|..." }, { "name": "d", "wave": "x.345x|x.23" }, { "name": "q", "wave": "10101x|1010" } ], "head": { "text": "My Simple Waveform" } } ''' # Render the WaveJSON string to an SVG string svg_output = render_wavedrom_svg(wavejson_data) # You can now save the SVG string to a file or embed it # with open("waveform.svg", "w") as f: # f.write(svg_output) # print(svg_output[:200]) # Print start of SVG to confirm
wavedrom --version
Debug
Known issues
breakingThe `wavedrom` library underwent a significant rewrite with version 2.0. The primary programmatic API for rendering changed. Older examples relying on direct `wavedrom.render_svg()` or accessing internal components may no longer work.
fix
Upgrade to `wavedrom` v2.x and update import paths to `from wavedrom.render import render_wavedrom_svg` for programmatic usage.
affects: < 2.0.0
gotchaThe `render_wavedrom_svg` function expects a *string* containing valid WaveJSON or WaveJSON5 data. Passing a Python dictionary directly will result in an error, as it's not automatically serialized.
fix
If you have your WaveDrom data as a Python dictionary, serialize it to a JSON/JSON5 string first using `json.dumps()` or `json5.dumps()` before passing it to `render_wavedrom_svg`.
affects: >= 2.0.0
gotchaWhile `wavedrom` provides a Python API, its name and `setup.py` entrypoint `wavedrom-cli` suggest it's often used as a command-line tool. Ensure you understand if you need the CLI (`wavedrom-cli input.json > output.svg`) or the Python library API.
fix
For programmatic use within Python scripts, import `render_wavedrom_svg`. For quick conversions or shell scripting, use the `wavedrom-cli` executable installed to your PATH.
affects: All
Upgrade
Version history
2.0.3.post3latest on PyPI · released May 27, 2022
Audit
Dependencies
json5requiredRequired for parsing WaveJSON5 input format, which extends standard JSON.
webcolorsrequiredUsed for parsing and handling color names in WaveDrom specifications.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources