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
ska-sa/katcp-python
katcp/server.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/server.py#L1210-L1233
def reply(self, connection, reply, orig_req): """Send an asynchronous reply to an earlier request. Parameters ---------- connection : ClientConnection object The client to send the reply to. reply : Message object The reply message to send. orig_r...
[ "def", "reply", "(", "self", ",", "connection", ",", "reply", ",", "orig_req", ")", ":", "if", "isinstance", "(", "connection", ",", "ClientRequestConnection", ")", ":", "self", ".", "_logger", ".", "warn", "(", "'Deprecation warning: do not use self.reply() '", ...
Send an asynchronous reply to an earlier request. Parameters ---------- connection : ClientConnection object The client to send the reply to. reply : Message object The reply message to send. orig_req : Message object The request message being...
[ "Send", "an", "asynchronous", "reply", "to", "an", "earlier", "request", "." ]
python
train
41.583333
kyzima-spb/flask-pony
flask_pony/decorators.py
https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/decorators.py#L20-L27
def route(obj, rule, *args, **kwargs): """Decorator for the View classes.""" def decorator(cls): endpoint = kwargs.get('endpoint', camel_to_snake(cls.__name__)) kwargs['view_func'] = cls.as_view(endpoint) obj.add_url_rule(rule, *args, **kwargs) return cls return decorator
[ "def", "route", "(", "obj", ",", "rule", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "cls", ")", ":", "endpoint", "=", "kwargs", ".", "get", "(", "'endpoint'", ",", "camel_to_snake", "(", "cls", ".", "__name__", ")...
Decorator for the View classes.
[ "Decorator", "for", "the", "View", "classes", "." ]
python
train
38.625
TheHive-Project/Cortex-Analyzers
analyzers/VirusTotal/virustotal_api.py
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/VirusTotal/virustotal_api.py#L124-L139
def scan_url(self, this_url): """ Submit a URL to be scanned by VirusTotal. :param this_url: The URL that should be scanned. This parameter accepts a list of URLs (up to 4 with the standard request rate) so as to perform a batch scanning request with one single call. The ...
[ "def", "scan_url", "(", "self", ",", "this_url", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'url'", ":", "this_url", "}", "try", ":", "response", "=", "requests", ".", "post", "(", "self", ".", "base", "+", "'url/sca...
Submit a URL to be scanned by VirusTotal. :param this_url: The URL that should be scanned. This parameter accepts a list of URLs (up to 4 with the standard request rate) so as to perform a batch scanning request with one single call. The URLs must be separated ...
[ "Submit", "a", "URL", "to", "be", "scanned", "by", "VirusTotal", "." ]
python
train
48.0625
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L114-L123
def get_institute_graph_url(start, end): """ Pie chart comparing institutes usage. """ filename = get_institute_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
[ "def", "get_institute_graph_url", "(", "start", ",", "end", ")", ":", "filename", "=", "get_institute_graph_filename", "(", "start", ",", "end", ")", "urls", "=", "{", "'graph_url'", ":", "urlparse", ".", "urljoin", "(", "GRAPH_URL", ",", "filename", "+", "\...
Pie chart comparing institutes usage.
[ "Pie", "chart", "comparing", "institutes", "usage", "." ]
python
train
31.1
nickoala/telepot
telepot/__init__.py
https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L701-L707
def sendGame(self, chat_id, game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None): """ See: https://core.telegram.org/bots/api#sendgame """ p = _strip(locals()) return self._api_request('sendGame', _rectify(p))
[ "def", "sendGame", "(", "self", ",", "chat_id", ",", "game_short_name", ",", "disable_notification", "=", "None", ",", "reply_to_message_id", "=", "None", ",", "reply_markup", "=", "None", ")", ":", "p", "=", "_strip", "(", "locals", "(", ")", ")", "return...
See: https://core.telegram.org/bots/api#sendgame
[ "See", ":", "https", ":", "//", "core", ".", "telegram", ".", "org", "/", "bots", "/", "api#sendgame" ]
python
train
44.857143
base4sistemas/satcfe
satcfe/resposta/consultarstatusoperacional.py
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/consultarstatusoperacional.py#L123-L130
def status(self): """Nome amigável do campo ``ESTADO_OPERACAO``, conforme a "Tabela de Informações do Status do SAT". """ for valor, rotulo in ESTADOS_OPERACAO: if self.ESTADO_OPERACAO == valor: return rotulo return u'(desconhecido: {})'.format(self.ES...
[ "def", "status", "(", "self", ")", ":", "for", "valor", ",", "rotulo", "in", "ESTADOS_OPERACAO", ":", "if", "self", ".", "ESTADO_OPERACAO", "==", "valor", ":", "return", "rotulo", "return", "u'(desconhecido: {})'", ".", "format", "(", "self", ".", "ESTADO_OP...
Nome amigável do campo ``ESTADO_OPERACAO``, conforme a "Tabela de Informações do Status do SAT".
[ "Nome", "amigável", "do", "campo", "ESTADO_OPERACAO", "conforme", "a", "Tabela", "de", "Informações", "do", "Status", "do", "SAT", "." ]
python
train
40.875
flatangle/flatlib
flatlib/predictives/primarydirections.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/predictives/primarydirections.py#L200-L214
def _arc(self, prom, sig): """ Computes the in-zodiaco and in-mundo arcs between a promissor and a significator. """ arcm = arc(prom['ra'], prom['decl'], sig['ra'], sig['decl'], self.mcRA, self.lat) arcz = arc(prom['raZ'], prom['d...
[ "def", "_arc", "(", "self", ",", "prom", ",", "sig", ")", ":", "arcm", "=", "arc", "(", "prom", "[", "'ra'", "]", ",", "prom", "[", "'decl'", "]", ",", "sig", "[", "'ra'", "]", ",", "sig", "[", "'decl'", "]", ",", "self", ".", "mcRA", ",", ...
Computes the in-zodiaco and in-mundo arcs between a promissor and a significator.
[ "Computes", "the", "in", "-", "zodiaco", "and", "in", "-", "mundo", "arcs", "between", "a", "promissor", "and", "a", "significator", "." ]
python
train
31.866667
slickqa/python-client
slickqa/micromodels/fields.py
https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/micromodels/fields.py#L125-L140
def to_python(self): '''A :class:`datetime.datetime` object is returned.''' if self.data is None: return None # don't parse data that is already native if isinstance(self.data, datetime.datetime): return self.data elif self.use_int: return da...
[ "def", "to_python", "(", "self", ")", ":", "if", "self", ".", "data", "is", "None", ":", "return", "None", "# don't parse data that is already native", "if", "isinstance", "(", "self", ".", "data", ",", "datetime", ".", "datetime", ")", ":", "return", "self"...
A :class:`datetime.datetime` object is returned.
[ "A", ":", "class", ":", "datetime", ".", "datetime", "object", "is", "returned", "." ]
python
train
34.3125
tomduck/pandoc-xnos
pandocxnos/core.py
https://github.com/tomduck/pandoc-xnos/blob/df8e162d257a548cea7eebf597efb2c21a1a4ba3/pandocxnos/core.py#L676-L823
def replace_refs_factory(references, use_cleveref_default, use_eqref, plusname, starname, target): """Returns replace_refs(key, value, fmt, meta) action that replaces references with format-specific content. The content is determined using the 'references' dict, which associates re...
[ "def", "replace_refs_factory", "(", "references", ",", "use_cleveref_default", ",", "use_eqref", ",", "plusname", ",", "starname", ",", "target", ")", ":", "global", "_cleveref_tex_flag", "# pylint: disable=global-statement", "# Update global if clever referencing is required b...
Returns replace_refs(key, value, fmt, meta) action that replaces references with format-specific content. The content is determined using the 'references' dict, which associates reference labels with numbers or string tags (e.g., { 'fig:1':1, 'fig:2':2, ...}). If 'use_cleveref_default' is True, or if ...
[ "Returns", "replace_refs", "(", "key", "value", "fmt", "meta", ")", "action", "that", "replaces", "references", "with", "format", "-", "specific", "content", ".", "The", "content", "is", "determined", "using", "the", "references", "dict", "which", "associates", ...
python
train
42.297297
aouyar/PyMunin
pysysinfo/util.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/util.py#L64-L81
def socket_read(fp): """Buffered read from socket. Reads all data available from socket. @fp: File pointer for socket. @return: String of characters read from buffer. """ response = '' oldlen = 0 newlen = 0 while True: response += fp.read(buffSize) newlen = ...
[ "def", "socket_read", "(", "fp", ")", ":", "response", "=", "''", "oldlen", "=", "0", "newlen", "=", "0", "while", "True", ":", "response", "+=", "fp", ".", "read", "(", "buffSize", ")", "newlen", "=", "len", "(", "response", ")", "if", "newlen", "...
Buffered read from socket. Reads all data available from socket. @fp: File pointer for socket. @return: String of characters read from buffer.
[ "Buffered", "read", "from", "socket", ".", "Reads", "all", "data", "available", "from", "socket", "." ]
python
train
23.833333
openstack/python-scciclient
scciclient/irmc/scci.py
https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/scci.py#L336-L352
def get_client(host, userid, password, port=443, auth_method='basic', client_timeout=60, **kwargs): """get SCCI command partial function This function returns SCCI command partial function :param host: hostname or IP of iRMC :param userid: userid for iRMC with administrator privileges ...
[ "def", "get_client", "(", "host", ",", "userid", ",", "password", ",", "port", "=", "443", ",", "auth_method", "=", "'basic'", ",", "client_timeout", "=", "60", ",", "*", "*", "kwargs", ")", ":", "return", "functools", ".", "partial", "(", "scci_cmd", ...
get SCCI command partial function This function returns SCCI command partial function :param host: hostname or IP of iRMC :param userid: userid for iRMC with administrator privileges :param password: password for userid :param port: port number of iRMC :param auth_method: irmc_username :par...
[ "get", "SCCI", "command", "partial", "function" ]
python
train
44.235294
assemblerflow/flowcraft
flowcraft/generator/inspect.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/inspect.py#L477-L537
def _update_pipeline_status(self): """Parses the .nextflow.log file for signatures of pipeline status. It sets the :attr:`status_info` attribute. """ with open(self.log_file) as fh: try: first_line = next(fh) except: raise eh.Insp...
[ "def", "_update_pipeline_status", "(", "self", ")", ":", "with", "open", "(", "self", ".", "log_file", ")", "as", "fh", ":", "try", ":", "first_line", "=", "next", "(", "fh", ")", "except", ":", "raise", "eh", ".", "InspectionError", "(", "\"Could not re...
Parses the .nextflow.log file for signatures of pipeline status. It sets the :attr:`status_info` attribute.
[ "Parses", "the", ".", "nextflow", ".", "log", "file", "for", "signatures", "of", "pipeline", "status", ".", "It", "sets", "the", ":", "attr", ":", "status_info", "attribute", "." ]
python
test
38.52459
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/device_directory/apis/default_api.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/device_directory/apis/default_api.py#L927-L951
def device_query_list(self, **kwargs): # noqa: E501 """List device queries. # noqa: E501 List all device queries. The result will be paged into pages of 100. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynch...
[ "def", "device_query_list", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'", ")", ":", "return", "self", ".", "device_query_list_with...
List device queries. # noqa: E501 List all device queries. The result will be paged into pages of 100. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.device_query_list(asynchron...
[ "List", "device", "queries", ".", "#", "noqa", ":", "E501" ]
python
train
159.24
devassistant/devassistant
devassistant/dapi/__init__.py
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L651-L653
def _is_dir(self, f): '''Check if the given in-dap file is a directory''' return self._tar.getmember(f).type == tarfile.DIRTYPE
[ "def", "_is_dir", "(", "self", ",", "f", ")", ":", "return", "self", ".", "_tar", ".", "getmember", "(", "f", ")", ".", "type", "==", "tarfile", ".", "DIRTYPE" ]
Check if the given in-dap file is a directory
[ "Check", "if", "the", "given", "in", "-", "dap", "file", "is", "a", "directory" ]
python
train
47
pybel/pybel
src/pybel/io/lines.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/io/lines.py#L23-L32
def from_lines(lines: Iterable[str], **kwargs) -> BELGraph: """Load a BEL graph from an iterable over the lines of a BEL script. :param lines: An iterable of strings (the lines in a BEL script) The remaining keyword arguments are passed to :func:`pybel.io.line_utils.parse_lines`. """ graph = BELGr...
[ "def", "from_lines", "(", "lines", ":", "Iterable", "[", "str", "]", ",", "*", "*", "kwargs", ")", "->", "BELGraph", ":", "graph", "=", "BELGraph", "(", ")", "parse_lines", "(", "graph", "=", "graph", ",", "lines", "=", "lines", ",", "*", "*", "kwa...
Load a BEL graph from an iterable over the lines of a BEL script. :param lines: An iterable of strings (the lines in a BEL script) The remaining keyword arguments are passed to :func:`pybel.io.line_utils.parse_lines`.
[ "Load", "a", "BEL", "graph", "from", "an", "iterable", "over", "the", "lines", "of", "a", "BEL", "script", "." ]
python
train
38.5
saltstack/salt
salt/states/netusers.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/netusers.py#L169-L443
def managed(name, users=None, defaults=None): ''' Manages the configuration of the users on the device, as specified in the state SLS file. Users not defined in that file will be remove whilst users not configured on the device, will be added. SLS Example: .. code-block:: yaml netusers_e...
[ "def", "managed", "(", "name", ",", "users", "=", "None", ",", "defaults", "=", "None", ")", ":", "result", "=", "False", "comment", "=", "''", "changes", "=", "{", "}", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "changes", ",",...
Manages the configuration of the users on the device, as specified in the state SLS file. Users not defined in that file will be remove whilst users not configured on the device, will be added. SLS Example: .. code-block:: yaml netusers_example: netusers.managed: - us...
[ "Manages", "the", "configuration", "of", "the", "users", "on", "the", "device", "as", "specified", "in", "the", "state", "SLS", "file", ".", "Users", "not", "defined", "in", "that", "file", "will", "be", "remove", "whilst", "users", "not", "configured", "o...
python
train
42.138182
uber/tchannel-python
tchannel/tornado/peer.py
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/peer.py#L196-L202
def register_incoming_conn(self, conn): """Add incoming connection into the heap.""" assert conn, "conn is required" conn.set_outbound_pending_change_callback(self._on_conn_change) self.connections.appendleft(conn) self._set_on_close_cb(conn) self._on_conn_change()
[ "def", "register_incoming_conn", "(", "self", ",", "conn", ")", ":", "assert", "conn", ",", "\"conn is required\"", "conn", ".", "set_outbound_pending_change_callback", "(", "self", ".", "_on_conn_change", ")", "self", ".", "connections", ".", "appendleft", "(", "...
Add incoming connection into the heap.
[ "Add", "incoming", "connection", "into", "the", "heap", "." ]
python
train
43.857143
saltstack/salt
salt/modules/vmctl.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vmctl.py#L286-L358
def status(name=None, id=None): ''' List VMs running on the host, or only the VM specified by ``id``. When both a name and id are provided, the id is ignored. name: Name of the defined VM. id: VM id. CLI Example: .. code-block:: bash salt '*' vmctl.status ...
[ "def", "status", "(", "name", "=", "None", ",", "id", "=", "None", ")", ":", "ret", "=", "{", "}", "cmd", "=", "[", "'vmctl'", ",", "'status'", "]", "result", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "cmd", ",", "output_loglevel", "=", "'tr...
List VMs running on the host, or only the VM specified by ``id``. When both a name and id are provided, the id is ignored. name: Name of the defined VM. id: VM id. CLI Example: .. code-block:: bash salt '*' vmctl.status # to list all VMs salt '*' vmctl...
[ "List", "VMs", "running", "on", "the", "host", "or", "only", "the", "VM", "specified", "by", "id", ".", "When", "both", "a", "name", "and", "id", "are", "provided", "the", "id", "is", "ignored", "." ]
python
train
31.068493
log2timeline/dfvfs
dfvfs/vfs/apfs_file_entry.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/apfs_file_entry.py#L193-L196
def modification_time(self): """dfdatetime.DateTimeValues: modification time or None if not available.""" timestamp = self._fsapfs_file_entry.get_modification_time_as_integer() return dfdatetime_apfs_time.APFSTime(timestamp=timestamp)
[ "def", "modification_time", "(", "self", ")", ":", "timestamp", "=", "self", ".", "_fsapfs_file_entry", ".", "get_modification_time_as_integer", "(", ")", "return", "dfdatetime_apfs_time", ".", "APFSTime", "(", "timestamp", "=", "timestamp", ")" ]
dfdatetime.DateTimeValues: modification time or None if not available.
[ "dfdatetime", ".", "DateTimeValues", ":", "modification", "time", "or", "None", "if", "not", "available", "." ]
python
train
60.75
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L38-L45
def add_plugin(self, plugin, call): """Add plugin to list of plugins. Will be added if it has the attribute I'm bound to. """ meth = getattr(plugin, call, None) if meth is not None: self.plugins.append((plugin, meth))
[ "def", "add_plugin", "(", "self", ",", "plugin", ",", "call", ")", ":", "meth", "=", "getattr", "(", "plugin", ",", "call", ",", "None", ")", "if", "meth", "is", "not", "None", ":", "self", ".", "plugins", ".", "append", "(", "(", "plugin", ",", ...
Add plugin to list of plugins. Will be added if it has the attribute I'm bound to.
[ "Add", "plugin", "to", "list", "of", "plugins", "." ]
python
train
32.875
HumanBrainProject/hbp-service-client
hbp_service_client/storage_service/api.py
https://github.com/HumanBrainProject/hbp-service-client/blob/b338fb41a7f0e7b9d654ff28fcf13a56d03bff4d/hbp_service_client/storage_service/api.py#L975-L996
def delete_file(self, file_id): '''Delete a file. Args: file_id (str): The UUID of the file to delete. Returns: None Raises: StorageArgumentException: Invalid arguments StorageForbiddenException: Server response code 403 Stor...
[ "def", "delete_file", "(", "self", ",", "file_id", ")", ":", "if", "not", "is_valid_uuid", "(", "file_id", ")", ":", "raise", "StorageArgumentException", "(", "'Invalid UUID for file_id: {0}'", ".", "format", "(", "file_id", ")", ")", "self", ".", "_authenticate...
Delete a file. Args: file_id (str): The UUID of the file to delete. Returns: None Raises: StorageArgumentException: Invalid arguments StorageForbiddenException: Server response code 403 StorageNotFoundException: Server response code ...
[ "Delete", "a", "file", "." ]
python
test
30.772727
ipfs/py-ipfs-api
ipfsapi/client.py
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L825-L856
def key_gen(self, key_name, type, size=2048, **kwargs): """Adds a new public key that can be used for name_publish. .. code-block:: python >>> c.key_gen('example_key_name') {'Name': 'example_key_name', 'Id': 'QmQLaT5ZrCfSkXTH6rUKtVidcxj8jrW3X2h75Lug1AV7g8'} ...
[ "def", "key_gen", "(", "self", ",", "key_name", ",", "type", ",", "size", "=", "2048", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "{", "\"type\"", ":", "type", ",", "\"size\"", ":", "size", "}", "kwargs", ".", "setdefault", "(", "\"opts\"", ",...
Adds a new public key that can be used for name_publish. .. code-block:: python >>> c.key_gen('example_key_name') {'Name': 'example_key_name', 'Id': 'QmQLaT5ZrCfSkXTH6rUKtVidcxj8jrW3X2h75Lug1AV7g8'} Parameters ---------- key_name : str ...
[ "Adds", "a", "new", "public", "key", "that", "can", "be", "used", "for", "name_publish", "." ]
python
train
29.34375
willseward/django-custom-field
custom_field/custom_field.py
https://github.com/willseward/django-custom-field/blob/d42a620a53a69e53902ece77bfbdad27485f3ef1/custom_field/custom_field.py#L42-L48
def get_custom_value(self, field_name): """ Get a value for a specified custom field field_name - Name of the custom field you want. """ custom_field = self.get_custom_field(field_name) return CustomFieldValue.objects.get_or_create( field=custom_field, object_id=self....
[ "def", "get_custom_value", "(", "self", ",", "field_name", ")", ":", "custom_field", "=", "self", ".", "get_custom_field", "(", "field_name", ")", "return", "CustomFieldValue", ".", "objects", ".", "get_or_create", "(", "field", "=", "custom_field", ",", "object...
Get a value for a specified custom field field_name - Name of the custom field you want.
[ "Get", "a", "value", "for", "a", "specified", "custom", "field", "field_name", "-", "Name", "of", "the", "custom", "field", "you", "want", "." ]
python
train
46.571429
Qiskit/qiskit-terra
qiskit/providers/basicaer/qasm_simulator.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/providers/basicaer/qasm_simulator.py#L622-L637
def _validate(self, qobj): """Semantic validations of the qobj which cannot be done via schemas.""" n_qubits = qobj.config.n_qubits max_qubits = self.configuration().n_qubits if n_qubits > max_qubits: raise BasicAerError('Number of qubits {} '.format(n_qubits) + ...
[ "def", "_validate", "(", "self", ",", "qobj", ")", ":", "n_qubits", "=", "qobj", ".", "config", ".", "n_qubits", "max_qubits", "=", "self", ".", "configuration", "(", ")", ".", "n_qubits", "if", "n_qubits", ">", "max_qubits", ":", "raise", "BasicAerError",...
Semantic validations of the qobj which cannot be done via schemas.
[ "Semantic", "validations", "of", "the", "qobj", "which", "cannot", "be", "done", "via", "schemas", "." ]
python
test
58.9375
GeoNode/geonode-notification
notification/models.py
https://github.com/GeoNode/geonode-notification/blob/c60bc28f16f5d0e62536e76c17d6944a79449ef1/notification/models.py#L117-L133
def get_notification_language(user): """ Returns site-specific notification language for this user. Raises LanguageStoreNotAvailable if this site does not use translated notifications. """ if getattr(settings, "NOTIFICATION_LANGUAGE_MODULE", False): try: app_label, model_name...
[ "def", "get_notification_language", "(", "user", ")", ":", "if", "getattr", "(", "settings", ",", "\"NOTIFICATION_LANGUAGE_MODULE\"", ",", "False", ")", ":", "try", ":", "app_label", ",", "model_name", "=", "settings", ".", "NOTIFICATION_LANGUAGE_MODULE", ".", "sp...
Returns site-specific notification language for this user. Raises LanguageStoreNotAvailable if this site does not use translated notifications.
[ "Returns", "site", "-", "specific", "notification", "language", "for", "this", "user", ".", "Raises", "LanguageStoreNotAvailable", "if", "this", "site", "does", "not", "use", "translated", "notifications", "." ]
python
valid
46.294118
eqcorrscan/EQcorrscan
eqcorrscan/utils/plotting.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/plotting.py#L1234-L1394
def pretty_template_plot(template, size=(10.5, 7.5), background=False, picks=False, **kwargs): """ Plot of a single template, possibly within background data. :type template: obspy.core.stream.Stream :param template: Template stream to plot :type size: tuple :param size...
[ "def", "pretty_template_plot", "(", "template", ",", "size", "=", "(", "10.5", ",", "7.5", ")", ",", "background", "=", "False", ",", "picks", "=", "False", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "fig", ...
Plot of a single template, possibly within background data. :type template: obspy.core.stream.Stream :param template: Template stream to plot :type size: tuple :param size: tuple of plot size :type background: obspy.core.stream.stream :param background: Stream to plot the template within. :...
[ "Plot", "of", "a", "single", "template", "possibly", "within", "background", "data", "." ]
python
train
40.335404
skioo/django-datatrans-gateway
datatrans/gateway/payment_with_alias.py
https://github.com/skioo/django-datatrans-gateway/blob/1c4de5b589403e4ec3aadc4ff2fc1eb17b34bcc7/datatrans/gateway/payment_with_alias.py#L15-L47
def pay_with_alias(amount: Money, alias_registration_id: str, client_ref: str) -> Payment: """ Charges money using datatrans, given a previously registered credit card alias. :param amount: The amount and currency we want to charge :param alias_registration_id: The alias registration to use :param ...
[ "def", "pay_with_alias", "(", "amount", ":", "Money", ",", "alias_registration_id", ":", "str", ",", "client_ref", ":", "str", ")", "->", "Payment", ":", "if", "amount", ".", "amount", "<=", "0", ":", "raise", "ValueError", "(", "'Pay with alias takes a strict...
Charges money using datatrans, given a previously registered credit card alias. :param amount: The amount and currency we want to charge :param alias_registration_id: The alias registration to use :param client_ref: A unique reference for this charge :return: a Payment (either successful or not)
[ "Charges", "money", "using", "datatrans", "given", "a", "previously", "registered", "credit", "card", "alias", "." ]
python
test
39.121212
berdario/pew
pew/pew.py
https://github.com/berdario/pew/blob/37d9ff79342336b8ef6437d9a551008be07afe9b/pew/pew.py#L451-L463
def toggleglobalsitepackages_cmd(argv): """Toggle the current virtualenv between having and not having access to the global site-packages.""" quiet = argv == ['-q'] site = sitepackages_dir() ngsp_file = site.parent / 'no-global-site-packages.txt' if ngsp_file.exists(): ngsp_file.unlink() ...
[ "def", "toggleglobalsitepackages_cmd", "(", "argv", ")", ":", "quiet", "=", "argv", "==", "[", "'-q'", "]", "site", "=", "sitepackages_dir", "(", ")", "ngsp_file", "=", "site", ".", "parent", "/", "'no-global-site-packages.txt'", "if", "ngsp_file", ".", "exist...
Toggle the current virtualenv between having and not having access to the global site-packages.
[ "Toggle", "the", "current", "virtualenv", "between", "having", "and", "not", "having", "access", "to", "the", "global", "site", "-", "packages", "." ]
python
train
38.538462
brainiak/brainiak
brainiak/fcma/voxelselector.py
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/brainiak/fcma/voxelselector.py#L371-L421
def _prepare_for_cross_validation(self, corr, clf): """Prepare data for voxelwise cross validation. If the classifier is sklearn.svm.SVC with precomputed kernel, the kernel matrix of each voxel is computed, otherwise do nothing. Parameters ---------- corr: 3D array in s...
[ "def", "_prepare_for_cross_validation", "(", "self", ",", "corr", ",", "clf", ")", ":", "time1", "=", "time", ".", "time", "(", ")", "(", "num_processed_voxels", ",", "num_epochs", ",", "_", ")", "=", "corr", ".", "shape", "if", "isinstance", "(", "clf",...
Prepare data for voxelwise cross validation. If the classifier is sklearn.svm.SVC with precomputed kernel, the kernel matrix of each voxel is computed, otherwise do nothing. Parameters ---------- corr: 3D array in shape [num_processed_voxels, num_epochs, num_voxels] ...
[ "Prepare", "data", "for", "voxelwise", "cross", "validation", "." ]
python
train
44.607843
LettError/MutatorMath
Lib/mutatorMath/objects/location.py
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/objects/location.py#L606-L644
def sortLocations(locations): """ Sort the locations by ranking: 1. all on-axis points 2. all off-axis points which project onto on-axis points these would be involved in master to master interpolations necessary for patching. Projecting off-axis masters hav...
[ "def", "sortLocations", "(", "locations", ")", ":", "onAxis", "=", "[", "]", "onAxisValues", "=", "{", "}", "offAxis", "=", "[", "]", "offAxis_projecting", "=", "[", "]", "offAxis_wild", "=", "[", "]", "# first get the on-axis points", "for", "l", "in", "l...
Sort the locations by ranking: 1. all on-axis points 2. all off-axis points which project onto on-axis points these would be involved in master to master interpolations necessary for patching. Projecting off-axis masters have at least one coordin...
[ "Sort", "the", "locations", "by", "ranking", ":", "1", ".", "all", "on", "-", "axis", "points", "2", ".", "all", "off", "-", "axis", "points", "which", "project", "onto", "on", "-", "axis", "points", "these", "would", "be", "involved", "in", "master", ...
python
train
35.102564
iotile/coretools
iotilecore/iotile/core/hw/reports/utc_assigner.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/reports/utc_assigner.py#L137-L149
def id_range(self): """Get the range of archor reading_ids. Returns: (int, int): The lowest and highest reading ids. If no reading ids have been loaded, (0, 0) is returned. """ if len(self._anchor_points) == 0: return (0, 0) return (self._a...
[ "def", "id_range", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_anchor_points", ")", "==", "0", ":", "return", "(", "0", ",", "0", ")", "return", "(", "self", ".", "_anchor_points", "[", "0", "]", ".", "reading_id", ",", "self", ".", "...
Get the range of archor reading_ids. Returns: (int, int): The lowest and highest reading ids. If no reading ids have been loaded, (0, 0) is returned.
[ "Get", "the", "range", "of", "archor", "reading_ids", "." ]
python
train
28.538462
great-expectations/great_expectations
great_expectations/data_asset/base.py
https://github.com/great-expectations/great_expectations/blob/08385c40529d4f14a1c46916788aecc47f33ee9d/great_expectations/data_asset/base.py#L581-L673
def get_expectations_config(self, discard_failed_expectations=True, discard_result_format_kwargs=True, discard_include_configs_kwargs=True, discard_catch_exceptions_kwargs=True, ...
[ "def", "get_expectations_config", "(", "self", ",", "discard_failed_expectations", "=", "True", ",", "discard_result_format_kwargs", "=", "True", ",", "discard_include_configs_kwargs", "=", "True", ",", "discard_catch_exceptions_kwargs", "=", "True", ",", "suppress_warnings...
Returns _expectation_config as a JSON object, and perform some cleaning along the way. Args: discard_failed_expectations (boolean): \ Only include expectations with success_on_last_run=True in the exported config. Defaults to `True`. discard_result_format_kwargs (boolea...
[ "Returns", "_expectation_config", "as", "a", "JSON", "object", "and", "perform", "some", "cleaning", "along", "the", "way", "." ]
python
train
51.935484
SetBased/py-stratum
pystratum/wrapper/Wrapper.py
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/wrapper/Wrapper.py#L224-L240
def _get_wrapper_args(routine): """ Returns code for the parameters of the wrapper method for the stored routine. :param dict[str,*] routine: The routine metadata. :rtype: str """ ret = '' for parameter_info in routine['parameters']: if ret: ...
[ "def", "_get_wrapper_args", "(", "routine", ")", ":", "ret", "=", "''", "for", "parameter_info", "in", "routine", "[", "'parameters'", "]", ":", "if", "ret", ":", "ret", "+=", "', '", "ret", "+=", "parameter_info", "[", "'name'", "]", "return", "ret" ]
Returns code for the parameters of the wrapper method for the stored routine. :param dict[str,*] routine: The routine metadata. :rtype: str
[ "Returns", "code", "for", "the", "parameters", "of", "the", "wrapper", "method", "for", "the", "stored", "routine", "." ]
python
train
22.764706
santosjorge/cufflinks
cufflinks/datagen.py
https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/datagen.py#L114-L129
def pie(n_labels=5,mode=None): """ Returns a DataFrame with the required format for a pie plot Parameters: ----------- n_labels : int Number of labels mode : string Format for each item 'abc' for alphabet columns 'stocks' for random stock names """ return pd.DataFrame({'values':np.random.ra...
[ "def", "pie", "(", "n_labels", "=", "5", ",", "mode", "=", "None", ")", ":", "return", "pd", ".", "DataFrame", "(", "{", "'values'", ":", "np", ".", "random", ".", "randint", "(", "1", ",", "100", ",", "n_labels", ")", ",", "'labels'", ":", "getN...
Returns a DataFrame with the required format for a pie plot Parameters: ----------- n_labels : int Number of labels mode : string Format for each item 'abc' for alphabet columns 'stocks' for random stock names
[ "Returns", "a", "DataFrame", "with", "the", "required", "format", "for", "a", "pie", "plot" ]
python
train
23.3125
tanghaibao/jcvi
jcvi/assembly/ca.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/ca.py#L258-L336
def overlap(args): """ %prog overlap best.contains iid Visualize overlaps for a given fragment. Must be run in 4-unitigger. All overlaps for iid were retrieved, excluding the ones matching best.contains. """ from jcvi.apps.console import green p = OptionParser(overlap.__doc__) p.add_op...
[ "def", "overlap", "(", "args", ")", ":", "from", "jcvi", ".", "apps", ".", "console", "import", "green", "p", "=", "OptionParser", "(", "overlap", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--maxerr\"", ",", "default", "=", "2", ",", "type", ...
%prog overlap best.contains iid Visualize overlaps for a given fragment. Must be run in 4-unitigger. All overlaps for iid were retrieved, excluding the ones matching best.contains.
[ "%prog", "overlap", "best", ".", "contains", "iid" ]
python
train
29.64557
remind101/stacker_blueprints
stacker_blueprints/aws_lambda.py
https://github.com/remind101/stacker_blueprints/blob/71624f6e1bd4ea794dc98fb621a04235e1931cae/stacker_blueprints/aws_lambda.py#L37-L62
def get_stream_action_type(stream_arn): """Returns the awacs Action for a stream type given an arn Args: stream_arn (str): The Arn of the stream. Returns: :class:`awacs.aws.Action`: The appropriate stream type awacs Action class Raises: ValueError: If the stream ty...
[ "def", "get_stream_action_type", "(", "stream_arn", ")", ":", "stream_type_map", "=", "{", "\"kinesis\"", ":", "awacs", ".", "kinesis", ".", "Action", ",", "\"dynamodb\"", ":", "awacs", ".", "dynamodb", ".", "Action", ",", "}", "stream_type", "=", "stream_arn"...
Returns the awacs Action for a stream type given an arn Args: stream_arn (str): The Arn of the stream. Returns: :class:`awacs.aws.Action`: The appropriate stream type awacs Action class Raises: ValueError: If the stream type doesn't match kinesis or dynamodb.
[ "Returns", "the", "awacs", "Action", "for", "a", "stream", "type", "given", "an", "arn" ]
python
train
26.461538
pydata/xarray
xarray/conventions.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/conventions.py#L595-L624
def cf_encoder(variables, attributes): """ A function which takes a dicts of variables and attributes and encodes them to conform to CF conventions as much as possible. This includes masking, scaling, character array handling, and CF-time encoding. Decode a set of CF encoded variables and attr...
[ "def", "cf_encoder", "(", "variables", ",", "attributes", ")", ":", "new_vars", "=", "OrderedDict", "(", "(", "k", ",", "encode_cf_variable", "(", "v", ",", "name", "=", "k", ")", ")", "for", "k", ",", "v", "in", "variables", ".", "items", "(", ")", ...
A function which takes a dicts of variables and attributes and encodes them to conform to CF conventions as much as possible. This includes masking, scaling, character array handling, and CF-time encoding. Decode a set of CF encoded variables and attributes. See Also, decode_cf_variable Para...
[ "A", "function", "which", "takes", "a", "dicts", "of", "variables", "and", "attributes", "and", "encodes", "them", "to", "conform", "to", "CF", "conventions", "as", "much", "as", "possible", ".", "This", "includes", "masking", "scaling", "character", "array", ...
python
train
31.166667
Gandi/gandi.cli
gandi/cli/commands/webacc.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/webacc.py#L198-L202
def update(gandi, resource, name, algorithm, ssl_enable, ssl_disable): """Update a webaccelerator""" result = gandi.webacc.update(resource, name, algorithm, ssl_enable, ssl_disable) return result
[ "def", "update", "(", "gandi", ",", "resource", ",", "name", ",", "algorithm", ",", "ssl_enable", ",", "ssl_disable", ")", ":", "result", "=", "gandi", ".", "webacc", ".", "update", "(", "resource", ",", "name", ",", "algorithm", ",", "ssl_enable", ",", ...
Update a webaccelerator
[ "Update", "a", "webaccelerator" ]
python
train
47.2
theonion/django-bulbs
bulbs/utils/methods.py
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/utils/methods.py#L125-L133
def import_class(name): """Load class from fully-qualified python module name. ex: import_class('bulbs.content.models.Content') """ module, _, klass = name.rpartition('.') mod = import_module(module) return getattr(mod, klass)
[ "def", "import_class", "(", "name", ")", ":", "module", ",", "_", ",", "klass", "=", "name", ".", "rpartition", "(", "'.'", ")", "mod", "=", "import_module", "(", "module", ")", "return", "getattr", "(", "mod", ",", "klass", ")" ]
Load class from fully-qualified python module name. ex: import_class('bulbs.content.models.Content')
[ "Load", "class", "from", "fully", "-", "qualified", "python", "module", "name", "." ]
python
train
27.111111
coinbase/coinbase-python
coinbase/wallet/model.py
https://github.com/coinbase/coinbase-python/blob/497c28158f529e8c7d0228521b4386a890baf088/coinbase/wallet/model.py#L253-L255
def get_deposit(self, deposit_id, **params): """https://developers.coinbase.com/api/v2#show-a-deposit""" return self.api_client.get_deposit(self.id, deposit_id, **params)
[ "def", "get_deposit", "(", "self", ",", "deposit_id", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api_client", ".", "get_deposit", "(", "self", ".", "id", ",", "deposit_id", ",", "*", "*", "params", ")" ]
https://developers.coinbase.com/api/v2#show-a-deposit
[ "https", ":", "//", "developers", ".", "coinbase", ".", "com", "/", "api", "/", "v2#show", "-", "a", "-", "deposit" ]
python
train
61.333333
corpusops/pdbclone
lib/pdb_clone/pdb.py
https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdb.py#L1494-L1506
def do_longlist(self, arg): """longlist | ll List the whole source code for the current function or frame. """ filename = self.curframe.f_code.co_filename breaklist = self.get_file_breaks(filename) try: lines, lineno = getsourcelines(self.curframe, ...
[ "def", "do_longlist", "(", "self", ",", "arg", ")", ":", "filename", "=", "self", ".", "curframe", ".", "f_code", ".", "co_filename", "breaklist", "=", "self", ".", "get_file_breaks", "(", "filename", ")", "try", ":", "lines", ",", "lineno", "=", "getsou...
longlist | ll List the whole source code for the current function or frame.
[ "longlist", "|", "ll", "List", "the", "whole", "source", "code", "for", "the", "current", "function", "or", "frame", "." ]
python
train
38.846154
AtteqCom/zsl
src/zsl/db/helpers/pagination.py
https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/db/helpers/pagination.py#L82-L91
def apply_pagination(self, q): """ Filters the query so that a given page is returned. The record count must be set in advance. :param q: Query to be paged. :return: Paged query. """ # type: (Query)->Query assert self.record_count >= 0, "Record count must ...
[ "def", "apply_pagination", "(", "self", ",", "q", ")", ":", "# type: (Query)->Query", "assert", "self", ".", "record_count", ">=", "0", ",", "\"Record count must be set.\"", "return", "q", ".", "limit", "(", "self", ".", "page_size", ")", ".", "offset", "(", ...
Filters the query so that a given page is returned. The record count must be set in advance. :param q: Query to be paged. :return: Paged query.
[ "Filters", "the", "query", "so", "that", "a", "given", "page", "is", "returned", ".", "The", "record", "count", "must", "be", "set", "in", "advance", ".", ":", "param", "q", ":", "Query", "to", "be", "paged", ".", ":", "return", ":", "Paged", "query"...
python
train
37.8
dw/mitogen
ansible_mitogen/target.py
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/ansible_mitogen/target.py#L229-L260
def prune_tree(path): """ Like shutil.rmtree(), but log errors rather than discard them, and do not waste multiple os.stat() calls discovering whether the object can be deleted, just try deleting it instead. """ try: os.unlink(path) return except OSError: e = sys.exc_...
[ "def", "prune_tree", "(", "path", ")", ":", "try", ":", "os", ".", "unlink", "(", "path", ")", "return", "except", "OSError", ":", "e", "=", "sys", ".", "exc_info", "(", ")", "[", "1", "]", "if", "not", "(", "os", ".", "path", ".", "isdir", "("...
Like shutil.rmtree(), but log errors rather than discard them, and do not waste multiple os.stat() calls discovering whether the object can be deleted, just try deleting it instead.
[ "Like", "shutil", ".", "rmtree", "()", "but", "log", "errors", "rather", "than", "discard", "them", "and", "do", "not", "waste", "multiple", "os", ".", "stat", "()", "calls", "discovering", "whether", "the", "object", "can", "be", "deleted", "just", "try",...
python
train
31.625
CalebBell/fluids
fluids/particle_size_distribution.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1206-L1269
def pdf(self, d, n=None): r'''Computes the probability density function of a continuous particle size distribution at a specified particle diameter, an optionally in a specified basis. The evaluation function varies with the distribution chosen. The interconversion between distribution ...
[ "def", "pdf", "(", "self", ",", "d", ",", "n", "=", "None", ")", ":", "ans", "=", "self", ".", "_pdf", "(", "d", "=", "d", ")", "if", "n", "is", "not", "None", "and", "n", "!=", "self", ".", "order", ":", "power", "=", "n", "-", "self", "...
r'''Computes the probability density function of a continuous particle size distribution at a specified particle diameter, an optionally in a specified basis. The evaluation function varies with the distribution chosen. The interconversion between distribution orders is performed using ...
[ "r", "Computes", "the", "probability", "density", "function", "of", "a", "continuous", "particle", "size", "distribution", "at", "a", "specified", "particle", "diameter", "an", "optionally", "in", "a", "specified", "basis", ".", "The", "evaluation", "function", ...
python
train
38.03125
dangunter/smoqe
smoqe/query.py
https://github.com/dangunter/smoqe/blob/70aa8ec1e9df875b9d21c71cbded95c595fe2aad/smoqe/query.py#L302-L315
def _set_size_code(self): """Set the code for a size operation. """ if not self._op.startswith(self.SIZE): self._size_code = None return if len(self._op) == len(self.SIZE): self._size_code = self.SZ_EQ else: suffix = self._op[len(s...
[ "def", "_set_size_code", "(", "self", ")", ":", "if", "not", "self", ".", "_op", ".", "startswith", "(", "self", ".", "SIZE", ")", ":", "self", ".", "_size_code", "=", "None", "return", "if", "len", "(", "self", ".", "_op", ")", "==", "len", "(", ...
Set the code for a size operation.
[ "Set", "the", "code", "for", "a", "size", "operation", "." ]
python
train
36.357143
google/grumpy
third_party/pypy/_md5.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_md5.py#L297-L337
def digest(self): """Terminate the message-digest computation and return digest. Return the digest of the strings passed to the update() method so far. This is a 16-byte string which may contain non-ASCII characters, including null bytes. """ A = self.A B = self.B C = self.C D = se...
[ "def", "digest", "(", "self", ")", ":", "A", "=", "self", ".", "A", "B", "=", "self", ".", "B", "C", "=", "self", ".", "C", "D", "=", "self", ".", "D", "input", "=", "[", "]", "+", "self", ".", "input", "count", "=", "[", "]", "+", "self"...
Terminate the message-digest computation and return digest. Return the digest of the strings passed to the update() method so far. This is a 16-byte string which may contain non-ASCII characters, including null bytes.
[ "Terminate", "the", "message", "-", "digest", "computation", "and", "return", "digest", "." ]
python
valid
21.439024
bcb/jsonrpcserver
jsonrpcserver/dispatcher.py
https://github.com/bcb/jsonrpcserver/blob/26bb70e868f81691816cabfc4b60a83428842b2f/jsonrpcserver/dispatcher.py#L195-L231
def dispatch_pure( request: str, methods: Methods, *, context: Any, convert_camel_case: bool, debug: bool, ) -> Response: """ Pure version of dispatch - no logging, no optional parameters. Does two things: 1. Deserializes and validates the string. 2. Calls each reque...
[ "def", "dispatch_pure", "(", "request", ":", "str", ",", "methods", ":", "Methods", ",", "*", ",", "context", ":", "Any", ",", "convert_camel_case", ":", "bool", ",", "debug", ":", "bool", ",", ")", "->", "Response", ":", "try", ":", "deserialized", "=...
Pure version of dispatch - no logging, no optional parameters. Does two things: 1. Deserializes and validates the string. 2. Calls each request. Args: request: The incoming request string. methods: Collection of methods that can be called. context: If specified, will be...
[ "Pure", "version", "of", "dispatch", "-", "no", "logging", "no", "optional", "parameters", "." ]
python
train
30.594595
edx/edx-val
edxval/migrations/0004_data__add_hls_profile.py
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0004_data__add_hls_profile.py#L11-L14
def create_hls_profile(apps, schema_editor): """ Create hls profile """ Profile = apps.get_model("edxval", "Profile") Profile.objects.get_or_create(profile_name=HLS_PROFILE)
[ "def", "create_hls_profile", "(", "apps", ",", "schema_editor", ")", ":", "Profile", "=", "apps", ".", "get_model", "(", "\"edxval\"", ",", "\"Profile\"", ")", "Profile", ".", "objects", ".", "get_or_create", "(", "profile_name", "=", "HLS_PROFILE", ")" ]
Create hls profile
[ "Create", "hls", "profile" ]
python
train
45.5
mitsei/dlkit
dlkit/services/hierarchy.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/hierarchy.py#L583-L595
def _set_operable_view(self, session): """Sets the underlying operable views to match current view""" for obj_name in self._operable_views: if self._operable_views[obj_name] == ACTIVE: try: getattr(session, 'use_active_' + obj_name + '_view')() ...
[ "def", "_set_operable_view", "(", "self", ",", "session", ")", ":", "for", "obj_name", "in", "self", ".", "_operable_views", ":", "if", "self", ".", "_operable_views", "[", "obj_name", "]", "==", "ACTIVE", ":", "try", ":", "getattr", "(", "session", ",", ...
Sets the underlying operable views to match current view
[ "Sets", "the", "underlying", "operable", "views", "to", "match", "current", "view" ]
python
train
41.692308
ArchiveTeam/wpull
wpull/url.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/url.py#L432-L443
def normalize_hostname(hostname): '''Normalizes a hostname so that it is ASCII and valid domain name.''' try: new_hostname = hostname.encode('idna').decode('ascii').lower() except UnicodeError as error: raise UnicodeError('Hostname {} rejected: {}'.format(hostname, error)) from error if...
[ "def", "normalize_hostname", "(", "hostname", ")", ":", "try", ":", "new_hostname", "=", "hostname", ".", "encode", "(", "'idna'", ")", ".", "decode", "(", "'ascii'", ")", ".", "lower", "(", ")", "except", "UnicodeError", "as", "error", ":", "raise", "Un...
Normalizes a hostname so that it is ASCII and valid domain name.
[ "Normalizes", "a", "hostname", "so", "that", "it", "is", "ASCII", "and", "valid", "domain", "name", "." ]
python
train
37.583333
mapbox/mapbox-sdk-py
mapbox/services/maps.py
https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L386-L468
def marker(self, marker_name=None, label=None, color=None, retina=False): """Returns a single marker image without any background map. Parameters ---------- marker_name : str The marker's shape and size. label : str, optional T...
[ "def", "marker", "(", "self", ",", "marker_name", "=", "None", ",", "label", "=", "None", ",", "color", "=", "None", ",", "retina", "=", "False", ")", ":", "# Check for marker_name.", "if", "marker_name", "is", "None", ":", "raise", "ValidationError", "(",...
Returns a single marker image without any background map. Parameters ---------- marker_name : str The marker's shape and size. label : str, optional The marker's alphanumeric label. Options are a through z, 0 through 99, or the ...
[ "Returns", "a", "single", "marker", "image", "without", "any", "background", "map", "." ]
python
train
26.240964
trevisanj/a99
a99/textinterface.py
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/textinterface.py#L16-L34
def format_underline(s, char="=", indents=0): """ Traces a dashed line below string Args: s: string char: indents: number of leading intenting spaces Returns: list >>> print("\\n".join(format_underline("Life of João da Silva", "^", 2))) Life of João da Si...
[ "def", "format_underline", "(", "s", ",", "char", "=", "\"=\"", ",", "indents", "=", "0", ")", ":", "n", "=", "len", "(", "s", ")", "ind", "=", "\" \"", "*", "indents", "return", "[", "\"{}{}\"", ".", "format", "(", "ind", ",", "s", ")", ",", "...
Traces a dashed line below string Args: s: string char: indents: number of leading intenting spaces Returns: list >>> print("\\n".join(format_underline("Life of João da Silva", "^", 2))) Life of João da Silva ^^^^^^^^^^^^^^^^^^^^^
[ "Traces", "a", "dashed", "line", "below", "string", "Args", ":", "s", ":", "string", "char", ":", "indents", ":", "number", "of", "leading", "intenting", "spaces", "Returns", ":", "list", ">>>", "print", "(", "\\\\", "n", ".", "join", "(", "format_underl...
python
train
23.684211
nickmckay/LiPD-utilities
Python/lipd/noaa.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa.py#L84-L114
def lpd_to_noaa(D, wds_url, lpd_url, version, path=""): """ Convert a LiPD format to NOAA format :param dict D: Metadata :return dict D: Metadata """ logger_noaa.info("enter process_lpd") d = D try: dsn = get_dsn(D) # Remove all the characters that are not allowed here. ...
[ "def", "lpd_to_noaa", "(", "D", ",", "wds_url", ",", "lpd_url", ",", "version", ",", "path", "=", "\"\"", ")", ":", "logger_noaa", ".", "info", "(", "\"enter process_lpd\"", ")", "d", "=", "D", "try", ":", "dsn", "=", "get_dsn", "(", "D", ")", "# Rem...
Convert a LiPD format to NOAA format :param dict D: Metadata :return dict D: Metadata
[ "Convert", "a", "LiPD", "format", "to", "NOAA", "format" ]
python
train
36.935484
jmgilman/Neolib
neolib/pyamf/util/imports.py
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/util/imports.py#L72-L92
def load_module(self, name): """ If we get this far, then there are hooks waiting to be called on import of this module. We manually load the module and then run the hooks. @param name: The name of the module to import. """ self.loaded_modules.append(name) ...
[ "def", "load_module", "(", "self", ",", "name", ")", ":", "self", ".", "loaded_modules", ".", "append", "(", "name", ")", "try", ":", "__import__", "(", "name", ",", "{", "}", ",", "{", "}", ",", "[", "]", ")", "mod", "=", "sys", ".", "modules", ...
If we get this far, then there are hooks waiting to be called on import of this module. We manually load the module and then run the hooks. @param name: The name of the module to import.
[ "If", "we", "get", "this", "far", "then", "there", "are", "hooks", "waiting", "to", "be", "called", "on", "import", "of", "this", "module", ".", "We", "manually", "load", "the", "module", "and", "then", "run", "the", "hooks", "." ]
python
train
24.619048
sendgrid/python-http-client
python_http_client/client.py
https://github.com/sendgrid/python-http-client/blob/fa72b743fbf1aa499cc4e34d6a690af3e16a7a4d/python_http_client/client.py#L158-L176
def _make_request(self, opener, request, timeout=None): """Make the API call and return the response. This is separated into it's own function, so we can mock it easily for testing. :param opener: :type opener: :param request: url payload to request :type request: url...
[ "def", "_make_request", "(", "self", ",", "opener", ",", "request", ",", "timeout", "=", "None", ")", ":", "timeout", "=", "timeout", "or", "self", ".", "timeout", "try", ":", "return", "opener", ".", "open", "(", "request", ",", "timeout", "=", "timeo...
Make the API call and return the response. This is separated into it's own function, so we can mock it easily for testing. :param opener: :type opener: :param request: url payload to request :type request: urllib.Request object :param timeout: timeout value or None ...
[ "Make", "the", "API", "call", "and", "return", "the", "response", ".", "This", "is", "separated", "into", "it", "s", "own", "function", "so", "we", "can", "mock", "it", "easily", "for", "testing", "." ]
python
train
35.578947
horazont/aioxmpp
aioxmpp/bookmarks/service.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/bookmarks/service.py#L133-L139
def _set_bookmarks(self, bookmarks): """ Set the bookmarks stored on the server. """ storage = bookmark_xso.Storage() storage.bookmarks[:] = bookmarks yield from self._private_xml.set_private_xml(storage)
[ "def", "_set_bookmarks", "(", "self", ",", "bookmarks", ")", ":", "storage", "=", "bookmark_xso", ".", "Storage", "(", ")", "storage", ".", "bookmarks", "[", ":", "]", "=", "bookmarks", "yield", "from", "self", ".", "_private_xml", ".", "set_private_xml", ...
Set the bookmarks stored on the server.
[ "Set", "the", "bookmarks", "stored", "on", "the", "server", "." ]
python
train
35.142857
edx/edx-enterprise
integrated_channels/sap_success_factors/exporters/content_metadata.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/exporters/content_metadata.py#L161-L178
def transform_courserun_description(self, content_metadata_item): """ Return the description of the courserun content item. """ description_with_locales = [] content_metadata_language_code = transform_language_code(content_metadata_item.get('content_language', '')) for lo...
[ "def", "transform_courserun_description", "(", "self", ",", "content_metadata_item", ")", ":", "description_with_locales", "=", "[", "]", "content_metadata_language_code", "=", "transform_language_code", "(", "content_metadata_item", ".", "get", "(", "'content_language'", "...
Return the description of the courserun content item.
[ "Return", "the", "description", "of", "the", "courserun", "content", "item", "." ]
python
valid
43.833333
Dallinger/Dallinger
demos/dlgr/demos/mcmcp/experiment.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/demos/dlgr/demos/mcmcp/experiment.py#L107-L121
def participate(self): """Finish reading and send text""" try: while True: left = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.ID, "left_button")) ) right = WebDriverWait(self.driver, 10).until( ...
[ "def", "participate", "(", "self", ")", ":", "try", ":", "while", "True", ":", "left", "=", "WebDriverWait", "(", "self", ".", "driver", ",", "10", ")", ".", "until", "(", "EC", ".", "element_to_be_clickable", "(", "(", "By", ".", "ID", ",", "\"left_...
Finish reading and send text
[ "Finish", "reading", "and", "send", "text" ]
python
train
35.6
stoneworksolutions/stoneredis
stoneredis/client.py
https://github.com/stoneworksolutions/stoneredis/blob/46018b81317c152bd47c0764c3f1293379618af4/stoneredis/client.py#L277-L289
def release_lock(self, lock, force=False): ''' Frees a lock ''' pid = os.getpid() caller = inspect.stack()[0][3] # try: # rl = redlock.Redlock([{"host": settings.REDIS_SERVERS['std_redis']['host'], "port": settings.REDIS_SERVERS['std_redis']['port'], "db": settings.REDIS_S...
[ "def", "release_lock", "(", "self", ",", "lock", ",", "force", "=", "False", ")", ":", "pid", "=", "os", ".", "getpid", "(", ")", "caller", "=", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", "# try:\r", "# rl = redlock.Redlock([{...
Frees a lock
[ "Frees", "a", "lock" ]
python
train
51.076923
greenbone/ospd
ospd/ospd.py
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L148-L166
def bind_unix_socket(path): """ Returns a unix file socket bound on (path). """ assert path bindsocket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: os.unlink(path) except OSError: if os.path.exists(path): raise try: bindsocket.bind(path) excep...
[ "def", "bind_unix_socket", "(", "path", ")", ":", "assert", "path", "bindsocket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_UNIX", ",", "socket", ".", "SOCK_STREAM", ")", "try", ":", "os", ".", "unlink", "(", "path", ")", "except", "OSError",...
Returns a unix file socket bound on (path).
[ "Returns", "a", "unix", "file", "socket", "bound", "on", "(", "path", ")", "." ]
python
train
25.421053
ivelum/graphql-py
graphql/parser.py
https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L255-L259
def p_field_optional2_5(self, p): """ field : alias name directives """ p[0] = Field(name=p[2], alias=p[1], directives=p[3])
[ "def", "p_field_optional2_5", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "Field", "(", "name", "=", "p", "[", "2", "]", ",", "alias", "=", "p", "[", "1", "]", ",", "directives", "=", "p", "[", "3", "]", ")" ]
field : alias name directives
[ "field", ":", "alias", "name", "directives" ]
python
train
30.4
MLAB-project/pymlab
src/pymlab/sensors/__init__.py
https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/__init__.py#L214-L217
def read_byte(self, address): """Reads unadressed byte from a device. """ LOGGER.debug("Reading byte from device %s!", hex(address)) return self.driver.read_byte(address)
[ "def", "read_byte", "(", "self", ",", "address", ")", ":", "LOGGER", ".", "debug", "(", "\"Reading byte from device %s!\"", ",", "hex", "(", "address", ")", ")", "return", "self", ".", "driver", ".", "read_byte", "(", "address", ")" ]
Reads unadressed byte from a device.
[ "Reads", "unadressed", "byte", "from", "a", "device", "." ]
python
train
47.75
spyder-ide/spyder
spyder/widgets/mixins.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L625-L629
def get_word_at(self, coordinates): """Return word at *coordinates* (QPoint)""" cursor = self.cursorForPosition(coordinates) cursor.select(QTextCursor.WordUnderCursor) return to_text_string(cursor.selectedText())
[ "def", "get_word_at", "(", "self", ",", "coordinates", ")", ":", "cursor", "=", "self", ".", "cursorForPosition", "(", "coordinates", ")", "cursor", ".", "select", "(", "QTextCursor", ".", "WordUnderCursor", ")", "return", "to_text_string", "(", "cursor", ".",...
Return word at *coordinates* (QPoint)
[ "Return", "word", "at", "*", "coordinates", "*", "(", "QPoint", ")" ]
python
train
48.8
materialsvirtuallab/monty
monty/design_patterns.py
https://github.com/materialsvirtuallab/monty/blob/d99d6f3c68372d83489d28ff515566c93cd569e2/monty/design_patterns.py#L37-L94
def cached_class(klass): """ Decorator to cache class instances by constructor arguments. This results in a class that behaves like a singleton for each set of constructor arguments, ensuring efficiency. Note that this should be used for *immutable classes only*. Having a cached mutable class ...
[ "def", "cached_class", "(", "klass", ")", ":", "cache", "=", "{", "}", "@", "wraps", "(", "klass", ",", "assigned", "=", "(", "\"__name__\"", ",", "\"__module__\"", ")", ",", "updated", "=", "(", ")", ")", "class", "_decorated", "(", "klass", ")", ":...
Decorator to cache class instances by constructor arguments. This results in a class that behaves like a singleton for each set of constructor arguments, ensuring efficiency. Note that this should be used for *immutable classes only*. Having a cached mutable class makes very little sense. For efficie...
[ "Decorator", "to", "cache", "class", "instances", "by", "constructor", "arguments", ".", "This", "results", "in", "a", "class", "that", "behaves", "like", "a", "singleton", "for", "each", "set", "of", "constructor", "arguments", "ensuring", "efficiency", "." ]
python
train
41.086207
newville/wxmplot
examples/tifffile.py
https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1249-L1255
def _fromdata(self, code, dtype, count, value, name=None): """Initialize instance from arguments.""" self.code = int(code) self.name = name if name else str(code) self.dtype = TIFF_DATA_TYPES[dtype] self.count = int(count) self.value = value
[ "def", "_fromdata", "(", "self", ",", "code", ",", "dtype", ",", "count", ",", "value", ",", "name", "=", "None", ")", ":", "self", ".", "code", "=", "int", "(", "code", ")", "self", ".", "name", "=", "name", "if", "name", "else", "str", "(", "...
Initialize instance from arguments.
[ "Initialize", "instance", "from", "arguments", "." ]
python
train
40.428571
agoragames/leaderboard-python
leaderboard/leaderboard.py
https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L319-L328
def remove_member_data_in(self, leaderboard_name, member): ''' Remove the optional member data for a given member in the named leaderboard. @param leaderboard_name [String] Name of the leaderboard. @param member [String] Member name. ''' self.redis_connection.hdel( ...
[ "def", "remove_member_data_in", "(", "self", ",", "leaderboard_name", ",", "member", ")", ":", "self", ".", "redis_connection", ".", "hdel", "(", "self", ".", "_member_data_key", "(", "leaderboard_name", ")", ",", "member", ")" ]
Remove the optional member data for a given member in the named leaderboard. @param leaderboard_name [String] Name of the leaderboard. @param member [String] Member name.
[ "Remove", "the", "optional", "member", "data", "for", "a", "given", "member", "in", "the", "named", "leaderboard", "." ]
python
train
37.8
GoogleCloudPlatform/appengine-gcs-client
python/src/cloudstorage/common.py
https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/d11078331ecd915d753c886e96a80133599f3f98/python/src/cloudstorage/common.py#L404-L413
def memory_usage(method): """Log memory usage before and after a method.""" def wrapper(*args, **kwargs): logging.info('Memory before method %s is %s.', method.__name__, runtime.memory_usage().current()) result = method(*args, **kwargs) logging.info('Memory after method %s is %s', ...
[ "def", "memory_usage", "(", "method", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logging", ".", "info", "(", "'Memory before method %s is %s.'", ",", "method", ".", "__name__", ",", "runtime", ".", "memory_usage", "("...
Log memory usage before and after a method.
[ "Log", "memory", "usage", "before", "and", "after", "a", "method", "." ]
python
train
40.8
ggaughan/pipe2py
pipe2py/modules/pipestrconcat.py
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/pipestrconcat.py#L54-L75
def pipe_strconcat(context=None, _INPUT=None, conf=None, **kwargs): """A string module that builds a string. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : pipeforever pipe or an iterable of items conf : { 'part': [ {'value': '<img src="'}, ...
[ "def", "pipe_strconcat", "(", "context", "=", "None", ",", "_INPUT", "=", "None", ",", "conf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "splits", "=", "get_splits", "(", "_INPUT", ",", "conf", "[", "'part'", "]", ",", "*", "*", "cdicts", "("...
A string module that builds a string. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : pipeforever pipe or an iterable of items conf : { 'part': [ {'value': '<img src="'}, {'subkey': 'img.src'}, {'value': '">'} ] } ...
[ "A", "string", "module", "that", "builds", "a", "string", ".", "Loopable", "." ]
python
train
26.272727
log2timeline/dftimewolf
dftimewolf/lib/collectors/grr_hosts.py
https://github.com/log2timeline/dftimewolf/blob/45f898476a288d73c4256ae8e3836a2a4848c0d7/dftimewolf/lib/collectors/grr_hosts.py#L178-L209
def _download_files(self, client, flow_id): """Download files from the specified flow. Args: client: GRR Client object to which to download flow data from. flow_id: GRR flow ID. Returns: str: path of downloaded files. """ output_file_path = os.path.join( self.output_path,...
[ "def", "_download_files", "(", "self", ",", "client", ",", "flow_id", ")", ":", "output_file_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "output_path", ",", "'.'", ".", "join", "(", "(", "flow_id", ",", "'zip'", ")", ")", ")", "if",...
Download files from the specified flow. Args: client: GRR Client object to which to download flow data from. flow_id: GRR flow ID. Returns: str: path of downloaded files.
[ "Download", "files", "from", "the", "specified", "flow", "." ]
python
train
30.9375
voidabhi/TheZineAPI
tz/tz.py
https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L148-L156
def from_soup(self,author,soup): """ Factory Pattern. Fetches contact data from given soup and builds the object """ email = soup.find('span',class_='icon icon-mail').findParent('a').get('href').split(':')[-1] if soup.find('span',class_='icon icon-mail') else '' facebook = soup.find('span',class_='icon ico...
[ "def", "from_soup", "(", "self", ",", "author", ",", "soup", ")", ":", "email", "=", "soup", ".", "find", "(", "'span'", ",", "class_", "=", "'icon icon-mail'", ")", ".", "findParent", "(", "'a'", ")", ".", "get", "(", "'href'", ")", ".", "split", ...
Factory Pattern. Fetches contact data from given soup and builds the object
[ "Factory", "Pattern", ".", "Fetches", "contact", "data", "from", "given", "soup", "and", "builds", "the", "object" ]
python
train
81.333333
kervi/kervi-devices
kervi/devices/gpio/MCP230XX.py
https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/gpio/MCP230XX.py#L60-L68
def define_as_input(self, pin, pullup=False): """Set the input or output mode for a specified pin. Mode should be either GPIO.OUT or GPIO.IN. """ self._validate_channel(pin) # Set bit to 1 for input or 0 for output. self.iodir[int(pin/8)] |= 1 << (int(pin%8)) sel...
[ "def", "define_as_input", "(", "self", ",", "pin", ",", "pullup", "=", "False", ")", ":", "self", ".", "_validate_channel", "(", "pin", ")", "# Set bit to 1 for input or 0 for output.", "self", ".", "iodir", "[", "int", "(", "pin", "/", "8", ")", "]", "|="...
Set the input or output mode for a specified pin. Mode should be either GPIO.OUT or GPIO.IN.
[ "Set", "the", "input", "or", "output", "mode", "for", "a", "specified", "pin", ".", "Mode", "should", "be", "either", "GPIO", ".", "OUT", "or", "GPIO", ".", "IN", "." ]
python
train
40.111111
Contraz/demosys-py
demosys/project/base.py
https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/project/base.py#L270-L276
def get_runnable_effects(self) -> List[Effect]: """ Returns all runnable effects in the project. :return: List of all runnable effects """ return [effect for name, effect in self._effects.items() if effect.runnable]
[ "def", "get_runnable_effects", "(", "self", ")", "->", "List", "[", "Effect", "]", ":", "return", "[", "effect", "for", "name", ",", "effect", "in", "self", ".", "_effects", ".", "items", "(", ")", "if", "effect", ".", "runnable", "]" ]
Returns all runnable effects in the project. :return: List of all runnable effects
[ "Returns", "all", "runnable", "effects", "in", "the", "project", ".", ":", "return", ":", "List", "of", "all", "runnable", "effects" ]
python
valid
36.571429
rvswift/EB
EB/builder/splitter/splitter_io.py
https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/splitter/splitter_io.py#L130-L168
def get_float(self, input_string): """ Return float type user input """ if input_string == '--training_fraction': # was the flag set? try: index = self.args.index(input_string) + 1 except ValueError: # it wasn't, it's optional, so...
[ "def", "get_float", "(", "self", ",", "input_string", ")", ":", "if", "input_string", "==", "'--training_fraction'", ":", "# was the flag set?", "try", ":", "index", "=", "self", ".", "args", ".", "index", "(", "input_string", ")", "+", "1", "except", "Value...
Return float type user input
[ "Return", "float", "type", "user", "input" ]
python
train
38.410256
twilio/twilio-python
twilio/rest/api/v2010/account/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/__init__.py#L450-L459
def keys(self): """ Access the keys :returns: twilio.rest.api.v2010.account.key.KeyList :rtype: twilio.rest.api.v2010.account.key.KeyList """ if self._keys is None: self._keys = KeyList(self._version, account_sid=self._solution['sid'], ) return self._...
[ "def", "keys", "(", "self", ")", ":", "if", "self", ".", "_keys", "is", "None", ":", "self", ".", "_keys", "=", "KeyList", "(", "self", ".", "_version", ",", "account_sid", "=", "self", ".", "_solution", "[", "'sid'", "]", ",", ")", "return", "self...
Access the keys :returns: twilio.rest.api.v2010.account.key.KeyList :rtype: twilio.rest.api.v2010.account.key.KeyList
[ "Access", "the", "keys" ]
python
train
31.5
RudolfCardinal/pythonlib
cardinal_pythonlib/logs.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/logs.py#L353-L366
def copy_root_log_to_file(filename: str, fmt: str = LOG_FORMAT, datefmt: str = LOG_DATEFMT) -> None: """ Copy all currently configured logs to the specified file. Should ONLY be called from the ``if __name__ == 'main'`` script; see https://docs.python...
[ "def", "copy_root_log_to_file", "(", "filename", ":", "str", ",", "fmt", ":", "str", "=", "LOG_FORMAT", ",", "datefmt", ":", "str", "=", "LOG_DATEFMT", ")", "->", "None", ":", "fh", "=", "logging", ".", "FileHandler", "(", "filename", ")", "# default file ...
Copy all currently configured logs to the specified file. Should ONLY be called from the ``if __name__ == 'main'`` script; see https://docs.python.org/3.4/howto/logging.html#library-config.
[ "Copy", "all", "currently", "configured", "logs", "to", "the", "specified", "file", "." ]
python
train
40.285714
Julian/Ivoire
ivoire/load.py
https://github.com/Julian/Ivoire/blob/5b8218cffa409ed733cf850a6fde16fafb8fc2af/ivoire/load.py#L43-L53
def discover(path, filter_specs=filter_specs): """ Discover all of the specs recursively inside ``path``. Successively yields the (full) relative paths to each spec. """ for dirpath, _, filenames in os.walk(path): for spec in filter_specs(filenames): yield os.path.join(dirpath...
[ "def", "discover", "(", "path", ",", "filter_specs", "=", "filter_specs", ")", ":", "for", "dirpath", ",", "_", ",", "filenames", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "spec", "in", "filter_specs", "(", "filenames", ")", ":", "yield", ...
Discover all of the specs recursively inside ``path``. Successively yields the (full) relative paths to each spec.
[ "Discover", "all", "of", "the", "specs", "recursively", "inside", "path", "." ]
python
test
28.818182
google/grr
grr/server/grr_response_server/databases/mem_flows.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_flows.py#L269-L297
def LeaseFlowForProcessing(self, client_id, flow_id, processing_time): """Marks a flow as being processed on this worker and returns it.""" rdf_flow = self.ReadFlowObject(client_id, flow_id) # TODO(user): remove the check for a legacy hunt prefix as soon as # AFF4 is gone. if rdf_flow.parent_hunt_id...
[ "def", "LeaseFlowForProcessing", "(", "self", ",", "client_id", ",", "flow_id", ",", "processing_time", ")", ":", "rdf_flow", "=", "self", ".", "ReadFlowObject", "(", "client_id", ",", "flow_id", ")", "# TODO(user): remove the check for a legacy hunt prefix as soon as", ...
Marks a flow as being processed on this worker and returns it.
[ "Marks", "a", "flow", "as", "being", "processed", "on", "this", "worker", "and", "returns", "it", "." ]
python
train
46.655172
cidrblock/modelsettings
modelsettings/__init__.py
https://github.com/cidrblock/modelsettings/blob/09763c111fb38b3ba7a13cc95ca59e4393fe75ba/modelsettings/__init__.py#L261-L273
def generate_docker_compose(self): """ Generate a sample docker compose """ example = {} example['app'] = {} example['app']['environment'] = [] for key in sorted(list(self.spec.keys())): if self.spec[key]['type'] in (dict, list): value = f"\'{j...
[ "def", "generate_docker_compose", "(", "self", ")", ":", "example", "=", "{", "}", "example", "[", "'app'", "]", "=", "{", "}", "example", "[", "'app'", "]", "[", "'environment'", "]", "=", "[", "]", "for", "key", "in", "sorted", "(", "list", "(", ...
Generate a sample docker compose
[ "Generate", "a", "sample", "docker", "compose" ]
python
train
45.384615
openid/JWTConnect-Python-OidcService
src/oidcservice/service.py
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/service.py#L402-L496
def parse_response(self, info, sformat="", state="", **kwargs): """ This the start of a pipeline that will: 1 Deserializes a response into it's response message class. Or :py:class:`oidcmsg.oauth2.ErrorResponse` if it's an error message 2 verifies the...
[ "def", "parse_response", "(", "self", ",", "info", ",", "sformat", "=", "\"\"", ",", "state", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "if", "not", "sformat", ":", "sformat", "=", "self", ".", "response_body_type", "logger", ".", "debug", "(", ...
This the start of a pipeline that will: 1 Deserializes a response into it's response message class. Or :py:class:`oidcmsg.oauth2.ErrorResponse` if it's an error message 2 verifies the correctness of the response by running the verify method belonging to...
[ "This", "the", "start", "of", "a", "pipeline", "that", "will", ":" ]
python
train
38.263158
F5Networks/f5-icontrol-rest-python
icontrol/session.py
https://github.com/F5Networks/f5-icontrol-rest-python/blob/34bb916299f4a00829352e7eb9818589408fa35a/icontrol/session.py#L300-L341
def _unique_resource_identifier_from_kwargs(**kwargs): """Chooses an identifier given different choices The unique identifier in BIG-IP's REST API at the time of this writing is called 'name'. This is in contrast to the unique identifier that is used by iWorkflow and BIG-IQ which at some times is 'name...
[ "def", "_unique_resource_identifier_from_kwargs", "(", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", ".", "pop", "(", "'name'", ",", "''", ")", "uuid", "=", "kwargs", ".", "pop", "(", "'uuid'", ",", "''", ")", "id", "=", "kwargs", ".", "pop", ...
Chooses an identifier given different choices The unique identifier in BIG-IP's REST API at the time of this writing is called 'name'. This is in contrast to the unique identifier that is used by iWorkflow and BIG-IQ which at some times is 'name' and other times is 'uuid'. For example, in iWorkflo...
[ "Chooses", "an", "identifier", "given", "different", "choices" ]
python
train
36.904762
quiltdata/quilt
compiler/quilt/tools/hashing.py
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/hashing.py#L5-L27
def digest_file(fname): """ Digest files using SHA-2 (256-bit) TESTING Produces identical output to `openssl sha256 FILE` for the following: * on all source .py files and some binary pyc files in parent dir * empty files with different names * 3.3GB DNAse Hypersensitive file * ...
[ "def", "digest_file", "(", "fname", ")", ":", "#chunk size in bytes", "size", "=", "4096", "hval", "=", "hashlib", ".", "new", "(", "HASH_TYPE", ")", "with", "open", "(", "fname", ",", "'rb'", ")", "as", "fd", ":", "for", "chunk", "in", "iter", "(", ...
Digest files using SHA-2 (256-bit) TESTING Produces identical output to `openssl sha256 FILE` for the following: * on all source .py files and some binary pyc files in parent dir * empty files with different names * 3.3GB DNAse Hypersensitive file * empty file, file with one space, fil...
[ "Digest", "files", "using", "SHA", "-", "2", "(", "256", "-", "bit", ")", "TESTING", "Produces", "identical", "output", "to", "openssl", "sha256", "FILE", "for", "the", "following", ":", "*", "on", "all", "source", ".", "py", "files", "and", "some", "b...
python
train
38.869565
andymccurdy/redis-py
redis/client.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L1189-L1207
def bitpos(self, key, bit, start=None, end=None): """ Return the position of the first bit set to 1 or 0 in a string. ``start`` and ``end`` difines search range. The range is interpreted as a range of bytes and not a range of bits, so start=0 and end=2 means to look at the first ...
[ "def", "bitpos", "(", "self", ",", "key", ",", "bit", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "if", "bit", "not", "in", "(", "0", ",", "1", ")", ":", "raise", "DataError", "(", "'bit must be 0 or 1'", ")", "params", "=", "["...
Return the position of the first bit set to 1 or 0 in a string. ``start`` and ``end`` difines search range. The range is interpreted as a range of bytes and not a range of bits, so start=0 and end=2 means to look at the first three bytes.
[ "Return", "the", "position", "of", "the", "first", "bit", "set", "to", "1", "or", "0", "in", "a", "string", ".", "start", "and", "end", "difines", "search", "range", ".", "The", "range", "is", "interpreted", "as", "a", "range", "of", "bytes", "and", ...
python
train
41.157895
ismms-himc/clustergrammer2
clustergrammer2/clustergrammer_fun/__init__.py
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L406-L438
def enrichrgram(self, lib, axis='row'): ''' Add Enrichr gene enrichment results to your visualization (where your rows are genes). Run enrichrgram before clustering to incldue enrichment results as row categories. Enrichrgram can also be run on the front-end using the Enrichr logo at the top left. ...
[ "def", "enrichrgram", "(", "self", ",", "lib", ",", "axis", "=", "'row'", ")", ":", "df", "=", "self", ".", "export_df", "(", ")", "df", ",", "bar_info", "=", "enr_fun", ".", "add_enrichr_cats", "(", "df", ",", "axis", ",", "lib", ")", "self", ".",...
Add Enrichr gene enrichment results to your visualization (where your rows are genes). Run enrichrgram before clustering to incldue enrichment results as row categories. Enrichrgram can also be run on the front-end using the Enrichr logo at the top left. Set lib to the Enrichr library that you want to ...
[ "Add", "Enrichr", "gene", "enrichment", "results", "to", "your", "visualization", "(", "where", "your", "rows", "are", "genes", ")", ".", "Run", "enrichrgram", "before", "clustering", "to", "incldue", "enrichment", "results", "as", "row", "categories", ".", "E...
python
train
31.393939
StackStorm/pybind
pybind/nos/v7_2_0/rbridge_id/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v7_2_0/rbridge_id/__init__.py#L1598-L1619
def _set_telnet(self, v, load=False): """ Setter method for telnet, mapped from YANG variable /rbridge_id/telnet (container) If this variable is read-only (config: false) in the source YANG file, then _set_telnet is considered as a private method. Backends looking to populate this variable should ...
[ "def", "_set_telnet", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for telnet, mapped from YANG variable /rbridge_id/telnet (container) If this variable is read-only (config: false) in the source YANG file, then _set_telnet is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_telnet() directly...
[ "Setter", "method", "for", "telnet", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "telnet", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "fil...
python
train
75.409091
ThreatConnect-Inc/tcex
tcex/tcex_ti/tcex_ti.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/tcex_ti.py#L253-L265
def campaign(self, name, owner=None, **kwargs): """ Create the Campaign TI object. Args: owner: name: **kwargs: Return: """ return Campaign(self.tcex, name, owner=owner, **kwargs)
[ "def", "campaign", "(", "self", ",", "name", ",", "owner", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Campaign", "(", "self", ".", "tcex", ",", "name", ",", "owner", "=", "owner", ",", "*", "*", "kwargs", ")" ]
Create the Campaign TI object. Args: owner: name: **kwargs: Return:
[ "Create", "the", "Campaign", "TI", "object", "." ]
python
train
19.538462
Contraz/pyrocket
rocket/connectors/socket.py
https://github.com/Contraz/pyrocket/blob/97f4153c79030497b97fbaf43b1aa6dc1a6c7f7b/rocket/connectors/socket.py#L87-L112
def read_command(self): """ Attempt to read the next command from the editor/server :return: boolean. Did we actually read a command? """ # Do a non-blocking read here so the demo can keep running if there is no data comm = self.reader.byte(blocking=False) if comm...
[ "def", "read_command", "(", "self", ")", ":", "# Do a non-blocking read here so the demo can keep running if there is no data", "comm", "=", "self", ".", "reader", ".", "byte", "(", "blocking", "=", "False", ")", "if", "comm", "is", "None", ":", "return", "False", ...
Attempt to read the next command from the editor/server :return: boolean. Did we actually read a command?
[ "Attempt", "to", "read", "the", "next", "command", "from", "the", "editor", "/", "server", ":", "return", ":", "boolean", ".", "Did", "we", "actually", "read", "a", "command?" ]
python
train
28.192308
apple/turicreate
src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_converter.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_converter.py#L10-L148
def convert(sk_obj, input_features = None, output_feature_names = None): """ Convert scikit-learn pipeline, classifier, or regressor to Core ML format. Parameters ---------- sk_obj: model | [model] of scikit-learn format. Scikit learn model(s) to convert to a Core ML format. ...
[ "def", "convert", "(", "sk_obj", ",", "input_features", "=", "None", ",", "output_feature_names", "=", "None", ")", ":", "# This function is just a thin wrapper around the internal converter so", "# that sklearn isn't actually imported unless this function is called", "from", ".", ...
Convert scikit-learn pipeline, classifier, or regressor to Core ML format. Parameters ---------- sk_obj: model | [model] of scikit-learn format. Scikit learn model(s) to convert to a Core ML format. The input model may be a single scikit learn model, a scikit learn pipeline model, ...
[ "Convert", "scikit", "-", "learn", "pipeline", "classifier", "or", "regressor", "to", "Core", "ML", "format", "." ]
python
train
35.877698
allianceauth/allianceauth
allianceauth/groupmanagement/managers.py
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/groupmanagement/managers.py#L31-L42
def can_manage_groups(cls, user): """ For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for ...
[ "def", "can_manage_groups", "(", "cls", ",", "user", ")", ":", "if", "user", ".", "is_authenticated", ":", "return", "cls", ".", "has_management_permission", "(", "user", ")", "or", "user", ".", "leads_groups", ".", "all", "(", ")", "return", "False" ]
For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for the request :return: bool True if user can man...
[ "For", "use", "with", "user_passes_test", "decorator", ".", "Check", "if", "the", "user", "can", "manage", "groups", ".", "Either", "has", "the", "auth", ".", "group_management", "permission", "or", "is", "a", "leader", "of", "at", "least", "one", "group", ...
python
train
44.916667
bids-standard/pybids
bids/variables/variables.py
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L527-L567
def merge_variables(variables, name=None, **kwargs): '''Merge/concatenate a list of variables along the row axis. Parameters ---------- variables : :obj:`list` A list of Variables to merge. name : :obj:`str` Optional name to assign to the output Variable. By default, uses the ...
[ "def", "merge_variables", "(", "variables", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "classes", "=", "set", "(", "[", "v", ".", "__class__", "for", "v", "in", "variables", "]", ")", "if", "len", "(", "classes", ")", ">", "1", ...
Merge/concatenate a list of variables along the row axis. Parameters ---------- variables : :obj:`list` A list of Variables to merge. name : :obj:`str` Optional name to assign to the output Variable. By default, uses the same name as the input variables. kwargs Optio...
[ "Merge", "/", "concatenate", "a", "list", "of", "variables", "along", "the", "row", "axis", "." ]
python
train
40.512195
quodlibet/mutagen
mutagen/asf/__init__.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/asf/__init__.py#L67-L75
def pprint(self): """Returns: text: a stream information text summary """ s = u"ASF (%s) %d bps, %s Hz, %d channels, %.2f seconds" % ( self.codec_type or self.codec_name or u"???", self.bitrate, self.sample_rate, self.channels, self.length) return s
[ "def", "pprint", "(", "self", ")", ":", "s", "=", "u\"ASF (%s) %d bps, %s Hz, %d channels, %.2f seconds\"", "%", "(", "self", ".", "codec_type", "or", "self", ".", "codec_name", "or", "u\"???\"", ",", "self", ".", "bitrate", ",", "self", ".", "sample_rate", ",...
Returns: text: a stream information text summary
[ "Returns", ":", "text", ":", "a", "stream", "information", "text", "summary" ]
python
train
34.444444
HIPS/autograd
autograd/differential_operators.py
https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L69-L73
def grad_named(fun, argname): '''Takes gradients with respect to a named argument. Doesn't work on *args or **kwargs.''' arg_index = getargspec(fun).args.index(argname) return grad(fun, arg_index)
[ "def", "grad_named", "(", "fun", ",", "argname", ")", ":", "arg_index", "=", "getargspec", "(", "fun", ")", ".", "args", ".", "index", "(", "argname", ")", "return", "grad", "(", "fun", ",", "arg_index", ")" ]
Takes gradients with respect to a named argument. Doesn't work on *args or **kwargs.
[ "Takes", "gradients", "with", "respect", "to", "a", "named", "argument", ".", "Doesn", "t", "work", "on", "*", "args", "or", "**", "kwargs", "." ]
python
train
42.2
keunwoochoi/kapre
kapre/backend.py
https://github.com/keunwoochoi/kapre/blob/8517f45d3ccb9fff1ec0049b9c3e4389f81c20aa/kapre/backend.py#L29-L40
def mel(sr, n_dft, n_mels=128, fmin=0.0, fmax=None, htk=False, norm=1): """[np] create a filterbank matrix to combine stft bins into mel-frequency bins use Slaney (said Librosa) n_mels: numbre of mel bands fmin : lowest frequency [Hz] fmax : highest frequency [Hz] If `None`, use `sr / 2.0` ...
[ "def", "mel", "(", "sr", ",", "n_dft", ",", "n_mels", "=", "128", ",", "fmin", "=", "0.0", ",", "fmax", "=", "None", ",", "htk", "=", "False", ",", "norm", "=", "1", ")", ":", "return", "librosa", ".", "filters", ".", "mel", "(", "sr", "=", "...
[np] create a filterbank matrix to combine stft bins into mel-frequency bins use Slaney (said Librosa) n_mels: numbre of mel bands fmin : lowest frequency [Hz] fmax : highest frequency [Hz] If `None`, use `sr / 2.0`
[ "[", "np", "]", "create", "a", "filterbank", "matrix", "to", "combine", "stft", "bins", "into", "mel", "-", "frequency", "bins", "use", "Slaney", "(", "said", "Librosa", ")" ]
python
train
42.083333
saltstack/salt
salt/returners/mongo_return.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mongo_return.py#L127-L165
def _get_conn(ret): ''' Return a mongodb connection object ''' _options = _get_options(ret) host = _options.get('host') port = _options.get('port') db_ = _options.get('db') user = _options.get('user') password = _options.get('password') indexes = _options.get('indexes', False) ...
[ "def", "_get_conn", "(", "ret", ")", ":", "_options", "=", "_get_options", "(", "ret", ")", "host", "=", "_options", ".", "get", "(", "'host'", ")", "port", "=", "_options", ".", "get", "(", "'port'", ")", "db_", "=", "_options", ".", "get", "(", "...
Return a mongodb connection object
[ "Return", "a", "mongodb", "connection", "object" ]
python
train
27.25641
dropbox/stone
stone/backends/python_helpers.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/python_helpers.py#L119-L151
def generate_imports_for_referenced_namespaces( backend, namespace, insert_type_ignore=False): # type: (Backend, ApiNamespace, bool) -> None """ Both the true Python backend and the Python PEP 484 Type Stub backend have to perform the same imports. :param insert_type_ignore: add a MyPy type...
[ "def", "generate_imports_for_referenced_namespaces", "(", "backend", ",", "namespace", ",", "insert_type_ignore", "=", "False", ")", ":", "# type: (Backend, ApiNamespace, bool) -> None", "imported_namespaces", "=", "namespace", ".", "get_imported_namespaces", "(", "consider_ann...
Both the true Python backend and the Python PEP 484 Type Stub backend have to perform the same imports. :param insert_type_ignore: add a MyPy type-ignore comment to the imports in the except: clause.
[ "Both", "the", "true", "Python", "backend", "and", "the", "Python", "PEP", "484", "Type", "Stub", "backend", "have", "to", "perform", "the", "same", "imports", "." ]
python
train
37.424242
cgoldberg/sauceclient
sauceclient.py
https://github.com/cgoldberg/sauceclient/blob/aa27b7da8eb2e483adc2754c694fe5082e1fa8f7/sauceclient.py#L100-L104
def get_user(self): """Access basic account information.""" method = 'GET' endpoint = '/rest/v1/users/{}'.format(self.client.sauce_username) return self.client.request(method, endpoint)
[ "def", "get_user", "(", "self", ")", ":", "method", "=", "'GET'", "endpoint", "=", "'/rest/v1/users/{}'", ".", "format", "(", "self", ".", "client", ".", "sauce_username", ")", "return", "self", ".", "client", ".", "request", "(", "method", ",", "endpoint"...
Access basic account information.
[ "Access", "basic", "account", "information", "." ]
python
train
42.6
KeithSSmith/switcheo-python
switcheo/utils.py
https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/utils.py#L101-L105
def get(self, path, params=None): """Perform GET request""" r = requests.get(url=self.url + path, params=params, timeout=self.timeout) r.raise_for_status() return r.json()
[ "def", "get", "(", "self", ",", "path", ",", "params", "=", "None", ")", ":", "r", "=", "requests", ".", "get", "(", "url", "=", "self", ".", "url", "+", "path", ",", "params", "=", "params", ",", "timeout", "=", "self", ".", "timeout", ")", "r...
Perform GET request
[ "Perform", "GET", "request" ]
python
train
39.8
bjodah/pyodesys
pyodesys/symbolic.py
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L637-L650
def get_jac(self): """ Derives the jacobian from ``self.exprs`` and ``self.dep``. """ if self._jac is True: if self.sparse is True: self._jac, self._colptrs, self._rowvals = self.be.sparse_jacobian_csc(self.exprs, self.dep) elif self.band is not None: # Banded ...
[ "def", "get_jac", "(", "self", ")", ":", "if", "self", ".", "_jac", "is", "True", ":", "if", "self", ".", "sparse", "is", "True", ":", "self", ".", "_jac", ",", "self", ".", "_colptrs", ",", "self", ".", "_rowvals", "=", "self", ".", "be", ".", ...
Derives the jacobian from ``self.exprs`` and ``self.dep``.
[ "Derives", "the", "jacobian", "from", "self", ".", "exprs", "and", "self", ".", "dep", "." ]
python
train
44.857143
pandas-dev/pandas
pandas/core/indexes/multi.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L1026-L1076
def _set_names(self, names, level=None, validate=True): """ Set new names on index. Each name has to be a hashable type. Parameters ---------- values : str or sequence name(s) to set level : int, level name, or sequence of int/level names (default None) ...
[ "def", "_set_names", "(", "self", ",", "names", ",", "level", "=", "None", ",", "validate", "=", "True", ")", ":", "# GH 15110", "# Don't allow a single string for names in a MultiIndex", "if", "names", "is", "not", "None", "and", "not", "is_list_like", "(", "na...
Set new names on index. Each name has to be a hashable type. Parameters ---------- values : str or sequence name(s) to set level : int, level name, or sequence of int/level names (default None) If the index is a MultiIndex (hierarchical), level(s) to set (None ...
[ "Set", "new", "names", "on", "index", ".", "Each", "name", "has", "to", "be", "a", "hashable", "type", "." ]
python
train
37.901961
odlgroup/odl
odl/util/utility.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/util/utility.py#L1309-L1430
def method_repr_string(inst_str, meth_str, arg_strs=None, allow_mixed_seps=True): r"""Return a repr string for a method that respects line width. This function is useful to generate a ``repr`` string for a derived class that is created through a method, for instance :: funct...
[ "def", "method_repr_string", "(", "inst_str", ",", "meth_str", ",", "arg_strs", "=", "None", ",", "allow_mixed_seps", "=", "True", ")", ":", "linewidth", "=", "np", ".", "get_printoptions", "(", ")", "[", "'linewidth'", "]", "# Part up to the method name", "if",...
r"""Return a repr string for a method that respects line width. This function is useful to generate a ``repr`` string for a derived class that is created through a method, for instance :: functional.translated(x) as a better way of representing :: FunctionalTranslation(functional, x) ...
[ "r", "Return", "a", "repr", "string", "for", "a", "method", "that", "respects", "line", "width", "." ]
python
train
35.778689
glitchassassin/lackey
lackey/PlatformManagerWindows.py
https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/PlatformManagerWindows.py#L557-L563
def focusWindow(self, hwnd): """ Brings specified window to the front """ Debug.log(3, "Focusing window: " + str(hwnd)) SW_RESTORE = 9 if ctypes.windll.user32.IsIconic(hwnd): ctypes.windll.user32.ShowWindow(hwnd, SW_RESTORE) ctypes.windll.user32.SetForegroundWindow(hw...
[ "def", "focusWindow", "(", "self", ",", "hwnd", ")", ":", "Debug", ".", "log", "(", "3", ",", "\"Focusing window: \"", "+", "str", "(", "hwnd", ")", ")", "SW_RESTORE", "=", "9", "if", "ctypes", ".", "windll", ".", "user32", ".", "IsIconic", "(", "hwn...
Brings specified window to the front
[ "Brings", "specified", "window", "to", "the", "front" ]
python
train
45.285714