Skip to content

Commit

Permalink
import speedups from vectorized (#1197)
Browse files Browse the repository at this point in the history
* import speedups from vectorized

* Add LineString to doctest_namespace

* Move conftest.py to geometry module to support doctests

* Add conftest.py
  • Loading branch information
sgillies authored Oct 4, 2021
1 parent 26cafd0 commit 769b203
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Deprecations:
The almost_exact() method of BaseGeometry has been deprecated. It is confusing
and will be removed in 2.0.0. The equals_exact() method is to be used instead.

Bug fixes:

- We ensure that the _speedups module is always imported before _vectorized to
avoid an unexplained condition on Windows with Python 3.8 and 3.9 (#1184).

1.8a3 (2021-08-24)
------------------

Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ build_script:
- python -c "import shapely; print(shapely.__version__)"
- python -c "from shapely.geos import geos_version_string; print(geos_version_string)"
- python -c "from shapely import speedups; assert speedups.enabled"
- python -c "from shapely import vectorized"


cache:
Expand Down
15 changes: 8 additions & 7 deletions shapely/geometry/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,9 @@ def equals(self, other):
Examples
--------
>>> LineString(
... (0, 0), (2, 2)
... [(0, 0), (2, 2)]
... ).equals(
... LineString((0, 0), (1, 1), (2, 2))
... LineString([(0, 0), (1, 1), (2, 2)])
... )
True
Expand Down Expand Up @@ -831,9 +831,9 @@ def equals_exact(self, other, tolerance):
Examples
--------
>>> LineString(
... (0, 0), (2, 2)
... [(0, 0), (2, 2)]
... ).equals_exact(
... LineString((0, 0), (1, 1), (2, 2)),
... LineString([(0, 0), (1, 1), (2, 2)]),
... 1e-6
... )
False
Expand Down Expand Up @@ -864,9 +864,10 @@ def almost_equals(self, other, decimal=6):
Examples
--------
>>> LineString(
... (0, 0), (2, 2)
... ).almost_equals(
... LineString((0, 0), (1, 1), (2, 2))
... [(0, 0), (2, 2)]
... ).equals_exact(
... LineString([(0, 0), (1, 1), (2, 2)]),
... 1e-6
... )
False
Expand Down
10 changes: 10 additions & 0 deletions shapely/geometry/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Autouse fixtures for doctests."""

import pytest

from .linestring import LineString


@pytest.fixture(autouse=True)
def add_linestring(doctest_namespace):
doctest_namespace["LineString"] = LineString
2 changes: 2 additions & 0 deletions shapely/vectorized/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Provides multi-point element-wise operations such as ``contains``."""

from shapely import speedups

from ._vectorized import (contains, touches)
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def pytest_addoption(parser):
parser.addoption("--without-speedups", action="store_true", default=False,
help="Run tests without speedups.")


def pytest_runtest_setup(item):
if item.config.getoption("--with-speedups"):
import shapely.speedups
Expand All @@ -30,6 +31,7 @@ def pytest_runtest_setup(item):
assert(shapely.speedups.enabled is False)
print("Speedups disabled for %s." % item.name)


def pytest_report_header(config):
headers = []
try:
Expand Down

0 comments on commit 769b203

Please sign in to comment.