nwo stringlengths 5 86 | sha stringlengths 40 40 | path stringlengths 4 189 | language stringclasses 1 value | identifier stringlengths 1 94 | parameters stringlengths 2 4.03k | argument_list stringclasses 1 value | return_statement stringlengths 0 11.5k | docstring stringlengths 1 33.2k | docstring_summary stringlengths 0 5.15k | docstring_tokens list | function stringlengths 34 151k | function_tokens list | url stringlengths 90 278 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TGAC/KAT | e8870331de2b4bb0a1b3b91c6afb8fb9d59e9216 | deps/boost/tools/build/src/build/scanner.py | python | register | (scanner_class, relevant_properties) | Registers a new generator class, specifying a set of
properties relevant to this scanner. Ctor for that class
should have one parameter: list of properties. | Registers a new generator class, specifying a set of
properties relevant to this scanner. Ctor for that class
should have one parameter: list of properties. | [
"Registers",
"a",
"new",
"generator",
"class",
"specifying",
"a",
"set",
"of",
"properties",
"relevant",
"to",
"this",
"scanner",
".",
"Ctor",
"for",
"that",
"class",
"should",
"have",
"one",
"parameter",
":",
"list",
"of",
"properties",
"."
] | def register(scanner_class, relevant_properties):
""" Registers a new generator class, specifying a set of
properties relevant to this scanner. Ctor for that class
should have one parameter: list of properties.
"""
assert issubclass(scanner_class, Scanner)
assert isinstance(relevant_properties, basestring)
__scanners[str(scanner_class)] = relevant_properties | [
"def",
"register",
"(",
"scanner_class",
",",
"relevant_properties",
")",
":",
"assert",
"issubclass",
"(",
"scanner_class",
",",
"Scanner",
")",
"assert",
"isinstance",
"(",
"relevant_properties",
",",
"basestring",
")",
"__scanners",
"[",
"str",
"(",
"scanner_cl... | https://github.com/TGAC/KAT/blob/e8870331de2b4bb0a1b3b91c6afb8fb9d59e9216/deps/boost/tools/build/src/build/scanner.py#L54-L61 | ||
OpenNI/OpenNI | 1e9524ffd759841789dadb4ca19fb5d4ac5820e7 | Platform/Linux/CreateRedist/Redist_OpenNi.py | python | replace_string_in_file | (findStr,repStr,filePath) | replaces all findStr by repStr in file filePath | replaces all findStr by repStr in file filePath | [
"replaces",
"all",
"findStr",
"by",
"repStr",
"in",
"file",
"filePath"
] | def replace_string_in_file(findStr,repStr,filePath):
"replaces all findStr by repStr in file filePath"
tempName=filePath+'~~~'
input = open(filePath)
output = open(tempName,'w')
for s in input:
output.write(s.replace(findStr,repStr))
output.close()
input.close()
os.remove(filePath)
os.rename(tempName,filePath) | [
"def",
"replace_string_in_file",
"(",
"findStr",
",",
"repStr",
",",
"filePath",
")",
":",
"tempName",
"=",
"filePath",
"+",
"'~~~'",
"input",
"=",
"open",
"(",
"filePath",
")",
"output",
"=",
"open",
"(",
"tempName",
",",
"'w'",
")",
"for",
"s",
"in",
... | https://github.com/OpenNI/OpenNI/blob/1e9524ffd759841789dadb4ca19fb5d4ac5820e7/Platform/Linux/CreateRedist/Redist_OpenNi.py#L57-L67 | ||
google/flatbuffers | b3006913369e0a7550795e477011ac5bebb93497 | python/flatbuffers/flexbuffers.py | python | Builder.Null | (self, key=None) | Encodes None value. | Encodes None value. | [
"Encodes",
"None",
"value",
"."
] | def Null(self, key=None):
"""Encodes None value."""
if key:
self.Key(key)
self._stack.append(Value.Null()) | [
"def",
"Null",
"(",
"self",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
":",
"self",
".",
"Key",
"(",
"key",
")",
"self",
".",
"_stack",
".",
"append",
"(",
"Value",
".",
"Null",
"(",
")",
")"
] | https://github.com/google/flatbuffers/blob/b3006913369e0a7550795e477011ac5bebb93497/python/flatbuffers/flexbuffers.py#L1215-L1219 | ||
raspberrypi/tools | 13474ee775d0c5ec8a7da4fb0a9fa84187abfc87 | arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/share/gcc-4.7.1/python/libstdcxx/v6/printers.py | python | register_libstdcxx_printers | (obj) | Register libstdc++ pretty-printers with objfile Obj. | Register libstdc++ pretty-printers with objfile Obj. | [
"Register",
"libstdc",
"++",
"pretty",
"-",
"printers",
"with",
"objfile",
"Obj",
"."
] | def register_libstdcxx_printers (obj):
"Register libstdc++ pretty-printers with objfile Obj."
global _use_gdb_pp
global libstdcxx_printer
if _use_gdb_pp:
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
else:
if obj is None:
obj = gdb
obj.pretty_printers.append(libstdcxx_printer) | [
"def",
"register_libstdcxx_printers",
"(",
"obj",
")",
":",
"global",
"_use_gdb_pp",
"global",
"libstdcxx_printer",
"if",
"_use_gdb_pp",
":",
"gdb",
".",
"printing",
".",
"register_pretty_printer",
"(",
"obj",
",",
"libstdcxx_printer",
")",
"else",
":",
"if",
"obj... | https://github.com/raspberrypi/tools/blob/13474ee775d0c5ec8a7da4fb0a9fa84187abfc87/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/share/gcc-4.7.1/python/libstdcxx/v6/printers.py#L790-L801 | ||
LiquidPlayer/LiquidCore | 9405979363f2353ac9a71ad8ab59685dd7f919c9 | deps/node-10.15.3/tools/gyp/pylib/gyp/msvs_emulation.py | python | MsvsSettings.GetOutputName | (self, config, expand_special) | return output_file | Gets the explicitly overridden output name for a target or returns None
if it's not overridden. | Gets the explicitly overridden output name for a target or returns None
if it's not overridden. | [
"Gets",
"the",
"explicitly",
"overridden",
"output",
"name",
"for",
"a",
"target",
"or",
"returns",
"None",
"if",
"it",
"s",
"not",
"overridden",
"."
] | def GetOutputName(self, config, expand_special):
"""Gets the explicitly overridden output name for a target or returns None
if it's not overridden."""
config = self._TargetConfig(config)
type = self.spec['type']
root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool'
# TODO(scottmg): Handle OutputDirectory without OutputFile.
output_file = self._Setting((root, 'OutputFile'), config)
if output_file:
output_file = expand_special(self.ConvertVSMacros(
output_file, config=config))
return output_file | [
"def",
"GetOutputName",
"(",
"self",
",",
"config",
",",
"expand_special",
")",
":",
"config",
"=",
"self",
".",
"_TargetConfig",
"(",
"config",
")",
"type",
"=",
"self",
".",
"spec",
"[",
"'type'",
"]",
"root",
"=",
"'VCLibrarianTool'",
"if",
"type",
"=... | https://github.com/LiquidPlayer/LiquidCore/blob/9405979363f2353ac9a71ad8ab59685dd7f919c9/deps/node-10.15.3/tools/gyp/pylib/gyp/msvs_emulation.py#L390-L401 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/windows/Lib/site-packages/pip/_internal/utils/misc.py | python | dist_in_usersite | (dist) | return dist_location(dist).startswith(normalize_path(user_site)) | Return True if given Distribution is installed in user site. | Return True if given Distribution is installed in user site. | [
"Return",
"True",
"if",
"given",
"Distribution",
"is",
"installed",
"in",
"user",
"site",
"."
] | def dist_in_usersite(dist):
# type: (Distribution) -> bool
"""
Return True if given Distribution is installed in user site.
"""
return dist_location(dist).startswith(normalize_path(user_site)) | [
"def",
"dist_in_usersite",
"(",
"dist",
")",
":",
"# type: (Distribution) -> bool",
"return",
"dist_location",
"(",
"dist",
")",
".",
"startswith",
"(",
"normalize_path",
"(",
"user_site",
")",
")"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/windows/Lib/site-packages/pip/_internal/utils/misc.py#L384-L389 | |
lballabio/quantlib-old | 136336947ed4fea9ecc1da6edad188700e821739 | gensrc/gensrc/addins/enumerations.py | python | Enumerations.generateEnumeratedPair | (self, enumeratedPairGroup) | return Enumerations.ENUM_REGISTER2 % {
'type' : enumeratedPairGroup.className(),
'buffer' : buffer } | Generate source code for enumerated type group. | Generate source code for enumerated type group. | [
"Generate",
"source",
"code",
"for",
"enumerated",
"type",
"group",
"."
] | def generateEnumeratedPair(self, enumeratedPairGroup):
"""Generate source code for enumerated type group."""
buffer = ''
for enumeratedPair in enumeratedPairGroup.enumeratedPairs():
buffer += Enumerations.ENUM_LINE3 % {
'id1' : enumeratedPair.id1(),
'id2' : enumeratedPair.id2(),
'value' : enumeratedPair.value() }
return Enumerations.ENUM_REGISTER2 % {
'type' : enumeratedPairGroup.className(),
'buffer' : buffer } | [
"def",
"generateEnumeratedPair",
"(",
"self",
",",
"enumeratedPairGroup",
")",
":",
"buffer",
"=",
"''",
"for",
"enumeratedPair",
"in",
"enumeratedPairGroup",
".",
"enumeratedPairs",
"(",
")",
":",
"buffer",
"+=",
"Enumerations",
".",
"ENUM_LINE3",
"%",
"{",
"'i... | https://github.com/lballabio/quantlib-old/blob/136336947ed4fea9ecc1da6edad188700e821739/gensrc/gensrc/addins/enumerations.py#L140-L150 | |
tensorflow/tensorflow | 419e3a6b650ea4bd1b0cba23c4348f8a69f3272e | tensorflow/python/data/ops/multi_device_iterator_ops.py | python | MultiDeviceIterator.get_next | (self, device=None) | return result | Returns the next element given a `device`, else returns all in a list. | Returns the next element given a `device`, else returns all in a list. | [
"Returns",
"the",
"next",
"element",
"given",
"a",
"device",
"else",
"returns",
"all",
"in",
"a",
"list",
"."
] | def get_next(self, device=None):
"""Returns the next element given a `device`, else returns all in a list."""
if device is not None:
index = self._devices.index(device)
return self._device_iterators[index].get_next()
result = []
for i, device in enumerate(self._devices):
with ops.device(device):
result.append(self._device_iterators[i].get_next())
return result | [
"def",
"get_next",
"(",
"self",
",",
"device",
"=",
"None",
")",
":",
"if",
"device",
"is",
"not",
"None",
":",
"index",
"=",
"self",
".",
"_devices",
".",
"index",
"(",
"device",
")",
"return",
"self",
".",
"_device_iterators",
"[",
"index",
"]",
".... | https://github.com/tensorflow/tensorflow/blob/419e3a6b650ea4bd1b0cba23c4348f8a69f3272e/tensorflow/python/data/ops/multi_device_iterator_ops.py#L303-L313 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | wx/tools/Editra/src/generator.py | python | Html.GetMenuEntry | (self, menu) | return wx.MenuItem(menu, self._id, _("Generate %s") % u"HTML",
_("Generate a %s version of the " \
"current document") % u"HTML") | Returns the Menu control for the HTML generator
@return: menu entry for this generator | Returns the Menu control for the HTML generator
@return: menu entry for this generator | [
"Returns",
"the",
"Menu",
"control",
"for",
"the",
"HTML",
"generator",
"@return",
":",
"menu",
"entry",
"for",
"this",
"generator"
] | def GetMenuEntry(self, menu):
"""Returns the Menu control for the HTML generator
@return: menu entry for this generator
"""
return wx.MenuItem(menu, self._id, _("Generate %s") % u"HTML",
_("Generate a %s version of the " \
"current document") % u"HTML") | [
"def",
"GetMenuEntry",
"(",
"self",
",",
"menu",
")",
":",
"return",
"wx",
".",
"MenuItem",
"(",
"menu",
",",
"self",
".",
"_id",
",",
"_",
"(",
"\"Generate %s\"",
")",
"%",
"u\"HTML\"",
",",
"_",
"(",
"\"Generate a %s version of the \"",
"\"current document... | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/wx/tools/Editra/src/generator.py#L279-L286 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/windows/Lib/turtle.py | python | TNavigator.speed | (self, s=0) | dummy method - to be overwritten by child class | dummy method - to be overwritten by child class | [
"dummy",
"method",
"-",
"to",
"be",
"overwritten",
"by",
"child",
"class"
] | def speed(self, s=0):
"""dummy method - to be overwritten by child class""" | [
"def",
"speed",
"(",
"self",
",",
"s",
"=",
"0",
")",
":"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/windows/Lib/turtle.py#L2003-L2004 | ||
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/setuptools/command/easy_install.py | python | easy_install.create_home_path | (self) | Create directories under ~. | Create directories under ~. | [
"Create",
"directories",
"under",
"~",
"."
] | def create_home_path(self):
"""Create directories under ~."""
if not self.user:
return
home = convert_path(os.path.expanduser("~"))
for name, path in six.iteritems(self.config_vars):
if path.startswith(home) and not os.path.isdir(path):
self.debug_print("os.makedirs('%s', 0o700)" % path)
os.makedirs(path, 0o700) | [
"def",
"create_home_path",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"user",
":",
"return",
"home",
"=",
"convert_path",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
")",
"for",
"name",
",",
"path",
"in",
"six",
".",
"iteritem... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/setuptools/command/easy_install.py#L1337-L1345 | ||
benoitsteiner/tensorflow-opencl | cb7cb40a57fde5cfd4731bc551e82a1e2fef43a5 | tensorflow/contrib/distributions/python/ops/vector_diffeomixture.py | python | interpolate_loc | (deg, interpolate_weight, loc) | Helper which interpolates between two locs. | Helper which interpolates between two locs. | [
"Helper",
"which",
"interpolates",
"between",
"two",
"locs",
"."
] | def interpolate_loc(deg, interpolate_weight, loc):
"""Helper which interpolates between two locs."""
if len(loc) != 2:
raise NotImplementedError("Currently only bimixtures are supported; "
"len(scale)={} is not 2.".format(len(loc)))
with ops.name_scope("interpolate_loc", values=[interpolate_weight, loc]):
if loc is None or loc[0] is None and loc[1] is None:
return [None]*deg
w = interpolate_weight[..., array_ops.newaxis, :] # shape: [B, 1, deg]
loc = [x[..., array_ops.newaxis] # shape: [B, e, 1]
if x is not None else None for x in loc]
if loc[0] is None:
x = (1. - w) * loc[1] # shape: [B, e, deg]
elif loc[1] is None:
x = w * loc[0] # shape: [B, e, deg]
else:
delta = loc[0] - loc[1]
x = w * delta + loc[1] # shape: [B, e, deg]
return [x[..., k] for k in range(deg)] | [
"def",
"interpolate_loc",
"(",
"deg",
",",
"interpolate_weight",
",",
"loc",
")",
":",
"if",
"len",
"(",
"loc",
")",
"!=",
"2",
":",
"raise",
"NotImplementedError",
"(",
"\"Currently only bimixtures are supported; \"",
"\"len(scale)={} is not 2.\"",
".",
"format",
"... | https://github.com/benoitsteiner/tensorflow-opencl/blob/cb7cb40a57fde5cfd4731bc551e82a1e2fef43a5/tensorflow/contrib/distributions/python/ops/vector_diffeomixture.py#L724-L742 | ||
smilehao/xlua-framework | a03801538be2b0e92d39332d445b22caca1ef61f | ConfigData/trunk/tools/protobuf-2.5.0/protobuf-2.5.0/python/mox.py | python | UnorderedGroup.AddMethod | (self, mock_method) | Add a method to this group.
Args:
mock_method: A mock method to be added to this group. | Add a method to this group. | [
"Add",
"a",
"method",
"to",
"this",
"group",
"."
] | def AddMethod(self, mock_method):
"""Add a method to this group.
Args:
mock_method: A mock method to be added to this group.
"""
self._methods.append(mock_method) | [
"def",
"AddMethod",
"(",
"self",
",",
"mock_method",
")",
":",
"self",
".",
"_methods",
".",
"append",
"(",
"mock_method",
")"
] | https://github.com/smilehao/xlua-framework/blob/a03801538be2b0e92d39332d445b22caca1ef61f/ConfigData/trunk/tools/protobuf-2.5.0/protobuf-2.5.0/python/mox.py#L1214-L1221 | ||
tensorflow/tensorflow | 419e3a6b650ea4bd1b0cba23c4348f8a69f3272e | tensorflow/python/keras/layers/merge.py | python | _Merge._compute_elemwise_op_output_shape | (self, shape1, shape2) | return tuple(output_shape) | Computes the shape of the resultant of an elementwise operation.
Args:
shape1: tuple or None. Shape of the first tensor
shape2: tuple or None. Shape of the second tensor
Returns:
expected output shape when an element-wise operation is
carried out on 2 tensors with shapes shape1 and shape2.
tuple or None.
Raises:
ValueError: if shape1 and shape2 are not compatible for
element-wise operations. | Computes the shape of the resultant of an elementwise operation. | [
"Computes",
"the",
"shape",
"of",
"the",
"resultant",
"of",
"an",
"elementwise",
"operation",
"."
] | def _compute_elemwise_op_output_shape(self, shape1, shape2):
"""Computes the shape of the resultant of an elementwise operation.
Args:
shape1: tuple or None. Shape of the first tensor
shape2: tuple or None. Shape of the second tensor
Returns:
expected output shape when an element-wise operation is
carried out on 2 tensors with shapes shape1 and shape2.
tuple or None.
Raises:
ValueError: if shape1 and shape2 are not compatible for
element-wise operations.
"""
if None in [shape1, shape2]:
return None
elif len(shape1) < len(shape2):
return self._compute_elemwise_op_output_shape(shape2, shape1)
elif not shape2:
return shape1
output_shape = list(shape1[:-len(shape2)])
for i, j in zip(shape1[-len(shape2):], shape2):
if i is None or j is None:
output_shape.append(None)
elif i == 1:
output_shape.append(j)
elif j == 1:
output_shape.append(i)
else:
if i != j:
raise ValueError(
'Operands could not be broadcast '
'together with shapes ' + str(shape1) + ' ' + str(shape2))
output_shape.append(i)
return tuple(output_shape) | [
"def",
"_compute_elemwise_op_output_shape",
"(",
"self",
",",
"shape1",
",",
"shape2",
")",
":",
"if",
"None",
"in",
"[",
"shape1",
",",
"shape2",
"]",
":",
"return",
"None",
"elif",
"len",
"(",
"shape1",
")",
"<",
"len",
"(",
"shape2",
")",
":",
"retu... | https://github.com/tensorflow/tensorflow/blob/419e3a6b650ea4bd1b0cba23c4348f8a69f3272e/tensorflow/python/keras/layers/merge.py#L47-L83 | |
apache/incubator-mxnet | f03fb23f1d103fec9541b5ae59ee06b1734a51d9 | python/mxnet/ndarray/numpy/random.py | python | power | (a, size=None, device=None, out=None) | return _api_internal.powerd(a, size, device, out) | r"""Draw samples in [0, 1] from a power distribution with given parameter a.
Parameters
----------
a : float or array_like of floats
Shape of the distribution. Must be > 0.
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
``m * n * k`` samples are drawn. If size is ``None`` (default),
a single value is returned if ``a`` is a scalar. Otherwise,
``np.array(a).size`` samples are drawn.
Returns
-------
out : ndarray or scalar
Drawn samples from the power distribution.
Examples
--------
>>> np.random.power(a=5)
array(0.8602478)
>>> np.random.power(a=5, size=[2,3])
array([[0.988391 , 0.5153122 , 0.9383134 ],
[0.9078098 , 0.87819266, 0.730635]])
>>> np.random.power(a=np.array([2,3])
array([0.7499419 , 0.88894516])
The probability density function is f(x; a) = ax^{a-1}, 0 \le x \le 1, a>0.
The power distribution is just the inverse of the Pareto distribution and
a special case of the Beta distribution. | r"""Draw samples in [0, 1] from a power distribution with given parameter a. | [
"r",
"Draw",
"samples",
"in",
"[",
"0",
"1",
"]",
"from",
"a",
"power",
"distribution",
"with",
"given",
"parameter",
"a",
"."
] | def power(a, size=None, device=None, out=None):
r"""Draw samples in [0, 1] from a power distribution with given parameter a.
Parameters
----------
a : float or array_like of floats
Shape of the distribution. Must be > 0.
size : int or tuple of ints, optional
Output shape. If the given shape is, e.g., ``(m, n, k)``, then
``m * n * k`` samples are drawn. If size is ``None`` (default),
a single value is returned if ``a`` is a scalar. Otherwise,
``np.array(a).size`` samples are drawn.
Returns
-------
out : ndarray or scalar
Drawn samples from the power distribution.
Examples
--------
>>> np.random.power(a=5)
array(0.8602478)
>>> np.random.power(a=5, size=[2,3])
array([[0.988391 , 0.5153122 , 0.9383134 ],
[0.9078098 , 0.87819266, 0.730635]])
>>> np.random.power(a=np.array([2,3])
array([0.7499419 , 0.88894516])
The probability density function is f(x; a) = ax^{a-1}, 0 \le x \le 1, a>0.
The power distribution is just the inverse of the Pareto distribution and
a special case of the Beta distribution.
"""
if device is None:
device = str(current_device())
else:
device = str(device)
if size == ():
size = None
return _api_internal.powerd(a, size, device, out) | [
"def",
"power",
"(",
"a",
",",
"size",
"=",
"None",
",",
"device",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"if",
"device",
"is",
"None",
":",
"device",
"=",
"str",
"(",
"current_device",
"(",
")",
")",
"else",
":",
"device",
"=",
"str",
... | https://github.com/apache/incubator-mxnet/blob/f03fb23f1d103fec9541b5ae59ee06b1734a51d9/python/mxnet/ndarray/numpy/random.py#L662-L700 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numba/targets/codegen.py | python | CodeLibrary.get_defined_functions | (self) | Get all functions defined in the library. The library must have
been finalized. | Get all functions defined in the library. The library must have
been finalized. | [
"Get",
"all",
"functions",
"defined",
"in",
"the",
"library",
".",
"The",
"library",
"must",
"have",
"been",
"finalized",
"."
] | def get_defined_functions(self):
"""
Get all functions defined in the library. The library must have
been finalized.
"""
mod = self._final_module
for fn in mod.functions:
if not fn.is_declaration:
yield fn | [
"def",
"get_defined_functions",
"(",
"self",
")",
":",
"mod",
"=",
"self",
".",
"_final_module",
"for",
"fn",
"in",
"mod",
".",
"functions",
":",
"if",
"not",
"fn",
".",
"is_declaration",
":",
"yield",
"fn"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numba/targets/codegen.py#L288-L296 | ||
ledger/ledger | 8e79216887cf3c342dfca1ffa52cf4e6389d6de4 | contrib/non-profit-audit-reports/ooolib2/__init__.py | python | Calc._zip_insert | (self, file, filename, data) | Insert a file into the zip archive | Insert a file into the zip archive | [
"Insert",
"a",
"file",
"into",
"the",
"zip",
"archive"
] | def _zip_insert(self, file, filename, data):
"Insert a file into the zip archive"
# zip seems to struggle with non-ascii characters
data = data.encode('utf-8')
now = time.localtime(time.time())[:6]
info = zipfile.ZipInfo(filename)
info.date_time = now
info.compress_type = zipfile.ZIP_DEFLATED
file.writestr(info, data) | [
"def",
"_zip_insert",
"(",
"self",
",",
"file",
",",
"filename",
",",
"data",
")",
":",
"# zip seems to struggle with non-ascii characters",
"data",
"=",
"data",
".",
"encode",
"(",
"'utf-8'",
")",
"now",
"=",
"time",
".",
"localtime",
"(",
"time",
".",
"tim... | https://github.com/ledger/ledger/blob/8e79216887cf3c342dfca1ffa52cf4e6389d6de4/contrib/non-profit-audit-reports/ooolib2/__init__.py#L1232-L1242 | ||
adobe/chromium | cfe5bf0b51b1f6b9fe239c2a3c2f2364da9967d7 | tools/checkperms/checkperms.py | python | CheckFile | (file_path) | return None | Checks file_path's permissions.
Args:
file_path: The file path to check.
Returns:
Either a string describing the error if there was one, or None if the file
checked out OK. | Checks file_path's permissions. | [
"Checks",
"file_path",
"s",
"permissions",
"."
] | def CheckFile(file_path):
"""Checks file_path's permissions.
Args:
file_path: The file path to check.
Returns:
Either a string describing the error if there was one, or None if the file
checked out OK.
"""
if VERBOSE:
print 'Checking file: ' + file_path
file_path_lower = file_path.lower()
if IsWhiteListed(file_path_lower):
return None
# Not whitelisted, stat the file and check permissions.
try:
st_mode = os.stat(file_path).st_mode
except IOError, e:
return 'Failed to stat file: %s' % e
except OSError, e:
return 'Failed to stat file: %s' % e
if EXECUTABLE_PERMISSION & st_mode:
# Look if the file starts with #!/
with open(file_path, 'rb') as f:
if f.read(3) == '#!/':
# That's fine.
return None
# TODO(maruel): Check that non-executable file do not start with a shebang.
error = 'Contains executable permission'
if VERBOSE:
return '%s: %06o' % (error, st_mode)
return error
return None | [
"def",
"CheckFile",
"(",
"file_path",
")",
":",
"if",
"VERBOSE",
":",
"print",
"'Checking file: '",
"+",
"file_path",
"file_path_lower",
"=",
"file_path",
".",
"lower",
"(",
")",
"if",
"IsWhiteListed",
"(",
"file_path_lower",
")",
":",
"return",
"None",
"# Not... | https://github.com/adobe/chromium/blob/cfe5bf0b51b1f6b9fe239c2a3c2f2364da9967d7/tools/checkperms/checkperms.py#L155-L191 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numpy/distutils/ccompiler.py | python | CCompiler_find_executables | (self) | Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found. | Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found. | [
"Does",
"nothing",
"here",
"but",
"is",
"called",
"by",
"the",
"get_version",
"method",
"and",
"can",
"be",
"overridden",
"by",
"subclasses",
".",
"In",
"particular",
"it",
"is",
"redefined",
"in",
"the",
"FCompiler",
"class",
"where",
"more",
"documentation",... | def CCompiler_find_executables(self):
"""
Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found.
"""
pass | [
"def",
"CCompiler_find_executables",
"(",
"self",
")",
":",
"pass"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numpy/distutils/ccompiler.py#L101-L108 | ||
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/mac/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py | python | set_event_loop | (loop) | Equivalent to calling get_event_loop_policy().set_event_loop(loop). | Equivalent to calling get_event_loop_policy().set_event_loop(loop). | [
"Equivalent",
"to",
"calling",
"get_event_loop_policy",
"()",
".",
"set_event_loop",
"(",
"loop",
")",
"."
] | def set_event_loop(loop):
"""Equivalent to calling get_event_loop_policy().set_event_loop(loop)."""
get_event_loop_policy().set_event_loop(loop) | [
"def",
"set_event_loop",
"(",
"loop",
")",
":",
"get_event_loop_policy",
"(",
")",
".",
"set_event_loop",
"(",
"loop",
")"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/mac/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py#L755-L757 | ||
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/mac/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/package_index.py | python | ContentChecker.feed | (self, block) | return | Feed a block of data to the hash. | Feed a block of data to the hash. | [
"Feed",
"a",
"block",
"of",
"data",
"to",
"the",
"hash",
"."
] | def feed(self, block):
"""
Feed a block of data to the hash.
"""
return | [
"def",
"feed",
"(",
"self",
",",
"block",
")",
":",
"return"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/mac/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/package_index.py#L246-L250 | |
quarnster/SublimeClang | 6823e7f0904e60680ac9f898108e301582ec5505 | internals/clang/cindex.py | python | Type.get_canonical | (self) | return Type_get_canonical(self) | Return the canonical type for a Type.
Clang's type system explicitly models typedefs and all the
ways a specific type can be represented. The canonical type
is the underlying type with all the "sugar" removed. For
example, if 'T' is a typedef for 'int', the canonical type for
'T' would be 'int'. | Return the canonical type for a Type. | [
"Return",
"the",
"canonical",
"type",
"for",
"a",
"Type",
"."
] | def get_canonical(self):
"""
Return the canonical type for a Type.
Clang's type system explicitly models typedefs and all the
ways a specific type can be represented. The canonical type
is the underlying type with all the "sugar" removed. For
example, if 'T' is a typedef for 'int', the canonical type for
'T' would be 'int'.
"""
return Type_get_canonical(self) | [
"def",
"get_canonical",
"(",
"self",
")",
":",
"return",
"Type_get_canonical",
"(",
"self",
")"
] | https://github.com/quarnster/SublimeClang/blob/6823e7f0904e60680ac9f898108e301582ec5505/internals/clang/cindex.py#L1457-L1467 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/osx_cocoa/_core.py | python | InputStream.flush | (*args, **kwargs) | return _core_.InputStream_flush(*args, **kwargs) | flush(self) | flush(self) | [
"flush",
"(",
"self",
")"
] | def flush(*args, **kwargs):
"""flush(self)"""
return _core_.InputStream_flush(*args, **kwargs) | [
"def",
"flush",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_core_",
".",
"InputStream_flush",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/_core.py#L2162-L2164 | |
pmq20/node-packer | 12c46c6e44fbc14d9ee645ebd17d5296b324f7e0 | current/tools/gyp/pylib/gyp/generator/make.py | python | EscapeShellArgument | (s) | return "'" + s.replace("'", "'\\''") + "'" | Quotes an argument so that it will be interpreted literally by a POSIX
shell. Taken from
http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python | Quotes an argument so that it will be interpreted literally by a POSIX
shell. Taken from
http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python | [
"Quotes",
"an",
"argument",
"so",
"that",
"it",
"will",
"be",
"interpreted",
"literally",
"by",
"a",
"POSIX",
"shell",
".",
"Taken",
"from",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"35817",
"/",
"whats",
"-",
"the",
"-",
... | def EscapeShellArgument(s):
"""Quotes an argument so that it will be interpreted literally by a POSIX
shell. Taken from
http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python
"""
return "'" + s.replace("'", "'\\''") + "'" | [
"def",
"EscapeShellArgument",
"(",
"s",
")",
":",
"return",
"\"'\"",
"+",
"s",
".",
"replace",
"(",
"\"'\"",
",",
"\"'\\\\''\"",
")",
"+",
"\"'\""
] | https://github.com/pmq20/node-packer/blob/12c46c6e44fbc14d9ee645ebd17d5296b324f7e0/current/tools/gyp/pylib/gyp/generator/make.py#L603-L608 | |
sumoprojects/sumokoin | 2857d0bffd36bf2aa579ef80518f4cb099c98b05 | contrib/depends/gen-sdk.py | python | cd | (path) | Context manager that restores PWD even if an exception was raised. | Context manager that restores PWD even if an exception was raised. | [
"Context",
"manager",
"that",
"restores",
"PWD",
"even",
"if",
"an",
"exception",
"was",
"raised",
"."
] | def cd(path):
"""Context manager that restores PWD even if an exception was raised."""
old_pwd = os.getcwd()
os.chdir(str(path))
try:
yield
finally:
os.chdir(old_pwd) | [
"def",
"cd",
"(",
"path",
")",
":",
"old_pwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"str",
"(",
"path",
")",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"old_pwd",
")"
] | https://github.com/sumoprojects/sumokoin/blob/2857d0bffd36bf2aa579ef80518f4cb099c98b05/contrib/depends/gen-sdk.py#L12-L19 | ||
RoboJackets/robocup-software | bce13ce53ddb2ecb9696266d980722c34617dc15 | rj_gameplay/stp/rc.py | python | WorldState.field | (self) | return self.__field | :return: The Field object | :return: The Field object | [
":",
"return",
":",
"The",
"Field",
"object"
] | def field(self) -> Field:
"""
:return: The Field object
"""
return self.__field | [
"def",
"field",
"(",
"self",
")",
"->",
"Field",
":",
"return",
"self",
".",
"__field"
] | https://github.com/RoboJackets/robocup-software/blob/bce13ce53ddb2ecb9696266d980722c34617dc15/rj_gameplay/stp/rc.py#L688-L692 | |
PaddlePaddle/Paddle | 1252f4bb3e574df80aa6d18c7ddae1b3a90bd81c | python/paddle/fluid/framework.py | python | EagerParamBase.__deepcopy__ | (self, memo) | return new_param | Deep copy parameter, it will always performs Tensor copy.
Examples:
.. code-block:: python
import paddle
import copy
linear = paddle.nn.Linear(1, 3)
linear_copy = copy.deepcopy(linear)
print(linear.weight)
# Parameter containing:
# Tensor(shape=[1, 3], dtype=float32, place=CPUPlace, stop_gradient=False,
# [[-0.30929261, -0.90929240, -1.07851017]])
print(linear_copy.weight)
# Parameter containing:
# Tensor(shape=[1, 3], dtype=float32, place=CPUPlace, stop_gradient=False,
# [[-0.30929261, -0.90929240, -1.07851017]]) | Deep copy parameter, it will always performs Tensor copy. | [
"Deep",
"copy",
"parameter",
"it",
"will",
"always",
"performs",
"Tensor",
"copy",
"."
] | def __deepcopy__(self, memo):
"""
Deep copy parameter, it will always performs Tensor copy.
Examples:
.. code-block:: python
import paddle
import copy
linear = paddle.nn.Linear(1, 3)
linear_copy = copy.deepcopy(linear)
print(linear.weight)
# Parameter containing:
# Tensor(shape=[1, 3], dtype=float32, place=CPUPlace, stop_gradient=False,
# [[-0.30929261, -0.90929240, -1.07851017]])
print(linear_copy.weight)
# Parameter containing:
# Tensor(shape=[1, 3], dtype=float32, place=CPUPlace, stop_gradient=False,
# [[-0.30929261, -0.90929240, -1.07851017]])
"""
state = copy.deepcopy(self.__dict__, memo)
state["name"] = self.name + unique_name.generate("_deepcopy")
new_param = EagerParamBase(self.shape, self.dtype, **state)
memo[id(self)] = new_param
new_param.copy_(self, True)
return new_param | [
"def",
"__deepcopy__",
"(",
"self",
",",
"memo",
")",
":",
"state",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"__dict__",
",",
"memo",
")",
"state",
"[",
"\"name\"",
"]",
"=",
"self",
".",
"name",
"+",
"unique_name",
".",
"generate",
"(",
"\"_d... | https://github.com/PaddlePaddle/Paddle/blob/1252f4bb3e574df80aa6d18c7ddae1b3a90bd81c/python/paddle/fluid/framework.py#L6522-L6550 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/osx_carbon/html.py | python | HtmlFilter.__init__ | (self, *args, **kwargs) | __init__(self) -> HtmlFilter | __init__(self) -> HtmlFilter | [
"__init__",
"(",
"self",
")",
"-",
">",
"HtmlFilter"
] | def __init__(self, *args, **kwargs):
"""__init__(self) -> HtmlFilter"""
_html.HtmlFilter_swiginit(self,_html.new_HtmlFilter(*args, **kwargs))
HtmlFilter._setCallbackInfo(self, self, HtmlFilter) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_html",
".",
"HtmlFilter_swiginit",
"(",
"self",
",",
"_html",
".",
"new_HtmlFilter",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"HtmlFilter",
".",
"_setC... | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_carbon/html.py#L906-L909 | ||
catboost/catboost | 167f64f237114a4d10b2b4ee42adb4569137debe | contrib/tools/python3/src/Lib/xml/sax/_exceptions.py | python | SAXException.__str__ | (self) | return self._msg | Create a string representation of the exception. | Create a string representation of the exception. | [
"Create",
"a",
"string",
"representation",
"of",
"the",
"exception",
"."
] | def __str__(self):
"Create a string representation of the exception."
return self._msg | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"_msg"
] | https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/tools/python3/src/Lib/xml/sax/_exceptions.py#L34-L36 | |
benoitsteiner/tensorflow-opencl | cb7cb40a57fde5cfd4731bc551e82a1e2fef43a5 | tensorflow/python/ops/data_flow_ops.py | python | QueueBase.is_closed | (self, name=None) | Returns true if queue is closed.
This operation returns true if the queue is closed and false if the queue
is open.
Args:
name: A name for the operation (optional).
Returns:
True if the queue is closed and false if the queue is open. | Returns true if queue is closed. | [
"Returns",
"true",
"if",
"queue",
"is",
"closed",
"."
] | def is_closed(self, name=None):
""" Returns true if queue is closed.
This operation returns true if the queue is closed and false if the queue
is open.
Args:
name: A name for the operation (optional).
Returns:
True if the queue is closed and false if the queue is open.
"""
if name is None:
name = "%s_Is_Closed" % self._name
if self._queue_ref.dtype == _dtypes.resource:
return gen_data_flow_ops.queue_is_closed_v2(self._queue_ref,name=name)
else:
return gen_data_flow_ops.queue_is_closed_(self._queue_ref,name=name) | [
"def",
"is_closed",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"\"%s_Is_Closed\"",
"%",
"self",
".",
"_name",
"if",
"self",
".",
"_queue_ref",
".",
"dtype",
"==",
"_dtypes",
".",
"resource",
":",
"r... | https://github.com/benoitsteiner/tensorflow-opencl/blob/cb7cb40a57fde5cfd4731bc551e82a1e2fef43a5/tensorflow/python/ops/data_flow_ops.py#L557-L574 | ||
mantidproject/mantid | 03deeb89254ec4289edb8771e0188c2090a02f32 | qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/Common/corrections_tab_widget/background_corrections_presenter.py | python | BackgroundCorrectionsPresenter.handle_instrument_changed | (self) | User changes the selected instrument. | User changes the selected instrument. | [
"User",
"changes",
"the",
"selected",
"instrument",
"."
] | def handle_instrument_changed(self) -> None:
"""User changes the selected instrument."""
self.model.set_background_correction_mode(BACKGROUND_MODE_NONE)
self.model.set_selected_function(FLAT_BACKGROUND_AND_EXP_DECAY)
self.view.background_correction_mode = BACKGROUND_MODE_NONE
self.view.selected_function = FLAT_BACKGROUND_AND_EXP_DECAY
self.model.clear_background_corrections_data() | [
"def",
"handle_instrument_changed",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"model",
".",
"set_background_correction_mode",
"(",
"BACKGROUND_MODE_NONE",
")",
"self",
".",
"model",
".",
"set_selected_function",
"(",
"FLAT_BACKGROUND_AND_EXP_DECAY",
")",
"self... | https://github.com/mantidproject/mantid/blob/03deeb89254ec4289edb8771e0188c2090a02f32/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/Common/corrections_tab_widget/background_corrections_presenter.py#L40-L46 | ||
ApolloAuto/apollo-platform | 86d9dc6743b496ead18d597748ebabd34a513289 | ros/ros_comm/rosservice/src/rosservice/__init__.py | python | _rosservice_cmd_find | (argv=sys.argv) | Implements 'rosservice type'
@param argv: command-line args
@type argv: [str] | Implements 'rosservice type' | [
"Implements",
"rosservice",
"type"
] | def _rosservice_cmd_find(argv=sys.argv):
"""
Implements 'rosservice type'
@param argv: command-line args
@type argv: [str]
"""
args = argv[2:]
parser = OptionParser(usage="usage: %prog find msg-type", prog=NAME)
options, args = parser.parse_args(args)
if not len(args):
parser.error("please specify a message type")
if len(args) > 1:
parser.error("you may only specify one message type")
print('\n'.join(rosservice_find(args[0]))) | [
"def",
"_rosservice_cmd_find",
"(",
"argv",
"=",
"sys",
".",
"argv",
")",
":",
"args",
"=",
"argv",
"[",
"2",
":",
"]",
"parser",
"=",
"OptionParser",
"(",
"usage",
"=",
"\"usage: %prog find msg-type\"",
",",
"prog",
"=",
"NAME",
")",
"options",
",",
"ar... | https://github.com/ApolloAuto/apollo-platform/blob/86d9dc6743b496ead18d597748ebabd34a513289/ros/ros_comm/rosservice/src/rosservice/__init__.py#L332-L346 | ||
avast/retdec | b9879088a5f0278508185ec645494e6c5c57a455 | scripts/type_extractor/type_extractor/parse_structs_unions.py | python | split_members | (s) | return parts | Struct members are separated by semicolon. Returns list of members. | Struct members are separated by semicolon. Returns list of members. | [
"Struct",
"members",
"are",
"separated",
"by",
"semicolon",
".",
"Returns",
"list",
"of",
"members",
"."
] | def split_members(s):
"""Struct members are separated by semicolon. Returns list of members."""
parts = []
bracket_level = 0
current = []
for c in s:
if c == ";" and bracket_level == 0:
parts.append("".join(current).strip())
current = []
else:
if c == "{":
bracket_level += 1
elif c == "}":
bracket_level -= 1
current.append(c)
return parts | [
"def",
"split_members",
"(",
"s",
")",
":",
"parts",
"=",
"[",
"]",
"bracket_level",
"=",
"0",
"current",
"=",
"[",
"]",
"for",
"c",
"in",
"s",
":",
"if",
"c",
"==",
"\";\"",
"and",
"bracket_level",
"==",
"0",
":",
"parts",
".",
"append",
"(",
"\... | https://github.com/avast/retdec/blob/b9879088a5f0278508185ec645494e6c5c57a455/scripts/type_extractor/type_extractor/parse_structs_unions.py#L202-L217 | |
mantidproject/mantid | 03deeb89254ec4289edb8771e0188c2090a02f32 | qt/python/mantidqtinterfaces/mantidqtinterfaces/reduction_gui/widgets/sans/stitcher.py | python | StitcherWidget.plot_result | (self) | Plot the scaled data sets | Plot the scaled data sets | [
"Plot",
"the",
"scaled",
"data",
"sets"
] | def plot_result(self):
"""
Plot the scaled data sets
"""
low_xmin = util._check_and_get_float_line_edit(self._content.low_min_edit)
low_xmax = util._check_and_get_float_line_edit(self._content.low_max_edit)
med_xmin = util._check_and_get_float_line_edit(self._content.medium_min_edit)
med_xmax = util._check_and_get_float_line_edit(self._content.medium_max_edit)
ws_list = []
if self._low_q_data is not None:
xmin, _ = self._low_q_data.get_skipped_range()
self._low_q_data.apply_scale(xmin, low_xmax)
ws_list.append(self._low_q_data.get_scaled_ws())
if self._medium_q_data is not None:
_, xmax = self._medium_q_data.get_skipped_range()
if self._high_q_data is not None:
xmax = med_xmax
self._medium_q_data.apply_scale(low_xmin, xmax)
ws_list.append(self._medium_q_data.get_scaled_ws())
if self._high_q_data is not None:
_, xmax = self._high_q_data.get_skipped_range()
self._high_q_data.apply_scale(med_xmin, xmax)
ws_list.append(self._high_q_data.get_scaled_ws())
if len(ws_list) > 0:
g = plotSpectrum(ws_list, [0], error_bars=True)
g.suptitle(self._graph) | [
"def",
"plot_result",
"(",
"self",
")",
":",
"low_xmin",
"=",
"util",
".",
"_check_and_get_float_line_edit",
"(",
"self",
".",
"_content",
".",
"low_min_edit",
")",
"low_xmax",
"=",
"util",
".",
"_check_and_get_float_line_edit",
"(",
"self",
".",
"_content",
"."... | https://github.com/mantidproject/mantid/blob/03deeb89254ec4289edb8771e0188c2090a02f32/qt/python/mantidqtinterfaces/mantidqtinterfaces/reduction_gui/widgets/sans/stitcher.py#L463-L492 | ||
pytorch/pytorch | 7176c92687d3cc847cc046bf002269c6949a21c2 | torch/__init__.py | python | set_deterministic_debug_mode | (debug_mode: Union[builtins.int, str]) | r"""Sets the debug mode for deterministic operations.
.. note:: This is an alternative interface for
:func:`torch.use_deterministic_algorithms`. Refer to that function's
documentation for details about affected operations.
Args:
debug_mode(str or int): If "default" or 0, don't error or warn on
nondeterministic operations. If "warn" or 1, warn on
nondeterministic operations. If "error" or 2, error on
nondeterministic operations. | r"""Sets the debug mode for deterministic operations. | [
"r",
"Sets",
"the",
"debug",
"mode",
"for",
"deterministic",
"operations",
"."
] | def set_deterministic_debug_mode(debug_mode: Union[builtins.int, str]) -> None:
r"""Sets the debug mode for deterministic operations.
.. note:: This is an alternative interface for
:func:`torch.use_deterministic_algorithms`. Refer to that function's
documentation for details about affected operations.
Args:
debug_mode(str or int): If "default" or 0, don't error or warn on
nondeterministic operations. If "warn" or 1, warn on
nondeterministic operations. If "error" or 2, error on
nondeterministic operations.
"""
# NOTE: builtins.int is used here because int in this scope resolves
# to torch.int
if not isinstance(debug_mode, (builtins.int, str)):
raise TypeError(f'debug_mode must be str or int, but got {type(debug_mode)}')
if isinstance(debug_mode, str):
if debug_mode == 'default':
debug_mode = 0
elif debug_mode == 'warn':
debug_mode = 1
elif debug_mode == 'error':
debug_mode = 2
else:
raise RuntimeError(
'invalid value of debug_mode, expected one of `default`, '
f'`warn`, `error`, but got {debug_mode}')
if debug_mode == 0:
_C._set_deterministic_algorithms(False)
elif debug_mode == 1:
_C._set_deterministic_algorithms(True, warn_only=True)
elif debug_mode == 2:
_C._set_deterministic_algorithms(True)
else:
raise RuntimeError(
'invalid value of debug_mode, expected 0, 1, or 2, '
f'but got {debug_mode}') | [
"def",
"set_deterministic_debug_mode",
"(",
"debug_mode",
":",
"Union",
"[",
"builtins",
".",
"int",
",",
"str",
"]",
")",
"->",
"None",
":",
"# NOTE: builtins.int is used here because int in this scope resolves",
"# to torch.int",
"if",
"not",
"isinstance",
"(",
"debug... | https://github.com/pytorch/pytorch/blob/7176c92687d3cc847cc046bf002269c6949a21c2/torch/__init__.py#L509-L549 | ||
protocolbuffers/protobuf | b5ab0b7a18b7336c60130f4ddb2d97c51792f896 | python/google/protobuf/descriptor.py | python | _OptionsOrNone | (descriptor_proto) | Returns the value of the field `options`, or None if it is not set. | Returns the value of the field `options`, or None if it is not set. | [
"Returns",
"the",
"value",
"of",
"the",
"field",
"options",
"or",
"None",
"if",
"it",
"is",
"not",
"set",
"."
] | def _OptionsOrNone(descriptor_proto):
"""Returns the value of the field `options`, or None if it is not set."""
if descriptor_proto.HasField('options'):
return descriptor_proto.options
else:
return None | [
"def",
"_OptionsOrNone",
"(",
"descriptor_proto",
")",
":",
"if",
"descriptor_proto",
".",
"HasField",
"(",
"'options'",
")",
":",
"return",
"descriptor_proto",
".",
"options",
"else",
":",
"return",
"None"
] | https://github.com/protocolbuffers/protobuf/blob/b5ab0b7a18b7336c60130f4ddb2d97c51792f896/python/google/protobuf/descriptor.py#L1053-L1058 | ||
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/msw/_controls.py | python | TreeCtrl.GetImageList | (*args, **kwargs) | return _controls_.TreeCtrl_GetImageList(*args, **kwargs) | GetImageList(self) -> ImageList | GetImageList(self) -> ImageList | [
"GetImageList",
"(",
"self",
")",
"-",
">",
"ImageList"
] | def GetImageList(*args, **kwargs):
"""GetImageList(self) -> ImageList"""
return _controls_.TreeCtrl_GetImageList(*args, **kwargs) | [
"def",
"GetImageList",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_controls_",
".",
"TreeCtrl_GetImageList",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/msw/_controls.py#L5236-L5238 | |
yrnkrn/zapcc | c6a8aa30006d997eff0d60fd37b0e62b8aa0ea50 | utils/lit/lit/llvm/config.py | python | LLVMConfig.use_clang | (self, required=True) | Configure the test suite to be able to invoke clang.
Sets up some environment variables important to clang, locates a
just-built or installed clang, and add a set of standard
substitutions useful to any test suite that makes use of clang. | Configure the test suite to be able to invoke clang. | [
"Configure",
"the",
"test",
"suite",
"to",
"be",
"able",
"to",
"invoke",
"clang",
"."
] | def use_clang(self, required=True):
"""Configure the test suite to be able to invoke clang.
Sets up some environment variables important to clang, locates a
just-built or installed clang, and add a set of standard
substitutions useful to any test suite that makes use of clang.
"""
# Clear some environment variables that might affect Clang.
#
# This first set of vars are read by Clang, but shouldn't affect tests
# that aren't specifically looking for these features, or are required
# simply to run the tests at all.
#
# FIXME: Should we have a tool that enforces this?
# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
# 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
# 'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
# 'VC80COMNTOOLS')
possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
'LIBCLANG_RESOURCE_USAGE',
'LIBCLANG_CODE_COMPLETION_LOGGING']
# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
if platform.system() != 'Windows':
possibly_dangerous_env_vars.append('INCLUDE')
self.clear_environment(possibly_dangerous_env_vars)
# Tweak the PATH to include the tools dir and the scripts dir.
# Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
possible_paths = ['clang_tools_dir', 'llvm_tools_dir']
paths = [getattr(self.config, pp) for pp in possible_paths
if getattr(self.config, pp, None)]
self.with_environment('PATH', paths, append_path=True)
paths = [self.config.llvm_shlib_dir, self.config.llvm_libs_dir]
self.with_environment('LD_LIBRARY_PATH', paths, append_path=True)
# Discover the 'clang' and 'clangcc' to use.
self.config.clang = self.use_llvm_tool(
'clang', search_env='CLANG', required=required)
self.config.zapcc= self.use_llvm_tool(
'zapcc', search_env='ZAPCC', required=False)
self.config.zapccs = self.use_llvm_tool(
'zapccs', search_env='ZAPCCS', required=False)
self.config.substitutions.append(
('%llvmshlibdir', self.config.llvm_shlib_dir))
self.config.substitutions.append(
('%pluginext', self.config.llvm_plugin_ext))
builtin_include_dir = self.get_clang_builtin_include_dir(self.config.clang)
tool_substitutions = [
ToolSubst('%clang', command=self.config.clang),
ToolSubst('%clang_analyze_cc1', command='%clang_cc1', extra_args=['-analyze']),
ToolSubst('%clang_cc1', command=self.config.clang, extra_args=['-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']),
ToolSubst('%clang_cpp', command=self.config.clang, extra_args=['--driver-mode=cpp']),
ToolSubst('%clang_cl', command=self.config.clang, extra_args=['--driver-mode=cl']),
ToolSubst('%clangxx', command=self.config.clang, extra_args=['--driver-mode=g++']),
]
self.add_tool_substitutions(tool_substitutions)
self.config.substitutions.append(('%itanium_abi_triple',
self.make_itanium_abi_triple(self.config.target_triple)))
self.config.substitutions.append(('%ms_abi_triple',
self.make_msabi_triple(self.config.target_triple)))
self.config.substitutions.append(
('%resource_dir', builtin_include_dir))
# The host triple might not be set, at least if we're compiling clang from
# an already installed llvm.
if self.config.host_triple and self.config.host_triple != '@LLVM_HOST_TRIPLE@':
self.config.substitutions.append(('%target_itanium_abi_host_triple',
'--target=%s' % self.make_itanium_abi_triple(self.config.host_triple)))
else:
self.config.substitutions.append(
('%target_itanium_abi_host_triple', ''))
self.config.substitutions.append(
('%src_include_dir', self.config.clang_src_dir + '/include'))
# FIXME: Find nicer way to prohibit this.
self.config.substitutions.append(
(' clang ', """*** Do not use 'clang' in tests, use '%clang'. ***"""))
self.config.substitutions.append(
(' clang\+\+ ', """*** Do not use 'clang++' in tests, use '%clangxx'. ***"""))
self.config.substitutions.append(
(' clang-cc ',
"""*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***"""))
self.config.substitutions.append(
(' clang -cc1 -analyze ',
"""*** Do not use 'clang -cc1 -analyze' in tests, use '%clang_analyze_cc1'. ***"""))
self.config.substitutions.append(
(' clang -cc1 ',
"""*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***"""))
self.config.substitutions.append(
(' %clang-cc1 ',
"""*** invalid substitution, use '%clang_cc1'. ***"""))
self.config.substitutions.append(
(' %clang-cpp ',
"""*** invalid substitution, use '%clang_cpp'. ***"""))
self.config.substitutions.append(
(' %clang-cl ',
"""*** invalid substitution, use '%clang_cl'. ***""")) | [
"def",
"use_clang",
"(",
"self",
",",
"required",
"=",
"True",
")",
":",
"# Clear some environment variables that might affect Clang.",
"#",
"# This first set of vars are read by Clang, but shouldn't affect tests",
"# that aren't specifically looking for these features, or are required",
... | https://github.com/yrnkrn/zapcc/blob/c6a8aa30006d997eff0d60fd37b0e62b8aa0ea50/utils/lit/lit/llvm/config.py#L337-L448 | ||
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/windows/Lib/distutils/dist.py | python | Distribution.run_commands | (self) | Run each command that was seen on the setup script command line.
Uses the list of commands found and cache of command objects
created by 'get_command_obj()'. | Run each command that was seen on the setup script command line.
Uses the list of commands found and cache of command objects
created by 'get_command_obj()'. | [
"Run",
"each",
"command",
"that",
"was",
"seen",
"on",
"the",
"setup",
"script",
"command",
"line",
".",
"Uses",
"the",
"list",
"of",
"commands",
"found",
"and",
"cache",
"of",
"command",
"objects",
"created",
"by",
"get_command_obj",
"()",
"."
] | def run_commands(self):
"""Run each command that was seen on the setup script command line.
Uses the list of commands found and cache of command objects
created by 'get_command_obj()'.
"""
for cmd in self.commands:
self.run_command(cmd) | [
"def",
"run_commands",
"(",
"self",
")",
":",
"for",
"cmd",
"in",
"self",
".",
"commands",
":",
"self",
".",
"run_command",
"(",
"cmd",
")"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/windows/Lib/distutils/dist.py#L960-L966 | ||
BlzFans/wke | b0fa21158312e40c5fbd84682d643022b6c34a93 | cygwin/lib/python2.6/Cookie.py | python | BaseCookie.output | (self, attrs=None, header="Set-Cookie:", sep="\015\012") | return sep.join(result) | Return a string suitable for HTTP. | Return a string suitable for HTTP. | [
"Return",
"a",
"string",
"suitable",
"for",
"HTTP",
"."
] | def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):
"""Return a string suitable for HTTP."""
result = []
items = self.items()
items.sort()
for K,V in items:
result.append( V.output(attrs, header) )
return sep.join(result) | [
"def",
"output",
"(",
"self",
",",
"attrs",
"=",
"None",
",",
"header",
"=",
"\"Set-Cookie:\"",
",",
"sep",
"=",
"\"\\015\\012\"",
")",
":",
"result",
"=",
"[",
"]",
"items",
"=",
"self",
".",
"items",
"(",
")",
"items",
".",
"sort",
"(",
")",
"for... | https://github.com/BlzFans/wke/blob/b0fa21158312e40c5fbd84682d643022b6c34a93/cygwin/lib/python2.6/Cookie.py#L588-L595 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/msw/html.py | python | HtmlWindow.GetDefaultHTMLCursor | (*args, **kwargs) | return _html.HtmlWindow_GetDefaultHTMLCursor(*args, **kwargs) | GetDefaultHTMLCursor(int type) -> Cursor | GetDefaultHTMLCursor(int type) -> Cursor | [
"GetDefaultHTMLCursor",
"(",
"int",
"type",
")",
"-",
">",
"Cursor"
] | def GetDefaultHTMLCursor(*args, **kwargs):
"""GetDefaultHTMLCursor(int type) -> Cursor"""
return _html.HtmlWindow_GetDefaultHTMLCursor(*args, **kwargs) | [
"def",
"GetDefaultHTMLCursor",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_html",
".",
"HtmlWindow_GetDefaultHTMLCursor",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/msw/html.py#L1175-L1177 | |
papyrussolution/OpenPapyrus | bbfb5ec2ea2109b8e2f125edd838e12eaf7b8b91 | Src/OSF/protobuf-3.19.1/python/google/protobuf/internal/containers.py | python | RepeatedCompositeFieldContainer.MergeFrom | (self, other) | Appends the contents of another repeated field of the same type to this
one, copying each individual message. | Appends the contents of another repeated field of the same type to this
one, copying each individual message. | [
"Appends",
"the",
"contents",
"of",
"another",
"repeated",
"field",
"of",
"the",
"same",
"type",
"to",
"this",
"one",
"copying",
"each",
"individual",
"message",
"."
] | def MergeFrom(self, other):
"""Appends the contents of another repeated field of the same type to this
one, copying each individual message.
"""
self.extend(other._values) | [
"def",
"MergeFrom",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"extend",
"(",
"other",
".",
"_values",
")"
] | https://github.com/papyrussolution/OpenPapyrus/blob/bbfb5ec2ea2109b8e2f125edd838e12eaf7b8b91/Src/OSF/protobuf-3.19.1/python/google/protobuf/internal/containers.py#L278-L282 | ||
openvinotoolkit/openvino | dedcbeafa8b84cccdc55ca64b8da516682b381c7 | src/bindings/python/src/openvino/runtime/opset3/ops.py | python | extract_image_patches | (
image: NodeInput,
sizes: TensorShape,
strides: List[int],
rates: TensorShape,
auto_pad: str,
name: Optional[str] = None,
) | return _get_node_factory_opset3().create(
"ExtractImagePatches",
[as_node(image)],
{"sizes": sizes, "strides": strides, "rates": rates, "auto_pad": auto_pad},
) | Return a node which produces the ExtractImagePatches operation.
@param image: 4-D Input data to extract image patches.
@param sizes: Patch size in the format of [size_rows, size_cols].
@param strides: Patch movement stride in the format of [stride_rows, stride_cols]
@param rates: Element seleciton rate for creating a patch.
@param auto_pad: Padding type.
@param name: Optional name for output node.
@return ExtractImagePatches node | Return a node which produces the ExtractImagePatches operation. | [
"Return",
"a",
"node",
"which",
"produces",
"the",
"ExtractImagePatches",
"operation",
"."
] | def extract_image_patches(
image: NodeInput,
sizes: TensorShape,
strides: List[int],
rates: TensorShape,
auto_pad: str,
name: Optional[str] = None,
) -> Node:
"""Return a node which produces the ExtractImagePatches operation.
@param image: 4-D Input data to extract image patches.
@param sizes: Patch size in the format of [size_rows, size_cols].
@param strides: Patch movement stride in the format of [stride_rows, stride_cols]
@param rates: Element seleciton rate for creating a patch.
@param auto_pad: Padding type.
@param name: Optional name for output node.
@return ExtractImagePatches node
"""
return _get_node_factory_opset3().create(
"ExtractImagePatches",
[as_node(image)],
{"sizes": sizes, "strides": strides, "rates": rates, "auto_pad": auto_pad},
) | [
"def",
"extract_image_patches",
"(",
"image",
":",
"NodeInput",
",",
"sizes",
":",
"TensorShape",
",",
"strides",
":",
"List",
"[",
"int",
"]",
",",
"rates",
":",
"TensorShape",
",",
"auto_pad",
":",
"str",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
... | https://github.com/openvinotoolkit/openvino/blob/dedcbeafa8b84cccdc55ca64b8da516682b381c7/src/bindings/python/src/openvino/runtime/opset3/ops.py#L222-L244 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/importlib/_bootstrap_external.py | python | _path_isfile | (path) | return _path_is_mode_type(path, 0o100000) | Replacement for os.path.isfile. | Replacement for os.path.isfile. | [
"Replacement",
"for",
"os",
".",
"path",
".",
"isfile",
"."
] | def _path_isfile(path):
"""Replacement for os.path.isfile."""
return _path_is_mode_type(path, 0o100000) | [
"def",
"_path_isfile",
"(",
"path",
")",
":",
"return",
"_path_is_mode_type",
"(",
"path",
",",
"0o100000",
")"
] | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/importlib/_bootstrap_external.py#L93-L95 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | samples/pySketch/pySketch.py | python | LineDrawingObject._privateDraw | (self, dc, position, selected) | Private routine to draw this DrawingObject.
'dc' is the device context to use for drawing, while 'position' is
the position in which to draw the object. If 'selected' is True,
the object is drawn with selection handles. This private drawing
routine assumes that the pen and brush have already been set by the
caller. | Private routine to draw this DrawingObject. | [
"Private",
"routine",
"to",
"draw",
"this",
"DrawingObject",
"."
] | def _privateDraw(self, dc, position, selected):
""" Private routine to draw this DrawingObject.
'dc' is the device context to use for drawing, while 'position' is
the position in which to draw the object. If 'selected' is True,
the object is drawn with selection handles. This private drawing
routine assumes that the pen and brush have already been set by the
caller.
"""
dc.DrawLine(position.x + self.startPt.x,
position.y + self.startPt.y,
position.x + self.endPt.x,
position.y + self.endPt.y) | [
"def",
"_privateDraw",
"(",
"self",
",",
"dc",
",",
"position",
",",
"selected",
")",
":",
"dc",
".",
"DrawLine",
"(",
"position",
".",
"x",
"+",
"self",
".",
"startPt",
".",
"x",
",",
"position",
".",
"y",
"+",
"self",
".",
"startPt",
".",
"y",
... | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/samples/pySketch/pySketch.py#L2656-L2668 | ||
Tencent/Pebble | 68315f176d9e328a233ace29b7579a829f89879f | tools/blade/src/blade/proto_library_target.py | python | ProtoLibrary.__init__ | (self,
name,
srcs,
deps,
optimize,
deprecated,
blade,
kwargs) | Init method.
Init the proto target. | Init method. | [
"Init",
"method",
"."
] | def __init__(self,
name,
srcs,
deps,
optimize,
deprecated,
blade,
kwargs):
"""Init method.
Init the proto target.
"""
srcs_list = var_to_list(srcs)
self._check_proto_srcs_name(srcs_list)
CcTarget.__init__(self,
name,
'proto_library',
srcs,
deps,
'',
[], [], [], optimize, [], [],
blade,
kwargs)
proto_config = configparse.blade_config.get_config('proto_library_config')
protobuf_lib = var_to_list(proto_config['protobuf_libs'])
# Hardcode deps rule to thirdparty protobuf lib.
self._add_hardcode_library(protobuf_lib)
# Link all the symbols by default
self.data['link_all_symbols'] = True
self.data['deprecated'] = deprecated
self.data['java_sources_explict_dependency'] = []
self.data['python_vars'] = []
self.data['python_sources'] = [] | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"srcs",
",",
"deps",
",",
"optimize",
",",
"deprecated",
",",
"blade",
",",
"kwargs",
")",
":",
"srcs_list",
"=",
"var_to_list",
"(",
"srcs",
")",
"self",
".",
"_check_proto_srcs_name",
"(",
"srcs_list",
... | https://github.com/Tencent/Pebble/blob/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/blade/proto_library_target.py#L21-L57 | ||
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/gtk/_controls.py | python | TreeEvent.SetLabel | (*args, **kwargs) | return _controls_.TreeEvent_SetLabel(*args, **kwargs) | SetLabel(self, String label) | SetLabel(self, String label) | [
"SetLabel",
"(",
"self",
"String",
"label",
")"
] | def SetLabel(*args, **kwargs):
"""SetLabel(self, String label)"""
return _controls_.TreeEvent_SetLabel(*args, **kwargs) | [
"def",
"SetLabel",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_controls_",
".",
"TreeEvent_SetLabel",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/gtk/_controls.py#L5148-L5150 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/msw/_gdi.py | python | RendererNative.DrawSplitterBorder | (*args, **kwargs) | return _gdi_.RendererNative_DrawSplitterBorder(*args, **kwargs) | DrawSplitterBorder(self, Window win, DC dc, Rect rect, int flags=0)
Draw the border for a sash window: this border must be such that the
sash drawn by `DrawSplitterSash` blends into it well. | DrawSplitterBorder(self, Window win, DC dc, Rect rect, int flags=0) | [
"DrawSplitterBorder",
"(",
"self",
"Window",
"win",
"DC",
"dc",
"Rect",
"rect",
"int",
"flags",
"=",
"0",
")"
] | def DrawSplitterBorder(*args, **kwargs):
"""
DrawSplitterBorder(self, Window win, DC dc, Rect rect, int flags=0)
Draw the border for a sash window: this border must be such that the
sash drawn by `DrawSplitterSash` blends into it well.
"""
return _gdi_.RendererNative_DrawSplitterBorder(*args, **kwargs) | [
"def",
"DrawSplitterBorder",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_gdi_",
".",
"RendererNative_DrawSplitterBorder",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/msw/_gdi.py#L7473-L7480 | |
catboost/catboost | 167f64f237114a4d10b2b4ee42adb4569137debe | contrib/python/pandas/py2/pandas/io/stata.py | python | StataValueLabel.generate_value_label | (self, byteorder, encoding) | return bio.read() | Parameters
----------
byteorder : str
Byte order of the output
encoding : str
File encoding
Returns
-------
value_label : bytes
Bytes containing the formatted value label | Parameters
----------
byteorder : str
Byte order of the output
encoding : str
File encoding | [
"Parameters",
"----------",
"byteorder",
":",
"str",
"Byte",
"order",
"of",
"the",
"output",
"encoding",
":",
"str",
"File",
"encoding"
] | def generate_value_label(self, byteorder, encoding):
"""
Parameters
----------
byteorder : str
Byte order of the output
encoding : str
File encoding
Returns
-------
value_label : bytes
Bytes containing the formatted value label
"""
self._encoding = encoding
bio = BytesIO()
null_string = '\x00'
null_byte = b'\x00'
# len
bio.write(struct.pack(byteorder + 'i', self.len))
# labname
labname = self._encode(_pad_bytes(self.labname[:32], 33))
bio.write(labname)
# padding - 3 bytes
for i in range(3):
bio.write(struct.pack('c', null_byte))
# value_label_table
# n - int32
bio.write(struct.pack(byteorder + 'i', self.n))
# textlen - int32
bio.write(struct.pack(byteorder + 'i', self.text_len))
# off - int32 array (n elements)
for offset in self.off:
bio.write(struct.pack(byteorder + 'i', offset))
# val - int32 array (n elements)
for value in self.val:
bio.write(struct.pack(byteorder + 'i', value))
# txt - Text labels, null terminated
for text in self.txt:
bio.write(self._encode(text + null_string))
bio.seek(0)
return bio.read() | [
"def",
"generate_value_label",
"(",
"self",
",",
"byteorder",
",",
"encoding",
")",
":",
"self",
".",
"_encoding",
"=",
"encoding",
"bio",
"=",
"BytesIO",
"(",
")",
"null_string",
"=",
"'\\x00'",
"null_byte",
"=",
"b'\\x00'",
"# len",
"bio",
".",
"write",
... | https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/python/pandas/py2/pandas/io/stata.py#L666-L717 | |
MVIG-SJTU/RMPE | 5188c230ec800c12be7369c3619615bc9b020aa4 | tools/extra/extract_seconds.py | python | get_log_created_year | (input_file) | return log_created_year | Get year from log file system timestamp | Get year from log file system timestamp | [
"Get",
"year",
"from",
"log",
"file",
"system",
"timestamp"
] | def get_log_created_year(input_file):
"""Get year from log file system timestamp
"""
log_created_time = os.path.getctime(input_file)
log_created_year = datetime.datetime.fromtimestamp(log_created_time).year
return log_created_year | [
"def",
"get_log_created_year",
"(",
"input_file",
")",
":",
"log_created_time",
"=",
"os",
".",
"path",
".",
"getctime",
"(",
"input_file",
")",
"log_created_year",
"=",
"datetime",
".",
"datetime",
".",
"fromtimestamp",
"(",
"log_created_time",
")",
".",
"year"... | https://github.com/MVIG-SJTU/RMPE/blob/5188c230ec800c12be7369c3619615bc9b020aa4/tools/extra/extract_seconds.py#L22-L28 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | wx/tools/Editra/src/ed_print.py | python | EdPrinter.Print | (self) | Prints the document
@postcondition: the current document is printed | Prints the document
@postcondition: the current document is printed | [
"Prints",
"the",
"document",
"@postcondition",
":",
"the",
"current",
"document",
"is",
"printed"
] | def Print(self):
"""Prints the document
@postcondition: the current document is printed
"""
pdd = wx.PrintDialogData(self.print_data)
printer = wx.Printer(pdd)
printout = self.CreatePrintout()
result = printer.Print(self.parent, printout)
if result:
dlg_data = printer.GetPrintDialogData()
self.print_data = wx.PrintData(dlg_data.GetPrintData())
elif printer.GetLastError() == wx.PRINTER_ERROR:
wx.MessageBox(_("There was an error when printing.\n"
"Check that your printer is properly connected."),
_("Printer Error"),
style=wx.ICON_ERROR|wx.OK)
printout.Destroy() | [
"def",
"Print",
"(",
"self",
")",
":",
"pdd",
"=",
"wx",
".",
"PrintDialogData",
"(",
"self",
".",
"print_data",
")",
"printer",
"=",
"wx",
".",
"Printer",
"(",
"pdd",
")",
"printout",
"=",
"self",
".",
"CreatePrintout",
"(",
")",
"result",
"=",
"pri... | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/wx/tools/Editra/src/ed_print.py#L124-L141 | ||
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/osx_cocoa/stc.py | python | StyledTextCtrl.AutoCompSelect | (*args, **kwargs) | return _stc.StyledTextCtrl_AutoCompSelect(*args, **kwargs) | AutoCompSelect(self, String text)
Select the item in the auto-completion list that starts with a string. | AutoCompSelect(self, String text) | [
"AutoCompSelect",
"(",
"self",
"String",
"text",
")"
] | def AutoCompSelect(*args, **kwargs):
"""
AutoCompSelect(self, String text)
Select the item in the auto-completion list that starts with a string.
"""
return _stc.StyledTextCtrl_AutoCompSelect(*args, **kwargs) | [
"def",
"AutoCompSelect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_stc",
".",
"StyledTextCtrl_AutoCompSelect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/stc.py#L3095-L3101 | |
wlanjie/AndroidFFmpeg | 7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf | tools/fdk-aac-build/armeabi-v7a/toolchain/lib/python2.7/optparse.py | python | OptionParser.error | (self, msg) | error(msg : string)
Print a usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception. | error(msg : string) | [
"error",
"(",
"msg",
":",
"string",
")"
] | def error(self, msg):
"""error(msg : string)
Print a usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
self.print_usage(sys.stderr)
self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg)) | [
"def",
"error",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"print_usage",
"(",
"sys",
".",
"stderr",
")",
"self",
".",
"exit",
"(",
"2",
",",
"\"%s: error: %s\\n\"",
"%",
"(",
"self",
".",
"get_prog_name",
"(",
")",
",",
"msg",
")",
")"
] | https://github.com/wlanjie/AndroidFFmpeg/blob/7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf/tools/fdk-aac-build/armeabi-v7a/toolchain/lib/python2.7/optparse.py#L1575-L1583 | ||
hanpfei/chromium-net | 392cc1fa3a8f92f42e4071ab6e674d8e0482f83f | third_party/catapult/experimental/buildbot/buildbot.py | python | _ParseTraceFromLog | (log) | return tuple(stack_trace), exception | Search the log for a stack trace and return a structured representation.
This function supports both default Python-style stacks and Telemetry-style
stacks. It returns the first stack trace found in the log - sometimes a bug
leads to a cascade of failures, so the first one is usually the root cause. | Search the log for a stack trace and return a structured representation. | [
"Search",
"the",
"log",
"for",
"a",
"stack",
"trace",
"and",
"return",
"a",
"structured",
"representation",
"."
] | def _ParseTraceFromLog(log):
"""Search the log for a stack trace and return a structured representation.
This function supports both default Python-style stacks and Telemetry-style
stacks. It returns the first stack trace found in the log - sometimes a bug
leads to a cascade of failures, so the first one is usually the root cause.
"""
log_iterator = iter(log.splitlines())
for line in log_iterator:
if line == 'Traceback (most recent call last):':
break
else:
return (None, None)
stack_trace = []
while True:
line = log_iterator.next()
match1 = re.match(r'\s*File "(?P<file>.+)", line (?P<line>[0-9]+), '
'in (?P<function>.+)', line)
match2 = re.match(r'\s*(?P<function>.+) at '
'(?P<file>.+):(?P<line>[0-9]+)', line)
match = match1 or match2
if not match:
exception = line
break
trace_line = match.groupdict()
# Use the base name, because the path will be different
# across platforms and configurations.
file_base_name = trace_line['file'].split('/')[-1].split('\\')[-1]
source = log_iterator.next().strip()
stack_trace.append(StackTraceLine(
file_base_name, trace_line['function'], trace_line['line'], source))
return tuple(stack_trace), exception | [
"def",
"_ParseTraceFromLog",
"(",
"log",
")",
":",
"log_iterator",
"=",
"iter",
"(",
"log",
".",
"splitlines",
"(",
")",
")",
"for",
"line",
"in",
"log_iterator",
":",
"if",
"line",
"==",
"'Traceback (most recent call last):'",
":",
"break",
"else",
":",
"re... | https://github.com/hanpfei/chromium-net/blob/392cc1fa3a8f92f42e4071ab6e674d8e0482f83f/third_party/catapult/experimental/buildbot/buildbot.py#L256-L289 | |
kismetwireless/kismet | a7c0dc270c960fb1f58bd9cec4601c201885fd4e | capture_proxy_adsb/KismetCaptureProxyAdsb/__init__.py | python | KismetProxyAdsb.adsb_msg_fix_double_bit | (self, data, bits) | return None | Try to fix double bit errors using the checksum, like fix_single_bit.
This is very slow and should only be tried against DF17 messages.
If successful returns the modified bytearray.
data - bytearray of message input
bits - length in bits | Try to fix double bit errors using the checksum, like fix_single_bit.
This is very slow and should only be tried against DF17 messages.
If successful returns the modified bytearray.
data - bytearray of message input
bits - length in bits | [
"Try",
"to",
"fix",
"double",
"bit",
"errors",
"using",
"the",
"checksum",
"like",
"fix_single_bit",
".",
"This",
"is",
"very",
"slow",
"and",
"should",
"only",
"be",
"tried",
"against",
"DF17",
"messages",
".",
"If",
"successful",
"returns",
"the",
"modifie... | def adsb_msg_fix_double_bit(self, data, bits):
"""
Try to fix double bit errors using the checksum, like fix_single_bit.
This is very slow and should only be tried against DF17 messages.
If successful returns the modified bytearray.
data - bytearray of message input
bits - length in bits
"""
for j in range(0, bits):
byte1 = int(j / 8)
bitmask1 = 1 << (7 - (j % 8))
# Don't check the same pairs multiple times, so i starts from j+1
for i in range(j + 1, bits):
byte2 = int(i / 8)
bitmask2 = 1 << (7 - (i % 8))
aux = data[:]
# Flip the jth bit
aux[byte1] ^= bitmask1
# Flip the ith bit
aux[byte2] ^= bitmask2
crc1 = (aux[int(bits / 8) - 3] << 16)
crc1 |= (aux[int(bits / 8) - 2] << 8)
crc1 |= (aux[int(bits / 8) - 1])
crc2 = self.adsb_crc(aux, bits)
if crc1 == crc2:
# The error is fixed; return the new buffer
return aux
return None | [
"def",
"adsb_msg_fix_double_bit",
"(",
"self",
",",
"data",
",",
"bits",
")",
":",
"for",
"j",
"in",
"range",
"(",
"0",
",",
"bits",
")",
":",
"byte1",
"=",
"int",
"(",
"j",
"/",
"8",
")",
"bitmask1",
"=",
"1",
"<<",
"(",
"7",
"-",
"(",
"j",
... | https://github.com/kismetwireless/kismet/blob/a7c0dc270c960fb1f58bd9cec4601c201885fd4e/capture_proxy_adsb/KismetCaptureProxyAdsb/__init__.py#L476-L513 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/site-packages/setuptools/package_index.py | python | HashChecker.from_url | (cls, url) | return cls(**match.groupdict()) | Construct a (possibly null) ContentChecker from a URL | Construct a (possibly null) ContentChecker from a URL | [
"Construct",
"a",
"(",
"possibly",
"null",
")",
"ContentChecker",
"from",
"a",
"URL"
] | def from_url(cls, url):
"Construct a (possibly null) ContentChecker from a URL"
fragment = urllib.parse.urlparse(url)[-1]
if not fragment:
return ContentChecker()
match = cls.pattern.search(fragment)
if not match:
return ContentChecker()
return cls(**match.groupdict()) | [
"def",
"from_url",
"(",
"cls",
",",
"url",
")",
":",
"fragment",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
")",
"[",
"-",
"1",
"]",
"if",
"not",
"fragment",
":",
"return",
"ContentChecker",
"(",
")",
"match",
"=",
"cls",
".",
"patte... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/site-packages/setuptools/package_index.py#L278-L286 | |
google/filament | d21f092645b8e1e312307cbf89f1484891347c63 | third_party/spirv-tools/utils/generate_grammar_tables.py | python | generate_enum_operand_kind_entry | (entry, extension_map) | return str(EnumerantInitializer(
enumerant, value, caps, exts, params, version, max_version)) | Returns the C initializer for the given operand enum entry.
Arguments:
- entry: a dict containing information about an enum entry
- extension_map: a dict mapping enum value to list of extensions
Returns:
a string containing the C initializer for spv_operand_desc_t | Returns the C initializer for the given operand enum entry. | [
"Returns",
"the",
"C",
"initializer",
"for",
"the",
"given",
"operand",
"enum",
"entry",
"."
] | def generate_enum_operand_kind_entry(entry, extension_map):
"""Returns the C initializer for the given operand enum entry.
Arguments:
- entry: a dict containing information about an enum entry
- extension_map: a dict mapping enum value to list of extensions
Returns:
a string containing the C initializer for spv_operand_desc_t
"""
enumerant = entry.get('enumerant')
value = entry.get('value')
caps = entry.get('capabilities', [])
if value in extension_map:
exts = extension_map[value]
else:
exts = []
params = entry.get('parameters', [])
params = [p.get('kind') for p in params]
params = zip(params, [''] * len(params))
version = entry.get('version', None)
max_version = entry.get('lastVersion', None)
assert enumerant is not None
assert value is not None
return str(EnumerantInitializer(
enumerant, value, caps, exts, params, version, max_version)) | [
"def",
"generate_enum_operand_kind_entry",
"(",
"entry",
",",
"extension_map",
")",
":",
"enumerant",
"=",
"entry",
".",
"get",
"(",
"'enumerant'",
")",
"value",
"=",
"entry",
".",
"get",
"(",
"'value'",
")",
"caps",
"=",
"entry",
".",
"get",
"(",
"'capabi... | https://github.com/google/filament/blob/d21f092645b8e1e312307cbf89f1484891347c63/third_party/spirv-tools/utils/generate_grammar_tables.py#L431-L458 | |
krishauser/Klampt | 972cc83ea5befac3f653c1ba20f80155768ad519 | Python/klampt/robotsim.py | python | SimRobotSensor.setLink | (self, *args) | return _robotsim.SimRobotSensor_setLink(self, *args) | r"""
Sets the link on which the sensor is mounted (helper for setSetting)
setLink (link)
Args:
link (:class:`~klampt.RobotModelLink` or int): | r"""
Sets the link on which the sensor is mounted (helper for setSetting) | [
"r",
"Sets",
"the",
"link",
"on",
"which",
"the",
"sensor",
"is",
"mounted",
"(",
"helper",
"for",
"setSetting",
")"
] | def setLink(self, *args) ->None:
r"""
Sets the link on which the sensor is mounted (helper for setSetting)
setLink (link)
Args:
link (:class:`~klampt.RobotModelLink` or int):
"""
return _robotsim.SimRobotSensor_setLink(self, *args) | [
"def",
"setLink",
"(",
"self",
",",
"*",
"args",
")",
"->",
"None",
":",
"return",
"_robotsim",
".",
"SimRobotSensor_setLink",
"(",
"self",
",",
"*",
"args",
")"
] | https://github.com/krishauser/Klampt/blob/972cc83ea5befac3f653c1ba20f80155768ad519/Python/klampt/robotsim.py#L6884-L6894 | |
xieyufei1993/FOTS | 9881966697fd5e2936d2cca8aa04309e4b64f77c | config.py | python | parse | (self,kwargs) | update the config params
:param self:
:param kwargs:
:return: | update the config params
:param self:
:param kwargs:
:return: | [
"update",
"the",
"config",
"params",
":",
"param",
"self",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | def parse(self,kwargs):
'''
update the config params
:param self:
:param kwargs:
:return:
'''
for k,v in kwargs.items():
if not hasattr(self,k):
warnings.warn("Warning:opt has not attribute ^s" %k)
setattr(self,k,v)
print('use config:')
for k,v in self.__class__.__dict__.items():
if not k.startswith('__'):
print(k,getattr(self,k))
print("end the parse!!!") | [
"def",
"parse",
"(",
"self",
",",
"kwargs",
")",
":",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"k",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Warning:opt has not attribute ^s\"",
"%... | https://github.com/xieyufei1993/FOTS/blob/9881966697fd5e2936d2cca8aa04309e4b64f77c/config.py#L39-L56 | ||
LiquidPlayer/LiquidCore | 9405979363f2353ac9a71ad8ab59685dd7f919c9 | deps/node-10.15.3/deps/v8/third_party/jinja2/filters.py | python | do_center | (value, width=80) | return text_type(value).center(width) | Centers the value in a field of a given width. | Centers the value in a field of a given width. | [
"Centers",
"the",
"value",
"in",
"a",
"field",
"of",
"a",
"given",
"width",
"."
] | def do_center(value, width=80):
"""Centers the value in a field of a given width."""
return text_type(value).center(width) | [
"def",
"do_center",
"(",
"value",
",",
"width",
"=",
"80",
")",
":",
"return",
"text_type",
"(",
"value",
")",
".",
"center",
"(",
"width",
")"
] | https://github.com/LiquidPlayer/LiquidCore/blob/9405979363f2353ac9a71ad8ab59685dd7f919c9/deps/node-10.15.3/deps/v8/third_party/jinja2/filters.py#L427-L429 | |
weolar/miniblink49 | 1c4678db0594a4abde23d3ebbcc7cd13c3170777 | third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py | python | InterfaceInfoCollector.get_info_as_dict | (self) | return {
'interfaces_info': self.interfaces_info,
# Can't pickle defaultdict, convert to dict
# FIXME: this should be included in get_component_info.
'partial_interface_files': dict(self.partial_interface_files),
} | Returns info packaged as a dict. | Returns info packaged as a dict. | [
"Returns",
"info",
"packaged",
"as",
"a",
"dict",
"."
] | def get_info_as_dict(self):
"""Returns info packaged as a dict."""
return {
'interfaces_info': self.interfaces_info,
# Can't pickle defaultdict, convert to dict
# FIXME: this should be included in get_component_info.
'partial_interface_files': dict(self.partial_interface_files),
} | [
"def",
"get_info_as_dict",
"(",
"self",
")",
":",
"return",
"{",
"'interfaces_info'",
":",
"self",
".",
"interfaces_info",
",",
"# Can't pickle defaultdict, convert to dict",
"# FIXME: this should be included in get_component_info.",
"'partial_interface_files'",
":",
"dict",
"(... | https://github.com/weolar/miniblink49/blob/1c4678db0594a4abde23d3ebbcc7cd13c3170777/third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py#L251-L258 | |
krishauser/Klampt | 972cc83ea5befac3f653c1ba20f80155768ad519 | Python/python2_version/klampt/io/ros.py | python | to_Point | (klampt_pt) | return Point(klampt_pt[0],klampt_pt[1],klampt_pt[2]) | From Klamp't point to ROS Point | From Klamp't point to ROS Point | [
"From",
"Klamp",
"t",
"point",
"to",
"ROS",
"Point"
] | def to_Point(klampt_pt):
"""From Klamp't point to ROS Point"""
return Point(klampt_pt[0],klampt_pt[1],klampt_pt[2]) | [
"def",
"to_Point",
"(",
"klampt_pt",
")",
":",
"return",
"Point",
"(",
"klampt_pt",
"[",
"0",
"]",
",",
"klampt_pt",
"[",
"1",
"]",
",",
"klampt_pt",
"[",
"2",
"]",
")"
] | https://github.com/krishauser/Klampt/blob/972cc83ea5befac3f653c1ba20f80155768ad519/Python/python2_version/klampt/io/ros.py#L45-L47 | |
llvm-mirror/lldb | d01083a850f577b85501a0902b52fd0930de72c7 | third_party/Python/module/pexpect-4.6/pexpect/utils.py | python | select_ignore_interrupts | (iwtd, owtd, ewtd, timeout=None) | This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). | This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). | [
"This",
"is",
"a",
"wrapper",
"around",
"select",
".",
"select",
"()",
"that",
"ignores",
"signals",
".",
"If",
"select",
".",
"select",
"raises",
"a",
"select",
".",
"error",
"exception",
"and",
"errno",
"is",
"an",
"EINTR",
"error",
"then",
"it",
"is",... | def select_ignore_interrupts(iwtd, owtd, ewtd, timeout=None):
'''This is a wrapper around select.select() that ignores signals. If
select.select raises a select.error exception and errno is an EINTR
error then it is ignored. Mainly this is used to ignore sigwinch
(terminal resize). '''
# if select() is interrupted by a signal (errno==EINTR) then
# we loop back and enter the select() again.
if timeout is not None:
end_time = time.time() + timeout
while True:
try:
return select.select(iwtd, owtd, ewtd, timeout)
except InterruptedError:
err = sys.exc_info()[1]
if err.args[0] == errno.EINTR:
# if we loop back we have to subtract the
# amount of time we already waited.
if timeout is not None:
timeout = end_time - time.time()
if timeout < 0:
return([], [], [])
else:
# something else caused the select.error, so
# this actually is an exception.
raise | [
"def",
"select_ignore_interrupts",
"(",
"iwtd",
",",
"owtd",
",",
"ewtd",
",",
"timeout",
"=",
"None",
")",
":",
"# if select() is interrupted by a signal (errno==EINTR) then",
"# we loop back and enter the select() again.",
"if",
"timeout",
"is",
"not",
"None",
":",
"end... | https://github.com/llvm-mirror/lldb/blob/d01083a850f577b85501a0902b52fd0930de72c7/third_party/Python/module/pexpect-4.6/pexpect/utils.py#L130-L156 | ||
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/urllib3/util/selectors.py | python | _can_allocate | (struct) | Checks that select structs can be allocated by the underlying
operating system, not just advertised by the select module. We don't
check select() because we'll be hopeful that most platforms that
don't have it available will not advertise it. (ie: GAE) | Checks that select structs can be allocated by the underlying
operating system, not just advertised by the select module. We don't
check select() because we'll be hopeful that most platforms that
don't have it available will not advertise it. (ie: GAE) | [
"Checks",
"that",
"select",
"structs",
"can",
"be",
"allocated",
"by",
"the",
"underlying",
"operating",
"system",
"not",
"just",
"advertised",
"by",
"the",
"select",
"module",
".",
"We",
"don",
"t",
"check",
"select",
"()",
"because",
"we",
"ll",
"be",
"h... | def _can_allocate(struct):
""" Checks that select structs can be allocated by the underlying
operating system, not just advertised by the select module. We don't
check select() because we'll be hopeful that most platforms that
don't have it available will not advertise it. (ie: GAE) """
try:
# select.poll() objects won't fail until used.
if struct == 'poll':
p = select.poll()
p.poll(0)
# All others will fail on allocation.
else:
getattr(select, struct)().close()
return True
except (OSError, AttributeError) as e:
return False | [
"def",
"_can_allocate",
"(",
"struct",
")",
":",
"try",
":",
"# select.poll() objects won't fail until used.",
"if",
"struct",
"==",
"'poll'",
":",
"p",
"=",
"select",
".",
"poll",
"(",
")",
"p",
".",
"poll",
"(",
"0",
")",
"# All others will fail on allocation.... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/urllib3/util/selectors.py#L543-L559 | ||
mhammond/pywin32 | 44afd86ba8485194df93234639243252deeb40d5 | Pythonwin/pywin/framework/editor/template.py | python | EditorTemplateBase.GetPythonPropertyPages | (self) | return [configui.EditorPropertyPage(), configui.EditorWhitespacePropertyPage()] | Returns a list of property pages | Returns a list of property pages | [
"Returns",
"a",
"list",
"of",
"property",
"pages"
] | def GetPythonPropertyPages(self):
"""Returns a list of property pages"""
from . import configui
return [configui.EditorPropertyPage(), configui.EditorWhitespacePropertyPage()] | [
"def",
"GetPythonPropertyPages",
"(",
"self",
")",
":",
"from",
".",
"import",
"configui",
"return",
"[",
"configui",
".",
"EditorPropertyPage",
"(",
")",
",",
"configui",
".",
"EditorWhitespacePropertyPage",
"(",
")",
"]"
] | https://github.com/mhammond/pywin32/blob/44afd86ba8485194df93234639243252deeb40d5/Pythonwin/pywin/framework/editor/template.py#L42-L46 | |
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | wx/lib/agw/aui/framemanager.py | python | AuiManager.UpdateButtonOnScreen | (self, button_ui_part, event) | Updates/redraws the UI part containing a pane button.
:param AuiDockUIPart `button_ui_part`: the UI part the button belongs to;
:param `event`: a :class:`MouseEvent` to be processed. | Updates/redraws the UI part containing a pane button. | [
"Updates",
"/",
"redraws",
"the",
"UI",
"part",
"containing",
"a",
"pane",
"button",
"."
] | def UpdateButtonOnScreen(self, button_ui_part, event):
"""
Updates/redraws the UI part containing a pane button.
:param AuiDockUIPart `button_ui_part`: the UI part the button belongs to;
:param `event`: a :class:`MouseEvent` to be processed.
"""
hit_test = self.HitTest(*event.GetPosition())
if not hit_test or not button_ui_part:
return
state = AUI_BUTTON_STATE_NORMAL
if hit_test == button_ui_part:
if event.LeftDown():
state = AUI_BUTTON_STATE_PRESSED
else:
state = AUI_BUTTON_STATE_HOVER
else:
if event.LeftDown():
state = AUI_BUTTON_STATE_HOVER
# now repaint the button with hover state
cdc = wx.ClientDC(self._frame)
# if the frame has a toolbar, the client area
# origin will not be (0,0).
pt = self._frame.GetClientAreaOrigin()
if pt.x != 0 or pt.y != 0:
cdc.SetDeviceOrigin(pt.x, pt.y)
if hit_test.pane:
self._art.DrawPaneButton(cdc, self._frame,
button_ui_part.button.button_id,
state,
button_ui_part.rect, hit_test.pane) | [
"def",
"UpdateButtonOnScreen",
"(",
"self",
",",
"button_ui_part",
",",
"event",
")",
":",
"hit_test",
"=",
"self",
".",
"HitTest",
"(",
"*",
"event",
".",
"GetPosition",
"(",
")",
")",
"if",
"not",
"hit_test",
"or",
"not",
"button_ui_part",
":",
"return",... | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/wx/lib/agw/aui/framemanager.py#L8910-L8947 | ||
snap-stanford/snap-python | d53c51b0a26aa7e3e7400b014cdf728948fde80a | setup/snap.py | python | TStr.Clr | (self) | return _snap.TStr_Clr(self) | Clr(TStr self)
Parameters:
self: TStr * | Clr(TStr self) | [
"Clr",
"(",
"TStr",
"self",
")"
] | def Clr(self):
"""
Clr(TStr self)
Parameters:
self: TStr *
"""
return _snap.TStr_Clr(self) | [
"def",
"Clr",
"(",
"self",
")",
":",
"return",
"_snap",
".",
"TStr_Clr",
"(",
"self",
")"
] | https://github.com/snap-stanford/snap-python/blob/d53c51b0a26aa7e3e7400b014cdf728948fde80a/setup/snap.py#L9673-L9681 | |
catboost/catboost | 167f64f237114a4d10b2b4ee42adb4569137debe | contrib/python/ipython/py3/IPython/core/page.py | python | display_page | (strng, start=0, screen_lines=25) | Just display, no paging. screen_lines is ignored. | Just display, no paging. screen_lines is ignored. | [
"Just",
"display",
"no",
"paging",
".",
"screen_lines",
"is",
"ignored",
"."
] | def display_page(strng, start=0, screen_lines=25):
"""Just display, no paging. screen_lines is ignored."""
if isinstance(strng, dict):
data = strng
else:
if start:
strng = u'\n'.join(strng.splitlines()[start:])
data = { 'text/plain': strng }
display(data, raw=True) | [
"def",
"display_page",
"(",
"strng",
",",
"start",
"=",
"0",
",",
"screen_lines",
"=",
"25",
")",
":",
"if",
"isinstance",
"(",
"strng",
",",
"dict",
")",
":",
"data",
"=",
"strng",
"else",
":",
"if",
"start",
":",
"strng",
"=",
"u'\\n'",
".",
"joi... | https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/python/ipython/py3/IPython/core/page.py#L35-L43 | ||
thalium/icebox | 99d147d5b9269222225443ce171b4fd46d8985d4 | third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2class.py | python | xmlDoc.validateRoot | (self, ctxt) | return ret | Try to validate a the root element basically it does the
following check as described by the XML-1.0 recommendation:
- [ VC: Root Element Type ] it doesn't try to recurse or
apply other check to the element | Try to validate a the root element basically it does the
following check as described by the XML-1.0 recommendation:
- [ VC: Root Element Type ] it doesn't try to recurse or
apply other check to the element | [
"Try",
"to",
"validate",
"a",
"the",
"root",
"element",
"basically",
"it",
"does",
"the",
"following",
"check",
"as",
"described",
"by",
"the",
"XML",
"-",
"1",
".",
"0",
"recommendation",
":",
"-",
"[",
"VC",
":",
"Root",
"Element",
"Type",
"]",
"it",... | def validateRoot(self, ctxt):
"""Try to validate a the root element basically it does the
following check as described by the XML-1.0 recommendation:
- [ VC: Root Element Type ] it doesn't try to recurse or
apply other check to the element """
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
ret = libxml2mod.xmlValidateRoot(ctxt__o, self._o)
return ret | [
"def",
"validateRoot",
"(",
"self",
",",
"ctxt",
")",
":",
"if",
"ctxt",
"is",
"None",
":",
"ctxt__o",
"=",
"None",
"else",
":",
"ctxt__o",
"=",
"ctxt",
".",
"_o",
"ret",
"=",
"libxml2mod",
".",
"xmlValidateRoot",
"(",
"ctxt__o",
",",
"self",
".",
"_... | https://github.com/thalium/icebox/blob/99d147d5b9269222225443ce171b4fd46d8985d4/third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2class.py#L4019-L4027 | |
hanpfei/chromium-net | 392cc1fa3a8f92f42e4071ab6e674d8e0482f83f | third_party/catapult/third_party/gsutil/third_party/boto/boto/dynamodb/item.py | python | Item.add_attribute | (self, attr_name, attr_value) | Queue the addition of an attribute to an item in DynamoDB.
This will eventually result in an UpdateItem request being issued
with an update action of ADD when the save method is called.
:type attr_name: str
:param attr_name: Name of the attribute you want to alter.
:type attr_value: int|long|float|set
:param attr_value: Value which is to be added to the attribute. | Queue the addition of an attribute to an item in DynamoDB.
This will eventually result in an UpdateItem request being issued
with an update action of ADD when the save method is called. | [
"Queue",
"the",
"addition",
"of",
"an",
"attribute",
"to",
"an",
"item",
"in",
"DynamoDB",
".",
"This",
"will",
"eventually",
"result",
"in",
"an",
"UpdateItem",
"request",
"being",
"issued",
"with",
"an",
"update",
"action",
"of",
"ADD",
"when",
"the",
"s... | def add_attribute(self, attr_name, attr_value):
"""
Queue the addition of an attribute to an item in DynamoDB.
This will eventually result in an UpdateItem request being issued
with an update action of ADD when the save method is called.
:type attr_name: str
:param attr_name: Name of the attribute you want to alter.
:type attr_value: int|long|float|set
:param attr_value: Value which is to be added to the attribute.
"""
self._updates[attr_name] = ("ADD", attr_value) | [
"def",
"add_attribute",
"(",
"self",
",",
"attr_name",
",",
"attr_value",
")",
":",
"self",
".",
"_updates",
"[",
"attr_name",
"]",
"=",
"(",
"\"ADD\"",
",",
"attr_value",
")"
] | https://github.com/hanpfei/chromium-net/blob/392cc1fa3a8f92f42e4071ab6e674d8e0482f83f/third_party/catapult/third_party/gsutil/third_party/boto/boto/dynamodb/item.py#L75-L87 | ||
mongodb/mongo | d8ff665343ad29cf286ee2cf4a1960d29371937b | buildscripts/ciconfig/evergreen.py | python | Variant.__init__ | (self, conf_dict, task_map, task_group_map) | Initialize Variant. | Initialize Variant. | [
"Initialize",
"Variant",
"."
] | def __init__(self, conf_dict, task_map, task_group_map):
"""Initialize Variant."""
self.raw = conf_dict
run_on = self.run_on
self.tasks = []
for task in conf_dict["tasks"]:
task_name = task.get("name")
if task_name in task_group_map:
# A task in conf_dict may be a task_group, containing a list of tasks.
for task_in_group in task_group_map.get(task_name).tasks:
self.tasks.append(
VariantTask(task_map.get(task_in_group), task.get("distros", run_on), self))
else:
self.tasks.append(
VariantTask(task_map.get(task["name"]), task.get("distros", run_on), self))
self.distro_names = set(run_on)
for task in self.tasks:
self.distro_names.update(task.run_on) | [
"def",
"__init__",
"(",
"self",
",",
"conf_dict",
",",
"task_map",
",",
"task_group_map",
")",
":",
"self",
".",
"raw",
"=",
"conf_dict",
"run_on",
"=",
"self",
".",
"run_on",
"self",
".",
"tasks",
"=",
"[",
"]",
"for",
"task",
"in",
"conf_dict",
"[",
... | https://github.com/mongodb/mongo/blob/d8ff665343ad29cf286ee2cf4a1960d29371937b/buildscripts/ciconfig/evergreen.py#L259-L276 | ||
larroy/clearskies_core | 3574ddf0edc8555454c7044126e786a6c29444dc | tools/gyp/pylib/gyp/generator/android.py | python | AndroidMkWriter.ComputeOutput | (self, spec) | return os.path.join(path, self.ComputeOutputBasename(spec)) | Return the 'output' (full output path) of a gyp spec.
E.g., the loadable module 'foobar' in directory 'baz' will produce
'$(obj)/baz/libfoobar.so' | Return the 'output' (full output path) of a gyp spec. | [
"Return",
"the",
"output",
"(",
"full",
"output",
"path",
")",
"of",
"a",
"gyp",
"spec",
"."
] | def ComputeOutput(self, spec):
"""Return the 'output' (full output path) of a gyp spec.
E.g., the loadable module 'foobar' in directory 'baz' will produce
'$(obj)/baz/libfoobar.so'
"""
if self.type == 'executable' and self.toolset == 'host':
# We install host executables into shared_intermediate_dir so they can be
# run by gyp rules that refer to PRODUCT_DIR.
path = '$(gyp_shared_intermediate_dir)'
elif self.type == 'shared_library':
if self.toolset == 'host':
path = '$(HOST_OUT_INTERMEDIATE_LIBRARIES)'
else:
path = '$(TARGET_OUT_INTERMEDIATE_LIBRARIES)'
else:
# Other targets just get built into their intermediate dir.
if self.toolset == 'host':
path = '$(call intermediates-dir-for,%s,%s,true)' % (self.android_class,
self.android_module)
else:
path = '$(call intermediates-dir-for,%s,%s)' % (self.android_class,
self.android_module)
assert spec.get('product_dir') is None # TODO: not supported?
return os.path.join(path, self.ComputeOutputBasename(spec)) | [
"def",
"ComputeOutput",
"(",
"self",
",",
"spec",
")",
":",
"if",
"self",
".",
"type",
"==",
"'executable'",
"and",
"self",
".",
"toolset",
"==",
"'host'",
":",
"# We install host executables into shared_intermediate_dir so they can be",
"# run by gyp rules that refer to ... | https://github.com/larroy/clearskies_core/blob/3574ddf0edc8555454c7044126e786a6c29444dc/tools/gyp/pylib/gyp/generator/android.py#L672-L697 | |
hyperledger-archives/iroha | ed579f85126d0e86532a1f4f1f6ce5681bbcd3a9 | docs/permissions_compiler/rst.py | python | example | (text) | return result | Renders example description contents | Renders example description contents | [
"Renders",
"example",
"description",
"contents"
] | def example(text):
"""Renders example description contents"""
result = ['**Example**', '']
lines = text.split('\n')
for line in lines:
result.append('| {}'.format(line))
result.extend(['|', ''])
return result | [
"def",
"example",
"(",
"text",
")",
":",
"result",
"=",
"[",
"'**Example**'",
",",
"''",
"]",
"lines",
"=",
"text",
".",
"split",
"(",
"'\\n'",
")",
"for",
"line",
"in",
"lines",
":",
"result",
".",
"append",
"(",
"'| {}'",
".",
"format",
"(",
"lin... | https://github.com/hyperledger-archives/iroha/blob/ed579f85126d0e86532a1f4f1f6ce5681bbcd3a9/docs/permissions_compiler/rst.py#L157-L164 | |
google/mysql-protobuf | 467cda676afaa49e762c5c9164a43f6ad31a1fbf | protobuf/python/google/protobuf/internal/containers.py | python | RepeatedScalarFieldContainer.__eq__ | (self, other) | return other == self._values | Compares the current instance with another one. | Compares the current instance with another one. | [
"Compares",
"the",
"current",
"instance",
"with",
"another",
"one",
"."
] | def __eq__(self, other):
"""Compares the current instance with another one."""
if self is other:
return True
# Special case for the same type which should be common and fast.
if isinstance(other, self.__class__):
return other._values == self._values
# We are presumably comparing against some other sequence type.
return other == self._values | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
"is",
"other",
":",
"return",
"True",
"# Special case for the same type which should be common and fast.",
"if",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"return",
"o... | https://github.com/google/mysql-protobuf/blob/467cda676afaa49e762c5c9164a43f6ad31a1fbf/protobuf/python/google/protobuf/internal/containers.py#L329-L337 | |
OSGeo/gdal | 3748fc4ba4fba727492774b2b908a2130c864a83 | swig/python/osgeo/ogr.py | python | GeomFieldDefn.SetNullable | (self, *args) | return _ogr.GeomFieldDefn_SetNullable(self, *args) | r"""SetNullable(GeomFieldDefn self, int bNullable) | r"""SetNullable(GeomFieldDefn self, int bNullable) | [
"r",
"SetNullable",
"(",
"GeomFieldDefn",
"self",
"int",
"bNullable",
")"
] | def SetNullable(self, *args):
r"""SetNullable(GeomFieldDefn self, int bNullable)"""
return _ogr.GeomFieldDefn_SetNullable(self, *args) | [
"def",
"SetNullable",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"_ogr",
".",
"GeomFieldDefn_SetNullable",
"(",
"self",
",",
"*",
"args",
")"
] | https://github.com/OSGeo/gdal/blob/3748fc4ba4fba727492774b2b908a2130c864a83/swig/python/osgeo/ogr.py#L5637-L5639 | |
ChromiumWebApps/chromium | c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7 | third_party/closure_linter/closure_linter/closurizednamespacesinfo.py | python | ClosurizedNamespacesInfo.ProcessToken | (self, token, state_tracker) | Processes the given token for dependency information.
Args:
token: The token to process.
state_tracker: The JavaScript state tracker. | Processes the given token for dependency information. | [
"Processes",
"the",
"given",
"token",
"for",
"dependency",
"information",
"."
] | def ProcessToken(self, token, state_tracker):
"""Processes the given token for dependency information.
Args:
token: The token to process.
state_tracker: The JavaScript state tracker.
"""
# Note that this method is in the critical path for the linter and has been
# optimized for performance in the following ways:
# - Tokens are checked by type first to minimize the number of function
# calls necessary to determine if action needs to be taken for the token.
# - The most common tokens types are checked for first.
# - The number of function calls has been minimized (thus the length of this
# function.
if token.type == TokenType.IDENTIFIER:
# TODO(user): Consider saving the whole identifier in metadata.
whole_identifier_string = self._GetWholeIdentifierString(token)
if whole_identifier_string is None:
# We only want to process the identifier one time. If the whole string
# identifier is None, that means this token was part of a multi-token
# identifier, but it was not the first token of the identifier.
return
# In the odd case that a goog.require is encountered inside a function,
# just ignore it (e.g. dynamic loading in test runners).
if token.string == 'goog.require' and not state_tracker.InFunction():
self._require_tokens.append(token)
namespace = tokenutil.Search(token, TokenType.STRING_TEXT).string
if namespace in self._required_namespaces:
self._duplicate_require_tokens.append(token)
else:
self._required_namespaces.append(namespace)
# If there is a suppression for the require, add a usage for it so it
# gets treated as a regular goog.require (i.e. still gets sorted).
jsdoc = state_tracker.GetDocComment()
if jsdoc and ('extraRequire' in jsdoc.suppressions):
self._suppressed_requires.append(namespace)
self._AddUsedNamespace(state_tracker, namespace)
elif token.string == 'goog.provide':
self._provide_tokens.append(token)
namespace = tokenutil.Search(token, TokenType.STRING_TEXT).string
if namespace in self._provided_namespaces:
self._duplicate_provide_tokens.append(token)
else:
self._provided_namespaces.append(namespace)
# If there is a suppression for the provide, add a creation for it so it
# gets treated as a regular goog.provide (i.e. still gets sorted).
jsdoc = state_tracker.GetDocComment()
if jsdoc and ('extraProvide' in jsdoc.suppressions):
self._AddCreatedNamespace(state_tracker, namespace)
elif token.string == 'goog.scope':
self._scopified_file = True
else:
jsdoc = state_tracker.GetDocComment()
if jsdoc and jsdoc.HasFlag('typedef'):
self._AddCreatedNamespace(state_tracker, whole_identifier_string,
self.GetClosurizedNamespace(
whole_identifier_string))
else:
self._AddUsedNamespace(state_tracker, whole_identifier_string)
elif token.type == TokenType.SIMPLE_LVALUE:
identifier = token.values['identifier']
namespace = self.GetClosurizedNamespace(identifier)
if state_tracker.InFunction():
self._AddUsedNamespace(state_tracker, identifier)
elif namespace and namespace != 'goog':
self._AddCreatedNamespace(state_tracker, identifier, namespace)
elif token.type == TokenType.DOC_FLAG:
flag_type = token.attached_object.flag_type
is_interface = state_tracker.GetDocComment().HasFlag('interface')
if flag_type == 'implements' or (flag_type == 'extends' and is_interface):
# Interfaces should be goog.require'd.
doc_start = tokenutil.Search(token, TokenType.DOC_START_BRACE)
interface = tokenutil.Search(doc_start, TokenType.COMMENT)
self._AddUsedNamespace(state_tracker, interface.string) | [
"def",
"ProcessToken",
"(",
"self",
",",
"token",
",",
"state_tracker",
")",
":",
"# Note that this method is in the critical path for the linter and has been",
"# optimized for performance in the following ways:",
"# - Tokens are checked by type first to minimize the number of function",
... | https://github.com/ChromiumWebApps/chromium/blob/c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7/third_party/closure_linter/closure_linter/closurizednamespacesinfo.py#L280-L363 | ||
wxWidgets/wxPython-Classic | 19571e1ae65f1ac445f5491474121998c97a1bf0 | src/osx_cocoa/_misc.py | python | GetFullHostName | (*args) | return _misc_.GetFullHostName(*args) | GetFullHostName() -> String | GetFullHostName() -> String | [
"GetFullHostName",
"()",
"-",
">",
"String"
] | def GetFullHostName(*args):
"""GetFullHostName() -> String"""
return _misc_.GetFullHostName(*args) | [
"def",
"GetFullHostName",
"(",
"*",
"args",
")",
":",
"return",
"_misc_",
".",
"GetFullHostName",
"(",
"*",
"args",
")"
] | https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/_misc.py#L393-L395 | |
kungfu-origin/kungfu | 90c84b2b590855654cb9a6395ed050e0f7763512 | core/deps/SQLiteCpp-2.3.0/cpplint.py | python | _FunctionState.Count | (self) | Count line in current function body. | Count line in current function body. | [
"Count",
"line",
"in",
"current",
"function",
"body",
"."
] | def Count(self):
"""Count line in current function body."""
if self.in_a_function:
self.lines_in_function += 1 | [
"def",
"Count",
"(",
"self",
")",
":",
"if",
"self",
".",
"in_a_function",
":",
"self",
".",
"lines_in_function",
"+=",
"1"
] | https://github.com/kungfu-origin/kungfu/blob/90c84b2b590855654cb9a6395ed050e0f7763512/core/deps/SQLiteCpp-2.3.0/cpplint.py#L822-L825 | ||
google/skia | 82d65d0487bd72f5f7332d002429ec2dc61d2463 | tools/skpbench/_hardware.py | python | Hardware.sanity_check | (self) | Raises a HardwareException if any hardware state is not as expected. | Raises a HardwareException if any hardware state is not as expected. | [
"Raises",
"a",
"HardwareException",
"if",
"any",
"hardware",
"state",
"is",
"not",
"as",
"expected",
"."
] | def sanity_check(self):
"""Raises a HardwareException if any hardware state is not as expected."""
pass | [
"def",
"sanity_check",
"(",
"self",
")",
":",
"pass"
] | https://github.com/google/skia/blob/82d65d0487bd72f5f7332d002429ec2dc61d2463/tools/skpbench/_hardware.py#L36-L38 | ||
gem5/gem5 | 141cc37c2d4b93959d4c249b8f7e6a8b2ef75338 | ext/ply/example/ansic/cparse.py | python | p_conditional_expression_1 | (t) | conditional_expression : logical_or_expression | conditional_expression : logical_or_expression | [
"conditional_expression",
":",
"logical_or_expression"
] | def p_conditional_expression_1(t):
'conditional_expression : logical_or_expression'
pass | [
"def",
"p_conditional_expression_1",
"(",
"t",
")",
":",
"pass"
] | https://github.com/gem5/gem5/blob/141cc37c2d4b93959d4c249b8f7e6a8b2ef75338/ext/ply/example/ansic/cparse.py#L601-L603 | ||
catboost/catboost | 167f64f237114a4d10b2b4ee42adb4569137debe | contrib/python/path.py/path.py | python | Path.dirs | (self, pattern=None) | return [p for p in self.listdir(pattern) if p.isdir()] | D.dirs() -> List of this directory's subdirectories.
The elements of the list are Path objects.
This does not walk recursively into subdirectories
(but see :meth:`walkdirs`).
With the optional `pattern` argument, this only lists
directories whose names match the given pattern. For
example, ``d.dirs('build-*')``. | D.dirs() -> List of this directory's subdirectories. | [
"D",
".",
"dirs",
"()",
"-",
">",
"List",
"of",
"this",
"directory",
"s",
"subdirectories",
"."
] | def dirs(self, pattern=None):
""" D.dirs() -> List of this directory's subdirectories.
The elements of the list are Path objects.
This does not walk recursively into subdirectories
(but see :meth:`walkdirs`).
With the optional `pattern` argument, this only lists
directories whose names match the given pattern. For
example, ``d.dirs('build-*')``.
"""
return [p for p in self.listdir(pattern) if p.isdir()] | [
"def",
"dirs",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"return",
"[",
"p",
"for",
"p",
"in",
"self",
".",
"listdir",
"(",
"pattern",
")",
"if",
"p",
".",
"isdir",
"(",
")",
"]"
] | https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/python/path.py/path.py#L535-L546 | |
MythTV/mythtv | d282a209cb8be85d036f85a62a8ec971b67d45f4 | mythtv/contrib/imports/mirobridge/mirobridge/mirobridge_interpreter_6_0_0.py | python | MiroInterpreter.do_download | (self, line) | download <name> -- Downloads an item by name in the feed/playlist
selected. | download <name> -- Downloads an item by name in the feed/playlist
selected. | [
"download",
"<name",
">",
"--",
"Downloads",
"an",
"item",
"by",
"name",
"in",
"the",
"feed",
"/",
"playlist",
"selected",
"."
] | def do_download(self, line):
"""download <name> -- Downloads an item by name in the feed/playlist
selected.
"""
if self.selection_type is None:
print "Error: No feed/playlist selected."
return
item = self._find_item(line)
if item is None:
print "No item named %r" % line
return
if item.get_state() == 'downloading':
print '%s is currently being downloaded' % item.get_title()
elif item.is_downloaded():
print '%s is already downloaded' % item.get_title()
else:
item.download() | [
"def",
"do_download",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"selection_type",
"is",
"None",
":",
"print",
"\"Error: No feed/playlist selected.\"",
"return",
"item",
"=",
"self",
".",
"_find_item",
"(",
"line",
")",
"if",
"item",
"is",
"None"... | https://github.com/MythTV/mythtv/blob/d282a209cb8be85d036f85a62a8ec971b67d45f4/mythtv/contrib/imports/mirobridge/mirobridge/mirobridge_interpreter_6_0_0.py#L696-L712 | ||
weolar/miniblink49 | 1c4678db0594a4abde23d3ebbcc7cd13c3170777 | third_party/jinja2/debug.py | python | translate_syntax_error | (error, source=None) | return fake_exc_info(exc_info, filename, error.lineno) | Rewrites a syntax error to please traceback systems. | Rewrites a syntax error to please traceback systems. | [
"Rewrites",
"a",
"syntax",
"error",
"to",
"please",
"traceback",
"systems",
"."
] | def translate_syntax_error(error, source=None):
"""Rewrites a syntax error to please traceback systems."""
error.source = source
error.translated = True
exc_info = (error.__class__, error, None)
filename = error.filename
if filename is None:
filename = '<unknown>'
return fake_exc_info(exc_info, filename, error.lineno) | [
"def",
"translate_syntax_error",
"(",
"error",
",",
"source",
"=",
"None",
")",
":",
"error",
".",
"source",
"=",
"source",
"error",
".",
"translated",
"=",
"True",
"exc_info",
"=",
"(",
"error",
".",
"__class__",
",",
"error",
",",
"None",
")",
"filenam... | https://github.com/weolar/miniblink49/blob/1c4678db0594a4abde23d3ebbcc7cd13c3170777/third_party/jinja2/debug.py#L143-L151 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemMetric/v1/AWS/common-code/Lib/pandas/core/arrays/sparse/array.py | python | SparseArray.any | (self, axis=0, *args, **kwargs) | return values.any().item() | Tests whether at least one of elements evaluate True
Returns
-------
any : bool
See Also
--------
numpy.any | Tests whether at least one of elements evaluate True | [
"Tests",
"whether",
"at",
"least",
"one",
"of",
"elements",
"evaluate",
"True"
] | def any(self, axis=0, *args, **kwargs):
"""
Tests whether at least one of elements evaluate True
Returns
-------
any : bool
See Also
--------
numpy.any
"""
nv.validate_any(args, kwargs)
values = self.sp_values
if len(values) != len(self) and np.any(self.fill_value):
return True
return values.any().item() | [
"def",
"any",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"nv",
".",
"validate_any",
"(",
"args",
",",
"kwargs",
")",
"values",
"=",
"self",
".",
"sp_values",
"if",
"len",
"(",
"values",
")",
"!=",
"... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/common-code/Lib/pandas/core/arrays/sparse/array.py#L1198-L1217 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/requests/sessions.py | python | Session.get_adapter | (self, url) | Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter | Returns the appropriate connection adapter for the given URL. | [
"Returns",
"the",
"appropriate",
"connection",
"adapter",
"for",
"the",
"given",
"URL",
"."
] | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix):
return adapter
# Nothing matches :-/
raise InvalidSchema("No connection adapters were found for '%s'" % url) | [
"def",
"get_adapter",
"(",
"self",
",",
"url",
")",
":",
"for",
"(",
"prefix",
",",
"adapter",
")",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"prefix",
")",
":",
"retu... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/requests/sessions.py#L691-L703 | ||
ros-perception/vision_opencv | c791220cefd0abf02c6719e2ce0fea465857a88e | image_geometry/src/image_geometry/cameramodels.py | python | PinholeCameraModel.fy | (self) | return self.P[1,1] | Returns y focal length | Returns y focal length | [
"Returns",
"y",
"focal",
"length"
] | def fy(self):
""" Returns y focal length """
return self.P[1,1] | [
"def",
"fy",
"(",
"self",
")",
":",
"return",
"self",
".",
"P",
"[",
"1",
",",
"1",
"]"
] | https://github.com/ros-perception/vision_opencv/blob/c791220cefd0abf02c6719e2ce0fea465857a88e/image_geometry/src/image_geometry/cameramodels.py#L239-L241 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numba/targets/npdatetime.py | python | are_not_nat | (builder, vals) | return pred | Return a predicate which is true if all of *vals* are not NaT. | Return a predicate which is true if all of *vals* are not NaT. | [
"Return",
"a",
"predicate",
"which",
"is",
"true",
"if",
"all",
"of",
"*",
"vals",
"*",
"are",
"not",
"NaT",
"."
] | def are_not_nat(builder, vals):
"""
Return a predicate which is true if all of *vals* are not NaT.
"""
assert len(vals) >= 1
pred = is_not_nat(builder, vals[0])
for val in vals[1:]:
pred = builder.and_(pred, is_not_nat(builder, val))
return pred | [
"def",
"are_not_nat",
"(",
"builder",
",",
"vals",
")",
":",
"assert",
"len",
"(",
"vals",
")",
">=",
"1",
"pred",
"=",
"is_not_nat",
"(",
"builder",
",",
"vals",
"[",
"0",
"]",
")",
"for",
"val",
"in",
"vals",
"[",
"1",
":",
"]",
":",
"pred",
... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numba/targets/npdatetime.py#L99-L107 | |
blocknetdx/blocknet | f85bdf3eeebb1ed8c2321ebd928232d4885b30b6 | contrib/devtools/security-check.py | python | check_PE_DYNAMIC_BASE | (executable) | return (bits & reqbits) == reqbits | PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR) | PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR) | [
"PIE",
":",
"DllCharacteristics",
"bit",
"0x40",
"signifies",
"dynamicbase",
"(",
"ASLR",
")"
] | def check_PE_DYNAMIC_BASE(executable):
'''PIE: DllCharacteristics bit 0x40 signifies dynamicbase (ASLR)'''
(arch,bits) = get_PE_dll_characteristics(executable)
reqbits = IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
return (bits & reqbits) == reqbits | [
"def",
"check_PE_DYNAMIC_BASE",
"(",
"executable",
")",
":",
"(",
"arch",
",",
"bits",
")",
"=",
"get_PE_dll_characteristics",
"(",
"executable",
")",
"reqbits",
"=",
"IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE",
"return",
"(",
"bits",
"&",
"reqbits",
")",
"==",
"reqb... | https://github.com/blocknetdx/blocknet/blob/f85bdf3eeebb1ed8c2321ebd928232d4885b30b6/contrib/devtools/security-check.py#L142-L146 | |
aws/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | dev/Tools/Python/3.7.10/windows/Lib/site-packages/setuptools/depends.py | python | extract_constant | (code, symbol, default=-1) | Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
object 'code', return that value. If 'symbol' is bound to an expression,
return 'default'. Otherwise, return 'None'.
Return value is based on the first assignment to 'symbol'. 'symbol' must
be a global, or at least a non-"fast" local in the code block. That is,
only 'STORE_NAME' and 'STORE_GLOBAL' opcodes are checked, and 'symbol'
must be present in 'code.co_names'. | Extract the constant value of 'symbol' from 'code' | [
"Extract",
"the",
"constant",
"value",
"of",
"symbol",
"from",
"code"
] | def extract_constant(code, symbol, default=-1):
"""Extract the constant value of 'symbol' from 'code'
If the name 'symbol' is bound to a constant value by the Python code
object 'code', return that value. If 'symbol' is bound to an expression,
return 'default'. Otherwise, return 'None'.
Return value is based on the first assignment to 'symbol'. 'symbol' must
be a global, or at least a non-"fast" local in the code block. That is,
only 'STORE_NAME' and 'STORE_GLOBAL' opcodes are checked, and 'symbol'
must be present in 'code.co_names'.
"""
if symbol not in code.co_names:
# name's not there, can't possibly be an assignment
return None
name_idx = list(code.co_names).index(symbol)
STORE_NAME = 90
STORE_GLOBAL = 97
LOAD_CONST = 100
const = default
for byte_code in Bytecode(code):
op = byte_code.opcode
arg = byte_code.arg
if op == LOAD_CONST:
const = code.co_consts[arg]
elif arg == name_idx and (op == STORE_NAME or op == STORE_GLOBAL):
return const
else:
const = default | [
"def",
"extract_constant",
"(",
"code",
",",
"symbol",
",",
"default",
"=",
"-",
"1",
")",
":",
"if",
"symbol",
"not",
"in",
"code",
".",
"co_names",
":",
"# name's not there, can't possibly be an assignment",
"return",
"None",
"name_idx",
"=",
"list",
"(",
"c... | https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/windows/Lib/site-packages/setuptools/depends.py#L125-L158 | ||
Xilinx/Vitis-AI | fc74d404563d9951b57245443c73bef389f3657f | tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/framework/tensor_shape.py | python | matrix | (rows, cols) | return TensorShape([rows, cols]) | Returns a shape representing a matrix.
Args:
rows: The number of rows in the matrix, which may be None if unknown.
cols: The number of columns in the matrix, which may be None if unknown.
Returns:
A TensorShape representing a matrix of the given size. | Returns a shape representing a matrix. | [
"Returns",
"a",
"shape",
"representing",
"a",
"matrix",
"."
] | def matrix(rows, cols):
"""Returns a shape representing a matrix.
Args:
rows: The number of rows in the matrix, which may be None if unknown.
cols: The number of columns in the matrix, which may be None if unknown.
Returns:
A TensorShape representing a matrix of the given size.
"""
return TensorShape([rows, cols]) | [
"def",
"matrix",
"(",
"rows",
",",
"cols",
")",
":",
"return",
"TensorShape",
"(",
"[",
"rows",
",",
"cols",
"]",
")"
] | https://github.com/Xilinx/Vitis-AI/blob/fc74d404563d9951b57245443c73bef389f3657f/tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/framework/tensor_shape.py#L1262-L1272 | |
openthread/openthread | 9fcdbed9c526c70f1556d1ed84099c1535c7cd32 | tools/harness-thci/OpenThread.py | python | OpenThreadTHCI.setNetworkKey | (self, key) | return self.__executeCommand(cmd)[-1] == 'Done' and self.__executeCommand(datasetCmd)[-1] == 'Done' | set Thread network key
Args:
key: Thread network key used in secure the MLE/802.15.4 packet
Returns:
True: successful to set the Thread network key
False: fail to set the Thread network key | set Thread network key | [
"set",
"Thread",
"network",
"key"
] | def setNetworkKey(self, key):
"""set Thread network key
Args:
key: Thread network key used in secure the MLE/802.15.4 packet
Returns:
True: successful to set the Thread network key
False: fail to set the Thread network key
"""
print('%s call setNetworkKey' % self)
print(key)
if not isinstance(key, str):
networkKey = self.__convertLongToHex(key, 32)
cmd = 'networkkey %s' % networkKey
datasetCmd = 'dataset networkkey %s' % networkKey
else:
networkKey = key
cmd = 'networkkey %s' % networkKey
datasetCmd = 'dataset networkkey %s' % networkKey
self.networkKey = networkKey
self.hasActiveDatasetToCommit = True
return self.__executeCommand(cmd)[-1] == 'Done' and self.__executeCommand(datasetCmd)[-1] == 'Done' | [
"def",
"setNetworkKey",
"(",
"self",
",",
"key",
")",
":",
"print",
"(",
"'%s call setNetworkKey'",
"%",
"self",
")",
"print",
"(",
"key",
")",
"if",
"not",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"networkKey",
"=",
"self",
".",
"__convertLongToH... | https://github.com/openthread/openthread/blob/9fcdbed9c526c70f1556d1ed84099c1535c7cd32/tools/harness-thci/OpenThread.py#L1004-L1028 | |
ChromiumWebApps/chromium | c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7 | third_party/closure_linter/closure_linter/tokenutil.py | python | SearchExcept | (start_token, token_types, distance=None, reverse=False) | return CustomSearch(start_token,
lambda token: not token.IsAnyType(token_types),
None, distance, reverse) | Returns the first token not of any type in token_types within distance.
Args:
start_token: The token to start searching from
token_types: The unallowable types of the token being searched for
distance: The number of tokens to look through before failing search. Must
be positive. If unspecified, will search until the end of the token
chain
reverse: When true, search the tokens before this one instead of the tokens
after it
Returns:
The first token of any type in token_types within distance of this token, or
None if no such token is found. | Returns the first token not of any type in token_types within distance. | [
"Returns",
"the",
"first",
"token",
"not",
"of",
"any",
"type",
"in",
"token_types",
"within",
"distance",
"."
] | def SearchExcept(start_token, token_types, distance=None, reverse=False):
"""Returns the first token not of any type in token_types within distance.
Args:
start_token: The token to start searching from
token_types: The unallowable types of the token being searched for
distance: The number of tokens to look through before failing search. Must
be positive. If unspecified, will search until the end of the token
chain
reverse: When true, search the tokens before this one instead of the tokens
after it
Returns:
The first token of any type in token_types within distance of this token, or
None if no such token is found.
"""
return CustomSearch(start_token,
lambda token: not token.IsAnyType(token_types),
None, distance, reverse) | [
"def",
"SearchExcept",
"(",
"start_token",
",",
"token_types",
",",
"distance",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"return",
"CustomSearch",
"(",
"start_token",
",",
"lambda",
"token",
":",
"not",
"token",
".",
"IsAnyType",
"(",
"token_type... | https://github.com/ChromiumWebApps/chromium/blob/c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7/third_party/closure_linter/closure_linter/tokenutil.py#L167-L185 | |
Polidea/SiriusObfuscator | b0e590d8130e97856afe578869b83a209e2b19be | SymbolExtractorAndRenamer/lldb/examples/python/file_extract.py | python | FileExtract.get_n_sint32 | (self, n, fail_value=0) | Extract "n" int32_t integers from the binary file at the current file position, returns a list of integers | Extract "n" int32_t integers from the binary file at the current file position, returns a list of integers | [
"Extract",
"n",
"int32_t",
"integers",
"from",
"the",
"binary",
"file",
"at",
"the",
"current",
"file",
"position",
"returns",
"a",
"list",
"of",
"integers"
] | def get_n_sint32(self, n, fail_value=0):
'''Extract "n" int32_t integers from the binary file at the current file position, returns a list of integers'''
s = self.read_size(4 * n)
if s:
return struct.unpack(self.byte_order + ("%u" % n) + 'i', s)
else:
return (fail_value,) * n | [
"def",
"get_n_sint32",
"(",
"self",
",",
"n",
",",
"fail_value",
"=",
"0",
")",
":",
"s",
"=",
"self",
".",
"read_size",
"(",
"4",
"*",
"n",
")",
"if",
"s",
":",
"return",
"struct",
".",
"unpack",
"(",
"self",
".",
"byte_order",
"+",
"(",
"\"%u\"... | https://github.com/Polidea/SiriusObfuscator/blob/b0e590d8130e97856afe578869b83a209e2b19be/SymbolExtractorAndRenamer/lldb/examples/python/file_extract.py#L196-L202 | ||
gklz1982/caffe-yolov2 | ebb27029db4ddc0d40e520634633b0fa9cdcc10d | tools/extra/parse_log.py | python | fix_initial_nan_learning_rate | (dict_list) | Correct initial value of learning rate
Learning rate is normally not printed until after the initial test and
training step, which means the initial testing and training rows have
LearningRate = NaN. Fix this by copying over the LearningRate from the
second row, if it exists. | Correct initial value of learning rate | [
"Correct",
"initial",
"value",
"of",
"learning",
"rate"
] | def fix_initial_nan_learning_rate(dict_list):
"""Correct initial value of learning rate
Learning rate is normally not printed until after the initial test and
training step, which means the initial testing and training rows have
LearningRate = NaN. Fix this by copying over the LearningRate from the
second row, if it exists.
"""
if len(dict_list) > 1:
dict_list[0]['LearningRate'] = dict_list[1]['LearningRate'] | [
"def",
"fix_initial_nan_learning_rate",
"(",
"dict_list",
")",
":",
"if",
"len",
"(",
"dict_list",
")",
">",
"1",
":",
"dict_list",
"[",
"0",
"]",
"[",
"'LearningRate'",
"]",
"=",
"dict_list",
"[",
"1",
"]",
"[",
"'LearningRate'",
"]"
] | https://github.com/gklz1982/caffe-yolov2/blob/ebb27029db4ddc0d40e520634633b0fa9cdcc10d/tools/extra/parse_log.py#L119-L129 | ||
AMReX-Astro/Castro | 5bf85dc1fe41909206d80ff71463f2baad22dab5 | Exec/science/flame_wave/analysis/front_tracker.py | python | get_center | (ds, xlim=None, ylim=None, zlim=None) | return xctr, yctr, zctr | Get the coordinates of the center of the frb. | Get the coordinates of the center of the frb. | [
"Get",
"the",
"coordinates",
"of",
"the",
"center",
"of",
"the",
"frb",
"."
] | def get_center(ds, xlim=None, ylim=None, zlim=None):
""" Get the coordinates of the center of the frb. """
if xlim is None: xlim = ds.domain_left_edge[0], ds.domain_right_edge[0]
else: xlim = xlim[0], xlim[1]
if ylim is None: ylim = ds.domain_left_edge[1], ds.domain_right_edge[1]
else: ylim = ylim[0], ylim[1]
if zlim is None: zlim = ds.domain_left_edge[2], ds.domain_right_edge[2]
else: zlim = zlim[0], zlim[1]
xctr = 0.5 * (xlim[0] + xlim[1]).in_cgs()
yctr = 0.5 * (ylim[0] + ylim[1]).in_cgs()
zctr = 0.5 * (zlim[0] + zlim[1]).in_cgs()
return xctr, yctr, zctr | [
"def",
"get_center",
"(",
"ds",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
",",
"zlim",
"=",
"None",
")",
":",
"if",
"xlim",
"is",
"None",
":",
"xlim",
"=",
"ds",
".",
"domain_left_edge",
"[",
"0",
"]",
",",
"ds",
".",
"domain_right_edge",... | https://github.com/AMReX-Astro/Castro/blob/5bf85dc1fe41909206d80ff71463f2baad22dab5/Exec/science/flame_wave/analysis/front_tracker.py#L157-L173 | |
msitt/blpapi-python | bebcf43668c9e5f5467b1f685f9baebbfc45bc87 | src/blpapi/event.py | python | EventQueue._getSessions | (self) | return sessions | Get a list of sessions this EventQueue related to.
For internal use. | Get a list of sessions this EventQueue related to. | [
"Get",
"a",
"list",
"of",
"sessions",
"this",
"EventQueue",
"related",
"to",
"."
] | def _getSessions(self):
"""Get a list of sessions this EventQueue related to.
For internal use.
"""
sessions = list(self.__sessions)
return sessions | [
"def",
"_getSessions",
"(",
"self",
")",
":",
"sessions",
"=",
"list",
"(",
"self",
".",
"__sessions",
")",
"return",
"sessions"
] | https://github.com/msitt/blpapi-python/blob/bebcf43668c9e5f5467b1f685f9baebbfc45bc87/src/blpapi/event.py#L220-L226 | |
echronos/echronos | c996f1d2c8af6c6536205eb319c1bf1d4d84569c | external_tools/ply_info/example/GardenSnake/GardenSnake.py | python | p_if_stmt | (p) | if_stmt : IF test COLON suite | if_stmt : IF test COLON suite | [
"if_stmt",
":",
"IF",
"test",
"COLON",
"suite"
] | def p_if_stmt(p):
'if_stmt : IF test COLON suite'
p[0] = ast.If([(p[2], p[4])], None) | [
"def",
"p_if_stmt",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"If",
"(",
"[",
"(",
"p",
"[",
"2",
"]",
",",
"p",
"[",
"4",
"]",
")",
"]",
",",
"None",
")"
] | https://github.com/echronos/echronos/blob/c996f1d2c8af6c6536205eb319c1bf1d4d84569c/external_tools/ply_info/example/GardenSnake/GardenSnake.py#L466-L468 | ||
dmlc/treelite | df56babb6a4a2d7c29d719c28ce53acfa7dbab3c | python/treelite/frontend.py | python | Model.num_tree | (self) | return out.value | Number of decision trees in the model | Number of decision trees in the model | [
"Number",
"of",
"decision",
"trees",
"in",
"the",
"model"
] | def num_tree(self):
"""Number of decision trees in the model"""
if self.handle is None:
raise AttributeError('Model not loaded yet')
out = ctypes.c_size_t()
_check_call(_LIB.TreeliteQueryNumTree(self.handle, ctypes.byref(out)))
return out.value | [
"def",
"num_tree",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"'Model not loaded yet'",
")",
"out",
"=",
"ctypes",
".",
"c_size_t",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"TreeliteQueryNumTree",... | https://github.com/dmlc/treelite/blob/df56babb6a4a2d7c29d719c28ce53acfa7dbab3c/python/treelite/frontend.py#L129-L135 | |
gemrb/gemrb | 730206eed8d1dd358ca5e69a62f9e099aa22ffc6 | gemrb/GUIScripts/GUICommonWindows.py | python | ActionQItemRightPressed | (action) | return | Selects the used ability of the quick item. | Selects the used ability of the quick item. | [
"Selects",
"the",
"used",
"ability",
"of",
"the",
"quick",
"item",
"."
] | def ActionQItemRightPressed (action):
"""Selects the used ability of the quick item."""
GemRB.SetVar ("Slot", action)
GemRB.SetVar ("ActionLevel", UAW_QITEMS)
UpdateActionsWindow ()
return | [
"def",
"ActionQItemRightPressed",
"(",
"action",
")",
":",
"GemRB",
".",
"SetVar",
"(",
"\"Slot\"",
",",
"action",
")",
"GemRB",
".",
"SetVar",
"(",
"\"ActionLevel\"",
",",
"UAW_QITEMS",
")",
"UpdateActionsWindow",
"(",
")",
"return"
] | https://github.com/gemrb/gemrb/blob/730206eed8d1dd358ca5e69a62f9e099aa22ffc6/gemrb/GUIScripts/GUICommonWindows.py#L981-L986 | |
baidu/AnyQ | d94d450d2aaa5f7ed73424b10aa4539835b97527 | tools/simnet/train/paddle/optimizers/paddle_optimizers.py | python | AdamOptimizer.__init__ | (self, conf_dict) | initialize | initialize | [
"initialize"
] | def __init__(self, conf_dict):
"""
initialize
"""
self.learning_rate = conf_dict["optimizer"]["learning_rate"]
self.beta1 = conf_dict["optimizer"]["beta1"]
self.beta2 = conf_dict["optimizer"]["beta2"]
self.epsilon = conf_dict["optimizer"]["epsilon"] | [
"def",
"__init__",
"(",
"self",
",",
"conf_dict",
")",
":",
"self",
".",
"learning_rate",
"=",
"conf_dict",
"[",
"\"optimizer\"",
"]",
"[",
"\"learning_rate\"",
"]",
"self",
".",
"beta1",
"=",
"conf_dict",
"[",
"\"optimizer\"",
"]",
"[",
"\"beta1\"",
"]",
... | https://github.com/baidu/AnyQ/blob/d94d450d2aaa5f7ed73424b10aa4539835b97527/tools/simnet/train/paddle/optimizers/paddle_optimizers.py#L42-L49 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.