Пример #1
0
 def test_missing_kwargs(self, swarm, options, vh_strat):
     """Test if method raises KeyError with missing kwargs"""
     vh = VelocityHandler(strategy=vh_strat)
     with pytest.raises(KeyError):
         swarm.options = options
         clamp = (0, 1)
         P.compute_velocity(swarm, clamp, vh)
Пример #2
0
 def test_return_values(self, swarm, clamp):
     """Test if method gives the expected shape and range"""
     vh = VelocityHandler(strategy="unmodified")
     v = P.compute_velocity(swarm, clamp, vh)
     assert v.shape == swarm.position.shape
     if clamp is not None:
         assert (clamp[0] <= v).all() and (clamp[1] >= v).all()
Пример #3
0
def test_compute_velocity_return_values(swarm, clamp):
    """Test if compute_velocity() gives the expected shape and range"""
    v = P.compute_velocity(swarm, clamp)
    assert v.shape == swarm.position.shape
    if clamp is not None:
        assert (clamp[0] <= v).all() and (clamp[1] >= v).all()
Пример #4
0
 def test_input_swarm(self, swarm, vh_strat):
     """Test if method raises AttributeError with wrong swarm"""
     vh = VelocityHandler(strategy=vh_strat)
     with pytest.raises(AttributeError):
         P.compute_velocity(swarm, clamp=(0, 1), vh=vh)