pax_global_header00006660000000000000000000000064135667542070014531gustar00rootroot0000000000000052 comment=dc22c382c0483d2a56370a966baa5046438c6b18 pypathlib-0.1.3/000077500000000000000000000000001356675420700135265ustar00rootroot00000000000000pypathlib-0.1.3/.circleci/000077500000000000000000000000001356675420700153615ustar00rootroot00000000000000pypathlib-0.1.3/.circleci/config.yml000066400000000000000000000014001356675420700173440ustar00rootroot00000000000000version: 2 jobs: lint: docker: - image: circleci/python:3 steps: - checkout - run: pip3 install -U black flake8 --user - run: black --check . - run: flake8 . build: working_directory: ~/work docker: - image: circleci/python:3 steps: - run: pip3 install pytest pytest-cov --user - checkout - run: pip install .[all] --user - run: pip install -r test_requirements.txt --user # The tests - run: command: pytest --cov pypathlib working_directory: test/ env: MPLBACKEND: Agg # submit to codecov - run: bash <(curl -s https://codecov.io/bash) workflows: version: 2 lint_and_build: jobs: - lint - build pypathlib-0.1.3/.flake8000066400000000000000000000001531356675420700147000ustar00rootroot00000000000000[flake8] ignore = E203, E266, E501, W503 max-line-length = 80 max-complexity = 18 select = B,C,E,F,W,T4,B9 pypathlib-0.1.3/.github/000077500000000000000000000000001356675420700150665ustar00rootroot00000000000000pypathlib-0.1.3/.github/workflows/000077500000000000000000000000001356675420700171235ustar00rootroot00000000000000pypathlib-0.1.3/.github/workflows/ci.yml000066400000000000000000000016361356675420700202470ustar00rootroot00000000000000name: ci on: [push] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/setup-python@v1 with: python-version: "3.x" - uses: actions/checkout@v1 - name: Lint with flake8 run: | pip install --upgrade pip pip install flake8 flake8 . - name: Lint with black run: | pip install black black --check . build: runs-on: ubuntu-latest steps: - uses: actions/setup-python@v1 with: python-version: "3.x" - uses: actions/checkout@v1 with: lfs: true - name: Install package run: | pip install --upgrade pip pip install .[all] pip install -r test_requirements.txt - name: Test with pytest run: | pip install pytest pytest-cov pytest --cov pypathlib # - name: Submit to codecov # run: bash <(curl -s https://codecov.io/bash) pypathlib-0.1.3/.gitignore000066400000000000000000000001411356675420700155120ustar00rootroot00000000000000*.pyc *.swp *.prof MANIFEST README.rst dist/ build/ .coverage .cache/ *.egg-info/ .pytest_cache/ pypathlib-0.1.3/LICENSE.txt000066400000000000000000000020761356675420700153560ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2018-2019 Nico Schlömer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pypathlib-0.1.3/Makefile000066400000000000000000000016511356675420700151710ustar00rootroot00000000000000VERSION=$(shell python3 -c "import pypathlib; print(pypathlib.__version__)") default: @echo "\"make publish\"?" # https://packaging.python.org/distributing/#id72 upload: setup.py # Make sure we're on the master branch @if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi rm -f dist/* python3 setup.py sdist python3 setup.py bdist_wheel twine upload dist/* tag: @if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi @echo "Tagging v$(VERSION)..." git tag v$(VERSION) git push --tags curl -H "Authorization: token `cat $(HOME)/.github-access-token`" -d '{"tag_name": "$(VERSION)"}' https://api.github.com/repos/nschloe/pypathlib/releases publish: tag upload clean: @find . | grep -E "(__pycache__|\.pyc|\.pyo$\)" | xargs rm -rf @rm -rf *.egg-info/ build/ dist/ MANIFEST .pytest_cache/ format: isort -rc . black . black: black . lint: black --check . flake8 . pypathlib-0.1.3/README.md000066400000000000000000000047721356675420700150170ustar00rootroot00000000000000# pypathlib [![CircleCI](https://img.shields.io/circleci/project/github/nschloe/pypathlib/master.svg?style=flat-square)](https://circleci.com/gh/nschloe/pypathlib/tree/master) [![codecov](https://img.shields.io/codecov/c/github/nschloe/pypathlib.svg?style=flat-square)](https://codecov.io/gh/nschloe/pypathlib) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black) [![PyPi Version](https://img.shields.io/pypi/v/pypathlib.svg?style=flat-square)](https://pypi.org/project/pypathlib) [![Debian CI](https://badges.debian.net/badges/debian/testing/python3-pypathlib/version.svg?style=flat-square)](https://tracker.debian.org/pkg/python-pypathlib) [![GitHub stars](https://img.shields.io/github/stars/nschloe/pypathlib.svg?style=flat-square&logo=github&label=Stars&logoColor=white)](https://github.com/nschloe/pypathlib) [![PyPi downloads](https://img.shields.io/pypi/dm/pypathlib.svg?style=flat-square)](https://pypistats.org/packages/pypathlib) Lightweight package for working with 2D paths/polygons. ```python 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`](https://matplotlib.org/api/path_api.html#matplotlib.path.Path.contains_points) though.) ### Relevant publications * [S.W. Sloan, _A point-in-polygon program_. Adv. Eng. Software, Vol 7, No. 1, pp. 45-47, 1985, 10.1016/0141-1195(85)90094-4](https://doi.org/10.1016/0141-1195(85)90094-4). ### Installation pypathlib is [available from the Python Package Index](https://pypi.org/project/pypathlib/), so simply type ``` pip install -U pypathlib --user ``` to install or upgrade. ### Testing To run the pypathlib unit tests, check out this repository and type ``` pytest ``` ### Distribution To create a new release 1. bump the `__version__` number, 2. publish to PyPi and GitHub: ``` make publish ``` ### License pypathlib is published under the [MIT license](https://en.wikipedia.org/wiki/MIT_License). pypathlib-0.1.3/codecov.yml000066400000000000000000000001631356675420700156730ustar00rootroot00000000000000comment: no codecov: disable_default_path_fixes: true fixes: - ".*/dist-packages/::" - ".*/site-packages/::" pypathlib-0.1.3/pypathlib/000077500000000000000000000000001356675420700155225ustar00rootroot00000000000000pypathlib-0.1.3/pypathlib/__about__.py000066400000000000000000000004221356675420700200000ustar00rootroot00000000000000__author__ = "Nico Schlömer" __email__ = "nico.schloemer@gmail.com" __copyright__ = "Copyright (c) 2018-2019, {} <{}>".format(__author__, __email__) __license__ = "License :: OSI Approved :: MIT License" __version__ = "0.1.3" __status__ = "Development Status :: 3 - Alpha" pypathlib-0.1.3/pypathlib/__init__.py000066400000000000000000000004261356675420700176350ustar00rootroot00000000000000from .__about__ import __author__, __email__, __license__, __status__, __version__ from .closed_path import ClosedPath from .path import Path __all__ = [ "__author__", "__email__", "__license__", "__version__", "__status__", "ClosedPath", "Path", ] pypathlib-0.1.3/pypathlib/closed_path.py000066400000000000000000000055501356675420700203660ustar00rootroot00000000000000import numpy from .helpers import shoelace from .path import Path class ClosedPath(Path): def __init__(self, points): closed_points = numpy.concatenate([points, [points[0]]]) super(ClosedPath, self).__init__(closed_points) assert self.points.shape[0] > 2 assert self.points.shape[1] == 2 self.area = 0.5 * shoelace(self.points) self.positive_orientation = self.area >= 0 if self.area < 0: self.area = -self.area self._is_convex_node = None return def signed_squared_distance(self, x): """Negative inside the polgon. """ x = numpy.array(x) assert x.shape[1] == 2 t, dist2, idx = self._all_distances(x) contains_points = self._contains_points(t, x, idx) dist2[contains_points] *= -1 return dist2 def signed_distance(self, x): """Negative inside the polgon. """ x = numpy.array(x) assert x.shape[1] == 2 t, dist2, idx = self._all_distances(x) dist = numpy.sqrt(dist2) contains_points = self._contains_points(t, x, idx) dist[contains_points] *= -1 return dist def _contains_points(self, t, x, idx): r = numpy.arange(idx.shape[0]) contains_points = numpy.zeros(x.shape[0], dtype=bool) pts0 = self.points pts1 = numpy.roll(self.points, -1, axis=0) # If the point is closest to a polygon edge, check which which side of the edge # it is on. is_closest_to_side = (0.0 < t[r, idx]) & (t[r, idx] < 1.0) tri = numpy.array( [ x[is_closest_to_side], pts0[idx[is_closest_to_side]], pts1[idx[is_closest_to_side]], ] ) contains_points[is_closest_to_side] = ( shoelace(tri) > 0.0 ) == self.positive_orientation # If the point is closest to a polygon node, check if the node is convex or # concave. is_closest_to_pt0 = t[r, idx] <= 0.0 contains_points[is_closest_to_pt0] = ~self.is_convex_node[ idx[is_closest_to_pt0] ] is_closest_to_pt1 = 1.0 <= t[r, idx] n = self.points.shape[0] - 1 contains_points[is_closest_to_pt1] = ~self.is_convex_node[ (idx[is_closest_to_pt1] + 1) % n ] return contains_points def contains_points(self, x, tol=1.0e-15): return self.signed_distance(x) < tol @property def is_convex_node(self): points = self.points[:-1] if self._is_convex_node is None: tri = numpy.array( [numpy.roll(points, +1, axis=0), points, numpy.roll(points, -1, axis=0)] ) self._is_convex_node = numpy.equal( shoelace(tri) >= 0, self.positive_orientation ) return self._is_convex_node pypathlib-0.1.3/pypathlib/helpers.py000066400000000000000000000002601356675420700175340ustar00rootroot00000000000000import numpy def shoelace(x): previous = numpy.roll(x, 1, axis=0) return numpy.sum( x[..., 1] * previous[..., 0] - x[..., 0] * previous[..., 1], axis=0 ) pypathlib-0.1.3/pypathlib/path.py000066400000000000000000000101161356675420700170270ustar00rootroot00000000000000import numpy class Path(object): def __init__(self, points): self.points = numpy.asarray(points) assert self.points.shape[1] == 2 self.edges = self.points[1:] - self.points[:-1] self.e_dot_e = numpy.einsum("ij,ij->i", self.edges, self.edges) assert numpy.all( self.e_dot_e > 1.0e-12 ), "Edges of 0 length are not permitted (edge lengths: {})".format( numpy.sqrt(self.e_dot_e) ) def _all_distances(self, x): x = numpy.asarray(x) assert x.shape[1] == 2 # Find closest point for each side segment # diff = x[:, None, :] - self.points[None, :, :] diff_dot_edge = numpy.einsum("ijk,jk->ij", diff[:, :-1], self.edges) t = diff_dot_edge / self.e_dot_e # The squared distance from the point x to the line defined by the points x0, x1 # is # # ( - **2) / # dist2_points = numpy.einsum("ijk,ijk->ij", diff, diff) dist2_sides = ( self.e_dot_e * dist2_points[:, :-1] - diff_dot_edge ** 2 ) / self.e_dot_e # Wipe out small negative values dist2_sides = numpy.maximum(dist2_sides, numpy.zeros(dist2_sides.shape)) # The numerator can be written as # # ( - **2) # = 1/2 * sum ((x1-x0) (x-x0).T - (x-x0) (x1-x0).T)**2, # # (Lagrange' identity, ) # which is numerically guaranteed to be positive. # # # a = numpy.einsum("jk,ijl->ijkl", self.edges, diff) # b = a - numpy.moveaxis(a, 2, 3) # dist2_sides2 = 0.5 * numpy.einsum("ijkl,ijkl->ij", b, b) # Get the squared distance to the polygon. By default equals the distance to the # line, unless t < 0 (then the squared distance to x0), unless t > 1 (then the # squared distance to x1). t0 = t < 0.0 t1 = t > 1.0 t[t0] = 0.0 t[t1] = 1.0 dist2_sides[t0] = dist2_points[:, :-1][t0] dist2_sides[t1] = dist2_points[:, 1:][t1] if dist2_sides.shape[1] > 0: idx = numpy.argmin(dist2_sides, axis=1) dist2_sides = dist2_sides[numpy.arange(idx.shape[0]), idx] else: idx = numpy.zeros(dist2_points.shape[0], dtype=int) dist2_sides = dist2_points[:, 0] return t, dist2_sides, idx @property def diameter(self): # compute distance from all points to each other diff = self.points[:, None] - self.points[None, :] dist2 = numpy.einsum("ijk,ijk->ij", diff, diff) return numpy.sqrt(numpy.max(dist2)) def squared_distance(self, x): """Get the squared distance of all points x to the polygon `poly`. """ x = numpy.asarray(x) assert x.shape[1] == 2 _, dist2_sides, _ = self._all_distances(x) return dist2_sides def distance(self, x): """Get the distance of all points x to the polygon `poly`. """ return numpy.sqrt(self.squared_distance(x)) def closest_points(self, x): """Get the closest points on the polygon. """ x = numpy.asarray(x) assert x.shape[1] == 2 t, _, idx = self._all_distances(x) pts0 = self.points[idx] pts1 = numpy.roll(self.points, -1, axis=0)[idx] r = numpy.arange(t.shape[0]) t0 = t[r, idx] closest_points = (pts0.T * (1 - t0)).T + (pts1.T * t0).T return closest_points def plot(self, color="#1f77b4"): import matplotlib.pyplot as plt x = numpy.concatenate([self.points[:, 0], [self.points[0, 0]]]) y = numpy.concatenate([self.points[:, 1], [self.points[0, 1]]]) plt.plot(x, y, "-", color=color) plt.axis("square") def show(self, *args, **kwargs): import matplotlib.pyplot as plt self.plot(*args, **kwargs) plt.show() pypathlib-0.1.3/setup.py000066400000000000000000000020211356675420700152330ustar00rootroot00000000000000import os from setuptools import find_packages, setup base_dir = os.path.abspath(os.path.dirname(__file__)) about = {} with open(os.path.join(base_dir, "pypathlib", "__about__.py"), "rb") as f: exec(f.read(), about) setup( name="pypathlib", version=about["__version__"], packages=find_packages(), url="https://github.com/nschloe/pypathlib", author=about["__author__"], author_email=about["__email__"], install_requires=["numpy"], extras_require={"all": ["matplotlib"], "plot": ["matplotlib"]}, description="Tools for 2D open and closed paths", long_description=open("README.md").read(), long_description_content_type="text/markdown", license=about["__license__"], classifiers=[ about["__license__"], about["__status__"], "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Mathematics", ], ) pypathlib-0.1.3/test/000077500000000000000000000000001356675420700145055ustar00rootroot00000000000000pypathlib-0.1.3/test/test_closed_path.py000066400000000000000000000112121356675420700204000ustar00rootroot00000000000000import numpy import pypathlib def test_show(): path = pypathlib.ClosedPath([[0.0, 0.0], [1.0, 0.0], [1.1, 1.1], [0.1, 1.0]]) path.show() return def test_convex(): path = pypathlib.ClosedPath([[0.0, 0.0], [1.0, 0.0], [1.1, 1.1], [0.1, 1.0]]) ref = 1.045 assert abs(path.area - ref) < 1.0e-12 * ref assert path.positive_orientation assert all(path.is_convex_node) return def test_orientation(): path = pypathlib.ClosedPath([[0.1, 1.0], [1.1, 1.1], [1.0, 0.0], [0.0, 0.0]]) ref = 1.045 assert abs(path.area - ref) < 1.0e-12 * ref assert not path.positive_orientation assert all(path.is_convex_node) return def test_concave(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.1, 1.1], [0.1, 1.0]] ) ref = 0.965 assert abs(path.area - ref) < 1.0e-12 * ref assert path.positive_orientation assert numpy.array_equal(path.is_convex_node, [True, True, False, True, True]) return def test_concave_counterclock(): path = pypathlib.ClosedPath( [[0.1, 1.0], [1.1, 1.1], [0.9, 0.5], [1.0, 0.0], [0.0, 0.0]] ) ref = 0.965 assert abs(path.area - ref) < 1.0e-12 * ref assert not path.positive_orientation assert numpy.array_equal(path.is_convex_node, [True, True, False, True, True]) return def test_squared_distance(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]] ) dist = path.squared_distance( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) ref = numpy.array([0.01, 0.16, 1.0 / 104.0, 0.01, 0.02, 0.0]) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return def test_distance(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]] ) dist = path.distance( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) ref = numpy.array([0.1, 0.4, numpy.sqrt(1.0 / 104.0), 0.1, numpy.sqrt(2) / 10, 0.0]) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return def test_signed_distance(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]] ) dist = path.signed_distance( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) print(dist) ref = numpy.array( [-0.1, -0.4, numpy.sqrt(1.0 / 104.0), 0.1, numpy.sqrt(2) / 10, 0.0] ) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return def test_inside(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]] ) contains_points = path.contains_points( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) assert numpy.array_equal(contains_points, [True, True, False, False, False, True]) return def test_closest_points(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]] ) closest_points = path.closest_points( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) ref = numpy.array( [ [0.2, 0.0], [0.9, 0.5], [9.0384615384615385e-01, 5.1923076923076927e-01], [0.0, 1.0], [0.0, 1.0], [1.0, 1.0], ] ) assert numpy.all(numpy.abs(closest_points - ref) < 1.0e-12) return def test_signed_squared_distance(): path = pypathlib.ClosedPath( [[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]] ) dist = path.signed_squared_distance( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) ref = numpy.array([-0.01, -0.16, 1.0 / 104.0, 0.01, 0.02, 0.0]) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return def test_sharp_angle(): path = pypathlib.ClosedPath( [ [0.0, 0.0], [1.0, 0.0], [1.0, 0.45], [0.6, 0.5], [1.0, 0.55], [1.0, 1.0], [0.0, 1.0], ] ) contains_points = path.contains_points([[0.5, 0.4], [0.5, 0.6]]) assert numpy.all(contains_points) dist = path.signed_squared_distance([[0.5, 0.4], [0.5, 0.6]]) ref = numpy.array([-0.02, -0.02]) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return # def test_two_points(): # path = pypathlib.ClosedPath([[-0.5, 1.0], [+0.5, 1.0]]) # contains_points = path.contains_points([[0.0, 0.0], [0.0, 2.0]]) # assert numpy.array_equal(contains_points, [False, False]) # return if __name__ == "__main__": test_sharp_angle() pypathlib-0.1.3/test/test_path.py000066400000000000000000000014031356675420700170500ustar00rootroot00000000000000import numpy import pypathlib def test_squared_distance(): path = pypathlib.Path([[0.0, 0.0], [1.0, 0.0], [0.9, 0.5], [1.0, 1.0], [0.0, 1.0]]) dist = path.squared_distance( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) ref = numpy.array([0.01, 0.16, 1.0 / 104.0, 0.01, 0.02, 0.0]) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return def test_one_point(): path = pypathlib.Path([[0.0, 0.0]]) dist = path.squared_distance( [[0.2, 0.1], [0.5, 0.5], [1.0, 0.5], [0.0, 1.1], [-0.1, 1.1], [1.0, 1.0]] ) ref = numpy.array([0.05, 0.5, 1.25, 1.21, 1.22, 2.0]) assert numpy.all(numpy.abs(dist - ref) < 1.0e-12) return if __name__ == "__main__": test_squared_distance() pypathlib-0.1.3/test/test_speed.py000066400000000000000000000017371356675420700172260ustar00rootroot00000000000000import numpy from matplotlib import path import perfplot import pypathlib def test_speed(n=3): path_pts = [[0, 0], [0, 1], [1, 1], [1, 0]] path0 = path.Path(path_pts) path1 = pypathlib.ClosedPath(path_pts) def _mpl_path(pts): return path0.contains_points(pts) def _pypathlib_contains_points(pts): return path1.contains_points(pts) numpy.random.seed(0) perfplot.show( setup=lambda n: numpy.random.rand(n, 2), kernels=[_mpl_path, _pypathlib_contains_points], n_range=[2 ** k for k in range(n)], labels=["matplotlib.path.contains_points", "pypathlib.contains_points"], logx=True, logy=True, xlabel="num points", ) return def benchmark(): path_pts = [[0, 0], [0, 1], [1, 1], [1, 0]] path1 = pypathlib.ClosedPath(path_pts) pts = numpy.random.rand(5000000, 2) path1.contains_points(pts) return if __name__ == "__main__": # test_speed(20) benchmark() pypathlib-0.1.3/test_requirements.txt000066400000000000000000000000111356675420700200410ustar00rootroot00000000000000perfplot