import pytest  # type: ignore
from hypothesis import given
from hypothesis.strategies import floats
from utils import vectors
from ppb_vector import Vector2


@pytest.mark.parametrize("x, y, expected", [
    (Vector2(6, 1), 0, Vector2(0, 0)),
    (Vector2(6, 1), 2, Vector2(12, 2)),
    (Vector2(0, 0), 3, Vector2(0, 0)),
    (Vector2(-1.5, 2.4), -2, Vector2(3.0, -4.8)),
    (Vector2(1, 2), 0.1, Vector2(0.1, 0.2))
])
def test_scalar_multiplication(x, y, expected):
    assert x * y == expected


@given(
    x=floats(min_value=-1e75, max_value=1e75),
    y=floats(min_value=-1e75, max_value=1e75),
    v=vectors(max_magnitude=1e150)
)
def test_scalar_associative(x: float, y: float, v: Vector2):
    left  = (x * y) * v
    right =  x * (y * v)
    assert left.isclose(right)

import pytest  # type: ignore
from hypothesis import given
from hypothesis.strategies import floats
from utils import vectors
from ppb_vector import Vector2


@pytest.mark.parametrize("x, y, expected", [
    (Vector2(6, 1), 0, Vector2(0, 0)),
    (Vector2(6, 1), 2, Vector2(12, 2)),
    (Vector2(0, 0), 3, Vector2(0, 0)),
    (Vector2(-1.5, 2.4), -2, Vector2(3.0, -4.8)),
    (Vector2(1, 2), 0.1, Vector2(0.1, 0.2))
])
def test_scalar_multiplication(x, y, expected):
    assert x * y == expected


@given(
    x=floats(min_value=-1e75, max_value=1e75),
    y=floats(min_value=-1e75, max_value=1e75),
    v=vectors(max_magnitude=1e150)
)
def test_scalar_associative(x: float, y: float, v: Vector2):
    left  = (x * y) * v
    right =  x * (y * v)
    assert left.isclose(right)

@given(
    l=floats(min_value=-1e150, max_value=1e150),
    x=vectors(max_magnitude=1e150),
    y=vectors(max_magnitude=1e150),
)
def test_scalar_linear(l: float, x: Vector2, y: Vector2):
    assert (l * (x + y)).isclose(l*x + l*y)

Add a test of the linearity of scalar multiplication
Add a test of the linearity of scalar multiplication

  import pytest  # type: ignore
  from hypothesis import given
  from hypothesis.strategies import floats
  from utils import vectors
  from ppb_vector import Vector2
  
  
  @pytest.mark.parametrize("x, y, expected", [
      (Vector2(6, 1), 0, Vector2(0, 0)),
      (Vector2(6, 1), 2, Vector2(12, 2)),
      (Vector2(0, 0), 3, Vector2(0, 0)),
      (Vector2(-1.5, 2.4), -2, Vector2(3.0, -4.8)),
      (Vector2(1, 2), 0.1, Vector2(0.1, 0.2))
  ])
  def test_scalar_multiplication(x, y, expected):
      assert x * y == expected
  
  
  @given(
      x=floats(min_value=-1e75, max_value=1e75),
      y=floats(min_value=-1e75, max_value=1e75),
      v=vectors(max_magnitude=1e150)
  )
  def test_scalar_associative(x: float, y: float, v: Vector2):
      left  = (x * y) * v
      right =  x * (y * v)
      assert left.isclose(right)
  
+ @given(
+     l=floats(min_value=-1e150, max_value=1e150),
+     x=vectors(max_magnitude=1e150),
+     y=vectors(max_magnitude=1e150),
+ )
+ def test_scalar_linear(l: float, x: Vector2, y: Vector2):
+     assert (l * (x + y)).isclose(l*x + l*y)
+ 
Add a test of the linearity of scalar multiplication
## Code Before:
import pytest  # type: ignore
from hypothesis import given
from hypothesis.strategies import floats
from utils import vectors
from ppb_vector import Vector2


@pytest.mark.parametrize("x, y, expected", [
    (Vector2(6, 1), 0, Vector2(0, 0)),
    (Vector2(6, 1), 2, Vector2(12, 2)),
    (Vector2(0, 0), 3, Vector2(0, 0)),
    (Vector2(-1.5, 2.4), -2, Vector2(3.0, -4.8)),
    (Vector2(1, 2), 0.1, Vector2(0.1, 0.2))
])
def test_scalar_multiplication(x, y, expected):
    assert x * y == expected


@given(
    x=floats(min_value=-1e75, max_value=1e75),
    y=floats(min_value=-1e75, max_value=1e75),
    v=vectors(max_magnitude=1e150)
)
def test_scalar_associative(x: float, y: float, v: Vector2):
    left  = (x * y) * v
    right =  x * (y * v)
    assert left.isclose(right)

## Instruction:
Add a test of the linearity of scalar multiplication
## Code After:
import pytest  # type: ignore
from hypothesis import given
from hypothesis.strategies import floats
from utils import vectors
from ppb_vector import Vector2


@pytest.mark.parametrize("x, y, expected", [
    (Vector2(6, 1), 0, Vector2(0, 0)),
    (Vector2(6, 1), 2, Vector2(12, 2)),
    (Vector2(0, 0), 3, Vector2(0, 0)),
    (Vector2(-1.5, 2.4), -2, Vector2(3.0, -4.8)),
    (Vector2(1, 2), 0.1, Vector2(0.1, 0.2))
])
def test_scalar_multiplication(x, y, expected):
    assert x * y == expected


@given(
    x=floats(min_value=-1e75, max_value=1e75),
    y=floats(min_value=-1e75, max_value=1e75),
    v=vectors(max_magnitude=1e150)
)
def test_scalar_associative(x: float, y: float, v: Vector2):
    left  = (x * y) * v
    right =  x * (y * v)
    assert left.isclose(right)

@given(
    l=floats(min_value=-1e150, max_value=1e150),
    x=vectors(max_magnitude=1e150),
    y=vectors(max_magnitude=1e150),
)
def test_scalar_linear(l: float, x: Vector2, y: Vector2):
    assert (l * (x + y)).isclose(l*x + l*y)
