attach_islands assumes transform='b' & assumes k=1
It'd be nice to be able to use more than 1 nearest neighbor for the islands, use different kinds of supplemental weights, or use non-binary transforms.
Functionally, I think this conceptually involves:
- Ensuring the "supplement" weights to the transform of the target weights. (probably usually binary, since this seems to be used mostly for rook/queen with islands)
- Merging all of the neighbors,weights of islands in the target with their corresponding neighbors,weights in the supplement:
I believe this mostly looks the same as what's implemented:
def attach_islands(target, suplement):
assert supplement.id_order == target.id_order
supplement.transform = target.transform
neighbors, weights = copy.deepcopy(target.neighbors), copy.deepcopy(target.weights)
for island_ix in target.islands:
neighbors[island_ix] = supplement.neighbors[island_ix]
weights[island_ix] = supplement.weights[island_ix]
return W(neighbors, weights, id_order=target.id_order)
This is a nice feature. One additional thing to consider is whether we want the returned spatial weight matrix to be symmetric. For contiguity-based spatial weights, symmetry could be an important property.
Thinking about this... what's the difference between this idea of merging 2 weights & w_union? Only that we're restricting the update to the union of islands' neighbors?
Stale issue message