libpysal.weights.full2W(m, ids=None)[source]¶Create a PySAL W object from a full array.
| Parameters: | m : array
ids : list
|
|---|---|
| Returns: | w : W
|
Examples
>>> import libpysal
>>> import numpy as np
Create an array of zeros
>>> a = np.zeros((4, 4))
For loop to fill it with random numbers
>>> for i in range(len(a)):
... for j in range(len(a[i])):
... if i!=j:
... a[i, j] = np.random.random(1)
Create W object
>>> w = libpysal.weights.util.full2W(a)
>>> w.full()[0] == a
array([[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True]])
Create list of user ids
>>> ids = ['myID0', 'myID1', 'myID2', 'myID3']
>>> w = libpysal.weights.util.full2W(a, ids=ids)
>>> w.full()[0] == a
array([[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True]])