<commit_before>
# import pytest
from pyfrc.physics import tankmodel, motor_cfgs
from pyfrc.physics.units import units
from math import degrees, radians, isclose


def test_tankdrive_get_distance():
    '''Test TankModel.get_distance() by driving in a quarter circle.
    If the turn angle is 90deg, then x should equal y. get_distance() runs in little steps,
    so multiple calls should be equivalent to a single call'''

    # just use the default robot
    tank = tankmodel.TankModel.theory(motor_cfgs.MOTOR_CFG_CIM,
                                      robot_mass=90*units.lbs,
                                      gearing=10.71,
                                      nmotors=2,
                                      x_wheelbase=2.0*units.feet,
                                      wheel_diameter=6*units.inch)
    # slight turn to the right
    l_motor = -1.0
    r_motor = 0.9

    # get the motors up to speed, so that subsequent calls produce the same result
    tank.get_distance(l_motor, r_motor, 2.0)

    # figure out how much time is needed to turn 90 degrees
    angle = 0.0
    angle_target = radians(90.0)
    total_time = 0.0
    tstep = 0.01

    while angle < angle_target:
        result = tank.get_distance(l_motor, r_motor, tstep)
        angle += result[2]
        total_time += tstep

    # print('time needed', total_time)

    # OK, now do it in a single call. x should equal y
    result = tank.get_distance(l_motor, r_motor, total_time)
    # print(result[0], result[1], degrees(result[2]), result[0]/result[1])
    assert isclose(degrees(result[2]), 90.0, abs_tol=2.0), 'Single call did not produce a 90deg turn'
    assert isclose(result[0], result[1], rel_tol=0.01), 'For 90deg turn, x and y should be the same'
    return<commit_msg>A little more clean up for the pull request.<commit_after>
# import pytest
from pyfrc.physics import tankmodel, motor_cfgs
from pyfrc.physics.units import units
import math


def test_tankdrive_get_distance():
    '''Test TankModel.get_distance() by driving in a quarter circle.
    If the turn angle is 90deg, then x should equal y. get_distance() runs in little steps,
    so multiple calls should be equivalent to a single call'''

    # just use the default robot
    tank = tankmodel.TankModel.theory(motor_cfgs.MOTOR_CFG_CIM,
                                      robot_mass=90*units.lbs,
                                      gearing=10.71,
                                      nmotors=2,
                                      x_wheelbase=2.0*units.feet,
                                      wheel_diameter=6*units.inch)
    # slight turn to the right
    l_motor = -1.0
    r_motor = 0.9

    # get the motors up to speed, so that subsequent calls produce the same result
    tank.get_distance(l_motor, r_motor, 2.0)

    # figure out how much time is needed to turn 90 degrees
    angle = 0.0
    angle_target = math.pi / 2.0 # 90 degrees
    total_time = 0.0
    tstep = 0.01

    while angle < angle_target:
        result = tank.get_distance(l_motor, r_motor, tstep)
        angle += result[2]
        total_time += tstep

    # print('time needed', total_time)

    # OK, now do it in a single call. x should equal y
    result = tank.get_distance(l_motor, r_motor, total_time)
    # print(result[0], result[1], degrees(result[2]), result[0]/result[1])
    assert math.isclose(result[2], angle_target, abs_tol=2.0), 'Single call should produce a 90deg turn'
    assert math.isclose(result[0], result[1], rel_tol=0.01), 'For 90deg turn, x and y should be the same'
    return
{'fraction_non_alphanumeric': 0.08630868709586731, 'fraction_numerical': 0.028113578858588697, 'mean_word_length': 2.285318559556787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7114891', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1079, 'n_words': 349}