text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def astuple(self, encoding=None): """ Return a tuple suitable for import into a database. Attributes field and extra field jsonified into strings. The order of fields is such that they can be supplied as arguments for the query defined in :attr:`gffutils.constants._INSERT`. ...
[ "def", "astuple", "(", "self", ",", "encoding", "=", "None", ")", ":", "if", "not", "encoding", ":", "return", "(", "self", ".", "id", ",", "self", ".", "seqid", ",", "self", ".", "source", ",", "self", ".", "featuretype", ",", "self", ".", "start"...
40.533333
0.001606
def step1_get_authorize_url(self, redirect_uri=None, state=None): """Returns a URI to redirect to the provider. Args: redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob' for a non-web-based application, or a URI that handle...
[ "def", "step1_get_authorize_url", "(", "self", ",", "redirect_uri", "=", "None", ",", "state", "=", "None", ")", ":", "if", "redirect_uri", "is", "not", "None", ":", "logger", ".", "warning", "(", "(", "'The redirect_uri parameter for '", "'OAuth2WebServerFlow.ste...
43.043478
0.000988
def filter(self, *args, **kwargs): """ See :py:meth:`nornir.core.inventory.Inventory.filter` Returns: :obj:`Nornir`: A new object with same configuration as ``self`` but filtered inventory. """ b = Nornir(**self.__dict__) b.inventory = self.inventory.filter(*...
[ "def", "filter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "b", "=", "Nornir", "(", "*", "*", "self", ".", "__dict__", ")", "b", ".", "inventory", "=", "self", ".", "inventory", ".", "filter", "(", "*", "args", ",", "*",...
34.3
0.008523
def parseWord(word): """ Split given attribute word to key, value pair. Values are casted to python equivalents. :param word: API word. :returns: Key, value pair. """ mapping = {'yes': True, 'true': True, 'no': False, 'false': False} _, key, value = word.split('=', 2) try: ...
[ "def", "parseWord", "(", "word", ")", ":", "mapping", "=", "{", "'yes'", ":", "True", ",", "'true'", ":", "True", ",", "'no'", ":", "False", ",", "'false'", ":", "False", "}", "_", ",", "key", ",", "value", "=", "word", ".", "split", "(", "'='", ...
25.75
0.002342
def trigger_on_off(request, trigger_id): """ enable/disable the status of the trigger then go back home :param request: request object :param trigger_id: the trigger ID to switch the status to True or False :type request: HttpRequest object :type trigger_id: int :retu...
[ "def", "trigger_on_off", "(", "request", ",", "trigger_id", ")", ":", "now", "=", "arrow", ".", "utcnow", "(", ")", ".", "to", "(", "settings", ".", "TIME_ZONE", ")", ".", "format", "(", "'YYYY-MM-DD HH:mm:ssZZ'", ")", "trigger", "=", "get_object_or_404", ...
37.228571
0.000748
def lines_diff(before_lines, after_lines, check_modified=False): '''Diff the lines in two strings. Parameters ---------- before_lines : iterable Iterable containing lines used as the baseline version. after_lines : iterable Iterable containing lines to be compared against the baseli...
[ "def", "lines_diff", "(", "before_lines", ",", "after_lines", ",", "check_modified", "=", "False", ")", ":", "before_comps", "=", "[", "LineComparator", "(", "line", ",", "check_modified", "=", "check_modified", ")", "for", "line", "in", "before_lines", "]", "...
27.535714
0.001253
def get_residue_mapping(self): """this function maps the chain and res ids "A 234" to values from [1-N]""" resid_list = self.aa_resids() # resid_set = set(resid_list) # resid_lst1 = list(resid_set) # resid_lst1.sort() map_res_id = {} x = 1 for resid in ...
[ "def", "get_residue_mapping", "(", "self", ")", ":", "resid_list", "=", "self", ".", "aa_resids", "(", ")", "# resid_set = set(resid_list)", "# resid_lst1 = list(resid_set)", "# resid_lst1.sort()", "map_res_id", "=", "{", "}", "x", "=", "1", "for", "resid", "in", ...
30.066667
0.012903
def get_title(brain_or_object): """Get the Title for this object :param brain_or_object: A single catalog brain or content object :type brain_or_object: ATContentType/DexterityContentType/CatalogBrain :returns: Title :rtype: string """ if is_brain(brain_or_object) and base_hasattr(brain_or_...
[ "def", "get_title", "(", "brain_or_object", ")", ":", "if", "is_brain", "(", "brain_or_object", ")", "and", "base_hasattr", "(", "brain_or_object", ",", "\"Title\"", ")", ":", "return", "brain_or_object", ".", "Title", "return", "get_object", "(", "brain_or_object...
37.363636
0.002375
def _chk_truncate(self): ''' Checks whether the frame should be truncated. If so, slices the frame up. ''' # Column of which first element is used to determine width of a dot col self.tr_size_col = -1 # Cut the data to the information actually printed ma...
[ "def", "_chk_truncate", "(", "self", ")", ":", "# Column of which first element is used to determine width of a dot col", "self", ".", "tr_size_col", "=", "-", "1", "# Cut the data to the information actually printed", "max_cols", "=", "self", ".", "max_cols", "max_rows", "="...
36.594203
0.002314
def create_statement_inspection_table(sts: List[Influence]): """ Display an HTML representation of a table with INDRA statements to manually inspect for validity. Args: sts: A list of INDRA statements to be manually inspected for validity. """ columns = [ "un_groundings", "...
[ "def", "create_statement_inspection_table", "(", "sts", ":", "List", "[", "Influence", "]", ")", ":", "columns", "=", "[", "\"un_groundings\"", ",", "\"subj_polarity\"", ",", "\"obj_polarity\"", ",", "\"Sentence\"", ",", "\"Source API\"", ",", "]", "polarity_to_str"...
29.74
0.001953
def save_figures(block, block_vars, gallery_conf): """Save all open figures of the example code-block. Parameters ---------- block : tuple A tuple containing the (label, content, line_number) of the block. block_vars : dict Dict of block variables. gallery_conf : dict Co...
[ "def", "save_figures", "(", "block", ",", "block_vars", ",", "gallery_conf", ")", ":", "image_path_iterator", "=", "block_vars", "[", "'image_path_iterator'", "]", "all_rst", "=", "u''", "prev_count", "=", "len", "(", "image_path_iterator", ")", "for", "scraper", ...
37.485714
0.000743
def hdbscan(X, min_cluster_size=5, min_samples=None, alpha=1.0, metric='minkowski', p=2, leaf_size=40, algorithm='best', memory=Memory(cachedir=None, verbose=0), approx_min_span_tree=True, gen_min_span_tree=False, core_dist_n_jobs=4, cluster_selection_method='...
[ "def", "hdbscan", "(", "X", ",", "min_cluster_size", "=", "5", ",", "min_samples", "=", "None", ",", "alpha", "=", "1.0", ",", "metric", "=", "'minkowski'", ",", "p", "=", "2", ",", "leaf_size", "=", "40", ",", "algorithm", "=", "'best'", ",", "memor...
46.367698
0.00029
def _get_securitygroupname_id(securitygroupname_list): ''' Returns the SecurityGroupId of a SecurityGroupName to use ''' securitygroupid_set = set() if not isinstance(securitygroupname_list, list): securitygroupname_list = [securitygroupname_list] params = {'Action': 'DescribeSecurityGro...
[ "def", "_get_securitygroupname_id", "(", "securitygroupname_list", ")", ":", "securitygroupid_set", "=", "set", "(", ")", "if", "not", "isinstance", "(", "securitygroupname_list", ",", "list", ")", ":", "securitygroupname_list", "=", "[", "securitygroupname_list", "]"...
42.411765
0.001357
def search_tags_as_filters(tags): """Get different tags as dicts ready to use as dropdown lists.""" # set dicts actions = {} contacts = {} formats = {} inspire = {} keywords = {} licenses = {} md_types = dict() owners = defaultdict(str) srs = {} unused = {} # 0/1 valu...
[ "def", "search_tags_as_filters", "(", "tags", ")", ":", "# set dicts", "actions", "=", "{", "}", "contacts", "=", "{", "}", "formats", "=", "{", "}", "inspire", "=", "{", "}", "keywords", "=", "{", "}", "licenses", "=", "{", "}", "md_types", "=", "di...
27.736842
0.000305
def get_easyui_context(self, **kwargs): """ 初始化一个空的context """ context = {} queryset = self.get_queryset() limit_queryset = self.get_limit_queryset() data = model_serialize(limit_queryset, self.extra_fields, self.remove_fields) count = queryset.count() ...
[ "def", "get_easyui_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "{", "}", "queryset", "=", "self", ".", "get_queryset", "(", ")", "limit_queryset", "=", "self", ".", "get_limit_queryset", "(", ")", "data", "=", "model_serialize...
34.461538
0.008696
def older_message(m, lastm): '''return true if m is older than lastm by timestamp''' atts = {'time_boot_ms' : 1.0e-3, 'time_unix_usec' : 1.0e-6, 'time_usec' : 1.0e-6} for a in atts.keys(): if hasattr(m, a): mul = atts[a] t1 = m.getattr(a) * mul ...
[ "def", "older_message", "(", "m", ",", "lastm", ")", ":", "atts", "=", "{", "'time_boot_ms'", ":", "1.0e-3", ",", "'time_unix_usec'", ":", "1.0e-6", ",", "'time_usec'", ":", "1.0e-6", "}", "for", "a", "in", "atts", ".", "keys", "(", ")", ":", "if", "...
32.846154
0.009112
def generate(self): '''Generate the whole static site. Iterates through all existing s2 pages, rendering and writing them (and copying all common files along). It also generates the toc, a sitemap, and the atom feed etc. (in the future it should handle tags and categories) ...
[ "def", "generate", "(", "self", ")", ":", "if", "self", ".", "_dirs", "[", "'base'", "]", "==", "None", "or", "not", "self", ".", "_tree_ready", ":", "#there's NO base here or up the chain", "raise", "ValueError", "#cannot generate!", "# wipe www dir & recreate", ...
41.111111
0.011876
def generic_insert_module(module_name, args, **kwargs): """ In general we have a initial template and then insert new data, so we dont repeat the schema for each module :param module_name: String with module name :paran **kwargs: Args to be rendered in template """ file = create_or_open( ...
[ "def", "generic_insert_module", "(", "module_name", ",", "args", ",", "*", "*", "kwargs", ")", ":", "file", "=", "create_or_open", "(", "'{}.py'", ".", "format", "(", "module_name", ")", ",", "os", ".", "path", ".", "join", "(", "BASE_TEMPLATES_DIR", ",", ...
28.541667
0.012712
def calculate_infixop(self, node, previous, next_node): """Create new node for infixop""" previous_position = (previous.last_line, previous.last_col - 1) position = (next_node.first_line, next_node.first_col + 1) possible = [] for ch in OPERATORS[node.__class__]: try:...
[ "def", "calculate_infixop", "(", "self", ",", "node", ",", "previous", ",", "next_node", ")", ":", "previous_position", "=", "(", "previous", ".", "last_line", ",", "previous", ".", "last_col", "-", "1", ")", "position", "=", "(", "next_node", ".", "first_...
40.25
0.002427
def nla_get_u64(nla): """Return value of 64 bit integer attribute as an int(). https://github.com/thom311/libnl/blob/libnl3_2_25/lib/attr.c#L649 Positional arguments: nla -- 64 bit integer attribute (nlattr class instance). Returns: Payload as an int(). """ tmp = c_uint64(0) if nl...
[ "def", "nla_get_u64", "(", "nla", ")", ":", "tmp", "=", "c_uint64", "(", "0", ")", "if", "nla", "and", "nla_len", "(", "nla", ")", ">=", "sizeof", "(", "tmp", ")", ":", "tmp", "=", "c_uint64", ".", "from_buffer", "(", "nla_data", "(", "nla", ")", ...
28.6
0.002257
def set_min_level_to_mail(self, level): """Allow to change mail level after creation """ self.min_log_level_to_mail = level handler_class = AlkiviEmailHandler self._set_min_level(handler_class, level)
[ "def", "set_min_level_to_mail", "(", "self", ",", "level", ")", ":", "self", ".", "min_log_level_to_mail", "=", "level", "handler_class", "=", "AlkiviEmailHandler", "self", ".", "_set_min_level", "(", "handler_class", ",", "level", ")" ]
39.166667
0.008333
async def open(self): """Register with the publisher.""" self.store.register(self) while not self.finished: message = await self.messages.get() await self.publish(message)
[ "async", "def", "open", "(", "self", ")", ":", "self", ".", "store", ".", "register", "(", "self", ")", "while", "not", "self", ".", "finished", ":", "message", "=", "await", "self", ".", "messages", ".", "get", "(", ")", "await", "self", ".", "pub...
36.5
0.008929
def writefits(self, filename, clobber=True, trimzero=True, binned=False, precision=None, hkeys=None): """Write the spectrum to a FITS table. Primary header in EXT 0. ``FILENAME``, ``ORIGIN``, and any extra keyword(s) from ``hkeys`` will also be added. Table header an...
[ "def", "writefits", "(", "self", ",", "filename", ",", "clobber", "=", "True", ",", "trimzero", "=", "True", ",", "binned", "=", "False", ",", "precision", "=", "None", ",", "hkeys", "=", "None", ")", ":", "pcodes", "=", "{", "'d'", ":", "'D'", ","...
37.013072
0.002236
def upload_from_shared_memory(self, location, bbox, order='F', cutout_bbox=None): """ Upload from a shared memory array. https://github.com/seung-lab/cloud-volume/wiki/Advanced-Topic:-Shared-Memory tip: If you want to use slice notation, np.s_[...] will help in a pinch. MEMORY LIFECYCLE WARNING:...
[ "def", "upload_from_shared_memory", "(", "self", ",", "location", ",", "bbox", ",", "order", "=", "'F'", ",", "cutout_bbox", "=", "None", ")", ":", "def", "tobbox", "(", "x", ")", ":", "if", "type", "(", "x", ")", "==", "Bbox", ":", "return", "x", ...
45.652174
0.014916
def angle(v1,v2, cos=False): """ Find the angle between two vectors. :param cos: If True, the cosine of the angle will be returned. False by default. """ n = (norm(v1)*norm(v2)) _ = dot(v1,v2)/n return _ if cos else N.arccos(_)
[ "def", "angle", "(", "v1", ",", "v2", ",", "cos", "=", "False", ")", ":", "n", "=", "(", "norm", "(", "v1", ")", "*", "norm", "(", "v2", ")", ")", "_", "=", "dot", "(", "v1", ",", "v2", ")", "/", "n", "return", "_", "if", "cos", "else", ...
25.1
0.011538
def to_csc(self): """Convert Dataset to scipy's Compressed Sparse Column matrix.""" self._X_train = csc_matrix(self._X_train) self._X_test = csc_matrix(self._X_test)
[ "def", "to_csc", "(", "self", ")", ":", "self", ".", "_X_train", "=", "csc_matrix", "(", "self", ".", "_X_train", ")", "self", ".", "_X_test", "=", "csc_matrix", "(", "self", ".", "_X_test", ")" ]
46.5
0.010582
def search_user_group_for_facets(self, **kwargs): # noqa: E501 """Lists the values of one or more facets over the customer's user groups # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=Tru...
[ "def", "search_user_group_for_facets", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "search_user_gr...
46
0.002028
def generate_signing_key(args): """ Generate an ECDSA signing key for signing secure boot images (post-bootloader) """ if os.path.exists(args.keyfile): raise esptool.FatalError("ERROR: Key file %s already exists" % args.keyfile) sk = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p) with open(args...
[ "def", "generate_signing_key", "(", "args", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "args", ".", "keyfile", ")", ":", "raise", "esptool", ".", "FatalError", "(", "\"ERROR: Key file %s already exists\"", "%", "args", ".", "keyfile", ")", "sk", ...
55.75
0.00883
def get_day(): """Function for retrieving the wanted day""" day = datetime.datetime.today().weekday() if len(sys.argv) == 3: if sys.argv[2] == "mon": day = 0 elif sys.argv[2] == "tue": day = 1 elif sys.argv[2] == "wed": day = 2 elif sys.arg...
[ "def", "get_day", "(", ")", ":", "day", "=", "datetime", ".", "datetime", ".", "today", "(", ")", ".", "weekday", "(", ")", "if", "len", "(", "sys", ".", "argv", ")", "==", "3", ":", "if", "sys", ".", "argv", "[", "2", "]", "==", "\"mon\"", "...
26.75
0.001805
def _IAC_parser(self, buf, network_reader, network_writer, connection): """ Processes and removes any Telnet commands from the buffer. :param buf: buffer :returns: buffer minus Telnet commands """ skip_to = 0 while True: # Locate an IAC to process ...
[ "def", "_IAC_parser", "(", "self", ",", "buf", ",", "network_reader", ",", "network_writer", ",", "connection", ")", ":", "skip_to", "=", "0", "while", "True", ":", "# Locate an IAC to process", "iac_loc", "=", "buf", ".", "find", "(", "IAC", ",", "skip_to",...
42.375
0.002162
def search_dashboard_deleted_entities(self, **kwargs): # noqa: E501 """Search over a customer's deleted dashboards # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread =...
[ "def", "search_dashboard_deleted_entities", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "search_da...
44.904762
0.002077
def DyStrData(cls, name, regx, index = 0): ''' set dynamic value from the string data of response @param name: glob parameter name @param regx: re._pattern_type e.g. DyStrData("a",re.compile('123')) ''' text = Web.PageSource() if not text...
[ "def", "DyStrData", "(", "cls", ",", "name", ",", "regx", ",", "index", "=", "0", ")", ":", "text", "=", "Web", ".", "PageSource", "(", ")", "if", "not", "text", ":", "return", "if", "not", "isinstance", "(", "regx", ",", "re", ".", "_pattern_type"...
36.777778
0.014728
def enqueue(self, message, *, delay=None): """Enqueue a message. Parameters: message(Message): The message to enqueue. delay(int): The minimum amount of time, in milliseconds, to delay the message by. Raises: QueueNotFound: If the queue the message is ...
[ "def", "enqueue", "(", "self", ",", "message", ",", "*", ",", "delay", "=", "None", ")", ":", "queue_name", "=", "message", ".", "queue_name", "if", "delay", "is", "not", "None", ":", "queue_name", "=", "dq_name", "(", "queue_name", ")", "message_eta", ...
31.833333
0.002033
def delete(self, custom_field, params={}, **options): """A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field. Returns an empty data record. Parameters ---------- custom_field : {Id} Globally unique identifier for...
[ "def", "delete", "(", "self", ",", "custom_field", ",", "params", "=", "{", "}", ",", "*", "*", "options", ")", ":", "path", "=", "\"/custom_fields/%s\"", "%", "(", "custom_field", ")", "return", "self", ".", "client", ".", "delete", "(", "path", ",", ...
41
0.010846
def from_df(cls, path, df:DataFrame, dep_var:str, valid_idx:Collection[int], procs:OptTabTfms=None, cat_names:OptStrList=None, cont_names:OptStrList=None, classes:Collection=None, test_df=None, bs:int=64, val_bs:int=None, num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callab...
[ "def", "from_df", "(", "cls", ",", "path", ",", "df", ":", "DataFrame", ",", "dep_var", ":", "str", ",", "valid_idx", ":", "Collection", "[", "int", "]", ",", "procs", ":", "OptTabTfms", "=", "None", ",", "cat_names", ":", "OptStrList", "=", "None", ...
91.6
0.042507
def registration_error(self, stanza): """Handle in-band registration error. [client only] :Parameters: - `stanza`: the error stanza received or `None` on timeout. :Types: - `stanza`: `pyxmpp.stanza.Stanza`""" self.lock.acquire() try: ...
[ "def", "registration_error", "(", "self", ",", "stanza", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "err", "=", "stanza", ".", "get_error", "(", ")", "ae", "=", "err", ".", "xpath_eval", "(", "\"e:*\"", ",", "{", "\"e\"", ...
31.55
0.013846
def _annotate_groups(self): """ Annotate the objects belonging to separate (non-connected) graphs with individual indices. """ g = {} for x in self.metadata: g[x.id] = x idx = 0 for x in self.metadata: if not hasattr(x, 'group'): ...
[ "def", "_annotate_groups", "(", "self", ")", ":", "g", "=", "{", "}", "for", "x", "in", "self", ".", "metadata", ":", "g", "[", "x", ".", "id", "]", "=", "x", "idx", "=", "0", "for", "x", "in", "self", ".", "metadata", ":", "if", "not", "hasa...
31.551724
0.002121
def delete_collection_mutating_webhook_configuration(self, **kwargs): # noqa: E501 """delete_collection_mutating_webhook_configuration # noqa: E501 delete collection of MutatingWebhookConfiguration # noqa: E501 This method makes a synchronous HTTP request by default. To make an async...
[ "def", "delete_collection_mutating_webhook_configuration", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", "....
167.137931
0.00041
def flag_inner_classes(obj): """ Mutates any attributes on ``obj`` which are classes, with link to ``obj``. Adds a convenience accessor which instantiates ``obj`` and then calls its ``setup`` method. Recurses on those objects as well. """ for tup in class_members(obj): tup[1]._pare...
[ "def", "flag_inner_classes", "(", "obj", ")", ":", "for", "tup", "in", "class_members", "(", "obj", ")", ":", "tup", "[", "1", "]", ".", "_parent", "=", "obj", "tup", "[", "1", "]", ".", "_parent_inst", "=", "None", "tup", "[", "1", "]", ".", "__...
30.357143
0.002283
def save(self): """ :return: save this team on Ariane server (create or update) """ LOGGER.debug("Team.save") post_payload = {} consolidated_osi_id = [] consolidated_app_id = [] if self.id is not None: post_payload['teamID'] = self.id ...
[ "def", "save", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Team.save\"", ")", "post_payload", "=", "{", "}", "consolidated_osi_id", "=", "[", "]", "consolidated_app_id", "=", "[", "]", "if", "self", ".", "id", "is", "not", "None", ":", "post...
38.207792
0.001325
def generate_all_deps(self, target: Target): """Generate all dependencies of `target` (the target nodes).""" yield from (self.targets[dep_name] for dep_name in self.generate_dep_names(target))
[ "def", "generate_all_deps", "(", "self", ",", "target", ":", "Target", ")", ":", "yield", "from", "(", "self", ".", "targets", "[", "dep_name", "]", "for", "dep_name", "in", "self", ".", "generate_dep_names", "(", "target", ")", ")" ]
56.25
0.008772
def load_data(self): """Load data in bulk for each embed block.""" for embed_type in self.ids.keys(): self.load_instances(embed_type, self.ids[embed_type])
[ "def", "load_data", "(", "self", ")", ":", "for", "embed_type", "in", "self", ".", "ids", ".", "keys", "(", ")", ":", "self", ".", "load_instances", "(", "embed_type", ",", "self", ".", "ids", "[", "embed_type", "]", ")" ]
36
0.01087
def resample(sig, old=1, new=1, order=3, zero=0.): """ Generic resampler based on Waring-Lagrange interpolators. Parameters ---------- sig : Input signal (any iterable). old : Time duration reference (defaults to 1, allowing percentages to the ``new`` keyword argument). This can be float number...
[ "def", "resample", "(", "sig", ",", "old", "=", "1", ",", "new", "=", "1", ",", "order", "=", "3", ",", "zero", "=", "0.", ")", ":", "sig", "=", "Stream", "(", "sig", ")", "threshold", "=", ".5", "*", "(", "order", "+", "1", ")", "step", "=...
32.661538
0.00823
def _generate_pyephem_snapshot( mjd, log, magLimit): """* generate pyephem snapshot* **Key Arguments:** - ``mjd`` -- the mjd to generate the pyephem snapshot database for - ``xephemOE`` -- a list of xephem database format strings for use with pyephem **Return:** ...
[ "def", "_generate_pyephem_snapshot", "(", "mjd", ",", "log", ",", "magLimit", ")", ":", "log", ".", "info", "(", "'starting the ``_generate_pyephem_snapshot`` method'", ")", "print", "\"generating pyephem database for MJD %(mjd)s\"", "%", "locals", "(", ")", "global", "...
29.576271
0.001109
def rgb_2_hex(self, r, g, b): """ convert a rgb color to hex """ return "#{:02X}{:02X}{:02X}".format(int(r * 255), int(g * 255), int(b * 255))
[ "def", "rgb_2_hex", "(", "self", ",", "r", ",", "g", ",", "b", ")", ":", "return", "\"#{:02X}{:02X}{:02X}\"", ".", "format", "(", "int", "(", "r", "*", "255", ")", ",", "int", "(", "g", "*", "255", ")", ",", "int", "(", "b", "*", "255", ")", ...
34
0.017241
def version_dict(version): """Turn a version string into a dict with major/minor/... info.""" match = version_re.match(str(version) or '') letters = 'alpha pre'.split() numbers = 'major minor1 minor2 minor3 alpha_ver pre_ver'.split() if match: d = match.groupdict() for letter in lett...
[ "def", "version_dict", "(", "version", ")", ":", "match", "=", "version_re", ".", "match", "(", "str", "(", "version", ")", "or", "''", ")", "letters", "=", "'alpha pre'", ".", "split", "(", ")", "numbers", "=", "'major minor1 minor2 minor3 alpha_ver pre_ver'"...
35.444444
0.001527
def collapse (listoflists,keepcols,collapsecols,fcn1=None,fcn2=None,cfcn=None): """ Averages data in collapsecol, keeping all unique items in keepcols (using unique, which keeps unique LISTS of column numbers), retaining the unique sets of values in keepcols, the mean for each. Setting fcn1 and/or fcn2 to point t...
[ "def", "collapse", "(", "listoflists", ",", "keepcols", ",", "collapsecols", ",", "fcn1", "=", "None", ",", "fcn2", "=", "None", ",", "cfcn", "=", "None", ")", ":", "def", "collmean", "(", "inlist", ")", ":", "s", "=", "0", "for", "item", "in", "in...
39.026316
0.029267
def DiffAnys(obj1, obj2, looseMatch=False, ignoreArrayOrder=True): """Diff any two objects. Objects can either be primitive type or DataObjects""" differ = Differ(looseMatch = looseMatch, ignoreArrayOrder = ignoreArrayOrder) return differ.DiffAnyObjects(obj1, obj2)
[ "def", "DiffAnys", "(", "obj1", ",", "obj2", ",", "looseMatch", "=", "False", ",", "ignoreArrayOrder", "=", "True", ")", ":", "differ", "=", "Differ", "(", "looseMatch", "=", "looseMatch", ",", "ignoreArrayOrder", "=", "ignoreArrayOrder", ")", "return", "dif...
55.2
0.032143
def analytical(src, rec, res, freqtime, solution='fs', signal=None, ab=11, aniso=None, epermH=None, epermV=None, mpermH=None, mpermV=None, verb=2): r"""Return the analytical full- or half-space solution. Calculate the electromagnetic frequency- or time-domain field due to infi...
[ "def", "analytical", "(", "src", ",", "rec", ",", "res", ",", "freqtime", ",", "solution", "=", "'fs'", ",", "signal", "=", "None", ",", "ab", "=", "11", ",", "aniso", "=", "None", ",", "epermH", "=", "None", ",", "epermV", "=", "None", ",", "mpe...
42.617117
0.000103
def arcovar(x, order): r"""Simple and fast implementation of the covariance AR estimate This code is 10 times faster than :func:`arcovar_marple` and more importantly only 10 lines of code, compared to a 200 loc for :func:`arcovar_marple` :param array X: Array of complex data samples :param int o...
[ "def", "arcovar", "(", "x", ",", "order", ")", ":", "from", "spectrum", "import", "corrmtx", "import", "scipy", ".", "linalg", "X", "=", "corrmtx", "(", "x", ",", "order", ",", "'covariance'", ")", "Xc", "=", "np", ".", "matrix", "(", "X", "[", ":"...
33.681159
0.001672
def cogroup(self, other, numPartitions=None): """ Return a new DStream by applying 'cogroup' between RDDs of this DStream and `other` DStream. Hash partitioning is used to generate the RDDs with `numPartitions` partitions. """ if numPartitions is None: numPar...
[ "def", "cogroup", "(", "self", ",", "other", ",", "numPartitions", "=", "None", ")", ":", "if", "numPartitions", "is", "None", ":", "numPartitions", "=", "self", ".", "_sc", ".", "defaultParallelism", "return", "self", ".", "transformWith", "(", "lambda", ...
43.1
0.009091
def mean_size(self, p, q): ''' >>> psd = PSDLognormal(s=0.5, d_characteristic=5E-6) >>> psd.mean_size(3, 2) 4.412484512922977e-06 Note that for the case where p == q, a different set of formulas are required - which do not have analytical results for many...
[ "def", "mean_size", "(", "self", ",", "p", ",", "q", ")", ":", "if", "p", "==", "q", ":", "p", "-=", "1e-9", "q", "+=", "1e-9", "pow1", "=", "q", "-", "self", ".", "order", "denominator", "=", "self", ".", "_pdf_basis_integral_definite", "(", "d_mi...
41.807692
0.008094
def _get_gcloud_records(self, gcloud_zone, page_token=None): """ Generator function which yields ResourceRecordSet for the managed gcloud zone, until there are no more records to pull. :param gcloud_zone: zone to pull records from :type gcloud_zone: google.cloud.dns.ManagedZ...
[ "def", "_get_gcloud_records", "(", "self", ",", "gcloud_zone", ",", "page_token", "=", "None", ")", ":", "gcloud_iterator", "=", "gcloud_zone", ".", "list_resource_record_sets", "(", "page_token", "=", "page_token", ")", "for", "gcloud_record", "in", "gcloud_iterato...
46.636364
0.00191
def _sort_by_sortedset_before(self): """ Return True if we have to sort by set and do the stuff *before* asking redis for the sort """ return self._sort_by_sortedset and self._sort_limits and (not self._lazy_collection['pks'] ...
[ "def", "_sort_by_sortedset_before", "(", "self", ")", ":", "return", "self", ".", "_sort_by_sortedset", "and", "self", ".", "_sort_limits", "and", "(", "not", "self", ".", "_lazy_collection", "[", "'pks'", "]", "or", "self", ".", "_want_score_value", ")" ]
49.428571
0.014205
def get_zeta_i_j_given_separate_counts(self, y_i, y_j): ''' Parameters ---------- y_i, np.array(int) Arrays of word counts of words occurring in positive class y_j, np.array(int) Returns ------- np.array of z-scores ''' n_i, n_j = y_i.sum(), y_j.sum() prior_scale_j = prior_scale_i = 1 if sel...
[ "def", "get_zeta_i_j_given_separate_counts", "(", "self", ",", "y_i", ",", "y_j", ")", ":", "n_i", ",", "n_j", "=", "y_i", ".", "sum", "(", ")", ",", "y_j", ".", "sum", "(", ")", "prior_scale_j", "=", "prior_scale_i", "=", "1", "if", "self", ".", "_s...
37.111111
0.029176
def regex_for_range(min_, max_): """ > regex_for_range(12, 345) '1[2-9]|[2-9]\d|[1-2]\d{2}|3[0-3]\d|34[0-5]' """ positive_subpatterns = [] negative_subpatterns = [] max_ -= 1 if min_ < 0: min__ = 1 if max_ < 0: min__ = abs(max_) max__ = abs(min_) ...
[ "def", "regex_for_range", "(", "min_", ",", "max_", ")", ":", "positive_subpatterns", "=", "[", "]", "negative_subpatterns", "=", "[", "]", "max_", "-=", "1", "if", "min_", "<", "0", ":", "min__", "=", "1", "if", "max_", "<", "0", ":", "min__", "=", ...
34.961538
0.009636
def set_type(self, form_type, css_class=None): """ Maybe you have a site where you're not allowed to change the python code, and for some reason you need to change the form_type in a template, not because you want to (because it seems like a bit of a hack) but maybe you don't rea...
[ "def", "set_type", "(", "self", ",", "form_type", ",", "css_class", "=", "None", ")", ":", "self", ".", "form_type", "=", "form_type", "if", "css_class", "is", "None", ":", "self", ".", "css_class", "=", "self", ".", "get_default_css_class", "(", "form_typ...
38.409091
0.008083
def limits(self,variable): """Return minimum and maximum of variable across all rows of data.""" (vmin,vmax), = self.SELECT('min(%(variable)s), max(%(variable)s)' % vars()) return vmin,vmax
[ "def", "limits", "(", "self", ",", "variable", ")", ":", "(", "vmin", ",", "vmax", ")", ",", "=", "self", ".", "SELECT", "(", "'min(%(variable)s), max(%(variable)s)'", "%", "vars", "(", ")", ")", "return", "vmin", ",", "vmax" ]
52.5
0.028169
def parse(resp) -> DataFrameType: """Makes a dictionary of DataFrames from a response object""" statements = [] for statement in resp['results']: series = {} for s in statement.get('series', []): series[_get_name(s)] = _drop_zero_index(_serializer(s)) statements.append(se...
[ "def", "parse", "(", "resp", ")", "->", "DataFrameType", ":", "statements", "=", "[", "]", "for", "statement", "in", "resp", "[", "'results'", "]", ":", "series", "=", "{", "}", "for", "s", "in", "statement", ".", "get", "(", "'series'", ",", "[", ...
33.3125
0.001825
def bestModelIdAndErrScore(self, swarmId=None, genIdx=None): """Return the model ID of the model with the best result so far and it's score on the optimize metric. If swarm is None, then it returns the global best, otherwise it returns the best for the given swarm for all generatons up to and including ...
[ "def", "bestModelIdAndErrScore", "(", "self", ",", "swarmId", "=", "None", ",", "genIdx", "=", "None", ")", ":", "if", "swarmId", "is", "None", ":", "return", "(", "self", ".", "_bestModelID", ",", "self", ".", "_bestResult", ")", "else", ":", "if", "s...
36.685714
0.009863
def get_assessment_part_form_for_create_for_assessment(self, assessment_id, assessment_part_record_types): """Gets the assessment part form for creating new assessment parts for an assessment. A new form should be requested for each create transaction. arg: assessment_id (osid.id.Id): an as...
[ "def", "get_assessment_part_form_for_create_for_assessment", "(", "self", ",", "assessment_id", ",", "assessment_part_record_types", ")", ":", "# Implemented from template for", "# osid.learning.ActivityAdminSession.get_activity_form_for_create_template", "if", "not", "isinstance", "("...
49.270833
0.002488
def search_record(datas, keyword): """Search target JSON -> dictionary Arguments: datas: dictionary of record datas keyword: search keyword (default is null) Key target is "name" or "content" or "type". default null. Either key and type, or on the other hand. When keyword has inc...
[ "def", "search_record", "(", "datas", ",", "keyword", ")", ":", "key_name", ",", "key_type", ",", "key_content", "=", "False", ",", "False", ",", "False", "if", "keyword", ".", "find", "(", "','", ")", ">", "-", "1", ":", "if", "len", "(", "keyword",...
29.977273
0.000734
def get_domain(context, prefix): """ Return the domain used for the tracking code. Each service may be configured with its own domain (called `<name>_domain`), or a django-analytical-wide domain may be set (using `analytical_domain`. If no explicit domain is found in either the context or the ...
[ "def", "get_domain", "(", "context", ",", "prefix", ")", ":", "domain", "=", "context", ".", "get", "(", "'%s_domain'", "%", "prefix", ")", "if", "domain", "is", "None", ":", "domain", "=", "context", ".", "get", "(", "'analytical_domain'", ")", "if", ...
41.166667
0.000989
def SLIT_GAUSSIAN(x,g): """ Instrumental (slit) function. B(x) = sqrt(ln(2)/pi)/γ*exp(-ln(2)*(x/γ)**2), where γ/2 is a gaussian half-width at half-maximum. """ g /= 2 return sqrt(log(2))/(sqrt(pi)*g)*exp(-log(2)*(x/g)**2)
[ "def", "SLIT_GAUSSIAN", "(", "x", ",", "g", ")", ":", "g", "/=", "2", "return", "sqrt", "(", "log", "(", "2", ")", ")", "/", "(", "sqrt", "(", "pi", ")", "*", "g", ")", "*", "exp", "(", "-", "log", "(", "2", ")", "*", "(", "x", "/", "g"...
30.25
0.008032
def _unweave(target, advices, pointcut, ctx, depth, depth_predicate): """Unweave deeply advices in target.""" # if weaving has to be done if pointcut is None or pointcut(target): # do something only if target is intercepted if is_intercepted(target): _remove_advices(target=targe...
[ "def", "_unweave", "(", "target", ",", "advices", ",", "pointcut", ",", "ctx", ",", "depth", ",", "depth_predicate", ")", ":", "# if weaving has to be done", "if", "pointcut", "is", "None", "or", "pointcut", "(", "target", ")", ":", "# do something only if targe...
39.2
0.001245
def parse_table(tag): """ returns tuple of type ("class"/"func") and list of param strings. :param tag: :return: """ first = True table_header = None table_type = 'unknown' param_strings = [] thead = tag.find('thead', recursive=False) theads = None # list (items in <tr> row...
[ "def", "parse_table", "(", "tag", ")", ":", "first", "=", "True", "table_header", "=", "None", "table_type", "=", "'unknown'", "param_strings", "=", "[", "]", "thead", "=", "tag", ".", "find", "(", "'thead'", ",", "recursive", "=", "False", ")", "theads"...
28.130952
0.001635
def tasks(self): """Get the list of tasks""" self._rwlock.reader_acquire() tl = [v for v in self._tasks.values()] tl.sort(key=lambda x: x.task_id) self._rwlock.reader_release() return tl
[ "def", "tasks", "(", "self", ")", ":", "self", ".", "_rwlock", ".", "reader_acquire", "(", ")", "tl", "=", "[", "v", "for", "v", "in", "self", ".", "_tasks", ".", "values", "(", ")", "]", "tl", ".", "sort", "(", "key", "=", "lambda", "x", ":", ...
25.333333
0.008475
def get_flash(self, format_ = "nl"): """ return a string representations of the flash """ flash = [self.flash.read(i) for i in range(self.flash.size)] return self._format_mem(flash, format_)
[ "def", "get_flash", "(", "self", ",", "format_", "=", "\"nl\"", ")", ":", "flash", "=", "[", "self", ".", "flash", ".", "read", "(", "i", ")", "for", "i", "in", "range", "(", "self", ".", "flash", ".", "size", ")", "]", "return", "self", ".", "...
32.666667
0.044776
async def set_key_metadata(wallet_handle: int, verkey: str, metadata: str) -> None: """ Creates keys pair and stores in the wallet. :param wallet_handle: Wallet handle (created by open_wallet). :param verkey: the key (verkey, key id) to store metada...
[ "async", "def", "set_key_metadata", "(", "wallet_handle", ":", "int", ",", "verkey", ":", "str", ",", "metadata", ":", "str", ")", "->", "None", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "debug", "(", "\"set_ke...
34.818182
0.001693
def dump_public_key(public_key, encoding='pem'): """ Serializes a public key object into a byte string :param public_key: An oscrypto.asymmetric.PublicKey or asn1crypto.keys.PublicKeyInfo object :param encoding: A unicode string of "pem" or "der" :return: A byte string of ...
[ "def", "dump_public_key", "(", "public_key", ",", "encoding", "=", "'pem'", ")", ":", "if", "encoding", "not", "in", "set", "(", "[", "'pem'", ",", "'der'", "]", ")", ":", "raise", "ValueError", "(", "pretty_message", "(", "'''\n encoding must be on...
27.794872
0.001783
def ignore_stops_before_now(self): """Ignore any stops received before this point""" self._sentinel_stop = object() self._q.put(self._sentinel_stop)
[ "def", "ignore_stops_before_now", "(", "self", ")", ":", "self", ".", "_sentinel_stop", "=", "object", "(", ")", "self", ".", "_q", ".", "put", "(", "self", ".", "_sentinel_stop", ")" ]
42.25
0.011628
def is_method(method, flags=METHOD_ALL): """ Determines whether the passed value is a method satisfying certain conditions: * Being instance method. * Being class method. * Being bound method. * Being unbound method. Flag check is considered or-wise. The default is to consider every ...
[ "def", "is_method", "(", "method", ",", "flags", "=", "METHOD_ALL", ")", ":", "if", "isinstance", "(", "method", ",", "types", ".", "UnboundMethodType", ")", ":", "if", "flags", "&", "METHOD_CLASS", "and", "issubclass", "(", "method", ".", "im_class", ",",...
36.545455
0.002424
def save(self, request, resource=None, **kwargs): """Create a resource.""" resources = resource if isinstance(resource, list) else [resource] for obj in resources: obj.save() return resource
[ "def", "save", "(", "self", ",", "request", ",", "resource", "=", "None", ",", "*", "*", "kwargs", ")", ":", "resources", "=", "resource", "if", "isinstance", "(", "resource", ",", "list", ")", "else", "[", "resource", "]", "for", "obj", "in", "resou...
38.166667
0.008547
def delete_api_method(restApiId, resourcePath, httpMethod, region=None, key=None, keyid=None, profile=None): ''' Delete API method for a resource in the given API CLI Example: .. code-block:: bash salt myminion boto_apigateway.delete_api_method restApiId resourcePath httpMethod ''' t...
[ "def", "delete_api_method", "(", "restApiId", ",", "resourcePath", ",", "httpMethod", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "try", ":", "resource", "=", "describe_api_resource...
43.52381
0.008565
def rotateInDeclination(v1, theta_deg): """Rotation is chosen so a rotation of 90 degrees from zenith ends up at ra=0, dec=0""" axis = np.array([0,-1,0]) return rotateAroundVector(v1, axis, theta_deg)
[ "def", "rotateInDeclination", "(", "v1", ",", "theta_deg", ")", ":", "axis", "=", "np", ".", "array", "(", "[", "0", ",", "-", "1", ",", "0", "]", ")", "return", "rotateAroundVector", "(", "v1", ",", "axis", ",", "theta_deg", ")" ]
42.4
0.013889
def update_lincs_proteins(): """Load the csv of LINCS protein metadata into a dict. Produces a dict keyed by HMS LINCS protein ids, with the metadata contained in a dict of row values keyed by the column headers extracted from the csv. """ url = 'http://lincs.hms.harvard.edu/db/proteins/' p...
[ "def", "update_lincs_proteins", "(", ")", ":", "url", "=", "'http://lincs.hms.harvard.edu/db/proteins/'", "prot_data", "=", "load_lincs_csv", "(", "url", ")", "prot_dict", "=", "{", "d", "[", "'HMS LINCS ID'", "]", ":", "d", ".", "copy", "(", ")", "for", "d", ...
42.357143
0.00165
def pair_SAM_alignments_with_buffer( alignments, max_buffer_size=30000000, primary_only=False): '''Iterate over SAM aligments with buffer, position-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap max_buffer_size (int): maxmal n...
[ "def", "pair_SAM_alignments_with_buffer", "(", "alignments", ",", "max_buffer_size", "=", "30000000", ",", "primary_only", "=", "False", ")", ":", "almnt_buffer", "=", "{", "}", "ambiguous_pairing_counter", "=", "0", "for", "almnt", "in", "alignments", ":", "if", ...
43.024096
0.002464
def angle_factor(angle, ab, msrc, mrec): r"""Return the angle-dependent factor. The whole calculation in the wavenumber domain is only a function of the distance between the source and the receiver, it is independent of the angel. The angle-dependency is this factor, which can be applied to the cor...
[ "def", "angle_factor", "(", "angle", ",", "ab", ",", "msrc", ",", "mrec", ")", ":", "# 33/66 are completely symmetric and hence independent of angle", "if", "ab", "in", "[", "33", ",", "]", ":", "return", "np", ".", "ones", "(", "angle", ".", "size", ")", ...
33.666667
0.000566
def main(argv=None): """ben-doc entry point""" arguments = cli_common(__doc__, argv=argv) campaign_path = arguments['CAMPAIGN-DIR'] driver = CampaignDriver(campaign_path, expandcampvars=False) with pushd(campaign_path): render( template=arguments['--template'], ostr=a...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "arguments", "=", "cli_common", "(", "__doc__", ",", "argv", "=", "argv", ")", "campaign_path", "=", "arguments", "[", "'CAMPAIGN-DIR'", "]", "driver", "=", "CampaignDriver", "(", "campaign_path", ",", "ex...
31.923077
0.002342
def create_snapshot(self, systemId, snapshotSpecificationObject): """ Create snapshot for list of volumes :param systemID: Cluster ID :param snapshotSpecificationObject: Of class SnapshotSpecification :rtype: SnapshotGroupId """ self.conn.connection._check_login(...
[ "def", "create_snapshot", "(", "self", ",", "systemId", ",", "snapshotSpecificationObject", ")", ":", "self", ".", "conn", ".", "connection", ".", "_check_login", "(", ")", "#try:", "response", "=", "self", ".", "conn", ".", "connection", ".", "_do_post", "(...
52.307692
0.010116
def get_digests(self): """ Returns a map of images to their digests """ try: pulp = get_manifests_in_pulp_repository(self.workflow) except KeyError: pulp = None digests = {} # repository -> digests for registry in self.workflow.push_conf...
[ "def", "get_digests", "(", "self", ")", ":", "try", ":", "pulp", "=", "get_manifests_in_pulp_repository", "(", "self", ".", "workflow", ")", "except", "KeyError", ":", "pulp", "=", "None", "digests", "=", "{", "}", "# repository -> digests", "for", "registry",...
40.333333
0.001614
def flatten_dict(dct, separator='-->', allowed_types=[int, float, bool]): """Returns a list of string identifiers for each element in dct. Recursively scans through dct and finds every element whose type is in allowed_types and adds a string indentifier for it. eg: dct = { 'a': 'a stri...
[ "def", "flatten_dict", "(", "dct", ",", "separator", "=", "'-->'", ",", "allowed_types", "=", "[", "int", ",", "float", ",", "bool", "]", ")", ":", "flat_list", "=", "[", "]", "for", "key", "in", "sorted", "(", "dct", ")", ":", "if", "key", "[", ...
29.1
0.001109
def connect_input(self, spec_name, node, node_input, format=None, **kwargs): # @ReservedAssignment @IgnorePep8 """ Connects a study fileset_spec as an input to the provided node Parameters ---------- spec_name : str Name of the study data spec (or one of the IDs fro...
[ "def", "connect_input", "(", "self", ",", "spec_name", ",", "node", ",", "node_input", ",", "format", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# @ReservedAssignment @IgnorePep8", "if", "spec_name", "in", "self", ".", "study", ".", "ITERFIELDS", ":", ...
49.103448
0.002066
def push(self, url, title=''): """ Pushes the url into the history stack at the current index. :param url | <str> :return <bool> | changed """ # ignore refreshes of the top level if self.currentUrl() == url or self._blockStack: ...
[ "def", "push", "(", "self", ",", "url", ",", "title", "=", "''", ")", ":", "# ignore refreshes of the top level", "if", "self", ".", "currentUrl", "(", ")", "==", "url", "or", "self", ".", "_blockStack", ":", "return", "False", "self", ".", "_blockStack", ...
30.357143
0.011403
def get_option(file_name, section, option, separator='='): ''' Get value of a key from a section in an ini file. Returns ``None`` if no matching key was found. API Example: .. code-block:: python import salt sc = salt.client.get_local_client() sc.cmd('target', 'ini.get_opt...
[ "def", "get_option", "(", "file_name", ",", "section", ",", "option", ",", "separator", "=", "'='", ")", ":", "inifile", "=", "_Ini", ".", "get_ini_file", "(", "file_name", ",", "separator", "=", "separator", ")", "if", "section", ":", "try", ":", "retur...
26.392857
0.001305
def simxLoadUI(clientID, uiPathAndName, options, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' count = ct.c_int() uiHandles = ct.POINTER(ct.c_int)() if (sys.version_info[0] == 3) and (type(uiPathAndName) is str): uiPathAndN...
[ "def", "simxLoadUI", "(", "clientID", ",", "uiPathAndName", ",", "options", ",", "operationMode", ")", ":", "count", "=", "ct", ".", "c_int", "(", ")", "uiHandles", "=", "ct", ".", "POINTER", "(", "ct", ".", "c_int", ")", "(", ")", "if", "(", "sys", ...
33.789474
0.009091
def resolvePublic(self, pubID): """Try to lookup the catalog local reference associated to a public ID in that catalog """ ret = libxml2mod.xmlACatalogResolvePublic(self._o, pubID) return ret
[ "def", "resolvePublic", "(", "self", ",", "pubID", ")", ":", "ret", "=", "libxml2mod", ".", "xmlACatalogResolvePublic", "(", "self", ".", "_o", ",", "pubID", ")", "return", "ret" ]
44.4
0.00885
def _command_list(self): """ build the command list """ cmd = [self.params.binary, "-f", str(self.params.f), "-T", str(self.params.T), "-m", str(self.params.m), "-N", str(self.params.N), "-x", str(self.params.x), ...
[ "def", "_command_list", "(", "self", ")", ":", "cmd", "=", "[", "self", ".", "params", ".", "binary", ",", "\"-f\"", ",", "str", "(", "self", ".", "params", ".", "f", ")", ",", "\"-T\"", ",", "str", "(", "self", ".", "params", ".", "T", ")", ",...
34.388889
0.011006
def somethingFound(self,data,mode="phonefy"): ''' Verifying if something was found. Note that this method needed to be rewritten as in Spoj we need to look for a text which APPEARS instead of looking for a text that does NOT appear. :param data: Data where the self.notFo...
[ "def", "somethingFound", "(", "self", ",", "data", ",", "mode", "=", "\"phonefy\"", ")", ":", "#try:", "for", "text", "in", "self", ".", "notFoundText", "[", "mode", "]", ":", "if", "text", "in", "data", ":", "# This is the change with regards to the standard ...
45.066667
0.014493
def _GetTripIndex(self, schedule=None): """Return a list of (trip, index). trip: a Trip object index: an offset in trip.GetStopTimes() """ trip_index = [] for trip, sequence in self._GetTripSequence(schedule): for index, st in enumerate(trip.GetStopTimes()): if st.stop_sequence ==...
[ "def", "_GetTripIndex", "(", "self", ",", "schedule", "=", "None", ")", ":", "trip_index", "=", "[", "]", "for", "trip", ",", "sequence", "in", "self", ".", "_GetTripSequence", "(", "schedule", ")", ":", "for", "index", ",", "st", "in", "enumerate", "(...
33.1875
0.009158
def anim(self, start=0, stop=None, fps=30): """ Method to return a matplotlib animation. The start and stop frames may be specified as well as the fps. """ figure = self.state or self.initialize_plot() anim = animation.FuncAnimation(figure, self.update_frame, ...
[ "def", "anim", "(", "self", ",", "start", "=", "0", ",", "stop", "=", "None", ",", "fps", "=", "30", ")", ":", "figure", "=", "self", ".", "state", "or", "self", ".", "initialize_plot", "(", ")", "anim", "=", "animation", ".", "FuncAnimation", "(",...
43.25
0.009434
def report(self, value): """ Setter for **self.__report** attribute. :param value: Attribute value. :type value: bool """ if value is not None: assert type(value) is bool, "'{0}' attribute: '{1}' type is not 'bool'!".format("report", value) self.__re...
[ "def", "report", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "bool", ",", "\"'{0}' attribute: '{1}' type is not 'bool'!\"", ".", "format", "(", "\"report\"", ",", "value", ")", "s...
29.272727
0.009036
def _add_input_state(self, node, input_state): """ Add the input state to all successors of the given node. :param node: The node whose successors' input states will be touched. :param input_state: The state that will be added to successors of the node. :return: ...
[ "def", "_add_input_state", "(", "self", ",", "node", ",", "input_state", ")", ":", "successors", "=", "self", ".", "_graph_visitor", ".", "successors", "(", "node", ")", "for", "succ", "in", "successors", ":", "if", "succ", "in", "self", ".", "_state_map",...
39.5625
0.010802
async def delete(self, _id=None): """Delete entry from database table. Accepts id. delete(id) => 1 (if exists) delete(id) => {"error":404, "reason":"Not found"} (if does not exist) delete() => {"error":400, "reason":"Missed required fields"} """ if not _id: return {"error":400, "reason":"Missed r...
[ "async", "def", "delete", "(", "self", ",", "_id", "=", "None", ")", ":", "if", "not", "_id", ":", "return", "{", "\"error\"", ":", "400", ",", "\"reason\"", ":", "\"Missed required fields\"", "}", "document", "=", "await", "self", ".", "collection", "."...
26.52381
0.045061
def _replace_labels(doc): """Really hacky find-and-replace method that modifies one of the sklearn docstrings to change the semantics of labels_ for the subclasses""" lines = doc.splitlines() labelstart, labelend = None, None foundattributes = False for i, line in enumerate(lines): strip...
[ "def", "_replace_labels", "(", "doc", ")", ":", "lines", "=", "doc", ".", "splitlines", "(", ")", "labelstart", ",", "labelend", "=", "None", ",", "None", "foundattributes", "=", "False", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", "...
39.833333
0.002043
def makeBaudRatePacket(ID, rate): """ Set baud rate of servo. in: rate - 0: 9600, 1:57600, 2:115200, 3:1Mbps out: write packet """ if rate not in [0, 1, 2, 3]: raise Exception('Packet.makeBaudRatePacket: wrong rate {}'.format(rate)) pkt = makeWritePacket(ID, xl320.XL320_BAUD_RATE, [rate]) return pkt
[ "def", "makeBaudRatePacket", "(", "ID", ",", "rate", ")", ":", "if", "rate", "not", "in", "[", "0", ",", "1", ",", "2", ",", "3", "]", ":", "raise", "Exception", "(", "'Packet.makeBaudRatePacket: wrong rate {}'", ".", "format", "(", "rate", ")", ")", "...
27.363636
0.032154
def goto_line(self, line, column=0, end_column=0, move=True, word=''): """ Moves the text cursor to the specified position. :param line: Number of the line to go to (0 based) :param column: Optional column number. Default is 0 (start of line). :param move: True to move the curso...
[ "def", "goto_line", "(", "self", ",", "line", ",", "column", "=", "0", ",", "end_column", "=", "0", ",", "move", "=", "True", ",", "word", "=", "''", ")", ":", "line", "=", "min", "(", "line", ",", "self", ".", "line_count", "(", ")", ")", "tex...
44.151515
0.001343
def yticks(self): """Compute the yticks labels of this grid_stack, used for plotting the y-axis ticks when visualizing an image \ """ return np.linspace(np.amin(self.grid_stack.regular[:, 0]), np.amax(self.grid_stack.regular[:, 0]), 4)
[ "def", "yticks", "(", "self", ")", ":", "return", "np", ".", "linspace", "(", "np", ".", "amin", "(", "self", ".", "grid_stack", ".", "regular", "[", ":", ",", "0", "]", ")", ",", "np", ".", "amax", "(", "self", ".", "grid_stack", ".", "regular",...
64
0.015444
def load(): """ Loads the built-in operators into the global test engine. """ for operator in operators: module, symbols = operator[0], operator[1:] path = 'grappa.operators.{}'.format(module) # Dynamically import modules operator = __import__(path, None, None, symbols) ...
[ "def", "load", "(", ")", ":", "for", "operator", "in", "operators", ":", "module", ",", "symbols", "=", "operator", "[", "0", "]", ",", "operator", "[", "1", ":", "]", "path", "=", "'grappa.operators.{}'", ".", "format", "(", "module", ")", "# Dynamica...
31.5
0.002203
def __deactivate_recipes(self, plugin, *args, **kwargs): """ Deactivates/unregisters all recipes of the current plugin, if this plugin gets deactivated. """ recipes = self.get() for recipe in recipes.keys(): self.unregister(recipe)
[ "def", "__deactivate_recipes", "(", "self", ",", "plugin", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "recipes", "=", "self", ".", "get", "(", ")", "for", "recipe", "in", "recipes", ".", "keys", "(", ")", ":", "self", ".", "unregister", "...
39.571429
0.010601