어리석은 것을 묻는다면 미리 사과 할 것이지만 실제로는 apply_along_axis
의 작동 방식을 이해하고 있다고 생각합니다. 나는 방금 고려하지 않은 최악의 경우일지도 모르는 무언가에 부딪 쳤지 만 그것은 나에게 당황 스럽다. 즉,이 나를 혼란 코드입니다 :numpy의 축에 대한 혼란과 축의 내포도
class Leaf(object):
def __init__(self, location):
self.location = location
def __len__(self):
return self.location.shape[0]
def bulk_leaves(child_array, axis=0):
test = np.array([Leaf(location) for location in child_array]) # This is what I want
check = np.apply_along_axis(Leaf, 0, child_array) # This returns an array of individual leafs with the same shape as child_array
return test, check
if __name__ == "__main__":
test, check = bulk_leaves(np.random.ran(100, 50))
test == check # False
난 항상 NumPy와 가진 지능형리스트를 사용하고 배열로 다시 캐스팅 바보 느끼지만, 난 그냥이 작업을 수행하는 또 다른 방법의 확인도 해요 . 나는 명백한 무엇인가 놓치고 있냐?
'apply_along_axis'는 결코 입력을 수정하지 않습니다. 새 배열을 반환합니다. – BrenBarn
잘못 말했는데, 체크가 모양이 child_array와 같음을 의미했습니다. –
'child_array '란 무엇입니까? – BrenBarn