コード例 #1
0
def test_shape():
    shape = (16, 16)
    wator = WaTor(shape=shape, nfish=16, nsharks=4)
    print(wator.creatures)
    assert wator.creatures.shape == shape
    assert wator.count_fish() == 16
    assert wator.count_sharks() == 4
    assert ((wator.creatures >= -10) & (wator.creatures <= 5)).all()
コード例 #2
0
def test_creatures():
    creatures = numpy.zeros((8, 8))
    creatures[2, 4] = 3
    creatures[1, :] = -5
    wator = WaTor(creatures)
    print(wator.creatures)
    assert (creatures == wator.creatures).all()
    assert wator.count_fish() == 1
    assert wator.count_sharks() == 8
コード例 #3
0
def test_shape_full_of_something():
    shape = (16, 16)
    total = 16 * 16
    nfish = total // 5
    nsharks = total - nfish
    wator = WaTor(shape=shape, nfish=nfish, nsharks=nsharks)
    print(wator.creatures)
    assert wator.count_fish() == nfish
    assert wator.count_sharks() == nsharks
コード例 #4
0
def test_shape_custom_age():
    shape = (16, 16)
    age_fish = 2
    age_shark = 20
    wator = WaTor(shape=shape,
                  nfish=16,
                  nsharks=4,
                  age_fish=age_fish,
                  age_shark=age_shark)
    print(wator.creatures)
    assert wator.creatures.shape == shape
    assert wator.count_fish() == 16
    assert wator.count_sharks() == 4
    assert ((wator.creatures >= -age_shark) &
            (wator.creatures <= age_fish)).all()
コード例 #5
0
ファイル: test_wator_speed.py プロジェクト: podondra/wator
def test_random_geenerator_speed():
    for i in range(20):
        wator = WaTor(shape=SHAPE, nfish=N, nsharks=N)
        print(i)
        assert wator.count_fish() == N
        assert wator.count_sharks() == N
コード例 #6
0
def test_shape_full_of_shark():
    shape = (16, 16)
    wator = WaTor(shape=shape, nfish=0, nsharks=16 * 16)
    print(wator.creatures)
    assert wator.count_fish() == 0
    assert wator.count_sharks() == 16 * 16