def test_approximate_max_intensity(): m1 = Matrix([ [1.0, 0.0, 0.0], [1.0, 0.0, 0.0], ]) m2 = Matrix([ [0.0, 0.0, 1.0], [0.0, 1.0, 0.0], ]) m1.approximate(m2, 1.0) expected = Matrix([ [0.0, 0.0, 1.0], [0.0, 1.0, 0.0], ]) assert matrixes_almost_equal(m1, expected)
def test_approximate_nothing(): m1 = Matrix([ [1.0, 0.0, 0.0], [1.0, 0.0, 0.0], ]) m2 = Matrix([ [1.0, 0.0, 0.0], [1.0, 0.0, 0.0], ]) m1.approximate(m2, 1.0) expected = Matrix([ [1.0, 0.0, 0.0], [1.0, 0.0, 0.0], ]) assert matrixes_almost_equal(m1, expected)
def test_approximate_some_intensity(): m1 = Matrix([ [1.0, 0.0, 0.0], [1.0, 0.0, 0.0], ]) m2 = Matrix([ [0.0, 0.0, 1.0], [0.0, 1.0, 0.0], ]) m1.approximate(m2, 0.1) expected = Matrix([ [0.9, 0.0, 0.1], [0.9, 0.1, 0.0], ]) assert matrixes_almost_equal(m1, expected) m1.approximate(m2, 0.1) expected = Matrix([ [0.819, 0.0, 0.19], [0.819, 0.19, 0.0], ]) assert matrixes_almost_equal(m1, expected)