• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.zip函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stdnet.utils.zip函数的典型用法代码示例。如果您正苦于以下问题:Python zip函数的具体用法?Python zip怎么用?Python zip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了zip函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create

 def create(self, test):
     session = test.session()
     with session.begin() as t:
         for name, typ, ccy in zip(self.inames, self.itypes, self.iccys):
             t.add(Instrument(name=name, type=typ, ccy=ccy))
         for name in self.gnames:
             t.add(Group(name=name))
         for name, ccy in zip(self.inames, self.iccys):
             t.add(Fund(name=name, ccy=ccy))
     yield t.on_result
     iall = yield test.session().query(Instrument).load_only('id').all()
     fall = yield test.session().query(Fund).load_only('id').all()
     with session.begin() as t:
         for i in iall:
             t.add(ObjectAnalytics(model_type=Instrument, object_id=i.id))
         for i in fall:
             t.add(ObjectAnalytics(model_type=Fund, object_id=i.id))
     yield t.on_result
     obj_len = self.size[1]
     groups = yield session.query(Group).all()
     objs = yield session.query(ObjectAnalytics).all()
     groups = self.populate('choice', obj_len, choice_from=groups)
     objs = self.populate('choice', obj_len, choice_from=objs)
     with test.session().begin() as t:
         for g, o in zip(groups, objs):
             t.add(AnalyticData(group=g, object=o))
     yield t.on_result
开发者ID:AlecTaylor,项目名称:python-stdnet,代码行数:27,代码来源:get_field.py


示例2: create

 def create(self, test, use_transaction=True):
     session = test.session()
     models = test.mapper
     eq = assertEqual if isinstance(test, type) else test.assertEqual
     c = yield models.instrument.query().count()
     eq(c, 0)
     if use_transaction:
         with session.begin() as t:
             for name, ccy in zip(self.fund_names, self.fund_ccys):
                 t.add(models.fund(name=name, ccy=ccy))
             for name, typ, ccy in zip(self.inst_names, self.inst_types,
                                       self.inst_ccys):
                 t.add(models.instrument(name=name, type=typ, ccy=ccy))
         yield t.on_result
     else:
         test.register()
         for name, typ, ccy in zip(self.inst_names, self.inst_types,
                                   self.inst_ccys):
             yield models.instrument.new(name=name, type=typ, ccy=ccy)
         for name, ccy in zip(self.fund_names, self.fund_ccys):
             yield models.fund(name=name, ccy=ccy)
     self.num_insts = yield models.instrument.query().count()
     self.num_funds = yield models.fund.query().count()
     eq(self.num_insts, len(self.inst_names))
     eq(self.num_funds, len(self.fund_names))
     yield session
开发者ID:AlecTaylor,项目名称:python-stdnet,代码行数:26,代码来源:data.py


示例3: load_related

    def load_related(self, result):
        '''load related fields into the query result.

:parameter result: a result from a queryset.
:rtype: the same queryset qith related models loaded.'''
        if self.qs.select_related:
            if not hasattr(result,'__len__'):
                result = list(result)
            meta = self.meta
            for field in self.qs.select_related:
                name = field.name
                attname = field.attname
                vals = [getattr(r,attname) for r in result]
                if field in meta.scalarfields:
                    related = field.relmodel.objects.filter(id__in = vals)
                    for r,val in zip(result,related):
                        setattr(r,name,val)
                else:
                    with self.backend.transaction() as t:
                        for val in vals:
                            val.reload(t)
                    for val,r in zip(vals,t.get_result()):
                        val.set_cache(r)
                        
        return result
开发者ID:kuno,项目名称:python-stdnet,代码行数:25,代码来源:base.py


示例4: setUp

 def setUp(self):
     '''Create Instruments and Funds'''
     session = self.session()
     with session.begin():
         for name,typ,ccy in zip(inst_names,inst_types,inst_ccys):
             session.add(Instrument(name = name, type = typ, ccy = ccy))
         for name,ccy in zip(fund_names,fund_ccys):
             session.add(Fund(name = name, ccy = ccy))
开发者ID:kuno,项目名称:python-stdnet,代码行数:8,代码来源:finance.py


示例5: as_dict

def as_dict(times, fields):
    lists = []
    names = []
    d = {}
    for name, value in fields.items():
        names.append(name)
        lists.append(value)
    for dt, data in zip(times, zip(*lists)):
        d[dt] = dict(zip(names, data))
    return d
开发者ID:AlecTaylor,项目名称:python-stdnet,代码行数:10,代码来源:models.py


示例6: generate

 def generate(self):
     self.dates = self.populate('date')
     self.values = self.populate('float', start=10, end=400)
     self.dates2 = self.populate('date', start=date(2009,1,1),
                                         end=date(2010,1,1))
     self.big_strings = self.populate(min_len=300, max_len=1000)
     self.alldata   = list(zip(self.dates, self.values))
     self.alldata2  = list(zip(self.dates2, self.values))
     self.testdata  = dict(self.alldata)
     self.testdata2 = dict(self.alldata2)
开发者ID:AlecTaylor,项目名称:python-stdnet,代码行数:10,代码来源:timeseries.py


示例7: unwind_query

 def unwind_query(self, meta, qset):
     """Unwind queryset"""
     table = meta.table()
     ids = list(qset)
     make_object = self.make_object
     for id, data in zip(ids, table.mget(ids)):
         yield make_object(meta, id, data)
开发者ID:kuno,项目名称:python-stdnet,代码行数:7,代码来源:redisb.py


