All Samples(642882) | Call(642882) | Derive(0) | Import(0)
len(object) -> integer Return the number of items of a sequence or mapping.
src/v/d/vdj-HEAD/bin/sample_imgt_without_replacement.py vdj(Download)
(options,args) = option_parser.parse_args()
if len(args) == 2:
inhandle = open(args[0],'r')
outhandle = open(args[1],'w')
elif len(args) == 1:
inhandle = open(args[0],'r')
outhandle = sys.stdout
elif len(args) == 0:
idxs = sorted(random.sample(xrange(total_chains),options.num))
for (i,chain) in enumerate(vdj.parse_imgt(inhandle)):
if len(idxs) == 0:
break
if i == idxs[0]:
src/q/u/quickflash-HEAD/netcdf/examples/flame_struct/build_Q_r_h_table.py quickflash(Download)
clean_line = line.strip()
if (len(clean_line) > 0) :
ret_line = clean_line
time_list = list()
num_metadata = len(metadata_list)
## Get list of indexes for metadata objects that enclose the specified time
dt_list = list()
num_select_times = len(time_list)
t_min = min_time
def get_vector_string(vect) :
ret_val = ""
num_elems = len(vect)
opts, args = argparser.parse_args()
argc = len(args)
min_args = int(1)
src/s/h/shedskin-HEAD/examples/go.py shedskin(Download)
def random_choice(self):
choices = len(self.empties)
while choices:
i = int(random.random()*choices)
pos = self.empties[i]
def add(self, pos):
self.empty_pos[pos] = len(self.empties)
self.empties.append(pos)
def remove(self, pos):
self.set(self.empty_pos[pos], self.empties[len(self.empties)-1])
if neighbour.color == color:
surround += 1
if surround == len(square.neighbours):
count += 1
return count
assert members1 == members2
assert len(liberties1) == liberties2, ('liberties differ at %r: %d %d' % (root, len(liberties1), liberties2))
empties1 = set(self.emptyset.empties)
src/s/h/shedskin-HEAD/examples/adatron.py shedskin(Download)
self.global_composition = dict(((x, 0.0) for x in AMINOACIDS))
for aminoacid in self.sequence:
self.global_composition[aminoacid] += 1.0 / len(self.sequence)
def create_vector(self):
for candidate in feature_table:
difference = 0.0
for counter in range(len(row)):
difference += (row[counter] - candidate[counter]) ** 2
kernel_row.append(exp(-D*difference))
def train_adatron(kernel_table, label_table, h, c):
tolerance = 0.5
alphas = [([0.0] * len(kernel_table)) for _ in range(len(label_table[0]))]
betas = [([0.0] * len(kernel_table)) for _ in range(len(label_table[0]))]
bias = [0.0] * len(label_table[0])
src/p/y/pyofss-0.9/examples/agrawal_book/fig_7-9.py pyofss(Download)
filename = "7-9_waterfall_t_pump", y_range = (0.0, 1.0e3) )
# ==============================================================================
if( len(sys.argv) > 1 and sys.argv[1] == 'animate' ):
animated_plot( x, y, z, labels["t"], labels["P_t"], "$z = {0:7.3f} \, m$",
(x[0], x[-1]), (0.0, 1.0e3), fps = 20, frame_prefix = "pump_", filename = "7-9_animation_t_pump.avi" )
filename = "7-9_waterfall_t_probe", y_range = (0.0, 1.2) )
# ==============================================================================
if( len(sys.argv) > 1 and sys.argv[1] == 'animate' ):
animated_plot( x, y, z, labels["t"], labels["P_t"], "$z = {0:7.3f} \, m$",
(x[0], x[-1]), (0.0, 1.2), fps = 20, frame_prefix = "probe_",
src/l/e/legger-HEAD/unstable/python-calibration/opencv-1.0.0-jbmod/src/samples/python/lkdemo.py legger(Download)
device = 0
if len (sys.argv) == 1:
# no argument on the command line, try to use the camera
capture = highgui.cvCreateCameraCapture (device)
cv.cvReleaseImage (temp)
elif len (points [0]) > 0:
# we have points, so display them
# calculate the optical flow
points [1], status = cv.cvCalcOpticalFlowPyrLK (
prev_grey, grey, prev_pyramid, pyramid,
points [0], len (points [0]),
points [0], len (points [0]),
cv.cvSize (win_size, win_size), 3,
len (points [0]),
None,
cv.cvTermCriteria (cv.CV_TERMCRIT_ITER|cv.CV_TERMCRIT_EPS,
src/p/u/pulsar-0.4.6/examples/httpbin/manage.py pulsar(Download)
def request_getsize(self, environ, bits):
if len(bits) == 1:
size = int(bits[0])
else:
raise HttpException(status=404)
def request_redirect(self, environ, bits):
if bits:
if len(bits) > 2:
raise HttpException(status=404)
num = int(bits[0])
def request_cookies_set(self, environ, bits):
if len(bits) == 2:
key = bits[0]
value = bits[1]
if key and value:
def request_status(self, environ, bits):
try:
number = int(bits[0]) if len(bits) == 1 else 404
except:
raise HttpException(status=404)
def request_challenge_auth(self, environ, bits):
if len(bits) == 2:
auth = environ.get('HTTP_AUTHORIZATION')
if auth and auth.type == 'basic':
if auth.authenticated(environ, *bits):
src/l/o/loglab-0.1/examples/logmerge/logmerge.py loglab(Download)
if logs:
logs.sort()
print "%s: merge from %d logs:" % (section, len(logs))
for l in logs:
print " " + l
if not options.quiet:
print "Splitting %s log..." % section
print "Initialising %d log buffers..." % len(sources)
source = LineDisplay(source)
src/b/i/bitey-0.0/examples/mandel/png.py bitey(Download)
def tostring(row):
l = len(row)
return struct.pack('%dB' % l, *row)
else:
def tostring(row):
"""
itotal = len(ipixels)
atotal = len(apixels)
newtotal = itotal + atotal
p = list(palette)
if not (0 < len(p) <= 256):
raise ValueError("a palette must have between 1 and 256 entries")
seen_triple = False
for i,t in enumerate(p):
if len(t) not in (3,4):
src/p/y/pygtk-2.24.0/examples/ide/edit.py PyGTK(Download)
search_text = gtk.Entry()
s = self.buffer.get_selection_bounds()
if len(s) > 0:
search_text.set_text(self.buffer.get_slice(s[0], s[1]))
dialog = gtk.Dialog("Search", self,
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next