def test_replace_velocities_norm_equal_zero( self, fixture_replace_velocities_norm_equal_to_zero): """ Verifies the replace velocity function when one agent has its velocity norm equal to zero. """ new_angle = Series(pytest.new_angle) df = DataFrame(pytest.data) df = df.apply( lambda row: AgentMovement.replace_velocities(row, new_angle), axis=1) assert df.vx[0] == df.vy[0] == 0
def test_replace_velocities_same_components( self, fixture_replace_velocities_same_components): """ Verifies the replace velocity function on three different agents with the same velocities components. """ new_angles = Series(pytest.new_angles_data) df = DataFrame(pytest.data) df = df.apply( lambda row: AgentMovement.replace_velocities(row, new_angles), axis=1) assert all(df.vy == sqrt(2) * sin(pi)) assert all(df.vx == sqrt(2) * cos(pi))
def test_replace_velocities_different_components( self, fixture_replace_velocities_different_components): """ Verifies the replace velocity function on three different agents with different angles and components. """ new_angles = Series(pytest.new_angles_data) df = DataFrame(pytest.data) df = df.apply( lambda row: AgentMovement.replace_velocities(row, new_angles), axis=1) for i in range(len(pytest.new_angles_list)): assert df.vx[i] == sqrt(2 * i) * cos(pytest.new_angles_list[i]) assert df.vy[i] == sqrt(2 * i) * sin(pytest.new_angles_list[i])