pd-code-to-diagram
Convert PD codes to routed diagram matrices, render images, and parse supported diagram matrices back to PD codes.
Installation
pip install pd-code-to-diagram
Usage example
from pd_code_to_diagram import get_diagram_from_pd_code, diagram_to_png
pd = [[1, 5, 2, 4], [3, 1, 4, 6], [5, 3, 6, 2]]
diagram = get_diagram_from_pd_code(pd)
diagram_to_png(diagram, "trefoil.png", tile_size=40, show_socket_labels=True)
print(len(diagram), len(diagram[0]))
Algorithm
The bundled C++ engine builds a crossing/socket tree, incrementally places crossings, and routes arcs through a grid path engine while avoiding occupied cells and preserving crossing over/under data. Python converts the matrix to cached antialiased Pillow tiles or traces a supported matrix back into crossing records. Matrix values use 0 for empty cells, positive integers for arcs, and negative values for the two crossing orientations.
Input conventions
A PD code is represented as a list of four-entry crossings. Arc labels normally occur exactly twice. Public functions validate inputs and return new values rather than mutating caller-owned data unless their API explicitly says otherwise.
External software
- A C++17 compiler such as GCC or Clang is required on first use to build the bundled layout executable.
- No GUI is required.
- Writing PNG images requires normal filesystem access.
Development
Run examples and package checks before release. Python packages require Python 3.10 or newer. Build PyPI artifacts with:
poetry check
poetry build
License
MIT. See LICENSE.
Metadata
Release files for pd-code-to-diagram 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pd_code_to_diagram-0.1.10.tar.gz | 49.3 kB | Without provenance | Details for pd_code_to_diagram-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pd_code_to_diagram-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for pd_code_to_diagram-0.1.10-py3-none-any.whl |
Total release size: 127.2 kB
Release files / pd_code_to_diagram-0.1.10.tar.gz
| Download URL | pd_code_to_diagram-0.1.10.tar.gz |
|---|---|
| Size | 49.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1efa3387007f7238e7afebd6b1a6857603f6ddad2838e3a91524a8c9d96aaa9
|
|
BLAKE2b-256 checksum How to use checksums |
e4118dd28fb04e0428ca7ab32afc9577a70911428452fe8fe7a4128503da7f31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Release files / pd_code_to_diagram-0.1.10-py3-none-any.whl
| Download URL | pd_code_to_diagram-0.1.10-py3-none-any.whl |
|---|---|
| Size | 77.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3ffb85f8763449a49cc61777abdf740ece2ef1606b2c87c527dbb17052224a6
|
|
BLAKE2b-256 checksum How to use checksums |
bc06721bc5b5595a59b5c88e8a374b8b1ecd0241f79b1a09ffe2609cadac4304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Security for pd-code-to-diagram 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.