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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OWASP/ZSC | 5bb9fed69efdc17996be4856b54af632aaed87b0 | module/readline_windows/pyreadline/modes/notemacs.py | python | NotEmacsMode.previous_history | (self, e) | Move back through the history list, fetching the previous command. | Move back through the history list, fetching the previous command. | [
"Move",
"back",
"through",
"the",
"history",
"list",
"fetching",
"the",
"previous",
"command",
"."
] | def previous_history(self, e): # (C-p)
'''Move back through the history list, fetching the previous command. '''
self._history.previous_history(self.l_buffer) | [
"def",
"previous_history",
"(",
"self",
",",
"e",
")",
":",
"# (C-p)",
"self",
".",
"_history",
".",
"previous_history",
"(",
"self",
".",
"l_buffer",
")"
] | https://github.com/OWASP/ZSC/blob/5bb9fed69efdc17996be4856b54af632aaed87b0/module/readline_windows/pyreadline/modes/notemacs.py#L142-L144 | ||
PlasmaPy/PlasmaPy | 78d63e341216475ce3318e1409296480407c9019 | plasmapy/formulary/braginskii.py | python | _nondim_resistivity | (hall, Z, particle, model, field_orientation) | return alpha_hat | Calculate dimensionless classical resistivity coefficients.
This function is a switchboard / wrapper that calls the appropriate
model-specific functions depending on which model is specified. | Calculate dimensionless classical resistivity coefficients. | [
"Calculate",
"dimensionless",
"classical",
"resistivity",
"coefficients",
"."
] | def _nondim_resistivity(hall, Z, particle, model, field_orientation):
"""
Calculate dimensionless classical resistivity coefficients.
This function is a switchboard / wrapper that calls the appropriate
model-specific functions depending on which model is specified.
"""
if model == "spitzer-harm... | [
"def",
"_nondim_resistivity",
"(",
"hall",
",",
"Z",
",",
"particle",
",",
"model",
",",
"field_orientation",
")",
":",
"if",
"model",
"==",
"\"spitzer-harm\"",
"or",
"model",
"==",
"\"spitzer\"",
":",
"alpha_hat",
"=",
"_nondim_resist_spitzer",
"(",
"Z",
",",... | https://github.com/PlasmaPy/PlasmaPy/blob/78d63e341216475ce3318e1409296480407c9019/plasmapy/formulary/braginskii.py#L1199-L1214 | |
yt-project/yt | dc7b24f9b266703db4c843e329c6c8644d47b824 | yt/visualization/volume_rendering/old_camera.py | python | StereoSphericalCamera._render | (self, double_check, num_threads, image, sampler, msg) | return image | [] | def _render(self, double_check, num_threads, image, sampler, msg):
ncells = sum(b.source_mask.size for b in self.volume.bricks)
pbar = get_pbar("Ray casting " + msg, ncells)
total_cells = 0
if double_check:
for brick in self.volume.bricks:
for data in brick.my... | [
"def",
"_render",
"(",
"self",
",",
"double_check",
",",
"num_threads",
",",
"image",
",",
"sampler",
",",
"msg",
")",
":",
"ncells",
"=",
"sum",
"(",
"b",
".",
"source_mask",
".",
"size",
"for",
"b",
"in",
"self",
".",
"volume",
".",
"bricks",
")",
... | https://github.com/yt-project/yt/blob/dc7b24f9b266703db4c843e329c6c8644d47b824/yt/visualization/volume_rendering/old_camera.py#L2429-L2451 | |||
lfz/Guided-Denoise | 8881ab768d16eaf87342da4ff7dc8271e183e205 | Attackset/fgsm_v3_resv2_inresv2_random/nets/inception_v4.py | python | inception_v4_base | (inputs, final_endpoint='Mixed_7d', scope=None) | Creates the Inception V4 network up to the given final endpoint.
Args:
inputs: a 4-D tensor of size [batch_size, height, width, 3].
final_endpoint: specifies the endpoint to construct the network up to.
It can be one of [ 'Conv2d_1a_3x3', 'Conv2d_2a_3x3', 'Conv2d_2b_3x3',
'Mixed_3a', 'Mixed_4a', ... | Creates the Inception V4 network up to the given final endpoint. | [
"Creates",
"the",
"Inception",
"V4",
"network",
"up",
"to",
"the",
"given",
"final",
"endpoint",
"."
] | def inception_v4_base(inputs, final_endpoint='Mixed_7d', scope=None):
"""Creates the Inception V4 network up to the given final endpoint.
Args:
inputs: a 4-D tensor of size [batch_size, height, width, 3].
final_endpoint: specifies the endpoint to construct the network up to.
It can be one of [ 'Conv2... | [
"def",
"inception_v4_base",
"(",
"inputs",
",",
"final_endpoint",
"=",
"'Mixed_7d'",
",",
"scope",
"=",
"None",
")",
":",
"end_points",
"=",
"{",
"}",
"def",
"add_and_check_final",
"(",
"name",
",",
"net",
")",
":",
"end_points",
"[",
"name",
"]",
"=",
"... | https://github.com/lfz/Guided-Denoise/blob/8881ab768d16eaf87342da4ff7dc8271e183e205/Attackset/fgsm_v3_resv2_inresv2_random/nets/inception_v4.py#L147-L254 | ||
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/rings/valuation/inductive_valuation.py | python | NonFinalInductiveValuation._test_is_equivalence_irreducible | (self, **options) | r"""
Test the correctness of :meth:`is_equivalence_irreducible`.
EXAMPLES::
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, valuations.TrivialValuation(QQ))
sage: v._test_is_equivalence_irreducible() | r"""
Test the correctness of :meth:`is_equivalence_irreducible`. | [
"r",
"Test",
"the",
"correctness",
"of",
":",
"meth",
":",
"is_equivalence_irreducible",
"."
] | def _test_is_equivalence_irreducible(self, **options):
r"""
Test the correctness of :meth:`is_equivalence_irreducible`.
EXAMPLES::
sage: R.<x> = QQ[]
sage: v = GaussValuation(R, valuations.TrivialValuation(QQ))
sage: v._test_is_equivalence_irreducible()
... | [
"def",
"_test_is_equivalence_irreducible",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"tester",
"=",
"self",
".",
"_tester",
"(",
"*",
"*",
"options",
")",
"S",
"=",
"tester",
".",
"some_elements",
"(",
"self",
".",
"domain",
"(",
")",
".",
"some... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/rings/valuation/inductive_valuation.py#L1583-L1607 | ||
biopython/biopython | 2dd97e71762af7b046d7f7f8a4f1e38db6b06c86 | Bio/Application/__init__.py | python | _Switch.__str__ | (self) | Return the value of this option for the commandline.
Includes a trailing space. | Return the value of this option for the commandline. | [
"Return",
"the",
"value",
"of",
"this",
"option",
"for",
"the",
"commandline",
"."
] | def __str__(self):
"""Return the value of this option for the commandline.
Includes a trailing space.
"""
assert not hasattr(self, "value")
if self.is_set:
return f"{self.names[0]} "
else:
return "" | [
"def",
"__str__",
"(",
"self",
")",
":",
"assert",
"not",
"hasattr",
"(",
"self",
",",
"\"value\"",
")",
"if",
"self",
".",
"is_set",
":",
"return",
"f\"{self.names[0]} \"",
"else",
":",
"return",
"\"\""
] | https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/Application/__init__.py#L699-L708 | ||
Calysto/calysto_scheme | 15bf81987870bcae1264e5a0a06feb9a8ee12b8b | calysto_scheme/scheme.py | python | b_handler2_4_d | (assertions, right, test_name, verbose, wrong, env, handler, k) | [] | def b_handler2_4_d(assertions, right, test_name, verbose, wrong, env, handler, k):
msg = get_exception_message(exception_reg)
where = get_exception_info(exception_reg)
assert_exp = (assertions).car
proc_exp = aunparse((cdr_hat(assert_exp)).car)
test_aexp = (cdr_hat(assert_exp)).cdr.car
test_exp ... | [
"def",
"b_handler2_4_d",
"(",
"assertions",
",",
"right",
",",
"test_name",
",",
"verbose",
",",
"wrong",
",",
"env",
",",
"handler",
",",
"k",
")",
":",
"msg",
"=",
"get_exception_message",
"(",
"exception_reg",
")",
"where",
"=",
"get_exception_info",
"(",... | https://github.com/Calysto/calysto_scheme/blob/15bf81987870bcae1264e5a0a06feb9a8ee12b8b/calysto_scheme/scheme.py#L3528-L3552 | ||||
llimllib/pymag-trees | 61a685089d0888dda13d493a4537450167466dee | reingold_actual.py | python | DrawTree.right | (self) | return self.thread or len(self.children) and self.children[-1] | [] | def right(self):
return self.thread or len(self.children) and self.children[-1] | [
"def",
"right",
"(",
"self",
")",
":",
"return",
"self",
".",
"thread",
"or",
"len",
"(",
"self",
".",
"children",
")",
"and",
"self",
".",
"children",
"[",
"-",
"1",
"]"
] | https://github.com/llimllib/pymag-trees/blob/61a685089d0888dda13d493a4537450167466dee/reingold_actual.py#L13-L14 | |||
jthsieh/DDPAE-video-prediction | 219e68301d24615410260c3d33c80ae74f6f2dc3 | models/base_model.py | python | BaseModel.setup | (self, is_train) | [] | def setup(self, is_train):
for _, net in self.nets.items():
if is_train:
net.train()
else:
net.eval() | [
"def",
"setup",
"(",
"self",
",",
"is_train",
")",
":",
"for",
"_",
",",
"net",
"in",
"self",
".",
"nets",
".",
"items",
"(",
")",
":",
"if",
"is_train",
":",
"net",
".",
"train",
"(",
")",
"else",
":",
"net",
".",
"eval",
"(",
")"
] | https://github.com/jthsieh/DDPAE-video-prediction/blob/219e68301d24615410260c3d33c80ae74f6f2dc3/models/base_model.py#L39-L44 | ||||
BitconFeng/Deep-Feature-video | fff73fbcd0e21d5db566d2b63c644e18b2732551 | lib/rpn/rpn.py | python | get_rpn_testbatch | (roidb, cfg) | return data, label, im_info | return a dict of testbatch
:param roidb: ['image', 'flipped']
:return: data, label, im_info | return a dict of testbatch
:param roidb: ['image', 'flipped']
:return: data, label, im_info | [
"return",
"a",
"dict",
"of",
"testbatch",
":",
"param",
"roidb",
":",
"[",
"image",
"flipped",
"]",
":",
"return",
":",
"data",
"label",
"im_info"
] | def get_rpn_testbatch(roidb, cfg):
"""
return a dict of testbatch
:param roidb: ['image', 'flipped']
:return: data, label, im_info
"""
# assert len(roidb) == 1, 'Single batch only'
imgs, roidb = get_image(roidb, cfg)
im_array = imgs
im_info = [np.array([roidb[i]['im_info']], dtype=np... | [
"def",
"get_rpn_testbatch",
"(",
"roidb",
",",
"cfg",
")",
":",
"# assert len(roidb) == 1, 'Single batch only'",
"imgs",
",",
"roidb",
"=",
"get_image",
"(",
"roidb",
",",
"cfg",
")",
"im_array",
"=",
"imgs",
"im_info",
"=",
"[",
"np",
".",
"array",
"(",
"["... | https://github.com/BitconFeng/Deep-Feature-video/blob/fff73fbcd0e21d5db566d2b63c644e18b2732551/lib/rpn/rpn.py#L34-L49 | |
GoogleCloudPlatform/gsutil | 5be882803e76608e2fd29cf8c504ccd1fe0a7746 | gslib/tracker_file.py | python | CreateTrackerDirIfNeeded | () | return tracker_dir | Looks up or creates the gsutil tracker file directory.
This is the configured directory where gsutil keeps its resumable transfer
tracker files. This function creates it if it doesn't already exist.
Returns:
The pathname to the tracker directory. | Looks up or creates the gsutil tracker file directory. | [
"Looks",
"up",
"or",
"creates",
"the",
"gsutil",
"tracker",
"file",
"directory",
"."
] | def CreateTrackerDirIfNeeded():
"""Looks up or creates the gsutil tracker file directory.
This is the configured directory where gsutil keeps its resumable transfer
tracker files. This function creates it if it doesn't already exist.
Returns:
The pathname to the tracker directory.
"""
tracker_dir = co... | [
"def",
"CreateTrackerDirIfNeeded",
"(",
")",
":",
"tracker_dir",
"=",
"config",
".",
"get",
"(",
"'GSUtil'",
",",
"'resumable_tracker_dir'",
",",
"os",
".",
"path",
".",
"join",
"(",
"GetGsutilStateDir",
"(",
")",
",",
"'tracker-files'",
")",
")",
"CreateDirIf... | https://github.com/GoogleCloudPlatform/gsutil/blob/5be882803e76608e2fd29cf8c504ccd1fe0a7746/gslib/tracker_file.py#L89-L101 | |
lixinsu/RCZoo | 37fcb7962fbd4c751c561d4a0c84173881ea8339 | reader/drqa/predictor.py | python | Predictor.predict | (self, document, question, candidates=None, top_n=1) | return results[0] | Predict a single document - question pair. | Predict a single document - question pair. | [
"Predict",
"a",
"single",
"document",
"-",
"question",
"pair",
"."
] | def predict(self, document, question, candidates=None, top_n=1):
"""Predict a single document - question pair."""
results = self.predict_batch([(document, question, candidates,)], top_n)
return results[0] | [
"def",
"predict",
"(",
"self",
",",
"document",
",",
"question",
",",
"candidates",
"=",
"None",
",",
"top_n",
"=",
"1",
")",
":",
"results",
"=",
"self",
".",
"predict_batch",
"(",
"[",
"(",
"document",
",",
"question",
",",
"candidates",
",",
")",
... | https://github.com/lixinsu/RCZoo/blob/37fcb7962fbd4c751c561d4a0c84173881ea8339/reader/drqa/predictor.py#L84-L87 | |
pyvista/pyvista | 012dbb95a9aae406c3cd4cd94fc8c477f871e426 | pyvista/themes.py | python | DefaultTheme.colorbar_horizontal | (self) | return self._colorbar_horizontal | Return or set the default parameters of a horizontal colorbar.
Examples
--------
Set the default horizontal colorbar width to 0.6.
>>> import pyvista
>>> pyvista.global_theme.colorbar_horizontal.width = 0.6 # doctest:+SKIP
Set the default horizontal colorbar height to... | Return or set the default parameters of a horizontal colorbar. | [
"Return",
"or",
"set",
"the",
"default",
"parameters",
"of",
"a",
"horizontal",
"colorbar",
"."
] | def colorbar_horizontal(self) -> _ColorbarConfig:
"""Return or set the default parameters of a horizontal colorbar.
Examples
--------
Set the default horizontal colorbar width to 0.6.
>>> import pyvista
>>> pyvista.global_theme.colorbar_horizontal.width = 0.6 # doctest... | [
"def",
"colorbar_horizontal",
"(",
"self",
")",
"->",
"_ColorbarConfig",
":",
"return",
"self",
".",
"_colorbar_horizontal"
] | https://github.com/pyvista/pyvista/blob/012dbb95a9aae406c3cd4cd94fc8c477f871e426/pyvista/themes.py#L1682-L1697 | |
enthought/mayavi | 2103a273568b8f0bd62328801aafbd6252543ae8 | mayavi/core/lut_manager.py | python | set_lut | (vtk_lut, lut_lst) | return vtk_lut | Setup the tvtk.LookupTable (`vtk_lut`) using the passed list of
lut values. | Setup the tvtk.LookupTable (`vtk_lut`) using the passed list of
lut values. | [
"Setup",
"the",
"tvtk",
".",
"LookupTable",
"(",
"vtk_lut",
")",
"using",
"the",
"passed",
"list",
"of",
"lut",
"values",
"."
] | def set_lut(vtk_lut, lut_lst):
"""Setup the tvtk.LookupTable (`vtk_lut`) using the passed list of
lut values."""
n_col = len(lut_lst)
vtk_lut.number_of_colors = n_col
vtk_lut.build()
for i in range(0, n_col):
lt = lut_lst[i]
vtk_lut.set_table_value(i, lt[0], lt[1], lt[2], lt[3])
... | [
"def",
"set_lut",
"(",
"vtk_lut",
",",
"lut_lst",
")",
":",
"n_col",
"=",
"len",
"(",
"lut_lst",
")",
"vtk_lut",
".",
"number_of_colors",
"=",
"n_col",
"vtk_lut",
".",
"build",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"n_col",
")",
":",
... | https://github.com/enthought/mayavi/blob/2103a273568b8f0bd62328801aafbd6252543ae8/mayavi/core/lut_manager.py#L53-L63 | |
mrlesmithjr/Ansible | d44f0dc0d942bdf3bf7334b307e6048f0ee16e36 | roles/ansible-vsphere-management/scripts/pdns/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py | python | _bypass_ensure_directory | (path) | Sandbox-bypassing version of ensure_directory() | Sandbox-bypassing version of ensure_directory() | [
"Sandbox",
"-",
"bypassing",
"version",
"of",
"ensure_directory",
"()"
] | def _bypass_ensure_directory(path):
"""Sandbox-bypassing version of ensure_directory()"""
if not WRITE_SUPPORT:
raise IOError('"os.mkdir" not supported on this platform.')
dirname, filename = split(path)
if dirname and filename and not isdir(dirname):
_bypass_ensure_directory(dirname)
... | [
"def",
"_bypass_ensure_directory",
"(",
"path",
")",
":",
"if",
"not",
"WRITE_SUPPORT",
":",
"raise",
"IOError",
"(",
"'\"os.mkdir\" not supported on this platform.'",
")",
"dirname",
",",
"filename",
"=",
"split",
"(",
"path",
")",
"if",
"dirname",
"and",
"filena... | https://github.com/mrlesmithjr/Ansible/blob/d44f0dc0d942bdf3bf7334b307e6048f0ee16e36/roles/ansible-vsphere-management/scripts/pdns/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L2948-L2955 | ||
cloudera/impyla | 0c736af4cad2bade9b8e313badc08ec50e81c948 | impala/_thrift_gen/hive_metastore/ttypes.py | python | CommitTxnRequest.write | (self, oprot) | [] | def write(self, oprot):
if oprot._fast_encode is not None and self.thrift_spec is not None:
oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
return
oprot.writeStructBegin('CommitTxnRequest')
if self.txnid is not None:
oprot.write... | [
"def",
"write",
"(",
"self",
",",
"oprot",
")",
":",
"if",
"oprot",
".",
"_fast_encode",
"is",
"not",
"None",
"and",
"self",
".",
"thrift_spec",
"is",
"not",
"None",
":",
"oprot",
".",
"trans",
".",
"write",
"(",
"oprot",
".",
"_fast_encode",
"(",
"s... | https://github.com/cloudera/impyla/blob/0c736af4cad2bade9b8e313badc08ec50e81c948/impala/_thrift_gen/hive_metastore/ttypes.py#L7660-L7670 | ||||
tobyyouup/conv_seq2seq | 78a6e4e62a4c57a5caa9d584033a85e810fd726e | seq2seq/training/utils.py | python | TrainOptions.model_params | (self) | return self._model_params | Returns the training task class | Returns the training task class | [
"Returns",
"the",
"training",
"task",
"class"
] | def model_params(self):
"""Returns the training task class"""
return self._model_params | [
"def",
"model_params",
"(",
"self",
")",
":",
"return",
"self",
".",
"_model_params"
] | https://github.com/tobyyouup/conv_seq2seq/blob/78a6e4e62a4c57a5caa9d584033a85e810fd726e/seq2seq/training/utils.py#L56-L58 | |
nodesign/weio | 1d67d705a5c36a2e825ad13feab910b0aca9a2e8 | handlers/editorHandler.py | python | WeioEditorHandler.on_message | (self, data) | Parsing JSON data that is comming from browser into python object | Parsing JSON data that is comming from browser into python object | [
"Parsing",
"JSON",
"data",
"that",
"is",
"comming",
"from",
"browser",
"into",
"python",
"object"
] | def on_message(self, data):
"""Parsing JSON data that is comming from browser into python object"""
req = json.loads(data)
self.serve(req) | [
"def",
"on_message",
"(",
"self",
",",
"data",
")",
":",
"req",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"self",
".",
"serve",
"(",
"req",
")"
] | https://github.com/nodesign/weio/blob/1d67d705a5c36a2e825ad13feab910b0aca9a2e8/handlers/editorHandler.py#L315-L318 | ||
mlrun/mlrun | 4c120719d64327a34b7ee1ab08fb5e01b258b00a | mlrun/projects/project.py | python | MlrunProject.set_function | (
self,
func: typing.Union[str, mlrun.runtimes.BaseRuntime],
name: str = "",
kind: str = "",
image: str = None,
handler=None,
with_repo: bool = None,
requirements: typing.Union[str, typing.List[str]] = None,
) | return function_object | update or add a function object to the project
function can be provided as an object (func) or a .py/.ipynb/.yaml url
support url prefixes::
object (s3://, v3io://, ..)
MLRun DB e.g. db://project/func:ver
functions hub/market: e.g. hub://sklearn_classifier:master
... | update or add a function object to the project | [
"update",
"or",
"add",
"a",
"function",
"object",
"to",
"the",
"project"
] | def set_function(
self,
func: typing.Union[str, mlrun.runtimes.BaseRuntime],
name: str = "",
kind: str = "",
image: str = None,
handler=None,
with_repo: bool = None,
requirements: typing.Union[str, typing.List[str]] = None,
) -> mlrun.runtimes.BaseRunt... | [
"def",
"set_function",
"(",
"self",
",",
"func",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"mlrun",
".",
"runtimes",
".",
"BaseRuntime",
"]",
",",
"name",
":",
"str",
"=",
"\"\"",
",",
"kind",
":",
"str",
"=",
"\"\"",
",",
"image",
":",
"str",
... | https://github.com/mlrun/mlrun/blob/4c120719d64327a34b7ee1ab08fb5e01b258b00a/mlrun/projects/project.py#L1316-L1390 | |
oracle/graalpython | 577e02da9755d916056184ec441c26e00b70145c | graalpython/lib-python/3/distutils/command/build_clib.py | python | build_clib.get_library_names | (self) | return lib_names | [] | def get_library_names(self):
# Assume the library list is valid -- 'check_library_list()' is
# called from 'finalize_options()', so it should be!
if not self.libraries:
return None
lib_names = []
for (lib_name, build_info) in self.libraries:
lib_names.app... | [
"def",
"get_library_names",
"(",
"self",
")",
":",
"# Assume the library list is valid -- 'check_library_list()' is",
"# called from 'finalize_options()', so it should be!",
"if",
"not",
"self",
".",
"libraries",
":",
"return",
"None",
"lib_names",
"=",
"[",
"]",
"for",
"("... | https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/distutils/command/build_clib.py#L154-L163 | |||
anfederico/Gemini | 54fbf71ce42799bab116d9047ca3cb89ceff8272 | gemini/gemini_core/gemini_master.py | python | Gemini.results | (self) | return percent_change | Print results of backtest to console
:return: | Print results of backtest to console
:return: | [
"Print",
"results",
"of",
"backtest",
"to",
"console",
":",
"return",
":"
] | def results(self):
"""
Print results of backtest to console
:return:
"""
ts = time.time()
results_history = open("results_history.txt", 'a')
results_history.write(datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') + '\n')
title = "{:=^50}"... | [
"def",
"results",
"(",
"self",
")",
":",
"ts",
"=",
"time",
".",
"time",
"(",
")",
"results_history",
"=",
"open",
"(",
"\"results_history.txt\"",
",",
"'a'",
")",
"results_history",
".",
"write",
"(",
"datetime",
".",
"datetime",
".",
"fromtimestamp",
"("... | https://github.com/anfederico/Gemini/blob/54fbf71ce42799bab116d9047ca3cb89ceff8272/gemini/gemini_core/gemini_master.py#L126-L239 | |
hankcs/HanLP | 6c02812969c4827d74b404c3ad4207f71ca9165a | hanlp/common/dataset.py | python | TransformableDataset.should_load_file | (self, data) | return isinstance(data, str) | Determines whether data is a filepath.
Args:
data: Data to check.
Returns: ``True`` to indicate it's a filepath. | Determines whether data is a filepath. | [
"Determines",
"whether",
"data",
"is",
"a",
"filepath",
"."
] | def should_load_file(self, data) -> bool:
"""Determines whether data is a filepath.
Args:
data: Data to check.
Returns: ``True`` to indicate it's a filepath.
"""
return isinstance(data, str) | [
"def",
"should_load_file",
"(",
"self",
",",
"data",
")",
"->",
"bool",
":",
"return",
"isinstance",
"(",
"data",
",",
"str",
")"
] | https://github.com/hankcs/HanLP/blob/6c02812969c4827d74b404c3ad4207f71ca9165a/hanlp/common/dataset.py#L165-L174 | |
diefenbach/django-lfs | 3bbcb3453d324c181ec68d11d5d35115a60a2fd5 | lfs/catalog/models.py | python | Product.get_images | (self) | return images | Returns all images of the product, including the main image. | Returns all images of the product, including the main image. | [
"Returns",
"all",
"images",
"of",
"the",
"product",
"including",
"the",
"main",
"image",
"."
] | def get_images(self):
"""
Returns all images of the product, including the main image.
"""
cache_key = "%s-product-images-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, self.id)
images = cache.get(cache_key)
if images is None:
if self.is_variant() and not self.... | [
"def",
"get_images",
"(",
"self",
")",
":",
"cache_key",
"=",
"\"%s-product-images-%s\"",
"%",
"(",
"settings",
".",
"CACHE_MIDDLEWARE_KEY_PREFIX",
",",
"self",
".",
"id",
")",
"images",
"=",
"cache",
".",
"get",
"(",
"cache_key",
")",
"if",
"images",
"is",
... | https://github.com/diefenbach/django-lfs/blob/3bbcb3453d324c181ec68d11d5d35115a60a2fd5/lfs/catalog/models.py#L976-L992 | |
tp4a/teleport | 1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad | server/www/packages/packages-darwin/x64/tornado/iostream.py | python | BaseIOStream._handle_events | (self, fd, events) | [] | def _handle_events(self, fd, events):
if self.closed():
gen_log.warning("Got events for closed stream %s", fd)
return
try:
if self._connecting:
# Most IOLoops will report a write failed connect
# with the WRITE event, but SelectIOLoop r... | [
"def",
"_handle_events",
"(",
"self",
",",
"fd",
",",
"events",
")",
":",
"if",
"self",
".",
"closed",
"(",
")",
":",
"gen_log",
".",
"warning",
"(",
"\"Got events for closed stream %s\"",
",",
"fd",
")",
"return",
"try",
":",
"if",
"self",
".",
"_connec... | https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-darwin/x64/tornado/iostream.py#L695-L746 | ||||
Octavian-ai/clevr-graph | a7d5be1da0c0c1e1e0a4b3c95f7e793b0de31b50 | gqa/functional.py | python | Architecture.get | (self, graph) | return Architecture(random.choice(StationProperties["architecture"])) | [] | def get(self, graph):
return Architecture(random.choice(StationProperties["architecture"])) | [
"def",
"get",
"(",
"self",
",",
"graph",
")",
":",
"return",
"Architecture",
"(",
"random",
".",
"choice",
"(",
"StationProperties",
"[",
"\"architecture\"",
"]",
")",
")"
] | https://github.com/Octavian-ai/clevr-graph/blob/a7d5be1da0c0c1e1e0a4b3c95f7e793b0de31b50/gqa/functional.py#L112-L113 | |||
21dotco/two1-python | 4e833300fd5a58363e3104ed4c097631e5d296d3 | two1/bitcoin/script_interpreter.py | python | ScriptInterpreter._op_lessthan | (self) | Returns 1 if a is less than b, 0 otherwise. | Returns 1 if a is less than b, 0 otherwise. | [
"Returns",
"1",
"if",
"a",
"is",
"less",
"than",
"b",
"0",
"otherwise",
"."
] | def _op_lessthan(self):
""" Returns 1 if a is less than b, 0 otherwise.
"""
self._do_binary_op(lambda a, b: int(a < b)) | [
"def",
"_op_lessthan",
"(",
"self",
")",
":",
"self",
".",
"_do_binary_op",
"(",
"lambda",
"a",
",",
"b",
":",
"int",
"(",
"a",
"<",
"b",
")",
")"
] | https://github.com/21dotco/two1-python/blob/4e833300fd5a58363e3104ed4c097631e5d296d3/two1/bitcoin/script_interpreter.py#L625-L628 | ||
yuanxiaosc/Multiple-Relations-Extraction-Only-Look-Once | 3d1fc216c6aedc0494e52f2ff142af856dcb673f | bert/create_pretraining_data.py | python | truncate_seq_pair | (tokens_a, tokens_b, max_num_tokens, rng) | Truncates a pair of sequences to a maximum sequence length. | Truncates a pair of sequences to a maximum sequence length. | [
"Truncates",
"a",
"pair",
"of",
"sequences",
"to",
"a",
"maximum",
"sequence",
"length",
"."
] | def truncate_seq_pair(tokens_a, tokens_b, max_num_tokens, rng):
"""Truncates a pair of sequences to a maximum sequence length."""
while True:
total_length = len(tokens_a) + len(tokens_b)
if total_length <= max_num_tokens:
break
trunc_tokens = tokens_a if len(tokens_a) > len(tokens_b) else tokens_... | [
"def",
"truncate_seq_pair",
"(",
"tokens_a",
",",
"tokens_b",
",",
"max_num_tokens",
",",
"rng",
")",
":",
"while",
"True",
":",
"total_length",
"=",
"len",
"(",
"tokens_a",
")",
"+",
"len",
"(",
"tokens_b",
")",
"if",
"total_length",
"<=",
"max_num_tokens",... | https://github.com/yuanxiaosc/Multiple-Relations-Extraction-Only-Look-Once/blob/3d1fc216c6aedc0494e52f2ff142af856dcb673f/bert/create_pretraining_data.py#L391-L406 | ||
zhanlaoban/Transformers_for_Text_Classification | 5e12b21616b29e445e11fe307948e5c55084bb0e | transformers/modeling_distilbert.py | python | MultiHeadSelfAttention.forward | (self, query, key, value, mask, head_mask = None) | Parameters
----------
query: torch.tensor(bs, seq_length, dim)
key: torch.tensor(bs, seq_length, dim)
value: torch.tensor(bs, seq_length, dim)
mask: torch.tensor(bs, seq_length)
Outputs
-------
weights: torch.tensor(bs, n_heads, seq_length, seq_length)
... | Parameters
----------
query: torch.tensor(bs, seq_length, dim)
key: torch.tensor(bs, seq_length, dim)
value: torch.tensor(bs, seq_length, dim)
mask: torch.tensor(bs, seq_length) | [
"Parameters",
"----------",
"query",
":",
"torch",
".",
"tensor",
"(",
"bs",
"seq_length",
"dim",
")",
"key",
":",
"torch",
".",
"tensor",
"(",
"bs",
"seq_length",
"dim",
")",
"value",
":",
"torch",
".",
"tensor",
"(",
"bs",
"seq_length",
"dim",
")",
"... | def forward(self, query, key, value, mask, head_mask = None):
"""
Parameters
----------
query: torch.tensor(bs, seq_length, dim)
key: torch.tensor(bs, seq_length, dim)
value: torch.tensor(bs, seq_length, dim)
mask: torch.tensor(bs, seq_length)
Outputs
... | [
"def",
"forward",
"(",
"self",
",",
"query",
",",
"key",
",",
"value",
",",
"mask",
",",
"head_mask",
"=",
"None",
")",
":",
"bs",
",",
"q_length",
",",
"dim",
"=",
"query",
".",
"size",
"(",
")",
"k_length",
"=",
"key",
".",
"size",
"(",
"1",
... | https://github.com/zhanlaoban/Transformers_for_Text_Classification/blob/5e12b21616b29e445e11fe307948e5c55084bb0e/transformers/modeling_distilbert.py#L142-L198 | ||
huawei-noah/Pretrained-Language-Model | d4694a134bdfacbaef8ff1d99735106bd3b3372b | TernaryBERT-MindSpore/src/cell_wrapper.py | python | ClipGradients.construct | (self,
grads,
clip_type,
clip_value) | return new_grads | clip gradients | clip gradients | [
"clip",
"gradients"
] | def construct(self,
grads,
clip_type,
clip_value):
"""clip gradients"""
if clip_type != 0 and clip_type != 1:
return grads
new_grads = ()
for grad in grads:
dt = self.dtype(grad)
if clip_type == 0:
... | [
"def",
"construct",
"(",
"self",
",",
"grads",
",",
"clip_type",
",",
"clip_value",
")",
":",
"if",
"clip_type",
"!=",
"0",
"and",
"clip_type",
"!=",
"1",
":",
"return",
"grads",
"new_grads",
"=",
"(",
")",
"for",
"grad",
"in",
"grads",
":",
"dt",
"=... | https://github.com/huawei-noah/Pretrained-Language-Model/blob/d4694a134bdfacbaef8ff1d99735106bd3b3372b/TernaryBERT-MindSpore/src/cell_wrapper.py#L162-L178 | |
cvlab-epfl/tf-lift | 5341909002e0a3269a115dc7f9ff7b5330961052 | networks/lift.py | python | Network._build_network | (self) | Define all the architecture here. Use the modules if necessary. | Define all the architecture here. Use the modules if necessary. | [
"Define",
"all",
"the",
"architecture",
"here",
".",
"Use",
"the",
"modules",
"if",
"necessary",
"."
] | def _build_network(self):
"""Define all the architecture here. Use the modules if necessary."""
# Import modules according to the configurations
self.modules = {}
for _key in ["kp", "ori", "desc"]:
self.modules[_key] = importlib.import_module(
"modules.{}".fo... | [
"def",
"_build_network",
"(",
"self",
")",
":",
"# Import modules according to the configurations",
"self",
".",
"modules",
"=",
"{",
"}",
"for",
"_key",
"in",
"[",
"\"kp\"",
",",
"\"ori\"",
",",
"\"desc\"",
"]",
":",
"self",
".",
"modules",
"[",
"_key",
"]"... | https://github.com/cvlab-epfl/tf-lift/blob/5341909002e0a3269a115dc7f9ff7b5330961052/networks/lift.py#L414-L602 | ||
selinon/selinon | 3613153566d454022a138639f0375c63f490c4cb | selinon/system.py | python | System._setup_nodes | (cls, system, nodes_definition, nodes_definition_file_name) | Configure nodes available in the system based on supplied configuration.
:param system: system instance to be used
:type system: selinon.system.System
:param nodes_definition: a list of dictionaries holding flow configuration
:type nodes_definition: dict
:param nodes_definition_... | Configure nodes available in the system based on supplied configuration. | [
"Configure",
"nodes",
"available",
"in",
"the",
"system",
"based",
"on",
"supplied",
"configuration",
"."
] | def _setup_nodes(cls, system, nodes_definition, nodes_definition_file_name):
"""Configure nodes available in the system based on supplied configuration.
:param system: system instance to be used
:type system: selinon.system.System
:param nodes_definition: a list of dictionaries holding ... | [
"def",
"_setup_nodes",
"(",
"cls",
",",
"system",
",",
"nodes_definition",
",",
"nodes_definition_file_name",
")",
":",
"def",
"append_file_name_if_any",
"(",
"error_message",
")",
":",
"\"\"\"Append file name to an error message.\"\"\"",
"if",
"nodes_definition_file_name",
... | https://github.com/selinon/selinon/blob/3613153566d454022a138639f0375c63f490c4cb/selinon/system.py#L1045-L1095 | ||
CalebBell/thermo | 572a47d1b03d49fe609b8d5f826fa6a7cde00828 | thermo/eos.py | python | IG.solve_T | (self, P, V, solution=None) | return P*V*R_inv | r'''Method to calculate `T` from a specified `P` and `V` for the
ideal gas equation of state.
.. math::
T = \frac{PV}{R}
Parameters
----------
P : float
Pressure, [Pa]
V : float
Molar volume, [m^3/mol]
solution : str or None, ... | r'''Method to calculate `T` from a specified `P` and `V` for the
ideal gas equation of state. | [
"r",
"Method",
"to",
"calculate",
"T",
"from",
"a",
"specified",
"P",
"and",
"V",
"for",
"the",
"ideal",
"gas",
"equation",
"of",
"state",
"."
] | def solve_T(self, P, V, solution=None):
r'''Method to calculate `T` from a specified `P` and `V` for the
ideal gas equation of state.
.. math::
T = \frac{PV}{R}
Parameters
----------
P : float
Pressure, [Pa]
V : float
Molar vo... | [
"def",
"solve_T",
"(",
"self",
",",
"P",
",",
"V",
",",
"solution",
"=",
"None",
")",
":",
"self",
".",
"no_T_spec",
"=",
"True",
"return",
"P",
"*",
"V",
"*",
"R_inv"
] | https://github.com/CalebBell/thermo/blob/572a47d1b03d49fe609b8d5f826fa6a7cde00828/thermo/eos.py#L7250-L7275 | |
eblot/pyftdi | 72797e5ae0945d6f771f13102d7fccac255d83d7 | pyftdi/jtag.py | python | JtagController.write_with_read | (self, out: BitSequence,
use_last: bool = False) | return len(out) | Write the given BitSequence while reading the same
number of bits into the FTDI read buffer.
Returns the number of bits written. | Write the given BitSequence while reading the same
number of bits into the FTDI read buffer.
Returns the number of bits written. | [
"Write",
"the",
"given",
"BitSequence",
"while",
"reading",
"the",
"same",
"number",
"of",
"bits",
"into",
"the",
"FTDI",
"read",
"buffer",
".",
"Returns",
"the",
"number",
"of",
"bits",
"written",
"."
] | def write_with_read(self, out: BitSequence,
use_last: bool = False) -> int:
"""Write the given BitSequence while reading the same
number of bits into the FTDI read buffer.
Returns the number of bits written."""
if not isinstance(out, BitSequence):
... | [
"def",
"write_with_read",
"(",
"self",
",",
"out",
":",
"BitSequence",
",",
"use_last",
":",
"bool",
"=",
"False",
")",
"->",
"int",
":",
"if",
"not",
"isinstance",
"(",
"out",
",",
"BitSequence",
")",
":",
"return",
"JtagError",
"(",
"'Expect a BitSequenc... | https://github.com/eblot/pyftdi/blob/72797e5ae0945d6f771f13102d7fccac255d83d7/pyftdi/jtag.py#L299-L327 | |
VLSIDA/OpenRAM | f66aac3264598eeae31225c62b6a4af52412d407 | compiler/pgates/pinv.py | python | pinv.create_ptx | (self) | Create the PMOS and NMOS netlist. | Create the PMOS and NMOS netlist. | [
"Create",
"the",
"PMOS",
"and",
"NMOS",
"netlist",
"."
] | def create_ptx(self):
"""
Create the PMOS and NMOS netlist.
"""
self.pmos_inst = self.add_inst(name="pinv_pmos",
mod=self.pmos)
self.connect_inst(["Z", "A", "vdd", "vdd"])
self.nmos_inst = self.add_inst(name="pinv_nmos",
... | [
"def",
"create_ptx",
"(",
"self",
")",
":",
"self",
".",
"pmos_inst",
"=",
"self",
".",
"add_inst",
"(",
"name",
"=",
"\"pinv_pmos\"",
",",
"mod",
"=",
"self",
".",
"pmos",
")",
"self",
".",
"connect_inst",
"(",
"[",
"\"Z\"",
",",
"\"A\"",
",",
"\"vd... | https://github.com/VLSIDA/OpenRAM/blob/f66aac3264598eeae31225c62b6a4af52412d407/compiler/pgates/pinv.py#L222-L233 | ||
openstack/ironic | b392dc19bcd29cef5a69ec00d2f18a7a19a679e5 | ironic/db/api.py | python | Connection.create_volume_connector | (self, connector_info) | Create a new volume connector.
:param connector_info: Dictionary containing information about the
connector. Example::
{
'uuid': '000000-..',
'type': 'wwnn',
... | Create a new volume connector. | [
"Create",
"a",
"new",
"volume",
"connector",
"."
] | def create_volume_connector(self, connector_info):
"""Create a new volume connector.
:param connector_info: Dictionary containing information about the
connector. Example::
{
'uuid': '000000-..',
... | [
"def",
"create_volume_connector",
"(",
"self",
",",
"connector_info",
")",
":"
] | https://github.com/openstack/ironic/blob/b392dc19bcd29cef5a69ec00d2f18a7a19a679e5/ironic/db/api.py#L795-L813 | ||
ValvePython/steam | 7aef9d2df57c2195f35bd85013e1b5ccb04624a5 | steam/steamid.py | python | SteamID.instance | (self) | return (int(self) >> 32) & 0xFFffF | :rtype: :class:`int` | :rtype: :class:`int` | [
":",
"rtype",
":",
":",
"class",
":",
"int"
] | def instance(self):
"""
:rtype: :class:`int`
"""
return (int(self) >> 32) & 0xFFffF | [
"def",
"instance",
"(",
"self",
")",
":",
"return",
"(",
"int",
"(",
"self",
")",
">>",
"32",
")",
"&",
"0xFFffF"
] | https://github.com/ValvePython/steam/blob/7aef9d2df57c2195f35bd85013e1b5ccb04624a5/steam/steamid.py#L98-L102 | |
deepmind/dm_control | 806a10e896e7c887635328bfa8352604ad0fedae | dm_control/suite/acrobot.py | python | Physics.orientations | (self) | return np.concatenate((self.horizontal(), self.vertical())) | Returns the sines and cosines of the pole angles. | Returns the sines and cosines of the pole angles. | [
"Returns",
"the",
"sines",
"and",
"cosines",
"of",
"the",
"pole",
"angles",
"."
] | def orientations(self):
"""Returns the sines and cosines of the pole angles."""
return np.concatenate((self.horizontal(), self.vertical())) | [
"def",
"orientations",
"(",
"self",
")",
":",
"return",
"np",
".",
"concatenate",
"(",
"(",
"self",
".",
"horizontal",
"(",
")",
",",
"self",
".",
"vertical",
"(",
")",
")",
")"
] | https://github.com/deepmind/dm_control/blob/806a10e896e7c887635328bfa8352604ad0fedae/dm_control/suite/acrobot.py#L76-L78 | |
wifiphisher/wifiphisher | 90b095a7f66ecdab167af2e857196ae0d9702aed | wifiphisher/common/interfaces.py | python | NetworkManager.get_interface_mac | (self, interface_name) | return self._name_to_object[interface_name].mac_address | Return the MAC address of the interface
:param self: A NetworkManager object
:param interface_name: Name of an interface
:type self: NetworkManager
:type interface_name: str
:return: Interface MAC address
:rtype: str | Return the MAC address of the interface | [
"Return",
"the",
"MAC",
"address",
"of",
"the",
"interface"
] | def get_interface_mac(self, interface_name):
"""
Return the MAC address of the interface
:param self: A NetworkManager object
:param interface_name: Name of an interface
:type self: NetworkManager
:type interface_name: str
:return: Interface MAC address
:... | [
"def",
"get_interface_mac",
"(",
"self",
",",
"interface_name",
")",
":",
"return",
"self",
".",
"_name_to_object",
"[",
"interface_name",
"]",
".",
"mac_address"
] | https://github.com/wifiphisher/wifiphisher/blob/90b095a7f66ecdab167af2e857196ae0d9702aed/wifiphisher/common/interfaces.py#L524-L536 | |
biopython/biopython | 2dd97e71762af7b046d7f7f8a4f1e38db6b06c86 | Bio/Graphics/GenomeDiagram/_Track.py | python | Track.to_string | (self, verbose=0) | Return a formatted string with information about the track.
Arguments:
- verbose - Boolean indicating whether a short or complete
account of the track is required | Return a formatted string with information about the track. | [
"Return",
"a",
"formatted",
"string",
"with",
"information",
"about",
"the",
"track",
"."
] | def to_string(self, verbose=0):
"""Return a formatted string with information about the track.
Arguments:
- verbose - Boolean indicating whether a short or complete
account of the track is required
"""
if not verbose: # Return the short description
retu... | [
"def",
"to_string",
"(",
"self",
",",
"verbose",
"=",
"0",
")",
":",
"if",
"not",
"verbose",
":",
"# Return the short description",
"return",
"f\"{self}\"",
"# Use __str__ method instead",
"else",
":",
"# Return the long description",
"outstr",
"=",
"[",
"f\"\\n<{self... | https://github.com/biopython/biopython/blob/2dd97e71762af7b046d7f7f8a4f1e38db6b06c86/Bio/Graphics/GenomeDiagram/_Track.py#L260-L275 | ||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Ubuntu_12/ecdsa/numbertheory.py | python | lcm2 | (a,b) | return (a*b)//gcd(a,b) | Least common multiple of two integers. | Least common multiple of two integers. | [
"Least",
"common",
"multiple",
"of",
"two",
"integers",
"."
] | def lcm2(a,b):
"""Least common multiple of two integers."""
return (a*b)//gcd(a,b) | [
"def",
"lcm2",
"(",
"a",
",",
"b",
")",
":",
"return",
"(",
"a",
"*",
"b",
")",
"//",
"gcd",
"(",
"a",
",",
"b",
")"
] | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Ubuntu_12/ecdsa/numbertheory.py#L226-L229 | |
Blosc/bloscpack | 5efdadf5b6f61e995df1817943afb9629ce28c89 | bloscpack/memory_io.py | python | CompressedMemorySink.write_bloscpack_header | (self) | [] | def write_bloscpack_header(self):
# no op
pass | [
"def",
"write_bloscpack_header",
"(",
"self",
")",
":",
"# no op",
"pass"
] | https://github.com/Blosc/bloscpack/blob/5efdadf5b6f61e995df1817943afb9629ce28c89/bloscpack/memory_io.py#L85-L87 | ||||
cuthbertLab/music21 | bd30d4663e52955ed922c10fdf541419d8c67671 | music21/chord/__init__.py | python | Chord.intervalVectorString | (self) | return Chord.formatVectorString(self.intervalVector) | Return the interval vector as a string representation.
>>> c1 = chord.Chord(['c', 'e-', 'g'])
>>> c1.intervalVectorString
'<001110>' | Return the interval vector as a string representation. | [
"Return",
"the",
"interval",
"vector",
"as",
"a",
"string",
"representation",
"."
] | def intervalVectorString(self):
'''
Return the interval vector as a string representation.
>>> c1 = chord.Chord(['c', 'e-', 'g'])
>>> c1.intervalVectorString
'<001110>'
'''
return Chord.formatVectorString(self.intervalVector) | [
"def",
"intervalVectorString",
"(",
"self",
")",
":",
"return",
"Chord",
".",
"formatVectorString",
"(",
"self",
".",
"intervalVector",
")"
] | https://github.com/cuthbertLab/music21/blob/bd30d4663e52955ed922c10fdf541419d8c67671/music21/chord/__init__.py#L4579-L4587 | |
youknowone/itunes-iap | 2b744356b9cdeb7c6b6a01b84757c705e057bc1b | itunesiap/legacy.py | python | Request.verify_from | (self, url, verify_ssl=False) | return self.result | Try verification from given url. | Try verification from given url. | [
"Try",
"verification",
"from",
"given",
"url",
"."
] | def verify_from(self, url, verify_ssl=False):
"""Try verification from given url."""
# If the password exists from kwargs, pass it up with the request, otherwise leave it alone
post_body = json.dumps(self.request_content)
try:
self.response = requests.post(url, post_body, ver... | [
"def",
"verify_from",
"(",
"self",
",",
"url",
",",
"verify_ssl",
"=",
"False",
")",
":",
"# If the password exists from kwargs, pass it up with the request, otherwise leave it alone",
"post_body",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"request_content",
")",
"tr... | https://github.com/youknowone/itunes-iap/blob/2b744356b9cdeb7c6b6a01b84757c705e057bc1b/itunesiap/legacy.py#L89-L106 | |
pantsbuild/pex | 473c6ac732ed4bc338b4b20a9ec930d1d722c9b4 | pex/vendor/_vendored/setuptools/setuptools/dist.py | python | Feature.warn_deprecated | () | [] | def warn_deprecated():
msg = (
"Features are deprecated and will be removed in a future "
"version. See https://github.com/pypa/setuptools/issues/65."
)
warnings.warn(msg, DistDeprecationWarning, stacklevel=3) | [
"def",
"warn_deprecated",
"(",
")",
":",
"msg",
"=",
"(",
"\"Features are deprecated and will be removed in a future \"",
"\"version. See https://github.com/pypa/setuptools/issues/65.\"",
")",
"warnings",
".",
"warn",
"(",
"msg",
",",
"DistDeprecationWarning",
",",
"stacklevel"... | https://github.com/pantsbuild/pex/blob/473c6ac732ed4bc338b4b20a9ec930d1d722c9b4/pex/vendor/_vendored/setuptools/setuptools/dist.py#L1228-L1233 | ||||
qiucheng025/zao- | 3a5edf3607b3a523f95746bc69b688090c76d89a | lib/gui/display_analysis.py | python | Analysis.summarise_data | (session) | return session.full_summary | Summarise data in a LongRunningThread as it can take a while | Summarise data in a LongRunningThread as it can take a while | [
"Summarise",
"data",
"in",
"a",
"LongRunningThread",
"as",
"it",
"can",
"take",
"a",
"while"
] | def summarise_data(session):
""" Summarise data in a LongRunningThread as it can take a while """
return session.full_summary | [
"def",
"summarise_data",
"(",
"session",
")",
":",
"return",
"session",
".",
"full_summary"
] | https://github.com/qiucheng025/zao-/blob/3a5edf3607b3a523f95746bc69b688090c76d89a/lib/gui/display_analysis.py#L157-L159 | |
apache/incubator-spot | 2d60a2adae7608b43e90ce1b9ec0adf24f6cc8eb | spot-oa/api/resources/flow.py | python | time_line | (ip,date) | return ImpalaEngine.execute_query_as_list(time_line_query) | [] | def time_line(ip,date):
db = Configuration.db()
time_line_query = ("""
SELECT
ip_threat,tstart,tend,srcip,dstip,proto,
sport,dport,ipkt,ibyt
FROM {0}.flow_timeline
WHERE
y={1} AND m={2} AND d={3}
AND ip_threat = '{4}'
""").format(db,date... | [
"def",
"time_line",
"(",
"ip",
",",
"date",
")",
":",
"db",
"=",
"Configuration",
".",
"db",
"(",
")",
"time_line_query",
"=",
"(",
"\"\"\"\n SELECT\n ip_threat,tstart,tend,srcip,dstip,proto,\n\t\t sport,dport,ipkt,ibyt\n FROM {0}.flow_timeline\n ... | https://github.com/apache/incubator-spot/blob/2d60a2adae7608b43e90ce1b9ec0adf24f6cc8eb/spot-oa/api/resources/flow.py#L178-L191 | |||
merkremont/LineVodka | c2fa74107cecf00dd17416b62e4eb579e2c7bbaf | LineAlpha/LineThrift/ChannelService.py | python | Iface.getChannels | (self, lastSynced, locale) | Parameters:
- lastSynced
- locale | Parameters:
- lastSynced
- locale | [
"Parameters",
":",
"-",
"lastSynced",
"-",
"locale"
] | def getChannels(self, lastSynced, locale):
"""
Parameters:
- lastSynced
- locale
"""
pass | [
"def",
"getChannels",
"(",
"self",
",",
"lastSynced",
",",
"locale",
")",
":",
"pass"
] | https://github.com/merkremont/LineVodka/blob/c2fa74107cecf00dd17416b62e4eb579e2c7bbaf/LineAlpha/LineThrift/ChannelService.py#L75-L81 | ||
pyscf/pyscf | 0adfb464333f5ceee07b664f291d4084801bae64 | pyscf/fci/addons.py | python | fix_spin_ | (fciobj, shift=PENALTY, ss=None, **kwargs) | return fciobj | r'''If FCI solver cannot stay on spin eigenfunction, this function can
add a shift to the states which have wrong spin.
.. math::
(H + shift*S^2) |\Psi\rangle = E |\Psi\rangle
Args:
fciobj : An instance of :class:`FCISolver`
Kwargs:
shift : float
Level shift for s... | r'''If FCI solver cannot stay on spin eigenfunction, this function can
add a shift to the states which have wrong spin. | [
"r",
"If",
"FCI",
"solver",
"cannot",
"stay",
"on",
"spin",
"eigenfunction",
"this",
"function",
"can",
"add",
"a",
"shift",
"to",
"the",
"states",
"which",
"have",
"wrong",
"spin",
"."
] | def fix_spin_(fciobj, shift=PENALTY, ss=None, **kwargs):
r'''If FCI solver cannot stay on spin eigenfunction, this function can
add a shift to the states which have wrong spin.
.. math::
(H + shift*S^2) |\Psi\rangle = E |\Psi\rangle
Args:
fciobj : An instance of :class:`FCISolver`
... | [
"def",
"fix_spin_",
"(",
"fciobj",
",",
"shift",
"=",
"PENALTY",
",",
"ss",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"types",
"if",
"'ss_value'",
"in",
"kwargs",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"'fix_spin_: kwarg \"ss_value... | https://github.com/pyscf/pyscf/blob/0adfb464333f5ceee07b664f291d4084801bae64/pyscf/fci/addons.py#L621-L683 | |
django/django | 0a17666045de6739ae1c2ac695041823d5f827f7 | django/utils/hashable.py | python | make_hashable | (value) | return value | Attempt to make value hashable or raise a TypeError if it fails.
The returned value should generate the same hash for equal values. | Attempt to make value hashable or raise a TypeError if it fails. | [
"Attempt",
"to",
"make",
"value",
"hashable",
"or",
"raise",
"a",
"TypeError",
"if",
"it",
"fails",
"."
] | def make_hashable(value):
"""
Attempt to make value hashable or raise a TypeError if it fails.
The returned value should generate the same hash for equal values.
"""
if isinstance(value, dict):
return tuple([
(key, make_hashable(nested_value))
for key, nested_value i... | [
"def",
"make_hashable",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"return",
"tuple",
"(",
"[",
"(",
"key",
",",
"make_hashable",
"(",
"nested_value",
")",
")",
"for",
"key",
",",
"nested_value",
"in",
"sorted",
"(... | https://github.com/django/django/blob/0a17666045de6739ae1c2ac695041823d5f827f7/django/utils/hashable.py#L4-L24 | |
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/groups/abelian_gps/values.py | python | AbelianGroupWithValuesElement.__pow__ | (self, n) | return pow_self | Exponentiate ``self``
INPUT:
- ``n`` -- integer. The exponent.
TESTS::
sage: G.<a,b> = AbelianGroupWithValues([5,2], 2)
sage: a^3
a^3
sage: (a^3).value()
125 | Exponentiate ``self`` | [
"Exponentiate",
"self"
] | def __pow__(self, n):
"""
Exponentiate ``self``
INPUT:
- ``n`` -- integer. The exponent.
TESTS::
sage: G.<a,b> = AbelianGroupWithValues([5,2], 2)
sage: a^3
a^3
sage: (a^3).value()
125
"""
m = Integer(... | [
"def",
"__pow__",
"(",
"self",
",",
"n",
")",
":",
"m",
"=",
"Integer",
"(",
"n",
")",
"if",
"n",
"!=",
"m",
":",
"raise",
"TypeError",
"(",
"'argument n (= '",
"+",
"str",
"(",
"n",
")",
"+",
"') must be an integer.'",
")",
"pow_self",
"=",
"Abelian... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/groups/abelian_gps/values.py#L309-L330 | |
libertysoft3/saidit | 271c7d03adb369f82921d811360b00812e42da24 | r2/r2/controllers/api.py | python | ApiController.POST_set_sr_style_enabled | (self, form, jquery, sr_style_enabled) | Update enabling of individual sr themes; refresh the page style | Update enabling of individual sr themes; refresh the page style | [
"Update",
"enabling",
"of",
"individual",
"sr",
"themes",
";",
"refresh",
"the",
"page",
"style"
] | def POST_set_sr_style_enabled(self, form, jquery, sr_style_enabled):
"""Update enabling of individual sr themes; refresh the page style"""
if feature.is_enabled('stylesheets_everywhere'):
c.user.set_subreddit_style(c.site, sr_style_enabled)
c.can_apply_styles = True
s... | [
"def",
"POST_set_sr_style_enabled",
"(",
"self",
",",
"form",
",",
"jquery",
",",
"sr_style_enabled",
")",
":",
"if",
"feature",
".",
"is_enabled",
"(",
"'stylesheets_everywhere'",
")",
":",
"c",
".",
"user",
".",
"set_subreddit_style",
"(",
"c",
".",
"site",
... | https://github.com/libertysoft3/saidit/blob/271c7d03adb369f82921d811360b00812e42da24/r2/r2/controllers/api.py#L4494-L4520 | ||
dimagi/commcare-hq | d67ff1d3b4c51fa050c19e60c3253a79d3452a39 | corehq/apps/userreports/sql/adapter.py | python | MultiDBSqlAdapter.get_distinct_values | (self, column, limit) | return self.main_adapter.get_distinct_values(column, limit) | [] | def get_distinct_values(self, column, limit):
return self.main_adapter.get_distinct_values(column, limit) | [
"def",
"get_distinct_values",
"(",
"self",
",",
"column",
",",
"limit",
")",
":",
"return",
"self",
".",
"main_adapter",
".",
"get_distinct_values",
"(",
"column",
",",
"limit",
")"
] | https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/userreports/sql/adapter.py#L259-L260 | |||
SigmaHQ/sigma | 6f7d28b52a6468b2430e8d7dfefb79dc01e2f1af | tools/sigma/backends/sumologic.py | python | SumoLogicBackend.generateAggregation | (self, agg) | [] | def generateAggregation(self, agg):
# lnx_shell_priv_esc_prep.yml
# print("DEBUG generateAggregation(): %s, %s, %s, %s" % (agg.aggfunc_notrans, agg.aggfield, agg.groupfield, agg.cond_op))
if agg.groupfield == 'host':
agg.groupfield = 'hostname'
if agg.aggfunc_notrans == 'coun... | [
"def",
"generateAggregation",
"(",
"self",
",",
"agg",
")",
":",
"# lnx_shell_priv_esc_prep.yml",
"# print(\"DEBUG generateAggregation(): %s, %s, %s, %s\" % (agg.aggfunc_notrans, agg.aggfield, agg.groupfield, agg.cond_op))",
"if",
"agg",
".",
"groupfield",
"==",
"'host'",
":",
"agg... | https://github.com/SigmaHQ/sigma/blob/6f7d28b52a6468b2430e8d7dfefb79dc01e2f1af/tools/sigma/backends/sumologic.py#L58-L104 | ||||
src-d/ml | db23fb14fc93dece05b434342def5f77b01c6cc3 | sourced/ml/algorithms/id_splitter/features.py | python | prepare_features | (csv_path: str, use_header: bool, max_identifier_len: int,
identifier_col: int, split_identifier_col: int, test_ratio: float,
padding: str, shuffle: bool = True) | return X_train, X_test, y_train[:, :, None], y_test[:, :, None] | Prepare the features to train the identifier splitting task.
:param csv_path: path to the CSV file.
:param use_header: uses header as normal line (True) or treat as header line with column names.
:param max_identifier_len: maximum length of raw identifiers. Skip identifiers that are longer.
:param iden... | Prepare the features to train the identifier splitting task. | [
"Prepare",
"the",
"features",
"to",
"train",
"the",
"identifier",
"splitting",
"task",
"."
] | def prepare_features(csv_path: str, use_header: bool, max_identifier_len: int,
identifier_col: int, split_identifier_col: int, test_ratio: float,
padding: str, shuffle: bool = True) -> Tuple[numpy.array]:
"""
Prepare the features to train the identifier splitting task.
... | [
"def",
"prepare_features",
"(",
"csv_path",
":",
"str",
",",
"use_header",
":",
"bool",
",",
"max_identifier_len",
":",
"int",
",",
"identifier_col",
":",
"int",
",",
"split_identifier_col",
":",
"int",
",",
"test_ratio",
":",
"float",
",",
"padding",
":",
"... | https://github.com/src-d/ml/blob/db23fb14fc93dece05b434342def5f77b01c6cc3/sourced/ml/algorithms/id_splitter/features.py#L44-L118 | |
GRAND-Lab/ARGA | a970fa583d8c474b18f950da06bf91da03a647db | ARGA/arga/layers.py | python | dropout_sparse | (x, keep_prob, num_nonzero_elems) | return pre_out * (1./keep_prob) | Dropout for sparse tensors. Currently fails for very large sparse tensors (>1M elements) | Dropout for sparse tensors. Currently fails for very large sparse tensors (>1M elements) | [
"Dropout",
"for",
"sparse",
"tensors",
".",
"Currently",
"fails",
"for",
"very",
"large",
"sparse",
"tensors",
"(",
">",
"1M",
"elements",
")"
] | def dropout_sparse(x, keep_prob, num_nonzero_elems):
"""Dropout for sparse tensors. Currently fails for very large sparse tensors (>1M elements)
"""
noise_shape = [num_nonzero_elems]
random_tensor = keep_prob
random_tensor += tf.random_uniform(noise_shape)
dropout_mask = tf.cast(tf.floor(random_... | [
"def",
"dropout_sparse",
"(",
"x",
",",
"keep_prob",
",",
"num_nonzero_elems",
")",
":",
"noise_shape",
"=",
"[",
"num_nonzero_elems",
"]",
"random_tensor",
"=",
"keep_prob",
"random_tensor",
"+=",
"tf",
".",
"random_uniform",
"(",
"noise_shape",
")",
"dropout_mas... | https://github.com/GRAND-Lab/ARGA/blob/a970fa583d8c474b18f950da06bf91da03a647db/ARGA/arga/layers.py#L22-L30 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/richards3-timed.py | python | IdleTask.__init__ | (self,i,p,w,s,r) | [] | def __init__(self,i,p,w,s,r):
Task.__init__(self,i,0,None,s,r) | [
"def",
"__init__",
"(",
"self",
",",
"i",
",",
"p",
",",
"w",
",",
"s",
",",
"r",
")",
":",
"Task",
".",
"__init__",
"(",
"self",
",",
"i",
",",
"0",
",",
"None",
",",
"s",
",",
"r",
")"
] | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/richards3-timed.py#L297-L298 | ||||
Kronuz/esprima-python | 809cb6e257b1d3d5b0d23f2bca7976e21f02fc3d | esprima/nodes.py | python | Identifier.__init__ | (self, name) | [] | def __init__(self, name):
self.type = Syntax.Identifier
self.name = name | [
"def",
"__init__",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"type",
"=",
"Syntax",
".",
"Identifier",
"self",
".",
"name",
"=",
"name"
] | https://github.com/Kronuz/esprima-python/blob/809cb6e257b1d3d5b0d23f2bca7976e21f02fc3d/esprima/nodes.py#L310-L312 | ||||
ysrc/xunfeng | 40d40ecf55910019b8b904ef70ae1eebb6b6d26f | vulscan/vulscan.py | python | install_kunpeng_plugin | () | [] | def install_kunpeng_plugin():
time_ = datetime.datetime.now()
for plugin in kp.get_plugin_list():
level_list = ['紧急','高危','中危','低危','提示']
plugin_info = {
'_id': plugin['references']['kpid'],
'name': 'Kunpeng -' + plugin['name'],
'info': plugin['remarks'] + ' '... | [
"def",
"install_kunpeng_plugin",
"(",
")",
":",
"time_",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"for",
"plugin",
"in",
"kp",
".",
"get_plugin_list",
"(",
")",
":",
"level_list",
"=",
"[",
"'紧急','高危",
"'",
",'中危','低",
"危",
"','提示']",
"",
... | https://github.com/ysrc/xunfeng/blob/40d40ecf55910019b8b904ef70ae1eebb6b6d26f/vulscan/vulscan.py#L248-L266 | ||||
tensorflow/lingvo | ce10019243d954c3c3ebe739f7589b5eebfdf907 | lingvo/core/py_utils.py | python | WeightInit.GaussianSqrtDim | (scale=1.0, seed=None) | return WeightInit._Params('gaussian_sqrt_dim', scale, seed) | scale * tf.random.normal(0, 1 / sqrt(dim0)). | scale * tf.random.normal(0, 1 / sqrt(dim0)). | [
"scale",
"*",
"tf",
".",
"random",
".",
"normal",
"(",
"0",
"1",
"/",
"sqrt",
"(",
"dim0",
"))",
"."
] | def GaussianSqrtDim(scale=1.0, seed=None):
"""scale * tf.random.normal(0, 1 / sqrt(dim0))."""
return WeightInit._Params('gaussian_sqrt_dim', scale, seed) | [
"def",
"GaussianSqrtDim",
"(",
"scale",
"=",
"1.0",
",",
"seed",
"=",
"None",
")",
":",
"return",
"WeightInit",
".",
"_Params",
"(",
"'gaussian_sqrt_dim'",
",",
"scale",
",",
"seed",
")"
] | https://github.com/tensorflow/lingvo/blob/ce10019243d954c3c3ebe739f7589b5eebfdf907/lingvo/core/py_utils.py#L1063-L1065 | |
openstack/designate | bff3d5f6e31fe595a77143ec4ac779c187bf72a8 | designate/objects/base.py | python | ListObjectMixin.__contains__ | (self, value) | return value in self.objects | List membership test | List membership test | [
"List",
"membership",
"test"
] | def __contains__(self, value):
"""List membership test"""
return value in self.objects | [
"def",
"__contains__",
"(",
"self",
",",
"value",
")",
":",
"return",
"value",
"in",
"self",
".",
"objects"
] | https://github.com/openstack/designate/blob/bff3d5f6e31fe595a77143ec4ac779c187bf72a8/designate/objects/base.py#L386-L388 | |
mdiazcl/fuzzbunch-debian | 2b76c2249ade83a389ae3badb12a1bd09901fd2c | windows/Resources/Python/Core/Lib/cookielib.py | python | is_third_party | (request) | RFC 2965, section 3.3.6:
An unverifiable transaction is to a third-party host if its request-
host U does not domain-match the reach R of the request-host O in the
origin transaction. | RFC 2965, section 3.3.6:
An unverifiable transaction is to a third-party host if its request-
host U does not domain-match the reach R of the request-host O in the
origin transaction. | [
"RFC",
"2965",
"section",
"3",
".",
"3",
".",
"6",
":",
"An",
"unverifiable",
"transaction",
"is",
"to",
"a",
"third",
"-",
"party",
"host",
"if",
"its",
"request",
"-",
"host",
"U",
"does",
"not",
"domain",
"-",
"match",
"the",
"reach",
"R",
"of",
... | def is_third_party(request):
"""
RFC 2965, section 3.3.6:
An unverifiable transaction is to a third-party host if its request-
host U does not domain-match the reach R of the request-host O in the
origin transaction.
"""
req_host = request_host(request)
if not ... | [
"def",
"is_third_party",
"(",
"request",
")",
":",
"req_host",
"=",
"request_host",
"(",
"request",
")",
"if",
"not",
"domain_match",
"(",
"req_host",
",",
"reach",
"(",
"request",
".",
"get_origin_req_host",
"(",
")",
")",
")",
":",
"return",
"True",
"els... | https://github.com/mdiazcl/fuzzbunch-debian/blob/2b76c2249ade83a389ae3badb12a1bd09901fd2c/windows/Resources/Python/Core/Lib/cookielib.py#L635-L649 | ||
mozillazg/pypy | 2ff5cd960c075c991389f842c6d59e71cf0cb7d0 | lib-python/2.7/atexit.py | python | register | (func, *targs, **kargs) | return func | register a function to be executed upon normal program termination
func - function to be called at exit
targs - optional arguments to pass to func
kargs - optional keyword arguments to pass to func
func is returned to facilitate usage as a decorator. | register a function to be executed upon normal program termination | [
"register",
"a",
"function",
"to",
"be",
"executed",
"upon",
"normal",
"program",
"termination"
] | def register(func, *targs, **kargs):
"""register a function to be executed upon normal program termination
func - function to be called at exit
targs - optional arguments to pass to func
kargs - optional keyword arguments to pass to func
func is returned to facilitate usage as a decorator.
"""... | [
"def",
"register",
"(",
"func",
",",
"*",
"targs",
",",
"*",
"*",
"kargs",
")",
":",
"_exithandlers",
".",
"append",
"(",
"(",
"func",
",",
"targs",
",",
"kargs",
")",
")",
"return",
"func"
] | https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/atexit.py#L37-L47 | |
raffaele-forte/climber | 5530a780446e35b1ce977bae140557050fe0b47c | Exscript/Account.py | python | Account.context | (self) | return Context(self) | When you need a 'with' context for an already-acquired account. | When you need a 'with' context for an already-acquired account. | [
"When",
"you",
"need",
"a",
"with",
"context",
"for",
"an",
"already",
"-",
"acquired",
"account",
"."
] | def context(self):
"""
When you need a 'with' context for an already-acquired account.
"""
return Context(self) | [
"def",
"context",
"(",
"self",
")",
":",
"return",
"Context",
"(",
"self",
")"
] | https://github.com/raffaele-forte/climber/blob/5530a780446e35b1ce977bae140557050fe0b47c/Exscript/Account.py#L62-L66 | |
CGATOxford/cgat | 326aad4694bdfae8ddc194171bb5d73911243947 | CGAT/CSV2DB.py | python | executewait | (dbhandle, statement, error,
retry=False,
wait=5,
args=()) | execute sql statement.
Retry on error, if retry is True.
Returns a cursor object. | execute sql statement. | [
"execute",
"sql",
"statement",
"."
] | def executewait(dbhandle, statement, error,
retry=False,
wait=5,
args=()):
'''execute sql statement.
Retry on error, if retry is True.
Returns a cursor object.
'''
cc = dbhandle.cursor()
i = 20
while i > 0:
try:
cc.execute... | [
"def",
"executewait",
"(",
"dbhandle",
",",
"statement",
",",
"error",
",",
"retry",
"=",
"False",
",",
"wait",
"=",
"5",
",",
"args",
"=",
"(",
")",
")",
":",
"cc",
"=",
"dbhandle",
".",
"cursor",
"(",
")",
"i",
"=",
"20",
"while",
"i",
">",
"... | https://github.com/CGATOxford/cgat/blob/326aad4694bdfae8ddc194171bb5d73911243947/CGAT/CSV2DB.py#L43-L71 | ||
exercism/python | f79d44ef6c9cf68d8c76cb94017a590f04391635 | exercises/practice/luhn/.meta/example.py | python | Luhn.__init__ | (self, card_num) | [] | def __init__(self, card_num):
self.card_num = card_num
self.checksum = -1
digits = card_num.replace(' ', '')
length = len(digits)
if digits.isdigit() and length > 1:
self.checksum = 0
cadence = length % 2
for idx, digit in enumerate(digits):
... | [
"def",
"__init__",
"(",
"self",
",",
"card_num",
")",
":",
"self",
".",
"card_num",
"=",
"card_num",
"self",
".",
"checksum",
"=",
"-",
"1",
"digits",
"=",
"card_num",
".",
"replace",
"(",
"' '",
",",
"''",
")",
"length",
"=",
"len",
"(",
"digits",
... | https://github.com/exercism/python/blob/f79d44ef6c9cf68d8c76cb94017a590f04391635/exercises/practice/luhn/.meta/example.py#L2-L16 | ||||
django-parler/django-parler | 577ca2f4a80713a9272c48db30e914a4d9332358 | parler/fields.py | python | _validate_master | (new_class) | return shared_model | Check whether the 'master' field on a TranslatedFieldsModel is correctly configured. | Check whether the 'master' field on a TranslatedFieldsModel is correctly configured. | [
"Check",
"whether",
"the",
"master",
"field",
"on",
"a",
"TranslatedFieldsModel",
"is",
"correctly",
"configured",
"."
] | def _validate_master(new_class):
"""
Check whether the 'master' field on a TranslatedFieldsModel is correctly configured.
"""
if not new_class.master or not isinstance(new_class.master, ForwardManyToOneDescriptor):
raise ImproperlyConfigured(
f"{new_class.__name__}.master should be a... | [
"def",
"_validate_master",
"(",
"new_class",
")",
":",
"if",
"not",
"new_class",
".",
"master",
"or",
"not",
"isinstance",
"(",
"new_class",
".",
"master",
",",
"ForwardManyToOneDescriptor",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"f\"{new_class.__name__}.ma... | https://github.com/django-parler/django-parler/blob/577ca2f4a80713a9272c48db30e914a4d9332358/parler/fields.py#L18-L51 | |
pykaldi/pykaldi | b4e7a15a31286e57c01259edfda54d113b5ceb0e | kaldi/fstext/_api.py | python | _MutableFstBase.invert | (self) | return self | Inverts the FST's transduction.
This operation destructively inverts the FST's transduction by
exchanging input and output labels.
Returns:
self. | Inverts the FST's transduction. | [
"Inverts",
"the",
"FST",
"s",
"transduction",
"."
] | def invert(self):
"""
Inverts the FST's transduction.
This operation destructively inverts the FST's transduction by
exchanging input and output labels.
Returns:
self.
"""
self._ops.invert(self)
self._check_mutating_imethod()
return sel... | [
"def",
"invert",
"(",
"self",
")",
":",
"self",
".",
"_ops",
".",
"invert",
"(",
"self",
")",
"self",
".",
"_check_mutating_imethod",
"(",
")",
"return",
"self"
] | https://github.com/pykaldi/pykaldi/blob/b4e7a15a31286e57c01259edfda54d113b5ceb0e/kaldi/fstext/_api.py#L847-L859 | |
faucetsdn/ryu | 537f35f4b2bc634ef05e3f28373eb5e24609f989 | ryu/services/protocols/bgp/application.py | python | RyuBGPSpeaker._add_routes | (self, settings) | Add BGP routes from given settings.
All valid routes are loaded.
Miss-configured routes are ignored and errors are logged. | Add BGP routes from given settings. | [
"Add",
"BGP",
"routes",
"from",
"given",
"settings",
"."
] | def _add_routes(self, settings):
"""
Add BGP routes from given settings.
All valid routes are loaded.
Miss-configured routes are ignored and errors are logged.
"""
for route_settings in settings:
if 'prefix' in route_settings:
prefix_add = sel... | [
"def",
"_add_routes",
"(",
"self",
",",
"settings",
")",
":",
"for",
"route_settings",
"in",
"settings",
":",
"if",
"'prefix'",
"in",
"route_settings",
":",
"prefix_add",
"=",
"self",
".",
"speaker",
".",
"prefix_add",
"elif",
"'route_type'",
"in",
"route_sett... | https://github.com/faucetsdn/ryu/blob/537f35f4b2bc634ef05e3f28373eb5e24609f989/ryu/services/protocols/bgp/application.py#L409-L431 | ||
aws-solutions/aws-instance-scheduler | d9208ddc4528536f20e14127ea0f49f8c52ea811 | source/lambda/requesthandlers/scheduler_setup_handler.py | python | SchedulerSetupHandler.started_tags | (self) | return self.resource_properties.get(configuration.STARTED_TAGS, None) | Returns started tags as a string
:return: started tags | Returns started tags as a string
:return: started tags | [
"Returns",
"started",
"tags",
"as",
"a",
"string",
":",
"return",
":",
"started",
"tags"
] | def started_tags(self):
"""
Returns started tags as a string
:return: started tags
"""
return self.resource_properties.get(configuration.STARTED_TAGS, None) | [
"def",
"started_tags",
"(",
"self",
")",
":",
"return",
"self",
".",
"resource_properties",
".",
"get",
"(",
"configuration",
".",
"STARTED_TAGS",
",",
"None",
")"
] | https://github.com/aws-solutions/aws-instance-scheduler/blob/d9208ddc4528536f20e14127ea0f49f8c52ea811/source/lambda/requesthandlers/scheduler_setup_handler.py#L115-L120 | |
robotframework/SeleniumLibrary | 0d8caf35cd8325ff391c27fe814744060470018e | src/SeleniumLibrary/keywords/browsermanagement.py | python | BrowserManagementKeywords.get_browser_ids | (self) | return self.drivers.active_driver_ids | Returns index of all active browser as list.
Example:
| @{browser_ids}= | Get Browser Ids | | |
| FOR | ${id} | IN | @{browser_ids} |
| | @{window_titles}= | Get Window Titles | browser=${id} |
... | Returns index of all active browser as list. | [
"Returns",
"index",
"of",
"all",
"active",
"browser",
"as",
"list",
"."
] | def get_browser_ids(self) -> List[str]:
"""Returns index of all active browser as list.
Example:
| @{browser_ids}= | Get Browser Ids | | |
| FOR | ${id} | IN | @{browser_ids} |
| | @{window... | [
"def",
"get_browser_ids",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"self",
".",
"drivers",
".",
"active_driver_ids"
] | https://github.com/robotframework/SeleniumLibrary/blob/0d8caf35cd8325ff391c27fe814744060470018e/src/SeleniumLibrary/keywords/browsermanagement.py#L442-L456 | |
theopolis/uefi-firmware-parser | 0171b4639ca0825db4fac5240c996e8a733bc6a4 | uefi_firmware/utils.py | python | aguid | (b, big=False) | return [a, b, c] + [_c for _c in d] | RFC4122 binary GUID as int array. | RFC4122 binary GUID as int array. | [
"RFC4122",
"binary",
"GUID",
"as",
"int",
"array",
"."
] | def aguid(b, big=False):
'''RFC4122 binary GUID as int array.'''
a, b, c, d = struct.unpack("%sIHH8s" % (">" if big else "<"), b)
return [a, b, c] + [_c for _c in d] | [
"def",
"aguid",
"(",
"b",
",",
"big",
"=",
"False",
")",
":",
"a",
",",
"b",
",",
"c",
",",
"d",
"=",
"struct",
".",
"unpack",
"(",
"\"%sIHH8s\"",
"%",
"(",
"\">\"",
"if",
"big",
"else",
"\"<\"",
")",
",",
"b",
")",
"return",
"[",
"a",
",",
... | https://github.com/theopolis/uefi-firmware-parser/blob/0171b4639ca0825db4fac5240c996e8a733bc6a4/uefi_firmware/utils.py#L103-L106 | |
gem/oq-engine | 1bdb88f3914e390abcbd285600bfd39477aae47c | openquake/hazardlib/geo/polygon.py | python | Polygon.wkt | (self) | return 'POLYGON((%s))' % ', '.join(pairs) | Generate WKT (Well-Known Text) to represent this polygon. | Generate WKT (Well-Known Text) to represent this polygon. | [
"Generate",
"WKT",
"(",
"Well",
"-",
"Known",
"Text",
")",
"to",
"represent",
"this",
"polygon",
"."
] | def wkt(self):
"""
Generate WKT (Well-Known Text) to represent this polygon.
"""
pairs = ['%.5f %.5f' % (lon, lat)
for lon, lat in zip(self.lons, self.lats)]
# the polygon must form a closed loop; first and last coord pairs
# are the same
pairs.ap... | [
"def",
"wkt",
"(",
"self",
")",
":",
"pairs",
"=",
"[",
"'%.5f %.5f'",
"%",
"(",
"lon",
",",
"lat",
")",
"for",
"lon",
",",
"lat",
"in",
"zip",
"(",
"self",
".",
"lons",
",",
"self",
".",
"lats",
")",
"]",
"# the polygon must form a closed loop; first ... | https://github.com/gem/oq-engine/blob/1bdb88f3914e390abcbd285600bfd39477aae47c/openquake/hazardlib/geo/polygon.py#L74-L83 | |
robcarver17/pysystemtrade | b0385705b7135c52d39cb6d2400feece881bcca9 | systems/forecast_combine.py | python | ForecastCombine.calculation_of_raw_estimated_monthly_forecast_weights | (self, instrument_code) | return weight_func | Does an optimisation for a single instrument
We do this if we can't do the special case of a fully pooled
optimisation (both costs and returns pooled)
Estimate the forecast weights for this instrument
We store this intermediate step to expose the calculation object
:param ins... | Does an optimisation for a single instrument | [
"Does",
"an",
"optimisation",
"for",
"a",
"single",
"instrument"
] | def calculation_of_raw_estimated_monthly_forecast_weights(self, instrument_code):
"""
Does an optimisation for a single instrument
We do this if we can't do the special case of a fully pooled
optimisation (both costs and returns pooled)
Estimate the forecast weights for this in... | [
"def",
"calculation_of_raw_estimated_monthly_forecast_weights",
"(",
"self",
",",
"instrument_code",
")",
":",
"self",
".",
"log",
".",
"terse",
"(",
"\"Calculating raw forecast weights for %s\"",
"%",
"instrument_code",
")",
"config",
"=",
"self",
".",
"config",
"# Get... | https://github.com/robcarver17/pysystemtrade/blob/b0385705b7135c52d39cb6d2400feece881bcca9/systems/forecast_combine.py#L564-L599 | |
dask/dask-jobqueue | 4980e746e9be15e5fe6736b6c496b8faea737fd7 | dask_jobqueue/_version.py | python | git_pieces_from_vcs | (tag_prefix, root, verbose, run_command=run_command) | return pieces | Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we're inside a checked out source tree. | Get version from 'git describe' in the root of the source tree. | [
"Get",
"version",
"from",
"git",
"describe",
"in",
"the",
"root",
"of",
"the",
"source",
"tree",
"."
] | def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
"""Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meani... | [
"def",
"git_pieces_from_vcs",
"(",
"tag_prefix",
",",
"root",
",",
"verbose",
",",
"run_command",
"=",
"run_command",
")",
":",
"GITS",
"=",
"[",
"\"git\"",
"]",
"if",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"GITS",
"=",
"[",
"\"git.cmd\"",
",",
... | https://github.com/dask/dask-jobqueue/blob/4980e746e9be15e5fe6736b6c496b8faea737fd7/dask_jobqueue/_version.py#L233-L330 | |
j-bennet/wharfee | a48536cba5d3830a29c63bb440b3e74a8a23431d | scripts/optionizer.py | python | format_option | (info) | return textwrap.dedent(result).strip() | Format code to create CommandOption.
:param info: OptInfo
:return: str | Format code to create CommandOption.
:param info: OptInfo
:return: str | [
"Format",
"code",
"to",
"create",
"CommandOption",
".",
":",
"param",
"info",
":",
"OptInfo",
":",
"return",
":",
"str"
] | def format_option(info):
"""
Format code to create CommandOption.
:param info: OptInfo
:return: str
"""
tmpl = Template("""
CommandOption(
CommandOption.{{ const_type }},
{{ short_name }},
{{ long_name }},
action='{{ action }}',
dest='{{ dest }}',{% if... | [
"def",
"format_option",
"(",
"info",
")",
":",
"tmpl",
"=",
"Template",
"(",
"\"\"\"\n CommandOption(\n CommandOption.{{ const_type }},\n {{ short_name }},\n {{ long_name }},\n action='{{ action }}',\n dest='{{ dest }}',{% if default is not none %}\n ... | https://github.com/j-bennet/wharfee/blob/a48536cba5d3830a29c63bb440b3e74a8a23431d/scripts/optionizer.py#L320-L346 | |
collinsctk/PyQYT | 7af3673955f94ff1b2df2f94220cd2dab2e252af | ExtentionPackages/pycparser/c_parser.py | python | CParser.p_postfix_expression_3 | (self, p) | postfix_expression : postfix_expression LPAREN argument_expression_list RPAREN
| postfix_expression LPAREN RPAREN | postfix_expression : postfix_expression LPAREN argument_expression_list RPAREN
| postfix_expression LPAREN RPAREN | [
"postfix_expression",
":",
"postfix_expression",
"LPAREN",
"argument_expression_list",
"RPAREN",
"|",
"postfix_expression",
"LPAREN",
"RPAREN"
] | def p_postfix_expression_3(self, p):
""" postfix_expression : postfix_expression LPAREN argument_expression_list RPAREN
| postfix_expression LPAREN RPAREN
"""
p[0] = c_ast.FuncCall(p[1], p[3] if len(p) == 5 else None, p[1].coord) | [
"def",
"p_postfix_expression_3",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"c_ast",
".",
"FuncCall",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
"if",
"len",
"(",
"p",
")",
"==",
"5",
"else",
"None",
",",
"p",
"[",
"1"... | https://github.com/collinsctk/PyQYT/blob/7af3673955f94ff1b2df2f94220cd2dab2e252af/ExtentionPackages/pycparser/c_parser.py#L1541-L1545 | ||
enthought/traits | d22ce1f096e2a6f87c78d7f1bb5bf0abab1a18ff | traits/trait_type.py | python | TraitType.clone | (self, default_value=NoDefaultSpecified, **metadata) | return new | Copy, optionally modifying default value and metadata.
Clones the contents of this object into a new instance of the same
class, and then modifies the cloned copy using the specified
``default_value`` and ``metadata``. Returns the cloned object as the
result.
Note that subclass... | Copy, optionally modifying default value and metadata. | [
"Copy",
"optionally",
"modifying",
"default",
"value",
"and",
"metadata",
"."
] | def clone(self, default_value=NoDefaultSpecified, **metadata):
""" Copy, optionally modifying default value and metadata.
Clones the contents of this object into a new instance of the same
class, and then modifies the cloned copy using the specified
``default_value`` and ``metadata``. R... | [
"def",
"clone",
"(",
"self",
",",
"default_value",
"=",
"NoDefaultSpecified",
",",
"*",
"*",
"metadata",
")",
":",
"if",
"\"parent\"",
"not",
"in",
"metadata",
":",
"metadata",
"[",
"\"parent\"",
"]",
"=",
"self",
"new",
"=",
"self",
".",
"__class__",
".... | https://github.com/enthought/traits/blob/d22ce1f096e2a6f87c78d7f1bb5bf0abab1a18ff/traits/trait_type.py#L265-L317 | |
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/nntplib.py | python | NNTP.body | (self, id, file=None) | return self.artcmd('BODY ' + id, file) | Process a BODY command. Argument:
- id: article number or message id
- file: Filename string or file object to store the article in
Returns:
- resp: server response if successful
- nr: article number
- id: message id
- list: the lines of the article's body or an ... | Process a BODY command. Argument:
- id: article number or message id
- file: Filename string or file object to store the article in
Returns:
- resp: server response if successful
- nr: article number
- id: message id
- list: the lines of the article's body or an ... | [
"Process",
"a",
"BODY",
"command",
".",
"Argument",
":",
"-",
"id",
":",
"article",
"number",
"or",
"message",
"id",
"-",
"file",
":",
"Filename",
"string",
"or",
"file",
"object",
"to",
"store",
"the",
"article",
"in",
"Returns",
":",
"-",
"resp",
":"... | def body(self, id, file=None):
"""Process a BODY command. Argument:
- id: article number or message id
- file: Filename string or file object to store the article in
Returns:
- resp: server response if successful
- nr: article number
- id: message id
- li... | [
"def",
"body",
"(",
"self",
",",
"id",
",",
"file",
"=",
"None",
")",
":",
"return",
"self",
".",
"artcmd",
"(",
"'BODY '",
"+",
"id",
",",
"file",
")"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/nntplib.py#L431-L442 | |
BlueBrain/BluePyOpt | 6d4185479bc6dddb3daad84fa27e0b8457d69652 | bluepyopt/ephys/serializer.py | python | DictMixin.to_dict | (self) | return ret | create dictionary | create dictionary | [
"create",
"dictionary"
] | def to_dict(self):
'''create dictionary'''
ret = {}
for field in self.SERIALIZED_FIELDS:
ret[field] = DictMixin._serializer(getattr(self, field))
ret['class'] = repr(self.__class__)
return ret | [
"def",
"to_dict",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"field",
"in",
"self",
".",
"SERIALIZED_FIELDS",
":",
"ret",
"[",
"field",
"]",
"=",
"DictMixin",
".",
"_serializer",
"(",
"getattr",
"(",
"self",
",",
"field",
")",
")",
"ret",
... | https://github.com/BlueBrain/BluePyOpt/blob/6d4185479bc6dddb3daad84fa27e0b8457d69652/bluepyopt/ephys/serializer.py#L47-L53 | |
golismero/golismero | 7d605b937e241f51c1ca4f47b20f755eeefb9d76 | thirdparty_libs/nltk/misc/minimalset.py | python | MinimalSet.contexts | (self, minimum=2) | return [c for c in self._contexts if len(self._seen[c]) >= minimum] | Determine which contexts occurred with enough distinct targets.
:param minimum: the minimum number of distinct target forms
:type minimum: int
:rtype list | Determine which contexts occurred with enough distinct targets. | [
"Determine",
"which",
"contexts",
"occurred",
"with",
"enough",
"distinct",
"targets",
"."
] | def contexts(self, minimum=2):
"""
Determine which contexts occurred with enough distinct targets.
:param minimum: the minimum number of distinct target forms
:type minimum: int
:rtype list
"""
return [c for c in self._contexts if len(self._seen[c]) >= minimum] | [
"def",
"contexts",
"(",
"self",
",",
"minimum",
"=",
"2",
")",
":",
"return",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"_contexts",
"if",
"len",
"(",
"self",
".",
"_seen",
"[",
"c",
"]",
")",
">=",
"minimum",
"]"
] | https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/nltk/misc/minimalset.py#L58-L66 | |
DataBrewery/cubes | 140133e8c2e3f2ff60631cc3ebc9966d16c1655e | cubes/metadata/cube.py | python | Cube.base_attributes | (self) | return [attr for attr in self.all_attributes if attr.is_base] | Returns a list of attributes that are not derived from other
attributes, do not depend on other cube attributes, variables or
parameters. Any attribute that has an expression (regardless of it's
contents, it might be a constant) is considered derived attribute.
The list contains also ag... | Returns a list of attributes that are not derived from other
attributes, do not depend on other cube attributes, variables or
parameters. Any attribute that has an expression (regardless of it's
contents, it might be a constant) is considered derived attribute. | [
"Returns",
"a",
"list",
"of",
"attributes",
"that",
"are",
"not",
"derived",
"from",
"other",
"attributes",
"do",
"not",
"depend",
"on",
"other",
"cube",
"attributes",
"variables",
"or",
"parameters",
".",
"Any",
"attribute",
"that",
"has",
"an",
"expression",... | def base_attributes(self):
"""Returns a list of attributes that are not derived from other
attributes, do not depend on other cube attributes, variables or
parameters. Any attribute that has an expression (regardless of it's
contents, it might be a constant) is considered derived attribu... | [
"def",
"base_attributes",
"(",
"self",
")",
":",
"return",
"[",
"attr",
"for",
"attr",
"in",
"self",
".",
"all_attributes",
"if",
"attr",
".",
"is_base",
"]"
] | https://github.com/DataBrewery/cubes/blob/140133e8c2e3f2ff60631cc3ebc9966d16c1655e/cubes/metadata/cube.py#L377-L389 | |
containerbuildsystem/atomic-reactor | 159e76234d31348e46804e63fa392362706e1c60 | atomic_reactor/util.py | python | create_tar_gz_archive | (file_name: str, file_content: str) | return tar.name | Create tar.gz archive with a single file with a specific content
:param str file_name: Name of the file packed in archive
:param str file_content: File content string
:return: Absolute path to the file archive | Create tar.gz archive with a single file with a specific content | [
"Create",
"tar",
".",
"gz",
"archive",
"with",
"a",
"single",
"file",
"with",
"a",
"specific",
"content"
] | def create_tar_gz_archive(file_name: str, file_content: str):
"""Create tar.gz archive with a single file with a specific content
:param str file_name: Name of the file packed in archive
:param str file_content: File content string
:return: Absolute path to the file archive
"""
with tempfile.N... | [
"def",
"create_tar_gz_archive",
"(",
"file_name",
":",
"str",
",",
"file_content",
":",
"str",
")",
":",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"'wb'",
",",
"suffix",
"=",
"'.tar.gz'",
",",
"delete",
"=",
"False",
")",
"as",
"f",
":",
"with",
... | https://github.com/containerbuildsystem/atomic-reactor/blob/159e76234d31348e46804e63fa392362706e1c60/atomic_reactor/util.py#L1998-L2013 | |
wger-project/wger | 3a17a2cf133d242d1f8c357faa53cf675a7b3223 | wger/measurements/api/views.py | python | MeasurementViewSet.get_queryset | (self) | return Measurement.objects.filter(category__user=self.request.user) | Only allow access to appropriate objects | Only allow access to appropriate objects | [
"Only",
"allow",
"access",
"to",
"appropriate",
"objects"
] | def get_queryset(self):
"""
Only allow access to appropriate objects
"""
return Measurement.objects.filter(category__user=self.request.user) | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"return",
"Measurement",
".",
"objects",
".",
"filter",
"(",
"category__user",
"=",
"self",
".",
"request",
".",
"user",
")"
] | https://github.com/wger-project/wger/blob/3a17a2cf133d242d1f8c357faa53cf675a7b3223/wger/measurements/api/views.py#L79-L83 | |
OpenMined/PySyft | f181ca02d307d57bfff9477610358df1a12e3ac9 | packages/syft/src/syft/core/tensor/smpc/mpc_tensor.py | python | MPCTensor.__pow__ | (self, power: int) | return result | Compute integer power of a number iteratively using mul.
- Divide power by 2 and multiply base to itself (if the power is even)
- Decrement power by 1 to make it even and then follow the first step
Args:
power (int): integer value to apply the
Returns:
MPCTens... | Compute integer power of a number iteratively using mul. | [
"Compute",
"integer",
"power",
"of",
"a",
"number",
"iteratively",
"using",
"mul",
"."
] | def __pow__(self, power: int) -> MPCTensor:
"""Compute integer power of a number iteratively using mul.
- Divide power by 2 and multiply base to itself (if the power is even)
- Decrement power by 1 to make it even and then follow the first step
Args:
power (int): integer va... | [
"def",
"__pow__",
"(",
"self",
",",
"power",
":",
"int",
")",
"->",
"MPCTensor",
":",
"# TODO: Implement after we have reciprocal function.",
"if",
"power",
"<",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Negative integer powers not supported yet.\"",
")",
"base",
"="... | https://github.com/OpenMined/PySyft/blob/f181ca02d307d57bfff9477610358df1a12e3ac9/packages/syft/src/syft/core/tensor/smpc/mpc_tensor.py#L839-L875 | |
imagr/imagr | e54bcf3f0f951babcd2fa153de2dd8556aa3506d | Imagr/gmacpyutil/systemconfig.py | python | SystemProfiler.GetDiskSerialNumber | (self) | Retrieves the primary disk serial number.
Returns:
string of serial number
Raises:
SystemProfilerError: when disk0 is not found on SATA bus. | Retrieves the primary disk serial number. | [
"Retrieves",
"the",
"primary",
"disk",
"serial",
"number",
"."
] | def GetDiskSerialNumber(self):
"""Retrieves the primary disk serial number.
Returns:
string of serial number
Raises:
SystemProfilerError: when disk0 is not found on SATA bus.
"""
# the order is important so we prefer SATA then RAID finally PATA
sp_types = ['SPSerialATADataType', 'S... | [
"def",
"GetDiskSerialNumber",
"(",
"self",
")",
":",
"# the order is important so we prefer SATA then RAID finally PATA",
"sp_types",
"=",
"[",
"'SPSerialATADataType'",
",",
"'SPHardwareRAIDDataType'",
",",
"'SPParallelATADataType'",
"]",
"for",
"sp_type",
"in",
"sp_types",
"... | https://github.com/imagr/imagr/blob/e54bcf3f0f951babcd2fa153de2dd8556aa3506d/Imagr/gmacpyutil/systemconfig.py#L305-L325 | ||
FederatedAI/FATE | 32540492623568ecd1afcb367360133616e02fa3 | python/federatedml/evaluation/evaluation.py | python | Evaluation.obtain_data | (self, data_list) | return data_list | [] | def obtain_data(self, data_list):
return data_list | [
"def",
"obtain_data",
"(",
"self",
",",
"data_list",
")",
":",
"return",
"data_list"
] | https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/evaluation/evaluation.py#L287-L288 | |||
x0rz/EQGRP_Lost_in_Translation | 6692b1486f562f027567a49523b8c151a4050988 | windows/Resources/Python/Override/Lib/multiprocessing/__init__.py | python | RLock | () | return RLock() | Returns a recursive lock object | Returns a recursive lock object | [
"Returns",
"a",
"recursive",
"lock",
"object"
] | def RLock():
'''
Returns a recursive lock object
'''
from multiprocessing.synchronize import RLock
return RLock() | [
"def",
"RLock",
"(",
")",
":",
"from",
"multiprocessing",
".",
"synchronize",
"import",
"RLock",
"return",
"RLock",
"(",
")"
] | https://github.com/x0rz/EQGRP_Lost_in_Translation/blob/6692b1486f562f027567a49523b8c151a4050988/windows/Resources/Python/Override/Lib/multiprocessing/__init__.py#L178-L183 | |
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Centos_5.9/paramiko/sftp_file.py | python | SFTPFile.check | (self, hash_algorithm, offset=0, length=0, block_size=0) | return data | Ask the server for a hash of a section of this file. This can be used
to verify a successful upload or download, or for various rsync-like
operations.
The file is hashed from C{offset}, for C{length} bytes. If C{length}
is 0, the remainder of the file is hashed. Thus, if both... | Ask the server for a hash of a section of this file. This can be used
to verify a successful upload or download, or for various rsync-like
operations.
The file is hashed from C{offset}, for C{length} bytes. If C{length}
is 0, the remainder of the file is hashed. Thus, if both... | [
"Ask",
"the",
"server",
"for",
"a",
"hash",
"of",
"a",
"section",
"of",
"this",
"file",
".",
"This",
"can",
"be",
"used",
"to",
"verify",
"a",
"successful",
"upload",
"or",
"download",
"or",
"for",
"various",
"rsync",
"-",
"like",
"operations",
".",
"T... | def check(self, hash_algorithm, offset=0, length=0, block_size=0):
"""
Ask the server for a hash of a section of this file. This can be used
to verify a successful upload or download, or for various rsync-like
operations.
The file is hashed from C{offset}, for C{length}... | [
"def",
"check",
"(",
"self",
",",
"hash_algorithm",
",",
"offset",
"=",
"0",
",",
"length",
"=",
"0",
",",
"block_size",
"=",
"0",
")",
":",
"t",
",",
"msg",
"=",
"self",
".",
"sftp",
".",
"_request",
"(",
"CMD_EXTENDED",
",",
"'check-file'",
",",
... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Centos_5.9/paramiko/sftp_file.py#L302-L354 | |
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/config/area_registry.py | python | async_setup | (hass) | return True | Enable the Area Registry views. | Enable the Area Registry views. | [
"Enable",
"the",
"Area",
"Registry",
"views",
"."
] | async def async_setup(hass):
"""Enable the Area Registry views."""
websocket_api.async_register_command(hass, websocket_list_areas)
websocket_api.async_register_command(hass, websocket_create_area)
websocket_api.async_register_command(hass, websocket_delete_area)
websocket_api.async_register_command... | [
"async",
"def",
"async_setup",
"(",
"hass",
")",
":",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_list_areas",
")",
"websocket_api",
".",
"async_register_command",
"(",
"hass",
",",
"websocket_create_area",
")",
"websocket_api",
".",
... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/config/area_registry.py#L9-L15 | |
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/quantum/quantum/rootwrap/wrapper.py | python | load_filters | (filters_path) | return filterlist | Load filters from a list of directories | Load filters from a list of directories | [
"Load",
"filters",
"from",
"a",
"list",
"of",
"directories"
] | def load_filters(filters_path):
"""Load filters from a list of directories"""
filterlist = []
for filterdir in filters_path:
if not os.path.isdir(filterdir):
continue
for filterfile in os.listdir(filterdir):
filterconfig = ConfigParser.RawConfigParser()
fi... | [
"def",
"load_filters",
"(",
"filters_path",
")",
":",
"filterlist",
"=",
"[",
"]",
"for",
"filterdir",
"in",
"filters_path",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"filterdir",
")",
":",
"continue",
"for",
"filterfile",
"in",
"os",
".",
... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/quantum/quantum/rootwrap/wrapper.py#L38-L53 | |
FederatedAI/FATE | 32540492623568ecd1afcb367360133616e02fa3 | python/federatedml/ensemble/basic_algorithms/decision_tree/hetero/hetero_fast_decision_tree_host.py | python | HeteroFastDecisionTreeHost.set_tree_work_mode | (self, tree_type, target_host_id) | [] | def set_tree_work_mode(self, tree_type, target_host_id):
self.tree_type, self.target_host_id = tree_type, target_host_id | [
"def",
"set_tree_work_mode",
"(",
"self",
",",
"tree_type",
",",
"target_host_id",
")",
":",
"self",
".",
"tree_type",
",",
"self",
".",
"target_host_id",
"=",
"tree_type",
",",
"target_host_id"
] | https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/ensemble/basic_algorithms/decision_tree/hetero/hetero_fast_decision_tree_host.py#L37-L38 | ||||
IBM/watson-online-store | 4c8b60883b319f07c3187d9cb433ef9c3ae29aea | watsononlinestore/watson_online_store.py | python | WatsonOnlineStore.handle_delete_from_cart | (self) | return False | Pulls cart_item from Watson context and deletes from Cloudant DB
cart_item in context must be an int or delete will silently fail. | Pulls cart_item from Watson context and deletes from Cloudant DB | [
"Pulls",
"cart_item",
"from",
"Watson",
"context",
"and",
"deletes",
"from",
"Cloudant",
"DB"
] | def handle_delete_from_cart(self):
"""Pulls cart_item from Watson context and deletes from Cloudant DB
cart_item in context must be an int or delete will silently fail.
"""
email = self.customer.email
shopping_list = self.cloudant_online_store.list_shopping_cart(email)
t... | [
"def",
"handle_delete_from_cart",
"(",
"self",
")",
":",
"email",
"=",
"self",
".",
"customer",
".",
"email",
"shopping_list",
"=",
"self",
".",
"cloudant_online_store",
".",
"list_shopping_cart",
"(",
"email",
")",
"try",
":",
"item_num",
"=",
"int",
"(",
"... | https://github.com/IBM/watson-online-store/blob/4c8b60883b319f07c3187d9cb433ef9c3ae29aea/watsononlinestore/watson_online_store.py#L757-L777 | |
home-assistant/core | 265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1 | homeassistant/components/config/config_entries.py | python | config_entries_progress | (hass, connection, msg) | List flows that are in progress but not started by a user.
Example of a non-user initiated flow is a discovered Hue hub that
requires user interaction to finish setup. | List flows that are in progress but not started by a user. | [
"List",
"flows",
"that",
"are",
"in",
"progress",
"but",
"not",
"started",
"by",
"a",
"user",
"."
] | def config_entries_progress(hass, connection, msg):
"""List flows that are in progress but not started by a user.
Example of a non-user initiated flow is a discovered Hue hub that
requires user interaction to finish setup.
"""
connection.send_result(
msg["id"],
[
flw
... | [
"def",
"config_entries_progress",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"connection",
".",
"send_result",
"(",
"msg",
"[",
"\"id\"",
"]",
",",
"[",
"flw",
"for",
"flw",
"in",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_progress"... | https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/config/config_entries.py#L220-L233 | ||
trakt/Plex-Trakt-Scrobbler | aeb0bfbe62fad4b06c164f1b95581da7f35dce0b | Trakttv.bundle/Contents/Libraries/Shared/CodernityDB/database.py | python | Database._update_indexes | (self, _rev, data) | return _id, new_rev | Performs update operation on all indexes in order | Performs update operation on all indexes in order | [
"Performs",
"update",
"operation",
"on",
"all",
"indexes",
"in",
"order"
] | def _update_indexes(self, _rev, data):
"""
Performs update operation on all indexes in order
"""
_id, new_rev, db_data = self._update_id_index(_rev, data)
for index in self.indexes[1:]:
self._single_update_index(index, data, db_data, _id)
return _id, new_rev | [
"def",
"_update_indexes",
"(",
"self",
",",
"_rev",
",",
"data",
")",
":",
"_id",
",",
"new_rev",
",",
"db_data",
"=",
"self",
".",
"_update_id_index",
"(",
"_rev",
",",
"data",
")",
"for",
"index",
"in",
"self",
".",
"indexes",
"[",
"1",
":",
"]",
... | https://github.com/trakt/Plex-Trakt-Scrobbler/blob/aeb0bfbe62fad4b06c164f1b95581da7f35dce0b/Trakttv.bundle/Contents/Libraries/Shared/CodernityDB/database.py#L674-L681 | |
mars-project/mars | 6afd7ed86db77f29cc9470485698ef192ecc6d33 | mars/dataframe/base/memory_usage.py | python | DataFrameMemoryUsage._tile_dataframe | (cls, op: "DataFrameMemoryUsage") | return new_op.new_series(
[df],
dtype=output.dtype,
shape=output.shape,
index_value=output.index_value,
chunks=list(chunks_to_reduce[0, :]),
nsplits=op._adapt_nsplits(df.nsplits),
) | Tile dataframes using tree reduction | Tile dataframes using tree reduction | [
"Tile",
"dataframes",
"using",
"tree",
"reduction"
] | def _tile_dataframe(cls, op: "DataFrameMemoryUsage"):
"""
Tile dataframes using tree reduction
"""
df = op.inputs[0]
output = op.outputs[0]
is_range_index = isinstance(df.index_value.value, IndexValue.RangeIndex)
# produce map chunks
# allocate matrix of ... | [
"def",
"_tile_dataframe",
"(",
"cls",
",",
"op",
":",
"\"DataFrameMemoryUsage\"",
")",
":",
"df",
"=",
"op",
".",
"inputs",
"[",
"0",
"]",
"output",
"=",
"op",
".",
"outputs",
"[",
"0",
"]",
"is_range_index",
"=",
"isinstance",
"(",
"df",
".",
"index_v... | https://github.com/mars-project/mars/blob/6afd7ed86db77f29cc9470485698ef192ecc6d33/mars/dataframe/base/memory_usage.py#L164-L241 | |
pysmt/pysmt | ade4dc2a825727615033a96d31c71e9f53ce4764 | pysmt/solvers/yices.py | python | YicesConverter.walk_bv_ror | (self, formula, args, **kwargs) | return res | [] | def walk_bv_ror(self, formula, args, **kwargs):
res = yicespy.yices_rotate_right(args[0], formula.bv_rotation_step())
self._check_term_result(res)
return res | [
"def",
"walk_bv_ror",
"(",
"self",
",",
"formula",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"res",
"=",
"yicespy",
".",
"yices_rotate_right",
"(",
"args",
"[",
"0",
"]",
",",
"formula",
".",
"bv_rotation_step",
"(",
")",
")",
"self",
".",
"_ch... | https://github.com/pysmt/pysmt/blob/ade4dc2a825727615033a96d31c71e9f53ce4764/pysmt/solvers/yices.py#L561-L564 | |||
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework | cb692f527e4e819b6c228187c5702d990a180043 | external/Scripting Engine/Xenotix Python Scripting Engine/bin/x86/Debug/Lib/email/message.py | python | Message.set_charset | (self, charset) | Set the charset of the payload to a given character set.
charset can be a Charset instance, a string naming a character set, or
None. If it is a string it will be converted to a Charset instance.
If charset is None, the charset parameter will be removed from the
Content-Type field. An... | Set the charset of the payload to a given character set. | [
"Set",
"the",
"charset",
"of",
"the",
"payload",
"to",
"a",
"given",
"character",
"set",
"."
] | def set_charset(self, charset):
"""Set the charset of the payload to a given character set.
charset can be a Charset instance, a string naming a character set, or
None. If it is a string it will be converted to a Charset instance.
If charset is None, the charset parameter will be remov... | [
"def",
"set_charset",
"(",
"self",
",",
"charset",
")",
":",
"if",
"charset",
"is",
"None",
":",
"self",
".",
"del_param",
"(",
"'charset'",
")",
"self",
".",
"_charset",
"=",
"None",
"return",
"if",
"isinstance",
"(",
"charset",
",",
"basestring",
")",
... | https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/bin/x86/Debug/Lib/email/message.py#L228-L271 | ||
zhaoweicai/Detectron-Cascade-RCNN | 5a297fcc16eab6c26b7b1a9fe2767c626730f03b | detectron/utils/io.py | python | cache_url | (url_or_file, cache_dir) | return cache_file_path | Download the file specified by the URL to the cache_dir and return the
path to the cached file. If the argument is not a URL, simply return it as
is. | Download the file specified by the URL to the cache_dir and return the
path to the cached file. If the argument is not a URL, simply return it as
is. | [
"Download",
"the",
"file",
"specified",
"by",
"the",
"URL",
"to",
"the",
"cache_dir",
"and",
"return",
"the",
"path",
"to",
"the",
"cached",
"file",
".",
"If",
"the",
"argument",
"is",
"not",
"a",
"URL",
"simply",
"return",
"it",
"as",
"is",
"."
] | def cache_url(url_or_file, cache_dir):
"""Download the file specified by the URL to the cache_dir and return the
path to the cached file. If the argument is not a URL, simply return it as
is.
"""
is_url = re.match(r'^(?:http)s?://', url_or_file, re.IGNORECASE) is not None
if not is_url:
... | [
"def",
"cache_url",
"(",
"url_or_file",
",",
"cache_dir",
")",
":",
"is_url",
"=",
"re",
".",
"match",
"(",
"r'^(?:http)s?://'",
",",
"url_or_file",
",",
"re",
".",
"IGNORECASE",
")",
"is",
"not",
"None",
"if",
"not",
"is_url",
":",
"return",
"url_or_file"... | https://github.com/zhaoweicai/Detectron-Cascade-RCNN/blob/5a297fcc16eab6c26b7b1a9fe2767c626730f03b/detectron/utils/io.py#L43-L70 | |
GoogleCloudPlatform/professional-services | 0c707aa97437f3d154035ef8548109b7882f71da | tools/hive-bigquery/hive_to_bigquery/bigquery_component.py | python | BigQueryComponent.create_table | (self, dataset_id, table_name, schema) | Creates BigQuery table.
Args:
dataset_id (str): BigQuery dataset id.
table_name (str): BigQuery table name.
schema (List[google.cloud.bigquery.schema.SchemaField]): Schema
of the table to be created. | Creates BigQuery table. | [
"Creates",
"BigQuery",
"table",
"."
] | def create_table(self, dataset_id, table_name, schema):
"""Creates BigQuery table.
Args:
dataset_id (str): BigQuery dataset id.
table_name (str): BigQuery table name.
schema (List[google.cloud.bigquery.schema.SchemaField]): Schema
of the table to be c... | [
"def",
"create_table",
"(",
"self",
",",
"dataset_id",
",",
"table_name",
",",
"schema",
")",
":",
"dataset_ref",
"=",
"self",
".",
"client",
".",
"dataset",
"(",
"dataset_id",
")",
"table_ref",
"=",
"dataset_ref",
".",
"table",
"(",
"table_name",
")",
"ta... | https://github.com/GoogleCloudPlatform/professional-services/blob/0c707aa97437f3d154035ef8548109b7882f71da/tools/hive-bigquery/hive_to_bigquery/bigquery_component.py#L118-L131 | ||
peering-manager/peering-manager | 62c870fb9caa6dfc056feb77c595d45bc3c4988a | devices/crypto/juniper.py | python | __gap_encode | (pc, prev, encode) | return crypt | [] | def __gap_encode(pc, prev, encode):
__ord = ord(pc)
crypt = ""
gaps = []
for mod in __reverse(encode):
gaps.insert(0, int(__ord / mod))
__ord %= mod
for gap in gaps:
gap += ALPHA_NUM[prev] + 1
prev = NUM_ALPHA[gap % len(NUM_ALPHA)]
crypt += prev
return ... | [
"def",
"__gap_encode",
"(",
"pc",
",",
"prev",
",",
"encode",
")",
":",
"__ord",
"=",
"ord",
"(",
"pc",
")",
"crypt",
"=",
"\"\"",
"gaps",
"=",
"[",
"]",
"for",
"mod",
"in",
"__reverse",
"(",
"encode",
")",
":",
"gaps",
".",
"insert",
"(",
"0",
... | https://github.com/peering-manager/peering-manager/blob/62c870fb9caa6dfc056feb77c595d45bc3c4988a/devices/crypto/juniper.py#L68-L82 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.