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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
wlanjie/AndroidFFmpeg
|
7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf
|
tools/fdk-aac-build/armeabi/toolchain/lib/python2.7/plat-mac/aepack.py
|
python
|
unpack
|
(desc, formodulename="")
|
return mkunknown(desc.type, desc.data)
|
Unpack an AE descriptor to a python object
|
Unpack an AE descriptor to a python object
|
[
"Unpack",
"an",
"AE",
"descriptor",
"to",
"a",
"python",
"object"
] |
def unpack(desc, formodulename=""):
"""Unpack an AE descriptor to a python object"""
t = desc.type
if t in unpacker_coercions:
desc = desc.AECoerceDesc(unpacker_coercions[t])
t = desc.type # This is a guess by Jack....
if t == typeAEList:
l = []
for i in range(desc.AECountItems()):
keyword, item = desc.AEGetNthDesc(i+1, '****')
l.append(unpack(item, formodulename))
return l
if t == typeAERecord:
d = {}
for i in range(desc.AECountItems()):
keyword, item = desc.AEGetNthDesc(i+1, '****')
d[keyword] = unpack(item, formodulename)
return d
if t == typeAEText:
record = desc.AECoerceDesc('reco')
return mkaetext(unpack(record, formodulename))
if t == typeAlias:
return Carbon.File.Alias(rawdata=desc.data)
# typeAppleEvent returned as unknown
if t == typeBoolean:
return struct.unpack('b', desc.data)[0]
if t == typeChar:
return desc.data
if t == typeUnicodeText:
return unicode(desc.data, 'utf16')
# typeColorTable coerced to typeAEList
# typeComp coerced to extended
# typeData returned as unknown
# typeDrawingArea coerced to typeAERecord
if t == typeEnumeration:
return mkenum(desc.data)
# typeEPS returned as unknown
if t == typeFalse:
return 0
if t == typeFloat:
data = desc.data
return struct.unpack('d', data)[0]
if t == typeFSS:
return Carbon.File.FSSpec(rawdata=desc.data)
if t == typeFSRef:
return Carbon.File.FSRef(rawdata=desc.data)
if t == typeInsertionLoc:
record = desc.AECoerceDesc('reco')
return mkinsertionloc(unpack(record, formodulename))
# typeInteger equal to typeLongInteger
if t == typeIntlText:
script, language = struct.unpack('hh', desc.data[:4])
return aetypes.IntlText(script, language, desc.data[4:])
if t == typeIntlWritingCode:
script, language = struct.unpack('hh', desc.data)
return aetypes.IntlWritingCode(script, language)
if t == typeKeyword:
return mkkeyword(desc.data)
if t == typeLongInteger:
return struct.unpack('l', desc.data)[0]
if t == typeLongDateTime:
a, b = struct.unpack('lL', desc.data)
return (long(a) << 32) + b
if t == typeNull:
return None
if t == typeMagnitude:
v = struct.unpack('l', desc.data)
if v < 0:
v = 0x100000000L + v
return v
if t == typeObjectSpecifier:
record = desc.AECoerceDesc('reco')
# If we have been told the name of the module we are unpacking aedescs for,
# we can attempt to create the right type of python object from that module.
if formodulename:
return mkobjectfrommodule(unpack(record, formodulename), formodulename)
return mkobject(unpack(record, formodulename))
# typePict returned as unknown
# typePixelMap coerced to typeAERecord
# typePixelMapMinus returned as unknown
# typeProcessSerialNumber returned as unknown
if t == typeQDPoint:
v, h = struct.unpack('hh', desc.data)
return aetypes.QDPoint(v, h)
if t == typeQDRectangle:
v0, h0, v1, h1 = struct.unpack('hhhh', desc.data)
return aetypes.QDRectangle(v0, h0, v1, h1)
if t == typeRGBColor:
r, g, b = struct.unpack('hhh', desc.data)
return aetypes.RGBColor(r, g, b)
# typeRotation coerced to typeAERecord
# typeScrapStyles returned as unknown
# typeSessionID returned as unknown
if t == typeShortFloat:
return struct.unpack('f', desc.data)[0]
if t == typeShortInteger:
return struct.unpack('h', desc.data)[0]
# typeSMFloat identical to typeShortFloat
# typeSMInt indetical to typeShortInt
# typeStyledText coerced to typeAERecord
if t == typeTargetID:
return mktargetid(desc.data)
# typeTextStyles coerced to typeAERecord
# typeTIFF returned as unknown
if t == typeTrue:
return 1
if t == typeType:
return mktype(desc.data, formodulename)
#
# The following are special
#
if t == 'rang':
record = desc.AECoerceDesc('reco')
return mkrange(unpack(record, formodulename))
if t == 'cmpd':
record = desc.AECoerceDesc('reco')
return mkcomparison(unpack(record, formodulename))
if t == 'logi':
record = desc.AECoerceDesc('reco')
return mklogical(unpack(record, formodulename))
return mkunknown(desc.type, desc.data)
|
[
"def",
"unpack",
"(",
"desc",
",",
"formodulename",
"=",
"\"\"",
")",
":",
"t",
"=",
"desc",
".",
"type",
"if",
"t",
"in",
"unpacker_coercions",
":",
"desc",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"unpacker_coercions",
"[",
"t",
"]",
")",
"t",
"=",
"desc",
".",
"type",
"# This is a guess by Jack....",
"if",
"t",
"==",
"typeAEList",
":",
"l",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"desc",
".",
"AECountItems",
"(",
")",
")",
":",
"keyword",
",",
"item",
"=",
"desc",
".",
"AEGetNthDesc",
"(",
"i",
"+",
"1",
",",
"'****'",
")",
"l",
".",
"append",
"(",
"unpack",
"(",
"item",
",",
"formodulename",
")",
")",
"return",
"l",
"if",
"t",
"==",
"typeAERecord",
":",
"d",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"desc",
".",
"AECountItems",
"(",
")",
")",
":",
"keyword",
",",
"item",
"=",
"desc",
".",
"AEGetNthDesc",
"(",
"i",
"+",
"1",
",",
"'****'",
")",
"d",
"[",
"keyword",
"]",
"=",
"unpack",
"(",
"item",
",",
"formodulename",
")",
"return",
"d",
"if",
"t",
"==",
"typeAEText",
":",
"record",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"'reco'",
")",
"return",
"mkaetext",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
")",
"if",
"t",
"==",
"typeAlias",
":",
"return",
"Carbon",
".",
"File",
".",
"Alias",
"(",
"rawdata",
"=",
"desc",
".",
"data",
")",
"# typeAppleEvent returned as unknown",
"if",
"t",
"==",
"typeBoolean",
":",
"return",
"struct",
".",
"unpack",
"(",
"'b'",
",",
"desc",
".",
"data",
")",
"[",
"0",
"]",
"if",
"t",
"==",
"typeChar",
":",
"return",
"desc",
".",
"data",
"if",
"t",
"==",
"typeUnicodeText",
":",
"return",
"unicode",
"(",
"desc",
".",
"data",
",",
"'utf16'",
")",
"# typeColorTable coerced to typeAEList",
"# typeComp coerced to extended",
"# typeData returned as unknown",
"# typeDrawingArea coerced to typeAERecord",
"if",
"t",
"==",
"typeEnumeration",
":",
"return",
"mkenum",
"(",
"desc",
".",
"data",
")",
"# typeEPS returned as unknown",
"if",
"t",
"==",
"typeFalse",
":",
"return",
"0",
"if",
"t",
"==",
"typeFloat",
":",
"data",
"=",
"desc",
".",
"data",
"return",
"struct",
".",
"unpack",
"(",
"'d'",
",",
"data",
")",
"[",
"0",
"]",
"if",
"t",
"==",
"typeFSS",
":",
"return",
"Carbon",
".",
"File",
".",
"FSSpec",
"(",
"rawdata",
"=",
"desc",
".",
"data",
")",
"if",
"t",
"==",
"typeFSRef",
":",
"return",
"Carbon",
".",
"File",
".",
"FSRef",
"(",
"rawdata",
"=",
"desc",
".",
"data",
")",
"if",
"t",
"==",
"typeInsertionLoc",
":",
"record",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"'reco'",
")",
"return",
"mkinsertionloc",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
")",
"# typeInteger equal to typeLongInteger",
"if",
"t",
"==",
"typeIntlText",
":",
"script",
",",
"language",
"=",
"struct",
".",
"unpack",
"(",
"'hh'",
",",
"desc",
".",
"data",
"[",
":",
"4",
"]",
")",
"return",
"aetypes",
".",
"IntlText",
"(",
"script",
",",
"language",
",",
"desc",
".",
"data",
"[",
"4",
":",
"]",
")",
"if",
"t",
"==",
"typeIntlWritingCode",
":",
"script",
",",
"language",
"=",
"struct",
".",
"unpack",
"(",
"'hh'",
",",
"desc",
".",
"data",
")",
"return",
"aetypes",
".",
"IntlWritingCode",
"(",
"script",
",",
"language",
")",
"if",
"t",
"==",
"typeKeyword",
":",
"return",
"mkkeyword",
"(",
"desc",
".",
"data",
")",
"if",
"t",
"==",
"typeLongInteger",
":",
"return",
"struct",
".",
"unpack",
"(",
"'l'",
",",
"desc",
".",
"data",
")",
"[",
"0",
"]",
"if",
"t",
"==",
"typeLongDateTime",
":",
"a",
",",
"b",
"=",
"struct",
".",
"unpack",
"(",
"'lL'",
",",
"desc",
".",
"data",
")",
"return",
"(",
"long",
"(",
"a",
")",
"<<",
"32",
")",
"+",
"b",
"if",
"t",
"==",
"typeNull",
":",
"return",
"None",
"if",
"t",
"==",
"typeMagnitude",
":",
"v",
"=",
"struct",
".",
"unpack",
"(",
"'l'",
",",
"desc",
".",
"data",
")",
"if",
"v",
"<",
"0",
":",
"v",
"=",
"0x100000000L",
"+",
"v",
"return",
"v",
"if",
"t",
"==",
"typeObjectSpecifier",
":",
"record",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"'reco'",
")",
"# If we have been told the name of the module we are unpacking aedescs for,",
"# we can attempt to create the right type of python object from that module.",
"if",
"formodulename",
":",
"return",
"mkobjectfrommodule",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
",",
"formodulename",
")",
"return",
"mkobject",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
")",
"# typePict returned as unknown",
"# typePixelMap coerced to typeAERecord",
"# typePixelMapMinus returned as unknown",
"# typeProcessSerialNumber returned as unknown",
"if",
"t",
"==",
"typeQDPoint",
":",
"v",
",",
"h",
"=",
"struct",
".",
"unpack",
"(",
"'hh'",
",",
"desc",
".",
"data",
")",
"return",
"aetypes",
".",
"QDPoint",
"(",
"v",
",",
"h",
")",
"if",
"t",
"==",
"typeQDRectangle",
":",
"v0",
",",
"h0",
",",
"v1",
",",
"h1",
"=",
"struct",
".",
"unpack",
"(",
"'hhhh'",
",",
"desc",
".",
"data",
")",
"return",
"aetypes",
".",
"QDRectangle",
"(",
"v0",
",",
"h0",
",",
"v1",
",",
"h1",
")",
"if",
"t",
"==",
"typeRGBColor",
":",
"r",
",",
"g",
",",
"b",
"=",
"struct",
".",
"unpack",
"(",
"'hhh'",
",",
"desc",
".",
"data",
")",
"return",
"aetypes",
".",
"RGBColor",
"(",
"r",
",",
"g",
",",
"b",
")",
"# typeRotation coerced to typeAERecord",
"# typeScrapStyles returned as unknown",
"# typeSessionID returned as unknown",
"if",
"t",
"==",
"typeShortFloat",
":",
"return",
"struct",
".",
"unpack",
"(",
"'f'",
",",
"desc",
".",
"data",
")",
"[",
"0",
"]",
"if",
"t",
"==",
"typeShortInteger",
":",
"return",
"struct",
".",
"unpack",
"(",
"'h'",
",",
"desc",
".",
"data",
")",
"[",
"0",
"]",
"# typeSMFloat identical to typeShortFloat",
"# typeSMInt indetical to typeShortInt",
"# typeStyledText coerced to typeAERecord",
"if",
"t",
"==",
"typeTargetID",
":",
"return",
"mktargetid",
"(",
"desc",
".",
"data",
")",
"# typeTextStyles coerced to typeAERecord",
"# typeTIFF returned as unknown",
"if",
"t",
"==",
"typeTrue",
":",
"return",
"1",
"if",
"t",
"==",
"typeType",
":",
"return",
"mktype",
"(",
"desc",
".",
"data",
",",
"formodulename",
")",
"#",
"# The following are special",
"#",
"if",
"t",
"==",
"'rang'",
":",
"record",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"'reco'",
")",
"return",
"mkrange",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
")",
"if",
"t",
"==",
"'cmpd'",
":",
"record",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"'reco'",
")",
"return",
"mkcomparison",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
")",
"if",
"t",
"==",
"'logi'",
":",
"record",
"=",
"desc",
".",
"AECoerceDesc",
"(",
"'reco'",
")",
"return",
"mklogical",
"(",
"unpack",
"(",
"record",
",",
"formodulename",
")",
")",
"return",
"mkunknown",
"(",
"desc",
".",
"type",
",",
"desc",
".",
"data",
")"
] |
https://github.com/wlanjie/AndroidFFmpeg/blob/7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf/tools/fdk-aac-build/armeabi/toolchain/lib/python2.7/plat-mac/aepack.py#L131-L253
|
|
cocos-creator/engine-native
|
984c4c9f5838253313b44ccd429bd8fac4ec8a6a
|
tools/bindings-generator/clang/cindex.py
|
python
|
Cursor.availability
|
(self)
|
return AvailabilityKind.from_id(self._availability)
|
Retrieves the availability of the entity pointed at by the cursor.
|
Retrieves the availability of the entity pointed at by the cursor.
|
[
"Retrieves",
"the",
"availability",
"of",
"the",
"entity",
"pointed",
"at",
"by",
"the",
"cursor",
"."
] |
def availability(self):
"""
Retrieves the availability of the entity pointed at by the cursor.
"""
if not hasattr(self, '_availability'):
self._availability = conf.lib.clang_getCursorAvailability(self)
return AvailabilityKind.from_id(self._availability)
|
[
"def",
"availability",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_availability'",
")",
":",
"self",
".",
"_availability",
"=",
"conf",
".",
"lib",
".",
"clang_getCursorAvailability",
"(",
"self",
")",
"return",
"AvailabilityKind",
".",
"from_id",
"(",
"self",
".",
"_availability",
")"
] |
https://github.com/cocos-creator/engine-native/blob/984c4c9f5838253313b44ccd429bd8fac4ec8a6a/tools/bindings-generator/clang/cindex.py#L1623-L1630
|
|
hughperkins/tf-coriander
|
970d3df6c11400ad68405f22b0c42a52374e94ca
|
tensorflow/python/framework/docs.py
|
python
|
Library._write_class_markdown_to_file
|
(self, f, name, cls)
|
Write the class doc to `f`.
Args:
f: File to write to.
name: name to use.
cls: class object.
|
Write the class doc to `f`.
|
[
"Write",
"the",
"class",
"doc",
"to",
"f",
"."
] |
def _write_class_markdown_to_file(self, f, name, cls):
"""Write the class doc to `f`.
Args:
f: File to write to.
name: name to use.
cls: class object.
"""
# Build the list of class methods to document.
methods = dict(self.get_class_members(name, cls))
# Used later to check if any methods were called out in the class
# docstring.
num_methods = len(methods)
try:
self._write_docstring_markdown_to_file(f, "####", inspect.getdoc(cls),
methods, {})
except ValueError as e:
raise ValueError(str(e) + " in class `%s`" % cls.__name__)
# If some methods were not described, describe them now if they are
# defined by the class itself (not inherited). If NO methods were
# described, describe all methods.
#
# TODO(touts): when all methods have been categorized make it an error
# if some methods are not categorized.
any_method_called_out = (len(methods) != num_methods)
if any_method_called_out:
other_methods = {n: m for n, m in methods.items() if n in cls.__dict__}
if other_methods:
print("\n#### Other Methods", file=f)
else:
other_methods = methods
for name in sorted(other_methods):
self._write_member_markdown_to_file(f, "####", *other_methods[name])
|
[
"def",
"_write_class_markdown_to_file",
"(",
"self",
",",
"f",
",",
"name",
",",
"cls",
")",
":",
"# Build the list of class methods to document.",
"methods",
"=",
"dict",
"(",
"self",
".",
"get_class_members",
"(",
"name",
",",
"cls",
")",
")",
"# Used later to check if any methods were called out in the class",
"# docstring.",
"num_methods",
"=",
"len",
"(",
"methods",
")",
"try",
":",
"self",
".",
"_write_docstring_markdown_to_file",
"(",
"f",
",",
"\"####\"",
",",
"inspect",
".",
"getdoc",
"(",
"cls",
")",
",",
"methods",
",",
"{",
"}",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"ValueError",
"(",
"str",
"(",
"e",
")",
"+",
"\" in class `%s`\"",
"%",
"cls",
".",
"__name__",
")",
"# If some methods were not described, describe them now if they are",
"# defined by the class itself (not inherited). If NO methods were",
"# described, describe all methods.",
"#",
"# TODO(touts): when all methods have been categorized make it an error",
"# if some methods are not categorized.",
"any_method_called_out",
"=",
"(",
"len",
"(",
"methods",
")",
"!=",
"num_methods",
")",
"if",
"any_method_called_out",
":",
"other_methods",
"=",
"{",
"n",
":",
"m",
"for",
"n",
",",
"m",
"in",
"methods",
".",
"items",
"(",
")",
"if",
"n",
"in",
"cls",
".",
"__dict__",
"}",
"if",
"other_methods",
":",
"print",
"(",
"\"\\n#### Other Methods\"",
",",
"file",
"=",
"f",
")",
"else",
":",
"other_methods",
"=",
"methods",
"for",
"name",
"in",
"sorted",
"(",
"other_methods",
")",
":",
"self",
".",
"_write_member_markdown_to_file",
"(",
"f",
",",
"\"####\"",
",",
"*",
"other_methods",
"[",
"name",
"]",
")"
] |
https://github.com/hughperkins/tf-coriander/blob/970d3df6c11400ad68405f22b0c42a52374e94ca/tensorflow/python/framework/docs.py#L478-L511
|
||
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/urllib3/packages/six.py
|
python
|
python_2_unicode_compatible
|
(klass)
|
return klass
|
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
|
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
|
[
"A",
"decorator",
"that",
"defines",
"__unicode__",
"and",
"__str__",
"methods",
"under",
"Python",
"2",
".",
"Under",
"Python",
"3",
"it",
"does",
"nothing",
"."
] |
def python_2_unicode_compatible(klass):
"""
A decorator that defines __unicode__ and __str__ methods under Python 2.
Under Python 3 it does nothing.
To support Python 2 and 3 with a single code base, define a __str__ method
returning text and apply this decorator to the class.
"""
if PY2:
if '__str__' not in klass.__dict__:
raise ValueError("@python_2_unicode_compatible cannot be applied "
"to %s because it doesn't define __str__()." %
klass.__name__)
klass.__unicode__ = klass.__str__
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
return klass
|
[
"def",
"python_2_unicode_compatible",
"(",
"klass",
")",
":",
"if",
"PY2",
":",
"if",
"'__str__'",
"not",
"in",
"klass",
".",
"__dict__",
":",
"raise",
"ValueError",
"(",
"\"@python_2_unicode_compatible cannot be applied \"",
"\"to %s because it doesn't define __str__().\"",
"%",
"klass",
".",
"__name__",
")",
"klass",
".",
"__unicode__",
"=",
"klass",
".",
"__str__",
"klass",
".",
"__str__",
"=",
"lambda",
"self",
":",
"self",
".",
"__unicode__",
"(",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"klass"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemDefectReporter/v1/AWS/common-code/Lib/urllib3/packages/six.py#L828-L843
|
|
yyzybb537/libgo
|
4af17b7c67643c4d54aa354dcc77963ea07847d0
|
third_party/boost.context/tools/build/src/util/path.py
|
python
|
glob_tree
|
(roots, patterns, exclude_patterns=None)
|
return result
|
Recursive version of GLOB. Builds the glob of files while
also searching in the subdirectories of the given roots. An
optional set of exclusion patterns will filter out the
matching entries from the result. The exclusions also apply
to the subdirectory scanning, such that directories that
match the exclusion patterns will not be searched.
|
Recursive version of GLOB. Builds the glob of files while
also searching in the subdirectories of the given roots. An
optional set of exclusion patterns will filter out the
matching entries from the result. The exclusions also apply
to the subdirectory scanning, such that directories that
match the exclusion patterns will not be searched.
|
[
"Recursive",
"version",
"of",
"GLOB",
".",
"Builds",
"the",
"glob",
"of",
"files",
"while",
"also",
"searching",
"in",
"the",
"subdirectories",
"of",
"the",
"given",
"roots",
".",
"An",
"optional",
"set",
"of",
"exclusion",
"patterns",
"will",
"filter",
"out",
"the",
"matching",
"entries",
"from",
"the",
"result",
".",
"The",
"exclusions",
"also",
"apply",
"to",
"the",
"subdirectory",
"scanning",
"such",
"that",
"directories",
"that",
"match",
"the",
"exclusion",
"patterns",
"will",
"not",
"be",
"searched",
"."
] |
def glob_tree(roots, patterns, exclude_patterns=None):
"""Recursive version of GLOB. Builds the glob of files while
also searching in the subdirectories of the given roots. An
optional set of exclusion patterns will filter out the
matching entries from the result. The exclusions also apply
to the subdirectory scanning, such that directories that
match the exclusion patterns will not be searched."""
if not exclude_patterns:
exclude_patterns = []
result = glob(roots, patterns, exclude_patterns)
subdirs = [s for s in glob(roots, ["*"]) if s != "." and s != ".." and os.path.isdir(s)]
if subdirs:
result.extend(glob_tree(subdirs, patterns, exclude_patterns))
return result
|
[
"def",
"glob_tree",
"(",
"roots",
",",
"patterns",
",",
"exclude_patterns",
"=",
"None",
")",
":",
"if",
"not",
"exclude_patterns",
":",
"exclude_patterns",
"=",
"[",
"]",
"result",
"=",
"glob",
"(",
"roots",
",",
"patterns",
",",
"exclude_patterns",
")",
"subdirs",
"=",
"[",
"s",
"for",
"s",
"in",
"glob",
"(",
"roots",
",",
"[",
"\"*\"",
"]",
")",
"if",
"s",
"!=",
"\".\"",
"and",
"s",
"!=",
"\"..\"",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"s",
")",
"]",
"if",
"subdirs",
":",
"result",
".",
"extend",
"(",
"glob_tree",
"(",
"subdirs",
",",
"patterns",
",",
"exclude_patterns",
")",
")",
"return",
"result"
] |
https://github.com/yyzybb537/libgo/blob/4af17b7c67643c4d54aa354dcc77963ea07847d0/third_party/boost.context/tools/build/src/util/path.py#L872-L888
|
|
shader-slang/slang
|
b8982fcf43b86c1e39dcc3dd19bff2821633eda6
|
external/vulkan/registry/cgenerator.py
|
python
|
COutputGenerator.genStruct
|
(self, typeinfo, typeName, alias)
|
Generate struct (e.g. C "struct" type).
This is a special case of the <type> tag where the contents are
interpreted as a set of <member> tags instead of freeform C
C type declarations. The <member> tags are just like <param>
tags - they are a declaration of a struct or union member.
Only simple member declarations are supported (no nested
structs etc.)
If alias is not None, then this struct aliases another; just
generate a typedef of that alias.
|
Generate struct (e.g. C "struct" type).
|
[
"Generate",
"struct",
"(",
"e",
".",
"g",
".",
"C",
"struct",
"type",
")",
"."
] |
def genStruct(self, typeinfo, typeName, alias):
"""Generate struct (e.g. C "struct" type).
This is a special case of the <type> tag where the contents are
interpreted as a set of <member> tags instead of freeform C
C type declarations. The <member> tags are just like <param>
tags - they are a declaration of a struct or union member.
Only simple member declarations are supported (no nested
structs etc.)
If alias is not None, then this struct aliases another; just
generate a typedef of that alias."""
OutputGenerator.genStruct(self, typeinfo, typeName, alias)
typeElem = typeinfo.elem
if alias:
body = 'typedef ' + alias + ' ' + typeName + ';\n'
else:
body = ''
(protect_begin, protect_end) = self.genProtectString(typeElem.get('protect'))
if protect_begin:
body += protect_begin
body += 'typedef ' + typeElem.get('category')
# This is an OpenXR-specific alternative where aliasing refers
# to an inheritance hierarchy of types rather than C-level type
# aliases.
if self.genOpts.genAliasMacro and self.typeMayAlias(typeName):
body += ' ' + self.genOpts.aliasMacro
body += ' ' + typeName + ' {\n'
targetLen = self.getMaxCParamTypeLength(typeinfo)
for member in typeElem.findall('.//member'):
body += self.makeCParamDecl(member, targetLen + 4)
body += ';\n'
body += '} ' + typeName + ';\n'
if protect_end:
body += protect_end
self.appendSection('struct', body)
|
[
"def",
"genStruct",
"(",
"self",
",",
"typeinfo",
",",
"typeName",
",",
"alias",
")",
":",
"OutputGenerator",
".",
"genStruct",
"(",
"self",
",",
"typeinfo",
",",
"typeName",
",",
"alias",
")",
"typeElem",
"=",
"typeinfo",
".",
"elem",
"if",
"alias",
":",
"body",
"=",
"'typedef '",
"+",
"alias",
"+",
"' '",
"+",
"typeName",
"+",
"';\\n'",
"else",
":",
"body",
"=",
"''",
"(",
"protect_begin",
",",
"protect_end",
")",
"=",
"self",
".",
"genProtectString",
"(",
"typeElem",
".",
"get",
"(",
"'protect'",
")",
")",
"if",
"protect_begin",
":",
"body",
"+=",
"protect_begin",
"body",
"+=",
"'typedef '",
"+",
"typeElem",
".",
"get",
"(",
"'category'",
")",
"# This is an OpenXR-specific alternative where aliasing refers",
"# to an inheritance hierarchy of types rather than C-level type",
"# aliases.",
"if",
"self",
".",
"genOpts",
".",
"genAliasMacro",
"and",
"self",
".",
"typeMayAlias",
"(",
"typeName",
")",
":",
"body",
"+=",
"' '",
"+",
"self",
".",
"genOpts",
".",
"aliasMacro",
"body",
"+=",
"' '",
"+",
"typeName",
"+",
"' {\\n'",
"targetLen",
"=",
"self",
".",
"getMaxCParamTypeLength",
"(",
"typeinfo",
")",
"for",
"member",
"in",
"typeElem",
".",
"findall",
"(",
"'.//member'",
")",
":",
"body",
"+=",
"self",
".",
"makeCParamDecl",
"(",
"member",
",",
"targetLen",
"+",
"4",
")",
"body",
"+=",
"';\\n'",
"body",
"+=",
"'} '",
"+",
"typeName",
"+",
"';\\n'",
"if",
"protect_end",
":",
"body",
"+=",
"protect_end",
"self",
".",
"appendSection",
"(",
"'struct'",
",",
"body",
")"
] |
https://github.com/shader-slang/slang/blob/b8982fcf43b86c1e39dcc3dd19bff2821633eda6/external/vulkan/registry/cgenerator.py#L313-L354
|
||
catboost/catboost
|
167f64f237114a4d10b2b4ee42adb4569137debe
|
contrib/tools/python3/src/Lib/logging/config.py
|
python
|
DictConfigurator.common_logger_config
|
(self, logger, config, incremental=False)
|
Perform configuration which is common to root and non-root loggers.
|
Perform configuration which is common to root and non-root loggers.
|
[
"Perform",
"configuration",
"which",
"is",
"common",
"to",
"root",
"and",
"non",
"-",
"root",
"loggers",
"."
] |
def common_logger_config(self, logger, config, incremental=False):
"""
Perform configuration which is common to root and non-root loggers.
"""
level = config.get('level', None)
if level is not None:
logger.setLevel(logging._checkLevel(level))
if not incremental:
#Remove any existing handlers
for h in logger.handlers[:]:
logger.removeHandler(h)
handlers = config.get('handlers', None)
if handlers:
self.add_handlers(logger, handlers)
filters = config.get('filters', None)
if filters:
self.add_filters(logger, filters)
|
[
"def",
"common_logger_config",
"(",
"self",
",",
"logger",
",",
"config",
",",
"incremental",
"=",
"False",
")",
":",
"level",
"=",
"config",
".",
"get",
"(",
"'level'",
",",
"None",
")",
"if",
"level",
"is",
"not",
"None",
":",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"_checkLevel",
"(",
"level",
")",
")",
"if",
"not",
"incremental",
":",
"#Remove any existing handlers",
"for",
"h",
"in",
"logger",
".",
"handlers",
"[",
":",
"]",
":",
"logger",
".",
"removeHandler",
"(",
"h",
")",
"handlers",
"=",
"config",
".",
"get",
"(",
"'handlers'",
",",
"None",
")",
"if",
"handlers",
":",
"self",
".",
"add_handlers",
"(",
"logger",
",",
"handlers",
")",
"filters",
"=",
"config",
".",
"get",
"(",
"'filters'",
",",
"None",
")",
"if",
"filters",
":",
"self",
".",
"add_filters",
"(",
"logger",
",",
"filters",
")"
] |
https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/tools/python3/src/Lib/logging/config.py#L774-L790
|
||
facebookincubator/BOLT
|
88c70afe9d388ad430cc150cc158641701397f70
|
compiler-rt/lib/asan/scripts/asan_symbolize.py
|
python
|
Symbolizer.symbolize
|
(self, addr, binary, offset)
|
return None
|
Symbolize the given address (pair of binary and offset).
Overriden in subclasses.
Args:
addr: virtual address of an instruction.
binary: path to executable/shared object containing this instruction.
offset: instruction offset in the @binary.
Returns:
list of strings (one string for each inlined frame) describing
the code locations for this instruction (that is, function name, file
name, line and column numbers).
|
Symbolize the given address (pair of binary and offset).
|
[
"Symbolize",
"the",
"given",
"address",
"(",
"pair",
"of",
"binary",
"and",
"offset",
")",
"."
] |
def symbolize(self, addr, binary, offset):
"""Symbolize the given address (pair of binary and offset).
Overriden in subclasses.
Args:
addr: virtual address of an instruction.
binary: path to executable/shared object containing this instruction.
offset: instruction offset in the @binary.
Returns:
list of strings (one string for each inlined frame) describing
the code locations for this instruction (that is, function name, file
name, line and column numbers).
"""
return None
|
[
"def",
"symbolize",
"(",
"self",
",",
"addr",
",",
"binary",
",",
"offset",
")",
":",
"return",
"None"
] |
https://github.com/facebookincubator/BOLT/blob/88c70afe9d388ad430cc150cc158641701397f70/compiler-rt/lib/asan/scripts/asan_symbolize.py#L66-L79
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_carbon/calendar.py
|
python
|
CalendarDateAttr.HasBorderColour
|
(*args, **kwargs)
|
return _calendar.CalendarDateAttr_HasBorderColour(*args, **kwargs)
|
HasBorderColour(self) -> bool
|
HasBorderColour(self) -> bool
|
[
"HasBorderColour",
"(",
"self",
")",
"-",
">",
"bool"
] |
def HasBorderColour(*args, **kwargs):
"""HasBorderColour(self) -> bool"""
return _calendar.CalendarDateAttr_HasBorderColour(*args, **kwargs)
|
[
"def",
"HasBorderColour",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_calendar",
".",
"CalendarDateAttr_HasBorderColour",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_carbon/calendar.py#L130-L132
|
|
CRYTEK/CRYENGINE
|
232227c59a220cbbd311576f0fbeba7bb53b2a8c
|
Code/Tools/waf-1.7.13/crywaflib/msvs.py
|
python
|
make_uuid
|
(v, prefix = None)
|
return str(gid).upper()
|
simple utility function
|
simple utility function
|
[
"simple",
"utility",
"function"
] |
def make_uuid(v, prefix = None):
"""
simple utility function
"""
if isinstance(v, dict):
keys = list(v.keys())
keys.sort()
tmp = str([(k, v[k]) for k in keys])
else:
tmp = str(v)
d = Utils.md5(tmp.encode()).hexdigest().upper()
if prefix:
d = '%s%s' % (prefix, d[8:])
gid = uuid.UUID(d, version = 4)
return str(gid).upper()
|
[
"def",
"make_uuid",
"(",
"v",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"keys",
"=",
"list",
"(",
"v",
".",
"keys",
"(",
")",
")",
"keys",
".",
"sort",
"(",
")",
"tmp",
"=",
"str",
"(",
"[",
"(",
"k",
",",
"v",
"[",
"k",
"]",
")",
"for",
"k",
"in",
"keys",
"]",
")",
"else",
":",
"tmp",
"=",
"str",
"(",
"v",
")",
"d",
"=",
"Utils",
".",
"md5",
"(",
"tmp",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")",
".",
"upper",
"(",
")",
"if",
"prefix",
":",
"d",
"=",
"'%s%s'",
"%",
"(",
"prefix",
",",
"d",
"[",
"8",
":",
"]",
")",
"gid",
"=",
"uuid",
".",
"UUID",
"(",
"d",
",",
"version",
"=",
"4",
")",
"return",
"str",
"(",
"gid",
")",
".",
"upper",
"(",
")"
] |
https://github.com/CRYTEK/CRYENGINE/blob/232227c59a220cbbd311576f0fbeba7bb53b2a8c/Code/Tools/waf-1.7.13/crywaflib/msvs.py#L710-L724
|
|
CRYTEK/CRYENGINE
|
232227c59a220cbbd311576f0fbeba7bb53b2a8c
|
Code/Tools/waf-1.7.13/waflib/Node.py
|
python
|
Node.__setstate__
|
(self, data)
|
Deserializes from data
|
Deserializes from data
|
[
"Deserializes",
"from",
"data"
] |
def __setstate__(self, data):
"Deserializes from data"
self.name = data[0]
self.parent = data[1]
if data[2] is not None:
self.children = data[2]
if data[3] is not None:
self.sig = data[3]
|
[
"def",
"__setstate__",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"name",
"=",
"data",
"[",
"0",
"]",
"self",
".",
"parent",
"=",
"data",
"[",
"1",
"]",
"if",
"data",
"[",
"2",
"]",
"is",
"not",
"None",
":",
"self",
".",
"children",
"=",
"data",
"[",
"2",
"]",
"if",
"data",
"[",
"3",
"]",
"is",
"not",
"None",
":",
"self",
".",
"sig",
"=",
"data",
"[",
"3",
"]"
] |
https://github.com/CRYTEK/CRYENGINE/blob/232227c59a220cbbd311576f0fbeba7bb53b2a8c/Code/Tools/waf-1.7.13/waflib/Node.py#L113-L120
|
||
ricardoquesada/Spidermonkey
|
4a75ea2543408bd1b2c515aa95901523eeef7858
|
python/configobj/configobj.py
|
python
|
InterpolationEngine._parse_match
|
(self, match)
|
Implementation-dependent helper function.
Will be passed a match object corresponding to the interpolation
key we just found (e.g., "%(foo)s" or "$foo"). Should look up that
key in the appropriate config file section (using the ``_fetch()``
helper function) and return a 3-tuple: (key, value, section)
``key`` is the name of the key we're looking for
``value`` is the value found for that key
``section`` is a reference to the section where it was found
``key`` and ``section`` should be None if no further
interpolation should be performed on the resulting value
(e.g., if we interpolated "$$" and returned "$").
|
Implementation-dependent helper function.
|
[
"Implementation",
"-",
"dependent",
"helper",
"function",
"."
] |
def _parse_match(self, match):
"""Implementation-dependent helper function.
Will be passed a match object corresponding to the interpolation
key we just found (e.g., "%(foo)s" or "$foo"). Should look up that
key in the appropriate config file section (using the ``_fetch()``
helper function) and return a 3-tuple: (key, value, section)
``key`` is the name of the key we're looking for
``value`` is the value found for that key
``section`` is a reference to the section where it was found
``key`` and ``section`` should be None if no further
interpolation should be performed on the resulting value
(e.g., if we interpolated "$$" and returned "$").
"""
raise NotImplementedError()
|
[
"def",
"_parse_match",
"(",
"self",
",",
"match",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] |
https://github.com/ricardoquesada/Spidermonkey/blob/4a75ea2543408bd1b2c515aa95901523eeef7858/python/configobj/configobj.py#L403-L419
|
||
SpenceKonde/megaTinyCore
|
1c4a70b18a149fe6bcb551dfa6db11ca50b8997b
|
megaavr/tools/libs/serial/rfc2217.py
|
python
|
TelnetOption.__init__
|
(self, connection, name, option, send_yes, send_no, ack_yes,
ack_no, initial_state, activation_callback=None)
|
\
Initialize option.
:param connection: connection used to transmit answers
:param name: a readable name for debug outputs
:param send_yes: what to send when option is to be enabled.
:param send_no: what to send when option is to be disabled.
:param ack_yes: what to expect when remote agrees on option.
:param ack_no: what to expect when remote disagrees on option.
:param initial_state: options initialized with REQUESTED are tried to
be enabled on startup. use INACTIVE for all others.
|
\
Initialize option.
:param connection: connection used to transmit answers
:param name: a readable name for debug outputs
:param send_yes: what to send when option is to be enabled.
:param send_no: what to send when option is to be disabled.
:param ack_yes: what to expect when remote agrees on option.
:param ack_no: what to expect when remote disagrees on option.
:param initial_state: options initialized with REQUESTED are tried to
be enabled on startup. use INACTIVE for all others.
|
[
"\\",
"Initialize",
"option",
".",
":",
"param",
"connection",
":",
"connection",
"used",
"to",
"transmit",
"answers",
":",
"param",
"name",
":",
"a",
"readable",
"name",
"for",
"debug",
"outputs",
":",
"param",
"send_yes",
":",
"what",
"to",
"send",
"when",
"option",
"is",
"to",
"be",
"enabled",
".",
":",
"param",
"send_no",
":",
"what",
"to",
"send",
"when",
"option",
"is",
"to",
"be",
"disabled",
".",
":",
"param",
"ack_yes",
":",
"what",
"to",
"expect",
"when",
"remote",
"agrees",
"on",
"option",
".",
":",
"param",
"ack_no",
":",
"what",
"to",
"expect",
"when",
"remote",
"disagrees",
"on",
"option",
".",
":",
"param",
"initial_state",
":",
"options",
"initialized",
"with",
"REQUESTED",
"are",
"tried",
"to",
"be",
"enabled",
"on",
"startup",
".",
"use",
"INACTIVE",
"for",
"all",
"others",
"."
] |
def __init__(self, connection, name, option, send_yes, send_no, ack_yes,
ack_no, initial_state, activation_callback=None):
"""\
Initialize option.
:param connection: connection used to transmit answers
:param name: a readable name for debug outputs
:param send_yes: what to send when option is to be enabled.
:param send_no: what to send when option is to be disabled.
:param ack_yes: what to expect when remote agrees on option.
:param ack_no: what to expect when remote disagrees on option.
:param initial_state: options initialized with REQUESTED are tried to
be enabled on startup. use INACTIVE for all others.
"""
self.connection = connection
self.name = name
self.option = option
self.send_yes = send_yes
self.send_no = send_no
self.ack_yes = ack_yes
self.ack_no = ack_no
self.state = initial_state
self.active = False
self.activation_callback = activation_callback
|
[
"def",
"__init__",
"(",
"self",
",",
"connection",
",",
"name",
",",
"option",
",",
"send_yes",
",",
"send_no",
",",
"ack_yes",
",",
"ack_no",
",",
"initial_state",
",",
"activation_callback",
"=",
"None",
")",
":",
"self",
".",
"connection",
"=",
"connection",
"self",
".",
"name",
"=",
"name",
"self",
".",
"option",
"=",
"option",
"self",
".",
"send_yes",
"=",
"send_yes",
"self",
".",
"send_no",
"=",
"send_no",
"self",
".",
"ack_yes",
"=",
"ack_yes",
"self",
".",
"ack_no",
"=",
"ack_no",
"self",
".",
"state",
"=",
"initial_state",
"self",
".",
"active",
"=",
"False",
"self",
".",
"activation_callback",
"=",
"activation_callback"
] |
https://github.com/SpenceKonde/megaTinyCore/blob/1c4a70b18a149fe6bcb551dfa6db11ca50b8997b/megaavr/tools/libs/serial/rfc2217.py#L238-L260
|
||
psi4/psi4
|
be533f7f426b6ccc263904e55122899b16663395
|
psi4/driver/qcdb/libmintsmolecule.py
|
python
|
LibmintsMolecule.set_units
|
(self, units)
|
Sets the geometry units (constructor use).
Parameters
----------
units : {'Angstrom', 'Bohr'}
Units of input geometry.
Returns
-------
None
Examples
--------
# [1]
>>> H2OH2O.set_units('Angstrom')
|
Sets the geometry units (constructor use).
|
[
"Sets",
"the",
"geometry",
"units",
"(",
"constructor",
"use",
")",
"."
] |
def set_units(self, units):
"""Sets the geometry units (constructor use).
Parameters
----------
units : {'Angstrom', 'Bohr'}
Units of input geometry.
Returns
-------
None
Examples
--------
# [1]
>>> H2OH2O.set_units('Angstrom')
"""
if units == 'Angstrom':
self.PYunits = units
self.PYinput_units_to_au = 1.0 / qcel.constants.bohr2angstroms
elif units == 'Bohr':
self.PYunits = units
self.PYinput_units_to_au = 1.0
else:
raise ValidationError("""Molecule::set_units: argument must be 'Angstrom' or 'Bohr'.""")
|
[
"def",
"set_units",
"(",
"self",
",",
"units",
")",
":",
"if",
"units",
"==",
"'Angstrom'",
":",
"self",
".",
"PYunits",
"=",
"units",
"self",
".",
"PYinput_units_to_au",
"=",
"1.0",
"/",
"qcel",
".",
"constants",
".",
"bohr2angstroms",
"elif",
"units",
"==",
"'Bohr'",
":",
"self",
".",
"PYunits",
"=",
"units",
"self",
".",
"PYinput_units_to_au",
"=",
"1.0",
"else",
":",
"raise",
"ValidationError",
"(",
"\"\"\"Molecule::set_units: argument must be 'Angstrom' or 'Bohr'.\"\"\"",
")"
] |
https://github.com/psi4/psi4/blob/be533f7f426b6ccc263904e55122899b16663395/psi4/driver/qcdb/libmintsmolecule.py#L303-L328
|
||
casadi/casadi
|
8d0f80a4d0fe2054384bfb9748f7a0f6bae540ff
|
misc/cpplint.py
|
python
|
Error
|
(filename, linenum, category, confidence, message)
|
Logs the fact we've found a lint error.
We log where the error was found, and also our confidence in the error,
that is, how certain we are this is a legitimate style regression, and
not a misidentification or a use that's sometimes justified.
False positives can be suppressed by the use of
"cpplint(category)" comments on the offending line. These are
parsed into _error_suppressions.
Args:
filename: The name of the file containing the error.
linenum: The number of the line containing the error.
category: A string used to describe the "category" this bug
falls under: "whitespace", say, or "runtime". Categories
may have a hierarchy separated by slashes: "whitespace/indent".
confidence: A number from 1-5 representing a confidence score for
the error, with 5 meaning that we are certain of the problem,
and 1 meaning that it could be a legitimate construct.
message: The error message.
|
Logs the fact we've found a lint error.
|
[
"Logs",
"the",
"fact",
"we",
"ve",
"found",
"a",
"lint",
"error",
"."
] |
def Error(filename, linenum, category, confidence, message):
"""Logs the fact we've found a lint error.
We log where the error was found, and also our confidence in the error,
that is, how certain we are this is a legitimate style regression, and
not a misidentification or a use that's sometimes justified.
False positives can be suppressed by the use of
"cpplint(category)" comments on the offending line. These are
parsed into _error_suppressions.
Args:
filename: The name of the file containing the error.
linenum: The number of the line containing the error.
category: A string used to describe the "category" this bug
falls under: "whitespace", say, or "runtime". Categories
may have a hierarchy separated by slashes: "whitespace/indent".
confidence: A number from 1-5 representing a confidence score for
the error, with 5 meaning that we are certain of the problem,
and 1 meaning that it could be a legitimate construct.
message: The error message.
"""
if _ShouldPrintError(category, confidence, linenum):
_cpplint_state.IncrementErrorCount(category)
if _cpplint_state.output_format == 'vs7':
sys.stderr.write('%s(%s): %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
elif _cpplint_state.output_format == 'eclipse':
sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
else:
sys.stderr.write('%s:%s: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
|
[
"def",
"Error",
"(",
"filename",
",",
"linenum",
",",
"category",
",",
"confidence",
",",
"message",
")",
":",
"if",
"_ShouldPrintError",
"(",
"category",
",",
"confidence",
",",
"linenum",
")",
":",
"_cpplint_state",
".",
"IncrementErrorCount",
"(",
"category",
")",
"if",
"_cpplint_state",
".",
"output_format",
"==",
"'vs7'",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'%s(%s): %s [%s] [%d]\\n'",
"%",
"(",
"filename",
",",
"linenum",
",",
"message",
",",
"category",
",",
"confidence",
")",
")",
"elif",
"_cpplint_state",
".",
"output_format",
"==",
"'eclipse'",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'%s:%s: warning: %s [%s] [%d]\\n'",
"%",
"(",
"filename",
",",
"linenum",
",",
"message",
",",
"category",
",",
"confidence",
")",
")",
"else",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'%s:%s: %s [%s] [%d]\\n'",
"%",
"(",
"filename",
",",
"linenum",
",",
"message",
",",
"category",
",",
"confidence",
")",
")"
] |
https://github.com/casadi/casadi/blob/8d0f80a4d0fe2054384bfb9748f7a0f6bae540ff/misc/cpplint.py#L981-L1013
|
||
hakuna-m/wubiuefi
|
caec1af0a09c78fd5a345180ada1fe45e0c63493
|
src/urlgrabber/keepalive.py
|
python
|
KeepAliveHandler.open_connections
|
(self)
|
return [(host, len(li)) for (host, li) in self._cm.get_all().items()]
|
return a list of connected hosts and the number of connections
to each. [('foo.com:80', 2), ('bar.org', 1)]
|
return a list of connected hosts and the number of connections
to each. [('foo.com:80', 2), ('bar.org', 1)]
|
[
"return",
"a",
"list",
"of",
"connected",
"hosts",
"and",
"the",
"number",
"of",
"connections",
"to",
"each",
".",
"[",
"(",
"foo",
".",
"com",
":",
"80",
"2",
")",
"(",
"bar",
".",
"org",
"1",
")",
"]"
] |
def open_connections(self):
"""return a list of connected hosts and the number of connections
to each. [('foo.com:80', 2), ('bar.org', 1)]"""
return [(host, len(li)) for (host, li) in self._cm.get_all().items()]
|
[
"def",
"open_connections",
"(",
"self",
")",
":",
"return",
"[",
"(",
"host",
",",
"len",
"(",
"li",
")",
")",
"for",
"(",
"host",
",",
"li",
")",
"in",
"self",
".",
"_cm",
".",
"get_all",
"(",
")",
".",
"items",
"(",
")",
"]"
] |
https://github.com/hakuna-m/wubiuefi/blob/caec1af0a09c78fd5a345180ada1fe45e0c63493/src/urlgrabber/keepalive.py#L182-L185
|
|
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Tools/Python/3.7.10/mac/Python.framework/Versions/3.7/lib/python3.7/pkgutil.py
|
python
|
get_importer
|
(path_item)
|
return importer
|
Retrieve a finder for the given path item
The returned finder is cached in sys.path_importer_cache
if it was newly created by a path hook.
The cache (or part of it) can be cleared manually if a
rescan of sys.path_hooks is necessary.
|
Retrieve a finder for the given path item
|
[
"Retrieve",
"a",
"finder",
"for",
"the",
"given",
"path",
"item"
] |
def get_importer(path_item):
"""Retrieve a finder for the given path item
The returned finder is cached in sys.path_importer_cache
if it was newly created by a path hook.
The cache (or part of it) can be cleared manually if a
rescan of sys.path_hooks is necessary.
"""
try:
importer = sys.path_importer_cache[path_item]
except KeyError:
for path_hook in sys.path_hooks:
try:
importer = path_hook(path_item)
sys.path_importer_cache.setdefault(path_item, importer)
break
except ImportError:
pass
else:
importer = None
return importer
|
[
"def",
"get_importer",
"(",
"path_item",
")",
":",
"try",
":",
"importer",
"=",
"sys",
".",
"path_importer_cache",
"[",
"path_item",
"]",
"except",
"KeyError",
":",
"for",
"path_hook",
"in",
"sys",
".",
"path_hooks",
":",
"try",
":",
"importer",
"=",
"path_hook",
"(",
"path_item",
")",
"sys",
".",
"path_importer_cache",
".",
"setdefault",
"(",
"path_item",
",",
"importer",
")",
"break",
"except",
"ImportError",
":",
"pass",
"else",
":",
"importer",
"=",
"None",
"return",
"importer"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/mac/Python.framework/Versions/3.7/lib/python3.7/pkgutil.py#L405-L426
|
|
alibaba/weex_js_engine
|
2bdf4b6f020c1fc99c63f649718f6faf7e27fdde
|
jni/v8core/v8/build/gyp/pylib/gyp/generator/make.py
|
python
|
MakefileWriter.WriteSources
|
(self, configs, deps, sources,
extra_outputs, extra_link_deps,
part_of_all, precompiled_header)
|
Write Makefile code for any 'sources' from the gyp input.
These are source files necessary to build the current target.
configs, deps, sources: input from gyp.
extra_outputs: a list of extra outputs this action should be dependent on;
used to serialize action/rules before compilation
extra_link_deps: a list that will be filled in with any outputs of
compilation (to be used in link lines)
part_of_all: flag indicating this target is part of 'all'
|
Write Makefile code for any 'sources' from the gyp input.
These are source files necessary to build the current target.
|
[
"Write",
"Makefile",
"code",
"for",
"any",
"sources",
"from",
"the",
"gyp",
"input",
".",
"These",
"are",
"source",
"files",
"necessary",
"to",
"build",
"the",
"current",
"target",
"."
] |
def WriteSources(self, configs, deps, sources,
extra_outputs, extra_link_deps,
part_of_all, precompiled_header):
"""Write Makefile code for any 'sources' from the gyp input.
These are source files necessary to build the current target.
configs, deps, sources: input from gyp.
extra_outputs: a list of extra outputs this action should be dependent on;
used to serialize action/rules before compilation
extra_link_deps: a list that will be filled in with any outputs of
compilation (to be used in link lines)
part_of_all: flag indicating this target is part of 'all'
"""
# Write configuration-specific variables for CFLAGS, etc.
for configname in sorted(configs.keys()):
config = configs[configname]
self.WriteList(config.get('defines'), 'DEFS_%s' % configname, prefix='-D',
quoter=EscapeCppDefine)
if self.flavor == 'mac':
cflags = self.xcode_settings.GetCflags(configname)
cflags_c = self.xcode_settings.GetCflagsC(configname)
cflags_cc = self.xcode_settings.GetCflagsCC(configname)
cflags_objc = self.xcode_settings.GetCflagsObjC(configname)
cflags_objcc = self.xcode_settings.GetCflagsObjCC(configname)
else:
cflags = config.get('cflags')
cflags_c = config.get('cflags_c')
cflags_cc = config.get('cflags_cc')
self.WriteLn("# Flags passed to all source files.");
self.WriteList(cflags, 'CFLAGS_%s' % configname)
self.WriteLn("# Flags passed to only C files.");
self.WriteList(cflags_c, 'CFLAGS_C_%s' % configname)
self.WriteLn("# Flags passed to only C++ files.");
self.WriteList(cflags_cc, 'CFLAGS_CC_%s' % configname)
if self.flavor == 'mac':
self.WriteLn("# Flags passed to only ObjC files.");
self.WriteList(cflags_objc, 'CFLAGS_OBJC_%s' % configname)
self.WriteLn("# Flags passed to only ObjC++ files.");
self.WriteList(cflags_objcc, 'CFLAGS_OBJCC_%s' % configname)
includes = config.get('include_dirs')
if includes:
includes = map(Sourceify, map(self.Absolutify, includes))
self.WriteList(includes, 'INCS_%s' % configname, prefix='-I')
compilable = filter(Compilable, sources)
objs = map(self.Objectify, map(self.Absolutify, map(Target, compilable)))
self.WriteList(objs, 'OBJS')
for obj in objs:
assert ' ' not in obj, (
"Spaces in object filenames not supported (%s)" % obj)
self.WriteLn('# Add to the list of files we specially track '
'dependencies for.')
self.WriteLn('all_deps += $(OBJS)')
self.WriteLn()
# Make sure our dependencies are built first.
if deps:
self.WriteMakeRule(['$(OBJS)'], deps,
comment = 'Make sure our dependencies are built '
'before any of us.',
order_only = True)
# Make sure the actions and rules run first.
# If they generate any extra headers etc., the per-.o file dep tracking
# will catch the proper rebuilds, so order only is still ok here.
if extra_outputs:
self.WriteMakeRule(['$(OBJS)'], extra_outputs,
comment = 'Make sure our actions/rules run '
'before any of us.',
order_only = True)
pchdeps = precompiled_header.GetObjDependencies(compilable, objs )
if pchdeps:
self.WriteLn('# Dependencies from obj files to their precompiled headers')
for source, obj, gch in pchdeps:
self.WriteLn('%s: %s' % (obj, gch))
self.WriteLn('# End precompiled header dependencies')
if objs:
extra_link_deps.append('$(OBJS)')
self.WriteLn("""\
# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.""")
self.WriteLn("$(OBJS): TOOLSET := $(TOOLSET)")
self.WriteLn("$(OBJS): GYP_CFLAGS := "
"$(DEFS_$(BUILDTYPE)) "
"$(INCS_$(BUILDTYPE)) "
"%s " % precompiled_header.GetInclude('c') +
"$(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_C_$(BUILDTYPE))")
self.WriteLn("$(OBJS): GYP_CXXFLAGS := "
"$(DEFS_$(BUILDTYPE)) "
"$(INCS_$(BUILDTYPE)) "
"%s " % precompiled_header.GetInclude('cc') +
"$(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_CC_$(BUILDTYPE))")
if self.flavor == 'mac':
self.WriteLn("$(OBJS): GYP_OBJCFLAGS := "
"$(DEFS_$(BUILDTYPE)) "
"$(INCS_$(BUILDTYPE)) "
"%s " % precompiled_header.GetInclude('m') +
"$(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_C_$(BUILDTYPE)) "
"$(CFLAGS_OBJC_$(BUILDTYPE))")
self.WriteLn("$(OBJS): GYP_OBJCXXFLAGS := "
"$(DEFS_$(BUILDTYPE)) "
"$(INCS_$(BUILDTYPE)) "
"%s " % precompiled_header.GetInclude('mm') +
"$(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_CC_$(BUILDTYPE)) "
"$(CFLAGS_OBJCC_$(BUILDTYPE))")
self.WritePchTargets(precompiled_header.GetPchBuildCommands())
# If there are any object files in our input file list, link them into our
# output.
extra_link_deps += filter(Linkable, sources)
self.WriteLn()
|
[
"def",
"WriteSources",
"(",
"self",
",",
"configs",
",",
"deps",
",",
"sources",
",",
"extra_outputs",
",",
"extra_link_deps",
",",
"part_of_all",
",",
"precompiled_header",
")",
":",
"# Write configuration-specific variables for CFLAGS, etc.",
"for",
"configname",
"in",
"sorted",
"(",
"configs",
".",
"keys",
"(",
")",
")",
":",
"config",
"=",
"configs",
"[",
"configname",
"]",
"self",
".",
"WriteList",
"(",
"config",
".",
"get",
"(",
"'defines'",
")",
",",
"'DEFS_%s'",
"%",
"configname",
",",
"prefix",
"=",
"'-D'",
",",
"quoter",
"=",
"EscapeCppDefine",
")",
"if",
"self",
".",
"flavor",
"==",
"'mac'",
":",
"cflags",
"=",
"self",
".",
"xcode_settings",
".",
"GetCflags",
"(",
"configname",
")",
"cflags_c",
"=",
"self",
".",
"xcode_settings",
".",
"GetCflagsC",
"(",
"configname",
")",
"cflags_cc",
"=",
"self",
".",
"xcode_settings",
".",
"GetCflagsCC",
"(",
"configname",
")",
"cflags_objc",
"=",
"self",
".",
"xcode_settings",
".",
"GetCflagsObjC",
"(",
"configname",
")",
"cflags_objcc",
"=",
"self",
".",
"xcode_settings",
".",
"GetCflagsObjCC",
"(",
"configname",
")",
"else",
":",
"cflags",
"=",
"config",
".",
"get",
"(",
"'cflags'",
")",
"cflags_c",
"=",
"config",
".",
"get",
"(",
"'cflags_c'",
")",
"cflags_cc",
"=",
"config",
".",
"get",
"(",
"'cflags_cc'",
")",
"self",
".",
"WriteLn",
"(",
"\"# Flags passed to all source files.\"",
")",
"self",
".",
"WriteList",
"(",
"cflags",
",",
"'CFLAGS_%s'",
"%",
"configname",
")",
"self",
".",
"WriteLn",
"(",
"\"# Flags passed to only C files.\"",
")",
"self",
".",
"WriteList",
"(",
"cflags_c",
",",
"'CFLAGS_C_%s'",
"%",
"configname",
")",
"self",
".",
"WriteLn",
"(",
"\"# Flags passed to only C++ files.\"",
")",
"self",
".",
"WriteList",
"(",
"cflags_cc",
",",
"'CFLAGS_CC_%s'",
"%",
"configname",
")",
"if",
"self",
".",
"flavor",
"==",
"'mac'",
":",
"self",
".",
"WriteLn",
"(",
"\"# Flags passed to only ObjC files.\"",
")",
"self",
".",
"WriteList",
"(",
"cflags_objc",
",",
"'CFLAGS_OBJC_%s'",
"%",
"configname",
")",
"self",
".",
"WriteLn",
"(",
"\"# Flags passed to only ObjC++ files.\"",
")",
"self",
".",
"WriteList",
"(",
"cflags_objcc",
",",
"'CFLAGS_OBJCC_%s'",
"%",
"configname",
")",
"includes",
"=",
"config",
".",
"get",
"(",
"'include_dirs'",
")",
"if",
"includes",
":",
"includes",
"=",
"map",
"(",
"Sourceify",
",",
"map",
"(",
"self",
".",
"Absolutify",
",",
"includes",
")",
")",
"self",
".",
"WriteList",
"(",
"includes",
",",
"'INCS_%s'",
"%",
"configname",
",",
"prefix",
"=",
"'-I'",
")",
"compilable",
"=",
"filter",
"(",
"Compilable",
",",
"sources",
")",
"objs",
"=",
"map",
"(",
"self",
".",
"Objectify",
",",
"map",
"(",
"self",
".",
"Absolutify",
",",
"map",
"(",
"Target",
",",
"compilable",
")",
")",
")",
"self",
".",
"WriteList",
"(",
"objs",
",",
"'OBJS'",
")",
"for",
"obj",
"in",
"objs",
":",
"assert",
"' '",
"not",
"in",
"obj",
",",
"(",
"\"Spaces in object filenames not supported (%s)\"",
"%",
"obj",
")",
"self",
".",
"WriteLn",
"(",
"'# Add to the list of files we specially track '",
"'dependencies for.'",
")",
"self",
".",
"WriteLn",
"(",
"'all_deps += $(OBJS)'",
")",
"self",
".",
"WriteLn",
"(",
")",
"# Make sure our dependencies are built first.",
"if",
"deps",
":",
"self",
".",
"WriteMakeRule",
"(",
"[",
"'$(OBJS)'",
"]",
",",
"deps",
",",
"comment",
"=",
"'Make sure our dependencies are built '",
"'before any of us.'",
",",
"order_only",
"=",
"True",
")",
"# Make sure the actions and rules run first.",
"# If they generate any extra headers etc., the per-.o file dep tracking",
"# will catch the proper rebuilds, so order only is still ok here.",
"if",
"extra_outputs",
":",
"self",
".",
"WriteMakeRule",
"(",
"[",
"'$(OBJS)'",
"]",
",",
"extra_outputs",
",",
"comment",
"=",
"'Make sure our actions/rules run '",
"'before any of us.'",
",",
"order_only",
"=",
"True",
")",
"pchdeps",
"=",
"precompiled_header",
".",
"GetObjDependencies",
"(",
"compilable",
",",
"objs",
")",
"if",
"pchdeps",
":",
"self",
".",
"WriteLn",
"(",
"'# Dependencies from obj files to their precompiled headers'",
")",
"for",
"source",
",",
"obj",
",",
"gch",
"in",
"pchdeps",
":",
"self",
".",
"WriteLn",
"(",
"'%s: %s'",
"%",
"(",
"obj",
",",
"gch",
")",
")",
"self",
".",
"WriteLn",
"(",
"'# End precompiled header dependencies'",
")",
"if",
"objs",
":",
"extra_link_deps",
".",
"append",
"(",
"'$(OBJS)'",
")",
"self",
".",
"WriteLn",
"(",
"\"\"\"\\\n# CFLAGS et al overrides must be target-local.\n# See \"Target-specific Variable Values\" in the GNU Make manual.\"\"\"",
")",
"self",
".",
"WriteLn",
"(",
"\"$(OBJS): TOOLSET := $(TOOLSET)\"",
")",
"self",
".",
"WriteLn",
"(",
"\"$(OBJS): GYP_CFLAGS := \"",
"\"$(DEFS_$(BUILDTYPE)) \"",
"\"$(INCS_$(BUILDTYPE)) \"",
"\"%s \"",
"%",
"precompiled_header",
".",
"GetInclude",
"(",
"'c'",
")",
"+",
"\"$(CFLAGS_$(BUILDTYPE)) \"",
"\"$(CFLAGS_C_$(BUILDTYPE))\"",
")",
"self",
".",
"WriteLn",
"(",
"\"$(OBJS): GYP_CXXFLAGS := \"",
"\"$(DEFS_$(BUILDTYPE)) \"",
"\"$(INCS_$(BUILDTYPE)) \"",
"\"%s \"",
"%",
"precompiled_header",
".",
"GetInclude",
"(",
"'cc'",
")",
"+",
"\"$(CFLAGS_$(BUILDTYPE)) \"",
"\"$(CFLAGS_CC_$(BUILDTYPE))\"",
")",
"if",
"self",
".",
"flavor",
"==",
"'mac'",
":",
"self",
".",
"WriteLn",
"(",
"\"$(OBJS): GYP_OBJCFLAGS := \"",
"\"$(DEFS_$(BUILDTYPE)) \"",
"\"$(INCS_$(BUILDTYPE)) \"",
"\"%s \"",
"%",
"precompiled_header",
".",
"GetInclude",
"(",
"'m'",
")",
"+",
"\"$(CFLAGS_$(BUILDTYPE)) \"",
"\"$(CFLAGS_C_$(BUILDTYPE)) \"",
"\"$(CFLAGS_OBJC_$(BUILDTYPE))\"",
")",
"self",
".",
"WriteLn",
"(",
"\"$(OBJS): GYP_OBJCXXFLAGS := \"",
"\"$(DEFS_$(BUILDTYPE)) \"",
"\"$(INCS_$(BUILDTYPE)) \"",
"\"%s \"",
"%",
"precompiled_header",
".",
"GetInclude",
"(",
"'mm'",
")",
"+",
"\"$(CFLAGS_$(BUILDTYPE)) \"",
"\"$(CFLAGS_CC_$(BUILDTYPE)) \"",
"\"$(CFLAGS_OBJCC_$(BUILDTYPE))\"",
")",
"self",
".",
"WritePchTargets",
"(",
"precompiled_header",
".",
"GetPchBuildCommands",
"(",
")",
")",
"# If there are any object files in our input file list, link them into our",
"# output.",
"extra_link_deps",
"+=",
"filter",
"(",
"Linkable",
",",
"sources",
")",
"self",
".",
"WriteLn",
"(",
")"
] |
https://github.com/alibaba/weex_js_engine/blob/2bdf4b6f020c1fc99c63f649718f6faf7e27fdde/jni/v8core/v8/build/gyp/pylib/gyp/generator/make.py#L1129-L1251
|
||
FreeCAD/FreeCAD
|
ba42231b9c6889b89e064d6d563448ed81e376ec
|
src/Mod/Fem/ObjectsFem.py
|
python
|
makeConstraintPulley
|
(
doc,
name="ConstraintPulley"
)
|
return obj
|
makeConstraintPulley(document, [name]):
makes a Fem ConstraintPulley object
|
makeConstraintPulley(document, [name]):
makes a Fem ConstraintPulley object
|
[
"makeConstraintPulley",
"(",
"document",
"[",
"name",
"]",
")",
":",
"makes",
"a",
"Fem",
"ConstraintPulley",
"object"
] |
def makeConstraintPulley(
doc,
name="ConstraintPulley"
):
"""makeConstraintPulley(document, [name]):
makes a Fem ConstraintPulley object"""
obj = doc.addObject("Fem::ConstraintPulley", name)
return obj
|
[
"def",
"makeConstraintPulley",
"(",
"doc",
",",
"name",
"=",
"\"ConstraintPulley\"",
")",
":",
"obj",
"=",
"doc",
".",
"addObject",
"(",
"\"Fem::ConstraintPulley\"",
",",
"name",
")",
"return",
"obj"
] |
https://github.com/FreeCAD/FreeCAD/blob/ba42231b9c6889b89e064d6d563448ed81e376ec/src/Mod/Fem/ObjectsFem.py#L261-L268
|
|
catboost/catboost
|
167f64f237114a4d10b2b4ee42adb4569137debe
|
contrib/tools/python3/src/Lib/uuid.py
|
python
|
_random_getnode
|
()
|
return random.getrandbits(48) | (1 << 40)
|
Get a random node ID.
|
Get a random node ID.
|
[
"Get",
"a",
"random",
"node",
"ID",
"."
] |
def _random_getnode():
"""Get a random node ID."""
# RFC 4122, $4.1.6 says "For systems with no IEEE address, a randomly or
# pseudo-randomly generated value may be used; see Section 4.5. The
# multicast bit must be set in such addresses, in order that they will
# never conflict with addresses obtained from network cards."
#
# The "multicast bit" of a MAC address is defined to be "the least
# significant bit of the first octet". This works out to be the 41st bit
# counting from 1 being the least significant bit, or 1<<40.
#
# See https://en.wikipedia.org/wiki/MAC_address#Unicast_vs._multicast
import random
return random.getrandbits(48) | (1 << 40)
|
[
"def",
"_random_getnode",
"(",
")",
":",
"# RFC 4122, $4.1.6 says \"For systems with no IEEE address, a randomly or",
"# pseudo-randomly generated value may be used; see Section 4.5. The",
"# multicast bit must be set in such addresses, in order that they will",
"# never conflict with addresses obtained from network cards.\"",
"#",
"# The \"multicast bit\" of a MAC address is defined to be \"the least",
"# significant bit of the first octet\". This works out to be the 41st bit",
"# counting from 1 being the least significant bit, or 1<<40.",
"#",
"# See https://en.wikipedia.org/wiki/MAC_address#Unicast_vs._multicast",
"import",
"random",
"return",
"random",
".",
"getrandbits",
"(",
"48",
")",
"|",
"(",
"1",
"<<",
"40",
")"
] |
https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/tools/python3/src/Lib/uuid.py#L599-L612
|
|
hanpfei/chromium-net
|
392cc1fa3a8f92f42e4071ab6e674d8e0482f83f
|
third_party/catapult/dashboard/dashboard/report.py
|
python
|
_CreatePageState
|
(masters, bots, tests, checked)
|
return {
'charts': chart_states
}
|
Creates a page state dictionary for old URI parameters.
Based on original /report page, each combination of masters, bots, and
tests is a chart; therefor we create a list of chart states for those
combinations.
Args:
masters: A string with comma separated list of masters.
bots: A string with comma separated list of bots.
tests: A string with comma separated list of tests.
checked: A string with comma separated list of checked series.
Returns:
Page state dictionary.
|
Creates a page state dictionary for old URI parameters.
|
[
"Creates",
"a",
"page",
"state",
"dictionary",
"for",
"old",
"URI",
"parameters",
"."
] |
def _CreatePageState(masters, bots, tests, checked):
"""Creates a page state dictionary for old URI parameters.
Based on original /report page, each combination of masters, bots, and
tests is a chart; therefor we create a list of chart states for those
combinations.
Args:
masters: A string with comma separated list of masters.
bots: A string with comma separated list of bots.
tests: A string with comma separated list of tests.
checked: A string with comma separated list of checked series.
Returns:
Page state dictionary.
"""
selected_series = []
if checked:
if checked == 'all':
selected_series = ['all']
else:
selected_series = checked.split(',')
masters = masters.split(',')
bots = bots.split(',')
tests = tests.split(',')
test_paths = []
for master in masters:
for bot in bots:
for test in tests:
test_parts = test.split('/')
if len(test_parts) == 1:
first_test_parts = _GetFirstTest(test, master + '/' + bot)
if first_test_parts:
test += '/' + '/'.join(first_test_parts)
if not selected_series:
selected_series.append(first_test_parts[-1])
test_paths.append(master + '/' + bot + '/' + test)
chart_states = []
for path in test_paths:
chart_states.append([[path, selected_series]])
return {
'charts': chart_states
}
|
[
"def",
"_CreatePageState",
"(",
"masters",
",",
"bots",
",",
"tests",
",",
"checked",
")",
":",
"selected_series",
"=",
"[",
"]",
"if",
"checked",
":",
"if",
"checked",
"==",
"'all'",
":",
"selected_series",
"=",
"[",
"'all'",
"]",
"else",
":",
"selected_series",
"=",
"checked",
".",
"split",
"(",
"','",
")",
"masters",
"=",
"masters",
".",
"split",
"(",
"','",
")",
"bots",
"=",
"bots",
".",
"split",
"(",
"','",
")",
"tests",
"=",
"tests",
".",
"split",
"(",
"','",
")",
"test_paths",
"=",
"[",
"]",
"for",
"master",
"in",
"masters",
":",
"for",
"bot",
"in",
"bots",
":",
"for",
"test",
"in",
"tests",
":",
"test_parts",
"=",
"test",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"test_parts",
")",
"==",
"1",
":",
"first_test_parts",
"=",
"_GetFirstTest",
"(",
"test",
",",
"master",
"+",
"'/'",
"+",
"bot",
")",
"if",
"first_test_parts",
":",
"test",
"+=",
"'/'",
"+",
"'/'",
".",
"join",
"(",
"first_test_parts",
")",
"if",
"not",
"selected_series",
":",
"selected_series",
".",
"append",
"(",
"first_test_parts",
"[",
"-",
"1",
"]",
")",
"test_paths",
".",
"append",
"(",
"master",
"+",
"'/'",
"+",
"bot",
"+",
"'/'",
"+",
"test",
")",
"chart_states",
"=",
"[",
"]",
"for",
"path",
"in",
"test_paths",
":",
"chart_states",
".",
"append",
"(",
"[",
"[",
"path",
",",
"selected_series",
"]",
"]",
")",
"return",
"{",
"'charts'",
":",
"chart_states",
"}"
] |
https://github.com/hanpfei/chromium-net/blob/392cc1fa3a8f92f42e4071ab6e674d8e0482f83f/third_party/catapult/dashboard/dashboard/report.py#L83-L128
|
|
thalium/icebox
|
99d147d5b9269222225443ce171b4fd46d8985d4
|
third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2class.py
|
python
|
lineNumbersDefault
|
(val)
|
return ret
|
Set and return the previous value for enabling line numbers
in elements contents. This may break on old application and
is turned off by default.
|
Set and return the previous value for enabling line numbers
in elements contents. This may break on old application and
is turned off by default.
|
[
"Set",
"and",
"return",
"the",
"previous",
"value",
"for",
"enabling",
"line",
"numbers",
"in",
"elements",
"contents",
".",
"This",
"may",
"break",
"on",
"old",
"application",
"and",
"is",
"turned",
"off",
"by",
"default",
"."
] |
def lineNumbersDefault(val):
"""Set and return the previous value for enabling line numbers
in elements contents. This may break on old application and
is turned off by default. """
ret = libxml2mod.xmlLineNumbersDefault(val)
return ret
|
[
"def",
"lineNumbersDefault",
"(",
"val",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlLineNumbersDefault",
"(",
"val",
")",
"return",
"ret"
] |
https://github.com/thalium/icebox/blob/99d147d5b9269222225443ce171b4fd46d8985d4/third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2class.py#L517-L522
|
|
apple/swift-lldb
|
d74be846ef3e62de946df343e8c234bde93a8912
|
scripts/Python/static-binding/lldb.py
|
python
|
SBDebugger.StateIsStoppedState
|
(state)
|
return _lldb.SBDebugger_StateIsStoppedState(state)
|
StateIsStoppedState(lldb::StateType state) -> bool
|
StateIsStoppedState(lldb::StateType state) -> bool
|
[
"StateIsStoppedState",
"(",
"lldb",
"::",
"StateType",
"state",
")",
"-",
">",
"bool"
] |
def StateIsStoppedState(state):
"""StateIsStoppedState(lldb::StateType state) -> bool"""
return _lldb.SBDebugger_StateIsStoppedState(state)
|
[
"def",
"StateIsStoppedState",
"(",
"state",
")",
":",
"return",
"_lldb",
".",
"SBDebugger_StateIsStoppedState",
"(",
"state",
")"
] |
https://github.com/apple/swift-lldb/blob/d74be846ef3e62de946df343e8c234bde93a8912/scripts/Python/static-binding/lldb.py#L4125-L4127
|
|
danxuhk/ContinuousCRF-CNN
|
2b6dcaf179620f118b225ed12c890414ca828e21
|
scripts/cpp_lint.py
|
python
|
ProcessLine
|
(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error,
extra_check_functions=[])
|
Processes a single line in the file.
Args:
filename: Filename of the file that is being processed.
file_extension: The extension (dot not included) of the file.
clean_lines: An array of strings, each representing a line of the file,
with comments stripped.
line: Number of line being processed.
include_state: An _IncludeState instance in which the headers are inserted.
function_state: A _FunctionState instance which counts function lines, etc.
nesting_state: A _NestingState instance which maintains information about
the current stack of nested blocks being parsed.
error: A callable to which errors are reported, which takes 4 arguments:
filename, line number, error level, and message
extra_check_functions: An array of additional check functions that will be
run on each source line. Each function takes 4
arguments: filename, clean_lines, line, error
|
Processes a single line in the file.
|
[
"Processes",
"a",
"single",
"line",
"in",
"the",
"file",
"."
] |
def ProcessLine(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error,
extra_check_functions=[]):
"""Processes a single line in the file.
Args:
filename: Filename of the file that is being processed.
file_extension: The extension (dot not included) of the file.
clean_lines: An array of strings, each representing a line of the file,
with comments stripped.
line: Number of line being processed.
include_state: An _IncludeState instance in which the headers are inserted.
function_state: A _FunctionState instance which counts function lines, etc.
nesting_state: A _NestingState instance which maintains information about
the current stack of nested blocks being parsed.
error: A callable to which errors are reported, which takes 4 arguments:
filename, line number, error level, and message
extra_check_functions: An array of additional check functions that will be
run on each source line. Each function takes 4
arguments: filename, clean_lines, line, error
"""
raw_lines = clean_lines.raw_lines
ParseNolintSuppressions(filename, raw_lines[line], line, error)
nesting_state.Update(filename, clean_lines, line, error)
if nesting_state.stack and nesting_state.stack[-1].inline_asm != _NO_ASM:
return
CheckForFunctionLengths(filename, clean_lines, line, function_state, error)
CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error)
CheckStyle(filename, clean_lines, line, file_extension, nesting_state, error)
CheckLanguage(filename, clean_lines, line, file_extension, include_state,
nesting_state, error)
CheckForNonConstReference(filename, clean_lines, line, nesting_state, error)
CheckForNonStandardConstructs(filename, clean_lines, line,
nesting_state, error)
CheckVlogArguments(filename, clean_lines, line, error)
CheckCaffeAlternatives(filename, clean_lines, line, error)
CheckCaffeDataLayerSetUp(filename, clean_lines, line, error)
CheckCaffeRandom(filename, clean_lines, line, error)
CheckPosixThreading(filename, clean_lines, line, error)
CheckInvalidIncrement(filename, clean_lines, line, error)
CheckMakePairUsesDeduction(filename, clean_lines, line, error)
for check_fn in extra_check_functions:
check_fn(filename, clean_lines, line, error)
|
[
"def",
"ProcessLine",
"(",
"filename",
",",
"file_extension",
",",
"clean_lines",
",",
"line",
",",
"include_state",
",",
"function_state",
",",
"nesting_state",
",",
"error",
",",
"extra_check_functions",
"=",
"[",
"]",
")",
":",
"raw_lines",
"=",
"clean_lines",
".",
"raw_lines",
"ParseNolintSuppressions",
"(",
"filename",
",",
"raw_lines",
"[",
"line",
"]",
",",
"line",
",",
"error",
")",
"nesting_state",
".",
"Update",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"if",
"nesting_state",
".",
"stack",
"and",
"nesting_state",
".",
"stack",
"[",
"-",
"1",
"]",
".",
"inline_asm",
"!=",
"_NO_ASM",
":",
"return",
"CheckForFunctionLengths",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"function_state",
",",
"error",
")",
"CheckForMultilineCommentsAndStrings",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckStyle",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"file_extension",
",",
"nesting_state",
",",
"error",
")",
"CheckLanguage",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"file_extension",
",",
"include_state",
",",
"nesting_state",
",",
"error",
")",
"CheckForNonConstReference",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"nesting_state",
",",
"error",
")",
"CheckForNonStandardConstructs",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"nesting_state",
",",
"error",
")",
"CheckVlogArguments",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckCaffeAlternatives",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckCaffeDataLayerSetUp",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckCaffeRandom",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckPosixThreading",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckInvalidIncrement",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"CheckMakePairUsesDeduction",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")",
"for",
"check_fn",
"in",
"extra_check_functions",
":",
"check_fn",
"(",
"filename",
",",
"clean_lines",
",",
"line",
",",
"error",
")"
] |
https://github.com/danxuhk/ContinuousCRF-CNN/blob/2b6dcaf179620f118b225ed12c890414ca828e21/scripts/cpp_lint.py#L4604-L4646
|
||
thalium/icebox
|
99d147d5b9269222225443ce171b4fd46d8985d4
|
third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2.py
|
python
|
xmlDoc.saveFormatFile
|
(self, filename, format)
|
return ret
|
Dump an XML document to a file. Will use compression if
compiled in and enabled. If @filename is "-" the stdout
file is used. If @format is set then the document will be
indented on output. Note that @format = 1 provide node
indenting only if xmlIndentTreeOutput = 1 or
xmlKeepBlanksDefault(0) was called
|
Dump an XML document to a file. Will use compression if
compiled in and enabled. If
|
[
"Dump",
"an",
"XML",
"document",
"to",
"a",
"file",
".",
"Will",
"use",
"compression",
"if",
"compiled",
"in",
"and",
"enabled",
".",
"If"
] |
def saveFormatFile(self, filename, format):
"""Dump an XML document to a file. Will use compression if
compiled in and enabled. If @filename is "-" the stdout
file is used. If @format is set then the document will be
indented on output. Note that @format = 1 provide node
indenting only if xmlIndentTreeOutput = 1 or
xmlKeepBlanksDefault(0) was called """
ret = libxml2mod.xmlSaveFormatFile(filename, self._o, format)
return ret
|
[
"def",
"saveFormatFile",
"(",
"self",
",",
"filename",
",",
"format",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlSaveFormatFile",
"(",
"filename",
",",
"self",
".",
"_o",
",",
"format",
")",
"return",
"ret"
] |
https://github.com/thalium/icebox/blob/99d147d5b9269222225443ce171b4fd46d8985d4/third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2.py#L4499-L4507
|
|
weolar/miniblink49
|
1c4678db0594a4abde23d3ebbcc7cd13c3170777
|
third_party/jinja2/environment.py
|
python
|
Environment.make_globals
|
(self, d)
|
return dict(self.globals, **d)
|
Return a dict for the globals.
|
Return a dict for the globals.
|
[
"Return",
"a",
"dict",
"for",
"the",
"globals",
"."
] |
def make_globals(self, d):
"""Return a dict for the globals."""
if not d:
return self.globals
return dict(self.globals, **d)
|
[
"def",
"make_globals",
"(",
"self",
",",
"d",
")",
":",
"if",
"not",
"d",
":",
"return",
"self",
".",
"globals",
"return",
"dict",
"(",
"self",
".",
"globals",
",",
"*",
"*",
"d",
")"
] |
https://github.com/weolar/miniblink49/blob/1c4678db0594a4abde23d3ebbcc7cd13c3170777/third_party/jinja2/environment.py#L843-L847
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/msw/stc.py
|
python
|
StyledTextCtrl.ChangeLexerState
|
(*args, **kwargs)
|
return _stc.StyledTextCtrl_ChangeLexerState(*args, **kwargs)
|
ChangeLexerState(self, int start, int end) -> int
|
ChangeLexerState(self, int start, int end) -> int
|
[
"ChangeLexerState",
"(",
"self",
"int",
"start",
"int",
"end",
")",
"-",
">",
"int"
] |
def ChangeLexerState(*args, **kwargs):
"""ChangeLexerState(self, int start, int end) -> int"""
return _stc.StyledTextCtrl_ChangeLexerState(*args, **kwargs)
|
[
"def",
"ChangeLexerState",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_stc",
".",
"StyledTextCtrl_ChangeLexerState",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/msw/stc.py#L6333-L6335
|
|
echronos/echronos
|
c996f1d2c8af6c6536205eb319c1bf1d4d84569c
|
external_tools/ply_info/example/BASIC/basparse.py
|
python
|
p_command_for_bad_final
|
(p)
|
command : FOR ID EQUALS expr TO error optstep
|
command : FOR ID EQUALS expr TO error optstep
|
[
"command",
":",
"FOR",
"ID",
"EQUALS",
"expr",
"TO",
"error",
"optstep"
] |
def p_command_for_bad_final(p):
'''command : FOR ID EQUALS expr TO error optstep'''
p[0] = "BAD FINAL VALUE IN FOR STATEMENT"
|
[
"def",
"p_command_for_bad_final",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"\"BAD FINAL VALUE IN FOR STATEMENT\""
] |
https://github.com/echronos/echronos/blob/c996f1d2c8af6c6536205eb319c1bf1d4d84569c/external_tools/ply_info/example/BASIC/basparse.py#L172-L174
|
||
LiquidPlayer/LiquidCore
|
9405979363f2353ac9a71ad8ab59685dd7f919c9
|
deps/node-10.15.3/tools/cpplint.py
|
python
|
CloseExpression
|
(clean_lines, linenum, pos)
|
return (line, clean_lines.NumLines(), -1)
|
If input points to ( or { or [ or <, finds the position that closes it.
If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
linenum/pos that correspond to the closing of the expression.
TODO(unknown): cpplint spends a fair bit of time matching parentheses.
Ideally we would want to index all opening and closing parentheses once
and have CloseExpression be just a simple lookup, but due to preprocessor
tricks, this is not so easy.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
pos: A position on the line.
Returns:
A tuple (line, linenum, pos) pointer *past* the closing brace, or
(line, len(lines), -1) if we never find a close. Note we ignore
strings and comments when matching; and the line we return is the
'cleansed' line at linenum.
|
If input points to ( or { or [ or <, finds the position that closes it.
|
[
"If",
"input",
"points",
"to",
"(",
"or",
"{",
"or",
"[",
"or",
"<",
"finds",
"the",
"position",
"that",
"closes",
"it",
"."
] |
def CloseExpression(clean_lines, linenum, pos):
"""If input points to ( or { or [ or <, finds the position that closes it.
If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
linenum/pos that correspond to the closing of the expression.
TODO(unknown): cpplint spends a fair bit of time matching parentheses.
Ideally we would want to index all opening and closing parentheses once
and have CloseExpression be just a simple lookup, but due to preprocessor
tricks, this is not so easy.
Args:
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
pos: A position on the line.
Returns:
A tuple (line, linenum, pos) pointer *past* the closing brace, or
(line, len(lines), -1) if we never find a close. Note we ignore
strings and comments when matching; and the line we return is the
'cleansed' line at linenum.
"""
line = clean_lines.elided[linenum]
if (line[pos] not in '({[<') or Match(r'<[<=]', line[pos:]):
return (line, clean_lines.NumLines(), -1)
# Check first line
(end_pos, stack) = FindEndOfExpressionInLine(line, pos, [])
if end_pos > -1:
return (line, linenum, end_pos)
# Continue scanning forward
while stack and linenum < clean_lines.NumLines() - 1:
linenum += 1
line = clean_lines.elided[linenum]
(end_pos, stack) = FindEndOfExpressionInLine(line, 0, stack)
if end_pos > -1:
return (line, linenum, end_pos)
# Did not find end of expression before end of file, give up
return (line, clean_lines.NumLines(), -1)
|
[
"def",
"CloseExpression",
"(",
"clean_lines",
",",
"linenum",
",",
"pos",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"if",
"(",
"line",
"[",
"pos",
"]",
"not",
"in",
"'({[<'",
")",
"or",
"Match",
"(",
"r'<[<=]'",
",",
"line",
"[",
"pos",
":",
"]",
")",
":",
"return",
"(",
"line",
",",
"clean_lines",
".",
"NumLines",
"(",
")",
",",
"-",
"1",
")",
"# Check first line",
"(",
"end_pos",
",",
"stack",
")",
"=",
"FindEndOfExpressionInLine",
"(",
"line",
",",
"pos",
",",
"[",
"]",
")",
"if",
"end_pos",
">",
"-",
"1",
":",
"return",
"(",
"line",
",",
"linenum",
",",
"end_pos",
")",
"# Continue scanning forward",
"while",
"stack",
"and",
"linenum",
"<",
"clean_lines",
".",
"NumLines",
"(",
")",
"-",
"1",
":",
"linenum",
"+=",
"1",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"(",
"end_pos",
",",
"stack",
")",
"=",
"FindEndOfExpressionInLine",
"(",
"line",
",",
"0",
",",
"stack",
")",
"if",
"end_pos",
">",
"-",
"1",
":",
"return",
"(",
"line",
",",
"linenum",
",",
"end_pos",
")",
"# Did not find end of expression before end of file, give up",
"return",
"(",
"line",
",",
"clean_lines",
".",
"NumLines",
"(",
")",
",",
"-",
"1",
")"
] |
https://github.com/LiquidPlayer/LiquidCore/blob/9405979363f2353ac9a71ad8ab59685dd7f919c9/deps/node-10.15.3/tools/cpplint.py#L1746-L1787
|
|
hpi-xnor/BMXNet-v2
|
af2b1859eafc5c721b1397cef02f946aaf2ce20d
|
python/mxnet/ndarray/ndarray.py
|
python
|
NDArray.shape_array
|
(self, *args, **kwargs)
|
return op.shape_array(self, *args, **kwargs)
|
Convenience fluent method for :py:func:`shape_array`.
The arguments are the same as for :py:func:`shape_array`, with
this array as data.
|
Convenience fluent method for :py:func:`shape_array`.
|
[
"Convenience",
"fluent",
"method",
"for",
":",
"py",
":",
"func",
":",
"shape_array",
"."
] |
def shape_array(self, *args, **kwargs):
"""Convenience fluent method for :py:func:`shape_array`.
The arguments are the same as for :py:func:`shape_array`, with
this array as data.
"""
return op.shape_array(self, *args, **kwargs)
|
[
"def",
"shape_array",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"op",
".",
"shape_array",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/hpi-xnor/BMXNet-v2/blob/af2b1859eafc5c721b1397cef02f946aaf2ce20d/python/mxnet/ndarray/ndarray.py#L1286-L1292
|
|
ricardoquesada/Spidermonkey
|
4a75ea2543408bd1b2c515aa95901523eeef7858
|
media/webrtc/trunk/tools/gyp/pylib/gyp/generator/make.py
|
python
|
Compilable
|
(filename)
|
return False
|
Return true if the file is compilable (should be in OBJS).
|
Return true if the file is compilable (should be in OBJS).
|
[
"Return",
"true",
"if",
"the",
"file",
"is",
"compilable",
"(",
"should",
"be",
"in",
"OBJS",
")",
"."
] |
def Compilable(filename):
"""Return true if the file is compilable (should be in OBJS)."""
for res in (filename.endswith(e) for e in COMPILABLE_EXTENSIONS):
if res:
return True
return False
|
[
"def",
"Compilable",
"(",
"filename",
")",
":",
"for",
"res",
"in",
"(",
"filename",
".",
"endswith",
"(",
"e",
")",
"for",
"e",
"in",
"COMPILABLE_EXTENSIONS",
")",
":",
"if",
"res",
":",
"return",
"True",
"return",
"False"
] |
https://github.com/ricardoquesada/Spidermonkey/blob/4a75ea2543408bd1b2c515aa95901523eeef7858/media/webrtc/trunk/tools/gyp/pylib/gyp/generator/make.py#L554-L559
|
|
mindspore-ai/mindspore
|
fb8fd3338605bb34fa5cea054e535a8b1d753fab
|
mindspore/python/mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py
|
python
|
get_cus_tile_info
|
(input_x1, input_x2, input_x3)
|
return mo_tile_, ko_tile_, no_tile_, core_m_num_, core_n_num_, diag_opt
|
get_cus_tile_info
|
get_cus_tile_info
|
[
"get_cus_tile_info"
] |
def get_cus_tile_info(input_x1, input_x2, input_x3):
"""get_cus_tile_info"""
_, mo, _, _ = input_x1.shape
no, _, _, _ = input_x2.shape
c0 = input_x1.shape[-1]
diag_outer = 128 // c0
input_shape = (tuple(input_x1.shape), input_x1.dtype, tuple(input_x2.shape), input_x2.dtype,
tuple(input_x3.shape), input_x3.dtype)
tile_map = {
# no diag opt:
((8, 32, 16, 16), "float16", (8, 8, 16, 16), "float16", (1,), "float32"): (4, 8, 2, 8, 4),
((4, 4, 16, 16), "float16", (4, 4, 16, 16), "float16", (1,), "float32"): (1, 4, 1, 4, 4),
((4, 16, 16, 16), 'float16', (4, 4, 16, 16), 'float16', (1,), 'float32'): (1, 4, 2, 16, 2),
((49, 4, 16, 16), 'float16', (49, 49, 16, 16), 'float16', (1,), 'float32'): (1, 7, 7, 4, 7),
((36, 4, 16, 16), 'float16', (36, 36, 16, 16), 'float16', (1,), 'float32'): (2, 6, 3, 2, 12),
# diag opt:
((288, 32, 16, 16), 'float16', (288, 288, 16, 16), 'float16', (1,), 'float32'): (16, 8, 8, 2, 12),
}
maxblocknum = 32
diag_opt = False
if input_x2.shape[0] * input_x2.shape[3] > 128 and input_x2.shape[0] % diag_outer == 0:
diag_opt = True
if input_shape in tile_map:
mo_tile_, ko_tile_, no_tile_, core_m_num_, core_n_num_ = tile_map[input_shape]
elif diag_opt:
ko_tile_ = diag_outer
no_tile_ = ko_tile_
core_n_num_ = no // no_tile_
core_m_num_max = maxblocknum // core_n_num_
mo_tile_ = -1
core_m_num_ = -1
for i in range(core_m_num_max, 0, -1):
if mo % i == 0:
core_m_num_ = i
mo_tile_ = mo // i
break
if mo_tile_ == -1:
raise ValueError("no valid tile be found!")
while mo_tile_ > 16:
mo_tile_ = mo_tile_ // 2
else:
raise ValueError("please add tile config to the tile_map")
print("shape: %s, tile: %s" % (input_shape, str((mo_tile_, ko_tile_, no_tile_, core_m_num_, core_n_num_,
diag_opt))))
return mo_tile_, ko_tile_, no_tile_, core_m_num_, core_n_num_, diag_opt
|
[
"def",
"get_cus_tile_info",
"(",
"input_x1",
",",
"input_x2",
",",
"input_x3",
")",
":",
"_",
",",
"mo",
",",
"_",
",",
"_",
"=",
"input_x1",
".",
"shape",
"no",
",",
"_",
",",
"_",
",",
"_",
"=",
"input_x2",
".",
"shape",
"c0",
"=",
"input_x1",
".",
"shape",
"[",
"-",
"1",
"]",
"diag_outer",
"=",
"128",
"//",
"c0",
"input_shape",
"=",
"(",
"tuple",
"(",
"input_x1",
".",
"shape",
")",
",",
"input_x1",
".",
"dtype",
",",
"tuple",
"(",
"input_x2",
".",
"shape",
")",
",",
"input_x2",
".",
"dtype",
",",
"tuple",
"(",
"input_x3",
".",
"shape",
")",
",",
"input_x3",
".",
"dtype",
")",
"tile_map",
"=",
"{",
"# no diag opt:",
"(",
"(",
"8",
",",
"32",
",",
"16",
",",
"16",
")",
",",
"\"float16\"",
",",
"(",
"8",
",",
"8",
",",
"16",
",",
"16",
")",
",",
"\"float16\"",
",",
"(",
"1",
",",
")",
",",
"\"float32\"",
")",
":",
"(",
"4",
",",
"8",
",",
"2",
",",
"8",
",",
"4",
")",
",",
"(",
"(",
"4",
",",
"4",
",",
"16",
",",
"16",
")",
",",
"\"float16\"",
",",
"(",
"4",
",",
"4",
",",
"16",
",",
"16",
")",
",",
"\"float16\"",
",",
"(",
"1",
",",
")",
",",
"\"float32\"",
")",
":",
"(",
"1",
",",
"4",
",",
"1",
",",
"4",
",",
"4",
")",
",",
"(",
"(",
"4",
",",
"16",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"4",
",",
"4",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"1",
",",
")",
",",
"'float32'",
")",
":",
"(",
"1",
",",
"4",
",",
"2",
",",
"16",
",",
"2",
")",
",",
"(",
"(",
"49",
",",
"4",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"49",
",",
"49",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"1",
",",
")",
",",
"'float32'",
")",
":",
"(",
"1",
",",
"7",
",",
"7",
",",
"4",
",",
"7",
")",
",",
"(",
"(",
"36",
",",
"4",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"36",
",",
"36",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"1",
",",
")",
",",
"'float32'",
")",
":",
"(",
"2",
",",
"6",
",",
"3",
",",
"2",
",",
"12",
")",
",",
"# diag opt:",
"(",
"(",
"288",
",",
"32",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"288",
",",
"288",
",",
"16",
",",
"16",
")",
",",
"'float16'",
",",
"(",
"1",
",",
")",
",",
"'float32'",
")",
":",
"(",
"16",
",",
"8",
",",
"8",
",",
"2",
",",
"12",
")",
",",
"}",
"maxblocknum",
"=",
"32",
"diag_opt",
"=",
"False",
"if",
"input_x2",
".",
"shape",
"[",
"0",
"]",
"*",
"input_x2",
".",
"shape",
"[",
"3",
"]",
">",
"128",
"and",
"input_x2",
".",
"shape",
"[",
"0",
"]",
"%",
"diag_outer",
"==",
"0",
":",
"diag_opt",
"=",
"True",
"if",
"input_shape",
"in",
"tile_map",
":",
"mo_tile_",
",",
"ko_tile_",
",",
"no_tile_",
",",
"core_m_num_",
",",
"core_n_num_",
"=",
"tile_map",
"[",
"input_shape",
"]",
"elif",
"diag_opt",
":",
"ko_tile_",
"=",
"diag_outer",
"no_tile_",
"=",
"ko_tile_",
"core_n_num_",
"=",
"no",
"//",
"no_tile_",
"core_m_num_max",
"=",
"maxblocknum",
"//",
"core_n_num_",
"mo_tile_",
"=",
"-",
"1",
"core_m_num_",
"=",
"-",
"1",
"for",
"i",
"in",
"range",
"(",
"core_m_num_max",
",",
"0",
",",
"-",
"1",
")",
":",
"if",
"mo",
"%",
"i",
"==",
"0",
":",
"core_m_num_",
"=",
"i",
"mo_tile_",
"=",
"mo",
"//",
"i",
"break",
"if",
"mo_tile_",
"==",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"no valid tile be found!\"",
")",
"while",
"mo_tile_",
">",
"16",
":",
"mo_tile_",
"=",
"mo_tile_",
"//",
"2",
"else",
":",
"raise",
"ValueError",
"(",
"\"please add tile config to the tile_map\"",
")",
"print",
"(",
"\"shape: %s, tile: %s\"",
"%",
"(",
"input_shape",
",",
"str",
"(",
"(",
"mo_tile_",
",",
"ko_tile_",
",",
"no_tile_",
",",
"core_m_num_",
",",
"core_n_num_",
",",
"diag_opt",
")",
")",
")",
")",
"return",
"mo_tile_",
",",
"ko_tile_",
",",
"no_tile_",
",",
"core_m_num_",
",",
"core_n_num_",
",",
"diag_opt"
] |
https://github.com/mindspore-ai/mindspore/blob/fb8fd3338605bb34fa5cea054e535a8b1d753fab/mindspore/python/mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py#L95-L139
|
|
cms-sw/cmssw
|
fd9de012d503d3405420bcbeec0ec879baa57cf2
|
Validation/RecoB/scripts/cuy.py
|
python
|
nonzero
|
(self)
|
return False
|
True if options were given
|
True if options were given
|
[
"True",
"if",
"options",
"were",
"given"
] |
def nonzero(self): # will become the nonzero method of optparse.Values
"True if options were given"
for v in self.__dict__.values():
if v is not None: return True
return False
|
[
"def",
"nonzero",
"(",
"self",
")",
":",
"# will become the nonzero method of optparse.Values",
"for",
"v",
"in",
"self",
".",
"__dict__",
".",
"values",
"(",
")",
":",
"if",
"v",
"is",
"not",
"None",
":",
"return",
"True",
"return",
"False"
] |
https://github.com/cms-sw/cmssw/blob/fd9de012d503d3405420bcbeec0ec879baa57cf2/Validation/RecoB/scripts/cuy.py#L79-L83
|
|
GoSSIP-SJTU/TripleDoggy
|
03648d6b19c812504b14e8b98c8c7b3f443f4e54
|
tools/clang/docs/tools/dump_ast_matchers.py
|
python
|
unify_arguments
|
(args)
|
return args
|
Gets rid of anything the user doesn't care about in the argument list.
|
Gets rid of anything the user doesn't care about in the argument list.
|
[
"Gets",
"rid",
"of",
"anything",
"the",
"user",
"doesn",
"t",
"care",
"about",
"in",
"the",
"argument",
"list",
"."
] |
def unify_arguments(args):
"""Gets rid of anything the user doesn't care about in the argument list."""
args = re.sub(r'internal::', r'', args)
args = re.sub(r'extern const\s+(.*)&', r'\1 ', args)
args = re.sub(r'&', r' ', args)
args = re.sub(r'(^|\s)M\d?(\s)', r'\1Matcher<*>\2', args)
return args
|
[
"def",
"unify_arguments",
"(",
"args",
")",
":",
"args",
"=",
"re",
".",
"sub",
"(",
"r'internal::'",
",",
"r''",
",",
"args",
")",
"args",
"=",
"re",
".",
"sub",
"(",
"r'extern const\\s+(.*)&'",
",",
"r'\\1 '",
",",
"args",
")",
"args",
"=",
"re",
".",
"sub",
"(",
"r'&'",
",",
"r' '",
",",
"args",
")",
"args",
"=",
"re",
".",
"sub",
"(",
"r'(^|\\s)M\\d?(\\s)'",
",",
"r'\\1Matcher<*>\\2'",
",",
"args",
")",
"return",
"args"
] |
https://github.com/GoSSIP-SJTU/TripleDoggy/blob/03648d6b19c812504b14e8b98c8c7b3f443f4e54/tools/clang/docs/tools/dump_ast_matchers.py#L95-L101
|
|
CalcProgrammer1/OpenRGB
|
8156b0167a7590dd8ba561dfde524bfcacf46b5e
|
dependencies/mbedtls-2.24.0/scripts/config.py
|
python
|
crypto_adapter
|
(adapter)
|
return continuation
|
Modify an adapter to disable non-crypto symbols.
``crypto_adapter(adapter)(name, active, section)`` is like
``adapter(name, active, section)``, but unsets all X.509 and TLS symbols.
|
Modify an adapter to disable non-crypto symbols.
|
[
"Modify",
"an",
"adapter",
"to",
"disable",
"non",
"-",
"crypto",
"symbols",
"."
] |
def crypto_adapter(adapter):
"""Modify an adapter to disable non-crypto symbols.
``crypto_adapter(adapter)(name, active, section)`` is like
``adapter(name, active, section)``, but unsets all X.509 and TLS symbols.
"""
def continuation(name, active, section):
if not include_in_crypto(name):
return False
if adapter is None:
return active
return adapter(name, active, section)
return continuation
|
[
"def",
"crypto_adapter",
"(",
"adapter",
")",
":",
"def",
"continuation",
"(",
"name",
",",
"active",
",",
"section",
")",
":",
"if",
"not",
"include_in_crypto",
"(",
"name",
")",
":",
"return",
"False",
"if",
"adapter",
"is",
"None",
":",
"return",
"active",
"return",
"adapter",
"(",
"name",
",",
"active",
",",
"section",
")",
"return",
"continuation"
] |
https://github.com/CalcProgrammer1/OpenRGB/blob/8156b0167a7590dd8ba561dfde524bfcacf46b5e/dependencies/mbedtls-2.24.0/scripts/config.py#L287-L299
|
|
apple/turicreate
|
cce55aa5311300e3ce6af93cb45ba791fd1bdf49
|
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_format.py
|
python
|
Tokenizer._ConsumeSingleByteString
|
(self)
|
return result
|
Consume one token of a string literal.
String literals (whether bytes or text) can come in multiple adjacent
tokens which are automatically concatenated, like in C or Python. This
method only consumes one token.
Returns:
The token parsed.
Raises:
ParseError: When the wrong format data is found.
|
Consume one token of a string literal.
|
[
"Consume",
"one",
"token",
"of",
"a",
"string",
"literal",
"."
] |
def _ConsumeSingleByteString(self):
"""Consume one token of a string literal.
String literals (whether bytes or text) can come in multiple adjacent
tokens which are automatically concatenated, like in C or Python. This
method only consumes one token.
Returns:
The token parsed.
Raises:
ParseError: When the wrong format data is found.
"""
text = self.token
if len(text) < 1 or text[0] not in _QUOTES:
raise self.ParseError('Expected string but found: %r' % (text,))
if len(text) < 2 or text[-1] != text[0]:
raise self.ParseError('String missing ending quote: %r' % (text,))
try:
result = text_encoding.CUnescape(text[1:-1])
except ValueError as e:
raise self.ParseError(str(e))
self.NextToken()
return result
|
[
"def",
"_ConsumeSingleByteString",
"(",
"self",
")",
":",
"text",
"=",
"self",
".",
"token",
"if",
"len",
"(",
"text",
")",
"<",
"1",
"or",
"text",
"[",
"0",
"]",
"not",
"in",
"_QUOTES",
":",
"raise",
"self",
".",
"ParseError",
"(",
"'Expected string but found: %r'",
"%",
"(",
"text",
",",
")",
")",
"if",
"len",
"(",
"text",
")",
"<",
"2",
"or",
"text",
"[",
"-",
"1",
"]",
"!=",
"text",
"[",
"0",
"]",
":",
"raise",
"self",
".",
"ParseError",
"(",
"'String missing ending quote: %r'",
"%",
"(",
"text",
",",
")",
")",
"try",
":",
"result",
"=",
"text_encoding",
".",
"CUnescape",
"(",
"text",
"[",
"1",
":",
"-",
"1",
"]",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"self",
".",
"ParseError",
"(",
"str",
"(",
"e",
")",
")",
"self",
".",
"NextToken",
"(",
")",
"return",
"result"
] |
https://github.com/apple/turicreate/blob/cce55aa5311300e3ce6af93cb45ba791fd1bdf49/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_format.py#L1196-L1220
|
|
krishauser/Klampt
|
972cc83ea5befac3f653c1ba20f80155768ad519
|
Python/python2_version/klampt/io/loader.py
|
python
|
parseLines
|
(text)
|
return esclines
|
Returns a list of lines from the given text. Understands end-of-line escapes '\\n
|
Returns a list of lines from the given text. Understands end-of-line escapes '\\n
|
[
"Returns",
"a",
"list",
"of",
"lines",
"from",
"the",
"given",
"text",
".",
"Understands",
"end",
"-",
"of",
"-",
"line",
"escapes",
"\\\\",
"n"
] |
def parseLines(text):
"""Returns a list of lines from the given text. Understands end-of-line escapes '\\n'"""
lines = text.strip().split('\n')
esclines = []
esc = False
for l in lines:
if esc:
esclines[-1] = esclines[-1]+l
else:
esclines.append(l)
if len(l)>0 and l[-1]=='\\':
esclines[-1] = esclines[-1][:-1]
esc = True
else:
esc = False
return esclines
|
[
"def",
"parseLines",
"(",
"text",
")",
":",
"lines",
"=",
"text",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"esclines",
"=",
"[",
"]",
"esc",
"=",
"False",
"for",
"l",
"in",
"lines",
":",
"if",
"esc",
":",
"esclines",
"[",
"-",
"1",
"]",
"=",
"esclines",
"[",
"-",
"1",
"]",
"+",
"l",
"else",
":",
"esclines",
".",
"append",
"(",
"l",
")",
"if",
"len",
"(",
"l",
")",
">",
"0",
"and",
"l",
"[",
"-",
"1",
"]",
"==",
"'\\\\'",
":",
"esclines",
"[",
"-",
"1",
"]",
"=",
"esclines",
"[",
"-",
"1",
"]",
"[",
":",
"-",
"1",
"]",
"esc",
"=",
"True",
"else",
":",
"esc",
"=",
"False",
"return",
"esclines"
] |
https://github.com/krishauser/Klampt/blob/972cc83ea5befac3f653c1ba20f80155768ad519/Python/python2_version/klampt/io/loader.py#L437-L452
|
|
Tom94/practical-path-guiding
|
fcf01afb436184e8a74bf300aa89f69b03ab25a2
|
visualizer/nanogui/docs/exhale.py
|
python
|
ExhaleRoot.generateNodeDocuments
|
(self)
|
Creates all of the reStructuredText documents related to types parsed by
Doxygen. This includes all leaf-like documents (``class``, ``struct``,
``enum``, ``typedef``, ``union``, ``variable``, and ``define``), as well as
namespace, file, and directory pages.
During the reparenting phase of the parsing process, nested items were added as
a child to their actual parent. For classes, structs, enums, and unions, if
it was reparented to a ``namespace`` it will *remain* in its respective
``self.<breathe_kind>`` list. However, if it was an internally declared child
of a class or struct (nested classes, structs, enums, and unions), this node
will be removed from its ``self.<breathe_kind>`` list to avoid duplication in
the class hierarchy generation.
When generating the full API, though, we will want to include all of these and
therefore must call :func:`exhale.ExhaleRoot.generateSingleNodeRST` with all of
the nested items. For nested classes and structs, this is done by just calling
``node.findNestedClassLike`` for every node in ``self.class_like``. The
resulting list then has all of ``self.class_like``, as well as any nested
classes and structs found. With ``enum`` and ``union``, these would have been
reparented to a **class** or **struct** if it was removed from the relevant
``self.<breathe_kind>`` list. Meaning we must make sure that we genererate the
single node RST documents for everything by finding the nested enums and unions
from ``self.class_like``, as well as everything in ``self.enums`` and
``self.unions``.
|
Creates all of the reStructuredText documents related to types parsed by
Doxygen. This includes all leaf-like documents (``class``, ``struct``,
``enum``, ``typedef``, ``union``, ``variable``, and ``define``), as well as
namespace, file, and directory pages.
|
[
"Creates",
"all",
"of",
"the",
"reStructuredText",
"documents",
"related",
"to",
"types",
"parsed",
"by",
"Doxygen",
".",
"This",
"includes",
"all",
"leaf",
"-",
"like",
"documents",
"(",
"class",
"struct",
"enum",
"typedef",
"union",
"variable",
"and",
"define",
")",
"as",
"well",
"as",
"namespace",
"file",
"and",
"directory",
"pages",
"."
] |
def generateNodeDocuments(self):
'''
Creates all of the reStructuredText documents related to types parsed by
Doxygen. This includes all leaf-like documents (``class``, ``struct``,
``enum``, ``typedef``, ``union``, ``variable``, and ``define``), as well as
namespace, file, and directory pages.
During the reparenting phase of the parsing process, nested items were added as
a child to their actual parent. For classes, structs, enums, and unions, if
it was reparented to a ``namespace`` it will *remain* in its respective
``self.<breathe_kind>`` list. However, if it was an internally declared child
of a class or struct (nested classes, structs, enums, and unions), this node
will be removed from its ``self.<breathe_kind>`` list to avoid duplication in
the class hierarchy generation.
When generating the full API, though, we will want to include all of these and
therefore must call :func:`exhale.ExhaleRoot.generateSingleNodeRST` with all of
the nested items. For nested classes and structs, this is done by just calling
``node.findNestedClassLike`` for every node in ``self.class_like``. The
resulting list then has all of ``self.class_like``, as well as any nested
classes and structs found. With ``enum`` and ``union``, these would have been
reparented to a **class** or **struct** if it was removed from the relevant
``self.<breathe_kind>`` list. Meaning we must make sure that we genererate the
single node RST documents for everything by finding the nested enums and unions
from ``self.class_like``, as well as everything in ``self.enums`` and
``self.unions``.
'''
# initialize all of the nodes
for node in self.all_nodes:
self.initializeNodeFilenameAndLink(node)
# find the potentially nested items that were reparented
nested_enums = []
nested_unions = []
nested_class_like = []
for cl in self.class_like:
cl.findNestedEnums(nested_enums)
cl.findNestedUnions(nested_unions)
cl.findNestedClassLike(nested_class_like)
# generate all of the leaf-like documents
for node in itertools.chain(nested_class_like, self.enums, nested_enums,
self.unions, nested_unions, self.functions,
self.typedefs, self.variables, self.defines):
self.generateSingleNodeRST(node)
# generate the remaining parent-like documents
self.generateNamespaceNodeDocuments()
self.generateFileNodeDocuments()
self.generateDirectoryNodeDocuments()
|
[
"def",
"generateNodeDocuments",
"(",
"self",
")",
":",
"# initialize all of the nodes",
"for",
"node",
"in",
"self",
".",
"all_nodes",
":",
"self",
".",
"initializeNodeFilenameAndLink",
"(",
"node",
")",
"# find the potentially nested items that were reparented",
"nested_enums",
"=",
"[",
"]",
"nested_unions",
"=",
"[",
"]",
"nested_class_like",
"=",
"[",
"]",
"for",
"cl",
"in",
"self",
".",
"class_like",
":",
"cl",
".",
"findNestedEnums",
"(",
"nested_enums",
")",
"cl",
".",
"findNestedUnions",
"(",
"nested_unions",
")",
"cl",
".",
"findNestedClassLike",
"(",
"nested_class_like",
")",
"# generate all of the leaf-like documents",
"for",
"node",
"in",
"itertools",
".",
"chain",
"(",
"nested_class_like",
",",
"self",
".",
"enums",
",",
"nested_enums",
",",
"self",
".",
"unions",
",",
"nested_unions",
",",
"self",
".",
"functions",
",",
"self",
".",
"typedefs",
",",
"self",
".",
"variables",
",",
"self",
".",
"defines",
")",
":",
"self",
".",
"generateSingleNodeRST",
"(",
"node",
")",
"# generate the remaining parent-like documents",
"self",
".",
"generateNamespaceNodeDocuments",
"(",
")",
"self",
".",
"generateFileNodeDocuments",
"(",
")",
"self",
".",
"generateDirectoryNodeDocuments",
"(",
")"
] |
https://github.com/Tom94/practical-path-guiding/blob/fcf01afb436184e8a74bf300aa89f69b03ab25a2/visualizer/nanogui/docs/exhale.py#L2049-L2098
|
||
wlanjie/AndroidFFmpeg
|
7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf
|
tools/fdk-aac-build/armeabi-v7a/toolchain/lib/python2.7/pydoc.py
|
python
|
TextDoc.docother
|
(self, object, name=None, mod=None, parent=None, maxlen=None, doc=None)
|
return line
|
Produce text documentation for a data object.
|
Produce text documentation for a data object.
|
[
"Produce",
"text",
"documentation",
"for",
"a",
"data",
"object",
"."
] |
def docother(self, object, name=None, mod=None, parent=None, maxlen=None, doc=None):
"""Produce text documentation for a data object."""
repr = self.repr(object)
if maxlen:
line = (name and name + ' = ' or '') + repr
chop = maxlen - len(line)
if chop < 0: repr = repr[:chop] + '...'
line = (name and self.bold(name) + ' = ' or '') + repr
if doc is not None:
line += '\n' + self.indent(str(doc))
return line
|
[
"def",
"docother",
"(",
"self",
",",
"object",
",",
"name",
"=",
"None",
",",
"mod",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"maxlen",
"=",
"None",
",",
"doc",
"=",
"None",
")",
":",
"repr",
"=",
"self",
".",
"repr",
"(",
"object",
")",
"if",
"maxlen",
":",
"line",
"=",
"(",
"name",
"and",
"name",
"+",
"' = '",
"or",
"''",
")",
"+",
"repr",
"chop",
"=",
"maxlen",
"-",
"len",
"(",
"line",
")",
"if",
"chop",
"<",
"0",
":",
"repr",
"=",
"repr",
"[",
":",
"chop",
"]",
"+",
"'...'",
"line",
"=",
"(",
"name",
"and",
"self",
".",
"bold",
"(",
"name",
")",
"+",
"' = '",
"or",
"''",
")",
"+",
"repr",
"if",
"doc",
"is",
"not",
"None",
":",
"line",
"+=",
"'\\n'",
"+",
"self",
".",
"indent",
"(",
"str",
"(",
"doc",
")",
")",
"return",
"line"
] |
https://github.com/wlanjie/AndroidFFmpeg/blob/7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf/tools/fdk-aac-build/armeabi-v7a/toolchain/lib/python2.7/pydoc.py#L1319-L1329
|
|
Netflix/NfWebCrypto
|
499faf4eb9f9ccf0b21dc728e974970f54bd6c52
|
plugin/ppapi/ppapi/generators/idl_parser.py
|
python
|
IDLParser.p_dictionary_block
|
(self, p)
|
dictionary_block : modifiers DICTIONARY SYMBOL '{' struct_list '}' ';
|
dictionary_block : modifiers DICTIONARY SYMBOL '{' struct_list '}' ';
|
[
"dictionary_block",
":",
"modifiers",
"DICTIONARY",
"SYMBOL",
"{",
"struct_list",
"}",
";"
] |
def p_dictionary_block(self, p):
"""dictionary_block : modifiers DICTIONARY SYMBOL '{' struct_list '}' ';'"""
p[0] = self.BuildNamed('Dictionary', p, 3, ListFromConcat(p[1], p[5]))
|
[
"def",
"p_dictionary_block",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"BuildNamed",
"(",
"'Dictionary'",
",",
"p",
",",
"3",
",",
"ListFromConcat",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"5",
"]",
")",
")"
] |
https://github.com/Netflix/NfWebCrypto/blob/499faf4eb9f9ccf0b21dc728e974970f54bd6c52/plugin/ppapi/ppapi/generators/idl_parser.py#L310-L312
|
||
Xilinx/Vitis-AI
|
fc74d404563d9951b57245443c73bef389f3657f
|
tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/distribute/distribute_coordinator.py
|
python
|
_run_single_worker
|
(worker_fn,
strategy,
cluster_spec,
task_type,
task_id,
session_config,
rpc_layer="",
worker_barrier=None,
coord=None)
|
Runs a single worker by calling `worker_fn` under context.
|
Runs a single worker by calling `worker_fn` under context.
|
[
"Runs",
"a",
"single",
"worker",
"by",
"calling",
"worker_fn",
"under",
"context",
"."
] |
def _run_single_worker(worker_fn,
strategy,
cluster_spec,
task_type,
task_id,
session_config,
rpc_layer="",
worker_barrier=None,
coord=None):
"""Runs a single worker by calling `worker_fn` under context."""
session_config = copy.deepcopy(session_config)
strategy = copy.deepcopy(strategy)
# If there is an EVALUATOR task, we run single-machine eval on that task.
if task_type == _TaskType.EVALUATOR:
# It is possible to not have a strategy object for EVALUATOR task.
if strategy:
strategy.configure(session_config)
else:
assert strategy
strategy.configure(session_config, cluster_spec, task_type, task_id)
context = _WorkerContext(
strategy,
cluster_spec,
task_type,
task_id,
session_config=session_config,
rpc_layer=rpc_layer,
worker_barrier=worker_barrier)
with context:
if coord:
with coord.stop_on_exception():
return worker_fn(strategy)
else:
return worker_fn(strategy)
|
[
"def",
"_run_single_worker",
"(",
"worker_fn",
",",
"strategy",
",",
"cluster_spec",
",",
"task_type",
",",
"task_id",
",",
"session_config",
",",
"rpc_layer",
"=",
"\"\"",
",",
"worker_barrier",
"=",
"None",
",",
"coord",
"=",
"None",
")",
":",
"session_config",
"=",
"copy",
".",
"deepcopy",
"(",
"session_config",
")",
"strategy",
"=",
"copy",
".",
"deepcopy",
"(",
"strategy",
")",
"# If there is an EVALUATOR task, we run single-machine eval on that task.",
"if",
"task_type",
"==",
"_TaskType",
".",
"EVALUATOR",
":",
"# It is possible to not have a strategy object for EVALUATOR task.",
"if",
"strategy",
":",
"strategy",
".",
"configure",
"(",
"session_config",
")",
"else",
":",
"assert",
"strategy",
"strategy",
".",
"configure",
"(",
"session_config",
",",
"cluster_spec",
",",
"task_type",
",",
"task_id",
")",
"context",
"=",
"_WorkerContext",
"(",
"strategy",
",",
"cluster_spec",
",",
"task_type",
",",
"task_id",
",",
"session_config",
"=",
"session_config",
",",
"rpc_layer",
"=",
"rpc_layer",
",",
"worker_barrier",
"=",
"worker_barrier",
")",
"with",
"context",
":",
"if",
"coord",
":",
"with",
"coord",
".",
"stop_on_exception",
"(",
")",
":",
"return",
"worker_fn",
"(",
"strategy",
")",
"else",
":",
"return",
"worker_fn",
"(",
"strategy",
")"
] |
https://github.com/Xilinx/Vitis-AI/blob/fc74d404563d9951b57245443c73bef389f3657f/tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/distribute/distribute_coordinator.py#L326-L360
|
||
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_carbon/richtext.py
|
python
|
RichTextObject.CalculateRange
|
(*args, **kwargs)
|
return _richtext.RichTextObject_CalculateRange(*args, **kwargs)
|
CalculateRange(self, long start, long OUTPUT)
|
CalculateRange(self, long start, long OUTPUT)
|
[
"CalculateRange",
"(",
"self",
"long",
"start",
"long",
"OUTPUT",
")"
] |
def CalculateRange(*args, **kwargs):
"""CalculateRange(self, long start, long OUTPUT)"""
return _richtext.RichTextObject_CalculateRange(*args, **kwargs)
|
[
"def",
"CalculateRange",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_richtext",
".",
"RichTextObject_CalculateRange",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_carbon/richtext.py#L1210-L1212
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_cocoa/html.py
|
python
|
HtmlCell.GetFirstChild
|
(*args, **kwargs)
|
return _html.HtmlCell_GetFirstChild(*args, **kwargs)
|
GetFirstChild(self) -> HtmlCell
|
GetFirstChild(self) -> HtmlCell
|
[
"GetFirstChild",
"(",
"self",
")",
"-",
">",
"HtmlCell"
] |
def GetFirstChild(*args, **kwargs):
"""GetFirstChild(self) -> HtmlCell"""
return _html.HtmlCell_GetFirstChild(*args, **kwargs)
|
[
"def",
"GetFirstChild",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_html",
".",
"HtmlCell_GetFirstChild",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/html.py#L654-L656
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/msw/_core.py
|
python
|
GBSizerItemList.__contains__
|
(*args, **kwargs)
|
return _core_.GBSizerItemList___contains__(*args, **kwargs)
|
__contains__(self, GBSizerItem obj) -> bool
|
__contains__(self, GBSizerItem obj) -> bool
|
[
"__contains__",
"(",
"self",
"GBSizerItem",
"obj",
")",
"-",
">",
"bool"
] |
def __contains__(*args, **kwargs):
"""__contains__(self, GBSizerItem obj) -> bool"""
return _core_.GBSizerItemList___contains__(*args, **kwargs)
|
[
"def",
"__contains__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_core_",
".",
"GBSizerItemList___contains__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/msw/_core.py#L15887-L15889
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
wx/tools/Editra/src/ebmlib/searcheng.py
|
python
|
SearchEngine.SetQuery
|
(self, query)
|
Set the search query
@param query: string
|
Set the search query
@param query: string
|
[
"Set",
"the",
"search",
"query",
"@param",
"query",
":",
"string"
] |
def SetQuery(self, query):
"""Set the search query
@param query: string
"""
self._query = query
self._CompileRegex()
|
[
"def",
"SetQuery",
"(",
"self",
",",
"query",
")",
":",
"self",
".",
"_query",
"=",
"query",
"self",
".",
"_CompileRegex",
"(",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/wx/tools/Editra/src/ebmlib/searcheng.py#L403-L409
|
||
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numpy/lib/utils.py
|
python
|
_Deprecate.__call__
|
(self, func, *args, **kwargs)
|
return newfunc
|
Decorator call. Refer to ``decorate``.
|
Decorator call. Refer to ``decorate``.
|
[
"Decorator",
"call",
".",
"Refer",
"to",
"decorate",
"."
] |
def __call__(self, func, *args, **kwargs):
"""
Decorator call. Refer to ``decorate``.
"""
old_name = self.old_name
new_name = self.new_name
message = self.message
if old_name is None:
try:
old_name = func.__name__
except AttributeError:
old_name = func.__name__
if new_name is None:
depdoc = "`%s` is deprecated!" % old_name
else:
depdoc = "`%s` is deprecated, use `%s` instead!" % \
(old_name, new_name)
if message is not None:
depdoc += "\n" + message
def newfunc(*args,**kwds):
"""`arrayrange` is deprecated, use `arange` instead!"""
warnings.warn(depdoc, DeprecationWarning, stacklevel=2)
return func(*args, **kwds)
newfunc = _set_function_name(newfunc, old_name)
doc = func.__doc__
if doc is None:
doc = depdoc
else:
lines = doc.expandtabs().split('\n')
indent = _get_indent(lines[1:])
if lines[0].lstrip():
# Indent the original first line to let inspect.cleandoc()
# dedent the docstring despite the deprecation notice.
doc = indent * ' ' + doc
else:
# Remove the same leading blank lines as cleandoc() would.
skip = len(lines[0]) + 1
for line in lines[1:]:
if len(line) > indent:
break
skip += len(line) + 1
doc = doc[skip:]
doc = '\n\n'.join([depdoc, doc])
newfunc.__doc__ = doc
try:
d = func.__dict__
except AttributeError:
pass
else:
newfunc.__dict__.update(d)
return newfunc
|
[
"def",
"__call__",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"old_name",
"=",
"self",
".",
"old_name",
"new_name",
"=",
"self",
".",
"new_name",
"message",
"=",
"self",
".",
"message",
"if",
"old_name",
"is",
"None",
":",
"try",
":",
"old_name",
"=",
"func",
".",
"__name__",
"except",
"AttributeError",
":",
"old_name",
"=",
"func",
".",
"__name__",
"if",
"new_name",
"is",
"None",
":",
"depdoc",
"=",
"\"`%s` is deprecated!\"",
"%",
"old_name",
"else",
":",
"depdoc",
"=",
"\"`%s` is deprecated, use `%s` instead!\"",
"%",
"(",
"old_name",
",",
"new_name",
")",
"if",
"message",
"is",
"not",
"None",
":",
"depdoc",
"+=",
"\"\\n\"",
"+",
"message",
"def",
"newfunc",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"\"\"\"`arrayrange` is deprecated, use `arange` instead!\"\"\"",
"warnings",
".",
"warn",
"(",
"depdoc",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
"newfunc",
"=",
"_set_function_name",
"(",
"newfunc",
",",
"old_name",
")",
"doc",
"=",
"func",
".",
"__doc__",
"if",
"doc",
"is",
"None",
":",
"doc",
"=",
"depdoc",
"else",
":",
"lines",
"=",
"doc",
".",
"expandtabs",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"indent",
"=",
"_get_indent",
"(",
"lines",
"[",
"1",
":",
"]",
")",
"if",
"lines",
"[",
"0",
"]",
".",
"lstrip",
"(",
")",
":",
"# Indent the original first line to let inspect.cleandoc()",
"# dedent the docstring despite the deprecation notice.",
"doc",
"=",
"indent",
"*",
"' '",
"+",
"doc",
"else",
":",
"# Remove the same leading blank lines as cleandoc() would.",
"skip",
"=",
"len",
"(",
"lines",
"[",
"0",
"]",
")",
"+",
"1",
"for",
"line",
"in",
"lines",
"[",
"1",
":",
"]",
":",
"if",
"len",
"(",
"line",
")",
">",
"indent",
":",
"break",
"skip",
"+=",
"len",
"(",
"line",
")",
"+",
"1",
"doc",
"=",
"doc",
"[",
"skip",
":",
"]",
"doc",
"=",
"'\\n\\n'",
".",
"join",
"(",
"[",
"depdoc",
",",
"doc",
"]",
")",
"newfunc",
".",
"__doc__",
"=",
"doc",
"try",
":",
"d",
"=",
"func",
".",
"__dict__",
"except",
"AttributeError",
":",
"pass",
"else",
":",
"newfunc",
".",
"__dict__",
".",
"update",
"(",
"d",
")",
"return",
"newfunc"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/numpy/lib/utils.py#L75-L130
|
|
mantidproject/mantid
|
03deeb89254ec4289edb8771e0188c2090a02f32
|
qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/Common/fitting_widgets/tf_asymmetry_fitting/tf_asymmetry_fitting_model.py
|
python
|
TFAsymmetryFittingModel._get_normalisation_parameter_name_for_simultaneous_domain
|
(domain_index: int)
|
return f"f{domain_index}.N0"
|
Returns the parameter name to use for a simultaneous normalisation parameter for a specific domain.
|
Returns the parameter name to use for a simultaneous normalisation parameter for a specific domain.
|
[
"Returns",
"the",
"parameter",
"name",
"to",
"use",
"for",
"a",
"simultaneous",
"normalisation",
"parameter",
"for",
"a",
"specific",
"domain",
"."
] |
def _get_normalisation_parameter_name_for_simultaneous_domain(domain_index: int) -> str:
"""Returns the parameter name to use for a simultaneous normalisation parameter for a specific domain."""
return f"f{domain_index}.N0"
|
[
"def",
"_get_normalisation_parameter_name_for_simultaneous_domain",
"(",
"domain_index",
":",
"int",
")",
"->",
"str",
":",
"return",
"f\"f{domain_index}.N0\""
] |
https://github.com/mantidproject/mantid/blob/03deeb89254ec4289edb8771e0188c2090a02f32/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/Common/fitting_widgets/tf_asymmetry_fitting/tf_asymmetry_fitting_model.py#L285-L287
|
|
PX4/PX4-Autopilot
|
0b9f60a0370be53d683352c63fd92db3d6586e18
|
Tools/mavlink_px4.py
|
python
|
MAVLink.debug_vect_send
|
(self, name, time_usec, x, y, z)
|
return self.send(self.debug_vect_encode(name, time_usec, x, y, z))
|
name : Name (char)
time_usec : Timestamp (uint64_t)
x : x (float)
y : y (float)
z : z (float)
|
[] |
def debug_vect_send(self, name, time_usec, x, y, z):
'''
name : Name (char)
time_usec : Timestamp (uint64_t)
x : x (float)
y : y (float)
z : z (float)
'''
return self.send(self.debug_vect_encode(name, time_usec, x, y, z))
|
[
"def",
"debug_vect_send",
"(",
"self",
",",
"name",
",",
"time_usec",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"return",
"self",
".",
"send",
"(",
"self",
".",
"debug_vect_encode",
"(",
"name",
",",
"time_usec",
",",
"x",
",",
"y",
",",
"z",
")",
")"
] |
https://github.com/PX4/PX4-Autopilot/blob/0b9f60a0370be53d683352c63fd92db3d6586e18/Tools/mavlink_px4.py#L5136-L5147
|
||
baidu-research/tensorflow-allreduce
|
66d5b855e90b0949e9fa5cca5599fd729a70e874
|
tensorflow/python/training/optimizer.py
|
python
|
Optimizer._get_or_make_slot_with_initializer
|
(self, var, initializer, shape, dtype,
slot_name, op_name)
|
return named_slots[_var_key(var)]
|
Find or create a slot for a variable, using an Initializer.
Args:
var: A `Variable` object.
initializer: An `Initializer`. The initial value of the slot.
shape: Shape of the initial value of the slot.
dtype: Type of the value of the slot.
slot_name: Name for the slot.
op_name: Name to use when scoping the Variable that
needs to be created for the slot.
Returns:
A `Variable` object.
|
Find or create a slot for a variable, using an Initializer.
|
[
"Find",
"or",
"create",
"a",
"slot",
"for",
"a",
"variable",
"using",
"an",
"Initializer",
"."
] |
def _get_or_make_slot_with_initializer(self, var, initializer, shape, dtype,
slot_name, op_name):
"""Find or create a slot for a variable, using an Initializer.
Args:
var: A `Variable` object.
initializer: An `Initializer`. The initial value of the slot.
shape: Shape of the initial value of the slot.
dtype: Type of the value of the slot.
slot_name: Name for the slot.
op_name: Name to use when scoping the Variable that
needs to be created for the slot.
Returns:
A `Variable` object.
"""
named_slots = self._slot_dict(slot_name)
if _var_key(var) not in named_slots:
named_slots[_var_key(var)] = slot_creator.create_slot_with_initializer(
var, initializer, shape, dtype, op_name)
return named_slots[_var_key(var)]
|
[
"def",
"_get_or_make_slot_with_initializer",
"(",
"self",
",",
"var",
",",
"initializer",
",",
"shape",
",",
"dtype",
",",
"slot_name",
",",
"op_name",
")",
":",
"named_slots",
"=",
"self",
".",
"_slot_dict",
"(",
"slot_name",
")",
"if",
"_var_key",
"(",
"var",
")",
"not",
"in",
"named_slots",
":",
"named_slots",
"[",
"_var_key",
"(",
"var",
")",
"]",
"=",
"slot_creator",
".",
"create_slot_with_initializer",
"(",
"var",
",",
"initializer",
",",
"shape",
",",
"dtype",
",",
"op_name",
")",
"return",
"named_slots",
"[",
"_var_key",
"(",
"var",
")",
"]"
] |
https://github.com/baidu-research/tensorflow-allreduce/blob/66d5b855e90b0949e9fa5cca5599fd729a70e874/tensorflow/python/training/optimizer.py#L730-L750
|
|
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Tools/build/waf-1.7.13/waflib/Tools/qt4.py
|
python
|
qxx.scan
|
(self)
|
return (lst, names)
|
Re-use the C/C++ scanner, but remove the moc files from the dependencies
since the .cpp file already depends on all the headers
|
Re-use the C/C++ scanner, but remove the moc files from the dependencies
since the .cpp file already depends on all the headers
|
[
"Re",
"-",
"use",
"the",
"C",
"/",
"C",
"++",
"scanner",
"but",
"remove",
"the",
"moc",
"files",
"from",
"the",
"dependencies",
"since",
"the",
".",
"cpp",
"file",
"already",
"depends",
"on",
"all",
"the",
"headers"
] |
def scan(self):
"""
Re-use the C/C++ scanner, but remove the moc files from the dependencies
since the .cpp file already depends on all the headers
"""
(nodes, names) = c_preproc.scan(self)
lst = []
for x in nodes:
# short lists, no need to use sets
if x.name.endswith('.moc'):
s = x.path_from(self.inputs[0].parent.get_bld())
if s not in names:
names.append(s)
else:
lst.append(x)
return (lst, names)
|
[
"def",
"scan",
"(",
"self",
")",
":",
"(",
"nodes",
",",
"names",
")",
"=",
"c_preproc",
".",
"scan",
"(",
"self",
")",
"lst",
"=",
"[",
"]",
"for",
"x",
"in",
"nodes",
":",
"# short lists, no need to use sets",
"if",
"x",
".",
"name",
".",
"endswith",
"(",
"'.moc'",
")",
":",
"s",
"=",
"x",
".",
"path_from",
"(",
"self",
".",
"inputs",
"[",
"0",
"]",
".",
"parent",
".",
"get_bld",
"(",
")",
")",
"if",
"s",
"not",
"in",
"names",
":",
"names",
".",
"append",
"(",
"s",
")",
"else",
":",
"lst",
".",
"append",
"(",
"x",
")",
"return",
"(",
"lst",
",",
"names",
")"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/build/waf-1.7.13/waflib/Tools/qt4.py#L117-L132
|
|
etodd/lasercrabs
|
91484d9ac3a47ac38b8f40ec3ff35194714dad8e
|
assets/script/etodd_blender_fbx/fbx_utils.py
|
python
|
elem_props_template_set
|
(template, elem, ptype_name, name, value, animatable=False, animated=False)
|
Only add a prop if the same value is not already defined in given template.
Note it is important to not give iterators as value, here!
|
Only add a prop if the same value is not already defined in given template.
Note it is important to not give iterators as value, here!
|
[
"Only",
"add",
"a",
"prop",
"if",
"the",
"same",
"value",
"is",
"not",
"already",
"defined",
"in",
"given",
"template",
".",
"Note",
"it",
"is",
"important",
"to",
"not",
"give",
"iterators",
"as",
"value",
"here!"
] |
def elem_props_template_set(template, elem, ptype_name, name, value, animatable=False, animated=False):
"""
Only add a prop if the same value is not already defined in given template.
Note it is important to not give iterators as value, here!
"""
ptype = FBX_PROPERTIES_DEFINITIONS[ptype_name]
if len(ptype) > 3:
value = tuple(value)
tmpl_val, tmpl_ptype, tmpl_animatable, tmpl_written = template.get(name, (None, None, False, False))
# Note animatable flag from template takes precedence over given one, if applicable.
# However, animated properties are always written, since they cannot match their template!
if tmpl_ptype is not None and not animated:
if (tmpl_written and
((len(ptype) == 3 and (tmpl_val, tmpl_ptype) == (value, ptype_name)) or
(len(ptype) > 3 and (tuple(tmpl_val), tmpl_ptype) == (value, ptype_name)))):
return # Already in template and same value.
_elem_props_set(elem, ptype, name, value, _elem_props_flags(tmpl_animatable, animated, False))
template[name][3] = True
else:
_elem_props_set(elem, ptype, name, value, _elem_props_flags(animatable, animated, False))
|
[
"def",
"elem_props_template_set",
"(",
"template",
",",
"elem",
",",
"ptype_name",
",",
"name",
",",
"value",
",",
"animatable",
"=",
"False",
",",
"animated",
"=",
"False",
")",
":",
"ptype",
"=",
"FBX_PROPERTIES_DEFINITIONS",
"[",
"ptype_name",
"]",
"if",
"len",
"(",
"ptype",
")",
">",
"3",
":",
"value",
"=",
"tuple",
"(",
"value",
")",
"tmpl_val",
",",
"tmpl_ptype",
",",
"tmpl_animatable",
",",
"tmpl_written",
"=",
"template",
".",
"get",
"(",
"name",
",",
"(",
"None",
",",
"None",
",",
"False",
",",
"False",
")",
")",
"# Note animatable flag from template takes precedence over given one, if applicable.",
"# However, animated properties are always written, since they cannot match their template!",
"if",
"tmpl_ptype",
"is",
"not",
"None",
"and",
"not",
"animated",
":",
"if",
"(",
"tmpl_written",
"and",
"(",
"(",
"len",
"(",
"ptype",
")",
"==",
"3",
"and",
"(",
"tmpl_val",
",",
"tmpl_ptype",
")",
"==",
"(",
"value",
",",
"ptype_name",
")",
")",
"or",
"(",
"len",
"(",
"ptype",
")",
">",
"3",
"and",
"(",
"tuple",
"(",
"tmpl_val",
")",
",",
"tmpl_ptype",
")",
"==",
"(",
"value",
",",
"ptype_name",
")",
")",
")",
")",
":",
"return",
"# Already in template and same value.",
"_elem_props_set",
"(",
"elem",
",",
"ptype",
",",
"name",
",",
"value",
",",
"_elem_props_flags",
"(",
"tmpl_animatable",
",",
"animated",
",",
"False",
")",
")",
"template",
"[",
"name",
"]",
"[",
"3",
"]",
"=",
"True",
"else",
":",
"_elem_props_set",
"(",
"elem",
",",
"ptype",
",",
"name",
",",
"value",
",",
"_elem_props_flags",
"(",
"animatable",
",",
"animated",
",",
"False",
")",
")"
] |
https://github.com/etodd/lasercrabs/blob/91484d9ac3a47ac38b8f40ec3ff35194714dad8e/assets/script/etodd_blender_fbx/fbx_utils.py#L626-L645
|
||
Xilinx/Vitis-AI
|
fc74d404563d9951b57245443c73bef389f3657f
|
tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/keras/distribute/distributed_training_utils.py
|
python
|
init_restore_or_wait_for_variables
|
()
|
Initialize or restore variables or wait for variables to be initialized.
|
Initialize or restore variables or wait for variables to be initialized.
|
[
"Initialize",
"or",
"restore",
"variables",
"or",
"wait",
"for",
"variables",
"to",
"be",
"initialized",
"."
] |
def init_restore_or_wait_for_variables():
"""Initialize or restore variables or wait for variables to be initialized."""
session = K._get_session() # pylint: disable=protected-access
if not multi_worker_util.has_worker_context(
) or multi_worker_util.should_load_checkpoint():
# TODO(yuefengz): if checkpoints exist, restore from checkpoint.
K._initialize_variables(session) # pylint: disable=protected-access
else:
_wait_for_variable_initialization(session)
|
[
"def",
"init_restore_or_wait_for_variables",
"(",
")",
":",
"session",
"=",
"K",
".",
"_get_session",
"(",
")",
"# pylint: disable=protected-access",
"if",
"not",
"multi_worker_util",
".",
"has_worker_context",
"(",
")",
"or",
"multi_worker_util",
".",
"should_load_checkpoint",
"(",
")",
":",
"# TODO(yuefengz): if checkpoints exist, restore from checkpoint.",
"K",
".",
"_initialize_variables",
"(",
"session",
")",
"# pylint: disable=protected-access",
"else",
":",
"_wait_for_variable_initialization",
"(",
"session",
")"
] |
https://github.com/Xilinx/Vitis-AI/blob/fc74d404563d9951b57245443c73bef389f3657f/tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/keras/distribute/distributed_training_utils.py#L403-L411
|
||
nsnam/ns-3-dev-git
|
efdb2e21f45c0a87a60b47c547b68fa140a7b686
|
utils/grid.py
|
python
|
TimelineDataRange.sort
|
(self)
|
! Sort ranges
@param self this object
@return none
|
! Sort ranges
|
[
"!",
"Sort",
"ranges"
] |
def sort(self):
"""! Sort ranges
@param self this object
@return none
"""
self.ranges.sort(ranges_cmp)
|
[
"def",
"sort",
"(",
"self",
")",
":",
"self",
".",
"ranges",
".",
"sort",
"(",
"ranges_cmp",
")"
] |
https://github.com/nsnam/ns-3-dev-git/blob/efdb2e21f45c0a87a60b47c547b68fa140a7b686/utils/grid.py#L165-L170
|
||
natanielruiz/android-yolo
|
1ebb54f96a67a20ff83ddfc823ed83a13dc3a47f
|
jni-build/jni/include/tensorflow/python/ops/control_flow_grad.py
|
python
|
_MergeGrad
|
(op, grad, _)
|
Gradients for a Merge op are calculated using a Switch op.
|
Gradients for a Merge op are calculated using a Switch op.
|
[
"Gradients",
"for",
"a",
"Merge",
"op",
"are",
"calculated",
"using",
"a",
"Switch",
"op",
"."
] |
def _MergeGrad(op, grad, _):
"""Gradients for a Merge op are calculated using a Switch op."""
input_op = op.inputs[0].op
graph = ops.get_default_graph()
# pylint: disable=protected-access
op_ctxt = input_op._get_control_flow_context()
grad_ctxt = graph._get_control_flow_context()
# pylint: enable=protected-access
if isinstance(op_ctxt, WhileContext):
# pylint: disable=protected-access
return control_flow_ops._SwitchRefOrTensor(grad, grad_ctxt.pivot)
# pylint: enable=protected-access
elif isinstance(op_ctxt, CondContext):
pred = op_ctxt.pred
if grad_ctxt and grad_ctxt.grad_state:
# This Merge node is part of a cond within a loop.
# The backprop needs to have the value of this predicate for every
# iteration. So we must have its values accumulated in the forward, and
# use the accumulated values as the predicate for this backprop switch.
grad_state = grad_ctxt.grad_state
real_pred = grad_state.history_map.get(pred.name)
if real_pred is None:
# Remember the value of pred for every iteration.
grad_ctxt = grad_state.grad_context
grad_ctxt.Exit()
history_pred = grad_state.AddForwardAccumulator(pred)
grad_ctxt.Enter()
# Add the stack pop op. If pred.op is in a (outer) CondContext,
# the stack pop will be guarded with a switch.
real_pred = grad_state.AddBackPropAccumulatedValue(history_pred, pred)
grad_state.history_map[pred.name] = real_pred
pred = real_pred
# pylint: disable=protected-access
return control_flow_ops._SwitchRefOrTensor(grad, pred, name="cond_grad")
# pylint: enable=protected-access
else:
num_inputs = len(op.inputs)
cond = [math_ops.equal(op.outputs[1], i) for i in xrange(num_inputs)]
# pylint: disable=protected-access
return [control_flow_ops._SwitchRefOrTensor(grad, cond[i])[1]
for i in xrange(num_inputs)]
|
[
"def",
"_MergeGrad",
"(",
"op",
",",
"grad",
",",
"_",
")",
":",
"input_op",
"=",
"op",
".",
"inputs",
"[",
"0",
"]",
".",
"op",
"graph",
"=",
"ops",
".",
"get_default_graph",
"(",
")",
"# pylint: disable=protected-access",
"op_ctxt",
"=",
"input_op",
".",
"_get_control_flow_context",
"(",
")",
"grad_ctxt",
"=",
"graph",
".",
"_get_control_flow_context",
"(",
")",
"# pylint: enable=protected-access",
"if",
"isinstance",
"(",
"op_ctxt",
",",
"WhileContext",
")",
":",
"# pylint: disable=protected-access",
"return",
"control_flow_ops",
".",
"_SwitchRefOrTensor",
"(",
"grad",
",",
"grad_ctxt",
".",
"pivot",
")",
"# pylint: enable=protected-access",
"elif",
"isinstance",
"(",
"op_ctxt",
",",
"CondContext",
")",
":",
"pred",
"=",
"op_ctxt",
".",
"pred",
"if",
"grad_ctxt",
"and",
"grad_ctxt",
".",
"grad_state",
":",
"# This Merge node is part of a cond within a loop.",
"# The backprop needs to have the value of this predicate for every",
"# iteration. So we must have its values accumulated in the forward, and",
"# use the accumulated values as the predicate for this backprop switch.",
"grad_state",
"=",
"grad_ctxt",
".",
"grad_state",
"real_pred",
"=",
"grad_state",
".",
"history_map",
".",
"get",
"(",
"pred",
".",
"name",
")",
"if",
"real_pred",
"is",
"None",
":",
"# Remember the value of pred for every iteration.",
"grad_ctxt",
"=",
"grad_state",
".",
"grad_context",
"grad_ctxt",
".",
"Exit",
"(",
")",
"history_pred",
"=",
"grad_state",
".",
"AddForwardAccumulator",
"(",
"pred",
")",
"grad_ctxt",
".",
"Enter",
"(",
")",
"# Add the stack pop op. If pred.op is in a (outer) CondContext,",
"# the stack pop will be guarded with a switch.",
"real_pred",
"=",
"grad_state",
".",
"AddBackPropAccumulatedValue",
"(",
"history_pred",
",",
"pred",
")",
"grad_state",
".",
"history_map",
"[",
"pred",
".",
"name",
"]",
"=",
"real_pred",
"pred",
"=",
"real_pred",
"# pylint: disable=protected-access",
"return",
"control_flow_ops",
".",
"_SwitchRefOrTensor",
"(",
"grad",
",",
"pred",
",",
"name",
"=",
"\"cond_grad\"",
")",
"# pylint: enable=protected-access",
"else",
":",
"num_inputs",
"=",
"len",
"(",
"op",
".",
"inputs",
")",
"cond",
"=",
"[",
"math_ops",
".",
"equal",
"(",
"op",
".",
"outputs",
"[",
"1",
"]",
",",
"i",
")",
"for",
"i",
"in",
"xrange",
"(",
"num_inputs",
")",
"]",
"# pylint: disable=protected-access",
"return",
"[",
"control_flow_ops",
".",
"_SwitchRefOrTensor",
"(",
"grad",
",",
"cond",
"[",
"i",
"]",
")",
"[",
"1",
"]",
"for",
"i",
"in",
"xrange",
"(",
"num_inputs",
")",
"]"
] |
https://github.com/natanielruiz/android-yolo/blob/1ebb54f96a67a20ff83ddfc823ed83a13dc3a47f/jni-build/jni/include/tensorflow/python/ops/control_flow_grad.py#L81-L122
|
||
stack-of-tasks/pinocchio
|
593d4d43fded997bb9aa2421f4e55294dbd233c4
|
bindings/python/pinocchio/visualize/rviz_visualizer.py
|
python
|
RVizVisualizer.display
|
(self, q = None)
|
Display the robot at configuration q in the viz by placing all the bodies.
|
Display the robot at configuration q in the viz by placing all the bodies.
|
[
"Display",
"the",
"robot",
"at",
"configuration",
"q",
"in",
"the",
"viz",
"by",
"placing",
"all",
"the",
"bodies",
"."
] |
def display(self, q = None):
"""Display the robot at configuration q in the viz by placing all the bodies."""
# Update the robot kinematics and geometry.
if q is not None:
pin.forwardKinematics(self.model,self.data,q)
pin.updateGeometryPlacements(self.model, self.data, self.collision_model, self.collision_data)
self.collision_ids = self.plot(self.collisions_publisher, self.collision_model, self.collision_data, self.collision_ids)
pin.updateGeometryPlacements(self.model, self.data, self.visual_model, self.visual_data)
self.visual_ids = self.plot(self.visuals_publisher, self.visual_model, self.visual_data, self.visual_ids)
|
[
"def",
"display",
"(",
"self",
",",
"q",
"=",
"None",
")",
":",
"# Update the robot kinematics and geometry.",
"if",
"q",
"is",
"not",
"None",
":",
"pin",
".",
"forwardKinematics",
"(",
"self",
".",
"model",
",",
"self",
".",
"data",
",",
"q",
")",
"pin",
".",
"updateGeometryPlacements",
"(",
"self",
".",
"model",
",",
"self",
".",
"data",
",",
"self",
".",
"collision_model",
",",
"self",
".",
"collision_data",
")",
"self",
".",
"collision_ids",
"=",
"self",
".",
"plot",
"(",
"self",
".",
"collisions_publisher",
",",
"self",
".",
"collision_model",
",",
"self",
".",
"collision_data",
",",
"self",
".",
"collision_ids",
")",
"pin",
".",
"updateGeometryPlacements",
"(",
"self",
".",
"model",
",",
"self",
".",
"data",
",",
"self",
".",
"visual_model",
",",
"self",
".",
"visual_data",
")",
"self",
".",
"visual_ids",
"=",
"self",
".",
"plot",
"(",
"self",
".",
"visuals_publisher",
",",
"self",
".",
"visual_model",
",",
"self",
".",
"visual_data",
",",
"self",
".",
"visual_ids",
")"
] |
https://github.com/stack-of-tasks/pinocchio/blob/593d4d43fded997bb9aa2421f4e55294dbd233c4/bindings/python/pinocchio/visualize/rviz_visualizer.py#L125-L135
|
||
benoitsteiner/tensorflow-opencl
|
cb7cb40a57fde5cfd4731bc551e82a1e2fef43a5
|
tensorflow/contrib/cudnn_rnn/python/ops/cudnn_rnn_ops.py
|
python
|
_cudnn_rnn
|
(inputs,
input_h,
input_c,
params,
is_training,
rnn_mode,
input_mode=CUDNN_INPUT_LINEAR_MODE,
direction=CUDNN_RNN_UNIDIRECTION,
dropout=0.,
seed=0,
name=None)
|
return (outputs, output_h, output_c)
|
Cudnn RNN.
Args:
inputs: the input sequence to the RNN model. A Tensor of shape [?,
batch_size, input_size].
input_h: the initial hidden state for h. A Tensor of shape [num_layers,
batch_size, num_units].
input_c: the initial hidden state for c. This is only relevant for LSTM.
A Tensor of the same shape as input_h.
params: the parameter buffer created for this model.
is_training: whether this operation will be used in training or inference
rnn_mode: one of ('lstm', 'gru', 'rnn_relu', 'rnn_tanh').
input_mode: indicate whether there is a linear projection between the
input and the actual computation before the first layer. It could be
'linear_input', 'skip_input' or 'auto_select'.
'linear_input' (default) always applies a linear projection of input
onto RNN hidden state. (standard RNN behavior).
'skip_input' is only allowed when input_size == num_units;
'auto_select' implies 'skip_input' when input_size == num_units;
otherwise, it implies 'linear_input'.
direction: the direction model that the model operates. Could be either
'unidirectional' or 'bidirectional'
dropout: whether to enable dropout. With it is 0, dropout is disabled.
seed: the op seed used for initializing dropout. See @{tf.set_random_seed}
for behavior.
name: name of the operation.
Returns:
outputs, output_h, output_c
|
Cudnn RNN.
|
[
"Cudnn",
"RNN",
"."
] |
def _cudnn_rnn(inputs,
input_h,
input_c,
params,
is_training,
rnn_mode,
input_mode=CUDNN_INPUT_LINEAR_MODE,
direction=CUDNN_RNN_UNIDIRECTION,
dropout=0.,
seed=0,
name=None):
"""Cudnn RNN.
Args:
inputs: the input sequence to the RNN model. A Tensor of shape [?,
batch_size, input_size].
input_h: the initial hidden state for h. A Tensor of shape [num_layers,
batch_size, num_units].
input_c: the initial hidden state for c. This is only relevant for LSTM.
A Tensor of the same shape as input_h.
params: the parameter buffer created for this model.
is_training: whether this operation will be used in training or inference
rnn_mode: one of ('lstm', 'gru', 'rnn_relu', 'rnn_tanh').
input_mode: indicate whether there is a linear projection between the
input and the actual computation before the first layer. It could be
'linear_input', 'skip_input' or 'auto_select'.
'linear_input' (default) always applies a linear projection of input
onto RNN hidden state. (standard RNN behavior).
'skip_input' is only allowed when input_size == num_units;
'auto_select' implies 'skip_input' when input_size == num_units;
otherwise, it implies 'linear_input'.
direction: the direction model that the model operates. Could be either
'unidirectional' or 'bidirectional'
dropout: whether to enable dropout. With it is 0, dropout is disabled.
seed: the op seed used for initializing dropout. See @{tf.set_random_seed}
for behavior.
name: name of the operation.
Returns:
outputs, output_h, output_c
"""
_check_rnn_mode(rnn_mode)
check_direction(direction)
check_input_mode(input_mode)
seed, seed2 = random_seed.get_seed(seed)
outputs, output_h, output_c, _ = gen_cudnn_rnn_ops.cudnn_rnn(
input=inputs,
input_h=input_h,
input_c=input_c,
params=params,
is_training=is_training,
rnn_mode=rnn_mode,
input_mode=input_mode,
direction=direction,
dropout=dropout,
seed=seed,
seed2=seed2,
name=name)
return (outputs, output_h, output_c)
|
[
"def",
"_cudnn_rnn",
"(",
"inputs",
",",
"input_h",
",",
"input_c",
",",
"params",
",",
"is_training",
",",
"rnn_mode",
",",
"input_mode",
"=",
"CUDNN_INPUT_LINEAR_MODE",
",",
"direction",
"=",
"CUDNN_RNN_UNIDIRECTION",
",",
"dropout",
"=",
"0.",
",",
"seed",
"=",
"0",
",",
"name",
"=",
"None",
")",
":",
"_check_rnn_mode",
"(",
"rnn_mode",
")",
"check_direction",
"(",
"direction",
")",
"check_input_mode",
"(",
"input_mode",
")",
"seed",
",",
"seed2",
"=",
"random_seed",
".",
"get_seed",
"(",
"seed",
")",
"outputs",
",",
"output_h",
",",
"output_c",
",",
"_",
"=",
"gen_cudnn_rnn_ops",
".",
"cudnn_rnn",
"(",
"input",
"=",
"inputs",
",",
"input_h",
"=",
"input_h",
",",
"input_c",
"=",
"input_c",
",",
"params",
"=",
"params",
",",
"is_training",
"=",
"is_training",
",",
"rnn_mode",
"=",
"rnn_mode",
",",
"input_mode",
"=",
"input_mode",
",",
"direction",
"=",
"direction",
",",
"dropout",
"=",
"dropout",
",",
"seed",
"=",
"seed",
",",
"seed2",
"=",
"seed2",
",",
"name",
"=",
"name",
")",
"return",
"(",
"outputs",
",",
"output_h",
",",
"output_c",
")"
] |
https://github.com/benoitsteiner/tensorflow-opencl/blob/cb7cb40a57fde5cfd4731bc551e82a1e2fef43a5/tensorflow/contrib/cudnn_rnn/python/ops/cudnn_rnn_ops.py#L767-L824
|
|
papyrussolution/OpenPapyrus
|
bbfb5ec2ea2109b8e2f125edd838e12eaf7b8b91
|
Src/OSF/protobuf-3.19.1/python/google/protobuf/internal/well_known_types.py
|
python
|
FieldMask.CanonicalFormFromMask
|
(self, mask)
|
Converts a FieldMask to the canonical form.
Removes paths that are covered by another path. For example,
"foo.bar" is covered by "foo" and will be removed if "foo"
is also in the FieldMask. Then sorts all paths in alphabetical order.
Args:
mask: The original FieldMask to be converted.
|
Converts a FieldMask to the canonical form.
|
[
"Converts",
"a",
"FieldMask",
"to",
"the",
"canonical",
"form",
"."
] |
def CanonicalFormFromMask(self, mask):
"""Converts a FieldMask to the canonical form.
Removes paths that are covered by another path. For example,
"foo.bar" is covered by "foo" and will be removed if "foo"
is also in the FieldMask. Then sorts all paths in alphabetical order.
Args:
mask: The original FieldMask to be converted.
"""
tree = _FieldMaskTree(mask)
tree.ToFieldMask(self)
|
[
"def",
"CanonicalFormFromMask",
"(",
"self",
",",
"mask",
")",
":",
"tree",
"=",
"_FieldMaskTree",
"(",
"mask",
")",
"tree",
".",
"ToFieldMask",
"(",
"self",
")"
] |
https://github.com/papyrussolution/OpenPapyrus/blob/bbfb5ec2ea2109b8e2f125edd838e12eaf7b8b91/Src/OSF/protobuf-3.19.1/python/google/protobuf/internal/well_known_types.py#L448-L459
|
||
miyosuda/TensorFlowAndroidDemo
|
35903e0221aa5f109ea2dbef27f20b52e317f42d
|
jni-build/jni/include/tensorflow/contrib/distributions/python/ops/mvn.py
|
python
|
MultivariateNormalOperatorPD.get_event_shape
|
(self)
|
return self._cov.get_shape()[-1:]
|
`TensorShape` available at graph construction time.
|
`TensorShape` available at graph construction time.
|
[
"TensorShape",
"available",
"at",
"graph",
"construction",
"time",
"."
] |
def get_event_shape(self):
"""`TensorShape` available at graph construction time."""
# Recall _check_mu ensures mu and self._cov have same batch shape.
return self._cov.get_shape()[-1:]
|
[
"def",
"get_event_shape",
"(",
"self",
")",
":",
"# Recall _check_mu ensures mu and self._cov have same batch shape.",
"return",
"self",
".",
"_cov",
".",
"get_shape",
"(",
")",
"[",
"-",
"1",
":",
"]"
] |
https://github.com/miyosuda/TensorFlowAndroidDemo/blob/35903e0221aa5f109ea2dbef27f20b52e317f42d/jni-build/jni/include/tensorflow/contrib/distributions/python/ops/mvn.py#L187-L190
|
|
glotzerlab/hoomd-blue
|
f7f97abfa3fcc2522fa8d458d65d0aeca7ba781a
|
hoomd/hpmc/integrate.py
|
python
|
HPMCIntegrator.rotate_moves
|
(self)
|
return self._cpp_obj.getCounters(1).rotate
|
tuple[int, int]: Count of the accepted and rejected rotate moves.
Note:
The counts are reset to 0 at the start of each
`hoomd.Simulation.run`.
|
tuple[int, int]: Count of the accepted and rejected rotate moves.
|
[
"tuple",
"[",
"int",
"int",
"]",
":",
"Count",
"of",
"the",
"accepted",
"and",
"rejected",
"rotate",
"moves",
"."
] |
def rotate_moves(self):
"""tuple[int, int]: Count of the accepted and rejected rotate moves.
Note:
The counts are reset to 0 at the start of each
`hoomd.Simulation.run`.
"""
return self._cpp_obj.getCounters(1).rotate
|
[
"def",
"rotate_moves",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cpp_obj",
".",
"getCounters",
"(",
"1",
")",
".",
"rotate"
] |
https://github.com/glotzerlab/hoomd-blue/blob/f7f97abfa3fcc2522fa8d458d65d0aeca7ba781a/hoomd/hpmc/integrate.py#L316-L323
|
|
wlanjie/AndroidFFmpeg
|
7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf
|
tools/fdk-aac-build/x86/toolchain/lib/python2.7/mailcap.py
|
python
|
readmailcapfile
|
(fp)
|
return caps
|
Read a mailcap file and return a dictionary keyed by MIME type.
Each MIME type is mapped to an entry consisting of a list of
dictionaries; the list will contain more than one such dictionary
if a given MIME type appears more than once in the mailcap file.
Each dictionary contains key-value pairs for that MIME type, where
the viewing command is stored with the key "view".
|
Read a mailcap file and return a dictionary keyed by MIME type.
|
[
"Read",
"a",
"mailcap",
"file",
"and",
"return",
"a",
"dictionary",
"keyed",
"by",
"MIME",
"type",
"."
] |
def readmailcapfile(fp):
"""Read a mailcap file and return a dictionary keyed by MIME type.
Each MIME type is mapped to an entry consisting of a list of
dictionaries; the list will contain more than one such dictionary
if a given MIME type appears more than once in the mailcap file.
Each dictionary contains key-value pairs for that MIME type, where
the viewing command is stored with the key "view".
"""
caps = {}
while 1:
line = fp.readline()
if not line: break
# Ignore comments and blank lines
if line[0] == '#' or line.strip() == '':
continue
nextline = line
# Join continuation lines
while nextline[-2:] == '\\\n':
nextline = fp.readline()
if not nextline: nextline = '\n'
line = line[:-2] + nextline
# Parse the line
key, fields = parseline(line)
if not (key and fields):
continue
# Normalize the key
types = key.split('/')
for j in range(len(types)):
types[j] = types[j].strip()
key = '/'.join(types).lower()
# Update the database
if key in caps:
caps[key].append(fields)
else:
caps[key] = [fields]
return caps
|
[
"def",
"readmailcapfile",
"(",
"fp",
")",
":",
"caps",
"=",
"{",
"}",
"while",
"1",
":",
"line",
"=",
"fp",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"break",
"# Ignore comments and blank lines",
"if",
"line",
"[",
"0",
"]",
"==",
"'#'",
"or",
"line",
".",
"strip",
"(",
")",
"==",
"''",
":",
"continue",
"nextline",
"=",
"line",
"# Join continuation lines",
"while",
"nextline",
"[",
"-",
"2",
":",
"]",
"==",
"'\\\\\\n'",
":",
"nextline",
"=",
"fp",
".",
"readline",
"(",
")",
"if",
"not",
"nextline",
":",
"nextline",
"=",
"'\\n'",
"line",
"=",
"line",
"[",
":",
"-",
"2",
"]",
"+",
"nextline",
"# Parse the line",
"key",
",",
"fields",
"=",
"parseline",
"(",
"line",
")",
"if",
"not",
"(",
"key",
"and",
"fields",
")",
":",
"continue",
"# Normalize the key",
"types",
"=",
"key",
".",
"split",
"(",
"'/'",
")",
"for",
"j",
"in",
"range",
"(",
"len",
"(",
"types",
")",
")",
":",
"types",
"[",
"j",
"]",
"=",
"types",
"[",
"j",
"]",
".",
"strip",
"(",
")",
"key",
"=",
"'/'",
".",
"join",
"(",
"types",
")",
".",
"lower",
"(",
")",
"# Update the database",
"if",
"key",
"in",
"caps",
":",
"caps",
"[",
"key",
"]",
".",
"append",
"(",
"fields",
")",
"else",
":",
"caps",
"[",
"key",
"]",
"=",
"[",
"fields",
"]",
"return",
"caps"
] |
https://github.com/wlanjie/AndroidFFmpeg/blob/7baf9122f4b8e1c74e7baf4be5c422c7a5ba5aaf/tools/fdk-aac-build/x86/toolchain/lib/python2.7/mailcap.py#L53-L89
|
|
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Gems/CloudGemMetric/v1/AWS/common-code/Lib/pandas/io/formats/format.py
|
python
|
DataFrameFormatter.write_result
|
(self, buf: IO[str])
|
Render a DataFrame to a console-friendly tabular output.
|
Render a DataFrame to a console-friendly tabular output.
|
[
"Render",
"a",
"DataFrame",
"to",
"a",
"console",
"-",
"friendly",
"tabular",
"output",
"."
] |
def write_result(self, buf: IO[str]) -> None:
"""
Render a DataFrame to a console-friendly tabular output.
"""
from pandas import Series
frame = self.frame
if len(frame.columns) == 0 or len(frame.index) == 0:
info_line = "Empty {name}\nColumns: {col}\nIndex: {idx}".format(
name=type(self.frame).__name__,
col=pprint_thing(frame.columns),
idx=pprint_thing(frame.index),
)
text = info_line
else:
strcols = self._to_str_columns()
if self.line_width is None: # no need to wrap around just print
# the whole frame
text = self.adj.adjoin(1, *strcols)
elif (
not isinstance(self.max_cols, int) or self.max_cols > 0
): # need to wrap around
text = self._join_multiline(*strcols)
else: # max_cols == 0. Try to fit frame to terminal
lines = self.adj.adjoin(1, *strcols).split("\n")
max_len = Series(lines).str.len().max()
# plus truncate dot col
dif = max_len - self.w
# '+ 1' to avoid too wide repr (GH PR #17023)
adj_dif = dif + 1
col_lens = Series([Series(ele).apply(len).max() for ele in strcols])
n_cols = len(col_lens)
counter = 0
while adj_dif > 0 and n_cols > 1:
counter += 1
mid = int(round(n_cols / 2.0))
mid_ix = col_lens.index[mid]
col_len = col_lens[mid_ix]
# adjoin adds one
adj_dif -= col_len + 1
col_lens = col_lens.drop(mid_ix)
n_cols = len(col_lens)
# subtract index column
max_cols_adj = n_cols - self.index
# GH-21180. Ensure that we print at least two.
max_cols_adj = max(max_cols_adj, 2)
self.max_cols_adj = max_cols_adj
# Call again _chk_truncate to cut frame appropriately
# and then generate string representation
self._chk_truncate()
strcols = self._to_str_columns()
text = self.adj.adjoin(1, *strcols)
buf.writelines(text)
if self.should_show_dimensions:
buf.write(
"\n\n[{nrows} rows x {ncols} columns]".format(
nrows=len(frame), ncols=len(frame.columns)
)
)
|
[
"def",
"write_result",
"(",
"self",
",",
"buf",
":",
"IO",
"[",
"str",
"]",
")",
"->",
"None",
":",
"from",
"pandas",
"import",
"Series",
"frame",
"=",
"self",
".",
"frame",
"if",
"len",
"(",
"frame",
".",
"columns",
")",
"==",
"0",
"or",
"len",
"(",
"frame",
".",
"index",
")",
"==",
"0",
":",
"info_line",
"=",
"\"Empty {name}\\nColumns: {col}\\nIndex: {idx}\"",
".",
"format",
"(",
"name",
"=",
"type",
"(",
"self",
".",
"frame",
")",
".",
"__name__",
",",
"col",
"=",
"pprint_thing",
"(",
"frame",
".",
"columns",
")",
",",
"idx",
"=",
"pprint_thing",
"(",
"frame",
".",
"index",
")",
",",
")",
"text",
"=",
"info_line",
"else",
":",
"strcols",
"=",
"self",
".",
"_to_str_columns",
"(",
")",
"if",
"self",
".",
"line_width",
"is",
"None",
":",
"# no need to wrap around just print",
"# the whole frame",
"text",
"=",
"self",
".",
"adj",
".",
"adjoin",
"(",
"1",
",",
"*",
"strcols",
")",
"elif",
"(",
"not",
"isinstance",
"(",
"self",
".",
"max_cols",
",",
"int",
")",
"or",
"self",
".",
"max_cols",
">",
"0",
")",
":",
"# need to wrap around",
"text",
"=",
"self",
".",
"_join_multiline",
"(",
"*",
"strcols",
")",
"else",
":",
"# max_cols == 0. Try to fit frame to terminal",
"lines",
"=",
"self",
".",
"adj",
".",
"adjoin",
"(",
"1",
",",
"*",
"strcols",
")",
".",
"split",
"(",
"\"\\n\"",
")",
"max_len",
"=",
"Series",
"(",
"lines",
")",
".",
"str",
".",
"len",
"(",
")",
".",
"max",
"(",
")",
"# plus truncate dot col",
"dif",
"=",
"max_len",
"-",
"self",
".",
"w",
"# '+ 1' to avoid too wide repr (GH PR #17023)",
"adj_dif",
"=",
"dif",
"+",
"1",
"col_lens",
"=",
"Series",
"(",
"[",
"Series",
"(",
"ele",
")",
".",
"apply",
"(",
"len",
")",
".",
"max",
"(",
")",
"for",
"ele",
"in",
"strcols",
"]",
")",
"n_cols",
"=",
"len",
"(",
"col_lens",
")",
"counter",
"=",
"0",
"while",
"adj_dif",
">",
"0",
"and",
"n_cols",
">",
"1",
":",
"counter",
"+=",
"1",
"mid",
"=",
"int",
"(",
"round",
"(",
"n_cols",
"/",
"2.0",
")",
")",
"mid_ix",
"=",
"col_lens",
".",
"index",
"[",
"mid",
"]",
"col_len",
"=",
"col_lens",
"[",
"mid_ix",
"]",
"# adjoin adds one",
"adj_dif",
"-=",
"col_len",
"+",
"1",
"col_lens",
"=",
"col_lens",
".",
"drop",
"(",
"mid_ix",
")",
"n_cols",
"=",
"len",
"(",
"col_lens",
")",
"# subtract index column",
"max_cols_adj",
"=",
"n_cols",
"-",
"self",
".",
"index",
"# GH-21180. Ensure that we print at least two.",
"max_cols_adj",
"=",
"max",
"(",
"max_cols_adj",
",",
"2",
")",
"self",
".",
"max_cols_adj",
"=",
"max_cols_adj",
"# Call again _chk_truncate to cut frame appropriately",
"# and then generate string representation",
"self",
".",
"_chk_truncate",
"(",
")",
"strcols",
"=",
"self",
".",
"_to_str_columns",
"(",
")",
"text",
"=",
"self",
".",
"adj",
".",
"adjoin",
"(",
"1",
",",
"*",
"strcols",
")",
"buf",
".",
"writelines",
"(",
"text",
")",
"if",
"self",
".",
"should_show_dimensions",
":",
"buf",
".",
"write",
"(",
"\"\\n\\n[{nrows} rows x {ncols} columns]\"",
".",
"format",
"(",
"nrows",
"=",
"len",
"(",
"frame",
")",
",",
"ncols",
"=",
"len",
"(",
"frame",
".",
"columns",
")",
")",
")"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/common-code/Lib/pandas/io/formats/format.py#L806-L868
|
||
lhmRyan/deep-supervised-hashing-DSH
|
631901f82e2ab031fbac33f914a5b08ef8e21d57
|
scripts/cpp_lint.py
|
python
|
CheckVlogArguments
|
(filename, clean_lines, linenum, error)
|
Checks that VLOG() is only used for defining a logging level.
For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and
VLOG(FATAL) are not.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
error: The function to call with any errors found.
|
Checks that VLOG() is only used for defining a logging level.
|
[
"Checks",
"that",
"VLOG",
"()",
"is",
"only",
"used",
"for",
"defining",
"a",
"logging",
"level",
"."
] |
def CheckVlogArguments(filename, clean_lines, linenum, error):
"""Checks that VLOG() is only used for defining a logging level.
For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and
VLOG(FATAL) are not.
Args:
filename: The name of the current file.
clean_lines: A CleansedLines instance containing the file.
linenum: The number of the line to check.
error: The function to call with any errors found.
"""
line = clean_lines.elided[linenum]
if Search(r'\bVLOG\((INFO|ERROR|WARNING|DFATAL|FATAL)\)', line):
error(filename, linenum, 'runtime/vlog', 5,
'VLOG() should be used with numeric verbosity level. '
'Use LOG() if you want symbolic severity levels.')
|
[
"def",
"CheckVlogArguments",
"(",
"filename",
",",
"clean_lines",
",",
"linenum",
",",
"error",
")",
":",
"line",
"=",
"clean_lines",
".",
"elided",
"[",
"linenum",
"]",
"if",
"Search",
"(",
"r'\\bVLOG\\((INFO|ERROR|WARNING|DFATAL|FATAL)\\)'",
",",
"line",
")",
":",
"error",
"(",
"filename",
",",
"linenum",
",",
"'runtime/vlog'",
",",
"5",
",",
"'VLOG() should be used with numeric verbosity level. '",
"'Use LOG() if you want symbolic severity levels.'",
")"
] |
https://github.com/lhmRyan/deep-supervised-hashing-DSH/blob/631901f82e2ab031fbac33f914a5b08ef8e21d57/scripts/cpp_lint.py#L1708-L1724
|
||
GoldenCheetah/GoldenCheetah
|
919a418895040144be5579884446ed6cd701bf0d
|
util/gh-downloads.py
|
python
|
error
|
(message)
|
Halt script due to critical error.
:param message: Error text.
|
Halt script due to critical error.
:param message: Error text.
|
[
"Halt",
"script",
"due",
"to",
"critical",
"error",
".",
":",
"param",
"message",
":",
"Error",
"text",
"."
] |
def error(message):
"""
Halt script due to critical error.
:param message: Error text.
"""
sys.exit(_Text.ERROR + "Error: " + message + _Text.END)
|
[
"def",
"error",
"(",
"message",
")",
":",
"sys",
".",
"exit",
"(",
"_Text",
".",
"ERROR",
"+",
"\"Error: \"",
"+",
"message",
"+",
"_Text",
".",
"END",
")"
] |
https://github.com/GoldenCheetah/GoldenCheetah/blob/919a418895040144be5579884446ed6cd701bf0d/util/gh-downloads.py#L115-L120
|
||
mindspore-ai/mindspore
|
fb8fd3338605bb34fa5cea054e535a8b1d753fab
|
mindspore/python/mindspore/ops/_op_impl/_custom_op/bessel_i1.py
|
python
|
bessel_i1_compute
|
(input_x, output_y, kernel_name="bessel_i1")
|
return res
|
bessel_i1_compute
|
bessel_i1_compute
|
[
"bessel_i1_compute"
] |
def bessel_i1_compute(input_x, output_y, kernel_name="bessel_i1"):
"""bessel_i1_compute"""
dtype = input_x.dtype
shape = input_x.shape
has_improve_precision = False
if dtype != "float32":
input_x = dsl.cast_to(input_x, "float32")
dtype = "float32"
has_improve_precision = True
y = dsl.vabs(input_x)
y_le_eight = dsl.vmul(y, chebevl(dsl.vadds(dsl.vmuls(y, 0.5), -2), 29, A, shape, dtype))
y_gt_eight = chebevl(dsl.vadds(dsl.vmuls(dsl.vrec(y), 32.0), -2.0), 25, B, shape, dtype)
y = dsl.vcmpsel(y, 8.0, 'le', y_le_eight, y_gt_eight)
res = dsl.vcmpsel(input_x, 0, 'lt', dsl.vmuls(y, -1.0), y)
res = dsl.vmul(res, dsl.vexp(dsl.vabs(input_x)))
if has_improve_precision:
res = dsl.cast_to(res, "float16")
return res
|
[
"def",
"bessel_i1_compute",
"(",
"input_x",
",",
"output_y",
",",
"kernel_name",
"=",
"\"bessel_i1\"",
")",
":",
"dtype",
"=",
"input_x",
".",
"dtype",
"shape",
"=",
"input_x",
".",
"shape",
"has_improve_precision",
"=",
"False",
"if",
"dtype",
"!=",
"\"float32\"",
":",
"input_x",
"=",
"dsl",
".",
"cast_to",
"(",
"input_x",
",",
"\"float32\"",
")",
"dtype",
"=",
"\"float32\"",
"has_improve_precision",
"=",
"True",
"y",
"=",
"dsl",
".",
"vabs",
"(",
"input_x",
")",
"y_le_eight",
"=",
"dsl",
".",
"vmul",
"(",
"y",
",",
"chebevl",
"(",
"dsl",
".",
"vadds",
"(",
"dsl",
".",
"vmuls",
"(",
"y",
",",
"0.5",
")",
",",
"-",
"2",
")",
",",
"29",
",",
"A",
",",
"shape",
",",
"dtype",
")",
")",
"y_gt_eight",
"=",
"chebevl",
"(",
"dsl",
".",
"vadds",
"(",
"dsl",
".",
"vmuls",
"(",
"dsl",
".",
"vrec",
"(",
"y",
")",
",",
"32.0",
")",
",",
"-",
"2.0",
")",
",",
"25",
",",
"B",
",",
"shape",
",",
"dtype",
")",
"y",
"=",
"dsl",
".",
"vcmpsel",
"(",
"y",
",",
"8.0",
",",
"'le'",
",",
"y_le_eight",
",",
"y_gt_eight",
")",
"res",
"=",
"dsl",
".",
"vcmpsel",
"(",
"input_x",
",",
"0",
",",
"'lt'",
",",
"dsl",
".",
"vmuls",
"(",
"y",
",",
"-",
"1.0",
")",
",",
"y",
")",
"res",
"=",
"dsl",
".",
"vmul",
"(",
"res",
",",
"dsl",
".",
"vexp",
"(",
"dsl",
".",
"vabs",
"(",
"input_x",
")",
")",
")",
"if",
"has_improve_precision",
":",
"res",
"=",
"dsl",
".",
"cast_to",
"(",
"res",
",",
"\"float16\"",
")",
"return",
"res"
] |
https://github.com/mindspore-ai/mindspore/blob/fb8fd3338605bb34fa5cea054e535a8b1d753fab/mindspore/python/mindspore/ops/_op_impl/_custom_op/bessel_i1.py#L85-L108
|
|
mantidproject/mantid
|
03deeb89254ec4289edb8771e0188c2090a02f32
|
scripts/Calibration/tube_calib.py
|
python
|
read_peak_file
|
(file_name)
|
return loaded_file
|
Load the file calibration
It returns a list of tuples, where the first value is the detector identification
and the second value is its calibration values.
Example of usage:
for (det_code, cal_values) in readPeakFile('pathname/TubeDemo'):
print(det_code)
print(cal_values)
|
Load the file calibration
|
[
"Load",
"the",
"file",
"calibration"
] |
def read_peak_file(file_name):
"""Load the file calibration
It returns a list of tuples, where the first value is the detector identification
and the second value is its calibration values.
Example of usage:
for (det_code, cal_values) in readPeakFile('pathname/TubeDemo'):
print(det_code)
print(cal_values)
"""
loaded_file = []
# split the entries to the main values:
# For example:
# MERLIN/door1/tube_1_1 [34.199347724575574, 525.5864438725401, 1001.7456248836971]
# Will be splited as:
# ['MERLIN/door1/tube_1_1', '', '34.199347724575574', '', '525.5864438725401', '', '1001.7456248836971', '', '', '']
pattern = re.compile(r'[\[\],\s\r]')
save_directory = config['defaultsave.directory']
pfile = os.path.join(save_directory, file_name)
for line in open(pfile, 'r'):
# check if the entry is a comment line
if line.startswith('#'):
continue
# split all values
line_vals = re.split(pattern, line)
id_ = line_vals[0]
if id_ == '':
continue
try:
f_values = [float(v) for v in line_vals[1:] if v != '']
except ValueError:
continue
loaded_file.append((id_, f_values))
return loaded_file
|
[
"def",
"read_peak_file",
"(",
"file_name",
")",
":",
"loaded_file",
"=",
"[",
"]",
"# split the entries to the main values:",
"# For example:",
"# MERLIN/door1/tube_1_1 [34.199347724575574, 525.5864438725401, 1001.7456248836971]",
"# Will be splited as:",
"# ['MERLIN/door1/tube_1_1', '', '34.199347724575574', '', '525.5864438725401', '', '1001.7456248836971', '', '', '']",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'[\\[\\],\\s\\r]'",
")",
"save_directory",
"=",
"config",
"[",
"'defaultsave.directory'",
"]",
"pfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"save_directory",
",",
"file_name",
")",
"for",
"line",
"in",
"open",
"(",
"pfile",
",",
"'r'",
")",
":",
"# check if the entry is a comment line",
"if",
"line",
".",
"startswith",
"(",
"'#'",
")",
":",
"continue",
"# split all values",
"line_vals",
"=",
"re",
".",
"split",
"(",
"pattern",
",",
"line",
")",
"id_",
"=",
"line_vals",
"[",
"0",
"]",
"if",
"id_",
"==",
"''",
":",
"continue",
"try",
":",
"f_values",
"=",
"[",
"float",
"(",
"v",
")",
"for",
"v",
"in",
"line_vals",
"[",
"1",
":",
"]",
"if",
"v",
"!=",
"''",
"]",
"except",
"ValueError",
":",
"continue",
"loaded_file",
".",
"append",
"(",
"(",
"id_",
",",
"f_values",
")",
")",
"return",
"loaded_file"
] |
https://github.com/mantidproject/mantid/blob/03deeb89254ec4289edb8771e0188c2090a02f32/scripts/Calibration/tube_calib.py#L459-L495
|
|
weolar/miniblink49
|
1c4678db0594a4abde23d3ebbcc7cd13c3170777
|
third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/autopep8.py
|
python
|
has_arithmetic_operator
|
(line)
|
return False
|
Return True if line contains any arithmetic operators.
|
Return True if line contains any arithmetic operators.
|
[
"Return",
"True",
"if",
"line",
"contains",
"any",
"arithmetic",
"operators",
"."
] |
def has_arithmetic_operator(line):
"""Return True if line contains any arithmetic operators."""
for operator in pep8.ARITHMETIC_OP:
if operator in line:
return True
return False
|
[
"def",
"has_arithmetic_operator",
"(",
"line",
")",
":",
"for",
"operator",
"in",
"pep8",
".",
"ARITHMETIC_OP",
":",
"if",
"operator",
"in",
"line",
":",
"return",
"True",
"return",
"False"
] |
https://github.com/weolar/miniblink49/blob/1c4678db0594a4abde23d3ebbcc7cd13c3170777/third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/autopep8.py#L3453-L3459
|
|
alexozer/jankdrone
|
c4b403eb254b41b832ab2bdfade12ba59c99e5dc
|
shm/lib/pyratemp/pyratemp.py
|
python
|
TemplateBase.__str__
|
(self)
|
return self.__call__()
|
Alias for __call__().
|
Alias for __call__().
|
[
"Alias",
"for",
"__call__",
"()",
"."
] |
def __str__(self):
"""Alias for __call__()."""
return self.__call__()
|
[
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"__call__",
"(",
")"
] |
https://github.com/alexozer/jankdrone/blob/c4b403eb254b41b832ab2bdfade12ba59c99e5dc/shm/lib/pyratemp/pyratemp.py#L1063-L1065
|
|
thalium/icebox
|
99d147d5b9269222225443ce171b4fd46d8985d4
|
third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2.py
|
python
|
SAXCallback.endDocument
|
(self)
|
called at the end of the document
|
called at the end of the document
|
[
"called",
"at",
"the",
"end",
"of",
"the",
"document"
] |
def endDocument(self):
"""called at the end of the document"""
pass
|
[
"def",
"endDocument",
"(",
"self",
")",
":",
"pass"
] |
https://github.com/thalium/icebox/blob/99d147d5b9269222225443ce171b4fd46d8985d4/third_party/virtualbox/src/libs/libxml2-2.9.4/python/libxml2.py#L168-L170
|
||
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_cocoa/_controls.py
|
python
|
TextAttr.HasListStyleName
|
(*args, **kwargs)
|
return _controls_.TextAttr_HasListStyleName(*args, **kwargs)
|
HasListStyleName(self) -> bool
|
HasListStyleName(self) -> bool
|
[
"HasListStyleName",
"(",
"self",
")",
"-",
">",
"bool"
] |
def HasListStyleName(*args, **kwargs):
"""HasListStyleName(self) -> bool"""
return _controls_.TextAttr_HasListStyleName(*args, **kwargs)
|
[
"def",
"HasListStyleName",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_controls_",
".",
"TextAttr_HasListStyleName",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/_controls.py#L1848-L1850
|
|
pmq20/node-packer
|
12c46c6e44fbc14d9ee645ebd17d5296b324f7e0
|
lts/deps/v8/tools/stats-viewer.py
|
python
|
StatsViewer.UpdateTime
|
(self)
|
Update the title of the window with the current time.
|
Update the title of the window with the current time.
|
[
"Update",
"the",
"title",
"of",
"the",
"window",
"with",
"the",
"current",
"time",
"."
] |
def UpdateTime(self):
"""Update the title of the window with the current time."""
self.root.title("Stats Viewer [updated %s]" % time.strftime("%H:%M:%S"))
|
[
"def",
"UpdateTime",
"(",
"self",
")",
":",
"self",
".",
"root",
".",
"title",
"(",
"\"Stats Viewer [updated %s]\"",
"%",
"time",
".",
"strftime",
"(",
"\"%H:%M:%S\"",
")",
")"
] |
https://github.com/pmq20/node-packer/blob/12c46c6e44fbc14d9ee645ebd17d5296b324f7e0/lts/deps/v8/tools/stats-viewer.py#L167-L169
|
||
ChromiumWebApps/chromium
|
c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7
|
chrome/common/extensions/docs/server2/app_yaml_helper.py
|
python
|
AppYamlHelper.GetFirstRevisionGreaterThan
|
(self, app_version)
|
return stored
|
Finds the first revision that the version in app.yaml was greater than
|app_version|.
WARNING: if there is no such revision (e.g. the app is up to date, or
*oops* the app is even newer) then this will throw a ValueError. Use
IsUpToDate to validate the input before calling this method.
|
Finds the first revision that the version in app.yaml was greater than
|app_version|.
|
[
"Finds",
"the",
"first",
"revision",
"that",
"the",
"version",
"in",
"app",
".",
"yaml",
"was",
"greater",
"than",
"|app_version|",
"."
] |
def GetFirstRevisionGreaterThan(self, app_version):
'''Finds the first revision that the version in app.yaml was greater than
|app_version|.
WARNING: if there is no such revision (e.g. the app is up to date, or
*oops* the app is even newer) then this will throw a ValueError. Use
IsUpToDate to validate the input before calling this method.
'''
stored = self._store.Get(app_version).Get()
if stored is None:
stored = self._GetFirstRevisionGreaterThanImpl(app_version)
assert stored is not None
self._store.Set(app_version, stored)
return stored
|
[
"def",
"GetFirstRevisionGreaterThan",
"(",
"self",
",",
"app_version",
")",
":",
"stored",
"=",
"self",
".",
"_store",
".",
"Get",
"(",
"app_version",
")",
".",
"Get",
"(",
")",
"if",
"stored",
"is",
"None",
":",
"stored",
"=",
"self",
".",
"_GetFirstRevisionGreaterThanImpl",
"(",
"app_version",
")",
"assert",
"stored",
"is",
"not",
"None",
"self",
".",
"_store",
".",
"Set",
"(",
"app_version",
",",
"stored",
")",
"return",
"stored"
] |
https://github.com/ChromiumWebApps/chromium/blob/c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7/chrome/common/extensions/docs/server2/app_yaml_helper.py#L87-L100
|
|
gnuradio/gnuradio
|
09c3c4fa4bfb1a02caac74cb5334dfe065391e3b
|
gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py
|
python
|
qa_digital_carrier_allocator_cvc.test_003_t
|
(self)
|
more advanced:
- 6 symbols per carrier
- 2 pilots per carrier
- have enough data for nearly 3 OFDM symbols
- send that twice
- add some random tags
- don't shift
|
more advanced:
- 6 symbols per carrier
- 2 pilots per carrier
- have enough data for nearly 3 OFDM symbols
- send that twice
- add some random tags
- don't shift
|
[
"more",
"advanced",
":",
"-",
"6",
"symbols",
"per",
"carrier",
"-",
"2",
"pilots",
"per",
"carrier",
"-",
"have",
"enough",
"data",
"for",
"nearly",
"3",
"OFDM",
"symbols",
"-",
"send",
"that",
"twice",
"-",
"add",
"some",
"random",
"tags",
"-",
"don",
"t",
"shift"
] |
def test_003_t(self):
"""
more advanced:
- 6 symbols per carrier
- 2 pilots per carrier
- have enough data for nearly 3 OFDM symbols
- send that twice
- add some random tags
- don't shift
"""
tx_symbols = list(range(1, 16)) # 15 symbols
pilot_symbols = ((1j, 2j), (3j, 4j))
occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),)
pilot_carriers = ((2, 13), (3, 12))
expected_result = list(
(0,
1,
1j,
2,
3,
0,
0,
0,
0,
0,
0,
4,
5,
2j,
6,
0,
0,
7,
8,
3j,
9,
0,
0,
0,
0,
0,
0,
10,
4j,
11,
12,
0,
0,
13,
1j,
14,
15,
0,
0,
0,
0,
0,
0,
0,
0,
2j,
0,
0))
fft_len = 16
testtag1 = gr.tag_t()
testtag1.offset = 0
testtag1.key = pmt.string_to_symbol('tag1')
testtag1.value = pmt.from_long(0)
testtag2 = gr.tag_t()
testtag2.offset = 7 # On the 2nd OFDM symbol
testtag2.key = pmt.string_to_symbol('tag2')
testtag2.value = pmt.from_long(0)
testtag3 = gr.tag_t()
testtag3.offset = len(tx_symbols) + 1 # First OFDM symbol of packet 2
testtag3.key = pmt.string_to_symbol('tag3')
testtag3.value = pmt.from_long(0)
testtag4 = gr.tag_t()
# Last OFDM symbol of packet 2
testtag4.offset = 2 * len(tx_symbols) - 1
testtag4.key = pmt.string_to_symbol('tag4')
testtag4.value = pmt.from_long(0)
src = blocks.vector_source_c(
tx_symbols * 2, False, 1, (testtag1, testtag2, testtag3, testtag4))
alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
occupied_carriers,
pilot_carriers,
pilot_symbols, (),
self.tsb_key,
False)
sink = blocks.tsb_vector_sink_c(fft_len)
self.tb.connect(
src,
blocks.stream_to_tagged_stream(
gr.sizeof_gr_complex,
1,
len(tx_symbols),
self.tsb_key),
alloc,
sink)
self.tb.run()
self.assertEqual(sink.data()[0], expected_result)
tags_found = {
'tag1': False,
'tag2': False,
'tag3': False,
'tag4': False}
correct_offsets = {'tag1': 0, 'tag2': 1, 'tag3': 3, 'tag4': 5}
for tag in sink.tags():
key = pmt.symbol_to_string(tag.key)
if key in list(tags_found.keys()):
tags_found[key] = True
self.assertEqual(correct_offsets[key], tag.offset)
self.assertTrue(all(tags_found.values()))
|
[
"def",
"test_003_t",
"(",
"self",
")",
":",
"tx_symbols",
"=",
"list",
"(",
"range",
"(",
"1",
",",
"16",
")",
")",
"# 15 symbols",
"pilot_symbols",
"=",
"(",
"(",
"1j",
",",
"2j",
")",
",",
"(",
"3j",
",",
"4j",
")",
")",
"occupied_carriers",
"=",
"(",
"(",
"1",
",",
"3",
",",
"4",
",",
"11",
",",
"12",
",",
"14",
")",
",",
"(",
"1",
",",
"2",
",",
"4",
",",
"11",
",",
"13",
",",
"14",
")",
",",
")",
"pilot_carriers",
"=",
"(",
"(",
"2",
",",
"13",
")",
",",
"(",
"3",
",",
"12",
")",
")",
"expected_result",
"=",
"list",
"(",
"(",
"0",
",",
"1",
",",
"1j",
",",
"2",
",",
"3",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"4",
",",
"5",
",",
"2j",
",",
"6",
",",
"0",
",",
"0",
",",
"7",
",",
"8",
",",
"3j",
",",
"9",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"10",
",",
"4j",
",",
"11",
",",
"12",
",",
"0",
",",
"0",
",",
"13",
",",
"1j",
",",
"14",
",",
"15",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"2j",
",",
"0",
",",
"0",
")",
")",
"fft_len",
"=",
"16",
"testtag1",
"=",
"gr",
".",
"tag_t",
"(",
")",
"testtag1",
".",
"offset",
"=",
"0",
"testtag1",
".",
"key",
"=",
"pmt",
".",
"string_to_symbol",
"(",
"'tag1'",
")",
"testtag1",
".",
"value",
"=",
"pmt",
".",
"from_long",
"(",
"0",
")",
"testtag2",
"=",
"gr",
".",
"tag_t",
"(",
")",
"testtag2",
".",
"offset",
"=",
"7",
"# On the 2nd OFDM symbol",
"testtag2",
".",
"key",
"=",
"pmt",
".",
"string_to_symbol",
"(",
"'tag2'",
")",
"testtag2",
".",
"value",
"=",
"pmt",
".",
"from_long",
"(",
"0",
")",
"testtag3",
"=",
"gr",
".",
"tag_t",
"(",
")",
"testtag3",
".",
"offset",
"=",
"len",
"(",
"tx_symbols",
")",
"+",
"1",
"# First OFDM symbol of packet 2",
"testtag3",
".",
"key",
"=",
"pmt",
".",
"string_to_symbol",
"(",
"'tag3'",
")",
"testtag3",
".",
"value",
"=",
"pmt",
".",
"from_long",
"(",
"0",
")",
"testtag4",
"=",
"gr",
".",
"tag_t",
"(",
")",
"# Last OFDM symbol of packet 2",
"testtag4",
".",
"offset",
"=",
"2",
"*",
"len",
"(",
"tx_symbols",
")",
"-",
"1",
"testtag4",
".",
"key",
"=",
"pmt",
".",
"string_to_symbol",
"(",
"'tag4'",
")",
"testtag4",
".",
"value",
"=",
"pmt",
".",
"from_long",
"(",
"0",
")",
"src",
"=",
"blocks",
".",
"vector_source_c",
"(",
"tx_symbols",
"*",
"2",
",",
"False",
",",
"1",
",",
"(",
"testtag1",
",",
"testtag2",
",",
"testtag3",
",",
"testtag4",
")",
")",
"alloc",
"=",
"digital",
".",
"ofdm_carrier_allocator_cvc",
"(",
"fft_len",
",",
"occupied_carriers",
",",
"pilot_carriers",
",",
"pilot_symbols",
",",
"(",
")",
",",
"self",
".",
"tsb_key",
",",
"False",
")",
"sink",
"=",
"blocks",
".",
"tsb_vector_sink_c",
"(",
"fft_len",
")",
"self",
".",
"tb",
".",
"connect",
"(",
"src",
",",
"blocks",
".",
"stream_to_tagged_stream",
"(",
"gr",
".",
"sizeof_gr_complex",
",",
"1",
",",
"len",
"(",
"tx_symbols",
")",
",",
"self",
".",
"tsb_key",
")",
",",
"alloc",
",",
"sink",
")",
"self",
".",
"tb",
".",
"run",
"(",
")",
"self",
".",
"assertEqual",
"(",
"sink",
".",
"data",
"(",
")",
"[",
"0",
"]",
",",
"expected_result",
")",
"tags_found",
"=",
"{",
"'tag1'",
":",
"False",
",",
"'tag2'",
":",
"False",
",",
"'tag3'",
":",
"False",
",",
"'tag4'",
":",
"False",
"}",
"correct_offsets",
"=",
"{",
"'tag1'",
":",
"0",
",",
"'tag2'",
":",
"1",
",",
"'tag3'",
":",
"3",
",",
"'tag4'",
":",
"5",
"}",
"for",
"tag",
"in",
"sink",
".",
"tags",
"(",
")",
":",
"key",
"=",
"pmt",
".",
"symbol_to_string",
"(",
"tag",
".",
"key",
")",
"if",
"key",
"in",
"list",
"(",
"tags_found",
".",
"keys",
"(",
")",
")",
":",
"tags_found",
"[",
"key",
"]",
"=",
"True",
"self",
".",
"assertEqual",
"(",
"correct_offsets",
"[",
"key",
"]",
",",
"tag",
".",
"offset",
")",
"self",
".",
"assertTrue",
"(",
"all",
"(",
"tags_found",
".",
"values",
"(",
")",
")",
")"
] |
https://github.com/gnuradio/gnuradio/blob/09c3c4fa4bfb1a02caac74cb5334dfe065391e3b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py#L169-L281
|
||
shedskin/shedskin
|
ae88dbca7b1d9671cd8be448cb0b497122758936
|
scripts/manpage.py
|
python
|
Translator.visit_substitution_definition
|
(self, node)
|
Internal only.
|
Internal only.
|
[
"Internal",
"only",
"."
] |
def visit_substitution_definition(self, node):
"""Internal only."""
raise nodes.SkipNode
|
[
"def",
"visit_substitution_definition",
"(",
"self",
",",
"node",
")",
":",
"raise",
"nodes",
".",
"SkipNode"
] |
https://github.com/shedskin/shedskin/blob/ae88dbca7b1d9671cd8be448cb0b497122758936/scripts/manpage.py#L845-L847
|
||
hpi-xnor/BMXNet
|
ed0b201da6667887222b8e4b5f997c4f6b61943d
|
python/mxnet/image/detection.py
|
python
|
DetHorizontalFlipAug._flip_label
|
(self, label)
|
Helper function to flip label.
|
Helper function to flip label.
|
[
"Helper",
"function",
"to",
"flip",
"label",
"."
] |
def _flip_label(self, label):
"""Helper function to flip label."""
tmp = 1.0 - label[:, 1]
label[:, 1] = 1.0 - label[:, 3]
label[:, 3] = tmp
|
[
"def",
"_flip_label",
"(",
"self",
",",
"label",
")",
":",
"tmp",
"=",
"1.0",
"-",
"label",
"[",
":",
",",
"1",
"]",
"label",
"[",
":",
",",
"1",
"]",
"=",
"1.0",
"-",
"label",
"[",
":",
",",
"3",
"]",
"label",
"[",
":",
",",
"3",
"]",
"=",
"tmp"
] |
https://github.com/hpi-xnor/BMXNet/blob/ed0b201da6667887222b8e4b5f997c4f6b61943d/python/mxnet/image/detection.py#L143-L147
|
||
catboost/catboost
|
167f64f237114a4d10b2b4ee42adb4569137debe
|
contrib/python/scipy/py2/scipy/linalg/special_matrices.py
|
python
|
hankel
|
(c, r=None)
|
return as_strided(vals, shape=out_shp, strides=(n, n)).copy()
|
Construct a Hankel matrix.
The Hankel matrix has constant anti-diagonals, with `c` as its
first column and `r` as its last row. If `r` is not given, then
`r = zeros_like(c)` is assumed.
Parameters
----------
c : array_like
First column of the matrix. Whatever the actual shape of `c`, it
will be converted to a 1-D array.
r : array_like, optional
Last row of the matrix. If None, ``r = zeros_like(c)`` is assumed.
r[0] is ignored; the last row of the returned matrix is
``[c[-1], r[1:]]``. Whatever the actual shape of `r`, it will be
converted to a 1-D array.
Returns
-------
A : (len(c), len(r)) ndarray
The Hankel matrix. Dtype is the same as ``(c[0] + r[0]).dtype``.
See Also
--------
toeplitz : Toeplitz matrix
circulant : circulant matrix
Examples
--------
>>> from scipy.linalg import hankel
>>> hankel([1, 17, 99])
array([[ 1, 17, 99],
[17, 99, 0],
[99, 0, 0]])
>>> hankel([1,2,3,4], [4,7,7,8,9])
array([[1, 2, 3, 4, 7],
[2, 3, 4, 7, 7],
[3, 4, 7, 7, 8],
[4, 7, 7, 8, 9]])
|
Construct a Hankel matrix.
|
[
"Construct",
"a",
"Hankel",
"matrix",
"."
] |
def hankel(c, r=None):
"""
Construct a Hankel matrix.
The Hankel matrix has constant anti-diagonals, with `c` as its
first column and `r` as its last row. If `r` is not given, then
`r = zeros_like(c)` is assumed.
Parameters
----------
c : array_like
First column of the matrix. Whatever the actual shape of `c`, it
will be converted to a 1-D array.
r : array_like, optional
Last row of the matrix. If None, ``r = zeros_like(c)`` is assumed.
r[0] is ignored; the last row of the returned matrix is
``[c[-1], r[1:]]``. Whatever the actual shape of `r`, it will be
converted to a 1-D array.
Returns
-------
A : (len(c), len(r)) ndarray
The Hankel matrix. Dtype is the same as ``(c[0] + r[0]).dtype``.
See Also
--------
toeplitz : Toeplitz matrix
circulant : circulant matrix
Examples
--------
>>> from scipy.linalg import hankel
>>> hankel([1, 17, 99])
array([[ 1, 17, 99],
[17, 99, 0],
[99, 0, 0]])
>>> hankel([1,2,3,4], [4,7,7,8,9])
array([[1, 2, 3, 4, 7],
[2, 3, 4, 7, 7],
[3, 4, 7, 7, 8],
[4, 7, 7, 8, 9]])
"""
c = np.asarray(c).ravel()
if r is None:
r = np.zeros_like(c)
else:
r = np.asarray(r).ravel()
# Form a 1D array of values to be used in the matrix, containing `c`
# followed by r[1:].
vals = np.concatenate((c, r[1:]))
# Stride on concatenated array to get hankel matrix
out_shp = len(c), len(r)
n = vals.strides[0]
return as_strided(vals, shape=out_shp, strides=(n, n)).copy()
|
[
"def",
"hankel",
"(",
"c",
",",
"r",
"=",
"None",
")",
":",
"c",
"=",
"np",
".",
"asarray",
"(",
"c",
")",
".",
"ravel",
"(",
")",
"if",
"r",
"is",
"None",
":",
"r",
"=",
"np",
".",
"zeros_like",
"(",
"c",
")",
"else",
":",
"r",
"=",
"np",
".",
"asarray",
"(",
"r",
")",
".",
"ravel",
"(",
")",
"# Form a 1D array of values to be used in the matrix, containing `c`",
"# followed by r[1:].",
"vals",
"=",
"np",
".",
"concatenate",
"(",
"(",
"c",
",",
"r",
"[",
"1",
":",
"]",
")",
")",
"# Stride on concatenated array to get hankel matrix",
"out_shp",
"=",
"len",
"(",
"c",
")",
",",
"len",
"(",
"r",
")",
"n",
"=",
"vals",
".",
"strides",
"[",
"0",
"]",
"return",
"as_strided",
"(",
"vals",
",",
"shape",
"=",
"out_shp",
",",
"strides",
"=",
"(",
"n",
",",
"n",
")",
")",
".",
"copy",
"(",
")"
] |
https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/python/scipy/py2/scipy/linalg/special_matrices.py#L247-L301
|
|
oracle/graaljs
|
36a56e8e993d45fc40939a3a4d9c0c24990720f1
|
graal-nodejs/tools/gyp/pylib/gyp/generator/ninja.py
|
python
|
NinjaWriter.GypPathToNinja
|
(self, path, env=None)
|
return os.path.normpath(os.path.join(self.build_to_base, path))
|
Translate a gyp path to a ninja path, optionally expanding environment
variable references in |path| with |env|.
See the above discourse on path conversions.
|
Translate a gyp path to a ninja path, optionally expanding environment
variable references in |path| with |env|.
|
[
"Translate",
"a",
"gyp",
"path",
"to",
"a",
"ninja",
"path",
"optionally",
"expanding",
"environment",
"variable",
"references",
"in",
"|path|",
"with",
"|env|",
"."
] |
def GypPathToNinja(self, path, env=None):
"""Translate a gyp path to a ninja path, optionally expanding environment
variable references in |path| with |env|.
See the above discourse on path conversions."""
if env:
if self.flavor == "mac":
path = gyp.xcode_emulation.ExpandEnvVars(path, env)
elif self.flavor == "win":
path = gyp.msvs_emulation.ExpandMacros(path, env)
if path.startswith("$!"):
expanded = self.ExpandSpecial(path)
if self.flavor == "win":
expanded = os.path.normpath(expanded)
return expanded
if "$|" in path:
path = self.ExpandSpecial(path)
assert "$" not in path, path
return os.path.normpath(os.path.join(self.build_to_base, path))
|
[
"def",
"GypPathToNinja",
"(",
"self",
",",
"path",
",",
"env",
"=",
"None",
")",
":",
"if",
"env",
":",
"if",
"self",
".",
"flavor",
"==",
"\"mac\"",
":",
"path",
"=",
"gyp",
".",
"xcode_emulation",
".",
"ExpandEnvVars",
"(",
"path",
",",
"env",
")",
"elif",
"self",
".",
"flavor",
"==",
"\"win\"",
":",
"path",
"=",
"gyp",
".",
"msvs_emulation",
".",
"ExpandMacros",
"(",
"path",
",",
"env",
")",
"if",
"path",
".",
"startswith",
"(",
"\"$!\"",
")",
":",
"expanded",
"=",
"self",
".",
"ExpandSpecial",
"(",
"path",
")",
"if",
"self",
".",
"flavor",
"==",
"\"win\"",
":",
"expanded",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"expanded",
")",
"return",
"expanded",
"if",
"\"$|\"",
"in",
"path",
":",
"path",
"=",
"self",
".",
"ExpandSpecial",
"(",
"path",
")",
"assert",
"\"$\"",
"not",
"in",
"path",
",",
"path",
"return",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"build_to_base",
",",
"path",
")",
")"
] |
https://github.com/oracle/graaljs/blob/36a56e8e993d45fc40939a3a4d9c0c24990720f1/graal-nodejs/tools/gyp/pylib/gyp/generator/ninja.py#L300-L318
|
|
kevinlin311tw/cvpr16-deepbit
|
c60fb3233d7d534cfcee9d3ed47d77af437ee32a
|
python/caffe/detector.py
|
python
|
Detector.detect_windows
|
(self, images_windows)
|
return detections
|
Do windowed detection over given images and windows. Windows are
extracted then warped to the input dimensions of the net.
Parameters
----------
images_windows: (image filename, window list) iterable.
context_crop: size of context border to crop in pixels.
Returns
-------
detections: list of {filename: image filename, window: crop coordinates,
predictions: prediction vector} dicts.
|
Do windowed detection over given images and windows. Windows are
extracted then warped to the input dimensions of the net.
|
[
"Do",
"windowed",
"detection",
"over",
"given",
"images",
"and",
"windows",
".",
"Windows",
"are",
"extracted",
"then",
"warped",
"to",
"the",
"input",
"dimensions",
"of",
"the",
"net",
"."
] |
def detect_windows(self, images_windows):
"""
Do windowed detection over given images and windows. Windows are
extracted then warped to the input dimensions of the net.
Parameters
----------
images_windows: (image filename, window list) iterable.
context_crop: size of context border to crop in pixels.
Returns
-------
detections: list of {filename: image filename, window: crop coordinates,
predictions: prediction vector} dicts.
"""
# Extract windows.
window_inputs = []
for image_fname, windows in images_windows:
image = caffe.io.load_image(image_fname).astype(np.float32)
for window in windows:
window_inputs.append(self.crop(image, window))
# Run through the net (warping windows to input dimensions).
in_ = self.inputs[0]
caffe_in = np.zeros((len(window_inputs), window_inputs[0].shape[2])
+ self.blobs[in_].data.shape[2:],
dtype=np.float32)
for ix, window_in in enumerate(window_inputs):
caffe_in[ix] = self.transformer.preprocess(in_, window_in)
out = self.forward_all(**{in_: caffe_in})
predictions = out[self.outputs[0]].squeeze(axis=(2, 3))
# Package predictions with images and windows.
detections = []
ix = 0
for image_fname, windows in images_windows:
for window in windows:
detections.append({
'window': window,
'prediction': predictions[ix],
'filename': image_fname
})
ix += 1
return detections
|
[
"def",
"detect_windows",
"(",
"self",
",",
"images_windows",
")",
":",
"# Extract windows.",
"window_inputs",
"=",
"[",
"]",
"for",
"image_fname",
",",
"windows",
"in",
"images_windows",
":",
"image",
"=",
"caffe",
".",
"io",
".",
"load_image",
"(",
"image_fname",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"for",
"window",
"in",
"windows",
":",
"window_inputs",
".",
"append",
"(",
"self",
".",
"crop",
"(",
"image",
",",
"window",
")",
")",
"# Run through the net (warping windows to input dimensions).",
"in_",
"=",
"self",
".",
"inputs",
"[",
"0",
"]",
"caffe_in",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"window_inputs",
")",
",",
"window_inputs",
"[",
"0",
"]",
".",
"shape",
"[",
"2",
"]",
")",
"+",
"self",
".",
"blobs",
"[",
"in_",
"]",
".",
"data",
".",
"shape",
"[",
"2",
":",
"]",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"for",
"ix",
",",
"window_in",
"in",
"enumerate",
"(",
"window_inputs",
")",
":",
"caffe_in",
"[",
"ix",
"]",
"=",
"self",
".",
"transformer",
".",
"preprocess",
"(",
"in_",
",",
"window_in",
")",
"out",
"=",
"self",
".",
"forward_all",
"(",
"*",
"*",
"{",
"in_",
":",
"caffe_in",
"}",
")",
"predictions",
"=",
"out",
"[",
"self",
".",
"outputs",
"[",
"0",
"]",
"]",
".",
"squeeze",
"(",
"axis",
"=",
"(",
"2",
",",
"3",
")",
")",
"# Package predictions with images and windows.",
"detections",
"=",
"[",
"]",
"ix",
"=",
"0",
"for",
"image_fname",
",",
"windows",
"in",
"images_windows",
":",
"for",
"window",
"in",
"windows",
":",
"detections",
".",
"append",
"(",
"{",
"'window'",
":",
"window",
",",
"'prediction'",
":",
"predictions",
"[",
"ix",
"]",
",",
"'filename'",
":",
"image_fname",
"}",
")",
"ix",
"+=",
"1",
"return",
"detections"
] |
https://github.com/kevinlin311tw/cvpr16-deepbit/blob/c60fb3233d7d534cfcee9d3ed47d77af437ee32a/python/caffe/detector.py#L56-L99
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_carbon/stc.py
|
python
|
StyledTextCtrl.AddSelection
|
(*args, **kwargs)
|
return _stc.StyledTextCtrl_AddSelection(*args, **kwargs)
|
AddSelection(self, int caret, int anchor) -> int
Add a selection
|
AddSelection(self, int caret, int anchor) -> int
|
[
"AddSelection",
"(",
"self",
"int",
"caret",
"int",
"anchor",
")",
"-",
">",
"int"
] |
def AddSelection(*args, **kwargs):
"""
AddSelection(self, int caret, int anchor) -> int
Add a selection
"""
return _stc.StyledTextCtrl_AddSelection(*args, **kwargs)
|
[
"def",
"AddSelection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_stc",
".",
"StyledTextCtrl_AddSelection",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_carbon/stc.py#L6120-L6126
|
|
Xilinx/Vitis-AI
|
fc74d404563d9951b57245443c73bef389f3657f
|
tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/ops/batch_ops.py
|
python
|
batch_function
|
(num_batch_threads,
max_batch_size,
batch_timeout_micros,
allowed_batch_sizes=None,
max_enqueued_batches=10,
autograph=True)
|
return decorator
|
Batches the computation done by the decorated function.
So, for example, in the following code
```python
@batch_function(1, 2, 3)
def layer(a):
return tf.matmul(a, a)
b = layer(w)
```
if more than one session.run call is simultaneously trying to compute `b`
the values of `w` will be gathered, non-deterministically concatenated
along the first axis, and only one thread will run the computation. See the
documentation of the `Batch` op for more details.
Assumes that all arguments of the decorated function are Tensors which will
be batched along their first dimension.
SparseTensor is not supported. The return value of the decorated function
must be a Tensor or a list/tuple of Tensors.
Args:
num_batch_threads: Number of scheduling threads for processing batches
of work. Determines the number of batches processed in parallel.
max_batch_size: Batch sizes will never be bigger than this.
batch_timeout_micros: Maximum number of microseconds to wait before
outputting an incomplete batch.
allowed_batch_sizes: Optional list of allowed batch sizes. If left empty,
does nothing. Otherwise, supplies a list of batch sizes, causing the op
to pad batches up to one of those sizes. The entries must increase
monotonically, and the final entry must equal max_batch_size.
max_enqueued_batches: The maximum depth of the batch queue. Defaults to 10.
autograph: Whether to use autograph to compile python and eager style code
for efficient graph-mode execution.
Returns:
The decorated function will return the unbatched computation output Tensors.
|
Batches the computation done by the decorated function.
|
[
"Batches",
"the",
"computation",
"done",
"by",
"the",
"decorated",
"function",
"."
] |
def batch_function(num_batch_threads,
max_batch_size,
batch_timeout_micros,
allowed_batch_sizes=None,
max_enqueued_batches=10,
autograph=True):
"""Batches the computation done by the decorated function.
So, for example, in the following code
```python
@batch_function(1, 2, 3)
def layer(a):
return tf.matmul(a, a)
b = layer(w)
```
if more than one session.run call is simultaneously trying to compute `b`
the values of `w` will be gathered, non-deterministically concatenated
along the first axis, and only one thread will run the computation. See the
documentation of the `Batch` op for more details.
Assumes that all arguments of the decorated function are Tensors which will
be batched along their first dimension.
SparseTensor is not supported. The return value of the decorated function
must be a Tensor or a list/tuple of Tensors.
Args:
num_batch_threads: Number of scheduling threads for processing batches
of work. Determines the number of batches processed in parallel.
max_batch_size: Batch sizes will never be bigger than this.
batch_timeout_micros: Maximum number of microseconds to wait before
outputting an incomplete batch.
allowed_batch_sizes: Optional list of allowed batch sizes. If left empty,
does nothing. Otherwise, supplies a list of batch sizes, causing the op
to pad batches up to one of those sizes. The entries must increase
monotonically, and the final entry must equal max_batch_size.
max_enqueued_batches: The maximum depth of the batch queue. Defaults to 10.
autograph: Whether to use autograph to compile python and eager style code
for efficient graph-mode execution.
Returns:
The decorated function will return the unbatched computation output Tensors.
"""
def decorator(fn): # pylint: disable=missing-docstring
def decorated(*args): # pylint: disable=missing-docstring
@function.defun(autograph=autograph)
def computation(*computation_args):
return fn(*computation_args)
computation = computation.get_concrete_function(
*[tensor_spec.TensorSpec(dtype=x.dtype, shape=x.shape, name=str(i))
for i, x in enumerate(args)])
with ops.name_scope("batch") as name:
for a in args:
if not isinstance(a, ops.Tensor):
raise ValueError("All arguments to functions decorated with "
"`batch_function` are supposed to be Tensors; "
"found %s" % repr(a))
return gen_batch_ops.batch_function(
num_batch_threads=num_batch_threads,
max_batch_size=max_batch_size,
batch_timeout_micros=batch_timeout_micros,
allowed_batch_sizes=allowed_batch_sizes,
max_enqueued_batches=max_enqueued_batches,
shared_name=name,
f=computation,
in_tensors=list(args),
captured_tensors=computation.captured_inputs,
Tout=[o.dtype for o in computation.outputs])
return decorated
return decorator
|
[
"def",
"batch_function",
"(",
"num_batch_threads",
",",
"max_batch_size",
",",
"batch_timeout_micros",
",",
"allowed_batch_sizes",
"=",
"None",
",",
"max_enqueued_batches",
"=",
"10",
",",
"autograph",
"=",
"True",
")",
":",
"def",
"decorator",
"(",
"fn",
")",
":",
"# pylint: disable=missing-docstring",
"def",
"decorated",
"(",
"*",
"args",
")",
":",
"# pylint: disable=missing-docstring",
"@",
"function",
".",
"defun",
"(",
"autograph",
"=",
"autograph",
")",
"def",
"computation",
"(",
"*",
"computation_args",
")",
":",
"return",
"fn",
"(",
"*",
"computation_args",
")",
"computation",
"=",
"computation",
".",
"get_concrete_function",
"(",
"*",
"[",
"tensor_spec",
".",
"TensorSpec",
"(",
"dtype",
"=",
"x",
".",
"dtype",
",",
"shape",
"=",
"x",
".",
"shape",
",",
"name",
"=",
"str",
"(",
"i",
")",
")",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"args",
")",
"]",
")",
"with",
"ops",
".",
"name_scope",
"(",
"\"batch\"",
")",
"as",
"name",
":",
"for",
"a",
"in",
"args",
":",
"if",
"not",
"isinstance",
"(",
"a",
",",
"ops",
".",
"Tensor",
")",
":",
"raise",
"ValueError",
"(",
"\"All arguments to functions decorated with \"",
"\"`batch_function` are supposed to be Tensors; \"",
"\"found %s\"",
"%",
"repr",
"(",
"a",
")",
")",
"return",
"gen_batch_ops",
".",
"batch_function",
"(",
"num_batch_threads",
"=",
"num_batch_threads",
",",
"max_batch_size",
"=",
"max_batch_size",
",",
"batch_timeout_micros",
"=",
"batch_timeout_micros",
",",
"allowed_batch_sizes",
"=",
"allowed_batch_sizes",
",",
"max_enqueued_batches",
"=",
"max_enqueued_batches",
",",
"shared_name",
"=",
"name",
",",
"f",
"=",
"computation",
",",
"in_tensors",
"=",
"list",
"(",
"args",
")",
",",
"captured_tensors",
"=",
"computation",
".",
"captured_inputs",
",",
"Tout",
"=",
"[",
"o",
".",
"dtype",
"for",
"o",
"in",
"computation",
".",
"outputs",
"]",
")",
"return",
"decorated",
"return",
"decorator"
] |
https://github.com/Xilinx/Vitis-AI/blob/fc74d404563d9951b57245443c73bef389f3657f/tools/Vitis-AI-Quantizer/vai_q_tensorflow1.x/tensorflow/python/ops/batch_ops.py#L32-L111
|
|
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/pathlib.py
|
python
|
PurePath.suffix
|
(self)
|
The final component's last suffix, if any.
This includes the leading period. For example: '.txt'
|
The final component's last suffix, if any.
|
[
"The",
"final",
"component",
"s",
"last",
"suffix",
"if",
"any",
"."
] |
def suffix(self):
"""
The final component's last suffix, if any.
This includes the leading period. For example: '.txt'
"""
name = self.name
i = name.rfind('.')
if 0 < i < len(name) - 1:
return name[i:]
else:
return ''
|
[
"def",
"suffix",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"name",
"i",
"=",
"name",
".",
"rfind",
"(",
"'.'",
")",
"if",
"0",
"<",
"i",
"<",
"len",
"(",
"name",
")",
"-",
"1",
":",
"return",
"name",
"[",
"i",
":",
"]",
"else",
":",
"return",
"''"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/pathlib.py#L804-L815
|
||
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Gems/CloudGemFramework/v1/AWS/common-code/lib/urllib3/__init__.py
|
python
|
disable_warnings
|
(category=exceptions.HTTPWarning)
|
Helper for quickly disabling all urllib3 warnings.
|
Helper for quickly disabling all urllib3 warnings.
|
[
"Helper",
"for",
"quickly",
"disabling",
"all",
"urllib3",
"warnings",
"."
] |
def disable_warnings(category=exceptions.HTTPWarning):
"""
Helper for quickly disabling all urllib3 warnings.
"""
warnings.simplefilter("ignore", category)
|
[
"def",
"disable_warnings",
"(",
"category",
"=",
"exceptions",
".",
"HTTPWarning",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
",",
"category",
")"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemFramework/v1/AWS/common-code/lib/urllib3/__init__.py#L82-L86
|
||
BlzFans/wke
|
b0fa21158312e40c5fbd84682d643022b6c34a93
|
cygwin/lib/python2.6/calendar.py
|
python
|
Calendar.itermonthdays2
|
(self, year, month)
|
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
|
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
|
[
"Like",
"itermonthdates",
"()",
"but",
"will",
"yield",
"(",
"day",
"number",
"weekday",
"number",
")",
"tuples",
".",
"For",
"days",
"outside",
"the",
"specified",
"month",
"the",
"day",
"number",
"is",
"0",
"."
] |
def itermonthdays2(self, year, month):
"""
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
"""
for date in self.itermonthdates(year, month):
if date.month != month:
yield (0, date.weekday())
else:
yield (date.day, date.weekday())
|
[
"def",
"itermonthdays2",
"(",
"self",
",",
"year",
",",
"month",
")",
":",
"for",
"date",
"in",
"self",
".",
"itermonthdates",
"(",
"year",
",",
"month",
")",
":",
"if",
"date",
".",
"month",
"!=",
"month",
":",
"yield",
"(",
"0",
",",
"date",
".",
"weekday",
"(",
")",
")",
"else",
":",
"yield",
"(",
"date",
".",
"day",
",",
"date",
".",
"weekday",
"(",
")",
")"
] |
https://github.com/BlzFans/wke/blob/b0fa21158312e40c5fbd84682d643022b6c34a93/cygwin/lib/python2.6/calendar.py#L168-L177
|
||
miyosuda/TensorFlowAndroidMNIST
|
7b5a4603d2780a8a2834575706e9001977524007
|
jni-build/jni/include/tensorflow/contrib/learn/python/learn/monitors.py
|
python
|
get_default_monitors
|
(loss_op=None, summary_op=None, save_summary_steps=100,
output_dir=None, summary_writer=None)
|
return monitors
|
Returns a default set of typically-used monitors.
Args:
loss_op: `Tensor`, the loss tensor. This will be printed using `PrintTensor`
at the default interval.
summary_op: See `SummarySaver`.
save_summary_steps: See `SummarySaver`.
output_dir: See `SummarySaver`.
summary_writer: See `SummarySaver`.
Returns:
`list` of monitors.
|
Returns a default set of typically-used monitors.
|
[
"Returns",
"a",
"default",
"set",
"of",
"typically",
"-",
"used",
"monitors",
"."
] |
def get_default_monitors(loss_op=None, summary_op=None, save_summary_steps=100,
output_dir=None, summary_writer=None):
"""Returns a default set of typically-used monitors.
Args:
loss_op: `Tensor`, the loss tensor. This will be printed using `PrintTensor`
at the default interval.
summary_op: See `SummarySaver`.
save_summary_steps: See `SummarySaver`.
output_dir: See `SummarySaver`.
summary_writer: See `SummarySaver`.
Returns:
`list` of monitors.
"""
monitors = []
if loss_op is not None:
monitors.append(PrintTensor(tensor_names={"loss": loss_op.name}))
if summary_op is not None:
monitors.append(SummarySaver(summary_op, save_steps=save_summary_steps,
output_dir=output_dir,
summary_writer=summary_writer))
return monitors
|
[
"def",
"get_default_monitors",
"(",
"loss_op",
"=",
"None",
",",
"summary_op",
"=",
"None",
",",
"save_summary_steps",
"=",
"100",
",",
"output_dir",
"=",
"None",
",",
"summary_writer",
"=",
"None",
")",
":",
"monitors",
"=",
"[",
"]",
"if",
"loss_op",
"is",
"not",
"None",
":",
"monitors",
".",
"append",
"(",
"PrintTensor",
"(",
"tensor_names",
"=",
"{",
"\"loss\"",
":",
"loss_op",
".",
"name",
"}",
")",
")",
"if",
"summary_op",
"is",
"not",
"None",
":",
"monitors",
".",
"append",
"(",
"SummarySaver",
"(",
"summary_op",
",",
"save_steps",
"=",
"save_summary_steps",
",",
"output_dir",
"=",
"output_dir",
",",
"summary_writer",
"=",
"summary_writer",
")",
")",
"return",
"monitors"
] |
https://github.com/miyosuda/TensorFlowAndroidMNIST/blob/7b5a4603d2780a8a2834575706e9001977524007/jni-build/jni/include/tensorflow/contrib/learn/python/learn/monitors.py#L764-L786
|
|
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_cocoa/_controls.py
|
python
|
CollapsiblePane.Expand
|
(*args, **kwargs)
|
return _controls_.CollapsiblePane_Expand(*args, **kwargs)
|
Expand(self)
Same as Collapse(False).
|
Expand(self)
|
[
"Expand",
"(",
"self",
")"
] |
def Expand(*args, **kwargs):
"""
Expand(self)
Same as Collapse(False).
"""
return _controls_.CollapsiblePane_Expand(*args, **kwargs)
|
[
"def",
"Expand",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_controls_",
".",
"CollapsiblePane_Expand",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/_controls.py#L7349-L7355
|
|
smilehao/xlua-framework
|
a03801538be2b0e92d39332d445b22caca1ef61f
|
ConfigData/trunk/tools/protobuf-2.5.0/protobuf-2.5.0/python/google/protobuf/service_reflection.py
|
python
|
_ServiceBuilder._CallMethod
|
(self, srvc, method_descriptor,
rpc_controller, request, callback)
|
return method(rpc_controller, request, callback)
|
Calls the method described by a given method descriptor.
Args:
srvc: Instance of the service for which this method is called.
method_descriptor: Descriptor that represent the method to call.
rpc_controller: RPC controller to use for this method's execution.
request: Request protocol message.
callback: A callback to invoke after the method has completed.
|
Calls the method described by a given method descriptor.
|
[
"Calls",
"the",
"method",
"described",
"by",
"a",
"given",
"method",
"descriptor",
"."
] |
def _CallMethod(self, srvc, method_descriptor,
rpc_controller, request, callback):
"""Calls the method described by a given method descriptor.
Args:
srvc: Instance of the service for which this method is called.
method_descriptor: Descriptor that represent the method to call.
rpc_controller: RPC controller to use for this method's execution.
request: Request protocol message.
callback: A callback to invoke after the method has completed.
"""
if method_descriptor.containing_service != self.descriptor:
raise RuntimeError(
'CallMethod() given method descriptor for wrong service type.')
method = getattr(srvc, method_descriptor.name)
return method(rpc_controller, request, callback)
|
[
"def",
"_CallMethod",
"(",
"self",
",",
"srvc",
",",
"method_descriptor",
",",
"rpc_controller",
",",
"request",
",",
"callback",
")",
":",
"if",
"method_descriptor",
".",
"containing_service",
"!=",
"self",
".",
"descriptor",
":",
"raise",
"RuntimeError",
"(",
"'CallMethod() given method descriptor for wrong service type.'",
")",
"method",
"=",
"getattr",
"(",
"srvc",
",",
"method_descriptor",
".",
"name",
")",
"return",
"method",
"(",
"rpc_controller",
",",
"request",
",",
"callback",
")"
] |
https://github.com/smilehao/xlua-framework/blob/a03801538be2b0e92d39332d445b22caca1ef61f/ConfigData/trunk/tools/protobuf-2.5.0/protobuf-2.5.0/python/google/protobuf/service_reflection.py#L156-L171
|
|
catboost/catboost
|
167f64f237114a4d10b2b4ee42adb4569137debe
|
contrib/python/joblib/joblib/externals/cloudpickle/cloudpickle.py
|
python
|
unregister_pickle_by_value
|
(module)
|
Unregister that the input module should be pickled by value.
|
Unregister that the input module should be pickled by value.
|
[
"Unregister",
"that",
"the",
"input",
"module",
"should",
"be",
"pickled",
"by",
"value",
"."
] |
def unregister_pickle_by_value(module):
"""Unregister that the input module should be pickled by value."""
if not isinstance(module, types.ModuleType):
raise ValueError(
f"Input should be a module object, got {str(module)} instead"
)
if module.__name__ not in _PICKLE_BY_VALUE_MODULES:
raise ValueError(f"{module} is not registered for pickle by value")
else:
_PICKLE_BY_VALUE_MODULES.remove(module.__name__)
|
[
"def",
"unregister_pickle_by_value",
"(",
"module",
")",
":",
"if",
"not",
"isinstance",
"(",
"module",
",",
"types",
".",
"ModuleType",
")",
":",
"raise",
"ValueError",
"(",
"f\"Input should be a module object, got {str(module)} instead\"",
")",
"if",
"module",
".",
"__name__",
"not",
"in",
"_PICKLE_BY_VALUE_MODULES",
":",
"raise",
"ValueError",
"(",
"f\"{module} is not registered for pickle by value\"",
")",
"else",
":",
"_PICKLE_BY_VALUE_MODULES",
".",
"remove",
"(",
"module",
".",
"__name__",
")"
] |
https://github.com/catboost/catboost/blob/167f64f237114a4d10b2b4ee42adb4569137debe/contrib/python/joblib/joblib/externals/cloudpickle/cloudpickle.py#L171-L180
|
||
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Tools/build/waf-1.7.13/lmbrwaflib/cryengine_modules.py
|
python
|
CryEditorCore
|
(ctx, *k, **kw)
|
return RunTaskGenerator(ctx, *k, **kw)
|
Wrapper for CryEngine Editor Core component
|
Wrapper for CryEngine Editor Core component
|
[
"Wrapper",
"for",
"CryEngine",
"Editor",
"Core",
"component"
] |
def CryEditorCore(ctx, *k, **kw):
"""
Wrapper for CryEngine Editor Core component
"""
# Initialize the Task Generator
if not InitializeTaskGenerator(ctx, kw):
return
# Append common modules
AppendCommonModules(ctx,kw)
# Setup TaskGenerator specific settings
ctx.set_editor_flags(kw)
apply_cryengine_module_defines(ctx, kw)
SetupRunTimeLibraries(ctx,kw)
append_kw_entry(kw,'msvc_cxxflags',['/EHsc'])
append_kw_entry(kw,'msvc_cflags', ['/EHsc'])
append_kw_entry(kw,'defines',['EDITOR_CORE', 'USE_MEM_ALLOCATOR', 'EDITOR', 'DONT_BAN_STD_STRING', 'FBXSDK_NEW_API=1' ])
LoadSharedSettings(ctx,k,kw)
ConfigureTaskGenerator(ctx, kw)
if not BuildTaskGenerator(ctx, kw):
return None
if ctx.env['PLATFORM'] == 'darwin_x64':
append_kw_entry(kw,'linkflags',['-install_name', '@rpath/lib'+kw['output_file_name']+'.dylib'])
return RunTaskGenerator(ctx, *k, **kw)
|
[
"def",
"CryEditorCore",
"(",
"ctx",
",",
"*",
"k",
",",
"*",
"*",
"kw",
")",
":",
"# Initialize the Task Generator",
"if",
"not",
"InitializeTaskGenerator",
"(",
"ctx",
",",
"kw",
")",
":",
"return",
"# Append common modules",
"AppendCommonModules",
"(",
"ctx",
",",
"kw",
")",
"# Setup TaskGenerator specific settings",
"ctx",
".",
"set_editor_flags",
"(",
"kw",
")",
"apply_cryengine_module_defines",
"(",
"ctx",
",",
"kw",
")",
"SetupRunTimeLibraries",
"(",
"ctx",
",",
"kw",
")",
"append_kw_entry",
"(",
"kw",
",",
"'msvc_cxxflags'",
",",
"[",
"'/EHsc'",
"]",
")",
"append_kw_entry",
"(",
"kw",
",",
"'msvc_cflags'",
",",
"[",
"'/EHsc'",
"]",
")",
"append_kw_entry",
"(",
"kw",
",",
"'defines'",
",",
"[",
"'EDITOR_CORE'",
",",
"'USE_MEM_ALLOCATOR'",
",",
"'EDITOR'",
",",
"'DONT_BAN_STD_STRING'",
",",
"'FBXSDK_NEW_API=1'",
"]",
")",
"LoadSharedSettings",
"(",
"ctx",
",",
"k",
",",
"kw",
")",
"ConfigureTaskGenerator",
"(",
"ctx",
",",
"kw",
")",
"if",
"not",
"BuildTaskGenerator",
"(",
"ctx",
",",
"kw",
")",
":",
"return",
"None",
"if",
"ctx",
".",
"env",
"[",
"'PLATFORM'",
"]",
"==",
"'darwin_x64'",
":",
"append_kw_entry",
"(",
"kw",
",",
"'linkflags'",
",",
"[",
"'-install_name'",
",",
"'@rpath/lib'",
"+",
"kw",
"[",
"'output_file_name'",
"]",
"+",
"'.dylib'",
"]",
")",
"return",
"RunTaskGenerator",
"(",
"ctx",
",",
"*",
"k",
",",
"*",
"*",
"kw",
")"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/build/waf-1.7.13/lmbrwaflib/cryengine_modules.py#L1937-L1968
|
|
windystrife/UnrealEngine_NVIDIAGameWorks
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
Engine/Extras/ThirdPartyNotUE/emsdk/Win64/python/2.7.5.3_64bit/Lib/lib-tk/Tkinter.py
|
python
|
Canvas.itemconfigure
|
(self, tagOrId, cnf=None, **kw)
|
return self._configure(('itemconfigure', tagOrId), cnf, kw)
|
Configure resources of an item TAGORID.
The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method without arguments.
|
Configure resources of an item TAGORID.
|
[
"Configure",
"resources",
"of",
"an",
"item",
"TAGORID",
"."
] |
def itemconfigure(self, tagOrId, cnf=None, **kw):
"""Configure resources of an item TAGORID.
The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method without arguments.
"""
return self._configure(('itemconfigure', tagOrId), cnf, kw)
|
[
"def",
"itemconfigure",
"(",
"self",
",",
"tagOrId",
",",
"cnf",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"return",
"self",
".",
"_configure",
"(",
"(",
"'itemconfigure'",
",",
"tagOrId",
")",
",",
"cnf",
",",
"kw",
")"
] |
https://github.com/windystrife/UnrealEngine_NVIDIAGameWorks/blob/b50e6338a7c5b26374d66306ebc7807541ff815e/Engine/Extras/ThirdPartyNotUE/emsdk/Win64/python/2.7.5.3_64bit/Lib/lib-tk/Tkinter.py#L2342-L2349
|
|
hanpfei/chromium-net
|
392cc1fa3a8f92f42e4071ab6e674d8e0482f83f
|
tools/json_schema_compiler/util_cc_helper.py
|
python
|
UtilCCHelper.PopulateArrayFromListFunction
|
(self, optional)
|
return ('%s::%s') % (_API_UTIL_NAMESPACE, populate_list_fn)
|
Returns the function to turn a list into a vector.
|
Returns the function to turn a list into a vector.
|
[
"Returns",
"the",
"function",
"to",
"turn",
"a",
"list",
"into",
"a",
"vector",
"."
] |
def PopulateArrayFromListFunction(self, optional):
"""Returns the function to turn a list into a vector.
"""
populate_list_fn = ('PopulateOptionalArrayFromList' if optional
else 'PopulateArrayFromList')
return ('%s::%s') % (_API_UTIL_NAMESPACE, populate_list_fn)
|
[
"def",
"PopulateArrayFromListFunction",
"(",
"self",
",",
"optional",
")",
":",
"populate_list_fn",
"=",
"(",
"'PopulateOptionalArrayFromList'",
"if",
"optional",
"else",
"'PopulateArrayFromList'",
")",
"return",
"(",
"'%s::%s'",
")",
"%",
"(",
"_API_UTIL_NAMESPACE",
",",
"populate_list_fn",
")"
] |
https://github.com/hanpfei/chromium-net/blob/392cc1fa3a8f92f42e4071ab6e674d8e0482f83f/tools/json_schema_compiler/util_cc_helper.py#L15-L20
|
|
albertz/openlierox
|
d316c14a8eb57848ef56e9bfa7b23a56f694a51b
|
tools/DedicatedServerVideo/gdata/maps/client.py
|
python
|
MapsClient.get_features
|
(self, map_id, user_id='default', auth_token=None,
desired_class=gdata.maps.data.FeatureFeed, query=None,
**kwargs)
|
return self.get_feed(MAP_FEATURE_URL_TEMPLATE % (user_id, map_id),
auth_token=auth_token, desired_class=desired_class,
query=query, **kwargs)
|
Retrieves a Feature feed for the given map ID/user ID combination.
Args:
map_id: A string representing the ID of the map whose features should be
retrieved.
user_id: An optional string representing the user ID; should be 'default'.
Returns:
A gdata.maps.data.FeatureFeed.
|
Retrieves a Feature feed for the given map ID/user ID combination.
|
[
"Retrieves",
"a",
"Feature",
"feed",
"for",
"the",
"given",
"map",
"ID",
"/",
"user",
"ID",
"combination",
"."
] |
def get_features(self, map_id, user_id='default', auth_token=None,
desired_class=gdata.maps.data.FeatureFeed, query=None,
**kwargs):
"""Retrieves a Feature feed for the given map ID/user ID combination.
Args:
map_id: A string representing the ID of the map whose features should be
retrieved.
user_id: An optional string representing the user ID; should be 'default'.
Returns:
A gdata.maps.data.FeatureFeed.
"""
return self.get_feed(MAP_FEATURE_URL_TEMPLATE % (user_id, map_id),
auth_token=auth_token, desired_class=desired_class,
query=query, **kwargs)
|
[
"def",
"get_features",
"(",
"self",
",",
"map_id",
",",
"user_id",
"=",
"'default'",
",",
"auth_token",
"=",
"None",
",",
"desired_class",
"=",
"gdata",
".",
"maps",
".",
"data",
".",
"FeatureFeed",
",",
"query",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get_feed",
"(",
"MAP_FEATURE_URL_TEMPLATE",
"%",
"(",
"user_id",
",",
"map_id",
")",
",",
"auth_token",
"=",
"auth_token",
",",
"desired_class",
"=",
"desired_class",
",",
"query",
"=",
"query",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/albertz/openlierox/blob/d316c14a8eb57848ef56e9bfa7b23a56f694a51b/tools/DedicatedServerVideo/gdata/maps/client.py#L67-L82
|
|
ChromiumWebApps/chromium
|
c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7
|
tools/telemetry/third_party/websocket-client/websocket.py
|
python
|
WebSocketApp.__init__
|
(self, url, header=[],
on_open=None, on_message=None, on_error=None,
on_close=None, keep_running=True, get_mask_key=None)
|
url: websocket url.
header: custom header for websocket handshake.
on_open: callable object which is called at opening websocket.
this function has one argument. The arugment is this class object.
on_message: callbale object which is called when recieved data.
on_message has 2 arguments.
The 1st arugment is this class object.
The passing 2nd arugment is utf-8 string which we get from the server.
on_error: callable object which is called when we get error.
on_error has 2 arguments.
The 1st arugment is this class object.
The passing 2nd arugment is exception object.
on_close: callable object which is called when closed the connection.
this function has one argument. The arugment is this class object.
keep_running: a boolean flag indicating whether the app's main loop should
keep running, defaults to True
get_mask_key: a callable to produce new mask keys, see the WebSocket.set_mask_key's
docstring for more information
|
url: websocket url.
header: custom header for websocket handshake.
on_open: callable object which is called at opening websocket.
this function has one argument. The arugment is this class object.
on_message: callbale object which is called when recieved data.
on_message has 2 arguments.
The 1st arugment is this class object.
The passing 2nd arugment is utf-8 string which we get from the server.
on_error: callable object which is called when we get error.
on_error has 2 arguments.
The 1st arugment is this class object.
The passing 2nd arugment is exception object.
on_close: callable object which is called when closed the connection.
this function has one argument. The arugment is this class object.
keep_running: a boolean flag indicating whether the app's main loop should
keep running, defaults to True
get_mask_key: a callable to produce new mask keys, see the WebSocket.set_mask_key's
docstring for more information
|
[
"url",
":",
"websocket",
"url",
".",
"header",
":",
"custom",
"header",
"for",
"websocket",
"handshake",
".",
"on_open",
":",
"callable",
"object",
"which",
"is",
"called",
"at",
"opening",
"websocket",
".",
"this",
"function",
"has",
"one",
"argument",
".",
"The",
"arugment",
"is",
"this",
"class",
"object",
".",
"on_message",
":",
"callbale",
"object",
"which",
"is",
"called",
"when",
"recieved",
"data",
".",
"on_message",
"has",
"2",
"arguments",
".",
"The",
"1st",
"arugment",
"is",
"this",
"class",
"object",
".",
"The",
"passing",
"2nd",
"arugment",
"is",
"utf",
"-",
"8",
"string",
"which",
"we",
"get",
"from",
"the",
"server",
".",
"on_error",
":",
"callable",
"object",
"which",
"is",
"called",
"when",
"we",
"get",
"error",
".",
"on_error",
"has",
"2",
"arguments",
".",
"The",
"1st",
"arugment",
"is",
"this",
"class",
"object",
".",
"The",
"passing",
"2nd",
"arugment",
"is",
"exception",
"object",
".",
"on_close",
":",
"callable",
"object",
"which",
"is",
"called",
"when",
"closed",
"the",
"connection",
".",
"this",
"function",
"has",
"one",
"argument",
".",
"The",
"arugment",
"is",
"this",
"class",
"object",
".",
"keep_running",
":",
"a",
"boolean",
"flag",
"indicating",
"whether",
"the",
"app",
"s",
"main",
"loop",
"should",
"keep",
"running",
"defaults",
"to",
"True",
"get_mask_key",
":",
"a",
"callable",
"to",
"produce",
"new",
"mask",
"keys",
"see",
"the",
"WebSocket",
".",
"set_mask_key",
"s",
"docstring",
"for",
"more",
"information"
] |
def __init__(self, url, header=[],
on_open=None, on_message=None, on_error=None,
on_close=None, keep_running=True, get_mask_key=None):
"""
url: websocket url.
header: custom header for websocket handshake.
on_open: callable object which is called at opening websocket.
this function has one argument. The arugment is this class object.
on_message: callbale object which is called when recieved data.
on_message has 2 arguments.
The 1st arugment is this class object.
The passing 2nd arugment is utf-8 string which we get from the server.
on_error: callable object which is called when we get error.
on_error has 2 arguments.
The 1st arugment is this class object.
The passing 2nd arugment is exception object.
on_close: callable object which is called when closed the connection.
this function has one argument. The arugment is this class object.
keep_running: a boolean flag indicating whether the app's main loop should
keep running, defaults to True
get_mask_key: a callable to produce new mask keys, see the WebSocket.set_mask_key's
docstring for more information
"""
self.url = url
self.header = header
self.on_open = on_open
self.on_message = on_message
self.on_error = on_error
self.on_close = on_close
self.keep_running = keep_running
self.get_mask_key = get_mask_key
self.sock = None
|
[
"def",
"__init__",
"(",
"self",
",",
"url",
",",
"header",
"=",
"[",
"]",
",",
"on_open",
"=",
"None",
",",
"on_message",
"=",
"None",
",",
"on_error",
"=",
"None",
",",
"on_close",
"=",
"None",
",",
"keep_running",
"=",
"True",
",",
"get_mask_key",
"=",
"None",
")",
":",
"self",
".",
"url",
"=",
"url",
"self",
".",
"header",
"=",
"header",
"self",
".",
"on_open",
"=",
"on_open",
"self",
".",
"on_message",
"=",
"on_message",
"self",
".",
"on_error",
"=",
"on_error",
"self",
".",
"on_close",
"=",
"on_close",
"self",
".",
"keep_running",
"=",
"keep_running",
"self",
".",
"get_mask_key",
"=",
"get_mask_key",
"self",
".",
"sock",
"=",
"None"
] |
https://github.com/ChromiumWebApps/chromium/blob/c7361d39be8abd1574e6ce8957c8dbddd4c6ccf7/tools/telemetry/third_party/websocket-client/websocket.py#L773-L804
|
||
SpaceNetChallenge/BuildingDetectors
|
3def3c44b5847c744cd2f3356182892d92496579
|
qinhaifang/src/evalTools/script/preprocess_space_net_data.py
|
python
|
save_raw_label_img_worker
|
(image_name)
|
docstring for save_raw_label_img_worker
|
docstring for save_raw_label_img_worker
|
[
"docstring",
"for",
"save_raw_label_img_worker"
] |
def save_raw_label_img_worker(image_name):
"""docstring for save_raw_label_img_worker
"""
try:
image_id = '_'.join(image_name.split('.')[0].split('_')[1:])
image_name = os.path.join(setting.PIC_3BAND_DIR, image_name)
label_map_file = os.path.join(setting.LABEL_MAP_DIR,
'{}.npy'.format(image_id))
img = sk.imread(image_name)
label_map = np.load(label_map_file)
label_img = img_util.create_label_img(img, label_map)
save_file = os.path.join(setting.RAW_LABEL_IMG_DIR, '{}_raw_label.png'.format(image_id))
sk.imsave(save_file, label_img)
return image_id, 'Done'
except Exception as e:
logging.warning('Generate_Label_Map Exception[{}] image_id[{}]'.format(e,
image_id))
return image_id, e
|
[
"def",
"save_raw_label_img_worker",
"(",
"image_name",
")",
":",
"try",
":",
"image_id",
"=",
"'_'",
".",
"join",
"(",
"image_name",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
".",
"split",
"(",
"'_'",
")",
"[",
"1",
":",
"]",
")",
"image_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"setting",
".",
"PIC_3BAND_DIR",
",",
"image_name",
")",
"label_map_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"setting",
".",
"LABEL_MAP_DIR",
",",
"'{}.npy'",
".",
"format",
"(",
"image_id",
")",
")",
"img",
"=",
"sk",
".",
"imread",
"(",
"image_name",
")",
"label_map",
"=",
"np",
".",
"load",
"(",
"label_map_file",
")",
"label_img",
"=",
"img_util",
".",
"create_label_img",
"(",
"img",
",",
"label_map",
")",
"save_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"setting",
".",
"RAW_LABEL_IMG_DIR",
",",
"'{}_raw_label.png'",
".",
"format",
"(",
"image_id",
")",
")",
"sk",
".",
"imsave",
"(",
"save_file",
",",
"label_img",
")",
"return",
"image_id",
",",
"'Done'",
"except",
"Exception",
"as",
"e",
":",
"logging",
".",
"warning",
"(",
"'Generate_Label_Map Exception[{}] image_id[{}]'",
".",
"format",
"(",
"e",
",",
"image_id",
")",
")",
"return",
"image_id",
",",
"e"
] |
https://github.com/SpaceNetChallenge/BuildingDetectors/blob/3def3c44b5847c744cd2f3356182892d92496579/qinhaifang/src/evalTools/script/preprocess_space_net_data.py#L85-L102
|
||
wxWidgets/wxPython-Classic
|
19571e1ae65f1ac445f5491474121998c97a1bf0
|
src/osx_cocoa/_misc.py
|
python
|
DateTime.GetNextWeekDay
|
(*args, **kwargs)
|
return _misc_.DateTime_GetNextWeekDay(*args, **kwargs)
|
GetNextWeekDay(self, int weekday) -> DateTime
|
GetNextWeekDay(self, int weekday) -> DateTime
|
[
"GetNextWeekDay",
"(",
"self",
"int",
"weekday",
")",
"-",
">",
"DateTime"
] |
def GetNextWeekDay(*args, **kwargs):
"""GetNextWeekDay(self, int weekday) -> DateTime"""
return _misc_.DateTime_GetNextWeekDay(*args, **kwargs)
|
[
"def",
"GetNextWeekDay",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_misc_",
".",
"DateTime_GetNextWeekDay",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] |
https://github.com/wxWidgets/wxPython-Classic/blob/19571e1ae65f1ac445f5491474121998c97a1bf0/src/osx_cocoa/_misc.py#L3857-L3859
|
|
tangzhenyu/Scene-Text-Understanding
|
0f7ffc7aea5971a50cdc03d33d0a41075285948b
|
ctpn_crnn_ocr/CTPN/src/detectors.py
|
python
|
TextDetector.detect
|
(self, im)
|
return text_lines
|
Detecting texts from an image
:return: the bounding boxes of the detected texts
|
Detecting texts from an image
:return: the bounding boxes of the detected texts
|
[
"Detecting",
"texts",
"from",
"an",
"image",
":",
"return",
":",
"the",
"bounding",
"boxes",
"of",
"the",
"detected",
"texts"
] |
def detect(self, im):
"""
Detecting texts from an image
:return: the bounding boxes of the detected texts
"""
text_proposals, scores=self.text_proposal_detector.detect(im, cfg.MEAN)
keep_inds=np.where(scores>cfg.TEXT_PROPOSALS_MIN_SCORE)[0]
text_proposals, scores=text_proposals[keep_inds], scores[keep_inds]
sorted_indices=np.argsort(scores.ravel())[::-1]
text_proposals, scores=text_proposals[sorted_indices], scores[sorted_indices]
# nms for text proposals
keep_inds=nms(np.hstack((text_proposals, scores)), cfg.TEXT_PROPOSALS_NMS_THRESH)
text_proposals, scores=text_proposals[keep_inds], scores[keep_inds]
scores=normalize(scores)
text_lines=self.text_proposal_connector.get_text_lines(text_proposals, scores, im.shape[:2])
keep_inds=self.filter_boxes(text_lines)
text_lines=text_lines[keep_inds]
if text_lines.shape[0]!=0:
keep_inds=nms(text_lines, cfg.TEXT_LINE_NMS_THRESH)
text_lines=text_lines[keep_inds]
return text_lines
|
[
"def",
"detect",
"(",
"self",
",",
"im",
")",
":",
"text_proposals",
",",
"scores",
"=",
"self",
".",
"text_proposal_detector",
".",
"detect",
"(",
"im",
",",
"cfg",
".",
"MEAN",
")",
"keep_inds",
"=",
"np",
".",
"where",
"(",
"scores",
">",
"cfg",
".",
"TEXT_PROPOSALS_MIN_SCORE",
")",
"[",
"0",
"]",
"text_proposals",
",",
"scores",
"=",
"text_proposals",
"[",
"keep_inds",
"]",
",",
"scores",
"[",
"keep_inds",
"]",
"sorted_indices",
"=",
"np",
".",
"argsort",
"(",
"scores",
".",
"ravel",
"(",
")",
")",
"[",
":",
":",
"-",
"1",
"]",
"text_proposals",
",",
"scores",
"=",
"text_proposals",
"[",
"sorted_indices",
"]",
",",
"scores",
"[",
"sorted_indices",
"]",
"# nms for text proposals",
"keep_inds",
"=",
"nms",
"(",
"np",
".",
"hstack",
"(",
"(",
"text_proposals",
",",
"scores",
")",
")",
",",
"cfg",
".",
"TEXT_PROPOSALS_NMS_THRESH",
")",
"text_proposals",
",",
"scores",
"=",
"text_proposals",
"[",
"keep_inds",
"]",
",",
"scores",
"[",
"keep_inds",
"]",
"scores",
"=",
"normalize",
"(",
"scores",
")",
"text_lines",
"=",
"self",
".",
"text_proposal_connector",
".",
"get_text_lines",
"(",
"text_proposals",
",",
"scores",
",",
"im",
".",
"shape",
"[",
":",
"2",
"]",
")",
"keep_inds",
"=",
"self",
".",
"filter_boxes",
"(",
"text_lines",
")",
"text_lines",
"=",
"text_lines",
"[",
"keep_inds",
"]",
"if",
"text_lines",
".",
"shape",
"[",
"0",
"]",
"!=",
"0",
":",
"keep_inds",
"=",
"nms",
"(",
"text_lines",
",",
"cfg",
".",
"TEXT_LINE_NMS_THRESH",
")",
"text_lines",
"=",
"text_lines",
"[",
"keep_inds",
"]",
"return",
"text_lines"
] |
https://github.com/tangzhenyu/Scene-Text-Understanding/blob/0f7ffc7aea5971a50cdc03d33d0a41075285948b/ctpn_crnn_ocr/CTPN/src/detectors.py#L34-L61
|
|
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/dateutil/zoneinfo/__init__.py
|
python
|
gettz
|
(name)
|
return _CLASS_ZONE_INSTANCE[0].zones.get(name)
|
This retrieves a time zone from the local zoneinfo tarball that is packaged
with dateutil.
:param name:
An IANA-style time zone name, as found in the zoneinfo file.
:return:
Returns a :class:`dateutil.tz.tzfile` time zone object.
.. warning::
It is generally inadvisable to use this function, and it is only
provided for API compatibility with earlier versions. This is *not*
equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
time zone based on the inputs, favoring system zoneinfo. This is ONLY
for accessing the dateutil-specific zoneinfo (which may be out of
date compared to the system zoneinfo).
.. deprecated:: 2.6
If you need to use a specific zoneinfofile over the system zoneinfo,
instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
:func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.
Use :func:`get_zonefile_instance` to retrieve an instance of the
dateutil-provided zoneinfo.
|
This retrieves a time zone from the local zoneinfo tarball that is packaged
with dateutil.
|
[
"This",
"retrieves",
"a",
"time",
"zone",
"from",
"the",
"local",
"zoneinfo",
"tarball",
"that",
"is",
"packaged",
"with",
"dateutil",
"."
] |
def gettz(name):
"""
This retrieves a time zone from the local zoneinfo tarball that is packaged
with dateutil.
:param name:
An IANA-style time zone name, as found in the zoneinfo file.
:return:
Returns a :class:`dateutil.tz.tzfile` time zone object.
.. warning::
It is generally inadvisable to use this function, and it is only
provided for API compatibility with earlier versions. This is *not*
equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
time zone based on the inputs, favoring system zoneinfo. This is ONLY
for accessing the dateutil-specific zoneinfo (which may be out of
date compared to the system zoneinfo).
.. deprecated:: 2.6
If you need to use a specific zoneinfofile over the system zoneinfo,
instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
:func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.
Use :func:`get_zonefile_instance` to retrieve an instance of the
dateutil-provided zoneinfo.
"""
warnings.warn("zoneinfo.gettz() will be removed in future versions, "
"to use the dateutil-provided zoneinfo files, instantiate a "
"ZoneInfoFile object and use ZoneInfoFile.zones.get() "
"instead. See the documentation for details.",
DeprecationWarning)
if len(_CLASS_ZONE_INSTANCE) == 0:
_CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
return _CLASS_ZONE_INSTANCE[0].zones.get(name)
|
[
"def",
"gettz",
"(",
"name",
")",
":",
"warnings",
".",
"warn",
"(",
"\"zoneinfo.gettz() will be removed in future versions, \"",
"\"to use the dateutil-provided zoneinfo files, instantiate a \"",
"\"ZoneInfoFile object and use ZoneInfoFile.zones.get() \"",
"\"instead. See the documentation for details.\"",
",",
"DeprecationWarning",
")",
"if",
"len",
"(",
"_CLASS_ZONE_INSTANCE",
")",
"==",
"0",
":",
"_CLASS_ZONE_INSTANCE",
".",
"append",
"(",
"ZoneInfoFile",
"(",
"getzoneinfofile_stream",
"(",
")",
")",
")",
"return",
"_CLASS_ZONE_INSTANCE",
"[",
"0",
"]",
".",
"zones",
".",
"get",
"(",
"name",
")"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Gems/CloudGemMetric/v1/AWS/python/windows/Lib/dateutil/zoneinfo/__init__.py#L109-L144
|
|
google/llvm-propeller
|
45c226984fe8377ebfb2ad7713c680d652ba678d
|
llvm/bindings/python/llvm/core.py
|
python
|
Module.datalayout
|
(self, new_data_layout)
|
new_data_layout is a string.
|
new_data_layout is a string.
|
[
"new_data_layout",
"is",
"a",
"string",
"."
] |
def datalayout(self, new_data_layout):
"""new_data_layout is a string."""
lib.LLVMSetDataLayout(self, new_data_layout)
|
[
"def",
"datalayout",
"(",
"self",
",",
"new_data_layout",
")",
":",
"lib",
".",
"LLVMSetDataLayout",
"(",
"self",
",",
"new_data_layout",
")"
] |
https://github.com/google/llvm-propeller/blob/45c226984fe8377ebfb2ad7713c680d652ba678d/llvm/bindings/python/llvm/core.py#L212-L214
|
||
mantidproject/mantid
|
03deeb89254ec4289edb8771e0188c2090a02f32
|
qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/Common/fitting_widgets/basic_fitting/basic_fitting_view.py
|
python
|
BasicFittingView.plot_guess_start_x
|
(self, value: float)
|
Sets the selected start X.
|
Sets the selected start X.
|
[
"Sets",
"the",
"selected",
"start",
"X",
"."
] |
def plot_guess_start_x(self, value: float) -> None:
"""Sets the selected start X."""
self.fit_function_options.plot_guess_start_x = value
|
[
"def",
"plot_guess_start_x",
"(",
"self",
",",
"value",
":",
"float",
")",
"->",
"None",
":",
"self",
".",
"fit_function_options",
".",
"plot_guess_start_x",
"=",
"value"
] |
https://github.com/mantidproject/mantid/blob/03deeb89254ec4289edb8771e0188c2090a02f32/qt/python/mantidqtinterfaces/mantidqtinterfaces/Muon/GUI/Common/fitting_widgets/basic_fitting/basic_fitting_view.py#L237-L239
|
||
mindspore-ai/mindspore
|
fb8fd3338605bb34fa5cea054e535a8b1d753fab
|
mindspore/python/mindspore/ops/operations/math_ops.py
|
python
|
BesselI0e.__init__
|
(self)
|
Initialize BesselI0e
|
Initialize BesselI0e
|
[
"Initialize",
"BesselI0e"
] |
def __init__(self):
"""Initialize BesselI0e"""
self.init_prim_io_names(inputs=['x'], outputs='output')
|
[
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"init_prim_io_names",
"(",
"inputs",
"=",
"[",
"'x'",
"]",
",",
"outputs",
"=",
"'output'",
")"
] |
https://github.com/mindspore-ai/mindspore/blob/fb8fd3338605bb34fa5cea054e535a8b1d753fab/mindspore/python/mindspore/ops/operations/math_ops.py#L5065-L5067
|
||
pmq20/node-packer
|
12c46c6e44fbc14d9ee645ebd17d5296b324f7e0
|
lts/tools/inspector_protocol/jinja2/runtime.py
|
python
|
markup_join
|
(seq)
|
return concat(buf)
|
Concatenation that escapes if necessary and converts to unicode.
|
Concatenation that escapes if necessary and converts to unicode.
|
[
"Concatenation",
"that",
"escapes",
"if",
"necessary",
"and",
"converts",
"to",
"unicode",
"."
] |
def markup_join(seq):
"""Concatenation that escapes if necessary and converts to unicode."""
buf = []
iterator = imap(soft_unicode, seq)
for arg in iterator:
buf.append(arg)
if hasattr(arg, '__html__'):
return Markup(u'').join(chain(buf, iterator))
return concat(buf)
|
[
"def",
"markup_join",
"(",
"seq",
")",
":",
"buf",
"=",
"[",
"]",
"iterator",
"=",
"imap",
"(",
"soft_unicode",
",",
"seq",
")",
"for",
"arg",
"in",
"iterator",
":",
"buf",
".",
"append",
"(",
"arg",
")",
"if",
"hasattr",
"(",
"arg",
",",
"'__html__'",
")",
":",
"return",
"Markup",
"(",
"u''",
")",
".",
"join",
"(",
"chain",
"(",
"buf",
",",
"iterator",
")",
")",
"return",
"concat",
"(",
"buf",
")"
] |
https://github.com/pmq20/node-packer/blob/12c46c6e44fbc14d9ee645ebd17d5296b324f7e0/lts/tools/inspector_protocol/jinja2/runtime.py#L43-L51
|
|
aws/lumberyard
|
f85344403c1c2e77ec8c75deb2c116e97b713217
|
dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/cgitb.py
|
python
|
scanvars
|
(reader, frame, locals)
|
return vars
|
Scan one logical line of Python and look up values of variables used.
|
Scan one logical line of Python and look up values of variables used.
|
[
"Scan",
"one",
"logical",
"line",
"of",
"Python",
"and",
"look",
"up",
"values",
"of",
"variables",
"used",
"."
] |
def scanvars(reader, frame, locals):
"""Scan one logical line of Python and look up values of variables used."""
vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__
for ttype, token, start, end, line in tokenize.generate_tokens(reader):
if ttype == tokenize.NEWLINE: break
if ttype == tokenize.NAME and token not in keyword.kwlist:
if lasttoken == '.':
if parent is not __UNDEF__:
value = getattr(parent, token, __UNDEF__)
vars.append((prefix + token, prefix, value))
else:
where, value = lookup(token, frame, locals)
vars.append((token, where, value))
elif token == '.':
prefix += lasttoken + '.'
parent = value
else:
parent, prefix = None, ''
lasttoken = token
return vars
|
[
"def",
"scanvars",
"(",
"reader",
",",
"frame",
",",
"locals",
")",
":",
"vars",
",",
"lasttoken",
",",
"parent",
",",
"prefix",
",",
"value",
"=",
"[",
"]",
",",
"None",
",",
"None",
",",
"''",
",",
"__UNDEF__",
"for",
"ttype",
",",
"token",
",",
"start",
",",
"end",
",",
"line",
"in",
"tokenize",
".",
"generate_tokens",
"(",
"reader",
")",
":",
"if",
"ttype",
"==",
"tokenize",
".",
"NEWLINE",
":",
"break",
"if",
"ttype",
"==",
"tokenize",
".",
"NAME",
"and",
"token",
"not",
"in",
"keyword",
".",
"kwlist",
":",
"if",
"lasttoken",
"==",
"'.'",
":",
"if",
"parent",
"is",
"not",
"__UNDEF__",
":",
"value",
"=",
"getattr",
"(",
"parent",
",",
"token",
",",
"__UNDEF__",
")",
"vars",
".",
"append",
"(",
"(",
"prefix",
"+",
"token",
",",
"prefix",
",",
"value",
")",
")",
"else",
":",
"where",
",",
"value",
"=",
"lookup",
"(",
"token",
",",
"frame",
",",
"locals",
")",
"vars",
".",
"append",
"(",
"(",
"token",
",",
"where",
",",
"value",
")",
")",
"elif",
"token",
"==",
"'.'",
":",
"prefix",
"+=",
"lasttoken",
"+",
"'.'",
"parent",
"=",
"value",
"else",
":",
"parent",
",",
"prefix",
"=",
"None",
",",
"''",
"lasttoken",
"=",
"token",
"return",
"vars"
] |
https://github.com/aws/lumberyard/blob/f85344403c1c2e77ec8c75deb2c116e97b713217/dev/Tools/Python/3.7.10/linux_x64/lib/python3.7/cgitb.py#L80-L99
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.