Skip to content

Commit 19a7b05

Browse files
committed
Fixed index2da causing inverted output
1 parent ea86611 commit 19a7b05

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

libpysal/weights/raster.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ def da2WSP(
281281
*shape, ids, id_map, criterion, k_nas, dtype, n_jobs
282282
) # -> (data, (row, col))
283283

284-
sw = sparse.csr_matrix(sw_tup, shape=(n, n), dtype=np.int8,)
284+
sw = sparse.csr_matrix(
285+
sw_tup,
286+
shape=(n, n),
287+
dtype=np.int8,
288+
)
285289

286290
# Higher_order functionality, this uses idea from
287291
# libpysal#313 for adding higher order neighbors.
@@ -559,10 +563,9 @@ def _index2da(data, index, attrs, coords):
559563
fill = attrs["nodatavals"][0] if "nodatavals" in attrs else 0
560564
data_complete = np.full(shape, fill, data.dtype)
561565
data_complete[indexer] = data
562-
data_complete = data_complete[:, ::-1]
563566

564567
da = DataArray(data_complete, coords=coords, dims=dims, attrs=attrs)
565-
return da.sortby(dims[-2], False)
568+
return da
566569

567570

568571
@jit(nopython=True, fastmath=True)
@@ -591,7 +594,13 @@ def _idmap(ids, mask, dtype):
591594

592595
@jit(nopython=True, fastmath=True)
593596
def _SWbuilder(
594-
nrows, ncols, ids, id_map, criterion, k, dtype,
597+
nrows,
598+
ncols,
599+
ids,
600+
id_map,
601+
criterion,
602+
k,
603+
dtype,
595604
):
596605
"""
597606
Computes data and orders rows, cols, data for a single chunk
@@ -631,7 +640,13 @@ def _SWbuilder(
631640

632641
@jit(nopython=True, fastmath=True, nogil=True)
633642
def _compute_chunk(
634-
nrows, ncols, ids, id_map, criterion, k, dtype,
643+
nrows,
644+
ncols,
645+
ids,
646+
id_map,
647+
criterion,
648+
k,
649+
dtype,
635650
):
636651
"""
637652
Computes rows cols for a single chunk
@@ -754,7 +769,9 @@ def _compute_chunk(
754769

755770
@jit(nopython=True, fastmath=True)
756771
def _chunk_generator(
757-
n_jobs, starts, ids,
772+
n_jobs,
773+
starts,
774+
ids,
758775
):
759776
"""
760777
Construct chunks to iterate over within numba in parallel
@@ -782,7 +799,14 @@ def _chunk_generator(
782799

783800

784801
def _parSWbuilder(
785-
nrows, ncols, ids, id_map, criterion, k, dtype, n_jobs,
802+
nrows,
803+
ncols,
804+
ids,
805+
id_map,
806+
criterion,
807+
k,
808+
dtype,
809+
n_jobs,
786810
):
787811
"""
788812
Computes data and orders rows, cols, data in parallel using numba

0 commit comments

Comments
 (0)