code stringlengths 51 2.34k | sequence stringlengths 186 3.94k | docstring stringlengths 11 171 |
|---|---|---|
def async_from_options(options):
_type = options.pop('_type', 'furious.async.Async')
_type = path_to_reference(_type)
return _type.from_dict(options) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Deserialize an Async or Async subclass from an options dict. |
def sign(self, msg: Dict) -> Dict:
ser = serialize_msg_for_signing(msg, topLevelKeysToIgnore=[f.SIG.nm])
bsig = self.naclSigner.signature(ser)
sig = base58.b58encode(bsig).decode("utf-8")
return sig | module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end return_statement identifier | Return a signature for the given message. |
def on_step_end(self, step, logs={}):
self.total_steps += 1
if self.total_steps % self.interval != 0:
return
filepath = self.filepath.format(step=self.total_steps, **logs)
if self.verbose > 0:
print('Step {}: saving model to {}'.format(self.total_steps, filepath))
self.model.save_weights(filepath, overwrite=True) | module function_definition identifier parameters identifier identifier default_parameter identifier dictionary block expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator binary_operator attribute identifier identifier attribute identifier identifier integer block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier dictionary_splat identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true | Save weights at interval steps during training |
def mul(a, b):
if a is None:
if b is None:
return None
else:
return b
elif b is None:
return a
return a * b | module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block if_statement comparison_operator identifier none block return_statement none else_clause block return_statement identifier elif_clause comparison_operator identifier none block return_statement identifier return_statement binary_operator identifier identifier | Multiply two values, ignoring None |
def dump(self, **kwargs):
f = io.StringIO()
w = Writer(f, self.keys, **kwargs)
w.write(self)
text = f.getvalue().lstrip()
f.close()
return text | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier | CSV representation of a item. |
def changed(self):
if not self.parents:
return []
return ChangedFileNodesGenerator([n for n in
self._get_paths_for_status('modified')], self) | module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement list return_statement call identifier argument_list list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier | Returns list of modified ``FileNode`` objects. |
def _make_examples(bam_file, data, ref_file, region_bed, out_file, work_dir):
log_dir = utils.safe_makedir(os.path.join(work_dir, "log"))
example_dir = utils.safe_makedir(os.path.join(work_dir, "examples"))
if len(glob.glob(os.path.join(example_dir, "%s.tfrecord*.gz" % dd.get_sample_name(data)))) == 0:
with tx_tmpdir(data) as tx_example_dir:
cmd = ["dv_make_examples.py", "--cores", dd.get_num_cores(data), "--ref", ref_file,
"--reads", bam_file, "--regions", region_bed, "--logdir", log_dir,
"--examples", tx_example_dir, "--sample", dd.get_sample_name(data)]
do.run(cmd, "DeepVariant make_examples %s" % dd.get_sample_name(data))
for fname in glob.glob(os.path.join(tx_example_dir, "%s.tfrecord*.gz" % dd.get_sample_name(data))):
utils.copy_plus(fname, os.path.join(example_dir, os.path.basename(fname)))
return example_dir | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier integer block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier | Create example pileup images to feed into variant calling. |
def read(sensor):
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
if sensor.gpio_in is 0:
raise RuntimeError('gpio_in, gpio_out attribute of Sensor object must be assigned before calling read')
else:
gpio_in = sensor.gpio_in
gpio_out = sensor.gpio_out
GPIO.setup(gpio_out, GPIO.OUT)
GPIO.setup(gpio_in, GPIO.IN)
GPIO.output(gpio_out, GPIO.LOW)
time.sleep(0.3)
GPIO.output(gpio_out, True)
time.sleep(0.00001)
GPIO.output(gpio_out, False)
while GPIO.input(gpio_in) == 0:
signaloff = time.time()
while GPIO.input(gpio_in) == 1:
signalon = time.time()
timepassed = signalon - signaloff
distance = timepassed * 17000
GPIO.cleanup()
return distance | module function_definition identifier parameters identifier block import_statement dotted_name identifier import_statement aliased_import dotted_name identifier identifier identifier expression_statement call attribute identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list float expression_statement call attribute identifier identifier argument_list identifier true expression_statement call attribute identifier identifier argument_list float expression_statement call attribute identifier identifier argument_list identifier false while_statement comparison_operator call attribute identifier identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list while_statement comparison_operator call attribute identifier identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier integer expression_statement call attribute identifier identifier argument_list return_statement identifier | distance of object in front of sensor in CM. |
def Read(self, expected_ids, read_data=True):
if self.send_idx:
self._Flush()
header_data = self._ReadBuffered(self.recv_header_len)
header = struct.unpack(self.recv_header_format, header_data)
command_id = self.wire_to_id[header[0]]
if command_id not in expected_ids:
if command_id == b'FAIL':
reason = ''
if self.recv_buffer:
reason = self.recv_buffer.decode('utf-8', errors='ignore')
raise usb_exceptions.AdbCommandFailureException('Command failed: {}'.format(reason))
raise adb_protocol.InvalidResponseError(
'Expected one of %s, got %s' % (expected_ids, command_id))
if not read_data:
return command_id, header[1:]
size = header[-1]
data = self._ReadBuffered(size)
return command_id, header[1:-1], data | module function_definition identifier parameters identifier identifier default_parameter identifier true block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier subscript identifier integer if_statement comparison_operator identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_end if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier if_statement not_operator identifier block return_statement expression_list identifier subscript identifier slice integer expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list identifier subscript identifier slice integer unary_operator integer identifier | Read ADB messages and return FileSync packets. |
def title(self, title, show=False):
self._write("title:%d:%s\n" % (int(show), title))
return self | module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple call identifier argument_list identifier identifier return_statement identifier | writes a title tag to the Purr pipe |
def xml_entity_escape(data):
data = data.replace("&", "&")
data = data.replace(">", ">")
data = data.replace("<", "<")
return data | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier | replace special characters with their XML entity versions |
def tick(self):
for npc in self.npcs:
self.move_entity(npc, *npc.towards(self.player))
for entity1, entity2 in itertools.combinations(self.entities, 2):
if (entity1.x, entity1.y) == (entity2.x, entity2.y):
if self.player in (entity1, entity2):
return 'you lost on turn %d' % self.turn
entity1.die()
entity2.die()
if all(npc.speed == 0 for npc in self.npcs):
return 'you won on turn %d' % self.turn
self.turn += 1
if self.turn % 20 == 0:
self.player.speed = max(1, self.player.speed - 1)
self.player.display = on_blue(green(bold(unicode_str(self.player.speed)))) | module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier list_splat call attribute identifier identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier integer block if_statement comparison_operator tuple attribute identifier identifier attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier tuple identifier identifier block return_statement binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement call identifier generator_expression comparison_operator attribute identifier identifier integer for_in_clause identifier attribute identifier identifier block return_statement binary_operator string string_start string_content string_end attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator binary_operator attribute identifier identifier integer integer block expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list integer binary_operator attribute attribute identifier identifier identifier integer expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list call identifier argument_list call identifier argument_list call identifier argument_list attribute attribute identifier identifier identifier | Returns a message to be displayed if game is over, else None |
def cleanup(output_root):
if os.path.exists(output_root):
if os.path.isdir(output_root):
rmtree(output_root)
else:
os.remove(output_root) | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier | Remove any reST files which were generated by this extension |
def json_decode(s: str) -> Any:
try:
return json.JSONDecoder(object_hook=json_class_decoder_hook).decode(s)
except json.JSONDecodeError:
log.warning("Failed to decode JSON (returning None): {!r}", s)
return None | module function_definition identifier parameters typed_parameter identifier type identifier type identifier block try_statement block return_statement call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list identifier except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement none | Decodes an object from JSON using our custom decoder. |
def _cellChunk(self, lines):
KEYWORDS = ('CELLIJ',
'NUMPIPES',
'SPIPE')
result = {'i': None,
'j': None,
'numPipes': None,
'spipes': []}
chunks = pt.chunk(KEYWORDS, lines)
for card, chunkList in iteritems(chunks):
for chunk in chunkList:
schunk = chunk[0].strip().split()
if card == 'CELLIJ':
result['i'] = schunk[1]
result['j'] = schunk[2]
elif card == 'NUMPIPES':
result['numPipes'] = schunk[1]
elif card == 'SPIPE':
pipe = {'linkNumber': schunk[1],
'nodeNumber': schunk[2],
'fraction': schunk[3]}
result['spipes'].append(pipe)
return result | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end none pair string string_start string_content string_end list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute call attribute subscript identifier integer identifier argument_list identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier integer expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer pair string string_start string_content string_end subscript identifier integer expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier return_statement identifier | Parse CELLIJ Chunk Method |
def _get_geometry(self):
return shapely.geometry.MultiPolygon([bbox.geometry for bbox in self.bbox_list]) | module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list list_comprehension attribute identifier identifier for_in_clause identifier attribute identifier identifier | Creates a multipolygon of bounding box polygons |
def _map_in_out(self, inside_var_name):
for out_name, in_name in self.outside_name_map.items():
if inside_var_name == in_name:
return out_name
return None | module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block return_statement identifier return_statement none | Return the external name of a variable mapped from inside. |
def _get_xtool():
for xtool in ['xl', 'xm']:
path = salt.utils.path.which(xtool)
if path is not None:
return path | module function_definition identifier parameters block for_statement identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement identifier | Internal, returns xl or xm command line path |
def label_empty(self, **kwargs):
"Label every item with an `EmptyLabel`."
kwargs['label_cls'] = EmptyLabelList
return self.label_from_func(func=lambda o: 0., **kwargs) | module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier float dictionary_splat identifier | Label every item with an `EmptyLabel`. |
def disable_key(self):
print("This command will disable a enabled key.")
apiKeyID = input("API Key ID: ")
try:
key = self._curl_bitmex("/apiKey/disable",
postdict={"apiKeyID": apiKeyID})
print("Key with ID %s disabled." % key["id"])
except:
print("Unable to disable key, please try again.")
self.disable_key() | module function_definition identifier parameters identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end subscript identifier string string_start string_content string_end except_clause block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list | Disable an existing API Key. |
def load_img(name):
fullname = name
try:
image = pygame.image.load(fullname)
if image.get_alpha() is None:
image = image.convert()
else:
image = image.convert_alpha()
except pygame.error, message:
print "Error: couldn't load image: ", fullname
raise SystemExit, message
return (image, image.get_rect()) | module function_definition identifier parameters identifier block expression_statement assignment identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute identifier identifier argument_list none block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause attribute identifier identifier identifier block print_statement string string_start string_content string_end identifier raise_statement expression_list identifier identifier return_statement tuple identifier call attribute identifier identifier argument_list | Load image and return an image object |
def make(directory):
if os.path.exists(directory):
if os.path.isdir(directory):
click.echo('Directory already exists')
else:
click.echo('Path exists and is not a directory')
sys.exit()
os.makedirs(directory)
os.mkdir(os.path.join(directory, 'jsons'))
copy_default_config(os.path.join(directory, 'config.yaml')) | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end | Makes a RAS Machine directory |
async def _recover_jobs(self, agent_addr):
for (client_addr, job_id), (agent, job_msg, _) in reversed(list(self._job_running.items())):
if agent == agent_addr:
await ZMQUtils.send_with_addr(self._client_socket, client_addr,
BackendJobDone(job_id, ("crash", "Agent restarted"),
0.0, {}, {}, {}, "", None, None, None))
del self._job_running[(client_addr, job_id)]
await self.update_queue() | module function_definition identifier parameters identifier identifier block for_statement pattern_list tuple_pattern identifier identifier tuple_pattern identifier identifier identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement await call attribute identifier identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier tuple string string_start string_content string_end string string_start string_content string_end float dictionary dictionary dictionary string string_start string_end none none none delete_statement subscript attribute identifier identifier tuple identifier identifier expression_statement await call attribute identifier identifier argument_list | Recover the jobs sent to a crashed agent |
def normalize(self):
self.routes.sort(key=lambda route: route.name)
self.data_types.sort(key=lambda data_type: data_type.name)
self.aliases.sort(key=lambda alias: alias.name)
self.annotations.sort(key=lambda annotation: annotation.name) | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute identifier identifier | Alphabetizes routes to make route declaration order irrelevant. |
def flattened(self, order=None, include_smaller=True):
if order is None:
order = self.order
else:
order = self._validate_order(order)
flat = set(self[order])
for order_i in range(0, order):
shift = 2 * (order - order_i)
for cell in self[order_i]:
flat.update(range(cell << shift, (cell + 1) << shift))
if include_smaller:
for order_i in range(order + 1, MAX_ORDER + 1):
shift = 2 * (order_i - order)
for cell in self[order_i]:
flat.add(cell >> shift)
return flat | module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list subscript identifier identifier for_statement identifier call identifier argument_list integer identifier block expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator identifier identifier for_statement identifier subscript identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list binary_operator identifier identifier binary_operator parenthesized_expression binary_operator identifier integer identifier if_statement identifier block for_statement identifier call identifier argument_list binary_operator identifier integer binary_operator identifier integer block expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator identifier identifier for_statement identifier subscript identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator identifier identifier return_statement identifier | Return a flattened pixel collection at a single order. |
def keep_season(show, keep):
deleted = 0
print('%s Cleaning %s to latest season.' % (datestr(), show.title))
for season in show.seasons()[:-1]:
for episode in season.episodes():
delete_episode(episode)
deleted += 1
return deleted | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list attribute identifier identifier for_statement identifier subscript call attribute identifier identifier argument_list slice unary_operator integer block for_statement identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier expression_statement augmented_assignment identifier integer return_statement identifier | Keep only the latest season. |
def dropout_mask(x:Tensor, sz:Collection[int], p:float):
"Return a dropout mask of the same type as `x`, size `sz`, with probability `p` to cancel an element."
return x.new(*sz).bernoulli_(1-p).div_(1-p) | module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier typed_parameter identifier type identifier block expression_statement string string_start string_content string_end return_statement call attribute call attribute call attribute identifier identifier argument_list list_splat identifier identifier argument_list binary_operator integer identifier identifier argument_list binary_operator integer identifier | Return a dropout mask of the same type as `x`, size `sz`, with probability `p` to cancel an element. |
def _get_scope_with_mangled(self, name):
scope = self
while True:
parent = scope.get_enclosing_scope()
if parent is None:
return
if name in parent.rev_mangled:
return parent
scope = parent | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block return_statement if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier expression_statement assignment identifier identifier | Return a scope containing passed mangled name. |
def compressedpubkey(self):
secret = unhexlify(repr(self._wif))
order = ecdsa.SigningKey.from_string(
secret, curve=ecdsa.SECP256k1).curve.generator.order()
p = ecdsa.SigningKey.from_string(
secret, curve=ecdsa.SECP256k1).verifying_key.pubkey.point
x_str = ecdsa.util.number_to_string(p.x(), order)
y_str = ecdsa.util.number_to_string(p.y(), order)
compressed = hexlify(
chr(2 + (p.y() & 1)).encode('ascii') + x_str
).decode('ascii')
uncompressed = hexlify(
chr(4).encode('ascii') + x_str + y_str).decode(
'ascii')
return [compressed, uncompressed] | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute attribute call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier identifier identifier argument_list expression_statement assignment identifier attribute attribute attribute call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list binary_operator call attribute call identifier argument_list binary_operator integer parenthesized_expression binary_operator call attribute identifier identifier argument_list integer identifier argument_list string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list binary_operator binary_operator call attribute call identifier argument_list integer identifier argument_list string string_start string_content string_end identifier identifier identifier argument_list string string_start string_content string_end return_statement list identifier identifier | Derive uncompressed public key |
def clean_total_refund_amount(self):
initial = self.cleaned_data.get('initial_refund_amount', 0)
total = self.cleaned_data['total_refund_amount']
summed_refunds = sum([v for k,v in self.cleaned_data.items() if k.startswith('item_refundamount_')])
if not self.cleaned_data.get('id'):
raise ValidationError('ID not in cleaned data')
if summed_refunds != total:
raise ValidationError(_('Passed value does not match sum of allocated refunds.'))
elif summed_refunds > self.cleaned_data['id'].amountPaid + self.cleaned_data['id'].refunds:
raise ValidationError(_('Total refunds allocated exceed revenue received.'))
elif total < initial:
raise ValidationError(_('Cannot reduce the total amount of the refund.'))
return total | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier binary_operator attribute subscript attribute identifier identifier string string_start string_content string_end identifier attribute subscript attribute identifier identifier string string_start string_content string_end identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier identifier block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end return_statement identifier | The Javascript should ensure that the hidden input is updated, but double check it here. |
def clicked(self, px, py):
if self.hidden:
return None
if (abs(px - self.posx) > self.width/2 or
abs(py - self.posy) > self.height/2):
return None
return math.sqrt((px-self.posx)**2 + (py-self.posy)**2) | module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block return_statement none if_statement parenthesized_expression boolean_operator comparison_operator call identifier argument_list binary_operator identifier attribute identifier identifier binary_operator attribute identifier identifier integer comparison_operator call identifier argument_list binary_operator identifier attribute identifier identifier binary_operator attribute identifier identifier integer block return_statement none return_statement call attribute identifier identifier argument_list binary_operator binary_operator parenthesized_expression binary_operator identifier attribute identifier identifier integer binary_operator parenthesized_expression binary_operator identifier attribute identifier identifier integer | see if the image has been clicked on |
def litecoin_withdrawal(self, amount, address):
data = {'amount': amount, 'address': address}
return self._post("ltc_withdrawal/", data=data, return_json=True,
version=2) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier integer | Send litecoins to another litecoin wallet specified by address. |
def read_d1_letter(fin_txt):
go2letter = {}
re_goid = re.compile(r"(GO:\d{7})")
with open(fin_txt) as ifstrm:
for line in ifstrm:
mtch = re_goid.search(line)
if mtch and line[:1] != ' ':
go2letter[mtch.group(1)] = line[:1]
return go2letter | module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator identifier comparison_operator subscript identifier slice integer string string_start string_content string_end block expression_statement assignment subscript identifier call attribute identifier identifier argument_list integer subscript identifier slice integer return_statement identifier | Reads letter aliases from a text file created by GoDepth1LettersWr. |
def list_names(cls):
response = subwrap.run(['lxc-ls'])
output = response.std_out
return map(str.strip, output.splitlines()) | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list | Lists all known LXC names |
def update(self, other: 'Language') -> 'Language':
return Language.make(
language=other.language or self.language,
extlangs=other.extlangs or self.extlangs,
script=other.script or self.script,
region=other.region or self.region,
variants=other.variants or self.variants,
extensions=other.extensions or self.extensions,
private=other.private or self.private
) | module function_definition identifier parameters identifier typed_parameter identifier type string string_start string_content string_end type string string_start string_content string_end block return_statement call attribute identifier identifier argument_list keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier | Update this Language with the fields of another Language. |
def execute(self, parents=None):
results = OrderedDict()
for row in self.query(parents=parents).execute(self.context.graph):
data = {k: v.toPython() for (k, v) in row.asdict().items()}
id = data.get(self.id)
if id not in results:
results[id] = self.base_object(data)
for child in self.children:
if child.id in data:
name = child.get_name(data)
value = data.get(child.id)
if child.node.many and \
child.node.op not in [OP_IN, OP_NIN]:
if name not in results[id]:
results[id][name] = [value]
else:
results[id][name].append(value)
else:
results[id][name] = value
return results | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list for_statement identifier call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list for_in_clause tuple_pattern identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement boolean_operator attribute attribute identifier identifier identifier line_continuation comparison_operator attribute attribute identifier identifier identifier list identifier identifier block if_statement comparison_operator identifier subscript identifier identifier block expression_statement assignment subscript subscript identifier identifier identifier list identifier else_clause block expression_statement call attribute subscript subscript identifier identifier identifier identifier argument_list identifier else_clause block expression_statement assignment subscript subscript identifier identifier identifier identifier return_statement identifier | Run the data query and construct entities from it's results. |
def generate(env):
path, cxx, shcxx, version = get_cppc(env)
if path:
cxx = os.path.join(path, cxx)
shcxx = os.path.join(path, shcxx)
cplusplus.generate(env)
env['CXX'] = cxx
env['SHCXX'] = shcxx
env['CXXVERSION'] = version
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC')
env['SHOBJPREFIX'] = 'so_'
env['SHOBJSUFFIX'] = '.o' | module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end | Add Builders and construction variables for SunPRO C++. |
def discounted_return(reward, length, discount):
timestep = tf.range(reward.shape[1].value)
mask = tf.cast(timestep[None, :] < length[:, None], tf.float32)
return_ = tf.reverse(tf.transpose(tf.scan(
lambda agg, cur: cur + discount * agg,
tf.transpose(tf.reverse(mask * reward, [1]), [1, 0]),
tf.zeros_like(reward[:, -1]), 1, False), [1, 0]), [1])
return tf.check_numerics(tf.stop_gradient(return_), 'return') | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute subscript attribute identifier identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list comparison_operator subscript identifier none slice subscript identifier slice none attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier binary_operator identifier binary_operator identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator identifier identifier list integer list integer integer call attribute identifier identifier argument_list subscript identifier slice unary_operator integer integer false list integer integer list integer return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end | Discounted Monte-Carlo returns. |
def next_frame_sv2p_cutoff():
hparams = next_frame_sv2p()
hparams.video_modality_loss_cutoff = 0.4
hparams.video_num_input_frames = 4
hparams.video_num_target_frames = 1
return hparams | module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer return_statement identifier | SV2P model with additional cutoff in L2 loss for environments like pong. |
def import_job(db, calc_id, calc_mode, description, user_name, status,
hc_id, datadir):
job = dict(id=calc_id,
calculation_mode=calc_mode,
description=description,
user_name=user_name,
hazard_calculation_id=hc_id,
is_running=0,
status=status,
ds_calc_dir=os.path.join('%s/calc_%s' % (datadir, calc_id)))
db('INSERT INTO job (?S) VALUES (?X)', job.keys(), job.values()) | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier integer keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list | Insert a calculation inside the database, if calc_id is not taken |
def key_sign(rsakey, message, digest):
padding = _asymmetric.padding.PKCS1v15()
signature = rsakey.sign(message, padding, digest)
return signature | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier | Sign the given message with the RSA key. |
def _recurse_find_trace(self, structure, item, trace=[]):
try:
i = structure.index(item)
except ValueError:
for j,substructure in enumerate(structure):
if isinstance(substructure, list):
return self._recurse_find_trace(substructure, item, trace+[j])
else:
return trace+[i] | module function_definition identifier parameters identifier identifier identifier default_parameter identifier list block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier binary_operator identifier list identifier else_clause block return_statement binary_operator identifier list identifier | given a nested structure from _parse_repr and find the trace route to get to item |
def _filter_classes(cls_list, cls_type):
for cls in cls_list:
if isinstance(cls, type) and issubclass(cls, cls_type):
if cls_type == TempyPlace and cls._base_place:
pass
else:
yield cls | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator identifier identifier attribute identifier identifier block pass_statement else_clause block expression_statement yield identifier | Filters a list of classes and yields TempyREPR subclasses |
def ModelDir(self):
model_dir = self.Parameters['model_output_dir'].Value
absolute_model_dir = os.path.abspath(model_dir)
return FilePath(absolute_model_dir) | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier | Absolute FilePath to the training output directory. |
def process(self, metric):
self.queue.append(metric)
if len(self.queue) >= self.queue_size:
logging.debug("Queue is full, sending logs to Logentries")
self._send() | module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list | Process metric by sending it to datadog api |
def _path_pair(self, s):
if s.startswith(b'"'):
parts = s[1:].split(b'" ', 1)
else:
parts = s.split(b' ', 1)
if len(parts) != 2:
self.abort(errors.BadFormat, '?', '?', s)
elif parts[1].startswith(b'"') and parts[1].endswith(b'"'):
parts[1] = parts[1][1:-1]
elif parts[1].startswith(b'"') or parts[1].endswith(b'"'):
self.abort(errors.BadFormat, '?', '?', s)
return [_unquote_c_string(s) for s in parts] | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute subscript identifier slice integer identifier argument_list string string_start string_content string_end integer else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier elif_clause boolean_operator call attribute subscript identifier integer identifier argument_list string string_start string_content string_end call attribute subscript identifier integer identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier integer subscript subscript identifier integer slice integer unary_operator integer elif_clause boolean_operator call attribute subscript identifier integer identifier argument_list string string_start string_content string_end call attribute subscript identifier integer identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier identifier | Parse two paths separated by a space. |
def __protocolize(base_url):
if not base_url.startswith("http://") and not base_url.startswith("https://"):
base_url = "https://" + base_url
base_url = base_url.rstrip("/")
return base_url | module function_definition identifier parameters identifier block if_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | Internal add-protocol-to-url helper |
def readkmz(self, filename):
filename.strip('"')
if filename[-4:] == '.kml':
fo = open(filename, "r")
fstring = fo.read()
fo.close()
elif filename[-4:] == '.kmz':
zip=ZipFile(filename)
for z in zip.filelist:
if z.filename[-4:] == '.kml':
fstring=zip.read(z)
break
else:
raise Exception("Could not find kml file in %s" % filename)
else:
raise Exception("Is not a valid kml or kmz file in %s" % filename)
kmlstring = parseString(fstring)
nodes=kmlstring.getElementsByTagName('Placemark')
return nodes | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator subscript identifier slice unary_operator integer string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript attribute identifier identifier slice unary_operator integer string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier break_statement else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier | reads in a kmz file and returns xml nodes |
def parse_rdp_assignment(line):
toks = line.strip().split('\t')
seq_id = toks.pop(0)
direction = toks.pop(0)
if ((len(toks) % 3) != 0):
raise ValueError(
"Expected assignments in a repeating series of (rank, name, "
"confidence), received %s" % toks)
assignments = []
itoks = iter(toks)
for taxon, rank, confidence_str in zip(itoks, itoks, itoks):
if not taxon:
continue
assignments.append((taxon.strip('"'), rank, float(confidence_str)))
return seq_id, direction, assignments | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list integer if_statement parenthesized_expression comparison_operator parenthesized_expression binary_operator call identifier argument_list identifier integer integer block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier identifier call identifier argument_list identifier identifier identifier block if_statement not_operator identifier block continue_statement expression_statement call attribute identifier identifier argument_list tuple call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier return_statement expression_list identifier identifier identifier | Returns a list of assigned taxa from an RDP classification line |
def wait_for_ribcl_firmware_update_to_complete(ribcl_object):
def is_ilo_reset_initiated():
try:
LOG.debug(ribcl_object._('Checking for iLO reset...'))
ribcl_object.get_product_name()
return False
except exception.IloError:
LOG.debug(ribcl_object._('iLO is being reset...'))
return True
wait_for_operation_to_complete(
is_ilo_reset_initiated,
delay_bw_retries=6,
delay_before_attempts=5,
is_silent_loop_exit=True
)
wait_for_ilo_after_reset(ribcl_object) | module function_definition identifier parameters identifier block function_definition identifier parameters block try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list return_statement false except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement true expression_statement call identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier true expression_statement call identifier argument_list identifier | Continuously checks for iLO firmware update to complete. |
def update_room(room):
if room.custom_server:
return
def _update_room(xmpp):
muc = xmpp.plugin['xep_0045']
muc.joinMUC(room.jid, xmpp.requested_jid.user)
muc.configureRoom(room.jid, _set_form_values(xmpp, room, muc.getRoomConfig(room.jid)))
current_plugin.logger.info('Updating room %s', room.jid)
_execute_xmpp(_update_room) | module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list identifier | Updates a MUC room on the XMPP server. |
def _effectupdate_enlarge_font_on_focus(self, time_passed):
data = self._effects['enlarge-font-on-focus']
fps = data['raise_font_ps']
final_size = data['size'] * data['enlarge_factor']
for i, option in enumerate(self.options):
if i == self.option:
if option['font_current_size'] < final_size:
option['raise_font_factor'] += fps * time_passed
elif option['font_current_size'] > final_size:
option['raise_font_factor'] = data['enlarge_factor']
elif option['raise_font_factor'] != 1.0:
if option['raise_font_factor'] > 1.0:
option['raise_font_factor'] -= fps * time_passed
elif option['raise_font_factor'] < 1.0:
option['raise_font_factor'] = 1.0
new_size = int(data['size'] * option['raise_font_factor'])
if new_size != option['font_current_size']:
option['font'] = pygame.font.Font(data['font'], new_size)
option['font_current_size'] = new_size | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier binary_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement augmented_assignment subscript identifier string string_start string_content string_end binary_operator identifier identifier elif_clause comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end elif_clause comparison_operator subscript identifier string string_start string_content string_end float block if_statement comparison_operator subscript identifier string string_start string_content string_end float block expression_statement augmented_assignment subscript identifier string string_start string_content string_end binary_operator identifier identifier elif_clause comparison_operator subscript identifier string string_start string_content string_end float block expression_statement assignment subscript identifier string string_start string_content string_end float expression_statement assignment identifier call identifier argument_list binary_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier | Gradually enlarge the font size of the focused line. |
def do_console(self) -> None:
if not self._console_enabled:
self._sout.write('Python console disabled for this sessiong\n')
self._sout.flush()
return
h, p = self._host, self._console_port
log.info('Starting console at %s:%d', h, p)
fut = init_console_server(
self._host, self._console_port, self._locals, self._loop)
server = fut.result(timeout=3)
try:
console_proxy(
self._sin, self._sout, self._host, self._console_port)
finally:
coro = close_server(server)
close_fut = asyncio.run_coroutine_threadsafe(coro, loop=self._loop)
close_fut.result(timeout=15) | module function_definition identifier parameters identifier type none block if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list return_statement expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer try_statement block expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier finally_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier integer | Switch to async Python REPL |
def serveMiniMonth(self, request, year=None, month=None):
if not request.is_ajax():
raise Http404("/mini/ is for ajax requests only")
today = timezone.localdate()
if year is None: year = today.year
if month is None: month = today.month
year = int(year)
month = int(month)
return render(request, "joyous/includes/minicalendar.html",
{'self': self,
'page': self,
'version': __version__,
'today': today,
'year': year,
'month': month,
'calendarUrl': self.get_url(request),
'monthName': MONTH_NAMES[month],
'weekdayInfo': zip(weekday_abbr, weekday_name),
'events': self._getEventsByWeek(request, year, month)}) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end subscript identifier identifier pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier identifier | Serve data for the MiniMonth template tag. |
def send_notification(self, title, message, typ=1, url=None, sender=None):
self.user.send_notification(title=title, message=message, typ=typ, url=url,
sender=sender) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier none default_parameter identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier | sends a message to user of this role's private mq exchange |
def _ensure_arraylike(values):
if not is_array_like(values):
inferred = lib.infer_dtype(values, skipna=False)
if inferred in ['mixed', 'string', 'unicode']:
if isinstance(values, tuple):
values = list(values)
values = construct_1d_object_array_from_listlike(values)
else:
values = np.asarray(values)
return values | module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier | ensure that we are arraylike if not already |
def add_to_history(self, command):
command = to_text_string(command)
if command in ['', '\n'] or command.startswith('Traceback'):
return
if command.endswith('\n'):
command = command[:-1]
self.histidx = None
if len(self.history) > 0 and self.history[-1] == command:
return
self.history.append(command)
text = os.linesep + command
if self.history_filename not in self.HISTORY_FILENAMES:
self.HISTORY_FILENAMES.append(self.history_filename)
text = self.SEPARATOR + text
try:
encoding.write(text, self.history_filename, mode='ab')
except EnvironmentError:
pass
if self.append_to_history is not None:
self.append_to_history.emit(self.history_filename, text) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier list string string_start string_end string string_start string_content escape_sequence string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement if_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment attribute identifier identifier none if_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier integer comparison_operator subscript attribute identifier identifier unary_operator integer identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end except_clause identifier block pass_statement if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier | Add command to history |
def extract_audio(filename, channels=1, rate=16000):
temp = tempfile.NamedTemporaryFile(suffix='.wav', delete=False)
if not os.path.isfile(filename):
print("The given file does not exist: {}".format(filename))
raise Exception("Invalid filepath: {}".format(filename))
if not which("ffmpeg"):
print("ffmpeg: Executable not found on machine.")
raise Exception("Dependency not found: ffmpeg")
command = ["ffmpeg", "-y", "-i", filename,
"-ac", str(channels), "-ar", str(rate),
"-loglevel", "error", temp.name]
use_shell = True if os.name == "nt" else False
subprocess.check_output(command, stdin=open(os.devnull), shell=use_shell)
return temp.name, rate | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier false if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement not_operator call identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier conditional_expression true comparison_operator attribute identifier identifier string string_start string_content string_end false expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier return_statement expression_list attribute identifier identifier identifier | Extract audio from an input file to a temporary WAV file. |
def _get_iris_args(attrs):
import cf_units
args = {'attributes': _filter_attrs(attrs, iris_forbidden_keys)}
args.update(_pick_attrs(attrs, ('standard_name', 'long_name',)))
unit_args = _pick_attrs(attrs, ('calendar',))
if 'units' in attrs:
args['units'] = cf_units.Unit(attrs['units'], **unit_args)
return args | module function_definition identifier parameters identifier block import_statement dotted_name identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier tuple string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end dictionary_splat identifier return_statement identifier | Converts the xarray attrs into args that can be passed into Iris |
def reject_recursive_repeats(to_wrap):
to_wrap.__already_called = {}
@functools.wraps(to_wrap)
def wrapped(*args):
arg_instances = tuple(map(id, args))
thread_id = threading.get_ident()
thread_local_args = (thread_id,) + arg_instances
if thread_local_args in to_wrap.__already_called:
raise ValueError('Recursively called %s with %r' % (to_wrap, args))
to_wrap.__already_called[thread_local_args] = True
try:
wrapped_val = to_wrap(*args)
finally:
del to_wrap.__already_called[thread_local_args]
return wrapped_val
return wrapped | module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator tuple identifier identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment subscript attribute identifier identifier identifier true try_statement block expression_statement assignment identifier call identifier argument_list list_splat identifier finally_clause block delete_statement subscript attribute identifier identifier identifier return_statement identifier return_statement identifier | Prevent simple cycles by returning None when called recursively with same instance |
def printdata(self) -> None:
np.set_printoptions(threshold=np.nan)
print(self.data)
np.set_printoptions(threshold=1000) | module function_definition identifier parameters identifier type none block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier integer | Prints data to stdout |
async def get_content_count(self, source: str):
params = {"uri": source, "type": None, "target": "all", "view": "flat"}
return ContentInfo.make(
**await self.services["avContent"]["getContentCount"](params)
) | module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end none pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list dictionary_splat await call subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end argument_list identifier | Return file listing for source. |
def _create_mappings(self, spec):
ret = dict(zip(set(spec.fields), set(spec.fields)))
ret.update(dict([(n, s.alias) for n, s in spec.fields.items() if s.alias]))
return ret | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list list_comprehension tuple identifier attribute identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause attribute identifier identifier return_statement identifier | Create property name map based on aliases. |
def post(self):
self.reqparse.add_argument('namespacePrefix', type=str, required=True)
self.reqparse.add_argument('description', type=str, required=True)
self.reqparse.add_argument('key', type=str, required=True)
self.reqparse.add_argument('value', required=True)
self.reqparse.add_argument('type', type=str, required=True)
args = self.reqparse.parse_args()
if not self.dbconfig.namespace_exists(args['namespacePrefix']):
return self.make_response('The namespace doesnt exist', HTTP.NOT_FOUND)
if self.dbconfig.key_exists(args['namespacePrefix'], args['key']):
return self.make_response('This config item already exists', HTTP.CONFLICT)
self.dbconfig.set(args['namespacePrefix'], args['key'], _to_dbc_class(args), description=args['description'])
auditlog(event='configItem.create', actor=session['user'].username, data=args)
return self.make_response('Config item added', HTTP.CREATED) | module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement not_operator call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute subscript identifier string string_start string_content string_end identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier | Create a new config item |
def xray_requests_send(wrapped, instance, args, kwargs):
return generic_xray_wrapper(
wrapped, instance, args, kwargs,
name='requests',
namespace='remote',
metadata_extractor=extract_http_metadata,
) | module function_definition identifier parameters identifier identifier identifier identifier block return_statement call identifier argument_list identifier identifier identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier | Wrapper around the requests library's low-level send method. |
def _check_buffer(self, data, ctype):
assert ctype in _ffi_types.values()
if not isinstance(data, bytes):
data = _ffi.from_buffer(data)
frames, remainder = divmod(len(data),
self.channels * _ffi.sizeof(ctype))
if remainder:
raise ValueError("Data size must be a multiple of frame size")
return data, frames | module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator identifier call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier binary_operator attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier | Convert buffer to cdata and check for valid size. |
def peekiter(iterable):
it = iter(iterable)
one = next(it)
def gen():
yield one
while True:
yield next(it)
return (one, gen()) | module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier function_definition identifier parameters block expression_statement yield identifier while_statement true block expression_statement yield call identifier argument_list identifier return_statement tuple identifier call identifier argument_list | Return first row and also iterable with same items as original |
def Wm(self):
centroids = self.get_element_centroids()
Wm = scipy.sparse.csr_matrix(
(self.nr_of_elements, self.nr_of_elements))
for i, nb in enumerate(self.element_neighbors):
for j, edges in zip(nb, self.element_neighbors_edges[i]):
edge_coords = self.nodes['presort'][edges][:, 1:]
edge_length = np.linalg.norm(
edge_coords[1, :] - edge_coords[0, :]
)
distance = np.linalg.norm(centroids[i] - centroids[j])
Wm[i, i] += edge_length / distance
Wm[i, j] -= edge_length / distance
return Wm | module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier subscript attribute identifier identifier identifier block expression_statement assignment identifier subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier slice slice integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator subscript identifier integer slice subscript identifier integer slice expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list binary_operator subscript identifier identifier subscript identifier identifier expression_statement augmented_assignment subscript identifier identifier identifier binary_operator identifier identifier expression_statement augmented_assignment subscript identifier identifier identifier binary_operator identifier identifier return_statement identifier | Return the smoothing regularization matrix Wm of the grid |
def replace_fields(meta, patterns):
for pattern in patterns:
try:
field, regex, subst, _ = pattern.split(pattern[-1])
namespace = meta
keypath = [i.replace('\0', '.') for i in field.replace('..', '\0').split('.')]
for key in keypath[:-1]:
namespace = namespace[key]
namespace[keypath[-1]] = re.sub(regex, subst, namespace[keypath[-1]])
except (KeyError, IndexError, TypeError, ValueError) as exc:
raise error.UserError("Bad substitution '%s' (%s)!" % (pattern, exc))
return meta | module function_definition identifier parameters identifier identifier block for_statement identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier identifier identifier call attribute identifier identifier argument_list subscript identifier unary_operator integer expression_statement assignment identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end for_in_clause identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content string_end for_statement identifier subscript identifier slice unary_operator integer block expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier subscript identifier unary_operator integer call attribute identifier identifier argument_list identifier identifier subscript identifier subscript identifier unary_operator integer except_clause as_pattern tuple identifier identifier identifier identifier as_pattern_target identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier | Replace patterns in fields. |
def _enter_plotting(self, fontsize=9):
self.original_fontsize = pyplot.rcParams['font.size']
pyplot.rcParams['font.size'] = fontsize
pyplot.hold(False)
pyplot.ioff() | module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list false expression_statement call attribute identifier identifier argument_list | assumes that a figure is open |
def process_source(self):
if isinstance(self.source, str):
self.source = self.source.replace("'", "\'").replace('"', "\'")
return "\"{source}\"".format(source=self.source)
return self.source | module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content string_end string string_start string_content escape_sequence string_end return_statement call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list keyword_argument identifier attribute identifier identifier return_statement attribute identifier identifier | Return source with transformations, if any |
def new_run(self):
self.current_run += 1
self.runs.append(RunData(self.current_run + 1)) | module function_definition identifier parameters identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list binary_operator attribute identifier identifier integer | Creates a new RunData object and increments pointers |
async def guessImageMetadataFromHttpData(response):
metadata = None
img_data = bytearray()
while len(img_data) < CoverSourceResult.MAX_FILE_METADATA_PEEK_SIZE:
new_img_data = await response.content.read(__class__.METADATA_PEEK_SIZE_INCREMENT)
if not new_img_data:
break
img_data.extend(new_img_data)
metadata = __class__.guessImageMetadataFromData(img_data)
if (metadata is not None) and all(metadata):
return metadata
return metadata | module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list while_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator parenthesized_expression comparison_operator identifier none call identifier argument_list identifier block return_statement identifier return_statement identifier | Identify an image format and size from the beginning of its HTTP data. |
def _load(self):
if os.path.exists(self.path):
root = ET.parse(self.path).getroot()
if (root.tag == "fortpy" and "mode" in root.attrib and
root.attrib["mode"] == "template" and "direction" in root.attrib and
root.attrib["direction"] == self.direction):
for v in _get_xml_version(root):
self.versions[v] = TemplateContents()
self._load_entries(root)
if "autoname" in root.attrib:
self.name = root.attrib["autoname"]
else:
msg.err("the specified template {} ".format(self.path) +
"is missing the mode and direction attributes.")
exit(1)
else:
msg.err("could not find the template {}.".format(self.path))
exit(1) | module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end attribute identifier identifier comparison_operator subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier block for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list integer else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list integer | Extracts the XML template data from the file. |
def rescale_gradients(self, scale: float):
for exe in self.executors:
for arr in exe.grad_arrays:
if arr is None:
continue
arr *= scale | module function_definition identifier parameters identifier typed_parameter identifier type identifier block for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier none block continue_statement expression_statement augmented_assignment identifier identifier | Rescales gradient arrays of executors by scale. |
def sort(self):
beams = [v for (_, v) in self.entries.items()]
sortedBeams = sorted(beams, reverse=True, key=lambda x: x.prTotal*x.prText)
return [x.labeling for x in sortedBeams] | module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true keyword_argument identifier lambda lambda_parameters identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement list_comprehension attribute identifier identifier for_in_clause identifier identifier | return beam-labelings, sorted by probability |
def probe(cls, resource, enable, disable, test, host, interval,
http_method, http_response, threshold, timeout, url, window):
params = {
'host': host,
'interval': interval,
'method': http_method,
'response': http_response,
'threshold': threshold,
'timeout': timeout,
'url': url,
'window': window
}
if enable:
params['enable'] = True
elif disable:
params['enable'] = False
if test:
result = cls.call(
'hosting.rproxy.probe.test', cls.usable_id(resource), params)
else:
result = cls.call(
'hosting.rproxy.probe.update', cls.usable_id(resource), params)
cls.display_progress(result)
return result | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end true elif_clause identifier block expression_statement assignment subscript identifier string string_start string_content string_end false if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Set a probe for a webaccelerator |
def render_obs(self, obs):
start_time = time.time()
self._obs = obs
self.check_valid_queued_action()
self._update_camera(point.Point.build(
self._obs.observation.raw_data.player.camera))
for surf in self._surfaces:
surf.draw(surf)
mouse_pos = self.get_mouse_pos()
if mouse_pos:
self.all_surfs(_Surface.draw_circle, colors.green, mouse_pos.world_pos,
0.1)
self.draw_actions()
with sw("flip"):
pygame.display.flip()
self._render_times.append(time.time() - start_time) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier float expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier | Render a frame given an observation. |
def node_updated(self, node):
if self._capture_node and node == self._capture_node["node"] and node.status != "started":
yield from self.stop_capture() | module function_definition identifier parameters identifier identifier block if_statement boolean_operator boolean_operator attribute identifier identifier comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement yield call attribute identifier identifier argument_list | Called when a node member of the link is updated |
def startswith_field(field, prefix):
if prefix.startswith("."):
return True
if field.startswith(prefix):
if len(field) == len(prefix) or field[len(prefix)] == ".":
return True
return False | module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true if_statement call attribute identifier identifier argument_list identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier call identifier argument_list identifier comparison_operator subscript identifier call identifier argument_list identifier string string_start string_content string_end block return_statement true return_statement false | RETURN True IF field PATH STRING STARTS WITH prefix PATH STRING |
def share_settings(self, other, keylist=None, include_callbacks=True,
callback=True):
if keylist is None:
keylist = self.group.keys()
if include_callbacks:
for key in keylist:
oset, mset = other.group[key], self.group[key]
other.group[key] = mset
oset.merge_callbacks_to(mset)
if callback:
for key in keylist:
other.group[key].make_callback('set', other.group[key].value) | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier true default_parameter identifier true block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement identifier block for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list subscript attribute identifier identifier identifier subscript attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block for_statement identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list string string_start string_content string_end attribute subscript attribute identifier identifier identifier identifier | Sharing settings with `other` |
def from_frame(klass, frame, connection):
event = frame.headers['new']
data = json.loads(frame.body)
info = data['info']
build = Build.fromDict(info)
build.connection = connection
return klass(build, event) | module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier return_statement call identifier argument_list identifier identifier | Create a new BuildStateChange event from a Stompest Frame. |
def _create_context_manager(self, mode):
" Create a context manager that sends 'mode' commands to the client. "
class mode_context_manager(object):
def __enter__(*a):
self.send_packet({'cmd': 'mode', 'data': mode})
def __exit__(*a):
self.send_packet({'cmd': 'mode', 'data': 'restore'})
return mode_context_manager() | module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end class_definition identifier argument_list identifier block function_definition identifier parameters list_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier function_definition identifier parameters list_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list | Create a context manager that sends 'mode' commands to the client. |
def _names(lexer):
first = _expect_token(lexer, {NameToken}).value
rest = _zom_name(lexer)
rnames = (first, ) + rest
return rnames[::-1] | module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call identifier argument_list identifier set identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator tuple identifier identifier return_statement subscript identifier slice unary_operator integer | Return a tuple of names. |
def prepare_axes(wave, flux, fig=None, ax_lower=(0.1, 0.1),
ax_dim=(0.85, 0.65)):
if not fig:
fig = plt.figure()
ax = fig.add_axes([ax_lower[0], ax_lower[1], ax_dim[0], ax_dim[1]])
ax.plot(wave, flux)
return fig, ax | module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier tuple float float default_parameter identifier tuple float float block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list list subscript identifier integer subscript identifier integer subscript identifier integer subscript identifier integer expression_statement call attribute identifier identifier argument_list identifier identifier return_statement expression_list identifier identifier | Create fig and axes if needed and layout axes in fig. |
def load_sources(self, sources):
self.clear()
for s in sources:
if isinstance(s, dict):
s = Model.create_from_dict(s)
self.load_source(s, build_index=False)
self._build_src_index() | module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list | Delete all sources in the ROI and load the input source list. |
def to_rec_single(samples, default_keys=None):
out = []
for data in samples:
recs = samples_to_records([normalize_missing(utils.to_single_data(data))], default_keys)
assert len(recs) == 1
out.append(recs[0])
return out | module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list list call identifier argument_list call attribute identifier identifier argument_list identifier identifier assert_statement comparison_operator call identifier argument_list identifier integer expression_statement call attribute identifier identifier argument_list subscript identifier integer return_statement identifier | Convert output into a list of single CWL records. |
def headers_for_url(cls, url):
response = cls.http_request(url, method='HEAD')
if response.status != 200:
cls.raise_http_error(response)
return Resource.headers_as_dict(response) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier | Return the headers only for the given URL as a dict |
def _make_fits(self):
a = self.tests[self.active]
args = self.curargs
if len(args["fits"]) > 0:
for fit in list(args["fits"].keys()):
a.fit(args["independent"], fit, args["fits"][fit], args["threshold"], args["functions"]) | module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end integer block for_statement identifier call identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier subscript subscript identifier string string_start string_content string_end identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end | Generates the data fits for any variables set for fitting in the shell. |
def fire_failed_msisdn_lookup(self, to_identity):
payload = {"to_identity": to_identity}
hooks = Hook.objects.filter(event="identity.no_address")
for hook in hooks:
hook.deliver_hook(
None, payload_override={"hook": hook.dict(), "data": payload}
) | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list none keyword_argument identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end identifier | Fires a webhook in the event of a None to_addr. |
def extract_tar (archive, compression, cmd, verbosity, interactive, outdir):
cmdlist = [cmd, '--extract']
add_tar_opts(cmdlist, compression, verbosity)
cmdlist.extend(["--file", archive, '--directory', outdir])
return cmdlist | module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end identifier string string_start string_content string_end identifier return_statement identifier | Extract a TAR archive. |
def write_bytes(self, data):
if not isinstance(data, six.binary_type):
raise TypeError(
'data must be %s, not %s' %
(six.binary_type.__class__.__name__, data.__class__.__name__))
with self.open(mode='wb') as f:
return f.write(data) | module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute attribute attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier | Open the file in bytes mode, write to it, and close the file. |
def launch_in_notebook(self, port=9095, width=900, height=600):
from IPython.lib import backgroundjobs as bg
from IPython.display import HTML
jobs = bg.BackgroundJobManager()
jobs.new(self.launch, kw=dict(port=port))
frame = HTML(
'<iframe src=http://localhost:{} width={} height={}></iframe>'
.format(port, width, height)
)
return frame | module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer block import_from_statement dotted_name identifier identifier aliased_import dotted_name identifier identifier import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier call identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier return_statement identifier | launch the app within an iframe in ipython notebook |
def getoptlist(self, p):
optlist = []
for k, v in self.pairs:
if k == p:
optlist.append(v)
return optlist | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier | Returns all option values stored that match p as a list. |
def _ref_key(self, key):
queue = self.queue
refcount = self.refcount
queue.append(key)
refcount[key] = refcount[key] + 1
if len(queue) > self.max_queue:
refcount.clear()
queue_appendleft = queue.appendleft
queue_appendleft(self.sentinel)
for k in filterfalse(refcount.__contains__,
iter(queue.pop, self.sentinel)):
queue_appendleft(k)
refcount[k] = 1 | module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier binary_operator subscript identifier identifier integer if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call identifier argument_list identifier expression_statement assignment subscript identifier identifier integer | Record a reference to the argument key. |
def load_currency(self, mnemonic: str):
if self.rate and self.rate.currency == mnemonic:
return
app = PriceDbApplication()
symbol = SecuritySymbol("CURRENCY", mnemonic)
self.rate = app.get_latest_price(symbol)
if not self.rate:
raise ValueError(f"No rate found for {mnemonic}!") | module function_definition identifier parameters identifier typed_parameter identifier type identifier block if_statement boolean_operator attribute identifier identifier comparison_operator attribute attribute identifier identifier identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content interpolation identifier string_content string_end | load the latest rate for the given mnemonic; expressed in the base currency |
def OnSearchDirectionButton(self, event):
if "DOWN" in self.search_options:
flag_index = self.search_options.index("DOWN")
self.search_options[flag_index] = "UP"
elif "UP" in self.search_options:
flag_index = self.search_options.index("UP")
self.search_options[flag_index] = "DOWN"
else:
raise AttributeError(_("Neither UP nor DOWN in search_flags"))
event.Skip() | module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list | Event handler for search direction toggle button |
def _setProperty(self, _type, data, win=None, mask=None):
if not win:
win = self.root
if type(data) is str:
dataSize = 8
else:
data = (data+[0]*(5-len(data)))[:5]
dataSize = 32
ev = protocol.event.ClientMessage(
window=win,
client_type=self.display.get_atom(_type), data=(dataSize, data))
if not mask:
mask = (X.SubstructureRedirectMask | X.SubstructureNotifyMask)
self.root.send_event(ev, event_mask=mask) | module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier subscript parenthesized_expression binary_operator identifier binary_operator list integer parenthesized_expression binary_operator integer call identifier argument_list identifier slice integer expression_statement assignment identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier tuple identifier identifier if_statement not_operator identifier block expression_statement assignment identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier | Send a ClientMessage event to the root window |
def configure(self, ns, mappings=None, **kwargs):
if mappings is None:
mappings = dict()
mappings.update(kwargs)
for operation, definition in mappings.items():
try:
configure_func = self._find_func(operation)
except AttributeError:
pass
else:
configure_func(ns, self._make_definition(definition)) | module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement else_clause block expression_statement call identifier argument_list identifier call attribute identifier identifier argument_list identifier | Apply mappings to a namespace. |
def segments (self):
for n in xrange(len(self.vertices) - 1):
yield Line(self.vertices[n], self.vertices[n + 1])
yield Line(self.vertices[-1], self.vertices[0]) | module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list binary_operator call identifier argument_list attribute identifier identifier integer block expression_statement yield call identifier argument_list subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer expression_statement yield call identifier argument_list subscript attribute identifier identifier unary_operator integer subscript attribute identifier identifier integer | Return the Line segments that comprise this Polygon. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.