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

Python collections.intersect函数代码示例

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

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



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

示例1: testEmptyIntersection

    def testEmptyIntersection(self):
        values, ix1, ix2 = collections.intersect([1, 2, 3], [4, 5, 6])
        self.assertEqual(len(values), 0)
        self.assertEqual(len(ix1), 0)
        self.assertEqual(len(ix2), 0)

        values, ix1, ix2 = collections.intersect([], [])
        self.assertEqual(len(values), 0)
        self.assertEqual(len(ix1), 0)
        self.assertEqual(len(ix2), 0)
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:10,代码来源:utils_test.py


示例2: testPartialIntersectionSkipNones

    def testPartialIntersectionSkipNones(self):
        v1 = [None, 1, None, None, 2, None, 3, None, 4]
        v2 = [1, None, 2, None, 3, 4]

        values, ix1, ix2 = collections.intersect(v1, v2, True)
        self.assertEqual(values, [1, 2, 3, 4])
        self.assertEqual(ix1, [1, 4, 6, 8])
        self.assertEqual(ix2, [0, 2, 4, 5])

        values, ix2, ix1 = collections.intersect(v2, v1, True)
        self.assertEqual(values, [1, 2, 3, 4])
        self.assertEqual(ix1, [1, 4, 6, 8])
        self.assertEqual(ix2, [0, 2, 4, 5])
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:13,代码来源:utils_test.py


示例3: testPartialIntersection6

    def testPartialIntersection6(self):
        v1 = [1, 1, 2, 2, 3, 3]
        v2 = [1, 2, 3]

        values, ix1, ix2 = collections.intersect(v1, v2)
        self.assertEqual(values, [1, 2, 3])
        self.assertEqual(ix1, [0, 2, 4])
        self.assertEqual(ix2, [0, 1, 2])

        values, ix2, ix1 = collections.intersect(v2, v1)
        self.assertEqual(values, [1, 2, 3])
        self.assertEqual(ix1, [0, 2, 4])
        self.assertEqual(ix2, [0, 1, 2])
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:13,代码来源:utils_test.py


示例4: update

	def update(self):
		if self.__isDirty():
			# Search for datetime intersections between the data series,
			# but start right after the last one found.
			ds1DateTimes = self.__ds1.getDecorated().getDateTimes()
			ds2DateTimes = self.__ds2.getDecorated().getDateTimes()
			if self.__lastPos1 != None:
				ds1DateTimes = ds1DateTimes[self.__lastPos1+1:]
			if self.__lastPos2 != None:
				ds2DateTimes = ds2DateTimes[self.__lastPos2+1:]

			# Calculate the intersections.
			dateTimes, pos1, pos2 = collections.intersect(ds1DateTimes, ds2DateTimes)

			# Update each array's relative position to make them absolute positions.
			if self.__lastPos1 != None and len(pos1):
				pos1 = [self.__lastPos1 + pos + 1 for pos in pos1]
			if self.__lastPos2 != None and len(pos2):
				pos2 = [self.__lastPos2 + pos + 1 for pos in pos2]

			# Update the last intersection.
			if len(pos1):
				self.__lastPos1 = pos1[-1]
			if len(pos2):
				self.__lastPos2 = pos2[-1]

			# Update the aligned data series.
			self.__ds1.update(dateTimes, pos1)
			self.__ds2.update(dateTimes, pos2)
			self.__resetDirty()
开发者ID:jacobirwin,项目名称:pyalgotrade,代码行数:30,代码来源:dataseries.py


示例5: testPartialIntersection2

 def testPartialIntersection2(self):
     values, ix1, ix2 = collections.intersect([1, 2, 4], [1, 2, 3])
     self.assertEqual(len(values), 2)
     self.assertEqual(values[0], 1)
     self.assertEqual(values[1], 2)
     self.assertEqual(ix1[0], 0)
     self.assertEqual(ix1[1], 1)
     self.assertEqual(ix2[0], 0)
     self.assertEqual(ix2[1], 1)
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:9,代码来源:utils_test.py


示例6: testFullIntersectionWithDateTimes

    def testFullIntersectionWithDateTimes(self):
        size = 1000
        dateTimes1 = []
        dateTimes2 = []
        now = datetime.datetime.now()
        for i in xrange(size):
            dateTimes1.append(now + datetime.timedelta(seconds=i))
            dateTimes2.append(now + datetime.timedelta(seconds=i))

        self.assertEqual(dateTimes1, dateTimes2)

        values, ix1, ix2 = collections.intersect(dateTimes1, dateTimes2)
        self.assertEqual(values, dateTimes1)
        self.assertEqual(values, dateTimes2)
        self.assertEqual(ix1, list(range(size)))
        self.assertEqual(ix1, ix2)
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:16,代码来源:utils_test.py


示例7: testFullIntersection

 def testFullIntersection(self):
     values, ix1, ix2 = collections.intersect([1, 2, 3], [1, 2, 3])
     self.assertEqual(len(values), 3)
     self.assertEqual(len(ix1), 3)
     self.assertEqual(len(ix2), 3)
     self.assertEqual(ix1, ix2)
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:6,代码来源:utils_test.py


示例8: testPartialIntersection5

 def testPartialIntersection5(self):
     values, ix1, ix2 = collections.intersect([1, 2, 3], [3, 6])
     self.assertEqual(len(values), 1)
     self.assertEqual(values[0], 3)
     self.assertEqual(ix1[0], 2)
     self.assertEqual(ix2[0], 0)
开发者ID:gansaihua,项目名称:pyalgotrade,代码行数:6,代码来源:utils_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python dt.as_utc函数代码示例发布时间:2022-05-25
下一篇:
Python yahoofinance.build_feed函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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