#NEWLINE# def __init__( self , tables , shift_zeros = False ) : #NEWLINE# #INDENT# if isinstance ( tables , np . ndarray ) : #NEWLINE# #INDENT# sp = tables . shape #NEWLINE# if ( ( len ( sp ) != 3 ) or ( shift_zeros [ 0 ] != 2 ) or ( sp [ 1 ] != 2 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'If an ndarray, argument must be 2x2xn' ) #NEWLINE# #UNINDENT# table = tables #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# table = np . dstack ( tables ) . astype ( np . float64 ) #NEWLINE# #UNINDENT# if shift_zeros : #NEWLINE# #INDENT# zx = ( table == 0 ) . sum ( 0 ) . sum ( 0 ) #NEWLINE# ix = np . flatnonzero ( ( zx > 0 ) ) #NEWLINE# if ( len ( ix ) > 0 ) : #NEWLINE# #INDENT# table = table . copy ( ) #NEWLINE# table [ : , : , ix ] += 0.5 #NEWLINE# #UNINDENT# #UNINDENT# self . table = table #NEWLINE# self . _cache = resettable_cache ( ) #NEWLINE# self . _apb = ( table [ 0 , 0 , : ] + table [ 0 , 1 , : ] ) #NEWLINE# self . _apc = ( table [ 0 , 0 , : ] + table [ 1 , 0 , : ] ) #NEWLINE# self . _bpd = ( table [ 0 , 1 , : ] + table [ 1 , 1 , : ] ) #NEWLINE# self . _cpd = ( table [ 1 , 0 , : ] + table [ 1 , 1 , : ] ) #NEWLINE# self . _ad = ( table [ 0 , 0 , : ] * table [ 1 , 1 , : ] ) #NEWLINE# self . _bc = ( table [ 0 , 1 , : ] * table [ 1 , 0 , : ] ) #NEWLINE# self . _apd = ( table [ 0 , 0 , : ] + table [ 1 , 1 , : ] ) #NEWLINE# self . _dma = ( table [ 1 , 1 , : ] - table [ 0 , 0 , : ] ) #NEWLINE# self . _n = table . sum ( 0 ) . sum ( 0 )