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 |
|---|---|---|---|---|---|---|---|---|---|
materialsproject/pymatgen | pymatgen/io/abinit/flows.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L548-L562 | def chroot(self, new_workdir):
"""
Change the workir of the :class:`Flow`. Mainly used for
allowing the user to open the GUI on the local host
and access the flow from remote via sshfs.
.. note::
Calling this method will make the flow go in read-only mode.
""... | [
"def",
"chroot",
"(",
"self",
",",
"new_workdir",
")",
":",
"self",
".",
"_chrooted_from",
"=",
"self",
".",
"workdir",
"self",
".",
"set_workdir",
"(",
"new_workdir",
",",
"chroot",
"=",
"True",
")",
"for",
"i",
",",
"work",
"in",
"enumerate",
"(",
"s... | Change the workir of the :class:`Flow`. Mainly used for
allowing the user to open the GUI on the local host
and access the flow from remote via sshfs.
.. note::
Calling this method will make the flow go in read-only mode. | [
"Change",
"the",
"workir",
"of",
"the",
":",
"class",
":",
"Flow",
".",
"Mainly",
"used",
"for",
"allowing",
"the",
"user",
"to",
"open",
"the",
"GUI",
"on",
"the",
"local",
"host",
"and",
"access",
"the",
"flow",
"from",
"remote",
"via",
"sshfs",
"."
... | python | train | 36 |
EmbodiedCognition/pagoda | pagoda/physics.py | https://github.com/EmbodiedCognition/pagoda/blob/8892f847026d98aba8646ecbc4589397e6dec7bd/pagoda/physics.py#L943-L954 | def axes(self, axes):
'''Set the linear axis of displacement for this joint.
Parameters
----------
axes : list containing one 3-tuple of floats
A list of the axes for this joint. For a slider joint, which has one
degree of freedom, this must contain one 3-tuple s... | [
"def",
"axes",
"(",
"self",
",",
"axes",
")",
":",
"self",
".",
"lmotor",
".",
"axes",
"=",
"[",
"axes",
"[",
"0",
"]",
"]",
"self",
".",
"ode_obj",
".",
"setAxis",
"(",
"tuple",
"(",
"axes",
"[",
"0",
"]",
")",
")"
] | Set the linear axis of displacement for this joint.
Parameters
----------
axes : list containing one 3-tuple of floats
A list of the axes for this joint. For a slider joint, which has one
degree of freedom, this must contain one 3-tuple specifying the X,
Y, a... | [
"Set",
"the",
"linear",
"axis",
"of",
"displacement",
"for",
"this",
"joint",
"."
] | python | valid | 38.333333 |
OnroerendErfgoed/oe_utils | oe_utils/search/query_builder.py | https://github.com/OnroerendErfgoed/oe_utils/blob/7b2014bda8ac6bb71b7138eaa06ac17ef3ff4a6d/oe_utils/search/query_builder.py#L45-L66 | def add_concept_filter(self, concept, concept_name=None):
"""
Add a concept filter
:param concept: concept which will be used as lowercase string in a search term
:param concept_name: name of the place where there will be searched for
"""
if concept in self.query_params.... | [
"def",
"add_concept_filter",
"(",
"self",
",",
"concept",
",",
"concept_name",
"=",
"None",
")",
":",
"if",
"concept",
"in",
"self",
".",
"query_params",
".",
"keys",
"(",
")",
":",
"if",
"not",
"concept_name",
":",
"concept_name",
"=",
"concept",
"if",
... | Add a concept filter
:param concept: concept which will be used as lowercase string in a search term
:param concept_name: name of the place where there will be searched for | [
"Add",
"a",
"concept",
"filter"
] | python | train | 49.909091 |
chaoss/grimoirelab-perceval | perceval/backends/core/mattermost.py | https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/mattermost.py#L224-L232 | def _init_client(self, from_archive=False):
"""Init client"""
return MattermostClient(self.url, self.api_token,
max_items=self.max_items,
sleep_for_rate=self.sleep_for_rate,
min_rate_to_sleep=self.min_rate_t... | [
"def",
"_init_client",
"(",
"self",
",",
"from_archive",
"=",
"False",
")",
":",
"return",
"MattermostClient",
"(",
"self",
".",
"url",
",",
"self",
".",
"api_token",
",",
"max_items",
"=",
"self",
".",
"max_items",
",",
"sleep_for_rate",
"=",
"self",
".",... | Init client | [
"Init",
"client"
] | python | test | 51.222222 |
inasafe/inasafe | safe/gui/tools/osm_downloader_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/osm_downloader_dialog.py#L285-L289 | def directory_button_clicked(self):
"""Show a dialog to choose directory."""
# noinspection PyCallByClass,PyTypeChecker
self.output_directory.setText(QFileDialog.getExistingDirectory(
self, self.tr('Select download directory'))) | [
"def",
"directory_button_clicked",
"(",
"self",
")",
":",
"# noinspection PyCallByClass,PyTypeChecker",
"self",
".",
"output_directory",
".",
"setText",
"(",
"QFileDialog",
".",
"getExistingDirectory",
"(",
"self",
",",
"self",
".",
"tr",
"(",
"'Select download director... | Show a dialog to choose directory. | [
"Show",
"a",
"dialog",
"to",
"choose",
"directory",
"."
] | python | train | 52 |
django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L261-L296 | def get_lines(self, force=False):
"""
Return a list of lists or strings, representing the code body.
Each list is a block, each string is a statement.
force (True or False): if an attribute object cannot be included,
it is usually skipped to be processed later. With 'force' set,... | [
"def",
"get_lines",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"code_lines",
"=",
"[",
"]",
"# Don't return anything if this is an instance that should be skipped",
"if",
"self",
".",
"skip",
"(",
")",
":",
"return",
"[",
"]",
"# Initialise our new object",
... | Return a list of lists or strings, representing the code body.
Each list is a block, each string is a statement.
force (True or False): if an attribute object cannot be included,
it is usually skipped to be processed later. With 'force' set, there
will be no waiting: a get_or_create() c... | [
"Return",
"a",
"list",
"of",
"lists",
"or",
"strings",
"representing",
"the",
"code",
"body",
".",
"Each",
"list",
"is",
"a",
"block",
"each",
"string",
"is",
"a",
"statement",
"."
] | python | train | 34.861111 |
pivotal-energy-solutions/django-datatable-view | datatableview/datatables.py | https://github.com/pivotal-energy-solutions/django-datatable-view/blob/00b77a9b5051c34e258c51b06c020e92edf15034/datatableview/datatables.py#L1010-L1032 | def resolve_virtual_columns(self, *names):
"""
Assume that all ``names`` are legacy-style tuple declarations, and generate modern columns
instances to match the behavior of the old syntax.
"""
from .views.legacy import get_field_definition
virtual_columns = {}
for... | [
"def",
"resolve_virtual_columns",
"(",
"self",
",",
"*",
"names",
")",
":",
"from",
".",
"views",
".",
"legacy",
"import",
"get_field_definition",
"virtual_columns",
"=",
"{",
"}",
"for",
"name",
"in",
"names",
":",
"field",
"=",
"get_field_definition",
"(",
... | Assume that all ``names`` are legacy-style tuple declarations, and generate modern columns
instances to match the behavior of the old syntax. | [
"Assume",
"that",
"all",
"names",
"are",
"legacy",
"-",
"style",
"tuple",
"declarations",
"and",
"generate",
"modern",
"columns",
"instances",
"to",
"match",
"the",
"behavior",
"of",
"the",
"old",
"syntax",
"."
] | python | train | 45.608696 |
trailofbits/manticore | manticore/platforms/decree.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/decree.py#L545-L596 | def sys_transmit(self, cpu, fd, buf, count, tx_bytes):
""" transmit - send bytes through a file descriptor
The transmit system call writes up to count bytes from the buffer pointed
to by buf to the file descriptor fd. If count is zero, transmit returns 0
and optionally sets *tx_by... | [
"def",
"sys_transmit",
"(",
"self",
",",
"cpu",
",",
"fd",
",",
"buf",
",",
"count",
",",
"tx_bytes",
")",
":",
"data",
"=",
"[",
"]",
"if",
"count",
"!=",
"0",
":",
"if",
"not",
"self",
".",
"_is_open",
"(",
"fd",
")",
":",
"logger",
".",
"err... | transmit - send bytes through a file descriptor
The transmit system call writes up to count bytes from the buffer pointed
to by buf to the file descriptor fd. If count is zero, transmit returns 0
and optionally sets *tx_bytes to zero.
:param cpu current CPU
... | [
"transmit",
"-",
"send",
"bytes",
"through",
"a",
"file",
"descriptor",
"The",
"transmit",
"system",
"call",
"writes",
"up",
"to",
"count",
"bytes",
"from",
"the",
"buffer",
"pointed",
"to",
"by",
"buf",
"to",
"the",
"file",
"descriptor",
"fd",
".",
"If",
... | python | valid | 44.846154 |
pyroscope/pyrocore | src/pyrocore/ui/categories.py | https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/ui/categories.py#L53-L91 | def mainloop(self):
""" Manage category views.
"""
# Get client state
proxy = config.engine.open()
views = [x for x in sorted(proxy.view.list()) if x.startswith(self.PREFIX)]
current_view = real_current_view = proxy.ui.current_view()
if current_view not in views:... | [
"def",
"mainloop",
"(",
"self",
")",
":",
"# Get client state",
"proxy",
"=",
"config",
".",
"engine",
".",
"open",
"(",
")",
"views",
"=",
"[",
"x",
"for",
"x",
"in",
"sorted",
"(",
"proxy",
".",
"view",
".",
"list",
"(",
")",
")",
"if",
"x",
".... | Manage category views. | [
"Manage",
"category",
"views",
"."
] | python | train | 40.538462 |
EntilZha/PyFunctional | functional/transformations.py | https://github.com/EntilZha/PyFunctional/blob/ac04e4a8552b0c464a7f492f7c9862424867b63e/functional/transformations.py#L176-L190 | def drop_right_t(n):
"""
Transformation for Sequence.drop_right
:param n: number to drop from right
:return: transformation
"""
if n <= 0:
end_index = None
else:
end_index = -n
return Transformation(
'drop_right({0})'.format(n),
lambda sequence: sequence[:... | [
"def",
"drop_right_t",
"(",
"n",
")",
":",
"if",
"n",
"<=",
"0",
":",
"end_index",
"=",
"None",
"else",
":",
"end_index",
"=",
"-",
"n",
"return",
"Transformation",
"(",
"'drop_right({0})'",
".",
"format",
"(",
"n",
")",
",",
"lambda",
"sequence",
":",... | Transformation for Sequence.drop_right
:param n: number to drop from right
:return: transformation | [
"Transformation",
"for",
"Sequence",
".",
"drop_right",
":",
"param",
"n",
":",
"number",
"to",
"drop",
"from",
"right",
":",
"return",
":",
"transformation"
] | python | train | 22.4 |
riga/law | law/workflow/remote.py | https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/workflow/remote.py#L973-L987 | def forward_dashboard_event(self, dashboard, job_data, event, job_num):
"""
Hook to preprocess and publish dashboard events. By default, every event is passed to the
dashboard's :py:meth:`law.job.dashboard.BaseJobDashboard.publish` method unchanged.
"""
# possible events:
... | [
"def",
"forward_dashboard_event",
"(",
"self",
",",
"dashboard",
",",
"job_data",
",",
"event",
",",
"job_num",
")",
":",
"# possible events:",
"# - action.submit",
"# - action.cancel",
"# - status.pending",
"# - status.running",
"# - status.finished",
"# - status... | Hook to preprocess and publish dashboard events. By default, every event is passed to the
dashboard's :py:meth:`law.job.dashboard.BaseJobDashboard.publish` method unchanged. | [
"Hook",
"to",
"preprocess",
"and",
"publish",
"dashboard",
"events",
".",
"By",
"default",
"every",
"event",
"is",
"passed",
"to",
"the",
"dashboard",
"s",
":",
"py",
":",
"meth",
":",
"law",
".",
"job",
".",
"dashboard",
".",
"BaseJobDashboard",
".",
"p... | python | train | 40.733333 |
yinkaisheng/Python-UIAutomation-for-Windows | uiautomation/uiautomation.py | https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L3172-L3183 | def GetSubBitmap(self, x: int, y: int, width: int, height: int) -> 'Bitmap':
"""
x: int.
y: int.
width: int.
height: int.
Return `Bitmap`, a sub bitmap of the input rect.
"""
colors = self.GetPixelColorsOfRect(x, y, width, height)
bitmap = Bitmap(w... | [
"def",
"GetSubBitmap",
"(",
"self",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
",",
"width",
":",
"int",
",",
"height",
":",
"int",
")",
"->",
"'Bitmap'",
":",
"colors",
"=",
"self",
".",
"GetPixelColorsOfRect",
"(",
"x",
",",
"y",
",",
"width",
... | x: int.
y: int.
width: int.
height: int.
Return `Bitmap`, a sub bitmap of the input rect. | [
"x",
":",
"int",
".",
"y",
":",
"int",
".",
"width",
":",
"int",
".",
"height",
":",
"int",
".",
"Return",
"Bitmap",
"a",
"sub",
"bitmap",
"of",
"the",
"input",
"rect",
"."
] | python | valid | 34.083333 |
dw/mitogen | examples/the_basics.py | https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/examples/the_basics.py#L60-L72 | def get_password_hash(username):
"""
Fetch a user's password hash.
"""
try:
h = spwd.getspnam(username)
except KeyError:
return None
# mitogen.core.Secret() is a Unicode subclass with a repr() that hides the
# secret data. This keeps secret stuff out of logs. Like blobs, sec... | [
"def",
"get_password_hash",
"(",
"username",
")",
":",
"try",
":",
"h",
"=",
"spwd",
".",
"getspnam",
"(",
"username",
")",
"except",
"KeyError",
":",
"return",
"None",
"# mitogen.core.Secret() is a Unicode subclass with a repr() that hides the",
"# secret data. This keep... | Fetch a user's password hash. | [
"Fetch",
"a",
"user",
"s",
"password",
"hash",
"."
] | python | train | 28.923077 |
sharibarboza/py_zap | py_zap/py_zap.py | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/py_zap.py#L451-L457 | def _get_net(self, entry):
"""Get the network for a specific row"""
try:
net = entry[1]
return net[net.find('(')+1:net.find(')')]
except IndexError:
return None | [
"def",
"_get_net",
"(",
"self",
",",
"entry",
")",
":",
"try",
":",
"net",
"=",
"entry",
"[",
"1",
"]",
"return",
"net",
"[",
"net",
".",
"find",
"(",
"'('",
")",
"+",
"1",
":",
"net",
".",
"find",
"(",
"')'",
")",
"]",
"except",
"IndexError",
... | Get the network for a specific row | [
"Get",
"the",
"network",
"for",
"a",
"specific",
"row"
] | python | train | 30.571429 |
halfak/deltas | deltas/algorithms/segment_matcher.py | https://github.com/halfak/deltas/blob/4173f4215b93426a877f4bb4a7a3547834e60ac3/deltas/algorithms/segment_matcher.py#L250-L263 | def _get_matchable_segments(segments):
"""
Performs a depth-first search of the segment tree to get all matchable
segments.
"""
for subsegment in segments:
if isinstance(subsegment, Token):
break # No tokens allowed next to segments
if isinstance(subsegment, Segment):
... | [
"def",
"_get_matchable_segments",
"(",
"segments",
")",
":",
"for",
"subsegment",
"in",
"segments",
":",
"if",
"isinstance",
"(",
"subsegment",
",",
"Token",
")",
":",
"break",
"# No tokens allowed next to segments",
"if",
"isinstance",
"(",
"subsegment",
",",
"Se... | Performs a depth-first search of the segment tree to get all matchable
segments. | [
"Performs",
"a",
"depth",
"-",
"first",
"search",
"of",
"the",
"segment",
"tree",
"to",
"get",
"all",
"matchable",
"segments",
"."
] | python | train | 36.714286 |
clchiou/startup | startup.py | https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L308-L319 | def _notify_reader_writes(writeto):
"""Notify reader closures about these writes and return a sorted
list of thus-satisfied closures.
"""
satisfied = []
for var in writeto:
if var.readable:
for reader in var.readers:
reader.notify_read_ready()
i... | [
"def",
"_notify_reader_writes",
"(",
"writeto",
")",
":",
"satisfied",
"=",
"[",
"]",
"for",
"var",
"in",
"writeto",
":",
"if",
"var",
".",
"readable",
":",
"for",
"reader",
"in",
"var",
".",
"readers",
":",
"reader",
".",
"notify_read_ready",
"(",
")",
... | Notify reader closures about these writes and return a sorted
list of thus-satisfied closures. | [
"Notify",
"reader",
"closures",
"about",
"these",
"writes",
"and",
"return",
"a",
"sorted",
"list",
"of",
"thus",
"-",
"satisfied",
"closures",
"."
] | python | train | 34 |
bcbio/bcbio-nextgen | bcbio/structural/cnvkit.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/cnvkit.py#L41-L51 | def bin_approach(data):
"""Check for binning approach from configuration or normalized file.
"""
for approach in ["cnvkit", "gatk-cnv"]:
if approach in dd.get_svcaller(data):
return approach
norm_file = tz.get_in(["depth", "bins", "normalized"], data)
if norm_file.endswith(("-crs... | [
"def",
"bin_approach",
"(",
"data",
")",
":",
"for",
"approach",
"in",
"[",
"\"cnvkit\"",
",",
"\"gatk-cnv\"",
"]",
":",
"if",
"approach",
"in",
"dd",
".",
"get_svcaller",
"(",
"data",
")",
":",
"return",
"approach",
"norm_file",
"=",
"tz",
".",
"get_in"... | Check for binning approach from configuration or normalized file. | [
"Check",
"for",
"binning",
"approach",
"from",
"configuration",
"or",
"normalized",
"file",
"."
] | python | train | 39.363636 |
yvesalexandre/bandicoot | bandicoot/network.py | https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/network.py#L286-L314 | def assortativity_attributes(user):
"""
Computes the assortativity of the nominal attributes.
This indicator measures the homophily of the current user with his
correspondants, for each attributes. It returns a value between 0
(no assortativity) and 1 (all the contacts share the same value):
th... | [
"def",
"assortativity_attributes",
"(",
"user",
")",
":",
"matrix",
"=",
"matrix_undirected_unweighted",
"(",
"user",
")",
"neighbors",
"=",
"[",
"k",
"for",
"k",
"in",
"user",
".",
"network",
".",
"keys",
"(",
")",
"if",
"k",
"!=",
"user",
".",
"name",
... | Computes the assortativity of the nominal attributes.
This indicator measures the homophily of the current user with his
correspondants, for each attributes. It returns a value between 0
(no assortativity) and 1 (all the contacts share the same value):
the percentage of contacts sharing the same value. | [
"Computes",
"the",
"assortativity",
"of",
"the",
"nominal",
"attributes",
"."
] | python | train | 39.206897 |
pvlib/pvlib-python | pvlib/singlediode.py | https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/singlediode.py#L32-L67 | def estimate_voc(photocurrent, saturation_current, nNsVth):
"""
Rough estimate of open circuit voltage useful for bounding searches for
``i`` of ``v`` when using :func:`~pvlib.pvsystem.singlediode`.
Parameters
----------
photocurrent : numeric
photo-generated current [A]
saturation_... | [
"def",
"estimate_voc",
"(",
"photocurrent",
",",
"saturation_current",
",",
"nNsVth",
")",
":",
"return",
"nNsVth",
"*",
"np",
".",
"log",
"(",
"np",
".",
"asarray",
"(",
"photocurrent",
")",
"/",
"saturation_current",
"+",
"1.0",
")"
] | Rough estimate of open circuit voltage useful for bounding searches for
``i`` of ``v`` when using :func:`~pvlib.pvsystem.singlediode`.
Parameters
----------
photocurrent : numeric
photo-generated current [A]
saturation_current : numeric
diode reverse saturation current [A]
nNsVt... | [
"Rough",
"estimate",
"of",
"open",
"circuit",
"voltage",
"useful",
"for",
"bounding",
"searches",
"for",
"i",
"of",
"v",
"when",
"using",
":",
"func",
":",
"~pvlib",
".",
"pvsystem",
".",
"singlediode",
"."
] | python | train | 32.388889 |
xapple/plumbing | plumbing/databases/access_database.py | https://github.com/xapple/plumbing/blob/4a7706c7722f5996d0ca366f191aff9ac145880a/plumbing/databases/access_database.py#L155-L158 | def tables_with_counts(self):
"""Return the number of entries in all table."""
table_to_count = lambda t: self.count_rows(t)
return zip(self.tables, map(table_to_count, self.tables)) | [
"def",
"tables_with_counts",
"(",
"self",
")",
":",
"table_to_count",
"=",
"lambda",
"t",
":",
"self",
".",
"count_rows",
"(",
"t",
")",
"return",
"zip",
"(",
"self",
".",
"tables",
",",
"map",
"(",
"table_to_count",
",",
"self",
".",
"tables",
")",
")... | Return the number of entries in all table. | [
"Return",
"the",
"number",
"of",
"entries",
"in",
"all",
"table",
"."
] | python | train | 50.75 |
SoCo/SoCo | soco/core.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L865-L987 | def _parse_zone_group_state(self):
"""The Zone Group State contains a lot of useful information.
Retrieve and parse it, and populate the relevant properties.
"""
# zoneGroupTopology.GetZoneGroupState()['ZoneGroupState'] returns XML like
# this:
#
# <ZoneGroups>
# <ZoneGroup Coordinator="RINC... | [
"def",
"_parse_zone_group_state",
"(",
"self",
")",
":",
"# zoneGroupTopology.GetZoneGroupState()['ZoneGroupState'] returns XML like",
"# this:",
"#",
"# <ZoneGroups>",
"# <ZoneGroup Coordinator=\"RINCON_000XXX1400\" ID=\"RINCON_000XXXX1400:0\">",
"# <ZoneGroupMember",
"# BootS... | The Zone Group State contains a lot of useful information.
Retrieve and parse it, and populate the relevant properties. | [
"The",
"Zone",
"Group",
"State",
"contains",
"a",
"lot",
"of",
"useful",
"information",
"."
] | python | train | 43.569106 |
datadotworld/data.world-py | datadotworld/client/api.py | https://github.com/datadotworld/data.world-py/blob/ffaeb115f358731ab0b805b0c43b7ff2e3cf0a77/datadotworld/client/api.py#L696-L726 | def sparql(self, dataset_key, query,
desired_mimetype='application/sparql-results+json', **kwargs):
"""Executes SPARQL queries against a dataset via POST
:param dataset_key: Dataset identifier, in the form of owner/id
:type dataset_key: str
:param query: SPARQL query
... | [
"def",
"sparql",
"(",
"self",
",",
"dataset_key",
",",
"query",
",",
"desired_mimetype",
"=",
"'application/sparql-results+json'",
",",
"*",
"*",
"kwargs",
")",
":",
"api_client",
"=",
"self",
".",
"_build_api_client",
"(",
"default_mimetype_header_accept",
"=",
"... | Executes SPARQL queries against a dataset via POST
:param dataset_key: Dataset identifier, in the form of owner/id
:type dataset_key: str
:param query: SPARQL query
:type query: str
:returns: file object that can be used in file parsers and
data handling modules.
... | [
"Executes",
"SPARQL",
"queries",
"against",
"a",
"dataset",
"via",
"POST"
] | python | train | 41.322581 |
sony/nnabla | python/src/nnabla/experimental/viewers.py | https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/experimental/viewers.py#L208-L254 | def create_graphviz_digraph(self, vleaf, format=None):
'''
Create a :obj:`graphviz.Digraph` object given the leaf variable of a
computation graph.
One of nice things of getting ``Digraph`` directly is that the drawn
graph can be displayed inline in a Jupyter notebook as describe... | [
"def",
"create_graphviz_digraph",
"(",
"self",
",",
"vleaf",
",",
"format",
"=",
"None",
")",
":",
"from",
"nnabla",
"import",
"get_parameters",
"import",
"copy",
"try",
":",
"from",
"graphviz",
"import",
"Digraph",
"except",
":",
"raise",
"ImportError",
"(",
... | Create a :obj:`graphviz.Digraph` object given the leaf variable of a
computation graph.
One of nice things of getting ``Digraph`` directly is that the drawn
graph can be displayed inline in a Jupyter notebook as described in
`Graphviz documentation <https://graphviz.readthedocs.io/en/st... | [
"Create",
"a",
":",
"obj",
":",
"graphviz",
".",
"Digraph",
"object",
"given",
"the",
"leaf",
"variable",
"of",
"a",
"computation",
"graph",
"."
] | python | train | 37.446809 |
bootphon/h5features | h5features/data.py | https://github.com/bootphon/h5features/blob/d5f95db0f1cee58ac1ba4575d1212e796c39e1f9/h5features/data.py#L147-L158 | def is_appendable_to(self, group):
"""Returns True if the data can be appended in a given group."""
# First check only the names
if not all([k in group for k in self._entries.keys()]):
return False
# If names are matching, check the contents
for k in self._entries.ke... | [
"def",
"is_appendable_to",
"(",
"self",
",",
"group",
")",
":",
"# First check only the names",
"if",
"not",
"all",
"(",
"[",
"k",
"in",
"group",
"for",
"k",
"in",
"self",
".",
"_entries",
".",
"keys",
"(",
")",
"]",
")",
":",
"return",
"False",
"# If ... | Returns True if the data can be appended in a given group. | [
"Returns",
"True",
"if",
"the",
"data",
"can",
"be",
"appended",
"in",
"a",
"given",
"group",
"."
] | python | train | 35.416667 |
Rackspace-DOT/flask_keystone | flask_keystone/__init__.py | https://github.com/Rackspace-DOT/flask_keystone/blob/6f6d630e9e66a3beca6607b0b786510ec2a79747/flask_keystone/__init__.py#L86-L123 | def init_app(self, app, config_group="flask_keystone"):
"""
Iniitialize the Flask_Keystone module in an application factory.
:param app: `flask.Flask` application to which to connect.
:type app: `flask.Flask`
:param str config_group: :class:`oslo_config.cfg.OptGroup` to which
... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"config_group",
"=",
"\"flask_keystone\"",
")",
":",
"cfg",
".",
"CONF",
".",
"register_opts",
"(",
"RAX_OPTS",
",",
"group",
"=",
"config_group",
")",
"self",
".",
"logger",
"=",
"logging",
".",
"getLogger"... | Iniitialize the Flask_Keystone module in an application factory.
:param app: `flask.Flask` application to which to connect.
:type app: `flask.Flask`
:param str config_group: :class:`oslo_config.cfg.OptGroup` to which
to attach.
When initialized, the ext... | [
"Iniitialize",
"the",
"Flask_Keystone",
"module",
"in",
"an",
"application",
"factory",
"."
] | python | train | 43.736842 |
jlmadurga/permabots | permabots/views/api/bot.py | https://github.com/jlmadurga/permabots/blob/781a91702529a23fe7bc2aa84c5d88e961412466/permabots/views/api/bot.py#L62-L82 | def put(self, request, id, format=None):
"""
Update an existing bot
---
serializer: BotUpdateSerializer
responseMessages:
- code: 401
message: Not authenticated
- code: 400
message: Not valid request
"""
bot = se... | [
"def",
"put",
"(",
"self",
",",
"request",
",",
"id",
",",
"format",
"=",
"None",
")",
":",
"bot",
"=",
"self",
".",
"get_bot",
"(",
"id",
",",
"request",
".",
"user",
")",
"serializer",
"=",
"BotUpdateSerializer",
"(",
"bot",
",",
"data",
"=",
"re... | Update an existing bot
---
serializer: BotUpdateSerializer
responseMessages:
- code: 401
message: Not authenticated
- code: 400
message: Not valid request | [
"Update",
"an",
"existing",
"bot",
"---",
"serializer",
":",
"BotUpdateSerializer",
"responseMessages",
":",
"-",
"code",
":",
"401",
"message",
":",
"Not",
"authenticated",
"-",
"code",
":",
"400",
"message",
":",
"Not",
"valid",
"request"
] | python | train | 34.571429 |
lsst-sqre/lsst-projectmeta-kit | lsstprojectmeta/jsonld.py | https://github.com/lsst-sqre/lsst-projectmeta-kit/blob/ac8d4ff65bb93d8fdeb1b46ae6eb5d7414f1ae14/lsstprojectmeta/jsonld.py#L34-L44 | def default(self, obj):
"""Encode values as JSON strings.
This method overrides the default implementation from
`json.JSONEncoder`.
"""
if isinstance(obj, datetime.datetime):
return self._encode_datetime(obj)
# Fallback to the default encoding
return... | [
"def",
"default",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"self",
".",
"_encode_datetime",
"(",
"obj",
")",
"# Fallback to the default encoding",
"return",
"json",
".",
"JSONEnc... | Encode values as JSON strings.
This method overrides the default implementation from
`json.JSONEncoder`. | [
"Encode",
"values",
"as",
"JSON",
"strings",
"."
] | python | valid | 31.454545 |
wmayner/pyphi | pyphi/cache.py | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L396-L414 | def MICECache(subsystem, parent_cache=None):
"""Construct a |MICE| cache.
Uses either a Redis-backed cache or a local dict cache on the object.
Args:
subsystem (Subsystem): The subsystem that this is a cache for.
Kwargs:
parent_cache (MICECache): The cache generated by the uncut
... | [
"def",
"MICECache",
"(",
"subsystem",
",",
"parent_cache",
"=",
"None",
")",
":",
"if",
"config",
".",
"REDIS_CACHE",
":",
"cls",
"=",
"RedisMICECache",
"else",
":",
"cls",
"=",
"DictMICECache",
"return",
"cls",
"(",
"subsystem",
",",
"parent_cache",
"=",
... | Construct a |MICE| cache.
Uses either a Redis-backed cache or a local dict cache on the object.
Args:
subsystem (Subsystem): The subsystem that this is a cache for.
Kwargs:
parent_cache (MICECache): The cache generated by the uncut
version of ``subsystem``. Any cached |MICE| w... | [
"Construct",
"a",
"|MICE|",
"cache",
"."
] | python | train | 33.157895 |
watson-developer-cloud/python-sdk | ibm_watson/speech_to_text_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/speech_to_text_v1.py#L982-L1053 | def create_language_model(self,
name,
base_model_name,
dialect=None,
description=None,
**kwargs):
"""
Create a custom language model.
Creates a n... | [
"def",
"create_language_model",
"(",
"self",
",",
"name",
",",
"base_model_name",
",",
"dialect",
"=",
"None",
",",
"description",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'name must be p... | Create a custom language model.
Creates a new custom language model for a specified base model. The custom
language model can be used only with the base model for which it is created. The
model is owned by the instance of the service whose credentials are used to create
it.
**Se... | [
"Create",
"a",
"custom",
"language",
"model",
"."
] | python | train | 48.375 |
rosenbrockc/acorn | acorn/logging/decoration.py | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/logging/decoration.py#L167-L222 | def _get_name_filter(package, context="decorate", reparse=False):
"""Makes sure that the name filters for the specified package have been
loaded.
Args:
package (str): name of the package that this method belongs to.
context (str): one of ['decorate', 'time', 'analyze']; specifies which
... | [
"def",
"_get_name_filter",
"(",
"package",
",",
"context",
"=",
"\"decorate\"",
",",
"reparse",
"=",
"False",
")",
":",
"global",
"name_filters",
"pkey",
"=",
"(",
"package",
",",
"context",
")",
"if",
"pkey",
"in",
"name_filters",
"and",
"not",
"reparse",
... | Makes sure that the name filters for the specified package have been
loaded.
Args:
package (str): name of the package that this method belongs to.
context (str): one of ['decorate', 'time', 'analyze']; specifies which
section of the configuration settings to check. | [
"Makes",
"sure",
"that",
"the",
"name",
"filters",
"for",
"the",
"specified",
"package",
"have",
"been",
"loaded",
"."
] | python | train | 40.660714 |
wishtack/pysynthetic | synthetic/synthetic_constructor_factory.py | https://github.com/wishtack/pysynthetic/blob/f37a4a2f1e0313b8c544f60d37c93726bc806ec6/synthetic/synthetic_constructor_factory.py#L19-L82 | def makeConstructor(self, originalConstructor, syntheticMemberList, doesConsumeArguments):
"""
:type syntheticMemberList: list(SyntheticMember)
:type doesConsumeArguments: bool
"""
# Original constructor's expected args.
originalConstructorExpectedArgList = []
doesExpectVariadic... | [
"def",
"makeConstructor",
"(",
"self",
",",
"originalConstructor",
",",
"syntheticMemberList",
",",
"doesConsumeArguments",
")",
":",
"# Original constructor's expected args.",
"originalConstructorExpectedArgList",
"=",
"[",
"]",
"doesExpectVariadicArgs",
"=",
"False",
"doesE... | :type syntheticMemberList: list(SyntheticMember)
:type doesConsumeArguments: bool | [
":",
"type",
"syntheticMemberList",
":",
"list",
"(",
"SyntheticMember",
")",
":",
"type",
"doesConsumeArguments",
":",
"bool"
] | python | train | 42.53125 |
saltstack/salt | salt/states/file.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L670-L696 | def _clean_dir(root, keep, exclude_pat):
'''
Clean out all of the files and directories in a directory (root) while
preserving the files in a list (keep) and part of exclude_pat
'''
root = os.path.normcase(root)
real_keep = _find_keep_files(root, keep)
removed = set()
def _delete_not_ke... | [
"def",
"_clean_dir",
"(",
"root",
",",
"keep",
",",
"exclude_pat",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"normcase",
"(",
"root",
")",
"real_keep",
"=",
"_find_keep_files",
"(",
"root",
",",
"keep",
")",
"removed",
"=",
"set",
"(",
")",
"def... | Clean out all of the files and directories in a directory (root) while
preserving the files in a list (keep) and part of exclude_pat | [
"Clean",
"out",
"all",
"of",
"the",
"files",
"and",
"directories",
"in",
"a",
"directory",
"(",
"root",
")",
"while",
"preserving",
"the",
"files",
"in",
"a",
"list",
"(",
"keep",
")",
"and",
"part",
"of",
"exclude_pat"
] | python | train | 36.777778 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/nose/tools/nontrivial.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/nose/tools/nontrivial.py#L39-L70 | def raises(*exceptions):
"""Test must raise one of expected exceptions to pass.
Example use::
@raises(TypeError, ValueError)
def test_raises_type_error():
raise TypeError("This test passes")
@raises(Exception)
def test_that_fails_by_passing():
pass
If you want... | [
"def",
"raises",
"(",
"*",
"exceptions",
")",
":",
"valid",
"=",
"' or '",
".",
"join",
"(",
"[",
"e",
".",
"__name__",
"for",
"e",
"in",
"exceptions",
"]",
")",
"def",
"decorate",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
"__name__",
"def",... | Test must raise one of expected exceptions to pass.
Example use::
@raises(TypeError, ValueError)
def test_raises_type_error():
raise TypeError("This test passes")
@raises(Exception)
def test_that_fails_by_passing():
pass
If you want to test many assertions about e... | [
"Test",
"must",
"raise",
"one",
"of",
"expected",
"exceptions",
"to",
"pass",
"."
] | python | test | 28.5625 |
nicferrier/md | src/mdlib/cli.py | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cli.py#L132-L143 | def do_lisp(self, subcmd, opts, folder=""):
"""${cmd_name}: list messages in the specified folder in JSON format
${cmd_usage}
"""
client = MdClient(self.maildir, filesystem=self.filesystem)
client.lisp(
foldername=folder,
stream=self.stdout,
... | [
"def",
"do_lisp",
"(",
"self",
",",
"subcmd",
",",
"opts",
",",
"folder",
"=",
"\"\"",
")",
":",
"client",
"=",
"MdClient",
"(",
"self",
".",
"maildir",
",",
"filesystem",
"=",
"self",
".",
"filesystem",
")",
"client",
".",
"lisp",
"(",
"foldername",
... | ${cmd_name}: list messages in the specified folder in JSON format
${cmd_usage} | [
"$",
"{",
"cmd_name",
"}",
":",
"list",
"messages",
"in",
"the",
"specified",
"folder",
"in",
"JSON",
"format"
] | python | train | 34.583333 |
readbeyond/aeneas | aeneas/tools/run_sd.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/run_sd.py#L82-L169 | def perform_command(self):
"""
Perform command and return the appropriate exit code.
:rtype: int
"""
if len(self.actual_arguments) < 4:
return self.print_help()
text_format = gf.safe_unicode(self.actual_arguments[0])
if text_format == u"list":
... | [
"def",
"perform_command",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"actual_arguments",
")",
"<",
"4",
":",
"return",
"self",
".",
"print_help",
"(",
")",
"text_format",
"=",
"gf",
".",
"safe_unicode",
"(",
"self",
".",
"actual_arguments",
"[... | Perform command and return the appropriate exit code.
:rtype: int | [
"Perform",
"command",
"and",
"return",
"the",
"appropriate",
"exit",
"code",
"."
] | python | train | 49.931818 |
nickw444/nsw-fuel-api-client | nsw_fuel/client.py | https://github.com/nickw444/nsw-fuel-api-client/blob/06bd9ae7ad094d5965fce3a9468785247e1b5a39/nsw_fuel/client.py#L134-L162 | def get_reference_data(
self,
modified_since: Optional[datetime.datetime] = None
) -> GetReferenceDataResponse:
"""
Fetches API reference data.
:param modified_since: The response will be empty if no
changes have been made to the reference data since this
... | [
"def",
"get_reference_data",
"(",
"self",
",",
"modified_since",
":",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
"=",
"None",
")",
"->",
"GetReferenceDataResponse",
":",
"if",
"modified_since",
"is",
"None",
":",
"modified_since",
"=",
"datetime",
".",
... | Fetches API reference data.
:param modified_since: The response will be empty if no
changes have been made to the reference data since this
timestamp, otherwise all reference data will be returned. | [
"Fetches",
"API",
"reference",
"data",
"."
] | python | valid | 31.896552 |
jwodder/doapi | doapi/doapi.py | https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/doapi.py#L955-L1025 | def _wait(self, objects, attr, value, wait_interval=None, wait_time=None):
r"""
Calls the ``fetch`` method of each object in ``objects`` periodically
until the ``attr`` attribute of each one equals ``value``, yielding the
final state of each object as soon as it satisfies the condition.
... | [
"def",
"_wait",
"(",
"self",
",",
"objects",
",",
"attr",
",",
"value",
",",
"wait_interval",
"=",
"None",
",",
"wait_time",
"=",
"None",
")",
":",
"objects",
"=",
"list",
"(",
"objects",
")",
"if",
"not",
"objects",
":",
"return",
"if",
"wait_interval... | r"""
Calls the ``fetch`` method of each object in ``objects`` periodically
until the ``attr`` attribute of each one equals ``value``, yielding the
final state of each object as soon as it satisfies the condition.
If ``wait_time`` is exceeded, a `WaitTimeoutError` (containing any
... | [
"r",
"Calls",
"the",
"fetch",
"method",
"of",
"each",
"object",
"in",
"objects",
"periodically",
"until",
"the",
"attr",
"attribute",
"of",
"each",
"one",
"equals",
"value",
"yielding",
"the",
"final",
"state",
"of",
"each",
"object",
"as",
"soon",
"as",
"... | python | train | 39.788732 |
twisted/mantissa | xmantissa/fulltext.py | https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/fulltext.py#L687-L703 | def remoteIndexer2to3(oldIndexer):
"""
The documentType keyword was added to all indexable items. Indexes need to
be regenerated for this to take effect. Also, PyLucene no longer stores
the text of messages it indexes, so deleting and re-creating the indexes
will make them much smaller.
"""
... | [
"def",
"remoteIndexer2to3",
"(",
"oldIndexer",
")",
":",
"newIndexer",
"=",
"oldIndexer",
".",
"upgradeVersion",
"(",
"oldIndexer",
".",
"typeName",
",",
"2",
",",
"3",
",",
"indexCount",
"=",
"oldIndexer",
".",
"indexCount",
",",
"installedOn",
"=",
"oldIndex... | The documentType keyword was added to all indexable items. Indexes need to
be regenerated for this to take effect. Also, PyLucene no longer stores
the text of messages it indexes, so deleting and re-creating the indexes
will make them much smaller. | [
"The",
"documentType",
"keyword",
"was",
"added",
"to",
"all",
"indexable",
"items",
".",
"Indexes",
"need",
"to",
"be",
"regenerated",
"for",
"this",
"to",
"take",
"effect",
".",
"Also",
"PyLucene",
"no",
"longer",
"stores",
"the",
"text",
"of",
"messages",... | python | train | 44.294118 |
DLR-RM/RAFCON | source/rafcon/core/execution/execution_engine.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/execution/execution_engine.py#L70-L80 | def pause(self):
"""Set the execution mode to paused
"""
if self.state_machine_manager.active_state_machine_id is None:
logger.info("'Pause' is not a valid action to initiate state machine execution.")
return
if self.state_machine_manager.get_active_state_machine(... | [
"def",
"pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"state_machine_manager",
".",
"active_state_machine_id",
"is",
"None",
":",
"logger",
".",
"info",
"(",
"\"'Pause' is not a valid action to initiate state machine execution.\"",
")",
"return",
"if",
"self",
"."... | Set the execution mode to paused | [
"Set",
"the",
"execution",
"mode",
"to",
"paused"
] | python | train | 49.181818 |
disqus/nydus | nydus/db/promise.py | https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/promise.py#L13-L27 | def promise_method(func):
"""
A decorator which ensures that once a method has been marked as resolved
(via Class.__resolved)) will then propagate the attribute (function) call
upstream.
"""
name = func.__name__
@wraps(func)
def wrapped(self, *args, **kwargs):
cls_name = type(se... | [
"def",
"promise_method",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
"__name__",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls_name",
"=",
"type",
"(",
"self",
")",
"... | A decorator which ensures that once a method has been marked as resolved
(via Class.__resolved)) will then propagate the attribute (function) call
upstream. | [
"A",
"decorator",
"which",
"ensures",
"that",
"once",
"a",
"method",
"has",
"been",
"marked",
"as",
"resolved",
"(",
"via",
"Class",
".",
"__resolved",
"))",
"will",
"then",
"propagate",
"the",
"attribute",
"(",
"function",
")",
"call",
"upstream",
"."
] | python | train | 35.466667 |
waqasbhatti/astrobase | astrobase/periodbase/zgls.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/periodbase/zgls.py#L161-L265 | def generalized_lsp_value_withtau(times, mags, errs, omega):
'''Generalized LSP value for a single omega.
This uses tau to provide an arbitrary time-reference point.
The relations used are::
P(w) = (1/YY) * (YC*YC/CC + YS*YS/SS)
where: YC, YS, CC, and SS are all calculated at T
... | [
"def",
"generalized_lsp_value_withtau",
"(",
"times",
",",
"mags",
",",
"errs",
",",
"omega",
")",
":",
"one_over_errs2",
"=",
"1.0",
"/",
"(",
"errs",
"*",
"errs",
")",
"W",
"=",
"npsum",
"(",
"one_over_errs2",
")",
"wi",
"=",
"one_over_errs2",
"/",
"W"... | Generalized LSP value for a single omega.
This uses tau to provide an arbitrary time-reference point.
The relations used are::
P(w) = (1/YY) * (YC*YC/CC + YS*YS/SS)
where: YC, YS, CC, and SS are all calculated at T
and where: tan 2omegaT = 2*CS/(CC - SS)
and where:
... | [
"Generalized",
"LSP",
"value",
"for",
"a",
"single",
"omega",
"."
] | python | valid | 25.8 |
koszullab/metaTOR | metator/scripts/network.py | https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/network.py#L42-L348 | def alignment_to_contacts(
sam_merged,
assembly,
output_dir,
output_file_network=DEFAULT_NETWORK_FILE_NAME,
output_file_chunk_data=DEFAULT_CHUNK_DATA_FILE_NAME,
parameters=DEFAULT_PARAMETERS,
):
"""Generates a network file (in edgelist form) from an
alignment in sam or bam format. Contig... | [
"def",
"alignment_to_contacts",
"(",
"sam_merged",
",",
"assembly",
",",
"output_dir",
",",
"output_file_network",
"=",
"DEFAULT_NETWORK_FILE_NAME",
",",
"output_file_chunk_data",
"=",
"DEFAULT_CHUNK_DATA_FILE_NAME",
",",
"parameters",
"=",
"DEFAULT_PARAMETERS",
",",
")",
... | Generates a network file (in edgelist form) from an
alignment in sam or bam format. Contigs are virtually split into
'chunks' of nearly fixed size (by default between 500 and 1000 bp)
to reduce size bias. The chunks are the network nodes and the edges
are the contact counts.
The network is in a str... | [
"Generates",
"a",
"network",
"file",
"(",
"in",
"edgelist",
"form",
")",
"from",
"an",
"alignment",
"in",
"sam",
"or",
"bam",
"format",
".",
"Contigs",
"are",
"virtually",
"split",
"into",
"chunks",
"of",
"nearly",
"fixed",
"size",
"(",
"by",
"default",
... | python | train | 37.319218 |
gem/oq-engine | openquake/server/db/actions.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/server/db/actions.py#L331-L367 | def del_calc(db, job_id, user):
"""
Delete a calculation and all associated outputs, if possible.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: job ID, can be an integer or a string
:param user: username
:returns: None if everything went fine or an error message
""... | [
"def",
"del_calc",
"(",
"db",
",",
"job_id",
",",
"user",
")",
":",
"job_id",
"=",
"int",
"(",
"job_id",
")",
"dependent",
"=",
"db",
"(",
"'SELECT id FROM job WHERE hazard_calculation_id=?x'",
",",
"job_id",
")",
"if",
"dependent",
":",
"return",
"{",
"\"er... | Delete a calculation and all associated outputs, if possible.
:param db: a :class:`openquake.server.dbapi.Db` instance
:param job_id: job ID, can be an integer or a string
:param user: username
:returns: None if everything went fine or an error message | [
"Delete",
"a",
"calculation",
"and",
"all",
"associated",
"outputs",
"if",
"possible",
"."
] | python | train | 38.594595 |
PMBio/limix-backup | limix/stats/pca.py | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/pca.py#L56-L74 | def PC_varExplained(Y,standardized=True):
"""
Run PCA and calculate the cumulative fraction of variance
Args:
Y: phenotype values
standardize: if True, phenotypes are standardized
Returns:
var: cumulative distribution of variance explained
"""
# figuring out the number of... | [
"def",
"PC_varExplained",
"(",
"Y",
",",
"standardized",
"=",
"True",
")",
":",
"# figuring out the number of latent factors",
"if",
"standardized",
":",
"Y",
"-=",
"Y",
".",
"mean",
"(",
"0",
")",
"Y",
"/=",
"Y",
".",
"std",
"(",
"0",
")",
"covY",
"=",
... | Run PCA and calculate the cumulative fraction of variance
Args:
Y: phenotype values
standardize: if True, phenotypes are standardized
Returns:
var: cumulative distribution of variance explained | [
"Run",
"PCA",
"and",
"calculate",
"the",
"cumulative",
"fraction",
"of",
"variance",
"Args",
":",
"Y",
":",
"phenotype",
"values",
"standardize",
":",
"if",
"True",
"phenotypes",
"are",
"standardized",
"Returns",
":",
"var",
":",
"cumulative",
"distribution",
... | python | train | 29.736842 |
jeremymcrae/denovonear | denovonear/ensembl_requester.py | https://github.com/jeremymcrae/denovonear/blob/feaab0fc77e89d70b31e8092899e4f0e68bac9fe/denovonear/ensembl_requester.py#L150-L167 | def get_genes_for_hgnc_id(self, hgnc_symbol):
""" obtain the ensembl gene IDs that correspond to a HGNC symbol
"""
headers = {"content-type": "application/json"}
# http://grch37.rest.ensembl.org/xrefs/symbol/homo_sapiens/KMT2A?content-type=application/json
... | [
"def",
"get_genes_for_hgnc_id",
"(",
"self",
",",
"hgnc_symbol",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
"}",
"# http://grch37.rest.ensembl.org/xrefs/symbol/homo_sapiens/KMT2A?content-type=application/json",
"self",
".",
"attempt",
"=",
... | obtain the ensembl gene IDs that correspond to a HGNC symbol | [
"obtain",
"the",
"ensembl",
"gene",
"IDs",
"that",
"correspond",
"to",
"a",
"HGNC",
"symbol"
] | python | train | 33.833333 |
mongodb/mongo-python-driver | pymongo/helpers.py | https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/helpers.py#L74-L98 | def _index_document(index_list):
"""Helper to generate an index specifying document.
Takes a list of (key, direction) pairs.
"""
if isinstance(index_list, abc.Mapping):
raise TypeError("passing a dict to sort/create_index/hint is not "
"allowed - use a list of tuples ins... | [
"def",
"_index_document",
"(",
"index_list",
")",
":",
"if",
"isinstance",
"(",
"index_list",
",",
"abc",
".",
"Mapping",
")",
":",
"raise",
"TypeError",
"(",
"\"passing a dict to sort/create_index/hint is not \"",
"\"allowed - use a list of tuples instead. did you \"",
"\"... | Helper to generate an index specifying document.
Takes a list of (key, direction) pairs. | [
"Helper",
"to",
"generate",
"an",
"index",
"specifying",
"document",
"."
] | python | train | 45.32 |
brutasse/graphite-api | graphite_api/functions.py | https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L1082-L1096 | def squareRoot(requestContext, seriesList):
"""
Takes one metric or a wildcard seriesList, and computes the square root
of each datapoint.
Example::
&target=squareRoot(Server.instance01.threads.busy)
"""
for series in seriesList:
series.name = "squareRoot(%s)" % (series.name)
... | [
"def",
"squareRoot",
"(",
"requestContext",
",",
"seriesList",
")",
":",
"for",
"series",
"in",
"seriesList",
":",
"series",
".",
"name",
"=",
"\"squareRoot(%s)\"",
"%",
"(",
"series",
".",
"name",
")",
"for",
"i",
",",
"value",
"in",
"enumerate",
"(",
"... | Takes one metric or a wildcard seriesList, and computes the square root
of each datapoint.
Example::
&target=squareRoot(Server.instance01.threads.busy) | [
"Takes",
"one",
"metric",
"or",
"a",
"wildcard",
"seriesList",
"and",
"computes",
"the",
"square",
"root",
"of",
"each",
"datapoint",
"."
] | python | train | 27.6 |
limodou/uliweb | uliweb/core/commands.py | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/commands.py#L295-L342 | def execute(self, callback=None):
"""
Given the command-line arguments, this figures out which subcommand is
being run, creates a parser appropriate to that command, and runs it.
"""
# Preprocess options to extract --settings and --pythonpath.
# These options could ... | [
"def",
"execute",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"# Preprocess options to extract --settings and --pythonpath.\r",
"# These options could affect the commands that are available, so they\r",
"# must be processed early.\r",
"self",
".",
"parser",
"=",
"parser",
... | Given the command-line arguments, this figures out which subcommand is
being run, creates a parser appropriate to that command, and runs it. | [
"Given",
"the",
"command",
"-",
"line",
"arguments",
"this",
"figures",
"out",
"which",
"subcommand",
"is",
"being",
"run",
"creates",
"a",
"parser",
"appropriate",
"to",
"that",
"command",
"and",
"runs",
"it",
"."
] | python | train | 43.5625 |
aaugustin/websockets | src/websockets/http.py | https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/http.py#L187-L204 | async def read_line(stream: asyncio.StreamReader) -> bytes:
"""
Read a single line from ``stream``.
``stream`` is an :class:`~asyncio.StreamReader`.
Return :class:`bytes` without CRLF.
"""
# Security: this is bounded by the StreamReader's limit (default = 32 KiB).
line = await stream.read... | [
"async",
"def",
"read_line",
"(",
"stream",
":",
"asyncio",
".",
"StreamReader",
")",
"->",
"bytes",
":",
"# Security: this is bounded by the StreamReader's limit (default = 32 KiB).",
"line",
"=",
"await",
"stream",
".",
"readline",
"(",
")",
"# Security: this guarantees... | Read a single line from ``stream``.
``stream`` is an :class:`~asyncio.StreamReader`.
Return :class:`bytes` without CRLF. | [
"Read",
"a",
"single",
"line",
"from",
"stream",
"."
] | python | train | 35.444444 |
sorgerlab/indra | indra/preassembler/hierarchy_manager.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/hierarchy_manager.py#L74-L84 | def load_from_rdf_string(self, rdf_str):
"""Initialize given an RDF string representing the hierarchy."
Parameters
----------
rdf_str : str
An RDF string.
"""
self.graph = rdflib.Graph()
self.graph.parse(data=rdf_str, format='nt')
self.initial... | [
"def",
"load_from_rdf_string",
"(",
"self",
",",
"rdf_str",
")",
":",
"self",
".",
"graph",
"=",
"rdflib",
".",
"Graph",
"(",
")",
"self",
".",
"graph",
".",
"parse",
"(",
"data",
"=",
"rdf_str",
",",
"format",
"=",
"'nt'",
")",
"self",
".",
"initial... | Initialize given an RDF string representing the hierarchy."
Parameters
----------
rdf_str : str
An RDF string. | [
"Initialize",
"given",
"an",
"RDF",
"string",
"representing",
"the",
"hierarchy",
"."
] | python | train | 28.636364 |
erikvw/django-collect-offline-files | django_collect_offline_files/transaction/transaction_importer.py | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L199-L217 | def save(self):
"""Saves all model instances in the batch as model.
"""
saved = 0
if not self.objects:
raise BatchError("Save failed. Batch is empty")
for deserialized_tx in self.objects:
try:
self.model.objects.get(pk=deserialized_tx.pk)
... | [
"def",
"save",
"(",
"self",
")",
":",
"saved",
"=",
"0",
"if",
"not",
"self",
".",
"objects",
":",
"raise",
"BatchError",
"(",
"\"Save failed. Batch is empty\"",
")",
"for",
"deserialized_tx",
"in",
"self",
".",
"objects",
":",
"try",
":",
"self",
".",
"... | Saves all model instances in the batch as model. | [
"Saves",
"all",
"model",
"instances",
"in",
"the",
"batch",
"as",
"model",
"."
] | python | train | 37.526316 |
Jajcus/pyxmpp2 | pyxmpp2/cache.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/cache.py#L250-L268 | def error(self, error_data):
"""Handle a retrieval error and call apriopriate handler.
Should be called when retrieval fails.
Do nothing when the fetcher is not active any more (after
one of handlers was already called).
:Parameters:
- `error_data`: additional info... | [
"def",
"error",
"(",
"self",
",",
"error_data",
")",
":",
"if",
"not",
"self",
".",
"active",
":",
"return",
"if",
"not",
"self",
".",
"_try_backup_item",
"(",
")",
":",
"self",
".",
"_error_handler",
"(",
"self",
".",
"address",
",",
"error_data",
")"... | Handle a retrieval error and call apriopriate handler.
Should be called when retrieval fails.
Do nothing when the fetcher is not active any more (after
one of handlers was already called).
:Parameters:
- `error_data`: additional information about the error (e.g. `StanzaErr... | [
"Handle",
"a",
"retrieval",
"error",
"and",
"call",
"apriopriate",
"handler",
"."
] | python | valid | 34.368421 |
Erotemic/utool | utool/util_class.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_class.py#L831-L863 | def get_comparison_methods():
""" makes methods for >, <, =, etc... """
method_list = []
def _register(func):
method_list.append(func)
return func
# Comparison operators for sorting and uniqueness
@_register
def __lt__(self, other):
return compare_instance(op.lt, self, o... | [
"def",
"get_comparison_methods",
"(",
")",
":",
"method_list",
"=",
"[",
"]",
"def",
"_register",
"(",
"func",
")",
":",
"method_list",
".",
"append",
"(",
"func",
")",
"return",
"func",
"# Comparison operators for sorting and uniqueness",
"@",
"_register",
"def",... | makes methods for >, <, =, etc... | [
"makes",
"methods",
"for",
">",
"<",
"=",
"etc",
"..."
] | python | train | 24.30303 |
mapillary/mapillary_tools | mapillary_tools/exif_read.py | https://github.com/mapillary/mapillary_tools/blob/816785e90c589cae6e8e34a5530ce8417d29591c/mapillary_tools/exif_read.py#L150-L185 | def extract_capture_time(self):
'''
Extract capture time from EXIF
return a datetime object
TODO: handle GPS DateTime
'''
time_string = exif_datetime_fields()[0]
capture_time, time_field = self._extract_alternative_fields(
time_string, 0, str)
... | [
"def",
"extract_capture_time",
"(",
"self",
")",
":",
"time_string",
"=",
"exif_datetime_fields",
"(",
")",
"[",
"0",
"]",
"capture_time",
",",
"time_field",
"=",
"self",
".",
"_extract_alternative_fields",
"(",
"time_string",
",",
"0",
",",
"str",
")",
"if",
... | Extract capture time from EXIF
return a datetime object
TODO: handle GPS DateTime | [
"Extract",
"capture",
"time",
"from",
"EXIF",
"return",
"a",
"datetime",
"object",
"TODO",
":",
"handle",
"GPS",
"DateTime"
] | python | train | 39.416667 |
RJT1990/pyflux | pyflux/tsm.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/tsm.py#L303-L345 | def _ols_fit(self):
""" Performs OLS
Returns
----------
None (stores latent variables)
"""
# TO DO - A lot of things are VAR specific here; might need to refactor in future, or just move to VAR script
method = 'OLS'
self.use_ols_covariance = True
... | [
"def",
"_ols_fit",
"(",
"self",
")",
":",
"# TO DO - A lot of things are VAR specific here; might need to refactor in future, or just move to VAR script",
"method",
"=",
"'OLS'",
"self",
".",
"use_ols_covariance",
"=",
"True",
"res_z",
"=",
"self",
".",
"_create_B_direct",
"(... | Performs OLS
Returns
----------
None (stores latent variables) | [
"Performs",
"OLS"
] | python | train | 38.976744 |
OCR-D/core | ocrd_models/ocrd_models/utils.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd_models/ocrd_models/utils.py#L10-L19 | def xmllint_format(xml):
"""
Pretty-print XML like ``xmllint`` does.
Arguments:
xml (string): Serialized XML
"""
parser = ET.XMLParser(resolve_entities=False, strip_cdata=False, remove_blank_text=True)
document = ET.fromstring(xml, parser)
return ('%s\n%s' % ('<?xml version="1.0" en... | [
"def",
"xmllint_format",
"(",
"xml",
")",
":",
"parser",
"=",
"ET",
".",
"XMLParser",
"(",
"resolve_entities",
"=",
"False",
",",
"strip_cdata",
"=",
"False",
",",
"remove_blank_text",
"=",
"True",
")",
"document",
"=",
"ET",
".",
"fromstring",
"(",
"xml",... | Pretty-print XML like ``xmllint`` does.
Arguments:
xml (string): Serialized XML | [
"Pretty",
"-",
"print",
"XML",
"like",
"xmllint",
"does",
"."
] | python | train | 40.4 |
sixty-north/added-value | setup.py | https://github.com/sixty-north/added-value/blob/7ae75b56712822b074fc874612d6058bb7d16a1e/setup.py#L25-L31 | def read_version():
"Read the `(version-string, version-info)` from `added_value/version.py`."
version_file = local_file('source', 'added_value', 'version.py')
local_vars = {}
with open(version_file) as handle:
exec(handle.read(), {}, local_vars) # pylint: disable=exec-used
return local_var... | [
"def",
"read_version",
"(",
")",
":",
"version_file",
"=",
"local_file",
"(",
"'source'",
",",
"'added_value'",
",",
"'version.py'",
")",
"local_vars",
"=",
"{",
"}",
"with",
"open",
"(",
"version_file",
")",
"as",
"handle",
":",
"exec",
"(",
"handle",
"."... | Read the `(version-string, version-info)` from `added_value/version.py`. | [
"Read",
"the",
"(",
"version",
"-",
"string",
"version",
"-",
"info",
")",
"from",
"added_value",
"/",
"version",
".",
"py",
"."
] | python | train | 47.142857 |
ClericPy/torequests | torequests/main.py | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/main.py#L604-L613 | def request(self, method, url, callback=None, retry=0, **kwargs):
"""Similar to `requests.request`, but return as NewFuture."""
return self.pool.submit(
self._request,
method=method,
url=url,
retry=retry,
callback=callback or self.default_callb... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"callback",
"=",
"None",
",",
"retry",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"pool",
".",
"submit",
"(",
"self",
".",
"_request",
",",
"method",
"=",
"me... | Similar to `requests.request`, but return as NewFuture. | [
"Similar",
"to",
"requests",
".",
"request",
"but",
"return",
"as",
"NewFuture",
"."
] | python | train | 34.6 |
jamieleshaw/lurklib | lurklib/__init__.py | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/__init__.py#L86-L97 | def mainloop(self):
"""
Handles events and calls their handler for infinity.
"""
while self.keep_going:
with self.lock:
if self.on_connect and not self.readable(2):
self.on_connect()
self.on_connect = None
... | [
"def",
"mainloop",
"(",
"self",
")",
":",
"while",
"self",
".",
"keep_going",
":",
"with",
"self",
".",
"lock",
":",
"if",
"self",
".",
"on_connect",
"and",
"not",
"self",
".",
"readable",
"(",
"2",
")",
":",
"self",
".",
"on_connect",
"(",
")",
"s... | Handles events and calls their handler for infinity. | [
"Handles",
"events",
"and",
"calls",
"their",
"handler",
"for",
"infinity",
"."
] | python | train | 33 |
mdgoldberg/sportsref | sportsref/nfl/boxscores.py | https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L127-L140 | def week(self):
"""Returns the week in which this game took place. 18 is WC round, 19
is Div round, 20 is CC round, 21 is SB.
:returns: Integer from 1 to 21.
"""
doc = self.get_doc()
raw = doc('div#div_other_scores h2 a').attr['href']
match = re.match(
... | [
"def",
"week",
"(",
"self",
")",
":",
"doc",
"=",
"self",
".",
"get_doc",
"(",
")",
"raw",
"=",
"doc",
"(",
"'div#div_other_scores h2 a'",
")",
".",
"attr",
"[",
"'href'",
"]",
"match",
"=",
"re",
".",
"match",
"(",
"r'/years/{}/week_(\\d+)\\.htm'",
".",... | Returns the week in which this game took place. 18 is WC round, 19
is Div round, 20 is CC round, 21 is SB.
:returns: Integer from 1 to 21. | [
"Returns",
"the",
"week",
"in",
"which",
"this",
"game",
"took",
"place",
".",
"18",
"is",
"WC",
"round",
"19",
"is",
"Div",
"round",
"20",
"is",
"CC",
"round",
"21",
"is",
"SB",
".",
":",
"returns",
":",
"Integer",
"from",
"1",
"to",
"21",
"."
] | python | test | 33.285714 |
sassoftware/saspy | saspy/sasbase.py | https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasbase.py#L551-L560 | def sasets(self) -> 'SASets':
"""
This methods creates a SASets object which you can use to run various analytics.
See the sasets.py module.
:return: sasets object
"""
if not self._loaded_macros:
self._loadmacros()
self._loaded_macros = True
... | [
"def",
"sasets",
"(",
"self",
")",
"->",
"'SASets'",
":",
"if",
"not",
"self",
".",
"_loaded_macros",
":",
"self",
".",
"_loadmacros",
"(",
")",
"self",
".",
"_loaded_macros",
"=",
"True",
"return",
"SASets",
"(",
"self",
")"
] | This methods creates a SASets object which you can use to run various analytics.
See the sasets.py module.
:return: sasets object | [
"This",
"methods",
"creates",
"a",
"SASets",
"object",
"which",
"you",
"can",
"use",
"to",
"run",
"various",
"analytics",
".",
"See",
"the",
"sasets",
".",
"py",
"module",
".",
":",
"return",
":",
"sasets",
"object"
] | python | train | 33.2 |
openstack/proliantutils | proliantutils/ilo/ris.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ris.py#L481-L486 | def _validate_if_patch_supported(self, headers, uri):
"""Check if the PATCH Operation is allowed on the resource."""
if not self._operation_allowed(headers, 'PATCH'):
msg = ('PATCH Operation not supported on the resource '
'"%s"' % uri)
raise except... | [
"def",
"_validate_if_patch_supported",
"(",
"self",
",",
"headers",
",",
"uri",
")",
":",
"if",
"not",
"self",
".",
"_operation_allowed",
"(",
"headers",
",",
"'PATCH'",
")",
":",
"msg",
"=",
"(",
"'PATCH Operation not supported on the resource '",
"'\"%s\"'",
"%"... | Check if the PATCH Operation is allowed on the resource. | [
"Check",
"if",
"the",
"PATCH",
"Operation",
"is",
"allowed",
"on",
"the",
"resource",
"."
] | python | train | 55.333333 |
mozilla-releng/scriptworker | scriptworker/cot/generate.py | https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/generate.py#L96-L128 | def generate_cot(context, parent_path=None):
"""Format and sign the cot body, and write to disk.
Args:
context (scriptworker.context.Context): the scriptworker context.
parent_path (str, optional): The directory to write the chain of trust
artifacts to. If None, this is ``artifact_... | [
"def",
"generate_cot",
"(",
"context",
",",
"parent_path",
"=",
"None",
")",
":",
"body",
"=",
"generate_cot_body",
"(",
"context",
")",
"schema",
"=",
"load_json_or_yaml",
"(",
"context",
".",
"config",
"[",
"'cot_schema_path'",
"]",
",",
"is_path",
"=",
"T... | Format and sign the cot body, and write to disk.
Args:
context (scriptworker.context.Context): the scriptworker context.
parent_path (str, optional): The directory to write the chain of trust
artifacts to. If None, this is ``artifact_dir/public/``.
Defaults to None.
Re... | [
"Format",
"and",
"sign",
"the",
"cot",
"body",
"and",
"write",
"to",
"disk",
"."
] | python | train | 43.030303 |
StackStorm/pybind | pybind/slxos/v17s_1_02/routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/__init__.py#L230-L251 | def _set_ospf_level2(self, v, load=False):
"""
Setter method for ospf_level2, mapped from YANG variable /routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/ospf_level2 (empty)
If this variable is read-only (config:... | [
"def",
"_set_ospf_level2",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for ospf_level2, mapped from YANG variable /routing_system/router/isis/router_isis_cmds_holder/address_family/ipv6/af_ipv6_unicast/af_ipv6_attributes/af_common_attributes/redistribute/ospf/ospf_level2 (empty)
If this variable is read-only (config: false) in the
source YANG file, then _set_ospf_lev... | [
"Setter",
"method",
"for",
"ospf_level2",
"mapped",
"from",
"YANG",
"variable",
"/",
"routing_system",
"/",
"router",
"/",
"isis",
"/",
"router_isis_cmds_holder",
"/",
"address_family",
"/",
"ipv6",
"/",
"af_ipv6_unicast",
"/",
"af_ipv6_attributes",
"/",
"af_common_... | python | train | 84.727273 |
Knoema/knoema-python-driver | knoema/api_client.py | https://github.com/Knoema/knoema-python-driver/blob/e98b13db3e4df51c208c272e2977bfbe4c6e5532/knoema/api_client.py#L168-L172 | def upload_submit(self, upload_request):
"""The method is submitting dataset upload"""
path = '/api/1.0/upload/save'
return self._api_post(definition.DatasetUploadResponse, path, upload_request) | [
"def",
"upload_submit",
"(",
"self",
",",
"upload_request",
")",
":",
"path",
"=",
"'/api/1.0/upload/save'",
"return",
"self",
".",
"_api_post",
"(",
"definition",
".",
"DatasetUploadResponse",
",",
"path",
",",
"upload_request",
")"
] | The method is submitting dataset upload | [
"The",
"method",
"is",
"submitting",
"dataset",
"upload"
] | python | train | 43.8 |
saltstack/salt | salt/modules/vsphere.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L3095-L3157 | def update_host_datetime(host, username, password, protocol=None, port=None, host_names=None):
'''
Update the date/time on the given host or list of host_names. This function should be
used with caution since network delays and execution delays can result in time skews.
host
The location of the... | [
"def",
"update_host_datetime",
"(",
"host",
",",
"username",
",",
"password",
",",
"protocol",
"=",
"None",
",",
"port",
"=",
"None",
",",
"host_names",
"=",
"None",
")",
":",
"service_instance",
"=",
"salt",
".",
"utils",
".",
"vmware",
".",
"get_service_... | Update the date/time on the given host or list of host_names. This function should be
used with caution since network delays and execution delays can result in time skews.
host
The location of the host.
username
The username used to login to the host, such as ``root``.
password
... | [
"Update",
"the",
"date",
"/",
"time",
"on",
"the",
"given",
"host",
"or",
"list",
"of",
"host_names",
".",
"This",
"function",
"should",
"be",
"used",
"with",
"caution",
"since",
"network",
"delays",
"and",
"execution",
"delays",
"can",
"result",
"in",
"ti... | python | train | 40.619048 |
gwastro/pycbc | pycbc/workflow/configuration.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/configuration.py#L796-L816 | def sanity_check_subsections(self):
"""
This function goes through the ConfigParset and checks that any options
given in the [SECTION_NAME] section are not also given in any
[SECTION_NAME-SUBSECTION] sections.
"""
# Loop over the sections in the ini file
for sect... | [
"def",
"sanity_check_subsections",
"(",
"self",
")",
":",
"# Loop over the sections in the ini file",
"for",
"section",
"in",
"self",
".",
"sections",
"(",
")",
":",
"# [pegasus_profile] specially is allowed to be overriden by",
"# sub-sections",
"if",
"section",
"==",
"'pe... | This function goes through the ConfigParset and checks that any options
given in the [SECTION_NAME] section are not also given in any
[SECTION_NAME-SUBSECTION] sections. | [
"This",
"function",
"goes",
"through",
"the",
"ConfigParset",
"and",
"checks",
"that",
"any",
"options",
"given",
"in",
"the",
"[",
"SECTION_NAME",
"]",
"section",
"are",
"not",
"also",
"given",
"in",
"any",
"[",
"SECTION_NAME",
"-",
"SUBSECTION",
"]",
"sect... | python | train | 42.857143 |
pulseenergy/vacation | vacation/transactions.py | https://github.com/pulseenergy/vacation/blob/23c6122590852a5e55d84d366143469af6602839/vacation/transactions.py#L90-L97 | def validate_rc():
""" Before we execute any actions, let's validate our .vacationrc. """
transactions = rc.read()
if not transactions:
print('Your .vacationrc file is empty! Set days and rate.')
return False
transactions = sort(unique(transactions))
return validate_setup(transaction... | [
"def",
"validate_rc",
"(",
")",
":",
"transactions",
"=",
"rc",
".",
"read",
"(",
")",
"if",
"not",
"transactions",
":",
"print",
"(",
"'Your .vacationrc file is empty! Set days and rate.'",
")",
"return",
"False",
"transactions",
"=",
"sort",
"(",
"unique",
"("... | Before we execute any actions, let's validate our .vacationrc. | [
"Before",
"we",
"execute",
"any",
"actions",
"let",
"s",
"validate",
"our",
".",
"vacationrc",
"."
] | python | train | 39.375 |
peterbe/hashin | hashin.py | https://github.com/peterbe/hashin/blob/c3efcba050961257622c475114c087efe675c58a/hashin.py#L621-L688 | def get_package_hashes(
package,
version=None,
algorithm=DEFAULT_ALGORITHM,
python_versions=(),
verbose=False,
include_prereleases=False,
lookup_memory=None,
index_url=DEFAULT_INDEX_URL,
):
"""
Gets the hashes for the given package.
>>> get_package_hashes('hashin')
{
... | [
"def",
"get_package_hashes",
"(",
"package",
",",
"version",
"=",
"None",
",",
"algorithm",
"=",
"DEFAULT_ALGORITHM",
",",
"python_versions",
"=",
"(",
")",
",",
"verbose",
"=",
"False",
",",
"include_prereleases",
"=",
"False",
",",
"lookup_memory",
"=",
"Non... | Gets the hashes for the given package.
>>> get_package_hashes('hashin')
{
'package': 'hashin',
'version': '0.10',
'hashes': [
{
'url': 'https://pypi.org/packages/[...]',
'hash': '45d1c5d2237a3b4f78b4198709fb2ecf[...]'
},
... | [
"Gets",
"the",
"hashes",
"for",
"the",
"given",
"package",
"."
] | python | train | 30.352941 |
ultrabug/py3status | py3status/events.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/events.py#L262-L290 | def run(self):
"""
Wait for an i3bar JSON event, then find the right module to dispatch
the message to based on the 'name' and 'instance' of the event.
In case the module does NOT support click_events, the default
implementation is to clear the module's cache
when the MI... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"while",
"self",
".",
"py3_wrapper",
".",
"running",
":",
"event_str",
"=",
"self",
".",
"poller_inp",
".",
"readline",
"(",
")",
"if",
"not",
"event_str",
":",
"continue",
"try",
":",
"# remove leading co... | Wait for an i3bar JSON event, then find the right module to dispatch
the message to based on the 'name' and 'instance' of the event.
In case the module does NOT support click_events, the default
implementation is to clear the module's cache
when the MIDDLE button (2) is pressed on it.
... | [
"Wait",
"for",
"an",
"i3bar",
"JSON",
"event",
"then",
"find",
"the",
"right",
"module",
"to",
"dispatch",
"the",
"message",
"to",
"based",
"on",
"the",
"name",
"and",
"instance",
"of",
"the",
"event",
"."
] | python | train | 41.724138 |
CybOXProject/mixbox | mixbox/namespaces.py | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L294-L322 | def set_preferred_prefix_for_namespace(self, ns_uri, prefix, add_if_not_exist=False):
"""Sets the preferred prefix for ns_uri. If add_if_not_exist is True,
the prefix is added if it's not already registered. Otherwise,
setting an unknown prefix as preferred is an error. The default
is... | [
"def",
"set_preferred_prefix_for_namespace",
"(",
"self",
",",
"ns_uri",
",",
"prefix",
",",
"add_if_not_exist",
"=",
"False",
")",
":",
"ni",
"=",
"self",
".",
"__lookup_uri",
"(",
"ns_uri",
")",
"if",
"not",
"prefix",
":",
"ni",
".",
"preferred_prefix",
"=... | Sets the preferred prefix for ns_uri. If add_if_not_exist is True,
the prefix is added if it's not already registered. Otherwise,
setting an unknown prefix as preferred is an error. The default
is False. Setting to None always works, and indicates a preference
to use the namespace as... | [
"Sets",
"the",
"preferred",
"prefix",
"for",
"ns_uri",
".",
"If",
"add_if_not_exist",
"is",
"True",
"the",
"prefix",
"is",
"added",
"if",
"it",
"s",
"not",
"already",
"registered",
".",
"Otherwise",
"setting",
"an",
"unknown",
"prefix",
"as",
"preferred",
"i... | python | train | 44 |
delph-in/pydelphin | delphin/itsdb.py | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L659-L681 | def from_file(cls, path, fields=None, encoding='utf-8'):
"""
Instantiate a Table from a database file.
This method instantiates a table attached to the file at *path*.
The file will be opened and traversed to determine the number of
records, but the contents will not be stored i... | [
"def",
"from_file",
"(",
"cls",
",",
"path",
",",
"fields",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"path",
"=",
"_table_filename",
"(",
"path",
")",
"# do early in case file not found",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"_g... | Instantiate a Table from a database file.
This method instantiates a table attached to the file at *path*.
The file will be opened and traversed to determine the number of
records, but the contents will not be stored in memory unless
they are modified.
Args:
path: t... | [
"Instantiate",
"a",
"Table",
"from",
"a",
"database",
"file",
"."
] | python | train | 37.826087 |
square/connect-python-sdk | squareconnect/models/model_break.py | https://github.com/square/connect-python-sdk/blob/adc1d09e817986cdc607391580f71d6b48ed4066/squareconnect/models/model_break.py#L153-L167 | def break_type_id(self, break_type_id):
"""
Sets the break_type_id of this ModelBreak.
The `BreakType` this `Break` was templated on.
:param break_type_id: The break_type_id of this ModelBreak.
:type: str
"""
if break_type_id is None:
raise ValueErro... | [
"def",
"break_type_id",
"(",
"self",
",",
"break_type_id",
")",
":",
"if",
"break_type_id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `break_type_id`, must not be `None`\"",
")",
"if",
"len",
"(",
"break_type_id",
")",
"<",
"1",
":",
"rai... | Sets the break_type_id of this ModelBreak.
The `BreakType` this `Break` was templated on.
:param break_type_id: The break_type_id of this ModelBreak.
:type: str | [
"Sets",
"the",
"break_type_id",
"of",
"this",
"ModelBreak",
".",
"The",
"BreakType",
"this",
"Break",
"was",
"templated",
"on",
"."
] | python | train | 37 |
inspirehep/inspire-schemas | inspire_schemas/builders/literature.py | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/literature.py#L361-L374 | def add_keyword(self, keyword, schema=None, source=None):
"""Add a keyword.
Args:
keyword(str): keyword to add.
schema(str): schema to which the keyword belongs.
source(str): source for the keyword.
"""
keyword_dict = self._sourced_dict(source, value=... | [
"def",
"add_keyword",
"(",
"self",
",",
"keyword",
",",
"schema",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"keyword_dict",
"=",
"self",
".",
"_sourced_dict",
"(",
"source",
",",
"value",
"=",
"keyword",
")",
"if",
"schema",
"is",
"not",
"None... | Add a keyword.
Args:
keyword(str): keyword to add.
schema(str): schema to which the keyword belongs.
source(str): source for the keyword. | [
"Add",
"a",
"keyword",
"."
] | python | train | 31.571429 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/subject_info.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L498-L514 | def get_path_list(self, type_str=None):
"""Get list of the labels of the nodes leading up to this node from the root.
Args:
type_str:
SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include
information from nodes of that type.
Returns:
... | [
"def",
"get_path_list",
"(",
"self",
",",
"type_str",
"=",
"None",
")",
":",
"return",
"list",
"(",
"reversed",
"(",
"[",
"v",
".",
"label_str",
"for",
"v",
"in",
"self",
".",
"parent_gen",
"if",
"type_str",
"in",
"(",
"None",
",",
"v",
".",
"type_st... | Get list of the labels of the nodes leading up to this node from the root.
Args:
type_str:
SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include
information from nodes of that type.
Returns:
list of str: The labels of the nodes leading up... | [
"Get",
"list",
"of",
"the",
"labels",
"of",
"the",
"nodes",
"leading",
"up",
"to",
"this",
"node",
"from",
"the",
"root",
"."
] | python | train | 32.470588 |
phoebe-project/phoebe2 | phoebe/parameters/parameters.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/parameters.py#L3265-L3284 | def uniquetwig(self, ps=None):
"""
see also :meth:`twig`
Determine the shortest (more-or-less) twig which will point
to this single Parameter in a given parent :class:`ParameterSet`
:parameter ps: :class:`ParameterSet` in which the returned
uniquetwig will point to ... | [
"def",
"uniquetwig",
"(",
"self",
",",
"ps",
"=",
"None",
")",
":",
"if",
"ps",
"is",
"None",
":",
"ps",
"=",
"self",
".",
"_bundle",
"if",
"ps",
"is",
"None",
":",
"return",
"self",
".",
"twig",
"return",
"ps",
".",
"_uniquetwig",
"(",
"self",
"... | see also :meth:`twig`
Determine the shortest (more-or-less) twig which will point
to this single Parameter in a given parent :class:`ParameterSet`
:parameter ps: :class:`ParameterSet` in which the returned
uniquetwig will point to this Parameter. If not provided
or Non... | [
"see",
"also",
":",
"meth",
":",
"twig"
] | python | train | 32.9 |
jeffh/rpi_courses | rpi_courses/scheduler.py | https://github.com/jeffh/rpi_courses/blob/c97176f73f866f112c785910ebf3ff8a790e8e9a/rpi_courses/scheduler.py#L136-L145 | def create_constraints(self, courses):
"""Internal use. Creates all constraints in the problem instance for the given
courses.
"""
for i, course1 in enumerate(courses):
for j, course2 in enumerate(courses):
if i <= j:
continue
... | [
"def",
"create_constraints",
"(",
"self",
",",
"courses",
")",
":",
"for",
"i",
",",
"course1",
"in",
"enumerate",
"(",
"courses",
")",
":",
"for",
"j",
",",
"course2",
"in",
"enumerate",
"(",
"courses",
")",
":",
"if",
"i",
"<=",
"j",
":",
"continue... | Internal use. Creates all constraints in the problem instance for the given
courses. | [
"Internal",
"use",
".",
"Creates",
"all",
"constraints",
"in",
"the",
"problem",
"instance",
"for",
"the",
"given",
"courses",
"."
] | python | train | 44.5 |
gccxml/pygccxml | pygccxml/declarations/container_traits.py | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L697-L732 | def find_container_traits(cls_or_string):
"""
Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits
"""
if utils.is_str(cls_or_string):
if not templat... | [
"def",
"find_container_traits",
"(",
"cls_or_string",
")",
":",
"if",
"utils",
".",
"is_str",
"(",
"cls_or_string",
")",
":",
"if",
"not",
"templates",
".",
"is_instantiation",
"(",
"cls_or_string",
")",
":",
"return",
"None",
"name",
"=",
"templates",
".",
... | Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits | [
"Find",
"the",
"container",
"traits",
"type",
"of",
"a",
"declaration",
"."
] | python | train | 35.305556 |
Legobot/Legobot | Legobot/Connectors/Slack.py | https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/Slack.py#L133-L150 | def find_and_replace_channel_refs(self, text):
'''Find occurrences of Slack channel referenfces and attempts to
replace them with just channel names.
Args:
text (string): The message text
Returns:
string: The message text with channel references replaced.
... | [
"def",
"find_and_replace_channel_refs",
"(",
"self",
",",
"text",
")",
":",
"match",
"=",
"True",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'<#([A-Z0-9]{9})\\|([A-Za-z0-9-]+)>'",
")",
"while",
"match",
":",
"match",
"=",
"pattern",
".",
"search",
"(",
"text"... | Find occurrences of Slack channel referenfces and attempts to
replace them with just channel names.
Args:
text (string): The message text
Returns:
string: The message text with channel references replaced. | [
"Find",
"occurrences",
"of",
"Slack",
"channel",
"referenfces",
"and",
"attempts",
"to",
"replace",
"them",
"with",
"just",
"channel",
"names",
"."
] | python | train | 32.055556 |
IBMStreams/pypi.streamsx | streamsx/topology/schema.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L103-L134 | def _normalize(schema, allow_none=True):
"""
Normalize a schema.
"""
if allow_none and schema is None:
return schema
if isinstance(schema, CommonSchema):
return schema
if isinstance(schema, StreamSchema):
return schema
if isinstance(schema, basestring):
retur... | [
"def",
"_normalize",
"(",
"schema",
",",
"allow_none",
"=",
"True",
")",
":",
"if",
"allow_none",
"and",
"schema",
"is",
"None",
":",
"return",
"schema",
"if",
"isinstance",
"(",
"schema",
",",
"CommonSchema",
")",
":",
"return",
"schema",
"if",
"isinstanc... | Normalize a schema. | [
"Normalize",
"a",
"schema",
"."
] | python | train | 29.09375 |
onicagroup/runway | runway/util.py | https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/util.py#L37-L42 | def ensure_file_is_executable(path):
"""Exit if file is not executable."""
if platform.system() != 'Windows' and (
not stat.S_IXUSR & os.stat(path)[stat.ST_MODE]):
print("Error: File %s is not executable" % path)
sys.exit(1) | [
"def",
"ensure_file_is_executable",
"(",
"path",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"'Windows'",
"and",
"(",
"not",
"stat",
".",
"S_IXUSR",
"&",
"os",
".",
"stat",
"(",
"path",
")",
"[",
"stat",
".",
"ST_MODE",
"]",
")",
":",
... | Exit if file is not executable. | [
"Exit",
"if",
"file",
"is",
"not",
"executable",
"."
] | python | train | 42.5 |
HttpRunner/HttpRunner | httprunner/api.py | https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/api.py#L232-L252 | def run_path(self, path, dot_env_path=None, mapping=None):
""" run testcase/testsuite file or folder.
Args:
path (str): testcase/testsuite file/foler path.
dot_env_path (str): specified .env file path.
mapping (dict): if mapping is specified, it will override variabl... | [
"def",
"run_path",
"(",
"self",
",",
"path",
",",
"dot_env_path",
"=",
"None",
",",
"mapping",
"=",
"None",
")",
":",
"# load tests",
"self",
".",
"exception_stage",
"=",
"\"load tests\"",
"tests_mapping",
"=",
"loader",
".",
"load_tests",
"(",
"path",
",",
... | run testcase/testsuite file or folder.
Args:
path (str): testcase/testsuite file/foler path.
dot_env_path (str): specified .env file path.
mapping (dict): if mapping is specified, it will override variables in config block.
Returns:
instance: HttpRunner(... | [
"run",
"testcase",
"/",
"testsuite",
"file",
"or",
"folder",
"."
] | python | train | 34.142857 |
indranilsinharoy/pyzos | pyzos/zos.py | https://github.com/indranilsinharoy/pyzos/blob/da6bf3296b0154ccee44ad9a4286055ae031ecc7/pyzos/zos.py#L164-L175 | def zLoadFile(self, fileName, append=None):
"""Loads a zmx file into the DDE server"""
reply = None
if append:
cmd = "LoadFile,{},{}".format(fileName, append)
else:
cmd = "LoadFile,{}".format(fileName)
reply = self._sendDDEcommand(cmd)
if reply:
... | [
"def",
"zLoadFile",
"(",
"self",
",",
"fileName",
",",
"append",
"=",
"None",
")",
":",
"reply",
"=",
"None",
"if",
"append",
":",
"cmd",
"=",
"\"LoadFile,{},{}\"",
".",
"format",
"(",
"fileName",
",",
"append",
")",
"else",
":",
"cmd",
"=",
"\"LoadFil... | Loads a zmx file into the DDE server | [
"Loads",
"a",
"zmx",
"file",
"into",
"the",
"DDE",
"server"
] | python | train | 34.75 |
senaite/senaite.lims | src/senaite/lims/browser/spotlight/jsonapi.py | https://github.com/senaite/senaite.lims/blob/3c7fc7b462321fb354c478c19b5c20f3014fa398/src/senaite/lims/browser/spotlight/jsonapi.py#L55-L80 | def get_brain_info(brain):
"""Extract the brain info
"""
icon = api.get_icon(brain)
# avoid 404 errors with these guys
if "document_icon.gif" in icon:
icon = ""
id = api.get_id(brain)
url = api.get_url(brain)
title = api.get_title(brain)
description = api.get_description(bra... | [
"def",
"get_brain_info",
"(",
"brain",
")",
":",
"icon",
"=",
"api",
".",
"get_icon",
"(",
"brain",
")",
"# avoid 404 errors with these guys",
"if",
"\"document_icon.gif\"",
"in",
"icon",
":",
"icon",
"=",
"\"\"",
"id",
"=",
"api",
".",
"get_id",
"(",
"brain... | Extract the brain info | [
"Extract",
"the",
"brain",
"info"
] | python | train | 25.346154 |
inveniosoftware/invenio-webhooks | invenio_webhooks/views.py | https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L121-L138 | def post(self, receiver_id=None):
"""Handle POST request."""
try:
user_id = request.oauth.access_token.user_id
except AttributeError:
user_id = current_user.get_id()
event = Event.create(
receiver_id=receiver_id,
user_id=user_id
)
... | [
"def",
"post",
"(",
"self",
",",
"receiver_id",
"=",
"None",
")",
":",
"try",
":",
"user_id",
"=",
"request",
".",
"oauth",
".",
"access_token",
".",
"user_id",
"except",
"AttributeError",
":",
"user_id",
"=",
"current_user",
".",
"get_id",
"(",
")",
"ev... | Handle POST request. | [
"Handle",
"POST",
"request",
"."
] | python | train | 27.666667 |
gem/oq-engine | openquake/hazardlib/source/multi.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/source/multi.py#L171-L176 | def geom(self):
"""
:returns: the geometry as an array of shape (N, 3)
"""
return numpy.array([(p.x, p.y, p.z) for p in self.mesh],
numpy.float32) | [
"def",
"geom",
"(",
"self",
")",
":",
"return",
"numpy",
".",
"array",
"(",
"[",
"(",
"p",
".",
"x",
",",
"p",
".",
"y",
",",
"p",
".",
"z",
")",
"for",
"p",
"in",
"self",
".",
"mesh",
"]",
",",
"numpy",
".",
"float32",
")"
] | :returns: the geometry as an array of shape (N, 3) | [
":",
"returns",
":",
"the",
"geometry",
"as",
"an",
"array",
"of",
"shape",
"(",
"N",
"3",
")"
] | python | train | 33.333333 |
juju/python-libjuju | juju/controller.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/controller.py#L425-L433 | async def get_cloud(self):
"""
Get the name of the cloud that this controller lives on.
"""
cloud_facade = client.CloudFacade.from_connection(self.connection())
result = await cloud_facade.Clouds()
cloud = list(result.clouds.keys())[0] # only lives on one cloud
... | [
"async",
"def",
"get_cloud",
"(",
"self",
")",
":",
"cloud_facade",
"=",
"client",
".",
"CloudFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"result",
"=",
"await",
"cloud_facade",
".",
"Clouds",
"(",
")",
"cloud",
"=",
"... | Get the name of the cloud that this controller lives on. | [
"Get",
"the",
"name",
"of",
"the",
"cloud",
"that",
"this",
"controller",
"lives",
"on",
"."
] | python | train | 38.333333 |
lorien/grab | grab/base.py | https://github.com/lorien/grab/blob/8b301db2a08c830245b61c589e58af6234f4db79/grab/base.py#L349-L357 | def load_config(self, config):
"""
Configure grab instance with external config object.
"""
self.config = copy_config(config, self.mutable_config_keys)
if 'cookiejar_cookies' in config['state']:
self.cookies = CookieManager.from_cookie_list(
config['s... | [
"def",
"load_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"copy_config",
"(",
"config",
",",
"self",
".",
"mutable_config_keys",
")",
"if",
"'cookiejar_cookies'",
"in",
"config",
"[",
"'state'",
"]",
":",
"self",
".",
"cookies... | Configure grab instance with external config object. | [
"Configure",
"grab",
"instance",
"with",
"external",
"config",
"object",
"."
] | python | train | 37.777778 |
CloverHealth/pytest-pgsql | deploy.py | https://github.com/CloverHealth/pytest-pgsql/blob/a863ed4b652053e315dfa039d978b56f03664c07/deploy.py#L43-L124 | def deploy(target):
"""Deploys the package and documentation.
Proceeds in the following steps:
1. Ensures proper environment variables are set and checks that we are on Circle CI
2. Tags the repository with the new version
3. Creates a standard distribution and a wheel
4. Updates version.py to... | [
"def",
"deploy",
"(",
"target",
")",
":",
"# Ensure proper environment",
"if",
"not",
"os",
".",
"getenv",
"(",
"CIRCLECI_ENV_VAR",
")",
":",
"# pragma: no cover",
"raise",
"EnvironmentError",
"(",
"'Must be on CircleCI to run this script'",
")",
"current_branch",
"=",
... | Deploys the package and documentation.
Proceeds in the following steps:
1. Ensures proper environment variables are set and checks that we are on Circle CI
2. Tags the repository with the new version
3. Creates a standard distribution and a wheel
4. Updates version.py to have the proper version
... | [
"Deploys",
"the",
"package",
"and",
"documentation",
"."
] | python | train | 39.768293 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_ip_policy.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_ip_policy.py#L606-L625 | def hide_routemap_holder_route_map_content_set_ipv6_interface_ipv6_null0(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
hide_routemap_holder = ET.SubElement(config, "hide-routemap-holder", xmlns="urn:brocade.com:mgmt:brocade-ip-policy")
route_map = ET.S... | [
"def",
"hide_routemap_holder_route_map_content_set_ipv6_interface_ipv6_null0",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"hide_routemap_holder",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 50.5 |
squaresLab/BugZoo | bugzoo/client/dockerm.py | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/dockerm.py#L30-L47 | def delete_image(self, name: str) -> None:
"""
Deletes a Docker image with a given name.
Parameters:
name: the name of the Docker image.
"""
logger.debug("deleting Docker image: %s", name)
path = "docker/images/{}".format(name)
response = self.__api.d... | [
"def",
"delete_image",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"\"deleting Docker image: %s\"",
",",
"name",
")",
"path",
"=",
"\"docker/images/{}\"",
".",
"format",
"(",
"name",
")",
"response",
"=",
"sel... | Deletes a Docker image with a given name.
Parameters:
name: the name of the Docker image. | [
"Deletes",
"a",
"Docker",
"image",
"with",
"a",
"given",
"name",
"."
] | python | train | 35.222222 |
miguelgrinberg/python-engineio | engineio/asyncio_server.py | https://github.com/miguelgrinberg/python-engineio/blob/261fd67103cb5d9a44369415748e66fdf62de6fb/engineio/asyncio_server.py#L101-L108 | async def save_session(self, sid, session):
"""Store the user session for a client.
:param sid: The session id of the client.
:param session: The session dictionary.
"""
socket = self._get_socket(sid)
socket.session = session | [
"async",
"def",
"save_session",
"(",
"self",
",",
"sid",
",",
"session",
")",
":",
"socket",
"=",
"self",
".",
"_get_socket",
"(",
"sid",
")",
"socket",
".",
"session",
"=",
"session"
] | Store the user session for a client.
:param sid: The session id of the client.
:param session: The session dictionary. | [
"Store",
"the",
"user",
"session",
"for",
"a",
"client",
"."
] | python | train | 33.375 |
fr33jc/bang | bang/deployers/cloud.py | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/deployers/cloud.py#L425-L437 | def add_to_inventory(self):
"""Adds lb IPs to stack inventory"""
if self.lb_attrs:
self.lb_attrs = self.consul.lb_details(
self.lb_attrs[A.loadbalancer.ID]
)
host = self.lb_attrs['virtualIps'][0]['address']
self.stack.add_lb_sec... | [
"def",
"add_to_inventory",
"(",
"self",
")",
":",
"if",
"self",
".",
"lb_attrs",
":",
"self",
".",
"lb_attrs",
"=",
"self",
".",
"consul",
".",
"lb_details",
"(",
"self",
".",
"lb_attrs",
"[",
"A",
".",
"loadbalancer",
".",
"ID",
"]",
")",
"host",
"=... | Adds lb IPs to stack inventory | [
"Adds",
"lb",
"IPs",
"to",
"stack",
"inventory"
] | python | train | 38.384615 |
nugget/python-insteonplm | insteonplm/messages/__init__.py | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/__init__.py#L56-L86 | def create(rawmessage):
"""Return an INSTEON message class based on a raw byte stream."""
rawmessage = _trim_buffer_garbage(rawmessage)
if len(rawmessage) < 2:
return (None, rawmessage)
code = rawmessage[1]
msgclass = _get_msg_class(code)
msg = None
remaining_data = rawmessage
... | [
"def",
"create",
"(",
"rawmessage",
")",
":",
"rawmessage",
"=",
"_trim_buffer_garbage",
"(",
"rawmessage",
")",
"if",
"len",
"(",
"rawmessage",
")",
"<",
"2",
":",
"return",
"(",
"None",
",",
"rawmessage",
")",
"code",
"=",
"rawmessage",
"[",
"1",
"]",
... | Return an INSTEON message class based on a raw byte stream. | [
"Return",
"an",
"INSTEON",
"message",
"class",
"based",
"on",
"a",
"raw",
"byte",
"stream",
"."
] | python | train | 34.645161 |
autokey/autokey | lib/autokey/qtui/notifier.py | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L109-L142 | def _create_static_actions(self):
"""
Create all static menu actions. The created actions will be placed in the tray icon context menu.
"""
logger.info("Creating static context menu actions.")
self.action_view_script_error = self._create_action(
None, "&View script er... | [
"def",
"_create_static_actions",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Creating static context menu actions.\"",
")",
"self",
".",
"action_view_script_error",
"=",
"self",
".",
"_create_action",
"(",
"None",
",",
"\"&View script error\"",
",",
"self",
... | Create all static menu actions. The created actions will be placed in the tray icon context menu. | [
"Create",
"all",
"static",
"menu",
"actions",
".",
"The",
"created",
"actions",
"will",
"be",
"placed",
"in",
"the",
"tray",
"icon",
"context",
"menu",
"."
] | python | train | 61.441176 |
bitesofcode/projexui | projexui/widgets/xorbtreewidget/xorbtreewidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbtreewidget/xorbtreewidget.py#L1774-L1784 | def selectedRecords(self):
"""
Returns a list of all the selected records for this widget.
:return [<orb.Table>, ..]
"""
output = []
for item in self.selectedItems():
if ( isinstance(item, XOrbRecordItem) ):
output.append(... | [
"def",
"selectedRecords",
"(",
"self",
")",
":",
"output",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"selectedItems",
"(",
")",
":",
"if",
"(",
"isinstance",
"(",
"item",
",",
"XOrbRecordItem",
")",
")",
":",
"output",
".",
"append",
"(",
"ite... | Returns a list of all the selected records for this widget.
:return [<orb.Table>, ..] | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"selected",
"records",
"for",
"this",
"widget",
".",
":",
"return",
"[",
"<orb",
".",
"Table",
">",
"..",
"]"
] | python | train | 31.545455 |
numenta/htmresearch | htmresearch/frameworks/sp_paper/sp_metrics.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/sp_paper/sp_metrics.py#L111-L138 | def getBar(imageSize, barCenter, barHalfLength, orientation='horizontal'):
"""
Generate a single horizontal or vertical bar
:param imageSize
a list of (numPixelX. numPixelY). The number of pixels on horizontal
and vertical dimension, e.g., (20, 20)
:param barCenter:
(list) center of t... | [
"def",
"getBar",
"(",
"imageSize",
",",
"barCenter",
",",
"barHalfLength",
",",
"orientation",
"=",
"'horizontal'",
")",
":",
"(",
"nX",
",",
"nY",
")",
"=",
"imageSize",
"(",
"xLoc",
",",
"yLoc",
")",
"=",
"barCenter",
"bar",
"=",
"np",
".",
"zeros",
... | Generate a single horizontal or vertical bar
:param imageSize
a list of (numPixelX. numPixelY). The number of pixels on horizontal
and vertical dimension, e.g., (20, 20)
:param barCenter:
(list) center of the bar, e.g. (10, 10)
:param barHalfLength
(int) half length of the bar.... | [
"Generate",
"a",
"single",
"horizontal",
"or",
"vertical",
"bar",
":",
"param",
"imageSize",
"a",
"list",
"of",
"(",
"numPixelX",
".",
"numPixelY",
")",
".",
"The",
"number",
"of",
"pixels",
"on",
"horizontal",
"and",
"vertical",
"dimension",
"e",
".",
"g"... | python | train | 35.392857 |
ga4gh/ga4gh-server | ga4gh/server/datamodel/reads.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/reads.py#L378-L382 | def getReadAlignments(self, reference, start=None, end=None):
"""
Returns an iterator over the specified reads
"""
return self._getReadAlignments(reference, start, end, self, None) | [
"def",
"getReadAlignments",
"(",
"self",
",",
"reference",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"return",
"self",
".",
"_getReadAlignments",
"(",
"reference",
",",
"start",
",",
"end",
",",
"self",
",",
"None",
")"
] | Returns an iterator over the specified reads | [
"Returns",
"an",
"iterator",
"over",
"the",
"specified",
"reads"
] | python | train | 41.6 |
tradenity/python-sdk | tradenity/resources/option_set.py | https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/option_set.py#L702-L723 | def replace_option_set_by_id(cls, option_set_id, option_set, **kwargs):
"""Replace OptionSet
Replace all attributes of OptionSet
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.replace_option_... | [
"def",
"replace_option_set_by_id",
"(",
"cls",
",",
"option_set_id",
",",
"option_set",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async'",
")",
":",
"return",
"cls",
"... | Replace OptionSet
Replace all attributes of OptionSet
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.replace_option_set_by_id(option_set_id, option_set, async=True)
>>> result = thread.get()
... | [
"Replace",
"OptionSet"
] | python | train | 46.636364 |
tanghaibao/goatools | goatools/rpt/write_hierarchy_base.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/rpt/write_hierarchy_base.py#L86-L94 | def _str_dash(self, depth, no_repeat, obj):
"""Return a string containing dashes (optional) and GO ID."""
if self.indent:
# '-' is default character indicating hierarchy level
# '=' is used to indicate a hierarchical path printed in detail previously.
single_or_double... | [
"def",
"_str_dash",
"(",
"self",
",",
"depth",
",",
"no_repeat",
",",
"obj",
")",
":",
"if",
"self",
".",
"indent",
":",
"# '-' is default character indicating hierarchy level",
"# '=' is used to indicate a hierarchical path printed in detail previously.",
"single_or_double",
... | Return a string containing dashes (optional) and GO ID. | [
"Return",
"a",
"string",
"containing",
"dashes",
"(",
"optional",
")",
"and",
"GO",
"ID",
"."
] | python | train | 51.444444 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.