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 |
|---|---|---|---|---|---|---|---|---|---|
pepkit/peppy | peppy/utils.py | https://github.com/pepkit/peppy/blob/f0f725e1557936b81c86573a77400e6f8da78f05/peppy/utils.py#L508-L521 | def _store_status(self, section, command, name):
"""
Based on new command execution attempt, update instance's
data structures with information about the success/fail status.
Return the result of the execution test.
"""
succeeded = is_command_callable(command, name)
... | [
"def",
"_store_status",
"(",
"self",
",",
"section",
",",
"command",
",",
"name",
")",
":",
"succeeded",
"=",
"is_command_callable",
"(",
"command",
",",
"name",
")",
"# Store status regardless of its value in the instance's largest DS.",
"self",
".",
"section_to_status... | Based on new command execution attempt, update instance's
data structures with information about the success/fail status.
Return the result of the execution test. | [
"Based",
"on",
"new",
"command",
"execution",
"attempt",
"update",
"instance",
"s",
"data",
"structures",
"with",
"information",
"about",
"the",
"success",
"/",
"fail",
"status",
".",
"Return",
"the",
"result",
"of",
"the",
"execution",
"test",
"."
] | python | train | 48.214286 |
redcanari/canari3 | src/canari/entrypoints.py | https://github.com/redcanari/canari3/blob/322d2bae4b49ac728229f418b786b51fcc227352/src/canari/entrypoints.py#L105-L108 | def debug_transform(ctx, transform, params, value, fields):
"""Runs Canari local transforms in a terminal-friendly fashion."""
from canari.commands.debug_transform import debug_transform
debug_transform(transform, value, fields, params, ctx.project, ctx.config) | [
"def",
"debug_transform",
"(",
"ctx",
",",
"transform",
",",
"params",
",",
"value",
",",
"fields",
")",
":",
"from",
"canari",
".",
"commands",
".",
"debug_transform",
"import",
"debug_transform",
"debug_transform",
"(",
"transform",
",",
"value",
",",
"field... | Runs Canari local transforms in a terminal-friendly fashion. | [
"Runs",
"Canari",
"local",
"transforms",
"in",
"a",
"terminal",
"-",
"friendly",
"fashion",
"."
] | python | train | 67.5 |
rq/django-rq | django_rq/workers.py | https://github.com/rq/django-rq/blob/f50097dfe44351bd2a2d9d40edb19150dfc6a168/django_rq/workers.py#L23-L38 | def get_worker_class(worker_class=None):
"""
Return worker class from RQ settings, otherwise return Worker.
If `worker_class` is not None, it is used as an override (can be
python import path as string).
"""
RQ = getattr(settings, 'RQ', {})
if worker_class is None:
worker_class = Wo... | [
"def",
"get_worker_class",
"(",
"worker_class",
"=",
"None",
")",
":",
"RQ",
"=",
"getattr",
"(",
"settings",
",",
"'RQ'",
",",
"{",
"}",
")",
"if",
"worker_class",
"is",
"None",
":",
"worker_class",
"=",
"Worker",
"if",
"'WORKER_CLASS'",
"in",
"RQ",
":"... | Return worker class from RQ settings, otherwise return Worker.
If `worker_class` is not None, it is used as an override (can be
python import path as string). | [
"Return",
"worker",
"class",
"from",
"RQ",
"settings",
"otherwise",
"return",
"Worker",
".",
"If",
"worker_class",
"is",
"not",
"None",
"it",
"is",
"used",
"as",
"an",
"override",
"(",
"can",
"be",
"python",
"import",
"path",
"as",
"string",
")",
"."
] | python | train | 32.625 |
pandas-dev/pandas | pandas/core/indexes/base.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L3968-L3979 | def _can_hold_identifiers_and_holds_name(self, name):
"""
Faster check for ``name in self`` when we know `name` is a Python
identifier (e.g. in NDFrame.__getattr__, which hits this to support
. key lookup). For indexes that can't hold identifiers (everything
but object & categori... | [
"def",
"_can_hold_identifiers_and_holds_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"is_object",
"(",
")",
"or",
"self",
".",
"is_categorical",
"(",
")",
":",
"return",
"name",
"in",
"self",
"return",
"False"
] | Faster check for ``name in self`` when we know `name` is a Python
identifier (e.g. in NDFrame.__getattr__, which hits this to support
. key lookup). For indexes that can't hold identifiers (everything
but object & categorical) we just return False.
https://github.com/pandas-dev/pandas/i... | [
"Faster",
"check",
"for",
"name",
"in",
"self",
"when",
"we",
"know",
"name",
"is",
"a",
"Python",
"identifier",
"(",
"e",
".",
"g",
".",
"in",
"NDFrame",
".",
"__getattr__",
"which",
"hits",
"this",
"to",
"support",
".",
"key",
"lookup",
")",
".",
"... | python | train | 42.75 |
chriskiehl/Gooey | gooey/gui/seeder.py | https://github.com/chriskiehl/Gooey/blob/e598573c6519b953e0ccfc1f3663f827f8cd7e22/gooey/gui/seeder.py#L9-L21 | def fetchDynamicProperties(target, encoding):
"""
Sends a gooey-seed-ui request to the client program it retrieve
dynamically generated defaults with which to seed the UI
"""
cmd = '{} {}'.format(target, 'gooey-seed-ui --ignore-gooey')
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, s... | [
"def",
"fetchDynamicProperties",
"(",
"target",
",",
"encoding",
")",
":",
"cmd",
"=",
"'{} {}'",
".",
"format",
"(",
"target",
",",
"'gooey-seed-ui --ignore-gooey'",
")",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
... | Sends a gooey-seed-ui request to the client program it retrieve
dynamically generated defaults with which to seed the UI | [
"Sends",
"a",
"gooey",
"-",
"seed",
"-",
"ui",
"request",
"to",
"the",
"client",
"program",
"it",
"retrieve",
"dynamically",
"generated",
"defaults",
"with",
"which",
"to",
"seed",
"the",
"UI"
] | python | train | 39.153846 |
bitprophet/ssh | ssh/sftp_client.py | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L376-L391 | def chmod(self, path, mode):
"""
Change the mode (permissions) of a file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param path: path of the file to change the permissions of
@type path: str
@param mode: new per... | [
"def",
"chmod",
"(",
"self",
",",
"path",
",",
"mode",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'chmod(%r, %r)'",
"%",
"(",
"path",
",",
"mode",
")",
")",
"attr",
"=",
"SFTPAttrib... | Change the mode (permissions) of a file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param path: path of the file to change the permissions of
@type path: str
@param mode: new permissions
@type mode: int | [
"Change",
"the",
"mode",
"(",
"permissions",
")",
"of",
"a",
"file",
".",
"The",
"permissions",
"are",
"unix",
"-",
"style",
"and",
"identical",
"to",
"those",
"used",
"by",
"python",
"s",
"C",
"{",
"os",
".",
"chmod",
"}",
"function",
"."
] | python | train | 34.4375 |
cknoll/ipydex | ipydex/core.py | https://github.com/cknoll/ipydex/blob/ca528ce4c97ee934e48efbd5983c1b7cd88bec9d/ipydex/core.py#L728-L794 | def get_whole_assignment_expression(line, varname, seq_type):
"""
Example:
line = "x = Container(cargs=(a, b, c))"
varname = cargs
delimiter pair = "()"
return "a, b, c"
:return:
"""
tokens = list(tk.generate_tokens(io.StringIO(line).readline))
if issubclass(seq_type, tuple)... | [
"def",
"get_whole_assignment_expression",
"(",
"line",
",",
"varname",
",",
"seq_type",
")",
":",
"tokens",
"=",
"list",
"(",
"tk",
".",
"generate_tokens",
"(",
"io",
".",
"StringIO",
"(",
"line",
")",
".",
"readline",
")",
")",
"if",
"issubclass",
"(",
... | Example:
line = "x = Container(cargs=(a, b, c))"
varname = cargs
delimiter pair = "()"
return "a, b, c"
:return: | [
"Example",
":"
] | python | train | 24.119403 |
graphql-python/graphql-core | graphql/backend/decider.py | https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/backend/decider.py#L121-L130 | def stop(self, timeout=None):
"""
Stops the task thread. Synchronous!
"""
with self._lock:
if self._thread:
self._queue.put_nowait(self._terminator)
self._thread.join(timeout=timeout)
self._thread = None
self._th... | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_thread",
":",
"self",
".",
"_queue",
".",
"put_nowait",
"(",
"self",
".",
"_terminator",
")",
"self",
".",
"_thread",
".",
"j... | Stops the task thread. Synchronous! | [
"Stops",
"the",
"task",
"thread",
".",
"Synchronous!"
] | python | train | 33 |
pytorch/vision | torchvision/transforms/functional.py | https://github.com/pytorch/vision/blob/3afcf3cd49661c466c75ea536b0b2a7ff57f9a05/torchvision/transforms/functional.py#L97-L181 | def to_pil_image(pic, mode=None):
"""Convert a tensor or an ndarray to PIL Image.
See :class:`~torchvision.transforms.ToPILImage` for more details.
Args:
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
mode (`PIL.Image mode`_): color space and pixel depth of input data (... | [
"def",
"to_pil_image",
"(",
"pic",
",",
"mode",
"=",
"None",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"pic",
",",
"torch",
".",
"Tensor",
")",
"or",
"isinstance",
"(",
"pic",
",",
"np",
".",
"ndarray",
")",
")",
":",
"raise",
"TypeError",
"("... | Convert a tensor or an ndarray to PIL Image.
See :class:`~torchvision.transforms.ToPILImage` for more details.
Args:
pic (Tensor or numpy.ndarray): Image to be converted to PIL Image.
mode (`PIL.Image mode`_): color space and pixel depth of input data (optional).
.. _PIL.Image mode: https... | [
"Convert",
"a",
"tensor",
"or",
"an",
"ndarray",
"to",
"PIL",
"Image",
"."
] | python | test | 39.164706 |
KeplerGO/K2fov | K2fov/c9.py | https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/c9.py#L69-L94 | def pixelInMicrolensRegion(ch, col, row):
"""Returns `True` if the given pixel falls inside the K2C9 superstamp.
The superstamp is used for microlensing experiment and is an almost
contiguous area of 2.8e6 pixels.
"""
# First try the superstamp
try:
vertices_col = SUPERSTAMP["channels"]... | [
"def",
"pixelInMicrolensRegion",
"(",
"ch",
",",
"col",
",",
"row",
")",
":",
"# First try the superstamp",
"try",
":",
"vertices_col",
"=",
"SUPERSTAMP",
"[",
"\"channels\"",
"]",
"[",
"str",
"(",
"int",
"(",
"ch",
")",
")",
"]",
"[",
"\"vertices_col\"",
... | Returns `True` if the given pixel falls inside the K2C9 superstamp.
The superstamp is used for microlensing experiment and is an almost
contiguous area of 2.8e6 pixels. | [
"Returns",
"True",
"if",
"the",
"given",
"pixel",
"falls",
"inside",
"the",
"K2C9",
"superstamp",
"."
] | python | train | 39.846154 |
redhat-cip/dci-control-server | dci/stores/files_utils.py | https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/stores/files_utils.py#L24-L41 | def get_stream_or_content_from_request(request):
"""Ensure the proper content is uploaded.
Stream might be already consumed by authentication process.
Hence flask.request.stream might not be readable and return improper value.
This methods checks if the stream has already been consumed and if so
r... | [
"def",
"get_stream_or_content_from_request",
"(",
"request",
")",
":",
"if",
"request",
".",
"stream",
".",
"tell",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Request stream already consumed. '",
"'Storing file content using in-memory data.'",
")",
"return",
"request"... | Ensure the proper content is uploaded.
Stream might be already consumed by authentication process.
Hence flask.request.stream might not be readable and return improper value.
This methods checks if the stream has already been consumed and if so
retrieve the data from flask.request.data where it has be... | [
"Ensure",
"the",
"proper",
"content",
"is",
"uploaded",
"."
] | python | train | 36.944444 |
quantopian/trading_calendars | trading_calendars/trading_calendar.py | https://github.com/quantopian/trading_calendars/blob/951711c82c8a2875c09e96e2979faaf8734fb4df/trading_calendars/trading_calendar.py#L807-L822 | def all_minutes(self):
"""
Returns a DatetimeIndex representing all the minutes in this calendar.
"""
opens_in_ns = self._opens.values.astype(
'datetime64[ns]',
).view('int64')
closes_in_ns = self._closes.values.astype(
'datetime64[ns]',
)... | [
"def",
"all_minutes",
"(",
"self",
")",
":",
"opens_in_ns",
"=",
"self",
".",
"_opens",
".",
"values",
".",
"astype",
"(",
"'datetime64[ns]'",
",",
")",
".",
"view",
"(",
"'int64'",
")",
"closes_in_ns",
"=",
"self",
".",
"_closes",
".",
"values",
".",
... | Returns a DatetimeIndex representing all the minutes in this calendar. | [
"Returns",
"a",
"DatetimeIndex",
"representing",
"all",
"the",
"minutes",
"in",
"this",
"calendar",
"."
] | python | train | 27.5 |
minio/minio-py | minio/parsers.py | https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/parsers.py#L80-L87 | def findall(self, name):
"""Similar to ElementTree.Element.findall()
"""
return [
S3Element(self.root_name, elem)
for elem in self.element.findall('s3:{}'.format(name), _S3_NS)
] | [
"def",
"findall",
"(",
"self",
",",
"name",
")",
":",
"return",
"[",
"S3Element",
"(",
"self",
".",
"root_name",
",",
"elem",
")",
"for",
"elem",
"in",
"self",
".",
"element",
".",
"findall",
"(",
"'s3:{}'",
".",
"format",
"(",
"name",
")",
",",
"_... | Similar to ElementTree.Element.findall() | [
"Similar",
"to",
"ElementTree",
".",
"Element",
".",
"findall",
"()"
] | python | train | 28.5 |
odlgroup/odl | odl/trafos/backends/pywt_bindings.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/trafos/backends/pywt_bindings.py#L54-L83 | def pywt_pad_mode(pad_mode, pad_const=0):
"""Convert ODL-style padding mode to pywt-style padding mode.
Parameters
----------
pad_mode : str
The ODL padding mode to use at the boundaries.
pad_const : float, optional
Value to use outside the signal boundaries when ``pad_mode`` is
... | [
"def",
"pywt_pad_mode",
"(",
"pad_mode",
",",
"pad_const",
"=",
"0",
")",
":",
"pad_mode",
"=",
"str",
"(",
"pad_mode",
")",
".",
"lower",
"(",
")",
"if",
"pad_mode",
"==",
"'constant'",
"and",
"pad_const",
"!=",
"0.0",
":",
"raise",
"ValueError",
"(",
... | Convert ODL-style padding mode to pywt-style padding mode.
Parameters
----------
pad_mode : str
The ODL padding mode to use at the boundaries.
pad_const : float, optional
Value to use outside the signal boundaries when ``pad_mode`` is
'constant'. Only a value of 0. is supported ... | [
"Convert",
"ODL",
"-",
"style",
"padding",
"mode",
"to",
"pywt",
"-",
"style",
"padding",
"mode",
"."
] | python | train | 34.533333 |
NYUCCL/psiTurk | psiturk/psiturk_shell.py | https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/psiturk_shell.py#L1055-L1058 | def complete_worker(self, text, line, begidx, endidx):
''' Tab-complete worker command. '''
return [i for i in PsiturkNetworkShell.worker_commands if \
i.startswith(text)] | [
"def",
"complete_worker",
"(",
"self",
",",
"text",
",",
"line",
",",
"begidx",
",",
"endidx",
")",
":",
"return",
"[",
"i",
"for",
"i",
"in",
"PsiturkNetworkShell",
".",
"worker_commands",
"if",
"i",
".",
"startswith",
"(",
"text",
")",
"]"
] | Tab-complete worker command. | [
"Tab",
"-",
"complete",
"worker",
"command",
"."
] | python | train | 50.5 |
fred49/linshare-api | linshareapi/user/threadentries.py | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L141-L155 | def get(self, wg_uuid, uuid, tree=False):
""" Get one workgroup member."""
url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % {
'base': self.local_base_url,
'wg_uuid': wg_uuid,
'uuid': uuid
}
param = {}
if tree:
param['tree'] = True
... | [
"def",
"get",
"(",
"self",
",",
"wg_uuid",
",",
"uuid",
",",
"tree",
"=",
"False",
")",
":",
"url",
"=",
"\"%(base)s/%(wg_uuid)s/nodes/%(uuid)s\"",
"%",
"{",
"'base'",
":",
"self",
".",
"local_base_url",
",",
"'wg_uuid'",
":",
"wg_uuid",
",",
"'uuid'",
":"... | Get one workgroup member. | [
"Get",
"one",
"workgroup",
"member",
"."
] | python | train | 29.6 |
AtomHash/evernode | evernode/scripts/sendemail.py | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/scripts/sendemail.py#L109-L117 | def send(self, email=None):
""" send email message """
if email is None and self.send_as_one:
self.smtp.send_message(
self.multipart, self.config['EMAIL'], self.addresses)
elif email is not None and self.send_as_one is False:
self.smtp.send_message(
... | [
"def",
"send",
"(",
"self",
",",
"email",
"=",
"None",
")",
":",
"if",
"email",
"is",
"None",
"and",
"self",
".",
"send_as_one",
":",
"self",
".",
"smtp",
".",
"send_message",
"(",
"self",
".",
"multipart",
",",
"self",
".",
"config",
"[",
"'EMAIL'",... | send email message | [
"send",
"email",
"message"
] | python | train | 47.555556 |
hollenstein/maspy | maspy/core.py | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/core.py#L1423-L1437 | def getValidItem(self, specfile, identifier):
"""Returns a ``Sii`` instance from ``self.container`` if it is valid,
if all elements of ``self.container[specfile][identifier] are
``Sii.isValid == False`` then ``None`` is returned.
:param specfile: a ms-run file name
:param identi... | [
"def",
"getValidItem",
"(",
"self",
",",
"specfile",
",",
"identifier",
")",
":",
"for",
"item",
"in",
"self",
".",
"container",
"[",
"specfile",
"]",
"[",
"identifier",
"]",
":",
"if",
"item",
".",
"isValid",
":",
"return",
"item",
"else",
":",
"retur... | Returns a ``Sii`` instance from ``self.container`` if it is valid,
if all elements of ``self.container[specfile][identifier] are
``Sii.isValid == False`` then ``None`` is returned.
:param specfile: a ms-run file name
:param identifier: item identifier ``Sii.id``
:returns: ``Sii... | [
"Returns",
"a",
"Sii",
"instance",
"from",
"self",
".",
"container",
"if",
"it",
"is",
"valid",
"if",
"all",
"elements",
"of",
"self",
".",
"container",
"[",
"specfile",
"]",
"[",
"identifier",
"]",
"are",
"Sii",
".",
"isValid",
"==",
"False",
"then",
... | python | train | 36.133333 |
thebigmunch/google-music | src/google_music/clients/mobileclient.py | https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L552-L564 | def playlist_song_delete(self, playlist_song):
"""Delete song from playlist.
Parameters:
playlist_song (str): A playlist song dict.
Returns:
dict: Playlist dict including songs.
"""
self.playlist_songs_delete([playlist_song])
return self.playlist(playlist_song['playlistId'], include_songs=True) | [
"def",
"playlist_song_delete",
"(",
"self",
",",
"playlist_song",
")",
":",
"self",
".",
"playlist_songs_delete",
"(",
"[",
"playlist_song",
"]",
")",
"return",
"self",
".",
"playlist",
"(",
"playlist_song",
"[",
"'playlistId'",
"]",
",",
"include_songs",
"=",
... | Delete song from playlist.
Parameters:
playlist_song (str): A playlist song dict.
Returns:
dict: Playlist dict including songs. | [
"Delete",
"song",
"from",
"playlist",
"."
] | python | train | 23.461538 |
nameko/nameko | nameko/exceptions.py | https://github.com/nameko/nameko/blob/88d7e5211de4fcc1c34cd7f84d7c77f0619c5f5d/nameko/exceptions.py#L97-L112 | def deserialize(data):
""" Deserialize `data` to an exception instance.
If the `exc_path` value matches an exception registered as
``deserializable``, return an instance of that exception type.
Otherwise, return a `RemoteError` instance describing the exception
that occurred.
"""
key = data... | [
"def",
"deserialize",
"(",
"data",
")",
":",
"key",
"=",
"data",
".",
"get",
"(",
"'exc_path'",
")",
"if",
"key",
"in",
"registry",
":",
"exc_args",
"=",
"data",
".",
"get",
"(",
"'exc_args'",
",",
"(",
")",
")",
"return",
"registry",
"[",
"key",
"... | Deserialize `data` to an exception instance.
If the `exc_path` value matches an exception registered as
``deserializable``, return an instance of that exception type.
Otherwise, return a `RemoteError` instance describing the exception
that occurred. | [
"Deserialize",
"data",
"to",
"an",
"exception",
"instance",
"."
] | python | train | 34.4375 |
radjkarl/imgProcessor | imgProcessor/generate/patterns.py | https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/generate/patterns.py#L83-L107 | def patSiemensStar(s0, n=72, vhigh=255, vlow=0, antiasing=False):
'''make line pattern'''
arr = np.full((s0,s0),vlow, dtype=np.uint8)
c = int(round(s0/2.))
s = 2*np.pi/(2*n)
step = 0
for i in range(2*n):
p0 = round(c+np.sin(step)*2*s0)
p1 = round(c+np.cos(step)*2*s0)
... | [
"def",
"patSiemensStar",
"(",
"s0",
",",
"n",
"=",
"72",
",",
"vhigh",
"=",
"255",
",",
"vlow",
"=",
"0",
",",
"antiasing",
"=",
"False",
")",
":",
"arr",
"=",
"np",
".",
"full",
"(",
"(",
"s0",
",",
"s0",
")",
",",
"vlow",
",",
"dtype",
"=",... | make line pattern | [
"make",
"line",
"pattern"
] | python | train | 29.72 |
mikicz/arca | arca/backend/docker.py | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/backend/docker.py#L732-L739 | def get_container_name(self, repo: str, branch: str, git_repo: Repo):
""" Returns the name of the container used for the repo.
"""
return "arca_{}_{}_{}".format(
self._arca.repo_id(repo),
branch,
self._arca.current_git_hash(repo, branch, git_repo, short=True)
... | [
"def",
"get_container_name",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"git_repo",
":",
"Repo",
")",
":",
"return",
"\"arca_{}_{}_{}\"",
".",
"format",
"(",
"self",
".",
"_arca",
".",
"repo_id",
"(",
"repo",
")",
",",
"branc... | Returns the name of the container used for the repo. | [
"Returns",
"the",
"name",
"of",
"the",
"container",
"used",
"for",
"the",
"repo",
"."
] | python | train | 40.25 |
yohell/python-tui | tui/__init__.py | https://github.com/yohell/python-tui/blob/de2e678e2f00e5940de52c000214dbcb8812a222/tui/__init__.py#L1365-L1390 | def format_usage(self, usage=None):
"""Return a formatted usage string.
If usage is None, use self.docs['usage'], and if that is also None,
generate one.
"""
if usage is None:
usage = self.docs['usage']
if usage is not None:
return usage... | [
"def",
"format_usage",
"(",
"self",
",",
"usage",
"=",
"None",
")",
":",
"if",
"usage",
"is",
"None",
":",
"usage",
"=",
"self",
".",
"docs",
"[",
"'usage'",
"]",
"if",
"usage",
"is",
"not",
"None",
":",
"return",
"usage",
"[",
"0",
"]",
"%",
"se... | Return a formatted usage string.
If usage is None, use self.docs['usage'], and if that is also None,
generate one. | [
"Return",
"a",
"formatted",
"usage",
"string",
".",
"If",
"usage",
"is",
"None",
"use",
"self",
".",
"docs",
"[",
"usage",
"]",
"and",
"if",
"that",
"is",
"also",
"None",
"generate",
"one",
"."
] | python | valid | 34.538462 |
ltalirz/aiida-phtools | aiida_phtools/data/data_cli.py | https://github.com/ltalirz/aiida-phtools/blob/acec3339425fe92d3f55e725a199123de9a1febc/aiida_phtools/data/data_cli.py#L15-L34 | def list_(): # pylint: disable=redefined-builtin
"""
Display all MultiplyParameters nodes
"""
load_dbenv_if_not_loaded(
) # Important to load the dbenv in the last moment
from aiida.orm.querybuilder import QueryBuilder
from aiida.orm import DataFactory
MultiplyParameters = DataFactory... | [
"def",
"list_",
"(",
")",
":",
"# pylint: disable=redefined-builtin",
"load_dbenv_if_not_loaded",
"(",
")",
"# Important to load the dbenv in the last moment",
"from",
"aiida",
".",
"orm",
".",
"querybuilder",
"import",
"QueryBuilder",
"from",
"aiida",
".",
"orm",
"import... | Display all MultiplyParameters nodes | [
"Display",
"all",
"MultiplyParameters",
"nodes"
] | python | train | 27.1 |
maweigert/gputools | gputools/denoise/bilateral3.py | https://github.com/maweigert/gputools/blob/6ab26efeb05dceef74cf13aadeeeb9b009b529dd/gputools/denoise/bilateral3.py#L17-L44 | def bilateral3(data, size_filter, sigma_p, sigma_x = 10.):
"""bilateral filter """
dtype = data.dtype.type
dtypes_kernels = {np.float32:"bilat3_float",}
if not dtype in dtypes_kernels:
logger.info("data type %s not supported yet (%s), casting to float:"%(dtype,list(dtypes_kernels.keys())))
... | [
"def",
"bilateral3",
"(",
"data",
",",
"size_filter",
",",
"sigma_p",
",",
"sigma_x",
"=",
"10.",
")",
":",
"dtype",
"=",
"data",
".",
"dtype",
".",
"type",
"dtypes_kernels",
"=",
"{",
"np",
".",
"float32",
":",
"\"bilat3_float\"",
",",
"}",
"if",
"not... | bilateral filter | [
"bilateral",
"filter"
] | python | train | 30.321429 |
gmr/tredis | tredis/strings.py | https://github.com/gmr/tredis/blob/2e91c6a58a35460be0525c51ac6a98fde3b506ad/tredis/strings.py#L638-L678 | def setrange(self, key, offset, value):
"""Overwrites part of the string stored at key, starting at the
specified offset, for the entire length of value. If the offset is
larger than the current length of the string at key, the string is
padded with zero-bytes to make offset fit. Non-exi... | [
"def",
"setrange",
"(",
"self",
",",
"key",
",",
"offset",
",",
"value",
")",
":",
"return",
"self",
".",
"_execute",
"(",
"[",
"b'SETRANGE'",
",",
"key",
",",
"ascii",
"(",
"offset",
")",
",",
"value",
"]",
")"
] | Overwrites part of the string stored at key, starting at the
specified offset, for the entire length of value. If the offset is
larger than the current length of the string at key, the string is
padded with zero-bytes to make offset fit. Non-existing keys are
considered as empty strings,... | [
"Overwrites",
"part",
"of",
"the",
"string",
"stored",
"at",
"key",
"starting",
"at",
"the",
"specified",
"offset",
"for",
"the",
"entire",
"length",
"of",
"value",
".",
"If",
"the",
"offset",
"is",
"larger",
"than",
"the",
"current",
"length",
"of",
"the"... | python | train | 54.02439 |
saltstack/salt | salt/states/openvswitch_db.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/openvswitch_db.py#L17-L69 | def managed(name, table, data, record=None):
'''
Ensures that the specified columns of the named record have the specified
values.
Args:
name: The name of the record.
table: The name of the table to which the record belongs.
data: Dictionary containing a mapping from column name... | [
"def",
"managed",
"(",
"name",
",",
"table",
",",
"data",
",",
"record",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"if",
"recor... | Ensures that the specified columns of the named record have the specified
values.
Args:
name: The name of the record.
table: The name of the table to which the record belongs.
data: Dictionary containing a mapping from column names to the desired
values. Columns that exist, ... | [
"Ensures",
"that",
"the",
"specified",
"columns",
"of",
"the",
"named",
"record",
"have",
"the",
"specified",
"values",
"."
] | python | train | 37.943396 |
Autodesk/pyccc | pyccc/backports.py | https://github.com/Autodesk/pyccc/blob/011698e78d49a83ac332e0578a4a2a865b75ef8d/pyccc/backports.py#L154-L216 | def getclosurevars(func):
"""
Get the mapping of free variables to their current values.
Returns a named tuple of dicts mapping the current nonlocal, global
and builtin references as seen by the body of the function. A final
set of unbound names that could not be resolved is also provided.
Not... | [
"def",
"getclosurevars",
"(",
"func",
")",
":",
"if",
"inspect",
".",
"ismethod",
"(",
"func",
")",
":",
"func",
"=",
"func",
".",
"__func__",
"elif",
"not",
"inspect",
".",
"isroutine",
"(",
"func",
")",
":",
"raise",
"TypeError",
"(",
"\"'{!r}' is not ... | Get the mapping of free variables to their current values.
Returns a named tuple of dicts mapping the current nonlocal, global
and builtin references as seen by the body of the function. A final
set of unbound names that could not be resolved is also provided.
Note:
Modified function from the ... | [
"Get",
"the",
"mapping",
"of",
"free",
"variables",
"to",
"their",
"current",
"values",
"."
] | python | train | 36.412698 |
acrazing/dbapi | dbapi/Group.py | https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/Group.py#L463-L479 | def remove_comment(self, topic_id, comment_id, reason='0', other=None):
"""
删除评论(自己发的话题所有的都可以删除,否则只能删自己发的)
:param topic_id: 话题ID
:param comment_id: 评论ID
:param reason: 原因 0/1/2 (内容不符/反动/其它)
:param other: 其它原因的具体(2)
:return: None
"""
params... | [
"def",
"remove_comment",
"(",
"self",
",",
"topic_id",
",",
"comment_id",
",",
"reason",
"=",
"'0'",
",",
"other",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'cid'",
":",
"comment_id",
"}",
"data",
"=",
"{",
"'cid'",
":",
"comment_id",
",",
"'ck'",
... | 删除评论(自己发的话题所有的都可以删除,否则只能删自己发的)
:param topic_id: 话题ID
:param comment_id: 评论ID
:param reason: 原因 0/1/2 (内容不符/反动/其它)
:param other: 其它原因的具体(2)
:return: None | [
"删除评论(自己发的话题所有的都可以删除,否则只能删自己发的)",
":",
"param",
"topic_id",
":",
"话题ID",
":",
"param",
"comment_id",
":",
"评论ID",
":",
"param",
"reason",
":",
"原因",
"0",
"/",
"1",
"/",
"2",
"(内容不符",
"/",
"反动",
"/",
"其它)",
":",
"param",
"other",
":",
"其它原因的具体",
"(",
"2... | python | train | 43.882353 |
arne-cl/discoursegraphs | src/discoursegraphs/statistics.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/statistics.py#L22-L25 | def print_most_common(counter, number=5, tab=1):
"""print the most common elements of a counter"""
for key, count in counter.most_common(number):
print "{0}{1} - {2}".format('\t'*tab, key, count) | [
"def",
"print_most_common",
"(",
"counter",
",",
"number",
"=",
"5",
",",
"tab",
"=",
"1",
")",
":",
"for",
"key",
",",
"count",
"in",
"counter",
".",
"most_common",
"(",
"number",
")",
":",
"print",
"\"{0}{1} - {2}\"",
".",
"format",
"(",
"'\\t'",
"*"... | print the most common elements of a counter | [
"print",
"the",
"most",
"common",
"elements",
"of",
"a",
"counter"
] | python | train | 52 |
NiklasRosenstein/myo-python | myo/math.py | https://github.com/NiklasRosenstein/myo-python/blob/89a7480f8058061da7a3dd98ccec57a6b134ddf3/myo/math.py#L236-L240 | def pitch(self):
""" Calculates the Pitch of the Quaternion. """
x, y, z, w = self.x, self.y, self.z, self.w
return math.atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z) | [
"def",
"pitch",
"(",
"self",
")",
":",
"x",
",",
"y",
",",
"z",
",",
"w",
"=",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"z",
",",
"self",
".",
"w",
"return",
"math",
".",
"atan2",
"(",
"2",
"*",
"x",
"*",
"w",
"-",
"2"... | Calculates the Pitch of the Quaternion. | [
"Calculates",
"the",
"Pitch",
"of",
"the",
"Quaternion",
"."
] | python | train | 33.8 |
googlefonts/fontbakery | Lib/fontbakery/profiles/googlefonts.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L2868-L2888 | def com_google_fonts_check_name_mandatory_entries(ttFont, style):
"""Font has all mandatory 'name' table entries ?"""
from fontbakery.utils import get_name_entry_strings
from fontbakery.constants import RIBBI_STYLE_NAMES
required_nameIDs = [NameID.FONT_FAMILY_NAME,
NameID.FONT_SUBFAMILY_N... | [
"def",
"com_google_fonts_check_name_mandatory_entries",
"(",
"ttFont",
",",
"style",
")",
":",
"from",
"fontbakery",
".",
"utils",
"import",
"get_name_entry_strings",
"from",
"fontbakery",
".",
"constants",
"import",
"RIBBI_STYLE_NAMES",
"required_nameIDs",
"=",
"[",
"N... | Font has all mandatory 'name' table entries ? | [
"Font",
"has",
"all",
"mandatory",
"name",
"table",
"entries",
"?"
] | python | train | 44.142857 |
saltstack/salt | salt/modules/boto_ec2.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_ec2.py#L540-L552 | def get_zones(region=None, key=None, keyid=None, profile=None):
'''
Get a list of AZs for the configured region.
CLI Example:
.. code-block:: bash
salt myminion boto_ec2.get_zones
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
return [z.name for z in c... | [
"def",
"get_zones",
"(",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"key",
",",
"keyid",
"=",
"keyid",
... | Get a list of AZs for the configured region.
CLI Example:
.. code-block:: bash
salt myminion boto_ec2.get_zones | [
"Get",
"a",
"list",
"of",
"AZs",
"for",
"the",
"configured",
"region",
"."
] | python | train | 25.230769 |
ASMfreaK/habitipy | habitipy/util.py | https://github.com/ASMfreaK/habitipy/blob/555b8b20faf6d553353092614a8a0d612f0adbde/habitipy/util.py#L144-L151 | def assert_secure_file(file):
"""checks if a file is stored securely"""
if not is_secure_file(file):
msg = """
File {0} can be read by other users.
This is not secure. Please run 'chmod 600 "{0}"'"""
raise SecurityError(dedent(msg).replace('\n', ' ').format(file))
return True | [
"def",
"assert_secure_file",
"(",
"file",
")",
":",
"if",
"not",
"is_secure_file",
"(",
"file",
")",
":",
"msg",
"=",
"\"\"\"\n File {0} can be read by other users.\n This is not secure. Please run 'chmod 600 \"{0}\"'\"\"\"",
"raise",
"SecurityError",
"(",
"dedent... | checks if a file is stored securely | [
"checks",
"if",
"a",
"file",
"is",
"stored",
"securely"
] | python | train | 39.125 |
cbclab/MOT | mot/lib/utils.py | https://github.com/cbclab/MOT/blob/fb3243b65025705842e82704705c00902f9a35af/mot/lib/utils.py#L546-L600 | def parse_cl_function(cl_code, dependencies=()):
"""Parse the given OpenCL string to a single SimpleCLFunction.
If the string contains more than one function, we will return only the last, with all the other added as a
dependency.
Args:
cl_code (str): the input string containing one or more fu... | [
"def",
"parse_cl_function",
"(",
"cl_code",
",",
"dependencies",
"=",
"(",
")",
")",
":",
"from",
"mot",
".",
"lib",
".",
"cl_function",
"import",
"SimpleCLFunction",
"def",
"separate_cl_functions",
"(",
"input_str",
")",
":",
"\"\"\"Separate all the OpenCL function... | Parse the given OpenCL string to a single SimpleCLFunction.
If the string contains more than one function, we will return only the last, with all the other added as a
dependency.
Args:
cl_code (str): the input string containing one or more functions.
dependencies (Iterable[CLCodeObject]): ... | [
"Parse",
"the",
"given",
"OpenCL",
"string",
"to",
"a",
"single",
"SimpleCLFunction",
"."
] | python | train | 34.781818 |
nickmckay/LiPD-utilities | Python/lipd/doi_resolver.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/doi_resolver.py#L175-L212 | def get_data(self, doi_id, idx):
"""
Resolve DOI and compile all attributes into one dictionary
:param str doi_id:
:param int idx: Publication index
:return dict: Updated publication dictionary
"""
tmp_dict = self.root_dict['pub'][0].copy()
try:
... | [
"def",
"get_data",
"(",
"self",
",",
"doi_id",
",",
"idx",
")",
":",
"tmp_dict",
"=",
"self",
".",
"root_dict",
"[",
"'pub'",
"]",
"[",
"0",
"]",
".",
"copy",
"(",
")",
"try",
":",
"# Send request to grab metadata at URL",
"url",
"=",
"\"http://dx.doi.org/... | Resolve DOI and compile all attributes into one dictionary
:param str doi_id:
:param int idx: Publication index
:return dict: Updated publication dictionary | [
"Resolve",
"DOI",
"and",
"compile",
"all",
"attributes",
"into",
"one",
"dictionary",
":",
"param",
"str",
"doi_id",
":",
":",
"param",
"int",
"idx",
":",
"Publication",
"index",
":",
"return",
"dict",
":",
"Updated",
"publication",
"dictionary"
] | python | train | 44.684211 |
google/apitools | apitools/gen/service_registry.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/gen/service_registry.py#L195-L261 | def WriteFile(self, printer):
"""Write the services in this registry to out."""
self.Validate()
client_info = self.__client_info
printer('"""Generated client library for %s version %s."""',
client_info.package, client_info.version)
printer('# NOTE: This file is au... | [
"def",
"WriteFile",
"(",
"self",
",",
"printer",
")",
":",
"self",
".",
"Validate",
"(",
")",
"client_info",
"=",
"self",
".",
"__client_info",
"printer",
"(",
"'\"\"\"Generated client library for %s version %s.\"\"\"'",
",",
"client_info",
".",
"package",
",",
"c... | Write the services in this registry to out. | [
"Write",
"the",
"services",
"in",
"this",
"registry",
"to",
"out",
"."
] | python | train | 53.731343 |
beregond/jsonmodels | jsonmodels/fields.py | https://github.com/beregond/jsonmodels/blob/97a1a6b90a49490fc5a6078f49027055d2e13541/jsonmodels/fields.py#L329-L335 | def parse_value(self, value):
"""Parse value to proper model type."""
if not isinstance(value, dict):
return value
embed_type = self._get_embed_type()
return embed_type(**value) | [
"def",
"parse_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"return",
"value",
"embed_type",
"=",
"self",
".",
"_get_embed_type",
"(",
")",
"return",
"embed_type",
"(",
"*",
"*",
"value",
"... | Parse value to proper model type. | [
"Parse",
"value",
"to",
"proper",
"model",
"type",
"."
] | python | train | 30.857143 |
peopledoc/workalendar | workalendar/core.py | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L259-L286 | def get_nth_weekday_in_month(year, month, weekday, n=1, start=None):
"""Get the nth weekday in a given month. e.g:
>>> # the 1st monday in Jan 2013
>>> Calendar.get_nth_weekday_in_month(2013, 1, MON)
datetime.date(2013, 1, 7)
>>> # The 2nd monday in Jan 2013
>>> Calendar... | [
"def",
"get_nth_weekday_in_month",
"(",
"year",
",",
"month",
",",
"weekday",
",",
"n",
"=",
"1",
",",
"start",
"=",
"None",
")",
":",
"# If start is `None` or Falsy, no need to check and clean",
"if",
"start",
":",
"start",
"=",
"cleaned_date",
"(",
"start",
")... | Get the nth weekday in a given month. e.g:
>>> # the 1st monday in Jan 2013
>>> Calendar.get_nth_weekday_in_month(2013, 1, MON)
datetime.date(2013, 1, 7)
>>> # The 2nd monday in Jan 2013
>>> Calendar.get_nth_weekday_in_month(2013, 1, MON, 2)
datetime.date(2013, 1, 14) | [
"Get",
"the",
"nth",
"weekday",
"in",
"a",
"given",
"month",
".",
"e",
".",
"g",
":"
] | python | train | 33.107143 |
lra/mackup | mackup/appsdb.py | https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/appsdb.py#L160-L171 | def get_pretty_app_names(self):
"""
Return the list of pretty app names that are available in the database.
Returns:
set of str.
"""
pretty_app_names = set()
for app_name in self.get_app_names():
pretty_app_names.add(self.get_name(app_name))
... | [
"def",
"get_pretty_app_names",
"(",
"self",
")",
":",
"pretty_app_names",
"=",
"set",
"(",
")",
"for",
"app_name",
"in",
"self",
".",
"get_app_names",
"(",
")",
":",
"pretty_app_names",
".",
"add",
"(",
"self",
".",
"get_name",
"(",
"app_name",
")",
")",
... | Return the list of pretty app names that are available in the database.
Returns:
set of str. | [
"Return",
"the",
"list",
"of",
"pretty",
"app",
"names",
"that",
"are",
"available",
"in",
"the",
"database",
"."
] | python | train | 28 |
gem/oq-engine | openquake/hazardlib/gsim/boore_2014.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/boore_2014.py#L226-L253 | def _get_intra_event_phi(self, C, mag, rjb, vs30, num_sites):
"""
Returns the intra-event standard deviation (phi), dependent on
magnitude, distance and vs30
"""
base_vals = np.zeros(num_sites)
# Magnitude Dependent phi (Equation 17)
if mag <= 4.5:
bas... | [
"def",
"_get_intra_event_phi",
"(",
"self",
",",
"C",
",",
"mag",
",",
"rjb",
",",
"vs30",
",",
"num_sites",
")",
":",
"base_vals",
"=",
"np",
".",
"zeros",
"(",
"num_sites",
")",
"# Magnitude Dependent phi (Equation 17)",
"if",
"mag",
"<=",
"4.5",
":",
"b... | Returns the intra-event standard deviation (phi), dependent on
magnitude, distance and vs30 | [
"Returns",
"the",
"intra",
"-",
"event",
"standard",
"deviation",
"(",
"phi",
")",
"dependent",
"on",
"magnitude",
"distance",
"and",
"vs30"
] | python | train | 42.464286 |
DataONEorg/d1_python | lib_client/src/d1_client/solr_client.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L258-L362 | def field_alpha_histogram(
self, name, n_bins=10, include_queries=True, **query_dict
):
"""Generates a histogram of values from a string field.
Output is: [[low, high, count, query], ... ]. Bin edges is determined by equal
division of the fields.
"""
bin_list = []
... | [
"def",
"field_alpha_histogram",
"(",
"self",
",",
"name",
",",
"n_bins",
"=",
"10",
",",
"include_queries",
"=",
"True",
",",
"*",
"*",
"query_dict",
")",
":",
"bin_list",
"=",
"[",
"]",
"q_bin",
"=",
"[",
"]",
"try",
":",
"# get total number of values for... | Generates a histogram of values from a string field.
Output is: [[low, high, count, query], ... ]. Bin edges is determined by equal
division of the fields. | [
"Generates",
"a",
"histogram",
"of",
"values",
"from",
"a",
"string",
"field",
"."
] | python | train | 44.771429 |
zhmcclient/python-zhmcclient | zhmcclient/_manager.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_manager.py#L380-L414 | def _divide_filter_args(self, filter_args):
"""
Divide the filter arguments into filter query parameters for filtering
on the server side, and the remaining client-side filters.
Parameters:
filter_args (dict):
Filter arguments that narrow the list of returned reso... | [
"def",
"_divide_filter_args",
"(",
"self",
",",
"filter_args",
")",
":",
"query_parms",
"=",
"[",
"]",
"# query parameter strings",
"client_filter_args",
"=",
"{",
"}",
"if",
"filter_args",
"is",
"not",
"None",
":",
"for",
"prop_name",
"in",
"filter_args",
":",
... | Divide the filter arguments into filter query parameters for filtering
on the server side, and the remaining client-side filters.
Parameters:
filter_args (dict):
Filter arguments that narrow the list of returned resources to
those that match the specified filter argum... | [
"Divide",
"the",
"filter",
"arguments",
"into",
"filter",
"query",
"parameters",
"for",
"filtering",
"on",
"the",
"server",
"side",
"and",
"the",
"remaining",
"client",
"-",
"side",
"filters",
"."
] | python | train | 35.714286 |
chemlab/chemlab | chemlab/mviewer/api/core.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/core.py#L22-L56 | def trajectory(start=None, stop=None, step=None):
'''Useful command to iterate on the trajectory frames by time (in
ns). It is meant to be used in a for loop::
for i in trajectory(0, 10, 0.1):
coords = current_frame()
t = current_time()
# Do something
The previo... | [
"def",
"trajectory",
"(",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"None",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"PyQt4",
"import",
"QtGui",
"times",
"=",
"np",
".",
"array",
"(",
"current_frame_times",
"(",
")",
"... | Useful command to iterate on the trajectory frames by time (in
ns). It is meant to be used in a for loop::
for i in trajectory(0, 10, 0.1):
coords = current_frame()
t = current_time()
# Do something
The previous snippet will stop at every frame from 0 to 10 ns with
... | [
"Useful",
"command",
"to",
"iterate",
"on",
"the",
"trajectory",
"frames",
"by",
"time",
"(",
"in",
"ns",
")",
".",
"It",
"is",
"meant",
"to",
"be",
"used",
"in",
"a",
"for",
"loop",
"::"
] | python | train | 26.085714 |
vex1023/vxUtils | vxUtils/decorator.py | https://github.com/vex1023/vxUtils/blob/58120a206cf96c4231d1e63d271c9d533d5f0a89/vxUtils/decorator.py#L26-L70 | def retry(tries, CatchExceptions=(Exception,), delay=0.01, backoff=2):
'''
错误重试的修饰器
:param tries: 重试次数
:param CatchExceptions: 需要重试的exception列表
:param delay: 重试前等待
:param backoff: 重试n次后,需要等待delay * n * backoff
:return:
@retry(5,ValueError)
def test():
raise ValueError
... | [
"def",
"retry",
"(",
"tries",
",",
"CatchExceptions",
"=",
"(",
"Exception",
",",
")",
",",
"delay",
"=",
"0.01",
",",
"backoff",
"=",
"2",
")",
":",
"if",
"backoff",
"<=",
"1",
":",
"raise",
"ValueError",
"(",
"\"backoff must be greater than 1\"",
")",
... | 错误重试的修饰器
:param tries: 重试次数
:param CatchExceptions: 需要重试的exception列表
:param delay: 重试前等待
:param backoff: 重试n次后,需要等待delay * n * backoff
:return:
@retry(5,ValueError)
def test():
raise ValueError | [
"错误重试的修饰器",
":",
"param",
"tries",
":",
"重试次数",
":",
"param",
"CatchExceptions",
":",
"需要重试的exception列表",
":",
"param",
"delay",
":",
"重试前等待",
":",
"param",
"backoff",
":",
"重试n次后,需要等待delay",
"*",
"n",
"*",
"backoff",
":",
"return",
":"
] | python | train | 27.266667 |
StackStorm/pybind | pybind/nos/v6_0_2f/arp/access_list/permit/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/arp/access_list/permit/__init__.py#L92-L113 | def _set_permit_list(self, v, load=False):
"""
Setter method for permit_list, mapped from YANG variable /arp/access_list/permit/permit_list (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_permit_list is considered as a private
method. Backends looking to popul... | [
"def",
"_set_permit_list",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for permit_list, mapped from YANG variable /arp/access_list/permit/permit_list (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_permit_list is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj.... | [
"Setter",
"method",
"for",
"permit_list",
"mapped",
"from",
"YANG",
"variable",
"/",
"arp",
"/",
"access_list",
"/",
"permit",
"/",
"permit_list",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"i... | python | train | 126.045455 |
kata198/python-subprocess2 | subprocess2/__init__.py | https://github.com/kata198/python-subprocess2/blob/8544b0b651d8e14de9fdd597baa704182e248b01/subprocess2/__init__.py#L63-L85 | def waitUpTo(self, timeoutSeconds, pollInterval=DEFAULT_POLL_INTERVAL):
'''
Popen.waitUpTo - Wait up to a certain number of seconds for the process to end.
@param timeoutSeconds <float> - Number of seconds to wait
@param pollInterval <float> (default .05) - Number of seconds in bet... | [
"def",
"waitUpTo",
"(",
"self",
",",
"timeoutSeconds",
",",
"pollInterval",
"=",
"DEFAULT_POLL_INTERVAL",
")",
":",
"i",
"=",
"0",
"numWaits",
"=",
"timeoutSeconds",
"/",
"float",
"(",
"pollInterval",
")",
"ret",
"=",
"self",
".",
"poll",
"(",
")",
"if",
... | Popen.waitUpTo - Wait up to a certain number of seconds for the process to end.
@param timeoutSeconds <float> - Number of seconds to wait
@param pollInterval <float> (default .05) - Number of seconds in between each poll
@return - Returncode of application, or None if did not term... | [
"Popen",
".",
"waitUpTo",
"-",
"Wait",
"up",
"to",
"a",
"certain",
"number",
"of",
"seconds",
"for",
"the",
"process",
"to",
"end",
"."
] | python | train | 29.956522 |
tensorflow/cleverhans | cleverhans/utils_tf.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils_tf.py#L647-L665 | def jacobian_graph(predictions, x, nb_classes):
"""
Create the Jacobian graph to be ran later in a TF session
:param predictions: the model's symbolic output (linear output,
pre-softmax)
:param x: the input placeholder
:param nb_classes: the number of classes the model has
:return:
"""
# This fun... | [
"def",
"jacobian_graph",
"(",
"predictions",
",",
"x",
",",
"nb_classes",
")",
":",
"# This function will return a list of TF gradients",
"list_derivatives",
"=",
"[",
"]",
"# Define the TF graph elements to compute our derivatives for each class",
"for",
"class_ind",
"in",
"xr... | Create the Jacobian graph to be ran later in a TF session
:param predictions: the model's symbolic output (linear output,
pre-softmax)
:param x: the input placeholder
:param nb_classes: the number of classes the model has
:return: | [
"Create",
"the",
"Jacobian",
"graph",
"to",
"be",
"ran",
"later",
"in",
"a",
"TF",
"session",
":",
"param",
"predictions",
":",
"the",
"model",
"s",
"symbolic",
"output",
"(",
"linear",
"output",
"pre",
"-",
"softmax",
")",
":",
"param",
"x",
":",
"the... | python | train | 32.157895 |
MagicStack/asyncpg | asyncpg/cursor.py | https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cursor.py#L241-L260 | async def forward(self, n, *, timeout=None) -> int:
r"""Skip over the next *n* rows.
:param float timeout: Optional timeout value in seconds.
:return: A number of rows actually skipped over (<= *n*).
"""
self._check_ready()
if n <= 0:
raise exceptions.Interf... | [
"async",
"def",
"forward",
"(",
"self",
",",
"n",
",",
"*",
",",
"timeout",
"=",
"None",
")",
"->",
"int",
":",
"self",
".",
"_check_ready",
"(",
")",
"if",
"n",
"<=",
"0",
":",
"raise",
"exceptions",
".",
"InterfaceError",
"(",
"'n must be greater tha... | r"""Skip over the next *n* rows.
:param float timeout: Optional timeout value in seconds.
:return: A number of rows actually skipped over (<= *n*). | [
"r",
"Skip",
"over",
"the",
"next",
"*",
"n",
"*",
"rows",
"."
] | python | train | 31.4 |
mongodb/mongo-python-driver | pymongo/mongo_client.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/mongo_client.py#L1636-L1690 | def _kill_cursors(self, cursor_ids, address, topology, session):
"""Send a kill cursors message with the given ids."""
listeners = self._event_listeners
publish = listeners.enabled_for_commands
if address:
# address could be a tuple or _CursorAddress, but
# select... | [
"def",
"_kill_cursors",
"(",
"self",
",",
"cursor_ids",
",",
"address",
",",
"topology",
",",
"session",
")",
":",
"listeners",
"=",
"self",
".",
"_event_listeners",
"publish",
"=",
"listeners",
".",
"enabled_for_commands",
"if",
"address",
":",
"# address could... | Send a kill cursors message with the given ids. | [
"Send",
"a",
"kill",
"cursors",
"message",
"with",
"the",
"given",
"ids",
"."
] | python | train | 46.163636 |
tensorflow/tensorboard | tensorboard/backend/event_processing/directory_watcher.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/backend/event_processing/directory_watcher.py#L172-L192 | def _SetPath(self, path):
"""Sets the current path to watch for new events.
This also records the size of the old path, if any. If the size can't be
found, an error is logged.
Args:
path: The full path of the file to watch.
"""
old_path = self._path
if old_path and not io_wrapper.IsC... | [
"def",
"_SetPath",
"(",
"self",
",",
"path",
")",
":",
"old_path",
"=",
"self",
".",
"_path",
"if",
"old_path",
"and",
"not",
"io_wrapper",
".",
"IsCloudPath",
"(",
"old_path",
")",
":",
"try",
":",
"# We're done with the path, so store its size.",
"size",
"="... | Sets the current path to watch for new events.
This also records the size of the old path, if any. If the size can't be
found, an error is logged.
Args:
path: The full path of the file to watch. | [
"Sets",
"the",
"current",
"path",
"to",
"watch",
"for",
"new",
"events",
"."
] | python | train | 34.52381 |
PyCQA/pylint | pylint/pyreverse/diadefslib.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/diadefslib.py#L217-L238 | def get_diadefs(self, project, linker):
"""Get the diagrams configuration data
:param project:The pyreverse project
:type project: pyreverse.utils.Project
:param linker: The linker
:type linker: pyreverse.inspector.Linker(IdGeneratorMixIn, LocalsVisitor)
:returns: The l... | [
"def",
"get_diadefs",
"(",
"self",
",",
"project",
",",
"linker",
")",
":",
"# read and interpret diagram definitions (Diadefs)",
"diagrams",
"=",
"[",
"]",
"generator",
"=",
"ClassDiadefGenerator",
"(",
"linker",
",",
"self",
")",
"for",
"klass",
"in",
"self",
... | Get the diagrams configuration data
:param project:The pyreverse project
:type project: pyreverse.utils.Project
:param linker: The linker
:type linker: pyreverse.inspector.Linker(IdGeneratorMixIn, LocalsVisitor)
:returns: The list of diagram definitions
:rtype: list(:cl... | [
"Get",
"the",
"diagrams",
"configuration",
"data"
] | python | test | 38.954545 |
bcbio/bcbio-nextgen | bcbio/provenance/versioncheck.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/versioncheck.py#L32-L56 | def _needs_java(data):
"""Check if a caller needs external java for MuTect.
No longer check for older GATK (<3.6) versions because of time cost; this
won't be relevant to most runs so we skip the sanity check.
"""
vc = dd.get_variantcaller(data)
if isinstance(vc, dict):
out = {}
... | [
"def",
"_needs_java",
"(",
"data",
")",
":",
"vc",
"=",
"dd",
".",
"get_variantcaller",
"(",
"data",
")",
"if",
"isinstance",
"(",
"vc",
",",
"dict",
")",
":",
"out",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"vc",
".",
"items",
"(",
")",
":",... | Check if a caller needs external java for MuTect.
No longer check for older GATK (<3.6) versions because of time cost; this
won't be relevant to most runs so we skip the sanity check. | [
"Check",
"if",
"a",
"caller",
"needs",
"external",
"java",
"for",
"MuTect",
"."
] | python | train | 36.68 |
jorahn/icy | icy/ext/xml2json.py | https://github.com/jorahn/icy/blob/d0bd765c933b2d9bff4d7d646c0938348b9c5c25/icy/ext/xml2json.py#L148-L158 | def elem2json(elem, options, strip_ns=1, strip=1):
"""Convert an ElementTree or Element into a JSON string."""
if hasattr(elem, 'getroot'):
elem = elem.getroot()
if options.pretty:
return json.dumps(elem_to_internal(elem, strip_ns=strip_ns, strip=strip), sort_keys=True, indent=4, separato... | [
"def",
"elem2json",
"(",
"elem",
",",
"options",
",",
"strip_ns",
"=",
"1",
",",
"strip",
"=",
"1",
")",
":",
"if",
"hasattr",
"(",
"elem",
",",
"'getroot'",
")",
":",
"elem",
"=",
"elem",
".",
"getroot",
"(",
")",
"if",
"options",
".",
"pretty",
... | Convert an ElementTree or Element into a JSON string. | [
"Convert",
"an",
"ElementTree",
"or",
"Element",
"into",
"a",
"JSON",
"string",
"."
] | python | train | 37.909091 |
googleapis/google-cloud-python | trace/google/cloud/trace/v1/_gapic.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace/v1/_gapic.py#L168-L183 | def make_trace_api(client):
"""
Create an instance of the gapic Trace API.
Args:
client (~google.cloud.trace.client.Client): The client that holds
configuration details.
Returns:
A :class:`~google.cloud.trace._gapic._TraceAPI` instance with the
proper configurations... | [
"def",
"make_trace_api",
"(",
"client",
")",
":",
"generated",
"=",
"trace_service_client",
".",
"TraceServiceClient",
"(",
"credentials",
"=",
"client",
".",
"_credentials",
",",
"client_info",
"=",
"_CLIENT_INFO",
")",
"return",
"_TraceAPI",
"(",
"generated",
",... | Create an instance of the gapic Trace API.
Args:
client (~google.cloud.trace.client.Client): The client that holds
configuration details.
Returns:
A :class:`~google.cloud.trace._gapic._TraceAPI` instance with the
proper configurations. | [
"Create",
"an",
"instance",
"of",
"the",
"gapic",
"Trace",
"API",
"."
] | python | train | 30.1875 |
usc-isi-i2/etk | etk/dependencies/landmark/landmark_extractor/extraction/Landmark.py | https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/dependencies/landmark/landmark_extractor/extraction/Landmark.py#L56-L129 | def loadRule(rule_json_object):
""" Method to load the rules - when adding a new rule it must be added to the if statement within this method. """
name = rule_json_object['name']
rule_type = rule_json_object['rule_type']
validation_regex = None
required = False
removehtml = False
include_end... | [
"def",
"loadRule",
"(",
"rule_json_object",
")",
":",
"name",
"=",
"rule_json_object",
"[",
"'name'",
"]",
"rule_type",
"=",
"rule_json_object",
"[",
"'rule_type'",
"]",
"validation_regex",
"=",
"None",
"required",
"=",
"False",
"removehtml",
"=",
"False",
"incl... | Method to load the rules - when adding a new rule it must be added to the if statement within this method. | [
"Method",
"to",
"load",
"the",
"rules",
"-",
"when",
"adding",
"a",
"new",
"rule",
"it",
"must",
"be",
"added",
"to",
"the",
"if",
"statement",
"within",
"this",
"method",
"."
] | python | train | 41.391892 |
gwpy/gwpy | gwpy/table/io/pycbc.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/table/io/pycbc.py#L188-L210 | def filter_empty_files(files, ifo=None):
"""Remove empty PyCBC-HDF5 files from a list
Parameters
----------
files : `list`
A list of file paths to test.
ifo : `str`, optional
prefix for the interferometer of interest (e.g. ``'L1'``),
include this for a more robust test of '... | [
"def",
"filter_empty_files",
"(",
"files",
",",
"ifo",
"=",
"None",
")",
":",
"return",
"type",
"(",
"files",
")",
"(",
"[",
"f",
"for",
"f",
"in",
"files",
"if",
"not",
"empty_hdf5_file",
"(",
"f",
",",
"ifo",
"=",
"ifo",
")",
"]",
")"
] | Remove empty PyCBC-HDF5 files from a list
Parameters
----------
files : `list`
A list of file paths to test.
ifo : `str`, optional
prefix for the interferometer of interest (e.g. ``'L1'``),
include this for a more robust test of 'emptiness'
Returns
-------
nonempty... | [
"Remove",
"empty",
"PyCBC",
"-",
"HDF5",
"files",
"from",
"a",
"list"
] | python | train | 26.26087 |
MisterWil/abodepy | abodepy/event_controller.py | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L76-L93 | def add_event_callback(self, event_groups, callback):
"""Register callback for a group of timeline events."""
if not event_groups:
return False
if not isinstance(event_groups, (tuple, list)):
event_groups = [event_groups]
for event_group in event_groups:
... | [
"def",
"add_event_callback",
"(",
"self",
",",
"event_groups",
",",
"callback",
")",
":",
"if",
"not",
"event_groups",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"event_groups",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"event_groups",
"=... | Register callback for a group of timeline events. | [
"Register",
"callback",
"for",
"a",
"group",
"of",
"timeline",
"events",
"."
] | python | train | 35.888889 |
quantumlib/Cirq | cirq/circuits/_block_diagram_drawer.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_block_diagram_drawer.py#L37-L43 | def min_width(self) -> int:
"""Minimum width necessary to render the block's contents."""
return max(
max(len(e) for e in self.content.split('\n')),
# Only horizontal lines can cross 0 width blocks.
int(any([self.top, self.bottom]))
) | [
"def",
"min_width",
"(",
"self",
")",
"->",
"int",
":",
"return",
"max",
"(",
"max",
"(",
"len",
"(",
"e",
")",
"for",
"e",
"in",
"self",
".",
"content",
".",
"split",
"(",
"'\\n'",
")",
")",
",",
"# Only horizontal lines can cross 0 width blocks.",
"int... | Minimum width necessary to render the block's contents. | [
"Minimum",
"width",
"necessary",
"to",
"render",
"the",
"block",
"s",
"contents",
"."
] | python | train | 41.142857 |
StackStorm/pybind | pybind/slxos/v17s_1_02/routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/__init__.py#L92-L113 | def _set_af_ipv6_unicast(self, v, load=False):
"""
Setter method for af_ipv6_unicast, mapped from YANG variable /routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_af_ipv6_uni... | [
"def",
"_set_af_ipv6_unicast",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
... | Setter method for af_ipv6_unicast, mapped from YANG variable /routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_af_ipv6_unicast is considered as a private
method. Backends lookin... | [
"Setter",
"method",
"for",
"af_ipv6_unicast",
"mapped",
"from",
"YANG",
"variable",
"/",
"routing_system",
"/",
"router",
"/",
"isis",
"/",
"router_isis_cmds_holder",
"/",
"address_family",
"/",
"ipv6",
"/",
"af_ipv6_unicast",
"(",
"container",
")",
"If",
"this",
... | python | train | 93.818182 |
romanorac/discomll | discomll/regression/locally_weighted_linear_regression.py | https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/regression/locally_weighted_linear_regression.py#L83-L139 | def fit_predict(training_data, fitting_data, tau=1, samples_per_job=0, save_results=True, show=False):
from disco.worker.pipeline.worker import Worker, Stage
from disco.core import Job, result_iterator
from disco.core import Disco
"""
training_data - training samples
fitting_data - dataset to b... | [
"def",
"fit_predict",
"(",
"training_data",
",",
"fitting_data",
",",
"tau",
"=",
"1",
",",
"samples_per_job",
"=",
"0",
",",
"save_results",
"=",
"True",
",",
"show",
"=",
"False",
")",
":",
"from",
"disco",
".",
"worker",
".",
"pipeline",
".",
"worker"... | training_data - training samples
fitting_data - dataset to be fitted to training data.
tau - controls how quickly the weight of a training sample falls off with distance of its x(i) from the query point x.
samples_per_job - define a number of samples that will be processed in single mapreduce job. If 0, alg... | [
"training_data",
"-",
"training",
"samples",
"fitting_data",
"-",
"dataset",
"to",
"be",
"fitted",
"to",
"training",
"data",
".",
"tau",
"-",
"controls",
"how",
"quickly",
"the",
"weight",
"of",
"a",
"training",
"sample",
"falls",
"off",
"with",
"distance",
... | python | train | 40.754386 |
HewlettPackard/python-hpOneView | hpOneView/resources/facilities/power_devices.py | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/facilities/power_devices.py#L126-L142 | def add_ipdu(self, information, timeout=-1):
"""
Add an HP iPDU and bring all components under management by discovery of its management module. Bring the
management module under exclusive management by the appliance, configure any management or data collection
settings, and create a pri... | [
"def",
"add_ipdu",
"(",
"self",
",",
"information",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"uri",
"=",
"self",
".",
"URI",
"+",
"\"/discover\"",
"return",
"self",
".",
"_client",
".",
"create",
"(",
"information",
",",
"uri",
"=",
"uri",
",",
"time... | Add an HP iPDU and bring all components under management by discovery of its management module. Bring the
management module under exclusive management by the appliance, configure any management or data collection
settings, and create a private set of administrative credentials to enable ongoing communic... | [
"Add",
"an",
"HP",
"iPDU",
"and",
"bring",
"all",
"components",
"under",
"management",
"by",
"discovery",
"of",
"its",
"management",
"module",
".",
"Bring",
"the",
"management",
"module",
"under",
"exclusive",
"management",
"by",
"the",
"appliance",
"configure",... | python | train | 54.176471 |
jlevy/strif | strif.py | https://github.com/jlevy/strif/blob/5a066f7a075ca822da59d665cfe88f0afd39a793/strif.py#L167-L182 | def make_all_dirs(path, mode=0o777):
"""
Ensure local dir, with all its parent dirs, are created.
Unlike os.makedirs(), will not fail if the path already exists.
"""
# Avoid races inherent to doing this in two steps (check then create).
# Python 3 has exist_ok but the approach below works for Python 2+3.
... | [
"def",
"make_all_dirs",
"(",
"path",
",",
"mode",
"=",
"0o777",
")",
":",
"# Avoid races inherent to doing this in two steps (check then create).",
"# Python 3 has exist_ok but the approach below works for Python 2+3.",
"# https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-p... | Ensure local dir, with all its parent dirs, are created.
Unlike os.makedirs(), will not fail if the path already exists. | [
"Ensure",
"local",
"dir",
"with",
"all",
"its",
"parent",
"dirs",
"are",
"created",
".",
"Unlike",
"os",
".",
"makedirs",
"()",
"will",
"not",
"fail",
"if",
"the",
"path",
"already",
"exists",
"."
] | python | train | 34.1875 |
hyperledger/indy-node | indy_node/server/upgrader.py | https://github.com/hyperledger/indy-node/blob/8fabd364eaf7d940a56df2911d9215b1e512a2de/indy_node/server/upgrader.py#L185-L205 | def didLastExecutedUpgradeSucceeded(self) -> bool:
"""
Checks last record in upgrade log to find out whether it
is about scheduling upgrade. If so - checks whether current version
is equals to the one in that record
:returns: upgrade execution result
"""
lastEven... | [
"def",
"didLastExecutedUpgradeSucceeded",
"(",
"self",
")",
"->",
"bool",
":",
"lastEventInfo",
"=",
"self",
".",
"lastActionEventInfo",
"if",
"lastEventInfo",
":",
"ev_data",
"=",
"lastEventInfo",
".",
"data",
"currentPkgVersion",
"=",
"NodeControlUtil",
".",
"curr... | Checks last record in upgrade log to find out whether it
is about scheduling upgrade. If so - checks whether current version
is equals to the one in that record
:returns: upgrade execution result | [
"Checks",
"last",
"record",
"in",
"upgrade",
"log",
"to",
"find",
"out",
"whether",
"it",
"is",
"about",
"scheduling",
"upgrade",
".",
"If",
"so",
"-",
"checks",
"whether",
"current",
"version",
"is",
"equals",
"to",
"the",
"one",
"in",
"that",
"record"
] | python | train | 40.190476 |
IntegralDefense/splunklib | splunklib/__init__.py | https://github.com/IntegralDefense/splunklib/blob/c3a02c83daad20cf24838f52b22cd2476f062eed/splunklib/__init__.py#L15-L30 | def create_timedelta(timespec):
"""Utility function to translate DD:HH:MM:SS into a timedelta object."""
duration = timespec.split(':')
seconds = int(duration[-1])
minutes = 0
hours = 0
days = 0
if len(duration) > 1:
minutes = int(duration[-2])
if len(duration) > 2:
hour... | [
"def",
"create_timedelta",
"(",
"timespec",
")",
":",
"duration",
"=",
"timespec",
".",
"split",
"(",
"':'",
")",
"seconds",
"=",
"int",
"(",
"duration",
"[",
"-",
"1",
"]",
")",
"minutes",
"=",
"0",
"hours",
"=",
"0",
"days",
"=",
"0",
"if",
"len"... | Utility function to translate DD:HH:MM:SS into a timedelta object. | [
"Utility",
"function",
"to",
"translate",
"DD",
":",
"HH",
":",
"MM",
":",
"SS",
"into",
"a",
"timedelta",
"object",
"."
] | python | train | 29.625 |
googleapis/google-cloud-python | spanner/google/cloud/spanner_v1/database.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/database.py#L758-L774 | def process(self, batch):
"""Process a single, partitioned query or read.
:type batch: mapping
:param batch:
one of the mappings returned from an earlier call to
:meth:`generate_query_batches`.
:rtype: :class:`~google.cloud.spanner_v1.streamed.StreamedResultSet`... | [
"def",
"process",
"(",
"self",
",",
"batch",
")",
":",
"if",
"\"query\"",
"in",
"batch",
":",
"return",
"self",
".",
"process_query_batch",
"(",
"batch",
")",
"if",
"\"read\"",
"in",
"batch",
":",
"return",
"self",
".",
"process_read_batch",
"(",
"batch",
... | Process a single, partitioned query or read.
:type batch: mapping
:param batch:
one of the mappings returned from an earlier call to
:meth:`generate_query_batches`.
:rtype: :class:`~google.cloud.spanner_v1.streamed.StreamedResultSet`
:returns: a result set insta... | [
"Process",
"a",
"single",
"partitioned",
"query",
"or",
"read",
"."
] | python | train | 39.411765 |
ThreatConnect-Inc/tcex | tcex/tcex_playbook.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_playbook.py#L1210-L1244 | def json_to_key_value(json_data, key_field, value_field=None, array=False):
"""Convert JSON data to a KeyValue/KeyValueArray.
Args:
json_data (dictionary|list): Array/List of JSON data.
key_field (string): Field name for the key.
value_field (string): Field name for ... | [
"def",
"json_to_key_value",
"(",
"json_data",
",",
"key_field",
",",
"value_field",
"=",
"None",
",",
"array",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"json_data",
",",
"list",
")",
":",
"json_data",
"=",
"[",
"json_data",
"]",
"key_value_a... | Convert JSON data to a KeyValue/KeyValueArray.
Args:
json_data (dictionary|list): Array/List of JSON data.
key_field (string): Field name for the key.
value_field (string): Field name for the value or use the value of the key field.
array (boolean): Always return... | [
"Convert",
"JSON",
"data",
"to",
"a",
"KeyValue",
"/",
"KeyValueArray",
"."
] | python | train | 37.6 |
jobovy/galpy | galpy/orbit/OrbitTop.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/OrbitTop.py#L1245-L1304 | def _setupaA(self,pot=None,type='staeckel',**kwargs):
"""
NAME:
_setupaA
PURPOSE:
set up an actionAngle module for this Orbit
INPUT:
pot - potential
type= ('staeckel') type of actionAngle module to use
1) 'adiabatic'
... | [
"def",
"_setupaA",
"(",
"self",
",",
"pot",
"=",
"None",
",",
"type",
"=",
"'staeckel'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_aA'",
")",
":",
"if",
"not",
"self",
".",
"_resetaA",
"(",
"pot",
"=",
"pot",
",",
... | NAME:
_setupaA
PURPOSE:
set up an actionAngle module for this Orbit
INPUT:
pot - potential
type= ('staeckel') type of actionAngle module to use
1) 'adiabatic'
2) 'staeckel'
3) 'isochroneApprox'
4) 'spheri... | [
"NAME",
":",
"_setupaA",
"PURPOSE",
":",
"set",
"up",
"an",
"actionAngle",
"module",
"for",
"this",
"Orbit",
"INPUT",
":",
"pot",
"-",
"potential",
"type",
"=",
"(",
"staeckel",
")",
"type",
"of",
"actionAngle",
"module",
"to",
"use",
"1",
")",
"adiabati... | python | train | 49.716667 |
ynop/audiomate | audiomate/corpus/io/mailabs.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/corpus/io/mailabs.py#L154-L204 | def load_books_of_speaker(corpus, path, speaker):
"""
Load all utterances for the speaker at the given path.
"""
utt_ids = []
for book_path in MailabsReader.get_folders(path):
meta_path = os.path.join(book_path, 'metadata.csv')
wavs_path = os.path.join(bo... | [
"def",
"load_books_of_speaker",
"(",
"corpus",
",",
"path",
",",
"speaker",
")",
":",
"utt_ids",
"=",
"[",
"]",
"for",
"book_path",
"in",
"MailabsReader",
".",
"get_folders",
"(",
"path",
")",
":",
"meta_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
... | Load all utterances for the speaker at the given path. | [
"Load",
"all",
"utterances",
"for",
"the",
"speaker",
"at",
"the",
"given",
"path",
"."
] | python | train | 36.843137 |
tensorflow/probability | tensorflow_probability/python/internal/distribution_util.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/distribution_util.py#L378-L395 | def is_diagonal_scale(scale):
"""Returns `True` if `scale` is a `LinearOperator` that is known to be diag.
Args:
scale: `LinearOperator` instance.
Returns:
Python `bool`.
Raises:
TypeError: If `scale` is not a `LinearOperator`.
"""
if not isinstance(scale, tf.linalg.LinearOperator):
rai... | [
"def",
"is_diagonal_scale",
"(",
"scale",
")",
":",
"if",
"not",
"isinstance",
"(",
"scale",
",",
"tf",
".",
"linalg",
".",
"LinearOperator",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected argument 'scale' to be instance of LinearOperator\"",
"\". Found: %s\"",
"%",... | Returns `True` if `scale` is a `LinearOperator` that is known to be diag.
Args:
scale: `LinearOperator` instance.
Returns:
Python `bool`.
Raises:
TypeError: If `scale` is not a `LinearOperator`. | [
"Returns",
"True",
"if",
"scale",
"is",
"a",
"LinearOperator",
"that",
"is",
"known",
"to",
"be",
"diag",
"."
] | python | test | 34.111111 |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/engine.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/engine.py#L123-L143 | def set_target_variable (self, targets, variable, value, append=0):
""" Sets a target variable.
The 'variable' will be available to bjam when it decides
where to generate targets, and will also be available to
updating rule for that 'taret'.
"""
if isinstance (targets, s... | [
"def",
"set_target_variable",
"(",
"self",
",",
"targets",
",",
"variable",
",",
"value",
",",
"append",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"targets",
",",
"str",
")",
":",
"targets",
"=",
"[",
"targets",
"]",
"if",
"isinstance",
"(",
"value"... | Sets a target variable.
The 'variable' will be available to bjam when it decides
where to generate targets, and will also be available to
updating rule for that 'taret'. | [
"Sets",
"a",
"target",
"variable",
"."
] | python | train | 36.095238 |
totalgood/nlpia | src/nlpia/book/forum/boltz.py | https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/book/forum/boltz.py#L54-L67 | def tablify(*args):
r"""
>>> tablify(range(3), range(10, 13))
[[0, 10], [1, 11], [2, 12]]
"""
table = []
args = [listify(arg) for arg in args]
for row in zip(*args):
r = []
for x in row:
r += listify(x)
table += [r]
return table
return [sum([listif... | [
"def",
"tablify",
"(",
"*",
"args",
")",
":",
"table",
"=",
"[",
"]",
"args",
"=",
"[",
"listify",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
"]",
"for",
"row",
"in",
"zip",
"(",
"*",
"args",
")",
":",
"r",
"=",
"[",
"]",
"for",
"x",
"in"... | r"""
>>> tablify(range(3), range(10, 13))
[[0, 10], [1, 11], [2, 12]] | [
"r",
">>>",
"tablify",
"(",
"range",
"(",
"3",
")",
"range",
"(",
"10",
"13",
"))",
"[[",
"0",
"10",
"]",
"[",
"1",
"11",
"]",
"[",
"2",
"12",
"]]"
] | python | train | 25.071429 |
codeinn/vcs | vcs/backends/hg/changeset.py | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/changeset.py#L331-L353 | def get_node(self, path):
"""
Returns ``Node`` object from the given ``path``. If there is no node at
the given ``path``, ``ChangesetError`` would be raised.
"""
path = self._fix_path(path)
if not path in self.nodes:
if path in self._file_paths:
... | [
"def",
"get_node",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_fix_path",
"(",
"path",
")",
"if",
"not",
"path",
"in",
"self",
".",
"nodes",
":",
"if",
"path",
"in",
"self",
".",
"_file_paths",
":",
"node",
"=",
"FileNode",
"(",... | Returns ``Node`` object from the given ``path``. If there is no node at
the given ``path``, ``ChangesetError`` would be raised. | [
"Returns",
"Node",
"object",
"from",
"the",
"given",
"path",
".",
"If",
"there",
"is",
"no",
"node",
"at",
"the",
"given",
"path",
"ChangesetError",
"would",
"be",
"raised",
"."
] | python | train | 37.608696 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/runsnakerun/pstatsloader.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/pstatsloader.py#L44-L54 | def load( self, stats ):
"""Build a squaremap-compatible model from a pstats class"""
rows = self.rows
for func, raw in stats.iteritems():
try:
rows[func] = row = PStatRow( func,raw )
except ValueError, err:
log.info( 'Null row: %s', func )... | [
"def",
"load",
"(",
"self",
",",
"stats",
")",
":",
"rows",
"=",
"self",
".",
"rows",
"for",
"func",
",",
"raw",
"in",
"stats",
".",
"iteritems",
"(",
")",
":",
"try",
":",
"rows",
"[",
"func",
"]",
"=",
"row",
"=",
"PStatRow",
"(",
"func",
","... | Build a squaremap-compatible model from a pstats class | [
"Build",
"a",
"squaremap",
"-",
"compatible",
"model",
"from",
"a",
"pstats",
"class"
] | python | train | 37.818182 |
orbingol/NURBS-Python | geomdl/_operations.py | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/_operations.py#L129-L145 | def binormal_curve_single_list(obj, param_list, normalize):
""" Evaluates the curve binormal vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned... | [
"def",
"binormal_curve_single_list",
"(",
"obj",
",",
"param_list",
",",
"normalize",
")",
":",
"ret_vector",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"temp",
"=",
"binormal_curve_single",
"(",
"obj",
",",
"param",
",",
"normalize",
")",
"ret_... | Evaluates the curve binormal vectors at the given list of parameter values.
:param obj: input curve
:type obj: abstract.Curve
:param param_list: parameter list
:type param_list: list or tuple
:param normalize: if True, the returned vector is converted to a unit vector
:type normalize: bool
... | [
"Evaluates",
"the",
"curve",
"binormal",
"vectors",
"at",
"the",
"given",
"list",
"of",
"parameter",
"values",
"."
] | python | train | 36.529412 |
tango-controls/pytango | tango/server.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/server.py#L317-L339 | def __patch_pipe_write_method(tango_device_klass, pipe):
"""
Checks if method given by it's name for the given DeviceImpl
class has the correct signature. If a read/write method doesn't
have a parameter (the traditional Pipe), then the method is
wrapped into another method which has correct paramete... | [
"def",
"__patch_pipe_write_method",
"(",
"tango_device_klass",
",",
"pipe",
")",
":",
"write_method",
"=",
"getattr",
"(",
"pipe",
",",
"\"fset\"",
",",
"None",
")",
"if",
"write_method",
":",
"method_name",
"=",
"\"__write_{0}__\"",
".",
"format",
"(",
"pipe",
... | Checks if method given by it's name for the given DeviceImpl
class has the correct signature. If a read/write method doesn't
have a parameter (the traditional Pipe), then the method is
wrapped into another method which has correct parameter definition
to make it work.
:param tango_device_klass: a D... | [
"Checks",
"if",
"method",
"given",
"by",
"it",
"s",
"name",
"for",
"the",
"given",
"DeviceImpl",
"class",
"has",
"the",
"correct",
"signature",
".",
"If",
"a",
"read",
"/",
"write",
"method",
"doesn",
"t",
"have",
"a",
"parameter",
"(",
"the",
"tradition... | python | train | 39.695652 |
nuagenetworks/monolithe | monolithe/generators/lang/csharp/writers/apiversionwriter.py | https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/csharp/writers/apiversionwriter.py#L291-L320 | def _set_enum_list_local_type(self, specifications):
""" This method is needed until get_type_name() is enhanced to include specification subtype and local_name
"""
for rest_name, specification in specifications.items():
for attribute in specification.attributes:
if a... | [
"def",
"_set_enum_list_local_type",
"(",
"self",
",",
"specifications",
")",
":",
"for",
"rest_name",
",",
"specification",
"in",
"specifications",
".",
"items",
"(",
")",
":",
"for",
"attribute",
"in",
"specification",
".",
"attributes",
":",
"if",
"attribute",... | This method is needed until get_type_name() is enhanced to include specification subtype and local_name | [
"This",
"method",
"is",
"needed",
"until",
"get_type_name",
"()",
"is",
"enhanced",
"to",
"include",
"specification",
"subtype",
"and",
"local_name"
] | python | train | 65.466667 |
spyder-ide/spyder | spyder/preferences/shortcuts.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/shortcuts.py#L823-L829 | def previous_row(self):
"""Move to previous row from currently selected row."""
row = self.currentIndex().row()
rows = self.proxy_model.rowCount()
if row == 0:
row = rows
self.selectRow(row - 1) | [
"def",
"previous_row",
"(",
"self",
")",
":",
"row",
"=",
"self",
".",
"currentIndex",
"(",
")",
".",
"row",
"(",
")",
"rows",
"=",
"self",
".",
"proxy_model",
".",
"rowCount",
"(",
")",
"if",
"row",
"==",
"0",
":",
"row",
"=",
"rows",
"self",
".... | Move to previous row from currently selected row. | [
"Move",
"to",
"previous",
"row",
"from",
"currently",
"selected",
"row",
"."
] | python | train | 35.142857 |
neherlab/treetime | treetime/wrappers.py | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L124-L148 | def read_if_vcf(params):
"""
Checks if input is VCF and reads in appropriately if it is
"""
ref = None
aln = params.aln
fixed_pi = None
if hasattr(params, 'aln') and params.aln is not None:
if any([params.aln.lower().endswith(x) for x in ['.vcf', '.vcf.gz']]):
if not para... | [
"def",
"read_if_vcf",
"(",
"params",
")",
":",
"ref",
"=",
"None",
"aln",
"=",
"params",
".",
"aln",
"fixed_pi",
"=",
"None",
"if",
"hasattr",
"(",
"params",
",",
"'aln'",
")",
"and",
"params",
".",
"aln",
"is",
"not",
"None",
":",
"if",
"any",
"("... | Checks if input is VCF and reads in appropriately if it is | [
"Checks",
"if",
"input",
"is",
"VCF",
"and",
"reads",
"in",
"appropriately",
"if",
"it",
"is"
] | python | test | 41.12 |
splunk/splunk-sdk-python | examples/analytics/bottle.py | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L944-L950 | def params(self):
""" A combined :class:`MultiDict` with values from :attr:`forms` and
:attr:`GET`. File-uploads are not included. """
params = MultiDict(self.GET)
for key, value in self.forms.iterallitems():
params[key] = value
return params | [
"def",
"params",
"(",
"self",
")",
":",
"params",
"=",
"MultiDict",
"(",
"self",
".",
"GET",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"forms",
".",
"iterallitems",
"(",
")",
":",
"params",
"[",
"key",
"]",
"=",
"value",
"return",
"params... | A combined :class:`MultiDict` with values from :attr:`forms` and
:attr:`GET`. File-uploads are not included. | [
"A",
"combined",
":",
"class",
":",
"MultiDict",
"with",
"values",
"from",
":",
"attr",
":",
"forms",
"and",
":",
"attr",
":",
"GET",
".",
"File",
"-",
"uploads",
"are",
"not",
"included",
"."
] | python | train | 41.714286 |
f3at/feat | src/feat/models/effect.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/models/effect.py#L114-L124 | def relative_ref(*parts):
"""
Create a reference builder with specified relative location.
using getter.relative_ref("some", "submodel") to get a value with key
"toto" will gives reference.Relative("some", "submodel", "toto")
"""
def relative_ref(_value, context, **_params):
return refe... | [
"def",
"relative_ref",
"(",
"*",
"parts",
")",
":",
"def",
"relative_ref",
"(",
"_value",
",",
"context",
",",
"*",
"*",
"_params",
")",
":",
"return",
"reference",
".",
"Relative",
"(",
"*",
"(",
"parts",
"+",
"(",
"context",
"[",
"\"key\"",
"]",
",... | Create a reference builder with specified relative location.
using getter.relative_ref("some", "submodel") to get a value with key
"toto" will gives reference.Relative("some", "submodel", "toto") | [
"Create",
"a",
"reference",
"builder",
"with",
"specified",
"relative",
"location",
".",
"using",
"getter",
".",
"relative_ref",
"(",
"some",
"submodel",
")",
"to",
"get",
"a",
"value",
"with",
"key",
"toto",
"will",
"gives",
"reference",
".",
"Relative",
"(... | python | train | 34.545455 |
Autodesk/aomi | aomi/cli.py | https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/cli.py#L240-L256 | def seed_args(subparsers):
"""Add command line options for the seed operation"""
seed_parser = subparsers.add_parser('seed')
secretfile_args(seed_parser)
vars_args(seed_parser)
seed_parser.add_argument('--mount-only',
dest='mount_only',
help=... | [
"def",
"seed_args",
"(",
"subparsers",
")",
":",
"seed_parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"'seed'",
")",
"secretfile_args",
"(",
"seed_parser",
")",
"vars_args",
"(",
"seed_parser",
")",
"seed_parser",
".",
"add_argument",
"(",
"'--mount-only'",
... | Add command line options for the seed operation | [
"Add",
"command",
"line",
"options",
"for",
"the",
"seed",
"operation"
] | python | train | 44.941176 |
IdentityPython/fedoidcmsg | src/fedoidcmsg/bundle.py | https://github.com/IdentityPython/fedoidcmsg/blob/d30107be02521fa6cdfe285da3b6b0cdd153c8cc/src/fedoidcmsg/bundle.py#L252-L267 | def jwks_to_keyjar(jwks, iss=''):
"""
Convert a JWKS to a KeyJar instance.
:param jwks: String representation of a JWKS
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
if not isinstance(jwks, dict):
try:
jwks = json.loads(jwks)
except json.JSONDecodeError:... | [
"def",
"jwks_to_keyjar",
"(",
"jwks",
",",
"iss",
"=",
"''",
")",
":",
"if",
"not",
"isinstance",
"(",
"jwks",
",",
"dict",
")",
":",
"try",
":",
"jwks",
"=",
"json",
".",
"loads",
"(",
"jwks",
")",
"except",
"json",
".",
"JSONDecodeError",
":",
"r... | Convert a JWKS to a KeyJar instance.
:param jwks: String representation of a JWKS
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance | [
"Convert",
"a",
"JWKS",
"to",
"a",
"KeyJar",
"instance",
"."
] | python | test | 26.375 |
tdryer/hangups | hangups/conversation_event.py | https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/conversation_event.py#L168-L171 | def segments(self):
"""List of :class:`ChatMessageSegment` in message (:class:`list`)."""
seg_list = self._event.chat_message.message_content.segment
return [ChatMessageSegment.deserialize(seg) for seg in seg_list] | [
"def",
"segments",
"(",
"self",
")",
":",
"seg_list",
"=",
"self",
".",
"_event",
".",
"chat_message",
".",
"message_content",
".",
"segment",
"return",
"[",
"ChatMessageSegment",
".",
"deserialize",
"(",
"seg",
")",
"for",
"seg",
"in",
"seg_list",
"]"
] | List of :class:`ChatMessageSegment` in message (:class:`list`). | [
"List",
"of",
":",
"class",
":",
"ChatMessageSegment",
"in",
"message",
"(",
":",
"class",
":",
"list",
")",
"."
] | python | valid | 58.75 |
openearth/mmi-python | mmi/runner.py | https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/runner.py#L186-L327 | def process_incoming(self):
"""
process incoming messages
data is a dict with several arrays
"""
model = self.model
sockets = self.sockets
# Check for new messages
if not sockets:
return
# unpack sockets
poller = sockets['pol... | [
"def",
"process_incoming",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"model",
"sockets",
"=",
"self",
".",
"sockets",
"# Check for new messages",
"if",
"not",
"sockets",
":",
"return",
"# unpack sockets",
"poller",
"=",
"sockets",
"[",
"'poller'",
"]",... | process incoming messages
data is a dict with several arrays | [
"process",
"incoming",
"messages"
] | python | train | 44.922535 |
05bit/peewee-async | peewee_async.py | https://github.com/05bit/peewee-async/blob/d15f4629da1d9975da4ec37306188e68d288c862/peewee_async.py#L892-L903 | async def pop_transaction_async(self):
"""Decrement async transaction depth.
"""
depth = self.transaction_depth_async()
if depth > 0:
depth -= 1
self._task_data.set('depth', depth)
if depth == 0:
conn = self._task_data.get('conn')
... | [
"async",
"def",
"pop_transaction_async",
"(",
"self",
")",
":",
"depth",
"=",
"self",
".",
"transaction_depth_async",
"(",
")",
"if",
"depth",
">",
"0",
":",
"depth",
"-=",
"1",
"self",
".",
"_task_data",
".",
"set",
"(",
"'depth'",
",",
"depth",
")",
... | Decrement async transaction depth. | [
"Decrement",
"async",
"transaction",
"depth",
"."
] | python | train | 36.166667 |
pyca/pyopenssl | src/OpenSSL/SSL.py | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/SSL.py#L1326-L1341 | def get_cert_store(self):
"""
Get the certificate store for the context. This can be used to add
"trusted" certificates without using the
:meth:`load_verify_locations` method.
:return: A X509Store object or None if it does not have one.
"""
store = _lib.SSL_CTX_... | [
"def",
"get_cert_store",
"(",
"self",
")",
":",
"store",
"=",
"_lib",
".",
"SSL_CTX_get_cert_store",
"(",
"self",
".",
"_context",
")",
"if",
"store",
"==",
"_ffi",
".",
"NULL",
":",
"# TODO: This is untested.",
"return",
"None",
"pystore",
"=",
"X509Store",
... | Get the certificate store for the context. This can be used to add
"trusted" certificates without using the
:meth:`load_verify_locations` method.
:return: A X509Store object or None if it does not have one. | [
"Get",
"the",
"certificate",
"store",
"for",
"the",
"context",
".",
"This",
"can",
"be",
"used",
"to",
"add",
"trusted",
"certificates",
"without",
"using",
"the",
":",
"meth",
":",
"load_verify_locations",
"method",
"."
] | python | test | 33.0625 |
mrcagney/gtfstk | gtfstk/trips.py | https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/trips.py#L572-L683 | def map_trips(
feed: "Feed",
trip_ids: List[str],
color_palette: List[str] = cs.COLORS_SET2,
*,
include_stops: bool = True,
):
"""
Return a Folium map showing the given trips and (optionally)
their stops.
Parameters
----------
feed : Feed
trip_ids : list
IDs of t... | [
"def",
"map_trips",
"(",
"feed",
":",
"\"Feed\"",
",",
"trip_ids",
":",
"List",
"[",
"str",
"]",
",",
"color_palette",
":",
"List",
"[",
"str",
"]",
"=",
"cs",
".",
"COLORS_SET2",
",",
"*",
",",
"include_stops",
":",
"bool",
"=",
"True",
",",
")",
... | Return a Folium map showing the given trips and (optionally)
their stops.
Parameters
----------
feed : Feed
trip_ids : list
IDs of trips in ``feed.trips``
color_palette : list
Palette to use to color the routes. If more routes than colors,
then colors will be recycled.
... | [
"Return",
"a",
"Folium",
"map",
"showing",
"the",
"given",
"trips",
"and",
"(",
"optionally",
")",
"their",
"stops",
"."
] | python | train | 27.982143 |
astropy/photutils | photutils/psf/sandbox.py | https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/psf/sandbox.py#L385-L403 | def to_original(self, x, y):
"""
Convert the input (x, y) positions from the rectified image to
the original (unrectified) image.
Parameters
----------
x, y: float or array-like of float
The zero-index pixel coordinates in the rectified image.
Retur... | [
"def",
"to_original",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"return",
"self",
".",
"_reproject",
"(",
"self",
".",
"wcs_rectified",
",",
"self",
".",
"wcs_original",
")",
"(",
"x",
",",
"y",
")"
] | Convert the input (x, y) positions from the rectified image to
the original (unrectified) image.
Parameters
----------
x, y: float or array-like of float
The zero-index pixel coordinates in the rectified image.
Returns
-------
x, y: float or array-... | [
"Convert",
"the",
"input",
"(",
"x",
"y",
")",
"positions",
"from",
"the",
"rectified",
"image",
"to",
"the",
"original",
"(",
"unrectified",
")",
"image",
"."
] | python | train | 29.947368 |
ev3dev/ev3dev-lang-python | ev3dev2/led.py | https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/led.py#L160-L178 | def trigger(self):
"""
Sets the LED trigger. A trigger is a kernel based source of LED events.
Triggers can either be simple or complex. A simple trigger isn't
configurable and is designed to slot into existing subsystems with
minimal additional code. Examples are the `ide-disk` ... | [
"def",
"trigger",
"(",
"self",
")",
":",
"self",
".",
"_trigger",
",",
"value",
"=",
"self",
".",
"get_attr_from_set",
"(",
"self",
".",
"_trigger",
",",
"'trigger'",
")",
"return",
"value"
] | Sets the LED trigger. A trigger is a kernel based source of LED events.
Triggers can either be simple or complex. A simple trigger isn't
configurable and is designed to slot into existing subsystems with
minimal additional code. Examples are the `ide-disk` and `nand-disk`
triggers.
... | [
"Sets",
"the",
"LED",
"trigger",
".",
"A",
"trigger",
"is",
"a",
"kernel",
"based",
"source",
"of",
"LED",
"events",
".",
"Triggers",
"can",
"either",
"be",
"simple",
"or",
"complex",
".",
"A",
"simple",
"trigger",
"isn",
"t",
"configurable",
"and",
"is"... | python | train | 53.736842 |
alpacahq/pipeline-live | pipeline_live/engine.py | https://github.com/alpacahq/pipeline-live/blob/6f42d64354a17e2546ca74f18004454f2019bd83/pipeline_live/engine.py#L271-L339 | def _to_narrow(self, terms, data, mask, dates, symbols):
"""
Convert raw computed pipeline results into a DataFrame for public APIs.
Parameters
----------
terms : dict[str -> Term]
Dict mapping column names to terms.
data : dict[str -> ndarray[ndim=2]]
... | [
"def",
"_to_narrow",
"(",
"self",
",",
"terms",
",",
"data",
",",
"mask",
",",
"dates",
",",
"symbols",
")",
":",
"assert",
"len",
"(",
"dates",
")",
"==",
"1",
"if",
"not",
"mask",
".",
"any",
"(",
")",
":",
"# Manually handle the empty DataFrame case. ... | Convert raw computed pipeline results into a DataFrame for public APIs.
Parameters
----------
terms : dict[str -> Term]
Dict mapping column names to terms.
data : dict[str -> ndarray[ndim=2]]
Dict mapping column names to computed results for those names.
... | [
"Convert",
"raw",
"computed",
"pipeline",
"results",
"into",
"a",
"DataFrame",
"for",
"public",
"APIs",
"."
] | python | train | 39.565217 |
hozn/stravalib | stravalib/client.py | https://github.com/hozn/stravalib/blob/5500ebc39e0bf4706bb1ca4c27b25e56becaaa5f/stravalib/client.py#L1546-L1566 | def list_subscriptions(self, client_id, client_secret):
"""
List current webhook event subscriptions in place for the current application.
http://strava.github.io/api/partner/v3/events/#list-push-subscriptions
:param client_id: application's ID, obtained during registration
:ty... | [
"def",
"list_subscriptions",
"(",
"self",
",",
"client_id",
",",
"client_secret",
")",
":",
"result_fetcher",
"=",
"functools",
".",
"partial",
"(",
"self",
".",
"protocol",
".",
"get",
",",
"'/push_subscriptions'",
",",
"client_id",
"=",
"client_id",
",",
"cl... | List current webhook event subscriptions in place for the current application.
http://strava.github.io/api/partner/v3/events/#list-push-subscriptions
:param client_id: application's ID, obtained during registration
:type client_id: int
:param client_secret: application's secret, obtai... | [
"List",
"current",
"webhook",
"event",
"subscriptions",
"in",
"place",
"for",
"the",
"current",
"application",
"."
] | python | train | 46 |
DEIB-GECO/PyGMQL | gmql/ml/dataset/parser/parser.py | https://github.com/DEIB-GECO/PyGMQL/blob/e58b2f9402a86056dcda484a32e3de0bb06ed991/gmql/ml/dataset/parser/parser.py#L83-L107 | def parse_single_meta(self, fname, selected_meta_data):
"""
Parses a single meta data file
:param fname: name of the file
:param selected_meta_data: If not none then only the specified columns of metadata are parsed
:return: the resulting pandas series
"""
# reads... | [
"def",
"parse_single_meta",
"(",
"self",
",",
"fname",
",",
"selected_meta_data",
")",
":",
"# reads a meta data file into a dataframe",
"columns",
"=",
"[",
"]",
"data",
"=",
"[",
"]",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"for",
"line",
"in",
... | Parses a single meta data file
:param fname: name of the file
:param selected_meta_data: If not none then only the specified columns of metadata are parsed
:return: the resulting pandas series | [
"Parses",
"a",
"single",
"meta",
"data",
"file",
":",
"param",
"fname",
":",
"name",
"of",
"the",
"file",
":",
"param",
"selected_meta_data",
":",
"If",
"not",
"none",
"then",
"only",
"the",
"specified",
"columns",
"of",
"metadata",
"are",
"parsed",
":",
... | python | train | 37.28 |
Nachtfeuer/pipeline | spline/tools/loc/application.py | https://github.com/Nachtfeuer/pipeline/blob/04ca18c4e95e4349532bb45b768206393e1f2c13/spline/tools/loc/application.py#L56-L60 | def load_configuration(self):
"""Loading configuration."""
filename = os.path.join(os.path.dirname(__file__), 'templates/spline-loc.yml.j2')
with open(filename) as handle:
return Adapter(safe_load(handle)).configuration | [
"def",
"load_configuration",
"(",
"self",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'templates/spline-loc.yml.j2'",
")",
"with",
"open",
"(",
"filename",
")",
"as",
"han... | Loading configuration. | [
"Loading",
"configuration",
"."
] | python | train | 50.2 |
pycontribs/pyrax | pyrax/__init__.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/__init__.py#L587-L606 | def clear_credentials():
"""De-authenticate by clearing all the names back to None."""
global identity, regions, services, cloudservers, cloudfiles, cloud_cdn
global cloud_loadbalancers, cloud_databases, cloud_blockstorage, cloud_dns
global cloud_networks, cloud_monitoring, autoscale, images, queues
... | [
"def",
"clear_credentials",
"(",
")",
":",
"global",
"identity",
",",
"regions",
",",
"services",
",",
"cloudservers",
",",
"cloudfiles",
",",
"cloud_cdn",
"global",
"cloud_loadbalancers",
",",
"cloud_databases",
",",
"cloud_blockstorage",
",",
"cloud_dns",
"global"... | De-authenticate by clearing all the names back to None. | [
"De",
"-",
"authenticate",
"by",
"clearing",
"all",
"the",
"names",
"back",
"to",
"None",
"."
] | python | train | 32.45 |
pydata/xarray | xarray/core/missing.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/missing.py#L343-L363 | def _get_interpolator_nd(method, **kwargs):
'''helper function to select the appropriate interpolator class
returns interpolator class and keyword arguments for the class
'''
valid_methods = ['linear', 'nearest']
try:
from scipy import interpolate
except ImportError:
raise Impo... | [
"def",
"_get_interpolator_nd",
"(",
"method",
",",
"*",
"*",
"kwargs",
")",
":",
"valid_methods",
"=",
"[",
"'linear'",
",",
"'nearest'",
"]",
"try",
":",
"from",
"scipy",
"import",
"interpolate",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'... | helper function to select the appropriate interpolator class
returns interpolator class and keyword arguments for the class | [
"helper",
"function",
"to",
"select",
"the",
"appropriate",
"interpolator",
"class"
] | python | train | 32.095238 |
materials-data-facility/toolbox | mdf_toolbox/toolbox.py | https://github.com/materials-data-facility/toolbox/blob/2a4ac2b6a892238263008efa6a5f3923d9a83505/mdf_toolbox/toolbox.py#L866-L879 | def get_local_ep(*args, **kwargs):
"""
Warning:
DEPRECATED: Use ``globus_sdk.LocalGlobusConnectPersonal().endpoint_id`` instead.
"""
if kwargs.get("warn", True):
raise DeprecationWarning("'get_local_ep()' has been deprecated in favor of "
"'globus_sdk.Loc... | [
"def",
"get_local_ep",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"warn\"",
",",
"True",
")",
":",
"raise",
"DeprecationWarning",
"(",
"\"'get_local_ep()' has been deprecated in favor of \"",
"\"'globus_sdk.LocalGlobusCon... | Warning:
DEPRECATED: Use ``globus_sdk.LocalGlobusConnectPersonal().endpoint_id`` instead. | [
"Warning",
":",
"DEPRECATED",
":",
"Use",
"globus_sdk",
".",
"LocalGlobusConnectPersonal",
"()",
".",
"endpoint_id",
"instead",
"."
] | python | train | 47.857143 |
aliyun/aliyun-log-python-sdk | aliyun/log/logclient.py | https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/logclient.py#L2390-L2439 | def copy_data(self, project, logstore, from_time, to_time=None,
to_client=None, to_project=None, to_logstore=None,
shard_list=None,
batch_size=None, compress=None, new_topic=None, new_source=None):
"""
copy data from one logstore to another one ... | [
"def",
"copy_data",
"(",
"self",
",",
"project",
",",
"logstore",
",",
"from_time",
",",
"to_time",
"=",
"None",
",",
"to_client",
"=",
"None",
",",
"to_project",
"=",
"None",
",",
"to_logstore",
"=",
"None",
",",
"shard_list",
"=",
"None",
",",
"batch_s... | copy data from one logstore to another one (could be the same or in different region), the time is log received time on server side.
:type project: string
:param project: project name
:type logstore: string
:param logstore: logstore name
:type from_time: string/int
... | [
"copy",
"data",
"from",
"one",
"logstore",
"to",
"another",
"one",
"(",
"could",
"be",
"the",
"same",
"or",
"in",
"different",
"region",
")",
"the",
"time",
"is",
"log",
"received",
"time",
"on",
"server",
"side",
".",
":",
"type",
"project",
":",
"str... | python | train | 53.3 |
inasafe/inasafe | safe/gui/tools/wizard/step_kw20_unit.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw20_unit.py#L63-L77 | def on_lstUnits_itemSelectionChanged(self):
"""Update unit description label and field widgets.
.. note:: This is an automatic Qt slot
executed when the unit selection changes.
"""
self.clear_further_steps()
# Set widgets
unit = self.selected_unit()
# ... | [
"def",
"on_lstUnits_itemSelectionChanged",
"(",
"self",
")",
":",
"self",
".",
"clear_further_steps",
"(",
")",
"# Set widgets",
"unit",
"=",
"self",
".",
"selected_unit",
"(",
")",
"# Exit if no selection",
"if",
"not",
"unit",
":",
"return",
"self",
".",
"lblD... | Update unit description label and field widgets.
.. note:: This is an automatic Qt slot
executed when the unit selection changes. | [
"Update",
"unit",
"description",
"label",
"and",
"field",
"widgets",
"."
] | python | train | 33.466667 |
EricCrosson/stump | stump/stump.py | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L350-L368 | def warning_ret(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Logging
value: warning. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted ... | [
"def",
"warning_ret",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"WARNING",
"}",
")",
"kwargs",
".",
"update",
"(",
"{",
"'print_return'",
":",
"True",
"}",
")",
... | Automatically log progress on function entry and exit. Logging
value: warning. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated ... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
".",
"Logging",
"value",
":",
"warning",
".",
"The",
"function",
"s",
"return",
"value",
"will",
"be",
"included",
"in",
"the",
"logs",
"."
] | python | train | 42.842105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.