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 |
|---|---|---|---|---|---|---|---|---|
ipfs/py-ipfs-api | ipfsapi/client.py | https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2194-L2221 | def add_pyobj(self, py_obj, **kwargs):
"""Adds a picklable Python object as a file to IPFS.
.. deprecated:: 0.4.2
The ``*_pyobj`` APIs allow for arbitrary code execution if abused.
Either switch to :meth:`~ipfsapi.Client.add_json` or use
``client.add_bytes(pickle.dumps(... | [
"def",
"add_pyobj",
"(",
"self",
",",
"py_obj",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Using `*_pyobj` on untrusted data is a security risk\"",
",",
"DeprecationWarning",
")",
"return",
"self",
".",
"add_bytes",
"(",
"encoding",
".",
... | Adds a picklable Python object as a file to IPFS.
.. deprecated:: 0.4.2
The ``*_pyobj`` APIs allow for arbitrary code execution if abused.
Either switch to :meth:`~ipfsapi.Client.add_json` or use
``client.add_bytes(pickle.dumps(py_obj))`` instead.
Please see :meth:`~ip... | [
"Adds",
"a",
"picklable",
"Python",
"object",
"as",
"a",
"file",
"to",
"IPFS",
"."
] | python | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/plotManager.py | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/plotManager.py#L290-L498 | def plot_elements_to_ax(self, cid, ax=None, **kwargs):
"""Plot element data (parameter sets).
If the parameter *ax* is not set, then a new figure will be created
with a corresponding axes.
Parameters
----------
cid : int or :py:class:`numpy.ndarray`
if *cid... | [
"def",
"plot_elements_to_ax",
"(",
"self",
",",
"cid",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"rasterize",
"=",
"kwargs",
".",
"get",
"(",
"'rasterize'",
",",
"False",
")",
"xmin",
"=",
"kwargs",
".",
"get",
"(",
"'xmin'",
",",
... | Plot element data (parameter sets).
If the parameter *ax* is not set, then a new figure will be created
with a corresponding axes.
Parameters
----------
cid : int or :py:class:`numpy.ndarray`
if *cid* is an int, then treat it as the id of the parameter set
... | [
"Plot",
"element",
"data",
"(",
"parameter",
"sets",
")",
"."
] | python | train |
lpantano/seqcluster | seqcluster/libs/thinkbayes.py | https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/thinkbayes.py#L1283-L1296 | def MakeSuiteFromDict(d, name=''):
"""Makes a suite from a map from values to probabilities.
Args:
d: dictionary that maps values to probabilities
name: string name for this suite
Returns:
Suite object
"""
suite = Suite(name=name)
suite.SetDict(d)
suite.Normalize()
... | [
"def",
"MakeSuiteFromDict",
"(",
"d",
",",
"name",
"=",
"''",
")",
":",
"suite",
"=",
"Suite",
"(",
"name",
"=",
"name",
")",
"suite",
".",
"SetDict",
"(",
"d",
")",
"suite",
".",
"Normalize",
"(",
")",
"return",
"suite"
] | Makes a suite from a map from values to probabilities.
Args:
d: dictionary that maps values to probabilities
name: string name for this suite
Returns:
Suite object | [
"Makes",
"a",
"suite",
"from",
"a",
"map",
"from",
"values",
"to",
"probabilities",
"."
] | python | train |
idlesign/uwsgiconf | uwsgiconf/options/caching.py | https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/options/caching.py#L83-L196 | def add_cache(
self, name, max_items, expires=None, store=None, store_sync_interval=None, store_delete=None,
hash_algo=None, hash_size=None, key_size=None, udp_clients=None, udp_servers=None,
block_size=None, block_count=None, sync_from=None, mode_bitmap=None, use_lastmod=None,
... | [
"def",
"add_cache",
"(",
"self",
",",
"name",
",",
"max_items",
",",
"expires",
"=",
"None",
",",
"store",
"=",
"None",
",",
"store_sync_interval",
"=",
"None",
",",
"store_delete",
"=",
"None",
",",
"hash_algo",
"=",
"None",
",",
"hash_size",
"=",
"None... | Creates cache. Default mode: single block.
.. note:: This uses new generation ``cache2`` option available since uWSGI 1.9.
.. note:: When at least one cache is configured without ``full_purge_lru``
and the master is enabled a thread named "the cache sweeper" is started.
Its mai... | [
"Creates",
"cache",
".",
"Default",
"mode",
":",
"single",
"block",
"."
] | python | train |
LIVVkit/LIVVkit | livvkit/util/elements.py | https://github.com/LIVVkit/LIVVkit/blob/680120cd437e408673e62e535fc0a246c7fc17db/livvkit/util/elements.py#L92-L126 | def tab(tab_name, element_list=None, section_list=None):
"""
Returns a dictionary representing a new tab to display elements.
This can be thought of as a simple container for displaying multiple
types of information.
Args:
tab_name: The title to display
element_list: The list of ele... | [
"def",
"tab",
"(",
"tab_name",
",",
"element_list",
"=",
"None",
",",
"section_list",
"=",
"None",
")",
":",
"_tab",
"=",
"{",
"'Type'",
":",
"'Tab'",
",",
"'Title'",
":",
"tab_name",
",",
"}",
"if",
"element_list",
"is",
"not",
"None",
":",
"if",
"i... | Returns a dictionary representing a new tab to display elements.
This can be thought of as a simple container for displaying multiple
types of information.
Args:
tab_name: The title to display
element_list: The list of elements to display. If a single element is
given ... | [
"Returns",
"a",
"dictionary",
"representing",
"a",
"new",
"tab",
"to",
"display",
"elements",
".",
"This",
"can",
"be",
"thought",
"of",
"as",
"a",
"simple",
"container",
"for",
"displaying",
"multiple",
"types",
"of",
"information",
"."
] | python | train |
codenerix/django-codenerix | codenerix/authbackend.py | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L407-L429 | def debug(self, msg):
'''
Handle the debugging to a file
'''
# If debug is not disabled
if self.__debug is not False:
# If never was set, try to set it up
if self.__debug is None:
# Check what do we have inside settings
de... | [
"def",
"debug",
"(",
"self",
",",
"msg",
")",
":",
"# If debug is not disabled",
"if",
"self",
".",
"__debug",
"is",
"not",
"False",
":",
"# If never was set, try to set it up",
"if",
"self",
".",
"__debug",
"is",
"None",
":",
"# Check what do we have inside setting... | Handle the debugging to a file | [
"Handle",
"the",
"debugging",
"to",
"a",
"file"
] | python | train |
nickmckay/LiPD-utilities | Python/lipd/directory.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/directory.py#L192-L202 | def collect_metadata_file(full_path):
"""
Create the file metadata and add it to the appropriate section by file-type
:param str full_path:
:param dict existing_files:
:return dict existing files:
"""
fne = os.path.basename(full_path)
fn = os.path.splitext(fne)[0]
obj = {"full_path":... | [
"def",
"collect_metadata_file",
"(",
"full_path",
")",
":",
"fne",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"full_path",
")",
"fn",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"fne",
")",
"[",
"0",
"]",
"obj",
"=",
"{",
"\"full_path\"",
":",
... | Create the file metadata and add it to the appropriate section by file-type
:param str full_path:
:param dict existing_files:
:return dict existing files: | [
"Create",
"the",
"file",
"metadata",
"and",
"add",
"it",
"to",
"the",
"appropriate",
"section",
"by",
"file",
"-",
"type",
":",
"param",
"str",
"full_path",
":",
":",
"param",
"dict",
"existing_files",
":",
":",
"return",
"dict",
"existing",
"files",
":"
] | python | train |
rshk/python-libxdo | xdo/__init__.py | https://github.com/rshk/python-libxdo/blob/84cafa5943b005bc423edd28203a5266b3579ac3/xdo/__init__.py#L596-L604 | def select_window_with_click(self):
"""
Get a window ID by clicking on it.
This function blocks until a selection is made.
"""
window_ret = window_t(0)
_libxdo.xdo_select_window_with_click(
self._xdo, ctypes.byref(window_ret))
return window_ret.value | [
"def",
"select_window_with_click",
"(",
"self",
")",
":",
"window_ret",
"=",
"window_t",
"(",
"0",
")",
"_libxdo",
".",
"xdo_select_window_with_click",
"(",
"self",
".",
"_xdo",
",",
"ctypes",
".",
"byref",
"(",
"window_ret",
")",
")",
"return",
"window_ret",
... | Get a window ID by clicking on it.
This function blocks until a selection is made. | [
"Get",
"a",
"window",
"ID",
"by",
"clicking",
"on",
"it",
".",
"This",
"function",
"blocks",
"until",
"a",
"selection",
"is",
"made",
"."
] | python | train |
bububa/pyTOP | pyTOP/simba.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/simba.py#L310-L322 | def add(self, campaign_id, item_id, default_price, title, img_url, nick=None):
'''xxxxx.xxxxx.adgroup.add
===================================
创建一个推广组'''
request = TOPRequest('xxxxx.xxxxx.adgroup.add')
request['campaign_id'] = campaign_id
request['item_id'] = item_id
... | [
"def",
"add",
"(",
"self",
",",
"campaign_id",
",",
"item_id",
",",
"default_price",
",",
"title",
",",
"img_url",
",",
"nick",
"=",
"None",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'xxxxx.xxxxx.adgroup.add'",
")",
"request",
"[",
"'campaign_id'",
"]",
... | xxxxx.xxxxx.adgroup.add
===================================
创建一个推广组 | [
"xxxxx",
".",
"xxxxx",
".",
"adgroup",
".",
"add",
"===================================",
"创建一个推广组"
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/data_generators/text_encoder.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/text_encoder.py#L750-L866 | def build_from_token_counts(self,
token_counts,
min_count,
num_iterations=4,
reserved_tokens=None,
max_subtoken_length=None):
"""Train a SubwordTextEncoder based on a... | [
"def",
"build_from_token_counts",
"(",
"self",
",",
"token_counts",
",",
"min_count",
",",
"num_iterations",
"=",
"4",
",",
"reserved_tokens",
"=",
"None",
",",
"max_subtoken_length",
"=",
"None",
")",
":",
"if",
"reserved_tokens",
"is",
"None",
":",
"reserved_t... | Train a SubwordTextEncoder based on a dictionary of word counts.
Args:
token_counts: a dictionary of Unicode strings to int.
min_count: an integer - discard subtokens with lower counts.
num_iterations: an integer. how many iterations of refinement.
reserved_tokens: List of reserved tokens.... | [
"Train",
"a",
"SubwordTextEncoder",
"based",
"on",
"a",
"dictionary",
"of",
"word",
"counts",
"."
] | python | train |
sendwithus/sendwithus_python | sendwithus/__init__.py | https://github.com/sendwithus/sendwithus_python/blob/8ae50d514febd44f7d9be3c838b4d92f99412832/sendwithus/__init__.py#L755-L774 | def _api_request(self, endpoint, http_method, *args, **kwargs):
"""Private method for api requests"""
logger.debug(' > Queing batch api request for endpoint: %s' % endpoint)
path = self._build_request_path(endpoint, absolute=False)
logger.debug('\tpath: %s' % path)
data = None
... | [
"def",
"_api_request",
"(",
"self",
",",
"endpoint",
",",
"http_method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"' > Queing batch api request for endpoint: %s'",
"%",
"endpoint",
")",
"path",
"=",
"self",
".",
"_bui... | Private method for api requests | [
"Private",
"method",
"for",
"api",
"requests"
] | python | valid |
alvarogzp/telegram-bot-framework | bot/multithreading/scheduler.py | https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/multithreading/scheduler.py#L156-L166 | def new_worker_pool(self, name: str, min_workers: int = 0, max_workers: int = 1,
max_seconds_idle: int = DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE):
"""
Creates a new worker pool and starts it.
Returns the Worker that schedules works to the pool.
"""
if not sel... | [
"def",
"new_worker_pool",
"(",
"self",
",",
"name",
":",
"str",
",",
"min_workers",
":",
"int",
"=",
"0",
",",
"max_workers",
":",
"int",
"=",
"1",
",",
"max_seconds_idle",
":",
"int",
"=",
"DEFAULT_WORKER_POOL_MAX_SECONDS_IDLE",
")",
":",
"if",
"not",
"se... | Creates a new worker pool and starts it.
Returns the Worker that schedules works to the pool. | [
"Creates",
"a",
"new",
"worker",
"pool",
"and",
"starts",
"it",
".",
"Returns",
"the",
"Worker",
"that",
"schedules",
"works",
"to",
"the",
"pool",
"."
] | python | train |
apache/incubator-mxnet | python/mxnet/optimizer/optimizer.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L1701-L1710 | def get_states(self, dump_optimizer=False):
"""Gets updater states.
Parameters
----------
dump_optimizer : bool, default False
Whether to also save the optimizer itself. This would also save optimizer
information such as learning rate and weight decay schedules.
... | [
"def",
"get_states",
"(",
"self",
",",
"dump_optimizer",
"=",
"False",
")",
":",
"return",
"pickle",
".",
"dumps",
"(",
"(",
"self",
".",
"states",
",",
"self",
".",
"optimizer",
")",
"if",
"dump_optimizer",
"else",
"self",
".",
"states",
")"
] | Gets updater states.
Parameters
----------
dump_optimizer : bool, default False
Whether to also save the optimizer itself. This would also save optimizer
information such as learning rate and weight decay schedules. | [
"Gets",
"updater",
"states",
"."
] | python | train |
spyder-ide/spyder | spyder/widgets/fileswitcher.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/fileswitcher.py#L565-L575 | def get_widget(self, index=None, path=None, tabs=None):
"""Get widget by index.
If no tabs and index specified the current active widget is returned.
"""
if (index and tabs) or (path and tabs):
return tabs.widget(index)
elif self.plugin:
return self.get_p... | [
"def",
"get_widget",
"(",
"self",
",",
"index",
"=",
"None",
",",
"path",
"=",
"None",
",",
"tabs",
"=",
"None",
")",
":",
"if",
"(",
"index",
"and",
"tabs",
")",
"or",
"(",
"path",
"and",
"tabs",
")",
":",
"return",
"tabs",
".",
"widget",
"(",
... | Get widget by index.
If no tabs and index specified the current active widget is returned. | [
"Get",
"widget",
"by",
"index",
"."
] | python | train |
ARMmbed/yotta | yotta/lib/component.py | https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/component.py#L41-L65 | def _truthyConfValue(v):
''' Determine yotta-config truthiness. In yotta config land truthiness is
different to python or json truthiness (in order to map nicely only
preprocessor and CMake definediness):
json -> python -> truthy/falsey
false -> False -> Falsey
... | [
"def",
"_truthyConfValue",
"(",
"v",
")",
":",
"if",
"v",
"is",
"False",
":",
"return",
"False",
"elif",
"v",
"is",
"None",
":",
"return",
"False",
"elif",
"v",
"==",
"0",
":",
"return",
"False",
"else",
":",
"# everything else is truthy!",
"return",
"Tr... | Determine yotta-config truthiness. In yotta config land truthiness is
different to python or json truthiness (in order to map nicely only
preprocessor and CMake definediness):
json -> python -> truthy/falsey
false -> False -> Falsey
null -> None -> Falsey
... | [
"Determine",
"yotta",
"-",
"config",
"truthiness",
".",
"In",
"yotta",
"config",
"land",
"truthiness",
"is",
"different",
"to",
"python",
"or",
"json",
"truthiness",
"(",
"in",
"order",
"to",
"map",
"nicely",
"only",
"preprocessor",
"and",
"CMake",
"definedine... | python | valid |
datacats/datacats | datacats/environment.py | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L295-L304 | def create_ckan_ini(self):
"""
Use make-config to generate an initial development.ini file
"""
self.run_command(
command='/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config'
' ckan /project/development.ini',
rw_project=True,
ro={s... | [
"def",
"create_ckan_ini",
"(",
"self",
")",
":",
"self",
".",
"run_command",
"(",
"command",
"=",
"'/scripts/run_as_user.sh /usr/lib/ckan/bin/paster make-config'",
"' ckan /project/development.ini'",
",",
"rw_project",
"=",
"True",
",",
"ro",
"=",
"{",
"scripts",
".",
... | Use make-config to generate an initial development.ini file | [
"Use",
"make",
"-",
"config",
"to",
"generate",
"an",
"initial",
"development",
".",
"ini",
"file"
] | python | train |
PmagPy/PmagPy | SPD/lib/lib_arai_plot_statistics.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_arai_plot_statistics.py#L297-L307 | def get_normed_points(point_array, norm): # good to go
"""
input: point_array, norm
output: normed array
"""
norm = float(norm)
#floated_array = []
#for p in point_array: # need to make sure each point is a float
#floated_array.append(float(p))
points = old_div(numpy.array(point_... | [
"def",
"get_normed_points",
"(",
"point_array",
",",
"norm",
")",
":",
"# good to go",
"norm",
"=",
"float",
"(",
"norm",
")",
"#floated_array = []",
"#for p in point_array: # need to make sure each point is a float",
"#floated_array.append(float(p))",
"points",
"=",
"old_div... | input: point_array, norm
output: normed array | [
"input",
":",
"point_array",
"norm",
"output",
":",
"normed",
"array"
] | python | train |
Vagrants/blackbird | blackbird/utils/configread.py | https://github.com/Vagrants/blackbird/blob/3b38cd5650caae362e0668dbd38bf8f88233e079/blackbird/utils/configread.py#L229-L250 | def add_default_module_dir(self):
"""
Add directory to store built-in plugins to `module_dir` parameter.
Default directory to store plugins is `BLACKBIRD_INSTALL_DIR/plugins`.
:rtype: None
:return: None
"""
default_module_dir = os.path.join(
os.path.ab... | [
"def",
"add_default_module_dir",
"(",
"self",
")",
":",
"default_module_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"curdir",
")",
",",
"'plugins'",
")",
"module_dir_params",
"=",
"{",
... | Add directory to store built-in plugins to `module_dir` parameter.
Default directory to store plugins is `BLACKBIRD_INSTALL_DIR/plugins`.
:rtype: None
:return: None | [
"Add",
"directory",
"to",
"store",
"built",
"-",
"in",
"plugins",
"to",
"module_dir",
"parameter",
".",
"Default",
"directory",
"to",
"store",
"plugins",
"is",
"BLACKBIRD_INSTALL_DIR",
"/",
"plugins",
".",
":",
"rtype",
":",
"None",
":",
"return",
":",
"None... | python | train |
jayvdb/flake8-putty | flake8_putty/config.py | https://github.com/jayvdb/flake8-putty/blob/854b2c6daef409974c2f5e9c5acaf0a069b0ff23/flake8_putty/config.py#L267-L278 | def match(self, filename, line, codes):
"""Match rule."""
if ((not self.file_selectors or self.file_match_any(filename)) and
(not self.environment_marker_selector or
self.environment_marker_evaluate()) and
(not self.code_selectors or self.codes_match_any(... | [
"def",
"match",
"(",
"self",
",",
"filename",
",",
"line",
",",
"codes",
")",
":",
"if",
"(",
"(",
"not",
"self",
".",
"file_selectors",
"or",
"self",
".",
"file_match_any",
"(",
"filename",
")",
")",
"and",
"(",
"not",
"self",
".",
"environment_marker... | Match rule. | [
"Match",
"rule",
"."
] | python | train |
dereneaton/ipyrad | ipyrad/analysis/bucky.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/bucky.py#L599-L608 | def _resolveambig(subseq):
"""
Randomly resolves iupac hetero codes. This is a shortcut
for now, we could instead use the phased alleles in RAD loci.
"""
N = []
for col in subseq:
rand = np.random.binomial(1, 0.5)
N.append([_AMBIGS[i][rand] for i in col])
return np.array(N) | [
"def",
"_resolveambig",
"(",
"subseq",
")",
":",
"N",
"=",
"[",
"]",
"for",
"col",
"in",
"subseq",
":",
"rand",
"=",
"np",
".",
"random",
".",
"binomial",
"(",
"1",
",",
"0.5",
")",
"N",
".",
"append",
"(",
"[",
"_AMBIGS",
"[",
"i",
"]",
"[",
... | Randomly resolves iupac hetero codes. This is a shortcut
for now, we could instead use the phased alleles in RAD loci. | [
"Randomly",
"resolves",
"iupac",
"hetero",
"codes",
".",
"This",
"is",
"a",
"shortcut",
"for",
"now",
"we",
"could",
"instead",
"use",
"the",
"phased",
"alleles",
"in",
"RAD",
"loci",
"."
] | python | valid |
pypa/pipenv | pipenv/project.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/project.py#L159-L164 | def path_to(self, p):
"""Returns the absolute path to a given relative path."""
if os.path.isabs(p):
return p
return os.sep.join([self._original_dir, p]) | [
"def",
"path_to",
"(",
"self",
",",
"p",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"p",
")",
":",
"return",
"p",
"return",
"os",
".",
"sep",
".",
"join",
"(",
"[",
"self",
".",
"_original_dir",
",",
"p",
"]",
")"
] | Returns the absolute path to a given relative path. | [
"Returns",
"the",
"absolute",
"path",
"to",
"a",
"given",
"relative",
"path",
"."
] | python | train |
gholt/swiftly | swiftly/client/standardclient.py | https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/standardclient.py#L222-L250 | def auth(self):
"""
See :py:func:`swiftly.client.client.Client.auth`
"""
self.reset()
if not self.auth_url:
raise ValueError('No Auth URL has been provided.')
funcs = []
if self.auth_methods:
for method in self.auth_methods.split(','):
... | [
"def",
"auth",
"(",
"self",
")",
":",
"self",
".",
"reset",
"(",
")",
"if",
"not",
"self",
".",
"auth_url",
":",
"raise",
"ValueError",
"(",
"'No Auth URL has been provided.'",
")",
"funcs",
"=",
"[",
"]",
"if",
"self",
".",
"auth_methods",
":",
"for",
... | See :py:func:`swiftly.client.client.Client.auth` | [
"See",
":",
"py",
":",
"func",
":",
"swiftly",
".",
"client",
".",
"client",
".",
"Client",
".",
"auth"
] | python | test |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L6830-L6866 | def Runtime_compileScript(self, expression, sourceURL, persistScript, **kwargs
):
"""
Function path: Runtime.compileScript
Domain: Runtime
Method name: compileScript
Parameters:
Required arguments:
'expression' (type: string) -> Expression to compile.
'sourceURL' (type: string) -> Sou... | [
"def",
"Runtime_compileScript",
"(",
"self",
",",
"expression",
",",
"sourceURL",
",",
"persistScript",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"isinstance",
"(",
"expression",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'expression' must be of type '[... | Function path: Runtime.compileScript
Domain: Runtime
Method name: compileScript
Parameters:
Required arguments:
'expression' (type: string) -> Expression to compile.
'sourceURL' (type: string) -> Source url to be set for the script.
'persistScript' (type: boolean) -> Specifies whether the... | [
"Function",
"path",
":",
"Runtime",
".",
"compileScript",
"Domain",
":",
"Runtime",
"Method",
"name",
":",
"compileScript",
"Parameters",
":",
"Required",
"arguments",
":",
"expression",
"(",
"type",
":",
"string",
")",
"-",
">",
"Expression",
"to",
"compile",... | python | train |
saltstack/salt | salt/modules/rh_ip.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rh_ip.py#L963-L968 | def _write_file_network(data, filename):
'''
Writes a file to disk
'''
with salt.utils.files.fopen(filename, 'w') as fp_:
fp_.write(salt.utils.stringutils.to_str(data)) | [
"def",
"_write_file_network",
"(",
"data",
",",
"filename",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"filename",
",",
"'w'",
")",
"as",
"fp_",
":",
"fp_",
".",
"write",
"(",
"salt",
".",
"utils",
".",
"stringutils",
".... | Writes a file to disk | [
"Writes",
"a",
"file",
"to",
"disk"
] | python | train |
Robpol86/libnl | libnl/list_.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/list_.py#L62-L69 | def nl_list_del(obj):
"""https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L49.
Positional arguments:
obj -- nl_list_head class instance.
"""
obj.next.prev = obj.prev
obj.prev.next_ = obj.next_ | [
"def",
"nl_list_del",
"(",
"obj",
")",
":",
"obj",
".",
"next",
".",
"prev",
"=",
"obj",
".",
"prev",
"obj",
".",
"prev",
".",
"next_",
"=",
"obj",
".",
"next_"
] | https://github.com/thom311/libnl/blob/libnl3_2_25/include/netlink/list.h#L49.
Positional arguments:
obj -- nl_list_head class instance. | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"thom311",
"/",
"libnl",
"/",
"blob",
"/",
"libnl3_2_25",
"/",
"include",
"/",
"netlink",
"/",
"list",
".",
"h#L49",
"."
] | python | train |
duguyue100/minesweeper | minesweeper/gui.py | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L117-L132 | def update_grid(self):
"""Update grid according to info map."""
info_map = self.ms_game.get_info_map()
for i in xrange(self.ms_game.board_height):
for j in xrange(self.ms_game.board_width):
self.grid_wgs[(i, j)].info_label(info_map[i, j])
self.ctrl_wg.move_co... | [
"def",
"update_grid",
"(",
"self",
")",
":",
"info_map",
"=",
"self",
".",
"ms_game",
".",
"get_info_map",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"ms_game",
".",
"board_height",
")",
":",
"for",
"j",
"in",
"xrange",
"(",
"self",
".",... | Update grid according to info map. | [
"Update",
"grid",
"according",
"to",
"info",
"map",
"."
] | python | train |
ninuxorg/nodeshot | nodeshot/networking/net/views.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/net/views.py#L35-L55 | def get_queryset(self):
"""
Optionally restricts the returned devices
by filtering against a `search` query parameter in the URL.
"""
# retrieve all devices which are published and accessible to current user
# and use joins to retrieve related fields
queryset = su... | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"# retrieve all devices which are published and accessible to current user",
"# and use joins to retrieve related fields",
"queryset",
"=",
"super",
"(",
"DeviceList",
",",
"self",
")",
".",
"get_queryset",
"(",
")",
"#.select_rel... | Optionally restricts the returned devices
by filtering against a `search` query parameter in the URL. | [
"Optionally",
"restricts",
"the",
"returned",
"devices",
"by",
"filtering",
"against",
"a",
"search",
"query",
"parameter",
"in",
"the",
"URL",
"."
] | python | train |
CamDavidsonPilon/lifelines | lifelines/plotting.py | https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L409-L446 | def plot_loglogs(cls, loc=None, iloc=None, show_censors=False, censor_styles=None, **kwargs):
"""
Specifies a plot of the log(-log(SV)) versus log(time) where SV is the estimated survival function.
"""
def loglog(s):
return np.log(-np.log(s))
if (loc is not None) and (iloc is not None):
... | [
"def",
"plot_loglogs",
"(",
"cls",
",",
"loc",
"=",
"None",
",",
"iloc",
"=",
"None",
",",
"show_censors",
"=",
"False",
",",
"censor_styles",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"loglog",
"(",
"s",
")",
":",
"return",
"np",
".",... | Specifies a plot of the log(-log(SV)) versus log(time) where SV is the estimated survival function. | [
"Specifies",
"a",
"plot",
"of",
"the",
"log",
"(",
"-",
"log",
"(",
"SV",
"))",
"versus",
"log",
"(",
"time",
")",
"where",
"SV",
"is",
"the",
"estimated",
"survival",
"function",
"."
] | python | train |
PyGithub/PyGithub | github/Repository.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Repository.py#L2674-L2682 | def subscribe_to_hub(self, event, callback, secret=github.GithubObject.NotSet):
"""
:calls: `POST /hub <http://developer.github.com/>`_
:param event: string
:param callback: string
:param secret: string
:rtype: None
"""
return self._hub("subscribe", event,... | [
"def",
"subscribe_to_hub",
"(",
"self",
",",
"event",
",",
"callback",
",",
"secret",
"=",
"github",
".",
"GithubObject",
".",
"NotSet",
")",
":",
"return",
"self",
".",
"_hub",
"(",
"\"subscribe\"",
",",
"event",
",",
"callback",
",",
"secret",
")"
] | :calls: `POST /hub <http://developer.github.com/>`_
:param event: string
:param callback: string
:param secret: string
:rtype: None | [
":",
"calls",
":",
"POST",
"/",
"hub",
"<http",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
">",
"_",
":",
"param",
"event",
":",
"string",
":",
"param",
"callback",
":",
"string",
":",
"param",
"secret",
":",
"string",
":",
"rtype",
":... | python | train |
pypa/pipenv | pipenv/vendor/pexpect/pty_spawn.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/pty_spawn.py#L557-L561 | def _log_control(self, s):
"""Write control characters to the appropriate log files"""
if self.encoding is not None:
s = s.decode(self.encoding, 'replace')
self._log(s, 'send') | [
"def",
"_log_control",
"(",
"self",
",",
"s",
")",
":",
"if",
"self",
".",
"encoding",
"is",
"not",
"None",
":",
"s",
"=",
"s",
".",
"decode",
"(",
"self",
".",
"encoding",
",",
"'replace'",
")",
"self",
".",
"_log",
"(",
"s",
",",
"'send'",
")"
... | Write control characters to the appropriate log files | [
"Write",
"control",
"characters",
"to",
"the",
"appropriate",
"log",
"files"
] | python | train |
numenta/nupic | src/nupic/algorithms/knn_classifier.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L840-L870 | def getPattern(self, idx, sparseBinaryForm=False, cat=None):
"""Gets a training pattern either by index or category number.
:param idx: Index of the training pattern
:param sparseBinaryForm: If true, returns a list of the indices of the
non-zero bits in the training pattern
:param cat: If not... | [
"def",
"getPattern",
"(",
"self",
",",
"idx",
",",
"sparseBinaryForm",
"=",
"False",
",",
"cat",
"=",
"None",
")",
":",
"if",
"cat",
"is",
"not",
"None",
":",
"assert",
"idx",
"is",
"None",
"idx",
"=",
"self",
".",
"_categoryList",
".",
"index",
"(",... | Gets a training pattern either by index or category number.
:param idx: Index of the training pattern
:param sparseBinaryForm: If true, returns a list of the indices of the
non-zero bits in the training pattern
:param cat: If not None, get the first pattern belonging to category cat. If
t... | [
"Gets",
"a",
"training",
"pattern",
"either",
"by",
"index",
"or",
"category",
"number",
"."
] | python | valid |
JasonKessler/scattertext | scattertext/characteristic/DenseRankCharacteristicness.py | https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/characteristic/DenseRankCharacteristicness.py#L37-L74 | def get_scores(self, corpus):
'''
Parameters
----------
corpus
Returns
-------
float, pd.Series
float: point on x-axis at even characteristicness
pd.Series: term -> value between 0 and 1, sorted by score in a descending manner
Background scores from corpus
'''
term_ranks = self.term_ranker(corp... | [
"def",
"get_scores",
"(",
"self",
",",
"corpus",
")",
":",
"term_ranks",
"=",
"self",
".",
"term_ranker",
"(",
"corpus",
")",
".",
"get_ranks",
"(",
")",
"freq_df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"'corpus'",
":",
"term_ranks",
".",
"sum",
"(",
... | Parameters
----------
corpus
Returns
-------
float, pd.Series
float: point on x-axis at even characteristicness
pd.Series: term -> value between 0 and 1, sorted by score in a descending manner
Background scores from corpus | [
"Parameters",
"----------",
"corpus"
] | python | train |
edoburu/django-debugtools | debugtools/formatter.py | https://github.com/edoburu/django-debugtools/blob/5c609c00fa9954330cd135fc62a1e18b8e7fea8a/debugtools/formatter.py#L129-L152 | def _style_text(text):
"""
Apply some HTML highlighting to the contents.
This can't be done in the
"""
# Escape text and apply some formatting.
# To have really good highlighting, pprint would have to be re-implemented.
text = escape(text)
text = text.replace(' <iterator object>', ... | [
"def",
"_style_text",
"(",
"text",
")",
":",
"# Escape text and apply some formatting.",
"# To have really good highlighting, pprint would have to be re-implemented.",
"text",
"=",
"escape",
"(",
"text",
")",
"text",
"=",
"text",
".",
"replace",
"(",
"' <iterator object>... | Apply some HTML highlighting to the contents.
This can't be done in the | [
"Apply",
"some",
"HTML",
"highlighting",
"to",
"the",
"contents",
".",
"This",
"can",
"t",
"be",
"done",
"in",
"the"
] | python | test |
rwl/pylon | pyreto/util.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/util.py#L96-L106 | def weighted_choice(lst):
""" Makes weighted choices. Accepts a list of tuples with the item and
probability as a pair like:
>>> x = [('one', 0.25), ('two', 0.25), ('three', 0.5)]
>>> y=windex(x) """
n = random.uniform(0, 1)
for item, weight in lst:
if n < weight:
break
... | [
"def",
"weighted_choice",
"(",
"lst",
")",
":",
"n",
"=",
"random",
".",
"uniform",
"(",
"0",
",",
"1",
")",
"for",
"item",
",",
"weight",
"in",
"lst",
":",
"if",
"n",
"<",
"weight",
":",
"break",
"n",
"=",
"n",
"-",
"weight",
"return",
"item"
] | Makes weighted choices. Accepts a list of tuples with the item and
probability as a pair like:
>>> x = [('one', 0.25), ('two', 0.25), ('three', 0.5)]
>>> y=windex(x) | [
"Makes",
"weighted",
"choices",
".",
"Accepts",
"a",
"list",
"of",
"tuples",
"with",
"the",
"item",
"and",
"probability",
"as",
"a",
"pair",
"like",
":",
">>>",
"x",
"=",
"[",
"(",
"one",
"0",
".",
"25",
")",
"(",
"two",
"0",
".",
"25",
")",
"(",... | python | train |
portantier/habu | habu/lib/ip2asn.py | https://github.com/portantier/habu/blob/87091e389dc6332fe1b82830c22b2eefc55816f2/habu/lib/ip2asn.py#L7-L77 | def ip2asn(ipaddr):
"""Returns the ASN data associated with an IP (v4 or v6)
>>> from pprint import pprint
>>> pprint(ip2asn('8.8.8.8'))
{'asn': '15169',
'asname': 'GOOGLE - Google Inc., US',
'cc': 'US',
'net': '8.8.8.0/24',
'rir': 'ARIN'}
>>> pprint(ip2asn('2001:4860:4860::8888... | [
"def",
"ip2asn",
"(",
"ipaddr",
")",
":",
"try",
":",
"ip",
"=",
"ipaddress",
".",
"ip_network",
"(",
"ipaddr",
")",
"except",
"ValueError",
":",
"return",
"None",
"if",
"ip",
".",
"is_private",
":",
"return",
"None",
"if",
"ip",
".",
"version",
"==",
... | Returns the ASN data associated with an IP (v4 or v6)
>>> from pprint import pprint
>>> pprint(ip2asn('8.8.8.8'))
{'asn': '15169',
'asname': 'GOOGLE - Google Inc., US',
'cc': 'US',
'net': '8.8.8.0/24',
'rir': 'ARIN'}
>>> pprint(ip2asn('2001:4860:4860::8888'))
{'asn': '15169',
... | [
"Returns",
"the",
"ASN",
"data",
"associated",
"with",
"an",
"IP",
"(",
"v4",
"or",
"v6",
")"
] | python | train |
Robpol86/sphinxcontrib-versioning | sphinxcontrib/versioning/__main__.py | https://github.com/Robpol86/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/__main__.py#L210-L234 | def override_root_main_ref(config, remotes, banner):
"""Override root_ref or banner_main_ref with tags in config if user requested.
:param sphinxcontrib.versioning.lib.Config config: Runtime configuration.
:param iter remotes: List of dicts from Versions.remotes.
:param bool banner: Evaluate banner mai... | [
"def",
"override_root_main_ref",
"(",
"config",
",",
"remotes",
",",
"banner",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"greatest_tag",
"=",
"config",
".",
"banner_greatest_tag",
"if",
"banner",
"else",
"config",
".",
"greatest_... | Override root_ref or banner_main_ref with tags in config if user requested.
:param sphinxcontrib.versioning.lib.Config config: Runtime configuration.
:param iter remotes: List of dicts from Versions.remotes.
:param bool banner: Evaluate banner main ref instead of root ref.
:return: If root/main ref ex... | [
"Override",
"root_ref",
"or",
"banner_main_ref",
"with",
"tags",
"in",
"config",
"if",
"user",
"requested",
"."
] | python | train |
xxtea/xxtea-python | xxtea/__init__.py | https://github.com/xxtea/xxtea-python/blob/35bd893cb42dce338631d051be9302fcbc21b7fc/xxtea/__init__.py#L42-L51 | def decrypt(data, key):
'''decrypt the data with the key'''
data_len = len(data)
data = ffi.from_buffer(data)
key = ffi.from_buffer(__tobytes(key))
out_len = ffi.new('size_t *')
result = lib.xxtea_decrypt(data, data_len, key, out_len)
ret = ffi.buffer(result, out_len[0])[:]
lib.free(resu... | [
"def",
"decrypt",
"(",
"data",
",",
"key",
")",
":",
"data_len",
"=",
"len",
"(",
"data",
")",
"data",
"=",
"ffi",
".",
"from_buffer",
"(",
"data",
")",
"key",
"=",
"ffi",
".",
"from_buffer",
"(",
"__tobytes",
"(",
"key",
")",
")",
"out_len",
"=",
... | decrypt the data with the key | [
"decrypt",
"the",
"data",
"with",
"the",
"key"
] | python | train |
trendmicro/flask-ini | flask_ini.py | https://github.com/trendmicro/flask-ini/blob/a1e4baa598c9a01021a1333d9c15e4d99c8334dd/flask_ini.py#L38-L58 | def _load_item(self, key):
'''Load the specified item from the [flask] section. Type is
determined by the type of the equivalent value in app.default_config
or string if unknown.'''
key_u = key.upper()
default = current_app.default_config.get(key_u)
# One of the defaul... | [
"def",
"_load_item",
"(",
"self",
",",
"key",
")",
":",
"key_u",
"=",
"key",
".",
"upper",
"(",
")",
"default",
"=",
"current_app",
".",
"default_config",
".",
"get",
"(",
"key_u",
")",
"# One of the default config vars is a timedelta - interpret it",
"# as an int... | Load the specified item from the [flask] section. Type is
determined by the type of the equivalent value in app.default_config
or string if unknown. | [
"Load",
"the",
"specified",
"item",
"from",
"the",
"[",
"flask",
"]",
"section",
".",
"Type",
"is",
"determined",
"by",
"the",
"type",
"of",
"the",
"equivalent",
"value",
"in",
"app",
".",
"default_config",
"or",
"string",
"if",
"unknown",
"."
] | python | train |
photo/openphoto-python | trovebox/api/api_tag.py | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_tag.py#L9-L17 | def list(self, **kwds):
"""
Endpoint: /tags/list.json
Returns a list of Tag objects.
"""
tags = self._client.get("/tags/list.json", **kwds)["result"]
tags = self._result_to_list(tags)
return [Tag(self._client, tag) for tag in tags] | [
"def",
"list",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"tags",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/tags/list.json\"",
",",
"*",
"*",
"kwds",
")",
"[",
"\"result\"",
"]",
"tags",
"=",
"self",
".",
"_result_to_list",
"(",
"tags",
... | Endpoint: /tags/list.json
Returns a list of Tag objects. | [
"Endpoint",
":",
"/",
"tags",
"/",
"list",
".",
"json"
] | python | train |
Esri/ArcREST | src/arcresthelper/common.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/common.py#L434-L457 | def unicode_convert(obj):
"""Converts unicode objects to anscii.
Args:
obj (object): The object to convert.
Returns:
The object converted to anscii, if possible. For ``dict`` and ``list``, the object type is maintained.
"""
try:
if isinstance(obj, dict):
return ... | [
"def",
"unicode_convert",
"(",
"obj",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"{",
"unicode_convert",
"(",
"key",
")",
":",
"unicode_convert",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in",
"obj",
... | Converts unicode objects to anscii.
Args:
obj (object): The object to convert.
Returns:
The object converted to anscii, if possible. For ``dict`` and ``list``, the object type is maintained. | [
"Converts",
"unicode",
"objects",
"to",
"anscii",
"."
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/pipeline.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/pipeline.py#L61-L79 | def add_model(self, spec):
"""
Add a protobuf spec or :py:class:`models.MLModel` instance to the pipeline.
All input features of this model must either match the input_features
of the pipeline, or match the outputs of a previous model.
Parameters
----------
spec... | [
"def",
"add_model",
"(",
"self",
",",
"spec",
")",
":",
"if",
"isinstance",
"(",
"spec",
",",
"_model",
".",
"MLModel",
")",
":",
"spec",
"=",
"spec",
".",
"_spec",
"pipeline",
"=",
"self",
".",
"spec",
".",
"pipeline",
"step_spec",
"=",
"pipeline",
... | Add a protobuf spec or :py:class:`models.MLModel` instance to the pipeline.
All input features of this model must either match the input_features
of the pipeline, or match the outputs of a previous model.
Parameters
----------
spec: [MLModel, Model_pb2]
A protobuf s... | [
"Add",
"a",
"protobuf",
"spec",
"or",
":",
"py",
":",
"class",
":",
"models",
".",
"MLModel",
"instance",
"to",
"the",
"pipeline",
"."
] | python | train |
inspirehep/inspire-crawler | inspire_crawler/cli.py | https://github.com/inspirehep/inspire-crawler/blob/36d5cc0cd87cc597ba80e680b7de7254b120173a/inspire_crawler/cli.py#L256-L309 | def schedule_crawl_cli(spider_name, workflow_name, dont_force_crawl, kwarg):
"""Schedule a new crawl.
Note:
Currently the oaiharvesting is done on inspire side, before this, so
it's not supported here yet.
"""
extra_kwargs = {}
for extra_kwarg in kwarg:
if '=' not in extra_k... | [
"def",
"schedule_crawl_cli",
"(",
"spider_name",
",",
"workflow_name",
",",
"dont_force_crawl",
",",
"kwarg",
")",
":",
"extra_kwargs",
"=",
"{",
"}",
"for",
"extra_kwarg",
"in",
"kwarg",
":",
"if",
"'='",
"not",
"in",
"extra_kwarg",
":",
"raise",
"TypeError",... | Schedule a new crawl.
Note:
Currently the oaiharvesting is done on inspire side, before this, so
it's not supported here yet. | [
"Schedule",
"a",
"new",
"crawl",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/lammps/data.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/lammps/data.py#L1117-L1130 | def to_file(self, filename):
"""
Saves object to a file in YAML format.
Args:
filename (str): Filename.
"""
d = {"mass_info": self.mass_info,
"nonbond_coeffs": self.nonbond_coeffs,
"topo_coeffs": self.topo_coeffs}
yaml = YAML(typ="s... | [
"def",
"to_file",
"(",
"self",
",",
"filename",
")",
":",
"d",
"=",
"{",
"\"mass_info\"",
":",
"self",
".",
"mass_info",
",",
"\"nonbond_coeffs\"",
":",
"self",
".",
"nonbond_coeffs",
",",
"\"topo_coeffs\"",
":",
"self",
".",
"topo_coeffs",
"}",
"yaml",
"=... | Saves object to a file in YAML format.
Args:
filename (str): Filename. | [
"Saves",
"object",
"to",
"a",
"file",
"in",
"YAML",
"format",
"."
] | python | train |
evhub/coconut | coconut/command/command.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/command/command.py#L470-L485 | def get_input(self, more=False):
"""Prompt for code input."""
received = None
try:
received = self.prompt.input(more)
except KeyboardInterrupt:
print()
printerr("KeyboardInterrupt")
except EOFError:
print()
self.exit_run... | [
"def",
"get_input",
"(",
"self",
",",
"more",
"=",
"False",
")",
":",
"received",
"=",
"None",
"try",
":",
"received",
"=",
"self",
".",
"prompt",
".",
"input",
"(",
"more",
")",
"except",
"KeyboardInterrupt",
":",
"print",
"(",
")",
"printerr",
"(",
... | Prompt for code input. | [
"Prompt",
"for",
"code",
"input",
"."
] | python | train |
opendatateam/udata | udata/harvest/actions.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/harvest/actions.py#L160-L187 | def preview_from_config(name, url, backend,
description=None,
frequency=DEFAULT_HARVEST_FREQUENCY,
owner=None,
organization=None,
config=None,
):
'''Preview an harvesting f... | [
"def",
"preview_from_config",
"(",
"name",
",",
"url",
",",
"backend",
",",
"description",
"=",
"None",
",",
"frequency",
"=",
"DEFAULT_HARVEST_FREQUENCY",
",",
"owner",
"=",
"None",
",",
"organization",
"=",
"None",
",",
"config",
"=",
"None",
",",
")",
"... | Preview an harvesting from a source created with the given parameters | [
"Preview",
"an",
"harvesting",
"from",
"a",
"source",
"created",
"with",
"the",
"given",
"parameters"
] | python | train |
BetterWorks/django-anonymizer | anonymizer/replacers.py | https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L53-L57 | def datetime(anon, obj, field, val):
"""
Returns a random datetime
"""
return anon.faker.datetime(field=field) | [
"def",
"datetime",
"(",
"anon",
",",
"obj",
",",
"field",
",",
"val",
")",
":",
"return",
"anon",
".",
"faker",
".",
"datetime",
"(",
"field",
"=",
"field",
")"
] | Returns a random datetime | [
"Returns",
"a",
"random",
"datetime"
] | python | train |
kervi/kervi-devices | kervi/devices/displays/dummy_display_driver.py | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/displays/dummy_display_driver.py#L105-L116 | def image(self, image):
"""Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size.
"""
if image.mode != '1':
raise ValueError('Image must be in mode 1.')
imwidth, imheight = image.size
if im... | [
"def",
"image",
"(",
"self",
",",
"image",
")",
":",
"if",
"image",
".",
"mode",
"!=",
"'1'",
":",
"raise",
"ValueError",
"(",
"'Image must be in mode 1.'",
")",
"imwidth",
",",
"imheight",
"=",
"image",
".",
"size",
"if",
"imwidth",
"!=",
"self",
".",
... | Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size. | [
"Set",
"buffer",
"to",
"value",
"of",
"Python",
"Imaging",
"Library",
"image",
".",
"The",
"image",
"should",
"be",
"in",
"1",
"bit",
"mode",
"and",
"a",
"size",
"equal",
"to",
"the",
"display",
"size",
"."
] | python | train |
PythonCharmers/python-future | src/future/backports/datetime.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/datetime.py#L1354-L1379 | def fromtimestamp(cls, t, tz=None):
"""Construct a datetime from a POSIX timestamp (like time.time()).
A timezone info object may be passed in as well.
"""
_check_tzinfo_arg(tz)
converter = _time.localtime if tz is None else _time.gmtime
t, frac = divmod(t, 1.0)
... | [
"def",
"fromtimestamp",
"(",
"cls",
",",
"t",
",",
"tz",
"=",
"None",
")",
":",
"_check_tzinfo_arg",
"(",
"tz",
")",
"converter",
"=",
"_time",
".",
"localtime",
"if",
"tz",
"is",
"None",
"else",
"_time",
".",
"gmtime",
"t",
",",
"frac",
"=",
"divmod... | Construct a datetime from a POSIX timestamp (like time.time()).
A timezone info object may be passed in as well. | [
"Construct",
"a",
"datetime",
"from",
"a",
"POSIX",
"timestamp",
"(",
"like",
"time",
".",
"time",
"()",
")",
"."
] | python | train |
blockstack-packages/blockstack-profiles-py | blockstack_profiles/token_verifying.py | https://github.com/blockstack-packages/blockstack-profiles-py/blob/103783798df78cf0f007801e79ec6298f00b2817/blockstack_profiles/token_verifying.py#L102-L124 | def get_profile_from_tokens(token_records, public_key_or_address,
hierarchical_keys=False):
""" A function for extracting a profile from a list of tokens.
"""
if hierarchical_keys:
raise NotImplementedError("Hierarchical key support not implemented")
profile = {}
... | [
"def",
"get_profile_from_tokens",
"(",
"token_records",
",",
"public_key_or_address",
",",
"hierarchical_keys",
"=",
"False",
")",
":",
"if",
"hierarchical_keys",
":",
"raise",
"NotImplementedError",
"(",
"\"Hierarchical key support not implemented\"",
")",
"profile",
"=",
... | A function for extracting a profile from a list of tokens. | [
"A",
"function",
"for",
"extracting",
"a",
"profile",
"from",
"a",
"list",
"of",
"tokens",
"."
] | python | train |
roclark/sportsreference | sportsreference/ncaab/boxscore.py | https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L255-L282 | def _parse_game_date_and_location(self, field, boxscore):
"""
Retrieve the game's date and location.
The date and location of the game follow a more complicated parsing
scheme and should be handled differently from other tags. Both fields
are separated by a newline character ('\... | [
"def",
"_parse_game_date_and_location",
"(",
"self",
",",
"field",
",",
"boxscore",
")",
":",
"scheme",
"=",
"BOXSCORE_SCHEME",
"[",
"field",
"]",
"items",
"=",
"[",
"i",
".",
"text",
"(",
")",
"for",
"i",
"in",
"boxscore",
"(",
"scheme",
")",
".",
"it... | Retrieve the game's date and location.
The date and location of the game follow a more complicated parsing
scheme and should be handled differently from other tags. Both fields
are separated by a newline character ('\n') with the first line being
the date and the second being the locati... | [
"Retrieve",
"the",
"game",
"s",
"date",
"and",
"location",
"."
] | python | train |
fhcrc/seqmagick | seqmagick/transform.py | https://github.com/fhcrc/seqmagick/blob/1642bb87ba5c171fbd307f9da0f8a0ee1d69d5ed/seqmagick/transform.py#L362-L368 | def ungap_sequences(records, gap_chars=GAP_TABLE):
"""
Remove gaps from sequences, given an alignment.
"""
logging.info('Applying _ungap_sequences generator: removing all gap characters')
for record in records:
yield ungap_all(record, gap_chars) | [
"def",
"ungap_sequences",
"(",
"records",
",",
"gap_chars",
"=",
"GAP_TABLE",
")",
":",
"logging",
".",
"info",
"(",
"'Applying _ungap_sequences generator: removing all gap characters'",
")",
"for",
"record",
"in",
"records",
":",
"yield",
"ungap_all",
"(",
"record",
... | Remove gaps from sequences, given an alignment. | [
"Remove",
"gaps",
"from",
"sequences",
"given",
"an",
"alignment",
"."
] | python | train |
cisco-sas/kitty | kitty/model/low_level/container.py | https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/model/low_level/container.py#L294-L302 | def pop(self):
'''
Remove a the top container from the container stack
'''
if not self._containers:
raise KittyException('no container to pop')
self._containers.pop()
if self._container():
self._container().pop() | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_containers",
":",
"raise",
"KittyException",
"(",
"'no container to pop'",
")",
"self",
".",
"_containers",
".",
"pop",
"(",
")",
"if",
"self",
".",
"_container",
"(",
")",
":",
"self",
"... | Remove a the top container from the container stack | [
"Remove",
"a",
"the",
"top",
"container",
"from",
"the",
"container",
"stack"
] | python | train |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L79-L111 | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | [
"def",
"match_tree",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
")",
":",
"pat_node",
"=",
"p",
"."... | Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to pattern, False otherwise
:raises... | [
"Matches",
"given",
"sentence",
"with",
"provided",
"pattern",
"."
] | python | train |
pkgw/pwkit | pwkit/dulk_models.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/dulk_models.py#L175-L205 | def calc_gs_nu_pk(b, ne, delta, sinth, depth):
"""Calculate the frequency of peak synchrotron emission, ν_pk.
This is Dulk (1985) equation 39, which is a fitting function assuming a
power-law electron population. Arguments are:
b
Magnetic field strength in Gauss
ne
The density of elect... | [
"def",
"calc_gs_nu_pk",
"(",
"b",
",",
"ne",
",",
"delta",
",",
"sinth",
",",
"depth",
")",
":",
"coldens",
"=",
"ne",
"*",
"depth",
"return",
"(",
"2.72e3",
"*",
"10",
"**",
"(",
"0.27",
"*",
"delta",
")",
"*",
"sinth",
"**",
"(",
"0.41",
"+",
... | Calculate the frequency of peak synchrotron emission, ν_pk.
This is Dulk (1985) equation 39, which is a fitting function assuming a
power-law electron population. Arguments are:
b
Magnetic field strength in Gauss
ne
The density of electrons per cubic centimeter with energies greater than 1... | [
"Calculate",
"the",
"frequency",
"of",
"peak",
"synchrotron",
"emission",
"ν_pk",
"."
] | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/namespace_range.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/namespace_range.py#L324-L330 | def to_json_object(self):
"""Returns a dict representation that can be serialized to JSON."""
obj_dict = dict(namespace_start=self.namespace_start,
namespace_end=self.namespace_end)
if self.app is not None:
obj_dict['app'] = self.app
return obj_dict | [
"def",
"to_json_object",
"(",
"self",
")",
":",
"obj_dict",
"=",
"dict",
"(",
"namespace_start",
"=",
"self",
".",
"namespace_start",
",",
"namespace_end",
"=",
"self",
".",
"namespace_end",
")",
"if",
"self",
".",
"app",
"is",
"not",
"None",
":",
"obj_dic... | Returns a dict representation that can be serialized to JSON. | [
"Returns",
"a",
"dict",
"representation",
"that",
"can",
"be",
"serialized",
"to",
"JSON",
"."
] | python | train |
has2k1/plotnine | plotnine/guides/guide.py | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/guides/guide.py#L93-L105 | def _default(self, key, default=None):
"""
Lookup value of *key* themeable
If *key* not in themeable or value is None,
return the *default* value.
"""
try:
value = self.theme.themeables.property(key)
except KeyError:
value = None
... | [
"def",
"_default",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"value",
"=",
"self",
".",
"theme",
".",
"themeables",
".",
"property",
"(",
"key",
")",
"except",
"KeyError",
":",
"value",
"=",
"None",
"return",
"value"... | Lookup value of *key* themeable
If *key* not in themeable or value is None,
return the *default* value. | [
"Lookup",
"value",
"of",
"*",
"key",
"*",
"themeable"
] | python | train |
datacats/datacats | datacats/cli/manage.py | https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/cli/manage.py#L206-L244 | def logs(environment, opts):
"""Display or follow container logs
Usage:
datacats logs [--postgres | --solr | --datapusher] [-s NAME] [-tr] [--tail=LINES] [ENVIRONMENT]
datacats logs -f [--postgres | --solr | --datapusher] [-s NAME] [-r] [ENVIRONMENT]
Options:
--datapusher Show logs for datapusher inst... | [
"def",
"logs",
"(",
"environment",
",",
"opts",
")",
":",
"container",
"=",
"'web'",
"if",
"opts",
"[",
"'--solr'",
"]",
":",
"container",
"=",
"'solr'",
"if",
"opts",
"[",
"'--postgres'",
"]",
":",
"container",
"=",
"'postgres'",
"if",
"opts",
"[",
"'... | Display or follow container logs
Usage:
datacats logs [--postgres | --solr | --datapusher] [-s NAME] [-tr] [--tail=LINES] [ENVIRONMENT]
datacats logs -f [--postgres | --solr | --datapusher] [-s NAME] [-r] [ENVIRONMENT]
Options:
--datapusher Show logs for datapusher instead of web logs
--postgres ... | [
"Display",
"or",
"follow",
"container",
"logs"
] | python | train |
andy-esch/sqterritory | sqterritory/territory.py | https://github.com/andy-esch/sqterritory/blob/53bcf7c8946f5d216d1ceccf55f9f339125b8205/sqterritory/territory.py#L74-L102 | def _get_target_nearest(self):
"""Get nearest target for each origin"""
reps_query = """
SELECT DISTINCT ON(g2.cartodb_id)
g1.cartodb_id As origin_id,
g2.the_geom,
g2.cartodb_id + {maxorigin} as cartodb_id,
g2.the_geom_webm... | [
"def",
"_get_target_nearest",
"(",
"self",
")",
":",
"reps_query",
"=",
"\"\"\"\n SELECT DISTINCT ON(g2.cartodb_id)\n g1.cartodb_id As origin_id,\n g2.the_geom,\n g2.cartodb_id + {maxorigin} as cartodb_id,\n g2.the_geom_webm... | Get nearest target for each origin | [
"Get",
"nearest",
"target",
"for",
"each",
"origin"
] | python | train |
Erotemic/utool | utool/util_cplat.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cplat.py#L544-L622 | def view_directory(dname=None, fname=None, verbose=True):
"""
View a directory in the operating system file browser. Currently supports
windows explorer, mac open, and linux nautlius.
Args:
dname (str): directory name
fname (str): a filename to select in the directory (nautlius only)
... | [
"def",
"view_directory",
"(",
"dname",
"=",
"None",
",",
"fname",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"from",
"utool",
".",
"util_arg",
"import",
"STRICT",
"from",
"utool",
".",
"util_path",
"import",
"checkpath",
"# from utool.util_str import ... | View a directory in the operating system file browser. Currently supports
windows explorer, mac open, and linux nautlius.
Args:
dname (str): directory name
fname (str): a filename to select in the directory (nautlius only)
verbose (bool):
CommandLine:
python -m utool.util_c... | [
"View",
"a",
"directory",
"in",
"the",
"operating",
"system",
"file",
"browser",
".",
"Currently",
"supports",
"windows",
"explorer",
"mac",
"open",
"and",
"linux",
"nautlius",
"."
] | python | train |
AtsushiSakai/SimpleTkGUIKit | SimpleTkGUIKit/SimpleTkGUIKit.py | https://github.com/AtsushiSakai/SimpleTkGUIKit/blob/e7cbb06ff32afb165cdaa4fe396ca2f172c66ff0/SimpleTkGUIKit/SimpleTkGUIKit.py#L134-L167 | def GetEntries(dataList, title="Select", msg=""):
"""
Get entries of the list
title: Window name
mag: Label of the check button
return data dictionary like:
{'y': '5.0', 'x': '100', 'z': 'save'}
"""
root = tkinter.Tk()
root.title(title)
label = tkinter.Label(root, text=msg)
... | [
"def",
"GetEntries",
"(",
"dataList",
",",
"title",
"=",
"\"Select\"",
",",
"msg",
"=",
"\"\"",
")",
":",
"root",
"=",
"tkinter",
".",
"Tk",
"(",
")",
"root",
".",
"title",
"(",
"title",
")",
"label",
"=",
"tkinter",
".",
"Label",
"(",
"root",
",",... | Get entries of the list
title: Window name
mag: Label of the check button
return data dictionary like:
{'y': '5.0', 'x': '100', 'z': 'save'} | [
"Get",
"entries",
"of",
"the",
"list"
] | python | train |
yyuu/botornado | boto/connection.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/connection.py#L699-L797 | def _mexe(self, request, sender=None, override_num_retries=None,
retry_handler=None):
"""
mexe - Multi-execute inside a loop, retrying multiple times to handle
transient Internet errors by simply trying again.
Also handles redirects.
This code was ins... | [
"def",
"_mexe",
"(",
"self",
",",
"request",
",",
"sender",
"=",
"None",
",",
"override_num_retries",
"=",
"None",
",",
"retry_handler",
"=",
"None",
")",
":",
"boto",
".",
"log",
".",
"debug",
"(",
"'Method: %s'",
"%",
"request",
".",
"method",
")",
"... | mexe - Multi-execute inside a loop, retrying multiple times to handle
transient Internet errors by simply trying again.
Also handles redirects.
This code was inspired by the S3Utils classes posted to the boto-users
Google group by Larry Bates. Thanks! | [
"mexe",
"-",
"Multi",
"-",
"execute",
"inside",
"a",
"loop",
"retrying",
"multiple",
"times",
"to",
"handle",
"transient",
"Internet",
"errors",
"by",
"simply",
"trying",
"again",
".",
"Also",
"handles",
"redirects",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/MySQL_python-1.2.4c1-py2.7-linux-x86_64.egg/MySQLdb/cursors.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/MySQL_python-1.2.4c1-py2.7-linux-x86_64.egg/MySQLdb/cursors.py#L206-L254 | def executemany(self, query, args):
"""Execute a multi-row query.
query -- string, query to execute on server
args
Sequence of sequences or mappings, parameters to use with
query.
Returns long integer rows affected, if any.
... | [
"def",
"executemany",
"(",
"self",
",",
"query",
",",
"args",
")",
":",
"del",
"self",
".",
"messages",
"[",
":",
"]",
"db",
"=",
"self",
".",
"_get_db",
"(",
")",
"if",
"not",
"args",
":",
"return",
"if",
"isinstance",
"(",
"query",
",",
"unicode"... | Execute a multi-row query.
query -- string, query to execute on server
args
Sequence of sequences or mappings, parameters to use with
query.
Returns long integer rows affected, if any.
This method improves performance on multiple-r... | [
"Execute",
"a",
"multi",
"-",
"row",
"query",
".",
"query",
"--",
"string",
"query",
"to",
"execute",
"on",
"server"
] | python | test |
dariusbakunas/rawdisk | rawdisk/filesystems/detector.py | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/filesystems/detector.py#L67-L77 | def register_mbr_plugin(self, fs_id, plugin):
"""Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem
"""
... | [
"def",
"register_mbr_plugin",
"(",
"self",
",",
"fs_id",
",",
"plugin",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'MBR: {}, FS ID: {}'",
".",
"format",
"(",
"self",
".",
"__get_plugin_name",
"(",
"plugin",
")",
",",
"fs_id",
")",
")",
"self",
... | Used in plugin's registration routine,
to associate it's detection method with given filesystem id
Args:
fs_id: filesystem id that is read from MBR partition entry
plugin: plugin that supports this filesystem | [
"Used",
"in",
"plugin",
"s",
"registration",
"routine",
"to",
"associate",
"it",
"s",
"detection",
"method",
"with",
"given",
"filesystem",
"id"
] | python | train |
Hackerfleet/hfos | modules/library/hfos/library/manager.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/library/hfos/library/manager.py#L141-L215 | def _augment_book(self, uuid, event):
"""
Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client
"""
try:
if not is... | [
"def",
"_augment_book",
"(",
"self",
",",
"uuid",
",",
"event",
")",
":",
"try",
":",
"if",
"not",
"isbnmeta",
":",
"self",
".",
"log",
"(",
"\"No isbntools found! Install it to get full \"",
"\"functionality!\"",
",",
"lvl",
"=",
"warn",
")",
"return",
"new_b... | Checks if the newly created object is a book and only has an ISBN.
If so, tries to fetch the book data off the internet.
:param uuid: uuid of book to augment
:param client: requesting client | [
"Checks",
"if",
"the",
"newly",
"created",
"object",
"is",
"a",
"book",
"and",
"only",
"has",
"an",
"ISBN",
".",
"If",
"so",
"tries",
"to",
"fetch",
"the",
"book",
"data",
"off",
"the",
"internet",
"."
] | python | train |
saltstack/salt | salt/modules/win_iis.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_iis.py#L1547-L1586 | def list_vdirs(site, app=_DEFAULT_APP):
'''
Get all configured IIS virtual directories for the specified site, or for
the combination of site and application.
Args:
site (str): The IIS site name.
app (str): The IIS application.
Returns:
dict: A dictionary of the virtual dir... | [
"def",
"list_vdirs",
"(",
"site",
",",
"app",
"=",
"_DEFAULT_APP",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"ps_cmd",
"=",
"[",
"'Get-WebVirtualDirectory'",
",",
"'-Site'",
",",
"r\"'{0}'\"",
".",
"format",
"(",
"site",
")",
",",
"'-Application'",
",",
"r... | Get all configured IIS virtual directories for the specified site, or for
the combination of site and application.
Args:
site (str): The IIS site name.
app (str): The IIS application.
Returns:
dict: A dictionary of the virtual directory names and properties.
CLI Example:
... | [
"Get",
"all",
"configured",
"IIS",
"virtual",
"directories",
"for",
"the",
"specified",
"site",
"or",
"for",
"the",
"combination",
"of",
"site",
"and",
"application",
"."
] | python | train |
h2oai/h2o-3 | h2o-py/h2o/frame.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/frame.py#L2988-L2995 | def signif(self, digits=6):
"""
Round doubles/floats to the given number of significant digits.
:param int digits: Number of significant digits to retain.
:returns: new H2OFrame with rounded values from the original frame.
"""
return H2OFrame._expr(expr=ExprNode("signif"... | [
"def",
"signif",
"(",
"self",
",",
"digits",
"=",
"6",
")",
":",
"return",
"H2OFrame",
".",
"_expr",
"(",
"expr",
"=",
"ExprNode",
"(",
"\"signif\"",
",",
"self",
",",
"digits",
")",
",",
"cache",
"=",
"self",
".",
"_ex",
".",
"_cache",
")"
] | Round doubles/floats to the given number of significant digits.
:param int digits: Number of significant digits to retain.
:returns: new H2OFrame with rounded values from the original frame. | [
"Round",
"doubles",
"/",
"floats",
"to",
"the",
"given",
"number",
"of",
"significant",
"digits",
"."
] | python | test |
seleniumbase/SeleniumBase | seleniumbase/fixtures/base_case.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L2344-L2350 | def find_partial_link_text(self, partial_link_text,
timeout=settings.LARGE_TIMEOUT):
""" Same as wait_for_partial_link_text() - returns the element """
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
timeout = self.__get_new_timeout(timeout)
... | [
"def",
"find_partial_link_text",
"(",
"self",
",",
"partial_link_text",
",",
"timeout",
"=",
"settings",
".",
"LARGE_TIMEOUT",
")",
":",
"if",
"self",
".",
"timeout_multiplier",
"and",
"timeout",
"==",
"settings",
".",
"LARGE_TIMEOUT",
":",
"timeout",
"=",
"self... | Same as wait_for_partial_link_text() - returns the element | [
"Same",
"as",
"wait_for_partial_link_text",
"()",
"-",
"returns",
"the",
"element"
] | python | train |
gwastro/pycbc | pycbc/inference/sampler/emcee_pt.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/sampler/emcee_pt.py#L119-L172 | def from_config(cls, cp, model, nprocesses=1, use_mpi=False):
"""
Loads the sampler from the given config file.
For generating the temperature ladder to be used by emcee_pt, either
the number of temperatures (provided by the option 'ntemps'),
or the path to a file storing invers... | [
"def",
"from_config",
"(",
"cls",
",",
"cp",
",",
"model",
",",
"nprocesses",
"=",
"1",
",",
"use_mpi",
"=",
"False",
")",
":",
"section",
"=",
"\"sampler\"",
"# check name",
"assert",
"cp",
".",
"get",
"(",
"section",
",",
"\"name\"",
")",
"==",
"cls"... | Loads the sampler from the given config file.
For generating the temperature ladder to be used by emcee_pt, either
the number of temperatures (provided by the option 'ntemps'),
or the path to a file storing inverse temperature values (provided
under a subsection inverse-temperatures-fil... | [
"Loads",
"the",
"sampler",
"from",
"the",
"given",
"config",
"file",
"."
] | python | train |
CamDavidsonPilon/lifelines | lifelines/utils/__init__.py | https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/__init__.py#L110-L145 | def qth_survival_time(q, survival_function, cdf=False):
"""
Returns the time when a single survival function reaches the qth percentile.
Parameters
----------
q: float
a float between 0 and 1 that represents the time when the survival function hit's the qth percentile.
survival_function: ... | [
"def",
"qth_survival_time",
"(",
"q",
",",
"survival_function",
",",
"cdf",
"=",
"False",
")",
":",
"if",
"type",
"(",
"survival_function",
")",
"is",
"pd",
".",
"DataFrame",
":",
"# pylint: disable=unidiomatic-typecheck",
"if",
"survival_function",
".",
"shape",
... | Returns the time when a single survival function reaches the qth percentile.
Parameters
----------
q: float
a float between 0 and 1 that represents the time when the survival function hit's the qth percentile.
survival_function: Series or single-column DataFrame.
cdf: boolean, optional
... | [
"Returns",
"the",
"time",
"when",
"a",
"single",
"survival",
"function",
"reaches",
"the",
"qth",
"percentile",
"."
] | python | train |
wandb/client | wandb/vendor/prompt_toolkit/contrib/telnet/server.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/contrib/telnet/server.py#L240-L246 | def erase_screen(self):
"""
Erase output screen.
"""
self.vt100_output.erase_screen()
self.vt100_output.cursor_goto(0, 0)
self.vt100_output.flush() | [
"def",
"erase_screen",
"(",
"self",
")",
":",
"self",
".",
"vt100_output",
".",
"erase_screen",
"(",
")",
"self",
".",
"vt100_output",
".",
"cursor_goto",
"(",
"0",
",",
"0",
")",
"self",
".",
"vt100_output",
".",
"flush",
"(",
")"
] | Erase output screen. | [
"Erase",
"output",
"screen",
"."
] | python | train |
visualfabriq/bquery | bquery/ctable.py | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L576-L654 | def create_agg_ctable(self, groupby_cols, agg_list, expectedlen, rootdir):
'''Create a container for the output table, a dictionary describing it's
columns and a list of tuples describing aggregation
operations to perform.
Args:
groupby_cols (list): a list of columns... | [
"def",
"create_agg_ctable",
"(",
"self",
",",
"groupby_cols",
",",
"agg_list",
",",
"expectedlen",
",",
"rootdir",
")",
":",
"dtype_dict",
"=",
"{",
"}",
"# include all the groupby columns",
"for",
"col",
"in",
"groupby_cols",
":",
"dtype_dict",
"[",
"col",
"]",... | Create a container for the output table, a dictionary describing it's
columns and a list of tuples describing aggregation
operations to perform.
Args:
groupby_cols (list): a list of columns to groupby over
agg_list (list): the aggregation operations (see groupby ... | [
"Create",
"a",
"container",
"for",
"the",
"output",
"table",
"a",
"dictionary",
"describing",
"it",
"s",
"columns",
"and",
"a",
"list",
"of",
"tuples",
"describing",
"aggregation",
"operations",
"to",
"perform",
"."
] | python | train |
LonamiWebs/Telethon | telethon/client/updates.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/client/updates.py#L70-L101 | def add_event_handler(self, callback, event=None):
"""
Registers the given callback to be called on the specified event.
Args:
callback (`callable`):
The callable function accepting one parameter to be used.
Note that if you have used `telethon.event... | [
"def",
"add_event_handler",
"(",
"self",
",",
"callback",
",",
"event",
"=",
"None",
")",
":",
"builders",
"=",
"events",
".",
"_get_handlers",
"(",
"callback",
")",
"if",
"builders",
"is",
"not",
"None",
":",
"for",
"event",
"in",
"builders",
":",
"self... | Registers the given callback to be called on the specified event.
Args:
callback (`callable`):
The callable function accepting one parameter to be used.
Note that if you have used `telethon.events.register` in
the callback, ``event`` will be ignored,... | [
"Registers",
"the",
"given",
"callback",
"to",
"be",
"called",
"on",
"the",
"specified",
"event",
"."
] | python | train |
fumitoh/modelx | modelx/core/model.py | https://github.com/fumitoh/modelx/blob/0180da34d052c44fb94dab9e115e218bbebfc9c3/modelx/core/model.py#L191-L195 | def clear_descendants(self, source, clear_source=True):
"""Clear values and nodes calculated from `source`."""
removed = self.cellgraph.clear_descendants(source, clear_source)
for node in removed:
del node[OBJ].data[node[KEY]] | [
"def",
"clear_descendants",
"(",
"self",
",",
"source",
",",
"clear_source",
"=",
"True",
")",
":",
"removed",
"=",
"self",
".",
"cellgraph",
".",
"clear_descendants",
"(",
"source",
",",
"clear_source",
")",
"for",
"node",
"in",
"removed",
":",
"del",
"no... | Clear values and nodes calculated from `source`. | [
"Clear",
"values",
"and",
"nodes",
"calculated",
"from",
"source",
"."
] | python | valid |
saltstack/salt | salt/client/ssh/__init__.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/__init__.py#L1258-L1304 | def shim_cmd(self, cmd_str, extension='py'):
'''
Run a shim command.
If tty is enabled, we must scp the shim to the target system and
execute it there
'''
if not self.tty and not self.winrm:
return self.shell.exec_cmd(cmd_str)
# Write the shim to a t... | [
"def",
"shim_cmd",
"(",
"self",
",",
"cmd_str",
",",
"extension",
"=",
"'py'",
")",
":",
"if",
"not",
"self",
".",
"tty",
"and",
"not",
"self",
".",
"winrm",
":",
"return",
"self",
".",
"shell",
".",
"exec_cmd",
"(",
"cmd_str",
")",
"# Write the shim t... | Run a shim command.
If tty is enabled, we must scp the shim to the target system and
execute it there | [
"Run",
"a",
"shim",
"command",
"."
] | python | train |
tBuLi/symfit | symfit/contrib/interactive_guess/interactive_guess.py | https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/contrib/interactive_guess/interactive_guess.py#L117-L156 | def _set_up_figure(self, x_mins, x_maxs, y_mins, y_maxs):
"""
Prepare the matplotlib figure: make all the subplots; adjust their
x and y range; plot the data; and plot an putative function.
"""
self.fig = plt.figure()
# Make room for the sliders:
bot = 0.1 + 0.05... | [
"def",
"_set_up_figure",
"(",
"self",
",",
"x_mins",
",",
"x_maxs",
",",
"y_mins",
",",
"y_maxs",
")",
":",
"self",
".",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"# Make room for the sliders:",
"bot",
"=",
"0.1",
"+",
"0.05",
"*",
"len",
"(",
"self"... | Prepare the matplotlib figure: make all the subplots; adjust their
x and y range; plot the data; and plot an putative function. | [
"Prepare",
"the",
"matplotlib",
"figure",
":",
"make",
"all",
"the",
"subplots",
";",
"adjust",
"their",
"x",
"and",
"y",
"range",
";",
"plot",
"the",
"data",
";",
"and",
"plot",
"an",
"putative",
"function",
"."
] | python | train |
ibis-project/ibis | ibis/sql/sqlite/client.py | https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/sql/sqlite/client.py#L302-L311 | def _register_aggregate(agg, con):
"""Register a Python class that performs aggregation in SQLite.
Parameters
----------
agg : type
con : sqlalchemy.Connection
"""
nargs = number_of_arguments(agg.step) - 1 # because self
con.connection.connection.create_aggregate(agg.__name__, nargs, a... | [
"def",
"_register_aggregate",
"(",
"agg",
",",
"con",
")",
":",
"nargs",
"=",
"number_of_arguments",
"(",
"agg",
".",
"step",
")",
"-",
"1",
"# because self",
"con",
".",
"connection",
".",
"connection",
".",
"create_aggregate",
"(",
"agg",
".",
"__name__",
... | Register a Python class that performs aggregation in SQLite.
Parameters
----------
agg : type
con : sqlalchemy.Connection | [
"Register",
"a",
"Python",
"class",
"that",
"performs",
"aggregation",
"in",
"SQLite",
"."
] | python | train |
LuminosoInsight/wordfreq | wordfreq/__init__.py | https://github.com/LuminosoInsight/wordfreq/blob/170e3c6536854b06dc63da8d873e8cc4f9ef6180/wordfreq/__init__.py#L357-L369 | def random_ascii_words(lang='en', wordlist='best', nwords=5,
bits_per_word=12):
"""
Returns a string of random, space separated, ASCII words.
These words are of the given language and from the given wordlist.
There will be `nwords` words in the string.
`bits_per_word` determ... | [
"def",
"random_ascii_words",
"(",
"lang",
"=",
"'en'",
",",
"wordlist",
"=",
"'best'",
",",
"nwords",
"=",
"5",
",",
"bits_per_word",
"=",
"12",
")",
":",
"return",
"random_words",
"(",
"lang",
",",
"wordlist",
",",
"nwords",
",",
"bits_per_word",
",",
"... | Returns a string of random, space separated, ASCII words.
These words are of the given language and from the given wordlist.
There will be `nwords` words in the string.
`bits_per_word` determines the amount of entropy provided by each word;
when it's higher, this function will choose from a larger lis... | [
"Returns",
"a",
"string",
"of",
"random",
"space",
"separated",
"ASCII",
"words",
"."
] | python | train |
simonvh/norns | norns/cfg.py | https://github.com/simonvh/norns/blob/81db0004c558f91479176daf1918b8c9473b5ee2/norns/cfg.py#L60-L73 | def load(self, path):
"""
Load yaml-formatted config file.
Parameters
----------
path : str
path to config file
"""
with open(path) as f:
self.config = full_load(f)
if self.config is None:
sys.stderr.write("War... | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"self",
".",
"config",
"=",
"full_load",
"(",
"f",
")",
"if",
"self",
".",
"config",
"is",
"None",
":",
"sys",
".",
"stderr",
".",
"write",
"("... | Load yaml-formatted config file.
Parameters
----------
path : str
path to config file | [
"Load",
"yaml",
"-",
"formatted",
"config",
"file",
"."
] | python | train |
cihai/cihai | cihai/log.py | https://github.com/cihai/cihai/blob/43b0c2931da18c1ef1ff1cdd71e4b1c5eca24a41/cihai/log.py#L24-L63 | def default_log_template(self, record):
"""Return the prefix for the log message. Template for Formatter.
:param: record: :py:class:`logging.LogRecord` object. this is passed in
from inside the :py:meth:`logging.Formatter.format` record.
"""
reset = Style.RESET_ALL
levelname = [
LEVEL... | [
"def",
"default_log_template",
"(",
"self",
",",
"record",
")",
":",
"reset",
"=",
"Style",
".",
"RESET_ALL",
"levelname",
"=",
"[",
"LEVEL_COLORS",
".",
"get",
"(",
"record",
".",
"levelname",
")",
",",
"Style",
".",
"BRIGHT",
",",
"'(%(levelname)s)'",
",... | Return the prefix for the log message. Template for Formatter.
:param: record: :py:class:`logging.LogRecord` object. this is passed in
from inside the :py:meth:`logging.Formatter.format` record. | [
"Return",
"the",
"prefix",
"for",
"the",
"log",
"message",
".",
"Template",
"for",
"Formatter",
"."
] | python | train |
cimm-kzn/CGRtools | CGRtools/algorithms/standardize.py | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/standardize.py#L26-L60 | def standardize(self):
"""
standardize functional groups
:return: number of found groups
"""
self.reset_query_marks()
seen = set()
total = 0
for n, atom in self.atoms():
if n in seen:
continue
for k, center in centr... | [
"def",
"standardize",
"(",
"self",
")",
":",
"self",
".",
"reset_query_marks",
"(",
")",
"seen",
"=",
"set",
"(",
")",
"total",
"=",
"0",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"n",
"in",
"seen",
":",
"continue"... | standardize functional groups
:return: number of found groups | [
"standardize",
"functional",
"groups"
] | python | train |
aliyun/aliyun-odps-python-sdk | odps/df/tools/lib/hll.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/df/tools/lib/hll.py#L135-L144 | def merge(self, buffer, other_hyper_log_log):
"""
Merge the HyperLogLog
:param other_hyper_log_log:
:return:
"""
for i in range(len(buffer)):
buffer[i] = max(buffer[i], other_hyper_log_log[i]) | [
"def",
"merge",
"(",
"self",
",",
"buffer",
",",
"other_hyper_log_log",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"buffer",
")",
")",
":",
"buffer",
"[",
"i",
"]",
"=",
"max",
"(",
"buffer",
"[",
"i",
"]",
",",
"other_hyper_log_log",
"[... | Merge the HyperLogLog
:param other_hyper_log_log:
:return: | [
"Merge",
"the",
"HyperLogLog"
] | python | train |
TAPPGuild/tapp-config | tapp_config.py | https://github.com/TAPPGuild/tapp-config/blob/20fdbe00e4763f38a90845ad2cfb63c94e13ca81/tapp_config.py#L20-L41 | def get_config(name=__name__):
"""
Get a configuration parser for a given TAPP name.
Reads config.ini files only, not in-database configuration records.
:param name: The tapp name to get a configuration for.
:rtype: ConfigParser
:return: A config parser matching the given name
"""
cfg =... | [
"def",
"get_config",
"(",
"name",
"=",
"__name__",
")",
":",
"cfg",
"=",
"ConfigParser",
"(",
")",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'%s_CONFIG_FILE'",
"%",
"name",
".",
"upper",
"(",
")",
")",
"if",
"path",
"is",
"None",
"or",
"... | Get a configuration parser for a given TAPP name.
Reads config.ini files only, not in-database configuration records.
:param name: The tapp name to get a configuration for.
:rtype: ConfigParser
:return: A config parser matching the given name | [
"Get",
"a",
"configuration",
"parser",
"for",
"a",
"given",
"TAPP",
"name",
".",
"Reads",
"config",
".",
"ini",
"files",
"only",
"not",
"in",
"-",
"database",
"configuration",
"records",
"."
] | python | train |
jingw/pyhdfs | pyhdfs.py | https://github.com/jingw/pyhdfs/blob/b382b34f7cb28b41559f5be73102beb1732cd933/pyhdfs.py#L713-L719 | def exists(self, path, **kwargs):
"""Return true if the given path exists"""
try:
self.get_file_status(path, **kwargs)
return True
except HdfsFileNotFoundException:
return False | [
"def",
"exists",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"get_file_status",
"(",
"path",
",",
"*",
"*",
"kwargs",
")",
"return",
"True",
"except",
"HdfsFileNotFoundException",
":",
"return",
"False"
] | Return true if the given path exists | [
"Return",
"true",
"if",
"the",
"given",
"path",
"exists"
] | python | train |
ozgur/python-firebase | firebase/firebase.py | https://github.com/ozgur/python-firebase/blob/6b96b326f6d8f477503ca42fdfbd81bcbe1f9e0d/firebase/firebase.py#L188-L195 | def get_user(self):
"""
Method that gets the authenticated user. The returning user has
the token, email and the provider data.
"""
token = self.authenticator.create_token(self.extra)
user_id = self.extra.get('id')
return FirebaseUser(self.email, token, self.provi... | [
"def",
"get_user",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"authenticator",
".",
"create_token",
"(",
"self",
".",
"extra",
")",
"user_id",
"=",
"self",
".",
"extra",
".",
"get",
"(",
"'id'",
")",
"return",
"FirebaseUser",
"(",
"self",
".",
... | Method that gets the authenticated user. The returning user has
the token, email and the provider data. | [
"Method",
"that",
"gets",
"the",
"authenticated",
"user",
".",
"The",
"returning",
"user",
"has",
"the",
"token",
"email",
"and",
"the",
"provider",
"data",
"."
] | python | valid |
gwastro/pycbc | pycbc/events/veto.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/events/veto.py#L70-L90 | def indices_outside_times(times, start, end):
"""
Return an index array into times that like outside the durations defined by start end arrays
Parameters
----------
times: numpy.ndarray
Array of times
start: numpy.ndarray
Array of duration start times
end: numpy.ndarray
... | [
"def",
"indices_outside_times",
"(",
"times",
",",
"start",
",",
"end",
")",
":",
"exclude",
"=",
"indices_within_times",
"(",
"times",
",",
"start",
",",
"end",
")",
"indices",
"=",
"numpy",
".",
"arange",
"(",
"0",
",",
"len",
"(",
"times",
")",
")",... | Return an index array into times that like outside the durations defined by start end arrays
Parameters
----------
times: numpy.ndarray
Array of times
start: numpy.ndarray
Array of duration start times
end: numpy.ndarray
Array of duration end times
Returns
-------
... | [
"Return",
"an",
"index",
"array",
"into",
"times",
"that",
"like",
"outside",
"the",
"durations",
"defined",
"by",
"start",
"end",
"arrays"
] | python | train |
briancappello/flask-unchained | flask_unchained/bundles/security/decorators/auth_required.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/security/decorators/auth_required.py#L13-L54 | def auth_required(decorated_fn=None, **role_rules):
"""
Decorator for requiring an authenticated user, optionally with roles.
Roles are passed as keyword arguments, like so::
@auth_required(role='REQUIRE_THIS_ONE_ROLE')
@auth_required(roles=['REQUIRE', 'ALL', 'OF', 'THESE', 'ROLES'])
... | [
"def",
"auth_required",
"(",
"decorated_fn",
"=",
"None",
",",
"*",
"*",
"role_rules",
")",
":",
"required_roles",
"=",
"[",
"]",
"one_of_roles",
"=",
"[",
"]",
"if",
"not",
"(",
"decorated_fn",
"and",
"callable",
"(",
"decorated_fn",
")",
")",
":",
"if"... | Decorator for requiring an authenticated user, optionally with roles.
Roles are passed as keyword arguments, like so::
@auth_required(role='REQUIRE_THIS_ONE_ROLE')
@auth_required(roles=['REQUIRE', 'ALL', 'OF', 'THESE', 'ROLES'])
@auth_required(one_of=['EITHER_THIS_ROLE', 'OR_THIS_ONE'])
... | [
"Decorator",
"for",
"requiring",
"an",
"authenticated",
"user",
"optionally",
"with",
"roles",
"."
] | python | train |
daviddrysdale/python-phonenumbers | python/phonenumbers/phonenumbermatcher.py | https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/phonenumbermatcher.py#L556-L582 | def _extract_match(self, candidate, offset):
"""Attempts to extract a match from a candidate string.
Arguments:
candidate -- The candidate text that might contain a phone number.
offset -- The offset of candidate within self.text
Returns the match found, None if none can be foun... | [
"def",
"_extract_match",
"(",
"self",
",",
"candidate",
",",
"offset",
")",
":",
"# Skip a match that is more likely a publication page reference or a",
"# date.",
"if",
"(",
"_SLASH_SEPARATED_DATES",
".",
"search",
"(",
"candidate",
")",
")",
":",
"return",
"None",
"... | Attempts to extract a match from a candidate string.
Arguments:
candidate -- The candidate text that might contain a phone number.
offset -- The offset of candidate within self.text
Returns the match found, None if none can be found | [
"Attempts",
"to",
"extract",
"a",
"match",
"from",
"a",
"candidate",
"string",
"."
] | python | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1350-L1440 | def selector_default(output_widget=None):
"""Capture selection events from the current figure, and apply the selections to Scatter objects.
Example:
>>> import ipyvolume as ipv
>>> ipv.figure()
>>> ipv.examples.gaussian()
>>> ipv.selector_default()
>>> ipv.show()
Now hold the control ... | [
"def",
"selector_default",
"(",
"output_widget",
"=",
"None",
")",
":",
"fig",
"=",
"gcf",
"(",
")",
"if",
"output_widget",
"is",
"None",
":",
"output_widget",
"=",
"ipywidgets",
".",
"Output",
"(",
")",
"display",
"(",
"output_widget",
")",
"def",
"lasso"... | Capture selection events from the current figure, and apply the selections to Scatter objects.
Example:
>>> import ipyvolume as ipv
>>> ipv.figure()
>>> ipv.examples.gaussian()
>>> ipv.selector_default()
>>> ipv.show()
Now hold the control key to do selections, type
* 'C' for circl... | [
"Capture",
"selection",
"events",
"from",
"the",
"current",
"figure",
"and",
"apply",
"the",
"selections",
"to",
"Scatter",
"objects",
"."
] | python | train |
singularityhub/singularity-cli | spython/main/parse/docker.py | https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/main/parse/docker.py#L156-L185 | def _add(self, lines):
'''Add can also handle https, and compressed files.
Parameters
==========
line: the line from the recipe file to parse for ADD
'''
lines = self._setup('ADD', lines)
for line in lines:
values = line.split(" ")
... | [
"def",
"_add",
"(",
"self",
",",
"lines",
")",
":",
"lines",
"=",
"self",
".",
"_setup",
"(",
"'ADD'",
",",
"lines",
")",
"for",
"line",
"in",
"lines",
":",
"values",
"=",
"line",
".",
"split",
"(",
"\" \"",
")",
"frompath",
"=",
"values",
".",
"... | Add can also handle https, and compressed files.
Parameters
==========
line: the line from the recipe file to parse for ADD | [
"Add",
"can",
"also",
"handle",
"https",
"and",
"compressed",
"files",
"."
] | python | train |
tanghaibao/jcvi | jcvi/variation/str.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/variation/str.py#L947-L996 | def compilevcf(args):
"""
%prog compilevcf samples.csv
Compile vcf results into master spreadsheet.
"""
p = OptionParser(compilevcf.__doc__)
p.add_option("--db", default="hg38", help="Use these lobSTR db")
p.add_option("--nofilter", default=False, action="store_true",
help=... | [
"def",
"compilevcf",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"compilevcf",
".",
"__doc__",
")",
"p",
".",
"add_option",
"(",
"\"--db\"",
",",
"default",
"=",
"\"hg38\"",
",",
"help",
"=",
"\"Use these lobSTR db\"",
")",
"p",
".",
"add_option"... | %prog compilevcf samples.csv
Compile vcf results into master spreadsheet. | [
"%prog",
"compilevcf",
"samples",
".",
"csv"
] | python | train |
blockstack/blockstack-core | blockstack/lib/client.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L3100-L3138 | def get_name_history(name, hostport=None, proxy=None, history_page=None):
"""
Get the full history of a name
Returns {'status': True, 'history': ...} on success, where history is grouped by block
Returns {'error': ...} on error
"""
assert hostport or proxy, 'Need hostport or proxy'
if proxy ... | [
"def",
"get_name_history",
"(",
"name",
",",
"hostport",
"=",
"None",
",",
"proxy",
"=",
"None",
",",
"history_page",
"=",
"None",
")",
":",
"assert",
"hostport",
"or",
"proxy",
",",
"'Need hostport or proxy'",
"if",
"proxy",
"is",
"None",
":",
"proxy",
"=... | Get the full history of a name
Returns {'status': True, 'history': ...} on success, where history is grouped by block
Returns {'error': ...} on error | [
"Get",
"the",
"full",
"history",
"of",
"a",
"name",
"Returns",
"{",
"status",
":",
"True",
"history",
":",
"...",
"}",
"on",
"success",
"where",
"history",
"is",
"grouped",
"by",
"block",
"Returns",
"{",
"error",
":",
"...",
"}",
"on",
"error"
] | python | train |
IdentityPython/oidcendpoint | src/oidcendpoint/token_handler.py | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/token_handler.py#L279-L300 | def factory(ec, code=None, token=None, refresh=None, **kwargs):
"""
Create a token handler
:param code:
:param token:
:param refresh:
:return: TokenHandler instance
"""
TTYPE = {'code': 'A', 'token': 'T', 'refresh': 'R'}
args = {}
if code:
args['code_handler'] = init_... | [
"def",
"factory",
"(",
"ec",
",",
"code",
"=",
"None",
",",
"token",
"=",
"None",
",",
"refresh",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"TTYPE",
"=",
"{",
"'code'",
":",
"'A'",
",",
"'token'",
":",
"'T'",
",",
"'refresh'",
":",
"'R'",
... | Create a token handler
:param code:
:param token:
:param refresh:
:return: TokenHandler instance | [
"Create",
"a",
"token",
"handler"
] | python | train |
openstack/python-monascaclient | monascaclient/common/monasca_manager.py | https://github.com/openstack/python-monascaclient/blob/03b07534145928eb2debad938da033c232dda105/monascaclient/common/monasca_manager.py#L37-L51 | def _list(self, path, dim_key=None, **kwargs):
"""Get a list of metrics."""
url_str = self.base_url + path
if dim_key and dim_key in kwargs:
dim_str = self.get_dimensions_url_string(kwargs[dim_key])
kwargs[dim_key] = dim_str
if kwargs:
url_str += '?%s... | [
"def",
"_list",
"(",
"self",
",",
"path",
",",
"dim_key",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url_str",
"=",
"self",
".",
"base_url",
"+",
"path",
"if",
"dim_key",
"and",
"dim_key",
"in",
"kwargs",
":",
"dim_str",
"=",
"self",
".",
"ge... | Get a list of metrics. | [
"Get",
"a",
"list",
"of",
"metrics",
"."
] | python | train |
user-cont/conu | conu/backend/k8s/backend.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/k8s/backend.py#L169-L177 | def delete_namespace(self, name):
"""
Delete namespace with specific name
:param name: str, namespace to delete
:return: None
"""
self.core_api.delete_namespace(name, client.V1DeleteOptions())
logger.info("Deleting namespace: %s", name) | [
"def",
"delete_namespace",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"core_api",
".",
"delete_namespace",
"(",
"name",
",",
"client",
".",
"V1DeleteOptions",
"(",
")",
")",
"logger",
".",
"info",
"(",
"\"Deleting namespace: %s\"",
",",
"name",
")"
] | Delete namespace with specific name
:param name: str, namespace to delete
:return: None | [
"Delete",
"namespace",
"with",
"specific",
"name",
":",
"param",
"name",
":",
"str",
"namespace",
"to",
"delete",
":",
"return",
":",
"None"
] | python | train |
tanghaibao/goatools | goatools/gosubdag/go_tasks.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/go_tasks.py#L91-L96 | def get_go2children_go2obj(go2obj):
"""Return go2children (set of child GO IDs) for all GO ID keys in go2obj."""
goobjs, altgo2goobj = get_goobjs_altgo2goobj(go2obj)
go2children = get_id2children(goobjs)
add_alt_goids(go2children, altgo2goobj)
return go2children | [
"def",
"get_go2children_go2obj",
"(",
"go2obj",
")",
":",
"goobjs",
",",
"altgo2goobj",
"=",
"get_goobjs_altgo2goobj",
"(",
"go2obj",
")",
"go2children",
"=",
"get_id2children",
"(",
"goobjs",
")",
"add_alt_goids",
"(",
"go2children",
",",
"altgo2goobj",
")",
"ret... | Return go2children (set of child GO IDs) for all GO ID keys in go2obj. | [
"Return",
"go2children",
"(",
"set",
"of",
"child",
"GO",
"IDs",
")",
"for",
"all",
"GO",
"ID",
"keys",
"in",
"go2obj",
"."
] | python | train |
waqasbhatti/astrobase | astrobase/lcfit/transits.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcfit/transits.py#L85-L401 | def traptransit_fit_magseries(times, mags, errs,
transitparams,
sigclip=10.0,
plotfit=False,
magsarefluxes=False,
verbose=True):
'''This fits a trapezoid transit mode... | [
"def",
"traptransit_fit_magseries",
"(",
"times",
",",
"mags",
",",
"errs",
",",
"transitparams",
",",
"sigclip",
"=",
"10.0",
",",
"plotfit",
"=",
"False",
",",
"magsarefluxes",
"=",
"False",
",",
"verbose",
"=",
"True",
")",
":",
"stimes",
",",
"smags",
... | This fits a trapezoid transit model to a magnitude time series.
Parameters
----------
times,mags,errs : np.array
The input mag/flux time-series to fit a trapezoid planet-transit model
to.
period : float
The period to use for the model fit.
transitparams : list of floats
... | [
"This",
"fits",
"a",
"trapezoid",
"transit",
"model",
"to",
"a",
"magnitude",
"time",
"series",
"."
] | python | valid |
PmagPy/PmagPy | dialogs/pmag_er_magic_dialogs.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/pmag_er_magic_dialogs.py#L981-L993 | def on_helpButton(self, event, page=None):
"""shows html help page"""
# for use on the command line:
path = find_pmag_dir.get_pmag_dir()
# for use with pyinstaller
#path = self.main_frame.resource_dir
help_page = os.path.join(path, 'dialogs', 'help_files', page)
#... | [
"def",
"on_helpButton",
"(",
"self",
",",
"event",
",",
"page",
"=",
"None",
")",
":",
"# for use on the command line:",
"path",
"=",
"find_pmag_dir",
".",
"get_pmag_dir",
"(",
")",
"# for use with pyinstaller",
"#path = self.main_frame.resource_dir",
"help_page",
"=",
... | shows html help page | [
"shows",
"html",
"help",
"page"
] | python | train |
palantir/typedjsonrpc | typedjsonrpc/server.py | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L177-L194 | def debug_application(self, environ, start_response):
"""Run the application and preserve the traceback frames.
:param environ: The environment which is passed into the wsgi application
:type environ: dict[str, object]
:param start_response: The start_response function of the wsgi appli... | [
"def",
"debug_application",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"adapter",
"=",
"self",
".",
"_debug_map",
".",
"bind_to_environ",
"(",
"environ",
")",
"if",
"adapter",
".",
"test",
"(",
")",
":",
"_",
",",
"args",
"=",
"adapter... | Run the application and preserve the traceback frames.
:param environ: The environment which is passed into the wsgi application
:type environ: dict[str, object]
:param start_response: The start_response function of the wsgi application
:type start_response: (str, list[(str, str)]) -> N... | [
"Run",
"the",
"application",
"and",
"preserve",
"the",
"traceback",
"frames",
"."
] | python | train |
coin-or/GiMPy | src/gimpy/graph.py | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2349-L2403 | def simplex_determine_leaving_arc(self, t, k, l):
'''
API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
... | [
"def",
"simplex_determine_leaving_arc",
"(",
"self",
",",
"t",
",",
"k",
",",
"l",
")",
":",
"# k,l are the first two elements of the cycle",
"cycle",
"=",
"self",
".",
"simplex_identify_cycle",
"(",
"t",
",",
"k",
",",
"l",
")",
"flow_kl",
"=",
"self",
".",
... | API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
l: head of the entering arc.
Return:
Returns the t... | [
"API",
":",
"simplex_determine_leaving_arc",
"(",
"self",
"t",
"k",
"l",
")",
"Description",
":",
"Determines",
"and",
"returns",
"the",
"leaving",
"arc",
".",
"Input",
":",
"t",
":",
"current",
"spanning",
"tree",
"solution",
".",
"k",
":",
"tail",
"of",
... | python | train |
ska-sa/katcp-python | katcp/client.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/client.py#L821-L843 | def start(self, timeout=None):
"""Start the client in a new thread.
Parameters
----------
timeout : float in seconds
Seconds to wait for client thread to start. Do not specify a
timeout if start() is being called from the same ioloop that this
client ... | [
"def",
"start",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_running",
".",
"isSet",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Device client already started.\"",
")",
"# Make sure we have an ioloop",
"self",
".",
"ioloop",
"="... | Start the client in a new thread.
Parameters
----------
timeout : float in seconds
Seconds to wait for client thread to start. Do not specify a
timeout if start() is being called from the same ioloop that this
client will be installed on, since it will block ... | [
"Start",
"the",
"client",
"in",
"a",
"new",
"thread",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.