Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug pysal import #568

Merged
merged 1 commit into from
Jul 21, 2023
Merged
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
10 changes: 5 additions & 5 deletions dynamo/tools/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def moran_i(
"""

try:
import pysal
from pysal import explore, lib
except ImportError:
raise ImportError(
"You need to install the package `pysal`."
Expand Down Expand Up @@ -118,9 +118,9 @@ def moran_i(
adj_dict = {i: row.indices for i, row in enumerate(neighbor_graph)}
if weighted:
weight_dict = {i: row.data for i, row in enumerate(neighbor_graph)}
W = pysal.lib.weights.W(adj_dict, weight_dict)
W = lib.weights.W(adj_dict, weight_dict)
else:
W = pysal.lib.weights.W(adj_dict)
W = lib.weights.W(adj_dict)

sparse = issparse(X_data)

Expand All @@ -133,7 +133,7 @@ def moran_i(
l_moran = np.zeros(X_data.shape)
for cur_g in tqdm(range(gene_num), desc="Moran’s I Global Autocorrelation Statistic"):
cur_X = X_data[:, cur_g].A if sparse else X_data[:, cur_g]
mbi = pysal.explore.esda.moran.Moran(cur_X, W, two_tailed=False)
mbi = explore.esda.moran.Moran(cur_X, W, two_tailed=False)

Moran_I[cur_g] = mbi.I
p_value[cur_g] = (
Expand All @@ -143,7 +143,7 @@ def moran_i(
mbi.z_sim if assumption == "permutation" else mbi.z_norm if assumption == "normality" else mbi.z_sim
)
if local_moran:
l_moran[:, cur_g] = pysal.explore.esda.moran.Moran_Local(cur_X, W).Is
l_moran[:, cur_g] = explore.esda.moran.Moran_Local(cur_X, W).Is

Moran_res = pd.DataFrame(
{
Expand Down