code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def pages(self, limit=0): if limit > 0: self.iterator.limit = limit return self.iterator
module function_definition identifier parameters identifier default_parameter identifier integer block if_statement comparison_operator identifier integer block expression_statement assignment attribute attribute identifier identifier identifier identifier return_statement attribute identifier identifier
Return iterator for pages
def query_all_issues(after): page = count(1) data = [] while True: page_data = query_issues(next(page), after) if not page_data: break data.extend(page_data) return data
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list integer expression_statement assignment identifier list while_statement true block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Hits the github API for all closed issues after the given date, returns the data.
def create_cell_renderer_combo(self, tree_view, title="title", assign=0, editable=False, model=None, function=None): renderer_combo = Gtk.CellRendererCombo() renderer_combo.set_property('editable', editable) if model: renderer_combo.set_property('model', model) if function: renderer_combo.connect("edited", function) renderer_combo.set_property("text-column", 0) renderer_combo.set_property("has-entry", False) column = Gtk.TreeViewColumn(title, renderer_combo, text=assign) tree_view.append_column(column)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer default_parameter identifier false default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Function creates a CellRendererCombo with title, model
def field_specific_errors(self): return { key: value for key, value in self.error_dict.items() if key != NON_FIELD_ERRORS }
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier identifier
Returns a dictionary of field-specific validation errors for this row.
def update(self): obj = self.__model__.objects.get_for_update(id=self.id) for name, value in self.__dict__.items(): if name in self._properties: setattr(obj, name, value) obj.update() return obj
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Finds record and update it based in serializer values
def load(fname): content = _open(fname).read() if PY2: state = pickle.loads(content) else: state = pickle.loads(content, encoding='latin1') voc, vec = state if len(voc) == 2: words, counts = voc word_count = dict(zip(words, counts)) vocab = CountedVocabulary(word_count=word_count) else: vocab = OrderedVocabulary(voc) return Embedding(vocabulary=vocab, vectors=vec)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Load an embedding dump generated by `save`
def nextSunrise(jd, lat, lon): return swe.sweNextTransit(const.SUN, jd, lat, lon, 'RISE')
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier string string_start string_content string_end
Returns the JD of the next sunrise.
def _ostaunicode(src): if have_py_3: bytename = src else: bytename = src.decode('utf-8') try: enc = bytename.encode('latin-1') encbyte = b'\x08' except (UnicodeEncodeError, UnicodeDecodeError): enc = bytename.encode('utf-16_be') encbyte = b'\x10' return encbyte + enc
module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content escape_sequence string_end except_clause tuple identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_content escape_sequence string_end return_statement binary_operator identifier identifier
Internal function to create an OSTA byte string from a source string.
def unwrap(self): red = [self.red[i] for i in range(self.size)] green = [self.green[i] for i in range(self.size)] blue = [self.blue[i] for i in range(self.size)] if NORMALIZE_GAMMA_RAMPS: red = [value / 65535.0 for value in red] green = [value / 65535.0 for value in green] blue = [value / 65535.0 for value in blue] return self.GLFWgammaramp(red, green, blue)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier call identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment identifier list_comprehension binary_operator identifier float for_in_clause identifier identifier expression_statement assignment identifier list_comprehension binary_operator identifier float for_in_clause identifier identifier expression_statement assignment identifier list_comprehension binary_operator identifier float for_in_clause identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier
Returns a GLFWgammaramp object.
def _slugify_internal_collection_name(self, json_repr): collection = self._coerce_json_to_collection(json_repr) if collection is None: return None internal_name = collection['name'] return slugify(internal_name)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call identifier argument_list identifier
Parse the JSON, find its name, return a slug of its name
def as_dict(self): "json friendly dict representation" d = {} d["@module"] = self.__class__.__module__ d["@class"] = self.__class__.__name__ d["spin_mode"] = self.spin_mode.as_dict() d["smearing"] = self.smearing.as_dict() d["algorithm"] = self.algorithm.as_dict() if self.algorithm else None d["nband"] = self.nband d["fband"] = self.fband d["charge"] = self.charge d["comment"] = self.comment return d
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end conditional_expression call attribute attribute identifier identifier identifier argument_list attribute identifier identifier none expression_statement assignment subscript identifier 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 expression_statement assignment subscript identifier 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 return_statement identifier
json friendly dict representation
def config(self, name, suffix): "Return config variable value, defaulting to environment" var = '%s_%s' % (name, suffix) var = var.upper().replace('-', '_') if var in self._config: return self._config[var] return os.environ[var]
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier 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 if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier identifier return_statement subscript attribute identifier identifier identifier
Return config variable value, defaulting to environment
def submit_sample_url(self, url, params={}, _extra_params={}): self._check_user_parameters(params) params = copy.copy(params) params['sample-url'] = url return self._submit(params, _extra_params=_extra_params)
module function_definition identifier parameters identifier identifier default_parameter identifier dictionary default_parameter identifier dictionary block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Submit a sample at a given URL for analysis.
def change_number_matches(self, current_match=0, total_matches=0): if current_match and total_matches: matches_string = u"{} {} {}".format(current_match, _(u"of"), total_matches) self.number_matches_text.setText(matches_string) elif total_matches: matches_string = u"{} {}".format(total_matches, _(u"matches")) self.number_matches_text.setText(matches_string) else: self.number_matches_text.setText(_(u"no matches"))
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block 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 identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end
Change number of match and total matches.
def _febrl_links(df): index = df.index.to_series() keys = index.str.extract(r'rec-(\d+)', expand=True)[0] index_int = numpy.arange(len(df)) df_helper = pandas.DataFrame({ 'key': keys, 'index': index_int }) pairs_df = df_helper.merge( df_helper, on='key' )[['index_x', 'index_y']] pairs_df = pairs_df[pairs_df['index_x'] > pairs_df['index_y']] return pandas.MultiIndex( levels=[df.index.values, df.index.values], labels=[pairs_df['index_x'].values, pairs_df['index_y'].values], names=[None, None], verify_integrity=False )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true integer expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript identifier comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list keyword_argument identifier list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier list attribute subscript identifier string string_start string_content string_end identifier attribute subscript identifier string string_start string_content string_end identifier keyword_argument identifier list none none keyword_argument identifier false
Get the links of a FEBRL dataset.
def stop_containers(self): while len(self._containers): container = self._containers.pop() try: container.kill(signal.SIGKILL) except docker.errors.APIError: pass
module function_definition identifier parameters identifier block while_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause attribute attribute identifier identifier identifier block pass_statement
Stops all containers used by this instance of the backend.
def _simple_command(self, command, arg=None, **kwargs): self._protocol.send_command(command, arg) return self._protocol.handle_simple_responses(**kwargs)
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
Send a simple command.
def list_security_group_rules(self, retrieve_all=True, **_params): return self.list('security_group_rules', self.security_group_rules_path, retrieve_all, **_params)
module function_definition identifier parameters identifier default_parameter identifier true dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier dictionary_splat identifier
Fetches a list of all security group rules for a project.
def intinlist(lst): for item in lst: try: item = int(item) return True except ValueError: pass return False
module function_definition identifier parameters identifier block for_statement identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier return_statement true except_clause identifier block pass_statement return_statement false
test if int in list
def _create_config(self): configinfo = {'creation_date': [ datetime.datetime.now().date().isoformat()], 'author': [self.site.site_config['default_author']], 'status': [u'draft'], 'lang': [u''], 'tags': [u''], 'title': [self._title], 'slug': [self._slug], 'theme': [u''], 'template': [u''], 'page_id': [uuid.uuid4().hex] } return configinfo
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end list call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier argument_list pair string string_start string_content string_end list subscript attribute attribute identifier identifier identifier string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end pair string string_start string_content string_end list string string_start string_end pair string string_start string_content string_end list string string_start string_end pair string string_start string_content string_end list attribute identifier identifier pair string string_start string_content string_end list attribute identifier identifier pair string string_start string_content string_end list string string_start string_end pair string string_start string_content string_end list string string_start string_end pair string string_start string_content string_end list attribute call attribute identifier identifier argument_list identifier return_statement identifier
Create the default configuration dictionary for this page.
def ping(): try: curl_couchdb('/cozy/') ping = True except requests.exceptions.ConnectionError, error: print error ping = False return ping
module function_definition identifier parameters block try_statement block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier true except_clause attribute attribute identifier identifier identifier identifier block print_statement identifier expression_statement assignment identifier false return_statement identifier
Ping CozyDB with existing credentials
def _delete(collection_name, spec, opts, flags): encoded = _dict_to_bson(spec, False, opts) return b"".join([ _ZERO_32, _make_c_string(collection_name), _pack_int(flags), encoded]), len(encoded)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier false identifier return_statement expression_list call attribute string string_start string_end identifier argument_list list identifier call identifier argument_list identifier call identifier argument_list identifier identifier call identifier argument_list identifier
Get an OP_DELETE message.
def logp_partial_gradient(self, variable, calculation_set=None): if self.verbose > 0: print_('\t' + self.__name__ + ': logp_partial_gradient accessed.') if not (datatypes.is_continuous(variable) and datatypes.is_continuous(self)): return zeros(shape(variable.value)) gradient = builtins.sum( [child.logp_partial_gradient(self, calculation_set) for child in self.children]) totalGradient = 0 for parameter, value in six.iteritems(self.parents): if value is variable: totalGradient += self.apply_jacobian( parameter, variable, gradient) return np.reshape(totalGradient, shape(variable.value))
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list binary_operator binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier string string_start string_content string_end if_statement not_operator parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier block return_statement call identifier argument_list call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier integer for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier call identifier argument_list attribute identifier identifier
gets the logp gradient of this deterministic with respect to variable
def argmax(self): if "argmax" not in self.attrs.keys(): def f(dataset, s): arr = dataset[s] try: amin = np.nanargmax(arr) except ValueError: amin = 0 idx = np.unravel_index(amin, arr.shape) val = arr[idx] return (tuple(i + (ss.start if ss.start else 0) for i, ss in zip(idx, s)), val) chunk_res = self.chunkwise(f) idxs = [i[0] for i in chunk_res.values()] vals = [i[1] for i in chunk_res.values()] self.attrs["argmax"] = idxs[np.nanargmax(vals)] return tuple(self.attrs["argmax"])
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list block function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier subscript identifier identifier return_statement tuple call identifier generator_expression binary_operator identifier parenthesized_expression conditional_expression attribute identifier identifier attribute identifier identifier integer for_in_clause pattern_list identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end subscript identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end
Index of the maximum, ignorning nans.
def sample(self, histogram_logits): histogram_probs = histogram_logits.exp() atoms = self.support_atoms.view(1, 1, self.atoms) return (histogram_probs * atoms).sum(dim=-1).argmax(dim=1)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer integer attribute identifier identifier return_statement call attribute call attribute parenthesized_expression binary_operator identifier identifier identifier argument_list keyword_argument identifier unary_operator integer identifier argument_list keyword_argument identifier integer
Sample from a greedy strategy with given q-value histogram
def _contains_cftime_datetimes(array) -> bool: try: from cftime import datetime as cftime_datetime except ImportError: return False else: if array.dtype == np.dtype('O') and array.size > 0: sample = array.ravel()[0] if isinstance(sample, dask_array_type): sample = sample.compute() if isinstance(sample, np.ndarray): sample = sample.item() return isinstance(sample, cftime_datetime) else: return False
module function_definition identifier parameters identifier type identifier block try_statement block import_from_statement dotted_name identifier aliased_import dotted_name identifier identifier except_clause identifier block return_statement false else_clause block if_statement boolean_operator comparison_operator attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator attribute identifier identifier integer block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list identifier identifier else_clause block return_statement false
Check if an array contains cftime.datetime objects
def as_dict(self): return {self.FLD_OP: self._op.name, self.FLD_MARK: self._pos, self.FLD_FLD: self._fld}
module function_definition identifier parameters identifier block return_statement dictionary pair attribute identifier identifier attribute attribute identifier identifier identifier pair attribute identifier identifier attribute identifier identifier pair attribute identifier identifier attribute identifier identifier
Representation as a dict for JSON serialization.
def to_cls(self): try: if isinstance(self._to_cls, str): self._to_cls = fetch_entity_cls_from_registry(self._to_cls) except AssertionError: pass return self._to_cls
module function_definition identifier parameters identifier block try_statement block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier except_clause identifier block pass_statement return_statement attribute identifier identifier
Property to retrieve to_cls as an entity when possible
def fw_create(self, data, fw_name=None, cache=False): LOG.debug("FW create %s", data) try: self._fw_create(fw_name, data, cache) except Exception as exc: LOG.error("Exception in fw_create %s", str(exc))
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier 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 call identifier argument_list identifier
Top level FW create function.
def remove_file(self): if not self.fullpath or not self.archived: raise RuntimeError() try: os.remove(self.fullpath) except: print("Error removing %s: %s" % (self.fullpath, sys.exc_info()[1]))
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier except_clause block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier subscript call attribute identifier identifier argument_list integer
Removes archived file associated with this DP
def format_item(item, template, name='item'): ctx = {name: item} return render_template_to_string(template, **ctx)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier dictionary pair identifier identifier return_statement call identifier argument_list identifier dictionary_splat identifier
Render a template to a string with the provided item in context.
def message_info(message): method = message.get('method') msgid = message.get('id') error = message.get('error') if method and msgid is not None: return 'method call "{}", id = "{}"'.format(method, msgid) elif method: return 'notification "{}"'.format(method) elif error is not None and msgid is not None: return 'error reply to id = "{}"'.format(msgid) elif error is not None: code = error.get('code', '(none)') return 'error reply: {}'.format(errorcode.get(code, code)) else: return 'method return for id = "{}"'.format(msgid)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier comparison_operator identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier elif_clause identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier elif_clause boolean_operator comparison_operator identifier none comparison_operator identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list identifier elif_clause comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier identifier else_clause block return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Return a string describing a message, for debugging purposes.
def _sanitize_numbers(uncleaned_numbers): cleaned_numbers = [] for x in uncleaned_numbers: try: cleaned_numbers.append(int(x)) except ValueError: cleaned_numbers.append(x) return cleaned_numbers
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Convert strings to integers if possible
def requestSubsystem(self, subsystem): data = common.NS(subsystem) return self.sendRequest('subsystem', data, wantReply=True)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier keyword_argument identifier true
Request a subsystem and return a deferred reply.
def setup(self, redis_conn=None, host='localhost', port=6379): if redis_conn is None: if host is not None and port is not None: self.redis_conn = redis.Redis(host=host, port=port) else: raise Exception("Please specify some form of connection " "to Redis") else: self.redis_conn = redis_conn self.redis_conn.info()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier integer block if_statement comparison_operator identifier none block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Set up the redis connection
def dict(self): return_obj = {} for attr in dir(self): if not attr.startswith('__') and attr not in self.__reserved: if isinstance(getattr(self, attr), list): return_val = [] for item in getattr(self, attr): if isinstance(item, DictClass): return_val.append(dict(item)) else: return_val.append(item) elif isinstance(getattr(self, attr), dict): return_val = {} for key, item in getattr(self, attr).items(): if isinstance(item, DictClass): return_val[key] = item.dict() else: return_val[key] = item elif isinstance(getattr(self, attr), DictClass): return_val = getattr(self, attr).dict() else: return_val = getattr(self, attr) return_obj[attr] = return_val return return_obj
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block if_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator identifier attribute identifier identifier block if_statement call identifier argument_list call identifier argument_list identifier identifier identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list call identifier argument_list identifier identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute call identifier argument_list identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment subscript identifier identifier identifier elif_clause call identifier argument_list call identifier argument_list identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
converts the class to a dictionary object
def load_buildfile(self, target): log.info('Loading: %s', target) filepath = os.path.join(target.path, app.get_options().buildfile_name) try: repo = self.repo_state.GetRepo(target.repo) return repo.get_file(filepath) except gitrepo.GitError as err: log.error('Failed loading %s: %s', target, err) raise error.BrokenGraph('Sadface.')
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier 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 identifier identifier raise_statement call attribute identifier identifier argument_list string string_start string_content string_end
Pull a build file from git.
def vhost_remove(cls, name): oper = cls.call('hosting.rproxy.vhost.delete', name) cls.echo('Deleting your virtual host %s' % name) cls.display_progress(oper) cls.echo('Your virtual host have been removed') return oper
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Delete a vhost in a webaccelerator
def _from_dict(cls, _dict): args = {} if 'start_time' in _dict: args['start_time'] = _dict.get('start_time') else: raise ValueError( 'Required property \'start_time\' not present in WordAlternativeResults JSON' ) if 'end_time' in _dict: args['end_time'] = _dict.get('end_time') else: raise ValueError( 'Required property \'end_time\' not present in WordAlternativeResults JSON' ) if 'alternatives' in _dict: args['alternatives'] = [ WordAlternativeResult._from_dict(x) for x in (_dict.get('alternatives')) ] else: raise ValueError( 'Required property \'alternatives\' not present in WordAlternativeResults JSON' ) return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary 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 call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence 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 call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence 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_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end else_clause block raise_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a WordAlternativeResults object from a json dictionary.
def export_data( self ): klass = self.__class__ output = bytearray( b'\x00'*self.get_size() ) queue = [] for name in klass._fields: self.scrub_field( name ) self.validate_field( name ) self.update_deps() for name in klass._fields: klass._fields[name].update_buffer_with_value( self._field_data[name], output, parent=self ) for name, check in klass._checks.items(): check.update_buffer( output, parent=self ) return output
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content escape_sequence string_end call attribute identifier identifier argument_list expression_statement assignment identifier list for_statement identifier attribute identifier identifier block 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 for_statement identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list subscript attribute identifier identifier identifier identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
Export data to a byte array.
def formatBodyNode(root,path): body = root body.name = "body" body.weight = calcFnWeight(body) body.path = path body.pclass = None return body
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier identifier expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none return_statement identifier
Format the root node for use as the body node.
def publish_json(self, channel, obj): return self.publish(channel, json.dumps(obj))
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
Post a JSON-encoded message to channel.
def delete(*args): from syn.base_utils import this_module mod = this_module(npop=3) yield for arg in args: name = arg if not isinstance(name, STR): name = arg.__name__ delattr(mod, name)
module function_definition identifier parameters list_splat_pattern identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier integer expression_statement yield for_statement identifier identifier block expression_statement assignment identifier identifier if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list identifier identifier
For using then deleting objects.
def provision(self, tool: Tool) -> docker.models.containers.Container: if not self.is_installed(tool): raise Exception("tool is not installed: {}".format(tool.name)) client = self.__installation.docker return client.containers.create(tool.image)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type attribute attribute attribute identifier identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Provisions a mountable Docker container for a given tool.
def init_datamembers(self, rec): if 'synonym' in self.optional_attrs: rec.synonym = [] if 'xref' in self.optional_attrs: rec.xref = set() if 'subset' in self.optional_attrs: rec.subset = set() if 'comment' in self.optional_attrs: rec.comment = "" if 'relationship' in self.optional_attrs: rec.relationship = {} rec.relationship_rev = {}
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier string string_start string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary
Initialize current GOTerm with data members for storing optional attributes.
async def json(self, *, encoding: str=None, loads: JSONDecoder=DEFAULT_JSON_DECODER, content_type: Optional[str]='application/json') -> Any: if self._body is None: await self.read() if content_type: ctype = self.headers.get(hdrs.CONTENT_TYPE, '').lower() if not _is_expected_content_type(ctype, content_type): raise ContentTypeError( self.request_info, self.history, message=('Attempt to decode JSON with ' 'unexpected mimetype: %s' % ctype), headers=self.headers) if encoding is None: encoding = self.get_encoding() return loads(self._body.decode(encoding))
module function_definition identifier parameters identifier keyword_separator typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier identifier typed_default_parameter identifier type generic_type identifier type_parameter type identifier string string_start string_content string_end type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement await call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_end identifier argument_list if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier
Read and decodes JSON response.
def real_ip(self): if self._real_ip is None: response = get(ICANHAZIP) self._real_ip = self._get_response_text(response) return self._real_ip
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
The actual public IP of this host.
def hide_navbar_items(portal): logger.info("*** Hide Navigation Items ***") object_ids = portal.objectIds() object_ids = filter(lambda id: id in object_ids, NAV_BAR_ITEMS_TO_HIDE) for object_id in object_ids: item = portal[object_id] item.setExcludeFromNav(True) item.reindexObject()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list
Hide root items in navigation
def main(): if sys.version_info[0] < 3: sys.stdout = codecs.getwriter("utf-8")(sys.stdout) options = docopt.docopt(__doc__, help=True, version='template_remover v%s' % __VERSION__) print(template_remover.clean(io.open(options['FILENAME']).read())) return 0
module function_definition identifier parameters block if_statement comparison_operator subscript attribute identifier identifier integer integer block expression_statement assignment attribute identifier identifier call call attribute identifier identifier argument_list string string_start string_content string_end argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier argument_list return_statement integer
Entry point for remove_template.
def _tail_profile(self, db, interval): latest_doc = None while latest_doc is None: time.sleep(interval) latest_doc = db['system.profile'].find_one() current_time = latest_doc['ts'] while True: time.sleep(interval) cursor = db['system.profile'].find({'ts': {'$gte': current_time}}).sort('ts', pymongo.ASCENDING) for doc in cursor: current_time = doc['ts'] yield doc
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none while_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier subscript identifier string string_start string_content string_end while_statement true block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute subscript identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end identifier identifier argument_list string string_start string_content string_end attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement yield identifier
Tails the system.profile collection
def ffill(arr, dim=None, limit=None): import bottleneck as bn axis = arr.get_axis_num(dim) _limit = limit if limit is not None else arr.shape[axis] return apply_ufunc(bn.push, arr, dask='parallelized', keep_attrs=True, output_dtypes=[arr.dtype], kwargs=dict(n=_limit, axis=axis)).transpose(*arr.dims)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier conditional_expression identifier comparison_operator identifier none subscript attribute identifier identifier identifier return_statement call attribute call identifier argument_list attribute identifier identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier list attribute identifier identifier keyword_argument identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list list_splat attribute identifier identifier
forward fill missing values
def walk_json(d, func): if isinstance(d, Mapping): return OrderedDict((k, walk_json(v, func)) for k, v in d.items()) elif isinstance(d, list): return [walk_json(v, func) for v in d] else: return func(d)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier generator_expression tuple identifier call identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list elif_clause call identifier argument_list identifier identifier block return_statement list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier else_clause block return_statement call identifier argument_list identifier
Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result
def aead_filename(aead_dir, key_handle, public_id): parts = [aead_dir, key_handle] + pyhsm.util.group(public_id, 2) + [public_id] return os.path.join(*parts)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier integer list identifier return_statement call attribute attribute identifier identifier identifier argument_list list_splat identifier
Return the filename of the AEAD for this public_id.
def init_limit(self, key, lower=None, upper=None, limit=False): above = agtb(self.__dict__[key], upper) for idx, item in enumerate(above): if item == 0.: continue maxval = upper[idx] self.log( '{0} <{1}.{2}> above its maximum of {3}.'.format( self.name[idx], self._name, key, maxval), ERROR) if limit: self.__dict__[key][idx] = maxval below = altb(self.__dict__[key], lower) for idx, item in enumerate(below): if item == 0.: continue minval = lower[idx] self.log( '{0} <{1}.{2}> below its minimum of {3}.'.format( self.name[idx], self._name, key, minval), ERROR) if limit: self.__dict__[key][idx] = minval
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier float block continue_statement expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier identifier attribute identifier identifier identifier identifier identifier if_statement identifier block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier float block continue_statement expression_statement assignment identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier identifier attribute identifier identifier identifier identifier identifier if_statement identifier block expression_statement assignment subscript subscript attribute identifier identifier identifier identifier identifier
check if data is within limits. reset if violates
def generate_specifications(self, count=1): out = {} copy_from = self.get_copy_from() for arnum in range(count): source = copy_from.get(arnum) if source is None: out[arnum] = {} continue results_range = source.getResultsRange() specification = {} for rr in results_range: specification[rr.get("keyword")] = rr out[arnum] = specification return out
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier identifier dictionary continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Returns a mapping of count -> specification
def squeeze(attrs, inputs, proto_obj): new_attrs = translation_utils._fix_attribute_names(attrs, {'axes' : 'axis'}) return 'squeeze', new_attrs, inputs
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary pair string string_start string_content string_end string string_start string_content string_end return_statement expression_list string string_start string_content string_end identifier identifier
Remove single-dimensional entries from the shape of a tensor.
def permute(self, ba): c = ba.copy() for i in xrange(len(self.mapping)): ba[i] = c[self.mapping[i]] return ba
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier subscript attribute identifier identifier identifier return_statement identifier
Permute the bitarray ba inplace.
def field_factory(base_class): from .fields import TranslationField class TranslationFieldField(TranslationField, base_class): pass TranslationFieldField.__name__ = "Translation%s" % base_class.__name__ return TranslationFieldField
module function_definition identifier parameters identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier class_definition identifier argument_list identifier identifier block pass_statement expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end attribute identifier identifier return_statement identifier
Takes a field base class and wrap it with ``TranslationField`` class.
def nmltostring(nml): if not isinstance(nml,dict): raise ValueError("nml should be a dict !") curstr = "" for key,group in nml.items(): namelist = ["&" + key] for k, v in group.items(): if isinstance(v, list) or isinstance(v, tuple): namelist.append(k + " = " + ",".join(map(str, v)) + ",") elif is_string(v): namelist.append(k + " = '" + str(v) + "',") else: namelist.append(k + " = " + str(v) + ",") namelist.append("/") curstr = curstr + "\n".join(namelist) + "\n" return curstr
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier list binary_operator string string_start string_content string_end identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier string string_start string_content string_end elif_clause call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier string string_start string_content escape_sequence string_end return_statement identifier
Convert a dictionary representing a Fortran namelist into a string.
def elapsed(self): if not self.started or self._start_time is None: return 0.0 return self._timing_data[-1][0] - self._start_time
module function_definition identifier parameters identifier block if_statement boolean_operator not_operator attribute identifier identifier comparison_operator attribute identifier identifier none block return_statement float return_statement binary_operator subscript subscript attribute identifier identifier unary_operator integer integer attribute identifier identifier
Returns the number of seconds it has been since the start until the latest entry.
def task_stop(self, **kw): id, task = self.get_task(**kw) self._execute(id, 'stop') return self.get_task(uuid=task['uuid'])[1]
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement subscript call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end integer
Marks a task as stopped.
def cmd_xcode(self, *args): app_name = self.buildozer.namify(self.buildozer.config.get('app', 'package.name')) app_name = app_name.lower() ios_dir = ios_dir = join(self.buildozer.platform_dir, 'kivy-ios') self.buildozer.cmd('open {}.xcodeproj'.format( app_name), cwd=join(ios_dir, '{}-ios'.format(app_name)))
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier assignment identifier call identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list identifier
Open the xcode project.
def cleanup_lib(self): if not self.using_openmp: logging.debug('unloading shared library') _ctypes.dlclose(self.lib._handle)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier
unload the previously loaded shared library
def saccadic_momentum_effect(durations, forward_angle, summary_stat=nanmean): durations_per_da = np.nan * np.ones((len(e_angle) - 1,)) for i, (bo, b1) in enumerate(zip(e_angle[:-1], e_angle[1:])): idx = ( bo <= forward_angle) & ( forward_angle < b1) & ( ~np.isnan(durations)) durations_per_da[i] = summary_stat(durations[idx]) return durations_per_da
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block expression_statement assignment identifier binary_operator attribute identifier identifier call attribute identifier identifier argument_list tuple binary_operator call identifier argument_list identifier integer for_statement pattern_list identifier tuple_pattern identifier identifier call identifier argument_list call identifier argument_list subscript identifier slice unary_operator integer subscript identifier slice integer block expression_statement assignment identifier binary_operator binary_operator parenthesized_expression comparison_operator identifier identifier parenthesized_expression comparison_operator identifier identifier parenthesized_expression unary_operator call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier
Computes the mean fixation duration at forward angles.
def _sample(probability_vec): return map(int, numpy.random.random(probability_vec.size) <= probability_vec)
module function_definition identifier parameters identifier block return_statement call identifier argument_list identifier comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
Return random binary string, with given probabilities.
def _remove_references(self, removed_part): removed_part.parent = None referrers_to_remove = set() for referrer in removed_part.referrers: if removed_part not in referrer.ancestors(): for label, referred_part in list(referrer.labels.items()): if referred_part is removed_part: del referrer.labels[label] referrers_to_remove.add(referrer) removed_part.referrers -= referrers_to_remove labels_to_delete = [] if isinstance(removed_part, Compound): for label, part in list(removed_part.labels.items()): if not isinstance(part, Compound): for p in part: self._remove_references(p) elif removed_part not in part.ancestors(): try: part.referrers.discard(removed_part) except KeyError: pass else: labels_to_delete.append(label) for label in labels_to_delete: removed_part.labels.pop(label, None)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block delete_statement subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier identifier expression_statement assignment identifier list if_statement call identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement not_operator call identifier argument_list identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier none
Remove labels pointing to this part and vice versa.
def _load_version(cls, state, version): from ._audio_feature_extractor import _get_feature_extractor from .._mxnet import _mxnet_utils state['_feature_extractor'] = _get_feature_extractor(state['feature_extractor_name']) num_classes = state['num_classes'] num_inputs = state['_feature_extractor'].output_length if 'custom_layer_sizes' in state: custom_layer_sizes = list(map(int, state['custom_layer_sizes'])) else: custom_layer_sizes = [100, 100] state['custom_layer_sizes'] = custom_layer_sizes net = SoundClassifier._build_custom_neural_network(num_inputs, num_classes, custom_layer_sizes) net_params = net.collect_params() ctx = _mxnet_utils.get_mxnet_context() _mxnet_utils.load_net_params_from_state(net_params, state['_custom_classifier'], ctx=ctx) state['_custom_classifier'] = net return SoundClassifier(state)
module function_definition identifier parameters identifier identifier identifier block import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier import_from_statement relative_import import_prefix dotted_name identifier dotted_name identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute subscript identifier string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier list integer integer expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call identifier argument_list identifier
A function to load a previously saved SoundClassifier instance.
def session(self): from sqlalchemy.orm import sessionmaker from sqlalchemy.event import listen if not self.Session: self.Session = sessionmaker(bind=self.engine) if not self._session: self._session = self.Session() if self._schema: def after_begin(session, transaction, connection): session.execute('SET search_path TO {}'.format(self._schema)) listen(self._session, 'after_begin', after_begin) return self._session
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier return_statement attribute identifier identifier
Return a SqlAlchemy session.
def analyses_info(self): f_config = os.path.join(self.analyses_path, 'index.yaml') tornado.autoreload.watch(f_config) with io.open(f_config, 'r', encoding='utf8') as f: config = yaml.safe_load(f) self.info.update(config) if self.debug: self.info['version'] += '.debug-{:04X}'.format( int(random.random() * 0xffff)) readme = Readme(self.analyses_path) if self.info['description'] is None: self.info['description'] = readme.text.strip() self.info['description_html'] = readme.html
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list binary_operator call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end none block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier
Add analyses from the analyses folder.
def _ask(question, default=None, data_type='str', show_hint=False): data = default if data_type == 'bool': data = None default_string = "Y" if default else "N" while data not in ('Y', 'J', 'N', '1', '0'): data = input("%s? [%s]: " % (question, default_string)).upper() if data == '': return default return data in ('Y', 'J', '1') elif data_type in ('str', 'unicode'): if show_hint: msg = "%s? [%s] (%s): " % (question, default, data_type) else: msg = question data = input(msg) if len(data) == 0: data = default elif data_type == 'int': if show_hint: msg = "%s? [%s] (%s): " % (question, default, data_type) else: msg = question data = input(msg) if len(data) == 0: data = int(default) else: data = int(data) return data
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier false block expression_statement assignment identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier none expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end while_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier call attribute call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier argument_list if_statement comparison_operator identifier string string_start string_end block return_statement identifier return_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Interactively ask the user for data
def slicenet_params1_tiny(): hparams = slicenet_params1() hparams.attention_type = "simple" hparams.separability = 0 hparams.hidden_size = 128 hparams.num_hidden_layers = 2 hparams.batch_size = 512 hparams.learning_rate_warmup_steps = 200 return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer return_statement identifier
Version for fast local runs.
def skew_normal_expval(mu, tau, alpha): delta = alpha / np.sqrt(1. + alpha ** 2) return mu + np.sqrt(2 / pi / tau) * delta
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list binary_operator float binary_operator identifier integer return_statement binary_operator identifier binary_operator call attribute identifier identifier argument_list binary_operator binary_operator integer identifier identifier identifier
Expectation of skew-normal random variables.
def raw(self, from_, to, body): if isinstance(to, string_types): raise TypeError('"to" parameter must be enumerable') return self._session.post('{}/raw'.format(self._url), json={ 'from': from_, 'to': to, 'body': body, }).json()
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument 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 identifier argument_list
Send a raw MIME message.
def parse_sm_config(): sagemaker_config = "/opt/ml/input/config/hyperparameters.json" if os.path.exists(sagemaker_config): conf = {} conf["sagemaker_training_job_name"] = os.getenv('TRAINING_JOB_NAME') for k, v in six.iteritems(json.load(open(sagemaker_config))): cast = v.strip('"') if os.getenv("WANDB_API_KEY") is None and k == "wandb_api_key": os.environ["WANDB_API_KEY"] = cast else: if re.match(r'^[-\d]+$', cast): cast = int(cast) elif re.match(r'^[-.\d]+$', cast): cast = float(cast) conf[k] = cast return conf else: return False
module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier else_clause block if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier else_clause block return_statement false
Attempts to parse SageMaker configuration returning False if it can't find it
def iter_links_element_text(cls, element): if element.text: link_type = identify_link_type(element.text) yield LinkInfo( element=element, tag=element.tag, attrib=None, link=element.text, inline=False, linked=True, base_link=None, value_type='plain', link_type=link_type )
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement yield call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier none keyword_argument identifier attribute identifier identifier keyword_argument identifier false keyword_argument identifier true keyword_argument identifier none keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Get the element text as a link.
def find_focusable(node): if not node.children: return node if node.focus: return find_focusable(node.children_dict[node.focus[0]])
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement identifier if_statement attribute identifier identifier block return_statement call identifier argument_list subscript attribute identifier identifier subscript attribute identifier identifier integer
Search for the first focusable window within the node tree
def file_containing_import(import_path, import_root): if not _import_paths: load_stdlib() if os.path.isfile(import_root): import_root = os.path.dirname(import_root) search_paths = [import_root] + _import_paths module_parts = import_path.split('.') for i in range(len(module_parts), 0, -1): module_path = os.path.join(*module_parts[:i]) for sp in search_paths: p = os.path.join(sp, module_path) if os.path.isdir(p): return os.path.join(p, '__init__.py') elif os.path.isfile(p + '.py'): return p + '.py' return None
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block expression_statement call identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier binary_operator list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list call identifier argument_list identifier integer unary_operator integer block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list_splat subscript identifier slice identifier for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end elif_clause call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end block return_statement binary_operator identifier string string_start string_content string_end return_statement none
Finds the file that might contain the import_path.
def process_role(ctx, param, value): role = Role.query.filter(Role.name == value).first() if not role: raise click.BadParameter('Role with name \'%s\' not found.', value) return role
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list comparison_operator attribute identifier identifier identifier identifier argument_list if_statement not_operator identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end identifier return_statement identifier
Return a role if it exists.
def _glyph_for_complex_pattern(self, pattern): monomer_glyphs = [] for monomer_pattern in pattern.monomer_patterns: glyph = self._glyph_for_monomer_pattern(monomer_pattern) monomer_glyphs.append(glyph) if len(monomer_glyphs) > 1: pattern.matches_key = lambda: str(pattern) agent_id = self._make_agent_id(pattern) complex_glyph = \ emaker.glyph(emaker.bbox(**self.complex_style), class_('complex'), id=agent_id) for glyph in monomer_glyphs: glyph.attrib['id'] = agent_id + glyph.attrib['id'] complex_glyph.append(glyph) return complex_glyph return monomer_glyphs[0]
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 identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment attribute identifier identifier lambda call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier line_continuation call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat attribute identifier identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier for_statement identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement subscript identifier integer
Add glyph and member glyphs for a PySB ComplexPattern.
def _imm_repr(self): return (type(self).__name__ + ('(' if _imm_is_persist(self) else '*(') + ', '.join([k + '=' + str(v) for (k,v) in six.iteritems(imm_params(self))]) + ')')
module function_definition identifier parameters identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator attribute call identifier argument_list identifier identifier parenthesized_expression conditional_expression string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier for_in_clause tuple_pattern identifier identifier call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end
The default representation function for an immutable object.
def _set_scatter_signature(self): self._scatter_signature = (self.thet0, self.thet, self.phi0, self.phi, self.alpha, self.beta, self.orient)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Mark the amplitude and scattering matrices as up to date.
def match(self, *args, **kwargs): return self._any_args or \ self._arguments_rule.validate(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement boolean_operator attribute identifier identifier line_continuation call attribute attribute identifier identifier identifier argument_list list_splat identifier dictionary_splat identifier
Check the if these args match this expectation.
def _query(self, filename): log.Info('Querying size of %s' % filename) from jottalib.JFS import JFSNotFoundError, JFSIncompleteFile remote_path = posixpath.join(self.folder.path, filename) try: remote_file = self.client.getObject(remote_path) except JFSNotFoundError: return {'size': -1} return { 'size': remote_file.size, }
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier import_from_statement dotted_name identifier identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block return_statement dictionary pair string string_start string_content string_end unary_operator integer return_statement dictionary pair string string_start string_content string_end attribute identifier identifier
Get size of filename
def _build_matrix(p, q, deriv): A = [([1 for _ in range(-p, q+1)])] for i in range(1, p + q + 1): A.append([j**i for j in range(-p, q+1)]) return np.array(A)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list parenthesized_expression list_comprehension integer for_in_clause identifier call identifier argument_list unary_operator identifier binary_operator identifier integer for_statement identifier call identifier argument_list integer binary_operator binary_operator identifier identifier integer block expression_statement call attribute identifier identifier argument_list list_comprehension binary_operator identifier identifier for_in_clause identifier call identifier argument_list unary_operator identifier binary_operator identifier integer return_statement call attribute identifier identifier argument_list identifier
Constructs the equation system matrix for the finite difference coefficients
def _setup_log_prefix(self, plugin_id=''): self._logger_console_fmtter.prefix = '%s: ' % plugin_id self._logger_console_fmtter.plugin_id = plugin_id self._logger_file_fmtter.prefix = '*' self._logger_file_fmtter.plugin_id = '%s: ' % plugin_id
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment attribute attribute identifier identifier identifier binary_operator string string_start string_content string_end identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier binary_operator string string_start string_content string_end identifier
Setup custom warning notification.
def encode_metadata(self): encoded_list = [] for key, value in iteritems(self.metadata): key_str = str(key) if re.search(r'^$|[\s,]+', key_str): msg = 'Upload-metadata key "{}" cannot be empty nor contain spaces or commas.' raise ValueError(msg.format(key_str)) value_bytes = b(value) encoded_list.append('{} {}'.format(key_str, b64encode(value_bytes).decode('ascii'))) return encoded_list
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end return_statement identifier
Return list of encoded metadata as defined by the Tus protocol.
def make(parser): parser.add_argument( 'mon', metavar='HOST', nargs='+', help='monitor host to pull keys from', ) parser.set_defaults( func=gatherkeys, )
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Gather authentication keys for provisioning new nodes.
def decrypt(secret, modN, d, blockSize): numBlocks = [modExp(blocks, d, modN) for blocks in secret] numList = blocks2numList(numBlocks, blockSize) return numList2string(numList)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement call identifier argument_list identifier
reverse function of encrypt
def stop_all(self): for alias, service in self._service_objects.items(): if service.is_alive: with expects.expect_no_raises( 'Failed to stop service "%s".' % alias): service.stop()
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement attribute identifier identifier block with_statement with_clause with_item call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list
Stops all active service instances.
def unmarshal_event(self, data: str, response_type): js = json.loads(data) js['raw_object'] = js['object'] if js['type'].lower() == 'error': return js if response_type is not None: js['object'] = self._api_client.deserialize( response=SimpleNamespace(data=json.dumps(js['raw_object'])), response_type=response_type ) if hasattr(js['object'], 'metadata'): self.resource_version = js['object'].metadata.resource_version elif (isinstance(js['object'], dict) and 'metadata' in js['object'] and 'resourceVersion' in js['object']['metadata']): self.resource_version = js['object']['metadata']['resourceVersion'] return js
module function_definition identifier parameters identifier typed_parameter identifier type identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end block return_statement identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier identifier if_statement call identifier argument_list subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier attribute attribute subscript identifier string string_start string_content string_end identifier identifier elif_clause parenthesized_expression boolean_operator boolean_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end comparison_operator string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end return_statement identifier
Return the K8s response `data` in JSON format.
def config_from_prefix(prefix): settings = {} if prefix.lower() in ('default', 'auto', ''): settings['zmq_prefix'] = '' settings['libzmq_extension'] = False settings['no_libzmq_extension'] = False elif prefix.lower() in ('bundled', 'extension'): settings['zmq_prefix'] = '' settings['libzmq_extension'] = True settings['no_libzmq_extension'] = False else: settings['zmq_prefix'] = prefix settings['libzmq_extension'] = False settings['no_libzmq_extension'] = True return settings
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary if_statement comparison_operator call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_end block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end false expression_statement assignment subscript identifier string string_start string_content string_end false elif_clause comparison_operator call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_end expression_statement assignment subscript identifier string string_start string_content string_end true expression_statement assignment subscript identifier string string_start string_content string_end false else_clause block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end false expression_statement assignment subscript identifier string string_start string_content string_end true return_statement identifier
Get config from zmq prefix
def _filter_queryset(self, perms, queryset): user = self.request.user if self.request else AnonymousUser() return get_objects_for_user(user, perms, queryset)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier conditional_expression attribute attribute identifier identifier identifier attribute identifier identifier call identifier argument_list return_statement call identifier argument_list identifier identifier identifier
Filter object objects by permissions of user in request.
def next_id(self): msgid = self._id_template.format(self._next_id) self._next_id += 1 return msgid
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement identifier
Return a unique message ID.
def on_response(self, msg: Dict[str, str]) -> None: response = msg.get('data', False) if response: task = self.__tasks.pop(msg.get('reqid'), False) if task and not task.cancelled() and not task.done(): task.set_result(msg.get('data'))
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end false if_statement boolean_operator boolean_operator identifier not_operator call attribute identifier identifier argument_list not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end
Run when get response from browser.
def isargument(self, node): try: node_id, _ = self.node_to_id(node) return (node_id in self.name_to_nodes and any([isinstance(n, ast.Name) and isinstance(n.ctx, ast.Param) for n in self.name_to_nodes[node_id]])) except UnboundableRValue: return False
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier call identifier argument_list list_comprehension boolean_operator call identifier argument_list identifier attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier for_in_clause identifier subscript attribute identifier identifier identifier except_clause identifier block return_statement false
checks whether node aliases to a parameter.
def _process_out_of_bounds(self, value, start, end): "Clips out of bounds values" if isinstance(value, np.datetime64): v = dt64_to_dt(value) if isinstance(start, (int, float)): start = convert_timestamp(start) if isinstance(end, (int, float)): end = convert_timestamp(end) s, e = start, end if isinstance(s, np.datetime64): s = dt64_to_dt(s) if isinstance(e, np.datetime64): e = dt64_to_dt(e) else: v, s, e = value, start, end if v < s: value = start elif v > e: value = end return value
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment pattern_list identifier identifier identifier expression_list identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier identifier return_statement identifier
Clips out of bounds values
def disconnect(self): _LOGGING.debug('Disconnecting from stream: %s', self.name) self.kill_thrd.set() self.thrd.join() _LOGGING.debug('Event stream thread for %s is stopped', self.name) self.kill_thrd.clear()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Disconnect from event stream.
def update_entitlement(owner, repo, identifier, name, token, show_tokens): client = get_entitlements_api() data = {} if name is not None: data["name"] = name if token is not None: data["token"] = token with catch_raise_api_exception(): data, _, headers = client.entitlements_partial_update_with_http_info( owner=owner, repo=repo, identifier=identifier, data=data, show_tokens=show_tokens, ) ratelimits.maybe_rate_limit(client, headers) return data.to_dict()
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement assignment subscript identifier 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 with_statement with_clause with_item call identifier argument_list block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list
Update an entitlement in a repository.
def _parse_resource_declarations(cls, declarations, resource_map): resources = {} for decl in declarations: name = decl.pop('name') typename = decl.pop('type') desc = decl.pop('description', None) autocreate = decl.pop('autocreate', False) args = decl res_type = resource_map.get(typename) if res_type is None: raise UnknownRecipeResourceType("Could not find shared resource type", type=typename, name=name) if hasattr(res_type, "ARG_SCHEMA"): try: args = res_type.ARG_SCHEMA.verify(args) except ValidationError as exc: raise RecipeFileInvalid("Recipe file resource declarttion has invalid parameters", resource=name, error_message=exc.msg, **exc.params) if name in resources: raise RecipeFileInvalid("Attempted to add two shared resources with the same name", name=name) res = ResourceDeclaration(name, resource_map.get(typename), args, autocreate, desc, typename) resources[name] = res return resources
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier dictionary_splat attribute identifier identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Parse out what resources are declared as shared for this recipe.
def find_genome_length(self): for sample in self.metadata: sample[self.analysistype].genome_length = sum(sample[self.analysistype].contig_lengths)
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement assignment attribute subscript identifier attribute identifier identifier identifier call identifier argument_list attribute subscript identifier attribute identifier identifier identifier
Determine the total length of all the contigs for each strain