def updateResultBars( self, canvas ): """ Draws summary for the user. """ canvas.delete( 'all' ) # calculate all necessary values by using functions from diet_delector.py user = diet_selector.normalizeVertically( self.userChoicesMatrix ) price = diet_selector.normalizeVertically( diet_selector.price ) nour = diet_selector.normalizeVertically( diet_selector.nour ) time = diet_selector.normalizeVertically( diet_selector.time ) digestibility = diet_selector.normalizeVertically( diet_selector.digestibility ) calorific = diet_selector.normalizeVertically( diet_selector.calorific ) simplicity = diet_selector.normalizeVertically( diet_selector.simplicity ) s0 = diet_selector.calcMatrixWithAvgRows( user ) s = diet_selector.calcMatrixWithAvgRows( price, nour, time, digestibility, calorific, simplicity ) r = diet_selector.calcDecisionValues( s0, s ) offsetY = -110 offsetX = -100 #canvas.create_rectangle( self.windowWidth / 2 - 100, 85 + self.beltPosOffset + offsetY, # self.windowWidth / 2 + 100, 185 + self.beltPosOffset + offsetY, fill = 'light green' ) canvas.create_text( self.windowWidth / 2 + offsetX, 120 + offsetY, anchor = 'e', text = diet_selector.COURSES[0], font = ( 'Calibri', 10 ), fill = 'black' ) canvas.create_rectangle( self.windowWidth / 2 + offsetX + 10, 115 + offsetY, self.windowWidth / 2 + offsetX + r[0] * 1000, 125 + self.beltPosOffset + offsetY, fill = 'light green' ) canvas.create_text( self.windowWidth / 2 + offsetX, 135 + offsetY, anchor = 'e', text = diet_selector.COURSES[1], font = ( 'Calibri', 10 ), fill = 'black' ) canvas.create_rectangle( self.windowWidth / 2 + offsetX + 10, 130 + offsetY, self.windowWidth / 2 + offsetX + r[1] * 1000, 140 + self.beltPosOffset + offsetY, fill = 'light green' ) canvas.create_text( self.windowWidth / 2 + offsetX, 150 + offsetY, anchor = 'e', text = diet_selector.COURSES[2], font = ( 'Calibri', 10 ), fill = 'black' ) canvas.create_rectangle( self.windowWidth / 2 + offsetX + 10, 145 + offsetY, self.windowWidth / 2 + offsetX + r[2] * 1000, 155 + self.beltPosOffset + offsetY, fill = 'light green' ) canvas.create_text( self.windowWidth / 2 + offsetX, 165 + offsetY, anchor = 'e', text = diet_selector.COURSES[3], font = ( 'Calibri', 10 ), fill = 'black' ) canvas.create_rectangle( self.windowWidth / 2 + offsetX + 10, 160 + offsetY, self.windowWidth / 2 + offsetX + r[3] * 1000, 170 + self.beltPosOffset + offsetY, fill = 'light green' ) canvas.create_text( self.windowWidth / 2 + offsetX, 180 + offsetY, anchor = 'e', text = diet_selector.COURSES[4], font = ( 'Calibri', 10 ), fill = 'black' ) canvas.create_rectangle( self.windowWidth / 2 + offsetX + 10, 175 + offsetY, self.windowWidth / 2 + offsetX + r[4] * 1000, 185 + self.beltPosOffset + offsetY, fill = 'light green' ) consistence = diet_selector.countMatrixConsistency( self.userChoicesMatrix, diet_selector.RI ) consistencyPercent = 100 - ( consistence / 0.1 * 100.0 ) if( not diet_selector.isMatrixConsistence( self.userChoicesMatrix, diet_selector.RI ) ): consistencyPercent = min( -( 100 - ( consistence / 0.1 * 100.0 ) ), 100 ) canvas.create_text( self.windowWidth / 2, 200 + offsetY, text = 'The choice is inconsistent! (' + str( int( consistencyPercent ) ) + '%)', font = ( 'Calibri', 13 ), fill = 'red' ) else: canvas.create_text( self.windowWidth / 2, 200 + offsetY, text = 'The choice is consistent. (' + str( int( consistencyPercent ) ) + '%)', font = ( 'Calibri', 13 ), fill = 'dark green' )
def test_countMatrixConsistency(self): i = diet_selector.countMatrixConsistency(self.m0, self.RI) self.assertEqual(i, 0.03885771511220274)