Skip to content

Commit 4a63e0b

Browse files
authored
Merge pull request #188 from ljwolf/v2.4.1
add pygeos-tolerant fails for the module
2 parents 1acdb23 + 56dd511 commit 4a63e0b

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

esda/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.4.0"
1+
__version__ = "2.4.1"
22
"""
33
:mod:`esda` --- Exploratory Spatial Data Analysis
44
=================================================

esda/map_comparison.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import numpy, pygeos, pandas, geopandas
1+
import numpy, pandas
22
from scipy.special import entr
33

4+
try:
5+
import pygeos
6+
except (ImportError, ModuleNotFoundError):
7+
pass # gets handled in the _cast function.
8+
49
# from nowosad and stepinski
510
# https://doi.org/10.1080/13658816.2018.1511794
611

@@ -21,6 +26,13 @@ def _cast(collection):
2126
"""
2227
Cast a collection to a pygeos geometry array.
2328
"""
29+
try:
30+
import pygeos, geopandas
31+
except (ImportError, ModuleNotFoundError) as exception:
32+
raise type(exception)(
33+
"pygeos and geopandas are required for map comparison statistics."
34+
)
35+
2436
if isinstance(collection, (geopandas.GeoSeries, geopandas.GeoDataFrame)):
2537
return collection.geometry.values.data.squeeze()
2638
elif pygeos.is_geometry(collection).all():

esda/shape.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
import pygeos
2-
import geopandas, pandas
31
import numpy
4-
from numba import njit, prange
2+
import pandas
3+
4+
try:
5+
import pygeos
6+
except (ImportError, ModuleNotFoundError):
7+
pass # gets handled at the _cast level.
8+
9+
from .crand import njit, prange
10+
511

612
# -------------------- UTILITIES --------------------#
713
def _cast(collection):
814
"""
915
Cast a collection to a pygeos geometry array.
1016
"""
17+
try:
18+
import pygeos, geopandas
19+
except (ImportError, ModuleNotFoundError) as exception:
20+
raise type(exception)("pygeos and geopandas are required for shape statistics.")
21+
1122
if isinstance(collection, (geopandas.GeoSeries, geopandas.GeoDataFrame)):
1223
return collection.geometry.values.data.squeeze()
1324
elif pygeos.is_geometry(collection).all():

0 commit comments

Comments
 (0)