repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
google/dotty
efilter/parsers/common/tokenizer.py
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/tokenizer.py#L268-L305
def _next_pattern(self): """Parses the next pattern by matching each in turn.""" current_state = self.state_stack[-1] position = self._position for pattern in self.patterns: if current_state not in pattern.states: continue m = pattern.regex.match(...
[ "def", "_next_pattern", "(", "self", ")", ":", "current_state", "=", "self", ".", "state_stack", "[", "-", "1", "]", "position", "=", "self", ".", "_position", "for", "pattern", "in", "self", ".", "patterns", ":", "if", "current_state", "not", "in", "pat...
Parses the next pattern by matching each in turn.
[ "Parses", "the", "next", "pattern", "by", "matching", "each", "in", "turn", "." ]
python
train
mozilla/configman
configman/config_manager.py
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L451-L472
def dump_conf(self, config_pathname=None): """write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target conf...
[ "def", "dump_conf", "(", "self", ",", "config_pathname", "=", "None", ")", ":", "if", "not", "config_pathname", ":", "config_pathname", "=", "self", ".", "_get_option", "(", "'admin.dump_conf'", ")", ".", "value", "opener", "=", "functools", ".", "partial", ...
write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target config file.
[ "write", "a", "config", "file", "to", "the", "pathname", "specified", "in", "the", "parameter", ".", "The", "file", "extention", "determines", "the", "type", "of", "file", "written", "and", "must", "match", "a", "registered", "type", "." ]
python
train
ArchiveTeam/wpull
wpull/application/tasks/writer.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/application/tasks/writer.py#L21-L93
def _build_file_writer(cls, session: AppSession): '''Create the File Writer. Returns: FileWriter: An instance of :class:`.writer.BaseFileWriter`. ''' args = session.args if args.delete_after: return session.factory.new('FileWriter') # is a NullWriter ...
[ "def", "_build_file_writer", "(", "cls", ",", "session", ":", "AppSession", ")", ":", "args", "=", "session", ".", "args", "if", "args", ".", "delete_after", ":", "return", "session", ".", "factory", ".", "new", "(", "'FileWriter'", ")", "# is a NullWriter",...
Create the File Writer. Returns: FileWriter: An instance of :class:`.writer.BaseFileWriter`.
[ "Create", "the", "File", "Writer", "." ]
python
train
titusjan/argos
argos/utils/cls.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/utils/cls.py#L245-L256
def is_text(var, allow_none=False): """ Returns True if var is a unicode text Result py-2 py-3 ----------------- ----- ----- b'bytes literal' False False 'string literal' False True u'unicode literal' True True Also works with the corresponding nu...
[ "def", "is_text", "(", "var", ",", "allow_none", "=", "False", ")", ":", "return", "isinstance", "(", "var", ",", "six", ".", "text_type", ")", "or", "(", "var", "is", "None", "and", "allow_none", ")" ]
Returns True if var is a unicode text Result py-2 py-3 ----------------- ----- ----- b'bytes literal' False False 'string literal' False True u'unicode literal' True True Also works with the corresponding numpy types.
[ "Returns", "True", "if", "var", "is", "a", "unicode", "text" ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/qt/console/frontend_widget.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/frontend_widget.py#L36-L59
def highlightBlock(self, string): """ Highlight a block of text. Reimplemented to highlight selectively. """ if not self.highlighting_on: return # The input to this function is a unicode string that may contain # paragraph break characters, non-breaking spaces, etc. ...
[ "def", "highlightBlock", "(", "self", ",", "string", ")", ":", "if", "not", "self", ".", "highlighting_on", ":", "return", "# The input to this function is a unicode string that may contain", "# paragraph break characters, non-breaking spaces, etc. Here we acquire", "# the string a...
Highlight a block of text. Reimplemented to highlight selectively.
[ "Highlight", "a", "block", "of", "text", ".", "Reimplemented", "to", "highlight", "selectively", "." ]
python
test
PyCQA/pylint
pylint/pyreverse/writer.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L112-L117
def set_printer(self, file_name, basename): """initialize DotWriter and add options for layout. """ layout = dict(rankdir="BT") self.printer = DotBackend(basename, additional_param=layout) self.file_name = file_name
[ "def", "set_printer", "(", "self", ",", "file_name", ",", "basename", ")", ":", "layout", "=", "dict", "(", "rankdir", "=", "\"BT\"", ")", "self", ".", "printer", "=", "DotBackend", "(", "basename", ",", "additional_param", "=", "layout", ")", "self", "....
initialize DotWriter and add options for layout.
[ "initialize", "DotWriter", "and", "add", "options", "for", "layout", "." ]
python
test
hendrix/hendrix
hendrix/deploy/base.py
https://github.com/hendrix/hendrix/blob/175af011a7e5822b772bfec0e11a46466bb8688d/hendrix/deploy/base.py#L99-L121
def getConf(cls, settings, options): "updates the options dict to use config options in the settings module" ports = ['http_port', 'https_port', 'cache_port'] for port_name in ports: port = getattr(settings, port_name.upper(), None) # only use the settings ports if the de...
[ "def", "getConf", "(", "cls", ",", "settings", ",", "options", ")", ":", "ports", "=", "[", "'http_port'", ",", "'https_port'", ",", "'cache_port'", "]", "for", "port_name", "in", "ports", ":", "port", "=", "getattr", "(", "settings", ",", "port_name", "...
updates the options dict to use config options in the settings module
[ "updates", "the", "options", "dict", "to", "use", "config", "options", "in", "the", "settings", "module" ]
python
train
ska-sa/katcp-python
katcp/resource_client.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1381-L1390
def set_ioloop(self, ioloop=None): """Set the tornado ioloop to use Defaults to tornado.ioloop.IOLoop.current() if set_ioloop() is not called or if ioloop=None. Must be called before start() """ ioloop = ioloop or tornado.ioloop.IOLoop.current() self.ioloop = ioloop ...
[ "def", "set_ioloop", "(", "self", ",", "ioloop", "=", "None", ")", ":", "ioloop", "=", "ioloop", "or", "tornado", ".", "ioloop", ".", "IOLoop", ".", "current", "(", ")", "self", ".", "ioloop", "=", "ioloop", "for", "res", "in", "dict", ".", "values",...
Set the tornado ioloop to use Defaults to tornado.ioloop.IOLoop.current() if set_ioloop() is not called or if ioloop=None. Must be called before start()
[ "Set", "the", "tornado", "ioloop", "to", "use" ]
python
train
zhanglab/psamm
psamm/commands/primarypairs.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/primarypairs.py#L162-L171
def _combine_transfers(self, result): """Combine multiple pair transfers into one.""" transfers = {} for reaction_id, c1, c2, form in result: key = reaction_id, c1, c2 combined_form = transfers.setdefault(key, Formula()) transfers[key] = combined_form | form ...
[ "def", "_combine_transfers", "(", "self", ",", "result", ")", ":", "transfers", "=", "{", "}", "for", "reaction_id", ",", "c1", ",", "c2", ",", "form", "in", "result", ":", "key", "=", "reaction_id", ",", "c1", ",", "c2", "combined_form", "=", "transfe...
Combine multiple pair transfers into one.
[ "Combine", "multiple", "pair", "transfers", "into", "one", "." ]
python
train
awslabs/aws-sam-cli
samcli/lib/logs/formatter.py
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/lib/logs/formatter.py#L114-L121
def _pretty_print_event(event, colored): """ Basic formatter to convert an event object to string """ event.timestamp = colored.yellow(event.timestamp) event.log_stream_name = colored.cyan(event.log_stream_name) return ' '.join([event.log_stream_name, event.timestamp, ev...
[ "def", "_pretty_print_event", "(", "event", ",", "colored", ")", ":", "event", ".", "timestamp", "=", "colored", ".", "yellow", "(", "event", ".", "timestamp", ")", "event", ".", "log_stream_name", "=", "colored", ".", "cyan", "(", "event", ".", "log_strea...
Basic formatter to convert an event object to string
[ "Basic", "formatter", "to", "convert", "an", "event", "object", "to", "string" ]
python
train
dmwm/DBS
Server/Python/src/dbs/web/DBSWriterModel.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSWriterModel.py#L254-L283
def insertBulkBlock(self): """ API to insert a bulk block :param blockDump: Output of the block dump command :type blockDump: dict """ try: body = request.body.read() indata = cjson.decode(body) if (indata.get("file_parent_list", []) ...
[ "def", "insertBulkBlock", "(", "self", ")", ":", "try", ":", "body", "=", "request", ".", "body", ".", "read", "(", ")", "indata", "=", "cjson", ".", "decode", "(", "body", ")", "if", "(", "indata", ".", "get", "(", "\"file_parent_list\"", ",", "[", ...
API to insert a bulk block :param blockDump: Output of the block dump command :type blockDump: dict
[ "API", "to", "insert", "a", "bulk", "block" ]
python
train
econ-ark/HARK
HARK/ConsumptionSaving/ConsPrefShockModel.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsPrefShockModel.py#L308-L351
def usePointsForInterpolation(self,cNrm,mNrm,interpolator): ''' Make a basic solution object with a consumption function and marginal value function (unconditional on the preference shock). Parameters ---------- cNrm : np.array Consumption points for interpol...
[ "def", "usePointsForInterpolation", "(", "self", ",", "cNrm", ",", "mNrm", ",", "interpolator", ")", ":", "# Make the preference-shock specific consumption functions", "PrefShkCount", "=", "self", ".", "PrefShkVals", ".", "size", "cFunc_list", "=", "[", "]", "for", ...
Make a basic solution object with a consumption function and marginal value function (unconditional on the preference shock). Parameters ---------- cNrm : np.array Consumption points for interpolation. mNrm : np.array Corresponding market resource points ...
[ "Make", "a", "basic", "solution", "object", "with", "a", "consumption", "function", "and", "marginal", "value", "function", "(", "unconditional", "on", "the", "preference", "shock", ")", "." ]
python
train
wonambi-python/wonambi
wonambi/widgets/notes.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/notes.py#L1292-L1310
def new_rater(self): """Action: add a new rater. """ if self.annot is None: # remove if buttons are disabled self.parent.statusBar().showMessage('No score file loaded') return newuser = NewUserDialog(self.parent.value('scoring_window')) answer = newuser....
[ "def", "new_rater", "(", "self", ")", ":", "if", "self", ".", "annot", "is", "None", ":", "# remove if buttons are disabled", "self", ".", "parent", ".", "statusBar", "(", ")", ".", "showMessage", "(", "'No score file loaded'", ")", "return", "newuser", "=", ...
Action: add a new rater.
[ "Action", ":", "add", "a", "new", "rater", "." ]
python
train
pybel/pybel
src/pybel/struct/utils.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/utils.py#L13-L28
def update_metadata(source, target) -> None: """Update the namespace and annotation metadata in the target graph. :param pybel.BELGraph source: :param pybel.BELGraph target: """ target.namespace_url.update(source.namespace_url) target.namespace_pattern.update(source.namespace_pattern) targ...
[ "def", "update_metadata", "(", "source", ",", "target", ")", "->", "None", ":", "target", ".", "namespace_url", ".", "update", "(", "source", ".", "namespace_url", ")", "target", ".", "namespace_pattern", ".", "update", "(", "source", ".", "namespace_pattern",...
Update the namespace and annotation metadata in the target graph. :param pybel.BELGraph source: :param pybel.BELGraph target:
[ "Update", "the", "namespace", "and", "annotation", "metadata", "in", "the", "target", "graph", "." ]
python
train
e7dal/bubble3
bubble3/util/value_path.py
https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/util/value_path.py#L64-L74
def _make(self, key, content): """clean""" pass self.say('make a new key>>>' + key + '>>>with>>>:' + str(content)) if key.isdigit(): i = int(key) # list index [p] self.say('extending parent list to contain index:' + key) # make a list with size ...
[ "def", "_make", "(", "self", ",", "key", ",", "content", ")", ":", "pass", "self", ".", "say", "(", "'make a new key>>>'", "+", "key", "+", "'>>>with>>>:'", "+", "str", "(", "content", ")", ")", "if", "key", ".", "isdigit", "(", ")", ":", "i", "=",...
clean
[ "clean" ]
python
train
saltstack/salt
salt/modules/mandrill.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mandrill.py#L64-L77
def _get_api_params(api_url=None, api_version=None, api_key=None): ''' Retrieve the API params from the config file. ''' mandrill_cfg = __salt__['config.merge']('mandrill') if not mandrill_cfg: mandrill_cfg = {} return { 'api_url': api_url ...
[ "def", "_get_api_params", "(", "api_url", "=", "None", ",", "api_version", "=", "None", ",", "api_key", "=", "None", ")", ":", "mandrill_cfg", "=", "__salt__", "[", "'config.merge'", "]", "(", "'mandrill'", ")", "if", "not", "mandrill_cfg", ":", "mandrill_cf...
Retrieve the API params from the config file.
[ "Retrieve", "the", "API", "params", "from", "the", "config", "file", "." ]
python
train
bavovanachte/sphinx-wavedrom
sphinxcontrib/wavedrom.py
https://github.com/bavovanachte/sphinx-wavedrom/blob/a8cfb4422ba2163453db669348f273af2e72f324/sphinxcontrib/wavedrom.py#L130-L171
def render_wavedrom(self, node, outpath, bname, format): """ Render a wavedrom image """ # Try to convert node, raise error with code on failure try: svgout = WaveDrom().renderWaveForm(0, json.loads(node['code'])) except JSONDecodeError as e: raise SphinxError("Cannot render the...
[ "def", "render_wavedrom", "(", "self", ",", "node", ",", "outpath", ",", "bname", ",", "format", ")", ":", "# Try to convert node, raise error with code on failure", "try", ":", "svgout", "=", "WaveDrom", "(", ")", ".", "renderWaveForm", "(", "0", ",", "json", ...
Render a wavedrom image
[ "Render", "a", "wavedrom", "image" ]
python
train
aws/sagemaker-python-sdk
src/sagemaker/session.py
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/session.py#L1266-L1294
def production_variant(model_name, instance_type, initial_instance_count=1, variant_name='AllTraffic', initial_weight=1, accelerator_type=None): """Create a production variant description suitable for use in a ``ProductionVariant`` list as part of a ``CreateEndpointConfig`` request. ...
[ "def", "production_variant", "(", "model_name", ",", "instance_type", ",", "initial_instance_count", "=", "1", ",", "variant_name", "=", "'AllTraffic'", ",", "initial_weight", "=", "1", ",", "accelerator_type", "=", "None", ")", ":", "production_variant_configuration"...
Create a production variant description suitable for use in a ``ProductionVariant`` list as part of a ``CreateEndpointConfig`` request. Args: model_name (str): The name of the SageMaker model this production variant references. instance_type (str): The EC2 instance type for this production vari...
[ "Create", "a", "production", "variant", "description", "suitable", "for", "use", "in", "a", "ProductionVariant", "list", "as", "part", "of", "a", "CreateEndpointConfig", "request", "." ]
python
train
glottobank/python-newick
src/newick.py
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L341-L345
def remove_internal_names(self): """ Set the name of all non-leaf nodes in the subtree to None. """ self.visit(lambda n: setattr(n, 'name', None), lambda n: not n.is_leaf)
[ "def", "remove_internal_names", "(", "self", ")", ":", "self", ".", "visit", "(", "lambda", "n", ":", "setattr", "(", "n", ",", "'name'", ",", "None", ")", ",", "lambda", "n", ":", "not", "n", ".", "is_leaf", ")" ]
Set the name of all non-leaf nodes in the subtree to None.
[ "Set", "the", "name", "of", "all", "non", "-", "leaf", "nodes", "in", "the", "subtree", "to", "None", "." ]
python
test
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/project.py
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/project.py#L131-L191
def new_application(request): """ A new application by a user to start a new project. """ # Note default kgapplications/index.html will display error if user logged # in. if not settings.ALLOW_REGISTRATIONS: return render( template_name='kgapplications/project_common_disabled.html', ...
[ "def", "new_application", "(", "request", ")", ":", "# Note default kgapplications/index.html will display error if user logged", "# in.", "if", "not", "settings", ".", "ALLOW_REGISTRATIONS", ":", "return", "render", "(", "template_name", "=", "'kgapplications/project_common_di...
A new application by a user to start a new project.
[ "A", "new", "application", "by", "a", "user", "to", "start", "a", "new", "project", "." ]
python
train
dbuscher/pois
pois/__init__.py
https://github.com/dbuscher/pois/blob/bb9d9a932e716b5d385221768027384691803aa3/pois/__init__.py#L73-L79
def FibreMode(gridSize,modeDiameter): """ Return a pupil-plane Gaussian mode with 1/e diameter given by *modeDiameter*, normalised so that integral power over the mode is unity """ rmode=modeDiameter/2 return np.exp(-(RadiusGrid(gridSize)/rmode)**2)/(np.sqrt(np.pi/2)*rmode)
[ "def", "FibreMode", "(", "gridSize", ",", "modeDiameter", ")", ":", "rmode", "=", "modeDiameter", "/", "2", "return", "np", ".", "exp", "(", "-", "(", "RadiusGrid", "(", "gridSize", ")", "/", "rmode", ")", "**", "2", ")", "/", "(", "np", ".", "sqrt...
Return a pupil-plane Gaussian mode with 1/e diameter given by *modeDiameter*, normalised so that integral power over the mode is unity
[ "Return", "a", "pupil", "-", "plane", "Gaussian", "mode", "with", "1", "/", "e", "diameter", "given", "by", "*", "modeDiameter", "*", "normalised", "so", "that", "integral", "power", "over", "the", "mode", "is", "unity" ]
python
train
pymc-devs/pymc
pymc/CommonDeterministics.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/CommonDeterministics.py#L472-L499
def pufunc(func): """ Called by pfunc to convert NumPy ufuncs to deterministic factories. """ def dtrm_generator(*args): if len(args) != func.nin: raise ValueError('invalid number of arguments') name = func.__name__ + '(' + '_'.join( [str(arg) for arg in list(args...
[ "def", "pufunc", "(", "func", ")", ":", "def", "dtrm_generator", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "func", ".", "nin", ":", "raise", "ValueError", "(", "'invalid number of arguments'", ")", "name", "=", "func", ".", "__na...
Called by pfunc to convert NumPy ufuncs to deterministic factories.
[ "Called", "by", "pfunc", "to", "convert", "NumPy", "ufuncs", "to", "deterministic", "factories", "." ]
python
train
erdewit/ib_insync
ib_insync/ticker.py
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ticker.py#L122-L135
def marketPrice(self) -> float: """ Return the first available one of * last price if within current bid/ask; * average of bid and ask (midpoint); * close price. """ price = self.last if ( self.hasBidAsk() and self.bid <= self.last <= self.ask) else \...
[ "def", "marketPrice", "(", "self", ")", "->", "float", ":", "price", "=", "self", ".", "last", "if", "(", "self", ".", "hasBidAsk", "(", ")", "and", "self", ".", "bid", "<=", "self", ".", "last", "<=", "self", ".", "ask", ")", "else", "self", "."...
Return the first available one of * last price if within current bid/ask; * average of bid and ask (midpoint); * close price.
[ "Return", "the", "first", "available", "one", "of" ]
python
train
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L1201-L1206
def set(self, data, size): """ Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk """ return lib.zchunk_set(self._as_parameter_, data, size)
[ "def", "set", "(", "self", ",", "data", ",", "size", ")", ":", "return", "lib", ".", "zchunk_set", "(", "self", ".", "_as_parameter_", ",", "data", ",", "size", ")" ]
Set chunk data from user-supplied data; truncate if too large. Data may be null. Returns actual size of chunk
[ "Set", "chunk", "data", "from", "user", "-", "supplied", "data", ";", "truncate", "if", "too", "large", ".", "Data", "may", "be", "null", ".", "Returns", "actual", "size", "of", "chunk" ]
python
train
saltstack/salt
salt/fileclient.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L169-L180
def get_file(self, path, dest='', makedirs=False, saltenv='base', gzip=None, cachedir=None): ''' Copies a file from the local files or master depending on implementation ''' rais...
[ "def", "get_file", "(", "self", ",", "path", ",", "dest", "=", "''", ",", "makedirs", "=", "False", ",", "saltenv", "=", "'base'", ",", "gzip", "=", "None", ",", "cachedir", "=", "None", ")", ":", "raise", "NotImplementedError" ]
Copies a file from the local files or master depending on implementation
[ "Copies", "a", "file", "from", "the", "local", "files", "or", "master", "depending", "on", "implementation" ]
python
train
loli/medpy
medpy/metric/histogram.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L572-L625
def jensen_shannon(h1, h2): # 85 us @array, 110 us @list \w 100 bins r""" Jensen-Shannon divergence. A symmetric and numerically more stable empirical extension of the Kullback-Leibler divergence. The Jensen Shannon divergence between two histograms :math:`H` and :math:`H'` of size :ma...
[ "def", "jensen_shannon", "(", "h1", ",", "h2", ")", ":", "# 85 us @array, 110 us @list \\w 100 bins", "h1", ",", "h2", "=", "__prepare_histogram", "(", "h1", ",", "h2", ")", "s", "=", "(", "h1", "+", "h2", ")", "/", "2.", "return", "__kullback_leibler", "(...
r""" Jensen-Shannon divergence. A symmetric and numerically more stable empirical extension of the Kullback-Leibler divergence. The Jensen Shannon divergence between two histograms :math:`H` and :math:`H'` of size :math:`m` is defined as: .. math:: d_{JSD}(H, H') = ...
[ "r", "Jensen", "-", "Shannon", "divergence", ".", "A", "symmetric", "and", "numerically", "more", "stable", "empirical", "extension", "of", "the", "Kullback", "-", "Leibler", "divergence", ".", "The", "Jensen", "Shannon", "divergence", "between", "two", "histogr...
python
train
Shapeways/coyote_framework
coyote_framework/webdriver/webdriverwrapper/WebElementWrapper.py
https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/webdriver/webdriverwrapper/WebElementWrapper.py#L737-L747
def find_all(self, locator): """ Find wrapper, finds all elements @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @rtype: list @return: A list of WebElementWrappers ""...
[ "def", "find_all", "(", "self", ",", "locator", ")", ":", "return", "self", ".", "driver_wrapper", ".", "find", "(", "locator", ",", "True", ",", "self", ".", "element", ")" ]
Find wrapper, finds all elements @type locator: webdriverwrapper.support.locator.Locator @param locator: locator used in search @rtype: list @return: A list of WebElementWrappers
[ "Find", "wrapper", "finds", "all", "elements" ]
python
train
dependencies-io/cli
dependencies_cli/project_template/{{cookiecutter.name}}/src/utils.py
https://github.com/dependencies-io/cli/blob/d8ae97343c48a61d6614d3e8af6a981b4cfb1bcb/dependencies_cli/project_template/{{cookiecutter.name}}/src/utils.py#L27-L37
def mock_lockfile_update(path): """ This is a mock update. In place of this, you might simply shell out to a command like `yarn upgrade`. """ updated_lockfile_contents = { 'package1': '1.2.0' } with open(path, 'w+') as f: f.write(json.dumps(updated_lockfile_contents, indent=4...
[ "def", "mock_lockfile_update", "(", "path", ")", ":", "updated_lockfile_contents", "=", "{", "'package1'", ":", "'1.2.0'", "}", "with", "open", "(", "path", ",", "'w+'", ")", "as", "f", ":", "f", ".", "write", "(", "json", ".", "dumps", "(", "updated_loc...
This is a mock update. In place of this, you might simply shell out to a command like `yarn upgrade`.
[ "This", "is", "a", "mock", "update", ".", "In", "place", "of", "this", "you", "might", "simply", "shell", "out", "to", "a", "command", "like", "yarn", "upgrade", "." ]
python
train
pywbem/pywbem
pywbem_mock/_wbemconnection_mock.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem_mock/_wbemconnection_mock.py#L3294-L3324
def _fake_closeenumeration(self, namespace, **params): """ Implements WBEM server responder for :meth:`~pywbem.WBEMConnection.CloseEnumeration` with data from the instance repository. If the EnumerationContext is valid it removes it from the context r...
[ "def", "_fake_closeenumeration", "(", "self", ",", "namespace", ",", "*", "*", "params", ")", ":", "self", ".", "_validate_namespace", "(", "namespace", ")", "context_id", "=", "params", "[", "'EnumerationContext'", "]", "try", ":", "context_data", "=", "self"...
Implements WBEM server responder for :meth:`~pywbem.WBEMConnection.CloseEnumeration` with data from the instance repository. If the EnumerationContext is valid it removes it from the context repository. Otherwise it returns an exception.
[ "Implements", "WBEM", "server", "responder", "for", ":", "meth", ":", "~pywbem", ".", "WBEMConnection", ".", "CloseEnumeration", "with", "data", "from", "the", "instance", "repository", "." ]
python
train
KE-works/pykechain
pykechain/client.py
https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/client.py#L720-L755
def service_executions(self, name=None, pk=None, scope=None, service=None, **kwargs): """ Retrieve Service Executions. If additional `keyword=value` arguments are provided, these are added to the request parameters. Please refer to the documentation of the KE-chain API for additional qu...
[ "def", "service_executions", "(", "self", ",", "name", "=", "None", ",", "pk", "=", "None", ",", "scope", "=", "None", ",", "service", "=", "None", ",", "*", "*", "kwargs", ")", ":", "request_params", "=", "{", "'name'", ":", "name", ",", "'id'", "...
Retrieve Service Executions. If additional `keyword=value` arguments are provided, these are added to the request parameters. Please refer to the documentation of the KE-chain API for additional query parameters. :param name: (optional) name to limit the search for :type name: basestri...
[ "Retrieve", "Service", "Executions", "." ]
python
train
Yubico/python-pyhsm
pyhsm/base.py
https://github.com/Yubico/python-pyhsm/blob/b6e2744d1ea15c352a0fc1d6ebc5950026b71311/pyhsm/base.py#L436-L464
def validate_aead_otp(self, public_id, otp, key_handle, aead): """ Ask YubiHSM to validate a YubiKey OTP using an AEAD and a key_handle to decrypt the AEAD. @param public_id: The six bytes public id of the YubiKey @param otp: The one time password (OTP) to validate @para...
[ "def", "validate_aead_otp", "(", "self", ",", "public_id", ",", "otp", ",", "key_handle", ",", "aead", ")", ":", "if", "type", "(", "public_id", ")", "is", "not", "str", ":", "assert", "(", ")", "if", "type", "(", "otp", ")", "is", "not", "str", ":...
Ask YubiHSM to validate a YubiKey OTP using an AEAD and a key_handle to decrypt the AEAD. @param public_id: The six bytes public id of the YubiKey @param otp: The one time password (OTP) to validate @param key_handle: The key handle that can decrypt the AEAD @param aead: AEAD co...
[ "Ask", "YubiHSM", "to", "validate", "a", "YubiKey", "OTP", "using", "an", "AEAD", "and", "a", "key_handle", "to", "decrypt", "the", "AEAD", "." ]
python
train
neurodata/ndio
ndio/remote/ndingest.py
https://github.com/neurodata/ndio/blob/792dd5816bc770b05a3db2f4327da42ff6253531/ndio/remote/ndingest.py#L261-L277
def project_dict(self, project_name, token_name, public): """ Genarate the project dictionary. """ project_dict = {} project_dict['project_name'] = project_name if token_name is not None: if token_name == '': project_dict['token_name'] = projec...
[ "def", "project_dict", "(", "self", ",", "project_name", ",", "token_name", ",", "public", ")", ":", "project_dict", "=", "{", "}", "project_dict", "[", "'project_name'", "]", "=", "project_name", "if", "token_name", "is", "not", "None", ":", "if", "token_na...
Genarate the project dictionary.
[ "Genarate", "the", "project", "dictionary", "." ]
python
test
DistrictDataLabs/yellowbrick
yellowbrick/text/postag.py
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/text/postag.py#L118-L152
def fit(self, X, y=None, **kwargs): """ Fits the corpus to the appropriate tag map. Text documents must be tokenized & tagged before passing to fit. Parameters ---------- X : list or generator Should be provided as a list of documents or a generator ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# TODO: add support for other tagsets?", "if", "self", ".", "tagset", "==", "\"penn_treebank\"", ":", "self", ".", "pos_tag_counts_", "=", "self", ".", "_penn_t...
Fits the corpus to the appropriate tag map. Text documents must be tokenized & tagged before passing to fit. Parameters ---------- X : list or generator Should be provided as a list of documents or a generator that yields a list of documents that contain a list o...
[ "Fits", "the", "corpus", "to", "the", "appropriate", "tag", "map", ".", "Text", "documents", "must", "be", "tokenized", "&", "tagged", "before", "passing", "to", "fit", "." ]
python
train
ejeschke/ginga
ginga/trcalc.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/trcalc.py#L443-L465
def get_scaled_cutout_basic_view(shp, p1, p2, scales): """ Like get_scaled_cutout_basic, but returns the view/slice to extract from an image, instead of the extraction itself """ x1, y1 = p1[:2] x2, y2 = p2[:2] scale_x, scale_y = scales[:2] # calculate dimensions of NON-scaled cutout ...
[ "def", "get_scaled_cutout_basic_view", "(", "shp", ",", "p1", ",", "p2", ",", "scales", ")", ":", "x1", ",", "y1", "=", "p1", "[", ":", "2", "]", "x2", ",", "y2", "=", "p2", "[", ":", "2", "]", "scale_x", ",", "scale_y", "=", "scales", "[", ":"...
Like get_scaled_cutout_basic, but returns the view/slice to extract from an image, instead of the extraction itself
[ "Like", "get_scaled_cutout_basic", "but", "returns", "the", "view", "/", "slice", "to", "extract", "from", "an", "image", "instead", "of", "the", "extraction", "itself" ]
python
train
mardix/flask-cloudy
flask_cloudy.py
https://github.com/mardix/flask-cloudy/blob/8085d8fbbafec6c358f0d307bfcb795de50d4acb/flask_cloudy.py#L83-L101
def get_driver_class(provider): """ Return the driver class :param provider: str - provider name :return: """ if "." in provider: parts = provider.split('.') kls = parts.pop() path = '.'.join(parts) module = import_module(path) if not hasattr(module, kls):...
[ "def", "get_driver_class", "(", "provider", ")", ":", "if", "\".\"", "in", "provider", ":", "parts", "=", "provider", ".", "split", "(", "'.'", ")", "kls", "=", "parts", ".", "pop", "(", ")", "path", "=", "'.'", ".", "join", "(", "parts", ")", "mod...
Return the driver class :param provider: str - provider name :return:
[ "Return", "the", "driver", "class", ":", "param", "provider", ":", "str", "-", "provider", "name", ":", "return", ":" ]
python
train
kpdyer/regex2dfa
third_party/re2/lib/codereview/codereview.py
https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1277-L1385
def change(ui, repo, *pats, **opts): """create, edit or delete a change list Create, edit or delete a change list. A change list is a group of files to be reviewed and submitted together, plus a textual description of the change. Change lists are referred to by simple alphanumeric names. Changes must be reviewe...
[ "def", "change", "(", "ui", ",", "repo", ",", "*", "pats", ",", "*", "*", "opts", ")", ":", "if", "codereview_disabled", ":", "raise", "hg_util", ".", "Abort", "(", "codereview_disabled", ")", "dirty", "=", "{", "}", "if", "len", "(", "pats", ")", ...
create, edit or delete a change list Create, edit or delete a change list. A change list is a group of files to be reviewed and submitted together, plus a textual description of the change. Change lists are referred to by simple alphanumeric names. Changes must be reviewed before they can be submitted. In the ...
[ "create", "edit", "or", "delete", "a", "change", "list" ]
python
train
changhiskhan/poseidon
poseidon/droplet.py
https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/droplet.py#L453-L465
def delete(self, wait=True): """ Delete this droplet Parameters ---------- wait: bool, default True Whether to block until the pending action is completed """ resp = self.parent.delete(self.id) if wait: self.wait() return r...
[ "def", "delete", "(", "self", ",", "wait", "=", "True", ")", ":", "resp", "=", "self", ".", "parent", ".", "delete", "(", "self", ".", "id", ")", "if", "wait", ":", "self", ".", "wait", "(", ")", "return", "resp" ]
Delete this droplet Parameters ---------- wait: bool, default True Whether to block until the pending action is completed
[ "Delete", "this", "droplet" ]
python
valid
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L222-L292
def post_message(self, msg): '''default post message call''' if '_posted' in msg.__dict__: return msg._posted = True msg._timestamp = time.time() type = msg.get_type() if type != 'HEARTBEAT' or (msg.type != mavlink.MAV_TYPE_GCS and msg.type != mavlink.MAV_TYPE...
[ "def", "post_message", "(", "self", ",", "msg", ")", ":", "if", "'_posted'", "in", "msg", ".", "__dict__", ":", "return", "msg", ".", "_posted", "=", "True", "msg", ".", "_timestamp", "=", "time", ".", "time", "(", ")", "type", "=", "msg", ".", "ge...
default post message call
[ "default", "post", "message", "call" ]
python
train
rbuffat/pyepw
pyepw/epw.py
https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L919-L942
def title_of_design_condition(self, value=None): """Corresponds to IDD Field `title_of_design_condition` Args: value (str): value for IDD Field `title_of_design_condition` if `value` is None it will not be checked against the specification and is assumed to b...
[ "def", "title_of_design_condition", "(", "self", ",", "value", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "try", ":", "value", "=", "str", "(", "value", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'value {} need to b...
Corresponds to IDD Field `title_of_design_condition` Args: value (str): value for IDD Field `title_of_design_condition` if `value` is None it will not be checked against the specification and is assumed to be a missing value Raises: ValueError: i...
[ "Corresponds", "to", "IDD", "Field", "title_of_design_condition" ]
python
train
zhanglab/psamm
psamm/datasource/sbml.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/datasource/sbml.py#L987-L995
def _add_gene_list(self, parent_tag, gene_id_dict): """Create list of all gene products as sbml readable elements.""" list_all_genes = ET.SubElement(parent_tag, _tag( 'listOfGeneProducts', FBC_V2)) for id, label in sorted(iteritems(gene_id_dict)): gene_tag = ET.SubElement...
[ "def", "_add_gene_list", "(", "self", ",", "parent_tag", ",", "gene_id_dict", ")", ":", "list_all_genes", "=", "ET", ".", "SubElement", "(", "parent_tag", ",", "_tag", "(", "'listOfGeneProducts'", ",", "FBC_V2", ")", ")", "for", "id", ",", "label", "in", "...
Create list of all gene products as sbml readable elements.
[ "Create", "list", "of", "all", "gene", "products", "as", "sbml", "readable", "elements", "." ]
python
train
Autodesk/cryptorito
cryptorito/__init__.py
https://github.com/Autodesk/cryptorito/blob/277fc7cc42c31c5bc37e26d8bf5a2ac746a6ea85/cryptorito/__init__.py#L214-L230
def fingerprint_from_keybase(fingerprint, kb_obj): """Extracts a key matching a specific fingerprint from a Keybase API response""" if 'public_keys' in kb_obj and \ 'pgp_public_keys' in kb_obj['public_keys']: for key in kb_obj['public_keys']['pgp_public_keys']: keyprint = fingerpr...
[ "def", "fingerprint_from_keybase", "(", "fingerprint", ",", "kb_obj", ")", ":", "if", "'public_keys'", "in", "kb_obj", "and", "'pgp_public_keys'", "in", "kb_obj", "[", "'public_keys'", "]", ":", "for", "key", "in", "kb_obj", "[", "'public_keys'", "]", "[", "'p...
Extracts a key matching a specific fingerprint from a Keybase API response
[ "Extracts", "a", "key", "matching", "a", "specific", "fingerprint", "from", "a", "Keybase", "API", "response" ]
python
train
saltstack/salt
salt/netapi/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/__init__.py#L111-L120
def local_subset(self, *args, **kwargs): ''' Run :ref:`execution modules <all-salt.modules>` against subsets of minions .. versionadded:: 2016.3.0 Wraps :py:meth:`salt.client.LocalClient.cmd_subset` ''' local = salt.client.get_local_client(mopts=self.opts) retur...
[ "def", "local_subset", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "local", "=", "salt", ".", "client", ".", "get_local_client", "(", "mopts", "=", "self", ".", "opts", ")", "return", "local", ".", "cmd_subset", "(", "*", "args"...
Run :ref:`execution modules <all-salt.modules>` against subsets of minions .. versionadded:: 2016.3.0 Wraps :py:meth:`salt.client.LocalClient.cmd_subset`
[ "Run", ":", "ref", ":", "execution", "modules", "<all", "-", "salt", ".", "modules", ">", "against", "subsets", "of", "minions" ]
python
train
rainwoodman/sharedmem
sharedmem/sharedmem.py
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L643-L782
def map(self, func, sequence, reduce=None, star=False, minlength=0): """ Map-reduce with multile processes. Apply func to each item on the sequence, in parallel. As the results are collected, reduce is called on the result. The reduced result is returned as a list. ...
[ "def", "map", "(", "self", ",", "func", ",", "sequence", ",", "reduce", "=", "None", ",", "star", "=", "False", ",", "minlength", "=", "0", ")", ":", "def", "realreduce", "(", "r", ")", ":", "if", "reduce", ":", "if", "isinstance", "(", "r", ",",...
Map-reduce with multile processes. Apply func to each item on the sequence, in parallel. As the results are collected, reduce is called on the result. The reduced result is returned as a list. Parameters ---------- func : callable ...
[ "Map", "-", "reduce", "with", "multile", "processes", "." ]
python
valid
tcalmant/ipopo
pelix/ldapfilter.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ldapfilter.py#L396-L406
def _comparator_star(filter_value, tested_value): """ Tests a filter containing a joker """ if isinstance(tested_value, ITERABLES): for value in tested_value: if _star_comparison(filter_value, value): return True return False return _star_comparison(filte...
[ "def", "_comparator_star", "(", "filter_value", ",", "tested_value", ")", ":", "if", "isinstance", "(", "tested_value", ",", "ITERABLES", ")", ":", "for", "value", "in", "tested_value", ":", "if", "_star_comparison", "(", "filter_value", ",", "value", ")", ":"...
Tests a filter containing a joker
[ "Tests", "a", "filter", "containing", "a", "joker" ]
python
train
michael-lazar/rtv
rtv/packages/praw/objects.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/objects.py#L1875-L1879
def _convert(reddit_session, data): """Return a Redditor object from the data.""" retval = Redditor(reddit_session, data['name'], fetch=False) retval.id = data['id'].split('_')[1] # pylint: disable=C0103,W0201 return retval
[ "def", "_convert", "(", "reddit_session", ",", "data", ")", ":", "retval", "=", "Redditor", "(", "reddit_session", ",", "data", "[", "'name'", "]", ",", "fetch", "=", "False", ")", "retval", ".", "id", "=", "data", "[", "'id'", "]", ".", "split", "("...
Return a Redditor object from the data.
[ "Return", "a", "Redditor", "object", "from", "the", "data", "." ]
python
train
ssato/python-anyconfig
src/anyconfig/backend/shellvars.py
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/backend/shellvars.py#L128-L137
def dump_to_stream(self, cnf, stream, **kwargs): """ Dump config 'cnf' to a file or file-like object 'stream'. :param cnf: Shell variables data to dump :param stream: Shell script file or file like object :param kwargs: backend-specific optional keyword parameters :: dict ...
[ "def", "dump_to_stream", "(", "self", ",", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "val", "in", "anyconfig", ".", "compat", ".", "iteritems", "(", "cnf", ")", ":", "stream", ".", "write", "(", "\"%s='%s'%s\"", "%",...
Dump config 'cnf' to a file or file-like object 'stream'. :param cnf: Shell variables data to dump :param stream: Shell script file or file like object :param kwargs: backend-specific optional keyword parameters :: dict
[ "Dump", "config", "cnf", "to", "a", "file", "or", "file", "-", "like", "object", "stream", "." ]
python
train
Erotemic/utool
utool/util_path.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_path.py#L1579-L1588
def assertpath(path_, msg='', **kwargs): """ Asserts that a patha exists """ if NO_ASSERTS: return if path_ is None: raise AssertionError('path is None! %s' % (path_, msg)) if path_ == '': raise AssertionError('path=%r is the empty string! %s' % (path_, msg)) if not checkpath...
[ "def", "assertpath", "(", "path_", ",", "msg", "=", "''", ",", "*", "*", "kwargs", ")", ":", "if", "NO_ASSERTS", ":", "return", "if", "path_", "is", "None", ":", "raise", "AssertionError", "(", "'path is None! %s'", "%", "(", "path_", ",", "msg", ")", ...
Asserts that a patha exists
[ "Asserts", "that", "a", "patha", "exists" ]
python
train
angr/angr
angr/sim_manager.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/sim_manager.py#L193-L211
def remove_technique(self, tech): """ Remove an exploration technique from a list of active techniques. :param tech: An ExplorationTechnique object. :type tech: ExplorationTechnique """ if not isinstance(tech, ExplorationTechnique): raise SimulationMan...
[ "def", "remove_technique", "(", "self", ",", "tech", ")", ":", "if", "not", "isinstance", "(", "tech", ",", "ExplorationTechnique", ")", ":", "raise", "SimulationManagerError", "def", "_is_overriden", "(", "name", ")", ":", "return", "getattr", "(", "tech", ...
Remove an exploration technique from a list of active techniques. :param tech: An ExplorationTechnique object. :type tech: ExplorationTechnique
[ "Remove", "an", "exploration", "technique", "from", "a", "list", "of", "active", "techniques", "." ]
python
train
mitsei/dlkit
dlkit/records/assessment/basic/multi_choice_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/basic/multi_choice_records.py#L884-L889
def clear_choices(self): """stub""" if self.get_choices_metadata().is_read_only(): raise NoAccess() self.my_osid_object_form._my_map['choices'] = \ self._choices_metadata['default_object_values'][0]
[ "def", "clear_choices", "(", "self", ")", ":", "if", "self", ".", "get_choices_metadata", "(", ")", ".", "is_read_only", "(", ")", ":", "raise", "NoAccess", "(", ")", "self", ".", "my_osid_object_form", ".", "_my_map", "[", "'choices'", "]", "=", "self", ...
stub
[ "stub" ]
python
train
hydraplatform/hydra-base
hydra_base/lib/network.py
https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L1729-L1750
def set_node_status(node_id, status, **kwargs): """ Set the status of a node to 'X' """ user_id = kwargs.get('user_id') try: node_i = db.DBSession.query(Node).filter(Node.id == node_id).one() except NoResultFound: raise ResourceNotFoundError("Node %s not found"%(node_id)) ...
[ "def", "set_node_status", "(", "node_id", ",", "status", ",", "*", "*", "kwargs", ")", ":", "user_id", "=", "kwargs", ".", "get", "(", "'user_id'", ")", "try", ":", "node_i", "=", "db", ".", "DBSession", ".", "query", "(", "Node", ")", ".", "filter",...
Set the status of a node to 'X'
[ "Set", "the", "status", "of", "a", "node", "to", "X" ]
python
train
pymupdf/PyMuPDF
fitz/fitz.py
https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L4625-L4638
def _le_slash(self, annot, p1, p2, lr): """Make stream commands for slash line end symbol. "lr" denotes left (False) or right point. """ m, im, L, R, w, scol, fcol, opacity = self._le_annot_parms(annot, p1, p2) rw = 1.1547 * max(1, w) * 1.0 # makes rect diagonal a 30 deg inclinat...
[ "def", "_le_slash", "(", "self", ",", "annot", ",", "p1", ",", "p2", ",", "lr", ")", ":", "m", ",", "im", ",", "L", ",", "R", ",", "w", ",", "scol", ",", "fcol", ",", "opacity", "=", "self", ".", "_le_annot_parms", "(", "annot", ",", "p1", ",...
Make stream commands for slash line end symbol. "lr" denotes left (False) or right point.
[ "Make", "stream", "commands", "for", "slash", "line", "end", "symbol", ".", "lr", "denotes", "left", "(", "False", ")", "or", "right", "point", "." ]
python
train
sony/nnabla
python/src/nnabla/experimental/graph_converters/batch_normalization_linear.py
https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/experimental/graph_converters/batch_normalization_linear.py#L27-L53
def convert(self, vroot, entry_variables): """ All functions are replaced with the same `new` function. Args: vroot (:obj:`Variable`): NNabla Variable entry_variables (:obj:`Variable`): Entry variable from which the conversion starts. """ self.graph_info ...
[ "def", "convert", "(", "self", ",", "vroot", ",", "entry_variables", ")", ":", "self", ".", "graph_info", "=", "GraphInfo", "(", "vroot", ")", "self", ".", "entry_variables", "=", "entry_variables", "cnt", "=", "0", "with", "nn", ".", "parameter_scope", "(...
All functions are replaced with the same `new` function. Args: vroot (:obj:`Variable`): NNabla Variable entry_variables (:obj:`Variable`): Entry variable from which the conversion starts.
[ "All", "functions", "are", "replaced", "with", "the", "same", "new", "function", "." ]
python
train
cggh/scikit-allel
allel/model/ndarray.py
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/model/ndarray.py#L3472-L3515
def locate_intersection(self, other): """Locate the intersection with another array. Parameters ---------- other : array_like, int Array of values to intersect. Returns ------- loc : ndarray, bool Boolean array with location of intersecti...
[ "def", "locate_intersection", "(", "self", ",", "other", ")", ":", "# check inputs", "other", "=", "SortedIndex", "(", "other", ",", "copy", "=", "False", ")", "# find intersection", "assume_unique", "=", "self", ".", "is_unique", "and", "other", ".", "is_uniq...
Locate the intersection with another array. Parameters ---------- other : array_like, int Array of values to intersect. Returns ------- loc : ndarray, bool Boolean array with location of intersection. loc_other : ndarray, bool ...
[ "Locate", "the", "intersection", "with", "another", "array", "." ]
python
train
SBRG/ssbio
ssbio/utils.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/utils.py#L551-L564
def dict_head(d, N=5): """Return the head of a dictionary. It will be random! Default is to return the first 5 key/value pairs in a dictionary. Args: d: Dictionary to get head. N: Number of elements to display. Returns: dict: the first N items of the dictionary. """ r...
[ "def", "dict_head", "(", "d", ",", "N", "=", "5", ")", ":", "return", "{", "k", ":", "d", "[", "k", "]", "for", "k", "in", "list", "(", "d", ".", "keys", "(", ")", ")", "[", ":", "N", "]", "}" ]
Return the head of a dictionary. It will be random! Default is to return the first 5 key/value pairs in a dictionary. Args: d: Dictionary to get head. N: Number of elements to display. Returns: dict: the first N items of the dictionary.
[ "Return", "the", "head", "of", "a", "dictionary", ".", "It", "will", "be", "random!" ]
python
train
materialsproject/pymatgen
pymatgen/symmetry/analyzer.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/symmetry/analyzer.py#L1022-L1056
def _find_mirror(self, axis): """ Looks for mirror symmetry of specified type about axis. Possible types are "h" or "vd". Horizontal (h) mirrors are perpendicular to the axis while vertical (v) or diagonal (d) mirrors are parallel. v mirrors has atoms lying on the mirror plane...
[ "def", "_find_mirror", "(", "self", ",", "axis", ")", ":", "mirror_type", "=", "\"\"", "# First test whether the axis itself is the normal to a mirror plane.", "if", "self", ".", "is_valid_op", "(", "SymmOp", ".", "reflection", "(", "axis", ")", ")", ":", "self", ...
Looks for mirror symmetry of specified type about axis. Possible types are "h" or "vd". Horizontal (h) mirrors are perpendicular to the axis while vertical (v) or diagonal (d) mirrors are parallel. v mirrors has atoms lying on the mirror plane while d mirrors do not.
[ "Looks", "for", "mirror", "symmetry", "of", "specified", "type", "about", "axis", ".", "Possible", "types", "are", "h", "or", "vd", ".", "Horizontal", "(", "h", ")", "mirrors", "are", "perpendicular", "to", "the", "axis", "while", "vertical", "(", "v", "...
python
train
PyCQA/astroid
astroid/scoped_nodes.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/scoped_nodes.py#L2290-L2312
def instance_attr(self, name, context=None): """Get the list of nodes associated to the given attribute name. Assignments are looked for in both this class and in parents. :returns: The list of assignments to the given name. :rtype: list(NodeNG) :raises AttributeInferenceError...
[ "def", "instance_attr", "(", "self", ",", "name", ",", "context", "=", "None", ")", ":", "# Return a copy, so we don't modify self.instance_attrs,", "# which could lead to infinite loop.", "values", "=", "list", "(", "self", ".", "instance_attrs", ".", "get", "(", "na...
Get the list of nodes associated to the given attribute name. Assignments are looked for in both this class and in parents. :returns: The list of assignments to the given name. :rtype: list(NodeNG) :raises AttributeInferenceError: If no attribute with this name can be foun...
[ "Get", "the", "list", "of", "nodes", "associated", "to", "the", "given", "attribute", "name", "." ]
python
train
OpenAgInitiative/openag_python
openag/cli/cloud/db.py
https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/cloud/db.py#L10-L29
def init(cloud_url): """ Choose a cloud server to use. Sets CLOUD_URL as the cloud server to use and sets up replication of global databases from that cloud server if a local database is already initialized (via `openag db init`). """ old_cloud_url = config["cloud_server"]["url"] if old_clou...
[ "def", "init", "(", "cloud_url", ")", ":", "old_cloud_url", "=", "config", "[", "\"cloud_server\"", "]", "[", "\"url\"", "]", "if", "old_cloud_url", "and", "old_cloud_url", "!=", "cloud_url", ":", "raise", "click", ".", "ClickException", "(", "'Server \"{}\" alr...
Choose a cloud server to use. Sets CLOUD_URL as the cloud server to use and sets up replication of global databases from that cloud server if a local database is already initialized (via `openag db init`).
[ "Choose", "a", "cloud", "server", "to", "use", ".", "Sets", "CLOUD_URL", "as", "the", "cloud", "server", "to", "use", "and", "sets", "up", "replication", "of", "global", "databases", "from", "that", "cloud", "server", "if", "a", "local", "database", "is", ...
python
train
ynop/audiomate
audiomate/corpus/corpus.py
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/corpus.py#L291-L313
def new_issuer(self, issuer_idx, info=None): """ Add a new issuer to the dataset with the given data. Parameters: issuer_idx (str): The id to associate the issuer with. If None or already exists, one is generated. info (dict, list): Addition...
[ "def", "new_issuer", "(", "self", ",", "issuer_idx", ",", "info", "=", "None", ")", ":", "new_issuer_idx", "=", "issuer_idx", "# Add index to idx if already existing", "if", "new_issuer_idx", "in", "self", ".", "_issuers", ".", "keys", "(", ")", ":", "new_issuer...
Add a new issuer to the dataset with the given data. Parameters: issuer_idx (str): The id to associate the issuer with. If None or already exists, one is generated. info (dict, list): Additional info of the issuer. Returns: Issuer: The ...
[ "Add", "a", "new", "issuer", "to", "the", "dataset", "with", "the", "given", "data", "." ]
python
train
angr/angr
angr/sim_procedure.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/sim_procedure.py#L406-L417
def exit(self, exit_code): """ Add an exit representing terminating the program. """ self.inhibit_autoret = True self.state.options.discard(o.AST_DEPS) self.state.options.discard(o.AUTO_REFS) if isinstance(exit_code, int): exit_code = self.state.solve...
[ "def", "exit", "(", "self", ",", "exit_code", ")", ":", "self", ".", "inhibit_autoret", "=", "True", "self", ".", "state", ".", "options", ".", "discard", "(", "o", ".", "AST_DEPS", ")", "self", ".", "state", ".", "options", ".", "discard", "(", "o",...
Add an exit representing terminating the program.
[ "Add", "an", "exit", "representing", "terminating", "the", "program", "." ]
python
train
OpenHumans/open-humans-api
ohapi/command_line.py
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L219-L227
def upload_metadata_cli(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`. """ retur...
[ "def", "upload_metadata_cli", "(", "directory", ",", "create_csv", "=", "''", ",", "review", "=", "''", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "return", "upload_metadata", "(", "directory", ",", ...
Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`.
[ "Command", "line", "function", "for", "drafting", "or", "reviewing", "metadata", "files", ".", "For", "more", "information", "visit", ":", "func", ":", "upload_metadata<ohapi", ".", "command_line", ".", "upload_metadata", ">", "." ]
python
train
quantmind/pulsar-odm
odm/mapper.py
https://github.com/quantmind/pulsar-odm/blob/5955c20beca0a89270c2b390335838deb7d5915e/odm/mapper.py#L303-L309
def database_all(self): """Return a dictionary mapping engines with databases """ all = {} for engine in self.engines(): all[engine] = self._database_all(engine) return all
[ "def", "database_all", "(", "self", ")", ":", "all", "=", "{", "}", "for", "engine", "in", "self", ".", "engines", "(", ")", ":", "all", "[", "engine", "]", "=", "self", ".", "_database_all", "(", "engine", ")", "return", "all" ]
Return a dictionary mapping engines with databases
[ "Return", "a", "dictionary", "mapping", "engines", "with", "databases" ]
python
train
pandas-dev/pandas
pandas/core/panel.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L694-L733
def dropna(self, axis=0, how='any', inplace=False): """ Drop 2D from panel, holding passed axis constant. Parameters ---------- axis : int, default 0 Axis to hold constant. E.g. axis=1 will drop major_axis entries having a certain amount of NA data ...
[ "def", "dropna", "(", "self", ",", "axis", "=", "0", ",", "how", "=", "'any'", ",", "inplace", "=", "False", ")", ":", "axis", "=", "self", ".", "_get_axis_number", "(", "axis", ")", "values", "=", "self", ".", "values", "mask", "=", "notna", "(", ...
Drop 2D from panel, holding passed axis constant. Parameters ---------- axis : int, default 0 Axis to hold constant. E.g. axis=1 will drop major_axis entries having a certain amount of NA data how : {'all', 'any'}, default 'any' 'any': one or more val...
[ "Drop", "2D", "from", "panel", "holding", "passed", "axis", "constant", "." ]
python
train
tensorflow/probability
tensorflow_probability/python/distributions/transformed_distribution.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/transformed_distribution.py#L41-L49
def _pick_scalar_condition(pred, cond_true, cond_false): """Convenience function which chooses the condition based on the predicate.""" # Note: This function is only valid if all of pred, cond_true, and cond_false # are scalars. This means its semantics are arguably more like tf.cond than # tf.where even though...
[ "def", "_pick_scalar_condition", "(", "pred", ",", "cond_true", ",", "cond_false", ")", ":", "# Note: This function is only valid if all of pred, cond_true, and cond_false", "# are scalars. This means its semantics are arguably more like tf.cond than", "# tf.where even though we use tf.where...
Convenience function which chooses the condition based on the predicate.
[ "Convenience", "function", "which", "chooses", "the", "condition", "based", "on", "the", "predicate", "." ]
python
test
tensorflow/probability
tensorflow_probability/python/distributions/linear_gaussian_ssm.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/linear_gaussian_ssm.py#L454-L541
def backward_smoothing_pass(self, filtered_means, filtered_covs, predicted_means, predicted_covs): """Run the backward pass in Kalman smoother. The backward smoothing is using Rauch, Tung and...
[ "def", "backward_smoothing_pass", "(", "self", ",", "filtered_means", ",", "filtered_covs", ",", "predicted_means", ",", "predicted_covs", ")", ":", "with", "tf", ".", "name_scope", "(", "\"backward_pass\"", ")", ":", "filtered_means", "=", "tf", ".", "convert_to_...
Run the backward pass in Kalman smoother. The backward smoothing is using Rauch, Tung and Striebel smoother as as discussed in section 18.3.2 of Kevin P. Murphy, 2012, Machine Learning: A Probabilistic Perspective, The MIT Press. The inputs are returned by `forward_filter` function. Args: fi...
[ "Run", "the", "backward", "pass", "in", "Kalman", "smoother", "." ]
python
test
delph-in/pydelphin
delphin/mrs/penman.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/penman.py#L29-L41
def load(fh, model): """ Deserialize PENMAN graphs from a file (handle or filename) Args: fh: filename or file object model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*) """ graphs = penman.load(fh, cls=XMRSCodec) xs =...
[ "def", "load", "(", "fh", ",", "model", ")", ":", "graphs", "=", "penman", ".", "load", "(", "fh", ",", "cls", "=", "XMRSCodec", ")", "xs", "=", "[", "model", ".", "from_triples", "(", "g", ".", "triples", "(", ")", ")", "for", "g", "in", "grap...
Deserialize PENMAN graphs from a file (handle or filename) Args: fh: filename or file object model: Xmrs subclass instantiated from decoded triples Returns: a list of objects (of class *model*)
[ "Deserialize", "PENMAN", "graphs", "from", "a", "file", "(", "handle", "or", "filename", ")" ]
python
train
CyberReboot/vent
vent/menus/tools.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menus/tools.py#L82-L202
def create(self, group_view=False): """ Update with current tools """ self.add_handlers({'^T': self.quit, '^Q': self.quit}) self.add(npyscreen.TitleText, name='Select which tools to ' + self.action['action'] + ':', editable=False) togglable = ['remove'] ...
[ "def", "create", "(", "self", ",", "group_view", "=", "False", ")", ":", "self", ".", "add_handlers", "(", "{", "'^T'", ":", "self", ".", "quit", ",", "'^Q'", ":", "self", ".", "quit", "}", ")", "self", ".", "add", "(", "npyscreen", ".", "TitleText...
Update with current tools
[ "Update", "with", "current", "tools" ]
python
train
pypa/pipenv
pipenv/patched/notpip/_internal/cli/autocompletion.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/autocompletion.py#L13-L101
def autocomplete(): """Entry Point for completion of main and subcommand options. """ # Don't complete if user hasn't sourced bash_completion file. if 'PIP_AUTO_COMPLETE' not in os.environ: return cwords = os.environ['COMP_WORDS'].split()[1:] cword = int(os.environ['COMP_CWORD']) try...
[ "def", "autocomplete", "(", ")", ":", "# Don't complete if user hasn't sourced bash_completion file.", "if", "'PIP_AUTO_COMPLETE'", "not", "in", "os", ".", "environ", ":", "return", "cwords", "=", "os", ".", "environ", "[", "'COMP_WORDS'", "]", ".", "split", "(", ...
Entry Point for completion of main and subcommand options.
[ "Entry", "Point", "for", "completion", "of", "main", "and", "subcommand", "options", "." ]
python
train
openstax/cnx-epub
cnxepub/adapters.py
https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/adapters.py#L58-L68
def adapt_package(package): """Adapts ``.epub.Package`` to a ``BinderItem`` and cascades the adaptation downward to ``DocumentItem`` and ``ResourceItem``. The results of this process provide the same interface as ``.models.Binder``, ``.models.Document`` and ``.models.Resource``. """ navigati...
[ "def", "adapt_package", "(", "package", ")", ":", "navigation_item", "=", "package", ".", "navigation", "html", "=", "etree", ".", "parse", "(", "navigation_item", ".", "data", ")", "tree", "=", "parse_navigation_html_to_tree", "(", "html", ",", "navigation_item...
Adapts ``.epub.Package`` to a ``BinderItem`` and cascades the adaptation downward to ``DocumentItem`` and ``ResourceItem``. The results of this process provide the same interface as ``.models.Binder``, ``.models.Document`` and ``.models.Resource``.
[ "Adapts", ".", "epub", ".", "Package", "to", "a", "BinderItem", "and", "cascades", "the", "adaptation", "downward", "to", "DocumentItem", "and", "ResourceItem", ".", "The", "results", "of", "this", "process", "provide", "the", "same", "interface", "as", ".", ...
python
train
ellmetha/django-machina
machina/apps/forum_moderation/views.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_moderation/views.py#L267-L269
def post(self, request, *args, **kwargs): """ Handles POST requests. """ return self.update_type(request, *args, **kwargs)
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "update_type", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Handles POST requests.
[ "Handles", "POST", "requests", "." ]
python
train
saltstack/salt
salt/key.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/key.py#L518-L540
def list_keys(self): ''' Return a dict of managed keys and what the key status are ''' key_dirs = self._check_minions_directories() ret = {} for dir_ in key_dirs: if dir_ is None: continue ret[os.path.basename(dir_)] = [] ...
[ "def", "list_keys", "(", "self", ")", ":", "key_dirs", "=", "self", ".", "_check_minions_directories", "(", ")", "ret", "=", "{", "}", "for", "dir_", "in", "key_dirs", ":", "if", "dir_", "is", "None", ":", "continue", "ret", "[", "os", ".", "path", "...
Return a dict of managed keys and what the key status are
[ "Return", "a", "dict", "of", "managed", "keys", "and", "what", "the", "key", "status", "are" ]
python
train
DinoTools/python-overpy
overpy/__init__.py
https://github.com/DinoTools/python-overpy/blob/db8f80eeb1b4d1405816bd62c16ddb3364e0c46d/overpy/__init__.py#L1008-L1061
def from_xml(cls, child, result=None): """ Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject ...
[ "def", "from_xml", "(", "cls", ",", "child", ",", "result", "=", "None", ")", ":", "if", "child", ".", "tag", ".", "lower", "(", ")", "!=", "cls", ".", "_type_value", ":", "raise", "exception", ".", "ElementDataWrongType", "(", "type_expected", "=", "c...
Create new way element from XML data :param child: XML node to be parsed :type child: xml.etree.ElementTree.Element :param result: The result this node belongs to :type result: overpy.Result :return: New Way oject :rtype: overpy.Way :raises overpy.exception.Eleme...
[ "Create", "new", "way", "element", "from", "XML", "data" ]
python
train
square/connect-python-sdk
squareconnect/models/model_break.py
https://github.com/square/connect-python-sdk/blob/adc1d09e817986cdc607391580f71d6b48ed4066/squareconnect/models/model_break.py#L153-L167
def break_type_id(self, break_type_id): """ Sets the break_type_id of this ModelBreak. The `BreakType` this `Break` was templated on. :param break_type_id: The break_type_id of this ModelBreak. :type: str """ if break_type_id is None: raise ValueErro...
[ "def", "break_type_id", "(", "self", ",", "break_type_id", ")", ":", "if", "break_type_id", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `break_type_id`, must not be `None`\"", ")", "if", "len", "(", "break_type_id", ")", "<", "1", ":", "rai...
Sets the break_type_id of this ModelBreak. The `BreakType` this `Break` was templated on. :param break_type_id: The break_type_id of this ModelBreak. :type: str
[ "Sets", "the", "break_type_id", "of", "this", "ModelBreak", ".", "The", "BreakType", "this", "Break", "was", "templated", "on", "." ]
python
train
arista-eosplus/pyeapi
pyeapi/client.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/client.py#L546-L581
def config(self, commands, **kwargs): """Configures the node with the specified commands This method is used to send configuration commands to the node. It will take either a string or a list and prepend the necessary commands to put the session into config mode. Args: ...
[ "def", "config", "(", "self", ",", "commands", ",", "*", "*", "kwargs", ")", ":", "commands", "=", "make_iterable", "(", "commands", ")", "commands", "=", "list", "(", "commands", ")", "# push the configure command onto the command stack", "commands", ".", "inse...
Configures the node with the specified commands This method is used to send configuration commands to the node. It will take either a string or a list and prepend the necessary commands to put the session into config mode. Args: commands (str, list): The commands to send t...
[ "Configures", "the", "node", "with", "the", "specified", "commands" ]
python
train
awslabs/serverless-application-model
samtranslator/plugins/globals/globals.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/globals/globals.py#L286-L314
def _do_merge(self, global_value, local_value): """ Actually perform the merge operation for the given inputs. This method is used as part of the recursion. Therefore input values can be of any type. So is the output. :param global_value: Global value to be merged :param local_v...
[ "def", "_do_merge", "(", "self", ",", "global_value", ",", "local_value", ")", ":", "token_global", "=", "self", ".", "_token_of", "(", "global_value", ")", "token_local", "=", "self", ".", "_token_of", "(", "local_value", ")", "# The following statements codify t...
Actually perform the merge operation for the given inputs. This method is used as part of the recursion. Therefore input values can be of any type. So is the output. :param global_value: Global value to be merged :param local_value: Local value to be merged :return: Merged result
[ "Actually", "perform", "the", "merge", "operation", "for", "the", "given", "inputs", ".", "This", "method", "is", "used", "as", "part", "of", "the", "recursion", ".", "Therefore", "input", "values", "can", "be", "of", "any", "type", ".", "So", "is", "the...
python
train
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/database.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/database.py#L382-L391
def _fix_incoming(self, son, collection): """Apply manipulators to an incoming SON object before it gets stored. :Parameters: - `son`: the son object going into the database - `collection`: the collection the son object is being saved in """ son = self._apply_incomin...
[ "def", "_fix_incoming", "(", "self", ",", "son", ",", "collection", ")", ":", "son", "=", "self", ".", "_apply_incoming_manipulators", "(", "son", ",", "collection", ")", "son", "=", "self", ".", "_apply_incoming_copying_manipulators", "(", "son", ",", "collec...
Apply manipulators to an incoming SON object before it gets stored. :Parameters: - `son`: the son object going into the database - `collection`: the collection the son object is being saved in
[ "Apply", "manipulators", "to", "an", "incoming", "SON", "object", "before", "it", "gets", "stored", "." ]
python
train
gabstopper/smc-python
smc/elements/profiles.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/profiles.py#L259-L268
def create(cls, name, sandbox_data_center, portal_username=None, comment=None): """ Create a Sandbox Service element """ json = { 'name': name, 'sandbox_data_center': element_resolver(sandbox_data_center), 'portal_username': portal_username if portal_u...
[ "def", "create", "(", "cls", ",", "name", ",", "sandbox_data_center", ",", "portal_username", "=", "None", ",", "comment", "=", "None", ")", ":", "json", "=", "{", "'name'", ":", "name", ",", "'sandbox_data_center'", ":", "element_resolver", "(", "sandbox_da...
Create a Sandbox Service element
[ "Create", "a", "Sandbox", "Service", "element" ]
python
train
PythonCharmers/python-future
src/future/backports/http/server.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/http/server.py#L988-L991
def is_python(self, path): """Test whether argument path is a Python script.""" head, tail = os.path.splitext(path) return tail.lower() in (".py", ".pyw")
[ "def", "is_python", "(", "self", ",", "path", ")", ":", "head", ",", "tail", "=", "os", ".", "path", ".", "splitext", "(", "path", ")", "return", "tail", ".", "lower", "(", ")", "in", "(", "\".py\"", ",", "\".pyw\"", ")" ]
Test whether argument path is a Python script.
[ "Test", "whether", "argument", "path", "is", "a", "Python", "script", "." ]
python
train
tanghaibao/jcvi
jcvi/projects/str.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/projects/str.py#L1611-L1628
def get_lo_hi_from_CI(s, exclude=None): """ Parse the confidence interval from CI. >>> get_lo_hi_from_CI("20-20/40-60") (40, 60) """ a, b = s.split("|") ai, aj = a.split("-") bi, bj = b.split("-") los = [int(ai), int(bi)] his = [int(aj), int(bj)] if exclude and exclude in l...
[ "def", "get_lo_hi_from_CI", "(", "s", ",", "exclude", "=", "None", ")", ":", "a", ",", "b", "=", "s", ".", "split", "(", "\"|\"", ")", "ai", ",", "aj", "=", "a", ".", "split", "(", "\"-\"", ")", "bi", ",", "bj", "=", "b", ".", "split", "(", ...
Parse the confidence interval from CI. >>> get_lo_hi_from_CI("20-20/40-60") (40, 60)
[ "Parse", "the", "confidence", "interval", "from", "CI", "." ]
python
train
wummel/linkchecker
linkcheck/checker/urlbase.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/urlbase.py#L485-L497
def close_connection (self): """ Close an opened url connection. """ if self.url_connection is None: # no connection is open return try: self.url_connection.close() except Exception: # ignore close errors pass ...
[ "def", "close_connection", "(", "self", ")", ":", "if", "self", ".", "url_connection", "is", "None", ":", "# no connection is open", "return", "try", ":", "self", ".", "url_connection", ".", "close", "(", ")", "except", "Exception", ":", "# ignore close errors",...
Close an opened url connection.
[ "Close", "an", "opened", "url", "connection", "." ]
python
train
PyCQA/pylint
pylint/checkers/imports.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/imports.py#L473-L497
def visit_import(self, node): """triggered when an import statement is seen""" self._check_reimport(node) self._check_import_as_rename(node) modnode = node.root() names = [name for name, _ in node.names] if len(names) >= 2: self.add_message("multiple-imports"...
[ "def", "visit_import", "(", "self", ",", "node", ")", ":", "self", ".", "_check_reimport", "(", "node", ")", "self", ".", "_check_import_as_rename", "(", "node", ")", "modnode", "=", "node", ".", "root", "(", ")", "names", "=", "[", "name", "for", "nam...
triggered when an import statement is seen
[ "triggered", "when", "an", "import", "statement", "is", "seen" ]
python
test
apache/airflow
airflow/contrib/hooks/bigquery_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/bigquery_hook.py#L634-L853
def run_query(self, sql, destination_dataset_table=None, write_disposition='WRITE_EMPTY', allow_large_results=False, flatten_results=None, udf_config=None, use_legacy_sql=None, ...
[ "def", "run_query", "(", "self", ",", "sql", ",", "destination_dataset_table", "=", "None", ",", "write_disposition", "=", "'WRITE_EMPTY'", ",", "allow_large_results", "=", "False", ",", "flatten_results", "=", "None", ",", "udf_config", "=", "None", ",", "use_l...
Executes a BigQuery SQL query. Optionally persists results in a BigQuery table. See here: https://cloud.google.com/bigquery/docs/reference/v2/jobs For more details about these parameters. :param sql: The BigQuery SQL to execute. :type sql: str :param destination_datase...
[ "Executes", "a", "BigQuery", "SQL", "query", ".", "Optionally", "persists", "results", "in", "a", "BigQuery", "table", ".", "See", "here", ":" ]
python
test
hozn/stravalib
stravalib/model.py
https://github.com/hozn/stravalib/blob/5500ebc39e0bf4706bb1ca4c27b25e56becaaa5f/stravalib/model.py#L362-L375
def is_authenticated_athlete(self): """ :return: Boolean as to whether the athlete is the authenticated athlete. """ if self._is_authenticated is None: if self.resource_state == DETAILED: # If the athlete is in detailed state it must be the authenticated athle...
[ "def", "is_authenticated_athlete", "(", "self", ")", ":", "if", "self", ".", "_is_authenticated", "is", "None", ":", "if", "self", ".", "resource_state", "==", "DETAILED", ":", "# If the athlete is in detailed state it must be the authenticated athlete", "self", ".", "_...
:return: Boolean as to whether the athlete is the authenticated athlete.
[ ":", "return", ":", "Boolean", "as", "to", "whether", "the", "athlete", "is", "the", "authenticated", "athlete", "." ]
python
train
ssalentin/plip
plip/modules/preparation.py
https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L777-L800
def refine_hbonds_ldon(self, all_hbonds, salt_lneg, salt_pneg): """Refine selection of hydrogen bonds. Do not allow groups which already form salt bridges to form H-Bonds.""" i_set = {} for hbond in all_hbonds: i_set[hbond] = False for salt in salt_pneg: p...
[ "def", "refine_hbonds_ldon", "(", "self", ",", "all_hbonds", ",", "salt_lneg", ",", "salt_pneg", ")", ":", "i_set", "=", "{", "}", "for", "hbond", "in", "all_hbonds", ":", "i_set", "[", "hbond", "]", "=", "False", "for", "salt", "in", "salt_pneg", ":", ...
Refine selection of hydrogen bonds. Do not allow groups which already form salt bridges to form H-Bonds.
[ "Refine", "selection", "of", "hydrogen", "bonds", ".", "Do", "not", "allow", "groups", "which", "already", "form", "salt", "bridges", "to", "form", "H", "-", "Bonds", "." ]
python
train
yvesalexandre/bandicoot
bandicoot/weekmatrix.py
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/weekmatrix.py#L290-L307
def _find_weektime(datetime, time_type='min'): """ Finds the minutes/seconds aways from midnight between Sunday and Monday. Parameters ---------- datetime : datetime The date and time that needs to be converted. time_type : 'min' or 'sec' States whether the time difference shoul...
[ "def", "_find_weektime", "(", "datetime", ",", "time_type", "=", "'min'", ")", ":", "if", "time_type", "==", "'sec'", ":", "return", "datetime", ".", "weekday", "(", ")", "*", "24", "*", "60", "*", "60", "+", "datetime", ".", "hour", "*", "60", "*", ...
Finds the minutes/seconds aways from midnight between Sunday and Monday. Parameters ---------- datetime : datetime The date and time that needs to be converted. time_type : 'min' or 'sec' States whether the time difference should be specified in seconds or minutes.
[ "Finds", "the", "minutes", "/", "seconds", "aways", "from", "midnight", "between", "Sunday", "and", "Monday", "." ]
python
train
tensorflow/probability
tensorflow_probability/python/distributions/binomial.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/binomial.py#L43-L62
def _bdtr(k, n, p): """The binomial cumulative distribution function. Args: k: floating point `Tensor`. n: floating point `Tensor`. p: floating point `Tensor`. Returns: `sum_{j=0}^k p^j (1 - p)^(n - j)`. """ # Trick for getting safe backprop/gradients into n, k when # betainc(a = 0, ..) ...
[ "def", "_bdtr", "(", "k", ",", "n", ",", "p", ")", ":", "# Trick for getting safe backprop/gradients into n, k when", "# betainc(a = 0, ..) = nan", "# Write:", "# where(unsafe, safe_output, betainc(where(unsafe, safe_input, input)))", "ones", "=", "tf", ".", "ones_like", "(...
The binomial cumulative distribution function. Args: k: floating point `Tensor`. n: floating point `Tensor`. p: floating point `Tensor`. Returns: `sum_{j=0}^k p^j (1 - p)^(n - j)`.
[ "The", "binomial", "cumulative", "distribution", "function", "." ]
python
test
learningequality/ricecooker
ricecooker/classes/questions.py
https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/classes/questions.py#L229-L241
def validate(self): """ validate: Makes sure perseus question is valid Args: None Returns: boolean indicating if perseus question is valid """ try: assert self.question == "", "Assumption Failed: Perseus question should not have a question" assert ...
[ "def", "validate", "(", "self", ")", ":", "try", ":", "assert", "self", ".", "question", "==", "\"\"", ",", "\"Assumption Failed: Perseus question should not have a question\"", "assert", "self", ".", "question_type", "==", "exercises", ".", "PERSEUS_QUESTION", ",", ...
validate: Makes sure perseus question is valid Args: None Returns: boolean indicating if perseus question is valid
[ "validate", ":", "Makes", "sure", "perseus", "question", "is", "valid", "Args", ":", "None", "Returns", ":", "boolean", "indicating", "if", "perseus", "question", "is", "valid" ]
python
train
wummel/dosage
dosagelib/rss.py
https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/rss.py#L26-L30
def addElement(self, parent, tag, value): """Add an RSS item.""" elem = self.rss.createElement(tag) node = self.rss.createTextNode(value) return parent.appendChild(elem).appendChild(node)
[ "def", "addElement", "(", "self", ",", "parent", ",", "tag", ",", "value", ")", ":", "elem", "=", "self", ".", "rss", ".", "createElement", "(", "tag", ")", "node", "=", "self", ".", "rss", ".", "createTextNode", "(", "value", ")", "return", "parent"...
Add an RSS item.
[ "Add", "an", "RSS", "item", "." ]
python
train
nschloe/pygmsh
pygmsh/opencascade/geometry.py
https://github.com/nschloe/pygmsh/blob/1a1a07481aebe6c161b60dd31e0fbe1ddf330d61/pygmsh/opencascade/geometry.py#L163-L175
def boolean_intersection(self, entities, delete_first=True, delete_other=True): """Boolean intersection, see https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity and tool_entity are called object and tool in gmsh documentation. """ assert len(entities) > 1 ...
[ "def", "boolean_intersection", "(", "self", ",", "entities", ",", "delete_first", "=", "True", ",", "delete_other", "=", "True", ")", ":", "assert", "len", "(", "entities", ")", ">", "1", "return", "self", ".", "_boolean_operation", "(", "\"BooleanIntersection...
Boolean intersection, see https://gmsh.info/doc/texinfo/gmsh.html#Boolean-operations input_entity and tool_entity are called object and tool in gmsh documentation.
[ "Boolean", "intersection", "see", "https", ":", "//", "gmsh", ".", "info", "/", "doc", "/", "texinfo", "/", "gmsh", ".", "html#Boolean", "-", "operations", "input_entity", "and", "tool_entity", "are", "called", "object", "and", "tool", "in", "gmsh", "documen...
python
train
LogicalDash/LiSE
ELiDE/ELiDE/board/arrow.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/arrow.py#L407-L422
def pos_along(self, pct): """Return coordinates for where a Pawn should be if it has travelled along ``pct`` of my length (between 0 and 1). Might get complex when I switch over to using beziers for arrows, but for now this is quite simple, using distance along a line segment. ...
[ "def", "pos_along", "(", "self", ",", "pct", ")", ":", "if", "pct", "<", "0", "or", "pct", ">", "1", ":", "raise", "ValueError", "(", "\"Invalid portion\"", ")", "(", "ox", ",", "oy", ")", "=", "self", ".", "origin", ".", "center", "(", "dx", ","...
Return coordinates for where a Pawn should be if it has travelled along ``pct`` of my length (between 0 and 1). Might get complex when I switch over to using beziers for arrows, but for now this is quite simple, using distance along a line segment.
[ "Return", "coordinates", "for", "where", "a", "Pawn", "should", "be", "if", "it", "has", "travelled", "along", "pct", "of", "my", "length", "(", "between", "0", "and", "1", ")", "." ]
python
train
waqasbhatti/astrobase
astrobase/hatsurveys/hatlc.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/hatsurveys/hatlc.py#L1929-L2031
def main(): ''' This is called when we're executed from the commandline. The current usage from the command-line is described below:: usage: hatlc [-h] [--describe] hatlcfile read a HAT LC of any format and output to stdout positional arguments: hatlcfile path to the ...
[ "def", "main", "(", ")", ":", "# handle SIGPIPE sent by less, head, et al.", "import", "signal", "signal", ".", "signal", "(", "signal", ".", "SIGPIPE", ",", "signal", ".", "SIG_DFL", ")", "import", "argparse", "aparser", "=", "argparse", ".", "ArgumentParser", ...
This is called when we're executed from the commandline. The current usage from the command-line is described below:: usage: hatlc [-h] [--describe] hatlcfile read a HAT LC of any format and output to stdout positional arguments: hatlcfile path to the light curve you want to ...
[ "This", "is", "called", "when", "we", "re", "executed", "from", "the", "commandline", "." ]
python
valid
astropy/photutils
photutils/aperture/ellipse.py
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/aperture/ellipse.py#L26-L98
def to_mask(self, method='exact', subpixels=5): """ Return a list of `~photutils.ApertureMask` objects, one for each aperture position. Parameters ---------- method : {'exact', 'center', 'subpixel'}, optional The method used to determine the overlap of the ap...
[ "def", "to_mask", "(", "self", ",", "method", "=", "'exact'", ",", "subpixels", "=", "5", ")", ":", "use_exact", ",", "subpixels", "=", "self", ".", "_translate_mask_mode", "(", "method", ",", "subpixels", ")", "if", "hasattr", "(", "self", ",", "'a'", ...
Return a list of `~photutils.ApertureMask` objects, one for each aperture position. Parameters ---------- method : {'exact', 'center', 'subpixel'}, optional The method used to determine the overlap of the aperture on the pixel grid. Not all options are available...
[ "Return", "a", "list", "of", "~photutils", ".", "ApertureMask", "objects", "one", "for", "each", "aperture", "position", "." ]
python
train
fancybits/pychannels
pychannels/__init__.py
https://github.com/fancybits/pychannels/blob/080f269b6d17d4622a0787000befe31bebc1a15d/pychannels/__init__.py#L30-L53
def _request(self, method, path, params=None): """Make the actual request and returns the parsed response.""" url = self._base_url + path try: if method == 'GET': response = requests.get(url, timeout=TIMEOUT) elif method == "POST": respons...
[ "def", "_request", "(", "self", ",", "method", ",", "path", ",", "params", "=", "None", ")", ":", "url", "=", "self", ".", "_base_url", "+", "path", "try", ":", "if", "method", "==", "'GET'", ":", "response", "=", "requests", ".", "get", "(", "url"...
Make the actual request and returns the parsed response.
[ "Make", "the", "actual", "request", "and", "returns", "the", "parsed", "response", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xchart/xchart.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchart.py#L540-L551
def setHorizontalAxis(self, axis): """ Sets the horizontal axis for this chart. :param axis | <XChartAxis> """ self._horizontalAxis = axis if axis: axis.setOrientation(Qt.Horizontal) self.uiXAxisVIEW.setFixedHeight(axis.minim...
[ "def", "setHorizontalAxis", "(", "self", ",", "axis", ")", ":", "self", ".", "_horizontalAxis", "=", "axis", "if", "axis", ":", "axis", ".", "setOrientation", "(", "Qt", ".", "Horizontal", ")", "self", ".", "uiXAxisVIEW", ".", "setFixedHeight", "(", "axis"...
Sets the horizontal axis for this chart. :param axis | <XChartAxis>
[ "Sets", "the", "horizontal", "axis", "for", "this", "chart", ".", ":", "param", "axis", "|", "<XChartAxis", ">" ]
python
train
Nekroze/librarian
librarian/deck.py
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L86-L103
def contains_info(self, key, value): """ Returns how many cards in the deck have the specified value under the specified key in their info data. This method requires a library to be stored in the deck instance and will return `None` if there is no library. """ if...
[ "def", "contains_info", "(", "self", ",", "key", ",", "value", ")", ":", "if", "self", ".", "library", "is", "None", ":", "return", "0", "load", "=", "self", ".", "library", ".", "load_card", "matches", "=", "0", "for", "code", "in", "self", ".", "...
Returns how many cards in the deck have the specified value under the specified key in their info data. This method requires a library to be stored in the deck instance and will return `None` if there is no library.
[ "Returns", "how", "many", "cards", "in", "the", "deck", "have", "the", "specified", "value", "under", "the", "specified", "key", "in", "their", "info", "data", "." ]
python
train
twisted/axiom
axiom/store.py
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/store.py#L2066-L2081
def getTypeID(self, tableClass): """ Retrieve the typeID associated with a particular table in the in-database schema for this Store. A typeID is an opaque integer representing the Item subclass, and the associated table in this Store's SQLite database. @param tableClas...
[ "def", "getTypeID", "(", "self", ",", "tableClass", ")", ":", "key", "=", "(", "tableClass", ".", "typeName", ",", "tableClass", ".", "schemaVersion", ")", "if", "key", "in", "self", ".", "typenameAndVersionToID", ":", "return", "self", ".", "typenameAndVers...
Retrieve the typeID associated with a particular table in the in-database schema for this Store. A typeID is an opaque integer representing the Item subclass, and the associated table in this Store's SQLite database. @param tableClass: a subclass of Item @return: an integer
[ "Retrieve", "the", "typeID", "associated", "with", "a", "particular", "table", "in", "the", "in", "-", "database", "schema", "for", "this", "Store", ".", "A", "typeID", "is", "an", "opaque", "integer", "representing", "the", "Item", "subclass", "and", "the",...
python
train
simonw/datasette
datasette/app.py
https://github.com/simonw/datasette/blob/11b352b4d52fd02a422776edebb14f12e4994d3b/datasette/app.py#L414-L455
def inspect(self): " Inspect the database and return a dictionary of table metadata " if self._inspect: return self._inspect self._inspect = {} for filename in self.files: if filename is MEMORY: self._inspect[":memory:"] = { "h...
[ "def", "inspect", "(", "self", ")", ":", "if", "self", ".", "_inspect", ":", "return", "self", ".", "_inspect", "self", ".", "_inspect", "=", "{", "}", "for", "filename", "in", "self", ".", "files", ":", "if", "filename", "is", "MEMORY", ":", "self",...
Inspect the database and return a dictionary of table metadata
[ "Inspect", "the", "database", "and", "return", "a", "dictionary", "of", "table", "metadata" ]
python
train
pyviz/holoviews
holoviews/core/ndmapping.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/ndmapping.py#L152-L181
def _add_item(self, dim_vals, data, sort=True, update=True): """ Adds item to the data, applying dimension types and ensuring key conforms to Dimension type and values. """ sort = sort and self.sort if not isinstance(dim_vals, tuple): dim_vals = (dim_vals,) ...
[ "def", "_add_item", "(", "self", ",", "dim_vals", ",", "data", ",", "sort", "=", "True", ",", "update", "=", "True", ")", ":", "sort", "=", "sort", "and", "self", ".", "sort", "if", "not", "isinstance", "(", "dim_vals", ",", "tuple", ")", ":", "dim...
Adds item to the data, applying dimension types and ensuring key conforms to Dimension type and values.
[ "Adds", "item", "to", "the", "data", "applying", "dimension", "types", "and", "ensuring", "key", "conforms", "to", "Dimension", "type", "and", "values", "." ]
python
train
datastax/python-driver
cassandra/cluster.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cluster.py#L1721-L1728
def remove_host(self, host): """ Called when the control connection observes that a node has left the ring. Intended for internal use only. """ if host and self.metadata.remove_host(host): log.info("Cassandra host %s removed", host) self.on_remove(host)
[ "def", "remove_host", "(", "self", ",", "host", ")", ":", "if", "host", "and", "self", ".", "metadata", ".", "remove_host", "(", "host", ")", ":", "log", ".", "info", "(", "\"Cassandra host %s removed\"", ",", "host", ")", "self", ".", "on_remove", "(", ...
Called when the control connection observes that a node has left the ring. Intended for internal use only.
[ "Called", "when", "the", "control", "connection", "observes", "that", "a", "node", "has", "left", "the", "ring", ".", "Intended", "for", "internal", "use", "only", "." ]
python
train
user-cont/conu
conu/backend/podman/container.py
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L346-L354
def get_metadata(self): """ Convert dictionary returned after podman inspect command into instance of ContainerMetadata class :return: ContainerMetadata, container metadata instance """ if self._metadata is None: self._metadata = ContainerMetadata() inspect_to...
[ "def", "get_metadata", "(", "self", ")", ":", "if", "self", ".", "_metadata", "is", "None", ":", "self", ".", "_metadata", "=", "ContainerMetadata", "(", ")", "inspect_to_container_metadata", "(", "self", ".", "_metadata", ",", "self", ".", "inspect", "(", ...
Convert dictionary returned after podman inspect command into instance of ContainerMetadata class :return: ContainerMetadata, container metadata instance
[ "Convert", "dictionary", "returned", "after", "podman", "inspect", "command", "into", "instance", "of", "ContainerMetadata", "class", ":", "return", ":", "ContainerMetadata", "container", "metadata", "instance" ]
python
train
google/apitools
apitools/base/py/gzip.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/gzip.py#L612-L617
def decompress(data): """Decompress a gzip compressed string in one shot. Return the decompressed string. """ with GzipFile(fileobj=io.BytesIO(data)) as f: return f.read()
[ "def", "decompress", "(", "data", ")", ":", "with", "GzipFile", "(", "fileobj", "=", "io", ".", "BytesIO", "(", "data", ")", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Decompress a gzip compressed string in one shot. Return the decompressed string.
[ "Decompress", "a", "gzip", "compressed", "string", "in", "one", "shot", ".", "Return", "the", "decompressed", "string", "." ]
python
train