コード例 #1
0
def test_multiset_change(counter_type):
    ent1 = FeatureCollection()
    ent1['bow'] += counter_type(Counter(['big', 'dog']))
    ent1.pop('bow')
    assert dict(ent1.items()) == dict()

    ## can pop empty -- fails
    #ent1.pop('foo')

    ## set equal to
    test_data = ['big2', 'dog2']
    ent1['bow'] = counter_type(Counter(test_data))
    assert list(ent1['bow'].values()) == [1,1]

    ent1['bow'] += counter_type(Counter(test_data))
    assert list(ent1['bow'].values()) == [2,2]
コード例 #2
0
def test_multiset_change(counter_type):
    ent1 = FeatureCollection()
    ent1["bow"] += counter_type(Counter(["big", "dog"]))
    ent1.pop("bow")
    assert dict(ent1.items()) == dict()

    ## can pop empty -- fails
    # ent1.pop('foo')

    ## set equal to
    test_data = ["big2", "dog2"]
    ent1["bow"] = counter_type(Counter(test_data))
    assert list(map(abs, ent1["bow"].values())) == [1, 1]

    ent1["bow"] += counter_type(Counter(test_data))
    assert list(map(abs, ent1["bow"].values())) == [2, 2]