repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
edx/edx-enterprise
integrated_channels/integrated_channel/transmitters/learner_data.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/learner_data.py#L37-L95
def transmit(self, payload, **kwargs): """ Send a completion status call to the integrated channel using the client. Args: payload: The learner completion data payload to send to the integrated channel. kwargs: Contains integrated channel-specific information for customi...
[ "def", "transmit", "(", "self", ",", "payload", ",", "*", "*", "kwargs", ")", ":", "IntegratedChannelLearnerDataTransmissionAudit", "=", "apps", ".", "get_model", "(", "# pylint: disable=invalid-name", "app_label", "=", "kwargs", ".", "get", "(", "'app_label'", ",...
Send a completion status call to the integrated channel using the client. Args: payload: The learner completion data payload to send to the integrated channel. kwargs: Contains integrated channel-specific information for customized transmission variables. - app_label: Th...
[ "Send", "a", "completion", "status", "call", "to", "the", "integrated", "channel", "using", "the", "client", "." ]
python
valid
typlog/sphinx-typlog-theme
sphinx_typlog_theme/__init__.py
https://github.com/typlog/sphinx-typlog-theme/blob/25e26fbbf406da82d842a5ee995aa177be931340/sphinx_typlog_theme/__init__.py#L50-L88
def add_github_roles(app, repo): """Add ``gh`` role to your sphinx documents. It can generate GitHub links easily:: :gh:`issue#57` will generate the issue link :gh:`PR#85` will generate the pull request link Use this function in ``conf.py`` to enable this feature:: def setup(app):...
[ "def", "add_github_roles", "(", "app", ",", "repo", ")", ":", "from", "docutils", ".", "nodes", "import", "reference", "from", "docutils", ".", "parsers", ".", "rst", ".", "roles", "import", "set_classes", "base_url", "=", "'https://github.com/{}'", ".", "form...
Add ``gh`` role to your sphinx documents. It can generate GitHub links easily:: :gh:`issue#57` will generate the issue link :gh:`PR#85` will generate the pull request link Use this function in ``conf.py`` to enable this feature:: def setup(app): sphinx_typlog_theme.add_git...
[ "Add", "gh", "role", "to", "your", "sphinx", "documents", ".", "It", "can", "generate", "GitHub", "links", "easily", "::" ]
python
train
brocade/pynos
pynos/versions/base/firmware.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/firmware.py#L41-L56
def download(self, protocol, host, user, password, file_name, rbridge='all'): """ Download firmware to device """ urn = "{urn:brocade.com:mgmt:brocade-firmware}" request_fwdl = self.get_firmware_download_request(protocol, host, ...
[ "def", "download", "(", "self", ",", "protocol", ",", "host", ",", "user", ",", "password", ",", "file_name", ",", "rbridge", "=", "'all'", ")", ":", "urn", "=", "\"{urn:brocade.com:mgmt:brocade-firmware}\"", "request_fwdl", "=", "self", ".", "get_firmware_downl...
Download firmware to device
[ "Download", "firmware", "to", "device" ]
python
train
nocarryr/python-dispatch
pydispatch/dispatch.py
https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L199-L215
def unbind(self, *args): """Unsubscribes from events or :class:`~pydispatch.properties.Property` updates Multiple arguments can be given. Each of which can be either the method that was used for the original call to :meth:`bind` or an instance object. If an instance of an objec...
[ "def", "unbind", "(", "self", ",", "*", "args", ")", ":", "props", "=", "self", ".", "__property_events", ".", "values", "(", ")", "events", "=", "self", ".", "__events", ".", "values", "(", ")", "for", "arg", "in", "args", ":", "for", "prop", "in"...
Unsubscribes from events or :class:`~pydispatch.properties.Property` updates Multiple arguments can be given. Each of which can be either the method that was used for the original call to :meth:`bind` or an instance object. If an instance of an object is supplied, any previously bound ...
[ "Unsubscribes", "from", "events", "or", ":", "class", ":", "~pydispatch", ".", "properties", ".", "Property", "updates" ]
python
train
sublee/zeronimo
zeronimo/core.py
https://github.com/sublee/zeronimo/blob/b216638232932718d2cbc5eabd870c8f5b5e83fb/zeronimo/core.py#L336-L339
def reject(self, reply_socket, call_id, topics=()): """Sends REJECT reply.""" info = self.info or b'' self.send_raw(reply_socket, REJECT, info, call_id, b'', topics)
[ "def", "reject", "(", "self", ",", "reply_socket", ",", "call_id", ",", "topics", "=", "(", ")", ")", ":", "info", "=", "self", ".", "info", "or", "b''", "self", ".", "send_raw", "(", "reply_socket", ",", "REJECT", ",", "info", ",", "call_id", ",", ...
Sends REJECT reply.
[ "Sends", "REJECT", "reply", "." ]
python
test
infobloxopen/infoblox-client
infoblox_client/object_manager.py
https://github.com/infobloxopen/infoblox-client/blob/edeec62db1935784c728731b2ae7cf0fcc9bf84d/infoblox_client/object_manager.py#L103-L113
def create_ip_range(self, network_view, start_ip, end_ip, network, disable, range_extattrs): """Creates IPRange or fails if already exists.""" return obj.IPRange.create(self.connector, network_view=network_view, ...
[ "def", "create_ip_range", "(", "self", ",", "network_view", ",", "start_ip", ",", "end_ip", ",", "network", ",", "disable", ",", "range_extattrs", ")", ":", "return", "obj", ".", "IPRange", ".", "create", "(", "self", ".", "connector", ",", "network_view", ...
Creates IPRange or fails if already exists.
[ "Creates", "IPRange", "or", "fails", "if", "already", "exists", "." ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/discoursegraph.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/discoursegraph.py#L1146-L1188
def select_nodes_by_attribute(docgraph, attribute=None, value=None, data=False): """ Get all nodes with the given attribute (and attribute value). Parameters ---------- docgraph : DiscourseDocumentGraph document graph from which the nodes will be extracted attribute : str or None ...
[ "def", "select_nodes_by_attribute", "(", "docgraph", ",", "attribute", "=", "None", ",", "value", "=", "None", ",", "data", "=", "False", ")", ":", "for", "node_id", ",", "node_attribs", "in", "docgraph", ".", "nodes_iter", "(", "data", "=", "True", ")", ...
Get all nodes with the given attribute (and attribute value). Parameters ---------- docgraph : DiscourseDocumentGraph document graph from which the nodes will be extracted attribute : str or None Name of the node attribute that all nodes must posess. If None, returns all nodes. ...
[ "Get", "all", "nodes", "with", "the", "given", "attribute", "(", "and", "attribute", "value", ")", "." ]
python
train
adrn/gala
gala/dynamics/core.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/core.py#L300-L346
def represent_as(self, new_pos, new_vel=None): """ Represent the position and velocity of the orbit in an alternate coordinate system. Supports any of the Astropy coordinates representation classes. Parameters ---------- new_pos : :class:`~astropy.coordinates.Bas...
[ "def", "represent_as", "(", "self", ",", "new_pos", ",", "new_vel", "=", "None", ")", ":", "if", "self", ".", "ndim", "!=", "3", ":", "raise", "ValueError", "(", "\"Can only change representation for \"", "\"ndim=3 instances.\"", ")", "# get the name of the desired ...
Represent the position and velocity of the orbit in an alternate coordinate system. Supports any of the Astropy coordinates representation classes. Parameters ---------- new_pos : :class:`~astropy.coordinates.BaseRepresentation` The type of representation to generate...
[ "Represent", "the", "position", "and", "velocity", "of", "the", "orbit", "in", "an", "alternate", "coordinate", "system", ".", "Supports", "any", "of", "the", "Astropy", "coordinates", "representation", "classes", "." ]
python
train
datastax/python-driver
cassandra/cqlengine/query.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cqlengine/query.py#L622-L633
def consistency(self, consistency): """ Sets the consistency level for the operation. See :class:`.ConsistencyLevel`. .. code-block:: python for user in User.objects(id=3).consistency(CL.ONE): print(user) """ clone = copy.deepcopy(self) clone...
[ "def", "consistency", "(", "self", ",", "consistency", ")", ":", "clone", "=", "copy", ".", "deepcopy", "(", "self", ")", "clone", ".", "_consistency", "=", "consistency", "return", "clone" ]
Sets the consistency level for the operation. See :class:`.ConsistencyLevel`. .. code-block:: python for user in User.objects(id=3).consistency(CL.ONE): print(user)
[ "Sets", "the", "consistency", "level", "for", "the", "operation", ".", "See", ":", "class", ":", ".", "ConsistencyLevel", "." ]
python
train
pyviz/holoviews
holoviews/core/options.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/options.py#L744-L766
def options(self, group, target=None, defaults=True): """ Using inheritance up to the root, get the complete Options object for the given node and the specified group. """ if target is None: target = self.path if self.groups.get(group, None) is None: ...
[ "def", "options", "(", "self", ",", "group", ",", "target", "=", "None", ",", "defaults", "=", "True", ")", ":", "if", "target", "is", "None", ":", "target", "=", "self", ".", "path", "if", "self", ".", "groups", ".", "get", "(", "group", ",", "N...
Using inheritance up to the root, get the complete Options object for the given node and the specified group.
[ "Using", "inheritance", "up", "to", "the", "root", "get", "the", "complete", "Options", "object", "for", "the", "given", "node", "and", "the", "specified", "group", "." ]
python
train
ljcooke/see
see/inspector.py
https://github.com/ljcooke/see/blob/4cbc67a31c92367977ecb4bbb1f0736fa688a6ba/see/inspector.py#L44-L64
def handle_deprecated_args(tokens, args, kwargs): """ Backwards compatibility with deprecated arguments ``pattern`` and ``r``. """ num_args = len(args) pattern = args[0] if num_args else kwargs.get('pattern', None) regex = args[1] if num_args > 1 else kwargs.get('r', None) if pattern is not...
[ "def", "handle_deprecated_args", "(", "tokens", ",", "args", ",", "kwargs", ")", ":", "num_args", "=", "len", "(", "args", ")", "pattern", "=", "args", "[", "0", "]", "if", "num_args", "else", "kwargs", ".", "get", "(", "'pattern'", ",", "None", ")", ...
Backwards compatibility with deprecated arguments ``pattern`` and ``r``.
[ "Backwards", "compatibility", "with", "deprecated", "arguments", "pattern", "and", "r", "." ]
python
train
jahuth/litus
spikes.py
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L1201-L1232
def temporal_firing_rate(self,time_dimension=0,resolution=1.0,units=None, min_t=None,max_t=None,weight_function=None,normalize_time=False, normalize_n=False,start_units_with_0=True,cell_dimension='N'): """ Outputs a time histogram of spikes. ...
[ "def", "temporal_firing_rate", "(", "self", ",", "time_dimension", "=", "0", ",", "resolution", "=", "1.0", ",", "units", "=", "None", ",", "min_t", "=", "None", ",", "max_t", "=", "None", ",", "weight_function", "=", "None", ",", "normalize_time", "=", ...
Outputs a time histogram of spikes. `bins`: number of bins (default is 1ms bins from 0 to t_max) `weight_function`: if set, computes a weighted histogram, dependent on the (index, time) tuples of each spike weight_function = lambda x: weight_map.flatten()[array(x[:,0],dtype...
[ "Outputs", "a", "time", "histogram", "of", "spikes", "." ]
python
train
MAVENSDC/cdflib
cdflib/cdfwrite.py
https://github.com/MAVENSDC/cdflib/blob/d237c60e5db67db0f92d96054209c25c4042465c/cdflib/cdfwrite.py#L2101-L2126
def _convert_nptype(data_type, data): # @NoSelf ''' Converts "data" of CDF type "data_type" into a numpy array ''' if data_type in (1, 41): return np.int8(data).tobytes() elif data_type == 2: return np.int16(data).tobytes() elif data_type == 4: ...
[ "def", "_convert_nptype", "(", "data_type", ",", "data", ")", ":", "# @NoSelf", "if", "data_type", "in", "(", "1", ",", "41", ")", ":", "return", "np", ".", "int8", "(", "data", ")", ".", "tobytes", "(", ")", "elif", "data_type", "==", "2", ":", "r...
Converts "data" of CDF type "data_type" into a numpy array
[ "Converts", "data", "of", "CDF", "type", "data_type", "into", "a", "numpy", "array" ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/paulaxml/paula.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/paulaxml/paula.py#L540-L564
def __gen_annoset_file(self): """ An ``annoSet`` file describes the set of annotations contained in a document (i.e. it lists all annotation files that belong to a PAULA document). Each PAULA document must contain an annoSet file. An ``annoSet`` file can also be used to list the...
[ "def", "__gen_annoset_file", "(", "self", ")", ":", "paula_id", "=", "'{0}.{1}.anno'", ".", "format", "(", "self", ".", "corpus_name", ",", "self", ".", "name", ")", "E", ",", "tree", "=", "gen_paula_etree", "(", "paula_id", ")", "slist", "=", "E", "(", ...
An ``annoSet`` file describes the set of annotations contained in a document (i.e. it lists all annotation files that belong to a PAULA document). Each PAULA document must contain an annoSet file. An ``annoSet`` file can also be used to list the contents of a (sub)corpus, but we're not ...
[ "An", "annoSet", "file", "describes", "the", "set", "of", "annotations", "contained", "in", "a", "document", "(", "i", ".", "e", ".", "it", "lists", "all", "annotation", "files", "that", "belong", "to", "a", "PAULA", "document", ")", ".", "Each", "PAULA"...
python
train
ets-labs/python-dependency-injector
examples/miniapps/movie_lister/example/db.py
https://github.com/ets-labs/python-dependency-injector/blob/d04fe41eb17f667da38b97525e2d16c8f2d272fe/examples/miniapps/movie_lister/example/db.py#L6-L19
def init_sqlite(movies_data, database): """Initialize sqlite3 movies database. :param movies_data: Data about movies :type movies_data: tuple[tuple] :param database: Connection to sqlite database with movies data :type database: sqlite3.Connection """ with database: database.execut...
[ "def", "init_sqlite", "(", "movies_data", ",", "database", ")", ":", "with", "database", ":", "database", ".", "execute", "(", "'CREATE TABLE IF NOT EXISTS movies '", "'(name text, year int, director text)'", ")", "database", ".", "execute", "(", "'DELETE FROM movies'", ...
Initialize sqlite3 movies database. :param movies_data: Data about movies :type movies_data: tuple[tuple] :param database: Connection to sqlite database with movies data :type database: sqlite3.Connection
[ "Initialize", "sqlite3", "movies", "database", "." ]
python
train
JarryShaw/PyPCAPKit
src/protocols/application/httpv2.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/application/httpv2.py#L386-L421
def _read_http_rst_stream(self, size, kind, flag): """Read HTTP/2 RST_STREAM frames. Structure of HTTP/2 RST_STREAM frame [RFC 7540]: +-----------------------------------------------+ | Length (24) | +---------------+---------------+...
[ "def", "_read_http_rst_stream", "(", "self", ",", "size", ",", "kind", ",", "flag", ")", ":", "if", "size", "!=", "8", ":", "raise", "ProtocolError", "(", "f'HTTP/2: [Type {kind}] invalid format'", ",", "quiet", "=", "True", ")", "if", "any", "(", "(", "in...
Read HTTP/2 RST_STREAM frames. Structure of HTTP/2 RST_STREAM frame [RFC 7540]: +-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) |...
[ "Read", "HTTP", "/", "2", "RST_STREAM", "frames", "." ]
python
train
deepmipt/DeepPavlov
deeppavlov/metrics/recall_at_k.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/metrics/recall_at_k.py#L23-L43
def recall_at_k(y_true: List[int], y_pred: List[List[np.ndarray]], k: int): """ Calculates recall at k ranking metric. Args: y_true: Labels. Not used in the calculation of the metric. y_predicted: Predictions. Each prediction contains ranking score of all ranking candidates for ...
[ "def", "recall_at_k", "(", "y_true", ":", "List", "[", "int", "]", ",", "y_pred", ":", "List", "[", "List", "[", "np", ".", "ndarray", "]", "]", ",", "k", ":", "int", ")", ":", "num_examples", "=", "float", "(", "len", "(", "y_pred", ")", ")", ...
Calculates recall at k ranking metric. Args: y_true: Labels. Not used in the calculation of the metric. y_predicted: Predictions. Each prediction contains ranking score of all ranking candidates for the particular data sample. It is supposed that the ranking score for the tr...
[ "Calculates", "recall", "at", "k", "ranking", "metric", "." ]
python
test
christian-oudard/htmltreediff
htmltreediff/changes.py
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/changes.py#L48-L65
def add_changes_markup(dom, ins_nodes, del_nodes): """ Add <ins> and <del> tags to the dom to show changes. """ # add markup for inserted and deleted sections for node in reversed(del_nodes): # diff algorithm deletes nodes in reverse order, so un-reverse the # order for this iteratio...
[ "def", "add_changes_markup", "(", "dom", ",", "ins_nodes", ",", "del_nodes", ")", ":", "# add markup for inserted and deleted sections", "for", "node", "in", "reversed", "(", "del_nodes", ")", ":", "# diff algorithm deletes nodes in reverse order, so un-reverse the", "# order...
Add <ins> and <del> tags to the dom to show changes.
[ "Add", "<ins", ">", "and", "<del", ">", "tags", "to", "the", "dom", "to", "show", "changes", "." ]
python
train
tomduck/pandoc-eqnos
pandoc_eqnos.py
https://github.com/tomduck/pandoc-eqnos/blob/a0e2b5684d2024ea96049ed2cff3acf4ab47c541/pandoc_eqnos.py#L84-L154
def _process_equation(value, fmt): """Processes the equation. Returns a dict containing eq properties.""" # pylint: disable=global-statement global Nreferences # Global references counter global cursec # Current section # Parse the equation attrs = value[0] # Initialize the return...
[ "def", "_process_equation", "(", "value", ",", "fmt", ")", ":", "# pylint: disable=global-statement", "global", "Nreferences", "# Global references counter", "global", "cursec", "# Current section", "# Parse the equation", "attrs", "=", "value", "[", "0", "]", "# Initiali...
Processes the equation. Returns a dict containing eq properties.
[ "Processes", "the", "equation", ".", "Returns", "a", "dict", "containing", "eq", "properties", "." ]
python
train
urbn/Caesium
caesium/document.py
https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/document.py#L614-L636
def update(self, predicate_value, dct, upsert=False, attribute="_id"): """Update an existing document :param predicate_value: The value of the predicate :param dict dct: The dictionary to update with :param bool upsert: Whether this is an upsert action :param str attribute: The ...
[ "def", "update", "(", "self", ",", "predicate_value", ",", "dct", ",", "upsert", "=", "False", ",", "attribute", "=", "\"_id\"", ")", ":", "if", "self", ".", "schema", ":", "jsonschema", ".", "validate", "(", "dct", ",", "self", ".", "schema", ")", "...
Update an existing document :param predicate_value: The value of the predicate :param dict dct: The dictionary to update with :param bool upsert: Whether this is an upsert action :param str attribute: The attribute to query for to find the object to set this data ond :returns: J...
[ "Update", "an", "existing", "document" ]
python
train
niklasb/webkit-server
webkit_server.py
https://github.com/niklasb/webkit-server/blob/c9e3a8394b8c51000c35f8a56fb770580562b544/webkit_server.py#L356-L361
def set_proxy(self, host = "localhost", port = 0, user = "", password = ""): """ Sets a custom HTTP proxy to use for future requests. """ self.conn.issue_command("SetProxy", host, port, user, password)
[ "def", "set_proxy", "(", "self", ",", "host", "=", "\"localhost\"", ",", "port", "=", "0", ",", "user", "=", "\"\"", ",", "password", "=", "\"\"", ")", ":", "self", ".", "conn", ".", "issue_command", "(", "\"SetProxy\"", ",", "host", ",", "port", ","...
Sets a custom HTTP proxy to use for future requests.
[ "Sets", "a", "custom", "HTTP", "proxy", "to", "use", "for", "future", "requests", "." ]
python
train
onnx/onnx-mxnet
onnx_mxnet/import_onnx.py
https://github.com/onnx/onnx-mxnet/blob/b602d75c5a01f5ed8f68b11150a06374f058a86b/onnx_mxnet/import_onnx.py#L219-L232
def _fix_gemm(self, op_name, inputs, old_attr): """Using FullyConnected operator in place of linalg_gemm to perform same operation""" op = getattr(mx.sym, op_name, None) alpha = float(old_attr.get('alpha', 1.0)) beta = float(old_attr.get('beta', 1.0)) transA = int(old_attr.get('t...
[ "def", "_fix_gemm", "(", "self", ",", "op_name", ",", "inputs", ",", "old_attr", ")", ":", "op", "=", "getattr", "(", "mx", ".", "sym", ",", "op_name", ",", "None", ")", "alpha", "=", "float", "(", "old_attr", ".", "get", "(", "'alpha'", ",", "1.0"...
Using FullyConnected operator in place of linalg_gemm to perform same operation
[ "Using", "FullyConnected", "operator", "in", "place", "of", "linalg_gemm", "to", "perform", "same", "operation" ]
python
train
BetterWorks/django-anonymizer
anonymizer/base.py
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L80-L90
def varchar(self, field=None): """ Returns a chunk of text, of maximum length 'max_length' """ assert field is not None, "The field parameter must be passed to the 'varchar' method." max_length = field.max_length def source(): length = random.choice(range(1, ...
[ "def", "varchar", "(", "self", ",", "field", "=", "None", ")", ":", "assert", "field", "is", "not", "None", ",", "\"The field parameter must be passed to the 'varchar' method.\"", "max_length", "=", "field", ".", "max_length", "def", "source", "(", ")", ":", "le...
Returns a chunk of text, of maximum length 'max_length'
[ "Returns", "a", "chunk", "of", "text", "of", "maximum", "length", "max_length" ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/page.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/page.py#L256-L271
def get_pager_cmd(pager_cmd=None): """Return a pager command. Makes some attempts at finding an OS-correct one. """ if os.name == 'posix': default_pager_cmd = 'less -r' # -r for color control sequences elif os.name in ['nt','dos']: default_pager_cmd = 'type' if pager_cmd is No...
[ "def", "get_pager_cmd", "(", "pager_cmd", "=", "None", ")", ":", "if", "os", ".", "name", "==", "'posix'", ":", "default_pager_cmd", "=", "'less -r'", "# -r for color control sequences", "elif", "os", ".", "name", "in", "[", "'nt'", ",", "'dos'", "]", ":", ...
Return a pager command. Makes some attempts at finding an OS-correct one.
[ "Return", "a", "pager", "command", "." ]
python
test
psd-tools/psd-tools
src/psd_tools/api/layers.py
https://github.com/psd-tools/psd-tools/blob/4952b57bcf1cf2c1f16fd9d6d51d4fa0b53bce4e/src/psd_tools/api/layers.py#L238-L248
def has_pixels(self): """ Returns True if the layer has associated pixels. When this is True, `topil` method returns :py:class:`PIL.Image`. :return: `bool` """ return any( ci.id >= 0 and cd.data and len(cd.data) > 0 for ci, cd in zip(self._record....
[ "def", "has_pixels", "(", "self", ")", ":", "return", "any", "(", "ci", ".", "id", ">=", "0", "and", "cd", ".", "data", "and", "len", "(", "cd", ".", "data", ")", ">", "0", "for", "ci", ",", "cd", "in", "zip", "(", "self", ".", "_record", "."...
Returns True if the layer has associated pixels. When this is True, `topil` method returns :py:class:`PIL.Image`. :return: `bool`
[ "Returns", "True", "if", "the", "layer", "has", "associated", "pixels", ".", "When", "this", "is", "True", "topil", "method", "returns", ":", "py", ":", "class", ":", "PIL", ".", "Image", "." ]
python
train
googleapis/oauth2client
oauth2client/service_account.py
https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/service_account.py#L337-L371
def from_p12_keyfile_buffer(cls, service_account_email, file_buffer, private_key_password=None, scopes='', token_uri=oauth2client.GOOGLE_TOKEN_URI, revoke_uri=oauth2client.GOOGLE_REVOKE_URI): """Factory constructor f...
[ "def", "from_p12_keyfile_buffer", "(", "cls", ",", "service_account_email", ",", "file_buffer", ",", "private_key_password", "=", "None", ",", "scopes", "=", "''", ",", "token_uri", "=", "oauth2client", ".", "GOOGLE_TOKEN_URI", ",", "revoke_uri", "=", "oauth2client"...
Factory constructor from JSON keyfile. Args: service_account_email: string, The email associated with the service account. file_buffer: stream, A buffer that implements ``read()`` and contains the PKCS#12 key contents. ...
[ "Factory", "constructor", "from", "JSON", "keyfile", "." ]
python
valid
klen/pylama
pylama/hook.py
https://github.com/klen/pylama/blob/f436ccc6b55b33381a295ded753e467953cf4379/pylama/hook.py#L45-L61
def hg_hook(ui, repo, node=None, **kwargs): """Run pylama after mercurial commit.""" seen = set() paths = [] if len(repo): for rev in range(repo[node], len(repo)): for file_ in repo[rev].files(): file_ = op.join(repo.root, file_) if file_ in seen or no...
[ "def", "hg_hook", "(", "ui", ",", "repo", ",", "node", "=", "None", ",", "*", "*", "kwargs", ")", ":", "seen", "=", "set", "(", ")", "paths", "=", "[", "]", "if", "len", "(", "repo", ")", ":", "for", "rev", "in", "range", "(", "repo", "[", ...
Run pylama after mercurial commit.
[ "Run", "pylama", "after", "mercurial", "commit", "." ]
python
train
pkgw/pwkit
pwkit/msmt.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/msmt.py#L125-L153
def sample_double_norm(mean, std_upper, std_lower, size): """Note that this function requires Scipy.""" from scipy.special import erfinv # There's probably a better way to do this. We first draw percentiles # uniformly between 0 and 1. We want the peak of the distribution to occur # at `mean`. Howe...
[ "def", "sample_double_norm", "(", "mean", ",", "std_upper", ",", "std_lower", ",", "size", ")", ":", "from", "scipy", ".", "special", "import", "erfinv", "# There's probably a better way to do this. We first draw percentiles", "# uniformly between 0 and 1. We want the peak of t...
Note that this function requires Scipy.
[ "Note", "that", "this", "function", "requires", "Scipy", "." ]
python
train
saltstack/salt
salt/modules/gnomedesktop.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gnomedesktop.py#L66-L89
def _get(self): ''' get the value for user in gsettings ''' user = self.USER try: uid = pwd.getpwnam(user).pw_uid except KeyError: log.info('User does not exist') return False cmd = self.gsetting_command + ['get', str(self.SCH...
[ "def", "_get", "(", "self", ")", ":", "user", "=", "self", ".", "USER", "try", ":", "uid", "=", "pwd", ".", "getpwnam", "(", "user", ")", ".", "pw_uid", "except", "KeyError", ":", "log", ".", "info", "(", "'User does not exist'", ")", "return", "Fals...
get the value for user in gsettings
[ "get", "the", "value", "for", "user", "in", "gsettings" ]
python
train
PyCQA/astroid
astroid/mixins.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/mixins.py#L44-L50
def _get_filtered_stmts(self, _, node, _stmts, mystmt): """method used in _filter_stmts to get statements and trigger break""" if self.statement() is mystmt: # original node's statement is the assignment, only keep # current node (gen exp, list comp) return [node], Tr...
[ "def", "_get_filtered_stmts", "(", "self", ",", "_", ",", "node", ",", "_stmts", ",", "mystmt", ")", ":", "if", "self", ".", "statement", "(", ")", "is", "mystmt", ":", "# original node's statement is the assignment, only keep", "# current node (gen exp, list comp)", ...
method used in _filter_stmts to get statements and trigger break
[ "method", "used", "in", "_filter_stmts", "to", "get", "statements", "and", "trigger", "break" ]
python
train
materialsproject/pymatgen
pymatgen/analysis/substrate_analyzer.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/substrate_analyzer.py#L118-L148
def get_equiv_transformations(self, transformation_sets, film_vectors, substrate_vectors): """ Applies the transformation_sets to the film and substrate vectors to generate super-lattices and checks if they matches. Returns all matching vectors sets. ...
[ "def", "get_equiv_transformations", "(", "self", ",", "transformation_sets", ",", "film_vectors", ",", "substrate_vectors", ")", ":", "for", "(", "film_transformations", ",", "substrate_transformations", ")", "in", "transformation_sets", ":", "# Apply transformations and re...
Applies the transformation_sets to the film and substrate vectors to generate super-lattices and checks if they matches. Returns all matching vectors sets. Args: transformation_sets(array): an array of transformation sets: each transformation set is an array with the...
[ "Applies", "the", "transformation_sets", "to", "the", "film", "and", "substrate", "vectors", "to", "generate", "super", "-", "lattices", "and", "checks", "if", "they", "matches", ".", "Returns", "all", "matching", "vectors", "sets", "." ]
python
train
glormph/msstitch
src/app/readers/openms.py
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/openms.py#L45-L55
def get_quantmap(consfile): """Returns map of isobaric quant channel names as keys, channel numbers values from consensus XML. E.g. {'113': '0', '114': '1',} """ quantmap = {} maplist = basereader.get_element(consfile, 'mapList') for mapitem in maplist: quantmap[mapitem.att...
[ "def", "get_quantmap", "(", "consfile", ")", ":", "quantmap", "=", "{", "}", "maplist", "=", "basereader", ".", "get_element", "(", "consfile", ",", "'mapList'", ")", "for", "mapitem", "in", "maplist", ":", "quantmap", "[", "mapitem", ".", "attrib", "[", ...
Returns map of isobaric quant channel names as keys, channel numbers values from consensus XML. E.g. {'113': '0', '114': '1',}
[ "Returns", "map", "of", "isobaric", "quant", "channel", "names", "as", "keys", "channel", "numbers", "values", "from", "consensus", "XML", ".", "E", ".", "g", ".", "{", "113", ":", "0", "114", ":", "1", "}" ]
python
train
onnx/onnxmltools
onnxmltools/convert/coreml/shape_calculators/FeatureVectorizer.py
https://github.com/onnx/onnxmltools/blob/d4e4c31990fc2d9fd1f92139f497d360914c9df2/onnxmltools/convert/coreml/shape_calculators/FeatureVectorizer.py#L12-L46
def calculate_feature_vectorizer_output_shapes(operator): ''' Allowed input/output patterns are 1. [N, C_1], ..., [N, C_n] ---> [N, C_1 + ... + C_n] Feature vectorizer concatenates all input tensors along the C-axis, so the output dimension along C-axis is simply a sum of all input features. ...
[ "def", "calculate_feature_vectorizer_output_shapes", "(", "operator", ")", ":", "check_input_and_output_numbers", "(", "operator", ",", "input_count_range", "=", "[", "1", ",", "None", "]", ",", "output_count_range", "=", "1", ")", "check_input_and_output_types", "(", ...
Allowed input/output patterns are 1. [N, C_1], ..., [N, C_n] ---> [N, C_1 + ... + C_n] Feature vectorizer concatenates all input tensors along the C-axis, so the output dimension along C-axis is simply a sum of all input features.
[ "Allowed", "input", "/", "output", "patterns", "are", "1", ".", "[", "N", "C_1", "]", "...", "[", "N", "C_n", "]", "---", ">", "[", "N", "C_1", "+", "...", "+", "C_n", "]" ]
python
train
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L278-L344
def import_data(self, filenames=None): """Import data from text file.""" title = _("Import data") if filenames is None: if self.filename is None: basedir = getcwd_or_home() else: basedir = osp.dirname(self.filename) file...
[ "def", "import_data", "(", "self", ",", "filenames", "=", "None", ")", ":", "title", "=", "_", "(", "\"Import data\"", ")", "if", "filenames", "is", "None", ":", "if", "self", ".", "filename", "is", "None", ":", "basedir", "=", "getcwd_or_home", "(", "...
Import data from text file.
[ "Import", "data", "from", "text", "file", "." ]
python
train
nerdvegas/rez
src/rezplugins/release_vcs/hg.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L58-L82
def _create_tag_highlevel(self, tag_name, message=None): """Create a tag on the toplevel repo if there is no patch repo, or a tag on the patch repo and bookmark on the top repo if there is a patch repo Returns a list where each entry is a dict for each bookmark or tag created, w...
[ "def", "_create_tag_highlevel", "(", "self", ",", "tag_name", ",", "message", "=", "None", ")", ":", "results", "=", "[", "]", "if", "self", ".", "patch_path", ":", "# make a tag on the patch queue", "tagged", "=", "self", ".", "_create_tag_lowlevel", "(", "ta...
Create a tag on the toplevel repo if there is no patch repo, or a tag on the patch repo and bookmark on the top repo if there is a patch repo Returns a list where each entry is a dict for each bookmark or tag created, which looks like {'type': ('bookmark' or 'tag'), 'patch': bool}
[ "Create", "a", "tag", "on", "the", "toplevel", "repo", "if", "there", "is", "no", "patch", "repo", "or", "a", "tag", "on", "the", "patch", "repo", "and", "bookmark", "on", "the", "top", "repo", "if", "there", "is", "a", "patch", "repo" ]
python
train
inasafe/inasafe
safe/gui/tools/minimum_needs/needs_manager_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L704-L734
def save_profile_as(self): """Save the minimum needs under a new profile name. """ # noinspection PyCallByClass,PyTypeChecker file_name_dialog = QFileDialog(self) file_name_dialog.setAcceptMode(QFileDialog.AcceptSave) file_name_dialog.setNameFilter(self.tr('JSON files (*....
[ "def", "save_profile_as", "(", "self", ")", ":", "# noinspection PyCallByClass,PyTypeChecker", "file_name_dialog", "=", "QFileDialog", "(", "self", ")", "file_name_dialog", ".", "setAcceptMode", "(", "QFileDialog", ".", "AcceptSave", ")", "file_name_dialog", ".", "setNa...
Save the minimum needs under a new profile name.
[ "Save", "the", "minimum", "needs", "under", "a", "new", "profile", "name", "." ]
python
train
JnyJny/Geometry
Geometry/triangle.py
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L87-L100
def isosceles(cls, origin=None, base=1, alpha=90): ''' :origin: optional Point :base: optional float describing triangle base length :return: Triangle initialized with points comprising a isosceles triangle. XXX isoceles triangle definition ''' ...
[ "def", "isosceles", "(", "cls", ",", "origin", "=", "None", ",", "base", "=", "1", ",", "alpha", "=", "90", ")", ":", "o", "=", "Point", "(", "origin", ")", "base", "=", "o", ".", "x", "+", "base", "return", "cls", "(", "o", ",", "[", "base",...
:origin: optional Point :base: optional float describing triangle base length :return: Triangle initialized with points comprising a isosceles triangle. XXX isoceles triangle definition
[ ":", "origin", ":", "optional", "Point", ":", "base", ":", "optional", "float", "describing", "triangle", "base", "length", ":", "return", ":", "Triangle", "initialized", "with", "points", "comprising", "a", "isosceles", "triangle", "." ]
python
train
openstax/cnx-epub
cnxepub/collation.py
https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/collation.py#L54-L73
def collate(binder, ruleset=None, includes=None): """Given a ``Binder`` as ``binder``, collate the content into a new set of models. Returns the collated binder. """ html_formatter = SingleHTMLFormatter(binder, includes) raw_html = io.BytesIO(bytes(html_formatter)) collated_html = io.BytesI...
[ "def", "collate", "(", "binder", ",", "ruleset", "=", "None", ",", "includes", "=", "None", ")", ":", "html_formatter", "=", "SingleHTMLFormatter", "(", "binder", ",", "includes", ")", "raw_html", "=", "io", ".", "BytesIO", "(", "bytes", "(", "html_formatt...
Given a ``Binder`` as ``binder``, collate the content into a new set of models. Returns the collated binder.
[ "Given", "a", "Binder", "as", "binder", "collate", "the", "content", "into", "a", "new", "set", "of", "models", ".", "Returns", "the", "collated", "binder", "." ]
python
train
blockstack/blockstack-core
blockstack/lib/snv.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L153-L238
def serial_number_to_tx(serial_number, bitcoind_proxy, proxy=None): """ Convert a serial number into its transaction in the blockchain. Use an untrusted bitcoind connection to get the list of transactions, and use trusted SPV headers to ensure that the transaction obtained is on the main chain. @bit...
[ "def", "serial_number_to_tx", "(", "serial_number", ",", "bitcoind_proxy", ",", "proxy", "=", "None", ")", ":", "proxy", "=", "get_default_proxy", "(", ")", "if", "proxy", "is", "None", "else", "proxy", "parts", "=", "serial_number", ".", "split", "(", "'-'"...
Convert a serial number into its transaction in the blockchain. Use an untrusted bitcoind connection to get the list of transactions, and use trusted SPV headers to ensure that the transaction obtained is on the main chain. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Re...
[ "Convert", "a", "serial", "number", "into", "its", "transaction", "in", "the", "blockchain", ".", "Use", "an", "untrusted", "bitcoind", "connection", "to", "get", "the", "list", "of", "transactions", "and", "use", "trusted", "SPV", "headers", "to", "ensure", ...
python
train
DLR-RM/RAFCON
source/rafcon/utils/geometry.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/utils/geometry.py#L139-L181
def cal_dist_between_2_coord_frame_aligned_boxes(box1_pos, box1_size, box2_pos, box2_size): """ Calculate Euclidean distance between two boxes those edges are parallel to the coordinate axis The function decides condition based which corner to corner or edge to edge distance needs to be calculated. :param...
[ "def", "cal_dist_between_2_coord_frame_aligned_boxes", "(", "box1_pos", ",", "box1_size", ",", "box2_pos", ",", "box2_size", ")", ":", "box1_x_min", ",", "box1_y_min", "=", "box1_pos", "box1_x_max", ",", "box1_y_max", "=", "(", "box1_pos", "[", "0", "]", "+", "b...
Calculate Euclidean distance between two boxes those edges are parallel to the coordinate axis The function decides condition based which corner to corner or edge to edge distance needs to be calculated. :param tuple box1_pos: x and y position of box 1 :param tuple box1_size: x and y size of box 1 :pa...
[ "Calculate", "Euclidean", "distance", "between", "two", "boxes", "those", "edges", "are", "parallel", "to", "the", "coordinate", "axis" ]
python
train
petrjasek/eve-elastic
eve_elastic/elastic.py
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L695-L721
def put_settings(self, app=None, index=None, settings=None, es=None): """Modify index settings. Index must exist already. """ if not index: index = self.index if not app: app = self.app if not es: es = self.es if not setting...
[ "def", "put_settings", "(", "self", ",", "app", "=", "None", ",", "index", "=", "None", ",", "settings", "=", "None", ",", "es", "=", "None", ")", ":", "if", "not", "index", ":", "index", "=", "self", ".", "index", "if", "not", "app", ":", "app",...
Modify index settings. Index must exist already.
[ "Modify", "index", "settings", "." ]
python
train
aouyar/PyMunin
pysysinfo/diskio.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/diskio.py#L194-L228
def _initDevClasses(self): """Sort block devices into lists depending on device class and initialize device type map and partition map.""" self._devClassTree = {} self._partitionTree = {} self._mapDevType = {} basedevs = [] otherdevs = [] if self._mapMajo...
[ "def", "_initDevClasses", "(", "self", ")", ":", "self", ".", "_devClassTree", "=", "{", "}", "self", ".", "_partitionTree", "=", "{", "}", "self", ".", "_mapDevType", "=", "{", "}", "basedevs", "=", "[", "]", "otherdevs", "=", "[", "]", "if", "self"...
Sort block devices into lists depending on device class and initialize device type map and partition map.
[ "Sort", "block", "devices", "into", "lists", "depending", "on", "device", "class", "and", "initialize", "device", "type", "map", "and", "partition", "map", "." ]
python
train
PredixDev/predixpy
predix/admin/weather.py
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/weather.py#L48-L68
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
[ "def", "add_to_manifest", "(", "self", ",", "manifest", ")", ":", "# Add this service to list of services", "manifest", ".", "add_service", "(", "self", ".", "service", ".", "name", ")", "# Add environment variables", "zone_id", "=", "predix", ".", "config", ".", ...
Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry app.
[ "Add", "useful", "details", "to", "the", "manifest", "about", "this", "service", "so", "that", "it", "can", "be", "used", "in", "an", "application", "." ]
python
train
timknip/pycsg
csg/core.py
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L124-L152
def rotate(self, axis, angleDeg): """ Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees """ ax = Vector(axis[0], axis[1], axis[2]).unit() cosAngle = math.cos(math.pi * angleDeg / 180.) sinAngle = math.sin(m...
[ "def", "rotate", "(", "self", ",", "axis", ",", "angleDeg", ")", ":", "ax", "=", "Vector", "(", "axis", "[", "0", "]", ",", "axis", "[", "1", "]", ",", "axis", "[", "2", "]", ")", ".", "unit", "(", ")", "cosAngle", "=", "math", ".", "cos", ...
Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees
[ "Rotate", "geometry", ".", "axis", ":", "axis", "of", "rotation", "(", "array", "of", "floats", ")", "angleDeg", ":", "rotation", "angle", "in", "degrees" ]
python
train
redhat-cip/python-dciclient
dciclient/v1/shell_commands/tag.py
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/tag.py#L45-L56
def create(context, name): """create(context, name) Create a tag. >>> dcictl tag-create [OPTIONS] :param string name: Name of the tag [required] """ result = tag.create(context, name=name) utils.format_output(result, context.format)
[ "def", "create", "(", "context", ",", "name", ")", ":", "result", "=", "tag", ".", "create", "(", "context", ",", "name", "=", "name", ")", "utils", ".", "format_output", "(", "result", ",", "context", ".", "format", ")" ]
create(context, name) Create a tag. >>> dcictl tag-create [OPTIONS] :param string name: Name of the tag [required]
[ "create", "(", "context", "name", ")" ]
python
train
OpenKMIP/PyKMIP
kmip/core/messages/payloads/revoke.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/core/messages/payloads/revoke.py#L172-L193
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the RevokeResponsePayload object and decode it into its constituent parts. Args: istream (Stream): A data stream containing encoded object data, supporting a read meth...
[ "def", "read", "(", "self", ",", "istream", ",", "kmip_version", "=", "enums", ".", "KMIPVersion", ".", "KMIP_1_0", ")", ":", "super", "(", "RevokeResponsePayload", ",", "self", ")", ".", "read", "(", "istream", ",", "kmip_version", "=", "kmip_version", ")...
Read the data encoding the RevokeResponsePayload object and decode it into its constituent parts. Args: istream (Stream): A data stream containing encoded object data, supporting a read method; usually a BytearrayStream object. kmip_version (KMIPVersion): An enume...
[ "Read", "the", "data", "encoding", "the", "RevokeResponsePayload", "object", "and", "decode", "it", "into", "its", "constituent", "parts", ".", "Args", ":", "istream", "(", "Stream", ")", ":", "A", "data", "stream", "containing", "encoded", "object", "data", ...
python
test
klahnakoski/pyLibrary
pyLibrary/env/rollover_index.py
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/rollover_index.py#L262-L290
def fix(source_key, rownum, line, source, sample_only_filter, sample_size): """ :param rownum: :param line: :param source: :param sample_only_filter: :param sample_size: :return: (row, no_more_data) TUPLE WHERE row IS {"value":<data structure>} OR {"json":<text line>} """ value = js...
[ "def", "fix", "(", "source_key", ",", "rownum", ",", "line", ",", "source", ",", "sample_only_filter", ",", "sample_size", ")", ":", "value", "=", "json2value", "(", "line", ")", "if", "rownum", "==", "0", ":", "if", "len", "(", "line", ")", ">", "MA...
:param rownum: :param line: :param source: :param sample_only_filter: :param sample_size: :return: (row, no_more_data) TUPLE WHERE row IS {"value":<data structure>} OR {"json":<text line>}
[ ":", "param", "rownum", ":", ":", "param", "line", ":", ":", "param", "source", ":", ":", "param", "sample_only_filter", ":", ":", "param", "sample_size", ":", ":", "return", ":", "(", "row", "no_more_data", ")", "TUPLE", "WHERE", "row", "IS", "{", "va...
python
train
janpipek/physt
physt/binnings.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/binnings.py#L729-L751
def exponential_binning(data=None, bin_count: Optional[int] = None, *, range=None, **kwargs) -> ExponentialBinning: """Construct exponential binning schema. Parameters ---------- bin_count: Optional[int] Number of bins range: Optional[tuple] (min, max) See also -------- ...
[ "def", "exponential_binning", "(", "data", "=", "None", ",", "bin_count", ":", "Optional", "[", "int", "]", "=", "None", ",", "*", ",", "range", "=", "None", ",", "*", "*", "kwargs", ")", "->", "ExponentialBinning", ":", "if", "bin_count", "is", "None"...
Construct exponential binning schema. Parameters ---------- bin_count: Optional[int] Number of bins range: Optional[tuple] (min, max) See also -------- numpy.logspace - note that our range semantics is different
[ "Construct", "exponential", "binning", "schema", "." ]
python
train
reingart/gui2py
gui/menu.py
https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/menu.py#L277-L281
def RemoveItem(self, menu): "Helper method to remove a menu avoiding using its position" menus = self.GetMenus() # get the list of (menu, title) menus = [submenu for submenu in menus if submenu[0] != menu] self.SetMenus(menus)
[ "def", "RemoveItem", "(", "self", ",", "menu", ")", ":", "menus", "=", "self", ".", "GetMenus", "(", ")", "# get the list of (menu, title)\r", "menus", "=", "[", "submenu", "for", "submenu", "in", "menus", "if", "submenu", "[", "0", "]", "!=", "menu", "]...
Helper method to remove a menu avoiding using its position
[ "Helper", "method", "to", "remove", "a", "menu", "avoiding", "using", "its", "position" ]
python
test
click-contrib/click-configfile
tasks/docs.py
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/docs.py#L48-L57
def browse(ctx): """Open documentation in web browser.""" page_html = Path(ctx.config.sphinx.destdir)/"html"/"index.html" if not page_html.exists(): build(ctx, builder="html") assert page_html.exists() open_cmd = "open" # -- WORKS ON: MACOSX if sys.platform.startswith("win"): o...
[ "def", "browse", "(", "ctx", ")", ":", "page_html", "=", "Path", "(", "ctx", ".", "config", ".", "sphinx", ".", "destdir", ")", "/", "\"html\"", "/", "\"index.html\"", "if", "not", "page_html", ".", "exists", "(", ")", ":", "build", "(", "ctx", ",", ...
Open documentation in web browser.
[ "Open", "documentation", "in", "web", "browser", "." ]
python
train
saltstack/salt
salt/modules/boto_rds.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L176-L196
def parameter_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an RDS parameter group exists. CLI example:: salt myminion boto_rds.parameter_group_exists myparametergroup \ region=us-east-1 ''' co...
[ "def", "parameter_group_exists", "(", "name", ",", "tags", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ","...
Check to see if an RDS parameter group exists. CLI example:: salt myminion boto_rds.parameter_group_exists myparametergroup \ region=us-east-1
[ "Check", "to", "see", "if", "an", "RDS", "parameter", "group", "exists", "." ]
python
train
JoelBender/bacpypes
py25/bacpypes/vlan.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/vlan.py#L58-L85
def process_pdu(self, pdu): """ Process a PDU by sending a copy to each node as dictated by the addressing and if a node is promiscuous. """ if _debug: Network._debug("process_pdu(%s) %r", self.name, pdu) # if there is a traffic log, call it with the network name and pdu ...
[ "def", "process_pdu", "(", "self", ",", "pdu", ")", ":", "if", "_debug", ":", "Network", ".", "_debug", "(", "\"process_pdu(%s) %r\"", ",", "self", ".", "name", ",", "pdu", ")", "# if there is a traffic log, call it with the network name and pdu", "if", "self", "....
Process a PDU by sending a copy to each node as dictated by the addressing and if a node is promiscuous.
[ "Process", "a", "PDU", "by", "sending", "a", "copy", "to", "each", "node", "as", "dictated", "by", "the", "addressing", "and", "if", "a", "node", "is", "promiscuous", "." ]
python
train
openstack/networking-cisco
networking_cisco/plugins/cisco/cfg_agent/device_drivers/iosxe/iosxe_routing_driver.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/cfg_agent/device_drivers/iosxe/iosxe_routing_driver.py#L405-L415
def _cfg_exists(self, cfg_str): """Check a partial config string exists in the running config. :param cfg_str: config string to check :return : True or False """ ios_cfg = self._get_running_config() parse = HTParser(ios_cfg) cfg_raw = parse.find_lines("^" + cfg_s...
[ "def", "_cfg_exists", "(", "self", ",", "cfg_str", ")", ":", "ios_cfg", "=", "self", ".", "_get_running_config", "(", ")", "parse", "=", "HTParser", "(", "ios_cfg", ")", "cfg_raw", "=", "parse", ".", "find_lines", "(", "\"^\"", "+", "cfg_str", ")", "LOG"...
Check a partial config string exists in the running config. :param cfg_str: config string to check :return : True or False
[ "Check", "a", "partial", "config", "string", "exists", "in", "the", "running", "config", "." ]
python
train
T-002/pycast
pycast/errors/baseerrormeasure.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/errors/baseerrormeasure.py#L54-L105
def initialize(self, originalTimeSeries, calculatedTimeSeries): """Initializes the ErrorMeasure. During initialization, all :py:meth:`BaseErrorMeasure.local_errors` are calculated. :param TimeSeries originalTimeSeries: TimeSeries containing the original data. :param TimeSeries calcu...
[ "def", "initialize", "(", "self", ",", "originalTimeSeries", ",", "calculatedTimeSeries", ")", ":", "# ErrorMeasure was already initialized.", "if", "0", "<", "len", "(", "self", ".", "_errorValues", ")", ":", "raise", "StandardError", "(", "\"An ErrorMeasure can only...
Initializes the ErrorMeasure. During initialization, all :py:meth:`BaseErrorMeasure.local_errors` are calculated. :param TimeSeries originalTimeSeries: TimeSeries containing the original data. :param TimeSeries calculatedTimeSeries: TimeSeries containing calculated data. Calc...
[ "Initializes", "the", "ErrorMeasure", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L471-L482
def _IsValidPath(message_descriptor, path): """Checks whether the path is valid for Message Descriptor.""" parts = path.split('.') last = parts.pop() for name in parts: field = message_descriptor.fields_by_name[name] if (field is None or field.label == FieldDescriptor.LABEL_REPEATED or f...
[ "def", "_IsValidPath", "(", "message_descriptor", ",", "path", ")", ":", "parts", "=", "path", ".", "split", "(", "'.'", ")", "last", "=", "parts", ".", "pop", "(", ")", "for", "name", "in", "parts", ":", "field", "=", "message_descriptor", ".", "field...
Checks whether the path is valid for Message Descriptor.
[ "Checks", "whether", "the", "path", "is", "valid", "for", "Message", "Descriptor", "." ]
python
train
doconix/django-mako-plus
django_mako_plus/router/decorators.py
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/decorators.py#L56-L59
def is_decorated(cls, f): '''Returns True if the given function is decorated with @view_function''' real_func = inspect.unwrap(f) return real_func in cls.DECORATED_FUNCTIONS
[ "def", "is_decorated", "(", "cls", ",", "f", ")", ":", "real_func", "=", "inspect", ".", "unwrap", "(", "f", ")", "return", "real_func", "in", "cls", ".", "DECORATED_FUNCTIONS" ]
Returns True if the given function is decorated with @view_function
[ "Returns", "True", "if", "the", "given", "function", "is", "decorated", "with" ]
python
train
klen/zeta-library
zetalibrary/packer.py
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/packer.py#L106-L113
def out(msg, error=False): " Send message to shell " pipe = stdout if error: pipe = stderr msg = color_msg(msg, "warning") pipe.write("%s\n" % msg)
[ "def", "out", "(", "msg", ",", "error", "=", "False", ")", ":", "pipe", "=", "stdout", "if", "error", ":", "pipe", "=", "stderr", "msg", "=", "color_msg", "(", "msg", ",", "\"warning\"", ")", "pipe", ".", "write", "(", "\"%s\\n\"", "%", "msg", ")" ...
Send message to shell
[ "Send", "message", "to", "shell" ]
python
train
treycucco/bidon
bidon/spreadsheet/base.py
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/spreadsheet/base.py#L82-L95
def tuple_to_datetime(self, date_tuple): """Converts a tuple to a either a date, time or datetime object. If the Y, M and D parts of the tuple are all 0, then a time object is returned. If the h, m and s aprts of the tuple are all 0, then a date object is returned. Otherwise a datetime object is return...
[ "def", "tuple_to_datetime", "(", "self", ",", "date_tuple", ")", ":", "year", ",", "month", ",", "day", ",", "hour", ",", "minute", ",", "second", "=", "date_tuple", "if", "year", "==", "month", "==", "day", "==", "0", ":", "return", "time", "(", "ho...
Converts a tuple to a either a date, time or datetime object. If the Y, M and D parts of the tuple are all 0, then a time object is returned. If the h, m and s aprts of the tuple are all 0, then a date object is returned. Otherwise a datetime object is returned.
[ "Converts", "a", "tuple", "to", "a", "either", "a", "date", "time", "or", "datetime", "object", "." ]
python
train
adewes/blitzdb
blitzdb/backends/file/index.py
https://github.com/adewes/blitzdb/blob/4b459e0bcde9e1f6224dd4e3bea74194586864b0/blitzdb/backends/file/index.py#L386-L405
def commit(self): """Commit current transaction.""" if (not self._add_cache and not self._remove_cache and not self._undefined_cache): return for store_key, hash_values in self._add_cache.items(): for hash_value in hash_values: ...
[ "def", "commit", "(", "self", ")", ":", "if", "(", "not", "self", ".", "_add_cache", "and", "not", "self", ".", "_remove_cache", "and", "not", "self", ".", "_undefined_cache", ")", ":", "return", "for", "store_key", ",", "hash_values", "in", "self", ".",...
Commit current transaction.
[ "Commit", "current", "transaction", "." ]
python
train
minhhoit/yacms
yacms/pages/admin.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L51-L57
def check_permission(self, request, page, permission): """ Runs the custom permission check and raises an exception if False. """ if not getattr(page, "can_" + permission)(request): raise PermissionDenied
[ "def", "check_permission", "(", "self", ",", "request", ",", "page", ",", "permission", ")", ":", "if", "not", "getattr", "(", "page", ",", "\"can_\"", "+", "permission", ")", "(", "request", ")", ":", "raise", "PermissionDenied" ]
Runs the custom permission check and raises an exception if False.
[ "Runs", "the", "custom", "permission", "check", "and", "raises", "an", "exception", "if", "False", "." ]
python
train
mpdavis/python-jose
jose/jwt.py
https://github.com/mpdavis/python-jose/blob/deea7600eeea47aeb1bf5053a96de51cf2b9c639/jose/jwt.py#L264-L291
def _validate_nbf(claims, leeway=0): """Validates that the 'nbf' claim is valid. The "nbf" (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the "nbf" claim requires that the current date/time MUST be after or equal to the not-before...
[ "def", "_validate_nbf", "(", "claims", ",", "leeway", "=", "0", ")", ":", "if", "'nbf'", "not", "in", "claims", ":", "return", "try", ":", "nbf", "=", "int", "(", "claims", "[", "'nbf'", "]", ")", "except", "ValueError", ":", "raise", "JWTClaimsError",...
Validates that the 'nbf' claim is valid. The "nbf" (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the "nbf" claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the "nbf" claim. Imple...
[ "Validates", "that", "the", "nbf", "claim", "is", "valid", "." ]
python
train
inasafe/inasafe
safe/metadata/base_metadata.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/metadata/base_metadata.py#L368-L386
def read_xml(self): """ read metadata from xml and set all the found properties. :return: the root element of the xml :rtype: ElementTree.Element """ if self.xml_uri is None: root = self._read_xml_db() else: root = self._read_xml_file() ...
[ "def", "read_xml", "(", "self", ")", ":", "if", "self", ".", "xml_uri", "is", "None", ":", "root", "=", "self", ".", "_read_xml_db", "(", ")", "else", ":", "root", "=", "self", ".", "_read_xml_file", "(", ")", "if", "root", "is", "not", "None", ":"...
read metadata from xml and set all the found properties. :return: the root element of the xml :rtype: ElementTree.Element
[ "read", "metadata", "from", "xml", "and", "set", "all", "the", "found", "properties", "." ]
python
train
mitsei/dlkit
dlkit/json_/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/sessions.py#L1890-L1913
def assign_objective_to_objective_bank(self, objective_id, objective_bank_id): """Adds an existing ``Objective`` to an ``ObjectiveBank``. arg: objective_id (osid.id.Id): the ``Id`` of the ``Objective`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ...
[ "def", "assign_objective_to_objective_bank", "(", "self", ",", "objective_id", ",", "objective_bank_id", ")", ":", "# Implemented from template for", "# osid.resource.ResourceBinAssignmentSession.assign_resource_to_bin", "mgr", "=", "self", ".", "_get_provider_manager", "(", "'LE...
Adds an existing ``Objective`` to an ``ObjectiveBank``. arg: objective_id (osid.id.Id): the ``Id`` of the ``Objective`` arg: objective_bank_id (osid.id.Id): the ``Id`` of the ``ObjectiveBank`` raise: AlreadyExists - ``objective_id`` already mapped to ...
[ "Adds", "an", "existing", "Objective", "to", "an", "ObjectiveBank", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/utils/type_helpers.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/utils/type_helpers.py#L112-L127
def type_inherits_of_type(inheriting_type, base_type): """Checks whether inheriting_type inherits from base_type :param str inheriting_type: :param str base_type: :return: True is base_type is base of inheriting_type """ assert isinstance(inheriting_type, type) or isclass(inheriting_type) a...
[ "def", "type_inherits_of_type", "(", "inheriting_type", ",", "base_type", ")", ":", "assert", "isinstance", "(", "inheriting_type", ",", "type", ")", "or", "isclass", "(", "inheriting_type", ")", "assert", "isinstance", "(", "base_type", ",", "type", ")", "or", ...
Checks whether inheriting_type inherits from base_type :param str inheriting_type: :param str base_type: :return: True is base_type is base of inheriting_type
[ "Checks", "whether", "inheriting_type", "inherits", "from", "base_type" ]
python
train
harvard-nrg/yaxil
yaxil/bids/__init__.py
https://github.com/harvard-nrg/yaxil/blob/af594082258e62d1904d6e6841fce0bb5c0bf309/yaxil/bids/__init__.py#L86-L120
def proc_anat(config, args): ''' Download anatomical data and convert to BIDS ''' refs = dict() for scan in iterconfig(config, 'anat'): ref = scan.get('id', None) templ = 'sub-${sub}_ses-${ses}' if 'acquisition' in scan: templ += '_acq-${acquisition}' if '...
[ "def", "proc_anat", "(", "config", ",", "args", ")", ":", "refs", "=", "dict", "(", ")", "for", "scan", "in", "iterconfig", "(", "config", ",", "'anat'", ")", ":", "ref", "=", "scan", ".", "get", "(", "'id'", ",", "None", ")", "templ", "=", "'sub...
Download anatomical data and convert to BIDS
[ "Download", "anatomical", "data", "and", "convert", "to", "BIDS" ]
python
train
saltstack/salt
salt/modules/virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3511-L3534
def get_hypervisor(): ''' Returns the name of the hypervisor running on this node or ``None``. Detected hypervisors: - kvm - xen - bhyve CLI Example: .. code-block:: bash salt '*' virt.get_hypervisor .. versionadded:: 2019.2.0 the function and the ``kvm``, ``xen...
[ "def", "get_hypervisor", "(", ")", ":", "# To add a new 'foo' hypervisor, add the _is_foo_hyper function,", "# add 'foo' to the list below and add it to the docstring with a .. versionadded::", "hypervisors", "=", "[", "'kvm'", ",", "'xen'", ",", "'bhyve'", "]", "result", "=", "[...
Returns the name of the hypervisor running on this node or ``None``. Detected hypervisors: - kvm - xen - bhyve CLI Example: .. code-block:: bash salt '*' virt.get_hypervisor .. versionadded:: 2019.2.0 the function and the ``kvm``, ``xen`` and ``bhyve`` hypervisors suppo...
[ "Returns", "the", "name", "of", "the", "hypervisor", "running", "on", "this", "node", "or", "None", "." ]
python
train
googledatalab/pydatalab
solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py#L37-L66
def parse_arguments(argv): """Parse command line arguments. Args: argv: list of command line arguments, includeing programe name. Returns: An argparse Namespace object. """ parser = argparse.ArgumentParser( description='Runs Preprocessing on structured CSV data.') parser.add_argument('--inpu...
[ "def", "parse_arguments", "(", "argv", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Runs Preprocessing on structured CSV data.'", ")", "parser", ".", "add_argument", "(", "'--input-file-pattern'", ",", "type", "=", "str", ",...
Parse command line arguments. Args: argv: list of command line arguments, includeing programe name. Returns: An argparse Namespace object.
[ "Parse", "command", "line", "arguments", "." ]
python
train
kennknowles/python-jsonpath-rw
jsonpath_rw/lexer.py
https://github.com/kennknowles/python-jsonpath-rw/blob/f615451d7b405e23e0f80b15cad03b1427b0256d/jsonpath_rw/lexer.py#L118-L124
def t_doublequote_end(self, t): r'"' t.value = t.lexer.string_value t.type = 'ID' t.lexer.string_value = None t.lexer.pop_state() return t
[ "def", "t_doublequote_end", "(", "self", ",", "t", ")", ":", "t", ".", "value", "=", "t", ".", "lexer", ".", "string_value", "t", ".", "type", "=", "'ID'", "t", ".", "lexer", ".", "string_value", "=", "None", "t", ".", "lexer", ".", "pop_state", "(...
r'"
[ "r" ]
python
train
yahoo/TensorFlowOnSpark
examples/imagenet/inception/slim/ops.py
https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L135-L163
def _two_element_tuple(int_or_tuple): """Converts `int_or_tuple` to height, width. Several of the functions that follow accept arguments as either a tuple of 2 integers or a single integer. A single integer indicates that the 2 values of the tuple are the same. This functions normalizes the input value by ...
[ "def", "_two_element_tuple", "(", "int_or_tuple", ")", ":", "if", "isinstance", "(", "int_or_tuple", ",", "(", "list", ",", "tuple", ")", ")", ":", "if", "len", "(", "int_or_tuple", ")", "!=", "2", ":", "raise", "ValueError", "(", "'Must be a list with 2 ele...
Converts `int_or_tuple` to height, width. Several of the functions that follow accept arguments as either a tuple of 2 integers or a single integer. A single integer indicates that the 2 values of the tuple are the same. This functions normalizes the input value by always returning a tuple. Args: int_...
[ "Converts", "int_or_tuple", "to", "height", "width", "." ]
python
train
OLC-Bioinformatics/ConFindr
confindr_src/confindr.py
https://github.com/OLC-Bioinformatics/ConFindr/blob/4c292617c3f270ebd5ff138cbc5a107f6d01200d/confindr_src/confindr.py#L259-L320
def find_if_multibase(column, quality_cutoff, base_cutoff, base_fraction_cutoff): """ Finds if a position in a pileup has more than one base present. :param column: A pileupColumn generated by pysam :param quality_cutoff: Desired minimum phred quality for a base in order to be counted towards a multi-al...
[ "def", "find_if_multibase", "(", "column", ",", "quality_cutoff", ",", "base_cutoff", ",", "base_fraction_cutoff", ")", ":", "# Sometimes the qualities come out to ridiculously high (>70) values. Looks to be because sometimes reads", "# are overlapping and the qualities get summed for over...
Finds if a position in a pileup has more than one base present. :param column: A pileupColumn generated by pysam :param quality_cutoff: Desired minimum phred quality for a base in order to be counted towards a multi-allelic column :param base_cutoff: Minimum number of bases needed to support presence of a b...
[ "Finds", "if", "a", "position", "in", "a", "pileup", "has", "more", "than", "one", "base", "present", ".", ":", "param", "column", ":", "A", "pileupColumn", "generated", "by", "pysam", ":", "param", "quality_cutoff", ":", "Desired", "minimum", "phred", "qu...
python
train
chrislit/abydos
abydos/fingerprint/_count.py
https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/fingerprint/_count.py#L96-L129
def count_fingerprint(word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG): """Return the count fingerprint. This is a wrapper for :py:meth:`Count.fingerprint`. Parameters ---------- word : str The word to fingerprint n_bits : int Number of bits in the fingerprint returned ...
[ "def", "count_fingerprint", "(", "word", ",", "n_bits", "=", "16", ",", "most_common", "=", "MOST_COMMON_LETTERS_CG", ")", ":", "return", "Count", "(", ")", ".", "fingerprint", "(", "word", ",", "n_bits", ",", "most_common", ")" ]
Return the count fingerprint. This is a wrapper for :py:meth:`Count.fingerprint`. Parameters ---------- word : str The word to fingerprint n_bits : int Number of bits in the fingerprint returned most_common : list The most common tokens in the target language, ordered b...
[ "Return", "the", "count", "fingerprint", "." ]
python
valid
skibblenybbles/django-commando
commando/management/base.py
https://github.com/skibblenybbles/django-commando/blob/dd1dd6969fc0dd8231fc115fee3eeb690809585b/commando/management/base.py#L340-L355
def check_command(self, name): """ Checks whether the given Django management command exists, excluding this command from the search. """ if not check_command( name, exclude_packages=self.get_exclude_packages(), exclude_command_class=...
[ "def", "check_command", "(", "self", ",", "name", ")", ":", "if", "not", "check_command", "(", "name", ",", "exclude_packages", "=", "self", ".", "get_exclude_packages", "(", ")", ",", "exclude_command_class", "=", "self", ".", "__class__", ")", ":", "raise"...
Checks whether the given Django management command exists, excluding this command from the search.
[ "Checks", "whether", "the", "given", "Django", "management", "command", "exists", "excluding", "this", "command", "from", "the", "search", "." ]
python
train
nfcpy/nfcpy
src/nfc/clf/rcs956.py
https://github.com/nfcpy/nfcpy/blob/6649146d1afdd5e82b2b6b1ea00aa58d50785117/src/nfc/clf/rcs956.py#L258-L270
def listen_tta(self, target, timeout): """Listen *timeout* seconds for a Type A activation at 106 kbps. The ``sens_res``, ``sdd_res``, and ``sel_res`` response data must be provided and ``sdd_res`` must be a 4 byte UID that starts with ``08h``. Depending on ``sel_res`` an activation may ...
[ "def", "listen_tta", "(", "self", ",", "target", ",", "timeout", ")", ":", "if", "target", ".", "sel_res", "and", "target", ".", "sel_res", "[", "0", "]", "&", "0x20", ":", "info", "=", "\"{device} does not support listen as Type 4A Target\"", "raise", "nfc", ...
Listen *timeout* seconds for a Type A activation at 106 kbps. The ``sens_res``, ``sdd_res``, and ``sel_res`` response data must be provided and ``sdd_res`` must be a 4 byte UID that starts with ``08h``. Depending on ``sel_res`` an activation may return a target with ``tt2_cmd`` or ``atr_...
[ "Listen", "*", "timeout", "*", "seconds", "for", "a", "Type", "A", "activation", "at", "106", "kbps", ".", "The", "sens_res", "sdd_res", "and", "sel_res", "response", "data", "must", "be", "provided", "and", "sdd_res", "must", "be", "a", "4", "byte", "UI...
python
train
tobgu/pyrsistent
pyrsistent/_field_common.py
https://github.com/tobgu/pyrsistent/blob/c84dab0daaa44973cbe83830d14888827b307632/pyrsistent/_field_common.py#L278-L303
def pmap_field(key_type, value_type, optional=False, invariant=PFIELD_NO_INVARIANT): """ Create a checked ``PMap`` field. :param key: The required type for the keys of the map. :param value: The required type for the values of the map. :param optional: If true, ``None`` can be used as a value for ...
[ "def", "pmap_field", "(", "key_type", ",", "value_type", ",", "optional", "=", "False", ",", "invariant", "=", "PFIELD_NO_INVARIANT", ")", ":", "TheMap", "=", "_make_pmap_field_type", "(", "key_type", ",", "value_type", ")", "if", "optional", ":", "def", "fact...
Create a checked ``PMap`` field. :param key: The required type for the keys of the map. :param value: The required type for the values of the map. :param optional: If true, ``None`` can be used as a value for this field. :param invariant: Pass-through to ``field``. :return: A ``field`` con...
[ "Create", "a", "checked", "PMap", "field", "." ]
python
train
shoebot/shoebot
shoebot/grammar/grammar.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/grammar.py#L47-L62
def _load_namespace(self, namespace, filename=None): """ Initialise bot namespace with info in shoebot.data :param filename: Will be set to __file__ in the namespace """ from shoebot import data for name in dir(data): namespace[name] = getattr(data, name) ...
[ "def", "_load_namespace", "(", "self", ",", "namespace", ",", "filename", "=", "None", ")", ":", "from", "shoebot", "import", "data", "for", "name", "in", "dir", "(", "data", ")", ":", "namespace", "[", "name", "]", "=", "getattr", "(", "data", ",", ...
Initialise bot namespace with info in shoebot.data :param filename: Will be set to __file__ in the namespace
[ "Initialise", "bot", "namespace", "with", "info", "in", "shoebot", ".", "data" ]
python
valid
trailofbits/manticore
manticore/native/cpu/x86.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/cpu/x86.py#L3727-L3761
def SAL(cpu, dest, src): """ The shift arithmetic left. Shifts the bits in the first operand (destination operand) to the left or right by the number of bits specified in the second operand (count operand). Bits shifted beyond the destination operand boundary are first shifted into the ...
[ "def", "SAL", "(", "cpu", ",", "dest", ",", "src", ")", ":", "OperandSize", "=", "dest", ".", "size", "count", "=", "src", ".", "read", "(", ")", "countMask", "=", "{", "8", ":", "0x1f", ",", "16", ":", "0x1f", ",", "32", ":", "0x1f", ",", "6...
The shift arithmetic left. Shifts the bits in the first operand (destination operand) to the left or right by the number of bits specified in the second operand (count operand). Bits shifted beyond the destination operand boundary are first shifted into the CF flag, then discarded. At the end o...
[ "The", "shift", "arithmetic", "left", "." ]
python
valid
jdoda/sdl2hl
sdl2hl/renderer.py
https://github.com/jdoda/sdl2hl/blob/3b477e1e01cea5d8e15e9e5ef3a302ea460f5946/sdl2hl/renderer.py#L268-L298
def copy(self, texture, source_rect=None, dest_rect=None, rotation=0, center=None, flip=lib.SDL_FLIP_NONE): """Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center. Args: texture (Texture): The source texture. source_...
[ "def", "copy", "(", "self", ",", "texture", ",", "source_rect", "=", "None", ",", "dest_rect", "=", "None", ",", "rotation", "=", "0", ",", "center", "=", "None", ",", "flip", "=", "lib", ".", "SDL_FLIP_NONE", ")", ":", "if", "source_rect", "==", "No...
Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center. Args: texture (Texture): The source texture. source_rect (Rect): The source rectangle, or None for the entire texture. dest_rect (Rect): The destination rectan...
[ "Copy", "a", "portion", "of", "the", "source", "texture", "to", "the", "current", "rendering", "target", "rotating", "it", "by", "angle", "around", "the", "given", "center", "." ]
python
train
SeabornGames/Table
seaborn_table/table.py
https://github.com/SeabornGames/Table/blob/0c474ef2fb00db0e7cf47e8af91e3556c2e7485a/seaborn_table/table.py#L1042-L1061
def pertibate_to_obj(cls, columns, pertibate_values, generated_columns=None, filter_func=None, max_size=None, deliminator=None, tab=None): """ This will create and add rows to the table by pertibating the parameters for the provided colum...
[ "def", "pertibate_to_obj", "(", "cls", ",", "columns", ",", "pertibate_values", ",", "generated_columns", "=", "None", ",", "filter_func", "=", "None", ",", "max_size", "=", "None", ",", "deliminator", "=", "None", ",", "tab", "=", "None", ")", ":", "table...
This will create and add rows to the table by pertibating the parameters for the provided columns :param columns: list of str of columns in the table :param pertibate_values: dict of {'column': [values]} :param generated_columns: dict of {'column': func} :param filter_func: f...
[ "This", "will", "create", "and", "add", "rows", "to", "the", "table", "by", "pertibating", "the", "parameters", "for", "the", "provided", "columns", ":", "param", "columns", ":", "list", "of", "str", "of", "columns", "in", "the", "table", ":", "param", "...
python
train
readbeyond/aeneas
aeneas/textfile.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L919-L978
def _read_unparsed(self, lines): """ Read text fragments from an unparsed format text file. :param list lines: the lines of the unparsed text file """ from bs4 import BeautifulSoup def filter_attributes(): """ Return a dict with the bs4 filter parameters """...
[ "def", "_read_unparsed", "(", "self", ",", "lines", ")", ":", "from", "bs4", "import", "BeautifulSoup", "def", "filter_attributes", "(", ")", ":", "\"\"\" Return a dict with the bs4 filter parameters \"\"\"", "attributes", "=", "{", "}", "for", "attribute_name", ",", ...
Read text fragments from an unparsed format text file. :param list lines: the lines of the unparsed text file
[ "Read", "text", "fragments", "from", "an", "unparsed", "format", "text", "file", "." ]
python
train
makinacorpus/landez
landez/tiles.py
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L146-L156
def add_layer(self, tilemanager, opacity=1.0): """ Add a layer to be blended (alpha-composite) on top of the tile. tilemanager -- a `TileManager` instance opacity -- transparency factor for compositing """ assert has_pil, _("Cannot blend layers without python PIL") ...
[ "def", "add_layer", "(", "self", ",", "tilemanager", ",", "opacity", "=", "1.0", ")", ":", "assert", "has_pil", ",", "_", "(", "\"Cannot blend layers without python PIL\"", ")", "assert", "self", ".", "tile_size", "==", "tilemanager", ".", "tile_size", ",", "_...
Add a layer to be blended (alpha-composite) on top of the tile. tilemanager -- a `TileManager` instance opacity -- transparency factor for compositing
[ "Add", "a", "layer", "to", "be", "blended", "(", "alpha", "-", "composite", ")", "on", "top", "of", "the", "tile", ".", "tilemanager", "--", "a", "TileManager", "instance", "opacity", "--", "transparency", "factor", "for", "compositing" ]
python
train
dnanexus/dx-toolkit
src/python/dxpy/api.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L1060-L1066
def project_update(object_id, input_params={}, always_retry=True, **kwargs): """ Invokes the /project-xxxx/update API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Projects#API-method%3A-%2Fproject-xxxx%2Fupdate """ return DXHTTPRequest('/%s/update' % object_id, inp...
[ "def", "project_update", "(", "object_id", ",", "input_params", "=", "{", "}", ",", "always_retry", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "DXHTTPRequest", "(", "'/%s/update'", "%", "object_id", ",", "input_params", ",", "always_retry", "=...
Invokes the /project-xxxx/update API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Projects#API-method%3A-%2Fproject-xxxx%2Fupdate
[ "Invokes", "the", "/", "project", "-", "xxxx", "/", "update", "API", "method", "." ]
python
train
matthewdeanmartin/jiggle_version
sample_projects/ver_in_weird_file/setup_helpers.py
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/sample_projects/ver_in_weird_file/setup_helpers.py#L137-L150
def description(filename): """Provide a short description.""" # This ends up in the Summary header for PKG-INFO and it should be a # one-liner. It will get rendered on the package page just below the # package version header but above the long_description, which ironically # gets stuff into the Des...
[ "def", "description", "(", "filename", ")", ":", "# This ends up in the Summary header for PKG-INFO and it should be a", "# one-liner. It will get rendered on the package page just below the", "# package version header but above the long_description, which ironically", "# gets stuff into the Desc...
Provide a short description.
[ "Provide", "a", "short", "description", "." ]
python
train
eqcorrscan/EQcorrscan
eqcorrscan/utils/seismo_logs.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/seismo_logs.py#L166-L191
def check_all_logs(directory, time_thresh): """ Check all the log-files in a directory tree for timing errors. :type directory: str :param directory: Directory to search within :type time_thresh: float :param time_thresh: Time threshold in seconds :returns: List of :class:`datetime.datetim...
[ "def", "check_all_logs", "(", "directory", ",", "time_thresh", ")", ":", "log_files", "=", "glob", ".", "glob", "(", "directory", "+", "'/*/0/000000000_00000000'", ")", "print", "(", "'I have '", "+", "str", "(", "len", "(", "log_files", ")", ")", "+", "' ...
Check all the log-files in a directory tree for timing errors. :type directory: str :param directory: Directory to search within :type time_thresh: float :param time_thresh: Time threshold in seconds :returns: List of :class:`datetime.datetime` for which error timing is above threshold, e....
[ "Check", "all", "the", "log", "-", "files", "in", "a", "directory", "tree", "for", "timing", "errors", "." ]
python
train
spacetelescope/stsci.tools
lib/stsci/tools/minmatch.py
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/minmatch.py#L225-L234
def get(self, key, failobj=None, exact=0): """Returns failobj if key is not found or is ambiguous""" if not exact: try: key = self.getfullkey(key) except KeyError: return failobj return self.data.get(key,failobj)
[ "def", "get", "(", "self", ",", "key", ",", "failobj", "=", "None", ",", "exact", "=", "0", ")", ":", "if", "not", "exact", ":", "try", ":", "key", "=", "self", ".", "getfullkey", "(", "key", ")", "except", "KeyError", ":", "return", "failobj", "...
Returns failobj if key is not found or is ambiguous
[ "Returns", "failobj", "if", "key", "is", "not", "found", "or", "is", "ambiguous" ]
python
train
midasplatform/pydas
pydas/api.py
https://github.com/midasplatform/pydas/blob/e5f9e96e754fb2dc5da187b05e4abc77a9b2affd/pydas/api.py#L666-L685
def download(server_path, local_path='.'): """ Recursively download a file or item from the Midas Server instance. :param server_path: The location on the server to find the resource to download :type server_path: string :param local_path: The location on the client to store the downloaded ...
[ "def", "download", "(", "server_path", ",", "local_path", "=", "'.'", ")", ":", "session", ".", "token", "=", "verify_credentials", "(", ")", "is_item", ",", "resource_id", "=", "_find_resource_id_from_path", "(", "server_path", ")", "if", "resource_id", "==", ...
Recursively download a file or item from the Midas Server instance. :param server_path: The location on the server to find the resource to download :type server_path: string :param local_path: The location on the client to store the downloaded data :type local_path: string
[ "Recursively", "download", "a", "file", "or", "item", "from", "the", "Midas", "Server", "instance", "." ]
python
valid
cuihantao/andes
andes/routines/eig.py
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/eig.py#L39-L63
def calc_state_matrix(self): """ Return state matrix and store to ``self.As`` Returns ------- matrix state matrix """ system = self.system Gyx = matrix(system.dae.Gx) self.solver.linsolve(system.dae.Gy, Gyx) self.As = matrix(...
[ "def", "calc_state_matrix", "(", "self", ")", ":", "system", "=", "self", ".", "system", "Gyx", "=", "matrix", "(", "system", ".", "dae", ".", "Gx", ")", "self", ".", "solver", ".", "linsolve", "(", "system", ".", "dae", ".", "Gy", ",", "Gyx", ")",...
Return state matrix and store to ``self.As`` Returns ------- matrix state matrix
[ "Return", "state", "matrix", "and", "store", "to", "self", ".", "As" ]
python
train
thebigmunch/google-music
src/google_music/clients/mobileclient.py
https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L1814-L1838
def stations(self, *, generated=True, library=True): """Get a listing of library stations. The listing can contain stations added to the library and generated from the library. Parameters: generated (bool, Optional): Include generated stations. Default: True library (bool, Optional): Include library s...
[ "def", "stations", "(", "self", ",", "*", ",", "generated", "=", "True", ",", "library", "=", "True", ")", ":", "station_list", "=", "[", "]", "for", "chunk", "in", "self", ".", "stations_iter", "(", "page_size", "=", "49995", ")", ":", "for", "stati...
Get a listing of library stations. The listing can contain stations added to the library and generated from the library. Parameters: generated (bool, Optional): Include generated stations. Default: True library (bool, Optional): Include library stations. Default: True Returns: list: Station in...
[ "Get", "a", "listing", "of", "library", "stations", "." ]
python
train
HonzaKral/django-threadedcomments
threadedcomments/util.py
https://github.com/HonzaKral/django-threadedcomments/blob/7b36d9e0813fcbb634052990d1cf01bba8ef220f/threadedcomments/util.py#L21-L34
def fill_tree(comments): """ Insert extra comments in the comments list, so that the root path of the first comment is always visible. Use this in comments' pagination to fill in the tree information. The inserted comments have an ``added_path`` attribute. """ if not comments: return ...
[ "def", "fill_tree", "(", "comments", ")", ":", "if", "not", "comments", ":", "return", "it", "=", "iter", "(", "comments", ")", "first", "=", "next", "(", "it", ")", "extra_path_items", "=", "imap", "(", "_mark_as_root_path", ",", "first", ".", "root_pat...
Insert extra comments in the comments list, so that the root path of the first comment is always visible. Use this in comments' pagination to fill in the tree information. The inserted comments have an ``added_path`` attribute.
[ "Insert", "extra", "comments", "in", "the", "comments", "list", "so", "that", "the", "root", "path", "of", "the", "first", "comment", "is", "always", "visible", ".", "Use", "this", "in", "comments", "pagination", "to", "fill", "in", "the", "tree", "informa...
python
train
aiogram/aiogram
aiogram/contrib/fsm_storage/redis.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/fsm_storage/redis.py#L150-L164
async def get_states_list(self) -> typing.List[typing.Tuple[int]]: """ Get list of all stored chat's and user's :return: list of tuples where first element is chat id and second is user id """ conn = await self.redis() result = [] keys = await conn.execute('KEYS...
[ "async", "def", "get_states_list", "(", "self", ")", "->", "typing", ".", "List", "[", "typing", ".", "Tuple", "[", "int", "]", "]", ":", "conn", "=", "await", "self", ".", "redis", "(", ")", "result", "=", "[", "]", "keys", "=", "await", "conn", ...
Get list of all stored chat's and user's :return: list of tuples where first element is chat id and second is user id
[ "Get", "list", "of", "all", "stored", "chat", "s", "and", "user", "s" ]
python
train
PyCQA/astroid
astroid/bases.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/bases.py#L359-L382
def infer_call_result(self, caller, context): """ The boundnode of the regular context with a function called on ``object.__new__`` will be of type ``object``, which is incorrect for the argument in general. If no context is given the ``object.__new__`` call argument will ...
[ "def", "infer_call_result", "(", "self", ",", "caller", ",", "context", ")", ":", "# If we're unbound method __new__ of builtin object, the result is an", "# instance of the class given as first argument.", "if", "(", "self", ".", "_proxied", ".", "name", "==", "\"__new__\"",...
The boundnode of the regular context with a function called on ``object.__new__`` will be of type ``object``, which is incorrect for the argument in general. If no context is given the ``object.__new__`` call argument will correctly inferred except when inside a call that requires ...
[ "The", "boundnode", "of", "the", "regular", "context", "with", "a", "function", "called", "on", "object", ".", "__new__", "will", "be", "of", "type", "object", "which", "is", "incorrect", "for", "the", "argument", "in", "general", ".", "If", "no", "context...
python
train
earwig/mwparserfromhell
mwparserfromhell/parser/tokenizer.py
https://github.com/earwig/mwparserfromhell/blob/98dc30902d35c714a70aca8e6616f49d71cb24cc/mwparserfromhell/parser/tokenizer.py#L545-L568
def _parse_heading(self): """Parse a section heading at the head of the wikicode string.""" self._global |= contexts.GL_HEADING reset = self._head self._head += 1 best = 1 while self._read() == "=": best += 1 self._head += 1 context = conte...
[ "def", "_parse_heading", "(", "self", ")", ":", "self", ".", "_global", "|=", "contexts", ".", "GL_HEADING", "reset", "=", "self", ".", "_head", "self", ".", "_head", "+=", "1", "best", "=", "1", "while", "self", ".", "_read", "(", ")", "==", "\"=\""...
Parse a section heading at the head of the wikicode string.
[ "Parse", "a", "section", "heading", "at", "the", "head", "of", "the", "wikicode", "string", "." ]
python
train
mitsei/dlkit
dlkit/records/assessment/fbw/assessment_part_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/fbw/assessment_part_records.py#L43-L48
def _init_map(self): """stub""" self.my_osid_object_form._my_map['learningObjectiveId'] = \ str(self._learning_objective_id_metadata['default_id_values'][0]) self.my_osid_object_form._my_map['minimumProficiency'] = \ str(self._minimum_proficiency_metadata['default_id_valu...
[ "def", "_init_map", "(", "self", ")", ":", "self", ".", "my_osid_object_form", ".", "_my_map", "[", "'learningObjectiveId'", "]", "=", "str", "(", "self", ".", "_learning_objective_id_metadata", "[", "'default_id_values'", "]", "[", "0", "]", ")", "self", ".",...
stub
[ "stub" ]
python
train
slackapi/python-slackclient
slack/web/client.py
https://github.com/slackapi/python-slackclient/blob/901341c0284fd81e6d2719d6a0502308760d83e4/slack/web/client.py#L1282-L1289
def users_setPresence(self, *, presence: str, **kwargs) -> SlackResponse: """Manually sets user presence. Args: presence (str): Either 'auto' or 'away'. """ kwargs.update({"presence": presence}) return self.api_call("users.setPresence", json=kwargs)
[ "def", "users_setPresence", "(", "self", ",", "*", ",", "presence", ":", "str", ",", "*", "*", "kwargs", ")", "->", "SlackResponse", ":", "kwargs", ".", "update", "(", "{", "\"presence\"", ":", "presence", "}", ")", "return", "self", ".", "api_call", "...
Manually sets user presence. Args: presence (str): Either 'auto' or 'away'.
[ "Manually", "sets", "user", "presence", "." ]
python
train
heitzmann/gdspy
gdspy/__init__.py
https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L3073-L3148
def get_polygons(self, by_spec=False, depth=None): """ Returns a list of polygons created by this reference. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). ...
[ "def", "get_polygons", "(", "self", ",", "by_spec", "=", "False", ",", "depth", "=", "None", ")", ":", "if", "not", "isinstance", "(", "self", ".", "ref_cell", ",", "Cell", ")", ":", "return", "dict", "(", ")", "if", "by_spec", "else", "[", "]", "i...
Returns a list of polygons created by this reference. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines ...
[ "Returns", "a", "list", "of", "polygons", "created", "by", "this", "reference", "." ]
python
train
hydpy-dev/hydpy
hydpy/core/filetools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/filetools.py#L508-L530
def filepaths(self) -> List[str]: """Absolute path names of the files contained in the current working directory. Files names starting with underscores are ignored: >>> from hydpy.core.filetools import FileManager >>> filemanager = FileManager() >>> filemanager.BASEDIR ...
[ "def", "filepaths", "(", "self", ")", "->", "List", "[", "str", "]", ":", "path", "=", "self", ".", "currentpath", "return", "[", "os", ".", "path", ".", "join", "(", "path", ",", "name", ")", "for", "name", "in", "self", ".", "filenames", "]" ]
Absolute path names of the files contained in the current working directory. Files names starting with underscores are ignored: >>> from hydpy.core.filetools import FileManager >>> filemanager = FileManager() >>> filemanager.BASEDIR = 'basename' >>> filemanager.projectd...
[ "Absolute", "path", "names", "of", "the", "files", "contained", "in", "the", "current", "working", "directory", "." ]
python
train
limodou/uliweb
uliweb/lib/werkzeug/wrappers.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wrappers.py#L321-L332
def make_form_data_parser(self): """Creates the form data parser. Instanciates the :attr:`form_data_parser_class` with some parameters. .. versionadded:: 0.8 """ return self.form_data_parser_class(self._get_file_stream, self.charset, ...
[ "def", "make_form_data_parser", "(", "self", ")", ":", "return", "self", ".", "form_data_parser_class", "(", "self", ".", "_get_file_stream", ",", "self", ".", "charset", ",", "self", ".", "encoding_errors", ",", "self", ".", "max_form_memory_size", ",", "self",...
Creates the form data parser. Instanciates the :attr:`form_data_parser_class` with some parameters. .. versionadded:: 0.8
[ "Creates", "the", "form", "data", "parser", ".", "Instanciates", "the", ":", "attr", ":", "form_data_parser_class", "with", "some", "parameters", "." ]
python
train
roboogle/gtkmvc3
gtkmvco/examples/custom_widget/htmltextview.py
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/examples/custom_widget/htmltextview.py#L42-L48
def _parse_css_color(color): '''_parse_css_color(css_color) -> gtk.gdk.Color''' if color.startswith("rgb(") and color.endswith(')'): r, g, b = [int(c)*257 for c in color[4:-1].split(',')] return gtk.gdk.Color(r, g, b) else: return gtk.gdk.color_parse(color)
[ "def", "_parse_css_color", "(", "color", ")", ":", "if", "color", ".", "startswith", "(", "\"rgb(\"", ")", "and", "color", ".", "endswith", "(", "')'", ")", ":", "r", ",", "g", ",", "b", "=", "[", "int", "(", "c", ")", "*", "257", "for", "c", "...
_parse_css_color(css_color) -> gtk.gdk.Color
[ "_parse_css_color", "(", "css_color", ")", "-", ">", "gtk", ".", "gdk", ".", "Color" ]
python
train
dh1tw/pyhamtools
pyhamtools/lookuplib.py
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L485-L538
def lookup_prefix(self, prefix, timestamp=timestamp_now): """ Returns lookup data of a Prefix Args: prefix (string): Prefix of a Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dict: Dictionary contai...
[ "def", "lookup_prefix", "(", "self", ",", "prefix", ",", "timestamp", "=", "timestamp_now", ")", ":", "prefix", "=", "prefix", ".", "strip", "(", ")", ".", "upper", "(", ")", "if", "self", ".", "_lookuptype", "==", "\"clublogxml\"", "or", "self", ".", ...
Returns lookup data of a Prefix Args: prefix (string): Prefix of a Amateur Radio callsign timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC) Returns: dict: Dictionary containing the country specific data of the Prefix Raises: KeyE...
[ "Returns", "lookup", "data", "of", "a", "Prefix" ]
python
train
ondryaso/pi-rc522
pirc522/rfid.py
https://github.com/ondryaso/pi-rc522/blob/9d9103e9701c105ba2348155e91f21ef338c4bd3/pirc522/rfid.py#L339-L355
def read(self, block_address): """ Reads data from block. You should be authenticated before calling read. Returns tuple of (error state, read data). """ buf = [] buf.append(self.act_read) buf.append(block_address) crc = self.calculate_crc(buf) buf...
[ "def", "read", "(", "self", ",", "block_address", ")", ":", "buf", "=", "[", "]", "buf", ".", "append", "(", "self", ".", "act_read", ")", "buf", ".", "append", "(", "block_address", ")", "crc", "=", "self", ".", "calculate_crc", "(", "buf", ")", "...
Reads data from block. You should be authenticated before calling read. Returns tuple of (error state, read data).
[ "Reads", "data", "from", "block", ".", "You", "should", "be", "authenticated", "before", "calling", "read", ".", "Returns", "tuple", "of", "(", "error", "state", "read", "data", ")", "." ]
python
train
ekzhu/datasketch
datasketch/lshensemble_partition.py
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L13-L32
def _compute_nfp_uniform(l, u, cum_counts, sizes): """Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], assuming uniform distribution of set sizes within the interval. Args: l: the lower bound on set sizes. u: the upper bo...
[ "def", "_compute_nfp_uniform", "(", "l", ",", "u", ",", "cum_counts", ",", "sizes", ")", ":", "if", "l", ">", "u", ":", "raise", "ValueError", "(", "\"l must be less or equal to u\"", ")", "if", "l", "==", "0", ":", "n", "=", "cum_counts", "[", "u", "]...
Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], assuming uniform distribution of set sizes within the interval. Args: l: the lower bound on set sizes. u: the upper bound on set sizes. cum_counts: the complete cummula...
[ "Computes", "the", "expected", "number", "of", "false", "positives", "caused", "by", "using", "u", "to", "approximate", "set", "sizes", "in", "the", "interval", "[", "l", "u", "]", "assuming", "uniform", "distribution", "of", "set", "sizes", "within", "the",...
python
test