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 |
|---|---|---|---|---|---|---|---|---|
IBMStreams/pypi.streamsx | streamsx/topology/topology.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1356-L1423 | def set_parallel(self, width, name=None):
"""
Set this source stream to be split into multiple channels
as the start of a parallel region.
Calling ``set_parallel`` on a stream created by
:py:meth:`~Topology.source` results in the stream
having `width` channels, each crea... | [
"def",
"set_parallel",
"(",
"self",
",",
"width",
",",
"name",
"=",
"None",
")",
":",
"self",
".",
"oport",
".",
"operator",
".",
"config",
"[",
"'parallel'",
"]",
"=",
"True",
"self",
".",
"oport",
".",
"operator",
".",
"config",
"[",
"'width'",
"]"... | Set this source stream to be split into multiple channels
as the start of a parallel region.
Calling ``set_parallel`` on a stream created by
:py:meth:`~Topology.source` results in the stream
having `width` channels, each created by its own instance
of the callable::
... | [
"Set",
"this",
"source",
"stream",
"to",
"be",
"split",
"into",
"multiple",
"channels",
"as",
"the",
"start",
"of",
"a",
"parallel",
"region",
"."
] | python | train |
rapidpro/expressions | python/temba_expressions/functions/excel.py | https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/functions/excel.py#L47-L53 | def fixed(ctx, number, decimals=2, no_commas=False):
"""
Formats the given number in decimal format using a period and commas
"""
value = _round(ctx, number, decimals)
format_str = '{:f}' if no_commas else '{:,f}'
return format_str.format(value) | [
"def",
"fixed",
"(",
"ctx",
",",
"number",
",",
"decimals",
"=",
"2",
",",
"no_commas",
"=",
"False",
")",
":",
"value",
"=",
"_round",
"(",
"ctx",
",",
"number",
",",
"decimals",
")",
"format_str",
"=",
"'{:f}'",
"if",
"no_commas",
"else",
"'{:,f}'",
... | Formats the given number in decimal format using a period and commas | [
"Formats",
"the",
"given",
"number",
"in",
"decimal",
"format",
"using",
"a",
"period",
"and",
"commas"
] | python | train |
python-openxml/python-docx | docx/package.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/package.py#L100-L113 | def _next_image_partname(self, ext):
"""
The next available image partname, starting from
``/word/media/image1.{ext}`` where unused numbers are reused. The
partname is unique by number, without regard to the extension. *ext*
does not include the leading period.
"""
... | [
"def",
"_next_image_partname",
"(",
"self",
",",
"ext",
")",
":",
"def",
"image_partname",
"(",
"n",
")",
":",
"return",
"PackURI",
"(",
"'/word/media/image%d.%s'",
"%",
"(",
"n",
",",
"ext",
")",
")",
"used_numbers",
"=",
"[",
"image_part",
".",
"partname... | The next available image partname, starting from
``/word/media/image1.{ext}`` where unused numbers are reused. The
partname is unique by number, without regard to the extension. *ext*
does not include the leading period. | [
"The",
"next",
"available",
"image",
"partname",
"starting",
"from",
"/",
"word",
"/",
"media",
"/",
"image1",
".",
"{",
"ext",
"}",
"where",
"unused",
"numbers",
"are",
"reused",
".",
"The",
"partname",
"is",
"unique",
"by",
"number",
"without",
"regard",... | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/text/freqdist.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/text/freqdist.py#L202-L263 | def draw(self, **kwargs):
"""
Called from the fit method, this method creates the canvas and
draws the distribution plot on it.
Parameters
----------
kwargs: generic keyword arguments.
"""
# Prepare the data
bins = np.arange(self.N)
word... | [
"def",
"draw",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Prepare the data",
"bins",
"=",
"np",
".",
"arange",
"(",
"self",
".",
"N",
")",
"words",
"=",
"[",
"self",
".",
"features",
"[",
"i",
"]",
"for",
"i",
"in",
"self",
".",
"sorted_"... | Called from the fit method, this method creates the canvas and
draws the distribution plot on it.
Parameters
----------
kwargs: generic keyword arguments. | [
"Called",
"from",
"the",
"fit",
"method",
"this",
"method",
"creates",
"the",
"canvas",
"and",
"draws",
"the",
"distribution",
"plot",
"on",
"it",
"."
] | python | train |
Tanganelli/CoAPthon3 | coapthon/messages/option.py | https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/messages/option.py#L55-L77 | def value(self, value):
"""
Set the value of the option.
:param value: the option value
"""
opt_type = defines.OptionRegistry.LIST[self._number].value_type
if opt_type == defines.INTEGER:
if type(value) is not int:
value = int(value)
... | [
"def",
"value",
"(",
"self",
",",
"value",
")",
":",
"opt_type",
"=",
"defines",
".",
"OptionRegistry",
".",
"LIST",
"[",
"self",
".",
"_number",
"]",
".",
"value_type",
"if",
"opt_type",
"==",
"defines",
".",
"INTEGER",
":",
"if",
"type",
"(",
"value"... | Set the value of the option.
:param value: the option value | [
"Set",
"the",
"value",
"of",
"the",
"option",
"."
] | python | train |
ANCIR/granoloader | granoloader/mapping.py | https://github.com/ANCIR/granoloader/blob/c48b1bd50403dd611340c5f51637f7c5ca54059c/granoloader/mapping.py#L124-L129 | def get_source(self, spec, row):
""" Sources can be specified as plain strings or as a reference to a column. """
value = self.get_value({'column': spec.get('source_url_column')}, row)
if value is not None:
return value
return spec.get('source_url') | [
"def",
"get_source",
"(",
"self",
",",
"spec",
",",
"row",
")",
":",
"value",
"=",
"self",
".",
"get_value",
"(",
"{",
"'column'",
":",
"spec",
".",
"get",
"(",
"'source_url_column'",
")",
"}",
",",
"row",
")",
"if",
"value",
"is",
"not",
"None",
"... | Sources can be specified as plain strings or as a reference to a column. | [
"Sources",
"can",
"be",
"specified",
"as",
"plain",
"strings",
"or",
"as",
"a",
"reference",
"to",
"a",
"column",
"."
] | python | train |
mar10/wsgidav | wsgidav/util.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/util.py#L387-L396 | def to_unicode_safe(s):
"""Convert a binary string to Unicode using UTF-8 (fallback to ISO-8859-1)."""
try:
u = compat.to_unicode(s, "utf8")
except ValueError:
_logger.error(
"to_unicode_safe({!r}) *** UTF-8 failed. Trying ISO-8859-1".format(s)
)
u = compat.to_uni... | [
"def",
"to_unicode_safe",
"(",
"s",
")",
":",
"try",
":",
"u",
"=",
"compat",
".",
"to_unicode",
"(",
"s",
",",
"\"utf8\"",
")",
"except",
"ValueError",
":",
"_logger",
".",
"error",
"(",
"\"to_unicode_safe({!r}) *** UTF-8 failed. Trying ISO-8859-1\"",
".",
"for... | Convert a binary string to Unicode using UTF-8 (fallback to ISO-8859-1). | [
"Convert",
"a",
"binary",
"string",
"to",
"Unicode",
"using",
"UTF",
"-",
"8",
"(",
"fallback",
"to",
"ISO",
"-",
"8859",
"-",
"1",
")",
"."
] | python | valid |
EventTeam/beliefs | src/beliefs/cells/sets.py | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/sets.py#L60-L65 | def is_equal(self, other):
"""
True iff all members are the same
"""
other = self.coerce(other)
return len(self.get_values().symmetric_difference(other.get_values())) == 0 | [
"def",
"is_equal",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"coerce",
"(",
"other",
")",
"return",
"len",
"(",
"self",
".",
"get_values",
"(",
")",
".",
"symmetric_difference",
"(",
"other",
".",
"get_values",
"(",
")",
")",
")... | True iff all members are the same | [
"True",
"iff",
"all",
"members",
"are",
"the",
"same"
] | python | train |
yyuu/botornado | boto/sdb/db/manager/__init__.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sdb/db/manager/__init__.py#L23-L90 | def get_manager(cls):
"""
Returns the appropriate Manager class for a given Model class. It does this by
looking in the boto config for a section like this::
[DB]
db_type = SimpleDB
db_user = <aws access key id>
db_passwd = <aws secret access key>
db_name = my_d... | [
"def",
"get_manager",
"(",
"cls",
")",
":",
"db_user",
"=",
"boto",
".",
"config",
".",
"get",
"(",
"'DB'",
",",
"'db_user'",
",",
"None",
")",
"db_passwd",
"=",
"boto",
".",
"config",
".",
"get",
"(",
"'DB'",
",",
"'db_passwd'",
",",
"None",
")",
... | Returns the appropriate Manager class for a given Model class. It does this by
looking in the boto config for a section like this::
[DB]
db_type = SimpleDB
db_user = <aws access key id>
db_passwd = <aws secret access key>
db_name = my_domain
[DB_TestBasic]
... | [
"Returns",
"the",
"appropriate",
"Manager",
"class",
"for",
"a",
"given",
"Model",
"class",
".",
"It",
"does",
"this",
"by",
"looking",
"in",
"the",
"boto",
"config",
"for",
"a",
"section",
"like",
"this",
"::",
"[",
"DB",
"]",
"db_type",
"=",
"SimpleDB"... | python | train |
materialsproject/pymatgen | pymatgen/analysis/transition_state.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/transition_state.py#L214-L292 | def from_dir(cls, root_dir, relaxation_dirs=None, **kwargs):
"""
Initializes a NEBAnalysis object from a directory of a NEB run.
Note that OUTCARs must be present in all image directories. For the
terminal OUTCARs from relaxation calculations, you can specify the
locations using ... | [
"def",
"from_dir",
"(",
"cls",
",",
"root_dir",
",",
"relaxation_dirs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"neb_dirs",
"=",
"[",
"]",
"for",
"d",
"in",
"os",
".",
"listdir",
"(",
"root_dir",
")",
":",
"pth",
"=",
"os",
".",
"path",
"... | Initializes a NEBAnalysis object from a directory of a NEB run.
Note that OUTCARs must be present in all image directories. For the
terminal OUTCARs from relaxation calculations, you can specify the
locations using relaxation_dir. If these are not specified, the code
will attempt to look... | [
"Initializes",
"a",
"NEBAnalysis",
"object",
"from",
"a",
"directory",
"of",
"a",
"NEB",
"run",
".",
"Note",
"that",
"OUTCARs",
"must",
"be",
"present",
"in",
"all",
"image",
"directories",
".",
"For",
"the",
"terminal",
"OUTCARs",
"from",
"relaxation",
"cal... | python | train |
nugget/python-insteonplm | insteonplm/devices/__init__.py | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L441-L473 | def write_aldb(self, mem_addr: int, mode: str, group: int, target,
data1=0x00, data2=0x00, data3=0x00):
"""Write to the device All-Link Database.
Parameters:
Required:
mode: r - device is a responder of target
c - device is a controller o... | [
"def",
"write_aldb",
"(",
"self",
",",
"mem_addr",
":",
"int",
",",
"mode",
":",
"str",
",",
"group",
":",
"int",
",",
"target",
",",
"data1",
"=",
"0x00",
",",
"data2",
"=",
"0x00",
",",
"data3",
"=",
"0x00",
")",
":",
"if",
"isinstance",
"(",
"... | Write to the device All-Link Database.
Parameters:
Required:
mode: r - device is a responder of target
c - device is a controller of target
group: Link group
target: Address of the other device
Optional:
data1: Dev... | [
"Write",
"to",
"the",
"device",
"All",
"-",
"Link",
"Database",
"."
] | python | train |
smdabdoub/phylotoast | bin/sanger_qiimify.py | https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/sanger_qiimify.py#L94-L128 | def generate_barcodes(nIds, codeLen=12):
"""
Given a list of sample IDs generate unique n-base barcodes for each.
Note that only 4^n unique barcodes are possible.
"""
def next_code(b, c, i):
return c[:i] + b + (c[i+1:] if i < -1 else '')
def rand_base():
return random.choice(['A... | [
"def",
"generate_barcodes",
"(",
"nIds",
",",
"codeLen",
"=",
"12",
")",
":",
"def",
"next_code",
"(",
"b",
",",
"c",
",",
"i",
")",
":",
"return",
"c",
"[",
":",
"i",
"]",
"+",
"b",
"+",
"(",
"c",
"[",
"i",
"+",
"1",
":",
"]",
"if",
"i",
... | Given a list of sample IDs generate unique n-base barcodes for each.
Note that only 4^n unique barcodes are possible. | [
"Given",
"a",
"list",
"of",
"sample",
"IDs",
"generate",
"unique",
"n",
"-",
"base",
"barcodes",
"for",
"each",
".",
"Note",
"that",
"only",
"4^n",
"unique",
"barcodes",
"are",
"possible",
"."
] | python | train |
SeattleTestbed/seash | pyreadline/unicode_helper.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/unicode_helper.py#L20-L27 | def ensure_unicode(text):
u"""helper to ensure that text passed to WriteConsoleW is unicode"""
if isinstance(text, str):
try:
return text.decode(pyreadline_codepage, u"replace")
except (LookupError, TypeError):
return text.decode(u"ascii", u"replace")
return te... | [
"def",
"ensure_unicode",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"try",
":",
"return",
"text",
".",
"decode",
"(",
"pyreadline_codepage",
",",
"u\"replace\"",
")",
"except",
"(",
"LookupError",
",",
"TypeError",
")",
... | u"""helper to ensure that text passed to WriteConsoleW is unicode | [
"u",
"helper",
"to",
"ensure",
"that",
"text",
"passed",
"to",
"WriteConsoleW",
"is",
"unicode"
] | python | train |
bninja/pilo | pilo/fields.py | https://github.com/bninja/pilo/blob/32b7298a47e33fb7383103017b4f3b59ad76ea6f/pilo/fields.py#L567-L587 | def map(self, value=NONE):
"""
Executes the steps used to "map" this fields value from `ctx.src` to a
value.
:param value: optional **pre-computed** value.
:return: The successfully mapped value or:
- NONE if one was not found
- ERROR if the field was p... | [
"def",
"map",
"(",
"self",
",",
"value",
"=",
"NONE",
")",
":",
"with",
"self",
".",
"ctx",
"(",
"field",
"=",
"self",
",",
"parent",
"=",
"self",
")",
":",
"value",
"=",
"self",
".",
"_map",
"(",
"value",
")",
"if",
"self",
".",
"attach_parent",... | Executes the steps used to "map" this fields value from `ctx.src` to a
value.
:param value: optional **pre-computed** value.
:return: The successfully mapped value or:
- NONE if one was not found
- ERROR if the field was present in `ctx.src` but invalid. | [
"Executes",
"the",
"steps",
"used",
"to",
"map",
"this",
"fields",
"value",
"from",
"ctx",
".",
"src",
"to",
"a",
"value",
"."
] | python | train |
PatrikValkovic/grammpy | grammpy/transforms/InverseContextFree.py | https://github.com/PatrikValkovic/grammpy/blob/879ce0ef794ac2823acc19314fcd7a8aba53e50f/grammpy/transforms/InverseContextFree.py#L58-L72 | def reverse_cyk_transforms(root):
# type: (Nonterminal) -> Nonterminal
"""
Reverse transformation made to grammar before CYK.
Performs following steps:
- transform from chomsky normal form
- restore unit rules
- restore epsilon rules
:param root: Root node... | [
"def",
"reverse_cyk_transforms",
"(",
"root",
")",
":",
"# type: (Nonterminal) -> Nonterminal",
"root",
"=",
"InverseContextFree",
".",
"transform_from_chomsky_normal_form",
"(",
"root",
")",
"root",
"=",
"InverseContextFree",
".",
"unit_rules_restore",
"(",
"root",
")",
... | Reverse transformation made to grammar before CYK.
Performs following steps:
- transform from chomsky normal form
- restore unit rules
- restore epsilon rules
:param root: Root node of the parsed tree.
:return: Restored parsed tree. | [
"Reverse",
"transformation",
"made",
"to",
"grammar",
"before",
"CYK",
".",
"Performs",
"following",
"steps",
":",
"-",
"transform",
"from",
"chomsky",
"normal",
"form",
"-",
"restore",
"unit",
"rules",
"-",
"restore",
"epsilon",
"rules",
":",
"param",
"root",... | python | train |
JoshAshby/pyRethinkORM | rethinkORM/rethinkModel.py | https://github.com/JoshAshby/pyRethinkORM/blob/92158d146dea6cfe9022d7de2537403f5f2c1e02/rethinkORM/rethinkModel.py#L277-L289 | def delete(self):
"""
Deletes the current instance. This assumes that we know what we're
doing, and have a primary key in our data already. If this is a new
instance, then we'll let the user know with an Exception
"""
if self._new:
raise Exception("This is a n... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"_new",
":",
"raise",
"Exception",
"(",
"\"This is a new object, %s not in data, \\\nindicating this entry isn't stored.\"",
"%",
"self",
".",
"primaryKey",
")",
"r",
".",
"table",
"(",
"self",
".",
"table... | Deletes the current instance. This assumes that we know what we're
doing, and have a primary key in our data already. If this is a new
instance, then we'll let the user know with an Exception | [
"Deletes",
"the",
"current",
"instance",
".",
"This",
"assumes",
"that",
"we",
"know",
"what",
"we",
"re",
"doing",
"and",
"have",
"a",
"primary",
"key",
"in",
"our",
"data",
"already",
".",
"If",
"this",
"is",
"a",
"new",
"instance",
"then",
"we",
"ll... | python | train |
zeaphoo/reston | reston/core/apk.py | https://github.com/zeaphoo/reston/blob/96502487b2259572df55237c9526f92627465088/reston/core/apk.py#L797-L811 | def get_signature_names(self):
"""
Return a list of the signature file names.
"""
signature_expr = re.compile("^(META-INF/)(.*)(\.RSA|\.EC|\.DSA)$")
signatures = []
for i in self.get_files():
if signature_expr.search(i):
signatures.append... | [
"def",
"get_signature_names",
"(",
"self",
")",
":",
"signature_expr",
"=",
"re",
".",
"compile",
"(",
"\"^(META-INF/)(.*)(\\.RSA|\\.EC|\\.DSA)$\"",
")",
"signatures",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".",
"get_files",
"(",
")",
":",
"if",
"signature_e... | Return a list of the signature file names. | [
"Return",
"a",
"list",
"of",
"the",
"signature",
"file",
"names",
"."
] | python | train |
MaxStrange/AudioSegment | algorithms/asa.py | https://github.com/MaxStrange/AudioSegment/blob/1daefb8de626ddff3ff7016697c3ad31d262ecd6/algorithms/asa.py#L888-L901 | def _merge_adjacent_segments(mask):
"""
Merges all segments in `mask` which are touching.
"""
mask_ids = [id for id in np.unique(mask) if id != 0]
for id in mask_ids:
myfidxs, mysidxs = np.where(mask == id)
for other in mask_ids: # Ugh, brute force O(N^2) algorithm.. gross..
... | [
"def",
"_merge_adjacent_segments",
"(",
"mask",
")",
":",
"mask_ids",
"=",
"[",
"id",
"for",
"id",
"in",
"np",
".",
"unique",
"(",
"mask",
")",
"if",
"id",
"!=",
"0",
"]",
"for",
"id",
"in",
"mask_ids",
":",
"myfidxs",
",",
"mysidxs",
"=",
"np",
".... | Merges all segments in `mask` which are touching. | [
"Merges",
"all",
"segments",
"in",
"mask",
"which",
"are",
"touching",
"."
] | python | test |
saltstack/salt | salt/modules/mysql.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1049-L1083 | def db_tables(name, **connection_args):
'''
Shows the tables in the given MySQL database (if exists)
CLI Example:
.. code-block:: bash
salt '*' mysql.db_tables 'database'
'''
if not db_exists(name, **connection_args):
log.info('Database \'%s\' does not exist', name)
re... | [
"def",
"db_tables",
"(",
"name",
",",
"*",
"*",
"connection_args",
")",
":",
"if",
"not",
"db_exists",
"(",
"name",
",",
"*",
"*",
"connection_args",
")",
":",
"log",
".",
"info",
"(",
"'Database \\'%s\\' does not exist'",
",",
"name",
")",
"return",
"Fals... | Shows the tables in the given MySQL database (if exists)
CLI Example:
.. code-block:: bash
salt '*' mysql.db_tables 'database' | [
"Shows",
"the",
"tables",
"in",
"the",
"given",
"MySQL",
"database",
"(",
"if",
"exists",
")"
] | python | train |
AtomHash/evernode | evernode/classes/form_data.py | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/form_data.py#L38-L46 | def add_file(self, name, required=False, error=None, extensions=None):
""" Add a file field to parse on request (uploads) """
if name is None:
return
self.file_arguments.append(dict(
name=name,
required=required,
error=error,
ex... | [
"def",
"add_file",
"(",
"self",
",",
"name",
",",
"required",
"=",
"False",
",",
"error",
"=",
"None",
",",
"extensions",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"return",
"self",
".",
"file_arguments",
".",
"append",
"(",
"dict",
"("... | Add a file field to parse on request (uploads) | [
"Add",
"a",
"file",
"field",
"to",
"parse",
"on",
"request",
"(",
"uploads",
")"
] | python | train |
stephrdev/django-formwizard | formwizard/views.py | https://github.com/stephrdev/django-formwizard/blob/7b35165f0340aae4e8302d5b05b0cb443f6c9904/formwizard/views.py#L637-L646 | def post(self, *args, **kwargs):
"""
Do a redirect if user presses the prev. step button. The rest of this
is super'd from FormWizard.
"""
prev_step = self.request.POST.get('wizard_prev_step', None)
if prev_step and prev_step in self.get_form_list():
self.stor... | [
"def",
"post",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"prev_step",
"=",
"self",
".",
"request",
".",
"POST",
".",
"get",
"(",
"'wizard_prev_step'",
",",
"None",
")",
"if",
"prev_step",
"and",
"prev_step",
"in",
"self",
".",... | Do a redirect if user presses the prev. step button. The rest of this
is super'd from FormWizard. | [
"Do",
"a",
"redirect",
"if",
"user",
"presses",
"the",
"prev",
".",
"step",
"button",
".",
"The",
"rest",
"of",
"this",
"is",
"super",
"d",
"from",
"FormWizard",
"."
] | python | train |
apache/airflow | airflow/contrib/hooks/gcp_video_intelligence_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_video_intelligence_hook.py#L51-L105 | def annotate_video(
self,
input_uri=None,
input_content=None,
features=None,
video_context=None,
output_uri=None,
location=None,
retry=None,
timeout=None,
metadata=None,
):
"""
Performs video annotation.
:param ... | [
"def",
"annotate_video",
"(",
"self",
",",
"input_uri",
"=",
"None",
",",
"input_content",
"=",
"None",
",",
"features",
"=",
"None",
",",
"video_context",
"=",
"None",
",",
"output_uri",
"=",
"None",
",",
"location",
"=",
"None",
",",
"retry",
"=",
"Non... | Performs video annotation.
:param input_uri: Input video location. Currently, only Google Cloud Storage URIs are supported,
which must be specified in the following format: ``gs://bucket-id/object-id``.
:type input_uri: str
:param input_content: The video data bytes.
If ... | [
"Performs",
"video",
"annotation",
"."
] | python | test |
google/grr | grr/config/grr_response_templates/setup.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/config/grr_response_templates/setup.py#L53-L69 | def CheckTemplates(self, base_dir, version):
"""Verify we have at least one template that matches maj.minor version."""
major_minor = ".".join(version.split(".")[0:2])
templates = glob.glob(
os.path.join(base_dir, "templates/*%s*.zip" % major_minor))
required_templates = set(
[x.replace(... | [
"def",
"CheckTemplates",
"(",
"self",
",",
"base_dir",
",",
"version",
")",
":",
"major_minor",
"=",
"\".\"",
".",
"join",
"(",
"version",
".",
"split",
"(",
"\".\"",
")",
"[",
"0",
":",
"2",
"]",
")",
"templates",
"=",
"glob",
".",
"glob",
"(",
"o... | Verify we have at least one template that matches maj.minor version. | [
"Verify",
"we",
"have",
"at",
"least",
"one",
"template",
"that",
"matches",
"maj",
".",
"minor",
"version",
"."
] | python | train |
matrix-org/matrix-python-sdk | matrix_client/client.py | https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/client.py#L512-L531 | def start_listener_thread(self, timeout_ms=30000, exception_handler=None):
""" Start a listener thread to listen for events in the background.
Args:
timeout (int): How long to poll the Home Server for before
retrying.
exception_handler (func(exception)): Optional ... | [
"def",
"start_listener_thread",
"(",
"self",
",",
"timeout_ms",
"=",
"30000",
",",
"exception_handler",
"=",
"None",
")",
":",
"try",
":",
"thread",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"listen_forever",
",",
"args",
"=",
"(",
"timeout_ms",
",",... | Start a listener thread to listen for events in the background.
Args:
timeout (int): How long to poll the Home Server for before
retrying.
exception_handler (func(exception)): Optional exception handler
function which can be used to handle exceptions in the... | [
"Start",
"a",
"listener",
"thread",
"to",
"listen",
"for",
"events",
"in",
"the",
"background",
"."
] | python | train |
Azure/azure-storage-python | azure-storage-queue/azure/storage/queue/queueservice.py | https://github.com/Azure/azure-storage-python/blob/52327354b192cbcf6b7905118ec6b5d57fa46275/azure-storage-queue/azure/storage/queue/queueservice.py#L732-L794 | def put_message(self, queue_name, content, visibility_timeout=None,
time_to_live=None, timeout=None):
'''
Adds a new message to the back of the message queue.
The visibility timeout specifies the time that the message will be
invisible. After the timeout expires, t... | [
"def",
"put_message",
"(",
"self",
",",
"queue_name",
",",
"content",
",",
"visibility_timeout",
"=",
"None",
",",
"time_to_live",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"_validate_encryption_required",
"(",
"self",
".",
"require_encryption",
",",
... | Adds a new message to the back of the message queue.
The visibility timeout specifies the time that the message will be
invisible. After the timeout expires, the message will become visible.
If a visibility timeout is not specified, the default value of 0 is used.
The message time-t... | [
"Adds",
"a",
"new",
"message",
"to",
"the",
"back",
"of",
"the",
"message",
"queue",
"."
] | python | train |
census-instrumentation/opencensus-python | opencensus/trace/tracers/context_tracer.py | https://github.com/census-instrumentation/opencensus-python/blob/992b223f7e34c5dcb65922b7d5c827e7a1351e7d/opencensus/trace/tracers/context_tracer.py#L149-L176 | def get_span_datas(self, span):
"""Extracts a list of SpanData tuples from a span
:rtype: list of opencensus.trace.span_data.SpanData
:return list of SpanData tuples
"""
span_datas = [
span_data_module.SpanData(
name=ss.name,
context=s... | [
"def",
"get_span_datas",
"(",
"self",
",",
"span",
")",
":",
"span_datas",
"=",
"[",
"span_data_module",
".",
"SpanData",
"(",
"name",
"=",
"ss",
".",
"name",
",",
"context",
"=",
"self",
".",
"span_context",
",",
"span_id",
"=",
"ss",
".",
"span_id",
... | Extracts a list of SpanData tuples from a span
:rtype: list of opencensus.trace.span_data.SpanData
:return list of SpanData tuples | [
"Extracts",
"a",
"list",
"of",
"SpanData",
"tuples",
"from",
"a",
"span"
] | python | train |
globality-corp/microcosm-flask | microcosm_flask/fields/timestamp_field.py | https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/fields/timestamp_field.py#L24-L35 | def _serialize(self, value, attr, obj):
"""
Serialize value as a timestamp, either as a Unix timestamp (in float second) or a UTC isoformat string.
"""
if value is None:
return None
if self.use_isoformat:
return datetime.utcfromtimestamp(value).isoformat... | [
"def",
"_serialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"use_isoformat",
":",
"return",
"datetime",
".",
"utcfromtimestamp",
"(",
"value",
")",
".",
"isof... | Serialize value as a timestamp, either as a Unix timestamp (in float second) or a UTC isoformat string. | [
"Serialize",
"value",
"as",
"a",
"timestamp",
"either",
"as",
"a",
"Unix",
"timestamp",
"(",
"in",
"float",
"second",
")",
"or",
"a",
"UTC",
"isoformat",
"string",
"."
] | python | train |
zetaops/zengine | zengine/views/system.py | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/system.py#L107-L197 | def get_tasks(current):
"""
List task invitations of current user
.. code-block:: python
# request:
{
'view': '_zops_get_tasks',
'state': string, # one of these:
# "active", "future", "finished", "expire... | [
"def",
"get_tasks",
"(",
"current",
")",
":",
"# TODO: Also return invitations for user's other roles",
"# TODO: Handle automatic role switching",
"STATE_DICT",
"=",
"{",
"'active'",
":",
"[",
"20",
",",
"30",
"]",
",",
"'future'",
":",
"10",
",",
"'finished'",
":",
... | List task invitations of current user
.. code-block:: python
# request:
{
'view': '_zops_get_tasks',
'state': string, # one of these:
# "active", "future", "finished", "expired"
'inverted': boolean, ... | [
"List",
"task",
"invitations",
"of",
"current",
"user"
] | python | train |
Robpol86/Flask-Celery-Helper | flask_celery.py | https://github.com/Robpol86/Flask-Celery-Helper/blob/92bd3b02954422665260116adda8eb899546c365/flask_celery.py#L87-L90 | def reset_lock(self):
"""Removed the lock regardless of timeout."""
redis_key = self.CELERY_LOCK.format(task_id=self.task_identifier)
self.celery_self.backend.client.delete(redis_key) | [
"def",
"reset_lock",
"(",
"self",
")",
":",
"redis_key",
"=",
"self",
".",
"CELERY_LOCK",
".",
"format",
"(",
"task_id",
"=",
"self",
".",
"task_identifier",
")",
"self",
".",
"celery_self",
".",
"backend",
".",
"client",
".",
"delete",
"(",
"redis_key",
... | Removed the lock regardless of timeout. | [
"Removed",
"the",
"lock",
"regardless",
"of",
"timeout",
"."
] | python | valid |
ray-project/ray | python/ray/worker.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2006-L2045 | def _try_to_compute_deterministic_class_id(cls, depth=5):
"""Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results tha... | [
"def",
"_try_to_compute_deterministic_class_id",
"(",
"cls",
",",
"depth",
"=",
"5",
")",
":",
"# Pickling, loading, and pickling again seems to produce more consistent",
"# results than simply pickling. This is a bit",
"class_id",
"=",
"pickle",
".",
"dumps",
"(",
"cls",
")",
... | Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results than simply pickling. This is a bit crazy
and could cause proble... | [
"Attempt",
"to",
"produce",
"a",
"deterministic",
"class",
"ID",
"for",
"a",
"given",
"class",
"."
] | python | train |
seung-lab/cloud-volume | cloudvolume/txrx.py | https://github.com/seung-lab/cloud-volume/blob/d2fd4500333f1bc3cd3e3919a8b649cec5d8e214/cloudvolume/txrx.py#L273-L314 | def upload_image(vol, img, offset, parallel=1,
manual_shared_memory_id=None, manual_shared_memory_bbox=None, manual_shared_memory_order='F'):
"""Upload img to vol with offset. This is the primary entry point for uploads."""
global NON_ALIGNED_WRITE
if not np.issubdtype(img.dtype, np.dtype(vol.dtype).type):
... | [
"def",
"upload_image",
"(",
"vol",
",",
"img",
",",
"offset",
",",
"parallel",
"=",
"1",
",",
"manual_shared_memory_id",
"=",
"None",
",",
"manual_shared_memory_bbox",
"=",
"None",
",",
"manual_shared_memory_order",
"=",
"'F'",
")",
":",
"global",
"NON_ALIGNED_W... | Upload img to vol with offset. This is the primary entry point for uploads. | [
"Upload",
"img",
"to",
"vol",
"with",
"offset",
".",
"This",
"is",
"the",
"primary",
"entry",
"point",
"for",
"uploads",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/click/formatting.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/formatting.py#L211-L223 | def section(self, name):
"""Helpful context manager that writes a paragraph, a heading,
and the indents.
:param name: the section name that is written as heading.
"""
self.write_paragraph()
self.write_heading(name)
self.indent()
try:
yield
... | [
"def",
"section",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"write_paragraph",
"(",
")",
"self",
".",
"write_heading",
"(",
"name",
")",
"self",
".",
"indent",
"(",
")",
"try",
":",
"yield",
"finally",
":",
"self",
".",
"dedent",
"(",
")"
] | Helpful context manager that writes a paragraph, a heading,
and the indents.
:param name: the section name that is written as heading. | [
"Helpful",
"context",
"manager",
"that",
"writes",
"a",
"paragraph",
"a",
"heading",
"and",
"the",
"indents",
"."
] | python | train |
WojciechMula/pyahocorasick | py/pyahocorasick.py | https://github.com/WojciechMula/pyahocorasick/blob/53842f783fbe3fa77d53cde1ac251b23c3cbed02/py/pyahocorasick.py#L113-L129 | def items(self):
"""
Generator returning all keys and values stored in a trie.
"""
L = []
def aux(node, s):
s = s + node.char
if node.output is not nil:
L.append((s, node.output))
for child in node.children.values():
if child is not node:
aux(child, s)
aux(self.root, '')
return it... | [
"def",
"items",
"(",
"self",
")",
":",
"L",
"=",
"[",
"]",
"def",
"aux",
"(",
"node",
",",
"s",
")",
":",
"s",
"=",
"s",
"+",
"node",
".",
"char",
"if",
"node",
".",
"output",
"is",
"not",
"nil",
":",
"L",
".",
"append",
"(",
"(",
"s",
",... | Generator returning all keys and values stored in a trie. | [
"Generator",
"returning",
"all",
"keys",
"and",
"values",
"stored",
"in",
"a",
"trie",
"."
] | python | train |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/summary.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/summary.py#L136-L165 | def get_diff(left, right):
"""Get the difference of two summaries.
Subtracts the values of the right summary from the values of the left
summary.
If similar rows appear on both sides, the are included in the summary with
0 for number of elements and total size.
If the number of elements of a ro... | [
"def",
"get_diff",
"(",
"left",
",",
"right",
")",
":",
"res",
"=",
"[",
"]",
"for",
"row_r",
"in",
"right",
":",
"found",
"=",
"False",
"for",
"row_l",
"in",
"left",
":",
"if",
"row_r",
"[",
"0",
"]",
"==",
"row_l",
"[",
"0",
"]",
":",
"res",
... | Get the difference of two summaries.
Subtracts the values of the right summary from the values of the left
summary.
If similar rows appear on both sides, the are included in the summary with
0 for number of elements and total size.
If the number of elements of a row of the diff is 0, but the total ... | [
"Get",
"the",
"difference",
"of",
"two",
"summaries",
"."
] | python | train |
nickpandolfi/Cyther | cyther/processing.py | https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/processing.py#L169-L186 | def core(args):
"""
The heart of Cyther, this function controls the main loop, and can be
used to perform any Cyther action. You can call if using Cyther
from the module level
"""
args = furtherArgsProcessing(args)
numfiles = len(args['filenames'])
interval = INTERVAL / numfiles
fil... | [
"def",
"core",
"(",
"args",
")",
":",
"args",
"=",
"furtherArgsProcessing",
"(",
"args",
")",
"numfiles",
"=",
"len",
"(",
"args",
"[",
"'filenames'",
"]",
")",
"interval",
"=",
"INTERVAL",
"/",
"numfiles",
"files",
"=",
"processFiles",
"(",
"args",
")",... | The heart of Cyther, this function controls the main loop, and can be
used to perform any Cyther action. You can call if using Cyther
from the module level | [
"The",
"heart",
"of",
"Cyther",
"this",
"function",
"controls",
"the",
"main",
"loop",
"and",
"can",
"be",
"used",
"to",
"perform",
"any",
"Cyther",
"action",
".",
"You",
"can",
"call",
"if",
"using",
"Cyther",
"from",
"the",
"module",
"level"
] | python | train |
numenta/nupic | src/nupic/algorithms/knn_classifier.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L757-L777 | def getClosest(self, inputPattern, topKCategories=3):
"""Returns the index of the pattern that is closest to inputPattern,
the distances of all patterns to inputPattern, and the indices of the k
closest categories.
"""
inferenceResult = numpy.zeros(max(self._categoryList)+1)
dist = self._getDist... | [
"def",
"getClosest",
"(",
"self",
",",
"inputPattern",
",",
"topKCategories",
"=",
"3",
")",
":",
"inferenceResult",
"=",
"numpy",
".",
"zeros",
"(",
"max",
"(",
"self",
".",
"_categoryList",
")",
"+",
"1",
")",
"dist",
"=",
"self",
".",
"_getDistances",... | Returns the index of the pattern that is closest to inputPattern,
the distances of all patterns to inputPattern, and the indices of the k
closest categories. | [
"Returns",
"the",
"index",
"of",
"the",
"pattern",
"that",
"is",
"closest",
"to",
"inputPattern",
"the",
"distances",
"of",
"all",
"patterns",
"to",
"inputPattern",
"and",
"the",
"indices",
"of",
"the",
"k",
"closest",
"categories",
"."
] | python | valid |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/topology.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/topology.py#L283-L291 | def get_primary(self):
"""Return primary's address or None."""
# Implemented here in Topology instead of MongoClient, so it can lock.
with self._lock:
topology_type = self._description.topology_type
if topology_type != TOPOLOGY_TYPE.ReplicaSetWithPrimary:
... | [
"def",
"get_primary",
"(",
"self",
")",
":",
"# Implemented here in Topology instead of MongoClient, so it can lock.",
"with",
"self",
".",
"_lock",
":",
"topology_type",
"=",
"self",
".",
"_description",
".",
"topology_type",
"if",
"topology_type",
"!=",
"TOPOLOGY_TYPE",... | Return primary's address or None. | [
"Return",
"primary",
"s",
"address",
"or",
"None",
"."
] | python | train |
MIT-LCP/wfdb-python | wfdb/io/annotation.py | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1529-L1565 | def interpret_defintion_annotations(potential_definition_inds, aux_note):
"""
Try to extract annotation definition information from annotation notes.
Information that may be contained:
- fs - sample=0, label_state=22, aux_note='## time resolution: XXX'
- custom annotation label definitions
"""
... | [
"def",
"interpret_defintion_annotations",
"(",
"potential_definition_inds",
",",
"aux_note",
")",
":",
"fs",
"=",
"None",
"custom_labels",
"=",
"[",
"]",
"if",
"len",
"(",
"potential_definition_inds",
")",
">",
"0",
":",
"i",
"=",
"0",
"while",
"i",
"<",
"le... | Try to extract annotation definition information from annotation notes.
Information that may be contained:
- fs - sample=0, label_state=22, aux_note='## time resolution: XXX'
- custom annotation label definitions | [
"Try",
"to",
"extract",
"annotation",
"definition",
"information",
"from",
"annotation",
"notes",
".",
"Information",
"that",
"may",
"be",
"contained",
":",
"-",
"fs",
"-",
"sample",
"=",
"0",
"label_state",
"=",
"22",
"aux_note",
"=",
"##",
"time",
"resolut... | python | train |
tensorflow/probability | tensorflow_probability/python/edward2/generated_random_variables.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/edward2/generated_random_variables.py#L43-L79 | def _simple_name(distribution):
"""Infer the original name passed into a distribution constructor.
Distributions typically follow the pattern of
with.name_scope(name) as name:
super(name=name)
so we attempt to reverse the name-scope transformation to allow
addressing of RVs by the distribution's original... | [
"def",
"_simple_name",
"(",
"distribution",
")",
":",
"simple_name",
"=",
"distribution",
".",
"name",
"# turn 'scope/x/' into 'x'",
"if",
"simple_name",
".",
"endswith",
"(",
"'/'",
")",
":",
"simple_name",
"=",
"simple_name",
".",
"split",
"(",
"'/'",
")",
"... | Infer the original name passed into a distribution constructor.
Distributions typically follow the pattern of
with.name_scope(name) as name:
super(name=name)
so we attempt to reverse the name-scope transformation to allow
addressing of RVs by the distribution's original, user-visible
name kwarg.
Args:... | [
"Infer",
"the",
"original",
"name",
"passed",
"into",
"a",
"distribution",
"constructor",
"."
] | python | test |
pkgw/pwkit | pwkit/cli/wrapout.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/cli/wrapout.py#L93-L104 | def output(self, kind, line):
"*line* should be bytes"
self.destination.write(b''.join([
self._cyan,
b't=%07d' % (time.time() - self._t0),
self._reset,
self._kind_prefixes[kind],
self.markers[kind],
line,
self._reset,
... | [
"def",
"output",
"(",
"self",
",",
"kind",
",",
"line",
")",
":",
"self",
".",
"destination",
".",
"write",
"(",
"b''",
".",
"join",
"(",
"[",
"self",
".",
"_cyan",
",",
"b't=%07d'",
"%",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_... | *line* should be bytes | [
"*",
"line",
"*",
"should",
"be",
"bytes"
] | python | train |
saltstack/salt | salt/modules/libcloud_compute.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/libcloud_compute.py#L780-L789 | def _get_by_id(collection, id):
'''
Get item from a list by the id field
'''
matches = [item for item in collection if item.id == id]
if not matches:
raise ValueError('Could not find a matching item')
elif len(matches) > 1:
raise ValueError('The id matched {0} items, not 1'.forma... | [
"def",
"_get_by_id",
"(",
"collection",
",",
"id",
")",
":",
"matches",
"=",
"[",
"item",
"for",
"item",
"in",
"collection",
"if",
"item",
".",
"id",
"==",
"id",
"]",
"if",
"not",
"matches",
":",
"raise",
"ValueError",
"(",
"'Could not find a matching item... | Get item from a list by the id field | [
"Get",
"item",
"from",
"a",
"list",
"by",
"the",
"id",
"field"
] | python | train |
django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L178-L183 | def get_import_lines(self):
""" Take the stored imports and converts them to lines """
if self.imports:
return ["from %s import %s" % (value, key) for key, value in self.imports.items()]
else:
return [] | [
"def",
"get_import_lines",
"(",
"self",
")",
":",
"if",
"self",
".",
"imports",
":",
"return",
"[",
"\"from %s import %s\"",
"%",
"(",
"value",
",",
"key",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"imports",
".",
"items",
"(",
")",
"]",
"e... | Take the stored imports and converts them to lines | [
"Take",
"the",
"stored",
"imports",
"and",
"converts",
"them",
"to",
"lines"
] | python | train |
bitesofcode/projexui | projexui/widgets/xpopupwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpopupwidget.py#L757-L869 | def popup(self, pos=None):
"""
Pops up this widget at the inputed position. The inputed point should \
be in global space.
:param pos | <QPoint>
:return <bool> success
"""
if self._first and self.centralWidget() is not None:
... | [
"def",
"popup",
"(",
"self",
",",
"pos",
"=",
"None",
")",
":",
"if",
"self",
".",
"_first",
"and",
"self",
".",
"centralWidget",
"(",
")",
"is",
"not",
"None",
":",
"self",
".",
"adjustSize",
"(",
")",
"self",
".",
"_first",
"=",
"False",
"if",
... | Pops up this widget at the inputed position. The inputed point should \
be in global space.
:param pos | <QPoint>
:return <bool> success | [
"Pops",
"up",
"this",
"widget",
"at",
"the",
"inputed",
"position",
".",
"The",
"inputed",
"point",
"should",
"\\",
"be",
"in",
"global",
"space",
".",
":",
"param",
"pos",
"|",
"<QPoint",
">",
":",
"return",
"<bool",
">",
"success"
] | python | train |
pypa/pipenv | pipenv/patched/notpip/_internal/download.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/download.py#L835-L881 | def unpack_url(
link, # type: Optional[Link]
location, # type: Optional[str]
download_dir=None, # type: Optional[str]
only_download=False, # type: bool
session=None, # type: Optional[PipSession]
hashes=None, # type: Optional[Hashes]
progress_bar="on" # type: str
):
# type: (...) -... | [
"def",
"unpack_url",
"(",
"link",
",",
"# type: Optional[Link]",
"location",
",",
"# type: Optional[str]",
"download_dir",
"=",
"None",
",",
"# type: Optional[str]",
"only_download",
"=",
"False",
",",
"# type: bool",
"session",
"=",
"None",
",",
"# type: Optional[PipSe... | Unpack link.
If link is a VCS link:
if only_download, export into download_dir and ignore location
else unpack into location
for other types of link:
- unpack into location
- if download_dir, copy the file into download_dir
- if only_download, mark location fo... | [
"Unpack",
"link",
".",
"If",
"link",
"is",
"a",
"VCS",
"link",
":",
"if",
"only_download",
"export",
"into",
"download_dir",
"and",
"ignore",
"location",
"else",
"unpack",
"into",
"location",
"for",
"other",
"types",
"of",
"link",
":",
"-",
"unpack",
"into... | python | train |
sdispater/cachy | cachy/stores/redis_store.py | https://github.com/sdispater/cachy/blob/ee4b044d6aafa80125730a00b1f679a7bd852b8a/cachy/stores/redis_store.py#L102-L111 | def forget(self, key):
"""
Remove an item from the cache.
:param key: The cache key
:type key: str
:rtype: bool
"""
return bool(self._redis.delete(self._prefix + key)) | [
"def",
"forget",
"(",
"self",
",",
"key",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_redis",
".",
"delete",
"(",
"self",
".",
"_prefix",
"+",
"key",
")",
")"
] | Remove an item from the cache.
:param key: The cache key
:type key: str
:rtype: bool | [
"Remove",
"an",
"item",
"from",
"the",
"cache",
"."
] | python | train |
bokeh/bokeh | bokeh/plotting/figure.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/plotting/figure.py#L914-L954 | def harea_stack(self, stackers, **kw):
''' Generate multiple ``HArea`` renderers for levels stacked left
to right.
Args:
stackers (seq[str]) : a list of data source field names to stack
successively for ``x1`` and ``x2`` harea coordinates.
Additional... | [
"def",
"harea_stack",
"(",
"self",
",",
"stackers",
",",
"*",
"*",
"kw",
")",
":",
"result",
"=",
"[",
"]",
"for",
"kw",
"in",
"_double_stack",
"(",
"stackers",
",",
"\"x1\"",
",",
"\"x2\"",
",",
"*",
"*",
"kw",
")",
":",
"result",
".",
"append",
... | Generate multiple ``HArea`` renderers for levels stacked left
to right.
Args:
stackers (seq[str]) : a list of data source field names to stack
successively for ``x1`` and ``x2`` harea coordinates.
Additionally, the ``name`` of the renderer will be set to
... | [
"Generate",
"multiple",
"HArea",
"renderers",
"for",
"levels",
"stacked",
"left",
"to",
"right",
"."
] | python | train |
maas/python-libmaas | maas/client/viscera/maas.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/viscera/maas.py#L268-L274 | async def get_default_storage_layout(cls) -> StorageLayout:
"""Default storage layout.
Storage layout that is applied to a node when it is deployed.
"""
data = await cls.get_config("default_storage_layout")
return cls.StorageLayout.lookup(data) | [
"async",
"def",
"get_default_storage_layout",
"(",
"cls",
")",
"->",
"StorageLayout",
":",
"data",
"=",
"await",
"cls",
".",
"get_config",
"(",
"\"default_storage_layout\"",
")",
"return",
"cls",
".",
"StorageLayout",
".",
"lookup",
"(",
"data",
")"
] | Default storage layout.
Storage layout that is applied to a node when it is deployed. | [
"Default",
"storage",
"layout",
"."
] | python | train |
EventTeam/beliefs | src/beliefs/cells/posets.py | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/posets.py#L406-L411 | def to_dotfile(self):
""" Writes a DOT graphviz file of the domain structure, and returns the filename"""
domain = self.get_domain()
filename = "%s.dot" % (self.__class__.__name__)
nx.write_dot(domain, filename)
return filename | [
"def",
"to_dotfile",
"(",
"self",
")",
":",
"domain",
"=",
"self",
".",
"get_domain",
"(",
")",
"filename",
"=",
"\"%s.dot\"",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"nx",
".",
"write_dot",
"(",
"domain",
",",
"filename",
")",
"retur... | Writes a DOT graphviz file of the domain structure, and returns the filename | [
"Writes",
"a",
"DOT",
"graphviz",
"file",
"of",
"the",
"domain",
"structure",
"and",
"returns",
"the",
"filename"
] | python | train |
cggh/scikit-allel | allel/stats/admixture.py | https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/admixture.py#L306-L373 | def average_patterson_f3(acc, aca, acb, blen, normed=True):
"""Estimate F3(C; A, B) and standard error using the block-jackknife.
Parameters
----------
acc : array_like, int, shape (n_variants, 2)
Allele counts for the test population (C).
aca : array_like, int, shape (n_variants, 2)
... | [
"def",
"average_patterson_f3",
"(",
"acc",
",",
"aca",
",",
"acb",
",",
"blen",
",",
"normed",
"=",
"True",
")",
":",
"# calculate per-variant values",
"T",
",",
"B",
"=",
"patterson_f3",
"(",
"acc",
",",
"aca",
",",
"acb",
")",
"# N.B., nans can occur if an... | Estimate F3(C; A, B) and standard error using the block-jackknife.
Parameters
----------
acc : array_like, int, shape (n_variants, 2)
Allele counts for the test population (C).
aca : array_like, int, shape (n_variants, 2)
Allele counts for the first source population (A).
acb : arra... | [
"Estimate",
"F3",
"(",
"C",
";",
"A",
"B",
")",
"and",
"standard",
"error",
"using",
"the",
"block",
"-",
"jackknife",
"."
] | python | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1561-L1604 | def __validate_simple_subfield(self, parameter, field, segment_list,
_segment_index=0):
"""Verifies that a proposed subfield actually exists and is a simple field.
Here, simple means it is not a MessageField (nested).
Args:
parameter: String; the '.' delimited name o... | [
"def",
"__validate_simple_subfield",
"(",
"self",
",",
"parameter",
",",
"field",
",",
"segment_list",
",",
"_segment_index",
"=",
"0",
")",
":",
"if",
"_segment_index",
">=",
"len",
"(",
"segment_list",
")",
":",
"# In this case, the field is the final one, so should... | Verifies that a proposed subfield actually exists and is a simple field.
Here, simple means it is not a MessageField (nested).
Args:
parameter: String; the '.' delimited name of the current field being
considered. This is relative to some root.
field: An instance of a subclass of message... | [
"Verifies",
"that",
"a",
"proposed",
"subfield",
"actually",
"exists",
"and",
"is",
"a",
"simple",
"field",
"."
] | python | train |
inspirehep/refextract | refextract/references/tag.py | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L182-L338 | def process_reference_line(working_line,
journals_matches,
pprint_repnum_len,
pprint_repnum_matchtext,
publishers_matches,
removed_spaces,
standardised_titles... | [
"def",
"process_reference_line",
"(",
"working_line",
",",
"journals_matches",
",",
"pprint_repnum_len",
",",
"pprint_repnum_matchtext",
",",
"publishers_matches",
",",
"removed_spaces",
",",
"standardised_titles",
",",
"kbs",
")",
":",
"if",
"len",
"(",
"journals_match... | After the phase of identifying and tagging citation instances
in a reference line, this function is called to go through the
line and the collected information about the recognised citations,
and to transform the line into a string of MARC XML in which the
recognised citations are grouped un... | [
"After",
"the",
"phase",
"of",
"identifying",
"and",
"tagging",
"citation",
"instances",
"in",
"a",
"reference",
"line",
"this",
"function",
"is",
"called",
"to",
"go",
"through",
"the",
"line",
"and",
"the",
"collected",
"information",
"about",
"the",
"recogn... | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/datetimefunc.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/datetimefunc.py#L165-L171 | def pendulum_date_to_datetime_date(x: Date) -> datetime.date:
"""
Takes a :class:`pendulum.Date` and returns a :class:`datetime.date`.
Used, for example, where a database backend insists on
:class:`datetime.date`.
"""
return datetime.date(year=x.year, month=x.month, day=x.day) | [
"def",
"pendulum_date_to_datetime_date",
"(",
"x",
":",
"Date",
")",
"->",
"datetime",
".",
"date",
":",
"return",
"datetime",
".",
"date",
"(",
"year",
"=",
"x",
".",
"year",
",",
"month",
"=",
"x",
".",
"month",
",",
"day",
"=",
"x",
".",
"day",
... | Takes a :class:`pendulum.Date` and returns a :class:`datetime.date`.
Used, for example, where a database backend insists on
:class:`datetime.date`. | [
"Takes",
"a",
":",
"class",
":",
"pendulum",
".",
"Date",
"and",
"returns",
"a",
":",
"class",
":",
"datetime",
".",
"date",
".",
"Used",
"for",
"example",
"where",
"a",
"database",
"backend",
"insists",
"on",
":",
"class",
":",
"datetime",
".",
"date"... | python | train |
Chilipp/psyplot | psyplot/config/rcsetup.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/config/rcsetup.py#L120-L164 | def add_base_str(self, base_str, pattern='.+', pattern_base=None,
append=True):
"""
Add further base string to this instance
Parameters
----------
base_str: str or list of str
Strings that are used as to look for keys to get and set keys in
... | [
"def",
"add_base_str",
"(",
"self",
",",
"base_str",
",",
"pattern",
"=",
"'.+'",
",",
"pattern_base",
"=",
"None",
",",
"append",
"=",
"True",
")",
":",
"base_str",
"=",
"safe_list",
"(",
"base_str",
")",
"pattern_base",
"=",
"safe_list",
"(",
"pattern_ba... | Add further base string to this instance
Parameters
----------
base_str: str or list of str
Strings that are used as to look for keys to get and set keys in
the :attr:`base` dictionary. If a string does not contain
``'%(key)s'``, it will be appended at the en... | [
"Add",
"further",
"base",
"string",
"to",
"this",
"instance"
] | python | train |
James1345/django-rest-knox | knox/auth.py | https://github.com/James1345/django-rest-knox/blob/05f218f1922999d1be76753076cf8af78f134e02/knox/auth.py#L56-L78 | def authenticate_credentials(self, token):
'''
Due to the random nature of hashing a salted value, this must inspect
each auth_token individually to find the correct one.
Tokens that have expired will be deleted and skipped
'''
msg = _('Invalid token.')
token = t... | [
"def",
"authenticate_credentials",
"(",
"self",
",",
"token",
")",
":",
"msg",
"=",
"_",
"(",
"'Invalid token.'",
")",
"token",
"=",
"token",
".",
"decode",
"(",
"\"utf-8\"",
")",
"for",
"auth_token",
"in",
"AuthToken",
".",
"objects",
".",
"filter",
"(",
... | Due to the random nature of hashing a salted value, this must inspect
each auth_token individually to find the correct one.
Tokens that have expired will be deleted and skipped | [
"Due",
"to",
"the",
"random",
"nature",
"of",
"hashing",
"a",
"salted",
"value",
"this",
"must",
"inspect",
"each",
"auth_token",
"individually",
"to",
"find",
"the",
"correct",
"one",
"."
] | python | train |
earlye/nephele | nephele/AwsAutoScalingGroup.py | https://github.com/earlye/nephele/blob/a7dadc68f4124671457f09119419978c4d22013e/nephele/AwsAutoScalingGroup.py#L181-L227 | def do_ssh(self,args):
"""SSH to an instance. ssh -h for detailed help"""
parser = CommandArgumentParser("ssh")
parser.add_argument(dest='instance',help='instance index or name');
parser.add_argument('-a','--address-number',default='0',dest='interface-number',help='instance id of the ins... | [
"def",
"do_ssh",
"(",
"self",
",",
"args",
")",
":",
"parser",
"=",
"CommandArgumentParser",
"(",
"\"ssh\"",
")",
"parser",
".",
"add_argument",
"(",
"dest",
"=",
"'instance'",
",",
"help",
"=",
"'instance index or name'",
")",
"parser",
".",
"add_argument",
... | SSH to an instance. ssh -h for detailed help | [
"SSH",
"to",
"an",
"instance",
".",
"ssh",
"-",
"h",
"for",
"detailed",
"help"
] | python | train |
annoviko/pyclustering | pyclustering/cluster/birch.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/birch.py#L156-L172 | def __extract_features(self):
"""!
@brief Extracts features from CF-tree cluster.
"""
self.__features = [];
if (len(self.__tree.leafes) == 1):
# parameters are too general, copy all entries
for entry in self.__tree.leaf... | [
"def",
"__extract_features",
"(",
"self",
")",
":",
"self",
".",
"__features",
"=",
"[",
"]",
"if",
"(",
"len",
"(",
"self",
".",
"__tree",
".",
"leafes",
")",
"==",
"1",
")",
":",
"# parameters are too general, copy all entries\r",
"for",
"entry",
"in",
"... | !
@brief Extracts features from CF-tree cluster. | [
"!"
] | python | valid |
swharden/SWHLab | doc/oldcode/swhlab/core/abf.py | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/abf.py#L432-L467 | def average_data(self,ranges=[[None,None]],percentile=None):
"""
given a list of ranges, return single point averages for every sweep.
Units are in seconds. Expects something like:
ranges=[[1,2],[4,5],[7,7.5]]
None values will be replaced with maximum/minimum bounds.
... | [
"def",
"average_data",
"(",
"self",
",",
"ranges",
"=",
"[",
"[",
"None",
",",
"None",
"]",
"]",
",",
"percentile",
"=",
"None",
")",
":",
"ranges",
"=",
"copy",
".",
"deepcopy",
"(",
"ranges",
")",
"#TODO: make this cleaner. Why needed?",
"# clean up ranges... | given a list of ranges, return single point averages for every sweep.
Units are in seconds. Expects something like:
ranges=[[1,2],[4,5],[7,7.5]]
None values will be replaced with maximum/minimum bounds.
For baseline subtraction, make a range baseline then sub it youtself.
... | [
"given",
"a",
"list",
"of",
"ranges",
"return",
"single",
"point",
"averages",
"for",
"every",
"sweep",
".",
"Units",
"are",
"in",
"seconds",
".",
"Expects",
"something",
"like",
":",
"ranges",
"=",
"[[",
"1",
"2",
"]",
"[",
"4",
"5",
"]",
"[",
"7",
... | python | valid |
RJT1990/pyflux | pyflux/families/laplace.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/laplace.py#L182-L197 | def logpdf(self, mu):
"""
Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu))
"""
if self.transform is not None:
mu = ... | [
"def",
"logpdf",
"(",
"self",
",",
"mu",
")",
":",
"if",
"self",
".",
"transform",
"is",
"not",
"None",
":",
"mu",
"=",
"self",
".",
"transform",
"(",
"mu",
")",
"return",
"ss",
".",
"laplace",
".",
"logpdf",
"(",
"mu",
",",
"loc",
"=",
"self",
... | Log PDF for Laplace prior
Parameters
----------
mu : float
Latent variable for which the prior is being formed over
Returns
----------
- log(p(mu)) | [
"Log",
"PDF",
"for",
"Laplace",
"prior"
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/tee.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/tee.py#L272-L286 | def close(self) -> None:
"""
To act as a file.
"""
if self.underlying_stream:
if self.using_stdout:
sys.stdout = self.underlying_stream
else:
sys.stderr = self.underlying_stream
self.underlying_stream = None
if s... | [
"def",
"close",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"underlying_stream",
":",
"if",
"self",
".",
"using_stdout",
":",
"sys",
".",
"stdout",
"=",
"self",
".",
"underlying_stream",
"else",
":",
"sys",
".",
"stderr",
"=",
"self",
".",
... | To act as a file. | [
"To",
"act",
"as",
"a",
"file",
"."
] | python | train |
inasafe/inasafe | safe/gui/tools/options_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L833-L843 | def save_default_values(self):
"""Save InaSAFE default values."""
for parameter_container in self.default_value_parameter_containers:
parameters = parameter_container.get_parameters()
for parameter in parameters:
set_inasafe_default_value_qsetting(
... | [
"def",
"save_default_values",
"(",
"self",
")",
":",
"for",
"parameter_container",
"in",
"self",
".",
"default_value_parameter_containers",
":",
"parameters",
"=",
"parameter_container",
".",
"get_parameters",
"(",
")",
"for",
"parameter",
"in",
"parameters",
":",
"... | Save InaSAFE default values. | [
"Save",
"InaSAFE",
"default",
"values",
"."
] | python | train |
ShenggaoZhu/midict | midict/__init__.py | https://github.com/ShenggaoZhu/midict/blob/2fad2edcfb753035b443a70fe15852affae1b5bb/midict/__init__.py#L1450-L1479 | def rename_index(self, *args):
'''change the index name(s).
* call with one argument:
1. list of new index names (to replace all old names)
* call with two arguments:
1. old index name(s) (or index/indices)
2. new index name(s)
'''
if len(arg... | [
"def",
"rename_index",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"new_indices",
"=",
"args",
"[",
"0",
"]",
"old_indices",
"=",
"force_list",
"(",
"self",
".",
"indices",
".",
"keys",
"(",
")",
")",
"... | change the index name(s).
* call with one argument:
1. list of new index names (to replace all old names)
* call with two arguments:
1. old index name(s) (or index/indices)
2. new index name(s) | [
"change",
"the",
"index",
"name",
"(",
"s",
")",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/pipdeptree.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pipdeptree.py#L113-L127 | def guess_version(pkg_key, default='?'):
"""Guess the version of a pkg when pip doesn't provide it
:param str pkg_key: key of the package
:param str default: default version to return if unable to find
:returns: version
:rtype: string
"""
try:
m = import_module(pkg_key)
except ... | [
"def",
"guess_version",
"(",
"pkg_key",
",",
"default",
"=",
"'?'",
")",
":",
"try",
":",
"m",
"=",
"import_module",
"(",
"pkg_key",
")",
"except",
"ImportError",
":",
"return",
"default",
"else",
":",
"return",
"getattr",
"(",
"m",
",",
"'__version__'",
... | Guess the version of a pkg when pip doesn't provide it
:param str pkg_key: key of the package
:param str default: default version to return if unable to find
:returns: version
:rtype: string | [
"Guess",
"the",
"version",
"of",
"a",
"pkg",
"when",
"pip",
"doesn",
"t",
"provide",
"it"
] | python | train |
hospadar/sqlite_object | sqlite_object/_sqlite_list.py | https://github.com/hospadar/sqlite_object/blob/a24a5d297f10a7d68b5f3e3b744654efb1eee9d4/sqlite_object/_sqlite_list.py#L198-L204 | def extend(self, iterable):
"""
Add each item from iterable to the end of the list
"""
with self.lock:
for item in iterable:
self.append(item) | [
"def",
"extend",
"(",
"self",
",",
"iterable",
")",
":",
"with",
"self",
".",
"lock",
":",
"for",
"item",
"in",
"iterable",
":",
"self",
".",
"append",
"(",
"item",
")"
] | Add each item from iterable to the end of the list | [
"Add",
"each",
"item",
"from",
"iterable",
"to",
"the",
"end",
"of",
"the",
"list"
] | python | train |
teepark/greenhouse | greenhouse/pool.py | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/pool.py#L36-L40 | def start(self):
"start the pool's workers"
for i in xrange(self.size):
scheduler.schedule(self._runner)
self._closing = False | [
"def",
"start",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"size",
")",
":",
"scheduler",
".",
"schedule",
"(",
"self",
".",
"_runner",
")",
"self",
".",
"_closing",
"=",
"False"
] | start the pool's workers | [
"start",
"the",
"pool",
"s",
"workers"
] | python | train |
google/grr | grr/server/grr_response_server/aff4.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L2393-L2409 | def ListChildren(self, limit=None, age=NEWEST_TIME):
"""Yields RDFURNs of all the children of this object.
Args:
limit: Total number of items we will attempt to retrieve.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range in microseconds.
Yields:
... | [
"def",
"ListChildren",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"age",
"=",
"NEWEST_TIME",
")",
":",
"# Just grab all the children from the index.",
"for",
"predicate",
",",
"timestamp",
"in",
"data_store",
".",
"DB",
".",
"AFF4FetchChildren",
"(",
"self",
"... | Yields RDFURNs of all the children of this object.
Args:
limit: Total number of items we will attempt to retrieve.
age: The age of the items to retrieve. Should be one of ALL_TIMES,
NEWEST_TIME or a range in microseconds.
Yields:
RDFURNs instances of each child. | [
"Yields",
"RDFURNs",
"of",
"all",
"the",
"children",
"of",
"this",
"object",
"."
] | python | train |
chrisspen/burlap | burlap/common.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/common.py#L890-L922 | def unregister(self):
"""
Removes this satchel from global registeries.
"""
for k in list(env.keys()):
if k.startswith(self.env_prefix):
del env[k]
try:
del all_satchels[self.name.upper()]
except KeyError:
pass
... | [
"def",
"unregister",
"(",
"self",
")",
":",
"for",
"k",
"in",
"list",
"(",
"env",
".",
"keys",
"(",
")",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"self",
".",
"env_prefix",
")",
":",
"del",
"env",
"[",
"k",
"]",
"try",
":",
"del",
"all_satc... | Removes this satchel from global registeries. | [
"Removes",
"this",
"satchel",
"from",
"global",
"registeries",
"."
] | python | valid |
ssato/python-anyconfig | src/anyconfig/cli.py | https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/cli.py#L309-L330 | def _output_result(cnf, outpath, otype, inpaths, itype,
extra_opts=None):
"""
:param cnf: Configuration object to print out
:param outpath: Output file path or None
:param otype: Output type or None
:param inpaths: List of input file paths
:param itype: Input type or None
... | [
"def",
"_output_result",
"(",
"cnf",
",",
"outpath",
",",
"otype",
",",
"inpaths",
",",
"itype",
",",
"extra_opts",
"=",
"None",
")",
":",
"fmsg",
"=",
"(",
"\"Uknown file type and cannot detect appropriate backend \"",
"\"from its extension, '%s'\"",
")",
"if",
"no... | :param cnf: Configuration object to print out
:param outpath: Output file path or None
:param otype: Output type or None
:param inpaths: List of input file paths
:param itype: Input type or None
:param extra_opts: Map object will be given to API.dump as extra options | [
":",
"param",
"cnf",
":",
"Configuration",
"object",
"to",
"print",
"out",
":",
"param",
"outpath",
":",
"Output",
"file",
"path",
"or",
"None",
":",
"param",
"otype",
":",
"Output",
"type",
"or",
"None",
":",
"param",
"inpaths",
":",
"List",
"of",
"in... | python | train |
jstitch/MambuPy | MambuPy/rest/mambuloan.py | https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuloan.py#L211-L247 | def setProduct(self, cache=False, *args, **kwargs):
"""Adds the product for this loan to a 'product' field.
Product is a MambuProduct object.
cache argument allows to use AllMambuProducts singleton to
retrieve the products. See mambuproduct.AllMambuProducts code
and pydoc for f... | [
"def",
"setProduct",
"(",
"self",
",",
"cache",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cache",
":",
"try",
":",
"prods",
"=",
"self",
".",
"allmambuproductsclass",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
... | Adds the product for this loan to a 'product' field.
Product is a MambuProduct object.
cache argument allows to use AllMambuProducts singleton to
retrieve the products. See mambuproduct.AllMambuProducts code
and pydoc for further information.
Returns the number of requests don... | [
"Adds",
"the",
"product",
"for",
"this",
"loan",
"to",
"a",
"product",
"field",
"."
] | python | train |
basho/riak-python-client | riak/datatypes/map.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/datatypes/map.py#L238-L249 | def value(self):
"""
Returns a copy of the original map's value. Nested values are
pure Python values as returned by :attr:`Datatype.value` from
the nested types.
:rtype: dict
"""
pvalue = {}
for key in self._value:
pvalue[key] = self._value[k... | [
"def",
"value",
"(",
"self",
")",
":",
"pvalue",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"_value",
":",
"pvalue",
"[",
"key",
"]",
"=",
"self",
".",
"_value",
"[",
"key",
"]",
".",
"value",
"return",
"pvalue"
] | Returns a copy of the original map's value. Nested values are
pure Python values as returned by :attr:`Datatype.value` from
the nested types.
:rtype: dict | [
"Returns",
"a",
"copy",
"of",
"the",
"original",
"map",
"s",
"value",
".",
"Nested",
"values",
"are",
"pure",
"Python",
"values",
"as",
"returned",
"by",
":",
"attr",
":",
"Datatype",
".",
"value",
"from",
"the",
"nested",
"types",
"."
] | python | train |
iotile/coretools | iotilesensorgraph/iotile/sg/node_descriptor.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/node_descriptor.py#L32-L84 | def parse_node_descriptor(desc, model):
"""Parse a string node descriptor.
The function creates an SGNode object without connecting its inputs and outputs
and returns a 3-tuple:
SGNode, [(input X, trigger X)], <processing function name>
Args:
desc (str): A description of the node to be cr... | [
"def",
"parse_node_descriptor",
"(",
"desc",
",",
"model",
")",
":",
"try",
":",
"data",
"=",
"graph_node",
".",
"parseString",
"(",
"desc",
")",
"except",
"ParseException",
":",
"raise",
"# TODO: Fix this to properly encapsulate the parse error",
"stream_desc",
"=",
... | Parse a string node descriptor.
The function creates an SGNode object without connecting its inputs and outputs
and returns a 3-tuple:
SGNode, [(input X, trigger X)], <processing function name>
Args:
desc (str): A description of the node to be created.
model (str): A device model for ... | [
"Parse",
"a",
"string",
"node",
"descriptor",
"."
] | python | train |
CyberZHG/keras-word-char-embd | keras_wc_embd/wrapper.py | https://github.com/CyberZHG/keras-word-char-embd/blob/cca6ddff01b6264dd0d12613bb9ed308e1367b8c/keras_wc_embd/wrapper.py#L47-L54 | def get_dicts(self):
"""Get word and character dictionaries.
:return word_dict, char_dict:
"""
if self.word_dict is None:
self.word_dict, self.char_dict, self.max_word_len = self.dict_generator(return_dict=True)
return self.word_dict, self.char_dict | [
"def",
"get_dicts",
"(",
"self",
")",
":",
"if",
"self",
".",
"word_dict",
"is",
"None",
":",
"self",
".",
"word_dict",
",",
"self",
".",
"char_dict",
",",
"self",
".",
"max_word_len",
"=",
"self",
".",
"dict_generator",
"(",
"return_dict",
"=",
"True",
... | Get word and character dictionaries.
:return word_dict, char_dict: | [
"Get",
"word",
"and",
"character",
"dictionaries",
"."
] | python | train |
saltstack/salt | salt/modules/supervisord.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/supervisord.py#L28-L49 | def _get_supervisorctl_bin(bin_env):
'''
Return supervisorctl command to call, either from a virtualenv, an argument
passed in, or from the global modules options
'''
cmd = 'supervisorctl'
if not bin_env:
which_result = __salt__['cmd.which_bin']([cmd])
if which_result is None:
... | [
"def",
"_get_supervisorctl_bin",
"(",
"bin_env",
")",
":",
"cmd",
"=",
"'supervisorctl'",
"if",
"not",
"bin_env",
":",
"which_result",
"=",
"__salt__",
"[",
"'cmd.which_bin'",
"]",
"(",
"[",
"cmd",
"]",
")",
"if",
"which_result",
"is",
"None",
":",
"raise",
... | Return supervisorctl command to call, either from a virtualenv, an argument
passed in, or from the global modules options | [
"Return",
"supervisorctl",
"command",
"to",
"call",
"either",
"from",
"a",
"virtualenv",
"an",
"argument",
"passed",
"in",
"or",
"from",
"the",
"global",
"modules",
"options"
] | python | train |
casacore/python-casacore | casacore/measures/__init__.py | https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/measures/__init__.py#L777-L805 | def rise(self, crd, ev='5deg'):
"""This method will give the rise/set hour-angles of a source. It
needs the position in the frame, and a time. If the latter is not
set, the current time will be used.
:param crd: a direction measure
:param ev: the elevation limit as a quantity or... | [
"def",
"rise",
"(",
"self",
",",
"crd",
",",
"ev",
"=",
"'5deg'",
")",
":",
"if",
"not",
"is_measure",
"(",
"crd",
")",
":",
"raise",
"TypeError",
"(",
"'No rise/set coordinates specified'",
")",
"ps",
"=",
"self",
".",
"_getwhere",
"(",
")",
"self",
"... | This method will give the rise/set hour-angles of a source. It
needs the position in the frame, and a time. If the latter is not
set, the current time will be used.
:param crd: a direction measure
:param ev: the elevation limit as a quantity or string
:returns: `dict` with rise ... | [
"This",
"method",
"will",
"give",
"the",
"rise",
"/",
"set",
"hour",
"-",
"angles",
"of",
"a",
"source",
".",
"It",
"needs",
"the",
"position",
"in",
"the",
"frame",
"and",
"a",
"time",
".",
"If",
"the",
"latter",
"is",
"not",
"set",
"the",
"current"... | python | train |
datasift/datasift-python | datasift/token.py | https://github.com/datasift/datasift-python/blob/bfaca1a47501a18e11065ecf630d9c31df818f65/datasift/token.py#L56-L71 | def update(self, identity_id, service, token=None):
""" Update the token
:param identity_id: The ID of the identity to retrieve
:return: dict of REST API output with headers attached
:rtype: :class:`~datasift.request.DictResponse`
:raises: :class:`~datasift.excep... | [
"def",
"update",
"(",
"self",
",",
"identity_id",
",",
"service",
",",
"token",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"token",
":",
"params",
"[",
"'token'",
"]",
"=",
"token",
"return",
"self",
".",
"request",
".",
"put",
"(",
"str... | Update the token
:param identity_id: The ID of the identity to retrieve
:return: dict of REST API output with headers attached
:rtype: :class:`~datasift.request.DictResponse`
:raises: :class:`~datasift.exceptions.DataSiftApiException`,
:class:`requests.ex... | [
"Update",
"the",
"token"
] | python | train |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L349-L383 | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | [
"def",
"long_alg",
"(",
"alg_str",
",",
"position",
")",
":",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<",
"4",
"or",
"len",
"(",
"alg_str",
")",
">",
"6",
":",
"raise",
"ValueError",
"(",
"\"Invalid string input {}\"",
".",
"f... | Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move | [
"Converts",
"a",
"string",
"written",
"in",
"long",
"algebraic",
"form",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"(",
"initial",
"location",
"specified",
")",
".",
"Used",
"primarily",
"for",
"UCI",
"but",
"can",
"be",
"us... | python | train |
pywbem/pywbem | pywbem/cim_operations.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_operations.py#L4581-L4849 | def IterEnumerateInstancePaths(self, ClassName, namespace=None,
FilterQueryLanguage=None, FilterQuery=None,
OperationTimeout=None, ContinueOnError=None,
MaxObjectCount=DEFAULT_ITER_MAXOBJECTCOUNT,
... | [
"def",
"IterEnumerateInstancePaths",
"(",
"self",
",",
"ClassName",
",",
"namespace",
"=",
"None",
",",
"FilterQueryLanguage",
"=",
"None",
",",
"FilterQuery",
"=",
"None",
",",
"OperationTimeout",
"=",
"None",
",",
"ContinueOnError",
"=",
"None",
",",
"MaxObjec... | Enumerate the instance paths of instances of a class (including
instances of its subclasses) in a namespace, using the
Python :term:`py:generator` idiom to return the result.
*New in pywbem 0.10 as experimental and finalized in 0.12.*
This method uses the corresponding pull operations ... | [
"Enumerate",
"the",
"instance",
"paths",
"of",
"instances",
"of",
"a",
"class",
"(",
"including",
"instances",
"of",
"its",
"subclasses",
")",
"in",
"a",
"namespace",
"using",
"the",
"Python",
":",
"term",
":",
"py",
":",
"generator",
"idiom",
"to",
"retur... | python | train |
CyberReboot/vent | vent/api/tools.py | https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/api/tools.py#L949-L980 | def repo_tools(self, repo, branch, version):
""" Get available tools for a repository branch at a version """
try:
tools = []
status = self.path_dirs.apply_path(repo)
# switch to directory where repo will be cloned to
if status[0]:
cwd = st... | [
"def",
"repo_tools",
"(",
"self",
",",
"repo",
",",
"branch",
",",
"version",
")",
":",
"try",
":",
"tools",
"=",
"[",
"]",
"status",
"=",
"self",
".",
"path_dirs",
".",
"apply_path",
"(",
"repo",
")",
"# switch to directory where repo will be cloned to",
"i... | Get available tools for a repository branch at a version | [
"Get",
"available",
"tools",
"for",
"a",
"repository",
"branch",
"at",
"a",
"version"
] | python | train |
web-push-libs/pywebpush | pywebpush/__init__.py | https://github.com/web-push-libs/pywebpush/blob/2a23f45b7819e31bd030de9fe1357a1cf7dcfdc4/pywebpush/__init__.py#L256-L347 | def send(self, data=None, headers=None, ttl=0, gcm_key=None, reg_id=None,
content_encoding="aes128gcm", curl=False, timeout=None):
"""Encode and send the data to the Push Service.
:param data: A serialized block of data (see encode() ).
:type data: str
:param headers: A dic... | [
"def",
"send",
"(",
"self",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"ttl",
"=",
"0",
",",
"gcm_key",
"=",
"None",
",",
"reg_id",
"=",
"None",
",",
"content_encoding",
"=",
"\"aes128gcm\"",
",",
"curl",
"=",
"False",
",",
"timeout"... | Encode and send the data to the Push Service.
:param data: A serialized block of data (see encode() ).
:type data: str
:param headers: A dictionary containing any additional HTTP headers.
:type headers: dict
:param ttl: The Time To Live in seconds for this message if the
... | [
"Encode",
"and",
"send",
"the",
"data",
"to",
"the",
"Push",
"Service",
"."
] | python | train |
gregmccoy/melissadata | melissadata/melissadata.py | https://github.com/gregmccoy/melissadata/blob/e610152c8ec98f673b9c7be4d359bfacdfde7c1e/melissadata/melissadata.py#L30-L79 | def verify_address(self, addr1="", addr2="", city="", fname="", lname="", phone="", province="", postal="", country="", email="", recordID="", freeform= ""):
"""verify_address
Builds a JSON request to send to Melissa data. Takes in all needed address info.
Args:
addr1 (str):Con... | [
"def",
"verify_address",
"(",
"self",
",",
"addr1",
"=",
"\"\"",
",",
"addr2",
"=",
"\"\"",
",",
"city",
"=",
"\"\"",
",",
"fname",
"=",
"\"\"",
",",
"lname",
"=",
"\"\"",
",",
"phone",
"=",
"\"\"",
",",
"province",
"=",
"\"\"",
",",
"postal",
"=",... | verify_address
Builds a JSON request to send to Melissa data. Takes in all needed address info.
Args:
addr1 (str):Contains info for Melissa data
addr2 (str):Contains info for Melissa data
city (str):Contains info for Melissa data
fname (s... | [
"verify_address"
] | python | train |
angr/angr | angr/sim_state.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/sim_state.py#L568-L587 | def copy(self):
"""
Returns a copy of the state.
"""
if self._global_condition is not None:
raise SimStateError("global condition was not cleared before state.copy().")
c_plugins = self._copy_plugins()
state = SimState(project=self.project, arch=self.arch, p... | [
"def",
"copy",
"(",
"self",
")",
":",
"if",
"self",
".",
"_global_condition",
"is",
"not",
"None",
":",
"raise",
"SimStateError",
"(",
"\"global condition was not cleared before state.copy().\"",
")",
"c_plugins",
"=",
"self",
".",
"_copy_plugins",
"(",
")",
"stat... | Returns a copy of the state. | [
"Returns",
"a",
"copy",
"of",
"the",
"state",
"."
] | python | train |
openstack/horizon | horizon/base.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L86-L101 | def _wrapped_include(arg):
"""Convert the old 3-tuple arg for include() into the new format.
The argument "arg" should be a tuple with 3 elements:
(pattern_list, app_namespace, instance_namespace)
Prior to Django 2.0, django.urls.conf.include() accepts 3-tuple arg
(urlconf, namespace, app_name), b... | [
"def",
"_wrapped_include",
"(",
"arg",
")",
":",
"pattern_list",
",",
"app_namespace",
",",
"instance_namespace",
"=",
"arg",
"return",
"include",
"(",
"(",
"pattern_list",
",",
"app_namespace",
")",
",",
"namespace",
"=",
"instance_namespace",
")"
] | Convert the old 3-tuple arg for include() into the new format.
The argument "arg" should be a tuple with 3 elements:
(pattern_list, app_namespace, instance_namespace)
Prior to Django 2.0, django.urls.conf.include() accepts 3-tuple arg
(urlconf, namespace, app_name), but it was droppped in Django 2.0.
... | [
"Convert",
"the",
"old",
"3",
"-",
"tuple",
"arg",
"for",
"include",
"()",
"into",
"the",
"new",
"format",
"."
] | python | train |
bjodah/pyodesys | pyodesys/core.py | https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L917-L996 | def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None,
integrate_kwargs=None, x0=None, npoints=1, numpy=None):
""" Integrate an ODE-system for a serie of durations with some parameters changed in-between
Parameters
----------
subject ... | [
"def",
"chained_parameter_variation",
"(",
"subject",
",",
"durations",
",",
"y0",
",",
"varied_params",
",",
"default_params",
"=",
"None",
",",
"integrate_kwargs",
"=",
"None",
",",
"x0",
"=",
"None",
",",
"npoints",
"=",
"1",
",",
"numpy",
"=",
"None",
... | Integrate an ODE-system for a serie of durations with some parameters changed in-between
Parameters
----------
subject : function or ODESys instance
If a function: should have the signature of :meth:`pyodesys.ODESys.integrate`
(and resturn a :class:`pyodesys.results.Result` object).
... | [
"Integrate",
"an",
"ODE",
"-",
"system",
"for",
"a",
"serie",
"of",
"durations",
"with",
"some",
"parameters",
"changed",
"in",
"-",
"between"
] | python | train |
gwastro/pycbc | pycbc/filter/matchedfilter.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/filter/matchedfilter.py#L1575-L1580 | def combine_results(self, results):
"""Combine results from different batches of filtering"""
result = {}
for key in results[0]:
result[key] = numpy.concatenate([r[key] for r in results])
return result | [
"def",
"combine_results",
"(",
"self",
",",
"results",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"results",
"[",
"0",
"]",
":",
"result",
"[",
"key",
"]",
"=",
"numpy",
".",
"concatenate",
"(",
"[",
"r",
"[",
"key",
"]",
"for",
"r",
... | Combine results from different batches of filtering | [
"Combine",
"results",
"from",
"different",
"batches",
"of",
"filtering"
] | python | train |
compmech/composites | composites/laminate.py | https://github.com/compmech/composites/blob/3c5d4fd6033898e35a5085063af5dbb81eb6a97d/composites/laminate.py#L289-L353 | def calc_lamination_parameters(self):
"""Calculate the lamination parameters.
The following attributes are calculated:
xiA, xiB, xiD, xiE
"""
if len(self.plies) == 0:
if self.xiA is None:
raise ValueError('Laminate with 0 plies!')
els... | [
"def",
"calc_lamination_parameters",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"plies",
")",
"==",
"0",
":",
"if",
"self",
".",
"xiA",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Laminate with 0 plies!'",
")",
"else",
":",
"return",
"xiA... | Calculate the lamination parameters.
The following attributes are calculated:
xiA, xiB, xiD, xiE | [
"Calculate",
"the",
"lamination",
"parameters",
"."
] | python | train |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwe/utils.py | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/utils.py#L98-L121 | def concat_sha256(secret, dk_len, other_info):
"""
The Concat KDF, using SHA256 as the hash function.
Note: Does not validate that otherInfo meets the requirements of
SP800-56A.
:param secret: The shared secret value
:param dk_len: Length of key to be derived, in bits
:param other_info: Ot... | [
"def",
"concat_sha256",
"(",
"secret",
",",
"dk_len",
",",
"other_info",
")",
":",
"dkm",
"=",
"b''",
"dk_bytes",
"=",
"int",
"(",
"ceil",
"(",
"dk_len",
"/",
"8.0",
")",
")",
"counter",
"=",
"0",
"while",
"len",
"(",
"dkm",
")",
"<",
"dk_bytes",
"... | The Concat KDF, using SHA256 as the hash function.
Note: Does not validate that otherInfo meets the requirements of
SP800-56A.
:param secret: The shared secret value
:param dk_len: Length of key to be derived, in bits
:param other_info: Other info to be incorporated (see SP800-56A)
:return: Th... | [
"The",
"Concat",
"KDF",
"using",
"SHA256",
"as",
"the",
"hash",
"function",
"."
] | python | train |
saltstack/salt | salt/states/boto_kinesis.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_kinesis.py#L78-L384 | def present(name,
retention_hours=None,
enhanced_monitoring=None,
num_shards=None,
do_reshard=True,
region=None,
key=None,
keyid=None,
profile=None):
'''
Ensure the kinesis stream is properly configured and scaled.
... | [
"def",
"present",
"(",
"name",
",",
"retention_hours",
"=",
"None",
",",
"enhanced_monitoring",
"=",
"None",
",",
"num_shards",
"=",
"None",
",",
"do_reshard",
"=",
"True",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
... | Ensure the kinesis stream is properly configured and scaled.
name (string)
Stream name
retention_hours (int)
Retain data for this many hours.
AWS allows minimum 24 hours, maximum 168 hours.
enhanced_monitoring (list of string)
Turn on enhanced monitoring for the specified ... | [
"Ensure",
"the",
"kinesis",
"stream",
"is",
"properly",
"configured",
"and",
"scaled",
"."
] | python | train |
pydsigner/taskit | taskit/frontend.py | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L73-L82 | def _sending_task(self, backend):
"""
Used internally to safely increment `backend`s task count. Returns the
overall count of tasks for `backend`.
"""
with self.backend_mutex:
self.backends[backend] += 1
self.task_counter[backend] += 1
this_ta... | [
"def",
"_sending_task",
"(",
"self",
",",
"backend",
")",
":",
"with",
"self",
".",
"backend_mutex",
":",
"self",
".",
"backends",
"[",
"backend",
"]",
"+=",
"1",
"self",
".",
"task_counter",
"[",
"backend",
"]",
"+=",
"1",
"this_task",
"=",
"self",
".... | Used internally to safely increment `backend`s task count. Returns the
overall count of tasks for `backend`. | [
"Used",
"internally",
"to",
"safely",
"increment",
"backend",
"s",
"task",
"count",
".",
"Returns",
"the",
"overall",
"count",
"of",
"tasks",
"for",
"backend",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/vasp/outputs.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/outputs.py#L593-L612 | def final_energy(self):
"""
Final energy from the vasp run.
"""
try:
final_istep = self.ionic_steps[-1]
if final_istep["e_wo_entrp"] != final_istep[
'electronic_steps'][-1]["e_0_energy"]:
warnings.warn("Final e_wo_entrp differs from... | [
"def",
"final_energy",
"(",
"self",
")",
":",
"try",
":",
"final_istep",
"=",
"self",
".",
"ionic_steps",
"[",
"-",
"1",
"]",
"if",
"final_istep",
"[",
"\"e_wo_entrp\"",
"]",
"!=",
"final_istep",
"[",
"'electronic_steps'",
"]",
"[",
"-",
"1",
"]",
"[",
... | Final energy from the vasp run. | [
"Final",
"energy",
"from",
"the",
"vasp",
"run",
"."
] | python | train |
Esri/ArcREST | src/arcrest/ags/_gpobjects.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_gpobjects.py#L193-L205 | def fromJSON(value):
"""loads the GP object from a JSON string """
j = json.loads(value)
v = GPFeatureRecordSetLayer()
if "defaultValue" in j:
v.value = j['defaultValue']
else:
v.value = j['value']
if 'paramName' in j:
v.paramName = j['... | [
"def",
"fromJSON",
"(",
"value",
")",
":",
"j",
"=",
"json",
".",
"loads",
"(",
"value",
")",
"v",
"=",
"GPFeatureRecordSetLayer",
"(",
")",
"if",
"\"defaultValue\"",
"in",
"j",
":",
"v",
".",
"value",
"=",
"j",
"[",
"'defaultValue'",
"]",
"else",
":... | loads the GP object from a JSON string | [
"loads",
"the",
"GP",
"object",
"from",
"a",
"JSON",
"string"
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/magnify.py#L83-L110 | def viewbox_mouse_event(self, event):
"""ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event.
"""
# When the attached ViewBox reseives a mouse event, it is sent to the
# camera here.
self.mouse_... | [
"def",
"viewbox_mouse_event",
"(",
"self",
",",
"event",
")",
":",
"# When the attached ViewBox reseives a mouse event, it is sent to the",
"# camera here.",
"self",
".",
"mouse_pos",
"=",
"event",
".",
"pos",
"[",
":",
"2",
"]",
"if",
"event",
".",
"type",
"==",
... | ViewBox mouse event handler
Parameters
----------
event : instance of Event
The mouse event. | [
"ViewBox",
"mouse",
"event",
"handler"
] | python | train |
HubSpot/hapipy | hapi/broadcast.py | https://github.com/HubSpot/hapipy/blob/6c492ec09aaa872b1b2177454b8c446678a0b9ed/hapi/broadcast.py#L108-L115 | def get_broadcast(self, broadcast_guid, **kwargs):
'''
Get a specific broadcast by guid
'''
params = kwargs
broadcast = self._call('broadcasts/%s' % broadcast_guid,
params=params, content_type='application/json')
return Broadcast(broadcast) | [
"def",
"get_broadcast",
"(",
"self",
",",
"broadcast_guid",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"kwargs",
"broadcast",
"=",
"self",
".",
"_call",
"(",
"'broadcasts/%s'",
"%",
"broadcast_guid",
",",
"params",
"=",
"params",
",",
"content_type",
... | Get a specific broadcast by guid | [
"Get",
"a",
"specific",
"broadcast",
"by",
"guid"
] | python | train |
astropy/photutils | photutils/segmentation/properties.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/segmentation/properties.py#L526-L539 | def sky_centroid(self):
"""
The sky coordinates of the centroid within the source segment,
returned as a `~astropy.coordinates.SkyCoord` object.
The output coordinate frame is the same as the input WCS.
"""
if self._wcs is not None:
return pixel_to_skycoord(... | [
"def",
"sky_centroid",
"(",
"self",
")",
":",
"if",
"self",
".",
"_wcs",
"is",
"not",
"None",
":",
"return",
"pixel_to_skycoord",
"(",
"self",
".",
"xcentroid",
".",
"value",
",",
"self",
".",
"ycentroid",
".",
"value",
",",
"self",
".",
"_wcs",
",",
... | The sky coordinates of the centroid within the source segment,
returned as a `~astropy.coordinates.SkyCoord` object.
The output coordinate frame is the same as the input WCS. | [
"The",
"sky",
"coordinates",
"of",
"the",
"centroid",
"within",
"the",
"source",
"segment",
"returned",
"as",
"a",
"~astropy",
".",
"coordinates",
".",
"SkyCoord",
"object",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L470-L494 | def can_create_catalog_with_record_types(self, catalog_record_types):
"""Tests if this user can create a single ``Catalog`` using the desired record types.
While ``CatalogingManager.getCatalogRecordTypes()`` can be used
to examine which records are supported, this method tests which
rec... | [
"def",
"can_create_catalog_with_record_types",
"(",
"self",
",",
"catalog_record_types",
")",
":",
"# Implemented from template for",
"# osid.resource.BinAdminSession.can_create_bin_with_record_types",
"# NOTE: It is expected that real authentication hints will be",
"# handled in a service ada... | Tests if this user can create a single ``Catalog`` using the desired record types.
While ``CatalogingManager.getCatalogRecordTypes()`` can be used
to examine which records are supported, this method tests which
record(s) are required for creating a specific ``Catalog``.
Providing an emp... | [
"Tests",
"if",
"this",
"user",
"can",
"create",
"a",
"single",
"Catalog",
"using",
"the",
"desired",
"record",
"types",
"."
] | python | train |
awickert/gFlex | gflex/f2d.py | https://github.com/awickert/gFlex/blob/3ac32249375b0f8d342a142585d86ea4d905a5a0/gflex/f2d.py#L248-L334 | def BC_Rigidity(self):
"""
Utility function to help implement boundary conditions by specifying
them for and applying them to the elastic thickness grid
"""
#########################################
# FLEXURAL RIGIDITY BOUNDARY CONDITIONS #
#########################################
# W... | [
"def",
"BC_Rigidity",
"(",
"self",
")",
":",
"#########################################",
"# FLEXURAL RIGIDITY BOUNDARY CONDITIONS #",
"#########################################",
"# West",
"if",
"self",
".",
"BC_W",
"==",
"'Periodic'",
":",
"self",
".",
"BC_Rigidity_W",
"=",... | Utility function to help implement boundary conditions by specifying
them for and applying them to the elastic thickness grid | [
"Utility",
"function",
"to",
"help",
"implement",
"boundary",
"conditions",
"by",
"specifying",
"them",
"for",
"and",
"applying",
"them",
"to",
"the",
"elastic",
"thickness",
"grid"
] | python | train |
dcramer/piplint | src/piplint/__init__.py | https://github.com/dcramer/piplint/blob/134b90f4c5adbeb1de73a8e507503d4b7544f6d2/src/piplint/__init__.py#L39-L204 | def check_requirements(requirement_files, strict=False, error_on_extras=False, verbose=False,
venv=None, do_colour=False):
"""
Given a list of requirements files, checks them against the installed
packages in the currentl environment. If any are missing, or do not fit
within the v... | [
"def",
"check_requirements",
"(",
"requirement_files",
",",
"strict",
"=",
"False",
",",
"error_on_extras",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"venv",
"=",
"None",
",",
"do_colour",
"=",
"False",
")",
":",
"colour",
"=",
"TextColours",
"(",
"... | Given a list of requirements files, checks them against the installed
packages in the currentl environment. If any are missing, or do not fit
within the version bounds, exits with a code of 1 and outputs information
about the missing dependency. | [
"Given",
"a",
"list",
"of",
"requirements",
"files",
"checks",
"them",
"against",
"the",
"installed",
"packages",
"in",
"the",
"currentl",
"environment",
".",
"If",
"any",
"are",
"missing",
"or",
"do",
"not",
"fit",
"within",
"the",
"version",
"bounds",
"exi... | python | train |
rigetti/pyquil | pyquil/quil.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/quil.py#L941-L974 | def merge_programs(prog_list):
"""
Merges a list of pyQuil programs into a single one by appending them in sequence.
If multiple programs in the list contain the same gate and/or noisy gate definition
with identical name, this definition will only be applied once. If different definitions
with the s... | [
"def",
"merge_programs",
"(",
"prog_list",
")",
":",
"definitions",
"=",
"[",
"gate",
"for",
"prog",
"in",
"prog_list",
"for",
"gate",
"in",
"Program",
"(",
"prog",
")",
".",
"defined_gates",
"]",
"seen",
"=",
"{",
"}",
"# Collect definitions in reverse order ... | Merges a list of pyQuil programs into a single one by appending them in sequence.
If multiple programs in the list contain the same gate and/or noisy gate definition
with identical name, this definition will only be applied once. If different definitions
with the same name appear multiple times in the progr... | [
"Merges",
"a",
"list",
"of",
"pyQuil",
"programs",
"into",
"a",
"single",
"one",
"by",
"appending",
"them",
"in",
"sequence",
".",
"If",
"multiple",
"programs",
"in",
"the",
"list",
"contain",
"the",
"same",
"gate",
"and",
"/",
"or",
"noisy",
"gate",
"de... | python | train |
kedder/ofxstatement | src/ofxstatement/statement.py | https://github.com/kedder/ofxstatement/blob/61f9dc1cfe6024874b859c8aec108b9d9acee57a/src/ofxstatement/statement.py#L166-L180 | def recalculate_balance(stmt):
"""Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement.
"""
total_amount = ... | [
"def",
"recalculate_balance",
"(",
"stmt",
")",
":",
"total_amount",
"=",
"sum",
"(",
"sl",
".",
"amount",
"for",
"sl",
"in",
"stmt",
".",
"lines",
")",
"stmt",
".",
"start_balance",
"=",
"stmt",
".",
"start_balance",
"or",
"D",
"(",
"0",
")",
"stmt",
... | Recalculate statement starting and ending dates and balances.
When starting balance is not available, it will be assumed to be 0.
This function can be used in statement parsers when balance information is
not available in source statement. | [
"Recalculate",
"statement",
"starting",
"and",
"ending",
"dates",
"and",
"balances",
"."
] | python | train |
rabitt/pysox | sox/transform.py | https://github.com/rabitt/pysox/blob/eae89bde74567136ec3f723c3e6b369916d9b837/sox/transform.py#L255-L380 | def set_output_format(self, file_type=None, rate=None, bits=None,
channels=None, encoding=None, comments=None,
append_comments=True):
'''Sets output file format arguments. These arguments will overwrite
any format related arguments supplied by other ef... | [
"def",
"set_output_format",
"(",
"self",
",",
"file_type",
"=",
"None",
",",
"rate",
"=",
"None",
",",
"bits",
"=",
"None",
",",
"channels",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"comments",
"=",
"None",
",",
"append_comments",
"=",
"True",
"... | Sets output file format arguments. These arguments will overwrite
any format related arguments supplied by other effects (e.g. rate).
If this function is not explicity called the output format is inferred
from the file extension or the file's header.
Parameters
----------
... | [
"Sets",
"output",
"file",
"format",
"arguments",
".",
"These",
"arguments",
"will",
"overwrite",
"any",
"format",
"related",
"arguments",
"supplied",
"by",
"other",
"effects",
"(",
"e",
".",
"g",
".",
"rate",
")",
"."
] | python | valid |
sernst/cauldron | cauldron/render/stack.py | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/stack.py#L67-L87 | def get_formatted_stack_frame(
project: 'projects.Project',
error_stack: bool = True
) -> list:
"""
Returns a list of the stack frames formatted for user display that has
been enriched by the project-specific data.
:param project:
The currently open project used to enrich t... | [
"def",
"get_formatted_stack_frame",
"(",
"project",
":",
"'projects.Project'",
",",
"error_stack",
":",
"bool",
"=",
"True",
")",
"->",
"list",
":",
"return",
"[",
"format_stack_frame",
"(",
"f",
",",
"project",
")",
"for",
"f",
"in",
"get_stack_frames",
"(",
... | Returns a list of the stack frames formatted for user display that has
been enriched by the project-specific data.
:param project:
The currently open project used to enrich the stack data.
:param error_stack:
Whether or not to return the error stack. When True the stack of the
... | [
"Returns",
"a",
"list",
"of",
"the",
"stack",
"frames",
"formatted",
"for",
"user",
"display",
"that",
"has",
"been",
"enriched",
"by",
"the",
"project",
"-",
"specific",
"data",
".",
":",
"param",
"project",
":",
"The",
"currently",
"open",
"project",
"us... | python | train |
watson-developer-cloud/python-sdk | ibm_watson/discovery_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/discovery_v1.py#L5276-L5298 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'document_id') and self.document_id is not None:
_dict['document_id'] = self.document_id
if hasattr(self,
'configuration_id') and self.configuration_id i... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'document_id'",
")",
"and",
"self",
".",
"document_id",
"is",
"not",
"None",
":",
"_dict",
"[",
"'document_id'",
"]",
"=",
"self",
".",
"document_id",... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.