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 |
|---|---|---|---|---|---|---|---|---|
neighbordog/deviantart | deviantart/api.py | https://github.com/neighbordog/deviantart/blob/5612f1d5e2139a48c9d793d7fd19cde7e162d7b1/deviantart/api.py#L962-L1009 | def update_user(self, user_is_artist="", artist_level="", artist_specialty="", real_name="", tagline="", countryid="", website="", bio=""):
"""Update the users profile information
:param user_is_artist: Is the user an artist?
:param artist_level: If the user is an artist, what level are they
... | [
"def",
"update_user",
"(",
"self",
",",
"user_is_artist",
"=",
"\"\"",
",",
"artist_level",
"=",
"\"\"",
",",
"artist_specialty",
"=",
"\"\"",
",",
"real_name",
"=",
"\"\"",
",",
"tagline",
"=",
"\"\"",
",",
"countryid",
"=",
"\"\"",
",",
"website",
"=",
... | Update the users profile information
:param user_is_artist: Is the user an artist?
:param artist_level: If the user is an artist, what level are they
:param artist_specialty: If the user is an artist, what is their specialty
:param real_name: The users real name
:param tagline: ... | [
"Update",
"the",
"users",
"profile",
"information"
] | python | train |
vtkiorg/vtki | vtki/renderer.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L748-L762 | def enable_eye_dome_lighting(self):
"""Enable eye dome lighting (EDL)"""
if hasattr(self, 'edl_pass'):
return self
# create the basic VTK render steps
basic_passes = vtk.vtkRenderStepsPass()
# blur the resulting image
# The blur delegates rendering the unblure... | [
"def",
"enable_eye_dome_lighting",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'edl_pass'",
")",
":",
"return",
"self",
"# create the basic VTK render steps",
"basic_passes",
"=",
"vtk",
".",
"vtkRenderStepsPass",
"(",
")",
"# blur the resulting image",... | Enable eye dome lighting (EDL) | [
"Enable",
"eye",
"dome",
"lighting",
"(",
"EDL",
")"
] | python | train |
JohannesBuchner/regulargrid | regulargrid/interpn.py | https://github.com/JohannesBuchner/regulargrid/blob/8803d8367c6b413d7a70ec474c67cc45ad8c00c8/regulargrid/interpn.py#L26-L46 | def npinterpn(*args, **kw):
"""Interpolation on N-D.
ai = interpn(x, y, z, ..., a, xi, yi, zi, ...)
where the arrays x, y, z, ... define a rectangular grid
and a.shape == (len(x), len(y), len(z), ...) are the values
interpolate at xi, yi, zi, ...
"""
method = kw.pop('method', 'cubic')
if kw:
raise ValueErro... | [
"def",
"npinterpn",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"method",
"=",
"kw",
".",
"pop",
"(",
"'method'",
",",
"'cubic'",
")",
"if",
"kw",
":",
"raise",
"ValueError",
"(",
"\"Unknown arguments: \"",
"%",
"kw",
".",
"keys",
"(",
")",
")... | Interpolation on N-D.
ai = interpn(x, y, z, ..., a, xi, yi, zi, ...)
where the arrays x, y, z, ... define a rectangular grid
and a.shape == (len(x), len(y), len(z), ...) are the values
interpolate at xi, yi, zi, ... | [
"Interpolation",
"on",
"N",
"-",
"D",
"."
] | python | train |
BoGoEngine/bogo-python | bogo/core.py | https://github.com/BoGoEngine/bogo-python/blob/9b85329a408ded4cead3539cecba12984d5d7650/bogo/core.py#L289-L329 | def _get_transformation_list(key, im, fallback_sequence):
"""
Return the list of transformations inferred from the entered key. The
map between transform types and keys is given by module
bogo_config (if exists) or by variable simple_telex_im
if entered key is not in im, return "+key", meaning appe... | [
"def",
"_get_transformation_list",
"(",
"key",
",",
"im",
",",
"fallback_sequence",
")",
":",
"# if key in im:",
"# lkey = key",
"# else:",
"# lkey = key.lower()",
"lkey",
"=",
"key",
".",
"lower",
"(",
")",
"if",
"lkey",
"in",
"im",
":",
"if",
"isinstan... | Return the list of transformations inferred from the entered key. The
map between transform types and keys is given by module
bogo_config (if exists) or by variable simple_telex_im
if entered key is not in im, return "+key", meaning appending
the entered key to current text | [
"Return",
"the",
"list",
"of",
"transformations",
"inferred",
"from",
"the",
"entered",
"key",
".",
"The",
"map",
"between",
"transform",
"types",
"and",
"keys",
"is",
"given",
"by",
"module",
"bogo_config",
"(",
"if",
"exists",
")",
"or",
"by",
"variable",
... | python | train |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/AnyValueArray.py | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/AnyValueArray.py#L82-L97 | def get_as_array(self, index):
"""
Converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.
:param index: an index of element to get.
:return: AnyValueArray value of the element or empty AnyValueArray if conversion is not supported.
... | [
"def",
"get_as_array",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"==",
"None",
":",
"array",
"=",
"[",
"]",
"for",
"value",
"in",
"self",
":",
"array",
".",
"append",
"(",
"value",
")",
"return",
"array",
"else",
":",
"value",
"=",
"self"... | Converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.
:param index: an index of element to get.
:return: AnyValueArray value of the element or empty AnyValueArray if conversion is not supported. | [
"Converts",
"array",
"element",
"into",
"an",
"AnyValueArray",
"or",
"returns",
"empty",
"AnyValueArray",
"if",
"conversion",
"is",
"not",
"possible",
"."
] | python | train |
praekeltfoundation/marathon-acme | marathon_acme/cli.py | https://github.com/praekeltfoundation/marathon-acme/blob/b1b71e3dde0ba30e575089280658bd32890e3325/marathon_acme/cli.py#L271-L283 | def init_logging(log_level):
"""
Initialise the logging by adding an observer to the global log publisher.
:param str log_level: The minimum log level to log messages for.
"""
log_level_filter = LogLevelFilterPredicate(
LogLevel.levelWithName(log_level))
log_level_filter.setLogLevelForN... | [
"def",
"init_logging",
"(",
"log_level",
")",
":",
"log_level_filter",
"=",
"LogLevelFilterPredicate",
"(",
"LogLevel",
".",
"levelWithName",
"(",
"log_level",
")",
")",
"log_level_filter",
".",
"setLogLevelForNamespace",
"(",
"'twisted.web.client._HTTP11ClientFactory'",
... | Initialise the logging by adding an observer to the global log publisher.
:param str log_level: The minimum log level to log messages for. | [
"Initialise",
"the",
"logging",
"by",
"adding",
"an",
"observer",
"to",
"the",
"global",
"log",
"publisher",
"."
] | python | valid |
ray-project/ray | python/ray/log_monitor.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L81-L88 | def close_all_files(self):
"""Close all open files (so that we can open more)."""
while len(self.open_file_infos) > 0:
file_info = self.open_file_infos.pop(0)
file_info.file_handle.close()
file_info.file_handle = None
self.closed_file_infos.append(file_inf... | [
"def",
"close_all_files",
"(",
"self",
")",
":",
"while",
"len",
"(",
"self",
".",
"open_file_infos",
")",
">",
"0",
":",
"file_info",
"=",
"self",
".",
"open_file_infos",
".",
"pop",
"(",
"0",
")",
"file_info",
".",
"file_handle",
".",
"close",
"(",
"... | Close all open files (so that we can open more). | [
"Close",
"all",
"open",
"files",
"(",
"so",
"that",
"we",
"can",
"open",
"more",
")",
"."
] | python | train |
aiogram/aiogram | aiogram/utils/callback_data.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/callback_data.py#L44-L81 | def new(self, *args, **kwargs) -> str:
"""
Generate callback data
:param args:
:param kwargs:
:return:
"""
args = list(args)
data = [self.prefix]
for part in self._part_names:
value = kwargs.pop(part, None)
if value is No... | [
"def",
"new",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"args",
"=",
"list",
"(",
"args",
")",
"data",
"=",
"[",
"self",
".",
"prefix",
"]",
"for",
"part",
"in",
"self",
".",
"_part_names",
":",
"value",
"="... | Generate callback data
:param args:
:param kwargs:
:return: | [
"Generate",
"callback",
"data"
] | python | train |
pandas-dev/pandas | pandas/core/internals/concat.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/internals/concat.py#L395-L421 | def trim_join_unit(join_unit, length):
"""
Reduce join_unit's shape along item axis to length.
Extra items that didn't fit are returned as a separate block.
"""
if 0 not in join_unit.indexers:
extra_indexers = join_unit.indexers
if join_unit.block is None:
extra_block ... | [
"def",
"trim_join_unit",
"(",
"join_unit",
",",
"length",
")",
":",
"if",
"0",
"not",
"in",
"join_unit",
".",
"indexers",
":",
"extra_indexers",
"=",
"join_unit",
".",
"indexers",
"if",
"join_unit",
".",
"block",
"is",
"None",
":",
"extra_block",
"=",
"Non... | Reduce join_unit's shape along item axis to length.
Extra items that didn't fit are returned as a separate block. | [
"Reduce",
"join_unit",
"s",
"shape",
"along",
"item",
"axis",
"to",
"length",
"."
] | python | train |
TheOstrichIO/ostrichlib | ostrich/utils/proc.py | https://github.com/TheOstrichIO/ostrichlib/blob/ed97634ccbfb8b5042e61fbd0ac9a27aef281bcb/ostrich/utils/proc.py#L122-L126 | def check_returncode(self):
"""Raise CalledProcessError if the exit code is non-zero."""
if self.returncode:
raise CalledProcessError(self.returncode, self.args, self.stdout,
self.stderr) | [
"def",
"check_returncode",
"(",
"self",
")",
":",
"if",
"self",
".",
"returncode",
":",
"raise",
"CalledProcessError",
"(",
"self",
".",
"returncode",
",",
"self",
".",
"args",
",",
"self",
".",
"stdout",
",",
"self",
".",
"stderr",
")"
] | Raise CalledProcessError if the exit code is non-zero. | [
"Raise",
"CalledProcessError",
"if",
"the",
"exit",
"code",
"is",
"non",
"-",
"zero",
"."
] | python | train |
osrg/ryu | ryu/services/protocols/bgp/utils/validation.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/utils/validation.py#L39-L51 | def is_valid_ip_prefix(prefix, bits):
"""Returns True if *prefix* is a valid IPv4 or IPv6 address prefix.
*prefix* should be a number between 0 to *bits* length.
"""
try:
# Prefix should be a number
prefix = int(prefix)
except ValueError:
return False
# Prefix should be... | [
"def",
"is_valid_ip_prefix",
"(",
"prefix",
",",
"bits",
")",
":",
"try",
":",
"# Prefix should be a number",
"prefix",
"=",
"int",
"(",
"prefix",
")",
"except",
"ValueError",
":",
"return",
"False",
"# Prefix should be a number between 0 to *bits*",
"return",
"0",
... | Returns True if *prefix* is a valid IPv4 or IPv6 address prefix.
*prefix* should be a number between 0 to *bits* length. | [
"Returns",
"True",
"if",
"*",
"prefix",
"*",
"is",
"a",
"valid",
"IPv4",
"or",
"IPv6",
"address",
"prefix",
"."
] | python | train |
matousc89/padasip | padasip/misc/error_evaluation.py | https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/misc/error_evaluation.py#L221-L246 | def get_mean_error(x1, x2=-1, function="MSE"):
"""
This function returns desired mean error. Options are: MSE, MAE, RMSE
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this shou... | [
"def",
"get_mean_error",
"(",
"x1",
",",
"x2",
"=",
"-",
"1",
",",
"function",
"=",
"\"MSE\"",
")",
":",
"if",
"function",
"==",
"\"MSE\"",
":",
"return",
"MSE",
"(",
"x1",
",",
"x2",
")",
"elif",
"function",
"==",
"\"MAE\"",
":",
"return",
"MAE",
... | This function returns desired mean error. Options are: MSE, MAE, RMSE
**Args:**
* `x1` - first data series or error (1d array)
**Kwargs:**
* `x2` - second series (1d array) if first series was not error directly,\\
then this should be the second series
**Returns:**
* `e` - mean... | [
"This",
"function",
"returns",
"desired",
"mean",
"error",
".",
"Options",
"are",
":",
"MSE",
"MAE",
"RMSE",
"**",
"Args",
":",
"**"
] | python | train |
pinterest/pymemcache | pymemcache/client/base.py | https://github.com/pinterest/pymemcache/blob/f3a348f4ce2248cce8b398e93e08d984fb9100e5/pymemcache/client/base.py#L382-L399 | def append(self, key, value, expire=0, noreply=None):
"""
The memcached "append" command.
Args:
key: str, see class docs for details.
value: str, see class docs for details.
expire: optional int, number of seconds until the item is expired
from th... | [
"def",
"append",
"(",
"self",
",",
"key",
",",
"value",
",",
"expire",
"=",
"0",
",",
"noreply",
"=",
"None",
")",
":",
"if",
"noreply",
"is",
"None",
":",
"noreply",
"=",
"self",
".",
"default_noreply",
"return",
"self",
".",
"_store_cmd",
"(",
"b'a... | The memcached "append" command.
Args:
key: str, see class docs for details.
value: str, see class docs for details.
expire: optional int, number of seconds until the item is expired
from the cache, or zero for no expiry (the default).
noreply: optional ... | [
"The",
"memcached",
"append",
"command",
"."
] | python | train |
swharden/SWHLab | swhlab/common.py | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/common.py#L97-L108 | def timeit(timer=None):
"""simple timer. returns a time object, or a string."""
if timer is None:
return time.time()
else:
took=time.time()-timer
if took<1:
return "%.02f ms"%(took*1000.0)
elif took<60:
return "%.02f s"%(took)
else:
... | [
"def",
"timeit",
"(",
"timer",
"=",
"None",
")",
":",
"if",
"timer",
"is",
"None",
":",
"return",
"time",
".",
"time",
"(",
")",
"else",
":",
"took",
"=",
"time",
".",
"time",
"(",
")",
"-",
"timer",
"if",
"took",
"<",
"1",
":",
"return",
"\"%.... | simple timer. returns a time object, or a string. | [
"simple",
"timer",
".",
"returns",
"a",
"time",
"object",
"or",
"a",
"string",
"."
] | python | valid |
projectatomic/osbs-client | osbs/core.py | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L326-L334 | def get_all_build_configs_by_labels(self, label_selectors):
"""
Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results.
"""
labels = ['%s=%s' % (field, value) for field, value in label_selectors]
labels = ','.joi... | [
"def",
"get_all_build_configs_by_labels",
"(",
"self",
",",
"label_selectors",
")",
":",
"labels",
"=",
"[",
"'%s=%s'",
"%",
"(",
"field",
",",
"value",
")",
"for",
"field",
",",
"value",
"in",
"label_selectors",
"]",
"labels",
"=",
"','",
".",
"join",
"("... | Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results. | [
"Returns",
"all",
"builds",
"matching",
"a",
"given",
"set",
"of",
"label",
"selectors",
".",
"It",
"is",
"up",
"to",
"the",
"calling",
"function",
"to",
"filter",
"the",
"results",
"."
] | python | train |
singularityhub/singularity-cli | spython/instance/cmd/iutils.py | https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/instance/cmd/iutils.py#L9-L33 | def parse_table(table_string, header, remove_rows=1):
'''parse a table to json from a string, where a header is expected by default.
Return a jsonified table.
Parameters
==========
table_string: the string table, ideally with a header
header: header of expected table, must match ... | [
"def",
"parse_table",
"(",
"table_string",
",",
"header",
",",
"remove_rows",
"=",
"1",
")",
":",
"rows",
"=",
"[",
"x",
"for",
"x",
"in",
"table_string",
".",
"split",
"(",
"'\\n'",
")",
"if",
"x",
"]",
"rows",
"=",
"rows",
"[",
"0",
"+",
"remove_... | parse a table to json from a string, where a header is expected by default.
Return a jsonified table.
Parameters
==========
table_string: the string table, ideally with a header
header: header of expected table, must match dimension (number columns)
remove_rows: an integer to ... | [
"parse",
"a",
"table",
"to",
"json",
"from",
"a",
"string",
"where",
"a",
"header",
"is",
"expected",
"by",
"default",
".",
"Return",
"a",
"jsonified",
"table",
"."
] | python | train |
iotile/coretools | iotileemulate/iotile/emulate/reference/controller_features/config_database.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/reference/controller_features/config_database.py#L109-L122 | def compact(self):
"""Remove all invalid config entries."""
saved_length = 0
to_remove = []
for i, entry in enumerate(self.entries):
if not entry.valid:
to_remove.append(i)
saved_length += entry.data_space()
for i in reversed(to_remov... | [
"def",
"compact",
"(",
"self",
")",
":",
"saved_length",
"=",
"0",
"to_remove",
"=",
"[",
"]",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"self",
".",
"entries",
")",
":",
"if",
"not",
"entry",
".",
"valid",
":",
"to_remove",
".",
"append",
... | Remove all invalid config entries. | [
"Remove",
"all",
"invalid",
"config",
"entries",
"."
] | python | train |
beetbox/audioread | audioread/macca.py | https://github.com/beetbox/audioread/blob/c8bedf7880f13a7b7488b108aaf245d648674818/audioread/macca.py#L281-L297 | def setup(self, bitdepth=16):
"""Set the client format parameters, specifying the desired PCM
audio data format to be read from the file. Must be called
before reading from the file.
"""
fmt = self.get_file_format()
newfmt = copy.copy(fmt)
newfmt.mFormatID = AUDI... | [
"def",
"setup",
"(",
"self",
",",
"bitdepth",
"=",
"16",
")",
":",
"fmt",
"=",
"self",
".",
"get_file_format",
"(",
")",
"newfmt",
"=",
"copy",
".",
"copy",
"(",
"fmt",
")",
"newfmt",
".",
"mFormatID",
"=",
"AUDIO_ID_PCM",
"newfmt",
".",
"mFormatFlags"... | Set the client format parameters, specifying the desired PCM
audio data format to be read from the file. Must be called
before reading from the file. | [
"Set",
"the",
"client",
"format",
"parameters",
"specifying",
"the",
"desired",
"PCM",
"audio",
"data",
"format",
"to",
"be",
"read",
"from",
"the",
"file",
".",
"Must",
"be",
"called",
"before",
"reading",
"from",
"the",
"file",
"."
] | python | train |
shoebot/shoebot | lib/photobot/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/photobot/__init__.py#L486-L524 | def mask(self):
"""Masks the layer below with this layer.
Commits the current layer to the alpha channel of
the previous layer. Primarily, mask() is useful when
using gradient layers as masks on images below.
For example:
canvas.layer("image.jpg")
... | [
"def",
"mask",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"canvas",
".",
"layers",
")",
"<",
"2",
":",
"return",
"i",
"=",
"self",
".",
"index",
"(",
")",
"if",
"i",
"==",
"0",
":",
"return",
"layer",
"=",
"self",
".",
"canvas",
".... | Masks the layer below with this layer.
Commits the current layer to the alpha channel of
the previous layer. Primarily, mask() is useful when
using gradient layers as masks on images below.
For example:
canvas.layer("image.jpg")
canvas.gradient()
canv... | [
"Masks",
"the",
"layer",
"below",
"with",
"this",
"layer",
".",
"Commits",
"the",
"current",
"layer",
"to",
"the",
"alpha",
"channel",
"of",
"the",
"previous",
"layer",
".",
"Primarily",
"mask",
"()",
"is",
"useful",
"when",
"using",
"gradient",
"layers",
... | python | valid |
SCIP-Interfaces/PySCIPOpt | examples/unfinished/flp_nonlinear.py | https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/unfinished/flp_nonlinear.py#L22-L73 | def flp_nonlinear_mselect(I,J,d,M,f,c,K):
"""flp_nonlinear_mselect -- use multiple selection model
Parameters:
- I: set of customers
- J: set of facilities
- d[i]: demand for customer i
- M[j]: capacity of facility j
- f[j]: fixed cost for using a facility in point j
... | [
"def",
"flp_nonlinear_mselect",
"(",
"I",
",",
"J",
",",
"d",
",",
"M",
",",
"f",
",",
"c",
",",
"K",
")",
":",
"a",
",",
"b",
"=",
"{",
"}",
",",
"{",
"}",
"for",
"j",
"in",
"J",
":",
"U",
"=",
"M",
"[",
"j",
"]",
"L",
"=",
"0",
"wid... | flp_nonlinear_mselect -- use multiple selection model
Parameters:
- I: set of customers
- J: set of facilities
- d[i]: demand for customer i
- M[j]: capacity of facility j
- f[j]: fixed cost for using a facility in point j
- c[i,j]: unit cost of servicing demand poin... | [
"flp_nonlinear_mselect",
"--",
"use",
"multiple",
"selection",
"model",
"Parameters",
":",
"-",
"I",
":",
"set",
"of",
"customers",
"-",
"J",
":",
"set",
"of",
"facilities",
"-",
"d",
"[",
"i",
"]",
":",
"demand",
"for",
"customer",
"i",
"-",
"M",
"[",... | python | train |
fastai/fastai | fastai/callback.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/callback.py#L358-L360 | def annealing_linear(start:Number, end:Number, pct:float)->Number:
"Linearly anneal from `start` to `end` as pct goes from 0.0 to 1.0."
return start + pct * (end-start) | [
"def",
"annealing_linear",
"(",
"start",
":",
"Number",
",",
"end",
":",
"Number",
",",
"pct",
":",
"float",
")",
"->",
"Number",
":",
"return",
"start",
"+",
"pct",
"*",
"(",
"end",
"-",
"start",
")"
] | Linearly anneal from `start` to `end` as pct goes from 0.0 to 1.0. | [
"Linearly",
"anneal",
"from",
"start",
"to",
"end",
"as",
"pct",
"goes",
"from",
"0",
".",
"0",
"to",
"1",
".",
"0",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/assessment/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/managers.py#L2860-L2877 | def get_assessment_taken_bank_session(self, proxy):
"""Gets the session for retrieving taken assessments to bank mappings.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.assessment.AssessmentTakenBankSession) - an
``AssessmentTakenBankSession``
raise: NullArgum... | [
"def",
"get_assessment_taken_bank_session",
"(",
"self",
",",
"proxy",
")",
":",
"if",
"not",
"self",
".",
"supports_assessment_taken_bank",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
... | Gets the session for retrieving taken assessments to bank mappings.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.assessment.AssessmentTakenBankSession) - an
``AssessmentTakenBankSession``
raise: NullArgument - ``proxy`` is ``null``
raise: OperationFailed - u... | [
"Gets",
"the",
"session",
"for",
"retrieving",
"taken",
"assessments",
"to",
"bank",
"mappings",
"."
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L4888-L4894 | def getOverlayTransformTrackedDeviceComponent(self, ulOverlayHandle, pchComponentName, unComponentNameSize):
"""Gets the transform information when the overlay is rendering on a component."""
fn = self.function_table.getOverlayTransformTrackedDeviceComponent
punDeviceIndex = TrackedDeviceIndex_... | [
"def",
"getOverlayTransformTrackedDeviceComponent",
"(",
"self",
",",
"ulOverlayHandle",
",",
"pchComponentName",
",",
"unComponentNameSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOverlayTransformTrackedDeviceComponent",
"punDeviceIndex",
"=",
"Tracke... | Gets the transform information when the overlay is rendering on a component. | [
"Gets",
"the",
"transform",
"information",
"when",
"the",
"overlay",
"is",
"rendering",
"on",
"a",
"component",
"."
] | python | train |
globus/globus-cli | globus_cli/parsing/shared_options.py | https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/parsing/shared_options.py#L664-L753 | def server_add_and_update_opts(*args, **kwargs):
"""
shared collection of options for `globus transfer endpoint server add` and
`globus transfer endpoint server update`.
Accepts a toggle to know if it's being used as `add` or `update`.
usage:
>>> @server_add_and_update_opts
>>> def command... | [
"def",
"server_add_and_update_opts",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"port_range_callback",
"(",
"ctx",
",",
"param",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"value",
"=",
"value",
".",
"lower",
... | shared collection of options for `globus transfer endpoint server add` and
`globus transfer endpoint server update`.
Accepts a toggle to know if it's being used as `add` or `update`.
usage:
>>> @server_add_and_update_opts
>>> def command_func(subject, port, scheme, hostname):
>>> ...
... | [
"shared",
"collection",
"of",
"options",
"for",
"globus",
"transfer",
"endpoint",
"server",
"add",
"and",
"globus",
"transfer",
"endpoint",
"server",
"update",
".",
"Accepts",
"a",
"toggle",
"to",
"know",
"if",
"it",
"s",
"being",
"used",
"as",
"add",
"or",
... | python | train |
singingwolfboy/flask-dance | flask_dance/utils.py | https://github.com/singingwolfboy/flask-dance/blob/87d45328bbdaff833559a6d3da71461fe4579592/flask_dance/utils.py#L82-L92 | def timestamp_from_datetime(dt):
"""
Given a datetime, in UTC, return a float that represents the timestamp for
that datetime.
http://stackoverflow.com/questions/8777753/converting-datetime-date-to-utc-timestamp-in-python#8778548
"""
dt = dt.replace(tzinfo=utc)
if hasattr(dt, "timestamp") a... | [
"def",
"timestamp_from_datetime",
"(",
"dt",
")",
":",
"dt",
"=",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"utc",
")",
"if",
"hasattr",
"(",
"dt",
",",
"\"timestamp\"",
")",
"and",
"callable",
"(",
"dt",
".",
"timestamp",
")",
":",
"return",
"dt",
"... | Given a datetime, in UTC, return a float that represents the timestamp for
that datetime.
http://stackoverflow.com/questions/8777753/converting-datetime-date-to-utc-timestamp-in-python#8778548 | [
"Given",
"a",
"datetime",
"in",
"UTC",
"return",
"a",
"float",
"that",
"represents",
"the",
"timestamp",
"for",
"that",
"datetime",
"."
] | python | train |
thunder-project/thunder | thunder/series/series.py | https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L914-L943 | def convolve(self, signal, mode='full'):
"""
Convolve series data against another signal.
Parameters
----------
signal : array
Signal to convolve with (must be 1D)
mode : str, optional, default='full'
Mode of convolution, options are 'full', 'sam... | [
"def",
"convolve",
"(",
"self",
",",
"signal",
",",
"mode",
"=",
"'full'",
")",
":",
"from",
"numpy",
"import",
"convolve",
"s",
"=",
"asarray",
"(",
"signal",
")",
"n",
"=",
"size",
"(",
"self",
".",
"index",
")",
"m",
"=",
"size",
"(",
"s",
")"... | Convolve series data against another signal.
Parameters
----------
signal : array
Signal to convolve with (must be 1D)
mode : str, optional, default='full'
Mode of convolution, options are 'full', 'same', and 'valid' | [
"Convolve",
"series",
"data",
"against",
"another",
"signal",
"."
] | python | train |
pallets/werkzeug | src/werkzeug/http.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/http.py#L1086-L1219 | def dump_cookie(
key,
value="",
max_age=None,
expires=None,
path="/",
domain=None,
secure=False,
httponly=False,
charset="utf-8",
sync_expires=True,
max_size=4093,
samesite=None,
):
"""Creates a new Set-Cookie header without the ``Set-Cookie`` prefix
The parameter... | [
"def",
"dump_cookie",
"(",
"key",
",",
"value",
"=",
"\"\"",
",",
"max_age",
"=",
"None",
",",
"expires",
"=",
"None",
",",
"path",
"=",
"\"/\"",
",",
"domain",
"=",
"None",
",",
"secure",
"=",
"False",
",",
"httponly",
"=",
"False",
",",
"charset",
... | Creates a new Set-Cookie header without the ``Set-Cookie`` prefix
The parameters are the same as in the cookie Morsel object in the
Python standard library but it accepts unicode data, too.
On Python 3 the return value of this function will be a unicode
string, on Python 2 it will be a native string. ... | [
"Creates",
"a",
"new",
"Set",
"-",
"Cookie",
"header",
"without",
"the",
"Set",
"-",
"Cookie",
"prefix",
"The",
"parameters",
"are",
"the",
"same",
"as",
"in",
"the",
"cookie",
"Morsel",
"object",
"in",
"the",
"Python",
"standard",
"library",
"but",
"it",
... | python | train |
kata198/indexedredis | IndexedRedis/fields/foreign.py | https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L231-L240 | def isFetched(self):
'''
isFetched - @see ForeignLinkData.isFetched
'''
if not self.obj:
return False
if not self.pk or None in self.obj:
return False
return not bool(self.obj is None) | [
"def",
"isFetched",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"obj",
":",
"return",
"False",
"if",
"not",
"self",
".",
"pk",
"or",
"None",
"in",
"self",
".",
"obj",
":",
"return",
"False",
"return",
"not",
"bool",
"(",
"self",
".",
"obj",
... | isFetched - @see ForeignLinkData.isFetched | [
"isFetched",
"-"
] | python | valid |
vtkiorg/vtki | vtki/common.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L460-L494 | def _cell_scalar(self, name=None):
"""
Returns the cell scalars of a vtk object
Parameters
----------
name : str
Name of cell scalars to retrive.
Returns
-------
scalars : np.ndarray
Numpy array of scalars
"""
if ... | [
"def",
"_cell_scalar",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"# use active scalar array",
"field",
",",
"name",
"=",
"self",
".",
"active_scalar_info",
"if",
"field",
"!=",
"CELL_DATA_FIELD",
":",
"raise",
"Runtime... | Returns the cell scalars of a vtk object
Parameters
----------
name : str
Name of cell scalars to retrive.
Returns
-------
scalars : np.ndarray
Numpy array of scalars | [
"Returns",
"the",
"cell",
"scalars",
"of",
"a",
"vtk",
"object"
] | python | train |
tommikaikkonen/prettyprinter | prettyprinter/__init__.py | https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/__init__.py#L110-L139 | def pformat(
object,
indent=_UNSET_SENTINEL,
width=_UNSET_SENTINEL,
depth=_UNSET_SENTINEL,
*,
ribbon_width=_UNSET_SENTINEL,
max_seq_len=_UNSET_SENTINEL,
compact=_UNSET_SENTINEL,
sort_dict_keys=_UNSET_SENTINEL
):
"""
Returns a pretty printed representation of the object as a `... | [
"def",
"pformat",
"(",
"object",
",",
"indent",
"=",
"_UNSET_SENTINEL",
",",
"width",
"=",
"_UNSET_SENTINEL",
",",
"depth",
"=",
"_UNSET_SENTINEL",
",",
"*",
",",
"ribbon_width",
"=",
"_UNSET_SENTINEL",
",",
"max_seq_len",
"=",
"_UNSET_SENTINEL",
",",
"compact",... | Returns a pretty printed representation of the object as a ``str``.
Accepts the same parameters as :func:`~prettyprinter.pprint`.
The output is not colored. | [
"Returns",
"a",
"pretty",
"printed",
"representation",
"of",
"the",
"object",
"as",
"a",
"str",
".",
"Accepts",
"the",
"same",
"parameters",
"as",
":",
"func",
":",
"~prettyprinter",
".",
"pprint",
".",
"The",
"output",
"is",
"not",
"colored",
"."
] | python | train |
hydpy-dev/hydpy | hydpy/core/auxfiletools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/auxfiletools.py#L595-L611 | def get_filename(self, variable):
"""Return the auxiliary file name the given variable is allocated
to or |None| if the given variable is not allocated to any
auxiliary file name.
>>> from hydpy import dummies
>>> eqb = dummies.v2af.eqb[0]
>>> dummies.v2af.get_filename(e... | [
"def",
"get_filename",
"(",
"self",
",",
"variable",
")",
":",
"fn2var",
"=",
"self",
".",
"_type2filename2variable",
".",
"get",
"(",
"type",
"(",
"variable",
")",
",",
"{",
"}",
")",
"for",
"(",
"fn_",
",",
"var",
")",
"in",
"fn2var",
".",
"items",... | Return the auxiliary file name the given variable is allocated
to or |None| if the given variable is not allocated to any
auxiliary file name.
>>> from hydpy import dummies
>>> eqb = dummies.v2af.eqb[0]
>>> dummies.v2af.get_filename(eqb)
'file1'
>>> eqb += 500.0
... | [
"Return",
"the",
"auxiliary",
"file",
"name",
"the",
"given",
"variable",
"is",
"allocated",
"to",
"or",
"|None|",
"if",
"the",
"given",
"variable",
"is",
"not",
"allocated",
"to",
"any",
"auxiliary",
"file",
"name",
"."
] | python | train |
CityOfZion/neo-python | neo/Wallets/NEP5Token.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Wallets/NEP5Token.py#L255-L276 | def Mint(self, wallet, mint_to_addr, attachment_args, invoke_attrs=None):
"""
Call the "mintTokens" function of the smart contract.
Args:
wallet (neo.Wallets.Wallet): a wallet instance.
mint_to_addr (str): public address of the account to mint the tokens to.
... | [
"def",
"Mint",
"(",
"self",
",",
"wallet",
",",
"mint_to_addr",
",",
"attachment_args",
",",
"invoke_attrs",
"=",
"None",
")",
":",
"invoke_args",
"=",
"[",
"self",
".",
"ScriptHash",
".",
"ToString",
"(",
")",
",",
"'mintTokens'",
",",
"[",
"]",
"]",
... | Call the "mintTokens" function of the smart contract.
Args:
wallet (neo.Wallets.Wallet): a wallet instance.
mint_to_addr (str): public address of the account to mint the tokens to.
attachment_args: (list): a list of arguments used to attach neo and/or gas to an invoke, eg ['... | [
"Call",
"the",
"mintTokens",
"function",
"of",
"the",
"smart",
"contract",
"."
] | python | train |
Yelp/kafka-utils | kafka_utils/util/zookeeper.py | https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/util/zookeeper.py#L529-L547 | def get_cluster_plan(self):
"""Fetch cluster plan from zookeeper."""
_log.info('Fetching current cluster-topology from Zookeeper...')
cluster_layout = self.get_topics(fetch_partition_state=False)
# Re-format cluster-layout
partitions = [
{
'topic': to... | [
"def",
"get_cluster_plan",
"(",
"self",
")",
":",
"_log",
".",
"info",
"(",
"'Fetching current cluster-topology from Zookeeper...'",
")",
"cluster_layout",
"=",
"self",
".",
"get_topics",
"(",
"fetch_partition_state",
"=",
"False",
")",
"# Re-format cluster-layout",
"pa... | Fetch cluster plan from zookeeper. | [
"Fetch",
"cluster",
"plan",
"from",
"zookeeper",
"."
] | python | train |
naught101/sobol_seq | sobol_seq/sobol_seq.py | https://github.com/naught101/sobol_seq/blob/6ac1799818a1b9a359a5fc86517173584fe34613/sobol_seq/sobol_seq.py#L114-L130 | def i4_sobol_generate(dim_num, n, skip=1):
"""
i4_sobol_generate generates a Sobol dataset.
Parameters:
Input, integer dim_num, the spatial dimension.
Input, integer N, the number of points to generate.
Input, integer SKIP, the number of initial points to skip.
Output, real R(M,N),... | [
"def",
"i4_sobol_generate",
"(",
"dim_num",
",",
"n",
",",
"skip",
"=",
"1",
")",
":",
"r",
"=",
"np",
".",
"full",
"(",
"(",
"n",
",",
"dim_num",
")",
",",
"np",
".",
"nan",
")",
"for",
"j",
"in",
"range",
"(",
"n",
")",
":",
"seed",
"=",
... | i4_sobol_generate generates a Sobol dataset.
Parameters:
Input, integer dim_num, the spatial dimension.
Input, integer N, the number of points to generate.
Input, integer SKIP, the number of initial points to skip.
Output, real R(M,N), the points. | [
"i4_sobol_generate",
"generates",
"a",
"Sobol",
"dataset",
"."
] | python | train |
ntucllab/libact | libact/query_strategies/multiclass/mdsp.py | https://github.com/ntucllab/libact/blob/e37e9ed6c36febe701d84b2d495c958ab02f0bc8/libact/query_strategies/multiclass/mdsp.py#L24-L171 | def _smacof_single_p(similarities, n_uq, metric=True, n_components=2, init=None,
max_iter=300, verbose=0, eps=1e-3, random_state=None):
"""
Computes multidimensional scaling using SMACOF algorithm
Parameters
----------
n_uq
similarities: symmetric ndarray, shape [n ... | [
"def",
"_smacof_single_p",
"(",
"similarities",
",",
"n_uq",
",",
"metric",
"=",
"True",
",",
"n_components",
"=",
"2",
",",
"init",
"=",
"None",
",",
"max_iter",
"=",
"300",
",",
"verbose",
"=",
"0",
",",
"eps",
"=",
"1e-3",
",",
"random_state",
"=",
... | Computes multidimensional scaling using SMACOF algorithm
Parameters
----------
n_uq
similarities: symmetric ndarray, shape [n * n]
similarities between the points
metric: boolean, optional, default: True
compute metric or nonmetric SMACOF algorithm
n_components: i... | [
"Computes",
"multidimensional",
"scaling",
"using",
"SMACOF",
"algorithm",
"Parameters",
"----------",
"n_uq",
"similarities",
":",
"symmetric",
"ndarray",
"shape",
"[",
"n",
"*",
"n",
"]",
"similarities",
"between",
"the",
"points",
"metric",
":",
"boolean",
"opt... | python | train |
RRZE-HPC/pycachesim | cachesim/cache.py | https://github.com/RRZE-HPC/pycachesim/blob/6dd084d29cf91ec19b016e0db9ccdfc8d1f63c5b/cachesim/cache.py#L168-L178 | def print_stats(self, header=True, file=sys.stdout):
"""Pretty print stats table."""
if header:
print("CACHE {:*^18} {:*^18} {:*^18} {:*^18} {:*^18}".format(
"HIT", "MISS", "LOAD", "STORE", "EVICT"), file=file)
for s in self.stats():
print("{name:>5} {HIT_... | [
"def",
"print_stats",
"(",
"self",
",",
"header",
"=",
"True",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"if",
"header",
":",
"print",
"(",
"\"CACHE {:*^18} {:*^18} {:*^18} {:*^18} {:*^18}\"",
".",
"format",
"(",
"\"HIT\"",
",",
"\"MISS\"",
",",
"\"L... | Pretty print stats table. | [
"Pretty",
"print",
"stats",
"table",
"."
] | python | train |
emre/storm | storm/__main__.py | https://github.com/emre/storm/blob/c752defc1b718cfffbf0e0e15532fa1d7840bf6d/storm/__main__.py#L146-L169 | def update(name, connection_uri="", id_file="", o=[], config=None):
"""
Enhanced version of the edit command featuring multiple
edits using regular expressions to match entries
"""
storm_ = get_storm_instance(config)
settings = {}
if id_file != "":
settings['identityfile'] = id_fil... | [
"def",
"update",
"(",
"name",
",",
"connection_uri",
"=",
"\"\"",
",",
"id_file",
"=",
"\"\"",
",",
"o",
"=",
"[",
"]",
",",
"config",
"=",
"None",
")",
":",
"storm_",
"=",
"get_storm_instance",
"(",
"config",
")",
"settings",
"=",
"{",
"}",
"if",
... | Enhanced version of the edit command featuring multiple
edits using regular expressions to match entries | [
"Enhanced",
"version",
"of",
"the",
"edit",
"command",
"featuring",
"multiple",
"edits",
"using",
"regular",
"expressions",
"to",
"match",
"entries"
] | python | train |
ladybug-tools/ladybug | ladybug/designday.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/designday.py#L323-L383 | def from_ep_string(cls, ep_string, location):
"""Initalize from an EnergyPlus string of a SizingPeriod:DesignDay.
args:
ep_string: A full string representing a SizingPeriod:DesignDay.
"""
# format the object into a list of properties
ep_string = ep_string.strip()
... | [
"def",
"from_ep_string",
"(",
"cls",
",",
"ep_string",
",",
"location",
")",
":",
"# format the object into a list of properties",
"ep_string",
"=",
"ep_string",
".",
"strip",
"(",
")",
"if",
"'\\n'",
"in",
"ep_string",
":",
"ep_lines",
"=",
"ep_string",
".",
"s... | Initalize from an EnergyPlus string of a SizingPeriod:DesignDay.
args:
ep_string: A full string representing a SizingPeriod:DesignDay. | [
"Initalize",
"from",
"an",
"EnergyPlus",
"string",
"of",
"a",
"SizingPeriod",
":",
"DesignDay",
"."
] | python | train |
ewels/MultiQC | multiqc/modules/slamdunk/slamdunk.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/slamdunk/slamdunk.py#L435-L472 | def slamdunkOverallRatesPlot (self):
""" Generate the overall rates plot """
pconfig = {
'id': 'overallratesplot',
'title': 'Slamdunk: Overall conversion rates in reads',
'cpswitch': False,
'cpswitch_c_active': False,
'ylab': 'Number of reads'... | [
"def",
"slamdunkOverallRatesPlot",
"(",
"self",
")",
":",
"pconfig",
"=",
"{",
"'id'",
":",
"'overallratesplot'",
",",
"'title'",
":",
"'Slamdunk: Overall conversion rates in reads'",
",",
"'cpswitch'",
":",
"False",
",",
"'cpswitch_c_active'",
":",
"False",
",",
"'... | Generate the overall rates plot | [
"Generate",
"the",
"overall",
"rates",
"plot"
] | python | train |
Gandi/gandi.cli | gandi/cli/modules/status.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/status.py#L39-L42 | def status(cls):
"""Retrieve global status from status.gandi.net."""
return cls.json_get('%s/status' % cls.api_url, empty_key=True,
send_key=False) | [
"def",
"status",
"(",
"cls",
")",
":",
"return",
"cls",
".",
"json_get",
"(",
"'%s/status'",
"%",
"cls",
".",
"api_url",
",",
"empty_key",
"=",
"True",
",",
"send_key",
"=",
"False",
")"
] | Retrieve global status from status.gandi.net. | [
"Retrieve",
"global",
"status",
"from",
"status",
".",
"gandi",
".",
"net",
"."
] | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/convert.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/convert.py#L113-L122 | def convert_attrs_to_lowercase(obj: Any, attrs: Iterable[str]) -> None:
"""
Converts the specified attributes of an object to lower case, modifying
the object in place.
"""
for a in attrs:
value = getattr(obj, a)
if value is None:
continue
setattr(obj, a, value.lo... | [
"def",
"convert_attrs_to_lowercase",
"(",
"obj",
":",
"Any",
",",
"attrs",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"None",
":",
"for",
"a",
"in",
"attrs",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"a",
")",
"if",
"value",
"is",
"None",
":... | Converts the specified attributes of an object to lower case, modifying
the object in place. | [
"Converts",
"the",
"specified",
"attributes",
"of",
"an",
"object",
"to",
"lower",
"case",
"modifying",
"the",
"object",
"in",
"place",
"."
] | python | train |
vtkiorg/vtki | vtki/common.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L749-L762 | def scalar_names(self):
"""A list of scalar names for the dataset. This makes
sure to put the active scalar's name first in the list."""
names = []
for i in range(self.GetPointData().GetNumberOfArrays()):
names.append(self.GetPointData().GetArrayName(i))
for i in rang... | [
"def",
"scalar_names",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"GetPointData",
"(",
")",
".",
"GetNumberOfArrays",
"(",
")",
")",
":",
"names",
".",
"append",
"(",
"self",
".",
"GetPointData",
"(",
... | A list of scalar names for the dataset. This makes
sure to put the active scalar's name first in the list. | [
"A",
"list",
"of",
"scalar",
"names",
"for",
"the",
"dataset",
".",
"This",
"makes",
"sure",
"to",
"put",
"the",
"active",
"scalar",
"s",
"name",
"first",
"in",
"the",
"list",
"."
] | python | train |
daviddrysdale/python-phonenumbers | python/phonenumbers/asyoutypeformatter.py | https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/asyoutypeformatter.py#L400-L414 | def get_remembered_position(self):
"""Returns the current position in the partially formatted phone
number of the character which was previously passed in as the
parameter of input_digit(remember_position=True)."""
if not self._able_to_format:
return self._original_position
... | [
"def",
"get_remembered_position",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_able_to_format",
":",
"return",
"self",
".",
"_original_position",
"accrued_input_index",
"=",
"0",
"current_output_index",
"=",
"0",
"while",
"(",
"accrued_input_index",
"<",
"se... | Returns the current position in the partially formatted phone
number of the character which was previously passed in as the
parameter of input_digit(remember_position=True). | [
"Returns",
"the",
"current",
"position",
"in",
"the",
"partially",
"formatted",
"phone",
"number",
"of",
"the",
"character",
"which",
"was",
"previously",
"passed",
"in",
"as",
"the",
"parameter",
"of",
"input_digit",
"(",
"remember_position",
"=",
"True",
")",
... | python | train |
materialsproject/pymatgen | pymatgen/analysis/nmr.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/nmr.py#L98-L108 | def maryland_values(self):
"""
Returns: the Chemical shielding tensor in Maryland Notation
"""
pas=self.principal_axis_system
sigma_iso=pas.trace() / 3
omega=np.diag(pas)[2] - np.diag(pas)[0]
# There is a typo in equation 20 from Magn. Reson. Chem. 2008, 46, 582–5... | [
"def",
"maryland_values",
"(",
"self",
")",
":",
"pas",
"=",
"self",
".",
"principal_axis_system",
"sigma_iso",
"=",
"pas",
".",
"trace",
"(",
")",
"/",
"3",
"omega",
"=",
"np",
".",
"diag",
"(",
"pas",
")",
"[",
"2",
"]",
"-",
"np",
".",
"diag",
... | Returns: the Chemical shielding tensor in Maryland Notation | [
"Returns",
":",
"the",
"Chemical",
"shielding",
"tensor",
"in",
"Maryland",
"Notation"
] | python | train |
Saledddar/pyunet | pyunet/util.py | https://github.com/Saledddar/pyunet/blob/ca5ccc32588fae8da43f968e7747d3f3da509507/pyunet/util.py#L33-L54 | def find_file_regex(root_dir,re_expression,return_abs_path = True,search_sub_directories = True):
'''
Finds all the files with the specified root directory with the name matching the regex expression.
Args :
root_dir : The root directory.
re_expression ... | [
"def",
"find_file_regex",
"(",
"root_dir",
",",
"re_expression",
",",
"return_abs_path",
"=",
"True",
",",
"search_sub_directories",
"=",
"True",
")",
":",
"compiled",
"=",
"re",
".",
"compile",
"(",
"re_expression",
")",
"result",
"=",
"[",
"]",
"for",
"dir... | Finds all the files with the specified root directory with the name matching the regex expression.
Args :
root_dir : The root directory.
re_expression : The regex expression.
return_abs_path : If set to true, returns the absolute path of th... | [
"Finds",
"all",
"the",
"files",
"with",
"the",
"specified",
"root",
"directory",
"with",
"the",
"name",
"matching",
"the",
"regex",
"expression",
".",
"Args",
":",
"root_dir",
":",
"The",
"root",
"directory",
".",
"re_expression",
":",
"The",
"regex",
"expre... | python | train |
utek/pyseaweed | pyseaweed/weed.py | https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L50-L66 | def get_file(self, fid):
"""Get file from WeedFS.
Returns file content. May be problematic for large files as content is
stored in memory.
Args:
**fid**: File identifier <volume_id>,<file_name_hash>
Returns:
Content of the file with provided fid or None... | [
"def",
"get_file",
"(",
"self",
",",
"fid",
")",
":",
"url",
"=",
"self",
".",
"get_file_url",
"(",
"fid",
")",
"return",
"self",
".",
"conn",
".",
"get_raw_data",
"(",
"url",
")"
] | Get file from WeedFS.
Returns file content. May be problematic for large files as content is
stored in memory.
Args:
**fid**: File identifier <volume_id>,<file_name_hash>
Returns:
Content of the file with provided fid or None if file doesn't
exist o... | [
"Get",
"file",
"from",
"WeedFS",
"."
] | python | train |
intelligenia/modeltranslation | modeltranslation/templatetags/modeltranslation_tags.py | https://github.com/intelligenia/modeltranslation/blob/64d6adeb537747321d5020efedf5d7e0d135862d/modeltranslation/templatetags/modeltranslation_tags.py#L15-L47 | def get_translated_attribute(instance, attr):
"""
Wraps Django Model __getattribute__ method making translation in templates less painful
"""
# If its class has no translatable fields, returns attribute
try:
if not hasattr(instance._meta, "translatable_fields") or len(getattr(instance._meta,"translatable_field... | [
"def",
"get_translated_attribute",
"(",
"instance",
",",
"attr",
")",
":",
"# If its class has no translatable fields, returns attribute",
"try",
":",
"if",
"not",
"hasattr",
"(",
"instance",
".",
"_meta",
",",
"\"translatable_fields\"",
")",
"or",
"len",
"(",
"getatt... | Wraps Django Model __getattribute__ method making translation in templates less painful | [
"Wraps",
"Django",
"Model",
"__getattribute__",
"method",
"making",
"translation",
"in",
"templates",
"less",
"painful"
] | python | train |
CiscoUcs/UcsPythonSDK | src/UcsSdk/UcsBase.py | https://github.com/CiscoUcs/UcsPythonSDK/blob/bf6b07d6abeacb922c92b198352eda4eb9e4629b/src/UcsSdk/UcsBase.py#L875-L902 | def DecryptPassword(cipher, key):
""" Decrypts the password using the given key with which the password was encrypted first. """
import base64
import hmac
import sha
from array import array
H = UcsUtils.GetShaHash
cipher = cipher + "\n"
cipher = base64.decodestring(cipher)
n = len(cipher) - 16 - 8
... | [
"def",
"DecryptPassword",
"(",
"cipher",
",",
"key",
")",
":",
"import",
"base64",
"import",
"hmac",
"import",
"sha",
"from",
"array",
"import",
"array",
"H",
"=",
"UcsUtils",
".",
"GetShaHash",
"cipher",
"=",
"cipher",
"+",
"\"\\n\"",
"cipher",
"=",
"base... | Decrypts the password using the given key with which the password was encrypted first. | [
"Decrypts",
"the",
"password",
"using",
"the",
"given",
"key",
"with",
"which",
"the",
"password",
"was",
"encrypted",
"first",
"."
] | python | train |
googleapis/google-cloud-python | datastore/google/cloud/datastore/client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/client.py#L296-L340 | def get(self, key, missing=None, deferred=None, transaction=None, eventual=False):
"""Retrieve an entity from a single key (if it exists).
.. note::
This is just a thin wrapper over :meth:`get_multi`.
The backend API does not make a distinction between a single key or
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"missing",
"=",
"None",
",",
"deferred",
"=",
"None",
",",
"transaction",
"=",
"None",
",",
"eventual",
"=",
"False",
")",
":",
"entities",
"=",
"self",
".",
"get_multi",
"(",
"keys",
"=",
"[",
"key",
"]"... | Retrieve an entity from a single key (if it exists).
.. note::
This is just a thin wrapper over :meth:`get_multi`.
The backend API does not make a distinction between a single key or
multiple keys in a lookup request.
:type key: :class:`google.cloud.datastore.key.Key`... | [
"Retrieve",
"an",
"entity",
"from",
"a",
"single",
"key",
"(",
"if",
"it",
"exists",
")",
"."
] | python | train |
apache/airflow | airflow/contrib/hooks/azure_fileshare_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_fileshare_hook.py#L64-L81 | def check_for_file(self, share_name, directory_name, file_name, **kwargs):
"""
Check if a file exists on Azure File Share.
:param share_name: Name of the share.
:type share_name: str
:param directory_name: Name of the directory.
:type directory_name: str
:param f... | [
"def",
"check_for_file",
"(",
"self",
",",
"share_name",
",",
"directory_name",
",",
"file_name",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"connection",
".",
"exists",
"(",
"share_name",
",",
"directory_name",
",",
"file_name",
",",
"*",
"... | Check if a file exists on Azure File Share.
:param share_name: Name of the share.
:type share_name: str
:param directory_name: Name of the directory.
:type directory_name: str
:param file_name: Name of the file.
:type file_name: str
:param kwargs: Optional keywor... | [
"Check",
"if",
"a",
"file",
"exists",
"on",
"Azure",
"File",
"Share",
"."
] | python | test |
RI-imaging/qpimage | qpimage/bg_estimate.py | https://github.com/RI-imaging/qpimage/blob/863c0fce5735b4c0ae369f75c0df9a33411b2bb2/qpimage/bg_estimate.py#L131-L139 | def profile_tilt(data, mask):
"""Fit a 2D tilt to `data[mask]`"""
params = lmfit.Parameters()
params.add(name="mx", value=0)
params.add(name="my", value=0)
params.add(name="off", value=np.average(data[mask]))
fr = lmfit.minimize(tilt_residual, params, args=(data, mask))
bg = tilt_model(fr.pa... | [
"def",
"profile_tilt",
"(",
"data",
",",
"mask",
")",
":",
"params",
"=",
"lmfit",
".",
"Parameters",
"(",
")",
"params",
".",
"add",
"(",
"name",
"=",
"\"mx\"",
",",
"value",
"=",
"0",
")",
"params",
".",
"add",
"(",
"name",
"=",
"\"my\"",
",",
... | Fit a 2D tilt to `data[mask]` | [
"Fit",
"a",
"2D",
"tilt",
"to",
"data",
"[",
"mask",
"]"
] | python | train |
toastdriven/alligator | alligator/__init__.py | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/__init__.py#L11-L22 | def version():
"""
Returns a human-readable version string.
For official releases, it will follow a semver style (e.g. ``1.2.7``).
For dev versions, it will have the semver style first, followed by
hyphenated qualifiers (e.g. ``1.2.7-dev``).
Returns a string.
"""
short = '.'.join([str(... | [
"def",
"version",
"(",
")",
":",
"short",
"=",
"'.'",
".",
"join",
"(",
"[",
"str",
"(",
"bit",
")",
"for",
"bit",
"in",
"__version__",
"[",
":",
"3",
"]",
"]",
")",
"return",
"'-'",
".",
"join",
"(",
"[",
"short",
"]",
"+",
"[",
"str",
"(",
... | Returns a human-readable version string.
For official releases, it will follow a semver style (e.g. ``1.2.7``).
For dev versions, it will have the semver style first, followed by
hyphenated qualifiers (e.g. ``1.2.7-dev``).
Returns a string. | [
"Returns",
"a",
"human",
"-",
"readable",
"version",
"string",
"."
] | python | train |
Erotemic/utool | utool/util_dict.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dict.py#L1282-L1300 | def range_hist(items, bins):
"""
Bins items into a discrete histogram by values and/or ranges.
items = [1, 2, 3, 4, 5, 6, 7]
bins = [0, 1, 2, (3, float('inf'))]
ut.range_hist(items, bins)
"""
big_hist = ut.dict_hist(items)
hist = ut.odict([(b, 0) for b in bins])
for k, ... | [
"def",
"range_hist",
"(",
"items",
",",
"bins",
")",
":",
"big_hist",
"=",
"ut",
".",
"dict_hist",
"(",
"items",
")",
"hist",
"=",
"ut",
".",
"odict",
"(",
"[",
"(",
"b",
",",
"0",
")",
"for",
"b",
"in",
"bins",
"]",
")",
"for",
"k",
",",
"v"... | Bins items into a discrete histogram by values and/or ranges.
items = [1, 2, 3, 4, 5, 6, 7]
bins = [0, 1, 2, (3, float('inf'))]
ut.range_hist(items, bins) | [
"Bins",
"items",
"into",
"a",
"discrete",
"histogram",
"by",
"values",
"and",
"/",
"or",
"ranges",
"."
] | python | train |
saltstack/salt | salt/modules/smartos_imgadm.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smartos_imgadm.py#L104-L114 | def _split_docker_uuid(uuid):
'''
Split a smartos docker uuid into repo and tag
'''
if uuid:
uuid = uuid.split(':')
if len(uuid) == 2:
tag = uuid[1]
repo = uuid[0]
return repo, tag
return None, None | [
"def",
"_split_docker_uuid",
"(",
"uuid",
")",
":",
"if",
"uuid",
":",
"uuid",
"=",
"uuid",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"uuid",
")",
"==",
"2",
":",
"tag",
"=",
"uuid",
"[",
"1",
"]",
"repo",
"=",
"uuid",
"[",
"0",
"]",
"... | Split a smartos docker uuid into repo and tag | [
"Split",
"a",
"smartos",
"docker",
"uuid",
"into",
"repo",
"and",
"tag"
] | python | train |
project-rig/rig | rig/place_and_route/place/sa/python_kernel.py | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/sa/python_kernel.py#L295-L349 | def _swap(vas, vas_location, vbs, vbs_location, l2v, vertices_resources,
placements, machine):
"""Swap the positions of two sets of vertices.
Parameters
----------
vas : [vertex, ...]
A set of vertices currently at vas_location.
vas_location : (x, y)
vbs : [vertex, ...]
... | [
"def",
"_swap",
"(",
"vas",
",",
"vas_location",
",",
"vbs",
",",
"vbs_location",
",",
"l2v",
",",
"vertices_resources",
",",
"placements",
",",
"machine",
")",
":",
"# Get the lists of vertices at either location",
"vas_location2v",
"=",
"l2v",
"[",
"vas_location",... | Swap the positions of two sets of vertices.
Parameters
----------
vas : [vertex, ...]
A set of vertices currently at vas_location.
vas_location : (x, y)
vbs : [vertex, ...]
A set of vertices currently at vbs_location.
vbs_location : (x, y)
l2v : {(x, y): [vertex, ...], ...}
... | [
"Swap",
"the",
"positions",
"of",
"two",
"sets",
"of",
"vertices",
"."
] | python | train |
inasafe/inasafe | safe/gui/tools/multi_buffer_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/multi_buffer_dialog.py#L104-L156 | def accept(self):
"""Process the layer for multi buffering and generate a new layer.
.. note:: This is called on OK click.
"""
# set parameter from dialog
input_layer = self.layer.currentLayer()
output_path = self.output_form.text()
radius = self.get_classificati... | [
"def",
"accept",
"(",
"self",
")",
":",
"# set parameter from dialog",
"input_layer",
"=",
"self",
".",
"layer",
".",
"currentLayer",
"(",
")",
"output_path",
"=",
"self",
".",
"output_form",
".",
"text",
"(",
")",
"radius",
"=",
"self",
".",
"get_classifica... | Process the layer for multi buffering and generate a new layer.
.. note:: This is called on OK click. | [
"Process",
"the",
"layer",
"for",
"multi",
"buffering",
"and",
"generate",
"a",
"new",
"layer",
"."
] | python | train |
pylp/pylp | pylp/cli/run.py | https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/cli/run.py#L18-L45 | def run(path, tasks):
"""Run a pylpfile."""
# Test if the pylpfile exists
readable_path = make_readable_path(path)
if not os.path.isfile(path):
logger.log(logger.red("Can't read pylpfile "), logger.magenta(readable_path))
sys.exit(-1)
else:
logger.log("Using pylpfile ", logger.magenta(readable_path))
# R... | [
"def",
"run",
"(",
"path",
",",
"tasks",
")",
":",
"# Test if the pylpfile exists",
"readable_path",
"=",
"make_readable_path",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"logger",
".",
"log",
"(",
"logger",
"... | Run a pylpfile. | [
"Run",
"a",
"pylpfile",
"."
] | python | train |
edx/edx-enterprise | enterprise/utils.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L543-L567 | def traverse_pagination(response, endpoint):
"""
Traverse a paginated API response.
Extracts and concatenates "results" (list of dict) returned by DRF-powered
APIs.
Arguments:
response (Dict): Current response dict from service API
endpoint (slumber Resource object): slumber Resour... | [
"def",
"traverse_pagination",
"(",
"response",
",",
"endpoint",
")",
":",
"results",
"=",
"response",
".",
"get",
"(",
"'results'",
",",
"[",
"]",
")",
"next_page",
"=",
"response",
".",
"get",
"(",
"'next'",
")",
"while",
"next_page",
":",
"querystring",
... | Traverse a paginated API response.
Extracts and concatenates "results" (list of dict) returned by DRF-powered
APIs.
Arguments:
response (Dict): Current response dict from service API
endpoint (slumber Resource object): slumber Resource object from edx-rest-api-client
Returns:
... | [
"Traverse",
"a",
"paginated",
"API",
"response",
"."
] | python | valid |
mayfield/syndicate | syndicate/data.py | https://github.com/mayfield/syndicate/blob/917af976dacb7377bdf0cb616f47e0df5afaff1a/syndicate/data.py#L40-L46 | def parse_object(self, data):
""" Look for datetime looking strings. """
for key, value in data.items():
if isinstance(value, (str, type(u''))) and \
self.strict_iso_match.match(value):
data[key] = dateutil.parser.parse(value)
return data | [
"def",
"parse_object",
"(",
"self",
",",
"data",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"str",
",",
"type",
"(",
"u''",
")",
")",
")",
"and",
"self",
".",
"st... | Look for datetime looking strings. | [
"Look",
"for",
"datetime",
"looking",
"strings",
"."
] | python | train |
twilio/twilio-python | twilio/rest/ip_messaging/v2/service/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/ip_messaging/v2/service/__init__.py#L262-L368 | def update(self, friendly_name=values.unset,
default_service_role_sid=values.unset,
default_channel_role_sid=values.unset,
default_channel_creator_role_sid=values.unset,
read_status_enabled=values.unset, reachability_enabled=values.unset,
typing... | [
"def",
"update",
"(",
"self",
",",
"friendly_name",
"=",
"values",
".",
"unset",
",",
"default_service_role_sid",
"=",
"values",
".",
"unset",
",",
"default_channel_role_sid",
"=",
"values",
".",
"unset",
",",
"default_channel_creator_role_sid",
"=",
"values",
"."... | Update the ServiceInstance
:param unicode friendly_name: A string to describe the resource
:param unicode default_service_role_sid: The service role assigned to users when they are added to the service
:param unicode default_channel_role_sid: The channel role assigned to users when they are add... | [
"Update",
"the",
"ServiceInstance"
] | python | train |
drongo-framework/drongo | drongo/utils/dict2.py | https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/utils/dict2.py#L25-L41 | def get_property(self, prop):
"""Access nested value using dot separated keys
Args:
prop (:obj:`str`): Property in the form of dot separated keys
Returns:
Property value if exists, else `None`
"""
prop = prop.split('.')
root = self
for p ... | [
"def",
"get_property",
"(",
"self",
",",
"prop",
")",
":",
"prop",
"=",
"prop",
".",
"split",
"(",
"'.'",
")",
"root",
"=",
"self",
"for",
"p",
"in",
"prop",
":",
"if",
"p",
"in",
"root",
":",
"root",
"=",
"root",
"[",
"p",
"]",
"else",
":",
... | Access nested value using dot separated keys
Args:
prop (:obj:`str`): Property in the form of dot separated keys
Returns:
Property value if exists, else `None` | [
"Access",
"nested",
"value",
"using",
"dot",
"separated",
"keys"
] | python | train |
GoogleCloudPlatform/cloud-debug-python | src/googleclouddebugger/imphook2.py | https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/imphook2.py#L211-L237 | def _ResolveRelativeImport(name, package):
"""Resolves a relative import into an absolute path.
This is mostly an adapted version of the logic found in the backported
version of import_module in Python 2.7.
https://github.com/python/cpython/blob/2.7/Lib/importlib/__init__.py
Args:
name: relative name im... | [
"def",
"_ResolveRelativeImport",
"(",
"name",
",",
"package",
")",
":",
"level",
"=",
"sum",
"(",
"1",
"for",
"c",
"in",
"itertools",
".",
"takewhile",
"(",
"lambda",
"c",
":",
"c",
"==",
"'.'",
",",
"name",
")",
")",
"if",
"level",
"==",
"1",
":",... | Resolves a relative import into an absolute path.
This is mostly an adapted version of the logic found in the backported
version of import_module in Python 2.7.
https://github.com/python/cpython/blob/2.7/Lib/importlib/__init__.py
Args:
name: relative name imported, such as '.a' or '..b.c'
package: abs... | [
"Resolves",
"a",
"relative",
"import",
"into",
"an",
"absolute",
"path",
"."
] | python | train |
ceph/ceph-deploy | ceph_deploy/util/net.py | https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/util/net.py#L61-L68 | def in_subnet(cidr, addrs=None):
"""
Returns True if host is within specified subnet, otherwise False
"""
for address in addrs:
if ip_in_subnet(address, cidr):
return True
return False | [
"def",
"in_subnet",
"(",
"cidr",
",",
"addrs",
"=",
"None",
")",
":",
"for",
"address",
"in",
"addrs",
":",
"if",
"ip_in_subnet",
"(",
"address",
",",
"cidr",
")",
":",
"return",
"True",
"return",
"False"
] | Returns True if host is within specified subnet, otherwise False | [
"Returns",
"True",
"if",
"host",
"is",
"within",
"specified",
"subnet",
"otherwise",
"False"
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L14931-L14941 | def hot_plug_cpu(self, cpu):
"""Plugs a CPU into the machine.
in cpu of type int
The CPU id to insert.
"""
if not isinstance(cpu, baseinteger):
raise TypeError("cpu can only be an instance of type baseinteger")
self._call("hotPlugCPU",
... | [
"def",
"hot_plug_cpu",
"(",
"self",
",",
"cpu",
")",
":",
"if",
"not",
"isinstance",
"(",
"cpu",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"cpu can only be an instance of type baseinteger\"",
")",
"self",
".",
"_call",
"(",
"\"hotPlugCPU\"",
","... | Plugs a CPU into the machine.
in cpu of type int
The CPU id to insert. | [
"Plugs",
"a",
"CPU",
"into",
"the",
"machine",
"."
] | python | train |
MediaFire/mediafire-python-open-sdk | mediafire/api.py | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L705-L720 | def file_update_file(self, quick_key, file_extension=None, filename=None,
description=None, mtime=None, privacy=None,
timezone=None):
"""file/update_file
http://www.mediafire.com/developers/core_api/1.3/file/#update_file
"""
return self.... | [
"def",
"file_update_file",
"(",
"self",
",",
"quick_key",
",",
"file_extension",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"description",
"=",
"None",
",",
"mtime",
"=",
"None",
",",
"privacy",
"=",
"None",
",",
"timezone",
"=",
"None",
")",
":",
... | file/update_file
http://www.mediafire.com/developers/core_api/1.3/file/#update_file | [
"file",
"/",
"update_file"
] | python | train |
bitesofcode/projexui | projexui/widgets/xviewwidget/xview.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xview.py#L504-L514 | def setMinimumHeight(self, height):
"""
Sets the minimum height value to the inputed height and emits the \
sizeConstraintChanged signal.
:param height | <int>
"""
super(XView, self).setMinimumHeight(height)
if ( not self.signalsBlocked() ):... | [
"def",
"setMinimumHeight",
"(",
"self",
",",
"height",
")",
":",
"super",
"(",
"XView",
",",
"self",
")",
".",
"setMinimumHeight",
"(",
"height",
")",
"if",
"(",
"not",
"self",
".",
"signalsBlocked",
"(",
")",
")",
":",
"self",
".",
"sizeConstraintChange... | Sets the minimum height value to the inputed height and emits the \
sizeConstraintChanged signal.
:param height | <int> | [
"Sets",
"the",
"minimum",
"height",
"value",
"to",
"the",
"inputed",
"height",
"and",
"emits",
"the",
"\\",
"sizeConstraintChanged",
"signal",
".",
":",
"param",
"height",
"|",
"<int",
">"
] | python | train |
base4sistemas/satcomum | satcomum/br.py | https://github.com/base4sistemas/satcomum/blob/b42bec06cb0fb0ad2f6b1a2644a1e8fc8403f2c3/satcomum/br.py#L230-L237 | def as_cpf(numero):
"""Formata um número de CPF. Se o número não for um CPF válido apenas
retorna o argumento sem qualquer modificação.
"""
_num = digitos(numero)
if is_cpf(_num):
return '{}.{}.{}-{}'.format(_num[:3], _num[3:6], _num[6:9], _num[9:])
return numero | [
"def",
"as_cpf",
"(",
"numero",
")",
":",
"_num",
"=",
"digitos",
"(",
"numero",
")",
"if",
"is_cpf",
"(",
"_num",
")",
":",
"return",
"'{}.{}.{}-{}'",
".",
"format",
"(",
"_num",
"[",
":",
"3",
"]",
",",
"_num",
"[",
"3",
":",
"6",
"]",
",",
"... | Formata um número de CPF. Se o número não for um CPF válido apenas
retorna o argumento sem qualquer modificação. | [
"Formata",
"um",
"número",
"de",
"CPF",
".",
"Se",
"o",
"número",
"não",
"for",
"um",
"CPF",
"válido",
"apenas",
"retorna",
"o",
"argumento",
"sem",
"qualquer",
"modificação",
"."
] | python | train |
pytroll/satpy | satpy/dataset.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/dataset.py#L293-L301 | def replace_anc(dataset, parent_dataset):
"""Replace *dataset* the *parent_dataset*'s `ancillary_variables` field."""
if parent_dataset is None:
return
current_dsid = DatasetID.from_dict(dataset.attrs)
for idx, ds in enumerate(parent_dataset.attrs['ancillary_variables']):
if current_dsid... | [
"def",
"replace_anc",
"(",
"dataset",
",",
"parent_dataset",
")",
":",
"if",
"parent_dataset",
"is",
"None",
":",
"return",
"current_dsid",
"=",
"DatasetID",
".",
"from_dict",
"(",
"dataset",
".",
"attrs",
")",
"for",
"idx",
",",
"ds",
"in",
"enumerate",
"... | Replace *dataset* the *parent_dataset*'s `ancillary_variables` field. | [
"Replace",
"*",
"dataset",
"*",
"the",
"*",
"parent_dataset",
"*",
"s",
"ancillary_variables",
"field",
"."
] | python | train |
michaelpb/omnic | omnic/cli/commandparser.py | https://github.com/michaelpb/omnic/blob/1111cfd73c9dc1955afe42d9cf2a468c46f83cd6/omnic/cli/commandparser.py#L64-L70 | def parse_args_to_action_args(self, argv=None):
'''
Parses args and returns an action and the args that were parsed
'''
args = self.parse_args(argv)
action = self.subcommands[args.subcommand][1]
return action, args | [
"def",
"parse_args_to_action_args",
"(",
"self",
",",
"argv",
"=",
"None",
")",
":",
"args",
"=",
"self",
".",
"parse_args",
"(",
"argv",
")",
"action",
"=",
"self",
".",
"subcommands",
"[",
"args",
".",
"subcommand",
"]",
"[",
"1",
"]",
"return",
"act... | Parses args and returns an action and the args that were parsed | [
"Parses",
"args",
"and",
"returns",
"an",
"action",
"and",
"the",
"args",
"that",
"were",
"parsed"
] | python | train |
aio-libs/aiodocker | aiodocker/utils.py | https://github.com/aio-libs/aiodocker/blob/88d0285ddba8e606ff684278e0a831347209189c/aiodocker/utils.py#L214-L227 | def clean_filters(filters: Mapping = None) -> str:
"""
Checks the values inside `filters`
https://docs.docker.com/engine/api/v1.29/#operation/ServiceList
Returns a new dictionary in the format `map[string][]string` jsonized
"""
if filters and isinstance(filters, dict):
for k, v in filte... | [
"def",
"clean_filters",
"(",
"filters",
":",
"Mapping",
"=",
"None",
")",
"->",
"str",
":",
"if",
"filters",
"and",
"isinstance",
"(",
"filters",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"filters",
".",
"items",
"(",
")",
":",
"if",
"not"... | Checks the values inside `filters`
https://docs.docker.com/engine/api/v1.29/#operation/ServiceList
Returns a new dictionary in the format `map[string][]string` jsonized | [
"Checks",
"the",
"values",
"inside",
"filters",
"https",
":",
"//",
"docs",
".",
"docker",
".",
"com",
"/",
"engine",
"/",
"api",
"/",
"v1",
".",
"29",
"/",
"#operation",
"/",
"ServiceList",
"Returns",
"a",
"new",
"dictionary",
"in",
"the",
"format",
"... | python | train |
maweigert/gputools | gputools/convolve/convolve.py | https://github.com/maweigert/gputools/blob/6ab26efeb05dceef74cf13aadeeeb9b009b529dd/gputools/convolve/convolve.py#L116-L151 | def _convolve3_old(data, h, dev=None):
"""convolves 3d data with kernel h on the GPU Device dev
boundary conditions are clamping to edge.
h is converted to float32
if dev == None the default one is used
"""
if dev is None:
dev = get_device()
if dev is None:
raise ValueErro... | [
"def",
"_convolve3_old",
"(",
"data",
",",
"h",
",",
"dev",
"=",
"None",
")",
":",
"if",
"dev",
"is",
"None",
":",
"dev",
"=",
"get_device",
"(",
")",
"if",
"dev",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"no OpenCLDevice found...\"",
")",
"dty... | convolves 3d data with kernel h on the GPU Device dev
boundary conditions are clamping to edge.
h is converted to float32
if dev == None the default one is used | [
"convolves",
"3d",
"data",
"with",
"kernel",
"h",
"on",
"the",
"GPU",
"Device",
"dev",
"boundary",
"conditions",
"are",
"clamping",
"to",
"edge",
".",
"h",
"is",
"converted",
"to",
"float32"
] | python | train |
marl/jams | jams/eval.py | https://github.com/marl/jams/blob/b16778399b9528efbd71434842a079f7691a7a66/jams/eval.py#L279-L319 | def hierarchy(ref, est, **kwargs):
r'''Multi-level segmentation evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : ... | [
"def",
"hierarchy",
"(",
"ref",
",",
"est",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"'multi_segment'",
"ref",
"=",
"coerce_annotation",
"(",
"ref",
",",
"namespace",
")",
"est",
"=",
"coerce_annotation",
"(",
"est",
",",
"namespace",
")",
"r... | r'''Multi-level segmentation evaluation
Parameters
----------
ref : jams.Annotation
Reference annotation object
est : jams.Annotation
Estimated annotation object
kwargs
Additional keyword arguments
Returns
-------
scores : dict
Dictionary of scores, wher... | [
"r",
"Multi",
"-",
"level",
"segmentation",
"evaluation"
] | python | valid |
gmr/tinman | tinman/handlers/base.py | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L204-L219 | def start_session(self):
"""Start the session. Invoke in your @gen.coroutine wrapped prepare
method like::
result = yield gen.Task(self.start_session)
:rtype: bool
"""
self.session = self._session_start()
result = yield gen.Task(self.session.fetch)
... | [
"def",
"start_session",
"(",
"self",
")",
":",
"self",
".",
"session",
"=",
"self",
".",
"_session_start",
"(",
")",
"result",
"=",
"yield",
"gen",
".",
"Task",
"(",
"self",
".",
"session",
".",
"fetch",
")",
"self",
".",
"_set_session_cookie",
"(",
")... | Start the session. Invoke in your @gen.coroutine wrapped prepare
method like::
result = yield gen.Task(self.start_session)
:rtype: bool | [
"Start",
"the",
"session",
".",
"Invoke",
"in",
"your",
"@gen",
".",
"coroutine",
"wrapped",
"prepare",
"method",
"like",
"::"
] | python | train |
horazont/aioxmpp | aioxmpp/forms/fields.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/forms/fields.py#L235-L288 | def render(self, *, use_local_metadata=True):
"""
Return a :class:`~.Field` containing the values and metadata set in the
field.
:param use_local_metadata: if true, the description, label and required
metadata can be sourced from the field
... | [
"def",
"render",
"(",
"self",
",",
"*",
",",
"use_local_metadata",
"=",
"True",
")",
":",
"result",
"=",
"forms_xso",
".",
"Field",
"(",
"var",
"=",
"self",
".",
"field",
".",
"var",
",",
"type_",
"=",
"self",
".",
"field",
".",
"FIELD_TYPE",
",",
... | Return a :class:`~.Field` containing the values and metadata set in the
field.
:param use_local_metadata: if true, the description, label and required
metadata can be sourced from the field
descriptor associated with this bound field... | [
"Return",
"a",
":",
"class",
":",
"~",
".",
"Field",
"containing",
"the",
"values",
"and",
"metadata",
"set",
"in",
"the",
"field",
"."
] | python | train |
inveniosoftware/invenio-github | invenio_github/api.py | https://github.com/inveniosoftware/invenio-github/blob/ec42fd6a06079310dcbe2c46d9fd79d5197bbe26/invenio_github/api.py#L272-L284 | def remove_hook(self, repo_id, name):
"""Remove repository hook."""
ghrepo = self.api.repository_with_id(repo_id)
if ghrepo:
hooks = (h for h in ghrepo.hooks()
if h.config.get('url', '') == self.webhook_url)
hook = next(hooks, None)
if not... | [
"def",
"remove_hook",
"(",
"self",
",",
"repo_id",
",",
"name",
")",
":",
"ghrepo",
"=",
"self",
".",
"api",
".",
"repository_with_id",
"(",
"repo_id",
")",
"if",
"ghrepo",
":",
"hooks",
"=",
"(",
"h",
"for",
"h",
"in",
"ghrepo",
".",
"hooks",
"(",
... | Remove repository hook. | [
"Remove",
"repository",
"hook",
"."
] | python | train |
opendatateam/udata | udata/harvest/actions.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/harvest/actions.py#L62-L87 | def create_source(name, url, backend,
description=None,
frequency=DEFAULT_HARVEST_FREQUENCY,
owner=None,
organization=None,
config=None,
):
'''Create a new harvest source'''
if owner and not isinstance(ow... | [
"def",
"create_source",
"(",
"name",
",",
"url",
",",
"backend",
",",
"description",
"=",
"None",
",",
"frequency",
"=",
"DEFAULT_HARVEST_FREQUENCY",
",",
"owner",
"=",
"None",
",",
"organization",
"=",
"None",
",",
"config",
"=",
"None",
",",
")",
":",
... | Create a new harvest source | [
"Create",
"a",
"new",
"harvest",
"source"
] | python | train |
Genida/django-meerkat | src/meerkat/utils/url.py | https://github.com/Genida/django-meerkat/blob/486502a75bb0800266db785fd32717d8c0eb8deb/src/meerkat/utils/url.py#L43-L63 | def url_is(white_list):
"""
Function generator.
Args:
white_list (dict): dict with PREFIXES and CONSTANTS keys (list values).
Returns:
func: a function to check if a URL is...
"""
def func(url):
prefixes = white_list.get('PREFIXES', ())
for prefix in prefixes:
... | [
"def",
"url_is",
"(",
"white_list",
")",
":",
"def",
"func",
"(",
"url",
")",
":",
"prefixes",
"=",
"white_list",
".",
"get",
"(",
"'PREFIXES'",
",",
"(",
")",
")",
"for",
"prefix",
"in",
"prefixes",
":",
"if",
"url",
".",
"startswith",
"(",
"prefix"... | Function generator.
Args:
white_list (dict): dict with PREFIXES and CONSTANTS keys (list values).
Returns:
func: a function to check if a URL is... | [
"Function",
"generator",
"."
] | python | train |
QualiSystems/cloudshell-networking-devices | cloudshell/devices/autoload/autoload_builder.py | https://github.com/QualiSystems/cloudshell-networking-devices/blob/009aab33edb30035b52fe10dbb91db61c95ba4d9/cloudshell/devices/autoload/autoload_builder.py#L23-L49 | def _validate_build_resource_structure(autoload_resource):
"""Validate resource structure
:param dict autoload_resource:
:return correct autoload resource structure
:rtype: dict
"""
result = {}
for resource_prefix, resources in autoload_resource.iteritems():
... | [
"def",
"_validate_build_resource_structure",
"(",
"autoload_resource",
")",
":",
"result",
"=",
"{",
"}",
"for",
"resource_prefix",
",",
"resources",
"in",
"autoload_resource",
".",
"iteritems",
"(",
")",
":",
"max_free_index",
"=",
"max",
"(",
"map",
"(",
"int"... | Validate resource structure
:param dict autoload_resource:
:return correct autoload resource structure
:rtype: dict | [
"Validate",
"resource",
"structure"
] | python | train |
MisterWil/skybellpy | skybellpy/device.py | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/device.py#L270-L280 | def motion_sensor(self, enabled):
"""Set the motion sensor state."""
if enabled is True:
value = CONST.SETTINGS_MOTION_POLICY_ON
elif enabled is False:
value = CONST.SETTINGS_MOTION_POLICY_OFF
else:
raise SkybellException(ERROR.INVALID_SETTING_VALUE,
... | [
"def",
"motion_sensor",
"(",
"self",
",",
"enabled",
")",
":",
"if",
"enabled",
"is",
"True",
":",
"value",
"=",
"CONST",
".",
"SETTINGS_MOTION_POLICY_ON",
"elif",
"enabled",
"is",
"False",
":",
"value",
"=",
"CONST",
".",
"SETTINGS_MOTION_POLICY_OFF",
"else",... | Set the motion sensor state. | [
"Set",
"the",
"motion",
"sensor",
"state",
"."
] | python | train |
cloudera/impyla | impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py | https://github.com/cloudera/impyla/blob/547fa2ba3b6151e2a98b3544301471a643212dc3/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L3867-L3874 | def partition_name_has_valid_characters(self, part_vals, throw_exception):
"""
Parameters:
- part_vals
- throw_exception
"""
self.send_partition_name_has_valid_characters(part_vals, throw_exception)
return self.recv_partition_name_has_valid_characters() | [
"def",
"partition_name_has_valid_characters",
"(",
"self",
",",
"part_vals",
",",
"throw_exception",
")",
":",
"self",
".",
"send_partition_name_has_valid_characters",
"(",
"part_vals",
",",
"throw_exception",
")",
"return",
"self",
".",
"recv_partition_name_has_valid_chara... | Parameters:
- part_vals
- throw_exception | [
"Parameters",
":",
"-",
"part_vals",
"-",
"throw_exception"
] | python | train |
saltstack/salt | salt/engines/libvirt_events.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/libvirt_events.py#L424-L431 | def _domain_event_agent_lifecycle_cb(conn, domain, state, reason, opaque):
'''
Domain agent lifecycle events handler
'''
_salt_send_domain_event(opaque, conn, domain, opaque['event'], {
'state': _get_libvirt_enum_string('VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_', state),
'reason':... | [
"def",
"_domain_event_agent_lifecycle_cb",
"(",
"conn",
",",
"domain",
",",
"state",
",",
"reason",
",",
"opaque",
")",
":",
"_salt_send_domain_event",
"(",
"opaque",
",",
"conn",
",",
"domain",
",",
"opaque",
"[",
"'event'",
"]",
",",
"{",
"'state'",
":",
... | Domain agent lifecycle events handler | [
"Domain",
"agent",
"lifecycle",
"events",
"handler"
] | python | train |
oasiswork/zimsoap | zimsoap/client.py | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/client.py#L429-L442 | def modify_signature(self, signature):
""" Modify an existing signature
Can modify the content, contenttype and name. An unset attribute will
not delete the attribute but leave it untouched.
:param: signature a zobject.Signature object, with modified
content/con... | [
"def",
"modify_signature",
"(",
"self",
",",
"signature",
")",
":",
"# if no content is specified, just use a selector (id/name)",
"dic",
"=",
"signature",
".",
"to_creator",
"(",
"for_modify",
"=",
"True",
")",
"self",
".",
"request",
"(",
"'ModifySignature'",
",",
... | Modify an existing signature
Can modify the content, contenttype and name. An unset attribute will
not delete the attribute but leave it untouched.
:param: signature a zobject.Signature object, with modified
content/contentype/name, the id should be present and
... | [
"Modify",
"an",
"existing",
"signature"
] | python | train |
learningequality/ricecooker | ricecooker/utils/linecook.py | https://github.com/learningequality/ricecooker/blob/2f0385282500cb77ef2894646c6f9ce11bd7a853/ricecooker/utils/linecook.py#L46-L59 | def rel_path_from_chan_path(chan_path, channeldir, windows=False):
"""
Convert `chan_path` as obtained from a metadata provider into a `rel_path`
suitable for accessing the file from the current working directory, e.g.,
>>> rel_path_from_chan_path('Open Stax/Math', 'content/open_stax_zip/Open Stax')
... | [
"def",
"rel_path_from_chan_path",
"(",
"chan_path",
",",
"channeldir",
",",
"windows",
"=",
"False",
")",
":",
"if",
"windows",
":",
"chan_path_list",
"=",
"chan_path",
".",
"split",
"(",
"'\\\\'",
")",
"else",
":",
"chan_path_list",
"=",
"chan_path",
".",
"... | Convert `chan_path` as obtained from a metadata provider into a `rel_path`
suitable for accessing the file from the current working directory, e.g.,
>>> rel_path_from_chan_path('Open Stax/Math', 'content/open_stax_zip/Open Stax')
'content/open_stax_zip/Open Stax/Math' | [
"Convert",
"chan_path",
"as",
"obtained",
"from",
"a",
"metadata",
"provider",
"into",
"a",
"rel_path",
"suitable",
"for",
"accessing",
"the",
"file",
"from",
"the",
"current",
"working",
"directory",
"e",
".",
"g",
".",
">>>",
"rel_path_from_chan_path",
"(",
... | python | train |
tchellomello/python-arlo | pyarlo/base_station.py | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L438-L447 | def get_speaker_muted(self):
"""Return whether or not the speaker is muted."""
if not self.camera_extended_properties:
return None
speaker = self.camera_extended_properties.get('speaker')
if not speaker:
return None
return speaker.get('mute') | [
"def",
"get_speaker_muted",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"camera_extended_properties",
":",
"return",
"None",
"speaker",
"=",
"self",
".",
"camera_extended_properties",
".",
"get",
"(",
"'speaker'",
")",
"if",
"not",
"speaker",
":",
"return... | Return whether or not the speaker is muted. | [
"Return",
"whether",
"or",
"not",
"the",
"speaker",
"is",
"muted",
"."
] | python | train |
dslackw/slpkg | slpkg/main.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/main.py#L119-L132 | def command_update(self):
"""Update package lists repositories
"""
if len(self.args) == 1 and self.args[0] == "update":
Update().repository(only="")
elif (len(self.args) == 2 and self.args[0] == "update" and
self.args[1].startswith("--only=")):
rep... | [
"def",
"command_update",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"args",
")",
"==",
"1",
"and",
"self",
".",
"args",
"[",
"0",
"]",
"==",
"\"update\"",
":",
"Update",
"(",
")",
".",
"repository",
"(",
"only",
"=",
"\"\"",
")",
"elif... | Update package lists repositories | [
"Update",
"package",
"lists",
"repositories"
] | python | train |
bitesofcode/projexui | projexui/widgets/xcombobox.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcombobox.py#L347-L371 | def setCheckedIndexes(self, indexes):
"""
Sets a list of checked indexes for this combobox.
:param indexes | [<int>, ..]
"""
if not self.isCheckable():
return
model = self.model()
model.blockSignals(True)
for i in range(s... | [
"def",
"setCheckedIndexes",
"(",
"self",
",",
"indexes",
")",
":",
"if",
"not",
"self",
".",
"isCheckable",
"(",
")",
":",
"return",
"model",
"=",
"self",
".",
"model",
"(",
")",
"model",
".",
"blockSignals",
"(",
"True",
")",
"for",
"i",
"in",
"rang... | Sets a list of checked indexes for this combobox.
:param indexes | [<int>, ..] | [
"Sets",
"a",
"list",
"of",
"checked",
"indexes",
"for",
"this",
"combobox",
".",
":",
"param",
"indexes",
"|",
"[",
"<int",
">",
"..",
"]"
] | python | train |
Azure/azure-multiapi-storage-python | azure/multiapi/storage/v2016_05_31/storageclient.py | https://github.com/Azure/azure-multiapi-storage-python/blob/bd5482547f993c6eb56fd09070e15c2e9616e440/azure/multiapi/storage/v2016_05_31/storageclient.py#L189-L285 | def _perform_request(self, request, parser=None, parser_args=None, operation_context=None):
'''
Sends the request and return response. Catches HTTPError and hands it
to error handler
'''
operation_context = operation_context or _OperationContext()
retry_context = RetryCon... | [
"def",
"_perform_request",
"(",
"self",
",",
"request",
",",
"parser",
"=",
"None",
",",
"parser_args",
"=",
"None",
",",
"operation_context",
"=",
"None",
")",
":",
"operation_context",
"=",
"operation_context",
"or",
"_OperationContext",
"(",
")",
"retry_conte... | Sends the request and return response. Catches HTTPError and hands it
to error handler | [
"Sends",
"the",
"request",
"and",
"return",
"response",
".",
"Catches",
"HTTPError",
"and",
"hands",
"it",
"to",
"error",
"handler"
] | python | train |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/__init__.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L336-L444 | def _executor_internal_inner(self, host, module_name, module_args, inject, port, is_chained=False):
''' decides how to invoke a module '''
# allow module args to work as a dictionary
# though it is usually a string
new_args = ""
if type(module_args) == dict:
for (k,v... | [
"def",
"_executor_internal_inner",
"(",
"self",
",",
"host",
",",
"module_name",
",",
"module_args",
",",
"inject",
",",
"port",
",",
"is_chained",
"=",
"False",
")",
":",
"# allow module args to work as a dictionary",
"# though it is usually a string",
"new_args",
"=",... | decides how to invoke a module | [
"decides",
"how",
"to",
"invoke",
"a",
"module"
] | python | train |
wavefrontHQ/python-client | wavefront_api_client/api/derived_metric_api.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/derived_metric_api.py#L333-L354 | def get_all_derived_metrics(self, **kwargs): # noqa: E501
"""Get all derived metric definitions for a customer # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api... | [
"def",
"get_all_derived_metrics",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"get_all_derived_met... | Get all derived metric definitions for a customer # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_all_derived_metrics(async_req=True)
>>> result = thread.g... | [
"Get",
"all",
"derived",
"metric",
"definitions",
"for",
"a",
"customer",
"#",
"noqa",
":",
"E501"
] | python | train |
telefonicaid/fiware-sdc | python-sdcclient/utils/rest_client_utils.py | https://github.com/telefonicaid/fiware-sdc/blob/d2d5f87fc574caf6bcc49594bbcb31f620ba8c51/python-sdcclient/utils/rest_client_utils.py#L87-L114 | def _call_api(self, uri_pattern, method, body=None, headers=None, parameters=None, **kwargs):
"""
Launch HTTP request to the API with given arguments
:param uri_pattern: string pattern of the full API url with keyword arguments (format string syntax)
:param method: HTTP method to execute... | [
"def",
"_call_api",
"(",
"self",
",",
"uri_pattern",
",",
"method",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"parameters",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"API_ROOT_URL_ARG_NAME",
"]",
"=",
"self",
".",... | Launch HTTP request to the API with given arguments
:param uri_pattern: string pattern of the full API url with keyword arguments (format string syntax)
:param method: HTTP method to execute (string) [get | post | put | delete | update]
:param body: Raw Body content (string) (Plain/XML/JSON to b... | [
"Launch",
"HTTP",
"request",
"to",
"the",
"API",
"with",
"given",
"arguments",
":",
"param",
"uri_pattern",
":",
"string",
"pattern",
"of",
"the",
"full",
"API",
"url",
"with",
"keyword",
"arguments",
"(",
"format",
"string",
"syntax",
")",
":",
"param",
"... | python | train |
playpauseandstop/bootstrapper | bootstrapper.py | https://github.com/playpauseandstop/bootstrapper/blob/b216a05f2acb0b9f4919c4e010ff7b0f63fc1393/bootstrapper.py#L68-L84 | def check_pre_requirements(pre_requirements):
"""Check all necessary system requirements to exist.
:param pre_requirements:
Sequence of pre-requirements to check by running
``where <pre_requirement>`` on Windows and ``which ...`` elsewhere.
"""
pre_requirements = set(pre_requirements or... | [
"def",
"check_pre_requirements",
"(",
"pre_requirements",
")",
":",
"pre_requirements",
"=",
"set",
"(",
"pre_requirements",
"or",
"[",
"]",
")",
"pre_requirements",
".",
"add",
"(",
"'virtualenv'",
")",
"for",
"requirement",
"in",
"pre_requirements",
":",
"if",
... | Check all necessary system requirements to exist.
:param pre_requirements:
Sequence of pre-requirements to check by running
``where <pre_requirement>`` on Windows and ``which ...`` elsewhere. | [
"Check",
"all",
"necessary",
"system",
"requirements",
"to",
"exist",
"."
] | python | valid |
ucfopen/canvasapi | canvasapi/canvas.py | https://github.com/ucfopen/canvasapi/blob/319064b5fc97ba54250af683eb98723ef3f76cf8/canvasapi/canvas.py#L1058-L1078 | def get_outcome(self, outcome):
"""
Returns the details of the outcome with the given id.
:calls: `GET /api/v1/outcomes/:id \
<https://canvas.instructure.com/doc/api/outcomes.html#method.outcomes_api.show>`_
:param outcome: The outcome object or ID to return.
:type outc... | [
"def",
"get_outcome",
"(",
"self",
",",
"outcome",
")",
":",
"from",
"canvasapi",
".",
"outcome",
"import",
"Outcome",
"outcome_id",
"=",
"obj_or_id",
"(",
"outcome",
",",
"\"outcome\"",
",",
"(",
"Outcome",
",",
")",
")",
"response",
"=",
"self",
".",
"... | Returns the details of the outcome with the given id.
:calls: `GET /api/v1/outcomes/:id \
<https://canvas.instructure.com/doc/api/outcomes.html#method.outcomes_api.show>`_
:param outcome: The outcome object or ID to return.
:type outcome: :class:`canvasapi.outcome.Outcome` or int
... | [
"Returns",
"the",
"details",
"of",
"the",
"outcome",
"with",
"the",
"given",
"id",
"."
] | python | train |
saltstack/salt | salt/fileclient.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L67-L84 | def decode_dict_keys_to_str(src):
'''
Convert top level keys from bytes to strings if possible.
This is necessary because Python 3 makes a distinction
between these types.
'''
if not six.PY3 or not isinstance(src, dict):
return src
output = {}
for key, val in six.iteritems(src):... | [
"def",
"decode_dict_keys_to_str",
"(",
"src",
")",
":",
"if",
"not",
"six",
".",
"PY3",
"or",
"not",
"isinstance",
"(",
"src",
",",
"dict",
")",
":",
"return",
"src",
"output",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"six",
".",
"iteritems",
... | Convert top level keys from bytes to strings if possible.
This is necessary because Python 3 makes a distinction
between these types. | [
"Convert",
"top",
"level",
"keys",
"from",
"bytes",
"to",
"strings",
"if",
"possible",
".",
"This",
"is",
"necessary",
"because",
"Python",
"3",
"makes",
"a",
"distinction",
"between",
"these",
"types",
"."
] | python | train |
explosion/spaCy | spacy/util.py | https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/util.py#L149-L152 | def load_model_from_package(name, **overrides):
"""Load a model from an installed package."""
cls = importlib.import_module(name)
return cls.load(**overrides) | [
"def",
"load_model_from_package",
"(",
"name",
",",
"*",
"*",
"overrides",
")",
":",
"cls",
"=",
"importlib",
".",
"import_module",
"(",
"name",
")",
"return",
"cls",
".",
"load",
"(",
"*",
"*",
"overrides",
")"
] | Load a model from an installed package. | [
"Load",
"a",
"model",
"from",
"an",
"installed",
"package",
"."
] | python | train |
spyder-ide/spyder-notebook | spyder_notebook/notebookplugin.py | https://github.com/spyder-ide/spyder-notebook/blob/54e626b9d2a3fccd3e4625b0f97fe06e5bb1a6db/spyder_notebook/notebookplugin.py#L470-L473 | def move_tab(self, index_from, index_to):
"""Move tab."""
client = self.clients.pop(index_from)
self.clients.insert(index_to, client) | [
"def",
"move_tab",
"(",
"self",
",",
"index_from",
",",
"index_to",
")",
":",
"client",
"=",
"self",
".",
"clients",
".",
"pop",
"(",
"index_from",
")",
"self",
".",
"clients",
".",
"insert",
"(",
"index_to",
",",
"client",
")"
] | Move tab. | [
"Move",
"tab",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/core/states/container_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/states/container_state.py#L2101-L2129 | def states(self, states):
""" Setter for _states field
See property
:param states: Dictionary of States
:raises exceptions.TypeError: if the states parameter is of wrong type
:raises exceptions.AttributeError: if the keys of the dictionary and the state_ids in the dictionary do... | [
"def",
"states",
"(",
"self",
",",
"states",
")",
":",
"if",
"not",
"isinstance",
"(",
"states",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"\"states must be of type dict\"",
")",
"if",
"[",
"state_id",
"for",
"state_id",
",",
"state",
"in",
"states... | Setter for _states field
See property
:param states: Dictionary of States
:raises exceptions.TypeError: if the states parameter is of wrong type
:raises exceptions.AttributeError: if the keys of the dictionary and the state_ids in the dictionary do not match | [
"Setter",
"for",
"_states",
"field"
] | python | train |
ladybug-tools/ladybug | ladybug/datacollection.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/datacollection.py#L1322-L1340 | def filter_by_months_per_hour(self, months_per_hour):
"""Filter the Data Collection based on a list of months per hour (as strings).
Args:
months_per_hour: A list of tuples representing months per hour.
Each tuple should possess two values: the first is the month
... | [
"def",
"filter_by_months_per_hour",
"(",
"self",
",",
"months_per_hour",
")",
":",
"_filt_values",
"=",
"[",
"]",
"_filt_datetimes",
"=",
"[",
"]",
"for",
"i",
",",
"d",
"in",
"enumerate",
"(",
"self",
".",
"datetimes",
")",
":",
"if",
"d",
"in",
"months... | Filter the Data Collection based on a list of months per hour (as strings).
Args:
months_per_hour: A list of tuples representing months per hour.
Each tuple should possess two values: the first is the month
and the second is the hour. (eg. (12, 23) = December at 11 PM)
... | [
"Filter",
"the",
"Data",
"Collection",
"based",
"on",
"a",
"list",
"of",
"months",
"per",
"hour",
"(",
"as",
"strings",
")",
"."
] | python | train |
epfl-lts2/pygsp | pygsp/graphs/graph.py | https://github.com/epfl-lts2/pygsp/blob/8ce5bde39206129287375af24fdbcd7edddca8c5/pygsp/graphs/graph.py#L219-L256 | def subgraph(self, vertices):
r"""Create a subgraph from a list of vertices.
Parameters
----------
vertices : list
Vertices to keep.
Either a list of indices or an indicator function.
Returns
-------
subgraph : :class:`Graph`
... | [
"def",
"subgraph",
"(",
"self",
",",
"vertices",
")",
":",
"adjacency",
"=",
"self",
".",
"W",
"[",
"vertices",
",",
":",
"]",
"[",
":",
",",
"vertices",
"]",
"try",
":",
"coords",
"=",
"self",
".",
"coords",
"[",
"vertices",
"]",
"except",
"Attrib... | r"""Create a subgraph from a list of vertices.
Parameters
----------
vertices : list
Vertices to keep.
Either a list of indices or an indicator function.
Returns
-------
subgraph : :class:`Graph`
Subgraph.
Examples
--... | [
"r",
"Create",
"a",
"subgraph",
"from",
"a",
"list",
"of",
"vertices",
"."
] | python | train |
Esri/ArcREST | src/arcrest/ags/_gpobjects.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/_gpobjects.py#L184-L190 | def loadFeatures(self, path_to_fc):
"""
loads a feature class features to the object
"""
from ..common.spatial import featureclass_to_json
v = json.loads(featureclass_to_json(path_to_fc))
self.value = v | [
"def",
"loadFeatures",
"(",
"self",
",",
"path_to_fc",
")",
":",
"from",
".",
".",
"common",
".",
"spatial",
"import",
"featureclass_to_json",
"v",
"=",
"json",
".",
"loads",
"(",
"featureclass_to_json",
"(",
"path_to_fc",
")",
")",
"self",
".",
"value",
"... | loads a feature class features to the object | [
"loads",
"a",
"feature",
"class",
"features",
"to",
"the",
"object"
] | python | train |
Hackerfleet/hfos | modules/enrol/hfos/enrol/enrolmanager.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L651-L675 | def _invite(self, name, method, email, uuid, event, password=""):
"""Actually invite a given user"""
props = {
'uuid': std_uuid(),
'status': 'Open',
'name': name,
'method': method,
'email': email,
'password': password,
... | [
"def",
"_invite",
"(",
"self",
",",
"name",
",",
"method",
",",
"email",
",",
"uuid",
",",
"event",
",",
"password",
"=",
"\"\"",
")",
":",
"props",
"=",
"{",
"'uuid'",
":",
"std_uuid",
"(",
")",
",",
"'status'",
":",
"'Open'",
",",
"'name'",
":",
... | Actually invite a given user | [
"Actually",
"invite",
"a",
"given",
"user"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.