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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ReactionMechanismGenerator/RMG-Py | 2b7baf51febf27157def58fb3f6cee03fb6a684c | rmgpy/molecule/molecule.py | python | Molecule.from_augmented_inchi | (self, aug_inchi, raise_atomtype_exception=True) | return self | Convert an Augmented InChI string `aug_inchi` to a molecular structure. | Convert an Augmented InChI string `aug_inchi` to a molecular structure. | [
"Convert",
"an",
"Augmented",
"InChI",
"string",
"aug_inchi",
"to",
"a",
"molecular",
"structure",
"."
] | def from_augmented_inchi(self, aug_inchi, raise_atomtype_exception=True):
"""
Convert an Augmented InChI string `aug_inchi` to a molecular structure.
"""
translator.from_augmented_inchi(self, aug_inchi, raise_atomtype_exception=raise_atomtype_exception)
return self | [
"def",
"from_augmented_inchi",
"(",
"self",
",",
"aug_inchi",
",",
"raise_atomtype_exception",
"=",
"True",
")",
":",
"translator",
".",
"from_augmented_inchi",
"(",
"self",
",",
"aug_inchi",
",",
"raise_atomtype_exception",
"=",
"raise_atomtype_exception",
")",
"retu... | https://github.com/ReactionMechanismGenerator/RMG-Py/blob/2b7baf51febf27157def58fb3f6cee03fb6a684c/rmgpy/molecule/molecule.py#L1710-L1715 | |
lovelylain/pyctp | fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d | stock2/ctp/ApiStruct.py | python | InvestorPosition.__init__ | (self, InstrumentID='', BrokerID='', InvestorID='', PosiDirection=PD_Net, HedgeFlag=HF_Speculation, PositionDate=PSD_Today, YdPosition=0, Position=0, LongFrozen=0, ShortFrozen=0, LongFrozenAmount=0.0, ShortFrozenAmount=0.0, OpenVolume=0, CloseVolume=0, OpenAmount=0.0, CloseAmount=0.0, PositionCost=0.0, FrozenCash=0.0, ... | [] | def __init__(self, InstrumentID='', BrokerID='', InvestorID='', PosiDirection=PD_Net, HedgeFlag=HF_Speculation, PositionDate=PSD_Today, YdPosition=0, Position=0, LongFrozen=0, ShortFrozen=0, LongFrozenAmount=0.0, ShortFrozenAmount=0.0, OpenVolume=0, CloseVolume=0, OpenAmount=0.0, CloseAmount=0.0, PositionCost=0.0, Froz... | [
"def",
"__init__",
"(",
"self",
",",
"InstrumentID",
"=",
"''",
",",
"BrokerID",
"=",
"''",
",",
"InvestorID",
"=",
"''",
",",
"PosiDirection",
"=",
"PD_Net",
",",
"HedgeFlag",
"=",
"HF_Speculation",
",",
"PositionDate",
"=",
"PSD_Today",
",",
"YdPosition",
... | https://github.com/lovelylain/pyctp/blob/fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d/stock2/ctp/ApiStruct.py#L1697-L1743 | ||||
returntocorp/semgrep | b8d7202bfaff8898c08b5543da3aa0949982ed93 | semgrep/semgrep/util.py | python | listendswith | (l: List[T], tail: List[T]) | return all(l[len(l) - len(tail) + i] == tail[i] for i in range(len(tail))) | E.g.
- listendswith([1, 2, 3, 4], [3, 4]) -> True
- listendswith([1, 2, 3, 4], [1, 4]) -> False | E.g.
- listendswith([1, 2, 3, 4], [3, 4]) -> True
- listendswith([1, 2, 3, 4], [1, 4]) -> False | [
"E",
".",
"g",
".",
"-",
"listendswith",
"(",
"[",
"1",
"2",
"3",
"4",
"]",
"[",
"3",
"4",
"]",
")",
"-",
">",
"True",
"-",
"listendswith",
"(",
"[",
"1",
"2",
"3",
"4",
"]",
"[",
"1",
"4",
"]",
")",
"-",
">",
"False"
] | def listendswith(l: List[T], tail: List[T]) -> bool:
"""
E.g.
- listendswith([1, 2, 3, 4], [3, 4]) -> True
- listendswith([1, 2, 3, 4], [1, 4]) -> False
"""
if len(tail) > len(l):
return False
return all(l[len(l) - len(tail) + i] == tail[i] for i in range(len(tail))) | [
"def",
"listendswith",
"(",
"l",
":",
"List",
"[",
"T",
"]",
",",
"tail",
":",
"List",
"[",
"T",
"]",
")",
"->",
"bool",
":",
"if",
"len",
"(",
"tail",
")",
">",
"len",
"(",
"l",
")",
":",
"return",
"False",
"return",
"all",
"(",
"l",
"[",
... | https://github.com/returntocorp/semgrep/blob/b8d7202bfaff8898c08b5543da3aa0949982ed93/semgrep/semgrep/util.py#L167-L176 | |
googleads/google-ads-python | 2a1d6062221f6aad1992a6bcca0e7e4a93d2db86 | google/ads/googleads/v8/services/services/extension_feed_item_service/client.py | python | ExtensionFeedItemServiceClient.common_billing_account_path | (billing_account: str,) | return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
) | Return a fully-qualified billing_account string. | Return a fully-qualified billing_account string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"billing_account",
"string",
"."
] | def common_billing_account_path(billing_account: str,) -> str:
"""Return a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
) | [
"def",
"common_billing_account_path",
"(",
"billing_account",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"billingAccounts/{billing_account}\"",
".",
"format",
"(",
"billing_account",
"=",
"billing_account",
",",
")"
] | https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v8/services/services/extension_feed_item_service/client.py#L241-L245 | |
tosher/Mediawiker | 81bf97cace59bedcb1668e7830b85c36e014428e | lib/Crypto.lin.x64/Crypto/Hash/CMAC.py | python | CMAC.update | (self, msg) | return self | Authenticate the next chunk of message.
Args:
data (byte string/byte array/memoryview): The next chunk of data | Authenticate the next chunk of message. | [
"Authenticate",
"the",
"next",
"chunk",
"of",
"message",
"."
] | def update(self, msg):
"""Authenticate the next chunk of message.
Args:
data (byte string/byte array/memoryview): The next chunk of data
"""
# Mutable values must be copied if cached
self._data_size += len(msg)
if len(self._cache) > 0:
filler =... | [
"def",
"update",
"(",
"self",
",",
"msg",
")",
":",
"# Mutable values must be copied if cached",
"self",
".",
"_data_size",
"+=",
"len",
"(",
"msg",
")",
"if",
"len",
"(",
"self",
".",
"_cache",
")",
">",
"0",
":",
"filler",
"=",
"min",
"(",
"self",
".... | https://github.com/tosher/Mediawiker/blob/81bf97cace59bedcb1668e7830b85c36e014428e/lib/Crypto.lin.x64/Crypto/Hash/CMAC.py#L121-L151 | |
gnuradio/pybombs | 17044241bf835b93571026b112f179f2db7448a4 | pybombs/packagers/yum.py | python | ExternalYumDnf._run_cmd | (self, pkgname, cmd) | Call yum or dnf with cmd. | Call yum or dnf with cmd. | [
"Call",
"yum",
"or",
"dnf",
"with",
"cmd",
"."
] | def _run_cmd(self, pkgname, cmd):
"""
Call yum or dnf with cmd.
"""
try:
subproc.monitor_process([self.command, "-y", cmd, pkgname], elevate=True)
return True
except Exception as ex:
self.log.error("Running `{0} install' failed.".format(self.co... | [
"def",
"_run_cmd",
"(",
"self",
",",
"pkgname",
",",
"cmd",
")",
":",
"try",
":",
"subproc",
".",
"monitor_process",
"(",
"[",
"self",
".",
"command",
",",
"\"-y\"",
",",
"cmd",
",",
"pkgname",
"]",
",",
"elevate",
"=",
"True",
")",
"return",
"True",... | https://github.com/gnuradio/pybombs/blob/17044241bf835b93571026b112f179f2db7448a4/pybombs/packagers/yum.py#L118-L128 | ||
awslabs/autogluon | 7309118f2ab1c9519f25acf61a283a95af95842b | tabular/src/autogluon/tabular/predictor/predictor.py | python | TabularPredictor.features | (self, feature_stage: str = 'original') | Returns a list of feature names dependent on the value of feature_stage.
Parameters
----------
feature_stage : str, default = 'original'
If 'original', returns the list of features specified in the original training data. This feature set is required in input data when making predic... | Returns a list of feature names dependent on the value of feature_stage. | [
"Returns",
"a",
"list",
"of",
"feature",
"names",
"dependent",
"on",
"the",
"value",
"of",
"feature_stage",
"."
] | def features(self, feature_stage: str = 'original'):
"""
Returns a list of feature names dependent on the value of feature_stage.
Parameters
----------
feature_stage : str, default = 'original'
If 'original', returns the list of features specified in the original tra... | [
"def",
"features",
"(",
"self",
",",
"feature_stage",
":",
"str",
"=",
"'original'",
")",
":",
"if",
"feature_stage",
"==",
"'original'",
":",
"return",
"self",
".",
"feature_metadata_in",
".",
"get_features",
"(",
")",
"elif",
"feature_stage",
"==",
"'transfo... | https://github.com/awslabs/autogluon/blob/7309118f2ab1c9519f25acf61a283a95af95842b/tabular/src/autogluon/tabular/predictor/predictor.py#L245-L264 | ||
kubernetes-client/python | 47b9da9de2d02b2b7a34fbe05afb44afd130d73a | kubernetes/client/models/v1beta1_csi_storage_capacity.py | python | V1beta1CSIStorageCapacity.metadata | (self, metadata) | Sets the metadata of this V1beta1CSIStorageCapacity.
:param metadata: The metadata of this V1beta1CSIStorageCapacity. # noqa: E501
:type: V1ObjectMeta | Sets the metadata of this V1beta1CSIStorageCapacity. | [
"Sets",
"the",
"metadata",
"of",
"this",
"V1beta1CSIStorageCapacity",
"."
] | def metadata(self, metadata):
"""Sets the metadata of this V1beta1CSIStorageCapacity.
:param metadata: The metadata of this V1beta1CSIStorageCapacity. # noqa: E501
:type: V1ObjectMeta
"""
self._metadata = metadata | [
"def",
"metadata",
"(",
"self",
",",
"metadata",
")",
":",
"self",
".",
"_metadata",
"=",
"metadata"
] | https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1beta1_csi_storage_capacity.py#L187-L195 | ||
Robot-Will/Stino | a94831cd1bf40a59587a7b6cc2e9b5c4306b1bf2 | libs/stino_runtime/__init__.py | python | clean_path | (dir_path) | . | . | [
"."
] | def clean_path(dir_path):
"""."""
if os.path.isdir(dir_path):
shutil.rmtree(dir_path) | [
"def",
"clean_path",
"(",
"dir_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dir_path",
")",
":",
"shutil",
".",
"rmtree",
"(",
"dir_path",
")"
] | https://github.com/Robot-Will/Stino/blob/a94831cd1bf40a59587a7b6cc2e9b5c4306b1bf2/libs/stino_runtime/__init__.py#L1080-L1083 | ||
tensorflow/tfx | b4a6b83269815ed12ba9df9e9154c7376fef2ea0 | tfx/types/artifact.py | python | Artifact.state | (self, state: str) | Set state of the underlying artifact. | Set state of the underlying artifact. | [
"Set",
"state",
"of",
"the",
"underlying",
"artifact",
"."
] | def state(self, state: str):
"""Set state of the underlying artifact."""
self._set_system_property('state', state) | [
"def",
"state",
"(",
"self",
",",
"state",
":",
"str",
")",
":",
"self",
".",
"_set_system_property",
"(",
"'state'",
",",
"state",
")"
] | https://github.com/tensorflow/tfx/blob/b4a6b83269815ed12ba9df9e9154c7376fef2ea0/tfx/types/artifact.py#L553-L555 | ||
noamraph/dreampie | b09ee546ec099ee6549c649692ceb129e05fb229 | dreampielib/subprocess/__init__.py | python | Subprocess.store_in_reshist | (self, res) | return res_index | Get a result value to store in the result history.
Store it, and return the result's index.
If the result isn't stored, return None. | Get a result value to store in the result history.
Store it, and return the result's index.
If the result isn't stored, return None. | [
"Get",
"a",
"result",
"value",
"to",
"store",
"in",
"the",
"result",
"history",
".",
"Store",
"it",
"and",
"return",
"the",
"result",
"s",
"index",
".",
"If",
"the",
"result",
"isn",
"t",
"stored",
"return",
"None",
"."
] | def store_in_reshist(self, res):
"""
Get a result value to store in the result history.
Store it, and return the result's index.
If the result isn't stored, return None.
"""
if res is None:
return None
if '__' in self.locs:
sel... | [
"def",
"store_in_reshist",
"(",
"self",
",",
"res",
")",
":",
"if",
"res",
"is",
"None",
":",
"return",
"None",
"if",
"'__'",
"in",
"self",
".",
"locs",
":",
"self",
".",
"locs",
"[",
"'___'",
"]",
"=",
"self",
".",
"locs",
"[",
"'__'",
"]",
"if"... | https://github.com/noamraph/dreampie/blob/b09ee546ec099ee6549c649692ceb129e05fb229/dreampielib/subprocess/__init__.py#L534-L557 | |
AXErunners/electrum-axe | 7ef05088c0edaf0688fb167df353d6da619ebf2f | electrum_axe/plugins/hideez/transport.py | python | HideezTransport.all_transports | () | return transports | Reimplemented hideezlib.transport.all_transports so that we can
enable/disable specific transports. | Reimplemented hideezlib.transport.all_transports so that we can
enable/disable specific transports. | [
"Reimplemented",
"hideezlib",
".",
"transport",
".",
"all_transports",
"so",
"that",
"we",
"can",
"enable",
"/",
"disable",
"specific",
"transports",
"."
] | def all_transports():
"""Reimplemented hideezlib.transport.all_transports so that we can
enable/disable specific transports.
"""
from hideezlib.transport import all_transports
transports = []
try:
from hideezlib.transport.bridge import BridgeTransport
... | [
"def",
"all_transports",
"(",
")",
":",
"from",
"hideezlib",
".",
"transport",
"import",
"all_transports",
"transports",
"=",
"[",
"]",
"try",
":",
"from",
"hideezlib",
".",
"transport",
".",
"bridge",
"import",
"BridgeTransport",
"transports",
".",
"append",
... | https://github.com/AXErunners/electrum-axe/blob/7ef05088c0edaf0688fb167df353d6da619ebf2f/electrum_axe/plugins/hideez/transport.py#L10-L21 | |
ansible-collections/community.general | 3faffe8f47968a2400ba3c896c8901c03001a194 | plugins/modules/system/timezone.py | python | Timezone.abort | (self, msg) | Abort the process with error message.
This is just the wrapper of module.fail_json().
Args:
msg: The error message. | Abort the process with error message. | [
"Abort",
"the",
"process",
"with",
"error",
"message",
"."
] | def abort(self, msg):
"""Abort the process with error message.
This is just the wrapper of module.fail_json().
Args:
msg: The error message.
"""
error_msg = ['Error message:', msg]
if len(self.msg) > 0:
error_msg.append('Other message(s):')
... | [
"def",
"abort",
"(",
"self",
",",
"msg",
")",
":",
"error_msg",
"=",
"[",
"'Error message:'",
",",
"msg",
"]",
"if",
"len",
"(",
"self",
".",
"msg",
")",
">",
"0",
":",
"error_msg",
".",
"append",
"(",
"'Other message(s):'",
")",
"error_msg",
".",
"e... | https://github.com/ansible-collections/community.general/blob/3faffe8f47968a2400ba3c896c8901c03001a194/plugins/modules/system/timezone.py#L159-L171 | ||
git-cola/git-cola | b48b8028e0c3baf47faf7b074b9773737358163d | cola/app.py | python | setup_environment | () | Set environment variables to control git's behavior | Set environment variables to control git's behavior | [
"Set",
"environment",
"variables",
"to",
"control",
"git",
"s",
"behavior"
] | def setup_environment():
"""Set environment variables to control git's behavior"""
# Allow Ctrl-C to exit
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Session management wants an absolute path when restarting
sys.argv[0] = sys_argv0 = os.path.abspath(sys.argv[0])
# Spoof an X11 display for S... | [
"def",
"setup_environment",
"(",
")",
":",
"# Allow Ctrl-C to exit",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal",
".",
"SIG_DFL",
")",
"# Session management wants an absolute path when restarting",
"sys",
".",
"argv",
"[",
"0",
"]",
"=",
"... | https://github.com/git-cola/git-cola/blob/b48b8028e0c3baf47faf7b074b9773737358163d/cola/app.py#L68-L156 | ||
materialsproject/pymatgen | 8128f3062a334a2edd240e4062b5b9bdd1ae6f58 | pymatgen/analysis/structure_matcher.py | python | PointDefectComparator.are_equal | (self, d1, d2) | return sm.fit(d1.generate_defect_structure(), d2.generate_defect_structure()) | Args:
d1: First defect. A pymatgen Defect object.
d2: Second defect. A pymatgen Defect object.
Returns:
True if defects are identical in type and sublattice. | Args:
d1: First defect. A pymatgen Defect object.
d2: Second defect. A pymatgen Defect object. | [
"Args",
":",
"d1",
":",
"First",
"defect",
".",
"A",
"pymatgen",
"Defect",
"object",
".",
"d2",
":",
"Second",
"defect",
".",
"A",
"pymatgen",
"Defect",
"object",
"."
] | def are_equal(self, d1, d2):
"""
Args:
d1: First defect. A pymatgen Defect object.
d2: Second defect. A pymatgen Defect object.
Returns:
True if defects are identical in type and sublattice.
"""
possible_defect_types = (Defect, Vacancy, Substi... | [
"def",
"are_equal",
"(",
"self",
",",
"d1",
",",
"d2",
")",
":",
"possible_defect_types",
"=",
"(",
"Defect",
",",
"Vacancy",
",",
"Substitution",
",",
"Interstitial",
")",
"if",
"not",
"isinstance",
"(",
"d1",
",",
"possible_defect_types",
")",
"or",
"not... | https://github.com/materialsproject/pymatgen/blob/8128f3062a334a2edd240e4062b5b9bdd1ae6f58/pymatgen/analysis/structure_matcher.py#L1223-L1279 | |
realpython/book2-exercises | cde325eac8e6d8cff2316601c2e5b36bb46af7d0 | py2manager/gluon/tools.py | python | Service.xmlrpc | (self, f) | return f | Example:
Use as::
service = Service()
@service.xmlrpc
def myfunction(a, b):
return a + b
def call():
return service()
The call it with:
wget http://..../app/default/call/xml... | Example:
Use as:: | [
"Example",
":",
"Use",
"as",
"::"
] | def xmlrpc(self, f):
"""
Example:
Use as::
service = Service()
@service.xmlrpc
def myfunction(a, b):
return a + b
def call():
return service()
The call it with:
... | [
"def",
"xmlrpc",
"(",
"self",
",",
"f",
")",
":",
"self",
".",
"xmlrpc_procedures",
"[",
"f",
".",
"__name__",
"]",
"=",
"f",
"return",
"f"
] | https://github.com/realpython/book2-exercises/blob/cde325eac8e6d8cff2316601c2e5b36bb46af7d0/py2manager/gluon/tools.py#L5458-L5476 | |
plotly/plotly.py | cfad7862594b35965c0e000813bd7805e8494a5b | packages/python/plotly/plotly/graph_objs/isosurface/_colorbar.py | python | ColorBar.xpad | (self) | return self["xpad"] | Sets the amount of padding (in px) along the x direction.
The 'xpad' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float | Sets the amount of padding (in px) along the x direction.
The 'xpad' property is a number and may be specified as:
- An int or float in the interval [0, inf] | [
"Sets",
"the",
"amount",
"of",
"padding",
"(",
"in",
"px",
")",
"along",
"the",
"x",
"direction",
".",
"The",
"xpad",
"property",
"is",
"a",
"number",
"and",
"may",
"be",
"specified",
"as",
":",
"-",
"An",
"int",
"or",
"float",
"in",
"the",
"interval... | def xpad(self):
"""
Sets the amount of padding (in px) along the x direction.
The 'xpad' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
"""
return self["xpad"] | [
"def",
"xpad",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"xpad\"",
"]"
] | https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/isosurface/_colorbar.py#L1303-L1314 | |
edisonlz/fastor | 342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3 | base/site-packages/diff_match_patch.py | python | diff_match_patch.diff_charsToLines | (self, diffs, lineArray) | Rehydrate the text in a diff from a string of line hashes to real lines
of text.
Args:
diffs: Array of diff tuples.
lineArray: Array of unique strings. | Rehydrate the text in a diff from a string of line hashes to real lines
of text. | [
"Rehydrate",
"the",
"text",
"in",
"a",
"diff",
"from",
"a",
"string",
"of",
"line",
"hashes",
"to",
"real",
"lines",
"of",
"text",
"."
] | def diff_charsToLines(self, diffs, lineArray):
"""Rehydrate the text in a diff from a string of line hashes to real lines
of text.
Args:
diffs: Array of diff tuples.
lineArray: Array of unique strings.
"""
for x in xrange(len(diffs)):
text = []
for char in diffs[x][1]:
... | [
"def",
"diff_charsToLines",
"(",
"self",
",",
"diffs",
",",
"lineArray",
")",
":",
"for",
"x",
"in",
"xrange",
"(",
"len",
"(",
"diffs",
")",
")",
":",
"text",
"=",
"[",
"]",
"for",
"char",
"in",
"diffs",
"[",
"x",
"]",
"[",
"1",
"]",
":",
"tex... | https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/diff_match_patch.py#L274-L286 | ||
googleads/google-ads-python | 2a1d6062221f6aad1992a6bcca0e7e4a93d2db86 | google/ads/googleads/v7/services/services/feed_mapping_service/client.py | python | FeedMappingServiceClient.feed_mapping_path | (
customer_id: str, feed_id: str, feed_mapping_id: str,
) | return "customers/{customer_id}/feedMappings/{feed_id}~{feed_mapping_id}".format(
customer_id=customer_id,
feed_id=feed_id,
feed_mapping_id=feed_mapping_id,
) | Return a fully-qualified feed_mapping string. | Return a fully-qualified feed_mapping string. | [
"Return",
"a",
"fully",
"-",
"qualified",
"feed_mapping",
"string",
"."
] | def feed_mapping_path(
customer_id: str, feed_id: str, feed_mapping_id: str,
) -> str:
"""Return a fully-qualified feed_mapping string."""
return "customers/{customer_id}/feedMappings/{feed_id}~{feed_mapping_id}".format(
customer_id=customer_id,
feed_id=feed_id,
... | [
"def",
"feed_mapping_path",
"(",
"customer_id",
":",
"str",
",",
"feed_id",
":",
"str",
",",
"feed_mapping_id",
":",
"str",
",",
")",
"->",
"str",
":",
"return",
"\"customers/{customer_id}/feedMappings/{feed_id}~{feed_mapping_id}\"",
".",
"format",
"(",
"customer_id",... | https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v7/services/services/feed_mapping_service/client.py#L175-L183 | |
simonw/djangopeople.net | ed04d3c79d03b9c74f3e7f82b2af944e021f8e15 | djangopeople/clustering.py | python | save_clusters | (clusters, zoom) | The output function provided to ClusterLizard should be a
function that takes 'clusters', a set of clusters, and 'zoom',
the integer Google zoom level. | The output function provided to ClusterLizard should be a
function that takes 'clusters', a set of clusters, and 'zoom',
the integer Google zoom level. | [
"The",
"output",
"function",
"provided",
"to",
"ClusterLizard",
"should",
"be",
"a",
"function",
"that",
"takes",
"clusters",
"a",
"set",
"of",
"clusters",
"and",
"zoom",
"the",
"integer",
"Google",
"zoom",
"level",
"."
] | def save_clusters(clusters, zoom):
"""
The output function provided to ClusterLizard should be a
function that takes 'clusters', a set of clusters, and 'zoom',
the integer Google zoom level.
"""
for cluster in clusters:
lat, long = mercator_to_latlong(*cluster.mean)
ClusteredPoin... | [
"def",
"save_clusters",
"(",
"clusters",
",",
"zoom",
")",
":",
"for",
"cluster",
"in",
"clusters",
":",
"lat",
",",
"long",
"=",
"mercator_to_latlong",
"(",
"*",
"cluster",
".",
"mean",
")",
"ClusteredPoint",
".",
"objects",
".",
"create",
"(",
"latitude"... | https://github.com/simonw/djangopeople.net/blob/ed04d3c79d03b9c74f3e7f82b2af944e021f8e15/djangopeople/clustering.py#L36-L50 | ||
THUDM/cogdl | 881746a69b74d3667e2ce59bcbcf6a5835d52751 | cogdl/models/__init__.py | python | register_model | (name) | return register_model_cls | New model types can be added to cogdl with the :func:`register_model`
function decorator.
For example::
@register_model('gat')
class GAT(BaseModel):
(...)
Args:
name (str): the name of the model | New model types can be added to cogdl with the :func:`register_model`
function decorator.
For example:: | [
"New",
"model",
"types",
"can",
"be",
"added",
"to",
"cogdl",
"with",
"the",
":",
"func",
":",
"register_model",
"function",
"decorator",
".",
"For",
"example",
"::"
] | def register_model(name):
"""
New model types can be added to cogdl with the :func:`register_model`
function decorator.
For example::
@register_model('gat')
class GAT(BaseModel):
(...)
Args:
name (str): the name of the model
"""
def register_model_cls(cls... | [
"def",
"register_model",
"(",
"name",
")",
":",
"def",
"register_model_cls",
"(",
"cls",
")",
":",
"print",
"(",
"\"The `register_model` API is deprecated!\"",
")",
"return",
"cls",
"return",
"register_model_cls"
] | https://github.com/THUDM/cogdl/blob/881746a69b74d3667e2ce59bcbcf6a5835d52751/cogdl/models/__init__.py#L6-L22 | |
RhetTbull/osxphotos | 231d13279296ee4a242d3140d8abe7b5a5bcc9c0 | osxphotos/photosdb/photosdb.py | python | PhotosDB._album_folder_hierarchy_list | (self, album_uuid) | return appropriate album_folder_hierarchy_list for the _db_version | return appropriate album_folder_hierarchy_list for the _db_version | [
"return",
"appropriate",
"album_folder_hierarchy_list",
"for",
"the",
"_db_version"
] | def _album_folder_hierarchy_list(self, album_uuid):
"""return appropriate album_folder_hierarchy_list for the _db_version"""
if self._db_version <= _PHOTOS_4_VERSION:
return self._album_folder_hierarchy_list_4(album_uuid)
else:
return self._album_folder_hierarchy_list_5(a... | [
"def",
"_album_folder_hierarchy_list",
"(",
"self",
",",
"album_uuid",
")",
":",
"if",
"self",
".",
"_db_version",
"<=",
"_PHOTOS_4_VERSION",
":",
"return",
"self",
".",
"_album_folder_hierarchy_list_4",
"(",
"album_uuid",
")",
"else",
":",
"return",
"self",
".",
... | https://github.com/RhetTbull/osxphotos/blob/231d13279296ee4a242d3140d8abe7b5a5bcc9c0/osxphotos/photosdb/photosdb.py#L2691-L2696 | ||
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/astropy-4.0-py3.7-macosx-10.9-x86_64.egg/astropy/nddata/nduncertainty.py | python | UnknownUncertainty._data_unit_to_uncertainty_unit | (self, value) | return None | No way to convert if uncertainty is unknown. | No way to convert if uncertainty is unknown. | [
"No",
"way",
"to",
"convert",
"if",
"uncertainty",
"is",
"unknown",
"."
] | def _data_unit_to_uncertainty_unit(self, value):
"""
No way to convert if uncertainty is unknown.
"""
return None | [
"def",
"_data_unit_to_uncertainty_unit",
"(",
"self",
",",
"value",
")",
":",
"return",
"None"
] | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/astropy-4.0-py3.7-macosx-10.9-x86_64.egg/astropy/nddata/nduncertainty.py#L427-L431 | |
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e | deep-learning/fastai-docs/fastai_docs-master/dev_nb/nb_004a.py | python | trainable_params | (m:nn.Module) | return res | Return list of trainable params in `m` | Return list of trainable params in `m` | [
"Return",
"list",
"of",
"trainable",
"params",
"in",
"m"
] | def trainable_params(m:nn.Module)->ParamList:
"Return list of trainable params in `m`"
res = filter(lambda p: p.requires_grad, m.parameters())
return res | [
"def",
"trainable_params",
"(",
"m",
":",
"nn",
".",
"Module",
")",
"->",
"ParamList",
":",
"res",
"=",
"filter",
"(",
"lambda",
"p",
":",
"p",
".",
"requires_grad",
",",
"m",
".",
"parameters",
"(",
")",
")",
"return",
"res"
] | 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#L21-L24 | |
Unidata/siphon | d8ede355114801bf7a05db20dfe49ab132723f86 | src/siphon/simplewebservice/igra2.py | python | IGRAUpperAir.__init__ | (self) | Set http site address and file suffix based on desired dataset. | Set http site address and file suffix based on desired dataset. | [
"Set",
"http",
"site",
"address",
"and",
"file",
"suffix",
"based",
"on",
"desired",
"dataset",
"."
] | def __init__(self):
"""Set http site address and file suffix based on desired dataset."""
self.suffix = ''
self.begin_date = ''
self.end_date = ''
self.site_id = ''
self.folder = ''
super().__init__('https://www1.ncdc.noaa.gov/pub/data/igra/') | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"suffix",
"=",
"''",
"self",
".",
"begin_date",
"=",
"''",
"self",
".",
"end_date",
"=",
"''",
"self",
".",
"site_id",
"=",
"''",
"self",
".",
"folder",
"=",
"''",
"super",
"(",
")",
".",
"__... | https://github.com/Unidata/siphon/blob/d8ede355114801bf7a05db20dfe49ab132723f86/src/siphon/simplewebservice/igra2.py#L26-L33 | ||
apache/tvm | 6eb4ed813ebcdcd9558f0906a1870db8302ff1e0 | python/tvm/relay/op/contrib/tensorrt.py | python | strided_slice_annotate_fn | (expr) | return True | Check if strided_slice is supported by TensorRT. | Check if strided_slice is supported by TensorRT. | [
"Check",
"if",
"strided_slice",
"is",
"supported",
"by",
"TensorRT",
"."
] | def strided_slice_annotate_fn(expr): # pylint: disable=unused-variable
"""Check if strided_slice is supported by TensorRT."""
attrs, args = expr.attrs, expr.args
if args[0].checked_type.dtype != "float32":
logger.info("Only float32 inputs are supported for TensorRT.")
return False
if n... | [
"def",
"strided_slice_annotate_fn",
"(",
"expr",
")",
":",
"# pylint: disable=unused-variable",
"attrs",
",",
"args",
"=",
"expr",
".",
"attrs",
",",
"expr",
".",
"args",
"if",
"args",
"[",
"0",
"]",
".",
"checked_type",
".",
"dtype",
"!=",
"\"float32\"",
":... | https://github.com/apache/tvm/blob/6eb4ed813ebcdcd9558f0906a1870db8302ff1e0/python/tvm/relay/op/contrib/tensorrt.py#L765-L809 | |
fastnlp/fastHan | 09550a750bb06b89b81769b8786a7eb3f8ca5713 | fastHan/model/bert_encoder_theseus.py | python | BasicTokenizer._run_strip_accents | (self, text) | return "".join(output) | Strips accents from a piece of text. | Strips accents from a piece of text. | [
"Strips",
"accents",
"from",
"a",
"piece",
"of",
"text",
"."
] | def _run_strip_accents(self, text):
"""Strips accents from a piece of text."""
text = unicodedata.normalize("NFD", text)
output = []
for char in text:
cat = unicodedata.category(char)
if cat == "Mn":
continue
output.append(char)
... | [
"def",
"_run_strip_accents",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"unicodedata",
".",
"normalize",
"(",
"\"NFD\"",
",",
"text",
")",
"output",
"=",
"[",
"]",
"for",
"char",
"in",
"text",
":",
"cat",
"=",
"unicodedata",
".",
"category",
"(",... | https://github.com/fastnlp/fastHan/blob/09550a750bb06b89b81769b8786a7eb3f8ca5713/fastHan/model/bert_encoder_theseus.py#L803-L812 | |
ericgazoni/openpyxl | c55988e4904d4337ce4c35ab8b7dc305bca9de23 | openpyxl/workbook/workbook.py | python | Workbook.create_sheet | (self, index=None, title=None) | return new_ws | Create a worksheet (at an optional index).
:param index: optional position at which the sheet will be inserted
:type index: int | Create a worksheet (at an optional index). | [
"Create",
"a",
"worksheet",
"(",
"at",
"an",
"optional",
"index",
")",
"."
] | def create_sheet(self, index=None, title=None):
"""Create a worksheet (at an optional index).
:param index: optional position at which the sheet will be inserted
:type index: int
"""
if self.__optimized_read:
raise ReadOnlyWorkbookException('Cannot create new sheet... | [
"def",
"create_sheet",
"(",
"self",
",",
"index",
"=",
"None",
",",
"title",
"=",
"None",
")",
":",
"if",
"self",
".",
"__optimized_read",
":",
"raise",
"ReadOnlyWorkbookException",
"(",
"'Cannot create new sheet in a read-only workbook'",
")",
"if",
"self",
".",
... | https://github.com/ericgazoni/openpyxl/blob/c55988e4904d4337ce4c35ab8b7dc305bca9de23/openpyxl/workbook/workbook.py#L141-L163 | |
roglew/guppy-proxy | 01df16be71dd9f23d7de415a315821659c29bc63 | guppyproxy/proxy.py | python | ProxyConnection.close | (self) | [] | def close(self):
self.sbuf.close()
if self.parent_client is not None:
try:
self.parent_client.conns.remove(self)
except KeyError:
pass
self.closed = True | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"sbuf",
".",
"close",
"(",
")",
"if",
"self",
".",
"parent_client",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"parent_client",
".",
"conns",
".",
"remove",
"(",
"self",
")",
"except",
"Ke... | https://github.com/roglew/guppy-proxy/blob/01df16be71dd9f23d7de415a315821659c29bc63/guppyproxy/proxy.py#L695-L702 | ||||
stefanoborini/vai | 7e6981690209e8ccd9a6e6f64d2f2a6c7426ef3f | vai/models/Buffer.py | python | Buffer.isModified | (self) | return self._document.documentMetaInfo("Modified").data() | Returns True if the document is modified | Returns True if the document is modified | [
"Returns",
"True",
"if",
"the",
"document",
"is",
"modified"
] | def isModified(self):
"""
Returns True if the document is modified
"""
return self._document.documentMetaInfo("Modified").data() | [
"def",
"isModified",
"(",
"self",
")",
":",
"return",
"self",
".",
"_document",
".",
"documentMetaInfo",
"(",
"\"Modified\"",
")",
".",
"data",
"(",
")"
] | https://github.com/stefanoborini/vai/blob/7e6981690209e8ccd9a6e6f64d2f2a6c7426ef3f/vai/models/Buffer.py#L35-L39 | |
F8LEFT/DecLLVM | d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c | python/idc.py | python | GetEventModuleName | () | return idaapi.get_event_module_name(ev) | Get module name for debug event
@return: module name | Get module name for debug event | [
"Get",
"module",
"name",
"for",
"debug",
"event"
] | def GetEventModuleName():
"""
Get module name for debug event
@return: module name
"""
ev = idaapi.get_debug_event()
assert ev, "Could not retrieve debug event"
return idaapi.get_event_module_name(ev) | [
"def",
"GetEventModuleName",
"(",
")",
":",
"ev",
"=",
"idaapi",
".",
"get_debug_event",
"(",
")",
"assert",
"ev",
",",
"\"Could not retrieve debug event\"",
"return",
"idaapi",
".",
"get_event_module_name",
"(",
"ev",
")"
] | https://github.com/F8LEFT/DecLLVM/blob/d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c/python/idc.py#L7566-L7574 | |
pklaus/brother_ql | 56cf4394ad750346c6b664821ccd7489ec140dae | brother_ql/image_trafos.py | python | filtered_hsv | (im, filter_h, filter_s, filter_v, default_col=(255,255,255)) | return filtered_im | https://stackoverflow.com/a/22237709/183995 | https://stackoverflow.com/a/22237709/183995 | [
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"22237709",
"/",
"183995"
] | def filtered_hsv(im, filter_h, filter_s, filter_v, default_col=(255,255,255)):
""" https://stackoverflow.com/a/22237709/183995 """
hsv_im = im.convert('HSV')
H, S, V = 0, 1, 2
hsv = hsv_im.split()
mask_h = hsv[H].point(filter_h)
mask_s = hsv[S].point(filter_s)
mask_v = hsv[V].point(filter_v... | [
"def",
"filtered_hsv",
"(",
"im",
",",
"filter_h",
",",
"filter_s",
",",
"filter_v",
",",
"default_col",
"=",
"(",
"255",
",",
"255",
",",
"255",
")",
")",
":",
"hsv_im",
"=",
"im",
".",
"convert",
"(",
"'HSV'",
")",
"H",
",",
"S",
",",
"V",
"=",... | https://github.com/pklaus/brother_ql/blob/56cf4394ad750346c6b664821ccd7489ec140dae/brother_ql/image_trafos.py#L4-L23 | |
GoogleCloudPlatform/gsutil | 5be882803e76608e2fd29cf8c504ccd1fe0a7746 | gslib/boto_translation.py | python | _AddCustomEndpointToKey | (key) | Update Boto Key object with user config's custom endpoint. | Update Boto Key object with user config's custom endpoint. | [
"Update",
"Boto",
"Key",
"object",
"with",
"user",
"config",
"s",
"custom",
"endpoint",
"."
] | def _AddCustomEndpointToKey(key):
"""Update Boto Key object with user config's custom endpoint."""
user_setting_to_key_attribute = {
'gs_host': 'host',
'gs_port': 'port',
'gs_host_header': 'host_header',
}
for user_setting, key_attribute in user_setting_to_key_attribute.items():
user_setti... | [
"def",
"_AddCustomEndpointToKey",
"(",
"key",
")",
":",
"user_setting_to_key_attribute",
"=",
"{",
"'gs_host'",
":",
"'host'",
",",
"'gs_port'",
":",
"'port'",
",",
"'gs_host_header'",
":",
"'host_header'",
",",
"}",
"for",
"user_setting",
",",
"key_attribute",
"i... | https://github.com/GoogleCloudPlatform/gsutil/blob/5be882803e76608e2fd29cf8c504ccd1fe0a7746/gslib/boto_translation.py#L131-L141 | ||
Lausannen/NAS-FCOS | d586b28c0fae72a9f30119797732e614a2517de5 | maskrcnn_benchmark/utils/comm.py | python | all_gather | (data) | return data_list | Run all_gather on arbitrary picklable data (not necessarily tensors)
Args:
data: any picklable object
Returns:
list[data]: list of data gathered from each rank | Run all_gather on arbitrary picklable data (not necessarily tensors)
Args:
data: any picklable object
Returns:
list[data]: list of data gathered from each rank | [
"Run",
"all_gather",
"on",
"arbitrary",
"picklable",
"data",
"(",
"not",
"necessarily",
"tensors",
")",
"Args",
":",
"data",
":",
"any",
"picklable",
"object",
"Returns",
":",
"list",
"[",
"data",
"]",
":",
"list",
"of",
"data",
"gathered",
"from",
"each",... | def all_gather(data):
"""
Run all_gather on arbitrary picklable data (not necessarily tensors)
Args:
data: any picklable object
Returns:
list[data]: list of data gathered from each rank
"""
world_size = get_world_size()
if world_size == 1:
return [data]
# seriali... | [
"def",
"all_gather",
"(",
"data",
")",
":",
"world_size",
"=",
"get_world_size",
"(",
")",
"if",
"world_size",
"==",
"1",
":",
"return",
"[",
"data",
"]",
"# serialized to a Tensor",
"buffer",
"=",
"pickle",
".",
"dumps",
"(",
"data",
")",
"storage",
"=",
... | https://github.com/Lausannen/NAS-FCOS/blob/d586b28c0fae72a9f30119797732e614a2517de5/maskrcnn_benchmark/utils/comm.py#L48-L88 | |
akapur/pyiqfeed | d3839dcfb5e1f3ce1d5254dba503d63ef756c6ca | pyiqfeed/conn.py | python | AdminConn._process_remove_client_app_completed | (self,
fields: Sequence[str]) | Acknowledgement that the client app has de-registered.
If your app is shutting down, another app may still be using IQFeed.
Here you are telling IQFeed that all requests it is still getting are
not from apps you wrote. | Acknowledgement that the client app has de-registered. | [
"Acknowledgement",
"that",
"the",
"client",
"app",
"has",
"de",
"-",
"registered",
"."
] | def _process_remove_client_app_completed(self,
fields: Sequence[str]) -> None:
"""
Acknowledgement that the client app has de-registered.
If your app is shutting down, another app may still be using IQFeed.
Here you are telling IQFeed that al... | [
"def",
"_process_remove_client_app_completed",
"(",
"self",
",",
"fields",
":",
"Sequence",
"[",
"str",
"]",
")",
"->",
"None",
":",
"assert",
"len",
"(",
"fields",
")",
">",
"1",
"assert",
"fields",
"[",
"0",
"]",
"==",
"'S'",
"assert",
"fields",
"[",
... | https://github.com/akapur/pyiqfeed/blob/d3839dcfb5e1f3ce1d5254dba503d63ef756c6ca/pyiqfeed/conn.py#L1397-L1411 | ||
Bitwise-01/Instagram- | 407adf5af54a0dc59bd93650c5b6eb9685190462 | lib/proxy.py | python | Proxy.decr_usage | (self) | Takes away usage data for this session | Takes away usage data for this session | [
"Takes",
"away",
"usage",
"data",
"for",
"this",
"session"
] | def decr_usage(self) -> None:
"""Takes away usage data for this session"""
self.__total_used = 0
self.__total_passed = 0 | [
"def",
"decr_usage",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"__total_used",
"=",
"0",
"self",
".",
"__total_passed",
"=",
"0"
] | https://github.com/Bitwise-01/Instagram-/blob/407adf5af54a0dc59bd93650c5b6eb9685190462/lib/proxy.py#L28-L31 | ||
linuxscout/pyarabic | 010bddadb7c9b5c6bd24cc02d4aeddde0c4a10c4 | pyarabic/araby.py | python | is_arabicrange | (text) | return True | Checks for an Arabic Unicode block characters
@param text: input text
@type text: unicode
@return: True if all charaters are in Arabic block
@rtype: Boolean | Checks for an Arabic Unicode block characters | [
"Checks",
"for",
"an",
"Arabic",
"Unicode",
"block",
"characters"
] | def is_arabicrange(text):
""" Checks for an Arabic Unicode block characters
@param text: input text
@type text: unicode
@return: True if all charaters are in Arabic block
@rtype: Boolean
"""
if ARABIC_RANGE.search(text):
return False
return True | [
"def",
"is_arabicrange",
"(",
"text",
")",
":",
"if",
"ARABIC_RANGE",
".",
"search",
"(",
"text",
")",
":",
"return",
"False",
"return",
"True"
] | https://github.com/linuxscout/pyarabic/blob/010bddadb7c9b5c6bd24cc02d4aeddde0c4a10c4/pyarabic/araby.py#L602-L611 | |
kinegratii/django-echarts | 50f9ebb60ccd5e96aeb88176b6e8c789a66b7677 | django_echarts/datasets/fetch.py | python | ifetch_single | (iterable, key, default=EMPTY, getter=None) | return map(_getter, iterable) | getter() g(item, key):pass | getter() g(item, key):pass | [
"getter",
"()",
"g",
"(",
"item",
"key",
")",
":",
"pass"
] | def ifetch_single(iterable, key, default=EMPTY, getter=None):
"""
getter() g(item, key):pass
"""
def _getter(item):
if getter:
custom_getter = partial(getter, key=key)
return custom_getter(item)
else:
try:
attrgetter = operator.attrget... | [
"def",
"ifetch_single",
"(",
"iterable",
",",
"key",
",",
"default",
"=",
"EMPTY",
",",
"getter",
"=",
"None",
")",
":",
"def",
"_getter",
"(",
"item",
")",
":",
"if",
"getter",
":",
"custom_getter",
"=",
"partial",
"(",
"getter",
",",
"key",
"=",
"k... | https://github.com/kinegratii/django-echarts/blob/50f9ebb60ccd5e96aeb88176b6e8c789a66b7677/django_echarts/datasets/fetch.py#L19-L46 | |
saltstack/salt | fae5bc757ad0f1716483ce7ae180b451545c2058 | salt/modules/win_iis.py | python | __virtual__ | () | return __virtualname__ | Load only on Windows
Requires PowerShell and the WebAdministration module | Load only on Windows
Requires PowerShell and the WebAdministration module | [
"Load",
"only",
"on",
"Windows",
"Requires",
"PowerShell",
"and",
"the",
"WebAdministration",
"module"
] | def __virtual__():
"""
Load only on Windows
Requires PowerShell and the WebAdministration module
"""
if not salt.utils.platform.is_windows():
return False, "Only available on Windows systems"
powershell_info = __salt__["cmd.shell_info"]("powershell", True)
if not powershell_info["in... | [
"def",
"__virtual__",
"(",
")",
":",
"if",
"not",
"salt",
".",
"utils",
".",
"platform",
".",
"is_windows",
"(",
")",
":",
"return",
"False",
",",
"\"Only available on Windows systems\"",
"powershell_info",
"=",
"__salt__",
"[",
"\"cmd.shell_info\"",
"]",
"(",
... | https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/modules/win_iis.py#L31-L46 | |
Azure/azure-linux-extensions | a42ef718c746abab2b3c6a21da87b29e76364558 | OSPatching/azure/__init__.py | python | _fill_scalar_list_of | (xmldoc, element_type, parent_xml_element_name,
xml_element_name) | Converts an xml fragment into a list of scalar types. The parent xml
element contains a flat list of xml elements which are converted into the
specified scalar type and added to the list.
Example:
xmldoc=
<Endpoints>
<Endpoint>http://{storage-service-name}.blob.core.windows.net/</Endpoint>
<End... | Converts an xml fragment into a list of scalar types. The parent xml
element contains a flat list of xml elements which are converted into the
specified scalar type and added to the list.
Example:
xmldoc=
<Endpoints>
<Endpoint>http://{storage-service-name}.blob.core.windows.net/</Endpoint>
<End... | [
"Converts",
"an",
"xml",
"fragment",
"into",
"a",
"list",
"of",
"scalar",
"types",
".",
"The",
"parent",
"xml",
"element",
"contains",
"a",
"flat",
"list",
"of",
"xml",
"elements",
"which",
"are",
"converted",
"into",
"the",
"specified",
"scalar",
"type",
... | def _fill_scalar_list_of(xmldoc, element_type, parent_xml_element_name,
xml_element_name):
'''Converts an xml fragment into a list of scalar types. The parent xml
element contains a flat list of xml elements which are converted into the
specified scalar type and added to the list.
... | [
"def",
"_fill_scalar_list_of",
"(",
"xmldoc",
",",
"element_type",
",",
"parent_xml_element_name",
",",
"xml_element_name",
")",
":",
"xmlelements",
"=",
"_get_child_nodes",
"(",
"xmldoc",
",",
"parent_xml_element_name",
")",
"if",
"xmlelements",
":",
"xmlelements",
"... | https://github.com/Azure/azure-linux-extensions/blob/a42ef718c746abab2b3c6a21da87b29e76364558/OSPatching/azure/__init__.py#L476-L496 | ||
zedshaw/lamson | 8a8ad546ea746b129fa5f069bf9278f87d01473a | examples/librelist/app/model/archive.py | python | to_json | (base) | return json.dumps(json_build(base), sort_keys=True, indent=4) | [] | def to_json(base):
return json.dumps(json_build(base), sort_keys=True, indent=4) | [
"def",
"to_json",
"(",
"base",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"json_build",
"(",
"base",
")",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
")"
] | https://github.com/zedshaw/lamson/blob/8a8ad546ea746b129fa5f069bf9278f87d01473a/examples/librelist/app/model/archive.py#L100-L101 | |||
pypa/bandersnatch | 2e3eb53029ddb8f205f85242d724ae492040c1ce | src/bandersnatch/delete.py | python | delete_packages | (config: ConfigParser, args: Namespace, master: Master) | return 0 | [] | async def delete_packages(config: ConfigParser, args: Namespace, master: Master) -> int:
workers = args.workers or config.getint("mirror", "workers")
executor = concurrent.futures.ThreadPoolExecutor(max_workers=workers)
storage_backend = next(
iter(storage_backend_plugins(config=config, clear_cache=... | [
"async",
"def",
"delete_packages",
"(",
"config",
":",
"ConfigParser",
",",
"args",
":",
"Namespace",
",",
"master",
":",
"Master",
")",
"->",
"int",
":",
"workers",
"=",
"args",
".",
"workers",
"or",
"config",
".",
"getint",
"(",
"\"mirror\"",
",",
"\"w... | https://github.com/pypa/bandersnatch/blob/2e3eb53029ddb8f205f85242d724ae492040c1ce/src/bandersnatch/delete.py#L48-L121 | |||
quic/aimet | dae9bae9a77ca719aa7553fefde4768270fc3518 | TrainingExtensions/torch/src/python/aimet_torch/cross_layer_equalization.py | python | GraphSearchUtils.find_downstream_layer_groups_to_scale | (op, layer_groups, current_group=None, visited_nodes=None) | Recursive function to find cls layer groups downstream from a given op
:param op: Starting op to search from
:param layer_groups: Running list of layer groups
:param current_group: Running current layer group
:param visited_nodes: Running list of visited nodes (to short-circuit recursion... | Recursive function to find cls layer groups downstream from a given op
:param op: Starting op to search from
:param layer_groups: Running list of layer groups
:param current_group: Running current layer group
:param visited_nodes: Running list of visited nodes (to short-circuit recursion... | [
"Recursive",
"function",
"to",
"find",
"cls",
"layer",
"groups",
"downstream",
"from",
"a",
"given",
"op",
":",
"param",
"op",
":",
"Starting",
"op",
"to",
"search",
"from",
":",
"param",
"layer_groups",
":",
"Running",
"list",
"of",
"layer",
"groups",
":"... | def find_downstream_layer_groups_to_scale(op, layer_groups, current_group=None, visited_nodes=None):
"""
Recursive function to find cls layer groups downstream from a given op
:param op: Starting op to search from
:param layer_groups: Running list of layer groups
:param current_g... | [
"def",
"find_downstream_layer_groups_to_scale",
"(",
"op",
",",
"layer_groups",
",",
"current_group",
"=",
"None",
",",
"visited_nodes",
"=",
"None",
")",
":",
"if",
"not",
"visited_nodes",
":",
"visited_nodes",
"=",
"[",
"]",
"if",
"not",
"current_group",
":",
... | https://github.com/quic/aimet/blob/dae9bae9a77ca719aa7553fefde4768270fc3518/TrainingExtensions/torch/src/python/aimet_torch/cross_layer_equalization.py#L115-L154 | ||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Centos_5.9/paramiko/file.py | python | BufferedFile.__iter__ | (self) | return self | Returns an iterator that can be used to iterate over the lines in this
file. This iterator happens to return the file itself, since a file is
its own iterator.
@raise ValueError: if the file is closed.
@return: an interator.
@rtype: iterator | Returns an iterator that can be used to iterate over the lines in this
file. This iterator happens to return the file itself, since a file is
its own iterator. | [
"Returns",
"an",
"iterator",
"that",
"can",
"be",
"used",
"to",
"iterate",
"over",
"the",
"lines",
"in",
"this",
"file",
".",
"This",
"iterator",
"happens",
"to",
"return",
"the",
"file",
"itself",
"since",
"a",
"file",
"is",
"its",
"own",
"iterator",
".... | def __iter__(self):
"""
Returns an iterator that can be used to iterate over the lines in this
file. This iterator happens to return the file itself, since a file is
its own iterator.
@raise ValueError: if the file is closed.
@return: an interator.
@rty... | [
"def",
"__iter__",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"raise",
"ValueError",
"(",
"'I/O operation on closed file'",
")",
"return",
"self"
] | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Centos_5.9/paramiko/file.py#L64-L77 | |
linxid/Machine_Learning_Study_Path | 558e82d13237114bbb8152483977806fc0c222af | Machine Learning In Action/Chapter4-NaiveBayes/venv/Lib/encodings/base64_codec.py | python | base64_decode | (input, errors='strict') | return (base64.decodebytes(input), len(input)) | [] | def base64_decode(input, errors='strict'):
assert errors == 'strict'
return (base64.decodebytes(input), len(input)) | [
"def",
"base64_decode",
"(",
"input",
",",
"errors",
"=",
"'strict'",
")",
":",
"assert",
"errors",
"==",
"'strict'",
"return",
"(",
"base64",
".",
"decodebytes",
"(",
"input",
")",
",",
"len",
"(",
"input",
")",
")"
] | https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter4-NaiveBayes/venv/Lib/encodings/base64_codec.py#L17-L19 | |||
out0fmemory/GoAgent-Always-Available | c4254984fea633ce3d1893fe5901debd9f22c2a9 | server/lib/google/appengine/ext/ndb/model.py | python | Model._from_pb | (cls, pb, set_key=True, ent=None, key=None) | return ent | Internal helper to create an entity from an EntityProto protobuf. | Internal helper to create an entity from an EntityProto protobuf. | [
"Internal",
"helper",
"to",
"create",
"an",
"entity",
"from",
"an",
"EntityProto",
"protobuf",
"."
] | def _from_pb(cls, pb, set_key=True, ent=None, key=None):
"""Internal helper to create an entity from an EntityProto protobuf."""
if not isinstance(pb, entity_pb.EntityProto):
raise TypeError('pb must be a EntityProto; received %r' % pb)
if ent is None:
ent = cls()
# A key passed in override... | [
"def",
"_from_pb",
"(",
"cls",
",",
"pb",
",",
"set_key",
"=",
"True",
",",
"ent",
"=",
"None",
",",
"key",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"pb",
",",
"entity_pb",
".",
"EntityProto",
")",
":",
"raise",
"TypeError",
"(",
"'pb... | https://github.com/out0fmemory/GoAgent-Always-Available/blob/c4254984fea633ce3d1893fe5901debd9f22c2a9/server/lib/google/appengine/ext/ndb/model.py#L3189-L3212 | |
glitchdotcom/WebPutty | 4f5da5eb2b4668cbf3c15cf002feacd1d95d2ef7 | ziplibs/wtforms/fields.py | python | SelectFieldBase.iter_choices | (self) | Provides data for choice widget rendering. Must return a sequence or
iterable of (value, label, selected) tuples. | Provides data for choice widget rendering. Must return a sequence or
iterable of (value, label, selected) tuples. | [
"Provides",
"data",
"for",
"choice",
"widget",
"rendering",
".",
"Must",
"return",
"a",
"sequence",
"or",
"iterable",
"of",
"(",
"value",
"label",
"selected",
")",
"tuples",
"."
] | def iter_choices(self):
"""
Provides data for choice widget rendering. Must return a sequence or
iterable of (value, label, selected) tuples.
"""
raise NotImplementedError() | [
"def",
"iter_choices",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | https://github.com/glitchdotcom/WebPutty/blob/4f5da5eb2b4668cbf3c15cf002feacd1d95d2ef7/ziplibs/wtforms/fields.py#L358-L363 | ||
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/idlelib/configdialog.py | python | HelpFrame.helplist_item_remove | (self) | Handle remove button for the help list.
Delete the help list item from config. | Handle remove button for the help list. | [
"Handle",
"remove",
"button",
"for",
"the",
"help",
"list",
"."
] | def helplist_item_remove(self):
"""Handle remove button for the help list.
Delete the help list item from config.
"""
item_index = self.helplist.index(ANCHOR)
del(self.user_helplist[item_index])
self.helplist.delete(item_index)
self.update_help_changes()
... | [
"def",
"helplist_item_remove",
"(",
"self",
")",
":",
"item_index",
"=",
"self",
".",
"helplist",
".",
"index",
"(",
"ANCHOR",
")",
"del",
"(",
"self",
".",
"user_helplist",
"[",
"item_index",
"]",
")",
"self",
".",
"helplist",
".",
"delete",
"(",
"item_... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/idlelib/configdialog.py#L2195-L2204 | ||
oracle/oci-python-sdk | 3c1604e4e212008fb6718e2f68cdb5ef71fd5793 | src/oci/artifacts/artifacts_client.py | python | ArtifactsClient.create_container_image_signature | (self, create_container_image_signature_details, **kwargs) | Upload a signature to an image.
:param oci.artifacts.models.CreateContainerImageSignatureDetails create_container_image_signature_details: (required)
Upload container image signature details
:param str opc_request_id: (optional)
Unique identifier for the request.
I... | Upload a signature to an image. | [
"Upload",
"a",
"signature",
"to",
"an",
"image",
"."
] | def create_container_image_signature(self, create_container_image_signature_details, **kwargs):
"""
Upload a signature to an image.
:param oci.artifacts.models.CreateContainerImageSignatureDetails create_container_image_signature_details: (required)
Upload container image signature... | [
"def",
"create_container_image_signature",
"(",
"self",
",",
"create_container_image_signature_details",
",",
"*",
"*",
"kwargs",
")",
":",
"resource_path",
"=",
"\"/container/imageSignatures\"",
"method",
"=",
"\"POST\"",
"# Don't accept unknown kwargs",
"expected_kwargs",
"... | https://github.com/oracle/oci-python-sdk/blob/3c1604e4e212008fb6718e2f68cdb5ef71fd5793/src/oci/artifacts/artifacts_client.py#L318-L403 | ||
Instagram/LibCST | 13370227703fe3171e94c57bdd7977f3af696b73 | libcst/_parser/base_parser.py | python | BaseParser.convert_nonterminal | (
self, nonterminal: str, children: Sequence[_NodeT]
) | [] | def convert_nonterminal(
self, nonterminal: str, children: Sequence[_NodeT]
) -> _NodeT:
... | [
"def",
"convert_nonterminal",
"(",
"self",
",",
"nonterminal",
":",
"str",
",",
"children",
":",
"Sequence",
"[",
"_NodeT",
"]",
")",
"->",
"_NodeT",
":",
"..."
] | https://github.com/Instagram/LibCST/blob/13370227703fe3171e94c57bdd7977f3af696b73/libcst/_parser/base_parser.py#L130-L133 | ||||
smart-mobile-software/gitstack | d9fee8f414f202143eb6e620529e8e5539a2af56 | python/Lib/idlelib/tabbedpages.py | python | TabSet.set_selected_tab | (self, tab_name) | Show the tab named <tab_name> as the selected one | Show the tab named <tab_name> as the selected one | [
"Show",
"the",
"tab",
"named",
"<tab_name",
">",
"as",
"the",
"selected",
"one"
] | def set_selected_tab(self, tab_name):
"""Show the tab named <tab_name> as the selected one"""
if tab_name == self._selected_tab:
return
if tab_name is not None and tab_name not in self._tabs:
raise KeyError("No such Tab: '%s" % page_name)
# deselect the current s... | [
"def",
"set_selected_tab",
"(",
"self",
",",
"tab_name",
")",
":",
"if",
"tab_name",
"==",
"self",
".",
"_selected_tab",
":",
"return",
"if",
"tab_name",
"is",
"not",
"None",
"and",
"tab_name",
"not",
"in",
"self",
".",
"_tabs",
":",
"raise",
"KeyError",
... | https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/idlelib/tabbedpages.py#L86-L106 | ||
hasanirtiza/Pedestron | 3bdcf8476edc0741f28a80dd4cb161ac532507ee | mmdet/models/losses/accuracy.py | python | Accuracy.forward | (self, pred, target) | return accuracy(pred, target, self.topk) | [] | def forward(self, pred, target):
return accuracy(pred, target, self.topk) | [
"def",
"forward",
"(",
"self",
",",
"pred",
",",
"target",
")",
":",
"return",
"accuracy",
"(",
"pred",
",",
"target",
",",
"self",
".",
"topk",
")"
] | https://github.com/hasanirtiza/Pedestron/blob/3bdcf8476edc0741f28a80dd4cb161ac532507ee/mmdet/models/losses/accuracy.py#L30-L31 | |||
PyTorchLightning/lightning-bolts | 22e494e546e7fe322d6b4cf36258819c7ba58e02 | pl_bolts/datamodules/imagenet_datamodule.py | python | ImagenetDataModule.train_dataloader | (self) | return loader | Uses the train split of imagenet2012 and puts away a portion of it for the validation split. | Uses the train split of imagenet2012 and puts away a portion of it for the validation split. | [
"Uses",
"the",
"train",
"split",
"of",
"imagenet2012",
"and",
"puts",
"away",
"a",
"portion",
"of",
"it",
"for",
"the",
"validation",
"split",
"."
] | def train_dataloader(self) -> DataLoader:
"""Uses the train split of imagenet2012 and puts away a portion of it for the validation split."""
transforms = self.train_transform() if self.train_transforms is None else self.train_transforms
dataset = UnlabeledImagenet(
self.data_dir,
... | [
"def",
"train_dataloader",
"(",
"self",
")",
"->",
"DataLoader",
":",
"transforms",
"=",
"self",
".",
"train_transform",
"(",
")",
"if",
"self",
".",
"train_transforms",
"is",
"None",
"else",
"self",
".",
"train_transforms",
"dataset",
"=",
"UnlabeledImagenet",
... | https://github.com/PyTorchLightning/lightning-bolts/blob/22e494e546e7fe322d6b4cf36258819c7ba58e02/pl_bolts/datamodules/imagenet_datamodule.py#L144-L164 | |
adamgot/python-plexlibrary | 6525ea73e1d5b6713e085f5a417ab831cf1c13bb | plexlibrary/imdbutils.py | python | IMDb._handle_request | (self, url) | return ids, titles, years | Stolen from Automated IMDB Top 250 Plex library script
by /u/SwiftPanda16 | Stolen from Automated IMDB Top 250 Plex library script
by /u/SwiftPanda16 | [
"Stolen",
"from",
"Automated",
"IMDB",
"Top",
"250",
"Plex",
"library",
"script",
"by",
"/",
"u",
"/",
"SwiftPanda16"
] | def _handle_request(self, url):
"""Stolen from Automated IMDB Top 250 Plex library script
by /u/SwiftPanda16
"""
r = requests.get(url)
tree = html.fromstring(r.content)
# Dict of the IMDB top 250 ids in order
titles = tree.xpath("//table[contains(@class, 'char... | [
"def",
"_handle_request",
"(",
"self",
",",
"url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"tree",
"=",
"html",
".",
"fromstring",
"(",
"r",
".",
"content",
")",
"# Dict of the IMDB top 250 ids in order",
"titles",
"=",
"tree",
".",
... | https://github.com/adamgot/python-plexlibrary/blob/6525ea73e1d5b6713e085f5a417ab831cf1c13bb/plexlibrary/imdbutils.py#L16-L31 | |
eirannejad/pyRevit | 49c0b7eb54eb343458ce1365425e6552d0c47d44 | site-packages/werkzeug/contrib/sessions.py | python | Session.should_save | (self) | return self.modified | True if the session should be saved.
.. versionchanged:: 0.6
By default the session is now only saved if the session is
modified, not if it is new like it was before. | True if the session should be saved. | [
"True",
"if",
"the",
"session",
"should",
"be",
"saved",
"."
] | def should_save(self):
"""True if the session should be saved.
.. versionchanged:: 0.6
By default the session is now only saved if the session is
modified, not if it is new like it was before.
"""
return self.modified | [
"def",
"should_save",
"(",
"self",
")",
":",
"return",
"self",
".",
"modified"
] | https://github.com/eirannejad/pyRevit/blob/49c0b7eb54eb343458ce1365425e6552d0c47d44/site-packages/werkzeug/contrib/sessions.py#L135-L142 | |
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/horizon/horizon/base.py | python | Site.get_default_dashboard | (self) | Returns the default :class:`~horizon.Dashboard` instance.
If ``"default_dashboard"`` is specified in ``HORIZON_CONFIG``
then that dashboard will be returned. If not, the first dashboard
returned by :func:`~horizon.get_dashboards` will be returned. | Returns the default :class:`~horizon.Dashboard` instance. | [
"Returns",
"the",
"default",
":",
"class",
":",
"~horizon",
".",
"Dashboard",
"instance",
"."
] | def get_default_dashboard(self):
""" Returns the default :class:`~horizon.Dashboard` instance.
If ``"default_dashboard"`` is specified in ``HORIZON_CONFIG``
then that dashboard will be returned. If not, the first dashboard
returned by :func:`~horizon.get_dashboards` will be returned.
... | [
"def",
"get_default_dashboard",
"(",
"self",
")",
":",
"if",
"self",
".",
"default_dashboard",
":",
"return",
"self",
".",
"_registered",
"(",
"self",
".",
"default_dashboard",
")",
"elif",
"len",
"(",
"self",
".",
"_registry",
")",
":",
"return",
"self",
... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/horizon/horizon/base.py#L645-L657 | ||
google-research/language | 61fa7260ac7d690d11ef72ca863e45a37c0bdc80 | language/labs/drkit/evaluate.py | python | normalize_answer | (s) | return white_space_fix(remove_articles(remove_punc(lower(s)))) | Lower text and remove punctuation, articles and extra whitespace. | Lower text and remove punctuation, articles and extra whitespace. | [
"Lower",
"text",
"and",
"remove",
"punctuation",
"articles",
"and",
"extra",
"whitespace",
"."
] | def normalize_answer(s):
"""Lower text and remove punctuation, articles and extra whitespace."""
def remove_articles(text):
return re.sub(r"\b(a|an|the)\b", " ", text)
def white_space_fix(text):
return " ".join(text.split())
def remove_punc(text):
exclude = set(string.punctuation)
return "".j... | [
"def",
"normalize_answer",
"(",
"s",
")",
":",
"def",
"remove_articles",
"(",
"text",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r\"\\b(a|an|the)\\b\"",
",",
"\" \"",
",",
"text",
")",
"def",
"white_space_fix",
"(",
"text",
")",
":",
"return",
"\" \"",
... | https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/labs/drkit/evaluate.py#L322-L338 | |
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/cinder/cinder/api/v2/views/volumes.py | python | ViewBuilder.summary_list | (self, request, volumes) | return self._list_view(self.summary, request, volumes) | Show a list of volumes without many details. | Show a list of volumes without many details. | [
"Show",
"a",
"list",
"of",
"volumes",
"without",
"many",
"details",
"."
] | def summary_list(self, request, volumes):
"""Show a list of volumes without many details."""
return self._list_view(self.summary, request, volumes) | [
"def",
"summary_list",
"(",
"self",
",",
"request",
",",
"volumes",
")",
":",
"return",
"self",
".",
"_list_view",
"(",
"self",
".",
"summary",
",",
"request",
",",
"volumes",
")"
] | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/cinder/cinder/api/v2/views/volumes.py#L34-L36 | |
khanhnamle1994/natural-language-processing | 01d450d5ac002b0156ef4cf93a07cb508c1bcdc5 | assignment1/.env/lib/python2.7/site-packages/six.py | python | add_metaclass | (metaclass) | return wrapper | Class decorator for creating a class with a metaclass. | Class decorator for creating a class with a metaclass. | [
"Class",
"decorator",
"for",
"creating",
"a",
"class",
"with",
"a",
"metaclass",
"."
] | def add_metaclass(metaclass):
"""Class decorator for creating a class with a metaclass."""
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
if slots is not None:
if isinstance(slots, str):
slots = [slots]
for slo... | [
"def",
"add_metaclass",
"(",
"metaclass",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"orig_vars",
"=",
"cls",
".",
"__dict__",
".",
"copy",
"(",
")",
"slots",
"=",
"orig_vars",
".",
"get",
"(",
"'__slots__'",
")",
"if",
"slots",
"is",
"not",
"... | https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/six.py#L782-L795 | |
replit-archive/empythoned | 977ec10ced29a3541a4973dc2b59910805695752 | cpython/Lib/pydoc.py | python | HTMLDoc.index | (self, dir, shadowed=None) | return self.bigsection(dir, '#ffffff', '#ee77aa', contents) | Generate an HTML index for a directory of modules. | Generate an HTML index for a directory of modules. | [
"Generate",
"an",
"HTML",
"index",
"for",
"a",
"directory",
"of",
"modules",
"."
] | def index(self, dir, shadowed=None):
"""Generate an HTML index for a directory of modules."""
modpkgs = []
if shadowed is None: shadowed = {}
for importer, name, ispkg in pkgutil.iter_modules([dir]):
modpkgs.append((name, '', ispkg, name in shadowed))
shadowed[nam... | [
"def",
"index",
"(",
"self",
",",
"dir",
",",
"shadowed",
"=",
"None",
")",
":",
"modpkgs",
"=",
"[",
"]",
"if",
"shadowed",
"is",
"None",
":",
"shadowed",
"=",
"{",
"}",
"for",
"importer",
",",
"name",
",",
"ispkg",
"in",
"pkgutil",
".",
"iter_mod... | https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/pydoc.py#L931-L941 | |
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/opentherm_gw/__init__.py | python | async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | return unload_ok | Cleanup and disconnect from gateway. | Cleanup and disconnect from gateway. | [
"Cleanup",
"and",
"disconnect",
"from",
"gateway",
"."
] | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Cleanup and disconnect from gateway."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
gateway = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][entry.data[CONF_ID]]
await gateway.cleanup()
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"await",
"hass",
".",
"config_entries",
".",
"async_unload_platforms",
"(",
"entry",
",",
"PLATFORMS",
")",
"ga... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/opentherm_gw/__init__.py#L400-L405 | |
FederatedAI/FATE | 32540492623568ecd1afcb367360133616e02fa3 | python/fate_arch/abc/_storage.py | python | StorageTableMetaABC.get_in_serialized | (self) | [] | def get_in_serialized(self):
... | [
"def",
"get_in_serialized",
"(",
"self",
")",
":",
"..."
] | https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/fate_arch/abc/_storage.py#L77-L78 | ||||
interpretml/interpret-text | d74efc985270aaa2b3ab779408597d9505e9ea1d | python/interpret_text/experimental/introspective_rationale/explainer.py | python | IntrospectiveRationaleExplainer._load_defaults_model_config_dict | (self) | return config | Load default configuration for a given classifier
:return: config: Model configuration
:rtype: Dict | Load default configuration for a given classifier | [
"Load",
"default",
"configuration",
"for",
"a",
"given",
"classifier"
] | def _load_defaults_model_config_dict(self) -> Dict:
""" Load default configuration for a given classifier
:return: config: Model configuration
:rtype: Dict
"""
if self.classifier_type == CLASSIFIER_TYPE_BERT:
config = get_bert_default_config()
elif self.class... | [
"def",
"_load_defaults_model_config_dict",
"(",
"self",
")",
"->",
"Dict",
":",
"if",
"self",
".",
"classifier_type",
"==",
"CLASSIFIER_TYPE_BERT",
":",
"config",
"=",
"get_bert_default_config",
"(",
")",
"elif",
"self",
".",
"classifier_type",
"==",
"CLASSIFIER_TYP... | https://github.com/interpretml/interpret-text/blob/d74efc985270aaa2b3ab779408597d9505e9ea1d/python/interpret_text/experimental/introspective_rationale/explainer.py#L173-L188 | |
davidhalter/parso | ee5edaf22ff3941cbdfa4efd8cb3e8f69779fd56 | parso/python/tree.py | python | Function._get_param_nodes | (self) | return self.children[2].children | [] | def _get_param_nodes(self):
return self.children[2].children | [
"def",
"_get_param_nodes",
"(",
"self",
")",
":",
"return",
"self",
".",
"children",
"[",
"2",
"]",
".",
"children"
] | https://github.com/davidhalter/parso/blob/ee5edaf22ff3941cbdfa4efd8cb3e8f69779fd56/parso/python/tree.py#L557-L558 | |||
sethmlarson/virtualbox-python | 984a6e2cb0e8996f4df40f4444c1528849f1c70d | virtualbox/library.py | python | IEventSource.register_listener | (self, listener, interesting, active) | Register an event listener.
To avoid system overload, the VirtualBox server process checks if passive event
listeners call :py:func:`IEventSource.get_event` frequently enough. In the
current implementation, if more than 500 pending events are detected for a passive
event listener, it ... | Register an event listener. | [
"Register",
"an",
"event",
"listener",
"."
] | def register_listener(self, listener, interesting, active):
"""Register an event listener.
To avoid system overload, the VirtualBox server process checks if passive event
listeners call :py:func:`IEventSource.get_event` frequently enough. In the
current implementation, if more than 50... | [
"def",
"register_listener",
"(",
"self",
",",
"listener",
",",
"interesting",
",",
"active",
")",
":",
"if",
"not",
"isinstance",
"(",
"listener",
",",
"IEventListener",
")",
":",
"raise",
"TypeError",
"(",
"\"listener can only be an instance of type IEventListener\""... | https://github.com/sethmlarson/virtualbox-python/blob/984a6e2cb0e8996f4df40f4444c1528849f1c70d/virtualbox/library.py#L34183-L34220 | ||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/rest_framework/schemas.py | python | EndpointInspector.get_path_from_regex | (self, path_regex) | return path | Given a URL conf regex, return a URI template string. | Given a URL conf regex, return a URI template string. | [
"Given",
"a",
"URL",
"conf",
"regex",
"return",
"a",
"URI",
"template",
"string",
"."
] | def get_path_from_regex(self, path_regex):
"""
Given a URL conf regex, return a URI template string.
"""
path = simplify_regex(path_regex)
path = path.replace('<', '{').replace('>', '}')
return path | [
"def",
"get_path_from_regex",
"(",
"self",
",",
"path_regex",
")",
":",
"path",
"=",
"simplify_regex",
"(",
"path_regex",
")",
"path",
"=",
"path",
".",
"replace",
"(",
"'<'",
",",
"'{'",
")",
".",
"replace",
"(",
"'>'",
",",
"'}'",
")",
"return",
"pat... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/rest_framework/schemas.py#L224-L230 | |
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/scf/v20180416/models.py | python | PublishLayerVersionResponse.__init__ | (self) | r"""
:param LayerVersion: 本次创建的层的版本号
:type LayerVersion: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | r"""
:param LayerVersion: 本次创建的层的版本号
:type LayerVersion: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | [
"r",
":",
"param",
"LayerVersion",
":",
"本次创建的层的版本号",
":",
"type",
"LayerVersion",
":",
"int",
":",
"param",
"RequestId",
":",
"唯一请求",
"ID,每次请求都会返回。定位问题时需要提供该次请求的",
"RequestId。",
":",
"type",
"RequestId",
":",
"str"
] | def __init__(self):
r"""
:param LayerVersion: 本次创建的层的版本号
:type LayerVersion: int
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str
"""
self.LayerVersion = None
self.RequestId = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"LayerVersion",
"=",
"None",
"self",
".",
"RequestId",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/scf/v20180416/models.py#L3710-L3718 | ||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/Python-2.7.9/Lib/plat-linux2/TYPES.py | python | FD_ZERO | (fdsetp) | return __FD_ZERO (fdsetp) | [] | def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) | [
"def",
"FD_ZERO",
"(",
"fdsetp",
")",
":",
"return",
"__FD_ZERO",
"(",
"fdsetp",
")"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/plat-linux2/TYPES.py#L155-L155 | |||
ofirnachum/tree_rnn | 84a7c71202b118239ba17ad72590808c65e816e7 | tree_rnn.py | python | gen_nn_inputs | (root_node, max_degree=None, only_leaves_have_vals=True,
with_labels=False) | return (np.array(x, dtype='int32'),
np.array(tree, dtype='int32')) | Given a root node, returns the appropriate inputs to NN.
The NN takes in
x: the values at the leaves (e.g. word indices)
tree: a (n x degree) matrix that provides the computation order.
Namely, a row tree[i] = [a, b, c] in tree signifies that a
and b are children of c, and t... | Given a root node, returns the appropriate inputs to NN. | [
"Given",
"a",
"root",
"node",
"returns",
"the",
"appropriate",
"inputs",
"to",
"NN",
"."
] | def gen_nn_inputs(root_node, max_degree=None, only_leaves_have_vals=True,
with_labels=False):
"""Given a root node, returns the appropriate inputs to NN.
The NN takes in
x: the values at the leaves (e.g. word indices)
tree: a (n x degree) matrix that provides the computation o... | [
"def",
"gen_nn_inputs",
"(",
"root_node",
",",
"max_degree",
"=",
"None",
",",
"only_leaves_have_vals",
"=",
"True",
",",
"with_labels",
"=",
"False",
")",
":",
"_clear_indices",
"(",
"root_node",
")",
"x",
",",
"leaf_labels",
"=",
"_get_leaf_vals",
"(",
"root... | https://github.com/ofirnachum/tree_rnn/blob/84a7c71202b118239ba17ad72590808c65e816e7/tree_rnn.py#L72-L103 | |
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/video/v1/composition_hook.py | python | CompositionHookInstance.date_created | (self) | return self._properties['date_created'] | :returns: The ISO 8601 date and time in GMT when the resource was created
:rtype: datetime | :returns: The ISO 8601 date and time in GMT when the resource was created
:rtype: datetime | [
":",
"returns",
":",
"The",
"ISO",
"8601",
"date",
"and",
"time",
"in",
"GMT",
"when",
"the",
"resource",
"was",
"created",
":",
"rtype",
":",
"datetime"
] | def date_created(self):
"""
:returns: The ISO 8601 date and time in GMT when the resource was created
:rtype: datetime
"""
return self._properties['date_created'] | [
"def",
"date_created",
"(",
"self",
")",
":",
"return",
"self",
".",
"_properties",
"[",
"'date_created'",
"]"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/video/v1/composition_hook.py#L423-L428 | |
gumroad/gumroad-v1 | 35be4df01717b47a290c01b28ad5391e81c44a68 | appengine_utilities/sessions.py | python | _AppEngineUtilities_SessionData.delete | (self) | return True | Deletes an entity from the session in memcache and the datastore
Returns True | Deletes an entity from the session in memcache and the datastore | [
"Deletes",
"an",
"entity",
"from",
"the",
"session",
"in",
"memcache",
"and",
"the",
"datastore"
] | def delete(self):
"""
Deletes an entity from the session in memcache and the datastore
Returns True
"""
try:
db.delete(self)
except:
self.deleted = True
mc_items = memcache.get(u"_AppEngineUtilities_SessionData_%s" % \
(str(sel... | [
"def",
"delete",
"(",
"self",
")",
":",
"try",
":",
"db",
".",
"delete",
"(",
"self",
")",
"except",
":",
"self",
".",
"deleted",
"=",
"True",
"mc_items",
"=",
"memcache",
".",
"get",
"(",
"u\"_AppEngineUtilities_SessionData_%s\"",
"%",
"(",
"str",
"(",
... | https://github.com/gumroad/gumroad-v1/blob/35be4df01717b47a290c01b28ad5391e81c44a68/appengine_utilities/sessions.py#L300-L323 | |
blackholll/loonflow | 040fb7c5c205db0c6cc0a90d5c40e15dddc5f619 | service/ticket/ticket_base_service.py | python | TicketBaseService.get_ticket_list | (cls, sn: str='', title: str='', username: str='', create_start: str='', create_end: str='',
workflow_ids: str='', state_ids: str='', ticket_ids: str='', category: str='', reverse: int=1,
per_page: int=10, page: int=1, app_name: str='', **kwargs) | return True, dict(ticket_result_restful_list=ticket_result_restful_list,
paginator_info=dict(per_page=per_page, page=page, total=paginator.count)) | 工单列表
:param sn:
:param title:
:param username:
:param create_start: 创建时间起
:param create_end: 创建时间止
:param workflow_ids: 工作流id,str,逗号隔开
:param state_ids: 状态id,str,逗号隔开
:param ticket_ids: 工单id,str,逗号隔开
:param category: 查询类别(创建的,待办的,关联的:包括创建的、处理过的、曾经需... | 工单列表
:param sn:
:param title:
:param username:
:param create_start: 创建时间起
:param create_end: 创建时间止
:param workflow_ids: 工作流id,str,逗号隔开
:param state_ids: 状态id,str,逗号隔开
:param ticket_ids: 工单id,str,逗号隔开
:param category: 查询类别(创建的,待办的,关联的:包括创建的、处理过的、曾经需... | [
"工单列表",
":",
"param",
"sn",
":",
":",
"param",
"title",
":",
":",
"param",
"username",
":",
":",
"param",
"create_start",
":",
"创建时间起",
":",
"param",
"create_end",
":",
"创建时间止",
":",
"param",
"workflow_ids",
":",
"工作流id",
"str",
"逗号隔开",
":",
"param",
"... | def get_ticket_list(cls, sn: str='', title: str='', username: str='', create_start: str='', create_end: str='',
workflow_ids: str='', state_ids: str='', ticket_ids: str='', category: str='', reverse: int=1,
per_page: int=10, page: int=1, app_name: str='', **kwargs):
... | [
"def",
"get_ticket_list",
"(",
"cls",
",",
"sn",
":",
"str",
"=",
"''",
",",
"title",
":",
"str",
"=",
"''",
",",
"username",
":",
"str",
"=",
"''",
",",
"create_start",
":",
"str",
"=",
"''",
",",
"create_end",
":",
"str",
"=",
"''",
",",
"workf... | https://github.com/blackholll/loonflow/blob/040fb7c5c205db0c6cc0a90d5c40e15dddc5f619/service/ticket/ticket_base_service.py#L47-L205 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/whoosh/src/whoosh/codec/whoosh3.py | python | W3TermsReader._keycoder | (self, fieldname, tbytes) | return pack_ushort(fnum) + tbytes | [] | def _keycoder(self, fieldname, tbytes):
assert isinstance(tbytes, bytes_type), "tbytes=%r" % tbytes
fnum = self._fieldmap.get(fieldname, 65535)
return pack_ushort(fnum) + tbytes | [
"def",
"_keycoder",
"(",
"self",
",",
"fieldname",
",",
"tbytes",
")",
":",
"assert",
"isinstance",
"(",
"tbytes",
",",
"bytes_type",
")",
",",
"\"tbytes=%r\"",
"%",
"tbytes",
"fnum",
"=",
"self",
".",
"_fieldmap",
".",
"get",
"(",
"fieldname",
",",
"655... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/whoosh/src/whoosh/codec/whoosh3.py#L507-L510 | |||
CamDavidsonPilon/lifelines | 9be26a9a8720e8536e9828e954bb91d559a3016f | lifelines/fitters/coxph_fitter.py | python | SemiParametricPHFitter.score | (self, df: pd.DataFrame, scoring_method: str = "log_likelihood") | Score the data in df on the fitted model. With default scoring method, returns
the *average partial log-likelihood*.
Parameters
----------
df: DataFrame
the dataframe with duration col, event col, etc.
scoring_method: str
one of {'log_likelihood', 'concor... | Score the data in df on the fitted model. With default scoring method, returns
the *average partial log-likelihood*. | [
"Score",
"the",
"data",
"in",
"df",
"on",
"the",
"fitted",
"model",
".",
"With",
"default",
"scoring",
"method",
"returns",
"the",
"*",
"average",
"partial",
"log",
"-",
"likelihood",
"*",
"."
] | def score(self, df: pd.DataFrame, scoring_method: str = "log_likelihood") -> float:
"""
Score the data in df on the fitted model. With default scoring method, returns
the *average partial log-likelihood*.
Parameters
----------
df: DataFrame
the dataframe with... | [
"def",
"score",
"(",
"self",
",",
"df",
":",
"pd",
".",
"DataFrame",
",",
"scoring_method",
":",
"str",
"=",
"\"log_likelihood\"",
")",
"->",
"float",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"if",
"self",
".",
"strata",
":",
"df",
"=",
"df",
... | https://github.com/CamDavidsonPilon/lifelines/blob/9be26a9a8720e8536e9828e954bb91d559a3016f/lifelines/fitters/coxph_fitter.py#L2646-L2707 | ||
owid/covid-19-data | 936aeae6cfbdc0163939ed7bd8ecdbb2582c0a92 | scripts/src/cowidev/vax/manual/twitter/base.py | python | TwitterCollectorBase._order_columns | (self, df) | return df | [] | def _order_columns(self, df):
column_metrics = []
column_optional = []
for col in COLUMN_METRICS_ALL:
if col in df.columns:
column_metrics.append(col)
if "media_url" in df:
column_optional.append("media_url")
df = df[["date"] + column_metr... | [
"def",
"_order_columns",
"(",
"self",
",",
"df",
")",
":",
"column_metrics",
"=",
"[",
"]",
"column_optional",
"=",
"[",
"]",
"for",
"col",
"in",
"COLUMN_METRICS_ALL",
":",
"if",
"col",
"in",
"df",
".",
"columns",
":",
"column_metrics",
".",
"append",
"(... | https://github.com/owid/covid-19-data/blob/936aeae6cfbdc0163939ed7bd8ecdbb2582c0a92/scripts/src/cowidev/vax/manual/twitter/base.py#L75-L85 | |||
fritzy/SleekXMPP | cc1d470397de768ffcc41d2ed5ac3118d19f09f5 | sleekxmpp/xmlstream/xmlstream.py | python | XMLStream.get_id | (self) | return "%s%X" % (self._id_prefix, self._id) | Return the current unique stream ID in hexadecimal form. | Return the current unique stream ID in hexadecimal form. | [
"Return",
"the",
"current",
"unique",
"stream",
"ID",
"in",
"hexadecimal",
"form",
"."
] | def get_id(self):
"""Return the current unique stream ID in hexadecimal form."""
return "%s%X" % (self._id_prefix, self._id) | [
"def",
"get_id",
"(",
"self",
")",
":",
"return",
"\"%s%X\"",
"%",
"(",
"self",
".",
"_id_prefix",
",",
"self",
".",
"_id",
")"
] | https://github.com/fritzy/SleekXMPP/blob/cc1d470397de768ffcc41d2ed5ac3118d19f09f5/sleekxmpp/xmlstream/xmlstream.py#L414-L416 | |
thu-coai/ConvLab-2 | ad32b76022fa29cbc2f24cbefbb855b60492985e | convlab2/policy/hdsa/multiwoz/train_predictor.py | python | QqpProcessor.get_labels | (self) | return [str(i) for i in range(44)] | See base class. | See base class. | [
"See",
"base",
"class",
"."
] | def get_labels(self):
"""See base class."""
return [str(i) for i in range(44)] | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"str",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"44",
")",
"]"
] | https://github.com/thu-coai/ConvLab-2/blob/ad32b76022fa29cbc2f24cbefbb855b60492985e/convlab2/policy/hdsa/multiwoz/train_predictor.py#L129-L131 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/site-packages/click/core.py | python | Option.__init__ | (self, param_decls=None, show_default=False,
prompt=False, confirmation_prompt=False,
hide_input=False, is_flag=None, flag_value=None,
multiple=False, count=False, allow_from_autoenv=True,
type=None, help=None, **attrs) | [] | def __init__(self, param_decls=None, show_default=False,
prompt=False, confirmation_prompt=False,
hide_input=False, is_flag=None, flag_value=None,
multiple=False, count=False, allow_from_autoenv=True,
type=None, help=None, **attrs):
default_is_... | [
"def",
"__init__",
"(",
"self",
",",
"param_decls",
"=",
"None",
",",
"show_default",
"=",
"False",
",",
"prompt",
"=",
"False",
",",
"confirmation_prompt",
"=",
"False",
",",
"hide_input",
"=",
"False",
",",
"is_flag",
"=",
"None",
",",
"flag_value",
"=",... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/click/core.py#L1454-L1522 | ||||
webpy/webpy | 62245f7da4aab8f8607c192b98d5ef93873f995b | web/form.py | python | Form.render | (self) | return out | [] | def render(self):
out = ""
out += self.rendernote(self.note)
out += "<table>\n"
for i in self.inputs:
html = (
utils.safeunicode(i.pre)
+ i.render()
+ self.rendernote(i.note)
+ utils.safeunicode(i.post)
... | [
"def",
"render",
"(",
"self",
")",
":",
"out",
"=",
"\"\"",
"out",
"+=",
"self",
".",
"rendernote",
"(",
"self",
".",
"note",
")",
"out",
"+=",
"\"<table>\\n\"",
"for",
"i",
"in",
"self",
".",
"inputs",
":",
"html",
"=",
"(",
"utils",
".",
"safeuni... | https://github.com/webpy/webpy/blob/62245f7da4aab8f8607c192b98d5ef93873f995b/web/form.py#L55-L77 | |||
timy90022/One-Shot-Object-Detection | 26ca16238f2c4f17685ea57b646d58a2d7542fdb | lib/model/faster_rcnn/resnet.py | python | BasicBlock.__init__ | (self, inplanes, planes, stride=1, downsample=None) | [] | def __init__(self, inplanes, planes, stride=1, downsample=None):
super(BasicBlock, self).__init__()
self.conv1 = conv3x3(inplanes, planes, stride)
self.bn1 = nn.BatchNorm2d(planes)
self.relu = nn.ReLU(inplace=True)
self.conv2 = conv3x3(planes, planes)
self.bn2 = nn.BatchNorm2d(planes)
self.d... | [
"def",
"__init__",
"(",
"self",
",",
"inplanes",
",",
"planes",
",",
"stride",
"=",
"1",
",",
"downsample",
"=",
"None",
")",
":",
"super",
"(",
"BasicBlock",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"conv1",
"=",
"conv3x3",
"(",
"... | https://github.com/timy90022/One-Shot-Object-Detection/blob/26ca16238f2c4f17685ea57b646d58a2d7542fdb/lib/model/faster_rcnn/resnet.py#L37-L45 | ||||
justinmeister/The-Stolen-Crown-RPG | 91a9949cc8ed9a2054c3b1ab8efe46678be0fcf4 | data/battlegui.py | python | InfoBox.set_player_damage | (self, player_damage) | Set player damage in state dictionary. | Set player damage in state dictionary. | [
"Set",
"player",
"damage",
"in",
"state",
"dictionary",
"."
] | def set_player_damage(self, player_damage):
"""
Set player damage in state dictionary.
"""
self.player_damage = player_damage
self.state_dict[c.PLAYER_DAMAGED] = self.player_hit() | [
"def",
"set_player_damage",
"(",
"self",
",",
"player_damage",
")",
":",
"self",
".",
"player_damage",
"=",
"player_damage",
"self",
".",
"state_dict",
"[",
"c",
".",
"PLAYER_DAMAGED",
"]",
"=",
"self",
".",
"player_hit",
"(",
")"
] | https://github.com/justinmeister/The-Stolen-Crown-RPG/blob/91a9949cc8ed9a2054c3b1ab8efe46678be0fcf4/data/battlegui.py#L152-L157 | ||
ReactiveX/RxPY | 52e72c2e691f0a8ae0f479cb3a22753e6c4f8242 | rx/scheduler/eventloop/ioloopscheduler.py | python | IOLoopScheduler.__init__ | (self, loop: Any) | Create a new IOLoopScheduler.
Args:
loop: The ioloop to use; typically, you would get this by
tornado import ioloop; ioloop.IOLoop.current() | Create a new IOLoopScheduler. | [
"Create",
"a",
"new",
"IOLoopScheduler",
"."
] | def __init__(self, loop: Any) -> None:
"""Create a new IOLoopScheduler.
Args:
loop: The ioloop to use; typically, you would get this by
tornado import ioloop; ioloop.IOLoop.current()
"""
super().__init__()
self._loop = loop | [
"def",
"__init__",
"(",
"self",
",",
"loop",
":",
"Any",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_loop",
"=",
"loop"
] | https://github.com/ReactiveX/RxPY/blob/52e72c2e691f0a8ae0f479cb3a22753e6c4f8242/rx/scheduler/eventloop/ioloopscheduler.py#L21-L30 | ||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/combinat/crystals/induced_structure.py | python | InducedFromCrystal._element_constructor_ | (self, x) | Construct an element of ``self``.
EXAMPLES::
sage: C = crystals.Tableaux(['A',3], shape=[2,1])
sage: def psi(x):
....: ret = RSK_inverse(x.to_tableau(), Tableau([[1,1],[2]]))
....: return (tuple(ret[0]), tuple(ret[1]))
sage: psi_inv = lambda ... | Construct an element of ``self``. | [
"Construct",
"an",
"element",
"of",
"self",
"."
] | def _element_constructor_(self, x):
"""
Construct an element of ``self``.
EXAMPLES::
sage: C = crystals.Tableaux(['A',3], shape=[2,1])
sage: def psi(x):
....: ret = RSK_inverse(x.to_tableau(), Tableau([[1,1],[2]]))
....: return (tuple(ret... | [
"def",
"_element_constructor_",
"(",
"self",
",",
"x",
")",
":",
"if",
"x",
"in",
"self",
".",
"_crystal",
":",
"return",
"self",
".",
"element_class",
"(",
"self",
",",
"self",
".",
"_phi",
"(",
"self",
".",
"_crystal",
"(",
"x",
")",
")",
")",
"t... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/combinat/crystals/induced_structure.py#L491-L514 | ||
lk-geimfari/mimesis | 36653b49f28719c0a2aa20fef6c6df3911811b32 | mimesis/random.py | python | Random.uniform | (self, a: float, b: float, precision: int = 15) | return round(a + (b - a) * self.random(), precision) | Get a random number in the range [a, b) or [a, b] depending on rounding.
:param a: Minimum value.
:param b: Maximum value.
:param precision: Round a number to a given
precision in decimal digits, default is 15. | Get a random number in the range [a, b) or [a, b] depending on rounding. | [
"Get",
"a",
"random",
"number",
"in",
"the",
"range",
"[",
"a",
"b",
")",
"or",
"[",
"a",
"b",
"]",
"depending",
"on",
"rounding",
"."
] | def uniform(self, a: float, b: float, precision: int = 15) -> float:
"""Get a random number in the range [a, b) or [a, b] depending on rounding.
:param a: Minimum value.
:param b: Maximum value.
:param precision: Round a number to a given
precision in decimal digits, default... | [
"def",
"uniform",
"(",
"self",
",",
"a",
":",
"float",
",",
"b",
":",
"float",
",",
"precision",
":",
"int",
"=",
"15",
")",
"->",
"float",
":",
"return",
"round",
"(",
"a",
"+",
"(",
"b",
"-",
"a",
")",
"*",
"self",
".",
"random",
"(",
")",
... | https://github.com/lk-geimfari/mimesis/blob/36653b49f28719c0a2aa20fef6c6df3911811b32/mimesis/random.py#L91-L99 | |
nucleic/enaml | 65c2a2a2d765e88f2e1103046680571894bb41ed | enaml/qt/docking/q_dock_item.py | python | QDockItem.setPinned | (self, pinned, quiet=False) | Set whether or not the dock item is pinned.
Parameters
----------
pinned : bool
True if the dock item should be pinned, False otherwise.
quiet : bool, optional
True if the state should be set without emitted the toggled
signal. The default is False. | Set whether or not the dock item is pinned. | [
"Set",
"whether",
"or",
"not",
"the",
"dock",
"item",
"is",
"pinned",
"."
] | def setPinned(self, pinned, quiet=False):
""" Set whether or not the dock item is pinned.
Parameters
----------
pinned : bool
True if the dock item should be pinned, False otherwise.
quiet : bool, optional
True if the state should be set without emitted ... | [
"def",
"setPinned",
"(",
"self",
",",
"pinned",
",",
"quiet",
"=",
"False",
")",
":",
"self",
".",
"titleBarWidget",
"(",
")",
".",
"setPinned",
"(",
"pinned",
",",
"quiet",
")"
] | https://github.com/nucleic/enaml/blob/65c2a2a2d765e88f2e1103046680571894bb41ed/enaml/qt/docking/q_dock_item.py#L507-L520 | ||
NeuralEnsemble/python-neo | 34d4db8fb0dc950dbbc6defd7fb75e99ea877286 | neo/io/brainwaresrcio.py | python | BrainwareSrcIO._opensrc | (self) | Open the file if it isn't already open. | Open the file if it isn't already open. | [
"Open",
"the",
"file",
"if",
"it",
"isn",
"t",
"already",
"open",
"."
] | def _opensrc(self):
"""
Open the file if it isn't already open.
"""
# if the file isn't already open, open it and clear the Blocks
if not self._fsrc or self._fsrc.closed:
self._fsrc = open(self._filename, 'rb')
# figure out the filename of the current fil... | [
"def",
"_opensrc",
"(",
"self",
")",
":",
"# if the file isn't already open, open it and clear the Blocks",
"if",
"not",
"self",
".",
"_fsrc",
"or",
"self",
".",
"_fsrc",
".",
"closed",
":",
"self",
".",
"_fsrc",
"=",
"open",
"(",
"self",
".",
"_filename",
","... | https://github.com/NeuralEnsemble/python-neo/blob/34d4db8fb0dc950dbbc6defd7fb75e99ea877286/neo/io/brainwaresrcio.py#L191-L200 | ||
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/SimpleXMLRPCServer.py | python | SimpleXMLRPCServer.__init__ | (self, addr, requestHandler=SimpleXMLRPCRequestHandler,
logRequests=True, allow_none=False, encoding=None, bind_and_activate=True) | [] | def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
logRequests=True, allow_none=False, encoding=None, bind_and_activate=True):
self.logRequests = logRequests
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
SocketServer.TCPServer.__init__(self, addr,... | [
"def",
"__init__",
"(",
"self",
",",
"addr",
",",
"requestHandler",
"=",
"SimpleXMLRPCRequestHandler",
",",
"logRequests",
"=",
"True",
",",
"allow_none",
"=",
"False",
",",
"encoding",
"=",
"None",
",",
"bind_and_activate",
"=",
"True",
")",
":",
"self",
".... | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/SimpleXMLRPCServer.py#L588-L601 | ||||
replit-archive/empythoned | 977ec10ced29a3541a4973dc2b59910805695752 | cpython/Lib/mailbox.py | python | MH.lock | (self) | Lock the mailbox. | Lock the mailbox. | [
"Lock",
"the",
"mailbox",
"."
] | def lock(self):
"""Lock the mailbox."""
if not self._locked:
self._file = open(os.path.join(self._path, '.mh_sequences'), 'rb+')
_lock_file(self._file)
self._locked = True | [
"def",
"lock",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_locked",
":",
"self",
".",
"_file",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_path",
",",
"'.mh_sequences'",
")",
",",
"'rb+'",
")",
"_lock_file",
"(",
... | https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/mailbox.py#L1018-L1023 | ||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/django/contrib/admin/checks.py | python | InlineModelAdminChecks._check_relation | (self, obj, parent_model) | [] | def _check_relation(self, obj, parent_model):
try:
_get_foreign_key(parent_model, obj.model, fk_name=obj.fk_name)
except ValueError as e:
return [checks.Error(e.args[0], obj=obj.__class__, id='admin.E202')]
else:
return [] | [
"def",
"_check_relation",
"(",
"self",
",",
"obj",
",",
"parent_model",
")",
":",
"try",
":",
"_get_foreign_key",
"(",
"parent_model",
",",
"obj",
".",
"model",
",",
"fk_name",
"=",
"obj",
".",
"fk_name",
")",
"except",
"ValueError",
"as",
"e",
":",
"ret... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/django/contrib/admin/checks.py#L899-L905 | ||||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/vlc/media_player.py | python | VlcDevice.media_position | (self) | return self._media_position | Position of current playing media in seconds. | Position of current playing media in seconds. | [
"Position",
"of",
"current",
"playing",
"media",
"in",
"seconds",
"."
] | def media_position(self):
"""Position of current playing media in seconds."""
return self._media_position | [
"def",
"media_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"_media_position"
] | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/vlc/media_player.py#L131-L133 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/matrices/dense.py | python | DenseMatrix._eval_adjoint | (self) | return self.T.C | [] | def _eval_adjoint(self):
return self.T.C | [
"def",
"_eval_adjoint",
"(",
"self",
")",
":",
"return",
"self",
".",
"T",
".",
"C"
] | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/matrices/dense.py#L251-L252 | |||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/combinat/words/finite_word.py | python | FiniteWord_class.to_integer_word | (self) | return Word(self.to_integer_list()) | r"""
Return a word over the alphabet ``[0,1,...,self.length()-1]``
whose letters are in the same relative order as the letters
of ``self`` in the parent.
EXAMPLES::
sage: from itertools import count
sage: w = Word('abbabaab')
sage: w.to_integer_word(... | r"""
Return a word over the alphabet ``[0,1,...,self.length()-1]``
whose letters are in the same relative order as the letters
of ``self`` in the parent. | [
"r",
"Return",
"a",
"word",
"over",
"the",
"alphabet",
"[",
"0",
"1",
"...",
"self",
".",
"length",
"()",
"-",
"1",
"]",
"whose",
"letters",
"are",
"in",
"the",
"same",
"relative",
"order",
"as",
"the",
"letters",
"of",
"self",
"in",
"the",
"parent",... | def to_integer_word(self):
r"""
Return a word over the alphabet ``[0,1,...,self.length()-1]``
whose letters are in the same relative order as the letters
of ``self`` in the parent.
EXAMPLES::
sage: from itertools import count
sage: w = Word('abbabaab')
... | [
"def",
"to_integer_word",
"(",
"self",
")",
":",
"from",
"sage",
".",
"combinat",
".",
"words",
".",
"word",
"import",
"Word",
"return",
"Word",
"(",
"self",
".",
"to_integer_list",
"(",
")",
")"
] | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/combinat/words/finite_word.py#L824-L845 | |
wemake-services/wemake-python-styleguide | 11767452c7d9766dbf9aa49c75b231db9aaef937 | wemake_python_styleguide/logic/tree/imports.py | python | is_nested_typing_import | (parent: ast.AST) | return checked_condition in constants.ALLOWED_NESTED_IMPORTS_CONDITIONS | Tells whether ``if`` checks for ``TYPE_CHECKING``. | Tells whether ``if`` checks for ``TYPE_CHECKING``. | [
"Tells",
"whether",
"if",
"checks",
"for",
"TYPE_CHECKING",
"."
] | def is_nested_typing_import(parent: ast.AST) -> bool:
"""Tells whether ``if`` checks for ``TYPE_CHECKING``."""
checked_condition = None
if isinstance(parent, ast.If):
if isinstance(parent.test, ast.Name):
checked_condition = parent.test.id
elif isinstance(parent.test, ast.Attribu... | [
"def",
"is_nested_typing_import",
"(",
"parent",
":",
"ast",
".",
"AST",
")",
"->",
"bool",
":",
"checked_condition",
"=",
"None",
"if",
"isinstance",
"(",
"parent",
",",
"ast",
".",
"If",
")",
":",
"if",
"isinstance",
"(",
"parent",
".",
"test",
",",
... | https://github.com/wemake-services/wemake-python-styleguide/blob/11767452c7d9766dbf9aa49c75b231db9aaef937/wemake_python_styleguide/logic/tree/imports.py#L51-L59 | |
DigitalSlideArchive/HistomicsTK | db2ceb4831bec0efa557cf5b18078ae790253de5 | histomicstk/annotations_and_masks/annotation_and_mask_utils.py | python | _maybe_crop_polygon | (vertices, bounds_polygon) | return all_vertices | Crop bounds to desired area using shapely polygons. | Crop bounds to desired area using shapely polygons. | [
"Crop",
"bounds",
"to",
"desired",
"area",
"using",
"shapely",
"polygons",
"."
] | def _maybe_crop_polygon(vertices, bounds_polygon):
"""Crop bounds to desired area using shapely polygons."""
all_vertices = []
# First, we get the polygon or polygons which result from
# intersection. Keep in mind that a particular annotation may
# "ecit then enter" the cropping ROI, so it may be s... | [
"def",
"_maybe_crop_polygon",
"(",
"vertices",
",",
"bounds_polygon",
")",
":",
"all_vertices",
"=",
"[",
"]",
"# First, we get the polygon or polygons which result from",
"# intersection. Keep in mind that a particular annotation may",
"# \"ecit then enter\" the cropping ROI, so it may ... | https://github.com/DigitalSlideArchive/HistomicsTK/blob/db2ceb4831bec0efa557cf5b18078ae790253de5/histomicstk/annotations_and_masks/annotation_and_mask_utils.py#L315-L352 | |
caiiiac/Machine-Learning-with-Python | 1a26c4467da41ca4ebc3d5bd789ea942ef79422f | MachineLearning/venv/lib/python3.5/site-packages/pip/_vendor/requests/sessions.py | python | Session.post | (self, url, data=None, json=None, **kwargs) | return self.request('POST', url, data=data, json=json, **kwargs) | Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
:param json: (optional) json to send in the body of the :class:`Request`.
... | Sends a POST request. Returns :class:`Response` object. | [
"Sends",
"a",
"POST",
"request",
".",
"Returns",
":",
"class",
":",
"Response",
"object",
"."
] | def post(self, url, data=None, json=None, **kwargs):
"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
:param json: (... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'POST'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",... | https://github.com/caiiiac/Machine-Learning-with-Python/blob/1a26c4467da41ca4ebc3d5bd789ea942ef79422f/MachineLearning/venv/lib/python3.5/site-packages/pip/_vendor/requests/sessions.py#L512-L522 | |
Scarygami/mirror-api | 497783f6d721b24b793c1fcd8c71d0c7d11956d4 | lib/cloudstorage/cloudstorage_api.py | python | _Bucket.__init__ | (self, api, path, options) | Initialize.
Args:
api: storage_api instance.
path: bucket path of form '/bucket'.
options: a dict of listbucket options. Please see listbucket doc. | Initialize. | [
"Initialize",
"."
] | def __init__(self, api, path, options):
"""Initialize.
Args:
api: storage_api instance.
path: bucket path of form '/bucket'.
options: a dict of listbucket options. Please see listbucket doc.
"""
self._init(api, path, options) | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"path",
",",
"options",
")",
":",
"self",
".",
"_init",
"(",
"api",
",",
"path",
",",
"options",
")"
] | https://github.com/Scarygami/mirror-api/blob/497783f6d721b24b793c1fcd8c71d0c7d11956d4/lib/cloudstorage/cloudstorage_api.py#L279-L287 | ||
pypa/pip | 7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4 | src/pip/_vendor/html5lib/serializer.py | python | serialize | (input, tree="etree", encoding=None, **serializer_opts) | return s.render(walker(input), encoding) | Serializes the input token stream using the specified treewalker
:arg input: the token stream to serialize
:arg tree: the treewalker to use
:arg encoding: the encoding to use
:arg serializer_opts: any options to pass to the
:py:class:`html5lib.serializer.HTMLSerializer` that gets created
... | Serializes the input token stream using the specified treewalker | [
"Serializes",
"the",
"input",
"token",
"stream",
"using",
"the",
"specified",
"treewalker"
] | def serialize(input, tree="etree", encoding=None, **serializer_opts):
"""Serializes the input token stream using the specified treewalker
:arg input: the token stream to serialize
:arg tree: the treewalker to use
:arg encoding: the encoding to use
:arg serializer_opts: any options to pass to the... | [
"def",
"serialize",
"(",
"input",
",",
"tree",
"=",
"\"etree\"",
",",
"encoding",
"=",
"None",
",",
"*",
"*",
"serializer_opts",
")",
":",
"# XXX: Should we cache this?",
"walker",
"=",
"treewalkers",
".",
"getTreeWalker",
"(",
"tree",
")",
"s",
"=",
"HTMLSe... | https://github.com/pypa/pip/blob/7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4/src/pip/_vendor/html5lib/serializer.py#L75-L101 | |
google/textfsm | 65ce6c13f0b0c798a6505366cf17dd54bf285d90 | textfsm/parser.py | python | TextFSM._ClearRecord | (self) | Remove non 'Filldown' record entries. | Remove non 'Filldown' record entries. | [
"Remove",
"non",
"Filldown",
"record",
"entries",
"."
] | def _ClearRecord(self):
"""Remove non 'Filldown' record entries."""
_ = [value.ClearVar() for value in self.values] | [
"def",
"_ClearRecord",
"(",
"self",
")",
":",
"_",
"=",
"[",
"value",
".",
"ClearVar",
"(",
")",
"for",
"value",
"in",
"self",
".",
"values",
"]"
] | https://github.com/google/textfsm/blob/65ce6c13f0b0c798a6505366cf17dd54bf285d90/textfsm/parser.py#L1036-L1038 | ||
genforce/idinvert | 138266724c7c8709fa4b2565c1f8e648ae5c6641 | dnnlib/tflib/network.py | python | Network.__setstate__ | (self, state: dict) | Pickle import. | Pickle import. | [
"Pickle",
"import",
"."
] | def __setstate__(self, state: dict) -> None:
"""Pickle import."""
# pylint: disable=attribute-defined-outside-init
tfutil.assert_tf_initialized()
self._init_fields()
# Execute custom import handlers.
for handler in _import_handlers:
state = handler(state)
... | [
"def",
"__setstate__",
"(",
"self",
",",
"state",
":",
"dict",
")",
"->",
"None",
":",
"# pylint: disable=attribute-defined-outside-init",
"tfutil",
".",
"assert_tf_initialized",
"(",
")",
"self",
".",
"_init_fields",
"(",
")",
"# Execute custom import handlers.",
"fo... | https://github.com/genforce/idinvert/blob/138266724c7c8709fa4b2565c1f8e648ae5c6641/dnnlib/tflib/network.py#L268-L300 | ||
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/SQLAlchemy-1.3.17/lib/sqlalchemy/event/api.py | python | contains | (target, identifier, fn) | return _event_key(target, identifier, fn).contains() | Return True if the given target/ident/fn is set up to listen.
.. versionadded:: 0.9.0 | Return True if the given target/ident/fn is set up to listen. | [
"Return",
"True",
"if",
"the",
"given",
"target",
"/",
"ident",
"/",
"fn",
"is",
"set",
"up",
"to",
"listen",
"."
] | def contains(target, identifier, fn):
"""Return True if the given target/ident/fn is set up to listen.
.. versionadded:: 0.9.0
"""
return _event_key(target, identifier, fn).contains() | [
"def",
"contains",
"(",
"target",
",",
"identifier",
",",
"fn",
")",
":",
"return",
"_event_key",
"(",
"target",
",",
"identifier",
",",
"fn",
")",
".",
"contains",
"(",
")"
] | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/SQLAlchemy-1.3.17/lib/sqlalchemy/event/api.py#L206-L213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.