code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def update1(self, key: str, data: np.ndarray, size: int) -> None: print(data) if key in self.get_keys(): self.data[key][data[0]] = data else: newdata = np.zeros((size, 6)) newdata[data[0]] = data self.data[key] = newdata
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update1'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '15']}; {'id': '4', 'type': 'identifier', 'children': ...
Update one entry in specific record in datastore
def open_file(filename): if sys.platform.startswith("darwin"): subprocess.call(("open", filename)) elif sys.platform == "cygwin": subprocess.call(("cygstart", filename)) elif os.name == "nt": os.system("start %s" % filename) elif os.name == "posix": subprocess.call(("xdg-...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open_file'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filenam...
Multi-platform way to make the OS open a file with its default application
def domain_whois_history(self, domain, limit=None): params = dict() if limit is not None: params['limit'] = limit uri = self._uris["whois_domain_history"].format(domain) resp_json = self.get_parse(uri, params) return resp_json
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'domain_whois_history'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ...
Gets whois history for a domain
def _create_vlanprofile(self, handle, vlan_id, ucsm_ip): vlan_name = self.make_vlan_name(vlan_id) vlan_profile_dest = (const.VLAN_PATH + const.VLAN_PROFILE_PATH_PREFIX + vlan_name) try: vp1 = handle.query_dn(const.VLAN_PATH) if not vp1: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_vlanprofile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childre...
Creates VLAN profile to able associated with the Port Profile.
def twisted_absolute_path(path, request): parsed = urlparse.urlparse(request.uri) if parsed.scheme != '': path_parts = parsed.path.lstrip('/').split('/') request.prepath = path_parts[0:1] request.postpath = path_parts[1:] path = request.prepath[0] return path, request
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'twisted_absolute_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Hack to fix twisted not accepting absolute URIs
def extract_dms (archive, compression, cmd, verbosity, interactive, outdir): check_archive_ext(archive) cmdlist = [cmd, '-d', outdir] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(['u', archive]) return cmdlist
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_dms'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'chil...
Extract a DMS archive.
def version(): path = join("lib", _CONFIG["name"], "__version__.py") with open(path) as stream: exec(stream.read()) return __version__
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'version'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16', '36']}; {'id': '5',...
Get the local package version.
def _build_receipt_table(result, billing="hourly", test=False): title = "OrderId: %s" % (result.get('orderId', 'No order placed')) table = formatting.Table(['Cost', 'Description'], title=title) table.align['Cost'] = 'r' table.align['Description'] = 'l' total = 0.000 if test: prices = res...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_receipt_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children':...
Retrieve the total recurring fee of the items prices
def reset_ball(self, x, y): self.sprite.position.x = x self.sprite.position.y = y
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_ball'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
reset ball to set location on the screen
def load_gpi(self, gpi_path): if self.config.gpi_authority_path is not None: gpis = dict() parser = entityparser.GpiParser() with open(self.config.gpi_authority_path) as gpi_f: entities = parser.parse(file=gpi_f) for entity in entities: gpis[entity["id...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_gpi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Loads a GPI as a file from the `config.gpi_authority_path`
def set(key, value, timeout = -1, adapter = MemoryAdapter): if adapter(timeout = timeout).set(key, pickle.dumps(value)): return value else: return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
set cache by code, must set timeout length
def format_currency_field(__, prec, number, locale): locale = Locale.parse(locale) currency = get_territory_currencies(locale.territory)[0] if prec is None: pattern, currency_digits = None, True else: prec = int(prec) pattern = locale.currency_formats['standard'] pattern ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_currency_field'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child...
Formats a currency field.
def extraSelections(self, qpart, block, columnIndex): blockText = block.text() if columnIndex < len(blockText) and \ blockText[columnIndex] in self._ALL_BRACKETS and \ qpart.isCode(block, columnIndex): return self._highlightBracket(blockText[columnIndex], qpart, blo...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extraSelections'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': ...
List of QTextEdit.ExtraSelection's, which highlighte brackets
def resolve(self, value): if self is value: raise TypeError('Cannot resolve promise with itself.') if isinstance(value, Promise): value.done(self.resolve, self.reject) return if self._state != 'pending': raise RuntimeError('Promise is no longer pen...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Resolves the promise with the given value.
def _add_recent(self, doc, logged_id): "Keep a tab on the most recent message for each channel" spec = dict(channel=doc['channel']) doc['ref'] = logged_id doc.pop('_id') self._recent.replace_one(spec, doc, upsert=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_recent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Keep a tab on the most recent message for each channel
async def remove_listener(self, channel, callback): if self.is_closed(): return if channel not in self._listeners: return if callback not in self._listeners[channel]: return self._listeners[channel].remove(callback) if not self._listeners[chann...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_listener'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Remove a listening callback on the specified channel.
def releases(self, owner, module): resource = self.RRELEASES params = { self.PMODULE: owner + '-' + module, self.PLIMIT: self.max_items, self.PSHOW_DELETED: 'true', self.PSORT_BY: self.VRELEASE_DATE, } for page in self._fetch(resource, para...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'releases'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Fetch the releases of a module.
def _encode(self, data: mx.sym.Symbol, data_length: mx.sym.Symbol, seq_len: int) -> mx.sym.Symbol: data_reverse = mx.sym.SequenceReverse(data=data, sequence_length=data_length, use_sequence_length=True) hidden_forward, _, _ = self.forward_rnn.encode(data, da...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_encode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '13', '21']}; {'id': '4', 'type': 'identifier', 'children':...
Bidirectionally encodes time-major data.
def write_and_return( command, ack, serial_connection, timeout=DEFAULT_WRITE_TIMEOUT): clear_buffer(serial_connection) with serial_with_temp_timeout( serial_connection, timeout) as device_connection: response = _write_to_device_and_return(command, ack, device_connection) return r...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_and_return'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'...
Write a command and return the response
def gc(self): gc = len([base for base in self.seq if base == 'C' or base == 'G']) return float(gc) / len(self)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gc'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id':...
Find the frequency of G and C in the current sequence.
def _siftup_max(heap, pos): 'Maxheap variant of _siftup' endpos = len(heap) startpos = pos newitem = heap[pos] childpos = 2*pos + 1 while childpos < endpos: rightpos = childpos + 1 if rightpos < endpos and not heap[rightpos] < heap[childpos]: childpos = rightpos ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_siftup_max'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Maxheap variant of _siftup
def _get_schema(): schema_path = os.path.join(os.path.dirname(__file__), 'schema', 'scheduling_block_schema.json') with open(schema_path, 'r') as file: schema_data = file.read() schema = json.loads(schema_data) return schema
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_schema'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '25', '45', '54']}; {...
Get the schema for validation
def graceful_exit(self, msg): if self.caught_error: self.print2file(self.stderr, False, False, self.caught_error) self.log(msg) sys.exit(1)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'graceful_exit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
This function Tries to update the MSQL database before exiting.
def _get_main_and_json(directory): directory = os.path.normpath(os.path.abspath(directory)) checker_main = os.path.normpath(os.path.join(directory, os.path.pardir, "checker-workflow-wrapping-tool.cwl")) if checker_main and os.path.exists(checker_main): main_cwl = [checker_main] else: mai...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_main_and_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Retrieve the main CWL and sample JSON files from a bcbio generated directory.
def getTopdir(topfile, start=None): if not start: start = os.getcwd() here = start toomany = 20 while toomany > 0: if os.path.exists(os.path.join(here, topfile)): return here next = os.path.dirname(here) if next == here: break here = next ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getTopdir'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'to...
walk upwards from the current directory until we find this topfile
def _compute_acq_withGradients(self, x): means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x) fmins = self.model.get_fmin() f_acqu = None df_acqu = None for m, s, fmin, dmdx, dsdx in zip(means, stds, fmins, dmdxs, dsdxs): phi, Phi, u = get_quantiles(self.ji...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_compute_acq_withGradients'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
Integrated Expected Improvement and its derivative
def _ligotimegps(s, ns=0): from lal import LIGOTimeGPS try: return LIGOTimeGPS(s, ns) except TypeError: return LIGOTimeGPS(int(s), int(ns))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ligotimegps'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Catch TypeError and cast `s` and `ns` to `int`
def truth(val, context): try: 0 + val except TypeError: lower_val = val.lower() if lower_val in TRUE: return True elif lower_val in FALSE: return False else: raise FilterError("Bad boolean value %r in %r (expected one of '%s', or '%s')"...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'truth'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'val'};...
Convert truth value in "val" to a boolean.
def radiation_values(self, location, timestep=1): sp = Sunpath.from_location(location) altitudes = [] dates = self._get_datetimes(timestep) for t_date in dates: sun = sp.calculate_sun_from_date_time(t_date) altitudes.append(sun.altitude) dir_norm, diff_hor...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'radiation_values'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Lists of driect normal, diffuse horiz, and global horiz rad at each timestep.
def initiate_tasks(self): self.tasks_classes = TaskLoader().load_tasks( paths=self.configuration[Configuration.ALGORITHM][Configuration.TASKS][Configuration.PATHS])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initiate_tasks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Loads all tasks using `TaskLoader` from respective configuration option
def _cutadapt_pe_cmd(fastq_files, out_files, quality_format, base_cmd, data): fq1, fq2 = [objectstore.cl_input(x) for x in fastq_files] of1, of2 = out_files base_cmd += " --minimum-length={min_length} ".format(min_length=dd.get_min_read_length(data)) first_cmd = base_cmd + " -o {of1_tx} -p {of2_tx} " + ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cutadapt_pe_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'child...
run cutadapt in paired end mode
def find_dimension_by_name(self, dim_name): for dim in self.dimensions: if is_equal_strings_ignore_case(dim.name, dim_name): return dim return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_dimension_by_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
the method searching dimension with a given name
def write_line(self, line, count=1): self.write(line) self.write_newlines(count)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_line'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
writes the line and count newlines after the line
def use_sequestered_assessment_part_view(self): self._containable_views['assessment_part'] = SEQUESTERED self._get_sub_package_provider_session('assessment_authoring', 'assessment_part_lookup_session') for session in self._provider_sessions: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_sequestered_assessment_part_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'child...
Pass through to provider AssessmentPartLookupSession.use_sequestered_assessment_part_view
def find_config(revision): if not is_git_repo(): return None cfg_path = f"{revision}:.cherry_picker.toml" cmd = "git", "cat-file", "-t", cfg_path try: output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) path_type = output.strip().decode("utf-8") return cfg_pat...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'revis...
Locate and return the default config for current revison.
def list_local_plugins(plugin_type, plugins_path, plugin_details): installed_plugins = list() for plugin in next(os.walk(plugins_path))[1]: s = plugin_details(plugin) installed_plugins.append(plugin) click.secho(s) if not installed_plugins: click.secho("[*] You do not have an...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_local_plugins'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []...
List local plugins with details.
def acq(self, graph): mean, std = self.gpr.predict(np.array([graph.extract_descriptor()])) if self.optimizemode is OptimizeMode.Maximize: return mean + self.beta * std return mean - self.beta * std
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'acq'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
estimate the value of generated graph
def _get_best_prediction(self, record, train=True): if not self.trees: return best = (+1e999999, None) for tree in self.trees: best = min(best, (tree.mae.mean, tree)) _, best_tree = best prediction, tree_mae = best_tree.predict(record, train=train) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_best_prediction'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ...
Gets the prediction from the tree with the lowest mean absolute error.
def parse_bind(bind): if isinstance(bind, Connection): engine = bind.engine else: engine = bind m = re.match(r"Engine\((.*?)\)", str(engine)) if m is not None: u = urlparse(m.group(1)) uses_netloc.append(u.scheme) safe_url = "" if u.password is None: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_bind'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'bind'}...
Parses a connection string and creates SQL trace metadata
def update(self, **kwargs): ret_val = super(ManagerUtilsQuerySet, self).update(**kwargs) post_bulk_operation.send(sender=self.model, model=self.model) return ret_val
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Overrides Django's update method to emit a post_bulk_operation signal when it completes.
def _direct_render(self, name, attrs): context = { 'image': self.image_url(), 'name': name, 'key': self._key, 'id': u'%s_%s' % (self.id_prefix, attrs.get('id')) if self.id_prefix else attrs.get('id'), 'audio': self.audio_url(), } self.i...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_direct_render'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Render the widget the old way - using field_template or output_format.
def _clear_strobes(self): self['SEQ']['GLOBAL_SHIFT_EN'].setall(False) self['SEQ']['GLOBAL_CTR_LD'].setall(False) self['SEQ']['GLOBAL_DAC_LD'].setall(False) self['SEQ']['PIXEL_SHIFT_EN'].setall(False) self['SEQ']['INJECTION'].setall(False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clear_strobes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Resets the "enable" and "load" output streams to all 0.
def eglGetDisplay(display=EGL_DEFAULT_DISPLAY): res = _lib.eglGetDisplay(display) if not res or res == EGL_NO_DISPLAY: raise RuntimeError('Could not create display') return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'eglGetDisplay'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']...
Connect to the EGL display server.
def factorial(n): if isinstance(n, float): if n.is_integer(): n = int(n) if not isinstance(n, INT_TYPES): raise TypeError("Non-integer input (perhaps you need Euler Gamma " "function or Gauss Pi function)") if n < 0: raise ValueError("Input shouldn't be negative") return re...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'factorial'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'n'}; {'...
Factorial function that works with really big numbers.
def print_device_aldb(self, addr): if Address(addr).id == self.plm.address.id: device = self.plm else: dev_addr = Address(addr) device = self.plm.devices[dev_addr.id] if device: if device.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_device_aldb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Diplay the All-Link database for a device.
def Reverse(self, copy=False): numPoints = self.GetN() if copy: revGraph = self.Clone() else: revGraph = self X = self.GetX() EXlow = self.GetEXlow() EXhigh = self.GetEXhigh() Y = self.GetY() EYlow = self.GetEYlow() EYhigh =...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Reverse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Reverse the order of the points
def _determine_username(self, ip): ssh = subprocess.Popen([ "ssh", "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no", "root@%s" % ip], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.DEVN...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_determine_username'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
SSH in as root and determine the username.
def parallel_variantcall_region(samples, run_parallel): to_process, extras = _dup_samples_by_variantcaller(samples) split_fn = _split_by_ready_regions(".vcf.gz", "work_bam", get_variantcaller) samples = _collapse_by_bam_variantcaller( grouped_parallel_split_combine(to_process, split_fn, ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parallel_variantcall_region'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children'...
Perform variant calling and post-analysis on samples by region.
def delete_notification_rule(self, id, **kwargs): endpoint = '{0}/{1}/notification_rules/{2}'.format( self.endpoint, self['id'], id, ) return self.request('DELETE', endpoint=endpoint, query_params=kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_notification_rule'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre...
Get a notification rule for this user.
def com_google_fonts_check_family_tnum_horizontal_metrics(fonts): from fontbakery.constants import RIBBI_STYLE_NAMES from fontTools.ttLib import TTFont RIBBI_ttFonts = [TTFont(f) for f in fonts if style(f) in RIBBI_STYLE_NAMES] tnum_widths = {} for ttFont in RIBBI_ttFonts...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'com_google_fonts_check_family_tnum_horizontal_metrics'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'id...
All tabular figures must have the same width across the RIBBI-family.
def _is_non_string_iterable(value): if isinstance(value, str): return False if hasattr(value, '__iter__'): return True if isinstance(value, collections.abc.Sequence): return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_non_string_iterable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Whether a value is iterable.
def cycle_focus(self): windows = self.windows() new_index = (windows.index(self.active_window) + 1) % len(windows) self.active_window = windows[new_index]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cycle_focus'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Cycle through all windows.
def map_grounding(): if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) stmts_json = body.get('statements') stmts = stmts_from_json(stmts_json) stmts_out = ac.map_grounding(stmts) return _return_stmts(stmts_out)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map_grounding'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '14', '29', '38', '...
Map grounding on a list of INDRA Statements.
def batch_predict(dataset, model_dir, output_csv, output_bq_table): import apache_beam as beam from google.datalab.utils import LambdaJob from . import _predictor if output_csv is None and output_bq_table is None: raise ValueError('output_csv and output_bq_table cannot both be None.') job_id =...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'batch_predict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []...
Batch predict running locally.
def to_log(x1, x2, x1err, x2err): logx1 = numpy.log10(numpy.array(x1)) logx2 = numpy.log10(numpy.array(x2)) x1err = numpy.log10(numpy.array(x1)+numpy.array(x1err)) - logx1 x2err = numpy.log10(numpy.array(x2)+numpy.array(x2err)) - logx2 return logx1, logx2, x1err, x2err
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_log'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Take linear measurements and uncertainties and transform to log values.
def parse_uinput_mapping(name, mapping): axes, buttons, mouse, mouse_options = {}, {}, {}, {} description = "ds4drv custom mapping ({0})".format(name) for key, attr in mapping.items(): key = key.upper() if key.startswith("BTN_") or key.startswith("KEY_"): buttons[key] = attr ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_uinput_mapping'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Parses a dict of mapping options.
def version(): import pkg_resources version = pkg_resources.require(PROJECT_NAME)[0].version floyd_logger.info(version)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'version'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '8', '21']}; {'id': '5', ...
View the current version of the CLI.
def read_dir_tree(self, file_hash): json_d = self.read_index_object(file_hash, 'tree') node = {'files' : json_d['files'], 'dirs' : {}} for name, hsh in json_d['dirs'].iteritems(): node['dirs'][name] = self.read_dir_tree(hsh) return node
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_dir_tree'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Recursively read the directory structure beginning at hash
def _create_arc(self, inst, destination, placeable=None): this_container = None if isinstance(placeable, containers.Well): this_container = placeable.get_parent() elif isinstance(placeable, containers.WellSeries): this_container = placeable.get_parent() elif isins...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_arc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [],...
Returns a list of coordinates to arrive to the destination coordinate
def bartlett(timeseries, segmentlength, **kwargs): kwargs.pop('noverlap', None) return welch(timeseries, segmentlength, noverlap=0, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bartlett'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Calculate a PSD using Bartlett's method
def _deployment_menu_entry(deployment): paths = ", ".join([_module_name_for_display(module) for module in deployment['modules']]) regions = ", ".join(deployment.get('regions', [])) return "%s - %s (%s)" % (deployment.get('name'), paths, regions)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_deployment_menu_entry'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Build a string to display in the 'select deployment' menu.
def simple( child, shared, parent ): return ( not child.get('refs',()) and ( not shared.get(child['address']) or shared.get(child['address']) == [parent['address']] ) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'simple'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Return sub-set of children who are "simple" in the sense of group_children
def create_noise(length, level=4): noise = bytearray(length) adjust = 128 - int(level / 2) i = 0 while i < length: v = random.randint(0, 256) noise[i] = v % level + adjust i += 1 return noise
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_noise'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Create white noise for background
def _grid_col(self): tr = self._tr idx = tr.tc_lst.index(self) preceding_tcs = tr.tc_lst[:idx] return sum(tc.grid_span for tc in preceding_tcs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_grid_col'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
The grid column at which this cell begins.
def reset(yes): ok = yes or confirm('Do you really want to destroy all your data? (y/n) ') if not ok: return dbpath = os.path.realpath(os.path.expanduser(config.dbserver.file)) if os.path.isfile(dbpath) and os.access(dbpath, os.W_OK): if dbserver.get_status() == 'running': if...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'yes'}; {'id...
Remove all the datastores and the database of the current user
def create_trainer(self, username, team, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=True, daily_goal=None, total_goal=None, prefered=True, account=None, verified=False): args = locals() url = api_url+'trainers/' payload = { 'username': username, 'faction': team, ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '37']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_trainer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22', '25', '28', '31', ...
Add a trainer to the database
def kube_resourcequota(self, metric, scraper_config): metric_base_name = scraper_config['namespace'] + '.resourcequota.{}.{}' suffixes = {'used': 'used', 'hard': 'limit'} if metric.type in METRIC_TYPES: for sample in metric.samples: mtype = sample[self.SAMPLE_LABELS]....
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'kube_resourcequota'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []...
Quota and current usage by resource type.
def _try_open(cls): handle = None for usb_cls, subcls, protocol in [(adb_device.CLASS, adb_device.SUBCLASS, adb_device.PROTOCOL), (fastboot_device.CLASS, fas...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_try_open'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; ...
Try to open a USB handle.
def save_program(self, title, bytes, line=32768): self.standard_program_header(title, len(bytes), line) bytes = [self.BLOCK_TYPE_DATA] + [(int(x) & 0xFF) for x in bytes] self.standard_block(bytes)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_program'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []...
Saves the given bytes as a BASIC program.
def _is_partial_index(gbi_file): with open(gbi_file) as in_handle: for i, _ in enumerate(in_handle): if i > 2: return False return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_partial_index'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Check for truncated output since grabix doesn't write to a transactional directory.
def _schema_from_verb(verb, partial=False): from .verbs import Verbs return getattr(Verbs, verb)(partial=partial)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_schema_from_verb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Return an instance of schema for given verb.
def parse_config(file_path): config_parser = configparser.ConfigParser() config_parser.read(file_path) plugin_config = {} options = config_parser.options(CONFIG_OPTION) for option in options: try: plugin_config[option] = config_parser.get(CONFIG_OPTION, option) if plu...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file...
Loads the configuration file given as parameter
def type_name(self) -> T.Optional[str]: return self.args[1] if len(self.args) > 1 else None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'type_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Return type name associated with given docstring metadata.
def _weights_callback(self, msg): weights = np.array(msg.data) if len(self._weight_buffers) == 0: self._weight_buffers = [[] for i in range(len(weights))] for i, w in enumerate(weights): if len(self._weight_buffers[i]) == self._ntaps: self._weight_buffers[...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_weights_callback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Callback for recording weights from sensor.
def flatten_container(self, container): for names in ARG_MAP.values(): if names[TransformationTypes.MARATHON.value]['name'] and \ '.' in names[TransformationTypes.MARATHON.value]['name']: marathon_dotted_name = names[TransformationTypes.MARATHON.value]['na...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten_container'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Accepts a marathon container and pulls out the nested values into the top level
def docstring(self, servicer): s = getattr(servicer, to_lower_camel_case(self.name)).__doc__ \ or "TODO: no docstring in .proto file" if self.uses_request: s += "\n" for field in get_fields(self.request_type): if field != self.field_name: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'docstring'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Generate a doc-string.
def dynamodb_autoscaling_policy(tables): return Policy( Statement=[ Statement( Effect=Allow, Resource=dynamodb_arns(tables), Action=[ dynamodb.DescribeTable, dynamodb.UpdateTable, ] ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dynamodb_autoscaling_policy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],...
Policy to allow AutoScaling a list of DynamoDB tables.
def authenticate_credentials(self, token: bytes, request=None): user = AuthToken.get_user_for_token(token) if user is None: raise AuthenticationFailed(_('Invalid auth token.')) if not user.is_active: raise AuthenticationFailed(_('User inactive or deleted.')) retur...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate_credentials'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'childr...
Authenticate the token with optional request for context.
def move_point_cat(point, ipoint, to_clust, from_clust, cl_attr_freq, membship, centroids): membship[to_clust, ipoint] = 1 membship[from_clust, ipoint] = 0 for iattr, curattr in enumerate(point): to_attr_counts = cl_attr_freq[to_clust][iattr] from_attr_counts = cl_attr_fre...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_point_cat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifie...
Move point between clusters, categorical attributes.
def allow_network_access_grading(self): vals = self._hook_manager.call_hook('task_network_grading', course=self.get_course(), task=self, default=self._network_grading) return vals[0] if len(vals) else self._network_grading
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'allow_network_access_grading'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
Return True if the grading container should have access to the network
def lookup(self, mac): oui = ":".join(mac.split(":")[:3]).upper() return self[oui]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lookup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Find OUI name matching to a MAC
def init_app(self, app): assert 'zodb' not in app.extensions, \ 'app already initiated for zodb' app.extensions['zodb'] = _ZODBState(self, app) app.teardown_request(self.close_db)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_app'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Configure a Flask application to use this ZODB extension.
def validate_hex(value): try: binascii.unhexlify(value) except Exception: raise vol.Invalid( '{} is not of hex format'.format(value)) return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_hex'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'valu...
Validate that value has hex format.
def current_grid_empty(self): empty = True if not any(self.magic_dataframe.df.index): empty = True elif len(self.grid.row_labels) > 1: empty = False else: non_null_vals = [val for val in self.magic_dataframe.df.values[0] if cb.not_null(val, False)] ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'current_grid_empty'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Check to see if grid is empty except for default values
def _assert_valid_permission(self, perm_str): if perm_str not in ORDERED_PERM_LIST: raise d1_common.types.exceptions.InvalidRequest( 0, 'Permission must be one of {}. perm_str="{}"'.format( ', '.join(ORDERED_PERM_LIST), perm_str ), ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_assert_valid_permission'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
Raise D1 exception if ``perm_str`` is not a valid permission.
def strip_wsgi(request): meta = copy(request.META) for key in meta: if key[:4] == 'wsgi': meta[key] = None return meta
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'strip_wsgi'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'reques...
Strip WSGI data out of the request META data.
async def jsk_vc_youtube_dl(self, ctx: commands.Context, *, url: str): if not youtube_dl: return await ctx.send("youtube_dl is not installed.") voice = ctx.guild.voice_client if voice.is_playing(): voice.stop() url = url.lstrip("<").rstrip(">") voice.play(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'jsk_vc_youtube_dl'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '11', '12']}; {'id': '4', 'type': 'identifier', 'childr...
Plays audio from youtube_dl-compatible sources.
def download_log_of_current_script(): try: src_file = get_workbench().get_current_editor().get_filename(False) if src_file is None: return download_log(src_file) except Exception: error_msg = traceback.format_exc(0)+'\n' showerror("Error", error_msg)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'download_log_of_current_script'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; ...
download log of current python script from EV3
def plot_sphere(ax, center, radius, color='black', alpha=1., linspace_count=_LINSPACE_COUNT): u = np.linspace(0, 2 * np.pi, linspace_count) v = np.linspace(0, np.pi, linspace_count) sin_v = np.sin(v) x = center[0] + radius * np.outer(np.cos(u), sin_v) y = center[1] + radius * np.outer(np.sin(u), sin...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_sphere'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'ch...
Plots a 3d sphere, given the center and the radius.
def override_env_variables(): env_vars = ("LOGNAME", "USER", "LNAME", "USERNAME") old = [os.environ[v] if v in os.environ else None for v in env_vars] for v in env_vars: os.environ[v] = "test" yield for i, v in enumerate(env_vars): if old[i]: os.environ[v] = old[i]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'override_env_variables'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '32'...
Override user environmental variables with custom one.
def filter(self, run_counts, criteria): correctness = criteria['correctness'] assert correctness.dtype == np.bool filtered_counts = deep_copy(run_counts) for key in filtered_counts: filtered_counts[key] = filtered_counts[key][correctness] return filtered_counts
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Return run counts only for examples that are still correctly classified
def remove_cron(self, client, event): for index, cron in enumerate(self.crons): if cron.event == event: _log.info("De-registering cron '%s'.", event) self.crons.pop(index) break return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_cron'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Remove a cron entry by event name.
def execute(self): if self._decode_output: with Popen(self.command, shell=True, stdout=PIPE) as process: self._output = [i.decode("utf-8").strip() for i in process.stdout] self._success = True else: os.system(self.command) self._success...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'execute'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Execute a system command.
def _completed_families(self, reference_name, rightmost_boundary): in_progress = self._right_coords_in_progress[reference_name] while len(in_progress): right_coord = in_progress[0] if right_coord < rightmost_boundary: in_progress.pop(0) left_famili...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_completed_families'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
returns one or more families whose end < rightmost boundary
def handle_error(self, error, response): query_params = {"error": error.error} query = urlencode(query_params) location = "%s?%s" % (self.client.redirect_uri, query) response.status_code = 302 response.body = "" response.add_header("Location", location) return res...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_error'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Redirects the client in case an error in the auth process occurred.
async def _ask_queue_update(self): try: while True: await asyncio.sleep(self._queue_update_timer) if self._queue_update_last_attempt == 0 or self._queue_update_last_attempt > self._queue_update_last_attempt_max: if self._queue_update_last_attempt: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ask_queue_update'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Send a ClientGetQueue message to the backend, if one is not already sent
def read_static_uplink(self): if self.node_list is None or self.node_uplink_list is None: return for node, port in zip(self.node_list.split(','), self.node_uplink_list.split(',')): if node.strip() == self.host_name: self.static_uplink...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_static_uplink'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Read the static uplink from file, if given.
def GetCredentials(package_name, scopes, client_id, client_secret, user_agent, credentials_filename=None, api_key=None, client=None, oauth2client_args=None, **kwds): scopes = util.NormalizeScopes(scopes) client_info =...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetCredentials'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12', '15', '18', '21']}; {'id': '4', ...
Attempt to get credentials, using an oauth dance as the last resort.
def connect(self): ctx = Context(self.module, self.create_mediator()) ctx.logger = self.logger ctx.default_factory = self.default_factory return ctx
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Returns a context that uses this pool as a connection source.
def Indirect(self, off): N.enforce_number(off, N.UOffsetTFlags) return off + encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Indirect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Indirect retrieves the relative offset stored at `offset`.