Skip to content

Commit

Permalink
tests: Uniformize the variable names for angles
Browse files Browse the repository at this point in the history
  • Loading branch information
nbraud committed Jan 1, 2019
1 parent c35e7b7 commit 41bfd8c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/test_vector2_rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def test_for_exception():

@given(angle=angles())
def test_trig_stability(angle):
"""cos² + sin² == 1
We are testing that this equation holds, as otherwise rotations
would (slightly) change the length of vectors they are applied to.
"""
r = math.radians(angle)
r_cos, r_sin = Vector2._trig(angle)

# Don't use exponents here. Multiplication is generally more stable.
Expand All @@ -58,17 +64,17 @@ def test_rotation_angle(initial, angle):
assert angle_isclose(angle, measured_angle)


@given(increment=angles(), loops=st.integers(min_value=0, max_value=500))
def test_rotation_stability(increment, loops):
@given(angle=angles(), loops=st.integers(min_value=0, max_value=500))
def test_rotation_stability(angle, loops):
"""Rotating loops times by angle is equivalent to rotating by loops*angle."""
initial = Vector2(1, 0)

fellswoop = initial.rotate(increment * loops)
fellswoop = initial.rotate(angle * loops)
note(f"One Fell Swoop: {fellswoop}")

stepwise = initial
for _ in range(loops):
stepwise = stepwise.rotate(increment)
stepwise = stepwise.rotate(angle)
note(f"Step-wise: {stepwise}")

assert fellswoop.isclose(stepwise)
Expand Down

0 comments on commit 41bfd8c

Please sign in to comment.