Skip to content

Commit

Permalink
make matplotlib optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswillis committed Aug 5, 2024
1 parent 0388ad2 commit 2c55506
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ $ pip install git+https://github.com/pysal/esda@main

- `numba>=0.57` - used to accelerate computational geometry and permutation-based statistical inference.
- `rtree>=1.0` - required for `esda.topo.isolation()`
- `matplotlib` - required for `esda.moran.explore()`

## Contribute

Expand Down
6 changes: 5 additions & 1 deletion esda/moran.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import scipy.stats as stats
from libpysal.weights import W
from libpysal.weights.spatial_lag import lag_spatial
from matplotlib import colors
from scipy import sparse

from .crand import _prepare_univariate
Expand Down Expand Up @@ -1786,6 +1785,11 @@ def _explore_local_moran(moran_local, gdf, crit_value, **kwargs):
folium.Map
"""

try:
from matplotlib import colors
except ImportError:
raise ImportError("matplotlib library must be installed to use the explore feature") from None

gdf = gdf.copy()
gdf["Moran Cluster"] = moran_local.get_cluster_labels(crit_value)
gdf["p-value"] = moran_local.p_sim
Expand Down

0 comments on commit 2c55506

Please sign in to comment.