def test_maxprod_composition(): mfI = np.r_[0.4, 0.7, 1.0, 0.8, 0.6] mfV = np.r_[0.2, 0.6, 1.0, 0.9, 0.7] mfC = np.r_[0.4, 1.0, 0.8] P = cartprod(mfV, mfI) S = cartprod(mfI, mfC) test = maxprod_composition(P, S) expected = np.r_[[[0.08, 0.2, 0.16], [0.24, 0.6, 0.48], [0.4, 1., 0.8], [0.36, 0.9, 0.72], [0.28, 0.7, 0.56]]] assert_allclose(test, expected) A = np.r_[0.3, 0.2, 0.1, 0, 0.7, 0.9, 1] B = np.r_[0.5, 0.5, 0.6, 0.4, 0.6, 0.3, 0.2] c = maxprod_composition(A, B) assert (1, 1) == c.shape assert_allclose(c, np.r_[[[0.42]]])
def test_maxprod_composition(): mfI = np.r_[0.4, 0.7, 1.0, 0.8, 0.6] mfV = np.r_[0.2, 0.6, 1.0, 0.9, 0.7] mfC = np.r_[0.4, 1.0, 0.8] P = cartprod(mfV, mfI) S = cartprod(mfI, mfC) test = maxprod_composition(P, S) expected = np.r_[[[0.08, 0.2 , 0.16], [0.24, 0.6 , 0.48], [0.4 , 1. , 0.8 ], [0.36, 0.9 , 0.72], [0.28, 0.7 , 0.56]]] assert_allclose(test, expected) A = np.r_[0.3, 0.2, 0.1, 0, 0.7, 0.9, 1] B = np.r_[0.5, 0.5, 0.6, 0.4, 0.6, 0.3, 0.2] c = maxprod_composition(A, B) assert (1, 1) == c.shape assert_allclose(c, np.r_[[[0.42]]])
def test_cartprod(): a = np.r_[0, 0, 0, 0.3, 0.7, 1, 0.9, 0] b = np.r_[0, 0, 1, 0.2, 0.1, 0, 0] z = cartprod(a, b) expected = np.r_[[[0., 0., 0. , 0. , 0. , 0., 0.], [0., 0., 0. , 0. , 0. , 0., 0.], [0., 0., 0. , 0. , 0. , 0., 0.], [0., 0., 0.3, 0.2, 0.1, 0., 0.], [0., 0., 0.7, 0.2, 0.1, 0., 0.], [0., 0., 1. , 0.2, 0.1, 0., 0.], [0., 0., 0.9, 0.2, 0.1, 0., 0.], [0., 0., 0. , 0. , 0. , 0., 0.]]] assert_allclose(z, expected)
def test_cartprod(): a = np.r_[0, 0, 0, 0.3, 0.7, 1, 0.9, 0] b = np.r_[0, 0, 1, 0.2, 0.1, 0, 0] z = cartprod(a, b) expected = np.r_[[[0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0.3, 0.2, 0.1, 0., 0.], [0., 0., 0.7, 0.2, 0.1, 0., 0.], [0., 0., 1., 0.2, 0.1, 0., 0.], [0., 0., 0.9, 0.2, 0.1, 0., 0.], [0., 0., 0., 0., 0., 0., 0.]]] assert_allclose(z, expected)