code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def getElementsBy(self, cond: Callable[[Element], bool]) -> NodeList: return getElementsBy(self, cond)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getElementsBy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Get elements in this document which matches condition.
def block_header_verify( block_data, prev_hash, block_hash ): serialized_header = block_header_to_hex( block_data, prev_hash ) candidate_hash_bin_reversed = hashing.bin_double_sha256(binascii.unhexlify(serialized_header)) candidate_hash = binascii.hexlify( candidate_hash_bin_reversed[::-1] ) return bloc...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'block_header_verify'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
Verify whether or not bitcoind's block header matches the hash we expect.
def simple_state_machine(): from random import random from furious.async import Async number = random() logging.info('Generating a number... %s', number) if number > 0.25: logging.info('Continuing to do stuff.') return Async(target=simple_state_machine) return number
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'simple_state_machine'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '10', '16', ...
Pick a number, if it is more than some cuttoff continue the chain.
def action(cls, view): name = "%s:%s" % (cls.name, view.__name__) path = "%s/%s" % (cls.url, view.__name__) cls.actions.append((view.__doc__, path)) return cls.register(path, name=name)(view)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'action'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}...
Register admin view action.
def guess_mode(self, data): if data.ndim == 2: return "L" elif data.shape[-1] == 3: return "RGB" elif data.shape[-1] == 4: return "RGBA" else: raise ValueError( "Un-supported shape for image conversion %s" % list(data.shape)...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'guess_mode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Guess what type of image the np.array is representing
def init_drivers(enable_debug_driver=False): for driver in DRIVERS: try: if driver != DebugDriver or enable_debug_driver: CLASSES.append(driver) except Exception: continue
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_drivers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}...
Initialize all the drivers.
def warn_disabled(scraperclass, reasons): out.warn(u"Skipping comic %s: %s" % (scraperclass.getName(), ' '.join(reasons.values())))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'warn_disabled'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Print warning about disabled comic modules.
def add_letter_to_axis(ax, let, col, x, y, height): if len(let) == 2: colors = [col, "white"] elif len(let) == 1: colors = [col] else: raise ValueError("3 or more Polygons are not supported") for polygon, color in zip(let, colors): new_polygon = affinity.scale( ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_letter_to_axis'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier'...
Add 'let' with position x,y and height height to matplotlib axis 'ax'.
def source_pipe(self, source, ps=None): if isinstance(source, string_types): source = self.source(source) source.dataset = self.dataset source._bundle = self iter_source, source_pipe = self._iterable_source(source, ps) if self.limited_run: source_pipe.limi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'source_pipe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Create a source pipe for a source, giving it access to download files to the local cache
def ReadAllClientActionRequests(self, client_id, cursor=None): query = ("SELECT request, UNIX_TIMESTAMP(leased_until), leased_by, " "leased_count " "FROM client_action_requests " "WHERE client_id = %s") cursor.execute(query, [db_utils.ClientIDToInt(client_id)]) ret = [...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ReadAllClientActionRequests'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'chil...
Reads all client messages available for a given client_id.
def _getUE4BuildInterrogator(self): ubtLambda = lambda target, platform, config, args: self._runUnrealBuildTool(target, platform, config, args, True) interrogator = UE4BuildInterrogator(self.getEngineRoot(), self._getEngineVersionDetails(), self._getEngineVersionHash(), ubtLambda) return interrogator
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_getUE4BuildInterrogator'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Uses UE4BuildInterrogator to interrogate UnrealBuildTool about third-party library details
def text(value, encoding="utf-8", errors="strict"): if isinstance(value, text_type): return value elif isinstance(value, bytes): return text_type(value, encoding, errors) else: return text_type(value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'text'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'v...
Convert a value to str on Python 3 and unicode on Python 2.
def check_section(node, section, keys=None): if keys: for key in keys: if key not in node: raise ValueError('Missing key %r inside %r node' % (key, section))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_section'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Validate keys in a section
async def executemany( self, sql: str, parameters: Iterable[Iterable[Any]] ) -> Cursor: cursor = await self._execute(self._conn.executemany, sql, parameters) return Cursor(self, cursor)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'executemany'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': []...
Helper to create a cursor and execute the given multiquery.
def exclude_fields(obj, exclude=EXCLUDE): return dict([(k, getattr(obj, k)) for k in obj.__slots__ if k not in exclude])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exclude_fields'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Return dict of object without parent attrs.
def highlightBlock(self, text): for expression, nth, format in self.rules: index = expression.indexIn(text, 0) while index >= 0: index = expression.pos(nth) length = len(expression.cap(nth)) self.setFormat(index, length, format) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'highlightBlock'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Apply syntax highlighting to the given block of text.
def soviet_checksum(code): def sum_digits(code, offset=1): total = 0 for digit, index in zip(code[:7], count(offset)): total += int(digit) * index summed = (total / 11 * 11) return total - summed check = sum_digits(code, 1) if check == 10: check = sum_digi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'soviet_checksum'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c...
Courtesy of Sir Vlad Lavrov.
def signature(self): if self.usage is not None: return self.usage params = self.clean_params if not params: return '' result = [] for name, param in params.items(): greedy = isinstance(param.annotation, converters._Greedy) if param....
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'signature'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Returns a POSIX-like signature useful for help command output.
def error_message_and_exit(message, error_result): if message: error_message(message) puts(json.dumps(error_result, indent=2)) 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': 'error_message_and_exit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
Prints error messages in blue, the failed task result and quits.
def query(self, titles, pageids=None, cparams=None): query = self.QUERY.substitute( WIKI=self.uri, ENDPOINT=self.endpoint, TITLES=safequote(titles) or pageids) status = titles or pageids if pageids and not titles: query = query.replace('&titles=', ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Returns MediaWiki action=query query string
def sampleLocation(self): areaRatio = self.radius / (self.radius + self.height) if random.random() < areaRatio: return self._sampleLocationOnDisc() else: return self._sampleLocationOnSide()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sampleLocation'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Simple method to sample uniformly from a cylinder.
def effect_info(self, mechanism, purview): return repertoire_distance( Direction.EFFECT, self.effect_repertoire(mechanism, purview), self.unconstrained_effect_repertoire(purview) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'effect_info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Return the effect information for a mechanism over a purview.
def focus_prev(self): mid = self.get_selected_mid() localroot = self._sanitize_position((mid,)) if localroot == self.get_focus()[1]: newpos = self._tree.prev_position(mid) if newpos is not None: newpos = self._sanitize_position((newpos,)) else: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'focus_prev'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
focus previous message in depth first order
def _publish_match(self, publish, names=False, name_only=False): if names: for name in names: if not name_only and isinstance(name, re._pattern_type): if re.match(name, publish.name): return True else: op...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_publish_match'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': ...
Check if publish name matches list of names or regex patterns
def deprecate_module_attribute(mod, deprecated): deprecated = set(deprecated) class Wrapper(object): def __getattr__(self, attr): if attr in deprecated: warnings.warn("Property %s is deprecated" % attr) return getattr(mod, attr) def __setattr__(self, attr,...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'deprecate_module_attribute'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
Return a wrapped object that warns about deprecated accesses
def _validate_desc(self, desc): if desc is None: return desc if not isinstance(desc, STRING_TYPES): raise TypeError( "predicate description for Matching must be a string, " "got %r" % (type(desc),)) if not IS_PY3 and isinstance(desc, unicod...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_desc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Validate the predicate description.
def to_dict(self): d = super(WaitTime, self).to_dict() d['condition'] = {'waitTime': {'waitTime': self.wait_time}} return d
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Save this wait_time condition into a dictionary.
def step(self, **kwargs): kwargs.setdefault('linestyle', kwargs.pop('where', 'steps-post')) data = self.append(self.value[-1:], inplace=False) return data.plot(**kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'step'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Create a step plot of this series
def walk_commands(self): for command in tuple(self.all_commands.values()): yield command if isinstance(command, GroupMixin): yield from command.walk_commands()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'walk_commands'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
An iterator that recursively walks through all commands and subcommands.
def _note_reply_pending(self, option, state): if not self.telnet_opt_dict.has_key(option): self.telnet_opt_dict[option] = TelnetOption() self.telnet_opt_dict[option].reply_pending = state
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_note_reply_pending'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
Record the status of requested Telnet options.
def initialize_weights_nn(data, means, lognorm=True): genes, cells = data.shape k = means.shape[1] if lognorm: data = log1p(cell_normalize(data)) for i in range(cells): for j in range(k): pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initialize_weights_nn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':...
Initializes the weights with a nearest-neighbor approach using the means.
def add_f77_to_env(env): try: F77Suffixes = env['F77FILESUFFIXES'] except KeyError: F77Suffixes = ['.f77'] try: F77PPSuffixes = env['F77PPFILESUFFIXES'] except KeyError: F77PPSuffixes = [] DialectAddToEnv(env, "F77", F77Suffixes, F77PPSuffixes)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_f77_to_env'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'en...
Add Builders and construction variables for f77 to an Environment.
def current_state(self): field_names = set() [field_names.add(f.name) for f in self._meta.local_fields] [field_names.add(f.attname) for f in self._meta.local_fields] return dict([(field_name, getattr(self, field_name)) for field_name in field_names])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'current_state'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Returns a ``field -> value`` dict of the current state of the instance.
def read_large_int(self, bits, signed=True): return int.from_bytes( self.read(bits // 8), byteorder='little', signed=signed)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_large_int'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Reads a n-bits long integer value.
def dispatch(argdict): cmd = argdict['command'] ftc = getattr(THIS_MODULE, 'do_'+cmd) ftc(argdict)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'argdict'...
Call the command-specific function, depending on the command.
def cursor(self): if self._cursor is None: self._cursor = self.cursor_class(self, self.get_initial_elements()) return self._cursor
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cursor'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Cache and return cursor_class instance
def full_redraw(self): self.left.draw_statuses(self.statuses, self.selected) self.right.draw(self.get_selected_status()) self.header.draw(self.user) self.draw_footer_status()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'full_redraw'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Perform a full redraw of the UI.
def plot_memory(calc_id=-1): dstore = util.read(calc_id) plots = [] for task_name in dstore['task_info']: mem = dstore['task_info/' + task_name]['mem_gb'] plots.append((task_name, mem)) plt = make_figure(plots) plt.show()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plot_memory'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']};...
Plot the memory occupation
def complete_get(self, text, line, begidx, endidx): options = self.GET_OPTS if not text: completions = options else: completions = [f for f in options if f.startswith(text) ] return c...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children'...
completion for find command
def _get_dependencies_from_cache(ireq): if os.environ.get("PASSA_IGNORE_LOCAL_CACHE"): return if ireq.editable: return try: deps = DEPENDENCY_CACHE[ireq] pyrq = REQUIRES_PYTHON_CACHE[ireq] except KeyError: return try: packaging.specifiers.SpecifierSet(...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_dependencies_from_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
Retrieves dependencies for the requirement from the dependency cache.
def silence(self): sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'silence'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Route all stdout to null.
def govuk_template(context: Context, version='0.23.0', replace_fonts=True): if FileSet(os.path.join(context.app.govuk_templates_path, 'base.html')): return url = 'https://github.com/alphagov/govuk_template/releases' \ '/download/v{0}/django_govuk_template-{0}.tgz'.format(version) try: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'govuk_template'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '11']}; {'id': '4', 'type': 'typed_parameter', 'children':...
Installs GOV.UK template
def fetch_libcapnp(savedir, url=None): is_preconfigured = False if url is None: url = libcapnp_url is_preconfigured = True dest = pjoin(savedir, 'capnproto-c++') if os.path.exists(dest): info("already have %s" % dest) return fname = fetch_archive(savedir, url, libcapn...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fetch_libcapnp'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
download and extract libcapnp
def iter_xCharts(self): plot_tags = ( qn('c:area3DChart'), qn('c:areaChart'), qn('c:bar3DChart'), qn('c:barChart'), qn('c:bubbleChart'), qn('c:doughnutChart'), qn('c:line3DChart'), qn('c:lineChart'), qn('c:ofPieChart'), qn('c:pie3DChart'), qn('c:pieChart'), qn('c:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iter_xCharts'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Generate each xChart child element in document.
def build_table(self, table, force=False): sources = self._resolve_sources(None, [table]) for source in sources: self.build_source(None, source, force=force) self.unify_partitions()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Build all of the sources for a table
def _create_worker(self, method, *args, **kwargs): thread = QThread() worker = RequestsDownloadWorker(method, args, kwargs) worker.moveToThread(thread) worker.sig_finished.connect(self._start) self._sig_download_finished.connect(worker.sig_download_finished) self._sig_dow...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_worker'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': ...
Create a new worker instance.
def _fetch_result(self): self._result = self.conn.query_single(self.object_type, self.url_params, self.query_params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fetch_result'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Fetch the queried object.
def _load_result(response, ret): if response['code'] is None: ret['comment'] = response['content'] elif response['code'] == 401: ret['comment'] = '401 Forbidden: Authentication required!' elif response['code'] == 404: ret['comment'] = response['content']['message'] elif response[...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_result'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
format the results of listing functions
def fit_for_distance(self): for prop in self.properties.keys(): if prop in self.ic.bands: 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': 'fit_for_distance'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
``True`` if any of the properties are apparent magnitudes.
def allParses(self,meter=None,include_bounded=False,one_per_meter=True): meter=self.get_meter(meter) try: parses=self.__parses[meter.id] if one_per_meter: toreturn=[] for _parses in parses: sofar=set() _parses2=[] for _p in _parses: _pm=_p.str_meter() if not _pm in sofar: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'allParses'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Return a list of lists of parses.
def cmd_repeat(self, args): if len(args) == 0: if len(self.repeats) == 0: print("No repeats") return for i in range(len(self.repeats)): print("%u: %s" % (i, self.repeats[i])) return if args[0] == 'add': if le...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cmd_repeat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
repeat a command at regular intervals
def prune_to_subset(self, subset, inplace=False): if not subset.issubset(self.labels): print('"subset" is not a subset') return if not inplace: t = self.copy() else: t = self t._tree.retain_taxa_with_labels(subset) t._tree.encode_bi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prune_to_subset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Prunes the Tree to just the taxon set given in `subset`
def WriteMessagesFile(file_descriptor, package, version, printer): _WriteFile(file_descriptor, package, version, _Proto2Printer(printer))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'WriteMessagesFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'...
Write the given extended file descriptor to out as a message file.
def filtered(self, efilter): if not self.params: self.params={'filter' : efilter} return self if not self.params.has_key('filter'): self.params['filter'] = efilter return self self.params['filter'].update(efilter) return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filtered'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
Applies a filter to the search
def rank(self): rank = re.findall(r'\d+', self._rank) if len(rank) == 0: return None return rank[0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rank'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Returns an ``int`` of the team's rank at the time the game was played.
def _dfs(self, visited): if self not in visited: visited.add(self) for successor in self._children + self._followOns: successor._dfs(visited)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_dfs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Adds the job and all jobs reachable on a directed path from current node to the given set.
def slow_minimum_distance2(hull_a, hull_b): d2_min = np.iinfo(int).max for a in hull_a: if within_hull(a, hull_b): return 0 for b in hull_b: if within_hull(b, hull_a): return 0 for pt_a in hull_a: for pt_b in hull_b: d2_min = min(d2_min, np.sum...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'slow_minimum_distance2'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
Do the minimum distance by exhaustive examination of all points
def _format_metric_name(self, m_name, cfunc): try: aggr = CFUNC_TO_AGGR[cfunc] except KeyError: aggr = cfunc.lower() try: m_name = CACTI_TO_DD[m_name] if aggr != 'avg': m_name += '.{}'.format(aggr) return m_name ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_format_metric_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [...
Format a cacti metric name into a Datadog-friendly name
def linreg_ols_qr(y, X): import numpy as np try: q, r = np.linalg.qr(np.dot(X.T, X)) return np.dot(np.dot(np.linalg.inv(r), q.T), np.dot(X.T, y)) except np.linalg.LinAlgError: print("LinAlgError: Factoring failed") return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'linreg_ols_qr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Linear Regression, OLS, inverse by QR Factoring
def shelve(self): logger.info('creating shelve data') fname = str(self.create_path.absolute()) inst = sh.open(fname, writeback=self.writeback) self.is_open = True return inst
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shelve'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'...
Return an opened shelve object.
def ValidateIapJwt(iap_jwt, expected_audience): try: key_id = jwt.get_unverified_header(iap_jwt).get("kid") if not key_id: raise IAPValidationFailedError("No key ID") key = GetIapKey(key_id) decoded_jwt = jwt.decode( iap_jwt, key, algorithms=["ES256"], audience=expected_audience) ret...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ValidateIapJwt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Validates an IAP JWT.
def until_synced(self, timeout=None): futures = [r.until_synced(timeout) for r in dict.values(self.children)] yield tornado.gen.multi(futures, quiet_exceptions=tornado.gen.TimeoutError)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'until_synced'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Return a tornado Future; resolves when all subordinate clients are synced
def data_children(self) -> List["DataNode"]: res = [] for child in self.children: if isinstance(child, DataNode): res.append(child) elif not isinstance(child, SchemaTreeNode): res.extend(child.data_children()) return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'data_children'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Return the set of all data nodes directly under the receiver.
def insert_right(self, item): 'Insert a new item. If equal keys are found, add to the right' k = self._key(item) i = bisect_right(self._keys, k) self._keys.insert(i, k) self._items.insert(i, item)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'insert_right'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Insert a new item. If equal keys are found, add to the right
def centroid(self): if self.v is None: raise ValueError('Mesh has no vertices; centroid is not defined') return np.mean(self.v, axis=0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'centroid'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Return the geometric center.
def clean(self): super(CTENode, self).clean() if self.parent and self.pk in getattr(self.parent, self._cte_node_path): raise ValidationError(_("A node cannot be made a descendant of itself."))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Prevents cycles in the tree.
def reset_all(self, suppress_logging=False): pool_names = list(self.pools) for name in pool_names: self.reset(name, suppress_logging)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_all'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
iterates thru the list of established connections and resets them by disconnecting and reconnecting
def publish(self, topic, message): self.connect() log.info('publish {}'.format(message)) self.client.publish(topic, message)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'publish'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Publish an MQTT message to a topic.
def create_writer(self, name, *args, **kwargs): self._check_format(name) return self._formats[name]['writer'](*args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_writer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [...
Create a new writer instance for a given format.
def extern_store_i64(self, context_handle, i64): c = self._ffi.from_handle(context_handle) return c.to_value(i64)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extern_store_i64'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Given a context and int32_t, return a new Handle to represent the int32_t.
def letter_set(self): end_str = ctypes.create_string_buffer(MAX_CHARS) cgaddag.gdg_letter_set(self.gdg, self.node, end_str) return [char for char in end_str.value.decode("ascii")]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'letter_set'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Return the letter set of this node.
def flush(self): keys = list(self.keys()) if keys: return self.database.delete(*keys)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flush'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i...
Remove all cached objects from the database.
def _is_ctype(self, ctype): if not self.valid: return False mime = self.content_type return self.ContentMimetypes.get(mime) == ctype
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_ctype'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Return True iff content is valid and of the given type.
def main(): name = os.path.splitext(os.path.basename(__file__))[0] logging.basicConfig( format="%(asctime)s [%(process)s] %(levelname)s {} - %(message)s".format(name), level=logging.INFO) parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--edges", metavar="FILENA...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '25', '44', '55', '71', '87'...
Main interface function for the command line.
def _add_unknown_char(self, string): if self.has_xvowel: self._promote_solitary_xvowel() self.unknown_char = string self._flush_char()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_unknown_char'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Adds an unknown character to the stack.
def vfolders(access_key): fields = [ ('Name', 'name'), ('Created At', 'created_at'), ('Last Used', 'last_used'), ('Max Files', 'max_files'), ('Max Size', 'max_size'), ] if access_key is None: q = 'query { vfolders { $fields } }' else: q = 'query($a...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vfolders'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'access_k...
List and manage virtual folders.
def elements(self): elements = [] for el in ct: if isinstance(el[1], datapoint.Element.Element): elements.append(el[1]) return elements
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'elements'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Return a list of the elements which are not None
def as_dict(self): if hasattr(self, 'cust_dict'): return self.cust_dict if hasattr(self, 'attr_check'): self.attr_check() cls_bltns = set(dir(self.__class__)) return {a: getattr(self, a) for a in dir(self) if a not in cls_bltns}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
returns an dict version of the object, based on it's attributes
def username(self): if self._username is None: if self.has_logged_in: self._username = self._get_username() else: raise AuthenticationError('Not logged in.') return self._username
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'username'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ...
Username of the current API user
def load(filename: str, format: str = None): path = Path(filename).resolve() with path.open() as file: data = file.read() if format is None: loader, error_class = _load_autodetect, InvalidMofileFormat else: try: loader, error_class = formats[format] except Key...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'...
Load a task file and get a ``Project`` back.
def block_events(self): BaseObject.block_events(self) for i in range(self._widget.topLevelItemCount()): self._widget.topLevelItem(i).param.blockSignals(True) return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'block_events'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Special version of block_events that loops over all tree elements.
def count_documents(self, filter={}, *args, **kwargs): result = self.collection.count_documents(filter, *args, **kwargs) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'count_documents'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '10']}; {'id': '4', 'type': 'identifier', 'children'...
Count all the documents in a collection accurately
def path(self): if self.parent: try: parent_path = self.parent.path.encode() except AttributeError: parent_path = self.parent.path return os.path.join(parent_path, self.name) return b"/"
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Node's relative path from the root node
def __parseResponse(self, result): response = [] for data in result['data'] : result_dict={} for k,v in data.items() : column = self.getOutputColumn(k) if column != None: type = column.getSqlColumnType() if t...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__parseResponse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Parses the server response.
def insert_function(self, fname, ftype): "Inserts a new function" index = self.insert_id(fname, SharedData.KINDS.FUNCTION, [SharedData.KINDS.GLOBAL_VAR, SharedData.KINDS.FUNCTION], ftype) self.table[index].set_attribute("Params",0) return index
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'insert_function'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Inserts a new function
def _write_conf_file(): with open(CONF_FILE, "w") as f: f.write(DEFAULT_PROFTPD_CONF) logger.debug("'%s' created.", CONF_FILE)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_write_conf_file'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 't...
Write configuration file as it is defined in settings.
def window_from_array(array): from ...utils.lal import (find_typed_function) dtype = array.dtype seq = find_typed_function(dtype, 'Create', 'Sequence')(array.size) seq.data = array return find_typed_function(dtype, 'Create', 'WindowFromSequence')(seq)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'window_from_array'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Convert a `numpy.ndarray` into a LAL `Window` object
def options(self): config = self._config o = {} o.update(self._default_smtp_options) o.update(self._default_message_options) o.update(self._default_backend_options) o.update(get_namespace(config, 'EMAIL_', valid_keys=o.keys())) o['port'] = int(o['port']) o...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'options'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Reads all EMAIL_ options and set default values.
def month_crumb(date): year = date.strftime('%Y') month = date.strftime('%m') month_text = DateFormat(date).format('F').capitalize() return Crumb(month_text, reverse('zinnia:entry_archive_month', args=[year, month]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'month_crumb'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'date'...
Crumb for a month.
def _heuristic_bin_width(obs): IQR = sp.percentile(obs, 75) - sp.percentile(obs, 25) N = len(obs) return 2*IQR*N**(-1/3)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_heuristic_bin_width'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Optimal histogram bin width based on the Freedman-Diaconis rule
def _doc_property(klass, prop): header = "{klass}.{name}".format(klass=klass.__name__, name=_name(prop), ) docstring = _doc(prop) return _concat(header, docstring)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_doc_property'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Generate the docstring of a property.
def resolveSystem(self, sysID): ret = libxml2mod.xmlACatalogResolveSystem(self._o, sysID) return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolveSystem'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Try to lookup the catalog resource for a system ID
def random_secret() -> Secret: while True: secret = os.urandom(32) if secret != constants.EMPTY_HASH: return Secret(secret)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'random_secret'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'type', 'children': ['5']}; {'id': '5', '...
Return a random 32 byte secret except the 0 secret since it's not accepted in the contracts
def df(self, qname_predicates:bool=False, keep_variable_type:bool=True) -> pd.DataFrame: local_df = self.df.copy() if qname_predicates: for col in self.columns: local_df.rename({col: self.g.qname(col)}) if not keep_variable_type: pass return local_...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'df'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
Multi funcitonal DataFrame with settings
def list_users(self, envs=[], query="/users/"): juicer.utils.Log.log_debug( "List Users In: %s", ", ".join(envs)) for env in envs: juicer.utils.Log.log_info("%s:" % (env)) _r = self.connectors[env].get(query) if _r.status_code == Constants.PULP_GET_OK:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_users'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
List users in specified environments
def wrap_function(func): if is_text(func): return compile_expression(func) numarg = func.__code__.co_argcount if numarg == 0: def temp(row, rownum, rows): return func() return temp elif numarg == 1: def temp(row, rownum, rows): return func(row) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wrap_function'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fun...
RETURN A THREE-PARAMETER WINDOW FUNCTION TO MATCH
def add_data_files(*include_dirs): 'called from setup.py in skeleton projects' data_files = [] for include_dir in include_dirs: for root, directories, filenames in os.walk(include_dir): include_files = [] for filename in filenames: if filename.endswith('.local...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_data_files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; ...
called from setup.py in skeleton projects
def dump_pytorch_graph(graph): f = "{:25} {:40} {} -> {}" print(f.format("kind", "scopeName", "inputs", "outputs")) for node in graph.nodes(): print(f.format(node.kind(), node.scopeName(), [i.unique() for i in node.inputs()], [i.unique() for i in node....
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dump_pytorch_graph'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
List all the nodes in a PyTorch graph.
def cut(list_, index=0): if isinstance(index, int): cut_ = lambda x: x[index] else: cut_ = lambda x: getattr(x, index) return list(map(cut_, list_))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cut'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'list_'};...
Cut a list by index or arg
def to_type(cls, typename): NAME_TYPES = {cls.TYPE_NAMES[x]: x for x in cls.TYPE_NAMES} return NAME_TYPES.get(typename, None)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'...
Converts a type ID to name. On error returns None