Skip to content

Commit 61ef1d4

Browse files
authored
Merge pull request #237 from sjsrey/master
BUG: ufunc.outer deprecation on pandas series
2 parents 1352315 + 440e9bb commit 61ef1d4

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

libpysal/weights/tests/test_adjlist.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from ... import examples
77
from ..util import lat2W
88
from ...common import RTOL, ATOL
9-
from ... import io
10-
from ...examples import get_path
9+
1110

1211
try:
1312
import pandas
@@ -20,11 +19,11 @@
2019
class Test_Adjlist(ut.TestCase):
2120
def setUp(self):
2221
self.knownW = io.open(examples.get_path('columbus.gal')).read()
23-
22+
2423
def test_round_trip(self):
2524
adjlist = self.knownW.to_adjlist(remove_symmetric=False).astype(int)
2625
w_from_adj = weights.W.from_adjlist(adjlist)
27-
np.testing.assert_allclose(w_from_adj.sparse.toarray(),
26+
np.testing.assert_allclose(w_from_adj.sparse.toarray(),
2827
self.knownW.sparse.toarray())
2928

3029
def test_filter(self):
@@ -33,7 +32,7 @@ def test_filter(self):
3332
assert len(alist) == 4
3433
with self.assertRaises(AssertionError):
3534
badgrid = weights.W.from_adjlist(alist)
36-
np.testing.assert_allclose(badgrid.sparse.toarray(),
35+
np.testing.assert_allclose(badgrid.sparse.toarray(),
3736
grid.sparse.toarray())
3837
assert set(alist.focal.unique().tolist()) == set(list(range(4)))
3938
assert set(alist.neighbor.unique().tolist()) == set(list(range(4)))
@@ -43,7 +42,7 @@ def test_filter(self):
4342
assert len(alist) == 4
4443
with self.assertRaises(AssertionError):
4544
badgrid = weights.W.from_adjlist(alist)
46-
np.testing.assert_allclose(badgrid.sparse.toarray(),
45+
np.testing.assert_allclose(badgrid.sparse.toarray(),
4746
grid.sparse.toarray())
4847
print(alist)
4948
tuples = set([tuple(t) for t in alist[['focal','neighbor']].values])
@@ -56,7 +55,7 @@ def test_filter(self):
5655
assert reversed_complements == tuples, ('the remaining links in the duplicated'
5756
' adjlist are not the reverse of the links'
5857
' in the deduplicated adjlist.')
59-
assert alist.weight.unique().item() == 1
58+
assert alist.weight.unique().item() == 1
6059

6160

6261
def apply_and_compare_columbus(self, col):
@@ -66,7 +65,7 @@ def apply_and_compare_columbus(self, col):
6665
alist = adj.adjlist_apply(df[col], W=W)
6766
right_hovals = alist.groupby('focal').att_focal.unique()
6867
assert (right_hovals == df[col]).all()
69-
allpairs = np.subtract.outer(df[col], df[col])
68+
allpairs = np.subtract.outer(df[col].values, df[col].values)
7069
flat_diffs = allpairs[W.sparse.toarray().astype(bool)]
7170
np.testing.assert_allclose(flat_diffs, alist['subtract'].values)
7271
return flat_diffs
@@ -80,7 +79,7 @@ def test_mvapply(self):
8079
W = weights.Queen.from_dataframe(df)
8180
ssq = lambda x_y: np.sum((x_y[0]-x_y[1])**2).item()
8281
ssq.__name__ = 'sum_of_squares'
83-
alist = adj.adjlist_apply(df[['HOVAL', 'CRIME', 'INC']], W=W,
82+
alist = adj.adjlist_apply(df[['HOVAL', 'CRIME', 'INC']], W=W,
8483
func=ssq)
8584
known_ssq = [1301.1639302990804,
8685
3163.46450914361,
@@ -101,11 +100,11 @@ def test_mvapply(self):
101100
rtol=RTOL, atol=ATOL)
102101

103102
def test_map(self):
104-
atts = ['HOVAL', 'CRIME', 'INC']
103+
atts = ['HOVAL', 'CRIME', 'INC']
105104
df = geopandas.read_file(examples.get_path('columbus.dbf')).head()
106105
W = weights.Queen.from_dataframe(df)
107-
hoval, crime, inc = list(map(self.apply_and_compare_columbus, atts))
106+
hoval, crime, inc = list(map(self.apply_and_compare_columbus, atts))
108107
mapped = adj.adjlist_map(df[atts], W=W)
109108
for name,data in zip(atts, (hoval, crime, inc)):
110-
np.testing.assert_allclose(data,
109+
np.testing.assert_allclose(data,
111110
mapped['_'.join(('subtract',name))].values)

libpysal/weights/tests/test_util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
except:
1717
HAS_GEOPANDAS = False
1818

19+
1920
class Testutil(unittest.TestCase):
2021
def setUp(self):
2122
self.w = Rook.from_shapefile(
2223
examples.get_path('10740.shp'))
2324

25+
self.rio = examples.load_example('Rio Grande do Sul')
26+
2427
def test_lat2W(self):
2528
w9 = lat2W(3, 3)
2629
self.assertEqual(w9.pct_nonzero, 29.62962962962963)
@@ -95,7 +98,7 @@ def test_higher_order(self):
9598
w5_2 = util.higher_order(w5, 2)
9699
w5_20 = {2: 1.0, 10: 1.0, 6: 1.0}
97100
self.assertEqual(w5_20, w5_2[0])
98-
101+
99102
def test_higher_order_classes(self):
100103
wdb = DistanceBand.from_shapefile(examples.get_path('baltim.shp'), 34)
101104
wknn = KNN.from_shapefile(examples.get_path('baltim.shp'), 10)
@@ -199,7 +202,7 @@ def test_get_ids_gdf(self):
199202
polyids = util.get_ids(gdf, "POLYID")
200203
polyids5 = [1, 2, 3, 4, 5]
201204
self.assertEqual(polyids5, polyids[:5])
202-
205+
203206
def test_get_points_array_from_shapefile(self):
204207
xy = util.get_points_array_from_shapefile(
205208
examples.get_path('juvenile.shp'))

0 commit comments

Comments
 (0)