repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
obsrvbl/flowlogs-reader | flowlogs_reader/__main__.py | https://github.com/obsrvbl/flowlogs-reader/blob/248d8cb3cc586859b6744d30cebce0f359d9900c/flowlogs_reader/__main__.py#L31-L44 | def action_print(reader, *args):
"""Simply print the Flow Log records to output."""
arg_count = len(args)
if arg_count == 0:
stop_after = 0
elif arg_count == 1:
stop_after = int(args[0])
else:
raise RuntimeError("0 or 1 arguments expected for action 'print'")
for i, reco... | [
"def",
"action_print",
"(",
"reader",
",",
"*",
"args",
")",
":",
"arg_count",
"=",
"len",
"(",
"args",
")",
"if",
"arg_count",
"==",
"0",
":",
"stop_after",
"=",
"0",
"elif",
"arg_count",
"==",
"1",
":",
"stop_after",
"=",
"int",
"(",
"args",
"[",
... | Simply print the Flow Log records to output. | [
"Simply",
"print",
"the",
"Flow",
"Log",
"records",
"to",
"output",
"."
] | python | train | 29.642857 |
getsentry/rb | rb/ketama.py | https://github.com/getsentry/rb/blob/569d1d13311f6c04bae537fc17e75da430e4ec45/rb/ketama.py#L69-L73 | def add_node(self, node, weight=1):
"""Adds node to circle and rebuild it."""
self._nodes.add(node)
self._weights[node] = weight
self._rebuild_circle() | [
"def",
"add_node",
"(",
"self",
",",
"node",
",",
"weight",
"=",
"1",
")",
":",
"self",
".",
"_nodes",
".",
"add",
"(",
"node",
")",
"self",
".",
"_weights",
"[",
"node",
"]",
"=",
"weight",
"self",
".",
"_rebuild_circle",
"(",
")"
] | Adds node to circle and rebuild it. | [
"Adds",
"node",
"to",
"circle",
"and",
"rebuild",
"it",
"."
] | python | train | 35.8 |
Nagasaki45/bibo | bibo/internals.py | https://github.com/Nagasaki45/bibo/blob/e6afb28711e78eb11475834d3f9455252ac9f347/bibo/internals.py#L76-L87 | def remove_entry(data, entry):
'''
Remove an entry in place.
'''
file_field = entry['fields'].get('file')
if file_field:
try:
os.remove(file_field)
except IOError:
click.echo('This entry\'s file was missing')
data.remove(entry) | [
"def",
"remove_entry",
"(",
"data",
",",
"entry",
")",
":",
"file_field",
"=",
"entry",
"[",
"'fields'",
"]",
".",
"get",
"(",
"'file'",
")",
"if",
"file_field",
":",
"try",
":",
"os",
".",
"remove",
"(",
"file_field",
")",
"except",
"IOError",
":",
... | Remove an entry in place. | [
"Remove",
"an",
"entry",
"in",
"place",
"."
] | python | train | 23.416667 |
materialsproject/pymatgen | pymatgen/core/periodic_table.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/periodic_table.py#L999-L1006 | def as_dict(self):
"""
Makes Element obey the general json interface used in pymatgen for
easier serialization.
"""
return {"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"element": self.symbol} | [
"def",
"as_dict",
"(",
"self",
")",
":",
"return",
"{",
"\"@module\"",
":",
"self",
".",
"__class__",
".",
"__module__",
",",
"\"@class\"",
":",
"self",
".",
"__class__",
".",
"__name__",
",",
"\"element\"",
":",
"self",
".",
"symbol",
"}"
] | Makes Element obey the general json interface used in pymatgen for
easier serialization. | [
"Makes",
"Element",
"obey",
"the",
"general",
"json",
"interface",
"used",
"in",
"pymatgen",
"for",
"easier",
"serialization",
"."
] | python | train | 35.625 |
ellmetha/django-machina | machina/apps/forum/admin.py | https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L137-L155 | def moveforum_view(self, request, forum_id, direction):
""" Moves the given forum toward the requested direction. """
forum = get_object_or_404(Forum, pk=forum_id)
# Fetch the target
target, position = None, None
if direction == 'up':
target, position = forum.get_pre... | [
"def",
"moveforum_view",
"(",
"self",
",",
"request",
",",
"forum_id",
",",
"direction",
")",
":",
"forum",
"=",
"get_object_or_404",
"(",
"Forum",
",",
"pk",
"=",
"forum_id",
")",
"# Fetch the target",
"target",
",",
"position",
"=",
"None",
",",
"None",
... | Moves the given forum toward the requested direction. | [
"Moves",
"the",
"given",
"forum",
"toward",
"the",
"requested",
"direction",
"."
] | python | train | 40.631579 |
pymc-devs/pymc | pymc/StepMethods.py | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/StepMethods.py#L1498-L1503 | def stoch2array(self):
"""Return the stochastic objects as an array."""
a = np.empty(self.dim)
for stochastic in self.stochastics:
a[self._slices[stochastic]] = stochastic.value
return a | [
"def",
"stoch2array",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"empty",
"(",
"self",
".",
"dim",
")",
"for",
"stochastic",
"in",
"self",
".",
"stochastics",
":",
"a",
"[",
"self",
".",
"_slices",
"[",
"stochastic",
"]",
"]",
"=",
"stochastic",
"... | Return the stochastic objects as an array. | [
"Return",
"the",
"stochastic",
"objects",
"as",
"an",
"array",
"."
] | python | train | 37.5 |
jaraco/keyring | keyring/util/platform_.py | https://github.com/jaraco/keyring/blob/71c798378e365286b7cc03c06e4d7d24c7de8fc4/keyring/util/platform_.py#L32-L48 | def _check_old_config_root():
"""
Prior versions of keyring would search for the config
in XDG_DATA_HOME, but should probably have been
searching for config in XDG_CONFIG_HOME. If the
config exists in the former but not in the latter,
raise a RuntimeError to force the change.
"""
# disab... | [
"def",
"_check_old_config_root",
"(",
")",
":",
"# disable the check - once is enough and avoids infinite loop",
"globals",
"(",
")",
"[",
"'_check_old_config_root'",
"]",
"=",
"lambda",
":",
"None",
"config_file_new",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_confi... | Prior versions of keyring would search for the config
in XDG_DATA_HOME, but should probably have been
searching for config in XDG_CONFIG_HOME. If the
config exists in the former but not in the latter,
raise a RuntimeError to force the change. | [
"Prior",
"versions",
"of",
"keyring",
"would",
"search",
"for",
"the",
"config",
"in",
"XDG_DATA_HOME",
"but",
"should",
"probably",
"have",
"been",
"searching",
"for",
"config",
"in",
"XDG_CONFIG_HOME",
".",
"If",
"the",
"config",
"exists",
"in",
"the",
"form... | python | valid | 52.235294 |
aisayko/Django-tinymce-filebrowser | mce_filebrowser/views.py | https://github.com/aisayko/Django-tinymce-filebrowser/blob/f34c9e8f8c5e32c1d1221270314f31ee07f24409/mce_filebrowser/views.py#L15-L43 | def filebrowser(request, file_type):
""" Trigger view for filebrowser """
template = 'filebrowser.html'
upload_form = FileUploadForm()
uploaded_file = None
upload_tab_active = False
is_images_dialog = (file_type == 'img')
is_documents_dialog = (file_type == 'doc')
files = FileBrowse... | [
"def",
"filebrowser",
"(",
"request",
",",
"file_type",
")",
":",
"template",
"=",
"'filebrowser.html'",
"upload_form",
"=",
"FileUploadForm",
"(",
")",
"uploaded_file",
"=",
"None",
"upload_tab_active",
"=",
"False",
"is_images_dialog",
"=",
"(",
"file_type",
"==... | Trigger view for filebrowser | [
"Trigger",
"view",
"for",
"filebrowser"
] | python | train | 35.068966 |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L4337-L4351 | def ekopr(fname):
"""
Open an existing E-kernel file for reading.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekopr_c.html
:param fname: Name of EK file.
:type fname: str
:return: Handle attached to EK file.
:rtype: int
"""
fname = stypes.stringToCharP(fname)
handle... | [
"def",
"ekopr",
"(",
"fname",
")",
":",
"fname",
"=",
"stypes",
".",
"stringToCharP",
"(",
"fname",
")",
"handle",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"libspice",
".",
"ekopr_c",
"(",
"fname",
",",
"ctypes",
".",
"byref",
"(",
"handle",
")",
")",
... | Open an existing E-kernel file for reading.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekopr_c.html
:param fname: Name of EK file.
:type fname: str
:return: Handle attached to EK file.
:rtype: int | [
"Open",
"an",
"existing",
"E",
"-",
"kernel",
"file",
"for",
"reading",
"."
] | python | train | 26.466667 |
craffel/mir_eval | mir_eval/hierarchy.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/hierarchy.py#L556-L627 | def lmeasure(reference_intervals_hier, reference_labels_hier,
estimated_intervals_hier, estimated_labels_hier,
frame_size=0.1, beta=1.0):
'''Computes the tree measures for hierarchical segment annotations.
Parameters
----------
reference_intervals_hier : list of ndarray
... | [
"def",
"lmeasure",
"(",
"reference_intervals_hier",
",",
"reference_labels_hier",
",",
"estimated_intervals_hier",
",",
"estimated_labels_hier",
",",
"frame_size",
"=",
"0.1",
",",
"beta",
"=",
"1.0",
")",
":",
"# Compute the number of frames in the window",
"if",
"frame_... | Computes the tree measures for hierarchical segment annotations.
Parameters
----------
reference_intervals_hier : list of ndarray
``reference_intervals_hier[i]`` contains the segment intervals
(in seconds) for the ``i`` th layer of the annotations. Layers are
ordered from top to bo... | [
"Computes",
"the",
"tree",
"measures",
"for",
"hierarchical",
"segment",
"annotations",
"."
] | python | train | 32.916667 |
google/grr | grr/server/grr_response_server/databases/db.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/db.py#L4062-L4081 | def _ValidatePathInfos(path_infos):
"""Validates a sequence of path infos."""
precondition.AssertIterableType(path_infos, rdf_objects.PathInfo)
validated = set()
for path_info in path_infos:
_ValidatePathInfo(path_info)
path_key = (path_info.path_type, path_info.GetPathID())
if path_key in validat... | [
"def",
"_ValidatePathInfos",
"(",
"path_infos",
")",
":",
"precondition",
".",
"AssertIterableType",
"(",
"path_infos",
",",
"rdf_objects",
".",
"PathInfo",
")",
"validated",
"=",
"set",
"(",
")",
"for",
"path_info",
"in",
"path_infos",
":",
"_ValidatePathInfo",
... | Validates a sequence of path infos. | [
"Validates",
"a",
"sequence",
"of",
"path",
"infos",
"."
] | python | train | 36.05 |
pkkid/python-plexapi | plexapi/utils.py | https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/utils.py#L146-L167 | def threaded(callback, listargs):
""" Returns the result of <callback> for each set of \*args in listargs. Each call
to <callback> is called concurrently in their own separate threads.
Parameters:
callback (func): Callback function to apply to each set of \*args.
listargs (l... | [
"def",
"threaded",
"(",
"callback",
",",
"listargs",
")",
":",
"threads",
",",
"results",
"=",
"[",
"]",
",",
"[",
"]",
"job_is_done_event",
"=",
"Event",
"(",
")",
"for",
"args",
"in",
"listargs",
":",
"args",
"+=",
"[",
"results",
",",
"len",
"(",
... | Returns the result of <callback> for each set of \*args in listargs. Each call
to <callback> is called concurrently in their own separate threads.
Parameters:
callback (func): Callback function to apply to each set of \*args.
listargs (list): List of lists; \*args to pass each t... | [
"Returns",
"the",
"result",
"of",
"<callback",
">",
"for",
"each",
"set",
"of",
"\\",
"*",
"args",
"in",
"listargs",
".",
"Each",
"call",
"to",
"<callback",
">",
"is",
"called",
"concurrently",
"in",
"their",
"own",
"separate",
"threads",
"."
] | python | train | 39.681818 |
saltstack/salt | salt/modules/opkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/opkg.py#L776-L844 | def hold(name=None, pkgs=None, sources=None, **kwargs): # pylint: disable=W0613
'''
Set package in 'hold' state, meaning it will not be upgraded.
name
The name of the package, e.g., 'tmux'
CLI Example:
.. code-block:: bash
salt '*' pkg.hold <package name>
pkgs
... | [
"def",
"hold",
"(",
"name",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"if",
"not",
"name",
"and",
"not",
"pkgs",
"and",
"not",
"sources",
":",
"raise",
"SaltInvocat... | Set package in 'hold' state, meaning it will not be upgraded.
name
The name of the package, e.g., 'tmux'
CLI Example:
.. code-block:: bash
salt '*' pkg.hold <package name>
pkgs
A list of packages to hold. Must be passed as a python list.
CLI Example:
... | [
"Set",
"package",
"in",
"hold",
"state",
"meaning",
"it",
"will",
"not",
"be",
"upgraded",
"."
] | python | train | 30.73913 |
hyperledger/indy-sdk | wrappers/python/indy/anoncreds.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/anoncreds.py#L211-L249 | async def issuer_create_credential_offer(wallet_handle: int,
cred_def_id: str) -> str:
"""
Create credential offer that will be used by Prover for
credential request creation. Offer includes nonce and key correctness proof
for authentication between protocol step... | [
"async",
"def",
"issuer_create_credential_offer",
"(",
"wallet_handle",
":",
"int",
",",
"cred_def_id",
":",
"str",
")",
"->",
"str",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"issuer_create_credential_... | Create credential offer that will be used by Prover for
credential request creation. Offer includes nonce and key correctness proof
for authentication between protocol steps and integrity checking.
:param wallet_handle: wallet handler (created by open_wallet).
:param cred_def_id: id of credential defin... | [
"Create",
"credential",
"offer",
"that",
"will",
"be",
"used",
"by",
"Prover",
"for",
"credential",
"request",
"creation",
".",
"Offer",
"includes",
"nonce",
"and",
"key",
"correctness",
"proof",
"for",
"authentication",
"between",
"protocol",
"steps",
"and",
"i... | python | train | 41.974359 |
phaethon/kamene | kamene/contrib/gsm_um.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L333-L340 | def channelModeModifyAcknowledge():
"""CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x17) # 00010111
c = ChannelDescription2()
d = ChannelMode()
packet = a / b / c / d
return packet | [
"def",
"channelModeModifyAcknowledge",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x17",
")",
"# 00010111",
"c",
"=",
"ChannelDescription2",
"(",
")",
"d",
"=",
"ChannelMode",
"(",
")",
"... | CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6 | [
"CHANNEL",
"MODE",
"MODIFY",
"ACKNOWLEDGE",
"Section",
"9",
".",
"1",
".",
"6"
] | python | train | 31 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/gallery/gallery_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/gallery/gallery_client.py#L1146-L1173 | def update_publisher_asset(self, upload_stream, publisher_name, asset_type=None, file_name=None, **kwargs):
"""UpdatePublisherAsset.
[Preview API] Update publisher asset like logo. It accepts asset file as an octet stream and file name is passed in header values.
:param object upload_stream: Str... | [
"def",
"update_publisher_asset",
"(",
"self",
",",
"upload_stream",
",",
"publisher_name",
",",
"asset_type",
"=",
"None",
",",
"file_name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"publisher_name",
"is",
"not",
... | UpdatePublisherAsset.
[Preview API] Update publisher asset like logo. It accepts asset file as an octet stream and file name is passed in header values.
:param object upload_stream: Stream to upload
:param str publisher_name: Internal name of the publisher
:param str asset_type: Type of ... | [
"UpdatePublisherAsset",
".",
"[",
"Preview",
"API",
"]",
"Update",
"publisher",
"asset",
"like",
"logo",
".",
"It",
"accepts",
"asset",
"file",
"as",
"an",
"octet",
"stream",
"and",
"file",
"name",
"is",
"passed",
"in",
"header",
"values",
".",
":",
"param... | python | train | 56.785714 |
ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L103-L116 | def query_symbol(self, asset: str) -> str:
"""
This interface is used to query the asset's symbol of ONT or ONG.
:param asset: a string which is used to indicate which asset's symbol we want to get.
:return: asset's symbol in the form of string.
"""
contract_address = se... | [
"def",
"query_symbol",
"(",
"self",
",",
"asset",
":",
"str",
")",
"->",
"str",
":",
"contract_address",
"=",
"self",
".",
"get_asset_address",
"(",
"asset",
")",
"method",
"=",
"'symbol'",
"invoke_code",
"=",
"build_native_invoke_code",
"(",
"contract_address",... | This interface is used to query the asset's symbol of ONT or ONG.
:param asset: a string which is used to indicate which asset's symbol we want to get.
:return: asset's symbol in the form of string. | [
"This",
"interface",
"is",
"used",
"to",
"query",
"the",
"asset",
"s",
"symbol",
"of",
"ONT",
"or",
"ONG",
"."
] | python | train | 50.428571 |
lago-project/lago | lago/sdk_utils.py | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/sdk_utils.py#L76-L95 | def setup_sdk_logging(logfile=None, loglevel=logging.INFO):
"""
Setup a NullHandler to the root logger. If ``logfile`` is passed,
additionally add a FileHandler in ``loglevel`` level.
Args:
logfile(str): A path to setup a log file.
loglevel(int): :mod:`logging` log level.
Returns:
... | [
"def",
"setup_sdk_logging",
"(",
"logfile",
"=",
"None",
",",
"loglevel",
"=",
"logging",
".",
"INFO",
")",
":",
"logging",
".",
"root",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"logging",
".",
"root",
".",
"addHandler",
"(",
"logging",
".",
... | Setup a NullHandler to the root logger. If ``logfile`` is passed,
additionally add a FileHandler in ``loglevel`` level.
Args:
logfile(str): A path to setup a log file.
loglevel(int): :mod:`logging` log level.
Returns:
None | [
"Setup",
"a",
"NullHandler",
"to",
"the",
"root",
"logger",
".",
"If",
"logfile",
"is",
"passed",
"additionally",
"add",
"a",
"FileHandler",
"in",
"loglevel",
"level",
"."
] | python | train | 29.55 |
wavefrontHQ/python-client | wavefront_api_client/models/event.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/models/event.py#L288-L303 | def creator_type(self, creator_type):
"""Sets the creator_type of this Event.
:param creator_type: The creator_type of this Event. # noqa: E501
:type: list[str]
"""
allowed_values = ["USER", "ALERT", "SYSTEM"] # noqa: E501
if not set(creator_type).issubset(set(allowed... | [
"def",
"creator_type",
"(",
"self",
",",
"creator_type",
")",
":",
"allowed_values",
"=",
"[",
"\"USER\"",
",",
"\"ALERT\"",
",",
"\"SYSTEM\"",
"]",
"# noqa: E501",
"if",
"not",
"set",
"(",
"creator_type",
")",
".",
"issubset",
"(",
"set",
"(",
"allowed_valu... | Sets the creator_type of this Event.
:param creator_type: The creator_type of this Event. # noqa: E501
:type: list[str] | [
"Sets",
"the",
"creator_type",
"of",
"this",
"Event",
"."
] | python | train | 41.375 |
vpelletier/python-hidraw | hidraw/__init__.py | https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L120-L134 | def getFeatureReport(self, report_num=0, length=63):
"""
Receive a feature report.
Blocks, unless you configured provided file (descriptor) to be
non-blocking.
"""
length += 1
buf = bytearray(length)
buf[0] = report_num
self._ioctl(
_HI... | [
"def",
"getFeatureReport",
"(",
"self",
",",
"report_num",
"=",
"0",
",",
"length",
"=",
"63",
")",
":",
"length",
"+=",
"1",
"buf",
"=",
"bytearray",
"(",
"length",
")",
"buf",
"[",
"0",
"]",
"=",
"report_num",
"self",
".",
"_ioctl",
"(",
"_HIDIOCGF... | Receive a feature report.
Blocks, unless you configured provided file (descriptor) to be
non-blocking. | [
"Receive",
"a",
"feature",
"report",
".",
"Blocks",
"unless",
"you",
"configured",
"provided",
"file",
"(",
"descriptor",
")",
"to",
"be",
"non",
"-",
"blocking",
"."
] | python | train | 28.6 |
pypyr/pypyr-cli | pypyr/yaml.py | https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/yaml.py#L7-L31 | def get_pipeline_yaml(file):
"""Return pipeline yaml from open file object.
Use specific custom representers to model the custom pypyr pipeline yaml
format, to load in special literal types like py and sic strings.
If looking to extend the pypyr pipeline syntax with special types, add
these to the... | [
"def",
"get_pipeline_yaml",
"(",
"file",
")",
":",
"tag_representers",
"=",
"[",
"PyString",
",",
"SicString",
"]",
"yaml_loader",
"=",
"get_yaml_parser_safe",
"(",
")",
"for",
"representer",
"in",
"tag_representers",
":",
"yaml_loader",
".",
"register_class",
"("... | Return pipeline yaml from open file object.
Use specific custom representers to model the custom pypyr pipeline yaml
format, to load in special literal types like py and sic strings.
If looking to extend the pypyr pipeline syntax with special types, add
these to the tag_representers list.
Args:
... | [
"Return",
"pipeline",
"yaml",
"from",
"open",
"file",
"object",
"."
] | python | train | 27.88 |
lizardsystem/tags2sdists | tags2sdists/packagedir.py | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/packagedir.py#L37-L49 | def add_tarball(self, tarball, package):
"""Add a tarball, possibly creating the directory if needed."""
if tarball is None:
logger.error(
"No tarball found for %s: probably a renamed project?",
package)
return
target_dir = os.path.join(sel... | [
"def",
"add_tarball",
"(",
"self",
",",
"tarball",
",",
"package",
")",
":",
"if",
"tarball",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"No tarball found for %s: probably a renamed project?\"",
",",
"package",
")",
"return",
"target_dir",
"=",
"os",
".",... | Add a tarball, possibly creating the directory if needed. | [
"Add",
"a",
"tarball",
"possibly",
"creating",
"the",
"directory",
"if",
"needed",
"."
] | python | train | 42.923077 |
raphaelvallat/pingouin | pingouin/correlation.py | https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/correlation.py#L264-L480 | def corr(x, y, tail='two-sided', method='pearson'):
"""(Robust) correlation between two variables.
Parameters
----------
x, y : array_like
First and second set of observations. x and y must be independent.
tail : string
Specify whether to return 'one-sided' or 'two-sided' p-value.
... | [
"def",
"corr",
"(",
"x",
",",
"y",
",",
"tail",
"=",
"'two-sided'",
",",
"method",
"=",
"'pearson'",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
")",
"y",
"=",
"np",
".",
"asarray",
"(",
"y",
")",
"# Check size",
"if",
"x",
".",
"size",... | (Robust) correlation between two variables.
Parameters
----------
x, y : array_like
First and second set of observations. x and y must be independent.
tail : string
Specify whether to return 'one-sided' or 'two-sided' p-value.
method : string
Specify which method to use for ... | [
"(",
"Robust",
")",
"correlation",
"between",
"two",
"variables",
"."
] | python | train | 36.004608 |
nanoporetech/ont_fast5_api | ont_fast5_api/analysis_tools/segmentation.py | https://github.com/nanoporetech/ont_fast5_api/blob/352b3903155fcf4f19234c4f429dcefaa6d6bc4a/ont_fast5_api/analysis_tools/segmentation.py#L79-L110 | def get_event_data(self, section, time_in_seconds=False):
""" Get the template or complement event data.
:param section: Either template, complement, or both.
:param time_in_seconds: Return the start and length fields
in seconds, rather than samples.
:return: The eve... | [
"def",
"get_event_data",
"(",
"self",
",",
"section",
",",
"time_in_seconds",
"=",
"False",
")",
":",
"if",
"section",
"not",
"in",
"[",
"'template'",
",",
"'complement'",
",",
"'both'",
"]",
":",
"raise",
"Exception",
"(",
"'Unrecognized section: {} Expected: \... | Get the template or complement event data.
:param section: Either template, complement, or both.
:param time_in_seconds: Return the start and length fields
in seconds, rather than samples.
:return: The event dataset for the section. If section=both
then it return... | [
"Get",
"the",
"template",
"or",
"complement",
"event",
"data",
".",
":",
"param",
"section",
":",
"Either",
"template",
"complement",
"or",
"both",
".",
":",
"param",
"time_in_seconds",
":",
"Return",
"the",
"start",
"and",
"length",
"fields",
"in",
"seconds... | python | train | 47.90625 |
fermiPy/fermipy | fermipy/diffuse/name_policy.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/name_policy.py#L554-L563 | def master_srcmdl_xml(self, **kwargs):
""" return the name of a source model file
"""
kwargs_copy = self.base_dict.copy()
kwargs_copy.update(**kwargs)
self._replace_none(kwargs_copy)
localpath = NameFactory.master_srcmdl_xml_format.format(**kwargs_copy)
if... | [
"def",
"master_srcmdl_xml",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"self",
".",
"base_dict",
".",
"copy",
"(",
")",
"kwargs_copy",
".",
"update",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"_replace_none",
"(",
"kwargs_copy",... | return the name of a source model file | [
"return",
"the",
"name",
"of",
"a",
"source",
"model",
"file"
] | python | train | 42.1 |
upsight/doctor | doctor/docs/base.py | https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/docs/base.py#L495-L505 | def class_name_to_resource_name(class_name: str) -> str:
"""Converts a camel case class name to a resource name with spaces.
>>> class_name_to_resource_name('FooBarObject')
'Foo Bar Object'
:param class_name: The name to convert.
:returns: The resource name.
"""
s = re.sub('(.)([A-Z][a-z]+... | [
"def",
"class_name_to_resource_name",
"(",
"class_name",
":",
"str",
")",
"->",
"str",
":",
"s",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1 \\2'",
",",
"class_name",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1 ... | Converts a camel case class name to a resource name with spaces.
>>> class_name_to_resource_name('FooBarObject')
'Foo Bar Object'
:param class_name: The name to convert.
:returns: The resource name. | [
"Converts",
"a",
"camel",
"case",
"class",
"name",
"to",
"a",
"resource",
"name",
"with",
"spaces",
"."
] | python | train | 35.181818 |
lxc/python2-lxc | lxc/__init__.py | https://github.com/lxc/python2-lxc/blob/b7ec757d2bea1e5787c3e65b1359b8893491ef90/lxc/__init__.py#L233-L254 | def clone(self, newname, config_path=None, flags=0, bdevtype=None,
bdevdata=None, newsize=0, hookargs=()):
"""
Clone the current container.
"""
args = {}
args['newname'] = newname
args['flags'] = flags
args['newsize'] = newsize
args['hoo... | [
"def",
"clone",
"(",
"self",
",",
"newname",
",",
"config_path",
"=",
"None",
",",
"flags",
"=",
"0",
",",
"bdevtype",
"=",
"None",
",",
"bdevdata",
"=",
"None",
",",
"newsize",
"=",
"0",
",",
"hookargs",
"=",
"(",
")",
")",
":",
"args",
"=",
"{"... | Clone the current container. | [
"Clone",
"the",
"current",
"container",
"."
] | python | train | 29.954545 |
Azure/azure-sdk-for-python | azure-mgmt-storage/azure/mgmt/storage/storage_management_client.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-storage/azure/mgmt/storage/storage_management_client.py#L179-L189 | def management_policies(self):
"""Instance depends on the API version:
* 2018-07-01: :class:`ManagementPoliciesOperations<azure.mgmt.storage.v2018_07_01.operations.ManagementPoliciesOperations>`
"""
api_version = self._get_api_version('management_policies')
if api_version == ... | [
"def",
"management_policies",
"(",
"self",
")",
":",
"api_version",
"=",
"self",
".",
"_get_api_version",
"(",
"'management_policies'",
")",
"if",
"api_version",
"==",
"'2018-07-01'",
":",
"from",
".",
"v2018_07_01",
".",
"operations",
"import",
"ManagementPoliciesO... | Instance depends on the API version:
* 2018-07-01: :class:`ManagementPoliciesOperations<azure.mgmt.storage.v2018_07_01.operations.ManagementPoliciesOperations>` | [
"Instance",
"depends",
"on",
"the",
"API",
"version",
":"
] | python | test | 61 |
napalm-automation/napalm | napalm/junos/junos.py | https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/junos/junos.py#L1427-L1441 | def get_ipv6_neighbors_table(self):
"""Return the IPv6 neighbors table."""
ipv6_neighbors_table = []
ipv6_neighbors_table_raw = junos_views.junos_ipv6_neighbors_table(self.device)
ipv6_neighbors_table_raw.get()
ipv6_neighbors_table_items = ipv6_neighbors_table_raw.items()
... | [
"def",
"get_ipv6_neighbors_table",
"(",
"self",
")",
":",
"ipv6_neighbors_table",
"=",
"[",
"]",
"ipv6_neighbors_table_raw",
"=",
"junos_views",
".",
"junos_ipv6_neighbors_table",
"(",
"self",
".",
"device",
")",
"ipv6_neighbors_table_raw",
".",
"get",
"(",
")",
"ip... | Return the IPv6 neighbors table. | [
"Return",
"the",
"IPv6",
"neighbors",
"table",
"."
] | python | train | 45.333333 |
allenai/allennlp | allennlp/semparse/contexts/table_question_knowledge_graph.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/table_question_knowledge_graph.py#L329-L333 | def _should_split_column_cells(cls, column_cells: List[str]) -> bool:
"""
Returns true if there is any cell in this column that can be split.
"""
return any(cls._should_split_cell(cell_text) for cell_text in column_cells) | [
"def",
"_should_split_column_cells",
"(",
"cls",
",",
"column_cells",
":",
"List",
"[",
"str",
"]",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"cls",
".",
"_should_split_cell",
"(",
"cell_text",
")",
"for",
"cell_text",
"in",
"column_cells",
")"
] | Returns true if there is any cell in this column that can be split. | [
"Returns",
"true",
"if",
"there",
"is",
"any",
"cell",
"in",
"this",
"column",
"that",
"can",
"be",
"split",
"."
] | python | train | 49.8 |
plotly/octogrid | octogrid/auth/auth.py | https://github.com/plotly/octogrid/blob/46237a72c79765fe5a48af7065049c692e6457a7/octogrid/auth/auth.py#L19-L31 | def has_credentials_stored():
"""
Return 'auth token' string, if the user credentials are already stored
"""
try:
with open(credentials_file, 'r') as f:
token = f.readline().strip()
id = f.readline().strip()
return token
except Exception, e:
retu... | [
"def",
"has_credentials_stored",
"(",
")",
":",
"try",
":",
"with",
"open",
"(",
"credentials_file",
",",
"'r'",
")",
"as",
"f",
":",
"token",
"=",
"f",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"id",
"=",
"f",
".",
"readline",
"(",
")",
... | Return 'auth token' string, if the user credentials are already stored | [
"Return",
"auth",
"token",
"string",
"if",
"the",
"user",
"credentials",
"are",
"already",
"stored"
] | python | train | 24.307692 |
lambdalisue/django-permission | src/permission/templatetags/permissionif.py | https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/templatetags/permissionif.py#L77-L128 | def do_permissionif(parser, token):
"""
Permission if templatetag
Examples
--------
::
{% if user has 'blogs.add_article' %}
<p>This user have 'blogs.add_article' permission</p>
{% elif user has 'blog.change_article' of object %}
<p>This user have 'blogs.cha... | [
"def",
"do_permissionif",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"ELIF",
"=",
"\"el%s\"",
"%",
"bits",
"[",
"0",
"]",
"ELSE",
"=",
"\"else\"",
"ENDIF",
"=",
"\"end%s\"",
"%",
"bits",
"[",
"0",
"]... | Permission if templatetag
Examples
--------
::
{% if user has 'blogs.add_article' %}
<p>This user have 'blogs.add_article' permission</p>
{% elif user has 'blog.change_article' of object %}
<p>This user have 'blogs.change_article' permission of {{object}}</p>
... | [
"Permission",
"if",
"templatetag"
] | python | train | 32.25 |
ModisWorks/modis | modis/discord_modis/modules/manager/ui_embed.py | https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/manager/ui_embed.py#L31-L51 | def modify_prefix(channel, new_prefix):
"""
Creates an embed UI containing the prefix modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
new_prefix (str): The value of the new prefix
Returns:
embed: The created embed
"""
# Create... | [
"def",
"modify_prefix",
"(",
"channel",
",",
"new_prefix",
")",
":",
"# Create embed UI object",
"gui",
"=",
"ui_embed",
".",
"UI",
"(",
"channel",
",",
"\"Prefix updated\"",
",",
"\"Modis prefix is now `{}`\"",
".",
"format",
"(",
"new_prefix",
")",
",",
"modulen... | Creates an embed UI containing the prefix modified message
Args:
channel (discord.Channel): The Discord channel to bind the embed to
new_prefix (str): The value of the new prefix
Returns:
embed: The created embed | [
"Creates",
"an",
"embed",
"UI",
"containing",
"the",
"prefix",
"modified",
"message"
] | python | train | 23.285714 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py#L129-L143 | def fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_eth_port_id(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
fcoe_get_interface = ET.Element("fcoe_get_interface")
config = fcoe_get_interface
output = ET.SubElement(fcoe_get_interface, "outpu... | [
"def",
"fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_eth_port_id",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"fcoe_get_interface",
"=",
"ET",
".",
"Element",
"(",
"\"fcoe_get_interface\"",
")",... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 53.133333 |
makinacorpus/landez | landez/tiles.py | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L410-L424 | def grid_tiles(self, bbox, zoomlevel):
"""
Return a grid of (x, y) tuples representing the juxtaposition
of tiles on the specified ``bbox`` at the specified ``zoomlevel``.
"""
tiles = self.tileslist(bbox, [zoomlevel])
grid = {}
for (z, x, y) in tiles:
... | [
"def",
"grid_tiles",
"(",
"self",
",",
"bbox",
",",
"zoomlevel",
")",
":",
"tiles",
"=",
"self",
".",
"tileslist",
"(",
"bbox",
",",
"[",
"zoomlevel",
"]",
")",
"grid",
"=",
"{",
"}",
"for",
"(",
"z",
",",
"x",
",",
"y",
")",
"in",
"tiles",
":"... | Return a grid of (x, y) tuples representing the juxtaposition
of tiles on the specified ``bbox`` at the specified ``zoomlevel``. | [
"Return",
"a",
"grid",
"of",
"(",
"x",
"y",
")",
"tuples",
"representing",
"the",
"juxtaposition",
"of",
"tiles",
"on",
"the",
"specified",
"bbox",
"at",
"the",
"specified",
"zoomlevel",
"."
] | python | train | 38.133333 |
annoviko/pyclustering | pyclustering/nnet/sync.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/sync.py#L302-L335 | def allocate_correlation_matrix(self, iteration = None):
"""!
@brief Allocate correlation matrix between oscillators at the specified step of simulation.
@param[in] iteration (uint): Number of iteration of simulation for which correlation matrix should be allocated.
... | [
"def",
"allocate_correlation_matrix",
"(",
"self",
",",
"iteration",
"=",
"None",
")",
":",
"if",
"(",
"self",
".",
"_ccore_sync_dynamic_pointer",
"is",
"not",
"None",
")",
":",
"return",
"wrapper",
".",
"sync_dynamic_allocate_correlation_matrix",
"(",
"self",
"."... | !
@brief Allocate correlation matrix between oscillators at the specified step of simulation.
@param[in] iteration (uint): Number of iteration of simulation for which correlation matrix should be allocated.
If iternation number is not specified, the last step of s... | [
"!"
] | python | valid | 45.264706 |
DasIch/argvard | argvard/__init__.py | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/__init__.py#L41-L53 | def from_main(cls, signature=''):
"""
A decorator that creates an instance and registers the decorated
function as main function, see :meth:`main` for more information.
.. versionadded:: 0.2
"""
instance = cls()
def decorate(function):
instance.main(... | [
"def",
"from_main",
"(",
"cls",
",",
"signature",
"=",
"''",
")",
":",
"instance",
"=",
"cls",
"(",
")",
"def",
"decorate",
"(",
"function",
")",
":",
"instance",
".",
"main",
"(",
"signature",
")",
"(",
"function",
")",
"return",
"instance",
"return",... | A decorator that creates an instance and registers the decorated
function as main function, see :meth:`main` for more information.
.. versionadded:: 0.2 | [
"A",
"decorator",
"that",
"creates",
"an",
"instance",
"and",
"registers",
"the",
"decorated",
"function",
"as",
"main",
"function",
"see",
":",
"meth",
":",
"main",
"for",
"more",
"information",
"."
] | python | train | 29.230769 |
not-na/peng3d | peng3d/world.py | https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/world.py#L270-L278 | def on_key_press(self,symbol,modifiers):
"""
Keyboard event handler handling only the escape key.
If an escape key press is detected, mouse exclusivity is toggled via :py:meth:`PengWindow.toggle_exclusivity()`\ .
"""
if symbol == key.ESCAPE:
self.world.peng.w... | [
"def",
"on_key_press",
"(",
"self",
",",
"symbol",
",",
"modifiers",
")",
":",
"if",
"symbol",
"==",
"key",
".",
"ESCAPE",
":",
"self",
".",
"world",
".",
"peng",
".",
"window",
".",
"toggle_exclusivity",
"(",
")",
"return",
"pyglet",
".",
"event",
"."... | Keyboard event handler handling only the escape key.
If an escape key press is detected, mouse exclusivity is toggled via :py:meth:`PengWindow.toggle_exclusivity()`\ . | [
"Keyboard",
"event",
"handler",
"handling",
"only",
"the",
"escape",
"key",
".",
"If",
"an",
"escape",
"key",
"press",
"is",
"detected",
"mouse",
"exclusivity",
"is",
"toggled",
"via",
":",
"py",
":",
"meth",
":",
"PengWindow",
".",
"toggle_exclusivity",
"()... | python | test | 42.666667 |
sosreport/sos | sos/plugins/__init__.py | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L940-L956 | def _make_command_filename(self, exe):
"""The internal function to build up a filename based on a command."""
outfn = os.path.join(self.commons['cmddir'], self.name(),
self._mangle_command(exe))
# check for collisions
if os.path.exists(outfn):
i... | [
"def",
"_make_command_filename",
"(",
"self",
",",
"exe",
")",
":",
"outfn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"commons",
"[",
"'cmddir'",
"]",
",",
"self",
".",
"name",
"(",
")",
",",
"self",
".",
"_mangle_command",
"(",
"exe",
... | The internal function to build up a filename based on a command. | [
"The",
"internal",
"function",
"to",
"build",
"up",
"a",
"filename",
"based",
"on",
"a",
"command",
"."
] | python | train | 31.411765 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/configeditor.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/configeditor.py#L211-L224 | def get_value(self, index):
""" Return the value of the given index
The index stores the section as internal pointer.
The row of the index determines the key.
The key is used on the section to return the value
:param index: The QModelIndex
:type index: QModelIndex
... | [
"def",
"get_value",
"(",
"self",
",",
"index",
")",
":",
"p",
"=",
"index",
".",
"internalPointer",
"(",
")",
"k",
"=",
"self",
".",
"get_key",
"(",
"p",
",",
"index",
".",
"row",
"(",
")",
")",
"return",
"p",
"[",
"k",
"]"
] | Return the value of the given index
The index stores the section as internal pointer.
The row of the index determines the key.
The key is used on the section to return the value
:param index: The QModelIndex
:type index: QModelIndex
:returns: The value for the given ind... | [
"Return",
"the",
"value",
"of",
"the",
"given",
"index"
] | python | train | 32.714286 |
jbloomlab/phydms | phydmslib/parsearguments.py | https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/parsearguments.py#L146-L155 | def diffPrefsPrior(priorstring):
"""Parses `priorstring` and returns `prior` tuple."""
assert isinstance(priorstring, str)
prior = priorstring.split(',')
if len(prior) == 3 and prior[0] == 'invquadratic':
[c1, c2] = [float(x) for x in prior[1 : ]]
assert c1 > 0 and c2 > 0, "C1 and C2 mus... | [
"def",
"diffPrefsPrior",
"(",
"priorstring",
")",
":",
"assert",
"isinstance",
"(",
"priorstring",
",",
"str",
")",
"prior",
"=",
"priorstring",
".",
"split",
"(",
"','",
")",
"if",
"len",
"(",
"prior",
")",
"==",
"3",
"and",
"prior",
"[",
"0",
"]",
... | Parses `priorstring` and returns `prior` tuple. | [
"Parses",
"priorstring",
"and",
"returns",
"prior",
"tuple",
"."
] | python | train | 46.9 |
google/pyu2f | pyu2f/apdu.py | https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/apdu.py#L56-L79 | def ToByteArray(self):
"""Serialize the command.
Encodes the command as per the U2F specs, using the standard
ISO 7816-4 extended encoding. All Commands expect data, so
Le is always present.
Returns:
Python bytearray of the encoded command.
"""
lc = self.InternalEncodeLc()
out =... | [
"def",
"ToByteArray",
"(",
"self",
")",
":",
"lc",
"=",
"self",
".",
"InternalEncodeLc",
"(",
")",
"out",
"=",
"bytearray",
"(",
"4",
")",
"# will extend",
"out",
"[",
"0",
"]",
"=",
"self",
".",
"cla",
"out",
"[",
"1",
"]",
"=",
"self",
".",
"in... | Serialize the command.
Encodes the command as per the U2F specs, using the standard
ISO 7816-4 extended encoding. All Commands expect data, so
Le is always present.
Returns:
Python bytearray of the encoded command. | [
"Serialize",
"the",
"command",
"."
] | python | train | 24.333333 |
cuihantao/andes | andes/main.py | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L425-L480 | def edit_conf(edit_config=False, load_config=None, **kwargs):
"""
Edit the Andes config file which occurs first in the search path.
Parameters
----------
edit_config : bool
If ``True``, try to open up an editor and edit the config file.
Otherwise returns.
load_config : None or ... | [
"def",
"edit_conf",
"(",
"edit_config",
"=",
"False",
",",
"load_config",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"False",
"# no `edit-config` supplied",
"if",
"edit_config",
"==",
"''",
":",
"return",
"ret",
"conf_path",
"=",
"misc",
"... | Edit the Andes config file which occurs first in the search path.
Parameters
----------
edit_config : bool
If ``True``, try to open up an editor and edit the config file.
Otherwise returns.
load_config : None or str, optional
Path to the config file, which will be placed to the... | [
"Edit",
"the",
"Andes",
"config",
"file",
"which",
"occurs",
"first",
"in",
"the",
"search",
"path",
"."
] | python | train | 27.125 |
wonambi-python/wonambi | wonambi/widgets/traces.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/widgets/traces.py#L754-L757 | def Y_ampl(self, new_y_scale):
"""Make scaling on Y axis using predefined values"""
self.parent.value('y_scale', new_y_scale)
self.parent.traces.display() | [
"def",
"Y_ampl",
"(",
"self",
",",
"new_y_scale",
")",
":",
"self",
".",
"parent",
".",
"value",
"(",
"'y_scale'",
",",
"new_y_scale",
")",
"self",
".",
"parent",
".",
"traces",
".",
"display",
"(",
")"
] | Make scaling on Y axis using predefined values | [
"Make",
"scaling",
"on",
"Y",
"axis",
"using",
"predefined",
"values"
] | python | train | 43.75 |
log2timeline/plaso | plaso/formatters/interface.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/formatters/interface.py#L182-L198 | def GetSources(self, event):
"""Determines the the short and long source for an event object.
Args:
event (EventObject): event.
Returns:
tuple(str, str): short and long source string.
Raises:
WrongFormatter: if the event object cannot be formatted by the formatter.
"""
if se... | [
"def",
"GetSources",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"DATA_TYPE",
"!=",
"event",
".",
"data_type",
":",
"raise",
"errors",
".",
"WrongFormatter",
"(",
"'Unsupported data type: {0:s}.'",
".",
"format",
"(",
"event",
".",
"data_type",
"... | Determines the the short and long source for an event object.
Args:
event (EventObject): event.
Returns:
tuple(str, str): short and long source string.
Raises:
WrongFormatter: if the event object cannot be formatted by the formatter. | [
"Determines",
"the",
"the",
"short",
"and",
"long",
"source",
"for",
"an",
"event",
"object",
"."
] | python | train | 28.588235 |
genepattern/genepattern-python | gp/modules.py | https://github.com/genepattern/genepattern-python/blob/9478ea65362b91c72a94f7300c3de8d710bebb71/gp/modules.py#L542-L560 | def _generate_namespace():
"""
Generate an LSID namespace based off Jupyter user or system user
:return: string
"""
raw_namespace = None
# Get the Jupyter user, if available
try:
raw_namespace = os.environ['JPY_USER']
except KeyError:
... | [
"def",
"_generate_namespace",
"(",
")",
":",
"raw_namespace",
"=",
"None",
"# Get the Jupyter user, if available",
"try",
":",
"raw_namespace",
"=",
"os",
".",
"environ",
"[",
"'JPY_USER'",
"]",
"except",
"KeyError",
":",
"pass",
"# Otherwise get the current user",
"i... | Generate an LSID namespace based off Jupyter user or system user
:return: string | [
"Generate",
"an",
"LSID",
"namespace",
"based",
"off",
"Jupyter",
"user",
"or",
"system",
"user",
":",
"return",
":",
"string"
] | python | train | 29.315789 |
RedHatInsights/insights-core | insights/core/dr.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L735-L743 | def observer(self, component_type=ComponentType):
"""
You can use ``@broker.observer()`` as a decorator to your callback
instead of :func:`Broker.add_observer`.
"""
def inner(func):
self.add_observer(func, component_type)
return func
return inner | [
"def",
"observer",
"(",
"self",
",",
"component_type",
"=",
"ComponentType",
")",
":",
"def",
"inner",
"(",
"func",
")",
":",
"self",
".",
"add_observer",
"(",
"func",
",",
"component_type",
")",
"return",
"func",
"return",
"inner"
] | You can use ``@broker.observer()`` as a decorator to your callback
instead of :func:`Broker.add_observer`. | [
"You",
"can",
"use"
] | python | train | 34.444444 |
matthewgilbert/mapping | mapping/mappings.py | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/mappings.py#L144-L171 | def aggregate_weights(weights, drop_date=False):
"""
Transforms list of tuples of weights into pandas.DataFrame of weights.
Parameters:
-----------
weights: list
A list of tuples consisting of the generic instrument name,
the tradeable contract as a string, the weight on this contra... | [
"def",
"aggregate_weights",
"(",
"weights",
",",
"drop_date",
"=",
"False",
")",
":",
"dwts",
"=",
"pd",
".",
"DataFrame",
"(",
"weights",
",",
"columns",
"=",
"[",
"\"generic\"",
",",
"\"contract\"",
",",
"\"weight\"",
",",
"\"date\"",
"]",
")",
"dwts",
... | Transforms list of tuples of weights into pandas.DataFrame of weights.
Parameters:
-----------
weights: list
A list of tuples consisting of the generic instrument name,
the tradeable contract as a string, the weight on this contract as a
float and the date as a pandas.Timestamp.
... | [
"Transforms",
"list",
"of",
"tuples",
"of",
"weights",
"into",
"pandas",
".",
"DataFrame",
"of",
"weights",
"."
] | python | train | 37.25 |
trailofbits/manticore | manticore/core/workspace.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/workspace.py#L376-L384 | def load_state(self, state_id, delete=True):
"""
Load a state from storage identified by `state_id`.
:param state_id: The state reference of what to load
:return: The deserialized state
:rtype: State
"""
return self._store.load_state(f'{self._prefix}{state_id:08x... | [
"def",
"load_state",
"(",
"self",
",",
"state_id",
",",
"delete",
"=",
"True",
")",
":",
"return",
"self",
".",
"_store",
".",
"load_state",
"(",
"f'{self._prefix}{state_id:08x}{self._suffix}'",
",",
"delete",
"=",
"delete",
")"
] | Load a state from storage identified by `state_id`.
:param state_id: The state reference of what to load
:return: The deserialized state
:rtype: State | [
"Load",
"a",
"state",
"from",
"storage",
"identified",
"by",
"state_id",
"."
] | python | valid | 38.222222 |
fumitoh/modelx | modelx/core/spacecontainer.py | https://github.com/fumitoh/modelx/blob/0180da34d052c44fb94dab9e115e218bbebfc9c3/modelx/core/spacecontainer.py#L307-L360 | def new_space(
self,
name=None,
bases=None,
formula=None,
*,
refs=None,
source=None,
is_derived=False,
prefix=""
):
"""Create a new child space.
Args:
name (str): Name of the space. If omitted, the space is
... | [
"def",
"new_space",
"(",
"self",
",",
"name",
"=",
"None",
",",
"bases",
"=",
"None",
",",
"formula",
"=",
"None",
",",
"*",
",",
"refs",
"=",
"None",
",",
"source",
"=",
"None",
",",
"is_derived",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
")",
"... | Create a new child space.
Args:
name (str): Name of the space. If omitted, the space is
created automatically.
bases: If specified, the new space becomes a derived space of
the `base` space.
formula: Function whose parameters used to set space... | [
"Create",
"a",
"new",
"child",
"space",
"."
] | python | valid | 29.666667 |
praekelt/django-analytics | analytics/validation.py | https://github.com/praekelt/django-analytics/blob/29c22d03374ccc0ec451650e2c2886d324f6e5c6/analytics/validation.py#L3-L11 | def validate(metric_class):
"""
Does basic Metric option validation.
"""
if not hasattr(metric_class, 'label'):
raise ImproperlyConfigured("No 'label' attribute found for metric %s." % metric_class.__name__)
if not hasattr(metric_class, 'widget'):
raise ImproperlyConfigured("No... | [
"def",
"validate",
"(",
"metric_class",
")",
":",
"if",
"not",
"hasattr",
"(",
"metric_class",
",",
"'label'",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"No 'label' attribute found for metric %s.\"",
"%",
"metric_class",
".",
"__name__",
")",
"if",
"not",
... | Does basic Metric option validation. | [
"Does",
"basic",
"Metric",
"option",
"validation",
"."
] | python | test | 42 |
requests/requests-oauthlib | requests_oauthlib/oauth1_session.py | https://github.com/requests/requests-oauthlib/blob/800976faab3b827a42fa1cb80f13fcc03961d2c9/requests_oauthlib/oauth1_session.py#L293-L326 | def fetch_access_token(self, url, verifier=None, **request_kwargs):
"""Fetch an access token.
This is the final step in the OAuth 1 workflow. An access token is
obtained using all previously obtained credentials, including the
verifier from the authorization step.
Note that a p... | [
"def",
"fetch_access_token",
"(",
"self",
",",
"url",
",",
"verifier",
"=",
"None",
",",
"*",
"*",
"request_kwargs",
")",
":",
"if",
"verifier",
":",
"self",
".",
"_client",
".",
"client",
".",
"verifier",
"=",
"verifier",
"if",
"not",
"getattr",
"(",
... | Fetch an access token.
This is the final step in the OAuth 1 workflow. An access token is
obtained using all previously obtained credentials, including the
verifier from the authorization step.
Note that a previously set verifier will be reset for your
convenience, or else sign... | [
"Fetch",
"an",
"access",
"token",
"."
] | python | valid | 46.147059 |
razor-x/dichalcogenides | dichalcogenides/parameters/parameters.py | https://github.com/razor-x/dichalcogenides/blob/0fa1995a3a328b679c9926f73239d0ecdc6e5d3d/dichalcogenides/parameters/parameters.py#L126-L160 | def load_file(self, path):
"""Load a YAML file with parameter data and other metadata.
:param path: Path to YAML file.
:type path: str
The data in the YAML file is used to set the properties for the instance.
The YAML file must contain a ``parameters`` key.
It may optio... | [
"def",
"load_file",
"(",
"self",
",",
"path",
")",
":",
"data",
"=",
"yaml",
".",
"load",
"(",
"open",
"(",
"path",
",",
"'r'",
")",
")",
"for",
"key",
"in",
"self",
".",
"property_keys",
":",
"if",
"key",
"in",
"data",
":",
"setattr",
"(",
"self... | Load a YAML file with parameter data and other metadata.
:param path: Path to YAML file.
:type path: str
The data in the YAML file is used to set the properties for the instance.
The YAML file must contain a ``parameters`` key.
It may optionally include any keys defined in :att... | [
"Load",
"a",
"YAML",
"file",
"with",
"parameter",
"data",
"and",
"other",
"metadata",
"."
] | python | train | 30.771429 |
jaraco/svg.charts | svg/charts/util.py | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/util.py#L4-L13 | def reverse_mapping(mapping):
"""
For every key, value pair, return the mapping for the
equivalent value, key pair
>>> reverse_mapping({'a': 'b'}) == {'b': 'a'}
True
"""
keys, values = zip(*mapping.items())
return dict(zip(values, keys)) | [
"def",
"reverse_mapping",
"(",
"mapping",
")",
":",
"keys",
",",
"values",
"=",
"zip",
"(",
"*",
"mapping",
".",
"items",
"(",
")",
")",
"return",
"dict",
"(",
"zip",
"(",
"values",
",",
"keys",
")",
")"
] | For every key, value pair, return the mapping for the
equivalent value, key pair
>>> reverse_mapping({'a': 'b'}) == {'b': 'a'}
True | [
"For",
"every",
"key",
"value",
"pair",
"return",
"the",
"mapping",
"for",
"the",
"equivalent",
"value",
"key",
"pair"
] | python | test | 23.7 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_fabric_service.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_fabric_service.py#L405-L417 | def show_fibrechannel_interface_info_output_show_fibrechannel_interface_portsgroup_rbridgeid(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
show_fibrechannel_interface_info = ET.Element("show_fibrechannel_interface_info")
config = show_fibrechannel_inte... | [
"def",
"show_fibrechannel_interface_info_output_show_fibrechannel_interface_portsgroup_rbridgeid",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"show_fibrechannel_interface_info",
"=",
"ET",
".",
"Element",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 57.230769 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/settings/settings_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/settings/settings_client.py#L76-L98 | def get_entries_for_scope(self, user_scope, scope_name, scope_value, key=None):
"""GetEntriesForScope.
[Preview API] Get all setting entries for the given named scope
:param str user_scope: User-Scope at which to get the value. Should be "me" for the current user or "host" for all users.
... | [
"def",
"get_entries_for_scope",
"(",
"self",
",",
"user_scope",
",",
"scope_name",
",",
"scope_value",
",",
"key",
"=",
"None",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"user_scope",
"is",
"not",
"None",
":",
"route_values",
"[",
"'userScope'",
"]",
... | GetEntriesForScope.
[Preview API] Get all setting entries for the given named scope
:param str user_scope: User-Scope at which to get the value. Should be "me" for the current user or "host" for all users.
:param str scope_name: Scope at which to get the setting for (e.g. "project" or "team")
... | [
"GetEntriesForScope",
".",
"[",
"Preview",
"API",
"]",
"Get",
"all",
"setting",
"entries",
"for",
"the",
"given",
"named",
"scope",
":",
"param",
"str",
"user_scope",
":",
"User",
"-",
"Scope",
"at",
"which",
"to",
"get",
"the",
"value",
".",
"Should",
"... | python | train | 61.608696 |
mitsei/dlkit | dlkit/json_/assessment/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/sessions.py#L4121-L4221 | def get_assessments_by_query(self, assessment_query):
"""Gets a list of ``Assessments`` matching the given assessment query.
arg: assessment_query (osid.assessment.AssessmentQuery): the
assessment query
return: (osid.assessment.AssessmentList) - the returned
`... | [
"def",
"get_assessments_by_query",
"(",
"self",
",",
"assessment_query",
")",
":",
"\"\"\"Gets a list of ``Assessments`` matching the given assessment query.\n\n arg: assessment_query (osid.assessment.AssessmentQuery): the\n assessment query\n return: (osid.assessment... | Gets a list of ``Assessments`` matching the given assessment query.
arg: assessment_query (osid.assessment.AssessmentQuery): the
assessment query
return: (osid.assessment.AssessmentList) - the returned
``AssessmentList``
raise: NullArgument - ``assessment_que... | [
"Gets",
"a",
"list",
"of",
"Assessments",
"matching",
"the",
"given",
"assessment",
"query",
"."
] | python | train | 50.059406 |
gwpy/gwpy | gwpy/segments/segments.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/segments/segments.py#L189-L202 | def write(self, target, *args, **kwargs):
"""Write this `SegmentList` to a file
Arguments and keywords depend on the output format, see the
online documentation for full details for each format.
Parameters
----------
target : `str`
output filename
N... | [
"def",
"write",
"(",
"self",
",",
"target",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"io_registry",
".",
"write",
"(",
"self",
",",
"target",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Write this `SegmentList` to a file
Arguments and keywords depend on the output format, see the
online documentation for full details for each format.
Parameters
----------
target : `str`
output filename
Notes
----- | [
"Write",
"this",
"SegmentList",
"to",
"a",
"file"
] | python | train | 28 |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L4831-L4837 | def NewWalker(self, reader):
"""Setup an xmltextReader to parse a preparsed XML document.
This reuses the existing @reader xmlTextReader. """
if reader is None: reader__o = None
else: reader__o = reader._o
ret = libxml2mod.xmlReaderNewWalker(reader__o, self._o)
return ... | [
"def",
"NewWalker",
"(",
"self",
",",
"reader",
")",
":",
"if",
"reader",
"is",
"None",
":",
"reader__o",
"=",
"None",
"else",
":",
"reader__o",
"=",
"reader",
".",
"_o",
"ret",
"=",
"libxml2mod",
".",
"xmlReaderNewWalker",
"(",
"reader__o",
",",
"self",... | Setup an xmltextReader to parse a preparsed XML document.
This reuses the existing @reader xmlTextReader. | [
"Setup",
"an",
"xmltextReader",
"to",
"parse",
"a",
"preparsed",
"XML",
"document",
".",
"This",
"reuses",
"the",
"existing"
] | python | train | 45.285714 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1595-L1608 | def nic_remove(self, nic):
"""
Detach a nic from a bridge
:param nic: nic name to detach
"""
args = {
'nic': nic,
}
self._nic_remove_chk.check(args)
return self._client.json('bridge.nic-remove', args) | [
"def",
"nic_remove",
"(",
"self",
",",
"nic",
")",
":",
"args",
"=",
"{",
"'nic'",
":",
"nic",
",",
"}",
"self",
".",
"_nic_remove_chk",
".",
"check",
"(",
"args",
")",
"return",
"self",
".",
"_client",
".",
"json",
"(",
"'bridge.nic-remove'",
",",
"... | Detach a nic from a bridge
:param nic: nic name to detach | [
"Detach",
"a",
"nic",
"from",
"a",
"bridge"
] | python | train | 19.071429 |
junzis/pyModeS | pyModeS/decoder/common.py | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/common.py#L283-L297 | def allzeros(msg):
"""check if the data bits are all zeros
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False
"""
d = hex2bin(data(msg))
if bin2int(d) > 0:
return False
else:
return True | [
"def",
"allzeros",
"(",
"msg",
")",
":",
"d",
"=",
"hex2bin",
"(",
"data",
"(",
"msg",
")",
")",
"if",
"bin2int",
"(",
"d",
")",
">",
"0",
":",
"return",
"False",
"else",
":",
"return",
"True"
] | check if the data bits are all zeros
Args:
msg (String): 28 bytes hexadecimal message string
Returns:
bool: True or False | [
"check",
"if",
"the",
"data",
"bits",
"are",
"all",
"zeros"
] | python | train | 17.933333 |
materialsproject/pymatgen | pymatgen/io/vasp/inputs.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/inputs.py#L1004-L1019 | def gamma_automatic(kpts=(1, 1, 1), shift=(0, 0, 0)):
"""
Convenient static constructor for an automatic Gamma centered Kpoint
grid.
Args:
kpts: Subdivisions N_1, N_2 and N_3 along reciprocal lattice
vectors. Defaults to (1,1,1)
shift: Shift to be... | [
"def",
"gamma_automatic",
"(",
"kpts",
"=",
"(",
"1",
",",
"1",
",",
"1",
")",
",",
"shift",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"return",
"Kpoints",
"(",
"\"Automatic kpoint scheme\"",
",",
"0",
",",
"Kpoints",
".",
"supported_modes",
... | Convenient static constructor for an automatic Gamma centered Kpoint
grid.
Args:
kpts: Subdivisions N_1, N_2 and N_3 along reciprocal lattice
vectors. Defaults to (1,1,1)
shift: Shift to be applied to the kpoints. Defaults to (0,0,0).
Returns:
... | [
"Convenient",
"static",
"constructor",
"for",
"an",
"automatic",
"Gamma",
"centered",
"Kpoint",
"grid",
"."
] | python | train | 35.5 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/crash.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/crash.py#L727-L845 | def isExploitable(self):
"""
Guess how likely is it that the bug causing the crash can be leveraged
into an exploitable vulnerability.
@note: Don't take this as an equivalent of a real exploitability
analysis, that can only be done by a human being! This is only
... | [
"def",
"isExploitable",
"(",
"self",
")",
":",
"# Terminal rules",
"if",
"self",
".",
"eventCode",
"!=",
"win32",
".",
"EXCEPTION_DEBUG_EVENT",
":",
"return",
"(",
"\"Not an exception\"",
",",
"\"NotAnException\"",
",",
"\"The event is not an exception.\"",
")",
"if",... | Guess how likely is it that the bug causing the crash can be leveraged
into an exploitable vulnerability.
@note: Don't take this as an equivalent of a real exploitability
analysis, that can only be done by a human being! This is only
a guideline, useful for example to sort crash... | [
"Guess",
"how",
"likely",
"is",
"it",
"that",
"the",
"bug",
"causing",
"the",
"crash",
"can",
"be",
"leveraged",
"into",
"an",
"exploitable",
"vulnerability",
"."
] | python | train | 59.798319 |
newville/wxmplot | wxmplot/plotpanel.py | https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/wxmplot/plotpanel.py#L535-L540 | def toggle_legend(self, evt=None, show=None):
"toggle legend display"
if show is None:
show = not self.conf.show_legend
self.conf.show_legend = show
self.conf.draw_legend() | [
"def",
"toggle_legend",
"(",
"self",
",",
"evt",
"=",
"None",
",",
"show",
"=",
"None",
")",
":",
"if",
"show",
"is",
"None",
":",
"show",
"=",
"not",
"self",
".",
"conf",
".",
"show_legend",
"self",
".",
"conf",
".",
"show_legend",
"=",
"show",
"s... | toggle legend display | [
"toggle",
"legend",
"display"
] | python | train | 35.833333 |
bwohlberg/sporco | sporco/cnvrep.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cnvrep.py#L681-L701 | def zpad(v, Nv):
"""Zero-pad initial axes of array to specified size. Padding is
applied to the right, top, etc. of the array indices.
Parameters
----------
v : array_like
Array to be padded
Nv : tuple
Sizes to which each of initial indices should be padded
Returns
-------
... | [
"def",
"zpad",
"(",
"v",
",",
"Nv",
")",
":",
"vp",
"=",
"np",
".",
"zeros",
"(",
"Nv",
"+",
"v",
".",
"shape",
"[",
"len",
"(",
"Nv",
")",
":",
"]",
",",
"dtype",
"=",
"v",
".",
"dtype",
")",
"axnslc",
"=",
"tuple",
"(",
"[",
"slice",
"(... | Zero-pad initial axes of array to specified size. Padding is
applied to the right, top, etc. of the array indices.
Parameters
----------
v : array_like
Array to be padded
Nv : tuple
Sizes to which each of initial indices should be padded
Returns
-------
vp : ndarray
P... | [
"Zero",
"-",
"pad",
"initial",
"axes",
"of",
"array",
"to",
"specified",
"size",
".",
"Padding",
"is",
"applied",
"to",
"the",
"right",
"top",
"etc",
".",
"of",
"the",
"array",
"indices",
"."
] | python | train | 23.095238 |
srsudar/eg | eg/substitute.py | https://github.com/srsudar/eg/blob/96142a74f4416b4a7000c85032c070df713b849e/eg/substitute.py#L23-L34 | def apply_and_get_result(self, string):
"""
Perform the substitution represented by this object on string and return
the result.
"""
if self.is_multiline:
compiled_pattern = re.compile(self.pattern, re.MULTILINE)
else:
compiled_pattern = re.compile... | [
"def",
"apply_and_get_result",
"(",
"self",
",",
"string",
")",
":",
"if",
"self",
".",
"is_multiline",
":",
"compiled_pattern",
"=",
"re",
".",
"compile",
"(",
"self",
".",
"pattern",
",",
"re",
".",
"MULTILINE",
")",
"else",
":",
"compiled_pattern",
"=",... | Perform the substitution represented by this object on string and return
the result. | [
"Perform",
"the",
"substitution",
"represented",
"by",
"this",
"object",
"on",
"string",
"and",
"return",
"the",
"result",
"."
] | python | train | 33.916667 |
apetrynet/pyfilemail | pyfilemail/transfer.py | https://github.com/apetrynet/pyfilemail/blob/eb81b0e69ff42f4335d5298833e4769b750bf397/pyfilemail/transfer.py#L628-L660 | def download(self,
files=None,
destination=None,
overwrite=False,
callback=None):
"""Download file or files.
:param files: file or files to download
:param destination: destination path (defaults to users home directory)
... | [
"def",
"download",
"(",
"self",
",",
"files",
"=",
"None",
",",
"destination",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"callback",
"=",
"None",
")",
":",
"if",
"files",
"is",
"None",
":",
"files",
"=",
"self",
".",
"files",
"elif",
"not",
... | Download file or files.
:param files: file or files to download
:param destination: destination path (defaults to users home directory)
:param overwrite: replace existing files?
:param callback: callback function that will receive total file size
and written bytes as arguments
... | [
"Download",
"file",
"or",
"files",
"."
] | python | train | 32.272727 |
ambitioninc/rabbitmq-admin | rabbitmq_admin/api.py | https://github.com/ambitioninc/rabbitmq-admin/blob/ff65054115f19991da153f0e4f4e45e526545fea/rabbitmq_admin/api.py#L174-L183 | def list_exchanges_for_vhost(self, vhost):
"""
A list of all exchanges in a given virtual host.
:param vhost: The vhost name
:type vhost: str
"""
return self._api_get('/api/exchanges/{0}'.format(
urllib.parse.quote_plus(vhost)
)) | [
"def",
"list_exchanges_for_vhost",
"(",
"self",
",",
"vhost",
")",
":",
"return",
"self",
".",
"_api_get",
"(",
"'/api/exchanges/{0}'",
".",
"format",
"(",
"urllib",
".",
"parse",
".",
"quote_plus",
"(",
"vhost",
")",
")",
")"
] | A list of all exchanges in a given virtual host.
:param vhost: The vhost name
:type vhost: str | [
"A",
"list",
"of",
"all",
"exchanges",
"in",
"a",
"given",
"virtual",
"host",
"."
] | python | train | 28.9 |
bitesofcode/projexui | projexui/widgets/xpageswidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpageswidget.py#L193-L205 | def pageSizePicked( self, pageSize ):
"""
Updates when the user picks a page size.
:param pageSize | <str>
"""
try:
pageSize = int(self._pageSizeCombo.currentText())
except ValueError:
pageSize = 0
self.set... | [
"def",
"pageSizePicked",
"(",
"self",
",",
"pageSize",
")",
":",
"try",
":",
"pageSize",
"=",
"int",
"(",
"self",
".",
"_pageSizeCombo",
".",
"currentText",
"(",
")",
")",
"except",
"ValueError",
":",
"pageSize",
"=",
"0",
"self",
".",
"setPageSize",
"("... | Updates when the user picks a page size.
:param pageSize | <str> | [
"Updates",
"when",
"the",
"user",
"picks",
"a",
"page",
"size",
".",
":",
"param",
"pageSize",
"|",
"<str",
">"
] | python | train | 28.538462 |
aio-libs/aiohttp | aiohttp/web_request.py | https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L436-L444 | def _http_date(_date_str: str) -> Optional[datetime.datetime]:
"""Process a date string, return a datetime object
"""
if _date_str is not None:
timetuple = parsedate(_date_str)
if timetuple is not None:
return datetime.datetime(*timetuple[:6],
... | [
"def",
"_http_date",
"(",
"_date_str",
":",
"str",
")",
"->",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
":",
"if",
"_date_str",
"is",
"not",
"None",
":",
"timetuple",
"=",
"parsedate",
"(",
"_date_str",
")",
"if",
"timetuple",
"is",
"not",
"None... | Process a date string, return a datetime object | [
"Process",
"a",
"date",
"string",
"return",
"a",
"datetime",
"object"
] | python | train | 43.333333 |
mwickert/scikit-dsp-comm | sk_dsp_comm/multirate_helper.py | https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/multirate_helper.py#L203-L207 | def zplane(self,auto_scale=True,size=2,detect_mult=True,tol=0.001):
"""
Plot the poles and zeros of the FIR filter in the z-plane
"""
iir_d.sos_zplane(self.sos,auto_scale,size,tol) | [
"def",
"zplane",
"(",
"self",
",",
"auto_scale",
"=",
"True",
",",
"size",
"=",
"2",
",",
"detect_mult",
"=",
"True",
",",
"tol",
"=",
"0.001",
")",
":",
"iir_d",
".",
"sos_zplane",
"(",
"self",
".",
"sos",
",",
"auto_scale",
",",
"size",
",",
"tol... | Plot the poles and zeros of the FIR filter in the z-plane | [
"Plot",
"the",
"poles",
"and",
"zeros",
"of",
"the",
"FIR",
"filter",
"in",
"the",
"z",
"-",
"plane"
] | python | valid | 41.6 |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/html5lib/html5parser.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/html5lib/html5parser.py#L24-L29 | def parse(doc, treebuilder="etree", encoding=None,
namespaceHTMLElements=True):
"""Parse a string or file-like object into a tree"""
tb = treebuilders.getTreeBuilder(treebuilder)
p = HTMLParser(tb, namespaceHTMLElements=namespaceHTMLElements)
return p.parse(doc, encoding=encoding) | [
"def",
"parse",
"(",
"doc",
",",
"treebuilder",
"=",
"\"etree\"",
",",
"encoding",
"=",
"None",
",",
"namespaceHTMLElements",
"=",
"True",
")",
":",
"tb",
"=",
"treebuilders",
".",
"getTreeBuilder",
"(",
"treebuilder",
")",
"p",
"=",
"HTMLParser",
"(",
"tb... | Parse a string or file-like object into a tree | [
"Parse",
"a",
"string",
"or",
"file",
"-",
"like",
"object",
"into",
"a",
"tree"
] | python | test | 50.333333 |
Alignak-monitoring-contrib/alignak-backend-client | alignak_backend_client/client.py | https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L157-L196 | def get_response(self, method, endpoint, headers=None, json=None, params=None, data=None):
# pylint: disable=too-many-arguments
"""
Returns the response from the requested endpoint with the requested method
:param method: str. one of the methods accepted by Requests ('POST', 'GET', ...)
... | [
"def",
"get_response",
"(",
"self",
",",
"method",
",",
"endpoint",
",",
"headers",
"=",
"None",
",",
"json",
"=",
"None",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"# pylint: disable=too-many-arguments",
"logger",
".",
"debug",
"(",
... | Returns the response from the requested endpoint with the requested method
:param method: str. one of the methods accepted by Requests ('POST', 'GET', ...)
:param endpoint: str. the relative endpoint to access
:param params: (optional) Dictionary or bytes to be sent in the query string
f... | [
"Returns",
"the",
"response",
"from",
"the",
"requested",
"endpoint",
"with",
"the",
"requested",
"method",
":",
"param",
"method",
":",
"str",
".",
"one",
"of",
"the",
"methods",
"accepted",
"by",
"Requests",
"(",
"POST",
"GET",
"...",
")",
":",
"param",
... | python | test | 52.325 |
bububa/pyTOP | pyTOP/wangwang.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/wangwang.py#L133-L150 | def noreplynum_get(self, service_staff_id, start_date, end_date, session):
'''taobao.wangwang.eservice.noreplynum.get 客服未回复人数
根据操作者ID,返回被查者ID指定日期内每个帐号每日的"未回复情况" 备注:
- 1、如果是操作者ID=被查者ID,返回被查者ID的"未回复情况"(未回复人数、未回复的ID)。
- 2、如果操作者是组管理员,他可以查询他的组中的所有子帐号的"未回复情况"。
- 3、如... | [
"def",
"noreplynum_get",
"(",
"self",
",",
"service_staff_id",
",",
"start_date",
",",
"end_date",
",",
"session",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'taobao.wangwang.eservice.noreplynum.get'",
")",
"request",
"[",
"'service_staff_id'",
"]",
"=",
"service... | taobao.wangwang.eservice.noreplynum.get 客服未回复人数
根据操作者ID,返回被查者ID指定日期内每个帐号每日的"未回复情况" 备注:
- 1、如果是操作者ID=被查者ID,返回被查者ID的"未回复情况"(未回复人数、未回复的ID)。
- 2、如果操作者是组管理员,他可以查询他的组中的所有子帐号的"未回复情况"。
- 3、如果操作者是主账户,他可以查询所有子帐号的"未回复情况"。
- 4、被查者ID可以是多个,用 "," 隔开,id数不能超过30。
- 5、... | [
"taobao",
".",
"wangwang",
".",
"eservice",
".",
"noreplynum",
".",
"get",
"客服未回复人数",
"根据操作者ID,返回被查者ID指定日期内每个帐号每日的",
"未回复情况",
"备注:",
"-",
"1、如果是操作者ID",
"=",
"被查者ID,返回被查者ID的",
"未回复情况",
"(未回复人数、未回复的ID)。",
"-",
"2、如果操作者是组管理员,他可以查询他的组中的所有子帐号的",
"未回复情况",
"。",
"-",
"3、如果操作者... | python | train | 42.5 |
childsish/sofia | sofia/execution_engines/workers/parallel_worker.py | https://github.com/childsish/sofia/blob/39b992f143e2610a62ad751568caa5ca9aaf0224/sofia/execution_engines/workers/parallel_worker.py#L4-L35 | def parallel_worker(conn, steps):
"""
All messages follow the form: <message>, <data>
Valid messages
--------------
run, { 'step': <step_name>, 'input': <input_data> }
finalise, { 'step': <step_name> }
next, { 'step': <step_name> }
stop, None
"""
while True:
message, dat... | [
"def",
"parallel_worker",
"(",
"conn",
",",
"steps",
")",
":",
"while",
"True",
":",
"message",
",",
"data",
"=",
"conn",
".",
"recv",
"(",
")",
"sys",
".",
"stderr",
".",
"write",
"(",
"' worker recieved \"{}\" for {}\\n'",
".",
"format",
"(",
"message",
... | All messages follow the form: <message>, <data>
Valid messages
--------------
run, { 'step': <step_name>, 'input': <input_data> }
finalise, { 'step': <step_name> }
next, { 'step': <step_name> }
stop, None | [
"All",
"messages",
"follow",
"the",
"form",
":",
"<message",
">",
"<data",
">"
] | python | train | 38.25 |
fhs/pyhdf | pyhdf/SD.py | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2892-L2918 | def info(self):
"""Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
... | [
"def",
"info",
"(",
"self",
")",
":",
"status",
",",
"dim_name",
",",
"dim_size",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDdiminfo",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'info'",
",",
"status",
",",
"'cannot execute'",
")",
"ret... | Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
- dimension lengt... | [
"Return",
"info",
"about",
"the",
"dimension",
"instance",
"."
] | python | train | 35.740741 |
PyCQA/astroid | astroid/node_classes.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L162-L186 | def _slice_value(index, context=None):
"""Get the value of the given slice index."""
if isinstance(index, Const):
if isinstance(index.value, (int, type(None))):
return index.value
elif index is None:
return None
else:
# Try to infer what the index actually is.
... | [
"def",
"_slice_value",
"(",
"index",
",",
"context",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"index",
",",
"Const",
")",
":",
"if",
"isinstance",
"(",
"index",
".",
"value",
",",
"(",
"int",
",",
"type",
"(",
"None",
")",
")",
")",
":",
"... | Get the value of the given slice index. | [
"Get",
"the",
"value",
"of",
"the",
"given",
"slice",
"index",
"."
] | python | train | 34.44 |
spyder-ide/spyder | spyder/plugins/editor/utils/bookmarks.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/bookmarks.py#L32-L35 | def load_bookmarks_without_file(filename):
"""Load all bookmarks but those from a specific file."""
bookmarks = _load_all_bookmarks()
return {k: v for k, v in bookmarks.items() if v[0] != filename} | [
"def",
"load_bookmarks_without_file",
"(",
"filename",
")",
":",
"bookmarks",
"=",
"_load_all_bookmarks",
"(",
")",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"bookmarks",
".",
"items",
"(",
")",
"if",
"v",
"[",
"0",
"]",
"!=",
"filename... | Load all bookmarks but those from a specific file. | [
"Load",
"all",
"bookmarks",
"but",
"those",
"from",
"a",
"specific",
"file",
"."
] | python | train | 51.5 |
zenotech/SysScribe | sysscribe/__init__.py | https://github.com/zenotech/SysScribe/blob/8cabfc9718e7ccc6d217fbcfc158dd255b28c9b1/sysscribe/__init__.py#L10-L36 | def cpuinfo():
''' Return the information in /proc/cpuinfo
as a dictionary in the following format:
cpu_info['proc0']={...}
cpu_info['proc1']={...}
'''
cpuinfo=OrderedDict()
procinfo=OrderedDict()
nprocs = 0
with open('/proc/cpuinfo') as f:
for line in f:
if no... | [
"def",
"cpuinfo",
"(",
")",
":",
"cpuinfo",
"=",
"OrderedDict",
"(",
")",
"procinfo",
"=",
"OrderedDict",
"(",
")",
"nprocs",
"=",
"0",
"with",
"open",
"(",
"'/proc/cpuinfo'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"not",
"line",
... | Return the information in /proc/cpuinfo
as a dictionary in the following format:
cpu_info['proc0']={...}
cpu_info['proc1']={...} | [
"Return",
"the",
"information",
"in",
"/",
"proc",
"/",
"cpuinfo",
"as",
"a",
"dictionary",
"in",
"the",
"following",
"format",
":",
"cpu_info",
"[",
"proc0",
"]",
"=",
"{",
"...",
"}",
"cpu_info",
"[",
"proc1",
"]",
"=",
"{",
"...",
"}"
] | python | train | 28.259259 |
calmjs/calmjs.parse | src/calmjs/parse/parsers/es5.py | https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/parsers/es5.py#L225-L228 | def p_numeric_literal(self, p):
"""numeric_literal : NUMBER"""
p[0] = self.asttypes.Number(p[1])
p[0].setpos(p) | [
"def",
"p_numeric_literal",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"asttypes",
".",
"Number",
"(",
"p",
"[",
"1",
"]",
")",
"p",
"[",
"0",
"]",
".",
"setpos",
"(",
"p",
")"
] | numeric_literal : NUMBER | [
"numeric_literal",
":",
"NUMBER"
] | python | train | 33 |
boto/s3transfer | s3transfer/download.py | https://github.com/boto/s3transfer/blob/2aead638c8385d8ae0b1756b2de17e8fad45fffa/s3transfer/download.py#L283-L309 | def _get_download_output_manager_cls(self, transfer_future, osutil):
"""Retrieves a class for managing output for a download
:type transfer_future: s3transfer.futures.TransferFuture
:param transfer_future: The transfer future for the request
:type osutil: s3transfer.utils.OSUtils
... | [
"def",
"_get_download_output_manager_cls",
"(",
"self",
",",
"transfer_future",
",",
"osutil",
")",
":",
"download_manager_resolver_chain",
"=",
"[",
"DownloadSpecialFilenameOutputManager",
",",
"DownloadFilenameOutputManager",
",",
"DownloadSeekableOutputManager",
",",
"Downlo... | Retrieves a class for managing output for a download
:type transfer_future: s3transfer.futures.TransferFuture
:param transfer_future: The transfer future for the request
:type osutil: s3transfer.utils.OSUtils
:param osutil: The os utility associated to the transfer
:rtype: cla... | [
"Retrieves",
"a",
"class",
"for",
"managing",
"output",
"for",
"a",
"download"
] | python | test | 41.740741 |
pantsbuild/pants | src/python/pants/util/fileutil.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/util/fileutil.py#L18-L23 | def atomic_copy(src, dst):
"""Copy the file src to dst, overwriting dst atomically."""
with temporary_file(root_dir=os.path.dirname(dst)) as tmp_dst:
shutil.copyfile(src, tmp_dst.name)
os.chmod(tmp_dst.name, os.stat(src).st_mode)
os.rename(tmp_dst.name, dst) | [
"def",
"atomic_copy",
"(",
"src",
",",
"dst",
")",
":",
"with",
"temporary_file",
"(",
"root_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"dst",
")",
")",
"as",
"tmp_dst",
":",
"shutil",
".",
"copyfile",
"(",
"src",
",",
"tmp_dst",
".",
"name",... | Copy the file src to dst, overwriting dst atomically. | [
"Copy",
"the",
"file",
"src",
"to",
"dst",
"overwriting",
"dst",
"atomically",
"."
] | python | train | 44.833333 |
crypto101/arthur | arthur/auth.py | https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/auth.py#L52-L66 | def _getContextFactory(path, workbench):
"""Get a context factory.
If the client already has a credentials at path, use them.
Otherwise, generate them at path. Notifications are reported to
the given workbench.
"""
try:
return succeed(getContextFactory(path))
except IOError:
... | [
"def",
"_getContextFactory",
"(",
"path",
",",
"workbench",
")",
":",
"try",
":",
"return",
"succeed",
"(",
"getContextFactory",
"(",
"path",
")",
")",
"except",
"IOError",
":",
"d",
"=",
"prompt",
"(",
"workbench",
",",
"u\"E-mail entry\"",
",",
"u\"Enter e... | Get a context factory.
If the client already has a credentials at path, use them.
Otherwise, generate them at path. Notifications are reported to
the given workbench. | [
"Get",
"a",
"context",
"factory",
"."
] | python | train | 33.4 |
The-Politico/politico-civic-election-night | electionnight/models/page_type.py | https://github.com/The-Politico/politico-civic-election-night/blob/a8aaf5be43872a7b84d2b0d7c2b6151d32d4d8b6/electionnight/models/page_type.py#L69-L109 | def page_location_template(self):
"""
Returns the published URL template for a page type.
"""
cycle = self.election_day.cycle.name
model_class = self.model_type.model_class()
if model_class == ElectionDay:
return "/{}/".format(cycle)
if model_class == ... | [
"def",
"page_location_template",
"(",
"self",
")",
":",
"cycle",
"=",
"self",
".",
"election_day",
".",
"cycle",
".",
"name",
"model_class",
"=",
"self",
".",
"model_type",
".",
"model_class",
"(",
")",
"if",
"model_class",
"==",
"ElectionDay",
":",
"return"... | Returns the published URL template for a page type. | [
"Returns",
"the",
"published",
"URL",
"template",
"for",
"a",
"page",
"type",
"."
] | python | train | 39.853659 |
tsnaomi/finnsyll | finnsyll/prev/v10.py | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L179-L195 | def apply_T2(word):
'''There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
WORD = word
offset = 0
for vv in vv_sequences(WORD):
seq = vv.group(2)
if not is_diphthong(seq) and not is_long(seq):
... | [
"def",
"apply_T2",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vv",
"in",
"vv_sequences",
"(",
"WORD",
")",
":",
"seq",
"=",
"vv",
".",
"group",
"(",
"2",
")",
"if",
"not",
"is_diphthong",
"(",
"seq",
")",
"and",
"not"... | There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa]. | [
"There",
"is",
"a",
"syllable",
"boundary",
"within",
"a",
"VV",
"sequence",
"of",
"two",
"nonidentical",
"vowels",
"that",
"are",
"not",
"a",
"genuine",
"diphthong",
"e",
".",
"g",
".",
"[",
"ta",
".",
"e",
"]",
"[",
"ko",
".",
"et",
".",
"taa",
"... | python | train | 28.117647 |
lmjohns3/theanets | theanets/util.py | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/util.py#L110-L134 | def random_vector(size, mean=0, std=1, rng=None):
'''Create a vector of randomly-initialized values.
Parameters
----------
size : int
Length of vecctor to create.
mean : float, optional
Mean value for initial vector values. Defaults to 0.
std : float, optional
Standard d... | [
"def",
"random_vector",
"(",
"size",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"1",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
"or",
"isinstance",
"(",
"rng",
",",
"int",
")",
":",
"rng",
"=",
"np",
".",
"random",
".",
"RandomS... | Create a vector of randomly-initialized values.
Parameters
----------
size : int
Length of vecctor to create.
mean : float, optional
Mean value for initial vector values. Defaults to 0.
std : float, optional
Standard deviation for initial vector values. Defaults to 1.
rn... | [
"Create",
"a",
"vector",
"of",
"randomly",
"-",
"initialized",
"values",
"."
] | python | test | 36.76 |
PmagPy/PmagPy | programs/demag_gui.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/demag_gui.py#L7281-L7319 | def on_menu_criteria_file(self, event):
"""
read pmag_criteria.txt file
and open changecriteria dialog
"""
if self.data_model == 3:
default_file = "criteria.txt"
else:
default_file = "pmag_criteria.txt"
read_sucsess = False
dlg = wx... | [
"def",
"on_menu_criteria_file",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"data_model",
"==",
"3",
":",
"default_file",
"=",
"\"criteria.txt\"",
"else",
":",
"default_file",
"=",
"\"pmag_criteria.txt\"",
"read_sucsess",
"=",
"False",
"dlg",
"=",
... | read pmag_criteria.txt file
and open changecriteria dialog | [
"read",
"pmag_criteria",
".",
"txt",
"file",
"and",
"open",
"changecriteria",
"dialog"
] | python | train | 34.615385 |
apache/incubator-heron | heron/statemgrs/src/python/zkstatemanager.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/statemgrs/src/python/zkstatemanager.py#L119-L138 | def _get_topologies_with_watch(self, callback, isWatching):
"""
Helper function to get topologies with
a callback. The future watch is placed
only if isWatching is True.
"""
path = self.get_topologies_path()
if isWatching:
LOG.info("Adding children watch for path: " + path)
# pyli... | [
"def",
"_get_topologies_with_watch",
"(",
"self",
",",
"callback",
",",
"isWatching",
")",
":",
"path",
"=",
"self",
".",
"get_topologies_path",
"(",
")",
"if",
"isWatching",
":",
"LOG",
".",
"info",
"(",
"\"Adding children watch for path: \"",
"+",
"path",
")",... | Helper function to get topologies with
a callback. The future watch is placed
only if isWatching is True. | [
"Helper",
"function",
"to",
"get",
"topologies",
"with",
"a",
"callback",
".",
"The",
"future",
"watch",
"is",
"placed",
"only",
"if",
"isWatching",
"is",
"True",
"."
] | python | valid | 32.7 |
boriel/zxbasic | zxbparser.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L1939-L1945 | def p_label_list_list(p):
""" label_list : label_list COMMA ID
| label_list COMMA NUMBER
"""
p[0] = p[1]
entry = check_and_make_label(p[3], p.lineno(3))
p[1].append(entry) | [
"def",
"p_label_list_list",
"(",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"entry",
"=",
"check_and_make_label",
"(",
"p",
"[",
"3",
"]",
",",
"p",
".",
"lineno",
"(",
"3",
")",
")",
"p",
"[",
"1",
"]",
".",
"append",
"(",
... | label_list : label_list COMMA ID
| label_list COMMA NUMBER | [
"label_list",
":",
"label_list",
"COMMA",
"ID",
"|",
"label_list",
"COMMA",
"NUMBER"
] | python | train | 29.142857 |
ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_settings.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_settings.py#L175-L184 | def save(self, filename):
'''save settings to a file. Return True/False on success/failure'''
try:
f = open(filename, mode='w')
except Exception:
return False
for k in self.list():
f.write("%s=%s\n" % (k, self.get(k)))
f.close()
return ... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"mode",
"=",
"'w'",
")",
"except",
"Exception",
":",
"return",
"False",
"for",
"k",
"in",
"self",
".",
"list",
"(",
")",
":",
"f",
".",
"... | save settings to a file. Return True/False on success/failure | [
"save",
"settings",
"to",
"a",
"file",
".",
"Return",
"True",
"/",
"False",
"on",
"success",
"/",
"failure"
] | python | train | 31.5 |
Captricity/captools | captools/api/client.py | https://github.com/Captricity/captools/blob/e7dc069ff5ede95d4956c7a0a4614d0e53e5a955/captools/api/client.py#L124-L139 | def _construct_request(self):
"""
Utility for constructing the request header and connection
"""
if self.parsed_endpoint.scheme == 'https':
conn = httplib.HTTPSConnection(self.parsed_endpoint.netloc)
else:
conn = httplib.HTTPConnection(self.parsed_endpoint... | [
"def",
"_construct_request",
"(",
"self",
")",
":",
"if",
"self",
".",
"parsed_endpoint",
".",
"scheme",
"==",
"'https'",
":",
"conn",
"=",
"httplib",
".",
"HTTPSConnection",
"(",
"self",
".",
"parsed_endpoint",
".",
"netloc",
")",
"else",
":",
"conn",
"="... | Utility for constructing the request header and connection | [
"Utility",
"for",
"constructing",
"the",
"request",
"header",
"and",
"connection"
] | python | train | 37.9375 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L64-L74 | def _get_conn(self, host, port):
"""Get or create a connection to a broker using host and port"""
host_key = (host, port)
if host_key not in self.conns:
self.conns[host_key] = KafkaConnection(
host,
port,
timeout=self.timeout
... | [
"def",
"_get_conn",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"host_key",
"=",
"(",
"host",
",",
"port",
")",
"if",
"host_key",
"not",
"in",
"self",
".",
"conns",
":",
"self",
".",
"conns",
"[",
"host_key",
"]",
"=",
"KafkaConnection",
"(",
... | Get or create a connection to a broker using host and port | [
"Get",
"or",
"create",
"a",
"connection",
"to",
"a",
"broker",
"using",
"host",
"and",
"port"
] | python | train | 31.818182 |
nutechsoftware/alarmdecoder | examples/alarm_email.py | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/alarm_email.py#L37-L60 | def handle_alarm(sender, **kwargs):
"""
Handles alarm events from the AlarmDecoder.
"""
zone = kwargs.pop('zone', None)
text = "Alarm: Zone {0}".format(zone)
# Build the email message
msg = MIMEText(text)
msg['Subject'] = SUBJECT
msg['From'] = FROM_ADDRESS
msg['To'] = TO_ADDRESS... | [
"def",
"handle_alarm",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"zone",
"=",
"kwargs",
".",
"pop",
"(",
"'zone'",
",",
"None",
")",
"text",
"=",
"\"Alarm: Zone {0}\"",
".",
"format",
"(",
"zone",
")",
"# Build the email message",
"msg",
"=",
"MI... | Handles alarm events from the AlarmDecoder. | [
"Handles",
"alarm",
"events",
"from",
"the",
"AlarmDecoder",
"."
] | python | train | 23.875 |
bioasp/caspo | caspo/core/clamping.py | https://github.com/bioasp/caspo/blob/a68d1eace75b9b08f23633d1fb5ce6134403959e/caspo/core/clamping.py#L243-L268 | def combinatorics(self):
"""
Returns mutually exclusive/inclusive clampings
Returns
-------
(dict,dict)
A tuple of 2 dictionaries.
For each literal key, the first dict has as value the set of mutually exclusive clampings while
the second dict ... | [
"def",
"combinatorics",
"(",
"self",
")",
":",
"df",
"=",
"self",
".",
"to_dataframe",
"(",
")",
"literals",
"=",
"set",
"(",
"(",
"l",
"for",
"l",
"in",
"it",
".",
"chain",
".",
"from_iterable",
"(",
"self",
")",
")",
")",
"exclusive",
",",
"inclu... | Returns mutually exclusive/inclusive clampings
Returns
-------
(dict,dict)
A tuple of 2 dictionaries.
For each literal key, the first dict has as value the set of mutually exclusive clampings while
the second dict has as value the set of mutually inclusive cl... | [
"Returns",
"mutually",
"exclusive",
"/",
"inclusive",
"clampings"
] | python | train | 37.153846 |
fabioz/PyDev.Debugger | _pydevd_bundle/pydevd_comm.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L1000-L1044 | def internal_get_completions(dbg, seq, thread_id, frame_id, act_tok, line=-1, column=-1):
'''
Note that if the column is >= 0, the act_tok is considered text and the actual
activation token/qualifier is computed in this command.
'''
try:
remove_path = None
try:
qualifier ... | [
"def",
"internal_get_completions",
"(",
"dbg",
",",
"seq",
",",
"thread_id",
",",
"frame_id",
",",
"act_tok",
",",
"line",
"=",
"-",
"1",
",",
"column",
"=",
"-",
"1",
")",
":",
"try",
":",
"remove_path",
"=",
"None",
"try",
":",
"qualifier",
"=",
"u... | Note that if the column is >= 0, the act_tok is considered text and the actual
activation token/qualifier is computed in this command. | [
"Note",
"that",
"if",
"the",
"column",
"is",
">",
"=",
"0",
"the",
"act_tok",
"is",
"considered",
"text",
"and",
"the",
"actual",
"activation",
"token",
"/",
"qualifier",
"is",
"computed",
"in",
"this",
"command",
"."
] | python | train | 43.533333 |
tensorflow/mesh | mesh_tensorflow/ops.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L816-L828 | def mesh_axis_to_cumprod(self, tensor_shape):
"""For each mesh axis, give the product of previous tensor axes.
Args:
tensor_shape: Shape.
Returns:
list with length self.ndims where each element is an integer or None.
"""
tensor_layout = self.tensor_layout(tensor_shape)
ma2ta = tens... | [
"def",
"mesh_axis_to_cumprod",
"(",
"self",
",",
"tensor_shape",
")",
":",
"tensor_layout",
"=",
"self",
".",
"tensor_layout",
"(",
"tensor_shape",
")",
"ma2ta",
"=",
"tensor_layout",
".",
"mesh_axis_to_tensor_axis",
"(",
"self",
".",
"ndims",
")",
"ta2cumprod",
... | For each mesh axis, give the product of previous tensor axes.
Args:
tensor_shape: Shape.
Returns:
list with length self.ndims where each element is an integer or None. | [
"For",
"each",
"mesh",
"axis",
"give",
"the",
"product",
"of",
"previous",
"tensor",
"axes",
"."
] | python | train | 35.384615 |
elastic/elasticsearch-py | elasticsearch/client/cat.py | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/cat.py#L111-L137 | def indices(self, index=None, params=None):
"""
The indices command provides a cross-section of each index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html>`_
:arg index: A comma-separated list of index names to limit the returned
informati... | [
"def",
"indices",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"'GET'",
",",
"_make_path",
"(",
"'_cat'",
",",
"'indices'",
",",
"index",
")",
",",
"param... | The indices command provides a cross-section of each index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values,... | [
"The",
"indices",
"command",
"provides",
"a",
"cross",
"-",
"section",
"of",
"each",
"index",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"cat",
"-",
... | python | train | 52.555556 |
ninuxorg/nodeshot | nodeshot/core/base/managers.py | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/base/managers.py#L45-L54 | def access_level_up_to(self, access_level):
""" returns all items that have an access level equal or lower than the one specified """
# if access_level is number
if isinstance(access_level, int):
value = access_level
# else if is string get the numeric value
else:
... | [
"def",
"access_level_up_to",
"(",
"self",
",",
"access_level",
")",
":",
"# if access_level is number",
"if",
"isinstance",
"(",
"access_level",
",",
"int",
")",
":",
"value",
"=",
"access_level",
"# else if is string get the numeric value",
"else",
":",
"value",
"=",... | returns all items that have an access level equal or lower than the one specified | [
"returns",
"all",
"items",
"that",
"have",
"an",
"access",
"level",
"equal",
"or",
"lower",
"than",
"the",
"one",
"specified"
] | python | train | 43.7 |
ahopkins/sanic-jwt | sanic_jwt/initialization.py | https://github.com/ahopkins/sanic-jwt/blob/fca7750499c8cedde823d778512f613777fb5282/sanic_jwt/initialization.py#L164-L186 | def __add_class_views(self):
"""
Include any custom class views on the Sanic JWT Blueprint
"""
config = self.config
if "class_views" in self.kwargs:
class_views = self.kwargs.pop("class_views")
for route, view in class_views:
if issubclass... | [
"def",
"__add_class_views",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"config",
"if",
"\"class_views\"",
"in",
"self",
".",
"kwargs",
":",
"class_views",
"=",
"self",
".",
"kwargs",
".",
"pop",
"(",
"\"class_views\"",
")",
"for",
"route",
",",
"... | Include any custom class views on the Sanic JWT Blueprint | [
"Include",
"any",
"custom",
"class",
"views",
"on",
"the",
"Sanic",
"JWT",
"Blueprint"
] | python | train | 36.695652 |
tensorflow/tensor2tensor | tensor2tensor/layers/transformer_memory.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L339-L371 | def pre_attention(self, segment_number, query_antecedent,
memory_antecedent, bias):
"""Called prior to self-attention, to incorporate memory items.
Args:
segment_number: an integer Tensor with shape [batch]
query_antecedent: a Tensor with shape [batch, length_q, channels]
... | [
"def",
"pre_attention",
"(",
"self",
",",
"segment_number",
",",
"query_antecedent",
",",
"memory_antecedent",
",",
"bias",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"self",
".",
"name",
"+",
"\"/pre_attention\"",
",",
"reuse",
"=",
"tf",
".",
"AUT... | Called prior to self-attention, to incorporate memory items.
Args:
segment_number: an integer Tensor with shape [batch]
query_antecedent: a Tensor with shape [batch, length_q, channels]
memory_antecedent: must be None. Attention normally allows this to be a
Tensor with shape [batch, lengt... | [
"Called",
"prior",
"to",
"self",
"-",
"attention",
"to",
"incorporate",
"memory",
"items",
"."
] | python | train | 50.575758 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.