text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def distance_matrix(lons, lats, diameter=2*EARTH_RADIUS): """ :param lons: array of m longitudes :param lats: array of m latitudes :returns: matrix of (m, m) distances """ m = len(lons) assert m == len(lats), (m, len(lats)) lons = numpy.radians(lons) lats = numpy.radians(lats) co...
[ "def", "distance_matrix", "(", "lons", ",", "lats", ",", "diameter", "=", "2", "*", "EARTH_RADIUS", ")", ":", "m", "=", "len", "(", "lons", ")", "assert", "m", "==", "len", "(", "lats", ")", ",", "(", "m", ",", "len", "(", "lats", ")", ")", "lo...
35.5
0.001524
def has_only_keys(self, keys): """ Ensures :attr:`subject` is a :class:`collections.Mapping` and contains *keys*, and no other keys. """ self.is_a(Mapping) self.contains_only(keys) return ChainInspector(self._subject)
[ "def", "has_only_keys", "(", "self", ",", "keys", ")", ":", "self", ".", "is_a", "(", "Mapping", ")", "self", ".", "contains_only", "(", "keys", ")", "return", "ChainInspector", "(", "self", ".", "_subject", ")" ]
37
0.011321
def _op_generic_Ctz(self, args): """Count the trailing zeroes""" wtf_expr = claripy.BVV(self._from_size, self._from_size) for a in reversed(range(self._from_size)): bit = claripy.Extract(a, a, args[0]) wtf_expr = claripy.If(bit == 1, claripy.BVV(a, self._from_size), wtf_e...
[ "def", "_op_generic_Ctz", "(", "self", ",", "args", ")", ":", "wtf_expr", "=", "claripy", ".", "BVV", "(", "self", ".", "_from_size", ",", "self", ".", "_from_size", ")", "for", "a", "in", "reversed", "(", "range", "(", "self", ".", "_from_size", ")", ...
48.857143
0.008621
def isAboveHorizon(ra, decl, mcRA, lat): """ Returns if an object's 'ra' and 'decl' is above the horizon at a specific latitude, given the MC's right ascension. """ # This function checks if the equatorial distance from # the object to the MC is within its diurnal semi-arc. dArc...
[ "def", "isAboveHorizon", "(", "ra", ",", "decl", ",", "mcRA", ",", "lat", ")", ":", "# This function checks if the equatorial distance from ", "# the object to the MC is within its diurnal semi-arc.", "dArc", ",", "_", "=", "dnarcs", "(", "decl", ",", "lat", ")", "dis...
34.75
0.014019
def equal(actual, expected): ''' Compare actual and expected using == >>> expect = Expector([]) >>> expect(1).to_not(equal, 2) (True, 'equal: expect 1 == 2') >>> expect(1).to(equal, 1) (True, 'equal: expect 1 == 1') ''' is_passing = (actual == expected) types_to_diff = (str, d...
[ "def", "equal", "(", "actual", ",", "expected", ")", ":", "is_passing", "=", "(", "actual", "==", "expected", ")", "types_to_diff", "=", "(", "str", ",", "dict", ",", "list", ",", "tuple", ")", "if", "not", "is_passing", "and", "isinstance", "(", "expe...
35.454545
0.002497
def unpack_rsp(cls, rsp_pb): """Convert from PLS response to user response""" if rsp_pb.retType != RET_OK: return RET_ERROR, rsp_pb.retMsg, None raw_deal_list = rsp_pb.s2c.orderFillList deal_list = [DealListQuery.parse_deal(rsp_pb, deal) for deal in raw_deal_list] r...
[ "def", "unpack_rsp", "(", "cls", ",", "rsp_pb", ")", ":", "if", "rsp_pb", ".", "retType", "!=", "RET_OK", ":", "return", "RET_ERROR", ",", "rsp_pb", ".", "retMsg", ",", "None", "raw_deal_list", "=", "rsp_pb", ".", "s2c", ".", "orderFillList", "deal_list", ...
37.666667
0.008646
def solve_let(expr, vars): """Solves a let-form by calling RHS with nested scope.""" lhs_value = solve(expr.lhs, vars).value if not isinstance(lhs_value, structured.IStructured): raise errors.EfilterTypeError( root=expr.lhs, query=expr.original, message="The LHS of 'let' must...
[ "def", "solve_let", "(", "expr", ",", "vars", ")", ":", "lhs_value", "=", "solve", "(", "expr", ".", "lhs", ",", "vars", ")", ".", "value", "if", "not", "isinstance", "(", "lhs_value", ",", "structured", ".", "IStructured", ")", ":", "raise", "errors",...
44.5
0.002203
async def _connect_sentinel(self, address, timeout, pools): """Try to connect to specified Sentinel returning either connections pool or exception. """ try: with async_timeout(timeout, loop=self._loop): pool = await create_pool( address, mi...
[ "async", "def", "_connect_sentinel", "(", "self", ",", "address", ",", "timeout", ",", "pools", ")", ":", "try", ":", "with", "async_timeout", "(", "timeout", ",", "loop", "=", "self", ".", "_loop", ")", ":", "pool", "=", "await", "create_pool", "(", "...
39.380952
0.002361
def read(cls, proto): """ capnp deserialization method for the anomaly likelihood object :param proto: (Object) capnp proto object specified in nupic.regions.anomaly_likelihood.capnp :returns: (Object) the deserialized AnomalyLikelihood object """ # pylint: disable=W0212 ...
[ "def", "read", "(", "cls", ",", "proto", ")", ":", "# pylint: disable=W0212", "anomalyLikelihood", "=", "object", ".", "__new__", "(", "cls", ")", "anomalyLikelihood", ".", "_iteration", "=", "proto", ".", "iteration", "anomalyLikelihood", ".", "_historicalScores"...
51.363636
0.010855
def context_exclude(zap_helper, name, pattern): """Exclude a pattern from a given context.""" console.info('Excluding regex {0} from context with name: {1}'.format(pattern, name)) with zap_error_handler(): result = zap_helper.zap.context.exclude_from_context(contextname=name, regex=pattern) ...
[ "def", "context_exclude", "(", "zap_helper", ",", "name", ",", "pattern", ")", ":", "console", ".", "info", "(", "'Excluding regex {0} from context with name: {1}'", ".", "format", "(", "pattern", ",", "name", ")", ")", "with", "zap_error_handler", "(", ")", ":"...
52.125
0.009434
def extract(what, calc_id, webapi=True): """ Extract an output from the datastore and save it into an .hdf5 file. By default uses the WebAPI, otherwise the extraction is done locally. """ with performance.Monitor('extract', measuremem=True) as mon: if webapi: obj = WebExtractor(c...
[ "def", "extract", "(", "what", ",", "calc_id", ",", "webapi", "=", "True", ")", ":", "with", "performance", ".", "Monitor", "(", "'extract'", ",", "measuremem", "=", "True", ")", "as", "mon", ":", "if", "webapi", ":", "obj", "=", "WebExtractor", "(", ...
37.25
0.001637
def jdToDate(jd): '''def jdToDate(jd): Convert a Julian day number to day/month/year. jd is an integer.''' if (jd > 2299160): # After 5/10/1582, Gregorian calendar a = jd + 32044 b = int((4 * a + 3) / 146097.) c = a - int((b * 146097) / 4.) else: ...
[ "def", "jdToDate", "(", "jd", ")", ":", "if", "(", "jd", ">", "2299160", ")", ":", "# After 5/10/1582, Gregorian calendar", "a", "=", "jd", "+", "32044", "b", "=", "int", "(", "(", "4", "*", "a", "+", "3", ")", "/", "146097.", ")", "c", "=", "a",...
32.555556
0.001658
def authenticate_search_bind(self, username, password): """ Performs a search bind to authenticate a user. This is required when a the login attribute is not the same as the RDN, since we cannot string together their DN on the fly, instead we have to find it in the LDAP, then att...
[ "def", "authenticate_search_bind", "(", "self", ",", "username", ",", "password", ")", ":", "connection", "=", "self", ".", "_make_connection", "(", "bind_user", "=", "self", ".", "config", ".", "get", "(", "'LDAP_BIND_USER_DN'", ")", ",", "bind_password", "="...
39.396552
0.001067
def _parse_node(node, parent_matrix, material_map, meshes, graph, resolver=None): """ Recursively parse COLLADA scene nodes. """ # Parse mesh node if isinstance(node, collada.scene.GeometryNode): geometry = node...
[ "def", "_parse_node", "(", "node", ",", "parent_matrix", ",", "material_map", ",", "meshes", ",", "graph", ",", "resolver", "=", "None", ")", ":", "# Parse mesh node", "if", "isinstance", "(", "node", ",", "collada", ".", "scene", ".", "GeometryNode", ")", ...
38.76699
0.000244
def handle(data_type, data, data_id=None, caller=None): """ execute all data handlers on the specified data according to data type Args: data_type (str): data type handle data (dict or list): data Kwargs: data_id (str): can be used to differentiate between different data ...
[ "def", "handle", "(", "data_type", ",", "data", ",", "data_id", "=", "None", ",", "caller", "=", "None", ")", ":", "if", "not", "data_id", ":", "data_id", "=", "data_type", "# instantiate handlers for data type if they havent been yet", "if", "data_id", "not", "...
33.085714
0.001678
def split_box( fraction, x,y, w,h ): """Return set of two boxes where first is the fraction given""" if w >= h: new_w = int(w*fraction) if new_w: return (x,y,new_w,h),(x+new_w,y,w-new_w,h) else: return None,None else: new_h = int(h*fraction) if...
[ "def", "split_box", "(", "fraction", ",", "x", ",", "y", ",", "w", ",", "h", ")", ":", "if", "w", ">=", "h", ":", "new_w", "=", "int", "(", "w", "*", "fraction", ")", "if", "new_w", ":", "return", "(", "x", ",", "y", ",", "new_w", ",", "h",...
29.428571
0.049412
def _calc_ticks(value_range, base): """ Calculate tick marks within a range Parameters ---------- value_range: tuple Range for which to calculate ticks. Returns ------- out: tuple (major, middle, minor) tick locations """ ...
[ "def", "_calc_ticks", "(", "value_range", ",", "base", ")", ":", "def", "_minor", "(", "x", ",", "mid_idx", ")", ":", "return", "np", ".", "hstack", "(", "[", "x", "[", "1", ":", "mid_idx", "]", ",", "x", "[", "mid_idx", "+", "1", ":", "-", "1"...
33.65
0.001444
def plot_points(self, ax, legend=None, field=None, field_function=None, undefined=0, **kwargs): """ Plotting, but only for points (as opposed to intervals). """ ys = [iv.top.z for iv in s...
[ "def", "plot_points", "(", "self", ",", "ax", ",", "legend", "=", "None", ",", "field", "=", "None", ",", "field_function", "=", "None", ",", "undefined", "=", "0", ",", "*", "*", "kwargs", ")", ":", "ys", "=", "[", "iv", ".", "top", ".", "z", ...
27.76
0.009749
def scalars_impl(self, run, tag_regex_string): """Given a tag regex and single run, return ScalarEvents. Args: run: A run string. tag_regex_string: A regular expression that captures portions of tags. Raises: ValueError: if the scalars plugin is not registered. Returns: A dict...
[ "def", "scalars_impl", "(", "self", ",", "run", ",", "tag_regex_string", ")", ":", "if", "not", "tag_regex_string", ":", "# The user provided no regex.", "return", "{", "_REGEX_VALID_PROPERTY", ":", "False", ",", "_TAG_TO_EVENTS_PROPERTY", ":", "{", "}", ",", "}",...
28.87931
0.009238
def zSetSurfaceData(self, surfNum, radius=None, thick=None, material=None, semidia=None, conic=None, comment=None): """Sets surface data""" if self.pMode == 0: # Sequential mode surf = self.pLDE.GetSurfaceAt(surfNum) if radius is not None: ...
[ "def", "zSetSurfaceData", "(", "self", ",", "surfNum", ",", "radius", "=", "None", ",", "thick", "=", "None", ",", "material", "=", "None", ",", "semidia", "=", "None", ",", "conic", "=", "None", ",", "comment", "=", "None", ")", ":", "if", "self", ...
42.526316
0.008475
async def update_pin(**payload): """Update the onboarding welcome message after recieving a "pin_added" event from Slack. Update timestamp for welcome message as well. """ data = payload["data"] web_client = payload["web_client"] channel_id = data["channel_id"] user_id = data["user"] # ...
[ "async", "def", "update_pin", "(", "*", "*", "payload", ")", ":", "data", "=", "payload", "[", "\"data\"", "]", "web_client", "=", "payload", "[", "\"web_client\"", "]", "channel_id", "=", "data", "[", "\"channel_id\"", "]", "user_id", "=", "data", "[", ...
35.26087
0.0012
def display_pil_image(im): """Displayhook function for PIL Images, rendered as PNG.""" from IPython.core import display b = BytesIO() im.save(b, format='png') data = b.getvalue() ip_img = display.Image(data=data, format='png', embed=True) return ip_img._repr_png_()
[ "def", "display_pil_image", "(", "im", ")", ":", "from", "IPython", ".", "core", "import", "display", "b", "=", "BytesIO", "(", ")", "im", ".", "save", "(", "b", ",", "format", "=", "'png'", ")", "data", "=", "b", ".", "getvalue", "(", ")", "ip_img...
31
0.027875
def _upload(self, archive, region): """Upload function source and return source url """ # Generate source upload url url = self.client.execute_command( 'generateUploadUrl', {'parent': 'projects/{}/locations/{}'.format( self.session.get_default_proj...
[ "def", "_upload", "(", "self", ",", "archive", ",", "region", ")", ":", "# Generate source upload url", "url", "=", "self", ".", "client", ".", "execute_command", "(", "'generateUploadUrl'", ",", "{", "'parent'", ":", "'projects/{}/locations/{}'", ".", "format", ...
39.25
0.002073
def copy(self, deep=True, data=None): """Returns a copy of this object. `deep` is ignored since data is stored in the form of pandas.Index, which is already immutable. Dimensions, attributes and encodings are always copied. Use `data` to create a new object with the same struct...
[ "def", "copy", "(", "self", ",", "deep", "=", "True", ",", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "data", "=", "self", ".", "_data", "else", ":", "data", "=", "as_compatible_data", "(", "data", ")", "if", "self", ".", "sh...
36.03125
0.001689
def add_output_option(parser): """output option""" parser.add_argument("-o", "--outdir", dest="outdir", type=str, default='GSEApy_reports', metavar='', action="store", help="The GSEApy output directory. Default: the current working directory") parser.add_argu...
[ "def", "add_output_option", "(", "parser", ")", ":", "parser", ".", "add_argument", "(", "\"-o\"", ",", "\"--outdir\"", ",", "dest", "=", "\"outdir\"", ",", "type", "=", "str", ",", "default", "=", "'GSEApy_reports'", ",", "metavar", "=", "''", ",", "actio...
77.95
0.013308
def cartesian_square_centred_on_point(self, point, distance, **kwargs): ''' Select earthquakes from within a square centered on a point :param point: Centre point as instance of nhlib.geo.point.Point class :param distance: Distance (km) :returns: ...
[ "def", "cartesian_square_centred_on_point", "(", "self", ",", "point", ",", "distance", ",", "*", "*", "kwargs", ")", ":", "point_surface", "=", "Point", "(", "point", ".", "longitude", ",", "point", ".", "latitude", ",", "0.", ")", "# As distance is", "nort...
40.542857
0.001376
def validateData(self, text): ''' Method which validates the data from each tag, to check whether it is an empty string :param text: data to be validated :return: True or False depending on the result ''' if text == "\n": return False for c in text: ...
[ "def", "validateData", "(", "self", ",", "text", ")", ":", "if", "text", "==", "\"\\n\"", ":", "return", "False", "for", "c", "in", "text", ":", "try", ":", "if", "str", "(", "c", ")", "!=", "\" \"", ":", "return", "True", "except", ":", "return", ...
30.4
0.008511
def renew_service(request, pk): """ renew an existing service :param request object :param pk: the primary key of the service to renew :type pk: int """ default_provider.load_services() service = get_object_or_404(ServicesActivated, pk=pk) service_name = str(service.n...
[ "def", "renew_service", "(", "request", ",", "pk", ")", ":", "default_provider", ".", "load_services", "(", ")", "service", "=", "get_object_or_404", "(", "ServicesActivated", ",", "pk", "=", "pk", ")", "service_name", "=", "str", "(", "service", ".", "name"...
36.714286
0.001898
def clicked(self, px, py): '''see if the image has been clicked on''' if self.hidden: return None if (abs(px - self.posx) > self.width/2 or abs(py - self.posy) > self.height/2): return None return math.sqrt((px-self.posx)**2 + (py-self.posy)**2)
[ "def", "clicked", "(", "self", ",", "px", ",", "py", ")", ":", "if", "self", ".", "hidden", ":", "return", "None", "if", "(", "abs", "(", "px", "-", "self", ".", "posx", ")", ">", "self", ".", "width", "/", "2", "or", "abs", "(", "py", "-", ...
38.25
0.009585
def proj_l1(v, gamma, axis=None, method=None): r"""Projection operator of the :math:`\ell_1` norm. Parameters ---------- v : array_like Input array :math:`\mathbf{v}` gamma : float Parameter :math:`\gamma` axis : None or int or tuple of ints, optional (default None) Axes of `...
[ "def", "proj_l1", "(", "v", ",", "gamma", ",", "axis", "=", "None", ",", "method", "=", "None", ")", ":", "if", "method", "is", "None", ":", "if", "axis", "is", "None", ":", "method", "=", "'scalarroot'", "else", ":", "method", "=", "'sortcumsum'", ...
32.461538
0.000575
def setOverlayTransformTrackedDeviceRelative(self, ulOverlayHandle, unTrackedDevice): """Sets the transform to relative to the transform of the specified tracked device.""" fn = self.function_table.setOverlayTransformTrackedDeviceRelative pmatTrackedDeviceToOverlayTransform = HmdMatrix34_t() ...
[ "def", "setOverlayTransformTrackedDeviceRelative", "(", "self", ",", "ulOverlayHandle", ",", "unTrackedDevice", ")", ":", "fn", "=", "self", ".", "function_table", ".", "setOverlayTransformTrackedDeviceRelative", "pmatTrackedDeviceToOverlayTransform", "=", "HmdMatrix34_t", "(...
66.857143
0.010549
def chunk(line, mapping={None: 'text', '${': 'escape', '#{': 'bless', '&{': 'args', '%{': 'format', '@{': 'json'}): """Chunkify and "tag" a block of text into plain text and code sections. The first delimeter is blank to represent text sections, and keep the indexes aligned with the tags. Values are yielded in t...
[ "def", "chunk", "(", "line", ",", "mapping", "=", "{", "None", ":", "'text'", ",", "'${'", ":", "'escape'", ",", "'#{'", ":", "'bless'", ",", "'&{'", ":", "'args'", ",", "'%{'", ":", "'format'", ",", "'@{'", ":", "'json'", "}", ")", ":", "skipping"...
24.690476
0.05102
def show_image(self, image_id_or_slug): """ This method displays the attributes of an image. Required parameters image_id: Numeric, this is the id of the image you would like to use to rebuild your droplet with """ if not image_id_or_...
[ "def", "show_image", "(", "self", ",", "image_id_or_slug", ")", ":", "if", "not", "image_id_or_slug", ":", "msg", "=", "'image_id_or_slug is required to destroy an image!'", "raise", "DOPException", "(", "msg", ")", "json", "=", "self", ".", "request", "(", "'/ima...
33.869565
0.002497
def remove_zero_normals(self): """Removes normal vectors with a zero magnitude. Note ---- This returns nothing and updates the NormalCloud in-place. """ points_of_interest = np.where(np.linalg.norm(self._data, axis=0) != 0.0)[0] self._data = self._data[:, points_...
[ "def", "remove_zero_normals", "(", "self", ")", ":", "points_of_interest", "=", "np", ".", "where", "(", "np", ".", "linalg", ".", "norm", "(", "self", ".", "_data", ",", "axis", "=", "0", ")", "!=", "0.0", ")", "[", "0", "]", "self", ".", "_data",...
36
0.009036
def search(self, index=None, doc_type=None, body=None, **query_params): """ Make a search query on the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_ :param index: the index name to query :param doc_type: he doc type to sear...
[ "def", "search", "(", "self", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "body", "=", "None", ",", "*", "*", "query_params", ")", ":", "path", "=", "self", ".", "_es_parser", ".", "make_path", "(", "index", ",", "doc_type", ",", ...
57.652778
0.001895
def set_static_dns(iface, *addrs): ''' Set static DNS configuration on a Windows NIC Args: iface (str): The name of the interface to set addrs (*): One or more DNS servers to be added. To clear the list of DNS servers pass an empty list (``[]``). If undefined or ``...
[ "def", "set_static_dns", "(", "iface", ",", "*", "addrs", ")", ":", "if", "addrs", "is", "(", ")", "or", "str", "(", "addrs", "[", "0", "]", ")", ".", "lower", "(", ")", "==", "'none'", ":", "return", "{", "'Interface'", ":", "iface", ",", "'DNS ...
37.115385
0.001514
def unarchive(filename,output_dir='.'): '''unpacks the given archive into ``output_dir``''' if not os.path.exists(output_dir): os.makedirs(output_dir) for archive in archive_formats: if filename.endswith(archive_formats[archive]['suffix']): return subprocess.call(archive_formats[...
[ "def", "unarchive", "(", "filename", ",", "output_dir", "=", "'.'", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output_dir", ")", ":", "os", ".", "makedirs", "(", "output_dir", ")", "for", "archive", "in", "archive_formats", ":", "if...
46.75
0.013123
def convert_destination_to_id(destination_node, destination_port, nodes): """ Convert a destination to device and port ID :param str destination_node: Destination node name :param str destination_port: Destination port name :param list nodes: list of nodes from :py:meth:`generat...
[ "def", "convert_destination_to_id", "(", "destination_node", ",", "destination_port", ",", "nodes", ")", ":", "device_id", "=", "None", "device_name", "=", "None", "port_id", "=", "None", "if", "destination_node", "!=", "'NIO'", ":", "for", "node", "in", "nodes"...
39.297297
0.001342
def _match_pattern(filename, include, exclude, real, path, follow): """Match includes and excludes.""" if real: symlinks = {} if isinstance(filename, bytes): curdir = os.fsencode(os.curdir) mount = RE_BWIN_MOUNT if util.platform() == "windows" else RE_BMOUNT else...
[ "def", "_match_pattern", "(", "filename", ",", "include", ",", "exclude", ",", "real", ",", "path", ",", "follow", ")", ":", "if", "real", ":", "symlinks", "=", "{", "}", "if", "isinstance", "(", "filename", ",", "bytes", ")", ":", "curdir", "=", "os...
28.820513
0.001721
def get(self): '''Return a dictionary that represents the Tcl array''' value = {} for (elementname, elementvar) in self._elementvars.items(): value[elementname] = elementvar.get() return value
[ "def", "get", "(", "self", ")", ":", "value", "=", "{", "}", "for", "(", "elementname", ",", "elementvar", ")", "in", "self", ".", "_elementvars", ".", "items", "(", ")", ":", "value", "[", "elementname", "]", "=", "elementvar", ".", "get", "(", ")...
38.5
0.008475
def assert_not_visible(self, selector, testid=None, **kwargs): """Assert that the element is not visible in the dom Args: selector (str): the selector used to find the element test_id (str): the test_id or a str Kwargs: wait_until_not_visible (bool) ...
[ "def", "assert_not_visible", "(", "self", ",", "selector", ",", "testid", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "info_log", "(", "\"Assert not visible selector(%s) testid(%s)\"", "%", "(", "selector", ",", "testid", ")", ")", "highlight"...
33.90625
0.000896
def aggregator(name, func, *args, type=None): 'Define simple aggregator `name` that calls func(values)' def _func(col, rows): # wrap builtins so they can have a .type vals = list(col.getValues(rows)) try: return func(vals, *args) except Exception as e: if len(val...
[ "def", "aggregator", "(", "name", ",", "func", ",", "*", "args", ",", "type", "=", "None", ")", ":", "def", "_func", "(", "col", ",", "rows", ")", ":", "# wrap builtins so they can have a .type", "vals", "=", "list", "(", "col", ".", "getValues", "(", ...
34.916667
0.002326
def is_valid_nc3_name(s): """Test whether an object can be validly converted to a netCDF-3 dimension, variable or attribute name Earlier versions of the netCDF C-library reference implementation enforced a more restricted set of characters in creating new names, but permitted reading names containi...
[ "def", "is_valid_nc3_name", "(", "s", ")", ":", "if", "not", "isinstance", "(", "s", ",", "str", ")", ":", "return", "False", "if", "not", "isinstance", "(", "s", ",", "str", ")", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", "num_bytes",...
46.896552
0.00072
def question_default_add_related_pks(self, obj): """Add related primary keys to a Question instance.""" if not hasattr(obj, '_choice_pks'): obj._choice_pks = list(obj.choices.values_list('pk', flat=True))
[ "def", "question_default_add_related_pks", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_choice_pks'", ")", ":", "obj", ".", "_choice_pks", "=", "list", "(", "obj", ".", "choices", ".", "values_list", "(", "'pk'", ",", "f...
57.25
0.008621
def run_async(self): """ Spawns a new thread that runs the message loop until the Pebble disconnects. ``run_async`` will call :meth:`fetch_watch_info` on your behalf, and block until it receives a response. """ thread = threading.Thread(target=self.run_sync) thread.daemon...
[ "def", "run_async", "(", "self", ")", ":", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "run_sync", ")", "thread", ".", "daemon", "=", "True", "thread", ".", "name", "=", "\"PebbleConnection\"", "thread", ".", "start", "(",...
41.4
0.009456
def ordered_symbols(self): """ :return: list of all symbols in this model, topologically sorted so they can be evaluated in the correct order. Within each group of equal priority symbols, we sort by the order of the derivative. """ key_func = lambda s...
[ "def", "ordered_symbols", "(", "self", ")", ":", "key_func", "=", "lambda", "s", ":", "[", "isinstance", "(", "s", ",", "sympy", ".", "Derivative", ")", ",", "isinstance", "(", "s", ",", "sympy", ".", "Derivative", ")", "and", "s", ".", "derivative_cou...
39
0.011686
def print_usage(self, hint=None): """Usage format should be like: Lineno | Content 1 | Script description (__doc__) 2 | Usage: {script name} [COMMAND] [ARGUMENTS] 3 | \n 4 | Commands: 5 | cmd1 cmd1 description. ...
[ "def", "print_usage", "(", "self", ",", "hint", "=", "None", ")", ":", "buf", "=", "[", "]", "# Description", "if", "__doc__", ":", "buf", ".", "append", "(", "__doc__", ")", "# Usage", "script_name", "=", "sys", ".", "argv", "[", "0", "]", "buf", ...
31.681818
0.002088
def convert_to_sympy_matrix(expr, full_space=None): """Convert a QNET expression to an explicit ``n x n`` instance of `sympy.Matrix`, where ``n`` is the dimension of `full_space`. The entries of the matrix may contain symbols. Parameters: expr: a QNET expression full_space (qnet.algebra...
[ "def", "convert_to_sympy_matrix", "(", "expr", ",", "full_space", "=", "None", ")", ":", "if", "full_space", "is", "None", ":", "full_space", "=", "expr", ".", "space", "if", "not", "expr", ".", "space", ".", "is_tensor_factor_of", "(", "full_space", ")", ...
44.122807
0.000194
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: WorkspaceCumulativeStatisticsContext for this WorkspaceCumulativeStatisticsInstance :rtype: twili...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "WorkspaceCumulativeStatisticsContext", "(", "self", ".", "_version", ",", "workspace_sid", "=", "self", ".", "_solution", "[", "'workspac...
46.785714
0.008982
def build_uri(endpoint, api_version, uri_parts, uri_args={}): """ Build the URL using the endpoint, the api version, the uri parts and the args. :param dict uri_args: parameters to include in the URL. :param tuple uri_parts: url encoded and `uri_parts` too. :return: A string that repre...
[ "def", "build_uri", "(", "endpoint", ",", "api_version", ",", "uri_parts", ",", "uri_args", "=", "{", "}", ")", ":", "# to unicode", "uri_parts", "=", "[", "unicode", "(", "x", ")", "for", "x", "in", "uri_parts", "]", "# and encoded ", "uri_parts", "=", ...
36.740741
0.008841
def _run_dnb_normalization(self, dnb_data, sza_data): """Scale the DNB data using a adaptive histogram equalization method. Args: dnb_data (ndarray): Day/Night Band data array sza_data (ndarray): Solar Zenith Angle data array """ # convert dask arrays to DataArr...
[ "def", "_run_dnb_normalization", "(", "self", ",", "dnb_data", ",", "sza_data", ")", ":", "# convert dask arrays to DataArray objects", "dnb_data", "=", "xr", ".", "DataArray", "(", "dnb_data", ",", "dims", "=", "(", "'y'", ",", "'x'", ")", ")", "sza_data", "=...
42.837209
0.000531
def values(self): """ Return all values as numpy-array (mean, var, min, max, num). """ return np.array([self.mean, self.var, self.min, self.max, self.num])
[ "def", "values", "(", "self", ")", ":", "return", "np", ".", "array", "(", "[", "self", ".", "mean", ",", "self", ".", "var", ",", "self", ".", "min", ",", "self", ".", "max", ",", "self", ".", "num", "]", ")" ]
36.6
0.010695
def _check_no_current_table(new_obj, current_table): """ Raises exception if we try to add a relation or a column with no current table. """ if current_table is None: msg = 'Cannot add {} before adding table' if isinstance(new_obj, Relation): raise NoCurrentTableException(msg.for...
[ "def", "_check_no_current_table", "(", "new_obj", ",", "current_table", ")", ":", "if", "current_table", "is", "None", ":", "msg", "=", "'Cannot add {} before adding table'", "if", "isinstance", "(", "new_obj", ",", "Relation", ")", ":", "raise", "NoCurrentTableExce...
48
0.002273
def start(self): """ Begins the job by kicking off all tasks with no dependencies. """ logger.info('Job {0} starting job run'.format(self.name)) if not self.state.allow_start: raise DagobahError('job cannot be started in its current state; ' + 'it is p...
[ "def", "start", "(", "self", ")", ":", "logger", ".", "info", "(", "'Job {0} starting job run'", ".", "format", "(", "self", ".", "name", ")", ")", "if", "not", "self", ".", "state", ".", "allow_start", ":", "raise", "DagobahError", "(", "'job cannot be st...
40.0625
0.002285
def validate_args(api_key, *, rate="informers", **kwargs): "Проверяет и формирует аргументы для запроса" rate = Rate.validate(rate) headers = {"X-Yandex-API-Key": api_key} url = "https://api.weather.yandex.ru/v1/{}".format(rate) if rate == "informers": params = ARGS_SCHEMA(kwargs) else: ...
[ "def", "validate_args", "(", "api_key", ",", "*", ",", "rate", "=", "\"informers\"", ",", "*", "*", "kwargs", ")", ":", "rate", "=", "Rate", ".", "validate", "(", "rate", ")", "headers", "=", "{", "\"X-Yandex-API-Key\"", ":", "api_key", "}", "url", "="...
41.4
0.002364
def _encrypted_data_keys_hash(hasher, encrypted_data_keys): """Generates the expected hash for the provided encrypted data keys. :param hasher: Existing hasher to use :type hasher: cryptography.hazmat.primitives.hashes.Hash :param iterable encrypted_data_keys: Encrypted data keys to hash :returns: ...
[ "def", "_encrypted_data_keys_hash", "(", "hasher", ",", "encrypted_data_keys", ")", ":", "hashed_keys", "=", "[", "]", "for", "edk", "in", "encrypted_data_keys", ":", "serialized_edk", "=", "serialize_encrypted_data_key", "(", "edk", ")", "_hasher", "=", "hasher", ...
40.375
0.001513
def parse_info(response): "Parse the result of Redis's INFO command into a Python dict" info = {} response = nativestr(response) def get_value(value): if ',' not in value or '=' not in value: try: if '.' in value: return float(value) ...
[ "def", "parse_info", "(", "response", ")", ":", "info", "=", "{", "}", "response", "=", "nativestr", "(", "response", ")", "def", "get_value", "(", "value", ")", ":", "if", "','", "not", "in", "value", "or", "'='", "not", "in", "value", ":", "try", ...
31.677419
0.000988
def _rpt_unused_sections(self, prt): """Report unused sections.""" sections_unused = set(self.sections_seen).difference(self.section2goids.keys()) for sec in sections_unused: prt.write(" UNUSED SECTION: {SEC}\n".format(SEC=sec))
[ "def", "_rpt_unused_sections", "(", "self", ",", "prt", ")", ":", "sections_unused", "=", "set", "(", "self", ".", "sections_seen", ")", ".", "difference", "(", "self", ".", "section2goids", ".", "keys", "(", ")", ")", "for", "sec", "in", "sections_unused"...
52.2
0.011321
def _field_accessor(name, docstring=None, min_cftime_version='0.0'): """Adapted from pandas.tseries.index._field_accessor""" def f(self, min_cftime_version=min_cftime_version): import cftime version = cftime.__version__ if LooseVersion(version) >= LooseVersion(min_cftime_version): ...
[ "def", "_field_accessor", "(", "name", ",", "docstring", "=", "None", ",", "min_cftime_version", "=", "'0.0'", ")", ":", "def", "f", "(", "self", ",", "min_cftime_version", "=", "min_cftime_version", ")", ":", "import", "cftime", "version", "=", "cftime", "....
37.263158
0.001377
def verify_checksum(*lines): """Verify the checksum of one or more TLE lines. Raises `ValueError` if any of the lines fails its checksum, and includes the failing line in the error message. """ for line in lines: checksum = line[68:69] if not checksum.isdigit(): continu...
[ "def", "verify_checksum", "(", "*", "lines", ")", ":", "for", "line", "in", "lines", ":", "checksum", "=", "line", "[", "68", ":", "69", "]", "if", "not", "checksum", ".", "isdigit", "(", ")", ":", "continue", "checksum", "=", "int", "(", "checksum",...
35.705882
0.001605
def otherrole(self, otherrole): """ Get the ``OTHERROLE`` attribute value. """ if otherrole is not None: self._el.set('ROLE', 'OTHER') self._el.set('OTHERROLE', otherrole)
[ "def", "otherrole", "(", "self", ",", "otherrole", ")", ":", "if", "otherrole", "is", "not", "None", ":", "self", ".", "_el", ".", "set", "(", "'ROLE'", ",", "'OTHER'", ")", "self", ".", "_el", ".", "set", "(", "'OTHERROLE'", ",", "otherrole", ")" ]
31.571429
0.008811
def rcm_chip_order(machine): """A generator which iterates over a set of chips in a machine in Reverse-Cuthill-McKee order. For use as a chip ordering for the sequential placer. """ # Convert the Machine description into a placement-problem-style-graph # where the vertices are chip coordinate t...
[ "def", "rcm_chip_order", "(", "machine", ")", ":", "# Convert the Machine description into a placement-problem-style-graph", "# where the vertices are chip coordinate tuples (x, y) and each net", "# represents the links leaving each chip. This allows us to re-use the", "# rcm_vertex_order function...
41.233333
0.00079
def add_user(username, deployment_name, token_manager=None, app_url=defaults.APP_URL): """ add user to deployment """ deployment_id = get_deployment_id(deployment_name, token_manager=token_manager, ...
[ "def", "add_user", "(", "username", ",", "deployment_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "deployment_id", "=", "get_deployment_id", "(", "deployment_name", ",", "token_manager", "=", "token_manager",...
37.384615
0.002006
def plotcdf(x,xmin,alpha): """ Plots CDF and powerlaw """ x=sort(x) n=len(x) xcdf = arange(n,0,-1,dtype='float')/float(n) q = x[x>=xmin] fcdf = (q/xmin)**(1-alpha) nc = xcdf[argmax(x>=xmin)] fcdf_norm = nc*fcdf loglog(x,xcdf) loglog(q,fcdf_norm)
[ "def", "plotcdf", "(", "x", ",", "xmin", ",", "alpha", ")", ":", "x", "=", "sort", "(", "x", ")", "n", "=", "len", "(", "x", ")", "xcdf", "=", "arange", "(", "n", ",", "0", ",", "-", "1", ",", "dtype", "=", "'float'", ")", "/", "float", "...
17.5625
0.040541
def unlock_wallet(self, *args, **kwargs): """ Unlock the library internal wallet """ self.blockchain.wallet.unlock(*args, **kwargs) return self
[ "def", "unlock_wallet", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "blockchain", ".", "wallet", ".", "unlock", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self" ]
34.2
0.011429
def _check_stop_conditions(self, sensor_graph): """Check if any of our stop conditions are met. Args: sensor_graph (SensorGraph): The sensor graph we are currently simulating Returns: bool: True if we should stop the simulation """ for stop in self.stop...
[ "def", "_check_stop_conditions", "(", "self", ",", "sensor_graph", ")", ":", "for", "stop", "in", "self", ".", "stop_conditions", ":", "if", "stop", ".", "should_stop", "(", "self", ".", "tick_count", ",", "self", ".", "tick_count", "-", "self", ".", "_sta...
31.2
0.008299
def local_2d_halo_exchange(k, v, num_h_blocks, h_dim, num_w_blocks, w_dim, mask_right): """Halo exchange for keys and values for Local 2D attention.""" for blocks_dim, block_size_dim, halo_size in [ (num_h_blocks, h_dim, h_dim.size), (num_w_blocks, w_dim, w_dim.size)]: # s...
[ "def", "local_2d_halo_exchange", "(", "k", ",", "v", ",", "num_h_blocks", ",", "h_dim", ",", "num_w_blocks", ",", "w_dim", ",", "mask_right", ")", ":", "for", "blocks_dim", ",", "block_size_dim", ",", "halo_size", "in", "[", "(", "num_h_blocks", ",", "h_dim"...
47.695652
0.013405
def from_json(graph_json_dict: Mapping[str, Any], check_version=True) -> BELGraph: """Build a graph from Node-Link JSON Object.""" graph = node_link_graph(graph_json_dict) return ensure_version(graph, check_version=check_version)
[ "def", "from_json", "(", "graph_json_dict", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "check_version", "=", "True", ")", "->", "BELGraph", ":", "graph", "=", "node_link_graph", "(", "graph_json_dict", ")", "return", "ensure_version", "(", "graph", ",...
59.5
0.008299
def _get_uniprot_id(agent): """Return the UniProt ID for an agent, looking up in HGNC if necessary. If the UniProt ID is a list then return the first ID by default. """ up_id = agent.db_refs.get('UP') hgnc_id = agent.db_refs.get('HGNC') if up_id is None: if hgnc_id is None: ...
[ "def", "_get_uniprot_id", "(", "agent", ")", ":", "up_id", "=", "agent", ".", "db_refs", ".", "get", "(", "'UP'", ")", "hgnc_id", "=", "agent", ".", "db_refs", ".", "get", "(", "'HGNC'", ")", "if", "up_id", "is", "None", ":", "if", "hgnc_id", "is", ...
37.545455
0.001181
def purge_url(self, host, path): """Purge an individual URL.""" content = self._fetch(path, method="PURGE", headers={ "Host": host }) return FastlyPurge(self, content)
[ "def", "purge_url", "(", "self", ",", "host", ",", "path", ")", ":", "content", "=", "self", ".", "_fetch", "(", "path", ",", "method", "=", "\"PURGE\"", ",", "headers", "=", "{", "\"Host\"", ":", "host", "}", ")", "return", "FastlyPurge", "(", "self...
42.75
0.051724
def transform_position_array(array, pos, euler, is_normal, reverse=False): """ Transform any Nx3 position array by translating to a center-of-mass 'pos' and applying an euler transformation :parameter array array: numpy array of Nx3 positions in the original (star) coordinate frame :paramet...
[ "def", "transform_position_array", "(", "array", ",", "pos", ",", "euler", ",", "is_normal", ",", "reverse", "=", "False", ")", ":", "trans_matrix", "=", "euler_trans_matrix", "(", "*", "euler", ")", "if", "not", "reverse", ":", "trans_matrix", "=", "trans_m...
39.285714
0.000887
def _find_by(self, key): """Find devices.""" by_path = glob.glob('/dev/input/by-{key}/*-event-*'.format(key=key)) for device_path in by_path: self._parse_device_path(device_path)
[ "def", "_find_by", "(", "self", ",", "key", ")", ":", "by_path", "=", "glob", ".", "glob", "(", "'/dev/input/by-{key}/*-event-*'", ".", "format", "(", "key", "=", "key", ")", ")", "for", "device_path", "in", "by_path", ":", "self", ".", "_parse_device_path...
42
0.009346
def download(self, force=False, silent=False): """Download from URL.""" def _download(): if self.url.startswith("http"): self._download_http(silent=silent) elif self.url.startswith("ftp"): self._download_ftp(silent=silent) else: ...
[ "def", "download", "(", "self", ",", "force", "=", "False", ",", "silent", "=", "False", ")", ":", "def", "_download", "(", ")", ":", "if", "self", ".", "url", ".", "startswith", "(", "\"http\"", ")", ":", "self", ".", "_download_http", "(", "silent"...
40.75
0.001198
def parse_line(self, statement, element, mode): """As part of real-time update, parses the statement and adjusts the attributes of the specified CustomType instance to reflect the changes. :arg statement: the lines of code that was added/removed/changed on the element after it had al...
[ "def", "parse_line", "(", "self", ",", "statement", ",", "element", ",", "mode", ")", ":", "if", "element", ".", "incomplete", ":", "#We need to check for the end_token so we can close up the incomplete", "#status for the instance.", "if", "element", ".", "end_token", "...
50.363636
0.0124
def envs(self): ''' Check the refs and return a list of the ones which can be used as salt environments. ''' ref_paths = [x.path for x in self.repo.refs] return self._get_envs_from_ref_paths(ref_paths)
[ "def", "envs", "(", "self", ")", ":", "ref_paths", "=", "[", "x", ".", "path", "for", "x", "in", "self", ".", "repo", ".", "refs", "]", "return", "self", ".", "_get_envs_from_ref_paths", "(", "ref_paths", ")" ]
34.714286
0.008032
def render(self): """Render the axes data into the dict data""" for opt,values in self.data.items(): if opt == 'ticks': self['chxtc'] = '|'.join(values) else: self['chx%s'%opt[0]] = '|'.join(values) return self
[ "def", "render", "(", "self", ")", ":", "for", "opt", ",", "values", "in", "self", ".", "data", ".", "items", "(", ")", ":", "if", "opt", "==", "'ticks'", ":", "self", "[", "'chxtc'", "]", "=", "'|'", ".", "join", "(", "values", ")", "else", ":...
35.375
0.013793
def s_to_ev(offset_us, source_to_detector_m, array): """convert time (s) to energy (eV) Parameters: =========== numpy array of time in s offset_us: float. Delay of detector in us source_to_detector_m: float. Distance source to detector in m Returns: ======== numpy array of energy in...
[ "def", "s_to_ev", "(", "offset_us", ",", "source_to_detector_m", ",", "array", ")", ":", "lambda_a", "=", "3956.", "*", "(", "array", "+", "offset_us", "*", "1e-6", ")", "/", "source_to_detector_m", "return", "(", "81.787", "/", "pow", "(", "lambda_a", ","...
31.285714
0.002217
def get_uaa(self): """ Returns an insstance of the UAA Service. """ import predix.security.uaa uaa = predix.security.uaa.UserAccountAuthentication() return uaa
[ "def", "get_uaa", "(", "self", ")", ":", "import", "predix", ".", "security", ".", "uaa", "uaa", "=", "predix", ".", "security", ".", "uaa", ".", "UserAccountAuthentication", "(", ")", "return", "uaa" ]
28.714286
0.009662
def transform(line, known_fields=ENRICHED_EVENT_FIELD_TYPES, add_geolocation_data=True): """ Convert a Snowplow enriched event TSV into a JSON """ return jsonify_good_event(line.split('\t'), known_fields, add_geolocation_data)
[ "def", "transform", "(", "line", ",", "known_fields", "=", "ENRICHED_EVENT_FIELD_TYPES", ",", "add_geolocation_data", "=", "True", ")", ":", "return", "jsonify_good_event", "(", "line", ".", "split", "(", "'\\t'", ")", ",", "known_fields", ",", "add_geolocation_da...
47.6
0.012397
def load_config(path=None, defaults=None): """ Loads and parses an INI style configuration file using Python's built-in configparser module. If path is specified, load it. If ``defaults`` (a list of strings) is given, try to load each entry as a file, without throwing any error if the operation fail...
[ "def", "load_config", "(", "path", "=", "None", ",", "defaults", "=", "None", ")", ":", "if", "defaults", "is", "None", ":", "defaults", "=", "DEFAULT_FILES", "config", "=", "ConfigParser", "(", "allow_no_value", "=", "True", ")", "if", "defaults", ":", ...
32.96
0.001179
def _iter_from_annotations_dict(graph: BELGraph, annotations_dict: AnnotationsDict, ) -> Iterable[Tuple[str, Set[str]]]: """Iterate over the key/value pairs in this edge data dictionary normalized to their source URLs.""" for key, n...
[ "def", "_iter_from_annotations_dict", "(", "graph", ":", "BELGraph", ",", "annotations_dict", ":", "AnnotationsDict", ",", ")", "->", "Iterable", "[", "Tuple", "[", "str", ",", "Set", "[", "str", "]", "]", "]", ":", "for", "key", ",", "names", "in", "ann...
52.625
0.008168
def CopyToDict(self): """Copies the path specification to a dictionary. Returns: dict[str, object]: path specification attributes. """ path_spec_dict = {} for attribute_name, attribute_value in iter(self.__dict__.items()): if attribute_value is None: continue if attribute...
[ "def", "CopyToDict", "(", "self", ")", ":", "path_spec_dict", "=", "{", "}", "for", "attribute_name", ",", "attribute_value", "in", "iter", "(", "self", ".", "__dict__", ".", "items", "(", ")", ")", ":", "if", "attribute_value", "is", "None", ":", "conti...
27.058824
0.008403
def from_string(cls, s): """Create an istance from string s containing a YAML dictionary.""" stream = cStringIO(s) stream.seek(0) return cls(**yaml.safe_load(stream))
[ "def", "from_string", "(", "cls", ",", "s", ")", ":", "stream", "=", "cStringIO", "(", "s", ")", "stream", ".", "seek", "(", "0", ")", "return", "cls", "(", "*", "*", "yaml", ".", "safe_load", "(", "stream", ")", ")" ]
38.8
0.010101
def read_config(config_path): """read config_path and return options as dictionary""" result = {} with open(config_path, 'r') as fd: for line in fd.readlines(): if '=' in line: key, value = line.split('=', 1) try: result[key] = json.loa...
[ "def", "read_config", "(", "config_path", ")", ":", "result", "=", "{", "}", "with", "open", "(", "config_path", ",", "'r'", ")", "as", "fd", ":", "for", "line", "in", "fd", ".", "readlines", "(", ")", ":", "if", "'='", "in", "line", ":", "key", ...
35.333333
0.002299
def assign_hosting_device_to_cfg_agent(self, context, cfg_agent_id, hosting_device_id): """Make config agent handle an (unassigned) hosting device.""" hd_db = self._get_hosting_device(context, hosting_device_id) if hd_db.cfg_agent_id: if hd_...
[ "def", "assign_hosting_device_to_cfg_agent", "(", "self", ",", "context", ",", "cfg_agent_id", ",", "hosting_device_id", ")", ":", "hd_db", "=", "self", ".", "_get_hosting_device", "(", "context", ",", "hosting_device_id", ")", "if", "hd_db", ".", "cfg_agent_id", ...
62.380952
0.002256
def _run_bubbletree(vcf_csv, cnv_csv, data, wide_lrr=False, do_plots=True, handle_failures=True): """Create R script and run on input data BubbleTree has some internal hardcoded paramters that assume a smaller distribution of log2 scores. This is not true for tumor-only calls, so if ...
[ "def", "_run_bubbletree", "(", "vcf_csv", ",", "cnv_csv", ",", "data", ",", "wide_lrr", "=", "False", ",", "do_plots", "=", "True", ",", "handle_failures", "=", "True", ")", ":", "lrr_scale", "=", "10.0", "if", "wide_lrr", "else", "1.0", "local_sitelib", "...
46.857143
0.001195
def plot_slippage_sweep(returns, positions, transactions, slippage_params=(3, 8, 10, 12, 15, 20, 50), ax=None, **kwargs): """ Plots equity curves at different per-dollar slippage assumptions. Parameters ---------- returns : pd.Series Timeserie...
[ "def", "plot_slippage_sweep", "(", "returns", ",", "positions", ",", "transactions", ",", "slippage_params", "=", "(", "3", ",", "8", ",", "10", ",", "12", ",", "15", ",", "20", ",", "50", ")", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ...
32.142857
0.000616