Skip to content
Open
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
1 change: 0 additions & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ jobs:

geodatasets.fetch("nybb")
geodatasets.fetch("geoda liquor_stores")
geodatasets.fetch("eea large_rivers")
geodatasets.fetch("geoda groceries")
geodatasets.fetch("geoda guerry")
libpysal.examples.fetch_all()
Expand Down
2 changes: 1 addition & 1 deletion libpysal/graph/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _neighbor_dict_to_edges(neighbors, weights=None):
FutureWarning,
)
idxs = idxs.fillna(pd.Series(idxs.index, index=idxs.index)) # self-loops
heads, tails = idxs.index.values, idxs.values
heads, tails = idxs.index.to_numpy(), idxs.to_numpy()
tails = tails.astype(heads.dtype)
if weights is not None:
with warnings.catch_warnings():
Expand Down
9 changes: 7 additions & 2 deletions libpysal/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,8 +1853,13 @@ def asymmetry(self, intrinsic=True):
zip(np.arange(self.unique_ids.shape[0]), self.unique_ids, strict=True)
)
focal, neighbor = np.nonzero(wd)
focal = focal.astype(self._adjacency.index.dtypes["focal"])
neighbor = neighbor.astype(self._adjacency.index.dtypes["focal"])
dtype = (
self._adjacency.index.dtypes["focal"]
if self._adjacency.index.dtypes["focal"] != "str"
else "object"
)
focal = focal.astype(dtype)
neighbor = neighbor.astype(dtype)
for i in i2id:
focal[focal == i] = i2id[i]
neighbor[neighbor == i] = i2id[i]
Expand Down
7 changes: 4 additions & 3 deletions libpysal/graph/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def setup_method(self):
self.weight_dict_str_binary.values(),
name="weight",
index=pd.MultiIndex.from_arrays(
[self.index_str, self.neighbor_dict_str.values()],
# list() to allow pandas to coerce the data to its StringDtype
[list(self.index_str), self.neighbor_dict_str.values()],
names=["focal", "neighbor"],
),
)
Expand Down Expand Up @@ -457,7 +458,8 @@ def test_from_dicts(self):
pd.testing.assert_series_equal(
g._adjacency,
self.adjacency_str_binary,
check_dtype=False,
check_dtype=True,
check_index_type=False,
)

@pytest.mark.parametrize("y", [3, 5])
Expand Down Expand Up @@ -617,7 +619,6 @@ def test_cardinalities(self):
[3, 3, 2, 3, 4, 3, 2, 3, 2, 0],
index=pd.Index(
["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"],
dtype="object",
name="focal",
),
name="cardinalities",
Expand Down