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 |
|---|---|---|---|---|---|---|---|---|
xoolive/traffic | traffic/core/mixins.py | https://github.com/xoolive/traffic/blob/d1a8878098f16759f6b6e0e8d8b8f32e34a680a8/traffic/core/mixins.py#L119-L124 | def bounds(self) -> Tuple[float, float, float, float]:
"""Returns the bounds of the shape.
Bounds are given in the following order in the origin crs:
west, south, east, north
"""
return self.shape.bounds | [
"def",
"bounds",
"(",
"self",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
",",
"float",
"]",
":",
"return",
"self",
".",
"shape",
".",
"bounds"
] | Returns the bounds of the shape.
Bounds are given in the following order in the origin crs:
west, south, east, north | [
"Returns",
"the",
"bounds",
"of",
"the",
"shape",
".",
"Bounds",
"are",
"given",
"in",
"the",
"following",
"order",
"in",
"the",
"origin",
"crs",
":",
"west",
"south",
"east",
"north"
] | python | train |
nerdvegas/rez | src/rez/utils/colorize.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/colorize.py#L176-L219 | def _color(str_, fore_color=None, back_color=None, styles=None):
""" Return the string wrapped with the appropriate styling escape sequences.
Args:
str_ (str): The string to be wrapped.
fore_color (str, optional): Any foreground color supported by the
`Colorama`_ module.
back_color (s... | [
"def",
"_color",
"(",
"str_",
",",
"fore_color",
"=",
"None",
",",
"back_color",
"=",
"None",
",",
"styles",
"=",
"None",
")",
":",
"# TODO: Colorama is documented to work on Windows and trivial test case",
"# proves this to be the case, but it doesn't work in Rez. If the init... | Return the string wrapped with the appropriate styling escape sequences.
Args:
str_ (str): The string to be wrapped.
fore_color (str, optional): Any foreground color supported by the
`Colorama`_ module.
back_color (str, optional): Any background color supported by the
`Colorama`_ ... | [
"Return",
"the",
"string",
"wrapped",
"with",
"the",
"appropriate",
"styling",
"escape",
"sequences",
"."
] | python | train |
jaysonsantos/python-binary-memcached | bmemcached/protocol.py | https://github.com/jaysonsantos/python-binary-memcached/blob/6a792829349c69204d9c5045e5c34b4231216dd6/bmemcached/protocol.py#L364-L406 | def deserialize(self, value, flags):
"""
Deserialized values based on flags or just return it if it is not serialized.
:param value: Serialized or not value.
:type value: six.string_types, int
:param flags: Value flags
:type flags: int
:return: Deserialized value... | [
"def",
"deserialize",
"(",
"self",
",",
"value",
",",
"flags",
")",
":",
"FLAGS",
"=",
"self",
".",
"FLAGS",
"if",
"flags",
"&",
"FLAGS",
"[",
"'compressed'",
"]",
":",
"# pragma: no branch",
"value",
"=",
"self",
".",
"compression",
".",
"decompress",
"... | Deserialized values based on flags or just return it if it is not serialized.
:param value: Serialized or not value.
:type value: six.string_types, int
:param flags: Value flags
:type flags: int
:return: Deserialized value
:rtype: six.string_types|int | [
"Deserialized",
"values",
"based",
"on",
"flags",
"or",
"just",
"return",
"it",
"if",
"it",
"is",
"not",
"serialized",
"."
] | python | train |
FNNDSC/med2image | med2image/med2image.py | https://github.com/FNNDSC/med2image/blob/638d5d230de47608af20f9764acf8e382c2bf2ff/med2image/med2image.py#L489-L537 | def run(self):
'''
Runs the NIfTI conversion based on internal state.
'''
self._log('About to perform NifTI to %s conversion...\n' %
self._str_outputFileType)
frames = 1
frameStart = 0
frameEnd = 0
sliceStart = 0
sliceEnd... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_log",
"(",
"'About to perform NifTI to %s conversion...\\n'",
"%",
"self",
".",
"_str_outputFileType",
")",
"frames",
"=",
"1",
"frameStart",
"=",
"0",
"frameEnd",
"=",
"0",
"sliceStart",
"=",
"0",
"sliceEnd"... | Runs the NIfTI conversion based on internal state. | [
"Runs",
"the",
"NIfTI",
"conversion",
"based",
"on",
"internal",
"state",
"."
] | python | train |
graphql-python/graphql-core-next | graphql/utilities/separate_operations.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/utilities/separate_operations.py#L19-L52 | def separate_operations(document_ast: DocumentNode) -> Dict[str, DocumentNode]:
"""Separate operations in a given AST document.
This function accepts a single AST document which may contain many operations and
fragments and returns a collection of AST documents each of which contains a single
operation... | [
"def",
"separate_operations",
"(",
"document_ast",
":",
"DocumentNode",
")",
"->",
"Dict",
"[",
"str",
",",
"DocumentNode",
"]",
":",
"# Populate metadata and build a dependency graph.",
"visitor",
"=",
"SeparateOperations",
"(",
")",
"visit",
"(",
"document_ast",
","... | Separate operations in a given AST document.
This function accepts a single AST document which may contain many operations and
fragments and returns a collection of AST documents each of which contains a single
operation as well the fragment definitions it refers to. | [
"Separate",
"operations",
"in",
"a",
"given",
"AST",
"document",
"."
] | python | train |
inveniosoftware-attic/invenio-utils | invenio_utils/mail.py | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/mail.py#L29-L138 | def email_quoted_txt2html(text,
tabs_before=0,
indent_txt='>>',
linebreak_txt="\n",
indent_html=('<div class="commentbox">', "</div>"),
linebreak_html='<br/>',
inde... | [
"def",
"email_quoted_txt2html",
"(",
"text",
",",
"tabs_before",
"=",
"0",
",",
"indent_txt",
"=",
"'>>'",
",",
"linebreak_txt",
"=",
"\"\\n\"",
",",
"indent_html",
"=",
"(",
"'<div class=\"commentbox\">'",
",",
"\"</div>\"",
")",
",",
"linebreak_html",
"=",
"'<... | Takes a typical mail quoted text, e.g.::
hello,
you told me:
>> Your mother was a hamster and your father smelt of elderberries
I must tell you that I'm not convinced. Then in this discussion:
>>>> Is there someone else up there we could talk to?
>> No. Now, go away, or I... | [
"Takes",
"a",
"typical",
"mail",
"quoted",
"text",
"e",
".",
"g",
".",
"::",
"hello",
"you",
"told",
"me",
":",
">>",
"Your",
"mother",
"was",
"a",
"hamster",
"and",
"your",
"father",
"smelt",
"of",
"elderberries",
"I",
"must",
"tell",
"you",
"that",
... | python | train |
google/grr | grr/client/grr_response_client/client_actions/artifact_collector.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/artifact_collector.py#L114-L119 | def _ProcessSources(self, sources, parser_factory):
"""Iterates through sources yielding action responses."""
for source in sources:
for action, request in self._ParseSourceType(source):
yield self._RunClientAction(action, request, parser_factory,
source.path_ty... | [
"def",
"_ProcessSources",
"(",
"self",
",",
"sources",
",",
"parser_factory",
")",
":",
"for",
"source",
"in",
"sources",
":",
"for",
"action",
",",
"request",
"in",
"self",
".",
"_ParseSourceType",
"(",
"source",
")",
":",
"yield",
"self",
".",
"_RunClien... | Iterates through sources yielding action responses. | [
"Iterates",
"through",
"sources",
"yielding",
"action",
"responses",
"."
] | python | train |
basho/riak-python-client | riak/transports/http/transport.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/transport.py#L602-L624 | def search(self, index, query, **params):
"""
Performs a search query.
"""
if index is None:
index = 'search'
options = {}
if 'op' in params:
op = params.pop('op')
options['q.op'] = op
options.update(params)
url = self... | [
"def",
"search",
"(",
"self",
",",
"index",
",",
"query",
",",
"*",
"*",
"params",
")",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"'search'",
"options",
"=",
"{",
"}",
"if",
"'op'",
"in",
"params",
":",
"op",
"=",
"params",
".",
"pop",... | Performs a search query. | [
"Performs",
"a",
"search",
"query",
"."
] | python | train |
Linaro/squad | squad/core/management/commands/users.py | https://github.com/Linaro/squad/blob/27da5375e119312a86f231df95f99c979b9f48f0/squad/core/management/commands/users.py#L148-L157 | def handle(self, *args, **options):
""" Forward to the right sub-handler """
if options["sub_command"] == "add":
self.handle_add(options)
elif options["sub_command"] == "update":
self.handle_update(options)
elif options["sub_command"] == "details":
sel... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"if",
"options",
"[",
"\"sub_command\"",
"]",
"==",
"\"add\"",
":",
"self",
".",
"handle_add",
"(",
"options",
")",
"elif",
"options",
"[",
"\"sub_command\"",
"]",
"=="... | Forward to the right sub-handler | [
"Forward",
"to",
"the",
"right",
"sub",
"-",
"handler"
] | python | train |
quodlibet/mutagen | mutagen/_util.py | https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/_util.py#L781-L821 | def fallback_move(fobj, dest, src, count, BUFFER_SIZE=2 ** 16):
"""Moves data around using read()/write().
Args:
fileobj (fileobj)
dest (int): The destination offset
src (int): The source offset
count (int) The amount of data to move
Raises:
IOError: In case an opera... | [
"def",
"fallback_move",
"(",
"fobj",
",",
"dest",
",",
"src",
",",
"count",
",",
"BUFFER_SIZE",
"=",
"2",
"**",
"16",
")",
":",
"if",
"dest",
"<",
"0",
"or",
"src",
"<",
"0",
"or",
"count",
"<",
"0",
":",
"raise",
"ValueError",
"fobj",
".",
"seek... | Moves data around using read()/write().
Args:
fileobj (fileobj)
dest (int): The destination offset
src (int): The source offset
count (int) The amount of data to move
Raises:
IOError: In case an operation on the fileobj fails
ValueError: In case invalid parameter... | [
"Moves",
"data",
"around",
"using",
"read",
"()",
"/",
"write",
"()",
"."
] | python | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/dataset.py | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/dataset.py#L76-L93 | def data_files(self):
"""Returns a python list of all (sharded) data subset files.
Returns:
python list of all (sharded) data set files.
Raises:
ValueError: if there are not data_files matching the subset.
"""
tf_record_pattern = os.path.join(FLAGS.data_dir, '%s-*' % self.subset)
da... | [
"def",
"data_files",
"(",
"self",
")",
":",
"tf_record_pattern",
"=",
"os",
".",
"path",
".",
"join",
"(",
"FLAGS",
".",
"data_dir",
",",
"'%s-*'",
"%",
"self",
".",
"subset",
")",
"data_files",
"=",
"tf",
".",
"gfile",
".",
"Glob",
"(",
"tf_record_pat... | Returns a python list of all (sharded) data subset files.
Returns:
python list of all (sharded) data set files.
Raises:
ValueError: if there are not data_files matching the subset. | [
"Returns",
"a",
"python",
"list",
"of",
"all",
"(",
"sharded",
")",
"data",
"subset",
"files",
"."
] | python | train |
alefnula/tea | tea/shell/__init__.py | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L300-L313 | def gmove(pattern, destination):
"""Move all file found by glob.glob(pattern) to destination directory.
Args:
pattern (str): Glob pattern
destination (str): Path to the destination directory.
Returns:
bool: True if the operation is successful, False otherwise.
"""
for item ... | [
"def",
"gmove",
"(",
"pattern",
",",
"destination",
")",
":",
"for",
"item",
"in",
"glob",
".",
"glob",
"(",
"pattern",
")",
":",
"if",
"not",
"move",
"(",
"item",
",",
"destination",
")",
":",
"return",
"False",
"return",
"True"
] | Move all file found by glob.glob(pattern) to destination directory.
Args:
pattern (str): Glob pattern
destination (str): Path to the destination directory.
Returns:
bool: True if the operation is successful, False otherwise. | [
"Move",
"all",
"file",
"found",
"by",
"glob",
".",
"glob",
"(",
"pattern",
")",
"to",
"destination",
"directory",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/electronic_structure/plotter.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/plotter.py#L3526-L3647 | def get_plot(self, xlim=None, ylim=None, plot_negative=None,
integrated=False, invert_axes=True):
"""
Get a matplotlib plot showing the COHP.
Args:
xlim: Specifies the x-axis limits. Defaults to None for
automatic determination.
ylim: Sp... | [
"def",
"get_plot",
"(",
"self",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
",",
"plot_negative",
"=",
"None",
",",
"integrated",
"=",
"False",
",",
"invert_axes",
"=",
"True",
")",
":",
"if",
"self",
".",
"are_coops",
":",
"cohp_label",
"=",
... | Get a matplotlib plot showing the COHP.
Args:
xlim: Specifies the x-axis limits. Defaults to None for
automatic determination.
ylim: Specifies the y-axis limits. Defaults to None for
automatic determination.
plot_negative: It is common to pl... | [
"Get",
"a",
"matplotlib",
"plot",
"showing",
"the",
"COHP",
"."
] | python | train |
f3at/feat | src/feat/extern/log/log.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/extern/log/log.py#L681-L704 | def reopenOutputFiles():
"""
Reopens the stdout and stderr output files, as set by
L{outputToFiles}.
"""
if not _stdout and not _stderr:
debug('log', 'told to reopen log files, but log files not set')
return
def reopen(name, fileno, *args):
oldmask = os.umask(0026)
... | [
"def",
"reopenOutputFiles",
"(",
")",
":",
"if",
"not",
"_stdout",
"and",
"not",
"_stderr",
":",
"debug",
"(",
"'log'",
",",
"'told to reopen log files, but log files not set'",
")",
"return",
"def",
"reopen",
"(",
"name",
",",
"fileno",
",",
"*",
"args",
")",... | Reopens the stdout and stderr output files, as set by
L{outputToFiles}. | [
"Reopens",
"the",
"stdout",
"and",
"stderr",
"output",
"files",
"as",
"set",
"by",
"L",
"{",
"outputToFiles",
"}",
"."
] | python | train |
cloudtools/troposphere | troposphere/utils.py | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/utils.py#L8-L19 | def get_events(conn, stackname):
"""Get the events in batches and return in chronological order"""
next = None
event_list = []
while 1:
events = conn.describe_stack_events(stackname, next)
event_list.append(events)
if events.next_token is None:
break
next = ev... | [
"def",
"get_events",
"(",
"conn",
",",
"stackname",
")",
":",
"next",
"=",
"None",
"event_list",
"=",
"[",
"]",
"while",
"1",
":",
"events",
"=",
"conn",
".",
"describe_stack_events",
"(",
"stackname",
",",
"next",
")",
"event_list",
".",
"append",
"(",
... | Get the events in batches and return in chronological order | [
"Get",
"the",
"events",
"in",
"batches",
"and",
"return",
"in",
"chronological",
"order"
] | python | train |
saltstack/salt | salt/modules/rabbitmq.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rabbitmq.py#L1008-L1020 | def plugin_is_enabled(name, runas=None):
'''
Return whether the plugin is enabled.
CLI Example:
.. code-block:: bash
salt '*' rabbitmq.plugin_is_enabled rabbitmq_plugin_name
'''
if runas is None and not salt.utils.platform.is_windows():
runas = salt.utils.user.get_user()
r... | [
"def",
"plugin_is_enabled",
"(",
"name",
",",
"runas",
"=",
"None",
")",
":",
"if",
"runas",
"is",
"None",
"and",
"not",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"runas",
"=",
"salt",
".",
"utils",
".",
"user",
".",
... | Return whether the plugin is enabled.
CLI Example:
.. code-block:: bash
salt '*' rabbitmq.plugin_is_enabled rabbitmq_plugin_name | [
"Return",
"whether",
"the",
"plugin",
"is",
"enabled",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/distlib/database.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/database.py#L1003-L1039 | def list_installed_files(self):
"""
Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: a list of (path, hash, size)
"""
def _md5(path):
f = open(path, 'rb')
try:
c... | [
"def",
"list_installed_files",
"(",
"self",
")",
":",
"def",
"_md5",
"(",
"path",
")",
":",
"f",
"=",
"open",
"(",
"path",
",",
"'rb'",
")",
"try",
":",
"content",
"=",
"f",
".",
"read",
"(",
")",
"finally",
":",
"f",
".",
"close",
"(",
")",
"r... | Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line.
:returns: a list of (path, hash, size) | [
"Iterates",
"over",
"the",
"installed",
"-",
"files",
".",
"txt",
"entries",
"and",
"returns",
"a",
"tuple",
"(",
"path",
"hash",
"size",
")",
"for",
"each",
"line",
"."
] | python | train |
hobson/pug-invest | pug/invest/sandbox/sim.py | https://github.com/hobson/pug-invest/blob/836911258a0e920083a88c91beae88eefdebb20c/pug/invest/sandbox/sim.py#L276-L292 | def symbols_bollinger(symbols='sp5002012',
start=datetime.datetime(2008, 1, 1), end=datetime.datetime(2009, 12, 31), price_type='adjusted_close', cleaner=clean_dataframe,
window=20, sigma=1.):
"""Calculate the Bolinger for a list or set of symbols
Example:
>>> symbols_bollinger(["AAPL", "GOOG", "IB... | [
"def",
"symbols_bollinger",
"(",
"symbols",
"=",
"'sp5002012'",
",",
"start",
"=",
"datetime",
".",
"datetime",
"(",
"2008",
",",
"1",
",",
"1",
")",
",",
"end",
"=",
"datetime",
".",
"datetime",
"(",
"2009",
",",
"12",
",",
"31",
")",
",",
"price_ty... | Calculate the Bolinger for a list or set of symbols
Example:
>>> symbols_bollinger(["AAPL", "GOOG", "IBM", "MSFT"], '10-12-01', '10-12-30')[-5:] # doctest: +NORMALIZE_WHITESPACE
GOOG AAPL IBM MSFT
2010-12-23 16:00:00 1.298178 1.185009 1.177220 1.237684
... | [
"Calculate",
"the",
"Bolinger",
"for",
"a",
"list",
"or",
"set",
"of",
"symbols"
] | python | train |
jasontrigg0/jtutils | jtutils/jtutils.py | https://github.com/jasontrigg0/jtutils/blob/e1d1ab35083f6c7a4ebd94d1bd08eca59e8e9c6a/jtutils/jtutils.py#L233-L273 | def lesspager(lines):
"""
Use for streaming writes to a less process
Taken from pydoc.pipepager:
/usr/lib/python2.7/pydoc.py
and
/usr/lib/python3.5/pydoc.py
"""
cmd = "less -S"
if sys.version_info[0] >= 3:
"""Page through text by feeding it to another program."""
impo... | [
"def",
"lesspager",
"(",
"lines",
")",
":",
"cmd",
"=",
"\"less -S\"",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"\"\"\"Page through text by feeding it to another program.\"\"\"",
"import",
"subprocess",
"proc",
"=",
"subprocess",
".",
"Pope... | Use for streaming writes to a less process
Taken from pydoc.pipepager:
/usr/lib/python2.7/pydoc.py
and
/usr/lib/python3.5/pydoc.py | [
"Use",
"for",
"streaming",
"writes",
"to",
"a",
"less",
"process",
"Taken",
"from",
"pydoc",
".",
"pipepager",
":",
"/",
"usr",
"/",
"lib",
"/",
"python2",
".",
"7",
"/",
"pydoc",
".",
"py",
"and",
"/",
"usr",
"/",
"lib",
"/",
"python3",
".",
"5",
... | python | valid |
b3j0f/utils | b3j0f/utils/iterable.py | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L93-L121 | def first(iterable, default=None):
"""Try to get input iterable first item or default if iterable is empty.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not ... | [
"def",
"first",
"(",
"iterable",
",",
"default",
"=",
"None",
")",
":",
"result",
"=",
"default",
"# start to get the iterable iterator (raises TypeError if iter)",
"iterator",
"=",
"iter",
"(",
"iterable",
")",
"# get first element",
"try",
":",
"result",
"=",
"nex... | Try to get input iterable first item or default if iterable is empty.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not an iterable value.
:Example:
>>>... | [
"Try",
"to",
"get",
"input",
"iterable",
"first",
"item",
"or",
"default",
"if",
"iterable",
"is",
"empty",
"."
] | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/task/task_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/task/task_client.py#L428-L446 | def get_timelines(self, scope_identifier, hub_name, plan_id):
"""GetTimelines.
:param str scope_identifier: The project GUID to scope the request
:param str hub_name: The name of the server hub: "build" for the Build server or "rm" for the Release Management server
:param str plan_id:
... | [
"def",
"get_timelines",
"(",
"self",
",",
"scope_identifier",
",",
"hub_name",
",",
"plan_id",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"scope_identifier",
"is",
"not",
"None",
":",
"route_values",
"[",
"'scopeIdentifier'",
"]",
"=",
"self",
".",
"_ser... | GetTimelines.
:param str scope_identifier: The project GUID to scope the request
:param str hub_name: The name of the server hub: "build" for the Build server or "rm" for the Release Management server
:param str plan_id:
:rtype: [Timeline] | [
"GetTimelines",
".",
":",
"param",
"str",
"scope_identifier",
":",
"The",
"project",
"GUID",
"to",
"scope",
"the",
"request",
":",
"param",
"str",
"hub_name",
":",
"The",
"name",
"of",
"the",
"server",
"hub",
":",
"build",
"for",
"the",
"Build",
"server",
... | python | train |
O365/python-o365 | O365/utils/utils.py | https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/utils/utils.py#L116-L121 | def _track_changes(self):
""" Update the track_changes on the parent to reflect a
needed update on this field """
if self._field and getattr(self._parent, '_track_changes',
None) is not None:
self._parent._track_changes.add(self._field) | [
"def",
"_track_changes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_field",
"and",
"getattr",
"(",
"self",
".",
"_parent",
",",
"'_track_changes'",
",",
"None",
")",
"is",
"not",
"None",
":",
"self",
".",
"_parent",
".",
"_track_changes",
".",
"add",
... | Update the track_changes on the parent to reflect a
needed update on this field | [
"Update",
"the",
"track_changes",
"on",
"the",
"parent",
"to",
"reflect",
"a",
"needed",
"update",
"on",
"this",
"field"
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L13364-L13404 | def subpnt(method, target, et, fixref, abcorr, obsrvr):
"""
Compute the rectangular coordinates of the sub-observer point on
a target body at a specified epoch, optionally corrected for
light time and stellar aberration.
This routine supersedes :func:`subpt`.
http://naif.jpl.nasa.gov/pub/naif/... | [
"def",
"subpnt",
"(",
"method",
",",
"target",
",",
"et",
",",
"fixref",
",",
"abcorr",
",",
"obsrvr",
")",
":",
"method",
"=",
"stypes",
".",
"stringToCharP",
"(",
"method",
")",
"target",
"=",
"stypes",
".",
"stringToCharP",
"(",
"target",
")",
"et",... | Compute the rectangular coordinates of the sub-observer point on
a target body at a specified epoch, optionally corrected for
light time and stellar aberration.
This routine supersedes :func:`subpt`.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/subpnt_c.html
:param method: Computation ... | [
"Compute",
"the",
"rectangular",
"coordinates",
"of",
"the",
"sub",
"-",
"observer",
"point",
"on",
"a",
"target",
"body",
"at",
"a",
"specified",
"epoch",
"optionally",
"corrected",
"for",
"light",
"time",
"and",
"stellar",
"aberration",
"."
] | python | train |
jtwhite79/pyemu | pyemu/pst/pst_handler.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L1789-L1823 | def _adjust_weights_by_phi_components(self, components,original_ceiling):
"""resets the weights of observations by group to account for
residual phi components.
Parameters
----------
components : dict
a dictionary of obs group:phi contribution pairs
original_... | [
"def",
"_adjust_weights_by_phi_components",
"(",
"self",
",",
"components",
",",
"original_ceiling",
")",
":",
"obs",
"=",
"self",
".",
"observation_data",
"nz_groups",
"=",
"obs",
".",
"groupby",
"(",
"obs",
"[",
"\"weight\"",
"]",
".",
"map",
"(",
"lambda",
... | resets the weights of observations by group to account for
residual phi components.
Parameters
----------
components : dict
a dictionary of obs group:phi contribution pairs
original_ceiling : bool
flag to keep weights from increasing | [
"resets",
"the",
"weights",
"of",
"observations",
"by",
"group",
"to",
"account",
"for",
"residual",
"phi",
"components",
"."
] | python | train |
CitrineInformatics/pypif | pypif/pif.py | https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/pif.py#L53-L66 | def loado(obj, class_=None):
"""
Convert a dictionary or a list of dictionaries into a single Physical Information Object or a list of such objects.
:param obj: Dictionary or list to convert to Physical Information Objects.
:param class_: Subclass of :class:`.Pio` to produce, if not unambiguous
:re... | [
"def",
"loado",
"(",
"obj",
",",
"class_",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"[",
"_dict_to_pio",
"(",
"i",
",",
"class_",
"=",
"class_",
")",
"for",
"i",
"in",
"obj",
"]",
"elif",
"isinstance",... | Convert a dictionary or a list of dictionaries into a single Physical Information Object or a list of such objects.
:param obj: Dictionary or list to convert to Physical Information Objects.
:param class_: Subclass of :class:`.Pio` to produce, if not unambiguous
:return: Single object derived from :class:`... | [
"Convert",
"a",
"dictionary",
"or",
"a",
"list",
"of",
"dictionaries",
"into",
"a",
"single",
"Physical",
"Information",
"Object",
"or",
"a",
"list",
"of",
"such",
"objects",
"."
] | python | train |
awslabs/sockeye | sockeye/inference.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/inference.py#L2434-L2450 | def hybrid_forward(self, F, scores, offset):
"""
Get the single lowest element per sentence from a `scores` matrix. Expects that
beam size is 1, for greedy decoding.
:param scores: Vocabulary scores for the next beam step. (batch_size * beam_size, target_vocabulary_size)
:param ... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"scores",
",",
"offset",
")",
":",
"best_word_indices",
"=",
"F",
".",
"cast",
"(",
"F",
".",
"argmin",
"(",
"scores",
",",
"axis",
"=",
"1",
")",
",",
"dtype",
"=",
"'int32'",
")",
"values",
"="... | Get the single lowest element per sentence from a `scores` matrix. Expects that
beam size is 1, for greedy decoding.
:param scores: Vocabulary scores for the next beam step. (batch_size * beam_size, target_vocabulary_size)
:param offset: Array to add to the hypothesis indices for offsetting in ... | [
"Get",
"the",
"single",
"lowest",
"element",
"per",
"sentence",
"from",
"a",
"scores",
"matrix",
".",
"Expects",
"that",
"beam",
"size",
"is",
"1",
"for",
"greedy",
"decoding",
"."
] | python | train |
freelancer/freelancer-sdk-python | freelancersdk/resources/projects/projects.py | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L574-L591 | def request_release_milestone_payment(session, milestone_id):
"""
Release a milestone payment
"""
params_data = {
'action': 'request_release',
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'.format(milestone_id)
response = make_put_r... | [
"def",
"request_release_milestone_payment",
"(",
"session",
",",
"milestone_id",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'request_release'",
",",
"}",
"# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release",
"endpoint",
"=",
"'milestones/{}'",
".",
... | Release a milestone payment | [
"Release",
"a",
"milestone",
"payment"
] | python | valid |
RedHatInsights/insights-core | insights/contrib/pyparsing.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/contrib/pyparsing.py#L3596-L3598 | def downcaseTokens(s,l,t):
"""Helper parse action to convert tokens to lower case."""
return [ tt.lower() for tt in map(_ustr,t) ] | [
"def",
"downcaseTokens",
"(",
"s",
",",
"l",
",",
"t",
")",
":",
"return",
"[",
"tt",
".",
"lower",
"(",
")",
"for",
"tt",
"in",
"map",
"(",
"_ustr",
",",
"t",
")",
"]"
] | Helper parse action to convert tokens to lower case. | [
"Helper",
"parse",
"action",
"to",
"convert",
"tokens",
"to",
"lower",
"case",
"."
] | python | train |
rene-aguirre/pywinusb | pywinusb/hid/winapi.py | https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/winapi.py#L28-L33 | def winapi_result( result ):
"""Validate WINAPI BOOL result, raise exception if failed"""
if not result:
raise WinApiException("%d (%x): %s" % (ctypes.GetLastError(),
ctypes.GetLastError(), ctypes.FormatError()))
return result | [
"def",
"winapi_result",
"(",
"result",
")",
":",
"if",
"not",
"result",
":",
"raise",
"WinApiException",
"(",
"\"%d (%x): %s\"",
"%",
"(",
"ctypes",
".",
"GetLastError",
"(",
")",
",",
"ctypes",
".",
"GetLastError",
"(",
")",
",",
"ctypes",
".",
"FormatErr... | Validate WINAPI BOOL result, raise exception if failed | [
"Validate",
"WINAPI",
"BOOL",
"result",
"raise",
"exception",
"if",
"failed"
] | python | train |
JNRowe/upoints | upoints/point.py | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/point.py#L28-L38 | def _manage_location(attr):
"""Build managed property interface.
Args:
attr (str): Property's name
Returns:
property: Managed property interface
"""
return property(lambda self: getattr(self, '_%s' % attr),
lambda self, value: self._set_location(attr, value)) | [
"def",
"_manage_location",
"(",
"attr",
")",
":",
"return",
"property",
"(",
"lambda",
"self",
":",
"getattr",
"(",
"self",
",",
"'_%s'",
"%",
"attr",
")",
",",
"lambda",
"self",
",",
"value",
":",
"self",
".",
"_set_location",
"(",
"attr",
",",
"value... | Build managed property interface.
Args:
attr (str): Property's name
Returns:
property: Managed property interface | [
"Build",
"managed",
"property",
"interface",
"."
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5406-L5415 | def getComponentName(self, pchRenderModelName, unComponentIndex, pchComponentName, unComponentNameLen):
"""
Use this to get the names of available components. Index does not correlate to a tracked device index, but
is only used for iterating over all available components. If the index is out o... | [
"def",
"getComponentName",
"(",
"self",
",",
"pchRenderModelName",
",",
"unComponentIndex",
",",
"pchComponentName",
",",
"unComponentNameLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getComponentName",
"result",
"=",
"fn",
"(",
"pchRenderModelName... | Use this to get the names of available components. Index does not correlate to a tracked device index, but
is only used for iterating over all available components. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name. | [
"Use",
"this",
"to",
"get",
"the",
"names",
"of",
"available",
"components",
".",
"Index",
"does",
"not",
"correlate",
"to",
"a",
"tracked",
"device",
"index",
"but",
"is",
"only",
"used",
"for",
"iterating",
"over",
"all",
"available",
"components",
".",
... | python | train |
tornadoweb/tornado | tornado/log.py | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/log.py#L211-L256 | def enable_pretty_logging(options: Any = None, logger: logging.Logger = None) -> None:
"""Turns on formatted logging output as configured.
This is called automatically by `tornado.options.parse_command_line`
and `tornado.options.parse_config_file`.
"""
if options is None:
import tornado.opt... | [
"def",
"enable_pretty_logging",
"(",
"options",
":",
"Any",
"=",
"None",
",",
"logger",
":",
"logging",
".",
"Logger",
"=",
"None",
")",
"->",
"None",
":",
"if",
"options",
"is",
"None",
":",
"import",
"tornado",
".",
"options",
"options",
"=",
"tornado"... | Turns on formatted logging output as configured.
This is called automatically by `tornado.options.parse_command_line`
and `tornado.options.parse_config_file`. | [
"Turns",
"on",
"formatted",
"logging",
"output",
"as",
"configured",
"."
] | python | train |
chrisspen/burlap | burlap/mongodb.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/mongodb.py#L150-L155 | def shell(self, name='default', user=None, password=None, root=0, verbose=1, write_password=1, no_db=0, no_pw=0):
"""
Opens a SQL shell to the given database, assuming the configured database
and user supports this feature.
"""
raise NotImplementedError | [
"def",
"shell",
"(",
"self",
",",
"name",
"=",
"'default'",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"root",
"=",
"0",
",",
"verbose",
"=",
"1",
",",
"write_password",
"=",
"1",
",",
"no_db",
"=",
"0",
",",
"no_pw",
"=",
"0",
... | Opens a SQL shell to the given database, assuming the configured database
and user supports this feature. | [
"Opens",
"a",
"SQL",
"shell",
"to",
"the",
"given",
"database",
"assuming",
"the",
"configured",
"database",
"and",
"user",
"supports",
"this",
"feature",
"."
] | python | valid |
globocom/GloboNetworkAPI-client-python | networkapiclient/ClientFactory.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ClientFactory.py#L481-L487 | def create_dhcprelay_ipv6(self):
"""Get an instance of DHCPRelayIPv6 services facade."""
return DHCPRelayIPv6(
self.networkapi_url,
self.user,
self.password,
self.user_ldap) | [
"def",
"create_dhcprelay_ipv6",
"(",
"self",
")",
":",
"return",
"DHCPRelayIPv6",
"(",
"self",
".",
"networkapi_url",
",",
"self",
".",
"user",
",",
"self",
".",
"password",
",",
"self",
".",
"user_ldap",
")"
] | Get an instance of DHCPRelayIPv6 services facade. | [
"Get",
"an",
"instance",
"of",
"DHCPRelayIPv6",
"services",
"facade",
"."
] | python | train |
phaethon/kamene | kamene/crypto/cert.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L1797-L1832 | def remainingDays(self, now=None):
"""
Based on the value of notBefore field, returns the number of
days the certificate will still be valid. The date used for the
comparison is the current and local date, as returned by
time.localtime(), except if 'now' argument is provided ano... | [
"def",
"remainingDays",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"if",
"now",
"is",
"None",
":",
"now",
"=",
"time",
".",
"localtime",
"(",
")",
"elif",
"type",
"(",
"now",
")",
"is",
"str",
":",
"try",
":",
"if",
"'/'",
"in",
"now",
":"... | Based on the value of notBefore field, returns the number of
days the certificate will still be valid. The date used for the
comparison is the current and local date, as returned by
time.localtime(), except if 'now' argument is provided another
one. 'now' argument can be given as either... | [
"Based",
"on",
"the",
"value",
"of",
"notBefore",
"field",
"returns",
"the",
"number",
"of",
"days",
"the",
"certificate",
"will",
"still",
"be",
"valid",
".",
"The",
"date",
"used",
"for",
"the",
"comparison",
"is",
"the",
"current",
"and",
"local",
"date... | python | train |
rollbar/pyrollbar | rollbar/__init__.py | https://github.com/rollbar/pyrollbar/blob/33ef2e723a33d09dd6302f978f4a3908be95b9d2/rollbar/__init__.py#L628-L693 | def _report_exc_info(exc_info, request, extra_data, payload_data, level=None):
"""
Called by report_exc_info() wrapper
"""
if not _check_config():
return
filtered_level = _filtered_level(exc_info[1])
if level is None:
level = filtered_level
filtered_exc_info = events.on_ex... | [
"def",
"_report_exc_info",
"(",
"exc_info",
",",
"request",
",",
"extra_data",
",",
"payload_data",
",",
"level",
"=",
"None",
")",
":",
"if",
"not",
"_check_config",
"(",
")",
":",
"return",
"filtered_level",
"=",
"_filtered_level",
"(",
"exc_info",
"[",
"1... | Called by report_exc_info() wrapper | [
"Called",
"by",
"report_exc_info",
"()",
"wrapper"
] | python | test |
HazyResearch/fonduer | src/fonduer/learning/disc_models/sparse_lstm.py | https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/learning/disc_models/sparse_lstm.py#L205-L234 | def _update_settings(self, X):
"""
Update the model argument.
:param X: The input data of the model.
:type X: list of (candidate, features) pairs
"""
self.logger.info("Loading default parameters for Sparse LSTM")
config = get_config()["learning"]["SparseLSTM"]
... | [
"def",
"_update_settings",
"(",
"self",
",",
"X",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Loading default parameters for Sparse LSTM\"",
")",
"config",
"=",
"get_config",
"(",
")",
"[",
"\"learning\"",
"]",
"[",
"\"SparseLSTM\"",
"]",
"for",
"key... | Update the model argument.
:param X: The input data of the model.
:type X: list of (candidate, features) pairs | [
"Update",
"the",
"model",
"argument",
"."
] | python | train |
PolyJIT/benchbuild | benchbuild/utils/download.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/utils/download.py#L158-L192 | def with_wget(url_dict=None, target_file=None):
"""
Decorate a project class with wget-based version information.
This adds two attributes to a project class:
- A `versions` method that returns a list of available versions
for this project.
- A `repository` attribute that provides... | [
"def",
"with_wget",
"(",
"url_dict",
"=",
"None",
",",
"target_file",
"=",
"None",
")",
":",
"def",
"wget_decorator",
"(",
"cls",
")",
":",
"def",
"download_impl",
"(",
"self",
")",
":",
"\"\"\"Download the selected version from the url_dict value.\"\"\"",
"t_file",... | Decorate a project class with wget-based version information.
This adds two attributes to a project class:
- A `versions` method that returns a list of available versions
for this project.
- A `repository` attribute that provides a repository string to
download from later.
W... | [
"Decorate",
"a",
"project",
"class",
"with",
"wget",
"-",
"based",
"version",
"information",
"."
] | python | train |
graphql-python/graphql-core-next | graphql/utilities/type_from_ast.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/utilities/type_from_ast.py#L42-L63 | def type_from_ast(schema, type_node): # noqa: F811
"""Get the GraphQL type definition from an AST node.
Given a Schema and an AST node describing a type, return a GraphQLType definition
which applies to that type. For example, if provided the parsed AST node for
`[User]`, a GraphQLList instance will b... | [
"def",
"type_from_ast",
"(",
"schema",
",",
"type_node",
")",
":",
"# noqa: F811",
"if",
"isinstance",
"(",
"type_node",
",",
"ListTypeNode",
")",
":",
"inner_type",
"=",
"type_from_ast",
"(",
"schema",
",",
"type_node",
".",
"type",
")",
"return",
"GraphQLLis... | Get the GraphQL type definition from an AST node.
Given a Schema and an AST node describing a type, return a GraphQLType definition
which applies to that type. For example, if provided the parsed AST node for
`[User]`, a GraphQLList instance will be returned, containing the type called
"User" found in ... | [
"Get",
"the",
"GraphQL",
"type",
"definition",
"from",
"an",
"AST",
"node",
"."
] | python | train |
StanfordVL/robosuite | robosuite/models/base.py | https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/models/base.py#L48-L58 | def create_default_element(self, name):
"""
Creates a <@name/> tag under root if there is none.
"""
found = self.root.find(name)
if found is not None:
return found
ele = ET.Element(name)
self.root.append(ele)
return ele | [
"def",
"create_default_element",
"(",
"self",
",",
"name",
")",
":",
"found",
"=",
"self",
".",
"root",
".",
"find",
"(",
"name",
")",
"if",
"found",
"is",
"not",
"None",
":",
"return",
"found",
"ele",
"=",
"ET",
".",
"Element",
"(",
"name",
")",
"... | Creates a <@name/> tag under root if there is none. | [
"Creates",
"a",
"<"
] | python | train |
jldantas/libmft | libmft/attribute.py | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L914-L928 | def _from_binary_attrlist(cls, binary_stream):
"""See base class."""
_attr_list = []
offset = 0
while True:
entry = AttributeListEntry.create_from_binary(binary_stream[offset:])
offset += len(entry)
_attr_list.append(entry)
if offset >= len(binary_stream):
br... | [
"def",
"_from_binary_attrlist",
"(",
"cls",
",",
"binary_stream",
")",
":",
"_attr_list",
"=",
"[",
"]",
"offset",
"=",
"0",
"while",
"True",
":",
"entry",
"=",
"AttributeListEntry",
".",
"create_from_binary",
"(",
"binary_stream",
"[",
"offset",
":",
"]",
"... | See base class. | [
"See",
"base",
"class",
"."
] | python | train |
raiden-network/raiden | raiden/api/python.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L712-L718 | def get_tokens_list(self, registry_address: PaymentNetworkID):
"""Returns a list of tokens the node knows about"""
tokens_list = views.get_token_identifiers(
chain_state=views.state_from_raiden(self.raiden),
payment_network_id=registry_address,
)
return tokens_lis... | [
"def",
"get_tokens_list",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
")",
":",
"tokens_list",
"=",
"views",
".",
"get_token_identifiers",
"(",
"chain_state",
"=",
"views",
".",
"state_from_raiden",
"(",
"self",
".",
"raiden",
")",
",",
"payme... | Returns a list of tokens the node knows about | [
"Returns",
"a",
"list",
"of",
"tokens",
"the",
"node",
"knows",
"about"
] | python | train |
eonpatapon/contrail-api-cli | contrail_api_cli/resource.py | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L537-L547 | def parent(self):
"""Return parent resource
:rtype: Resource
:raises ResourceNotFound: parent resource doesn't exists
:raises ResourceMissing: parent resource is not defined
"""
try:
return Resource(self['parent_type'], uuid=self['parent_uuid'], check=True)
... | [
"def",
"parent",
"(",
"self",
")",
":",
"try",
":",
"return",
"Resource",
"(",
"self",
"[",
"'parent_type'",
"]",
",",
"uuid",
"=",
"self",
"[",
"'parent_uuid'",
"]",
",",
"check",
"=",
"True",
")",
"except",
"KeyError",
":",
"raise",
"ResourceMissing",
... | Return parent resource
:rtype: Resource
:raises ResourceNotFound: parent resource doesn't exists
:raises ResourceMissing: parent resource is not defined | [
"Return",
"parent",
"resource"
] | python | train |
kvh/ramp | ramp/model_definition.py | https://github.com/kvh/ramp/blob/8618ce673e49b95f40c9659319c3cb72281dacac/ramp/model_definition.py#L217-L243 | def model_definition_factory(base_model_definition, **kwargs):
"""
Provides an iterator over passed-in
configuration values, allowing for easy
exploration of models.
Parameters:
___________
base_model_definition:
The base `ModelDefinition` to augment
kwargs:
Can be any... | [
"def",
"model_definition_factory",
"(",
"base_model_definition",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
":",
"yield",
"config",
"else",
":",
"for",
"param",
"in",
"kwargs",
":",
"if",
"not",
"hasattr",
"(",
"base_model_definition",
",",
"p... | Provides an iterator over passed-in
configuration values, allowing for easy
exploration of models.
Parameters:
___________
base_model_definition:
The base `ModelDefinition` to augment
kwargs:
Can be any keyword accepted by `ModelDefinition`.
Values should be iterables. | [
"Provides",
"an",
"iterator",
"over",
"passed",
"-",
"in",
"configuration",
"values",
"allowing",
"for",
"easy",
"exploration",
"of",
"models",
"."
] | python | train |
ryukinix/decorating | decorating/debugging.py | https://github.com/ryukinix/decorating/blob/df78c3f87800205701704c0bc0fb9b6bb908ba7e/decorating/debugging.py#L20-L43 | def debug(function):
"""
Function: debug
Summary: decorator to debug a function
Examples: at the execution of the function wrapped,
the decorator will allows to print the
input and output of each execution
Attributes:
@param (function): function
Returns: wrapp... | [
"def",
"debug",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"key",
",",
... | Function: debug
Summary: decorator to debug a function
Examples: at the execution of the function wrapped,
the decorator will allows to print the
input and output of each execution
Attributes:
@param (function): function
Returns: wrapped function | [
"Function",
":",
"debug",
"Summary",
":",
"decorator",
"to",
"debug",
"a",
"function",
"Examples",
":",
"at",
"the",
"execution",
"of",
"the",
"function",
"wrapped",
"the",
"decorator",
"will",
"allows",
"to",
"print",
"the",
"input",
"and",
"output",
"of",
... | python | train |
tensorflow/datasets | tensorflow_datasets/core/units.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/units.py#L34-L53 | def size_str(size_in_bytes):
"""Returns a human readable size string.
If size_in_bytes is None, then returns "?? GiB".
For example `size_str(1.5 * tfds.units.GiB) == "1.50 GiB"`.
Args:
size_in_bytes: `int` or `None`, the size, in bytes, that we want to
format as a human-readable size string.
"""
... | [
"def",
"size_str",
"(",
"size_in_bytes",
")",
":",
"if",
"not",
"size_in_bytes",
":",
"return",
"\"?? GiB\"",
"size_in_bytes",
"=",
"float",
"(",
"size_in_bytes",
")",
"for",
"(",
"name",
",",
"size_bytes",
")",
"in",
"_NAME_LIST",
":",
"value",
"=",
"size_i... | Returns a human readable size string.
If size_in_bytes is None, then returns "?? GiB".
For example `size_str(1.5 * tfds.units.GiB) == "1.50 GiB"`.
Args:
size_in_bytes: `int` or `None`, the size, in bytes, that we want to
format as a human-readable size string. | [
"Returns",
"a",
"human",
"readable",
"size",
"string",
"."
] | python | train |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/subscribe/channels/channel.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/subscribe/channels/channel.py#L156-L165 | def _configure(self, manager, connect_api_instance, observer_params):
"""Configure behind-the-scenes settings for the channel
These are required in addition to the parameters provided
on instantiation
"""
self._manager = manager
self._api = connect_api_instance
s... | [
"def",
"_configure",
"(",
"self",
",",
"manager",
",",
"connect_api_instance",
",",
"observer_params",
")",
":",
"self",
".",
"_manager",
"=",
"manager",
"self",
".",
"_api",
"=",
"connect_api_instance",
"self",
".",
"_observer_params",
"=",
"self",
".",
"_obs... | Configure behind-the-scenes settings for the channel
These are required in addition to the parameters provided
on instantiation | [
"Configure",
"behind",
"-",
"the",
"-",
"scenes",
"settings",
"for",
"the",
"channel"
] | python | train |
arviz-devs/arviz | arviz/plots/forestplot.py | https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/plots/forestplot.py#L578-L585 | def y_max(self):
"""Get max y value for the variable."""
end_y = max(y for y, *_ in self.iterator())
if self.combined:
end_y += self.group_offset
return end_y + 2 * self.group_offset | [
"def",
"y_max",
"(",
"self",
")",
":",
"end_y",
"=",
"max",
"(",
"y",
"for",
"y",
",",
"*",
"_",
"in",
"self",
".",
"iterator",
"(",
")",
")",
"if",
"self",
".",
"combined",
":",
"end_y",
"+=",
"self",
".",
"group_offset",
"return",
"end_y",
"+",... | Get max y value for the variable. | [
"Get",
"max",
"y",
"value",
"for",
"the",
"variable",
"."
] | python | train |
StackStorm/pybind | pybind/slxos/v17s_1_02/overlay/access_list/type/vxlan/extended/ext_seq/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/overlay/access_list/type/vxlan/extended/ext_seq/__init__.py#L285-L306 | def _set_ext_src_vtep_ip_any(self, v, load=False):
"""
Setter method for ext_src_vtep_ip_any, mapped from YANG variable /overlay/access_list/type/vxlan/extended/ext_seq/ext_src_vtep_ip_any (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_ext_src_vtep_ip_any is con... | [
"def",
"_set_ext_src_vtep_ip_any",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",... | Setter method for ext_src_vtep_ip_any, mapped from YANG variable /overlay/access_list/type/vxlan/extended/ext_seq/ext_src_vtep_ip_any (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_ext_src_vtep_ip_any is considered as a private
method. Backends looking to populate t... | [
"Setter",
"method",
"for",
"ext_src_vtep_ip_any",
"mapped",
"from",
"YANG",
"variable",
"/",
"overlay",
"/",
"access_list",
"/",
"type",
"/",
"vxlan",
"/",
"extended",
"/",
"ext_seq",
"/",
"ext_src_vtep_ip_any",
"(",
"empty",
")",
"If",
"this",
"variable",
"is... | python | train |
PixelwarStudio/PyTree | Tree/core.py | https://github.com/PixelwarStudio/PyTree/blob/f14b25ea145da6b00d836e34251d2a4c823766dc/Tree/core.py#L217-L223 | def _get_node_parent(self, age, pos):
"""Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node.
"""
return self.nodes[age][int(pos / self.comp)] | [
"def",
"_get_node_parent",
"(",
"self",
",",
"age",
",",
"pos",
")",
":",
"return",
"self",
".",
"nodes",
"[",
"age",
"]",
"[",
"int",
"(",
"pos",
"/",
"self",
".",
"comp",
")",
"]"
] | Get the parent node of node, whch is located in tree's node list.
Returns:
object: The parent node. | [
"Get",
"the",
"parent",
"node",
"of",
"node",
"whch",
"is",
"located",
"in",
"tree",
"s",
"node",
"list",
"."
] | python | train |
RedFantom/ttkwidgets | ttkwidgets/timeline.py | https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/timeline.py#L997-L1004 | def current(self):
"""
Currently active item on the _timeline Canvas
:rtype: str
"""
results = self._timeline.find_withtag(tk.CURRENT)
return results[0] if len(results) != 0 else None | [
"def",
"current",
"(",
"self",
")",
":",
"results",
"=",
"self",
".",
"_timeline",
".",
"find_withtag",
"(",
"tk",
".",
"CURRENT",
")",
"return",
"results",
"[",
"0",
"]",
"if",
"len",
"(",
"results",
")",
"!=",
"0",
"else",
"None"
] | Currently active item on the _timeline Canvas
:rtype: str | [
"Currently",
"active",
"item",
"on",
"the",
"_timeline",
"Canvas"
] | python | train |
axltxl/m2bk | m2bk/log.py | https://github.com/axltxl/m2bk/blob/980083dfd17e6e783753a946e9aa809714551141/m2bk/log.py#L100-L109 | def msg_warn(message):
"""
Log a warning message
:param message: the message to be logged
"""
to_stdout(" (!) {message}".format(message=message),
colorf=yellow, bold=True)
if _logger:
_logger.warn(message) | [
"def",
"msg_warn",
"(",
"message",
")",
":",
"to_stdout",
"(",
"\" (!) {message}\"",
".",
"format",
"(",
"message",
"=",
"message",
")",
",",
"colorf",
"=",
"yellow",
",",
"bold",
"=",
"True",
")",
"if",
"_logger",
":",
"_logger",
".",
"warn",
"(",
"me... | Log a warning message
:param message: the message to be logged | [
"Log",
"a",
"warning",
"message"
] | python | train |
giancosta86/Iris | info/gianlucacosta/iris/io/utils.py | https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/io/utils.py#L61-L67 | def safeRmTree(rootPath):
"""
Deletes a tree and returns true if it was correctly deleted
"""
shutil.rmtree(rootPath, True)
return not os.path.exists(rootPath) | [
"def",
"safeRmTree",
"(",
"rootPath",
")",
":",
"shutil",
".",
"rmtree",
"(",
"rootPath",
",",
"True",
")",
"return",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"rootPath",
")"
] | Deletes a tree and returns true if it was correctly deleted | [
"Deletes",
"a",
"tree",
"and",
"returns",
"true",
"if",
"it",
"was",
"correctly",
"deleted"
] | python | train |
keleshev/mini | mini.py | https://github.com/keleshev/mini/blob/da7893a1ee72aca315d6921f25604316462ec019/mini.py#L59-L62 | def infix(self, node, children):
'infix = "(" expr operator expr ")"'
_, expr1, operator, expr2, _ = children
return operator(expr1, expr2) | [
"def",
"infix",
"(",
"self",
",",
"node",
",",
"children",
")",
":",
"_",
",",
"expr1",
",",
"operator",
",",
"expr2",
",",
"_",
"=",
"children",
"return",
"operator",
"(",
"expr1",
",",
"expr2",
")"
] | infix = "(" expr operator expr ")" | [
"infix",
"=",
"(",
"expr",
"operator",
"expr",
")"
] | python | train |
RPi-Distro/python-sense-hat | sense_hat/sense_hat.py | https://github.com/RPi-Distro/python-sense-hat/blob/9a37f0923ce8dbde69514c3b8d58d30de01c9ee7/sense_hat/sense_hat.py#L415-L424 | def _get_char_pixels(self, s):
"""
Internal. Safeguards the character indexed dictionary for the
show_message function below
"""
if len(s) == 1 and s in self._text_dict.keys():
return list(self._text_dict[s])
else:
return list(self._text_dict['?']... | [
"def",
"_get_char_pixels",
"(",
"self",
",",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"==",
"1",
"and",
"s",
"in",
"self",
".",
"_text_dict",
".",
"keys",
"(",
")",
":",
"return",
"list",
"(",
"self",
".",
"_text_dict",
"[",
"s",
"]",
")",
"e... | Internal. Safeguards the character indexed dictionary for the
show_message function below | [
"Internal",
".",
"Safeguards",
"the",
"character",
"indexed",
"dictionary",
"for",
"the",
"show_message",
"function",
"below"
] | python | train |
HPENetworking/topology_lib_ip | setup.py | https://github.com/HPENetworking/topology_lib_ip/blob/c69cc3db80d96575d787fdc903a9370d2df1c5ae/setup.py#L46-L57 | def find_requirements(filename):
"""
Find requirements in file.
"""
import string
content = read(filename)
requirements = []
for line in content.splitlines():
line = line.strip()
if line and line[:1] in string.ascii_letters:
requirements.append(line)
return re... | [
"def",
"find_requirements",
"(",
"filename",
")",
":",
"import",
"string",
"content",
"=",
"read",
"(",
"filename",
")",
"requirements",
"=",
"[",
"]",
"for",
"line",
"in",
"content",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"strip",
... | Find requirements in file. | [
"Find",
"requirements",
"in",
"file",
"."
] | python | train |
mrtazz/InstapaperLibrary | instapaperlib/instapaperlib.py | https://github.com/mrtazz/InstapaperLibrary/blob/bf273c02b468e523994d46def07f70902f596676/instapaperlib/instapaperlib.py#L112-L133 | def auth(self, user=None, password=None, jsonp=None):
""" authenticate with the instapaper.com service
Parameters: user -> username
password -> password
Returns: (status as int, status error message)
"""
if not user:
user = self.user
... | [
"def",
"auth",
"(",
"self",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"jsonp",
"=",
"None",
")",
":",
"if",
"not",
"user",
":",
"user",
"=",
"self",
".",
"user",
"if",
"not",
"password",
":",
"password",
"=",
"self",
".",
"pass... | authenticate with the instapaper.com service
Parameters: user -> username
password -> password
Returns: (status as int, status error message) | [
"authenticate",
"with",
"the",
"instapaper",
".",
"com",
"service"
] | python | train |
libtcod/python-tcod | tcod/libtcodpy.py | https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1477-L1491 | def console_hline(
con: tcod.console.Console,
x: int,
y: int,
l: int,
flag: int = BKGND_DEFAULT,
) -> None:
"""Draw a horizontal line on the console.
This always uses the character 196, the horizontal line character.
.. deprecated:: 8.5
Use :any:`Console.hline` instead.
"""... | [
"def",
"console_hline",
"(",
"con",
":",
"tcod",
".",
"console",
".",
"Console",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
",",
"l",
":",
"int",
",",
"flag",
":",
"int",
"=",
"BKGND_DEFAULT",
",",
")",
"->",
"None",
":",
"lib",
".",
"TCOD_conso... | Draw a horizontal line on the console.
This always uses the character 196, the horizontal line character.
.. deprecated:: 8.5
Use :any:`Console.hline` instead. | [
"Draw",
"a",
"horizontal",
"line",
"on",
"the",
"console",
"."
] | python | train |
taskcluster/taskcluster-client.py | taskcluster/auth.py | https://github.com/taskcluster/taskcluster-client.py/blob/bcc95217f8bf80bed2ae5885a19fa0035da7ebc9/taskcluster/auth.py#L330-L347 | def expandScopesGet(self, *args, **kwargs):
"""
Expand Scopes
Return an expanded copy of the given scopeset, with scopes implied by any
roles included.
This call uses the GET method with an HTTP body. It remains only for
backward compatibility.
This method tak... | [
"def",
"expandScopesGet",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_makeApiCall",
"(",
"self",
".",
"funcinfo",
"[",
"\"expandScopesGet\"",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Expand Scopes
Return an expanded copy of the given scopeset, with scopes implied by any
roles included.
This call uses the GET method with an HTTP body. It remains only for
backward compatibility.
This method takes input: ``v1/scopeset.json#``
This method gives outpu... | [
"Expand",
"Scopes"
] | python | train |
numenta/nupic | src/nupic/regions/record_sensor.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L633-L646 | def readFromProto(cls, proto):
"""
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.readFromProto`.
"""
instance = cls()
instance.encoder = MultiEncoder.read(proto.encoder)
if proto.disabledEncoder is not None:
instance.disabledEncoder = MultiEncoder.read(proto.disabledEncode... | [
"def",
"readFromProto",
"(",
"cls",
",",
"proto",
")",
":",
"instance",
"=",
"cls",
"(",
")",
"instance",
".",
"encoder",
"=",
"MultiEncoder",
".",
"read",
"(",
"proto",
".",
"encoder",
")",
"if",
"proto",
".",
"disabledEncoder",
"is",
"not",
"None",
"... | Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.readFromProto`. | [
"Overrides",
":",
"meth",
":",
"nupic",
".",
"bindings",
".",
"regions",
".",
"PyRegion",
".",
"PyRegion",
".",
"readFromProto",
"."
] | python | valid |
dcwatson/bbcode | bbcode.py | https://github.com/dcwatson/bbcode/blob/eb6f7ff140a78ddb1641102d7382479c4d7c1c78/bbcode.py#L231-L244 | def _newline_tokenize(self, data):
"""
Given a string that does not contain any tags, this function will
return a list of NEWLINE and DATA tokens such that if you concatenate
their data, you will have the original string.
"""
parts = data.split('\n')
tokens = []
... | [
"def",
"_newline_tokenize",
"(",
"self",
",",
"data",
")",
":",
"parts",
"=",
"data",
".",
"split",
"(",
"'\\n'",
")",
"tokens",
"=",
"[",
"]",
"for",
"num",
",",
"part",
"in",
"enumerate",
"(",
"parts",
")",
":",
"if",
"part",
":",
"tokens",
".",
... | Given a string that does not contain any tags, this function will
return a list of NEWLINE and DATA tokens such that if you concatenate
their data, you will have the original string. | [
"Given",
"a",
"string",
"that",
"does",
"not",
"contain",
"any",
"tags",
"this",
"function",
"will",
"return",
"a",
"list",
"of",
"NEWLINE",
"and",
"DATA",
"tokens",
"such",
"that",
"if",
"you",
"concatenate",
"their",
"data",
"you",
"will",
"have",
"the",... | python | train |
volafiled/python-volapi | volapi/handler.py | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L151-L177 | def _handle_files(self, data):
"""Handle new files being uploaded"""
initial = data.get("set", False)
files = data["files"]
for f in files:
try:
fobj = File(
self.room,
self.conn,
f[0],
... | [
"def",
"_handle_files",
"(",
"self",
",",
"data",
")",
":",
"initial",
"=",
"data",
".",
"get",
"(",
"\"set\"",
",",
"False",
")",
"files",
"=",
"data",
"[",
"\"files\"",
"]",
"for",
"f",
"in",
"files",
":",
"try",
":",
"fobj",
"=",
"File",
"(",
... | Handle new files being uploaded | [
"Handle",
"new",
"files",
"being",
"uploaded"
] | python | train |
aouyar/healthgraph-api | samples/bottle/runkeeper_demo.py | https://github.com/aouyar/healthgraph-api/blob/fc5135ab353ca1f05e8a70ec784ff921e686c072/samples/bottle/runkeeper_demo.py#L121-L145 | def parse_cmdline(argv=None):
"""Parse command line options.
@param argv: List of command line arguments. If None, get list from system.
@return: Tuple of Option List and Argument List.
"""
parser = optparse.OptionParser()
parser.add_option('-c', '--conf', help='Configuration file ... | [
"def",
"parse_cmdline",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
")",
"parser",
".",
"add_option",
"(",
"'-c'",
",",
"'--conf'",
",",
"help",
"=",
"'Configuration file path.'",
",",
"dest",
"=",
"'confpath'",
... | Parse command line options.
@param argv: List of command line arguments. If None, get list from system.
@return: Tuple of Option List and Argument List. | [
"Parse",
"command",
"line",
"options",
"."
] | python | train |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/validators.py | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/validators.py#L97-L101 | def validate_owner_repo_package(ctx, param, value):
"""Ensure that owner/repo/package is formatted correctly."""
# pylint: disable=unused-argument
form = "OWNER/REPO/PACKAGE"
return validate_slashes(param, value, minimum=3, maximum=3, form=form) | [
"def",
"validate_owner_repo_package",
"(",
"ctx",
",",
"param",
",",
"value",
")",
":",
"# pylint: disable=unused-argument",
"form",
"=",
"\"OWNER/REPO/PACKAGE\"",
"return",
"validate_slashes",
"(",
"param",
",",
"value",
",",
"minimum",
"=",
"3",
",",
"maximum",
... | Ensure that owner/repo/package is formatted correctly. | [
"Ensure",
"that",
"owner",
"/",
"repo",
"/",
"package",
"is",
"formatted",
"correctly",
"."
] | python | train |
gmr/tinman | tinman/application.py | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/application.py#L88-L100 | def _import_class(self, class_path):
"""Try and import the specified namespaced class.
:param str class_path: The full path to the class (foo.bar.Baz)
:rtype: class
"""
LOGGER.debug('Importing %s', class_path)
try:
return utils.import_namespaced_class(class_... | [
"def",
"_import_class",
"(",
"self",
",",
"class_path",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'Importing %s'",
",",
"class_path",
")",
"try",
":",
"return",
"utils",
".",
"import_namespaced_class",
"(",
"class_path",
")",
"except",
"ImportError",
"as",
"erro... | Try and import the specified namespaced class.
:param str class_path: The full path to the class (foo.bar.Baz)
:rtype: class | [
"Try",
"and",
"import",
"the",
"specified",
"namespaced",
"class",
"."
] | python | train |
zhanglab/psamm | psamm/lpsolver/glpk.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/lpsolver/glpk.py#L114-L178 | def define(self, *names, **kwargs):
"""Define a variable in the problem.
Variables must be defined before they can be accessed by var() or
set(). This function takes keyword arguments lower and upper to define
the bounds of the variable (default: -inf to inf). The keyword argument
... | [
"def",
"define",
"(",
"self",
",",
"*",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"names",
"=",
"tuple",
"(",
"names",
")",
"for",
"name",
"in",
"names",
":",
"if",
"name",
"in",
"self",
".",
"_variables",
":",
"raise",
"ValueError",
"(",
"'Varia... | Define a variable in the problem.
Variables must be defined before they can be accessed by var() or
set(). This function takes keyword arguments lower and upper to define
the bounds of the variable (default: -inf to inf). The keyword argument
types can be used to select the type of the ... | [
"Define",
"a",
"variable",
"in",
"the",
"problem",
"."
] | python | train |
minio/minio-py | minio/compat.py | https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/compat.py#L96-L105 | def urlencode(resource):
"""
This implementation of urlencode supports all unicode characters
:param: resource: Resource value to be url encoded.
"""
if isinstance(resource, str):
return _urlencode(resource.encode('utf-8'))
return _urlencode(resource) | [
"def",
"urlencode",
"(",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"str",
")",
":",
"return",
"_urlencode",
"(",
"resource",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"return",
"_urlencode",
"(",
"resource",
")"
] | This implementation of urlencode supports all unicode characters
:param: resource: Resource value to be url encoded. | [
"This",
"implementation",
"of",
"urlencode",
"supports",
"all",
"unicode",
"characters"
] | python | train |
project-rig/rig | rig/utils/contexts.py | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/utils/contexts.py#L91-L175 | def use_contextual_arguments(**kw_only_args_defaults):
"""Decorator function which allows the wrapped function to accept
arguments not specified in the call from the context.
Arguments whose default value is set to the Required sentinel must be
supplied either by the context or the call... | [
"def",
"use_contextual_arguments",
"(",
"*",
"*",
"kw_only_args_defaults",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"# Extract any positional and positional-and-key-word arguments",
"# which may be set.",
"arg_names",
",",
"varargs",
",",
"keywords",
",",
"defaul... | Decorator function which allows the wrapped function to accept
arguments not specified in the call from the context.
Arguments whose default value is set to the Required sentinel must be
supplied either by the context or the caller and a TypeError is raised
if not.
.. warning::... | [
"Decorator",
"function",
"which",
"allows",
"the",
"wrapped",
"function",
"to",
"accept",
"arguments",
"not",
"specified",
"in",
"the",
"call",
"from",
"the",
"context",
"."
] | python | train |
has2k1/plydata | plydata/utils.py | https://github.com/has2k1/plydata/blob/d8ca85ff70eee621e96f7c74034e90fec16e8b61/plydata/utils.py#L147-L212 | def regular_index(*dfs):
"""
Change & restore the indices of dataframes
Dataframe with duplicate values can be hard to work with.
When split and recombined, you cannot restore the row order.
This can be the case even if the index has unique but
irregular/unordered. This contextmanager resets th... | [
"def",
"regular_index",
"(",
"*",
"dfs",
")",
":",
"original_index",
"=",
"[",
"df",
".",
"index",
"for",
"df",
"in",
"dfs",
"]",
"have_bad_index",
"=",
"[",
"not",
"isinstance",
"(",
"df",
".",
"index",
",",
"pd",
".",
"RangeIndex",
")",
"for",
"df"... | Change & restore the indices of dataframes
Dataframe with duplicate values can be hard to work with.
When split and recombined, you cannot restore the row order.
This can be the case even if the index has unique but
irregular/unordered. This contextmanager resets the unordered
indices of any datafr... | [
"Change",
"&",
"restore",
"the",
"indices",
"of",
"dataframes"
] | python | train |
psphere-project/psphere | psphere/client.py | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/client.py#L552-L588 | def find_entity_views(self, view_type, begin_entity=None, properties=None):
"""Find all ManagedEntity's of the requested type.
:param view_type: The type of ManagedEntity's to find.
:type view_type: str
:param begin_entity: The MOR to start searching for the entity. \
The defaul... | [
"def",
"find_entity_views",
"(",
"self",
",",
"view_type",
",",
"begin_entity",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"[",
"]",
"# Start the search at the root folder if no begin_entity was g... | Find all ManagedEntity's of the requested type.
:param view_type: The type of ManagedEntity's to find.
:type view_type: str
:param begin_entity: The MOR to start searching for the entity. \
The default is to start the search at the root folder.
:type begin_entity: ManagedObjectR... | [
"Find",
"all",
"ManagedEntity",
"s",
"of",
"the",
"requested",
"type",
"."
] | python | train |
quantmind/pulsar | pulsar/apps/socket/__init__.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/socket/__init__.py#L256-L273 | async def monitor_start(self, monitor):
'''Create the socket listening to the ``bind`` address.
If the platform does not support multiprocessing sockets set the
number of workers to 0.
'''
cfg = self.cfg
if (not platform.has_multiprocessing_socket or
cfg.... | [
"async",
"def",
"monitor_start",
"(",
"self",
",",
"monitor",
")",
":",
"cfg",
"=",
"self",
".",
"cfg",
"if",
"(",
"not",
"platform",
".",
"has_multiprocessing_socket",
"or",
"cfg",
".",
"concurrency",
"==",
"'thread'",
")",
":",
"cfg",
".",
"set",
"(",
... | Create the socket listening to the ``bind`` address.
If the platform does not support multiprocessing sockets set the
number of workers to 0. | [
"Create",
"the",
"socket",
"listening",
"to",
"the",
"bind",
"address",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/interface_vlan/interface/vlan/ipv6/mldVlan/snooping/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/interface_vlan/interface/vlan/ipv6/mldVlan/snooping/__init__.py#L263-L284 | def _set_mrouter(self, v, load=False):
"""
Setter method for mrouter, mapped from YANG variable /interface_vlan/interface/vlan/ipv6/mldVlan/snooping/mrouter (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_mrouter is considered as a private
method. Backend... | [
"def",
"_set_mrouter",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",... | Setter method for mrouter, mapped from YANG variable /interface_vlan/interface/vlan/ipv6/mldVlan/snooping/mrouter (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_mrouter is considered as a private
method. Backends looking to populate this variable should
do s... | [
"Setter",
"method",
"for",
"mrouter",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface_vlan",
"/",
"interface",
"/",
"vlan",
"/",
"ipv6",
"/",
"mldVlan",
"/",
"snooping",
"/",
"mrouter",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"... | python | train |
dmbee/seglearn | seglearn/pipe.py | https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L143-L171 | def transform(self, X, y=None):
"""
Apply transforms, and transform with the final estimator
This also works where final estimator is ``None``: all prior
transformations are applied.
Parameters
----------
X : iterable
Data to transform. Must fulfill i... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"Xt",
",",
"yt",
",",
"_",
"=",
"self",
".",
"_transform",
"(",
"X",
",",
"y",
")",
"if",
"isinstance",
"(",
"self",
".",
"_final_estimator",
",",
"XyTransformerMixin",
")"... | Apply transforms, and transform with the final estimator
This also works where final estimator is ``None``: all prior
transformations are applied.
Parameters
----------
X : iterable
Data to transform. Must fulfill input requirements of first step
of the p... | [
"Apply",
"transforms",
"and",
"transform",
"with",
"the",
"final",
"estimator",
"This",
"also",
"works",
"where",
"final",
"estimator",
"is",
"None",
":",
"all",
"prior",
"transformations",
"are",
"applied",
"."
] | python | train |
gtaylor/django-athumb | athumb/backends/s3boto.py | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/backends/s3boto.py#L112-L126 | def _get_host(self, region):
"""
Returns correctly formatted host. Accepted formats:
* simple region name, eg 'us-west-1' (see list in AWS_REGIONS)
* full host name, eg 's3-us-west-1.amazonaws.com'.
"""
if 'us-east-1' in region:
return 's3.amazonaws.c... | [
"def",
"_get_host",
"(",
"self",
",",
"region",
")",
":",
"if",
"'us-east-1'",
"in",
"region",
":",
"return",
"'s3.amazonaws.com'",
"elif",
"region",
"in",
"AWS_REGIONS",
":",
"return",
"'s3-%s.amazonaws.com'",
"%",
"region",
"elif",
"region",
"and",
"not",
"R... | Returns correctly formatted host. Accepted formats:
* simple region name, eg 'us-west-1' (see list in AWS_REGIONS)
* full host name, eg 's3-us-west-1.amazonaws.com'. | [
"Returns",
"correctly",
"formatted",
"host",
".",
"Accepted",
"formats",
":"
] | python | train |
signetlabdei/sem | sem/manager.py | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L57-L136 | def new(cls, ns_path, script, campaign_dir, runner_type='Auto',
overwrite=False, optimized=True, check_repo=True):
"""
Create a new campaign from an ns-3 installation and a campaign
directory.
This method will create a DatabaseManager, which will install a
database i... | [
"def",
"new",
"(",
"cls",
",",
"ns_path",
",",
"script",
",",
"campaign_dir",
",",
"runner_type",
"=",
"'Auto'",
",",
"overwrite",
"=",
"False",
",",
"optimized",
"=",
"True",
",",
"check_repo",
"=",
"True",
")",
":",
"# Convert paths to be absolute",
"ns_pa... | Create a new campaign from an ns-3 installation and a campaign
directory.
This method will create a DatabaseManager, which will install a
database in the specified campaign_dir. If a database is already
available at the ns_path described in the specified campaign_dir and
its con... | [
"Create",
"a",
"new",
"campaign",
"from",
"an",
"ns",
"-",
"3",
"installation",
"and",
"a",
"campaign",
"directory",
"."
] | python | train |
boriel/zxbasic | arch/zx48k/backend/__8bit.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__8bit.py#L490-L502 | def _ltu8(ins):
""" Compares & pops top 2 operands out of the stack, and checks
if the 1st operand < 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit unsigned version
"""
output = _8bit_oper(ins.quad[2], ins.quad[3])
output.append('cp h')
output.append('sb... | [
"def",
"_ltu8",
"(",
"ins",
")",
":",
"output",
"=",
"_8bit_oper",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
",",
"ins",
".",
"quad",
"[",
"3",
"]",
")",
"output",
".",
"append",
"(",
"'cp h'",
")",
"output",
".",
"append",
"(",
"'sbc a, a'",
")",
... | Compares & pops top 2 operands out of the stack, and checks
if the 1st operand < 2nd operand (top of the stack).
Pushes 0 if False, 1 if True.
8 bit unsigned version | [
"Compares",
"&",
"pops",
"top",
"2",
"operands",
"out",
"of",
"the",
"stack",
"and",
"checks",
"if",
"the",
"1st",
"operand",
"<",
"2nd",
"operand",
"(",
"top",
"of",
"the",
"stack",
")",
".",
"Pushes",
"0",
"if",
"False",
"1",
"if",
"True",
"."
] | python | train |
saltstack/salt | salt/grains/zfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/zfs.py#L76-L86 | def zfs():
'''
Provide grains for zfs/zpool
'''
grains = {}
grains['zfs_support'] = __utils__['zfs.is_supported']()
grains['zfs_feature_flags'] = __utils__['zfs.has_feature_flags']()
if grains['zfs_support']:
grains = salt.utils.dictupdate.update(grains, _zfs_pool_data(), merge_lists... | [
"def",
"zfs",
"(",
")",
":",
"grains",
"=",
"{",
"}",
"grains",
"[",
"'zfs_support'",
"]",
"=",
"__utils__",
"[",
"'zfs.is_supported'",
"]",
"(",
")",
"grains",
"[",
"'zfs_feature_flags'",
"]",
"=",
"__utils__",
"[",
"'zfs.has_feature_flags'",
"]",
"(",
")... | Provide grains for zfs/zpool | [
"Provide",
"grains",
"for",
"zfs",
"/",
"zpool"
] | python | train |
equinor/segyio | python/segyio/tools.py | https://github.com/equinor/segyio/blob/58fd449947ccd330b9af0699d6b8710550d34e8e/python/segyio/tools.py#L411-L516 | def from_array(filename, data, iline=189,
xline=193,
format=SegySampleFormat.IBM_FLOAT_4_BYTE,
dt=4000,
delrt=0):
""" Create a new SEGY file from an n-dimentional array. Create a structured
... | [
"def",
"from_array",
"(",
"filename",
",",
"data",
",",
"iline",
"=",
"189",
",",
"xline",
"=",
"193",
",",
"format",
"=",
"SegySampleFormat",
".",
"IBM_FLOAT_4_BYTE",
",",
"dt",
"=",
"4000",
",",
"delrt",
"=",
"0",
")",
":",
"dt",
"=",
"int",
"(",
... | Create a new SEGY file from an n-dimentional array. Create a structured
SEGY file with defaulted headers from a 2-, 3- or 4-dimensional array.
ilines, xlines, offsets and samples are inferred from the size of the
array. Please refer to the documentation for functions from_array2D,
from_array3D and from_... | [
"Create",
"a",
"new",
"SEGY",
"file",
"from",
"an",
"n",
"-",
"dimentional",
"array",
".",
"Create",
"a",
"structured",
"SEGY",
"file",
"with",
"defaulted",
"headers",
"from",
"a",
"2",
"-",
"3",
"-",
"or",
"4",
"-",
"dimensional",
"array",
".",
"iline... | python | train |
20c/twentyc.database | twentyc/database/couchbase/client.py | https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/couchbase/client.py#L130-L149 | def set(self, key, data, retry=0):
"""
Store data <data> index by key <key>
Args
key <string> couchbase document id
data <dict> data to store
"""
try:
if type(data) != dict:
raise Exception("data needs to be of type <dict>")
self.bucket.set(key, 0, 0, json.d... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"data",
",",
"retry",
"=",
"0",
")",
":",
"try",
":",
"if",
"type",
"(",
"data",
")",
"!=",
"dict",
":",
"raise",
"Exception",
"(",
"\"data needs to be of type <dict>\"",
")",
"self",
".",
"bucket",
".",
"s... | Store data <data> index by key <key>
Args
key <string> couchbase document id
data <dict> data to store | [
"Store",
"data",
"<data",
">",
"index",
"by",
"key",
"<key",
">"
] | python | train |
westurner/pyrpo | pyrpo/pyrpo.py | https://github.com/westurner/pyrpo/blob/2a910af055dc405b761571a52ef87842397ddadf/pyrpo/pyrpo.py#L191-L224 | def sh(cmd, ignore_error=False, cwd=None, shell=False, **kwargs):
"""
Execute a command with subprocess.Popen and block until output
Args:
cmd (tuple or str): same as subprocess.Popen args
Keyword Arguments:
ignore_error (bool): if False, raise an Exception if p.returncode is
... | [
"def",
"sh",
"(",
"cmd",
",",
"ignore_error",
"=",
"False",
",",
"cwd",
"=",
"None",
",",
"shell",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'shell'",
":",
"shell",
",",
"'cwd'",
":",
"cwd",
",",
"'stder... | Execute a command with subprocess.Popen and block until output
Args:
cmd (tuple or str): same as subprocess.Popen args
Keyword Arguments:
ignore_error (bool): if False, raise an Exception if p.returncode is
not 0
cwd (str): current working directory path to run cmd with
... | [
"Execute",
"a",
"command",
"with",
"subprocess",
".",
"Popen",
"and",
"block",
"until",
"output"
] | python | train |
numenta/htmresearch | htmresearch/support/sp_paper_utils.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/support/sp_paper_utils.py#L123-L138 | def plotReceptiveFields(sp, nDim1=8, nDim2=8):
"""
Plot 2D receptive fields for 16 randomly selected columns
:param sp:
:return:
"""
columnNumber = np.product(sp.getColumnDimensions())
fig, ax = plt.subplots(nrows=4, ncols=4)
for rowI in range(4):
for colI in range(4):
col = np.random.randint(... | [
"def",
"plotReceptiveFields",
"(",
"sp",
",",
"nDim1",
"=",
"8",
",",
"nDim2",
"=",
"8",
")",
":",
"columnNumber",
"=",
"np",
".",
"product",
"(",
"sp",
".",
"getColumnDimensions",
"(",
")",
")",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
... | Plot 2D receptive fields for 16 randomly selected columns
:param sp:
:return: | [
"Plot",
"2D",
"receptive",
"fields",
"for",
"16",
"randomly",
"selected",
"columns",
":",
"param",
"sp",
":",
":",
"return",
":"
] | python | train |
ynop/audiomate | audiomate/containers/audio.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/containers/audio.py#L79-L116 | def append(self, key, samples, sampling_rate):
"""
Append the given samples to the data that already exists
in the container for the given key.
Args:
key (str): A key to store the data for.
samples (numpy.ndarray): 1-D array of audio samples (int-16).
... | [
"def",
"append",
"(",
"self",
",",
"key",
",",
"samples",
",",
"sampling_rate",
")",
":",
"if",
"not",
"np",
".",
"issubdtype",
"(",
"samples",
".",
"dtype",
",",
"np",
".",
"floating",
")",
":",
"raise",
"ValueError",
"(",
"'Samples are required as np.flo... | Append the given samples to the data that already exists
in the container for the given key.
Args:
key (str): A key to store the data for.
samples (numpy.ndarray): 1-D array of audio samples (int-16).
sampling_rate (int): The sampling-rate of the audio samples.
... | [
"Append",
"the",
"given",
"samples",
"to",
"the",
"data",
"that",
"already",
"exists",
"in",
"the",
"container",
"for",
"the",
"given",
"key",
"."
] | python | train |
rbarrois/xworkflows | src/xworkflows/base.py | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L165-L181 | def _setup_states(state_definitions, prev=()):
"""Create a StateList object from a 'states' Workflow attribute."""
states = list(prev)
for state_def in state_definitions:
if len(state_def) != 2:
raise TypeError(
"The 'state' attribute of a workflow should be "
... | [
"def",
"_setup_states",
"(",
"state_definitions",
",",
"prev",
"=",
"(",
")",
")",
":",
"states",
"=",
"list",
"(",
"prev",
")",
"for",
"state_def",
"in",
"state_definitions",
":",
"if",
"len",
"(",
"state_def",
")",
"!=",
"2",
":",
"raise",
"TypeError",... | Create a StateList object from a 'states' Workflow attribute. | [
"Create",
"a",
"StateList",
"object",
"from",
"a",
"states",
"Workflow",
"attribute",
"."
] | python | train |
openpaperwork/paperwork-backend | paperwork_backend/__init__.py | https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/__init__.py#L12-L47 | def init_flatpak():
"""
If we are in Flatpak, we must build a tessdata/ directory using the
.traineddata files from each locale directory
"""
tessdata_files = glob.glob("/app/share/locale/*/*.traineddata")
if len(tessdata_files) <= 0:
return os.path.exists("/app")
localdir = os.path... | [
"def",
"init_flatpak",
"(",
")",
":",
"tessdata_files",
"=",
"glob",
".",
"glob",
"(",
"\"/app/share/locale/*/*.traineddata\"",
")",
"if",
"len",
"(",
"tessdata_files",
")",
"<=",
"0",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"\"/app\"",
")",
... | If we are in Flatpak, we must build a tessdata/ directory using the
.traineddata files from each locale directory | [
"If",
"we",
"are",
"in",
"Flatpak",
"we",
"must",
"build",
"a",
"tessdata",
"/",
"directory",
"using",
"the",
".",
"traineddata",
"files",
"from",
"each",
"locale",
"directory"
] | python | train |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L1473-L1479 | def createFileParserCtxt(filename):
"""Create a parser context for a file content. Automatic
support for ZLIB/Compress compressed document is provided
by default if found at compile-time. """
ret = libxml2mod.xmlCreateFileParserCtxt(filename)
if ret is None:raise parserError('xmlCreateFileParse... | [
"def",
"createFileParserCtxt",
"(",
"filename",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlCreateFileParserCtxt",
"(",
"filename",
")",
"if",
"ret",
"is",
"None",
":",
"raise",
"parserError",
"(",
"'xmlCreateFileParserCtxt() failed'",
")",
"return",
"parserCtxt",
... | Create a parser context for a file content. Automatic
support for ZLIB/Compress compressed document is provided
by default if found at compile-time. | [
"Create",
"a",
"parser",
"context",
"for",
"a",
"file",
"content",
".",
"Automatic",
"support",
"for",
"ZLIB",
"/",
"Compress",
"compressed",
"document",
"is",
"provided",
"by",
"default",
"if",
"found",
"at",
"compile",
"-",
"time",
"."
] | python | train |
VJftw/invoke-tools | idflow/flow.py | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L95-L104 | def get_branch_container_tag(self):
"""
Returns the branch container tag
"""
if self.__prefix:
return "{0}-{1}".format(
self.__prefix,
self.__branch)
else:
return "{0}".format(self.__branch) | [
"def",
"get_branch_container_tag",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}-{1}\"",
".",
"format",
"(",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
")",
"else",
":",
"return",
"\"{0}\"",
".",
"format",
"(",
"... | Returns the branch container tag | [
"Returns",
"the",
"branch",
"container",
"tag"
] | python | train |
geertj/gruvi | lib/gruvi/fibers.py | https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/fibers.py#L150-L162 | def spawn(func, *args, **kwargs):
"""Spawn a new fiber.
A new :class:`Fiber` is created with main function *func* and positional
arguments *args*. The keyword arguments are passed to the :class:`Fiber`
constructor, not to the main function. The fiber is then scheduled to start
by calling its :meth:... | [
"def",
"spawn",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fiber",
"=",
"Fiber",
"(",
"func",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
"fiber",
".",
"start",
"(",
")",
"return",
"fiber"
] | Spawn a new fiber.
A new :class:`Fiber` is created with main function *func* and positional
arguments *args*. The keyword arguments are passed to the :class:`Fiber`
constructor, not to the main function. The fiber is then scheduled to start
by calling its :meth:`~Fiber.start` method.
The fiber ins... | [
"Spawn",
"a",
"new",
"fiber",
"."
] | python | train |
saltstack/salt | salt/fileserver/__init__.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/__init__.py#L440-L466 | def lock(self, back=None, remote=None):
'''
``remote`` can either be a dictionary containing repo configuration
information, or a pattern. If the latter, then remotes for which the URL
matches the pattern will be locked.
'''
back = self.backends(back)
locked = []
... | [
"def",
"lock",
"(",
"self",
",",
"back",
"=",
"None",
",",
"remote",
"=",
"None",
")",
":",
"back",
"=",
"self",
".",
"backends",
"(",
"back",
")",
"locked",
"=",
"[",
"]",
"errors",
"=",
"[",
"]",
"for",
"fsb",
"in",
"back",
":",
"fstr",
"=",
... | ``remote`` can either be a dictionary containing repo configuration
information, or a pattern. If the latter, then remotes for which the URL
matches the pattern will be locked. | [
"remote",
"can",
"either",
"be",
"a",
"dictionary",
"containing",
"repo",
"configuration",
"information",
"or",
"a",
"pattern",
".",
"If",
"the",
"latter",
"then",
"remotes",
"for",
"which",
"the",
"URL",
"matches",
"the",
"pattern",
"will",
"be",
"locked",
... | python | train |
DataDog/integrations-core | hdfs_namenode/datadog_checks/hdfs_namenode/hdfs_namenode.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/hdfs_namenode/datadog_checks/hdfs_namenode/hdfs_namenode.py#L107-L129 | def _hdfs_namenode_metrics(self, beans, metrics, tags):
"""
Get HDFS namenode metrics from JMX
"""
bean = next(iter(beans))
bean_name = bean.get('name')
if bean_name != bean_name:
raise Exception("Unexpected bean name {}".format(bean_name))
for metri... | [
"def",
"_hdfs_namenode_metrics",
"(",
"self",
",",
"beans",
",",
"metrics",
",",
"tags",
")",
":",
"bean",
"=",
"next",
"(",
"iter",
"(",
"beans",
")",
")",
"bean_name",
"=",
"bean",
".",
"get",
"(",
"'name'",
")",
"if",
"bean_name",
"!=",
"bean_name",... | Get HDFS namenode metrics from JMX | [
"Get",
"HDFS",
"namenode",
"metrics",
"from",
"JMX"
] | python | train |
evocell/rabifier | rabifier/utils.py | https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/utils.py#L62-L73 | def get(self, name):
""" Looks for a name in the path.
:param name: file name
:return: path to the file
"""
for d in self.paths:
if os.path.exists(d) and name in os.listdir(d):
return os.path.join(d, name)
logger.debug('File not found {}'.for... | [
"def",
"get",
"(",
"self",
",",
"name",
")",
":",
"for",
"d",
"in",
"self",
".",
"paths",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"d",
")",
"and",
"name",
"in",
"os",
".",
"listdir",
"(",
"d",
")",
":",
"return",
"os",
".",
"path",
... | Looks for a name in the path.
:param name: file name
:return: path to the file | [
"Looks",
"for",
"a",
"name",
"in",
"the",
"path",
"."
] | python | train |
google/dotty | efilter/protocol.py | https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/protocol.py#L81-L90 | def isa(cls, protocol):
"""Does the type 'cls' participate in the 'protocol'?"""
if not isinstance(cls, type):
raise TypeError("First argument to isa must be a type. Got %s." %
repr(cls))
if not isinstance(protocol, type):
raise TypeError(("Second argument to isa mus... | [
"def",
"isa",
"(",
"cls",
",",
"protocol",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
",",
"type",
")",
":",
"raise",
"TypeError",
"(",
"\"First argument to isa must be a type. Got %s.\"",
"%",
"repr",
"(",
"cls",
")",
")",
"if",
"not",
"isinstance",
... | Does the type 'cls' participate in the 'protocol'? | [
"Does",
"the",
"type",
"cls",
"participate",
"in",
"the",
"protocol",
"?"
] | python | train |
Locu/chronology | pykronos/pykronos/client.py | https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/pykronos/pykronos/client.py#L266-L294 | def delete(self, stream, start_time, end_time, start_id=None, namespace=None):
"""
Delete events in the stream with name `stream` that occurred between
`start_time` and `end_time` (both inclusive). An optional `start_id` allows
the client to delete events starting from after an ID rather than starting
... | [
"def",
"delete",
"(",
"self",
",",
"stream",
",",
"start_time",
",",
"end_time",
",",
"start_id",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"start_time",
",",
"types",
".",
"StringTypes",
")",
":",
"start_time",
"=",
... | Delete events in the stream with name `stream` that occurred between
`start_time` and `end_time` (both inclusive). An optional `start_id` allows
the client to delete events starting from after an ID rather than starting
at a timestamp. | [
"Delete",
"events",
"in",
"the",
"stream",
"with",
"name",
"stream",
"that",
"occurred",
"between",
"start_time",
"and",
"end_time",
"(",
"both",
"inclusive",
")",
".",
"An",
"optional",
"start_id",
"allows",
"the",
"client",
"to",
"delete",
"events",
"startin... | python | train |
foremast/foremast | src/foremast/awslambda/awslambda.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/awslambda/awslambda.py#L153-L162 | def update_alias(self):
"""Update lambda alias to point to $LATEST."""
LOG.info('Updating alias %s to point to $LATEST', self.env)
try:
self.lambda_client.update_alias(FunctionName=self.app_name, Name=self.env, FunctionVersion='$LATEST')
except boto3.exceptions.botocore.exce... | [
"def",
"update_alias",
"(",
"self",
")",
":",
"LOG",
".",
"info",
"(",
"'Updating alias %s to point to $LATEST'",
",",
"self",
".",
"env",
")",
"try",
":",
"self",
".",
"lambda_client",
".",
"update_alias",
"(",
"FunctionName",
"=",
"self",
".",
"app_name",
... | Update lambda alias to point to $LATEST. | [
"Update",
"lambda",
"alias",
"to",
"point",
"to",
"$LATEST",
"."
] | python | train |
andreikop/qutepart | qutepart/brackethlighter.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/brackethlighter.py#L115-L130 | def _highlightBracket(self, bracket, qpart, block, columnIndex):
"""Highlight bracket and matching bracket
Return tuple of QTextEdit.ExtraSelection's
"""
try:
matchedBlock, matchedColumnIndex = self._findMatchingBracket(bracket, qpart, block, columnIndex)
except _Time... | [
"def",
"_highlightBracket",
"(",
"self",
",",
"bracket",
",",
"qpart",
",",
"block",
",",
"columnIndex",
")",
":",
"try",
":",
"matchedBlock",
",",
"matchedColumnIndex",
"=",
"self",
".",
"_findMatchingBracket",
"(",
"bracket",
",",
"qpart",
",",
"block",
",... | Highlight bracket and matching bracket
Return tuple of QTextEdit.ExtraSelection's | [
"Highlight",
"bracket",
"and",
"matching",
"bracket",
"Return",
"tuple",
"of",
"QTextEdit",
".",
"ExtraSelection",
"s"
] | python | train |
saltstack/salt | salt/netapi/rest_cherrypy/app.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_cherrypy/app.py#L2643-L2739 | def POST(self, *args, **kwargs):
'''
Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
... | [
"def",
"POST",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tag",
"=",
"'/'",
".",
"join",
"(",
"itertools",
".",
"chain",
"(",
"self",
".",
"tag_base",
",",
"args",
")",
")",
"data",
"=",
"cherrypy",
".",
"serving",
".",
... | Fire an event in Salt with a custom event tag and data
.. http:post:: /hook
:status 200: |200|
:status 401: |401|
:status 406: |406|
:status 413: request body is too large
**Example request:**
.. code-block:: bash
curl -sS localhos... | [
"Fire",
"an",
"event",
"in",
"Salt",
"with",
"a",
"custom",
"event",
"tag",
"and",
"data"
] | python | train |
bcbio/bcbio-nextgen | bcbio/cwl/cwlutils.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/cwlutils.py#L197-L225 | def assign_complex_to_samples(items):
"""Assign complex inputs like variants and align outputs to samples.
Handles list inputs to record conversion where we have inputs from multiple
locations and need to ensure they are properly assigned to samples in many
environments.
The unpleasant approach he... | [
"def",
"assign_complex_to_samples",
"(",
"items",
")",
":",
"extract_fns",
"=",
"{",
"(",
"\"variants\"",
",",
"\"samples\"",
")",
":",
"_get_vcf_samples",
",",
"(",
"\"align_bam\"",
",",
")",
":",
"_get_bam_samples",
"}",
"complex",
"=",
"{",
"k",
":",
"{",... | Assign complex inputs like variants and align outputs to samples.
Handles list inputs to record conversion where we have inputs from multiple
locations and need to ensure they are properly assigned to samples in many
environments.
The unpleasant approach here is to use standard file naming to match
... | [
"Assign",
"complex",
"inputs",
"like",
"variants",
"and",
"align",
"outputs",
"to",
"samples",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/urllib3/connectionpool.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/connectionpool.py#L799-L805 | def _prepare_proxy(self, conn):
"""
Establish tunnel connection early, because otherwise httplib
would improperly set Host: header to proxy's IP:port.
"""
conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
conn.connect() | [
"def",
"_prepare_proxy",
"(",
"self",
",",
"conn",
")",
":",
"conn",
".",
"set_tunnel",
"(",
"self",
".",
"_proxy_host",
",",
"self",
".",
"port",
",",
"self",
".",
"proxy_headers",
")",
"conn",
".",
"connect",
"(",
")"
] | Establish tunnel connection early, because otherwise httplib
would improperly set Host: header to proxy's IP:port. | [
"Establish",
"tunnel",
"connection",
"early",
"because",
"otherwise",
"httplib",
"would",
"improperly",
"set",
"Host",
":",
"header",
"to",
"proxy",
"s",
"IP",
":",
"port",
"."
] | python | train |
pgjones/quart | quart/blueprints.py | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/blueprints.py#L377-L394 | def before_app_first_request(self, func: Callable) -> Callable:
"""Add a before request first function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.before_first_request`. It is
triggered before the first request to the app thi... | [
"def",
"before_app_first_request",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"self",
".",
"record_once",
"(",
"lambda",
"state",
":",
"state",
".",
"app",
".",
"before_first_request",
"(",
"func",
")",
")",
"return",
"func"
] | Add a before request first function to the app.
This is designed to be used as a decorator, and has the same
arguments as :meth:`~quart.Quart.before_first_request`. It is
triggered before the first request to the app this blueprint
is registered on. An example usage,
.. code-bl... | [
"Add",
"a",
"before",
"request",
"first",
"function",
"to",
"the",
"app",
"."
] | python | train |
todddeluca/temps | setup.py | https://github.com/todddeluca/temps/blob/10bf4e71a6b2e8ad10fa8a272145968b6c84f61b/setup.py#L5-L16 | def version(modfile):
'''
Parse version from module without importing or evaluating the code.
The module should define a __version__ variable like __version__ = '2.0.1'.
'''
import re
with open(modfile) as fh:
for line in fh:
m = re.search(r"^__version__ = '([^']+)'$", line)
... | [
"def",
"version",
"(",
"modfile",
")",
":",
"import",
"re",
"with",
"open",
"(",
"modfile",
")",
"as",
"fh",
":",
"for",
"line",
"in",
"fh",
":",
"m",
"=",
"re",
".",
"search",
"(",
"r\"^__version__ = '([^']+)'$\"",
",",
"line",
")",
"if",
"m",
":",
... | Parse version from module without importing or evaluating the code.
The module should define a __version__ variable like __version__ = '2.0.1'. | [
"Parse",
"version",
"from",
"module",
"without",
"importing",
"or",
"evaluating",
"the",
"code",
".",
"The",
"module",
"should",
"define",
"a",
"__version__",
"variable",
"like",
"__version__",
"=",
"2",
".",
"0",
".",
"1",
"."
] | python | train |
numirias/firefed | firefed/util.py | https://github.com/numirias/firefed/blob/908114fe3a1506dcaafb23ce49e99f171e5e329d/firefed/util.py#L70-L84 | def profile_dir(name):
"""Return path to FF profile for a given profile name or path."""
if name:
possible_path = Path(name)
if possible_path.exists():
return possible_path
profiles = list(read_profiles())
try:
if name:
profile = next(p for p in profiles i... | [
"def",
"profile_dir",
"(",
"name",
")",
":",
"if",
"name",
":",
"possible_path",
"=",
"Path",
"(",
"name",
")",
"if",
"possible_path",
".",
"exists",
"(",
")",
":",
"return",
"possible_path",
"profiles",
"=",
"list",
"(",
"read_profiles",
"(",
")",
")",
... | Return path to FF profile for a given profile name or path. | [
"Return",
"path",
"to",
"FF",
"profile",
"for",
"a",
"given",
"profile",
"name",
"or",
"path",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.