nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py
python
DDLCompiler.visit_create_sequence
(self, create)
return text
[]
def visit_create_sequence(self, create): text = "CREATE SEQUENCE %s" % \ self.preparer.format_sequence(create.element) if create.element.increment is not None: text += " INCREMENT BY %d" % create.element.increment if create.element.start is not None: text += " START WITH %d" % create.element.start if create.element.minvalue is not None: text += " MINVALUE %d" % create.element.minvalue if create.element.maxvalue is not None: text += " MAXVALUE %d" % create.element.maxvalue if create.element.nominvalue is not None: text += " NO MINVALUE" if create.element.nomaxvalue is not None: text += " NO MAXVALUE" if create.element.cache is not None: text += " CACHE %d" % create.element.cache if create.element.order is True: text += " ORDER" if create.element.cycle is not None: text += " CYCLE" return text
[ "def", "visit_create_sequence", "(", "self", ",", "create", ")", ":", "text", "=", "\"CREATE SEQUENCE %s\"", "%", "self", ".", "preparer", ".", "format_sequence", "(", "create", ".", "element", ")", "if", "create", ".", "element", ".", "increment", "is", "no...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py#L2628-L2649
barseghyanartur/django-dash
dc00513b65e017c40f278a0a7df2a18ec8da9bc3
src/dash/templatetags/dash_tags.py
python
GetDashPluginNode.__init__
(self, dashboard_entry, as_var=None)
[]
def __init__(self, dashboard_entry, as_var=None): self.dashboard_entry = dashboard_entry self.as_var = as_var
[ "def", "__init__", "(", "self", ",", "dashboard_entry", ",", "as_var", "=", "None", ")", ":", "self", ".", "dashboard_entry", "=", "dashboard_entry", "self", ".", "as_var", "=", "as_var" ]
https://github.com/barseghyanartur/django-dash/blob/dc00513b65e017c40f278a0a7df2a18ec8da9bc3/src/dash/templatetags/dash_tags.py#L35-L37
KalleHallden/AutoTimer
2d954216700c4930baa154e28dbddc34609af7ce
env/lib/python2.7/site-packages/pkg_resources/__init__.py
python
ZipProvider._get_eager_resources
(self)
return self.eagers
[]
def _get_eager_resources(self): if self.eagers is None: eagers = [] for name in ('native_libs.txt', 'eager_resources.txt'): if self.has_metadata(name): eagers.extend(self.get_metadata_lines(name)) self.eagers = eagers return self.eagers
[ "def", "_get_eager_resources", "(", "self", ")", ":", "if", "self", ".", "eagers", "is", "None", ":", "eagers", "=", "[", "]", "for", "name", "in", "(", "'native_libs.txt'", ",", "'eager_resources.txt'", ")", ":", "if", "self", ".", "has_metadata", "(", ...
https://github.com/KalleHallden/AutoTimer/blob/2d954216700c4930baa154e28dbddc34609af7ce/env/lib/python2.7/site-packages/pkg_resources/__init__.py#L1826-L1833
mchristopher/PokemonGo-DesktopMap
ec37575f2776ee7d64456e2a1f6b6b78830b4fe0
app/pywin/Lib/distutils/sysconfig.py
python
customize_compiler
(compiler)
Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile.
Do any platform-specific customization of a CCompiler instance.
[ "Do", "any", "platform", "-", "specific", "customization", "of", "a", "CCompiler", "instance", "." ]
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars # Use get_config_var() to ensure _config_vars is initialized. if not get_config_var('CUSTOMIZED_OSX_COMPILER'): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if (sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc)): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
[ "def", "customize_compiler", "(", "compiler", ")", ":", "if", "compiler", ".", "compiler_type", "==", "\"unix\"", ":", "if", "sys", ".", "platform", "==", "\"darwin\"", ":", "# Perform first-time customization of compiler-related", "# config vars on OS X now that we know we...
https://github.com/mchristopher/PokemonGo-DesktopMap/blob/ec37575f2776ee7d64456e2a1f6b6b78830b4fe0/app/pywin/Lib/distutils/sysconfig.py#L151-L222
PyMVPA/PyMVPA
76c476b3de8264b0bb849bf226da5674d659564e
mvpa2/measures/anova.py
python
OneWayAnova.__init__
(self, space='targets', **kwargs)
Parameters ---------- space : str What samples attribute to use as targets (labels).
Parameters ---------- space : str What samples attribute to use as targets (labels).
[ "Parameters", "----------", "space", ":", "str", "What", "samples", "attribute", "to", "use", "as", "targets", "(", "labels", ")", "." ]
def __init__(self, space='targets', **kwargs): """ Parameters ---------- space : str What samples attribute to use as targets (labels). """ # set auto-train flag since we have nothing special to be done # so by default auto train kwargs['auto_train'] = kwargs.get('auto_train', True) FeaturewiseMeasure.__init__(self, space=space, **kwargs)
[ "def", "__init__", "(", "self", ",", "space", "=", "'targets'", ",", "*", "*", "kwargs", ")", ":", "# set auto-train flag since we have nothing special to be done", "# so by default auto train", "kwargs", "[", "'auto_train'", "]", "=", "kwargs", ".", "get", "(", "'a...
https://github.com/PyMVPA/PyMVPA/blob/76c476b3de8264b0bb849bf226da5674d659564e/mvpa2/measures/anova.py#L48-L58
eriklindernoren/ML-From-Scratch
a2806c6732eee8d27762edd6d864e0c179d8e9e8
mlfromscratch/supervised_learning/decision_tree.py
python
DecisionTree.print_tree
(self, tree=None, indent=" ")
Recursively print the decision tree
Recursively print the decision tree
[ "Recursively", "print", "the", "decision", "tree" ]
def print_tree(self, tree=None, indent=" "): """ Recursively print the decision tree """ if not tree: tree = self.root # If we're at leaf => print the label if tree.value is not None: print (tree.value) # Go deeper down the tree else: # Print test print ("%s:%s? " % (tree.feature_i, tree.threshold)) # Print the true scenario print ("%sT->" % (indent), end="") self.print_tree(tree.true_branch, indent + indent) # Print the false scenario print ("%sF->" % (indent), end="") self.print_tree(tree.false_branch, indent + indent)
[ "def", "print_tree", "(", "self", ",", "tree", "=", "None", ",", "indent", "=", "\" \"", ")", ":", "if", "not", "tree", ":", "tree", "=", "self", ".", "root", "# If we're at leaf => print the label", "if", "tree", ".", "value", "is", "not", "None", ":", ...
https://github.com/eriklindernoren/ML-From-Scratch/blob/a2806c6732eee8d27762edd6d864e0c179d8e9e8/mlfromscratch/supervised_learning/decision_tree.py#L167-L184
ring04h/weakfilescan
b1a3066e3fdcd60b8ecf635526f49cb5ad603064
libs/requests/cookies.py
python
MockRequest.get_origin_req_host
(self)
return self.get_host()
[]
def get_origin_req_host(self): return self.get_host()
[ "def", "get_origin_req_host", "(", "self", ")", ":", "return", "self", ".", "get_host", "(", ")" ]
https://github.com/ring04h/weakfilescan/blob/b1a3066e3fdcd60b8ecf635526f49cb5ad603064/libs/requests/cookies.py#L44-L45
openstack/barbican
a9d2b133c8dc3307974f119f9a2b23a4ba82e8ce
barbican/api/controllers/secrets.py
python
SecretController._lookup
(self, sub_resource, *remainder)
[]
def _lookup(self, sub_resource, *remainder): if sub_resource == 'acl': return acls.SecretACLsController(self.secret), remainder elif sub_resource == 'metadata': if len(remainder) == 0 or remainder == ('',): return secretmeta.SecretMetadataController(self.secret), \ remainder else: request_method = pecan.request.method allowed_methods = ['GET', 'PUT', 'DELETE'] if request_method in allowed_methods: return secretmeta.SecretMetadatumController(self.secret), \ remainder else: # methods cannot be handled at controller level pecan.abort(405) else: # only 'acl' and 'metadata' as sub-resource is supported pecan.abort(404)
[ "def", "_lookup", "(", "self", ",", "sub_resource", ",", "*", "remainder", ")", ":", "if", "sub_resource", "==", "'acl'", ":", "return", "acls", ".", "SecretACLsController", "(", "self", ".", "secret", ")", ",", "remainder", "elif", "sub_resource", "==", "...
https://github.com/openstack/barbican/blob/a9d2b133c8dc3307974f119f9a2b23a4ba82e8ce/barbican/api/controllers/secrets.py#L85-L104
mgear-dev/mgear
06ddc26c5adb5eab07ca470c7fafa77404c8a1de
scripts/mgear/maya/rigbits/sdk_io.py
python
mirrorSDKkeys
(node, attributes=[], invertDriver=True, invertDriven=True)
mirror/invert the values on the specified node and attrs, get the sdks and invert those values Args: node (pynode): node being driven to have its sdk values inverted attributes (list, optional): attrs to be inverted invertDriver (bool, optional): should the driver, "time" values be inverted invertDriven (bool, optional): should the driven, "value" values be inverted
mirror/invert the values on the specified node and attrs, get the sdks and invert those values
[ "mirror", "/", "invert", "the", "values", "on", "the", "specified", "node", "and", "attrs", "get", "the", "sdks", "and", "invert", "those", "values" ]
def mirrorSDKkeys(node, attributes=[], invertDriver=True, invertDriven=True): """mirror/invert the values on the specified node and attrs, get the sdks and invert those values Args: node (pynode): node being driven to have its sdk values inverted attributes (list, optional): attrs to be inverted invertDriver (bool, optional): should the driver, "time" values be inverted invertDriven (bool, optional): should the driven, "value" values be inverted """ sourceSDKInfo = getConnectedSDKs(node) sourceSDKInfo.extend(getMultiDriverSDKs(node)) if not attributes: attributes = pm.listAttr(node, connectable=True) for source, dest in sourceSDKInfo: if dest.plugAttr(longName=True) not in attributes: continue animCurve = source.node() invertKeyValues(animCurve, invertDriver=invertDriver, invertDriven=invertDriven)
[ "def", "mirrorSDKkeys", "(", "node", ",", "attributes", "=", "[", "]", ",", "invertDriver", "=", "True", ",", "invertDriven", "=", "True", ")", ":", "sourceSDKInfo", "=", "getConnectedSDKs", "(", "node", ")", "sourceSDKInfo", ".", "extend", "(", "getMultiDri...
https://github.com/mgear-dev/mgear/blob/06ddc26c5adb5eab07ca470c7fafa77404c8a1de/scripts/mgear/maya/rigbits/sdk_io.py#L378-L400
rembo10/headphones
b3199605be1ebc83a7a8feab6b1e99b64014187c
lib/cherrypy/_cptools.py
python
Toolbox.__enter__
(self)
return populate
Populate request.toolmaps from tools specified in config.
Populate request.toolmaps from tools specified in config.
[ "Populate", "request", ".", "toolmaps", "from", "tools", "specified", "in", "config", "." ]
def __enter__(self): """Populate request.toolmaps from tools specified in config.""" cherrypy.serving.request.toolmaps[self.namespace] = map = {} def populate(k, v): toolname, arg = k.split(".", 1) bucket = map.setdefault(toolname, {}) bucket[arg] = v return populate
[ "def", "__enter__", "(", "self", ")", ":", "cherrypy", ".", "serving", ".", "request", ".", "toolmaps", "[", "self", ".", "namespace", "]", "=", "map", "=", "{", "}", "def", "populate", "(", "k", ",", "v", ")", ":", "toolname", ",", "arg", "=", "...
https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/cherrypy/_cptools.py#L444-L452
salabim/salabim
e0de846b042daf2dc71aaf43d8adc6486b57f376
salabim_exp.py
python
exp140
()
[]
def exp140(): @yc def funcr(event): yc(event.keysym) class X(sim.Component): def process(self): passrr env = sim.Environment(trace=True) env.animate(True) env.root.bind("r", funcr) env.root.bind("s", funcr) env.root.bind("t", funcr) env.root.bind("<Down>", funcr) env.root.bind("<Up>", funcr) env.root.bind("<Right>", funcr) env.root.bind("<Left>", funcr) env.root.bind("<Next>", funcr) env.root.bind("<Prior>", funcr) env.run(1000)
[ "def", "exp140", "(", ")", ":", "@", "yc", "def", "funcr", "(", "event", ")", ":", "yc", "(", "event", ".", "keysym", ")", "class", "X", "(", "sim", ".", "Component", ")", ":", "def", "process", "(", "self", ")", ":", "passrr", "env", "=", "sim...
https://github.com/salabim/salabim/blob/e0de846b042daf2dc71aaf43d8adc6486b57f376/salabim_exp.py#L356-L378
Cimbali/pympress
d376c92ede603a305738bd38f0c50b2f68c58fcf
pympress/scribble.py
python
parse_color
(text)
return color
Transform a string to a Gdk object in a single function call Args: text (`str`): A string describing a color Returns: :class:`~Gdk.RGBA`: A new color object parsed from the string
Transform a string to a Gdk object in a single function call
[ "Transform", "a", "string", "to", "a", "Gdk", "object", "in", "a", "single", "function", "call" ]
def parse_color(text): """ Transform a string to a Gdk object in a single function call Args: text (`str`): A string describing a color Returns: :class:`~Gdk.RGBA`: A new color object parsed from the string """ color = Gdk.RGBA() color.parse(text) return color
[ "def", "parse_color", "(", "text", ")", ":", "color", "=", "Gdk", ".", "RGBA", "(", ")", "color", ".", "parse", "(", "text", ")", "return", "color" ]
https://github.com/Cimbali/pympress/blob/d376c92ede603a305738bd38f0c50b2f68c58fcf/pympress/scribble.py#L272-L283
inventree/InvenTree
4a5e4a88ac3e91d64a21e8cab3708ecbc6e2bd8b
InvenTree/stock/serializers.py
python
StockAddSerializer.save
(self)
[]
def save(self): request = self.context['request'] data = self.validated_data notes = data.get('notes', '') with transaction.atomic(): for item in data['items']: stock_item = item['pk'] quantity = item['quantity'] stock_item.add_stock( quantity, request.user, notes=notes )
[ "def", "save", "(", "self", ")", ":", "request", "=", "self", ".", "context", "[", "'request'", "]", "data", "=", "self", ".", "validated_data", "notes", "=", "data", ".", "get", "(", "'notes'", ",", "''", ")", "with", "transaction", ".", "atomic", "...
https://github.com/inventree/InvenTree/blob/4a5e4a88ac3e91d64a21e8cab3708ecbc6e2bd8b/InvenTree/stock/serializers.py#L916-L933
airaria/TextBrewer
14c0b2c805d2b0f6ddd44683c6ca7d117ee94880
examples/cmrc2018_example/pytorch_pretrained_bert/tokenization.py
python
BertTokenizer.convert_tokens_to_ids
(self, tokens)
return ids
Converts a sequence of tokens into ids using the vocab.
Converts a sequence of tokens into ids using the vocab.
[ "Converts", "a", "sequence", "of", "tokens", "into", "ids", "using", "the", "vocab", "." ]
def convert_tokens_to_ids(self, tokens): """Converts a sequence of tokens into ids using the vocab.""" ids = [] for token in tokens: ids.append(self.vocab[token]) if len(ids) > self.max_len: logger.warning( "Token indices sequence length is longer than the specified maximum " " sequence length for this BERT model ({} > {}). Running this" " sequence through BERT will result in indexing errors".format(len(ids), self.max_len) ) return ids
[ "def", "convert_tokens_to_ids", "(", "self", ",", "tokens", ")", ":", "ids", "=", "[", "]", "for", "token", "in", "tokens", ":", "ids", ".", "append", "(", "self", ".", "vocab", "[", "token", "]", ")", "if", "len", "(", "ids", ")", ">", "self", "...
https://github.com/airaria/TextBrewer/blob/14c0b2c805d2b0f6ddd44683c6ca7d117ee94880/examples/cmrc2018_example/pytorch_pretrained_bert/tokenization.py#L117-L128
larryhastings/gilectomy
4315ec3f1d6d4f813cc82ce27a24e7f784dbfc1a
Lib/_osx_support.py
python
_supports_universal_builds
()
return bool(osx_version >= (10, 4)) if osx_version else False
Returns True if universal builds are supported on this system
Returns True if universal builds are supported on this system
[ "Returns", "True", "if", "universal", "builds", "are", "supported", "on", "this", "system" ]
def _supports_universal_builds(): """Returns True if universal builds are supported on this system""" # As an approximation, we assume that if we are running on 10.4 or above, # then we are running with an Xcode environment that supports universal # builds, in particular -isysroot and -arch arguments to the compiler. This # is in support of allowing 10.4 universal builds to run on 10.3.x systems. osx_version = _get_system_version() if osx_version: try: osx_version = tuple(int(i) for i in osx_version.split('.')) except ValueError: osx_version = '' return bool(osx_version >= (10, 4)) if osx_version else False
[ "def", "_supports_universal_builds", "(", ")", ":", "# As an approximation, we assume that if we are running on 10.4 or above,", "# then we are running with an Xcode environment that supports universal", "# builds, in particular -isysroot and -arch arguments to the compiler. This", "# is in support ...
https://github.com/larryhastings/gilectomy/blob/4315ec3f1d6d4f813cc82ce27a24e7f784dbfc1a/Lib/_osx_support.py#L128-L141
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/compressor/parser/html5lib.py
python
Html5LibParser.elem_name
(self, elem)
return elem.tag
[]
def elem_name(self, elem): if '}' in elem.tag: return elem.tag.split('}')[1] return elem.tag
[ "def", "elem_name", "(", "self", ",", "elem", ")", ":", "if", "'}'", "in", "elem", ".", "tag", ":", "return", "elem", ".", "tag", ".", "split", "(", "'}'", ")", "[", "1", "]", "return", "elem", ".", "tag" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/compressor/parser/html5lib.py#L50-L53
jython/jython3
def4f8ec47cb7a9c799ea4c745f12badf92c5769
Lib/datetime.py
python
date.isocalendar
(self)
return year, week+1, day+1
Return a 3-tuple containing ISO year, week number, and weekday. The first ISO week of the year is the (Mon-Sun) week containing the year's first Thursday; everything else derives from that. The first week is 1; Monday is 1 ... Sunday is 7. ISO calendar algorithm taken from http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
Return a 3-tuple containing ISO year, week number, and weekday.
[ "Return", "a", "3", "-", "tuple", "containing", "ISO", "year", "week", "number", "and", "weekday", "." ]
def isocalendar(self): """Return a 3-tuple containing ISO year, week number, and weekday. The first ISO week of the year is the (Mon-Sun) week containing the year's first Thursday; everything else derives from that. The first week is 1; Monday is 1 ... Sunday is 7. ISO calendar algorithm taken from http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm """ year = self._year week1monday = _isoweek1monday(year) today = _ymd2ord(self._year, self._month, self._day) # Internally, week and day have origin 0 week, day = divmod(today - week1monday, 7) if week < 0: year -= 1 week1monday = _isoweek1monday(year) week, day = divmod(today - week1monday, 7) elif week >= 52: if today >= _isoweek1monday(year+1): year += 1 week = 0 return year, week+1, day+1
[ "def", "isocalendar", "(", "self", ")", ":", "year", "=", "self", ".", "_year", "week1monday", "=", "_isoweek1monday", "(", "year", ")", "today", "=", "_ymd2ord", "(", "self", ".", "_year", ",", "self", ".", "_month", ",", "self", ".", "_day", ")", "...
https://github.com/jython/jython3/blob/def4f8ec47cb7a9c799ea4c745f12badf92c5769/Lib/datetime.py#L1031-L1056
quantumlib/OpenFermion-Cirq
655b00fee21c94cc96c343c63f7c52ea1aa329dc
openfermioncirq/variational/objective.py
python
VariationalObjective.value
(self, circuit_output: Union[cirq.TrialResult, cirq.SimulationTrialResult, numpy.ndarray] )
The evaluation function for a circuit output. A variational quantum algorithm will attempt to minimize this value over possible settings of the parameters.
The evaluation function for a circuit output.
[ "The", "evaluation", "function", "for", "a", "circuit", "output", "." ]
def value(self, circuit_output: Union[cirq.TrialResult, cirq.SimulationTrialResult, numpy.ndarray] ) -> float: """The evaluation function for a circuit output. A variational quantum algorithm will attempt to minimize this value over possible settings of the parameters. """
[ "def", "value", "(", "self", ",", "circuit_output", ":", "Union", "[", "cirq", ".", "TrialResult", ",", "cirq", ".", "SimulationTrialResult", ",", "numpy", ".", "ndarray", "]", ")", "->", "float", ":" ]
https://github.com/quantumlib/OpenFermion-Cirq/blob/655b00fee21c94cc96c343c63f7c52ea1aa329dc/openfermioncirq/variational/objective.py#L38-L47
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/preview/trusted_comms/current_call.py
python
CurrentCallList.__repr__
(self)
return '<Twilio.Preview.TrustedComms.CurrentCallList>'
Provide a friendly representation :returns: Machine friendly representation :rtype: str
Provide a friendly representation
[ "Provide", "a", "friendly", "representation" ]
def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Preview.TrustedComms.CurrentCallList>'
[ "def", "__repr__", "(", "self", ")", ":", "return", "'<Twilio.Preview.TrustedComms.CurrentCallList>'" ]
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/preview/trusted_comms/current_call.py#L54-L61
tensorflow/tensor2tensor
2a33b152d7835af66a6d20afe7961751047e28dd
tensor2tensor/layers/transformer_memory.py
python
TransformerMemory.__init__
(self, batch_size, key_depth, val_depth, memory_size, sharpen_factor=1., name="neural_memory")
Initialize the memory object. Args: batch_size: the batch size. key_depth: the depth of the memory keys. val_depth: the depth of the memory values. memory_size: the number of items in the memory. sharpen_factor: the sharpen_factor for addressing the memory. name: the optional variable scope.
Initialize the memory object.
[ "Initialize", "the", "memory", "object", "." ]
def __init__(self, batch_size, key_depth, val_depth, memory_size, sharpen_factor=1., name="neural_memory"): """Initialize the memory object. Args: batch_size: the batch size. key_depth: the depth of the memory keys. val_depth: the depth of the memory values. memory_size: the number of items in the memory. sharpen_factor: the sharpen_factor for addressing the memory. name: the optional variable scope. """ self.name = name self.batch_size = batch_size self.key_depth = key_depth self.val_depth = val_depth self.memory_size = memory_size self.sharpen_factor = sharpen_factor with tf.variable_scope(name): self.segment_number = tf.get_variable( "segment_number", [self.batch_size], dtype=tf.int32, trainable=False, initializer=tf.constant_initializer(100000)) self.mem_vals = tf.get_variable( "memvals", [self.batch_size, self.memory_size, self.val_depth], dtype=tf.float32, trainable=False, initializer=tf.constant_initializer(.0)) self.mean_logits = tf.get_variable( "meanlogits", [self.batch_size, self.memory_size], dtype=tf.float32, trainable=False, initializer=tf.constant_initializer(.0))
[ "def", "__init__", "(", "self", ",", "batch_size", ",", "key_depth", ",", "val_depth", ",", "memory_size", ",", "sharpen_factor", "=", "1.", ",", "name", "=", "\"neural_memory\"", ")", ":", "self", ".", "name", "=", "name", "self", ".", "batch_size", "=", ...
https://github.com/tensorflow/tensor2tensor/blob/2a33b152d7835af66a6d20afe7961751047e28dd/tensor2tensor/layers/transformer_memory.py#L194-L224
ambakick/Person-Detection-and-Tracking
f925394ac29b5cf321f1ce89a71b193381519a0b
metrics/coco_tools.py
python
COCOEvalWrapper.GetCategory
(self, category_id)
return self.cocoGt.cats[category_id]
Fetches dictionary holding category information given category id. Args: category_id: integer id Returns: dictionary holding 'id', 'name'.
Fetches dictionary holding category information given category id.
[ "Fetches", "dictionary", "holding", "category", "information", "given", "category", "id", "." ]
def GetCategory(self, category_id): """Fetches dictionary holding category information given category id. Args: category_id: integer id Returns: dictionary holding 'id', 'name'. """ return self.cocoGt.cats[category_id]
[ "def", "GetCategory", "(", "self", ",", "category_id", ")", ":", "return", "self", ".", "cocoGt", ".", "cats", "[", "category_id", "]" ]
https://github.com/ambakick/Person-Detection-and-Tracking/blob/f925394ac29b5cf321f1ce89a71b193381519a0b/metrics/coco_tools.py#L174-L182
jacoxu/encoder_decoder
6829c3bc42105aedfd1b8a81c81be19df4326c0a
keras/utils/generic_utils.py
python
Progbar.__init__
(self, target, width=30, verbose=1)
@param target: total number of steps expected
[]
def __init__(self, target, width=30, verbose=1): ''' @param target: total number of steps expected ''' self.width = width self.target = target self.sum_values = {} self.unique_values = [] self.start = time.time() self.total_width = 0 self.seen_so_far = 0 self.verbose = verbose
[ "def", "__init__", "(", "self", ",", "target", ",", "width", "=", "30", ",", "verbose", "=", "1", ")", ":", "self", ".", "width", "=", "width", "self", ".", "target", "=", "target", "self", ".", "sum_values", "=", "{", "}", "self", ".", "unique_val...
https://github.com/jacoxu/encoder_decoder/blob/6829c3bc42105aedfd1b8a81c81be19df4326c0a/keras/utils/generic_utils.py#L29-L40
gramps-project/gramps
04d4651a43eb210192f40a9f8c2bad8ee8fa3753
gramps/plugins/view/mediaview.py
python
MediaView.drag_data_received
(self, widget, context, x, y, sel_data, info, time)
Handle the standard gtk interface for drag_data_received. If the selection data is define, extract the value from sel_data.data, and decide if this is a move or a reorder. The only data we accept on mediaview is dropping a file, so URI_LIST. We assume this is what we obtain
Handle the standard gtk interface for drag_data_received.
[ "Handle", "the", "standard", "gtk", "interface", "for", "drag_data_received", "." ]
def drag_data_received(self, widget, context, x, y, sel_data, info, time): """ Handle the standard gtk interface for drag_data_received. If the selection data is define, extract the value from sel_data.data, and decide if this is a move or a reorder. The only data we accept on mediaview is dropping a file, so URI_LIST. We assume this is what we obtain """ if not sel_data: return files = sel_data.get_uris() photo = None for file in files: protocol, site, mfile, j, k, l = urlparse(file) if protocol == "file": name = url2pathname(mfile) mime = get_type(name) if not is_valid_type(mime): return photo = Media() self.uistate.set_busy_cursor(True) photo.set_checksum(create_checksum(name)) self.uistate.set_busy_cursor(False) base_dir = str(media_path(self.dbstate.db)) if os.path.exists(base_dir): name = relative_path(name, base_dir) photo.set_path(name) photo.set_mime_type(mime) basename = os.path.basename(name) (root, ext) = os.path.splitext(basename) photo.set_description(root) with DbTxn(_("Drag Media Object"), self.dbstate.db) as trans: self.dbstate.db.add_media(photo, trans) if photo: self.uistate.set_active(photo.handle, "Media") widget.emit_stop_by_name('drag_data_received')
[ "def", "drag_data_received", "(", "self", ",", "widget", ",", "context", ",", "x", ",", "y", ",", "sel_data", ",", "info", ",", "time", ")", ":", "if", "not", "sel_data", ":", "return", "files", "=", "sel_data", ".", "get_uris", "(", ")", "photo", "=...
https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/plugins/view/mediaview.py#L161-L201
dragonfly/dragonfly
a579b5eadf452e23b07d4caf27b402703b0012b7
dragonfly/exd/experiment_caller.py
python
FunctionCaller.__init__
(self, func, *args, **kwargs)
Constructor.
Constructor.
[ "Constructor", "." ]
def __init__(self, func, *args, **kwargs): """ Constructor. """ self.func = func super(FunctionCaller, self).__init__(func, *args, **kwargs)
[ "def", "__init__", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "func", "=", "func", "super", "(", "FunctionCaller", ",", "self", ")", ".", "__init__", "(", "func", ",", "*", "args", ",", "*", "*", ...
https://github.com/dragonfly/dragonfly/blob/a579b5eadf452e23b07d4caf27b402703b0012b7/dragonfly/exd/experiment_caller.py#L603-L606
google-research/fixmatch
d4985a158065947dba803e626ee9a6721709c570
third_party/auto_augment/augmentations.py
python
_posterize_impl
(pil_img, level)
return ImageOps.posterize(pil_img.convert('RGB'), 4 - level).convert('RGBA')
Applies PIL Posterize to `pil_img`.
Applies PIL Posterize to `pil_img`.
[ "Applies", "PIL", "Posterize", "to", "pil_img", "." ]
def _posterize_impl(pil_img, level): """Applies PIL Posterize to `pil_img`.""" level = int_parameter(level, 4) return ImageOps.posterize(pil_img.convert('RGB'), 4 - level).convert('RGBA')
[ "def", "_posterize_impl", "(", "pil_img", ",", "level", ")", ":", "level", "=", "int_parameter", "(", "level", ",", "4", ")", "return", "ImageOps", ".", "posterize", "(", "pil_img", ".", "convert", "(", "'RGB'", ")", ",", "4", "-", "level", ")", ".", ...
https://github.com/google-research/fixmatch/blob/d4985a158065947dba803e626ee9a6721709c570/third_party/auto_augment/augmentations.py#L265-L268
google/apitools
31cad2d904f356872d2965687e84b2d87ee2cdd3
apitools/base/py/base_api.py
python
BaseApiService.__ConstructRelativePath
(self, method_config, request, relative_path=None)
return util.ExpandRelativePath(method_config, params, relative_path=relative_path)
Determine the relative path for request.
Determine the relative path for request.
[ "Determine", "the", "relative", "path", "for", "request", "." ]
def __ConstructRelativePath(self, method_config, request, relative_path=None): """Determine the relative path for request.""" python_param_names = util.MapParamNames( method_config.path_params, type(request)) params = dict([(param, getattr(request, param, None)) for param in python_param_names]) params = util.MapRequestParams(params, type(request)) return util.ExpandRelativePath(method_config, params, relative_path=relative_path)
[ "def", "__ConstructRelativePath", "(", "self", ",", "method_config", ",", "request", ",", "relative_path", "=", "None", ")", ":", "python_param_names", "=", "util", ".", "MapParamNames", "(", "method_config", ".", "path_params", ",", "type", "(", "request", ")",...
https://github.com/google/apitools/blob/31cad2d904f356872d2965687e84b2d87ee2cdd3/apitools/base/py/base_api.py#L581-L590
meduza-corp/interstellar
40a801ccd7856491726f5a126621d9318cabe2e1
gsutil/gslib/commands/rsync.py
python
CleanUpTempFiles
()
Cleans up temp files. This function allows the main (RunCommand) function to clean up at end of operation, or if gsutil rsync is interrupted (e.g., via ^C). This is necessary because tempfile.NamedTemporaryFile doesn't allow the created file to be re-opened in read mode on Windows, so we have to use tempfile.mkstemp, which doesn't automatically delete temp files.
Cleans up temp files.
[ "Cleans", "up", "temp", "files", "." ]
def CleanUpTempFiles(): """Cleans up temp files. This function allows the main (RunCommand) function to clean up at end of operation, or if gsutil rsync is interrupted (e.g., via ^C). This is necessary because tempfile.NamedTemporaryFile doesn't allow the created file to be re-opened in read mode on Windows, so we have to use tempfile.mkstemp, which doesn't automatically delete temp files. """ try: for fname in _tmp_files: os.unlink(fname) except: # pylint: disable=bare-except pass
[ "def", "CleanUpTempFiles", "(", ")", ":", "try", ":", "for", "fname", "in", "_tmp_files", ":", "os", ".", "unlink", "(", "fname", ")", "except", ":", "# pylint: disable=bare-except", "pass" ]
https://github.com/meduza-corp/interstellar/blob/40a801ccd7856491726f5a126621d9318cabe2e1/gsutil/gslib/commands/rsync.py#L298-L311
phonopy/phonopy
816586d0ba8177482ecf40e52f20cbdee2260d51
phonopy/spectrum/dynamic_structure_factor.py
python
DynamicStructureFactor.__next__
(self)
Calculate at next q-point.
Calculate at next q-point.
[ "Calculate", "at", "next", "q", "-", "point", "." ]
def __next__(self): """Calculate at next q-point.""" if self._q_count == len(self._Qpoints): self._q_count = 0 raise StopIteration else: S = self._run_at_Q() self.dynamic_structure_factors[self._q_count] = S self._q_count += 1 return S
[ "def", "__next__", "(", "self", ")", ":", "if", "self", ".", "_q_count", "==", "len", "(", "self", ".", "_Qpoints", ")", ":", "self", ".", "_q_count", "=", "0", "raise", "StopIteration", "else", ":", "S", "=", "self", ".", "_run_at_Q", "(", ")", "s...
https://github.com/phonopy/phonopy/blob/816586d0ba8177482ecf40e52f20cbdee2260d51/phonopy/spectrum/dynamic_structure_factor.py#L183-L192
apple/ccs-calendarserver
13c706b985fb728b9aab42dc0fef85aae21921c3
txdav/caldav/datastore/index_file.py
python
AbstractCalendarIndex.__init__
(self, resource)
@param resource: the L{CalDAVResource} resource to index. C{resource} must be a calendar collection (ie. C{resource.isPseudoCalendarCollection()} returns C{True}.)
[]
def __init__(self, resource): """ @param resource: the L{CalDAVResource} resource to index. C{resource} must be a calendar collection (ie. C{resource.isPseudoCalendarCollection()} returns C{True}.) """ self.resource = resource db_filename = self.resource.fp.child(db_basename).path super(AbstractCalendarIndex, self).__init__(db_filename, False) self.resource._txn.postCommit(self._db_close) self.resource._txn.postAbort(self._db_close)
[ "def", "__init__", "(", "self", ",", "resource", ")", ":", "self", ".", "resource", "=", "resource", "db_filename", "=", "self", ".", "resource", ".", "fp", ".", "child", "(", "db_basename", ")", ".", "path", "super", "(", "AbstractCalendarIndex", ",", "...
https://github.com/apple/ccs-calendarserver/blob/13c706b985fb728b9aab42dc0fef85aae21921c3/txdav/caldav/datastore/index_file.py#L88-L99
ethereum/trinity
6383280c5044feb06695ac2f7bc1100b7bcf4fe0
trinity/components/builtin/metrics/registry.py
python
HostMetricsRegistry.dump_metrics
(self)
return metrics
[]
def dump_metrics(self) -> Dict[str, Dict[str, Any]]: metrics = super().dump_metrics() for key in metrics: # We want every metric to include a 'host' identifier to be able to filter accordingly metrics[key]['host'] = self.host return metrics
[ "def", "dump_metrics", "(", "self", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "metrics", "=", "super", "(", ")", ".", "dump_metrics", "(", ")", "for", "key", "in", "metrics", ":", "# We want every metric to incl...
https://github.com/ethereum/trinity/blob/6383280c5044feb06695ac2f7bc1100b7bcf4fe0/trinity/components/builtin/metrics/registry.py#L24-L31
smart-mobile-software/gitstack
d9fee8f414f202143eb6e620529e8e5539a2af56
python/Lib/lib-tk/Tkinter.py
python
BooleanVar.__init__
(self, master=None, value=None, name=None)
Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained.
Construct a boolean variable.
[ "Construct", "a", "boolean", "variable", "." ]
def __init__(self, master=None, value=None, name=None): """Construct a boolean variable. MASTER can be given as master widget. VALUE is an optional value (defaults to False) NAME is an optional Tcl name (defaults to PY_VARnum). If NAME matches an existing variable and VALUE is omitted then the existing value is retained. """ Variable.__init__(self, master, value, name)
[ "def", "__init__", "(", "self", ",", "master", "=", "None", ",", "value", "=", "None", ",", "name", "=", "None", ")", ":", "Variable", ".", "__init__", "(", "self", ",", "master", ",", "value", ",", "name", ")" ]
https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/lib-tk/Tkinter.py#L307-L317
NeuromorphicProcessorProject/snn_toolbox
a85ada7b5d060500703285ef8a68f06ea1ffda65
snntoolbox/datasets/aedat/ImportAedatHeaders.py
python
import_aedat_headers
(info)
return info
Parameters ---------- info : Returns -------
[]
def import_aedat_headers(info): # Start from the beginning of the file (should not be necessary) """ Parameters ---------- info : Returns ------- """ info['fileHandle'].seek(0) # From version 3.1 there is an unambiguous division between header and # data: A line like this: '#!END-HEADER\r\n' # However, for all older files there's no guarantee that the first # character in the data would not be '#'. We ignore this - we look in the # next unread position and if it is not # we exit. info['xml'] = {} # Assume the format version is 1 unless a header of the version number is # found info['formatVersion'] = 1 # Read the first character is_comment = '#' in str(info['fileHandle'].read(1)) while is_comment: # Read the rest of the line line = info['fileHandle'].readline().decode('utf-8') # File format if line[: 8] == '!AER-DAT': info['formatVersion'] = int(line[8: -4]) # Pick out the source # Version 2.0 encodes it like this: if line[: 9] == ' AEChip: ': # Ignore everything the class path and only use what follows the # final dot start_prefix = line.rfind('.') info['sourceFromFile'] = import_aedat_basic_source_name( line[start_prefix + 1:]) # Version 3.0 encodes it like this # The following ignores any trace of previous sources # (prefixed with a minus sign) if line[: 8] == ' Source ': start_prefix = line.find(':') # There should be only one colon if 'sourceFromFile' in info: pass # One source has already been added; convert to a cell array if # it has not already been done # NOT HANDLED YET: # if ~iscell(info.sourceFromFile) # info.sourceFromFile = {info.sourceFromFile}; # info.sourceFromFile = [info.sourceFromFile line[start_prefix # + 2 : ]; else: info['sourceFromFile'] = line[start_prefix + 2:] # Pick out date and time of recording # Version 2.0 encodes it like this: # # created Thu Dec 03 14:47:00 CET 2015 if line[: 9] == ' created ': info['dateTime'] = line[9:] # Version 3.0 encodes it like this: # # Start-Time: #Y-#m-#d #H:#M:#S (TZ#z)\r\n if line[: 13] == ' Start-Time: ': info['dateTime'] = line[13:] """# Parse xml, adding it to output as a cell array, in a field called 'xml'. # This is done by maintaining a cell array which is inside out as it is # constructed - as a level of the hierarchy is descended, everything is # pushed down into the first position of a cell array, and as the # hierarchy is ascended, the first node is popped back up and the nodes # that have been added to the right are pushed down inside it. # If <node> then descend hierarchy - do this by taking the existing # cell array and putting it into another cell array if strncmp(line, '<node', 5) nameOfNode = line(length('<node name="') + 1 : end - length('">')); info.xml = {info.xml nameOfNode}; # </node> - ascend hierarchy - take everything to the right of the # initial cell array and put it inside the inital cell array elseif strncmp(line, '</node>', 7) parent = info.xml{1}; child = info.xml(2:end); info.xml = [parent {child}]; # <entry> - Add a field to the struct elseif strncmp(line, '<entry ', 7) # Find the division between key and value endOfKey = strfind(line, '" value="'); key = line(length('<entry key="') + 1 : endOfKey - 1); value = line(endOfKey + length('" value="') : end - length('"/>')); info.xml{end + 1} = {key value}; end # Gets the next line, including line ending chars line = native2unicode(fgets(info.fileHandle)); """ # Read ahead the first character of the next line to complete the # while loop is_comment = '#' in str(info['fileHandle'].read(1)) # We have read ahead one byte looking for '#', and not found it. # Now wind back one to be in the right place to start reading info['fileHandle'].seek(-1, 1) info['beginningOfDataPointer'] = info['fileHandle'].tell() """ # If a device is specified in input, does it match the derived source? if isfield(info, 'source') info.source = importAedat_basicSourceName(info.source); if isfield(info, 'sourceFromFile') && ~strcmp(info.source, info.sourceFromFile) fprintf('The source given as input, "#s", doesn''t match the source declared in the file, "#s"; assuming the source given as input.\n', inputSource, info.Source); end elseif ~isfield(info, 'sourceFromFile') # If no source was detected, assume it was from a DVS128 info.source = 'Dvs128'; else info.source = info.sourceFromFile; end if isfield(info, 'sourceFromFile') # Clean up rmfield(info, 'sourceFromFile'); end """ return info
[ "def", "import_aedat_headers", "(", "info", ")", ":", "# Start from the beginning of the file (should not be necessary)", "info", "[", "'fileHandle'", "]", ".", "seek", "(", "0", ")", "# From version 3.1 there is an unambiguous division between header and", "# data: A line like thi...
https://github.com/NeuromorphicProcessorProject/snn_toolbox/blob/a85ada7b5d060500703285ef8a68f06ea1ffda65/snntoolbox/datasets/aedat/ImportAedatHeaders.py#L19-L158
BillBillBillBill/Tickeys-linux
2df31b8665004c58a5d4ab05277f245267d96364
tickeys/kivy_32/kivy/uix/textinput.py
python
TextInput.cancel_selection
(self)
Cancel current selection (if any).
Cancel current selection (if any).
[ "Cancel", "current", "selection", "(", "if", "any", ")", "." ]
def cancel_selection(self): '''Cancel current selection (if any). ''' self._selection_from = self._selection_to = self.cursor_index() self._selection = False self._selection_finished = True self._selection_touch = None self._trigger_update_graphics()
[ "def", "cancel_selection", "(", "self", ")", ":", "self", ".", "_selection_from", "=", "self", ".", "_selection_to", "=", "self", ".", "cursor_index", "(", ")", "self", ".", "_selection", "=", "False", "self", ".", "_selection_finished", "=", "True", "self",...
https://github.com/BillBillBillBill/Tickeys-linux/blob/2df31b8665004c58a5d4ab05277f245267d96364/tickeys/kivy_32/kivy/uix/textinput.py#L916-L923
couchbase/couchbase-python-client
58ccfd42af320bde6b733acf094fd5a4cf34e0ad
couchbase/search.py
python
_genprop_str
(*apipaths, **kwargs)
return _genprop(unicode, *apipaths, **kwargs)
Convenience function to return a string property in which the value is converted to a string
Convenience function to return a string property in which the value is converted to a string
[ "Convenience", "function", "to", "return", "a", "string", "property", "in", "which", "the", "value", "is", "converted", "to", "a", "string" ]
def _genprop_str(*apipaths, **kwargs): """ Convenience function to return a string property in which the value is converted to a string """ return _genprop(unicode, *apipaths, **kwargs)
[ "def", "_genprop_str", "(", "*", "apipaths", ",", "*", "*", "kwargs", ")", ":", "return", "_genprop", "(", "unicode", ",", "*", "apipaths", ",", "*", "*", "kwargs", ")" ]
https://github.com/couchbase/couchbase-python-client/blob/58ccfd42af320bde6b733acf094fd5a4cf34e0ad/couchbase/search.py#L99-L104
smart-mobile-software/gitstack
d9fee8f414f202143eb6e620529e8e5539a2af56
python/Lib/distutils/command/bdist_rpm.py
python
bdist_rpm._make_spec_file
(self)
return spec_file
Generate the text of an RPM spec file and return it as a list of strings (one per line).
Generate the text of an RPM spec file and return it as a list of strings (one per line).
[ "Generate", "the", "text", "of", "an", "RPM", "spec", "file", "and", "return", "it", "as", "a", "list", "of", "strings", "(", "one", "per", "line", ")", "." ]
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define unmangled_version ' + self.distribution.get_version(), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ] # put locale summaries into spec file # XXX not supported for now (hard to put a dictionary # in a config file -- arg!) #for locale in self.summaries.keys(): # spec_file.append('Summary(%s): %s' % (locale, # self.summaries[locale])) spec_file.extend([ 'Name: %{name}', 'Version: %{version}', 'Release: %{release}',]) # XXX yuck! this filename is available from the "sdist" command, # but only after it has run: and we create the spec file before # running "sdist", in case of --spec-only. if self.use_bzip2: spec_file.append('Source0: %{name}-%{unmangled_version}.tar.bz2') else: spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz') spec_file.extend([ 'License: ' + self.distribution.get_license(), 'Group: ' + self.group, 'BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot', 'Prefix: %{_prefix}', ]) if not self.force_arch: # noarch if no extension modules if not self.distribution.has_ext_modules(): spec_file.append('BuildArch: noarch') else: spec_file.append( 'BuildArch: %s' % self.force_arch ) for field in ('Vendor', 'Packager', 'Provides', 'Requires', 'Conflicts', 'Obsoletes', ): val = getattr(self, string.lower(field)) if isinstance(val, list): spec_file.append('%s: %s' % (field, string.join(val))) elif val is not None: spec_file.append('%s: %s' % (field, val)) if self.distribution.get_url() != 'UNKNOWN': spec_file.append('Url: ' + self.distribution.get_url()) if self.distribution_name: spec_file.append('Distribution: ' + self.distribution_name) if self.build_requires: spec_file.append('BuildRequires: ' + string.join(self.build_requires)) if self.icon: spec_file.append('Icon: ' + os.path.basename(self.icon)) if self.no_autoreq: spec_file.append('AutoReq: 0') spec_file.extend([ '', '%description', self.distribution.get_long_description() ]) # put locale descriptions into spec file # XXX again, suppressed because config file syntax doesn't # easily support this ;-( #for locale in self.descriptions.keys(): # spec_file.extend([ # '', # '%description -l ' + locale, # self.descriptions[locale], # ]) # rpm scripts # figure out default build script def_setup_call = "%s %s" % (self.python,os.path.basename(sys.argv[0])) def_build = "%s build" % def_setup_call if self.use_rpm_opt_flags: def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build # insert contents of files # XXX this is kind of misleading: user-supplied options are files # that we open and interpolate into the spec file, but the defaults # are just text that we drop in as-is. Hmmm. install_cmd = ('%s install -O1 --root=$RPM_BUILD_ROOT ' '--record=INSTALLED_FILES') % def_setup_call script_options = [ ('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"), ('build', 'build_script', def_build), ('install', 'install_script', install_cmd), ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"), ('verifyscript', 'verify_script', None), ('pre', 'pre_install', None), ('post', 'post_install', None), ('preun', 'pre_uninstall', None), ('postun', 'post_uninstall', None), ] for (rpm_opt, attr, default) in script_options: # Insert contents of file referred to, if no file is referred to # use 'default' as contents of script val = getattr(self, attr) if val or default: spec_file.extend([ '', '%' + rpm_opt,]) if val: spec_file.extend(string.split(open(val, 'r').read(), '\n')) else: spec_file.append(default) # files section spec_file.extend([ '', '%files -f INSTALLED_FILES', '%defattr(-,root,root)', ]) if self.doc_files: spec_file.append('%doc ' + string.join(self.doc_files)) if self.changelog: spec_file.extend([ '', '%changelog',]) spec_file.extend(self.changelog) return spec_file
[ "def", "_make_spec_file", "(", "self", ")", ":", "# definitions and headers", "spec_file", "=", "[", "'%define name '", "+", "self", ".", "distribution", ".", "get_name", "(", ")", ",", "'%define version '", "+", "self", ".", "distribution", ".", "get_version", ...
https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/distutils/command/bdist_rpm.py#L397-L548
FederatedAI/FATE
32540492623568ecd1afcb367360133616e02fa3
python/federatedml/cipher_compressor/compressor.py
python
NormalCipherPackage.retrieve
(self)
return self._cipher_text
[]
def retrieve(self): return self._cipher_text
[ "def", "retrieve", "(", "self", ")", ":", "return", "self", ".", "_cipher_text" ]
https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/cipher_compressor/compressor.py#L170-L171
jliljebl/flowblade
995313a509b80e99eb1ad550d945bdda5995093b
flowblade-trunk/Flowblade/kftoolmode.py
python
TLineKeyFrameEditor._draw_value_texts
(self, cr, x, w)
[]
def _draw_value_texts(self, cr, x, w): # Audio hard coded value lines TEXT_X_OFF = 4 TEXT_X_OFF_END = -28 TEXT_Y_OFF = 4 active_width = w - 2 * END_PAD xs = x + END_PAD xe = xs + active_width cr.select_font_face ("sans-serif", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) cr.set_font_size(12) cr.set_source_rgb(*SCALE_LINES_TEXT_COLOR) if self.edit_type == VOLUME_KF_EDIT: # 0 y = self._get_panel_y_for_value(0.0) text = "0 dB" cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END + 16, y - TEXT_Y_OFF) cr.show_text(text) # -20 y = self._get_panel_y_for_value(-20.0) text = "-20 dB" cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF + 8) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END + 6, y - TEXT_Y_OFF + 8) cr.show_text(text) # -70 y = self._get_panel_y_for_value(-70.0) text = "-70 dB" cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END, y - TEXT_Y_OFF) cr.show_text(text) elif self.edit_type == BRIGHTNESS_KF_EDIT: # 0 y = self._get_panel_y_for_value(0.0) text = "0" cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END + 16, y - TEXT_Y_OFF) cr.show_text(text) # 50 y = self._get_panel_y_for_value(50) text = "50" cr.move_to(xs + TEXT_X_OFF, y + 4) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END + 6, y + 4) cr.show_text(text) # 100 y = self._get_panel_y_for_value(100) text = "100" cr.move_to(xs + TEXT_X_OFF, y + 13) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END, y + 13) cr.show_text(text) else: editable_property = edit_data["editable_property"] adjustment = editable_property.get_input_range_adjustment() lower = adjustment.get_lower() upper = adjustment.get_upper() half = (upper - lower) / 2 + lower # Min y = self._get_panel_y_for_value(lower) text = str(lower) cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END + 16, y - TEXT_Y_OFF) cr.show_text(text) # Half y = self._get_panel_y_for_value(half) text = str(half) cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF + 8) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END + 6, y - TEXT_Y_OFF + 8) cr.show_text(text) # Max y = self._get_panel_y_for_value(upper) text = str(upper) cr.move_to(xs + TEXT_X_OFF, y - TEXT_Y_OFF + 17) cr.show_text(text) cr.move_to(xe + TEXT_X_OFF_END, y - TEXT_Y_OFF + 17) cr.show_text(text)
[ "def", "_draw_value_texts", "(", "self", ",", "cr", ",", "x", ",", "w", ")", ":", "# Audio hard coded value lines", "TEXT_X_OFF", "=", "4", "TEXT_X_OFF_END", "=", "-", "28", "TEXT_Y_OFF", "=", "4", "active_width", "=", "w", "-", "2", "*", "END_PAD", "xs", ...
https://github.com/jliljebl/flowblade/blob/995313a509b80e99eb1ad550d945bdda5995093b/flowblade-trunk/Flowblade/kftoolmode.py#L776-L881
MTG/freesound
72f234a656ce31f5f625f0bba5376dd4160b478d
accounts/views.py
python
check_username
(request)
return JsonResponse({'result': username_valid})
AJAX endpoint to check if a specified username is available to be registered. This checks against the normal username validator, and then also verifies to see if the username already exists in the database. Returns JSON {'result': true} if the username is valid and can be used
AJAX endpoint to check if a specified username is available to be registered. This checks against the normal username validator, and then also verifies to see if the username already exists in the database.
[ "AJAX", "endpoint", "to", "check", "if", "a", "specified", "username", "is", "available", "to", "be", "registered", ".", "This", "checks", "against", "the", "normal", "username", "validator", "and", "then", "also", "verifies", "to", "see", "if", "the", "user...
def check_username(request): """AJAX endpoint to check if a specified username is available to be registered. This checks against the normal username validator, and then also verifies to see if the username already exists in the database. Returns JSON {'result': true} if the username is valid and can be used""" username = request.GET.get('username', None) username_valid = False username_field = UsernameField() if username: try: username_field.run_validators(username) # If the validator passes, check if the username is indeed available username_valid = not username_taken_by_other_user(username) except ValidationError: username_valid = False return JsonResponse({'result': username_valid})
[ "def", "check_username", "(", "request", ")", ":", "username", "=", "request", ".", "GET", ".", "get", "(", "'username'", ",", "None", ")", "username_valid", "=", "False", "username_field", "=", "UsernameField", "(", ")", "if", "username", ":", "try", ":",...
https://github.com/MTG/freesound/blob/72f234a656ce31f5f625f0bba5376dd4160b478d/accounts/views.py#L225-L242
4w4k3/rePy2exe
f3ff8efcf9103e4e8d7501e53a5536dcc43cbf9d
rePy2exe.py
python
pp
()
[]
def pp(): print """ .... ,''. : __ \|_.' `: _.----._//_ .' .'.`'-._ .' _/ -._ \)-.----O '._.'.' '--''-'._ '--..--'-` .'.'___ /`'---'. / ,-'` * _<__.-._))../ /'----'/.'_____:'. \_ : \ ] : '. \___: SEE YOU \\ LATER ! : '. : \\__ : .' :_______________|__]__________: .' .' __ '. :.' .' .' '. '. .' .' '. '. #rePy2exe .' .' '. '. _.' .'______________'. '._ [_0______________________0_] """
[ "def", "pp", "(", ")", ":", "print", "\"\"\"\n ....\n ,''. : __\n \\|_.' `: _.----._//_\n .' .'.`'-._ .' _/ -._ \\)-.----O\n '._.'.' '--''-'._ '--..--'-`\n .'.'___ /`'---'. / ,-'`\n * _<__.-._))../ /'----'/.'___...
https://github.com/4w4k3/rePy2exe/blob/f3ff8efcf9103e4e8d7501e53a5536dcc43cbf9d/rePy2exe.py#L151-L170
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Tools/scripts/fixdiv.py
python
FileContext.__init__
(self, fp, window=5, lineno=1)
[]
def __init__(self, fp, window=5, lineno=1): self.fp = fp self.window = 5 self.lineno = 1 self.eoflookahead = 0 self.lookahead = [] self.buffer = []
[ "def", "__init__", "(", "self", ",", "fp", ",", "window", "=", "5", ",", "lineno", "=", "1", ")", ":", "self", ".", "fp", "=", "fp", "self", ".", "window", "=", "5", "self", ".", "lineno", "=", "1", "self", ".", "eoflookahead", "=", "0", "self"...
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Tools/scripts/fixdiv.py#L316-L322
omz/PythonistaAppTemplate
f560f93f8876d82a21d108977f90583df08d55af
PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/sympy/integrals/meijerint.py
python
_check_antecedents_1
(g, x, helper=False)
return Or(*conds)
Return a condition under which the mellin transform of g exists. Any power of x has already been absorbed into the G function, so this is just int_0^\infty g dx. See [L, section 5.6.1]. (Note that s=1.) If ``helper`` is True, only check if the MT exists at infinity, i.e. if int_1^\infty g dx exists.
Return a condition under which the mellin transform of g exists. Any power of x has already been absorbed into the G function, so this is just int_0^\infty g dx.
[ "Return", "a", "condition", "under", "which", "the", "mellin", "transform", "of", "g", "exists", ".", "Any", "power", "of", "x", "has", "already", "been", "absorbed", "into", "the", "G", "function", "so", "this", "is", "just", "int_0^", "\\", "infty", "g...
def _check_antecedents_1(g, x, helper=False): """ Return a condition under which the mellin transform of g exists. Any power of x has already been absorbed into the G function, so this is just int_0^\infty g dx. See [L, section 5.6.1]. (Note that s=1.) If ``helper`` is True, only check if the MT exists at infinity, i.e. if int_1^\infty g dx exists. """ # NOTE if you update these conditions, please update the documentation as well from sympy import Eq, Not, ceiling, Ne, re, unbranched_argument as arg delta = g.delta eta, _ = _get_coeff_exp(g.argument, x) m, n, p, q = S([len(g.bm), len(g.an), len(g.ap), len(g.bq)]) xi = m + n - p if p > q: def tr(l): return [1 - x for x in l] return _check_antecedents_1(meijerg(tr(g.bm), tr(g.bother), tr(g.an), tr(g.aother), x/eta), x) tmp = [] for b in g.bm: tmp += [-re(b) < 1] for a in g.an: tmp += [1 < 1 - re(a)] cond_3 = And(*tmp) for b in g.bother: tmp += [-re(b) < 1] for a in g.aother: tmp += [1 < 1 - re(a)] cond_3_star = And(*tmp) cond_4 = (-re(g.nu) + (q + 1 - p)/2 > q - p) def debug(*msg): _debug(*msg) debug('Checking antecedents for 1 function:') debug(' delta=%s, eta=%s, m=%s, n=%s, p=%s, q=%s' % (delta, eta, m, n, p, q)) debug(' ap = %s, %s' % (list(g.an), list(g.aother))) debug(' bq = %s, %s' % (list(g.bm), list(g.bother))) debug(' cond_3=%s, cond_3*=%s, cond_4=%s' % (cond_3, cond_3_star, cond_4)) conds = [] # case 1 case1 = [] tmp1 = [1 <= n, p < q, 1 <= m] tmp2 = [1 <= p, 1 <= m, Eq(q, p + 1), Not(And(Eq(n, 0), Eq(m, p + 1)))] tmp3 = [1 <= p, Eq(q, p)] for k in range(ceiling(delta/2) + 1): tmp3 += [Ne(abs(arg(eta)), (delta - 2*k)*pi)] tmp = [delta > 0, abs(arg(eta)) < delta*pi] extra = [Ne(eta, 0), cond_3] if helper: extra = [] for t in [tmp1, tmp2, tmp3]: case1 += [And(*(t + tmp + extra))] conds += case1 debug(' case 1:', case1) # case 2 extra = [cond_3] if helper: extra = [] case2 = [And(Eq(n, 0), p + 1 <= m, m <= q, abs(arg(eta)) < delta*pi, *extra)] conds += case2 debug(' case 2:', case2) # case 3 extra = [cond_3, cond_4] if helper: extra = [] case3 = [And(p < q, 1 <= m, delta > 0, Eq(abs(arg(eta)), delta*pi), *extra)] case3 += [And(p <= q - 2, Eq(delta, 0), Eq(abs(arg(eta)), 0), *extra)] conds += case3 debug(' case 3:', case3) # TODO altered cases 4-7 # extra case from wofram functions site: # (reproduced verbatim from prudnikov, section 2.24.2) # http://functions.wolfram.com/HypergeometricFunctions/MeijerG/21/02/01/ case_extra = [] case_extra += [Eq(p, q), Eq(delta, 0), Eq(arg(eta), 0), Ne(eta, 0)] if not helper: case_extra += [cond_3] s = [] for a, b in zip(g.ap, g.bq): s += [b - a] case_extra += [re(Add(*s)) < 0] case_extra = And(*case_extra) conds += [case_extra] debug(' extra case:', [case_extra]) case_extra_2 = [And(delta > 0, abs(arg(eta)) < delta*pi)] if not helper: case_extra_2 += [cond_3] case_extra_2 = And(*case_extra_2) conds += [case_extra_2] debug(' second extra case:', [case_extra_2]) # TODO This leaves only one case from the three listed by prudnikov. # Investigate if these indeed cover everything; if so, remove the rest. return Or(*conds)
[ "def", "_check_antecedents_1", "(", "g", ",", "x", ",", "helper", "=", "False", ")", ":", "# NOTE if you update these conditions, please update the documentation as well", "from", "sympy", "import", "Eq", ",", "Not", ",", "ceiling", ",", "Ne", ",", "re", ",", "unb...
https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib_ext/sympy/integrals/meijerint.py#L708-L822
intel/virtual-storage-manager
00706ab9701acbd0d5e04b19cc80c6b66a2973b8
source/python-vsmclient/vsmclient/v1/vsms.py
python
VolumeManager.get_server_list
(self, req=None)
return self.api.client.get(url)
host list
host list
[ "host", "list" ]
def get_server_list(self, req=None): """ host list """ url = "/cluster/servers" return self.api.client.get(url)
[ "def", "get_server_list", "(", "self", ",", "req", "=", "None", ")", ":", "url", "=", "\"/cluster/servers\"", "return", "self", ".", "api", ".", "client", ".", "get", "(", "url", ")" ]
https://github.com/intel/virtual-storage-manager/blob/00706ab9701acbd0d5e04b19cc80c6b66a2973b8/source/python-vsmclient/vsmclient/v1/vsms.py#L196-L201
triaquae/triaquae
bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9
TriAquae/models/Centos_5.9/pyasn1/type/namedval.py
python
NamedValues.getName
(self, value)
[]
def getName(self, value): if value in self.valToNameIdx: return self.valToNameIdx[value]
[ "def", "getName", "(", "self", ",", "value", ")", ":", "if", "value", "in", "self", ".", "valToNameIdx", ":", "return", "self", ".", "valToNameIdx", "[", "value", "]" ]
https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Centos_5.9/pyasn1/type/namedval.py#L27-L29
pyansys/pymapdl
c07291fc062b359abf0e92b95a92d753a95ef3d7
ansys/mapdl/core/_commands/preproc/database.py
python
Database.check
(self, sele="", levl="", **kwargs)
return self.run(command, **kwargs)
Checks current database items for completeness. APDL Command: CHECK Parameters ---------- sele Specifies which elements are to be checked: (blank) - Check all data. ESEL - Check only elements in the selected set and unselect any elements not producing geometry check messages. The remaining elements (those producing check messages) can then be displayed and corrected. A null set results if no elements produce a message. Issue ESEL,ALL to select all elements before proceeding. levl Used only with Sele = ESEL: WARN - Select elements producing warning and error messages. ERR - Select only elements producing error messages (default). Notes ----- This command will not work if SHPP,OFF has been set. A similar, automatic check of all data is done before the solution begins. If the "Check Elements" option is invoked through the GUI (menu path Main Menu> Preprocessor> Meshing> Check Elems), the CHECK,ESEL logic is used to highlight elements in the following way: good elements are blue, elements having warnings are yellow, and bad (error) elements are red. Note:: : The currently selected set of elements is not changed by this GUI function. This command is also valid in PREP7.
Checks current database items for completeness.
[ "Checks", "current", "database", "items", "for", "completeness", "." ]
def check(self, sele="", levl="", **kwargs): """Checks current database items for completeness. APDL Command: CHECK Parameters ---------- sele Specifies which elements are to be checked: (blank) - Check all data. ESEL - Check only elements in the selected set and unselect any elements not producing geometry check messages. The remaining elements (those producing check messages) can then be displayed and corrected. A null set results if no elements produce a message. Issue ESEL,ALL to select all elements before proceeding. levl Used only with Sele = ESEL: WARN - Select elements producing warning and error messages. ERR - Select only elements producing error messages (default). Notes ----- This command will not work if SHPP,OFF has been set. A similar, automatic check of all data is done before the solution begins. If the "Check Elements" option is invoked through the GUI (menu path Main Menu> Preprocessor> Meshing> Check Elems), the CHECK,ESEL logic is used to highlight elements in the following way: good elements are blue, elements having warnings are yellow, and bad (error) elements are red. Note:: : The currently selected set of elements is not changed by this GUI function. This command is also valid in PREP7. """ command = "CHECK,%s,%s" % (str(sele), str(levl)) return self.run(command, **kwargs)
[ "def", "check", "(", "self", ",", "sele", "=", "\"\"", ",", "levl", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "command", "=", "\"CHECK,%s,%s\"", "%", "(", "str", "(", "sele", ")", ",", "str", "(", "levl", ")", ")", "return", "self", ".", ...
https://github.com/pyansys/pymapdl/blob/c07291fc062b359abf0e92b95a92d753a95ef3d7/ansys/mapdl/core/_commands/preproc/database.py#L380-L423
ninja-ide/ninja-ide
87d91131bd19fdc3dcfd91eb97ad1e41c49c60c0
ninja_ide/tools/console.py
python
Console.return_output
(self)
Reassign the proper values to output and error channel.
Reassign the proper values to output and error channel.
[ "Reassign", "the", "proper", "values", "to", "output", "and", "error", "channel", "." ]
def return_output(self): """Reassign the proper values to output and error channel.""" sys.stdout = self.stdout sys.stderr = self.stderr
[ "def", "return_output", "(", "self", ")", ":", "sys", ".", "stdout", "=", "self", ".", "stdout", "sys", ".", "stderr", "=", "self", ".", "stderr" ]
https://github.com/ninja-ide/ninja-ide/blob/87d91131bd19fdc3dcfd91eb97ad1e41c49c60c0/ninja_ide/tools/console.py#L82-L85
googleads/google-ads-python
2a1d6062221f6aad1992a6bcca0e7e4a93d2db86
google/ads/googleads/v8/services/services/detailed_demographic_service/client.py
python
DetailedDemographicServiceClient.parse_common_billing_account_path
(path: str)
return m.groupdict() if m else {}
Parse a billing_account path into its component segments.
Parse a billing_account path into its component segments.
[ "Parse", "a", "billing_account", "path", "into", "its", "component", "segments", "." ]
def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path) return m.groupdict() if m else {}
[ "def", "parse_common_billing_account_path", "(", "path", ":", "str", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "m", "=", "re", ".", "match", "(", "r\"^billingAccounts/(?P<billing_account>.+?)$\"", ",", "path", ")", "return", "m", ".", "groupdict", ...
https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v8/services/services/detailed_demographic_service/client.py#L190-L193
yangxue0827/FPN_Tensorflow
c72110d2803455e6e55020f69144d9490a3d39ad
libs/rpn/build_rpn.py
python
RPN.rpn_find_positive_negative_samples
(self, anchors)
assign anchors targets: object or background. :param anchors: [valid_num_of_anchors, 4]. use N to represent valid_num_of_anchors :return:labels. anchors_matched_gtboxes, object_mask labels shape is [N, ]. positive is 1, negative is 0, ignored is -1 anchor_matched_gtboxes. each anchor's gtbox(only positive box has gtbox)shape is [N, 4] object_mask. tf.float32. 1.0 represent box is object, 0.0 is others. shape is [N, ]
assign anchors targets: object or background. :param anchors: [valid_num_of_anchors, 4]. use N to represent valid_num_of_anchors
[ "assign", "anchors", "targets", ":", "object", "or", "background", ".", ":", "param", "anchors", ":", "[", "valid_num_of_anchors", "4", "]", ".", "use", "N", "to", "represent", "valid_num_of_anchors" ]
def rpn_find_positive_negative_samples(self, anchors): ''' assign anchors targets: object or background. :param anchors: [valid_num_of_anchors, 4]. use N to represent valid_num_of_anchors :return:labels. anchors_matched_gtboxes, object_mask labels shape is [N, ]. positive is 1, negative is 0, ignored is -1 anchor_matched_gtboxes. each anchor's gtbox(only positive box has gtbox)shape is [N, 4] object_mask. tf.float32. 1.0 represent box is object, 0.0 is others. shape is [N, ] ''' with tf.variable_scope('rpn_find_positive_negative_samples'): gtboxes = tf.reshape(self.gtboxes_and_label[:, :-1], [-1, 4]) gtboxes = tf.cast(gtboxes, tf.float32) ious = iou.iou_calculate(anchors, gtboxes) # [N, M] max_iou_each_row = tf.reduce_max(ious, axis=1) labels = tf.ones(shape=[tf.shape(anchors)[0], ], dtype=tf.float32) * (-1) # [N, ] # ignored is -1 matchs = tf.cast(tf.argmax(ious, axis=1), tf.int32) # an anchor that has an IoU overlap higher than 0.7 with any ground-truth box positives1 = tf.greater_equal(max_iou_each_row, self.rpn_iou_positive_threshold) # iou >= 0.7 is positive # to avoid none of boxes iou >= 0.7, use max iou boxes as positive max_iou_each_column = tf.reduce_max(ious, 0) # the anchor/anchors with the highest Intersection-over-Union (IoU) overlap with a ground-truth box positives2 = tf.reduce_sum(tf.cast(tf.equal(ious, max_iou_each_column), tf.float32), axis=1) positives = tf.logical_or(positives1, tf.cast(positives2, tf.bool)) labels += 2 * tf.cast(positives, tf.float32) # Now, positive is 1, ignored and background is -1 # object_mask = tf.cast(positives, tf.float32) # 1.0 is object, 0.0 is others # matchs = matchs * tf.cast(positives, dtype=matchs.dtype) # remove background and ignored anchors_matched_gtboxes = tf.gather(gtboxes, matchs) # [N, 4] # background's gtboxes tmp set the first gtbox, it dose not matter, because use object_mask will ignored it negatives = tf.less(max_iou_each_row, self.rpn_iou_negative_threshold) negatives = tf.logical_and(negatives, tf.greater_equal(max_iou_each_row, 0.1)) labels = labels + tf.cast(negatives, tf.float32) # [N, ] positive is >=1.0, negative is 0, ignored is -1.0 ''' Need to note: when opsitive, labels may >= 1.0. Because, when all the iou< 0.7, we set anchors having max iou each column as positive. these anchors may have iou < 0.3. In the begining, labels is [-1, -1, -1...-1] then anchors having iou<0.3 as well as are max iou each column will be +1.0. when decide negatives, because of iou<0.3, they add 1.0 again. So, the final result will be 2.0 So, when opsitive, labels may in [1.0, 2.0]. that is labels >=1.0 ''' positives = tf.cast(tf.greater_equal(labels, 1.0), tf.float32) ignored = tf.cast(tf.equal(labels, -1.0), tf.float32) * -1 labels = positives + ignored object_mask = tf.cast(positives, tf.float32) # 1.0 is object, 0.0 is others return labels, anchors_matched_gtboxes, object_mask
[ "def", "rpn_find_positive_negative_samples", "(", "self", ",", "anchors", ")", ":", "with", "tf", ".", "variable_scope", "(", "'rpn_find_positive_negative_samples'", ")", ":", "gtboxes", "=", "tf", ".", "reshape", "(", "self", ".", "gtboxes_and_label", "[", ":", ...
https://github.com/yangxue0827/FPN_Tensorflow/blob/c72110d2803455e6e55020f69144d9490a3d39ad/libs/rpn/build_rpn.py#L241-L303
oracle/oci-python-sdk
3c1604e4e212008fb6718e2f68cdb5ef71fd5793
src/oci/object_storage/transfer/upload_manager.py
python
UploadManager._add_adapter_to_service_client
(object_storage_client, allow_parallel_uploads, parallel_process_count)
[]
def _add_adapter_to_service_client(object_storage_client, allow_parallel_uploads, parallel_process_count): # No need to mount with a larger pool size if we are not running multiple threads if not allow_parallel_uploads or not parallel_process_count: return endpoint = object_storage_client.base_client.endpoint mount_protocol = 'https://' if endpoint.startswith('http://'): mount_protocol = 'http://' parallel_processes = DEFAULT_PARALLEL_PROCESS_COUNT if parallel_process_count is not None: parallel_processes = parallel_process_count target_pool_size = UploadManager.REQUESTS_POOL_SIZE_FACTOR * parallel_processes adapter = requests.adapters.HTTPAdapter(pool_maxsize=target_pool_size) if mount_protocol in object_storage_client.base_client.session.adapters: # If someone has already mounted and it's large enough, don't mount over the top if object_storage_client.base_client.session.adapters[mount_protocol]._pool_maxsize >= target_pool_size: return object_storage_client.base_client.session.mount(mount_protocol, adapter)
[ "def", "_add_adapter_to_service_client", "(", "object_storage_client", ",", "allow_parallel_uploads", ",", "parallel_process_count", ")", ":", "# No need to mount with a larger pool size if we are not running multiple threads", "if", "not", "allow_parallel_uploads", "or", "not", "par...
https://github.com/oracle/oci-python-sdk/blob/3c1604e4e212008fb6718e2f68cdb5ef71fd5793/src/oci/object_storage/transfer/upload_manager.py#L370-L392
MrH0wl/Cloudmare
65e5bc9888f9d362ab2abfb103ea6c1e869d67aa
thirdparty/dns/dnssec.py
python
_validate_rrsig
(rrset, rrsig, keys, origin=None, now=None)
Validate an RRset against a single signature rdata, throwing an exception if validation is not successful. *rrset*, the RRset to validate. This can be a ``thirdparty.dns.rrset.RRset`` or a (``thirdparty.dns.name.Name``, ``thirdparty.dns.rdataset.Rdataset``) tuple. *rrsig*, a ``thirdparty.dns.rdata.Rdata``, the signature to validate. *keys*, the key dictionary, used to find the DNSKEY associated with a given name. The dictionary is keyed by a ``thirdparty.dns.name.Name``, and has ``thirdparty.dns.node.Node`` or ``thirdparty.dns.rdataset.Rdataset`` values. *origin*, a ``thirdparty.dns.name.Name`` or ``None``, the origin to use for relative names. *now*, an ``int`` or ``None``, the time, in seconds since the epoch, to use as the current time when validating. If ``None``, the actual current time is used. Raises ``ValidationFailure`` if the signature is expired, not yet valid, the public key is invalid, the algorithm is unknown, the verification fails, etc. Raises ``UnsupportedAlgorithm`` if the algorithm is recognized by dnspython but not implemented.
Validate an RRset against a single signature rdata, throwing an exception if validation is not successful.
[ "Validate", "an", "RRset", "against", "a", "single", "signature", "rdata", "throwing", "an", "exception", "if", "validation", "is", "not", "successful", "." ]
def _validate_rrsig(rrset, rrsig, keys, origin=None, now=None): """Validate an RRset against a single signature rdata, throwing an exception if validation is not successful. *rrset*, the RRset to validate. This can be a ``thirdparty.dns.rrset.RRset`` or a (``thirdparty.dns.name.Name``, ``thirdparty.dns.rdataset.Rdataset``) tuple. *rrsig*, a ``thirdparty.dns.rdata.Rdata``, the signature to validate. *keys*, the key dictionary, used to find the DNSKEY associated with a given name. The dictionary is keyed by a ``thirdparty.dns.name.Name``, and has ``thirdparty.dns.node.Node`` or ``thirdparty.dns.rdataset.Rdataset`` values. *origin*, a ``thirdparty.dns.name.Name`` or ``None``, the origin to use for relative names. *now*, an ``int`` or ``None``, the time, in seconds since the epoch, to use as the current time when validating. If ``None``, the actual current time is used. Raises ``ValidationFailure`` if the signature is expired, not yet valid, the public key is invalid, the algorithm is unknown, the verification fails, etc. Raises ``UnsupportedAlgorithm`` if the algorithm is recognized by dnspython but not implemented. """ if isinstance(origin, str): origin = thirdparty.dns.name.from_text(origin, thirdparty.dns.name.root) candidate_keys = _find_candidate_keys(keys, rrsig) if candidate_keys is None: raise ValidationFailure('unknown key') for candidate_key in candidate_keys: # For convenience, allow the rrset to be specified as a (name, # rdataset) tuple as well as a proper rrset if isinstance(rrset, tuple): rrname = rrset[0] rdataset = rrset[1] else: rrname = rrset.name rdataset = rrset if now is None: now = time.time() if rrsig.expiration < now: raise ValidationFailure('expired') if rrsig.inception > now: raise ValidationFailure('not yet valid') if _is_rsa(rrsig.algorithm): keyptr = candidate_key.key (bytes_,) = struct.unpack('!B', keyptr[0:1]) keyptr = keyptr[1:] if bytes_ == 0: (bytes_,) = struct.unpack('!H', keyptr[0:2]) keyptr = keyptr[2:] rsa_e = keyptr[0:bytes_] rsa_n = keyptr[bytes_:] try: public_key = rsa.RSAPublicNumbers( _bytes_to_long(rsa_e), _bytes_to_long(rsa_n)).public_key(default_backend()) except ValueError: raise ValidationFailure('invalid public key') sig = rrsig.signature elif _is_dsa(rrsig.algorithm): keyptr = candidate_key.key (t,) = struct.unpack('!B', keyptr[0:1]) keyptr = keyptr[1:] octets = 64 + t * 8 dsa_q = keyptr[0:20] keyptr = keyptr[20:] dsa_p = keyptr[0:octets] keyptr = keyptr[octets:] dsa_g = keyptr[0:octets] keyptr = keyptr[octets:] dsa_y = keyptr[0:octets] try: public_key = dsa.DSAPublicNumbers( _bytes_to_long(dsa_y), dsa.DSAParameterNumbers( _bytes_to_long(dsa_p), _bytes_to_long(dsa_q), _bytes_to_long(dsa_g))).public_key(default_backend()) except ValueError: raise ValidationFailure('invalid public key') sig_r = rrsig.signature[1:21] sig_s = rrsig.signature[21:] sig = utils.encode_dss_signature(_bytes_to_long(sig_r), _bytes_to_long(sig_s)) elif _is_ecdsa(rrsig.algorithm): keyptr = candidate_key.key if rrsig.algorithm == Algorithm.ECDSAP256SHA256: curve = ec.SECP256R1() octets = 32 else: curve = ec.SECP384R1() octets = 48 ecdsa_x = keyptr[0:octets] ecdsa_y = keyptr[octets:octets * 2] try: public_key = ec.EllipticCurvePublicNumbers( curve=curve, x=_bytes_to_long(ecdsa_x), y=_bytes_to_long(ecdsa_y)).public_key(default_backend()) except ValueError: raise ValidationFailure('invalid public key') sig_r = rrsig.signature[0:octets] sig_s = rrsig.signature[octets:] sig = utils.encode_dss_signature(_bytes_to_long(sig_r), _bytes_to_long(sig_s)) elif _is_eddsa(rrsig.algorithm): keyptr = candidate_key.key if rrsig.algorithm == Algorithm.ED25519: loader = ed25519.Ed25519PublicKey else: loader = ed448.Ed448PublicKey try: public_key = loader.from_public_bytes(keyptr) except ValueError: raise ValidationFailure('invalid public key') sig = rrsig.signature elif _is_gost(rrsig.algorithm): raise UnsupportedAlgorithm( 'algorithm "%s" not supported by dnspython' % algorithm_to_text(rrsig.algorithm)) else: raise ValidationFailure('unknown algorithm %u' % rrsig.algorithm) data = b'' data += rrsig.to_wire(origin=origin)[:18] data += rrsig.signer.to_digestable(origin) if rrsig.labels < len(rrname) - 1: suffix = rrname.split(rrsig.labels + 1)[1] rrname = thirdparty.dns.name.from_text('*', suffix) rrnamebuf = rrname.to_digestable(origin) rrfixed = struct.pack('!HHI', rdataset.rdtype, rdataset.rdclass, rrsig.original_ttl) rrlist = sorted(rdataset) for rr in rrlist: data += rrnamebuf data += rrfixed rrdata = rr.to_digestable(origin) rrlen = struct.pack('!H', len(rrdata)) data += rrlen data += rrdata chosen_hash = _make_hash(rrsig.algorithm) try: if _is_rsa(rrsig.algorithm): public_key.verify(sig, data, padding.PKCS1v15(), chosen_hash) elif _is_dsa(rrsig.algorithm): public_key.verify(sig, data, chosen_hash) elif _is_ecdsa(rrsig.algorithm): public_key.verify(sig, data, ec.ECDSA(chosen_hash)) elif _is_eddsa(rrsig.algorithm): public_key.verify(sig, data) else: # Raise here for code clarity; this won't actually ever happen # since if the algorithm is really unknown we'd already have # raised an exception above raise ValidationFailure('unknown algorithm %u' % rrsig.algorithm) # pragma: no cover # If we got here, we successfully verified so we can return # without error return except InvalidSignature: # this happens on an individual validation failure continue # nothing verified -- raise failure: raise ValidationFailure('verify failure')
[ "def", "_validate_rrsig", "(", "rrset", ",", "rrsig", ",", "keys", ",", "origin", "=", "None", ",", "now", "=", "None", ")", ":", "if", "isinstance", "(", "origin", ",", "str", ")", ":", "origin", "=", "thirdparty", ".", "dns", ".", "name", ".", "f...
https://github.com/MrH0wl/Cloudmare/blob/65e5bc9888f9d362ab2abfb103ea6c1e869d67aa/thirdparty/dns/dnssec.py#L257-L434
kylejusticemagnuson/pyti
2f78430dfd60a0d20f4e7fc0cb4588c03107c4b2
pyti/bollinger_bands.py
python
bandwidth
(data, period, std=2.0)
return bandwidth
Bandwidth. Formula: bw = u_bb - l_bb / m_bb
Bandwidth.
[ "Bandwidth", "." ]
def bandwidth(data, period, std=2.0): """ Bandwidth. Formula: bw = u_bb - l_bb / m_bb """ catch_errors.check_for_period_error(data, period) period = int(period) bandwidth = ((upper_bollinger_band(data, period, std) - lower_bollinger_band(data, period, std)) / middle_bollinger_band(data, period, std) ) return bandwidth
[ "def", "bandwidth", "(", "data", ",", "period", ",", "std", "=", "2.0", ")", ":", "catch_errors", ".", "check_for_period_error", "(", "data", ",", "period", ")", "period", "=", "int", "(", "period", ")", "bandwidth", "=", "(", "(", "upper_bollinger_band", ...
https://github.com/kylejusticemagnuson/pyti/blob/2f78430dfd60a0d20f4e7fc0cb4588c03107c4b2/pyti/bollinger_bands.py#L68-L83
vcheckzen/FODI
3bb23644938a33c3fdfb9611a622e35ed4ce6532
back-end-py/main/3rd/PIL/ImageCms.py
python
buildProofTransform
( inputProfile, outputProfile, proofProfile, inMode, outMode, renderingIntent=INTENT_PERCEPTUAL, proofRenderingIntent=INTENT_ABSOLUTE_COLORIMETRIC, flags=FLAGS["SOFTPROOFING"], )
(pyCMS) Builds an ICC transform mapping from the inputProfile to the outputProfile, but tries to simulate the result that would be obtained on the proofProfile device. If the input, output, or proof profiles specified are not valid filenames, a PyCMSError will be raised. If an error occurs during creation of the transform, a PyCMSError will be raised. If inMode or outMode are not a mode supported by the outputProfile (or by pyCMS), a PyCMSError will be raised. This function builds and returns an ICC transform from the inputProfile to the outputProfile, but tries to simulate the result that would be obtained on the proofProfile device using renderingIntent and proofRenderingIntent to determine what to do with out-of-gamut colors. This is known as "soft-proofing". It will ONLY work for converting images that are in inMode to images that are in outMode color format (PIL mode, i.e. "RGB", "RGBA", "CMYK", etc.). Usage of the resulting transform object is exactly the same as with ImageCms.buildTransform(). Proof profiling is generally used when using an output device to get a good idea of what the final printed/displayed image would look like on the proofProfile device when it's quicker and easier to use the output device for judging color. Generally, this means that the output device is a monitor, or a dye-sub printer (etc.), and the simulated device is something more expensive, complicated, or time consuming (making it difficult to make a real print for color judgement purposes). Soft-proofing basically functions by adjusting the colors on the output device to match the colors of the device being simulated. However, when the simulated device has a much wider gamut than the output device, you may obtain marginal results. :param inputProfile: String, as a valid filename path to the ICC input profile you wish to use for this transform, or a profile object :param outputProfile: String, as a valid filename path to the ICC output (monitor, usually) profile you wish to use for this transform, or a profile object :param proofProfile: String, as a valid filename path to the ICC proof profile you wish to use for this transform, or a profile object :param inMode: String, as a valid PIL mode that the appropriate profile also supports (i.e. "RGB", "RGBA", "CMYK", etc.) :param outMode: String, as a valid PIL mode that the appropriate profile also supports (i.e. "RGB", "RGBA", "CMYK", etc.) :param renderingIntent: Integer (0-3) specifying the rendering intent you wish to use for the input->proof (simulated) transform ImageCms.INTENT_PERCEPTUAL = 0 (DEFAULT) ImageCms.INTENT_RELATIVE_COLORIMETRIC = 1 ImageCms.INTENT_SATURATION = 2 ImageCms.INTENT_ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. :param proofRenderingIntent: Integer (0-3) specifying the rendering intent you wish to use for proof->output transform ImageCms.INTENT_PERCEPTUAL = 0 (DEFAULT) ImageCms.INTENT_RELATIVE_COLORIMETRIC = 1 ImageCms.INTENT_SATURATION = 2 ImageCms.INTENT_ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. :param flags: Integer (0-...) specifying additional flags :returns: A CmsTransform class object. :exception PyCMSError:
(pyCMS) Builds an ICC transform mapping from the inputProfile to the outputProfile, but tries to simulate the result that would be obtained on the proofProfile device.
[ "(", "pyCMS", ")", "Builds", "an", "ICC", "transform", "mapping", "from", "the", "inputProfile", "to", "the", "outputProfile", "but", "tries", "to", "simulate", "the", "result", "that", "would", "be", "obtained", "on", "the", "proofProfile", "device", "." ]
def buildProofTransform( inputProfile, outputProfile, proofProfile, inMode, outMode, renderingIntent=INTENT_PERCEPTUAL, proofRenderingIntent=INTENT_ABSOLUTE_COLORIMETRIC, flags=FLAGS["SOFTPROOFING"], ): """ (pyCMS) Builds an ICC transform mapping from the inputProfile to the outputProfile, but tries to simulate the result that would be obtained on the proofProfile device. If the input, output, or proof profiles specified are not valid filenames, a PyCMSError will be raised. If an error occurs during creation of the transform, a PyCMSError will be raised. If inMode or outMode are not a mode supported by the outputProfile (or by pyCMS), a PyCMSError will be raised. This function builds and returns an ICC transform from the inputProfile to the outputProfile, but tries to simulate the result that would be obtained on the proofProfile device using renderingIntent and proofRenderingIntent to determine what to do with out-of-gamut colors. This is known as "soft-proofing". It will ONLY work for converting images that are in inMode to images that are in outMode color format (PIL mode, i.e. "RGB", "RGBA", "CMYK", etc.). Usage of the resulting transform object is exactly the same as with ImageCms.buildTransform(). Proof profiling is generally used when using an output device to get a good idea of what the final printed/displayed image would look like on the proofProfile device when it's quicker and easier to use the output device for judging color. Generally, this means that the output device is a monitor, or a dye-sub printer (etc.), and the simulated device is something more expensive, complicated, or time consuming (making it difficult to make a real print for color judgement purposes). Soft-proofing basically functions by adjusting the colors on the output device to match the colors of the device being simulated. However, when the simulated device has a much wider gamut than the output device, you may obtain marginal results. :param inputProfile: String, as a valid filename path to the ICC input profile you wish to use for this transform, or a profile object :param outputProfile: String, as a valid filename path to the ICC output (monitor, usually) profile you wish to use for this transform, or a profile object :param proofProfile: String, as a valid filename path to the ICC proof profile you wish to use for this transform, or a profile object :param inMode: String, as a valid PIL mode that the appropriate profile also supports (i.e. "RGB", "RGBA", "CMYK", etc.) :param outMode: String, as a valid PIL mode that the appropriate profile also supports (i.e. "RGB", "RGBA", "CMYK", etc.) :param renderingIntent: Integer (0-3) specifying the rendering intent you wish to use for the input->proof (simulated) transform ImageCms.INTENT_PERCEPTUAL = 0 (DEFAULT) ImageCms.INTENT_RELATIVE_COLORIMETRIC = 1 ImageCms.INTENT_SATURATION = 2 ImageCms.INTENT_ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. :param proofRenderingIntent: Integer (0-3) specifying the rendering intent you wish to use for proof->output transform ImageCms.INTENT_PERCEPTUAL = 0 (DEFAULT) ImageCms.INTENT_RELATIVE_COLORIMETRIC = 1 ImageCms.INTENT_SATURATION = 2 ImageCms.INTENT_ABSOLUTE_COLORIMETRIC = 3 see the pyCMS documentation for details on rendering intents and what they do. :param flags: Integer (0-...) specifying additional flags :returns: A CmsTransform class object. :exception PyCMSError: """ if not isinstance(renderingIntent, int) or not (0 <= renderingIntent <= 3): raise PyCMSError("renderingIntent must be an integer between 0 and 3") if not isinstance(flags, int) or not (0 <= flags <= _MAX_FLAG): raise PyCMSError("flags must be an integer between 0 and %s" + _MAX_FLAG) try: if not isinstance(inputProfile, ImageCmsProfile): inputProfile = ImageCmsProfile(inputProfile) if not isinstance(outputProfile, ImageCmsProfile): outputProfile = ImageCmsProfile(outputProfile) if not isinstance(proofProfile, ImageCmsProfile): proofProfile = ImageCmsProfile(proofProfile) return ImageCmsTransform( inputProfile, outputProfile, inMode, outMode, renderingIntent, proofProfile, proofRenderingIntent, flags, ) except (OSError, TypeError, ValueError) as v: raise PyCMSError(v)
[ "def", "buildProofTransform", "(", "inputProfile", ",", "outputProfile", ",", "proofProfile", ",", "inMode", ",", "outMode", ",", "renderingIntent", "=", "INTENT_PERCEPTUAL", ",", "proofRenderingIntent", "=", "INTENT_ABSOLUTE_COLORIMETRIC", ",", "flags", "=", "FLAGS", ...
https://github.com/vcheckzen/FODI/blob/3bb23644938a33c3fdfb9611a622e35ed4ce6532/back-end-py/main/3rd/PIL/ImageCms.py#L480-L588
dmlc/dgl
8d14a739bc9e446d6c92ef83eafe5782398118de
python/dgl/udf.py
python
EdgeBatch.batch_size
(self)
return len(self._eid)
Return the number of edges in the batch. Returns ------- int Examples -------- The following example uses PyTorch backend. >>> import dgl >>> import torch >>> # Instantiate a graph >>> g = dgl.graph((torch.tensor([0, 1, 1]), torch.tensor([1, 1, 0]))) >>> # Define a UDF that returns one for each edge >>> def edge_udf(edges): >>> return {'h': torch.ones(edges.batch_size(), 1)} >>> # Creates a feature 'h' >>> g.apply_edges(edge_udf) >>> g.edata['h'] tensor([[1.], [1.], [1.]]) >>> # Use edge UDF in message passing >>> import dgl.function as fn >>> g.update_all(edge_udf, fn.sum('h', 'h')) >>> g.ndata['h'] tensor([[1.], [2.]])
Return the number of edges in the batch.
[ "Return", "the", "number", "of", "edges", "in", "the", "batch", "." ]
def batch_size(self): """Return the number of edges in the batch. Returns ------- int Examples -------- The following example uses PyTorch backend. >>> import dgl >>> import torch >>> # Instantiate a graph >>> g = dgl.graph((torch.tensor([0, 1, 1]), torch.tensor([1, 1, 0]))) >>> # Define a UDF that returns one for each edge >>> def edge_udf(edges): >>> return {'h': torch.ones(edges.batch_size(), 1)} >>> # Creates a feature 'h' >>> g.apply_edges(edge_udf) >>> g.edata['h'] tensor([[1.], [1.], [1.]]) >>> # Use edge UDF in message passing >>> import dgl.function as fn >>> g.update_all(edge_udf, fn.sum('h', 'h')) >>> g.ndata['h'] tensor([[1.], [2.]]) """ return len(self._eid)
[ "def", "batch_size", "(", "self", ")", ":", "return", "len", "(", "self", ".", "_eid", ")" ]
https://github.com/dmlc/dgl/blob/8d14a739bc9e446d6c92ef83eafe5782398118de/python/dgl/udf.py#L182-L217
tanghaibao/goatools
647e9dd833695f688cd16c2f9ea18f1692e5c6bc
goatools/godag_small.py
python
GODagSmall.__init__
(self)
[]
def __init__(self): # Sub-graph of input DAG. User has option of using a subset of children/parents self.go_sources = None self.go2obj = {} self.p_from_cs = defaultdict(set) # GO ids for child->parents self.c_from_ps = defaultdict(set)
[ "def", "__init__", "(", "self", ")", ":", "# Sub-graph of input DAG. User has option of using a subset of children/parents", "self", ".", "go_sources", "=", "None", "self", ".", "go2obj", "=", "{", "}", "self", ".", "p_from_cs", "=", "defaultdict", "(", "set", ")", ...
https://github.com/tanghaibao/goatools/blob/647e9dd833695f688cd16c2f9ea18f1692e5c6bc/goatools/godag_small.py#L11-L16
RDFLib/rdflib
c0bd5eaaa983461445b9469d731be4ae0e0cfc54
rdflib/term.py
python
Literal.__add__
(self, val)
>>> Literal(1) + 1 rdflib.term.Literal(u'2', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#integer')) >>> Literal("1") + "1" rdflib.term.Literal(u'11')
>>> Literal(1) + 1 rdflib.term.Literal(u'2', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#integer')) >>> Literal("1") + "1" rdflib.term.Literal(u'11')
[ ">>>", "Literal", "(", "1", ")", "+", "1", "rdflib", ".", "term", ".", "Literal", "(", "u", "2", "datatype", "=", "rdflib", ".", "term", ".", "URIRef", "(", "u", "http", ":", "//", "www", ".", "w3", ".", "org", "/", "2001", "/", "XMLSchema#intege...
def __add__(self, val): """ >>> Literal(1) + 1 rdflib.term.Literal(u'2', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#integer')) >>> Literal("1") + "1" rdflib.term.Literal(u'11') """ # if no val is supplied, return this Literal if val is None: return self # convert the val to a Literal, if it isn't already one if not isinstance(val, Literal): val = Literal(val) # if the datatypes are the same, just add the Python values and convert back if self.datatype == val.datatype: return Literal( self.toPython() + val.toPython(), self.language, datatype=self.datatype ) # if the datatypes are not the same but are both numeric, add the Python values and strip off decimal junk # (i.e. tiny numbers (more than 17 decimal places) and trailing zeros) and return as a decimal elif ( self.datatype in _NUMERIC_LITERAL_TYPES and val.datatype in _NUMERIC_LITERAL_TYPES ): return Literal( Decimal( ( "%f" % round(Decimal(self.toPython()) + Decimal(val.toPython()), 15) ) .rstrip("0") .rstrip(".") ), datatype=_XSD_DECIMAL, ) # in all other cases, perform string concatenation else: try: s = str.__add__(self, val) except TypeError: s = str(self.value) + str(val) # if the original datatype is string-like, use that if self.datatype in _STRING_LITERAL_TYPES: new_datatype = self.datatype # if not, use string else: new_datatype = _XSD_STRING return Literal(s, self.language, datatype=new_datatype)
[ "def", "__add__", "(", "self", ",", "val", ")", ":", "# if no val is supplied, return this Literal", "if", "val", "is", "None", ":", "return", "self", "# convert the val to a Literal, if it isn't already one", "if", "not", "isinstance", "(", "val", ",", "Literal", ")"...
https://github.com/RDFLib/rdflib/blob/c0bd5eaaa983461445b9469d731be4ae0e0cfc54/rdflib/term.py#L665-L717
fastnlp/fastNLP
fb645d370f4cc1b00c7dbb16c1ff4542327c46e5
fastNLP/io/loader/classification.py
python
DBPediaLoader.download
(self, dev_ratio: float = 0.0, re_download: bool = False)
return data_dir
r""" 自动下载数据集,如果你使用了这个数据集,请引用以下的文章 Xiang Zhang, Junbo Zhao, Yann LeCun. Character-level Convolutional Networks for Text Classification. Advances in Neural Information Processing Systems 28 (NIPS 2015) 如果dev_ratio不等于0,则根据dev_ratio的值随机将train中的数据取出一部分作为dev数据。 下载完成后在output_dir中有train.csv, test.csv, dev.csv三个文件。否则只有train.csv和test.csv :param float dev_ratio: 如果路径中没有dev集,从train划分多少作为dev的数据. 如果为0,则不划分dev。 :param bool re_download: 是否重新下载数据,以重新切分数据。 :return: str, 数据集的目录地址
r""" 自动下载数据集,如果你使用了这个数据集,请引用以下的文章
[ "r", "自动下载数据集,如果你使用了这个数据集,请引用以下的文章" ]
def download(self, dev_ratio: float = 0.0, re_download: bool = False): r""" 自动下载数据集,如果你使用了这个数据集,请引用以下的文章 Xiang Zhang, Junbo Zhao, Yann LeCun. Character-level Convolutional Networks for Text Classification. Advances in Neural Information Processing Systems 28 (NIPS 2015) 如果dev_ratio不等于0,则根据dev_ratio的值随机将train中的数据取出一部分作为dev数据。 下载完成后在output_dir中有train.csv, test.csv, dev.csv三个文件。否则只有train.csv和test.csv :param float dev_ratio: 如果路径中没有dev集,从train划分多少作为dev的数据. 如果为0,则不划分dev。 :param bool re_download: 是否重新下载数据,以重新切分数据。 :return: str, 数据集的目录地址 """ dataset_name = 'dbpedia' data_dir = self._get_dataset_path(dataset_name=dataset_name) data_dir = _split_dev(dataset_name=dataset_name, data_dir=data_dir, dev_ratio=dev_ratio, re_download=re_download, suffix='csv') return data_dir
[ "def", "download", "(", "self", ",", "dev_ratio", ":", "float", "=", "0.0", ",", "re_download", ":", "bool", "=", "False", ")", ":", "dataset_name", "=", "'dbpedia'", "data_dir", "=", "self", ".", "_get_dataset_path", "(", "dataset_name", "=", "dataset_name"...
https://github.com/fastnlp/fastNLP/blob/fb645d370f4cc1b00c7dbb16c1ff4542327c46e5/fastNLP/io/loader/classification.py#L139-L160
jgagneastro/coffeegrindsize
22661ebd21831dba4cf32bfc6ba59fe3d49f879c
App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/pandas/core/indexes/api.py
python
_get_distinct_objs
(objs)
return res
Return a list with distinct elements of "objs" (different ids). Preserves order.
Return a list with distinct elements of "objs" (different ids). Preserves order.
[ "Return", "a", "list", "with", "distinct", "elements", "of", "objs", "(", "different", "ids", ")", ".", "Preserves", "order", "." ]
def _get_distinct_objs(objs): """ Return a list with distinct elements of "objs" (different ids). Preserves order. """ ids = set() res = [] for obj in objs: if not id(obj) in ids: ids.add(id(obj)) res.append(obj) return res
[ "def", "_get_distinct_objs", "(", "objs", ")", ":", "ids", "=", "set", "(", ")", "res", "=", "[", "]", "for", "obj", "in", "objs", ":", "if", "not", "id", "(", "obj", ")", "in", "ids", ":", "ids", ".", "add", "(", "id", "(", "obj", ")", ")", ...
https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/pandas/core/indexes/api.py#L73-L84
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/networkx/algorithms/cluster.py
python
_directed_weighted_triangles_and_degree_iter
(G, nodes=None, weight = 'weight')
Return an iterator of (node, total_degree, reciprocal_degree, directed_weighted_triangles). Used for directed weighted clustering.
Return an iterator of (node, total_degree, reciprocal_degree, directed_weighted_triangles).
[ "Return", "an", "iterator", "of", "(", "node", "total_degree", "reciprocal_degree", "directed_weighted_triangles", ")", "." ]
def _directed_weighted_triangles_and_degree_iter(G, nodes=None, weight = 'weight'): """ Return an iterator of (node, total_degree, reciprocal_degree, directed_weighted_triangles). Used for directed weighted clustering. """ if weight is None or G.number_of_edges() == 0: max_weight = 1 else: max_weight = max(d.get(weight, 1) for u, v, d in G.edges(data=True)) nodes_nbrs = ((n, G._pred[n], G._succ[n]) for n in G.nbunch_iter(nodes)) def wt(u, v): return G[u][v].get(weight, 1) / max_weight for i, preds, succs in nodes_nbrs: ipreds = set(preds) - {i} isuccs = set(succs) - {i} directed_triangles = 0 for j in ipreds: jpreds = set(G._pred[j]) - {j} jsuccs = set(G._succ[j]) - {j} directed_triangles += sum((wt(j, i) * wt(k, i) * wt(k, j))**(1 / 3) for k in ipreds & jpreds) directed_triangles += sum((wt(j, i) * wt(k, i) * wt(j, k))**(1 / 3) for k in ipreds & jsuccs) directed_triangles += sum((wt(j, i) * wt(i, k) * wt(k, j))**(1 / 3) for k in isuccs & jpreds) directed_triangles += sum((wt(j, i) * wt(i, k) * wt(j, k))**(1 / 3) for k in isuccs & jsuccs) for j in isuccs: jpreds = set(G._pred[j]) - {j} jsuccs = set(G._succ[j]) - {j} directed_triangles += sum((wt(i, j) * wt(k, i) * wt(k, j))**(1 / 3) for k in ipreds & jpreds) directed_triangles += sum((wt(i, j) * wt(k, i) * wt(j, k))**(1 / 3) for k in ipreds & jsuccs) directed_triangles += sum((wt(i, j) * wt(i, k) * wt(k, j))**(1 / 3) for k in isuccs & jpreds) directed_triangles += sum((wt(i, j) * wt(i, k) * wt(j, k))**(1 / 3) for k in isuccs & jsuccs) dtotal = len(ipreds) + len(isuccs) dbidirectional = len(ipreds & isuccs) yield (i, dtotal, dbidirectional, directed_triangles)
[ "def", "_directed_weighted_triangles_and_degree_iter", "(", "G", ",", "nodes", "=", "None", ",", "weight", "=", "'weight'", ")", ":", "if", "weight", "is", "None", "or", "G", ".", "number_of_edges", "(", ")", "==", "0", ":", "max_weight", "=", "1", "else",...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/networkx/algorithms/cluster.py#L156-L204
SteveDoyle2/pyNastran
eda651ac2d4883d95a34951f8a002ff94f642a1a
pyNastran/dev/bdf_vectorized/cards/bdf_sets.py
python
CSET1.raw_fields
(self)
return list_fields
gets the "raw" card without any processing as a list for printing
gets the "raw" card without any processing as a list for printing
[ "gets", "the", "raw", "card", "without", "any", "processing", "as", "a", "list", "for", "printing" ]
def raw_fields(self): """gets the "raw" card without any processing as a list for printing""" list_fields = ['CSET1', self.components] + collapse_thru(self.ids) return list_fields
[ "def", "raw_fields", "(", "self", ")", ":", "list_fields", "=", "[", "'CSET1'", ",", "self", ".", "components", "]", "+", "collapse_thru", "(", "self", ".", "ids", ")", "return", "list_fields" ]
https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/dev/bdf_vectorized/cards/bdf_sets.py#L574-L577
AppScale/gts
46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9
AppServer/lib/django-1.2/django/forms/fields.py
python
MultipleChoiceField.validate
(self, value)
Validates that the input is a list or tuple.
Validates that the input is a list or tuple.
[ "Validates", "that", "the", "input", "is", "a", "list", "or", "tuple", "." ]
def validate(self, value): """ Validates that the input is a list or tuple. """ if self.required and not value: raise ValidationError(self.error_messages['required']) # Validate that each value in the value list is in self.choices. for val in value: if not self.valid_value(val): raise ValidationError(self.error_messages['invalid_choice'] % {'value': val})
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "self", ".", "required", "and", "not", "value", ":", "raise", "ValidationError", "(", "self", ".", "error_messages", "[", "'required'", "]", ")", "# Validate that each value in the value list is in self...
https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.2/django/forms/fields.py#L701-L710
giantbranch/python-hacker-code
addbc8c73e7e6fb9e4fcadcec022fa1d3da4b96d
我手敲的代码(中文注释)/chapter11/volatility/obj.py
python
CType.v
(self)
return long(self.obj_offset)
When a struct is evaluated we just return our offset.
When a struct is evaluated we just return our offset.
[ "When", "a", "struct", "is", "evaluated", "we", "just", "return", "our", "offset", "." ]
def v(self): """ When a struct is evaluated we just return our offset. """ # Ensure that proxied offsets are converted to longs # to avoid integer boundaries when doing __rand__ proxying # (see issue 265) return long(self.obj_offset)
[ "def", "v", "(", "self", ")", ":", "# Ensure that proxied offsets are converted to longs", "# to avoid integer boundaries when doing __rand__ proxying", "# (see issue 265)", "return", "long", "(", "self", ".", "obj_offset", ")" ]
https://github.com/giantbranch/python-hacker-code/blob/addbc8c73e7e6fb9e4fcadcec022fa1d3da4b96d/我手敲的代码(中文注释)/chapter11/volatility/obj.py#L697-L703
DamnWidget/anaconda
a9998fb362320f907d5ccbc6fcf5b62baca677c0
anaconda_lib/explore_panel.py
python
ExplorerPanel.on_select
(self, index: int, transient: bool=False)
Called when an option is been made in the quick panel
Called when an option is been made in the quick panel
[ "Called", "when", "an", "option", "is", "been", "made", "in", "the", "quick", "panel" ]
def on_select(self, index: int, transient: bool=False) -> None: """Called when an option is been made in the quick panel """ if index == -1: self._restore_view() return cluster = self.last_cluster node = cluster[index] if transient and 'options' in node: return if 'options' in node: self.prev_cluster = self.last_cluster opts = node['options'][:] opts.insert(0, {'title': '<- Go Back', 'position': 'back'}) sublime.set_timeout(lambda: self.show(opts), 0) else: if node['position'] == 'back' and not transient: sublime.set_timeout(lambda: self.show(self.prev_cluster), 0) elif node['position'] != 'back': Jumper(self.view, node['position']).jump(transient)
[ "def", "on_select", "(", "self", ",", "index", ":", "int", ",", "transient", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "index", "==", "-", "1", ":", "self", ".", "_restore_view", "(", ")", "return", "cluster", "=", "self", ".", "last...
https://github.com/DamnWidget/anaconda/blob/a9998fb362320f907d5ccbc6fcf5b62baca677c0/anaconda_lib/explore_panel.py#L77-L99
TryCatchHCF/DumpsterFire
43b46a274663ff694763db6e627975e160bc3597
FireModules/Shenanigans/osx_rickroll_multi_dialogs.py
python
osx_rickroll_multi_dialogs.__init__
(self)
[]
def __init__(self): self.commentsStr = "Shenanigans/osx_rickroll_multi_dialogs" self.textToSayStr = ""
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "commentsStr", "=", "\"Shenanigans/osx_rickroll_multi_dialogs\"", "self", ".", "textToSayStr", "=", "\"\"" ]
https://github.com/TryCatchHCF/DumpsterFire/blob/43b46a274663ff694763db6e627975e160bc3597/FireModules/Shenanigans/osx_rickroll_multi_dialogs.py#L27-L29
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/logging/__init__.py
python
warning
(msg, *args, **kwargs)
Log a message with severity 'WARNING' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format.
Log a message with severity 'WARNING' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format.
[ "Log", "a", "message", "with", "severity", "WARNING", "on", "the", "root", "logger", ".", "If", "the", "logger", "has", "no", "handlers", "call", "basicConfig", "()", "to", "add", "a", "console", "handler", "with", "a", "pre", "-", "defined", "format", "...
def warning(msg, *args, **kwargs): """ Log a message with severity 'WARNING' on the root logger. If the logger has no handlers, call basicConfig() to add a console handler with a pre-defined format. """ if len(root.handlers) == 0: basicConfig() root.warning(msg, *args, **kwargs)
[ "def", "warning", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "root", ".", "handlers", ")", "==", "0", ":", "basicConfig", "(", ")", "root", ".", "warning", "(", "msg", ",", "*", "args", ",", "*", "*", "...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/logging/__init__.py#L2106-L2114
rwth-i6/returnn
f2d718a197a280b0d5f0fd91a7fcb8658560dddb
returnn/util/debug.py
python
auto_exclude_all_new_threads
(func)
return wrapped
:param T func: :return: func wrapped :rtype: T
:param T func: :return: func wrapped :rtype: T
[ ":", "param", "T", "func", ":", ":", "return", ":", "func", "wrapped", ":", "rtype", ":", "T" ]
def auto_exclude_all_new_threads(func): """ :param T func: :return: func wrapped :rtype: T """ def wrapped(*args, **kwargs): """ :param args: :param kwargs: :return: """ # noinspection PyProtectedMember,PyUnresolvedReferences old_threads = set(sys._current_frames().keys()) res = func(*args, **kwargs) # noinspection PyProtectedMember,PyUnresolvedReferences new_threads = set(sys._current_frames().keys()) new_threads -= old_threads global_exclude_thread_ids.update(new_threads) return res return wrapped
[ "def", "auto_exclude_all_new_threads", "(", "func", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n :param args:\n :param kwargs:\n :return:\n \"\"\"", "# noinspection PyProtectedMember,PyUnresolvedReferences", "old_threads...
https://github.com/rwth-i6/returnn/blob/f2d718a197a280b0d5f0fd91a7fcb8658560dddb/returnn/util/debug.py#L24-L45
deepfakes/faceswap
09c7d8aca3c608d1afad941ea78e9fd9b64d9219
tools/effmpeg/effmpeg.py
python
Effmpeg.mux_audio
(input_=None, output=None, ref_vid=None, # pylint:disable=unused-argument exe=None, **kwargs)
Mux Audio
Mux Audio
[ "Mux", "Audio" ]
def mux_audio(input_=None, output=None, ref_vid=None, # pylint:disable=unused-argument exe=None, **kwargs): """ Mux Audio """ _input_opts = Effmpeg._common_ffmpeg_args[:] _ref_vid_opts = None _output_opts = '-y -c copy -map 0:0 -map 1:1 -shortest' _inputs = OrderedDict([(input_.path, _input_opts), (ref_vid.path, _ref_vid_opts)]) _outputs = {output.path: _output_opts} Effmpeg.__run_ffmpeg(exe=exe, inputs=_inputs, outputs=_outputs)
[ "def", "mux_audio", "(", "input_", "=", "None", ",", "output", "=", "None", ",", "ref_vid", "=", "None", ",", "# pylint:disable=unused-argument", "exe", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_input_opts", "=", "Effmpeg", ".", "_common_ffmpeg_args"...
https://github.com/deepfakes/faceswap/blob/09c7d8aca3c608d1afad941ea78e9fd9b64d9219/tools/effmpeg/effmpeg.py#L400-L408
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials
5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e
deep-learning/fastai-docs/fastai_docs-master/dev_nb/nb_004a.py
python
first_layer
(m:nn.Module)
return flatten_model(m)[0]
Retrieve first layer in a module
Retrieve first layer in a module
[ "Retrieve", "first", "layer", "in", "a", "module" ]
def first_layer(m:nn.Module)->nn.Module: "Retrieve first layer in a module" return flatten_model(m)[0]
[ "def", "first_layer", "(", "m", ":", "nn", ".", "Module", ")", "->", "nn", ".", "Module", ":", "return", "flatten_model", "(", "m", ")", "[", "0", "]" ]
https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/deep-learning/fastai-docs/fastai_docs-master/dev_nb/nb_004a.py#L157-L159
bpython/curtsies
56a0ad1199d346a059635982aa87ca07be17e14a
curtsies/termhelpers.py
python
Nonblocking.__init__
(self, stream: IO)
[]
def __init__(self, stream: IO) -> None: self.stream = stream self.fd = self.stream.fileno()
[ "def", "__init__", "(", "self", ",", "stream", ":", "IO", ")", "->", "None", ":", "self", ".", "stream", "=", "stream", "self", ".", "fd", "=", "self", ".", "stream", ".", "fileno", "(", ")" ]
https://github.com/bpython/curtsies/blob/56a0ad1199d346a059635982aa87ca07be17e14a/curtsies/termhelpers.py#L17-L19
1012598167/flask_mongodb_game
60c7e0351586656ec38f851592886338e50b4110
python_flask/venv/Lib/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/pkg_resources/__init__.py
python
WorkingSet.add
(self, dist, entry=None, insert=True, replace=False)
Add `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set, unless `replace=True`. If it's added, any callbacks registered with the ``subscribe()`` method will be called.
Add `dist` to working set, associated with `entry`
[ "Add", "dist", "to", "working", "set", "associated", "with", "entry" ]
def add(self, dist, entry=None, insert=True, replace=False): """Add `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set, unless `replace=True`. If it's added, any callbacks registered with the ``subscribe()`` method will be called. """ if insert: dist.insert_on(self.entries, entry, replace=replace) if entry is None: entry = dist.location keys = self.entry_keys.setdefault(entry, []) keys2 = self.entry_keys.setdefault(dist.location, []) if not replace and dist.key in self.by_key: # ignore hidden distros return self.by_key[dist.key] = dist if dist.key not in keys: keys.append(dist.key) if dist.key not in keys2: keys2.append(dist.key) self._added_new(dist)
[ "def", "add", "(", "self", ",", "dist", ",", "entry", "=", "None", ",", "insert", "=", "True", ",", "replace", "=", "False", ")", ":", "if", "insert", ":", "dist", ".", "insert_on", "(", "self", ".", "entries", ",", "entry", ",", "replace", "=", ...
https://github.com/1012598167/flask_mongodb_game/blob/60c7e0351586656ec38f851592886338e50b4110/python_flask/venv/Lib/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/pkg_resources/__init__.py#L683-L711
danielfrg/copper
956e9ae607aec461d4fe4f6e7b0ccd9ed556fc79
dev/ml/gdbn/gdbn/gnumpy.py
python
garray.isreal
(self)
return (self<numpy.inf) * (self>-numpy.inf)
elementwise, checking for real numbers. See also .all_real()
elementwise, checking for real numbers. See also .all_real()
[ "elementwise", "checking", "for", "real", "numbers", ".", "See", "also", ".", "all_real", "()" ]
def isreal(self): """ elementwise, checking for real numbers. See also .all_real() """ return (self<numpy.inf) * (self>-numpy.inf)
[ "def", "isreal", "(", "self", ")", ":", "return", "(", "self", "<", "numpy", ".", "inf", ")", "*", "(", "self", ">", "-", "numpy", ".", "inf", ")" ]
https://github.com/danielfrg/copper/blob/956e9ae607aec461d4fe4f6e7b0ccd9ed556fc79/dev/ml/gdbn/gdbn/gnumpy.py#L875-L877
google/mysql-tools
02d18542735a528c4a6cca951207393383266bb9
permissions_lib/utils.py
python
DecryptHash
(key, ciphertext)
Decrypt a hash with a private key.
Decrypt a hash with a private key.
[ "Decrypt", "a", "hash", "with", "a", "private", "key", "." ]
def DecryptHash(key, ciphertext): """Decrypt a hash with a private key.""" encrypted = base64.b64decode(ciphertext) plaintext = key.decrypt(compat.stringToBytes(encrypted)) if plaintext: return compat.bytesToString(plaintext) else: # decryption failed return None
[ "def", "DecryptHash", "(", "key", ",", "ciphertext", ")", ":", "encrypted", "=", "base64", ".", "b64decode", "(", "ciphertext", ")", "plaintext", "=", "key", ".", "decrypt", "(", "compat", ".", "stringToBytes", "(", "encrypted", ")", ")", "if", "plaintext"...
https://github.com/google/mysql-tools/blob/02d18542735a528c4a6cca951207393383266bb9/permissions_lib/utils.py#L120-L128
lebedov/scikit-cuda
5d3c74f926fe7ce67ecfc85e9623aab7bc0b344f
skcuda/magma.py
python
magma_sgetrf_gpu
(n, m, A, lda, ipiv)
LU factorization.
LU factorization.
[ "LU", "factorization", "." ]
def magma_sgetrf_gpu(n, m, A, lda, ipiv): """ LU factorization. """ info = c_int_type() status = _libmagma.magma_sgetrf_gpu(n, m, int(A), lda, int(ipiv), ctypes.byref(info)) magmaCheckStatus(status)
[ "def", "magma_sgetrf_gpu", "(", "n", ",", "m", ",", "A", ",", "lda", ",", "ipiv", ")", ":", "info", "=", "c_int_type", "(", ")", "status", "=", "_libmagma", ".", "magma_sgetrf_gpu", "(", "n", ",", "m", ",", "int", "(", "A", ")", ",", "lda", ",", ...
https://github.com/lebedov/scikit-cuda/blob/5d3c74f926fe7ce67ecfc85e9623aab7bc0b344f/skcuda/magma.py#L3402-L3410
Cog-Creators/Red-DiscordBot
b05933274a11fb097873ab0d1b246d37b06aa306
redbot/cogs/audio/core/commands/audioset.py
python
AudioSetCommands.command_audioset_restart
(self, ctx: commands.Context)
Restarts the lavalink connection.
Restarts the lavalink connection.
[ "Restarts", "the", "lavalink", "connection", "." ]
async def command_audioset_restart(self, ctx: commands.Context): """Restarts the lavalink connection.""" async with ctx.typing(): await lavalink.close(self.bot) if self.player_manager is not None: await self.player_manager.shutdown() self.lavalink_restart_connect() await self.send_embed_msg( ctx, title=_("Restarting Lavalink"), description=_("It can take a couple of minutes for Lavalink to fully start up."), )
[ "async", "def", "command_audioset_restart", "(", "self", ",", "ctx", ":", "commands", ".", "Context", ")", ":", "async", "with", "ctx", ".", "typing", "(", ")", ":", "await", "lavalink", ".", "close", "(", "self", ".", "bot", ")", "if", "self", ".", ...
https://github.com/Cog-Creators/Red-DiscordBot/blob/b05933274a11fb097873ab0d1b246d37b06aa306/redbot/cogs/audio/core/commands/audioset.py#L1448-L1461
tendenci/tendenci
0f2c348cc0e7d41bc56f50b00ce05544b083bf1d
tendenci/apps/events/admin.py
python
StandardRegFormAdmin.edit_regform_view
(self, request)
return render_to_resp(request=request, template_name='admin/events/standardregform/standard_reg_form_edit.html', context={'adminform': form})
[]
def edit_regform_view(self, request): form = StandardRegAdminForm(request.POST or None) if request.method == 'POST' and form.is_valid(): form.apply_changes() delete_settings_cache('module', 'events') messages.success(request, "Successfully updated Standard Registration Form") return redirect(reverse('admin:standardregform_edit')) return render_to_resp(request=request, template_name='admin/events/standardregform/standard_reg_form_edit.html', context={'adminform': form})
[ "def", "edit_regform_view", "(", "self", ",", "request", ")", ":", "form", "=", "StandardRegAdminForm", "(", "request", ".", "POST", "or", "None", ")", "if", "request", ".", "method", "==", "'POST'", "and", "form", ".", "is_valid", "(", ")", ":", "form",...
https://github.com/tendenci/tendenci/blob/0f2c348cc0e7d41bc56f50b00ce05544b083bf1d/tendenci/apps/events/admin.py#L274-L284
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/caldav/calendar.py
python
WebDavCalendarData.is_matching
(vevent, search)
return ( hasattr(vevent, "summary") and pattern.match(vevent.summary.value) or hasattr(vevent, "location") and pattern.match(vevent.location.value) or hasattr(vevent, "description") and pattern.match(vevent.description.value) )
Return if the event matches the filter criteria.
Return if the event matches the filter criteria.
[ "Return", "if", "the", "event", "matches", "the", "filter", "criteria", "." ]
def is_matching(vevent, search): """Return if the event matches the filter criteria.""" if search is None: return True pattern = re.compile(search) return ( hasattr(vevent, "summary") and pattern.match(vevent.summary.value) or hasattr(vevent, "location") and pattern.match(vevent.location.value) or hasattr(vevent, "description") and pattern.match(vevent.description.value) )
[ "def", "is_matching", "(", "vevent", ",", "search", ")", ":", "if", "search", "is", "None", ":", "return", "True", "pattern", "=", "re", ".", "compile", "(", "search", ")", "return", "(", "hasattr", "(", "vevent", ",", "\"summary\"", ")", "and", "patte...
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/caldav/calendar.py#L274-L287
pytorch/captum
38b57082d22854013c0a0b80a51c0b85269afdaf
captum/attr/_models/base.py
python
_get_deep_layer_name
(obj, layer_names)
return reduce(getattr, layer_names.split("."), obj)
r""" Traverses through the layer names that are separated by dot in order to access the embedding layer.
r""" Traverses through the layer names that are separated by dot in order to access the embedding layer.
[ "r", "Traverses", "through", "the", "layer", "names", "that", "are", "separated", "by", "dot", "in", "order", "to", "access", "the", "embedding", "layer", "." ]
def _get_deep_layer_name(obj, layer_names): r""" Traverses through the layer names that are separated by dot in order to access the embedding layer. """ return reduce(getattr, layer_names.split("."), obj)
[ "def", "_get_deep_layer_name", "(", "obj", ",", "layer_names", ")", ":", "return", "reduce", "(", "getattr", ",", "layer_names", ".", "split", "(", "\".\"", ")", ",", "obj", ")" ]
https://github.com/pytorch/captum/blob/38b57082d22854013c0a0b80a51c0b85269afdaf/captum/attr/_models/base.py#L123-L128
DeloitteDigitalUK/jira-agile-metrics
55a4b1a68c767b65aa03036e481a993e1a233da4
jira_agile_metrics/querymanager.py
python
QueryManager.resolve_attribute_value
(self, issue, attribute_name)
return self.resolve_field_value(issue, field_id)
Given an attribute name (i.e. one named in the config file and mapped to a field in JIRA), return its value from the given issue. Respects the `Known Values` settings and tries to resolve complex data types.
Given an attribute name (i.e. one named in the config file and mapped to a field in JIRA), return its value from the given issue. Respects the `Known Values` settings and tries to resolve complex data types.
[ "Given", "an", "attribute", "name", "(", "i", ".", "e", ".", "one", "named", "in", "the", "config", "file", "and", "mapped", "to", "a", "field", "in", "JIRA", ")", "return", "its", "value", "from", "the", "given", "issue", ".", "Respects", "the", "Kn...
def resolve_attribute_value(self, issue, attribute_name): """Given an attribute name (i.e. one named in the config file and mapped to a field in JIRA), return its value from the given issue. Respects the `Known Values` settings and tries to resolve complex data types. """ field_id = self.attributes_to_fields[attribute_name] return self.resolve_field_value(issue, field_id)
[ "def", "resolve_attribute_value", "(", "self", ",", "issue", ",", "attribute_name", ")", ":", "field_id", "=", "self", ".", "attributes_to_fields", "[", "attribute_name", "]", "return", "self", ".", "resolve_field_value", "(", "issue", ",", "field_id", ")" ]
https://github.com/DeloitteDigitalUK/jira-agile-metrics/blob/55a4b1a68c767b65aa03036e481a993e1a233da4/jira_agile_metrics/querymanager.py#L107-L114
Mingtzge/2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement
42ad9686f3c3bde0d29a8bc6bcb0e3afb35fb3c3
recognize_process/data_provider/write_tfrecord.py
python
_write_tfrecords
(tfrecords_writer)
[]
def _write_tfrecords(tfrecords_writer): while True: sample_info = _SAMPLE_INFO_QUEUE.get() if sample_info == _SENTINEL: print('Process {:d} finished writing work'.format(os.getpid())) tfrecords_writer.close() break sample_path = sample_info[0] sample_label = sample_info[1] if _is_valid_jpg_file(sample_path): print('Image file: {:d} is not a valid jpg file'.format(sample_path)) continue try: image = cv2.imread(sample_path, cv2.IMREAD_COLOR) if image is None: continue image = _resize_image(image) image = image.tostring() except IOError as err: print(err) continue sample_path = sample_path if sys.version_info[0] < 3 else sample_path.encode('utf-8') features = tf.train.Features(feature={ 'labels': _int64_feature(sample_label), 'images': _bytes_feature(image), 'imagepaths': _bytes_feature(sample_path) }) tf_example = tf.train.Example(features=features) tfrecords_writer.write(tf_example.SerializeToString())
[ "def", "_write_tfrecords", "(", "tfrecords_writer", ")", ":", "while", "True", ":", "sample_info", "=", "_SAMPLE_INFO_QUEUE", ".", "get", "(", ")", "if", "sample_info", "==", "_SENTINEL", ":", "print", "(", "'Process {:d} finished writing work'", ".", "format", "(...
https://github.com/Mingtzge/2019-CCF-BDCI-OCR-MCZJ-OCR-IdentificationIDElement/blob/42ad9686f3c3bde0d29a8bc6bcb0e3afb35fb3c3/recognize_process/data_provider/write_tfrecord.py#L165-L197
emmetio/livestyle-sublime-old
c42833c046e9b2f53ebce3df3aa926528f5a33b5
tornado/curl_httpclient.py
python
_curl_create
()
return curl
[]
def _curl_create(): curl = pycurl.Curl() if gen_log.isEnabledFor(logging.DEBUG): curl.setopt(pycurl.VERBOSE, 1) curl.setopt(pycurl.DEBUGFUNCTION, _curl_debug) return curl
[ "def", "_curl_create", "(", ")", ":", "curl", "=", "pycurl", ".", "Curl", "(", ")", "if", "gen_log", ".", "isEnabledFor", "(", "logging", ".", "DEBUG", ")", ":", "curl", ".", "setopt", "(", "pycurl", ".", "VERBOSE", ",", "1", ")", "curl", ".", "set...
https://github.com/emmetio/livestyle-sublime-old/blob/c42833c046e9b2f53ebce3df3aa926528f5a33b5/tornado/curl_httpclient.py#L286-L291
CvvT/dumpDex
92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1
python/idaapi.py
python
qvector_history_t.has
(self, *args)
return _idaapi.qvector_history_t_has(self, *args)
has(self, x) -> bool
has(self, x) -> bool
[ "has", "(", "self", "x", ")", "-", ">", "bool" ]
def has(self, *args): """ has(self, x) -> bool """ return _idaapi.qvector_history_t_has(self, *args)
[ "def", "has", "(", "self", ",", "*", "args", ")", ":", "return", "_idaapi", ".", "qvector_history_t_has", "(", "self", ",", "*", "args", ")" ]
https://github.com/CvvT/dumpDex/blob/92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1/python/idaapi.py#L34430-L34434
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-linux/x64/psutil/_common.py
python
conn_to_ntuple
(fd, fam, type_, laddr, raddr, status, status_map, pid=None)
Convert a raw connection tuple to a proper ntuple.
Convert a raw connection tuple to a proper ntuple.
[ "Convert", "a", "raw", "connection", "tuple", "to", "a", "proper", "ntuple", "." ]
def conn_to_ntuple(fd, fam, type_, laddr, raddr, status, status_map, pid=None): """Convert a raw connection tuple to a proper ntuple.""" if fam in (socket.AF_INET, AF_INET6): if laddr: laddr = addr(*laddr) if raddr: raddr = addr(*raddr) if type_ == socket.SOCK_STREAM and fam in (AF_INET, AF_INET6): status = status_map.get(status, CONN_NONE) else: status = CONN_NONE # ignore whatever C returned to us fam = sockfam_to_enum(fam) type_ = socktype_to_enum(type_) if pid is None: return pconn(fd, fam, type_, laddr, raddr, status) else: return sconn(fd, fam, type_, laddr, raddr, status, pid)
[ "def", "conn_to_ntuple", "(", "fd", ",", "fam", ",", "type_", ",", "laddr", ",", "raddr", ",", "status", ",", "status_map", ",", "pid", "=", "None", ")", ":", "if", "fam", "in", "(", "socket", ".", "AF_INET", ",", "AF_INET6", ")", ":", "if", "laddr...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/psutil/_common.py#L574-L590
Anaconda-Platform/anaconda-project
df5ec33c12591e6512436d38d36c6132fa2e9618
anaconda_project/project.py
python
_ConfigCache._update_lock_sets
(self, problems, lock_file)
[]
def _update_lock_sets(self, problems, lock_file): self.lock_sets = dict() self.locking_globally_enabled = False enabled = lock_file.get_value(['locking_enabled'], True) if not isinstance(enabled, bool): _file_problem(problems, lock_file, "Value for locking_enabled should be true or false, found %r" % enabled) else: self.locking_globally_enabled = enabled lock_sets = lock_file.get_value(['env_specs'], {}) if not is_dict(lock_sets): _file_problem(problems, lock_file, ("'env_specs:' section in lock file should be a dictionary from " + "env spec names to lock information, found {}").format(repr(lock_sets))) return for (name, lock_set) in lock_sets.items(): if not is_dict(lock_set): _file_problem( problems, lock_file, "Field '%s' in env_specs in lock file should be a dictionary, found %r" % (name, lock_set)) continue _unknown_field_suggestions(lock_file, problems, lock_set, ('packages', 'dependencies', 'platforms', 'locked', 'env_spec_hash')) enabled = lock_set.get('locked', self.locking_globally_enabled) if not isinstance(enabled, bool): _file_problem(problems, lock_file, "Value for locked for env spec '%s' should be true or false, found %r" % (name, enabled)) continue env_spec_hash = lock_set.get('env_spec_hash', None) # we deliberately don't check the hash length or format, because we might # want to evolve those someday, and if someone sets the hash by hand to # "foobar" that's fine, won't hurt anything. if env_spec_hash is not None and not is_string(env_spec_hash): _file_problem( problems, lock_file, "Value for env_spec_hash for env spec '%s' should be a string, found %r" % (name, env_spec_hash)) continue platforms = self._parse_platforms(problems, lock_file, lock_set) conda_packages_by_platform = dict() packages_by_platform = lock_set.get('packages', {}) if not is_dict(packages_by_platform): _file_problem( problems, lock_file, "'packages:' section in env spec '%s' in lock file should be a dictionary, found %r" % (name, packages_by_platform)) continue for platform in packages_by_platform.keys(): previous_problem_count = len(problems) # this may set problems due to invalid package specs (deps, pip_deps) = self._parse_packages(problems, lock_file, platform, packages_by_platform) if len(problems) > previous_problem_count: continue if len(pip_deps) > 0: # we warn but don't fail on this, so if we add pip support in the future # older versions of anaconda-project won't puke on it. problems.append( ProjectProblem(text="env spec '%s': pip dependencies are currently ignored in the lock file" % name, filename=lock_file.filename, only_a_suggestion=True)) conda_packages_by_platform[platform] = deps lock_set_object = CondaLockSet(package_specs_by_platform=conda_packages_by_platform, platforms=platforms, enabled=enabled) lock_set_object.env_spec_hash = env_spec_hash self.lock_sets[name] = lock_set_object
[ "def", "_update_lock_sets", "(", "self", ",", "problems", ",", "lock_file", ")", ":", "self", ".", "lock_sets", "=", "dict", "(", ")", "self", ".", "locking_globally_enabled", "=", "False", "enabled", "=", "lock_file", ".", "get_value", "(", "[", "'locking_e...
https://github.com/Anaconda-Platform/anaconda-project/blob/df5ec33c12591e6512436d38d36c6132fa2e9618/anaconda_project/project.py#L487-L564
RittmanMead/md_to_conf
964f6089c49b0e30e3bd9f74e61332c3463109e4
md2conf.py
python
convert_comment_block
(html)
return html
Convert markdown code bloc to Confluence hidden comment :param html: string :return: modified html string
Convert markdown code bloc to Confluence hidden comment
[ "Convert", "markdown", "code", "bloc", "to", "Confluence", "hidden", "comment" ]
def convert_comment_block(html): """ Convert markdown code bloc to Confluence hidden comment :param html: string :return: modified html string """ open_tag = '<ac:placeholder>' close_tag = '</ac:placeholder>' html = html.replace('<!--', open_tag).replace('-->', close_tag) return html
[ "def", "convert_comment_block", "(", "html", ")", ":", "open_tag", "=", "'<ac:placeholder>'", "close_tag", "=", "'</ac:placeholder>'", "html", "=", "html", ".", "replace", "(", "'<!--'", ",", "open_tag", ")", ".", "replace", "(", "'-->'", ",", "close_tag", ")"...
https://github.com/RittmanMead/md_to_conf/blob/964f6089c49b0e30e3bd9f74e61332c3463109e4/md2conf.py#L127-L139
googleanalytics/google-analytics-super-proxy
f5bad82eb1375d222638423e6ae302173a9a7948
src/models/db_models.py
python
ApiQuery.modified_timedelta
(self, from_time=None)
return models_helper.GetModifiedTimedelta(self, from_time)
Returns how long since the API Query was updated.
Returns how long since the API Query was updated.
[ "Returns", "how", "long", "since", "the", "API", "Query", "was", "updated", "." ]
def modified_timedelta(self, from_time=None): """Returns how long since the API Query was updated.""" return models_helper.GetModifiedTimedelta(self, from_time)
[ "def", "modified_timedelta", "(", "self", ",", "from_time", "=", "None", ")", ":", "return", "models_helper", ".", "GetModifiedTimedelta", "(", "self", ",", "from_time", ")" ]
https://github.com/googleanalytics/google-analytics-super-proxy/blob/f5bad82eb1375d222638423e6ae302173a9a7948/src/models/db_models.py#L102-L104
HuberTRoy/leetCode
e19c670fe09035a55692e2b3d2dd993db3be4725
Array/3SumWithMultiplicity.py
python
Solution.threeSumMulti
(self, A, target)
return result % mod
:type A: List[int] :type target: int :rtype: int
:type A: List[int] :type target: int :rtype: int
[ ":", "type", "A", ":", "List", "[", "int", "]", ":", "type", "target", ":", "int", ":", "rtype", ":", "int" ]
def threeSumMulti(self, A, target): """ :type A: List[int] :type target: int :rtype: int """ mod = 10**9 + 7 def get_multiple(time, all_times): if time==1: return all_times elif time==2: return sum(range(all_times)) elif time==3: return sum(plus[:all_times]) x = {} for j in set(A): x[j] = A.count(j) maxes = max(x, key=lambda t: x[t]) plus = [sum(range(i)) for i in range(x[maxes])] A = [] for i in sorted(x.keys()): if x[i] > 3: A.extend([i]*3) else: A.extend([i]*x[i]) result = 0 length = len(A) - 1 sets = set() for i in range(length): t = target - A[i] start = i+1 end = length while start < end: if A[start] + A[end] == t: # pass _ = [A[i], A[start], A[end]] y = {e:_.count(e) for e in set(_)} _ = "{}{}{}".format(*_) if _ in sets: start += 1 continue c = 1 for g in y: c *= get_multiple(y[g], x[g]) result += c sets.add(_) start += 1 if A[start] + A[end] > t: end -= 1 else: start += 1 return result % mod
[ "def", "threeSumMulti", "(", "self", ",", "A", ",", "target", ")", ":", "mod", "=", "10", "**", "9", "+", "7", "def", "get_multiple", "(", "time", ",", "all_times", ")", ":", "if", "time", "==", "1", ":", "return", "all_times", "elif", "time", "=="...
https://github.com/HuberTRoy/leetCode/blob/e19c670fe09035a55692e2b3d2dd993db3be4725/Array/3SumWithMultiplicity.py#L81-L144
mrlesmithjr/Ansible
d44f0dc0d942bdf3bf7334b307e6048f0ee16e36
roles/ansible-vsphere-management/scripts/pdns/lib/python2.7/site-packages/pip/_vendor/ipaddress.py
python
_BaseV6._compress_hextets
(cls, hextets)
return hextets
Compresses a list of hextets. Compresses a list of strings, replacing the longest continuous sequence of "0" in the list with "" and adding empty strings at the beginning or at the end of the string such that subsequently calling ":".join(hextets) will produce the compressed version of the IPv6 address. Args: hextets: A list of strings, the hextets to compress. Returns: A list of strings.
Compresses a list of hextets.
[ "Compresses", "a", "list", "of", "hextets", "." ]
def _compress_hextets(cls, hextets): """Compresses a list of hextets. Compresses a list of strings, replacing the longest continuous sequence of "0" in the list with "" and adding empty strings at the beginning or at the end of the string such that subsequently calling ":".join(hextets) will produce the compressed version of the IPv6 address. Args: hextets: A list of strings, the hextets to compress. Returns: A list of strings. """ best_doublecolon_start = -1 best_doublecolon_len = 0 doublecolon_start = -1 doublecolon_len = 0 for index, hextet in enumerate(hextets): if hextet == '0': doublecolon_len += 1 if doublecolon_start == -1: # Start of a sequence of zeros. doublecolon_start = index if doublecolon_len > best_doublecolon_len: # This is the longest sequence of zeros so far. best_doublecolon_len = doublecolon_len best_doublecolon_start = doublecolon_start else: doublecolon_len = 0 doublecolon_start = -1 if best_doublecolon_len > 1: best_doublecolon_end = (best_doublecolon_start + best_doublecolon_len) # For zeros at the end of the address. if best_doublecolon_end == len(hextets): hextets += [''] hextets[best_doublecolon_start:best_doublecolon_end] = [''] # For zeros at the beginning of the address. if best_doublecolon_start == 0: hextets = [''] + hextets return hextets
[ "def", "_compress_hextets", "(", "cls", ",", "hextets", ")", ":", "best_doublecolon_start", "=", "-", "1", "best_doublecolon_len", "=", "0", "doublecolon_start", "=", "-", "1", "doublecolon_len", "=", "0", "for", "index", ",", "hextet", "in", "enumerate", "(",...
https://github.com/mrlesmithjr/Ansible/blob/d44f0dc0d942bdf3bf7334b307e6048f0ee16e36/roles/ansible-vsphere-management/scripts/pdns/lib/python2.7/site-packages/pip/_vendor/ipaddress.py#L1888-L1933
FSecureLABS/Jandroid
e31d0dab58a2bfd6ed8e0a387172b8bd7c893436
libs/platform-tools/platform-tools_linux/systrace/catapult/devil/devil/android/device_utils.py
python
DeviceUtils.build_id
(self)
return self.GetProp('ro.build.id', cache=True)
Returns the build ID of the system (e.g. 'KTU84P').
Returns the build ID of the system (e.g. 'KTU84P').
[ "Returns", "the", "build", "ID", "of", "the", "system", "(", "e", ".", "g", ".", "KTU84P", ")", "." ]
def build_id(self): """Returns the build ID of the system (e.g. 'KTU84P').""" return self.GetProp('ro.build.id', cache=True)
[ "def", "build_id", "(", "self", ")", ":", "return", "self", ".", "GetProp", "(", "'ro.build.id'", ",", "cache", "=", "True", ")" ]
https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_linux/systrace/catapult/devil/devil/android/device_utils.py#L2270-L2272
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/matrices/expressions/matmul.py
python
MatMul.doit
(self, **kwargs)
return canonicalize(MatMul(*args))
[]
def doit(self, **kwargs): deep = kwargs.get('deep', False) if deep: args = [arg.doit(**kwargs) for arg in self.args] else: args = self.args return canonicalize(MatMul(*args))
[ "def", "doit", "(", "self", ",", "*", "*", "kwargs", ")", ":", "deep", "=", "kwargs", ".", "get", "(", "'deep'", ",", "False", ")", "if", "deep", ":", "args", "=", "[", "arg", ".", "doit", "(", "*", "*", "kwargs", ")", "for", "arg", "in", "se...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/matrices/expressions/matmul.py#L109-L115
macadmins/installapplications
2063c4a2bbec1df62e25e1e4a5820ffe3b5c4e46
payload/Library/installapplications/gurl.py
python
Gurl.URLSession_task_didReceiveChallenge_completionHandler_
( self, _session, _task, challenge, completionHandler)
NSURLSessionTaskDelegate method
NSURLSessionTaskDelegate method
[ "NSURLSessionTaskDelegate", "method" ]
def URLSession_task_didReceiveChallenge_completionHandler_( self, _session, _task, challenge, completionHandler): '''NSURLSessionTaskDelegate method''' if CALLBACK_HELPER_AVAILABLE: completionHandler.__block_signature__ = objc_method_signature(b'v@i@') self.log('URLSession_task_didReceiveChallenge_completionHandler_') self.handleChallenge_withCompletionHandler_( challenge, completionHandler)
[ "def", "URLSession_task_didReceiveChallenge_completionHandler_", "(", "self", ",", "_session", ",", "_task", ",", "challenge", ",", "completionHandler", ")", ":", "if", "CALLBACK_HELPER_AVAILABLE", ":", "completionHandler", ".", "__block_signature__", "=", "objc_method_sign...
https://github.com/macadmins/installapplications/blob/2063c4a2bbec1df62e25e1e4a5820ffe3b5c4e46/payload/Library/installapplications/gurl.py#L659-L666
dmlc/dgl
8d14a739bc9e446d6c92ef83eafe5782398118de
python/dgl/contrib/dis_kvstore.py
python
KVClient.pull
(self, name, id_tensor)
Pull message from KVServer. Parameters ---------- name : str data name id_tensor : tensor (mx.ndarray or torch.tensor) a vector storing the ID list Returns ------- tensor a data tensor with the same row size of id_tensor.
Pull message from KVServer.
[ "Pull", "message", "from", "KVServer", "." ]
def pull(self, name, id_tensor): """Pull message from KVServer. Parameters ---------- name : str data name id_tensor : tensor (mx.ndarray or torch.tensor) a vector storing the ID list Returns ------- tensor a data tensor with the same row size of id_tensor. """ assert len(name) > 0, 'name cannot be empty.' assert F.ndim(id_tensor) == 1, 'ID must be a vector.' if self._udf_pull_handler is None: # Use fast-pull g2l = None if name+'-g2l-' in self._data_store: g2l = self._data_store[name+'-g2l-'] return _fast_pull(name, id_tensor, self._machine_count, self._group_count, self._machine_id, self._client_id, self._data_store[name+'-part-'], g2l, self._data_store[name+'-data-'], self._sender, self._receiver) else: for msg in self._garbage_msg: _clear_kv_msg(msg) self._garbage_msg = [] # partition data machine_id = self._data_store[name+'-part-'][id_tensor] # sort index by machine id sorted_id = F.tensor(np.argsort(F.asnumpy(machine_id))) back_sorted_id = F.tensor(np.argsort(F.asnumpy(sorted_id))) id_tensor = id_tensor[sorted_id] machine, count = np.unique(F.asnumpy(machine_id), return_counts=True) # pull data from server by order start = 0 pull_count = 0 local_id = None for idx in range(len(machine)): end = start + count[idx] if start == end: # No data for target machine continue partial_id = id_tensor[start:end] if machine[idx] == self._machine_id: # local pull # Note that DO NOT pull local data right now because we can overlap # communication-local_pull here if (name+'-g2l-' in self._has_data) == True: local_id = self._data_store[name+'-g2l-'][partial_id] else: local_id = partial_id else: # pull data from remote server msg = KVStoreMsg( type=KVMsgType.PULL, rank=self._client_id, name=name, id=partial_id, data=None, shape=None, c_ptr=None) # randomly select a server node in target machine for load-balance s_id = random.randint(machine[idx]*self._group_count, (machine[idx]+1)*self._group_count-1) _send_kv_msg(self._sender, msg, s_id) pull_count += 1 start += count[idx] msg_list = [] if local_id is not None: # local pull local_data = self._udf_pull_handler(name+'-data-', local_id, self._data_store) s_id = random.randint(self._machine_id*self._group_count, (self._machine_id+1)*self._group_count-1) local_msg = KVStoreMsg( type=KVMsgType.PULL_BACK, rank=s_id, name=name, id=None, data=local_data, shape=None, c_ptr=None) msg_list.append(local_msg) self._garbage_msg.append(local_msg) # wait message from server nodes for idx in range(pull_count): remote_msg = _recv_kv_msg(self._receiver) msg_list.append(remote_msg) self._garbage_msg.append(remote_msg) # sort msg by server id and merge tensor together msg_list.sort(key=self._takeId) data_tensor = F.cat(seq=[msg.data for msg in msg_list], dim=0) return data_tensor[back_sorted_id]
[ "def", "pull", "(", "self", ",", "name", ",", "id_tensor", ")", ":", "assert", "len", "(", "name", ")", ">", "0", ",", "'name cannot be empty.'", "assert", "F", ".", "ndim", "(", "id_tensor", ")", "==", "1", ",", "'ID must be a vector.'", "if", "self", ...
https://github.com/dmlc/dgl/blob/8d14a739bc9e446d6c92ef83eafe5782398118de/python/dgl/contrib/dis_kvstore.py#L1057-L1158
unknown-horizons/unknown-horizons
7397fb333006d26c3d9fe796c7bd9cb8c3b43a49
horizons/util/shapes/rect.py
python
Rect.contains_tuple
(self, tup)
return (self.left <= tup[0] <= self.right) and (self.top <= tup[1] <= self.bottom)
Same as contains, but takes a tuple (x, y) as parameter (overloaded function)
Same as contains, but takes a tuple (x, y) as parameter (overloaded function)
[ "Same", "as", "contains", "but", "takes", "a", "tuple", "(", "x", "y", ")", "as", "parameter", "(", "overloaded", "function", ")" ]
def contains_tuple(self, tup): """Same as contains, but takes a tuple (x, y) as parameter (overloaded function)""" return (self.left <= tup[0] <= self.right) and (self.top <= tup[1] <= self.bottom)
[ "def", "contains_tuple", "(", "self", ",", "tup", ")", ":", "return", "(", "self", ".", "left", "<=", "tup", "[", "0", "]", "<=", "self", ".", "right", ")", "and", "(", "self", ".", "top", "<=", "tup", "[", "1", "]", "<=", "self", ".", "bottom"...
https://github.com/unknown-horizons/unknown-horizons/blob/7397fb333006d26c3d9fe796c7bd9cb8c3b43a49/horizons/util/shapes/rect.py#L192-L194
flow-project/flow
a511c41c48e6b928bb2060de8ad1ef3c3e3d9554
flow/core/kernel/network/traci.py
python
TraCIKernelNetwork.generate_net
(self, net_params, traffic_lights, nodes, edges, types=None, connections=None)
Generate Net files for the transportation network. Creates different network configuration files for: * nodes: x,y position of points which are connected together to form links. The nodes may also be fitted with traffic lights, or can be treated as priority or zipper merge regions if they combines several lanes or edges together. * edges: directed edges combining nodes together. These constitute the lanes vehicles will be allowed to drive on. * types (optional): parameters used to describe common features amount several edges of similar types. If edges are not defined with common types, this is not needed. * connections (optional): describes how incoming and outgoing edge/lane pairs on a specific node as connected. If none is specified, SUMO handles these connections by default. The above files are then combined to form a .net.xml file describing the shape of the traffic network in a form compatible with SUMO. Parameters ---------- net_params : flow.core.params.NetParams network-specific parameters. Different networks require different net_params; see the separate sub-classes for more information. traffic_lights : flow.core.params.TrafficLightParams traffic light information, used to determine which nodes are treated as traffic lights nodes : list of dict A list of node attributes (a separate dict for each node). Nodes attributes must include: * id {string} -- name of the node * x {float} -- x coordinate of the node * y {float} -- y coordinate of the node edges : list of dict A list of edges attributes (a separate dict for each edge). Edge attributes must include: * id {string} -- name of the edge * from {string} -- name of node the directed edge starts from * to {string} -- name of the node the directed edge ends at In addition, the attributes must contain at least one of the following: * "numLanes" {int} and "speed" {float} -- the number of lanes and speed limit of the edge, respectively * type {string} -- a type identifier for the edge, which can be used if several edges are supposed to possess the same number of lanes, speed limits, etc... types : list of dict A list of type attributes for specific groups of edges. If none are specified, no .typ.xml file is created. connections : list of dict A list of connection attributes. If none are specified, no .con.xml file is created. Returns ------- edges : dict <dict> Key = name of the edge Elements = length, lanes, speed connection_data : dict < dict < list < (edge, pos) > > > Key = name of the arriving edge Key = lane index Element = list of edge/lane pairs that a vehicle can traverse from the arriving edge/lane pairs
Generate Net files for the transportation network.
[ "Generate", "Net", "files", "for", "the", "transportation", "network", "." ]
def generate_net(self, net_params, traffic_lights, nodes, edges, types=None, connections=None): """Generate Net files for the transportation network. Creates different network configuration files for: * nodes: x,y position of points which are connected together to form links. The nodes may also be fitted with traffic lights, or can be treated as priority or zipper merge regions if they combines several lanes or edges together. * edges: directed edges combining nodes together. These constitute the lanes vehicles will be allowed to drive on. * types (optional): parameters used to describe common features amount several edges of similar types. If edges are not defined with common types, this is not needed. * connections (optional): describes how incoming and outgoing edge/lane pairs on a specific node as connected. If none is specified, SUMO handles these connections by default. The above files are then combined to form a .net.xml file describing the shape of the traffic network in a form compatible with SUMO. Parameters ---------- net_params : flow.core.params.NetParams network-specific parameters. Different networks require different net_params; see the separate sub-classes for more information. traffic_lights : flow.core.params.TrafficLightParams traffic light information, used to determine which nodes are treated as traffic lights nodes : list of dict A list of node attributes (a separate dict for each node). Nodes attributes must include: * id {string} -- name of the node * x {float} -- x coordinate of the node * y {float} -- y coordinate of the node edges : list of dict A list of edges attributes (a separate dict for each edge). Edge attributes must include: * id {string} -- name of the edge * from {string} -- name of node the directed edge starts from * to {string} -- name of the node the directed edge ends at In addition, the attributes must contain at least one of the following: * "numLanes" {int} and "speed" {float} -- the number of lanes and speed limit of the edge, respectively * type {string} -- a type identifier for the edge, which can be used if several edges are supposed to possess the same number of lanes, speed limits, etc... types : list of dict A list of type attributes for specific groups of edges. If none are specified, no .typ.xml file is created. connections : list of dict A list of connection attributes. If none are specified, no .con.xml file is created. Returns ------- edges : dict <dict> Key = name of the edge Elements = length, lanes, speed connection_data : dict < dict < list < (edge, pos) > > > Key = name of the arriving edge Key = lane index Element = list of edge/lane pairs that a vehicle can traverse from the arriving edge/lane pairs """ # add traffic lights to the nodes tl_ids = list(traffic_lights.get_properties().keys()) for n_id in tl_ids: indx = next(i for i, nd in enumerate(nodes) if nd['id'] == n_id) nodes[indx]['type'] = 'traffic_light' # for nodes that have traffic lights that haven't been added for node in nodes: if node['id'] not in tl_ids \ and node.get('type', None) == 'traffic_light': traffic_lights.add(node['id']) # modify the x and y values to be strings node['x'] = str(node['x']) node['y'] = str(node['y']) if 'radius' in node: node['radius'] = str(node['radius']) # xml file for nodes; contains nodes for the boundary points with # respect to the x and y axes x = makexml('nodes', 'http://sumo.dlr.de/xsd/nodes_file.xsd') for node_attributes in nodes: x.append(E('node', **node_attributes)) printxml(x, self.net_path + self.nodfn) # modify the length, shape, numLanes, and speed values for edge in edges: edge['length'] = str(edge['length']) if 'priority' in edge: edge['priority'] = str(edge['priority']) if 'shape' in edge: if not isinstance(edge['shape'], str): edge['shape'] = ' '.join('%.2f,%.2f' % (x, y) for x, y in edge['shape']) if 'numLanes' in edge: edge['numLanes'] = str(edge['numLanes']) if 'speed' in edge: edge['speed'] = str(edge['speed']) # xml file for edges x = makexml('edges', 'http://sumo.dlr.de/xsd/edges_file.xsd') for edge_attributes in edges: x.append(E('edge', attrib=edge_attributes)) printxml(x, self.net_path + self.edgfn) # xml file for types: contains the the number of lanes and the speed # limit for the lanes if types is not None: # modify the numLanes and speed values for typ in types: if 'numLanes' in typ: typ['numLanes'] = str(typ['numLanes']) if 'speed' in typ: typ['speed'] = str(typ['speed']) x = makexml('types', 'http://sumo.dlr.de/xsd/types_file.xsd') for type_attributes in types: x.append(E('type', **type_attributes)) printxml(x, self.net_path + self.typfn) # xml for connections: specifies which lanes connect to which in the # edges if connections is not None: # modify the fromLane and toLane values for connection in connections: if 'fromLane' in connection: connection['fromLane'] = str(connection['fromLane']) if 'toLane' in connection: connection['toLane'] = str(connection['toLane']) x = makexml('connections', 'http://sumo.dlr.de/xsd/connections_file.xsd') for connection_attributes in connections: if 'signal_group' in connection_attributes: del connection_attributes['signal_group'] x.append(E('connection', **connection_attributes)) printxml(x, self.net_path + self.confn) # xml file for configuration, which specifies: # - the location of all files of interest for sumo # - output net file # - processing parameters for no internal links and no turnarounds x = makexml('configuration', 'http://sumo.dlr.de/xsd/netconvertConfiguration.xsd') t = E('input') t.append(E('node-files', value=self.nodfn)) t.append(E('edge-files', value=self.edgfn)) if types is not None: t.append(E('type-files', value=self.typfn)) if connections is not None: t.append(E('connection-files', value=self.confn)) x.append(t) t = E('output') t.append(E('output-file', value=self.netfn)) x.append(t) t = E('processing') t.append(E('no-internal-links', value='false')) t.append(E('no-turnarounds', value='true')) x.append(t) printxml(x, self.net_path + self.cfgfn) subprocess.call( [ 'netconvert -c ' + self.net_path + self.cfgfn + ' --output-file=' + self.cfg_path + self.netfn + ' --no-internal-links="false"' ], stdout=subprocess.DEVNULL, shell=True) # collect data from the generated network configuration file error = None for _ in range(RETRIES_ON_ERROR): try: edges_dict, conn_dict = self._import_edges_from_net(net_params) return edges_dict, conn_dict except Exception as e: print('Error during start: {}'.format(e)) print('Retrying in {} seconds...'.format(WAIT_ON_ERROR)) time.sleep(WAIT_ON_ERROR) raise error
[ "def", "generate_net", "(", "self", ",", "net_params", ",", "traffic_lights", ",", "nodes", ",", "edges", ",", "types", "=", "None", ",", "connections", "=", "None", ")", ":", "# add traffic lights to the nodes", "tl_ids", "=", "list", "(", "traffic_lights", "...
https://github.com/flow-project/flow/blob/a511c41c48e6b928bb2060de8ad1ef3c3e3d9554/flow/core/kernel/network/traci.py#L329-L527
microsoft/azure-devops-python-api
451cade4c475482792cbe9e522c1fee32393139e
azure-devops/azure/devops/released/client_factory.py
python
ClientFactory.get_profile_client
(self)
return self._connection.get_client('azure.devops.released.profile.profile_client.ProfileClient')
get_profile_client. Gets the 5.1 version of the ProfileClient :rtype: :class:`<ProfileClient> <azure.devops.released.profile.profile_client.ProfileClient>`
get_profile_client. Gets the 5.1 version of the ProfileClient :rtype: :class:`<ProfileClient> <azure.devops.released.profile.profile_client.ProfileClient>`
[ "get_profile_client", ".", "Gets", "the", "5", ".", "1", "version", "of", "the", "ProfileClient", ":", "rtype", ":", ":", "class", ":", "<ProfileClient", ">", "<azure", ".", "devops", ".", "released", ".", "profile", ".", "profile_client", ".", "ProfileClien...
def get_profile_client(self): """get_profile_client. Gets the 5.1 version of the ProfileClient :rtype: :class:`<ProfileClient> <azure.devops.released.profile.profile_client.ProfileClient>` """ return self._connection.get_client('azure.devops.released.profile.profile_client.ProfileClient')
[ "def", "get_profile_client", "(", "self", ")", ":", "return", "self", ".", "_connection", ".", "get_client", "(", "'azure.devops.released.profile.profile_client.ProfileClient'", ")" ]
https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/released/client_factory.py#L81-L86
emesene/emesene
4548a4098310e21b16437bb36223a7f632a4f7bc
emesene/e3/cache/PictureCache.py
python
PictureCache.insert_raw
(self, item)
return self.__add_entry(hash_)
insert a new item into the cache return the information (stamp, hash) on success None otherwise item -- a file like object containing an image
insert a new item into the cache return the information (stamp, hash) on success None otherwise item -- a file like object containing an image
[ "insert", "a", "new", "item", "into", "the", "cache", "return", "the", "information", "(", "stamp", "hash", ")", "on", "success", "None", "otherwise", "item", "--", "a", "file", "like", "object", "containing", "an", "image" ]
def insert_raw(self, item): '''insert a new item into the cache return the information (stamp, hash) on success None otherwise item -- a file like object containing an image ''' if item is None: return None position = item.tell() item.seek(0) hash_ = Cache.get_file_hash(item) if hash_ is None: return None path = os.path.join(self.path, hash_) last_path = os.path.join(self.path, 'last') self.create_file(path, item) shutil.copy2(path, last_path) item.seek(position) return self.__add_entry(hash_)
[ "def", "insert_raw", "(", "self", ",", "item", ")", ":", "if", "item", "is", "None", ":", "return", "None", "position", "=", "item", ".", "tell", "(", ")", "item", ".", "seek", "(", "0", ")", "hash_", "=", "Cache", ".", "get_file_hash", "(", "item"...
https://github.com/emesene/emesene/blob/4548a4098310e21b16437bb36223a7f632a4f7bc/emesene/e3/cache/PictureCache.py#L83-L105
chubin/rate.sx
1ce1bb37f7dccd76f40e2c23016b6a6f1d6da407
lib/panela/panela_colors.py
python
Panela.put_line
(self, x1, y1, x2, y2, char=None, color=None, background=None)
Draw line (x1, y1) - (x2, y2) fith foreground color <color>, background color <background> and charachter <char>, if specified.
Draw line (x1, y1) - (x2, y2) fith foreground color <color>, background color <background> and charachter <char>, if specified.
[ "Draw", "line", "(", "x1", "y1", ")", "-", "(", "x2", "y2", ")", "fith", "foreground", "color", "<color", ">", "background", "color", "<background", ">", "and", "charachter", "<char", ">", "if", "specified", "." ]
def put_line(self, x1, y1, x2, y2, char=None, color=None, background=None): """ Draw line (x1, y1) - (x2, y2) fith foreground color <color>, background color <background> and charachter <char>, if specified. """ def get_line(start, end): """Bresenham's Line Algorithm Produces a list of tuples from start and end Source: http://www.roguebasin.com/index.php?title=Bresenham%27s_Line_Algorithm#Python >>> points1 = get_line((0, 0), (3, 4)) >>> points2 = get_line((3, 4), (0, 0)) >>> assert(set(points1) == set(points2)) >>> print points1 [(0, 0), (1, 1), (1, 2), (2, 3), (3, 4)] >>> print points2 [(3, 4), (2, 3), (1, 2), (1, 1), (0, 0)] """ # Setup initial conditions x1, y1 = start x2, y2 = end dx = x2 - x1 dy = y2 - y1 # Determine how steep the line is is_steep = abs(dy) > abs(dx) # Rotate line if is_steep: x1, y1 = y1, x1 x2, y2 = y2, x2 # Swap start and end points if necessary and store swap state swapped = False if x1 > x2: x1, x2 = x2, x1 y1, y2 = y2, y1 swapped = True # Recalculate differentials dx = x2 - x1 dy = y2 - y1 # Calculate error error = int(dx / 2.0) ystep = 1 if y1 < y2 else -1 # Iterate over bounding box generating points between start and end y = y1 points = [] for x in range(x1, x2 + 1): coord = (y, x) if is_steep else (x, y) points.append(coord) error -= abs(dy) if error < 0: y += ystep error += dx # Reverse the list if the coordinates were swapped if swapped: points.reverse() return points if color and not isinstance(color, basestring): color_iter = itertools.cycle(color) else: color_iter = itertools.repeat(color) if background and not isinstance(background, basestring): background_iter = itertools.cycle(background) else: background_iter = itertools.repeat(background) if char: char_iter = itertools.cycle(char) else: char_iter = itertools.repeat(char) for x, y in get_line((x1,y1), (x2, y2)): char = next(char_iter) color = next(color_iter) background = next(background_iter) self.put_point(x, y, char=char, color=color, background=background)
[ "def", "put_line", "(", "self", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "char", "=", "None", ",", "color", "=", "None", ",", "background", "=", "None", ")", ":", "def", "get_line", "(", "start", ",", "end", ")", ":", "\"\"\"Bresenham's Lin...
https://github.com/chubin/rate.sx/blob/1ce1bb37f7dccd76f40e2c23016b6a6f1d6da407/lib/panela/panela_colors.py#L300-L385
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-darwin/x64/mako/_ast_util.py
python
SourceGenerator.generator_visit
(left, right)
return visit
[]
def generator_visit(left, right): def visit(self, node): self.write(left) self.visit(node.elt) for comprehension in node.generators: self.visit(comprehension) self.write(right) return visit
[ "def", "generator_visit", "(", "left", ",", "right", ")", ":", "def", "visit", "(", "self", ",", "node", ")", ":", "self", ".", "write", "(", "left", ")", "self", ".", "visit", "(", "node", ".", "elt", ")", "for", "comprehension", "in", "node", "."...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-darwin/x64/mako/_ast_util.py#L784-L791
blacktop/malice
d318fab96dc011689a0a2be29d1513c71d3866aa
lib/common/objects.py
python
File.get_data
(self)
return self.file_data
Read file contents. @return: data.
Read file contents.
[ "Read", "file", "contents", "." ]
def get_data(self): """Read file contents. @return: data. """ return self.file_data
[ "def", "get_data", "(", "self", ")", ":", "return", "self", ".", "file_data" ]
https://github.com/blacktop/malice/blob/d318fab96dc011689a0a2be29d1513c71d3866aa/lib/common/objects.py#L97-L101
AstroPrint/AstroBox
e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75
src/astroprint/camera/v4l2/gstreamer/process/__init__.py
python
processInterface._stopLocalVideoAction
(self, reqId)
return self.RESPONSE_ASYNC
[]
def _stopLocalVideoAction(self, reqId): def doneCb(success): self.sendResponse(reqId, success) self._pipeline.stopLocalVideo(doneCb) return self.RESPONSE_ASYNC
[ "def", "_stopLocalVideoAction", "(", "self", ",", "reqId", ")", ":", "def", "doneCb", "(", "success", ")", ":", "self", ".", "sendResponse", "(", "reqId", ",", "success", ")", "self", ".", "_pipeline", ".", "stopLocalVideo", "(", "doneCb", ")", "return", ...
https://github.com/AstroPrint/AstroBox/blob/e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75/src/astroprint/camera/v4l2/gstreamer/process/__init__.py#L152-L159
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/table/_header.py
python
Header.values
(self)
return self["values"]
Header cell values. `values[m][n]` represents the value of the `n`th point in column `m`, therefore the `values[m]` vector length for all columns must be the same (longer vectors will be truncated). Each value must be a finite number or a string. The 'values' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray
Header cell values. `values[m][n]` represents the value of the `n`th point in column `m`, therefore the `values[m]` vector length for all columns must be the same (longer vectors will be truncated). Each value must be a finite number or a string. The 'values' property is an array that may be specified as a tuple, list, numpy array, or pandas Series
[ "Header", "cell", "values", ".", "values", "[", "m", "]", "[", "n", "]", "represents", "the", "value", "of", "the", "n", "th", "point", "in", "column", "m", "therefore", "the", "values", "[", "m", "]", "vector", "length", "for", "all", "columns", "mu...
def values(self): """ Header cell values. `values[m][n]` represents the value of the `n`th point in column `m`, therefore the `values[m]` vector length for all columns must be the same (longer vectors will be truncated). Each value must be a finite number or a string. The 'values' property is an array that may be specified as a tuple, list, numpy array, or pandas Series Returns ------- numpy.ndarray """ return self["values"]
[ "def", "values", "(", "self", ")", ":", "return", "self", "[", "\"values\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/table/_header.py#L342-L356
zykls/whynot
86fd2349a83cd43c614b55f5bf2dfc9ece143081
whynot/causal_graphs.py
python
is_dead_node
(node)
return False
Check if this node adds a spurious dependency, e.g. 0 * constant.
Check if this node adds a spurious dependency, e.g. 0 * constant.
[ "Check", "if", "this", "node", "adds", "a", "spurious", "dependency", "e", ".", "g", ".", "0", "*", "constant", "." ]
def is_dead_node(node): """Check if this node adds a spurious dependency, e.g. 0 * constant.""" if hasattr(node.fun, "fun") and node.fun.fun == np.multiply: # If we multiplied a parent by a constant 0, skip. for idx, arg in enumerate(node.args): if idx not in node.parent_argnums and arg == 0.0: return True return False
[ "def", "is_dead_node", "(", "node", ")", ":", "if", "hasattr", "(", "node", ".", "fun", ",", "\"fun\"", ")", "and", "node", ".", "fun", ".", "fun", "==", "np", ".", "multiply", ":", "# If we multiplied a parent by a constant 0, skip.", "for", "idx", ",", "...
https://github.com/zykls/whynot/blob/86fd2349a83cd43c614b55f5bf2dfc9ece143081/whynot/causal_graphs.py#L198-L205
PaddlePaddle/PaddleSpeech
26524031d242876b7fdb71582b0b3a7ea45c7d9d
paddlespeech/t2s/models/transformer_tts/transformer_tts.py
python
GuidedAttentionLoss.forward
(self, att_ws, ilens, olens)
return self.alpha * loss
Calculate forward propagation. Parameters ---------- att_ws : Tensor Batch of attention weights (B, T_max_out, T_max_in). ilens : LongTensor Batch of input lenghts (B,). olens : LongTensor Batch of output lenghts (B,). Returns ---------- Tensor Guided attention loss value.
Calculate forward propagation.
[ "Calculate", "forward", "propagation", "." ]
def forward(self, att_ws, ilens, olens): """Calculate forward propagation. Parameters ---------- att_ws : Tensor Batch of attention weights (B, T_max_out, T_max_in). ilens : LongTensor Batch of input lenghts (B,). olens : LongTensor Batch of output lenghts (B,). Returns ---------- Tensor Guided attention loss value. """ if self.guided_attn_masks is None: self.guided_attn_masks = self._make_guided_attention_masks(ilens, olens) if self.masks is None: self.masks = self._make_masks(ilens, olens) losses = self.guided_attn_masks * att_ws loss = paddle.mean( losses.masked_select(self.masks.broadcast_to(losses.shape))) if self.reset_always: self._reset_masks() return self.alpha * loss
[ "def", "forward", "(", "self", ",", "att_ws", ",", "ilens", ",", "olens", ")", ":", "if", "self", ".", "guided_attn_masks", "is", "None", ":", "self", ".", "guided_attn_masks", "=", "self", ".", "_make_guided_attention_masks", "(", "ilens", ",", "olens", "...
https://github.com/PaddlePaddle/PaddleSpeech/blob/26524031d242876b7fdb71582b0b3a7ea45c7d9d/paddlespeech/t2s/models/transformer_tts/transformer_tts.py#L916-L944