#NEWLINE# def arg_chunk( func , argfunc , x , axis , offset_info ) : #NEWLINE# #INDENT# arg_axis = ( None if ( ( len ( axis ) == x . ndim ) or ( x . ndim == 1 ) ) else axis [ 0 ] ) #NEWLINE# vals = func ( x , axis = arg_axis , keepdims = True ) #NEWLINE# arg = argfunc ( x , axis = arg_axis , keepdims = True ) #NEWLINE# if ( arg_axis is None ) : #NEWLINE# #INDENT# ( offset , total_shape ) = offset_info #NEWLINE# ind = np . unravel_index ( arg . ravel ( ) [ 0 ] , x . shape ) #NEWLINE# total_ind = tuple ( ( ( o + i ) for ( o , i ) in zip ( offset , ind ) ) ) #NEWLINE# arg [ : ] = np . ravel_multi_index ( total_ind , total_shape ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arg += offset_info #NEWLINE# #UNINDENT# result = np . empty ( shape = vals . shape , dtype = [ ( 'vals' , vals . dtype ) , ( 'arg' , arg . dtype ) ] ) #NEWLINE# result [ 'vals' ] = vals #NEWLINE# result [ 'arg' ] = arg #NEWLINE# return result