code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def convert_machine_list_time_val(text: str) -> datetime.datetime: text = text[:14] if len(text) != 14: raise ValueError('Time value not 14 chars') year = int(text[0:4]) month = int(text[4:6]) day = int(text[6:8]) hour = int(text[8:10]) minute = int(text[10:12]) second = int(text[12:14]) return datetime.datetime(year, month, day, hour, minute, second, tzinfo=datetime.timezone.utc)
module function_definition identifier parameters typed_parameter identifier type identifier type attribute identifier identifier block expression_statement assignment identifier subscript identifier slice integer if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier
Convert RFC 3659 time-val to datetime objects.
def gpu_mem_restore(func): "Reclaim GPU RAM if CUDA out of memory happened, or execution was interrupted" @functools.wraps(func) def wrapper(*args, **kwargs): tb_clear_frames = os.environ.get('FASTAI_TB_CLEAR_FRAMES', None) if not IS_IN_IPYTHON or tb_clear_frames=="0": return func(*args, **kwargs) try: return func(*args, **kwargs) except Exception as e: if ("CUDA out of memory" in str(e) or "device-side assert triggered" in str(e) or tb_clear_frames == "1"): type, val, tb = get_ref_free_exc_info() gc.collect() if "device-side assert triggered" in str(e): warn() raise type(val).with_traceback(tb) from None else: raise return wrapper
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end none if_statement boolean_operator not_operator identifier comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator string string_start string_content string_end call identifier argument_list identifier comparison_operator string string_start string_content string_end call identifier argument_list identifier comparison_operator identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier block expression_statement call identifier argument_list raise_statement call attribute call identifier argument_list identifier identifier argument_list identifier none else_clause block raise_statement return_statement identifier
Reclaim GPU RAM if CUDA out of memory happened, or execution was interrupted
def since(self, ts): while True: items = super(TailingOplog, self).since(ts) for doc in items: yield doc ts = doc['ts']
module function_definition identifier parameters identifier identifier block while_statement true block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement yield identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end
Tail the oplog, starting from ts.
def isinstance(self, instance, class_name): if isinstance(instance, BaseNode): klass = self.dynamic_node_classes.get(class_name, None) if klass: return isinstance(instance, klass) return False else: raise TypeError("This function can only be used for BaseNode objects")
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier none if_statement identifier block return_statement call identifier argument_list identifier identifier return_statement false else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Check if a BaseNode is an instance of a registered dynamic class
def _print_title(self): if self.title: self._stream_out('{}\n'.format(self.title)) self._stream_flush()
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Prints tracking title at initialization.
def count_rows_with_nans(X): if X.ndim == 2: return np.where(np.isnan(X).sum(axis=1) != 0, 1, 0).sum()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block return_statement call attribute call attribute identifier identifier argument_list comparison_operator call attribute call attribute identifier identifier argument_list identifier identifier argument_list keyword_argument identifier integer integer integer integer identifier argument_list
Count the number of rows in 2D arrays that contain any nan values.
def todo_tasks(self): tasks = [task for task in self.all_tasks if task._state == NewTask._PENDING] return tasks
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier attribute identifier identifier return_statement identifier
Return tasks in loop which its state is pending.
def checkForDeadlocks(self): totalRunningJobs = len(self.batchSystem.getRunningBatchJobIDs()) totalServicesIssued = self.serviceJobsIssued + self.preemptableServiceJobsIssued if totalServicesIssued >= totalRunningJobs and totalRunningJobs > 0: serviceJobs = [x for x in list(self.jobBatchSystemIDToIssuedJob.keys()) if isinstance(self.jobBatchSystemIDToIssuedJob[x], ServiceJobNode)] runningServiceJobs = set([x for x in serviceJobs if self.serviceManager.isRunning(self.jobBatchSystemIDToIssuedJob[x])]) assert len(runningServiceJobs) <= totalRunningJobs if len(runningServiceJobs) == totalRunningJobs: if self.potentialDeadlockedJobs != runningServiceJobs: self.potentialDeadlockedJobs = runningServiceJobs self.potentialDeadlockTime = time.time() elif time.time() - self.potentialDeadlockTime >= self.config.deadlockWait: raise DeadlockException("The system is service deadlocked - all %d running jobs are active services" % totalRunningJobs) else: self.potentialDeadlockedJobs = set() self.potentialDeadlockTime = 0 else: self.potentialDeadlockedJobs = set() self.potentialDeadlockTime = 0
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier integer block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list if_clause call identifier argument_list subscript attribute identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension identifier for_in_clause identifier identifier if_clause call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier identifier assert_statement comparison_operator call identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list elif_clause comparison_operator binary_operator call attribute identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier integer
Checks if the system is deadlocked running service jobs.
def list_securitygroup(call=None): if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --function.' ) params = { 'Action': 'DescribeSecurityGroups', 'RegionId': get_location(), 'PageSize': '50', } result = query(params) if 'Code' in result: return {} ret = {} for sg in result['SecurityGroups']['SecurityGroup']: ret[sg['SecurityGroupId']] = {} for item in sg: ret[sg['SecurityGroupId']][item] = sg[item] return ret
module function_definition identifier parameters default_parameter identifier none block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement dictionary expression_statement assignment identifier dictionary for_statement identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end dictionary for_statement identifier identifier block expression_statement assignment subscript subscript identifier subscript identifier string string_start string_content string_end identifier subscript identifier identifier return_statement identifier
Return a list of security group
def make_slice_strings(cls, slice_key): start = slice_key.start size = slice_key.stop - start return (str(start), str(size))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier return_statement tuple call identifier argument_list identifier call identifier argument_list identifier
Converts the given slice key to start and size query parts.
def update(self, x, w=1): self.n += w if len(self) == 0: self._add_centroid(Centroid(x, w)) return S = self._find_closest_centroids(x) while len(S) != 0 and w > 0: j = choice(list(range(len(S)))) c_j = S[j] q = self._compute_centroid_quantile(c_j) if c_j.count + w > self._threshold(q): S.pop(j) continue delta_w = min(self._threshold(q) - c_j.count, w) self._update_centroid(c_j, x, delta_w) w -= delta_w S.pop(j) if w > 0: self._add_centroid(Centroid(x, w)) if len(self) > self.K / self.delta: self.compress() return
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement augmented_assignment attribute identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier while_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list call identifier argument_list call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator binary_operator attribute identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier continue_statement expression_statement assignment identifier call identifier argument_list binary_operator call attribute identifier identifier argument_list identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement augmented_assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier if_statement comparison_operator call identifier argument_list identifier binary_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement
Update the t-digest with value x and weight w.
def check_pypi_exists(dependencies): for dependency in dependencies.get('pypi', []): logger.debug("Checking if %r exists in PyPI", dependency) try: exists = _pypi_head_package(dependency) except Exception as error: logger.error("Error checking %s in PyPI: %r", dependency, error) raise FadesError("Could not check if dependency exists in PyPI") else: if not exists: logger.error("%s doesn't exists in PyPI.", dependency) return False return True
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier raise_statement call identifier argument_list string string_start string_content string_end else_clause block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement false return_statement true
Check if the indicated dependencies actually exists in pypi.
def send_action(action, params=None): data={"msg_type":"action", "action":action} if params is not None: data['params']=params _comm.send(data)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
helper method for sending actions
def isoncurve(self, p): return p.iszero() or p.y ** 2 == p.x ** 3 + self.a * p.x + self.b
module function_definition identifier parameters identifier identifier block return_statement boolean_operator call attribute identifier identifier argument_list comparison_operator binary_operator attribute identifier identifier integer binary_operator binary_operator binary_operator attribute identifier identifier integer binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier
verifies if a point is on the curve
def _iris_cell_methods_to_str(cell_methods_obj): cell_methods = [] for cell_method in cell_methods_obj: names = ''.join(['{}: '.format(n) for n in cell_method.coord_names]) intervals = ' '.join(['interval: {}'.format(interval) for interval in cell_method.intervals]) comments = ' '.join(['comment: {}'.format(comment) for comment in cell_method.comments]) extra = ' '.join([intervals, comments]).strip() if extra: extra = ' ({})'.format(extra) cell_methods.append(names + cell_method.method + extra) return ' '.join(cell_methods)
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute string string_start string_content string_end identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute string string_start string_content string_end identifier argument_list list identifier identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator binary_operator identifier attribute identifier identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Converts a Iris cell methods into a string
def check_garden_requirements(self): garden_requirements = self.config.getlist('app', 'garden_requirements', '') if exists(self.gardenlibs_dir) and \ self.state.get('cache.gardenlibs', '') == garden_requirements: self.debug('Garden requirements already installed, pass') return self.rmdir(self.gardenlibs_dir) if not garden_requirements: self.state['cache.gardenlibs'] = garden_requirements return self._ensure_virtualenv() self.cmd('pip install Kivy-Garden==0.1.1', env=self.env_venv) self.mkdir(self.gardenlibs_dir) for requirement in garden_requirements: self._install_garden_package(requirement) self.state['cache.gardenlibs'] = garden_requirements
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_end if_statement boolean_operator call identifier argument_list attribute identifier identifier line_continuation comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier return_statement expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier
Ensure required garden packages are available to be included.
def loadTextureD3D11_Async(self, textureId, pD3D11Device): fn = self.function_table.loadTextureD3D11_Async ppD3D11Texture2D = c_void_p() result = fn(textureId, pD3D11Device, byref(ppD3D11Texture2D)) return result, ppD3D11Texture2D.value
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier call identifier argument_list identifier return_statement expression_list identifier attribute identifier identifier
Creates a D3D11 texture and loads data into it.
def create_api_environment_vip(self): return ApiEnvironmentVip( self.networkapi_url, self.user, self.password, self.user_ldap)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Get an instance of Api Environment Vip services facade.
def unset_default_org(self): for org in self.list_orgs(): org_config = self.get_org(org) if org_config.default: del org_config.config["default"] self.set_org(org_config)
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block delete_statement subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
unset the default orgs for tasks
def recover_all_handler(self): for handler in self._handler_cache: self.logger.addHandler(handler) self._handler_cache = list()
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call identifier argument_list
Relink the file handler association you just removed.
def convert_references_json(ref_content, soup=None): "Check for references that will not pass schema validation, fix or convert them to unknown" if ( (ref_content.get("type") == "other") or (ref_content.get("type") == "book-chapter" and "editors" not in ref_content) or (ref_content.get("type") == "journal" and "articleTitle" not in ref_content) or (ref_content.get("type") in ["journal", "book-chapter"] and not "pages" in ref_content) or (ref_content.get("type") == "journal" and "journal" not in ref_content) or (ref_content.get("type") in ["book", "book-chapter", "report", "thesis", "software"] and "publisher" not in ref_content) or (ref_content.get("type") == "book" and "bookTitle" not in ref_content) or (ref_content.get("type") == "data" and "source" not in ref_content) or (ref_content.get("type") == "conference-proceeding" and "conference" not in ref_content) ): ref_content = references_json_to_unknown(ref_content, soup) return ref_content
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement string string_start string_content string_end if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator boolean_operator parenthesized_expression comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end not_operator comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Check for references that will not pass schema validation, fix or convert them to unknown
def getTileUrlsByLatLngExtent(self, xmin, ymin, xmax, ymax, level): tileXMin, tileYMin = self.tileUtils.convertLngLatToTileXY(xmin, ymax, level) tileXMax, tileYMax = self.tileUtils.convertLngLatToTileXY(xmax, ymin, level) tileUrls = [] for y in range(tileYMax, tileYMin - 1, -1): for x in range(tileXMin, tileXMax + 1, 1): tileUrls.append(self.createTileUrl(x, y, level)) return tileUrls
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier binary_operator identifier integer unary_operator integer block for_statement identifier call identifier argument_list identifier binary_operator identifier integer integer block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
Returns a list of tile urls by extent
def initRnaQuantificationSet(self): store = rnaseq2ga.RnaSqliteStore(self._args.filePath) store.createTables()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Initialize an empty RNA quantification set
def dim_lower_extent_dict(self): return { d.name: d.lower_extent for d in self._dims.itervalues()}
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair attribute identifier identifier attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list
Returns a mapping of dimension name to lower_extent
def removeSettingsGroup(groupName, settings=None): logger.debug("Removing settings group: {}".format(groupName)) settings = QtCore.QSettings() if settings is None else settings settings.remove(groupName)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list comparison_operator identifier none identifier expression_statement call attribute identifier identifier argument_list identifier
Removes a group from the persistent settings
def _update_vdr_vxrheadtail(self, f, vdr_offset, VXRoffset): self._update_offset_value(f, vdr_offset+28, 8, VXRoffset) self._update_offset_value(f, vdr_offset+36, 8, VXRoffset)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier integer integer identifier expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier integer integer identifier
This sets a VXR to be the first and last VXR in the VDR
def restore(self): signal.signal(signal.SIGINT, self.original_sigint) signal.signal(signal.SIGTERM, self.original_sigterm) if os.name == 'nt': signal.signal(signal.SIGBREAK, self.original_sigbreak)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Restore signal handlers to their original settings.
def rollback(self): self._check_state() database = self._session._database api = database.spanner_api metadata = _metadata_with_prefix(database.name) api.rollback(self._session.name, self._transaction_id, metadata=metadata) self._rolled_back = True del self._session._transaction
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier true delete_statement attribute attribute identifier identifier identifier
Roll back a transaction on the database.
def _toggle_filming(self): if self._filming: self.log("Stopping operation") self._filming = False self.timer.stop() else: self.log("Starting operation") self._filming = True self.timer.start()
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list
Toggles the camera system recording state
def dxdy(line): x0, y0, x1, y1 = line dx = float(x1 - x0) dy = float(y1 - y0) f = hypot(dx, dy) return dx / f, dy / f
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement expression_list binary_operator identifier identifier binary_operator identifier identifier
return normalised ascent vector
def add_mavlink_packet(self, msg): mtype = msg.get_type() if mtype not in self.msg_types: return for i in range(len(self.fields)): if mtype not in self.field_types[i]: continue f = self.fields[i] self.values[i] = mavutil.evaluate_expression(f, self.state.master.messages) if self.livegraph is not None: self.livegraph.add_values(self.values)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block return_statement for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier subscript attribute identifier identifier identifier block continue_statement expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier attribute attribute attribute identifier identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
add data to the graph
def rounddown(ctx, number, num_digits): number = conversions.to_decimal(number, ctx) num_digits = conversions.to_integer(num_digits, ctx) return decimal_round(number, num_digits, ROUND_DOWN)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier identifier
Rounds a number down, toward zero
def root(self, value): self._xml = t2s(value) self._root = value
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Set new XML tree
def Subtract(self, other): for val, freq in other.Items(): self.Incr(val, -freq)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier unary_operator identifier
Subtracts the values in the given histogram from this histogram.
def _get_tag(repo, name): try: return [x for x in _all_tags(repo) if x[0] == name][0] except IndexError: return False
module function_definition identifier parameters identifier identifier block try_statement block return_statement subscript list_comprehension identifier for_in_clause identifier call identifier argument_list identifier if_clause comparison_operator subscript identifier integer identifier integer except_clause identifier block return_statement false
Find the requested tag in the specified repo
def can_view(self, user): return user.is_admin or self == user \ or set(self.classes).intersection(user.admin_for)
module function_definition identifier parameters identifier identifier block return_statement boolean_operator boolean_operator attribute identifier identifier comparison_operator identifier identifier line_continuation call attribute call identifier argument_list attribute identifier identifier identifier argument_list attribute identifier identifier
Return whether or not `user` can view information about the user.
def _extract_etag(response): if response and response.headers: for name, value in response.headers: if name.lower() == 'etag': return value return None
module function_definition identifier parameters identifier block if_statement boolean_operator identifier attribute identifier identifier block for_statement pattern_list identifier identifier attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement identifier return_statement none
Extracts the etag from the response headers.
def ascii_text(text): text = latinize_text(text, ascii=True) if isinstance(text, six.text_type): text = text.encode('ascii', 'ignore').decode('ascii') return text
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement identifier
Transliterate the given text and make sure it ends up as ASCII.
def find_spec(self, fullname, path, target=None): if fullname.startswith(self.package_prefix): for path in self._get_paths(fullname): if os.path.exists(path): return ModuleSpec( name=fullname, loader=self.loader_class(fullname, path), origin=path, is_package=(path.endswith('__init__.ipynb') or path.endswith('__init__.py')), )
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement call attribute identifier identifier argument_list attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier parenthesized_expression boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end
Claims modules that are under ipynb.fs
def _handle_info(self, *args, **kwargs): if 'version' in kwargs: self.api_version = kwargs['version'] print("Initialized API with version %s" % self.api_version) return try: info_code = str(kwargs['code']) except KeyError: raise FaultyPayloadError("_handle_info: %s" % kwargs) if not info_code.startswith('2'): raise ValueError("Info Code must start with 2! %s", kwargs) output_msg = "_handle_info(): %s" % kwargs log.info(output_msg) try: self._code_handlers[info_code]() except KeyError: raise UnknownWSSInfo(output_msg)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier return_statement try_statement block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement call subscript attribute identifier identifier identifier argument_list except_clause identifier block raise_statement call identifier argument_list identifier
Handles info messages and executed corresponding code
def visit_nonlocal(self, node, parent): return nodes.Nonlocal( node.names, getattr(node, "lineno", None), getattr(node, "col_offset", None), parent, )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier
visit a Nonlocal node and return a new instance of it
def _connect_signal(self, index): post_save_signal = ElasticSignal(index, 'build') post_save_signal.connect(post_save, sender=index.object_type) self.signals.append(post_save_signal) post_delete_signal = ElasticSignal(index, 'remove_object') post_delete_signal.connect(post_delete, sender=index.object_type) self.signals.append(post_delete_signal) for dependency in index.get_dependencies(): if isinstance(dependency, (models.ManyToManyField, ManyToManyDescriptor)): dependency = ManyToManyDependency(dependency) elif not isinstance(dependency, Dependency): raise TypeError("Unsupported dependency type: {}".format(repr(dependency))) signal = dependency.connect(index) self.signals.extend(signal)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier tuple attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Create signals for building indexes.
def memory_enumerator(buffer_, *args, **kwargs): _LOGGER.debug("Enumerating through (%d) bytes of archive data.", len(buffer_)) def opener(archive_res): _LOGGER.debug("Opening from (%d) bytes (memory_enumerator).", len(buffer_)) _archive_read_open_memory(archive_res, buffer_) if 'entry_cls' not in kwargs: kwargs['entry_cls'] = _ArchiveEntryItReadable return _enumerator(opener, *args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier
Return an enumerator that knows how to read raw memory.
def use_plenary_sequence_rule_enabler_view(self): self._object_views['sequence_rule_enabler'] = PLENARY for session in self._get_provider_sessions(): try: session.use_plenary_sequence_rule_enabler_view() except AttributeError: pass
module function_definition identifier parameters identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
Pass through to provider SequenceRuleEnablerLookupSession.use_plenary_sequence_rule_enabler_view
def SplitV(a, splits, axis): return tuple(np.split(np.copy(a), np.cumsum(splits), axis=axis))
module function_definition identifier parameters identifier identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Split op with multiple split sizes.
def fields_with_locales(self): result = {} for locale, fields in self._fields.items(): for k, v in fields.items(): real_field_id = self._real_field_id_for(k) if real_field_id not in result: result[real_field_id] = {} result[real_field_id][locale] = self._serialize_value(v) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier dictionary expression_statement assignment subscript subscript identifier identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier
Get fields with locales per field.
def log(self, msg, level="info"): if not self.config.get("log_file"): level = LOG_LEVELS.get(level, level) syslog(level, u"{}".format(msg)) else: with open(self.config["log_file"], "ab") as f: log_time = time.strftime("%Y-%m-%d %H:%M:%S") if isinstance(msg, (dict, list, set, tuple)): msg = pformat(msg) if "\n" in msg: msg = u"\n" + msg out = u"{} {} {}\n".format(log_time, level.upper(), msg) try: f.write(out.encode("utf-8")) except (AttributeError, UnicodeDecodeError): f.write(out)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier else_clause block with_statement with_clause with_item as_pattern call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier tuple identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator string string_start string_content escape_sequence string_end identifier block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
log this information to syslog or user provided logfile.
def monthly(date=datetime.date.today()): return datetime.date(date.year, date.month, 1)
module function_definition identifier parameters default_parameter identifier call attribute attribute identifier identifier identifier argument_list block return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer
Take a date object and return the first day of the month.
def _clean(self, t, capitalize=None): if self._from_bibtex: t = latex_to_unicode(t, capitalize=capitalize) t = ' '.join([el.rstrip('.') if el.count('.') == 1 else el for el in t.split()]) return t
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list_comprehension conditional_expression call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end integer identifier for_in_clause identifier call attribute identifier identifier argument_list return_statement identifier
Convert to normalized unicode and strip trailing full stops.
def connect(self, name, callback): if not self._callbacks[name]: self._callbacks[name] = callback else: raise HookAlreadyConnectedError('Callback hook already connected.')
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator subscript attribute identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Add callback to hook.
def remove_cts_record(file_name, map, position): db = XonoticDB.load_path(file_name) db.remove_cts_record(map, position) db.save(file_name)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Remove cts record on MAP and POSITION
def walk_subclasses(root): classes = [root] visited = set() while classes: cls = classes.pop() if cls is type or cls in visited: continue classes.extend(cls.__subclasses__()) visited.add(cls) if cls is not root: yield cls
module function_definition identifier parameters identifier block expression_statement assignment identifier list identifier expression_statement assignment identifier call identifier argument_list while_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement yield identifier
Does not yield the input class
def alphafilter(request, queryset, template): qs_filter = {} for key in list(request.GET.keys()): if '__istartswith' in key: qs_filter[str(key)] = request.GET[key] break return render_to_response( template, {'objects': queryset.filter(**qs_filter), 'unfiltered_objects': queryset}, context_instance=RequestContext(request) )
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier call identifier argument_list identifier subscript attribute identifier identifier identifier break_statement return_statement call identifier argument_list identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list dictionary_splat identifier pair string string_start string_content string_end identifier keyword_argument identifier call identifier argument_list identifier
Render the template with the filtered queryset
def _auth(): if 'auth' not in __context__: try: __context__['auth'] = salt.crypt.SAuth(__opts__) except SaltClientError: log.error('Could not authenticate with master.' 'Mine data will not be transmitted.') return __context__['auth']
module function_definition identifier parameters block if_statement comparison_operator string string_start string_content string_end identifier block try_statement block expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement subscript identifier string string_start string_content string_end
Return the auth object
def _define_format(self, occur): if hasattr(self, "default"): self.attr["nma:default"] = self.default middle = self._chorder() if self.rng_children() else "<empty/>%s" return (self.start_tag() + self.serialize_annots().replace("%", "%%") + middle + self.end_tag())
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement parenthesized_expression binary_operator binary_operator binary_operator call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier call attribute identifier identifier argument_list
Return the serialization format for a define node.
def pop_viewport(self): vp = self._vp_stack.pop() if len(self._vp_stack) > 0: self.context.set_viewport(*self._vp_stack[-1]) else: self.context.set_viewport(0, 0, *self.physical_size) self._update_transforms() return vp
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list list_splat subscript attribute identifier identifier unary_operator integer else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list integer integer list_splat attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Pop a viewport from the stack.
def add_stale_devices_callback(self, callback): self._stale_devices_callbacks.append(callback) _LOGGER.debug('Added stale devices callback to %s', callback)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Register as callback for when stale devices exist.
def _random_candidates(self, n=1000): candidates = np.zeros((n, len(self.tunables))) for i, tunable in enumerate(self.tunables): param = tunable[1] lo, hi = param.range if param.is_integer: column = np.random.randint(lo, hi + 1, size=n) else: diff = hi - lo column = lo + diff * np.random.rand(n) candidates[:, i] = column return candidates
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier call identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment pattern_list identifier identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator identifier integer keyword_argument identifier identifier else_clause block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment subscript identifier slice identifier identifier return_statement identifier
Generate a matrix of random parameters, column by column.
def add_feature(self, pr_name, pr_value): setattr(self, pr_name, pr_value) self.features.add(pr_name)
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add or update a node's feature.
def psf_convolution(self, grid, grid_scale, psf_subgrid=False, subgrid_res=1): psf_type = self.psf_type if psf_type == 'NONE': return grid elif psf_type == 'GAUSSIAN': sigma = self._sigma_gaussian/grid_scale img_conv = ndimage.filters.gaussian_filter(grid, sigma, mode='nearest', truncate=self._truncation) return img_conv elif psf_type == 'PIXEL': if psf_subgrid: kernel = self.subgrid_pixel_kernel(subgrid_res) else: kernel = self._kernel_pixel img_conv1 = signal.fftconvolve(grid, kernel, mode='same') return img_conv1 else: raise ValueError('PSF type %s not valid!' % psf_type)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false default_parameter identifier integer block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier return_statement identifier elif_clause comparison_operator identifier string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end return_statement identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
convolves a given pixel grid with a PSF
def trace2array(self, sl): chain = [] for stochastic in self.stochastics: tr = stochastic.trace.gettrace(slicing=sl) if tr is None: raise AttributeError chain.append(tr) return np.hstack(chain)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier none block raise_statement identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Return an array with the trace of all stochastics, sliced by sl.
def cache_param(self, value): if value not in self.cf_parameters: keyname = chr(ord('A') + len(self.cf_parameters)) param = self.cf_template.add_parameter(troposphere.Parameter( keyname, Type="String", Default=value, tags=self.tags )) self.cf_parameters[value] = param return troposphere.Ref(self.cf_parameters[value])
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier
Returns a troposphere Ref to a value cached as a parameter.
def _read_files(files): file_contents = [ ( _parse_title(file_path), _read_file(file_path), ) for file_path in files ] return file_contents
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension tuple call identifier argument_list identifier call identifier argument_list identifier for_in_clause identifier identifier return_statement identifier
Read the contents of a list of files
def _parse_text(self, el, refs=None, specials=None, element_cls=Paragraph): if specials is None: specials = {} if refs is None: refs = {} elements = self._parse_element_r(el, specials=specials, refs=refs, element_cls=element_cls) if not elements: return [element_cls('')] element = elements[0] for next_element in elements[1:]: element += element_cls(' ') + next_element return [element]
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement not_operator identifier block return_statement list call identifier argument_list string string_start string_end expression_statement assignment identifier subscript identifier integer for_statement identifier subscript identifier slice integer block expression_statement augmented_assignment identifier binary_operator call identifier argument_list string string_start string_content string_end identifier return_statement list identifier
Like _parse_element but ensure a single element.
def remove_file(paths): for path in force_list(paths): if os.path.exists(path): os.remove(path)
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Remove file from paths introduced.
def verify_retry_data(self, retry_data): retry_defaults = { 'until': True, 'attempts': 2, 'splay': 0, 'interval': 30, } expected_data = { 'until': bool, 'attempts': int, 'interval': int, 'splay': int, } validated_retry_data = {} if isinstance(retry_data, dict): for expected_key, value_type in six.iteritems(expected_data): if expected_key in retry_data: if isinstance(retry_data[expected_key], value_type): validated_retry_data[expected_key] = retry_data[expected_key] else: log.warning( 'An invalid value was passed for the retry %s, ' 'using default value \'%s\'', expected_key, retry_defaults[expected_key] ) validated_retry_data[expected_key] = retry_defaults[expected_key] else: validated_retry_data[expected_key] = retry_defaults[expected_key] else: log.warning(('State is set to retry, but a valid dict for retry ' 'configuration was not found. Using retry defaults')) validated_retry_data = retry_defaults return validated_retry_data
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end true pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end integer expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier dictionary if_statement call identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier identifier block if_statement call identifier argument_list subscript identifier identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end identifier subscript identifier identifier expression_statement assignment subscript identifier identifier subscript identifier identifier else_clause block expression_statement assignment subscript identifier identifier subscript identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier identifier return_statement identifier
verifies the specified retry data
def detach(self): from . import _ndarray_cls hdl = NDArrayHandle() check_call(_LIB.MXNDArrayDetach(self.handle, ctypes.byref(hdl))) return _ndarray_cls(hdl)
module function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Returns a new NDArray, detached from the current graph.
def _spec_to_globs(address_mapper, specs): patterns = set() for spec in specs: patterns.update(spec.make_glob_patterns(address_mapper)) return PathGlobs(include=patterns, exclude=address_mapper.build_ignore_patterns)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Given a Specs object, return a PathGlobs object for the build files that it matches.
def complete(self): if not self._techniques: return False if not any(tech._is_overriden('complete') for tech in self._techniques): return False return self.completion_mode(tech.complete(self) for tech in self._techniques if tech._is_overriden('complete'))
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement false if_statement not_operator call identifier generator_expression call attribute identifier identifier argument_list string string_start string_content string_end for_in_clause identifier attribute identifier identifier block return_statement false return_statement call attribute identifier identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier if_clause call attribute identifier identifier argument_list string string_start string_content string_end
Returns whether or not this manager has reached a "completed" state.
def cgi_parameter_exists(form: cgi.FieldStorage, key: str) -> bool: s = get_cgi_parameter_str(form, key) return s is not None
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement comparison_operator identifier none
Does a CGI form contain the key?
def _send(self, message): message['command'] = 'zappa.asynchronous.route_lambda_task' payload = json.dumps(message).encode('utf-8') if len(payload) > LAMBDA_ASYNC_PAYLOAD_LIMIT: raise AsyncException("Payload too large for async Lambda call") self.response = self.client.invoke( FunctionName=self.lambda_function_name, InvocationType='Event', Payload=payload ) self.sent = (self.response.get('StatusCode', 0) == 202)
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment attribute identifier identifier parenthesized_expression comparison_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer integer
Given a message, directly invoke the lamdba function for this task.
def create_page(slug, post_data): logger.info('Call create Page') if MWiki.get_by_uid(slug): return False title = post_data['title'].strip() if len(title) < 2: return False return MWiki.__create_rec(slug, '2', post_data=post_data)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list identifier block return_statement false expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block return_statement false return_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier
The page would be created with slug.
def _guess_available_methods(self): available_methods = [] for m in ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]: self_method = getattr(type(self), "API_{}".format(m)) super_method = getattr(APIPage, "API_{}".format(m)) if self_method != super_method: available_methods.append(m) return available_methods
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Guess the method implemented by the subclass
def add_synonym(self, syn): n = self.node(syn.class_id) if 'meta' not in n: n['meta'] = {} meta = n['meta'] if 'synonyms' not in meta: meta['synonyms'] = [] meta['synonyms'].append(syn.as_dict())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end dictionary expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list
Adds a synonym for a node
def as_dash_app(self): dateless_dash_app = getattr(self, '_stateless_dash_app_instance', None) if not dateless_dash_app: dateless_dash_app = get_stateless_by_name(self.app_name) setattr(self, '_stateless_dash_app_instance', dateless_dash_app) return dateless_dash_app
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call identifier argument_list identifier string string_start string_content string_end identifier return_statement identifier
Return a DjangoDash instance of the dash application
def send_request(self, method, url, headers=None, data=None, is_retry=False): if not self._token: self.login() if not headers: headers = {} headers['Authorization'] = 'Bearer ' + self._oauth_token headers['ABODE-API-KEY'] = self._token try: response = getattr(self._session, method)( url, headers=headers, json=data) if response and response.status_code < 400: return response except RequestException: _LOGGER.info("Abode connection reset...") if not is_retry: self._token = None return self.send_request(method, url, headers, data, True) raise AbodeException((ERROR.REQUEST))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier try_statement block expression_statement assignment identifier call call identifier argument_list attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement boolean_operator identifier comparison_operator attribute identifier identifier integer block return_statement identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment attribute identifier identifier none return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier true raise_statement call identifier argument_list parenthesized_expression attribute identifier identifier
Send requests to Abode.
def view_creatr(filename): if not check(): click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:view command') return path = os.path.abspath('.') + '/public/templates' if not os.path.exists(path): os.makedirs(path) filename_ = str(filename + ".html").lower() view_file = open(path + "/" + filename_, 'w+') view_file.write("") view_file.close() click.echo(Fore.GREEN + "View file " + filename_ + "created in public/template folder")
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list block expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end return_statement expression_statement assignment identifier binary_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list binary_operator identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier call identifier argument_list binary_operator binary_operator identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end
Name of the View File to be created
def AddHashEntry(self, hash_entry, timestamp): if timestamp in self._hash_entries: message = ("Duplicated hash entry write for path '%s' of type '%s' at " "timestamp '%s'. Old: %s. New: %s.") message %= ("/".join(self._components), self._path_type, timestamp, self._hash_entries[timestamp], hash_entry) raise db.Error(message) if timestamp not in self._path_infos: path_info = rdf_objects.PathInfo( path_type=self._path_type, components=self._components, timestamp=timestamp, hash_entry=hash_entry) self.AddPathInfo(path_info) else: self._path_infos[timestamp].hash_entry = hash_entry
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment identifier tuple call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier identifier subscript attribute identifier identifier identifier identifier raise_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment attribute subscript attribute identifier identifier identifier identifier identifier
Registers hash entry at a given timestamp.
def gen_secret(length=64): charset = string.ascii_letters + string.digits return ''.join(random.SystemRandom().choice(charset) for _ in range(length))
module function_definition identifier parameters default_parameter identifier integer block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement call attribute string string_start string_end identifier generator_expression call attribute call attribute identifier identifier argument_list identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier
Generates a secret of given length
def move(self, source, destination): if source.isfile(): source.copy(destination) source.remove() else: source.copy(destination, recursive=True) source.remove('r')
module function_definition identifier parameters identifier identifier identifier block if_statement call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
the semantic should be like unix 'mv' command
def _write(self, item, labels, features): data = Data([item], [labels], [features]) self._writer.write(data, self.groupname, append=True)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list list identifier list identifier list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier true
Writes the given item to the owned file.
def find_learning_rate_from_args(args: argparse.Namespace) -> None: params = Params.from_file(args.param_path, args.overrides) find_learning_rate_model(params, args.serialization_dir, start_lr=args.start_lr, end_lr=args.end_lr, num_batches=args.num_batches, linear_steps=args.linear, stopping_factor=args.stopping_factor, force=args.force)
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Start learning rate finder for given args
def tamper_file_at(path, pos=0, replace_str=None): if not replace_str: replace_str = "\x00" try: with open(path, "r+b") as fh: if pos < 0: fsize = os.fstat(fh.fileno()).st_size pos = fsize + pos fh.seek(pos) fh.write(replace_str) except IOError: return False finally: try: fh.close() except Exception: pass return True
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block return_statement false finally_clause block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement return_statement true
Tamper a file at the given position and using the given string
def stack_files(files, hemi, source, target): import csv import os import numpy as np fname = "sdist_%s_%s_%s.csv" % (hemi, source, target) filename = os.path.join(os.getcwd(),fname) alldist = [] for dfile in files: alldist.append(np.genfromtxt(dfile, delimiter=',')) alldist = np.array(alldist) alldist.tofile(filename,",") return filename
module function_definition identifier parameters identifier identifier identifier identifier block import_statement dotted_name identifier import_statement dotted_name identifier import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement identifier
This function takes a list of files as input and vstacks them
def lint(): path = os.path.realpath(os.getcwd()) cmd = 'flake8 %s' % path opt = '' print(">>> Linting codebase with the following command: %s %s" % (cmd, opt)) try: return_code = call([cmd, opt], shell=True) if return_code < 0: print(">>> Terminated by signal", -return_code, file=sys.stderr) elif return_code != 0: sys.exit('>>> Lint checks failed') else: print(">>> Lint checks passed", return_code, file=sys.stderr) except OSError as e: print(">>> Execution failed:", e, file=sys.stderr)
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier string string_start string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list list identifier identifier keyword_argument identifier true if_statement comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end unary_operator identifier keyword_argument identifier attribute identifier identifier elif_clause comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier
run linter on our code base.
def load_scripts(): scrypture_dir = os.path.realpath( os.path.abspath( os.path.split( inspect.getfile( inspect.currentframe() ))[0])) if scrypture_dir not in sys.path: sys.path.insert(0, scrypture_dir) registered_scripts = app.config['REGISTERED_SCRIPTS'] for script in registered_scripts: try: s = import_module('.'+script, package=os.path.split(app.config['SCRIPTS_DIR'])[-1]) s.package = s.__name__.split('.')[1] script_name = script.split('.')[-1] registered_modules[script_name] = s except Exception as e: logging.warning('Could not import ' + \ str(script)+': '+str(e.message)) logging.debug(str(traceback.format_exc())) continue
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer identifier expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end for_statement identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier subscript call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end unary_operator integer expression_statement assignment attribute identifier identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer expression_statement assignment subscript identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end line_continuation call identifier argument_list identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list continue_statement
Import all of the modules named in REGISTERED_SCRIPTS
def max_pool(x_input, pool_size): return tf.nn.max_pool(x_input, ksize=[1, pool_size, pool_size, 1], strides=[1, pool_size, pool_size, 1], padding='SAME')
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier list integer identifier identifier integer keyword_argument identifier list integer identifier identifier integer keyword_argument identifier string string_start string_content string_end
max_pool downsamples a feature map by 2X.
def draw(self): if not self.vao: self.vao = VAO(indices=self.array_indices) self._fill_vao() if self.visible: if self.dynamic: for vbo in self.vbos: vbo._buffer_subdata() if self.drawmode == gl.GL_POINTS: gl.glPointSize(self.point_size) for texture in self.textures: texture.bind() with self.vao as vao: self.uniforms.send() vao.draw(mode=self.drawmode) for texture in self.textures: texture.unbind()
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Draw the Mesh if it's visible, from the perspective of the camera and lit by the light. The function sends the uniforms
def makeGly(segID, N, CA, C, O, geo): res= Residue((' ', segID, ' '), "GLY", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) return res
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list tuple string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Creates a Glycine residue
def play(self, target=None, index=None, choose=None): if choose: if self.must_choose_one: choose = card = self.choose_cards.filter(id=choose)[0] self.log("%r: choosing %r", self, choose) else: raise InvalidAction("%r cannot be played with choice %r" % (self, choose)) else: if self.must_choose_one: raise InvalidAction("%r requires a choice (one of %r)" % (self, self.choose_cards)) card = self if not self.is_playable(): raise InvalidAction("%r isn't playable." % (self)) if card.requires_target(): if not target: raise InvalidAction("%r requires a target to play." % (self)) elif target not in self.play_targets: raise InvalidAction("%r is not a valid target for %r." % (target, self)) elif target: self.logger.warning("%r does not require a target, ignoring target %r", self, target) self.game.play_card(self, target, index, choose) return self
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement identifier block if_statement attribute identifier identifier block expression_statement assignment identifier assignment identifier subscript call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier else_clause block if_statement attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement assignment identifier identifier if_statement not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier if_statement call attribute identifier identifier argument_list block if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression identifier elif_clause comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier elif_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier return_statement identifier
Queue a Play action on the card.
def compute_file_hashes(file_path, hashes=frozenset(['md5'])): if not os.path.exists(file_path): logging.warning("%s does not exist" % file_path) return else: logging.debug("Computing [%s] hashes for file [%s]" % (','.join(hashes), file_path)) try: with open(file_path, 'rb') as fd: return compute_hashes(fd, hashes) except (IOError, OSError) as e: logging.warning("Error while calculating digest(s) for file %s: %s" % (file_path, str(e))) raise
module function_definition identifier parameters identifier default_parameter identifier call identifier argument_list list string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute string string_start string_content string_end identifier argument_list identifier identifier try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call identifier argument_list identifier identifier except_clause as_pattern tuple identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier raise_statement
Digests data read from file denoted by file_path.
def all_names(self): return [ _get_variable_names(arr) if not isinstance(arr, ArrayList) else arr.all_names for arr in self]
module function_definition identifier parameters identifier block return_statement list_comprehension conditional_expression call identifier argument_list identifier not_operator call identifier argument_list identifier identifier attribute identifier identifier for_in_clause identifier identifier
The variable names for each of the arrays in this list
def describe_snitch(self, ): self._seqid += 1 d = self._reqs[self._seqid] = defer.Deferred() self.send_describe_snitch() return d
module function_definition identifier parameters identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment identifier assignment subscript attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
returns the snitch used by this cluster
def run_job(self, name): data = self._get_schedule().get(name, {}) if 'function' in data: func = data['function'] elif 'func' in data: func = data['func'] elif 'fun' in data: func = data['fun'] else: func = None if not isinstance(func, list): func = [func] for _func in func: if _func not in self.functions: log.error( 'Invalid function: %s in scheduled job %s.', _func, name ) if 'name' not in data: data['name'] = name log.info('Running Job: %s', name) run = data.get('run', True) if run: self._run_job(_func, data)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier none if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier for_statement identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end true if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Run a schedule job now
def _fullqualname_method_py3(obj): if inspect.isclass(obj.__self__): cls = obj.__self__.__qualname__ else: cls = obj.__self__.__class__.__qualname__ return obj.__self__.__module__ + '.' + cls + '.' + obj.__name__
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier return_statement binary_operator binary_operator binary_operator binary_operator attribute attribute identifier identifier identifier string string_start string_content string_end identifier string string_start string_content string_end attribute identifier identifier
Fully qualified name for 'method' objects in Python 3.
async def log( self, date: datetime.date = None, days: int = None, details: bool = False) -> list: endpoint = 'watering/log' if details: endpoint += '/details' if date and days: endpoint = '{0}/{1}/{2}'.format( endpoint, date.strftime('%Y-%m-%d'), days) data = await self._request('get', endpoint) return data['waterLog']['days']
module function_definition identifier parameters identifier typed_default_parameter identifier type attribute identifier identifier none typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier false type identifier block expression_statement assignment identifier string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier await call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement subscript subscript identifier string string_start string_content string_end string string_start string_content string_end
Get watering information for X days from Y date.
def read_cluster(data, id=1): cl = cluster(1) names = [s.keys()[0] for s in data['seqs']] cl.add_id_member(names, 1) freq = defaultdict() [freq.update({s.keys()[0]: s.values()[0]}) for s in data['freq']]
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list integer expression_statement assignment identifier list_comprehension subscript call attribute identifier identifier argument_list integer for_in_clause identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list expression_statement list_comprehension call attribute identifier identifier argument_list dictionary pair subscript call attribute identifier identifier argument_list integer subscript call attribute identifier identifier argument_list integer for_in_clause identifier subscript identifier string string_start string_content string_end
Read json cluster and populate as cluster class
def _is_inline(button): return isinstance(button, ( types.KeyboardButtonCallback, types.KeyboardButtonSwitchInline, types.KeyboardButtonUrl ))
module function_definition identifier parameters identifier block return_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier
Returns ``True`` if the button belongs to an inline keyboard.
def ddl(self, dialect=None, creates=True, drops=True): dialect = self._dialect(dialect) creator = CreateTable(self.table).compile(mock_engines[dialect]) creator = "\n".join(l for l in str(creator).splitlines() if l.strip()) comments = "\n\n".join(self._comment_wrapper.fill("in %s: %s" % (col, self.comments[col])) for col in self.comments) result = [] if drops: result.append(self._dropper(dialect) + ';') if creates: result.append("%s;\n%s" % (creator, comments)) for child in self.children.values(): result.append(child.ddl(dialect=dialect, creates=creates, drops=drops)) return '\n\n'.join(result)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list subscript identifier identifier expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression identifier for_in_clause identifier call attribute call identifier argument_list identifier identifier argument_list if_clause call attribute identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_content escape_sequence escape_sequence string_end identifier generator_expression call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier list if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier
Returns SQL to define the table.
def export_gpg_key(key): cmd = flatten([gnupg_bin(), gnupg_verbose(), gnupg_home(), "--export", key]) handle, gpg_stderr = stderr_handle() try: gpg_proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=gpg_stderr) output, _err = gpg_proc.communicate() if handle: handle.close() return portable_b64encode(output) except subprocess.CalledProcessError as exception: LOGGER.debug("GPG Command %s", ' '.join(exception.cmd)) LOGGER.debug("GPG Output %s", exception.output) raise CryptoritoError('GPG encryption error')
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list list call identifier argument_list call identifier argument_list call identifier argument_list string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier raise_statement call identifier argument_list string string_start string_content string_end
Exports a GPG key and returns it