def generatePattern(numCols=100, minOnes=21, maxOnes=25, colSet=[], prevPattern=numpy.array([])):
 assert (minOnes < maxOnes)
 assert (maxOnes < numCols)
 nOnes = rgen.randint(minOnes, maxOnes)
 candidates = list(colSet.difference(set(prevPattern.nonzero()[0])))
 rgen.shuffle(candidates)
 ind = candidates[:nOnes]
 x = numpy.zeros(numCols, dtype='float32')
 x[ind] = 1
 return x

def generatePattern ( numCols = 100 , minOnes = 21 , maxOnes = 25 , colSet = [ ] , prevPattern = numpy . array ( [ ] ) ) : assert ( minOnes < maxOnes ) assert ( maxOnes < numCols ) nOnes = rgen . randint ( minOnes , maxOnes ) candidates = list ( colSet . difference ( set ( prevPattern . nonzero ( ) [ 0 ] ) ) ) rgen . shuffle ( candidates ) ind = candidates [ : nOnes ] x = numpy . zeros ( numCols , dtype = 'float32' ) x [ ind ] = 1 return x
generate a single test pattern with given parameters .