Skip to main content

Polylabel algorithm for optimal label centers in polygons (python wheels).

Project description

Test Build Benchmark PyPI version

polylabel-pyo3

polylabel-pyo3 lets you calculate the pole of inaccessibility in Python. It's a pyo3 wrapper of polylabel-rs.

Install

pip install polylabel-pyo3

Use

from polylabel_pyo3 import polylabel_ext, polylabel_ext_np

# define an open L-shape
L = [(0,0),(1,0),(1,1),(2,1),(2,2),(0,2)]

polylabel_ext(L, 1.0)
# (0.5, 0.5)

# A version for numpy.ndarray only is slightly faster
import numpy as np
polylabel_ext_np(np.array(L, dtype=np.float), 1.0)
# (0.5, 0.5)

# Note that the optional polylabel center for an L-shape
# is in between its mean of exterior vertices and origin
np.mean(L, axis=0)
# array([1., 1.])

GUI Example

pip install -r examples/requirements.txt
python examples/polylabel_gui.py

Drag your shape with the mouse and observe a momentum based center in grey and polylabel center in green:

Develop

Requirements:

  • Rust Toolchain
  • Python >=3.7

In a venv or conda env:

pip install maturin -r requirements.txt
pre-commit install

Test

maturin develop
pytest -v

Benchmark

maturin develop --release
pyest benchmark

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polylabel_pyo3-0.1.1.tar.gz (37.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

polylabel_pyo3-0.1.1-cp310-none-win_amd64.whl (123.8 kB view details)

Uploaded CPython 3.10Windows x86-64

polylabel_pyo3-0.1.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (445.6 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

polylabel_pyo3-0.1.1-cp39-none-win_amd64.whl (123.8 kB view details)

Uploaded CPython 3.9Windows x86-64

polylabel_pyo3-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (950.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (445.6 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

polylabel_pyo3-0.1.1-cp38-none-win_amd64.whl (123.9 kB view details)

Uploaded CPython 3.8Windows x86-64

polylabel_pyo3-0.1.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (445.3 kB view details)

Uploaded CPython 3.8macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

polylabel_pyo3-0.1.1-cp37-none-win_amd64.whl (123.9 kB view details)

Uploaded CPython 3.7Windows x86-64

polylabel_pyo3-0.1.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (445.3 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

File details

Details for the file polylabel_pyo3-0.1.1.tar.gz.

File metadata

  • Download URL: polylabel_pyo3-0.1.1.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.6

File hashes

Hashes for polylabel_pyo3-0.1.1.tar.gz
Algorithm Hash digest
SHA256 06cc915b364665825bf641e9de93c99cfe336bcf85b133d01da1f500dceb2d58
MD5 5667fbcac1143bb712ac965d03607bbe
BLAKE2b-256 94ecedf43ad089dc35caf2d65272e32dff8174498740dafe309e2ca05946697d

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 823f0f995e6637c9261437701d8e97f6bc3485b5a4ace37f0dd897b26b4842c1
MD5 6af4e9e98de9da0860124cec6dfefef5
BLAKE2b-256 dbc1362d5c472537d3c183a4dfa50559212951888583ea4d7ffa0c0178d72737

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 7caba01e1b042f964259c2df6b3da1565aef2c4a7e51597bae2e96d0ab2767b3
MD5 00852797d2becba1a2440c3c64c6c79f
BLAKE2b-256 79718e4cba1573d57d64e7e70190e08a8ee3fdba3d058af8da6a5e4cc8e843bc

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 8c2eab4ec06f60b76af81d8b61468034d2fbd24d23e20cf14dbe353a2c83eec7
MD5 7fd656be94e60fa77d89e192a2986fa5
BLAKE2b-256 68ef7223a689273e16e6bf9abd7c838820f8ed09c188baa84574798f47491089

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 feb37c619069de865fc4a4b0dd29bd108cb897028aeab4d484a1ee398decb1bd
MD5 369969fd8b3657c9420b1294a869df75
BLAKE2b-256 c278c4889c7c6a45d6c6e2b2436dc87e73aad69faeac271d923a0a29a893af36

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b8616d0d451d395751cc4c6bd7efc49d1e6f269c7328d6e34876f0bf9e145701
MD5 abccd7abaec2bcb84ed9a07944d1d1a8
BLAKE2b-256 3e4c4460297a09290855cfcc6a8c74b13c618615c141e465be1e480d3c96dfca

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 065ab19b50ffba2ed868a7ba3b502b8f01f19bd2ce0a36635a280b4d65b509fd
MD5 a8b9501a75db5b9e91f5ff4d6f8d42ca
BLAKE2b-256 cf8dcf0eb6897b4f341712f4c0e1ba932a4039ad74a2a666d267d1af38d8b2e9

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0cec781a0a9da0c9643773ffe15e91c0c12142da3212785bd0fbce42f82add2c
MD5 cff655f17df53e40a0e21343b82314df
BLAKE2b-256 29e093a66bab6d9ee8bdd69951337652d6f9829ce29d690d3a910b4ecf9f3ea5

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp37-none-win_amd64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 dfa4cfe5dac4f53c27ccae26fbcfecd4a72233668593094490352bfa14371b87
MD5 11488006cb6eb5b88d4a0a40875fd5cb
BLAKE2b-256 8f957cc89e5c3d66de6b0f9c639e73e0fbdcbb7df57c53c8932044a7170df6ff

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 55f00ac6ef3d8e8bece37223c4c8bce7466943a0acb17dce20bc86280ebcf530
MD5 d682e46e1e4747d2320ea186974b1550
BLAKE2b-256 7a2d9f2f939facbd9e1ad15011dfa3174c968cae21b1eb9def420cb8f31bb400

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page