Skip to main content

Tools for 2D open and closed paths

Project description


CircleCI codecov Code style: black PyPi Version Debian CI GitHub stars PyPi downloads

Lightweight package for working with 2D paths/polygons.

import pypathlib

# Create path
path = pypathlib.ClosedPath([[0, 0], [0, 1], [1, 1], [1, 0]])

# Get the squared distance of some points to the path
path.squared_distance([[0.5, 0.5], [0.1, 2.4]])

# Get the _signed_ squared distance of some points to the path
# (negative if inside the path)
path.signed_squared_distance([[0.5, 0.5], [0.1, 2.4]])

# Check if the path contains the points
# (with a tolerance; set negative if you want to exclude the boundary)
path.contains_points([[0.5, 0.5], [0.1, 2.4]], tol=1.0e-12)

pypathlib is fully vectorized, so it's pretty fast. (Not quite as fast as mathplotlib.path.contains_points though.)

Relevant publications


pypathlib is available from the Python Package Index, so simply type

pip install -U pypathlib --user

to install or upgrade.


To run the pypathlib unit tests, check out this repository and type



To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    make publish


pypathlib is published under the MIT license.

Project details

Download files

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

Files for pypathlib, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size pypathlib-0.1.3-py3-none-any.whl (6.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pypathlib-0.1.3.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page