Skip to main content

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

Project description

Test Build Benchmark

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.6

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.0.tar.gz (37.4 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.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl (965.4 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.0-cp310-none-win_amd64.whl (129.8 kB view details)

Uploaded CPython 3.10Windows x86-64

polylabel_pyo3-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (965.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (450.9 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.0-cp39-none-win_amd64.whl (129.8 kB view details)

Uploaded CPython 3.9Windows x86-64

polylabel_pyo3-0.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (965.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (450.9 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.0-cp38-none-win_amd64.whl (129.9 kB view details)

Uploaded CPython 3.8Windows x86-64

polylabel_pyo3-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (965.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (451.0 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.0-cp37-none-win_amd64.whl (129.8 kB view details)

Uploaded CPython 3.7Windows x86-64

polylabel_pyo3-0.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (964.8 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (450.5 kB view details)

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

polylabel_pyo3-0.1.0-cp36-none-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.6Windows x86-64

polylabel_pyo3-0.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (964.7 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

polylabel_pyo3-0.1.0-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (449.4 kB view details)

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

File details

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

File metadata

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

File hashes

Hashes for polylabel_pyo3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb1841dab62d76413463fbd7669ab3e4b0cc815981e28d061327cacd2f9ea4ee
MD5 2ae29cc62f00d6670b98fcece9bd735b
BLAKE2b-256 0b2554db22ea35a1b0074edf00f3ae6f0ba88293194788d9f9a0bef21d103fd9

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4d897b90ea9d843c6c61a98ef7d8bc2f6d7d0066462e8550679cba5326a057f1
MD5 b08bea5857f925d917cf015d2c1ee47b
BLAKE2b-256 d18f8473ee72ddb5f96b6d59167df0f9456ad375c58514cef143f408c9fc42f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 a7f6532a241714a98ef7981c0d4b9758835fc9877c60574033c984f047aa514a
MD5 83b366e7435edc1bc06df2348755dea5
BLAKE2b-256 ec971bf4f88b44a0e6f975e237ec7de4ffd1327db08183e3d69dc4fa9cd3d099

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 10d4720784382ca21214eb23cd3a5a811881ff39350a25739dd380a003286d54
MD5 5358bb0e1b3e177dc7d4a9e74a7a0b13
BLAKE2b-256 374730ecca47546e00586d63a6bb75bbc962110fb0d61c941683f951094fb8ff

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-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.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 63a09f67e64098c8fbb1a4a10221bf9534622fcdeda9d1da5d16773bb9a65f03
MD5 03b1cccaacb3ff880934eaea16b70891
BLAKE2b-256 fd171e479f806e1c6334af7d28ff7b286adf9d7da6ee4a02d64c754500cb6112

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 10a548fdb8f8abc90c1143433521ae33c429ecd9e773cacc3f360bae7bb3e828
MD5 830b50aa69d9e0b9f36e35d792d9311b
BLAKE2b-256 5e412c44773d87adaa63271ee9d44c4041739fa5a09847fd0de9b9fa314fc409

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cb18873be89f43a384f8d8c72af02ffa744fa00dd1c86987300c39e3a53643f8
MD5 0282698c8b39c00f7a474566ef7d9aa4
BLAKE2b-256 a04370b2eb6fb2402b529429532b33b34f1bedad09b0730ebe47b94a31a37355

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-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.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 da19100d66ba5286051d47100099f13275254f5ce1da3e641652902eda717652
MD5 3a50ec58d50b8b87ee8bc9cdfffc30f4
BLAKE2b-256 47d0022dcb61e5e766e808580d000ebb47168b937869585e2c876c46095fa3e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 515950d4ce7105d65f30de8c2bd6a82029812a6fcc3f4954f1ad0e087be8c459
MD5 dcfcd9577b51bd9e78ad4eee5fda5929
BLAKE2b-256 da77b97e732d51feeb364e761b0618a3adaca485acd64cbc64f70c55a876945f

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 81c5a3a1fdb46b77961f95d0146a793abdd1f3f403b3eebbb30306931edba526
MD5 0b1e7417aec6693b2eede569a7fee6ce
BLAKE2b-256 78ea7be518be544d931ce82a8e4cae62d07049ae6455f91a8932e0ab799050b7

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-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.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d9182e85359dc73bcbaeea6f42cdb066cf3bbff1fe49f1466e88d7dfad086558
MD5 eb89240318e2083ec132b6646b678838
BLAKE2b-256 bd40a29ed8a3e07e944f1bf40e34028d34ff77b652005450f096d1b2133c5f81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 781560d3e7255c771f6675428c6b5c1a553ac639171966f14b1f4dfa64eb9f2a
MD5 db7eeb0e90289fd156ee09fb13e5ca89
BLAKE2b-256 4c226982142ea5cd4dab6a55f8cc6e7153c0e1ca447c29122d0db6fdca349c40

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b154ba303baaa5fbdef6e0c657317d81ff1d7eb343711e91f258adfe441a3069
MD5 0b8d8eca9458f6d16c8003eb543ff2ed
BLAKE2b-256 d46feea4eec8e603fecd80d4c133e3e0d233259fcf84e01b7b29c3c1500bde14

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-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.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1fb0b5be768264795fdc1ec49c0cdeec824aaa61ef16ccd791bdb370077accfb
MD5 846d820cf60a750f97a02209e74c6eb6
BLAKE2b-256 4ff9276a9677782099da3b105c80c5c87d600eccfceba39daa2c6fb6d5434394

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-cp36-none-win_amd64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 b5e332445f2ae18c75aa77fc09b717c58fe14488f25740f95e1ad28f46ad95d7
MD5 66a5fd3ebc36c1654f6774afbad42c89
BLAKE2b-256 517fc21376387fa3e5ed654889747798493b85a9f88d0a35aacf79b051672333

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a118bb0ce7ba4ae7715ba133d7482076f2e82c78d6d404a33eb6d73bcc6c6261
MD5 6cb4adf642f2d5aa9e1285295346ade5
BLAKE2b-256 e3ed65fa3cdf5a1d1b81401cc157b572aafe154ecf39c4259c0b6f5223a8a173

See more details on using hashes here.

File details

Details for the file polylabel_pyo3-0.1.0-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for polylabel_pyo3-0.1.0-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 47547a63e76d72dc929d8019e69e9ad843e6b99f9aa72c66e32337069df5c231
MD5 ef59b9ab864d39b99587dcdca30a7cb5
BLAKE2b-256 a7e1372623d62290bf11b32b642d41fedd4b32dd776e58e8848fb1055f6a102d

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