#NEWLINE# def moment_chunk( A , order = 2 , sum = chunk . sum , numel = numel , dtype = 'f8' , **kwargs ) : #NEWLINE# #INDENT# total = sum ( A , dtype = dtype , ** kwargs ) #NEWLINE# n = numel ( A , ** kwargs ) #NEWLINE# u = ( total / n ) #NEWLINE# M = np . empty ( shape = ( n . shape + ( ( order - 1 ) , ) ) , dtype = dtype ) #NEWLINE# for i in range ( 2 , ( order + 1 ) ) : #NEWLINE# #INDENT# M [ ( ... , ( i - 2 ) ) ] = sum ( ( ( A - u ) ** i ) , dtype = dtype , ** kwargs ) #NEWLINE# #UNINDENT# result = np . empty ( shape = n . shape , dtype = [ ( 'total' , total . dtype ) , ( 'n' , n . dtype ) , ( 'M' , M . dtype , ( ( order - 1 ) , ) ) ] ) #NEWLINE# result [ 'total' ] = total #NEWLINE# result [ 'n' ] = n #NEWLINE# result [ 'M' ] = total #NEWLINE# return result