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
jimzhan/pyx
rex/core/system.py
https://github.com/jimzhan/pyx/blob/819e8251323a7923e196c0c438aa8524f5aaee6e/rex/core/system.py#L13-L27
def execute(command, cwd=os.path.curdir, **options): """ Run the system command with optional options. Args: * command: system command. * cwd: current working directory. * verbose: direct options for :func:`subprocess.Popen`. Returns: Opened process, standard output & e...
[ "def", "execute", "(", "command", ",", "cwd", "=", "os", ".", "path", ".", "curdir", ",", "*", "*", "options", ")", ":", "process", "=", "subprocess", ".", "Popen", "(", "shlex", ".", "split", "(", "command", ")", ",", "cwd", "=", "cwd", ",", "*"...
Run the system command with optional options. Args: * command: system command. * cwd: current working directory. * verbose: direct options for :func:`subprocess.Popen`. Returns: Opened process, standard output & error.
[ "Run", "the", "system", "command", "with", "optional", "options", "." ]
python
train
bwohlberg/sporco
docs/source/docntbk.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/docs/source/docntbk.py#L705-L738
def get_sphinx_ref(self, url, label=None): """ Get an internal sphinx cross reference corresponding to `url` into the online docs, associated with a link with label `label` (if not None). """ # Raise an exception if the initial part of url does not match # the ba...
[ "def", "get_sphinx_ref", "(", "self", ",", "url", ",", "label", "=", "None", ")", ":", "# Raise an exception if the initial part of url does not match", "# the base url for this object", "n", "=", "len", "(", "self", ".", "baseurl", ")", "if", "url", "[", "0", ":"...
Get an internal sphinx cross reference corresponding to `url` into the online docs, associated with a link with label `label` (if not None).
[ "Get", "an", "internal", "sphinx", "cross", "reference", "corresponding", "to", "url", "into", "the", "online", "docs", "associated", "with", "a", "link", "with", "label", "label", "(", "if", "not", "None", ")", "." ]
python
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/bridge.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/bridge.py#L100-L108
def remove_nio(self, nio): """ Removes the specified NIO as member of this bridge. :param nio: NIO instance to remove """ if self._hypervisor: yield from self._hypervisor.send('nio_bridge remove_nio "{name}" {nio}'.format(name=self._name, nio=nio)) self._nios...
[ "def", "remove_nio", "(", "self", ",", "nio", ")", ":", "if", "self", ".", "_hypervisor", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'nio_bridge remove_nio \"{name}\" {nio}'", ".", "format", "(", "name", "=", "self", ".", "_name", ...
Removes the specified NIO as member of this bridge. :param nio: NIO instance to remove
[ "Removes", "the", "specified", "NIO", "as", "member", "of", "this", "bridge", "." ]
python
train
spyder-ide/spyder
spyder/widgets/comboboxes.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/comboboxes.py#L351-L355
def is_valid(self, qstr=None): """Return True if string is valid""" if qstr is None: qstr = self.currentText() return is_module_or_package(to_text_string(qstr))
[ "def", "is_valid", "(", "self", ",", "qstr", "=", "None", ")", ":", "if", "qstr", "is", "None", ":", "qstr", "=", "self", ".", "currentText", "(", ")", "return", "is_module_or_package", "(", "to_text_string", "(", "qstr", ")", ")" ]
Return True if string is valid
[ "Return", "True", "if", "string", "is", "valid" ]
python
train
Alignak-monitoring/alignak
alignak/downtime.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/downtime.py#L174-L227
def enter(self, timeperiods, hosts, services): """Set ref in scheduled downtime and raise downtime log entry (start) :param hosts: hosts objects to get item ref :type hosts: alignak.objects.host.Hosts :param services: services objects to get item ref :type services: alignak.obje...
[ "def", "enter", "(", "self", ",", "timeperiods", ",", "hosts", ",", "services", ")", ":", "if", "self", ".", "ref", "in", "hosts", ":", "item", "=", "hosts", "[", "self", ".", "ref", "]", "else", ":", "item", "=", "services", "[", "self", ".", "r...
Set ref in scheduled downtime and raise downtime log entry (start) :param hosts: hosts objects to get item ref :type hosts: alignak.objects.host.Hosts :param services: services objects to get item ref :type services: alignak.objects.service.Services :return: broks :rtype...
[ "Set", "ref", "in", "scheduled", "downtime", "and", "raise", "downtime", "log", "entry", "(", "start", ")" ]
python
train
Cog-Creators/Red-Lavalink
lavalink/lavalink.py
https://github.com/Cog-Creators/Red-Lavalink/blob/5b3fc6eb31ee5db8bd2b633a523cf69749957111/lavalink/lavalink.py#L211-L231
def register_update_listener(coro): """ Registers a coroutine to receive lavalink player update information. This coroutine will accept a two arguments: an instance of :py:class:`Player` and an instance of :py:class:`PlayerState`. Parameters ---------- coro Raises ------ TypeE...
[ "def", "register_update_listener", "(", "coro", ")", ":", "if", "not", "asyncio", ".", "iscoroutinefunction", "(", "coro", ")", ":", "raise", "TypeError", "(", "\"Function is not a coroutine.\"", ")", "if", "coro", "not", "in", "_update_listeners", ":", "_update_l...
Registers a coroutine to receive lavalink player update information. This coroutine will accept a two arguments: an instance of :py:class:`Player` and an instance of :py:class:`PlayerState`. Parameters ---------- coro Raises ------ TypeError If ``coro`` is not a coroutine.
[ "Registers", "a", "coroutine", "to", "receive", "lavalink", "player", "update", "information", "." ]
python
train
python-diamond/Diamond
src/diamond/metric.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/metric.py#L148-L164
def getMetricPath(self): """ Returns the metric path after the collector name servers.host.cpu.total.idle return "total.idle" """ # If we don't have a host name, assume it's just the fourth+ part of the # metric path if self.host is None: ...
[ "def", "getMetricPath", "(", "self", ")", ":", "# If we don't have a host name, assume it's just the fourth+ part of the", "# metric path", "if", "self", ".", "host", "is", "None", ":", "path", "=", "self", ".", "path", ".", "split", "(", "'.'", ")", "[", "3", "...
Returns the metric path after the collector name servers.host.cpu.total.idle return "total.idle"
[ "Returns", "the", "metric", "path", "after", "the", "collector", "name", "servers", ".", "host", ".", "cpu", ".", "total", ".", "idle", "return", "total", ".", "idle" ]
python
train
has2k1/plotnine
plotnine/geoms/geom.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L195-L221
def draw_layer(self, data, layout, coord, **params): """ Draw layer across all panels geoms should not override this method. Parameters ---------- data : DataFrame DataFrame specific for this layer layout : Lanel Layout object created whe...
[ "def", "draw_layer", "(", "self", ",", "data", ",", "layout", ",", "coord", ",", "*", "*", "params", ")", ":", "for", "pid", ",", "pdata", "in", "data", ".", "groupby", "(", "'PANEL'", ")", ":", "if", "len", "(", "pdata", ")", "==", "0", ":", "...
Draw layer across all panels geoms should not override this method. Parameters ---------- data : DataFrame DataFrame specific for this layer layout : Lanel Layout object created when the plot is getting built coord : coord ...
[ "Draw", "layer", "across", "all", "panels" ]
python
train
jxtech/wechatpy
wechatpy/client/api/merchant/__init__.py
https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/merchant/__init__.py#L123-L139
def add_stock(self, product_id, sku_info, quantity): """ 增加库存 :param product_id: 商品ID :param sku_info: sku信息,格式"id1:vid1;id2:vid2",如商品为统一规格,则此处赋值为空字符串即可 :param quantity: 增加的库存数量 :return: 返回的 JSON 数据包 """ return self._post( 'merchant/stock/add'...
[ "def", "add_stock", "(", "self", ",", "product_id", ",", "sku_info", ",", "quantity", ")", ":", "return", "self", ".", "_post", "(", "'merchant/stock/add'", ",", "data", "=", "{", "\"product_id\"", ":", "product_id", ",", "\"sku_info\"", ":", "sku_info", ","...
增加库存 :param product_id: 商品ID :param sku_info: sku信息,格式"id1:vid1;id2:vid2",如商品为统一规格,则此处赋值为空字符串即可 :param quantity: 增加的库存数量 :return: 返回的 JSON 数据包
[ "增加库存" ]
python
train
apache/incubator-mxnet
python/mxnet/symbol/symbol.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1824-L1862
def eval(self, ctx=None, **kwargs): """Evaluates a symbol given arguments. The `eval` method combines a call to `bind` (which returns an executor) with a call to `forward` (executor method). For the common use case, where you might repeatedly evaluate with same arguments, eval i...
[ "def", "eval", "(", "self", ",", "ctx", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ctx", "is", "None", ":", "ctx", "=", "current_context", "(", ")", "return", "self", ".", "bind", "(", "ctx", ",", "kwargs", ")", ".", "forward", "(", ...
Evaluates a symbol given arguments. The `eval` method combines a call to `bind` (which returns an executor) with a call to `forward` (executor method). For the common use case, where you might repeatedly evaluate with same arguments, eval is slow. In that case, you should call `...
[ "Evaluates", "a", "symbol", "given", "arguments", "." ]
python
train
saltstack/salt
salt/modules/gem.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/gem.py#L313-L348
def list_upgrades(ruby=None, runas=None, gem_bin=None): ''' .. versionadded:: 2015.8.0 Check if an upgrade is available for installed gems gem_bin : None Full path to ``gem`` binary to use. ruby : None If RVM or rbenv are installed, the ruby vers...
[ "def", "list_upgrades", "(", "ruby", "=", "None", ",", "runas", "=", "None", ",", "gem_bin", "=", "None", ")", ":", "result", "=", "_gem", "(", "[", "'outdated'", "]", ",", "ruby", ",", "gem_bin", "=", "gem_bin", ",", "runas", "=", "runas", ")", "r...
.. versionadded:: 2015.8.0 Check if an upgrade is available for installed gems gem_bin : None Full path to ``gem`` binary to use. ruby : None If RVM or rbenv are installed, the ruby version and gemset to use. Ignored if ``gem_bin`` is specified. runas : None The user to...
[ "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
python
train
capless/warrant
warrant/__init__.py
https://github.com/capless/warrant/blob/ff2e4793d8479e770f2461ef7cbc0c15ee784395/warrant/__init__.py#L245-L263
def check_token(self, renew=True): """ Checks the exp attribute of the access_token and either refreshes the tokens by calling the renew_access_tokens method or does nothing :param renew: bool indicating whether to refresh on expiration :return: bool indicating whether access_tok...
[ "def", "check_token", "(", "self", ",", "renew", "=", "True", ")", ":", "if", "not", "self", ".", "access_token", ":", "raise", "AttributeError", "(", "'Access Token Required to Check Token'", ")", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")...
Checks the exp attribute of the access_token and either refreshes the tokens by calling the renew_access_tokens method or does nothing :param renew: bool indicating whether to refresh on expiration :return: bool indicating whether access_token has expired
[ "Checks", "the", "exp", "attribute", "of", "the", "access_token", "and", "either", "refreshes", "the", "tokens", "by", "calling", "the", "renew_access_tokens", "method", "or", "does", "nothing", ":", "param", "renew", ":", "bool", "indicating", "whether", "to", ...
python
train
InQuest/python-sandboxapi
sandboxapi/vmray.py
https://github.com/InQuest/python-sandboxapi/blob/9bad73f453e25d7d23e7b4b1ae927f44a35a5bc3/sandboxapi/vmray.py#L107-L152
def report(self, item_id, report_format="json"): """Retrieves the specified report for the analyzed item, referenced by item_id. Available formats include: json. :type item_id: str :param item_id: File ID number :type report_format: str :param report_forma...
[ "def", "report", "(", "self", ",", "item_id", ",", "report_format", "=", "\"json\"", ")", ":", "if", "report_format", "==", "\"html\"", ":", "return", "\"Report Unavailable\"", "# grab an analysis id from the submission id.", "response", "=", "self", ".", "_request", ...
Retrieves the specified report for the analyzed item, referenced by item_id. Available formats include: json. :type item_id: str :param item_id: File ID number :type report_format: str :param report_format: Return format :rtype: dict :return: Dic...
[ "Retrieves", "the", "specified", "report", "for", "the", "analyzed", "item", "referenced", "by", "item_id", "." ]
python
train
bloomreach/s4cmd
s4cmd.py
https://github.com/bloomreach/s4cmd/blob/bb51075bf43703e7cd95aa39288cf7732ec13a6d/s4cmd.py#L1260-L1275
def get_file_splits(self, id, source, target, fsize, splitsize): '''Get file splits for upload/download/copy operation.''' pos = 0 part = 1 # S3 part id starts from 1 mpi = ThreadUtil.MultipartItem(id) splits = [] while pos < fsize: chunk = min(splitsize, fsize - pos) assert(chunk >...
[ "def", "get_file_splits", "(", "self", ",", "id", ",", "source", ",", "target", ",", "fsize", ",", "splitsize", ")", ":", "pos", "=", "0", "part", "=", "1", "# S3 part id starts from 1", "mpi", "=", "ThreadUtil", ".", "MultipartItem", "(", "id", ")", "sp...
Get file splits for upload/download/copy operation.
[ "Get", "file", "splits", "for", "upload", "/", "download", "/", "copy", "operation", "." ]
python
test
Rikanishu/static-bundle
static_bundle/builders.py
https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/builders.py#L44-L61
def add_bundle(self, *args): """ Add some bundle to build group :type bundle: static_bundle.bundles.AbstractBundle @rtype: BuildGroup """ for bundle in args: if not self.multitype and self.has_bundles(): first_bundle = self.get_first_bundle() ...
[ "def", "add_bundle", "(", "self", ",", "*", "args", ")", ":", "for", "bundle", "in", "args", ":", "if", "not", "self", ".", "multitype", "and", "self", ".", "has_bundles", "(", ")", ":", "first_bundle", "=", "self", ".", "get_first_bundle", "(", ")", ...
Add some bundle to build group :type bundle: static_bundle.bundles.AbstractBundle @rtype: BuildGroup
[ "Add", "some", "bundle", "to", "build", "group" ]
python
valid
mpasternak/django-dsl
django_dsl/parser.py
https://github.com/mpasternak/django-dsl/blob/da1fe4da92503841a4ba5ae9db100248cf98437d/django_dsl/parser.py#L64-L84
def p_expression_ID(p): """expression : FIELD operation value """ lookup = compa2lookup[p[2]] try: field = get_shortcut(p[1]) except KeyError: field = p[1] if lookup: field = '%s__%s' % (field, lookup) # In some situations (which ones?), python # refuses unicod...
[ "def", "p_expression_ID", "(", "p", ")", ":", "lookup", "=", "compa2lookup", "[", "p", "[", "2", "]", "]", "try", ":", "field", "=", "get_shortcut", "(", "p", "[", "1", "]", ")", "except", "KeyError", ":", "field", "=", "p", "[", "1", "]", "if", ...
expression : FIELD operation value
[ "expression", ":", "FIELD", "operation", "value" ]
python
train
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L9589-L9615
def linreg(x, y): """ does a linear regression """ if len(x) != len(y): print('x and y must be same length') return xx, yy, xsum, ysum, xy, n, sum = 0, 0, 0, 0, 0, len(x), 0 linpars = {} for i in range(n): xx += x[i] * x[i] yy += y[i] * y[i] xy += x[i]...
[ "def", "linreg", "(", "x", ",", "y", ")", ":", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ":", "print", "(", "'x and y must be same length'", ")", "return", "xx", ",", "yy", ",", "xsum", ",", "ysum", ",", "xy", ",", "n", ",", "sum"...
does a linear regression
[ "does", "a", "linear", "regression" ]
python
train
Fantomas42/django-blog-zinnia
zinnia/sitemaps.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/sitemaps.py#L123-L129
def get_queryset(self): """ Return the published Tags with option counts. """ self.entries_qs = Entry.published.all() return Tag.objects.usage_for_queryset( self.entries_qs, counts=True)
[ "def", "get_queryset", "(", "self", ")", ":", "self", ".", "entries_qs", "=", "Entry", ".", "published", ".", "all", "(", ")", "return", "Tag", ".", "objects", ".", "usage_for_queryset", "(", "self", ".", "entries_qs", ",", "counts", "=", "True", ")" ]
Return the published Tags with option counts.
[ "Return", "the", "published", "Tags", "with", "option", "counts", "." ]
python
train
CxAalto/gtfspy
gtfspy/shapes.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/shapes.py#L324-L381
def get_shape_between_stops(cur, trip_I, seq_stop1=None, seq_stop2=None, shape_breaks=None): """ Given a trip_I (shortened id), return shape points between two stops (seq_stop1 and seq_stop2). Trip_I is used for matching obtaining the full shape of one trip (route). From the resulting shape we then...
[ "def", "get_shape_between_stops", "(", "cur", ",", "trip_I", ",", "seq_stop1", "=", "None", ",", "seq_stop2", "=", "None", ",", "shape_breaks", "=", "None", ")", ":", "assert", "(", "seq_stop1", "and", "seq_stop2", ")", "or", "shape_breaks", "if", "not", "...
Given a trip_I (shortened id), return shape points between two stops (seq_stop1 and seq_stop2). Trip_I is used for matching obtaining the full shape of one trip (route). From the resulting shape we then obtain only shape points between stop_seq1 and stop_seq2 trip_I---(trips)--->shape_id trip_I...
[ "Given", "a", "trip_I", "(", "shortened", "id", ")", "return", "shape", "points", "between", "two", "stops", "(", "seq_stop1", "and", "seq_stop2", ")", "." ]
python
valid
MolSSI-BSE/basis_set_exchange
basis_set_exchange/api.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/api.py#L318-L330
def get_reference_data(data_dir=None): '''Obtain information for all stored references This is a nested dictionary with all the data for all the references The reference data is read from the REFERENCES.json file in the given `data_dir` directory. ''' data_dir = fix_data_dir(data_dir) ref...
[ "def", "get_reference_data", "(", "data_dir", "=", "None", ")", ":", "data_dir", "=", "fix_data_dir", "(", "data_dir", ")", "reffile_path", "=", "os", ".", "path", ".", "join", "(", "data_dir", ",", "'REFERENCES.json'", ")", "return", "fileio", ".", "read_re...
Obtain information for all stored references This is a nested dictionary with all the data for all the references The reference data is read from the REFERENCES.json file in the given `data_dir` directory.
[ "Obtain", "information", "for", "all", "stored", "references" ]
python
train
quantopian/zipline
zipline/assets/asset_writer.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_writer.py#L335-L368
def _split_symbol_mappings(df, exchanges): """Split out the symbol: sid mappings from the raw data. Parameters ---------- df : pd.DataFrame The dataframe with multiple rows for each symbol: sid pair. exchanges : pd.DataFrame The exchanges table. Returns ------- asset_in...
[ "def", "_split_symbol_mappings", "(", "df", ",", "exchanges", ")", ":", "mappings", "=", "df", "[", "list", "(", "mapping_columns", ")", "]", "with", "pd", ".", "option_context", "(", "'mode.chained_assignment'", ",", "None", ")", ":", "mappings", "[", "'sid...
Split out the symbol: sid mappings from the raw data. Parameters ---------- df : pd.DataFrame The dataframe with multiple rows for each symbol: sid pair. exchanges : pd.DataFrame The exchanges table. Returns ------- asset_info : pd.DataFrame The asset info with one ...
[ "Split", "out", "the", "symbol", ":", "sid", "mappings", "from", "the", "raw", "data", "." ]
python
train
opendatateam/udata
udata/core/metrics/commands.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/metrics/commands.py#L70-L76
def list(): '''List all known metrics''' for cls, metrics in metric_catalog.items(): echo(white(cls.__name__)) for metric in metrics.keys(): echo('> {0}'.format(metric))
[ "def", "list", "(", ")", ":", "for", "cls", ",", "metrics", "in", "metric_catalog", ".", "items", "(", ")", ":", "echo", "(", "white", "(", "cls", ".", "__name__", ")", ")", "for", "metric", "in", "metrics", ".", "keys", "(", ")", ":", "echo", "(...
List all known metrics
[ "List", "all", "known", "metrics" ]
python
train
andreikop/qutepart
qutepart/margins.py
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/margins.py#L175-L185
def clear(self): """Convenience method to reset all the block values to 0 """ if self._bit_count == 0: return block = self._qpart.document().begin() while block.isValid(): if self.getBlockValue(block): self.setBlockValue(block, 0) ...
[ "def", "clear", "(", "self", ")", ":", "if", "self", ".", "_bit_count", "==", "0", ":", "return", "block", "=", "self", ".", "_qpart", ".", "document", "(", ")", ".", "begin", "(", ")", "while", "block", ".", "isValid", "(", ")", ":", "if", "self...
Convenience method to reset all the block values to 0
[ "Convenience", "method", "to", "reset", "all", "the", "block", "values", "to", "0" ]
python
train
wonambi-python/wonambi
wonambi/detect/spindle.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/detect/spindle.py#L1804-L1849
def peak_in_power(events, dat, s_freq, method, value=None): """Define peak in power of the signal. Parameters ---------- events : ndarray (dtype='int') N x 3 matrix with start, peak, end samples dat : ndarray (dtype='float') vector with the original data s_freq : float s...
[ "def", "peak_in_power", "(", "events", ",", "dat", ",", "s_freq", ",", "method", ",", "value", "=", "None", ")", ":", "dat", "=", "diff", "(", "dat", ")", "# remove 1/f", "peak", "=", "empty", "(", "events", ".", "shape", "[", "0", "]", ")", "peak"...
Define peak in power of the signal. Parameters ---------- events : ndarray (dtype='int') N x 3 matrix with start, peak, end samples dat : ndarray (dtype='float') vector with the original data s_freq : float sampling frequency method : str or None 'peak' or 'inter...
[ "Define", "peak", "in", "power", "of", "the", "signal", "." ]
python
train
fxsjy/jieba
jieba/__init__.py
https://github.com/fxsjy/jieba/blob/8212b6c5725d08311952a3a08e5509eeaee33eb7/jieba/__init__.py#L424-L453
def suggest_freq(self, segment, tune=False): """ Suggest word frequency to force the characters in a word to be joined or splitted. Parameter: - segment : The segments that the word is expected to be cut into, If the word should be treated as a whole,...
[ "def", "suggest_freq", "(", "self", ",", "segment", ",", "tune", "=", "False", ")", ":", "self", ".", "check_initialized", "(", ")", "ftotal", "=", "float", "(", "self", ".", "total", ")", "freq", "=", "1", "if", "isinstance", "(", "segment", ",", "s...
Suggest word frequency to force the characters in a word to be joined or splitted. Parameter: - segment : The segments that the word is expected to be cut into, If the word should be treated as a whole, use a str. - tune : If True, tune the word frequency...
[ "Suggest", "word", "frequency", "to", "force", "the", "characters", "in", "a", "word", "to", "be", "joined", "or", "splitted", "." ]
python
train
zwischenloesung/ardu-report-lib
libardurep/datastore.py
https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L207-L219
def get_json_tuples(self, prettyprint=False, translate=True): """ Get the data as JSON tuples """ j = self.get_json(prettyprint, translate) if len(j) > 2: if prettyprint: j = j[1:-2] + ",\n" else: j = j[1:-1] + "," e...
[ "def", "get_json_tuples", "(", "self", ",", "prettyprint", "=", "False", ",", "translate", "=", "True", ")", ":", "j", "=", "self", ".", "get_json", "(", "prettyprint", ",", "translate", ")", "if", "len", "(", "j", ")", ">", "2", ":", "if", "prettypr...
Get the data as JSON tuples
[ "Get", "the", "data", "as", "JSON", "tuples" ]
python
valid
rgs1/zk_shell
zk_shell/shell.py
https://github.com/rgs1/zk_shell/blob/bbf34fdfcf1f81100e2a5816fad8af6afc782a54/zk_shell/shell.py#L1775-L1789
def do_rmr(self, params): """ \x1b[1mNAME\x1b[0m rmr - Delete a path and all its children \x1b[1mSYNOPSIS\x1b[0m rmr <path> [path] [path] ... [path] \x1b[1mEXAMPLES\x1b[0m > rmr /foo > rmr /foo /bar """ for path in params.paths: self._zk.delete(path...
[ "def", "do_rmr", "(", "self", ",", "params", ")", ":", "for", "path", "in", "params", ".", "paths", ":", "self", ".", "_zk", ".", "delete", "(", "path", ",", "recursive", "=", "True", ")" ]
\x1b[1mNAME\x1b[0m rmr - Delete a path and all its children \x1b[1mSYNOPSIS\x1b[0m rmr <path> [path] [path] ... [path] \x1b[1mEXAMPLES\x1b[0m > rmr /foo > rmr /foo /bar
[ "\\", "x1b", "[", "1mNAME", "\\", "x1b", "[", "0m", "rmr", "-", "Delete", "a", "path", "and", "all", "its", "children" ]
python
train
i3visio/osrframework
osrframework/alias_generator.py
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/alias_generator.py#L50-L2822
def generate(name=None, surname1=None, surname2=None, city=None, country=None, year=None, useNumbers=False, useCommonWords=False, useLeet=False, useLocales=False, extraWords=[]): """ The method that generates the given aliases. It receives several parameters as parsed by this module's `getParser()`. Pr...
[ "def", "generate", "(", "name", "=", "None", ",", "surname1", "=", "None", ",", "surname2", "=", "None", ",", "city", "=", "None", ",", "country", "=", "None", ",", "year", "=", "None", ",", "useNumbers", "=", "False", ",", "useCommonWords", "=", "Fa...
The method that generates the given aliases. It receives several parameters as parsed by this module's `getParser()`. Previously referenced as `main`. Args: ----- name: String representing the known name of the investigated profile. surname1: String representing the first surname of th...
[ "The", "method", "that", "generates", "the", "given", "aliases", "." ]
python
train
quadrismegistus/prosodic
prosodic/entity.py
https://github.com/quadrismegistus/prosodic/blob/8af66ed9be40c922d03a0b09bc11c87d2061b618/prosodic/entity.py#L132-L156
def feat(self,k,v): """ Store value 'v' as a feature name 'k' for this object. Features are stored in the dictionary self.feats. [IMPORTANT NOTE:] If the feature 'k' is not yet defined, then: self.feats[k]=v OTHERWISE: self.feats[k] becomes a list (if not already) 'v' is added to this list """ ...
[ "def", "feat", "(", "self", ",", "k", ",", "v", ")", ":", "if", "(", "not", "hasattr", "(", "self", ",", "'feats'", ")", ")", ":", "self", ".", "feats", "=", "{", "}", "if", "(", "not", "hasattr", "(", "self", ",", "'featpaths'", ")", ")", ":...
Store value 'v' as a feature name 'k' for this object. Features are stored in the dictionary self.feats. [IMPORTANT NOTE:] If the feature 'k' is not yet defined, then: self.feats[k]=v OTHERWISE: self.feats[k] becomes a list (if not already) 'v' is added to this list
[ "Store", "value", "v", "as", "a", "feature", "name", "k", "for", "this", "object", ".", "Features", "are", "stored", "in", "the", "dictionary", "self", ".", "feats", ".", "[", "IMPORTANT", "NOTE", ":", "]", "If", "the", "feature", "k", "is", "not", "...
python
train
ninuxorg/nodeshot
nodeshot/networking/links/views.py
https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/links/views.py#L73-L93
def initial(self, request, *args, **kwargs): """ Custom initial method: * ensure node exists and store it in an instance attribute * change queryset to return only links of current node """ super(NodeLinkList, self).initial(request, *args, **kwargs) # ensu...
[ "def", "initial", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "NodeLinkList", ",", "self", ")", ".", "initial", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", "# ensure node exists"...
Custom initial method: * ensure node exists and store it in an instance attribute * change queryset to return only links of current node
[ "Custom", "initial", "method", ":", "*", "ensure", "node", "exists", "and", "store", "it", "in", "an", "instance", "attribute", "*", "change", "queryset", "to", "return", "only", "links", "of", "current", "node" ]
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/gloo/wrappers.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/wrappers.py#L159-L172
def set_polygon_offset(self, factor=0., units=0.): """Set the scale and units used to calculate depth values Parameters ---------- factor : float Scale factor used to create a variable depth offset for each polygon. units : float Multiplie...
[ "def", "set_polygon_offset", "(", "self", ",", "factor", "=", "0.", ",", "units", "=", "0.", ")", ":", "self", ".", "glir", ".", "command", "(", "'FUNC'", ",", "'glPolygonOffset'", ",", "float", "(", "factor", ")", ",", "float", "(", "units", ")", ")...
Set the scale and units used to calculate depth values Parameters ---------- factor : float Scale factor used to create a variable depth offset for each polygon. units : float Multiplied by an implementation-specific value to create a ...
[ "Set", "the", "scale", "and", "units", "used", "to", "calculate", "depth", "values", "Parameters", "----------", "factor", ":", "float", "Scale", "factor", "used", "to", "create", "a", "variable", "depth", "offset", "for", "each", "polygon", ".", "units", ":...
python
train
SBRG/ssbio
ssbio/pipeline/gempro.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/pipeline/gempro.py#L1500-L1524
def get_freesasa_annotations_parallelize(self, sc, include_hetatms=False, representatives_only=True, force_rerun=False): """Run freesasa on structures and store calculations. Annotations are stored in the protein structure's chain sequence at: ``<cha...
[ "def", "get_freesasa_annotations_parallelize", "(", "self", ",", "sc", ",", "include_hetatms", "=", "False", ",", "representatives_only", "=", "True", ",", "force_rerun", "=", "False", ")", ":", "genes_rdd", "=", "sc", ".", "parallelize", "(", "self", ".", "ge...
Run freesasa on structures and store calculations. Annotations are stored in the protein structure's chain sequence at: ``<chain_prop>.seq_record.letter_annotations['*-freesasa']`` Args: include_hetatms (bool): If HETATMs should be included in calculations. Defaults to ``False``. ...
[ "Run", "freesasa", "on", "structures", "and", "store", "calculations", "." ]
python
train
google/importlab
importlab/import_finder.py
https://github.com/google/importlab/blob/92090a0b4421137d1369c2ed952eda6bb4c7a155/importlab/import_finder.py#L123-L137
def get_imports(filename): """Get all the imports in a file. Each import is a tuple of: (name, alias, is_from, is_star, source_file) """ with open(filename, "rb") as f: src = f.read() finder = ImportFinder() finder.visit(ast.parse(src, filename=filename)) imports = [] for ...
[ "def", "get_imports", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "f", ":", "src", "=", "f", ".", "read", "(", ")", "finder", "=", "ImportFinder", "(", ")", "finder", ".", "visit", "(", "ast", ".", "parse",...
Get all the imports in a file. Each import is a tuple of: (name, alias, is_from, is_star, source_file)
[ "Get", "all", "the", "imports", "in", "a", "file", "." ]
python
train
veltzer/pypitools
pypitools/common.py
https://github.com/veltzer/pypitools/blob/5f097be21e9bc65578eed5b6b7855c1945540701/pypitools/common.py#L22-L42
def check_call_no_output(args): """ Run a process and check that it returns an OK return code and has no output :param args: :return: """ logger = logging.getLogger(__name__) logger.debug("running %s", args) process = subprocess.Popen( args, stdout=subprocess.PIPE, ...
[ "def", "check_call_no_output", "(", "args", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "debug", "(", "\"running %s\"", ",", "args", ")", "process", "=", "subprocess", ".", "Popen", "(", "args", ",", "stdout",...
Run a process and check that it returns an OK return code and has no output :param args: :return:
[ "Run", "a", "process", "and", "check", "that", "it", "returns", "an", "OK", "return", "code", "and", "has", "no", "output", ":", "param", "args", ":", ":", "return", ":" ]
python
train
cdgriffith/Reusables
reusables/file_operations.py
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/file_operations.py#L684-L715
def directory_duplicates(directory, hash_type='md5', **kwargs): """ Find all duplicates in a directory. Will return a list, in that list are lists of duplicate files. .. code: python dups = reusables.directory_duplicates('C:\\Users\\Me\\Pictures') print(len(dups)) # 56 ...
[ "def", "directory_duplicates", "(", "directory", ",", "hash_type", "=", "'md5'", ",", "*", "*", "kwargs", ")", ":", "size_map", ",", "hash_map", "=", "defaultdict", "(", "list", ")", ",", "defaultdict", "(", "list", ")", "for", "item", "in", "find_files", ...
Find all duplicates in a directory. Will return a list, in that list are lists of duplicate files. .. code: python dups = reusables.directory_duplicates('C:\\Users\\Me\\Pictures') print(len(dups)) # 56 print(dups) # [['C:\\Users\\Me\\Pictures\\IMG_20161127.jpg', ...
[ "Find", "all", "duplicates", "in", "a", "directory", ".", "Will", "return", "a", "list", "in", "that", "list", "are", "lists", "of", "duplicate", "files", "." ]
python
train
pierre-rouanet/hampy
hampy/hamming.py
https://github.com/pierre-rouanet/hampy/blob/bb633a3936f8a3b5f619fb0d92c7448f3dc3c92d/hampy/hamming.py#L52-L82
def decode(C): """ Decode data using Hamming(7, 4) code. E.g.: decode([1, 0, 0, 0, 0, 1, 1]) encode([[1, 1, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 1]]) :param array C: binary data to code (must be shaped as (7, ) or (-1, 7)). """ C = array(C) flatten = False ...
[ "def", "decode", "(", "C", ")", ":", "C", "=", "array", "(", "C", ")", "flatten", "=", "False", "if", "len", "(", "C", ".", "shape", ")", "==", "1", ":", "flatten", "=", "True", "C", "=", "C", ".", "reshape", "(", "1", ",", "-", "1", ")", ...
Decode data using Hamming(7, 4) code. E.g.: decode([1, 0, 0, 0, 0, 1, 1]) encode([[1, 1, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 1]]) :param array C: binary data to code (must be shaped as (7, ) or (-1, 7)).
[ "Decode", "data", "using", "Hamming", "(", "7", "4", ")", "code", "." ]
python
train
inveniosoftware/invenio-oauth2server
invenio_oauth2server/models.py
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/models.py#L219-L229
def redirect_uris(self, value): """Validate and store redirect URIs for client.""" if isinstance(value, six.text_type): value = value.split("\n") value = [v.strip() for v in value] for v in value: validate_redirect_uri(v) self._redirect_uris = "\n".join...
[ "def", "redirect_uris", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "text_type", ")", ":", "value", "=", "value", ".", "split", "(", "\"\\n\"", ")", "value", "=", "[", "v", ".", "strip", "(", ")", "for", ...
Validate and store redirect URIs for client.
[ "Validate", "and", "store", "redirect", "URIs", "for", "client", "." ]
python
train
SuperCowPowers/chains
examples/tag_example.py
https://github.com/SuperCowPowers/chains/blob/b0227847b0c43083b456f0bae52daee0b62a3e03/examples/tag_example.py#L10-L29
def run(iface_name=None, bpf=None, summary=None, max_packets=50): """Run the Simple Packet Printer Example""" # Create the classes streamer = packet_streamer.PacketStreamer(iface_name=iface_name, bpf=bpf, max_packets=max_packets) meta = packet_meta.PacketMeta() rdns = reverse_dns.ReverseDNS() t...
[ "def", "run", "(", "iface_name", "=", "None", ",", "bpf", "=", "None", ",", "summary", "=", "None", ",", "max_packets", "=", "50", ")", ":", "# Create the classes", "streamer", "=", "packet_streamer", ".", "PacketStreamer", "(", "iface_name", "=", "iface_nam...
Run the Simple Packet Printer Example
[ "Run", "the", "Simple", "Packet", "Printer", "Example" ]
python
train
uchicago-cs/deepdish
deepdish/image.py
https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/image.py#L289-L305
def bounding_box_as_binary_map(alpha, threshold=0.1): """ Similar to `bounding_box`, except returns the bounding box as a binary map the same size as the input. Same parameters as `bounding_box`. Returns ------- binary_map : ndarray, ndim=2, dtype=np.bool_ Binary map with True if o...
[ "def", "bounding_box_as_binary_map", "(", "alpha", ",", "threshold", "=", "0.1", ")", ":", "bb", "=", "bounding_box", "(", "alpha", ")", "x", "=", "np", ".", "zeros", "(", "alpha", ".", "shape", ",", "dtype", "=", "np", ".", "bool_", ")", "x", "[", ...
Similar to `bounding_box`, except returns the bounding box as a binary map the same size as the input. Same parameters as `bounding_box`. Returns ------- binary_map : ndarray, ndim=2, dtype=np.bool_ Binary map with True if object and False if background.
[ "Similar", "to", "bounding_box", "except", "returns", "the", "bounding", "box", "as", "a", "binary", "map", "the", "same", "size", "as", "the", "input", "." ]
python
train
vanheeringen-lab/gimmemotifs
gimmemotifs/rocmetrics.py
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/rocmetrics.py#L357-L444
def roc_auc_xlim(x_bla, y_bla, xlim=0.1): """ Computes the ROC Area Under Curve until a certain FPR value. Parameters ---------- fg_vals : array_like list of values for positive set bg_vals : array_like list of values for negative set xlim : float, optional FPR val...
[ "def", "roc_auc_xlim", "(", "x_bla", ",", "y_bla", ",", "xlim", "=", "0.1", ")", ":", "x", "=", "x_bla", "[", ":", "]", "y", "=", "y_bla", "[", ":", "]", "x", ".", "sort", "(", ")", "y", ".", "sort", "(", ")", "u", "=", "{", "}", "for", "...
Computes the ROC Area Under Curve until a certain FPR value. Parameters ---------- fg_vals : array_like list of values for positive set bg_vals : array_like list of values for negative set xlim : float, optional FPR value Returns ------- score : float ...
[ "Computes", "the", "ROC", "Area", "Under", "Curve", "until", "a", "certain", "FPR", "value", "." ]
python
train
shidenggui/easytrader
easytrader/webtrader.py
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L76-L81
def keepalive(self): """启动保持在线的进程 """ if self.heart_thread.is_alive(): self.heart_active = True else: self.heart_thread.start()
[ "def", "keepalive", "(", "self", ")", ":", "if", "self", ".", "heart_thread", ".", "is_alive", "(", ")", ":", "self", ".", "heart_active", "=", "True", "else", ":", "self", ".", "heart_thread", ".", "start", "(", ")" ]
启动保持在线的进程
[ "启动保持在线的进程" ]
python
train
theiviaxx/Frog
frog/views/gallery.py
https://github.com/theiviaxx/Frog/blob/a9475463a8eed1323fe3ef5d51f9751fb1dc9edd/frog/views/gallery.py#L219-L331
def _filter(request, object_, tags=None, more=False, orderby='created'): """Filters Piece objects from self based on filters, search, and range :param tags: List of tag IDs to filter :type tags: list :param more -- bool, Returns more of the same filtered set of images based on session range return...
[ "def", "_filter", "(", "request", ",", "object_", ",", "tags", "=", "None", ",", "more", "=", "False", ",", "orderby", "=", "'created'", ")", ":", "res", "=", "Result", "(", ")", "models", "=", "QUERY_MODELS", "idDict", "=", "{", "}", "objDict", "=",...
Filters Piece objects from self based on filters, search, and range :param tags: List of tag IDs to filter :type tags: list :param more -- bool, Returns more of the same filtered set of images based on session range return list, Objects filtered
[ "Filters", "Piece", "objects", "from", "self", "based", "on", "filters", "search", "and", "range" ]
python
train
pandas-dev/pandas
pandas/io/sql.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sql.py#L454-L475
def has_table(table_name, con, schema=None): """ Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported ...
[ "def", "has_table", "(", "table_name", ",", "con", ",", "schema", "=", "None", ")", ":", "pandas_sql", "=", "pandasSQL_builder", "(", "con", ",", "schema", "=", "schema", ")", "return", "pandas_sql", ".", "has_table", "(", "table_name", ")" ]
Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table. con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only...
[ "Check", "if", "DataBase", "has", "named", "table", "." ]
python
train
spyder-ide/spyder
spyder/widgets/mixins.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L440-L447
def is_cursor_before(self, position, char_offset=0): """Return True if cursor is before *position*""" position = self.get_position(position) + char_offset cursor = self.textCursor() cursor.movePosition(QTextCursor.End) if position < cursor.position(): cursor.set...
[ "def", "is_cursor_before", "(", "self", ",", "position", ",", "char_offset", "=", "0", ")", ":", "position", "=", "self", ".", "get_position", "(", "position", ")", "+", "char_offset", "cursor", "=", "self", ".", "textCursor", "(", ")", "cursor", ".", "m...
Return True if cursor is before *position*
[ "Return", "True", "if", "cursor", "is", "before", "*", "position", "*" ]
python
train
Jaymon/pyt
pyt/__init__.py
https://github.com/Jaymon/pyt/blob/801581fd0ae238158134bde1c937fa199fa626b2/pyt/__init__.py#L60-L70
def is_single_module(): """Returns True if only a module is being run""" ret = False counts = get_counts() if counts["modules"] == 1: ret = True elif counts["modules"] < 1: ret = is_single_class() return ret
[ "def", "is_single_module", "(", ")", ":", "ret", "=", "False", "counts", "=", "get_counts", "(", ")", "if", "counts", "[", "\"modules\"", "]", "==", "1", ":", "ret", "=", "True", "elif", "counts", "[", "\"modules\"", "]", "<", "1", ":", "ret", "=", ...
Returns True if only a module is being run
[ "Returns", "True", "if", "only", "a", "module", "is", "being", "run" ]
python
test
Autodesk/pyccc
pyccc/utils.py
https://github.com/Autodesk/pyccc/blob/011698e78d49a83ac332e0578a4a2a865b75ef8d/pyccc/utils.py#L34-L41
def gist_diff(): """Diff this file with the gist on github""" remote_file = wget(RAW_GIST) proc = subprocess.Popen(('diff - %s'%MY_PATH).split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdout, stderr = proc.communicate(remote_file) retu...
[ "def", "gist_diff", "(", ")", ":", "remote_file", "=", "wget", "(", "RAW_GIST", ")", "proc", "=", "subprocess", ".", "Popen", "(", "(", "'diff - %s'", "%", "MY_PATH", ")", ".", "split", "(", ")", ",", "stdin", "=", "subprocess", ".", "PIPE", ",", "st...
Diff this file with the gist on github
[ "Diff", "this", "file", "with", "the", "gist", "on", "github" ]
python
train
DarkEnergySurvey/ugali
ugali/analysis/mcmc.py
https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/analysis/mcmc.py#L280-L291
def createMCMC(config,srcfile,section='source',samples=None): """ Create an MCMC instance """ source = ugali.analysis.source.Source() source.load(srcfile,section=section) loglike = ugali.analysis.loglike.createLoglike(config,source) mcmc = MCMC(config,loglike) if samples is not None: m...
[ "def", "createMCMC", "(", "config", ",", "srcfile", ",", "section", "=", "'source'", ",", "samples", "=", "None", ")", ":", "source", "=", "ugali", ".", "analysis", ".", "source", ".", "Source", "(", ")", "source", ".", "load", "(", "srcfile", ",", "...
Create an MCMC instance
[ "Create", "an", "MCMC", "instance" ]
python
train
PythonCharmers/python-future
src/future/backports/email/header.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/header.py#L62-L154
def decode_header(header): """Decode a message header value without converting charset. Returns a list of (string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character ...
[ "def", "decode_header", "(", "header", ")", ":", "# If it is a Header object, we can just return the encoded chunks.", "if", "hasattr", "(", "header", ",", "'_chunks'", ")", ":", "return", "[", "(", "_charset", ".", "_encode", "(", "string", ",", "str", "(", "char...
Decode a message header value without converting charset. Returns a list of (string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character set specified in the encoded s...
[ "Decode", "a", "message", "header", "value", "without", "converting", "charset", "." ]
python
train
SuperCowPowers/workbench
workbench/workers/rekall_adapter/rekall_adapter.py
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/rekall_adapter/rekall_adapter.py#L59-L76
def process_row(cls, data, column_map): """Process the row data from Rekall""" row = {} for key,value in data.iteritems(): if not value: value = '-' elif isinstance(value, list): value = value[1] elif isinstance(...
[ "def", "process_row", "(", "cls", ",", "data", ",", "column_map", ")", ":", "row", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "iteritems", "(", ")", ":", "if", "not", "value", ":", "value", "=", "'-'", "elif", "isinstance", "(", ...
Process the row data from Rekall
[ "Process", "the", "row", "data", "from", "Rekall" ]
python
train
astropy/regions
regions/shapes/rectangle.py
https://github.com/astropy/regions/blob/452d962c417e4ff20d1268f99535c6ff89c83437/regions/shapes/rectangle.py#L228-L244
def _lower_left_xy(self): """ Compute lower left `xy` position. This is used for the conversion to matplotlib in ``as_artist`` Taken from http://photutils.readthedocs.io/en/latest/_modules/photutils/aperture/rectangle.html#RectangularAperture.plot """ hw = self.width / ...
[ "def", "_lower_left_xy", "(", "self", ")", ":", "hw", "=", "self", ".", "width", "/", "2.", "hh", "=", "self", ".", "height", "/", "2.", "sint", "=", "np", ".", "sin", "(", "self", ".", "angle", ")", "cost", "=", "np", ".", "cos", "(", "self", ...
Compute lower left `xy` position. This is used for the conversion to matplotlib in ``as_artist`` Taken from http://photutils.readthedocs.io/en/latest/_modules/photutils/aperture/rectangle.html#RectangularAperture.plot
[ "Compute", "lower", "left", "xy", "position", "." ]
python
train
timothydmorton/VESPA
vespa/stars/populations.py
https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/stars/populations.py#L1269-L1281
def rsky_lhood(self,rsky,**kwargs): """ Evaluates Rsky likelihood at provided position(s) :param rsky: position :param **kwargs: Keyword arguments passed to :func:`BinaryPopulation.rsky_distribution` """ dist = self.rsky_distribution(**kwargs) ...
[ "def", "rsky_lhood", "(", "self", ",", "rsky", ",", "*", "*", "kwargs", ")", ":", "dist", "=", "self", ".", "rsky_distribution", "(", "*", "*", "kwargs", ")", "return", "dist", "(", "rsky", ")" ]
Evaluates Rsky likelihood at provided position(s) :param rsky: position :param **kwargs: Keyword arguments passed to :func:`BinaryPopulation.rsky_distribution`
[ "Evaluates", "Rsky", "likelihood", "at", "provided", "position", "(", "s", ")" ]
python
train
dmcc/PyStanfordDependencies
StanfordDependencies/JPypeBackend.py
https://github.com/dmcc/PyStanfordDependencies/blob/43d8f38a19e40087f273330087918c87df6d4d8f/StanfordDependencies/JPypeBackend.py#L193-L199
def _listify(collection): """This is a workaround where Collections are no longer iterable when using JPype.""" new_list = [] for index in range(len(collection)): new_list.append(collection[index]) return new_list
[ "def", "_listify", "(", "collection", ")", ":", "new_list", "=", "[", "]", "for", "index", "in", "range", "(", "len", "(", "collection", ")", ")", ":", "new_list", ".", "append", "(", "collection", "[", "index", "]", ")", "return", "new_list" ]
This is a workaround where Collections are no longer iterable when using JPype.
[ "This", "is", "a", "workaround", "where", "Collections", "are", "no", "longer", "iterable", "when", "using", "JPype", "." ]
python
train
jobovy/galpy
galpy/potential/TwoPowerSphericalPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/TwoPowerSphericalPotential.py#L168-L185
def _dens(self,R,z,phi=0.,t=0.): """ NAME: _dens PURPOSE: evaluate the density for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the densi...
[ "def", "_dens", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "r", "=", "numpy", ".", "sqrt", "(", "R", "**", "2.", "+", "z", "**", "2.", ")", "return", "(", "self", ".", "a", "/", "r", ")", "**"...
NAME: _dens PURPOSE: evaluate the density for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the density HISTORY: 2010-08-08 - Written -...
[ "NAME", ":", "_dens", "PURPOSE", ":", "evaluate", "the", "density", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ":", "the"...
python
train
samirelanduk/quickplots
quickplots/series.py
https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/series.py#L353-L365
def write_to_canvas(self, canvas, name): """Writes the series to an OmniCanvas canvas. :param Canvas canvas: The canvas to write to. :param str name: The name to give the line graphic on the canvas.""" points = self.canvas_points() for point in points: canvas.add_ov...
[ "def", "write_to_canvas", "(", "self", ",", "canvas", ",", "name", ")", ":", "points", "=", "self", ".", "canvas_points", "(", ")", "for", "point", "in", "points", ":", "canvas", ".", "add_oval", "(", "point", "[", "0", "]", "-", "(", "self", ".", ...
Writes the series to an OmniCanvas canvas. :param Canvas canvas: The canvas to write to. :param str name: The name to give the line graphic on the canvas.
[ "Writes", "the", "series", "to", "an", "OmniCanvas", "canvas", "." ]
python
train
gawel/panoramisk
panoramisk/fast_agi.py
https://github.com/gawel/panoramisk/blob/2ccb5d18be28a8e8f444dc0cd3a3bfb59aa19a8e/panoramisk/fast_agi.py#L18-L50
def send_command(self, command): """Send a command for FastAGI request: :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds' :type command: String :Example: :: @asyncio.coroutine def call_waiting(request): ...
[ "def", "send_command", "(", "self", ",", "command", ")", ":", "command", "+=", "'\\n'", "self", ".", "writer", ".", "write", "(", "command", ".", "encode", "(", "self", ".", "encoding", ")", ")", "yield", "from", "self", ".", "writer", ".", "drain", ...
Send a command for FastAGI request: :param command: Command to launch on FastAGI request. Ex: 'EXEC StartMusicOnHolds' :type command: String :Example: :: @asyncio.coroutine def call_waiting(request): print(['AGI variables:', request.headers]) ...
[ "Send", "a", "command", "for", "FastAGI", "request", ":" ]
python
test
simodalla/pygmount
pygmount/utils/mount.py
https://github.com/simodalla/pygmount/blob/8027cfa2ed5fa8e9207d72b6013ecec7fcf2e5f5/pygmount/utils/mount.py#L57-L81
def requirements(self): """ Verifica che tutti i pacchetti apt necessari al "funzionamento" della classe siano installati. Se cosi' non fosse li installa. """ cache = apt.cache.Cache() for pkg in self.pkgs_required: try: pkg = cache[pkg] ...
[ "def", "requirements", "(", "self", ")", ":", "cache", "=", "apt", ".", "cache", ".", "Cache", "(", ")", "for", "pkg", "in", "self", ".", "pkgs_required", ":", "try", ":", "pkg", "=", "cache", "[", "pkg", "]", "if", "not", "pkg", ".", "is_installed...
Verifica che tutti i pacchetti apt necessari al "funzionamento" della classe siano installati. Se cosi' non fosse li installa.
[ "Verifica", "che", "tutti", "i", "pacchetti", "apt", "necessari", "al", "funzionamento", "della", "classe", "siano", "installati", ".", "Se", "cosi", "non", "fosse", "li", "installa", "." ]
python
train
google/google-visualization-python
gviz_api.py
https://github.com/google/google-visualization-python/blob/cbfb4d69ad2f4ca30dc55791629280aa3214c8e3/gviz_api.py#L968-L1009
def ToJSon(self, columns_order=None, order_by=()): """Returns a string that can be used in a JS DataTable constructor. This method writes a JSON string that can be passed directly into a Google Visualization API DataTable constructor. Use this output if you are hosting the visualization HTML on your si...
[ "def", "ToJSon", "(", "self", ",", "columns_order", "=", "None", ",", "order_by", "=", "(", ")", ")", ":", "encoded_response_str", "=", "DataTableJSONEncoder", "(", ")", ".", "encode", "(", "self", ".", "_ToJSonObj", "(", "columns_order", ",", "order_by", ...
Returns a string that can be used in a JS DataTable constructor. This method writes a JSON string that can be passed directly into a Google Visualization API DataTable constructor. Use this output if you are hosting the visualization HTML on your site, and want to code the data table in Python. Pass th...
[ "Returns", "a", "string", "that", "can", "be", "used", "in", "a", "JS", "DataTable", "constructor", "." ]
python
train
angr/angr
angr/analyses/bindiff.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/bindiff.py#L962-L973
def get_function_diff(self, function_addr_a, function_addr_b): """ :param function_addr_a: The address of the first function (in the first binary) :param function_addr_b: The address of the second function (in the second binary) :returns: the FunctionDiff of the two functions """...
[ "def", "get_function_diff", "(", "self", ",", "function_addr_a", ",", "function_addr_b", ")", ":", "pair", "=", "(", "function_addr_a", ",", "function_addr_b", ")", "if", "pair", "not", "in", "self", ".", "_function_diffs", ":", "function_a", "=", "self", ".",...
:param function_addr_a: The address of the first function (in the first binary) :param function_addr_b: The address of the second function (in the second binary) :returns: the FunctionDiff of the two functions
[ ":", "param", "function_addr_a", ":", "The", "address", "of", "the", "first", "function", "(", "in", "the", "first", "binary", ")", ":", "param", "function_addr_b", ":", "The", "address", "of", "the", "second", "function", "(", "in", "the", "second", "bina...
python
train
AirtestProject/Poco
poco/sdk/Selector.py
https://github.com/AirtestProject/Poco/blob/2c559a586adf3fd11ee81cabc446d4d3f6f2d119/poco/sdk/Selector.py#L73-L78
def select(self, cond, multiple=False): """ See Also: :py:meth:`select <poco.sdk.Selector.ISelector.select>` method in ``ISelector``. """ return self.selectImpl(cond, multiple, self.getRoot(), 9999, True, True)
[ "def", "select", "(", "self", ",", "cond", ",", "multiple", "=", "False", ")", ":", "return", "self", ".", "selectImpl", "(", "cond", ",", "multiple", ",", "self", ".", "getRoot", "(", ")", ",", "9999", ",", "True", ",", "True", ")" ]
See Also: :py:meth:`select <poco.sdk.Selector.ISelector.select>` method in ``ISelector``.
[ "See", "Also", ":", ":", "py", ":", "meth", ":", "select", "<poco", ".", "sdk", ".", "Selector", ".", "ISelector", ".", "select", ">", "method", "in", "ISelector", "." ]
python
train
openid/JWTConnect-Python-OidcService
src/oidcservice/client_auth.py
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/client_auth.py#L264-L287
def construct(self, request, service=None, http_args=None, **kwargs): """ Will add a token to the request if not present :param request: The request :param service_context: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :p...
[ "def", "construct", "(", "self", ",", "request", ",", "service", "=", "None", ",", "http_args", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_acc_token", "=", "''", "for", "_token_type", "in", "[", "'access_token'", ",", "'refresh_token'", "]", ":", ...
Will add a token to the request if not present :param request: The request :param service_context: A :py:class:`oidcservice.service.Service` instance :param http_args: HTTP arguments :param kwargs: extra keyword arguments :return: A possibly modified dictionary with ...
[ "Will", "add", "a", "token", "to", "the", "request", "if", "not", "present" ]
python
train
twilio/twilio-python
twilio/rest/sync/v1/service/sync_list/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/sync/v1/service/sync_list/__init__.py#L125-L140
def get_page(self, target_url): """ Retrieve a specific page of SyncListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListInstance :rtype: twilio.rest.sync.v1....
[ "def", "get_page", "(", "self", ",", "target_url", ")", ":", "response", "=", "self", ".", "_version", ".", "domain", ".", "twilio", ".", "request", "(", "'GET'", ",", "target_url", ",", ")", "return", "SyncListPage", "(", "self", ".", "_version", ",", ...
Retrieve a specific page of SyncListInstance records from the API. Request is executed immediately :param str target_url: API-generated URL for the requested results page :returns: Page of SyncListInstance :rtype: twilio.rest.sync.v1.service.sync_list.SyncListPage
[ "Retrieve", "a", "specific", "page", "of", "SyncListInstance", "records", "from", "the", "API", ".", "Request", "is", "executed", "immediately" ]
python
train
googlefonts/fontbakery
Lib/fontbakery/profiles/cmap.py
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/cmap.py#L10-L30
def com_google_fonts_check_family_equal_unicode_encodings(ttFonts): """Fonts have equal unicode encodings?""" encoding = None failed = False for ttFont in ttFonts: cmap = None for table in ttFont['cmap'].tables: if table.format == 4: cmap = table break # Could a font lack a for...
[ "def", "com_google_fonts_check_family_equal_unicode_encodings", "(", "ttFonts", ")", ":", "encoding", "=", "None", "failed", "=", "False", "for", "ttFont", "in", "ttFonts", ":", "cmap", "=", "None", "for", "table", "in", "ttFont", "[", "'cmap'", "]", ".", "tab...
Fonts have equal unicode encodings?
[ "Fonts", "have", "equal", "unicode", "encodings?" ]
python
train
spyder-ide/spyder
spyder/plugins/base.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/base.py#L112-L131
def create_dockwidget(self): """Add to parent QMainWindow as a dock widget""" # Creating dock widget dock = SpyderDockWidget(self.get_plugin_title(), self.main) # Set properties dock.setObjectName(self.__class__.__name__+"_dw") dock.setAllowedAreas(self.ALLOWED_AREAS) ...
[ "def", "create_dockwidget", "(", "self", ")", ":", "# Creating dock widget", "dock", "=", "SpyderDockWidget", "(", "self", ".", "get_plugin_title", "(", ")", ",", "self", ".", "main", ")", "# Set properties", "dock", ".", "setObjectName", "(", "self", ".", "__...
Add to parent QMainWindow as a dock widget
[ "Add", "to", "parent", "QMainWindow", "as", "a", "dock", "widget" ]
python
train
saltstack/salt
salt/states/rbenv.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rbenv.py#L87-L106
def _check_and_install_ruby(ret, ruby, default=False, user=None): ''' Verify that ruby is installed, install if unavailable ''' ret = _ruby_installed(ret, ruby, user=user) if not ret['result']: if __salt__['rbenv.install_ruby'](ruby, runas=user): ret['result'] = True ...
[ "def", "_check_and_install_ruby", "(", "ret", ",", "ruby", ",", "default", "=", "False", ",", "user", "=", "None", ")", ":", "ret", "=", "_ruby_installed", "(", "ret", ",", "ruby", ",", "user", "=", "user", ")", "if", "not", "ret", "[", "'result'", "...
Verify that ruby is installed, install if unavailable
[ "Verify", "that", "ruby", "is", "installed", "install", "if", "unavailable" ]
python
train
abau171/highfive
highfive/jobs.py
https://github.com/abau171/highfive/blob/07b3829331072035ab100d1d66deca3e8f3f372a/highfive/jobs.py#L114-L124
async def wait_changed(self): """ Waits until the result set changes. Possible changes can be a result being added or the result set becoming complete. If the result set is already completed, this method returns immediately. """ if not self.is_complete(): wai...
[ "async", "def", "wait_changed", "(", "self", ")", ":", "if", "not", "self", ".", "is_complete", "(", ")", ":", "waiter", "=", "self", ".", "_loop", ".", "create_future", "(", ")", "self", ".", "_waiters", ".", "append", "(", "waiter", ")", "await", "...
Waits until the result set changes. Possible changes can be a result being added or the result set becoming complete. If the result set is already completed, this method returns immediately.
[ "Waits", "until", "the", "result", "set", "changes", ".", "Possible", "changes", "can", "be", "a", "result", "being", "added", "or", "the", "result", "set", "becoming", "complete", ".", "If", "the", "result", "set", "is", "already", "completed", "this", "m...
python
test
saltstack/salt
salt/modules/firewalld.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/firewalld.py#L437-L453
def add_service_port(service, port): ''' Add a new port to the specified service. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_service_port zone 80 ''' if service not in get_services(permanent=True): raise CommandExecutionError('The...
[ "def", "add_service_port", "(", "service", ",", "port", ")", ":", "if", "service", "not", "in", "get_services", "(", "permanent", "=", "True", ")", ":", "raise", "CommandExecutionError", "(", "'The service does not exist.'", ")", "cmd", "=", "'--permanent --servic...
Add a new port to the specified service. .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.add_service_port zone 80
[ "Add", "a", "new", "port", "to", "the", "specified", "service", "." ]
python
train
log2timeline/plaso
plaso/output/mysql_4n6time.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/mysql_4n6time.py#L254-L262
def SetServerInformation(self, server, port): """Sets the server information. Args: server (str): hostname or IP address of the database server. port (int): port number of the database server. """ self._host = server self._port = port
[ "def", "SetServerInformation", "(", "self", ",", "server", ",", "port", ")", ":", "self", ".", "_host", "=", "server", "self", ".", "_port", "=", "port" ]
Sets the server information. Args: server (str): hostname or IP address of the database server. port (int): port number of the database server.
[ "Sets", "the", "server", "information", "." ]
python
train
terrycain/aioboto3
aioboto3/resources.py
https://github.com/terrycain/aioboto3/blob/0fd192175461f7bb192f3ed9a872591caf8474ac/aioboto3/resources.py#L183-L240
def _create_action(factory_self, action_model, resource_name, service_context, is_load=False): """ Creates a new method which makes a request to the underlying AWS service. """ # Create the action in in this closure but before the ``do_action`` # me...
[ "def", "_create_action", "(", "factory_self", ",", "action_model", ",", "resource_name", ",", "service_context", ",", "is_load", "=", "False", ")", ":", "# Create the action in in this closure but before the ``do_action``", "# method below is invoked, which allows instances of the ...
Creates a new method which makes a request to the underlying AWS service.
[ "Creates", "a", "new", "method", "which", "makes", "a", "request", "to", "the", "underlying", "AWS", "service", "." ]
python
train
Josef-Friedrich/phrydy
phrydy/mediafile.py
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1150-L1157
def delete(self, mutagen_file): """Remove all images from the file. """ for cover_tag in self.TAG_NAMES.values(): try: del mutagen_file[cover_tag] except KeyError: pass
[ "def", "delete", "(", "self", ",", "mutagen_file", ")", ":", "for", "cover_tag", "in", "self", ".", "TAG_NAMES", ".", "values", "(", ")", ":", "try", ":", "del", "mutagen_file", "[", "cover_tag", "]", "except", "KeyError", ":", "pass" ]
Remove all images from the file.
[ "Remove", "all", "images", "from", "the", "file", "." ]
python
train
DAI-Lab/Copulas
copulas/bivariate/gumbel.py
https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/bivariate/gumbel.py#L20-L35
def probability_density(self, X): """Compute density function for given copula family.""" self.check_fit() U, V = self.split_matrix(X) if self.theta == 1: return np.multiply(U, V) else: a = np.power(np.multiply(U, V), -1) tmp = np.power(-np....
[ "def", "probability_density", "(", "self", ",", "X", ")", ":", "self", ".", "check_fit", "(", ")", "U", ",", "V", "=", "self", ".", "split_matrix", "(", "X", ")", "if", "self", ".", "theta", "==", "1", ":", "return", "np", ".", "multiply", "(", "...
Compute density function for given copula family.
[ "Compute", "density", "function", "for", "given", "copula", "family", "." ]
python
train
aio-libs/aioredis
aioredis/commands/string.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/string.py#L45-L47
def bitop_xor(self, dest, key, *keys): """Perform bitwise XOR operations between strings.""" return self.execute(b'BITOP', b'XOR', dest, key, *keys)
[ "def", "bitop_xor", "(", "self", ",", "dest", ",", "key", ",", "*", "keys", ")", ":", "return", "self", ".", "execute", "(", "b'BITOP'", ",", "b'XOR'", ",", "dest", ",", "key", ",", "*", "keys", ")" ]
Perform bitwise XOR operations between strings.
[ "Perform", "bitwise", "XOR", "operations", "between", "strings", "." ]
python
train
Nic30/hwtGraph
hwtGraph/elk/fromHwt/utils.py
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/utils.py#L84-L92
def getDefault(self, k): """ :return: tuple (value, True if key was there before else False) """ try: return self[k], True except KeyError: v = self[k] = NetCtx(self, k) return v, False
[ "def", "getDefault", "(", "self", ",", "k", ")", ":", "try", ":", "return", "self", "[", "k", "]", ",", "True", "except", "KeyError", ":", "v", "=", "self", "[", "k", "]", "=", "NetCtx", "(", "self", ",", "k", ")", "return", "v", ",", "False" ]
:return: tuple (value, True if key was there before else False)
[ ":", "return", ":", "tuple", "(", "value", "True", "if", "key", "was", "there", "before", "else", "False", ")" ]
python
train
Miserlou/Zappa
zappa/core.py
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2284-L2326
def create_domain_name(self, domain_name, certificate_name, certificate_body=None, certificate_private_key=None, certificate_chain=None, certificate_arn=None,...
[ "def", "create_domain_name", "(", "self", ",", "domain_name", ",", "certificate_name", ",", "certificate_body", "=", "None", ",", "certificate_private_key", "=", "None", ",", "certificate_chain", "=", "None", ",", "certificate_arn", "=", "None", ",", "lambda_name", ...
Creates the API GW domain and returns the resulting DNS name.
[ "Creates", "the", "API", "GW", "domain", "and", "returns", "the", "resulting", "DNS", "name", "." ]
python
train
uber/doubles
doubles/target.py
https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/target.py#L114-L121
def restore_attr(self, attr_name): """Restore an attribute back onto the target object. :param str attr_name: the name of the attribute to restore """ original_attr = self._original_attr(attr_name) if self._original_attr(attr_name): setattr(self.obj.__class__, attr_n...
[ "def", "restore_attr", "(", "self", ",", "attr_name", ")", ":", "original_attr", "=", "self", ".", "_original_attr", "(", "attr_name", ")", "if", "self", ".", "_original_attr", "(", "attr_name", ")", ":", "setattr", "(", "self", ".", "obj", ".", "__class__...
Restore an attribute back onto the target object. :param str attr_name: the name of the attribute to restore
[ "Restore", "an", "attribute", "back", "onto", "the", "target", "object", "." ]
python
train
Rapptz/discord.py
discord/permissions.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/permissions.py#L171-L190
def update(self, **kwargs): r"""Bulk updates this permission object. Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored. Parameters ------------ ...
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "try", ":", "is_property", "=", "isinstance", "(", "getattr", "(", "self", ".", "__class__", ",", "key", ")", ...
r"""Bulk updates this permission object. Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored. Parameters ------------ \*\*kwargs A list o...
[ "r", "Bulk", "updates", "this", "permission", "object", "." ]
python
train
GoogleCloudPlatform/cloud-debug-python
src/googleclouddebugger/capture_collector.py
https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/capture_collector.py#L385-L406
def CaptureNamedVariable(self, name, value, depth, limits): """Appends name to the product of CaptureVariable. Args: name: name of the variable. value: data to capture depth: nested depth of dictionaries and vectors so far. limits: Per-object limits for capturing variable data. Ret...
[ "def", "CaptureNamedVariable", "(", "self", ",", "name", ",", "value", ",", "depth", ",", "limits", ")", ":", "if", "not", "hasattr", "(", "name", ",", "'__dict__'", ")", ":", "name", "=", "str", "(", "name", ")", "else", ":", "# TODO(vlif): call str(nam...
Appends name to the product of CaptureVariable. Args: name: name of the variable. value: data to capture depth: nested depth of dictionaries and vectors so far. limits: Per-object limits for capturing variable data. Returns: Formatted captured data as per Variable proto with name...
[ "Appends", "name", "to", "the", "product", "of", "CaptureVariable", "." ]
python
train
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py#L47-L71
def _WriteIfcfg(self, interfaces, logger): """Write ifcfg files for multi-NIC support. Overwrites the files. This allows us to update ifcfg-* in the future. Disable the network setup to override this behavior and customize the configurations. Args: interfaces: list of string, the output devi...
[ "def", "_WriteIfcfg", "(", "self", ",", "interfaces", ",", "logger", ")", ":", "for", "interface", "in", "interfaces", ":", "interface_config", "=", "os", ".", "path", ".", "join", "(", "self", ".", "network_path", ",", "'ifcfg-%s'", "%", "interface", ")",...
Write ifcfg files for multi-NIC support. Overwrites the files. This allows us to update ifcfg-* in the future. Disable the network setup to override this behavior and customize the configurations. Args: interfaces: list of string, the output device names to enable. logger: logger object, u...
[ "Write", "ifcfg", "files", "for", "multi", "-", "NIC", "support", "." ]
python
train
HumanCellAtlas/dcp-cli
hca/upload/upload_config.py
https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/upload/upload_config.py#L128-L143
def area_uuid_from_partial_uuid(self, partial_uuid): """ Given a partial UUID (a prefix), see if we have know about an Upload Area matching it. :param (str) partial_uuid: UUID prefix :return: a matching UUID :rtype: str :raises UploadException: if no or more than one UUID...
[ "def", "area_uuid_from_partial_uuid", "(", "self", ",", "partial_uuid", ")", ":", "matching_areas", "=", "[", "uuid", "for", "uuid", "in", "self", ".", "areas", "if", "re", ".", "match", "(", "partial_uuid", ",", "uuid", ")", "]", "if", "len", "(", "matc...
Given a partial UUID (a prefix), see if we have know about an Upload Area matching it. :param (str) partial_uuid: UUID prefix :return: a matching UUID :rtype: str :raises UploadException: if no or more than one UUIDs match.
[ "Given", "a", "partial", "UUID", "(", "a", "prefix", ")", "see", "if", "we", "have", "know", "about", "an", "Upload", "Area", "matching", "it", ".", ":", "param", "(", "str", ")", "partial_uuid", ":", "UUID", "prefix", ":", "return", ":", "a", "match...
python
train
aws/aws-iot-device-sdk-python
AWSIoTPythonSDK/core/protocol/paho/client.py
https://github.com/aws/aws-iot-device-sdk-python/blob/f0aa2ce34b21dd2e44f4fb7e1d058656aaf2fc62/AWSIoTPythonSDK/core/protocol/paho/client.py#L1141-L1162
def loop_read(self, max_packets=1): """Process read network events. Use in place of calling loop() if you wish to handle your client reads as part of your own application. Use socket() to obtain the client socket to call select() or equivalent on. Do not use if you are using th...
[ "def", "loop_read", "(", "self", ",", "max_packets", "=", "1", ")", ":", "if", "self", ".", "_sock", "is", "None", "and", "self", ".", "_ssl", "is", "None", ":", "return", "MQTT_ERR_NO_CONN", "max_packets", "=", "len", "(", "self", ".", "_out_messages", ...
Process read network events. Use in place of calling loop() if you wish to handle your client reads as part of your own application. Use socket() to obtain the client socket to call select() or equivalent on. Do not use if you are using the threaded interface loop_start().
[ "Process", "read", "network", "events", ".", "Use", "in", "place", "of", "calling", "loop", "()", "if", "you", "wish", "to", "handle", "your", "client", "reads", "as", "part", "of", "your", "own", "application", "." ]
python
train
vertexproject/synapse
synapse/cortex.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/cortex.py#L225-L231
async def updateTrigger(self, iden, query): ''' Change an existing trigger's query ''' trig = self.cell.triggers.get(iden) self._trig_auth_check(trig.get('useriden')) self.cell.triggers.mod(iden, query)
[ "async", "def", "updateTrigger", "(", "self", ",", "iden", ",", "query", ")", ":", "trig", "=", "self", ".", "cell", ".", "triggers", ".", "get", "(", "iden", ")", "self", ".", "_trig_auth_check", "(", "trig", ".", "get", "(", "'useriden'", ")", ")",...
Change an existing trigger's query
[ "Change", "an", "existing", "trigger", "s", "query" ]
python
train
pytroll/posttroll
posttroll/listener.py
https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/listener.py#L65-L71
def restart_listener(self, topics): '''Restart listener after configuration update. ''' if self.listener is not None: if self.listener.running: self.stop() self.__init__(topics=topics)
[ "def", "restart_listener", "(", "self", ",", "topics", ")", ":", "if", "self", ".", "listener", "is", "not", "None", ":", "if", "self", ".", "listener", ".", "running", ":", "self", ".", "stop", "(", ")", "self", ".", "__init__", "(", "topics", "=", ...
Restart listener after configuration update.
[ "Restart", "listener", "after", "configuration", "update", "." ]
python
train
JdeRobot/base
src/libs/comm_py/comm/ice/irIceClient.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ice/irIceClient.py#L92-L105
def getIRData(self): ''' Returns last LaserData. @return last JdeRobotTypes LaserData saved ''' if self.hasproxy(): self.lock.acquire() ir = self.ir self.lock.release() return ir return None
[ "def", "getIRData", "(", "self", ")", ":", "if", "self", ".", "hasproxy", "(", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "ir", "=", "self", ".", "ir", "self", ".", "lock", ".", "release", "(", ")", "return", "ir", "return", "None" ...
Returns last LaserData. @return last JdeRobotTypes LaserData saved
[ "Returns", "last", "LaserData", "." ]
python
train
ml4ai/delphi
delphi/AnalysisGraph.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/AnalysisGraph.py#L940-L1060
def to_sql(self, app=None, last_known_value_date: Optional[date] = None): """ Inserts the model into the SQLite3 database associated with Delphi, for use with the ICM REST API. """ from delphi.apps.rest_api import create_app, db self.assign_uuids_to_nodes_and_edges() icm_metada...
[ "def", "to_sql", "(", "self", ",", "app", "=", "None", ",", "last_known_value_date", ":", "Optional", "[", "date", "]", "=", "None", ")", ":", "from", "delphi", ".", "apps", ".", "rest_api", "import", "create_app", ",", "db", "self", ".", "assign_uuids_t...
Inserts the model into the SQLite3 database associated with Delphi, for use with the ICM REST API.
[ "Inserts", "the", "model", "into", "the", "SQLite3", "database", "associated", "with", "Delphi", "for", "use", "with", "the", "ICM", "REST", "API", "." ]
python
train
NASA-AMMOS/AIT-Core
ait/core/bsc.py
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/bsc.py#L240-L253
def add_handler(self, handler): ''' Add an additional handler Args: handler: A dictionary of handler configuration for the handler that should be added. See :func:`__init__` for details on valid parameters. ''' handler['logger'...
[ "def", "add_handler", "(", "self", ",", "handler", ")", ":", "handler", "[", "'logger'", "]", "=", "self", ".", "_get_logger", "(", "handler", ")", "handler", "[", "'reads'", "]", "=", "0", "handler", "[", "'data_read'", "]", "=", "0", "self", ".", "...
Add an additional handler Args: handler: A dictionary of handler configuration for the handler that should be added. See :func:`__init__` for details on valid parameters.
[ "Add", "an", "additional", "handler" ]
python
train
tyiannak/pyAudioAnalysis
pyAudioAnalysis/audioFeatureExtraction.py
https://github.com/tyiannak/pyAudioAnalysis/blob/e3da991e7247492deba50648a4c7c0f41e684af4/pyAudioAnalysis/audioFeatureExtraction.py#L19-L23
def stZCR(frame): """Computes zero crossing rate of frame""" count = len(frame) countZ = numpy.sum(numpy.abs(numpy.diff(numpy.sign(frame)))) / 2 return (numpy.float64(countZ) / numpy.float64(count-1.0))
[ "def", "stZCR", "(", "frame", ")", ":", "count", "=", "len", "(", "frame", ")", "countZ", "=", "numpy", ".", "sum", "(", "numpy", ".", "abs", "(", "numpy", ".", "diff", "(", "numpy", ".", "sign", "(", "frame", ")", ")", ")", ")", "/", "2", "r...
Computes zero crossing rate of frame
[ "Computes", "zero", "crossing", "rate", "of", "frame" ]
python
train
DEIB-GECO/PyGMQL
gmql/ml/algorithms/clustering.py
https://github.com/DEIB-GECO/PyGMQL/blob/e58b2f9402a86056dcda484a32e3de0bb06ed991/gmql/ml/algorithms/clustering.py#L415-L422
def normalized_mutual_info_score(self, reference_clusters): """ Calculates the normalized mutual information w.r.t. the reference clusters (explicit evaluation) :param reference_clusters: Clusters that are to be used as reference :return: The resulting normalized mutual information scor...
[ "def", "normalized_mutual_info_score", "(", "self", ",", "reference_clusters", ")", ":", "return", "normalized_mutual_info_score", "(", "self", ".", "get_labels", "(", "self", ")", ",", "self", ".", "get_labels", "(", "reference_clusters", ")", ")" ]
Calculates the normalized mutual information w.r.t. the reference clusters (explicit evaluation) :param reference_clusters: Clusters that are to be used as reference :return: The resulting normalized mutual information score.
[ "Calculates", "the", "normalized", "mutual", "information", "w", ".", "r", ".", "t", ".", "the", "reference", "clusters", "(", "explicit", "evaluation", ")" ]
python
train
bitlabstudio/django-subscribe
subscribe/forms.py
https://github.com/bitlabstudio/django-subscribe/blob/313de63fb4acda172e88b65c3327c793f98e8aa9/subscribe/forms.py#L29-L36
def save(self, *args, **kwargs): """Adds a subscription for the given user to the given object.""" method_kwargs = self._get_method_kwargs() try: subscription = Subscription.objects.get(**method_kwargs) except Subscription.DoesNotExist: subscription = Subscription...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "method_kwargs", "=", "self", ".", "_get_method_kwargs", "(", ")", "try", ":", "subscription", "=", "Subscription", ".", "objects", ".", "get", "(", "*", "*", "method_kwar...
Adds a subscription for the given user to the given object.
[ "Adds", "a", "subscription", "for", "the", "given", "user", "to", "the", "given", "object", "." ]
python
train
openstack/horizon
openstack_dashboard/dashboards/project/key_pairs/tables.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/key_pairs/tables.py#L110-L114
def filter(self, table, keypairs, filter_string): """Naive case-insensitive search.""" query = filter_string.lower() return [keypair for keypair in keypairs if query in keypair.name.lower()]
[ "def", "filter", "(", "self", ",", "table", ",", "keypairs", ",", "filter_string", ")", ":", "query", "=", "filter_string", ".", "lower", "(", ")", "return", "[", "keypair", "for", "keypair", "in", "keypairs", "if", "query", "in", "keypair", ".", "name",...
Naive case-insensitive search.
[ "Naive", "case", "-", "insensitive", "search", "." ]
python
train
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L10428-L10448
def reordi(iorder, ndim, array): """ Re-order the elements of an integer array according to a given order vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/reordi_c.html :param iorder: Order vector to be used to re-order array. :type iorder: Array of ints :param ndim: Dimensi...
[ "def", "reordi", "(", "iorder", ",", "ndim", ",", "array", ")", ":", "iorder", "=", "stypes", ".", "toIntVector", "(", "iorder", ")", "ndim", "=", "ctypes", ".", "c_int", "(", "ndim", ")", "array", "=", "stypes", ".", "toIntVector", "(", "array", ")"...
Re-order the elements of an integer array according to a given order vector. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/reordi_c.html :param iorder: Order vector to be used to re-order array. :type iorder: Array of ints :param ndim: Dimension of array. :type ndim: int :param a...
[ "Re", "-", "order", "the", "elements", "of", "an", "integer", "array", "according", "to", "a", "given", "order", "vector", "." ]
python
train
revelc/pyaccumulo
pyaccumulo/proxy/AccumuloProxy.py
https://github.com/revelc/pyaccumulo/blob/8adcf535bb82ba69c749efce785c9efc487e85de/pyaccumulo/proxy/AccumuloProxy.py#L1577-L1586
def mergeTablets(self, login, tableName, startRow, endRow): """ Parameters: - login - tableName - startRow - endRow """ self.send_mergeTablets(login, tableName, startRow, endRow) self.recv_mergeTablets()
[ "def", "mergeTablets", "(", "self", ",", "login", ",", "tableName", ",", "startRow", ",", "endRow", ")", ":", "self", ".", "send_mergeTablets", "(", "login", ",", "tableName", ",", "startRow", ",", "endRow", ")", "self", ".", "recv_mergeTablets", "(", ")" ...
Parameters: - login - tableName - startRow - endRow
[ "Parameters", ":", "-", "login", "-", "tableName", "-", "startRow", "-", "endRow" ]
python
train
alpacahq/pylivetrader
pylivetrader/backend/alpaca.py
https://github.com/alpacahq/pylivetrader/blob/fd328b6595428c0789d9f218df34623f83a02b8b/pylivetrader/backend/alpaca.py#L474-L527
def get_bars(self, assets, data_frequency, bar_count=500): ''' Interface method. Return: pd.Dataframe() with columns MultiIndex [asset -> OHLCV] ''' assets_is_scalar = not isinstance(assets, (list, set, tuple)) is_daily = 'd' in data_frequency # 'daily' or '1d' ...
[ "def", "get_bars", "(", "self", ",", "assets", ",", "data_frequency", ",", "bar_count", "=", "500", ")", ":", "assets_is_scalar", "=", "not", "isinstance", "(", "assets", ",", "(", "list", ",", "set", ",", "tuple", ")", ")", "is_daily", "=", "'d'", "in...
Interface method. Return: pd.Dataframe() with columns MultiIndex [asset -> OHLCV]
[ "Interface", "method", "." ]
python
train
fuzeman/PyUPnP
pyupnp/lict.py
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L249-L255
def remove(self, value): """ L.remove(value) -- remove first occurrence of value. Raises ValueError if the value is not present. """ self._col_list.remove(value) self._col_dict.pop(self._get_object_key(value))
[ "def", "remove", "(", "self", ",", "value", ")", ":", "self", ".", "_col_list", ".", "remove", "(", "value", ")", "self", ".", "_col_dict", ".", "pop", "(", "self", ".", "_get_object_key", "(", "value", ")", ")" ]
L.remove(value) -- remove first occurrence of value. Raises ValueError if the value is not present.
[ "L", ".", "remove", "(", "value", ")", "--", "remove", "first", "occurrence", "of", "value", ".", "Raises", "ValueError", "if", "the", "value", "is", "not", "present", "." ]
python
train
materialsproject/pymatgen
pymatgen/transformations/standard_transformations.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/transformations/standard_transformations.py#L768-L796
def apply_transformation(self, structure): """ Discretizes the site occupancies in the structure. Args: structure: disordered Structure to discretize occupancies Returns: A new disordered Structure with occupancies discretized """ if structure.is...
[ "def", "apply_transformation", "(", "self", ",", "structure", ")", ":", "if", "structure", ".", "is_ordered", ":", "return", "structure", "species", "=", "[", "dict", "(", "sp", ")", "for", "sp", "in", "structure", ".", "species_and_occu", "]", "for", "sp"...
Discretizes the site occupancies in the structure. Args: structure: disordered Structure to discretize occupancies Returns: A new disordered Structure with occupancies discretized
[ "Discretizes", "the", "site", "occupancies", "in", "the", "structure", "." ]
python
train
zhanglab/psamm
psamm/lpsolver/glpk.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/glpk.py#L444-L447
def _get_value(self, variable): """Return value of variable in solution.""" return swiglpk.glp_mip_col_val( self._problem._p, self._problem._variables[variable])
[ "def", "_get_value", "(", "self", ",", "variable", ")", ":", "return", "swiglpk", ".", "glp_mip_col_val", "(", "self", ".", "_problem", ".", "_p", ",", "self", ".", "_problem", ".", "_variables", "[", "variable", "]", ")" ]
Return value of variable in solution.
[ "Return", "value", "of", "variable", "in", "solution", "." ]
python
train
bionikspoon/cache_requests
cache_requests/memoize.py
https://github.com/bionikspoon/cache_requests/blob/d75f6f944bc5a72fef5d7811e4973e124d9921dd/cache_requests/memoize.py#L97-L107
def put_cache_results(self, key, func_akw, set_cache_cb): """Put function results into cache.""" args, kwargs = func_akw # get function results func_results = self.func(*args, **kwargs) # optionally add results to cache if set_cache_cb(func_results): self[ke...
[ "def", "put_cache_results", "(", "self", ",", "key", ",", "func_akw", ",", "set_cache_cb", ")", ":", "args", ",", "kwargs", "=", "func_akw", "# get function results", "func_results", "=", "self", ".", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")",...
Put function results into cache.
[ "Put", "function", "results", "into", "cache", "." ]
python
train
nickmckay/LiPD-utilities
Python/lipd/noaa_lpd.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L578-L603
def __name_unit_regex(word): """ Split a name and unit that are bunched together (i.e. '250m') :param str word: :return str str: """ value = "" unit = "" r = re.findall(re_name_unit, word) try: value = r[0][0] except IndexError ...
[ "def", "__name_unit_regex", "(", "word", ")", ":", "value", "=", "\"\"", "unit", "=", "\"\"", "r", "=", "re", ".", "findall", "(", "re_name_unit", ",", "word", ")", "try", ":", "value", "=", "r", "[", "0", "]", "[", "0", "]", "except", "IndexError"...
Split a name and unit that are bunched together (i.e. '250m') :param str word: :return str str:
[ "Split", "a", "name", "and", "unit", "that", "are", "bunched", "together", "(", "i", ".", "e", ".", "250m", ")", ":", "param", "str", "word", ":", ":", "return", "str", "str", ":" ]
python
train
numenta/htmresearch
htmresearch/algorithms/union_temporal_pooler.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/union_temporal_pooler.py#L180-L246
def compute(self, activeInput, predictedActiveInput, learn): """ Computes one cycle of the Union Temporal Pooler algorithm. @param activeInput (numpy array) A numpy array of 0's and 1's that comprises the input to the union pooler @param predictedActiveInput (numpy array) A numpy array of 0...
[ "def", "compute", "(", "self", ",", "activeInput", ",", "predictedActiveInput", ",", "learn", ")", ":", "assert", "numpy", ".", "size", "(", "activeInput", ")", "==", "self", ".", "getNumInputs", "(", ")", "assert", "numpy", ".", "size", "(", "predictedAct...
Computes one cycle of the Union Temporal Pooler algorithm. @param activeInput (numpy array) A numpy array of 0's and 1's that comprises the input to the union pooler @param predictedActiveInput (numpy array) A numpy array of 0's and 1's that comprises the correctly predicted input to the union pool...
[ "Computes", "one", "cycle", "of", "the", "Union", "Temporal", "Pooler", "algorithm", "." ]
python
train
ranaroussi/ezibpy
ezibpy/utils.py
https://github.com/ranaroussi/ezibpy/blob/1a9d4bf52018abd2a01af7c991d7cf00cda53e0c/ezibpy/utils.py#L204-L207
def order_to_dict(order): """Convert an IBPy Order object to a dict containing any non-default values.""" default = Order() return {field: val for field, val in vars(order).items() if val != getattr(default, field, None)}
[ "def", "order_to_dict", "(", "order", ")", ":", "default", "=", "Order", "(", ")", "return", "{", "field", ":", "val", "for", "field", ",", "val", "in", "vars", "(", "order", ")", ".", "items", "(", ")", "if", "val", "!=", "getattr", "(", "default"...
Convert an IBPy Order object to a dict containing any non-default values.
[ "Convert", "an", "IBPy", "Order", "object", "to", "a", "dict", "containing", "any", "non", "-", "default", "values", "." ]
python
train
eleme/ruskit
ruskit/utils.py
https://github.com/eleme/ruskit/blob/2e8c5a3f6a65b8aeb07012b4e2c8ba324d887c3b/ruskit/utils.py#L57-L76
def spread(nodes, n): """Distrubute master instances in different nodes { "192.168.0.1": [node1, node2], "192.168.0.2": [node3, node4], "192.168.0.3": [node5, node6] } => [node1, node3, node5] """ target = [] while len(target) < n and nodes: for ip, node_group i...
[ "def", "spread", "(", "nodes", ",", "n", ")", ":", "target", "=", "[", "]", "while", "len", "(", "target", ")", "<", "n", "and", "nodes", ":", "for", "ip", ",", "node_group", "in", "list", "(", "nodes", ".", "items", "(", ")", ")", ":", "if", ...
Distrubute master instances in different nodes { "192.168.0.1": [node1, node2], "192.168.0.2": [node3, node4], "192.168.0.3": [node5, node6] } => [node1, node3, node5]
[ "Distrubute", "master", "instances", "in", "different", "nodes" ]
python
train
wummel/linkchecker
linkcheck/cache/urlqueue.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/cache/urlqueue.py#L108-L114
def put (self, item): """Put an item into the queue. Block if necessary until a free slot is available. """ with self.mutex: self._put(item) self.not_empty.notify()
[ "def", "put", "(", "self", ",", "item", ")", ":", "with", "self", ".", "mutex", ":", "self", ".", "_put", "(", "item", ")", "self", ".", "not_empty", ".", "notify", "(", ")" ]
Put an item into the queue. Block if necessary until a free slot is available.
[ "Put", "an", "item", "into", "the", "queue", ".", "Block", "if", "necessary", "until", "a", "free", "slot", "is", "available", "." ]
python
train