File: test_nearest.py

package info (click to toggle)
python-shapely 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 2,528 kB
  • sloc: python: 18,648; ansic: 6,615; makefile: 88; sh: 62
file content (18 lines) | stat: -rw-r--r-- 476 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import unittest

import pytest

from shapely.geometry import Point
from shapely.ops import nearest_points


class Nearest(unittest.TestCase):
    def test_nearest(self):
        first, second = nearest_points(
            Point(0, 0).buffer(1.0),
            Point(3, 0).buffer(1.0),
        )
        assert first.x == pytest.approx(1.0)
        assert second.x == pytest.approx(2.0)
        assert first.y == pytest.approx(0.0)
        assert second.y == pytest.approx(0.0)