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
slackapi/python-slackclient
slack/web/client.py
https://github.com/slackapi/python-slackclient/blob/901341c0284fd81e6d2719d6a0502308760d83e4/slack/web/client.py#L1282-L1289
def users_setPresence(self, *, presence: str, **kwargs) -> SlackResponse: """Manually sets user presence. Args: presence (str): Either 'auto' or 'away'. """ kwargs.update({"presence": presence}) return self.api_call("users.setPresence", json=kwargs)
[ "def", "users_setPresence", "(", "self", ",", "*", ",", "presence", ":", "str", ",", "*", "*", "kwargs", ")", "->", "SlackResponse", ":", "kwargs", ".", "update", "(", "{", "\"presence\"", ":", "presence", "}", ")", "return", "self", ".", "api_call", "...
Manually sets user presence. Args: presence (str): Either 'auto' or 'away'.
[ "Manually", "sets", "user", "presence", "." ]
python
train
36.875
jspricke/python-remind
remind.py
https://github.com/jspricke/python-remind/blob/dda2aa8fc20b87b9c9fcbca2b67bce73911d05d1/remind.py#L550-L566
def replace_vobject(self, uid, ical, filename=None): """Update the Remind command with the uid in the file with the new iCalendar""" if not filename: filename = self._filename elif filename not in self._reminders: return uid = uid.split('@')[0] with self...
[ "def", "replace_vobject", "(", "self", ",", "uid", ",", "ical", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "filename", "=", "self", ".", "_filename", "elif", "filename", "not", "in", "self", ".", "_reminders", ":", "return", ...
Update the Remind command with the uid in the file with the new iCalendar
[ "Update", "the", "Remind", "command", "with", "the", "uid", "in", "the", "file", "with", "the", "new", "iCalendar" ]
python
train
39.941176
brocade/pynos
pynos/versions/base/interface.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/interface.py#L2139-L2184
def port_channel_minimum_links(self, **kwargs): """Set minimum number of links in a port channel. Args: name (str): Port-channel number. (1, 5, etc) minimum_links (str): Minimum number of links in channel group. callback (function): A function executed upon completio...
[ "def", "port_channel_minimum_links", "(", "self", ",", "*", "*", "kwargs", ")", ":", "name", "=", "str", "(", "kwargs", ".", "pop", "(", "'name'", ")", ")", "minimum_links", "=", "str", "(", "kwargs", ".", "pop", "(", "'minimum_links'", ")", ")", "call...
Set minimum number of links in a port channel. Args: name (str): Port-channel number. (1, 5, etc) minimum_links (str): Minimum number of links in channel group. callback (function): A function executed upon completion of the method. The only parameter passed...
[ "Set", "minimum", "number", "of", "links", "in", "a", "port", "channel", "." ]
python
train
38.891304
openthread/openthread
tools/harness-thci/OpenThread.py
https://github.com/openthread/openthread/blob/0208d10563aa21c518092985c78ecf9cd223ab74/tools/harness-thci/OpenThread.py#L1706-L1752
def getChildrenInfo(self): """get all children information Returns: children's extended address """ print '%s call getChildrenInfo' % self.port try: childrenInfoAll = [] childrenInfo = {'EUI': 0, 'Rloc16': 0, 'MLEID': ''} childrenL...
[ "def", "getChildrenInfo", "(", "self", ")", ":", "print", "'%s call getChildrenInfo'", "%", "self", ".", "port", "try", ":", "childrenInfoAll", "=", "[", "]", "childrenInfo", "=", "{", "'EUI'", ":", "0", ",", "'Rloc16'", ":", "0", ",", "'MLEID'", ":", "'...
get all children information Returns: children's extended address
[ "get", "all", "children", "information" ]
python
train
34.212766
yourlabs/django-session-security
session_security/middleware.py
https://github.com/yourlabs/django-session-security/blob/5845c55f1c4b8cef8362302d64b396fc705e1a10/session_security/middleware.py#L37-L50
def is_passive_request(self, request): """ Should we skip activity update on this URL/View. """ if request.path in PASSIVE_URLS: return True try: match = resolve(request.path) # TODO: check namespaces too if match.url_name in PASSIVE_URL_NAMES: ...
[ "def", "is_passive_request", "(", "self", ",", "request", ")", ":", "if", "request", ".", "path", "in", "PASSIVE_URLS", ":", "return", "True", "try", ":", "match", "=", "resolve", "(", "request", ".", "path", ")", "# TODO: check namespaces too", "if", "match...
Should we skip activity update on this URL/View.
[ "Should", "we", "skip", "activity", "update", "on", "this", "URL", "/", "View", "." ]
python
train
28.5
google/grr
grr/client/grr_response_client/osx/objc.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/osx/objc.py#L497-L506
def LegacyKextunload(self, cf_bundle_identifier): """Unload a kext by forking into kextunload.""" error_code = OS_SUCCESS bundle_identifier = self.CFStringToPystring(cf_bundle_identifier) try: subprocess.check_call(['/sbin/kextunload', '-b', bundle_identifier]) except subprocess.CalledProcessE...
[ "def", "LegacyKextunload", "(", "self", ",", "cf_bundle_identifier", ")", ":", "error_code", "=", "OS_SUCCESS", "bundle_identifier", "=", "self", ".", "CFStringToPystring", "(", "cf_bundle_identifier", ")", "try", ":", "subprocess", ".", "check_call", "(", "[", "'...
Unload a kext by forking into kextunload.
[ "Unload", "a", "kext", "by", "forking", "into", "kextunload", "." ]
python
train
44.2
ToFuProject/tofu
tofu/geom/_core.py
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L946-L1006
def plot_sino(self, ax=None, Ang=_def.LOSImpAng, AngUnit=_def.LOSImpAngUnit, Sketch=True, dP=None, dLeg=_def.TorLegd, draw=True, fs=None, wintit=None, Test=True): """ Plot the sinogram of the vessel polygon, by computing its envelopp in a cross-section, can ...
[ "def", "plot_sino", "(", "self", ",", "ax", "=", "None", ",", "Ang", "=", "_def", ".", "LOSImpAng", ",", "AngUnit", "=", "_def", ".", "LOSImpAngUnit", ",", "Sketch", "=", "True", ",", "dP", "=", "None", ",", "dLeg", "=", "_def", ".", "TorLegd", ","...
Plot the sinogram of the vessel polygon, by computing its envelopp in a cross-section, can also plot a 3D version of it The envelop of the polygon is computed using self.Sino_RefPt as a reference point in projection space, and plotted using the provided dictionary of properties. Optionaly a sma...
[ "Plot", "the", "sinogram", "of", "the", "vessel", "polygon", "by", "computing", "its", "envelopp", "in", "a", "cross", "-", "section", "can", "also", "plot", "a", "3D", "version", "of", "it" ]
python
train
52.606557
google/grr
grr/server/grr_response_server/hunt.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/hunt.py#L378-L432
def StartHuntFlowOnClient(client_id, hunt_id): """Starts a flow corresponding to a given hunt on a given client.""" hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id) hunt_obj = CompleteHuntIfExpirationTimeReached(hunt_obj) # There may be a little race between foreman rules being removed and # foreman sche...
[ "def", "StartHuntFlowOnClient", "(", "client_id", ",", "hunt_id", ")", ":", "hunt_obj", "=", "data_store", ".", "REL_DB", ".", "ReadHuntObject", "(", "hunt_id", ")", "hunt_obj", "=", "CompleteHuntIfExpirationTimeReached", "(", "hunt_obj", ")", "# There may be a little...
Starts a flow corresponding to a given hunt on a given client.
[ "Starts", "a", "flow", "corresponding", "to", "a", "given", "hunt", "on", "a", "given", "client", "." ]
python
train
40.163636
mapbox/mapbox-cli-py
mapboxcli/scripts/geocoding.py
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/geocoding.py#L34-L38
def echo_headers(headers, file=None): """Echo headers, sorted.""" for k, v in sorted(headers.items()): click.echo("{0}: {1}".format(k.title(), v), file=file) click.echo(file=file)
[ "def", "echo_headers", "(", "headers", ",", "file", "=", "None", ")", ":", "for", "k", ",", "v", "in", "sorted", "(", "headers", ".", "items", "(", ")", ")", ":", "click", ".", "echo", "(", "\"{0}: {1}\"", ".", "format", "(", "k", ".", "title", "...
Echo headers, sorted.
[ "Echo", "headers", "sorted", "." ]
python
train
39
mozilla/treeherder
treeherder/model/models.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/model/models.py#L1287-L1301
def create_match(self, matcher_name, classification): """ Create a TextLogErrorMatch instance Typically used for manual "matches" or tests. """ if classification is None: classification = ClassifiedFailure.objects.create() TextLogErrorMatch.objects.create( ...
[ "def", "create_match", "(", "self", ",", "matcher_name", ",", "classification", ")", ":", "if", "classification", "is", "None", ":", "classification", "=", "ClassifiedFailure", ".", "objects", ".", "create", "(", ")", "TextLogErrorMatch", ".", "objects", ".", ...
Create a TextLogErrorMatch instance Typically used for manual "matches" or tests.
[ "Create", "a", "TextLogErrorMatch", "instance" ]
python
train
30.266667
frictionlessdata/tableschema-py
tableschema/table.py
https://github.com/frictionlessdata/tableschema-py/blob/9c5fa930319e7c5b10351f794091c5f9de5e8684/tableschema/table.py#L141-L165
def infer(self, limit=100, confidence=0.75): """https://github.com/frictionlessdata/tableschema-py#schema """ if self.__schema is None or self.__headers is None: # Infer (tabulator) if not self.__storage: with self.__stream as stream: ...
[ "def", "infer", "(", "self", ",", "limit", "=", "100", ",", "confidence", "=", "0.75", ")", ":", "if", "self", ".", "__schema", "is", "None", "or", "self", ".", "__headers", "is", "None", ":", "# Infer (tabulator)", "if", "not", "self", ".", "__storage...
https://github.com/frictionlessdata/tableschema-py#schema
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "py#schema" ]
python
train
41.44
apache/incubator-heron
heron/tools/cli/src/python/main.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/cli/src/python/main.py#L309-L380
def execute(handlers, local_commands): ''' Run the command :return: ''' # verify if the environment variables are correctly set check_environment() # create the argument parser parser = create_parser(handlers) # if no argument is provided, print help and exit if len(sys.argv[1:]) == 0: parser....
[ "def", "execute", "(", "handlers", ",", "local_commands", ")", ":", "# verify if the environment variables are correctly set", "check_environment", "(", ")", "# create the argument parser", "parser", "=", "create_parser", "(", "handlers", ")", "# if no argument is provided, pri...
Run the command :return:
[ "Run", "the", "command", ":", "return", ":" ]
python
valid
29.916667
dmwm/DBS
Server/Python/src/dbs/business/DBSBlock.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/business/DBSBlock.py#L163-L183
def updateSiteName(self, block_name, origin_site_name): """ Update the origin_site_name for a given block name """ if not origin_site_name: dbsExceptionHandler('dbsException-invalid-input', "DBSBlock/updateSiteName. origin_site_name is mandator...
[ "def", "updateSiteName", "(", "self", ",", "block_name", ",", "origin_site_name", ")", ":", "if", "not", "origin_site_name", ":", "dbsExceptionHandler", "(", "'dbsException-invalid-input'", ",", "\"DBSBlock/updateSiteName. origin_site_name is mandatory.\"", ")", "conn", "="...
Update the origin_site_name for a given block name
[ "Update", "the", "origin_site_name", "for", "a", "given", "block", "name" ]
python
train
32.47619
jopohl/urh
src/urh/signalprocessing/ProtocolAnalyzer.py
https://github.com/jopohl/urh/blob/2eb33b125c8407964cd1092843cde5010eb88aae/src/urh/signalprocessing/ProtocolAnalyzer.py#L439-L455
def convert_index(self, index: int, from_view: int, to_view: int, decoded: bool, message_indx=-1) -> tuple: """ Konvertiert einen Index aus der einen Sicht (z.B. Bit) in eine andere (z.B. Hex) :param message_indx: if -1, the message with max length is chosen :return: """ ...
[ "def", "convert_index", "(", "self", ",", "index", ":", "int", ",", "from_view", ":", "int", ",", "to_view", ":", "int", ",", "decoded", ":", "bool", ",", "message_indx", "=", "-", "1", ")", "->", "tuple", ":", "if", "len", "(", "self", ".", "messa...
Konvertiert einen Index aus der einen Sicht (z.B. Bit) in eine andere (z.B. Hex) :param message_indx: if -1, the message with max length is chosen :return:
[ "Konvertiert", "einen", "Index", "aus", "der", "einen", "Sicht", "(", "z", ".", "B", ".", "Bit", ")", "in", "eine", "andere", "(", "z", ".", "B", ".", "Hex", ")" ]
python
train
39.705882
ManiacalLabs/BiblioPixel
bibliopixel/drivers/curses.py
https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/drivers/curses.py#L55-L71
def main(): """ If a project has a Curses driver, the section "main" in the section "run" must be "bibliopixel.drivers.curses.Curses.main". """ if not _curses: # https://stackoverflow.com/a/1325587/43839 if os.name == 'nt': raise ValueErro...
[ "def", "main", "(", ")", ":", "if", "not", "_curses", ":", "# https://stackoverflow.com/a/1325587/43839", "if", "os", ".", "name", "==", "'nt'", ":", "raise", "ValueError", "(", "'curses is not supported under Windows'", ")", "raise", "ValueError", "(", "'Your platf...
If a project has a Curses driver, the section "main" in the section "run" must be "bibliopixel.drivers.curses.Curses.main".
[ "If", "a", "project", "has", "a", "Curses", "driver", "the", "section", "main", "in", "the", "section", "run", "must", "be", "bibliopixel", ".", "drivers", ".", "curses", ".", "Curses", ".", "main", "." ]
python
valid
35.352941
lago-project/lago
lago/workdir.py
https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/workdir.py#L63-L76
def workdir_loaded(func): """ Decorator to make sure that the workdir is loaded when calling the decorated function """ @wraps(func) def decorator(workdir, *args, **kwargs): if not workdir.loaded: workdir.load() return func(workdir, *args, **kwargs) return deco...
[ "def", "workdir_loaded", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "decorator", "(", "workdir", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "workdir", ".", "loaded", ":", "workdir", ".", "load", "(", ")", ...
Decorator to make sure that the workdir is loaded when calling the decorated function
[ "Decorator", "to", "make", "sure", "that", "the", "workdir", "is", "loaded", "when", "calling", "the", "decorated", "function" ]
python
train
22.285714
coldfix/udiskie
udiskie/mount.py
https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L702-L711
def get_all_handleable_leaves(self): """ Get list of all handleable devices, return only those that represent leaf nodes within the filtered device tree. """ nodes = self.get_device_tree() return [node.device for node in sorted(nodes.values(), key=DevNode....
[ "def", "get_all_handleable_leaves", "(", "self", ")", ":", "nodes", "=", "self", ".", "get_device_tree", "(", ")", "return", "[", "node", ".", "device", "for", "node", "in", "sorted", "(", "nodes", ".", "values", "(", ")", ",", "key", "=", "DevNode", "...
Get list of all handleable devices, return only those that represent leaf nodes within the filtered device tree.
[ "Get", "list", "of", "all", "handleable", "devices", "return", "only", "those", "that", "represent", "leaf", "nodes", "within", "the", "filtered", "device", "tree", "." ]
python
train
44
pjuren/pyokit
src/pyokit/interface/cli.py
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/interface/cli.py#L277-L288
def optionIsSet(self, name): """ Check whether an option with a given name exists and has been set. :param name: the name of the option to check; can be short or long name. :return: true if an option matching the given name exists and it has had it's value set by the user """ name ...
[ "def", "optionIsSet", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "strip", "(", ")", "if", "not", "self", ".", "hasOption", "(", "name", ")", ":", "return", "False", "return", "self", ".", "getOption", "(", "name", ")", ".", "isSe...
Check whether an option with a given name exists and has been set. :param name: the name of the option to check; can be short or long name. :return: true if an option matching the given name exists and it has had it's value set by the user
[ "Check", "whether", "an", "option", "with", "a", "given", "name", "exists", "and", "has", "been", "set", "." ]
python
train
34.583333
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/eight_planets.py
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/eight_planets.py#L189-L231
def make_movie(q: np.ndarray, step: int, bodies: List[str], plot_colors: Dict[str, str], fname: str): """ Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order. """ # Get N and ...
[ "def", "make_movie", "(", "q", ":", "np", ".", "ndarray", ",", "step", ":", "int", ",", "bodies", ":", "List", "[", "str", "]", ",", "plot_colors", ":", "Dict", "[", "str", ",", "str", "]", ",", "fname", ":", "str", ")", ":", "# Get N and number of...
Make a series of frames of the planetary orbits that can be assembled into a movie. q is a Nx3B array. t indexes time points. 3B columns are (x, y, z) for the bodies in order.
[ "Make", "a", "series", "of", "frames", "of", "the", "planetary", "orbits", "that", "can", "be", "assembled", "into", "a", "movie", ".", "q", "is", "a", "Nx3B", "array", ".", "t", "indexes", "time", "points", ".", "3B", "columns", "are", "(", "x", "y"...
python
train
41.116279
volafiled/python-volapi
volapi/file.py
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/file.py#L100-L105
def duration(self): """Returns the duration in seconds of this audio or video file""" if self.filetype not in ("video", "audio"): raise RuntimeError("Only videos and audio have durations") return self.info.get("length") or self.info.get("duration")
[ "def", "duration", "(", "self", ")", ":", "if", "self", ".", "filetype", "not", "in", "(", "\"video\"", ",", "\"audio\"", ")", ":", "raise", "RuntimeError", "(", "\"Only videos and audio have durations\"", ")", "return", "self", ".", "info", ".", "get", "(",...
Returns the duration in seconds of this audio or video file
[ "Returns", "the", "duration", "in", "seconds", "of", "this", "audio", "or", "video", "file" ]
python
train
46.666667
peopledoc/django-agnocomplete
agnocomplete/core.py
https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/core.py#L378-L387
def get_queryset_filters(self, query): """ Return the filtered queryset """ conditions = Q() for field_name in self.fields: conditions |= Q(**{ self._construct_qs_filter(field_name): query }) return conditions
[ "def", "get_queryset_filters", "(", "self", ",", "query", ")", ":", "conditions", "=", "Q", "(", ")", "for", "field_name", "in", "self", ".", "fields", ":", "conditions", "|=", "Q", "(", "*", "*", "{", "self", ".", "_construct_qs_filter", "(", "field_nam...
Return the filtered queryset
[ "Return", "the", "filtered", "queryset" ]
python
train
28.8
OpenKMIP/PyKMIP
kmip/core/messages/payloads/get.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/core/messages/payloads/get.py#L220-L260
def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Write the data encoding the Get request payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStream ...
[ "def", "write", "(", "self", ",", "output_stream", ",", "kmip_version", "=", "enums", ".", "KMIPVersion", ".", "KMIP_1_0", ")", ":", "local_stream", "=", "utils", ".", "BytearrayStream", "(", ")", "if", "self", ".", "_unique_identifier", "is", "not", "None",...
Write the data encoding the Get request payload to a stream. Args: output_stream (stream): A data stream in which to encode object data, supporting a write method; usually a BytearrayStream object. kmip_version (KMIPVersion): An enumeration defining the K...
[ "Write", "the", "data", "encoding", "the", "Get", "request", "payload", "to", "a", "stream", "." ]
python
test
36.341463
awslabs/aws-shell
awsshell/config.py
https://github.com/awslabs/aws-shell/blob/8950f03d9d720879890af6c11537b8f9789ce5a9/awsshell/config.py#L47-L64
def _load_template_or_config(self, template_path, config_path): """Load the config file if it exists, else read the default config. :type template_path: str :param template_path: The template config file path. :type config_path: str :param config_path: The user's config file pa...
[ "def", "_load_template_or_config", "(", "self", ",", "template_path", ",", "config_path", ")", ":", "expanded_config_path", "=", "os", ".", "path", ".", "expanduser", "(", "config_path", ")", "cfg", "=", "ConfigObj", "(", ")", "cfg", ".", "filename", "=", "e...
Load the config file if it exists, else read the default config. :type template_path: str :param template_path: The template config file path. :type config_path: str :param config_path: The user's config file path. :rtype: :class:`configobj.ConfigObj` :return: The conf...
[ "Load", "the", "config", "file", "if", "it", "exists", "else", "read", "the", "default", "config", "." ]
python
train
39.888889
project-rig/rig
rig/machine_control/machine_controller.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L1649-L1671
def load_routing_tables(self, routing_tables, app_id): """Allocate space for an load multicast routing tables. The routing table entries will be removed automatically when the associated application is stopped. Parameters ---------- routing_tables : {(x, y): \ ...
[ "def", "load_routing_tables", "(", "self", ",", "routing_tables", ",", "app_id", ")", ":", "for", "(", "x", ",", "y", ")", ",", "table", "in", "iteritems", "(", "routing_tables", ")", ":", "self", ".", "load_routing_table_entries", "(", "table", ",", "x", ...
Allocate space for an load multicast routing tables. The routing table entries will be removed automatically when the associated application is stopped. Parameters ---------- routing_tables : {(x, y): \ [:py:class:`~rig.routing_table.RoutingTableEntry`...
[ "Allocate", "space", "for", "an", "load", "multicast", "routing", "tables", "." ]
python
train
41.913043
KrzyHonk/bpmn-python
bpmn_python/bpmn_diagram_export.py
https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_export.py#L77-L86
def export_complex_gateway_info(node_params, output_element): """ Adds ComplexGateway node attributes to exported XML element :param node_params: dictionary with given complex gateway parameters, :param output_element: object representing BPMN XML 'complexGateway' element. """ ...
[ "def", "export_complex_gateway_info", "(", "node_params", ",", "output_element", ")", ":", "output_element", ".", "set", "(", "consts", ".", "Consts", ".", "gateway_direction", ",", "node_params", "[", "consts", ".", "Consts", ".", "gateway_direction", "]", ")", ...
Adds ComplexGateway node attributes to exported XML element :param node_params: dictionary with given complex gateway parameters, :param output_element: object representing BPMN XML 'complexGateway' element.
[ "Adds", "ComplexGateway", "node", "attributes", "to", "exported", "XML", "element" ]
python
train
60.5
cltk/cltk
cltk/utils/contributors.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/utils/contributors.py#L79-L97
def find_write_contribs() -> None: """Look for files, find authors, sort, write file.""" map_file_auth = {} # type: Dict[str, List[str]] for filename in scantree('cltk'): filepath = filename.path # type: str authors_list = get_authors(filepath) # type: List[str] if authors_list: ...
[ "def", "find_write_contribs", "(", ")", "->", "None", ":", "map_file_auth", "=", "{", "}", "# type: Dict[str, List[str]]", "for", "filename", "in", "scantree", "(", "'cltk'", ")", ":", "filepath", "=", "filename", ".", "path", "# type: str", "authors_list", "=",...
Look for files, find authors, sort, write file.
[ "Look", "for", "files", "find", "authors", "sort", "write", "file", "." ]
python
train
44.105263
CityOfZion/neo-python
neo/Wallets/NEP5Token.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Wallets/NEP5Token.py#L320-L334
def ToJson(self): """ Convert object members to a dictionary that can be parsed as JSON. Returns: dict: """ jsn = { 'name': self.name, 'symbol': self.symbol, 'decimals': self.decimals, 'script_hash': self.ScriptHash.To...
[ "def", "ToJson", "(", "self", ")", ":", "jsn", "=", "{", "'name'", ":", "self", ".", "name", ",", "'symbol'", ":", "self", ".", "symbol", ",", "'decimals'", ":", "self", ".", "decimals", ",", "'script_hash'", ":", "self", ".", "ScriptHash", ".", "To0...
Convert object members to a dictionary that can be parsed as JSON. Returns: dict:
[ "Convert", "object", "members", "to", "a", "dictionary", "that", "can", "be", "parsed", "as", "JSON", "." ]
python
train
26.066667
python-openxml/python-docx
docx/text/paragraph.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/paragraph.py#L65-L77
def insert_paragraph_before(self, text=None, style=None): """ Return a newly created paragraph, inserted directly before this paragraph. If *text* is supplied, the new paragraph contains that text in a single run. If *style* is provided, that style is assigned to the new paragrap...
[ "def", "insert_paragraph_before", "(", "self", ",", "text", "=", "None", ",", "style", "=", "None", ")", ":", "paragraph", "=", "self", ".", "_insert_paragraph_before", "(", ")", "if", "text", ":", "paragraph", ".", "add_run", "(", "text", ")", "if", "st...
Return a newly created paragraph, inserted directly before this paragraph. If *text* is supplied, the new paragraph contains that text in a single run. If *style* is provided, that style is assigned to the new paragraph.
[ "Return", "a", "newly", "created", "paragraph", "inserted", "directly", "before", "this", "paragraph", ".", "If", "*", "text", "*", "is", "supplied", "the", "new", "paragraph", "contains", "that", "text", "in", "a", "single", "run", ".", "If", "*", "style"...
python
train
39.846154
OpenTreeOfLife/peyotl
peyotl/nexson_validation/_validation_base.py
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_validation/_validation_base.py#L575-L581
def _validate_obj_by_schema(self, obj, obj_nex_id, vc): """Creates: errors if `obj` does not contain keys in the schema.ALLOWED_KEY_SET, warnings if `obj` lacks keys listed in schema.EXPECETED_KEY_SET, or if `obj` contains keys not listed in schema.ALLOWED_KEY_SET. ...
[ "def", "_validate_obj_by_schema", "(", "self", ",", "obj", ",", "obj_nex_id", ",", "vc", ")", ":", "return", "self", ".", "_validate_id_obj_list_by_schema", "(", "[", "(", "obj_nex_id", ",", "obj", ")", "]", ",", "vc", ",", "group_by_warning", "=", "False", ...
Creates: errors if `obj` does not contain keys in the schema.ALLOWED_KEY_SET, warnings if `obj` lacks keys listed in schema.EXPECETED_KEY_SET, or if `obj` contains keys not listed in schema.ALLOWED_KEY_SET.
[ "Creates", ":", "errors", "if", "obj", "does", "not", "contain", "keys", "in", "the", "schema", ".", "ALLOWED_KEY_SET", "warnings", "if", "obj", "lacks", "keys", "listed", "in", "schema", ".", "EXPECETED_KEY_SET", "or", "if", "obj", "contains", "keys", "not"...
python
train
60.857143
juju/charm-helpers
charmhelpers/fetch/ubuntu.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/ubuntu.py#L351-L376
def _get_keyid_by_gpg_key(key_material): """Get a GPG key fingerprint by GPG key material. Gets a GPG key fingerprint (40-digit, 160-bit) by the ASCII armor-encoded or binary GPG key material. Can be used, for example, to generate file names for keys passed via charm options. :param key_material: A...
[ "def", "_get_keyid_by_gpg_key", "(", "key_material", ")", ":", "# Use the same gpg command for both Xenial and Bionic", "cmd", "=", "'gpg --with-colons --with-fingerprint'", "ps", "=", "subprocess", ".", "Popen", "(", "cmd", ".", "split", "(", ")", ",", "stdout", "=", ...
Get a GPG key fingerprint by GPG key material. Gets a GPG key fingerprint (40-digit, 160-bit) by the ASCII armor-encoded or binary GPG key material. Can be used, for example, to generate file names for keys passed via charm options. :param key_material: ASCII armor-encoded or binary GPG key material ...
[ "Get", "a", "GPG", "key", "fingerprint", "by", "GPG", "key", "material", ".", "Gets", "a", "GPG", "key", "fingerprint", "(", "40", "-", "digit", "160", "-", "bit", ")", "by", "the", "ASCII", "armor", "-", "encoded", "or", "binary", "GPG", "key", "mat...
python
train
45.769231
ewels/MultiQC
multiqc/modules/skewer/skewer.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/skewer/skewer.py#L75-L89
def add_readlen_dist_plot(self): """ Generate plot HTML for read length distribution plot. """ pconfig = { 'id': 'skewer_read_length_histogram', 'title': 'Skewer: Read Length Distribution after trimming', 'xDecimals': False, 'ylab': '% of Reads', ...
[ "def", "add_readlen_dist_plot", "(", "self", ")", ":", "pconfig", "=", "{", "'id'", ":", "'skewer_read_length_histogram'", ",", "'title'", ":", "'Skewer: Read Length Distribution after trimming'", ",", "'xDecimals'", ":", "False", ",", "'ylab'", ":", "'% of Reads'", "...
Generate plot HTML for read length distribution plot.
[ "Generate", "plot", "HTML", "for", "read", "length", "distribution", "plot", "." ]
python
train
36.8
tensorflow/tensor2tensor
tensor2tensor/layers/latent_layers.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/latent_layers.py#L703-L758
def iaf_flow(one_hot_assignments, scale_weights, scale_bias, num_codes, summary=True, name=None): """Performs a single IAF flow using scale and normalization transformations. Args: one_hot_assignments: Assignments Tensor with shape [num_samples, ...
[ "def", "iaf_flow", "(", "one_hot_assignments", ",", "scale_weights", ",", "scale_bias", ",", "num_codes", ",", "summary", "=", "True", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ",", "default_name", "=", "\"iaf\"", ")...
Performs a single IAF flow using scale and normalization transformations. Args: one_hot_assignments: Assignments Tensor with shape [num_samples, batch_size, latent_size, num_codes]. scale_weights: Tensor corresponding to lower triangular matrix used to autoregressively generate scale matrix from ...
[ "Performs", "a", "single", "IAF", "flow", "using", "scale", "and", "normalization", "transformations", "." ]
python
train
48.589286
Wiredcraft/dopy
dopy/manager.py
https://github.com/Wiredcraft/dopy/blob/8b7bcbc85ef27ec4ae2fb46eae9bac827c4c3df0/dopy/manager.py#L541-L549
def get_floating_ip_action(self, ip_addr, action_id): """ Retrieve the status of a Floating IP action. """ if self.api_version == 2: json = self.request('/floating_ips/' + ip_addr + '/actions/' + action_id) return json['action'] else: raise DoE...
[ "def", "get_floating_ip_action", "(", "self", ",", "ip_addr", ",", "action_id", ")", ":", "if", "self", ".", "api_version", "==", "2", ":", "json", "=", "self", ".", "request", "(", "'/floating_ips/'", "+", "ip_addr", "+", "'/actions/'", "+", "action_id", ...
Retrieve the status of a Floating IP action.
[ "Retrieve", "the", "status", "of", "a", "Floating", "IP", "action", "." ]
python
train
37.444444
AdvancedClimateSystems/uModbus
umodbus/server/serial/rtu.py
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/server/serial/rtu.py#L60-L67
def process(self, request_adu): """ Process request ADU and return response. :param request_adu: A bytearray containing the ADU request. :return: A bytearray containing the response of the ADU request. """ validate_crc(request_adu) return super(RTUServer, self).process(r...
[ "def", "process", "(", "self", ",", "request_adu", ")", ":", "validate_crc", "(", "request_adu", ")", "return", "super", "(", "RTUServer", ",", "self", ")", ".", "process", "(", "request_adu", ")" ]
Process request ADU and return response. :param request_adu: A bytearray containing the ADU request. :return: A bytearray containing the response of the ADU request.
[ "Process", "request", "ADU", "and", "return", "response", "." ]
python
train
40.5
honzamach/pynspect
pynspect/gparser.py
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/gparser.py#L336-L342
def p_ex_expression(tok): """ex_expression : OP_EXISTS cmp_expression | cmp_expression""" if len(tok) == 3: tok[0] = UnaryOperationRule(tok[1], tok[2]) else: tok[0] = tok[1]
[ "def", "p_ex_expression", "(", "tok", ")", ":", "if", "len", "(", "tok", ")", "==", "3", ":", "tok", "[", "0", "]", "=", "UnaryOperationRule", "(", "tok", "[", "1", "]", ",", "tok", "[", "2", "]", ")", "else", ":", "tok", "[", "0", "]", "=", ...
ex_expression : OP_EXISTS cmp_expression | cmp_expression
[ "ex_expression", ":", "OP_EXISTS", "cmp_expression", "|", "cmp_expression" ]
python
train
34.285714
pypa/pipenv
pipenv/vendor/distlib/index.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/index.py#L134-L150
def _reader(self, name, stream, outbuf): """ Thread runner for reading lines of from a subprocess into a buffer. :param name: The logical name of the stream (used for logging only). :param stream: The stream to read from. This will typically a pipe connected to th...
[ "def", "_reader", "(", "self", ",", "name", ",", "stream", ",", "outbuf", ")", ":", "while", "True", ":", "s", "=", "stream", ".", "readline", "(", ")", "if", "not", "s", ":", "break", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", ".", "rs...
Thread runner for reading lines of from a subprocess into a buffer. :param name: The logical name of the stream (used for logging only). :param stream: The stream to read from. This will typically a pipe connected to the output stream of a subprocess. :param outbuf: The l...
[ "Thread", "runner", "for", "reading", "lines", "of", "from", "a", "subprocess", "into", "a", "buffer", "." ]
python
train
38.176471
python-cmd2/cmd2
cmd2/cmd2.py
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L2599-L2631
def complete_help_subcommand(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: """Completes the subcommand argument of help""" # Get all tokens through the one being completed tokens, _ = self.tokens_for_completion(line, begidx, endidx) if not tokens: retu...
[ "def", "complete_help_subcommand", "(", "self", ",", "text", ":", "str", ",", "line", ":", "str", ",", "begidx", ":", "int", ",", "endidx", ":", "int", ")", "->", "List", "[", "str", "]", ":", "# Get all tokens through the one being completed", "tokens", ","...
Completes the subcommand argument of help
[ "Completes", "the", "subcommand", "argument", "of", "help" ]
python
train
33.424242
xiaocong/uiautomator
uiautomator/__init__.py
https://github.com/xiaocong/uiautomator/blob/9a0c892ffd056713f91aa2153d1533c5b0553a1c/uiautomator/__init__.py#L608-L617
def dump(self, filename=None, compressed=True, pretty=True): '''dump device window and pull to local file.''' content = self.server.jsonrpc.dumpWindowHierarchy(compressed, None) if filename: with open(filename, "wb") as f: f.write(content.encode("utf-8")) if p...
[ "def", "dump", "(", "self", ",", "filename", "=", "None", ",", "compressed", "=", "True", ",", "pretty", "=", "True", ")", ":", "content", "=", "self", ".", "server", ".", "jsonrpc", ".", "dumpWindowHierarchy", "(", "compressed", ",", "None", ")", "if"...
dump device window and pull to local file.
[ "dump", "device", "window", "and", "pull", "to", "local", "file", "." ]
python
train
50
kipe/enocean
enocean/protocol/packet.py
https://github.com/kipe/enocean/blob/99fa03f47004eef74c7987545c33ecd01af0de07/enocean/protocol/packet.py#L256-L262
def select_eep(self, rorg_func, rorg_type, direction=None, command=None): ''' Set EEP based on FUNC and TYPE ''' # set EEP profile self.rorg_func = rorg_func self.rorg_type = rorg_type self._profile = self.eep.find_profile(self._bit_data, self.rorg, rorg_func, rorg_type, directio...
[ "def", "select_eep", "(", "self", ",", "rorg_func", ",", "rorg_type", ",", "direction", "=", "None", ",", "command", "=", "None", ")", ":", "# set EEP profile", "self", ".", "rorg_func", "=", "rorg_func", "self", ".", "rorg_type", "=", "rorg_type", "self", ...
Set EEP based on FUNC and TYPE
[ "Set", "EEP", "based", "on", "FUNC", "and", "TYPE" ]
python
train
52.285714
quantopian/alphalens
alphalens/performance.py
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L497-L592
def positions(weights, period, freq=None): """ Builds net position values time series, the portfolio percentage invested in each position. Parameters ---------- weights: pd.Series pd.Series containing factor weights, the index contains timestamps at which the trades are computed...
[ "def", "positions", "(", "weights", ",", "period", ",", "freq", "=", "None", ")", ":", "weights", "=", "weights", ".", "unstack", "(", ")", "if", "not", "isinstance", "(", "period", ",", "pd", ".", "Timedelta", ")", ":", "period", "=", "pd", ".", "...
Builds net position values time series, the portfolio percentage invested in each position. Parameters ---------- weights: pd.Series pd.Series containing factor weights, the index contains timestamps at which the trades are computed and the values correspond to assets weights ...
[ "Builds", "net", "position", "values", "time", "series", "the", "portfolio", "percentage", "invested", "in", "each", "position", "." ]
python
train
35.9375
ebu/PlugIt
plugit_proxy/views.py
https://github.com/ebu/PlugIt/blob/de5f1e870f67caaef7a4a58e4bb1ed54d9c5dc53/plugit_proxy/views.py#L639-L651
def get_template(request, query, meta, proxyMode): """Return (if needed) the template to use""" templateContent = None if not proxyMode: templateContent = plugIt.getTemplate(query, meta) if not templateContent: return (None, gen404(request, baseURI, 'template')) return (...
[ "def", "get_template", "(", "request", ",", "query", ",", "meta", ",", "proxyMode", ")", ":", "templateContent", "=", "None", "if", "not", "proxyMode", ":", "templateContent", "=", "plugIt", ".", "getTemplate", "(", "query", ",", "meta", ")", "if", "not", ...
Return (if needed) the template to use
[ "Return", "(", "if", "needed", ")", "the", "template", "to", "use" ]
python
train
25.384615
log2timeline/dfvfs
dfvfs/file_io/gzip_file_io.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/file_io/gzip_file_io.py#L117-L144
def read(self, size=None): """Reads a byte string from the gzip file at the current offset. The function will read a byte string up to the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remain...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "data", "=", "b''", "while", "(", "(", "size", "and", "len", "(", "data", ")", "<", "size", ")", "and", "self", ".", "_current_offset", "<", "self", ".", "uncompressed_data_size", ")", ...
Reads a byte string from the gzip file at the current offset. The function will read a byte string up to the specified size or all of the remaining data if no size was specified. Args: size (Optional[int]): number of bytes to read, where None is all remaining data. Returns: byte...
[ "Reads", "a", "byte", "string", "from", "the", "gzip", "file", "at", "the", "current", "offset", "." ]
python
train
31.357143
robertpeteuil/multi-cloud-control
mcc/cldcnct.py
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L288-L299
def adj_nodes_ali(ali_nodes): """Adjust details specific to AliCloud.""" for node in ali_nodes: node.cloud = "alicloud" node.cloud_disp = "AliCloud" node.private_ips = ip_to_str(node.extra['vpc_attributes']['private_ip_address']) node.public_ips = ip_to_str(node.public_ips) ...
[ "def", "adj_nodes_ali", "(", "ali_nodes", ")", ":", "for", "node", "in", "ali_nodes", ":", "node", ".", "cloud", "=", "\"alicloud\"", "node", ".", "cloud_disp", "=", "\"AliCloud\"", "node", ".", "private_ips", "=", "ip_to_str", "(", "node", ".", "extra", "...
Adjust details specific to AliCloud.
[ "Adjust", "details", "specific", "to", "AliCloud", "." ]
python
train
41.916667
cloud-custodian/cloud-custodian
tools/c7n_logexporter/c7n_logexporter/exporter.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L372-L388
def filter_creation_date(groups, start, end): """Filter log groups by their creation date. Also sets group specific value for start to the minimum of creation date or start. """ results = [] for g in groups: created = datetime.fromtimestamp(g['creationTime'] / 1000.0) if created...
[ "def", "filter_creation_date", "(", "groups", ",", "start", ",", "end", ")", ":", "results", "=", "[", "]", "for", "g", "in", "groups", ":", "created", "=", "datetime", ".", "fromtimestamp", "(", "g", "[", "'creationTime'", "]", "/", "1000.0", ")", "if...
Filter log groups by their creation date. Also sets group specific value for start to the minimum of creation date or start.
[ "Filter", "log", "groups", "by", "their", "creation", "date", "." ]
python
train
29.117647
monarch-initiative/dipper
dipper/sources/Reactome.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Reactome.py#L55-L73
def parse(self, limit=None): """ Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None """ if limit is not None: LOG.info("Only parsing first %d rows", limit) ensemb...
[ "def", "parse", "(", "self", ",", "limit", "=", "None", ")", ":", "if", "limit", "is", "not", "None", ":", "LOG", ".", "info", "(", "\"Only parsing first %d rows\"", ",", "limit", ")", "ensembl_file", "=", "'/'", ".", "join", "(", "(", "self", ".", "...
Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
[ "Override", "Source", ".", "parse", "()", "Args", ":", ":", "param", "limit", "(", "int", "optional", ")", "limit", "the", "number", "of", "rows", "processed", "Returns", ":", ":", "return", "None" ]
python
train
38.157895
dslackw/slpkg
slpkg/sbo/remove.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/remove.py#L31-L35
def delete(build_folder): """Delete build directory and all its contents. """ if _meta_.del_build in ["on", "ON"] and os.path.exists(build_folder): shutil.rmtree(build_folder)
[ "def", "delete", "(", "build_folder", ")", ":", "if", "_meta_", ".", "del_build", "in", "[", "\"on\"", ",", "\"ON\"", "]", "and", "os", ".", "path", ".", "exists", "(", "build_folder", ")", ":", "shutil", ".", "rmtree", "(", "build_folder", ")" ]
Delete build directory and all its contents.
[ "Delete", "build", "directory", "and", "all", "its", "contents", "." ]
python
train
38.2
zyga/python-glibc
tempfile_ext.py
https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/tempfile_ext.py#L333-L355
def _mkstemp_inner(dir, pre, suf, flags): """Code common to mkstemp, TemporaryFile, and NamedTemporaryFile.""" names = _get_candidate_names() for seq in range(TMP_MAX): name = next(names) file = _os.path.join(dir, pre + name + suf) try: fd = _os.open(file, flags, 0o600)...
[ "def", "_mkstemp_inner", "(", "dir", ",", "pre", ",", "suf", ",", "flags", ")", ":", "names", "=", "_get_candidate_names", "(", ")", "for", "seq", "in", "range", "(", "TMP_MAX", ")", ":", "name", "=", "next", "(", "names", ")", "file", "=", "_os", ...
Code common to mkstemp, TemporaryFile, and NamedTemporaryFile.
[ "Code", "common", "to", "mkstemp", "TemporaryFile", "and", "NamedTemporaryFile", "." ]
python
train
33.434783
volfpeter/graphscraper
src/graphscraper/base.py
https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/base.py#L498-L535
def add_edge(self, source: Node, target: Node, weight: float = 1, save_to_cache: bool = True) -> None: """ Adds an edge to the edge list that will connect the specified nodes. Arguments: source (Node): The ...
[ "def", "add_edge", "(", "self", ",", "source", ":", "Node", ",", "target", ":", "Node", ",", "weight", ":", "float", "=", "1", ",", "save_to_cache", ":", "bool", "=", "True", ")", "->", "None", ":", "if", "not", "isinstance", "(", "source", ",", "N...
Adds an edge to the edge list that will connect the specified nodes. Arguments: source (Node): The source node of the edge. target (Node): The target node of the edge. weight (float): The weight of the created edge. save_to_cache (bool): Whether the edge sh...
[ "Adds", "an", "edge", "to", "the", "edge", "list", "that", "will", "connect", "the", "specified", "nodes", ".", "Arguments", ":", "source", "(", "Node", ")", ":", "The", "source", "node", "of", "the", "edge", ".", "target", "(", "Node", ")", ":", "Th...
python
train
42.368421
gwpy/gwpy
gwpy/plot/utils.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/plot/utils.py#L40-L48
def color_cycle(colors=None): """An infinite iterator of the given (or default) colors """ if colors: return itertools.cycle(colors) try: return itertools.cycle(p["color"] for p in rcParams["axes.prop_cycle"]) except KeyError: # matplotlib < 1.5 return itertools.cycle(rcPara...
[ "def", "color_cycle", "(", "colors", "=", "None", ")", ":", "if", "colors", ":", "return", "itertools", ".", "cycle", "(", "colors", ")", "try", ":", "return", "itertools", ".", "cycle", "(", "p", "[", "\"color\"", "]", "for", "p", "in", "rcParams", ...
An infinite iterator of the given (or default) colors
[ "An", "infinite", "iterator", "of", "the", "given", "(", "or", "default", ")", "colors" ]
python
train
37.222222
yyuu/botornado
boto/gs/resumable_upload_handler.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/gs/resumable_upload_handler.py#L478-L584
def send_file(self, key, fp, headers, cb=None, num_cb=10): """ Upload a file to a key into a bucket on GS, using GS resumable upload protocol. :type key: :class:`boto.s3.key.Key` or subclass :param key: The Key object to which data is to be uploaded :typ...
[ "def", "send_file", "(", "self", ",", "key", ",", "fp", ",", "headers", ",", "cb", "=", "None", ",", "num_cb", "=", "10", ")", ":", "if", "not", "headers", ":", "headers", "=", "{", "}", "fp", ".", "seek", "(", "0", ",", "os", ".", "SEEK_END", ...
Upload a file to a key into a bucket on GS, using GS resumable upload protocol. :type key: :class:`boto.s3.key.Key` or subclass :param key: The Key object to which data is to be uploaded :type fp: file-like object :param fp: The file pointer to upload ...
[ "Upload", "a", "file", "to", "a", "key", "into", "a", "bucket", "on", "GS", "using", "GS", "resumable", "upload", "protocol", ".", ":", "type", "key", ":", ":", "class", ":", "boto", ".", "s3", ".", "key", ".", "Key", "or", "subclass", ":", "param"...
python
train
47.607477
Erotemic/ubelt
ubelt/util_stream.py
https://github.com/Erotemic/ubelt/blob/db802f3ad8abba025db74b54f86e6892b8927325/ubelt/util_stream.py#L130-L136
def log_part(self): """ Log what has been captured so far """ self.cap_stdout.seek(self._pos) text = self.cap_stdout.read() self._pos = self.cap_stdout.tell() self.parts.append(text) self.text = text
[ "def", "log_part", "(", "self", ")", ":", "self", ".", "cap_stdout", ".", "seek", "(", "self", ".", "_pos", ")", "text", "=", "self", ".", "cap_stdout", ".", "read", "(", ")", "self", ".", "_pos", "=", "self", ".", "cap_stdout", ".", "tell", "(", ...
Log what has been captured so far
[ "Log", "what", "has", "been", "captured", "so", "far" ]
python
valid
34.428571
rwl/pylon
pylon/solver.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L716-L723
def _costfcn(self, x): """ Evaluates the objective function, gradient and Hessian for OPF. """ f = self._f(x) df = self._df(x) d2f = self._d2f(x) return f, df, d2f
[ "def", "_costfcn", "(", "self", ",", "x", ")", ":", "f", "=", "self", ".", "_f", "(", "x", ")", "df", "=", "self", ".", "_df", "(", "x", ")", "d2f", "=", "self", ".", "_d2f", "(", "x", ")", "return", "f", ",", "df", ",", "d2f" ]
Evaluates the objective function, gradient and Hessian for OPF.
[ "Evaluates", "the", "objective", "function", "gradient", "and", "Hessian", "for", "OPF", "." ]
python
train
25.625
dmlc/gluon-nlp
scripts/bert/create_pretraining_data.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/bert/create_pretraining_data.py#L244-L266
def write_to_files_rec(instances, tokenizer, max_seq_length, max_predictions_per_seq, output_files): """Create IndexedRecordIO files from `TrainingInstance`s.""" writers = [] for output_file in output_files: writers.append( mx.recordio.MXIndexedRecordIO( ...
[ "def", "write_to_files_rec", "(", "instances", ",", "tokenizer", ",", "max_seq_length", ",", "max_predictions_per_seq", ",", "output_files", ")", ":", "writers", "=", "[", "]", "for", "output_file", "in", "output_files", ":", "writers", ".", "append", "(", "mx",...
Create IndexedRecordIO files from `TrainingInstance`s.
[ "Create", "IndexedRecordIO", "files", "from", "TrainingInstance", "s", "." ]
python
train
37.782609
googleads/googleads-python-lib
googleads/adwords.py
https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/adwords.py#L2453-L2491
def HasNext(self, page): """Checks if there is still a page left to query. This method is meant to be used with NextPage(). When using DataService, the paging mechanism is different from other services. For details, see https://developers.google.com/adwords/api/docs/guides/bid-landscapes#paging_through...
[ "def", "HasNext", "(", "self", ",", "page", ")", ":", "if", "self", ".", "_start_index", "is", "None", ":", "raise", "ValueError", "(", "'Cannot page through query with no LIMIT clause.'", ")", "if", "page", "is", "None", ":", "raise", "ValueError", "(", "'The...
Checks if there is still a page left to query. This method is meant to be used with NextPage(). When using DataService, the paging mechanism is different from other services. For details, see https://developers.google.com/adwords/api/docs/guides/bid-landscapes#paging_through_results. Args: page:...
[ "Checks", "if", "there", "is", "still", "a", "page", "left", "to", "query", "." ]
python
train
43.051282
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/device_directory/device_directory.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/device_directory/device_directory.py#L290-L305
def list_device_events(self, **kwargs): """List all device logs. :param int limit: The number of logs to retrieve. :param str order: The ordering direction, ascending (asc) or descending (desc) :param str after: Get logs after/starting at given `device_event_id` :par...
[ "def", "list_device_events", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_verify_sort_options", "(", "kwargs", ")", "kwargs", "=", "self", ".", "_verify_filters", "(", "kwargs", ",", "DeviceEvent", ",", "True", ")", "api", ...
List all device logs. :param int limit: The number of logs to retrieve. :param str order: The ordering direction, ascending (asc) or descending (desc) :param str after: Get logs after/starting at given `device_event_id` :param dict filters: Dictionary of filters to apply. ...
[ "List", "all", "device", "logs", "." ]
python
train
44.875
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Client.py
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1050-L1063
def __new_request_id(self): """requestId follows form "pre num" where pre is some random ascii prefix EG 6 chars long and num is an ever increasing number (self.__reqnum). MUST be called within self.__requests lock """ while True: # Since seqnum wraps on 2^64 at most, this sh...
[ "def", "__new_request_id", "(", "self", ")", ":", "while", "True", ":", "# Since seqnum wraps on 2^64 at most, this should always fit into 32 chars (QAPI request id limit)", "with", "self", ".", "__seqnum_lock", ":", "requestId", "=", "\"%s%d\"", "%", "(", "self", ".", "_...
requestId follows form "pre num" where pre is some random ascii prefix EG 6 chars long and num is an ever increasing number (self.__reqnum). MUST be called within self.__requests lock
[ "requestId", "follows", "form", "pre", "num", "where", "pre", "is", "some", "random", "ascii", "prefix", "EG", "6", "chars", "long", "and", "num", "is", "an", "ever", "increasing", "number", "(", "self", ".", "__reqnum", ")", ".", "MUST", "be", "called",...
python
train
50.428571
lpantano/seqcluster
seqcluster/libs/thinkbayes.py
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/thinkbayes.py#L926-L933
def Scale(self, factor): """Multiplies the xs by a factor. factor: what to multiply by """ new = self.Copy() new.xs = [x * factor for x in self.xs] return new
[ "def", "Scale", "(", "self", ",", "factor", ")", ":", "new", "=", "self", ".", "Copy", "(", ")", "new", ".", "xs", "=", "[", "x", "*", "factor", "for", "x", "in", "self", ".", "xs", "]", "return", "new" ]
Multiplies the xs by a factor. factor: what to multiply by
[ "Multiplies", "the", "xs", "by", "a", "factor", "." ]
python
train
25
adaptive-learning/proso-apps
proso/conversion.py
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso/conversion.py#L9-L28
def str2type(value): """ Take a string and convert it to a value of proper type. .. testsetup:: from proso.coversion import str2type .. doctest:: >>> print(str2type("[1, 2, 3]") [1, 2, 3] """ if not isinstance(value, str): return value ...
[ "def", "str2type", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "str", ")", ":", "return", "value", "try", ":", "return", "json", ".", "loads", "(", "value", ")", "except", "JSONDecodeError", ":", "return", "value" ]
Take a string and convert it to a value of proper type. .. testsetup:: from proso.coversion import str2type .. doctest:: >>> print(str2type("[1, 2, 3]") [1, 2, 3]
[ "Take", "a", "string", "and", "convert", "it", "to", "a", "value", "of", "proper", "type", "." ]
python
train
19.4
gagneurlab/concise
concise/legacy/concise.py
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/concise.py#L1062-L1098
def from_dict(cls, obj_dict): """ Load the object from a dictionary (produced with :py:func:`Concise.to_dict`) Returns: Concise: Loaded Concise object. """ # convert the output into a proper form obj_dict['output'] = helper.rec_dict_to_numpy_dict(obj_dict["o...
[ "def", "from_dict", "(", "cls", ",", "obj_dict", ")", ":", "# convert the output into a proper form", "obj_dict", "[", "'output'", "]", "=", "helper", ".", "rec_dict_to_numpy_dict", "(", "obj_dict", "[", "\"output\"", "]", ")", "helper", ".", "dict_to_numpy_dict", ...
Load the object from a dictionary (produced with :py:func:`Concise.to_dict`) Returns: Concise: Loaded Concise object.
[ "Load", "the", "object", "from", "a", "dictionary", "(", "produced", "with", ":", "py", ":", "func", ":", "Concise", ".", "to_dict", ")" ]
python
train
36.378378
azraq27/neural
neural/dsets.py
https://github.com/azraq27/neural/blob/fe91bfeecbf73ad99708cf5dca66cb61fcd529f5/neural/dsets.py#L301-L307
def bounding_box(dset): '''return the coordinates (in RAI) of the corners of a box enclosing the data in ``dset``''' o = nl.run(["3dAutobox","-input",dset]) ijk_coords = re.findall(r'[xyz]=(\d+)\.\.(\d+)',o.output) from_rai = ijk_to_xyz(dset,[float(x[0]) for x in ijk_coords]) to_rai = ijk_to_xyz(dse...
[ "def", "bounding_box", "(", "dset", ")", ":", "o", "=", "nl", ".", "run", "(", "[", "\"3dAutobox\"", ",", "\"-input\"", ",", "dset", "]", ")", "ijk_coords", "=", "re", ".", "findall", "(", "r'[xyz]=(\\d+)\\.\\.(\\d+)'", ",", "o", ".", "output", ")", "f...
return the coordinates (in RAI) of the corners of a box enclosing the data in ``dset``
[ "return", "the", "coordinates", "(", "in", "RAI", ")", "of", "the", "corners", "of", "a", "box", "enclosing", "the", "data", "in", "dset" ]
python
train
54.142857
ionelmc/python-manhole
src/manhole/__init__.py
https://github.com/ionelmc/python-manhole/blob/6a519a1f25142b047e814c6d00f4ef404856a15d/src/manhole/__init__.py#L284-L335
def handle_connection_repl(client): """ Handles connection. """ client.settimeout(None) # # disable this till we have evidence that it's needed # client.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 0) # # Note: setting SO_RCVBUF on UDS has no effect, see: http://man7.org/linux/man-pages/m...
[ "def", "handle_connection_repl", "(", "client", ")", ":", "client", ".", "settimeout", "(", "None", ")", "# # disable this till we have evidence that it's needed", "# client.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 0)", "# # Note: setting SO_RCVBUF on UDS has no effect, see: http:...
Handles connection.
[ "Handles", "connection", "." ]
python
train
36.903846
veripress/veripress
veripress/model/parsers.py
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/parsers.py#L58-L71
def remove_read_more_sep(self, raw_content): """ Removes the first read_more_sep that occurs in raw_content. Subclasses should call this method to preprocess raw_content. """ if self._read_more_exp is None: return raw_content sp = self._read_more_exp.split(ra...
[ "def", "remove_read_more_sep", "(", "self", ",", "raw_content", ")", ":", "if", "self", ".", "_read_more_exp", "is", "None", ":", "return", "raw_content", "sp", "=", "self", ".", "_read_more_exp", ".", "split", "(", "raw_content", ",", "maxsplit", "=", "1", ...
Removes the first read_more_sep that occurs in raw_content. Subclasses should call this method to preprocess raw_content.
[ "Removes", "the", "first", "read_more_sep", "that", "occurs", "in", "raw_content", ".", "Subclasses", "should", "call", "this", "method", "to", "preprocess", "raw_content", "." ]
python
train
35.714286
pydata/xarray
xarray/core/ops.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/ops.py#L168-L191
def where_method(self, cond, other=dtypes.NA): """Return elements from `self` or `other` depending on `cond`. Parameters ---------- cond : DataArray or Dataset with boolean dtype Locations at which to preserve this objects values. other : scalar, DataArray or Dataset, optional Value...
[ "def", "where_method", "(", "self", ",", "cond", ",", "other", "=", "dtypes", ".", "NA", ")", ":", "from", ".", "computation", "import", "apply_ufunc", "# alignment for three arguments is complicated, so don't support it yet", "join", "=", "'inner'", "if", "other", ...
Return elements from `self` or `other` depending on `cond`. Parameters ---------- cond : DataArray or Dataset with boolean dtype Locations at which to preserve this objects values. other : scalar, DataArray or Dataset, optional Value to use for locations in this object where ``cond`` is...
[ "Return", "elements", "from", "self", "or", "other", "depending", "on", "cond", "." ]
python
train
36.666667
fishtown-analytics/dbt
core/dbt/adapters/cache.py
https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/adapters/cache.py#L19-L25
def _make_key(relation): """Make _ReferenceKeys with lowercase values for the cache so we don't have to keep track of quoting """ return _ReferenceKey(_lower(relation.database), _lower(relation.schema), _lower(relation.identifier))
[ "def", "_make_key", "(", "relation", ")", ":", "return", "_ReferenceKey", "(", "_lower", "(", "relation", ".", "database", ")", ",", "_lower", "(", "relation", ".", "schema", ")", ",", "_lower", "(", "relation", ".", "identifier", ")", ")" ]
Make _ReferenceKeys with lowercase values for the cache so we don't have to keep track of quoting
[ "Make", "_ReferenceKeys", "with", "lowercase", "values", "for", "the", "cache", "so", "we", "don", "t", "have", "to", "keep", "track", "of", "quoting" ]
python
train
41.571429
awslabs/aws-shell
awsshell/ui.py
https://github.com/awslabs/aws-shell/blob/8950f03d9d720879890af6c11537b8f9789ce5a9/awsshell/ui.py#L28-L197
def create_default_layout(app, message='', lexer=None, is_password=False, reserve_space_for_menu=False, get_prompt_tokens=None, get_bottom_toolbar_tokens=None, display_completions_in_columns...
[ "def", "create_default_layout", "(", "app", ",", "message", "=", "''", ",", "lexer", "=", "None", ",", "is_password", "=", "False", ",", "reserve_space_for_menu", "=", "False", ",", "get_prompt_tokens", "=", "None", ",", "get_bottom_toolbar_tokens", "=", "None",...
Generate default layout. Returns a ``Layout`` instance. :param message: Text to be used as prompt. :param lexer: Lexer to be used for the highlighting. :param is_password: `bool` or `CLIFilter`. When True, display input as '*'. :param reserve_space_for_menu: When True, make sure that a minimal hei...
[ "Generate", "default", "layout", "." ]
python
train
40.670588
dereneaton/ipyrad
ipyrad/assemble/cluster_within.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/cluster_within.py#L1161-L1263
def cluster(data, sample, nthreads, force): """ Calls vsearch for clustering. cov varies by data type, values were chosen based on experience, but could be edited by users """ ## get the dereplicated reads if "reference" in data.paramsdict["assembly_method"]: derephandle = os.path.join(...
[ "def", "cluster", "(", "data", ",", "sample", ",", "nthreads", ",", "force", ")", ":", "## get the dereplicated reads", "if", "\"reference\"", "in", "data", ".", "paramsdict", "[", "\"assembly_method\"", "]", ":", "derephandle", "=", "os", ".", "path", ".", ...
Calls vsearch for clustering. cov varies by data type, values were chosen based on experience, but could be edited by users
[ "Calls", "vsearch", "for", "clustering", ".", "cov", "varies", "by", "data", "type", "values", "were", "chosen", "based", "on", "experience", "but", "could", "be", "edited", "by", "users" ]
python
valid
40.087379
allenai/allennlp
allennlp/models/model.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/model.py#L240-L285
def _load(cls, config: Params, serialization_dir: str, weights_file: str = None, cuda_device: int = -1) -> 'Model': """ Instantiates an already-trained model, based on the experiment configuration and some optional overrides. """ ...
[ "def", "_load", "(", "cls", ",", "config", ":", "Params", ",", "serialization_dir", ":", "str", ",", "weights_file", ":", "str", "=", "None", ",", "cuda_device", ":", "int", "=", "-", "1", ")", "->", "'Model'", ":", "weights_file", "=", "weights_file", ...
Instantiates an already-trained model, based on the experiment configuration and some optional overrides.
[ "Instantiates", "an", "already", "-", "trained", "model", "based", "on", "the", "experiment", "configuration", "and", "some", "optional", "overrides", "." ]
python
train
49.195652
datastax/python-driver
cassandra/policies.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/policies.py#L815-L840
def on_unavailable(self, query, consistency, required_replicas, alive_replicas, retry_num): """ This is called when the coordinator node determines that a read or write operation cannot be successful because the number of live replicas are too low to meet the requested :class:`.Consisten...
[ "def", "on_unavailable", "(", "self", ",", "query", ",", "consistency", ",", "required_replicas", ",", "alive_replicas", ",", "retry_num", ")", ":", "return", "(", "self", ".", "RETRY_NEXT_HOST", ",", "None", ")", "if", "retry_num", "==", "0", "else", "(", ...
This is called when the coordinator node determines that a read or write operation cannot be successful because the number of live replicas are too low to meet the requested :class:`.ConsistencyLevel`. This means that the read or write operation was never forwarded to any replicas. ...
[ "This", "is", "called", "when", "the", "coordinator", "node", "determines", "that", "a", "read", "or", "write", "operation", "cannot", "be", "successful", "because", "the", "number", "of", "live", "replicas", "are", "too", "low", "to", "meet", "the", "reques...
python
train
51.346154
sampsyo/confuse
confuse.py
https://github.com/sampsyo/confuse/blob/9ff0992e30470f6822824711950e6dd906e253fb/confuse.py#L1198-L1205
def value(self, view, template=None): """Get a dict with the same keys as the template and values validated according to the value types. """ out = AttrDict() for key, typ in self.subtemplates.items(): out[key] = typ.value(view[key], self) return out
[ "def", "value", "(", "self", ",", "view", ",", "template", "=", "None", ")", ":", "out", "=", "AttrDict", "(", ")", "for", "key", ",", "typ", "in", "self", ".", "subtemplates", ".", "items", "(", ")", ":", "out", "[", "key", "]", "=", "typ", "....
Get a dict with the same keys as the template and values validated according to the value types.
[ "Get", "a", "dict", "with", "the", "same", "keys", "as", "the", "template", "and", "values", "validated", "according", "to", "the", "value", "types", "." ]
python
train
37.875
gwastro/pycbc-glue
pycbc_glue/pipeline.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/pipeline.py#L1602-L1607
def add_maxjobs_category(self,categoryName,maxJobsNum): """ Add a category to this DAG called categoryName with a maxjobs of maxJobsNum. @param node: Add (categoryName,maxJobsNum) tuple to CondorDAG.__maxjobs_categories. """ self.__maxjobs_categories.append((str(categoryName),str(maxJobsNum)))
[ "def", "add_maxjobs_category", "(", "self", ",", "categoryName", ",", "maxJobsNum", ")", ":", "self", ".", "__maxjobs_categories", ".", "append", "(", "(", "str", "(", "categoryName", ")", ",", "str", "(", "maxJobsNum", ")", ")", ")" ]
Add a category to this DAG called categoryName with a maxjobs of maxJobsNum. @param node: Add (categoryName,maxJobsNum) tuple to CondorDAG.__maxjobs_categories.
[ "Add", "a", "category", "to", "this", "DAG", "called", "categoryName", "with", "a", "maxjobs", "of", "maxJobsNum", "." ]
python
train
51.5
orb-framework/orb
orb/core/column.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/column.py#L173-L191
def dbStore(self, typ, py_value): """ Prepares to store this column for the a particular backend database. :param backend: <orb.Database> :param py_value: <variant> :param context: <orb.Context> :return: <variant> """ # convert base types to work in the ...
[ "def", "dbStore", "(", "self", ",", "typ", ",", "py_value", ")", ":", "# convert base types to work in the database", "if", "isinstance", "(", "py_value", ",", "(", "list", ",", "tuple", ",", "set", ")", ")", ":", "py_value", "=", "tuple", "(", "(", "self"...
Prepares to store this column for the a particular backend database. :param backend: <orb.Database> :param py_value: <variant> :param context: <orb.Context> :return: <variant>
[ "Prepares", "to", "store", "this", "column", "for", "the", "a", "particular", "backend", "database", "." ]
python
train
32.947368
ElementAI/greensim
greensim/__init__.py
https://github.com/ElementAI/greensim/blob/f160e8b57d69f6ef469f2e991cc07b7721e08a91/greensim/__init__.py#L606-L637
def happens(intervals: Iterable[float], name: Optional[str] = None) -> Callable: """ Decorator used to set up a process that adds a new instance of another process at intervals dictated by the given sequence (which may be infinite). Example: the following program runs process named `my_process` 5 times...
[ "def", "happens", "(", "intervals", ":", "Iterable", "[", "float", "]", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Callable", ":", "def", "hook", "(", "event", ":", "Callable", ")", ":", "def", "make_happen", "(", "*", ...
Decorator used to set up a process that adds a new instance of another process at intervals dictated by the given sequence (which may be infinite). Example: the following program runs process named `my_process` 5 times, each time spaced by 2.0 time units. ``` from itertools import repeat sim = Si...
[ "Decorator", "used", "to", "set", "up", "a", "process", "that", "adds", "a", "new", "instance", "of", "another", "process", "at", "intervals", "dictated", "by", "the", "given", "sequence", "(", "which", "may", "be", "infinite", ")", "." ]
python
train
30.15625
SBRG/ssbio
ssbio/protein/sequence/utils/utils.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/utils/utils.py#L6-L24
def cast_to_str(obj): """Return a string representation of a Seq or SeqRecord. Args: obj (str, Seq, SeqRecord): Biopython Seq or SeqRecord Returns: str: String representation of the sequence """ if isinstance(obj, str): return obj if isinstance(obj, Seq): retu...
[ "def", "cast_to_str", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "return", "obj", "if", "isinstance", "(", "obj", ",", "Seq", ")", ":", "return", "str", "(", "obj", ")", "if", "isinstance", "(", "obj", ",", "SeqReco...
Return a string representation of a Seq or SeqRecord. Args: obj (str, Seq, SeqRecord): Biopython Seq or SeqRecord Returns: str: String representation of the sequence
[ "Return", "a", "string", "representation", "of", "a", "Seq", "or", "SeqRecord", "." ]
python
train
24.368421
GaryLee/cmdlet
cmdlet/cmds.py
https://github.com/GaryLee/cmdlet/blob/5852a63fc2c7dd723a3d7abe18455f8dacb49433/cmdlet/cmds.py#L329-L371
def match(prev, pattern, *args, **kw): """The pipe greps the data passed from previous generator according to given regular expression. The data passed to next pipe is MatchObject , dict or tuple which determined by 'to' in keyword argument. By default, match pipe yields MatchObject. Use 'to' in keywor...
[ "def", "match", "(", "prev", ",", "pattern", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "to", "=", "'to'", "in", "kw", "and", "kw", ".", "pop", "(", "'to'", ")", "pattern_obj", "=", "re", ".", "compile", "(", "pattern", ",", "*", "args", ...
The pipe greps the data passed from previous generator according to given regular expression. The data passed to next pipe is MatchObject , dict or tuple which determined by 'to' in keyword argument. By default, match pipe yields MatchObject. Use 'to' in keyword argument to change the type of match res...
[ "The", "pipe", "greps", "the", "data", "passed", "from", "previous", "generator", "according", "to", "given", "regular", "expression", ".", "The", "data", "passed", "to", "next", "pipe", "is", "MatchObject", "dict", "or", "tuple", "which", "determined", "by", ...
python
valid
34.813953
Damgaard/PyImgur
pyimgur/__init__.py
https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L554-L600
def download(self, path='', name=None, overwrite=False, size=None): """ Download the image. :param path: The image will be downloaded to the folder specified at path, if path is None (default) then the current working directory will be used. :param name: The name...
[ "def", "download", "(", "self", ",", "path", "=", "''", ",", "name", "=", "None", ",", "overwrite", "=", "False", ",", "size", "=", "None", ")", ":", "def", "save_as", "(", "filename", ")", ":", "local_path", "=", "os", ".", "path", ".", "join", ...
Download the image. :param path: The image will be downloaded to the folder specified at path, if path is None (default) then the current working directory will be used. :param name: The name the image will be stored as (not including file extension). If name is None...
[ "Download", "the", "image", "." ]
python
train
50.531915
pyrapt/rapt
rapt/treebrd/attributes.py
https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/attributes.py#L40-L51
def merge(cls, first, second): """ Return an AttributeList that is the result of merging first with second. """ merged = AttributeList([], None) assert (isinstance(first, AttributeList)) assert (isinstance(second, AttributeList)) merged._contents = first._content...
[ "def", "merge", "(", "cls", ",", "first", ",", "second", ")", ":", "merged", "=", "AttributeList", "(", "[", "]", ",", "None", ")", "assert", "(", "isinstance", "(", "first", ",", "AttributeList", ")", ")", "assert", "(", "isinstance", "(", "second", ...
Return an AttributeList that is the result of merging first with second.
[ "Return", "an", "AttributeList", "that", "is", "the", "result", "of", "merging", "first", "with", "second", "." ]
python
train
32
QualiSystems/vCenterShell
package/cloudshell/cp/vcenter/commands/connect_dvswitch.py
https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/connect_dvswitch.py#L25-L68
def connect_to_networks(self, si, logger, vm_uuid, vm_network_mappings, default_network_name, reserved_networks, dv_switch_name, promiscuous_mode): """ Connect VM to Network :param si: VmWare Service Instance - defined connection to vCenter :param logger: ...
[ "def", "connect_to_networks", "(", "self", ",", "si", ",", "logger", ",", "vm_uuid", ",", "vm_network_mappings", ",", "default_network_name", ",", "reserved_networks", ",", "dv_switch_name", ",", "promiscuous_mode", ")", ":", "vm", "=", "self", ".", "pv_service", ...
Connect VM to Network :param si: VmWare Service Instance - defined connection to vCenter :param logger: :param vm_uuid: <str> UUID for VM :param vm_network_mappings: <collection of 'VmNetworkMapping'> :param default_network_name: <str> Full Network name - likes 'DataCenterName/Ne...
[ "Connect", "VM", "to", "Network", ":", "param", "si", ":", "VmWare", "Service", "Instance", "-", "defined", "connection", "to", "vCenter", ":", "param", "logger", ":", ":", "param", "vm_uuid", ":", "<str", ">", "UUID", "for", "VM", ":", "param", "vm_netw...
python
train
51.181818
csparpa/pyowm
pyowm/weatherapi25/historian.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/historian.py#L125-L146
def min_temperature(self, unit='kelvin'): """Returns a tuple containing the min value in the temperature series preceeded by its timestamp :param unit: the unit of measure for the temperature values. May be among: '*kelvin*' (default), '*celsius*' or '*fahrenheit*' :...
[ "def", "min_temperature", "(", "self", ",", "unit", "=", "'kelvin'", ")", ":", "if", "unit", "not", "in", "(", "'kelvin'", ",", "'celsius'", ",", "'fahrenheit'", ")", ":", "raise", "ValueError", "(", "\"Invalid value for parameter 'unit'\"", ")", "minimum", "=...
Returns a tuple containing the min value in the temperature series preceeded by its timestamp :param unit: the unit of measure for the temperature values. May be among: '*kelvin*' (default), '*celsius*' or '*fahrenheit*' :type unit: str :returns: a tuple :rai...
[ "Returns", "a", "tuple", "containing", "the", "min", "value", "in", "the", "temperature", "series", "preceeded", "by", "its", "timestamp", ":", "param", "unit", ":", "the", "unit", "of", "measure", "for", "the", "temperature", "values", ".", "May", "be", "...
python
train
46.318182
mcs07/MolVS
molvs/standardize.py
https://github.com/mcs07/MolVS/blob/d815fe52d160abcecbcbf117e6437bf727dbd8ad/molvs/standardize.py#L78-L99
def standardize(self, mol): """Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :py:func:`~rdkit.Chem.rdmolops.RemoveHs`, RDKit :py:func:`~rdkit.Chem.rdmolops.SanitizeMol`, :class:`~molvs.metal.MetalDisconnector`, :cla...
[ "def", "standardize", "(", "self", ",", "mol", ")", ":", "mol", "=", "copy", ".", "deepcopy", "(", "mol", ")", "Chem", ".", "SanitizeMol", "(", "mol", ")", "mol", "=", "Chem", ".", "RemoveHs", "(", "mol", ")", "mol", "=", "self", ".", "disconnect_m...
Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :py:func:`~rdkit.Chem.rdmolops.RemoveHs`, RDKit :py:func:`~rdkit.Chem.rdmolops.SanitizeMol`, :class:`~molvs.metal.MetalDisconnector`, :class:`~molvs.normalize.Normalizer`, ...
[ "Return", "a", "standardized", "version", "the", "given", "molecule", "." ]
python
test
44.090909
dgketchum/satellite_image
sat_image/warped_vrt.py
https://github.com/dgketchum/satellite_image/blob/0207fbb7b2bbf14f4307db65489bb4d4c5b92f52/sat_image/warped_vrt.py#L30-L121
def warp_vrt(directory, delete_extra=False, use_band_map=False, overwrite=False, remove_bqa=True, return_profile=False): """ Read in image geometry, resample subsequent images to same grid. The purpose of this function is to snap many Landsat images to one geometry. Use Landsat578 to download ...
[ "def", "warp_vrt", "(", "directory", ",", "delete_extra", "=", "False", ",", "use_band_map", "=", "False", ",", "overwrite", "=", "False", ",", "remove_bqa", "=", "True", ",", "return_profile", "=", "False", ")", ":", "if", "'resample_meta.txt'", "in", "os",...
Read in image geometry, resample subsequent images to same grid. The purpose of this function is to snap many Landsat images to one geometry. Use Landsat578 to download and unzip them, then run them through this to get identical geometries for analysis. Files :param use_band_map: :param delete_extr...
[ "Read", "in", "image", "geometry", "resample", "subsequent", "images", "to", "same", "grid", "." ]
python
train
38.25
DeepHorizons/iarm
iarm/arm_instructions/arithmetic.py
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/arithmetic.py#L37-L80
def ADD(self, params): """ ADD [Rx,] Ry, [Rz, PC] ADD [Rx,] [SP, PC], #imm10_4 ADD [SP,] SP, #imm9_4 Add Ry and Rz and store the result in Rx Rx, Ry, and Rz can be any register If Rx is omitted, then it is assumed to be Ry """ # This instruction a...
[ "def", "ADD", "(", "self", ",", "params", ")", ":", "# This instruction allows for an optional destination register", "# If it is omitted, then it is assumed to be Rb", "# As defined in http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0662b/index.html", "# TODO can we have ADD SP...
ADD [Rx,] Ry, [Rz, PC] ADD [Rx,] [SP, PC], #imm10_4 ADD [SP,] SP, #imm9_4 Add Ry and Rz and store the result in Rx Rx, Ry, and Rz can be any register If Rx is omitted, then it is assumed to be Ry
[ "ADD", "[", "Rx", "]", "Ry", "[", "Rz", "PC", "]", "ADD", "[", "Rx", "]", "[", "SP", "PC", "]", "#imm10_4", "ADD", "[", "SP", "]", "SP", "#imm9_4" ]
python
train
41.772727
deshima-dev/decode
decode/io/functions.py
https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/io/functions.py#L324-L350
def loadnetcdf(filename, copy=True): """Load a dataarray from a NetCDF file. Args: filename (str): Filename (*.nc). copy (bool): If True, dataarray is copied in memory. Default is True. Returns: dataarray (xarray.DataArray): Loaded dataarray. """ filename = str(Path(filenam...
[ "def", "loadnetcdf", "(", "filename", ",", "copy", "=", "True", ")", ":", "filename", "=", "str", "(", "Path", "(", "filename", ")", ".", "expanduser", "(", ")", ")", "if", "copy", ":", "dataarray", "=", "xr", ".", "open_dataarray", "(", "filename", ...
Load a dataarray from a NetCDF file. Args: filename (str): Filename (*.nc). copy (bool): If True, dataarray is copied in memory. Default is True. Returns: dataarray (xarray.DataArray): Loaded dataarray.
[ "Load", "a", "dataarray", "from", "a", "NetCDF", "file", "." ]
python
train
28.074074
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Platform/win32.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Platform/win32.py#L298-L322
def get_program_files_dir(): """ Get the location of the program files directory Returns ------- """ # Now see if we can look in the registry... val = '' if SCons.Util.can_read_reg: try: # Look for Windows Program Files directory k=SCons.Util.RegOpenKeyEx...
[ "def", "get_program_files_dir", "(", ")", ":", "# Now see if we can look in the registry...", "val", "=", "''", "if", "SCons", ".", "Util", ".", "can_read_reg", ":", "try", ":", "# Look for Windows Program Files directory", "k", "=", "SCons", ".", "Util", ".", "RegO...
Get the location of the program files directory Returns -------
[ "Get", "the", "location", "of", "the", "program", "files", "directory", "Returns", "-------" ]
python
train
32.24
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L2727-L2741
def enable_host_event_handler(self, host): """Enable event handlers for a host Format of the line that triggers function call:: ENABLE_HOST_EVENT_HANDLER;<host_name> :param host: host to edit :type host: alignak.objects.host.Host :return: None """ if not...
[ "def", "enable_host_event_handler", "(", "self", ",", "host", ")", ":", "if", "not", "host", ".", "event_handler_enabled", ":", "host", ".", "modified_attributes", "|=", "DICT_MODATTR", "[", "\"MODATTR_EVENT_HANDLER_ENABLED\"", "]", ".", "value", "host", ".", "eve...
Enable event handlers for a host Format of the line that triggers function call:: ENABLE_HOST_EVENT_HANDLER;<host_name> :param host: host to edit :type host: alignak.objects.host.Host :return: None
[ "Enable", "event", "handlers", "for", "a", "host", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
36.933333
greenbender/pynntp
nntp/nntp.py
https://github.com/greenbender/pynntp/blob/991a76331cdf5d8f9dbf5b18f6e29adc80749a2f/nntp/nntp.py#L758-L782
def list_active_times_gen(self): """Generator for the LIST ACTIVE.TIMES command. Generates a list of newsgroups including the creation time and who created them. See <http://tools.ietf.org/html/rfc3977#section-7.6.4> Yields: A tuple containing the name, creation da...
[ "def", "list_active_times_gen", "(", "self", ")", ":", "code", ",", "message", "=", "self", ".", "command", "(", "\"LIST ACTIVE.TIMES\"", ")", "if", "code", "!=", "215", ":", "raise", "NNTPReplyError", "(", "code", ",", "message", ")", "for", "line", "in",...
Generator for the LIST ACTIVE.TIMES command. Generates a list of newsgroups including the creation time and who created them. See <http://tools.ietf.org/html/rfc3977#section-7.6.4> Yields: A tuple containing the name, creation date as a datetime object and crea...
[ "Generator", "for", "the", "LIST", "ACTIVE", ".", "TIMES", "command", "." ]
python
test
35.92
DiamondLightSource/python-workflows
workflows/transport/stomp_transport.py
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/transport/stomp_transport.py#L293-L334
def _subscribe(self, sub_id, channel, callback, **kwargs): """Listen to a queue, notify via callback function. :param sub_id: ID for this subscription in the transport layer :param channel: Queue name to subscribe to :param callback: Function to be called when messages are received ...
[ "def", "_subscribe", "(", "self", ",", "sub_id", ",", "channel", ",", "callback", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "{", "}", "if", "kwargs", ".", "get", "(", "\"exclusive\"", ")", ":", "headers", "[", "\"activemq.exclusive\"", "]", "=...
Listen to a queue, notify via callback function. :param sub_id: ID for this subscription in the transport layer :param channel: Queue name to subscribe to :param callback: Function to be called when messages are received :param **kwargs: Further parameters for the transport layer. For ex...
[ "Listen", "to", "a", "queue", "notify", "via", "callback", "function", ".", ":", "param", "sub_id", ":", "ID", "for", "this", "subscription", "in", "the", "transport", "layer", ":", "param", "channel", ":", "Queue", "name", "to", "subscribe", "to", ":", ...
python
train
51.47619
michael-lazar/rtv
rtv/packages/praw/objects.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1796-L1805
def edit(self, *args, **kwargs): """Edit this multireddit. Convenience function that utilizes :meth:`.MultiredditMixin.edit_multireddit` populating the `name` parameter. """ return self.reddit_session.edit_multireddit(name=self.name, *args, ...
[ "def", "edit", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "reddit_session", ".", "edit_multireddit", "(", "name", "=", "self", ".", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Edit this multireddit. Convenience function that utilizes :meth:`.MultiredditMixin.edit_multireddit` populating the `name` parameter.
[ "Edit", "this", "multireddit", "." ]
python
train
34.3
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/image.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/image.py#L306-L330
def _build_interpolation(self): """Rebuild the _data_lookup_fn using different interpolations within the shader """ interpolation = self._interpolation self._data_lookup_fn = self._interpolation_fun[interpolation] self.shared_program.frag['get_data'] = self._data_lookup_f...
[ "def", "_build_interpolation", "(", "self", ")", ":", "interpolation", "=", "self", ".", "_interpolation", "self", ".", "_data_lookup_fn", "=", "self", ".", "_interpolation_fun", "[", "interpolation", "]", "self", ".", "shared_program", ".", "frag", "[", "'get_d...
Rebuild the _data_lookup_fn using different interpolations within the shader
[ "Rebuild", "the", "_data_lookup_fn", "using", "different", "interpolations", "within", "the", "shader" ]
python
train
42.36
Rikanishu/static-bundle
static_bundle/builders.py
https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/builders.py#L157-L170
def render_asset(self, name): """ Render all includes in asset by names :type name: str|unicode :rtype: str|unicode """ result = "" if self.has_asset(name): asset = self.get_asset(name) if asset.files: for f in asset.files:...
[ "def", "render_asset", "(", "self", ",", "name", ")", ":", "result", "=", "\"\"", "if", "self", ".", "has_asset", "(", "name", ")", ":", "asset", "=", "self", ".", "get_asset", "(", "name", ")", "if", "asset", ".", "files", ":", "for", "f", "in", ...
Render all includes in asset by names :type name: str|unicode :rtype: str|unicode
[ "Render", "all", "includes", "in", "asset", "by", "names" ]
python
valid
27.642857
bokeh/bokeh
bokeh/util/serialization.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L295-L328
def transform_array(array, force_list=False, buffers=None): ''' Transform a NumPy arrays into serialized format Converts un-serializable dtypes and returns JSON serializable format Args: array (np.ndarray) : a NumPy array to be transformed force_list (bool, optional) : whether to only ...
[ "def", "transform_array", "(", "array", ",", "force_list", "=", "False", ",", "buffers", "=", "None", ")", ":", "array", "=", "convert_datetime_array", "(", "array", ")", "return", "serialize_array", "(", "array", ",", "force_list", "=", "force_list", ",", "...
Transform a NumPy arrays into serialized format Converts un-serializable dtypes and returns JSON serializable format Args: array (np.ndarray) : a NumPy array to be transformed force_list (bool, optional) : whether to only output to standard lists This function can encode some d...
[ "Transform", "a", "NumPy", "arrays", "into", "serialized", "format" ]
python
train
35.352941
DataBiosphere/toil
src/toil/fileStore.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/fileStore.py#L1822-L1844
def _getAllJobStates(workflowDir): """ Generator function that deserializes and yields the job state for every job on the node, one at a time. :param str workflowDir: The location of the workflow directory on the node. :return: dict with keys (jobName, jobPID, jobDir, deferredF...
[ "def", "_getAllJobStates", "(", "workflowDir", ")", ":", "jobStateFiles", "=", "[", "]", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "workflowDir", ")", ":", "for", "filename", "in", "files", ":", "if", "filename", "==", "'....
Generator function that deserializes and yields the job state for every job on the node, one at a time. :param str workflowDir: The location of the workflow directory on the node. :return: dict with keys (jobName, jobPID, jobDir, deferredFunctions) :rtype: dict
[ "Generator", "function", "that", "deserializes", "and", "yields", "the", "job", "state", "for", "every", "job", "on", "the", "node", "one", "at", "a", "time", "." ]
python
train
40.913043
yaz/yaz
yaz/task.py
https://github.com/yaz/yaz/blob/48c842fe053bf9cd6446c4b33fb081c65339aa48/yaz/task.py#L141-L182
def get_task_tree(white_list=None): """Returns a tree of Task instances The tree is comprised of dictionaries containing strings for keys and either dictionaries or Task instances for values. When WHITE_LIST is given, only the tasks and plugins in this list will become part of the task tree. The ...
[ "def", "get_task_tree", "(", "white_list", "=", "None", ")", ":", "assert", "white_list", "is", "None", "or", "isinstance", "(", "white_list", ",", "list", ")", ",", "type", "(", "white_list", ")", "if", "white_list", "is", "not", "None", ":", "white_list"...
Returns a tree of Task instances The tree is comprised of dictionaries containing strings for keys and either dictionaries or Task instances for values. When WHITE_LIST is given, only the tasks and plugins in this list will become part of the task tree. The WHITE_LIST may contain either strings, ...
[ "Returns", "a", "tree", "of", "Task", "instances" ]
python
valid
38.571429
kgiusti/pyngus
pyngus/container.py
https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/container.py#L53-L75
def need_processing(self): """A utility to help determine which connections need processing. Returns a triple of lists containing those connections that 0) need to read from the network, 1) need to write to the network, 2) waiting for pending timers to expire. The timer list is sorted w...
[ "def", "need_processing", "(", "self", ")", ":", "readers", "=", "[", "]", "writers", "=", "[", "]", "timer_heap", "=", "[", "]", "for", "c", "in", "iter", "(", "self", ".", "_connections", ".", "values", "(", ")", ")", ":", "if", "c", ".", "need...
A utility to help determine which connections need processing. Returns a triple of lists containing those connections that 0) need to read from the network, 1) need to write to the network, 2) waiting for pending timers to expire. The timer list is sorted with the connection next expiri...
[ "A", "utility", "to", "help", "determine", "which", "connections", "need", "processing", ".", "Returns", "a", "triple", "of", "lists", "containing", "those", "connections", "that", "0", ")", "need", "to", "read", "from", "the", "network", "1", ")", "need", ...
python
test
37.608696
wummel/linkchecker
setup.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/setup.py#L215-L240
def create_conf_file (self, data, directory=None): """Create local config file from given data (list of lines) in the directory (or current directory if not given).""" data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") ...
[ "def", "create_conf_file", "(", "self", ",", "data", ",", "directory", "=", "None", ")", ":", "data", ".", "insert", "(", "0", ",", "\"# this file is automatically created by setup.py\"", ")", "data", ".", "insert", "(", "0", ",", "\"# -*- coding: iso-8859-1 -*-\"...
Create local config file from given data (list of lines) in the directory (or current directory if not given).
[ "Create", "local", "config", "file", "from", "given", "data", "(", "list", "of", "lines", ")", "in", "the", "directory", "(", "or", "current", "directory", "if", "not", "given", ")", "." ]
python
train
48.961538
Fantomas42/django-blog-zinnia
zinnia/templatetags/zinnia.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/templatetags/zinnia.py#L136-L149
def get_similar_entries(context, number=5, template='zinnia/tags/entries_similar.html'): """ Return similar entries. """ entry = context.get('entry') if not entry: return {'template': template, 'entries': []} vectors = EntryPublishedVectorBuilder() entries = ...
[ "def", "get_similar_entries", "(", "context", ",", "number", "=", "5", ",", "template", "=", "'zinnia/tags/entries_similar.html'", ")", ":", "entry", "=", "context", ".", "get", "(", "'entry'", ")", "if", "not", "entry", ":", "return", "{", "'template'", ":"...
Return similar entries.
[ "Return", "similar", "entries", "." ]
python
train
29.142857
jlesquembre/jlle
jlle/releaser/pypi.py
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/pypi.py#L135-L154
def python_file_with_version(self): """Return Python filename with ``__version__`` marker, if configured. Enable this by adding a ``python-file-with-version`` option:: [zest.releaser] python-file-with-version = reinout/maurits.py Return None when nothing has been confi...
[ "def", "python_file_with_version", "(", "self", ")", ":", "default", "=", "None", "if", "self", ".", "config", "is", "None", ":", "return", "default", "try", ":", "result", "=", "self", ".", "config", ".", "get", "(", "'zest.releaser'", ",", "'python-file-...
Return Python filename with ``__version__`` marker, if configured. Enable this by adding a ``python-file-with-version`` option:: [zest.releaser] python-file-with-version = reinout/maurits.py Return None when nothing has been configured.
[ "Return", "Python", "filename", "with", "__version__", "marker", "if", "configured", "." ]
python
train
32.15
inasafe/inasafe
safe/gui/tools/wizard/step_kw33_multi_classifications.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw33_multi_classifications.py#L487-L510
def clear(self): """Clear current state.""" self.exposures = [] self.exposure_labels = [] self.exposure_combo_boxes = [] self.exposure_edit_buttons = [] self.mode = CHOOSE_MODE self.layer_purpose = None self.layer_mode = None self.special_case_ind...
[ "def", "clear", "(", "self", ")", ":", "self", ".", "exposures", "=", "[", "]", "self", ".", "exposure_labels", "=", "[", "]", "self", ".", "exposure_combo_boxes", "=", "[", "]", "self", ".", "exposure_edit_buttons", "=", "[", "]", "self", ".", "mode",...
Clear current state.
[ "Clear", "current", "state", "." ]
python
train
26.666667
google-research/batch-ppo
agents/parts/normalize.py
https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/parts/normalize.py#L81-L108
def update(self, value): """Update the mean and variance estimates. Args: value: Batch or single value tensor. Returns: Summary tensor. """ with tf.name_scope(self._name + '/update'): if value.shape.ndims == self._mean.shape.ndims: # Add a batch dimension if necessary. ...
[ "def", "update", "(", "self", ",", "value", ")", ":", "with", "tf", ".", "name_scope", "(", "self", ".", "_name", "+", "'/update'", ")", ":", "if", "value", ".", "shape", ".", "ndims", "==", "self", ".", "_mean", ".", "shape", ".", "ndims", ":", ...
Update the mean and variance estimates. Args: value: Batch or single value tensor. Returns: Summary tensor.
[ "Update", "the", "mean", "and", "variance", "estimates", "." ]
python
train
41.285714
MartinThoma/hwrt
hwrt/handwritten_data.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/handwritten_data.py#L352-L401
def _get_colors(segmentation): """Get a list of colors which is as long as the segmentation. Parameters ---------- segmentation : list of lists Returns ------- list A list of colors. """ symbol_count = len(segmentation) num_colors = symbol_count # See http://stacko...
[ "def", "_get_colors", "(", "segmentation", ")", ":", "symbol_count", "=", "len", "(", "segmentation", ")", "num_colors", "=", "symbol_count", "# See http://stackoverflow.com/a/20298116/562769", "color_array", "=", "[", "\"#000000\"", ",", "\"#FFFF00\"", ",", "\"#1CE6FF\...
Get a list of colors which is as long as the segmentation. Parameters ---------- segmentation : list of lists Returns ------- list A list of colors.
[ "Get", "a", "list", "of", "colors", "which", "is", "as", "long", "as", "the", "segmentation", "." ]
python
train
45.06
GeorgeArgyros/symautomata
symautomata/flex2fst.py
https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/flex2fst.py#L207-L217
def _create_states(self, states_num): """ Args: states_num (int): Number of States Returns: list: An initialized list """ states = [] for i in range(0, states_num): states.append(i) return states
[ "def", "_create_states", "(", "self", ",", "states_num", ")", ":", "states", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "states_num", ")", ":", "states", ".", "append", "(", "i", ")", "return", "states" ]
Args: states_num (int): Number of States Returns: list: An initialized list
[ "Args", ":", "states_num", "(", "int", ")", ":", "Number", "of", "States", "Returns", ":", "list", ":", "An", "initialized", "list" ]
python
train
25.181818