示例8: create_one

 def create_one(self):
     ts = self.structure()
     ts.update(zip(self.data.dates, self.data.values))
     self.assertFalse(ts.cache.cache)
     self.assertTrue(ts.cache.toadd)
     self.assertFalse(ts.cache.toremove)
     return ts
开发者ID:AlecTaylor,项目名称:python-stdnet,代码行数:7,代码来源:ts.py


示例9: setUp

 def setUp(self):
     size = self.sizes.get(getattr(self,'test_size','normal'))
     inst_names = populate('string',size, min_len = 5, max_len = 20)
     inst_types = populate('choice',size, choice_from = insts_types)
     inst_ccys  = populate('choice',size, choice_from = ccys_types)
     with transaction(Instrument) as t:
         for name,typ,ccy in zip(inst_names,inst_types,inst_ccys):
             Instrument(name = name, type = typ, ccy = ccy).save(t)
开发者ID:kuno,项目名称:python-stdnet,代码行数:8,代码来源:filter.py


示例10: testPushBack

 def testPushBack(self):
     li = SimpleList().save()
     names = li.names
     for elem in elems:
         names.push_back(elem)
     li.save()
     for el,ne in zip(elems,names):
         self.assertEqual(el,ne)
开发者ID:kuno,项目名称:python-stdnet,代码行数:8,代码来源:list.py


示例11: testPushFront

 def testPushFront(self):
     li = SimpleList().save()
     names = li.names
     for elem in reversed(elems):
         names.push_front(elem)
     li.save()
     for el,ne in zip(elems,names):
         self.assertEqual(el,ne)
开发者ID:kuno,项目名称:python-stdnet,代码行数:8,代码来源:list.py


示例12: zset_score_pairs

def zset_score_pairs(response, **options):
    """
    If ``withscores`` is specified in the options, return the response as
    a list of (value, score) pairs
    """
    if not response or not options['withscores']:
        return response
    return zip(response[::2], map(float, response[1::2]))
开发者ID:kuno,项目名称:python-stdnet,代码行数:8,代码来源:redis.py


示例13: _wrap_commit

 def _wrap_commit(self, request, response, iids=None, **options):
     for id, iid in zip(response, iids):
         id, flag, info = id
         if int(flag):
             yield instance_session_result(iid, True, id, False, float(info))
         else:
             msg = info.decode(request.encoding)
             yield CommitException(msg)
开发者ID:abulte,项目名称:python-stdnet,代码行数:8,代码来源:redisb.py


示例14: callback

 def callback(self, response, args, session=None):
     # The session has received the callback from redis client
     data = []
     for instance, id in list(zip(session, response)):
         instance = session.server_update(instance, id)
         if instance:
             data.append(instance)
     return data
开发者ID:kuno,项目名称:python-stdnet,代码行数:8,代码来源:redisb.py


示例15: setUp

 def setUp(self):
     '''Create Instruments and Funds commiting at the end for speed'''
     session = self.session()
     with session.begin():
         session.add(Dictionary(name='test'))
         session.add(Dictionary(name='test2'))
     self.assertEqual(session.query(Dictionary).count(),2)
     self.data = dict(zip(dict_keys,dict_values))
开发者ID:abulte,项目名称:python-stdnet,代码行数:8,代码来源:delete.py


示例16: testPushFront

 def testPushFront(self):
     li = SimpleList().save()
     if li.session.backend.name == 'redis':
         names = li.names
         for elem in reversed(elems):
             names.push_front(elem)
         li.save()
         for el,ne in zip(elems,names):
             self.assertEqual(el,ne)
开发者ID:abulte,项目名称:python-stdnet,代码行数:9,代码来源:struct.py


示例17: testPushBack

 def testPushBack(self):
     li = SimpleList().save()
     with li.session.begin():
         names = li.names
         for elem in elems:
             names.push_back(elem)
     for el, ne in zip(elems, names):
         self.assertEqual(el, ne)
     self.assertEqual(li.names.size(), len(elems))
开发者ID:abulte,项目名称:python-stdnet,代码行数:9,代码来源:struct.py


示例18: _load_missing_scripts

def _load_missing_scripts(results, positions, res):
    for i,r in zip(positions,res):
        if i == -1:
            if isinstance(r, Exception):
                raise r
            else:
                continue
        results[i] = r
    return results
开发者ID:abulte,项目名称:python-stdnet,代码行数:9,代码来源:scripts.py


示例19: pairs_to_dict

def pairs_to_dict(response, encoding, value_encoder=0):
    "Create a dict given a list of key/value pairs"
    if response:
        v1 = (r.decode(encoding) for r in response[::2])
        v2 = response[1::2]
        if value_encoder:
            v2 = (value_encoder(v) for v in v2)
        return zip(v1,v2)
    else:
        return ()
开发者ID:abulte,项目名称:python-stdnet,代码行数:10,代码来源:scripts.py


示例20: testData

 def testData(self):
     ts = orm.TS()
     ts.update(zip(dates,values))
     ts.save()
     self.assertEqual(ts.size(),len(dates))
     front = ts.front()
     back = ts.back()
     self.assertTrue(back>front)
     range = list(ts.range(date(2009,10,1),date(2010,5,1)))
     self.assertTrue(range)
开发者ID:kuno,项目名称:python-stdnet,代码行数:10,代码来源:struct.py



注:本文中的stdnet.utils.zip函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.clean函数代码示例发布时间:2022-05-27
下一篇:
Python msg.String类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap