repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
inveniosoftware/invenio-files-rest
invenio_files_rest/models.py
https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/models.py#L1298-L1311
def copy(self, object_version=None, key=None): """Copy a tag to a given object version. :param object_version: The object version instance to copy the tag to. Default: current object version. :param key: Key of destination tag. Default: current tag key. :return: ...
[ "def", "copy", "(", "self", ",", "object_version", "=", "None", ",", "key", "=", "None", ")", ":", "return", "ObjectVersionTag", ".", "create", "(", "self", ".", "object_version", "if", "object_version", "is", "None", "else", "object_version", ",", "key", ...
Copy a tag to a given object version. :param object_version: The object version instance to copy the tag to. Default: current object version. :param key: Key of destination tag. Default: current tag key. :return: The copied object version tag.
[ "Copy", "a", "tag", "to", "a", "given", "object", "version", "." ]
python
train
37.857143
fermiPy/fermipy
fermipy/diffuse/fitting.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/fitting.py#L112-L142
def snapshot(gta, plotter, key, do_weighted=True, make_plots=True): """Take a snapshot of the ROI Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object plotter : `fermipy.plotting.AnalysisPlotter` The object that makes the plots key : str Key for this s...
[ "def", "snapshot", "(", "gta", ",", "plotter", ",", "key", ",", "do_weighted", "=", "True", ",", "make_plots", "=", "True", ")", ":", "gta", ".", "write_roi", "(", "key", ",", "save_model_map", "=", "True", ",", "make_plots", "=", "make_plots", ",", "s...
Take a snapshot of the ROI Parameters ---------- gta : `fermipy.GTAnalysis` The analysis object plotter : `fermipy.plotting.AnalysisPlotter` The object that makes the plots key : str Key for this snapshot, used to create filenames do_weighted : bool If True, ...
[ "Take", "a", "snapshot", "of", "the", "ROI" ]
python
train
27.258065
onnx/onnx
setup.py
https://github.com/onnx/onnx/blob/2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4/setup.py#L252-L256
def run(self): """Run command.""" onnx_script = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "tools/mypy-onnx.py")) returncode = subprocess.call([sys.executable, onnx_script]) sys.exit(returncode)
[ "def", "run", "(", "self", ")", ":", "onnx_script", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "\...
Run command.
[ "Run", "command", "." ]
python
train
50.6
RealTimeWeb/datasets
builder/compile.py
https://github.com/RealTimeWeb/datasets/blob/2fe5befd251c783744d000bd4763e277616a152f/builder/compile.py#L379-L423
def walk_interface(self, name, data, in_location): interface = Interface() location = "{}.{}".format(in_location, name) if isinstance(data, dict): interface.name = de_identifier(self.require_field(location, "name", data, "", str)) location = "{}.{}".format(in_location, cl...
[ "def", "walk_interface", "(", "self", ",", "name", ",", "data", ",", "in_location", ")", ":", "interface", "=", "Interface", "(", ")", "location", "=", "\"{}.{}\"", ".", "format", "(", "in_location", ",", "name", ")", "if", "isinstance", "(", "data", ","...
self.require_field("url", "{}.url".format(location), data, str) self.require_field("verb", "{}.verb".format(location), data, set(("get", "post", "delete", "put"))) self.recommend_field("format", "{}.format".format(location), data, set(("json", "xml", "html", "csv", "text")), not_found="Assuming ...
[ "self", ".", "require_field", "(", "url", "{}", ".", "url", ".", "format", "(", "location", ")", "data", "str", ")", "self", ".", "require_field", "(", "verb", "{}", ".", "verb", ".", "format", "(", "location", ")", "data", "set", "((", "get", "post"...
python
train
62.733333
Microsoft/botbuilder-python
libraries/botframework-connector/botframework/connector/auth/emulator_validation.py
https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botframework-connector/botframework/connector/auth/emulator_validation.py#L33-L81
def is_token_from_emulator(auth_header: str) -> bool: """ Determines if a given Auth header is from the Bot Framework Emulator :param auth_header: Bearer Token, in the 'Bearer [Long String]' Format. :type auth_header: str :return: True, if the token was issued by the Emulator. Otherwis...
[ "def", "is_token_from_emulator", "(", "auth_header", ":", "str", ")", "->", "bool", ":", "# The Auth Header generally looks like this:", "# \"Bearer eyJ0e[...Big Long String...]XAiO\"", "if", "not", "auth_header", ":", "# No token. Can't be an emulator token.", "return", "False",...
Determines if a given Auth header is from the Bot Framework Emulator :param auth_header: Bearer Token, in the 'Bearer [Long String]' Format. :type auth_header: str :return: True, if the token was issued by the Emulator. Otherwise, false.
[ "Determines", "if", "a", "given", "Auth", "header", "is", "from", "the", "Bot", "Framework", "Emulator" ]
python
test
35.877551
scanny/python-pptx
pptx/chart/xmlwriter.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/xmlwriter.py#L1809-L1822
def _rewrite_ser_data(self, ser, series_data, date_1904): """ Rewrite the ``<c:tx>``, ``<c:xVal>`` and ``<c:yVal>`` child elements of *ser* based on the values in *series_data*. """ ser._remove_tx() ser._remove_xVal() ser._remove_yVal() xml_writer = _XySe...
[ "def", "_rewrite_ser_data", "(", "self", ",", "ser", ",", "series_data", ",", "date_1904", ")", ":", "ser", ".", "_remove_tx", "(", ")", "ser", ".", "_remove_xVal", "(", ")", "ser", ".", "_remove_yVal", "(", ")", "xml_writer", "=", "_XySeriesXmlWriter", "(...
Rewrite the ``<c:tx>``, ``<c:xVal>`` and ``<c:yVal>`` child elements of *ser* based on the values in *series_data*.
[ "Rewrite", "the", "<c", ":", "tx", ">", "<c", ":", "xVal", ">", "and", "<c", ":", "yVal", ">", "child", "elements", "of", "*", "ser", "*", "based", "on", "the", "values", "in", "*", "series_data", "*", "." ]
python
train
32.571429
hovren/crisp
crisp/camera.py
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/camera.py#L128-L158
def from_hdf(cls, filename): """Load camera model params from a HDF5 file The HDF5 file should contain the following datasets: wc : (2,) float with distortion center lgamma : float distortion parameter readout : float readout value size : (2,) int image s...
[ "def", "from_hdf", "(", "cls", ",", "filename", ")", ":", "import", "h5py", "with", "h5py", ".", "File", "(", "filename", ",", "'r'", ")", "as", "f", ":", "wc", "=", "f", "[", "\"wc\"", "]", ".", "value", "lgamma", "=", "f", "[", "\"lgamma\"", "]...
Load camera model params from a HDF5 file The HDF5 file should contain the following datasets: wc : (2,) float with distortion center lgamma : float distortion parameter readout : float readout value size : (2,) int image size fps : float frame rate ...
[ "Load", "camera", "model", "params", "from", "a", "HDF5", "file" ]
python
train
31.451613
jjangsangy/kan
kan/structures.py
https://github.com/jjangsangy/kan/blob/7da9d9ec5dc6b8bbb86cfd27d737978a406d9fa6/kan/structures.py#L118-L132
def connect(self, agent='Python'): """ Context manager for HTTP Connection state and ensures proper handling of network sockets, sends a GET request. Exception is raised at the yield statement. :yield request: FileIO<Socket> """ headers = {'User-Agent': agent} ...
[ "def", "connect", "(", "self", ",", "agent", "=", "'Python'", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "agent", "}", "request", "=", "urlopen", "(", "Request", "(", "self", ".", "url", ",", "headers", "=", "headers", ")", ")", "try", ":", ...
Context manager for HTTP Connection state and ensures proper handling of network sockets, sends a GET request. Exception is raised at the yield statement. :yield request: FileIO<Socket>
[ "Context", "manager", "for", "HTTP", "Connection", "state", "and", "ensures", "proper", "handling", "of", "network", "sockets", "sends", "a", "GET", "request", "." ]
python
train
30
googledatalab/pydatalab
google/datalab/contrib/pipeline/commands/_pipeline.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/contrib/pipeline/commands/_pipeline.py#L66-L83
def _create_pipeline_parser(): """ Create the parser for the %pipeline magics. Note that because we use the func default handler dispatch mechanism of argparse, our handlers can take only one argument which is the parsed args. So we must create closures for the handlers that bind the cell contents and th...
[ "def", "_create_pipeline_parser", "(", ")", ":", "parser", "=", "google", ".", "datalab", ".", "utils", ".", "commands", ".", "CommandParser", "(", "prog", "=", "'%pipeline'", ",", "description", "=", "\"\"\"\nExecute various pipeline-related operations. Use \"%pipeline...
Create the parser for the %pipeline magics. Note that because we use the func default handler dispatch mechanism of argparse, our handlers can take only one argument which is the parsed args. So we must create closures for the handlers that bind the cell contents and thus must recreate this parser for ...
[ "Create", "the", "parser", "for", "the", "%pipeline", "magics", "." ]
python
train
37.944444
f3at/feat
src/feat/models/response.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/models/response.py#L51-L57
def done(message): """Create a Deleted response builder with specified message.""" def done(value, _context, **_params): return Done(value, message) return done
[ "def", "done", "(", "message", ")", ":", "def", "done", "(", "value", ",", "_context", ",", "*", "*", "_params", ")", ":", "return", "Done", "(", "value", ",", "message", ")", "return", "done" ]
Create a Deleted response builder with specified message.
[ "Create", "a", "Deleted", "response", "builder", "with", "specified", "message", "." ]
python
train
25.142857
nerdvegas/rez
src/rez/vendor/argcomplete/__init__.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/argcomplete/__init__.py#L409-L439
def complete(self, text, state): ''' Alternate entry point for using the argcomplete completer in a readline-based REPL. See also `rlcompleter <https://docs.python.org/2/library/rlcompleter.html#completer-objects>`_. Usage: .. code-block:: python import argcomplete...
[ "def", "complete", "(", "self", ",", "text", ",", "state", ")", ":", "if", "state", "==", "0", ":", "print", "(", "\"Retrieving matches for\"", ",", "text", ")", "cword_prequote", ",", "cword_prefix", ",", "cword_suffix", ",", "comp_words", ",", "first_colon...
Alternate entry point for using the argcomplete completer in a readline-based REPL. See also `rlcompleter <https://docs.python.org/2/library/rlcompleter.html#completer-objects>`_. Usage: .. code-block:: python import argcomplete, argparse, readline parser = argparse.Ar...
[ "Alternate", "entry", "point", "for", "using", "the", "argcomplete", "completer", "in", "a", "readline", "-", "based", "REPL", ".", "See", "also", "rlcompleter", "<https", ":", "//", "docs", ".", "python", ".", "org", "/", "2", "/", "library", "/", "rlco...
python
train
45.774194
idlesign/django-siteblocks
siteblocks/templatetags/siteblocks.py
https://github.com/idlesign/django-siteblocks/blob/7fdb3800f7330dd4143d55416393d83d01a09f73/siteblocks/templatetags/siteblocks.py#L13-L39
def siteblock(parser, token): """Two notation types are acceptable: 1. Two arguments: {% siteblock "myblock" %} Used to render "myblock" site block. 2. Four arguments: {% siteblock "myblock" as myvar %} Used to put "myblock" site block into "m...
[ "def", "siteblock", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "tokens_num", "=", "len", "(", "tokens", ")", "if", "tokens_num", "not", "in", "(", "2", ",", "4", ")", ":", "raise", "template", ".",...
Two notation types are acceptable: 1. Two arguments: {% siteblock "myblock" %} Used to render "myblock" site block. 2. Four arguments: {% siteblock "myblock" as myvar %} Used to put "myblock" site block into "myvar" template variable.
[ "Two", "notation", "types", "are", "acceptable", ":" ]
python
train
31.62963
vmlaker/mpipe
src/Stage.py
https://github.com/vmlaker/mpipe/blob/5a1804cf64271931f0cd3e4fff3e2b38291212dd/src/Stage.py#L42-L55
def get(self, timeout=None): """Retrieve results from all the output tubes.""" valid = False result = None for tube in self._output_tubes: if timeout: valid, result = tube.get(timeout) if valid: result = result[0] ...
[ "def", "get", "(", "self", ",", "timeout", "=", "None", ")", ":", "valid", "=", "False", "result", "=", "None", "for", "tube", "in", "self", ".", "_output_tubes", ":", "if", "timeout", ":", "valid", ",", "result", "=", "tube", ".", "get", "(", "tim...
Retrieve results from all the output tubes.
[ "Retrieve", "results", "from", "all", "the", "output", "tubes", "." ]
python
train
30.571429
thomasdelaet/python-velbus
velbus/connections/serial.py
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/connections/serial.py#L77-L85
def stop(self): """Close serial port.""" self.logger.warning("Stop executed") try: self._reader.close() except serial.serialutil.SerialException: self.logger.error("Error while closing device") raise VelbusException("Error while closing device") ...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "logger", ".", "warning", "(", "\"Stop executed\"", ")", "try", ":", "self", ".", "_reader", ".", "close", "(", ")", "except", "serial", ".", "serialutil", ".", "SerialException", ":", "self", ".", "lo...
Close serial port.
[ "Close", "serial", "port", "." ]
python
train
36.333333
chimera0/accel-brain-code
Binaural-Beat-and-Monaural-Beat-with-python/AccelBrainBeat/brain_beat.py
https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Binaural-Beat-and-Monaural-Beat-with-python/AccelBrainBeat/brain_beat.py#L85-L113
def save_beat( self, output_file_name, frequencys, play_time, sample_rate=44100, volume=0.01 ): ''' 引数で指定した条件でビートを鳴らす Args: frequencys: (左の周波数(Hz), 右の周波数(Hz))のtuple play_time: 再生時間(秒) ...
[ "def", "save_beat", "(", "self", ",", "output_file_name", ",", "frequencys", ",", "play_time", ",", "sample_rate", "=", "44100", ",", "volume", "=", "0.01", ")", ":", "left_frequency", ",", "right_frequency", "=", "frequencys", "left_chunk", "=", "self", ".", ...
引数で指定した条件でビートを鳴らす Args: frequencys: (左の周波数(Hz), 右の周波数(Hz))のtuple play_time: 再生時間(秒) sample_rate: サンプルレート volume: 音量 Returns: void
[ "引数で指定した条件でビートを鳴らす", "Args", ":", "frequencys", ":", "(", "左の周波数", "(", "Hz", ")", "右の周波数", "(", "Hz", "))", "のtuple", "play_time", ":", "再生時間(秒)", "sample_rate", ":", "サンプルレート", "volume", ":", "音量", "Returns", ":", "void" ]
python
train
30.275862
ga4gh/ga4gh-server
ga4gh/server/repo/rnaseq2ga.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/repo/rnaseq2ga.py#L136-L172
def writeExpression(self, rnaQuantificationId, quantfilename): """ Reads the quantification results file and adds entries to the specified database. """ isNormalized = self._isNormalized units = self._units with open(quantfilename, "r") as quantFile: q...
[ "def", "writeExpression", "(", "self", ",", "rnaQuantificationId", ",", "quantfilename", ")", ":", "isNormalized", "=", "self", ".", "_isNormalized", "units", "=", "self", ".", "_units", "with", "open", "(", "quantfilename", ",", "\"r\"", ")", "as", "quantFile...
Reads the quantification results file and adds entries to the specified database.
[ "Reads", "the", "quantification", "results", "file", "and", "adds", "entries", "to", "the", "specified", "database", "." ]
python
train
49.054054
dailymuse/oz
oz/bandit/__init__.py
https://github.com/dailymuse/oz/blob/4329f6a207dc9d2a8fbeb4d16d415dbe4570b5bd/oz/bandit/__init__.py#L190-L196
def choices(self): """Gets the experiment choices""" if self._choices == None: self._choices = [ExperimentChoice(self, choice_name) for choice_name in self.choice_names] return self._choices
[ "def", "choices", "(", "self", ")", ":", "if", "self", ".", "_choices", "==", "None", ":", "self", ".", "_choices", "=", "[", "ExperimentChoice", "(", "self", ",", "choice_name", ")", "for", "choice_name", "in", "self", ".", "choice_names", "]", "return"...
Gets the experiment choices
[ "Gets", "the", "experiment", "choices" ]
python
train
31.714286
jilljenn/tryalgo
tryalgo/binary_search.py
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/binary_search.py#L26-L41
def discrete_binary_search(tab, lo, hi): """Binary search in a table :param tab: boolean monotone table with tab[hi] = True :param int lo: :param int hi: with hi >= lo :returns: first index i in [lo,hi] such that tab[i] :complexity: `O(log(hi-lo))` """ while lo < hi: mid = lo + ...
[ "def", "discrete_binary_search", "(", "tab", ",", "lo", ",", "hi", ")", ":", "while", "lo", "<", "hi", ":", "mid", "=", "lo", "+", "(", "hi", "-", "lo", ")", "//", "2", "if", "tab", "[", "mid", "]", ":", "hi", "=", "mid", "else", ":", "lo", ...
Binary search in a table :param tab: boolean monotone table with tab[hi] = True :param int lo: :param int hi: with hi >= lo :returns: first index i in [lo,hi] such that tab[i] :complexity: `O(log(hi-lo))`
[ "Binary", "search", "in", "a", "table" ]
python
train
25.875
rochacbruno/Flask-GoogleMaps
flask_googlemaps/__init__.py
https://github.com/rochacbruno/Flask-GoogleMaps/blob/8b1c7c50c04219aac3d58ab5af569933e55ad464/flask_googlemaps/__init__.py#L192-L236
def build_rectangle_dict(self, north, west, south, east, stroke_color='#FF0000', stroke_opacity=.8, stroke_weight=2, ...
[ "def", "build_rectangle_dict", "(", "self", ",", "north", ",", "west", ",", "south", ",", "east", ",", "stroke_color", "=", "'#FF0000'", ",", "stroke_opacity", "=", ".8", ",", "stroke_weight", "=", "2", ",", "fill_color", "=", "'#FF0000'", ",", "fill_opacity...
Set a dictionary with the javascript class Rectangle parameters This function sets a default drawing configuration if the user just pass the rectangle bounds, but also allows to set each parameter individually if the user wish so. Args: north (float): The north latitude bou...
[ "Set", "a", "dictionary", "with", "the", "javascript", "class", "Rectangle", "parameters" ]
python
train
41.866667
RiotGames/cloud-inquisitor
backend/cloud_inquisitor/plugins/notifiers/slack.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/backend/cloud_inquisitor/plugins/notifiers/slack.py#L94-L131
def notify(self, subsystem, recipient, subject, body_html, body_text): """You can send messages either to channels and private groups by using the following formats #channel-name @username-direct-message Args: subsystem (`str`): Name of the subsystem originating the notific...
[ "def", "notify", "(", "self", ",", "subsystem", ",", "recipient", ",", "subject", ",", "body_html", ",", "body_text", ")", ":", "if", "not", "re", ".", "match", "(", "self", ".", "validation", ",", "recipient", ",", "re", ".", "I", ")", ":", "raise",...
You can send messages either to channels and private groups by using the following formats #channel-name @username-direct-message Args: subsystem (`str`): Name of the subsystem originating the notification recipient (`str`): Recipient subject (`str`): Subjec...
[ "You", "can", "send", "messages", "either", "to", "channels", "and", "private", "groups", "by", "using", "the", "following", "formats" ]
python
train
35.236842
ciena/afkak
afkak/producer.py
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/producer.py#L235-L252
def stop(self): """ Terminate any outstanding requests. :returns: :class:``Deferred` which fires when fully stopped. """ self.stopping = True # Cancel any outstanding request to our client if self._batch_send_d: self._batch_send_d.cancel() # D...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "stopping", "=", "True", "# Cancel any outstanding request to our client", "if", "self", ".", "_batch_send_d", ":", "self", ".", "_batch_send_d", ".", "cancel", "(", ")", "# Do we have to worry about our looping call?...
Terminate any outstanding requests. :returns: :class:``Deferred` which fires when fully stopped.
[ "Terminate", "any", "outstanding", "requests", "." ]
python
train
38.833333
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/ag/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/ag/__init__.py#L198-L219
def _set_nport_menu(self, v, load=False): """ Setter method for nport_menu, mapped from YANG variable /rbridge_id/ag/nport_menu (container) If this variable is read-only (config: false) in the source YANG file, then _set_nport_menu is considered as a private method. Backends looking to populate this...
[ "def", "_set_nport_menu", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "bas...
Setter method for nport_menu, mapped from YANG variable /rbridge_id/ag/nport_menu (container) If this variable is read-only (config: false) in the source YANG file, then _set_nport_menu is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_np...
[ "Setter", "method", "for", "nport_menu", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "ag", "/", "nport_menu", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "so...
python
train
73.272727
polyaxon/polyaxon
polyaxon/pipelines/utils.py
https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/pipelines/utils.py#L19-L25
def set_topological_dag_upstreams(dag, ops, op_runs, runs_by_ops): """Set the upstream runs for the operation runs in the dag following the topological sort.""" sorted_ops = dags.sort_topologically(dag=dag) for op_id in sorted_ops: op_run_id = runs_by_ops[op_id] op_run = op_runs[op_run_id] ...
[ "def", "set_topological_dag_upstreams", "(", "dag", ",", "ops", ",", "op_runs", ",", "runs_by_ops", ")", ":", "sorted_ops", "=", "dags", ".", "sort_topologically", "(", "dag", "=", "dag", ")", "for", "op_id", "in", "sorted_ops", ":", "op_run_id", "=", "runs_...
Set the upstream runs for the operation runs in the dag following the topological sort.
[ "Set", "the", "upstream", "runs", "for", "the", "operation", "runs", "in", "the", "dag", "following", "the", "topological", "sort", "." ]
python
train
52.428571
reichlab/pymmwr
pymmwr.py
https://github.com/reichlab/pymmwr/blob/98216bd5081998ca63db89003c4ef397fe905755/pymmwr.py#L83-L91
def epiweeks_in_year(year: int) -> int: """ Return number of epiweeks in a year """ if date_to_epiweek(epiweek_to_date(Epiweek(year, 53))).year == year: return 53 else: return 52
[ "def", "epiweeks_in_year", "(", "year", ":", "int", ")", "->", "int", ":", "if", "date_to_epiweek", "(", "epiweek_to_date", "(", "Epiweek", "(", "year", ",", "53", ")", ")", ")", ".", "year", "==", "year", ":", "return", "53", "else", ":", "return", ...
Return number of epiweeks in a year
[ "Return", "number", "of", "epiweeks", "in", "a", "year" ]
python
train
23
DataDog/integrations-core
datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L155-L175
def provider(self, value): """ Validate and set a WMI provider. Default to `ProviderArchitecture.DEFAULT` """ result = None # `None` defaults to `ProviderArchitecture.DEFAULT` defaulted_value = value or ProviderArchitecture.DEFAULT try: parsed_value ...
[ "def", "provider", "(", "self", ",", "value", ")", ":", "result", "=", "None", "# `None` defaults to `ProviderArchitecture.DEFAULT`", "defaulted_value", "=", "value", "or", "ProviderArchitecture", ".", "DEFAULT", "try", ":", "parsed_value", "=", "int", "(", "default...
Validate and set a WMI provider. Default to `ProviderArchitecture.DEFAULT`
[ "Validate", "and", "set", "a", "WMI", "provider", ".", "Default", "to", "ProviderArchitecture", ".", "DEFAULT" ]
python
train
31.952381
KelSolaar/Foundations
foundations/exceptions.py
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/exceptions.py#L220-L247
def format_exception(cls, instance, trcback, context=1): """ | Formats given exception. | The code produce a similar output to :func:`traceback.format_exception` except that it allows frames to be excluded from the stack if the given stack trace frame tag is found in the frame locals and set **True*...
[ "def", "format_exception", "(", "cls", ",", "instance", ",", "trcback", ",", "context", "=", "1", ")", ":", "stack", "=", "extract_stack", "(", "get_inner_most_frame", "(", "trcback", ")", ",", "context", "=", "context", ")", "output", "=", "[", "]", "ou...
| Formats given exception. | The code produce a similar output to :func:`traceback.format_exception` except that it allows frames to be excluded from the stack if the given stack trace frame tag is found in the frame locals and set **True**. :param cls: Exception class. :type cls: object :param...
[ "|", "Formats", "given", "exception", ".", "|", "The", "code", "produce", "a", "similar", "output", "to", ":", "func", ":", "traceback", ".", "format_exception", "except", "that", "it", "allows", "frames", "to", "be", "excluded", "from", "the", "stack", "i...
python
train
40.25
Neurita/boyle
boyle/excel_utils.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/excel_utils.py#L101-L110
def get_sheet_list(xl_path: str) -> List: """Return a list with the name of the sheets in the Excel file in `xl_path`. """ wb = read_xl(xl_path) if hasattr(wb, 'sheetnames'): return wb.sheetnames else: return wb.sheet_names()
[ "def", "get_sheet_list", "(", "xl_path", ":", "str", ")", "->", "List", ":", "wb", "=", "read_xl", "(", "xl_path", ")", "if", "hasattr", "(", "wb", ",", "'sheetnames'", ")", ":", "return", "wb", ".", "sheetnames", "else", ":", "return", "wb", ".", "s...
Return a list with the name of the sheets in the Excel file in `xl_path`.
[ "Return", "a", "list", "with", "the", "name", "of", "the", "sheets", "in", "the", "Excel", "file", "in", "xl_path", "." ]
python
valid
25.7
acutesoftware/AIKIF
aikif/toolbox/zip_tools.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/zip_tools.py#L97-L111
def extract(self, dest_fldr, password=''): """ unzip the file contents to the dest_folder (create if it doesn't exist) and then return the list of files extracted """ #print('extracting to ' + dest_fldr) if self.type == 'ZIP': self._extract_zip(dest_fl...
[ "def", "extract", "(", "self", ",", "dest_fldr", ",", "password", "=", "''", ")", ":", "#print('extracting to ' + dest_fldr)", "if", "self", ".", "type", "==", "'ZIP'", ":", "self", ".", "_extract_zip", "(", "dest_fldr", ",", "password", ")", "elif", "self",...
unzip the file contents to the dest_folder (create if it doesn't exist) and then return the list of files extracted
[ "unzip", "the", "file", "contents", "to", "the", "dest_folder", "(", "create", "if", "it", "doesn", "t", "exist", ")", "and", "then", "return", "the", "list", "of", "files", "extracted" ]
python
train
36.533333
hubo1016/vlcp
vlcp/event/matchtree.py
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/matchtree.py#L67-L81
def insert(self, matcher, obj): ''' Insert a new matcher :param matcher: an EventMatcher :param obj: object to return ''' current = self.subtree(matcher, True) #current.matchers[(obj, matcher)] = None if current._use_dict: cur...
[ "def", "insert", "(", "self", ",", "matcher", ",", "obj", ")", ":", "current", "=", "self", ".", "subtree", "(", "matcher", ",", "True", ")", "#current.matchers[(obj, matcher)] = None", "if", "current", ".", "_use_dict", ":", "current", ".", "matchers_dict", ...
Insert a new matcher :param matcher: an EventMatcher :param obj: object to return
[ "Insert", "a", "new", "matcher", ":", "param", "matcher", ":", "an", "EventMatcher", ":", "param", "obj", ":", "object", "to", "return" ]
python
train
29.4
MechanisM/django-confy
confy/database.py
https://github.com/MechanisM/django-confy/blob/53818db22d1f05623d257aac2abdc625f5972d88/confy/database.py#L64-L70
def config(name='DATABASE_URL', default='sqlite://:memory:'): """Returns configured DATABASE dictionary from DATABASE_URL.""" config = {} s = env(name, default) if s: config = parse_database_url(s) return config
[ "def", "config", "(", "name", "=", "'DATABASE_URL'", ",", "default", "=", "'sqlite://:memory:'", ")", ":", "config", "=", "{", "}", "s", "=", "env", "(", "name", ",", "default", ")", "if", "s", ":", "config", "=", "parse_database_url", "(", "s", ")", ...
Returns configured DATABASE dictionary from DATABASE_URL.
[ "Returns", "configured", "DATABASE", "dictionary", "from", "DATABASE_URL", "." ]
python
train
33.285714
crocs-muni/roca
roca/detect.py
https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L1605-L1624
def process_ssh(self, data, name): """ Processes SSH keys :param data: :param name: :return: """ if data is None or len(data) == 0: return ret = [] try: lines = [x.strip() for x in data.split(b'\n')] for idx, li...
[ "def", "process_ssh", "(", "self", ",", "data", ",", "name", ")", ":", "if", "data", "is", "None", "or", "len", "(", "data", ")", "==", "0", ":", "return", "ret", "=", "[", "]", "try", ":", "lines", "=", "[", "x", ".", "strip", "(", ")", "for...
Processes SSH keys :param data: :param name: :return:
[ "Processes", "SSH", "keys", ":", "param", "data", ":", ":", "param", "name", ":", ":", "return", ":" ]
python
train
28.3
ActivisionGameScience/assertpy
assertpy/assertpy.py
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L697-L705
def is_lower(self): """Asserts that val is non-empty string and all characters are lowercase.""" if not isinstance(self.val, str_types): raise TypeError('val is not a string') if len(self.val) == 0: raise ValueError('val is empty') if self.val != self.val.lower():...
[ "def", "is_lower", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "val", ",", "str_types", ")", ":", "raise", "TypeError", "(", "'val is not a string'", ")", "if", "len", "(", "self", ".", "val", ")", "==", "0", ":", "raise", "Va...
Asserts that val is non-empty string and all characters are lowercase.
[ "Asserts", "that", "val", "is", "non", "-", "empty", "string", "and", "all", "characters", "are", "lowercase", "." ]
python
valid
47.555556
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_dataflash_logger.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_dataflash_logger.py#L139-L182
def idle_send_acks_and_nacks(self): '''Send packets to UAV in idle loop''' max_blocks_to_send = 10 blocks_sent = 0 i=0 now = time.time() while i < len(self.blocks_to_ack_and_nack) and blocks_sent < max_blocks_to_send: # print("ACKLIST: %s" % ([x[1] for x in sel...
[ "def", "idle_send_acks_and_nacks", "(", "self", ")", ":", "max_blocks_to_send", "=", "10", "blocks_sent", "=", "0", "i", "=", "0", "now", "=", "time", ".", "time", "(", ")", "while", "i", "<", "len", "(", "self", ".", "blocks_to_ack_and_nack", ")", "and"...
Send packets to UAV in idle loop
[ "Send", "packets", "to", "UAV", "in", "idle", "loop" ]
python
train
38.568182
tradenity/python-sdk
tradenity/resources/option_value.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/option_value.py#L541-L563
def list_all_option_values(cls, **kwargs): """List OptionValues Return a list of OptionValues This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.list_all_option_values(async=True) >>> res...
[ "def", "list_all_option_values", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_list_all_option_values_with_http_info", "...
List OptionValues Return a list of OptionValues This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.list_all_option_values(async=True) >>> result = thread.get() :param async bool ...
[ "List", "OptionValues" ]
python
train
37.565217
phoebe-project/phoebe2
phoebe/constraints/builtin.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/constraints/builtin.py#L106-L113
def _delta_t_supconj_perpass(period, ecc, per0): """ time shift between superior conjuction and periastron passage """ ups_sc = np.pi/2-per0 E_sc = 2*np.arctan( np.sqrt((1-ecc)/(1+ecc)) * np.tan(ups_sc/2) ) M_sc = E_sc - ecc*np.sin(E_sc) return period*(M_sc/2./np.pi)
[ "def", "_delta_t_supconj_perpass", "(", "period", ",", "ecc", ",", "per0", ")", ":", "ups_sc", "=", "np", ".", "pi", "/", "2", "-", "per0", "E_sc", "=", "2", "*", "np", ".", "arctan", "(", "np", ".", "sqrt", "(", "(", "1", "-", "ecc", ")", "/",...
time shift between superior conjuction and periastron passage
[ "time", "shift", "between", "superior", "conjuction", "and", "periastron", "passage" ]
python
train
36
CyberReboot/vent
vent/helpers/meta.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/helpers/meta.py#L519-L535
def ToolMatches(tools=None, version='HEAD'): """ Get the tools paths and versions that were specified """ matches = [] if tools: for tool in tools: match_version = version if tool[1] != '': match_version = tool[1] match = '' if tool[0]....
[ "def", "ToolMatches", "(", "tools", "=", "None", ",", "version", "=", "'HEAD'", ")", ":", "matches", "=", "[", "]", "if", "tools", ":", "for", "tool", "in", "tools", ":", "match_version", "=", "version", "if", "tool", "[", "1", "]", "!=", "''", ":"...
Get the tools paths and versions that were specified
[ "Get", "the", "tools", "paths", "and", "versions", "that", "were", "specified" ]
python
train
34.235294
LISE-B26/pylabcontrol
build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py
https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/gui/windows_and_widgets/main_window.py#L322-L343
def switch_tab(self): """ takes care of the action that happen when switching between tabs e.g. activates and deactives probes """ current_tab = str(self.tabWidget.tabText(self.tabWidget.currentIndex())) if self.current_script is None: if current_tab == 'Probe...
[ "def", "switch_tab", "(", "self", ")", ":", "current_tab", "=", "str", "(", "self", ".", "tabWidget", ".", "tabText", "(", "self", ".", "tabWidget", ".", "currentIndex", "(", ")", ")", ")", "if", "self", ".", "current_script", "is", "None", ":", "if", ...
takes care of the action that happen when switching between tabs e.g. activates and deactives probes
[ "takes", "care", "of", "the", "action", "that", "happen", "when", "switching", "between", "tabs", "e", ".", "g", ".", "activates", "and", "deactives", "probes" ]
python
train
37.181818
pip-services3-python/pip-services3-commons-python
pip_services3_commons/random/RandomString.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/random/RandomString.py#L47-L63
def distort(value): """ Distorts a string by randomly replacing characters in it. :param value: a string to distort. :return: a distored string. """ value = value.lower() if (RandomBoolean.chance(1, 5)): value = value[0:1].upper() + value[1:] ...
[ "def", "distort", "(", "value", ")", ":", "value", "=", "value", ".", "lower", "(", ")", "if", "(", "RandomBoolean", ".", "chance", "(", "1", ",", "5", ")", ")", ":", "value", "=", "value", "[", "0", ":", "1", "]", ".", "upper", "(", ")", "+"...
Distorts a string by randomly replacing characters in it. :param value: a string to distort. :return: a distored string.
[ "Distorts", "a", "string", "by", "randomly", "replacing", "characters", "in", "it", "." ]
python
train
24.294118
bcbio/bcbio-nextgen
bcbio/variation/validate.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validate.py#L104-L128
def _normalize_cwl_inputs(items): """Extract variation and validation data from CWL input list of batched samples. """ with_validate = {} vrn_files = [] ready_items = [] batch_samples = [] for data in (cwlutils.normalize_missing(utils.to_single_data(d)) for d in items): batch_samples...
[ "def", "_normalize_cwl_inputs", "(", "items", ")", ":", "with_validate", "=", "{", "}", "vrn_files", "=", "[", "]", "ready_items", "=", "[", "]", "batch_samples", "=", "[", "]", "for", "data", "in", "(", "cwlutils", ".", "normalize_missing", "(", "utils", ...
Extract variation and validation data from CWL input list of batched samples.
[ "Extract", "variation", "and", "validation", "data", "from", "CWL", "input", "list", "of", "batched", "samples", "." ]
python
train
41.32
LuminosoInsight/langcodes
langcodes/__init__.py
https://github.com/LuminosoInsight/langcodes/blob/0cedf9ca257ebf7250de5d3a63ec33a7d198db58/langcodes/__init__.py#L730-L817
def find_name(tagtype: str, name: str, language: {str, 'Language', None}=None): """ Find the subtag of a particular `tagtype` that has the given `name`. The default language, "und", will allow matching names in any language, so you can get the code 'fr' by looking up "French", "Français...
[ "def", "find_name", "(", "tagtype", ":", "str", ",", "name", ":", "str", ",", "language", ":", "{", "str", ",", "'Language'", ",", "None", "}", "=", "None", ")", ":", "# No matter what form of language we got, normalize it to a single", "# language subtag", "if", ...
Find the subtag of a particular `tagtype` that has the given `name`. The default language, "und", will allow matching names in any language, so you can get the code 'fr' by looking up "French", "Français", or "francés". Occasionally, names are ambiguous in a way that can be resolved by...
[ "Find", "the", "subtag", "of", "a", "particular", "tagtype", "that", "has", "the", "given", "name", "." ]
python
train
40.113636
ryanolson/couchdb-schematics
couchdb_schematics/document.py
https://github.com/ryanolson/couchdb-schematics/blob/ac87327dd81e8fd5a52afbafcbdfbd27d91e4c40/couchdb_schematics/document.py#L189-L200
def query(cls, database, map_fun, reduce_fun, language='javascript', **options): """Execute a CouchDB temporary view and map the result values back to objects of this mapping. Note that by default, any properties of the document that are not included in the values of the v...
[ "def", "query", "(", "cls", ",", "database", ",", "map_fun", ",", "reduce_fun", ",", "language", "=", "'javascript'", ",", "*", "*", "options", ")", ":", "return", "database", ".", "query", "(", "map_fun", ",", "reduce_fun", "=", "reduce_fun", ",", "lang...
Execute a CouchDB temporary view and map the result values back to objects of this mapping. Note that by default, any properties of the document that are not included in the values of the view will be treated as if they were missing from the document. If you want to load the full docume...
[ "Execute", "a", "CouchDB", "temporary", "view", "and", "map", "the", "result", "values", "back", "to", "objects", "of", "this", "mapping", "." ]
python
train
53
bspaans/python-mingus
mingus/core/keys.py
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/keys.py#L87-L98
def get_key_signature_accidentals(key='C'): """Return the list of accidentals present into the key signature.""" accidentals = get_key_signature(key) res = [] if accidentals < 0: for i in range(-accidentals): res.append('{0}{1}'.format(list(reversed(notes.fifths))[i], 'b')) elif...
[ "def", "get_key_signature_accidentals", "(", "key", "=", "'C'", ")", ":", "accidentals", "=", "get_key_signature", "(", "key", ")", "res", "=", "[", "]", "if", "accidentals", "<", "0", ":", "for", "i", "in", "range", "(", "-", "accidentals", ")", ":", ...
Return the list of accidentals present into the key signature.
[ "Return", "the", "list", "of", "accidentals", "present", "into", "the", "key", "signature", "." ]
python
train
36.666667
marcomusy/vtkplotter
vtkplotter/shapes.py
https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/shapes.py#L704-L719
def Sphere(pos=(0, 0, 0), r=1, c="r", alpha=1, res=24): """Build a sphere at position `pos` of radius `r`. |Sphere| """ ss = vtk.vtkSphereSource() ss.SetRadius(r) ss.SetThetaResolution(2 * res) ss.SetPhiResolution(res) ss.Update() pd = ss.GetOutput() actor = Actor(pd, c, alp...
[ "def", "Sphere", "(", "pos", "=", "(", "0", ",", "0", ",", "0", ")", ",", "r", "=", "1", ",", "c", "=", "\"r\"", ",", "alpha", "=", "1", ",", "res", "=", "24", ")", ":", "ss", "=", "vtk", ".", "vtkSphereSource", "(", ")", "ss", ".", "SetR...
Build a sphere at position `pos` of radius `r`. |Sphere|
[ "Build", "a", "sphere", "at", "position", "pos", "of", "radius", "r", ".", "|Sphere|" ]
python
train
28
zhmcclient/python-zhmcclient
zhmcclient/_notification.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_notification.py#L298-L328
def on_message(self, headers, message): """ Event method that gets called when this listener has received a JMS message (representing an HMC notification). Parameters: headers (dict): JMS message headers, as described for `headers` tuple item returned by the ...
[ "def", "on_message", "(", "self", ",", "headers", ",", "message", ")", ":", "with", "self", ".", "_handover_cond", ":", "# Wait until receiver has processed the previous notification", "while", "len", "(", "self", ".", "_handover_dict", ")", ">", "0", ":", "self",...
Event method that gets called when this listener has received a JMS message (representing an HMC notification). Parameters: headers (dict): JMS message headers, as described for `headers` tuple item returned by the :meth:`~zhmcclient.NotificationReceiver.notifications...
[ "Event", "method", "that", "gets", "called", "when", "this", "listener", "has", "received", "a", "JMS", "message", "(", "representing", "an", "HMC", "notification", ")", "." ]
python
train
40.064516
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L169-L176
def constant_tuples_ordered_by_id(self): """ Returns ------- constants: [(str, Constant)] A list of tuples mapping strings to constants constants ordered by id """ return sorted(list(self.constant_tuple_dict), key=lambda constant_tuple: constant_tuple.constant...
[ "def", "constant_tuples_ordered_by_id", "(", "self", ")", ":", "return", "sorted", "(", "list", "(", "self", ".", "constant_tuple_dict", ")", ",", "key", "=", "lambda", "constant_tuple", ":", "constant_tuple", ".", "constant", ".", "id", ")" ]
Returns ------- constants: [(str, Constant)] A list of tuples mapping strings to constants constants ordered by id
[ "Returns", "-------", "constants", ":", "[", "(", "str", "Constant", ")", "]", "A", "list", "of", "tuples", "mapping", "strings", "to", "constants", "constants", "ordered", "by", "id" ]
python
train
39.625
welbornprod/colr
colr/trans.py
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L421-L423
def rgb2term(r: int, g: int, b: int) -> str: """ Convert an rgb value to a terminal code. """ return hex2term_map[rgb2termhex(r, g, b)]
[ "def", "rgb2term", "(", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "str", ":", "return", "hex2term_map", "[", "rgb2termhex", "(", "r", ",", "g", ",", "b", ")", "]" ]
Convert an rgb value to a terminal code.
[ "Convert", "an", "rgb", "value", "to", "a", "terminal", "code", "." ]
python
train
47
Rapptz/discord.py
discord/ext/commands/bot.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L735-L771
async def get_prefix(self, message): """|coro| Retrieves the prefix the bot is listening to with the message as a context. Parameters ----------- message: :class:`discord.Message` The message context to get the prefix of. Returns -------- ...
[ "async", "def", "get_prefix", "(", "self", ",", "message", ")", ":", "prefix", "=", "ret", "=", "self", ".", "command_prefix", "if", "callable", "(", "prefix", ")", ":", "ret", "=", "await", "discord", ".", "utils", ".", "maybe_coroutine", "(", "prefix",...
|coro| Retrieves the prefix the bot is listening to with the message as a context. Parameters ----------- message: :class:`discord.Message` The message context to get the prefix of. Returns -------- Union[List[:class:`str`], :class:`str`] ...
[ "|coro|" ]
python
train
34.459459
boolangery/py-lua-parser
luaparser/ast.py
https://github.com/boolangery/py-lua-parser/blob/578f2bf75f6f84c4b52c2affba56a4ec569d7ce7/luaparser/ast.py#L18-L23
def get_token_stream(source: str) -> CommonTokenStream: """ Get the antlr token stream. """ lexer = LuaLexer(InputStream(source)) stream = CommonTokenStream(lexer) return stream
[ "def", "get_token_stream", "(", "source", ":", "str", ")", "->", "CommonTokenStream", ":", "lexer", "=", "LuaLexer", "(", "InputStream", "(", "source", ")", ")", "stream", "=", "CommonTokenStream", "(", "lexer", ")", "return", "stream" ]
Get the antlr token stream.
[ "Get", "the", "antlr", "token", "stream", "." ]
python
train
32
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/scrappers/cpress_cz.py
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/cpress_cz.py#L27-L42
def _parse_alt_title(html_chunk): """ Parse title from alternative location if not found where it should be. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: str: Book's title. """ title = html_chunk.find("img", fn=has_param("alt")) i...
[ "def", "_parse_alt_title", "(", "html_chunk", ")", ":", "title", "=", "html_chunk", ".", "find", "(", "\"img\"", ",", "fn", "=", "has_param", "(", "\"alt\"", ")", ")", "if", "not", "title", ":", "raise", "UserWarning", "(", "\"Can't find alternative title sour...
Parse title from alternative location if not found where it should be. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: str: Book's title.
[ "Parse", "title", "from", "alternative", "location", "if", "not", "found", "where", "it", "should", "be", "." ]
python
train
26.625
wandb/client
wandb/vendor/prompt_toolkit/key_binding/bindings/completion.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/key_binding/bindings/completion.py#L137-L161
def _create_more_application(): """ Create an `Application` instance that displays the "--MORE--". """ from prompt_toolkit.shortcuts import create_prompt_application registry = Registry() @registry.add_binding(' ') @registry.add_binding('y') @registry.add_binding('Y') @registry.add_...
[ "def", "_create_more_application", "(", ")", ":", "from", "prompt_toolkit", ".", "shortcuts", "import", "create_prompt_application", "registry", "=", "Registry", "(", ")", "@", "registry", ".", "add_binding", "(", "' '", ")", "@", "registry", ".", "add_binding", ...
Create an `Application` instance that displays the "--MORE--".
[ "Create", "an", "Application", "instance", "that", "displays", "the", "--", "MORE", "--", "." ]
python
train
30.6
rigetti/quantumflow
quantumflow/states.py
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L225-L229
def join_states(*states: State) -> State: """Join two state vectors into a larger qubit state""" vectors = [ket.vec for ket in states] vec = reduce(outer_product, vectors) return State(vec.tensor, vec.qubits)
[ "def", "join_states", "(", "*", "states", ":", "State", ")", "->", "State", ":", "vectors", "=", "[", "ket", ".", "vec", "for", "ket", "in", "states", "]", "vec", "=", "reduce", "(", "outer_product", ",", "vectors", ")", "return", "State", "(", "vec"...
Join two state vectors into a larger qubit state
[ "Join", "two", "state", "vectors", "into", "a", "larger", "qubit", "state" ]
python
train
44
marians/py-daterangestr
daterangestr.py
https://github.com/marians/py-daterangestr/blob/fa5dd78c8fea5f91a85bf732af8a0bc307641134/daterangestr.py#L68-L147
def expand_date_param(param, lower_upper): """ Expands a (possibly) incomplete date string to either the lowest or highest possible contained date and returns datetime.datetime for that string. 0753 (lower) => 0753-01-01 2012 (upper) => 2012-12-31 2012 (lower) => 2012-01-01 201208 (uppe...
[ "def", "expand_date_param", "(", "param", ",", "lower_upper", ")", ":", "year", "=", "datetime", ".", "MINYEAR", "month", "=", "1", "day", "=", "1", "hour", "=", "0", "minute", "=", "0", "second", "=", "0", "if", "lower_upper", "==", "'upper'", ":", ...
Expands a (possibly) incomplete date string to either the lowest or highest possible contained date and returns datetime.datetime for that string. 0753 (lower) => 0753-01-01 2012 (upper) => 2012-12-31 2012 (lower) => 2012-01-01 201208 (upper) => 2012-08-31 etc.
[ "Expands", "a", "(", "possibly", ")", "incomplete", "date", "string", "to", "either", "the", "lowest", "or", "highest", "possible", "contained", "date", "and", "returns", "datetime", ".", "datetime", "for", "that", "string", "." ]
python
test
28.175
flowersteam/explauto
explauto/interest_model/tree.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/interest_model/tree.py#L189-L194
def get_nodes(self): """ Get the list of all nodes. """ return self.fold_up(lambda n, fl, fg: [n] + fl + fg, lambda leaf: [leaf])
[ "def", "get_nodes", "(", "self", ")", ":", "return", "self", ".", "fold_up", "(", "lambda", "n", ",", "fl", ",", "fg", ":", "[", "n", "]", "+", "fl", "+", "fg", ",", "lambda", "leaf", ":", "[", "leaf", "]", ")" ]
Get the list of all nodes.
[ "Get", "the", "list", "of", "all", "nodes", "." ]
python
train
27.5
erdewit/ib_insync
ib_insync/contract.py
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/contract.py#L102-L128
def create(**kwargs): """ Create and a return a specialized contract based on the given secType, or a general Contract if secType is not given. """ secType = kwargs.get('secType', '') cls = { '': Contract, 'STK': Stock, 'OPT': Option, ...
[ "def", "create", "(", "*", "*", "kwargs", ")", ":", "secType", "=", "kwargs", ".", "get", "(", "'secType'", ",", "''", ")", "cls", "=", "{", "''", ":", "Contract", ",", "'STK'", ":", "Stock", ",", "'OPT'", ":", "Option", ",", "'FUT'", ":", "Futur...
Create and a return a specialized contract based on the given secType, or a general Contract if secType is not given.
[ "Create", "and", "a", "return", "a", "specialized", "contract", "based", "on", "the", "given", "secType", "or", "a", "general", "Contract", "if", "secType", "is", "not", "given", "." ]
python
train
29.518519
awslabs/sockeye
sockeye/training.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/training.py#L913-L940
def _cleanup(self, lr_decay_opt_states_reset: str, process_manager: Optional['DecoderProcessManager'] = None, keep_training_state = False): """ Cleans parameter files, training state directory and waits for remaining decoding processes. """ utils.cleanup_params_files(sel...
[ "def", "_cleanup", "(", "self", ",", "lr_decay_opt_states_reset", ":", "str", ",", "process_manager", ":", "Optional", "[", "'DecoderProcessManager'", "]", "=", "None", ",", "keep_training_state", "=", "False", ")", ":", "utils", ".", "cleanup_params_files", "(", ...
Cleans parameter files, training state directory and waits for remaining decoding processes.
[ "Cleans", "parameter", "files", "training", "state", "directory", "and", "waits", "for", "remaining", "decoding", "processes", "." ]
python
train
65.5
rosenbrockc/fortpy
fortpy/scripts/analyze.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L108-L137
def do_help(self, arg): """Sets up the header for the help command that explains the background on how to use the script generally. Help for each command then stands alone in the context of this documentation. Although we could have documented this on the wiki, it is better served when s...
[ "def", "do_help", "(", "self", ",", "arg", ")", ":", "if", "arg", "==", "\"\"", ":", "lines", "=", "[", "(", "\"The fortpy unit testing analysis shell makes it easy to analyze the results \"", "\"of multiple test cases, make plots of trends and tabulate values for use in \"", "...
Sets up the header for the help command that explains the background on how to use the script generally. Help for each command then stands alone in the context of this documentation. Although we could have documented this on the wiki, it is better served when shipped with the shell.
[ "Sets", "up", "the", "header", "for", "the", "help", "command", "that", "explains", "the", "background", "on", "how", "to", "use", "the", "script", "generally", ".", "Help", "for", "each", "command", "then", "stands", "alone", "in", "the", "context", "of",...
python
train
78.866667
orb-framework/orb
orb/core/connection_types/sql/sqlconnection.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/connection_types/sql/sqlconnection.py#L261-L336
def execute(self, command, data=None, returning=True, mapper=dict, writeAccess=False, dryRun=False, locale=None): """ Executes the inputted command into the current \ connection cursor...
[ "def", "execute", "(", "self", ",", "command", ",", "data", "=", "None", ",", "returning", "=", "True", ",", "mapper", "=", "dict", ",", "writeAccess", "=", "False", ",", "dryRun", "=", "False", ",", "locale", "=", "None", ")", ":", "command", "=", ...
Executes the inputted command into the current \ connection cursor. :param command | <str> data | <dict> || None autoCommit | <bool> | commit database changes immediately autoClose | <bool> | closes connections immediately ...
[ "Executes", "the", "inputted", "command", "into", "the", "current", "\\", "connection", "cursor", "." ]
python
train
34.578947
tnkteja/myhelp
virtualEnvironment/lib/python2.7/site-packages/coverage/collector.py
https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/collector.py#L322-L339
def get_line_data(self): """Return the line data collected. Data is { filename: { lineno: None, ...}, ...} """ if self.branch: # If we were measuring branches, then we have to re-build the dict # to show line data. line_data = {} for f, a...
[ "def", "get_line_data", "(", "self", ")", ":", "if", "self", ".", "branch", ":", "# If we were measuring branches, then we have to re-build the dict", "# to show line data.", "line_data", "=", "{", "}", "for", "f", ",", "arcs", "in", "self", ".", "data", ".", "ite...
Return the line data collected. Data is { filename: { lineno: None, ...}, ...}
[ "Return", "the", "line", "data", "collected", "." ]
python
test
30.777778
ECESeniorDesign/lazy_record
lazy_record/query.py
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/query.py#L259-L266
def create(self, **attributes): """ Creates a new record suject to the restructions in the query and with the passed +attributes+. Operates using `build`. """ record = self.build(**attributes) record.save() return record
[ "def", "create", "(", "self", ",", "*", "*", "attributes", ")", ":", "record", "=", "self", ".", "build", "(", "*", "*", "attributes", ")", "record", ".", "save", "(", ")", "return", "record" ]
Creates a new record suject to the restructions in the query and with the passed +attributes+. Operates using `build`.
[ "Creates", "a", "new", "record", "suject", "to", "the", "restructions", "in", "the", "query", "and", "with", "the", "passed", "+", "attributes", "+", ".", "Operates", "using", "build", "." ]
python
train
33.625
gc3-uzh-ch/elasticluster
elasticluster/providers/openstack.py
https://github.com/gc3-uzh-ch/elasticluster/blob/e6345633308c76de13b889417df572815aabe744/elasticluster/providers/openstack.py#L314-L330
def __init_keystone_session(self): """Create and return a Keystone session object.""" api = self._identity_api_version # for readability tried = [] if api in ['3', None]: sess = self.__init_keystone_session_v3(check=(api is None)) tried.append('v3') i...
[ "def", "__init_keystone_session", "(", "self", ")", ":", "api", "=", "self", ".", "_identity_api_version", "# for readability", "tried", "=", "[", "]", "if", "api", "in", "[", "'3'", ",", "None", "]", ":", "sess", "=", "self", ".", "__init_keystone_session_v...
Create and return a Keystone session object.
[ "Create", "and", "return", "a", "Keystone", "session", "object", "." ]
python
train
38.294118
konstantint/PassportEye
passporteye/mrz/scripts.py
https://github.com/konstantint/PassportEye/blob/b32afba0f5dc4eb600c4edc4f49e5d49959c5415/passporteye/mrz/scripts.py#L134-L174
def mrz(): """ Command-line script for extracting MRZ from a given image """ parser = argparse.ArgumentParser(description='Run the MRZ OCR recognition algorithm on the given image.') parser.add_argument('filename') parser.add_argument('--json', action='store_true', help='Produce JSON (rather tha...
[ "def", "mrz", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Run the MRZ OCR recognition algorithm on the given image.'", ")", "parser", ".", "add_argument", "(", "'filename'", ")", "parser", ".", "add_argument", "(", "'-...
Command-line script for extracting MRZ from a given image
[ "Command", "-", "line", "script", "for", "extracting", "MRZ", "from", "a", "given", "image" ]
python
train
53.04878
bcbio/bcbio-nextgen
bcbio/bam/trim.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/trim.py#L192-L214
def _cutadapt_trim(fastq_files, quality_format, adapters, out_files, log_file, data): """Trimming with cutadapt. """ if all([utils.file_exists(x) for x in out_files]): return out_files cmd = _cutadapt_trim_cmd(fastq_files, quality_format, adapters, out_files, data) if len(fastq_files) == 1: ...
[ "def", "_cutadapt_trim", "(", "fastq_files", ",", "quality_format", ",", "adapters", ",", "out_files", ",", "log_file", ",", "data", ")", ":", "if", "all", "(", "[", "utils", ".", "file_exists", "(", "x", ")", "for", "x", "in", "out_files", "]", ")", "...
Trimming with cutadapt.
[ "Trimming", "with", "cutadapt", "." ]
python
train
49.26087
allenai/allennlp
allennlp/models/archival.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/archival.py#L150-L232
def load_archive(archive_file: str, cuda_device: int = -1, overrides: str = "", weights_file: str = None) -> Archive: """ Instantiates an Archive from an archived `tar.gz` file. Parameters ---------- archive_file: ``str`` The archive file t...
[ "def", "load_archive", "(", "archive_file", ":", "str", ",", "cuda_device", ":", "int", "=", "-", "1", ",", "overrides", ":", "str", "=", "\"\"", ",", "weights_file", ":", "str", "=", "None", ")", "->", "Archive", ":", "# redirect to the cache, if necessary"...
Instantiates an Archive from an archived `tar.gz` file. Parameters ---------- archive_file: ``str`` The archive file to load the model from. weights_file: ``str``, optional (default = None) The weights file to use. If unspecified, weights.th in the archive_file will be used. cuda_d...
[ "Instantiates", "an", "Archive", "from", "an", "archived", "tar", ".", "gz", "file", "." ]
python
train
43.421687
google/flatbuffers
python/flatbuffers/table.py
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L56-L64
def VectorLen(self, off): """VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) ret = encode.Get(N.UOffs...
[ "def", "VectorLen", "(", "self", ",", "off", ")", ":", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "off", "+=", "self", ".", "Pos", "off", "+=", "encode", ".", "Get", "(", "N", ".", "UOffsetTFlags", ".", "packer_type"...
VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.
[ "VectorLen", "retrieves", "the", "length", "of", "the", "vector", "whose", "offset", "is", "stored", "at", "off", "in", "this", "object", "." ]
python
train
41
onnx/onnxmltools
onnxutils/onnxconverter_common/optimizer.py
https://github.com/onnx/onnxmltools/blob/d4e4c31990fc2d9fd1f92139f497d360914c9df2/onnxutils/onnxconverter_common/optimizer.py#L76-L81
def in_miso_and_inner(self): """ Test if a node is miso: multiple input and single output """ return len(self.successor) == 1 and self.successor[0] is not None and not self.successor[0].in_or_out and \ len(self.precedence) > 1 and self.precedence[0] is not None and not sel...
[ "def", "in_miso_and_inner", "(", "self", ")", ":", "return", "len", "(", "self", ".", "successor", ")", "==", "1", "and", "self", ".", "successor", "[", "0", "]", "is", "not", "None", "and", "not", "self", ".", "successor", "[", "0", "]", ".", "in_...
Test if a node is miso: multiple input and single output
[ "Test", "if", "a", "node", "is", "miso", ":", "multiple", "input", "and", "single", "output" ]
python
train
56.5
mezz64/pyEmby
pyemby/helpers.py
https://github.com/mezz64/pyEmby/blob/6bb621e4e25bf1b9b0aba2c38b588e68f8816226/pyemby/helpers.py#L10-L22
def deprecated_name(name): """Allow old method names for backwards compatability. """ def decorator(func): """Decorator function.""" def func_wrapper(self): """Wrapper for original function.""" if hasattr(self, name): # Return the old property ...
[ "def", "deprecated_name", "(", "name", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"Decorator function.\"\"\"", "def", "func_wrapper", "(", "self", ")", ":", "\"\"\"Wrapper for original function.\"\"\"", "if", "hasattr", "(", "self", ",", "name", ")...
Allow old method names for backwards compatability.
[ "Allow", "old", "method", "names", "for", "backwards", "compatability", "." ]
python
train
33.769231
noahbenson/pimms
pimms/cmdline.py
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/cmdline.py#L345-L398
def argv_parse(schema, argv, init=None, arg_names=None, arg_abbrevs=None, value_parser=True, defaults=None, filters=None): ''' argv_parse(schema, argv) yields the tuple (unparsed_argv, params) where unparsed_argv is a list subset of argv that contains only those command line arguments that ...
[ "def", "argv_parse", "(", "schema", ",", "argv", ",", "init", "=", "None", ",", "arg_names", "=", "None", ",", "arg_abbrevs", "=", "None", ",", "value_parser", "=", "True", ",", "defaults", "=", "None", ",", "filters", "=", "None", ")", ":", "parser", ...
argv_parse(schema, argv) yields the tuple (unparsed_argv, params) where unparsed_argv is a list subset of argv that contains only those command line arguments that were not understood by the given argument schema and params is a dictionary of parameters as parsed by the given schema. It is equivalent...
[ "argv_parse", "(", "schema", "argv", ")", "yields", "the", "tuple", "(", "unparsed_argv", "params", ")", "where", "unparsed_argv", "is", "a", "list", "subset", "of", "argv", "that", "contains", "only", "those", "command", "line", "arguments", "that", "were", ...
python
train
73.296296
AdvancedClimateSystems/uModbus
umodbus/client/serial/rtu.py
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/client/serial/rtu.py#L205-L225
def send_message(adu, serial_port): """ Send ADU over serial to to server and return parsed response. :param adu: Request ADU. :param sock: Serial port instance. :return: Parsed response from server. """ serial_port.write(adu) serial_port.flush() # Check exception ADU (which is shorter...
[ "def", "send_message", "(", "adu", ",", "serial_port", ")", ":", "serial_port", ".", "write", "(", "adu", ")", "serial_port", ".", "flush", "(", ")", "# Check exception ADU (which is shorter than all other responses) first.", "exception_adu_size", "=", "5", "response_er...
Send ADU over serial to to server and return parsed response. :param adu: Request ADU. :param sock: Serial port instance. :return: Parsed response from server.
[ "Send", "ADU", "over", "serial", "to", "to", "server", "and", "return", "parsed", "response", "." ]
python
train
36.666667
gwastro/pycbc
pycbc/events/eventmgr.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/events/eventmgr.py#L835-L843
def cluster_template_events_single_ifo( self, tcolumn, column, window_size, ifo): """ Cluster the internal events over the named column """ # Just call through to the standard function self.template_events = self.template_event_dict[ifo] self.cluster_template_events(t...
[ "def", "cluster_template_events_single_ifo", "(", "self", ",", "tcolumn", ",", "column", ",", "window_size", ",", "ifo", ")", ":", "# Just call through to the standard function", "self", ".", "template_events", "=", "self", ".", "template_event_dict", "[", "ifo", "]",...
Cluster the internal events over the named column
[ "Cluster", "the", "internal", "events", "over", "the", "named", "column" ]
python
train
48.555556
mieubrisse/wunderpy2
wunderpy2/subtasks_endpoint.py
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L10-L17
def get_task_subtasks(client, task_id, completed=False): ''' Gets subtasks for task with given ID ''' params = { 'task_id' : int(task_id), 'completed' : completed, } response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params) return response....
[ "def", "get_task_subtasks", "(", "client", ",", "task_id", ",", "completed", "=", "False", ")", ":", "params", "=", "{", "'task_id'", ":", "int", "(", "task_id", ")", ",", "'completed'", ":", "completed", ",", "}", "response", "=", "client", ".", "authen...
Gets subtasks for task with given ID
[ "Gets", "subtasks", "for", "task", "with", "given", "ID" ]
python
train
39.875
iotile/coretools
iotilecore/iotile/core/utilities/async_tools/event_loop.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/async_tools/event_loop.py#L647-L656
def _log_future_exception(future, logger): """Log any exception raised by future.""" if not future.done(): return try: future.result() except: #pylint:disable=bare-except;This is a background logging helper logger.warning("Exception in ignored future: %s", future, exc_info=Tru...
[ "def", "_log_future_exception", "(", "future", ",", "logger", ")", ":", "if", "not", "future", ".", "done", "(", ")", ":", "return", "try", ":", "future", ".", "result", "(", ")", "except", ":", "#pylint:disable=bare-except;This is a background logging helper", ...
Log any exception raised by future.
[ "Log", "any", "exception", "raised", "by", "future", "." ]
python
train
31.3
tcalmant/ipopo
pelix/ipopo/waiting.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/waiting.py#L153-L159
def _clear(self): """ Clear all references (called by its bundle activator) """ self.__names.clear() self.__queue.clear() self.__context = None
[ "def", "_clear", "(", "self", ")", ":", "self", ".", "__names", ".", "clear", "(", ")", "self", ".", "__queue", ".", "clear", "(", ")", "self", ".", "__context", "=", "None" ]
Clear all references (called by its bundle activator)
[ "Clear", "all", "references", "(", "called", "by", "its", "bundle", "activator", ")" ]
python
train
26.428571
titusjan/argos
argos/config/groupcti.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/config/groupcti.py#L52-L56
def createEditor(self, delegate, parent, _option): """ Creates a hidden widget so that only the reset button is visible during editing. :type option: QStyleOptionViewItem """ return GroupCtiEditor(self, delegate, parent=parent)
[ "def", "createEditor", "(", "self", ",", "delegate", ",", "parent", ",", "_option", ")", ":", "return", "GroupCtiEditor", "(", "self", ",", "delegate", ",", "parent", "=", "parent", ")" ]
Creates a hidden widget so that only the reset button is visible during editing. :type option: QStyleOptionViewItem
[ "Creates", "a", "hidden", "widget", "so", "that", "only", "the", "reset", "button", "is", "visible", "during", "editing", ".", ":", "type", "option", ":", "QStyleOptionViewItem" ]
python
train
51.8
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/configuration_db/sip_config_db/_config_db_redis.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_config_db_redis.py#L264-L278
def set_hash_value(self, key, field, value, pipeline=False): """Set the value of field in a hash stored at key. Args: key (str): key (name) of the hash field (str): Field within the hash to set value: Value to set pipeline (bool): True, start a transactio...
[ "def", "set_hash_value", "(", "self", ",", "key", ",", "field", ",", "value", ",", "pipeline", "=", "False", ")", ":", "# FIXME(BMo): new name for this function -> save_dict_value ?", "if", "pipeline", ":", "self", ".", "_pipeline", ".", "hset", "(", "key", ",",...
Set the value of field in a hash stored at key. Args: key (str): key (name) of the hash field (str): Field within the hash to set value: Value to set pipeline (bool): True, start a transaction block. Default false.
[ "Set", "the", "value", "of", "field", "in", "a", "hash", "stored", "at", "key", "." ]
python
train
36.866667
googledatalab/pydatalab
datalab/bigquery/commands/_bigquery.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/commands/_bigquery.py#L725-L767
def _load_cell(args, schema): """Implements the BigQuery load magic used to load data from GCS to a table. The supported syntax is: %bigquery load -S|--source <source> -D|--destination <table> <other_args> Args: args: the arguments following '%bigquery load'. schema: a JSON schema for the dest...
[ "def", "_load_cell", "(", "args", ",", "schema", ")", ":", "name", "=", "args", "[", "'destination'", "]", "table", "=", "_get_table", "(", "name", ")", "if", "not", "table", ":", "table", "=", "datalab", ".", "bigquery", ".", "Table", "(", "name", "...
Implements the BigQuery load magic used to load data from GCS to a table. The supported syntax is: %bigquery load -S|--source <source> -D|--destination <table> <other_args> Args: args: the arguments following '%bigquery load'. schema: a JSON schema for the destination table. Returns: A mes...
[ "Implements", "the", "BigQuery", "load", "magic", "used", "to", "load", "data", "from", "GCS", "to", "a", "table", "." ]
python
train
41.72093
boriel/zxbasic
zxbparser.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L2015-L2026
def p_poke2(p): """ statement : POKE numbertype expr COMMA expr | POKE LP numbertype expr COMMA expr RP """ i = 2 if isinstance(p[2], Symbol) or p[2] is None else 3 if p[i + 1] is None or p[i + 3] is None: p[0] = None return p[0] = make_sentence('POKE', ...
[ "def", "p_poke2", "(", "p", ")", ":", "i", "=", "2", "if", "isinstance", "(", "p", "[", "2", "]", ",", "Symbol", ")", "or", "p", "[", "2", "]", "is", "None", "else", "3", "if", "p", "[", "i", "+", "1", "]", "is", "None", "or", "p", "[", ...
statement : POKE numbertype expr COMMA expr | POKE LP numbertype expr COMMA expr RP
[ "statement", ":", "POKE", "numbertype", "expr", "COMMA", "expr", "|", "POKE", "LP", "numbertype", "expr", "COMMA", "expr", "RP" ]
python
train
39.833333
pycontribs/pyrax
pyrax/object_storage.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/object_storage.py#L3299-L3304
def run(self): """Starts the uploading thread.""" root_path, folder_name = os.path.split(self.root_folder) self.root_folder = os.path.join(root_path, folder_name) for dirname, _, fnames in os.walk(self.root_folder): self.upload_files_in_folder(dirname, fnames)
[ "def", "run", "(", "self", ")", ":", "root_path", ",", "folder_name", "=", "os", ".", "path", ".", "split", "(", "self", ".", "root_folder", ")", "self", ".", "root_folder", "=", "os", ".", "path", ".", "join", "(", "root_path", ",", "folder_name", "...
Starts the uploading thread.
[ "Starts", "the", "uploading", "thread", "." ]
python
train
49.833333
core/uricore
uricore/wkz_urls.py
https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_urls.py#L116-L160
def iri_to_uri(iri, charset='utf-8'): r"""Converts any unicode based IRI to an acceptable ASCII URI. Werkzeug always uses utf-8 URLs internally because this is what browsers and HTTP do as well. In some places where it accepts an URL it also accepts a unicode IRI and converts it into a URI. Examp...
[ "def", "iri_to_uri", "(", "iri", ",", "charset", "=", "'utf-8'", ")", ":", "iri", "=", "unicode", "(", "iri", ")", "scheme", ",", "auth", ",", "hostname", ",", "port", ",", "path", ",", "query", ",", "fragment", "=", "_uri_split", "(", "iri", ")", ...
r"""Converts any unicode based IRI to an acceptable ASCII URI. Werkzeug always uses utf-8 URLs internally because this is what browsers and HTTP do as well. In some places where it accepts an URL it also accepts a unicode IRI and converts it into a URI. Examples for IRI versus URI: >>> iri_to_ur...
[ "r", "Converts", "any", "unicode", "based", "IRI", "to", "an", "acceptable", "ASCII", "URI", ".", "Werkzeug", "always", "uses", "utf", "-", "8", "URLs", "internally", "because", "this", "is", "what", "browsers", "and", "HTTP", "do", "as", "well", ".", "I...
python
train
33.266667
saltstack/salt
salt/modules/mount.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1408-L1444
def swapon(name, priority=None): ''' Activate a swap disk .. versionchanged:: 2016.3.2 CLI Example: .. code-block:: bash salt '*' mount.swapon /root/swapfile ''' ret = {} on_ = swaps() if name in on_: ret['stats'] = on_[name] ret['new'] = False ret...
[ "def", "swapon", "(", "name", ",", "priority", "=", "None", ")", ":", "ret", "=", "{", "}", "on_", "=", "swaps", "(", ")", "if", "name", "in", "on_", ":", "ret", "[", "'stats'", "]", "=", "on_", "[", "name", "]", "ret", "[", "'new'", "]", "="...
Activate a swap disk .. versionchanged:: 2016.3.2 CLI Example: .. code-block:: bash salt '*' mount.swapon /root/swapfile
[ "Activate", "a", "swap", "disk" ]
python
train
22.594595
PmagPy/PmagPy
pmagpy/validate_upload3.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L228-L241
def requiredOneInGroup(col_name, group, dm, df, *args): """ If col_name is present in df, the group validation is satisfied. If not, it still may be satisfied, but not by THIS col_name. If col_name is missing, return col_name, else return None. Later, we will validate to see if there is at least one...
[ "def", "requiredOneInGroup", "(", "col_name", ",", "group", ",", "dm", ",", "df", ",", "*", "args", ")", ":", "if", "col_name", "in", "df", ".", "columns", ":", "# if the column name is present, return nothing", "return", "None", "else", ":", "# if the column na...
If col_name is present in df, the group validation is satisfied. If not, it still may be satisfied, but not by THIS col_name. If col_name is missing, return col_name, else return None. Later, we will validate to see if there is at least one None (non-missing) value for this group.
[ "If", "col_name", "is", "present", "in", "df", "the", "group", "validation", "is", "satisfied", ".", "If", "not", "it", "still", "may", "be", "satisfied", "but", "not", "by", "THIS", "col_name", ".", "If", "col_name", "is", "missing", "return", "col_name",...
python
train
40.071429
senaite/senaite.core
bika/lims/browser/fields/historyawarereferencefield.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/fields/historyawarereferencefield.py#L126-L139
def unlink_version(self, source, target): """Unlink the current version of the target from the source """ if not hasattr(source, REFERENCE_VERSIONS): return target_uid = api.get_uid(target) if target_uid in source.reference_versions[target_uid]: # delete t...
[ "def", "unlink_version", "(", "self", ",", "source", ",", "target", ")", ":", "if", "not", "hasattr", "(", "source", ",", "REFERENCE_VERSIONS", ")", ":", "return", "target_uid", "=", "api", ".", "get_uid", "(", "target", ")", "if", "target_uid", "in", "s...
Unlink the current version of the target from the source
[ "Unlink", "the", "current", "version", "of", "the", "target", "from", "the", "source" ]
python
train
43.357143
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlist.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlist.py#L1517-L1539
def update(self, iterable): """Update the list by adding all elements from *iterable*.""" _maxes, _lists, _keys = self._maxes, self._lists, self._keys values = sorted(iterable, key=self._key) if _maxes: if len(values) * 4 >= self._len: values.extend(chain.fro...
[ "def", "update", "(", "self", ",", "iterable", ")", ":", "_maxes", ",", "_lists", ",", "_keys", "=", "self", ".", "_maxes", ",", "self", ".", "_lists", ",", "self", ".", "_keys", "values", "=", "sorted", "(", "iterable", ",", "key", "=", "self", "....
Update the list by adding all elements from *iterable*.
[ "Update", "the", "list", "by", "adding", "all", "elements", "from", "*", "iterable", "*", "." ]
python
train
37.73913
sdispater/orator
orator/orm/factory.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/factory.py#L229-L251
def build(self, klass, name="default", amount=None): """ Makes a factory builder with a specified amount. :param klass: The class :type klass: class :param name: The type :type name: str :param amount: The number of models to create :type amount: int ...
[ "def", "build", "(", "self", ",", "klass", ",", "name", "=", "\"default\"", ",", "amount", "=", "None", ")", ":", "if", "amount", "is", "None", ":", "if", "isinstance", "(", "name", ",", "int", ")", ":", "amount", "=", "name", "name", "=", "\"defau...
Makes a factory builder with a specified amount. :param klass: The class :type klass: class :param name: The type :type name: str :param amount: The number of models to create :type amount: int :return: mixed
[ "Makes", "a", "factory", "builder", "with", "a", "specified", "amount", "." ]
python
train
24.130435
PMEAL/porespy
porespy/tools/__funcs__.py
https://github.com/PMEAL/porespy/blob/1e13875b56787d8f5b7ffdabce8c4342c33ba9f8/porespy/tools/__funcs__.py#L769-L807
def functions_to_table(mod, colwidth=[27, 48]): r""" Given a module of functions, returns a ReST formatted text string that outputs a table when printed. Parameters ---------- mod : module The module containing the functions to be included in the table, such as 'porespy.filters'...
[ "def", "functions_to_table", "(", "mod", ",", "colwidth", "=", "[", "27", ",", "48", "]", ")", ":", "temp", "=", "mod", ".", "__dir__", "(", ")", "funcs", "=", "[", "i", "for", "i", "in", "temp", "if", "not", "i", "[", "0", "]", ".", "startswit...
r""" Given a module of functions, returns a ReST formatted text string that outputs a table when printed. Parameters ---------- mod : module The module containing the functions to be included in the table, such as 'porespy.filters'. colwidths : list of ints The width of...
[ "r", "Given", "a", "module", "of", "functions", "returns", "a", "ReST", "formatted", "text", "string", "that", "outputs", "a", "table", "when", "printed", "." ]
python
train
36.128205
Metatab/metapack
metapack/package/core.py
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L587-L601
def create_nv_link(self): """After a save(), write a link to the saved file using a non-versioned name""" from os.path import abspath, islink from os import unlink, symlink nv_name = self.doc.as_version(None) from_path = abspath(self._last_write_path or self.package_path.path)...
[ "def", "create_nv_link", "(", "self", ")", ":", "from", "os", ".", "path", "import", "abspath", ",", "islink", "from", "os", "import", "unlink", ",", "symlink", "nv_name", "=", "self", ".", "doc", ".", "as_version", "(", "None", ")", "from_path", "=", ...
After a save(), write a link to the saved file using a non-versioned name
[ "After", "a", "save", "()", "write", "a", "link", "to", "the", "saved", "file", "using", "a", "non", "-", "versioned", "name" ]
python
train
31.466667
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/_helpers.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/_helpers.py#L68-L71
def _bytes_from_json(value, field): """Base64-decode value""" if _not_null(value, field): return base64.standard_b64decode(_to_bytes(value))
[ "def", "_bytes_from_json", "(", "value", ",", "field", ")", ":", "if", "_not_null", "(", "value", ",", "field", ")", ":", "return", "base64", ".", "standard_b64decode", "(", "_to_bytes", "(", "value", ")", ")" ]
Base64-decode value
[ "Base64", "-", "decode", "value" ]
python
train
38.25
Bogdanp/dramatiq
dramatiq/message.py
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/message.py#L103-L109
def copy(self, **attributes): """Create a copy of this message. """ updated_options = attributes.pop("options", {}) options = self.options.copy() options.update(updated_options) return self._replace(**attributes, options=options)
[ "def", "copy", "(", "self", ",", "*", "*", "attributes", ")", ":", "updated_options", "=", "attributes", ".", "pop", "(", "\"options\"", ",", "{", "}", ")", "options", "=", "self", ".", "options", ".", "copy", "(", ")", "options", ".", "update", "(",...
Create a copy of this message.
[ "Create", "a", "copy", "of", "this", "message", "." ]
python
train
38.714286
dmwm/DBS
Server/Python/src/dbs/web/DBSReaderModel.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSReaderModel.py#L225-L248
def listPrimaryDatasets(self, primary_ds_name="", primary_ds_type=""): """ API to list primary datasets :param primary_ds_type: List primary datasets with primary dataset type (Optional) :type primary_ds_type: str :param primary_ds_name: List that primary dataset (Optional) ...
[ "def", "listPrimaryDatasets", "(", "self", ",", "primary_ds_name", "=", "\"\"", ",", "primary_ds_type", "=", "\"\"", ")", ":", "primary_ds_name", "=", "primary_ds_name", ".", "replace", "(", "\"*\"", ",", "\"%\"", ")", "primary_ds_type", "=", "primary_ds_type", ...
API to list primary datasets :param primary_ds_type: List primary datasets with primary dataset type (Optional) :type primary_ds_type: str :param primary_ds_name: List that primary dataset (Optional) :type primary_ds_name: str :returns: List of dictionaries containing the follow...
[ "API", "to", "list", "primary", "datasets" ]
python
train
54.708333
the01/python-flotils
flotils/loadable.py
https://github.com/the01/python-flotils/blob/5954712776bb590107e5b2f4362d010bf74f77a1/flotils/loadable.py#L386-L403
def join_path_prefix(path, pre_path=None): """ If path set and not absolute, append it to pre path (if used) :param path: path to append :type path: str | None :param pre_path: Base path to append to (default: None) :type pre_path: None | str :return: Path or appended path :rtype: str |...
[ "def", "join_path_prefix", "(", "path", ",", "pre_path", "=", "None", ")", ":", "if", "not", "path", ":", "return", "path", "if", "pre_path", "and", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "return", "os", ".", "path", ".", "j...
If path set and not absolute, append it to pre path (if used) :param path: path to append :type path: str | None :param pre_path: Base path to append to (default: None) :type pre_path: None | str :return: Path or appended path :rtype: str | None
[ "If", "path", "set", "and", "not", "absolute", "append", "it", "to", "pre", "path", "(", "if", "used", ")" ]
python
train
25.555556
nerdvegas/rez
src/rez/vendor/memcache/memcache.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/memcache/memcache.py#L588-L615
def cas(self, key, val, time=0, min_compress_len=0): '''Sets a key to a given value in the memcache if it hasn't been altered since last fetched. (See L{gets}). The C{key} can optionally be an tuple, with the first element being the server hash value and the second being the key. ...
[ "def", "cas", "(", "self", ",", "key", ",", "val", ",", "time", "=", "0", ",", "min_compress_len", "=", "0", ")", ":", "return", "self", ".", "_set", "(", "\"cas\"", ",", "key", ",", "val", ",", "time", ",", "min_compress_len", ")" ]
Sets a key to a given value in the memcache if it hasn't been altered since last fetched. (See L{gets}). The C{key} can optionally be an tuple, with the first element being the server hash value and the second being the key. If you want to avoid making this module calculate a hash value...
[ "Sets", "a", "key", "to", "a", "given", "value", "in", "the", "memcache", "if", "it", "hasn", "t", "been", "altered", "since", "last", "fetched", ".", "(", "See", "L", "{", "gets", "}", ")", "." ]
python
train
54.857143
fmfn/BayesianOptimization
bayes_opt/target_space.py
https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L169-L196
def probe(self, params): """ Evaulates a single point x, to obtain the value y and then records them as observations. Notes ----- If x has been previously seen returns a cached value of y. Parameters ---------- x : ndarray a single po...
[ "def", "probe", "(", "self", ",", "params", ")", ":", "x", "=", "self", ".", "_as_array", "(", "params", ")", "try", ":", "target", "=", "self", ".", "_cache", "[", "_hashable", "(", "x", ")", "]", "except", "KeyError", ":", "params", "=", "dict", ...
Evaulates a single point x, to obtain the value y and then records them as observations. Notes ----- If x has been previously seen returns a cached value of y. Parameters ---------- x : ndarray a single point, with len(x) == self.dim Returns...
[ "Evaulates", "a", "single", "point", "x", "to", "obtain", "the", "value", "y", "and", "then", "records", "them", "as", "observations", "." ]
python
train
24.75
openstax/cnx-epub
cnxepub/utils.py
https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/utils.py#L19-L51
def squash_xml_to_text(elm, remove_namespaces=False): """Squash the given XML element (as `elm`) to a text containing XML. The outer most element/tag will be removed, but inner elements will remain. If `remove_namespaces` is specified, XML namespace declarations will be removed from the text. :para...
[ "def", "squash_xml_to_text", "(", "elm", ",", "remove_namespaces", "=", "False", ")", ":", "leading_text", "=", "elm", ".", "text", "and", "elm", ".", "text", "or", "''", "result", "=", "[", "leading_text", "]", "for", "child", "in", "elm", ".", "getchil...
Squash the given XML element (as `elm`) to a text containing XML. The outer most element/tag will be removed, but inner elements will remain. If `remove_namespaces` is specified, XML namespace declarations will be removed from the text. :param elm: XML element :type elm: :class:`xml.etree.ElementTr...
[ "Squash", "the", "given", "XML", "element", "(", "as", "elm", ")", "to", "a", "text", "containing", "XML", ".", "The", "outer", "most", "element", "/", "tag", "will", "be", "removed", "but", "inner", "elements", "will", "remain", ".", "If", "remove_names...
python
train
39.666667
mitsei/dlkit
dlkit/json_/assessment/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1945-L1966
def set_duration(self, duration): """Sets the assessment duration. arg: duration (osid.calendaring.Duration): assessment duration raise: InvalidArgument - ``duration`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory ...
[ "def", "set_duration", "(", "self", ",", "duration", ")", ":", "# Implemented from template for osid.assessment.AssessmentOfferedForm.set_duration_template", "if", "self", ".", "get_duration_metadata", "(", ")", ".", "is_read_only", "(", ")", ":", "raise", "errors", ".", ...
Sets the assessment duration. arg: duration (osid.calendaring.Duration): assessment duration raise: InvalidArgument - ``duration`` is invalid raise: NoAccess - ``Metadata.isReadOnly()`` is ``true`` *compliance: mandatory -- This method must be implemented.*
[ "Sets", "the", "assessment", "duration", "." ]
python
train
40.272727
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vcs.py#L338-L351
def show_vcs_output_vcs_nodes_vcs_node_info_node_switch_mac(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") show_vcs = ET.Element("show_vcs") config = show_vcs output = ET.SubElement(show_vcs, "output") vcs_nodes = ET.SubElement(output, "...
[ "def", "show_vcs_output_vcs_nodes_vcs_node_info_node_switch_mac", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "show_vcs", "=", "ET", ".", "Element", "(", "\"show_vcs\"", ")", "config", "=", "show...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
43.571429
ttsteiger/cryptocompy
cryptocompy/coin.py
https://github.com/ttsteiger/cryptocompy/blob/b0514079202587a5bfb3a4f2c871196315b9302e/cryptocompy/coin.py#L56-L101
def get_coin_snapshot(fsym, tsym): """ Get blockchain information, aggregated data as well as data for the individual exchanges available for the specified currency pair. Args: fsym: FROM symbol. tsym: TO symbol. Returns: The function returns a dictionairy containing blockain as well as trading inform...
[ "def", "get_coin_snapshot", "(", "fsym", ",", "tsym", ")", ":", "# load data", "url", "=", "build_url", "(", "'coinsnapshot'", ",", "fsym", "=", "fsym", ",", "tsym", "=", "tsym", ")", "data", "=", "load_data", "(", "url", ")", "[", "'Data'", "]", "retu...
Get blockchain information, aggregated data as well as data for the individual exchanges available for the specified currency pair. Args: fsym: FROM symbol. tsym: TO symbol. Returns: The function returns a dictionairy containing blockain as well as trading information from the different exchanges were t...
[ "Get", "blockchain", "information", "aggregated", "data", "as", "well", "as", "data", "for", "the", "individual", "exchanges", "available", "for", "the", "specified", "currency", "pair", "." ]
python
train
24.782609
jochym/Elastic
parcalc/parcalc.py
https://github.com/jochym/Elastic/blob/8daae37d0c48aab8dfb1de2839dab02314817f95/parcalc/parcalc.py#L79-L94
def work_dir(path): ''' Context menager for executing commands in some working directory. Returns to the previous wd when finished. Usage: >>> with work_dir(path): ... subprocess.call('git status') ''' starting_directory = os.getcwd() try: os.chdir(path) yield ...
[ "def", "work_dir", "(", "path", ")", ":", "starting_directory", "=", "os", ".", "getcwd", "(", ")", "try", ":", "os", ".", "chdir", "(", "path", ")", "yield", "finally", ":", "os", ".", "chdir", "(", "starting_directory", ")" ]
Context menager for executing commands in some working directory. Returns to the previous wd when finished. Usage: >>> with work_dir(path): ... subprocess.call('git status')
[ "Context", "menager", "for", "executing", "commands", "in", "some", "working", "directory", ".", "Returns", "to", "the", "previous", "wd", "when", "finished", "." ]
python
train
21.9375
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/shellapp.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/shellapp.py#L297-L311
def _run_startup_files(self): """Run files from profile startup directory""" startup_dir = self.profile_dir.startup_dir startup_files = glob.glob(os.path.join(startup_dir, '*.py')) startup_files += glob.glob(os.path.join(startup_dir, '*.ipy')) if not startup_files: re...
[ "def", "_run_startup_files", "(", "self", ")", ":", "startup_dir", "=", "self", ".", "profile_dir", ".", "startup_dir", "startup_files", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "startup_dir", ",", "'*.py'", ")", ")", "startup_fi...
Run files from profile startup directory
[ "Run", "files", "from", "profile", "startup", "directory" ]
python
test
41.066667
manns/pyspread
pyspread/src/lib/vlc.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L6061-L6072
def libvlc_audio_output_set(p_mi, psz_name): '''Selects an audio output module. @note: Any change will take be effect only after playback is stopped and restarted. Audio output cannot be changed while playing. @param p_mi: media player. @param psz_name: name of audio output, use psz_name of See L{Au...
[ "def", "libvlc_audio_output_set", "(", "p_mi", ",", "psz_name", ")", ":", "f", "=", "_Cfunctions", ".", "get", "(", "'libvlc_audio_output_set'", ",", "None", ")", "or", "_Cfunction", "(", "'libvlc_audio_output_set'", ",", "(", "(", "1", ",", ")", ",", "(", ...
Selects an audio output module. @note: Any change will take be effect only after playback is stopped and restarted. Audio output cannot be changed while playing. @param p_mi: media player. @param psz_name: name of audio output, use psz_name of See L{AudioOutput}. @return: 0 if function succeded, -1 ...
[ "Selects", "an", "audio", "output", "module", "." ]
python
train
50
Dallinger/Dallinger
dallinger/deployment.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L570-L579
def notify(self, message): """Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete. """ if self.complete: return HerokuLocalWrappe...
[ "def", "notify", "(", "self", ",", "message", ")", ":", "if", "self", ".", "complete", ":", "return", "HerokuLocalWrapper", ".", "MONITOR_STOP", "return", "super", "(", "DebugDeployment", ",", "self", ")", ".", "notify", "(", "message", ")" ]
Monitor output from heroku process. This overrides the base class's `notify` to make sure that we stop if the status-monitoring thread has determined that the experiment is complete.
[ "Monitor", "output", "from", "heroku", "process", "." ]
python
train
38.5
lpantano/seqcluster
seqcluster/libs/thinkbayes.py
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/thinkbayes.py#L508-L525
def Random(self): """Chooses a random element from this PMF. Returns: float value from the Pmf """ if len(self.d) == 0: raise ValueError('Pmf contains no values.') target = random.random() total = 0.0 for x, p in self.d.iteritems(): ...
[ "def", "Random", "(", "self", ")", ":", "if", "len", "(", "self", ".", "d", ")", "==", "0", ":", "raise", "ValueError", "(", "'Pmf contains no values.'", ")", "target", "=", "random", ".", "random", "(", ")", "total", "=", "0.0", "for", "x", ",", "...
Chooses a random element from this PMF. Returns: float value from the Pmf
[ "Chooses", "a", "random", "element", "from", "this", "PMF", "." ]
python
train
23.944444