text
stringlengths
89
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
630
def new_page(self, page_number, new_chapter, **kwargs): """Called by :meth:`render` with the :class:`Chain`s that need more :class:`Container`s. This method should create a new :class:`Page` which contains a container associated with `chain`.""" right_template = self.document.get_page_te...
[ "def", "new_page", "(", "self", ",", "page_number", ",", "new_chapter", ",", "*", "*", "kwargs", ")", ":", "right_template", "=", "self", ".", "document", ".", "get_page_template", "(", "self", ",", "'right'", ")", "left_template", "=", "self", ".", "docum...
66.888889
21.222222
def _load_yml_config(self, config_file): """ loads a yaml str, creates a few constructs for pyaml, serializes and normalized the config data. Then assigns the config data to self._data. :param config_file: A :string: loaded from a yaml file. """ if not isinstance(config_file, s...
[ "def", "_load_yml_config", "(", "self", ",", "config_file", ")", ":", "if", "not", "isinstance", "(", "config_file", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'config_file must be a str.'", ")", "try", ":", "def", "construct_yaml_int...
37.609195
21.701149
def _get_default_annual_spacing(nyears): """ Returns a default spacing between consecutive ticks for annual data. """ if nyears < 11: (min_spacing, maj_spacing) = (1, 1) elif nyears < 20: (min_spacing, maj_spacing) = (1, 2) elif nyears < 50: (min_spacing, maj_spacing) = (...
[ "def", "_get_default_annual_spacing", "(", "nyears", ")", ":", "if", "nyears", "<", "11", ":", "(", "min_spacing", ",", "maj_spacing", ")", "=", "(", "1", ",", "1", ")", "elif", "nyears", "<", "20", ":", "(", "min_spacing", ",", "maj_spacing", ")", "="...
33
11.5
def get_resource_allocation(self): """Get the :py:class:`ResourceAllocation` element tance. Returns: ResourceAllocation: Resource allocation used to access information about the resource where this PE is running. .. versionadded:: 1.9 """ if hasattr(self, 'resourceA...
[ "def", "get_resource_allocation", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'resourceAllocation'", ")", ":", "return", "ResourceAllocation", "(", "self", ".", "rest_client", ".", "make_request", "(", "self", ".", "resourceAllocation", ")", ",", ...
43.5
28.2
def startElement(self, name, attrs): """Callback run at the start of each XML element""" self._contextStack.append(self._context) self._contentList = [] if name in self._statusDict: self._itemTag, itemType = self._statusDict[name] self._progress.startItem(itemTy...
[ "def", "startElement", "(", "self", ",", "name", ",", "attrs", ")", ":", "self", ".", "_contextStack", ".", "append", "(", "self", ".", "_context", ")", "self", ".", "_contentList", "=", "[", "]", "if", "name", "in", "self", ".", "_statusDict", ":", ...
39.314286
11.171429
def send_email(name, ctx_dict, send_to=None, subject=u'Subject', **kwargs): """ Shortcut function for EmailFromTemplate class @return: None """ eft = EmailFromTemplate(name=name) eft.subject = subject eft.context = ctx_dict eft.get_object() eft.render_message() eft.send_email(s...
[ "def", "send_email", "(", "name", ",", "ctx_dict", ",", "send_to", "=", "None", ",", "subject", "=", "u'Subject'", ",", "*", "*", "kwargs", ")", ":", "eft", "=", "EmailFromTemplate", "(", "name", "=", "name", ")", "eft", ".", "subject", "=", "subject",...
25.615385
16.846154
def request_cached_property(func): """Make the given method a per-request cached property. This caches the value on the request context rather than on the object itself, preventing problems if the object gets reused across multiple requests. """ @property @functools.wraps(func) def wrap...
[ "def", "request_cached_property", "(", "func", ")", ":", "@", "property", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "self", ")", ":", "cached_value", "=", "context", ".", "get_for_view", "(", "self", ",", "func", ".", "__na...
29.4
21.8
def get_chunk(self): """Return complete chunks or None if EOF reached""" while not self._eof_reached: read = self.input_stream.read(self.chunk_size - len(self._partial_chunk)) if len(read) == 0: self._eof_reached = True self._partial_chunk += read ...
[ "def", "get_chunk", "(", "self", ")", ":", "while", "not", "self", ".", "_eof_reached", ":", "read", "=", "self", ".", "input_stream", ".", "read", "(", "self", ".", "chunk_size", "-", "len", "(", "self", ".", "_partial_chunk", ")", ")", "if", "len", ...
45.454545
12.272727
def build(cls, name_dict, use_printable=False): """ Creates a Name object from a dict of unicode string keys and values. The keys should be from NameType._map, or a dotted-integer OID unicode string. :param name_dict: A dict of name information, e.g. {"common_name": ...
[ "def", "build", "(", "cls", ",", "name_dict", ",", "use_printable", "=", "False", ")", ":", "rdns", "=", "[", "]", "if", "not", "use_printable", ":", "encoding_name", "=", "'utf8_string'", "encoding_class", "=", "UTF8String", "else", ":", "encoding_name", "=...
35.677966
19.983051
def logToConsole(level=logging.INFO): """ Create a log handler that logs to the console. """ logger = logging.getLogger() logger.setLevel(level) formatter = logging.Formatter( '%(asctime)s %(name)s %(levelname)s %(message)s') handler = logging.StreamHandler() handler.setFormatter...
[ "def", "logToConsole", "(", "level", "=", "logging", ".", "INFO", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "logger", ".", "setLevel", "(", "level", ")", "formatter", "=", "logging", ".", "Formatter", "(", "'%(asctime)s %(name)s %(level...
32.642857
7.642857
def from_tfs(klass, tfs_project, labor_hours=True): """ Creates CodeGovProject object from TFS/VSTS/AzureDevOps Instance """ project = klass() project_web_url = '' # -- REQUIRED FIELDS -- project['name'] = tfs_project.projectInfo.name if 'web' in tfs_pro...
[ "def", "from_tfs", "(", "klass", ",", "tfs_project", ",", "labor_hours", "=", "True", ")", ":", "project", "=", "klass", "(", ")", "project_web_url", "=", "''", "# -- REQUIRED FIELDS --", "project", "[", "'name'", "]", "=", "tfs_project", ".", "projectInfo", ...
37.207547
28.981132
def _escape_argspec(obj, iterable, escape): """Helper for various string-wrapped functions.""" for key, value in iterable: if hasattr(value, '__html__') or isinstance(value, string_types): obj[key] = escape(value) return obj
[ "def", "_escape_argspec", "(", "obj", ",", "iterable", ",", "escape", ")", ":", "for", "key", ",", "value", "in", "iterable", ":", "if", "hasattr", "(", "value", ",", "'__html__'", ")", "or", "isinstance", "(", "value", ",", "string_types", ")", ":", "...
41.833333
12.5
def processEscalatedException(self, ex): """ Process an exception escalated from a Replica """ if isinstance(ex, SuspiciousNode): self.reportSuspiciousNodeEx(ex) else: raise RuntimeError("unhandled replica-escalated exception") from ex
[ "def", "processEscalatedException", "(", "self", ",", "ex", ")", ":", "if", "isinstance", "(", "ex", ",", "SuspiciousNode", ")", ":", "self", ".", "reportSuspiciousNodeEx", "(", "ex", ")", "else", ":", "raise", "RuntimeError", "(", "\"unhandled replica-escalated...
36.5
10.5
def _req(self, url, method='GET', **kw): '''Make request and convert JSON response to python objects''' send = requests.post if method == 'POST' else requests.get try: r = send( url, headers=self._token_header(), timeout=self.settings['...
[ "def", "_req", "(", "self", ",", "url", ",", "method", "=", "'GET'", ",", "*", "*", "kw", ")", ":", "send", "=", "requests", ".", "post", "if", "method", "==", "'POST'", "else", "requests", ".", "get", "try", ":", "r", "=", "send", "(", "url", ...
41.444444
19.666667
def add_directories(names): """Git/Mercurial/zip files omit directories, let's add them back.""" res = list(names) seen = set(names) for name in names: while True: name = os.path.dirname(name) if not name or name in seen: break res.append(name)...
[ "def", "add_directories", "(", "names", ")", ":", "res", "=", "list", "(", "names", ")", "seen", "=", "set", "(", "names", ")", "for", "name", "in", "names", ":", "while", "True", ":", "name", "=", "os", ".", "path", ".", "dirname", "(", "name", ...
29.916667
12.75
def isxmap(xmethod, opt): """Return ``isxmap`` argument for ``.IterStatsConfig`` initialiser. """ if xmethod == 'admm': isx = {'XPrRsdl': 'PrimalRsdl', 'XDlRsdl': 'DualRsdl', 'XRho': 'Rho'} else: isx = {'X_F_Btrack': 'F_Btrack', 'X_Q_Btrack': 'Q_Btrack', 'X...
[ "def", "isxmap", "(", "xmethod", ",", "opt", ")", ":", "if", "xmethod", "==", "'admm'", ":", "isx", "=", "{", "'XPrRsdl'", ":", "'PrimalRsdl'", ",", "'XDlRsdl'", ":", "'DualRsdl'", ",", "'XRho'", ":", "'Rho'", "}", "else", ":", "isx", "=", "{", "'X_F...
33.769231
17.769231
def generate_apiary_doc(task_router): """Generate apiary documentation. Create a Apiary generator and add application packages to it. :param task_router: task router, injected :type task_router: TaskRouter :return: apiary generator :rtype: ApiaryDoc """ generator = ApiaryDoc() for...
[ "def", "generate_apiary_doc", "(", "task_router", ")", ":", "generator", "=", "ApiaryDoc", "(", ")", "for", "m", "in", "task_router", ".", "get_task_packages", "(", ")", "+", "get_method_packages", "(", ")", ":", "m", "=", "importlib", ".", "import_module", ...
26.941176
17.882353
def _mmult(self, a, b): """ Returns the 3x3 matrix multiplication of A and B. Note that scale(), translate(), rotate() work with premultiplication, e.g. the matrix A followed by B = BA and not AB. """ # No need to optimize (C version is just as fast). return...
[ "def", "_mmult", "(", "self", ",", "a", ",", "b", ")", ":", "# No need to optimize (C version is just as fast).\r", "return", "[", "a", "[", "0", "]", "*", "b", "[", "0", "]", "+", "a", "[", "1", "]", "*", "b", "[", "3", "]", ",", "a", "[", "0", ...
36.352941
14.352941
def _init_actions(self, create_standard_actions): """ Init context menu action """ menu_advanced = QtWidgets.QMenu(_('Advanced')) self.add_menu(menu_advanced) self._sub_menus = { 'Advanced': menu_advanced } if create_standard_actions: # Undo ...
[ "def", "_init_actions", "(", "self", ",", "create_standard_actions", ")", ":", "menu_advanced", "=", "QtWidgets", ".", "QMenu", "(", "_", "(", "'Advanced'", ")", ")", "self", ".", "add_menu", "(", "menu_advanced", ")", "self", ".", "_sub_menus", "=", "{", ...
43.537736
11.424528
def sha_hash(self) -> str: """ Return uppercase hex sha256 hash from signed raw document :return: """ return hashlib.sha256(self.signed_raw().encode("ascii")).hexdigest().upper()
[ "def", "sha_hash", "(", "self", ")", "->", "str", ":", "return", "hashlib", ".", "sha256", "(", "self", ".", "signed_raw", "(", ")", ".", "encode", "(", "\"ascii\"", ")", ")", ".", "hexdigest", "(", ")", ".", "upper", "(", ")" ]
30.428571
21
def create_output_directories(self): """Create output directories for thumbnails and original images.""" check_or_create_dir(self.dst_path) if self.medias: check_or_create_dir(join(self.dst_path, self.settings['thumb_dir'])) if self.medi...
[ "def", "create_output_directories", "(", "self", ")", ":", "check_or_create_dir", "(", "self", ".", "dst_path", ")", "if", "self", ".", "medias", ":", "check_or_create_dir", "(", "join", "(", "self", ".", "dst_path", ",", "self", ".", "settings", "[", "'thum...
42.545455
17.727273
def _get_pull_requests(self): """ Gets all pull requests from the repo since we can't do a filtered date merged search """ for pull in self.repo.pull_requests( state="closed", base=self.github_info["master_branch"], direction="asc" ): if self._include_pull_request...
[ "def", "_get_pull_requests", "(", "self", ")", ":", "for", "pull", "in", "self", ".", "repo", ".", "pull_requests", "(", "state", "=", "\"closed\"", ",", "base", "=", "self", ".", "github_info", "[", "\"master_branch\"", "]", ",", "direction", "=", "\"asc\...
43.375
13.75
def deserialize(stream_or_string, **options): ''' Deserialize any string or stream like object into a Python data structure. :param stream_or_string: stream or string to deserialize. :param options: options given to lower configparser module. ''' if six.PY3: cp = configparser.ConfigPar...
[ "def", "deserialize", "(", "stream_or_string", ",", "*", "*", "options", ")", ":", "if", "six", ".", "PY3", ":", "cp", "=", "configparser", ".", "ConfigParser", "(", "*", "*", "options", ")", "else", ":", "cp", "=", "configparser", ".", "SafeConfigParser...
33.617647
20.735294
def config(self): """Implements Munin Plugin Graph Configuration. Prints out configuration for graphs. Use as is. Not required to be overwritten in child classes. The plugin will work correctly as long as the Munin Graph objects have been populated. """ ...
[ "def", "config", "(", "self", ")", ":", "for", "parent_name", "in", "self", ".", "_graphNames", ":", "graph", "=", "self", ".", "_graphDict", "[", "parent_name", "]", "if", "self", ".", "isMultigraph", ":", "print", "\"multigraph %s\"", "%", "self", ".", ...
44.230769
21.923077
def set_stdev(self, col, row, stdev): """ Sets the standard deviation at this location (if valid location). :param col: the 0-based column index :type col: int :param row: the 0-based row index :type row: int :param stdev: the standard deviation to set :t...
[ "def", "set_stdev", "(", "self", ",", "col", ",", "row", ",", "stdev", ")", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"setStdDev\"", ",", "\"(IID)V\"", ",", "col", ",", "row", ",", "stdev", ")" ]
34.583333
14.916667
def create_for_block( cls, i=None, name=None, cname=None, version=None, **kwargs): """ return a new datacol with the block i """ if cname is None: cname = name or 'values_block_{idx}'.format(idx=i) if name is None: name = cname # prior to 0.10.1, we ...
[ "def", "create_for_block", "(", "cls", ",", "i", "=", "None", ",", "name", "=", "None", ",", "cname", "=", "None", ",", "version", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "cname", "is", "None", ":", "cname", "=", "name", "or", "'val...
35.45
23.6
def vmomentsurfacemass(self,*args,**kwargs): """ NAME: vmomentsurfacemass PURPOSE: calculate the an arbitrary moment of the velocity distribution at R times the surfacmass INPUT: R - radius at which to calculate the moment (in ...
[ "def", "vmomentsurfacemass", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "use_physical", "=", "kwargs", ".", "pop", "(", "'use_physical'", ",", "True", ")", "ro", "=", "kwargs", ".", "pop", "(", "'ro'", ",", "None", ")", "if", ...
29.3
24.533333
def validate_card_issue_modes(issue_mode: int, cards: list) -> list: """validate cards against deck_issue modes""" supported_mask = 63 # sum of all issue_mode values if not bool(issue_mode & supported_mask): return [] # return empty list for i in [1 << x for x in range(len(IssueMode))]: ...
[ "def", "validate_card_issue_modes", "(", "issue_mode", ":", "int", ",", "cards", ":", "list", ")", "->", "list", ":", "supported_mask", "=", "63", "# sum of all issue_mode values", "if", "not", "bool", "(", "issue_mode", "&", "supported_mask", ")", ":", "return"...
28.28
18.72
def compare_table_cols(a, b): """ Return False if the two tables a and b have the same columns (ignoring order) according to LIGO LW name conventions, return True otherwise. """ return cmp(sorted((col.Name, col.Type) for col in a.getElementsByTagName(ligolw.Column.tagName)), sorted((col.Name, col.Type) for col in...
[ "def", "compare_table_cols", "(", "a", ",", "b", ")", ":", "return", "cmp", "(", "sorted", "(", "(", "col", ".", "Name", ",", "col", ".", "Type", ")", "for", "col", "in", "a", ".", "getElementsByTagName", "(", "ligolw", ".", "Column", ".", "tagName",...
51.714286
33.428571
def str_transmission_rate(self): """Returns a tuple of human readable transmission rates in bytes.""" upstream, downstream = self.transmission_rate return ( fritztools.format_num(upstream), fritztools.format_num(downstream) )
[ "def", "str_transmission_rate", "(", "self", ")", ":", "upstream", ",", "downstream", "=", "self", ".", "transmission_rate", "return", "(", "fritztools", ".", "format_num", "(", "upstream", ")", ",", "fritztools", ".", "format_num", "(", "downstream", ")", ")"...
39.285714
12.142857
def mark(self, lineno, count=1): """Mark a given source line as executed count times. Multiple calls to mark for the same lineno add up. """ self.sourcelines[lineno] = self.sourcelines.get(lineno, 0) + count
[ "def", "mark", "(", "self", ",", "lineno", ",", "count", "=", "1", ")", ":", "self", ".", "sourcelines", "[", "lineno", "]", "=", "self", ".", "sourcelines", ".", "get", "(", "lineno", ",", "0", ")", "+", "count" ]
39.166667
16.666667
def withdraw(self, **params): """Submit a withdraw request. https://www.binance.com/restapipub.html Assumptions: - You must have Withdraw permissions enabled on your API key - You must have withdrawn to the address specified through the website and approved the transaction via...
[ "def", "withdraw", "(", "self", ",", "*", "*", "params", ")", ":", "# force a name for the withdrawal if one not set", "if", "'asset'", "in", "params", "and", "'name'", "not", "in", "params", ":", "params", "[", "'name'", "]", "=", "params", "[", "'asset'", ...
34.44186
24.162791
def add_archive(self, src_file, remove_final=False): """ Adds the contents of another tarfile to the build. It will be repackaged during context generation, and added to the root level of the file system. Therefore, it is not required that tar (or compression utilities) is present in the...
[ "def", "add_archive", "(", "self", ",", "src_file", ",", "remove_final", "=", "False", ")", ":", "with", "tarfile", ".", "open", "(", "src_file", ",", "'r'", ")", "as", "tf", ":", "member_names", "=", "[", "member", ".", "name", "for", "member", "in", ...
54.2
25
def __make_another_index(self, list_of_entries, url=False, hs_admin=False): ''' Find an index not yet used in the handle record and not reserved for any (other) special type. :param: list_of_entries: List of all entries to find which indices are used already. :pa...
[ "def", "__make_another_index", "(", "self", ",", "list_of_entries", ",", "url", "=", "False", ",", "hs_admin", "=", "False", ")", ":", "start", "=", "2", "# reserved indices:", "reserved_for_url", "=", "set", "(", "[", "1", "]", ")", "reserved_for_admin", "=...
36.4
22.1
def parseFASTACommandLineOptions(args): """ Examine parsed command-line options and return a Reads instance. @param args: An argparse namespace, as returned by the argparse C{parse_args} function. @return: A C{Reads} subclass instance, depending on the type of FASTA file given. """ ...
[ "def", "parseFASTACommandLineOptions", "(", "args", ")", ":", "# Set default FASTA type.", "if", "not", "(", "args", ".", "fasta", "or", "args", ".", "fastq", "or", "args", ".", "fasta_ss", ")", ":", "args", ".", "fasta", "=", "True", "readClass", "=", "re...
34.791667
18.791667
def check_nodes_count(baremetal_client, stack, parameters, defaults): """Check if there are enough available nodes for creating/scaling stack""" count = 0 if stack: for param in defaults: try: current = int(stack.parameters[param]) except KeyError: ...
[ "def", "check_nodes_count", "(", "baremetal_client", ",", "stack", ",", "parameters", ",", "defaults", ")", ":", "count", "=", "0", "if", "stack", ":", "for", "param", "in", "defaults", ":", "try", ":", "current", "=", "int", "(", "stack", ".", "paramete...
39.043478
19.217391
def _add_model(self, model_list_or_dict, core_element, model_class, model_key=None, load_meta_data=True): """Adds one model for a given core element. The method will add a model for a given core object and checks if there is a corresponding model object in the future expected model list. The me...
[ "def", "_add_model", "(", "self", ",", "model_list_or_dict", ",", "core_element", ",", "model_class", ",", "model_key", "=", "None", ",", "load_meta_data", "=", "True", ")", ":", "found_model", "=", "self", ".", "_get_future_expected_model", "(", "core_element", ...
53.310345
36.62069
def get_storage_policies(profile_manager, policy_names=None, get_all_policies=False): ''' Returns a list of the storage policies, filtered by name. profile_manager Reference to the profile manager. policy_names List of policy names to filter by. Default...
[ "def", "get_storage_policies", "(", "profile_manager", ",", "policy_names", "=", "None", ",", "get_all_policies", "=", "False", ")", ":", "res_type", "=", "pbm", ".", "profile", ".", "ResourceType", "(", "resourceType", "=", "pbm", ".", "profile", ".", "Resour...
35.975
17.925
def regex_match_any(self, line, codes=None): """Match any regex.""" for selector in self.regex_selectors: for match in selector.regex.finditer(line): if codes and match.lastindex: # Currently the group name must be 'codes' try: ...
[ "def", "regex_match_any", "(", "self", ",", "line", ",", "codes", "=", "None", ")", ":", "for", "selector", "in", "self", ".", "regex_selectors", ":", "for", "match", "in", "selector", ".", "regex", ".", "finditer", "(", "line", ")", ":", "if", "codes"...
35.6
15.7
def multidict_to_dict(d): """ Turns a werkzeug.MultiDict or django.MultiValueDict into a dict with list values :param d: a MultiDict or MultiValueDict instance :return: a dict instance """ return dict((k, v[0] if len(v) == 1 else v) for k, v in iterlists(d))
[ "def", "multidict_to_dict", "(", "d", ")", ":", "return", "dict", "(", "(", "k", ",", "v", "[", "0", "]", "if", "len", "(", "v", ")", "==", "1", "else", "v", ")", "for", "k", ",", "v", "in", "iterlists", "(", "d", ")", ")" ]
34.875
16.125
def quadrant(xcoord, ycoord): """ Find the quadrant a pair of coordinates are located in :type xcoord: integer :param xcoord: The x coordinate to find the quadrant for :type ycoord: integer :param ycoord: The y coordinate to find the quadrant for """ xneg = bool(xcoord < 0) yneg =...
[ "def", "quadrant", "(", "xcoord", ",", "ycoord", ")", ":", "xneg", "=", "bool", "(", "xcoord", "<", "0", ")", "yneg", "=", "bool", "(", "ycoord", "<", "0", ")", "if", "xneg", "is", "True", ":", "if", "yneg", "is", "False", ":", "return", "2", "...
22.75
19.75
def add_moving_summary(*args, **kwargs): """ Summarize the moving average for scalar tensors. This function is a no-op if not calling from main training tower. Args: args: scalar tensors to summarize decay (float): the decay rate. Defaults to 0.95. collection (str or None): the ...
[ "def", "add_moving_summary", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "decay", "=", "kwargs", ".", "pop", "(", "'decay'", ",", "0.95", ")", "coll", "=", "kwargs", ".", "pop", "(", "'collection'", ",", "MOVING_SUMMARY_OPS_KEY", ")", "summ_coll...
42.178082
21.30137
def _get_index(n_items, item_size, n): """Prepare an index attribute for GPU uploading.""" index = np.arange(n_items) index = np.repeat(index, item_size) index = index.astype(np.float64) assert index.shape == (n,) return index
[ "def", "_get_index", "(", "n_items", ",", "item_size", ",", "n", ")", ":", "index", "=", "np", ".", "arange", "(", "n_items", ")", "index", "=", "np", ".", "repeat", "(", "index", ",", "item_size", ")", "index", "=", "index", ".", "astype", "(", "n...
34.857143
7.285714
def as_wfn(self): """ Returns the CPE Name as WFN string of version 2.3. Only shows the first seven components. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ wfn = [] wfn.append(CPE2_3_WFN.CPE_PRE...
[ "def", "as_wfn", "(", "self", ")", ":", "wfn", "=", "[", "]", "wfn", ".", "append", "(", "CPE2_3_WFN", ".", "CPE_PREFIX", ")", "for", "ck", "in", "CPEComponent", ".", "CPE_COMP_KEYS", ":", "lc", "=", "self", ".", "_get_attribute_components", "(", "ck", ...
26.431818
18.431818
def data_transforms_cifar10(args): """ data_transforms for cifar10 dataset """ cifar_mean = [0.49139968, 0.48215827, 0.44653124] cifar_std = [0.24703233, 0.24348505, 0.26158768] train_transform = transforms.Compose( [ transforms.RandomCrop(32, padding=4), transforms...
[ "def", "data_transforms_cifar10", "(", "args", ")", ":", "cifar_mean", "=", "[", "0.49139968", ",", "0.48215827", ",", "0.44653124", "]", "cifar_std", "=", "[", "0.24703233", ",", "0.24348505", ",", "0.26158768", "]", "train_transform", "=", "transforms", ".", ...
31.409091
18.681818
def moignard15() -> AnnData: """Hematopoiesis in early mouse embryos [Moignard15]_. Returns ------- Annotated data matrix. """ filename = settings.datasetdir / 'moignard15/nbt.3154-S3.xlsx' backup_url = 'http://www.nature.com/nbt/journal/v33/n3/extref/nbt.3154-S3.xlsx' adata = sc.read(f...
[ "def", "moignard15", "(", ")", "->", "AnnData", ":", "filename", "=", "settings", ".", "datasetdir", "/", "'moignard15/nbt.3154-S3.xlsx'", "backup_url", "=", "'http://www.nature.com/nbt/journal/v33/n3/extref/nbt.3154-S3.xlsx'", "adata", "=", "sc", ".", "read", "(", "fil...
49.961538
23.153846
def get_features(self, mapobject_type_name): '''Gets features for a given object type. Parameters ---------- mapobject_type_name: str type of the segmented objects Returns ------- List[Dict[str, str]] information about each feature ...
[ "def", "get_features", "(", "self", ",", "mapobject_type_name", ")", ":", "logger", ".", "info", "(", "'get features of experiment \"%s\", object type \"%s\"'", ",", "self", ".", "experiment_name", ",", "mapobject_type_name", ")", "mapobject_type_id", "=", "self", ".", ...
31.625
19.5625
def _process_download_descriptor(self, dd): # type: (Downloader, blobxfer.models.download.Descriptor) -> None """Process download descriptor :param Downloader self: this :param blobxfer.models.download.Descriptor dd: download descriptor """ # update progress bar s...
[ "def", "_process_download_descriptor", "(", "self", ",", "dd", ")", ":", "# type: (Downloader, blobxfer.models.download.Descriptor) -> None", "# update progress bar", "self", ".", "_update_progress_bar", "(", ")", "# get download offsets", "offsets", ",", "resume_bytes", "=", ...
43.644737
12.052632
def simplified_rayliegh_vel(self): """Simplified Rayliegh velocity of the site. This follows the simplifications proposed by Urzua et al. (2017) Returns ------- rayleigh_vel : float Equivalent shear-wave velocity. """ # FIXME: What if last layer has ...
[ "def", "simplified_rayliegh_vel", "(", "self", ")", ":", "# FIXME: What if last layer has no thickness?", "thicks", "=", "np", ".", "array", "(", "[", "l", ".", "thickness", "for", "l", "in", "self", "]", ")", "depths_mid", "=", "np", ".", "array", "(", "[",...
39.032258
19.516129
def base_image_inspect(self): """ inspect base image :return: dict """ if self._base_image_inspect is None: if self.base_from_scratch: self._base_image_inspect = {} elif self.parents_pulled or self.custom_base_image: try: ...
[ "def", "base_image_inspect", "(", "self", ")", ":", "if", "self", ".", "_base_image_inspect", "is", "None", ":", "if", "self", ".", "base_from_scratch", ":", "self", ".", "_base_image_inspect", "=", "{", "}", "elif", "self", ".", "parents_pulled", "or", "sel...
43.8
25.066667
def _create_contextualvals_obj_from_context(cls, context): """ Gathers all of the 'contextual' data needed to render a menu instance and returns it in a structure that can be conveniently referenced throughout the process of preparing the menu and menu items and for rendering. ...
[ "def", "_create_contextualvals_obj_from_context", "(", "cls", ",", "context", ")", ":", "context_processor_vals", "=", "context", ".", "get", "(", "'wagtailmenus_vals'", ",", "{", "}", ")", "return", "ContextualVals", "(", "context", ",", "context", "[", "'request...
46.894737
19.210526
def virtual_network_present(name, address_prefixes, resource_group, dns_servers=None, tags=None, connection_auth=None, **kwargs): ''' .. versionadded:: 2019.2.0 Ensure a virtual network exists. :param name: Name of the virtual network. :param resource_group: ...
[ "def", "virtual_network_present", "(", "name", ",", "address_prefixes", ",", "resource_group", ",", "dns_servers", "=", "None", ",", "tags", "=", "None", ",", "connection_auth", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":"...
33.07483
24.176871
def add_to_playlist(self, items, playlist='video'): '''Adds the provided list of items to the specified playlist. Available playlists include *video* and *music*. ''' playlists = {'music': 0, 'video': 1} assert playlist in playlists.keys(), ('Playlist "%s" is invalid.' % ...
[ "def", "add_to_playlist", "(", "self", ",", "items", ",", "playlist", "=", "'video'", ")", ":", "playlists", "=", "{", "'music'", ":", "0", ",", "'video'", ":", "1", "}", "assert", "playlist", "in", "playlists", ".", "keys", "(", ")", ",", "(", "'Pla...
48.318182
20.318182
def set_pre_processing_parameters(self, image_input_names = [], is_bgr = False, red_bias = 0.0, green_bias = 0.0, blue_bias = 0.0, gray_bias = 0.0, image_scale = 1.0): """Add pre-processing parameters to the neural network object Parameters ---------- image_input_names: [str...
[ "def", "set_pre_processing_parameters", "(", "self", ",", "image_input_names", "=", "[", "]", ",", "is_bgr", "=", "False", ",", "red_bias", "=", "0.0", ",", "green_bias", "=", "0.0", ",", "blue_bias", "=", "0.0", ",", "gray_bias", "=", "0.0", ",", "image_s...
49.155844
27.727273
def get_assignable_bin_ids(self, bin_id): """Gets a list of bins including and under the given bin node in which any resource can be assigned. arg: bin_id (osid.id.Id): the ``Id`` of the ``Bin`` return: (osid.id.IdList) - list of assignable bin ``Ids`` raise: NullArgument - ``bin_id...
[ "def", "get_assignable_bin_ids", "(", "self", ",", "bin_id", ")", ":", "# Implemented from template for", "# osid.resource.ResourceBinAssignmentSession.get_assignable_bin_ids", "# This will likely be overridden by an authorization adapter", "mgr", "=", "self", ".", "_get_provider_manag...
46.85
17.6
def to_file(self, file_name=None): """Saves a DataFrame with all the needed info about the experiment""" file_name = self._check_file_name(file_name) pages = self.pages top_level_dict = { 'info_df': pages, 'metadata': self._prm_packer() } jason_...
[ "def", "to_file", "(", "self", ",", "file_name", "=", "None", ")", ":", "file_name", "=", "self", ".", "_check_file_name", "(", "file_name", ")", "pages", "=", "self", ".", "pages", "top_level_dict", "=", "{", "'info_df'", ":", "pages", ",", "'metadata'", ...
26.28
18.72
def process_reply(self, reply, status, description): """ Process a web service operation SOAP reply. Depending on how the ``retxml`` option is set, may return the SOAP reply XML or process it and return the Python object representing the returned value. @param reply: Th...
[ "def", "process_reply", "(", "self", ",", "reply", ",", "status", ",", "description", ")", ":", "if", "status", "is", "None", ":", "status", "=", "httplib", ".", "OK", "debug_message", "=", "\"Reply HTTP status - %d\"", "%", "(", "status", ",", ")", "if", ...
42.350649
19.935065
def get_plugin_modules(plugins): """ Get plugin modules from input strings :param tuple plugins: a tuple of plugin names in str """ if not plugins: raise MissingPluginNames("input plugin names are required") modules = [] for plugin in plugins: short_name = PLUGIN_MAPPING.ge...
[ "def", "get_plugin_modules", "(", "plugins", ")", ":", "if", "not", "plugins", ":", "raise", "MissingPluginNames", "(", "\"input plugin names are required\"", ")", "modules", "=", "[", "]", "for", "plugin", "in", "plugins", ":", "short_name", "=", "PLUGIN_MAPPING"...
30.0625
19.4375
def get_traceback_html(self, **kwargs): "Return HTML version of debug 500 HTTP error page." t = Template(TECHNICAL_500_TEMPLATE) c = self.get_traceback_data() c['kwargs'] = kwargs return t.render(Context(c))
[ "def", "get_traceback_html", "(", "self", ",", "*", "*", "kwargs", ")", ":", "t", "=", "Template", "(", "TECHNICAL_500_TEMPLATE", ")", "c", "=", "self", ".", "get_traceback_data", "(", ")", "c", "[", "'kwargs'", "]", "=", "kwargs", "return", "t", ".", ...
40.333333
7.333333
def _unflatten_beam_dim(tensor, batch_size, beam_size): """Reshapes first dimension back to [batch_size, beam_size]. Args: tensor: Tensor to reshape of shape [batch_size*beam_size, ...] batch_size: Tensor, original batch size. beam_size: int, original beam size. Returns: Reshaped tensor of shape...
[ "def", "_unflatten_beam_dim", "(", "tensor", ",", "batch_size", ",", "beam_size", ")", ":", "shape", "=", "_shape_list", "(", "tensor", ")", "new_shape", "=", "[", "batch_size", ",", "beam_size", "]", "+", "shape", "[", "1", ":", "]", "return", "tf", "."...
32.928571
16.285714
def template_render(template, context=None, request=None): """ Passing Context or RequestContext to Template.render is deprecated in 1.9+, see https://github.com/django/django/pull/3883 and https://github.com/django/django/blob/1.9rc1/django/template/backends/django.py#L82-L84 :param template: Temp...
[ "def", "template_render", "(", "template", ",", "context", "=", "None", ",", "request", "=", "None", ")", ":", "if", "django", ".", "VERSION", "<", "(", "1", ",", "8", ")", "or", "isinstance", "(", "template", ",", "Template", ")", ":", "if", "reques...
40.4
18.1
def read(self): """ Reads the todo.txt file and returns a list of todo items. """ todos = [] try: todofile = codecs.open(self.path, 'r', encoding="utf-8") todos = todofile.readlines() todofile.close() except IOError: pass return to...
[ "def", "read", "(", "self", ")", ":", "todos", "=", "[", "]", "try", ":", "todofile", "=", "codecs", ".", "open", "(", "self", ".", "path", ",", "'r'", ",", "encoding", "=", "\"utf-8\"", ")", "todos", "=", "todofile", ".", "readlines", "(", ")", ...
28.454545
19.636364
def get_subdomain_ops_at_txid(txid, proxy=None, hostport=None): """ Get the list of subdomain operations added by a txid Returns the list of operations ([{...}]) on success Returns {'error': ...} on failure """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: prox...
[ "def", "get_subdomain_ops_at_txid", "(", "txid", ",", "proxy", "=", "None", ",", "hostport", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect_hostport", "(", ...
32.971831
23.985915
def md_report(self, file_path): """Generate and save MD report""" self.logger.debug('Generating MD report') report = self.zap.core.mdreport() self._write_report(report, file_path)
[ "def", "md_report", "(", "self", ",", "file_path", ")", ":", "self", ".", "logger", ".", "debug", "(", "'Generating MD report'", ")", "report", "=", "self", ".", "zap", ".", "core", ".", "mdreport", "(", ")", "self", ".", "_write_report", "(", "report", ...
41.4
4.8
def sys_access(self, buf, mode): """ Checks real user's permissions for a file :rtype: int :param buf: a buffer containing the pathname to the file to check its permissions. :param mode: the access permissions to check. :return: - C{0} if the calling process...
[ "def", "sys_access", "(", "self", ",", "buf", ",", "mode", ")", ":", "filename", "=", "b''", "for", "i", "in", "range", "(", "0", ",", "255", ")", ":", "c", "=", "Operators", ".", "CHR", "(", "self", ".", "current", ".", "read_int", "(", "buf", ...
33.318182
20.954545
def log_uuid(self, uuid): """Logs the object with the specified `uuid` to `self.uuids` if possible. Args: uuid (str): string value of :meth:`uuid.uuid4` value for the object. """ #We only need to try and describe an object once; if it is already in ...
[ "def", "log_uuid", "(", "self", ",", "uuid", ")", ":", "#We only need to try and describe an object once; if it is already in", "#our database, then just move along.", "if", "uuid", "not", "in", "self", ".", "uuids", "and", "uuid", "in", "uuids", ":", "self", ".", "uu...
38
18.5
def get_terminal_size(default_rows=25, default_cols=80): """ Returns the number of lines and columns of the current terminal. It attempts several strategies to determine the size and if all fail, it returns (80, 25). :rtype: int, int :return: The rows and columns of the terminal. """ #...
[ "def", "get_terminal_size", "(", "default_rows", "=", "25", ",", "default_cols", "=", "80", ")", ":", "# Collect a list of viable input channels that may tell us something", "# about the terminal dimensions.", "fileno_list", "=", "[", "]", "try", ":", "fileno_list", ".", ...
28.337079
19.325843
def validate_expires_at(form, field): """Validate that date is in the future.""" if form.accept.data: if not field.data or datetime.utcnow().date() >= field.data: raise validators.StopValidation(_( "Please provide a future date." )) if not field.data or \ ...
[ "def", "validate_expires_at", "(", "form", ",", "field", ")", ":", "if", "form", ".", "accept", ".", "data", ":", "if", "not", "field", ".", "data", "or", "datetime", ".", "utcnow", "(", ")", ".", "date", "(", ")", ">=", "field", ".", "data", ":", ...
43.666667
16.666667
def sample(self, size=1): """Generate samples of the random variable. Parameters ---------- size : int The number of samples to generate. Returns ------- :obj:`numpy.ndarray` of int or int The samples of the random variable. If `size == 1...
[ "def", "sample", "(", "self", ",", "size", "=", "1", ")", ":", "samples", "=", "scipy", ".", "stats", ".", "bernoulli", ".", "rvs", "(", "self", ".", "p", ",", "size", "=", "size", ")", "if", "size", "==", "1", ":", "return", "samples", "[", "0...
29.111111
18.888889
def single_feature_fit(self, feature): """Get the log2 bayes factor of the fit for each modality""" if np.isfinite(feature).sum() == 0: series = pd.Series(index=MODALITY_ORDER) else: logbf_one_param = pd.Series( {k: v.logsumexp_logliks(feature) for ...
[ "def", "single_feature_fit", "(", "self", ",", "feature", ")", ":", "if", "np", ".", "isfinite", "(", "feature", ")", ".", "sum", "(", ")", "==", "0", ":", "series", "=", "pd", ".", "Series", "(", "index", "=", "MODALITY_ORDER", ")", "else", ":", "...
43.571429
13.285714
def ParseMessageRow(self, parser_mediator, query, row, **unused_kwargs): """Parses a message row. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. query (str): query that created the row. row (sqlite3.Row)...
[ "def", "ParseMessageRow", "(", "self", ",", "parser_mediator", ",", "query", ",", "row", ",", "*", "*", "unused_kwargs", ")", ":", "query_hash", "=", "hash", "(", "query", ")", "event_data", "=", "KikIOSMessageEventData", "(", ")", "event_data", ".", "body",...
45.962963
22.148148
def do_windowed(self, line): """ Un-fullscreen the current window """ self.bot.canvas.sink.trigger_fullscreen_action(False) print(self.response_prompt, file=self.stdout)
[ "def", "do_windowed", "(", "self", ",", "line", ")", ":", "self", ".", "bot", ".", "canvas", ".", "sink", ".", "trigger_fullscreen_action", "(", "False", ")", "print", "(", "self", ".", "response_prompt", ",", "file", "=", "self", ".", "stdout", ")" ]
34
7.666667
def amount_object_to_dict(self, amount): """Return the dictionary representation of an Amount object. Amount object must have amount and currency properties and as_tuple method which will return (currency, amount) and as_quantized method to quantize amount property. :param amount: inst...
[ "def", "amount_object_to_dict", "(", "self", ",", "amount", ")", ":", "currency", ",", "amount", "=", "(", "amount", ".", "as_quantized", "(", "digits", "=", "2", ")", ".", "as_tuple", "(", ")", "if", "not", "isinstance", "(", "amount", ",", "dict", ")...
38.380952
19.952381
def _get_default_mapping(self, obj): """Return default mapping if there are no special needs.""" mapping = {v: k for k, v in obj.TYPE_MAPPING.items()} mapping.update({ fields.Email: text_type, fields.Dict: dict, fields.Url: text_type, fields.List: ...
[ "def", "_get_default_mapping", "(", "self", ",", "obj", ")", ":", "mapping", "=", "{", "v", ":", "k", "for", "k", ",", "v", "in", "obj", ".", "TYPE_MAPPING", ".", "items", "(", ")", "}", "mapping", ".", "update", "(", "{", "fields", ".", "Email", ...
37.583333
11.666667
def revision(self): """Revision number""" rev = self._p4dict.get('haveRev', -1) if rev == 'none': rev = 0 return int(rev)
[ "def", "revision", "(", "self", ")", ":", "rev", "=", "self", ".", "_p4dict", ".", "get", "(", "'haveRev'", ",", "-", "1", ")", "if", "rev", "==", "'none'", ":", "rev", "=", "0", "return", "int", "(", "rev", ")" ]
26.666667
13.166667
def run_sex_check(in_prefix, in_type, out_prefix, base_dir, options): """Runs step6 (sexcheck). :param in_prefix: the prefix of the input files. :param in_type: the type of the input files. :param out_prefix: the output prefix. :param base_dir: the output directory. :param options: the options ...
[ "def", "run_sex_check", "(", "in_prefix", ",", "in_type", ",", "out_prefix", ",", "base_dir", ",", "options", ")", ":", "# Creating the output directory", "os", ".", "mkdir", "(", "out_prefix", ")", "# We know we need a bfile", "required_type", "=", "\"bfile\"", "ch...
39.880435
19.956522
def interpolate_cubic(self, lons, lats, data): """ Interpolate using cubic spline approximation Returns the same as interpolate(lons,lats,data,order=3) """ return self.interpolate(lons, lats, data, order=3)
[ "def", "interpolate_cubic", "(", "self", ",", "lons", ",", "lats", ",", "data", ")", ":", "return", "self", ".", "interpolate", "(", "lons", ",", "lats", ",", "data", ",", "order", "=", "3", ")" ]
40.166667
9.833333
def redraw_label(self): """ Re-draws the text by calculating its position. Currently, the text will always be centered on the position of the layer. """ # Convenience variables x,y,_,_ = self.getPos() sx,sy = self.getSize() if self.font_n...
[ "def", "redraw_label", "(", "self", ")", ":", "# Convenience variables", "x", ",", "y", ",", "_", ",", "_", "=", "self", ".", "getPos", "(", ")", "sx", ",", "sy", "=", "self", ".", "getSize", "(", ")", "if", "self", ".", "font_name", "is", "not", ...
33.304348
12.608696
def Open(self): """Opens the USB device for this setting, and claims the interface.""" # Make sure we close any previous handle open to this usb device. port_path = tuple(self.port_path) with self._HANDLE_CACHE_LOCK: old_handle = self._HANDLE_CACHE.get(port_path) ...
[ "def", "Open", "(", "self", ")", ":", "# Make sure we close any previous handle open to this usb device.", "port_path", "=", "tuple", "(", "self", ".", "port_path", ")", "with", "self", ".", "_HANDLE_CACHE_LOCK", ":", "old_handle", "=", "self", ".", "_HANDLE_CACHE", ...
39.261905
15.690476
def trim(self, count, approximate=True): """ Trim the stream to the given "count" of messages, discarding the oldest messages first. :param count: maximum size of stream :param approximate: allow size to be approximate """ return self.database.xtrim(self.key, cou...
[ "def", "trim", "(", "self", ",", "count", ",", "approximate", "=", "True", ")", ":", "return", "self", ".", "database", ".", "xtrim", "(", "self", ".", "key", ",", "count", ",", "approximate", ")" ]
36.444444
15.555556
def swish(x, name='swish'): """Swish function. See `Swish: a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941>`__. Parameters ---------- x : Tensor input. name: str function name (optional). Returns ------- Tensor A ``Tensor`` in the same t...
[ "def", "swish", "(", "x", ",", "name", "=", "'swish'", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ")", ":", "x", "=", "tf", ".", "nn", ".", "sigmoid", "(", "x", ")", "*", "x", "return", "x" ]
18.952381
23.857143
def collect_conflicts_between_fields_and_fragment( context: ValidationContext, conflicts: List[Conflict], cached_fields_and_fragment_names: Dict, compared_fragments: Set[str], compared_fragment_pairs: "PairSet", are_mutually_exclusive: bool, field_map: NodeAndDefCollection, fragment_name...
[ "def", "collect_conflicts_between_fields_and_fragment", "(", "context", ":", "ValidationContext", ",", "conflicts", ":", "List", "[", "Conflict", "]", ",", "cached_fields_and_fragment_names", ":", "Dict", ",", "compared_fragments", ":", "Set", "[", "str", "]", ",", ...
32.508772
18.508772
def list_vpnservices(self, retrieve_all=True, **_params): """Fetches a list of all configured VPN services for a project.""" return self.list('vpnservices', self.vpnservices_path, retrieve_all, **_params)
[ "def", "list_vpnservices", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "list", "(", "'vpnservices'", ",", "self", ".", "vpnservices_path", ",", "retrieve_all", ",", "*", "*", "_params", ")" ]
60.5
14.5
def _inform_if_path_does_not_exist(path): """ If the path does not exist, print a message saying so. This is intended to be helpful to users if they specify a custom path that eg cannot find. """ expanded_path = get_expanded_path(path) if not os.path.exists(expanded_path): print('Could n...
[ "def", "_inform_if_path_does_not_exist", "(", "path", ")", ":", "expanded_path", "=", "get_expanded_path", "(", "path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "expanded_path", ")", ":", "print", "(", "'Could not find custom path at: {}'", ".", ...
45.375
13.625
def CORS(func=None): """ CORS support """ def w(r=None): from uliweb import request, response if request.method == 'OPTIONS': response = Response(status=204) response.headers['Access-Control-Allow-Credentials'] = 'true' response.headers['Access-Contr...
[ "def", "CORS", "(", "func", "=", "None", ")", ":", "def", "w", "(", "r", "=", "None", ")", ":", "from", "uliweb", "import", "request", ",", "response", "if", "request", ".", "method", "==", "'OPTIONS'", ":", "response", "=", "Response", "(", "status"...
43.125
26.825
def _folder_item_remarks(self, analysis_brain, item): """Renders the Remarks field for the passed in analysis If the edition of the analysis is permitted, adds the field into the list of editable fields. :param analysis_brain: Brain that represents an analysis :param item: anal...
[ "def", "_folder_item_remarks", "(", "self", ",", "analysis_brain", ",", "item", ")", ":", "if", "self", ".", "analysis_remarks_enabled", "(", ")", ":", "item", "[", "\"Remarks\"", "]", "=", "analysis_brain", ".", "getRemarks", "if", "self", ".", "is_analysis_e...
38.8
21.6
def populate_user_events(): """Generate a list of all registered authorized and anonymous events""" global AuthorizedEvents global AnonymousEvents def inheritors(klass): """Find inheritors of a specified object class""" subclasses = {} subclasses_set = set() work = [kl...
[ "def", "populate_user_events", "(", ")", ":", "global", "AuthorizedEvents", "global", "AnonymousEvents", "def", "inheritors", "(", "klass", ")", ":", "\"\"\"Find inheritors of a specified object class\"\"\"", "subclasses", "=", "{", "}", "subclasses_set", "=", "set", "(...
35.75
16.113636
def integrate(datasets_full, genes_list, batch_size=BATCH_SIZE, verbose=VERBOSE, ds_names=None, dimred=DIMRED, approx=APPROX, sigma=SIGMA, alpha=ALPHA, knn=KNN, geosketch=False, geosketch_max=20000, n_iter=1, union=False, hvg=None): """Integrate a list of data sets. Pa...
[ "def", "integrate", "(", "datasets_full", ",", "genes_list", ",", "batch_size", "=", "BATCH_SIZE", ",", "verbose", "=", "VERBOSE", ",", "ds_names", "=", "None", ",", "dimred", "=", "DIMRED", ",", "approx", "=", "APPROX", ",", "sigma", "=", "SIGMA", ",", ...
44.964286
19.464286
def _setContent(self): '''GED defines element name, so also define typecode aname ''' kw = KW.copy() try: kw.update(dict(klass=self.getClassName(), element='ElementDeclaration', literal=self.literalTag(), su...
[ "def", "_setContent", "(", "self", ")", ":", "kw", "=", "KW", ".", "copy", "(", ")", "try", ":", "kw", ".", "update", "(", "dict", "(", "klass", "=", "self", ".", "getClassName", "(", ")", ",", "element", "=", "'ElementDeclaration'", ",", "literal", ...
41.568182
18.295455
def rdopkg(*cargs): """ rdopkg CLI interface Execute rdopkg action with specified arguments and return shell friendly exit code. This is the default high level way to interact with rdopkg. py> rdopkg('new-version', '1.2.3') is equivalent to $> rdopkg new-version 1.2.3 ""...
[ "def", "rdopkg", "(", "*", "cargs", ")", ":", "runner", "=", "rdopkg_runner", "(", ")", "return", "shell", ".", "run", "(", "runner", ",", "cargs", "=", "cargs", ",", "prog", "=", "'rdopkg'", ",", "version", "=", "__version__", ")" ]
23.6
17.8
def _calc_uca_chunk(self, data, dX, dY, direction, mag, flats, area_edges, plotflag=False, edge_todo_i_no_mask=True): """ Calculates the upstream contributing area for the interior, and includes edge contributions if they are provided through area_edges. """ ...
[ "def", "_calc_uca_chunk", "(", "self", ",", "data", ",", "dX", ",", "dY", ",", "direction", ",", "mag", ",", "flats", ",", "area_edges", ",", "plotflag", "=", "False", ",", "edge_todo_i_no_mask", "=", "True", ")", ":", "# %%", "# Figure out which section the...
41.618644
20.838983
def _execute(self, func, command, **new_attributes): """ Execute command. """ if self._cfg_factory: # if we have a cfg_factory try: # we try to load a config with the factory if self.cfg_file: self.cfg = self._cf...
[ "def", "_execute", "(", "self", ",", "func", ",", "command", ",", "*", "*", "new_attributes", ")", ":", "if", "self", ".", "_cfg_factory", ":", "# if we have a cfg_factory", "try", ":", "# we try to load a config with the factory", "if", "self", ".", "cfg_file", ...
46.485981
15.682243
def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the ...
[ "def", "getopt", "(", "args", ",", "shortopts", ",", "longopts", "=", "[", "]", ")", ":", "opts", "=", "[", "]", "if", "type", "(", "longopts", ")", "==", "type", "(", "\"\"", ")", ":", "longopts", "=", "[", "longopts", "]", "else", ":", "longopt...
43.809524
23.738095
def set_chassis_location(location, host=None, admin_username=None, admin_password=None): ''' Set the location of the chassis. location The name of the location to be set on the chassis. host The chassis host. ...
[ "def", "set_chassis_location", "(", "location", ",", "host", "=", "None", ",", "admin_username", "=", "None", ",", "admin_password", "=", "None", ")", ":", "return", "__execute_cmd", "(", "'setsysinfo -c chassislocation {0}'", ".", "format", "(", "location", ")", ...
27.166667
24.5
def read_record(fp, first_line=None): """ Read a record from a file of AMOS messages On success returns a Message object On end of file raises EOFError """ if first_line is None: first_line = fp.readline() if not first_line: raise EOFError() match = _START.match(first...
[ "def", "read_record", "(", "fp", ",", "first_line", "=", "None", ")", ":", "if", "first_line", "is", "None", ":", "first_line", "=", "fp", ".", "readline", "(", ")", "if", "not", "first_line", ":", "raise", "EOFError", "(", ")", "match", "=", "_START",...
23.649123
18.315789
def _radixPass(a, b, r, n, K): """ Stable sort of the sequence a according to the keys given in r. >>> a=range(5) >>> b=[0]*5 >>> r=[2,1,3,0,4] >>> _radixPass(a, b, r, 5, 5) >>> b [3, 1, 0, 2, 4] When n is less than the length of a, the end of b must be left unaltered. >>> b=[...
[ "def", "_radixPass", "(", "a", ",", "b", ",", "r", ",", "n", ",", "K", ")", ":", "c", "=", "_array", "(", "\"i\"", ",", "[", "0", "]", "*", "(", "K", "+", "1", ")", ")", "# counter array", "for", "i", "in", "range", "(", "n", ")", ":", "#...
18.37037
23.703704
def export_node(bpmn_graph, export_elements, node, nodes_classification, order=0, prefix="", condition="", who="", add_join=False): """ General method for node exporting :param bpmn_graph: an instance of BpmnDiagramGraph class, :param export_elements: a dictionary ob...
[ "def", "export_node", "(", "bpmn_graph", ",", "export_elements", ",", "node", ",", "nodes_classification", ",", "order", "=", "0", ",", "prefix", "=", "\"\"", ",", "condition", "=", "\"\"", ",", "who", "=", "\"\"", ",", "add_join", "=", "False", ")", ":"...
69.333333
37
def react(reactor, main, argv): """ Call C{main} and run the reactor until the L{Deferred} it returns fires. @param reactor: An unstarted L{IReactorCore} provider which will be run and later stopped. @param main: A callable which returns a L{Deferred}. It should take as many arguments...
[ "def", "react", "(", "reactor", ",", "main", ",", "argv", ")", ":", "stopping", "=", "[", "]", "reactor", ".", "addSystemEventTrigger", "(", "'before'", ",", "'shutdown'", ",", "stopping", ".", "append", ",", "True", ")", "finished", "=", "main", "(", ...
33.956522
22.391304
def format_help(self, description): """ Format the setting's description into HTML. """ for bold in ("``", "*"): parts = [] if description is None: description = "" for i, s in enumerate(description.split(bold)): parts.a...
[ "def", "format_help", "(", "self", ",", "description", ")", ":", "for", "bold", "in", "(", "\"``\"", ",", "\"*\"", ")", ":", "parts", "=", "[", "]", "if", "description", "is", "None", ":", "description", "=", "\"\"", "for", "i", ",", "s", "in", "en...
39.384615
10.615385
def add_tour_step(self, message, selector=None, name=None, title=None, theme=None, alignment=None, duration=None): """ Allows the user to add tour steps for a website. @Params message - The message to display. selector - The CSS Selector of the Element t...
[ "def", "add_tour_step", "(", "self", ",", "message", ",", "selector", "=", "None", ",", "name", "=", "None", ",", "title", "=", "None", ",", "theme", "=", "None", ",", "alignment", "=", "None", ",", "duration", "=", "None", ")", ":", "if", "not", "...
45.098361
20.360656