Skip to content

Commit

Permalink
Merge pull request #188 from ljwolf/v2.4.1
Browse files Browse the repository at this point in the history
add pygeos-tolerant fails for the module
  • Loading branch information
ljwolf authored Jul 27, 2021
2 parents 1acdb23 + 56dd511 commit 4a63e0b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion esda/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.4.0"
__version__ = "2.4.1"
"""
:mod:`esda` --- Exploratory Spatial Data Analysis
=================================================
Expand Down
14 changes: 13 additions & 1 deletion esda/map_comparison.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import numpy, pygeos, pandas, geopandas
import numpy, pandas
from scipy.special import entr

try:
import pygeos
except (ImportError, ModuleNotFoundError):
pass # gets handled in the _cast function.

# from nowosad and stepinski
# https://doi.org/10.1080/13658816.2018.1511794

Expand All @@ -21,6 +26,13 @@ def _cast(collection):
"""
Cast a collection to a pygeos geometry array.
"""
try:
import pygeos, geopandas
except (ImportError, ModuleNotFoundError) as exception:
raise type(exception)(
"pygeos and geopandas are required for map comparison statistics."
)

if isinstance(collection, (geopandas.GeoSeries, geopandas.GeoDataFrame)):
return collection.geometry.values.data.squeeze()
elif pygeos.is_geometry(collection).all():
Expand Down
17 changes: 14 additions & 3 deletions esda/shape.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import pygeos
import geopandas, pandas
import numpy
from numba import njit, prange
import pandas

try:
import pygeos
except (ImportError, ModuleNotFoundError):
pass # gets handled at the _cast level.

from .crand import njit, prange


# -------------------- UTILITIES --------------------#
def _cast(collection):
"""
Cast a collection to a pygeos geometry array.
"""
try:
import pygeos, geopandas
except (ImportError, ModuleNotFoundError) as exception:
raise type(exception)("pygeos and geopandas are required for shape statistics.")

if isinstance(collection, (geopandas.GeoSeries, geopandas.GeoDataFrame)):
return collection.geometry.values.data.squeeze()
elif pygeos.is_geometry(collection).all():
Expand Down

0 comments on commit 4a63e0b

Please sign in to comment.