Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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