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

Python core.vstack函数代码示例

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

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



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

示例1: handleEvent

 def handleEvent(self, event):
     if event[0] == soya.sdlconst.QUIT:
         raise Exception
     elif event[0] == soya.sdlconst.MOUSEMOTION:
         if self.rightClicking:
             dx,dz = event[3],event[4] # mouse cursor movement
             self.alpha -= dx*0.02
             self.beta  -= dz*0.02
         elif not self.viewOnly:
             cube2dPositions = []
             for cubeCenter in self.cubeCenters:
                 cube3dPos = soya.Point(self.parent,cubeCenter[0],cubeCenter[1],cubeCenter[2])
                 cube2dPositions.append(self.camera.coord3d_to_2d(cube3dPos))
             cube2dPositions = vstack(cube2dPositions)
             i = argmin(map(norm, \
                         cube2dPositions - array([event[1],event[2]])))
             self.selectedCube = self.cubeToBlk.keys()[i]
             if self.selectedCube != self.previouslySelectedCube:
                 self.updateCursor()
                 self.previouslySelectedCube = self.selectedCube
     elif event[0] == soya.sdlconst.MOUSEBUTTONDOWN:
         if event[1] == soya.sdlconst.BUTTON_WHEELDOWN:
             self.selectedVariant += 1
             self.updateCursor()
         elif event[1] == soya.sdlconst.BUTTON_WHEELUP:
             self.selectedVariant -= 1
             self.updateCursor()
         elif event[1] == soya.sdlconst.BUTTON_RIGHT:
             self.rightClicking = True
         elif event[1] == soya.sdlconst.BUTTON_LEFT and not self.viewOnly:
             raise SelectionPerformed(self.selectedMove)
     elif event[0] == soya.sdlconst.MOUSEBUTTONUP:
         if event[1] == soya.sdlconst.BUTTON_RIGHT:
             self.rightClicking = False
     elif event[0] == soya.sdlconst.KEYDOWN:
         if event[1] == soya.sdlconst.K_LEFT:
             self.alpha += 0.1
         elif event[1] == soya.sdlconst.K_RIGHT:
             self.alpha -= 0.1
         elif event[1] == soya.sdlconst.K_DOWN:
             self.beta -= 0.1
         elif event[1] == soya.sdlconst.K_UP:
             self.beta += 0.1
         elif event[1] == soya.sdlconst.K_PAGEUP:
             self.radius = max(self.radius - 0.5, 0.01)
         elif event[1] == soya.sdlconst.K_PAGEDOWN:
             self.radius = min(self.radius + 0.5, 20.0)
         elif event[1] == soya.sdlconst.K_ESCAPE:
             raise Exception
开发者ID:didmar,项目名称:blokus3d-python,代码行数:49,代码来源:viewer.py


示例2: computeAllBlockPlacements

 def computeAllBlockPlacements(cls, legalMoves):
     cubeToBlk = {} # cube coords -> (blkId, blkVar)
     for coords, blkId, blkVarId in legalMoves:
         for cube in imap(tuple, coords+blockVarWithOrigin(blkId,blkVarId)):
             if not cubeToBlk.has_key(cube):
                 cubeToBlk[cube] = []
             cubeToBlk[cube].append( (coords,blkId,blkVarId) )
     # If their is a cube higher than another, move its entries to the lower cube
     S = reversed(sortCubes2(array(cubeToBlk.keys())))
     lastOne = tuple(next(S))
     try:
         while True:
             nextToLastOne = tuple(next(S))
             # Same xy coordinates ?
             if lastOne[0]==nextToLastOne[0] and lastOne[1]==nextToLastOne[1] :
                 # nextToLastOne has smaller z
                 L = cubeToBlk.pop(lastOne)
                 cubeToBlk[nextToLastOne].extend( L )
             lastOne = nextToLastOne
     except StopIteration:
         pass
     # Compute the center of each cube key in the soya world frame
     cubeCenters = vstack([array([c[0],c[2],c[1]]) for c in cubeToBlk.keys()])
     return cubeToBlk, cubeCenters
开发者ID:didmar,项目名称:blokus3d-python,代码行数:24,代码来源:viewer.py


示例3: bruteForceTree

def bruteForceTree(gs, root=(None,[]), saveGs=False, depth=2):
    if depth <= 0:
        return root
    knownMoves = []
    if root[0]!=None:
        # Get the next player moves already registered
        # through children nodes
        if len(root[1]) > 0 and root[1][0]['move'] != None:
            knownMoves = vstack(node[0]['move'] for node in root[1])
    # Get the legal moves of the next player
    lm = gs.legalMoves()
    if lm == []:
        lm = [None]
    else:
        # Filter moves that are already known
        lm = [move for move in lm if move not in knownMoves]
    # Add nodes for those which are new
    for move in lm:
        dic = {'player':gs.nextPlayer,'move':move}
        root[1].append( (dic,[]) )
    # Evaluate each move and perform recursion
    for i,node in enumerate(root[1]):
        # Play the move
        move = node[0]['move']
        nextGs = gs.clone().playMove(move)
        if saveGs:
            node[0]['gs'] = nextGs
        # Evaluate the scores
        node[0]['baseScores'] = nextGs.baseScores()
        node[0]['penalty'] = nextGs.penalty()
        # Recursion
        nextGs.bruteForceTree(root=node,saveGs=saveGs,depth=depth-1)
        # DEBUG
        if depth==2:
            print "done node %d/%d" % (i,len(root[1]))
    return root
开发者ID:didmar,项目名称:blokus3d-python,代码行数:36,代码来源:ai.py


示例4: test_2D_array2

 def test_2D_array2(self):
     a = array([1,2]); b = array([1,2]);
     res=vstack([a,b])
     desired = array([[1,2],[1,2]])
     assert_array_equal(res,desired)
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:5,代码来源:test_shape_base.py


示例5: test_1D_array

 def test_1D_array(self):
     a = array([1]); b = array([2]);
     res=vstack([a,b])
     desired = array([[1],[2]])
     assert_array_equal(res,desired)
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:5,代码来源:test_shape_base.py


示例6: test_2D_array

 def test_2D_array(self):
     a = array([[1], [2]])
     b = array([[1], [2]])
     res = vstack([a, b])
     desired = array([[1], [2], [1], [2]])
     assert_array_equal(res, desired)
开发者ID:8ballbb,项目名称:ProjectRothar,代码行数:6,代码来源:test_shape_base.py


示例7: test_generator

 def test_generator(self):
     with assert_warns(FutureWarning):
         vstack((np.arange(3) for _ in range(2)))
开发者ID:ales-erjavec,项目名称:numpy,代码行数:3,代码来源:test_shape_base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python core.zeros函数代码示例发布时间:2022-05-27
下一篇:
Python core.take函数代码示例发布时间: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