예제 #1
0
def test_translate_args():
    shape1 = Shape()
    shape1.translate([1, 2, 3])
    shape2 = Shape()
    shape2.translate(1, 2, 3)
    shape3 = Shape(translate=(1, 2, 3))
    shape4 = Shape(translate=np.array([1, 2, 3]))
    assert np.array_equal(shape1.transform, shape2.transform)
    assert np.array_equal(shape1.transform, shape3.transform)
    assert np.array_equal(shape1.transform, shape4.transform)
예제 #2
0
def test_translate_bad_args():
    shape = Shape()
    with pytest.raises(ValueError):
        shape.translate(1, 2)
    with pytest.raises(ValueError):
        shape.translate([1, 2])
    with pytest.raises(ValueError):
        shape.translate("a", 2, 3)
    with pytest.raises(ValueError):
        shape.translate([1, 2], 3)
예제 #3
0
def test_translate():
    v = np.array([1, 2, 3, 1])
    shape = Shape()
    shape.translate(3, 2, 5)
    assert np.array_equal(shape.transform @ v, np.array([4, 4, 8, 1]))