Ejemplo n.º 1
0
    def test_angle(self, x, y, expected_angle):
        """
        Verifies the standardized angle returned by the angle method
        of the agents with position components `x` and `y`.
        """
        angles = AgentMovement.angle(x, y)

        assert round(angles, decimals=10) == round(expected_angle, decimals=10)
Ejemplo n.º 2
0
    def test_init_required_fields_angles(self, set_up,
                                         fixture_init_required_fields):
        """
        Verifies whether the angles of the velocities of the agents are
        positives and minors than 2*pi.
        """
        dist_title = fixture_init_required_fields[0]
        group_info = fixture_init_required_fields[1]

        mobility_groups = MobilityGroups(dist_title=dist_title,
                                         group_info=group_info)
        df = DataFrame({
            "mobility_group": ["MG_1" for i in range(15)],
            "agent": [i for i in range(15)],
            "step": [i for i in range(15)]
        })
        df = AgentMovement.init_required_fields(df, pytest.box_size,
                                                mobility_groups)
        angles = Series(
            AgentMovement.angle(vx, vy)
            for (vx, vy) in zip(df["vx"], df["vy"]))

        assert all(angles.lt(2 * pi))
        assert all(angles.ge(0))