I couldn't figure out the problem.
here my code
from scipy.spatial.distance import euclidean
x_o = np.array([3,8,3,4,1,7,5,3,8,2,10,8,10,10,9,8,10,6,7,6])
y_o = np.array([7,3,1,6,10,10,3,6,5,10,10,9,8,2,1,3,1,1,2,2])
def m_dis_sampling(x_o, y_o, sample_size):
sample = []
x_value = x_o[1]
y_value = y_o[1]
x_o = np.delete(x_o, 1)
y_o = np.delete(y_o, 1)
sample.append((x_value,y_value))
arr=np.array(sample)
dst=[]
a=1
while a <sample_size:
if np.logical_or(len(x_o)>0, len(y_o)>0):
for i in range(len(x_o)):
ekl=euclidean((x_o[i], y_o[i]),(np.mean(arr[:,0]),np.mean(arr[:,1])))
dst += [[ekl,i]]
index=(max(dst, key=lambda x: x[0]))[1]
x_value = x_o[index]
y_value = y_o[index]
x_o = np.delete(x_o, index)
y_o = np.delete(y_o, index)
arr = np.concatenate((arr, [[x_value, y_value]]), axis=0)
dst=[]
else:
a=sample_size
a+=1
return arr
and there is a control statement, when it runs
assert maximum_distance_sampling(x_o,y_o, 10) == [(1, 10),
(10, 1),
(10, 10),
(3, 1),
(2, 10),
(9, 1),
(10, 2),
(7, 10),
(6, 1),
(10, 8)]
I got this eror
ValueError Traceback (most recent call last)
<ipython-input-69-2de6e8a36886> in <module>
3 y_o = np.array([7,3,1,6,10,10,3,6,5,10,10,9,8,2,1,3,1,1,2,2])
4
----> 5 assert maximum_distance_sampling(x_o,y_o, 10) == [(1, 10),
6 (10, 1),
7 (10, 10),
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Thank you