当前位置: 首页>>代码示例>>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;未经允许,请勿转载。