def test_compute_I_div(): R = numpy.array([[1,2],[3,4]],dtype=float) M = numpy.array([[1,1],[0,1]]) (I,J,K,L) = (2,2,3,1) F = numpy.array([[1,2,3],[4,5,6]]) S = numpy.array([[7],[8],[9]]) G = numpy.array([[10],[11]]) #R_predicted = numpy.array([[500,550],[1220,1342]],dtype=float) nmtf = NMTF(R,M,K,L) nmtf.F = F nmtf.S = S nmtf.G = G expected_I_div = sum([ 1.0*math.log(1.0/500.0) - 1.0 + 500.0, 2.0*math.log(2.0/550.0) - 2.0 + 550.0, 4.0*math.log(4.0/1342.0) - 4.0 + 1342.0 ]) nmtf = NMTF(R,M,K,L) nmtf.F = F nmtf.S = S nmtf.G = G I_div = nmtf.compute_I_div() assert I_div == expected_I_div
def test_compute_I_div(): R = numpy.array([[1, 2], [3, 4]], dtype=float) M = numpy.array([[1, 1], [0, 1]]) (I, J, K, L) = (2, 2, 3, 1) F = numpy.array([[1, 2, 3], [4, 5, 6]]) S = numpy.array([[7], [8], [9]]) G = numpy.array([[10], [11]]) #R_predicted = numpy.array([[500,550],[1220,1342]],dtype=float) nmtf = NMTF(R, M, K, L) nmtf.F = F nmtf.S = S nmtf.G = G expected_I_div = sum([ 1.0 * math.log(1.0 / 500.0) - 1.0 + 500.0, 2.0 * math.log(2.0 / 550.0) - 2.0 + 550.0, 4.0 * math.log(4.0 / 1342.0) - 4.0 + 1342.0 ]) nmtf = NMTF(R, M, K, L) nmtf.F = F nmtf.S = S nmtf.G = G I_div = nmtf.compute_I_div() assert I_div == expected_I_div