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

Dec 17, 2020 in Python 7,556 views
Hey, @Muammer,

I would suggest you go through this:https://blog.finxter.com/how-to-fix-valueerror-the-truth-value-of-an-array-with-more-than-one-element-is-ambiguous-use-a-any-or-a-all/

As it is possible happening multiple ambiguities.

## ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Hello @kartik, Since different users might have different ...READ MORE

## Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

I am getting this error: Truth value of ...READ MORE

## i want to create a dataframe,everytime i am gonna parse a xml file ,my expectation is all AIN.MFN and REG should come d contain all of themfrom that file but it is returning a dataframe with one row

from xml.dom import minidom import pandas as pd mydoc ...READ MORE

## How to slice an array using python numpy? Is there any numpy tutorial which has covered all its operations?

Slicing is basically extracting particular set of ...READ MORE

## Is arr.__len__() the preferred way to get the length of an array in Python?

my_list = [1,2,3,4,5,6,7] len(my_list) # 7 The same works for ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote