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 |
|---|---|---|---|---|---|---|---|---|---|
HewlettPackard/python-hpOneView | hpOneView/resources/resource.py | https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/resource.py#L613-L638 | def build_subresource_uri(self, resource_id_or_uri=None, subresource_id_or_uri=None, subresource_path=''):
"""Helps to build a URI with resource path and its sub resource path.
Args:
resoure_id_or_uri: ID/URI of the main resource.
subresource_id__or_uri: ID/URI of the sub resour... | [
"def",
"build_subresource_uri",
"(",
"self",
",",
"resource_id_or_uri",
"=",
"None",
",",
"subresource_id_or_uri",
"=",
"None",
",",
"subresource_path",
"=",
"''",
")",
":",
"if",
"subresource_id_or_uri",
"and",
"\"/\"",
"in",
"subresource_id_or_uri",
":",
"return",... | Helps to build a URI with resource path and its sub resource path.
Args:
resoure_id_or_uri: ID/URI of the main resource.
subresource_id__or_uri: ID/URI of the sub resource.
subresource_path: Sub resource path to be added with the URI.
Returns:
Returns UR... | [
"Helps",
"to",
"build",
"a",
"URI",
"with",
"resource",
"path",
"and",
"its",
"sub",
"resource",
"path",
"."
] | python | train | 37.153846 |
peterbrittain/asciimatics | asciimatics/widgets.py | https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/widgets.py#L1587-L1595 | def _pick_colours(self, palette_name, selected=False):
"""
Pick the rendering colour for a widget based on the current state.
:param palette_name: The stem name for the widget - e.g. "button".
:param selected: Whether this item is selected or not.
:returns: A colour tuple (fg, a... | [
"def",
"_pick_colours",
"(",
"self",
",",
"palette_name",
",",
"selected",
"=",
"False",
")",
":",
"return",
"self",
".",
"_frame",
".",
"palette",
"[",
"self",
".",
"_pick_palette_key",
"(",
"palette_name",
",",
"selected",
")",
"]"
] | Pick the rendering colour for a widget based on the current state.
:param palette_name: The stem name for the widget - e.g. "button".
:param selected: Whether this item is selected or not.
:returns: A colour tuple (fg, attr, bg) to be used. | [
"Pick",
"the",
"rendering",
"colour",
"for",
"a",
"widget",
"based",
"on",
"the",
"current",
"state",
"."
] | python | train | 47.444444 |
FSX/misaka | misaka/api.py | https://github.com/FSX/misaka/blob/c13aff82d370d606ff61361db79c166a897641cf/misaka/api.py#L96-L125 | def html(text, extensions=0, render_flags=0):
"""
Convert markdown text to HTML.
``extensions`` can be a list or tuple of extensions (e.g.
``('fenced-code', 'footnotes', 'strikethrough')``) or an integer
(e.g. ``EXT_FENCED_CODE | EXT_FOOTNOTES | EXT_STRIKETHROUGH``).
``render_flags`` can be a ... | [
"def",
"html",
"(",
"text",
",",
"extensions",
"=",
"0",
",",
"render_flags",
"=",
"0",
")",
":",
"extensions",
"=",
"args_to_int",
"(",
"extension_map",
",",
"extensions",
")",
"render_flags",
"=",
"args_to_int",
"(",
"html_flag_map",
",",
"render_flags",
"... | Convert markdown text to HTML.
``extensions`` can be a list or tuple of extensions (e.g.
``('fenced-code', 'footnotes', 'strikethrough')``) or an integer
(e.g. ``EXT_FENCED_CODE | EXT_FOOTNOTES | EXT_STRIKETHROUGH``).
``render_flags`` can be a list or tuple of flags (e.g.
``('skip-html', 'hard-wra... | [
"Convert",
"markdown",
"text",
"to",
"HTML",
"."
] | python | train | 35.933333 |
wreckage/django-happenings | happenings/utils/displays.py | https://github.com/wreckage/django-happenings/blob/7bca5576efa6cd4c4e87356bf9e5b8cd538ae91d/happenings/utils/displays.py#L25-L40 | def add_occurrences(events, count):
"""
Adds an occurrence key to the event object w/ a list of occurrences
and adds a popover (for use with twitter bootstrap).
The occurrence is added so that each event can be aware of what
day(s) it occurs in the month.
"""
for day in count:
for it... | [
"def",
"add_occurrences",
"(",
"events",
",",
"count",
")",
":",
"for",
"day",
"in",
"count",
":",
"for",
"item",
"in",
"count",
"[",
"day",
"]",
":",
"for",
"event",
"in",
"events",
":",
"if",
"event",
".",
"pk",
"==",
"item",
"[",
"1",
"]",
":"... | Adds an occurrence key to the event object w/ a list of occurrences
and adds a popover (for use with twitter bootstrap).
The occurrence is added so that each event can be aware of what
day(s) it occurs in the month. | [
"Adds",
"an",
"occurrence",
"key",
"to",
"the",
"event",
"object",
"w",
"/",
"a",
"list",
"of",
"occurrences",
"and",
"adds",
"a",
"popover",
"(",
"for",
"use",
"with",
"twitter",
"bootstrap",
")",
".",
"The",
"occurrence",
"is",
"added",
"so",
"that",
... | python | test | 38.4375 |
gwastro/pycbc | pycbc/workflow/plotting.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/plotting.py#L274-L296 | def make_ifar_plot(workflow, trigger_file, out_dir, tags=None,
hierarchical_level=None):
""" Creates a node in the workflow for plotting cumulative histogram
of IFAR values.
"""
if hierarchical_level is not None and tags:
tags = [("HIERARCHICAL_LEVEL_{:02d}".format(
... | [
"def",
"make_ifar_plot",
"(",
"workflow",
",",
"trigger_file",
",",
"out_dir",
",",
"tags",
"=",
"None",
",",
"hierarchical_level",
"=",
"None",
")",
":",
"if",
"hierarchical_level",
"is",
"not",
"None",
"and",
"tags",
":",
"tags",
"=",
"[",
"(",
"\"HIERAR... | Creates a node in the workflow for plotting cumulative histogram
of IFAR values. | [
"Creates",
"a",
"node",
"in",
"the",
"workflow",
"for",
"plotting",
"cumulative",
"histogram",
"of",
"IFAR",
"values",
"."
] | python | train | 42.478261 |
chrisrink10/basilisp | src/basilisp/lang/runtime.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L920-L931 | def deref(o, timeout_s=None, timeout_val=None):
"""Dereference a Deref object and return its contents.
If o is an object implementing IBlockingDeref and timeout_s and
timeout_val are supplied, deref will wait at most timeout_s seconds,
returning timeout_val if timeout_s seconds elapse and o has not
... | [
"def",
"deref",
"(",
"o",
",",
"timeout_s",
"=",
"None",
",",
"timeout_val",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"IDeref",
")",
":",
"return",
"o",
".",
"deref",
"(",
")",
"elif",
"isinstance",
"(",
"o",
",",
"IBlockingDeref",
... | Dereference a Deref object and return its contents.
If o is an object implementing IBlockingDeref and timeout_s and
timeout_val are supplied, deref will wait at most timeout_s seconds,
returning timeout_val if timeout_s seconds elapse and o has not
returned. | [
"Dereference",
"a",
"Deref",
"object",
"and",
"return",
"its",
"contents",
"."
] | python | test | 44.666667 |
saltstack/salt | salt/states/win_iis.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_iis.py#L480-L573 | def container_setting(name, container, settings=None):
'''
Set the value of the setting for an IIS container.
:param str name: The name of the IIS container.
:param str container: The type of IIS container. The container types are:
AppPools, Sites, SslBindings
:param str settings: A diction... | [
"def",
"container_setting",
"(",
"name",
",",
"container",
",",
"settings",
"=",
"None",
")",
":",
"identityType_map2string",
"=",
"{",
"0",
":",
"'LocalSystem'",
",",
"1",
":",
"'LocalService'",
",",
"2",
":",
"'NetworkService'",
",",
"3",
":",
"'SpecificUs... | Set the value of the setting for an IIS container.
:param str name: The name of the IIS container.
:param str container: The type of IIS container. The container types are:
AppPools, Sites, SslBindings
:param str settings: A dictionary of the setting names and their values.
Example of usage... | [
"Set",
"the",
"value",
"of",
"the",
"setting",
"for",
"an",
"IIS",
"container",
"."
] | python | train | 38.861702 |
google/pybadges | pybadges/precalculate_text.py | https://github.com/google/pybadges/blob/d42c8080adb21b81123ac9540c53127ed2fa1edc/pybadges/precalculate_text.py#L66-L84 | def generate_encodeable_characters(characters: Iterable[str],
encodings: Iterable[str]) -> Iterable[str]:
"""Generates the subset of 'characters' that can be encoded by 'encodings'.
Args:
characters: The characters to check for encodeability e.g. 'abcd'.
encod... | [
"def",
"generate_encodeable_characters",
"(",
"characters",
":",
"Iterable",
"[",
"str",
"]",
",",
"encodings",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"for",
"c",
"in",
"characters",
":",
"for",
"encoding",
"in",
"... | Generates the subset of 'characters' that can be encoded by 'encodings'.
Args:
characters: The characters to check for encodeability e.g. 'abcd'.
encodings: The encodings to check against e.g. ['cp1252', 'iso-8859-5'].
Returns:
The subset of 'characters' that can be encoded using one o... | [
"Generates",
"the",
"subset",
"of",
"characters",
"that",
"can",
"be",
"encoded",
"by",
"encodings",
"."
] | python | test | 36.157895 |
kaniblu/pydumper | dumper/__init__.py | https://github.com/kaniblu/pydumper/blob/ce61b96b09604b52d4bab667ac1862755ca21f3b/dumper/__init__.py#L33-L46 | def load(name, path=None, ext="dat", silent=False):
"""
Loads an object from file with given name and extension.
Optionally the path can be specified as well.
"""
filename = __get_filename(path, name, ext)
if not os.path.exists(filename):
if not silent:
raise ValueException(... | [
"def",
"load",
"(",
"name",
",",
"path",
"=",
"None",
",",
"ext",
"=",
"\"dat\"",
",",
"silent",
"=",
"False",
")",
":",
"filename",
"=",
"__get_filename",
"(",
"path",
",",
"name",
",",
"ext",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
... | Loads an object from file with given name and extension.
Optionally the path can be specified as well. | [
"Loads",
"an",
"object",
"from",
"file",
"with",
"given",
"name",
"and",
"extension",
".",
"Optionally",
"the",
"path",
"can",
"be",
"specified",
"as",
"well",
"."
] | python | train | 31.142857 |
kmerkmer/pymer | pymer/base.py | https://github.com/kmerkmer/pymer/blob/c22802436b3756a2e92829c9b234bde6217b683a/pymer/base.py#L38-L41 | def unconsume(self, seq):
'''Subtracts all k-mers in sequence.'''
for kmer in iter_kmers(seq, self.k, canonical=self.canonical):
self._decr(kmer) | [
"def",
"unconsume",
"(",
"self",
",",
"seq",
")",
":",
"for",
"kmer",
"in",
"iter_kmers",
"(",
"seq",
",",
"self",
".",
"k",
",",
"canonical",
"=",
"self",
".",
"canonical",
")",
":",
"self",
".",
"_decr",
"(",
"kmer",
")"
] | Subtracts all k-mers in sequence. | [
"Subtracts",
"all",
"k",
"-",
"mers",
"in",
"sequence",
"."
] | python | train | 42.5 |
google/python-adb | adb/common_cli.py | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common_cli.py#L146-L164 | def StartCli(args, adb_commands, extra=None, **device_kwargs):
"""Starts a common CLI interface for this usb path and protocol."""
try:
dev = adb_commands()
dev.ConnectDevice(port_path=args.port_path, serial=args.serial, default_timeout_ms=args.timeout_ms,
**device_kwar... | [
"def",
"StartCli",
"(",
"args",
",",
"adb_commands",
",",
"extra",
"=",
"None",
",",
"*",
"*",
"device_kwargs",
")",
":",
"try",
":",
"dev",
"=",
"adb_commands",
"(",
")",
"dev",
".",
"ConnectDevice",
"(",
"port_path",
"=",
"args",
".",
"port_path",
",... | Starts a common CLI interface for this usb path and protocol. | [
"Starts",
"a",
"common",
"CLI",
"interface",
"for",
"this",
"usb",
"path",
"and",
"protocol",
"."
] | python | train | 41 |
PySimpleGUI/PySimpleGUI | DemoPrograms/Demo_Uno_Card_Game.py | https://github.com/PySimpleGUI/PySimpleGUI/blob/08184197f5bd4580ab5e5aca28bdda30f87b86fc/DemoPrograms/Demo_Uno_Card_Game.py#L633-L655 | def setColor(self, color):
'''Sets Card's color and escape code.'''
if color == 'blue':
self.color = 'blue'
self.colorCode = self.colors['blue']
self.colorCodeDark = self.colors['dblue']
elif color == 'red':
self.color = 'red'
self.colo... | [
"def",
"setColor",
"(",
"self",
",",
"color",
")",
":",
"if",
"color",
"==",
"'blue'",
":",
"self",
".",
"color",
"=",
"'blue'",
"self",
".",
"colorCode",
"=",
"self",
".",
"colors",
"[",
"'blue'",
"]",
"self",
".",
"colorCodeDark",
"=",
"self",
".",... | Sets Card's color and escape code. | [
"Sets",
"Card",
"s",
"color",
"and",
"escape",
"code",
"."
] | python | train | 40.782609 |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L23349-L23389 | def create_base_storage(self, logical_size, variant):
"""Starts creating a hard disk storage unit (fixed/dynamic, according
to the variant flags) in the background. The previous storage unit
created for this object, if any, must first be deleted using
:py:func:`delete_storage` , otherwis... | [
"def",
"create_base_storage",
"(",
"self",
",",
"logical_size",
",",
"variant",
")",
":",
"if",
"not",
"isinstance",
"(",
"logical_size",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"logical_size can only be an instance of type baseinteger\"",
")",
"if"... | Starts creating a hard disk storage unit (fixed/dynamic, according
to the variant flags) in the background. The previous storage unit
created for this object, if any, must first be deleted using
:py:func:`delete_storage` , otherwise the operation will fail.
Before the operation ... | [
"Starts",
"creating",
"a",
"hard",
"disk",
"storage",
"unit",
"(",
"fixed",
"/",
"dynamic",
"according",
"to",
"the",
"variant",
"flags",
")",
"in",
"the",
"background",
".",
"The",
"previous",
"storage",
"unit",
"created",
"for",
"this",
"object",
"if",
"... | python | train | 48.414634 |
saltstack/salt | salt/utils/systemd.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L84-L94 | def has_scope(context=None):
'''
Scopes were introduced in systemd 205, this function returns a boolean
which is true when the minion is systemd-booted and running systemd>=205.
'''
if not booted(context):
return False
_sd_version = version(context)
if _sd_version is None:
re... | [
"def",
"has_scope",
"(",
"context",
"=",
"None",
")",
":",
"if",
"not",
"booted",
"(",
"context",
")",
":",
"return",
"False",
"_sd_version",
"=",
"version",
"(",
"context",
")",
"if",
"_sd_version",
"is",
"None",
":",
"return",
"False",
"return",
"_sd_v... | Scopes were introduced in systemd 205, this function returns a boolean
which is true when the minion is systemd-booted and running systemd>=205. | [
"Scopes",
"were",
"introduced",
"in",
"systemd",
"205",
"this",
"function",
"returns",
"a",
"boolean",
"which",
"is",
"true",
"when",
"the",
"minion",
"is",
"systemd",
"-",
"booted",
"and",
"running",
"systemd",
">",
"=",
"205",
"."
] | python | train | 31.818182 |
elehcimd/pynb | fabfile.py | https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/fabfile.py#L99-L110 | def docker_start(develop=True):
"""
Start docker container
"""
curr_dir = os.path.dirname(os.path.realpath(__file__))
local('docker run --rm --name pynb -d -ti -p 127.0.0.1:8889:8888 -v {}:/code -t pynb'.format(curr_dir))
if develop:
# Install package in develop mode: the code in /code... | [
"def",
"docker_start",
"(",
"develop",
"=",
"True",
")",
":",
"curr_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"local",
"(",
"'docker run --rm --name pynb -d -ti -p 127.0.0.1:8889:8888 -v {}... | Start docker container | [
"Start",
"docker",
"container"
] | python | train | 37.5 |
dhilipsiva/orm-choices | orm_choices/core.py | https://github.com/dhilipsiva/orm-choices/blob/e76391722bb761fa81402dcf0668eb0b93b486b3/orm_choices/core.py#L26-L36 | def choices(klass):
"""
Decorator to set `CHOICES` and other attributes
"""
_choices = []
for attr in user_attributes(klass.Meta):
val = getattr(klass.Meta, attr)
setattr(klass, attr, val[0])
_choices.append((val[0], val[1]))
setattr(klass, 'CHOICES', tuple(_choices))
... | [
"def",
"choices",
"(",
"klass",
")",
":",
"_choices",
"=",
"[",
"]",
"for",
"attr",
"in",
"user_attributes",
"(",
"klass",
".",
"Meta",
")",
":",
"val",
"=",
"getattr",
"(",
"klass",
".",
"Meta",
",",
"attr",
")",
"setattr",
"(",
"klass",
",",
"att... | Decorator to set `CHOICES` and other attributes | [
"Decorator",
"to",
"set",
"CHOICES",
"and",
"other",
"attributes"
] | python | train | 29.363636 |
Ezhil-Language-Foundation/open-tamil | solthiruthi/typographical.py | https://github.com/Ezhil-Language-Foundation/open-tamil/blob/b7556e88878d29bbc6c944ee17cdd3f75b8ea9f0/solthiruthi/typographical.py#L20-L48 | def oridam_generate_patterns(word_in,cm,ed=1,level=0,pos=0,candidates=None):
""" ed = 1 by default, pos - internal variable for algorithm """
alternates = cm.get(word_in[pos],[])
if not candidates:
candidates = []
assert ed <= len(word_in), 'edit distance has to be comparable to word size [ins/d... | [
"def",
"oridam_generate_patterns",
"(",
"word_in",
",",
"cm",
",",
"ed",
"=",
"1",
",",
"level",
"=",
"0",
",",
"pos",
"=",
"0",
",",
"candidates",
"=",
"None",
")",
":",
"alternates",
"=",
"cm",
".",
"get",
"(",
"word_in",
"[",
"pos",
"]",
",",
... | ed = 1 by default, pos - internal variable for algorithm | [
"ed",
"=",
"1",
"by",
"default",
"pos",
"-",
"internal",
"variable",
"for",
"algorithm"
] | python | train | 40.758621 |
Duke-GCB/lando-messaging | lando_messaging/workqueue.py | https://github.com/Duke-GCB/lando-messaging/blob/b90ccc79a874714e0776af8badf505bb2b56c0ec/lando_messaging/workqueue.py#L127-L138 | def receive_loop_with_callback(self, queue_name, callback):
"""
Process incoming messages with callback until close is called.
:param queue_name: str: name of the queue to poll
:param callback: func(ch, method, properties, body) called with data when data arrives
:return:
... | [
"def",
"receive_loop_with_callback",
"(",
"self",
",",
"queue_name",
",",
"callback",
")",
":",
"self",
".",
"connect",
"(",
")",
"channel",
"=",
"self",
".",
"create_channel",
"(",
"queue_name",
")",
"channel",
".",
"basic_qos",
"(",
"prefetch_count",
"=",
... | Process incoming messages with callback until close is called.
:param queue_name: str: name of the queue to poll
:param callback: func(ch, method, properties, body) called with data when data arrives
:return: | [
"Process",
"incoming",
"messages",
"with",
"callback",
"until",
"close",
"is",
"called",
".",
":",
"param",
"queue_name",
":",
"str",
":",
"name",
"of",
"the",
"queue",
"to",
"poll",
":",
"param",
"callback",
":",
"func",
"(",
"ch",
"method",
"properties",... | python | train | 43.5 |
hydraplatform/hydra-base | hydra_base/lib/network.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/network.py#L577-L652 | def _get_all_resource_attributes(network_id, template_id=None):
"""
Get all the attributes for the nodes, links and groups of a network.
Return these attributes as a dictionary, keyed on type (NODE, LINK, GROUP)
then by ID of the node or link.
"""
base_qry = db.DBSession.query(
... | [
"def",
"_get_all_resource_attributes",
"(",
"network_id",
",",
"template_id",
"=",
"None",
")",
":",
"base_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
"(",
"ResourceAttr",
".",
"id",
".",
"label",
"(",
"'id'",
")",
",",
"ResourceAttr",
".",
"ref_key",
... | Get all the attributes for the nodes, links and groups of a network.
Return these attributes as a dictionary, keyed on type (NODE, LINK, GROUP)
then by ID of the node or link. | [
"Get",
"all",
"the",
"attributes",
"for",
"the",
"nodes",
"links",
"and",
"groups",
"of",
"a",
"network",
".",
"Return",
"these",
"attributes",
"as",
"a",
"dictionary",
"keyed",
"on",
"type",
"(",
"NODE",
"LINK",
"GROUP",
")",
"then",
"by",
"ID",
"of",
... | python | train | 52.315789 |
SwissDataScienceCenter/renku-python | renku/cli/rerun.py | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/rerun.py#L134-L187 | def rerun(client, revision, roots, siblings, inputs, paths):
"""Recreate files generated by a sequence of ``run`` commands."""
graph = Graph(client)
outputs = graph.build(paths=paths, revision=revision)
# Check or extend siblings of outputs.
outputs = siblings(graph, outputs)
output_paths = {no... | [
"def",
"rerun",
"(",
"client",
",",
"revision",
",",
"roots",
",",
"siblings",
",",
"inputs",
",",
"paths",
")",
":",
"graph",
"=",
"Graph",
"(",
"client",
")",
"outputs",
"=",
"graph",
".",
"build",
"(",
"paths",
"=",
"paths",
",",
"revision",
"=",
... | Recreate files generated by a sequence of ``run`` commands. | [
"Recreate",
"files",
"generated",
"by",
"a",
"sequence",
"of",
"run",
"commands",
"."
] | python | train | 31.666667 |
pylast/pylast | src/pylast/__init__.py | https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L496-L503 | def get_track_by_mbid(self, mbid):
"""Looks up a track by its MusicBrainz ID"""
params = {"mbid": mbid}
doc = _Request(self, "track.getInfo", params).execute(True)
return Track(_extract(doc, "name", 1), _extract(doc, "name"), self) | [
"def",
"get_track_by_mbid",
"(",
"self",
",",
"mbid",
")",
":",
"params",
"=",
"{",
"\"mbid\"",
":",
"mbid",
"}",
"doc",
"=",
"_Request",
"(",
"self",
",",
"\"track.getInfo\"",
",",
"params",
")",
".",
"execute",
"(",
"True",
")",
"return",
"Track",
"(... | Looks up a track by its MusicBrainz ID | [
"Looks",
"up",
"a",
"track",
"by",
"its",
"MusicBrainz",
"ID"
] | python | train | 32.375 |
jupyter-widgets/ipyleaflet | ipyleaflet/xarray_ds.py | https://github.com/jupyter-widgets/ipyleaflet/blob/74488d4699a5663fc28aabf94ebf08d956a30598/ipyleaflet/xarray_ds.py#L11-L106 | def ds2json(ds, u_var, v_var, lat_dim='latitude', lon_dim='longitude', units=None):
"""
Assumes that the velocity components are given on a regular grid
(fixed spacing in latitude and longitude).
Parameters
----------
u_var : str
Name of the U-component (zonal) variable.
v_var : str... | [
"def",
"ds2json",
"(",
"ds",
",",
"u_var",
",",
"v_var",
",",
"lat_dim",
"=",
"'latitude'",
",",
"lon_dim",
"=",
"'longitude'",
",",
"units",
"=",
"None",
")",
":",
"import",
"numpy",
"as",
"np",
"ds",
"=",
"ds",
".",
"copy",
"(",
")",
"for",
"var_... | Assumes that the velocity components are given on a regular grid
(fixed spacing in latitude and longitude).
Parameters
----------
u_var : str
Name of the U-component (zonal) variable.
v_var : str
Name of the V-component (meridional) variable.
lat_dim : str, optional
Name... | [
"Assumes",
"that",
"the",
"velocity",
"components",
"are",
"given",
"on",
"a",
"regular",
"grid",
"(",
"fixed",
"spacing",
"in",
"latitude",
"and",
"longitude",
")",
"."
] | python | train | 31.0625 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L159-L163 | def is_executable(path):
'''is the given path executable?'''
return (stat.S_IXUSR & os.stat(path)[stat.ST_MODE]
or stat.S_IXGRP & os.stat(path)[stat.ST_MODE]
or stat.S_IXOTH & os.stat(path)[stat.ST_MODE]) | [
"def",
"is_executable",
"(",
"path",
")",
":",
"return",
"(",
"stat",
".",
"S_IXUSR",
"&",
"os",
".",
"stat",
"(",
"path",
")",
"[",
"stat",
".",
"ST_MODE",
"]",
"or",
"stat",
".",
"S_IXGRP",
"&",
"os",
".",
"stat",
"(",
"path",
")",
"[",
"stat",... | is the given path executable? | [
"is",
"the",
"given",
"path",
"executable?"
] | python | train | 46.4 |
mickbad/mblibs | mblibs/fast.py | https://github.com/mickbad/mblibs/blob/c1f423ef107c94e2ab6bd253e9148f6056e0ef75/mblibs/fast.py#L781-L793 | def run(self):
""" Fonctionnement du thread """
if self.debug:
print("Starting " + self.name)
# Lancement du programme du thread
if isinstance(self.function, str):
globals()[self.function](*self.args, **self.kwargs)
else:
self.function(*self.args, **self.kwargs)
if self.debug:
print("Exiting "... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"debug",
":",
"print",
"(",
"\"Starting \"",
"+",
"self",
".",
"name",
")",
"# Lancement du programme du thread",
"if",
"isinstance",
"(",
"self",
".",
"function",
",",
"str",
")",
":",
"globals",
"... | Fonctionnement du thread | [
"Fonctionnement",
"du",
"thread"
] | python | train | 24.692308 |
nirum/descent | descent/proxops.py | https://github.com/nirum/descent/blob/074c8452f15a0da638668a4fe139fde06ccfae7f/descent/proxops.py#L186-L219 | def smooth(x, rho, penalty, axis=0, newshape=None):
"""
Applies a smoothing operator along one dimension
currently only accepts a matrix as input
Parameters
----------
penalty : float
axis : int, optional
Axis along which to apply the smoothing (Default: 0)
newshape : tuple, ... | [
"def",
"smooth",
"(",
"x",
",",
"rho",
",",
"penalty",
",",
"axis",
"=",
"0",
",",
"newshape",
"=",
"None",
")",
":",
"orig_shape",
"=",
"x",
".",
"shape",
"if",
"newshape",
"is",
"not",
"None",
":",
"x",
"=",
"x",
".",
"reshape",
"(",
"newshape"... | Applies a smoothing operator along one dimension
currently only accepts a matrix as input
Parameters
----------
penalty : float
axis : int, optional
Axis along which to apply the smoothing (Default: 0)
newshape : tuple, optional
Desired shape of the parameters to apply the nu... | [
"Applies",
"a",
"smoothing",
"operator",
"along",
"one",
"dimension"
] | python | valid | 30 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_processor.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_processor.py#L242-L247 | def _output(self, file_like_object, path=None):
"""Display or save file like object."""
if not path:
self._output_to_display(file_like_object)
else:
self._output_to_file(file_like_object, path) | [
"def",
"_output",
"(",
"self",
",",
"file_like_object",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"path",
":",
"self",
".",
"_output_to_display",
"(",
"file_like_object",
")",
"else",
":",
"self",
".",
"_output_to_file",
"(",
"file_like_object",
",",
... | Display or save file like object. | [
"Display",
"or",
"save",
"file",
"like",
"object",
"."
] | python | train | 39.333333 |
saltstack/salt | salt/modules/bcache.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bcache.py#L451-L561 | def device(dev, stats=False, config=False, internals=False, superblock=False):
'''
Check the state of a single bcache device
CLI example:
.. code-block:: bash
salt '*' bcache.device bcache0
salt '*' bcache.device /dev/sdc stats=True
:param stats: include statistics
:param set... | [
"def",
"device",
"(",
"dev",
",",
"stats",
"=",
"False",
",",
"config",
"=",
"False",
",",
"internals",
"=",
"False",
",",
"superblock",
"=",
"False",
")",
":",
"result",
"=",
"{",
"}",
"if",
"not",
"_sysfs_attr",
"(",
"_bcpath",
"(",
"dev",
")",
"... | Check the state of a single bcache device
CLI example:
.. code-block:: bash
salt '*' bcache.device bcache0
salt '*' bcache.device /dev/sdc stats=True
:param stats: include statistics
:param settings: include all settings
:param internals: include all internals
:param superblo... | [
"Check",
"the",
"state",
"of",
"a",
"single",
"bcache",
"device"
] | python | train | 35.720721 |
apple/turicreate | src/unity/python/turicreate/_gl_pickle.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/_gl_pickle.py#L33-L50 | def _is_not_pickle_safe_gl_model_class(obj_class):
"""
Check if a Turi create model is pickle safe.
The function does it by checking that _CustomModel is the base class.
Parameters
----------
obj_class : Class to be checked.
Returns
----------
True if the GLC class is a model a... | [
"def",
"_is_not_pickle_safe_gl_model_class",
"(",
"obj_class",
")",
":",
"if",
"issubclass",
"(",
"obj_class",
",",
"_toolkits",
".",
"_model",
".",
"CustomModel",
")",
":",
"return",
"not",
"obj_class",
".",
"_is_gl_pickle_safe",
"(",
")",
"return",
"False"
] | Check if a Turi create model is pickle safe.
The function does it by checking that _CustomModel is the base class.
Parameters
----------
obj_class : Class to be checked.
Returns
----------
True if the GLC class is a model and is pickle safe. | [
"Check",
"if",
"a",
"Turi",
"create",
"model",
"is",
"pickle",
"safe",
"."
] | python | train | 25.388889 |
Clinical-Genomics/scout | scout/build/variant/clnsig.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/build/variant/clnsig.py#L2-L10 | def build_clnsig(clnsig_info):
"""docstring for build_clnsig"""
clnsig_obj = dict(
value = clnsig_info['value'],
accession = clnsig_info.get('accession'),
revstat = clnsig_info.get('revstat')
)
return clnsig_obj | [
"def",
"build_clnsig",
"(",
"clnsig_info",
")",
":",
"clnsig_obj",
"=",
"dict",
"(",
"value",
"=",
"clnsig_info",
"[",
"'value'",
"]",
",",
"accession",
"=",
"clnsig_info",
".",
"get",
"(",
"'accession'",
")",
",",
"revstat",
"=",
"clnsig_info",
".",
"get"... | docstring for build_clnsig | [
"docstring",
"for",
"build_clnsig"
] | python | test | 27.555556 |
senaite/senaite.core | bika/lims/browser/analysisrequest/add2.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analysisrequest/add2.py#L988-L993 | def get_method_info(self, obj):
"""Returns the info for a Method
"""
info = self.get_base_info(obj)
info.update({})
return info | [
"def",
"get_method_info",
"(",
"self",
",",
"obj",
")",
":",
"info",
"=",
"self",
".",
"get_base_info",
"(",
"obj",
")",
"info",
".",
"update",
"(",
"{",
"}",
")",
"return",
"info"
] | Returns the info for a Method | [
"Returns",
"the",
"info",
"for",
"a",
"Method"
] | python | train | 27 |
santosjorge/cufflinks | cufflinks/datagen.py | https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/datagen.py#L173-L197 | def lines(n_traces=5,n=100,columns=None,dateIndex=True,mode=None):
"""
Returns a DataFrame with the required format for
a scatter (lines) plot
Parameters:
-----------
n_traces : int
Number of traces
n : int
Number of points for each trace
columns : [str]
List of column names
dateIndex : bool
... | [
"def",
"lines",
"(",
"n_traces",
"=",
"5",
",",
"n",
"=",
"100",
",",
"columns",
"=",
"None",
",",
"dateIndex",
"=",
"True",
",",
"mode",
"=",
"None",
")",
":",
"index",
"=",
"pd",
".",
"date_range",
"(",
"'1/1/15'",
",",
"periods",
"=",
"n",
")"... | Returns a DataFrame with the required format for
a scatter (lines) plot
Parameters:
-----------
n_traces : int
Number of traces
n : int
Number of points for each trace
columns : [str]
List of column names
dateIndex : bool
If True it will return a datetime index
if False it will return a enu... | [
"Returns",
"a",
"DataFrame",
"with",
"the",
"required",
"format",
"for",
"a",
"scatter",
"(",
"lines",
")",
"plot"
] | python | train | 28.08 |
quantmind/pulsar | examples/helloworld/manage.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/examples/helloworld/manage.py#L36-L39 | def server(description=None, **kwargs):
'''Create the :class:`.WSGIServer` running :func:`hello`.'''
description = description or 'Pulsar Hello World Application'
return wsgi.WSGIServer(hello, description=description, **kwargs) | [
"def",
"server",
"(",
"description",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"description",
"=",
"description",
"or",
"'Pulsar Hello World Application'",
"return",
"wsgi",
".",
"WSGIServer",
"(",
"hello",
",",
"description",
"=",
"description",
",",
"*... | Create the :class:`.WSGIServer` running :func:`hello`. | [
"Create",
"the",
":",
"class",
":",
".",
"WSGIServer",
"running",
":",
"func",
":",
"hello",
"."
] | python | train | 59 |
googledatalab/pydatalab | google/datalab/bigquery/_query.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/bigquery/_query.py#L230-L322 | def execute_async(self, output_options=None, sampling=None, context=None, query_params=None):
""" Initiate the query and return a QueryJob.
Args:
output_options: a QueryOutput object describing how to execute the query
sampling: sampling function to use. No sampling is done if None. See bigquery.Sa... | [
"def",
"execute_async",
"(",
"self",
",",
"output_options",
"=",
"None",
",",
"sampling",
"=",
"None",
",",
"context",
"=",
"None",
",",
"query_params",
"=",
"None",
")",
":",
"# Default behavior is to execute to a table",
"if",
"output_options",
"is",
"None",
"... | Initiate the query and return a QueryJob.
Args:
output_options: a QueryOutput object describing how to execute the query
sampling: sampling function to use. No sampling is done if None. See bigquery.Sampling
context: an optional Context object providing project_id and credentials. If a specific
... | [
"Initiate",
"the",
"query",
"and",
"return",
"a",
"QueryJob",
"."
] | python | train | 44.408602 |
annoviko/pyclustering | pyclustering/core/som_wrapper.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/core/som_wrapper.py#L174-L188 | def som_get_capture_objects(som_pointer):
"""!
@brief Returns list of indexes of captured objects by each neuron.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map.
"""
ccore = ccore_library.get()
ccore.som_get_capture_objects.restype = POI... | [
"def",
"som_get_capture_objects",
"(",
"som_pointer",
")",
":",
"ccore",
"=",
"ccore_library",
".",
"get",
"(",
")",
"ccore",
".",
"som_get_capture_objects",
".",
"restype",
"=",
"POINTER",
"(",
"pyclustering_package",
")",
"package",
"=",
"ccore",
".",
"som_get... | !
@brief Returns list of indexes of captured objects by each neuron.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map. | [
"!"
] | python | valid | 31.066667 |
gwastro/pycbc | pycbc/inference/models/base.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/models/base.py#L439-L460 | def get_current_stats(self, names=None):
"""Return one or more of the current stats as a tuple.
This function does no computation. It only returns what has already
been calculated. If a stat hasn't been calculated, it will be returned
as ``numpy.nan``.
Parameters
------... | [
"def",
"get_current_stats",
"(",
"self",
",",
"names",
"=",
"None",
")",
":",
"if",
"names",
"is",
"None",
":",
"names",
"=",
"self",
".",
"default_stats",
"return",
"self",
".",
"_current_stats",
".",
"getstats",
"(",
"names",
")"
] | Return one or more of the current stats as a tuple.
This function does no computation. It only returns what has already
been calculated. If a stat hasn't been calculated, it will be returned
as ``numpy.nan``.
Parameters
----------
names : list of str, optional
... | [
"Return",
"one",
"or",
"more",
"of",
"the",
"current",
"stats",
"as",
"a",
"tuple",
"."
] | python | train | 35.090909 |
kylejusticemagnuson/pyti | pyti/detrended_price_oscillator.py | https://github.com/kylejusticemagnuson/pyti/blob/2f78430dfd60a0d20f4e7fc0cb4588c03107c4b2/pyti/detrended_price_oscillator.py#L8-L19 | def detrended_price_oscillator(data, period):
"""
Detrended Price Oscillator.
Formula:
DPO = DATA[i] - Avg(DATA[period/2 + 1])
"""
catch_errors.check_for_period_error(data, period)
period = int(period)
dop = [data[idx] - np.mean(data[idx+1-(int(period/2)+1):idx+1]) for idx in range(peri... | [
"def",
"detrended_price_oscillator",
"(",
"data",
",",
"period",
")",
":",
"catch_errors",
".",
"check_for_period_error",
"(",
"data",
",",
"period",
")",
"period",
"=",
"int",
"(",
"period",
")",
"dop",
"=",
"[",
"data",
"[",
"idx",
"]",
"-",
"np",
".",... | Detrended Price Oscillator.
Formula:
DPO = DATA[i] - Avg(DATA[period/2 + 1]) | [
"Detrended",
"Price",
"Oscillator",
"."
] | python | train | 32.5 |
google/grr | grr/server/grr_response_server/databases/mem_cronjobs.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_cronjobs.py#L23-L41 | def ReadCronJobs(self, cronjob_ids=None):
"""Reads a cronjob from the database."""
if cronjob_ids is None:
res = [job.Copy() for job in itervalues(self.cronjobs)]
else:
res = []
for job_id in cronjob_ids:
try:
res.append(self.cronjobs[job_id].Copy())
except KeyEr... | [
"def",
"ReadCronJobs",
"(",
"self",
",",
"cronjob_ids",
"=",
"None",
")",
":",
"if",
"cronjob_ids",
"is",
"None",
":",
"res",
"=",
"[",
"job",
".",
"Copy",
"(",
")",
"for",
"job",
"in",
"itervalues",
"(",
"self",
".",
"cronjobs",
")",
"]",
"else",
... | Reads a cronjob from the database. | [
"Reads",
"a",
"cronjob",
"from",
"the",
"database",
"."
] | python | train | 30.631579 |
genialis/resolwe | resolwe/flow/execution_engines/workflow/__init__.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/workflow/__init__.py#L85-L156 | def evaluate(self, data):
"""Evaluate the code needed to compute a given Data object."""
expression_engine = data.process.requirements.get('expression-engine', None)
if expression_engine is not None:
expression_engine = self.get_expression_engine(expression_engine)
# Parse s... | [
"def",
"evaluate",
"(",
"self",
",",
"data",
")",
":",
"expression_engine",
"=",
"data",
".",
"process",
".",
"requirements",
".",
"get",
"(",
"'expression-engine'",
",",
"None",
")",
"if",
"expression_engine",
"is",
"not",
"None",
":",
"expression_engine",
... | Evaluate the code needed to compute a given Data object. | [
"Evaluate",
"the",
"code",
"needed",
"to",
"compute",
"a",
"given",
"Data",
"object",
"."
] | python | train | 36.208333 |
elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L121-L150 | def document(self, document):
"""
Associate a :class:`~elasticsearch_dsl.Document` subclass with an index.
This means that, when this index is created, it will contain the
mappings for the ``Document``. If the ``Document`` class doesn't have a
default index yet (by defining ``cla... | [
"def",
"document",
"(",
"self",
",",
"document",
")",
":",
"self",
".",
"_doc_types",
".",
"append",
"(",
"document",
")",
"# If the document index does not have any name, that means the user",
"# did not set any index already to the document.",
"# So set this index as document i... | Associate a :class:`~elasticsearch_dsl.Document` subclass with an index.
This means that, when this index is created, it will contain the
mappings for the ``Document``. If the ``Document`` class doesn't have a
default index yet (by defining ``class Index``), this instance will be
used. C... | [
"Associate",
"a",
":",
"class",
":",
"~elasticsearch_dsl",
".",
"Document",
"subclass",
"with",
"an",
"index",
".",
"This",
"means",
"that",
"when",
"this",
"index",
"is",
"created",
"it",
"will",
"contain",
"the",
"mappings",
"for",
"the",
"Document",
".",
... | python | train | 35.2 |
jtwhite79/pyemu | pyemu/la.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/la.py#L1058-L1078 | def get_cso_dataframe(self):
"""
get a dataframe of composite observation sensitivity, as returned by PEST in the
seo file.
Note that this formulation deviates slightly from the PEST documentation in that the
values are divided by (npar-1) rather than by (npar).
The equ... | [
"def",
"get_cso_dataframe",
"(",
"self",
")",
":",
"assert",
"self",
".",
"jco",
"is",
"not",
"None",
"assert",
"self",
".",
"pst",
"is",
"not",
"None",
"weights",
"=",
"self",
".",
"pst",
".",
"observation_data",
".",
"loc",
"[",
"self",
".",
"jco",
... | get a dataframe of composite observation sensitivity, as returned by PEST in the
seo file.
Note that this formulation deviates slightly from the PEST documentation in that the
values are divided by (npar-1) rather than by (npar).
The equation is cso_j = ((Q^1/2*J*J^T*Q^1/2)^1/2)_jj/(NP... | [
"get",
"a",
"dataframe",
"of",
"composite",
"observation",
"sensitivity",
"as",
"returned",
"by",
"PEST",
"in",
"the",
"seo",
"file",
"."
] | python | train | 42.095238 |
rmorshea/spectate | spectate/core.py | https://github.com/rmorshea/spectate/blob/79bd84dd8d00889015ce1d1e190db865a02cdb93/spectate/core.py#L311-L341 | def watch(value, spectator_type=Spectator):
"""Register a :class:`Specatator` to a :class:`Watchable` and return it.
In order to register callbacks to an eventful object, you need to create
a Spectator that will watch it for you. A :class:`Specatator` is a relatively simple
object that has methods for ... | [
"def",
"watch",
"(",
"value",
",",
"spectator_type",
"=",
"Spectator",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Watchable",
")",
":",
"wtype",
"=",
"type",
"(",
"value",
")",
"else",
":",
"raise",
"TypeError",
"(",
"\"Expected a Watchable, not %r.\"... | Register a :class:`Specatator` to a :class:`Watchable` and return it.
In order to register callbacks to an eventful object, you need to create
a Spectator that will watch it for you. A :class:`Specatator` is a relatively simple
object that has methods for adding, deleting, and triggering callbacks. To
... | [
"Register",
"a",
":",
"class",
":",
"Specatator",
"to",
"a",
":",
"class",
":",
"Watchable",
"and",
"return",
"it",
"."
] | python | train | 36.870968 |
the01/python-paps | examples/measure/echo_server.py | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/measure/echo_server.py#L56-L75 | def create(host, port):
"""
Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None
"""
wrapper = WrapperEchoServer({
'server': None
})
d = {
'listen_port': port,
'changer': wrapper
}
if host:
... | [
"def",
"create",
"(",
"host",
",",
"port",
")",
":",
"wrapper",
"=",
"WrapperEchoServer",
"(",
"{",
"'server'",
":",
"None",
"}",
")",
"d",
"=",
"{",
"'listen_port'",
":",
"port",
",",
"'changer'",
":",
"wrapper",
"}",
"if",
"host",
":",
"d",
"[",
... | Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None | [
"Prepare",
"server",
"to",
"execute"
] | python | train | 20.8 |
Dallinger/Dallinger | dallinger/command_line.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/command_line.py#L343-L350 | def dallinger():
"""Dallinger command-line utility."""
from logging.config import fileConfig
fileConfig(
os.path.join(os.path.dirname(__file__), "logging.ini"),
disable_existing_loggers=False,
) | [
"def",
"dallinger",
"(",
")",
":",
"from",
"logging",
".",
"config",
"import",
"fileConfig",
"fileConfig",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"logging.ini\"",
")",
",",
"disable_exist... | Dallinger command-line utility. | [
"Dallinger",
"command",
"-",
"line",
"utility",
"."
] | python | train | 27.5 |
saltstack/salt | salt/states/modjk_worker.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/modjk_worker.py#L220-L241 | def disable(name, lbn, target, profile='default', tgt_type='glob'):
'''
.. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Disable the named worker from the lbn load balancers at the targeted
minions. The wo... | [
"def",
"disable",
"(",
"name",
",",
"lbn",
",",
"target",
",",
"profile",
"=",
"'default'",
",",
"tgt_type",
"=",
"'glob'",
")",
":",
"return",
"_talk2modjk",
"(",
"name",
",",
"lbn",
",",
"target",
",",
"'worker_disable'",
",",
"profile",
",",
"tgt_type... | .. versionchanged:: 2017.7.0
The ``expr_form`` argument has been renamed to ``tgt_type``, earlier
releases must use ``expr_form``.
Disable the named worker from the lbn load balancers at the targeted
minions. The worker will get traffic only for current sessions and won't
get new ones.
... | [
"..",
"versionchanged",
"::",
"2017",
".",
"7",
".",
"0",
"The",
"expr_form",
"argument",
"has",
"been",
"renamed",
"to",
"tgt_type",
"earlier",
"releases",
"must",
"use",
"expr_form",
"."
] | python | train | 32 |
mathandy/svgpathtools | svgpathtools/document.py | https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/document.py#L324-L338 | def add_group(self, group_attribs=None, parent=None):
"""Add an empty group element to the SVG."""
if parent is None:
parent = self.tree.getroot()
elif not self.contains_group(parent):
warnings.warn('The requested group {0} does not belong to '
'... | [
"def",
"add_group",
"(",
"self",
",",
"group_attribs",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"None",
":",
"parent",
"=",
"self",
".",
"tree",
".",
"getroot",
"(",
")",
"elif",
"not",
"self",
".",
"contains_group",
"... | Add an empty group element to the SVG. | [
"Add",
"an",
"empty",
"group",
"element",
"to",
"the",
"SVG",
"."
] | python | train | 37.933333 |
camsci/meteor-pi | src/pythonModules/meteorpi_client/meteorpi_client/__init__.py | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L69-L76 | def list_observatories(self):
"""
Get the IDs of all observatories with have stored observations on this server.
:return: a sequence of strings containing observatories IDs
"""
response = requests.get(self.base_url + '/obstories').text
return safe_load(response) | [
"def",
"list_observatories",
"(",
"self",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"base_url",
"+",
"'/obstories'",
")",
".",
"text",
"return",
"safe_load",
"(",
"response",
")"
] | Get the IDs of all observatories with have stored observations on this server.
:return: a sequence of strings containing observatories IDs | [
"Get",
"the",
"IDs",
"of",
"all",
"observatories",
"with",
"have",
"stored",
"observations",
"on",
"this",
"server",
"."
] | python | train | 38 |
saltstack/salt | salt/modules/rbenv.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/rbenv.py#L413-L442 | def do_with_ruby(ruby, cmdline, runas=None):
'''
Execute a ruby command with rbenv's shims using a specific ruby version
CLI Example:
.. code-block:: bash
salt '*' rbenv.do_with_ruby 2.0.0-p0 'gem list bundler'
salt '*' rbenv.do_with_ruby 2.0.0-p0 'gem list bundler' runas=deploy
'... | [
"def",
"do_with_ruby",
"(",
"ruby",
",",
"cmdline",
",",
"runas",
"=",
"None",
")",
":",
"if",
"not",
"cmdline",
":",
"# This is a positional argument so this should never happen, but this",
"# will handle cases where someone explicitly passes a false value for",
"# cmdline.",
... | Execute a ruby command with rbenv's shims using a specific ruby version
CLI Example:
.. code-block:: bash
salt '*' rbenv.do_with_ruby 2.0.0-p0 'gem list bundler'
salt '*' rbenv.do_with_ruby 2.0.0-p0 'gem list bundler' runas=deploy | [
"Execute",
"a",
"ruby",
"command",
"with",
"rbenv",
"s",
"shims",
"using",
"a",
"specific",
"ruby",
"version"
] | python | train | 29.066667 |
bitprophet/ssh | setup_helper.py | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/setup_helper.py#L34-L89 | def make_tarball(base_name, base_dir, compress='gzip',
verbose=False, dry_run=False):
"""Create a tar file from all the files under 'base_dir'.
This file may be compressed.
:param compress: Compression algorithms. Supported algorithms are:
'gzip': (the default)
'compress'
... | [
"def",
"make_tarball",
"(",
"base_name",
",",
"base_dir",
",",
"compress",
"=",
"'gzip'",
",",
"verbose",
"=",
"False",
",",
"dry_run",
"=",
"False",
")",
":",
"# XXX GNU tar 1.13 has a nifty option to add a prefix directory.",
"# It's pretty new, though, so we certainly ca... | Create a tar file from all the files under 'base_dir'.
This file may be compressed.
:param compress: Compression algorithms. Supported algorithms are:
'gzip': (the default)
'compress'
'bzip2'
None
For 'gzip' and 'bzip2' the internal tarfile module will be used.
For 'comp... | [
"Create",
"a",
"tar",
"file",
"from",
"all",
"the",
"files",
"under",
"base_dir",
".",
"This",
"file",
"may",
"be",
"compressed",
"."
] | python | train | 39.875 |
skelsec/minidump | minidump/minidumpreader.py | https://github.com/skelsec/minidump/blob/0c4dcabe6f11d7a403440919ffa9e3c9889c5212/minidump/minidumpreader.py#L118-L139 | def read(self, size = -1):
"""
Returns data bytes of size size from the current segment. If size is -1 it returns all the remaining data bytes from memory segment
"""
if size < -1:
raise Exception('You shouldnt be doing this')
if size == -1:
t = self.current_segment.remaining_len(self.current_position)
... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"size",
"<",
"-",
"1",
":",
"raise",
"Exception",
"(",
"'You shouldnt be doing this'",
")",
"if",
"size",
"==",
"-",
"1",
":",
"t",
"=",
"self",
".",
"current_segment",
".",
"r... | Returns data bytes of size size from the current segment. If size is -1 it returns all the remaining data bytes from memory segment | [
"Returns",
"data",
"bytes",
"of",
"size",
"size",
"from",
"the",
"current",
"segment",
".",
"If",
"size",
"is",
"-",
"1",
"it",
"returns",
"all",
"the",
"remaining",
"data",
"bytes",
"from",
"memory",
"segment"
] | python | train | 38.681818 |
lensacom/sparkit-learn | splearn/feature_extraction/text.py | https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_extraction/text.py#L169-L197 | def _count_vocab(self, analyzed_docs):
"""Create sparse feature matrix, and vocabulary where fixed_vocab=False
"""
vocabulary = self.vocabulary_
j_indices = _make_int_array()
indptr = _make_int_array()
indptr.append(0)
for doc in analyzed_docs:
for fea... | [
"def",
"_count_vocab",
"(",
"self",
",",
"analyzed_docs",
")",
":",
"vocabulary",
"=",
"self",
".",
"vocabulary_",
"j_indices",
"=",
"_make_int_array",
"(",
")",
"indptr",
"=",
"_make_int_array",
"(",
")",
"indptr",
".",
"append",
"(",
"0",
")",
"for",
"do... | Create sparse feature matrix, and vocabulary where fixed_vocab=False | [
"Create",
"sparse",
"feature",
"matrix",
"and",
"vocabulary",
"where",
"fixed_vocab",
"=",
"False"
] | python | test | 33.965517 |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/emit_match.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L21-L50 | def _first_step_to_match(match_step):
"""Transform the very first MATCH step into a MATCH query string."""
parts = []
if match_step.root_block is not None:
if not isinstance(match_step.root_block, QueryRoot):
raise AssertionError(u'Expected None or QueryRoot root block, received: '
... | [
"def",
"_first_step_to_match",
"(",
"match_step",
")",
":",
"parts",
"=",
"[",
"]",
"if",
"match_step",
".",
"root_block",
"is",
"not",
"None",
":",
"if",
"not",
"isinstance",
"(",
"match_step",
".",
"root_block",
",",
"QueryRoot",
")",
":",
"raise",
"Asse... | Transform the very first MATCH step into a MATCH query string. | [
"Transform",
"the",
"very",
"first",
"MATCH",
"step",
"into",
"a",
"MATCH",
"query",
"string",
"."
] | python | train | 43.933333 |
MartinThoma/hwrt | hwrt/create_ffiles.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/create_ffiles.py#L62-L85 | def _create_translation_file(feature_folder,
dataset_name,
translation,
formula_id2index):
"""
Write a loop-up file that contains the direct (record-wise) lookup
information.
Parameters
----------
feature_fol... | [
"def",
"_create_translation_file",
"(",
"feature_folder",
",",
"dataset_name",
",",
"translation",
",",
"formula_id2index",
")",
":",
"translationfilename",
"=",
"\"%s/translation-%s.csv\"",
"%",
"(",
"feature_folder",
",",
"dataset_name",
")",
"with",
"open",
"(",
"t... | Write a loop-up file that contains the direct (record-wise) lookup
information.
Parameters
----------
feature_folder :
Path to the feature files.
dataset_name :
'traindata', 'validdata' or 'testdata'.
translation : list of triples
(raw data id, formula in latex, formula ... | [
"Write",
"a",
"loop",
"-",
"up",
"file",
"that",
"contains",
"the",
"direct",
"(",
"record",
"-",
"wise",
")",
"lookup",
"information",
"."
] | python | train | 37.166667 |
tanghaibao/jcvi | jcvi/utils/table.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/utils/table.py#L32-L77 | def tabulate(d, transpose=False, thousands=True, key_fun=None, sep=',', align=True):
"""
d is a dictionary, keyed by tuple(A, B).
Goal is to put A in rows, B in columns, report data in table form.
>>> d = {(1,'a'):3, (1,'b'):4, (2,'a'):5, (2,'b'):0}
>>> print tabulate(d)
===========
o a ... | [
"def",
"tabulate",
"(",
"d",
",",
"transpose",
"=",
"False",
",",
"thousands",
"=",
"True",
",",
"key_fun",
"=",
"None",
",",
"sep",
"=",
"','",
",",
"align",
"=",
"True",
")",
":",
"pairs",
"=",
"d",
".",
"keys",
"(",
")",
"rows",
",",
"cols",
... | d is a dictionary, keyed by tuple(A, B).
Goal is to put A in rows, B in columns, report data in table form.
>>> d = {(1,'a'):3, (1,'b'):4, (2,'a'):5, (2,'b'):0}
>>> print tabulate(d)
===========
o a b
-----------
1 3 4
2 5 0
-----------
>>> print tabulate(d, tr... | [
"d",
"is",
"a",
"dictionary",
"keyed",
"by",
"tuple",
"(",
"A",
"B",
")",
".",
"Goal",
"is",
"to",
"put",
"A",
"in",
"rows",
"B",
"in",
"columns",
"report",
"data",
"in",
"table",
"form",
"."
] | python | train | 26.956522 |
pyamg/pyamg | pyamg/classical/split.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/classical/split.py#L240-L291 | def CLJP(S, color=False):
"""Compute a C/F splitting using the parallel CLJP algorithm.
Parameters
----------
S : csr_matrix
Strength of connection matrix indicating the strength between nodes i
and j (S_ij)
color : bool
use the CLJP coloring approach
Returns
------... | [
"def",
"CLJP",
"(",
"S",
",",
"color",
"=",
"False",
")",
":",
"if",
"not",
"isspmatrix_csr",
"(",
"S",
")",
":",
"raise",
"TypeError",
"(",
"'expected csr_matrix'",
")",
"S",
"=",
"remove_diagonal",
"(",
"S",
")",
"colorid",
"=",
"0",
"if",
"color",
... | Compute a C/F splitting using the parallel CLJP algorithm.
Parameters
----------
S : csr_matrix
Strength of connection matrix indicating the strength between nodes i
and j (S_ij)
color : bool
use the CLJP coloring approach
Returns
-------
splitting : array
A... | [
"Compute",
"a",
"C",
"/",
"F",
"splitting",
"using",
"the",
"parallel",
"CLJP",
"algorithm",
"."
] | python | train | 25.807692 |
SwissDataScienceCenter/renku-python | renku/cli/_git.py | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/_git.py#L32-L39 | def get_git_home(path='.'):
"""Get Git path from the current context."""
ctx = click.get_current_context(silent=True)
if ctx and GIT_KEY in ctx.meta:
return ctx.meta[GIT_KEY]
from git import Repo
return Repo(path, search_parent_directories=True).working_dir | [
"def",
"get_git_home",
"(",
"path",
"=",
"'.'",
")",
":",
"ctx",
"=",
"click",
".",
"get_current_context",
"(",
"silent",
"=",
"True",
")",
"if",
"ctx",
"and",
"GIT_KEY",
"in",
"ctx",
".",
"meta",
":",
"return",
"ctx",
".",
"meta",
"[",
"GIT_KEY",
"]... | Get Git path from the current context. | [
"Get",
"Git",
"path",
"from",
"the",
"current",
"context",
"."
] | python | train | 34.875 |
adafruit/Adafruit_CircuitPython_OneWire | adafruit_onewire/bus.py | https://github.com/adafruit/Adafruit_CircuitPython_OneWire/blob/113ca99b9087f7031f0b46a963472ad106520f9b/adafruit_onewire/bus.py#L202-L218 | def crc8(data):
"""
Perform the 1-Wire CRC check on the provided data.
:param bytearray data: 8 byte array representing 64 bit ROM code
"""
crc = 0
for byte in data:
crc ^= byte
for _ in range(8):
if crc & 0x01:
... | [
"def",
"crc8",
"(",
"data",
")",
":",
"crc",
"=",
"0",
"for",
"byte",
"in",
"data",
":",
"crc",
"^=",
"byte",
"for",
"_",
"in",
"range",
"(",
"8",
")",
":",
"if",
"crc",
"&",
"0x01",
":",
"crc",
"=",
"(",
"crc",
">>",
"1",
")",
"^",
"0x8C",... | Perform the 1-Wire CRC check on the provided data.
:param bytearray data: 8 byte array representing 64 bit ROM code | [
"Perform",
"the",
"1",
"-",
"Wire",
"CRC",
"check",
"on",
"the",
"provided",
"data",
"."
] | python | train | 25.176471 |
StackStorm/pybind | pybind/nos/v6_0_2f/interface/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/interface/__init__.py#L396-L422 | def _set_fc_port(self, v, load=False):
"""
Setter method for fc_port, mapped from YANG variable /interface/fc_port (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_fc_port is considered as a private
method. Backends looking to populate this variable should
... | [
"def",
"_set_fc_port",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",... | Setter method for fc_port, mapped from YANG variable /interface/fc_port (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_fc_port is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_fc_port() directly.
... | [
"Setter",
"method",
"for",
"fc_port",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface",
"/",
"fc_port",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"YANG",
"file",
... | python | train | 161.259259 |
jmcgeheeiv/pyfakefs | pyfakefs/fake_scandir.py | https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_scandir.py#L81-L102 | def stat(self, follow_symlinks=True):
"""Return a stat_result object for this entry.
Args:
follow_symlinks: If False and the entry is a symlink, return the
result for the symlink, otherwise for the object it points to.
"""
if follow_symlinks:
if s... | [
"def",
"stat",
"(",
"self",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"if",
"follow_symlinks",
":",
"if",
"self",
".",
"_statresult_symlink",
"is",
"None",
":",
"file_object",
"=",
"self",
".",
"_filesystem",
".",
"resolve",
"(",
"self",
".",
"path",
... | Return a stat_result object for this entry.
Args:
follow_symlinks: If False and the entry is a symlink, return the
result for the symlink, otherwise for the object it points to. | [
"Return",
"a",
"stat_result",
"object",
"for",
"this",
"entry",
"."
] | python | train | 42.681818 |
wal-e/wal-e | wal_e/pep3143daemon/daemon.py | https://github.com/wal-e/wal-e/blob/027263860e72a403bc0e1497bb3e67523138e7a2/wal_e/pep3143daemon/daemon.py#L309-L333 | def close_filenos(preserve):
""" Close unprotected file descriptors
Close all open file descriptors that are not in preserve.
If ulimit -nofile is "unlimited", all is defined filenos <= 4096,
else all is <= the output of resource.getrlimit().
:param preserve: set with protected files
:type pr... | [
"def",
"close_filenos",
"(",
"preserve",
")",
":",
"maxfd",
"=",
"resource",
".",
"getrlimit",
"(",
"resource",
".",
"RLIMIT_NOFILE",
")",
"[",
"1",
"]",
"if",
"maxfd",
"==",
"resource",
".",
"RLIM_INFINITY",
":",
"maxfd",
"=",
"4096",
"for",
"fileno",
"... | Close unprotected file descriptors
Close all open file descriptors that are not in preserve.
If ulimit -nofile is "unlimited", all is defined filenos <= 4096,
else all is <= the output of resource.getrlimit().
:param preserve: set with protected files
:type preserve: set
:return: None | [
"Close",
"unprotected",
"file",
"descriptors"
] | python | train | 32.24 |
googleapis/google-cloud-python | oslogin/google/cloud/oslogin_v1/gapic/os_login_service_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/oslogin/google/cloud/oslogin_v1/gapic/os_login_service_client.py#L490-L562 | def update_ssh_public_key(
self,
name,
ssh_public_key,
update_mask=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Updates an SSH public key and returns the profile inf... | [
"def",
"update_ssh_public_key",
"(",
"self",
",",
"name",
",",
"ssh_public_key",
",",
"update_mask",
"=",
"None",
",",
"retry",
"=",
"google",
".",
"api_core",
".",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
"=",
"google",
".",
"api_core",
... | Updates an SSH public key and returns the profile information. This method
supports patch semantics.
Example:
>>> from google.cloud import oslogin_v1
>>>
>>> client = oslogin_v1.OsLoginServiceClient()
>>>
>>> name = client.fingerprint_path('[U... | [
"Updates",
"an",
"SSH",
"public",
"key",
"and",
"returns",
"the",
"profile",
"information",
".",
"This",
"method",
"supports",
"patch",
"semantics",
"."
] | python | train | 46.808219 |
phn/angles | angles.py | https://github.com/phn/angles/blob/5c30ed7c3a7412177daaed180bf3b2351b287589/angles.py#L911-L1003 | def bear(a1, b1, a2, b2):
"""Find bearing/position angle between two points on a unit sphere.
Parameters
----------
a1, b1 : float
Longitude-like and latitude-like angles defining the first
point. Both are in radians.
a2, b2 : float
Longitude-like and latitude-like angles d... | [
"def",
"bear",
"(",
"a1",
",",
"b1",
",",
"a2",
",",
"b2",
")",
":",
"# Find perpendicular to the plane containing the base and",
"# z-axis. Then find the perpendicular to the plane containing",
"# the base and the target. The angle between these two is the",
"# position angle or beari... | Find bearing/position angle between two points on a unit sphere.
Parameters
----------
a1, b1 : float
Longitude-like and latitude-like angles defining the first
point. Both are in radians.
a2, b2 : float
Longitude-like and latitude-like angles defining the second
point.... | [
"Find",
"bearing",
"/",
"position",
"angle",
"between",
"two",
"points",
"on",
"a",
"unit",
"sphere",
"."
] | python | train | 30 |
doconix/django-mako-plus | django_mako_plus/router/data.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/data.py#L104-L109 | def get_template_loader(self, subdir='templates'):
'''App-specific function to get the current app's template loader'''
if self.request is None:
raise ValueError("this method can only be called after the view middleware is run. Check that `django_mako_plus.middleware` is in MIDDLEWARE.")
... | [
"def",
"get_template_loader",
"(",
"self",
",",
"subdir",
"=",
"'templates'",
")",
":",
"if",
"self",
".",
"request",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"this method can only be called after the view middleware is run. Check that `django_mako_plus.middleware` is... | App-specific function to get the current app's template loader | [
"App",
"-",
"specific",
"function",
"to",
"get",
"the",
"current",
"app",
"s",
"template",
"loader"
] | python | train | 71.5 |
TC01/calcpkg | calcrepo/output.py | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/output.py#L61-L69 | def getLoggingLocation(self):
"""Return the path for the calcpkg.log file - at the moment, only use a Linux path since I don't know where Windows thinks logs should go."""
if sys.platform == "win32":
modulePath = os.path.realpath(__file__)
modulePath = modulePath[:modulePath.rfind("/")]
return modulePath
... | [
"def",
"getLoggingLocation",
"(",
"self",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"modulePath",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
"modulePath",
"=",
"modulePath",
"[",
":",
"modulePath",
".",
"rfind",
... | Return the path for the calcpkg.log file - at the moment, only use a Linux path since I don't know where Windows thinks logs should go. | [
"Return",
"the",
"path",
"for",
"the",
"calcpkg",
".",
"log",
"file",
"-",
"at",
"the",
"moment",
"only",
"use",
"a",
"Linux",
"path",
"since",
"I",
"don",
"t",
"know",
"where",
"Windows",
"thinks",
"logs",
"should",
"go",
"."
] | python | train | 38.555556 |
Qiskit/qiskit-terra | qiskit/circuit/instructionset.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/circuit/instructionset.py#L57-L61 | def c_if(self, classical, val):
"""Add classical control register to all instructions."""
for gate in self.instructions:
gate.c_if(classical, val)
return self | [
"def",
"c_if",
"(",
"self",
",",
"classical",
",",
"val",
")",
":",
"for",
"gate",
"in",
"self",
".",
"instructions",
":",
"gate",
".",
"c_if",
"(",
"classical",
",",
"val",
")",
"return",
"self"
] | Add classical control register to all instructions. | [
"Add",
"classical",
"control",
"register",
"to",
"all",
"instructions",
"."
] | python | test | 38 |
citruz/beacontools | beacontools/scanner.py | https://github.com/citruz/beacontools/blob/15a83e9750d0a4393f8a36868e07f6d9458253fe/beacontools/scanner.py#L240-L244 | def terminate(self):
"""Signal runner to stop and join thread."""
self.toggle_scan(False)
self.keep_going = False
self.join() | [
"def",
"terminate",
"(",
"self",
")",
":",
"self",
".",
"toggle_scan",
"(",
"False",
")",
"self",
".",
"keep_going",
"=",
"False",
"self",
".",
"join",
"(",
")"
] | Signal runner to stop and join thread. | [
"Signal",
"runner",
"to",
"stop",
"and",
"join",
"thread",
"."
] | python | train | 30.6 |
openstack/networking-cisco | networking_cisco/plugins/cisco/device_manager/plugging_drivers/vif_hotplug_plugging_driver.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/device_manager/plugging_drivers/vif_hotplug_plugging_driver.py#L59-L86 | def create_hosting_device_resources(self, context, complementary_id,
tenant_id, mgmt_context, max_hosted):
"""Create resources for a hosting device in a plugin specific way."""
mgmt_port = None
if mgmt_context and mgmt_context.get('mgmt_nw_id') and tenant_... | [
"def",
"create_hosting_device_resources",
"(",
"self",
",",
"context",
",",
"complementary_id",
",",
"tenant_id",
",",
"mgmt_context",
",",
"max_hosted",
")",
":",
"mgmt_port",
"=",
"None",
"if",
"mgmt_context",
"and",
"mgmt_context",
".",
"get",
"(",
"'mgmt_nw_id... | Create resources for a hosting device in a plugin specific way. | [
"Create",
"resources",
"for",
"a",
"hosting",
"device",
"in",
"a",
"plugin",
"specific",
"way",
"."
] | python | train | 53.892857 |
dmwm/DBS | Server/Python/src/dbs/web/DBSWriterModel.py | https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSWriterModel.py#L404-L437 | def updateFile(self, logical_file_name=[], is_file_valid=1, lost=0, dataset=''):
"""
API to update file status
:param logical_file_name: logical_file_name to update (optional), but must have either a fln or
a dataset
:type logical_file_name: str
:param is_file_valid: va... | [
"def",
"updateFile",
"(",
"self",
",",
"logical_file_name",
"=",
"[",
"]",
",",
"is_file_valid",
"=",
"1",
",",
"lost",
"=",
"0",
",",
"dataset",
"=",
"''",
")",
":",
"if",
"lost",
"in",
"[",
"1",
",",
"True",
",",
"'True'",
",",
"'true'",
",",
"... | API to update file status
:param logical_file_name: logical_file_name to update (optional), but must have either a fln or
a dataset
:type logical_file_name: str
:param is_file_valid: valid=1, invalid=0 (Required)
:type is_file_valid: bool
:param lost: default lost=0 (op... | [
"API",
"to",
"update",
"file",
"status"
] | python | train | 50.676471 |
ethereum/py-evm | eth/db/journal.py | https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/db/journal.py#L379-L408 | def commit(self, changeset_id: uuid.UUID) -> None:
"""
Commits a given changeset. This merges the given changeset and all
subsequent changesets into the previous changeset giving precidence
to later changesets in case of any conflicting keys.
If this is the base changeset then a... | [
"def",
"commit",
"(",
"self",
",",
"changeset_id",
":",
"uuid",
".",
"UUID",
")",
"->",
"None",
":",
"self",
".",
"_validate_changeset",
"(",
"changeset_id",
")",
"journal_data",
"=",
"self",
".",
"journal",
".",
"commit_changeset",
"(",
"changeset_id",
")",... | Commits a given changeset. This merges the given changeset and all
subsequent changesets into the previous changeset giving precidence
to later changesets in case of any conflicting keys.
If this is the base changeset then all changes will be written to
the underlying database and the J... | [
"Commits",
"a",
"given",
"changeset",
".",
"This",
"merges",
"the",
"given",
"changeset",
"and",
"all",
"subsequent",
"changesets",
"into",
"the",
"previous",
"changeset",
"giving",
"precidence",
"to",
"later",
"changesets",
"in",
"case",
"of",
"any",
"conflicti... | python | train | 44.8 |
djgagne/hagelslag | hagelslag/processing/TrackModeler.py | https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/TrackModeler.py#L63-L111 | def load_data(self, mode="train", format="csv"):
"""
Load data from flat data files containing total track information and information about each timestep.
The two sets are combined using merge operations on the Track IDs. Additional member information is gathered
from the appropriate me... | [
"def",
"load_data",
"(",
"self",
",",
"mode",
"=",
"\"train\"",
",",
"format",
"=",
"\"csv\"",
")",
":",
"if",
"mode",
"in",
"self",
".",
"data",
".",
"keys",
"(",
")",
":",
"run_dates",
"=",
"pd",
".",
"DatetimeIndex",
"(",
"start",
"=",
"self",
"... | Load data from flat data files containing total track information and information about each timestep.
The two sets are combined using merge operations on the Track IDs. Additional member information is gathered
from the appropriate member file.
Args:
mode: "train" or "forecast"
... | [
"Load",
"data",
"from",
"flat",
"data",
"files",
"containing",
"total",
"track",
"information",
"and",
"information",
"about",
"each",
"timestep",
".",
"The",
"two",
"sets",
"are",
"combined",
"using",
"merge",
"operations",
"on",
"the",
"Track",
"IDs",
".",
... | python | train | 64.306122 |
keenlabs/KeenClient-Python | keen/api.py | https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L97-L110 | def post_event(self, event):
"""
Posts a single event to the Keen IO API. The write key must be set first.
:param event: an Event to upload
"""
url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, self.api_version,
... | [
"def",
"post_event",
"(",
"self",
",",
"event",
")",
":",
"url",
"=",
"\"{0}/{1}/projects/{2}/events/{3}\"",
".",
"format",
"(",
"self",
".",
"base_url",
",",
"self",
".",
"api_version",
",",
"self",
".",
"project_id",
",",
"event",
".",
"event_collection",
... | Posts a single event to the Keen IO API. The write key must be set first.
:param event: an Event to upload | [
"Posts",
"a",
"single",
"event",
"to",
"the",
"Keen",
"IO",
"API",
".",
"The",
"write",
"key",
"must",
"be",
"set",
"first",
"."
] | python | train | 45.785714 |
blockstack/virtualchain | virtualchain/lib/encoding.py | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/encoding.py#L133-L148 | def num_to_var_int(x):
"""
(bitcoin-specific): convert an integer into a variable-length integer
"""
x = int(x)
if x < 253:
return from_int_to_byte(x)
elif x < 65536:
return from_int_to_byte(253) + encode(x, 256, 2)[::-1]
elif x < 4294967296:
return from_int_to_byte... | [
"def",
"num_to_var_int",
"(",
"x",
")",
":",
"x",
"=",
"int",
"(",
"x",
")",
"if",
"x",
"<",
"253",
":",
"return",
"from_int_to_byte",
"(",
"x",
")",
"elif",
"x",
"<",
"65536",
":",
"return",
"from_int_to_byte",
"(",
"253",
")",
"+",
"encode",
"(",... | (bitcoin-specific): convert an integer into a variable-length integer | [
"(",
"bitcoin",
"-",
"specific",
")",
":",
"convert",
"an",
"integer",
"into",
"a",
"variable",
"-",
"length",
"integer"
] | python | train | 25.625 |
rodluger/everest | everest/mathutils.py | https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/mathutils.py#L104-L136 | def Scatter(y, win=13, remove_outliers=False):
'''
Return the scatter in ppm based on the median running standard deviation
for a window size of :py:obj:`win` = 13 cadences (for K2, this
is ~6.5 hours, as in VJ14).
:param ndarray y: The array whose CDPP is to be computed
:param int win: The win... | [
"def",
"Scatter",
"(",
"y",
",",
"win",
"=",
"13",
",",
"remove_outliers",
"=",
"False",
")",
":",
"if",
"remove_outliers",
":",
"# Remove 5-sigma outliers from data",
"# smoothed on a 1 day timescale",
"if",
"len",
"(",
"y",
")",
">=",
"50",
":",
"ys",
"=",
... | Return the scatter in ppm based on the median running standard deviation
for a window size of :py:obj:`win` = 13 cadences (for K2, this
is ~6.5 hours, as in VJ14).
:param ndarray y: The array whose CDPP is to be computed
:param int win: The window size in cadences. Default `13`
:param bool remove_o... | [
"Return",
"the",
"scatter",
"in",
"ppm",
"based",
"on",
"the",
"median",
"running",
"standard",
"deviation",
"for",
"a",
"window",
"size",
"of",
":",
"py",
":",
"obj",
":",
"win",
"=",
"13",
"cadences",
"(",
"for",
"K2",
"this",
"is",
"~6",
".",
"5",... | python | train | 34.030303 |
bihealth/vcfpy | vcfpy/parser.py | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L777-L789 | def _check_samples_line(klass, arr):
"""Peform additional check on samples line"""
if len(arr) <= len(REQUIRE_NO_SAMPLE_HEADER):
if tuple(arr) != REQUIRE_NO_SAMPLE_HEADER:
raise exceptions.IncorrectVCFFormat(
"Sample header line indicates no sample but doe... | [
"def",
"_check_samples_line",
"(",
"klass",
",",
"arr",
")",
":",
"if",
"len",
"(",
"arr",
")",
"<=",
"len",
"(",
"REQUIRE_NO_SAMPLE_HEADER",
")",
":",
"if",
"tuple",
"(",
"arr",
")",
"!=",
"REQUIRE_NO_SAMPLE_HEADER",
":",
"raise",
"exceptions",
".",
"Inco... | Peform additional check on samples line | [
"Peform",
"additional",
"check",
"on",
"samples",
"line"
] | python | train | 56 |
google/grr | grr/server/grr_response_server/databases/mem_clients.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_clients.py#L220-L228 | def ListClientsForKeywords(self, keywords, start_time=None):
"""Lists the clients associated with keywords."""
res = {kw: [] for kw in keywords}
for kw in keywords:
for client_id, timestamp in iteritems(self.keywords.get(kw, {})):
if start_time is not None and timestamp < start_time:
... | [
"def",
"ListClientsForKeywords",
"(",
"self",
",",
"keywords",
",",
"start_time",
"=",
"None",
")",
":",
"res",
"=",
"{",
"kw",
":",
"[",
"]",
"for",
"kw",
"in",
"keywords",
"}",
"for",
"kw",
"in",
"keywords",
":",
"for",
"client_id",
",",
"timestamp",... | Lists the clients associated with keywords. | [
"Lists",
"the",
"clients",
"associated",
"with",
"keywords",
"."
] | python | train | 41.111111 |
alex-kostirin/pyatomac | atomac/AXClasses.py | https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/AXClasses.py#L98-L120 | def getFrontmostApp(cls):
"""Get the current frontmost application.
Raise a ValueError exception if no GUI applications are found.
"""
# Refresh the runningApplications list
apps = cls._getRunningApps()
for app in apps:
pid = app.processIdentifier()
... | [
"def",
"getFrontmostApp",
"(",
"cls",
")",
":",
"# Refresh the runningApplications list",
"apps",
"=",
"cls",
".",
"_getRunningApps",
"(",
")",
"for",
"app",
"in",
"apps",
":",
"pid",
"=",
"app",
".",
"processIdentifier",
"(",
")",
"ref",
"=",
"cls",
".",
... | Get the current frontmost application.
Raise a ValueError exception if no GUI applications are found. | [
"Get",
"the",
"current",
"frontmost",
"application",
"."
] | python | valid | 41.608696 |
orb-framework/orb | orb/core/model.py | https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/model.py#L898-L929 | def validate(self, columns=None):
"""
Validates the current record object to make sure it is ok to commit to the database. If
the optional override dictionary is passed in, then it will use the given values vs. the one
stored with this record object which can be useful to check to see i... | [
"def",
"validate",
"(",
"self",
",",
"columns",
"=",
"None",
")",
":",
"schema",
"=",
"self",
".",
"schema",
"(",
")",
"if",
"not",
"columns",
":",
"ignore_flags",
"=",
"orb",
".",
"Column",
".",
"Flags",
".",
"Virtual",
"|",
"orb",
".",
"Column",
... | Validates the current record object to make sure it is ok to commit to the database. If
the optional override dictionary is passed in, then it will use the given values vs. the one
stored with this record object which can be useful to check to see if the record will be valid before
it is commit... | [
"Validates",
"the",
"current",
"record",
"object",
"to",
"make",
"sure",
"it",
"is",
"ok",
"to",
"commit",
"to",
"the",
"database",
".",
"If",
"the",
"optional",
"override",
"dictionary",
"is",
"passed",
"in",
"then",
"it",
"will",
"use",
"the",
"given",
... | python | train | 35.625 |
saltstack/salt | salt/grains/core.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/core.py#L1559-L1584 | def _parse_cpe_name(cpe):
'''
Parse CPE_NAME data from the os-release
Info: https://csrc.nist.gov/projects/security-content-automation-protocol/scap-specifications/cpe
:param cpe:
:return:
'''
part = {
'o': 'operating system',
'h': 'hardware',
'a': 'application',
... | [
"def",
"_parse_cpe_name",
"(",
"cpe",
")",
":",
"part",
"=",
"{",
"'o'",
":",
"'operating system'",
",",
"'h'",
":",
"'hardware'",
",",
"'a'",
":",
"'application'",
",",
"}",
"ret",
"=",
"{",
"}",
"cpe",
"=",
"(",
"cpe",
"or",
"''",
")",
".",
"spli... | Parse CPE_NAME data from the os-release
Info: https://csrc.nist.gov/projects/security-content-automation-protocol/scap-specifications/cpe
:param cpe:
:return: | [
"Parse",
"CPE_NAME",
"data",
"from",
"the",
"os",
"-",
"release"
] | python | train | 32.884615 |
angr/angr | angr/analyses/ddg.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/ddg.py#L1484-L1508 | def _filter_defs_at_call_sites(self, defs):
"""
If we are not tracing into the function that are called in a real execution, we should properly filter the defs
to account for the behavior of the skipped function at this call site.
This function is a WIP. See TODOs inside.
:para... | [
"def",
"_filter_defs_at_call_sites",
"(",
"self",
",",
"defs",
")",
":",
"# TODO: make definition killing architecture independent and calling convention independent",
"# TODO: use information from a calling convention analysis",
"filtered_defs",
"=",
"LiveDefinitions",
"(",
")",
"for"... | If we are not tracing into the function that are called in a real execution, we should properly filter the defs
to account for the behavior of the skipped function at this call site.
This function is a WIP. See TODOs inside.
:param defs:
:return: | [
"If",
"we",
"are",
"not",
"tracing",
"into",
"the",
"function",
"that",
"are",
"called",
"in",
"a",
"real",
"execution",
"we",
"should",
"properly",
"filter",
"the",
"defs",
"to",
"account",
"for",
"the",
"behavior",
"of",
"the",
"skipped",
"function",
"at... | python | train | 41.96 |
matllubos/django-is-core | is_core/forms/widgets.py | https://github.com/matllubos/django-is-core/blob/3f87ec56a814738683c732dce5f07e0328c2300d/is_core/forms/widgets.py#L52-L55 | def build_attrs(self, *args, **kwargs):
"Helper function for building an attribute dictionary."
self.attrs = self.widget.build_attrs(*args, **kwargs)
return self.attrs | [
"def",
"build_attrs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"attrs",
"=",
"self",
".",
"widget",
".",
"build_attrs",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"attrs"
] | Helper function for building an attribute dictionary. | [
"Helper",
"function",
"for",
"building",
"an",
"attribute",
"dictionary",
"."
] | python | train | 47 |
tensorflow/probability | tensorflow_probability/python/vi/csiszar_divergence.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/vi/csiszar_divergence.py#L51-L118 | def amari_alpha(logu, alpha=1., self_normalized=False, name=None):
"""The Amari-alpha Csiszar-function in log-space.
A Csiszar-function is a member of,
```none
F = { f:R_+ to R : f convex }.
```
When `self_normalized = True`, the Amari-alpha Csiszar-function is:
```none
f(u) = { -log(u) + (u - 1), ... | [
"def",
"amari_alpha",
"(",
"logu",
",",
"alpha",
"=",
"1.",
",",
"self_normalized",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(",
"name",
",",
"\"amari_alpha\"",
",",
"[",
"logu",
"]... | The Amari-alpha Csiszar-function in log-space.
A Csiszar-function is a member of,
```none
F = { f:R_+ to R : f convex }.
```
When `self_normalized = True`, the Amari-alpha Csiszar-function is:
```none
f(u) = { -log(u) + (u - 1), alpha = 0
{ u log(u) - (u - 1), alpha = 1
{ [(u*... | [
"The",
"Amari",
"-",
"alpha",
"Csiszar",
"-",
"function",
"in",
"log",
"-",
"space",
"."
] | python | test | 33.352941 |
quantumlib/Cirq | cirq/google/engine/engine.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/engine/engine.py#L414-L428 | def get_job(self, job_resource_name: str) -> Dict:
"""Returns metadata about a previously created job.
See get_job_result if you want the results of the job and not just
metadata about the job.
Params:
job_resource_name: A string of the form
`projects/projec... | [
"def",
"get_job",
"(",
"self",
",",
"job_resource_name",
":",
"str",
")",
"->",
"Dict",
":",
"return",
"self",
".",
"service",
".",
"projects",
"(",
")",
".",
"programs",
"(",
")",
".",
"jobs",
"(",
")",
".",
"get",
"(",
"name",
"=",
"job_resource_na... | Returns metadata about a previously created job.
See get_job_result if you want the results of the job and not just
metadata about the job.
Params:
job_resource_name: A string of the form
`projects/project_id/programs/program_id/jobs/job_id`.
Returns:
... | [
"Returns",
"metadata",
"about",
"a",
"previously",
"created",
"job",
"."
] | python | train | 35.466667 |
spyder-ide/spyder | spyder/plugins/breakpoints/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/plugin.py#L77-L96 | def register_plugin(self):
"""Register plugin in Spyder's main window"""
self.breakpoints.edit_goto.connect(self.main.editor.load)
#self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
self.breakpoints.clear_all_breakpoints.connect(
... | [
"def",
"register_plugin",
"(",
"self",
")",
":",
"self",
".",
"breakpoints",
".",
"edit_goto",
".",
"connect",
"(",
"self",
".",
"main",
".",
"editor",
".",
"load",
")",
"#self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)\r",
"self",
".",
"breakpoi... | Register plugin in Spyder's main window | [
"Register",
"plugin",
"in",
"Spyder",
"s",
"main",
"window"
] | python | train | 55.05 |
tensorflow/probability | tensorflow_probability/python/stats/sample_stats.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/stats/sample_stats.py#L686-L694 | def _squeeze(x, axis):
"""A version of squeeze that works with dynamic axis."""
x = tf.convert_to_tensor(value=x, name='x')
if axis is None:
return tf.squeeze(x, axis=None)
axis = tf.convert_to_tensor(value=axis, name='axis', dtype=tf.int32)
axis += tf.zeros([1], dtype=axis.dtype) # Make axis at least 1d... | [
"def",
"_squeeze",
"(",
"x",
",",
"axis",
")",
":",
"x",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"x",
",",
"name",
"=",
"'x'",
")",
"if",
"axis",
"is",
"None",
":",
"return",
"tf",
".",
"squeeze",
"(",
"x",
",",
"axis",
"=",
"No... | A version of squeeze that works with dynamic axis. | [
"A",
"version",
"of",
"squeeze",
"that",
"works",
"with",
"dynamic",
"axis",
"."
] | python | test | 49.777778 |
mcieslik-mctp/papy | src/numap/NuMap.py | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/numap/NuMap.py#L766-L842 | def imports(modules, forgive=False):
"""
Should be used as a decorator to *attach* import statments to function
definitions. These imports are added to the global (i.e. module-level of
the decorated function) namespace.
Two forms of import statements are supported (in the following example... | [
"def",
"imports",
"(",
"modules",
",",
"forgive",
"=",
"False",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"if",
"modules",
":",
"# attach import to function",
"setattr",
"(",
"f",
",",
"'imports'",
",",
"modules",
")",
"for",
"alternatives",
"in",
"mo... | Should be used as a decorator to *attach* import statments to function
definitions. These imports are added to the global (i.e. module-level of
the decorated function) namespace.
Two forms of import statements are supported (in the following examples
``foo``, ``bar``, ``oof, and ``rab`` are mo... | [
"Should",
"be",
"used",
"as",
"a",
"decorator",
"to",
"*",
"attach",
"*",
"import",
"statments",
"to",
"function",
"definitions",
".",
"These",
"imports",
"are",
"added",
"to",
"the",
"global",
"(",
"i",
".",
"e",
".",
"module",
"-",
"level",
"of",
"th... | python | train | 35.311688 |
markchil/gptools | gptools/utils.py | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1626-L1656 | def generate_set_partitions(set_):
"""Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:... | [
"def",
"generate_set_partitions",
"(",
"set_",
")",
":",
"set_",
"=",
"scipy",
".",
"asarray",
"(",
"set_",
")",
"strings",
"=",
"generate_set_partition_strings",
"(",
"len",
"(",
"set_",
")",
")",
"partitions",
"=",
"[",
"]",
"for",
"string",
"in",
"strin... | Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:class:`Array` or other Array-like, (`m`,)
... | [
"Generate",
"all",
"of",
"the",
"partitions",
"of",
"a",
"set",
".",
"This",
"is",
"a",
"helper",
"function",
"that",
"utilizes",
"the",
"restricted",
"growth",
"strings",
"from",
":",
"py",
":",
"func",
":",
"generate_set_partition_strings",
".",
"The",
"pa... | python | train | 36.419355 |
nickoala/telepot | telepot/delegate.py | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/delegate.py#L324-L337 | def pair(seeders, delegator_factory, *args, **kwargs):
"""
The basic pair producer.
:return:
a (seeder, delegator_factory(\*args, \*\*kwargs)) tuple.
:param seeders:
If it is a seeder function or a list of one seeder function, it is returned
as the final seeder. If it is a list... | [
"def",
"pair",
"(",
"seeders",
",",
"delegator_factory",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"(",
"chain",
"(",
"*",
"seeders",
")",
"if",
"len",
"(",
"seeders",
")",
">",
"1",
"else",
"seeders",
"[",
"0",
"]",
",",
"de... | The basic pair producer.
:return:
a (seeder, delegator_factory(\*args, \*\*kwargs)) tuple.
:param seeders:
If it is a seeder function or a list of one seeder function, it is returned
as the final seeder. If it is a list of more than one seeder function, they
are chained togethe... | [
"The",
"basic",
"pair",
"producer",
"."
] | python | train | 38.071429 |
redhat-cip/python-dciclient | dciclient/v1/api/base.py | https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/base.py#L45-L66 | def iter(context, resource, **kwargs):
"""List all resources"""
data = utils.sanitize_kwargs(**kwargs)
id = data.pop('id', None)
subresource = data.pop('subresource', None)
data['limit'] = data.get('limit', 20)
if subresource:
uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, sub... | [
"def",
"iter",
"(",
"context",
",",
"resource",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"utils",
".",
"sanitize_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"id",
"=",
"data",
".",
"pop",
"(",
"'id'",
",",
"None",
")",
"subresource",
"=",
"data",... | List all resources | [
"List",
"all",
"resources"
] | python | train | 31 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/consoleapp.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/consoleapp.py#L202-L246 | def init_connection_file(self):
"""find the connection file, and load the info if found.
The current working directory and the current profile's security
directory will be searched for the file if it is not given by
absolute path.
When attempting to connect to a... | [
"def",
"init_connection_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"existing",
":",
"try",
":",
"cf",
"=",
"find_connection_file",
"(",
"self",
".",
"existing",
")",
"except",
"Exception",
":",
"self",
".",
"log",
".",
"critical",
"(",
"\"Could not f... | find the connection file, and load the info if found.
The current working directory and the current profile's security
directory will be searched for the file if it is not given by
absolute path.
When attempting to connect to an existing kernel and the `--existing`
... | [
"find",
"the",
"connection",
"file",
"and",
"load",
"the",
"info",
"if",
"found",
".",
"The",
"current",
"working",
"directory",
"and",
"the",
"current",
"profile",
"s",
"security",
"directory",
"will",
"be",
"searched",
"for",
"the",
"file",
"if",
"it",
"... | python | test | 46.311111 |
pypa/pipenv | pipenv/vendor/cerberus/validator.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/cerberus/validator.py#L1036-L1047 | def _validate_forbidden(self, forbidden_values, field, value):
""" {'type': 'list'} """
if isinstance(value, _str_type):
if value in forbidden_values:
self._error(field, errors.FORBIDDEN_VALUE, value)
elif isinstance(value, Sequence):
forbidden = set(value... | [
"def",
"_validate_forbidden",
"(",
"self",
",",
"forbidden_values",
",",
"field",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"_str_type",
")",
":",
"if",
"value",
"in",
"forbidden_values",
":",
"self",
".",
"_error",
"(",
"field",
",",
... | {'type': 'list'} | [
"{",
"type",
":",
"list",
"}"
] | python | train | 48.5 |
satellogic/telluric | telluric/georaster.py | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1586-L1597 | def _calc_footprint(self):
"""Return rectangle in world coordinates, as GeoVector."""
corners = [self.corner(corner) for corner in self.corner_types()]
coords = []
for corner in corners:
shape = corner.get_shape(corner.crs)
coords.append([shape.x, shape.y])
... | [
"def",
"_calc_footprint",
"(",
"self",
")",
":",
"corners",
"=",
"[",
"self",
".",
"corner",
"(",
"corner",
")",
"for",
"corner",
"in",
"self",
".",
"corner_types",
"(",
")",
"]",
"coords",
"=",
"[",
"]",
"for",
"corner",
"in",
"corners",
":",
"shape... | Return rectangle in world coordinates, as GeoVector. | [
"Return",
"rectangle",
"in",
"world",
"coordinates",
"as",
"GeoVector",
"."
] | python | train | 38.083333 |
phoebe-project/phoebe2 | phoebe/parameters/constraint.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/constraint.py#L421-L459 | def t0_ref_supconj(b, orbit, solve_for=None, **kwargs):
"""
Create a constraint for t0_ref in an orbit - allowing translating between
t0_ref and t0_supconj.
:parameter b: the :class:`phoebe.frontend.bundle.Bundle`
:parameter str orbit: the label of the orbit in which this
constraint should ... | [
"def",
"t0_ref_supconj",
"(",
"b",
",",
"orbit",
",",
"solve_for",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"orbit_ps",
"=",
"_get_system_ps",
"(",
"b",
",",
"orbit",
")",
"metawargs",
"=",
"orbit_ps",
".",
"meta",
"metawargs",
".",
"pop",
"(",
... | Create a constraint for t0_ref in an orbit - allowing translating between
t0_ref and t0_supconj.
:parameter b: the :class:`phoebe.frontend.bundle.Bundle`
:parameter str orbit: the label of the orbit in which this
constraint should be built
:parameter str solve_for: if 't0_ref' should not be th... | [
"Create",
"a",
"constraint",
"for",
"t0_ref",
"in",
"an",
"orbit",
"-",
"allowing",
"translating",
"between",
"t0_ref",
"and",
"t0_supconj",
"."
] | python | train | 37.025641 |
chrisrink10/basilisp | src/basilisp/lang/reader.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/reader.py#L138-L143 | def pushback(self) -> None:
"""Push one character back onto the stream, allowing it to be
read again."""
if abs(self._idx - 1) > self._pushback_depth:
raise IndexError("Exceeded pushback depth")
self._idx -= 1 | [
"def",
"pushback",
"(",
"self",
")",
"->",
"None",
":",
"if",
"abs",
"(",
"self",
".",
"_idx",
"-",
"1",
")",
">",
"self",
".",
"_pushback_depth",
":",
"raise",
"IndexError",
"(",
"\"Exceeded pushback depth\"",
")",
"self",
".",
"_idx",
"-=",
"1"
] | Push one character back onto the stream, allowing it to be
read again. | [
"Push",
"one",
"character",
"back",
"onto",
"the",
"stream",
"allowing",
"it",
"to",
"be",
"read",
"again",
"."
] | python | test | 41.333333 |
d0c-s4vage/pfp | pfp/interp.py | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1505-L1516 | def _str_to_int(self, string):
"""Check for the hex
"""
string = string.lower()
if string.endswith("l"):
string = string[:-1]
if string.lower().startswith("0x"):
# should always match
match = re.match(r'0[xX]([a-fA-F0-9]+)', string)
... | [
"def",
"_str_to_int",
"(",
"self",
",",
"string",
")",
":",
"string",
"=",
"string",
".",
"lower",
"(",
")",
"if",
"string",
".",
"endswith",
"(",
"\"l\"",
")",
":",
"string",
"=",
"string",
"[",
":",
"-",
"1",
"]",
"if",
"string",
".",
"lower",
... | Check for the hex | [
"Check",
"for",
"the",
"hex"
] | python | train | 32.25 |
DataBiosphere/toil | src/toil/lib/docker.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/lib/docker.py#L477-L497 | def containerIsRunning(container_name):
"""
Checks whether the container is running or not.
:param container_name: Name of the container being checked.
:returns: True if status is 'running', False if status is anything else,
and None if the container does not exist.
"""
client = docker.from_... | [
"def",
"containerIsRunning",
"(",
"container_name",
")",
":",
"client",
"=",
"docker",
".",
"from_env",
"(",
"version",
"=",
"'auto'",
")",
"try",
":",
"this_container",
"=",
"client",
".",
"containers",
".",
"get",
"(",
"container_name",
")",
"if",
"this_co... | Checks whether the container is running or not.
:param container_name: Name of the container being checked.
:returns: True if status is 'running', False if status is anything else,
and None if the container does not exist. | [
"Checks",
"whether",
"the",
"container",
"is",
"running",
"or",
"not",
".",
":",
"param",
"container_name",
":",
"Name",
"of",
"the",
"container",
"being",
"checked",
".",
":",
"returns",
":",
"True",
"if",
"status",
"is",
"running",
"False",
"if",
"status... | python | train | 39.238095 |
saltstack/salt | salt/returners/memcache_return.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/memcache_return.py#L213-L223 | def get_jids():
'''
Return a list of all job ids
'''
serv = _get_serv(ret=None)
jids = _get_list(serv, 'jids')
loads = serv.get_multi(jids) # {jid: load, jid: load, ...}
ret = {}
for jid, load in six.iteritems(loads):
ret[jid] = salt.utils.jid.format_jid_instance(jid, salt.utils... | [
"def",
"get_jids",
"(",
")",
":",
"serv",
"=",
"_get_serv",
"(",
"ret",
"=",
"None",
")",
"jids",
"=",
"_get_list",
"(",
"serv",
",",
"'jids'",
")",
"loads",
"=",
"serv",
".",
"get_multi",
"(",
"jids",
")",
"# {jid: load, jid: load, ...}",
"ret",
"=",
... | Return a list of all job ids | [
"Return",
"a",
"list",
"of",
"all",
"job",
"ids"
] | python | train | 31.181818 |
saltstack/salt | salt/states/smartos.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/smartos.py#L452-L485 | def source_absent(name):
'''
Ensure an image source is absent on the computenode
name : string
source url
'''
ret = {'name': name,
'changes': {},
'result': None,
'comment': ''}
if name not in __salt__['imgadm.sources']():
# source is absent
... | [
"def",
"source_absent",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
"}",
"if",
"name",
"not",
"in",
"__salt__",
"[",
"'imgadm.sources'",
"]... | Ensure an image source is absent on the computenode
name : string
source url | [
"Ensure",
"an",
"image",
"source",
"is",
"absent",
"on",
"the",
"computenode"
] | python | train | 28.470588 |
inveniosoftware/invenio-access | invenio_access/cli.py | https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/invenio_access/cli.py#L30-L35 | def lazy_result(f):
"""Decorate function to return LazyProxy."""
@wraps(f)
def decorated(ctx, param, value):
return LocalProxy(lambda: f(ctx, param, value))
return decorated | [
"def",
"lazy_result",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"ctx",
",",
"param",
",",
"value",
")",
":",
"return",
"LocalProxy",
"(",
"lambda",
":",
"f",
"(",
"ctx",
",",
"param",
",",
"value",
")",
")",
"retur... | Decorate function to return LazyProxy. | [
"Decorate",
"function",
"to",
"return",
"LazyProxy",
"."
] | python | train | 32 |
tanghaibao/jcvi | jcvi/formats/blast.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/blast.py#L255-L336 | def filter(args):
"""
%prog filter test.blast
Produce a new blast file and filter based on:
- score: >= cutoff
- pctid: >= cutoff
- hitlen: >= cutoff
- evalue: <= cutoff
- ids: valid ids
Use --inverse to obtain the complementary records for the criteria above.
- noself: remove... | [
"def",
"filter",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"filter",
".",
"__doc__",
")",
"p",
".",
"add_option",
"(",
"\"--score\"",
",",
"dest",
"=",
"\"score\"",
",",
"default",
"=",
"0",
",",
"type",
"=",
"\"int\"",
",",
"help",
"=",
... | %prog filter test.blast
Produce a new blast file and filter based on:
- score: >= cutoff
- pctid: >= cutoff
- hitlen: >= cutoff
- evalue: <= cutoff
- ids: valid ids
Use --inverse to obtain the complementary records for the criteria above.
- noself: remove self-self hits | [
"%prog",
"filter",
"test",
".",
"blast"
] | python | train | 27.02439 |
whiteclover/dbpy | db/__init__.py | https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/__init__.py#L54-L91 | def setup(config, minconn=5, maxconn=10, adapter='mysql', key='default', slave=False):
"""Setup database
:param config dict: is the db adapter config
:param key string: the key to identify dabtabase
:param adapter string: the dabtabase adapter current support mysql only
:param minconn int: the mi... | [
"def",
"setup",
"(",
"config",
",",
"minconn",
"=",
"5",
",",
"maxconn",
"=",
"10",
",",
"adapter",
"=",
"'mysql'",
",",
"key",
"=",
"'default'",
",",
"slave",
"=",
"False",
")",
":",
"global",
"__db",
"if",
"'.'",
"in",
"key",
":",
"raise",
"TypeE... | Setup database
:param config dict: is the db adapter config
:param key string: the key to identify dabtabase
:param adapter string: the dabtabase adapter current support mysql only
:param minconn int: the min connection for connection pool
:param maxconn int: the max connection for connection pool
... | [
"Setup",
"database"
] | python | train | 31.868421 |
gwastro/pycbc | pycbc/filter/matchedfilter.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/filter/matchedfilter.py#L1282-L1315 | def matched_filter(template, data, psd=None, low_frequency_cutoff=None,
high_frequency_cutoff=None, sigmasq=None):
""" Return the complex snr.
Return the complex snr, along with its associated normalization of the
template, matched filtered against the data.
Parameters
----------... | [
"def",
"matched_filter",
"(",
"template",
",",
"data",
",",
"psd",
"=",
"None",
",",
"low_frequency_cutoff",
"=",
"None",
",",
"high_frequency_cutoff",
"=",
"None",
",",
"sigmasq",
"=",
"None",
")",
":",
"snr",
",",
"_",
",",
"norm",
"=",
"matched_filter_c... | Return the complex snr.
Return the complex snr, along with its associated normalization of the
template, matched filtered against the data.
Parameters
----------
template : TimeSeries or FrequencySeries
The template waveform
data : TimeSeries or FrequencySeries
The strain data ... | [
"Return",
"the",
"complex",
"snr",
"."
] | python | train | 37.705882 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.