當前位置: 首頁>>代碼示例>>Python>>正文


Python FeatureCollection.loads方法代碼示例

本文整理匯總了Python中dossier.fc.FeatureCollection.loads方法的典型用法代碼示例。如果您正苦於以下問題:Python FeatureCollection.loads方法的具體用法?Python FeatureCollection.loads怎麽用?Python FeatureCollection.loads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dossier.fc.FeatureCollection的用法示例。


在下文中一共展示了FeatureCollection.loads方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_read_only_preserved_after_serialized

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_read_only_preserved_after_serialized():
    fc = FeatureCollection({'NAME': {'foo': 1, 'baz': 2}})
    fc.read_only = True
    fcnew = FeatureCollection.loads(fc.dumps())
    assert fcnew.read_only
    with pytest.raises(ReadOnlyException):
        fcnew['NAME']['foo'] += 1
開發者ID:brandontheis,項目名稱:dossier.fc,代碼行數:9,代碼來源:test_read_only.py

示例2: test_ft_roundtrip

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_ft_roundtrip():
    fc = FeatureCollection()
    fc['@NAME']['foo'].append([
        ('nltk', 5, 2),
    ])
    fc2 = FeatureCollection.loads(fc.dumps())
    assert fc['@NAME'] == fc2['@NAME']
開發者ID:brandontheis,項目名稱:dossier.fc,代碼行數:9,代碼來源:test_feature_tokens.py

示例3: test_nsc_roundtrip

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_nsc_roundtrip():
    fc = FeatureCollection()
    fc['#testing'] = NestedStringCounter()
    fc['#testing']['foo'] = StringCounter({'foo': 1})
    fc['#testing']['bar'] = StringCounter({'foo': 2, 'bar': 1})
    dumped = fc.dumps()
    assert FeatureCollection.loads(dumped) == fc
開發者ID:dossier,項目名稱:dossier.fc,代碼行數:9,代碼來源:test_nested_stringcounter.py

示例4: test_string_counter_serialize

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_string_counter_serialize():
    fc = FeatureCollection()
    fc['thing1'] = StringCounter()
    fc['thing1']['foo'] += 1
    fc_str = fc.dumps()

    fc2 = FeatureCollection.loads(fc_str)
    assert fc2['thing1']['foo'] == 1
開發者ID:brandontheis,項目名稱:dossier.fc,代碼行數:10,代碼來源:test_serialization.py

示例5: test_serialize_deserialize

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_serialize_deserialize(counter_type):
    ## build entity, serialize, deserialize, and verify its multisets
    ent1 = FeatureCollection()
    ent1["bow"] += counter_type(Counter(["big", "dog"]))
    ent1["bow"] += counter_type(Counter("tall building"))
    ent1["bon"] += counter_type(Counter(["Super Cat", "Small Cat", "Tiger Fish"]))

    blob = ent1.dumps()
    ent2 = FeatureCollection.loads(blob)
    assert_same_fc(ent1, ent2)
開發者ID:dossier,項目名稱:dossier.fc,代碼行數:12,代碼來源:test_feature_collection.py

示例6: test_serialize_deserialize

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_serialize_deserialize(counter_type):
    ## build entity, serialize, deserialize, and verify its multisets
    ent1 = FeatureCollection()
    ent1['bow'] += counter_type(Counter(['big', 'dog']))
    ent1['bow'] += counter_type(Counter('tall building'))
    ent1['bon'] += counter_type(Counter(['Super Cat', 'Small Cat',
                                         'Tiger Fish']))

    blob = ent1.dumps()
    ent2 = FeatureCollection.loads(blob)
    assert_same_fc(ent1, ent2)
開發者ID:brianolson,項目名稱:dossier.fc,代碼行數:13,代碼來源:test_feature_collection.py

示例7: test_entity

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_entity(counter_type):
    ## build entity, serialize, deserialize, and verify its multisets
    fc1 = FeatureCollection()
    fc1['bow'] += counter_type(Counter(['big', 'dog']))
    fc1['bow'] += counter_type(Counter('tall building'))
    fc1['bon'] += counter_type(Counter(['Super Cat', 'Small Cat', 'Tiger Fish']))

    ## there should be nine items of size 1
    assert Counter(fc1['bow'].values())[1] == 10, fc1['bow'].items()

    ## double the counts, should recurse down
    fc1 += fc1

    ## check values doubled
    assert Counter(fc1['bow'].values())[2] == 10, fc1['bow'].items()

    ## serialize/deserialize it
    blob = fc1.dumps()
    assert_same_fc(fc1, FeatureCollection.loads(blob))

    ## deserialize it via chunk
    fc2 = FeatureCollection.loads(fc1.dumps())
    assert_same_fc(fc1, fc2)
開發者ID:brianolson,項目名稱:dossier.fc,代碼行數:25,代碼來源:test_feature_collection.py

