• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(8425)  |  Call(7279)  |  Derive(0)  |  Import(1146)
Shallow copy operation on arbitrary Python objects.

See the module's __doc__ string for more info.

        def copy(x):
    """Shallow copy operation on arbitrary Python objects.

    See the module's __doc__ string for more info.
    """

    cls = type(x)

    copier = _copy_dispatch.get(cls)
    if copier:
        return copier(x)

    copier = getattr(cls, "__copy__", None)
    if copier:
        return copier(x)

    reductor = dispatch_table.get(cls)
    if reductor:
        rv = reductor(x)
    else:
        reductor = getattr(x, "__reduce_ex__", None)
        if reductor:
            rv = reductor(2)
        else:
            reductor = getattr(x, "__reduce__", None)
            if reductor:
                rv = reductor()
            else:
                raise Error("un(shallow)copyable object of type %s" % cls)

    return _reconstruct(x, rv, 0)
        


src/s/h/shedskin-HEAD/examples/bh.py   shedskin(Download)
 
from time import clock
from sys import stderr, maxint, argv
from copy import copy
from math import sqrt, pi, floor
 
class Random(object):
        self.pskip = b
 
        # Poat which to evaluate field
        self.pos0 = copy(p)
 
        # Computed potential at pos0
        self.phi0 = 0.0
    def vp(bodies, nstep):
        dacc = Vec3()
        dvel = Vec3()
        dthf = 0.5 * BH.DTIME
 
        for b in reversed(bodies):
            acc1 = copy(b.new_acc)
            if nstep > 0:
                dacc.subtraction2(acc1, b.acc)
                dvel.mult_scalar2(dacc, dthf)
                dvel += b.vel
                b.vel = copy(dvel)
 
            b.acc = copy(acc1)
            b.acc = copy(acc1)
            dvel.mult_scalar2(b.acc, dthf)
 
            vel1 = copy(b.vel)
            vel1 += dvel
            dpos = copy(vel1)
            dpos *= BH.DTIME
            dpos += b.pos
            b.pos = copy(dpos)
            vel1 += dvel
            b.vel = copy(vel1)

src/s/h/shedskin-HEAD/examples/chess.py   shedskin(Download)
# 4x castling flags, indices [10-13], queen side white, king side white, queen side black, king side white
# turn, enpassant [26, 27]
 
from copy import copy
 
iNone = -999
iTrue = 1
  if board[26]:
    kingVal = -kingVal
  for mv in allMoves:
    board2 = copy(board)
    move(board2, mv)
    #print "trying to reduce move", toString(mv)
    if not [i for i in pseudoLegalCaptures(board2) if board2[i & 0xff] == kingVal]:
  if n >= -4:
    #from copy import copy
    for mv in pseudoLegalCaptures(board):
      newboard = copy(board)
      move(newboard, mv)
      value = alphaBetaQui(newboard, -beta, -alpha, n - 1)
      value = (-value[0], value[1])
  bestMove = iNone # XXX
 
  for mv in legalMoves(board):
    newboard = copy(board)
    move(newboard, mv)
    value = alphaBeta(newboard, -beta, -alpha, n - 1)
    value = (-value[0], value[1])

src/o/p/opengrasp-HEAD/trunk/OpenRAVE_Modified/python/examples/mobilemanipulation.py   opengrasp(Download)
__license__ = 'Apache License, Version 2.0'
 
import time,traceback
from copy import copy as shallowcopy
from openravepy import *
from openravepy.interfaces import BaseManipulation, TaskManipulation, VisualFeedback
from openravepy.examples import inversekinematics,inversereachability,graspplanning,grasping,visibilitymodel
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.irmodels = []
        for irmodel in self.irmodels:
            try:
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.envreal = self.env
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.grmodel = self.grmodel.clone(envother) if self.grmodel is not None else None
        clone.basemanip = self.basemanip.clone(envother)

src/s/h/shedskin-HEAD/examples/genetic.py   shedskin(Download)
# (c) Bearophile
#
# genetic algorithm
 
from random import random, randint, choice
from math import sin, pi
from copy import copy 
            if individual.fitness > bestIndividualGeneration.fitness:
                bestIndividualGeneration = individual
        if self.bestIndividual.fitness < bestIndividualGeneration.fitness:
            self.bestIndividual = copy(bestIndividualGeneration) 
 
 
    def run(self):

src/o/p/opengrasp-HEAD/OpenRAVE_Modified/python/examples/mobilemanipulation.py   opengrasp(Download)
__license__ = 'Apache License, Version 2.0'
 
import time,traceback
from copy import copy as shallowcopy
from openravepy import *
from openravepy.interfaces import BaseManipulation, TaskManipulation, VisualFeedback
from openravepy.examples import inversekinematics,inversereachability,graspplanning,grasping,visibilitymodel
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.irmodels = []
        for irmodel in self.irmodels:
            try:
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.envreal = self.env
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.grmodel = self.grmodel.clone(envother) if self.grmodel is not None else None
        clone.basemanip = self.basemanip.clone(envother)

src/q/u/quickflash-HEAD/branch_tags/octave-swig/QuickFlash-1.0.0-Octave-1.0/examples/raytracer/stitch_tasks.py   quickflash(Download)
def condense_indexes(index_list) :
 
    from copy import copy
 
    # Convert a list of indexes to a list of (start_index, length) pairs
 
    work_list = copy(index_list)

src/o/p/openrave-HEAD/trunk/python/examples/mobilemanipulation.py   openrave(Download)
__license__ = 'Apache License, Version 2.0'
 
import time,traceback
from copy import copy as shallowcopy
from openravepy import *
from openravepy.interfaces import BaseManipulation, TaskManipulation, VisualFeedback
from openravepy.databases import inversekinematics,inversereachability,grasping,visibilitymodel
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.irmodels = []
        for irmodel in self.irmodels:
            try:
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.envreal = self.env
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.grmodel = self.grmodel.clone(envother) if self.grmodel is not None else None
        clone.basemanip = self.basemanip.clone(envother)

src/p/y/pylife-HEAD/src/parallel/parallel_life_board_example.py   pylife(Download)
################
 
# Creates a copy of the life board for comparison
from copy import copy
lifeBoardCopy = copy(lifeBoard)
 
lifeBoardCopy.update()

src/o/p/openrave-HEAD/python/examples/mobilemanipulation.py   openrave(Download)
__license__ = 'Apache License, Version 2.0'
 
import time,traceback
from copy import copy as shallowcopy
from openravepy import *
from openravepy.interfaces import BaseManipulation, TaskManipulation, VisualFeedback
from openravepy.databases import inversekinematics,inversereachability,grasping,visibilitymodel
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.irmodels = []
        for irmodel in self.irmodels:
            try:
    def clone(self,envother):
        clone = shallowcopy(self)
        clone.env = envother
        clone.envreal = self.env
        clone.robot = clone.env.GetRobot(self.robot.GetName())
        clone.grmodel = self.grmodel.clone(envother) if self.grmodel is not None else None
        clone.basemanip = self.basemanip.clone(envother)

src/q/u/quickflash-HEAD/trunk/examples/raytracer/stitch_tasks.py   quickflash(Download)
def condense_indexes(index_list) :
 
    from copy import copy
 
    # Convert a list of indexes to a list of (start_index, length) pairs
 
    work_list = copy(index_list)

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next