Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
75
104k
code_tokens
sequence
avg_line_len
float64
7.91
980
score
float64
0
0.18
def get_requested_aosp_permissions(self): """ Returns requested permissions declared within AOSP project. This includes several other permissions as well, which are in the platform apps. :rtype: list of str """ aosp_permissions = [] all_permissions = self.get_pe...
[ "def", "get_requested_aosp_permissions", "(", "self", ")", ":", "aosp_permissions", "=", "[", "]", "all_permissions", "=", "self", ".", "get_permissions", "(", ")", "for", "perm", "in", "all_permissions", ":", "if", "perm", "in", "list", "(", "self", ".", "p...
35.214286
0.005929
def ask_and_eval(self, func, args=(), gradf=None, number=None, xmean=None, sigma_fac=1, evaluations=1, aggregation=np.median, kappa=1): """samples `number` solutions and evaluates them on `func`, where each solution `s` is resampled until ``self.is_feasible(s, func(s)) is True``. ...
[ "def", "ask_and_eval", "(", "self", ",", "func", ",", "args", "=", "(", ")", ",", "gradf", "=", "None", ",", "number", "=", "None", ",", "xmean", "=", "None", ",", "sigma_fac", "=", "1", ",", "evaluations", "=", "1", ",", "aggregation", "=", "np", ...
44.634146
0.002316
def PreprocessSources( self, artifacts_registry_object, source_path_specs, resolver_context=None): """Preprocesses the sources. Args: artifacts_registry_object (artifacts.ArtifactDefinitionsRegistry): artifact definitions registry. source_path_specs (list[dfvfs.PathSpec]): pat...
[ "def", "PreprocessSources", "(", "self", ",", "artifacts_registry_object", ",", "source_path_specs", ",", "resolver_context", "=", "None", ")", ":", "detected_operating_systems", "=", "[", "]", "for", "source_path_spec", "in", "source_path_specs", ":", "try", ":", "...
37.463415
0.005711
async def update_api(request: web.Request) -> web.Response: """ This handler accepts a POST request with Content-Type: multipart/form-data and file fields in the body named "whl", "serverlib", and "fw". The "whl" and "serverlib" files should be valid Python wheels to be installed ("whl" is expected ...
[ "async", "def", "update_api", "(", "request", ":", "web", ".", "Request", ")", "->", "web", ".", "Response", ":", "log", ".", "debug", "(", "'Update request received'", ")", "data", "=", "await", "request", ".", "post", "(", ")", "try", ":", "res0", "=...
43.314286
0.000645
def _parsemeta_tmy2(columns, line): """Retrieves metadata from the top line of the tmy2 file. Parameters ---------- columns : string String of column headings in the header line : string Header string containing DataFrame Returns ------- meta : Dict of metadata contain...
[ "def", "_parsemeta_tmy2", "(", "columns", ",", "line", ")", ":", "# Remove duplicated spaces, and read in each element", "rawmeta", "=", "\" \"", ".", "join", "(", "line", ".", "split", "(", ")", ")", ".", "split", "(", "\" \"", ")", "meta", "=", "rawmeta", ...
31.59375
0.00096
def parse_rec(filename): """ Parse a PASCAL VOC xml file """ tree = ET.parse(filename) objects = [] for obj in tree.findall('object'): obj_struct = {} obj_struct['name'] = obj.find('name').text obj_struct['pose'] = obj.find('pose').text obj_struct['truncated'] = int(obj.f...
[ "def", "parse_rec", "(", "filename", ")", ":", "tree", "=", "ET", ".", "parse", "(", "filename", ")", "objects", "=", "[", "]", "for", "obj", "in", "tree", ".", "findall", "(", "'object'", ")", ":", "obj_struct", "=", "{", "}", "obj_struct", "[", "...
40.666667
0.001335
def main(self): """The main function containing the loop for communication and process management. This function is the heart of the daemon. It is responsible for: - Client communication - Executing commands from clients - Update the status of processes by polling the Pr...
[ "def", "main", "(", "self", ")", ":", "try", ":", "while", "self", ".", "running", ":", "# Trigger the processing of finished processes by the ProcessHandler.", "# If there are finished processes we write the log to keep it up to date.", "if", "self", ".", "process_handler", "....
50.491379
0.002679
def account_info(self): """ Certain attributes have a user's account information associated with it such as a gifted or crafted item. A dict with two keys: 'persona' and 'id64'. None if the attribute has no account information attached to it. """ account_info = self._attribute.g...
[ "def", "account_info", "(", "self", ")", ":", "account_info", "=", "self", ".", "_attribute", ".", "get", "(", "\"account_info\"", ")", "if", "account_info", ":", "return", "{", "\"persona\"", ":", "account_info", ".", "get", "(", "\"personaname\"", ",", "\"...
42.583333
0.003831
def add_route(self, gateway, network): """ Add a route to engine. Specify gateway and network. If this is the default gateway, use a network address of 0.0.0.0/0. .. note: This will fail if the gateway provided does not have a corresponding interface on the netw...
[ "def", "add_route", "(", "self", ",", "gateway", ",", "network", ")", ":", "self", ".", "make_request", "(", "EngineCommandFailed", ",", "method", "=", "'create'", ",", "resource", "=", "'add_route'", ",", "params", "=", "{", "'gateway'", ":", "gateway", "...
36.8
0.002649
def connect(provider_id): """Starts the provider connection OAuth flow""" provider = get_provider_or_404(provider_id) callback_url = get_authorize_callback('connect', provider_id) allow_view = get_url(config_value('CONNECT_ALLOW_VIEW')) pc = request.form.get('next', allow_view) session[config_va...
[ "def", "connect", "(", "provider_id", ")", ":", "provider", "=", "get_provider_or_404", "(", "provider_id", ")", "callback_url", "=", "get_authorize_callback", "(", "'connect'", ",", "provider_id", ")", "allow_view", "=", "get_url", "(", "config_value", "(", "'CON...
50
0.002457
def compute_position_log(self, td=None, method='mc', update_deviation=True): """ Args: deviation (ndarray): A deviation survey with rows like MD, INC, AZI td (Number): The TD of the well, if no...
[ "def", "compute_position_log", "(", "self", ",", "td", "=", "None", ",", "method", "=", "'mc'", ",", "update_deviation", "=", "True", ")", ":", "deviation", "=", "np", ".", "copy", "(", "self", ".", "deviation", ")", "# Adjust to TD.", "if", "td", "is", ...
36.3875
0.001672
def add_event(self, event): """ Add an event to the heap/priority queue Parameters ---------- event : Event """ assert event.dep_time_ut <= event.arr_time_ut heappush(self.heap, event)
[ "def", "add_event", "(", "self", ",", "event", ")", ":", "assert", "event", ".", "dep_time_ut", "<=", "event", ".", "arr_time_ut", "heappush", "(", "self", ".", "heap", ",", "event", ")" ]
24
0.008032
def padded_accuracy_topk(predictions, labels, k, weights_fn=common_layers.weights_nonzero): """Percentage of times that top-k predictions matches labels on non-0s.""" with tf.variable_scope("padded_accuracy_topk", values=[predictions, labels...
[ "def", "padded_accuracy_topk", "(", "predictions", ",", "labels", ",", "k", ",", "weights_fn", "=", "common_layers", ".", "weights_nonzero", ")", ":", "with", "tf", ".", "variable_scope", "(", "\"padded_accuracy_topk\"", ",", "values", "=", "[", "predictions", "...
50.421053
0.003074
def get_device_scale(self): """Returns the previous device offset set by :meth:`set_device_scale`. *New in cairo 1.14.* *New in cairocffi 0.9.* """ size = ffi.new('double[2]') cairo.cairo_surface_get_device_scale(self._pointer, size + 0, size + 1) return tuple(...
[ "def", "get_device_scale", "(", "self", ")", ":", "size", "=", "ffi", ".", "new", "(", "'double[2]'", ")", "cairo", ".", "cairo_surface_get_device_scale", "(", "self", ".", "_pointer", ",", "size", "+", "0", ",", "size", "+", "1", ")", "return", "tuple",...
28.636364
0.006154
def rates(ctx, opts): """Check current API rate limits.""" click.echo("Retrieving rate limits ... ", nl=False) context_msg = "Failed to retrieve status!" with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg): with maybe_spinner(opts): resources_limits = get_rate_limits...
[ "def", "rates", "(", "ctx", ",", "opts", ")", ":", "click", ".", "echo", "(", "\"Retrieving rate limits ... \"", ",", "nl", "=", "False", ")", "context_msg", "=", "\"Failed to retrieve status!\"", "with", "handle_api_exceptions", "(", "ctx", ",", "opts", "=", ...
34.860465
0.001947
def _add_to_found_storage(self, storage_url): """ Will first normalize the img src and then check if this bucket was discovered before If it is in storage_urls_found, the function returns Else, it send a GET for the original URL (normalized image src) and will look for "AmazonS3" in ...
[ "def", "_add_to_found_storage", "(", "self", ",", "storage_url", ")", ":", "storage_url", "=", "self", ".", "_normalize_url", "(", "storage_url", ")", "bucket", "=", "S3Bucket", "(", "storage_url", ")", "if", "bucket", ".", "url", "not", "in", "self", ".", ...
46.428571
0.00402
def get_pattern_link_topattern(self, patternnumber): """Get the 'linked pattern' value for a given pattern. Args: patternnumber (integer): From 0-7 Returns: The 'linked pattern' value (int). """ _checkPatternNumber(patternnumber) add...
[ "def", "get_pattern_link_topattern", "(", "self", ",", "patternnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "address", "=", "_calculateRegisterAddress", "(", "'linkpattern'", ",", "patternnumber", ")", "return", "self", ".", "read_register", "(...
31.769231
0.007059
def get_backend_expiry(self, expiry=DEFAULT_EXPIRY): """ Return the expiry value usable by this backend based upon the provided timeout. """ if expiry == DEFAULT_EXPIRY: expiry = self.default_expiry elif expiry == 0: # avoid time.time() related pre...
[ "def", "get_backend_expiry", "(", "self", ",", "expiry", "=", "DEFAULT_EXPIRY", ")", ":", "if", "expiry", "==", "DEFAULT_EXPIRY", ":", "expiry", "=", "self", ".", "default_expiry", "elif", "expiry", "==", "0", ":", "# avoid time.time() related precision issues", "...
37.363636
0.004751
def lock(self, page): """Locks *page*.""" result = self._dokuwiki.send('dokuwiki.setLocks', lock=[page], unlock=[]) if result['lockfail']: raise DokuWikiError('unable to lock page')
[ "def", "lock", "(", "self", ",", "page", ")", ":", "result", "=", "self", ".", "_dokuwiki", ".", "send", "(", "'dokuwiki.setLocks'", ",", "lock", "=", "[", "page", "]", ",", "unlock", "=", "[", "]", ")", "if", "result", "[", "'lockfail'", "]", ":",...
41.5
0.007874
def save_any_file(data, filename): """ Determines a Saver based on the the file extension. Returns whether successfully saved. :param filename: the name of the file to save :type filename: str :param data: the data to save :type data: Instances :return: whether successfully saved :rtype...
[ "def", "save_any_file", "(", "data", ",", "filename", ")", ":", "saver", "=", "saver_for_file", "(", "filename", ")", "if", "saver", "is", "None", ":", "return", "False", "else", ":", "saver", ".", "save_file", "(", "data", ",", "filename", ")", "return"...
27.529412
0.004132
def open_session(self): """ Open tensorflow session. Exposed for memory management. """ with self._graph.as_default(): init = tf.initialize_all_variables() self._sess = tf.Session() self._sess.run(init)
[ "def", "open_session", "(", "self", ")", ":", "with", "self", ".", "_graph", ".", "as_default", "(", ")", ":", "init", "=", "tf", ".", "initialize_all_variables", "(", ")", "self", ".", "_sess", "=", "tf", ".", "Session", "(", ")", "self", ".", "_ses...
41.5
0.007874
def interactive_output(f, controls): """Connect widget controls to a function. This function does not generate a user interface for the widgets (unlike `interact`). This enables customisation of the widget user interface layout. The user interface layout must be defined and displayed manually. """ ...
[ "def", "interactive_output", "(", "f", ",", "controls", ")", ":", "out", "=", "Output", "(", ")", "def", "observer", "(", "change", ")", ":", "kwargs", "=", "{", "k", ":", "v", ".", "value", "for", "k", ",", "v", "in", "controls", ".", "items", "...
33.380952
0.008322
def return_dat(self, chan, begsam, endsam): """Return the data as 2D numpy.ndarray. Parameters ---------- chan : int or list index (indices) of the channels to read begsam : int index of the first sample endsam : int index of the last ...
[ "def", "return_dat", "(", "self", ",", "chan", ",", "begsam", ",", "endsam", ")", ":", "dat_begsam", "=", "max", "(", "begsam", ",", "0", ")", "dat_endsam", "=", "min", "(", "endsam", ",", "self", ".", "n_samples", ")", "dur", "=", "dat_endsam", "-",...
30.803922
0.002468
def dist_location(dist): """ Get the site-packages location of this distribution. Generally this is dist.location, except in the case of develop-installed packages, where dist.location is the source code location, and we want to know where the egg-link file is. """ egg_link = egg_link_path(...
[ "def", "dist_location", "(", "dist", ")", ":", "egg_link", "=", "egg_link_path", "(", "dist", ")", "if", "os", ".", "path", ".", "exists", "(", "egg_link", ")", ":", "return", "egg_link", "return", "dist", ".", "location" ]
33
0.002457
def effectiveTagSet(self): """Return a :class:`~pyasn1.type.tag.TagSet` object of the currently initialized component or self (if |ASN.1| is tagged).""" if self.tagSet: return self.tagSet else: component = self.getComponent() return component.effectiveTagSet
[ "def", "effectiveTagSet", "(", "self", ")", ":", "if", "self", ".", "tagSet", ":", "return", "self", ".", "tagSet", "else", ":", "component", "=", "self", ".", "getComponent", "(", ")", "return", "component", ".", "effectiveTagSet" ]
44.571429
0.009434
def request(self, cmd, *args, **kwargs): """ Request data fromo the server. :param cmd: repo handler command. :returns: Result. """ params = {'action': cmd} #TODO: serialize the kwargs? params.update(kwargs) return self.__request(self.url, params...
[ "def", "request", "(", "self", ",", "cmd", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'action'", ":", "cmd", "}", "#TODO: serialize the kwargs?", "params", ".", "update", "(", "kwargs", ")", "return", "self", ".", "__requ...
25.833333
0.009346
def datetime_to_synergy(time_qualifier, dt): """ method parses datetime and returns Synergy Date""" if time_qualifier == QUALIFIER_HOURLY: date_format = SYNERGY_HOURLY_PATTERN elif time_qualifier == QUALIFIER_DAILY: date_format = SYNERGY_DAILY_PATTERN elif time_qualifier == QUALIFIER_MON...
[ "def", "datetime_to_synergy", "(", "time_qualifier", ",", "dt", ")", ":", "if", "time_qualifier", "==", "QUALIFIER_HOURLY", ":", "date_format", "=", "SYNERGY_HOURLY_PATTERN", "elif", "time_qualifier", "==", "QUALIFIER_DAILY", ":", "date_format", "=", "SYNERGY_DAILY_PATT...
44.4
0.001471
def clustering_coef_bu(G): ''' The clustering coefficient is the fraction of triangles around a node (equiv. the fraction of nodes neighbors that are neighbors of each other). Parameters ---------- A : NxN np.ndarray binary undirected connection matrix Returns ------- C : N...
[ "def", "clustering_coef_bu", "(", "G", ")", ":", "n", "=", "len", "(", "G", ")", "C", "=", "np", ".", "zeros", "(", "(", "n", ",", ")", ")", "for", "u", "in", "range", "(", "n", ")", ":", "V", ",", "=", "np", ".", "where", "(", "G", "[", ...
23.192308
0.001592
def pack_tups(*args): """Pack an arbitrary set of iterables and non-iterables into tuples. Function packs a set of inputs with arbitrary iterability into tuples. Iterability is tested with :func:`iterable`. Non-iterable inputs are repeated in each output tuple. Iterable inputs are expanded uniforml...
[ "def", "pack_tups", "(", "*", "args", ")", ":", "# Imports", "import", "numpy", "as", "np", "# Debug flag", "_DEBUG", "=", "False", "# Marker value for non-iterable items", "NOT_ITER", "=", "-", "1", "# Uninitialized test value", "UNINIT_VAL", "=", "-", "1", "# Pr...
31.270833
0.003229
def ifusergroup(parser, token): """ Check to see if the currently logged in user belongs to a specific group. Requires the Django authentication contrib app and middleware. Usage: {% ifusergroup Admins %} ... {% endifusergroup %}, or {% ifusergroup Admins Clients Sellers %} ... {% else %} ... {%...
[ "def", "ifusergroup", "(", "parser", ",", "token", ")", ":", "try", ":", "tokensp", "=", "token", ".", "split_contents", "(", ")", "groups", "=", "[", "]", "groups", "+=", "tokensp", "[", "1", ":", "]", "except", "ValueError", ":", "raise", "template",...
35.2
0.005531
def read_lsm_timestamps(fh): """Read LSM time stamps from file and return as list.""" size, count = struct.unpack('<ii', fh.read(8)) if size != (8 + 8 * count): log.warning('read_lsm_timestamps: invalid LSM TimeStamps block') return [] # return struct.unpack('<%dd' % count, fh.read(8*cou...
[ "def", "read_lsm_timestamps", "(", "fh", ")", ":", "size", ",", "count", "=", "struct", ".", "unpack", "(", "'<ii'", ",", "fh", ".", "read", "(", "8", ")", ")", "if", "size", "!=", "(", "8", "+", "8", "*", "count", ")", ":", "log", ".", "warnin...
45.25
0.00271
def cli(env, identifier): """Cancel global IP.""" mgr = SoftLayer.NetworkManager(env.client) global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier, name='global ip') if not (env.skip_confirmations or formatting.no_going_back(global_ip_id)): ...
[ "def", "cli", "(", "env", ",", "identifier", ")", ":", "mgr", "=", "SoftLayer", ".", "NetworkManager", "(", "env", ".", "client", ")", "global_ip_id", "=", "helpers", ".", "resolve_id", "(", "mgr", ".", "resolve_global_ip_ids", ",", "identifier", ",", "nam...
35.363636
0.002506
def do_notebook(self, name): """Run a notebook file after optionally converting it to a python file.""" CONVERT_NOTEBOOKS = int(os.getenv('CONVERT_NOTEBOOKS', True)) s = StringIO() if mock: out = unittest.mock.patch('sys.stdout', new=MockDevice(s)) err = u...
[ "def", "do_notebook", "(", "self", ",", "name", ")", ":", "CONVERT_NOTEBOOKS", "=", "int", "(", "os", ".", "getenv", "(", "'CONVERT_NOTEBOOKS'", ",", "True", ")", ")", "s", "=", "StringIO", "(", ")", "if", "mock", ":", "out", "=", "unittest", ".", "m...
40
0.00349
def call_api(self, method_type, method_name, valid_status_codes, resource, data, uid, **kwargs): """ Make HTTP calls. Args: method_type: The HTTP method method_name: The name of the python method making the HTTP call valid_st...
[ "def", "call_api", "(", "self", ",", "method_type", ",", "method_name", ",", "valid_status_codes", ",", "resource", ",", "data", ",", "uid", ",", "*", "*", "kwargs", ")", ":", "url", "=", "resource", ".", "get_resource_url", "(", "resource", ",", "base_url...
38.255814
0.002371
def create_readme_with_long_description(): '''Try to convert content of README.md into rst format using pypandoc, write it into README and return it. If pypandoc cannot be imported write content of README.md unchanged into README and return it. ''' this_dir = os.path.abspath(os.path.dirname(__f...
[ "def", "create_readme_with_long_description", "(", ")", ":", "this_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "readme_md", "=", "os", ".", "path", ".", "join", "(", "this_dir", ",", ...
34.125
0.00089
def check_exports(mod, specs, renamings): ''' Does nothing but raising PythranSyntaxError if specs references an undefined global ''' functions = {renamings.get(k, k): v for k, v in specs.functions.items()} mod_functions = {node.name: node for node in mod.body if isinstance...
[ "def", "check_exports", "(", "mod", ",", "specs", ",", "renamings", ")", ":", "functions", "=", "{", "renamings", ".", "get", "(", "k", ",", "k", ")", ":", "v", "for", "k", ",", "v", "in", "specs", ".", "functions", ".", "items", "(", ")", "}", ...
39.333333
0.000919
def get_status_from_resource(self, response): """Process the latest status update retrieved from the same URL as the previous request. :param requests.Response response: latest REST call response. :raises: BadResponse if status not 200 or 204. """ self._raise_if_bad_http...
[ "def", "get_status_from_resource", "(", "self", ",", "response", ")", ":", "self", ".", "_raise_if_bad_http_status_and_method", "(", "response", ")", "if", "self", ".", "_is_empty", "(", "response", ")", ":", "raise", "BadResponse", "(", "'The response from long run...
41
0.002981
def parse_field_value(field_info, value): """Parse ``value`` according to ``field_info`` """ if field_info.id == "FT": return [x for x in value.split(";") if x != "."] elif field_info.type == "Flag": return True elif field_info.number == 1: return convert_field_value(field_in...
[ "def", "parse_field_value", "(", "field_info", ",", "value", ")", ":", "if", "field_info", ".", "id", "==", "\"FT\"", ":", "return", "[", "x", "for", "x", "in", "value", ".", "split", "(", "\";\"", ")", "if", "x", "!=", "\".\"", "]", "elif", "field_i...
34.285714
0.004057
def getAsWmsDatasetString(self, session): """ Retrieve the WMS Raster as a string in the WMS Dataset format """ # Magic numbers FIRST_VALUE_INDEX = 12 # Write value raster if type(self.raster) != type(None): # Convert to GRASS ASCII Raster ...
[ "def", "getAsWmsDatasetString", "(", "self", ",", "session", ")", ":", "# Magic numbers", "FIRST_VALUE_INDEX", "=", "12", "# Write value raster", "if", "type", "(", "self", ".", "raster", ")", "!=", "type", "(", "None", ")", ":", "# Convert to GRASS ASCII Raster",...
30.916667
0.003922
def create_site(self, params={}): """ Creates a site http://dev.wheniwork.com/#create-update-site """ url = "/2/sites/" body = params data = self._post_resource(url, body) return self.site_from_json(data["site"])
[ "def", "create_site", "(", "self", ",", "params", "=", "{", "}", ")", ":", "url", "=", "\"/2/sites/\"", "body", "=", "params", "data", "=", "self", ".", "_post_resource", "(", "url", ",", "body", ")", "return", "self", ".", "site_from_json", "(", "data...
24.363636
0.007194
def is_plugin_installed(name): """Check if a plugin is installed, even if it's not enabled. :param name: Name of the plugin to check. :type name: string :return: If the plugin is installed. :rtype: bool """ for directory in plugin_paths: if isdir(join(directory, name)): ...
[ "def", "is_plugin_installed", "(", "name", ")", ":", "for", "directory", "in", "plugin_paths", ":", "if", "isdir", "(", "join", "(", "directory", ",", "name", ")", ")", ":", "return", "True", "return", "False" ]
25.923077
0.002865
def sweep(ABF,sweep=None,rainbow=True,alpha=None,protocol=False,color='b', continuous=False,offsetX=0,offsetY=0,minutes=False, decimate=None,newFigure=False): """ Load a particular sweep then plot it. If sweep is None or False, just plot current dataX/dataY. If rainbow, it'...
[ "def", "sweep", "(", "ABF", ",", "sweep", "=", "None", ",", "rainbow", "=", "True", ",", "alpha", "=", "None", ",", "protocol", "=", "False", ",", "color", "=", "'b'", ",", "continuous", "=", "False", ",", "offsetX", "=", "0", ",", "offsetY", "=", ...
29.446154
0.02275
def __substitute_objects(self, value, context_dict): """ recursively substitute value with the context_dict """ if type(value) == dict: return dict([(k, self.__substitute_objects(v, context_dict)) for k, v in value.items()]) elif type(value) == str: try: ...
[ "def", "__substitute_objects", "(", "self", ",", "value", ",", "context_dict", ")", ":", "if", "type", "(", "value", ")", "==", "dict", ":", "return", "dict", "(", "[", "(", "k", ",", "self", ".", "__substitute_objects", "(", "v", ",", "context_dict", ...
37.466667
0.005208
def create_polynoms(): """Create and return poly1d objects. Uses the parameters from Morgan to create poly1d objects for calculations. """ fname = pr.resource_filename('pyciss', 'data/soliton_prediction_parameters.csv') res_df = pd.read_csv(fname) polys = {} for resorder, row in zip('65...
[ "def", "create_polynoms", "(", ")", ":", "fname", "=", "pr", ".", "resource_filename", "(", "'pyciss'", ",", "'data/soliton_prediction_parameters.csv'", ")", "res_df", "=", "pd", ".", "read_csv", "(", "fname", ")", "polys", "=", "{", "}", "for", "resorder", ...
37.285714
0.005607
def get_weekly_charts(self, chart_kind, from_date=None, to_date=None): """ Returns the weekly charts for the week starting from the from_date value to the to_date value. chart_kind should be one of "album", "artist" or "track" """ method = ".getWeekly" + chart_kind.title(...
[ "def", "get_weekly_charts", "(", "self", ",", "chart_kind", ",", "from_date", "=", "None", ",", "to_date", "=", "None", ")", ":", "method", "=", "\".getWeekly\"", "+", "chart_kind", ".", "title", "(", ")", "+", "\"Chart\"", "chart_type", "=", "eval", "(", ...
37.642857
0.002775
def get_proxy_version(self): """ Returns version of the Cloud SQL Proxy. """ self._download_sql_proxy_if_needed() command_to_run = [self.sql_proxy_path] command_to_run.extend(['--version']) command_to_run.extend(self._get_credential_parameters()) result = ...
[ "def", "get_proxy_version", "(", "self", ")", ":", "self", ".", "_download_sql_proxy_if_needed", "(", ")", "command_to_run", "=", "[", "self", ".", "sql_proxy_path", "]", "command_to_run", ".", "extend", "(", "[", "'--version'", "]", ")", "command_to_run", ".", ...
35.733333
0.003636
def from_prefix(cls, container, prefix): """Create from prefix object.""" if cls._is_gs_folder(prefix): name, suffix, extra = prefix.name.partition(cls._gs_folder_suffix) if (suffix, extra) == (cls._gs_folder_suffix, ''): # Patch GS specific folder to remove suffi...
[ "def", "from_prefix", "(", "cls", ",", "container", ",", "prefix", ")", ":", "if", "cls", ".", "_is_gs_folder", "(", "prefix", ")", ":", "name", ",", "suffix", ",", "extra", "=", "prefix", ".", "name", ".", "partition", "(", "cls", ".", "_gs_folder_suf...
46.333333
0.004706
def remove_label(self, to_remove): """ Remove a label from the document. (-> rewrite the label file) """ if to_remove not in self.labels: return labels = self.labels labels.remove(to_remove) with self.fs.open(self.fs.join(self.path, self.LABEL_FILE), '...
[ "def", "remove_label", "(", "self", ",", "to_remove", ")", ":", "if", "to_remove", "not", "in", "self", ".", "labels", ":", "return", "labels", "=", "self", ".", "labels", "labels", ".", "remove", "(", "to_remove", ")", "with", "self", ".", "fs", ".", ...
38.615385
0.003891
def compress_for_rename(paths): """Returns a set containing the paths that need to be renamed. This set may include directories when the original sequence of paths included every file on disk. """ case_map = dict((os.path.normcase(p), p) for p in paths) remaining = set(case_map) unchecked =...
[ "def", "compress_for_rename", "(", "paths", ")", ":", "case_map", "=", "dict", "(", "(", "os", ".", "path", ".", "normcase", "(", "p", ")", ",", "p", ")", "for", "p", "in", "paths", ")", "remaining", "=", "set", "(", "case_map", ")", "unchecked", "...
37.833333
0.000716
def put_settings(self, app=None, index=None, settings=None, es=None): """Modify index settings. Index must exist already. """ if not index: index = self.index if not app: app = self.app if not es: es = self.es if not setting...
[ "def", "put_settings", "(", "self", ",", "app", "=", "None", ",", "index", "=", "None", ",", "settings", "=", "None", ",", "es", "=", "None", ")", ":", "if", "not", "index", ":", "index", "=", "self", ".", "index", "if", "not", "app", ":", "app",...
27.074074
0.005284
def add_filehandler(level, fmt, filename, mode, backup_count, limit, when): """Add a file handler to the global logger.""" kwargs = {} # If the filename is not set, use the default filename if filename is None: filename = getattr(sys.modules['__main__'], '__file__', 'log.py') filename ...
[ "def", "add_filehandler", "(", "level", ",", "fmt", ",", "filename", ",", "mode", ",", "backup_count", ",", "limit", ",", "when", ")", ":", "kwargs", "=", "{", "}", "# If the filename is not set, use the default filename", "if", "filename", "is", "None", ":", ...
37.83871
0.003325
def run_slurm(self, steps=None, **kwargs): """Run the steps via the SLURM queue.""" # Optional extra SLURM parameters # params = self.extra_slurm_params params.update(kwargs) # Mandatory extra SLURM parameters # if 'time' not in params: params['time'] = self.d...
[ "def", "run_slurm", "(", "self", ",", "steps", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Optional extra SLURM parameters #", "params", "=", "self", ".", "extra_slurm_params", "params", ".", "update", "(", "kwargs", ")", "# Mandatory extra SLURM parameters...
51.117647
0.019209
def revoke(self, only_access=False): """Revoke the current Authorization. :param only_access: (Optional) When explicitly set to True, do not evict the refresh token if one is set. Revoking a refresh token will in-turn revoke all access tokens associated with that authorizat...
[ "def", "revoke", "(", "self", ",", "only_access", "=", "False", ")", ":", "if", "only_access", "or", "self", ".", "refresh_token", "is", "None", ":", "super", "(", "Authorizer", ",", "self", ")", ".", "revoke", "(", ")", "else", ":", "self", ".", "_a...
34.555556
0.00313
def _set_ldp_session(self, v, load=False): """ Setter method for ldp_session, mapped from YANG variable /mpls_config/router/mpls/mpls_cmds_holder/ldp/ldp_holder/ldp_session (list) If this variable is read-only (config: false) in the source YANG file, then _set_ldp_session is considered as a private ...
[ "def", "_set_ldp_session", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "ba...
123
0.004034
def _slugify(string): """ This is not as good as a proper slugification function, but the input space is limited >>> _slugify("beets") 'beets' >>> _slugify("Toaster Strudel") 'toaster-strudel' Here's why: It handles very little. It doesn't handle esoteric whitespace or symbols: >>> _...
[ "def", "_slugify", "(", "string", ")", ":", "words", "=", "re", ".", "split", "(", "r'[\\W]'", ",", "string", ")", "clean_words", "=", "[", "w", "for", "w", "in", "words", "if", "w", "!=", "''", "]", "return", "'-'", ".", "join", "(", "clean_words"...
28.473684
0.005367
def _is_protein(pe): """Return True if the element is a protein""" val = isinstance(pe, _bp('Protein')) or \ isinstance(pe, _bpimpl('Protein')) or \ isinstance(pe, _bp('ProteinReference')) or \ isinstance(pe, _bpimpl('ProteinReference')) return val
[ "def", "_is_protein", "(", "pe", ")", ":", "val", "=", "isinstance", "(", "pe", ",", "_bp", "(", "'Protein'", ")", ")", "or", "isinstance", "(", "pe", ",", "_bpimpl", "(", "'Protein'", ")", ")", "or", "isinstance", "(", "pe", ",", "_bp", "(", "'Pro...
41.428571
0.013514
def make_combined_periodogram(pflist, outfile, addmethods=False): '''This just puts all of the period-finders on a single periodogram. This will renormalize all of the periodograms so their values lie between 0 and 1, with values lying closer to 1 being more significant. Periodograms that give the same...
[ "def", "make_combined_periodogram", "(", "pflist", ",", "outfile", ",", "addmethods", "=", "False", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "for", "pf", "in", "pflist", ":", "if", "pf", "[", "'method'", "]", "==", "'pdm'", ":", "plt...
37.901235
0.000952
def validate_flavor_data(self, expected, actual): """Validate flavor data. Validate a list of actual flavors vs a list of expected flavors. """ self.log.debug('Validating flavor data...') self.log.debug('actual: {}'.format(repr(actual))) act = [a.name for a in actu...
[ "def", "validate_flavor_data", "(", "self", ",", "expected", ",", "actual", ")", ":", "self", ".", "log", ".", "debug", "(", "'Validating flavor data...'", ")", "self", ".", "log", ".", "debug", "(", "'actual: {}'", ".", "format", "(", "repr", "(", "actual...
41.111111
0.005291
def relation_call(method, relation_name=None, flag=None, state=None, *args): """Invoke a method on the class implementing a relation via the CLI""" if relation_name: relation = relation_from_name(relation_name) if relation is None: raise ValueError('Relation not found: %s' % relation...
[ "def", "relation_call", "(", "method", ",", "relation_name", "=", "None", ",", "flag", "=", "None", ",", "state", "=", "None", ",", "*", "args", ")", ":", "if", "relation_name", ":", "relation", "=", "relation_from_name", "(", "relation_name", ")", "if", ...
48.058824
0.0012
def weakref_proxy(obj): """returns either a weakref.proxy for the object, or if object is already a proxy, returns itself.""" if type(obj) in weakref.ProxyTypes: return obj else: return weakref.proxy(obj)
[ "def", "weakref_proxy", "(", "obj", ")", ":", "if", "type", "(", "obj", ")", "in", "weakref", ".", "ProxyTypes", ":", "return", "obj", "else", ":", "return", "weakref", ".", "proxy", "(", "obj", ")" ]
32.857143
0.008475
def DeleteClusterTags(r, tags, dry_run=False): """ Deletes tags from the cluster. @type tags: list of str @param tags: tags to delete @type dry_run: bool @param dry_run: whether to perform a dry run """ query = { "dry-run": dry_run, "tag": tags, } return r.requ...
[ "def", "DeleteClusterTags", "(", "r", ",", "tags", ",", "dry_run", "=", "False", ")", ":", "query", "=", "{", "\"dry-run\"", ":", "dry_run", ",", "\"tag\"", ":", "tags", ",", "}", "return", "r", ".", "request", "(", "\"delete\"", ",", "\"/2/tags\"", ",...
21.375
0.002801
def python_to_couch(options): """ Translates query options from python style options into CouchDB/Cloudant query options. For example ``{'include_docs': True}`` will translate to ``{'include_docs': 'true'}``. Primarily meant for use by code that formulates a query to retrieve results data from the...
[ "def", "python_to_couch", "(", "options", ")", ":", "translation", "=", "dict", "(", ")", "for", "key", ",", "val", "in", "iteritems_", "(", "options", ")", ":", "py_to_couch_validate", "(", "key", ",", "val", ")", "translation", ".", "update", "(", "_py...
44.789474
0.001151
def yield_lines(strs): """Yield non-empty/non-comment lines of a string or sequence""" if isinstance(strs, string_types): for s in strs.splitlines(): s = s.strip() # skip blank lines/comments if s and not s.startswith('#'): yield s else: fo...
[ "def", "yield_lines", "(", "strs", ")", ":", "if", "isinstance", "(", "strs", ",", "string_types", ")", ":", "for", "s", "in", "strs", ".", "splitlines", "(", ")", ":", "s", "=", "s", ".", "strip", "(", ")", "# skip blank lines/comments", "if", "s", ...
32
0.002532
def get_ruleset_file(ruleset=None): """ Get the ruleset file from name :param ruleset: str :return: str """ ruleset = ruleset or "default" ruleset_dirs = get_ruleset_dirs() for ruleset_directory in ruleset_dirs: possible_ruleset_files = [os.path.join(ruleset_directory, ruleset ...
[ "def", "get_ruleset_file", "(", "ruleset", "=", "None", ")", ":", "ruleset", "=", "ruleset", "or", "\"default\"", "ruleset_dirs", "=", "get_ruleset_dirs", "(", ")", "for", "ruleset_directory", "in", "ruleset_dirs", ":", "possible_ruleset_files", "=", "[", "os", ...
35.952381
0.003871
def run_callback(self, callback, *args): """Queue a callback. The *callback* will be called with positional arguments *args* in the next iteration of the event loop. If you add multiple callbacks, they will be called in the order that you added them. The callback will run in the...
[ "def", "run_callback", "(", "self", ",", "callback", ",", "*", "args", ")", ":", "if", "self", ".", "_loop", "is", "None", ":", "raise", "RuntimeError", "(", "'hub is closed'", ")", "elif", "not", "callable", "(", "callback", ")", ":", "raise", "TypeErro...
43.352941
0.002656
def _send_get_request(self, path, params, headers): """ Sends the GET request to the Route53 endpoint. :param str path: The path to tack on to the endpoint URL for the query. :param dict params: Key/value pairs to send. :param dict headers: A dict of headers to send ...
[ "def", "_send_get_request", "(", "self", ",", "path", ",", "params", ",", "headers", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "endpoint", "+", "path", ",", "params", "=", "params", ",", "headers", "=", "headers", ")", "r", ".", ...
35.333333
0.003676
def meyer_penny_program(): """ Returns the program to simulate the Meyer-Penny Game The full description is available in docs/source/examples.rst :return: pyQuil Program """ prog = pq.Program() ro = prog.declare('ro', memory_size=2) picard_register = ro[1] answer_register = ro[0] ...
[ "def", "meyer_penny_program", "(", ")", ":", "prog", "=", "pq", ".", "Program", "(", ")", "ro", "=", "prog", ".", "declare", "(", "'ro'", ",", "memory_size", "=", "2", ")", "picard_register", "=", "ro", "[", "1", "]", "answer_register", "=", "ro", "[...
29.928571
0.001156
def get_index_from_alias(alias_name, index_client=None): """Retrieve the base index name from an alias Args: alias_name (str) Name of the alias index_client (Elasticsearch.IndicesClient) an Elasticsearch index client. Optional, will create one if not given Returns: (str) Name o...
[ "def", "get_index_from_alias", "(", "alias_name", ",", "index_client", "=", "None", ")", ":", "index_client", "=", "index_client", "or", "indices_client", "(", ")", "if", "not", "index_client", ".", "exists_alias", "(", "name", "=", "alias_name", ")", ":", "re...
36.857143
0.00189
def shutdown(self): """Stops all active periodic tasks and closes the socket.""" self.stop_all_periodic_tasks() for channel in self._bcm_sockets: log.debug("Closing bcm socket for channel {}".format(channel)) bcm_socket = self._bcm_sockets[channel] bcm_socket....
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "stop_all_periodic_tasks", "(", ")", "for", "channel", "in", "self", ".", "_bcm_sockets", ":", "log", ".", "debug", "(", "\"Closing bcm socket for channel {}\"", ".", "format", "(", "channel", ")", ")", ...
43.444444
0.005013
def parse_arguments(argv): """Parse command line arguments. Args: argv: list of command line arguments, includeing programe name. Returns: An argparse Namespace object. """ parser = argparse.ArgumentParser( description='Runs Preprocessing on structured CSV data.') parser.add_argument('--inpu...
[ "def", "parse_arguments", "(", "argv", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Runs Preprocessing on structured CSV data.'", ")", "parser", ".", "add_argument", "(", "'--input-file-pattern'", ",", "type", "=", "str", ",...
32.2
0.01005
def vars_args(parser): """Add various command line options for external vars""" parser.add_argument('--extra-vars', dest='extra_vars', help='Extra template variables', default=[], type=str, ac...
[ "def", "vars_args", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "'--extra-vars'", ",", "dest", "=", "'extra_vars'", ",", "help", "=", "'Extra template variables'", ",", "default", "=", "[", "]", ",", "type", "=", "str", ",", "action", "=",...
41.857143
0.001669
def set_armed_state(self, state): """Set the armed state, also update local state.""" self.set_service_value( self.security_sensor_service, 'Armed', 'newArmedValue', state) self.set_cache_value('Armed', state)
[ "def", "set_armed_state", "(", "self", ",", "state", ")", ":", "self", ".", "set_service_value", "(", "self", ".", "security_sensor_service", ",", "'Armed'", ",", "'newArmedValue'", ",", "state", ")", "self", ".", "set_cache_value", "(", "'Armed'", ",", "state...
34.25
0.007117
def acls(self): """The instance bound ACLs operations layer.""" if self._acls is None: self._acls = InstanceAcls(instance=self) return self._acls
[ "def", "acls", "(", "self", ")", ":", "if", "self", ".", "_acls", "is", "None", ":", "self", ".", "_acls", "=", "InstanceAcls", "(", "instance", "=", "self", ")", "return", "self", ".", "_acls" ]
35.4
0.01105
def reply_to(self, value): """The reply to email address :param value: The reply to email address :type value: ReplyTo, str, tuple """ if isinstance(value, str): value = ReplyTo(value, None) if isinstance(value, tuple): value = ReplyTo(value[0], v...
[ "def", "reply_to", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "ReplyTo", "(", "value", ",", "None", ")", "if", "isinstance", "(", "value", ",", "tuple", ")", ":", "value", "=", "ReplyT...
31.727273
0.005571
def dump_error_msg(msg, ofd=_LOGGER.debug): """https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L908. Positional arguments: msg -- message to print (nl_msg class instance). Keyword arguments: ofd -- function to call with arguments similar to `logging.debug`. """ hdr = nlmsg_hdr(...
[ "def", "dump_error_msg", "(", "msg", ",", "ofd", "=", "_LOGGER", ".", "debug", ")", ":", "hdr", "=", "nlmsg_hdr", "(", "msg", ")", "err", "=", "libnl", ".", "linux_private", ".", "netlink", ".", "nlmsgerr", "(", "nlmsg_data", "(", "hdr", ")", ")", "o...
34.526316
0.001484
def key_changes(self, from_token, to_token): """Gets a list of users who have updated their device identity keys. Args: from_token (str): The desired start point of the list. Should be the next_batch field from a response to an earlier call to /sync. to_token (st...
[ "def", "key_changes", "(", "self", ",", "from_token", ",", "to_token", ")", ":", "params", "=", "{", "\"from\"", ":", "from_token", ",", "\"to\"", ":", "to_token", "}", "return", "self", ".", "_send", "(", "\"GET\"", ",", "\"/keys/changes\"", ",", "query_p...
54.454545
0.00821
def export_module_spec_with_checkpoint(module_spec, checkpoint_path, export_path, scope_prefix=""): """Exports given checkpoint as tfhub module with given spec.""" # The main requirement is that it ...
[ "def", "export_module_spec_with_checkpoint", "(", "module_spec", ",", "checkpoint_path", ",", "export_path", ",", "scope_prefix", "=", "\"\"", ")", ":", "# The main requirement is that it is possible to know how to map from", "# module variable name to checkpoint variable name.", "# ...
43.904762
0.010616
def observe_multi(self, keys, master_only=False): """Multi-variant of :meth:`observe`""" return _Base.observe_multi(self, keys, master_only=master_only)
[ "def", "observe_multi", "(", "self", ",", "keys", ",", "master_only", "=", "False", ")", ":", "return", "_Base", ".", "observe_multi", "(", "self", ",", "keys", ",", "master_only", "=", "master_only", ")" ]
55.333333
0.011905
def finite_difference(self, *args, **kwargs): """ Calculates a numerical approximation of the Jacobian of the model using the sixth order central finite difference method. Accepts a `dx` keyword to tune the relative stepsize used. Makes 6*n_params calls to the model. :re...
[ "def", "finite_difference", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# See also: scipy.misc.derivative. It might be convinced to work, but", "# it will make way too many function evaluations", "dx", "=", "kwargs", ".", "pop", "(", "'dx'", ")", ...
51.333333
0.00182
def delete_value(self, key): """ Delete the key if the token is expired. Arg: key : cache key """ response = {} response['status'] = False response['msg'] = "key does not exist" file_cache = self.read_file() if key in file_cache: ...
[ "def", "delete_value", "(", "self", ",", "key", ")", ":", "response", "=", "{", "}", "response", "[", "'status'", "]", "=", "False", "response", "[", "'msg'", "]", "=", "\"key does not exist\"", "file_cache", "=", "self", ".", "read_file", "(", ")", "if"...
26.055556
0.004115
def dimensions(self) -> Tuple[str, ...]: """The dimension names of the NetCDF variable. Usually, the string defined by property |IOSequence.descr_sequence| prefixes all dimension names except the second one related to time, which allows storing different sequences in one NetCDF file: ...
[ "def", "dimensions", "(", "self", ")", "->", "Tuple", "[", "str", ",", "...", "]", ":", "nmb_timepoints", "=", "dimmapping", "[", "'nmb_timepoints'", "]", "nmb_subdevices", "=", "'%s%s'", "%", "(", "self", ".", "prefix", ",", "dimmapping", "[", "'nmb_subde...
47.052632
0.001096
def horner_log(coeffs, log_coeff, x): '''Technically possible to save one addition of the last term of coeffs is removed but benchmarks said nothing was saved''' tot = 0.0 for c in coeffs: tot = tot*x + c return tot + log_coeff*log(x)
[ "def", "horner_log", "(", "coeffs", ",", "log_coeff", ",", "x", ")", ":", "tot", "=", "0.0", "for", "c", "in", "coeffs", ":", "tot", "=", "tot", "*", "x", "+", "c", "return", "tot", "+", "log_coeff", "*", "log", "(", "x", ")" ]
36.714286
0.007605
def index_service(self, service_id): """ Index a service in search engine. """ from hypermap.aggregator.models import Service service = Service.objects.get(id=service_id) if not service.is_valid: LOGGER.debug('Not indexing service with id %s in search engine as it is not valid' % servi...
[ "def", "index_service", "(", "self", ",", "service_id", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Service", "service", "=", "Service", ".", "objects", ".", "get", "(", "id", "=", "service_id", ")", "if", "not", "service", ...
30.15
0.003215
def author_mail_from_git(self): """ Get the author mail from git information. """ try: # launch git command and get answer cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE) stdoutdata = cmd.communicate() if (stdoutdata[0]): ...
[ "def", "author_mail_from_git", "(", "self", ")", ":", "try", ":", "# launch git command and get answer", "cmd", "=", "Popen", "(", "[", "\"git\"", ",", "\"config\"", ",", "\"--get\"", ",", "\"user.email\"", "]", ",", "stdout", "=", "PIPE", ")", "stdoutdata", "...
33
0.003683
def inverable_group_multi_list(item_lists): """ aid_list1 = np.array([1, 1, 2, 2, 3, 3]) aid2_list = np.array([4, 2, 1, 9, 8, 7]) item_lists = (np.array(aid1_list), np.array(aid2_list)) """ #unique_list1, inverse1 = np.unique(item1_list, return_index=True, return_inverse=True) import vtool a...
[ "def", "inverable_group_multi_list", "(", "item_lists", ")", ":", "#unique_list1, inverse1 = np.unique(item1_list, return_index=True, return_inverse=True)", "import", "vtool", "as", "vt", "import", "utool", "as", "ut", "# Find uniques and groups in each individual list", "unique_list...
47.071429
0.002974
def spec_dice(spec): """ Return the dice specification as a string in a common format """ if spec[0] == 'c': return str(spec[1]) elif spec[0] == 'r': r = spec[1:] s = "{}d{}".format(r[0], r[1]) if len(r) == 4 and ((r[2] == 'd' and r[3] < r[0]) or (r[2] == 'k' and r[3] > 0)):...
[ "def", "spec_dice", "(", "spec", ")", ":", "if", "spec", "[", "0", "]", "==", "'c'", ":", "return", "str", "(", "spec", "[", "1", "]", ")", "elif", "spec", "[", "0", "]", "==", "'r'", ":", "r", "=", "spec", "[", "1", ":", "]", "s", "=", "...
40.923077
0.009191
def plot_diagrams( diagrams, plot_only=None, title=None, xy_range=None, labels=None, colormap="default", size=20, ax_color=np.array([0.0, 0.0, 0.0]), diagonal=True, lifetime=False, legend=True, show=False, ax=None ): """A helper function to plot persistence diagra...
[ "def", "plot_diagrams", "(", "diagrams", ",", "plot_only", "=", "None", ",", "title", "=", "None", ",", "xy_range", "=", "None", ",", "labels", "=", "None", ",", "colormap", "=", "\"default\"", ",", "size", "=", "20", ",", "ax_color", "=", "np", ".", ...
29.129412
0.002539
def set_user_agent(self, name, http): '''Sets the application name. LibVLC passes this as the user agent string when a protocol requires it. @param name: human-readable application name, e.g. "FooBar player 1.2.3". @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0". @...
[ "def", "set_user_agent", "(", "self", ",", "name", ",", "http", ")", ":", "return", "libvlc_set_user_agent", "(", "self", ",", "str_to_bytes", "(", "name", ")", ",", "str_to_bytes", "(", "http", ")", ")" ]
54.875
0.011211
def _construct(self, context): """Constructs this by calling the deferred method. This assumes that all unbound_vars have been specified in context and if this layer has already been computed in this context, then the previously constructed value will be returned. Args: context: A dict of Un...
[ "def", "_construct", "(", "self", ",", "context", ")", ":", "with", "self", ".", "g", ".", "as_default", "(", ")", ":", "if", "self", ".", "_pass_through", ":", "# pylint: disable=protected-access", "return", "self", ".", "_pass_through", ".", "_construct", ...
39.571429
0.010573
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
9