code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def meta_changed(self, model, prop_name, info): self.state_machine.marked_dirty = True msg = info.arg if model is not self and msg.change.startswith('sm_notification_'): msg = msg._replace(change=msg.change.replace('sm_notification_', '', 1)) self.state_meta_signal.emit(msg)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier true expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier
When the meta was changed, we have to set the dirty flag, as the changes are unsaved
def cli(ctx, *args, **kwargs): backend = kwargs.get('backend', None) model = kwargs.get('model', None) printer = kwargs.get('printer', None) debug = kwargs.get('debug') ctx.meta['MODEL'] = model ctx.meta['BACKEND'] = backend ctx.meta['PRINTER'] = printer logging.basicConfig(level='DEBUG' if debug else 'INFO')
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end
Command line interface for the brother_ql Python package.
def chainproperty(func): func = assertionproperty(func) setattr(AssertionBuilder, func.fget.__name__, func) return func
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier attribute attribute identifier identifier identifier identifier return_statement identifier
Extend sure with a custom chain property.
def list_jobs(tail): query = ( db.session.query(models.CrawlerJob) .order_by(models.CrawlerJob.id.desc()) ) if tail != 0: query = query.limit(tail) results = query.yield_per(10).all() _show_table(results=results)
module function_definition identifier parameters identifier block expression_statement assignment identifier parenthesized_expression call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list expression_statement call identifier argument_list keyword_argument identifier identifier
Show info about the existing crawler jobs.
def extract_file_args(subparsers): extract_parser = subparsers.add_parser('extract_file', help='Extract a single secret from' 'Vault to a local file') extract_parser.add_argument('vault_path', help='Full path (including key) to secret') extract_parser.add_argument('destination', help='Location of destination file') base_args(extract_parser)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list identifier
Add the command line options for the extract_file operation
def _ppid(): ret = {} if __grains__['kernel'] == 'SunOS': cmd = 'ps -a -o pid,ppid | tail +2' else: cmd = 'ps -ax -o pid,ppid | tail -n+2' out = __salt__['cmd.run'](cmd, python_shell=True) for line in out.splitlines(): pid, ppid = line.split() ret[pid] = ppid return ret
module function_definition identifier parameters block expression_statement assignment identifier dictionary if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list identifier keyword_argument identifier true for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier identifier return_statement identifier
Return a dict of pid to ppid mappings
def cli(env): manager = CapacityManager(env.client) items = manager.get_create_options() items.sort(key=lambda term: int(term['capacity'])) table = formatting.Table(["KeyName", "Description", "Term", "Default Hourly Price Per Instance"], title="Reserved Capacity Options") table.align["Hourly Price"] = "l" table.align["Description"] = "l" table.align["KeyName"] = "l" for item in items: table.add_row([ item['keyName'], item['description'], item['capacity'], get_price(item) ]) env.fout(table) regions = manager.get_available_routers() location_table = formatting.Table(['Location', 'POD', 'BackendRouterId'], 'Orderable Locations') for region in regions: for location in region['locations']: for pod in location['location']['pods']: location_table.add_row([region['keyname'], pod['backendRouterName'], pod['backendRouterId']]) env.fout(location_table)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block for_statement identifier subscript identifier string string_start string_content string_end block for_statement identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
List options for creating Reserved Capacity
def resolve_attribute(name, bases, default=None): for base in bases: if hasattr(base, name): return getattr(base, name) return default
module function_definition identifier parameters identifier identifier default_parameter identifier none block for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier identifier return_statement identifier
Find the first definition of an attribute according to MRO order.
def delete(self, key, sort_key): primary_key = key key = self.prefixed('{}:{}'.format(key, sort_key)) self.logger.debug('Storage - delete {}'.format(key)) if sort_key is not None: self.cache[self.prefixed(primary_key)].remove(sort_key) for index in self._secondary_indexes: obj = json.loads(self.cache[key]) if index in obj.keys(): self.cache['secondary_indexes'][index][obj[index]].remove( key) del(self.cache[key]) return True
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute subscript attribute identifier identifier call attribute identifier identifier argument_list identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier identifier if_statement comparison_operator identifier call attribute identifier identifier argument_list block expression_statement call attribute subscript subscript subscript attribute identifier identifier string string_start string_content string_end identifier subscript identifier identifier identifier argument_list identifier delete_statement parenthesized_expression subscript attribute identifier identifier identifier return_statement true
Delete an element in dictionary
def add_xml_to_node(self, node): node.tag = self.xml_element_name() node.set('xblock-family', self.entry_point) for field_name, field in self.fields.items(): if field_name in ('children', 'parent', 'content'): continue if field.is_set_on(self) or field.force_export: self._add_field(node, field_name, field) text = self.xml_text_content() if text is not None: node.text = text
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block continue_statement if_statement boolean_operator call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier
For exporting, set data on `node` from ourselves.
def _update_dPrxy(self): super(ExpCM_empirical_phi_divpressure, self)._update_dPrxy() if 'omega2' in self.freeparams: with scipy.errstate(divide='raise', under='raise', over='raise', invalid='ignore'): scipy.copyto(self.dPrxy['omega2'], -self.ln_piAx_piAy_beta * self.Qxy * self.omega / (1 - self.piAx_piAy_beta), where=CODON_NONSYN) scipy.copyto(self.dPrxy['omega2'], self.Qxy * self.omega, where=scipy.logical_and(CODON_NONSYN, scipy.fabs(1 - self.piAx_piAy_beta) < ALMOST_ZERO)) for r in range(self.nsites): self.dPrxy['omega2'][r] *= self.deltar[r] _fill_diagonals(self.dPrxy['omega2'], self._diag_indices)
module function_definition identifier parameters identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end binary_operator binary_operator binary_operator unary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier parenthesized_expression binary_operator integer attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end binary_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier comparison_operator call attribute identifier identifier argument_list binary_operator integer attribute identifier identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement augmented_assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier subscript attribute identifier identifier identifier expression_statement call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier
Update `dPrxy`, accounting for dependence of `Prxy` on `omega2`.
def run(): parser = OptionParser(version='%prog {0}'.format(__version__)) parser.add_option('-a', '--addr', default='localhost', help=('The address or host to listen on. Specify -a ' '0.0.0.0 to listen on all addresses. ' 'Default: localhost')) parser.add_option('-p', '--port', type='int', default='10101', help=('The port to listen for requests on. ' 'Default: 10101')) options, _ = parser.parse_args() try: server = ThreadingTCPServer((options.addr, options.port), RequestHandler) except (socket.error, socket.gaierror) as exc: print(exc) sys.exit(1) print('Listening on {0} port {1}'.format(options.addr, options.port)) try: server.serve_forever() except KeyboardInterrupt: server.socket.close() RequestHandler.http.close() print('Goodbye!')
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call identifier argument_list tuple attribute identifier identifier attribute identifier identifier identifier except_clause as_pattern tuple attribute identifier identifier attribute identifier identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end
The entry point from the praw-multiprocess utility.
def updateRPYText(self): 'Updates the displayed Roll, Pitch, Yaw Text' self.rollText.set_text('Roll: %.2f' % self.roll) self.pitchText.set_text('Pitch: %.2f' % self.pitch) self.yawText.set_text('Yaw: %.2f' % self.yaw)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
Updates the displayed Roll, Pitch, Yaw Text
def update(self, a, b, c, d): self.table.ravel()[:] = [a, b, c, d] self.N = self.table.sum()
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment subscript call attribute attribute identifier identifier identifier argument_list slice list identifier identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list
Update contingency table with new values without creating a new object.
def download_manylinux_wheels(self, abi, packages, directory): for package in packages: arguments = ['--only-binary=:all:', '--no-deps', '--platform', 'manylinux1_x86_64', '--implementation', 'cp', '--abi', abi, '--dest', directory, package] self._execute('download', arguments)
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier identifier block 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 string string_start string_content string_end 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 identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Download wheel files for manylinux for all the given packages.
def baremetal(self): if self._baremetal is not None: return self._baremetal endpoint = self._instance.get_endpoint_for_service_type( "baremetal", region_name=self._instance._region_name, ) token = self._instance.auth.get_token(self._instance.session) self._baremetal = ironic_client.get_client( 1, os_auth_token=token, ironic_url=endpoint, ca_file=self._instance._cli_options.os_cacert) return self._baremetal
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier return_statement attribute identifier identifier
Returns an baremetal service client
def H13(self): "Information measure of correlation 2." return np.sqrt(1 - np.exp(-2 * (self.hxy2 - self.H9())))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end return_statement call attribute identifier identifier argument_list binary_operator integer call attribute identifier identifier argument_list binary_operator unary_operator integer parenthesized_expression binary_operator attribute identifier identifier call attribute identifier identifier argument_list
Information measure of correlation 2.
def via_dom_id(self, dom_id, det_id): try: return DOM.from_json([ d for d in self._json if d["DOMId"] == dom_id and d["DetOID"] == det_id ][0]) except IndexError: log.critical("No DOM found for DOM ID '{0}'".format(dom_id))
module function_definition identifier parameters identifier identifier identifier block try_statement block return_statement call attribute identifier identifier argument_list subscript list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause boolean_operator comparison_operator subscript identifier string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end identifier integer except_clause identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Return DOM for given dom_id
def find_write_contribs() -> None: map_file_auth = {} for filename in scantree('cltk'): filepath = filename.path authors_list = get_authors(filepath) if authors_list: map_file_auth[filepath] = authors_list map_auth_file = defaultdict(list) for file, authors_file in map_file_auth.items(): for author in authors_file: map_auth_file[author].append(file) map_auth_file = sort_def_dict(map_auth_file) map_auth_file_sorted = sorted(map_auth_file.items()) map_auth_file = OrderedDict(map_auth_file_sorted) write_contribs(map_auth_file)
module function_definition identifier parameters type none block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement identifier identifier block expression_statement call attribute subscript identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier
Look for files, find authors, sort, write file.
def keys(self): keys = [] for app_name, __ in self.items(): keys.append(app_name) return keys
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
return a list of all app_names
def list_cands(candsfile, threshold=0.): loc, prop, d0 = pc.read_candidates(candsfile, snrmin=threshold, returnstate=True) if 'snr2' in d0['features']: snrcol = d0['features'].index('snr2') elif 'snr1' in d0['features']: snrcol = d0['features'].index('snr1') dmindcol = d0['featureind'].index('dmind') if len(loc): snrs = prop[:, snrcol] times = pc.int2mjd(d0, loc) times = times - times[0] logger.info('Getting candidates...') logger.info('candnum: loc, SNR, DM (pc/cm3), time (s; rel)') for i in range(len(loc)): logger.info("%d: %s, %.1f, %.1f, %.1f" % (i, str(loc[i]), prop[i, snrcol], np.array(d0['dmarr'])[loc[i,dmindcol]], times[i]))
module function_definition identifier parameters identifier default_parameter identifier float block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true if_statement comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier block expression_statement assignment identifier subscript identifier slice identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier binary_operator identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list subscript identifier identifier subscript identifier identifier identifier subscript call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier identifier identifier subscript identifier identifier
Prints candidate info in time order above some threshold
def delayed_redraw(self): with self._defer_lock: whence = self._defer_whence self._defer_whence = self._defer_whence_reset flag = self._defer_flag self._defer_flag = False if flag: self.redraw_now(whence=whence)
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier false if_statement identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Handle delayed redrawing of the canvas.
def stop(self): if getattr(self, "_jsc", None): try: self._jsc.stop() except Py4JError: warnings.warn( 'Unable to cleanly shutdown Spark JVM process.' ' It is possible that the process has crashed,' ' been killed or may also be in a zombie state.', RuntimeWarning ) finally: self._jsc = None if getattr(self, "_accumulatorServer", None): self._accumulatorServer.shutdown() self._accumulatorServer = None with SparkContext._lock: SparkContext._active_spark_context = None
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier string string_start string_content string_end none block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier finally_clause block expression_statement assignment attribute identifier identifier none if_statement call identifier argument_list identifier string string_start string_content string_end none block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none with_statement with_clause with_item attribute identifier identifier block expression_statement assignment attribute identifier identifier none
Shut down the SparkContext.
def manager(self): from flask_script import Manager, Command manager = Manager(usage="Migrate database.") manager.add_command('create', Command(self.cmd_create)) manager.add_command('migrate', Command(self.cmd_migrate)) manager.add_command('rollback', Command(self.cmd_rollback)) manager.add_command('list', Command(self.cmd_list)) manager.add_command('merge', Command(self.cmd_merge)) return manager
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier return_statement identifier
Integrate a Flask-Script.
def _get_fba_problem(model, tfba, solver): p = FluxBalanceProblem(model, solver) if tfba: p.add_thermodynamic() return p
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement identifier
Convenience function for returning the right FBA problem instance
def load_from_file(cls, file_path: str): with open(file_path, "r") as f: data = json.load(f) item = cls.decode(data=data) return item
module function_definition identifier parameters identifier typed_parameter identifier type identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
Read and reconstruct the data from a JSON file.
def reset_everything(self, payload): kill_signal = signals['9'] self.process_handler.kill_all(kill_signal, True) self.process_handler.wait_for_finish() self.reset = True answer = {'message': 'Resetting current queue', 'status': 'success'} return answer
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement assignment identifier 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 identifier
Kill all processes, delete the queue and clean everything up.
def create_entity(project_id, entity_type_id, entity_value, synonyms): import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() synonyms = synonyms or [entity_value] entity_type_path = entity_types_client.entity_type_path( project_id, entity_type_id) entity = dialogflow.types.EntityType.Entity() entity.value = entity_value entity.synonyms.extend(synonyms) response = entity_types_client.batch_create_entities( entity_type_path, [entity]) print('Entity created: {}'.format(response))
module function_definition identifier parameters identifier identifier identifier identifier block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier boolean_operator identifier list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Create an entity of the given entity type.
def OnNodeSelected(self, event): try: node = self.sorted[event.GetIndex()] except IndexError, err: log.warn(_('Invalid index in node selected: %(index)s'), index=event.GetIndex()) else: if node is not self.selected_node: wx.PostEvent( self, squaremap.SquareSelectionEvent(node=node, point=None, map=None) )
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript attribute identifier identifier call attribute identifier identifier argument_list except_clause identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list else_clause block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier none keyword_argument identifier none
We have selected a node with the list control, tell the world
def f(field: str, kwargs: Dict[str, Any], default: Optional[Any] = None) -> str: if default is not None: return str(kwargs.get(field, default)) return str(kwargs[field])
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier typed_default_parameter identifier type generic_type identifier type_parameter type identifier none type identifier block if_statement comparison_operator identifier none block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list subscript identifier identifier
Alias for more readable command construction
def noargs(self): "Returns True if the callable takes no arguments" noargs = inspect.ArgSpec(args=[], varargs=None, keywords=None, defaults=None) return self.argspec == noargs
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier list keyword_argument identifier none keyword_argument identifier none keyword_argument identifier none return_statement comparison_operator attribute identifier identifier identifier
Returns True if the callable takes no arguments
def encode_batch(self, inputBatch): X = inputBatch encode = self.encode Y = np.array([ encode(x) for x in X]) return Y
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier return_statement identifier
Encodes a whole batch of input arrays, without learning.
def list_scanners(zap_helper, scanners): scanner_list = zap_helper.zap.ascan.scanners() if scanners is not None and 'all' not in scanners: scanner_list = filter_by_ids(scanner_list, scanners) click.echo(tabulate([[s['id'], s['name'], s['policyId'], s['enabled'], s['attackStrength'], s['alertThreshold']] for s in scanner_list], headers=['ID', 'Name', 'Policy ID', 'Enabled', 'Strength', 'Threshold'], tablefmt='grid'))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list list_comprehension list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end for_in_clause identifier identifier keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Get a list of scanners and whether or not they are enabled.
def create_templates(self, templates): count = 0 for template in templates: if not self.template_exists_db(template): name, location, description, language = template text = self.open_file(location) html_content = self.get_html_content(text) data = { 'name': utils.camel_to_snake(name).upper(), 'html_content': html_content, 'content': self.text_version(html_content), 'subject': self.get_subject(text), 'description': description, 'language': language } if models.EmailTemplate.objects.create(**data): count += 1 return count
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list identifier identifier argument_list 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 call attribute identifier identifier argument_list identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat identifier block expression_statement augmented_assignment identifier integer return_statement identifier
Gets a list of templates to insert into the database
def to_task(self): from google.appengine.api.taskqueue import Task from google.appengine.api.taskqueue import TaskRetryOptions self._increment_recursion_level() self.check_recursion_depth() url = "%s/%s" % (ASYNC_ENDPOINT, self.function_path) kwargs = { 'url': url, 'headers': self.get_headers().copy(), 'payload': json.dumps(self.to_dict()) } kwargs.update(copy.deepcopy(self.get_task_args())) retry_options = copy.deepcopy(DEFAULT_RETRY_OPTIONS) retry_options.update(kwargs.pop('retry_options', {})) kwargs['retry_options'] = TaskRetryOptions(**retry_options) return Task(**kwargs)
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier identifier identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute call attribute identifier identifier argument_list identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list dictionary_splat identifier return_statement call identifier argument_list dictionary_splat identifier
Return a task object representing this async job.
def xmlrpc_task_done(self, result): (task_id, task_results) = result del self.scheduled_tasks[task_id] self.task_store.update_results(task_id, task_results) self.results += 1 return True
module function_definition identifier parameters identifier identifier block expression_statement assignment tuple_pattern identifier identifier identifier delete_statement subscript attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement true
Take the results of a computation and put it into the results list.
def group_comments_by_round(comments, ranking=0): comment_rounds = {} ordered_comment_round_names = [] for comment in comments: comment_round_name = ranking and comment[11] or comment[7] if comment_round_name not in comment_rounds: comment_rounds[comment_round_name] = [] ordered_comment_round_names.append(comment_round_name) comment_rounds[comment_round_name].append(comment) return [(comment_round_name, comment_rounds[comment_round_name]) for comment_round_name in ordered_comment_round_names]
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier dictionary expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier boolean_operator boolean_operator identifier subscript identifier integer subscript identifier integer if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute subscript identifier identifier identifier argument_list identifier return_statement list_comprehension tuple identifier subscript identifier identifier for_in_clause identifier identifier
Group comments by the round to which they belong
def subtract_weeks(self, weeks: int) -> datetime: self.value = self.value - timedelta(weeks=weeks) return self.value
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier call identifier argument_list keyword_argument identifier identifier return_statement attribute identifier identifier
Subtracts number of weeks from the current value
def unindent(self, lines): indent = min( len(self.re.match(r'^ *', line).group()) for line in lines) return [line[indent:].rstrip() for line in lines]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier generator_expression call identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier argument_list for_in_clause identifier identifier return_statement list_comprehension call attribute subscript identifier slice identifier identifier argument_list for_in_clause identifier identifier
Removes any indentation that is common to all of the given lines.
def read_files(filenames): if isinstance(filenames, list): for filename in filenames: with open(filename, 'r') as infile: return infile.read() else: with open(filenames, 'r') as infile: return infile.read()
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list
Read a file into memory.
def cree_widgets(self): for t in self.FIELDS: if type(t) is str: attr, kwargs = t, {} else: attr, kwargs = t[0], t[1].copy() self.champs.append(attr) is_editable = kwargs.pop("is_editable", self.is_editable) args = [self.acces[attr], is_editable] with_base = kwargs.pop("with_base", False) if with_base: args.append(self.acces.base) if 'with_label' in kwargs: label = kwargs.pop('with_label') else: label = ASSOCIATION[attr][0] if kwargs: w = ASSOCIATION[attr][3](*args, **kwargs) else: w = ASSOCIATION[attr][3](*args) self.widgets[attr] = (w, label)
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list identifier dictionary else_clause block expression_statement assignment pattern_list identifier identifier expression_list subscript identifier integer call attribute subscript identifier integer identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier list subscript attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier subscript subscript identifier identifier integer if_statement identifier block expression_statement assignment identifier call subscript subscript identifier identifier integer argument_list list_splat identifier dictionary_splat identifier else_clause block expression_statement assignment identifier call subscript subscript identifier identifier integer argument_list list_splat identifier expression_statement assignment subscript attribute identifier identifier identifier tuple identifier identifier
Create widgets and store them in self.widgets
def clear(self, results=True, errors=True): if results: self.results = [] if errors: self.errors = []
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier true block if_statement identifier block expression_statement assignment attribute identifier identifier list if_statement identifier block expression_statement assignment attribute identifier identifier list
Clears results and errors lists.
def _get_bounds(mapper, values): array = np.array([mapper.get(x) for x in values]) return array[:, 0], array[:, 1]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier return_statement expression_list subscript identifier slice integer subscript identifier slice integer
Extract first and second value from tuples of mapped bins.
def image_create(cmptparms, cspace): lst = [ctypes.c_int, ctypes.POINTER(ImageComptParmType), ctypes.c_int] OPENJPEG.opj_image_create.argtypes = lst OPENJPEG.opj_image_create.restype = ctypes.POINTER(ImageType) image = OPENJPEG.opj_image_create(len(cmptparms), cmptparms, cspace) return(image)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list attribute identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier identifier return_statement parenthesized_expression identifier
Wrapper for openjpeg library function opj_image_create.
def _smallest_buffer(self): smallest = np.inf for buffer in self.buffers: if buffer is None: return 0 elif buffer.shape[0] < smallest: smallest = buffer.shape[0] return smallest
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier none block return_statement integer elif_clause comparison_operator subscript attribute identifier identifier integer identifier block expression_statement assignment identifier subscript attribute identifier identifier integer return_statement identifier
Get the size of the smallest buffer.
def retry(default=None): def decorator(func): @functools.wraps(func) def _wrapper(*args, **kw): for pos in range(1, MAX_RETRIES): try: return func(*args, **kw) except (RuntimeError, requests.ConnectionError) as error: LOGGER.warning("Failed: %s, %s", type(error), error) for _ in range(pos): _rest() LOGGER.warning("Request Aborted") return default return _wrapper return decorator
module function_definition identifier parameters default_parameter identifier none block function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block for_statement identifier call identifier argument_list integer identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern tuple identifier attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier return_statement identifier return_statement identifier
Retry functions after failures
def check(self, profile_data, training_metadata=[]): data = { "profile_json": _validate_dict(profile_data, "profile_data"), "training_metadata": _validate_training_metadata(training_metadata), } response = self.client.post("profile/json/check", data=data) return response.json()
module function_definition identifier parameters identifier identifier default_parameter identifier list block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list
Use the api to check weither the profile_data are valid.
def run(self, refresh_interval=0.05): try: from asciimatics.screen import Screen except ImportError: raise ExternalError("You must have asciimatics installed to use LinebufferUI", suggestion="pip install iotilecore[ui]") Screen.wrapper(self._run_loop, arguments=[refresh_interval])
module function_definition identifier parameters identifier default_parameter identifier float block try_statement block import_from_statement dotted_name identifier identifier dotted_name identifier except_clause identifier block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier list identifier
Set up the loop, check that the tool is installed
def subscriptions(self): if _debug: ChangeOfValueServices._debug("subscriptions") subscription_list = [] for obj, cov_detection in self.cov_detections.items(): for cov in cov_detection.cov_subscriptions: subscription_list.append(cov) return subscription_list
module function_definition identifier parameters identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Generator for the active subscriptions.
def run(m, w, trace=False, steps=1000, show_stack=3): is_pda = True stack = None if not m.oneway: is_pda = False for s in range(m.num_stores): if s == m.input: pass elif m.has_cell(s): pass elif m.has_stack(s): if stack is None: stack = s else: is_pda = False else: is_pda = False if is_pda and stack is not None: if trace: print("using modified Lang algorithm") return run_pda(m, w, stack=stack, trace=trace, show_stack=show_stack) else: if trace: print("using breadth-first search") return run_bfs(m, w, trace=trace, steps=steps)
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier true expression_statement assignment identifier none if_statement not_operator attribute identifier identifier block expression_statement assignment identifier false for_statement identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block pass_statement elif_clause call attribute identifier identifier argument_list identifier block pass_statement elif_clause call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier false else_clause block expression_statement assignment identifier false if_statement boolean_operator identifier comparison_operator identifier none block if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Runs an automaton, automatically selecting a search method.
def users(accountable, query): users = accountable.users(query) headers = ['display_name', 'key'] if users: rows = [[v for k, v in sorted(u.items()) if k in headers] for u in users] rows.insert(0, headers) print_table(SingleTable(rows)) else: click.secho('No users found for query {}'.format( query ), fg='red')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment identifier list_comprehension list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list integer identifier expression_statement call identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
Executes a user search for the given query.
def run(self): self.stop = False while not self.stop: self.tracker.create_snapshot() sleep(self.interval)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false while_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier
Loop until a stop signal is set.
def _generate_username(self): while True: username = str(uuid.uuid4()) username = username.replace('-', '') username = username[:-2] try: User.objects.get(username=username) except User.DoesNotExist: return username
module function_definition identifier parameters identifier block while_statement true block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier subscript identifier slice unary_operator integer try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier except_clause attribute identifier identifier block return_statement identifier
Generate a unique username
def atanh(x, context=None): return _apply_function_in_current_context( BigFloat, mpfr.mpfr_atanh, (BigFloat._implicit_convert(x),), context, )
module function_definition identifier parameters identifier default_parameter identifier none block return_statement call identifier argument_list identifier attribute identifier identifier tuple call attribute identifier identifier argument_list identifier identifier
Return the inverse hyperbolic tangent of x.
def _post_data(options=None, xml=None): params = {'token': options['token'].strip(), 'cmd': 'submitcheck', 'XMLDATA': xml} res = salt.utils.http.query( url=options['url'], method='POST', params=params, data='', decode=True, status=True, header_dict={}, opts=__opts__, ) if res.get('status', None) == salt.ext.six.moves.http_client.OK: if res.get('dict', None) and isinstance(res['dict'], list): _content = res['dict'][0] if _content.get('status', None): return True else: return False else: log.error('No content returned from Nagios NRDP.') return False else: log.error( 'Error returned from Nagios NRDP. Status code: %s.', res.status_code ) return False
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_end keyword_argument identifier true keyword_argument identifier true keyword_argument identifier dictionary keyword_argument identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none attribute attribute attribute attribute attribute identifier identifier identifier identifier identifier identifier block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end none call identifier argument_list subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end integer if_statement call attribute identifier identifier argument_list string string_start string_content string_end none block return_statement true else_clause block return_statement false else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement false
Post data to Nagios NRDP
def extend(self, ampal_container): if isinstance(ampal_container, AmpalContainer): self._ampal_objects.extend(ampal_container) else: raise TypeError( 'Only AmpalContainer objects may be merged with ' 'an AmpalContainer.') return
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement
Extends an `AmpalContainer` with another `AmpalContainer`.
def getBody(cls, url, method='GET', headers={}, data=None, socket=None, timeout=120): if not 'User-Agent' in headers: headers['User-Agent'] = ['Tensor HTTP checker'] return cls().request(url, method, headers, data, socket, timeout)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier dictionary default_parameter identifier none default_parameter identifier none default_parameter identifier integer block if_statement not_operator comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list string string_start string_content string_end return_statement call attribute call identifier argument_list identifier argument_list identifier identifier identifier identifier identifier identifier
Make an HTTP request and return the body
def pull_en_words() -> None: ENGLISH_WORDS_URL = "https://github.com/dwyl/english-words.git" en_words_path = Path(config.EN_WORDS_PATH) if not en_words_path.is_file(): subprocess.run(["git", "clone", ENGLISH_WORDS_URL, str(en_words_path.parent)])
module function_definition identifier parameters type none block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier call identifier argument_list attribute identifier identifier
Fetches a repository containing English words.
def save_state(state, output_dir, keep=False): params_file = os.path.join(output_dir, "model.pkl") with gfile.GFile(params_file, "wb") as f: pickle.dump((state.params, state.step, state.history), f) if keep: params_file = os.path.join(output_dir, "model_{}.pkl".format(state.step)) with gfile.GFile(params_file, "wb") as f: pickle.dump((state.params, state.step, state.history), f) log("Model saved to %s" % params_file, stdout=False)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier false
Save State and optionally gin config.
def rouge_2(hypotheses, references): rouge_2 = [ rouge_n([hyp], [ref], 2) for hyp, ref in zip(hypotheses, references) ] rouge_2_f, _, _ = map(np.mean, zip(*rouge_2)) return rouge_2_f
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list list identifier list identifier integer for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list attribute identifier identifier call identifier argument_list list_splat identifier return_statement identifier
Calculate ROUGE-2 F1, precision, recall scores
def add_data(self, request, pk=None): resp = super().add_data(request, pk) entity = self.get_object() for collection in entity.collections.all(): collection.data.add(*request.data['ids']) return resp
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat subscript attribute identifier identifier string string_start string_content string_end return_statement identifier
Add data to Entity and it's collection.
def start(self): def _heartbeat(): if not self._client.lifecycle.is_live: return self._heartbeat() self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat) self._heartbeat_timer = self._client.reactor.add_timer(self._heartbeat_interval, _heartbeat)
module function_definition identifier parameters identifier block function_definition identifier parameters block if_statement not_operator attribute attribute attribute identifier identifier identifier identifier block return_statement expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier identifier
Starts sending periodic HeartBeat operations.
def api_key(self): if not self._api_key: error_msg = ( f"Email is enabled but API_KEY is not set. " f"See settings.{self.api_key_attr}" ) try: self._api_key = getattr(settings, self.api_key_attr) except AttributeError: raise EmailNotEnabledError(error_msg, code="api_key_attribute_error") else: if not self._api_key: raise EmailNotEnabledError(error_msg, code="api_key_is_none") return self._api_key
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content interpolation attribute identifier identifier string_end try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list identifier attribute identifier identifier except_clause identifier block raise_statement call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end else_clause block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement attribute identifier identifier
Returns the api_key or None.
def next_frame_l1(): hparams = next_frame_basic_deterministic() hparams.loss["targets"] = modalities.video_l1_loss hparams.top["targets"] = modalities.video_l1_top hparams.video_modality_loss_cutoff = 2.4 return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier float return_statement identifier
Basic conv model with L1 modality.
def random_uniform(attrs, inputs, proto_obj): try: from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE except ImportError: raise ImportError("Onnx and protobuf need to be installed. " "Instructions to install - https://github.com/onnx/onnx") new_attrs = translation_utils._remove_attributes(attrs, ['seed']) new_attrs['dtype'] = TENSOR_TYPE_TO_NP_TYPE[int(new_attrs.get('dtype', 1))] return 'random_uniform', new_attrs, inputs
module function_definition identifier parameters identifier identifier identifier block try_statement block import_from_statement dotted_name identifier identifier dotted_name identifier except_clause identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer return_statement expression_list string string_start string_content string_end identifier identifier
Draw random samples from a uniform distribtuion.
def mksls(src, dst=None): with salt.utils.files.fopen(src, 'r') as fh_: ps_opts = xml.to_dict(ET.fromstring(fh_.read())) if dst is not None: with salt.utils.files.fopen(dst, 'w') as fh_: salt.utils.yaml.safe_dump(ps_opts, fh_, default_flow_style=False) else: return salt.utils.yaml.safe_dump(ps_opts, default_flow_style=False)
module function_definition identifier parameters identifier default_parameter identifier none block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator identifier none block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier keyword_argument identifier false else_clause block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier false
Convert an AutoYAST file to an SLS file
def gen_undef(): empty_reg = ReilEmptyOperand() return ReilBuilder.build(ReilMnemonic.UNDEF, empty_reg, empty_reg, empty_reg)
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier
Return an UNDEF instruction.
def counter_mean_and_median(counter): if not counter: return np.nan, np.nan total = sum(v for k, v in counter.items()) mid = total / 2 weighted_sum = 0 items_seen = 0 median_found = False for k, v in sorted(counter.items()): weighted_sum += k * v items_seen += v if not median_found and items_seen >= mid: median = k median_found = True mean = weighted_sum * 1. / total return mean, median
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement expression_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier generator_expression identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier false for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier binary_operator identifier identifier expression_statement augmented_assignment identifier identifier if_statement boolean_operator not_operator identifier comparison_operator identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier true expression_statement assignment identifier binary_operator binary_operator identifier float identifier return_statement expression_list identifier identifier
Calculate the mean and median value of a counter
def get(self, id, depth=3, schema=None): uri = URIRef(id) if schema is None: for o in self.graph.objects(subject=uri, predicate=RDF.type): schema = self.parent.get_schema(str(o)) if schema is not None: break else: schema = self.parent.get_schema(schema) binding = self.get_binding(schema, None) return self._objectify(uri, binding, depth=depth, path=set())
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block for_statement identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier if_statement comparison_operator identifier none block break_statement else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier none return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list
Construct a single object based on its ID.
def ret_pcre_minions(self): tgt = re.compile(self.tgt) refilter = functools.partial(filter, tgt.match) return self._ret_minions(refilter)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Return minions that match via pcre
def register(model, admin=None, category=None): def _model_admin_wrapper(admin_class): site.register(model, admin_class=admin_class) if category: site.register_block(model, category) return admin_class return _model_admin_wrapper
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier return_statement identifier
Decorator to registering you Admin class.
def _trim_and_decode(ids, subtokenizer): try: index = list(ids).index(tokenizer.EOS_ID) return subtokenizer.decode(ids[:index]) except ValueError: return subtokenizer.decode(ids)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list subscript identifier slice identifier except_clause identifier block return_statement call attribute identifier identifier argument_list identifier
Trim EOS and PAD tokens from ids, and decode to return a string.
def prepare(self): text = self.property('caption') if text: capw = int(self.property('caption_width', 0)) item = self.addText(text, capw)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier
Prepares this graphic item to be displayed.
def parse_geometry(geometry, ratio=None): if "%" not in geometry: return xy_geometry_parser(geometry, ratio) return float(geometry.strip("%")) / 100.0
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list identifier identifier return_statement binary_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end float
Enhanced parse_geometry parser with percentage support.
def string(v): if nodesetp(v): if not v: return u'' return string_value(v[0]) elif numberp(v): if v == float('inf'): return u'Infinity' elif v == float('-inf'): return u'-Infinity' elif str(v) == 'nan': return u'NaN' elif int(v) == v and v <= 0xffffffff: v = int(v) return unicode(v) elif booleanp(v): return u'true' if v else u'false' return v
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier block if_statement not_operator identifier block return_statement string string_start string_end return_statement call identifier argument_list subscript identifier integer elif_clause call identifier argument_list identifier block if_statement comparison_operator identifier call identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator identifier call identifier argument_list string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause comparison_operator call identifier argument_list identifier string string_start string_content string_end block return_statement string string_start string_content string_end elif_clause boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier elif_clause call identifier argument_list identifier block return_statement conditional_expression string string_start string_content string_end identifier string string_start string_content string_end return_statement identifier
Convert a value to a string.
def x10_command_type(command): command_type = X10CommandType.DIRECT if command in [X10_COMMAND_ALL_UNITS_OFF, X10_COMMAND_ALL_LIGHTS_ON, X10_COMMAND_ALL_LIGHTS_OFF]: command_type = X10CommandType.BROADCAST return command_type
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier list identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier return_statement identifier
Return the X10 command type from an X10 command.
def _update_project_watch(config, task_presenter, results, long_description, tutorial): logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') path = os.getcwd() event_handler = PbsHandler(config, task_presenter, results, long_description, tutorial) observer = Observer() observer.schedule(event_handler, path, recursive=False) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join()
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list try_statement block while_statement true block expression_statement call attribute identifier identifier argument_list integer except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Update a project in a loop.
def remove_dependent_cols(M, tol=1e-6, display=False): R = la.qr(M, mode='r')[0][:M.shape[1], :] I = (abs(R.diagonal())>tol) if sp.any(~I) and display: print(('cols ' + str(sp.where(~I)[0]) + ' have been removed because linearly dependent on the others')) R = M[:,I] else: R = M.copy() return R
module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier false block expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end integer slice subscript attribute identifier identifier integer slice expression_statement assignment identifier parenthesized_expression comparison_operator call identifier argument_list call attribute identifier identifier argument_list identifier if_statement boolean_operator call attribute identifier identifier argument_list unary_operator identifier identifier block expression_statement call identifier argument_list parenthesized_expression binary_operator binary_operator string string_start string_content string_end call identifier argument_list subscript call attribute identifier identifier argument_list unary_operator identifier integer string string_start string_content string_end expression_statement assignment identifier subscript identifier slice identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Returns a matrix where dependent columsn have been removed
def delete(self): if lib.EnvDeleteActivation(self._env, self._act) != 1: raise CLIPSError(self._env) self._env = None
module function_definition identifier parameters identifier block if_statement comparison_operator call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer block raise_statement call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier none
Remove the activation from the agenda.
def dump(self): id = self.get("id") if not id: id = "(none)" else: id = id[0] parent = self.get("parent") if not parent: parent = "(none)" else: parent = parent[0] print "'%s'" % id print "Parent project:%s", parent print "Requirements:%s", self.get("requirements") print "Default build:%s", string.join(self.get("debuild-build")) print "Source location:%s", string.join(self.get("source-location")) print "Projects to build:%s", string.join(self.get("projects-to-build").sort());
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript identifier integer print_statement binary_operator string string_start string_content string_end identifier print_statement string string_start string_content string_end identifier print_statement string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end print_statement string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end print_statement string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end print_statement string string_start string_content string_end call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list
Prints the project attributes.
def training_loop(self): if not self.restarting: self._write_counters(self._local_step_at_start, self._global_step) tf.logging.info( "Training %s up to %d, %d to go", self.model_mode, self.target_local_step, self.steps_to_go ) yield self._write_counters(self.target_local_step, -1)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement yield expression_statement call attribute identifier identifier argument_list attribute identifier identifier unary_operator integer
Context manager wrapping the training loop, updates step counters.
def content_type(self, data): self._content_type = str(data) self.add_header('Content-Type', str(data))
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier
The Content-Type header value for this request.
def delete_model(self, meta: dict): bucket = self.connect() if bucket is None: raise BackendRequiredError blob_name = "models/%s/%s.asdf" % (meta["model"], meta["uuid"]) self._log.info(blob_name) try: self._log.info("Deleting model ...") bucket.delete_blob(blob_name) except NotFound: self._log.warning("Model %s already deleted.", meta["uuid"])
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block raise_statement identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end
Delete the model from GCS.
def run_migration(connection, queries, engine): with connection.cursor() as cursorMig: queries = parse_statements(queries, engine) for query in queries: cursorMig.execute(query) connection.commit() return True
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement true
Apply a migration to the SQL server
def __add_stack(self, span, limit=None): span.stack = [] frame_count = 0 tb = traceback.extract_stack() tb.reverse() for frame in tb: if limit is not None and frame_count >= limit: break if "INSTANA_DEV" not in os.environ: if re_tracer_frame.search(frame[0]) is not None: continue if re_with_stan_frame.search(frame[2]) is not None: continue span.stack.append({ "c": frame[0], "n": frame[1], "m": frame[2] }) if limit is not None: frame_count += 1
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier list expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier identifier block break_statement if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list subscript identifier integer none block continue_statement if_statement comparison_operator call attribute identifier identifier argument_list subscript identifier integer none block continue_statement expression_statement call attribute attribute identifier identifier identifier argument_list 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 if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier integer
Adds a backtrace to this span
def listThirdPartyLibs(self, configuration = 'Development'): interrogator = self._getUE4BuildInterrogator() return interrogator.list(self.getPlatformIdentifier(), configuration, self._getLibraryOverrides())
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list
Lists the supported Unreal-bundled third-party libraries
def _write_images(self, iteration:int)->None: "Writes model generated, original and real images to Tensorboard" self.img_gen_vis.write(learn=self.learn, trn_batch=self.trn_batch, val_batch=self.val_batch, iteration=iteration, tbwriter=self.tbwriter)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type none block expression_statement string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Writes model generated, original and real images to Tensorboard
def merge_values(values1,values2): array1 = values_to_array(values1) array2 = values_to_array(values2) if array1.size == 0: return array2 if array2.size == 0: return array1 merged_array = [] for row_array1 in array1: for row_array2 in array2: merged_row = np.hstack((row_array1,row_array2)) merged_array.append(merged_row) return np.atleast_2d(merged_array)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block return_statement identifier if_statement comparison_operator attribute identifier identifier integer block return_statement identifier expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Merges two numpy arrays by calculating all possible combinations of rows
def getRandomBinaryTreeLeafNode(binaryTree): if binaryTree.internal == True: if random.random() > 0.5: return getRandomBinaryTreeLeafNode(binaryTree.left) else: return getRandomBinaryTreeLeafNode(binaryTree.right) else: return binaryTree
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier true block if_statement comparison_operator call attribute identifier identifier argument_list float block return_statement call identifier argument_list attribute identifier identifier else_clause block return_statement call identifier argument_list attribute identifier identifier else_clause block return_statement identifier
Get random binary tree node.
def draw(self): pos = np.arange(self.scores_.shape[0]) + 0.5 self.ax.barh(pos, self.scores_) self.ax.set_yticks(pos) self.ax.set_yticklabels(self.features_) return self.ax
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list subscript attribute attribute identifier identifier identifier integer float expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Draws the feature correlation to dependent variable, called from fit.
def getLastPoses(self, unRenderPoseArrayCount, unGamePoseArrayCount): fn = self.function_table.getLastPoses pRenderPoseArray = TrackedDevicePose_t() pGamePoseArray = TrackedDevicePose_t() result = fn(byref(pRenderPoseArray), unRenderPoseArrayCount, byref(pGamePoseArray), unGamePoseArrayCount) return result, pRenderPoseArray, pGamePoseArray
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier call identifier argument_list identifier identifier return_statement expression_list identifier identifier identifier
Get the last set of poses returned by WaitGetPoses.
def mode(self): mu = self.mean() sigma = self.std() ret_val = math.exp(mu - sigma**2) if math.isnan(ret_val): ret_val = float("inf") return ret_val
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier binary_operator identifier integer if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end return_statement identifier
Computes the mode of a log-normal distribution built with the stats data.
def start(self): self.agent.submit(self._start()) self.is_running = True
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true
starts behaviour in the event loop
def _cx_state_psutil(self, tags=None): metrics = defaultdict(int) tags = [] if tags is None else tags for conn in psutil.net_connections(): protocol = self._parse_protocol_psutil(conn) status = self.tcp_states['psutil'].get(conn.status) metric = self.cx_state_gauge.get((protocol, status)) if metric is None: self.log.warning('Metric not found for: %s,%s', protocol, status) else: metrics[metric] += 1 for metric, value in iteritems(metrics): self.gauge(metric, value, tags=tags)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier conditional_expression list comparison_operator identifier none identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier else_clause block expression_statement augmented_assignment subscript identifier identifier integer for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier
Collect metrics about connections state using psutil
def _file_size(file_path, uncompressed=False): _, ext = os.path.splitext(file_path) if uncompressed: if ext in {".gz", ".gzip"}: with gzip.GzipFile(file_path, mode="rb") as fp: try: fp.seek(0, os.SEEK_END) return fp.tell() except ValueError: fp.seek(0) while len(fp.read(8192)) != 0: pass return fp.tell() elif ext in {".bz", ".bz2", ".bzip", ".bzip2"}: with bz2.BZ2File(file_path, mode="rb") as fp: fp.seek(0, os.SEEK_END) return fp.tell() return os.path.getsize(file_path)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block if_statement comparison_operator identifier set string string_start string_content string_end string string_start string_content string_end block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block try_statement block expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier return_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list integer while_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list integer integer block pass_statement return_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier set string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier return_statement call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list identifier
Return size of a single file, compressed or uncompressed
def avl_release_parent(node): parent = node.parent if parent is not None: if parent.right is node: parent.right = None elif parent.left is node: parent.left = None else: raise AssertionError('impossible state') node.parent = None parent.balance = max(height(parent.right), height(parent.left)) + 1 return node, parent
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier none elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier none else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier binary_operator call identifier argument_list call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier integer return_statement expression_list identifier identifier
removes the parent of a child
def pack(window, sizer, expand=1.1): "simple wxPython pack function" tsize = window.GetSize() msize = window.GetMinSize() window.SetSizer(sizer) sizer.Fit(window) nsize = (10*int(expand*(max(msize[0], tsize[0])/10)), 10*int(expand*(max(msize[1], tsize[1])/10.))) window.SetSize(nsize)
module function_definition identifier parameters identifier identifier default_parameter identifier float block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier tuple binary_operator integer call identifier argument_list binary_operator identifier parenthesized_expression binary_operator call identifier argument_list subscript identifier integer subscript identifier integer integer binary_operator integer call identifier argument_list binary_operator identifier parenthesized_expression binary_operator call identifier argument_list subscript identifier integer subscript identifier integer float expression_statement call attribute identifier identifier argument_list identifier
simple wxPython pack function
def gen_anytext(*args): bag = [] for term in args: if term is not None: if isinstance(term, list): for term2 in term: if term2 is not None: bag.append(term2) else: bag.append(term) return ' '.join(bag)
module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement comparison_operator identifier none block if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Convenience function to create bag of words for anytext property
def save(self): try: response = requests.post(self._upload_url, auth=self.jss.session.auth, verify=self.jss.session.verify, files=self.resource) except JSSPostError as error: if error.status_code == 409: raise JSSPostError(error) else: raise JSSMethodNotAllowedError(self.__class__.__name__) if response.status_code == 201: if self.jss.verbose: print "POST: Success" print response.text.encode("utf-8") elif response.status_code >= 400: error_handler(JSSPostError, response)
module function_definition identifier parameters identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list identifier else_clause block raise_statement call identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier integer block if_statement attribute attribute identifier identifier identifier block print_statement string string_start string_content string_end print_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list identifier identifier
POST the object to the JSS.
def highwiredict2xmlstring(highwire_elements, ordering=HIGHWIRE_ORDER): highwire_elements.sort(key=lambda obj: ordering.index(obj.name)) root = Element('metadata') for element in highwire_elements: attribs = {'name': element.name, 'content': element.content} SubElement(root, 'meta', attribs) return '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring( root, pretty_print=True )
module function_definition identifier parameters identifier default_parameter identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end identifier return_statement binary_operator string string_start string_content escape_sequence string_end call identifier argument_list identifier keyword_argument identifier true
Create an XML string from the highwire data dictionary.