def test_set_velocities_raise_error(self, fixture_set_velocities): """ Raises a ValueError when `vy` column is not in the input DataFrame. """ distribution = fixture_set_velocities[0] df = DataFrame({"vx": [1, 2, 0, -1, -1]}) with pytest.raises(ValueError): AgentMovement.set_velocities(df, distribution, 0.1)
def test_set_velocities(self, fixture_set_velocities): """ Verifies whether set_velocities method assigns correctly new velocities to the agents of a DataFrame, using a constant distribution for the norm of the velocities and a None `angle_distribution`. """ distribution = fixture_set_velocities[0] df = DataFrame({"vx": [1, 2, 0, -1, -1], "vy": [0, 2, 1, 0, 1]}) df = AgentMovement.set_velocities(df, distribution, 0.1) expected_df = DataFrame({"vx": pytest.vx, "vy": pytest.vy}) assert all(round(df, 10) == round(expected_df, 10))