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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
datacenter/acitoolkit | 629b84887dd0f0183b81efc8adb16817f985541a | acitoolkit/acibaseobject.py | python | BaseACIObject._check_attachment | (self, item, status) | return check in self._attachments | Internal function to return whether an attachment exists to the
specified item with the given status.
:returns: True or False, True indicates the attachment exists. | Internal function to return whether an attachment exists to the
specified item with the given status. | [
"Internal",
"function",
"to",
"return",
"whether",
"an",
"attachment",
"exists",
"to",
"the",
"specified",
"item",
"with",
"the",
"given",
"status",
"."
] | def _check_attachment(self, item, status):
"""
Internal function to return whether an attachment exists to the
specified item with the given status.
:returns: True or False, True indicates the attachment exists.
"""
check = BaseRelation(item, status)
return check... | [
"def",
"_check_attachment",
"(",
"self",
",",
"item",
",",
"status",
")",
":",
"check",
"=",
"BaseRelation",
"(",
"item",
",",
"status",
")",
"return",
"check",
"in",
"self",
".",
"_attachments"
] | https://github.com/datacenter/acitoolkit/blob/629b84887dd0f0183b81efc8adb16817f985541a/acitoolkit/acibaseobject.py#L661-L669 | |
log2timeline/dfvfs | 4ca7bf06b15cdc000297a7122a065f0ca71de544 | dfvfs/helpers/file_system_searcher.py | python | FindSpec._SplitPath | (self, path, path_separator) | return list(filter(None, path.split(path_separator))) | Splits the path into path segments.
Args:
path (str): path.
path_separator (str): path separator.
Returns:
list[str]: path segments without the root path segment, which is
an empty string. | Splits the path into path segments. | [
"Splits",
"the",
"path",
"into",
"path",
"segments",
"."
] | def _SplitPath(self, path, path_separator):
"""Splits the path into path segments.
Args:
path (str): path.
path_separator (str): path separator.
Returns:
list[str]: path segments without the root path segment, which is
an empty string.
"""
# Split the path with the path... | [
"def",
"_SplitPath",
"(",
"self",
",",
"path",
",",
"path_separator",
")",
":",
"# Split the path with the path separator and remove empty path segments.",
"return",
"list",
"(",
"filter",
"(",
"None",
",",
"path",
".",
"split",
"(",
"path_separator",
")",
")",
")"
... | https://github.com/log2timeline/dfvfs/blob/4ca7bf06b15cdc000297a7122a065f0ca71de544/dfvfs/helpers/file_system_searcher.py#L318-L330 | |
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/email/_header_value_parser.py | python | WhiteSpaceTerminal.startswith_fws | (self) | return True | [] | def startswith_fws(self):
return True | [
"def",
"startswith_fws",
"(",
"self",
")",
":",
"return",
"True"
] | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/email/_header_value_parser.py#L919-L920 | |||
achael/eht-imaging | bbd3aeb06bef52bf89fa1c06de71e5509a5b0015 | ehtim/io/load.py | python | load_movie_dat | (basename, nframes, startframe=0, framedur_sec=1, psize=-1,
interp=ehc.INTERP_DEFAULT, bounds_error=ehc.BOUNDS_ERROR,
ra=ehc.RA_DEFAULT, dec=ehc.DEC_DEFAULT, rf=ehc.RF_DEFAULT,
pulse=ehc.PULSE_DEFAULT) | return(ehtim.movie.Movie(sim, times, psize, ra, dec, rf,
interp=interp, bounds_error=bounds_error)) | Read in a movie from dat files and create a Movie object.
Args:
basename (str): The base name of individual movie frames.
Files should have names basename + 000001, etc.
nframes (int): The total number of frames
startframe (int): The index of the ... | Read in a movie from dat files and create a Movie object. | [
"Read",
"in",
"a",
"movie",
"from",
"dat",
"files",
"and",
"create",
"a",
"Movie",
"object",
"."
] | def load_movie_dat(basename, nframes, startframe=0, framedur_sec=1, psize=-1,
interp=ehc.INTERP_DEFAULT, bounds_error=ehc.BOUNDS_ERROR,
ra=ehc.RA_DEFAULT, dec=ehc.DEC_DEFAULT, rf=ehc.RF_DEFAULT,
pulse=ehc.PULSE_DEFAULT):
"""Read in a movie from dat files and ... | [
"def",
"load_movie_dat",
"(",
"basename",
",",
"nframes",
",",
"startframe",
"=",
"0",
",",
"framedur_sec",
"=",
"1",
",",
"psize",
"=",
"-",
"1",
",",
"interp",
"=",
"ehc",
".",
"INTERP_DEFAULT",
",",
"bounds_error",
"=",
"ehc",
".",
"BOUNDS_ERROR",
","... | https://github.com/achael/eht-imaging/blob/bbd3aeb06bef52bf89fa1c06de71e5509a5b0015/ehtim/io/load.py#L729-L780 | |
pyside/pyside2-setup | d526f801ced4687d5413907a93dedcd782ef72fa | build_scripts/qp5_tool.py | python | expand_reference | (cache_dict, value) | return value | Expand references to other keys in config files $(name) by value. | Expand references to other keys in config files $(name) by value. | [
"Expand",
"references",
"to",
"other",
"keys",
"in",
"config",
"files",
"$",
"(",
"name",
")",
"by",
"value",
"."
] | def expand_reference(cache_dict, value):
"""Expand references to other keys in config files $(name) by value."""
pattern = re.compile(r"\$\([^)]+\)")
while True:
match = pattern.match(value)
if not match:
break
key = match.group(0)[2:-1]
value = value[:match.start... | [
"def",
"expand_reference",
"(",
"cache_dict",
",",
"value",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r\"\\$\\([^)]+\\)\"",
")",
"while",
"True",
":",
"match",
"=",
"pattern",
".",
"match",
"(",
"value",
")",
"if",
"not",
"match",
":",
"break... | https://github.com/pyside/pyside2-setup/blob/d526f801ced4687d5413907a93dedcd782ef72fa/build_scripts/qp5_tool.py#L167-L176 | |
joelgrus/data-science-from-scratch | d5d0f117f41b3ccab3b07f1ee1fa21cfcf69afa1 | first-edition/code/simple_linear_regression.py | python | total_sum_of_squares | (y) | return sum(v ** 2 for v in de_mean(y)) | the total squared variation of y_i's from their mean | the total squared variation of y_i's from their mean | [
"the",
"total",
"squared",
"variation",
"of",
"y_i",
"s",
"from",
"their",
"mean"
] | def total_sum_of_squares(y):
"""the total squared variation of y_i's from their mean"""
return sum(v ** 2 for v in de_mean(y)) | [
"def",
"total_sum_of_squares",
"(",
"y",
")",
":",
"return",
"sum",
"(",
"v",
"**",
"2",
"for",
"v",
"in",
"de_mean",
"(",
"y",
")",
")"
] | https://github.com/joelgrus/data-science-from-scratch/blob/d5d0f117f41b3ccab3b07f1ee1fa21cfcf69afa1/first-edition/code/simple_linear_regression.py#L25-L27 | |
pymedusa/Medusa | 1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38 | ext3/bs4/element.py | python | PageElement.setup | (self, parent=None, previous_element=None, next_element=None,
previous_sibling=None, next_sibling=None) | Sets up the initial relations between this element and
other elements.
:param parent: The parent of this element.
:param previous_element: The element parsed immediately before
this one.
:param next_element: The element parsed immediately before
this on... | Sets up the initial relations between this element and
other elements. | [
"Sets",
"up",
"the",
"initial",
"relations",
"between",
"this",
"element",
"and",
"other",
"elements",
"."
] | def setup(self, parent=None, previous_element=None, next_element=None,
previous_sibling=None, next_sibling=None):
"""Sets up the initial relations between this element and
other elements.
:param parent: The parent of this element.
:param previous_element: The element pars... | [
"def",
"setup",
"(",
"self",
",",
"parent",
"=",
"None",
",",
"previous_element",
"=",
"None",
",",
"next_element",
"=",
"None",
",",
"previous_sibling",
"=",
"None",
",",
"next_sibling",
"=",
"None",
")",
":",
"self",
".",
"parent",
"=",
"parent",
"self... | https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext3/bs4/element.py#L158-L197 | ||
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/distutils/ccompiler.py | python | CCompiler._find_macro | (self, name) | return None | [] | def _find_macro(self, name):
i = 0
for defn in self.macros:
if defn[0] == name:
return i
i += 1
return None | [
"def",
"_find_macro",
"(",
"self",
",",
"name",
")",
":",
"i",
"=",
"0",
"for",
"defn",
"in",
"self",
".",
"macros",
":",
"if",
"defn",
"[",
"0",
"]",
"==",
"name",
":",
"return",
"i",
"i",
"+=",
"1",
"return",
"None"
] | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/distutils/ccompiler.py#L159-L165 | |||
MartinThoma/algorithms | 6199cfa3446e1056c7b4d75ca6e306e9e56fd95b | ML/gtsdb/analyze_model.py | python | load_data | () | return X_train, X_val, y_train, y_val | Load data. | Load data. | [
"Load",
"data",
"."
] | def load_data():
"""Load data."""
data = gtsdb.load_data()
X_train = data['x_train']
y_train = data['y_train']
X_val = None
y_val = None
# X_train, X_val, y_train, y_val = train_test_split(X_train, y_train,
# test_size=0.10,
# ... | [
"def",
"load_data",
"(",
")",
":",
"data",
"=",
"gtsdb",
".",
"load_data",
"(",
")",
"X_train",
"=",
"data",
"[",
"'x_train'",
"]",
"y_train",
"=",
"data",
"[",
"'y_train'",
"]",
"X_val",
"=",
"None",
"y_val",
"=",
"None",
"# X_train, X_val, y_train, y_val... | https://github.com/MartinThoma/algorithms/blob/6199cfa3446e1056c7b4d75ca6e306e9e56fd95b/ML/gtsdb/analyze_model.py#L47-L63 | |
mesalock-linux/mesapy | ed546d59a21b36feb93e2309d5c6b75aa0ad95c9 | pypy/objspace/std/unicodeobject.py | python | W_UnicodeObject.__repr__ | (self) | return "%s(%r)" % (self.__class__.__name__, self._value) | representation for debugging purposes | representation for debugging purposes | [
"representation",
"for",
"debugging",
"purposes"
] | def __repr__(self):
"""representation for debugging purposes"""
return "%s(%r)" % (self.__class__.__name__, self._value) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"\"%s(%r)\"",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"_value",
")"
] | https://github.com/mesalock-linux/mesapy/blob/ed546d59a21b36feb93e2309d5c6b75aa0ad95c9/pypy/objspace/std/unicodeobject.py#L39-L41 | |
Samsung/cotopaxi | d19178b1235017257fec20d0a41edc918de55574 | cotopaxi/protocol_fuzzer.py | python | FuzzingCase.test_payload | (self, test_params, test_timeouts, alive_before=True) | return True | Send payload for fuzzing.
test_timeouts list is extended if applicable. | Send payload for fuzzing. | [
"Send",
"payload",
"for",
"fuzzing",
"."
] | def test_payload(self, test_params, test_timeouts, alive_before=True):
"""Send payload for fuzzing.
test_timeouts list is extended if applicable.
"""
if not alive_before:
alive_before = service_ping(test_params)
if not alive_before:
print(
... | [
"def",
"test_payload",
"(",
"self",
",",
"test_params",
",",
"test_timeouts",
",",
"alive_before",
"=",
"True",
")",
":",
"if",
"not",
"alive_before",
":",
"alive_before",
"=",
"service_ping",
"(",
"test_params",
")",
"if",
"not",
"alive_before",
":",
"print",... | https://github.com/Samsung/cotopaxi/blob/d19178b1235017257fec20d0a41edc918de55574/cotopaxi/protocol_fuzzer.py#L70-L156 | |
CouchPotato/CouchPotatoServer | 7260c12f72447ddb6f062367c6dfbda03ecd4e9c | libs/subliminal/subtitles.py | python | Subtitle.exists | (self) | return False | Whether the subtitle exists or not | Whether the subtitle exists or not | [
"Whether",
"the",
"subtitle",
"exists",
"or",
"not"
] | def exists(self):
"""Whether the subtitle exists or not"""
if self.path:
return os.path.exists(self.path)
return False | [
"def",
"exists",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
"return",
"False"
] | https://github.com/CouchPotato/CouchPotatoServer/blob/7260c12f72447ddb6f062367c6dfbda03ecd4e9c/libs/subliminal/subtitles.py#L44-L48 | |
lovelylain/pyctp | fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d | example/ctp/stock/__init__.py | python | MdApi.OnRspError | (self, pRspInfo, nRequestID, bIsLast) | 错误应答 | 错误应答 | [
"错误应答"
] | def OnRspError(self, pRspInfo, nRequestID, bIsLast):
"""错误应答""" | [
"def",
"OnRspError",
"(",
"self",
",",
"pRspInfo",
",",
"nRequestID",
",",
"bIsLast",
")",
":"
] | https://github.com/lovelylain/pyctp/blob/fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d/example/ctp/stock/__init__.py#L98-L99 | ||
PyCQA/pylint | 3fc855f9d0fa8e6410be5a23cf954ffd5471b4eb | pylint/extensions/typing.py | python | TypingChecker._check_for_typing_alias | (
self,
node: Union[nodes.Name, nodes.Attribute],
) | Check if typing alias is deprecated or could be replaced.
Requires
- Python 3.9
- OR: Python 3.7+ with postponed evaluation in
a type annotation context
For Python 3.7+: Only emit message if change doesn't create
any name collisions, only ever used in a type a... | Check if typing alias is deprecated or could be replaced. | [
"Check",
"if",
"typing",
"alias",
"is",
"deprecated",
"or",
"could",
"be",
"replaced",
"."
] | def _check_for_typing_alias(
self,
node: Union[nodes.Name, nodes.Attribute],
) -> None:
"""Check if typing alias is deprecated or could be replaced.
Requires
- Python 3.9
- OR: Python 3.7+ with postponed evaluation in
a type annotation context
... | [
"def",
"_check_for_typing_alias",
"(",
"self",
",",
"node",
":",
"Union",
"[",
"nodes",
".",
"Name",
",",
"nodes",
".",
"Attribute",
"]",
",",
")",
"->",
"None",
":",
"inferred",
"=",
"safe_infer",
"(",
"node",
")",
"if",
"not",
"isinstance",
"(",
"inf... | https://github.com/PyCQA/pylint/blob/3fc855f9d0fa8e6410be5a23cf954ffd5471b4eb/pylint/extensions/typing.py#L212-L256 | ||
kubernetes-client/python | 47b9da9de2d02b2b7a34fbe05afb44afd130d73a | kubernetes/client/models/v1alpha1_cluster_role.py | python | V1alpha1ClusterRole.__eq__ | (self, other) | return self.to_dict() == other.to_dict() | Returns true if both objects are equal | Returns true if both objects are equal | [
"Returns",
"true",
"if",
"both",
"objects",
"are",
"equal"
] | def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V1alpha1ClusterRole):
return False
return self.to_dict() == other.to_dict() | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"V1alpha1ClusterRole",
")",
":",
"return",
"False",
"return",
"self",
".",
"to_dict",
"(",
")",
"==",
"other",
".",
"to_dict",
"(",
")"
] | https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1alpha1_cluster_role.py#L218-L223 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/os.py | python | execl | (file, *args) | execl(file, *args)
Execute the executable file with argument list args, replacing the
current process. | execl(file, *args) | [
"execl",
"(",
"file",
"*",
"args",
")"
] | def execl(file, *args):
"""execl(file, *args)
Execute the executable file with argument list args, replacing the
current process. """
execv(file, args) | [
"def",
"execl",
"(",
"file",
",",
"*",
"args",
")",
":",
"execv",
"(",
"file",
",",
"args",
")"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/os.py#L309-L314 | ||
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/stat.py | python | S_ISPORT | (mode) | return False | Return True if mode is from an event port. | Return True if mode is from an event port. | [
"Return",
"True",
"if",
"mode",
"is",
"from",
"an",
"event",
"port",
"."
] | def S_ISPORT(mode):
"""Return True if mode is from an event port."""
return False | [
"def",
"S_ISPORT",
"(",
"mode",
")",
":",
"return",
"False"
] | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/stat.py#L82-L84 | |
P1sec/pycrate | d12bbccf1df8c9c7891a26967a9d2635610ec5b8 | pycrate_asn1c/tokenizer.py | python | scan_module_opt | (Tok) | return tag, ext | extract module options from given tokens | extract module options from given tokens | [
"extract",
"module",
"options",
"from",
"given",
"tokens"
] | def scan_module_opt(Tok):
"""extract module options from given tokens
"""
# scan TagDefault and ExtensionDefault
# TODO: scan EncodingReferenceDefault first
tag, ext = None, False
if not Tok.has_next():
return tag, next
tok = Tok.get_next()
if tok in (TOK_AUTO, TOK_TEXP, TOK_TIMP... | [
"def",
"scan_module_opt",
"(",
"Tok",
")",
":",
"# scan TagDefault and ExtensionDefault",
"# TODO: scan EncodingReferenceDefault first",
"tag",
",",
"ext",
"=",
"None",
",",
"False",
"if",
"not",
"Tok",
".",
"has_next",
"(",
")",
":",
"return",
"tag",
",",
"next",... | https://github.com/P1sec/pycrate/blob/d12bbccf1df8c9c7891a26967a9d2635610ec5b8/pycrate_asn1c/tokenizer.py#L575-L597 | |
OpenMDAO/OpenMDAO-Framework | f2e37b7de3edeaaeb2d251b375917adec059db9b | openmdao.lib/src/openmdao/lib/datatypes/domain/plot3d.py | python | _write_plot3d_coords | (zone, stream, planes, logger) | Write coordinates (& blanking) to Plot3D stream. | Write coordinates (& blanking) to Plot3D stream. | [
"Write",
"coordinates",
"(",
"&",
"blanking",
")",
"to",
"Plot3D",
"stream",
"."
] | def _write_plot3d_coords(zone, stream, planes, logger):
""" Write coordinates (& blanking) to Plot3D stream. """
if hasattr(zone.grid_coordinates, 'iblank'):
raise NotImplementedError('blanking not supported yet')
if planes:
raise NotImplementedError('planar format not supported yet')
... | [
"def",
"_write_plot3d_coords",
"(",
"zone",
",",
"stream",
",",
"planes",
",",
"logger",
")",
":",
"if",
"hasattr",
"(",
"zone",
".",
"grid_coordinates",
",",
"'iblank'",
")",
":",
"raise",
"NotImplementedError",
"(",
"'blanking not supported yet'",
")",
"if",
... | https://github.com/OpenMDAO/OpenMDAO-Framework/blob/f2e37b7de3edeaaeb2d251b375917adec059db9b/openmdao.lib/src/openmdao/lib/datatypes/domain/plot3d.py#L698-L734 | ||
IronLanguages/ironpython2 | 51fdedeeda15727717fb8268a805f71b06c0b9f1 | Src/StdLib/Lib/locale.py | python | atof | (string, func=float) | return func(string) | Parses a string as a float according to the locale settings. | Parses a string as a float according to the locale settings. | [
"Parses",
"a",
"string",
"as",
"a",
"float",
"according",
"to",
"the",
"locale",
"settings",
"."
] | def atof(string, func=float):
"Parses a string as a float according to the locale settings."
#First, get rid of the grouping
ts = localeconv()['thousands_sep']
if ts:
string = string.replace(ts, '')
#next, replace the decimal point with a dot
dd = localeconv()['decimal_point']
if dd:... | [
"def",
"atof",
"(",
"string",
",",
"func",
"=",
"float",
")",
":",
"#First, get rid of the grouping",
"ts",
"=",
"localeconv",
"(",
")",
"[",
"'thousands_sep'",
"]",
"if",
"ts",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"ts",
",",
"''",
")",
"... | https://github.com/IronLanguages/ironpython2/blob/51fdedeeda15727717fb8268a805f71b06c0b9f1/Src/StdLib/Lib/locale.py#L307-L318 | |
deanishe/alfred-reddit | 2f7545e682fc1579489947baa679e19b4eb1900e | src/workflow/workflow.py | python | Workflow._create | (self, dirpath) | return dirpath | Create directory `dirpath` if it doesn't exist.
:param dirpath: path to directory
:type dirpath: ``unicode``
:returns: ``dirpath`` argument
:rtype: ``unicode`` | Create directory `dirpath` if it doesn't exist. | [
"Create",
"directory",
"dirpath",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | def _create(self, dirpath):
"""Create directory `dirpath` if it doesn't exist.
:param dirpath: path to directory
:type dirpath: ``unicode``
:returns: ``dirpath`` argument
:rtype: ``unicode``
"""
if not os.path.exists(dirpath):
os.makedirs(dirpath)
... | [
"def",
"_create",
"(",
"self",
",",
"dirpath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dirpath",
")",
":",
"os",
".",
"makedirs",
"(",
"dirpath",
")",
"return",
"dirpath"
] | https://github.com/deanishe/alfred-reddit/blob/2f7545e682fc1579489947baa679e19b4eb1900e/src/workflow/workflow.py#L2769-L2780 | |
mayank93/Twitter-Sentiment-Analysis | f095c6ca6bf69787582b5dabb140fefaf278eb37 | front-end/web2py/gluon/contrib/pymysql/connections.py | python | Connection.literal | (self, obj) | return escape_item(obj, self.charset) | Alias for escape() | Alias for escape() | [
"Alias",
"for",
"escape",
"()"
] | def literal(self, obj):
''' Alias for escape() '''
return escape_item(obj, self.charset) | [
"def",
"literal",
"(",
"self",
",",
"obj",
")",
":",
"return",
"escape_item",
"(",
"obj",
",",
"self",
".",
"charset",
")"
] | https://github.com/mayank93/Twitter-Sentiment-Analysis/blob/f095c6ca6bf69787582b5dabb140fefaf278eb37/front-end/web2py/gluon/contrib/pymysql/connections.py#L646-L648 | |
EventGhost/EventGhost | 177be516849e74970d2e13cda82244be09f277ce | lib27/site-packages/requests/utils.py | python | default_user_agent | (name="python-requests") | return '%s/%s' % (name, __version__) | Return a string representing the default user agent. | Return a string representing the default user agent. | [
"Return",
"a",
"string",
"representing",
"the",
"default",
"user",
"agent",
"."
] | def default_user_agent(name="python-requests"):
"""Return a string representing the default user agent."""
return '%s/%s' % (name, __version__) | [
"def",
"default_user_agent",
"(",
"name",
"=",
"\"python-requests\"",
")",
":",
"return",
"'%s/%s'",
"%",
"(",
"name",
",",
"__version__",
")"
] | https://github.com/EventGhost/EventGhost/blob/177be516849e74970d2e13cda82244be09f277ce/lib27/site-packages/requests/utils.py#L591-L593 | |
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit /tools/sqli/plugins/dbms/maxdb/syntax.py | python | Syntax.__init__ | (self) | [] | def __init__(self):
GenericSyntax.__init__(self) | [
"def",
"__init__",
"(",
"self",
")",
":",
"GenericSyntax",
".",
"__init__",
"(",
"self",
")"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/sqli/plugins/dbms/maxdb/syntax.py#L11-L12 | ||||
rowliny/DiffHelper | ab3a96f58f9579d0023aed9ebd785f4edf26f8af | Tool/SitePackages/nltk/tokenize/punkt.py | python | PunktSentenceTokenizer.text_contains_sentbreak | (self, text) | return False | Returns True if the given text includes a sentence break. | Returns True if the given text includes a sentence break. | [
"Returns",
"True",
"if",
"the",
"given",
"text",
"includes",
"a",
"sentence",
"break",
"."
] | def text_contains_sentbreak(self, text):
"""
Returns True if the given text includes a sentence break.
"""
found = False # used to ignore last token
for tok in self._annotate_tokens(self._tokenize_words(text)):
if found:
return True
if tok... | [
"def",
"text_contains_sentbreak",
"(",
"self",
",",
"text",
")",
":",
"found",
"=",
"False",
"# used to ignore last token",
"for",
"tok",
"in",
"self",
".",
"_annotate_tokens",
"(",
"self",
".",
"_tokenize_words",
"(",
"text",
")",
")",
":",
"if",
"found",
"... | https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/nltk/tokenize/punkt.py#L1381-L1391 | |
bookwyrm-social/bookwyrm | 0c2537e27a2cdbc0136880dfbbf170d5fec72986 | bookwyrm/models/user.py | python | User.deleted | (self) | return not self.is_active | for consistent naming | for consistent naming | [
"for",
"consistent",
"naming"
] | def deleted(self):
"""for consistent naming"""
return not self.is_active | [
"def",
"deleted",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"is_active"
] | https://github.com/bookwyrm-social/bookwyrm/blob/0c2537e27a2cdbc0136880dfbbf170d5fec72986/bookwyrm/models/user.py#L200-L202 | |
calebstewart/pwncat | d67865bdaac60dd0761d0698062e7b443a62c6db | pwncat/platform/__init__.py | python | Platform.chdir | (self, path: Union[str, Path]) | Change directories to the given path. This method returns the current
working directory prior to the change.
:param path: a relative or absolute path to change to
:type path: Union[str, Path]
:return: current working directory prior to the change
:raises:
FileNotFoundE... | Change directories to the given path. This method returns the current
working directory prior to the change. | [
"Change",
"directories",
"to",
"the",
"given",
"path",
".",
"This",
"method",
"returns",
"the",
"current",
"working",
"directory",
"prior",
"to",
"the",
"change",
"."
] | def chdir(self, path: Union[str, Path]):
"""
Change directories to the given path. This method returns the current
working directory prior to the change.
:param path: a relative or absolute path to change to
:type path: Union[str, Path]
:return: current working directory... | [
"def",
"chdir",
"(",
"self",
",",
"path",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
")",
":"
] | https://github.com/calebstewart/pwncat/blob/d67865bdaac60dd0761d0698062e7b443a62c6db/pwncat/platform/__init__.py#L812-L823 | ||
dmnfarrell/tkintertable | f3fc8950aaa0f087de100d671ce13c24006d9639 | tkintertable/App.py | python | ToolBar.__init__ | (self, parent=None, parentapp=None) | return | [] | def __init__(self, parent=None, parentapp=None):
Frame.__init__(self, parent, width=600, height=40)
from . import Table_images
self.parentframe = parent
self.parentapp = parentapp
#add buttons
img = Table_images.new_proj()
self.add_button('New Project', self.paren... | [
"def",
"__init__",
"(",
"self",
",",
"parent",
"=",
"None",
",",
"parentapp",
"=",
"None",
")",
":",
"Frame",
".",
"__init__",
"(",
"self",
",",
"parent",
",",
"width",
"=",
"600",
",",
"height",
"=",
"40",
")",
"from",
".",
"import",
"Table_images",... | https://github.com/dmnfarrell/tkintertable/blob/f3fc8950aaa0f087de100d671ce13c24006d9639/tkintertable/App.py#L503-L528 | |||
nlloyd/SubliminalCollaborator | 5c619e17ddbe8acb9eea8996ec038169ddcd50a1 | libs/twisted/words/xish/utility.py | python | CallbackList.removeCallback | (self, method) | Remove callback.
@param method: The callable to be removed. | Remove callback. | [
"Remove",
"callback",
"."
] | def removeCallback(self, method):
"""
Remove callback.
@param method: The callable to be removed.
"""
if method in self.callbacks:
del self.callbacks[method] | [
"def",
"removeCallback",
"(",
"self",
",",
"method",
")",
":",
"if",
"method",
"in",
"self",
".",
"callbacks",
":",
"del",
"self",
".",
"callbacks",
"[",
"method",
"]"
] | https://github.com/nlloyd/SubliminalCollaborator/blob/5c619e17ddbe8acb9eea8996ec038169ddcd50a1/libs/twisted/words/xish/utility.py#L77-L85 | ||
robclewley/compneuro | b10edb3cb44b31389a03f5e408294a751e34afbb | phaseplane.py | python | plot_PP_vf | (gen, xname, yname, N=20, subdomain=None, scale_exp=0) | Draw 2D vector field in (xname, yname) coordinates of given Generator,
sampling on a uniform grid of n by n points.
Optional subdomain dictionary specifies axes limits in each variable,
otherwise Generator's xdomain attribute will be used.
For systems of dimension > 2, the non-phase plane variables wi... | Draw 2D vector field in (xname, yname) coordinates of given Generator,
sampling on a uniform grid of n by n points. | [
"Draw",
"2D",
"vector",
"field",
"in",
"(",
"xname",
"yname",
")",
"coordinates",
"of",
"given",
"Generator",
"sampling",
"on",
"a",
"uniform",
"grid",
"of",
"n",
"by",
"n",
"points",
"."
] | def plot_PP_vf(gen, xname, yname, N=20, subdomain=None, scale_exp=0):
"""Draw 2D vector field in (xname, yname) coordinates of given Generator,
sampling on a uniform grid of n by n points.
Optional subdomain dictionary specifies axes limits in each variable,
otherwise Generator's xdomain attribute will... | [
"def",
"plot_PP_vf",
"(",
"gen",
",",
"xname",
",",
"yname",
",",
"N",
"=",
"20",
",",
"subdomain",
"=",
"None",
",",
"scale_exp",
"=",
"0",
")",
":",
"assert",
"N",
">",
"1",
"xdom",
"=",
"gen",
".",
"xdomain",
"[",
"xname",
"]",
"ydom",
"=",
... | https://github.com/robclewley/compneuro/blob/b10edb3cb44b31389a03f5e408294a751e34afbb/phaseplane.py#L3775-L3868 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_openshift/library/oc_clusterrole.py | python | Utils.filter_versions | (stdout) | return version_dict | filter the oc version output | filter the oc version output | [
"filter",
"the",
"oc",
"version",
"output"
] | def filter_versions(stdout):
''' filter the oc version output '''
version_dict = {}
version_search = ['oc', 'openshift', 'kubernetes']
for line in stdout.strip().split('\n'):
for term in version_search:
if not line:
continue
... | [
"def",
"filter_versions",
"(",
"stdout",
")",
":",
"version_dict",
"=",
"{",
"}",
"version_search",
"=",
"[",
"'oc'",
",",
"'openshift'",
",",
"'kubernetes'",
"]",
"for",
"line",
"in",
"stdout",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.40/roles/lib_openshift/library/oc_clusterrole.py#L1268-L1286 | |
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/fax/v1/fax/fax_media.py | python | FaxMediaInstance.sid | (self) | return self._properties['sid'] | :returns: The unique string that identifies the resource
:rtype: unicode | :returns: The unique string that identifies the resource
:rtype: unicode | [
":",
"returns",
":",
"The",
"unique",
"string",
"that",
"identifies",
"the",
"resource",
":",
"rtype",
":",
"unicode"
] | def sid(self):
"""
:returns: The unique string that identifies the resource
:rtype: unicode
"""
return self._properties['sid'] | [
"def",
"sid",
"(",
"self",
")",
":",
"return",
"self",
".",
"_properties",
"[",
"'sid'",
"]"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/fax/v1/fax/fax_media.py#L290-L295 | |
edisonlz/fastor | 342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3 | base/site-packages/south/creator/freezer.py | python | model_dependencies | (model, checked_models=None) | return depends | Returns a set of models this one depends on to be defined; things like
OneToOneFields as ID, ForeignKeys everywhere, etc. | Returns a set of models this one depends on to be defined; things like
OneToOneFields as ID, ForeignKeys everywhere, etc. | [
"Returns",
"a",
"set",
"of",
"models",
"this",
"one",
"depends",
"on",
"to",
"be",
"defined",
";",
"things",
"like",
"OneToOneFields",
"as",
"ID",
"ForeignKeys",
"everywhere",
"etc",
"."
] | def model_dependencies(model, checked_models=None):
"""
Returns a set of models this one depends on to be defined; things like
OneToOneFields as ID, ForeignKeys everywhere, etc.
"""
depends = set()
checked_models = checked_models or set()
# Get deps for each field
for field in model._met... | [
"def",
"model_dependencies",
"(",
"model",
",",
"checked_models",
"=",
"None",
")",
":",
"depends",
"=",
"set",
"(",
")",
"checked_models",
"=",
"checked_models",
"or",
"set",
"(",
")",
"# Get deps for each field",
"for",
"field",
"in",
"model",
".",
"_meta",
... | https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/south/creator/freezer.py#L85-L113 | |
aaronportnoy/toolbag | 2d39457a7617b2f334d203d8c8cf88a5a25ef1fa | toolbag/agent/dbg/vtrace/platforms/base.py | python | TracerBase.fireNotifiers | (self, event) | Fire the registered notifiers for the NOTIFY_* event. | Fire the registered notifiers for the NOTIFY_* event. | [
"Fire",
"the",
"registered",
"notifiers",
"for",
"the",
"NOTIFY_",
"*",
"event",
"."
] | def fireNotifiers(self, event):
"""
Fire the registered notifiers for the NOTIFY_* event.
"""
if event == vtrace.NOTIFY_SIGNAL:
signo = self.getCurrentSignal()
if signo in self.getMeta("IgnoredSignals", []):
if vtrace.verbose: print "Ignoring",sign... | [
"def",
"fireNotifiers",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
"==",
"vtrace",
".",
"NOTIFY_SIGNAL",
":",
"signo",
"=",
"self",
".",
"getCurrentSignal",
"(",
")",
"if",
"signo",
"in",
"self",
".",
"getMeta",
"(",
"\"IgnoredSignals\"",
",",
"... | https://github.com/aaronportnoy/toolbag/blob/2d39457a7617b2f334d203d8c8cf88a5a25ef1fa/toolbag/agent/dbg/vtrace/platforms/base.py#L338-L374 | ||
F8LEFT/DecLLVM | d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c | python/idc.py | python | GetPrevIndex | (tag, array_id, idx) | Get index of the previous existing array element.
@param tag: Tag of array, specifies one of two array types: AR_LONG, AR_STR
@param array_id: The array ID.
@param idx: Index of the current element.
@return: -1 if no more elements, otherwise returns index of the
previous array element of ... | Get index of the previous existing array element. | [
"Get",
"index",
"of",
"the",
"previous",
"existing",
"array",
"element",
"."
] | def GetPrevIndex(tag, array_id, idx):
"""
Get index of the previous existing array element.
@param tag: Tag of array, specifies one of two array types: AR_LONG, AR_STR
@param array_id: The array ID.
@param idx: Index of the current element.
@return: -1 if no more elements, otherwise returns in... | [
"def",
"GetPrevIndex",
"(",
"tag",
",",
"array_id",
",",
"idx",
")",
":",
"node",
"=",
"__GetArrayById",
"(",
"array_id",
")",
"try",
":",
"if",
"tag",
"==",
"AR_LONG",
":",
"return",
"__l2m1",
"(",
"node",
".",
"altprev",
"(",
"idx",
",",
"tag",
")"... | https://github.com/F8LEFT/DecLLVM/blob/d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c/python/idc.py#L6597-L6618 | ||
Jajcus/pyxmpp2 | 59e5fd7c8837991ac265dc6aad23a6bd256768a7 | pyxmpp2/xmppparser.py | python | ParserTarget.end | (self, tag) | Handle an end tag.
Call the handler's 'stream_end' method with
an the root element (built by the `start` method).
On the first level below root, sent the built element tree
to the handler via the 'stanza methods'.
Any tag below will be just added to the tree builder. | Handle an end tag. | [
"Handle",
"an",
"end",
"tag",
"."
] | def end(self, tag):
"""Handle an end tag.
Call the handler's 'stream_end' method with
an the root element (built by the `start` method).
On the first level below root, sent the built element tree
to the handler via the 'stanza methods'.
Any tag below will be just added... | [
"def",
"end",
"(",
"self",
",",
"tag",
")",
":",
"self",
".",
"_level",
"-=",
"1",
"if",
"self",
".",
"_level",
"<",
"0",
":",
"self",
".",
"_handler",
".",
"stream_parse_error",
"(",
"u\"Unexpected end tag for: {0!r}\"",
".",
"format",
"(",
"tag",
")",
... | https://github.com/Jajcus/pyxmpp2/blob/59e5fd7c8837991ac265dc6aad23a6bd256768a7/pyxmpp2/xmppparser.py#L133-L158 | ||
OpenCobolIDE/OpenCobolIDE | c78d0d335378e5fe0a5e74f53c19b68b55e85388 | open_cobol_ide/extlibs/pygments/formatters/terminal256.py | python | Terminal256Formatter._build_color_table | (self) | [] | def _build_color_table(self):
# colors 0..15: 16 basic colors
self.xterm_colors.append((0x00, 0x00, 0x00)) # 0
self.xterm_colors.append((0xcd, 0x00, 0x00)) # 1
self.xterm_colors.append((0x00, 0xcd, 0x00)) # 2
self.xterm_colors.append((0xcd, 0xcd, 0x00)) # 3
self.xter... | [
"def",
"_build_color_table",
"(",
"self",
")",
":",
"# colors 0..15: 16 basic colors",
"self",
".",
"xterm_colors",
".",
"append",
"(",
"(",
"0x00",
",",
"0x00",
",",
"0x00",
")",
")",
"# 0",
"self",
".",
"xterm_colors",
".",
"append",
"(",
"(",
"0xcd",
",... | https://github.com/OpenCobolIDE/OpenCobolIDE/blob/c78d0d335378e5fe0a5e74f53c19b68b55e85388/open_cobol_ide/extlibs/pygments/formatters/terminal256.py#L117-L151 | ||||
mrkipling/maraschino | c6be9286937783ae01df2d6d8cebfc8b2734a7d7 | lib/sqlalchemy/dialects/mysql/base.py | python | FLOAT.__init__ | (self, precision=None, scale=None, asdecimal=False, **kw) | Construct a FLOAT.
:param precision: Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.
:param scale: The number of digits after the decimal point.
:param unsigned: a boolean, optional.
:param zerofill: Opt... | Construct a FLOAT. | [
"Construct",
"a",
"FLOAT",
"."
] | def __init__(self, precision=None, scale=None, asdecimal=False, **kw):
"""Construct a FLOAT.
:param precision: Total digits in this number. If scale and precision
are both None, values are stored to limits allowed by the server.
:param scale: The number of digits after the decimal p... | [
"def",
"__init__",
"(",
"self",
",",
"precision",
"=",
"None",
",",
"scale",
"=",
"None",
",",
"asdecimal",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"super",
"(",
"FLOAT",
",",
"self",
")",
".",
"__init__",
"(",
"precision",
"=",
"precision",
"... | https://github.com/mrkipling/maraschino/blob/c6be9286937783ae01df2d6d8cebfc8b2734a7d7/lib/sqlalchemy/dialects/mysql/base.py#L457-L474 | ||
makerbot/ReplicatorG | d6f2b07785a5a5f1e172fb87cb4303b17c575d5d | skein_engines/skeinforge-50/skeinforge_application/skeinforge_plugins/craft.py | python | writeOutput | (fileName) | return skeinforge_craft.writeOutput(fileName) | Craft a gcode file. | Craft a gcode file. | [
"Craft",
"a",
"gcode",
"file",
"."
] | def writeOutput(fileName):
"Craft a gcode file."
return skeinforge_craft.writeOutput(fileName) | [
"def",
"writeOutput",
"(",
"fileName",
")",
":",
"return",
"skeinforge_craft",
".",
"writeOutput",
"(",
"fileName",
")"
] | https://github.com/makerbot/ReplicatorG/blob/d6f2b07785a5a5f1e172fb87cb4303b17c575d5d/skein_engines/skeinforge-50/skeinforge_application/skeinforge_plugins/craft.py#L61-L63 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/pip/_vendor/urllib3/util/url.py | python | split_first | (s, delims) | return s[:min_idx], s[min_idx + 1:], min_delim | Given a string and an iterable of delimiters, split on the first found
delimiter. Return two split parts and the matched delimiter.
If not found, then the first part is the full input string.
Example::
>>> split_first('foo/bar?baz', '?/=')
('foo', 'bar?baz', '/')
>>> split_first('... | Given a string and an iterable of delimiters, split on the first found
delimiter. Return two split parts and the matched delimiter. | [
"Given",
"a",
"string",
"and",
"an",
"iterable",
"of",
"delimiters",
"split",
"on",
"the",
"first",
"found",
"delimiter",
".",
"Return",
"two",
"split",
"parts",
"and",
"the",
"matched",
"delimiter",
"."
] | def split_first(s, delims):
"""
Given a string and an iterable of delimiters, split on the first found
delimiter. Return two split parts and the matched delimiter.
If not found, then the first part is the full input string.
Example::
>>> split_first('foo/bar?baz', '?/=')
('foo', '... | [
"def",
"split_first",
"(",
"s",
",",
"delims",
")",
":",
"min_idx",
"=",
"None",
"min_delim",
"=",
"None",
"for",
"d",
"in",
"delims",
":",
"idx",
"=",
"s",
".",
"find",
"(",
"d",
")",
"if",
"idx",
"<",
"0",
":",
"continue",
"if",
"min_idx",
"is"... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/pip/_vendor/urllib3/util/url.py#L99-L129 | |
google/grr | 8ad8a4d2c5a93c92729206b7771af19d92d4f915 | grr/client/grr_response_client/windows/installers.py | python | _CreateService | (service_name: str, description: str,
command_line: str) | Creates a Windows service. | Creates a Windows service. | [
"Creates",
"a",
"Windows",
"service",
"."
] | def _CreateService(service_name: str, description: str,
command_line: str) -> None:
"""Creates a Windows service."""
logging.info("Creating service '%s'.", service_name)
with contextlib.ExitStack() as stack:
hscm = win32service.OpenSCManager(None, None,
... | [
"def",
"_CreateService",
"(",
"service_name",
":",
"str",
",",
"description",
":",
"str",
",",
"command_line",
":",
"str",
")",
"->",
"None",
":",
"logging",
".",
"info",
"(",
"\"Creating service '%s'.\"",
",",
"service_name",
")",
"with",
"contextlib",
".",
... | https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/client/grr_response_client/windows/installers.py#L142-L177 | ||
python-ivi/python-usbtmc | d9bfb20b2ef002da787adb6b093e1679705c00e2 | usbtmc/usbtmc.py | python | Instrument._abort_bulk_in | (self, btag=None) | Abort bulk in | Abort bulk in | [
"Abort",
"bulk",
"in"
] | def _abort_bulk_in(self, btag=None):
"Abort bulk in"
if not self.connected:
return
if btag is None:
btag = self.last_btag
# Send INITIATE_ABORT_BULK_IN
b = self.device.ctrl_transfer(
bmRequestType=usb.util.build_request_type(usb.util.CTRL_IN... | [
"def",
"_abort_bulk_in",
"(",
"self",
",",
"btag",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"connected",
":",
"return",
"if",
"btag",
"is",
"None",
":",
"btag",
"=",
"self",
".",
"last_btag",
"# Send INITIATE_ABORT_BULK_IN",
"b",
"=",
"self",
"."... | https://github.com/python-ivi/python-usbtmc/blob/d9bfb20b2ef002da787adb6b093e1679705c00e2/usbtmc/usbtmc.py#L900-L935 | ||
playframework/play1 | 0ecac3bc2421ae2dbec27a368bf671eda1c9cba5 | python/Lib/difflib.py | python | Differ._qformat | (self, aline, bline, atags, btags) | r"""
Format "?" output and deal with leading tabs.
Example:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
... ' ^ ^ ^ ', ' ^ ^ ^ ')
>>> for line in results: print repr(line)
...
'- \t... | r"""
Format "?" output and deal with leading tabs. | [
"r",
"Format",
"?",
"output",
"and",
"deal",
"with",
"leading",
"tabs",
"."
] | def _qformat(self, aline, bline, atags, btags):
r"""
Format "?" output and deal with leading tabs.
Example:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
... ' ^ ^ ^ ', ' ^ ^ ^ ')
>>> for lin... | [
"def",
"_qformat",
"(",
"self",
",",
"aline",
",",
"bline",
",",
"atags",
",",
"btags",
")",
":",
"# Can hurt, but will probably help most of the time.",
"common",
"=",
"min",
"(",
"_count_leading",
"(",
"aline",
",",
"\"\\t\"",
")",
",",
"_count_leading",
"(",
... | https://github.com/playframework/play1/blob/0ecac3bc2421ae2dbec27a368bf671eda1c9cba5/python/Lib/difflib.py#L1054-L1085 | ||
rwl/PYPOWER | f5be0406aa54dcebded075de075454f99e2a46e6 | pypower/makeApq.py | python | makeApq | (baseMVA, gen) | return Apqh, ubpqh, Apql, ubpql, data | Construct linear constraints for generator capability curves.
Constructs the parameters for the following linear constraints
implementing trapezoidal generator capability curves, where
C{Pg} and C{Qg} are the real and reactive generator injections::
Apqh * [Pg, Qg] <= ubpqh
Apql * [Pg, Qg]... | Construct linear constraints for generator capability curves. | [
"Construct",
"linear",
"constraints",
"for",
"generator",
"capability",
"curves",
"."
] | def makeApq(baseMVA, gen):
"""Construct linear constraints for generator capability curves.
Constructs the parameters for the following linear constraints
implementing trapezoidal generator capability curves, where
C{Pg} and C{Qg} are the real and reactive generator injections::
Apqh * [Pg, Qg... | [
"def",
"makeApq",
"(",
"baseMVA",
",",
"gen",
")",
":",
"data",
"=",
"{",
"}",
"## data dimensions",
"ng",
"=",
"gen",
".",
"shape",
"[",
"0",
"]",
"## number of dispatchable injections",
"## which generators require additional linear constraints",
"## (in addition to s... | https://github.com/rwl/PYPOWER/blob/f5be0406aa54dcebded075de075454f99e2a46e6/pypower/makeApq.py#L17-L96 | |
SCons/scons | 309f0234d1d9cc76955818be47c5c722f577dac6 | SCons/Memoize.py | python | CountMethodCall | (fn) | Decorator for counting memoizer hits/misses while retrieving
a simple value in a class method. It wraps the given method
fn and uses a CountValue object to keep track of the
caching statistics.
Wrapping gets enabled by calling EnableMemoization(). | Decorator for counting memoizer hits/misses while retrieving
a simple value in a class method. It wraps the given method
fn and uses a CountValue object to keep track of the
caching statistics.
Wrapping gets enabled by calling EnableMemoization(). | [
"Decorator",
"for",
"counting",
"memoizer",
"hits",
"/",
"misses",
"while",
"retrieving",
"a",
"simple",
"value",
"in",
"a",
"class",
"method",
".",
"It",
"wraps",
"the",
"given",
"method",
"fn",
"and",
"uses",
"a",
"CountValue",
"object",
"to",
"keep",
"t... | def CountMethodCall(fn):
""" Decorator for counting memoizer hits/misses while retrieving
a simple value in a class method. It wraps the given method
fn and uses a CountValue object to keep track of the
caching statistics.
Wrapping gets enabled by calling EnableMemoization().
"""... | [
"def",
"CountMethodCall",
"(",
"fn",
")",
":",
"if",
"use_memoizer",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"CounterList",
"key",
"=",
"self",
".",
"__class__",
".",
"__name__",
"+",
"'.'",
... | https://github.com/SCons/scons/blob/309f0234d1d9cc76955818be47c5c722f577dac6/SCons/Memoize.py#L193-L211 | ||
maas/maas | db2f89970c640758a51247c59bf1ec6f60cf4ab5 | src/provisioningserver/drivers/pod/virsh.py | python | VirshSSH.poweron | (self, machine) | return True | Poweron a VM. | Poweron a VM. | [
"Poweron",
"a",
"VM",
"."
] | def poweron(self, machine):
"""Poweron a VM."""
try:
self.run(["start", machine])
except VirshError:
return False
return True | [
"def",
"poweron",
"(",
"self",
",",
"machine",
")",
":",
"try",
":",
"self",
".",
"run",
"(",
"[",
"\"start\"",
",",
"machine",
"]",
")",
"except",
"VirshError",
":",
"return",
"False",
"return",
"True"
] | https://github.com/maas/maas/blob/db2f89970c640758a51247c59bf1ec6f60cf4ab5/src/provisioningserver/drivers/pod/virsh.py#L845-L851 | |
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/twisted/twisted/web/http.py | python | _ChunkedTransferDecoder.dataReceived | (self, data) | Interpret data from a request or response body which uses the
I{chunked} Transfer-Encoding. | Interpret data from a request or response body which uses the
I{chunked} Transfer-Encoding. | [
"Interpret",
"data",
"from",
"a",
"request",
"or",
"response",
"body",
"which",
"uses",
"the",
"I",
"{",
"chunked",
"}",
"Transfer",
"-",
"Encoding",
"."
] | def dataReceived(self, data):
"""
Interpret data from a request or response body which uses the
I{chunked} Transfer-Encoding.
"""
data = self._buffer + data
self._buffer = ''
while data:
if self.state == 'chunk-length':
if '\r\n' in dat... | [
"def",
"dataReceived",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"self",
".",
"_buffer",
"+",
"data",
"self",
".",
"_buffer",
"=",
"''",
"while",
"data",
":",
"if",
"self",
".",
"state",
"==",
"'chunk-length'",
":",
"if",
"'\\r\\n'",
"in",
"da... | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/twisted/twisted/web/http.py#L1422-L1468 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_clusterrole.py | python | Rule.add_resource | (self, inc_resource) | add an resource to the resources array | add an resource to the resources array | [
"add",
"an",
"resource",
"to",
"the",
"resources",
"array"
] | def add_resource(self, inc_resource):
'''add an resource to the resources array'''
self.resources.append(inc_resource) | [
"def",
"add_resource",
"(",
"self",
",",
"inc_resource",
")",
":",
"self",
".",
"resources",
".",
"append",
"(",
"inc_resource",
")"
] | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_clusterrole.py#L1542-L1544 | ||
Tautulli/Tautulli | 2410eb33805aaac4bd1c5dad0f71e4f15afaf742 | lib/httpagentparser/__init__.py | python | YandexBot.getVersion | (self, agent, word) | return agent[agent.index('Yandex'):].split('/')[-1].split(')')[0].strip() | [] | def getVersion(self, agent, word):
return agent[agent.index('Yandex'):].split('/')[-1].split(')')[0].strip() | [
"def",
"getVersion",
"(",
"self",
",",
"agent",
",",
"word",
")",
":",
"return",
"agent",
"[",
"agent",
".",
"index",
"(",
"'Yandex'",
")",
":",
"]",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
".",
"split",
"(",
"')'",
")",
"[",
"0",
... | https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/httpagentparser/__init__.py#L289-L290 | |||
xonsh/xonsh | b76d6f994f22a4078f602f8b386f4ec280c8461f | xonsh/procs/proxies.py | python | FileThreadDispatcher.seek | (self, offset, whence=io.SEEK_SET) | return self.handle.seek(offset, whence) | Seeks the current file. | Seeks the current file. | [
"Seeks",
"the",
"current",
"file",
"."
] | def seek(self, offset, whence=io.SEEK_SET):
"""Seeks the current file."""
return self.handle.seek(offset, whence) | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"io",
".",
"SEEK_SET",
")",
":",
"return",
"self",
".",
"handle",
".",
"seek",
"(",
"offset",
",",
"whence",
")"
] | https://github.com/xonsh/xonsh/blob/b76d6f994f22a4078f602f8b386f4ec280c8461f/xonsh/procs/proxies.py#L169-L171 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_service.py | python | Yedit.create | (self, path, value) | return (False, self.yaml_dict) | create a yaml file | create a yaml file | [
"create",
"a",
"yaml",
"file"
] | def create(self, path, value):
''' create a yaml file '''
if not self.file_exists():
# deepcopy didn't work
# Try to use ruamel.yaml and fallback to pyyaml
try:
tmp_copy = yaml.load(yaml.round_trip_dump(self.yaml_dict,
... | [
"def",
"create",
"(",
"self",
",",
"path",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"file_exists",
"(",
")",
":",
"# deepcopy didn't work",
"# Try to use ruamel.yaml and fallback to pyyaml",
"try",
":",
"tmp_copy",
"=",
"yaml",
".",
"load",
"(",
"yaml... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_vendored_deps/library/oc_service.py#L691-L714 | |
cuthbertLab/music21 | bd30d4663e52955ed922c10fdf541419d8c67671 | music21/stream/iterator.py | python | OffsetIterator.reset | (self) | runs before iteration | runs before iteration | [
"runs",
"before",
"iteration"
] | def reset(self):
'''
runs before iteration
'''
super().reset()
self.nextToYield = []
self.nextOffsetToYield = None
self.raiseStopIterationNext = False | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"reset",
"(",
")",
"self",
".",
"nextToYield",
"=",
"[",
"]",
"self",
".",
"nextOffsetToYield",
"=",
"None",
"self",
".",
"raiseStopIterationNext",
"=",
"False"
] | https://github.com/cuthbertLab/music21/blob/bd30d4663e52955ed922c10fdf541419d8c67671/music21/stream/iterator.py#L1496-L1503 | ||
otsaloma/gaupol | 6dec7826654d223c71a8d3279dcd967e95c46714 | aeidon/markups/ssa.py | python | SubStationAlpha.bolden | (self, text, bounds=None) | return "".join((text[:a], target, text[z:])) | Return bolded `text`. | Return bolded `text`. | [
"Return",
"bolded",
"text",
"."
] | def bolden(self, text, bounds=None):
"""Return bolded `text`."""
a, z = bounds or (0, len(text))
target = "{{\\b1}}{}{{\\b0}}".format(text[a:z])
return "".join((text[:a], target, text[z:])) | [
"def",
"bolden",
"(",
"self",
",",
"text",
",",
"bounds",
"=",
"None",
")",
":",
"a",
",",
"z",
"=",
"bounds",
"or",
"(",
"0",
",",
"len",
"(",
"text",
")",
")",
"target",
"=",
"\"{{\\\\b1}}{}{{\\\\b0}}\"",
".",
"format",
"(",
"text",
"[",
"a",
"... | https://github.com/otsaloma/gaupol/blob/6dec7826654d223c71a8d3279dcd967e95c46714/aeidon/markups/ssa.py#L58-L62 | |
holzschu/Carnets | 44effb10ddfc6aa5c8b0687582a724ba82c6b547 | Library/lib/python3.7/site-packages/matplotlib-3.0.3-py3.7-macosx-10.9-x86_64.egg/matplotlib/artist.py | python | setp | (obj, *args, **kwargs) | return list(cbook.flatten(ret)) | Set a property on an artist object.
matplotlib supports the use of :func:`setp` ("set property") and
:func:`getp` to set and get object properties, as well as to do
introspection on the object. For example, to set the linestyle of a
line to be dashed, you can do::
>>> line, = plot([1,2,3])
... | Set a property on an artist object. | [
"Set",
"a",
"property",
"on",
"an",
"artist",
"object",
"."
] | def setp(obj, *args, **kwargs):
"""
Set a property on an artist object.
matplotlib supports the use of :func:`setp` ("set property") and
:func:`getp` to set and get object properties, as well as to do
introspection on the object. For example, to set the linestyle of a
line to be dashed, you ca... | [
"def",
"setp",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"Artist",
")",
":",
"objs",
"=",
"[",
"obj",
"]",
"else",
":",
"objs",
"=",
"list",
"(",
"cbook",
".",
"flatten",
"(",
"obj",
... | https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/matplotlib-3.0.3-py3.7-macosx-10.9-x86_64.egg/matplotlib/artist.py#L1430-L1508 | |
Kismuz/btgym | 7fb3316e67f1d7a17c620630fb62fb29428b2cec | btgym/rendering/plotter.py | python | BTgymPlotter.__init__ | (self, **kwargs) | pass | pass | [
"pass"
] | def __init__(self, **kwargs):
"""
pass
"""
super(BTgymPlotter, self).__init__(**kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"BTgymPlotter",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"*",
"kwargs",
")"
] | https://github.com/Kismuz/btgym/blob/7fb3316e67f1d7a17c620630fb62fb29428b2cec/btgym/rendering/plotter.py#L31-L35 | ||
OpenEndedGroup/Field | 4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c | Contents/lib/python/logging/__init__.py | python | getLogger | (name=None) | Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger. | Return a logger with the specified name, creating it if necessary. | [
"Return",
"a",
"logger",
"with",
"the",
"specified",
"name",
"creating",
"it",
"if",
"necessary",
"."
] | def getLogger(name=None):
"""
Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger.
"""
if name:
return Logger.manager.getLogger(name)
else:
return root | [
"def",
"getLogger",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
":",
"return",
"Logger",
".",
"manager",
".",
"getLogger",
"(",
"name",
")",
"else",
":",
"return",
"root"
] | https://github.com/OpenEndedGroup/Field/blob/4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c/Contents/lib/python/logging/__init__.py#L1258-L1267 | ||
llSourcell/AI_Artist | 3038c06c2e389b9c919c881c9a169efe2fd7810e | lib/python2.7/site-packages/pip/_vendor/packaging/specifiers.py | python | LegacySpecifier._compare_equal | (self, prospective, spec) | return prospective == self._coerce_version(spec) | [] | def _compare_equal(self, prospective, spec):
return prospective == self._coerce_version(spec) | [
"def",
"_compare_equal",
"(",
"self",
",",
"prospective",
",",
"spec",
")",
":",
"return",
"prospective",
"==",
"self",
".",
"_coerce_version",
"(",
"spec",
")"
] | https://github.com/llSourcell/AI_Artist/blob/3038c06c2e389b9c919c881c9a169efe2fd7810e/lib/python2.7/site-packages/pip/_vendor/packaging/specifiers.py#L247-L248 | |||
openhatch/oh-mainline | ce29352a034e1223141dcc2f317030bbc3359a51 | vendor/packages/twisted/twisted/conch/client/knownhosts.py | python | _BaseEntry.matchesKey | (self, keyObject) | return self.publicKey == keyObject | Check to see if this entry matches a given key object.
@type keyObject: L{Key}
@rtype: bool | Check to see if this entry matches a given key object. | [
"Check",
"to",
"see",
"if",
"this",
"entry",
"matches",
"a",
"given",
"key",
"object",
"."
] | def matchesKey(self, keyObject):
"""
Check to see if this entry matches a given key object.
@type keyObject: L{Key}
@rtype: bool
"""
return self.publicKey == keyObject | [
"def",
"matchesKey",
"(",
"self",
",",
"keyObject",
")",
":",
"return",
"self",
".",
"publicKey",
"==",
"keyObject"
] | https://github.com/openhatch/oh-mainline/blob/ce29352a034e1223141dcc2f317030bbc3359a51/vendor/packages/twisted/twisted/conch/client/knownhosts.py#L85-L93 | |
liqd/adhocracy | a143e7101f788f56c78e00bd30b2fe2e15bf3552 | src/adhocracy/lib/base.py | python | BaseController.__call__ | (self, environ, start_response) | Invoke the Controller | Invoke the Controller | [
"Invoke",
"the",
"Controller"
] | def __call__(self, environ, start_response):
"""Invoke the Controller"""
c.body_css_classes = []
c.body_css_classes.append('controller-' + self.identifier)
if self.identifier in ['proposals', 'milestones', 'norms', 'category',
'members']:
c.ac... | [
"def",
"__call__",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"c",
".",
"body_css_classes",
"=",
"[",
"]",
"c",
".",
"body_css_classes",
".",
"append",
"(",
"'controller-'",
"+",
"self",
".",
"identifier",
")",
"if",
"self",
".",
"iden... | https://github.com/liqd/adhocracy/blob/a143e7101f788f56c78e00bd30b2fe2e15bf3552/src/adhocracy/lib/base.py#L27-L111 | ||
1040003585/WebScrapingWithPython | a770fa5b03894076c8c9539b1ffff34424ffc016 | ResourceCode/wswp-places-c573d29efa3a/web2py/gluon/contrib/pg8000/core.py | python | Cursor.fetchall | (self) | Fetches all remaining rows of a query result.
This method is part of the `DBAPI 2.0 specification
<http://www.python.org/dev/peps/pep-0249/>`_.
:returns:
A sequence, each entry of which is a sequence of field values
making up a row. | Fetches all remaining rows of a query result. | [
"Fetches",
"all",
"remaining",
"rows",
"of",
"a",
"query",
"result",
"."
] | def fetchall(self):
"""Fetches all remaining rows of a query result.
This method is part of the `DBAPI 2.0 specification
<http://www.python.org/dev/peps/pep-0249/>`_.
:returns:
A sequence, each entry of which is a sequence of field values
making up a row.
... | [
"def",
"fetchall",
"(",
"self",
")",
":",
"try",
":",
"return",
"tuple",
"(",
"self",
")",
"except",
"TypeError",
":",
"raise",
"ProgrammingError",
"(",
"\"attempting to use unexecuted cursor\"",
")"
] | https://github.com/1040003585/WebScrapingWithPython/blob/a770fa5b03894076c8c9539b1ffff34424ffc016/ResourceCode/wswp-places-c573d29efa3a/web2py/gluon/contrib/pg8000/core.py#L647-L661 | ||
iclavera/learning_to_adapt | bd7d99ba402521c96631e7d09714128f549db0f1 | learning_to_adapt/mujoco_py/glfw.py | python | get_monitor_physical_size | (monitor) | return width_value.value, height_value.value | Returns the physical size of the monitor.
Wrapper for:
void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); | Returns the physical size of the monitor. | [
"Returns",
"the",
"physical",
"size",
"of",
"the",
"monitor",
"."
] | def get_monitor_physical_size(monitor):
'''
Returns the physical size of the monitor.
Wrapper for:
void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
'''
width_value = ctypes.c_int(0)
width = ctypes.pointer(width_value)
height_value = ctypes.c_int(0)
... | [
"def",
"get_monitor_physical_size",
"(",
"monitor",
")",
":",
"width_value",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"width",
"=",
"ctypes",
".",
"pointer",
"(",
"width_value",
")",
"height_value",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"height",
... | https://github.com/iclavera/learning_to_adapt/blob/bd7d99ba402521c96631e7d09714128f549db0f1/learning_to_adapt/mujoco_py/glfw.py#L642-L654 | |
Arelle/Arelle | 20f3d8a8afd41668e1520799acd333349ce0ba17 | arelle/ModelXbrl.py | python | ModelXbrl.prefixedNamespaces | (self) | return prefixedNamespaces | Dict of prefixes for namespaces defined in DTS | Dict of prefixes for namespaces defined in DTS | [
"Dict",
"of",
"prefixes",
"for",
"namespaces",
"defined",
"in",
"DTS"
] | def prefixedNamespaces(self):
"""Dict of prefixes for namespaces defined in DTS
"""
prefixedNamespaces = {}
for nsDocs in self.namespaceDocs.values():
for nsDoc in nsDocs:
ns = nsDoc.targetNamespace
if ns:
prefix = XmlUtil.x... | [
"def",
"prefixedNamespaces",
"(",
"self",
")",
":",
"prefixedNamespaces",
"=",
"{",
"}",
"for",
"nsDocs",
"in",
"self",
".",
"namespaceDocs",
".",
"values",
"(",
")",
":",
"for",
"nsDoc",
"in",
"nsDocs",
":",
"ns",
"=",
"nsDoc",
".",
"targetNamespace",
"... | https://github.com/Arelle/Arelle/blob/20f3d8a8afd41668e1520799acd333349ce0ba17/arelle/ModelXbrl.py#L505-L516 | |
deepgully/me | f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0 | libs/mako/runtime.py | python | Namespace.get_template | (self, uri) | return _lookup_template(self.context, uri, self._templateuri) | Return a :class:`.Template` from the given ``uri``.
The ``uri`` resolution is relative to the ``uri`` of this :class:`.Namespace`
object's :class:`.Template`. | Return a :class:`.Template` from the given ``uri``. | [
"Return",
"a",
":",
"class",
":",
".",
"Template",
"from",
"the",
"given",
"uri",
"."
] | def get_template(self, uri):
"""Return a :class:`.Template` from the given ``uri``.
The ``uri`` resolution is relative to the ``uri`` of this :class:`.Namespace`
object's :class:`.Template`.
"""
return _lookup_template(self.context, uri, self._templateuri) | [
"def",
"get_template",
"(",
"self",
",",
"uri",
")",
":",
"return",
"_lookup_template",
"(",
"self",
".",
"context",
",",
"uri",
",",
"self",
".",
"_templateuri",
")"
] | https://github.com/deepgully/me/blob/f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0/libs/mako/runtime.py#L433-L440 | |
janpipek/physt | e7bce911532fac5f96e4e2d54881152e7e668a41 | physt/plotting/matplotlib.py | python | _add_colorbar | (
ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize
) | Show a colorbar right of the plot. | Show a colorbar right of the plot. | [
"Show",
"a",
"colorbar",
"right",
"of",
"the",
"plot",
"."
] | def _add_colorbar(
ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize
) -> None:
"""Show a colorbar right of the plot."""
fig = ax.get_figure()
mappable = cm.ScalarMappable(cmap=cmap, norm=norm)
mappable.set_array(cmap_data) # TODO: Or what???
fig.colorbar(mappable, ... | [
"def",
"_add_colorbar",
"(",
"ax",
":",
"Axes",
",",
"cmap",
":",
"colors",
".",
"Colormap",
",",
"cmap_data",
":",
"np",
".",
"ndarray",
",",
"norm",
":",
"colors",
".",
"Normalize",
")",
"->",
"None",
":",
"fig",
"=",
"ax",
".",
"get_figure",
"(",
... | https://github.com/janpipek/physt/blob/e7bce911532fac5f96e4e2d54881152e7e668a41/physt/plotting/matplotlib.py#L957-L964 | ||
materialsproject/pymatgen | 8128f3062a334a2edd240e4062b5b9bdd1ae6f58 | pymatgen/io/vasp/outputs.py | python | Outcar.read_lepsilon | (self) | Reads an LEPSILON run.
# TODO: Document the actual variables. | Reads an LEPSILON run. | [
"Reads",
"an",
"LEPSILON",
"run",
"."
] | def read_lepsilon(self):
"""
Reads an LEPSILON run.
# TODO: Document the actual variables.
"""
try:
search = []
def dielectric_section_start(results, match):
results.dielectric_index = -1
search.append(
[
... | [
"def",
"read_lepsilon",
"(",
"self",
")",
":",
"try",
":",
"search",
"=",
"[",
"]",
"def",
"dielectric_section_start",
"(",
"results",
",",
"match",
")",
":",
"results",
".",
"dielectric_index",
"=",
"-",
"1",
"search",
".",
"append",
"(",
"[",
"r\"MACRO... | https://github.com/materialsproject/pymatgen/blob/8128f3062a334a2edd240e4062b5b9bdd1ae6f58/pymatgen/io/vasp/outputs.py#L2749-L2903 | ||
DeepPavlov/convai | 54d921f99606960941ece4865a396925dfc264f4 | 2017/solutions/kaib/ParlAI/parlai/agents/seq2seq_v2/beam.py | python | Beam.advance_end | (self, word_lk) | return self.done | Advance the beam.
Until each beam meets __eos__
Do not generate __unk__ | Advance the beam.
Until each beam meets __eos__
Do not generate __unk__ | [
"Advance",
"the",
"beam",
".",
"Until",
"each",
"beam",
"meets",
"__eos__",
"Do",
"not",
"generate",
"__unk__"
] | def advance_end(self, word_lk):
"""Advance the beam.
Until each beam meets __eos__
Do not generate __unk__
"""
num_words = word_lk.size(1)
if debug:
print("score mask")
print(self.score_mask)
# Sum the previous scores.
... | [
"def",
"advance_end",
"(",
"self",
",",
"word_lk",
")",
":",
"num_words",
"=",
"word_lk",
".",
"size",
"(",
"1",
")",
"if",
"debug",
":",
"print",
"(",
"\"score mask\"",
")",
"print",
"(",
"self",
".",
"score_mask",
")",
"# Sum the previous scores.",
"if",... | https://github.com/DeepPavlov/convai/blob/54d921f99606960941ece4865a396925dfc264f4/2017/solutions/kaib/ParlAI/parlai/agents/seq2seq_v2/beam.py#L107-L167 | |
HypothesisWorks/hypothesis | d1bfc4acc86899caa7a40f892322e1a69fbf36f4 | hypothesis-python/src/hypothesis/extra/ghostwriter.py | python | _get_params | (func: Callable) | return OrderedDict((p.name, p) for p in params if p.kind not in var_param_kinds) | Get non-vararg parameters of `func` as an ordered dict. | Get non-vararg parameters of `func` as an ordered dict. | [
"Get",
"non",
"-",
"vararg",
"parameters",
"of",
"func",
"as",
"an",
"ordered",
"dict",
"."
] | def _get_params(func: Callable) -> Dict[str, inspect.Parameter]:
"""Get non-vararg parameters of `func` as an ordered dict."""
var_param_kinds = (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD)
try:
params = list(inspect.signature(func).parameters.values())
except Exception:
... | [
"def",
"_get_params",
"(",
"func",
":",
"Callable",
")",
"->",
"Dict",
"[",
"str",
",",
"inspect",
".",
"Parameter",
"]",
":",
"var_param_kinds",
"=",
"(",
"inspect",
".",
"Parameter",
".",
"VAR_POSITIONAL",
",",
"inspect",
".",
"Parameter",
".",
"VAR_KEYW... | https://github.com/HypothesisWorks/hypothesis/blob/d1bfc4acc86899caa7a40f892322e1a69fbf36f4/hypothesis-python/src/hypothesis/extra/ghostwriter.py#L324-L372 | |
pilotmoon/PopClip-Extensions | 29fc472befc09ee350092ac70283bd9fdb456cb6 | source/InstantTranslate/requests/packages/urllib3/util/retry.py | python | Retry.is_forced_retry | (self, method, status_code) | return self.status_forcelist and status_code in self.status_forcelist | Is this method/status code retryable? (Based on method/codes whitelists) | Is this method/status code retryable? (Based on method/codes whitelists) | [
"Is",
"this",
"method",
"/",
"status",
"code",
"retryable?",
"(",
"Based",
"on",
"method",
"/",
"codes",
"whitelists",
")"
] | def is_forced_retry(self, method, status_code):
""" Is this method/status code retryable? (Based on method/codes whitelists)
"""
if self.method_whitelist and method.upper() not in self.method_whitelist:
return False
return self.status_forcelist and status_code in self.status... | [
"def",
"is_forced_retry",
"(",
"self",
",",
"method",
",",
"status_code",
")",
":",
"if",
"self",
".",
"method_whitelist",
"and",
"method",
".",
"upper",
"(",
")",
"not",
"in",
"self",
".",
"method_whitelist",
":",
"return",
"False",
"return",
"self",
".",... | https://github.com/pilotmoon/PopClip-Extensions/blob/29fc472befc09ee350092ac70283bd9fdb456cb6/source/InstantTranslate/requests/packages/urllib3/util/retry.py#L192-L198 | |
Dozed12/df-style-worldgen | 937455d54f4b02df9c4b10ae6418f4c932fd97bf | dist/libtcodpy.py | python | parser_get_string_property | (parser, name) | return _lib.TCOD_parser_get_string_property(parser, c_char_p(name)) | [] | def parser_get_string_property(parser, name):
return _lib.TCOD_parser_get_string_property(parser, c_char_p(name)) | [
"def",
"parser_get_string_property",
"(",
"parser",
",",
"name",
")",
":",
"return",
"_lib",
".",
"TCOD_parser_get_string_property",
"(",
"parser",
",",
"c_char_p",
"(",
"name",
")",
")"
] | https://github.com/Dozed12/df-style-worldgen/blob/937455d54f4b02df9c4b10ae6418f4c932fd97bf/dist/libtcodpy.py#L1376-L1377 | |||
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/site-packages/kombu/transport/base.py | python | Transport.supports_heartbeats | (self) | return self.implements.heartbeats | [] | def supports_heartbeats(self):
return self.implements.heartbeats | [
"def",
"supports_heartbeats",
"(",
"self",
")",
":",
"return",
"self",
".",
"implements",
".",
"heartbeats"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/kombu/transport/base.py#L250-L251 | |||
smicallef/spiderfoot | fd4bf9394c9ab3ecc90adc3115c56349fb23165b | spiderfoot/plugin.py | python | SpiderFootPlugin.notifyListeners | (self, sfEvent) | Call the handleEvent() method of every other plug-in listening for
events from this plug-in. Remember that those plug-ins will be called
within the same execution context of this thread, not on their own.
Args:
sfEvent (SpiderFootEvent): event
Raises:
TypeError:... | Call the handleEvent() method of every other plug-in listening for
events from this plug-in. Remember that those plug-ins will be called
within the same execution context of this thread, not on their own. | [
"Call",
"the",
"handleEvent",
"()",
"method",
"of",
"every",
"other",
"plug",
"-",
"in",
"listening",
"for",
"events",
"from",
"this",
"plug",
"-",
"in",
".",
"Remember",
"that",
"those",
"plug",
"-",
"ins",
"will",
"be",
"called",
"within",
"the",
"same... | def notifyListeners(self, sfEvent):
"""Call the handleEvent() method of every other plug-in listening for
events from this plug-in. Remember that those plug-ins will be called
within the same execution context of this thread, not on their own.
Args:
sfEvent (SpiderFootEvent)... | [
"def",
"notifyListeners",
"(",
"self",
",",
"sfEvent",
")",
":",
"from",
"spiderfoot",
"import",
"SpiderFootEvent",
"if",
"not",
"isinstance",
"(",
"sfEvent",
",",
"SpiderFootEvent",
")",
":",
"raise",
"TypeError",
"(",
"f\"sfEvent is {type(sfEvent)}; expected SpiderF... | https://github.com/smicallef/spiderfoot/blob/fd4bf9394c9ab3ecc90adc3115c56349fb23165b/spiderfoot/plugin.py#L312-L400 | ||
bitcoin-core/HWI | 6871946c2176f2f9777b6ac8f0614d96d99bfa0e | hwilib/devices/jadepy/jade.py | python | JadeAPI.run_remote_selfcheck | (self) | return self._jadeRpc('debug_selfcheck', long_timeout=True) | [] | def run_remote_selfcheck(self):
return self._jadeRpc('debug_selfcheck', long_timeout=True) | [
"def",
"run_remote_selfcheck",
"(",
"self",
")",
":",
"return",
"self",
".",
"_jadeRpc",
"(",
"'debug_selfcheck'",
",",
"long_timeout",
"=",
"True",
")"
] | https://github.com/bitcoin-core/HWI/blob/6871946c2176f2f9777b6ac8f0614d96d99bfa0e/hwilib/devices/jadepy/jade.py#L210-L211 | |||
Netflix/security_monkey | c28592ffd518fa399527d26262683fc860c30eef | security_monkey/watchers/vpc/networkacl.py | python | NetworkACL.slurp | (self) | return slurp_items() | :returns: item_list - list of network acls.
:returns: exception_map - A dict where the keys are a tuple containing the
location of the exception and the value is the actual exception | :returns: item_list - list of network acls.
:returns: exception_map - A dict where the keys are a tuple containing the
location of the exception and the value is the actual exception | [
":",
"returns",
":",
"item_list",
"-",
"list",
"of",
"network",
"acls",
".",
":",
"returns",
":",
"exception_map",
"-",
"A",
"dict",
"where",
"the",
"keys",
"are",
"a",
"tuple",
"containing",
"the",
"location",
"of",
"the",
"exception",
"and",
"the",
"va... | def slurp(self):
"""
:returns: item_list - list of network acls.
:returns: exception_map - A dict where the keys are a tuple containing the
location of the exception and the value is the actual exception
"""
self.prep_for_slurp()
@iter_account_region(index=s... | [
"def",
"slurp",
"(",
"self",
")",
":",
"self",
".",
"prep_for_slurp",
"(",
")",
"@",
"iter_account_region",
"(",
"index",
"=",
"self",
".",
"index",
",",
"accounts",
"=",
"self",
".",
"accounts",
",",
"service_name",
"=",
"'ec2'",
")",
"def",
"slurp_item... | https://github.com/Netflix/security_monkey/blob/c28592ffd518fa399527d26262683fc860c30eef/security_monkey/watchers/vpc/networkacl.py#L48-L90 | |
xlcnd/isbntools | e7c85f0f4b3dd023b43b0b5daccbd8f6f62250f9 | isbntools/_shelvecache.py | python | ShelveCache.__init__ | (self, filepath, allow_empty=True) | Initialize attributes. | Initialize attributes. | [
"Initialize",
"attributes",
"."
] | def __init__(self, filepath, allow_empty=True):
"""Initialize attributes."""
self._sh = shelve
self.filepath = filepath
self._allow_empty = allow_empty
self._allow_empty_default = allow_empty
try:
s = self._sh.open(self.filepath)
try:
... | [
"def",
"__init__",
"(",
"self",
",",
"filepath",
",",
"allow_empty",
"=",
"True",
")",
":",
"self",
".",
"_sh",
"=",
"shelve",
"self",
".",
"filepath",
"=",
"filepath",
"self",
".",
"_allow_empty",
"=",
"allow_empty",
"self",
".",
"_allow_empty_default",
"... | https://github.com/xlcnd/isbntools/blob/e7c85f0f4b3dd023b43b0b5daccbd8f6f62250f9/isbntools/_shelvecache.py#L51-L69 | ||
google/timesketch | 1ce6b60e125d104e6644947c6f1dbe1b82ac76b6 | api_client/python/timesketch_api_client/config.py | python | get_client | (
config_dict: Optional[Dict[Text, Any]] = None,
config_path: Optional[Text] = '',
config_section: Optional[Text] = 'timesketch',
token_password: Optional[Text] = '',
confirm_choices: Optional[bool] = False,
load_cli_config: Optional[bool] = False
) | Returns a Timesketch API client using the configuration assistant.
Args:
config_dict (dict): optional dict that will be used to configure
the client.
config_path (str): optional path to the configuration file, if
not supplied a default path will be used.
config_secti... | Returns a Timesketch API client using the configuration assistant. | [
"Returns",
"a",
"Timesketch",
"API",
"client",
"using",
"the",
"configuration",
"assistant",
"."
] | def get_client(
config_dict: Optional[Dict[Text, Any]] = None,
config_path: Optional[Text] = '',
config_section: Optional[Text] = 'timesketch',
token_password: Optional[Text] = '',
confirm_choices: Optional[bool] = False,
load_cli_config: Optional[bool] = False
) ... | [
"def",
"get_client",
"(",
"config_dict",
":",
"Optional",
"[",
"Dict",
"[",
"Text",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"config_path",
":",
"Optional",
"[",
"Text",
"]",
"=",
"''",
",",
"config_section",
":",
"Optional",
"[",
"Text",
"]",
"=",
"'... | https://github.com/google/timesketch/blob/1ce6b60e125d104e6644947c6f1dbe1b82ac76b6/api_client/python/timesketch_api_client/config.py#L376-L438 | ||
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/dexcom/config_flow.py | python | DexcomOptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | [
"Initialize",
"options",
"flow",
"."
] | def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/dexcom/config_flow.py#L64-L66 | ||
couchbase/couchbase-python-client | 58ccfd42af320bde6b733acf094fd5a4cf34e0ad | couchbase_version.py | python | gen_version | (do_write=True, txt=None) | Generate a version based on git tag info. This will write the
couchbase/_version.py file. If not inside a git tree it will
raise a CantInvokeGit exception - which is normal
(and squashed by setup.py) if we are running from a tarball | Generate a version based on git tag info. This will write the
couchbase/_version.py file. If not inside a git tree it will
raise a CantInvokeGit exception - which is normal
(and squashed by setup.py) if we are running from a tarball | [
"Generate",
"a",
"version",
"based",
"on",
"git",
"tag",
"info",
".",
"This",
"will",
"write",
"the",
"couchbase",
"/",
"_version",
".",
"py",
"file",
".",
"If",
"not",
"inside",
"a",
"git",
"tree",
"it",
"will",
"raise",
"a",
"CantInvokeGit",
"exception... | def gen_version(do_write=True, txt=None):
"""
Generate a version based on git tag info. This will write the
couchbase/_version.py file. If not inside a git tree it will
raise a CantInvokeGit exception - which is normal
(and squashed by setup.py) if we are running from a tarball
"""
if txt i... | [
"def",
"gen_version",
"(",
"do_write",
"=",
"True",
",",
"txt",
"=",
"None",
")",
":",
"if",
"txt",
"is",
"None",
":",
"txt",
"=",
"get_git_describe",
"(",
")",
"try",
":",
"info",
"=",
"VersionInfo",
"(",
"txt",
")",
"vstr",
"=",
"info",
".",
"pac... | https://github.com/couchbase/couchbase-python-client/blob/58ccfd42af320bde6b733acf094fd5a4cf34e0ad/couchbase_version.py#L131-L161 | ||
llSourcell/3D_Pose_Estimation | 87c9d77e3bb0c1105eae74046c26f8b7f101ca45 | src/data_utils.py | python | project_to_cameras | ( poses_set, cams, ncams=4 ) | return t2d | Project 3d poses using camera parameters
Args
poses_set: dictionary with 3d poses
cams: dictionary with camera parameters
ncams: number of cameras per subject
Returns
t2d: dictionary with 2d poses | Project 3d poses using camera parameters | [
"Project",
"3d",
"poses",
"using",
"camera",
"parameters"
] | def project_to_cameras( poses_set, cams, ncams=4 ):
"""
Project 3d poses using camera parameters
Args
poses_set: dictionary with 3d poses
cams: dictionary with camera parameters
ncams: number of cameras per subject
Returns
t2d: dictionary with 2d poses
"""
t2d = {}
for t3dk in sorted( po... | [
"def",
"project_to_cameras",
"(",
"poses_set",
",",
"cams",
",",
"ncams",
"=",
"4",
")",
":",
"t2d",
"=",
"{",
"}",
"for",
"t3dk",
"in",
"sorted",
"(",
"poses_set",
".",
"keys",
"(",
")",
")",
":",
"subj",
",",
"a",
",",
"seqname",
"=",
"t3dk",
"... | https://github.com/llSourcell/3D_Pose_Estimation/blob/87c9d77e3bb0c1105eae74046c26f8b7f101ca45/src/data_utils.py#L337-L362 | |
RichardFrangenberg/Prism | 09283b5146d9cdf9d489dcf252f7927083534a48 | Prism/Plugins/ProjectManagers/Shotgun/external_modules/shotgun_api3/lib/httplib2/python3/__init__.py | python | HmacDigestAuthentication.request | (self, method, request_uri, headers, content) | Modify the request headers | Modify the request headers | [
"Modify",
"the",
"request",
"headers"
] | def request(self, method, request_uri, headers, content):
"""Modify the request headers"""
keys = _get_end2end_headers(headers)
keylist = "".join(["%s " % k for k in keys])
headers_val = "".join([headers[k] for k in keys])
created = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"request_uri",
",",
"headers",
",",
"content",
")",
":",
"keys",
"=",
"_get_end2end_headers",
"(",
"headers",
")",
"keylist",
"=",
"\"\"",
".",
"join",
"(",
"[",
"\"%s \"",
"%",
"k",
"for",
"k",
"in",
... | https://github.com/RichardFrangenberg/Prism/blob/09283b5146d9cdf9d489dcf252f7927083534a48/Prism/Plugins/ProjectManagers/Shotgun/external_modules/shotgun_api3/lib/httplib2/python3/__init__.py#L788-L818 | ||
alanhamlett/pip-update-requirements | ce875601ef278c8ce00ad586434a978731525561 | pur/packages/pip/_vendor/pyparsing.py | python | ParserElement.__rxor__ | (self, other ) | return other ^ self | Implementation of ^ operator when left operand is not a :class:`ParserElement` | Implementation of ^ operator when left operand is not a :class:`ParserElement` | [
"Implementation",
"of",
"^",
"operator",
"when",
"left",
"operand",
"is",
"not",
"a",
":",
"class",
":",
"ParserElement"
] | def __rxor__(self, other ):
"""
Implementation of ^ operator when left operand is not a :class:`ParserElement`
"""
if isinstance( other, basestring ):
other = ParserElement._literalStringClass( other )
if not isinstance( other, ParserElement ):
warnings.wa... | [
"def",
"__rxor__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"basestring",
")",
":",
"other",
"=",
"ParserElement",
".",
"_literalStringClass",
"(",
"other",
")",
"if",
"not",
"isinstance",
"(",
"other",
",",
"ParserElemen... | https://github.com/alanhamlett/pip-update-requirements/blob/ce875601ef278c8ce00ad586434a978731525561/pur/packages/pip/_vendor/pyparsing.py#L2157-L2167 | |
kuri65536/python-for-android | 26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891 | python-modules/zope/zope/interface/common/mapping.py | python | IEnumerableMapping.items | () | Return the items of the mapping object. | Return the items of the mapping object. | [
"Return",
"the",
"items",
"of",
"the",
"mapping",
"object",
"."
] | def items():
"""Return the items of the mapping object.
""" | [
"def",
"items",
"(",
")",
":"
] | https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-modules/zope/zope/interface/common/mapping.py#L71-L73 | ||
invesalius/invesalius3 | 0616d3e73bfe0baf7525877dbf6acab697395eb9 | invesalius/data/coregistration.py | python | tracker_to_image | (m_change, m_probe_ref, r_obj_img, m_obj_raw, s0_dyn) | return m_img | Compute affine transformation matrix to the reference basis
:param m_change: Corregistration transformation obtained from fiducials
:type m_change: numpy.ndarray
:param m_probe_ref: Object or probe in reference coordinate system
:type m_probe_ref: numpy.ndarray
:param r_obj_img: Object coordinate s... | Compute affine transformation matrix to the reference basis | [
"Compute",
"affine",
"transformation",
"matrix",
"to",
"the",
"reference",
"basis"
] | def tracker_to_image(m_change, m_probe_ref, r_obj_img, m_obj_raw, s0_dyn):
"""Compute affine transformation matrix to the reference basis
:param m_change: Corregistration transformation obtained from fiducials
:type m_change: numpy.ndarray
:param m_probe_ref: Object or probe in reference coordinate sys... | [
"def",
"tracker_to_image",
"(",
"m_change",
",",
"m_probe_ref",
",",
"r_obj_img",
",",
"m_obj_raw",
",",
"s0_dyn",
")",
":",
"m_img",
"=",
"m_change",
"@",
"m_probe_ref",
"r_obj",
"=",
"r_obj_img",
"@",
"np",
".",
"linalg",
".",
"inv",
"(",
"m_obj_raw",
")... | https://github.com/invesalius/invesalius3/blob/0616d3e73bfe0baf7525877dbf6acab697395eb9/invesalius/data/coregistration.py#L82-L102 | |
getsentry/sentry | 83b1f25aac3e08075e0e2495bc29efaf35aca18a | src/sentry/charts/base.py | python | ChartRenderer.generate_chart | (self, style: ChartType, data: Any, upload: bool = True) | Produces a chart. You may specify the upload kwarg to have the chart
uploaded to storage and receive a public URL for the chart | Produces a chart. You may specify the upload kwarg to have the chart
uploaded to storage and receive a public URL for the chart | [
"Produces",
"a",
"chart",
".",
"You",
"may",
"specify",
"the",
"upload",
"kwarg",
"to",
"have",
"the",
"chart",
"uploaded",
"to",
"storage",
"and",
"receive",
"a",
"public",
"URL",
"for",
"the",
"chart"
] | def generate_chart(self, style: ChartType, data: Any, upload: bool = True) -> Union[str, bytes]:
"""
Produces a chart. You may specify the upload kwarg to have the chart
uploaded to storage and receive a public URL for the chart
"""
raise NotImplementedError | [
"def",
"generate_chart",
"(",
"self",
",",
"style",
":",
"ChartType",
",",
"data",
":",
"Any",
",",
"upload",
":",
"bool",
"=",
"True",
")",
"->",
"Union",
"[",
"str",
",",
"bytes",
"]",
":",
"raise",
"NotImplementedError"
] | https://github.com/getsentry/sentry/blob/83b1f25aac3e08075e0e2495bc29efaf35aca18a/src/sentry/charts/base.py#L32-L37 | ||
jparkhill/TensorMol | d52104dc7ee46eec8301d332a95d672270ac0bd1 | TensorMol/Simulations/SimpleMD.py | python | NoseThermostat.__init__ | (self,m_,v_) | return | Velocity Verlet step with a Nose-Hoover Thermostat. | Velocity Verlet step with a Nose-Hoover Thermostat. | [
"Velocity",
"Verlet",
"step",
"with",
"a",
"Nose",
"-",
"Hoover",
"Thermostat",
"."
] | def __init__(self,m_,v_):
"""
Velocity Verlet step with a Nose-Hoover Thermostat.
"""
self.m = m_.copy()
self.N = len(m_)
self.T = PARAMS["MDTemp"] # Length of NH chain.
self.eta = 0.0
self.name = "Nose"
self.Rescale(v_)
print("Using ", self.name, " thermostat at ",self.T, " degrees Kelvin")
retu... | [
"def",
"__init__",
"(",
"self",
",",
"m_",
",",
"v_",
")",
":",
"self",
".",
"m",
"=",
"m_",
".",
"copy",
"(",
")",
"self",
".",
"N",
"=",
"len",
"(",
"m_",
")",
"self",
".",
"T",
"=",
"PARAMS",
"[",
"\"MDTemp\"",
"]",
"# Length of NH chain.",
... | https://github.com/jparkhill/TensorMol/blob/d52104dc7ee46eec8301d332a95d672270ac0bd1/TensorMol/Simulations/SimpleMD.py#L91-L102 | |
LKI/chinese-calendar | bbbc7a2df493930f5824ac63e72f6c12160e3e8f | chinese_calendar/scripts/data.py | python | Arrangement.maf | (self) | return self.mark(chinese_calendar.Holiday.mid_autumn_festival) | 中秋节 Mid-autumn Festival | 中秋节 Mid-autumn Festival | [
"中秋节",
"Mid",
"-",
"autumn",
"Festival"
] | def maf(self):
"""中秋节 Mid-autumn Festival"""
return self.mark(chinese_calendar.Holiday.mid_autumn_festival) | [
"def",
"maf",
"(",
"self",
")",
":",
"return",
"self",
".",
"mark",
"(",
"chinese_calendar",
".",
"Holiday",
".",
"mid_autumn_festival",
")"
] | https://github.com/LKI/chinese-calendar/blob/bbbc7a2df493930f5824ac63e72f6c12160e3e8f/chinese_calendar/scripts/data.py#L509-L511 | |
dingjiansw101/RoITransformer_DOTA | 9125055aed313dde7a68882e9931c9ea58c6f6ab | faster_rcnn/core/module.py | python | MutableModule.fit | (self, train_data, eval_data=None, eval_metric='acc',
epoch_end_callback=None, batch_end_callback=None, kvstore='local',
optimizer='sgd', optimizer_params=(('learning_rate', 0.01),),
eval_end_callback=None,
eval_batch_end_callback=None, initializer=Uniform(0.01),
... | Train the module parameters.
Parameters
----------
train_data : DataIter
eval_data : DataIter
If not `None`, will be used as validation set and evaluate the performance
after each epoch.
eval_metric : str or EvalMetric
Default `'acc'`. The per... | Train the module parameters. | [
"Train",
"the",
"module",
"parameters",
"."
] | def fit(self, train_data, eval_data=None, eval_metric='acc',
epoch_end_callback=None, batch_end_callback=None, kvstore='local',
optimizer='sgd', optimizer_params=(('learning_rate', 0.01),),
eval_end_callback=None,
eval_batch_end_callback=None, initializer=Uniform(0.01),
... | [
"def",
"fit",
"(",
"self",
",",
"train_data",
",",
"eval_data",
"=",
"None",
",",
"eval_metric",
"=",
"'acc'",
",",
"epoch_end_callback",
"=",
"None",
",",
"batch_end_callback",
"=",
"None",
",",
"kvstore",
"=",
"'local'",
",",
"optimizer",
"=",
"'sgd'",
"... | https://github.com/dingjiansw101/RoITransformer_DOTA/blob/9125055aed313dde7a68882e9931c9ea58c6f6ab/faster_rcnn/core/module.py#L884-L1026 | ||
open-mmlab/mmdetection | ff9bc39913cb3ff5dde79d3933add7dc2561bab7 | mmdet/core/mask/structures.py | python | polygon_to_bitmap | (polygons, height, width) | return bitmap_mask | Convert masks from the form of polygons to bitmaps.
Args:
polygons (list[ndarray]): masks in polygon representation
height (int): mask height
width (int): mask width
Return:
ndarray: the converted masks in bitmap representation | Convert masks from the form of polygons to bitmaps. | [
"Convert",
"masks",
"from",
"the",
"form",
"of",
"polygons",
"to",
"bitmaps",
"."
] | def polygon_to_bitmap(polygons, height, width):
"""Convert masks from the form of polygons to bitmaps.
Args:
polygons (list[ndarray]): masks in polygon representation
height (int): mask height
width (int): mask width
Return:
ndarray: the converted masks in bitmap representa... | [
"def",
"polygon_to_bitmap",
"(",
"polygons",
",",
"height",
",",
"width",
")",
":",
"rles",
"=",
"maskUtils",
".",
"frPyObjects",
"(",
"polygons",
",",
"height",
",",
"width",
")",
"rle",
"=",
"maskUtils",
".",
"merge",
"(",
"rles",
")",
"bitmap_mask",
"... | https://github.com/open-mmlab/mmdetection/blob/ff9bc39913cb3ff5dde79d3933add7dc2561bab7/mmdet/core/mask/structures.py#L1057-L1071 | |
spyder-ide/spyder | 55da47c032dfcf519600f67f8b30eab467f965e7 | external-deps/spyder-kernels/spyder_kernels/console/kernel.py | python | SpyderKernel.is_defined | (self, obj, force_import=False) | return isdefined(obj, force_import=force_import, namespace=ns) | Return True if object is defined in current namespace | Return True if object is defined in current namespace | [
"Return",
"True",
"if",
"object",
"is",
"defined",
"in",
"current",
"namespace"
] | def is_defined(self, obj, force_import=False):
"""Return True if object is defined in current namespace"""
from spyder_kernels.utils.dochelpers import isdefined
ns = self._get_current_namespace(with_magics=True)
return isdefined(obj, force_import=force_import, namespace=ns) | [
"def",
"is_defined",
"(",
"self",
",",
"obj",
",",
"force_import",
"=",
"False",
")",
":",
"from",
"spyder_kernels",
".",
"utils",
".",
"dochelpers",
"import",
"isdefined",
"ns",
"=",
"self",
".",
"_get_current_namespace",
"(",
"with_magics",
"=",
"True",
")... | https://github.com/spyder-ide/spyder/blob/55da47c032dfcf519600f67f8b30eab467f965e7/external-deps/spyder-kernels/spyder_kernels/console/kernel.py#L403-L408 | |
getalp/Flaubert | ded1cf89820a22dbf885c85ba3dccc8ab360681b | xlm/trainer.py | python | Trainer.__init__ | (self, data, params) | Initialize trainer. | Initialize trainer. | [
"Initialize",
"trainer",
"."
] | def __init__(self, data, params):
"""
Initialize trainer.
"""
# epoch / iteration size
self.epoch_size = params.epoch_size
if self.epoch_size == -1:
self.epoch_size = self.data
assert self.epoch_size > 0
# data iterators
self.itera... | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"params",
")",
":",
"# epoch / iteration size",
"self",
".",
"epoch_size",
"=",
"params",
".",
"epoch_size",
"if",
"self",
".",
"epoch_size",
"==",
"-",
"1",
":",
"self",
".",
"epoch_size",
"=",
"self",
"... | https://github.com/getalp/Flaubert/blob/ded1cf89820a22dbf885c85ba3dccc8ab360681b/xlm/trainer.py#L34-L155 | ||
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit - MAC OSX/tools/inject/lib/core/common.py | python | Backend.isVersionGreaterOrEqualThan | (version) | return Backend.getVersion() is not None and str(Backend.getVersion()) >= str(version) | [] | def isVersionGreaterOrEqualThan(version):
return Backend.getVersion() is not None and str(Backend.getVersion()) >= str(version) | [
"def",
"isVersionGreaterOrEqualThan",
"(",
"version",
")",
":",
"return",
"Backend",
".",
"getVersion",
"(",
")",
"is",
"not",
"None",
"and",
"str",
"(",
"Backend",
".",
"getVersion",
"(",
")",
")",
">=",
"str",
"(",
"version",
")"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/tools/inject/lib/core/common.py#L532-L533 | |||
balajiln/mondrianforest | eac11fe085160daf56f4e8c6226d0400b78c3908 | src/mondrianforest.py | python | MondrianTree.gen_node_ids_print | (self) | generate binary string label for each node
root_node is denoted by empty string "e"
all other node labels are defined as follows: left(j) = j0, right(j) = j1
e.g. left and right child of root_node are 0 and 1 respectively,
left and right of node 0 are 00 and 01 respectively and so ... | generate binary string label for each node
root_node is denoted by empty string "e"
all other node labels are defined as follows: left(j) = j0, right(j) = j1
e.g. left and right child of root_node are 0 and 1 respectively,
left and right of node 0 are 00 and 01 respectively and so ... | [
"generate",
"binary",
"string",
"label",
"for",
"each",
"node",
"root_node",
"is",
"denoted",
"by",
"empty",
"string",
"e",
"all",
"other",
"node",
"labels",
"are",
"defined",
"as",
"follows",
":",
"left",
"(",
"j",
")",
"=",
"j0",
"right",
"(",
"j",
"... | def gen_node_ids_print(self):
"""
generate binary string label for each node
root_node is denoted by empty string "e"
all other node labels are defined as follows: left(j) = j0, right(j) = j1
e.g. left and right child of root_node are 0 and 1 respectively,
left and ... | [
"def",
"gen_node_ids_print",
"(",
"self",
")",
":",
"node_ids",
"=",
"[",
"self",
".",
"root",
"]",
"self",
".",
"node_ids_print",
"=",
"{",
"self",
".",
"root",
":",
"''",
"}",
"while",
"node_ids",
":",
"node_id",
"=",
"node_ids",
".",
"pop",
"(",
"... | https://github.com/balajiln/mondrianforest/blob/eac11fe085160daf56f4e8c6226d0400b78c3908/src/mondrianforest.py#L317-L337 | ||
demisto/content | 5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07 | Packs/CarbonBlackDefense/Integrations/CarbonBlackEndpointStandard/CarbonBlackEndpointStandard.py | python | Client.search_alerts_request | (self, suffix_url_path: str = None, minimum_severity: int = None, create_time: Dict = None,
policy_id: List = None, device_username: List = None, device_id: List = None,
query: str = None, alert_category: List = None, sort_field: str = "create_time",
... | return self._http_request('POST', suffix_url, headers=self.headers, json_data=body) | Searches for Carbon Black alerts using the '/appservices/v6/orgs/{org_key}/alerts/_search' API endpoint
All the parameters are passed directly to the API as HTTP POST parameters in the request
:type suffix_url_path: ``Optional[str]``
:param suffix_url_path: type of the alert to search for. Opt... | Searches for Carbon Black alerts using the '/appservices/v6/orgs/{org_key}/alerts/_search' API endpoint | [
"Searches",
"for",
"Carbon",
"Black",
"alerts",
"using",
"the",
"/",
"appservices",
"/",
"v6",
"/",
"orgs",
"/",
"{",
"org_key",
"}",
"/",
"alerts",
"/",
"_search",
"API",
"endpoint"
] | def search_alerts_request(self, suffix_url_path: str = None, minimum_severity: int = None, create_time: Dict = None,
policy_id: List = None, device_username: List = None, device_id: List = None,
query: str = None, alert_category: List = None, sort_field: str =... | [
"def",
"search_alerts_request",
"(",
"self",
",",
"suffix_url_path",
":",
"str",
"=",
"None",
",",
"minimum_severity",
":",
"int",
"=",
"None",
",",
"create_time",
":",
"Dict",
"=",
"None",
",",
"policy_id",
":",
"List",
"=",
"None",
",",
"device_username",
... | https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/CarbonBlackDefense/Integrations/CarbonBlackEndpointStandard/CarbonBlackEndpointStandard.py#L65-L137 | |
kanzure/nanoengineer | 874e4c9f8a9190f093625b267f9767e19f82e6c4 | cad/src/dna/commands/OrderDna/OrderDna_PropertyManager.py | python | OrderDna_PropertyManager._update_UI_do_updates | (self) | return | Overrides superclass method. | Overrides superclass method. | [
"Overrides",
"superclass",
"method",
"."
] | def _update_UI_do_updates(self):
"""
Overrides superclass method.
"""
self.update_includeStrands()
return | [
"def",
"_update_UI_do_updates",
"(",
"self",
")",
":",
"self",
".",
"update_includeStrands",
"(",
")",
"return"
] | https://github.com/kanzure/nanoengineer/blob/874e4c9f8a9190f093625b267f9767e19f82e6c4/cad/src/dna/commands/OrderDna/OrderDna_PropertyManager.py#L257-L262 | |
CuriousAI/mean-teacher | 546348ff863c998c26be4339021425df973b4a36 | tensorflow/mean_teacher/nn.py | python | flip_randomly | (inputs, horizontally, vertically, is_training, name=None) | Flip images randomly. Make separate flipping decision for each image.
Args:
inputs (4-D tensor): Input images (batch size, height, width, channels).
horizontally (bool): If True, flip horizontally with 50% probability. Otherwise, don't.
vertically (bool): If True, flip vertically with 50% p... | Flip images randomly. Make separate flipping decision for each image. | [
"Flip",
"images",
"randomly",
".",
"Make",
"separate",
"flipping",
"decision",
"for",
"each",
"image",
"."
] | def flip_randomly(inputs, horizontally, vertically, is_training, name=None):
"""Flip images randomly. Make separate flipping decision for each image.
Args:
inputs (4-D tensor): Input images (batch size, height, width, channels).
horizontally (bool): If True, flip horizontally with 50% probabili... | [
"def",
"flip_randomly",
"(",
"inputs",
",",
"horizontally",
",",
"vertically",
",",
"is_training",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
",",
"\"flip_randomly\"",
")",
"as",
"scope",
":",
"batch_size",
",",
"heig... | https://github.com/CuriousAI/mean-teacher/blob/546348ff863c998c26be4339021425df973b4a36/tensorflow/mean_teacher/nn.py#L31-L51 | ||
gammapy/gammapy | 735b25cd5bbed35e2004d633621896dcd5295e8b | gammapy/data/event_list.py | python | EventList.plot_time | (self, ax=None, **kwargs) | return ax | Plots an event rate time curve.
Parameters
----------
ax : `~matplotlib.axes.Axes` or None
Axes
**kwargs : dict
Keyword arguments passed to `~matplotlib.pyplot.errorbar`
Returns
-------
ax : `~matplotlib.axes.Axes`
Axes | Plots an event rate time curve. | [
"Plots",
"an",
"event",
"rate",
"time",
"curve",
"."
] | def plot_time(self, ax=None, **kwargs):
"""Plots an event rate time curve.
Parameters
----------
ax : `~matplotlib.axes.Axes` or None
Axes
**kwargs : dict
Keyword arguments passed to `~matplotlib.pyplot.errorbar`
Returns
-------
a... | [
"def",
"plot_time",
"(",
"self",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"if",
"ax",
"is",
"None",
"else",
"ax",
"# Note the events are not... | https://github.com/gammapy/gammapy/blob/735b25cd5bbed35e2004d633621896dcd5295e8b/gammapy/data/event_list.py#L351-L386 | |
inducer/pyopencl | 71b29745dc023a4d3aa9ddf22ff65c0cb3e6d703 | pyopencl/clrandom.py | python | fill_rand | (result, queue=None, luxury=None, a=0, b=1) | Fill *result* with random values of `dtype` in the range [0,1). | Fill *result* with random values of `dtype` in the range [0,1). | [
"Fill",
"*",
"result",
"*",
"with",
"random",
"values",
"of",
"dtype",
"in",
"the",
"range",
"[",
"0",
"1",
")",
"."
] | def fill_rand(result, queue=None, luxury=None, a=0, b=1):
"""Fill *result* with random values of `dtype` in the range [0,1).
"""
if luxury is not None:
from warnings import warn
warn("Specifying the 'luxury' argument is deprecated and will stop being "
"supported in PyOpenCL ... | [
"def",
"fill_rand",
"(",
"result",
",",
"queue",
"=",
"None",
",",
"luxury",
"=",
"None",
",",
"a",
"=",
"0",
",",
"b",
"=",
"1",
")",
":",
"if",
"luxury",
"is",
"not",
"None",
":",
"from",
"warnings",
"import",
"warn",
"warn",
"(",
"\"Specifying t... | https://github.com/inducer/pyopencl/blob/71b29745dc023a4d3aa9ddf22ff65c0cb3e6d703/pyopencl/clrandom.py#L740-L751 | ||
sumanj/frankencert | 5bbaae85cab35882dec1672ef037a42e29180b40 | pyopenssl-19.1.0/src/OpenSSL/crypto.py | python | load_pkcs12 | (buffer, passphrase=None) | return pkcs12 | Load pkcs12 data from the string *buffer*. If the pkcs12 structure is
encrypted, a *passphrase* must be included. The MAC is always
checked and thus required.
See also the man page for the C function :py:func:`PKCS12_parse`.
:param buffer: The buffer the certificate is stored in
:param passphrase... | Load pkcs12 data from the string *buffer*. If the pkcs12 structure is
encrypted, a *passphrase* must be included. The MAC is always
checked and thus required. | [
"Load",
"pkcs12",
"data",
"from",
"the",
"string",
"*",
"buffer",
"*",
".",
"If",
"the",
"pkcs12",
"structure",
"is",
"encrypted",
"a",
"*",
"passphrase",
"*",
"must",
"be",
"included",
".",
"The",
"MAC",
"is",
"always",
"checked",
"and",
"thus",
"requir... | def load_pkcs12(buffer, passphrase=None):
"""
Load pkcs12 data from the string *buffer*. If the pkcs12 structure is
encrypted, a *passphrase* must be included. The MAC is always
checked and thus required.
See also the man page for the C function :py:func:`PKCS12_parse`.
:param buffer: The buf... | [
"def",
"load_pkcs12",
"(",
"buffer",
",",
"passphrase",
"=",
"None",
")",
":",
"passphrase",
"=",
"_text_to_bytes_and_warn",
"(",
"\"passphrase\"",
",",
"passphrase",
")",
"if",
"isinstance",
"(",
"buffer",
",",
"_text_type",
")",
":",
"buffer",
"=",
"buffer",... | https://github.com/sumanj/frankencert/blob/5bbaae85cab35882dec1672ef037a42e29180b40/pyopenssl-19.1.0/src/OpenSSL/crypto.py#L3002-L3086 | |
trailofbits/manticore | b050fdf0939f6c63f503cdf87ec0ab159dd41159 | manticore/ethereum/detectors.py | python | DetectIntegerOverflow._unsigned_mul_overflow | (state, a, b) | return cond | Sign extend the value to 512 bits and check the result can be represented
in 256. Following there is a 32 bit excerpt of this condition:
a * b +00000000000000000 +00000000000000001 +0000000003fffffff +0000000007fffffff +00000000080000001 +000000000bfffffff +000000000ffffffff
+00000... | Sign extend the value to 512 bits and check the result can be represented
in 256. Following there is a 32 bit excerpt of this condition: | [
"Sign",
"extend",
"the",
"value",
"to",
"512",
"bits",
"and",
"check",
"the",
"result",
"can",
"be",
"represented",
"in",
"256",
".",
"Following",
"there",
"is",
"a",
"32",
"bit",
"excerpt",
"of",
"this",
"condition",
":"
] | def _unsigned_mul_overflow(state, a, b):
"""
Sign extend the value to 512 bits and check the result can be represented
in 256. Following there is a 32 bit excerpt of this condition:
a * b +00000000000000000 +00000000000000001 +0000000003fffffff +0000000007fffffff +000000000... | [
"def",
"_unsigned_mul_overflow",
"(",
"state",
",",
"a",
",",
"b",
")",
":",
"mul",
"=",
"Operators",
".",
"SEXTEND",
"(",
"a",
",",
"256",
",",
"512",
")",
"*",
"Operators",
".",
"SEXTEND",
"(",
"b",
",",
"256",
",",
"512",
")",
"cond",
"=",
"Op... | https://github.com/trailofbits/manticore/blob/b050fdf0939f6c63f503cdf87ec0ab159dd41159/manticore/ethereum/detectors.py#L480-L497 | |
IronLanguages/main | a949455434b1fda8c783289e897e78a9a0caabb5 | External.LCA_RESTRICTED/Languages/CPython/27/Lib/weakref.py | python | WeakValueDictionary.itervaluerefs | (self) | return self.data.itervalues() | Return an iterator that yields the weak references to the values.
The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used. This can be used to avoid
creating references that will cause the g... | Return an iterator that yields the weak references to the values. | [
"Return",
"an",
"iterator",
"that",
"yields",
"the",
"weak",
"references",
"to",
"the",
"values",
"."
] | def itervaluerefs(self):
"""Return an iterator that yields the weak references to the values.
The references are not guaranteed to be 'live' at the time
they are used, so the result of calling the references needs
to be checked before being used. This can be used to avoid
creat... | [
"def",
"itervaluerefs",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
".",
"itervalues",
"(",
")"
] | https://github.com/IronLanguages/main/blob/a949455434b1fda8c783289e897e78a9a0caabb5/External.LCA_RESTRICTED/Languages/CPython/27/Lib/weakref.py#L134-L144 | |
internetarchive/openlibrary | 33b9b005ecb0adeda690c67952f5ae5f1fe3a8d8 | openlibrary/plugins/upstream/utils.py | python | kebab_case | (upper_camel_case) | return '-'.join(parts).lower() | :param str upper_camel_case: Text in upper camel case (e.g. "HelloWorld")
:return: text in kebab case (e.g. 'hello-world')
>>> kebab_case('HelloWorld')
'hello-world'
>>> kebab_case("MergeUI")
'merge-u-i' | :param str upper_camel_case: Text in upper camel case (e.g. "HelloWorld")
:return: text in kebab case (e.g. 'hello-world') | [
":",
"param",
"str",
"upper_camel_case",
":",
"Text",
"in",
"upper",
"camel",
"case",
"(",
"e",
".",
"g",
".",
"HelloWorld",
")",
":",
"return",
":",
"text",
"in",
"kebab",
"case",
"(",
"e",
".",
"g",
".",
"hello",
"-",
"world",
")"
] | def kebab_case(upper_camel_case):
"""
:param str upper_camel_case: Text in upper camel case (e.g. "HelloWorld")
:return: text in kebab case (e.g. 'hello-world')
>>> kebab_case('HelloWorld')
'hello-world'
>>> kebab_case("MergeUI")
'merge-u-i'
"""
parts = re.findall(r'[A-Z][^A-Z]*', u... | [
"def",
"kebab_case",
"(",
"upper_camel_case",
")",
":",
"parts",
"=",
"re",
".",
"findall",
"(",
"r'[A-Z][^A-Z]*'",
",",
"upper_camel_case",
")",
"return",
"'-'",
".",
"join",
"(",
"parts",
")",
".",
"lower",
"(",
")"
] | https://github.com/internetarchive/openlibrary/blob/33b9b005ecb0adeda690c67952f5ae5f1fe3a8d8/openlibrary/plugins/upstream/utils.py#L123-L134 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.