repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
aio-libs/aiohttp
aiohttp/connector.py
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/connector.py#L744-L749
def close(self) -> Awaitable[None]: """Close all ongoing DNS calls.""" for ev in self._throttle_dns_events.values(): ev.cancel() return super().close()
[ "def", "close", "(", "self", ")", "->", "Awaitable", "[", "None", "]", ":", "for", "ev", "in", "self", ".", "_throttle_dns_events", ".", "values", "(", ")", ":", "ev", ".", "cancel", "(", ")", "return", "super", "(", ")", ".", "close", "(", ")" ]
Close all ongoing DNS calls.
[ "Close", "all", "ongoing", "DNS", "calls", "." ]
python
train
30.5
sliem/barrett
example/plot.py
https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L26-L73
def pairplot(dataset, vars, filename, bins=60): """ Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs. """ n = len(vars) fig, axes = plt.subplots(nrows=n, ncols=n) plt.subplots_adjust(wspace=0.1, hspace=0.1) for i, x in enumerate(vars): for j, y in enumerate(var...
[ "def", "pairplot", "(", "dataset", ",", "vars", ",", "filename", ",", "bins", "=", "60", ")", ":", "n", "=", "len", "(", "vars", ")", "fig", ",", "axes", "=", "plt", ".", "subplots", "(", "nrows", "=", "n", ",", "ncols", "=", "n", ")", "plt", ...
Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs.
[ "Plot", "a", "matrix", "of", "the", "specified", "variables", "with", "all", "the", "2D", "pdfs", "and", "1D", "pdfs", "." ]
python
train
37.5625
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pytree.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pytree.py#L429-L445
def convert(gr, raw_node): """ Convert raw node information to a Node or Leaf instance. This is passed to the parser driver which calls it whenever a reduction of a grammar rule produces a new complete node, so that the tree is build strictly bottom-up. """ type, value, context, children = ...
[ "def", "convert", "(", "gr", ",", "raw_node", ")", ":", "type", ",", "value", ",", "context", ",", "children", "=", "raw_node", "if", "children", "or", "type", "in", "gr", ".", "number2symbol", ":", "# If there's exactly one child, return that child instead of", ...
Convert raw node information to a Node or Leaf instance. This is passed to the parser driver which calls it whenever a reduction of a grammar rule produces a new complete node, so that the tree is build strictly bottom-up.
[ "Convert", "raw", "node", "information", "to", "a", "Node", "or", "Leaf", "instance", "." ]
python
train
37.176471
vbwagner/ctypescrypto
ctypescrypto/rand.py
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/rand.py#L15-L28
def bytes(num, check_result=False): """ Returns num bytes of cryptographically strong pseudo-random bytes. If checkc_result is True, raises error if PRNG is not seeded enough """ if num <= 0: raise ValueError("'num' should be > 0") buf = create_string_buffer(num) result = libcry...
[ "def", "bytes", "(", "num", ",", "check_result", "=", "False", ")", ":", "if", "num", "<=", "0", ":", "raise", "ValueError", "(", "\"'num' should be > 0\"", ")", "buf", "=", "create_string_buffer", "(", "num", ")", "result", "=", "libcrypto", ".", "RAND_by...
Returns num bytes of cryptographically strong pseudo-random bytes. If checkc_result is True, raises error if PRNG is not seeded enough
[ "Returns", "num", "bytes", "of", "cryptographically", "strong", "pseudo", "-", "random", "bytes", ".", "If", "checkc_result", "is", "True", "raises", "error", "if", "PRNG", "is", "not", "seeded", "enough" ]
python
train
33.428571
gwastro/pycbc
pycbc/io/hdf.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/io/hdf.py#L204-L215
def cluster(self, window): """ Cluster the dict array, assuming it has the relevant Coinc colums, time1, time2, stat, and timeslide_id """ # If no events, do nothing if len(self.time1) == 0 or len(self.time2) == 0: return self from pycbc.events import cluster_...
[ "def", "cluster", "(", "self", ",", "window", ")", ":", "# If no events, do nothing", "if", "len", "(", "self", ".", "time1", ")", "==", "0", "or", "len", "(", "self", ".", "time2", ")", "==", "0", ":", "return", "self", "from", "pycbc", ".", "events...
Cluster the dict array, assuming it has the relevant Coinc colums, time1, time2, stat, and timeslide_id
[ "Cluster", "the", "dict", "array", "assuming", "it", "has", "the", "relevant", "Coinc", "colums", "time1", "time2", "stat", "and", "timeslide_id" ]
python
train
44.416667
MisterY/asset-allocation
asset_allocation/model.py
https://github.com/MisterY/asset-allocation/blob/72239aa20762cda67c091f27b86e65d61bf3b613/asset_allocation/model.py#L193-L198
def get_cash_asset_class(self) -> AssetClass: """ Find the cash asset class by name. """ for ac in self.asset_classes: if ac.name.lower() == "cash": return ac return None
[ "def", "get_cash_asset_class", "(", "self", ")", "->", "AssetClass", ":", "for", "ac", "in", "self", ".", "asset_classes", ":", "if", "ac", ".", "name", ".", "lower", "(", ")", "==", "\"cash\"", ":", "return", "ac", "return", "None" ]
Find the cash asset class by name.
[ "Find", "the", "cash", "asset", "class", "by", "name", "." ]
python
train
36.166667
mwshinn/paranoidscientist
paranoid/utils.py
https://github.com/mwshinn/paranoidscientist/blob/a5e9198bc40b0a985174ad643cc5d6d0c46efdcd/paranoid/utils.py#L46-L60
def set_fun_prop(f, k, v): """Set the value of property `k` to be `v` in function `f`. We define properties as annotations added to a function throughout the process of defining a function for verification, e.g. the argument types. This sets function `f`'s property named `k` to be value `v`. ...
[ "def", "set_fun_prop", "(", "f", ",", "k", ",", "v", ")", ":", "if", "not", "hasattr", "(", "f", ",", "_FUN_PROPS", ")", ":", "setattr", "(", "f", ",", "_FUN_PROPS", ",", "{", "}", ")", "if", "not", "isinstance", "(", "getattr", "(", "f", ",", ...
Set the value of property `k` to be `v` in function `f`. We define properties as annotations added to a function throughout the process of defining a function for verification, e.g. the argument types. This sets function `f`'s property named `k` to be value `v`. Users should never access this fun...
[ "Set", "the", "value", "of", "property", "k", "to", "be", "v", "in", "function", "f", "." ]
python
train
39.8
oceanprotocol/squid-py
squid_py/keeper/conditions/condition_base.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/conditions/condition_base.py#L62-L85
def subscribe_condition_fulfilled(self, agreement_id, timeout, callback, args, timeout_callback=None, wait=False): """ Subscribe to the condition fullfilled event. :param agreement_id: id of the agreement, hex str :param timeout: :param call...
[ "def", "subscribe_condition_fulfilled", "(", "self", ",", "agreement_id", ",", "timeout", ",", "callback", ",", "args", ",", "timeout_callback", "=", "None", ",", "wait", "=", "False", ")", ":", "logger", ".", "info", "(", "f'Subscribing {self.FULFILLED_EVENT} eve...
Subscribe to the condition fullfilled event. :param agreement_id: id of the agreement, hex str :param timeout: :param callback: :param args: :param timeout_callback: :param wait: if true block the listener until get the event, bool :return:
[ "Subscribe", "to", "the", "condition", "fullfilled", "event", "." ]
python
train
36.791667
pkkid/python-plexapi
plexapi/utils.py
https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/utils.py#L78-L91
def joinArgs(args): """ Returns a query string (uses for HTTP URLs) where only the value is URL encoded. Example return value: '?genre=action&type=1337'. Parameters: args (dict): Arguments to include in query string. """ if not args: return '' arglist = [] for ke...
[ "def", "joinArgs", "(", "args", ")", ":", "if", "not", "args", ":", "return", "''", "arglist", "=", "[", "]", "for", "key", "in", "sorted", "(", "args", ",", "key", "=", "lambda", "x", ":", "x", ".", "lower", "(", ")", ")", ":", "value", "=", ...
Returns a query string (uses for HTTP URLs) where only the value is URL encoded. Example return value: '?genre=action&type=1337'. Parameters: args (dict): Arguments to include in query string.
[ "Returns", "a", "query", "string", "(", "uses", "for", "HTTP", "URLs", ")", "where", "only", "the", "value", "is", "URL", "encoded", ".", "Example", "return", "value", ":", "?genre", "=", "action&type", "=", "1337", "." ]
python
train
34.785714
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L153-L198
def calc_riseset(t, target_name, location, prev_next, rise_set, horizon): """ Time at next rise/set of ``target``. Parameters ---------- t : `~astropy.time.Time` or other (see below) Time of observation. This will be passed in as the first argument to the `~astropy.time.Time` initia...
[ "def", "calc_riseset", "(", "t", ",", "target_name", ",", "location", ",", "prev_next", ",", "rise_set", ",", "horizon", ")", ":", "target", "=", "coord", ".", "get_body", "(", "target_name", ",", "t", ")", "t0", "=", "_rise_set_trig", "(", "t", ",", "...
Time at next rise/set of ``target``. Parameters ---------- t : `~astropy.time.Time` or other (see below) Time of observation. This will be passed in as the first argument to the `~astropy.time.Time` initializer, so it can be anything that `~astropy.time.Time` will accept (including ...
[ "Time", "at", "next", "rise", "/", "set", "of", "target", "." ]
python
train
34.978261
sdispater/pendulum
pendulum/date.py
https://github.com/sdispater/pendulum/blob/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e/pendulum/date.py#L469-L477
def _start_of_decade(self): """ Reset the date to the first day of the decade. :rtype: Date """ year = self.year - self.year % YEARS_PER_DECADE return self.set(year, 1, 1)
[ "def", "_start_of_decade", "(", "self", ")", ":", "year", "=", "self", ".", "year", "-", "self", ".", "year", "%", "YEARS_PER_DECADE", "return", "self", ".", "set", "(", "year", ",", "1", ",", "1", ")" ]
Reset the date to the first day of the decade. :rtype: Date
[ "Reset", "the", "date", "to", "the", "first", "day", "of", "the", "decade", "." ]
python
train
23.666667
tensorpack/tensorpack
tensorpack/tfutils/summary.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/summary.py#L56-L92
def create_image_summary(name, val): """ Args: name(str): val(np.ndarray): 4D tensor of NHWC. assume RGB if C==3. Can be either float or uint8. Range has to be [0,255]. Returns: tf.Summary: """ assert isinstance(name, six.string_types), type(name) n, h, w, c ...
[ "def", "create_image_summary", "(", "name", ",", "val", ")", ":", "assert", "isinstance", "(", "name", ",", "six", ".", "string_types", ")", ",", "type", "(", "name", ")", "n", ",", "h", ",", "w", ",", "c", "=", "val", ".", "shape", "val", "=", "...
Args: name(str): val(np.ndarray): 4D tensor of NHWC. assume RGB if C==3. Can be either float or uint8. Range has to be [0,255]. Returns: tf.Summary:
[ "Args", ":", "name", "(", "str", ")", ":", "val", "(", "np", ".", "ndarray", ")", ":", "4D", "tensor", "of", "NHWC", ".", "assume", "RGB", "if", "C", "==", "3", ".", "Can", "be", "either", "float", "or", "uint8", ".", "Range", "has", "to", "be"...
python
train
30.513514
EnigmaBridge/client.py
ebclient/eb_create_uo.py
https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_create_uo.py#L532-L563
def read_serialized_rsa_pub_key(serialized): """ Reads serialized RSA pub key TAG|len-2B|value. 81 = exponent, 82 = modulus :param serialized: :return: n, e """ n = None e = None rsa = from_hex(serialized) pos = 0 ln = len(rsa) ...
[ "def", "read_serialized_rsa_pub_key", "(", "serialized", ")", ":", "n", "=", "None", "e", "=", "None", "rsa", "=", "from_hex", "(", "serialized", ")", "pos", "=", "0", "ln", "=", "len", "(", "rsa", ")", "while", "pos", "<", "ln", ":", "tag", "=", "...
Reads serialized RSA pub key TAG|len-2B|value. 81 = exponent, 82 = modulus :param serialized: :return: n, e
[ "Reads", "serialized", "RSA", "pub", "key", "TAG|len", "-", "2B|value", ".", "81", "=", "exponent", "82", "=", "modulus" ]
python
train
25.5625
ulf1/oxyba
oxyba/clean_dateobject_to_string.py
https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/clean_dateobject_to_string.py#L2-L66
def clean_dateobject_to_string(x): """Convert a Pandas Timestamp object or datetime object to 'YYYY-MM-DD' string Parameters ---------- x : str, list, tuple, numpy.ndarray, pandas.DataFrame A Pandas Timestamp object or datetime object, or an array of these objects Returns -...
[ "def", "clean_dateobject_to_string", "(", "x", ")", ":", "import", "numpy", "as", "np", "import", "pandas", "as", "pd", "def", "proc_elem", "(", "e", ")", ":", "try", ":", "return", "e", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", "except", "Exception", "...
Convert a Pandas Timestamp object or datetime object to 'YYYY-MM-DD' string Parameters ---------- x : str, list, tuple, numpy.ndarray, pandas.DataFrame A Pandas Timestamp object or datetime object, or an array of these objects Returns ------- y : str, list, tuple, numpy.nda...
[ "Convert", "a", "Pandas", "Timestamp", "object", "or", "datetime", "object", "to", "YYYY", "-", "MM", "-", "DD", "string" ]
python
train
27.030769
ttinies/sc2gameMapRepo
sc2maptool/cli.py
https://github.com/ttinies/sc2gameMapRepo/blob/3a215067fae8f86f6a3ffe37272fbd7a5461cfab/sc2maptool/cli.py#L56-L90
def main(): # mini/unit test """ PURPOSE: command-line interface for map information """ options = optionsParser().parse_args() params = getSelectionParams(options) if options.list or options.details: specifiedMaps = filterMapNames( options.mapname, records = filt...
[ "def", "main", "(", ")", ":", "# mini/unit test", "options", "=", "optionsParser", "(", ")", ".", "parse_args", "(", ")", "params", "=", "getSelectionParams", "(", "options", ")", "if", "options", ".", "list", "or", "options", ".", "details", ":", "specifi...
PURPOSE: command-line interface for map information
[ "PURPOSE", ":", "command", "-", "line", "interface", "for", "map", "information" ]
python
train
35.2
Azure/azure-multiapi-storage-python
azure/multiapi/storage/v2015_04_05/table/tableservice.py
https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2015_04_05/table/tableservice.py#L649-L710
def _query_entities(self, table_name, filter=None, select=None, max_results=None, marker=None, accept=TablePayloadFormat.JSON_MINIMAL_METADATA, property_resolver=None, timeout=None): ''' Returns a list of entities under the specified table. Makes a single li...
[ "def", "_query_entities", "(", "self", ",", "table_name", ",", "filter", "=", "None", ",", "select", "=", "None", ",", "max_results", "=", "None", ",", "marker", "=", "None", ",", "accept", "=", "TablePayloadFormat", ".", "JSON_MINIMAL_METADATA", ",", "prope...
Returns a list of entities under the specified table. Makes a single list request to the service. Used internally by the query_entities method. :param str table_name: The name of the table to query. :param str filter: Returns only entities that satisfy the specified fil...
[ "Returns", "a", "list", "of", "entities", "under", "the", "specified", "table", ".", "Makes", "a", "single", "list", "request", "to", "the", "service", ".", "Used", "internally", "by", "the", "query_entities", "method", "." ]
python
train
52.241935
stephenmcd/gnotty
gnotty/client.py
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L160-L174
def on_nick(self, connection, event): """ Someone changed their nickname - send the nicknames list to the WebSocket. """ old_nickname = self.get_nickname(event) old_color = self.nicknames.pop(old_nickname) new_nickname = event.target() message = "is now kn...
[ "def", "on_nick", "(", "self", ",", "connection", ",", "event", ")", ":", "old_nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "old_color", "=", "self", ".", "nicknames", ".", "pop", "(", "old_nickname", ")", "new_nickname", "=", "event", ...
Someone changed their nickname - send the nicknames list to the WebSocket.
[ "Someone", "changed", "their", "nickname", "-", "send", "the", "nicknames", "list", "to", "the", "WebSocket", "." ]
python
train
40.4
cloudtools/stacker
stacker/providers/aws/default.py
https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/providers/aws/default.py#L838-L873
def update_stack(self, fqn, template, old_parameters, parameters, tags, force_interactive=False, force_change_set=False, stack_policy=None, **kwargs): """Update a Cloudformation stack. Args: fqn (str): The fully qualified name of the Cloudformation ...
[ "def", "update_stack", "(", "self", ",", "fqn", ",", "template", ",", "old_parameters", ",", "parameters", ",", "tags", ",", "force_interactive", "=", "False", ",", "force_change_set", "=", "False", ",", "stack_policy", "=", "None", ",", "*", "*", "kwargs", ...
Update a Cloudformation stack. Args: fqn (str): The fully qualified name of the Cloudformation stack. template (:class:`stacker.providers.base.Template`): A Template object to use when updating the stack. old_parameters (list): A list of dictionaries that def...
[ "Update", "a", "Cloudformation", "stack", "." ]
python
train
56.916667
mitodl/PyLmod
pylmod/gradebook.py
https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L64-L80
def unravel_sections(section_data): """Unravels section type dictionary into flat list of sections with section type set as an attribute. Args: section_data(dict): Data return from py:method::get_sections Returns: list: Flat list of sections with ``sectionType``...
[ "def", "unravel_sections", "(", "section_data", ")", ":", "sections", "=", "[", "]", "for", "type", ",", "subsection_list", "in", "section_data", ".", "items", "(", ")", ":", "for", "section", "in", "subsection_list", ":", "section", "[", "'sectionType'", "]...
Unravels section type dictionary into flat list of sections with section type set as an attribute. Args: section_data(dict): Data return from py:method::get_sections Returns: list: Flat list of sections with ``sectionType`` set to type (i.e. recitation, ...
[ "Unravels", "section", "type", "dictionary", "into", "flat", "list", "of", "sections", "with", "section", "type", "set", "as", "an", "attribute", "." ]
python
train
36
cloudera/impyla
impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py
https://github.com/cloudera/impyla/blob/547fa2ba3b6151e2a98b3544301471a643212dc3/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L4873-L4881
def alter_function(self, dbName, funcName, newFunc): """ Parameters: - dbName - funcName - newFunc """ self.send_alter_function(dbName, funcName, newFunc) self.recv_alter_function()
[ "def", "alter_function", "(", "self", ",", "dbName", ",", "funcName", ",", "newFunc", ")", ":", "self", ".", "send_alter_function", "(", "dbName", ",", "funcName", ",", "newFunc", ")", "self", ".", "recv_alter_function", "(", ")" ]
Parameters: - dbName - funcName - newFunc
[ "Parameters", ":", "-", "dbName", "-", "funcName", "-", "newFunc" ]
python
train
23.111111
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_battery.py#L121-L131
def mavlink_packet(self, m): '''handle a mavlink packet''' mtype = m.get_type() if mtype == "SYS_STATUS": self.battery_update(m) if mtype == "BATTERY2": self.battery2_voltage = m.voltage * 0.001 if mtype == "POWER_STATUS": self.power_status_upd...
[ "def", "mavlink_packet", "(", "self", ",", "m", ")", ":", "mtype", "=", "m", ".", "get_type", "(", ")", "if", "mtype", "==", "\"SYS_STATUS\"", ":", "self", ".", "battery_update", "(", "m", ")", "if", "mtype", "==", "\"BATTERY2\"", ":", "self", ".", "...
handle a mavlink packet
[ "handle", "a", "mavlink", "packet" ]
python
train
35.636364
briney/abutils
abutils/utils/s3.py
https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/utils/s3.py#L96-L123
def put(f, s3_path, multipart_chunk_size_mb=500, logger=None): ''' Uploads a single file to S3, using s3cmd. Args: f (str): Path to a single file. s3_path (str): The S3 path, with the filename omitted. The S3 filename will be the basename of the ``f``. For example:: ...
[ "def", "put", "(", "f", ",", "s3_path", ",", "multipart_chunk_size_mb", "=", "500", ",", "logger", "=", "None", ")", ":", "if", "not", "logger", ":", "logger", "=", "log", ".", "get_logger", "(", "'s3'", ")", "fname", "=", "os", ".", "path", ".", "...
Uploads a single file to S3, using s3cmd. Args: f (str): Path to a single file. s3_path (str): The S3 path, with the filename omitted. The S3 filename will be the basename of the ``f``. For example:: put(f='/path/to/myfile.tar.gz', s3_path='s3://my_bucket/path/to/') ...
[ "Uploads", "a", "single", "file", "to", "S3", "using", "s3cmd", "." ]
python
train
38.321429
rorr73/LifeSOSpy
lifesospy/protocol.py
https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/protocol.py#L177-L185
def close(self) -> None: """Closes connection to the LifeSOS ethernet interface.""" self.cancel_pending_tasks() _LOGGER.debug("Disconnected") if self._transport: self._transport.close() self._is_connected = False
[ "def", "close", "(", "self", ")", "->", "None", ":", "self", ".", "cancel_pending_tasks", "(", ")", "_LOGGER", ".", "debug", "(", "\"Disconnected\"", ")", "if", "self", ".", "_transport", ":", "self", ".", "_transport", ".", "close", "(", ")", "self", ...
Closes connection to the LifeSOS ethernet interface.
[ "Closes", "connection", "to", "the", "LifeSOS", "ethernet", "interface", "." ]
python
train
28.666667
CalebBell/fluids
fluids/geometry.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1651-L1710
def set_misc(self): '''Set more parameters, after the tank is better defined than in the __init__ function. Notes ----- Two of D, L, and L_over_D must be known when this function runs. The other one is set from the other two first thing in this function. a_ratio ...
[ "def", "set_misc", "(", "self", ")", ":", "if", "self", ".", "D", "and", "self", ".", "L", ":", "# If L and D are known, get L_over_D", "self", ".", "L_over_D", "=", "self", ".", "L", "/", "self", ".", "D", "elif", "self", ".", "D", "and", "self", "....
Set more parameters, after the tank is better defined than in the __init__ function. Notes ----- Two of D, L, and L_over_D must be known when this function runs. The other one is set from the other two first thing in this function. a_ratio parameters are used to calculat...
[ "Set", "more", "parameters", "after", "the", "tank", "is", "better", "defined", "than", "in", "the", "__init__", "function", "." ]
python
train
41.033333
kfdm/gntp
gntp/core.py
https://github.com/kfdm/gntp/blob/772a5f4db3707ea0253691d930bf648d1344913a/gntp/core.py#L354-L385
def encode(self): """Encode a GNTP Registration Message :return string: Encoded GNTP Registration message. Returned as a byte string """ buff = _GNTPBuffer() buff.writeln(self._format_info()) #Headers for k, v in self.headers.items(): buff.writeheader(k, v) buff.writeln() #Notifications if l...
[ "def", "encode", "(", "self", ")", ":", "buff", "=", "_GNTPBuffer", "(", ")", "buff", ".", "writeln", "(", "self", ".", "_format_info", "(", ")", ")", "#Headers", "for", "k", ",", "v", "in", "self", ".", "headers", ".", "items", "(", ")", ":", "b...
Encode a GNTP Registration Message :return string: Encoded GNTP Registration message. Returned as a byte string
[ "Encode", "a", "GNTP", "Registration", "Message" ]
python
train
21.21875
twisted/epsilon
epsilon/ampauth.py
https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/ampauth.py#L222-L229
def connectionLost(self, reason): """ If a login has happened, perform a logout. """ AMP.connectionLost(self, reason) if self.logout is not None: self.logout() self.boxReceiver = self.logout = None
[ "def", "connectionLost", "(", "self", ",", "reason", ")", ":", "AMP", ".", "connectionLost", "(", "self", ",", "reason", ")", "if", "self", ".", "logout", "is", "not", "None", ":", "self", ".", "logout", "(", ")", "self", ".", "boxReceiver", "=", "se...
If a login has happened, perform a logout.
[ "If", "a", "login", "has", "happened", "perform", "a", "logout", "." ]
python
train
31.75
Gandi/gandi.cli
gandi/cli/core/params.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/params.py#L526-L530
def display_value(self, ctx, value): """ Display value to be used for this parameter. """ gandi = ctx.obj gandi.log('%s: %s' % (self.name, (value if value is not None else 'Not found')))
[ "def", "display_value", "(", "self", ",", "ctx", ",", "value", ")", ":", "gandi", "=", "ctx", ".", "obj", "gandi", ".", "log", "(", "'%s: %s'", "%", "(", "self", ".", "name", ",", "(", "value", "if", "value", "is", "not", "None", "else", "'Not foun...
Display value to be used for this parameter.
[ "Display", "value", "to", "be", "used", "for", "this", "parameter", "." ]
python
train
49.6
wdbm/megaparsex
megaparsex_example_1.py
https://github.com/wdbm/megaparsex/blob/59da05410aa1cf8682dcee2bf0bd0572fa42bd29/megaparsex_example_1.py#L44-L92
def main(): """ Loop over a list of input text strings. Parse each string using a list of parsers, one included in megaparsex and one defined in this script. If a confirmation is requested, seek confirmation, otherwise display any response text and engage any triggered functions. """ for tex...
[ "def", "main", "(", ")", ":", "for", "text", "in", "[", "\"how are you\"", ",", "\"ip address\"", ",", "\"restart\"", ",", "\"run command\"", ",", "\"rain EGPF\"", ",", "\"reverse SSH\"", "]", ":", "print", "(", "\"\\nparse text: \"", "+", "text", "+", "\"\\nW...
Loop over a list of input text strings. Parse each string using a list of parsers, one included in megaparsex and one defined in this script. If a confirmation is requested, seek confirmation, otherwise display any response text and engage any triggered functions.
[ "Loop", "over", "a", "list", "of", "input", "text", "strings", ".", "Parse", "each", "string", "using", "a", "list", "of", "parsers", "one", "included", "in", "megaparsex", "and", "one", "defined", "in", "this", "script", ".", "If", "a", "confirmation", ...
python
train
35.346939
MisterY/pydatum
pydatum/datum.py
https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L213-L216
def today(self) -> datetime: """ Returns today (date only) as datetime """ self.value = datetime.combine(datetime.today().date(), time.min) return self.value
[ "def", "today", "(", "self", ")", "->", "datetime", ":", "self", ".", "value", "=", "datetime", ".", "combine", "(", "datetime", ".", "today", "(", ")", ".", "date", "(", ")", ",", "time", ".", "min", ")", "return", "self", ".", "value" ]
Returns today (date only) as datetime
[ "Returns", "today", "(", "date", "only", ")", "as", "datetime" ]
python
train
44.5
sirfoga/pyhal
hal/streams/pretty_table.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/pretty_table.py#L36-L53
def _parse_value(self, raw): """Parses value :param raw: raw value :return: Parsed value """ try: if not raw.startswith("0"): val = float(raw) if (val % 1) == 0: # integer val = int(raw) return ...
[ "def", "_parse_value", "(", "self", ",", "raw", ")", ":", "try", ":", "if", "not", "raw", ".", "startswith", "(", "\"0\"", ")", ":", "val", "=", "float", "(", "raw", ")", "if", "(", "val", "%", "1", ")", "==", "0", ":", "# integer", "val", "=",...
Parses value :param raw: raw value :return: Parsed value
[ "Parses", "value" ]
python
train
26.611111
LukeB42/Window
window.py
https://github.com/LukeB42/Window/blob/6d91c5ff94b8127e9c60f6eb78b7f9026d2faf62/window.py#L101-L110
def stop(self): """ Restore the TTY to its original state. """ _curses.nocbreak() self.window.keypad(0) _curses.echo() _curses.resetty() _curses.endwin() self.running = False
[ "def", "stop", "(", "self", ")", ":", "_curses", ".", "nocbreak", "(", ")", "self", ".", "window", ".", "keypad", "(", "0", ")", "_curses", ".", "echo", "(", ")", "_curses", ".", "resetty", "(", ")", "_curses", ".", "endwin", "(", ")", "self", "....
Restore the TTY to its original state.
[ "Restore", "the", "TTY", "to", "its", "original", "state", "." ]
python
train
23.7
roclark/sportsreference
sportsreference/nba/roster.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L413-L440
def _combine_contract(self, years, wages): """ Combine the contract wages and year. Match the wages with the year and add to a dictionary representing the player's contract. Parameters ---------- years : list A list where each element is a string den...
[ "def", "_combine_contract", "(", "self", ",", "years", ",", "wages", ")", ":", "contract", "=", "{", "}", "for", "i", "in", "range", "(", "len", "(", "years", ")", ")", ":", "contract", "[", "years", "[", "i", "]", "]", "=", "wages", "[", "i", ...
Combine the contract wages and year. Match the wages with the year and add to a dictionary representing the player's contract. Parameters ---------- years : list A list where each element is a string denoting the season, such as '2017-18'. wages ...
[ "Combine", "the", "contract", "wages", "and", "year", "." ]
python
train
32.178571
quasipedia/swaggery
examples/calc/calc.py
https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/calc/calc.py#L57-L87
def two_numbers( cls, request, operation: (Ptypes.path, String('One of the 4 arithmetic operations.', enum=['add', 'sub', 'mul', 'div'])), first: (Ptypes.path, Float('The first operand.')), second...
[ "def", "two_numbers", "(", "cls", ",", "request", ",", "operation", ":", "(", "Ptypes", ".", "path", ",", "String", "(", "'One of the 4 arithmetic operations.'", ",", "enum", "=", "[", "'add'", ",", "'sub'", ",", "'mul'", ",", "'div'", "]", ")", ")", ","...
Any of the four arithmetic operation on two numbers.
[ "Any", "of", "the", "four", "arithmetic", "operation", "on", "two", "numbers", "." ]
python
train
37.225806
tornadoweb/tornado
tornado/concurrent.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/concurrent.py#L74-L135
def run_on_executor(*args: Any, **kwargs: Any) -> Callable: """Decorator to run a synchronous method asynchronously on an executor. The decorated method may be called with a ``callback`` keyword argument and returns a future. The executor to be used is determined by the ``executor`` attributes of ...
[ "def", "run_on_executor", "(", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Callable", ":", "# Fully type-checking decorators is tricky, and this one is", "# discouraged anyway so it doesn't have all the generic magic.", "def", "run_on_executor_de...
Decorator to run a synchronous method asynchronously on an executor. The decorated method may be called with a ``callback`` keyword argument and returns a future. The executor to be used is determined by the ``executor`` attributes of ``self``. To use a different attribute name, pass a keyword arg...
[ "Decorator", "to", "run", "a", "synchronous", "method", "asynchronously", "on", "an", "executor", "." ]
python
train
37.709677
boriel/zxbasic
asmparse.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1301-L1347
def p_expr_div_expr(p): """ expr : expr BAND expr | expr BOR expr | expr BXOR expr | expr PLUS expr | expr MINUS expr | expr MUL expr | expr DIV expr | expr MOD expr | expr POW expr | expr LSHIFT exp...
[ "def", "p_expr_div_expr", "(", "p", ")", ":", "p", "[", "0", "]", "=", "Expr", ".", "makenode", "(", "Container", "(", "p", "[", "2", "]", ",", "p", ".", "lineno", "(", "2", ")", ")", ",", "p", "[", "1", "]", ",", "p", "[", "3", "]", ")" ...
expr : expr BAND expr | expr BOR expr | expr BXOR expr | expr PLUS expr | expr MINUS expr | expr MUL expr | expr DIV expr | expr MOD expr | expr POW expr | expr LSHIFT expr | expr RSHIFT exp...
[ "expr", ":", "expr", "BAND", "expr", "|", "expr", "BOR", "expr", "|", "expr", "BXOR", "expr", "|", "expr", "PLUS", "expr", "|", "expr", "MINUS", "expr", "|", "expr", "MUL", "expr", "|", "expr", "DIV", "expr", "|", "expr", "MOD", "expr", "|", "expr"...
python
train
30.12766
spotify/luigi
luigi/execution_summary.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/execution_summary.py#L350-L355
def _get_run_by_other_worker(worker): """ This returns a set of the tasks that are being run by other worker """ task_sets = _get_external_workers(worker).values() return functools.reduce(lambda a, b: a | b, task_sets, set())
[ "def", "_get_run_by_other_worker", "(", "worker", ")", ":", "task_sets", "=", "_get_external_workers", "(", "worker", ")", ".", "values", "(", ")", "return", "functools", ".", "reduce", "(", "lambda", "a", ",", "b", ":", "a", "|", "b", ",", "task_sets", ...
This returns a set of the tasks that are being run by other worker
[ "This", "returns", "a", "set", "of", "the", "tasks", "that", "are", "being", "run", "by", "other", "worker" ]
python
train
40
Locu/chronology
kronos/kronos/storage/memory/client.py
https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/kronos/kronos/storage/memory/client.py#L61-L79
def _delete(self, namespace, stream, start_id, end_time, configuration): """ Delete events with id > `start_id` and end_time <= `end_time`. """ start_id_event = Event(start_id) end_id_event = Event(uuid_from_kronos_time(end_time, _type=UUIDType.HIGHEST)...
[ "def", "_delete", "(", "self", ",", "namespace", ",", "stream", ",", "start_id", ",", "end_time", ",", "configuration", ")", ":", "start_id_event", "=", "Event", "(", "start_id", ")", "end_id_event", "=", "Event", "(", "uuid_from_kronos_time", "(", "end_time",...
Delete events with id > `start_id` and end_time <= `end_time`.
[ "Delete", "events", "with", "id", ">", "start_id", "and", "end_time", "<", "=", "end_time", "." ]
python
train
36.210526
adamrehn/ue4cli
ue4cli/UnrealManagerBase.py
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/UnrealManagerBase.py#L123-L131
def getProjectDescriptor(self, dir): """ Detects the .uproject descriptor file for the Unreal project in the specified directory """ for project in glob.glob(os.path.join(dir, '*.uproject')): return os.path.realpath(project) # No project detected raise UnrealManagerException('could not detect an Unrea...
[ "def", "getProjectDescriptor", "(", "self", ",", "dir", ")", ":", "for", "project", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "'*.uproject'", ")", ")", ":", "return", "os", ".", "path", ".", "realpath", "(", "...
Detects the .uproject descriptor file for the Unreal project in the specified directory
[ "Detects", "the", ".", "uproject", "descriptor", "file", "for", "the", "Unreal", "project", "in", "the", "specified", "directory" ]
python
train
38.666667
Jajcus/pyxmpp2
pyxmpp2/ext/muc/muccore.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/muc/muccore.py#L527-L537
def add_item(self,item): """Add an item to `self`. :Parameters: - `item`: the item to add. :Types: - `item`: `MucItemBase` """ if not isinstance(item,MucItemBase): raise TypeError("Bad item type for muc#user") item.as_xml(self.xmlnode)
[ "def", "add_item", "(", "self", ",", "item", ")", ":", "if", "not", "isinstance", "(", "item", ",", "MucItemBase", ")", ":", "raise", "TypeError", "(", "\"Bad item type for muc#user\"", ")", "item", ".", "as_xml", "(", "self", ".", "xmlnode", ")" ]
Add an item to `self`. :Parameters: - `item`: the item to add. :Types: - `item`: `MucItemBase`
[ "Add", "an", "item", "to", "self", "." ]
python
valid
28.181818
timothyb0912/pylogit
pylogit/uneven_logit.py
https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/uneven_logit.py#L452-L481
def create_calc_dh_d_shape(estimator): """ Return the function that can be used in the various gradient and hessian calculations to calculate the derivative of the transformation with respect to the shape parameters. Parameters ---------- estimator : an instance of the estimation.LogitTypeE...
[ "def", "create_calc_dh_d_shape", "(", "estimator", ")", ":", "dh_d_shape", "=", "estimator", ".", "rows_to_alts", ".", "copy", "(", ")", "# Create a function that will take in the pre-formed matrix, replace its", "# data in-place with the new data, and return the correct dh_dshape on...
Return the function that can be used in the various gradient and hessian calculations to calculate the derivative of the transformation with respect to the shape parameters. Parameters ---------- estimator : an instance of the estimation.LogitTypeEstimator class. Should contain a `rows_to_a...
[ "Return", "the", "function", "that", "can", "be", "used", "in", "the", "various", "gradient", "and", "hessian", "calculations", "to", "calculate", "the", "derivative", "of", "the", "transformation", "with", "respect", "to", "the", "shape", "parameters", "." ]
python
train
45.166667
brainiak/brainiak
brainiak/fcma/preprocessing.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/fcma/preprocessing.py#L117-L139
def _randomize_subject_list(data_list, random): """Randomly permute the voxels of a subject list. The method shuffles the subject one by one in place according to the random type. If RandomType.NORANDOM, return the original list. Parameters ---------- data_list: list of 2D array in shape [nV...
[ "def", "_randomize_subject_list", "(", "data_list", ",", "random", ")", ":", "if", "random", "==", "RandomType", ".", "REPRODUCIBLE", ":", "for", "i", "in", "range", "(", "len", "(", "data_list", ")", ")", ":", "_randomize_single_subject", "(", "data_list", ...
Randomly permute the voxels of a subject list. The method shuffles the subject one by one in place according to the random type. If RandomType.NORANDOM, return the original list. Parameters ---------- data_list: list of 2D array in shape [nVxels, nTRs] Activity image data list to be shuf...
[ "Randomly", "permute", "the", "voxels", "of", "a", "subject", "list", "." ]
python
train
31.086957
PyCQA/pylint
pylint/graph.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L21-L26
def target_info_from_filename(filename): """Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png').""" basename = osp.basename(filename) storedir = osp.dirname(osp.abspath(filename)) target = filename.split(".")[-1] return storedir, basename, target
[ "def", "target_info_from_filename", "(", "filename", ")", ":", "basename", "=", "osp", ".", "basename", "(", "filename", ")", "storedir", "=", "osp", ".", "dirname", "(", "osp", ".", "abspath", "(", "filename", ")", ")", "target", "=", "filename", ".", "...
Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png').
[ "Transforms", "/", "some", "/", "path", "/", "foo", ".", "png", "into", "(", "/", "some", "/", "path", "foo", ".", "png", "png", ")", "." ]
python
test
46.166667
CalebBell/thermo
thermo/viscosity.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/viscosity.py#L569-L620
def calculate(self, T, method): r'''Method to calculate low-pressure liquid viscosity at tempearture `T` with a given method. This method has no exception handling; see `T_dependent_property` for that. Parameters ---------- T : float Temperature at w...
[ "def", "calculate", "(", "self", ",", "T", ",", "method", ")", ":", "if", "method", "==", "DUTT_PRASAD", ":", "A", ",", "B", ",", "C", "=", "self", ".", "DUTT_PRASAD_coeffs", "mu", "=", "ViswanathNatarajan3", "(", "T", ",", "A", ",", "B", ",", "C",...
r'''Method to calculate low-pressure liquid viscosity at tempearture `T` with a given method. This method has no exception handling; see `T_dependent_property` for that. Parameters ---------- T : float Temperature at which to calculate viscosity, [K] ...
[ "r", "Method", "to", "calculate", "low", "-", "pressure", "liquid", "viscosity", "at", "tempearture", "T", "with", "a", "given", "method", "." ]
python
valid
40.326923
swharden/SWHLab
doc/oldcode/indexing/monitor.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/indexing/monitor.py#L33-L66
def lazygo(watchFolder='../abfs/',reAnalyze=False,rebuildSite=False, keepGoing=True,matching=False): """ continuously monitor a folder for new abfs and try to analyze them. This is intended to watch only one folder, but can run multiple copies. """ abfsKnown=[] while True: pr...
[ "def", "lazygo", "(", "watchFolder", "=", "'../abfs/'", ",", "reAnalyze", "=", "False", ",", "rebuildSite", "=", "False", ",", "keepGoing", "=", "True", ",", "matching", "=", "False", ")", ":", "abfsKnown", "=", "[", "]", "while", "True", ":", "print", ...
continuously monitor a folder for new abfs and try to analyze them. This is intended to watch only one folder, but can run multiple copies.
[ "continuously", "monitor", "a", "folder", "for", "new", "abfs", "and", "try", "to", "analyze", "them", ".", "This", "is", "intended", "to", "watch", "only", "one", "folder", "but", "can", "run", "multiple", "copies", "." ]
python
valid
41.088235
sanoma/django-arctic
arctic/generics.py
https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L284-L296
def _get_view_media(self): """ Gather view-level media assets """ try: css = self.Media.css except AttributeError: css = {} try: js = self.Media.js except AttributeError: js = [] return Media(css=css, js=js)
[ "def", "_get_view_media", "(", "self", ")", ":", "try", ":", "css", "=", "self", ".", "Media", ".", "css", "except", "AttributeError", ":", "css", "=", "{", "}", "try", ":", "js", "=", "self", ".", "Media", ".", "js", "except", "AttributeError", ":",...
Gather view-level media assets
[ "Gather", "view", "-", "level", "media", "assets" ]
python
train
23.615385
datastax/python-driver
cassandra/cluster.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cluster.py#L4224-L4271
def add_callback(self, fn, *args, **kwargs): """ Attaches a callback function to be called when the final results arrive. By default, `fn` will be called with the results as the first and only argument. If `*args` or `**kwargs` are supplied, they will be passed through as addit...
[ "def", "add_callback", "(", "self", ",", "fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "run_now", "=", "False", "with", "self", ".", "_callback_lock", ":", "# Always add fn to self._callbacks, even when we're about to", "# execute it, to prevent races wit...
Attaches a callback function to be called when the final results arrive. By default, `fn` will be called with the results as the first and only argument. If `*args` or `**kwargs` are supplied, they will be passed through as additional positional or keyword arguments to `fn`. If an err...
[ "Attaches", "a", "callback", "function", "to", "be", "called", "when", "the", "final", "results", "arrive", "." ]
python
train
44.916667
fermiPy/fermipy
fermipy/wcs_utils.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/wcs_utils.py#L242-L251
def offset_to_skydir(skydir, offset_lon, offset_lat, coordsys='CEL', projection='AIT'): """Convert a cartesian offset (X,Y) in the given projection into a SkyCoord.""" offset_lon = np.array(offset_lon, ndmin=1) offset_lat = np.array(offset_lat, ndmin=1) w = create_wcs(skydir, ...
[ "def", "offset_to_skydir", "(", "skydir", ",", "offset_lon", ",", "offset_lat", ",", "coordsys", "=", "'CEL'", ",", "projection", "=", "'AIT'", ")", ":", "offset_lon", "=", "np", ".", "array", "(", "offset_lon", ",", "ndmin", "=", "1", ")", "offset_lat", ...
Convert a cartesian offset (X,Y) in the given projection into a SkyCoord.
[ "Convert", "a", "cartesian", "offset", "(", "X", "Y", ")", "in", "the", "given", "projection", "into", "a", "SkyCoord", "." ]
python
train
39.3
aerkalov/ebooklib
ebooklib/epub.py
https://github.com/aerkalov/ebooklib/blob/305f2dd7f02923ffabf9586a5d16266113d00c4a/ebooklib/epub.py#L466-L486
def get_content(self): """ Returns content for cover page as HTML string. Content will be of type 'str' (Python 2) or 'bytes' (Python 3). :Returns: Returns content of this document. """ self.content = self.book.get_template('cover') tree = parse_string(super(...
[ "def", "get_content", "(", "self", ")", ":", "self", ".", "content", "=", "self", ".", "book", ".", "get_template", "(", "'cover'", ")", "tree", "=", "parse_string", "(", "super", "(", "EpubCoverHtml", ",", "self", ")", ".", "get_content", "(", ")", ")...
Returns content for cover page as HTML string. Content will be of type 'str' (Python 2) or 'bytes' (Python 3). :Returns: Returns content of this document.
[ "Returns", "content", "for", "cover", "page", "as", "HTML", "string", ".", "Content", "will", "be", "of", "type", "str", "(", "Python", "2", ")", "or", "bytes", "(", "Python", "3", ")", "." ]
python
train
32.142857
abn/cafeteria
cafeteria/datastructs/dict.py
https://github.com/abn/cafeteria/blob/0a2efb0529484d6da08568f4364daff77f734dfd/cafeteria/datastructs/dict.py#L51-L63
def replace(self, key, value): """ Convenience method provided as a way to replace a value mapped by a key.This is required since a MergingDict always merges via assignment of item/attribute. :param key: Attribute name or item key to replace rvalue for. :type key: object...
[ "def", "replace", "(", "self", ",", "key", ",", "value", ")", ":", "super", "(", "MergingDict", ",", "self", ")", ".", "__setitem__", "(", "key", ",", "value", ")" ]
Convenience method provided as a way to replace a value mapped by a key.This is required since a MergingDict always merges via assignment of item/attribute. :param key: Attribute name or item key to replace rvalue for. :type key: object :param value: The new value to assign. ...
[ "Convenience", "method", "provided", "as", "a", "way", "to", "replace", "a", "value", "mapped", "by", "a", "key", ".", "This", "is", "required", "since", "a", "MergingDict", "always", "merges", "via", "assignment", "of", "item", "/", "attribute", "." ]
python
train
36.076923
ktbyers/netmiko
netmiko/netapp/netapp_cdot_ssh.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/netapp/netapp_cdot_ssh.py#L7-L11
def session_preparation(self): """Prepare the session after the connection has been established.""" self.set_base_prompt() cmd = self.RETURN + "rows 0" + self.RETURN self.disable_paging(command=cmd)
[ "def", "session_preparation", "(", "self", ")", ":", "self", ".", "set_base_prompt", "(", ")", "cmd", "=", "self", ".", "RETURN", "+", "\"rows 0\"", "+", "self", ".", "RETURN", "self", ".", "disable_paging", "(", "command", "=", "cmd", ")" ]
Prepare the session after the connection has been established.
[ "Prepare", "the", "session", "after", "the", "connection", "has", "been", "established", "." ]
python
train
45.2
dropbox/stone
example/backend/unstone/unstone.stoneg.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/example/backend/unstone/unstone.stoneg.py#L41-L84
def generate_data_type(self, data_type): """Output a data type definition (a struct or union).""" if isinstance(data_type, Struct): # Output a struct definition. self.emit('') self.emit('struct %s' % data_type.name) with self.indent(): if d...
[ "def", "generate_data_type", "(", "self", ",", "data_type", ")", ":", "if", "isinstance", "(", "data_type", ",", "Struct", ")", ":", "# Output a struct definition.", "self", ".", "emit", "(", "''", ")", "self", ".", "emit", "(", "'struct %s'", "%", "data_typ...
Output a data type definition (a struct or union).
[ "Output", "a", "data", "type", "definition", "(", "a", "struct", "or", "union", ")", "." ]
python
train
47.772727
evocell/rabifier
rabifier/utils.py
https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/utils.py#L124-L138
def merge_files(sources, destination): """Copy content of multiple files into a single file. :param list(str) sources: source file names (paths) :param str destination: destination file name (path) :return: """ with open(destination, 'w') as hout: for f in sources: if os.pa...
[ "def", "merge_files", "(", "sources", ",", "destination", ")", ":", "with", "open", "(", "destination", ",", "'w'", ")", "as", "hout", ":", "for", "f", "in", "sources", ":", "if", "os", ".", "path", ".", "exists", "(", "f", ")", ":", "with", "open"...
Copy content of multiple files into a single file. :param list(str) sources: source file names (paths) :param str destination: destination file name (path) :return:
[ "Copy", "content", "of", "multiple", "files", "into", "a", "single", "file", "." ]
python
train
32.533333
jreese/tasky
tasky/loop.py
https://github.com/jreese/tasky/blob/681f4e5a9a60a0eb838b89f320309cfb45a56242/tasky/loop.py#L134-L139
async def execute(self, fn, *args, **kwargs) -> None: '''Execute an arbitrary function outside the event loop using a shared Executor.''' fn = functools.partial(fn, *args, **kwargs) return await self.loop.run_in_executor(self.executor, fn)
[ "async", "def", "execute", "(", "self", ",", "fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "None", ":", "fn", "=", "functools", ".", "partial", "(", "fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "await", "self", ...
Execute an arbitrary function outside the event loop using a shared Executor.
[ "Execute", "an", "arbitrary", "function", "outside", "the", "event", "loop", "using", "a", "shared", "Executor", "." ]
python
train
44.5
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/jar.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/jar.py#L41-L70
def jarSources(target, source, env, for_signature): """Only include sources that are not a manifest file.""" try: env['JARCHDIR'] except KeyError: jarchdir_set = False else: jarchdir_set = True jarchdir = env.subst('$JARCHDIR', target=target, source=source) if jar...
[ "def", "jarSources", "(", "target", ",", "source", ",", "env", ",", "for_signature", ")", ":", "try", ":", "env", "[", "'JARCHDIR'", "]", "except", "KeyError", ":", "jarchdir_set", "=", "False", "else", ":", "jarchdir_set", "=", "True", "jarchdir", "=", ...
Only include sources that are not a manifest file.
[ "Only", "include", "sources", "that", "are", "not", "a", "manifest", "file", "." ]
python
train
34.566667
openego/ding0
ding0/grid/mv_grid/models/models.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/grid/mv_grid/models/models.py#L208-L231
def insert(self, nodes, pos): # TODO: check docstring """Inserts all nodes from `nodes` list into this route at position `pos` Parameters ---------- nodes : type Desc pos : type Desc """ node_list = [] ...
[ "def", "insert", "(", "self", ",", "nodes", ",", "pos", ")", ":", "# TODO: check docstring", "node_list", "=", "[", "]", "nodes_demand", "=", "0", "for", "node", "in", "[", "node", "for", "node", "in", "nodes", "]", ":", "if", "node", ".", "_allocation...
Inserts all nodes from `nodes` list into this route at position `pos` Parameters ---------- nodes : type Desc pos : type Desc
[ "Inserts", "all", "nodes", "from", "nodes", "list", "into", "this", "route", "at", "position", "pos", "Parameters", "----------", "nodes", ":", "type", "Desc", "pos", ":", "type", "Desc" ]
python
train
28.583333
iotile/coretools
iotilecore/iotile/core/hw/transport/virtualadapter.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/virtualadapter.py#L23-L42
def stream(self, report, callback=None): """Queue data for streaming Args: report (IOTileReport): A report object to stream to a client callback (callable): An optional callback that will be called with a bool value of True when this report actually gets streamed...
[ "def", "stream", "(", "self", ",", "report", ",", "callback", "=", "None", ")", ":", "conn_id", "=", "self", ".", "_find_connection", "(", "self", ".", "conn_string", ")", "if", "isinstance", "(", "report", ",", "BroadcastReport", ")", ":", "self", ".", ...
Queue data for streaming Args: report (IOTileReport): A report object to stream to a client callback (callable): An optional callback that will be called with a bool value of True when this report actually gets streamed. If the client disconnects and the ...
[ "Queue", "data", "for", "streaming" ]
python
train
43.3
openstack/networking-arista
networking_arista/ml2/mechanism_arista.py
https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L150-L157
def create_port(self, port): """Enqueue port create""" instance_type = self.get_instance_type(port) if not instance_type: return port_type = instance_type + a_const.PORT_SUFFIX p_res = MechResource(port['id'], port_type, a_const.CREATE) self.provision_queue.pu...
[ "def", "create_port", "(", "self", ",", "port", ")", ":", "instance_type", "=", "self", ".", "get_instance_type", "(", "port", ")", "if", "not", "instance_type", ":", "return", "port_type", "=", "instance_type", "+", "a_const", ".", "PORT_SUFFIX", "p_res", "...
Enqueue port create
[ "Enqueue", "port", "create" ]
python
train
40.125
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/detect.py#L455-L493
def _buffer_ini(data, sample_rate): """ Initializes the buffer with eight 1s intervals ---------- Parameters ---------- data : ndarray Pre-processed ECG signal samples. sample_rate : int Sampling rate at which the acquisition took place. Returns ------- rr_buffe...
[ "def", "_buffer_ini", "(", "data", ",", "sample_rate", ")", ":", "rr_buffer", "=", "[", "1", "]", "*", "8", "spk1", "=", "max", "(", "data", "[", "sample_rate", ":", "2", "*", "sample_rate", "]", ")", "npk1", "=", "0", "threshold", "=", "_buffer_upda...
Initializes the buffer with eight 1s intervals ---------- Parameters ---------- data : ndarray Pre-processed ECG signal samples. sample_rate : int Sampling rate at which the acquisition took place. Returns ------- rr_buffer : list Data structure that stores eigh...
[ "Initializes", "the", "buffer", "with", "eight", "1s", "intervals" ]
python
train
31.948718
angr/angr
angr/concretization_strategies/__init__.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/concretization_strategies/__init__.py#L51-L57
def concretize(self, memory, addr): """ Concretizes the address into a list of values. If this strategy cannot handle this address, returns None. """ if self._filter is None or self._filter(memory, addr): return self._concretize(memory, addr)
[ "def", "concretize", "(", "self", ",", "memory", ",", "addr", ")", ":", "if", "self", ".", "_filter", "is", "None", "or", "self", ".", "_filter", "(", "memory", ",", "addr", ")", ":", "return", "self", ".", "_concretize", "(", "memory", ",", "addr", ...
Concretizes the address into a list of values. If this strategy cannot handle this address, returns None.
[ "Concretizes", "the", "address", "into", "a", "list", "of", "values", ".", "If", "this", "strategy", "cannot", "handle", "this", "address", "returns", "None", "." ]
python
train
41.142857
gmr/tinman
tinman/handlers/base.py
https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L135-L143
def prepare(self): """Prepare the incoming request, checking to see the request is sending JSON content in the request body. If so, the content is decoded and assigned to the json_arguments attribute. """ super(RequestHandler, self).prepare() if self.request.headers.get(...
[ "def", "prepare", "(", "self", ")", ":", "super", "(", "RequestHandler", ",", "self", ")", ".", "prepare", "(", ")", "if", "self", ".", "request", ".", "headers", ".", "get", "(", "'content-type'", ",", "''", ")", ".", "startswith", "(", "self", ".",...
Prepare the incoming request, checking to see the request is sending JSON content in the request body. If so, the content is decoded and assigned to the json_arguments attribute.
[ "Prepare", "the", "incoming", "request", "checking", "to", "see", "the", "request", "is", "sending", "JSON", "content", "in", "the", "request", "body", ".", "If", "so", "the", "content", "is", "decoded", "and", "assigned", "to", "the", "json_arguments", "att...
python
train
47.111111
saltstack/salt
salt/modules/dockermod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockermod.py#L1012-L1248
def compare_container_networks(first, second): ''' .. versionadded:: 2018.3.0 Returns the differences between two containers' networks. When a network is only present one of the two containers, that network's diff will simply be represented with ``True`` for the side of the diff in which the networ...
[ "def", "compare_container_networks", "(", "first", ",", "second", ")", ":", "def", "_get_nets", "(", "data", ")", ":", "return", "data", ".", "get", "(", "'NetworkSettings'", ",", "{", "}", ")", ".", "get", "(", "'Networks'", ",", "{", "}", ")", "compa...
.. versionadded:: 2018.3.0 Returns the differences between two containers' networks. When a network is only present one of the two containers, that network's diff will simply be represented with ``True`` for the side of the diff in which the network is present) and ``False`` for the side of the diff in...
[ "..", "versionadded", "::", "2018", ".", "3", ".", "0" ]
python
train
41.599156
Capitains/MyCapytain
MyCapytain/resources/texts/local/capitains/cts.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/texts/local/capitains/cts.py#L33-L46
def _make_passage_kwargs(urn, reference): """ Little helper used by CapitainsCtsPassage here to comply with parents args :param urn: URN String :param reference: Reference String :return: Dictionary of arguments with URN based on identifier and reference """ kwargs = {} if urn is not None: ...
[ "def", "_make_passage_kwargs", "(", "urn", ",", "reference", ")", ":", "kwargs", "=", "{", "}", "if", "urn", "is", "not", "None", ":", "if", "reference", "is", "not", "None", ":", "kwargs", "[", "\"urn\"", "]", "=", "URN", "(", "\"{}:{}\"", ".", "for...
Little helper used by CapitainsCtsPassage here to comply with parents args :param urn: URN String :param reference: Reference String :return: Dictionary of arguments with URN based on identifier and reference
[ "Little", "helper", "used", "by", "CapitainsCtsPassage", "here", "to", "comply", "with", "parents", "args" ]
python
train
34.714286
saltstack/salt
salt/modules/dockercompose.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dockercompose.py#L382-L397
def __dump_compose_file(path, compose_result, success_msg, already_existed): ''' Utility function to dump the compose result to a file. :param path: :param compose_result: :param success_msg: the message to give upon success :return: ''' ret = __dump_docker_compose(path, ...
[ "def", "__dump_compose_file", "(", "path", ",", "compose_result", ",", "success_msg", ",", "already_existed", ")", ":", "ret", "=", "__dump_docker_compose", "(", "path", ",", "compose_result", "[", "'compose_content'", "]", ",", "already_existed", ")", "if", "isin...
Utility function to dump the compose result to a file. :param path: :param compose_result: :param success_msg: the message to give upon success :return:
[ "Utility", "function", "to", "dump", "the", "compose", "result", "to", "a", "file", "." ]
python
train
36.125
MrKriss/vigilance
vigilance/decorators.py
https://github.com/MrKriss/vigilance/blob/2946b09f524c042c12d796f111f287866e7a3c67/vigilance/decorators.py#L54-L90
def returns(*checkers_args): """ Create a decorator for validating function return values. Parameters ---------- checkers_args: positional arguments A single functions to apply to the output of the decorated function. If a tuple is returned by the decorated function, multiple function ...
[ "def", "returns", "(", "*", "checkers_args", ")", ":", "@", "decorator", "def", "run_checkers", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "type", "(...
Create a decorator for validating function return values. Parameters ---------- checkers_args: positional arguments A single functions to apply to the output of the decorated function. If a tuple is returned by the decorated function, multiple function can be listed and are assumed to matc...
[ "Create", "a", "decorator", "for", "validating", "function", "return", "values", "." ]
python
train
31.189189
ewiger/mlab
src/mlab/awmstools.py
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L1097-L1111
def timeCall(*funcAndArgs, **kwargs): r"""Return the time (in ms) it takes to call a function (the first argument) with the remaining arguments and `kwargs`. Examples: To find out how long ``func('foo', spam=1)`` takes to execute, do: ``timeCall(func, foo, spam=1)`` """ func, args = func...
[ "def", "timeCall", "(", "*", "funcAndArgs", ",", "*", "*", "kwargs", ")", ":", "func", ",", "args", "=", "funcAndArgs", "[", "0", "]", ",", "funcAndArgs", "[", "1", ":", "]", "start", "=", "time", ".", "time", "(", ")", "func", "(", "*", "args", ...
r"""Return the time (in ms) it takes to call a function (the first argument) with the remaining arguments and `kwargs`. Examples: To find out how long ``func('foo', spam=1)`` takes to execute, do: ``timeCall(func, foo, spam=1)``
[ "r", "Return", "the", "time", "(", "in", "ms", ")", "it", "takes", "to", "call", "a", "function", "(", "the", "first", "argument", ")", "with", "the", "remaining", "arguments", "and", "kwargs", "." ]
python
train
27.6
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Builder.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Builder.py#L812-L832
def subst_src_suffixes(self, env): """ The suffix list may contain construction variable expansions, so we have to evaluate the individual strings. To avoid doing this over and over, we memoize the results for each construction environment. """ memo_key = id(env)...
[ "def", "subst_src_suffixes", "(", "self", ",", "env", ")", ":", "memo_key", "=", "id", "(", "env", ")", "try", ":", "memo_dict", "=", "self", ".", "_memo", "[", "'subst_src_suffixes'", "]", "except", "KeyError", ":", "memo_dict", "=", "{", "}", "self", ...
The suffix list may contain construction variable expansions, so we have to evaluate the individual strings. To avoid doing this over and over, we memoize the results for each construction environment.
[ "The", "suffix", "list", "may", "contain", "construction", "variable", "expansions", "so", "we", "have", "to", "evaluate", "the", "individual", "strings", ".", "To", "avoid", "doing", "this", "over", "and", "over", "we", "memoize", "the", "results", "for", "...
python
train
34.52381
moderngl/moderngl
examples/window/glfw/window.py
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/glfw/window.py#L121-L136
def mouse_button_callback(self, window, button, action, mods): """ Handle mouse button events and forward them to the example """ # Offset button index by 1 to make it match the other libraries button += 1 # Support left and right mouse button for now if bu...
[ "def", "mouse_button_callback", "(", "self", ",", "window", ",", "button", ",", "action", ",", "mods", ")", ":", "# Offset button index by 1 to make it match the other libraries\r", "button", "+=", "1", "# Support left and right mouse button for now\r", "if", "button", "not...
Handle mouse button events and forward them to the example
[ "Handle", "mouse", "button", "events", "and", "forward", "them", "to", "the", "example" ]
python
train
36.375
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L20400-L20428
def wait_for_array(self, wait_for, timeout_ms): """Waits for one or more events to happen. Scriptable version of :py:func:`wait_for` . in wait_for of type :class:`GuestSessionWaitForFlag` Specifies what to wait for; see :py:class:`GuestSessionWaitForFlag` for more infor...
[ "def", "wait_for_array", "(", "self", ",", "wait_for", ",", "timeout_ms", ")", ":", "if", "not", "isinstance", "(", "wait_for", ",", "list", ")", ":", "raise", "TypeError", "(", "\"wait_for can only be an instance of type list\"", ")", "for", "a", "in", "wait_fo...
Waits for one or more events to happen. Scriptable version of :py:func:`wait_for` . in wait_for of type :class:`GuestSessionWaitForFlag` Specifies what to wait for; see :py:class:`GuestSessionWaitForFlag` for more information. in timeout_ms of type int Time...
[ "Waits", "for", "one", "or", "more", "events", "to", "happen", ".", "Scriptable", "version", "of", ":", "py", ":", "func", ":", "wait_for", "." ]
python
train
43.724138
GoogleCloudPlatform/cloud-debug-python
src/googleclouddebugger/gcp_hub_client.py
https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/gcp_hub_client.py#L180-L218
def SetupAuth(self, project_id=None, project_number=None, service_account_json_file=None): """Sets up authentication with Google APIs. This will use the credentials from service_account_json_file if provided, falling back to application default credentials. ...
[ "def", "SetupAuth", "(", "self", ",", "project_id", "=", "None", ",", "project_number", "=", "None", ",", "service_account_json_file", "=", "None", ")", ":", "if", "service_account_json_file", ":", "self", ".", "_credentials", "=", "(", "service_account", ".", ...
Sets up authentication with Google APIs. This will use the credentials from service_account_json_file if provided, falling back to application default credentials. See https://cloud.google.com/docs/authentication/production. Args: project_id: GCP project ID (e.g. myproject). If not provided, wil...
[ "Sets", "up", "authentication", "with", "Google", "APIs", "." ]
python
train
41.897436
blackecho/Deep-Learning-TensorFlow
yadlt/models/boltzmann/rbm.py
https://github.com/blackecho/Deep-Learning-TensorFlow/blob/ddeb1f2848da7b7bee166ad2152b4afc46bb2086/yadlt/models/boltzmann/rbm.py#L101-L112
def _create_feed_dict(self, data): """Create the dictionary of data to feed to tf session during training. :param data: training/validation set batch :return: dictionary(self.input_data: data, self.hrand: random_uniform, self.vrand: random_uniform) """ ...
[ "def", "_create_feed_dict", "(", "self", ",", "data", ")", ":", "return", "{", "self", ".", "input_data", ":", "data", ",", "self", ".", "hrand", ":", "np", ".", "random", ".", "rand", "(", "data", ".", "shape", "[", "0", "]", ",", "self", ".", "...
Create the dictionary of data to feed to tf session during training. :param data: training/validation set batch :return: dictionary(self.input_data: data, self.hrand: random_uniform, self.vrand: random_uniform)
[ "Create", "the", "dictionary", "of", "data", "to", "feed", "to", "tf", "session", "during", "training", "." ]
python
train
42.083333
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_command_line_handling.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_command_line_handling.py#L80-L92
def setup_to_argv(setup): ''' :param dict setup: A dict previously gotten from process_command_line. :note: does not handle --file nor --DEBUG. ''' ret = [get_pydevd_file()] for handler in ACCEPTED_ARG_HANDLERS: if handler.arg_name in setup: handler.to_argv(ret, set...
[ "def", "setup_to_argv", "(", "setup", ")", ":", "ret", "=", "[", "get_pydevd_file", "(", ")", "]", "for", "handler", "in", "ACCEPTED_ARG_HANDLERS", ":", "if", "handler", ".", "arg_name", "in", "setup", ":", "handler", ".", "to_argv", "(", "ret", ",", "se...
:param dict setup: A dict previously gotten from process_command_line. :note: does not handle --file nor --DEBUG.
[ ":", "param", "dict", "setup", ":", "A", "dict", "previously", "gotten", "from", "process_command_line", "." ]
python
train
25.076923
aloetesting/aloe_webdriver
aloe_webdriver/__init__.py
https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/__init__.py#L152-L161
def should_see_link_text(self, link_text, link_url): """Assert a link with the provided text points to the provided URL.""" elements = ElementSelector( world.browser, str('//a[@href="%s"][./text()="%s"]' % (link_url, link_text)), filter_displayed=True, ) if not elements: ...
[ "def", "should_see_link_text", "(", "self", ",", "link_text", ",", "link_url", ")", ":", "elements", "=", "ElementSelector", "(", "world", ".", "browser", ",", "str", "(", "'//a[@href=\"%s\"][./text()=\"%s\"]'", "%", "(", "link_url", ",", "link_text", ")", ")", ...
Assert a link with the provided text points to the provided URL.
[ "Assert", "a", "link", "with", "the", "provided", "text", "points", "to", "the", "provided", "URL", "." ]
python
train
36
drongo-framework/drongo
drongo/response.py
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/response.py#L120-L129
def set_redirect(self, url, status=HttpStatusCodes.HTTP_303): """Helper method to set a redirect response. Args: url (:obj:`str`): URL to redirect to status (:obj:`str`, optional): Status code of the response """ self.set_status(status) self.set_content('...
[ "def", "set_redirect", "(", "self", ",", "url", ",", "status", "=", "HttpStatusCodes", ".", "HTTP_303", ")", ":", "self", ".", "set_status", "(", "status", ")", "self", ".", "set_content", "(", "''", ")", "self", ".", "set_header", "(", "HttpResponseHeader...
Helper method to set a redirect response. Args: url (:obj:`str`): URL to redirect to status (:obj:`str`, optional): Status code of the response
[ "Helper", "method", "to", "set", "a", "redirect", "response", "." ]
python
train
37.2
Opentrons/opentrons
api/src/opentrons/drivers/rpi_drivers/gpio.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/drivers/rpi_drivers/gpio.py#L87-L99
def _read_value(path): """ Reads value of specified path. :param path: A valid system path """ read_value = 0 if not os.path.exists(path): # Path will generally only exist on a Raspberry Pi pass else: with open(path) as f: read_value = int(f.read()) re...
[ "def", "_read_value", "(", "path", ")", ":", "read_value", "=", "0", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "# Path will generally only exist on a Raspberry Pi", "pass", "else", ":", "with", "open", "(", "path", ")", "as", "f...
Reads value of specified path. :param path: A valid system path
[ "Reads", "value", "of", "specified", "path", ".", ":", "param", "path", ":", "A", "valid", "system", "path" ]
python
train
24.846154
MarcoFavorito/pythomata
pythomata/dfa.py
https://github.com/MarcoFavorito/pythomata/blob/4739c620008b8fe50583eecb97f9bfd7f006b95c/pythomata/dfa.py#L284-L313
def levels_to_accepting_states(self) -> dict: """Return a dict from states to level, i.e. the number of steps to reach any accepting state. level = -1 if the state cannot reach any accepting state""" res = {accepting_state: 0 for accepting_state in self._accepting_states} level = 0 ...
[ "def", "levels_to_accepting_states", "(", "self", ")", "->", "dict", ":", "res", "=", "{", "accepting_state", ":", "0", "for", "accepting_state", "in", "self", ".", "_accepting_states", "}", "level", "=", "0", "# least fixpoint", "z_current", ",", "z_next", "=...
Return a dict from states to level, i.e. the number of steps to reach any accepting state. level = -1 if the state cannot reach any accepting state
[ "Return", "a", "dict", "from", "states", "to", "level", "i", ".", "e", ".", "the", "number", "of", "steps", "to", "reach", "any", "accepting", "state", ".", "level", "=", "-", "1", "if", "the", "state", "cannot", "reach", "any", "accepting", "state" ]
python
train
37.3
pysathq/pysat
pysat/solvers.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L2595-L2607
def add_clause(self, clause, no_return=True): """ Add a new clause to solver's internal formula. """ if self.maplesat: res = pysolvers.maplesat_add_cl(self.maplesat, clause) if res == False: self.status = False if not no_return: ...
[ "def", "add_clause", "(", "self", ",", "clause", ",", "no_return", "=", "True", ")", ":", "if", "self", ".", "maplesat", ":", "res", "=", "pysolvers", ".", "maplesat_add_cl", "(", "self", ".", "maplesat", ",", "clause", ")", "if", "res", "==", "False",...
Add a new clause to solver's internal formula.
[ "Add", "a", "new", "clause", "to", "solver", "s", "internal", "formula", "." ]
python
train
25.692308
tensorpack/tensorpack
tensorpack/tfutils/varmanip.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/tfutils/varmanip.py#L166-L193
def get_checkpoint_path(model_path): """ Work around TF problems in checkpoint path handling. Args: model_path: a user-input path Returns: str: the argument that can be passed to NewCheckpointReader """ if os.path.basename(model_path) == model_path: model_path = os.path....
[ "def", "get_checkpoint_path", "(", "model_path", ")", ":", "if", "os", ".", "path", ".", "basename", "(", "model_path", ")", "==", "model_path", ":", "model_path", "=", "os", ".", "path", ".", "join", "(", "'.'", ",", "model_path", ")", "# avoid #4921 and ...
Work around TF problems in checkpoint path handling. Args: model_path: a user-input path Returns: str: the argument that can be passed to NewCheckpointReader
[ "Work", "around", "TF", "problems", "in", "checkpoint", "path", "handling", "." ]
python
train
39.5
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/tools/gcs_file_seg_reader.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/tools/gcs_file_seg_reader.py#L115-L132
def _read_from_seg(self, n): """Read from current seg. Args: n: max number of bytes to read. Returns: valid bytes from the current seg. "" if no more is left. """ result = self._seg.read(size=n) if result == "": return result offset = self._seg.tell() if offset > self...
[ "def", "_read_from_seg", "(", "self", ",", "n", ")", ":", "result", "=", "self", ".", "_seg", ".", "read", "(", "size", "=", "n", ")", "if", "result", "==", "\"\"", ":", "return", "result", "offset", "=", "self", ".", "_seg", ".", "tell", "(", ")...
Read from current seg. Args: n: max number of bytes to read. Returns: valid bytes from the current seg. "" if no more is left.
[ "Read", "from", "current", "seg", "." ]
python
train
25.055556
ska-sa/montblanc
montblanc/examples/standalone.py
https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/examples/standalone.py#L69-L81
def uvw(self, context): """ Supply UVW antenna coordinates to montblanc """ # Shape (ntime, na, 3) (lt, ut), (la, ua), (l, u) = context.array_extents(context.name) # Create empty UVW coordinates data = np.empty(context.shape, context.dtype) data[:,:,0] = np.arange(la+1,...
[ "def", "uvw", "(", "self", ",", "context", ")", ":", "# Shape (ntime, na, 3)", "(", "lt", ",", "ut", ")", ",", "(", "la", ",", "ua", ")", ",", "(", "l", ",", "u", ")", "=", "context", ".", "array_extents", "(", "context", ".", "name", ")", "# Cre...
Supply UVW antenna coordinates to montblanc
[ "Supply", "UVW", "antenna", "coordinates", "to", "montblanc" ]
python
train
36
twilio/twilio-python
twilio/base/deserialize.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/base/deserialize.py#L10-L20
def iso8601_date(s): """ Parses an ISO 8601 date string and returns a UTC date object or the string if the parsing failed. :param s: ISO 8601-formatted date string (2015-01-25) :return: """ try: return datetime.datetime.strptime(s, ISO8601_DATE_FORMAT).replace(tzinfo=pytz.utc).date()...
[ "def", "iso8601_date", "(", "s", ")", ":", "try", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "s", ",", "ISO8601_DATE_FORMAT", ")", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", ".", "date", "(", ")", "except", "(...
Parses an ISO 8601 date string and returns a UTC date object or the string if the parsing failed. :param s: ISO 8601-formatted date string (2015-01-25) :return:
[ "Parses", "an", "ISO", "8601", "date", "string", "and", "returns", "a", "UTC", "date", "object", "or", "the", "string", "if", "the", "parsing", "failed", ".", ":", "param", "s", ":", "ISO", "8601", "-", "formatted", "date", "string", "(", "2015", "-", ...
python
train
33
NicolasLM/spinach
spinach/brokers/redis.py
https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/redis.py#L62-L74
def _load_script(self, filename: str) -> Script: """Load a Lua script. Read the Lua script file to generate its Script object. If the script starts with a magic string, add it to the list of scripts requiring an idempotency token to execute. """ with open(path.join(here,...
[ "def", "_load_script", "(", "self", ",", "filename", ":", "str", ")", "->", "Script", ":", "with", "open", "(", "path", ".", "join", "(", "here", ",", "'redis_scripts'", ",", "filename", ")", ",", "mode", "=", "'rb'", ")", "as", "f", ":", "script_dat...
Load a Lua script. Read the Lua script file to generate its Script object. If the script starts with a magic string, add it to the list of scripts requiring an idempotency token to execute.
[ "Load", "a", "Lua", "script", "." ]
python
train
45.076923
buildbot/buildbot
worker/buildbot_worker/base.py
https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/worker/buildbot_worker/base.py#L126-L156
def remote_startCommand(self, stepref, stepId, command, args): """ This gets invoked by L{buildbot.process.step.RemoteCommand.start}, as part of various master-side BuildSteps, to start various commands that actually do the build. I return nothing. Eventually I will call .command...
[ "def", "remote_startCommand", "(", "self", ",", "stepref", ",", "stepId", ",", "command", ",", "args", ")", ":", "stepId", "=", "decode", "(", "stepId", ")", "command", "=", "decode", "(", "command", ")", "args", "=", "decode", "(", "args", ")", "self"...
This gets invoked by L{buildbot.process.step.RemoteCommand.start}, as part of various master-side BuildSteps, to start various commands that actually do the build. I return nothing. Eventually I will call .commandComplete() to notify the master-side RemoteCommand that I'm done.
[ "This", "gets", "invoked", "by", "L", "{", "buildbot", ".", "process", ".", "step", ".", "RemoteCommand", ".", "start", "}", "as", "part", "of", "various", "master", "-", "side", "BuildSteps", "to", "start", "various", "commands", "that", "actually", "do",...
python
train
36.645161
etcher-be/elib_miz
elib_miz/mission.py
https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L639-L646
def farps(self) -> typing.Iterator['Static']: """ Returns: generator over all FARPs in this coalition """ for static in self.statics: if static.static_is_farp: yield static
[ "def", "farps", "(", "self", ")", "->", "typing", ".", "Iterator", "[", "'Static'", "]", ":", "for", "static", "in", "self", ".", "statics", ":", "if", "static", ".", "static_is_farp", ":", "yield", "static" ]
Returns: generator over all FARPs in this coalition
[ "Returns", ":", "generator", "over", "all", "FARPs", "in", "this", "coalition" ]
python
train
28.25
rocky/python-uncompyle6
uncompyle6/show.py
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/show.py#L35-L54
def maybe_show_tree(walker, ast): """ Show the ast based on the showast flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the parse tree is written to sys.stdout or not. (It is also to pass a...
[ "def", "maybe_show_tree", "(", "walker", ",", "ast", ")", ":", "if", "walker", ".", "showast", ":", "if", "hasattr", "(", "walker", ".", "showast", ",", "'write'", ")", ":", "stream", "=", "walker", ".", "showast", "else", ":", "stream", "=", "sys", ...
Show the ast based on the showast flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the parse tree is written to sys.stdout or not. (It is also to pass a file like object, into ...
[ "Show", "the", "ast", "based", "on", "the", "showast", "flag", "(", "or", "file", "object", ")", "writing", "to", "the", "appropriate", "stream", "depending", "on", "the", "type", "of", "the", "flag", "." ]
python
train
36.4
Jajcus/pyxmpp2
pyxmpp2/ext/version.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/version.py#L168-L173
def _os_name_factory(settings): """Factory for the :r:`software_os setting` default. """ # pylint: disable-msg=W0613,W0142 return u"{0} {1} {2}".format(platform.system(), platform.release(), platform.machine())
[ "def", "_os_name_factory", "(", "settings", ")", ":", "# pylint: disable-msg=W0613,W0142", "return", "u\"{0} {1} {2}\"", ".", "format", "(", "platform", ".", "system", "(", ")", ",", "platform", ".", "release", "(", ")", ",", "platform", ".", "machine", "(", "...
Factory for the :r:`software_os setting` default.
[ "Factory", "for", "the", ":", "r", ":", "software_os", "setting", "default", "." ]
python
valid
46.166667
hobson/pug-ann
pug/ann/data/weather.py
https://github.com/hobson/pug-ann/blob/8a4d7103a744d15b4a737fc0f9a84c823973e0ec/pug/ann/data/weather.py#L110-L142
def api(feature='conditions', city='Portland', state='OR', key=None): """Use the wunderground API to get current conditions instead of scraping Please be kind and use your own key (they're FREE!): http://www.wunderground.com/weather/api/d/login.html References: http://www.wunderground.com/weat...
[ "def", "api", "(", "feature", "=", "'conditions'", ",", "city", "=", "'Portland'", ",", "state", "=", "'OR'", ",", "key", "=", "None", ")", ":", "features", "=", "(", "'alerts astronomy conditions currenthurricane forecast forecast10day geolookup history hourly hourly10...
Use the wunderground API to get current conditions instead of scraping Please be kind and use your own key (they're FREE!): http://www.wunderground.com/weather/api/d/login.html References: http://www.wunderground.com/weather/api/d/terms.html Examples: >>> api('hurric', 'Boise', 'ID') ...
[ "Use", "the", "wunderground", "API", "to", "get", "current", "conditions", "instead", "of", "scraping" ]
python
train
52.636364
gwastro/pycbc
pycbc/fft/fftw_pruned.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/fft/fftw_pruned.py#L73-L103
def plan_first_phase(N1, N2): """ Create a plan for the first stage of the pruned FFT operation. (Alex to provide a write up with more details.) Parameters ----------- N1 : int Number of rows. N2 : int Number of columns. Returns -------- plan : FFTWF plan ...
[ "def", "plan_first_phase", "(", "N1", ",", "N2", ")", ":", "N", "=", "N1", "*", "N2", "vin", "=", "pycbc", ".", "types", ".", "zeros", "(", "N", ",", "dtype", "=", "numpy", ".", "complex64", ")", "vout", "=", "pycbc", ".", "types", ".", "zeros", ...
Create a plan for the first stage of the pruned FFT operation. (Alex to provide a write up with more details.) Parameters ----------- N1 : int Number of rows. N2 : int Number of columns. Returns -------- plan : FFTWF plan The plan for performing the first phase ...
[ "Create", "a", "plan", "for", "the", "first", "stage", "of", "the", "pruned", "FFT", "operation", ".", "(", "Alex", "to", "provide", "a", "write", "up", "with", "more", "details", ".", ")" ]
python
train
32.064516
sdispater/pendulum
pendulum/datetime.py
https://github.com/sdispater/pendulum/blob/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e/pendulum/datetime.py#L574-L586
def is_birthday(self, dt=None): """ Check if its the birthday. Compares the date/month values of the two dates. :rtype: bool """ if dt is None: dt = self.now(self.tz) instance = pendulum.instance(dt) return (self.month, self.day) == (instanc...
[ "def", "is_birthday", "(", "self", ",", "dt", "=", "None", ")", ":", "if", "dt", "is", "None", ":", "dt", "=", "self", ".", "now", "(", "self", ".", "tz", ")", "instance", "=", "pendulum", ".", "instance", "(", "dt", ")", "return", "(", "self", ...
Check if its the birthday. Compares the date/month values of the two dates. :rtype: bool
[ "Check", "if", "its", "the", "birthday", ".", "Compares", "the", "date", "/", "month", "values", "of", "the", "two", "dates", "." ]
python
train
25.384615
wavefrontHQ/python-client
wavefront_api_client/api/derived_metric_api.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/derived_metric_api.py#L1125-L1146
def update_derived_metric(self, id, **kwargs): # noqa: E501 """Update a specific derived metric definition # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.upd...
[ "def", "update_derived_metric", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "update...
Update a specific derived metric definition # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_derived_metric(id, async_req=True) >>> result = thread.get()...
[ "Update", "a", "specific", "derived", "metric", "definition", "#", "noqa", ":", "E501" ]
python
train
55.454545
estnltk/estnltk
estnltk/prettyprinter/terminalprettyprinter.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/prettyprinter/terminalprettyprinter.py#L257-L296
def _fix_overlapping_graphics( spansStartingFrom ): ''' Provides a fix for overlapping annotations that are formatted graphically (underlined or printed in non-default color). If two graphically formatted annotations overlap, and if one annotation, say A, ends within another an...
[ "def", "_fix_overlapping_graphics", "(", "spansStartingFrom", ")", ":", "for", "startIndex", "in", "sorted", "(", "spansStartingFrom", ".", "keys", "(", ")", ")", ":", "for", "span1", "in", "spansStartingFrom", "[", "startIndex", "]", ":", "# If the span is not gr...
Provides a fix for overlapping annotations that are formatted graphically (underlined or printed in non-default color). If two graphically formatted annotations overlap, and if one annotation, say A, ends within another annotation, say B, then ending of graphics of A also c...
[ "Provides", "a", "fix", "for", "overlapping", "annotations", "that", "are", "formatted", "graphically", "(", "underlined", "or", "printed", "in", "non", "-", "default", "color", ")", ".", "If", "two", "graphically", "formatted", "annotations", "overlap", "and", ...
python
train
58.6
WoLpH/python-statsd
statsd/client.py
https://github.com/WoLpH/python-statsd/blob/a757da04375c48d03d322246405b33382d37f03f/statsd/client.py#L80-L86
def get_counter(self, name=None): '''Shortcut for getting a :class:`~statsd.counter.Counter` instance :keyword name: See :func:`~statsd.client.Client.get_client` :type name: str ''' return self.get_client(name=name, class_=statsd.Counter)
[ "def", "get_counter", "(", "self", ",", "name", "=", "None", ")", ":", "return", "self", ".", "get_client", "(", "name", "=", "name", ",", "class_", "=", "statsd", ".", "Counter", ")" ]
Shortcut for getting a :class:`~statsd.counter.Counter` instance :keyword name: See :func:`~statsd.client.Client.get_client` :type name: str
[ "Shortcut", "for", "getting", "a", ":", "class", ":", "~statsd", ".", "counter", ".", "Counter", "instance" ]
python
train
39
bear/parsedatetime
parsedatetime/__init__.py
https://github.com/bear/parsedatetime/blob/830775dc5e36395622b41f12317f5e10c303d3a2/parsedatetime/__init__.py#L552-L683
def evalRanges(self, datetimeString, sourceTime=None): """ Evaluate the C{datetimeString} text and determine if it represents a date or time range. @type datetimeString: string @param datetimeString: datetime text to evaluate @type sourceTime: struct_time @...
[ "def", "evalRanges", "(", "self", ",", "datetimeString", ",", "sourceTime", "=", "None", ")", ":", "rangeFlag", "=", "retFlag", "=", "0", "startStr", "=", "endStr", "=", "''", "s", "=", "datetimeString", ".", "strip", "(", ")", ".", "lower", "(", ")", ...
Evaluate the C{datetimeString} text and determine if it represents a date or time range. @type datetimeString: string @param datetimeString: datetime text to evaluate @type sourceTime: struct_time @param sourceTime: C{struct_time} value to use as the base @rty...
[ "Evaluate", "the", "C", "{", "datetimeString", "}", "text", "and", "determine", "if", "it", "represents", "a", "date", "or", "time", "range", "." ]
python
train
34.212121
pypa/pipenv
pipenv/vendor/urllib3/util/ssl_.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L190-L210
def resolve_cert_reqs(candidate): """ Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_NONE`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbrevi...
[ "def", "resolve_cert_reqs", "(", "candidate", ")", ":", "if", "candidate", "is", "None", ":", "return", "CERT_NONE", "if", "isinstance", "(", "candidate", ",", "str", ")", ":", "res", "=", "getattr", "(", "ssl", ",", "candidate", ",", "None", ")", "if", ...
Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_NONE`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbreviation. (So you can specify `REQUIRED` inst...
[ "Resolves", "the", "argument", "to", "a", "numeric", "constant", "which", "can", "be", "passed", "to", "the", "wrap_socket", "function", "/", "method", "from", "the", "ssl", "module", ".", "Defaults", "to", ":", "data", ":", "ssl", ".", "CERT_NONE", ".", ...
python
train
36.142857
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L933-L963
def disconnect_relationship(cls, id, related_collection_name, request_json): """ Disconnect one or more relationship in a collection with cardinality 'Many'. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the mo...
[ "def", "disconnect_relationship", "(", "cls", ",", "id", ",", "related_collection_name", ",", "request_json", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")", "related_colle...
Disconnect one or more relationship in a collection with cardinality 'Many'. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is not the same as the node id :param related_collection_name: The name of the ...
[ "Disconnect", "one", "or", "more", "relationship", "in", "a", "collection", "with", "cardinality", "Many", "." ]
python
train
52.580645
vaexio/vaex
packages/vaex-core/vaex/__init__.py
https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L280-L317
def from_arrays(**arrays): """Create an in memory DataFrame from numpy arrays. Example >>> import vaex, numpy as np >>> x = np.arange(5) >>> y = x ** 2 >>> vaex.from_arrays(x=x, y=y) # x y 0 0 0 1 1 1 2 2 4 3 3 9 4 4 16 ...
[ "def", "from_arrays", "(", "*", "*", "arrays", ")", ":", "import", "numpy", "as", "np", "import", "six", "from", ".", "column", "import", "Column", "df", "=", "vaex", ".", "dataframe", ".", "DataFrameArrays", "(", "\"array\"", ")", "for", "name", ",", ...
Create an in memory DataFrame from numpy arrays. Example >>> import vaex, numpy as np >>> x = np.arange(5) >>> y = x ** 2 >>> vaex.from_arrays(x=x, y=y) # x y 0 0 0 1 1 1 2 2 4 3 3 9 4 4 16 >>> some_dict = {'x': x, 'y': y} ...
[ "Create", "an", "in", "memory", "DataFrame", "from", "numpy", "arrays", "." ]
python
test
24.394737
saulpw/visidata
visidata/vdtui.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/vdtui.py#L2788-L2794
def resolve_colors(self, colorstack): 'Returns the curses attribute for the colorstack, a list of color option names sorted highest-precedence color first.' attr = CursesAttr() for coloropt in colorstack: c = self.get_color(coloropt) attr = attr.update_attr(c) ret...
[ "def", "resolve_colors", "(", "self", ",", "colorstack", ")", ":", "attr", "=", "CursesAttr", "(", ")", "for", "coloropt", "in", "colorstack", ":", "c", "=", "self", ".", "get_color", "(", "coloropt", ")", "attr", "=", "attr", ".", "update_attr", "(", ...
Returns the curses attribute for the colorstack, a list of color option names sorted highest-precedence color first.
[ "Returns", "the", "curses", "attribute", "for", "the", "colorstack", "a", "list", "of", "color", "option", "names", "sorted", "highest", "-", "precedence", "color", "first", "." ]
python
train
46
kislyuk/aegea
aegea/packages/github3/users.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/users.py#L308-L322
def iter_org_events(self, org, number=-1, etag=None): """Iterate over events as they appear on the user's organization dashboard. You must be authenticated to view this. :param str org: (required), name of the organization :param int number: (optional), number of events to return. Defau...
[ "def", "iter_org_events", "(", "self", ",", "org", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "''", "if", "org", ":", "url", "=", "self", ".", "_build_url", "(", "'events'", ",", "'orgs'", ",", "org", ",", "base...
Iterate over events as they appear on the user's organization dashboard. You must be authenticated to view this. :param str org: (required), name of the organization :param int number: (optional), number of events to return. Default: -1 returns all available events :param st...
[ "Iterate", "over", "events", "as", "they", "appear", "on", "the", "user", "s", "organization", "dashboard", ".", "You", "must", "be", "authenticated", "to", "view", "this", "." ]
python
train
46.866667
acorg/dark-matter
dark/diamond/conversion.py
https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/diamond/conversion.py#L131-L227
def records(self): """ Parse the DIAMOND output and yield records. This will be used to read original DIAMOND output (either from stdin or from a file) to turn the DIAMOND results into Python dictionaries that will then be stored in our JSON format. @return: A generator ...
[ "def", "records", "(", "self", ")", ":", "with", "as_handle", "(", "self", ".", "_filename", ")", "as", "fp", ":", "previousQtitle", "=", "None", "subjectsSeen", "=", "{", "}", "record", "=", "{", "}", "for", "line", "in", "fp", ":", "line", "=", "...
Parse the DIAMOND output and yield records. This will be used to read original DIAMOND output (either from stdin or from a file) to turn the DIAMOND results into Python dictionaries that will then be stored in our JSON format. @return: A generator that produces C{dict}s containing 'alig...
[ "Parse", "the", "DIAMOND", "output", "and", "yield", "records", ".", "This", "will", "be", "used", "to", "read", "original", "DIAMOND", "output", "(", "either", "from", "stdin", "or", "from", "a", "file", ")", "to", "turn", "the", "DIAMOND", "results", "...
python
train
44.082474
materialsproject/pymatgen
pymatgen/phonon/plotter.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/phonon/plotter.py#L433-L462
def plot_compare(self, other_plotter): """ plot two band structure for comparison. One is in red the other in blue. The two band structures need to be defined on the same symmetry lines! and the distance between symmetry lines is the one of the band structure used to build the Ph...
[ "def", "plot_compare", "(", "self", ",", "other_plotter", ")", ":", "data_orig", "=", "self", ".", "bs_plot_data", "(", ")", "data", "=", "other_plotter", ".", "bs_plot_data", "(", ")", "if", "len", "(", "data_orig", "[", "'distances'", "]", ")", "!=", "...
plot two band structure for comparison. One is in red the other in blue. The two band structures need to be defined on the same symmetry lines! and the distance between symmetry lines is the one of the band structure used to build the PhononBSPlotter Args: another PhononBSPl...
[ "plot", "two", "band", "structure", "for", "comparison", ".", "One", "is", "in", "red", "the", "other", "in", "blue", ".", "The", "two", "band", "structures", "need", "to", "be", "defined", "on", "the", "same", "symmetry", "lines!", "and", "the", "distan...
python
train
35.5
onecodex/onecodex
onecodex/distance.py
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/distance.py#L75-L121
def unifrac(self, weighted=True, rank="auto"): """A beta diversity metric that takes into account the relative relatedness of community members. Weighted UniFrac looks at abundances, unweighted UniFrac looks at presence. Parameters ---------- weighted : `bool` Calcul...
[ "def", "unifrac", "(", "self", ",", "weighted", "=", "True", ",", "rank", "=", "\"auto\"", ")", ":", "# needs read counts, not relative abundances", "if", "self", ".", "_guess_normalized", "(", ")", ":", "raise", "OneCodexException", "(", "\"UniFrac requires unnorma...
A beta diversity metric that takes into account the relative relatedness of community members. Weighted UniFrac looks at abundances, unweighted UniFrac looks at presence. Parameters ---------- weighted : `bool` Calculate the weighted (True) or unweighted (False) distance met...
[ "A", "beta", "diversity", "metric", "that", "takes", "into", "account", "the", "relative", "relatedness", "of", "community", "members", ".", "Weighted", "UniFrac", "looks", "at", "abundances", "unweighted", "UniFrac", "looks", "at", "presence", "." ]
python
train
37.87234