Skip to main content

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)

Source distribution for pd-code-to-diagram 0.1.10
File Size Uploaded
pd_code_to_diagram-0.1.10.tar.gz 49.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pd-code-to-diagram 0.1.10
File Interpreter ABI Platform
pd_code_to_diagram-0.1.10-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page