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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework | cb692f527e4e819b6c228187c5702d990a180043 | external/Scripting Engine/Xenotix Python Scripting Engine/Lib/whichdb.py | python | whichdb | (filename) | return "" | Guess which db package to use to open a db file.
Return values:
- None if the database file can't be read;
- empty string if the file can be read but can't be recognized
- the module name (e.g. "dbm" or "gdbm") if recognized.
Importing the given module may still fail, and opening the
database... | Guess which db package to use to open a db file. | [
"Guess",
"which",
"db",
"package",
"to",
"use",
"to",
"open",
"a",
"db",
"file",
"."
] | def whichdb(filename):
"""Guess which db package to use to open a db file.
Return values:
- None if the database file can't be read;
- empty string if the file can be read but can't be recognized
- the module name (e.g. "dbm" or "gdbm") if recognized.
Importing the given module may still fail... | [
"def",
"whichdb",
"(",
"filename",
")",
":",
"# Check for dbm first -- this has a .pag and a .dir file",
"try",
":",
"f",
"=",
"open",
"(",
"filename",
"+",
"os",
".",
"extsep",
"+",
"\"pag\"",
",",
"\"rb\"",
")",
"f",
".",
"close",
"(",
")",
"# dbm linked wit... | https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/Lib/whichdb.py#L17-L113 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/whitenoise/static_file.py | python | get_alternative_encoding | (path, headers, suffix, encoding) | return alt_path, alt_headers | [] | def get_alternative_encoding(path, headers, suffix, encoding):
alt_path = path + suffix
try:
alt_size = stat_regular_file(alt_path).st_size
except MissingFileError:
return None
alt_headers = Headers(headers.items())
alt_headers['Vary'] = 'Accept-Encoding'
alt_headers['Content-Enc... | [
"def",
"get_alternative_encoding",
"(",
"path",
",",
"headers",
",",
"suffix",
",",
"encoding",
")",
":",
"alt_path",
"=",
"path",
"+",
"suffix",
"try",
":",
"alt_size",
"=",
"stat_regular_file",
"(",
"alt_path",
")",
".",
"st_size",
"except",
"MissingFileErro... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/whitenoise/static_file.py#L77-L87 | |||
tensorlayer/tensorlayer | cb4eb896dd063e650ef22533ed6fa6056a71cad5 | tensorlayer/prepro.py | python | obj_box_coord_centroid_to_upleft_butright | (coord, to_int=False) | Convert one coordinate [x_center, y_center, w, h] to [x1, y1, x2, y2] in up-left and botton-right format.
Parameters
------------
coord : list of 4 int/float
One coordinate.
to_int : boolean
Whether to convert output as integer.
Returns
-------
list of 4 numbers
New... | Convert one coordinate [x_center, y_center, w, h] to [x1, y1, x2, y2] in up-left and botton-right format. | [
"Convert",
"one",
"coordinate",
"[",
"x_center",
"y_center",
"w",
"h",
"]",
"to",
"[",
"x1",
"y1",
"x2",
"y2",
"]",
"in",
"up",
"-",
"left",
"and",
"botton",
"-",
"right",
"format",
"."
] | def obj_box_coord_centroid_to_upleft_butright(coord, to_int=False):
"""Convert one coordinate [x_center, y_center, w, h] to [x1, y1, x2, y2] in up-left and botton-right format.
Parameters
------------
coord : list of 4 int/float
One coordinate.
to_int : boolean
Whether to convert ou... | [
"def",
"obj_box_coord_centroid_to_upleft_butright",
"(",
"coord",
",",
"to_int",
"=",
"False",
")",
":",
"if",
"len",
"(",
"coord",
")",
"!=",
"4",
":",
"raise",
"AssertionError",
"(",
"\"coordinate should be 4 values : [x, y, w, h]\"",
")",
"x_center",
",",
"y_cent... | https://github.com/tensorlayer/tensorlayer/blob/cb4eb896dd063e650ef22533ed6fa6056a71cad5/tensorlayer/prepro.py#L2497-L2529 | ||
brosner/everyblock_code | 25397148223dad81e7fbb9c7cf2f169162df4681 | ebpub/ebpub/db/templatetags/mapping.py | python | _get_marker_radius | (normalized_value) | return int(round(((MAX_MARKER_RADIUS - MIN_MARKER_RADIUS) * normalized_value) + MIN_MARKER_RADIUS)) | Assumes `normalized_value` is in the range 0.0 and 1.0 | Assumes `normalized_value` is in the range 0.0 and 1.0 | [
"Assumes",
"normalized_value",
"is",
"in",
"the",
"range",
"0",
".",
"0",
"and",
"1",
".",
"0"
] | def _get_marker_radius(normalized_value):
"""
Assumes `normalized_value` is in the range 0.0 and 1.0
"""
return int(round(((MAX_MARKER_RADIUS - MIN_MARKER_RADIUS) * normalized_value) + MIN_MARKER_RADIUS)) | [
"def",
"_get_marker_radius",
"(",
"normalized_value",
")",
":",
"return",
"int",
"(",
"round",
"(",
"(",
"(",
"MAX_MARKER_RADIUS",
"-",
"MIN_MARKER_RADIUS",
")",
"*",
"normalized_value",
")",
"+",
"MIN_MARKER_RADIUS",
")",
")"
] | https://github.com/brosner/everyblock_code/blob/25397148223dad81e7fbb9c7cf2f169162df4681/ebpub/ebpub/db/templatetags/mapping.py#L22-L26 | |
AcidWeb/CurseBreaker | 1a8cb60f4db0cc8b7e0702441e1adc0f1829003e | CurseBreaker.py | python | TUI.c_uri_integration | (self, _) | [] | def c_uri_integration(self, _):
if self.os == 'Windows':
self.core.create_reg()
self.console.print('CurseBreaker.reg file was created. Attempting to import...')
out = os.system('"' + str(Path(os.path.dirname(sys.executable), 'CurseBreaker.reg')) + '"')
if out != 0... | [
"def",
"c_uri_integration",
"(",
"self",
",",
"_",
")",
":",
"if",
"self",
".",
"os",
"==",
"'Windows'",
":",
"self",
".",
"core",
".",
"create_reg",
"(",
")",
"self",
".",
"console",
".",
"print",
"(",
"'CurseBreaker.reg file was created. Attempting to import... | https://github.com/AcidWeb/CurseBreaker/blob/1a8cb60f4db0cc8b7e0702441e1adc0f1829003e/CurseBreaker.py#L635-L645 | ||||
dimagi/commcare-hq | d67ff1d3b4c51fa050c19e60c3253a79d3452a39 | corehq/apps/export/models/new.py | python | TableConfiguration._regenerate_column_cache | (self) | [] | def _regenerate_column_cache(self):
self._string_column_paths = [
self._create_index(column.item.path, column.item.transform)
for column in self.columns
] | [
"def",
"_regenerate_column_cache",
"(",
"self",
")",
":",
"self",
".",
"_string_column_paths",
"=",
"[",
"self",
".",
"_create_index",
"(",
"column",
".",
"item",
".",
"path",
",",
"column",
".",
"item",
".",
"transform",
")",
"for",
"column",
"in",
"self"... | https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/export/models/new.py#L560-L564 | ||||
openstack/heat | ea6633c35b04bb49c4a2858edc9df0a82d039478 | heat/engine/template.py | python | Template.param_schemata | (self, param_defaults=None) | Return a dict of parameters.Schema objects for the parameters. | Return a dict of parameters.Schema objects for the parameters. | [
"Return",
"a",
"dict",
"of",
"parameters",
".",
"Schema",
"objects",
"for",
"the",
"parameters",
"."
] | def param_schemata(self, param_defaults=None):
"""Return a dict of parameters.Schema objects for the parameters."""
pass | [
"def",
"param_schemata",
"(",
"self",
",",
"param_defaults",
"=",
"None",
")",
":",
"pass"
] | https://github.com/openstack/heat/blob/ea6633c35b04bb49c4a2858edc9df0a82d039478/heat/engine/template.py#L194-L196 | ||
JaniceWuo/MovieRecommend | 4c86db64ca45598917d304f535413df3bc9fea65 | movierecommend/venv1/Lib/site-packages/django/contrib/gis/measure.py | python | Distance.__mul__ | (self, other) | [] | def __mul__(self, other):
if isinstance(other, self.__class__):
return Area(
default_unit=AREA_PREFIX + self._default_unit,
**{AREA_PREFIX + self.STANDARD_UNIT: (self.standard * other.standard)}
)
elif isinstance(other, NUMERIC_TYPES):
... | [
"def",
"__mul__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"return",
"Area",
"(",
"default_unit",
"=",
"AREA_PREFIX",
"+",
"self",
".",
"_default_unit",
",",
"*",
"*",
"{",
"AREA_PR... | https://github.com/JaniceWuo/MovieRecommend/blob/4c86db64ca45598917d304f535413df3bc9fea65/movierecommend/venv1/Lib/site-packages/django/contrib/gis/measure.py#L308-L322 | ||||
biolab/orange2 | db40a9449cb45b507d63dcd5739b223f9cffb8e6 | Orange/OrangeCanvas/canvas/items/annotationitem.py | python | ArrowAnnotation.line | (self) | return QLineF(self.__line) | Return the arrow base line (`QLineF` in object coordinates). | Return the arrow base line (`QLineF` in object coordinates). | [
"Return",
"the",
"arrow",
"base",
"line",
"(",
"QLineF",
"in",
"object",
"coordinates",
")",
"."
] | def line(self):
"""
Return the arrow base line (`QLineF` in object coordinates).
"""
return QLineF(self.__line) | [
"def",
"line",
"(",
"self",
")",
":",
"return",
"QLineF",
"(",
"self",
".",
"__line",
")"
] | https://github.com/biolab/orange2/blob/db40a9449cb45b507d63dcd5739b223f9cffb8e6/Orange/OrangeCanvas/canvas/items/annotationitem.py#L528-L532 | |
great-expectations/great_expectations | 45224cb890aeae725af25905923d0dbbab2d969d | great_expectations/data_context/data_context.py | python | BaseDataContext.__init__ | (
self,
project_config,
context_root_dir=None,
runtime_environment=None,
ge_cloud_mode=False,
ge_cloud_config=None,
) | DataContext constructor
Args:
context_root_dir: location to look for the ``great_expectations.yml`` file. If None, searches for the file \
based on conventions for project subdirectories.
runtime_environment: a dictionary of config variables that
override both th... | DataContext constructor | [
"DataContext",
"constructor"
] | def __init__(
self,
project_config,
context_root_dir=None,
runtime_environment=None,
ge_cloud_mode=False,
ge_cloud_config=None,
):
"""DataContext constructor
Args:
context_root_dir: location to look for the ``great_expectations.yml`` file.... | [
"def",
"__init__",
"(",
"self",
",",
"project_config",
",",
"context_root_dir",
"=",
"None",
",",
"runtime_environment",
"=",
"None",
",",
"ge_cloud_mode",
"=",
"False",
",",
"ge_cloud_config",
"=",
"None",
",",
")",
":",
"if",
"not",
"BaseDataContext",
".",
... | https://github.com/great-expectations/great_expectations/blob/45224cb890aeae725af25905923d0dbbab2d969d/great_expectations/data_context/data_context.py#L308-L394 | ||
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/nova/nova/network/floating_ips.py | python | FloatingIP.init_host_floating_ips | (self) | Configures floating ips owned by host. | Configures floating ips owned by host. | [
"Configures",
"floating",
"ips",
"owned",
"by",
"host",
"."
] | def init_host_floating_ips(self):
"""Configures floating ips owned by host."""
admin_context = context.get_admin_context()
try:
floating_ips = self.db.floating_ip_get_all_by_host(admin_context,
self.host)
except ... | [
"def",
"init_host_floating_ips",
"(",
"self",
")",
":",
"admin_context",
"=",
"context",
".",
"get_admin_context",
"(",
")",
"try",
":",
"floating_ips",
"=",
"self",
".",
"db",
".",
"floating_ip_get_all_by_host",
"(",
"admin_context",
",",
"self",
".",
"host",
... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/nova/nova/network/floating_ips.py#L69-L98 | ||
Qirky/FoxDot | 76318f9630bede48ff3994146ed644affa27bfa4 | FoxDot/lib/TimeVar.py | python | mapvar.now | (self, time=None) | return self.current_value | Returns the value currently represented by this TimeVar | Returns the value currently represented by this TimeVar | [
"Returns",
"the",
"value",
"currently",
"represented",
"by",
"this",
"TimeVar"
] | def now(self, time=None):
""" Returns the value currently represented by this TimeVar """
i = self.get_current_index(time)
self.current_value = self.calculate(self.values.get(i, self.default))
return self.current_value | [
"def",
"now",
"(",
"self",
",",
"time",
"=",
"None",
")",
":",
"i",
"=",
"self",
".",
"get_current_index",
"(",
"time",
")",
"self",
".",
"current_value",
"=",
"self",
".",
"calculate",
"(",
"self",
".",
"values",
".",
"get",
"(",
"i",
",",
"self",... | https://github.com/Qirky/FoxDot/blob/76318f9630bede48ff3994146ed644affa27bfa4/FoxDot/lib/TimeVar.py#L834-L838 | |
numenta/nupic | b9ebedaf54f49a33de22d8d44dff7c765cdb5548 | external/linux32/lib/python2.6/site-packages/matplotlib/backends/backend_wx.py | python | new_figure_manager | (num, *args, **kwargs) | return figmgr | Create a new figure manager instance | Create a new figure manager instance | [
"Create",
"a",
"new",
"figure",
"manager",
"instance"
] | def new_figure_manager(num, *args, **kwargs):
"""
Create a new figure manager instance
"""
# in order to expose the Figure constructor to the pylab
# interface we need to create the figure here
DEBUG_MSG("new_figure_manager()", 3, None)
_create_wx_app()
FigureClass = kwargs.pop('FigureC... | [
"def",
"new_figure_manager",
"(",
"num",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# in order to expose the Figure constructor to the pylab",
"# interface we need to create the figure here",
"DEBUG_MSG",
"(",
"\"new_figure_manager()\"",
",",
"3",
",",
"None",
... | https://github.com/numenta/nupic/blob/b9ebedaf54f49a33de22d8d44dff7c765cdb5548/external/linux32/lib/python2.6/site-packages/matplotlib/backends/backend_wx.py#L1339-L1355 | |
nschaetti/EchoTorch | cba209c49e0fda73172d2e853b85c747f9f5117e | echotorch/data/datasets/TimeseriesDataset.py | python | TimeseriesDataset.global_transform | (self) | return self._global_transform | Global transform (GET)
:return: A Transformer object | Global transform (GET)
:return: A Transformer object | [
"Global",
"transform",
"(",
"GET",
")",
":",
"return",
":",
"A",
"Transformer",
"object"
] | def global_transform(self) -> Transformer:
"""
Global transform (GET)
:return: A Transformer object
"""
return self._global_transform | [
"def",
"global_transform",
"(",
"self",
")",
"->",
"Transformer",
":",
"return",
"self",
".",
"_global_transform"
] | https://github.com/nschaetti/EchoTorch/blob/cba209c49e0fda73172d2e853b85c747f9f5117e/echotorch/data/datasets/TimeseriesDataset.py#L177-L182 | |
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit - MAC OSX/tools/sqli/plugins/generic/connector.py | python | Connector.execute | (self, query) | [] | def execute(self, query):
errMsg = "'execute' method must be defined "
errMsg += "into the specific DBMS plugin"
raise SqlmapUndefinedMethod(errMsg) | [
"def",
"execute",
"(",
"self",
",",
"query",
")",
":",
"errMsg",
"=",
"\"'execute' method must be defined \"",
"errMsg",
"+=",
"\"into the specific DBMS plugin\"",
"raise",
"SqlmapUndefinedMethod",
"(",
"errMsg",
")"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/tools/sqli/plugins/generic/connector.py#L73-L76 | ||||
roclark/sportsipy | c19f545d3376d62ded6304b137dc69238ac620a9 | sportsipy/nfl/boxscore.py | python | BoxscorePlayer.solo_tackles | (self) | return self._solo_tackles | Returns an ``int`` of the number of solo tackles the player made during
the game. | Returns an ``int`` of the number of solo tackles the player made during
the game. | [
"Returns",
"an",
"int",
"of",
"the",
"number",
"of",
"solo",
"tackles",
"the",
"player",
"made",
"during",
"the",
"game",
"."
] | def solo_tackles(self):
"""
Returns an ``int`` of the number of solo tackles the player made during
the game.
"""
return self._solo_tackles | [
"def",
"solo_tackles",
"(",
"self",
")",
":",
"return",
"self",
".",
"_solo_tackles"
] | https://github.com/roclark/sportsipy/blob/c19f545d3376d62ded6304b137dc69238ac620a9/sportsipy/nfl/boxscore.py#L180-L185 | |
misterch0c/shadowbroker | e3a069bea47a2c1009697941ac214adc6f90aa8d | windows/Resources/Python/Core/Lib/lib-tk/Tkinter.py | python | Misc.winfo_depth | (self) | return getint(self.tk.call('winfo', 'depth', self._w)) | Return the number of bits per pixel. | Return the number of bits per pixel. | [
"Return",
"the",
"number",
"of",
"bits",
"per",
"pixel",
"."
] | def winfo_depth(self):
"""Return the number of bits per pixel."""
return getint(self.tk.call('winfo', 'depth', self._w)) | [
"def",
"winfo_depth",
"(",
"self",
")",
":",
"return",
"getint",
"(",
"self",
".",
"tk",
".",
"call",
"(",
"'winfo'",
",",
"'depth'",
",",
"self",
".",
"_w",
")",
")"
] | https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/lib-tk/Tkinter.py#L809-L811 | |
gammapy/gammapy | 735b25cd5bbed35e2004d633621896dcd5295e8b | gammapy/data/hdu_index_table.py | python | HDUIndexTable.hdu_type_unique | (self) | return list(np.unique(np.sort([_.strip() for _ in self["HDU_TYPE"]]))) | HDU types (unique). | HDU types (unique). | [
"HDU",
"types",
"(",
"unique",
")",
"."
] | def hdu_type_unique(self):
"""HDU types (unique)."""
return list(np.unique(np.sort([_.strip() for _ in self["HDU_TYPE"]]))) | [
"def",
"hdu_type_unique",
"(",
"self",
")",
":",
"return",
"list",
"(",
"np",
".",
"unique",
"(",
"np",
".",
"sort",
"(",
"[",
"_",
".",
"strip",
"(",
")",
"for",
"_",
"in",
"self",
"[",
"\"HDU_TYPE\"",
"]",
"]",
")",
")",
")"
] | https://github.com/gammapy/gammapy/blob/735b25cd5bbed35e2004d633621896dcd5295e8b/gammapy/data/hdu_index_table.py#L175-L177 | |
styxit/HTPC-Manager | 490697460b4fa1797106aece27d873bc256b2ff1 | libs/requests/packages/urllib3/poolmanager.py | python | PoolManager.clear | (self) | Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be
re-used after completion. | Empty our store of pools and direct them all to close. | [
"Empty",
"our",
"store",
"of",
"pools",
"and",
"direct",
"them",
"all",
"to",
"close",
"."
] | def clear(self):
"""
Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be
re-used after completion.
"""
self.pools.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"pools",
".",
"clear",
"(",
")"
] | https://github.com/styxit/HTPC-Manager/blob/490697460b4fa1797106aece27d873bc256b2ff1/libs/requests/packages/urllib3/poolmanager.py#L81-L88 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/google/appengine/ext/ndb/model.py | python | Property._call_shallow_validation | (self, value) | return call(value) | Call the initial set of _validate() methods.
This is similar to _call_to_base_type() except it only calls
those _validate() methods that can be called without needing to
call _to_base_type().
An example: suppose the class hierarchy is A -> B -> C ->
Property, and suppose A defines _validate() only... | Call the initial set of _validate() methods. | [
"Call",
"the",
"initial",
"set",
"of",
"_validate",
"()",
"methods",
"."
] | def _call_shallow_validation(self, value):
"""Call the initial set of _validate() methods.
This is similar to _call_to_base_type() except it only calls
those _validate() methods that can be called without needing to
call _to_base_type().
An example: suppose the class hierarchy is A -> B -> C ->
... | [
"def",
"_call_shallow_validation",
"(",
"self",
",",
"value",
")",
":",
"methods",
"=",
"[",
"]",
"for",
"method",
"in",
"self",
".",
"_find_methods",
"(",
"'_validate'",
",",
"'_to_base_type'",
")",
":",
"if",
"method",
".",
"__name__",
"!=",
"'_validate'",... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/google/appengine/ext/ndb/model.py#L1220-L1247 | |
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/rings/valuation/limit_valuation.py | python | MacLaneLimitValuation._improve_approximation | (self) | r"""
Perform one step of the Mac Lane algorithm to improve our approximation.
EXAMPLES::
sage: K = QQ
sage: R.<t> = K[]
sage: L.<t> = K.extension(t^2 + 1)
sage: v = QQ.valuation(2)
sage: w = v.extension(L)
sage: u = w._base_valuat... | r"""
Perform one step of the Mac Lane algorithm to improve our approximation. | [
"r",
"Perform",
"one",
"step",
"of",
"the",
"Mac",
"Lane",
"algorithm",
"to",
"improve",
"our",
"approximation",
"."
] | def _improve_approximation(self):
r"""
Perform one step of the Mac Lane algorithm to improve our approximation.
EXAMPLES::
sage: K = QQ
sage: R.<t> = K[]
sage: L.<t> = K.extension(t^2 + 1)
sage: v = QQ.valuation(2)
sage: w = v.extensi... | [
"def",
"_improve_approximation",
"(",
"self",
")",
":",
"from",
"sage",
".",
"rings",
".",
"infinity",
"import",
"infinity",
"if",
"self",
".",
"_approximation",
"(",
"self",
".",
"_G",
")",
"is",
"infinity",
":",
"# an infinite valuation can not be improved furth... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/rings/valuation/limit_valuation.py#L496-L534 | ||
lixinsu/RCZoo | 37fcb7962fbd4c751c561d4a0c84173881ea8339 | reader/bidafv1/model.py | python | DocReader.update | (self, ex) | return loss.item(), ex[0].size(0) | Forward a batch of examples; step the optimizer to update weights. | Forward a batch of examples; step the optimizer to update weights. | [
"Forward",
"a",
"batch",
"of",
"examples",
";",
"step",
"the",
"optimizer",
"to",
"update",
"weights",
"."
] | def update(self, ex):
"""Forward a batch of examples; step the optimizer to update weights."""
if not self.optimizer:
raise RuntimeError('No optimizer set.')
# Train mode
self.network.train()
# Transfer to GPU
if self.use_cuda:
inputs = [e if e i... | [
"def",
"update",
"(",
"self",
",",
"ex",
")",
":",
"if",
"not",
"self",
".",
"optimizer",
":",
"raise",
"RuntimeError",
"(",
"'No optimizer set.'",
")",
"# Train mode",
"self",
".",
"network",
".",
"train",
"(",
")",
"# Transfer to GPU",
"if",
"self",
".",... | https://github.com/lixinsu/RCZoo/blob/37fcb7962fbd4c751c561d4a0c84173881ea8339/reader/bidafv1/model.py#L196-L443 | |
Dman95/SASM | 7e3ae6da1c219a68e26d38939338567e5c27151a | Windows/MinGW64/opt/lib/python2.7/encodings/cp1252.py | python | IncrementalEncoder.encode | (self, input, final=False) | return codecs.charmap_encode(input,self.errors,encoding_table)[0] | [] | def encode(self, input, final=False):
return codecs.charmap_encode(input,self.errors,encoding_table)[0] | [
"def",
"encode",
"(",
"self",
",",
"input",
",",
"final",
"=",
"False",
")",
":",
"return",
"codecs",
".",
"charmap_encode",
"(",
"input",
",",
"self",
".",
"errors",
",",
"encoding_table",
")",
"[",
"0",
"]"
] | https://github.com/Dman95/SASM/blob/7e3ae6da1c219a68e26d38939338567e5c27151a/Windows/MinGW64/opt/lib/python2.7/encodings/cp1252.py#L18-L19 | |||
tensorflow/models | 6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3 | orbit/standard_runner.py | python | StandardTrainer.train_loop_end | (self) | Called once at the end of the training loop.
This method is always called in eager mode, and is a good place to get
metric results. The value returned from this function will be returned as-is
from the `train` method implementation provided by `StandardTrainer`.
Returns:
The function may return ... | Called once at the end of the training loop. | [
"Called",
"once",
"at",
"the",
"end",
"of",
"the",
"training",
"loop",
"."
] | def train_loop_end(self) -> Optional[runner.Output]:
"""Called once at the end of the training loop.
This method is always called in eager mode, and is a good place to get
metric results. The value returned from this function will be returned as-is
from the `train` method implementation provided by `St... | [
"def",
"train_loop_end",
"(",
"self",
")",
"->",
"Optional",
"[",
"runner",
".",
"Output",
"]",
":",
"pass"
] | https://github.com/tensorflow/models/blob/6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3/orbit/standard_runner.py#L181-L193 | ||
mozman/ezdxf | 59d0fc2ea63f5cf82293428f5931da7e9f9718e9 | src/ezdxf/disassemble.py | python | CurvePrimitive.path | (self) | return self._path | Create path representation on demand. | Create path representation on demand. | [
"Create",
"path",
"representation",
"on",
"demand",
"."
] | def path(self) -> Optional[Path]:
"""Create path representation on demand."""
if self._path is None:
self._path = make_path(self.entity)
return self._path | [
"def",
"path",
"(",
"self",
")",
"->",
"Optional",
"[",
"Path",
"]",
":",
"if",
"self",
".",
"_path",
"is",
"None",
":",
"self",
".",
"_path",
"=",
"make_path",
"(",
"self",
".",
"entity",
")",
"return",
"self",
".",
"_path"
] | https://github.com/mozman/ezdxf/blob/59d0fc2ea63f5cf82293428f5931da7e9f9718e9/src/ezdxf/disassemble.py#L146-L150 | |
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/turtle.py | python | _turtle_docrevise | (docstr) | return newdocstr | To reduce docstrings from RawTurtle class for functions | To reduce docstrings from RawTurtle class for functions | [
"To",
"reduce",
"docstrings",
"from",
"RawTurtle",
"class",
"for",
"functions"
] | def _turtle_docrevise(docstr):
"""To reduce docstrings from RawTurtle class for functions
"""
import re
if docstr is None:
return None
turtlename = _CFG["exampleturtle"]
newdocstr = docstr.replace("%s." % turtlename,"")
parexp = re.compile(r' \(.+ %s\):' % turtlename)
newdocstr =... | [
"def",
"_turtle_docrevise",
"(",
"docstr",
")",
":",
"import",
"re",
"if",
"docstr",
"is",
"None",
":",
"return",
"None",
"turtlename",
"=",
"_CFG",
"[",
"\"exampleturtle\"",
"]",
"newdocstr",
"=",
"docstr",
".",
"replace",
"(",
"\"%s.\"",
"%",
"turtlename",... | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/turtle.py#L3914-L3924 | |
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/lib-tk/Tkinter.py | python | Wm.wm_focusmodel | (self, model=None) | return self.tk.call('wm', 'focusmodel', self._w, model) | Set focus model to MODEL. "active" means that this widget will claim
the focus itself, "passive" means that the window manager shall give
the focus. Return current focus model if MODEL is None. | Set focus model to MODEL. "active" means that this widget will claim
the focus itself, "passive" means that the window manager shall give
the focus. Return current focus model if MODEL is None. | [
"Set",
"focus",
"model",
"to",
"MODEL",
".",
"active",
"means",
"that",
"this",
"widget",
"will",
"claim",
"the",
"focus",
"itself",
"passive",
"means",
"that",
"the",
"window",
"manager",
"shall",
"give",
"the",
"focus",
".",
"Return",
"current",
"focus",
... | def wm_focusmodel(self, model=None):
"""Set focus model to MODEL. "active" means that this widget will claim
the focus itself, "passive" means that the window manager shall give
the focus. Return current focus model if MODEL is None."""
return self.tk.call('wm', 'focusmodel', self._w, mo... | [
"def",
"wm_focusmodel",
"(",
"self",
",",
"model",
"=",
"None",
")",
":",
"return",
"self",
".",
"tk",
".",
"call",
"(",
"'wm'",
",",
"'focusmodel'",
",",
"self",
".",
"_w",
",",
"model",
")"
] | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/lib-tk/Tkinter.py#L1581-L1585 | |
ProjectQ-Framework/ProjectQ | 0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005 | projectq/backends/_circuits/_to_latex.py | python | _Circ2Tikz._op | (self, line, op=None, offset=0) | return "line{}_gate{}".format(line, op + offset) | Return the gate name for placing a gate on a line.
Args:
line (int): Line number.
op (int): Operation number or, by default, uses the current op
count.
Returns:
op_str (string): Gate name. | Return the gate name for placing a gate on a line. | [
"Return",
"the",
"gate",
"name",
"for",
"placing",
"a",
"gate",
"on",
"a",
"line",
"."
] | def _op(self, line, op=None, offset=0):
"""
Return the gate name for placing a gate on a line.
Args:
line (int): Line number.
op (int): Operation number or, by default, uses the current op
count.
Returns:
op_str (string): Gate name.
... | [
"def",
"_op",
"(",
"self",
",",
"line",
",",
"op",
"=",
"None",
",",
"offset",
"=",
"0",
")",
":",
"if",
"op",
"is",
"None",
":",
"op",
"=",
"self",
".",
"op_count",
"[",
"line",
"]",
"return",
"\"line{}_gate{}\"",
".",
"format",
"(",
"line",
","... | https://github.com/ProjectQ-Framework/ProjectQ/blob/0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005/projectq/backends/_circuits/_to_latex.py#L711-L725 | |
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/full/os.py | python | _execvpe | (file, args, env=None) | [] | def _execvpe(file, args, env=None):
if env is not None:
exec_func = execve
argrest = (args, env)
else:
exec_func = execv
argrest = (args,)
env = environ
if path.dirname(file):
exec_func(file, *argrest)
return
saved_exc = None
path_list = get_e... | [
"def",
"_execvpe",
"(",
"file",
",",
"args",
",",
"env",
"=",
"None",
")",
":",
"if",
"env",
"is",
"not",
"None",
":",
"exec_func",
"=",
"execve",
"argrest",
"=",
"(",
"args",
",",
"env",
")",
"else",
":",
"exec_func",
"=",
"execv",
"argrest",
"=",... | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/os.py#L587-L616 | ||||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/google/appengine/api/images/__init__.py | python | Image._update_tiff_dimensions | (self) | Updates the width and height fields of the tiff image.
Raises:
BadImageError if the image string is not a valid tiff image. | Updates the width and height fields of the tiff image. | [
"Updates",
"the",
"width",
"and",
"height",
"fields",
"of",
"the",
"tiff",
"image",
"."
] | def _update_tiff_dimensions(self):
"""Updates the width and height fields of the tiff image.
Raises:
BadImageError if the image string is not a valid tiff image.
"""
size = len(self._image_data)
if self._image_data.startswith("II"):
endianness = "<"
else:
endianness = ">"
... | [
"def",
"_update_tiff_dimensions",
"(",
"self",
")",
":",
"size",
"=",
"len",
"(",
"self",
".",
"_image_data",
")",
"if",
"self",
".",
"_image_data",
".",
"startswith",
"(",
"\"II\"",
")",
":",
"endianness",
"=",
"\"<\"",
"else",
":",
"endianness",
"=",
"... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/google/appengine/api/images/__init__.py#L347-L400 | ||
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/chat/v1/service/channel/__init__.py | python | ChannelInstance.members_count | (self) | return self._properties['members_count'] | :returns: The number of Members in the Channel
:rtype: unicode | :returns: The number of Members in the Channel
:rtype: unicode | [
":",
"returns",
":",
"The",
"number",
"of",
"Members",
"in",
"the",
"Channel",
":",
"rtype",
":",
"unicode"
] | def members_count(self):
"""
:returns: The number of Members in the Channel
:rtype: unicode
"""
return self._properties['members_count'] | [
"def",
"members_count",
"(",
"self",
")",
":",
"return",
"self",
".",
"_properties",
"[",
"'members_count'",
"]"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/chat/v1/service/channel/__init__.py#L489-L494 | |
dmlc/minpy | 2e44927ad0fbff9295e2acf6db636e588fdc5b42 | minpy/utils/minprof.py | python | main | (args=None) | Main function as a module tool
Usage
-p program level
-f function-call level
-l line-by-line level | Main function as a module tool
Usage
-p program level
-f function-call level
-l line-by-line level | [
"Main",
"function",
"as",
"a",
"module",
"tool",
"Usage",
"-",
"p",
"program",
"level",
"-",
"f",
"function",
"-",
"call",
"level",
"-",
"l",
"line",
"-",
"by",
"-",
"line",
"level"
] | def main(args=None):
""" Main function as a module tool
Usage
-p program level
-f function-call level
-l line-by-line level
"""
if args is None:
args = sys.argv
usage = "%prog scriptfile [arg] ..."
parser = argparse.ArgumentParser(usage=usage)
parser.add_argum... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"usage",
"=",
"\"%prog scriptfile [arg] ...\"",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"usage",
"=",
"usage",
")",
"parse... | https://github.com/dmlc/minpy/blob/2e44927ad0fbff9295e2acf6db636e588fdc5b42/minpy/utils/minprof.py#L269-L314 | ||
TuSimple/mx-maskrcnn | c35fb765e437ed187b2fb4931d79275721554922 | rcnn/dataset/ds_utils.py | python | unique_boxes | (boxes, scale=1.0) | return np.sort(index) | return indices of unique boxes | return indices of unique boxes | [
"return",
"indices",
"of",
"unique",
"boxes"
] | def unique_boxes(boxes, scale=1.0):
""" return indices of unique boxes """
v = np.array([1, 1e3, 1e6, 1e9])
hashes = np.round(boxes * scale).dot(v)
_, index = np.unique(hashes, return_index=True)
return np.sort(index) | [
"def",
"unique_boxes",
"(",
"boxes",
",",
"scale",
"=",
"1.0",
")",
":",
"v",
"=",
"np",
".",
"array",
"(",
"[",
"1",
",",
"1e3",
",",
"1e6",
",",
"1e9",
"]",
")",
"hashes",
"=",
"np",
".",
"round",
"(",
"boxes",
"*",
"scale",
")",
".",
"dot"... | https://github.com/TuSimple/mx-maskrcnn/blob/c35fb765e437ed187b2fb4931d79275721554922/rcnn/dataset/ds_utils.py#L4-L9 | |
EtienneCmb/visbrain | b599038e095919dc193b12d5e502d127de7d03c9 | visbrain/config.py | python | init_config | (argv) | Initialize visbrain configuration. | Initialize visbrain configuration. | [
"Initialize",
"visbrain",
"configuration",
"."
] | def init_config(argv):
"""Initialize visbrain configuration."""
global CONFIG
argnames = ['visbrain-log=', 'visbrain-show=', 'visbrain-help',
'visbrain-search=']
try:
opts, args = getopt.getopt(sys.argv[1:], '', argnames)
except getopt.GetoptError:
opts = []
for... | [
"def",
"init_config",
"(",
"argv",
")",
":",
"global",
"CONFIG",
"argnames",
"=",
"[",
"'visbrain-log='",
",",
"'visbrain-show='",
",",
"'visbrain-help'",
",",
"'visbrain-search='",
"]",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sy... | https://github.com/EtienneCmb/visbrain/blob/b599038e095919dc193b12d5e502d127de7d03c9/visbrain/config.py#L70-L91 | ||
tanghaibao/goatools | 647e9dd833695f688cd16c2f9ea18f1692e5c6bc | goatools/grouper/grprdflts.py | python | GrouperDflts.get_gosubdag | (gosubdag=None) | Gets a GoSubDag initialized for use by a Grouper object. | Gets a GoSubDag initialized for use by a Grouper object. | [
"Gets",
"a",
"GoSubDag",
"initialized",
"for",
"use",
"by",
"a",
"Grouper",
"object",
"."
] | def get_gosubdag(gosubdag=None):
"""Gets a GoSubDag initialized for use by a Grouper object."""
if gosubdag is not None:
if gosubdag.rcntobj is not None:
return gosubdag
else:
gosubdag.init_auxobjs()
return gosubdag
else:
... | [
"def",
"get_gosubdag",
"(",
"gosubdag",
"=",
"None",
")",
":",
"if",
"gosubdag",
"is",
"not",
"None",
":",
"if",
"gosubdag",
".",
"rcntobj",
"is",
"not",
"None",
":",
"return",
"gosubdag",
"else",
":",
"gosubdag",
".",
"init_auxobjs",
"(",
")",
"return",... | https://github.com/tanghaibao/goatools/blob/647e9dd833695f688cd16c2f9ea18f1692e5c6bc/goatools/grouper/grprdflts.py#L71-L81 | ||
IBM/lale | b4d6829c143a4735b06083a0e6c70d2cca244162 | lale/lib/rasl/_eval_pandas_df.py | python | eval_expr_pandas_df | (X, expr: Expr) | return _eval_ast_expr_pandas_df(X, expr._expr) | [] | def eval_expr_pandas_df(X, expr: Expr) -> pd.Series:
return _eval_ast_expr_pandas_df(X, expr._expr) | [
"def",
"eval_expr_pandas_df",
"(",
"X",
",",
"expr",
":",
"Expr",
")",
"->",
"pd",
".",
"Series",
":",
"return",
"_eval_ast_expr_pandas_df",
"(",
"X",
",",
"expr",
".",
"_expr",
")"
] | https://github.com/IBM/lale/blob/b4d6829c143a4735b06083a0e6c70d2cca244162/lale/lib/rasl/_eval_pandas_df.py#L26-L27 | |||
larryhastings/gilectomy | 4315ec3f1d6d4f813cc82ce27a24e7f784dbfc1a | Parser/asdl.py | python | ASDLParser.parse | (self, buf) | return self._parse_module() | Parse the ASDL in the buffer and return an AST with a Module root. | Parse the ASDL in the buffer and return an AST with a Module root. | [
"Parse",
"the",
"ASDL",
"in",
"the",
"buffer",
"and",
"return",
"an",
"AST",
"with",
"a",
"Module",
"root",
"."
] | def parse(self, buf):
"""Parse the ASDL in the buffer and return an AST with a Module root.
"""
self._tokenizer = tokenize_asdl(buf)
self._advance()
return self._parse_module() | [
"def",
"parse",
"(",
"self",
",",
"buf",
")",
":",
"self",
".",
"_tokenizer",
"=",
"tokenize_asdl",
"(",
"buf",
")",
"self",
".",
"_advance",
"(",
")",
"return",
"self",
".",
"_parse_module",
"(",
")"
] | https://github.com/larryhastings/gilectomy/blob/4315ec3f1d6d4f813cc82ce27a24e7f784dbfc1a/Parser/asdl.py#L255-L260 | |
gnuradio/SigMF | 3f60b653d8e6a529962b58c97267924702dd9dea | sigmf/sigmffile.py | python | SigMFFile.get_global_info | (self) | Returns a dictionary with all the global info. | Returns a dictionary with all the global info. | [
"Returns",
"a",
"dictionary",
"with",
"all",
"the",
"global",
"info",
"."
] | def get_global_info(self):
"""
Returns a dictionary with all the global info.
"""
try:
return self._metadata.get(self.GLOBAL_KEY, {})
except AttributeError:
return {} | [
"def",
"get_global_info",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_metadata",
".",
"get",
"(",
"self",
".",
"GLOBAL_KEY",
",",
"{",
"}",
")",
"except",
"AttributeError",
":",
"return",
"{",
"}"
] | https://github.com/gnuradio/SigMF/blob/3f60b653d8e6a529962b58c97267924702dd9dea/sigmf/sigmffile.py#L188-L195 | ||
dlcowen/FSEventsParser | f1ce91842a86b65508503e81a9aeda3881b31913 | FSEParser_V4.0.py | python | FSEventHandler.parse | (self, buf) | Parse the decompressed fsevent log. First
finding other dates, then iterating through
eash DLS page found. Then parse records within
each page. | Parse the decompressed fsevent log. First
finding other dates, then iterating through
eash DLS page found. Then parse records within
each page. | [
"Parse",
"the",
"decompressed",
"fsevent",
"log",
".",
"First",
"finding",
"other",
"dates",
"then",
"iterating",
"through",
"eash",
"DLS",
"page",
"found",
".",
"Then",
"parse",
"records",
"within",
"each",
"page",
"."
] | def parse(self, buf):
"""
Parse the decompressed fsevent log. First
finding other dates, then iterating through
eash DLS page found. Then parse records within
each page.
"""
# Initialize variables
pg_count = 0
# Call the date finder for current fs... | [
"def",
"parse",
"(",
"self",
",",
"buf",
")",
":",
"# Initialize variables",
"pg_count",
"=",
"0",
"# Call the date finder for current fsevent file",
"FSEventHandler",
".",
"find_date",
"(",
"self",
",",
"buf",
")",
"self",
".",
"valid_record_check",
"=",
"True",
... | https://github.com/dlcowen/FSEventsParser/blob/f1ce91842a86b65508503e81a9aeda3881b31913/FSEParser_V4.0.py#L695-L738 | ||
bbfamily/abu | 2de85ae57923a720dac99a545b4f856f6b87304b | abupy/UmpBu/ABuUmpMainBase.py | python | AbuUmpMainBase._fit_cprs | (self, show) | return cprs | 通过self.nts,eg: self.nts字典对象形式如下所示:
{
'14-7':
result buy_deg_ang42 buy_deg_ang252 buy_deg_ang60 buy_deg_ang21 ind cluster
2014-11-11 1 8.341 -9.450 0.730 12.397 7 7
2015-10-28 0 7.144 ... | 通过self.nts,eg: self.nts字典对象形式如下所示:
{
'14-7':
result buy_deg_ang42 buy_deg_ang252 buy_deg_ang60 buy_deg_ang21 ind cluster
2014-11-11 1 8.341 -9.450 0.730 12.397 7 7
2015-10-28 0 7.144 ... | [
"通过self",
".",
"nts,eg",
":",
"self",
".",
"nts字典对象形式如下所示:",
"{",
"14",
"-",
"7",
":",
"result",
"buy_deg_ang42",
"buy_deg_ang252",
"buy_deg_ang60",
"buy_deg_ang21",
"ind",
"cluster",
"2014",
"-",
"11",
"-",
"11",
"1",
"8",
".",
"341",
"-",
"9",
".",
"45... | def _fit_cprs(self, show):
"""
通过self.nts,eg: self.nts字典对象形式如下所示:
{
'14-7':
result buy_deg_ang42 buy_deg_ang252 buy_deg_ang60 buy_deg_ang21 ind cluster
2014-11-11 1 8.341 -9.450 0.730 12.397 7... | [
"def",
"_fit_cprs",
"(",
"self",
",",
"show",
")",
":",
"\"\"\"\n cprs_dict和cprs_index为了构造pd.DataFrame(cprs_dict, index=cprs_index)提供数据初始\n lcs:分类簇中的交易个数\n lrs:代表分类簇中失败亏损的交易数量/类醋中总交易数量\n lps:通过cluster_order_df.profit_cg计算分类簇中的交易的总收益比例\n lms:通过cl... | https://github.com/bbfamily/abu/blob/2de85ae57923a720dac99a545b4f856f6b87304b/abupy/UmpBu/ABuUmpMainBase.py#L451-L636 | |
alexgisby/imgur-album-downloader | dbaee1e342c1b46c022fccd26c294e251ac04015 | imguralbum.py | python | ImgurAlbumDownloader.num_images | (self) | return len(self.imageIDs) | Returns the number of images that are present in this album. | Returns the number of images that are present in this album. | [
"Returns",
"the",
"number",
"of",
"images",
"that",
"are",
"present",
"in",
"this",
"album",
"."
] | def num_images(self):
"""
Returns the number of images that are present in this album.
"""
return len(self.imageIDs) | [
"def",
"num_images",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"imageIDs",
")"
] | https://github.com/alexgisby/imgur-album-downloader/blob/dbaee1e342c1b46c022fccd26c294e251ac04015/imguralbum.py#L85-L89 | |
bigchaindb/bigchaindb | 0961aa6b26f918f98cf6a94a29d87af4edfdf00f | bigchaindb/web/websocket_server.py | python | Dispatcher.unsubscribe | (self, uuid) | Remove a websocket from the list of subscribers.
Args:
uuid (str): a unique identifier for the websocket. | Remove a websocket from the list of subscribers. | [
"Remove",
"a",
"websocket",
"from",
"the",
"list",
"of",
"subscribers",
"."
] | def unsubscribe(self, uuid):
"""Remove a websocket from the list of subscribers.
Args:
uuid (str): a unique identifier for the websocket.
"""
del self.subscribers[uuid] | [
"def",
"unsubscribe",
"(",
"self",
",",
"uuid",
")",
":",
"del",
"self",
".",
"subscribers",
"[",
"uuid",
"]"
] | https://github.com/bigchaindb/bigchaindb/blob/0961aa6b26f918f98cf6a94a29d87af4edfdf00f/bigchaindb/web/websocket_server.py#L90-L97 | ||
mardix/assembly | 4c993d19bc9d33c1641323e03231e9ecad711b38 | assembly/request.py | python | RequestProxy.delete | (cls, f) | return cls._accept_method(["DELETE"], f) | decorator to accept DELETE method | decorator to accept DELETE method | [
"decorator",
"to",
"accept",
"DELETE",
"method"
] | def delete(cls, f):
""" decorator to accept DELETE method """
return cls._accept_method(["DELETE"], f) | [
"def",
"delete",
"(",
"cls",
",",
"f",
")",
":",
"return",
"cls",
".",
"_accept_method",
"(",
"[",
"\"DELETE\"",
"]",
",",
"f",
")"
] | https://github.com/mardix/assembly/blob/4c993d19bc9d33c1641323e03231e9ecad711b38/assembly/request.py#L98-L100 | |
rucio/rucio | 6d0d358e04f5431f0b9a98ae40f31af0ddff4833 | lib/rucio/api/request.py | python | get_next | (request_type, state, issuer, account, vo='def') | return [api_update_return_dict(r) for r in reqs] | Retrieve the next request matching the request type and state.
:param request_type: Type of the request as a string.
:param state: State of the request as a string.
:param issuer: Issuing account as a string.
:param account: Account identifier as a string.
:param vo: The VO to act on.
:returns:... | Retrieve the next request matching the request type and state. | [
"Retrieve",
"the",
"next",
"request",
"matching",
"the",
"request",
"type",
"and",
"state",
"."
] | def get_next(request_type, state, issuer, account, vo='def'):
"""
Retrieve the next request matching the request type and state.
:param request_type: Type of the request as a string.
:param state: State of the request as a string.
:param issuer: Issuing account as a string.
:param account: Acco... | [
"def",
"get_next",
"(",
"request_type",
",",
"state",
",",
"issuer",
",",
"account",
",",
"vo",
"=",
"'def'",
")",
":",
"kwargs",
"=",
"{",
"'account'",
":",
"account",
",",
"'issuer'",
":",
"issuer",
",",
"'request_type'",
":",
"request_type",
",",
"'st... | https://github.com/rucio/rucio/blob/6d0d358e04f5431f0b9a98ae40f31af0ddff4833/lib/rucio/api/request.py#L108-L125 | |
google/capirca | 679e3885e3a5e5e129dc2dfab204ec44d63b26a4 | capirca/lib/naming.py | python | Naming.GetServiceNames | (self) | return list(self.services.keys()) | Returns the list of all known service names. | Returns the list of all known service names. | [
"Returns",
"the",
"list",
"of",
"all",
"known",
"service",
"names",
"."
] | def GetServiceNames(self):
"""Returns the list of all known service names."""
return list(self.services.keys()) | [
"def",
"GetServiceNames",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"services",
".",
"keys",
"(",
")",
")"
] | https://github.com/google/capirca/blob/679e3885e3a5e5e129dc2dfab204ec44d63b26a4/capirca/lib/naming.py#L313-L315 | |
SteveDoyle2/pyNastran | eda651ac2d4883d95a34951f8a002ff94f642a1a | pyNastran/bdf/bdf_interface/add_card.py | python | AddCards._add_param_nastran | (self, key: str, values: List[Union[int, float, str]],
comment: str='') | return param | Creates a PARAM card
Parameters
----------
key : str
the name of the PARAM
values : int/float/str/List
varies depending on the type of PARAM
comment : str; default=''
a comment for the card | Creates a PARAM card | [
"Creates",
"a",
"PARAM",
"card"
] | def _add_param_nastran(self, key: str, values: List[Union[int, float, str]],
comment: str='') -> PARAM:
"""
Creates a PARAM card
Parameters
----------
key : str
the name of the PARAM
values : int/float/str/List
varies de... | [
"def",
"_add_param_nastran",
"(",
"self",
",",
"key",
":",
"str",
",",
"values",
":",
"List",
"[",
"Union",
"[",
"int",
",",
"float",
",",
"str",
"]",
"]",
",",
"comment",
":",
"str",
"=",
"''",
")",
"->",
"PARAM",
":",
"param",
"=",
"PARAM",
"("... | https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/bdf/bdf_interface/add_card.py#L1069-L1086 | |
ioflo/ioflo | 177ac656d7c4ff801aebb0d8b401db365a5248ce | ioflo/aio/tcp/serving.py | python | Peer.__init__ | (self, **kwa) | Initialization method for instance. | Initialization method for instance. | [
"Initialization",
"method",
"for",
"instance",
"."
] | def __init__(self, **kwa):
"""
Initialization method for instance.
"""
super(Peer, self).init(**kwa)
self.oxes = odict() | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwa",
")",
":",
"super",
"(",
"Peer",
",",
"self",
")",
".",
"init",
"(",
"*",
"*",
"kwa",
")",
"self",
".",
"oxes",
"=",
"odict",
"(",
")"
] | https://github.com/ioflo/ioflo/blob/177ac656d7c4ff801aebb0d8b401db365a5248ce/ioflo/aio/tcp/serving.py#L966-L972 | ||
bslatkin/effectivepython | 4ae6f3141291ea137eb29a245bf889dbc8091713 | example_code/item_26.py | python | close_open_files | () | [] | def close_open_files():
everything = gc.get_objects()
for obj in everything:
if isinstance(obj, io.IOBase):
obj.close() | [
"def",
"close_open_files",
"(",
")",
":",
"everything",
"=",
"gc",
".",
"get_objects",
"(",
")",
"for",
"obj",
"in",
"everything",
":",
"if",
"isinstance",
"(",
"obj",
",",
"io",
".",
"IOBase",
")",
":",
"obj",
".",
"close",
"(",
")"
] | https://github.com/bslatkin/effectivepython/blob/4ae6f3141291ea137eb29a245bf889dbc8091713/example_code/item_26.py#L40-L44 | ||||
tuna/fishroom | a76daf5b88bb116a136123b270d8064ddfca4401 | fishroom/telegram_tg.py | python | TgTelegram.recv_header | (self) | return int(size) + 1 | Receive and parse message head like `ANSWER XXX\n`
Returns:
next message size | Receive and parse message head like `ANSWER XXX\n` | [
"Receive",
"and",
"parse",
"message",
"head",
"like",
"ANSWER",
"XXX",
"\\",
"n"
] | def recv_header(self):
"""Receive and parse message head like `ANSWER XXX\n`
Returns:
next message size
"""
# states = ("ANS", "NUM")
state = "ANS"
ans = b""
size = b""
while 1:
r = self.sock.recv(1)
if state == "ANS":... | [
"def",
"recv_header",
"(",
"self",
")",
":",
"# states = (\"ANS\", \"NUM\")",
"state",
"=",
"\"ANS\"",
"ans",
"=",
"b\"\"",
"size",
"=",
"b\"\"",
"while",
"1",
":",
"r",
"=",
"self",
".",
"sock",
".",
"recv",
"(",
"1",
")",
"if",
"state",
"==",
"\"ANS\... | https://github.com/tuna/fishroom/blob/a76daf5b88bb116a136123b270d8064ddfca4401/fishroom/telegram_tg.py#L74-L98 | |
smart-mobile-software/gitstack | d9fee8f414f202143eb6e620529e8e5539a2af56 | python/Lib/email/iterators.py | python | typed_subpart_iterator | (msg, maintype='text', subtype=None) | Iterate over the subparts with a given MIME type.
Use `maintype' as the main MIME type to match against; this defaults to
"text". Optional `subtype' is the MIME subtype to match against; if
omitted, only the main type is matched. | Iterate over the subparts with a given MIME type. | [
"Iterate",
"over",
"the",
"subparts",
"with",
"a",
"given",
"MIME",
"type",
"."
] | def typed_subpart_iterator(msg, maintype='text', subtype=None):
"""Iterate over the subparts with a given MIME type.
Use `maintype' as the main MIME type to match against; this defaults to
"text". Optional `subtype' is the MIME subtype to match against; if
omitted, only the main type is matched.
"... | [
"def",
"typed_subpart_iterator",
"(",
"msg",
",",
"maintype",
"=",
"'text'",
",",
"subtype",
"=",
"None",
")",
":",
"for",
"subpart",
"in",
"msg",
".",
"walk",
"(",
")",
":",
"if",
"subpart",
".",
"get_content_maintype",
"(",
")",
"==",
"maintype",
":",
... | https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/email/iterators.py#L47-L57 | ||
datacenter/acitoolkit | 629b84887dd0f0183b81efc8adb16817f985541a | acitoolkit/acitoolkit.py | python | MonitorPolicy.__str__ | (self) | return self.policyType + ':' + self.name | Return print string. | Return print string. | [
"Return",
"print",
"string",
"."
] | def __str__(self):
"""
Return print string.
"""
return self.policyType + ':' + self.name | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"policyType",
"+",
"':'",
"+",
"self",
".",
"name"
] | https://github.com/datacenter/acitoolkit/blob/629b84887dd0f0183b81efc8adb16817f985541a/acitoolkit/acitoolkit.py#L7065-L7069 | |
polychromatic/polychromatic | 106bc3fdfda650a732341bf45e0d20fd281cc521 | pylib/controller/shared.py | python | ColourPicker._rename_list_item | (self) | Rename the selected colour from the Saved Colour list. | Rename the selected colour from the Saved Colour list. | [
"Rename",
"the",
"selected",
"colour",
"from",
"the",
"Saved",
"Colour",
"list",
"."
] | def _rename_list_item(self):
"""
Rename the selected colour from the Saved Colour list.
"""
try:
item = self.saved_tree.selectedItems()[0]
name = item.text(0)
self.list_text_input.setText(name)
self._open_save_widget(replace=True)
e... | [
"def",
"_rename_list_item",
"(",
"self",
")",
":",
"try",
":",
"item",
"=",
"self",
".",
"saved_tree",
".",
"selectedItems",
"(",
")",
"[",
"0",
"]",
"name",
"=",
"item",
".",
"text",
"(",
"0",
")",
"self",
".",
"list_text_input",
".",
"setText",
"("... | https://github.com/polychromatic/polychromatic/blob/106bc3fdfda650a732341bf45e0d20fd281cc521/pylib/controller/shared.py#L1015-L1027 | ||
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/combinatorics/permutations.py | python | Permutation.__pow__ | (self, n) | return _af_new(_af_pow(self.array_form, n)) | Routine for finding powers of a permutation.
Examples
========
>>> from sympy.combinatorics.permutations import Permutation
>>> Permutation.print_cyclic = False
>>> p = Permutation([2,0,3,1])
>>> p.order()
4
>>> p**4
Permutation([0, 1, 2, 3]) | Routine for finding powers of a permutation. | [
"Routine",
"for",
"finding",
"powers",
"of",
"a",
"permutation",
"."
] | def __pow__(self, n):
"""
Routine for finding powers of a permutation.
Examples
========
>>> from sympy.combinatorics.permutations import Permutation
>>> Permutation.print_cyclic = False
>>> p = Permutation([2,0,3,1])
>>> p.order()
4
>>> ... | [
"def",
"__pow__",
"(",
"self",
",",
"n",
")",
":",
"if",
"type",
"(",
"n",
")",
"==",
"Perm",
":",
"raise",
"NotImplementedError",
"(",
"'p**p is not defined; do you mean p^p (conjugate)?'",
")",
"n",
"=",
"int",
"(",
"n",
")",
"return",
"_af_new",
"(",
"_... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/combinatorics/permutations.py#L1276-L1295 | |
Komodo/KomodoEdit | 61edab75dce2bdb03943b387b0608ea36f548e8e | src/codeintel/lib/codeintel2/database/stdlib.py | python | StdLib.reportMemory | (self) | return total_mem_usage | Report on memory usage from this StdLib.
@returns {dict} memory usage; keys are the paths, values are a dict of
"amount" -> number
"units" -> "bytes" | "count"
"desc" -> str description | Report on memory usage from this StdLib. | [
"Report",
"on",
"memory",
"usage",
"from",
"this",
"StdLib",
"."
] | def reportMemory(self):
"""
Report on memory usage from this StdLib.
@returns {dict} memory usage; keys are the paths, values are a dict of
"amount" -> number
"units" -> "bytes" | "count"
"desc" -> str description
"""
log.debug("%s StdLib %s: r... | [
"def",
"reportMemory",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"%s StdLib %s: reporting memory\"",
",",
"self",
".",
"lang",
",",
"self",
".",
"name",
")",
"import",
"memutils",
"return",
"{",
"\"explicit/python/codeintel/%s/stdlib/%s\"",
"%",
"(",
"s... | https://github.com/Komodo/KomodoEdit/blob/61edab75dce2bdb03943b387b0608ea36f548e8e/src/codeintel/lib/codeintel2/database/stdlib.py#L250-L268 | |
HenriWahl/Nagstamon | 16549c6860b51a93141d84881c6ad28c35d8581e | Nagstamon/Config.py | python | Config.Obfuscate | (self, string, count=5) | return string | Obfuscate a given string to store passwords etc. | Obfuscate a given string to store passwords etc. | [
"Obfuscate",
"a",
"given",
"string",
"to",
"store",
"passwords",
"etc",
"."
] | def Obfuscate(self, string, count=5):
"""
Obfuscate a given string to store passwords etc.
"""
string = string.encode()
for i in range(count):
string = base64.b64encode(string).decode()
string = list(string)
string.reverse()
s... | [
"def",
"Obfuscate",
"(",
"self",
",",
"string",
",",
"count",
"=",
"5",
")",
":",
"string",
"=",
"string",
".",
"encode",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"string",
"=",
"base64",
".",
"b64encode",
"(",
"string",
")",
... | https://github.com/HenriWahl/Nagstamon/blob/16549c6860b51a93141d84881c6ad28c35d8581e/Nagstamon/Config.py#L727-L744 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_clusterrole.py | python | OpenShiftCLI.__init__ | (self,
namespace,
kubeconfig='/etc/origin/master/admin.kubeconfig',
verbose=False,
all_namespaces=False) | Constructor for OpenshiftCLI | Constructor for OpenshiftCLI | [
"Constructor",
"for",
"OpenshiftCLI"
] | def __init__(self,
namespace,
kubeconfig='/etc/origin/master/admin.kubeconfig',
verbose=False,
all_namespaces=False):
''' Constructor for OpenshiftCLI '''
self.namespace = namespace
self.verbose = verbose
self.kubeconfig... | [
"def",
"__init__",
"(",
"self",
",",
"namespace",
",",
"kubeconfig",
"=",
"'/etc/origin/master/admin.kubeconfig'",
",",
"verbose",
"=",
"False",
",",
"all_namespaces",
"=",
"False",
")",
":",
"self",
".",
"namespace",
"=",
"namespace",
"self",
".",
"verbose",
... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_clusterrole.py#L868-L878 | ||
tensorflow/models | 6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3 | research/object_detection/models/keras_models/hourglass_network.py | python | hourglass_depth | (network) | return (input_conv_layers + encoder_decoder_layers + intermediate_layers
+ output_layers) | Helper function to verify depth of hourglass backbone. | Helper function to verify depth of hourglass backbone. | [
"Helper",
"function",
"to",
"verify",
"depth",
"of",
"hourglass",
"backbone",
"."
] | def hourglass_depth(network):
"""Helper function to verify depth of hourglass backbone."""
input_conv_layers = 3 # 1 ResidualBlock and 1 ConvBlock
# Only intermediate_conv2 and intermediate_residual are applied before
# sending inputs to the later stages.
intermediate_layers = (
_layer_depth(network.... | [
"def",
"hourglass_depth",
"(",
"network",
")",
":",
"input_conv_layers",
"=",
"3",
"# 1 ResidualBlock and 1 ConvBlock",
"# Only intermediate_conv2 and intermediate_residual are applied before",
"# sending inputs to the later stages.",
"intermediate_layers",
"=",
"(",
"_layer_depth",
... | https://github.com/tensorflow/models/blob/6b8bb0cbeb3e10415c7a87448f08adc3c484c1d3/research/object_detection/models/keras_models/hourglass_network.py#L501-L520 | |
LinkedInAttic/indextank-service | 880c6295ce8e7a3a55bf9b3777cc35c7680e0d7e | storefront/boto/sdb/connection.py | python | SDBConnection.query | (self, domain_or_name, query='', max_items=None, next_token=None) | return self.get_object('Query', params, ResultSet) | Returns a list of item names within domain_name that match the query.
:type domain_or_name: string or :class:`boto.sdb.domain.Domain` object.
:param domain_or_name: Either the name of a domain or a Domain object
:type query: string
:param query: The SimpleDB query to be perform... | Returns a list of item names within domain_name that match the query.
:type domain_or_name: string or :class:`boto.sdb.domain.Domain` object.
:param domain_or_name: Either the name of a domain or a Domain object | [
"Returns",
"a",
"list",
"of",
"item",
"names",
"within",
"domain_name",
"that",
"match",
"the",
"query",
".",
":",
"type",
"domain_or_name",
":",
"string",
"or",
":",
"class",
":",
"boto",
".",
"sdb",
".",
"domain",
".",
"Domain",
"object",
".",
":",
"... | def query(self, domain_or_name, query='', max_items=None, next_token=None):
"""
Returns a list of item names within domain_name that match the query.
:type domain_or_name: string or :class:`boto.sdb.domain.Domain` object.
:param domain_or_name: Either the name of a domain or a D... | [
"def",
"query",
"(",
"self",
",",
"domain_or_name",
",",
"query",
"=",
"''",
",",
"max_items",
"=",
"None",
",",
"next_token",
"=",
"None",
")",
":",
"warnings",
".",
"warn",
"(",
"'Query interface is deprecated'",
",",
"DeprecationWarning",
")",
"domain",
"... | https://github.com/LinkedInAttic/indextank-service/blob/880c6295ce8e7a3a55bf9b3777cc35c7680e0d7e/storefront/boto/sdb/connection.py#L355-L381 | |
Northxw/Python3_WebSpider | 903044564a09f470516a51ab2fa457b3c6f6c7a9 | 04-Selenium_Taobao/taobao.py | python | Products.__init__ | (self) | 初始化 | 初始化 | [
"初始化"
] | def __init__(self):
"""
初始化
"""
# 数据库配置
self.client = pymongo.MongoClient(MONGO_URL)
self.db = self.client[MONGO_DB]
self.collection = self.db[MONGO_COLLECTION]
# 代理配置
self.auth = Xdaili().auth()
self.chrome_options = webdriver.ChromeOption... | [
"def",
"__init__",
"(",
"self",
")",
":",
"# 数据库配置",
"self",
".",
"client",
"=",
"pymongo",
".",
"MongoClient",
"(",
"MONGO_URL",
")",
"self",
".",
"db",
"=",
"self",
".",
"client",
"[",
"MONGO_DB",
"]",
"self",
".",
"collection",
"=",
"self",
".",
"... | https://github.com/Northxw/Python3_WebSpider/blob/903044564a09f470516a51ab2fa457b3c6f6c7a9/04-Selenium_Taobao/taobao.py#L22-L37 | ||
edgewall/trac | beb3e4eaf1e0a456d801a50a8614ecab06de29fc | trac/wiki/formatter.py | python | Formatter._get_quote_depth | (self) | return self._quote_stack[-1] if self._quote_stack else 0 | Return the space offset associated to the deepest opened quote. | Return the space offset associated to the deepest opened quote. | [
"Return",
"the",
"space",
"offset",
"associated",
"to",
"the",
"deepest",
"opened",
"quote",
"."
] | def _get_quote_depth(self):
"""Return the space offset associated to the deepest opened quote."""
return self._quote_stack[-1] if self._quote_stack else 0 | [
"def",
"_get_quote_depth",
"(",
"self",
")",
":",
"return",
"self",
".",
"_quote_stack",
"[",
"-",
"1",
"]",
"if",
"self",
".",
"_quote_stack",
"else",
"0"
] | https://github.com/edgewall/trac/blob/beb3e4eaf1e0a456d801a50a8614ecab06de29fc/trac/wiki/formatter.py#L1004-L1006 | |
twilio/twilio-python | 6e1e811ea57a1edfadd5161ace87397c563f6915 | twilio/rest/monitor/v1/alert.py | python | AlertInstance.response_body | (self) | return self._properties['response_body'] | :returns: The response body of the request that generated the alert
:rtype: unicode | :returns: The response body of the request that generated the alert
:rtype: unicode | [
":",
"returns",
":",
"The",
"response",
"body",
"of",
"the",
"request",
"that",
"generated",
"the",
"alert",
":",
"rtype",
":",
"unicode"
] | def response_body(self):
"""
:returns: The response body of the request that generated the alert
:rtype: unicode
"""
return self._properties['response_body'] | [
"def",
"response_body",
"(",
"self",
")",
":",
"return",
"self",
".",
"_properties",
"[",
"'response_body'",
"]"
] | https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/monitor/v1/alert.py#L408-L413 | |
ladybug-tools/honeybee-legacy | bd62af4862fe022801fb87dbc8794fdf1dff73a9 | src/Honeybee_Honeybee.py | python | hb_RADParameters.__init__ | (self) | [] | def __init__(self):
self.radParDict = {
"_ab_": [2, 3, 6],
"_ad_": [512, 2048, 4096],
"_as_": [128, 2048, 4096],
"_ar_": [16, 64, 128],
"_aa_": [.25, .2, .1],
"_ps_": [8, 4, 2],
"_pt_": [.15, .10, .05],
"_pj_": [.6, .9, .9],
"_dj_": [0, .5,... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"radParDict",
"=",
"{",
"\"_ab_\"",
":",
"[",
"2",
",",
"3",
",",
"6",
"]",
",",
"\"_ad_\"",
":",
"[",
"512",
",",
"2048",
",",
"4096",
"]",
",",
"\"_as_\"",
":",
"[",
"128",
",",
"2048",
... | https://github.com/ladybug-tools/honeybee-legacy/blob/bd62af4862fe022801fb87dbc8794fdf1dff73a9/src/Honeybee_Honeybee.py#L8516-L8541 | ||||
sio2project/oioioi | adeb6a7b278b6bed853405e525f87fd2726c06ac | oioioi/base/utils/__init__.py | python | memoized | (fn) | return memoizer | Simple wrapper that adds result caching for functions with positional
arguments only.
The arguments must be hashable so that they can be stored as keys in
a dict. | Simple wrapper that adds result caching for functions with positional
arguments only. | [
"Simple",
"wrapper",
"that",
"adds",
"result",
"caching",
"for",
"functions",
"with",
"positional",
"arguments",
"only",
"."
] | def memoized(fn):
"""Simple wrapper that adds result caching for functions with positional
arguments only.
The arguments must be hashable so that they can be stored as keys in
a dict.
"""
cache = {}
@functools.wraps(fn)
def memoizer(*args):
if args not in cache:
cac... | [
"def",
"memoized",
"(",
"fn",
")",
":",
"cache",
"=",
"{",
"}",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"memoizer",
"(",
"*",
"args",
")",
":",
"if",
"args",
"not",
"in",
"cache",
":",
"cache",
"[",
"args",
"]",
"=",
"fn",
"(",
... | https://github.com/sio2project/oioioi/blob/adeb6a7b278b6bed853405e525f87fd2726c06ac/oioioi/base/utils/__init__.py#L329-L345 | |
keon/algorithms | 23d4e85a506eaeaff315e855be12f8dbe47a7ec3 | algorithms/sort/top_sort.py | python | top_sort | (graph) | return order | Time complexity is the same as DFS, which is O(V + E)
Space complexity: O(V) | Time complexity is the same as DFS, which is O(V + E)
Space complexity: O(V) | [
"Time",
"complexity",
"is",
"the",
"same",
"as",
"DFS",
"which",
"is",
"O",
"(",
"V",
"+",
"E",
")",
"Space",
"complexity",
":",
"O",
"(",
"V",
")"
] | def top_sort(graph):
""" Time complexity is the same as DFS, which is O(V + E)
Space complexity: O(V)
"""
order, enter, state = [], set(graph), {}
def is_ready(node):
lst = graph.get(node, ())
if len(lst) == 0:
return True
for k in lst:
sk = s... | [
"def",
"top_sort",
"(",
"graph",
")",
":",
"order",
",",
"enter",
",",
"state",
"=",
"[",
"]",
",",
"set",
"(",
"graph",
")",
",",
"{",
"}",
"def",
"is_ready",
"(",
"node",
")",
":",
"lst",
"=",
"graph",
".",
"get",
"(",
"node",
",",
"(",
")"... | https://github.com/keon/algorithms/blob/23d4e85a506eaeaff315e855be12f8dbe47a7ec3/algorithms/sort/top_sort.py#L26-L66 | |
chainer/chainer | e9da1423255c58c37be9733f51b158aa9b39dc93 | chainer/graph_optimizations/static_graph.py | python | ScheduleManager.get_schedule | (self, in_vars, enable_double_backprop=False) | return sched | Get a static schedule.
Return a static schedule object (that is, an instance of
``StaticScheduleFunction``) that is compatible with
the current configuration and input variables to the supplied chain.
If there is no existing schedule available, return an empty schedule
object.
... | Get a static schedule. | [
"Get",
"a",
"static",
"schedule",
"."
] | def get_schedule(self, in_vars, enable_double_backprop=False):
"""Get a static schedule.
Return a static schedule object (that is, an instance of
``StaticScheduleFunction``) that is compatible with
the current configuration and input variables to the supplied chain.
If there is ... | [
"def",
"get_schedule",
"(",
"self",
",",
"in_vars",
",",
"enable_double_backprop",
"=",
"False",
")",
":",
"if",
"self",
".",
"forward_over",
":",
"self",
".",
"forward_over",
"=",
"False",
"if",
"self",
".",
"minimize_cache_size",
":",
"if",
"chainer",
".",... | https://github.com/chainer/chainer/blob/e9da1423255c58c37be9733f51b158aa9b39dc93/chainer/graph_optimizations/static_graph.py#L968-L1063 | |
lsbardel/python-stdnet | 78db5320bdedc3f28c5e4f38cda13a4469e35db7 | stdnet/apps/searchengine/processors/__init__.py | python | stopwords.__init__ | (self, stp=None) | [] | def __init__(self, stp=None):
self.stp = stp if stp is not None else STOP_WORDS | [
"def",
"__init__",
"(",
"self",
",",
"stp",
"=",
"None",
")",
":",
"self",
".",
"stp",
"=",
"stp",
"if",
"stp",
"is",
"not",
"None",
"else",
"STOP_WORDS"
] | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/apps/searchengine/processors/__init__.py#L8-L9 | ||||
ladybug-tools/butterfly | c8fc0bbe317bb41bfe5f28305782a82347b8c776 | butterfly/runmanager.py | python | RunManager.start_openfoam | (self) | Start OpenFOAM for Windows image from batch file. | Start OpenFOAM for Windows image from batch file. | [
"Start",
"OpenFOAM",
"for",
"Windows",
"image",
"from",
"batch",
"file",
"."
] | def start_openfoam(self):
"""Start OpenFOAM for Windows image from batch file."""
Popen(self.__of_batch_file, shell=True) | [
"def",
"start_openfoam",
"(",
"self",
")",
":",
"Popen",
"(",
"self",
".",
"__of_batch_file",
",",
"shell",
"=",
"True",
")"
] | https://github.com/ladybug-tools/butterfly/blob/c8fc0bbe317bb41bfe5f28305782a82347b8c776/butterfly/runmanager.py#L204-L206 | ||
TKkk-iOSer/wechat-alfred-workflow | 449995275dd700bcb3686abcfe2ed9c63ea826a3 | src/workflow/workflow3.py | python | Workflow3.add_item | (self, title, subtitle='', arg=None, autocomplete=None,
valid=False, uid=None, icon=None, icontype=None, type=None,
largetext=None, copytext=None, quicklookurl=None, match=None) | return item | Add an item to be output to Alfred.
Args:
match (unicode, optional): If you have "Alfred filters results"
turned on for your Script Filter, Alfred (version 3.5 and
above) will filter against this field, not ``title``.
See :meth:`Workflow.add_item() <workflow... | Add an item to be output to Alfred. | [
"Add",
"an",
"item",
"to",
"be",
"output",
"to",
"Alfred",
"."
] | def add_item(self, title, subtitle='', arg=None, autocomplete=None,
valid=False, uid=None, icon=None, icontype=None, type=None,
largetext=None, copytext=None, quicklookurl=None, match=None):
"""Add an item to be output to Alfred.
Args:
match (unicode, optio... | [
"def",
"add_item",
"(",
"self",
",",
"title",
",",
"subtitle",
"=",
"''",
",",
"arg",
"=",
"None",
",",
"autocomplete",
"=",
"None",
",",
"valid",
"=",
"False",
",",
"uid",
"=",
"None",
",",
"icon",
"=",
"None",
",",
"icontype",
"=",
"None",
",",
... | https://github.com/TKkk-iOSer/wechat-alfred-workflow/blob/449995275dd700bcb3686abcfe2ed9c63ea826a3/src/workflow/workflow3.py#L553-L582 | |
v3n0m-Scanner/V3n0M-Scanner | 3d0a0d89fb947f791d23e522a72524fc229ee429 | src/modules/socks.py | python | wrap_module | (module) | Attempts to replace a module's socket library with a SOCKS socket. Must set
a default proxy using set_default_proxy(...) first.
This will only work on modules that import socket directly into the namespace;
most of the Python Standard Library falls into this category. | Attempts to replace a module's socket library with a SOCKS socket. Must set
a default proxy using set_default_proxy(...) first.
This will only work on modules that import socket directly into the namespace;
most of the Python Standard Library falls into this category. | [
"Attempts",
"to",
"replace",
"a",
"module",
"s",
"socket",
"library",
"with",
"a",
"SOCKS",
"socket",
".",
"Must",
"set",
"a",
"default",
"proxy",
"using",
"set_default_proxy",
"(",
"...",
")",
"first",
".",
"This",
"will",
"only",
"work",
"on",
"modules",... | def wrap_module(module):
"""
Attempts to replace a module's socket library with a SOCKS socket. Must set
a default proxy using set_default_proxy(...) first.
This will only work on modules that import socket directly into the namespace;
most of the Python Standard Library falls into this category.
... | [
"def",
"wrap_module",
"(",
"module",
")",
":",
"if",
"socksocket",
".",
"default_proxy",
":",
"module",
".",
"socket",
".",
"socket",
"=",
"socksocket",
"else",
":",
"raise",
"GeneralProxyError",
"(",
"\"No default proxy specified\"",
")"
] | https://github.com/v3n0m-Scanner/V3n0M-Scanner/blob/3d0a0d89fb947f791d23e522a72524fc229ee429/src/modules/socks.py#L200-L210 | ||
joschabach/micropsi2 | 74a2642d20da9da1d64acc5e4c11aeabee192a27 | micropsi_core/nodenet/nodenet.py | python | Nodenet.worldadapter | (self) | return self._worldadapter_uid | Returns the uid of the currently connected world adapter | Returns the uid of the currently connected world adapter | [
"Returns",
"the",
"uid",
"of",
"the",
"currently",
"connected",
"world",
"adapter"
] | def worldadapter(self):
"""
Returns the uid of the currently connected world adapter
"""
return self._worldadapter_uid | [
"def",
"worldadapter",
"(",
"self",
")",
":",
"return",
"self",
".",
"_worldadapter_uid"
] | https://github.com/joschabach/micropsi2/blob/74a2642d20da9da1d64acc5e4c11aeabee192a27/micropsi_core/nodenet/nodenet.py#L113-L117 | |
pymedusa/Medusa | 1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38 | medusa/notifiers/trakt.py | python | Notifier.add_episode_to_watchlist | (episode) | Add an episode to the trakt watchlist.
:params episode: Episode Object. | Add an episode to the trakt watchlist. | [
"Add",
"an",
"episode",
"to",
"the",
"trakt",
"watchlist",
"."
] | def add_episode_to_watchlist(episode):
"""
Add an episode to the trakt watchlist.
:params episode: Episode Object.
"""
show_id = str(episode.series.externals.get('trakt_id', episode.series.name))
try:
tv_episode = tv.TVEpisode(show_id, episode.season, episod... | [
"def",
"add_episode_to_watchlist",
"(",
"episode",
")",
":",
"show_id",
"=",
"str",
"(",
"episode",
".",
"series",
".",
"externals",
".",
"get",
"(",
"'trakt_id'",
",",
"episode",
".",
"series",
".",
"name",
")",
")",
"try",
":",
"tv_episode",
"=",
"tv",... | https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/medusa/notifiers/trakt.py#L132-L144 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.2/django/contrib/gis/geos/linestring.py | python | LineString.__len__ | (self) | return len(self._cs) | Returns the number of points in this LineString. | Returns the number of points in this LineString. | [
"Returns",
"the",
"number",
"of",
"points",
"in",
"this",
"LineString",
"."
] | def __len__(self):
"Returns the number of points in this LineString."
return len(self._cs) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_cs",
")"
] | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.2/django/contrib/gis/geos/linestring.py#L73-L75 | |
AstroPrint/AstroBox | e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75 | src/astroprint/plugin/__init__.py | python | PluginManager._getDirectories | (self, path) | return [ name for name in os.listdir(path) if name[0] != '.' and os.path.isdir(os.path.join(path, name)) ] | [] | def _getDirectories(self, path):
#don't return hidden dirs
return [ name for name in os.listdir(path) if name[0] != '.' and os.path.isdir(os.path.join(path, name)) ] | [
"def",
"_getDirectories",
"(",
"self",
",",
"path",
")",
":",
"#don't return hidden dirs",
"return",
"[",
"name",
"for",
"name",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
"if",
"name",
"[",
"0",
"]",
"!=",
"'.'",
"and",
"os",
".",
"path",
".",
"i... | https://github.com/AstroPrint/AstroBox/blob/e7e3b8a7d33ea85fcb6b2696869c0d719ceb8b75/src/astroprint/plugin/__init__.py#L529-L531 | |||
lad1337/XDM | 0c1b7009fe00f06f102a6f67c793478f515e7efe | site-packages/guessit_new/guess.py | python | choose_int | (g1, g2) | Function used by merge_similar_guesses to choose between 2 possible
properties when they are integers. | Function used by merge_similar_guesses to choose between 2 possible
properties when they are integers. | [
"Function",
"used",
"by",
"merge_similar_guesses",
"to",
"choose",
"between",
"2",
"possible",
"properties",
"when",
"they",
"are",
"integers",
"."
] | def choose_int(g1, g2):
"""Function used by merge_similar_guesses to choose between 2 possible
properties when they are integers."""
v1, c1 = g1 # value, confidence
v2, c2 = g2
if (v1 == v2):
return (v1, 1 - (1 - c1) * (1 - c2))
else:
if c1 > c2:
return (v1, c1 - c2)... | [
"def",
"choose_int",
"(",
"g1",
",",
"g2",
")",
":",
"v1",
",",
"c1",
"=",
"g1",
"# value, confidence",
"v2",
",",
"c2",
"=",
"g2",
"if",
"(",
"v1",
"==",
"v2",
")",
":",
"return",
"(",
"v1",
",",
"1",
"-",
"(",
"1",
"-",
"c1",
")",
"*",
"(... | https://github.com/lad1337/XDM/blob/0c1b7009fe00f06f102a6f67c793478f515e7efe/site-packages/guessit_new/guess.py#L243-L254 | ||
allegro/ralph | 1e4a9e1800d5f664abaef2624b8bf7512df279ce | contrib/dhcp_agent/dhcp_agent.py | python | convert_to_request_params | (params) | return request_params | Convert dict with into flat list.
Example:
>>> convert_to_request_params({'foo': ['bar1', 'bar2']})
[('foo': 'bar1'), ('foo', 'bar2')]
>>> convert_to_request_params({'foo': 'bar1'})
[('foo': 'bar1')]
Returns:
list: list contains key-value pairs | Convert dict with into flat list. | [
"Convert",
"dict",
"with",
"into",
"flat",
"list",
"."
] | def convert_to_request_params(params):
"""Convert dict with into flat list.
Example:
>>> convert_to_request_params({'foo': ['bar1', 'bar2']})
[('foo': 'bar1'), ('foo', 'bar2')]
>>> convert_to_request_params({'foo': 'bar1'})
[('foo': 'bar1')]
Returns:
list: list cont... | [
"def",
"convert_to_request_params",
"(",
"params",
")",
":",
"request_params",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"params",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"r... | https://github.com/allegro/ralph/blob/1e4a9e1800d5f664abaef2624b8bf7512df279ce/contrib/dhcp_agent/dhcp_agent.py#L89-L107 | |
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/django-1.3/django/contrib/comments/moderation.py | python | Moderator.unregister | (self, model_or_iterable) | Remove a model or a list of models from the list of models
whose comments will be moderated.
Raise ``NotModerated`` if any of the models are not currently
registered for moderation. | Remove a model or a list of models from the list of models
whose comments will be moderated. | [
"Remove",
"a",
"model",
"or",
"a",
"list",
"of",
"models",
"from",
"the",
"list",
"of",
"models",
"whose",
"comments",
"will",
"be",
"moderated",
"."
] | def unregister(self, model_or_iterable):
"""
Remove a model or a list of models from the list of models
whose comments will be moderated.
Raise ``NotModerated`` if any of the models are not currently
registered for moderation.
"""
if isinstance(model_or_iterable... | [
"def",
"unregister",
"(",
"self",
",",
"model_or_iterable",
")",
":",
"if",
"isinstance",
"(",
"model_or_iterable",
",",
"ModelBase",
")",
":",
"model_or_iterable",
"=",
"[",
"model_or_iterable",
"]",
"for",
"model",
"in",
"model_or_iterable",
":",
"if",
"model"... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/django-1.3/django/contrib/comments/moderation.py#L307-L321 | ||
selfteaching/selfteaching-python-camp | 9982ee964b984595e7d664b07c389cddaf158f1e | 19100205/Ceasar1978/pip-19.0.3/src/pip/_vendor/distlib/manifest.py | python | Manifest.process_directive | (self, directive) | Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``.
:param directive: The directive to process. This should be in a format
compatible with distutils ``MANIFEST.in`` files:
http://docs.python.or... | Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``. | [
"Process",
"a",
"directive",
"which",
"either",
"adds",
"some",
"files",
"from",
"allfiles",
"to",
"files",
"or",
"removes",
"some",
"files",
"from",
"files",
"."
] | def process_directive(self, directive):
"""
Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``.
:param directive: The directive to process. This should be in a format
compatible with distutils ``MANI... | [
"def",
"process_directive",
"(",
"self",
",",
"directive",
")",
":",
"# Parse the line: split it up, make sure the right number of words",
"# is there, and return the relevant words. 'action' is always",
"# defined: it's the first word of the line. Which of the other",
"# three are defined d... | https://github.com/selfteaching/selfteaching-python-camp/blob/9982ee964b984595e7d664b07c389cddaf158f1e/19100205/Ceasar1978/pip-19.0.3/src/pip/_vendor/distlib/manifest.py#L130-L203 | ||
bearpaw/pytorch-classification | 24f1c456f48c78133088c4eefd182ca9e6199b03 | models/cifar/vgg.py | python | vgg19 | (**kwargs) | return model | VGG 19-layer model (configuration "E")
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet | VGG 19-layer model (configuration "E") | [
"VGG",
"19",
"-",
"layer",
"model",
"(",
"configuration",
"E",
")"
] | def vgg19(**kwargs):
"""VGG 19-layer model (configuration "E")
Args:
pretrained (bool): If True, returns a model pre-trained on ImageNet
"""
model = VGG(make_layers(cfg['E']), **kwargs)
return model | [
"def",
"vgg19",
"(",
"*",
"*",
"kwargs",
")",
":",
"model",
"=",
"VGG",
"(",
"make_layers",
"(",
"cfg",
"[",
"'E'",
"]",
")",
",",
"*",
"*",
"kwargs",
")",
"return",
"model"
] | https://github.com/bearpaw/pytorch-classification/blob/24f1c456f48c78133088c4eefd182ca9e6199b03/models/cifar/vgg.py#L125-L132 | |
labd/wagtailstreamforms | fecbfedb9442d38d5f7c3a54a27e4d6291973ab5 | wagtailstreamforms/fields.py | python | BaseField.get_formfield_label | (cls, block_value) | Return a value to use as the 'label' for the Django form field. | Return a value to use as the 'label' for the Django form field. | [
"Return",
"a",
"value",
"to",
"use",
"as",
"the",
"label",
"for",
"the",
"Django",
"form",
"field",
"."
] | def get_formfield_label(cls, block_value):
"""
Return a value to use as the 'label' for the Django form field.
"""
try:
return block_value["label"]
except KeyError:
raise AttributeError(
f"No label value can be determined for an instance of... | [
"def",
"get_formfield_label",
"(",
"cls",
",",
"block_value",
")",
":",
"try",
":",
"return",
"block_value",
"[",
"\"label\"",
"]",
"except",
"KeyError",
":",
"raise",
"AttributeError",
"(",
"f\"No label value can be determined for an instance of {cls.__name__}. \"",
"\"A... | https://github.com/labd/wagtailstreamforms/blob/fecbfedb9442d38d5f7c3a54a27e4d6291973ab5/wagtailstreamforms/fields.py#L81-L93 | ||
CyberDiscovery/cyberdisc-bot | e7d3a0789148aec1ef3e4153955a8c6f4d2cf219 | cdbot/cogs/cyber.py | python | Cyber.level | (
self, ctx: Context, base: str, level_num: int, challenge_num: int = 0
) | Gets information about a specific CyberStart Game level and challenge. | Gets information about a specific CyberStart Game level and challenge. | [
"Gets",
"information",
"about",
"a",
"specific",
"CyberStart",
"Game",
"level",
"and",
"challenge",
"."
] | async def level(
self, ctx: Context, base: str, level_num: int, challenge_num: int = 0
):
"""
Gets information about a specific CyberStart Game level and challenge.
"""
# Gather data from CyberStart Game.
with open("cdbot/data/game.json") as f:
game_docs ... | [
"async",
"def",
"level",
"(",
"self",
",",
"ctx",
":",
"Context",
",",
"base",
":",
"str",
",",
"level_num",
":",
"int",
",",
"challenge_num",
":",
"int",
"=",
"0",
")",
":",
"# Gather data from CyberStart Game.",
"with",
"open",
"(",
"\"cdbot/data/game.json... | https://github.com/CyberDiscovery/cyberdisc-bot/blob/e7d3a0789148aec1ef3e4153955a8c6f4d2cf219/cdbot/cogs/cyber.py#L109-L159 | ||
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/com.oracle.graal.python.benchmarks/python/meso/srad_rodinia.py | python | __benchmark__ | (nIter=100) | [] | def __benchmark__(nIter=100):
measure(nIter) | [
"def",
"__benchmark__",
"(",
"nIter",
"=",
"100",
")",
":",
"measure",
"(",
"nIter",
")"
] | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/com.oracle.graal.python.benchmarks/python/meso/srad_rodinia.py#L136-L137 | ||||
sfu-db/dataprep | 6dfb9c659e8bf73f07978ae195d0372495c6f118 | dataprep/clean/components/num_imputation/mean_imputer.py | python | MeanImputer.fit | (self, col_df: dd.Series) | return self | Find the mean value for mean imputer according to the provided column.
Parameters
----------
col_df
Provided data column. | Find the mean value for mean imputer according to the provided column. | [
"Find",
"the",
"mean",
"value",
"for",
"mean",
"imputer",
"according",
"to",
"the",
"provided",
"column",
"."
] | def fit(self, col_df: dd.Series) -> Any:
"""
Find the mean value for mean imputer according to the provided column.
Parameters
----------
col_df
Provided data column.
"""
self.mean = col_df.mean()
return self | [
"def",
"fit",
"(",
"self",
",",
"col_df",
":",
"dd",
".",
"Series",
")",
"->",
"Any",
":",
"self",
".",
"mean",
"=",
"col_df",
".",
"mean",
"(",
")",
"return",
"self"
] | https://github.com/sfu-db/dataprep/blob/6dfb9c659e8bf73f07978ae195d0372495c6f118/dataprep/clean/components/num_imputation/mean_imputer.py#L32-L43 | |
n1nj4sec/pupy | a5d766ea81fdfe3bc2c38c9bdaf10e9b75af3b39 | pupy/packages/all/pupyutils/netcreds.py | python | Netcreds.parse_ftp | (self, full_load, dst_ip_port) | return print_strs | Parse out FTP creds | Parse out FTP creds | [
"Parse",
"out",
"FTP",
"creds"
] | def parse_ftp(self, full_load, dst_ip_port):
'''
Parse out FTP creds
'''
print_strs = []
# Sometimes FTP packets double up on the authentication lines
# We just want the lastest one. Ex: "USER danmcinerney\r\nUSER danmcinerney\r\n"
full_load = self.double_line_ch... | [
"def",
"parse_ftp",
"(",
"self",
",",
"full_load",
",",
"dst_ip_port",
")",
":",
"print_strs",
"=",
"[",
"]",
"# Sometimes FTP packets double up on the authentication lines",
"# We just want the lastest one. Ex: \"USER danmcinerney\\r\\nUSER danmcinerney\\r\\n\"",
"full_load",
"=",... | https://github.com/n1nj4sec/pupy/blob/a5d766ea81fdfe3bc2c38c9bdaf10e9b75af3b39/pupy/packages/all/pupyutils/netcreds.py#L404-L432 | |
wavestone-cdt/abaddon | c3d638154d195413cdf0b643271a56a5f1e26083 | delivery/views.py | python | undeploy | (request) | return HttpResponseRedirect('/delivery/redelk_dashboard/') | Undeploy the whole infrastructure
Redirect to the dashboard. | Undeploy the whole infrastructure
Redirect to the dashboard. | [
"Undeploy",
"the",
"whole",
"infrastructure",
"Redirect",
"to",
"the",
"dashboard",
"."
] | def undeploy(request):
"""
Undeploy the whole infrastructure
Redirect to the dashboard.
"""
if request.method == "POST":
op_name = request.POST.get("op_name", "")
try:
infra = Infra.objects.get(name=op_name)
nginx_concrete = get_nginx_concrete_object(i... | [
"def",
"undeploy",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"\"POST\"",
":",
"op_name",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"\"op_name\"",
",",
"\"\"",
")",
"try",
":",
"infra",
"=",
"Infra",
".",
"objects",
".",
"get... | https://github.com/wavestone-cdt/abaddon/blob/c3d638154d195413cdf0b643271a56a5f1e26083/delivery/views.py#L84-L102 | |
inducer/pudb | 82a0017982f20917c17989a0cb2b71c54ee90ba7 | pudb/remote.py | python | debugger | (term_size=None, host=PUDB_RDB_HOST, port=PUDB_RDB_PORT, reverse=False) | return rdb | Return the current debugger instance (if any),
or creates a new one. | Return the current debugger instance (if any),
or creates a new one. | [
"Return",
"the",
"current",
"debugger",
"instance",
"(",
"if",
"any",
")",
"or",
"creates",
"a",
"new",
"one",
"."
] | def debugger(term_size=None, host=PUDB_RDB_HOST, port=PUDB_RDB_PORT, reverse=False):
"""Return the current debugger instance (if any),
or creates a new one."""
rdb = _current[0]
if rdb is None:
rdb = _current[0] = RemoteDebugger(
host=host, port=port, term_size=term_size, reverse=rev... | [
"def",
"debugger",
"(",
"term_size",
"=",
"None",
",",
"host",
"=",
"PUDB_RDB_HOST",
",",
"port",
"=",
"PUDB_RDB_PORT",
",",
"reverse",
"=",
"False",
")",
":",
"rdb",
"=",
"_current",
"[",
"0",
"]",
"if",
"rdb",
"is",
"None",
":",
"rdb",
"=",
"_curre... | https://github.com/inducer/pudb/blob/82a0017982f20917c17989a0cb2b71c54ee90ba7/pudb/remote.py#L221-L230 | |
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | scripts/monitoring/cron-send-filesystem-metrics.py | python | zero_mount_percentages | (metric_dict) | return {
k:0 for (k, v) in metric_dict.iteritems()
} | Make all mounts report 0% used | Make all mounts report 0% used | [
"Make",
"all",
"mounts",
"report",
"0%",
"used"
] | def zero_mount_percentages(metric_dict):
""" Make all mounts report 0% used """
return {
k:0 for (k, v) in metric_dict.iteritems()
} | [
"def",
"zero_mount_percentages",
"(",
"metric_dict",
")",
":",
"return",
"{",
"k",
":",
"0",
"for",
"(",
"k",
",",
"v",
")",
"in",
"metric_dict",
".",
"iteritems",
"(",
")",
"}"
] | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/scripts/monitoring/cron-send-filesystem-metrics.py#L68-L72 | |
django-nonrel/django-nonrel | 4fbfe7344481a5eab8698f79207f09124310131b | django/db/models/sql/query.py | python | Query.get_meta | (self) | return self.model._meta | Returns the Options instance (the model._meta) from which to start
processing. Normally, this is self.model._meta, but it can be changed
by subclasses. | Returns the Options instance (the model._meta) from which to start
processing. Normally, this is self.model._meta, but it can be changed
by subclasses. | [
"Returns",
"the",
"Options",
"instance",
"(",
"the",
"model",
".",
"_meta",
")",
"from",
"which",
"to",
"start",
"processing",
".",
"Normally",
"this",
"is",
"self",
".",
"model",
".",
"_meta",
"but",
"it",
"can",
"be",
"changed",
"by",
"subclasses",
"."... | def get_meta(self):
"""
Returns the Options instance (the model._meta) from which to start
processing. Normally, this is self.model._meta, but it can be changed
by subclasses.
"""
return self.model._meta | [
"def",
"get_meta",
"(",
"self",
")",
":",
"return",
"self",
".",
"model",
".",
"_meta"
] | https://github.com/django-nonrel/django-nonrel/blob/4fbfe7344481a5eab8698f79207f09124310131b/django/db/models/sql/query.py#L215-L221 | |
pydata/xarray | 9226c7ac87b3eb246f7a7e49f8f0f23d68951624 | xarray/core/variable.py | python | IndexVariable.concat | (
cls,
variables,
dim="concat_dim",
positions=None,
shortcut=False,
combine_attrs="override",
) | return cls(first_var.dims, data, attrs) | Specialized version of Variable.concat for IndexVariable objects.
This exists because we want to avoid converting Index objects to NumPy
arrays, if possible. | Specialized version of Variable.concat for IndexVariable objects. | [
"Specialized",
"version",
"of",
"Variable",
".",
"concat",
"for",
"IndexVariable",
"objects",
"."
] | def concat(
cls,
variables,
dim="concat_dim",
positions=None,
shortcut=False,
combine_attrs="override",
):
"""Specialized version of Variable.concat for IndexVariable objects.
This exists because we want to avoid converting Index objects to NumPy
... | [
"def",
"concat",
"(",
"cls",
",",
"variables",
",",
"dim",
"=",
"\"concat_dim\"",
",",
"positions",
"=",
"None",
",",
"shortcut",
"=",
"False",
",",
"combine_attrs",
"=",
"\"override\"",
",",
")",
":",
"from",
".",
"merge",
"import",
"merge_attrs",
"if",
... | https://github.com/pydata/xarray/blob/9226c7ac87b3eb246f7a7e49f8f0f23d68951624/xarray/core/variable.py#L2684-L2733 | |
davidbau/ganseeing | 93cea2c8f391aef001ddf9dcb35c43990681a47c | seeing/renormalize.py | python | renormalizer | (source='zc', target='zc') | return Renormalizer(oldoffset, oldscale, newoffset, newscale,
tobyte=(target == 'byte')) | Returns a function that imposes a standard normalization on
the image data. The returned renormalizer operates on either
3d tensor (single image) or 4d tensor (image batch) data.
The normalization target choices are:
zc (default) - zero centered [-1..1]
pt - pytorch [0..1]
imagenet... | Returns a function that imposes a standard normalization on
the image data. The returned renormalizer operates on either
3d tensor (single image) or 4d tensor (image batch) data.
The normalization target choices are: | [
"Returns",
"a",
"function",
"that",
"imposes",
"a",
"standard",
"normalization",
"on",
"the",
"image",
"data",
".",
"The",
"returned",
"renormalizer",
"operates",
"on",
"either",
"3d",
"tensor",
"(",
"single",
"image",
")",
"or",
"4d",
"tensor",
"(",
"image"... | def renormalizer(source='zc', target='zc'):
'''
Returns a function that imposes a standard normalization on
the image data. The returned renormalizer operates on either
3d tensor (single image) or 4d tensor (image batch) data.
The normalization target choices are:
zc (default) - zero cente... | [
"def",
"renormalizer",
"(",
"source",
"=",
"'zc'",
",",
"target",
"=",
"'zc'",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"str",
")",
":",
"oldoffset",
",",
"oldscale",
"=",
"OFFSET_SCALE",
"[",
"source",
"]",
"else",
":",
"normalizer",
"=",
"fi... | https://github.com/davidbau/ganseeing/blob/93cea2c8f391aef001ddf9dcb35c43990681a47c/seeing/renormalize.py#L35-L62 | |
dagrz/aws_pwn | e90d6089adc99a0298549d173d17f01b76b22449 | elevation/dump_cloudformation_stack_descriptions.py | python | process_stack | (stack_name, stack_id) | [] | def process_stack(stack_name, stack_id):
client = boto3.client('cloudformation')
response = None
try:
response = client.describe_stacks(StackName=stack_id)
except ClientError as e:
print(e.response['Error']['Message'])
if response:
if 'ResponseMetadata' in response:
... | [
"def",
"process_stack",
"(",
"stack_name",
",",
"stack_id",
")",
":",
"client",
"=",
"boto3",
".",
"client",
"(",
"'cloudformation'",
")",
"response",
"=",
"None",
"try",
":",
"response",
"=",
"client",
".",
"describe_stacks",
"(",
"StackName",
"=",
"stack_i... | https://github.com/dagrz/aws_pwn/blob/e90d6089adc99a0298549d173d17f01b76b22449/elevation/dump_cloudformation_stack_descriptions.py#L34-L48 | ||||
linxid/Machine_Learning_Study_Path | 558e82d13237114bbb8152483977806fc0c222af | Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/site-packages/pkg_resources/_vendor/pyparsing.py | python | CaselessLiteral.__init__ | ( self, matchString ) | [] | def __init__( self, matchString ):
super(CaselessLiteral,self).__init__( matchString.upper() )
# Preserve the defining literal.
self.returnString = matchString
self.name = "'%s'" % self.returnString
self.errmsg = "Expected " + self.name | [
"def",
"__init__",
"(",
"self",
",",
"matchString",
")",
":",
"super",
"(",
"CaselessLiteral",
",",
"self",
")",
".",
"__init__",
"(",
"matchString",
".",
"upper",
"(",
")",
")",
"# Preserve the defining literal.",
"self",
".",
"returnString",
"=",
"matchStrin... | https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/site-packages/pkg_resources/_vendor/pyparsing.py#L2474-L2479 | ||||
tegaki/tegaki | eceec69fe651d0733c8c8752dae569d2283d0f3c | tegaki-pygtk/tegakigtk/canvas.py | python | Canvas.set_drawing_stopped_time | (self, time_msec) | Set the inactivity time after which a character is considered drawn.
@type time_msec: int
@param time_msec: time in milliseconds | Set the inactivity time after which a character is considered drawn. | [
"Set",
"the",
"inactivity",
"time",
"after",
"which",
"a",
"character",
"is",
"considered",
"drawn",
"."
] | def set_drawing_stopped_time(self, time_msec):
"""
Set the inactivity time after which a character is considered drawn.
@type time_msec: int
@param time_msec: time in milliseconds
"""
self._drawing_stopped_time = time_msec | [
"def",
"set_drawing_stopped_time",
"(",
"self",
",",
"time_msec",
")",
":",
"self",
".",
"_drawing_stopped_time",
"=",
"time_msec"
] | https://github.com/tegaki/tegaki/blob/eceec69fe651d0733c8c8752dae569d2283d0f3c/tegaki-pygtk/tegakigtk/canvas.py#L602-L609 | ||
n1nj4sec/pupy | a5d766ea81fdfe3bc2c38c9bdaf10e9b75af3b39 | pupy/network/lib/rpc/utils/classic.py | python | obtain | (proxy) | return pickle.loads(pickle.dumps(proxy)) | obtains (copies) a remote object from a proxy object. the object is
``pickled`` on the remote side and ``unpickled`` locally, thus moved
**by value**. changes made to the local object will not reflect remotely.
:param proxy: an RPyC proxy object
.. note:: the remote object to must be ``pickle``-able
... | obtains (copies) a remote object from a proxy object. the object is
``pickled`` on the remote side and ``unpickled`` locally, thus moved
**by value**. changes made to the local object will not reflect remotely. | [
"obtains",
"(",
"copies",
")",
"a",
"remote",
"object",
"from",
"a",
"proxy",
"object",
".",
"the",
"object",
"is",
"pickled",
"on",
"the",
"remote",
"side",
"and",
"unpickled",
"locally",
"thus",
"moved",
"**",
"by",
"value",
"**",
".",
"changes",
"made... | def obtain(proxy):
"""obtains (copies) a remote object from a proxy object. the object is
``pickled`` on the remote side and ``unpickled`` locally, thus moved
**by value**. changes made to the local object will not reflect remotely.
:param proxy: an RPyC proxy object
.. note:: the remote object to... | [
"def",
"obtain",
"(",
"proxy",
")",
":",
"return",
"pickle",
".",
"loads",
"(",
"pickle",
".",
"dumps",
"(",
"proxy",
")",
")"
] | https://github.com/n1nj4sec/pupy/blob/a5d766ea81fdfe3bc2c38c9bdaf10e9b75af3b39/pupy/network/lib/rpc/utils/classic.py#L124-L135 | |
nerdvegas/rez | d392c65bf63b4bca8106f938cec49144ba54e770 | src/rez/vendor/pika/channel.py | python | Channel._generate_consumer_tag | (self) | return 'ctag%i.%s' % (self.channel_number, uuid.uuid4().hex) | Generate a consumer tag
NOTE: this protected method may be called by derived classes
:returns: consumer tag
:rtype: str | Generate a consumer tag | [
"Generate",
"a",
"consumer",
"tag"
] | def _generate_consumer_tag(self):
"""Generate a consumer tag
NOTE: this protected method may be called by derived classes
:returns: consumer tag
:rtype: str
"""
return 'ctag%i.%s' % (self.channel_number, uuid.uuid4().hex) | [
"def",
"_generate_consumer_tag",
"(",
"self",
")",
":",
"return",
"'ctag%i.%s'",
"%",
"(",
"self",
".",
"channel_number",
",",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
")"
] | https://github.com/nerdvegas/rez/blob/d392c65bf63b4bca8106f938cec49144ba54e770/src/rez/vendor/pika/channel.py#L336-L345 | |
CLUEbenchmark/CLUENER2020 | a3e1bcf27eb9280d113b3e938561ca07652e32a3 | tf_version/run_classifier_roberta_wwm_large.py | python | _truncate_seq_pair | (tokens_a, tokens_b, max_length) | Truncates a sequence pair in place to the maximum length. | Truncates a sequence pair in place to the maximum length. | [
"Truncates",
"a",
"sequence",
"pair",
"in",
"place",
"to",
"the",
"maximum",
"length",
"."
] | def _truncate_seq_pair(tokens_a, tokens_b, max_length):
"""Truncates a sequence pair in place to the maximum length."""
# This is a simple heuristic which will always truncate the longer sequence
# one token at a time. This makes more sense than truncating an equal percent
# of tokens from each, since ... | [
"def",
"_truncate_seq_pair",
"(",
"tokens_a",
",",
"tokens_b",
",",
"max_length",
")",
":",
"# This is a simple heuristic which will always truncate the longer sequence",
"# one token at a time. This makes more sense than truncating an equal percent",
"# of tokens from each, since if one seq... | https://github.com/CLUEbenchmark/CLUENER2020/blob/a3e1bcf27eb9280d113b3e938561ca07652e32a3/tf_version/run_classifier_roberta_wwm_large.py#L440-L454 | ||
IntelPython/sdc | 1ebf55c00ef38dfbd401a70b3945e352a5a38b87 | examples/series/str/series_str_islower.py | python | series_str_islower | () | return out_series | [] | def series_str_islower():
series = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])
out_series = series.str.islower()
return out_series | [
"def",
"series_str_islower",
"(",
")",
":",
"series",
"=",
"pd",
".",
"Series",
"(",
"[",
"'leopard'",
",",
"'Golden Eagle'",
",",
"'SNAKE'",
",",
"''",
"]",
")",
"out_series",
"=",
"series",
".",
"str",
".",
"islower",
"(",
")",
"return",
"out_series"
] | https://github.com/IntelPython/sdc/blob/1ebf55c00ef38dfbd401a70b3945e352a5a38b87/examples/series/str/series_str_islower.py#L32-L36 | |||
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/lib-tk/Tix.py | python | TixWidget._subwidget_names | (self) | Return the name of all subwidgets. | Return the name of all subwidgets. | [
"Return",
"the",
"name",
"of",
"all",
"subwidgets",
"."
] | def _subwidget_names(self):
"""Return the name of all subwidgets."""
try:
x = self.tk.call(self._w, 'subwidgets', '-all')
return self.tk.split(x)
except TclError:
return None | [
"def",
"_subwidget_names",
"(",
"self",
")",
":",
"try",
":",
"x",
"=",
"self",
".",
"tk",
".",
"call",
"(",
"self",
".",
"_w",
",",
"'subwidgets'",
",",
"'-all'",
")",
"return",
"self",
".",
"tk",
".",
"split",
"(",
"x",
")",
"except",
"TclError",... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/lib-tk/Tix.py#L379-L385 | ||
ansible-collections/community.general | 3faffe8f47968a2400ba3c896c8901c03001a194 | plugins/modules/dimensiondata_network.py | python | DimensionDataNetworkModule.__init__ | (self) | Create a new Dimension Data network module. | Create a new Dimension Data network module. | [
"Create",
"a",
"new",
"Dimension",
"Data",
"network",
"module",
"."
] | def __init__(self):
"""
Create a new Dimension Data network module.
"""
super(DimensionDataNetworkModule, self).__init__(
module=AnsibleModule(
argument_spec=DimensionDataModule.argument_spec_with_wait(
name=dict(type='str', required=True)... | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
"DimensionDataNetworkModule",
",",
"self",
")",
".",
"__init__",
"(",
"module",
"=",
"AnsibleModule",
"(",
"argument_spec",
"=",
"DimensionDataModule",
".",
"argument_spec_with_wait",
"(",
"name",
"=",
"dic... | https://github.com/ansible-collections/community.general/blob/3faffe8f47968a2400ba3c896c8901c03001a194/plugins/modules/dimensiondata_network.py#L128-L148 | ||
learningequality/ka-lite | 571918ea668013dcf022286ea85eff1c5333fb8b | kalite/packages/bundled/securesync/devices/models.py | python | ZoneInvitation.generate | (cls, zone=None, invited_by=None) | return invitation | Returns an unsaved object. | Returns an unsaved object. | [
"Returns",
"an",
"unsaved",
"object",
"."
] | def generate(cls, zone=None, invited_by=None):
"""
Returns an unsaved object.
"""
invited_by = invited_by or Device.get_own_device()
zone = zone or invited_by.get_zone()
assert zone and invited_by
invitation = ZoneInvitation(zone=zone, invited_by=invited_by)
... | [
"def",
"generate",
"(",
"cls",
",",
"zone",
"=",
"None",
",",
"invited_by",
"=",
"None",
")",
":",
"invited_by",
"=",
"invited_by",
"or",
"Device",
".",
"get_own_device",
"(",
")",
"zone",
"=",
"zone",
"or",
"invited_by",
".",
"get_zone",
"(",
")",
"as... | https://github.com/learningequality/ka-lite/blob/571918ea668013dcf022286ea85eff1c5333fb8b/kalite/packages/bundled/securesync/devices/models.py#L488-L500 | |
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | opy/compiler2/ast.py | python | And.getChildren | (self) | return tuple(flatten(self.nodes)) | [] | def getChildren(self):
return tuple(flatten(self.nodes)) | [
"def",
"getChildren",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"flatten",
"(",
"self",
".",
"nodes",
")",
")"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/opy/compiler2/ast.py#L135-L136 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.