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
kgori/treeCl
treeCl/utils/misc.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/utils/misc.py#L151-L158
def insort_no_dup(lst, item): """ If item is not in lst, add item to list at its sorted position """ import bisect ix = bisect.bisect_left(lst, item) if lst[ix] != item: lst[ix:ix] = [item]
[ "def", "insort_no_dup", "(", "lst", ",", "item", ")", ":", "import", "bisect", "ix", "=", "bisect", ".", "bisect_left", "(", "lst", ",", "item", ")", "if", "lst", "[", "ix", "]", "!=", "item", ":", "lst", "[", "ix", ":", "ix", "]", "=", "[", "i...
If item is not in lst, add item to list at its sorted position
[ "If", "item", "is", "not", "in", "lst", "add", "item", "to", "list", "at", "its", "sorted", "position" ]
python
train
rm-hull/OPi.GPIO
OPi/GPIO.py
https://github.com/rm-hull/OPi.GPIO/blob/d151885eb0f0fc25d4a86266eefebc105700f3fd/OPi/GPIO.py#L497-L511
def add_event_callback(channel, callback, bouncetime=None): """ :param channel: the channel based on the numbering system you have specified (:py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM` or :py:attr:`GPIO.SUNXI`). :param callback: TODO :param bouncetime: (optional) TODO """ _check_configur...
[ "def", "add_event_callback", "(", "channel", ",", "callback", ",", "bouncetime", "=", "None", ")", ":", "_check_configured", "(", "channel", ",", "direction", "=", "IN", ")", "if", "bouncetime", "is", "not", "None", ":", "if", "_gpio_warnings", ":", "warning...
:param channel: the channel based on the numbering system you have specified (:py:attr:`GPIO.BOARD`, :py:attr:`GPIO.BCM` or :py:attr:`GPIO.SUNXI`). :param callback: TODO :param bouncetime: (optional) TODO
[ ":", "param", "channel", ":", "the", "channel", "based", "on", "the", "numbering", "system", "you", "have", "specified", "(", ":", "py", ":", "attr", ":", "GPIO", ".", "BOARD", ":", "py", ":", "attr", ":", "GPIO", ".", "BCM", "or", ":", "py", ":", ...
python
train
LEMS/pylems
lems/model/simulation.py
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/simulation.py#L44-L52
def toxml(self): """ Exports this object into a LEMS XML object """ return '<Run component="{0}" variable="{1}" increment="{2}" total="{3}"/>'.format(self.component, self.variable, ...
[ "def", "toxml", "(", "self", ")", ":", "return", "'<Run component=\"{0}\" variable=\"{1}\" increment=\"{2}\" total=\"{3}\"/>'", ".", "format", "(", "self", ".", "component", ",", "self", ".", "variable", ",", "self", ".", "increment", ",", "self", ".", "total", ")...
Exports this object into a LEMS XML object
[ "Exports", "this", "object", "into", "a", "LEMS", "XML", "object" ]
python
train
theduke/django-baseline
django_baseline/templatetags/helpers.py
https://github.com/theduke/django-baseline/blob/7be8b956e53c70b35f34e1783a8fe8f716955afb/django_baseline/templatetags/helpers.py#L36-L54
def link(url, text='', classes='', target='', get="", **kwargs): ''' Output a link tag. ''' if not (url.startswith('http') or url.startswith('/')): # Handle additional reverse args. urlargs = {} for arg, val in kwargs.items(): if arg[:4] == "url_": u...
[ "def", "link", "(", "url", ",", "text", "=", "''", ",", "classes", "=", "''", ",", "target", "=", "''", ",", "get", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "if", "not", "(", "url", ".", "startswith", "(", "'http'", ")", "or", "url", "...
Output a link tag.
[ "Output", "a", "link", "tag", "." ]
python
test
annoviko/pyclustering
pyclustering/utils/__init__.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/utils/__init__.py#L134-L156
def stretch_pattern(image_source): """! @brief Returns stretched content as 1-dimension (gray colored) matrix with size of input image. @param[in] image_source (Image): PIL Image instance. @return (list, Image) Stretched image as gray colored matrix and source image. """ ...
[ "def", "stretch_pattern", "(", "image_source", ")", ":", "wsize", ",", "hsize", "=", "image_source", ".", "size", "# Crop digit exactly\r", "(", "ws", ",", "hs", ",", "we", ",", "he", ")", "=", "gray_pattern_borders", "(", "image_source", ")", "image_source", ...
! @brief Returns stretched content as 1-dimension (gray colored) matrix with size of input image. @param[in] image_source (Image): PIL Image instance. @return (list, Image) Stretched image as gray colored matrix and source image.
[ "!" ]
python
valid
pahaz/sshtunnel
sshtunnel.py
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1654-L1808
def _parse_arguments(args=None): """ Parse arguments directly passed from CLI """ parser = argparse.ArgumentParser( description='Pure python ssh tunnel utils\n' 'Version {0}'.format(__version__), formatter_class=argparse.RawTextHelpFormatter ) parser.add_argu...
[ "def", "_parse_arguments", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Pure python ssh tunnel utils\\n'", "'Version {0}'", ".", "format", "(", "__version__", ")", ",", "formatter_class", "=", "ar...
Parse arguments directly passed from CLI
[ "Parse", "arguments", "directly", "passed", "from", "CLI" ]
python
train
spry-group/python-vultr
vultr/utils.py
https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/utils.py#L35-L39
def _request_post_helper(self, url, params=None): '''API POST helper''' if self.api_key: query = {'api_key': self.api_key} return requests.post(url, params=query, data=params, timeout=60)
[ "def", "_request_post_helper", "(", "self", ",", "url", ",", "params", "=", "None", ")", ":", "if", "self", ".", "api_key", ":", "query", "=", "{", "'api_key'", ":", "self", ".", "api_key", "}", "return", "requests", ".", "post", "(", "url", ",", "pa...
API POST helper
[ "API", "POST", "helper" ]
python
train
Microsoft/ApplicationInsights-Python
applicationinsights/channel/contracts/Envelope.py
https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/contracts/Envelope.py#L124-L133
def seq(self, value): """The seq property. Args: value (string). the property value. """ if value == self._defaults['seq'] and 'seq' in self._values: del self._values['seq'] else: self._values['seq'] = value
[ "def", "seq", "(", "self", ",", "value", ")", ":", "if", "value", "==", "self", ".", "_defaults", "[", "'seq'", "]", "and", "'seq'", "in", "self", ".", "_values", ":", "del", "self", ".", "_values", "[", "'seq'", "]", "else", ":", "self", ".", "_...
The seq property. Args: value (string). the property value.
[ "The", "seq", "property", ".", "Args", ":", "value", "(", "string", ")", ".", "the", "property", "value", "." ]
python
train
apple/turicreate
deps/src/boost_1_68_0/tools/build/src/build/project.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/project.py#L412-L509
def initialize(self, module_name, location=None, basename=None, standalone_path=''): """Initialize the module for a project. module-name is the name of the project module. location is the location (directory) of the project to initialize. If not specified, standalone project wi...
[ "def", "initialize", "(", "self", ",", "module_name", ",", "location", "=", "None", ",", "basename", "=", "None", ",", "standalone_path", "=", "''", ")", ":", "assert", "isinstance", "(", "module_name", ",", "basestring", ")", "assert", "isinstance", "(", ...
Initialize the module for a project. module-name is the name of the project module. location is the location (directory) of the project to initialize. If not specified, standalone project will be initialized standalone_path is the path to the source-location. ...
[ "Initialize", "the", "module", "for", "a", "project", "." ]
python
train
Azure/azure-cli-extensions
src/express-route-cross-connection/azext_expressroutecrossconnection/vendored_sdks/network_management_client.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/express-route-cross-connection/azext_expressroutecrossconnection/vendored_sdks/network_management_client.py#L616-L629
def express_route_cross_connections(self): """Instance depends on the API version: * 2018-02-01: :class:`ExpressRouteCrossConnectionsOperations<azure.mgmt.network.v2018_02_01.operations.ExpressRouteCrossConnectionsOperations>` * 2018-04-01: :class:`ExpressRouteCrossConnectionsOperations<a...
[ "def", "express_route_cross_connections", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'express_route_cross_connections'", ")", "if", "api_version", "==", "'2018-02-01'", ":", "from", ".", "v2018_02_01", ".", "operations", "import"...
Instance depends on the API version: * 2018-02-01: :class:`ExpressRouteCrossConnectionsOperations<azure.mgmt.network.v2018_02_01.operations.ExpressRouteCrossConnectionsOperations>` * 2018-04-01: :class:`ExpressRouteCrossConnectionsOperations<azure.mgmt.network.v2018_04_01.operations.ExpressRouteC...
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
python
train
shoebot/shoebot
shoebot/core/canvas.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L163-L168
def flush(self, frame): ''' Passes the drawqueue to the sink for rendering ''' self.sink.render(self.size_or_default(), frame, self._drawqueue) self.reset_drawqueue()
[ "def", "flush", "(", "self", ",", "frame", ")", ":", "self", ".", "sink", ".", "render", "(", "self", ".", "size_or_default", "(", ")", ",", "frame", ",", "self", ".", "_drawqueue", ")", "self", ".", "reset_drawqueue", "(", ")" ]
Passes the drawqueue to the sink for rendering
[ "Passes", "the", "drawqueue", "to", "the", "sink", "for", "rendering" ]
python
valid
UCSBarchlab/PyRTL
pyrtl/passes.py
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/passes.py#L451-L519
def _decompose(net, wv_map, mems, block_out): """ Add the wires and logicnets to block_out and wv_map to decompose net """ def arg(x, i): # return the mapped wire vector for argument x, wire number i return wv_map[(net.args[x], i)] def destlen(): # return iterator over length of th...
[ "def", "_decompose", "(", "net", ",", "wv_map", ",", "mems", ",", "block_out", ")", ":", "def", "arg", "(", "x", ",", "i", ")", ":", "# return the mapped wire vector for argument x, wire number i", "return", "wv_map", "[", "(", "net", ".", "args", "[", "x", ...
Add the wires and logicnets to block_out and wv_map to decompose net
[ "Add", "the", "wires", "and", "logicnets", "to", "block_out", "and", "wv_map", "to", "decompose", "net" ]
python
train
DEIB-GECO/PyGMQL
gmql/dataset/GMQLDataset.py
https://github.com/DEIB-GECO/PyGMQL/blob/e58b2f9402a86056dcda484a32e3de0bb06ed991/gmql/dataset/GMQLDataset.py#L1353-L1359
def regs_group(self, regs, regs_aggregates=None): """ *Wrapper of* ``GROUP`` Group operation only for region data. For further information check :meth:`~.group` """ return self.group(regs=regs, regs_aggregates=regs_aggregates)
[ "def", "regs_group", "(", "self", ",", "regs", ",", "regs_aggregates", "=", "None", ")", ":", "return", "self", ".", "group", "(", "regs", "=", "regs", ",", "regs_aggregates", "=", "regs_aggregates", ")" ]
*Wrapper of* ``GROUP`` Group operation only for region data. For further information check :meth:`~.group`
[ "*", "Wrapper", "of", "*", "GROUP" ]
python
train
MartinThoma/hwrt
hwrt/preprocess_dataset.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/preprocess_dataset.py#L95-L99
def main(folder): """Main part of preprocess_dataset that glues things togeter.""" raw_datapath, outputpath, p_queue = get_parameters(folder) create_preprocessed_dataset(raw_datapath, outputpath, p_queue) utils.create_run_logfile(folder)
[ "def", "main", "(", "folder", ")", ":", "raw_datapath", ",", "outputpath", ",", "p_queue", "=", "get_parameters", "(", "folder", ")", "create_preprocessed_dataset", "(", "raw_datapath", ",", "outputpath", ",", "p_queue", ")", "utils", ".", "create_run_logfile", ...
Main part of preprocess_dataset that glues things togeter.
[ "Main", "part", "of", "preprocess_dataset", "that", "glues", "things", "togeter", "." ]
python
train
lcharleux/argiope
argiope/mesh.py
https://github.com/lcharleux/argiope/blob/8170e431362dc760589f7d141090fd133dece259/argiope/mesh.py#L560-L569
def to_triangulation(self): """ Returns the mesh as a matplotlib.tri.Triangulation instance. (2D only) """ from matplotlib.tri import Triangulation conn = self.split("simplices").unstack() coords = self.nodes.coords.copy() node_map = pd.Series(data = np.arange(len(coords)), index = coords.i...
[ "def", "to_triangulation", "(", "self", ")", ":", "from", "matplotlib", ".", "tri", "import", "Triangulation", "conn", "=", "self", ".", "split", "(", "\"simplices\"", ")", ".", "unstack", "(", ")", "coords", "=", "self", ".", "nodes", ".", "coords", "."...
Returns the mesh as a matplotlib.tri.Triangulation instance. (2D only)
[ "Returns", "the", "mesh", "as", "a", "matplotlib", ".", "tri", ".", "Triangulation", "instance", ".", "(", "2D", "only", ")" ]
python
test
calston/tensor
tensor/utils.py
https://github.com/calston/tensor/blob/7c0c99708b5dbff97f3895f705e11996b608549d/tensor/utils.py#L349-L357
def get(self, k): """Returns key contents, and modify time""" if self._changed(): self._read() if k in self.store: return tuple(self.store[k]) else: return None
[ "def", "get", "(", "self", ",", "k", ")", ":", "if", "self", ".", "_changed", "(", ")", ":", "self", ".", "_read", "(", ")", "if", "k", "in", "self", ".", "store", ":", "return", "tuple", "(", "self", ".", "store", "[", "k", "]", ")", "else",...
Returns key contents, and modify time
[ "Returns", "key", "contents", "and", "modify", "time" ]
python
test
apple/turicreate
src/unity/python/turicreate/data_structures/sarray.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sarray.py#L4315-L4342
def cumulative_max(self): """ Return the cumulative maximum value of the elements in the SArray. Returns an SArray where each element in the output corresponds to the maximum value of all the elements preceding and including it. The SArray is expected to be of numeric type (int,...
[ "def", "cumulative_max", "(", "self", ")", ":", "from", ".", ".", "import", "extensions", "agg_op", "=", "\"__builtin__cum_max__\"", "return", "SArray", "(", "_proxy", "=", "self", ".", "__proxy__", ".", "builtin_cumulative_aggregate", "(", "agg_op", ")", ")" ]
Return the cumulative maximum value of the elements in the SArray. Returns an SArray where each element in the output corresponds to the maximum value of all the elements preceding and including it. The SArray is expected to be of numeric type (int, float). Returns ------- ...
[ "Return", "the", "cumulative", "maximum", "value", "of", "the", "elements", "in", "the", "SArray", "." ]
python
train
zyga/json-schema-validator
json_schema_validator/schema.py
https://github.com/zyga/json-schema-validator/blob/0504605da5c0a9a5b5b05c41b37661aec9652144/json_schema_validator/schema.py#L192-L201
def maximumCanEqual(self): """Flag indicating if the minimum value is inclusive or exclusive.""" if self.maximum is None: raise SchemaError("maximumCanEqual requires presence of maximum") value = self._schema.get("maximumCanEqual", True) if value is not True and value is not ...
[ "def", "maximumCanEqual", "(", "self", ")", ":", "if", "self", ".", "maximum", "is", "None", ":", "raise", "SchemaError", "(", "\"maximumCanEqual requires presence of maximum\"", ")", "value", "=", "self", ".", "_schema", ".", "get", "(", "\"maximumCanEqual\"", ...
Flag indicating if the minimum value is inclusive or exclusive.
[ "Flag", "indicating", "if", "the", "minimum", "value", "is", "inclusive", "or", "exclusive", "." ]
python
train
nicolargo/glances
glances/plugins/glances_plugin.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L691-L709
def get_limit_action(self, criticity, stat_name=""): """Return the tuple (action, repeat) for the alert. - action is a command line - repeat is a bool """ # Get the action for stat + header # Exemple: network_wlan0_rx_careful_action # Action key available ? ...
[ "def", "get_limit_action", "(", "self", ",", "criticity", ",", "stat_name", "=", "\"\"", ")", ":", "# Get the action for stat + header", "# Exemple: network_wlan0_rx_careful_action", "# Action key available ?", "ret", "=", "[", "(", "stat_name", "+", "'_'", "+", "critic...
Return the tuple (action, repeat) for the alert. - action is a command line - repeat is a bool
[ "Return", "the", "tuple", "(", "action", "repeat", ")", "for", "the", "alert", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/tasks.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L3409-L3477
def restart(self): """ Restart the structural relaxation. Structure relaxations can be restarted only if we have the WFK file or the DEN or the GSR file from which we can read the last structure (mandatory) and the wavefunctions (not mandatory but useful). Prefer WFK over other ...
[ "def", "restart", "(", "self", ")", ":", "restart_file", "=", "None", "# Try to restart from the WFK file if possible.", "# FIXME: This part has been disabled because WFK=IO is a mess if paral_kgb == 1", "# This is also the reason why I wrote my own MPI-IO code for the GW part!", "wfk_file",...
Restart the structural relaxation. Structure relaxations can be restarted only if we have the WFK file or the DEN or the GSR file from which we can read the last structure (mandatory) and the wavefunctions (not mandatory but useful). Prefer WFK over other files since we can reuse the wavefuncti...
[ "Restart", "the", "structural", "relaxation", "." ]
python
train
materialsproject/pymatgen
pymatgen/analysis/gb/grain.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/gb/grain.py#L124-L142
def get_sorted_structure(self, key=None, reverse=False): """ Get a sorted copy of the structure. The parameters have the same meaning as in list.sort. By default, sites are sorted by the electronegativity of the species. Note that Slab has to override this because of the differen...
[ "def", "get_sorted_structure", "(", "self", ",", "key", "=", "None", ",", "reverse", "=", "False", ")", ":", "sites", "=", "sorted", "(", "self", ",", "key", "=", "key", ",", "reverse", "=", "reverse", ")", "s", "=", "Structure", ".", "from_sites", "...
Get a sorted copy of the structure. The parameters have the same meaning as in list.sort. By default, sites are sorted by the electronegativity of the species. Note that Slab has to override this because of the different __init__ args. Args: key: Specifies a function of one a...
[ "Get", "a", "sorted", "copy", "of", "the", "structure", ".", "The", "parameters", "have", "the", "same", "meaning", "as", "in", "list", ".", "sort", ".", "By", "default", "sites", "are", "sorted", "by", "the", "electronegativity", "of", "the", "species", ...
python
train
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L7367-L7434
def WalkTree(top, getChildren: Callable = None, getFirstChild: Callable = None, getNextSibling: Callable = None, yieldCondition: Callable = None, includeTop: bool = False, maxDepth: int = 0xFFFFFFFF): """ Walk a tree not using recursive algorithm. top: a tree node. getChildren: function(treeNode) -> lis...
[ "def", "WalkTree", "(", "top", ",", "getChildren", ":", "Callable", "=", "None", ",", "getFirstChild", ":", "Callable", "=", "None", ",", "getNextSibling", ":", "Callable", "=", "None", ",", "yieldCondition", ":", "Callable", "=", "None", ",", "includeTop", ...
Walk a tree not using recursive algorithm. top: a tree node. getChildren: function(treeNode) -> list. getNextSibling: function(treeNode) -> treeNode. getNextSibling: function(treeNode) -> treeNode. yieldCondition: function(treeNode, depth) -> bool. includeTop: bool, if True yield top first. ...
[ "Walk", "a", "tree", "not", "using", "recursive", "algorithm", ".", "top", ":", "a", "tree", "node", ".", "getChildren", ":", "function", "(", "treeNode", ")", "-", ">", "list", ".", "getNextSibling", ":", "function", "(", "treeNode", ")", "-", ">", "t...
python
valid
Yelp/kafka-utils
kafka_utils/kafka_rolling_restart/main.py
https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_rolling_restart/main.py#L299-L349
def wait_for_stable_cluster( hosts, jolokia_port, jolokia_prefix, check_interval, check_count, unhealthy_time_limit, ): """ Block the caller until the cluster can be considered stable. :param hosts: list of brokers ip addresses :type hosts: list of strings :param jolokia_por...
[ "def", "wait_for_stable_cluster", "(", "hosts", ",", "jolokia_port", ",", "jolokia_prefix", ",", "check_interval", ",", "check_count", ",", "unhealthy_time_limit", ",", ")", ":", "stable_counter", "=", "0", "max_checks", "=", "int", "(", "math", ".", "ceil", "("...
Block the caller until the cluster can be considered stable. :param hosts: list of brokers ip addresses :type hosts: list of strings :param jolokia_port: HTTP port for Jolokia :type jolokia_port: integer :param jolokia_prefix: HTTP prefix on the server for the Jolokia queries :type jolokia_pref...
[ "Block", "the", "caller", "until", "the", "cluster", "can", "be", "considered", "stable", "." ]
python
train
saltstack/salt
salt/modules/statuspage.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/statuspage.py#L86-L101
def _get_api_params(api_url=None, page_id=None, api_key=None, api_version=None): ''' Retrieve the API params from the config file. ''' statuspage_cfg = __salt__['config.get']('statuspage') if not statuspage_cfg: statuspage_cfg = {} ...
[ "def", "_get_api_params", "(", "api_url", "=", "None", ",", "page_id", "=", "None", ",", "api_key", "=", "None", ",", "api_version", "=", "None", ")", ":", "statuspage_cfg", "=", "__salt__", "[", "'config.get'", "]", "(", "'statuspage'", ")", "if", "not", ...
Retrieve the API params from the config file.
[ "Retrieve", "the", "API", "params", "from", "the", "config", "file", "." ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/sadigh_1997.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/sadigh_1997.py#L165-L175
def _get_stddev_rock(self, mag, imt): """ Calculate and return total standard deviation for rock sites. Implements formulae from table 3. """ C = self.COEFFS_ROCK_STDDERR[imt] if mag > C['maxmag']: return C['maxsigma'] else: return C['sigm...
[ "def", "_get_stddev_rock", "(", "self", ",", "mag", ",", "imt", ")", ":", "C", "=", "self", ".", "COEFFS_ROCK_STDDERR", "[", "imt", "]", "if", "mag", ">", "C", "[", "'maxmag'", "]", ":", "return", "C", "[", "'maxsigma'", "]", "else", ":", "return", ...
Calculate and return total standard deviation for rock sites. Implements formulae from table 3.
[ "Calculate", "and", "return", "total", "standard", "deviation", "for", "rock", "sites", "." ]
python
train
blink1073/oct2py
oct2py/core.py
https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/core.py#L668-L679
def _exist(self, name): """Test whether a name exists and return the name code. Raises an error when the name does not exist. """ cmd = 'exist("%s")' % name resp = self._engine.eval(cmd, silent=True).strip() exist = int(resp.split()[-1]) if exist == 0: ...
[ "def", "_exist", "(", "self", ",", "name", ")", ":", "cmd", "=", "'exist(\"%s\")'", "%", "name", "resp", "=", "self", ".", "_engine", ".", "eval", "(", "cmd", ",", "silent", "=", "True", ")", ".", "strip", "(", ")", "exist", "=", "int", "(", "res...
Test whether a name exists and return the name code. Raises an error when the name does not exist.
[ "Test", "whether", "a", "name", "exists", "and", "return", "the", "name", "code", ".", "Raises", "an", "error", "when", "the", "name", "does", "not", "exist", "." ]
python
valid
pymc-devs/pymc
pymc/distributions.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L469-L572
def randomwrap(func): """ Decorator for random value generators Allows passing of sequence of parameters, as well as a size argument. Convention: - If size=1 and the parameters are all scalars, return a scalar. - If size=1, the random variates are 1D. - If the parameters are scalar...
[ "def", "randomwrap", "(", "func", ")", ":", "# Find the order of the arguments.", "refargs", ",", "defaults", "=", "utils", ".", "get_signature", "(", "func", ")", "# vfunc = np.vectorize(self.func)", "npos", "=", "len", "(", "refargs", ")", "-", "len", "(", "de...
Decorator for random value generators Allows passing of sequence of parameters, as well as a size argument. Convention: - If size=1 and the parameters are all scalars, return a scalar. - If size=1, the random variates are 1D. - If the parameters are scalars and size > 1, the random variate...
[ "Decorator", "for", "random", "value", "generators" ]
python
train
timothyb0912/pylogit
pylogit/bootstrap_abc.py
https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/bootstrap_abc.py#L79-L120
def create_long_form_weights(model_obj, wide_weights, rows_to_obs=None): """ Converts an array of weights with one element per observation (wide-format) to an array of weights with one element per observation per available alternative (long-format). Parameters ---------- model_obj : an inst...
[ "def", "create_long_form_weights", "(", "model_obj", ",", "wide_weights", ",", "rows_to_obs", "=", "None", ")", ":", "# Ensure argument validity", "check_validity_of_long_form_args", "(", "model_obj", ",", "wide_weights", ",", "rows_to_obs", ")", "# Get a rows_to_obs mappin...
Converts an array of weights with one element per observation (wide-format) to an array of weights with one element per observation per available alternative (long-format). Parameters ---------- model_obj : an instance or sublcass of the MNDC class. Should be the model object that correspon...
[ "Converts", "an", "array", "of", "weights", "with", "one", "element", "per", "observation", "(", "wide", "-", "format", ")", "to", "an", "array", "of", "weights", "with", "one", "element", "per", "observation", "per", "available", "alternative", "(", "long",...
python
train
quodlibet/mutagen
mutagen/wavpack.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/wavpack.py#L51-L71
def from_fileobj(cls, fileobj): """A new _WavPackHeader or raises WavPackHeaderError""" header = fileobj.read(32) if len(header) != 32 or not header.startswith(b"wvpk"): raise WavPackHeaderError("not a WavPack header: %r" % header) block_size = cdata.uint_le(header[4:8]) ...
[ "def", "from_fileobj", "(", "cls", ",", "fileobj", ")", ":", "header", "=", "fileobj", ".", "read", "(", "32", ")", "if", "len", "(", "header", ")", "!=", "32", "or", "not", "header", ".", "startswith", "(", "b\"wvpk\"", ")", ":", "raise", "WavPackHe...
A new _WavPackHeader or raises WavPackHeaderError
[ "A", "new", "_WavPackHeader", "or", "raises", "WavPackHeaderError" ]
python
train
biosignalsnotebooks/biosignalsnotebooks
biosignalsnotebooks/build/lib/biosignalsnotebooks/conversion.py
https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/build/lib/biosignalsnotebooks/conversion.py#L30-L228
def raw_to_phy(sensor, device, raw_signal, resolution, option): """ ----- Brief ----- Function for converting raw units to physical units. ----------- Description ----------- Each sensor and device has a specific transfer function that models the inputs to outputs. This transfer fun...
[ "def", "raw_to_phy", "(", "sensor", ",", "device", ",", "raw_signal", ",", "resolution", ",", "option", ")", ":", "raw_signal", "=", "numpy", ".", "array", "(", "raw_signal", ")", "# Check if resolution has the correct data format.", "if", "not", "isinstance", "("...
----- Brief ----- Function for converting raw units to physical units. ----------- Description ----------- Each sensor and device has a specific transfer function that models the inputs to outputs. This transfer function is, thus, used in order to convert the raw units that are measured...
[ "-----", "Brief", "-----", "Function", "for", "converting", "raw", "units", "to", "physical", "units", "." ]
python
train
ronhanson/python-tbx
tbx/template.py
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/template.py#L48-L61
def template(filename): """ Decorator """ def method_wrapper(method): @wraps(method) def jinja_wrapper(*args, **kwargs): ret = method(*args, **kwargs) return render_template(filename, ret) return jinja_wrapper return method_wrapper
[ "def", "template", "(", "filename", ")", ":", "def", "method_wrapper", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "jinja_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "method", "(", "*", "args", "...
Decorator
[ "Decorator" ]
python
train
rvswift/EB
EB/builder/slowheuristic/slowheuristic.py
https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/slowheuristic/slowheuristic.py#L67-L115
def rank_queries(molecules, ensemble, sort_order, options): """ rank queries by value added to existing ensemble :param molecules: :param score_field: :param ensemble: :param sort_order: :param options: :return: """ # generate query list query_list = [x for x in list(molecul...
[ "def", "rank_queries", "(", "molecules", ",", "ensemble", ",", "sort_order", ",", "options", ")", ":", "# generate query list", "query_list", "=", "[", "x", "for", "x", "in", "list", "(", "molecules", "[", "0", "]", ".", "scores", ".", "keys", "(", ")", ...
rank queries by value added to existing ensemble :param molecules: :param score_field: :param ensemble: :param sort_order: :param options: :return:
[ "rank", "queries", "by", "value", "added", "to", "existing", "ensemble", ":", "param", "molecules", ":", ":", "param", "score_field", ":", ":", "param", "ensemble", ":", ":", "param", "sort_order", ":", ":", "param", "options", ":", ":", "return", ":" ]
python
train
Azure/azure-event-hubs-python
azure/eventhub/client.py
https://github.com/Azure/azure-event-hubs-python/blob/737c5f966557ada2cf10fa0d8f3c19671ae96348/azure/eventhub/client.py#L257-L269
def create_properties(self): # pylint: disable=no-self-use """ Format the properties with which to instantiate the connection. This acts like a user agent over HTTP. :rtype: dict """ properties = {} properties["product"] = "eventhub.python" properties["v...
[ "def", "create_properties", "(", "self", ")", ":", "# pylint: disable=no-self-use", "properties", "=", "{", "}", "properties", "[", "\"product\"", "]", "=", "\"eventhub.python\"", "properties", "[", "\"version\"", "]", "=", "__version__", "properties", "[", "\"frame...
Format the properties with which to instantiate the connection. This acts like a user agent over HTTP. :rtype: dict
[ "Format", "the", "properties", "with", "which", "to", "instantiate", "the", "connection", ".", "This", "acts", "like", "a", "user", "agent", "over", "HTTP", "." ]
python
train
titusjan/argos
argos/collect/collector.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/collect/collector.py#L429-L461
def _comboBoxActivated(self, index, comboBox=None): """ Is called when a combo box value was changed by the user. Updates the spin boxes and sets other combo boxes having the same index to the fake dimension of length 1. """ if comboBox is None: comboBox = se...
[ "def", "_comboBoxActivated", "(", "self", ",", "index", ",", "comboBox", "=", "None", ")", ":", "if", "comboBox", "is", "None", ":", "comboBox", "=", "self", ".", "sender", "(", ")", "assert", "comboBox", ",", "\"comboBox not defined and not the sender\"", "bl...
Is called when a combo box value was changed by the user. Updates the spin boxes and sets other combo boxes having the same index to the fake dimension of length 1.
[ "Is", "called", "when", "a", "combo", "box", "value", "was", "changed", "by", "the", "user", "." ]
python
train
yaz/yaz
yaz/plugin.py
https://github.com/yaz/yaz/blob/48c842fe053bf9cd6446c4b33fb081c65339aa48/yaz/plugin.py#L87-L118
def get_plugin_instance(plugin_class, *args, **kwargs): """Returns an instance of a fully initialized plugin class Every plugin class is kept in a plugin cache, effectively making every plugin into a singleton object. When a plugin has a yaz.dependency decorator, it will be called as well, before ...
[ "def", "get_plugin_instance", "(", "plugin_class", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "issubclass", "(", "plugin_class", ",", "BasePlugin", ")", ",", "type", "(", "plugin_class", ")", "global", "_yaz_plugin_instance_cache", "qualname"...
Returns an instance of a fully initialized plugin class Every plugin class is kept in a plugin cache, effectively making every plugin into a singleton object. When a plugin has a yaz.dependency decorator, it will be called as well, before the instance is returned.
[ "Returns", "an", "instance", "of", "a", "fully", "initialized", "plugin", "class" ]
python
valid
nuagenetworks/monolithe
monolithe/generators/lang/python/writers/apiversionwriter.py
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/python/writers/apiversionwriter.py#L178-L195
def _write_fetcher(self, specification, specification_set): """ Write fetcher """ destination = "%s%s" % (self.output_directory, self.fetchers_path) base_name = "%s_fetcher" % specification.entity_name_plural.lower() filename = "%s%s.py" % (self._class_prefix.lower(), base_name)...
[ "def", "_write_fetcher", "(", "self", ",", "specification", ",", "specification_set", ")", ":", "destination", "=", "\"%s%s\"", "%", "(", "self", ".", "output_directory", ",", "self", ".", "fetchers_path", ")", "base_name", "=", "\"%s_fetcher\"", "%", "specifica...
Write fetcher
[ "Write", "fetcher" ]
python
train
xolox/python-vcs-repo-mgr
vcs_repo_mgr/__init__.py
https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/__init__.py#L1071-L1111
def create(self): """ Create the local repository (if it doesn't already exist). :returns: :data:`True` if the local repository was just created, :data:`False` if it already existed. What :func:`create()` does depends on the situation: - When :attr:`exists` i...
[ "def", "create", "(", "self", ")", ":", "if", "self", ".", "exists", ":", "logger", ".", "debug", "(", "\"Local %s repository (%s) already exists, ignoring request to create it.\"", ",", "self", ".", "friendly_name", ",", "format_path", "(", "self", ".", "local", ...
Create the local repository (if it doesn't already exist). :returns: :data:`True` if the local repository was just created, :data:`False` if it already existed. What :func:`create()` does depends on the situation: - When :attr:`exists` is :data:`True` nothing is done. ...
[ "Create", "the", "local", "repository", "(", "if", "it", "doesn", "t", "already", "exist", ")", "." ]
python
train
oseledets/ttpy
tt/core/tools.py
https://github.com/oseledets/ttpy/blob/b440f6299a6338de4aea67f3d839d613f4ef1374/tt/core/tools.py#L529-L609
def qlaplace_dd(d): """Creates a QTT representation of the Laplace operator""" res = _matrix.matrix() d0 = d[::-1] D = len(d0) I = _np.eye(2) J = _np.array([[0, 1], [0, 0]]) cr = [] if D is 1: for k in xrange(1, d0[0] + 1): if k is 1: cur_core = _np.ze...
[ "def", "qlaplace_dd", "(", "d", ")", ":", "res", "=", "_matrix", ".", "matrix", "(", ")", "d0", "=", "d", "[", ":", ":", "-", "1", "]", "D", "=", "len", "(", "d0", ")", "I", "=", "_np", ".", "eye", "(", "2", ")", "J", "=", "_np", ".", "...
Creates a QTT representation of the Laplace operator
[ "Creates", "a", "QTT", "representation", "of", "the", "Laplace", "operator" ]
python
train
i3visio/osrframework
osrframework/api/twitter_api.py
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/api/twitter_api.py#L115-L396
def _processUser(self, jUser): """ Convert tweepy.User to a i3visio-like user. This will process the returned JSON object that the API returns to transform it to the i3visio-like format. A sample answer is copied now when testing it to the @i3visio user in Twitter. { "follow_request_sent": false, ...
[ "def", "_processUser", "(", "self", ",", "jUser", ")", ":", "#raw_input(json.dumps(jUser, indent=2))", "r", "=", "{", "}", "r", "[", "\"type\"", "]", "=", "\"i3visio.profile\"", "r", "[", "\"value\"", "]", "=", "self", ".", "platformName", "+", "\" - \"", "+...
Convert tweepy.User to a i3visio-like user. This will process the returned JSON object that the API returns to transform it to the i3visio-like format. A sample answer is copied now when testing it to the @i3visio user in Twitter. { "follow_request_sent": false, "has_extended_profile": false, "profile_use_backgro...
[ "Convert", "tweepy", ".", "User", "to", "a", "i3visio", "-", "like", "user", ".", "This", "will", "process", "the", "returned", "JSON", "object", "that", "the", "API", "returns", "to", "transform", "it", "to", "the", "i3visio", "-", "like", "format", "."...
python
train
cni/MRS
MRS/api.py
https://github.com/cni/MRS/blob/16098b3cf4830780efd787fee9efa46513850283/MRS/api.py#L730-L749
def voxel_seg(self, segfile, MRSfile): """ add voxel segmentation info Parameters ---------- segfile : str Path to nifti file with segmentation info (e.g. XXXX_aseg.nii.gz) MRSfile : str Path to MRS nifti file ""...
[ "def", "voxel_seg", "(", "self", ",", "segfile", ",", "MRSfile", ")", ":", "total", ",", "grey", ",", "white", ",", "csf", ",", "nongmwm", ",", "pGrey", ",", "pWhite", ",", "pCSF", ",", "pNongmwm", "=", "fs", ".", "MRSvoxelStats", "(", "segfile", ","...
add voxel segmentation info Parameters ---------- segfile : str Path to nifti file with segmentation info (e.g. XXXX_aseg.nii.gz) MRSfile : str Path to MRS nifti file
[ "add", "voxel", "segmentation", "info", "Parameters", "----------", "segfile", ":", "str", "Path", "to", "nifti", "file", "with", "segmentation", "info", "(", "e", ".", "g", ".", "XXXX_aseg", ".", "nii", ".", "gz", ")", "MRSfile", ":", "str", "Path", "to...
python
train
ankitmathur3193/song-cli
song/commands/FileDownload.py
https://github.com/ankitmathur3193/song-cli/blob/ca8ccfe547e9d702313ff6d14e81ae4355989a67/song/commands/FileDownload.py#L9-L24
def get_html_response(self,url): '''It will download the html page specified by url and return the html response ''' print "Downloading page %s .."%url try: response=requests.get(url,timeout=50) except requests.exceptions.SSLError: try: response=requests.get(url,verify=False,timeout=50) except requ...
[ "def", "get_html_response", "(", "self", ",", "url", ")", ":", "print", "\"Downloading page %s ..\"", "%", "url", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "timeout", "=", "50", ")", "except", "requests", ".", "exceptions", ".",...
It will download the html page specified by url and return the html response
[ "It", "will", "download", "the", "html", "page", "specified", "by", "url", "and", "return", "the", "html", "response" ]
python
test
hydpy-dev/hydpy
hydpy/models/lland/lland_model.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_model.py#L1219-L1281
def calc_qbgz_v1(self): """Aggregate the amount of base flow released by all "soil type" HRUs and the "net precipitation" above water areas of type |SEE|. Water areas of type |SEE| are assumed to be directly connected with groundwater, but not with the stream network. This is modelled by adding th...
[ "def", "calc_qbgz_v1", "(", "self", ")", ":", "con", "=", "self", ".", "parameters", ".", "control", ".", "fastaccess", "flu", "=", "self", ".", "sequences", ".", "fluxes", ".", "fastaccess", "sta", "=", "self", ".", "sequences", ".", "states", ".", "f...
Aggregate the amount of base flow released by all "soil type" HRUs and the "net precipitation" above water areas of type |SEE|. Water areas of type |SEE| are assumed to be directly connected with groundwater, but not with the stream network. This is modelled by adding their (positive or negative) "net...
[ "Aggregate", "the", "amount", "of", "base", "flow", "released", "by", "all", "soil", "type", "HRUs", "and", "the", "net", "precipitation", "above", "water", "areas", "of", "type", "|SEE|", "." ]
python
train
sixty-north/asq
asq/queryables.py
https://github.com/sixty-north/asq/blob/db0c4cbcf2118435136d4b63c62a12711441088e/asq/queryables.py#L1141-L1173
def contains(self, value, equality_comparer=operator.eq): '''Determines whether the sequence contains a particular value. Execution is immediate. Depending on the type of the sequence, all or none of the sequence may be consumed by this operation. Note: This method uses immediate execu...
[ "def", "contains", "(", "self", ",", "value", ",", "equality_comparer", "=", "operator", ".", "eq", ")", ":", "if", "self", ".", "closed", "(", ")", ":", "raise", "ValueError", "(", "\"Attempt to call contains() on a \"", "\"closed Queryable.\"", ")", "if", "n...
Determines whether the sequence contains a particular value. Execution is immediate. Depending on the type of the sequence, all or none of the sequence may be consumed by this operation. Note: This method uses immediate execution. Args: value: The value to test for members...
[ "Determines", "whether", "the", "sequence", "contains", "a", "particular", "value", "." ]
python
train
dlintott/gns3-converter
gns3converter/node.py
https://github.com/dlintott/gns3-converter/blob/acbc55da51de86388dc5b5f6da55809b3c86b7ca/gns3converter/node.py#L91-L121
def add_slot_ports(self, slot): """ Add the ports to be added for a adapter card :param str slot: Slot name """ slot_nb = int(slot[4]) # slot_adapter = None # if slot in self.node['properties']: # slot_adapter = self.node['properties'][slot] #...
[ "def", "add_slot_ports", "(", "self", ",", "slot", ")", ":", "slot_nb", "=", "int", "(", "slot", "[", "4", "]", ")", "# slot_adapter = None", "# if slot in self.node['properties']:", "# slot_adapter = self.node['properties'][slot]", "# elif self.device_info['model'] == 'c...
Add the ports to be added for a adapter card :param str slot: Slot name
[ "Add", "the", "ports", "to", "be", "added", "for", "a", "adapter", "card" ]
python
train
ManiacalLabs/BiblioPixel
bibliopixel/util/log.py
https://github.com/ManiacalLabs/BiblioPixel/blob/fd97e6c651a4bbcade64733847f4eec8f7704b7c/bibliopixel/util/log.py#L115-L125
def set_log_level(level): """ :param level: the level to set - either a string level name from 'frame', 'debug', 'info', 'warning', 'error' or an integer log level from: log.FRAME, log.DEBUG, log.INFO, log.WARNING, log.ERROR """ if isinstance(level, ...
[ "def", "set_log_level", "(", "level", ")", ":", "if", "isinstance", "(", "level", ",", "str", ")", ":", "level", "=", "LOG_NAMES", "[", "level", ".", "lower", "(", ")", "]", "logger", ".", "setLevel", "(", "level", ")" ]
:param level: the level to set - either a string level name from 'frame', 'debug', 'info', 'warning', 'error' or an integer log level from: log.FRAME, log.DEBUG, log.INFO, log.WARNING, log.ERROR
[ ":", "param", "level", ":", "the", "level", "to", "set", "-", "either", "a", "string", "level", "name", "from", "frame", "debug", "info", "warning", "error", "or", "an", "integer", "log", "level", "from", ":", "log", ".", "FRAME", "log", ".", "DEBUG", ...
python
valid
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_menu.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_menu.py#L72-L74
def _append(self, menu): '''append this menu item to a menu''' menu.Append(self.id(), self.name, self.description)
[ "def", "_append", "(", "self", ",", "menu", ")", ":", "menu", ".", "Append", "(", "self", ".", "id", "(", ")", ",", "self", ".", "name", ",", "self", ".", "description", ")" ]
append this menu item to a menu
[ "append", "this", "menu", "item", "to", "a", "menu" ]
python
train
tcalmant/ipopo
pelix/internals/registry.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/internals/registry.py#L1285-L1295
def get_bundle_registered_services(self, bundle): # type: (Any) -> List[ServiceReference] """ Retrieves the services registered by the given bundle. Returns None if the bundle didn't register any service. :param bundle: The bundle to look into :return: The references to ...
[ "def", "get_bundle_registered_services", "(", "self", ",", "bundle", ")", ":", "# type: (Any) -> List[ServiceReference]", "with", "self", ".", "__svc_lock", ":", "return", "sorted", "(", "self", ".", "__bundle_svc", ".", "get", "(", "bundle", ",", "[", "]", ")",...
Retrieves the services registered by the given bundle. Returns None if the bundle didn't register any service. :param bundle: The bundle to look into :return: The references to the services registered by the bundle
[ "Retrieves", "the", "services", "registered", "by", "the", "given", "bundle", ".", "Returns", "None", "if", "the", "bundle", "didn", "t", "register", "any", "service", "." ]
python
train
ejeschke/ginga
ginga/opengl/Camera.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/opengl/Camera.py#L132-L153
def orbit(self, x1_px, y1_px, x2_px, y2_px): """ Causes the camera to "orbit" around the target point. This is also called "tumbling" in some software packages. """ px_per_deg = self.vport_radius_px / float(self.orbit_speed) radians_per_px = 1.0 / px_per_deg * np.pi / 180...
[ "def", "orbit", "(", "self", ",", "x1_px", ",", "y1_px", ",", "x2_px", ",", "y2_px", ")", ":", "px_per_deg", "=", "self", ".", "vport_radius_px", "/", "float", "(", "self", ".", "orbit_speed", ")", "radians_per_px", "=", "1.0", "/", "px_per_deg", "*", ...
Causes the camera to "orbit" around the target point. This is also called "tumbling" in some software packages.
[ "Causes", "the", "camera", "to", "orbit", "around", "the", "target", "point", ".", "This", "is", "also", "called", "tumbling", "in", "some", "software", "packages", "." ]
python
train
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/handlers.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/handlers.py#L1789-L1811
def _add_kickoff_task(cls, base_path, mapreduce_spec, eta, countdown, queue_name): """Enqueues a new kickoff task.""" params = {"mapreduce_id": mapreduce_spec.mapreduce_id} # Task is not n...
[ "def", "_add_kickoff_task", "(", "cls", ",", "base_path", ",", "mapreduce_spec", ",", "eta", ",", "countdown", ",", "queue_name", ")", ":", "params", "=", "{", "\"mapreduce_id\"", ":", "mapreduce_spec", ".", "mapreduce_id", "}", "# Task is not named so that it can b...
Enqueues a new kickoff task.
[ "Enqueues", "a", "new", "kickoff", "task", "." ]
python
train
tritemio/PyBroMo
pybromo/utils/git.py
https://github.com/tritemio/PyBroMo/blob/b75f82a4551ff37e7c7a7e6954c536451f3e6d06/pybromo/utils/git.py#L98-L112
def print_summary(string='Repository', git_path=None): """ Print the last commit line and eventual uncommitted changes. """ if git_path is None: git_path = GIT_PATH # If git is available, check fretbursts version if not git_path_valid(): print('\n%s revision unknown (git not found).' % ...
[ "def", "print_summary", "(", "string", "=", "'Repository'", ",", "git_path", "=", "None", ")", ":", "if", "git_path", "is", "None", ":", "git_path", "=", "GIT_PATH", "# If git is available, check fretbursts version", "if", "not", "git_path_valid", "(", ")", ":", ...
Print the last commit line and eventual uncommitted changes.
[ "Print", "the", "last", "commit", "line", "and", "eventual", "uncommitted", "changes", "." ]
python
valid
ska-sa/purr
Purr/Plugins/local_pychart/svgcanvas.py
https://github.com/ska-sa/purr/blob/4c848768d0485d0f88b30850d0d5372221b21b66/Purr/Plugins/local_pychart/svgcanvas.py#L51-L58
def _make_style_str(styledict): """ Make an SVG style string from the dictionary. See also _parse_style_str also. """ s = '' for key in list(styledict.keys()): s += "%s:%s;" % (key, styledict[key]) return s
[ "def", "_make_style_str", "(", "styledict", ")", ":", "s", "=", "''", "for", "key", "in", "list", "(", "styledict", ".", "keys", "(", ")", ")", ":", "s", "+=", "\"%s:%s;\"", "%", "(", "key", ",", "styledict", "[", "key", "]", ")", "return", "s" ]
Make an SVG style string from the dictionary. See also _parse_style_str also.
[ "Make", "an", "SVG", "style", "string", "from", "the", "dictionary", ".", "See", "also", "_parse_style_str", "also", "." ]
python
train
Trebek/pydealer
pydealer/card.py
https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/card.py#L323-L349
def ne(self, other, ranks=None): """ Compares the card against another card, ``other``, and checks whether the card is not equal to ``other``, based on the given rank dict. :arg Card other: The second Card to compare. :arg dict ranks: The ranks to refer t...
[ "def", "ne", "(", "self", ",", "other", ",", "ranks", "=", "None", ")", ":", "ranks", "=", "ranks", "or", "DEFAULT_RANKS", "if", "isinstance", "(", "other", ",", "Card", ")", ":", "if", "ranks", ".", "get", "(", "\"suits\"", ")", ":", "return", "("...
Compares the card against another card, ``other``, and checks whether the card is not equal to ``other``, based on the given rank dict. :arg Card other: The second Card to compare. :arg dict ranks: The ranks to refer to for comparisons. :returns: ``T...
[ "Compares", "the", "card", "against", "another", "card", "other", "and", "checks", "whether", "the", "card", "is", "not", "equal", "to", "other", "based", "on", "the", "given", "rank", "dict", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10472-L10484
def ahrs2_send(self, roll, pitch, yaw, altitude, lat, lng, force_mavlink1=False): ''' Status of secondary AHRS filter if available roll : Roll angle (rad) (float) pitch : Pitch angle (rad) (float) y...
[ "def", "ahrs2_send", "(", "self", ",", "roll", ",", "pitch", ",", "yaw", ",", "altitude", ",", "lat", ",", "lng", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "ahrs2_encode", "(", "roll", ",", "pitch...
Status of secondary AHRS filter if available roll : Roll angle (rad) (float) pitch : Pitch angle (rad) (float) yaw : Yaw angle (rad) (float) altitude : Altitude (MSL) (float) ...
[ "Status", "of", "secondary", "AHRS", "filter", "if", "available" ]
python
train
odlgroup/odl
odl/space/npy_tensors.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/space/npy_tensors.py#L1300-L1317
def imag(self, newimag): """Setter for the imaginary part. This method is invoked by ``x.imag = other``. Parameters ---------- newimag : array-like or scalar Values to be assigned to the imaginary part of this element. Raises ------ ValueErr...
[ "def", "imag", "(", "self", ",", "newimag", ")", ":", "if", "self", ".", "space", ".", "is_real", ":", "raise", "ValueError", "(", "'cannot set imaginary part in real spaces'", ")", "self", ".", "imag", ".", "data", "[", ":", "]", "=", "newimag" ]
Setter for the imaginary part. This method is invoked by ``x.imag = other``. Parameters ---------- newimag : array-like or scalar Values to be assigned to the imaginary part of this element. Raises ------ ValueError If the space is real,...
[ "Setter", "for", "the", "imaginary", "part", "." ]
python
train
sosreport/sos
sos/plugins/origin.py
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/origin.py#L78-L80
def is_static_etcd(self): '''Determine if we are on a node running etcd''' return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml"))
[ "def", "is_static_etcd", "(", "self", ")", ":", "return", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "self", ".", "static_pod_dir", ",", "\"etcd.yaml\"", ")", ")" ]
Determine if we are on a node running etcd
[ "Determine", "if", "we", "are", "on", "a", "node", "running", "etcd" ]
python
train
sdispater/cachy
cachy/stores/file_store.py
https://github.com/sdispater/cachy/blob/ee4b044d6aafa80125730a00b1f679a7bd852b8a/cachy/stores/file_store.py#L178-L188
def flush(self): """ Remove all items from the cache. """ if os.path.isdir(self._directory): for root, dirs, files in os.walk(self._directory, topdown=False): for name in files: os.remove(os.path.join(root, name)) for name ...
[ "def", "flush", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "_directory", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "_directory", ",", "topdown", "=", "False...
Remove all items from the cache.
[ "Remove", "all", "items", "from", "the", "cache", "." ]
python
train
sosy-lab/benchexec
benchexec/model.py
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/model.py#L590-L669
def create_run_from_task_definition( self, task_def_file, options, propertyfile, required_files_pattern): """Create a Run from a task definition in yaml format""" task_def = load_task_definition_file(task_def_file) def expand_patterns_from_tag(tag): result = [] ...
[ "def", "create_run_from_task_definition", "(", "self", ",", "task_def_file", ",", "options", ",", "propertyfile", ",", "required_files_pattern", ")", ":", "task_def", "=", "load_task_definition_file", "(", "task_def_file", ")", "def", "expand_patterns_from_tag", "(", "t...
Create a Run from a task definition in yaml format
[ "Create", "a", "Run", "from", "a", "task", "definition", "in", "yaml", "format" ]
python
train
cggh/scikit-allel
allel/model/ndarray.py
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L700-L712
def count_hom(self, allele=None, axis=None): """Count homozygous genotypes. Parameters ---------- allele : int, optional Allele index. axis : int, optional Axis over which to count, or None to perform overall count. """ b = self.is_hom(al...
[ "def", "count_hom", "(", "self", ",", "allele", "=", "None", ",", "axis", "=", "None", ")", ":", "b", "=", "self", ".", "is_hom", "(", "allele", "=", "allele", ")", "return", "np", ".", "sum", "(", "b", ",", "axis", "=", "axis", ")" ]
Count homozygous genotypes. Parameters ---------- allele : int, optional Allele index. axis : int, optional Axis over which to count, or None to perform overall count.
[ "Count", "homozygous", "genotypes", "." ]
python
train
bennylope/django-organizations
organizations/abstract.py
https://github.com/bennylope/django-organizations/blob/85f753a8f7a8f0f31636c9209fb69e7030a5c79a/organizations/abstract.py#L117-L137
def add_user(self, user, is_admin=False): """ Adds a new user and if the first user makes the user an admin and the owner. """ users_count = self.users.all().count() if users_count == 0: is_admin = True # TODO get specific org user? org_user = ...
[ "def", "add_user", "(", "self", ",", "user", ",", "is_admin", "=", "False", ")", ":", "users_count", "=", "self", ".", "users", ".", "all", "(", ")", ".", "count", "(", ")", "if", "users_count", "==", "0", ":", "is_admin", "=", "True", "# TODO get sp...
Adds a new user and if the first user makes the user an admin and the owner.
[ "Adds", "a", "new", "user", "and", "if", "the", "first", "user", "makes", "the", "user", "an", "admin", "and", "the", "owner", "." ]
python
train
morpframework/morpfw
morpfw/authn/pas/user/view.py
https://github.com/morpframework/morpfw/blob/803fbf29714e6f29456482f1cfbdbd4922b020b0/morpfw/authn/pas/user/view.py#L131-L140
def logout(context, request): """Log out the user.""" @request.after def forget(response): request.app.forget_identity(response, request) return { 'status': 'success' }
[ "def", "logout", "(", "context", ",", "request", ")", ":", "@", "request", ".", "after", "def", "forget", "(", "response", ")", ":", "request", ".", "app", ".", "forget_identity", "(", "response", ",", "request", ")", "return", "{", "'status'", ":", "'...
Log out the user.
[ "Log", "out", "the", "user", "." ]
python
train
log2timeline/plaso
plaso/preprocessors/linux.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/preprocessors/linux.py#L111-L137
def _ParseFileData(self, knowledge_base, file_object): """Parses file content (data) for system product preprocessing attribute. Args: knowledge_base (KnowledgeBase): to fill with preprocessing information. file_object (dfvfs.FileIO): file-like object that contains the artifact value data...
[ "def", "_ParseFileData", "(", "self", ",", "knowledge_base", ",", "file_object", ")", ":", "text_file_object", "=", "dfvfs_text_file", ".", "TextFile", "(", "file_object", ",", "encoding", "=", "'utf-8'", ")", "product_values", "=", "{", "}", "for", "line", "i...
Parses file content (data) for system product preprocessing attribute. Args: knowledge_base (KnowledgeBase): to fill with preprocessing information. file_object (dfvfs.FileIO): file-like object that contains the artifact value data. Raises: errors.PreProcessFail: if the preprocessi...
[ "Parses", "file", "content", "(", "data", ")", "for", "system", "product", "preprocessing", "attribute", "." ]
python
train
gbowerman/azurerm
azurerm/computerp.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/computerp.py#L638-L652
def list_vms_sub(access_token, subscription_id): '''List VMs in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of a list of VM model views. ''' endpoint = ''.join(...
[ "def", "list_vms_sub", "(", "access_token", ",", "subscription_id", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/providers/Microsoft.Compute/virtualMachines'", ",", "'?...
List VMs in a subscription. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. Returns: HTTP response. JSON body of a list of VM model views.
[ "List", "VMs", "in", "a", "subscription", "." ]
python
train
pyviz/geoviews
geoviews/plotting/bokeh/callbacks.py
https://github.com/pyviz/geoviews/blob/cc70ac2d5a96307769bc6192eaef8576c3d24b30/geoviews/plotting/bokeh/callbacks.py#L48-L62
def project_ranges(cb, msg, attributes): """ Projects ranges supplied by a callback. """ if skip(cb, msg, attributes): return msg plot = get_cb_plot(cb) x0, x1 = msg.get('x_range', (0, 1000)) y0, y1 = msg.get('y_range', (0, 1000)) extents = x0, y0, x1, y1 x0, y0, x1, y1 = pr...
[ "def", "project_ranges", "(", "cb", ",", "msg", ",", "attributes", ")", ":", "if", "skip", "(", "cb", ",", "msg", ",", "attributes", ")", ":", "return", "msg", "plot", "=", "get_cb_plot", "(", "cb", ")", "x0", ",", "x1", "=", "msg", ".", "get", "...
Projects ranges supplied by a callback.
[ "Projects", "ranges", "supplied", "by", "a", "callback", "." ]
python
train
MIT-LCP/wfdb-python
wfdb/io/_header.py
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L653-L672
def wfdb_strptime(time_string): """ Given a time string in an acceptable wfdb format, return a datetime.time object. Valid formats: SS, MM:SS, HH:MM:SS, all with and without microsec. """ n_colons = time_string.count(':') if n_colons == 0: time_fmt = '%S' elif n_colons == 1: ...
[ "def", "wfdb_strptime", "(", "time_string", ")", ":", "n_colons", "=", "time_string", ".", "count", "(", "':'", ")", "if", "n_colons", "==", "0", ":", "time_fmt", "=", "'%S'", "elif", "n_colons", "==", "1", ":", "time_fmt", "=", "'%M:%S'", "elif", "n_col...
Given a time string in an acceptable wfdb format, return a datetime.time object. Valid formats: SS, MM:SS, HH:MM:SS, all with and without microsec.
[ "Given", "a", "time", "string", "in", "an", "acceptable", "wfdb", "format", "return", "a", "datetime", ".", "time", "object", "." ]
python
train
aiortc/aioice
aioice/ice.py
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L430-L446
async def recvfrom(self): """ Receive the next datagram. The return value is a `(bytes, component)` tuple where `bytes` is a bytes object representing the data received and `component` is the component on which the data was received. If the connection is not established...
[ "async", "def", "recvfrom", "(", "self", ")", ":", "if", "not", "len", "(", "self", ".", "_nominated", ")", ":", "raise", "ConnectionError", "(", "'Cannot receive data, not connected'", ")", "result", "=", "await", "self", ".", "_queue", ".", "get", "(", "...
Receive the next datagram. The return value is a `(bytes, component)` tuple where `bytes` is a bytes object representing the data received and `component` is the component on which the data was received. If the connection is not established, a `ConnectionError` is raised.
[ "Receive", "the", "next", "datagram", "." ]
python
train
opencobra/cobrapy
cobra/util/solver.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/solver.py#L232-L266
def choose_solver(model, solver=None, qp=False): """Choose a solver given a solver name and model. This will choose a solver compatible with the model and required capabilities. Also respects model.solver where it can. Parameters ---------- model : a cobra model The model for which to ...
[ "def", "choose_solver", "(", "model", ",", "solver", "=", "None", ",", "qp", "=", "False", ")", ":", "if", "solver", "is", "None", ":", "solver", "=", "model", ".", "problem", "else", ":", "model", ".", "solver", "=", "solver", "# Check for QP, raise err...
Choose a solver given a solver name and model. This will choose a solver compatible with the model and required capabilities. Also respects model.solver where it can. Parameters ---------- model : a cobra model The model for which to choose the solver. solver : str, optional Th...
[ "Choose", "a", "solver", "given", "a", "solver", "name", "and", "model", "." ]
python
valid
boriel/zxbasic
arch/zx48k/backend/__str.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__str.py#L210-L221
def _lenstr(ins): ''' Returns string length ''' (tmp1, output) = _str_oper(ins.quad[2], no_exaf=True) if tmp1: output.append('push hl') output.append('call __STRLEN') output.extend(_free_sequence(tmp1)) output.append('push hl') REQUIRES.add('strlen.asm') return output
[ "def", "_lenstr", "(", "ins", ")", ":", "(", "tmp1", ",", "output", ")", "=", "_str_oper", "(", "ins", ".", "quad", "[", "2", "]", ",", "no_exaf", "=", "True", ")", "if", "tmp1", ":", "output", ".", "append", "(", "'push hl'", ")", "output", ".",...
Returns string length
[ "Returns", "string", "length" ]
python
train
pingali/dgit
dgitcore/datasets/common.py
https://github.com/pingali/dgit/blob/ecde01f40b98f0719dbcfb54452270ed2f86686d/dgitcore/datasets/common.py#L84-L96
def shellcmd(repo, args): """ Run a shell command within the repo's context Parameters ---------- repo: Repository object args: Shell command """ with cd(repo.rootdir): result = run(args) return result
[ "def", "shellcmd", "(", "repo", ",", "args", ")", ":", "with", "cd", "(", "repo", ".", "rootdir", ")", ":", "result", "=", "run", "(", "args", ")", "return", "result" ]
Run a shell command within the repo's context Parameters ---------- repo: Repository object args: Shell command
[ "Run", "a", "shell", "command", "within", "the", "repo", "s", "context" ]
python
valid
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py#L394-L429
def _getImports_ldd(pth): """ Find the binary dependencies of PTH. This implementation is for ldd platforms (mostly unix). """ rslt = set() if is_aix: # Match libs of the form 'archive.a(sharedobject.so)' # Will not match the fake lib '/unix' lddPattern = re.compile(r"\s...
[ "def", "_getImports_ldd", "(", "pth", ")", ":", "rslt", "=", "set", "(", ")", "if", "is_aix", ":", "# Match libs of the form 'archive.a(sharedobject.so)'", "# Will not match the fake lib '/unix'", "lddPattern", "=", "re", ".", "compile", "(", "r\"\\s+(.*?)(\\(.*\\))\"", ...
Find the binary dependencies of PTH. This implementation is for ldd platforms (mostly unix).
[ "Find", "the", "binary", "dependencies", "of", "PTH", "." ]
python
train
hyperledger/indy-node
indy_common/util.py
https://github.com/hyperledger/indy-node/blob/8fabd364eaf7d940a56df2911d9215b1e512a2de/indy_common/util.py#L130-L140
def getIndex(predicateFn: Callable[[T], bool], items: List[T]) -> int: """ Finds the index of an item in list, which satisfies predicate :param predicateFn: predicate function to run on items of list :param items: list of tuples :return: first index for which predicate function returns True """ ...
[ "def", "getIndex", "(", "predicateFn", ":", "Callable", "[", "[", "T", "]", ",", "bool", "]", ",", "items", ":", "List", "[", "T", "]", ")", "->", "int", ":", "try", ":", "return", "next", "(", "i", "for", "i", ",", "v", "in", "enumerate", "(",...
Finds the index of an item in list, which satisfies predicate :param predicateFn: predicate function to run on items of list :param items: list of tuples :return: first index for which predicate function returns True
[ "Finds", "the", "index", "of", "an", "item", "in", "list", "which", "satisfies", "predicate", ":", "param", "predicateFn", ":", "predicate", "function", "to", "run", "on", "items", "of", "list", ":", "param", "items", ":", "list", "of", "tuples", ":", "r...
python
train
alixedi/palal
palal/palal.py
https://github.com/alixedi/palal/blob/325359f66ac48a9f96efea0489aec353f8a40837/palal/palal.py#L41-L49
def vector_distance(v1, v2): """Given 2 vectors of multiple dimensions, calculate the euclidean distance measure between them.""" dist = 0 for dim in v1: for x in v1[dim]: dd = int(v1[dim][x]) - int(v2[dim][x]) dist = dist + dd**2 return dist
[ "def", "vector_distance", "(", "v1", ",", "v2", ")", ":", "dist", "=", "0", "for", "dim", "in", "v1", ":", "for", "x", "in", "v1", "[", "dim", "]", ":", "dd", "=", "int", "(", "v1", "[", "dim", "]", "[", "x", "]", ")", "-", "int", "(", "v...
Given 2 vectors of multiple dimensions, calculate the euclidean distance measure between them.
[ "Given", "2", "vectors", "of", "multiple", "dimensions", "calculate", "the", "euclidean", "distance", "measure", "between", "them", "." ]
python
train
trivago/Protector
protector/parser/query_parser.py
https://github.com/trivago/Protector/blob/7ebe7bde965e27737b961a0cb5740724d174fdc7/protector/parser/query_parser.py#L173-L180
def create_drop_query(self, tokens): """ Parse tokens of drop query :param tokens: A list of InfluxDB query tokens """ if not tokens[Keyword.SERIES]: return None return DropQuery(self.parse_keyword(Keyword.SERIES, tokens))
[ "def", "create_drop_query", "(", "self", ",", "tokens", ")", ":", "if", "not", "tokens", "[", "Keyword", ".", "SERIES", "]", ":", "return", "None", "return", "DropQuery", "(", "self", ".", "parse_keyword", "(", "Keyword", ".", "SERIES", ",", "tokens", ")...
Parse tokens of drop query :param tokens: A list of InfluxDB query tokens
[ "Parse", "tokens", "of", "drop", "query", ":", "param", "tokens", ":", "A", "list", "of", "InfluxDB", "query", "tokens" ]
python
valid
kensho-technologies/graphql-compiler
setup.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L23-L30
def find_version(): """Only define version in one place""" version_file = read_file('__init__.py') version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']', version_file, re.M) if version_match: return version_match.group(1) raise RuntimeError('Unable to ...
[ "def", "find_version", "(", ")", ":", "version_file", "=", "read_file", "(", "'__init__.py'", ")", "version_match", "=", "re", ".", "search", "(", "r'^__version__ = [\"\\']([^\"\\']*)[\"\\']'", ",", "version_file", ",", "re", ".", "M", ")", "if", "version_match", ...
Only define version in one place
[ "Only", "define", "version", "in", "one", "place" ]
python
train
jbloomlab/phydms
phydmslib/simulate.py
https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/simulate.py#L18-L95
def pyvolvePartitions(model, divselection=None): """Get list of `pyvolve` partitions for `model`. Args: `model` (`phydmslib.models.Models` object) The model used for the simulations. Currently only certain `Models` are supported (e.g., `YNGKP`, `ExpCM`) `divs...
[ "def", "pyvolvePartitions", "(", "model", ",", "divselection", "=", "None", ")", ":", "codons", "=", "pyvolve", ".", "genetics", ".", "Genetics", "(", ")", ".", "codons", "codon_dict", "=", "pyvolve", ".", "genetics", ".", "Genetics", "(", ")", ".", "cod...
Get list of `pyvolve` partitions for `model`. Args: `model` (`phydmslib.models.Models` object) The model used for the simulations. Currently only certain `Models` are supported (e.g., `YNGKP`, `ExpCM`) `divselection` (`None` or 2-tuple `(divomega, divsites)`) ...
[ "Get", "list", "of", "pyvolve", "partitions", "for", "model", "." ]
python
train
jacexh/pyautoit
autoit/win.py
https://github.com/jacexh/pyautoit/blob/598314c3eed0639c701c8cb2366acb015e04b161/autoit/win.py#L106-L113
def win_get_caret_pos(): """ Returns the coordinates of the caret in the foreground window :return: """ p = POINT() AUTO_IT.AU3_WinGetCaretPos(byref(p)) return p.x, p.y
[ "def", "win_get_caret_pos", "(", ")", ":", "p", "=", "POINT", "(", ")", "AUTO_IT", ".", "AU3_WinGetCaretPos", "(", "byref", "(", "p", ")", ")", "return", "p", ".", "x", ",", "p", ".", "y" ]
Returns the coordinates of the caret in the foreground window :return:
[ "Returns", "the", "coordinates", "of", "the", "caret", "in", "the", "foreground", "window", ":", "return", ":" ]
python
valid
dagster-io/dagster
python_modules/dagster/dagster/core/events/logging.py
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/events/logging.py#L134-L146
def construct_event_logger(event_record_callback): ''' Callback receives a stream of event_records ''' check.callable_param(event_record_callback, 'event_record_callback') return construct_single_handler_logger( 'event-logger', DEBUG, StructuredLoggerHandler( lam...
[ "def", "construct_event_logger", "(", "event_record_callback", ")", ":", "check", ".", "callable_param", "(", "event_record_callback", ",", "'event_record_callback'", ")", "return", "construct_single_handler_logger", "(", "'event-logger'", ",", "DEBUG", ",", "StructuredLogg...
Callback receives a stream of event_records
[ "Callback", "receives", "a", "stream", "of", "event_records" ]
python
test
snare/voltron
voltron/dbg.py
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L70-L84
def lock_host(func, *args, **kwargs): """ A decorator that acquires a lock before accessing the debugger to avoid API locking related errors with the debugger host. """ def inner(self, *args, **kwargs): self.host_lock.acquire() try: res = func(self, *args, **kwargs) ...
[ "def", "lock_host", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "host_lock", ".", "acquire", "(", ")", "try", ":", "res", "=", ...
A decorator that acquires a lock before accessing the debugger to avoid API locking related errors with the debugger host.
[ "A", "decorator", "that", "acquires", "a", "lock", "before", "accessing", "the", "debugger", "to", "avoid", "API", "locking", "related", "errors", "with", "the", "debugger", "host", "." ]
python
train
eddieantonio/perfection
perfection/getty.py
https://github.com/eddieantonio/perfection/blob/69b7a06b31a15bd9534c69d4bdcc2e48e8ddfc43/perfection/getty.py#L283-L311
def make_hash(keys, **kwargs): """ Creates a perfect hash function from the given keys. For a description of the keyword arguments see :py:func:`hash_parameters`. >>> l = (0, 3, 4, 7 ,10, 13, 15, 18, 19, 21, 22, 24, 26, 29, 30, 34) >>> hf = make_hash(l) >>> hf(19) 1 >>> hash_parameters(...
[ "def", "make_hash", "(", "keys", ",", "*", "*", "kwargs", ")", ":", "params", "=", "hash_parameters", "(", "keys", ",", "*", "*", "kwargs", ")", "t", "=", "params", ".", "t", "r", "=", "params", ".", "r", "offset", "=", "params", ".", "offset", "...
Creates a perfect hash function from the given keys. For a description of the keyword arguments see :py:func:`hash_parameters`. >>> l = (0, 3, 4, 7 ,10, 13, 15, 18, 19, 21, 22, 24, 26, 29, 30, 34) >>> hf = make_hash(l) >>> hf(19) 1 >>> hash_parameters(l).slots[1] 19
[ "Creates", "a", "perfect", "hash", "function", "from", "the", "given", "keys", ".", "For", "a", "description", "of", "the", "keyword", "arguments", "see", ":", "py", ":", "func", ":", "hash_parameters", "." ]
python
train
softlayer/softlayer-python
SoftLayer/managers/vs.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs.py#L442-L453
def wait_for_transaction(self, instance_id, limit, delay=10): """Waits on a VS transaction for the specified amount of time. This is really just a wrapper for wait_for_ready(pending=True). Provided for backwards compatibility. :param int instance_id: The instance ID with the pending tr...
[ "def", "wait_for_transaction", "(", "self", ",", "instance_id", ",", "limit", ",", "delay", "=", "10", ")", ":", "return", "self", ".", "wait_for_ready", "(", "instance_id", ",", "limit", ",", "delay", "=", "delay", ",", "pending", "=", "True", ")" ]
Waits on a VS transaction for the specified amount of time. This is really just a wrapper for wait_for_ready(pending=True). Provided for backwards compatibility. :param int instance_id: The instance ID with the pending transaction :param int limit: The maximum amount of time to wait. ...
[ "Waits", "on", "a", "VS", "transaction", "for", "the", "specified", "amount", "of", "time", "." ]
python
train
Azure/azure-sdk-for-python
azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/servicemanagementservice.py#L1189-L1209
def create_reserved_ip_address(self, name, label=None, location=None): ''' Reserves an IPv4 address for the specified subscription. name: Required. Specifies the name for the reserved IP address. label: Optional. Specifies a label for the reserved IP address. The...
[ "def", "create_reserved_ip_address", "(", "self", ",", "name", ",", "label", "=", "None", ",", "location", "=", "None", ")", ":", "_validate_not_none", "(", "'name'", ",", "name", ")", "return", "self", ".", "_perform_post", "(", "self", ".", "_get_reserved_...
Reserves an IPv4 address for the specified subscription. name: Required. Specifies the name for the reserved IP address. label: Optional. Specifies a label for the reserved IP address. The label can be up to 100 characters long and can be used for your tracking ...
[ "Reserves", "an", "IPv4", "address", "for", "the", "specified", "subscription", "." ]
python
test
spacetelescope/drizzlepac
drizzlepac/findobj.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/findobj.py#L420-L434
def roundness(im): """ from astropy.io import fits as pyfits data=pyfits.getdata('j94f05bgq_flt.fits',ext=1) star0=data[403:412,423:432] star=data[396:432,3522:3558] In [53]: findobj.roundness(star0) Out[53]: 0.99401955054989544 In [54]: findobj.roundness(star) Out[54]: 0.83091919980...
[ "def", "roundness", "(", "im", ")", ":", "perimeter", "=", "im", ".", "shape", "[", "0", "]", "*", "2", "+", "im", ".", "shape", "[", "1", "]", "*", "2", "-", "4", "area", "=", "im", ".", "size", "return", "4", "*", "np", ".", "pi", "*", ...
from astropy.io import fits as pyfits data=pyfits.getdata('j94f05bgq_flt.fits',ext=1) star0=data[403:412,423:432] star=data[396:432,3522:3558] In [53]: findobj.roundness(star0) Out[53]: 0.99401955054989544 In [54]: findobj.roundness(star) Out[54]: 0.83091919980660645
[ "from", "astropy", ".", "io", "import", "fits", "as", "pyfits", "data", "=", "pyfits", ".", "getdata", "(", "j94f05bgq_flt", ".", "fits", "ext", "=", "1", ")", "star0", "=", "data", "[", "403", ":", "412", "423", ":", "432", "]", "star", "=", "data...
python
train
arista-eosplus/pyeapi
pyeapi/api/interfaces.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/interfaces.py#L526-L548
def set_sflow(self, name, value=None, default=False, disable=False): """Configures the sFlow state on the interface Args: name (string): The interface identifier. It must be a full interface name (ie Ethernet, not Et) value (boolean): True if sFlow should be en...
[ "def", "set_sflow", "(", "self", ",", "name", ",", "value", "=", "None", ",", "default", "=", "False", ",", "disable", "=", "False", ")", ":", "if", "value", "not", "in", "[", "True", ",", "False", ",", "None", "]", ":", "raise", "ValueError", "com...
Configures the sFlow state on the interface Args: name (string): The interface identifier. It must be a full interface name (ie Ethernet, not Et) value (boolean): True if sFlow should be enabled otherwise False default (boolean): Specifies the default valu...
[ "Configures", "the", "sFlow", "state", "on", "the", "interface" ]
python
train
tyarkoni/pliers
pliers/utils/updater.py
https://github.com/tyarkoni/pliers/blob/5b3385960ebd8c6ef1e86dd5e1be0080b2cb7f2b/pliers/utils/updater.py#L23-L95
def check_updates(transformers, datastore=None, stimuli=None): """ Run transformers through a battery of stimuli, and check if output has changed. Store results in csv file for comparison. Args: transformers (list): A list of tuples of transformer names and dictionary of parameters to i...
[ "def", "check_updates", "(", "transformers", ",", "datastore", "=", "None", ",", "stimuli", "=", "None", ")", ":", "# Find datastore file", "datastore", "=", "datastore", "or", "expanduser", "(", "'~/.pliers_updates'", ")", "prior_data", "=", "pd", ".", "read_cs...
Run transformers through a battery of stimuli, and check if output has changed. Store results in csv file for comparison. Args: transformers (list): A list of tuples of transformer names and dictionary of parameters to instantiate with (or empty dict). datastore (str): Filepath of C...
[ "Run", "transformers", "through", "a", "battery", "of", "stimuli", "and", "check", "if", "output", "has", "changed", ".", "Store", "results", "in", "csv", "file", "for", "comparison", "." ]
python
train
noahbenson/neuropythy
neuropythy/freesurfer/core.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/freesurfer/core.py#L93-L101
def is_freesurfer_subject_path(path): ''' is_freesurfer_subject_path(path) yields True if the given path appears to be a valid freesurfer subject path and False otherwise. A path is considered to be freesurfer-subject-like if it contains the directories mri/, surf/, and label/. ''' if not ...
[ "def", "is_freesurfer_subject_path", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "False", "else", ":", "return", "all", "(", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "jo...
is_freesurfer_subject_path(path) yields True if the given path appears to be a valid freesurfer subject path and False otherwise. A path is considered to be freesurfer-subject-like if it contains the directories mri/, surf/, and label/.
[ "is_freesurfer_subject_path", "(", "path", ")", "yields", "True", "if", "the", "given", "path", "appears", "to", "be", "a", "valid", "freesurfer", "subject", "path", "and", "False", "otherwise", ".", "A", "path", "is", "considered", "to", "be", "freesurfer", ...
python
train
nion-software/nionswift
nion/swift/Facade.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Facade.py#L2228-L2237
def get_source_data_items(self, data_item: DataItem) -> typing.List[DataItem]: """Return the list of data items that are data sources for the data item. :return: The list of :py:class:`nion.swift.Facade.DataItem` objects. .. versionadded:: 1.0 Scriptable: Yes """ retur...
[ "def", "get_source_data_items", "(", "self", ",", "data_item", ":", "DataItem", ")", "->", "typing", ".", "List", "[", "DataItem", "]", ":", "return", "[", "DataItem", "(", "data_item", ")", "for", "data_item", "in", "self", ".", "_document_model", ".", "g...
Return the list of data items that are data sources for the data item. :return: The list of :py:class:`nion.swift.Facade.DataItem` objects. .. versionadded:: 1.0 Scriptable: Yes
[ "Return", "the", "list", "of", "data", "items", "that", "are", "data", "sources", "for", "the", "data", "item", "." ]
python
train
Trebek/pydealer
pydealer/deck.py
https://github.com/Trebek/pydealer/blob/2ac583dd8c55715658c740b614387775f4dda333/pydealer/deck.py#L120-L135
def build(self, jokers=False, num_jokers=0): """ Builds a standard 52 card French deck of Card instances. :arg bool jokers: Whether or not to include jokers in the deck. :arg int num_jokers: The number of jokers to include. """ jokers = jokers or...
[ "def", "build", "(", "self", ",", "jokers", "=", "False", ",", "num_jokers", "=", "0", ")", ":", "jokers", "=", "jokers", "or", "self", ".", "jokers", "num_jokers", "=", "num_jokers", "or", "self", ".", "num_jokers", "self", ".", "decks_used", "+=", "1...
Builds a standard 52 card French deck of Card instances. :arg bool jokers: Whether or not to include jokers in the deck. :arg int num_jokers: The number of jokers to include.
[ "Builds", "a", "standard", "52", "card", "French", "deck", "of", "Card", "instances", "." ]
python
train
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/__init__.py
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/__init__.py#L1175-L1266
def get_next_entity_to_export(self): """ Examines the archive_observationExport and archive_metadataExport tables, and builds either a :class:`meteorpi_db.ObservationExportTask` or a :class:`meteorpi_db.MetadataExportTask` as appropriate. These task objects can be used to retrieve the un...
[ "def", "get_next_entity_to_export", "(", "self", ")", ":", "# If the queue of items waiting to export is old, delete it and fetch a new list from the database", "if", "self", ".", "export_queue_valid_until", "<", "time", ".", "time", "(", ")", ":", "self", ".", "export_queue_...
Examines the archive_observationExport and archive_metadataExport tables, and builds either a :class:`meteorpi_db.ObservationExportTask` or a :class:`meteorpi_db.MetadataExportTask` as appropriate. These task objects can be used to retrieve the underlying entity and export configuration, and to update t...
[ "Examines", "the", "archive_observationExport", "and", "archive_metadataExport", "tables", "and", "builds", "either", "a", ":", "class", ":", "meteorpi_db", ".", "ObservationExportTask", "or", "a", ":", "class", ":", "meteorpi_db", ".", "MetadataExportTask", "as", "...
python
train
pywbem/pywbem
pywbem/cim_operations.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_operations.py#L1878-L2132
def _methodcall(self, methodname, objectname, Params=None, **params): """ Perform an extrinsic CIM-XML method call. Parameters: methodname (string): CIM method name. objectname (string or CIMInstanceName or CIMClassName): Target object. Strings are interpreted ...
[ "def", "_methodcall", "(", "self", ",", "methodname", ",", "objectname", ",", "Params", "=", "None", ",", "*", "*", "params", ")", ":", "if", "isinstance", "(", "objectname", ",", "(", "CIMInstanceName", ",", "CIMClassName", ")", ")", ":", "localobject", ...
Perform an extrinsic CIM-XML method call. Parameters: methodname (string): CIM method name. objectname (string or CIMInstanceName or CIMClassName): Target object. Strings are interpreted as class names. Params: CIM method input parameters, for details see InvokeMeth...
[ "Perform", "an", "extrinsic", "CIM", "-", "XML", "method", "call", "." ]
python
train
SpamScope/mail-parser
mailparser/mailparser.py
https://github.com/SpamScope/mail-parser/blob/814b56d0b803feab9dea04f054b802ce138097e2/mailparser/mailparser.py#L223-L238
def from_bytes(cls, bt): """ Init a new object from bytes. Args: bt (bytes-like object): raw email as bytes-like object Returns: Instance of MailParser """ log.debug("Parsing email from bytes") if six.PY2: raise MailParserEnvi...
[ "def", "from_bytes", "(", "cls", ",", "bt", ")", ":", "log", ".", "debug", "(", "\"Parsing email from bytes\"", ")", "if", "six", ".", "PY2", ":", "raise", "MailParserEnvironmentError", "(", "\"Parsing from bytes is valid only for Python 3.x version\"", ")", "message"...
Init a new object from bytes. Args: bt (bytes-like object): raw email as bytes-like object Returns: Instance of MailParser
[ "Init", "a", "new", "object", "from", "bytes", "." ]
python
train
bachiraoun/pyrep
Repository.py
https://github.com/bachiraoun/pyrep/blob/0449bf2fad3e3e8dda855d4686a8869efeefd433/Repository.py#L1331-L1361
def walk_files_path(self, relativePath="", fullPath=False, recursive=False): """ Walk the repository relative path and yield file relative/full path. :parameters: #. relativePath (string): The relative path from which start the walk. #. fullPath (boolean): Whether to ret...
[ "def", "walk_files_path", "(", "self", ",", "relativePath", "=", "\"\"", ",", "fullPath", "=", "False", ",", "recursive", "=", "False", ")", ":", "assert", "isinstance", "(", "fullPath", ",", "bool", ")", ",", "\"fullPath must be boolean\"", "assert", "isinsta...
Walk the repository relative path and yield file relative/full path. :parameters: #. relativePath (string): The relative path from which start the walk. #. fullPath (boolean): Whether to return full or relative path. #. recursive (boolean): Whether walk all directories files...
[ "Walk", "the", "repository", "relative", "path", "and", "yield", "file", "relative", "/", "full", "path", "." ]
python
valid
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py#L3148-L3160
def confd_state_internal_cdb_client_subscription_twophase(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") confd_state = ET.SubElement(config, "confd-state", xmlns="http://tail-f.com/yang/confd-monitoring") internal = ET.SubElement(confd_state, "internal"...
[ "def", "confd_state_internal_cdb_client_subscription_twophase", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "confd_state", "=", "ET", ".", "SubElement", "(", "config", ",", "\"confd-state\"", ",", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
sampottinger/pycotracer
pycotracer/report_interpreters.py
https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L32-L51
def parse_yes_no_str(bool_str): """Parse a string serialization of boolean data as yes (Y) or no (N). Prase a string serialization of boolean data where True is "Y" and False is "N" case-insensitive. @param bool_str: The string to parse. @type bool_str: str @return: The interpreted string. ...
[ "def", "parse_yes_no_str", "(", "bool_str", ")", ":", "lower_bool_str", "=", "bool_str", ".", "lower", "(", ")", "if", "lower_bool_str", "==", "'n'", ":", "return", "False", "elif", "lower_bool_str", "==", "'y'", ":", "return", "True", "else", ":", "raise", ...
Parse a string serialization of boolean data as yes (Y) or no (N). Prase a string serialization of boolean data where True is "Y" and False is "N" case-insensitive. @param bool_str: The string to parse. @type bool_str: str @return: The interpreted string. @rtype: bool @raise ValueError: Ra...
[ "Parse", "a", "string", "serialization", "of", "boolean", "data", "as", "yes", "(", "Y", ")", "or", "no", "(", "N", ")", "." ]
python
train
ellmetha/django-machina
machina/apps/forum_permission/viewmixins.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_permission/viewmixins.py#L51-L68
def get_required_permissions(self, request): """ Returns the required permissions to access the considered object. """ perms = [] if not self.permission_required: return perms if isinstance(self.permission_required, string_types): perms = [self.permission_requir...
[ "def", "get_required_permissions", "(", "self", ",", "request", ")", ":", "perms", "=", "[", "]", "if", "not", "self", ".", "permission_required", ":", "return", "perms", "if", "isinstance", "(", "self", ".", "permission_required", ",", "string_types", ")", ...
Returns the required permissions to access the considered object.
[ "Returns", "the", "required", "permissions", "to", "access", "the", "considered", "object", "." ]
python
train
xmikos/soapy_power
soapypower/power.py
https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L91-L93
def time_to_repeats(self, bins, integration_time): """Convert integration time to number of repeats""" return math.ceil((self.device.sample_rate * integration_time) / bins)
[ "def", "time_to_repeats", "(", "self", ",", "bins", ",", "integration_time", ")", ":", "return", "math", ".", "ceil", "(", "(", "self", ".", "device", ".", "sample_rate", "*", "integration_time", ")", "/", "bins", ")" ]
Convert integration time to number of repeats
[ "Convert", "integration", "time", "to", "number", "of", "repeats" ]
python
test
dh1tw/pyhamtools
pyhamtools/lookuplib.py
https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1435-L1439
def _generate_random_word(self, length): """ Generates a random word """ return ''.join(random.choice(string.ascii_lowercase) for _ in range(length))
[ "def", "_generate_random_word", "(", "self", ",", "length", ")", ":", "return", "''", ".", "join", "(", "random", ".", "choice", "(", "string", ".", "ascii_lowercase", ")", "for", "_", "in", "range", "(", "length", ")", ")" ]
Generates a random word
[ "Generates", "a", "random", "word" ]
python
train
mitsei/dlkit
dlkit/json_/grading/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/managers.py#L1526-L1543
def get_gradebook_column_query_session(self, proxy): """Gets the ``OsidSession`` associated with the gradebook column query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.grading.GradebookColumnQuerySession) - a ``GradebookColumnQuerySession`` raise: N...
[ "def", "get_gradebook_column_query_session", "(", "self", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_gradebook_column_query", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".",...
Gets the ``OsidSession`` associated with the gradebook column query service. arg: proxy (osid.proxy.Proxy): a proxy return: (osid.grading.GradebookColumnQuerySession) - a ``GradebookColumnQuerySession`` raise: NullArgument - ``proxy`` is ``null`` raise: OperationFai...
[ "Gets", "the", "OsidSession", "associated", "with", "the", "gradebook", "column", "query", "service", "." ]
python
train
blockstack/blockstack-core
blockstack/lib/client.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L1963-L2006
def get_all_names(offset=None, count=None, include_expired=False, proxy=None, hostport=None): """ Get all names within the given range. Return the list of names on success Return {'error': ...} on failure """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy ...
[ "def", "get_all_names", "(", "offset", "=", "None", ",", "count", "=", "None", ",", "include_expired", "=", "False", ",", "proxy", "=", "None", ",", "hostport", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "i...
Get all names within the given range. Return the list of names on success Return {'error': ...} on failure
[ "Get", "all", "names", "within", "the", "given", "range", ".", "Return", "the", "list", "of", "names", "on", "success", "Return", "{", "error", ":", "...", "}", "on", "failure" ]
python
train
pybel/pybel
src/pybel/struct/graph.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L554-L556
def has_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> bool: """Check if the given edge has a citation.""" return self._has_edge_attr(u, v, key, CITATION)
[ "def", "has_edge_citation", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "key", ":", "str", ")", "->", "bool", ":", "return", "self", ".", "_has_edge_attr", "(", "u", ",", "v", ",", "key", ",", "CITATION", ")" ]
Check if the given edge has a citation.
[ "Check", "if", "the", "given", "edge", "has", "a", "citation", "." ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8629-L8790
def main(argv=None): """to install and/or test from the command line use:: python cma.py [options | func dim sig0 [optkey optval][optkey optval]...] with options being ``--test`` (or ``-t``) to run the doctest, ``--test -v`` to get (much) verbosity. ``install`` to install cma.py (uses setup ...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "if", "argv", "is", "None", ":", "argv", "=", "sys", ".", "argv", "# should have better been sys.argv[1:]", "else", ":", "if", "isinstance", "(", "argv", ",", "list", ")", ":", "argv", "=", "[", "'pyth...
to install and/or test from the command line use:: python cma.py [options | func dim sig0 [optkey optval][optkey optval]...] with options being ``--test`` (or ``-t``) to run the doctest, ``--test -v`` to get (much) verbosity. ``install`` to install cma.py (uses setup from distutils.core). `...
[ "to", "install", "and", "/", "or", "test", "from", "the", "command", "line", "use", "::" ]
python
train
noxdafox/pebble
pebble/pool/thread.py
https://github.com/noxdafox/pebble/blob/d8f3d989655715754f0a65d7419cfa584491f614/pebble/pool/thread.py#L155-L167
def worker_thread(context): """The worker thread routines.""" queue = context.task_queue parameters = context.worker_parameters if parameters.initializer is not None: if not run_initializer(parameters.initializer, parameters.initargs): context.state = ERROR return f...
[ "def", "worker_thread", "(", "context", ")", ":", "queue", "=", "context", ".", "task_queue", "parameters", "=", "context", ".", "worker_parameters", "if", "parameters", ".", "initializer", "is", "not", "None", ":", "if", "not", "run_initializer", "(", "parame...
The worker thread routines.
[ "The", "worker", "thread", "routines", "." ]
python
train