나는 현재 TypeError: 'numpy.bool_' object is not iterable
이유를 모른 채 a 를 만나고있다 . 내가 사용한 각 변수를 확인했습니다. 이 오류가 발생하는 이유를 알고 있습니까? 다음은 함께 플레이하는 데 사용할 수있는 간단한 코드입니다.
import numpy as np
def rad_to_deg(x):
deg = x*180/np.pi
return deg
def flag_PA(x,bornes_test):
index_0_test = int(np.where(bornes_test==0)[0][0])
for i in range(index_0_test):
cond1 = any(bornes_test[i] <= x < bornes_test[i+1])
cond2 = any(bornes_test[i]+180 <= x < bornes_test[i+1]+180)
if np.logical_or(cond1,cond2)==True :
flag_test=i
return flag_test
##################################### DATA READING ###########################
# Trouver les fichiers en Bande L et Bande N
bornes_PA = np.linspace(-180,180,18+1)
lambda_fichier = np.linspace(3E-6,11E-6)
u_coord_fichier = np.linspace(1,40)
v_coord_fichier = np.linspace(1,40)
baseline_fichier = np.sqrt(np.array(u_coord_fichier)**2+np.array(v_coord_fichier)**2).tolist()
for l in range(len(lambda_fichier)):
for b in range(len(baseline_fichier)):
deg = rad_to_deg(np.arctan2(u_coord_fichier[b],v_coord_fichier[b]))
result = int(flag_PA(deg,bornes_PA))
다음은 전체 오류입니다.
line 34, in <module>
result = int(flag_PA(deg,bornes_PA))
line 13, in flag_PA
cond1 = any(bornes_test[i] <= x < bornes_test[i+1])
문제는 any
그 주장을 반복하려한다는 것입니다.
표현식 bornes_test[i] <= x < bornes_test[i+1]
은 numpy.bool_
배열이 아닌 스칼라를 반환합니다 .
따라서 any(bornes_test[i] <= x < bornes_test[i+1])
오류 메시지에 명시된대로 스칼라를 반복하려고합니다.
을 삭제 any
하고 원하는 결과를 얻을 수있는 것 같습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다