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
LogicalDash/LiSE
allegedb/allegedb/__init__.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/__init__.py#L409-L502
def get_turn_delta(self, branch=None, turn=None, tick_from=0, tick_to=None): """Get a dictionary describing changes made on a given turn. If ``tick_to`` is not supplied, report all changes after ``tick_from`` (default 0). The keys are graph names. Their values are dictionaries of the g...
[ "def", "get_turn_delta", "(", "self", ",", "branch", "=", "None", ",", "turn", "=", "None", ",", "tick_from", "=", "0", ",", "tick_to", "=", "None", ")", ":", "branch", "=", "branch", "or", "self", ".", "branch", "turn", "=", "turn", "or", "self", ...
Get a dictionary describing changes made on a given turn. If ``tick_to`` is not supplied, report all changes after ``tick_from`` (default 0). The keys are graph names. Their values are dictionaries of the graphs' attributes' new values, with ``None`` for deleted keys. Also in those gra...
[ "Get", "a", "dictionary", "describing", "changes", "made", "on", "a", "given", "turn", "." ]
python
train
CalebBell/fluids
fluids/core.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L879-L946
def Grashof(L, beta, T1, T2=0, rho=None, mu=None, nu=None, g=g): r'''Calculates Grashof number or `Gr` for a fluid with the given properties, temperature difference, and characteristic length. .. math:: Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2} = \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^...
[ "def", "Grashof", "(", "L", ",", "beta", ",", "T1", ",", "T2", "=", "0", ",", "rho", "=", "None", ",", "mu", "=", "None", ",", "nu", "=", "None", ",", "g", "=", "g", ")", ":", "if", "rho", "and", "mu", ":", "nu", "=", "mu", "/", "rho", ...
r'''Calculates Grashof number or `Gr` for a fluid with the given properties, temperature difference, and characteristic length. .. math:: Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2} = \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^2} Inputs either of any of the following sets: * L, beta, T...
[ "r", "Calculates", "Grashof", "number", "or", "Gr", "for", "a", "fluid", "with", "the", "given", "properties", "temperature", "difference", "and", "characteristic", "length", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xratingslider.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xratingslider.py#L129-L139
def setMaximum( self, value ): """ Sets the maximum value for this slider - this will also adjust the minimum size value to match the width of the icons by the number for the maximu. :param value | <int> """ super(XRatingSlider, self).setMaxi...
[ "def", "setMaximum", "(", "self", ",", "value", ")", ":", "super", "(", "XRatingSlider", ",", "self", ")", ".", "setMaximum", "(", "value", ")", "self", ".", "adjustMinimumWidth", "(", ")" ]
Sets the maximum value for this slider - this will also adjust the minimum size value to match the width of the icons by the number for the maximu. :param value | <int>
[ "Sets", "the", "maximum", "value", "for", "this", "slider", "-", "this", "will", "also", "adjust", "the", "minimum", "size", "value", "to", "match", "the", "width", "of", "the", "icons", "by", "the", "number", "for", "the", "maximu", ".", ":", "param", ...
python
train
saltstack/salt
salt/modules/boto_rds.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_rds.py#L736-L755
def delete_parameter_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an RDS parameter group. CLI example:: salt myminion boto_rds.delete_parameter_group my-param-group \ region=us-east-1 ''' try: conn = _get_conn(r...
[ "def", "delete_parameter_group", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "try", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", ...
Delete an RDS parameter group. CLI example:: salt myminion boto_rds.delete_parameter_group my-param-group \ region=us-east-1
[ "Delete", "an", "RDS", "parameter", "group", "." ]
python
train
twilio/twilio-python
twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/taskrouter/v1/workspace/worker/workers_statistics.py#L258-L284
def fetch(self, minutes=values.unset, start_date=values.unset, end_date=values.unset, task_queue_sid=values.unset, task_queue_name=values.unset, friendly_name=values.unset, task_channel=values.unset): """ Fetch a WorkersStatisticsInstance :param unicode...
[ "def", "fetch", "(", "self", ",", "minutes", "=", "values", ".", "unset", ",", "start_date", "=", "values", ".", "unset", ",", "end_date", "=", "values", ".", "unset", ",", "task_queue_sid", "=", "values", ".", "unset", ",", "task_queue_name", "=", "valu...
Fetch a WorkersStatisticsInstance :param unicode minutes: Filter cumulative statistics by up to 'x' minutes in the past. :param datetime start_date: Filter cumulative statistics by a start date. :param datetime end_date: Filter cumulative statistics by a end date. :param unicode task_qu...
[ "Fetch", "a", "WorkersStatisticsInstance" ]
python
train
shanbay/peeweext
peeweext/model.py
https://github.com/shanbay/peeweext/blob/ff62a3d01e4584d50fde1944b9616c3b4236ecf0/peeweext/model.py#L53-L59
def update_with(self, **query): """ secure update, mass assignment protected """ for k, v in self._filter_attrs(query).items(): setattr(self, k, v) return self.save()
[ "def", "update_with", "(", "self", ",", "*", "*", "query", ")", ":", "for", "k", ",", "v", "in", "self", ".", "_filter_attrs", "(", "query", ")", ".", "items", "(", ")", ":", "setattr", "(", "self", ",", "k", ",", "v", ")", "return", "self", "....
secure update, mass assignment protected
[ "secure", "update", "mass", "assignment", "protected" ]
python
train
jealous/stockstats
stockstats.py
https://github.com/jealous/stockstats/blob/a479a504ea1906955feeb8519c34ef40eb48ec9b/stockstats.py#L650-L661
def _get_kdjj(df, n_days): """ Get the J of KDJ J = 3K-2D :param df: data :param n_days: calculation range :return: None """ k_column = 'kdjk_{}'.format(n_days) d_column = 'kdjd_{}'.format(n_days) j_column = 'kdjj_{}'.format(n_days) ...
[ "def", "_get_kdjj", "(", "df", ",", "n_days", ")", ":", "k_column", "=", "'kdjk_{}'", ".", "format", "(", "n_days", ")", "d_column", "=", "'kdjd_{}'", ".", "format", "(", "n_days", ")", "j_column", "=", "'kdjj_{}'", ".", "format", "(", "n_days", ")", "...
Get the J of KDJ J = 3K-2D :param df: data :param n_days: calculation range :return: None
[ "Get", "the", "J", "of", "KDJ", "J", "=", "3K", "-", "2D", ":", "param", "df", ":", "data", ":", "param", "n_days", ":", "calculation", "range", ":", "return", ":", "None" ]
python
train
williamjameshandley/fgivenx
fgivenx/_utils.py
https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/_utils.py#L4-L61
def _check_args(logZ, f, x, samples, weights): """ Sanity-check the arguments for :func:`fgivenx.drivers.compute_samples`. Parameters ---------- f, x, samples, weights: see arguments for :func:`fgivenx.drivers.compute_samples` """ # convert to arrays if logZ is None: logZ = ...
[ "def", "_check_args", "(", "logZ", ",", "f", ",", "x", ",", "samples", ",", "weights", ")", ":", "# convert to arrays", "if", "logZ", "is", "None", ":", "logZ", "=", "[", "0", "]", "f", "=", "[", "f", "]", "samples", "=", "[", "samples", "]", "we...
Sanity-check the arguments for :func:`fgivenx.drivers.compute_samples`. Parameters ---------- f, x, samples, weights: see arguments for :func:`fgivenx.drivers.compute_samples`
[ "Sanity", "-", "check", "the", "arguments", "for", ":", "func", ":", "fgivenx", ".", "drivers", ".", "compute_samples", "." ]
python
train
kibitzr/kibitzr
kibitzr/storage.py
https://github.com/kibitzr/kibitzr/blob/749da312488f1dda1ed1093cf4c95aaac0a604f7/kibitzr/storage.py#L109-L142
def word(self): """Return last changes with word diff""" try: output = ensure_unicode(self.git.diff( '--no-color', '--word-diff=plain', 'HEAD~1:content', 'HEAD:content', ).stdout) except sh.ErrorReturnCode_12...
[ "def", "word", "(", "self", ")", ":", "try", ":", "output", "=", "ensure_unicode", "(", "self", ".", "git", ".", "diff", "(", "'--no-color'", ",", "'--word-diff=plain'", ",", "'HEAD~1:content'", ",", "'HEAD:content'", ",", ")", ".", "stdout", ")", "except"...
Return last changes with word diff
[ "Return", "last", "changes", "with", "word", "diff" ]
python
train
brocade/pynos
pynos/versions/base/interface.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/interface.py#L2874-L2887
def get_vlan_brief_request(last_vlan_id): """ Creates a new Netconf request based on the last received vlan id when the hasMore flag is true """ request_interface = ET.Element( 'get-vlan-brief', xmlns="urn:brocade.com:mgmt:brocade-interface-ext" ) ...
[ "def", "get_vlan_brief_request", "(", "last_vlan_id", ")", ":", "request_interface", "=", "ET", ".", "Element", "(", "'get-vlan-brief'", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocade-interface-ext\"", ")", "if", "last_vlan_id", "!=", "''", ":", "last_received_int_e...
Creates a new Netconf request based on the last received vlan id when the hasMore flag is true
[ "Creates", "a", "new", "Netconf", "request", "based", "on", "the", "last", "received", "vlan", "id", "when", "the", "hasMore", "flag", "is", "true" ]
python
train
thorgate/tg-react
tg_react/language.py
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L28-L36
def get_catalog(self, locale): """Create Django translation catalogue for `locale`.""" with translation.override(locale): translation_engine = DjangoTranslation(locale, domain=self.domain, localedirs=self.paths) trans_cat = translation_engine._catalog trans_fallback_...
[ "def", "get_catalog", "(", "self", ",", "locale", ")", ":", "with", "translation", ".", "override", "(", "locale", ")", ":", "translation_engine", "=", "DjangoTranslation", "(", "locale", ",", "domain", "=", "self", ".", "domain", ",", "localedirs", "=", "...
Create Django translation catalogue for `locale`.
[ "Create", "Django", "translation", "catalogue", "for", "locale", "." ]
python
train
genialis/resolwe
resolwe/flow/management/commands/collecttools.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/collecttools.py#L76-L84
def clear_dir(self): """Delete contents of the directory on the given path.""" self.stdout.write("Deleting contents of '{}'.".format(self.destination_path)) for filename in os.listdir(self.destination_path): if os.path.isfile(filename) or os.path.islink(filename): os...
[ "def", "clear_dir", "(", "self", ")", ":", "self", ".", "stdout", ".", "write", "(", "\"Deleting contents of '{}'.\"", ".", "format", "(", "self", ".", "destination_path", ")", ")", "for", "filename", "in", "os", ".", "listdir", "(", "self", ".", "destinat...
Delete contents of the directory on the given path.
[ "Delete", "contents", "of", "the", "directory", "on", "the", "given", "path", "." ]
python
train
pycontribs/pyrax
pyrax/base_identity.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/base_identity.py#L497-L503
def _read_credential_file(self, cfg): """ Implements the default (keystone) behavior. """ self.username = cfg.get("keystone", "username") self.password = cfg.get("keystone", "password", raw=True) self.tenant_id = cfg.get("keystone", "tenant_id")
[ "def", "_read_credential_file", "(", "self", ",", "cfg", ")", ":", "self", ".", "username", "=", "cfg", ".", "get", "(", "\"keystone\"", ",", "\"username\"", ")", "self", ".", "password", "=", "cfg", ".", "get", "(", "\"keystone\"", ",", "\"password\"", ...
Implements the default (keystone) behavior.
[ "Implements", "the", "default", "(", "keystone", ")", "behavior", "." ]
python
train
gwastro/pycbc-glue
pycbc_glue/pipeline.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/pipeline.py#L1167-L1177
def add_output_file(self, filename): """ Add filename as a output file for this DAG node. @param filename: output filename to add """ if filename not in self.__output_files: self.__output_files.append(filename) if not isinstance(self.job(), CondorDAGManJob): if self.job().get_un...
[ "def", "add_output_file", "(", "self", ",", "filename", ")", ":", "if", "filename", "not", "in", "self", ".", "__output_files", ":", "self", ".", "__output_files", ".", "append", "(", "filename", ")", "if", "not", "isinstance", "(", "self", ".", "job", "...
Add filename as a output file for this DAG node. @param filename: output filename to add
[ "Add", "filename", "as", "a", "output", "file", "for", "this", "DAG", "node", "." ]
python
train
CityOfZion/neo-python
neo/Core/State/StorageItem.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/StorageItem.py#L51-L59
def Deserialize(self, reader): """ Deserialize full object. Args: reader (neocore.IO.BinaryReader): """ super(StorageItem, self).Deserialize(reader) self.Value = reader.ReadVarBytes()
[ "def", "Deserialize", "(", "self", ",", "reader", ")", ":", "super", "(", "StorageItem", ",", "self", ")", ".", "Deserialize", "(", "reader", ")", "self", ".", "Value", "=", "reader", ".", "ReadVarBytes", "(", ")" ]
Deserialize full object. Args: reader (neocore.IO.BinaryReader):
[ "Deserialize", "full", "object", "." ]
python
train
InfoAgeTech/django-core
django_core/utils/urls.py
https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/utils/urls.py#L99-L128
def get_query_values_from_url(url, keys=None): """Gets query string values from a url. if a list of keys are provided, then a dict will be returned. If only a single string key is provided, then only a single value will be returned. >>> url = 'http://helloworld.com/some/path?test=5&hello=world&john=d...
[ "def", "get_query_values_from_url", "(", "url", ",", "keys", "=", "None", ")", ":", "if", "not", "url", "or", "'?'", "not", "in", "url", ":", "# no query params", "return", "None", "parsed_url", "=", "urlparse", "(", "url", ")", "query", "=", "dict", "("...
Gets query string values from a url. if a list of keys are provided, then a dict will be returned. If only a single string key is provided, then only a single value will be returned. >>> url = 'http://helloworld.com/some/path?test=5&hello=world&john=doe' >>> get_query_values_from_url(url=url, keys='t...
[ "Gets", "query", "string", "values", "from", "a", "url", "." ]
python
train
totalgood/pugnlp
src/pugnlp/stats.py
https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/stats.py#L227-L240
def confusion(df, labels=['neg', 'pos']): """ Binary classification confusion """ c = pd.DataFrame(np.zeros((2, 2)), dtype=int) a, b = df.columns[:2] # labels[df.columns[:2]] c.columns = sorted(set(df[a]))[:2] c.columns.name = a c.index = list(c.columns) c.index.name = b c1, c2 = c.colu...
[ "def", "confusion", "(", "df", ",", "labels", "=", "[", "'neg'", ",", "'pos'", "]", ")", ":", "c", "=", "pd", ".", "DataFrame", "(", "np", ".", "zeros", "(", "(", "2", ",", "2", ")", ")", ",", "dtype", "=", "int", ")", "a", ",", "b", "=", ...
Binary classification confusion
[ "Binary", "classification", "confusion" ]
python
train
jck/kya
scripts/link_pyqt.py
https://github.com/jck/kya/blob/377361a336691612ce1b86cc36dda3ab8b079789/scripts/link_pyqt.py#L16-L22
def link_pyqt(sys_python, venv_python): """Symlink the systemwide PyQt/sip into the venv.""" real_site = site_dir(sys_python) venv_site = site_dir(venv_python) for f in ['sip.so', 'PyQt5']: (venv_site/f).symlink_to(real_site/f)
[ "def", "link_pyqt", "(", "sys_python", ",", "venv_python", ")", ":", "real_site", "=", "site_dir", "(", "sys_python", ")", "venv_site", "=", "site_dir", "(", "venv_python", ")", "for", "f", "in", "[", "'sip.so'", ",", "'PyQt5'", "]", ":", "(", "venv_site",...
Symlink the systemwide PyQt/sip into the venv.
[ "Symlink", "the", "systemwide", "PyQt", "/", "sip", "into", "the", "venv", "." ]
python
train
cmbruns/pyopenvr
src/openvr/__init__.py
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L2718-L2746
def getOutputDevice(self, textureType): """ * Returns platform- and texture-type specific adapter identification so that applications and the compositor are creating textures and swap chains on the same GPU. If an error occurs the device will be set to 0. pInstance is an optional...
[ "def", "getOutputDevice", "(", "self", ",", "textureType", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getOutputDevice", "pnDevice", "=", "c_uint64", "(", ")", "pInstance", "=", "VkInstance_T", "(", ")", "fn", "(", "byref", "(", "pnDevice", "...
* Returns platform- and texture-type specific adapter identification so that applications and the compositor are creating textures and swap chains on the same GPU. If an error occurs the device will be set to 0. pInstance is an optional parameter that is required only when textureType is Texture...
[ "*", "Returns", "platform", "-", "and", "texture", "-", "type", "specific", "adapter", "identification", "so", "that", "applications", "and", "the", "compositor", "are", "creating", "textures", "and", "swap", "chains", "on", "the", "same", "GPU", ".", "If", ...
python
train
wind-python/windpowerlib
windpowerlib/wind_farm.py
https://github.com/wind-python/windpowerlib/blob/421b316139743311b7cb68a69f6b53d2665f7e23/windpowerlib/wind_farm.py#L160-L302
def assign_power_curve(self, wake_losses_model='power_efficiency_curve', smoothing=False, block_width=0.5, standard_deviation_method='turbulence_intensity', smoothing_order='wind_farm_power_curves', turbulence_in...
[ "def", "assign_power_curve", "(", "self", ",", "wake_losses_model", "=", "'power_efficiency_curve'", ",", "smoothing", "=", "False", ",", "block_width", "=", "0.5", ",", "standard_deviation_method", "=", "'turbulence_intensity'", ",", "smoothing_order", "=", "'wind_farm...
r""" Calculates the power curve of a wind farm. The wind farm power curve is calculated by aggregating the power curves of all wind turbines in the wind farm. Depending on the parameters the power curves are smoothed (before or after the aggregation) and/or a wind farm efficienc...
[ "r", "Calculates", "the", "power", "curve", "of", "a", "wind", "farm", "." ]
python
train
apache/spark
python/pyspark/rdd.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/rdd.py#L2159-L2184
def zipWithIndex(self): """ Zips this RDD with its element indices. The ordering is first based on the partition index and then the ordering of items within each partition. So the first item in the first partition gets index 0, and the last item in the last partition rec...
[ "def", "zipWithIndex", "(", "self", ")", ":", "starts", "=", "[", "0", "]", "if", "self", ".", "getNumPartitions", "(", ")", ">", "1", ":", "nums", "=", "self", ".", "mapPartitions", "(", "lambda", "it", ":", "[", "sum", "(", "1", "for", "i", "in...
Zips this RDD with its element indices. The ordering is first based on the partition index and then the ordering of items within each partition. So the first item in the first partition gets index 0, and the last item in the last partition receives the largest index. This metho...
[ "Zips", "this", "RDD", "with", "its", "element", "indices", "." ]
python
train
VisTrails/tej
tej/submission.py
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L209-L218
def _connect(self): """Connects via SSH. """ ssh = self._ssh_client() logger.debug("Connecting with %s", ', '.join('%s=%r' % (k, v if k != "password" else "***") for k, v in iteritems(self.destination))) ssh.connect(**self.desti...
[ "def", "_connect", "(", "self", ")", ":", "ssh", "=", "self", ".", "_ssh_client", "(", ")", "logger", ".", "debug", "(", "\"Connecting with %s\"", ",", "', '", ".", "join", "(", "'%s=%r'", "%", "(", "k", ",", "v", "if", "k", "!=", "\"password\"", "el...
Connects via SSH.
[ "Connects", "via", "SSH", "." ]
python
train
programa-stic/barf-project
barf/analysis/gadgets/finder.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/analysis/gadgets/finder.py#L307-L325
def _build_gadgets_rec(self, gadget_tree_root): """Build a gadgets from a gadgets tree. """ root = gadget_tree_root.get_root() children = gadget_tree_root.get_children() node_list = [] root_gadget_ins = root if not children: node_list += [[root_gadg...
[ "def", "_build_gadgets_rec", "(", "self", ",", "gadget_tree_root", ")", ":", "root", "=", "gadget_tree_root", ".", "get_root", "(", ")", "children", "=", "gadget_tree_root", ".", "get_children", "(", ")", "node_list", "=", "[", "]", "root_gadget_ins", "=", "ro...
Build a gadgets from a gadgets tree.
[ "Build", "a", "gadgets", "from", "a", "gadgets", "tree", "." ]
python
train
edx/i18n-tools
i18n/transifex.py
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L91-L100
def pull_all_rtl(configuration): """ Pulls all translations - reviewed or not - for RTL languages """ print("Pulling all translated RTL languages from transifex...") for lang in configuration.rtl_langs: print('rm -rf conf/locale/' + lang) execute('rm -rf conf/locale/' + lang) ...
[ "def", "pull_all_rtl", "(", "configuration", ")", ":", "print", "(", "\"Pulling all translated RTL languages from transifex...\"", ")", "for", "lang", "in", "configuration", ".", "rtl_langs", ":", "print", "(", "'rm -rf conf/locale/'", "+", "lang", ")", "execute", "("...
Pulls all translations - reviewed or not - for RTL languages
[ "Pulls", "all", "translations", "-", "reviewed", "or", "not", "-", "for", "RTL", "languages" ]
python
train
google/grumpy
third_party/pythonparser/parser.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1050-L1075
def import_from(self, from_loc, module_name, import_loc, names): """ (2.6, 2.7) import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) (3.0-) # note below: the ('.' | '...') is necessary because '...' is to...
[ "def", "import_from", "(", "self", ",", "from_loc", ",", "module_name", ",", "import_loc", ",", "names", ")", ":", "(", "dots_loc", ",", "dots_count", ")", ",", "dotted_name_opt", "=", "module_name", "module_loc", "=", "module", "=", "None", "if", "dotted_na...
(2.6, 2.7) import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) (3.0-) # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS import_from: ('from' (('.' | '...')* dotted_name | ('.' |...
[ "(", "2", ".", "6", "2", ".", "7", ")", "import_from", ":", "(", "from", "(", ".", "*", "dotted_name", "|", ".", "+", ")", "import", "(", "*", "|", "(", "import_as_names", ")", "|", "import_as_names", "))", "(", "3", ".", "0", "-", ")", "#", ...
python
valid
hazelcast/hazelcast-python-client
hazelcast/proxy/transactional_set.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/transactional_set.py#L21-L29
def remove(self, item): """ Transactional implementation of :func:`Set.remove(item) <hazelcast.proxy.set.Set.remove>` :param item: (object), the specified item to be deleted. :return: (bool), ``true`` if item is remove successfully, ``false`` otherwise. """ check_not_non...
[ "def", "remove", "(", "self", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"item can't be none\"", ")", "return", "self", ".", "_encode_invoke", "(", "transactional_set_remove_codec", ",", "item", "=", "self", ".", "_to_data", "(", "item", ")",...
Transactional implementation of :func:`Set.remove(item) <hazelcast.proxy.set.Set.remove>` :param item: (object), the specified item to be deleted. :return: (bool), ``true`` if item is remove successfully, ``false`` otherwise.
[ "Transactional", "implementation", "of", ":", "func", ":", "Set", ".", "remove", "(", "item", ")", "<hazelcast", ".", "proxy", ".", "set", ".", "Set", ".", "remove", ">" ]
python
train
google/transitfeed
transitfeed/util.py
https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/util.py#L549-L562
def writerow(self, row): """Write row to the csv file. Any unicode strings in row are encoded as utf-8.""" encoded_row = [] for s in row: if isinstance(s, unicode): encoded_row.append(s.encode("utf-8")) else: encoded_row.append(s) try: self.writer.writerow(encoded_r...
[ "def", "writerow", "(", "self", ",", "row", ")", ":", "encoded_row", "=", "[", "]", "for", "s", "in", "row", ":", "if", "isinstance", "(", "s", ",", "unicode", ")", ":", "encoded_row", ".", "append", "(", "s", ".", "encode", "(", "\"utf-8\"", ")", ...
Write row to the csv file. Any unicode strings in row are encoded as utf-8.
[ "Write", "row", "to", "the", "csv", "file", ".", "Any", "unicode", "strings", "in", "row", "are", "encoded", "as", "utf", "-", "8", "." ]
python
train
google/grr
grr/server/grr_response_server/rdfvalues/objects.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/rdfvalues/objects.py#L428-L443
def GetParent(self): """Constructs a path info corresponding to the parent of current path. The root path (represented by an empty list of components, corresponds to `/` on Unix-like systems) does not have a parent. Returns: Instance of `rdf_objects.PathInfo` or `None` if parent does not exist. ...
[ "def", "GetParent", "(", "self", ")", ":", "if", "self", ".", "root", ":", "return", "None", "return", "PathInfo", "(", "components", "=", "self", ".", "components", "[", ":", "-", "1", "]", ",", "path_type", "=", "self", ".", "path_type", ",", "dire...
Constructs a path info corresponding to the parent of current path. The root path (represented by an empty list of components, corresponds to `/` on Unix-like systems) does not have a parent. Returns: Instance of `rdf_objects.PathInfo` or `None` if parent does not exist.
[ "Constructs", "a", "path", "info", "corresponding", "to", "the", "parent", "of", "current", "path", "." ]
python
train
squaresLab/BugZoo
bugzoo/mgr/container.py
https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L446-L484
def copy_to(self, container: Container, fn_host: str, fn_container: str ) -> None: """ Copies a file from the host machine to a specified location inside a container. Raises: FileNotFound: if the host file wasn'...
[ "def", "copy_to", "(", "self", ",", "container", ":", "Container", ",", "fn_host", ":", "str", ",", "fn_container", ":", "str", ")", "->", "None", ":", "logger", ".", "debug", "(", "\"Copying file to container, %s: %s -> %s\"", ",", "container", ".", "uid", ...
Copies a file from the host machine to a specified location inside a container. Raises: FileNotFound: if the host file wasn't found. subprocess.CalledProcessError: if the file could not be copied to the container.
[ "Copies", "a", "file", "from", "the", "host", "machine", "to", "a", "specified", "location", "inside", "a", "container", "." ]
python
train
fananimi/pyzk
zk/base.py
https://github.com/fananimi/pyzk/blob/1a765d616526efdcb4c9adfcc9b1d10f6ed8b938/zk/base.py#L639-L650
def free_data(self): """ clear buffer :return: bool """ command = const.CMD_FREE_DATA cmd_response = self.__send_command(command) if cmd_response.get('status'): return True else: raise ZKErrorResponse("can't free data")
[ "def", "free_data", "(", "self", ")", ":", "command", "=", "const", ".", "CMD_FREE_DATA", "cmd_response", "=", "self", ".", "__send_command", "(", "command", ")", "if", "cmd_response", ".", "get", "(", "'status'", ")", ":", "return", "True", "else", ":", ...
clear buffer :return: bool
[ "clear", "buffer" ]
python
train
MonashBI/arcana
arcana/pipeline/base.py
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L783-L825
def _make_outputnode(self, frequency): """ Generates an output node for the given frequency. It also adds implicit file format conversion nodes to the pipeline. Parameters ---------- frequency : str The frequency (i.e. 'per_session', 'per_visit', 'per_subject...
[ "def", "_make_outputnode", "(", "self", ",", "frequency", ")", ":", "# Check to see whether there are any outputs for the given frequency", "outputs", "=", "list", "(", "self", ".", "frequency_outputs", "(", "frequency", ")", ")", "if", "not", "outputs", ":", "raise",...
Generates an output node for the given frequency. It also adds implicit file format conversion nodes to the pipeline. Parameters ---------- frequency : str The frequency (i.e. 'per_session', 'per_visit', 'per_subject' or 'per_study') of the output node to retriev...
[ "Generates", "an", "output", "node", "for", "the", "given", "frequency", ".", "It", "also", "adds", "implicit", "file", "format", "conversion", "nodes", "to", "the", "pipeline", "." ]
python
train
aws/aws-encryption-sdk-python
examples/src/basic_encryption.py
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/examples/src/basic_encryption.py#L17-L47
def cycle_string(key_arn, source_plaintext, botocore_session=None): """Encrypts and then decrypts a string under a KMS customer master key (CMK). :param str key_arn: Amazon Resource Name (ARN) of the KMS CMK :param bytes source_plaintext: Data to encrypt :param botocore_session: existing botocore sessi...
[ "def", "cycle_string", "(", "key_arn", ",", "source_plaintext", ",", "botocore_session", "=", "None", ")", ":", "# Create a KMS master key provider", "kms_kwargs", "=", "dict", "(", "key_ids", "=", "[", "key_arn", "]", ")", "if", "botocore_session", "is", "not", ...
Encrypts and then decrypts a string under a KMS customer master key (CMK). :param str key_arn: Amazon Resource Name (ARN) of the KMS CMK :param bytes source_plaintext: Data to encrypt :param botocore_session: existing botocore session instance :type botocore_session: botocore.session.Session
[ "Encrypts", "and", "then", "decrypts", "a", "string", "under", "a", "KMS", "customer", "master", "key", "(", "CMK", ")", "." ]
python
train
eternnoir/pyTelegramBotAPI
telebot/__init__.py
https://github.com/eternnoir/pyTelegramBotAPI/blob/47b53b88123097f1b9562a6cd5d4e080b86185d1/telebot/__init__.py#L613-L620
def delete_message(self, chat_id, message_id): """ Use this method to delete message. Returns True on success. :param chat_id: in which chat to delete :param message_id: which message to delete :return: API reply. """ return apihelper.delete_message(self.token, ch...
[ "def", "delete_message", "(", "self", ",", "chat_id", ",", "message_id", ")", ":", "return", "apihelper", ".", "delete_message", "(", "self", ".", "token", ",", "chat_id", ",", "message_id", ")" ]
Use this method to delete message. Returns True on success. :param chat_id: in which chat to delete :param message_id: which message to delete :return: API reply.
[ "Use", "this", "method", "to", "delete", "message", ".", "Returns", "True", "on", "success", ".", ":", "param", "chat_id", ":", "in", "which", "chat", "to", "delete", ":", "param", "message_id", ":", "which", "message", "to", "delete", ":", "return", ":"...
python
train
iotile/coretools
iotilecore/iotile/core/utilities/kvstore_json.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/kvstore_json.py#L107-L119
def remove(self, key): """Remove a key from the data store Args: key (string): The key to remove Raises: KeyError: if the key was not found """ data = self._load_file() del data[key] self._save_file(data)
[ "def", "remove", "(", "self", ",", "key", ")", ":", "data", "=", "self", ".", "_load_file", "(", ")", "del", "data", "[", "key", "]", "self", ".", "_save_file", "(", "data", ")" ]
Remove a key from the data store Args: key (string): The key to remove Raises: KeyError: if the key was not found
[ "Remove", "a", "key", "from", "the", "data", "store" ]
python
train
pantsbuild/pants
pants-plugins/src/python/internal_backend/sitegen/tasks/sitegen.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/pants-plugins/src/python/internal_backend/sitegen/tasks/sitegen.py#L153-L161
def precompute(config, soups): """Return info we want to compute (and preserve) before we mutate things.""" show_toc = config.get('show_toc', {}) page = {} pantsrefs = precompute_pantsrefs(soups) for p, soup in soups.items(): title = get_title(soup) or p page[p] = PrecomputedPageInfo(title=title, show...
[ "def", "precompute", "(", "config", ",", "soups", ")", ":", "show_toc", "=", "config", ".", "get", "(", "'show_toc'", ",", "{", "}", ")", "page", "=", "{", "}", "pantsrefs", "=", "precompute_pantsrefs", "(", "soups", ")", "for", "p", ",", "soup", "in...
Return info we want to compute (and preserve) before we mutate things.
[ "Return", "info", "we", "want", "to", "compute", "(", "and", "preserve", ")", "before", "we", "mutate", "things", "." ]
python
train
ska-sa/katcp-python
katcp/resource_client.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L458-L488
def set_sampling_strategies(self, filter, strategy_and_parms): """Set a strategy for all sensors matching the filter, including unseen sensors The strategy should persist across sensor disconnect/reconnect. filter : str Filter for sensor names strategy_and_params : seq of st...
[ "def", "set_sampling_strategies", "(", "self", ",", "filter", ",", "strategy_and_parms", ")", ":", "sensor_list", "=", "yield", "self", ".", "list_sensors", "(", "filter", "=", "filter", ")", "sensor_dict", "=", "{", "}", "for", "sens", "in", "sensor_list", ...
Set a strategy for all sensors matching the filter, including unseen sensors The strategy should persist across sensor disconnect/reconnect. filter : str Filter for sensor names strategy_and_params : seq of str or str As tuple contains (<strat_name>, [<strat_parm1>, ...]...
[ "Set", "a", "strategy", "for", "all", "sensors", "matching", "the", "filter", "including", "unseen", "sensors", "The", "strategy", "should", "persist", "across", "sensor", "disconnect", "/", "reconnect", "." ]
python
train
HiPERCAM/hcam_widgets
hcam_widgets/widgets.py
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L749-L755
def set(self, num): """ Sets current value to num """ if self.validate(num) is not None: self.index = self.allowed.index(num) IntegerEntry.set(self, num)
[ "def", "set", "(", "self", ",", "num", ")", ":", "if", "self", ".", "validate", "(", "num", ")", "is", "not", "None", ":", "self", ".", "index", "=", "self", ".", "allowed", ".", "index", "(", "num", ")", "IntegerEntry", ".", "set", "(", "self", ...
Sets current value to num
[ "Sets", "current", "value", "to", "num" ]
python
train
juztin/flask-tracy
flask_tracy/base.py
https://github.com/juztin/flask-tracy/blob/8a43094f0fced3c216f7b65ad6c5c7a22c14ea25/flask_tracy/base.py#L76-L107
def _after(self, response): """Calculates the request duration, and adds a transaction ID to the header. """ # Ignore excluded routes. if getattr(request, '_tracy_exclude', False): return response duration = None if getattr(request, '_tracy_start_time...
[ "def", "_after", "(", "self", ",", "response", ")", ":", "# Ignore excluded routes.", "if", "getattr", "(", "request", ",", "'_tracy_exclude'", ",", "False", ")", ":", "return", "response", "duration", "=", "None", "if", "getattr", "(", "request", ",", "'_tr...
Calculates the request duration, and adds a transaction ID to the header.
[ "Calculates", "the", "request", "duration", "and", "adds", "a", "transaction", "ID", "to", "the", "header", "." ]
python
valid
rehandalal/therapist
therapist/utils/filesystem.py
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/utils/filesystem.py#L14-L23
def list_files(path): """Recursively collects a list of files at a path.""" files = [] if os.path.isdir(path): for stats in os.walk(path): for f in stats[2]: files.append(os.path.join(stats[0], f)) elif os.path.isfile(path): files = [path] return files
[ "def", "list_files", "(", "path", ")", ":", "files", "=", "[", "]", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "for", "stats", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "f", "in", "stats", "[", "2", "]", ":", ...
Recursively collects a list of files at a path.
[ "Recursively", "collects", "a", "list", "of", "files", "at", "a", "path", "." ]
python
train
pyopenapi/pyswagger
pyswagger/spec/base.py
https://github.com/pyopenapi/pyswagger/blob/333c4ca08e758cd2194943d9904a3eda3fe43977/pyswagger/spec/base.py#L217-L236
def _assign_parent(self, ctx): """ parent assignment, internal usage only """ def _assign(cls, _, obj): if obj == None: return if cls.is_produced(obj): if isinstance(obj, BaseObj): obj._parent__ = self else:...
[ "def", "_assign_parent", "(", "self", ",", "ctx", ")", ":", "def", "_assign", "(", "cls", ",", "_", ",", "obj", ")", ":", "if", "obj", "==", "None", ":", "return", "if", "cls", ".", "is_produced", "(", "obj", ")", ":", "if", "isinstance", "(", "o...
parent assignment, internal usage only
[ "parent", "assignment", "internal", "usage", "only" ]
python
train
opereto/pyopereto
pyopereto/client.py
https://github.com/opereto/pyopereto/blob/16ca987738a7e1b82b52b0b099794a74ed557223/pyopereto/client.py#L1148-L1159
def get_process_rca(self, pid=None): ''' get_process_rca(self, pid=None) Get the RCA tree of a given failed process. The RCA tree contains all failed child processes that caused the failure of the given process. :Parameters: * *pid* (`string`) -- Identifier of an existing proce...
[ "def", "get_process_rca", "(", "self", ",", "pid", "=", "None", ")", ":", "pid", "=", "self", ".", "_get_pid", "(", "pid", ")", "return", "self", ".", "_call_rest_api", "(", "'get'", ",", "'/processes/'", "+", "pid", "+", "'/rca'", ",", "error", "=", ...
get_process_rca(self, pid=None) Get the RCA tree of a given failed process. The RCA tree contains all failed child processes that caused the failure of the given process. :Parameters: * *pid* (`string`) -- Identifier of an existing process
[ "get_process_rca", "(", "self", "pid", "=", "None", ")" ]
python
train
spry-group/python-vultr
vultr/v1_server.py
https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_server.py#L63-L74
def halt(self, subid, params=None): ''' /v1/server/halt POST - account Halt a virtual machine. This is a hard power off (basically, unplugging the machine). The data on the machine will not be modified, and you will still be billed for the machine. To completely delete a ...
[ "def", "halt", "(", "self", ",", "subid", ",", "params", "=", "None", ")", ":", "params", "=", "update_params", "(", "params", ",", "{", "'SUBID'", ":", "subid", "}", ")", "return", "self", ".", "request", "(", "'/v1/server/halt'", ",", "params", ",", ...
/v1/server/halt POST - account Halt a virtual machine. This is a hard power off (basically, unplugging the machine). The data on the machine will not be modified, and you will still be billed for the machine. To completely delete a machine, see v1/server/destroy Link: ht...
[ "/", "v1", "/", "server", "/", "halt", "POST", "-", "account", "Halt", "a", "virtual", "machine", ".", "This", "is", "a", "hard", "power", "off", "(", "basically", "unplugging", "the", "machine", ")", ".", "The", "data", "on", "the", "machine", "will",...
python
train
zhanglab/psamm
psamm/commands/fluxcheck.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/fluxcheck.py#L62-L157
def run(self): """Run flux consistency check command""" # Load compound information def compound_name(id): if id not in self._model.compounds: return id return self._model.compounds[id].properties.get('name', id) epsilon = self._args.epsilon ...
[ "def", "run", "(", "self", ")", ":", "# Load compound information", "def", "compound_name", "(", "id", ")", ":", "if", "id", "not", "in", "self", ".", "_model", ".", "compounds", ":", "return", "id", "return", "self", ".", "_model", ".", "compounds", "["...
Run flux consistency check command
[ "Run", "flux", "consistency", "check", "command" ]
python
train
s1s1ty/py-jsonq
pyjsonq/query.py
https://github.com/s1s1ty/py-jsonq/blob/9625597a2578bddcbed4e540174d5253b1fc3b75/pyjsonq/query.py#L411-L427
def group_by(self, property): """Getting the grouped result by the given property :@param property :@type property: string :@return self """ self.__prepare() group_data = {} for data in self._json_data: if data[property] not in group_data: ...
[ "def", "group_by", "(", "self", ",", "property", ")", ":", "self", ".", "__prepare", "(", ")", "group_data", "=", "{", "}", "for", "data", "in", "self", ".", "_json_data", ":", "if", "data", "[", "property", "]", "not", "in", "group_data", ":", "grou...
Getting the grouped result by the given property :@param property :@type property: string :@return self
[ "Getting", "the", "grouped", "result", "by", "the", "given", "property" ]
python
train
load-tools/netort
netort/resource.py
https://github.com/load-tools/netort/blob/b5233a70cea74108857ea24ba5c37975057ca00f/netort/resource.py#L85-L102
def get_opener(self, path): """ Args: path: str, resource file url or resource file absolute/relative path. Returns: file object """ self.path = path opener = None # FIXME this parser/matcher should use `urlparse` stdlib for opener...
[ "def", "get_opener", "(", "self", ",", "path", ")", ":", "self", ".", "path", "=", "path", "opener", "=", "None", "# FIXME this parser/matcher should use `urlparse` stdlib", "for", "opener_name", ",", "signature", "in", "self", ".", "openers", ".", "items", "(",...
Args: path: str, resource file url or resource file absolute/relative path. Returns: file object
[ "Args", ":", "path", ":", "str", "resource", "file", "url", "or", "resource", "file", "absolute", "/", "relative", "path", "." ]
python
train
m32/endesive
endesive/pdf/fpdf/fpdf.py
https://github.com/m32/endesive/blob/973091dc69847fe2df594c80ac9235a8d08460ff/endesive/pdf/fpdf/fpdf.py#L329-L337
def set_fill_color(self,r,g=-1,b=-1): "Set color for all filling operations" if((r==0 and g==0 and b==0) or g==-1): self.fill_color=sprintf('%.3f g',r/255.0) else: self.fill_color=sprintf('%.3f %.3f %.3f rg',r/255.0,g/255.0,b/255.0) self.color_flag=(self.fill_colo...
[ "def", "set_fill_color", "(", "self", ",", "r", ",", "g", "=", "-", "1", ",", "b", "=", "-", "1", ")", ":", "if", "(", "(", "r", "==", "0", "and", "g", "==", "0", "and", "b", "==", "0", ")", "or", "g", "==", "-", "1", ")", ":", "self", ...
Set color for all filling operations
[ "Set", "color", "for", "all", "filling", "operations" ]
python
train
ArduPilot/MAVProxy
MAVProxy/tools/MAVExplorer.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/tools/MAVExplorer.py#L279-L290
def flightmode_colours(): '''return mapping of flight mode to colours''' from MAVProxy.modules.lib.grapher import flightmode_colours mapping = {} idx = 0 for (mode,t0,t1) in flightmodes: if not mode in mapping: mapping[mode] = flightmode_colours[idx] idx += 1 ...
[ "def", "flightmode_colours", "(", ")", ":", "from", "MAVProxy", ".", "modules", ".", "lib", ".", "grapher", "import", "flightmode_colours", "mapping", "=", "{", "}", "idx", "=", "0", "for", "(", "mode", ",", "t0", ",", "t1", ")", "in", "flightmodes", "...
return mapping of flight mode to colours
[ "return", "mapping", "of", "flight", "mode", "to", "colours" ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/plugins/do_symfix.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/plugins/do_symfix.py#L35-L37
def do(self, arg): ".symfix - Set the default Microsoft Symbol Store settings if missing" self.debug.system.fix_symbol_store_path(remote = True, force = False)
[ "def", "do", "(", "self", ",", "arg", ")", ":", "self", ".", "debug", ".", "system", ".", "fix_symbol_store_path", "(", "remote", "=", "True", ",", "force", "=", "False", ")" ]
.symfix - Set the default Microsoft Symbol Store settings if missing
[ ".", "symfix", "-", "Set", "the", "default", "Microsoft", "Symbol", "Store", "settings", "if", "missing" ]
python
train
twisted/vertex
vertex/q2qclient.py
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2qclient.py#L321-L343
def enregister(svc, newAddress, password): """ Register a new account and return a Deferred that fires if it worked. @param svc: a Q2QService @param newAddress: a Q2QAddress object @param password: a shared secret (str) """ return svc.connectQ2Q(q2q.Q2QAddress("",""), ...
[ "def", "enregister", "(", "svc", ",", "newAddress", ",", "password", ")", ":", "return", "svc", ".", "connectQ2Q", "(", "q2q", ".", "Q2QAddress", "(", "\"\"", ",", "\"\"", ")", ",", "q2q", ".", "Q2QAddress", "(", "newAddress", ".", "domain", ",", "\"ac...
Register a new account and return a Deferred that fires if it worked. @param svc: a Q2QService @param newAddress: a Q2QAddress object @param password: a shared secret (str)
[ "Register", "a", "new", "account", "and", "return", "a", "Deferred", "that", "fires", "if", "it", "worked", "." ]
python
train
mitsei/dlkit
dlkit/services/commenting.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/commenting.py#L1225-L1233
def get_comment_form(self, *args, **kwargs): """Pass through to provider CommentAdminSession.get_comment_form_for_update""" # Implemented from kitosid template for - # osid.resource.ResourceAdminSession.get_resource_form_for_update # This method might be a bit sketchy. Time will tell. ...
[ "def", "get_comment_form", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Implemented from kitosid template for -", "# osid.resource.ResourceAdminSession.get_resource_form_for_update", "# This method might be a bit sketchy. Time will tell.", "if", "isinstance"...
Pass through to provider CommentAdminSession.get_comment_form_for_update
[ "Pass", "through", "to", "provider", "CommentAdminSession", ".", "get_comment_form_for_update" ]
python
train
iotile/coretools
iotilegateway/iotilegateway/supervisor/service_manager.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/service_manager.py#L103-L134
def add_service(self, name, long_name, preregistered=False, notify=True): """Add a service to the list of tracked services. Args: name (string): A unique short service name for the service long_name (string): A longer, user friendly name for the service preregistered...
[ "def", "add_service", "(", "self", ",", "name", ",", "long_name", ",", "preregistered", "=", "False", ",", "notify", "=", "True", ")", ":", "if", "name", "in", "self", ".", "services", ":", "raise", "ArgumentError", "(", "\"Could not add service because the lo...
Add a service to the list of tracked services. Args: name (string): A unique short service name for the service long_name (string): A longer, user friendly name for the service preregistered (bool): Whether this service is an expected preregistered service. ...
[ "Add", "a", "service", "to", "the", "list", "of", "tracked", "services", "." ]
python
train
swistakm/graceful
src/graceful/authentication.py
https://github.com/swistakm/graceful/blob/d4678cb6349a5c843a5e58002fc80140821609e4/src/graceful/authentication.py#L166-L171
def _get_storage_key(self, identified_with, identifier): """Get key string for given user identifier in consistent manner.""" return ':'.join(( self.key_prefix, identified_with.name, self.hash_identifier(identified_with, identifier), ))
[ "def", "_get_storage_key", "(", "self", ",", "identified_with", ",", "identifier", ")", ":", "return", "':'", ".", "join", "(", "(", "self", ".", "key_prefix", ",", "identified_with", ".", "name", ",", "self", ".", "hash_identifier", "(", "identified_with", ...
Get key string for given user identifier in consistent manner.
[ "Get", "key", "string", "for", "given", "user", "identifier", "in", "consistent", "manner", "." ]
python
train
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L796-L806
def _prepare_src_array(source_array, dtype): """Prepare `source_array` so that it can be used to construct NDArray. `source_array` is converted to a `np.ndarray` if it's neither an `NDArray` \ nor an `np.ndarray`. """ if not isinstance(source_array, NDArray) and not isinstance(source_array, np.ndarr...
[ "def", "_prepare_src_array", "(", "source_array", ",", "dtype", ")", ":", "if", "not", "isinstance", "(", "source_array", ",", "NDArray", ")", "and", "not", "isinstance", "(", "source_array", ",", "np", ".", "ndarray", ")", ":", "try", ":", "source_array", ...
Prepare `source_array` so that it can be used to construct NDArray. `source_array` is converted to a `np.ndarray` if it's neither an `NDArray` \ nor an `np.ndarray`.
[ "Prepare", "source_array", "so", "that", "it", "can", "be", "used", "to", "construct", "NDArray", ".", "source_array", "is", "converted", "to", "a", "np", ".", "ndarray", "if", "it", "s", "neither", "an", "NDArray", "\\", "nor", "an", "np", ".", "ndarray...
python
train
ArchiveTeam/wpull
wpull/processor/coprocessor/phantomjs.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/processor/coprocessor/phantomjs.py#L270-L295
def _add_warc_snapshot(self, filename, url): '''Add the snaphot to the WARC file.''' _logger.debug('Adding snapshot record.') extension = os.path.splitext(filename)[1] content_type = { '.pdf': 'application/pdf', '.html': 'text/html', '.png': 'image/pn...
[ "def", "_add_warc_snapshot", "(", "self", ",", "filename", ",", "url", ")", ":", "_logger", ".", "debug", "(", "'Adding snapshot record.'", ")", "extension", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", "content_type", "=",...
Add the snaphot to the WARC file.
[ "Add", "the", "snaphot", "to", "the", "WARC", "file", "." ]
python
train
jasonrbriggs/stomp.py
stomp/transport.py
https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/transport.py#L331-L370
def __receiver_loop(self): """ Main loop listening for incoming data. """ log.info("Starting receiver loop") notify_disconnected = True try: while self.running: try: while self.running: frames = self....
[ "def", "__receiver_loop", "(", "self", ")", ":", "log", ".", "info", "(", "\"Starting receiver loop\"", ")", "notify_disconnected", "=", "True", "try", ":", "while", "self", ".", "running", ":", "try", ":", "while", "self", ".", "running", ":", "frames", "...
Main loop listening for incoming data.
[ "Main", "loop", "listening", "for", "incoming", "data", "." ]
python
train
gem/oq-engine
openquake/hazardlib/geo/utils.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L428-L442
def get_middle_point(lon1, lat1, lon2, lat2): """ Given two points return the point exactly in the middle lying on the same great circle arc. Parameters are point coordinates in degrees. :returns: Tuple of longitude and latitude of the point in the middle. """ if lon1 == lon2 and l...
[ "def", "get_middle_point", "(", "lon1", ",", "lat1", ",", "lon2", ",", "lat2", ")", ":", "if", "lon1", "==", "lon2", "and", "lat1", "==", "lat2", ":", "return", "lon1", ",", "lat1", "dist", "=", "geodetic", ".", "geodetic_distance", "(", "lon1", ",", ...
Given two points return the point exactly in the middle lying on the same great circle arc. Parameters are point coordinates in degrees. :returns: Tuple of longitude and latitude of the point in the middle.
[ "Given", "two", "points", "return", "the", "point", "exactly", "in", "the", "middle", "lying", "on", "the", "same", "great", "circle", "arc", "." ]
python
train
saltstack/salt
salt/modules/ethtool.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ethtool.py#L199-L235
def set_coalesce(devname, **kwargs): ''' Changes the coalescing settings of the specified network device CLI Example: .. code-block:: bash salt '*' ethtool.set_coalesce <devname> [adaptive_rx=on|off] [adaptive_tx=on|off] [rx_usecs=N] [rx_frames=N] [rx_usecs_irq=N] [rx_frames_irq=N...
[ "def", "set_coalesce", "(", "devname", ",", "*", "*", "kwargs", ")", ":", "try", ":", "coalesce", "=", "ethtool", ".", "get_coalesce", "(", "devname", ")", "except", "IOError", ":", "log", ".", "error", "(", "'Interrupt coalescing not supported on %s'", ",", ...
Changes the coalescing settings of the specified network device CLI Example: .. code-block:: bash salt '*' ethtool.set_coalesce <devname> [adaptive_rx=on|off] [adaptive_tx=on|off] [rx_usecs=N] [rx_frames=N] [rx_usecs_irq=N] [rx_frames_irq=N] [tx_usecs=N] [tx_frames=N] [tx_usecs_irq=N] [tx...
[ "Changes", "the", "coalescing", "settings", "of", "the", "specified", "network", "device" ]
python
train
nicolargo/glances
glances/config.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L304-L309
def get_float_value(self, section, option, default=0.0): """Get the float value of an option, if it exists.""" try: return self.parser.getfloat(section, option) except NoOptionError: return float(default)
[ "def", "get_float_value", "(", "self", ",", "section", ",", "option", ",", "default", "=", "0.0", ")", ":", "try", ":", "return", "self", ".", "parser", ".", "getfloat", "(", "section", ",", "option", ")", "except", "NoOptionError", ":", "return", "float...
Get the float value of an option, if it exists.
[ "Get", "the", "float", "value", "of", "an", "option", "if", "it", "exists", "." ]
python
train
svenkreiss/pysparkling
pysparkling/streaming/dstream.py
https://github.com/svenkreiss/pysparkling/blob/596d0ef2793100f7115efe228ff9bfc17beaa08d/pysparkling/streaming/dstream.py#L94-L120
def countByValue(self): """Apply countByValue to every RDD.abs :rtype: DStream .. warning:: Implemented as a local operation. Example: >>> import pysparkling >>> sc = pysparkling.Context() >>> ssc = pysparkling.streaming.StreamingContext(sc, 0.1) ...
[ "def", "countByValue", "(", "self", ")", ":", "return", "self", ".", "transform", "(", "lambda", "rdd", ":", "self", ".", "_context", ".", "_context", ".", "parallelize", "(", "rdd", ".", "countByValue", "(", ")", ".", "items", "(", ")", ")", ")" ]
Apply countByValue to every RDD.abs :rtype: DStream .. warning:: Implemented as a local operation. Example: >>> import pysparkling >>> sc = pysparkling.Context() >>> ssc = pysparkling.streaming.StreamingContext(sc, 0.1) >>> ( ... ssc ...
[ "Apply", "countByValue", "to", "every", "RDD", ".", "abs" ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L253-L262
def normalize_array(q): """ Normalizes the list with len 4 so that it can be used as quaternion :param q: array of len 4 :returns: normalized array """ assert(len(q) == 4) q = np.array(q) n = QuaternionBase.norm_array(q) return q / n
[ "def", "normalize_array", "(", "q", ")", ":", "assert", "(", "len", "(", "q", ")", "==", "4", ")", "q", "=", "np", ".", "array", "(", "q", ")", "n", "=", "QuaternionBase", ".", "norm_array", "(", "q", ")", "return", "q", "/", "n" ]
Normalizes the list with len 4 so that it can be used as quaternion :param q: array of len 4 :returns: normalized array
[ "Normalizes", "the", "list", "with", "len", "4", "so", "that", "it", "can", "be", "used", "as", "quaternion", ":", "param", "q", ":", "array", "of", "len", "4", ":", "returns", ":", "normalized", "array" ]
python
train
kisom/pypcapfile
pcapfile/protocols/linklayer/wifi.py
https://github.com/kisom/pypcapfile/blob/67520cfbb6c2e9ab3e7c181a8012ddc56ec5cad8/pcapfile/protocols/linklayer/wifi.py#L1106-L1168
def strip_vht(self, idx): """strip(12 byte) radiotap.vht :idx: int :return: int idx :return: collections.namedtuple """ vht = collections.namedtuple( 'vht', ['known_bits', 'have_stbc', 'have_txop_ps', 'have_gi', 'have_sgi_nsym_d...
[ "def", "strip_vht", "(", "self", ",", "idx", ")", ":", "vht", "=", "collections", ".", "namedtuple", "(", "'vht'", ",", "[", "'known_bits'", ",", "'have_stbc'", ",", "'have_txop_ps'", ",", "'have_gi'", ",", "'have_sgi_nsym_da'", ",", "'have_ldpc_extra'", ",", ...
strip(12 byte) radiotap.vht :idx: int :return: int idx :return: collections.namedtuple
[ "strip", "(", "12", "byte", ")", "radiotap", ".", "vht", ":", "idx", ":", "int", ":", "return", ":", "int", "idx", ":", "return", ":", "collections", ".", "namedtuple" ]
python
valid
eyeseast/python-tablefu
table_fu/formatting.py
https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/formatting.py#L41-L54
def capfirst(value, failure_string='N/A'): """ Capitalizes the first character of the value. If the submitted value isn't a string, returns the `failure_string` keyword argument. Cribbs from django's default filter set """ try: value = value.lower() return value[0]....
[ "def", "capfirst", "(", "value", ",", "failure_string", "=", "'N/A'", ")", ":", "try", ":", "value", "=", "value", ".", "lower", "(", ")", "return", "value", "[", "0", "]", ".", "upper", "(", ")", "+", "value", "[", "1", ":", "]", "except", ":", ...
Capitalizes the first character of the value. If the submitted value isn't a string, returns the `failure_string` keyword argument. Cribbs from django's default filter set
[ "Capitalizes", "the", "first", "character", "of", "the", "value", ".", "If", "the", "submitted", "value", "isn", "t", "a", "string", "returns", "the", "failure_string", "keyword", "argument", ".", "Cribbs", "from", "django", "s", "default", "filter", "set" ]
python
train
SoftwareDefinedBuildings/XBOS
apps/Data_quality_analysis/Wrapper.py
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/Data_quality_analysis/Wrapper.py#L376-L436
def import_data(self, file_name='*', folder_name='.', head_row=0, index_col=0, convert_col=True, concat_files=False, save_file=True): """ Imports csv file(s) and stores the result in self.imported_data. Note ---- 1. If folder exists out of current directo...
[ "def", "import_data", "(", "self", ",", "file_name", "=", "'*'", ",", "folder_name", "=", "'.'", ",", "head_row", "=", "0", ",", "index_col", "=", "0", ",", "convert_col", "=", "True", ",", "concat_files", "=", "False", ",", "save_file", "=", "True", "...
Imports csv file(s) and stores the result in self.imported_data. Note ---- 1. If folder exists out of current directory, folder_name should contain correct regex 2. Assuming there's no file called "\*.csv" Parameters ---------- file_name : str ...
[ "Imports", "csv", "file", "(", "s", ")", "and", "stores", "the", "result", "in", "self", ".", "imported_data", ".", "Note", "----", "1", ".", "If", "folder", "exists", "out", "of", "current", "directory", "folder_name", "should", "contain", "correct", "reg...
python
train
sassoftware/saspy
saspy/sasiostdio.py
https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasiostdio.py#L1639-L1818
def sasdata2dataframeCSV(self, table: str, libref: str ='', dsopts: dict = None, tempfile: str=None, tempkeep: bool=False, **kwargs) -> '<Pandas Data Frame object>': """ This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. table - the name of the SAS Data Se...
[ "def", "sasdata2dataframeCSV", "(", "self", ",", "table", ":", "str", ",", "libref", ":", "str", "=", "''", ",", "dsopts", ":", "dict", "=", "None", ",", "tempfile", ":", "str", "=", "None", ",", "tempkeep", ":", "bool", "=", "False", ",", "*", "*"...
This method exports the SAS Data Set to a Pandas Data Frame, returning the Data Frame object. table - the name of the SAS Data Set you want to export to a Pandas Data Frame libref - the libref for the SAS Data Set. dsopts - data set options for the input SAS Data Set port - port to us...
[ "This", "method", "exports", "the", "SAS", "Data", "Set", "to", "a", "Pandas", "Data", "Frame", "returning", "the", "Data", "Frame", "object", ".", "table", "-", "the", "name", "of", "the", "SAS", "Data", "Set", "you", "want", "to", "export", "to", "a"...
python
train
CyberReboot/vent
vent/api/tools.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/api/tools.py#L685-L696
def _start_remaining_containers(self, containers_remaining, tool_d): """ Select remaining containers that didn't have priorities to start """ s_containers = [] f_containers = [] for container in containers_remaining: s_containers, f_containers = self._start_co...
[ "def", "_start_remaining_containers", "(", "self", ",", "containers_remaining", ",", "tool_d", ")", ":", "s_containers", "=", "[", "]", "f_containers", "=", "[", "]", "for", "container", "in", "containers_remaining", ":", "s_containers", ",", "f_containers", "=", ...
Select remaining containers that didn't have priorities to start
[ "Select", "remaining", "containers", "that", "didn", "t", "have", "priorities", "to", "start" ]
python
train
petrjasek/eve-elastic
eve_elastic/helpers.py
https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/helpers.py#L81-L137
def _process_bulk_chunk(client, bulk_actions, raise_on_exception=True, raise_on_error=True, **kwargs): """ Send a bulk request to elasticsearch and process the output. """ # if raise on error is set, we need to collect errors per chunk before raising them errors = [] try: # send the act...
[ "def", "_process_bulk_chunk", "(", "client", ",", "bulk_actions", ",", "raise_on_exception", "=", "True", ",", "raise_on_error", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# if raise on error is set, we need to collect errors per chunk before raising them", "errors", ...
Send a bulk request to elasticsearch and process the output.
[ "Send", "a", "bulk", "request", "to", "elasticsearch", "and", "process", "the", "output", "." ]
python
train
turicas/rows
rows/plugins/plugin_pdf.py
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/plugins/plugin_pdf.py#L446-L453
def selected_objects(self): """Filter out objects outside table boundaries""" return [ obj for obj in self.text_objects if contains_or_overlap(self.table_bbox, obj.bbox) ]
[ "def", "selected_objects", "(", "self", ")", ":", "return", "[", "obj", "for", "obj", "in", "self", ".", "text_objects", "if", "contains_or_overlap", "(", "self", ".", "table_bbox", ",", "obj", ".", "bbox", ")", "]" ]
Filter out objects outside table boundaries
[ "Filter", "out", "objects", "outside", "table", "boundaries" ]
python
train
sassoo/goldman
goldman/queryparams/fields.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/fields.py#L53-L76
def _validate_param(rtype, fields): """ Ensure the sparse fields exists on the models """ try: # raises ValueError if not found model = rtype_to_model(rtype) model_fields = model.all_fields except ValueError: raise InvalidQueryParams(**{ 'detail': 'The fields que...
[ "def", "_validate_param", "(", "rtype", ",", "fields", ")", ":", "try", ":", "# raises ValueError if not found", "model", "=", "rtype_to_model", "(", "rtype", ")", "model_fields", "=", "model", ".", "all_fields", "except", "ValueError", ":", "raise", "InvalidQuery...
Ensure the sparse fields exists on the models
[ "Ensure", "the", "sparse", "fields", "exists", "on", "the", "models" ]
python
train
saltstack/salt
salt/modules/out.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/out.py#L91-L115
def html_format(data, out='nested', opts=None, **kwargs): ''' Return the formatted string as HTML. data The JSON serializable object. out: ``nested`` The name of the output to use to transform the data. Default: ``nested``. opts Dictionary of configuration options. Default...
[ "def", "html_format", "(", "data", ",", "out", "=", "'nested'", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "opts", ":", "opts", "=", "__opts__", "return", "salt", ".", "output", ".", "html_format", "(", "data", ",", "...
Return the formatted string as HTML. data The JSON serializable object. out: ``nested`` The name of the output to use to transform the data. Default: ``nested``. opts Dictionary of configuration options. Default: ``__opts__``. kwargs Arguments to sent to the outputter...
[ "Return", "the", "formatted", "string", "as", "HTML", "." ]
python
train
yeraydiazdiaz/lunr.py
lunr/tokenizer.py
https://github.com/yeraydiazdiaz/lunr.py/blob/28ec3f6d4888295eed730211ee9617aa488d6ba3/lunr/tokenizer.py#L14-L59
def Tokenizer(obj, metadata=None, separator=SEPARATOR): """Splits a string into tokens ready to be inserted into the search index. This tokenizer will convert its parameter to a string by calling `str` and then will split this string on characters matching `separator`. Lists will have their elements co...
[ "def", "Tokenizer", "(", "obj", ",", "metadata", "=", "None", ",", "separator", "=", "SEPARATOR", ")", ":", "if", "obj", "is", "None", ":", "return", "[", "]", "metadata", "=", "metadata", "or", "{", "}", "if", "isinstance", "(", "obj", ",", "(", "...
Splits a string into tokens ready to be inserted into the search index. This tokenizer will convert its parameter to a string by calling `str` and then will split this string on characters matching `separator`. Lists will have their elements converted to strings and wrapped in a lunr `Token`. Opti...
[ "Splits", "a", "string", "into", "tokens", "ready", "to", "be", "inserted", "into", "the", "search", "index", "." ]
python
train
spyder-ide/spyder
spyder/config/gui.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L86-L92
def set_font(font, section='appearance', option='font'): """Set font""" CONF.set(section, option+'/family', to_text_string(font.family())) CONF.set(section, option+'/size', float(font.pointSize())) CONF.set(section, option+'/italic', int(font.italic())) CONF.set(section, option+'/bold', int(font.bol...
[ "def", "set_font", "(", "font", ",", "section", "=", "'appearance'", ",", "option", "=", "'font'", ")", ":", "CONF", ".", "set", "(", "section", ",", "option", "+", "'/family'", ",", "to_text_string", "(", "font", ".", "family", "(", ")", ")", ")", "...
Set font
[ "Set", "font" ]
python
train
tamasgal/km3pipe
km3pipe/stats.py
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/stats.py#L170-L187
def bootstrap_params(rv_cont, data, n_iter=5, **kwargs): """Bootstrap the fit params of a distribution. Parameters ========== rv_cont: scipy.stats.rv_continuous instance The distribution which to fit. data: array-like, 1d The data on which to fit. n_iter: int [default=10] ...
[ "def", "bootstrap_params", "(", "rv_cont", ",", "data", ",", "n_iter", "=", "5", ",", "*", "*", "kwargs", ")", ":", "fit_res", "=", "[", "]", "for", "_", "in", "range", "(", "n_iter", ")", ":", "params", "=", "rv_cont", ".", "fit", "(", "resample_1...
Bootstrap the fit params of a distribution. Parameters ========== rv_cont: scipy.stats.rv_continuous instance The distribution which to fit. data: array-like, 1d The data on which to fit. n_iter: int [default=10] Number of bootstrap iterations.
[ "Bootstrap", "the", "fit", "params", "of", "a", "distribution", "." ]
python
train
kislyuk/ensure
ensure/main.py
https://github.com/kislyuk/ensure/blob/0a562a4b469ffbaf71c75dc4d394e94334c831f0/ensure/main.py#L608-L616
def called_with(self, *args, **kwargs): """ Before evaluating subsequent predicates, calls :attr:`subject` with given arguments (but unlike a direct call, catches and transforms any exceptions that arise during the call). """ self._args = args self._kwargs = kwargs ...
[ "def", "called_with", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_args", "=", "args", "self", ".", "_kwargs", "=", "kwargs", "self", ".", "_call_subject", "=", "True", "return", "CallableInspector", "(", "self", ")"...
Before evaluating subsequent predicates, calls :attr:`subject` with given arguments (but unlike a direct call, catches and transforms any exceptions that arise during the call).
[ "Before", "evaluating", "subsequent", "predicates", "calls", ":", "attr", ":", "subject", "with", "given", "arguments", "(", "but", "unlike", "a", "direct", "call", "catches", "and", "transforms", "any", "exceptions", "that", "arise", "during", "the", "call", ...
python
train
mistio/mist.client
src/mistclient/model.py
https://github.com/mistio/mist.client/blob/bc190af2cba358fa556a69b205c12a77a34eb2a8/src/mistclient/model.py#L159-L167
def images(self): """ Available images to be used when creating a new machine. :returns: A list of all available images. """ req = self.request(self.mist_client.uri+'/clouds/'+self.id+'/images') images = req.get().json() return images
[ "def", "images", "(", "self", ")", ":", "req", "=", "self", ".", "request", "(", "self", ".", "mist_client", ".", "uri", "+", "'/clouds/'", "+", "self", ".", "id", "+", "'/images'", ")", "images", "=", "req", ".", "get", "(", ")", ".", "json", "(...
Available images to be used when creating a new machine. :returns: A list of all available images.
[ "Available", "images", "to", "be", "used", "when", "creating", "a", "new", "machine", "." ]
python
train
juju/charm-helpers
charmhelpers/core/host.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L1056-L1077
def install_ca_cert(ca_cert, name=None): """ Install the given cert as a trusted CA. The ``name`` is the stem of the filename where the cert is written, and if not provided, it will default to ``juju-{charm_name}``. If the cert is empty or None, or is unchanged, nothing is done. """ if not...
[ "def", "install_ca_cert", "(", "ca_cert", ",", "name", "=", "None", ")", ":", "if", "not", "ca_cert", ":", "return", "if", "not", "isinstance", "(", "ca_cert", ",", "bytes", ")", ":", "ca_cert", "=", "ca_cert", ".", "encode", "(", "'utf8'", ")", "if", ...
Install the given cert as a trusted CA. The ``name`` is the stem of the filename where the cert is written, and if not provided, it will default to ``juju-{charm_name}``. If the cert is empty or None, or is unchanged, nothing is done.
[ "Install", "the", "given", "cert", "as", "a", "trusted", "CA", "." ]
python
train
a1ezzz/wasp-general
wasp_general/network/clients/file.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/file.py#L114-L122
def make_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.make_directory` method implementation """ previous_path = self.session_path() try: self.session_path(directory_name) os.mkdir(self.full_path()) finally: self.session_path(previous_path)
[ "def", "make_directory", "(", "self", ",", "directory_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "previous_path", "=", "self", ".", "session_path", "(", ")", "try", ":", "self", ".", "session_path", "(", "directory_name", ")", "os", ".",...
:meth:`.WNetworkClientProto.make_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "make_directory", "method", "implementation" ]
python
train
bcbio/bcbio-nextgen
bcbio/rnaseq/gtf.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/gtf.py#L284-L305
def tx2genedict(gtf, keep_version=False): """ produce a tx2gene dictionary from a GTF file """ d = {} with open_gzipsafe(gtf) as in_handle: for line in in_handle: if "gene_id" not in line or "transcript_id" not in line: continue geneid = line.split("ge...
[ "def", "tx2genedict", "(", "gtf", ",", "keep_version", "=", "False", ")", ":", "d", "=", "{", "}", "with", "open_gzipsafe", "(", "gtf", ")", "as", "in_handle", ":", "for", "line", "in", "in_handle", ":", "if", "\"gene_id\"", "not", "in", "line", "or", ...
produce a tx2gene dictionary from a GTF file
[ "produce", "a", "tx2gene", "dictionary", "from", "a", "GTF", "file" ]
python
train
quantumlib/Cirq
cirq/contrib/acquaintance/executor.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/executor.py#L61-L65
def get_operations(self, indices: Sequence[LogicalIndex], qubits: Sequence[ops.Qid] ) -> ops.OP_TREE: """Gets the logical operations to apply to qubits."""
[ "def", "get_operations", "(", "self", ",", "indices", ":", "Sequence", "[", "LogicalIndex", "]", ",", "qubits", ":", "Sequence", "[", "ops", ".", "Qid", "]", ")", "->", "ops", ".", "OP_TREE", ":" ]
Gets the logical operations to apply to qubits.
[ "Gets", "the", "logical", "operations", "to", "apply", "to", "qubits", "." ]
python
train
nerdvegas/rez
src/rez/resolved_context.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/resolved_context.py#L1358-L1473
def from_dict(cls, d, identifier_str=None): """Load a `ResolvedContext` from a dict. Args: d (dict): Dict containing context data. identifier_str (str): String identifying the context, this is only used to display in an error string if a serialization version ...
[ "def", "from_dict", "(", "cls", ",", "d", ",", "identifier_str", "=", "None", ")", ":", "# check serialization version", "def", "_print_version", "(", "value", ")", ":", "return", "'.'", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "value", ...
Load a `ResolvedContext` from a dict. Args: d (dict): Dict containing context data. identifier_str (str): String identifying the context, this is only used to display in an error string if a serialization version mismatch is detected. Returns: ...
[ "Load", "a", "ResolvedContext", "from", "a", "dict", "." ]
python
train
happyleavesaoc/python-motorparts
motorparts/__init__.py
https://github.com/happyleavesaoc/python-motorparts/blob/4a6b4dc72dd45524dd64a7a079478bd98c55215c/motorparts/__init__.py#L168-L173
def _get_model(vehicle): """Clean the model field. Best guess.""" model = vehicle['model'] model = model.replace(vehicle['year'], '') model = model.replace(vehicle['make'], '') return model.strip().split(' ')[0]
[ "def", "_get_model", "(", "vehicle", ")", ":", "model", "=", "vehicle", "[", "'model'", "]", "model", "=", "model", ".", "replace", "(", "vehicle", "[", "'year'", "]", ",", "''", ")", "model", "=", "model", ".", "replace", "(", "vehicle", "[", "'make...
Clean the model field. Best guess.
[ "Clean", "the", "model", "field", ".", "Best", "guess", "." ]
python
train
limodou/uliweb
uliweb/orm/__init__.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/orm/__init__.py#L2677-L2693
def filter(self, *condition): """ If there are multple condition, then treats them *and* relastion. """ if not condition: return self cond = true() for c in condition: if c is not None: if isinstance(c, (str, unicode)): ...
[ "def", "filter", "(", "self", ",", "*", "condition", ")", ":", "if", "not", "condition", ":", "return", "self", "cond", "=", "true", "(", ")", "for", "c", "in", "condition", ":", "if", "c", "is", "not", "None", ":", "if", "isinstance", "(", "c", ...
If there are multple condition, then treats them *and* relastion.
[ "If", "there", "are", "multple", "condition", "then", "treats", "them", "*", "and", "*", "relastion", "." ]
python
train
ozgur/python-firebase
firebase/firebase.py
https://github.com/ozgur/python-firebase/blob/6b96b326f6d8f477503ca42fdfbd81bcbe1f9e0d/firebase/firebase.py#L319-L329
def post(self, url, data, params=None, headers=None, connection=None): """ Synchronous POST request. ``data`` must be a JSONable value. """ params = params or {} headers = headers or {} endpoint = self._build_endpoint_url(url, None) self._authenticate(params, head...
[ "def", "post", "(", "self", ",", "url", ",", "data", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "connection", "=", "None", ")", ":", "params", "=", "params", "or", "{", "}", "headers", "=", "headers", "or", "{", "}", "endpoint", ...
Synchronous POST request. ``data`` must be a JSONable value.
[ "Synchronous", "POST", "request", ".", "data", "must", "be", "a", "JSONable", "value", "." ]
python
valid
PythonCharmers/python-future
src/future/backports/email/message.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/message.py#L600-L620
def get_params(self, failobj=None, header='content-type', unquote=True): """Return the message's Content-Type parameters, as a list. The elements of the returned list are 2-tuples of key/value pairs, as split on the `=' sign. The left hand side of the `=' is the key, while the right ha...
[ "def", "get_params", "(", "self", ",", "failobj", "=", "None", ",", "header", "=", "'content-type'", ",", "unquote", "=", "True", ")", ":", "missing", "=", "object", "(", ")", "params", "=", "self", ".", "_get_params_preserve", "(", "missing", ",", "head...
Return the message's Content-Type parameters, as a list. The elements of the returned list are 2-tuples of key/value pairs, as split on the `=' sign. The left hand side of the `=' is the key, while the right hand side is the value. If there is no `=' sign in the parameter the value is...
[ "Return", "the", "message", "s", "Content", "-", "Type", "parameters", "as", "a", "list", "." ]
python
train
jkenlooper/chill
src/chill/migrations.py
https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/migrations.py#L10-L87
def migrate1(): "Migrate from version 0 to 1" initial = [ "create table Chill (version integer);", "insert into Chill (version) values (1);", "alter table SelectSQL rename to Query;", "alter table Node add column template integer references Template (id) on delete set null;", "alter table N...
[ "def", "migrate1", "(", ")", ":", "initial", "=", "[", "\"create table Chill (version integer);\"", ",", "\"insert into Chill (version) values (1);\"", ",", "\"alter table SelectSQL rename to Query;\"", ",", "\"alter table Node add column template integer references Template (id) on dele...
Migrate from version 0 to 1
[ "Migrate", "from", "version", "0", "to", "1" ]
python
train
bububa/pyTOP
pyTOP/campaign.py
https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/campaign.py#L456-L466
def recommend_get(self, adgroup_id, **kwargs): '''xxxxx.xxxxx.keywords.recommend.get =================================== 取得一个推广组的推荐关键词列表''' request = TOPRequest('xxxxx.xxxxx.keywords.recommend.get') request['adgroup_id'] = adgroup_id for k, v in kwargs.iteritems(): ...
[ "def", "recommend_get", "(", "self", ",", "adgroup_id", ",", "*", "*", "kwargs", ")", ":", "request", "=", "TOPRequest", "(", "'xxxxx.xxxxx.keywords.recommend.get'", ")", "request", "[", "'adgroup_id'", "]", "=", "adgroup_id", "for", "k", ",", "v", "in", "kw...
xxxxx.xxxxx.keywords.recommend.get =================================== 取得一个推广组的推荐关键词列表
[ "xxxxx", ".", "xxxxx", ".", "keywords", ".", "recommend", ".", "get", "===================================", "取得一个推广组的推荐关键词列表" ]
python
train
newville/wxmplot
wxmplot/plotframe.py
https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotframe.py#L45-L47
def scatterplot(self, x, y, **kw): """plot after clearing current plot """ self.panel.scatterplot(x, y, **kw)
[ "def", "scatterplot", "(", "self", ",", "x", ",", "y", ",", "*", "*", "kw", ")", ":", "self", ".", "panel", ".", "scatterplot", "(", "x", ",", "y", ",", "*", "*", "kw", ")" ]
plot after clearing current plot
[ "plot", "after", "clearing", "current", "plot" ]
python
train
yyuu/botornado
boto/ec2/autoscale/__init__.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/autoscale/__init__.py#L344-L359
def delete_scheduled_action(self, scheduled_action_name, autoscale_group=None): """ Deletes a previously scheduled action. :type scheduled_action_name: str :param scheduled_action_name: The name of the action you want to delete. :type...
[ "def", "delete_scheduled_action", "(", "self", ",", "scheduled_action_name", ",", "autoscale_group", "=", "None", ")", ":", "params", "=", "{", "'ScheduledActionName'", ":", "scheduled_action_name", "}", "if", "autoscale_group", ":", "params", "[", "'AutoScalingGroupN...
Deletes a previously scheduled action. :type scheduled_action_name: str :param scheduled_action_name: The name of the action you want to delete. :type autoscale_group: str :param autoscale_group: The name of the autoscale group.
[ "Deletes", "a", "previously", "scheduled", "action", "." ]
python
train
deepmind/pysc2
pysc2/lib/remote_controller.py
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/remote_controller.py#L248-L255
def actions(self, req_action): """Send a `sc_pb.RequestAction`, which may include multiple actions.""" if FLAGS.sc2_log_actions: for action in req_action.actions: sys.stderr.write(str(action)) sys.stderr.flush() return self._client.send(action=req_action)
[ "def", "actions", "(", "self", ",", "req_action", ")", ":", "if", "FLAGS", ".", "sc2_log_actions", ":", "for", "action", "in", "req_action", ".", "actions", ":", "sys", ".", "stderr", ".", "write", "(", "str", "(", "action", ")", ")", "sys", ".", "st...
Send a `sc_pb.RequestAction`, which may include multiple actions.
[ "Send", "a", "sc_pb", ".", "RequestAction", "which", "may", "include", "multiple", "actions", "." ]
python
train
arista-eosplus/pyeapi
pyeapi/api/routemaps.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/routemaps.py#L222-L257
def set_match_statements(self, name, action, seqno, statements): """Configures the match statements within the routemap clause. The final configuration of match statements will reflect the list of statements passed into the statements attribute. This implies match statements found in the...
[ "def", "set_match_statements", "(", "self", ",", "name", ",", "action", ",", "seqno", ",", "statements", ")", ":", "try", ":", "current_statements", "=", "self", ".", "get", "(", "name", ")", "[", "action", "]", "[", "seqno", "]", "[", "'match'", "]", ...
Configures the match statements within the routemap clause. The final configuration of match statements will reflect the list of statements passed into the statements attribute. This implies match statements found in the routemap that are not specified in the statements attribute will be...
[ "Configures", "the", "match", "statements", "within", "the", "routemap", "clause", ".", "The", "final", "configuration", "of", "match", "statements", "will", "reflect", "the", "list", "of", "statements", "passed", "into", "the", "statements", "attribute", ".", "...
python
train
user-cont/conu
conu/backend/docker/container.py
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/container.py#L378-L400
def get_port_mappings(self, port=None): """ Get list of port mappings between container and host. The format of dicts is: {"HostIp": XX, "HostPort": YY}; When port is None - return all port mappings. The container needs to be running, otherwise this returns an empty list. ...
[ "def", "get_port_mappings", "(", "self", ",", "port", "=", "None", ")", ":", "port_mappings", "=", "self", ".", "inspect", "(", "refresh", "=", "True", ")", "[", "\"NetworkSettings\"", "]", "[", "\"Ports\"", "]", "if", "not", "port", ":", "return", "port...
Get list of port mappings between container and host. The format of dicts is: {"HostIp": XX, "HostPort": YY}; When port is None - return all port mappings. The container needs to be running, otherwise this returns an empty list. :param port: int or None, container port :re...
[ "Get", "list", "of", "port", "mappings", "between", "container", "and", "host", ".", "The", "format", "of", "dicts", "is", ":" ]
python
train
benoitkugler/abstractDataLibrary
pyDLib/GUI/app.py
https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/app.py#L160-L172
def init_login(self, from_local=False): """Display login screen. May ask for local data loading if from_local is True.""" if self.toolbar: self.removeToolBar(self.toolbar) widget_login = login.Loading(self.statusBar(), self.theory_main) self.centralWidget().addWidget(widget_l...
[ "def", "init_login", "(", "self", ",", "from_local", "=", "False", ")", ":", "if", "self", ".", "toolbar", ":", "self", ".", "removeToolBar", "(", "self", ".", "toolbar", ")", "widget_login", "=", "login", ".", "Loading", "(", "self", ".", "statusBar", ...
Display login screen. May ask for local data loading if from_local is True.
[ "Display", "login", "screen", ".", "May", "ask", "for", "local", "data", "loading", "if", "from_local", "is", "True", "." ]
python
train
materialsproject/pymatgen
pymatgen/electronic_structure/plotter.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/plotter.py#L120-L214
def get_plot(self, xlim=None, ylim=None): """ Get a matplotlib plot showing the DOS. Args: xlim: Specifies the x-axis limits. Set to None for automatic determination. ylim: Specifies the y-axis limits. """ ncolors = max(3, len(self._doses...
[ "def", "get_plot", "(", "self", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ")", ":", "ncolors", "=", "max", "(", "3", ",", "len", "(", "self", ".", "_doses", ")", ")", "ncolors", "=", "min", "(", "9", ",", "ncolors", ")", "import", "pa...
Get a matplotlib plot showing the DOS. Args: xlim: Specifies the x-axis limits. Set to None for automatic determination. ylim: Specifies the y-axis limits.
[ "Get", "a", "matplotlib", "plot", "showing", "the", "DOS", "." ]
python
train
Kortemme-Lab/klab
klab/benchmarking/analysis/ddg_monomeric_stability_analysis.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/benchmarking/analysis/ddg_monomeric_stability_analysis.py#L464-L570
def create_dataframe(self, pdb_data = {}, verbose = True): '''This function creates a dataframe (a matrix with one row per dataset record and one column for fields of interest) from the benchmark run and the dataset data. For rows with multiple mutations, there may be multiple values for s...
[ "def", "create_dataframe", "(", "self", ",", "pdb_data", "=", "{", "}", ",", "verbose", "=", "True", ")", ":", "if", "self", ".", "use_existing_benchmark_data", "and", "self", ".", "store_data_on_disk", "and", "os", ".", "path", ".", "exists", "(", "self",...
This function creates a dataframe (a matrix with one row per dataset record and one column for fields of interest) from the benchmark run and the dataset data. For rows with multiple mutations, there may be multiple values for some fields e.g. wildtype residue exposure. We take the appr...
[ "This", "function", "creates", "a", "dataframe", "(", "a", "matrix", "with", "one", "row", "per", "dataset", "record", "and", "one", "column", "for", "fields", "of", "interest", ")", "from", "the", "benchmark", "run", "and", "the", "dataset", "data", ".", ...
python
train
WZBSocialScienceCenter/tmtoolkit
tmtoolkit/topicmod/model_stats.py
https://github.com/WZBSocialScienceCenter/tmtoolkit/blob/ca8b9d072e37ccc82b533f47d48bd9755722305b/tmtoolkit/topicmod/model_stats.py#L153-L166
def get_topic_word_relevance(topic_word_distrib, doc_topic_distrib, doc_lengths, lambda_): """ Calculate the topic-word relevance score with a lambda parameter `lambda_` according to Sievert and Shirley 2014. relevance(w,T|lambda) = lambda * log phi_{w,t} + (1-lambda) * log (phi_{w,t} / p(w)) with phi ...
[ "def", "get_topic_word_relevance", "(", "topic_word_distrib", ",", "doc_topic_distrib", ",", "doc_lengths", ",", "lambda_", ")", ":", "p_t", "=", "get_marginal_topic_distrib", "(", "doc_topic_distrib", ",", "doc_lengths", ")", "p_w", "=", "get_marginal_word_distrib", "(...
Calculate the topic-word relevance score with a lambda parameter `lambda_` according to Sievert and Shirley 2014. relevance(w,T|lambda) = lambda * log phi_{w,t} + (1-lambda) * log (phi_{w,t} / p(w)) with phi .. topic-word distribution p(w) .. marginal word probability
[ "Calculate", "the", "topic", "-", "word", "relevance", "score", "with", "a", "lambda", "parameter", "lambda_", "according", "to", "Sievert", "and", "Shirley", "2014", ".", "relevance", "(", "w", "T|lambda", ")", "=", "lambda", "*", "log", "phi_", "{", "w",...
python
train
titusjan/argos
argos/inspector/pgplugins/lineplot1d.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/lineplot1d.py#L106-L111
def setAutoRangeOn(self, axisNumber): """ Sets the auto-range of the axis on. :param axisNumber: 0 (X-axis), 1 (Y-axis), 2, (Both X and Y axes). """ setXYAxesAutoRangeOn(self, self.xAxisRangeCti, self.yAxisRangeCti, axisNumber)
[ "def", "setAutoRangeOn", "(", "self", ",", "axisNumber", ")", ":", "setXYAxesAutoRangeOn", "(", "self", ",", "self", ".", "xAxisRangeCti", ",", "self", ".", "yAxisRangeCti", ",", "axisNumber", ")" ]
Sets the auto-range of the axis on. :param axisNumber: 0 (X-axis), 1 (Y-axis), 2, (Both X and Y axes).
[ "Sets", "the", "auto", "-", "range", "of", "the", "axis", "on", "." ]
python
train
imjoey/pyhaproxy
pyhaproxy/render.py
https://github.com/imjoey/pyhaproxy/blob/4f0904acfc6bdb29ba6104ce2f6724c0330441d3/pyhaproxy/render.py#L103-L133
def __render_config_block(self, config_block): """Summary Args: config_block [config.Item, ...]: config lines Returns: str: config block str """ config_block_str = '' for line in config_block: if isinstance(line, config.Option): ...
[ "def", "__render_config_block", "(", "self", ",", "config_block", ")", ":", "config_block_str", "=", "''", "for", "line", "in", "config_block", ":", "if", "isinstance", "(", "line", ",", "config", ".", "Option", ")", ":", "line_str", "=", "self", ".", "__r...
Summary Args: config_block [config.Item, ...]: config lines Returns: str: config block str
[ "Summary" ]
python
train
jkenlooper/chill
src/chill/api.py
https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/api.py#L120-L154
def render_node(_node_id, value=None, noderequest={}, **kw): "Recursively render a node's value" if value == None: kw.update( noderequest ) results = _query(_node_id, **kw) current_app.logger.debug("results: %s", results) if results: values = [] for (resul...
[ "def", "render_node", "(", "_node_id", ",", "value", "=", "None", ",", "noderequest", "=", "{", "}", ",", "*", "*", "kw", ")", ":", "if", "value", "==", "None", ":", "kw", ".", "update", "(", "noderequest", ")", "results", "=", "_query", "(", "_nod...
Recursively render a node's value
[ "Recursively", "render", "a", "node", "s", "value" ]
python
train
ranaroussi/pywallet
pywallet/utils/bip32.py
https://github.com/ranaroussi/pywallet/blob/206ff224389c490d8798f660c9e79fe97ebb64cf/pywallet/utils/bip32.py#L501-L578
def deserialize(cls, key, network="bitcoin_testnet"): """Load the ExtendedBip32Key from a hex key. The key consists of * 4 byte version bytes (network key) * 1 byte depth: - 0x00 for master nodes, - 0x01 for level-1 descendants, .... ...
[ "def", "deserialize", "(", "cls", ",", "key", ",", "network", "=", "\"bitcoin_testnet\"", ")", ":", "network", "=", "Wallet", ".", "get_network", "(", "network", ")", "if", "len", "(", "key", ")", "in", "[", "78", ",", "(", "78", "+", "32", ")", "]...
Load the ExtendedBip32Key from a hex key. The key consists of * 4 byte version bytes (network key) * 1 byte depth: - 0x00 for master nodes, - 0x01 for level-1 descendants, .... * 4 byte fingerprint of the parent's key (0x00000000 if master ke...
[ "Load", "the", "ExtendedBip32Key", "from", "a", "hex", "key", "." ]
python
train
wagtail/django-modelcluster
modelcluster/models.py
https://github.com/wagtail/django-modelcluster/blob/bfc8bd755af0ddd49e2aee2f2ca126921573d38b/modelcluster/models.py#L135-L143
def get_all_child_m2m_relations(model): """ Return a list of ParentalManyToManyFields on the given model, including ones attached to ancestors of the model """ return [ field for field in model._meta.get_fields() if isinstance(field, ParentalManyToManyField) ]
[ "def", "get_all_child_m2m_relations", "(", "model", ")", ":", "return", "[", "field", "for", "field", "in", "model", ".", "_meta", ".", "get_fields", "(", ")", "if", "isinstance", "(", "field", ",", "ParentalManyToManyField", ")", "]" ]
Return a list of ParentalManyToManyFields on the given model, including ones attached to ancestors of the model
[ "Return", "a", "list", "of", "ParentalManyToManyFields", "on", "the", "given", "model", "including", "ones", "attached", "to", "ancestors", "of", "the", "model" ]
python
test
openstack/quark
quark/plugin_modules/mac_address_ranges.py
https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/mac_address_ranges.py#L120-L136
def delete_mac_address_range(context, id): """Delete a mac_address_range. : param context: neutron api request context : param id: UUID representing the mac_address_range to delete. """ LOG.info("delete_mac_address_range %s for tenant %s" % (id, context.tenant_id)) if not context.i...
[ "def", "delete_mac_address_range", "(", "context", ",", "id", ")", ":", "LOG", ".", "info", "(", "\"delete_mac_address_range %s for tenant %s\"", "%", "(", "id", ",", "context", ".", "tenant_id", ")", ")", "if", "not", "context", ".", "is_admin", ":", "raise",...
Delete a mac_address_range. : param context: neutron api request context : param id: UUID representing the mac_address_range to delete.
[ "Delete", "a", "mac_address_range", "." ]
python
valid