text
stringlengths
89
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
630
def unattach_issue(context, id, issue_id): """unattach_issue(context, id, issue_id) Unattach an issue from a job. >>> dcictl job-unattach-issue [OPTIONS] :param string id: ID of the job to attach the issue to [required] :param string issue_id: ID of the issue to unattach from the job [required] ...
[ "def", "unattach_issue", "(", "context", ",", "id", ",", "issue_id", ")", ":", "result", "=", "job", ".", "unattach_issue", "(", "context", ",", "id", "=", "id", ",", "issue_id", "=", "issue_id", ")", "if", "result", ".", "status_code", "==", "204", ":...
34
21.4375
def _compute_oneletter(self): """ m._compute_oneletter() -- [utility] Set the oneletter member variable """ letters = [] for i in range(self.width): downcase = None if self.bits[i] < 0.25: letters.append('.') continue ...
[ "def", "_compute_oneletter", "(", "self", ")", ":", "letters", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "width", ")", ":", "downcase", "=", "None", "if", "self", ".", "bits", "[", "i", "]", "<", "0.25", ":", "letters", ".", "ap...
38.555556
12.259259
def return_main_dataset(self): """Returns main data set from self Returns: X (numpy.ndarray): Features y (numpy.ndarray): Labels """ if not self.main_dataset['source']: raise exceptions.UserError('Source is empty') extraction_code = self.mai...
[ "def", "return_main_dataset", "(", "self", ")", ":", "if", "not", "self", ".", "main_dataset", "[", "'source'", "]", ":", "raise", "exceptions", ".", "UserError", "(", "'Source is empty'", ")", "extraction_code", "=", "self", ".", "main_dataset", "[", "\"sourc...
32
22.565217
def makeHist(x_val, y_val, fit=spline_base.fit2d, bins=[np.linspace(-36.5,36.5,74),np.linspace(-180,180,361)]): """ Constructs a (fitted) histogram of the given data. Parameters: x_val : array The data to be histogrammed along the x-axis. y_val : array ...
[ "def", "makeHist", "(", "x_val", ",", "y_val", ",", "fit", "=", "spline_base", ".", "fit2d", ",", "bins", "=", "[", "np", ".", "linspace", "(", "-", "36.5", ",", "36.5", ",", "74", ")", ",", "np", ".", "linspace", "(", "-", "180", ",", "180", "...
35.34375
19.21875
def refund(self, idempotency_key=None, **params): """Return a deferred.""" headers = populate_headers(idempotency_key) url = self.instance_url() + '/refund' d = self.request('post', url, params, headers) return d.addCallback(self.refresh_from).addCallback(lambda _: self)
[ "def", "refund", "(", "self", ",", "idempotency_key", "=", "None", ",", "*", "*", "params", ")", ":", "headers", "=", "populate_headers", "(", "idempotency_key", ")", "url", "=", "self", ".", "instance_url", "(", ")", "+", "'/refund'", "d", "=", "self", ...
51
12.333333
def parsefile(self, filename): """Parse from the file """ with open(filename, 'rb') as fd: return self.parse(fd.read())
[ "def", "parsefile", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "fd", ":", "return", "self", ".", "parse", "(", "fd", ".", "read", "(", ")", ")" ]
30.2
2
def guess_url(url): """Guess if URL is a http or ftp URL. @param url: the URL to check @ptype url: unicode @return: url with http:// or ftp:// prepended if it's detected as a http respective ftp URL. @rtype: unicode """ if url.lower().startswith("www."): # syntactic sugar ...
[ "def", "guess_url", "(", "url", ")", ":", "if", "url", ".", "lower", "(", ")", ".", "startswith", "(", "\"www.\"", ")", ":", "# syntactic sugar", "return", "\"http://%s\"", "%", "url", "elif", "url", ".", "lower", "(", ")", ".", "startswith", "(", "\"f...
29.8
11.933333
def read_dicom_directory(dicom_directory, stop_before_pixels=False): """ Read all dicom files in a given directory (stop before pixels) :type stop_before_pixels: bool :type dicom_directory: six.string_types :param stop_before_pixels: Should we stop reading before the pixeldata (handy if we only wan...
[ "def", "read_dicom_directory", "(", "dicom_directory", ",", "stop_before_pixels", "=", "False", ")", ":", "dicom_input", "=", "[", "]", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "dicom_directory", ")", ":", "for", "dicom_file", "...
50.727273
22.636364
def show_table(name, table, i, total): """ Display table info, name is tablename table is table object i is current Index total is total of tables """ return '[%d/%d, %s] %s' % (i+1, total, table.__appname__, name)
[ "def", "show_table", "(", "name", ",", "table", ",", "i", ",", "total", ")", ":", "return", "'[%d/%d, %s] %s'", "%", "(", "i", "+", "1", ",", "total", ",", "table", ".", "__appname__", ",", "name", ")" ]
26.444444
12.222222
def _parse_sensorupdate(self, msg): """ Given a sensor-update message, returns the sensors/variables that were updated as a dict that maps sensors/variables to their updated values. """ update = msg[self.sensorupdate_prefix_len:] parsed = [] # each element is either a sen...
[ "def", "_parse_sensorupdate", "(", "self", ",", "msg", ")", ":", "update", "=", "msg", "[", "self", ".", "sensorupdate_prefix_len", ":", "]", "parsed", "=", "[", "]", "# each element is either a sensor (key) or a sensor value", "curr_seg", "=", "''", "# current segm...
50.708333
19.041667
def get_info(domain_name): ''' Returns information about the requested domain returns a dictionary of information about the domain_name domain_name string Domain name to get information about CLI Example: .. code-block:: bash salt 'my-minion' namecheap_domains.get_info my-d...
[ "def", "get_info", "(", "domain_name", ")", ":", "opts", "=", "salt", ".", "utils", ".", "namecheap", ".", "get_opts", "(", "'namecheap.domains.getinfo'", ")", "opts", "[", "'DomainName'", "]", "=", "domain_name", "response_xml", "=", "salt", ".", "utils", "...
26.153846
28
def getDistrict(self, default=None): """Return the Province from the Physical or Postal Address """ physical_address = self.getPhysicalAddress().get("district", default) postal_address = self.getPostalAddress().get("district", default) return physical_address or postal_address
[ "def", "getDistrict", "(", "self", ",", "default", "=", "None", ")", ":", "physical_address", "=", "self", ".", "getPhysicalAddress", "(", ")", ".", "get", "(", "\"district\"", ",", "default", ")", "postal_address", "=", "self", ".", "getPostalAddress", "(",...
52
13.833333
def prev(self): """ Generate query parameters for the prev page """ if self.total: if self.offset - self.limit - self.limit < 0: return self.first else: offset = self.offset - self.limit return {'page[offset]': offset, 'page[limit]...
[ "def", "prev", "(", "self", ")", ":", "if", "self", ".", "total", ":", "if", "self", ".", "offset", "-", "self", ".", "limit", "-", "self", ".", "limit", "<", "0", ":", "return", "self", ".", "first", "else", ":", "offset", "=", "self", ".", "o...
32.909091
19.727273
def import_crud(app): ''' Import crud module and register all model cruds which it contains ''' try: app_path = import_module(app).__path__ except (AttributeError, ImportError): return None try: imp.find_module('crud', app_path) except ImportError: return No...
[ "def", "import_crud", "(", "app", ")", ":", "try", ":", "app_path", "=", "import_module", "(", "app", ")", ".", "__path__", "except", "(", "AttributeError", ",", "ImportError", ")", ":", "return", "None", "try", ":", "imp", ".", "find_module", "(", "'cru...
20.5
23.944444
def add_meta(self, name, value): """ Add a pair of meta data to the definition :param name: name of the meta :type name: str :param value: value of the meta :type value: str """ for mt in self.metas: if mt.name == name: mt.valu...
[ "def", "add_meta", "(", "self", ",", "name", ",", "value", ")", ":", "for", "mt", "in", "self", ".", "metas", ":", "if", "mt", ".", "name", "==", "name", ":", "mt", ".", "value", "=", "value", "return", "self", "self", ".", "metas", ".", "append"...
27.4
10.866667
def can_see_members(self, user): """Determine if given user can see other group members. :param user: User to be checked. :returns: True or False. """ if self.privacy_policy == PrivacyPolicy.PUBLIC: return True elif self.privacy_policy == PrivacyPolicy.MEMBER...
[ "def", "can_see_members", "(", "self", ",", "user", ")", ":", "if", "self", ".", "privacy_policy", "==", "PrivacyPolicy", ".", "PUBLIC", ":", "return", "True", "elif", "self", ".", "privacy_policy", "==", "PrivacyPolicy", ".", "MEMBERS", ":", "return", "self...
39.25
12.25
def method(self, method): """ Defines the HTTP method to match. Use ``*`` to match any method. Arguments: method (str): method value to match. E.g: ``GET``. Returns: self: current Mock instance. """ self._request.method = method s...
[ "def", "method", "(", "self", ",", "method", ")", ":", "self", ".", "_request", ".", "method", "=", "method", "self", ".", "add_matcher", "(", "matcher", "(", "'MethodMatcher'", ",", "method", ")", ")" ]
27.461538
14.384615
def average_overlap_ratio(ref_intervals, est_intervals, matching): """Compute the Average Overlap Ratio between a reference and estimated note transcription. Given a reference and corresponding estimated note, their overlap ratio (OR) is defined as the ratio between the duration of the time segment in w...
[ "def", "average_overlap_ratio", "(", "ref_intervals", ",", "est_intervals", ",", "matching", ")", ":", "ratios", "=", "[", "]", "for", "match", "in", "matching", ":", "ref_int", "=", "ref_intervals", "[", "match", "[", "0", "]", "]", "est_int", "=", "est_i...
42.36
24.82
def showOperandLines(rh): """ Produce help output related to operands. Input: Request Handle """ if rh.function == 'HELP': rh.printLn("N", " For the GetHost function:") else: rh.printLn("N", "Sub-Functions(s):") rh.printLn("N", " diskpoolnames - " + "Re...
[ "def", "showOperandLines", "(", "rh", ")", ":", "if", "rh", ".", "function", "==", "'HELP'", ":", "rh", ".", "printLn", "(", "\"N\"", ",", "\" For the GetHost function:\"", ")", "else", ":", "rh", ".", "printLn", "(", "\"N\"", ",", "\"Sub-Functions(s):\"", ...
37.586207
18.482759
def delete_tag(self, tag_name, **kwargs): """delete a tag by name Args: tag_name (string): name of tag to delete """ resp = self._delete(self._u(self._TAG_ENDPOINT_SUFFIX, tag_name), **kwargs) resp.raise_for_status() # successful d...
[ "def", "delete_tag", "(", "self", ",", "tag_name", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "self", ".", "_delete", "(", "self", ".", "_u", "(", "self", ".", "_TAG_ENDPOINT_SUFFIX", ",", "tag_name", ")", ",", "*", "*", "kwargs", ")", "resp", ...
34.272727
15.909091
def brecv(self, picture, *args): """ Receive a binary encoded 'picture' message from the socket (or actor). This method is similar to zsock_recv, except the arguments are encoded in a binary format that is compatible with zproto, and is designed to reduce memory allocations. The pattern argument is a st...
[ "def", "brecv", "(", "self", ",", "picture", ",", "*", "args", ")", ":", "return", "lib", ".", "zsock_brecv", "(", "self", ".", "_as_parameter_", ",", "picture", ",", "*", "args", ")" ]
53.190476
21
def run(self, hosts, function, attempts=1): """ Add the given function to a queue, and call it once for each host according to the threading options. Use decorators.bind() if you also want to pass additional arguments to the callback function. Returns an object that repr...
[ "def", "run", "(", "self", ",", "hosts", ",", "function", ",", "attempts", "=", "1", ")", ":", "return", "self", ".", "_run", "(", "hosts", ",", "function", ",", "self", ".", "workqueue", ".", "enqueue", ",", "attempts", ")" ]
42.8
17.3
def create_course_provisioning_report(self, account_id, term_id=None, params={}): """ Convenience method for create_report, for creating a course provisioning report. """ params["courses"] = True return self.create_report(ReportTy...
[ "def", "create_course_provisioning_report", "(", "self", ",", "account_id", ",", "term_id", "=", "None", ",", "params", "=", "{", "}", ")", ":", "params", "[", "\"courses\"", "]", "=", "True", "return", "self", ".", "create_report", "(", "ReportType", ".", ...
43.444444
14.333333
def autocorrplot(trace, vars=None, fontmap = None, max_lag=100): """Bar plot of the autocorrelation function for a trace""" try: # MultiTrace traces = trace.traces except AttributeError: # NpTrace traces = [trace] if fontmap is None: fontmap = {1:10, 2:8, 3:6, 4:5, 5:...
[ "def", "autocorrplot", "(", "trace", ",", "vars", "=", "None", ",", "fontmap", "=", "None", ",", "max_lag", "=", "100", ")", ":", "try", ":", "# MultiTrace", "traces", "=", "trace", ".", "traces", "except", "AttributeError", ":", "# NpTrace", "traces", "...
23.9375
22.770833
def retrieve_by_name(self, name, first_certificate=None): """ Retrieves a list certs via their subject name :param name: An asn1crypto.x509.Name object :param first_certificate: An asn1crypto.x509.Certificate object that if found, should be placed fi...
[ "def", "retrieve_by_name", "(", "self", ",", "name", ",", "first_certificate", "=", "None", ")", ":", "if", "not", "isinstance", "(", "name", ",", "x509", ".", "Name", ")", ":", "raise", "TypeError", "(", "pretty_message", "(", "'''\n name must ...
29.729167
19.395833
def spotlight(self, query, **kwargs): """Searches for users or rooms that are visible to the user.""" return self.__call_api_get('spotlight', query=query, kwargs=kwargs)
[ "def", "spotlight", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_get", "(", "'spotlight'", ",", "query", "=", "query", ",", "kwargs", "=", "kwargs", ")" ]
61
12.666667
def __parse_args(self, accept_unrecognized_args=False): """ Invoke the argument parser. """ # If the user provided a description, use it. Otherwise grab the doc string. if self.description: self.argparser.description = self.description elif getattr(sys.modules['__main__'], '...
[ "def", "__parse_args", "(", "self", ",", "accept_unrecognized_args", "=", "False", ")", ":", "# If the user provided a description, use it. Otherwise grab the doc string.", "if", "self", ".", "description", ":", "self", ".", "argparser", ".", "description", "=", "self", ...
46.190476
27.952381
def elements(compounds): """ Determine the set of elements present in a list of chemical compounds. The list of elements is sorted alphabetically. :param compounds: List of compound formulas and phases, e.g. ['Fe2O3[S1]', 'Al2O3[S1]']. :returns: List of elements. """ elementlist = ...
[ "def", "elements", "(", "compounds", ")", ":", "elementlist", "=", "[", "parse_compound", "(", "compound", ")", ".", "count", "(", ")", ".", "keys", "(", ")", "for", "compound", "in", "compounds", "]", "return", "set", "(", ")", ".", "union", "(", "*...
28.6
19.133333
def _is_len_call(node): """Checks if node is len(SOMETHING).""" return ( isinstance(node, astroid.Call) and isinstance(node.func, astroid.Name) and node.func.name == "len" )
[ "def", "_is_len_call", "(", "node", ")", ":", "return", "(", "isinstance", "(", "node", ",", "astroid", ".", "Call", ")", "and", "isinstance", "(", "node", ".", "func", ",", "astroid", ".", "Name", ")", "and", "node", ".", "func", ".", "name", "==", ...
29
13.428571
def timed_cache(timeout, max_size=128): """ Time based decorator, implementing :class:`faste.caches.TimeoutCache` :param int timeout: Cache key timeout :param int max_size: (keyword) max size. """ def actual_decorator(func): return _cached_func(func, caches.TimeoutCache, timeout, max_...
[ "def", "timed_cache", "(", "timeout", ",", "max_size", "=", "128", ")", ":", "def", "actual_decorator", "(", "func", ")", ":", "return", "_cached_func", "(", "func", ",", "caches", ".", "TimeoutCache", ",", "timeout", ",", "max_size", "=", "max_size", ")",...
27
20.230769
def setattr(d, **kwarg): """Set an attribute. set attributes is actually add a special key, value pair in this dict under key = "_meta". Usage:: >>> DT.setattr(d, population=27800000) >>> d {'_meta': {'population': 27800000, '_rootname': 'US'}} ...
[ "def", "setattr", "(", "d", ",", "*", "*", "kwarg", ")", ":", "if", "_meta", "not", "in", "d", ":", "d", "[", "_meta", "]", "=", "dict", "(", ")", "for", "k", ",", "v", "in", "kwarg", ".", "items", "(", ")", ":", "d", "[", "_meta", "]", "...
27
19.5625
def get_my_subreddits(self, *args, **kwargs): """Return a get_content generator of subreddits. The subreddits generated are those that hat the session's user is subscribed to. The additional parameters are passed directly into :meth:`.get_content`. Note: the `url` parameter can...
[ "def", "get_my_subreddits", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_content", "(", "self", ".", "config", "[", "'my_subreddits'", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
37.909091
24.181818
def igraph2pandas(self, ig): """Under current bindings, transform an IGraph into a pandas edges dataframe and a nodes dataframe. **Example** :: import graphistry g = graphistry.bind() es = pandas.DataFrame({'src': [0,1,2], 'dst': [1,2,0]}) ...
[ "def", "igraph2pandas", "(", "self", ",", "ig", ")", ":", "def", "get_edgelist", "(", "ig", ")", ":", "idmap", "=", "dict", "(", "enumerate", "(", "ig", ".", "vs", "[", "self", ".", "_node", "]", ")", ")", "for", "e", "in", "ig", ".", "es", ":"...
38.717949
21.076923
def datalab(line, cell=None): """Implements the datalab cell magic for ipython notebooks. Args: line: the contents of the datalab line. Returns: The results of executing the cell. """ parser = google.datalab.utils.commands.CommandParser( prog='%datalab', description=""" Execute operations...
[ "def", "datalab", "(", "line", ",", "cell", "=", "None", ")", ":", "parser", "=", "google", ".", "datalab", ".", "utils", ".", "commands", ".", "CommandParser", "(", "prog", "=", "'%datalab'", ",", "description", "=", "\"\"\"\nExecute operations that apply to ...
36.153846
17.903846
def addProteinGroup(self, groupRepresentative): """Adds a new protein group and returns the groupId. The groupId is defined using an internal counter, which is incremented every time a protein group is added. The groupRepresentative is added as a leading protein. :param groupRe...
[ "def", "addProteinGroup", "(", "self", ",", "groupRepresentative", ")", ":", "groupId", "=", "self", ".", "_getNextGroupId", "(", ")", "self", ".", "groups", "[", "groupId", "]", "=", "ProteinGroup", "(", "groupId", ",", "groupRepresentative", ")", "self", "...
44
20.214286
def set_interface(interface, name=''): """ don't want to bother with a dsn? Use this method to make an interface available """ global interfaces if not interface: raise ValueError('interface is empty') # close down the interface before we discard it if name in interfaces: interface...
[ "def", "set_interface", "(", "interface", ",", "name", "=", "''", ")", ":", "global", "interfaces", "if", "not", "interface", ":", "raise", "ValueError", "(", "'interface is empty'", ")", "# close down the interface before we discard it", "if", "name", "in", "interf...
27.461538
18.846154
def describe_spot_price_history(DryRun=None, StartTime=None, EndTime=None, InstanceTypes=None, ProductDescriptions=None, Filters=None, AvailabilityZone=None, MaxResults=None, NextToken=None): """ Describes the Spot price history. For more information, see Spot Instance Pricing History in the Amazon Elastic Comp...
[ "def", "describe_spot_price_history", "(", "DryRun", "=", "None", ",", "StartTime", "=", "None", ",", "EndTime", "=", "None", ",", "InstanceTypes", "=", "None", ",", "ProductDescriptions", "=", "None", ",", "Filters", "=", "None", ",", "AvailabilityZone", "=",...
69.548387
61.978495
def select_directory_dialog(windowTitle, defaultPath=os.getcwd(), style=None): """ Opens a directory selection dialog Style - specifies style of dialog (read wx documentation for information) """ app = wx.App(None) if style == None: style = wx.DD_DIR_MUST_EXIST dialog = wx.DirDialo...
[ "def", "select_directory_dialog", "(", "windowTitle", ",", "defaultPath", "=", "os", ".", "getcwd", "(", ")", ",", "style", "=", "None", ")", ":", "app", "=", "wx", ".", "App", "(", "None", ")", "if", "style", "==", "None", ":", "style", "=", "wx", ...
29.470588
22.941176
def autoescape(context, nodelist, setting): """ Force autoescape behaviour for this block. """ old_setting = context.autoescape context.autoescape = setting output = nodelist.render(context) context.autoescape = old_setting if setting: return mark_safe(output) else: r...
[ "def", "autoescape", "(", "context", ",", "nodelist", ",", "setting", ")", ":", "old_setting", "=", "context", ".", "autoescape", "context", ".", "autoescape", "=", "setting", "output", "=", "nodelist", ".", "render", "(", "context", ")", "context", ".", "...
26.75
9.25
def pair_looper(iterator): ''' Loop through iterator yielding items in adjacent pairs ''' left = START for item in iterator: if left is not START: yield (left, item) left = item
[ "def", "pair_looper", "(", "iterator", ")", ":", "left", "=", "START", "for", "item", "in", "iterator", ":", "if", "left", "is", "not", "START", ":", "yield", "(", "left", ",", "item", ")", "left", "=", "item" ]
24.111111
19.888889
def link_type(arg_type, arg_name=None, include_bt:bool=True): "Create link to documentation." arg_name = arg_name or fn_name(arg_type) if include_bt: arg_name = code_esc(arg_name) if belongs_to_module(arg_type, 'torch') and ('Tensor' not in arg_name): return f'[{arg_name}]({get_pytorch_link(arg_type)})'...
[ "def", "link_type", "(", "arg_type", ",", "arg_name", "=", "None", ",", "include_bt", ":", "bool", "=", "True", ")", ":", "arg_name", "=", "arg_name", "or", "fn_name", "(", "arg_type", ")", "if", "include_bt", ":", "arg_name", "=", "code_esc", "(", "arg_...
59.428571
26.857143
def _get_function_id(self): """Calculate the function id of current function descriptor. This function id is calculated from all the fields of function descriptor. Returns: ray.ObjectID to represent the function descriptor. """ if self.is_for_driver_task: ...
[ "def", "_get_function_id", "(", "self", ")", ":", "if", "self", ".", "is_for_driver_task", ":", "return", "ray", ".", "FunctionID", ".", "nil", "(", ")", "function_id_hash", "=", "hashlib", ".", "sha1", "(", ")", "# Include the function module and name in the hash...
41.25
16.3
def background_noise(self): """ Gaussian sigma of noise level per pixel (in counts per second) :return: sqrt(variance) of background noise level """ if self._background_noise is None: return data_util.bkg_noise(self.read_noise, self._exposure_time, self.sky_brightnes...
[ "def", "background_noise", "(", "self", ")", ":", "if", "self", ".", "_background_noise", "is", "None", ":", "return", "data_util", ".", "bkg_noise", "(", "self", ".", "read_noise", ",", "self", ".", "_exposure_time", ",", "self", ".", "sky_brightness", ",",...
41.454545
21.272727
def SVD(stream_list, full=False): """ Depreciated. Use svd. """ warnings.warn('Depreciated, use svd instead.') return svd(stream_list=stream_list, full=full)
[ "def", "SVD", "(", "stream_list", ",", "full", "=", "False", ")", ":", "warnings", ".", "warn", "(", "'Depreciated, use svd instead.'", ")", "return", "svd", "(", "stream_list", "=", "stream_list", ",", "full", "=", "full", ")" ]
28.666667
7
def _get_user_info(self, cmd, section, required=True, accept_just_who=False): """Parse a user section.""" line = self.next_line() if line.startswith(section + b' '): return self._who_when(line[len(section + b' '):], cmd, section, accept_just_who=accept_just_wh...
[ "def", "_get_user_info", "(", "self", ",", "cmd", ",", "section", ",", "required", "=", "True", ",", "accept_just_who", "=", "False", ")", ":", "line", "=", "self", ".", "next_line", "(", ")", "if", "line", ".", "startswith", "(", "section", "+", "b' '...
38.75
13.833333
def subst(self, string, raw=0, target=None, source=None, conv=None, executor=None): """Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result. Construction variables are specified by a $ prefix in the string and begi...
[ "def", "subst", "(", "self", ",", "string", ",", "raw", "=", "0", ",", "target", "=", "None", ",", "source", "=", "None", ",", "conv", "=", "None", ",", "executor", "=", "None", ")", ":", "gvars", "=", "self", ".", "gvars", "(", ")", "lvars", "...
52.0625
20.3125
def timedelta_range(start=None, end=None, periods=None, freq=None, name=None, closed=None): """ Return a fixed frequency TimedeltaIndex, with day as the default frequency Parameters ---------- start : string or timedelta-like, default None Left bound for generating t...
[ "def", "timedelta_range", "(", "start", "=", "None", ",", "end", "=", "None", ",", "periods", "=", "None", ",", "freq", "=", "None", ",", "name", "=", "None", ",", "closed", "=", "None", ")", ":", "if", "freq", "is", "None", "and", "com", ".", "_...
39
23
def set_default_alarm_ranges(self, parameter, watch=None, warning=None, distress=None, critical=None, severe=None, min_violations=1): """ Generate out-of-limit alarms for a parameter using the specified alarm ranges. This...
[ "def", "set_default_alarm_ranges", "(", "self", ",", "parameter", ",", "watch", "=", "None", ",", "warning", "=", "None", ",", "distress", "=", "None", ",", "critical", "=", "None", ",", "severe", "=", "None", ",", "min_violations", "=", "1", ")", ":", ...
53.526316
28.263158
def filter(cls, start_position="", max_results="", qb=None, **kwargs): """ :param start_position: :param max_results: :param qb: :param kwargs: field names and values to filter the query :return: Filtered list """ return cls.where(build_where_clause(**kwar...
[ "def", "filter", "(", "cls", ",", "start_position", "=", "\"\"", ",", "max_results", "=", "\"\"", ",", "qb", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "cls", ".", "where", "(", "build_where_clause", "(", "*", "*", "kwargs", ")", ",", ...
40.3
17.1
def user_timeline(self, delegate, user=None, params={}, extra_args=None): """Get the most recent updates for a user. If no user is specified, the statuses for the authenticating user are returned. See search for example of how results are returned.""" if user: param...
[ "def", "user_timeline", "(", "self", ",", "delegate", ",", "user", "=", "None", ",", "params", "=", "{", "}", ",", "extra_args", "=", "None", ")", ":", "if", "user", ":", "params", "[", "'id'", "]", "=", "user", "return", "self", ".", "__get", "(",...
42.090909
23.909091
def _insert_dummy_cart(self, exception, last_valid_cartesian=None): """Insert dummy atom into the already built cartesian of exception """ def get_normal_vec(cartesian, reference_labels): b_pos, a_pos, d_pos = cartesian._get_positions(reference_labels) BA = a_pos - b_pos ...
[ "def", "_insert_dummy_cart", "(", "self", ",", "exception", ",", "last_valid_cartesian", "=", "None", ")", ":", "def", "get_normal_vec", "(", "cartesian", ",", "reference_labels", ")", ":", "b_pos", ",", "a_pos", ",", "d_pos", "=", "cartesian", ".", "_get_posi...
45.185185
15.814815
def write(self, fh, deparsed=None): """Write the currently parsed RiveScript data into a file. Pass either a file name (string) or a file handle object. This uses ``deparse()`` to dump a representation of the loaded data and writes it to the destination file. If you provide your own da...
[ "def", "write", "(", "self", ",", "fh", ",", "deparsed", "=", "None", ")", ":", "# Passed a string instead of a file handle?", "if", "type", "(", "fh", ")", "is", "str", ":", "fh", "=", "codecs", ".", "open", "(", "fh", ",", "\"w\"", ",", "\"utf-8\"", ...
37.653465
21.267327
def Rock(*args, **kwargs): """ Graceful deprecation for old class name. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "The 'Rock' class was renamed 'Component'. " w += "Please update your code." warnings.warn(w, DeprecationWarning, stacklevel=2)...
[ "def", "Rock", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "w", "=", "\"The 'Rock' class was renamed 'Component'. \"", "w", "+=", "\"P...
29
11.833333
def download(self, id, directory_path='.', checksum=True): """Download a product. Uses the filename on the server for the downloaded file, e.g. "S1A_EW_GRDH_1SDH_20141003T003840_20141003T003920_002658_002F54_4DD1.zip". Incomplete downloads are continued and complete files are skipped. ...
[ "def", "download", "(", "self", ",", "id", ",", "directory_path", "=", "'.'", ",", "checksum", "=", "True", ")", ":", "product_info", "=", "self", ".", "get_product_odata", "(", "id", ")", "path", "=", "join", "(", "directory_path", ",", "product_info", ...
40.888889
22.433333
def project_onto_potential(r, pot_name, *args): """ TODO: add documentation """ pot = globals()[pot_name] dpdx = globals()['d%sdx'%(pot_name)] dpdy = globals()['d%sdy'%(pot_name)] dpdz = globals()['d%sdz'%(pot_name)] dpdr = globals()['d%sdr'%(pot_name)] n_iter = 0 rmag, rmag0 ...
[ "def", "project_onto_potential", "(", "r", ",", "pot_name", ",", "*", "args", ")", ":", "pot", "=", "globals", "(", ")", "[", "pot_name", "]", "dpdx", "=", "globals", "(", ")", "[", "'d%sdx'", "%", "(", "pot_name", ")", "]", "dpdy", "=", "globals", ...
28.821429
19.678571
def alarm( cls, template, default_params={}, stack_depth=0, log_context=None, **more_params ): """ :param template: *string* human readable string with placeholders for parameters :param default_params: *dict* parameters to fill in template ...
[ "def", "alarm", "(", "cls", ",", "template", ",", "default_params", "=", "{", "}", ",", "stack_depth", "=", "0", ",", "log_context", "=", "None", ",", "*", "*", "more_params", ")", ":", "timestamp", "=", "datetime", ".", "utcnow", "(", ")", "format", ...
35.821429
22.892857
def _all_unique_texts(text, final): """ Compute all the possible unique texts @type text: str @param text: Text written used spin syntax @type final: list @param final: An empty list where all the unique texts will be stored @return: Nothing. The result will be in the 'final' list """ ...
[ "def", "_all_unique_texts", "(", "text", ",", "final", ")", ":", "if", "not", "char_opening", "in", "text", ":", "if", "not", "text", "in", "final", ":", "final", ".", "append", "(", "text", ")", "return", "stack", "=", "[", "]", "indexes", "=", "[",...
32.064516
16.129032
def nltides_fourier_phase_difference(f, delta_f, f0, amplitude, n, m1, m2): """Calculate the change to the Fourier phase change due to non-linear tides. Note that the Fourier phase Psi(f) is not the same as the gravitational-wave phase phi(f) and is computed by Delta Psi(f) = 2 \pi f Delta t(f) - De...
[ "def", "nltides_fourier_phase_difference", "(", "f", ",", "delta_f", ",", "f0", ",", "amplitude", ",", "n", ",", "m1", ",", "m2", ")", ":", "kmin", "=", "int", "(", "f0", "/", "delta_f", ")", "kmax", "=", "len", "(", "f", ")", "f_ref", ",", "t_of_f...
32.339623
22
def fetch(version='bayestar2017'): """ Downloads the specified version of the Bayestar dust map. Args: version (Optional[:obj:`str`]): The map version to download. Valid versions are :obj:`'bayestar2017'` (Green, Schlafly, Finkbeiner et al. 2018) and :obj:`'bayestar2015'` (G...
[ "def", "fetch", "(", "version", "=", "'bayestar2017'", ")", ":", "doi", "=", "{", "'bayestar2015'", ":", "'10.7910/DVN/40C44C'", ",", "'bayestar2017'", ":", "'10.7910/DVN/LCYHJG'", "}", "# Raise an error if the specified version of the map does not exist", "try", ":", "do...
33.673913
26.195652
def extractBinaries(binaryDataArrayList, arrayLength): """ #TODO: docstring :param binaryDataArrayList: #TODO: docstring :param arrayLength: #TODO: docstring :returns: #TODO: docstring """ extractedArrays = dict() arrayInfo = dict() for binaryData in binaryDataArrayList: if fin...
[ "def", "extractBinaries", "(", "binaryDataArrayList", ",", "arrayLength", ")", ":", "extractedArrays", "=", "dict", "(", ")", "arrayInfo", "=", "dict", "(", ")", "for", "binaryData", "in", "binaryDataArrayList", ":", "if", "findParam", "(", "binaryData", "[", ...
40.657895
17.894737
def _diagnose_prefixes(self): """Returns a set of all of the prefixes seen in the main document dir """ from peyotl.collections_store import COLLECTION_ID_PATTERN p = set() for owner_dirname in os.listdir(self.doc_dir): example_collection_name = "{n}/xxxxx".format(n=o...
[ "def", "_diagnose_prefixes", "(", "self", ")", ":", "from", "peyotl", ".", "collections_store", "import", "COLLECTION_ID_PATTERN", "p", "=", "set", "(", ")", "for", "owner_dirname", "in", "os", ".", "listdir", "(", "self", ".", "doc_dir", ")", ":", "example_...
44.7
16.3
def _already_resized_on_fb(self,fn,pid,_megapixels): """Checks if image file (fn) with photo_id (pid) has already been resized on fb. If so, returns True""" logger.debug("%s - resize requested"%(fn)) # Get width/height from fb width_fb,height_fb=self._getphoto_originalsize(pid) ...
[ "def", "_already_resized_on_fb", "(", "self", ",", "fn", ",", "pid", ",", "_megapixels", ")", ":", "logger", ".", "debug", "(", "\"%s - resize requested\"", "%", "(", "fn", ")", ")", "# Get width/height from fb", "width_fb", ",", "height_fb", "=", "self", ".",...
45.944444
15.944444
def _unwrap(variable_parts: VariablePartsType): """ Yield URL parts. The given parts are usually in reverse order. """ curr_parts = variable_parts var_any = [] while curr_parts: curr_parts, (var_type, part) = curr_parts if var_type == Routes._VAR_ANY_NODE: var_any.a...
[ "def", "_unwrap", "(", "variable_parts", ":", "VariablePartsType", ")", ":", "curr_parts", "=", "variable_parts", "var_any", "=", "[", "]", "while", "curr_parts", ":", "curr_parts", ",", "(", "var_type", ",", "part", ")", "=", "curr_parts", "if", "var_type", ...
23.0625
18.5625
def sqlmany(self, stringname, *args): """Wrapper for executing many SQL calls on my connection. First arg is the name of a query, either a key in the precompiled JSON or a method name in ``allegedb.alchemy.Alchemist``. Remaining arguments should be tuples of argument sequences t...
[ "def", "sqlmany", "(", "self", ",", "stringname", ",", "*", "args", ")", ":", "if", "hasattr", "(", "self", ",", "'alchemist'", ")", ":", "return", "getattr", "(", "self", ".", "alchemist", ".", "many", ",", "stringname", ")", "(", "*", "args", ")", ...
42.307692
16.307692
def extract_retinotopy_argument(obj, retino_type, arg, default='any'): ''' extract_retinotopy_argument(o, retino_type, argument) yields retinotopy data of the given retinotopy type (e.g., 'polar_angle', 'eccentricity', 'variance_explained', 'visual_area', 'weight') from the given hemisphere or cortical ...
[ "def", "extract_retinotopy_argument", "(", "obj", ",", "retino_type", ",", "arg", ",", "default", "=", "'any'", ")", ":", "if", "pimms", ".", "is_str", "(", "arg", ")", ":", "values", "=", "obj", ".", "prop", "(", "arg", ")", "elif", "hasattr", "(", ...
62.823529
35.294118
def Reynolds_factor(FL, C, d, Rev, full_trim=True): r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery factor `FL`, and with either full or reduced trim, all according to IEC 60534 calculations. If f...
[ "def", "Reynolds_factor", "(", "FL", ",", "C", ",", "d", ",", "Rev", ",", "full_trim", "=", "True", ")", ":", "if", "full_trim", ":", "n1", "=", "N2", "/", "(", "min", "(", "C", "/", "d", "**", "2", ",", "0.04", ")", ")", "**", "2", "# C/d**2...
27.954023
26.137931
def get_diff(self, new_mapping): """ Given two mapping it extracts a schema evolution mapping. Returns None if no evolutions are required :param new_mapping: the new mapping :return: a new evolution mapping or None """ import copy result = copy.deepcopy(new_mappin...
[ "def", "get_diff", "(", "self", ",", "new_mapping", ")", ":", "import", "copy", "result", "=", "copy", ".", "deepcopy", "(", "new_mapping", ")", "result", ".", "clear_properties", "(", ")", "no_check_types", "=", "(", "BooleanField", ",", "IntegerField", ","...
36.837209
18.093023
def avatars(self): """Iterate over all my avatars, regardless of what character they are in. """ charname = self.character.name branch, turn, tick = self.engine._btt() charmap = self.engine.character avit = self.engine._avatarness_cache.iter_entities make...
[ "def", "avatars", "(", "self", ")", ":", "charname", "=", "self", ".", "character", ".", "name", "branch", ",", "turn", ",", "tick", "=", "self", ".", "engine", ".", "_btt", "(", ")", "charmap", "=", "self", ".", "engine", ".", "character", "avit", ...
32.65
13.75
def qteMoveToEndOfBuffer(self): """ Move cursor to the end of the buffer to facilitate auto scrolling. Technically, this is exactly the 'endOfBuffer' macro but to avoid swamping Qtmacs with 'qteRunMacroStarted' messages to no avail it was implemented here natively. ...
[ "def", "qteMoveToEndOfBuffer", "(", "self", ")", ":", "tc", "=", "self", ".", "qteText", ".", "textCursor", "(", ")", "tc", ".", "movePosition", "(", "QtGui", ".", "QTextCursor", ".", "End", ")", "self", ".", "qteText", ".", "setTextCursor", "(", "tc", ...
36.666667
14
def combine_psf(kernel_list_new, kernel_old, sigma_bkg, factor=1, stacking_option='median', symmetry=1): """ updates psf estimate based on old kernel and several new estimates :param kernel_list_new: list of new PSF kernels estimated from the point sources in the image :param kernel_old:...
[ "def", "combine_psf", "(", "kernel_list_new", ",", "kernel_old", ",", "sigma_bkg", ",", "factor", "=", "1", ",", "stacking_option", "=", "'median'", ",", "symmetry", "=", "1", ")", ":", "n", "=", "int", "(", "len", "(", "kernel_list_new", ")", "*", "symm...
49.068182
22.431818
def signed_hms(self, warn=True): """Convert to a tuple (sign, hours, minutes, seconds). The ``sign`` will be either +1 or -1, and the other quantities will all be positive. """ if warn and self.preference != 'hours': raise WrongUnitError('signed_hms') return...
[ "def", "signed_hms", "(", "self", ",", "warn", "=", "True", ")", ":", "if", "warn", "and", "self", ".", "preference", "!=", "'hours'", ":", "raise", "WrongUnitError", "(", "'signed_hms'", ")", "return", "_sexagesimalize_to_float", "(", "self", ".", "_hours",...
34.9
15.4
def get_pid(options): """returns The default location of the pid file for process management""" namespace = options['settings'] if options['settings'] else options['wsgi'] return os.path.join('{}', '{}_{}.pid').format(PID_DIR, options['http_port'], namespace.replace('.', '_'))
[ "def", "get_pid", "(", "options", ")", ":", "namespace", "=", "options", "[", "'settings'", "]", "if", "options", "[", "'settings'", "]", "else", "options", "[", "'wsgi'", "]", "return", "os", ".", "path", ".", "join", "(", "'{}'", ",", "'{}_{}.pid'", ...
71.5
31.75
def _from_dict(cls, _dict): """Initialize a DialogRuntimeResponseGeneric object from a json dictionary.""" args = {} if 'response_type' in _dict: args['response_type'] = _dict.get('response_type') else: raise ValueError( 'Required property \'respon...
[ "def", "_from_dict", "(", "cls", ",", "_dict", ")", ":", "args", "=", "{", "}", "if", "'response_type'", "in", "_dict", ":", "args", "[", "'response_type'", "]", "=", "_dict", ".", "get", "(", "'response_type'", ")", "else", ":", "raise", "ValueError", ...
40.325
13.875
def send(self, data, sample_rate=1): """ Squirt the metrics over UDP """ if self.prefix: data = dict((".".join((self.prefix, stat)), value) for stat, value in data.items()) if sample_rate < 1: if random.random() > sample_rate: return ...
[ "def", "send", "(", "self", ",", "data", ",", "sample_rate", "=", "1", ")", ":", "if", "self", ".", "prefix", ":", "data", "=", "dict", "(", "(", "\".\"", ".", "join", "(", "(", "self", ".", "prefix", ",", "stat", ")", ")", ",", "value", ")", ...
34.5
21.318182
def register(self, matchers, runnable): ''' Register an iterator(runnable) to scheduler and wait for events :param matchers: sequence of EventMatchers :param runnable: an iterator that accept send method :param daemon: if True, the runnable will be regi...
[ "def", "register", "(", "self", ",", "matchers", ",", "runnable", ")", ":", "if", "getattr", "(", "self", ",", "'syscallfunc'", ",", "None", ")", "is", "not", "None", "and", "getattr", "(", "self", ",", "'syscallrunnable'", ",", "None", ")", "is", "Non...
46.045455
24.772727
def set_automaster( name, device, fstype, opts='', config='/etc/auto_salt', test=False, **kwargs): ''' Verify that this mount is represented in the auto_salt, change the mount to match the data passed, or add the mount if it is not present. CLI Ex...
[ "def", "set_automaster", "(", "name", ",", "device", ",", "fstype", ",", "opts", "=", "''", ",", "config", "=", "'/etc/auto_salt'", ",", "test", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Fix the opts type if it is a list", "if", "isinstance", "(", ...
34.728814
16.559322
def get_default_values(self): """ Make a crude estimation of the alignment using the center of mass and general C->N orientation. """ out = dict(dx=0, dy=0, dz=0, theta=0, phi=0, psi=0) dx, dy, dz, _ = np.mean(self.coord1 - self.coord2, axis=1) out['dx'] = dx ...
[ "def", "get_default_values", "(", "self", ")", ":", "out", "=", "dict", "(", "dx", "=", "0", ",", "dy", "=", "0", ",", "dz", "=", "0", ",", "theta", "=", "0", ",", "phi", "=", "0", ",", "psi", "=", "0", ")", "dx", ",", "dy", ",", "dz", ",...
39.459459
19.351351
def call_closers(self, client, clients_list): """ Calls closers callbacks """ for func in self.closers: func(client, clients_list)
[ "def", "call_closers", "(", "self", ",", "client", ",", "clients_list", ")", ":", "for", "func", "in", "self", ".", "closers", ":", "func", "(", "client", ",", "clients_list", ")" ]
28.166667
3.833333
def get_suggested_type_names(schema, output_type, field_name): """Go through all of the implementations of type, as well as the interfaces that they implement. If any of those types include the provided field, suggest them, sorted by how often the type is referenced, starting with Interfaces.""" ...
[ "def", "get_suggested_type_names", "(", "schema", ",", "output_type", ",", "field_name", ")", ":", "if", "isinstance", "(", "output_type", ",", "(", "GraphQLInterfaceType", ",", "GraphQLUnionType", ")", ")", ":", "suggested_object_types", "=", "[", "]", "interface...
41.578947
22.578947
def commit(self, transaction=None, headers=None, **keyword_headers): """ Commit a transaction. :param str transaction: the identifier for the transaction :param dict headers: a map of any additional headers the broker requires :param keyword_headers: any additional headers the b...
[ "def", "commit", "(", "self", ",", "transaction", "=", "None", ",", "headers", "=", "None", ",", "*", "*", "keyword_headers", ")", ":", "assert", "transaction", "is", "not", "None", ",", "\"'transaction' is required\"", "headers", "=", "utils", ".", "merge_h...
46.75
20.083333
def build_absolute_uri(request, relative_url): """Ensure absolute_uri are relative to WEBROOT.""" webroot = getattr(settings, 'WEBROOT', '') if webroot.endswith("/") and relative_url.startswith("/"): webroot = webroot[:-1] return request.build_absolute_uri(webroot + relative_url)
[ "def", "build_absolute_uri", "(", "request", ",", "relative_url", ")", ":", "webroot", "=", "getattr", "(", "settings", ",", "'WEBROOT'", ",", "''", ")", "if", "webroot", ".", "endswith", "(", "\"/\"", ")", "and", "relative_url", ".", "startswith", "(", "\...
42.714286
15
def refitValue(self, a): """ Refit (normalize) the attribute's value. @param a: An attribute. @type a: L{Attribute} """ p, name = splitPrefix(a.getValue()) if p is None: return ns = a.resolvePrefix(p) if self.permit(ns): u =...
[ "def", "refitValue", "(", "self", ",", "a", ")", ":", "p", ",", "name", "=", "splitPrefix", "(", "a", ".", "getValue", "(", ")", ")", "if", "p", "is", "None", ":", "return", "ns", "=", "a", ".", "resolvePrefix", "(", "p", ")", "if", "self", "."...
27.857143
10
def maxBoundSize(self): """Get the maximum dimension in x, y or z of the actor bounding box.""" b = self.polydata(True).GetBounds() return max(abs(b[1] - b[0]), abs(b[3] - b[2]), abs(b[5] - b[4]))
[ "def", "maxBoundSize", "(", "self", ")", ":", "b", "=", "self", ".", "polydata", "(", "True", ")", ".", "GetBounds", "(", ")", "return", "max", "(", "abs", "(", "b", "[", "1", "]", "-", "b", "[", "0", "]", ")", ",", "abs", "(", "b", "[", "3...
54.25
13
def ContainsNone(self, *values): """Sets the type of the WHERE clause as "contains none". Args: *values: The values to be used in the WHERE condition. Returns: The query builder that this WHERE builder links to. """ self._awql = self._CreateMultipleValuesCondition(values, 'CONTAINS_NON...
[ "def", "ContainsNone", "(", "self", ",", "*", "values", ")", ":", "self", ".", "_awql", "=", "self", ".", "_CreateMultipleValuesCondition", "(", "values", ",", "'CONTAINS_NONE'", ")", "return", "self", ".", "_query_builder" ]
31.272727
21
def install_app(self, app_path, app_package): """ Install App via Appium Android only. - app_path - path to app - app_package - package of install app to verify """ driver = self._current_application() driver.install_app(app_path) return driver.i...
[ "def", "install_app", "(", "self", ",", "app_path", ",", "app_package", ")", ":", "driver", "=", "self", ".", "_current_application", "(", ")", "driver", ".", "install_app", "(", "app_path", ")", "return", "driver", ".", "is_app_installed", "(", "app_package",...
30.727273
12.636364
def with_git(repo, target_dir=None, limit=None, refspec="HEAD", clone=True, rev_list_args=None, version_filter=lambda version: True): """ Decorate a project class with git-based version information. This adds two attributes to a ...
[ "def", "with_git", "(", "repo", ",", "target_dir", "=", "None", ",", "limit", "=", "None", ",", "refspec", "=", "\"HEAD\"", ",", "clone", "=", "True", ",", "rev_list_args", "=", "None", ",", "version_filter", "=", "lambda", "version", ":", "True", ")", ...
39.7375
20.0625
def feature_handler(self, cmd): """Process a FeatureCommand.""" feature = cmd.feature_name if feature not in commands.FEATURE_NAMES: self.warning("feature %s is not supported - parsing may fail" % (feature,))
[ "def", "feature_handler", "(", "self", ",", "cmd", ")", ":", "feature", "=", "cmd", ".", "feature_name", "if", "feature", "not", "in", "commands", ".", "FEATURE_NAMES", ":", "self", ".", "warning", "(", "\"feature %s is not supported - parsing may fail\"", "%", ...
42.5
11.333333
def mwl(self, event): """Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this """ if event.num == 4: # up on Linux self.top.f.canvas.yview_scroll(-1*self._tmwm, 'units') elif event.num == 5: # down on Linux self.top.f.canvas.yview_scroll(1*self._tmwm, 'units') ...
[ "def", "mwl", "(", "self", ",", "event", ")", ":", "if", "event", ".", "num", "==", "4", ":", "# up on Linux", "self", ".", "top", ".", "f", ".", "canvas", ".", "yview_scroll", "(", "-", "1", "*", "self", ".", "_tmwm", ",", "'units'", ")", "elif"...
57.625
17.875
def _ParseRelationshipsXMLFile(self, xml_data): """Parses the relationships XML file (_rels/.rels). Args: xml_data (bytes): data of a _rels/.rels XML file. Returns: list[str]: property file paths. The path is relative to the root of the ZIP file. Raises: zipfile.BadZipfile...
[ "def", "_ParseRelationshipsXMLFile", "(", "self", ",", "xml_data", ")", ":", "xml_root", "=", "ElementTree", ".", "fromstring", "(", "xml_data", ")", "property_files", "=", "[", "]", "for", "xml_element", "in", "xml_root", ".", "iter", "(", ")", ":", "type_a...
29.869565
20.043478
async def field(self, elem=None, elem_type=None, params=None): """ Archive field :param elem: :param elem_type: :param params: :return: """ elem_type = elem_type if elem_type else elem.__class__ fvalue = None src = elem if issubcla...
[ "async", "def", "field", "(", "self", ",", "elem", "=", "None", ",", "elem_type", "=", "None", ",", "params", "=", "None", ")", ":", "elem_type", "=", "elem_type", "if", "elem_type", "else", "elem", ".", "__class__", "fvalue", "=", "None", "src", "=", ...
37.975
28.275
def compare_attribute_sets( url: str, profile_a: Tuple[str], profile_b: Tuple[str]) -> Dict: """ Given two phenotype profiles, returns their similarity :returns Dict with the structure: { 'unresolved' : [...] 'query_IRIs' : [...] 'target_IRIs': [...] '...
[ "def", "compare_attribute_sets", "(", "url", ":", "str", ",", "profile_a", ":", "Tuple", "[", "str", "]", ",", "profile_b", ":", "Tuple", "[", "str", "]", ")", "->", "Dict", ":", "owlsim_url", "=", "url", "+", "'compareAttributeSets'", "params", "=", "{"...
24.809524
17.47619
def isValid(self): """ Returns if the current Reference Sample is valid. This is, the sample hasn't neither been expired nor disposed. """ today = DateTime() expiry_date = self.getExpiryDate() if expiry_date and today > expiry_date: return False ...
[ "def", "isValid", "(", "self", ")", ":", "today", "=", "DateTime", "(", ")", "expiry_date", "=", "self", ".", "getExpiryDate", "(", ")", "if", "expiry_date", "and", "today", ">", "expiry_date", ":", "return", "False", "# TODO: Do We really need ExpiryDate + Date...
33.526316
16.052632
def _slugify_title(self): """Slugify the Entry title, but ensure it's less than the maximum number of characters. This method also ensures that a slug is unique by appending a timestamp to any duplicate slugs. """ # Restrict slugs to their maximum number of chars, but don't split...
[ "def", "_slugify_title", "(", "self", ")", ":", "# Restrict slugs to their maximum number of chars, but don't split mid-word", "self", ".", "slug", "=", "slugify", "(", "self", ".", "title", ")", "while", "len", "(", "self", ".", "slug", ")", ">", "255", ":", "s...
48.428571
16.857143
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delJ|J) into Pi arrays. Set the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
[ "def", "generate_PJdelJ_nt_pos_vecs", "(", "self", ",", "generative_model", ",", "genomic_data", ")", ":", "cutJ_genomic_CDR3_segs", "=", "genomic_data", ".", "cutJ_genomic_CDR3_segs", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", ...
53.270833
28.25
def _save_config(section, token, value): ''' Helper function to persist a configuration in the ini file ''' cmd = NIRTCFG_PATH cmd += ' --set section={0},token=\'{1}\',value=\'{2}\''.format(section, token, value) if __salt__['cmd.run_all'](cmd)['retcode'] != 0: exc_msg = 'Error: could no...
[ "def", "_save_config", "(", "section", ",", "token", ",", "value", ")", ":", "cmd", "=", "NIRTCFG_PATH", "cmd", "+=", "' --set section={0},token=\\'{1}\\',value=\\'{2}\\''", ".", "format", "(", "section", ",", "token", ",", "value", ")", "if", "__salt__", "[", ...
47.444444
26.111111
def loadFromFile(fileName): """ load the configuration for the ReturnInfo from a fileName @param fileName: filename that contains the json configuration to use in the ReturnInfo """ assert os.path.exists(fileName), "File " + fileName + " does not exist" conf = json.load(o...
[ "def", "loadFromFile", "(", "fileName", ")", ":", "assert", "os", ".", "path", ".", "exists", "(", "fileName", ")", ",", "\"File \"", "+", "fileName", "+", "\" does not exist\"", "conf", "=", "json", ".", "load", "(", "open", "(", "fileName", ")", ")", ...
57.444444
27.111111
def set_column_stretch(self, column=0, stretch=10): """ Sets the column stretch. Larger numbers mean it will expand more to fill space. """ self._layout.setColumnStretch(column, stretch) return self
[ "def", "set_column_stretch", "(", "self", ",", "column", "=", "0", ",", "stretch", "=", "10", ")", ":", "self", ".", "_layout", ".", "setColumnStretch", "(", "column", ",", "stretch", ")", "return", "self" ]
34.285714
14.571429
async def join_voice(guild_id: int, channel_id: int): """ Joins a voice channel by ID's. Parameters ---------- guild_id : int channel_id : int """ node = get_node(guild_id) voice_ws = node.get_voice_ws(guild_id) await voice_ws.voice_state(guild_id, channel_id)
[ "async", "def", "join_voice", "(", "guild_id", ":", "int", ",", "channel_id", ":", "int", ")", ":", "node", "=", "get_node", "(", "guild_id", ")", "voice_ws", "=", "node", ".", "get_voice_ws", "(", "guild_id", ")", "await", "voice_ws", ".", "voice_state", ...
24.166667
14.833333
def _check_pillar(self, force=False): ''' Check the pillar for errors, refuse to run the state if there are errors in the pillar and return the pillar errors ''' if force: return True if '_errors' in self.state.opts['pillar']: return False ...
[ "def", "_check_pillar", "(", "self", ",", "force", "=", "False", ")", ":", "if", "force", ":", "return", "True", "if", "'_errors'", "in", "self", ".", "state", ".", "opts", "[", "'pillar'", "]", ":", "return", "False", "return", "True" ]
32.2
19.8
def infos(self, type=None, failed=False): """ Get infos in the network. type specifies the type of info (defaults to Info). failed { False, True, "all" } specifies the failed state of the infos. To get infos from a specific node, see the infos() method in class :class:`~...
[ "def", "infos", "(", "self", ",", "type", "=", "None", ",", "failed", "=", "False", ")", ":", "if", "type", "is", "None", ":", "type", "=", "Info", "if", "failed", "not", "in", "[", "\"all\"", ",", "False", ",", "True", "]", ":", "raise", "ValueE...
36.631579
20.736842