From ece4de440cdb0e09e5d770f3f740f48259b6e2ea Mon Sep 17 00:00:00 2001 From: Pariksheet Nanda Date: Fri, 24 May 2024 12:55:06 -0400 Subject: [PATCH] drop unmaintained pygeos for shapely 2.0 (#545) * drop unmaintained pygeos for shapely 2.0 * removed unused pygeos env variable --------- Co-authored-by: Luca Marconato --- pyproject.toml | 3 +-- src/spatialdata/__init__.py | 7 ------- src/spatialdata/_compat.py | 27 --------------------------- tests/conftest.py | 22 +++++++++------------- 4 files changed, 10 insertions(+), 49 deletions(-) delete mode 100644 src/spatialdata/_compat.py diff --git a/pyproject.toml b/pyproject.toml index e6c187c1..860a2062 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ "dask-image", "dask<=2024.2.1", "fsspec<=2023.6", - "geopandas", + "geopandas>=0.14", "multiscale_spatial_image==0.11.2", "networkx", "numpy", @@ -35,7 +35,6 @@ dependencies = [ "pandas", "pooch", "pyarrow", - "pygeos", "rich", "shapely>=2.0.1", "spatial_image==0.3.0", diff --git a/src/spatialdata/__init__.py b/src/spatialdata/__init__.py index 18eae0f8..3fd835d9 100644 --- a/src/spatialdata/__init__.py +++ b/src/spatialdata/__init__.py @@ -4,13 +4,6 @@ __version__ = version("spatialdata") -# Forcing usage of shapely 2.0 by geopandas -# https://geopandas.org/en/stable/getting_started/install.html#using-the-optional-pygeos-dependency -from ._compat import _check_geopandas_using_shapely - -_check_geopandas_using_shapely() - - __all__ = [ "models", "transformations", diff --git a/src/spatialdata/_compat.py b/src/spatialdata/_compat.py deleted file mode 100644 index 3fb9b57a..00000000 --- a/src/spatialdata/_compat.py +++ /dev/null @@ -1,27 +0,0 @@ -def _check_geopandas_using_shapely() -> None: - """Check if geopandas is using shapely. - - This is required until it becomes the default. - """ - import warnings - - with warnings.catch_warnings(): - warnings.filterwarnings( - "ignore", - "Shapely 2.0 is installed, but because PyGEOS is also installed", - category=UserWarning, - ) - import geopandas - - if geopandas.options.use_pygeos is True: - geopandas.options.use_pygeos = False - - warnings.warn( - ( - "Geopandas was set to use PyGEOS, changing to shapely 2.0 with:" - "\n\n\tgeopandas.options.use_pygeos = True\n\n" - "If you intended to use PyGEOS, set the option to False." - ), - UserWarning, - stacklevel=2, - ) diff --git a/tests/conftest.py b/tests/conftest.py index 66f65e0c..f8a15a53 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,16 +1,11 @@ from __future__ import annotations -# isort: off -import os -from typing import Any from collections.abc import Sequence - -os.environ["USE_PYGEOS"] = "0" -# isort:on - -from shapely import linearrings, polygons from pathlib import Path -from spatialdata._types import ArrayLike +from typing import Any + +import dask.dataframe as dd +import geopandas as gpd import numpy as np import pandas as pd import pytest @@ -19,9 +14,13 @@ from geopandas import GeoDataFrame from multiscale_spatial_image import MultiscaleSpatialImage from numpy.random import default_rng +from shapely import linearrings, polygons from shapely.geometry import MultiPolygon, Point, Polygon from spatial_image import SpatialImage +from spatialdata._core._deepcopy import deepcopy as _deepcopy from spatialdata._core.spatialdata import SpatialData +from spatialdata._types import ArrayLike +from spatialdata.datasets import BlobsDataset from spatialdata.models import ( Image2DModel, Image3DModel, @@ -32,10 +31,6 @@ TableModel, ) from xarray import DataArray -from spatialdata.datasets import BlobsDataset -import geopandas as gpd -import dask.dataframe as dd -from spatialdata._core._deepcopy import deepcopy as _deepcopy RNG = default_rng(seed=0) @@ -309,6 +304,7 @@ def labels_blobs() -> ArrayLike: def sdata_blobs() -> SpatialData: """Create a 2D labels.""" from copy import deepcopy + from spatialdata.datasets import blobs sdata = deepcopy(blobs(256, 300, 3))