#NEWLINE# def test( self ) : #NEWLINE# #INDENT# self . assertTrue ( ( self . model . P ( ) . sum ( ) == len ( self . data . ratings ) ) ) #NEWLINE# user_sums = list ( ( [ 0 ] * self . data . num_users ( ) ) ) #NEWLINE# item_sums = list ( ( [ 0 ] * self . data . num_items ( ) ) ) #NEWLINE# for ( u , i , r ) in self . data . ratings : #NEWLINE# #INDENT# user_sums [ self ] += 1 #NEWLINE# item_sums [ i ] += 1 #NEWLINE# #UNINDENT# self . assertTrue ( np . array_equal ( self . model . P ( ) . sum ( 1 ) , np . matrix ( user_sums ) . T ) ) #NEWLINE# self . assertTrue ( np . array_equal ( self . model . P ( ) . sum ( 0 ) , np . matrix ( item_sums ) ) )