text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None, filter_type=None, **kwds): """ perform a reduction operation """ return op(self.get_values(), skipna=skipna, **kwds)
[ "def", "_reduce", "(", "self", ",", "op", ",", "name", ",", "axis", "=", "0", ",", "skipna", "=", "True", ",", "numeric_only", "=", "None", ",", "filter_type", "=", "None", ",", "*", "*", "kwds", ")", ":", "return", "op", "(", "self", ".", "get_v...
53.25
0.013889
def putcol(self, value, startrow=0, nrow=-1, rowincr=1): """Put an entire column or part of it. (see :func:`table.putcol`)""" return self._table.putcol(self._column, value, startrow, nrow, rowincr)
[ "def", "putcol", "(", "self", ",", "value", ",", "startrow", "=", "0", ",", "nrow", "=", "-", "1", ",", "rowincr", "=", "1", ")", ":", "return", "self", ".", "_table", ".", "putcol", "(", "self", ".", "_column", ",", "value", ",", "startrow", ","...
54.5
0.00905
def version_greater(minimum, version): """ Compare two version strings. :param minimum: The minimum valid version. :param version: The version to compare to. :returns: True if version is greater than minimum, False otherwise. """ # Chop up the version strings minimum = [...
[ "def", "version_greater", "(", "minimum", ",", "version", ")", ":", "# Chop up the version strings", "minimum", "=", "[", "int", "(", "i", ")", "for", "i", "in", "minimum", ".", "split", "(", "'.'", ")", "]", "version", "=", "[", "int", "(", "i", ")", ...
28.344828
0.001176
def tablelib_binary_features(span1, span2): """ Table-/structure-related features for a pair of spans """ binary_features = settings["featurization"]["table"]["binary_features"] if span1.sentence.is_tabular() and span2.sentence.is_tabular(): if span1.sentence.table == span2.sentence.table: ...
[ "def", "tablelib_binary_features", "(", "span1", ",", "span2", ")", ":", "binary_features", "=", "settings", "[", "\"featurization\"", "]", "[", "\"table\"", "]", "[", "\"binary_features\"", "]", "if", "span1", ".", "sentence", ".", "is_tabular", "(", ")", "an...
46.018519
0.002364
def extract(self, m): """ extract info specified in option """ self._clear() self.m = m # self._preprocess() if self.option != []: self._url_filter() self._email_filter() if 'tex' in self.option: self._tex_filte...
[ "def", "extract", "(", "self", ",", "m", ")", ":", "self", ".", "_clear", "(", ")", "self", ".", "m", "=", "m", "# self._preprocess()", "if", "self", ".", "option", "!=", "[", "]", ":", "self", ".", "_url_filter", "(", ")", "self", ".", "_email_fil...
29.75
0.002326
def join_resource_name(self, v): """Return a MetapackResourceUrl that includes a reference to the resource. Returns a MetapackResourceUrl, which will have a fragment """ d = self.dict d['fragment'] = [v, None] return MetapackResourceUrl(downloader=self._downloader, **d)
[ "def", "join_resource_name", "(", "self", ",", "v", ")", ":", "d", "=", "self", ".", "dict", "d", "[", "'fragment'", "]", "=", "[", "v", ",", "None", "]", "return", "MetapackResourceUrl", "(", "downloader", "=", "self", ".", "_downloader", ",", "*", ...
50.833333
0.009677
def parse_cluster_role_env(cluster_role_env, config_path): """Parse cluster/[role]/[environ], supply default, if not provided, not required""" parts = cluster_role_env.split('/')[:3] if not os.path.isdir(config_path): Log.error("Config path cluster directory does not exist: %s" % config_path) raise Except...
[ "def", "parse_cluster_role_env", "(", "cluster_role_env", ",", "config_path", ")", ":", "parts", "=", "cluster_role_env", ".", "split", "(", "'/'", ")", "[", ":", "3", "]", "if", "not", "os", ".", "path", ".", "isdir", "(", "config_path", ")", ":", "Log"...
40.4
0.01305
def convert(self, name): "translate gui2py attribute name from pythoncard legacy code" new_name = PYTHONCARD_PROPERTY_MAP.get(name) if new_name: print "WARNING: property %s should be %s (%s)" % (name, new_name, self.obj.name) return new_name else: retu...
[ "def", "convert", "(", "self", ",", "name", ")", ":", "new_name", "=", "PYTHONCARD_PROPERTY_MAP", ".", "get", "(", "name", ")", "if", "new_name", ":", "print", "\"WARNING: property %s should be %s (%s)\"", "%", "(", "name", ",", "new_name", ",", "self", ".", ...
40
0.009174
def trans_attr(attr, lang): """ Returns the name of the translated attribute of the object <attribute>_<lang_iso_code>. For example: name_es (name attribute in Spanish) @param attr Attribute whose name will form the name translated attribute. @param lang ISO Language code that will be the suffix of the translated ...
[ "def", "trans_attr", "(", "attr", ",", "lang", ")", ":", "lang", "=", "lang", ".", "replace", "(", "\"-\"", ",", "\"_\"", ")", ".", "lower", "(", ")", "return", "\"{0}_{1}\"", ".", "format", "(", "attr", ",", "lang", ")" ]
46
0.029851
def create_boxcar(aryCnd, aryOns, aryDrt, varTr, varNumVol, aryExclCnd=None, varTmpOvsmpl=1000.): """ Creation of condition time courses in temporally upsampled space. Parameters ---------- aryCnd : np.array 1D array with condition identifiers (every condition has its own...
[ "def", "create_boxcar", "(", "aryCnd", ",", "aryOns", ",", "aryDrt", ",", "varTr", ",", "varNumVol", ",", "aryExclCnd", "=", "None", ",", "varTmpOvsmpl", "=", "1000.", ")", ":", "if", "aryExclCnd", "is", "not", "None", ":", "for", "cond", "in", "aryExclC...
35.836066
0.000445
def ListPlugins(logdir): """List all the plugins that have registered assets in logdir. If the plugins_dir does not exist, it returns an empty list. This maintains compatibility with old directories that have no plugins written. Args: logdir: A directory that was created by a TensorFlow events writer. ...
[ "def", "ListPlugins", "(", "logdir", ")", ":", "plugins_dir", "=", "os", ".", "path", ".", "join", "(", "logdir", ",", "_PLUGINS_DIR", ")", "try", ":", "entries", "=", "tf", ".", "io", ".", "gfile", ".", "listdir", "(", "plugins_dir", ")", "except", ...
35.666667
0.010403
def get_permissions(self, role): """gets permissions of role""" target_role = AuthGroup.objects(role=role, creator=self.client).first() if not target_role: return '[]' targets = AuthPermission.objects(groups=target_role, creator=self.client).only('name') return json.l...
[ "def", "get_permissions", "(", "self", ",", "role", ")", ":", "target_role", "=", "AuthGroup", ".", "objects", "(", "role", "=", "role", ",", "creator", "=", "self", ".", "client", ")", ".", "first", "(", ")", "if", "not", "target_role", ":", "return",...
48.142857
0.008746
def __execute_cmd(name, xml): ''' Execute ilom commands ''' ret = {name.replace('_', ' '): {}} id_num = 0 tmp_dir = os.path.join(__opts__['cachedir'], 'tmp') if not os.path.isdir(tmp_dir): os.mkdir(tmp_dir) with tempfile.NamedTemporaryFile(dir=tmp_dir, ...
[ "def", "__execute_cmd", "(", "name", ",", "xml", ")", ":", "ret", "=", "{", "name", ".", "replace", "(", "'_'", ",", "' '", ")", ":", "{", "}", "}", "id_num", "=", "0", "tmp_dir", "=", "os", ".", "path", ".", "join", "(", "__opts__", "[", "'cac...
31.25
0.000705
def symlink(real_path, link_path, overwrite=False, on_error='raise', verbose=2): """ Attempt to create a symbolic link. TODO: Can this be fixed on windows? Args: path (str): path to real file or directory link_path (str): path to desired location for symlink ...
[ "def", "symlink", "(", "real_path", ",", "link_path", ",", "overwrite", "=", "False", ",", "on_error", "=", "'raise'", ",", "verbose", "=", "2", ")", ":", "path", "=", "normpath", "(", "real_path", ")", "link", "=", "normpath", "(", "link_path", ")", "...
35.911111
0.000903
def attrfindrows(self, groupname, attrname, value): """Get the row numbers of all rows where the attribute matches the given value.""" values = self.attrgetcol(groupname, attrname) return [i for i in range(len(values)) if values[i] == value]
[ "def", "attrfindrows", "(", "self", ",", "groupname", ",", "attrname", ",", "value", ")", ":", "values", "=", "self", ".", "attrgetcol", "(", "groupname", ",", "attrname", ")", "return", "[", "i", "for", "i", "in", "range", "(", "len", "(", "values", ...
65.5
0.011321
def upload_file(self, source, dest_uri): """Upload file to MediaFire. source -- path to the file or a file-like object (e.g. io.BytesIO) dest_uri -- MediaFire Resource URI """ folder_key, name = self._prepare_upload_info(source, dest_uri) is_fh = hasattr(source, 'read'...
[ "def", "upload_file", "(", "self", ",", "source", ",", "dest_uri", ")", ":", "folder_key", ",", "name", "=", "self", ".", "_prepare_upload_info", "(", "source", ",", "dest_uri", ")", "is_fh", "=", "hasattr", "(", "source", ",", "'read'", ")", "fd", "=", ...
29.259259
0.002451
def disttar_suffix(env, sources): """tar archive suffix generator""" env_dict = env.Dictionary() if env_dict.has_key("DISTTAR_FORMAT") and env_dict["DISTTAR_FORMAT"] in ["gz", "bz2"]: return ".tar." + env_dict["DISTTAR_FORMAT"] else: return ".tar"
[ "def", "disttar_suffix", "(", "env", ",", "sources", ")", ":", "env_dict", "=", "env", ".", "Dictionary", "(", ")", "if", "env_dict", ".", "has_key", "(", "\"DISTTAR_FORMAT\"", ")", "and", "env_dict", "[", "\"DISTTAR_FORMAT\"", "]", "in", "[", "\"gz\"", ",...
38.125
0.019231
def cli(env, origin_volume_id, origin_snapshot_id, duplicate_size, duplicate_iops, duplicate_tier, duplicate_snapshot_size, billing): """Order a duplicate file storage volume.""" file_manager = SoftLayer.FileStorageManager(env.client) hourly_billing_flag = False if billing.lower() == "hourly": ...
[ "def", "cli", "(", "env", ",", "origin_volume_id", ",", "origin_snapshot_id", ",", "duplicate_size", ",", "duplicate_iops", ",", "duplicate_tier", ",", "duplicate_snapshot_size", ",", "billing", ")", ":", "file_manager", "=", "SoftLayer", ".", "FileStorageManager", ...
38.030303
0.000777
def mpsse_gpio(self): """Return command to update the MPSSE GPIO state to the current direction and level. """ level_low = chr(self._level & 0xFF) level_high = chr((self._level >> 8) & 0xFF) dir_low = chr(self._direction & 0xFF) dir_high = chr((self._direction >...
[ "def", "mpsse_gpio", "(", "self", ")", ":", "level_low", "=", "chr", "(", "self", ".", "_level", "&", "0xFF", ")", "level_high", "=", "chr", "(", "(", "self", ".", "_level", ">>", "8", ")", "&", "0xFF", ")", "dir_low", "=", "chr", "(", "self", "....
45.555556
0.014354
def get_missing_simulations(self, param_list, runs=None): """ Return a list of the simulations among the required ones that are not available in the database. Args: param_list (list): a list of dictionaries containing all the parameters combinations. ...
[ "def", "get_missing_simulations", "(", "self", ",", "param_list", ",", "runs", "=", "None", ")", ":", "params_to_simulate", "=", "[", "]", "if", "runs", "is", "not", "None", ":", "# Get next available runs from the database", "next_runs", "=", "self", ".", "db",...
47.325581
0.001444
def get_header(request, header_service): """Return request's 'X_POLYAXON_...:' header, as a bytestring. Hide some test client ickyness where the header can be unicode. """ service = request.META.get('HTTP_{}'.format(header_service), b'') if isinstance(service, str): # Work around django tes...
[ "def", "get_header", "(", "request", ",", "header_service", ")", ":", "service", "=", "request", ".", "META", ".", "get", "(", "'HTTP_{}'", ".", "format", "(", "header_service", ")", ",", "b''", ")", "if", "isinstance", "(", "service", ",", "str", ")", ...
40.1
0.002439
def combine_words(word1, word2): """Combines two words. If the first word ends with a vowel and the initial letter of the second word is only consonant, it merges them into one letter:: >>> combine_words(u'다', u'ㄺ') 닭 >>> combine_words(u'가오', u'ㄴ누리') 가온누리 """ if word1 and word2 an...
[ "def", "combine_words", "(", "word1", ",", "word2", ")", ":", "if", "word1", "and", "word2", "and", "is_consonant", "(", "word2", "[", "0", "]", ")", ":", "onset", ",", "nucleus", ",", "coda", "=", "split_phonemes", "(", "word1", "[", "-", "1", "]", ...
31.764706
0.001799
def _rewrite_and_copy(src_file, dst_file, project_name): """Replace vars and copy.""" # Create temp file fh, abs_path = mkstemp() with io.open(abs_path, 'w', encoding='utf-8') as new_file: with io.open(src_file, 'r', encoding='utf-8') as old_file: for line in old_file: ...
[ "def", "_rewrite_and_copy", "(", "src_file", ",", "dst_file", ",", "project_name", ")", ":", "# Create temp file", "fh", ",", "abs_path", "=", "mkstemp", "(", ")", "with", "io", ".", "open", "(", "abs_path", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")"...
36.733333
0.00177
def match_string(self, string_to_match, regexp): """Get regular expression from the first of the lines passed in in string that matched. Handles first group of regexp as a return value. @param string_to_match: String to match on @param regexp: Regexp to check (per-line) against string @type string_to_matc...
[ "def", "match_string", "(", "self", ",", "string_to_match", ",", "regexp", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "if", "not", "isinstance", "(", "string_to_match", ",", "str", ")", ":", "return", "None", "lines...
32.486486
0.029079
def istextfile(fname, blocksize=512): """ Uses heuristics to guess whether the given file is text or binary, by reading a single block of bytes from the file. If more than 30% of the chars in the block are non-text, or there are NUL ('\x00') bytes in the block, assume this is a binary file. ...
[ "def", "istextfile", "(", "fname", ",", "blocksize", "=", "512", ")", ":", "with", "open", "(", "fname", ",", "\"rb\"", ")", "as", "fobj", ":", "block", "=", "fobj", ".", "read", "(", "blocksize", ")", "if", "not", "block", ":", "# An empty file is con...
37.333333
0.001244
def check_status(content, response): """ Check the response that is returned for known exceptions and errors. :param response: Response that is returned from the call. :raise: MalformedRequestException if `response.status` is 400 UnauthorisedException if `response.statu...
[ "def", "check_status", "(", "content", ",", "response", ")", ":", "if", "response", ".", "status", "==", "400", ":", "raise", "MalformedRequestException", "(", "content", ",", "response", ")", "if", "response", ".", "status", "==", "401", ":", "raise", "Un...
37.147059
0.001543
def download_vault_folder(remote_path, local_path, dry_run=False, force=False): """Recursively downloads a folder in a vault to a local directory. Only downloads files, not datasets.""" local_path = os.path.normpath(os.path.expanduser(local_path)) if not os.access(local_path, os.W_OK): raise Ex...
[ "def", "download_vault_folder", "(", "remote_path", ",", "local_path", ",", "dry_run", "=", "False", ",", "force", "=", "False", ")", ":", "local_path", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "expanduser", "(", "local_path", ...
38.058824
0.000502
def mention_to_tokens(mention, token_type="words", lowercase=False): """ Extract tokens from the mention :param mention: mention object. :param token_type: token type that wants to extract. :type token_type: str :param lowercase: use lowercase or not. :type lowercase: bool :return: The ...
[ "def", "mention_to_tokens", "(", "mention", ",", "token_type", "=", "\"words\"", ",", "lowercase", "=", "False", ")", ":", "tokens", "=", "mention", ".", "context", ".", "sentence", ".", "__dict__", "[", "token_type", "]", "return", "[", "w", ".", "lower",...
30.733333
0.002105
def copy(self): "Return a copy of the drop target (to avoid wx problems on rebuild)" return ToolBoxDropTarget(self.dv, self.root, self.designer, self.inspector)
[ "def", "copy", "(", "self", ")", ":", "return", "ToolBoxDropTarget", "(", "self", ".", "dv", ",", "self", ".", "root", ",", "self", ".", "designer", ",", "self", ".", "inspector", ")" ]
51.75
0.014286
def show_ext(self, path, id, **_params): """Client extension hook for show.""" return self.get(path % id, params=_params)
[ "def", "show_ext", "(", "self", ",", "path", ",", "id", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "path", "%", "id", ",", "params", "=", "_params", ")" ]
45
0.014599
def post_merge_request(profile, payload): """Do a POST request to Github's API to merge. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect ...
[ "def", "post_merge_request", "(", "profile", ",", "payload", ")", ":", "repo", "=", "profile", "[", "\"repo\"", "]", "url", "=", "GITHUB_API_BASE_URL", "+", "\"repos/\"", "+", "repo", "+", "\"/merges\"", "headers", "=", "get_headers", "(", "profile", ")", "r...
32.653846
0.001144
def create(python, env_dir, system, prompt, bare, virtualenv_py=None): """Main entry point to use this as a module. """ if not python or python == sys.executable: _create_with_this( env_dir=env_dir, system=system, prompt=prompt, bare=bare, virtualenv_py=virtualenv_py, ...
[ "def", "create", "(", "python", ",", "env_dir", ",", "system", ",", "prompt", ",", "bare", ",", "virtualenv_py", "=", "None", ")", ":", "if", "not", "python", "or", "python", "==", "sys", ".", "executable", ":", "_create_with_this", "(", "env_dir", "=", ...
35.428571
0.001965
def get_conv(bits, bin_point, signed=False, scaling=1.0): """ Creates a I{conversion structure} implented as a dictionary containing all parameters needed to switch between number representations. @param bits: the number of bits @param bin_point: binary point position @param signed: True if Fix,...
[ "def", "get_conv", "(", "bits", ",", "bin_point", ",", "signed", "=", "False", ",", "scaling", "=", "1.0", ")", ":", "conversion_t", "=", "{", "}", "conversion_t", "[", "\"bits\"", "]", "=", "bits", "conversion_t", "[", "\"bin_point\"", "]", "=", "bin_po...
37.71875
0.002423
def create_dset_to3d(prefix,file_list,file_order='zt',num_slices=None,num_reps=None,TR=None,slice_order='alt+z',only_dicoms=True,sort_filenames=False): '''manually create dataset by specifying everything (not recommended, but necessary when autocreation fails) If `num_slices` or `num_reps` is omitted, it will ...
[ "def", "create_dset_to3d", "(", "prefix", ",", "file_list", ",", "file_order", "=", "'zt'", ",", "num_slices", "=", "None", ",", "num_reps", "=", "None", ",", "TR", "=", "None", ",", "slice_order", "=", "'alt+z'", ",", "only_dicoms", "=", "True", ",", "s...
43.511628
0.018291
def regular_data_1d_from_sub_data_1d(self, sub_array_1d): """For an input sub-gridded array, map its hyper-values from the sub-gridded values to a 1D regular grid of \ values by summing each set of each set of sub-pixels values and dividing by the total number of sub-pixels. Parameters ...
[ "def", "regular_data_1d_from_sub_data_1d", "(", "self", ",", "sub_array_1d", ")", ":", "return", "np", ".", "multiply", "(", "self", ".", "sub_grid_fraction", ",", "sub_array_1d", ".", "reshape", "(", "-", "1", ",", "self", ".", "sub_grid_length", ")", ".", ...
56.727273
0.009464
def check_static_member_vars(class_, fpath=None, only_init=True): """ class_ can either be live object or a classname # fpath = ut.truepath('~/code/ibeis/ibeis/viz/viz_graph2.py') # classname = 'AnnotGraphWidget' """ #import ast #import astor import utool as ut if isinstance(class_...
[ "def", "check_static_member_vars", "(", "class_", ",", "fpath", "=", "None", ",", "only_init", "=", "True", ")", ":", "#import ast", "#import astor", "import", "utool", "as", "ut", "if", "isinstance", "(", "class_", ",", "six", ".", "string_types", ")", ":",...
32.009709
0.002354
def extend(self, content, zorder): """ Extends with a list and a z-order """ if zorder not in self._content: self._content[zorder] = [] self._content[zorder].extend(content)
[ "def", "extend", "(", "self", ",", "content", ",", "zorder", ")", ":", "if", "zorder", "not", "in", "self", ".", "_content", ":", "self", ".", "_content", "[", "zorder", "]", "=", "[", "]", "self", ".", "_content", "[", "zorder", "]", ".", "extend"...
35.333333
0.009217
def sigmalos(Pot,R,dens=None,surfdens=None,beta=0.,sigma_r=None): """ NAME: sigmalos PURPOSE: Compute the line-of-sight velocity dispersion using the spherical Jeans equation INPUT: Pot - potential or list of potentials (evaluated at R=r/sqrt(2),z=r/sqrt(2), sphericity not chec...
[ "def", "sigmalos", "(", "Pot", ",", "R", ",", "dens", "=", "None", ",", "surfdens", "=", "None", ",", "beta", "=", "0.", ",", "sigma_r", "=", "None", ")", ":", "Pot", "=", "flatten_pot", "(", "Pot", ")", "if", "dens", "is", "None", ":", "densPot"...
33.848485
0.020009
def _increment(self, what, host): ''' helper function to bump a statistic ''' self.processed[host] = 1 prev = (getattr(self, what)).get(host, 0) getattr(self, what)[host] = prev+1
[ "def", "_increment", "(", "self", ",", "what", ",", "host", ")", ":", "self", ".", "processed", "[", "host", "]", "=", "1", "prev", "=", "(", "getattr", "(", "self", ",", "what", ")", ")", ".", "get", "(", "host", ",", "0", ")", "getattr", "(",...
34.5
0.009434
def native_contracts(address: int, data: BaseCalldata) -> List[int]: """Takes integer address 1, 2, 3, 4. :param address: :param data: :return: """ functions = (ecrecover, sha256, ripemd160, identity) if isinstance(data, ConcreteCalldata): concrete_data = data.concrete(None) el...
[ "def", "native_contracts", "(", "address", ":", "int", ",", "data", ":", "BaseCalldata", ")", "->", "List", "[", "int", "]", ":", "functions", "=", "(", "ecrecover", ",", "sha256", ",", "ripemd160", ",", "identity", ")", "if", "isinstance", "(", "data", ...
26.6
0.002421
def setColor( self, name, color, colorGroup = None ): """ Sets the color for the inputed name in the given color group. If no \ specific color group is found then the color will be set for all \ color groups. :param name | <str> color ...
[ "def", "setColor", "(", "self", ",", "name", ",", "color", ",", "colorGroup", "=", "None", ")", ":", "self", ".", "_colors", ".", "setdefault", "(", "str", "(", "name", ")", ",", "{", "}", ")", "cmap", "=", "self", ".", "_colors", ".", "get", "("...
35.944444
0.01506
def plot_theta(self, colorbar=True, cb_orientation='vertical', cb_label='$g_\\theta$, m s$^{-2}$', ax=None, show=True, fname=None, **kwargs): """ Plot the theta component of the gravity field. Usage ----- x.plot_theta([tick_interval, xlabel,...
[ "def", "plot_theta", "(", "self", ",", "colorbar", "=", "True", ",", "cb_orientation", "=", "'vertical'", ",", "cb_label", "=", "'$g_\\\\theta$, m s$^{-2}$'", ",", "ax", "=", "None", ",", "show", "=", "True", ",", "fname", "=", "None", ",", "*", "*", "kw...
42.653846
0.001763
def extents(self): """list[VolumeExtent]: volume extents.""" if not self._is_parsed: self._Parse() self._is_parsed = True return self._extents
[ "def", "extents", "(", "self", ")", ":", "if", "not", "self", ".", "_is_parsed", ":", "self", ".", "_Parse", "(", ")", "self", ".", "_is_parsed", "=", "True", "return", "self", ".", "_extents" ]
23
0.017964
def update(self, observable, actions): """Called when a local reader is added or removed. Create remote pyro reader objects for added readers. Delete remote pyro reader objects for removed readers.""" (addedreaders, removedreaders) = actions for reader in addedreaders: ...
[ "def", "update", "(", "self", ",", "observable", ",", "actions", ")", ":", "(", "addedreaders", ",", "removedreaders", ")", "=", "actions", "for", "reader", "in", "addedreaders", ":", "remotereader", "=", "RemoteReader", "(", "reader", ")", "self", ".", "r...
50.375
0.002436
def _get_index_name(self, columns): """ Try several cases to get lines: 0) There are headers on row 0 and row 1 and their total summed lengths equals the length of the next line. Treat row 0 as columns and row 1 as indices 1) Look for implicit index: there are more colum...
[ "def", "_get_index_name", "(", "self", ",", "columns", ")", ":", "orig_names", "=", "list", "(", "columns", ")", "columns", "=", "list", "(", "columns", ")", "try", ":", "line", "=", "self", ".", "_next_line", "(", ")", "except", "StopIteration", ":", ...
34.063492
0.000906
def get_conversion_factor(structure, species, temperature): """ Conversion factor to convert between cm^2/s diffusivity measurements and mS/cm conductivity measurements based on number of atoms of diffusing species. Note that the charge is based on the oxidation state of the species (where available...
[ "def", "get_conversion_factor", "(", "structure", ",", "species", ",", "temperature", ")", ":", "df_sp", "=", "get_el_sp", "(", "species", ")", "if", "hasattr", "(", "df_sp", ",", "\"oxi_state\"", ")", ":", "z", "=", "df_sp", ".", "oxi_state", "else", ":",...
37.857143
0.00092
def _inject_args(sig, types): """ A function to inject arguments manually into a method signature before it's been parsed. If using keyword arguments use 'kw=type' instead in the types array. sig the string signature types a list of types to be inserted Returns the altered signat...
[ "def", "_inject_args", "(", "sig", ",", "types", ")", ":", "if", "'('", "in", "sig", ":", "parts", "=", "sig", ".", "split", "(", "'('", ")", "sig", "=", "'%s(%s%s%s'", "%", "(", "parts", "[", "0", "]", ",", "', '", ".", "join", "(", "types", "...
30.157895
0.001692
def _validate(self, value): """Validate the new value.""" if self.values and value not in self.values: raise ValueError( '{} is not a valid value for {}'.format(value, self.name))
[ "def", "_validate", "(", "self", ",", "value", ")", ":", "if", "self", ".", "values", "and", "value", "not", "in", "self", ".", "values", ":", "raise", "ValueError", "(", "'{} is not a valid value for {}'", ".", "format", "(", "value", ",", "self", ".", ...
43.8
0.008969
def wait_started(name, path=None, timeout=300): ''' Check that the system has fully inited This is actually very important for systemD based containers see https://github.com/saltstack/salt/issues/23847 path path to the container parent default: /var/lib/lxc (system default) ...
[ "def", "wait_started", "(", "name", ",", "path", "=", "None", ",", "timeout", "=", "300", ")", ":", "if", "not", "exists", "(", "name", ",", "path", "=", "path", ")", ":", "raise", "CommandExecutionError", "(", "'Container {0} does does exists'", ".", "for...
27.571429
0.000715
def where(self, other, cond, align=True, errors='raise', try_cast=False, axis=0, transpose=False): """ evaluate the block; return result block(s) from the result Parameters ---------- other : a ndarray/object cond : the condition to respect align :...
[ "def", "where", "(", "self", ",", "other", ",", "cond", ",", "align", "=", "True", ",", "errors", "=", "'raise'", ",", "try_cast", "=", "False", ",", "axis", "=", "0", ",", "transpose", "=", "False", ")", ":", "import", "pandas", ".", "core", ".", ...
35.766355
0.000763
def _nemo_accpars(self,vo,ro): """ NAME: _nemo_accpars PURPOSE: return the accpars potential parameters for use of this potential with NEMO INPUT: vo - velocity unit in km/s ro - length unit in kpc OUTPUT: accpars str...
[ "def", "_nemo_accpars", "(", "self", ",", "vo", ",", "ro", ")", ":", "ampl", "=", "self", ".", "_amp", "*", "vo", "**", "2.", "*", "ro", "vmax", "=", "numpy", ".", "sqrt", "(", "ampl", "/", "self", ".", "a", "/", "ro", "*", "0.2162165954", ")",...
19.535714
0.019164
def unbind(self, queue='', exchange='', routing_key='', arguments=None): """Unbind a Queue. :param str queue: Queue name :param str exchange: Exchange name :param str routing_key: The routing key used :param dict arguments: Unbind key/value arguments :raises AMQPInvalid...
[ "def", "unbind", "(", "self", ",", "queue", "=", "''", ",", "exchange", "=", "''", ",", "routing_key", "=", "''", ",", "arguments", "=", "None", ")", ":", "if", "not", "compatibility", ".", "is_string", "(", "queue", ")", ":", "raise", "AMQPInvalidArgu...
47.034483
0.001437
def get_versus(self): """Return the versus board, player, opponent and extra actions. Return None for any parts that can't be found. """ # game game_image = self._game_image_from_screen('versus') if game_image is None: return None, None, None, None # nothing ...
[ "def", "get_versus", "(", "self", ")", ":", "# game", "game_image", "=", "self", ".", "_game_image_from_screen", "(", "'versus'", ")", "if", "game_image", "is", "None", ":", "return", "None", ",", "None", ",", "None", ",", "None", "# nothing else will work", ...
43.190476
0.002157
def getMajorMinor(deviceName, dmsetupLs): """ Given output of dmsetup ls this will return themajor:minor (block name) of the device deviceName """ startingIndex = string.rindex(dmsetupLs, deviceName) + len(deviceName) endingIndex = string.index(dmsetupLs[startingIndex:], "\n") + startingIndex ...
[ "def", "getMajorMinor", "(", "deviceName", ",", "dmsetupLs", ")", ":", "startingIndex", "=", "string", ".", "rindex", "(", "dmsetupLs", ",", "deviceName", ")", "+", "len", "(", "deviceName", ")", "endingIndex", "=", "string", ".", "index", "(", "dmsetupLs", ...
38.454545
0.002309
def apply(self, snapshot): """Set the current context from a given snapshot dictionary""" for name in snapshot: setattr(self, name, snapshot[name])
[ "def", "apply", "(", "self", ",", "snapshot", ")", ":", "for", "name", "in", "snapshot", ":", "setattr", "(", "self", ",", "name", ",", "snapshot", "[", "name", "]", ")" ]
34.4
0.011364
def db(self, connection_string=None): """Gets the SQLALchemy session for this request""" connection_string = connection_string or self.settings["db"] if not hasattr(self, "_db_conns"): self._db_conns = {} if not connection_string in self._db_conns: self._db_conn...
[ "def", "db", "(", "self", ",", "connection_string", "=", "None", ")", ":", "connection_string", "=", "connection_string", "or", "self", ".", "settings", "[", "\"db\"", "]", "if", "not", "hasattr", "(", "self", ",", "\"_db_conns\"", ")", ":", "self", ".", ...
40.090909
0.008869
def getThirdPartyLibDefinitions(self, libs): """ Retrieves the list of preprocessor definitions for building against the Unreal-bundled versions of the specified third-party libraries """ platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.g...
[ "def", "getThirdPartyLibDefinitions", "(", "self", ",", "libs", ")", ":", "platformDefaults", "=", "True", "if", "libs", "[", "0", "]", "==", "'--nodefaults'", ":", "platformDefaults", "=", "False", "libs", "=", "libs", "[", "1", ":", "]", "details", "=", ...
41.454545
0.034335
def diff_fit(strains, stresses, eq_stress=None, order=2, tol=1e-10): """ nth order elastic constant fitting function based on central-difference derivatives with respect to distinct strain states. The algorithm is summarized as follows: 1. Identify distinct strain states as sets of indices ...
[ "def", "diff_fit", "(", "strains", ",", "stresses", ",", "eq_stress", "=", "None", ",", "order", "=", "2", ",", "tol", "=", "1e-10", ")", ":", "strain_state_dict", "=", "get_strain_state_dict", "(", "strains", ",", "stresses", ",", "eq_stress", "=", "eq_st...
43.25
0.000377
def bulkRead(self, endpoint, size, timeout = 100): r"""Performs a bulk read request to the endpoint specified. Arguments: endpoint: endpoint number. size: number of bytes to read. timeout: operation timeout in milliseconds. (default: 100) ...
[ "def", "bulkRead", "(", "self", ",", "endpoint", ",", "size", ",", "timeout", "=", "100", ")", ":", "return", "self", ".", "dev", ".", "read", "(", "endpoint", ",", "size", ",", "timeout", ")" ]
41.2
0.009501
def as_stream(self): """ Return a zipped package as a readable stream """ stream = io.BytesIO() self._store(stream) stream.seek(0) return stream
[ "def", "as_stream", "(", "self", ")", ":", "stream", "=", "io", ".", "BytesIO", "(", ")", "self", ".", "_store", "(", "stream", ")", "stream", ".", "seek", "(", "0", ")", "return", "stream" ]
18.875
0.056962
def find_best_periods(self, model, n_periods=5, return_scores=False): """Find the `n_periods` best periods in the model""" # compute the estimated peak width from the data range tmin, tmax = np.min(model.t), np.max(model.t) width = 2 * np.pi / (tmax - tmin) # raise a ValueError...
[ "def", "find_best_periods", "(", "self", ",", "model", ",", "n_periods", "=", "5", ",", "return_scores", "=", "False", ")", ":", "# compute the estimated peak width from the data range", "tmin", ",", "tmax", "=", "np", ".", "min", "(", "model", ".", "t", ")", ...
43.240964
0.000817
def nrows(self): """Number of rows in the dataframe (int).""" if not self._ex._cache.nrows_valid(): self._ex._cache.flush() self._frame(fill_cache=True) return self._ex._cache.nrows
[ "def", "nrows", "(", "self", ")", ":", "if", "not", "self", ".", "_ex", ".", "_cache", ".", "nrows_valid", "(", ")", ":", "self", ".", "_ex", ".", "_cache", ".", "flush", "(", ")", "self", ".", "_frame", "(", "fill_cache", "=", "True", ")", "retu...
37.333333
0.008734
def supervisor_events(stdin, stdout): """ An event stream from Supervisor. """ while True: stdout.write('READY\n') stdout.flush() line = stdin.readline() headers = get_headers(line) payload = stdin.read(int(headers['len'])) event_headers, event_data = e...
[ "def", "supervisor_events", "(", "stdin", ",", "stdout", ")", ":", "while", "True", ":", "stdout", ".", "write", "(", "'READY\\n'", ")", "stdout", ".", "flush", "(", ")", "line", "=", "stdin", ".", "readline", "(", ")", "headers", "=", "get_headers", "...
22.157895
0.002278
def change(self, inpt, hashfun=DEFAULT_HASHFUN): """Change the avatar by providing a new input. Uses the standard hash function if no one is given.""" self.img = self.__create_image(inpt, hashfun)
[ "def", "change", "(", "self", ",", "inpt", ",", "hashfun", "=", "DEFAULT_HASHFUN", ")", ":", "self", ".", "img", "=", "self", ".", "__create_image", "(", "inpt", ",", "hashfun", ")" ]
54.25
0.009091
def main(): """Primary entry point; we supply '/', but the class brings '/metadata'""" app = apikit.APIFlask(name="Hello", version="0.0.1", repository="http://example.repo", description="Hello World App") # pylint: disable=unu...
[ "def", "main", "(", ")", ":", "app", "=", "apikit", ".", "APIFlask", "(", "name", "=", "\"Hello\"", ",", "version", "=", "\"0.0.1\"", ",", "repository", "=", "\"http://example.repo\"", ",", "description", "=", "\"Hello World App\"", ")", "# pylint: disable=unuse...
31.285714
0.008869
def _create_from_java_class(cls, java_class, *args): """ Construct this object from given Java classname and arguments """ java_obj = JavaWrapper._new_java_obj(java_class, *args) return cls(java_obj)
[ "def", "_create_from_java_class", "(", "cls", ",", "java_class", ",", "*", "args", ")", ":", "java_obj", "=", "JavaWrapper", ".", "_new_java_obj", "(", "java_class", ",", "*", "args", ")", "return", "cls", "(", "java_obj", ")" ]
39
0.008368
def follow_link(self, link=None, *args, **kwargs): """Follow a link. If ``link`` is a bs4.element.Tag (i.e. from a previous call to :func:`links` or :func:`find_link`), then follow the link. If ``link`` doesn't have a *href*-attribute or is None, treat ``link`` as a url_regex a...
[ "def", "follow_link", "(", "self", ",", "link", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "link", "=", "self", ".", "_find_link_internal", "(", "link", ",", "args", ",", "kwargs", ")", "referer", "=", "self", ".", "get_url", ...
39.909091
0.002225
def joliet_vd_factory(joliet, sys_ident, vol_ident, set_size, seqnum, log_block_size, vol_set_ident, pub_ident_str, preparer_ident_str, app_ident_str, copyright_file, abstract_file, bibli_file, vol_expire_date, app_use, xa): # type: (int, bytes, byte...
[ "def", "joliet_vd_factory", "(", "joliet", ",", "sys_ident", ",", "vol_ident", ",", "set_size", ",", "seqnum", ",", "log_block_size", ",", "vol_set_ident", ",", "pub_ident_str", ",", "preparer_ident_str", ",", "app_ident_str", ",", "copyright_file", ",", "abstract_f...
53.64
0.002197
def parse_content_type(content_type): """ Return a tuple of content type and charset. :param content_type: A string describing a content type. """ if '; charset=' in content_type: return tuple(content_type.split('; charset=')) else: if 'text' in content_type: encodin...
[ "def", "parse_content_type", "(", "content_type", ")", ":", "if", "'; charset='", "in", "content_type", ":", "return", "tuple", "(", "content_type", ".", "split", "(", "'; charset='", ")", ")", "else", ":", "if", "'text'", "in", "content_type", ":", "encoding"...
31.2
0.001555
def format_percentiles(percentiles): """ Outputs rounded and formatted percentiles. Parameters ---------- percentiles : list-like, containing floats from interval [0,1] Returns ------- formatted : list of strings Notes ----- Rounding precision is chosen so that: (1) if any...
[ "def", "format_percentiles", "(", "percentiles", ")", ":", "percentiles", "=", "np", ".", "asarray", "(", "percentiles", ")", "# It checks for np.NaN as well", "with", "np", ".", "errstate", "(", "invalid", "=", "'ignore'", ")", ":", "if", "not", "is_numeric_dty...
33.098361
0.000481
def is_helpful_search_term(search_term): """ Decide if the given search_term string is helpful or not. We define "helpful" here as search terms that won't match an excessive number of bug summaries. Very short terms and those matching generic strings (listed in the blacklist) are deemed unhelpful ...
[ "def", "is_helpful_search_term", "(", "search_term", ")", ":", "# Search terms that will match too many bug summaries", "# and so not result in useful suggestions.", "search_term", "=", "search_term", ".", "strip", "(", ")", "blacklist", "=", "[", "'automation.py'", ",", "'re...
31.74359
0.000784
def __driver_stub(self, text, state): """Display help messages or invoke the proper completer. The interface of helper methods and completer methods are documented in the helper() decorator method and the completer() decorator method, respectively. Arguments: text: ...
[ "def", "__driver_stub", "(", "self", ",", "text", ",", "state", ")", ":", "origline", "=", "readline", ".", "get_line_buffer", "(", ")", "line", "=", "origline", ".", "lstrip", "(", ")", "if", "line", "and", "line", "[", "-", "1", "]", "==", "'?'", ...
40.413793
0.001667
def load_module(self, fullname): """ Iterate over the search path to locate and load fullname. """ root, base, target = fullname.partition(self.root_name + '.') for prefix in self.search_path: try: extant = prefix + target __import__(ex...
[ "def", "load_module", "(", "self", ",", "fullname", ")", ":", "root", ",", "base", ",", "target", "=", "fullname", ".", "partition", "(", "self", ".", "root_name", "+", "'.'", ")", "for", "prefix", "in", "self", ".", "search_path", ":", "try", ":", "...
41.571429
0.001679
def get_raise_description_indexes(self, data, prev=None): """Get from a docstring the next raise's description. In javadoc style it is after @param. :param data: string to parse :param prev: index after the param element name (Default value = None) :returns: start and end indexe...
[ "def", "get_raise_description_indexes", "(", "self", ",", "data", ",", "prev", "=", "None", ")", ":", "start", ",", "end", "=", "-", "1", ",", "-", "1", "if", "not", "prev", ":", "_", ",", "prev", "=", "self", ".", "get_raise_indexes", "(", "data", ...
36.151515
0.001633
def _match(self, query): """Tries to match in dialogues, getters and setters and subcomponents :param query: message tuple :type query: Tuple[bytes] :return: response if found or None :rtype: Tuple[bytes] | None """ response = self._match_dialog(query) if...
[ "def", "_match", "(", "self", ",", "query", ")", ":", "response", "=", "self", ".", "_match_dialog", "(", "query", ")", "if", "response", "is", "not", "None", ":", "return", "response", "response", "=", "self", ".", "_match_getters", "(", "query", ")", ...
28.342857
0.001949
def get_splits(split_bed, gff_file, stype, key): """ Use intersectBed to find the fused gene => split genes mappings. """ bed_file = get_bed_file(gff_file, stype, key) cmd = "intersectBed -a {0} -b {1} -wao".format(split_bed, bed_file) cmd += " | cut -f4,10" p = popen(cmd) splits = defau...
[ "def", "get_splits", "(", "split_bed", ",", "gff_file", ",", "stype", ",", "key", ")", ":", "bed_file", "=", "get_bed_file", "(", "gff_file", ",", "stype", ",", "key", ")", "cmd", "=", "\"intersectBed -a {0} -b {1} -wao\"", ".", "format", "(", "split_bed", "...
29.071429
0.002381
def generate(organization, package, destination): """Generates the Sphinx configuration and Makefile. Args: organization (str): the organization name. package (str): the package to be documented. destination (str): the destination directory. """ gen = ResourceGenerator(organizat...
[ "def", "generate", "(", "organization", ",", "package", ",", "destination", ")", ":", "gen", "=", "ResourceGenerator", "(", "organization", ",", "package", ")", "tmp", "=", "tempfile", ".", "NamedTemporaryFile", "(", "mode", "=", "'w+t'", ",", "delete", "=",...
28.72
0.001348
def get_header(changelog): """Return line number of the first version-like header. We check for patterns like '2.10 (unreleased)', so with either 'unreleased' or a date between parenthesis as that's the format we're using. As an alternative, we support an alternative format used by some zope/plone pas...
[ "def", "get_header", "(", "changelog", ")", ":", "pattern", "=", "re", ".", "compile", "(", "r\"\"\"\n (?P<version>.+) # Version string\n \\( # Opening (\n (?P<date>.+) # Date\n \\) # Closing )\n \\W*$ # Possible whitespace at end o...
42.392857
0.000824
def get_current_time(self): """ Get current time :return: datetime.time """ hms = [int(self.get_current_controller_value(i)) for i in range(406, 409)] return datetime.time(*hms)
[ "def", "get_current_time", "(", "self", ")", ":", "hms", "=", "[", "int", "(", "self", ".", "get_current_controller_value", "(", "i", ")", ")", "for", "i", "in", "range", "(", "406", ",", "409", ")", "]", "return", "datetime", ".", "time", "(", "*", ...
27.375
0.013274
async def create_tunnel_connection(self, req): """Create a tunnel connection """ tunnel_address = req.tunnel_address connection = await self.create_connection(tunnel_address) response = connection.current_consumer() for event in response.events().values(): eve...
[ "async", "def", "create_tunnel_connection", "(", "self", ",", "req", ")", ":", "tunnel_address", "=", "req", ".", "tunnel_address", "connection", "=", "await", "self", ".", "create_connection", "(", "tunnel_address", ")", "response", "=", "connection", ".", "cur...
40.206897
0.001675
def calc_toa_gain_offset(meta): """ Compute (gain, offset) tuples for each band of the specified image metadata """ # Set satellite index to look up cal factors sat_index = meta['satid'].upper() + "_" + meta['bandid'].upper() # Set scale for at sensor radiance # Eq is: # L = GAIN * DN *...
[ "def", "calc_toa_gain_offset", "(", "meta", ")", ":", "# Set satellite index to look up cal factors", "sat_index", "=", "meta", "[", "'satid'", "]", ".", "upper", "(", ")", "+", "\"_\"", "+", "meta", "[", "'bandid'", "]", ".", "upper", "(", ")", "# Set scale f...
41.071429
0.001133
def ns_whois(self, nameservers, limit=DEFAULT_LIMIT, offset=DEFAULT_OFFSET, sort_field=DEFAULT_SORT): '''Gets the domains that have been registered with a nameserver or nameservers''' if not isinstance(nameservers, list): uri = self._uris["whois_ns"].format(nameservers) p...
[ "def", "ns_whois", "(", "self", ",", "nameservers", ",", "limit", "=", "DEFAULT_LIMIT", ",", "offset", "=", "DEFAULT_OFFSET", ",", "sort_field", "=", "DEFAULT_SORT", ")", ":", "if", "not", "isinstance", "(", "nameservers", ",", "list", ")", ":", "uri", "="...
53.416667
0.009202
def copy(self): """overload of Ensemble.copy() Returns ------- ObservationEnsemble : ObservationEnsemble """ df = super(Ensemble,self).copy() return type(self).from_dataframe(df=df,pst=self.pst.get())
[ "def", "copy", "(", "self", ")", ":", "df", "=", "super", "(", "Ensemble", ",", "self", ")", ".", "copy", "(", ")", "return", "type", "(", "self", ")", ".", "from_dataframe", "(", "df", "=", "df", ",", "pst", "=", "self", ".", "pst", ".", "get"...
24.9
0.015504
def visitIgnoreDirective(self, ctx: jsgParser.IgnoreDirectiveContext): """ directive: '.IGNORE' name* SEMI """ for name in as_tokens(ctx.name()): self._context.directives.append('_CONTEXT.IGNORE.append("{}")'.format(name))
[ "def", "visitIgnoreDirective", "(", "self", ",", "ctx", ":", "jsgParser", ".", "IgnoreDirectiveContext", ")", ":", "for", "name", "in", "as_tokens", "(", "ctx", ".", "name", "(", ")", ")", ":", "self", ".", "_context", ".", "directives", ".", "append", "...
61.75
0.012
def builtin_info(builtin): """Show information on a particular builtin template""" help_obj = load_template_help(builtin) if help_obj.get('name') and help_obj.get('help'): print("The %s template" % (help_obj['name'])) print(help_obj['help']) else: print("No help for %s" % builtin...
[ "def", "builtin_info", "(", "builtin", ")", ":", "help_obj", "=", "load_template_help", "(", "builtin", ")", "if", "help_obj", ".", "get", "(", "'name'", ")", "and", "help_obj", ".", "get", "(", "'help'", ")", ":", "print", "(", "\"The %s template\"", "%",...
37.583333
0.002165
def array_to_schedule(array, events, slots): """Convert a schedule from array to schedule form Parameters ---------- array : np.array An E by S array (X) where E is the number of events and S the number of slots. Xij is 1 if event i is scheduled in slot j and zero otherwise ...
[ "def", "array_to_schedule", "(", "array", ",", "events", ",", "slots", ")", ":", "scheduled", "=", "np", ".", "transpose", "(", "np", ".", "nonzero", "(", "array", ")", ")", "return", "[", "ScheduledItem", "(", "event", "=", "events", "[", "item", "[",...
29.75
0.001357
def do_string_set(self, element, decl, pseudo): """Implement string-set declaration.""" args = serialize(decl.value) step = self.state[self.state['current_step']] strval = '' strname = None for term in decl.value: if type(term) is ast.WhitespaceToken: ...
[ "def", "do_string_set", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "args", "=", "serialize", "(", "decl", ".", "value", ")", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "strva...
43.918182
0.000405
def status(self, name=''): """Return a list of the statuses of the `name` service, or if name is omitted, a list of the status of all services for this specific init system. There should be a standardization around the status fields. There currently isn't. `self.service...
[ "def", "status", "(", "self", ",", "name", "=", "''", ")", ":", "super", "(", "SystemD", ",", "self", ")", ".", "status", "(", "name", "=", "name", ")", "svc_list", "=", "sh", ".", "systemctl", "(", "'--no-legend'", ",", "'--no-pager'", ",", "t", "...
39.75
0.002457
def jhk_to_sdssg(jmag,hmag,kmag): '''Converts given J, H, Ks mags to an SDSS g magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted SDSS g band magnitude. ''' return convert_constant...
[ "def", "jhk_to_sdssg", "(", "jmag", ",", "hmag", ",", "kmag", ")", ":", "return", "convert_constants", "(", "jmag", ",", "hmag", ",", "kmag", ",", "SDSSG_JHK", ",", "SDSSG_JH", ",", "SDSSG_JK", ",", "SDSSG_HK", ",", "SDSSG_J", ",", "SDSSG_H", ",", "SDSSG...
22.47619
0.010163
def run(self): """ Run time domain simulation Returns ------- bool Success flag """ ret = False system = self.system config = self.config dae = self.system.dae # maxit = config.maxit # tol = config.tol ...
[ "def", "run", "(", "self", ")", ":", "ret", "=", "False", "system", "=", "self", ".", "system", "config", "=", "self", ".", "config", "dae", "=", "self", ".", "system", ".", "dae", "# maxit = config.maxit", "# tol = config.tol", "if", "system", ".", "pfl...
29.459259
0.001946
def _find_cert_in_list(cert, issuer, certificate_list, crl_issuer): """ Looks for a cert in the list of revoked certificates :param cert: An asn1crypto.x509.Certificate object of the cert being checked :param issuer: An asn1crypto.x509.Certificate object of the cert issuer :param ...
[ "def", "_find_cert_in_list", "(", "cert", ",", "issuer", ",", "certificate_list", ",", "crl_issuer", ")", ":", "revoked_certificates", "=", "certificate_list", "[", "'tbs_cert_list'", "]", "[", "'revoked_certificates'", "]", "cert_serial", "=", "cert", ".", "serial_...
32.053571
0.001622
def toggle_service(self): """ Convenience method for toggling the expansion service on or off. This is called by the global hotkey. """ self.monitoring_disabled.emit(not self.service.is_running()) if self.service.is_running(): self.pause_service() else: ...
[ "def", "toggle_service", "(", "self", ")", ":", "self", ".", "monitoring_disabled", ".", "emit", "(", "not", "self", ".", "service", ".", "is_running", "(", ")", ")", "if", "self", ".", "service", ".", "is_running", "(", ")", ":", "self", ".", "pause_s...
37.777778
0.008621
def plot_carpet(img, atlaslabels, detrend=True, nskip=0, size=(950, 800), subplot=None, title=None, output_file=None, legend=False, lut=None, tr=None): """ Plot an image representation of voxel intensities across time also know as the "carpet plot" or "Power plot". See Jonath...
[ "def", "plot_carpet", "(", "img", ",", "atlaslabels", ",", "detrend", "=", "True", ",", "nskip", "=", "0", ",", "size", "=", "(", "950", ",", "800", ")", ",", "subplot", "=", "None", ",", "title", "=", "None", ",", "output_file", "=", "None", ",", ...
34.251534
0.001741
def _getFeatureById(self, featureId): """ find a feature and return ga4gh representation, use 'native' id as featureId """ featureRef = rdflib.URIRef(featureId) featureDetails = self._detailTuples([featureRef]) feature = {} for detail in featureDetails: ...
[ "def", "_getFeatureById", "(", "self", ",", "featureId", ")", ":", "featureRef", "=", "rdflib", ".", "URIRef", "(", "featureId", ")", "featureDetails", "=", "self", ".", "_detailTuples", "(", "[", "featureRef", "]", ")", "feature", "=", "{", "}", "for", ...
37.511111
0.001155
def find_consensus(bases): """ find consensus base based on nucleotide frequencies """ nucs = ['A', 'T', 'G', 'C', 'N'] total = sum([bases[nuc] for nuc in nucs if nuc in bases]) # save most common base as consensus (random nuc if there is a tie) try: top = max([bases[nuc] for nuc...
[ "def", "find_consensus", "(", "bases", ")", ":", "nucs", "=", "[", "'A'", ",", "'T'", ",", "'G'", ",", "'C'", ",", "'N'", "]", "total", "=", "sum", "(", "[", "bases", "[", "nuc", "]", "for", "nuc", "in", "nucs", "if", "nuc", "in", "bases", "]",...
32.875
0.001847
def _run_command(self, command_constructor, args): """ Run command_constructor and call run(args) on the resulting object :param command_constructor: class of an object that implements run(args) :param args: object arguments for specific command created by CommandParser """ ...
[ "def", "_run_command", "(", "self", ",", "command_constructor", ",", "args", ")", ":", "verify_terminal_encoding", "(", "sys", ".", "stdout", ".", "encoding", ")", "self", ".", "_check_pypi_version", "(", ")", "config", "=", "create_config", "(", "allow_insecure...
50.916667
0.008039
def _definition_from_example(example): """Generates a swagger definition json from a given example Works only for simple types in the dict Args: example: The example for which we want a definition Type is DICT Returns: A dict that is the ...
[ "def", "_definition_from_example", "(", "example", ")", ":", "assert", "isinstance", "(", "example", ",", "dict", ")", "def", "_has_simple_type", "(", "value", ")", ":", "accepted", "=", "(", "str", ",", "int", ",", "float", ",", "bool", ")", "return", "...
34.315789
0.001491
def initRnaQuantificationSet(self): """ Initialize an empty RNA quantification set """ store = rnaseq2ga.RnaSqliteStore(self._args.filePath) store.createTables()
[ "def", "initRnaQuantificationSet", "(", "self", ")", ":", "store", "=", "rnaseq2ga", ".", "RnaSqliteStore", "(", "self", ".", "_args", ".", "filePath", ")", "store", ".", "createTables", "(", ")" ]
32.666667
0.00995
def vcf_records(self, format_tags=None, qualified=False): """Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualifi...
[ "def", "vcf_records", "(", "self", ",", "format_tags", "=", "None", ",", "qualified", "=", "False", ")", ":", "if", "qualified", ":", "sample_names", "=", "self", ".", "qualified_sample_names", "else", ":", "sample_names", "=", "self", ".", "sample_names", "...
33.689655
0.00199
def serialize_data_tuple(self, stream_id, latency_in_ns): """Apply update to serialization metrics""" self.update_count(self.TUPLE_SERIALIZATION_TIME_NS, incr_by=latency_in_ns, key=stream_id)
[ "def", "serialize_data_tuple", "(", "self", ",", "stream_id", ",", "latency_in_ns", ")", ":", "self", ".", "update_count", "(", "self", ".", "TUPLE_SERIALIZATION_TIME_NS", ",", "incr_by", "=", "latency_in_ns", ",", "key", "=", "stream_id", ")" ]
65.666667
0.01005