All Samples(2292) | Call(1933) | Derive(0) | Import(359)
x, random=random.random -> shuffle list x in place; return None. Optional arg random is a 0-argument function returning a random float in [0.0, 1.0); by default, the standard random.random.
src/s/h/shedskin-HEAD/examples/rdb.py shedskin(Download)
seq=[]
last_domain=-1
for slice in slices:
random.shuffle(slice)
if len(slice)>2 and slice[0][1]==last_domain:
slice.append(slice.pop(0))
seq+=[x[0] for x in slice]
else:
log("Generating shuffle sequence ...",False)
seq=range(count)
random.shuffle(seq)
try:
file("iPod_Control/iTunes/iTunesShuffle","wb").write("".join([stringval(x) for x in seq]))
except IOError:
src/b/r/brian-HEAD/trunk/examples/misc/pulsepacket.py brian(Download)
''' This example basically replicates what the Brian PulsePacket object does, and then compares to that object. ''' from brian import * from random import gauss, shuffle
def pulse_packet(t, n, sigma):
# generate a list of n times with Gaussian distribution, sort them in time, and
# then randomly assign the neuron numbers to them
times = [gauss(t, sigma) for i in range(n)]
times.sort()
neuron = range(n)
shuffle(neuron)
src/b/r/brian-HEAD/examples/misc/pulsepacket.py brian(Download)
''' This example basically replicates what the Brian PulsePacket object does, and then compares to that object. ''' from brian import * from random import gauss, shuffle
def pulse_packet(t, n, sigma):
# generate a list of n times with Gaussian distribution, sort them in time, and
# then randomly assign the neuron numbers to them
times = [gauss(t, sigma) for i in range(n)]
times.sort()
neuron = range(n)
shuffle(neuron)
src/r/h/rhnsqa_python-HEAD/src/PyUnit_Sample.py rhnsqa_python(Download)
def testshuffle(self):
# make sure the shuffled sequence does not lose any elements
random.shuffle(self.seq)
self.seq.sort()
self.assertEqual(self.seq, range(10))
def testchoice(self):
src/p/y/pytoaster-HEAD/tests/sample/sampletest.py pytoaster(Download)
def test_shuffle(self):
# make sure the shuffled sequence does not lose any elements
random.shuffle(self.seq)
self.seq.sort()
self.assertEqual(self.seq, range(10))
# should raise an exception for an immutable sequence
src/p/y/python-ldapdict-HEAD/trunk/test/scripts/testexample.py python-ldapdict(Download)
def testshuffle(self):
# make sure the shuffled sequence does not lose any elements
random.shuffle(self.seq)
self.seq.sort()
self.assertEqual(self.seq, range(10))
def testchoice(self):
src/p/y/python-ldapdict-HEAD/test/scripts/testexample.py python-ldapdict(Download)
def testshuffle(self):
# make sure the shuffled sequence does not lose any elements
random.shuffle(self.seq)
self.seq.sort()
self.assertEqual(self.seq, range(10))
def testchoice(self):
src/p/y/pyevolve-HEAD/trunk/examples/pyevolve_ex12_tsp.py pyevolve(Download)
def G1DListTSPInitializator(genome, **args): """ The initializator for the TSP """ lst = [i for i in xrange(genome.getListSize())] random.shuffle(lst) genome.setInternalList(lst) # This is to make a video of best individuals along the evolution
src/p/y/pyevolve-HEAD/trunk/examples/pyevolve_ex21_nqueens.py pyevolve(Download)
from pyevolve import G1DList from pyevolve import Mutators, Crossovers from pyevolve import Consts, GSimpleGA from pyevolve import DBAdapters from random import shuffle # The "n" in n-queens
def queens_init(genome, **args): genome.genomeList = range(0, BOARD_SIZE) shuffle(genome.genomeList) def run_main(): genome = G1DList.G1DList(BOARD_SIZE) genome.setParams(bestrawscore=BOARD_SIZE, rounddecimal=2)
src/p/y/pyevolve-HEAD/examples/pyevolve_ex12_tsp.py pyevolve(Download)
def G1DListTSPInitializator(genome, **args): """ The initializator for the TSP """ lst = [i for i in xrange(genome.getListSize())] random.shuffle(lst) genome.setInternalList(lst) # This is to make a video of best individuals along the evolution
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next