def test_problem1_7_scalar(xs, n, expected): v = Vector(*xs) assert v * n == Vector(*expected)
def test_problem1_6(xs, ys, expected): u, v = Vector(*xs), Vector(*ys) assert u - v == Vector(*expected)
def test_problem1_6_invalid(): u, v = Vector(1, 2), Vector(1, 2, 3) with pytest.raises(ValueError): w = u - v
def test_problem1_4(xs, expected): v = Vector(*xs) assert -v == Vector(*expected) assert -(-v) == Vector(*xs)
def test_problem1_1(n): v = Vector(*list(range(n)))
def test_problem1_2(xs, expected): v = Vector(*xs) assert str(v) == expected
def test_problem1_3(n): v = Vector(*list(range(n))) assert len(v) == n
def test_problem1_8_invalid(): u, v = Vector(1, 2), Vector(1, 2, 3) with pytest.raises(TypeError): w = u / v with pytest.raises(TypeError): w = u // v
def test_problem1_8_floordiv(xs, n, expected): v = Vector(*xs) assert v // n == Vector(*expected)
def test_problem1_8_truediv(xs, n, expected): v = Vector(*xs) assert v / n == Vector(*expected)
def test_problem1_7_dot_product(xs, ys, expected): u, v = Vector(*xs), Vector(*ys) assert u * v == expected
def test_problem1_1_invalid(): with pytest.raises(ValueError): v = Vector() with pytest.raises(ValueError): v = Vector(1)