本文整理汇总了Python中asq.queryables.Queryable类的典型用法代码示例。如果您正苦于以下问题:Python Queryable类的具体用法?Python Queryable怎么用?Python Queryable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Queryable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_deferred
def test_select_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).select(lambda x: x*2)
self.assertEqual(a.trace, [])
c = b.take(3).to_list()
self.assertEqual(a.trace, [0, 1, 2])
示例2: test_take_is_deferred
def test_take_is_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).take()
self.assertEqual(a.trace, [])
c = b.to_list()
self.assertEqual(a.trace, [0])
示例3: test_select_many_with_index_closed
def test_select_many_with_index_closed(self):
a = [{'name' : 'Alice', 'flowers' : ['Agapanthus', 'Allium', 'Alpina', 'Alstroemeria', 'Amaranthus', 'Amarylis' ] },
{'name' : 'Bob', 'flowers' : ['Bouvardia' ]},
{'name' : 'Chris', 'flowers' : ['Carnations', 'Cattleya', 'Celosia', 'Chincherinchee', 'Chrysanthemum']}]
b = Queryable(a)
b.close()
self.assertRaises(ValueError, lambda: b.select_many_with_index(lambda i, x: [str(i) + flower for flower in x['flowers']]))
示例4: test_select_with_index_deferred
def test_select_with_index_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).select_with_index()
self.assertEqual(a.trace, [])
b.take(3).to_list()
self.assertEqual(a.trace, [0, 1, 2])
示例5: test_select_with_corresponding_deferred
def test_select_with_corresponding_deferred(self):
a = TracingGenerator()
self.assertListEqual(a.trace, [])
b = Queryable(a).select_with_correspondence(lambda x: x * 2)
self.assertListEqual(a.trace, [])
b.take(3).to_list()
self.assertListEqual(a.trace, list(range(3)))
示例6: test_group_join_is_deferred
def test_group_join_is_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = [2, 3, 4, 5, 6]
c = Queryable(a).group_join(b)
self.assertEqual(a.trace, [])
d = c.take(3).to_list()
示例7: test_select_many_deferred
def test_select_many_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).select_many(lambda x: [x] * x)
self.assertEqual(a.trace, [])
b.take(10).to_list()
self.assertEqual(a.trace, [0, 1, 2, 3, 4])
示例8: test_default_if_empty_is_deferred_not_empty
def test_default_if_empty_is_deferred_not_empty(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).default_if_empty(42)
self.assertEqual(a.trace, [])
c = b.take(3).to_list()
self.assertEqual(a.trace, [0, 1, 2])
示例9: test_skip_is_deferred
def test_skip_is_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).skip(3)
self.assertEqual(a.trace, [])
c = b.take().to_list()
self.assertEqual(a.trace, [0, 1, 2, 3])
示例10: test_where_deferred
def test_where_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).where(lambda x: x % 3 == 0)
self.assertEqual(a.trace, [])
c = b.take(2).to_list()
self.assertEqual(a.trace, [0, 1, 2, 3])
示例11: test_select_many_with_index_deferred
def test_select_many_with_index_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).select_many_with_index(lambda index, source_element: [source_element] * index)
self.assertEqual(a.trace, [])
b.take(10).to_list()
self.assertEqual(a.trace, [0, 1, 2, 3, 4])
示例12: test_join_is_deferred
def test_join_is_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = [2, 3, 4, 5, 6]
c = Queryable(a).join(b)
self.assertEqual(a.trace, [])
d = c.take(3).to_list()
e = [(2, 2), (3, 3), (4, 4)]
self.assertEqual(d, e)
示例13: test_take_while_is_deferred
def test_take_while_is_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = Queryable(a).take_while(lambda x: x < 3)
self.assertEqual(a.trace, [])
c = b.to_list()
# 3 is included here in the trace because it must have been consumed in order to test
# whether it satisfies the predicate
self.assertEqual(a.trace, [0, 1, 2, 3])
示例14: test_union_deferred
def test_union_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = [3, 7, 2, 9, 10]
c = Queryable(a).union(b)
self.assertEqual(a.trace, [])
d = c.take(5).to_list()
e = [0, 1, 2, 3, 4]
self.assertEqual(a.trace, e)
示例15: test_difference_deferred
def test_difference_deferred(self):
a = TracingGenerator()
self.assertEqual(a.trace, [])
b = [3, 7, 2, 9, 10]
c = Queryable(a).difference(b)
self.assertEqual(a.trace, [])
d = c.take(10).to_list()
e = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
self.assertEqual(a.trace, e)