def test_multiply(self): orig = array((1.0, 2.0, 3.0, 1.0, 4.0, 5.0)) desired = array([7., 4., 6., 7., 23., 18.]) m = agg.AffineMatrix(orig) other = agg.AffineMatrix(orig) m.multiply(other) result = m.asarray() assert (alltrue(result == desired))
def test_set_text_matrix_ndarray(self): """ Test that gc.set_text_matrix accepts 3x3 ndarrays. """ gc = agg.GraphicsContextArray((5, 5)) m = array([[1.0, 2.0, 0.0], [3.0, 4.0, 0.0], [5.0, 6.0, 1.0]]) gc.set_text_matrix(m) m2 = gc.get_text_matrix() self.assertEqual(m2, agg.AffineMatrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0))
def test_init_from_array1(self): a = ones(6, "D") try: agg.AffineMatrix(a) except (NotImplementedError, TypeError): # NotImplementedError in Swig 3, TypeError in Swig 4 (see swig #1261) pass # can't init from complex value.
def test_invert(self): orig = agg.AffineMatrix((1.0, 2.0, 3.0, 1.0, 4.0, 5.0)) orig.invert() actual = orig.asarray() desired = array([-0.2, 0.4, 0.6, -0.2, -2.2, -0.6]) assert (allclose(desired, actual))
def test_init(self): m = agg.AffineMatrix()
def test_determinant(self): orig = array((1.0, 2.0, 3.0, 1.0, 4.0, 5.0)) desired = -0.2 m = agg.AffineMatrix(orig) result = m.determinant() assert (alltrue(result == desired))
def _test_zero_arg_transform(self, method, orig, desired): m = agg.AffineMatrix(orig) method(m) result = m.asarray() assert (alltrue(result == desired))
def test_asarray(self): m = agg.AffineMatrix() result = m.asarray() desired = array((1.0, 0.0, 0.0, 1.0, 0.0, 0.0)) assert (alltrue(result == desired))
def test_imul(self): a = agg.AffineMatrix((2.0, 0, 0, 2.0, 0, 0)) a *= a actual = a desired = agg.AffineMatrix((4.0, 0, 0, 4.0, 0, 0)) assert (alltrue(desired == actual))
def test_init_from_array3(self): a = ones((2, 3), 'd') try: m = agg.AffineMatrix(a) except ValueError: pass # can't init from array that isn't 1d.
def test_init_from_array2(self): a = ones(7, 'd') try: m = agg.AffineMatrix(a) except ValueError: pass # can't init from array that isn't 6 element.
def test_init_from_array1(self): a = ones(6, 'D') try: m = agg.AffineMatrix(a) except NotImplementedError: pass # can't init from complex value.
def test_init_from_array(self): a = ones(6, 'd') m = agg.AffineMatrix(a) desired = ones(6, 'd') result = m.asarray() assert (alltrue(result == desired))