Skip to content

Commit

Permalink
rename tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Jan 25, 2023
1 parent 546e08f commit 867cb3a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
RELATIVE_TOLERANCE = 1e-12


@pytest.mark.parametrize('trial', range(50))
def test_matching_naive_algorithm(trial):
@pytest.mark.parametrize('trial', range(10))
def test_circle_matching_naive_algorithm(trial):
points = _random_points(random.randint(1, 30))

reference_circle = _smallest_enclosing_circle_naive(points)
Expand All @@ -20,36 +20,36 @@ def test_matching_naive_algorithm(trial):
assert test_circle.almost_equals(reference_circle, delta=RELATIVE_TOLERANCE)


@pytest.mark.parametrize('trial', range(50))
def test_translation(trial):
@pytest.mark.parametrize('trial', range(10))
def test_circle_translation(trial):
points = _random_points(random.randint(1, 300))

reference_circle = Circle.from_points(points)
test_circle = Circle.from_points(points)

dx = random.gauss(0, 1)
dy = random.gauss(0, 1)
translated_points = [(x + dx, y + dy) for (x, y) in points]

translated_circle = Circle.from_points(translated_points)
translated_reference_circle = reference_circle + (dx, dy)
reference_circle = test_circle + (dx, dy)

assert translated_circle.almost_equals(translated_reference_circle, delta=RELATIVE_TOLERANCE)
assert translated_circle.almost_equals(reference_circle, delta=RELATIVE_TOLERANCE)


@pytest.mark.parametrize('trial', range(50))
def test_scaling(trial):
@pytest.mark.parametrize('trial', range(10))
def test_circle_scaling(trial):
points = _random_points(random.randint(1, 300))

reference_circle = Circle.from_points(points)
test_circle = Circle.from_points(points)

scale = random.gauss(0, 1)
scaled_points = [(x * scale, y * scale) for (x, y) in points]

scaled_circle = Circle.from_points(scaled_points)
scaled_reference_circle = Circle((reference_circle.center[0] * scale, reference_circle.center[1] * scale),
reference_circle.radius * abs(scale))
reference_circle = Circle((test_circle.center[0] * scale, test_circle.center[1] * scale),
test_circle.radius * abs(scale))

assert scaled_circle.almost_equals(scaled_reference_circle, delta=RELATIVE_TOLERANCE)
assert scaled_circle.almost_equals(reference_circle, delta=RELATIVE_TOLERANCE)


def _random_points(n: int) -> List[Tuple[float, float]]:
Expand Down

0 comments on commit 867cb3a

Please sign in to comment.