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


Python Dataset.where方法代碼示例

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


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

示例1: test_where_dupe_dimension

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import where [as 別名]
def test_where_dupe_dimension():
    def clause(x):
        return True
    dataset = Dataset('test-bucket', ['dim1', 'dim2'], prefix='prefix/',
                      clauses={'dim1': clause})

    with pytest.raises(Exception) as exc_info:
        dataset.where(dim1=clause)

    assert str(exc_info.value) == 'There should be only one clause for dim1'
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:12,代碼來源:test_dataset.py

示例2: test_where_wrong_dimension

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import where [as 別名]
def test_where_wrong_dimension():
    dataset = Dataset('test-bucket', ['dim1', 'dim2'], prefix='prefix/')

    def clause(x):
        return True

    with pytest.raises(Exception) as exc_info:
        dataset.where(dim3=clause)

    assert str(exc_info.value) == 'The dimension dim3 doesn\'t exist'
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:12,代碼來源:test_dataset.py

示例3: test_scan_multiple_params

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import where [as 別名]
def test_scan_multiple_params():
    dataset = Dataset('test-bucket', ['dim1', 'dim2'], prefix='prefix/')
    new_dataset = dataset.where(dim1='myvalue')
    assert new_dataset is not dataset
    assert list(new_dataset.clauses.keys()) == ['dim1']
    condition = new_dataset.clauses['dim1']
    assert condition('myvalue')
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:9,代碼來源:test_dataset.py

示例4: test_where_exact_match

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import where [as 別名]
def test_where_exact_match():
    dataset = Dataset('test-bucket', ['dim1', 'dim2'], prefix='prefix/')
    new_dataset = dataset.where(dim1='my-value')
    assert new_dataset is not dataset
    assert new_dataset.clauses.keys() == ['dim1']
    condition = new_dataset.clauses['dim1']
    assert condition('my-value')
開發者ID:whd,項目名稱:python_moztelemetry,代碼行數:9,代碼來源:test_dataset.py

示例5: test_where

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import where [as 別名]
def test_where():
    dataset = Dataset('test-bucket', ['dim1', 'dim2'], prefix='prefix/')
    clause = lambda x: True
    new_dataset = dataset.where(dim1=clause)

    assert new_dataset is not dataset
    assert new_dataset.clauses == {'dim1': clause}
開發者ID:whd,項目名稱:python_moztelemetry,代碼行數:9,代碼來源:test_dataset.py

示例6: test_prefix_slash

# 需要導入模塊: from moztelemetry.dataset import Dataset [as 別名]
# 或者: from moztelemetry.dataset.Dataset import where [as 別名]
def test_prefix_slash(spark_context):
    bucket_name = 'test-bucket'
    store = InMemoryStore(bucket_name)
    store.store['a/b/dir1/subdir1/key1'] = 'value1'
    store.store['a/b/dir2/subdir2/key2'] = 'value2'
    store.store['x/b/dir3/subdir3/key3'] = 'value3'
    store.store['a/c/dir4/subdir4/key4'] = 'value4'

    dataset = Dataset(bucket_name, ['dim1', 'dim2'], store=store, prefix='a/b', max_concurrency=1)

    summaries = dataset.summaries(spark_context)
    assert len(summaries) == 2

    for item in summaries:
        assert item['key'] in store.store
        assert item['size'] == len(store.store[item['key']])

    # be sure "where" still works
    summaries_filtered = dataset.where(dim1='dir1').summaries(spark_context)
    assert len(summaries_filtered) == 1
    assert summaries_filtered[0]['key'] == 'a/b/dir1/subdir1/key1'
開發者ID:mozilla,項目名稱:python_moztelemetry,代碼行數:23,代碼來源:test_dataset.py


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