code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def log_if(level, msg, condition, *args): if condition: log(level, msg, *args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_if'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Logs 'msg % args' at level 'level' only if condition is fulfilled.
def fixtags(self, text): text = _guillemetLeftPat.sub(ur'\1 \2', text) text = _guillemetRightPat.sub(ur'\1 ', text) return text
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fixtags'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Clean up special characters, only run once, next-to-last before doBlockLevels
def render_thread(self): obs = True while obs: obs = self._obs_queue.get() if obs: for alert in obs.observation.alerts: self._alerts[sc_pb.Alert.Name(alert)] = time.time() for err in obs.action_errors: if err.result != sc_err.Success: self._alerts[sc_e...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'render_thread'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
A render loop that pulls observations off the queue to render.
def inh(table): t = [] for i in table: t.append(np.ndarray.tolist(np.arcsinh(i))) return t
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inh'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id...
inverse hyperbolic sine transformation
def parse_datetime(s: str) -> datetime.date: for fmt in (CREATION_DATE_FMT, PUBLISHED_DATE_FMT, PUBLISHED_DATE_FMT_2): try: dt = datetime.strptime(s, fmt) except ValueError: pass else: return dt raise ValueError('Incorrect datetime format for {}'.forma...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_datetime'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5',...
Try to parse a datetime object from a standard datetime format or date format.
def _hash(number, alphabet): hashed = '' len_alphabet = len(alphabet) while True: hashed = alphabet[number % len_alphabet] + hashed number //= len_alphabet if not number: return hashed
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_hash'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'number...
Hashes `number` using the given `alphabet` sequence.
def kube_cronjob_next_schedule_time(self, metric, scraper_config): check_basename = scraper_config['namespace'] + '.cronjob.on_schedule_check' curr_time = int(time.time()) for sample in metric.samples: on_schedule = int(sample[self.SAMPLE_VALUE]) - curr_time tags = [ ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'kube_cronjob_next_schedule_time'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', '...
Time until the next schedule
def create_postgresql_pypostgresql(username, password, host, port, database, **kwargs): return create_engine( _create_postgresql_pypostgresql( username, password, host, port, database), **kwargs )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_postgresql_pypostgresql'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': ...
create an engine connected to a postgresql database using pypostgresql.
def _load_manifest_from_url(manifest, url, verify_certificate=True, username=None, password=None): try: if username and password: manifest_file_handler = StringIO(lib.authenticated_get(username, password, url, verify=verify_certi...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_manifest_from_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier...
load a url body into a manifest
def object_ns(self): return Namespace( subject=self.object_, object_=None, prefix=self.prefix, qualifier=self.qualifier, version=self.version, )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'object_ns'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Create a new namespace for the current namespace's object value.
def use_comparative_asseessment_part_item_view(self): self._object_views['asseessment_part_item'] = COMPARATIVE for session in self._get_provider_sessions(): try: session.use_comparative_asseessment_part_item_view() except AttributeError: pass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_comparative_asseessment_part_item_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', ...
Pass through to provider AssessmentPartItemSession.use_comparative_asseessment_part_item_view
def _all_dims(x, default_dims=None): if x.get_shape().ndims is not None: return list(xrange(x.get_shape().ndims)) else: return default_dims
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_all_dims'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'...
Returns a list of dims in x or default_dims if the rank is unknown.
def slicesum(self, start, stop=None, axis=0): return self.slice(start, stop, axis).sum(axis)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'slicesum'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Slices the histogram along axis, then sums over that slice, returning a d-1 dimensional histogram
def entropy(self, base = 2): entropy = 0 if not base and self.base: base = self.base for type in self._dist: if not base: entropy += self._dist[type] * -math.log(self._dist[type]) else: entropy += self._dist[type] * -math.log(self._dist[typ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'entropy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
Compute the entropy of the distribution
def _class_tags(cls): class_tags = set() for base in cls.mro()[1:]: class_tags.update(getattr(base, '_class_tags', set())) return class_tags
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_class_tags'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}...
Collect the tags from all base classes.
def _calc_mask(self): mask = [] for row in self._constraints: mask.append(tuple(x is None for x in row)) return tuple(mask)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_calc_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Computes a boolean mask from the user defined constraints.
def _selectTree( self ): self.uiGanttTREE.blockSignals(True) self.uiGanttTREE.clearSelection() for item in self.uiGanttVIEW.scene().selectedItems(): item.treeItem().setSelected(True) self.uiGanttTREE.blockSignals(False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_selectTree'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Matches the tree selection to the views selection.
def open_json(file_name): with open(file_name, "r") as json_data: data = json.load(json_data) return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file_na...
returns json contents as string
def abbreviate(labels, rfill=' '): max_len = max(len(l) for l in labels) for i in range(1, max_len): abbrev = [l[:i].ljust(i, rfill) for l in labels] if len(abbrev) == len(set(abbrev)): break return abbrev
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'abbreviate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'l...
Abbreviate labels without introducing ambiguities.
def find_source_lines(self): strs = trace.find_strings(self.filename) lines = trace.find_lines_from_code(self.fn.__code__, strs) self.firstcodelineno = sys.maxint for lineno in lines: self.firstcodelineno = min(self.firstcodelineno, lineno) self.sourcelines.setdef...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_source_lines'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
Mark all executable source lines in fn as executed 0 times.
def dataset(self): data = tablib.Dataset() if len(list(self)) == 0: return data first = self[0] data.headers = first.keys() for row in self.all(): row = _reduce_datetimes(row.values()) data.append(row) return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dataset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
A Tablib Dataset representation of the RecordCollection.
def twirl_url(self): return construct_api_url(self.input, 'twirl', self.resolvers, False, self.get3d, False, **self.kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'twirl_url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
Url of a TwirlyMol 3D viewer.
def prettylist(list_): if not list_: return '' values = set() uniqueList = [] for entry in list_: if not entry in values: values.add(entry) uniqueList.append(entry) return uniqueList[0] if len(uniqueList) == 1 \ else '[' + '; '.join(uniqueList) + ']'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prettylist'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'list_'...
Filter out duplicate values while keeping order.
def omit(self): self._omit = self.lib.iperf_get_test_omit(self._test) return self._omit
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'omit'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
The test startup duration to omit in seconds.
def stringify(data): if isinstance(data, dict): for key, value in data.items(): data[key] = stringify(value) elif isinstance(data, list): return [stringify(item) for item in data] else: return smart_text(data) return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stringify'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'};...
Turns all dictionary values into strings
def inject_into_urllib3(): util.ssl_.SSLContext = SecureTransportContext util.HAS_SNI = HAS_SNI util.ssl_.HAS_SNI = HAS_SNI util.IS_SECURETRANSPORT = True util.ssl_.IS_SECURETRANSPORT = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inject_into_urllib3'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '19', '...
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
def run(addr, *commands, **kwargs): results = [] handler = VarnishHandler(addr, **kwargs) for cmd in commands: if isinstance(cmd, tuple) and len(cmd)>1: results.extend([getattr(handler, c[0].replace('.','_'))(*c[1:]) for c in cmd]) else: results.append(getattr(handler...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'add...
Non-threaded batch command runner returning output results
def _makepass(password, hasher='sha256'): if hasher == 'sha256': h = hashlib.sha256(password) elif hasher == 'md5': h = hashlib.md5(password) else: return NotImplemented c = "abcdefghijklmnopqrstuvwxyz" \ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "0123456789!?.,:;/*-+_()" ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_makepass'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pa...
Create a znc compatible hashed password
def apply_trans_rot(ampal, translation, angle, axis, point, radians=False): if not numpy.isclose(angle, 0.0): ampal.rotate(angle=angle, axis=axis, point=point, radians=radians) ampal.translate(vector=translation) return
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply_trans_rot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', '...
Applies a translation and rotation to an AMPAL object.
def add_resources_to_registry(): from deform.widget import default_resource_registry default_resource_registry.set_js_resources("jqueryui", None, None) default_resource_registry.set_js_resources("datetimepicker", None, None) default_resource_registry.set_js_resources("custom_dates", None, None) defa...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_resources_to_registry'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '...
Add resources to the deform registry
def register(name=''): "For backwards compatibility, we support @register(name) syntax." def reg(widget): w = widget.class_traits() Widget.widget_types.register(w['_model_module'].default_value, w['_model_module_version'].default_value, ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'...
For backwards compatibility, we support @register(name) syntax.
def log_vacation_days(): days_off = get_days_off(rc.read()) pretty_days = map(lambda day: day.strftime('%a %b %d %Y'), days_off) for day in pretty_days: print(day)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_vacation_days'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '16', '32']}; {...
Sum and report taken days off.
def global_custom_theme(request): today = datetime.datetime.now().date() theme = {} if today.month == 3 and (14 <= today.day <= 16): theme = {"css": "themes/piday/piday.css"} return {"theme": theme}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'global_custom_theme'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Add custom theme javascript and css.
def update_visited(self): assert isinstance(self.player.cshape.center, eu.Vector2) pos = self.player.cshape.center def set_visited(layer, cell): if cell and not cell.properties.get('visited') and cell.tile and cell.tile.id > 0: cell.properties['visited'] = True ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_visited'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Updates exploration map visited status
def _get_atomsection(mol2_lst): started = False for idx, s in enumerate(mol2_lst): if s.startswith('@<TRIPOS>ATOM'): first_idx = idx + 1 started = True elif started and s.startswith('@<TRIPOS>'): last_idx_plus1 = idx ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_atomsection'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Returns atom section from mol2 provided as list of strings
def _raiseValidationException(standardExcMsg, customExcMsg=None): if customExcMsg is None: raise ValidationException(str(standardExcMsg)) else: raise ValidationException(str(customExcMsg))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_raiseValidationException'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ...
Raise ValidationException with standardExcMsg, unless customExcMsg is specified.
def undo_action_name(self): if self._open: return self._open[-1].name elif self._undo: return self._undo[-1].name return ""
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'undo_action_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
The name of the top group on the undo stack, or an empty string.
def find_by_name(self, item_name, items_list, name_list=None): if not name_list: names = [item.name for item in items_list if item] else: names = name_list if item_name in names: ind = names.index(item_name) return items_list[ind] return Fa...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_by_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': []...
Return item from items_list with name item_name.
def PrintStorageInformation(self): storage_reader = storage_factory.StorageFactory.CreateStorageReaderForFile( self._storage_file_path) if not storage_reader: logger.error( 'Format of storage file: {0:s} not supported'.format( self._storage_file_path)) return try:...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'PrintStorageInformation'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Prints the storage information.
def _project_on_ellipsoid(c, r, locations): p0 = locations - c l2 = 1 / np.sum(p0**2 / r**2, axis=1, keepdims=True) p = p0 * np.sqrt(l2) fun = lambda x: np.sum((x.reshape(p0.shape) - p0)**2) con = lambda x: np.sum(x.reshape(p0.shape)**2 / r**2, axis=1) - 1 res = sp.optimize.minimize(fun, p, cons...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_project_on_ellipsoid'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':...
displace locations to the nearest point on ellipsoid surface
def drawHUD(self): self.win.move(self.height - 2, self.x_pad) self.win.clrtoeol() self.win.box() self.addstr(2, self.x_pad + 1, "Population: %i" % len(self.grid)) self.addstr(3, self.x_pad + 1, "Generation: %s" % self.current_gen) self.addstr(3, self.x_grid - 21, "s: star...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'drawHUD'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {...
Draw information on population size and current generation
def enumerate(context, data): items = ensure_list(context.params.get('items')) for item in items: data['item'] = item context.emit(data=data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'enumerate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'co...
Iterate through a set of items and emit each one of them.
def make_header(self, locale, catalog): return { "po-revision-date": self.get_catalogue_header_value(catalog, 'PO-Revision-Date'), "mime-version": self.get_catalogue_header_value(catalog, 'MIME-Version'), "last-translator": 'Automatic <hi@thorgate.eu>', "x-generat...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_header'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Populate header with correct data from top-most locale file.
def register_hid_device(screen_width, screen_height, absolute=False, integrated_display=False): message = create(protobuf.REGISTER_HID_DEVICE_MESSAGE) descriptor = message.inner().deviceDescriptor descriptor.absolute = 1 if absolute else 0 descriptor.integratedDisplay = 1 if inte...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_hid_device'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'childr...
Create a new REGISTER_HID_DEVICE_MESSAGE.
def Docker(): docker_info = {'server': {}, 'env': '', 'type': '', 'os': ''} try: d_client = docker.from_env() docker_info['server'] = d_client.version() except Exception as e: logger.error("Can't get docker info " + str(e)) system = System() docker_info['os'] = system if ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Docker'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '21', '59', '65', '71', '1...
Get Docker setup information
def serialized(self, prepend_date=True): name = self.serialized_name() datetime = self.serialized_time(prepend_date) return "%s %s" % (datetime, name)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialized'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Return a string fully representing the fact.
def time(ctx, hours, minutes, seconds): return _time(conversions.to_integer(hours, ctx), conversions.to_integer(minutes, ctx), conversions.to_integer(seconds, ctx))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'time'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Defines a time value
def add_host(self, name: str, **kwargs) -> None: host = { name: deserializer.inventory.InventoryElement.deserialize_host( name=name, defaults=self.defaults, **kwargs ) } self.hosts.update(host)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_host'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Add a host to the inventory after initialization
def _raise_error_from_response(data): meta = data.get('meta') if meta: if meta.get('code') in (200, 409): return data exc = error_types.get(meta.get('errorType')) if exc: raise exc(meta.get('errorDetail')) else: _log_and_raise_exception('Unknown error. met...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_raise_error_from_response'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Processes the response data
def AddAccuracy(model, softmax, label): accuracy = brew.accuracy(model, [softmax, label], "accuracy") return accuracy
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AddAccuracy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Adds an accuracy op to the model
def _update_visible_blocks(self, *args): self._visible_blocks[:] = [] block = self.firstVisibleBlock() block_nbr = block.blockNumber() top = int(self.blockBoundingGeometry(block).translated( self.contentOffset()).top()) bottom = top + int(self.blockBoundingRect(block)...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_visible_blocks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
Updates the list of visible blocks
def launch_ipython(argv=None): from .linux import launch_ipython as _launch_ipython_linux os.environ = {str(k): str(v) for k,v in os.environ.items()} try: from qtconsole.qtconsoleapp import JupyterQtConsoleApp except ImportError: sys.exit("ERROR: IPython QtConsole not installed in this e...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'launch_ipython'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6'...
Force usage of QtConsole under Windows
def at_match(self, match, predicate=None, index=None): return self.at_span(match.span, predicate, index)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'at_match'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Retrieves a list of matches from given match.
def best_parent( self, node, tree_type=None ): parents = self.parents(node) selected_parent = None if node['type'] == 'type': module = ".".join( node['name'].split( '.' )[:-1] ) if module: for mod in parents: if mod['type'] == 'module' ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'best_parent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Choose the best parent for a given node
def grid_2d_8graph(self, m, n): me = nx.Graph() node = me.node add_node = me.add_node add_edge = me.add_edge for i in range(m): for j in range(n): add_node((i, j)) if i > 0: add_edge((i, j), (i-1, j)) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'grid_2d_8graph'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
Make a 2d graph that's connected 8 ways, enabling diagonal movement
def cancelThread(*threads, exception=EscapeException): 'Raise exception on another thread.' for t in threads: ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(t.ident), ctypes.py_object(exception))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cancelThread'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']...
Raise exception on another thread.
def result(self, res): return self >> Parser(lambda _, index: Value.success(index, res))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'result'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'...
Return a value according to the parameter `res` when parse successfully.
def capture_dash_in_url_name(self, node): for keyword in node.keywords: if keyword.arg == 'name' and '-' in keyword.value.s: return DJ04( lineno=node.lineno, col=node.col_offset, )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'capture_dash_in_url_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
Capture dash in URL name
def _run_collect_allelic_counts(pos_file, pos_name, work_dir, data): out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), "structural", "counts")) out_file = os.path.join(out_dir, "%s-%s-counts.tsv" % (dd.get_sample_name(data), pos_name)) if not utils.file_exists(out_file): with file_tra...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_run_collect_allelic_counts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', ...
Counts by alleles for a specific sample and set of positions.
def unique(series: pd.Series) -> pd.Series: return ~series.duplicated(keep=False)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unique'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']};...
Test that the data items do not repeat.
def unicode_name(self, name, in_group=False): value = ord(_unicodedata.lookup(name)) if (self.is_bytes and value > 0xFF): value = "" if not in_group and value == "": return '[^%s]' % ('\x00-\xff' if self.is_bytes else _uniprops.UNICODE_RANGE) elif value == "": ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unicode_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
Insert Unicode value by its name.
def begin_commit(): session_token = request.headers['session_token'] repository = request.headers['repository'] current_user = have_authenticated_user(request.environ['REMOTE_ADDR'], repository, session_token) if current_user is False: return fail(user_auth_fail_msg) repository_path = config['rep...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'begin_commit'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '21', '34', '4...
Allow a client to begin a commit and acquire the write lock
def _find_controller(self, *args): for name in args: obj = self._lookup_child(name) if obj and iscontroller(obj): return obj return None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_controller'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Returns the appropriate controller for routing a custom action.
def read(fname): path = os.path.join(SCRIPTDIR, fname) if PY3: f = open(path, 'r', encoding='utf8') else: f = open(path, 'r') content = f.read() f.close() return content
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'i...
Return content of specified file
def addPrefs(self, prefs=[]): if len(prefs) == len(self.preferences) == 0: logger.debug("no preferences") return None self.preferences.extend(prefs) self.css1(path['search-btn']).click() count = 0 for pref in self.preferences: self.css1(path['s...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addPrefs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
add preference in self.preferences
def move_position(self, dx, dy, speed=None): if speed: self._intf.write('MoveChuckPosition %1.1f %1.1f R Y %d' % (dx, dy, speed)) else: self._intf.write('MoveChuckPosition %1.1f %1.1f R Y' % (dx, dy))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'move_position'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
Move chuck relative to actual position in um
def reset_password(app, appbuilder, username, password): _appbuilder = import_application(app, appbuilder) user = _appbuilder.sm.find_user(username=username) if not user: click.echo("User {0} not found.".format(username)) else: _appbuilder.sm.reset_password(user.id, password) cli...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_password'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [...
Resets a user's password
def default_hass_config_dir(): data_dir = os.getenv("APPDATA") if os.name == "nt" else os.path.expanduser("~") return os.path.join(data_dir, ".homeassistant")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'default_hass_config_dir'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '28']}; {...
Put together the default configuration directory based on the OS.
def add_fortran_to_env(env): try: FortranSuffixes = env['FORTRANFILESUFFIXES'] except KeyError: FortranSuffixes = ['.f', '.for', '.ftn'] try: FortranPPSuffixes = env['FORTRANPPFILESUFFIXES'] except KeyError: FortranPPSuffixes = ['.fpp', '.FPP'] DialectAddToEnv(env, "F...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_fortran_to_env'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Add Builders and construction variables for Fortran to an Environment.
def signature(self): iexec, execmod = self.context.parser.tree_find(self.context.el_name, self.context.module, "executables") if iexec is None: iexec, execmod = self.context.parser.tree_find(self.context.el_name, self.context.module, ...
{'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'};...
Gets completion or call signature information for the current cursor.
def spew_length(self, length): pos = self.pos if not pos or length > pos: return None row = self.row for char in reversed(self.string[pos - length:pos]): pos -= 1 if char == '\n': row -= 1 self.pos = pos self.col = self....
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spew_length'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Move current position backwards by length.
def add_atmost(self, lits, k, no_return=True): if self.minicard: res = pysolvers.minicard_add_am(self.minicard, lits, k) if res == False: self.status = False if not no_return: return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_atmost'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ...
Add a new atmost constraint to solver's internal formula.
def git_lines(*args, git=maybeloggit, **kwargs): 'Generator of stdout lines from given git command' err = io.StringIO() try: for line in git('--no-pager', _err=err, *args, _decode_errors='replace', _iter=True, _bg_exc=False, **kwargs): yield line[:-1] except sh.ErrorReturnCode as e: ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'git_lines'}; {'id': '3', 'type': 'parameters', 'children': ['4', '6', '9']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['...
Generator of stdout lines from given git command
def make_automaton(self): queue = deque() for i in range(256): c = chr(i) if c in self.root.children: node = self.root.children[c] node.fail = self.root queue.append(node) else: self.root.children[c] = self.root while queue: r = queue.popleft() for node in r.children.values(): q...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_automaton'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Converts trie to Aho-Corasick automaton.
def error_string(mqtt_errno): if mqtt_errno == MQTT_ERR_SUCCESS: return "No error." elif mqtt_errno == MQTT_ERR_NOMEM: return "Out of memory." elif mqtt_errno == MQTT_ERR_PROTOCOL: return "A network protocol error occurred when communicating with the broker." elif mqtt_errno == M...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'error_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mqtt...
Return the error string associated with an mqtt error number.
def _determine_current_dimension_size(self, dim_name, max_size): if self.dimensions[dim_name] is not None: return max_size def _find_dim(h5group, dim): if dim not in h5group: return _find_dim(h5group.parent, dim) return h5group[dim] dim_variabl...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_determine_current_dimension_size'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier',...
Helper method to determine the current size of a dimension.
def update_pointed(self): if not self.pointed_at_expired: try: conf_string, stat2 = self.zoo_client.get(self.point_path, watch=self.watch_pointed) except ZookeeperError: self.old_data = '' ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_pointed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
Grabs the latest file contents based on the pointer uri
def create_connection_model(service): services = service._services bases = (BaseModel,) attributes = {model_service_name(service): fields.CharField() for service in services} return type(BaseModel)(connection_service_name(service), bases, attributes)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_connection_model'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
Create an SQL Alchemy table that connects the provides services
def _await_socket(self, timeout): with safe_open(self._ng_stdout, 'r') as ng_stdout: start_time = time.time() accumulated_stdout = '' while 1: remaining_time = time.time() - (start_time + timeout) if remaining_time > 0: stderr = read_file(self._ng_stderr, binary_mode=True...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_await_socket'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Blocks for the nailgun subprocess to bind and emit a listening port in the nailgun stdout.
def refresh_toc(self, refresh_done_callback, toc_cache): self._useV2 = self.cf.platform.get_protocol_version() >= 4 self._toc_cache = toc_cache self._refresh_callback = refresh_done_callback self.toc = None pk = CRTPPacket() pk.set_header(CRTPPort.LOGGING, CHAN_SETTINGS) ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refresh_toc'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
Start refreshing the table of loggale variables
def update(): repo_directory = get_config()['repo_directory'] os.chdir(repo_directory) click.echo("Check for updates...") local = subprocess.check_output('git rev-parse master'.split()).strip() remote = subprocess.check_output( 'git ls-remote https://github.com/tldr-pages/tldr/ HEAD'.split()...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '13', '20', '27', '44', '6...
Update to the latest pages.
def apply(self, coordinates): transform = self.get_transformation(coordinates) result = MolecularDistortion(self.affected_atoms, transform) result.apply(coordinates) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'apply'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Generate, apply and return a random manipulation
def copy(self): ms = MouseState() ms.left_pressed = self.left_pressed ms.middle_pressed = self.middle_pressed ms.right_pressed = self.right_pressed ms.mouse_pos = self.mouse_pos return ms
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id...
Create a copy of this MouseState and return it.
def ics2task(): from argparse import ArgumentParser, FileType from sys import stdin parser = ArgumentParser(description='Converter from iCalendar to Taskwarrior syntax.') parser.add_argument('infile', nargs='?', type=FileType('r'), default=stdin, help='Input iCalendar file (defau...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ics2task'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '12', '17', '26', '48', ...
Command line tool to convert from iCalendar to Taskwarrior
def _notify_remove(self, slice_): change = RemoveChange(self, slice_) self.notify_observers(change)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_notify_remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
Notify about a RemoveChange.
def to_fp32(learn:Learner): "Put `learn` back to FP32 precision mode." learn.data.remove_tfm(batch_to_half) for cb in learn.callbacks: if isinstance(cb, MixedPrecision): learn.callbacks.remove(cb) learn.model = learn.model.float() return learn
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_fp32'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id'...
Put `learn` back to FP32 precision mode.
def init(config_file): schema = generate_schema_file(open(config_file, 'r').read()) sys.stdout.write(schema)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config_file'...
Initialize a confirm schema from an existing configuration file.
def partial_row_coordinates(self, X): utils.validation.check_is_fitted(self, 's_') if self.check_input: utils.check_array(X, dtype=[str, np.number]) X = self._prepare_input(X) P = len(X) ** 0.5 * self.U_ / self.s_ coords = {} for name, cols in sorted(self.grou...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'partial_row_coordinates'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []...
Returns the row coordinates for each group.
def can_delete_post(self, post, user): checker = self._get_checker(user) is_author = self._is_post_author(post, user) can_delete = ( user.is_superuser or (is_author and checker.has_perm('can_delete_own_posts', post.topic.forum)) or checker.has_perm('can_delete...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'can_delete_post'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
Given a forum post, checks whether the user can delete the latter.
def link_label(link): if hasattr(link, 'label'): label = link.label else: label = str(link.linknum+1) return label
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'link_label'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'link'}...
return a link label as a string
def level(self, lvl=None): if not lvl: return self._lvl self._lvl = self._parse_level(lvl) self.stream.setLevel(self._lvl) logging.root.setLevel(self._lvl)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'level'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
Get or set the logging level.
def copy_list(src_list, dst_list, lbl='Copying', ioerr_ok=False, sherro_ok=False, oserror_ok=False): task_iter = zip(src_list, dst_list) def docopy(src, dst): try: shutil.copy2(src, dst) except OSError: if ioerr_ok: return False r...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copy_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'chil...
Copies all data and stat info
def find_function(self, name): deffunction = lib.EnvFindDeffunction(self._env, name.encode()) if deffunction == ffi.NULL: raise LookupError("Function '%s' not found" % name) return Function(self._env, deffunction)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_function'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
Find the Function by its name.
def coerce(value): if isinstance(value, ListCell): return value elif isinstance(value, (list)): return ListCell(value) else: return ListCell([value])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'coerce'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {...
Turns a value into a list
def sysidpath(ignore_options=False): failover = Path('/tmp/machine-id') if not ignore_options: options = ( Path('/etc/machine-id'), failover, ) for option in options: if (option.exists() and os.access(option, os.R_OK) and ...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sysidpath'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {...
get a unique identifier for the machine running this function
def load(self,dset): self.dset_filename = dset self.dset = nib.load(dset) self.data = self.dset.get_data() self.header = self.dset.get_header()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};...
load a dataset from given filename into the object
def _check_emotion_set_is_supported(self): supported_emotion_subsets = [ set(['anger', 'fear', 'surprise', 'calm']), set(['happiness', 'disgust', 'surprise']), set(['anger', 'fear', 'surprise']), set(['anger', 'fear', 'calm']), set(['anger', 'happiness...
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_emotion_set_is_supported'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':...
Validates set of user-supplied target emotions.
def show_order(self, order_id): request = self._get('transactions/orders/' + str(order_id)) return self.responder(request)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_order'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
Shows an existing order transaction.
def accuracy_thresh(y_pred:Tensor, y_true:Tensor, thresh:float=0.5, sigmoid:bool=True)->Rank0Tensor: "Compute accuracy when `y_pred` and `y_true` are the same size." if sigmoid: y_pred = y_pred.sigmoid() return ((y_pred>thresh)==y_true.byte()).float().mean()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'accuracy_thresh'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '12', '17']}; {'id': '4', 'type': 'typed_parameter'...
Compute accuracy when `y_pred` and `y_true` are the same size.
def _decodeTimestamp(byteIter): dateStr = decodeSemiOctets(byteIter, 7) timeZoneStr = dateStr[-2:] return datetime.strptime(dateStr[:-2], '%y%m%d%H%M%S').replace(tzinfo=SmsPduTzInfo(timeZoneStr))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_decodeTimestamp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
Decodes a 7-octet timestamp