Skip to content

Commit

Permalink
DEPS: don't require pygeos + update to test with both pygeos and shap…
Browse files Browse the repository at this point in the history
…ely 2 (#183)
  • Loading branch information
jorisvandenbossche authored Dec 22, 2022
1 parent 6144fc8 commit 0062a14
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ substantial change. Please see [CHANGES](CHANGES.md).

Supports Python 3.8 - 3.10 and GDAL 3.1.x - 3.5.x.

Reading to GeoDataFrames requires requires `geopandas>=0.8` with `pygeos` enabled.
Reading to GeoDataFrames requires requires `geopandas>=0.8` with `pygeos`
or `geopandas>=0.12` with `shapely>=2`.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ dependencies:
- numpy
- libgdal
- pytest
- pygeos
- shapely>=2
- geopandas-base
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

autodoc_mock_imports = [
"geopandas",
"pygeos",
]

# -- Project information -----------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions docs/source/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

Supports Python 3.8 - 3.10 and GDAL 3.1.x - 3.5.x

Reading to GeoDataFrames requires requires `geopandas>=0.8` with `pygeos` enabled.
Reading to GeoDataFrames requires requires `geopandas>=0.8` with `pygeos`
or `geopandas>=0.12` with `shapely>=2`.

## Installation

Expand All @@ -18,7 +19,7 @@ conda install -c conda-forge pyogrio
```

This requires compatible versions of `GDAL` and `numpy` from `conda-forge` for
raw I/O support and `geopandas`, `pygeos`, and their dependencies for GeoDataFrame
raw I/O support and `geopandas` and their dependencies for GeoDataFrame
I/O support.

### PyPI
Expand Down
5 changes: 3 additions & 2 deletions pyogrio/tests/test_geopandas_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,11 @@ def test_write_read_null(tmp_path):
],
)
def test_write_geometry_z_types(tmp_path, wkt, geom_types):
pygeos = pytest.importorskip("pygeos")
from geopandas.array import from_wkt

filename = tmp_path / "test.fgb"

gdf = gp.GeoDataFrame(geometry=[pygeos.from_wkt(wkt)], crs="EPSG:4326")
gdf = gp.GeoDataFrame(geometry=from_wkt([wkt]), crs="EPSG:4326")
for geom_type in geom_types:
write_dataframe(gdf, filename, geometry_type=geom_type)
df = read_dataframe(filename)
Expand Down
12 changes: 9 additions & 3 deletions pyogrio/tests/test_raw_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,15 @@ def assert_equal_result(result1, result2):
# a plain `assert np.array_equal(geometry1, geometry2)` doesn't work because
# the WKB values are not exactly equal, therefore parsing with pygeos to compare
# with tolerance
pygeos = pytest.importorskip("pygeos")
assert pygeos.equals_exact(
pygeos.from_wkb(geometry1), pygeos.from_wkb(geometry2), tolerance=0.00001
try:
from shapely import from_wkb, equals_exact
except ImportError:
try:
from pygeos import from_wkb, equals_exact
except ImportError:
pytest.skip("Test requires pygeos or shapely>=2")
assert equals_exact(
from_wkb(geometry1), from_wkb(geometry2), tolerance=0.00001
).all()
assert all([np.array_equal(f1, f2) for f1, f2 in zip(field_data1, field_data2)])

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def run(self):
"dev": ["Cython"],
"test": ["pytest", "pytest-cov"],
"benchmark": ["pytest-benchmark"],
"geopandas": ["pygeos", "geopandas"],
"geopandas": ["geopandas"],
},
include_package_data=True,
cmdclass=cmdclass,
Expand Down

0 comments on commit 0062a14

Please sign in to comment.