#NEWLINE# def unit_boxify( x_na ) : #NEWLINE# #INDENT# ranges = x_na . ptp ( axis = 0 ) #NEWLINE# dlarge = ranges . argmax ( ) #NEWLINE# unscaled_translation = ( ( - ( x_na . min ( axis = 0 ) + x_na . max ( axis = 0 ) ) ) / 2 ) #NEWLINE# scaling = ( 1.0 / ranges [ dlarge ] ) #NEWLINE# scaled_translation = ( unscaled_translation * scaling ) #NEWLINE# return ( ( ( scaling * scaling ) + scaled_translation ) , ( scaling , scaled_translation ) )