numpy 파이썬 모듈 구문에 대한 질문이 하나 더 있습니다. 정규 파이썬 2.7 구문으로 변환하고 싶습니다.numpy 흐름 제어 구문을 일반 파이썬 구문으로 변환
if any((var.theta < 0) | (var.theta >= 90)):
print('Input incident angles <0 or >=90 detected For input angles with absolute value greater than 90, the ' + 'modifier is set to 0. For input angles between -90 and 0, the ' + 'angle is changed to its absolute value and evaluated.')
var.theta[(var.theta < 0) | (var.theta >= 90)]=abs((var.theta < 0) | (var.theta >= 90))
소스 코드 :
newTheta = []
for item in var.theta:
if (item < 0) and (item >= 90):
print('Input incident angles <0 or >=90 detected For input angles with absolute value greater than 90, the ' + 'modifier is set to 0. For input angles between -90 and 0, the ' + 'angle is changed to its absolute value and evaluated.')
newItem = abs(item)
newTheta.append(newItem)
: 우리는 NumPy와 배열이 차원이다 척하면 https://github.com/Sandia-Labs/PVLIB_Python/blob/master/pvlib/pvl_physicaliam.py#L93-95
는, 일반 파이썬 2.7 구문은 다음과 같이 보일 것입니다 여기에 NumPy와 버전은 무엇입니까? ? 답장을 보내 주셔서 감사합니다. 즉
MobiusKlein 답장을 보내 주셔서 감사합니다. 그래서 numpy의'|'는'or'를 대신합니다. '와'는 어때? 'and'에 대한 대체 구문은 무엇입니까? – marco
Numpy는 바이너리와 연산자 '&'를 오버로드하여 벡터화 된 논리 AND를 처리합니다. 코드는'cond_1 & cond_2'와 같을 것이며, 평범한 파이썬의 경우에는 and 키워드 만 있으면됩니다. – mobiusklein
mobiusklein 감사합니다. – marco