示例8: test_entity

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_entity(counter_type):
    ## build entity, serialize, deserialize, and verify its multisets
    fc1 = FeatureCollection()
    fc1["bow"] += counter_type(Counter(["big", "dog"]))
    fc1["bow"] += counter_type(Counter("tall building"))
    fc1["bon"] += counter_type(Counter(["Super Cat", "Small Cat", "Tiger Fish"]))

    ## there should be nine items of size 1
    assert Counter(map(abs, fc1["bow"].values()))[1] == 10, fc1["bow"].items()

    ## double the counts, should recurse down
    fc1 += fc1

    ## check values doubled
    assert Counter(map(abs, fc1["bow"].values()))[2] == 10, fc1["bow"].items()

    ## serialize/deserialize it
    blob = fc1.dumps()
    assert_same_fc(fc1, FeatureCollection.loads(blob))

    ## deserialize it via chunk
    fc2 = FeatureCollection.loads(fc1.dumps())
    assert_same_fc(fc1, fc2)
開發者ID:dossier,項目名稱:dossier.fc,代碼行數:25,代碼來源:test_feature_collection.py

示例9: test_json_serializer

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_json_serializer():
    with registry:
        registry.add('StringCounter', JsonSerializer)

        fc = FeatureCollection()
        fc['thing2'] = StringCounter(dict(hello='people'))
        fc['thing2']['another'] = 5
        fc['thing3'] = StringCounter(dict(hello='people2'))
        fc_str = fc.dumps()

        fc2 = FeatureCollection.loads(fc_str)

        assert fc2['thing2']['another'] == 5
        assert fc2['thing2']['hello'] == 'people'
        assert fc2['thing3']['hello'] == 'people2'
開發者ID:brandontheis,項目名稱:dossier.fc,代碼行數:17,代碼來源:test_serialization.py

示例10: test_thing_serializer

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_thing_serializer():
    with registry:
        registry.add('StringCounter', ThingSerializer)

        fc = FeatureCollection()
        fc['thing1'] = Thing(json.dumps(dict(hello='people')))
        fc['thing1']['another'] = 'more'
        fc['thing1'].do_more_things()
        fc_str = fc.dumps()

        fc2 = FeatureCollection.loads(fc_str)

        assert fc2['thing1']['another'] == 'more'
        assert fc2['thing1']['hello'] == 'people'
        assert fc2['thing1']['doing'] == 'something'
開發者ID:brandontheis,項目名稱:dossier.fc,代碼行數:17,代碼來源:test_serialization.py

示例11: perftest_throughput_feature_collection

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def perftest_throughput_feature_collection():
    with registry:
        registry.add('StringCounter', ThingSerializer)
        fc = FeatureCollection()
        fc['thing1'] = Thing(json.dumps(dict(one_mb=' ' * 2**20)))
        fc_str = fc.dumps()

        start_time = time.time()
        num = 1000
        for i in range(num):
            fc2 = FeatureCollection.loads(fc_str)
            fc2.dumps()
        elapsed = time.time() - start_time
        rate = float(num) / elapsed
        print('%d MB in %.1f sec --> %.1f MB per sec' % (num, elapsed, rate))
開發者ID:brandontheis,項目名稱:dossier.fc,代碼行數:17,代碼來源:performance.py

示例12: test_non_counter_features_serialize

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_non_counter_features_serialize():
    fc = FeatureCollection({'NAME': u'foobaz'})
    fc = FeatureCollection.loads(fc.dumps())
開發者ID:brianolson,項目名稱:dossier.fc,代碼行數:5,代碼來源:test_feature_collection.py

示例13: fc_loads

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def fc_loads(raw):
    return FeatureCollection.loads(snappy.decompress(raw))
開發者ID:dossier,項目名稱:dossier.store,代碼行數:4,代碼來源:store.py

示例14: test_geo_roundtrip

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_geo_roundtrip():
    fc = FeatureCollection()
    fc['!co_LOC']['foo'].append((-55, 22, 0, None))
    fc2 = FeatureCollection.loads(fc.dumps())
    assert fc['!co_LOC'] == fc2['!co_LOC']
開發者ID:dossier,項目名稱:dossier.fc,代碼行數:7,代碼來源:test_geocoords.py

示例15: test_unicode

# 需要導入模塊: from dossier.fc import FeatureCollection [as 別名]
# 或者: from dossier.fc.FeatureCollection import loads [as 別名]
def test_unicode():
    fc = FeatureCollection({'NAME': {'foo': 1}})
    fc = FeatureCollection.loads(fc.dumps())
    assert type(fc.keys()[0]) is unicode
    assert type(fc['NAME'].keys()[0]) is unicode
開發者ID:dossier,項目名稱:dossier.fc,代碼行數:7,代碼來源:test_counter.py


注:本文中的dossier.fc.FeatureCollection.loads方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。