Skip to content

Commit 16205db

Browse files
committed
fix the RNG-2 condition
1 parent 34bb08d commit 16205db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libpysal/weights/gabriel.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def _filter_relativehood(edges, coordinates, return_dkmax=False):
332332
2. for each edge of the delaunay (i,j), compute
333333
dkmax = max(d(k,i), d(k,j)) for k in 1..n, k != i, j
334334
3. for each edge of the delaunay (i,j), prune
335-
if any dkmax is greater than d(i,j)
335+
if any dkmax is smaller than d(i,j)
336336
"""
337337
n = edges.max()
338338
out = []
@@ -345,11 +345,12 @@ def _filter_relativehood(edges, coordinates, return_dkmax=False):
345345
dij = ((pi - pj) ** 2).sum() ** 0.5
346346
prune = False
347347
for k in range(n):
348+
if k == i or k == j:
349+
continue
348350
pk = coordinates[k]
349351
dik = ((pi - pk) ** 2).sum() ** 0.5
350352
djk = ((pj - pk) ** 2).sum() ** 0.5
351-
distances = numpy.array([dik, djk, dkmax])
352-
dkmax = distances.max()
353+
dkmax = max(dik, djk)
353354
prune = dkmax < dij
354355
if (not return_dkmax) & prune:
355356
break

0 commit comments

Comments
 (0)