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 |
|---|---|---|---|---|---|---|---|---|---|
pandas-dev/pandas | pandas/core/generic.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/generic.py#L3817-L3868 | def _drop_axis(self, labels, axis, level=None, errors='raise'):
"""
Drop labels from specified axis. Used in the ``drop`` method
internally.
Parameters
----------
labels : single label or list-like
axis : int or axis name
level : int or level name, defaul... | [
"def",
"_drop_axis",
"(",
"self",
",",
"labels",
",",
"axis",
",",
"level",
"=",
"None",
",",
"errors",
"=",
"'raise'",
")",
":",
"axis",
"=",
"self",
".",
"_get_axis_number",
"(",
"axis",
")",
"axis_name",
"=",
"self",
".",
"_get_axis_name",
"(",
"axi... | Drop labels from specified axis. Used in the ``drop`` method
internally.
Parameters
----------
labels : single label or list-like
axis : int or axis name
level : int or level name, default None
For MultiIndex
errors : {'ignore', 'raise'}, default 'rai... | [
"Drop",
"labels",
"from",
"specified",
"axis",
".",
"Used",
"in",
"the",
"drop",
"method",
"internally",
"."
] | python | train | 38.884615 |
kensho-technologies/graphql-compiler | setup.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L13-L20 | def read_file(filename):
"""Read package file as text to get name and version"""
# intentionally *not* adding an encoding option to open
# see here:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.joi... | [
"def",
"read_file",
"(",
"filename",
")",
":",
"# intentionally *not* adding an encoding option to open",
"# see here:",
"# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690",
"here",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dir... | Read package file as text to get name and version | [
"Read",
"package",
"file",
"as",
"text",
"to",
"get",
"name",
"and",
"version"
] | python | train | 48.25 |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/input_readers.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/input_readers.py#L1368-L1395 | def validate(cls, mapper_spec):
"""Validates mapper spec and all mapper parameters.
Args:
mapper_spec: The MapperSpec for this InputReader.
Raises:
BadReaderParamsError: required parameters are missing or invalid.
"""
if mapper_spec.input_reader_class() != cls:
raise BadReaderPar... | [
"def",
"validate",
"(",
"cls",
",",
"mapper_spec",
")",
":",
"if",
"mapper_spec",
".",
"input_reader_class",
"(",
")",
"!=",
"cls",
":",
"raise",
"BadReaderParamsError",
"(",
"\"Mapper input reader class mismatch\"",
")",
"params",
"=",
"_get_params",
"(",
"mapper... | Validates mapper spec and all mapper parameters.
Args:
mapper_spec: The MapperSpec for this InputReader.
Raises:
BadReaderParamsError: required parameters are missing or invalid. | [
"Validates",
"mapper",
"spec",
"and",
"all",
"mapper",
"parameters",
"."
] | python | train | 43.571429 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L314-L328 | def _add_zone(self, zone, name='', status=Zone.CLEAR, expander=False):
"""
Adds a zone to the internal zone list.
:param zone: zone number
:type zone: int
:param name: human readable zone name
:type name: string
:param status: zone status
:type status: in... | [
"def",
"_add_zone",
"(",
"self",
",",
"zone",
",",
"name",
"=",
"''",
",",
"status",
"=",
"Zone",
".",
"CLEAR",
",",
"expander",
"=",
"False",
")",
":",
"if",
"not",
"zone",
"in",
"self",
".",
"_zones",
":",
"self",
".",
"_zones",
"[",
"zone",
"]... | Adds a zone to the internal zone list.
:param zone: zone number
:type zone: int
:param name: human readable zone name
:type name: string
:param status: zone status
:type status: int | [
"Adds",
"a",
"zone",
"to",
"the",
"internal",
"zone",
"list",
"."
] | python | train | 32.933333 |
openvax/varlens | varlens/read_evidence/pileup_collection.py | https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/read_evidence/pileup_collection.py#L365-L402 | def group_by_match(self, variant):
'''
Given a variant, split the PileupCollection based on whether it the
data supports the reference allele, the alternate allele, or neither.
Parameters
----------
variant : Variant
The variant. Must have fields 'locus', 're... | [
"def",
"group_by_match",
"(",
"self",
",",
"variant",
")",
":",
"locus",
"=",
"to_locus",
"(",
"variant",
")",
"if",
"len",
"(",
"variant",
".",
"ref",
")",
"!=",
"len",
"(",
"locus",
".",
"positions",
")",
":",
"logging",
".",
"warning",
"(",
"\"Ref... | Given a variant, split the PileupCollection based on whether it the
data supports the reference allele, the alternate allele, or neither.
Parameters
----------
variant : Variant
The variant. Must have fields 'locus', 'ref', and 'alt'.
Returns
----------
... | [
"Given",
"a",
"variant",
"split",
"the",
"PileupCollection",
"based",
"on",
"whether",
"it",
"the",
"data",
"supports",
"the",
"reference",
"allele",
"the",
"alternate",
"allele",
"or",
"neither",
"."
] | python | train | 39.947368 |
thespacedoctor/astrocalc | astrocalc/coords/unit_conversion.py | https://github.com/thespacedoctor/astrocalc/blob/dfbebf9b86d7b2d2110c48a6a4f4194bf8885b86/astrocalc/coords/unit_conversion.py#L363-L448 | def dec_decimal_to_sexegesimal(
self,
dec,
delimiter=":"):
"""
*Convert a declination between decimal degrees and sexegesimal.*
Precision should be respected.
**Key Arguments:**
- ``dec`` -- DEC in decimal degrees. Will try and convert to... | [
"def",
"dec_decimal_to_sexegesimal",
"(",
"self",
",",
"dec",
",",
"delimiter",
"=",
"\":\"",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``dec_decimal_to_sexegesimal`` method'",
")",
"import",
"math",
"# CONVERT DEC TO FLOAT",
"try",
":",
"self",... | *Convert a declination between decimal degrees and sexegesimal.*
Precision should be respected.
**Key Arguments:**
- ``dec`` -- DEC in decimal degrees. Will try and convert to float before performing calculation.
- ``delimiter`` -- how to delimit the RA units. Default *:*
... | [
"*",
"Convert",
"a",
"declination",
"between",
"decimal",
"degrees",
"and",
"sexegesimal",
".",
"*"
] | python | train | 29.488372 |
tensorflow/lucid | lucid/optvis/objectives.py | https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/optvis/objectives.py#L332-L358 | def penalize_boundary_complexity(shp, w=20, mask=None, C=0.5):
"""Encourage the boundaries of an image to have less variation and of color C.
Args:
shp: shape of T("input") because this may not be known.
w: width of boundary to penalize. Ignored if mask is set.
mask: mask describing what area should be... | [
"def",
"penalize_boundary_complexity",
"(",
"shp",
",",
"w",
"=",
"20",
",",
"mask",
"=",
"None",
",",
"C",
"=",
"0.5",
")",
":",
"def",
"inner",
"(",
"T",
")",
":",
"arr",
"=",
"T",
"(",
"\"input\"",
")",
"# print shp",
"if",
"mask",
"is",
"None",... | Encourage the boundaries of an image to have less variation and of color C.
Args:
shp: shape of T("input") because this may not be known.
w: width of boundary to penalize. Ignored if mask is set.
mask: mask describing what area should be penalized.
Returns:
Objective. | [
"Encourage",
"the",
"boundaries",
"of",
"an",
"image",
"to",
"have",
"less",
"variation",
"and",
"of",
"color",
"C",
"."
] | python | train | 23.703704 |
bcbio/bcbio-nextgen | bcbio/structural/regions.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/regions.py#L98-L141 | def _calc_sizes(self, cnv_file, items):
"""Retrieve target and antitarget bin sizes based on depth.
Similar to CNVkit's do_autobin but tries to have a standard set of
ranges (50bp intervals for target and 10kb intervals for antitarget).
"""
bp_per_bin = 100000 # same target as ... | [
"def",
"_calc_sizes",
"(",
"self",
",",
"cnv_file",
",",
"items",
")",
":",
"bp_per_bin",
"=",
"100000",
"# same target as CNVkit",
"range_map",
"=",
"{",
"\"target\"",
":",
"(",
"100",
",",
"250",
")",
",",
"\"antitarget\"",
":",
"(",
"10000",
",",
"10000... | Retrieve target and antitarget bin sizes based on depth.
Similar to CNVkit's do_autobin but tries to have a standard set of
ranges (50bp intervals for target and 10kb intervals for antitarget). | [
"Retrieve",
"target",
"and",
"antitarget",
"bin",
"sizes",
"based",
"on",
"depth",
"."
] | python | train | 48.795455 |
pycontribs/pyrax | pyrax/utils.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L549-L562 | def to_timestamp(val):
"""
Takes a value that is either a Python date, datetime, or a string
representation of a date/datetime value. Returns a standard Unix timestamp
corresponding to that value.
"""
# If we're given a number, give it right back - it's already a timestamp.
if isinstance(val... | [
"def",
"to_timestamp",
"(",
"val",
")",
":",
"# If we're given a number, give it right back - it's already a timestamp.",
"if",
"isinstance",
"(",
"val",
",",
"numbers",
".",
"Number",
")",
":",
"return",
"val",
"elif",
"isinstance",
"(",
"val",
",",
"six",
".",
"... | Takes a value that is either a Python date, datetime, or a string
representation of a date/datetime value. Returns a standard Unix timestamp
corresponding to that value. | [
"Takes",
"a",
"value",
"that",
"is",
"either",
"a",
"Python",
"date",
"datetime",
"or",
"a",
"string",
"representation",
"of",
"a",
"date",
"/",
"datetime",
"value",
".",
"Returns",
"a",
"standard",
"Unix",
"timestamp",
"corresponding",
"to",
"that",
"value"... | python | train | 35.357143 |
pletzer/pnumpy | examples/exAverage2d.py | https://github.com/pletzer/pnumpy/blob/9e6d308be94a42637466b91ab1a7b4d64b4c29ae/examples/exAverage2d.py#L44-L65 | def setValues(nxG, nyG, iBeg, iEnd, jBeg, jEnd, data):
"""
Set setValues
@param nxG number of global cells in x
@param nyG number of global cells in y
@param iBeg global starting index in x
@param iEnd global ending index in x
@param jBeg global starting index in y
@param jEnd global end... | [
"def",
"setValues",
"(",
"nxG",
",",
"nyG",
",",
"iBeg",
",",
"iEnd",
",",
"jBeg",
",",
"jEnd",
",",
"data",
")",
":",
"nxGHalf",
"=",
"nxG",
"/",
"2.",
"nyGHalf",
"=",
"nyG",
"/",
"2.",
"nxGQuart",
"=",
"nxGHalf",
"/",
"2.",
"nyGQuart",
"=",
"ny... | Set setValues
@param nxG number of global cells in x
@param nyG number of global cells in y
@param iBeg global starting index in x
@param iEnd global ending index in x
@param jBeg global starting index in y
@param jEnd global ending index in y
@param data local array | [
"Set",
"setValues"
] | python | train | 32.136364 |
raphaelm/python-fints | fints/client.py | https://github.com/raphaelm/python-fints/blob/fee55ae37d3182d0adb40507d4acb98b06057e4a/fints/client.py#L290-L308 | def deconstruct(self, including_private: bool=False) -> bytes:
"""Return state of this FinTSClient instance as an opaque datablob. You should not
use this object after calling this method.
Information about the connection is implicitly retrieved from the bank and
cached in the FinTSClie... | [
"def",
"deconstruct",
"(",
"self",
",",
"including_private",
":",
"bool",
"=",
"False",
")",
"->",
"bytes",
":",
"data",
"=",
"self",
".",
"_deconstruct_v1",
"(",
"including_private",
"=",
"including_private",
")",
"return",
"compress_datablob",
"(",
"DATA_BLOB_... | Return state of this FinTSClient instance as an opaque datablob. You should not
use this object after calling this method.
Information about the connection is implicitly retrieved from the bank and
cached in the FinTSClient. This includes: system identifier, bank parameter
data, user pa... | [
"Return",
"state",
"of",
"this",
"FinTSClient",
"instance",
"as",
"an",
"opaque",
"datablob",
".",
"You",
"should",
"not",
"use",
"this",
"object",
"after",
"calling",
"this",
"method",
"."
] | python | train | 60.526316 |
googleapis/google-cloud-python | logging/google/cloud/logging/_gapic.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/_gapic.py#L408-L418 | def metric_delete(self, project, metric_name):
"""API call: delete a metric resource.
:type project: str
:param project: ID of the project containing the metric.
:type metric_name: str
:param metric_name: the name of the metric
"""
path = "projects/%s/metrics/%... | [
"def",
"metric_delete",
"(",
"self",
",",
"project",
",",
"metric_name",
")",
":",
"path",
"=",
"\"projects/%s/metrics/%s\"",
"%",
"(",
"project",
",",
"metric_name",
")",
"self",
".",
"_gapic_api",
".",
"delete_log_metric",
"(",
"path",
")"
] | API call: delete a metric resource.
:type project: str
:param project: ID of the project containing the metric.
:type metric_name: str
:param metric_name: the name of the metric | [
"API",
"call",
":",
"delete",
"a",
"metric",
"resource",
"."
] | python | train | 35 |
LISE-B26/pylabcontrol | build/lib/pylabcontrol/src/tools/export_default.py | https://github.com/LISE-B26/pylabcontrol/blob/67482e5157fcd1c40705e5c2cacfb93564703ed0/build/lib/pylabcontrol/src/tools/export_default.py#L85-L113 | def export_default_probes(path, module_name = '', raise_errors = False):
"""
NOT IMPLEMENTED YET
tries to instantiate all the instruments that are imported in /instruments/__init__.py
and the probes of each instrument that could be instantiated into a .b26 file in the folder path
Args:
path:... | [
"def",
"export_default_probes",
"(",
"path",
",",
"module_name",
"=",
"''",
",",
"raise_errors",
"=",
"False",
")",
":",
"raise",
"NotImplementedError",
"import",
"b26_toolkit",
".",
"b26_toolkit",
".",
"instruments",
"as",
"instruments",
"from",
"pylabcontrol",
"... | NOT IMPLEMENTED YET
tries to instantiate all the instruments that are imported in /instruments/__init__.py
and the probes of each instrument that could be instantiated into a .b26 file in the folder path
Args:
path: target path for .b26 files | [
"NOT",
"IMPLEMENTED",
"YET",
"tries",
"to",
"instantiate",
"all",
"the",
"instruments",
"that",
"are",
"imported",
"in",
"/",
"instruments",
"/",
"__init__",
".",
"py",
"and",
"the",
"probes",
"of",
"each",
"instrument",
"that",
"could",
"be",
"instantiated",
... | python | train | 39.172414 |
axltxl/m2bk | m2bk/app.py | https://github.com/axltxl/m2bk/blob/980083dfd17e6e783753a946e9aa809714551141/m2bk/app.py#L31-L96 | def init_parsecmdline(argv=[]):
"""
Parse arguments from the command line
:param argv: list of arguments
"""
# main argument parser
parser = argparse.ArgumentParser(prog=PKG_NAME)
# --version
parser.add_argument('--version', action='version', version=version)
# -c, --config <file_... | [
"def",
"init_parsecmdline",
"(",
"argv",
"=",
"[",
"]",
")",
":",
"# main argument parser",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"PKG_NAME",
")",
"# --version",
"parser",
".",
"add_argument",
"(",
"'--version'",
",",
"action",
"=... | Parse arguments from the command line
:param argv: list of arguments | [
"Parse",
"arguments",
"from",
"the",
"command",
"line"
] | python | train | 32.515152 |
mwouts/jupytext | jupytext/magics.py | https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/magics.py#L46-L55 | def comment_magic(source, language='python', global_escape_flag=True):
"""Escape Jupyter magics with '# '"""
parser = StringParser(language)
next_is_magic = False
for pos, line in enumerate(source):
if not parser.is_quoted() and (next_is_magic or is_magic(line, language, global_escape_flag)):
... | [
"def",
"comment_magic",
"(",
"source",
",",
"language",
"=",
"'python'",
",",
"global_escape_flag",
"=",
"True",
")",
":",
"parser",
"=",
"StringParser",
"(",
"language",
")",
"next_is_magic",
"=",
"False",
"for",
"pos",
",",
"line",
"in",
"enumerate",
"(",
... | Escape Jupyter magics with '# | [
"Escape",
"Jupyter",
"magics",
"with",
"#"
] | python | train | 50.2 |
dossier/dossier.store | dossier/store/elastic.py | https://github.com/dossier/dossier.store/blob/b22ffe2470bba9fcc98a30cb55b437bfa1521e7f/dossier/store/elastic.py#L189-L228 | def put(self, items, indexes=True):
'''Adds feature collections to the store.
This efficiently adds multiple FCs to the store. The iterable
of ``items`` given should yield tuples of ``(content_id, FC)``.
:param items: Iterable of ``(content_id, FC)``.
:param [str] feature_names... | [
"def",
"put",
"(",
"self",
",",
"items",
",",
"indexes",
"=",
"True",
")",
":",
"actions",
"=",
"[",
"]",
"for",
"cid",
",",
"fc",
"in",
"items",
":",
"# TODO: If we store features in a columnar order, then we",
"# could tell ES to index the feature values directly. -... | Adds feature collections to the store.
This efficiently adds multiple FCs to the store. The iterable
of ``items`` given should yield tuples of ``(content_id, FC)``.
:param items: Iterable of ``(content_id, FC)``.
:param [str] feature_names:
A list of feature names to retrieve... | [
"Adds",
"feature",
"collections",
"to",
"the",
"store",
"."
] | python | test | 43.425 |
playpauseandstop/Flask-And-Redis | flask_redis.py | https://github.com/playpauseandstop/Flask-And-Redis/blob/878bb193ae4a8c3497f6f1ff1511a3b8c96d08b5/flask_redis.py#L172-L189 | def _build_connection_args(self, klass):
"""Read connection args spec, exclude self from list of possible
:param klass: Redis connection class.
"""
bases = [base for base in klass.__bases__ if base is not object]
all_args = []
for cls in [klass] + bases:
try:... | [
"def",
"_build_connection_args",
"(",
"self",
",",
"klass",
")",
":",
"bases",
"=",
"[",
"base",
"for",
"base",
"in",
"klass",
".",
"__bases__",
"if",
"base",
"is",
"not",
"object",
"]",
"all_args",
"=",
"[",
"]",
"for",
"cls",
"in",
"[",
"klass",
"]... | Read connection args spec, exclude self from list of possible
:param klass: Redis connection class. | [
"Read",
"connection",
"args",
"spec",
"exclude",
"self",
"from",
"list",
"of",
"possible"
] | python | train | 36.166667 |
broox/python-nuheat | nuheat/thermostat.py | https://github.com/broox/python-nuheat/blob/3a18852dc9465c34cb96eb3a0c84f1a6caa70707/nuheat/thermostat.py#L205-L226 | def set_target_temperature(self, temperature, mode=config.SCHEDULE_HOLD):
"""
Updates the target temperature on the NuHeat API
:param temperature: The desired temperature in NuHeat format
:param permanent: Permanently hold the temperature. If set to False, the schedule will
... | [
"def",
"set_target_temperature",
"(",
"self",
",",
"temperature",
",",
"mode",
"=",
"config",
".",
"SCHEDULE_HOLD",
")",
":",
"if",
"temperature",
"<",
"self",
".",
"min_temperature",
":",
"temperature",
"=",
"self",
".",
"min_temperature",
"if",
"temperature",
... | Updates the target temperature on the NuHeat API
:param temperature: The desired temperature in NuHeat format
:param permanent: Permanently hold the temperature. If set to False, the schedule will
resume at the next programmed event | [
"Updates",
"the",
"target",
"temperature",
"on",
"the",
"NuHeat",
"API"
] | python | valid | 38.272727 |
dhermes/bezier | docs/make_images.py | https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/docs/make_images.py#L381-L419 | def surface_evaluate_cartesian_multi(surface, points):
"""Image for :meth`.Surface.evaluate_cartesian_multi` docstring."""
if NO_IMAGES:
return
ax = surface.plot(256)
ax.plot(
points[0, :], points[1, :], color="black", linestyle="None", marker="o"
)
delta = 1.0 / 32.0
font_s... | [
"def",
"surface_evaluate_cartesian_multi",
"(",
"surface",
",",
"points",
")",
":",
"if",
"NO_IMAGES",
":",
"return",
"ax",
"=",
"surface",
".",
"plot",
"(",
"256",
")",
"ax",
".",
"plot",
"(",
"points",
"[",
"0",
",",
":",
"]",
",",
"points",
"[",
"... | Image for :meth`.Surface.evaluate_cartesian_multi` docstring. | [
"Image",
"for",
":",
"meth",
".",
"Surface",
".",
"evaluate_cartesian_multi",
"docstring",
"."
] | python | train | 25.641026 |
fossasia/knittingpattern | knittingpattern/convert/Layout.py | https://github.com/fossasia/knittingpattern/blob/8e608896b0ab82fea1ca9fbfa2b4ee023d8c8027/knittingpattern/convert/Layout.py#L246-L249 | def _row_should_be_placed(self, row, position):
""":return: whether to place this instruction"""
placed_row = self._rows_in_grid.get(row)
return placed_row is None or placed_row.y < position.y | [
"def",
"_row_should_be_placed",
"(",
"self",
",",
"row",
",",
"position",
")",
":",
"placed_row",
"=",
"self",
".",
"_rows_in_grid",
".",
"get",
"(",
"row",
")",
"return",
"placed_row",
"is",
"None",
"or",
"placed_row",
".",
"y",
"<",
"position",
".",
"y... | :return: whether to place this instruction | [
":",
"return",
":",
"whether",
"to",
"place",
"this",
"instruction"
] | python | valid | 53.25 |
markovmodel/msmtools | msmtools/analysis/dense/fingerprints.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/analysis/dense/fingerprints.py#L175-L202 | def correlation(P, obs1, obs2=None, times=[1], k=None):
r"""Time-correlation for equilibrium experiment.
Parameters
----------
P : (M, M) ndarray
Transition matrix
obs1 : (M,) ndarray
Observable, represented as vector on state space
obs2 : (M,) ndarray (optional)
Second ... | [
"def",
"correlation",
"(",
"P",
",",
"obs1",
",",
"obs2",
"=",
"None",
",",
"times",
"=",
"[",
"1",
"]",
",",
"k",
"=",
"None",
")",
":",
"M",
"=",
"P",
".",
"shape",
"[",
"0",
"]",
"T",
"=",
"np",
".",
"asarray",
"(",
"times",
")",
".",
... | r"""Time-correlation for equilibrium experiment.
Parameters
----------
P : (M, M) ndarray
Transition matrix
obs1 : (M,) ndarray
Observable, represented as vector on state space
obs2 : (M,) ndarray (optional)
Second observable, for cross-correlations
times : list of int (... | [
"r",
"Time",
"-",
"correlation",
"for",
"equilibrium",
"experiment",
"."
] | python | train | 29.821429 |
bitesofcode/projexui | projexui/widgets/xorbquerywidget/xorbquickfilterwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbquerywidget/xorbquickfilterwidget.py#L83-L94 | def query(self):
"""
Builds the query for this quick filter.
:return <orb.Query>
"""
output = Query()
for column, op, plugin, editor in self._plugins:
query = Query(column)
if plugin.setupQuery(query, op, editor):
... | [
"def",
"query",
"(",
"self",
")",
":",
"output",
"=",
"Query",
"(",
")",
"for",
"column",
",",
"op",
",",
"plugin",
",",
"editor",
"in",
"self",
".",
"_plugins",
":",
"query",
"=",
"Query",
"(",
"column",
")",
"if",
"plugin",
".",
"setupQuery",
"("... | Builds the query for this quick filter.
:return <orb.Query> | [
"Builds",
"the",
"query",
"for",
"this",
"quick",
"filter",
".",
":",
"return",
"<orb",
".",
"Query",
">"
] | python | train | 29.333333 |
PolyJIT/benchbuild | benchbuild/reports/__init__.py | https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/reports/__init__.py#L17-L41 | def discover():
"""
Import all experiments listed in *_PLUGINS_REPORTS.
Tests:
>>> from benchbuild.settings import CFG
>>> from benchbuild.reports import discover
>>> import logging as lg
>>> import sys
>>> l = lg.getLogger('benchbuild')
>>> l.setLevel(lg.DEB... | [
"def",
"discover",
"(",
")",
":",
"if",
"CFG",
"[",
"\"plugins\"",
"]",
"[",
"\"autoload\"",
"]",
":",
"report_plugins",
"=",
"CFG",
"[",
"\"plugins\"",
"]",
"[",
"\"reports\"",
"]",
".",
"value",
"for",
"plugin",
"in",
"report_plugins",
":",
"try",
":",... | Import all experiments listed in *_PLUGINS_REPORTS.
Tests:
>>> from benchbuild.settings import CFG
>>> from benchbuild.reports import discover
>>> import logging as lg
>>> import sys
>>> l = lg.getLogger('benchbuild')
>>> l.setLevel(lg.DEBUG)
>>> l.handlers =... | [
"Import",
"all",
"experiments",
"listed",
"in",
"*",
"_PLUGINS_REPORTS",
"."
] | python | train | 36.76 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L361-L368 | def remove_known_hosts(overcloud_ip):
"""For a given IP address remove SSH keys from the known_hosts file"""
known_hosts = os.path.expanduser("~/.ssh/known_hosts")
if os.path.exists(known_hosts):
command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts]
subprocess.check_call(command) | [
"def",
"remove_known_hosts",
"(",
"overcloud_ip",
")",
":",
"known_hosts",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.ssh/known_hosts\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"known_hosts",
")",
":",
"command",
"=",
"[",
"'ssh-keygen'... | For a given IP address remove SSH keys from the known_hosts file | [
"For",
"a",
"given",
"IP",
"address",
"remove",
"SSH",
"keys",
"from",
"the",
"known_hosts",
"file"
] | python | train | 39.125 |
secdev/scapy | scapy/layers/ntp.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ntp.py#L212-L220 | def haslayer(self, cls):
"""Specific: NTPHeader().haslayer(NTP) should return True."""
if cls == "NTP":
if isinstance(self, NTP):
return True
elif issubtype(cls, NTP):
if isinstance(self, cls):
return True
return super(NTP, self).ha... | [
"def",
"haslayer",
"(",
"self",
",",
"cls",
")",
":",
"if",
"cls",
"==",
"\"NTP\"",
":",
"if",
"isinstance",
"(",
"self",
",",
"NTP",
")",
":",
"return",
"True",
"elif",
"issubtype",
"(",
"cls",
",",
"NTP",
")",
":",
"if",
"isinstance",
"(",
"self"... | Specific: NTPHeader().haslayer(NTP) should return True. | [
"Specific",
":",
"NTPHeader",
"()",
".",
"haslayer",
"(",
"NTP",
")",
"should",
"return",
"True",
"."
] | python | train | 35.888889 |
codelv/enaml-native | src/enamlnative/android/android_wifi.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_wifi.py#L401-L417 | def request_permission(cls, permissions):
""" Requests permission and returns an future result that returns a
boolean indicating if all the given permission were granted or denied.
"""
app = AndroidApplication.instance()
f = app.create_future()
def on_result(p... | [
"def",
"request_permission",
"(",
"cls",
",",
"permissions",
")",
":",
"app",
"=",
"AndroidApplication",
".",
"instance",
"(",
")",
"f",
"=",
"app",
".",
"create_future",
"(",
")",
"def",
"on_result",
"(",
"perms",
")",
":",
"allowed",
"=",
"True",
"for"... | Requests permission and returns an future result that returns a
boolean indicating if all the given permission were granted or denied. | [
"Requests",
"permission",
"and",
"returns",
"an",
"future",
"result",
"that",
"returns",
"a",
"boolean",
"indicating",
"if",
"all",
"the",
"given",
"permission",
"were",
"granted",
"or",
"denied",
"."
] | python | train | 31.941176 |
Arubacloud/pyArubaCloud | ArubaCloud/base/vm.py | https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/base/vm.py#L6-L24 | def find(self, name):
"""
Return a list of subset of VM that match the pattern name
@param name (str): the vm name of the virtual machine
@param name (Obj): the vm object that represent the virtual
machine (can be Pro or Smart)
@return (list): the subse... | [
"def",
"find",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
".",
"__class__",
"is",
"'base.Server.Pro'",
"or",
"name",
".",
"__class__",
"is",
"'base.Server.Smart'",
":",
"# print('DEBUG: matched VM object %s' % name.__class__)",
"pattern",
"=",
"name",
".",
... | Return a list of subset of VM that match the pattern name
@param name (str): the vm name of the virtual machine
@param name (Obj): the vm object that represent the virtual
machine (can be Pro or Smart)
@return (list): the subset containing the serach result. | [
"Return",
"a",
"list",
"of",
"subset",
"of",
"VM",
"that",
"match",
"the",
"pattern",
"name"
] | python | train | 57.789474 |
kdeldycke/maildir-deduplicate | maildir_deduplicate/mail.py | https://github.com/kdeldycke/maildir-deduplicate/blob/f1c6ff25b80c6c1a4dc2dc7a65b34d808b0b7733/maildir_deduplicate/mail.py#L99-L114 | def body_lines(self):
""" Return a normalized list of lines from message's body. """
if not self.message.is_multipart():
body = self.message.get_payload(None, decode=True)
else:
_, _, body = self.message.as_string().partition("\n\n")
if isinstance(body, bytes):
... | [
"def",
"body_lines",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"message",
".",
"is_multipart",
"(",
")",
":",
"body",
"=",
"self",
".",
"message",
".",
"get_payload",
"(",
"None",
",",
"decode",
"=",
"True",
")",
"else",
":",
"_",
",",
"_",
... | Return a normalized list of lines from message's body. | [
"Return",
"a",
"normalized",
"list",
"of",
"lines",
"from",
"message",
"s",
"body",
"."
] | python | train | 39.4375 |
streamlink/streamlink | src/streamlink_cli/main.py | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink_cli/main.py#L718-L760 | def setup_http_session():
"""Sets the global HTTP settings, such as proxy and headers."""
if args.http_proxy:
streamlink.set_option("http-proxy", args.http_proxy)
if args.https_proxy:
streamlink.set_option("https-proxy", args.https_proxy)
if args.http_cookie:
streamlink.set_opt... | [
"def",
"setup_http_session",
"(",
")",
":",
"if",
"args",
".",
"http_proxy",
":",
"streamlink",
".",
"set_option",
"(",
"\"http-proxy\"",
",",
"args",
".",
"http_proxy",
")",
"if",
"args",
".",
"https_proxy",
":",
"streamlink",
".",
"set_option",
"(",
"\"htt... | Sets the global HTTP settings, such as proxy and headers. | [
"Sets",
"the",
"global",
"HTTP",
"settings",
"such",
"as",
"proxy",
"and",
"headers",
"."
] | python | test | 32.162791 |
AtteqCom/zsl | src/zsl/utils/email_helper.py | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/email_helper.py#L16-L63 | def send_email(sender, receivers, subject, text=None, html=None, charset='utf-8', config=Injected):
"""Sends an email.
:param sender: Sender as string or None for default got from config.
:param receivers: String or array of recipients.
:param subject: Subject.
:param text: Plain text message.
... | [
"def",
"send_email",
"(",
"sender",
",",
"receivers",
",",
"subject",
",",
"text",
"=",
"None",
",",
"html",
"=",
"None",
",",
"charset",
"=",
"'utf-8'",
",",
"config",
"=",
"Injected",
")",
":",
"smtp_config",
"=",
"config",
"[",
"'SMTP'",
"]",
"# Rec... | Sends an email.
:param sender: Sender as string or None for default got from config.
:param receivers: String or array of recipients.
:param subject: Subject.
:param text: Plain text message.
:param html: Html message.
:param charset: Charset.
:param config: Current configuration | [
"Sends",
"an",
"email",
"."
] | python | train | 27.354167 |
twisted/epsilon | epsilon/extime.py | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/extime.py#L393-L568 | def fromISO8601TimeAndDate(klass, iso8601string, tzinfo=None):
"""Return a new Time instance from a string formated as in ISO 8601.
If the given string contains no timezone, it is assumed to be in the
timezone specified by the parameter `tzinfo`, or UTC if tzinfo is None.
An input strin... | [
"def",
"fromISO8601TimeAndDate",
"(",
"klass",
",",
"iso8601string",
",",
"tzinfo",
"=",
"None",
")",
":",
"def",
"calculateTimezone",
"(",
")",
":",
"if",
"groups",
"[",
"'zulu'",
"]",
"==",
"'Z'",
":",
"return",
"FixedOffset",
"(",
"0",
",",
"0",
")",
... | Return a new Time instance from a string formated as in ISO 8601.
If the given string contains no timezone, it is assumed to be in the
timezone specified by the parameter `tzinfo`, or UTC if tzinfo is None.
An input string with an explicit timezone will always override tzinfo.
If the g... | [
"Return",
"a",
"new",
"Time",
"instance",
"from",
"a",
"string",
"formated",
"as",
"in",
"ISO",
"8601",
"."
] | python | train | 43.056818 |
jaraco/hgtools | hgtools/managers/cmd.py | https://github.com/jaraco/hgtools/blob/bf5fe2324e5ae15e012487f95f0c97c3775c5d2e/hgtools/managers/cmd.py#L93-L110 | def _read_tags_for_revset(self, spec):
"""
Return TaggedRevision for each tag/rev combination in the revset spec
"""
cmd = [
'log', '--style', 'default', '--config', 'defaults.log=',
'-r', spec]
res = self._invoke(*cmd)
header_pattern = re.compile(r'(?P<header>\w+?):\s+(?P<value>.*)')
match_res = ma... | [
"def",
"_read_tags_for_revset",
"(",
"self",
",",
"spec",
")",
":",
"cmd",
"=",
"[",
"'log'",
",",
"'--style'",
",",
"'default'",
",",
"'--config'",
",",
"'defaults.log='",
",",
"'-r'",
",",
"spec",
"]",
"res",
"=",
"self",
".",
"_invoke",
"(",
"*",
"c... | Return TaggedRevision for each tag/rev combination in the revset spec | [
"Return",
"TaggedRevision",
"for",
"each",
"tag",
"/",
"rev",
"combination",
"in",
"the",
"revset",
"spec"
] | python | train | 36 |
saltstack/salt | salt/renderers/aws_kms.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/aws_kms.py#L179-L195 | def _plaintext_data_key():
'''
Return the configured KMS data key decrypted and encoded in urlsafe base64.
Cache the result to minimize API calls to AWS.
'''
response = getattr(_plaintext_data_key, 'response', None)
cache_hit = response is not None
if not cache_hit:
response = _api_... | [
"def",
"_plaintext_data_key",
"(",
")",
":",
"response",
"=",
"getattr",
"(",
"_plaintext_data_key",
",",
"'response'",
",",
"None",
")",
"cache_hit",
"=",
"response",
"is",
"not",
"None",
"if",
"not",
"cache_hit",
":",
"response",
"=",
"_api_decrypt",
"(",
... | Return the configured KMS data key decrypted and encoded in urlsafe base64.
Cache the result to minimize API calls to AWS. | [
"Return",
"the",
"configured",
"KMS",
"data",
"key",
"decrypted",
"and",
"encoded",
"in",
"urlsafe",
"base64",
"."
] | python | train | 38 |
wmayner/pyphi | pyphi/subsystem.py | https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/subsystem.py#L247-L257 | def apply_cut(self, cut):
"""Return a cut version of this |Subsystem|.
Args:
cut (Cut): The cut to apply to this |Subsystem|.
Returns:
Subsystem: The cut subsystem.
"""
return Subsystem(self.network, self.state, self.node_indices,
... | [
"def",
"apply_cut",
"(",
"self",
",",
"cut",
")",
":",
"return",
"Subsystem",
"(",
"self",
".",
"network",
",",
"self",
".",
"state",
",",
"self",
".",
"node_indices",
",",
"cut",
"=",
"cut",
",",
"mice_cache",
"=",
"self",
".",
"_mice_cache",
")"
] | Return a cut version of this |Subsystem|.
Args:
cut (Cut): The cut to apply to this |Subsystem|.
Returns:
Subsystem: The cut subsystem. | [
"Return",
"a",
"cut",
"version",
"of",
"this",
"|Subsystem|",
"."
] | python | train | 31.727273 |
kragniz/python-etcd3 | etcd3/events.py | https://github.com/kragniz/python-etcd3/blob/0adb14840d4a6011a2023a13f07e247e4c336a80/etcd3/events.py#L26-L41 | def new_event(event):
"""
Wrap a raw gRPC event in a friendlier containing class.
This picks the appropriate class from one of PutEvent or DeleteEvent and
returns a new instance.
"""
op_name = event.EventType.DESCRIPTOR.values_by_number[event.type].name
if op_name == 'PUT':
cls = Pu... | [
"def",
"new_event",
"(",
"event",
")",
":",
"op_name",
"=",
"event",
".",
"EventType",
".",
"DESCRIPTOR",
".",
"values_by_number",
"[",
"event",
".",
"type",
"]",
".",
"name",
"if",
"op_name",
"==",
"'PUT'",
":",
"cls",
"=",
"PutEvent",
"elif",
"op_name"... | Wrap a raw gRPC event in a friendlier containing class.
This picks the appropriate class from one of PutEvent or DeleteEvent and
returns a new instance. | [
"Wrap",
"a",
"raw",
"gRPC",
"event",
"in",
"a",
"friendlier",
"containing",
"class",
"."
] | python | train | 27.6875 |
pandas-dev/pandas | pandas/core/indexes/multi.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/multi.py#L49-L77 | def _codes_to_ints(self, codes):
"""
Transform combination(s) of uint64 in one uint64 (each), in a strictly
monotonic way (i.e. respecting the lexicographic order of integer
combinations): see BaseMultiIndexCodesEngine documentation.
Parameters
----------
codes :... | [
"def",
"_codes_to_ints",
"(",
"self",
",",
"codes",
")",
":",
"# Shift the representation of each level by the pre-calculated number",
"# of bits:",
"codes",
"<<=",
"self",
".",
"offsets",
"# Now sum and OR are in fact interchangeable. This is a simple",
"# composition of the (disjun... | Transform combination(s) of uint64 in one uint64 (each), in a strictly
monotonic way (i.e. respecting the lexicographic order of integer
combinations): see BaseMultiIndexCodesEngine documentation.
Parameters
----------
codes : 1- or 2-dimensional array of dtype uint64
... | [
"Transform",
"combination",
"(",
"s",
")",
"of",
"uint64",
"in",
"one",
"uint64",
"(",
"each",
")",
"in",
"a",
"strictly",
"monotonic",
"way",
"(",
"i",
".",
"e",
".",
"respecting",
"the",
"lexicographic",
"order",
"of",
"integer",
"combinations",
")",
"... | python | train | 36.965517 |
vtkiorg/vtki | vtki/common.py | https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L536-L541 | def copy_meta_from(self, ido):
"""Copies vtki meta data onto this object from another object"""
self._active_scalar_info = ido.active_scalar_info
self._active_vectors_info = ido.active_vectors_info
if hasattr(ido, '_textures'):
self._textures = ido._textures | [
"def",
"copy_meta_from",
"(",
"self",
",",
"ido",
")",
":",
"self",
".",
"_active_scalar_info",
"=",
"ido",
".",
"active_scalar_info",
"self",
".",
"_active_vectors_info",
"=",
"ido",
".",
"active_vectors_info",
"if",
"hasattr",
"(",
"ido",
",",
"'_textures'",
... | Copies vtki meta data onto this object from another object | [
"Copies",
"vtki",
"meta",
"data",
"onto",
"this",
"object",
"from",
"another",
"object"
] | python | train | 49.5 |
Azure/azure-cosmos-python | azure/cosmos/base.py | https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/base.py#L217-L252 | def GetResourceIdOrFullNameFromLink(resource_link):
"""Gets resource id or full name from resource link.
:param str resource_link:
:return:
The resource id or full name from the resource link.
:rtype: str
"""
# For named based, the resource link is the full name
if IsNameBased(reso... | [
"def",
"GetResourceIdOrFullNameFromLink",
"(",
"resource_link",
")",
":",
"# For named based, the resource link is the full name",
"if",
"IsNameBased",
"(",
"resource_link",
")",
":",
"return",
"TrimBeginningAndEndingSlashes",
"(",
"resource_link",
")",
"# Padding the resource li... | Gets resource id or full name from resource link.
:param str resource_link:
:return:
The resource id or full name from the resource link.
:rtype: str | [
"Gets",
"resource",
"id",
"or",
"full",
"name",
"from",
"resource",
"link",
"."
] | python | train | 38.75 |
gwastro/pycbc-glue | pycbc_glue/pipeline.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/pipeline.py#L2501-L2511 | def set_end(self,time,pass_to_command_line=True):
"""
Set the GPS end time of the analysis node by setting a --gps-end-time
option to the node when it is executed.
@param time: GPS end time of job.
@bool pass_to_command_line: add gps-end-time as variable option.
"""
if pass_to_command_line:
... | [
"def",
"set_end",
"(",
"self",
",",
"time",
",",
"pass_to_command_line",
"=",
"True",
")",
":",
"if",
"pass_to_command_line",
":",
"self",
".",
"add_var_opt",
"(",
"'gps-end-time'",
",",
"time",
")",
"self",
".",
"__end",
"=",
"time",
"self",
".",
"__data_... | Set the GPS end time of the analysis node by setting a --gps-end-time
option to the node when it is executed.
@param time: GPS end time of job.
@bool pass_to_command_line: add gps-end-time as variable option. | [
"Set",
"the",
"GPS",
"end",
"time",
"of",
"the",
"analysis",
"node",
"by",
"setting",
"a",
"--",
"gps",
"-",
"end",
"-",
"time",
"option",
"to",
"the",
"node",
"when",
"it",
"is",
"executed",
"."
] | python | train | 36.545455 |
rupertford/melody | src/melody/inputs.py | https://github.com/rupertford/melody/blob/d50459880a87fdd1802c6893f6e12b52d51b3b91/src/melody/inputs.py#L155-L180 | def create_input(option, template_name, template_location="template"):
'''create an input file using jinja2 by filling a template
with the values from the option variable passed in.'''
# restructure option list into jinja2 input format
jinja2_input = {}
for item in option:
try:
... | [
"def",
"create_input",
"(",
"option",
",",
"template_name",
",",
"template_location",
"=",
"\"template\"",
")",
":",
"# restructure option list into jinja2 input format",
"jinja2_input",
"=",
"{",
"}",
"for",
"item",
"in",
"option",
":",
"try",
":",
"jinja2_input",
... | create an input file using jinja2 by filling a template
with the values from the option variable passed in. | [
"create",
"an",
"input",
"file",
"using",
"jinja2",
"by",
"filling",
"a",
"template",
"with",
"the",
"values",
"from",
"the",
"option",
"variable",
"passed",
"in",
"."
] | python | test | 41.192308 |
OSSOS/MOP | src/ossos/core/ossos/storage.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/storage.py#L629-L701 | def _cutout_expnum(observation, sky_coord, radius):
"""
Get a cutout from an exposure based on the RA/DEC location.
@param observation: The Observation object that contains the expusre number information.
@type observation: Observation
@param sky_coord: which RA/DEC is needed,
@type sky_coord: ... | [
"def",
"_cutout_expnum",
"(",
"observation",
",",
"sky_coord",
",",
"radius",
")",
":",
"uri",
"=",
"observation",
".",
"get_image_uri",
"(",
")",
"cutout_filehandle",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"disposition_filename",
"=",
"client",
"... | Get a cutout from an exposure based on the RA/DEC location.
@param observation: The Observation object that contains the expusre number information.
@type observation: Observation
@param sky_coord: which RA/DEC is needed,
@type sky_coord: SkyCoord
@param radius:
@type radius: Quantity
@retu... | [
"Get",
"a",
"cutout",
"from",
"an",
"exposure",
"based",
"on",
"the",
"RA",
"/",
"DEC",
"location",
"."
] | python | train | 44.753425 |
saltstack/salt | salt/crypt.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L383-L407 | def __get_keys(self, name='master', passphrase=None):
'''
Returns a key object for a key in the pki-dir
'''
path = os.path.join(self.opts['pki_dir'],
name + '.pem')
if not os.path.exists(path):
log.info('Generating %s keys: %s', name, self.... | [
"def",
"__get_keys",
"(",
"self",
",",
"name",
"=",
"'master'",
",",
"passphrase",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"name",
"+",
"'.pem'",
")",
"if",
"not",
... | Returns a key object for a key in the pki-dir | [
"Returns",
"a",
"key",
"object",
"for",
"a",
"key",
"in",
"the",
"pki",
"-",
"dir"
] | python | train | 37.12 |
rigetti/quantumflow | quantumflow/gates.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/gates.py#L110-L113 | def almost_hermitian(gate: Gate) -> bool:
"""Return true if gate tensor is (almost) Hermitian"""
return np.allclose(asarray(gate.asoperator()),
asarray(gate.H.asoperator())) | [
"def",
"almost_hermitian",
"(",
"gate",
":",
"Gate",
")",
"->",
"bool",
":",
"return",
"np",
".",
"allclose",
"(",
"asarray",
"(",
"gate",
".",
"asoperator",
"(",
")",
")",
",",
"asarray",
"(",
"gate",
".",
"H",
".",
"asoperator",
"(",
")",
")",
")... | Return true if gate tensor is (almost) Hermitian | [
"Return",
"true",
"if",
"gate",
"tensor",
"is",
"(",
"almost",
")",
"Hermitian"
] | python | train | 50.25 |
bwohlberg/sporco | sporco/cupy/_cp_util.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cupy/_cp_util.py#L40-L64 | def cupy_wrapper(func):
"""A wrapper function that converts numpy ndarray arguments to cupy
arrays, and convert any cupy arrays returned by the wrapped
function into numpy ndarrays.
"""
@functools.wraps(func)
def wrapped(*args, **kwargs):
args = list(args)
for n, a in enumerate(... | [
"def",
"cupy_wrapper",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"list",
"(",
"args",
")",
"for",
"n",
",",
"a",
"in",
"enumerate",... | A wrapper function that converts numpy ndarray arguments to cupy
arrays, and convert any cupy arrays returned by the wrapped
function into numpy ndarrays. | [
"A",
"wrapper",
"function",
"that",
"converts",
"numpy",
"ndarray",
"arguments",
"to",
"cupy",
"arrays",
"and",
"convert",
"any",
"cupy",
"arrays",
"returned",
"by",
"the",
"wrapped",
"function",
"into",
"numpy",
"ndarrays",
"."
] | python | train | 34.64 |
mikeboers/MultiMap | multimap.py | https://github.com/mikeboers/MultiMap/blob/0251e5d5df693cc247b4ac5b95adfdd10e3bec04/multimap.py#L492-L521 | def setall(self, key, values):
"""Set more than one value for a given key.
Replaces all the existing values for the given key with new values,
removes extra values that are already set if we don't suply enough,
and appends values to the end if there are not enough existing spots... | [
"def",
"setall",
"(",
"self",
",",
"key",
",",
"values",
")",
":",
"key",
"=",
"self",
".",
"_conform_key",
"(",
"key",
")",
"values",
"=",
"[",
"self",
".",
"_conform_value",
"(",
"x",
")",
"for",
"x",
"in",
"values",
"]",
"ids",
"=",
"self",
".... | Set more than one value for a given key.
Replaces all the existing values for the given key with new values,
removes extra values that are already set if we don't suply enough,
and appends values to the end if there are not enough existing spots.
>>> m = MutableMultiMap... | [
"Set",
"more",
"than",
"one",
"value",
"for",
"a",
"given",
"key",
".",
"Replaces",
"all",
"the",
"existing",
"values",
"for",
"the",
"given",
"key",
"with",
"new",
"values",
"removes",
"extra",
"values",
"that",
"are",
"already",
"set",
"if",
"we",
"don... | python | train | 36.733333 |
kobejohn/PQHelper | pqhelper/ui.py | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L219-L223 | def _next(self):
"""Get the next summary and present it."""
self.summaries.rotate(-1)
current_summary = self.summaries[0]
self._update_summary(current_summary) | [
"def",
"_next",
"(",
"self",
")",
":",
"self",
".",
"summaries",
".",
"rotate",
"(",
"-",
"1",
")",
"current_summary",
"=",
"self",
".",
"summaries",
"[",
"0",
"]",
"self",
".",
"_update_summary",
"(",
"current_summary",
")"
] | Get the next summary and present it. | [
"Get",
"the",
"next",
"summary",
"and",
"present",
"it",
"."
] | python | train | 37.4 |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L3105-L3110 | def addContentLen(self, content, len):
"""Append the extra substring to the node content. NOTE: In
contrast to xmlNodeSetContentLen(), @content is supposed to
be raw text, so unescaped XML special chars are allowed,
entity references are not supported. """
libxml2mod.xmlNo... | [
"def",
"addContentLen",
"(",
"self",
",",
"content",
",",
"len",
")",
":",
"libxml2mod",
".",
"xmlNodeAddContentLen",
"(",
"self",
".",
"_o",
",",
"content",
",",
"len",
")"
] | Append the extra substring to the node content. NOTE: In
contrast to xmlNodeSetContentLen(), @content is supposed to
be raw text, so unescaped XML special chars are allowed,
entity references are not supported. | [
"Append",
"the",
"extra",
"substring",
"to",
"the",
"node",
"content",
".",
"NOTE",
":",
"In",
"contrast",
"to",
"xmlNodeSetContentLen",
"()"
] | python | train | 58.833333 |
toejough/pimento | pimento/__init__.py | https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L418-L525 | def _cli():
'''CLI interface'''
parser = _argparse.ArgumentParser(
description='''
Present the user with a simple CLI menu, and return the option chosen.
The menu is presented via stderr.
The output is printed to stdout for piping.
'''.format(_VERSION),
... | [
"def",
"_cli",
"(",
")",
":",
"parser",
"=",
"_argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'''\n Present the user with a simple CLI menu, and return the option chosen.\n The menu is presented via stderr.\n The output is printed to stdout for... | CLI interface | [
"CLI",
"interface"
] | python | train | 34.509259 |
joferkington/mpldatacursor | mpldatacursor/datacursor.py | https://github.com/joferkington/mpldatacursor/blob/7dabc589ed02c35ac5d89de5931f91e0323aa795/mpldatacursor/datacursor.py#L658-L719 | def _select(self, event):
"""This is basically a proxy to trigger a pick event. This function is
connected to either a mouse motion or mouse button event (see
"self.enable") depending on "self.hover". If we're over a point, it
fires a pick event.
This probably seems bizarre, bu... | [
"def",
"_select",
"(",
"self",
",",
"event",
")",
":",
"def",
"event_axes_data",
"(",
"event",
",",
"ax",
")",
":",
"\"\"\"Creates a new event will have xdata and ydata based on *ax*.\"\"\"",
"# We need to redefine event.xdata and event.ydata for twinned axes",
"# to work correct... | This is basically a proxy to trigger a pick event. This function is
connected to either a mouse motion or mouse button event (see
"self.enable") depending on "self.hover". If we're over a point, it
fires a pick event.
This probably seems bizarre, but it's required for hover mode (no mo... | [
"This",
"is",
"basically",
"a",
"proxy",
"to",
"trigger",
"a",
"pick",
"event",
".",
"This",
"function",
"is",
"connected",
"to",
"either",
"a",
"mouse",
"motion",
"or",
"mouse",
"button",
"event",
"(",
"see",
"self",
".",
"enable",
")",
"depending",
"on... | python | train | 44.580645 |
malramsay64/experi | src/experi/run.py | https://github.com/malramsay64/experi/blob/7159644df0420e4a395c87c0c08e11567f401443/src/experi/run.py#L90-L114 | def iterator_chain(variables: VarType, parent: str = None) -> Iterable[VarMatrix]:
"""This successively appends each element of an array to a single list of values.
This takes a list of values and puts all the values generated for each element in
the list into a single list of values. It uses the :func:`it... | [
"def",
"iterator_chain",
"(",
"variables",
":",
"VarType",
",",
"parent",
":",
"str",
"=",
"None",
")",
"->",
"Iterable",
"[",
"VarMatrix",
"]",
":",
"logger",
".",
"debug",
"(",
"\"Yielding from append iterator\"",
")",
"if",
"not",
"isinstance",
"(",
"vari... | This successively appends each element of an array to a single list of values.
This takes a list of values and puts all the values generated for each element in
the list into a single list of values. It uses the :func:`itertools.chain` function to
achieve this. This function is particularly useful for spec... | [
"This",
"successively",
"appends",
"each",
"element",
"of",
"an",
"array",
"to",
"a",
"single",
"list",
"of",
"values",
"."
] | python | train | 38.24 |
bcbio/bcbio-nextgen | bcbio/variation/scalpel.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/scalpel.py#L77-L90 | def run_scalpel(align_bams, items, ref_file, assoc_files, region=None,
out_file=None):
"""Run Scalpel indel calling, either paired tumor/normal or germline calling.
"""
if region is None:
message = ("A region must be provided for Scalpel")
raise ValueError(message)
if i... | [
"def",
"run_scalpel",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
"if",
"region",
"is",
"None",
":",
"message",
"=",
"(",
"\"A region must be provided for Scalpel\"",... | Run Scalpel indel calling, either paired tumor/normal or germline calling. | [
"Run",
"Scalpel",
"indel",
"calling",
"either",
"paired",
"tumor",
"/",
"normal",
"or",
"germline",
"calling",
"."
] | python | train | 47.071429 |
hydpy-dev/hydpy | hydpy/core/propertytools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L536-L538 | def call_fset(self, obj, value) -> None:
"""Store the given custom value and call the setter function."""
vars(obj)[self.name] = self.fset(obj, value) | [
"def",
"call_fset",
"(",
"self",
",",
"obj",
",",
"value",
")",
"->",
"None",
":",
"vars",
"(",
"obj",
")",
"[",
"self",
".",
"name",
"]",
"=",
"self",
".",
"fset",
"(",
"obj",
",",
"value",
")"
] | Store the given custom value and call the setter function. | [
"Store",
"the",
"given",
"custom",
"value",
"and",
"call",
"the",
"setter",
"function",
"."
] | python | train | 54.666667 |
studionow/pybrightcove | pybrightcove/playlist.py | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/playlist.py#L161-L168 | def delete(self, cascade=False):
"""
Deletes this playlist.
"""
if self.id:
self.connection.post('delete_playlist', playlist_id=self.id,
cascade=cascade)
self.id = None | [
"def",
"delete",
"(",
"self",
",",
"cascade",
"=",
"False",
")",
":",
"if",
"self",
".",
"id",
":",
"self",
".",
"connection",
".",
"post",
"(",
"'delete_playlist'",
",",
"playlist_id",
"=",
"self",
".",
"id",
",",
"cascade",
"=",
"cascade",
")",
"se... | Deletes this playlist. | [
"Deletes",
"this",
"playlist",
"."
] | python | train | 29.125 |
andreasjansson/head-in-the-clouds | headintheclouds/ec2.py | https://github.com/andreasjansson/head-in-the-clouds/blob/32c1d00d01036834dc94368e7f38b0afd3f7a82f/headintheclouds/ec2.py#L42-L55 | def mount_volume(volume, device='/dev/xvdf', mountpoint='/mnt/data', fstype='ext4'):
'''
Mount an EBS volume
Args:
volume (str): EBS volume ID
device (str): default /dev/xvdf
mountpoint (str): default /mnt/data
fstype (str): default ext4
'''
_ec2().attach_volume(volu... | [
"def",
"mount_volume",
"(",
"volume",
",",
"device",
"=",
"'/dev/xvdf'",
",",
"mountpoint",
"=",
"'/mnt/data'",
",",
"fstype",
"=",
"'ext4'",
")",
":",
"_ec2",
"(",
")",
".",
"attach_volume",
"(",
"volume",
",",
"_host_node",
"(",
")",
"[",
"'id'",
"]",
... | Mount an EBS volume
Args:
volume (str): EBS volume ID
device (str): default /dev/xvdf
mountpoint (str): default /mnt/data
fstype (str): default ext4 | [
"Mount",
"an",
"EBS",
"volume"
] | python | train | 33 |
datadesk/python-documentcloud | documentcloud/__init__.py | https://github.com/datadesk/python-documentcloud/blob/0d7f42cbf1edf5c61fca37ed846362cba4abfd76/documentcloud/__init__.py#L535-L549 | def get_or_create_by_title(self, title):
"""
Fetch a title, if it exists. Create it if it doesn't.
Returns a tuple with the object first, and then a boolean that
indicates whether or not the object was created fresh. True means it's
brand new.
"""
try:
... | [
"def",
"get_or_create_by_title",
"(",
"self",
",",
"title",
")",
":",
"try",
":",
"obj",
"=",
"self",
".",
"get_by_title",
"(",
"title",
")",
"created",
"=",
"False",
"except",
"DoesNotExistError",
":",
"obj",
"=",
"self",
".",
"create",
"(",
"title",
"=... | Fetch a title, if it exists. Create it if it doesn't.
Returns a tuple with the object first, and then a boolean that
indicates whether or not the object was created fresh. True means it's
brand new. | [
"Fetch",
"a",
"title",
"if",
"it",
"exists",
".",
"Create",
"it",
"if",
"it",
"doesn",
"t",
"."
] | python | train | 33.2 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L987-L1109 | def find_hist2d_offset(filename, reference, refwcs=None, refnames=['ra', 'dec'],
match_tolerance=5., chip_catalog=True, search_radius=15.0,
min_match=10, classify=True):
"""Iteratively look for the best cross-match between the catalog and ref.
Parameters
------... | [
"def",
"find_hist2d_offset",
"(",
"filename",
",",
"reference",
",",
"refwcs",
"=",
"None",
",",
"refnames",
"=",
"[",
"'ra'",
",",
"'dec'",
"]",
",",
"match_tolerance",
"=",
"5.",
",",
"chip_catalog",
"=",
"True",
",",
"search_radius",
"=",
"15.0",
",",
... | Iteratively look for the best cross-match between the catalog and ref.
Parameters
----------
filename : `~astropy.io.fits.HDUList` or str
Single image to extract sources for matching to
the external astrometric catalog.
reference : str or `~astropy.table.Table`
... | [
"Iteratively",
"look",
"for",
"the",
"best",
"cross",
"-",
"match",
"between",
"the",
"catalog",
"and",
"ref",
"."
] | python | train | 42.756098 |
dhain/potpy | potpy/router.py | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/router.py#L250-L261 | def add(self, match, handler):
"""Register a handler with the Router.
:param match: The first argument passed to the :meth:`match` method
when checking against this handler.
:param handler: A callable or :class:`Route` instance that will handle
matching calls. If not a R... | [
"def",
"add",
"(",
"self",
",",
"match",
",",
"handler",
")",
":",
"self",
".",
"routes",
".",
"append",
"(",
"(",
"match",
",",
"(",
"Route",
"(",
"handler",
")",
"if",
"not",
"isinstance",
"(",
"handler",
",",
"Route",
")",
"else",
"handler",
")"... | Register a handler with the Router.
:param match: The first argument passed to the :meth:`match` method
when checking against this handler.
:param handler: A callable or :class:`Route` instance that will handle
matching calls. If not a Route instance, will be wrapped in one. | [
"Register",
"a",
"handler",
"with",
"the",
"Router",
"."
] | python | train | 41.166667 |
CZ-NIC/yangson | yangson/schemadata.py | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemadata.py#L459-L466 | def derived_from_all(self, identities: List[QualName]) -> MutableSet[QualName]:
"""Return list of identities transitively derived from all `identity`."""
if not identities:
return set()
res = self.derived_from(identities[0])
for id in identities[1:]:
res &= self.d... | [
"def",
"derived_from_all",
"(",
"self",
",",
"identities",
":",
"List",
"[",
"QualName",
"]",
")",
"->",
"MutableSet",
"[",
"QualName",
"]",
":",
"if",
"not",
"identities",
":",
"return",
"set",
"(",
")",
"res",
"=",
"self",
".",
"derived_from",
"(",
"... | Return list of identities transitively derived from all `identity`. | [
"Return",
"list",
"of",
"identities",
"transitively",
"derived",
"from",
"all",
"identity",
"."
] | python | train | 43.375 |
tanghaibao/jcvi | jcvi/projects/synfind.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/projects/synfind.py#L52-L85 | def grasstruth(args):
"""
%prog grasstruth james-pan-grass.txt
Prepare truth pairs for 4 grasses.
"""
p = OptionParser(grasstruth.__doc__)
opts, args = p.parse_args(args)
if len(args) != 1:
sys.exit(not p.print_help())
james, = args
fp = open(james)
pairs = set()
f... | [
"def",
"grasstruth",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"grasstruth",
".",
"__doc__",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"sys",
".",
"exit",
"... | %prog grasstruth james-pan-grass.txt
Prepare truth pairs for 4 grasses. | [
"%prog",
"grasstruth",
"james",
"-",
"pan",
"-",
"grass",
".",
"txt"
] | python | train | 25 |
exosite-labs/pyonep | pyonep/provision.py | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/provision.py#L237-L248 | def content_list(self, key, model):
"""Returns the list of content IDs for a given model.
This method maps to
https://github.com/exosite/docs/tree/master/provision#get---list-content-ids
Args:
key: The CIK or Token for the device
model:
"""
path ... | [
"def",
"content_list",
"(",
"self",
",",
"key",
",",
"model",
")",
":",
"path",
"=",
"PROVISION_MANAGE_CONTENT",
"+",
"model",
"+",
"'/'",
"return",
"self",
".",
"_request",
"(",
"path",
",",
"key",
",",
"''",
",",
"'GET'",
",",
"self",
".",
"_manage_b... | Returns the list of content IDs for a given model.
This method maps to
https://github.com/exosite/docs/tree/master/provision#get---list-content-ids
Args:
key: The CIK or Token for the device
model: | [
"Returns",
"the",
"list",
"of",
"content",
"IDs",
"for",
"a",
"given",
"model",
"."
] | python | train | 35.083333 |
Komnomnomnom/swigibpy | swigibpy.py | https://github.com/Komnomnomnom/swigibpy/blob/cfd307fdbfaffabc69a2dc037538d7e34a8b8daf/swigibpy.py#L1220-L1222 | def exerciseOptions(self, id, contract, exerciseAction, exerciseQuantity, account, override):
"""exerciseOptions(EClient self, TickerId id, Contract contract, int exerciseAction, int exerciseQuantity, IBString const & account, int override)"""
return _swigibpy.EClient_exerciseOptions(self, id, contract,... | [
"def",
"exerciseOptions",
"(",
"self",
",",
"id",
",",
"contract",
",",
"exerciseAction",
",",
"exerciseQuantity",
",",
"account",
",",
"override",
")",
":",
"return",
"_swigibpy",
".",
"EClient_exerciseOptions",
"(",
"self",
",",
"id",
",",
"contract",
",",
... | exerciseOptions(EClient self, TickerId id, Contract contract, int exerciseAction, int exerciseQuantity, IBString const & account, int override) | [
"exerciseOptions",
"(",
"EClient",
"self",
"TickerId",
"id",
"Contract",
"contract",
"int",
"exerciseAction",
"int",
"exerciseQuantity",
"IBString",
"const",
"&",
"account",
"int",
"override",
")"
] | python | train | 123.666667 |
stevearc/dql | dql/engine.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/engine.py#L974-L992 | def execute(self, fragment, pretty_format=True):
"""
Run or aggregate a query fragment
Concat the fragment to any stored fragments. If they form a complete
query, run it and return the result. If not, store them and return
None.
"""
self.fragments = (self.fragme... | [
"def",
"execute",
"(",
"self",
",",
"fragment",
",",
"pretty_format",
"=",
"True",
")",
":",
"self",
".",
"fragments",
"=",
"(",
"self",
".",
"fragments",
"+",
"\"\\n\"",
"+",
"fragment",
")",
".",
"lstrip",
"(",
")",
"try",
":",
"line_parser",
".",
... | Run or aggregate a query fragment
Concat the fragment to any stored fragments. If they form a complete
query, run it and return the result. If not, store them and return
None. | [
"Run",
"or",
"aggregate",
"a",
"query",
"fragment"
] | python | train | 34.315789 |
aiven/pghoard | pghoard/pghoard.py | https://github.com/aiven/pghoard/blob/2994165d4ef3ff7a5669a2527346bcbfb5b3bd8a/pghoard/pghoard.py#L346-L392 | def startup_walk_for_missed_files(self):
"""Check xlog and xlog_incoming directories for files that receivexlog has received but not yet
compressed as well as the files we have compressed but not yet uploaded and process them."""
for site in self.config["backup_sites"]:
compressed_xl... | [
"def",
"startup_walk_for_missed_files",
"(",
"self",
")",
":",
"for",
"site",
"in",
"self",
".",
"config",
"[",
"\"backup_sites\"",
"]",
":",
"compressed_xlog_path",
",",
"_",
"=",
"self",
".",
"create_backup_site_paths",
"(",
"site",
")",
"uncompressed_xlog_path"... | Check xlog and xlog_incoming directories for files that receivexlog has received but not yet
compressed as well as the files we have compressed but not yet uploaded and process them. | [
"Check",
"xlog",
"and",
"xlog_incoming",
"directories",
"for",
"files",
"that",
"receivexlog",
"has",
"received",
"but",
"not",
"yet",
"compressed",
"as",
"well",
"as",
"the",
"files",
"we",
"have",
"compressed",
"but",
"not",
"yet",
"uploaded",
"and",
"proces... | python | train | 56.170213 |
saimn/sigal | sigal/video.py | https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/video.py#L38-L59 | def check_subprocess(cmd, source, outname):
"""Run the command to resize the video and remove the output file if the
processing fails.
"""
logger = logging.getLogger(__name__)
try:
res = subprocess.run(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
exc... | [
"def",
"check_subprocess",
"(",
"cmd",
",",
"source",
",",
"outname",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"try",
":",
"res",
"=",
"subprocess",
".",
"run",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE... | Run the command to resize the video and remove the output file if the
processing fails. | [
"Run",
"the",
"command",
"to",
"resize",
"the",
"video",
"and",
"remove",
"the",
"output",
"file",
"if",
"the",
"processing",
"fails",
"."
] | python | valid | 36.818182 |
Opentrons/opentrons | api/src/opentrons/protocol_api/contexts.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/protocol_api/contexts.py#L185-L200 | def load_labware(
self, labware_obj: Labware,
location: types.DeckLocation) -> Labware:
""" Specify the presence of a piece of labware on the OT2 deck.
This function loads the labware specified by `labware`
(previously loaded from a configuration file) to the location
... | [
"def",
"load_labware",
"(",
"self",
",",
"labware_obj",
":",
"Labware",
",",
"location",
":",
"types",
".",
"DeckLocation",
")",
"->",
"Labware",
":",
"self",
".",
"_deck_layout",
"[",
"location",
"]",
"=",
"labware_obj",
"return",
"labware_obj"
] | Specify the presence of a piece of labware on the OT2 deck.
This function loads the labware specified by `labware`
(previously loaded from a configuration file) to the location
specified by `location`.
:param Labware labware: The labware object to load
:param location: The slot... | [
"Specify",
"the",
"presence",
"of",
"a",
"piece",
"of",
"labware",
"on",
"the",
"OT2",
"deck",
"."
] | python | train | 39.125 |
iotile/coretools | iotilecore/iotile/core/utilities/intelhex/__init__.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/intelhex/__init__.py#L1145-L1158 | def data(offset, bytes):
"""Return Data record. This constructs the full record, including
the length information, the record type (0x00), the
checksum, and the offset.
@param offset load offset of first byte.
@param bytes list of byte values to pack into record.
@... | [
"def",
"data",
"(",
"offset",
",",
"bytes",
")",
":",
"assert",
"0",
"<=",
"offset",
"<",
"65536",
"assert",
"0",
"<",
"len",
"(",
"bytes",
")",
"<",
"256",
"b",
"=",
"[",
"len",
"(",
"bytes",
")",
",",
"(",
"offset",
">>",
"8",
")",
"&",
"0x... | Return Data record. This constructs the full record, including
the length information, the record type (0x00), the
checksum, and the offset.
@param offset load offset of first byte.
@param bytes list of byte values to pack into record.
@return String representation... | [
"Return",
"Data",
"record",
".",
"This",
"constructs",
"the",
"full",
"record",
"including",
"the",
"length",
"information",
"the",
"record",
"type",
"(",
"0x00",
")",
"the",
"checksum",
"and",
"the",
"offset",
"."
] | python | train | 39.5 |
Guake/guake | guake/guake_app.py | https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L437-L441 | def show_menu(self, status_icon, button, activate_time):
"""Show the tray icon menu.
"""
menu = self.get_widget('tray-menu')
menu.popup(None, None, None, Gtk.StatusIcon.position_menu, button, activate_time) | [
"def",
"show_menu",
"(",
"self",
",",
"status_icon",
",",
"button",
",",
"activate_time",
")",
":",
"menu",
"=",
"self",
".",
"get_widget",
"(",
"'tray-menu'",
")",
"menu",
".",
"popup",
"(",
"None",
",",
"None",
",",
"None",
",",
"Gtk",
".",
"StatusIc... | Show the tray icon menu. | [
"Show",
"the",
"tray",
"icon",
"menu",
"."
] | python | train | 46.8 |
ldomic/lintools | lintools/draw.py | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/draw.py#L29-L48 | def draw_hydrogen_bonds(self,color="black"):
"""For each bond that has been determined to be important, a line gets drawn.
"""
self.draw_hbonds=""
if self.hbonds!=None:
for bond in self.hbonds.hbonds_for_drawing:
x = str((self.molecule.x_dim-self.molecule.molsize1)/2)
y = str((self.molecule.y_dim-sel... | [
"def",
"draw_hydrogen_bonds",
"(",
"self",
",",
"color",
"=",
"\"black\"",
")",
":",
"self",
".",
"draw_hbonds",
"=",
"\"\"",
"if",
"self",
".",
"hbonds",
"!=",
"None",
":",
"for",
"bond",
"in",
"self",
".",
"hbonds",
".",
"hbonds_for_drawing",
":",
"x",... | For each bond that has been determined to be important, a line gets drawn. | [
"For",
"each",
"bond",
"that",
"has",
"been",
"determined",
"to",
"be",
"important",
"a",
"line",
"gets",
"drawn",
"."
] | python | train | 120.2 |
osrg/ryu | ryu/services/protocols/vrrp/api.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/vrrp/api.py#L21-L30 | def vrrp_config(app, interface, config):
"""create an instance.
returns EventVRRPConfigReply(instance.name, interface, config)
on success.
returns EventVRRPConfigReply(None, interface, config)
on failure.
"""
config_request = vrrp_event.EventVRRPConfigRequest(interface, config)
config_re... | [
"def",
"vrrp_config",
"(",
"app",
",",
"interface",
",",
"config",
")",
":",
"config_request",
"=",
"vrrp_event",
".",
"EventVRRPConfigRequest",
"(",
"interface",
",",
"config",
")",
"config_request",
".",
"sync",
"=",
"True",
"return",
"app",
".",
"send_reque... | create an instance.
returns EventVRRPConfigReply(instance.name, interface, config)
on success.
returns EventVRRPConfigReply(None, interface, config)
on failure. | [
"create",
"an",
"instance",
".",
"returns",
"EventVRRPConfigReply",
"(",
"instance",
".",
"name",
"interface",
"config",
")",
"on",
"success",
".",
"returns",
"EventVRRPConfigReply",
"(",
"None",
"interface",
"config",
")",
"on",
"failure",
"."
] | python | train | 37.2 |
samuelcolvin/pydantic | pydantic/schema.py | https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L408-L474 | def field_type_schema(
field: Field,
*,
by_alias: bool,
model_name_map: Dict[Type['main.BaseModel'], str],
schema_overrides: bool = False,
ref_prefix: Optional[str] = None,
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""
Used by ``field_schema()``, you probably should be using that funct... | [
"def",
"field_type_schema",
"(",
"field",
":",
"Field",
",",
"*",
",",
"by_alias",
":",
"bool",
",",
"model_name_map",
":",
"Dict",
"[",
"Type",
"[",
"'main.BaseModel'",
"]",
",",
"str",
"]",
",",
"schema_overrides",
":",
"bool",
"=",
"False",
",",
"ref_... | Used by ``field_schema()``, you probably should be using that function.
Take a single ``field`` and generate the schema for its type only, not including additional
information as title, etc. Also return additional schema definitions, from sub-models. | [
"Used",
"by",
"field_schema",
"()",
"you",
"probably",
"should",
"be",
"using",
"that",
"function",
"."
] | python | train | 43.223881 |
edx/edx-enterprise | integrated_channels/degreed/client.py | https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/degreed/client.py#L175-L188 | def _delete(self, url, data, scope):
"""
Make a DELETE request using the session object to a Degreed endpoint.
Args:
url (str): The url to send a DELETE request to.
data (str): The json encoded payload to DELETE.
scope (str): Must be one of the scopes Degreed... | [
"def",
"_delete",
"(",
"self",
",",
"url",
",",
"data",
",",
"scope",
")",
":",
"self",
".",
"_create_session",
"(",
"scope",
")",
"response",
"=",
"self",
".",
"session",
".",
"delete",
"(",
"url",
",",
"data",
"=",
"data",
")",
"return",
"response"... | Make a DELETE request using the session object to a Degreed endpoint.
Args:
url (str): The url to send a DELETE request to.
data (str): The json encoded payload to DELETE.
scope (str): Must be one of the scopes Degreed expects:
- `CONTENT_PROVIDER_SCO... | [
"Make",
"a",
"DELETE",
"request",
"using",
"the",
"session",
"object",
"to",
"a",
"Degreed",
"endpoint",
"."
] | python | valid | 41.071429 |
inveniosoftware/invenio-communities | invenio_communities/ext.py | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/ext.py#L50-L57 | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
app.cli.add_command(cmd)
app.extensions['invenio-communities'] = self
# Register the jinja do extension
app.jinja_env.add_extension('jinja2.ext.do')
self.register_signals(app) | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"app",
".",
"cli",
".",
"add_command",
"(",
"cmd",
")",
"app",
".",
"extensions",
"[",
"'invenio-communities'",
"]",
"=",
"self",
"# Register the jinja do ex... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | python | train | 38.875 |
getgauge/gauge-python | getgauge/parser_parso.py | https://github.com/getgauge/gauge-python/blob/90f3547dcfd2d16d51f116cdd4e53527eeab1a57/getgauge/parser_parso.py#L59-L77 | def _step_decorator_args(self, decorator):
"""
Get the arguments passed to step decorators
converted to python objects.
"""
args = decorator.children[3:-2]
step = None
if len(args) == 1:
try:
step = ast.literal_eval(args[0].get_code())
... | [
"def",
"_step_decorator_args",
"(",
"self",
",",
"decorator",
")",
":",
"args",
"=",
"decorator",
".",
"children",
"[",
"3",
":",
"-",
"2",
"]",
"step",
"=",
"None",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"try",
":",
"step",
"=",
"ast",
"... | Get the arguments passed to step decorators
converted to python objects. | [
"Get",
"the",
"arguments",
"passed",
"to",
"step",
"decorators",
"converted",
"to",
"python",
"objects",
"."
] | python | test | 40.842105 |
idlesign/srptools | srptools/utils.py | https://github.com/idlesign/srptools/blob/eb08a27137d3216e41d63bbeafbac79f43881a6a/srptools/utils.py#L22-L34 | def hex_from(val):
"""Returns hex string representation for a given value.
:param bytes|str|unicode|int|long val:
:rtype: bytes|str
"""
if isinstance(val, integer_types):
hex_str = '%x' % val
if len(hex_str) % 2:
hex_str = '0' + hex_str
return hex_str
return... | [
"def",
"hex_from",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"integer_types",
")",
":",
"hex_str",
"=",
"'%x'",
"%",
"val",
"if",
"len",
"(",
"hex_str",
")",
"%",
"2",
":",
"hex_str",
"=",
"'0'",
"+",
"hex_str",
"return",
"hex_str",
... | Returns hex string representation for a given value.
:param bytes|str|unicode|int|long val:
:rtype: bytes|str | [
"Returns",
"hex",
"string",
"representation",
"for",
"a",
"given",
"value",
"."
] | python | train | 24.692308 |
CartoDB/carto-python | carto/maps.py | https://github.com/CartoDB/carto-python/blob/f6ac3d17ed08e5bc3f99edd2bde4fb7dba3eee16/carto/maps.py#L138-L163 | def instantiate(self, params, auth=None):
"""
Allows you to fetch the map tiles of a created map
:param params: The json with the styling info for the named map
:param auth: The auth client
:type params: dict
:type auth: :class:`carto.auth.APIKeyAuthClient`
:ret... | [
"def",
"instantiate",
"(",
"self",
",",
"params",
",",
"auth",
"=",
"None",
")",
":",
"try",
":",
"endpoint",
"=",
"(",
"self",
".",
"Meta",
".",
"collection_endpoint",
"+",
"\"{template_id}\"",
")",
".",
"format",
"(",
"template_id",
"=",
"self",
".",
... | Allows you to fetch the map tiles of a created map
:param params: The json with the styling info for the named map
:param auth: The auth client
:type params: dict
:type auth: :class:`carto.auth.APIKeyAuthClient`
:return:
:raise: CartoException | [
"Allows",
"you",
"to",
"fetch",
"the",
"map",
"tiles",
"of",
"a",
"created",
"map"
] | python | train | 32.461538 |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L115-L127 | def require(self, key: str) -> str:
"""
Returns a configuration value by its given key. If it doesn't exist, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: str
:raises ConfigMissingError: The configur... | [
"def",
"require",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"str",
":",
"v",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"ConfigMissingError",
"(",
"self",
".",
"full_key",
"(",
"key",
")",
")",
"return"... | Returns a configuration value by its given key. If it doesn't exist, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: str
:raises ConfigMissingError: The configuration value did not exist. | [
"Returns",
"a",
"configuration",
"value",
"by",
"its",
"given",
"key",
".",
"If",
"it",
"doesn",
"t",
"exist",
"an",
"error",
"is",
"thrown",
"."
] | python | train | 36 |
bookieio/breadability | breadability/readable.py | https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L446-L458 | def _handle_no_candidates(self):
"""
If we fail to find a good candidate we need to find something else.
"""
# since we've not found a good candidate we're should help this
if self.dom is not None and len(self.dom):
dom = prep_article(self.dom)
dom = build... | [
"def",
"_handle_no_candidates",
"(",
"self",
")",
":",
"# since we've not found a good candidate we're should help this",
"if",
"self",
".",
"dom",
"is",
"not",
"None",
"and",
"len",
"(",
"self",
".",
"dom",
")",
":",
"dom",
"=",
"prep_article",
"(",
"self",
"."... | If we fail to find a good candidate we need to find something else. | [
"If",
"we",
"fail",
"to",
"find",
"a",
"good",
"candidate",
"we",
"need",
"to",
"find",
"something",
"else",
"."
] | python | train | 44.076923 |
MillionIntegrals/vel | vel/commands/phase_train_command.py | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/commands/phase_train_command.py#L50-L106 | def run(self):
""" Run the command with supplied configuration """
device = self.model_config.torch_device()
learner = Learner(device, self.model_factory.instantiate())
# All callbacks useful for learning
callbacks = self.gather_callbacks()
# Metrics to track through th... | [
"def",
"run",
"(",
"self",
")",
":",
"device",
"=",
"self",
".",
"model_config",
".",
"torch_device",
"(",
")",
"learner",
"=",
"Learner",
"(",
"device",
",",
"self",
".",
"model_factory",
".",
"instantiate",
"(",
")",
")",
"# All callbacks useful for learni... | Run the command with supplied configuration | [
"Run",
"the",
"command",
"with",
"supplied",
"configuration"
] | python | train | 39.578947 |
matplotlib/cmocean | cmocean/tools.py | https://github.com/matplotlib/cmocean/blob/37edd4a209a733d87dea7fed9eb22adc1d5a57c8/cmocean/tools.py#L73-L91 | def cmap(rgbin, N=256):
'''Input an array of rgb values to generate a colormap.
:param rgbin: An [mx3] array, where m is the number of input color triplets which
are interpolated between to make the colormap that is returned. hex values
can be input instead, as [mx1] in single quotes with a #... | [
"def",
"cmap",
"(",
"rgbin",
",",
"N",
"=",
"256",
")",
":",
"# rgb inputs here",
"if",
"not",
"isinstance",
"(",
"rgbin",
"[",
"0",
"]",
",",
"_string_types",
")",
":",
"# normalize to be out of 1 if out of 256 instead",
"if",
"rgbin",
".",
"max",
"(",
")",... | Input an array of rgb values to generate a colormap.
:param rgbin: An [mx3] array, where m is the number of input color triplets which
are interpolated between to make the colormap that is returned. hex values
can be input instead, as [mx1] in single quotes with a #.
:param N=10: The number o... | [
"Input",
"an",
"array",
"of",
"rgb",
"values",
"to",
"generate",
"a",
"colormap",
"."
] | python | train | 34.526316 |
UAVCAN/pyuavcan | uavcan/driver/common.py | https://github.com/UAVCAN/pyuavcan/blob/a06a9975c1c0de4f1d469f05b29b374332968e2b/uavcan/driver/common.py#L64-L76 | def add_io_hook(self, hook):
"""
Args:
hook: This hook will be invoked for every incoming and outgoing CAN frame.
Hook arguments: (direction, frame)
See FRAME_DIRECTION_*, CANFrame.
"""
def proxy(*args):
hook(*args)
... | [
"def",
"add_io_hook",
"(",
"self",
",",
"hook",
")",
":",
"def",
"proxy",
"(",
"*",
"args",
")",
":",
"hook",
"(",
"*",
"args",
")",
"self",
".",
"_io_hooks",
".",
"append",
"(",
"proxy",
")",
"return",
"self",
".",
"HookRemover",
"(",
"lambda",
":... | Args:
hook: This hook will be invoked for every incoming and outgoing CAN frame.
Hook arguments: (direction, frame)
See FRAME_DIRECTION_*, CANFrame. | [
"Args",
":",
"hook",
":",
"This",
"hook",
"will",
"be",
"invoked",
"for",
"every",
"incoming",
"and",
"outgoing",
"CAN",
"frame",
".",
"Hook",
"arguments",
":",
"(",
"direction",
"frame",
")",
"See",
"FRAME_DIRECTION_",
"*",
"CANFrame",
"."
] | python | train | 31.538462 |
pydata/xarray | xarray/core/dataarray.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L328-L358 | def to_dataset(self, dim=None, name=None):
"""Convert a DataArray to a Dataset.
Parameters
----------
dim : str, optional
Name of the dimension on this array along which to split this array
into separate variables. If not provided, this array is converted
... | [
"def",
"to_dataset",
"(",
"self",
",",
"dim",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"dim",
"is",
"not",
"None",
"and",
"dim",
"not",
"in",
"self",
".",
"dims",
":",
"warnings",
".",
"warn",
"(",
"'the order of the arguments on DataArray.... | Convert a DataArray to a Dataset.
Parameters
----------
dim : str, optional
Name of the dimension on this array along which to split this array
into separate variables. If not provided, this array is converted
into a Dataset of one variable.
name : st... | [
"Convert",
"a",
"DataArray",
"to",
"a",
"Dataset",
"."
] | python | train | 36.709677 |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L1485-L1504 | def is_broker_action_done(action, rid=None, unit=None):
"""Check whether broker action has completed yet.
@param action: name of action to be performed
@returns True if action complete otherwise False
"""
rdata = relation_get(rid, unit) or {}
broker_rsp = rdata.get(get_broker_rsp_key())
if ... | [
"def",
"is_broker_action_done",
"(",
"action",
",",
"rid",
"=",
"None",
",",
"unit",
"=",
"None",
")",
":",
"rdata",
"=",
"relation_get",
"(",
"rid",
",",
"unit",
")",
"or",
"{",
"}",
"broker_rsp",
"=",
"rdata",
".",
"get",
"(",
"get_broker_rsp_key",
"... | Check whether broker action has completed yet.
@param action: name of action to be performed
@returns True if action complete otherwise False | [
"Check",
"whether",
"broker",
"action",
"has",
"completed",
"yet",
"."
] | python | train | 30.75 |
stevelittlefish/littlefish | littlefish/util.py | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/util.py#L342-L356 | def from_base62(s):
"""
Convert a base62 String back into a number
:param s: The base62 encoded String
:return: The number encoded in the String (integer)
"""
result = 0
for c in s:
if c not in BASE62_MAP:
raise Exception('Invalid base64 string: %s' % s)
result ... | [
"def",
"from_base62",
"(",
"s",
")",
":",
"result",
"=",
"0",
"for",
"c",
"in",
"s",
":",
"if",
"c",
"not",
"in",
"BASE62_MAP",
":",
"raise",
"Exception",
"(",
"'Invalid base64 string: %s'",
"%",
"s",
")",
"result",
"=",
"result",
"*",
"62",
"+",
"BA... | Convert a base62 String back into a number
:param s: The base62 encoded String
:return: The number encoded in the String (integer) | [
"Convert",
"a",
"base62",
"String",
"back",
"into",
"a",
"number",
":",
"param",
"s",
":",
"The",
"base62",
"encoded",
"String",
":",
"return",
":",
"The",
"number",
"encoded",
"in",
"the",
"String",
"(",
"integer",
")"
] | python | test | 24 |
poppy-project/pypot | pypot/vrep/remoteApiBindings/vrep.py | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L529-L534 | def simxAuxiliaryConsoleShow(clientID, consoleHandle, showState, operationMode):
'''
Please have a look at the function description/documentation in the V-REP user manual
'''
return c_AuxiliaryConsoleShow(clientID, consoleHandle, showState, operationMode) | [
"def",
"simxAuxiliaryConsoleShow",
"(",
"clientID",
",",
"consoleHandle",
",",
"showState",
",",
"operationMode",
")",
":",
"return",
"c_AuxiliaryConsoleShow",
"(",
"clientID",
",",
"consoleHandle",
",",
"showState",
",",
"operationMode",
")"
] | Please have a look at the function description/documentation in the V-REP user manual | [
"Please",
"have",
"a",
"look",
"at",
"the",
"function",
"description",
"/",
"documentation",
"in",
"the",
"V",
"-",
"REP",
"user",
"manual"
] | python | train | 44.5 |
BlueBrain/NeuroM | neurom/fst/_neuronfunc.py | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L154-L177 | def trunk_angles(nrn, neurite_type=NeuriteType.all):
'''Calculates the angles between all the trunks of the neuron.
The angles are defined on the x-y plane and the trees
are sorted from the y axis and anticlock-wise.
'''
vectors = trunk_vectors(nrn, neurite_type=neurite_type)
# In order to avoid... | [
"def",
"trunk_angles",
"(",
"nrn",
",",
"neurite_type",
"=",
"NeuriteType",
".",
"all",
")",
":",
"vectors",
"=",
"trunk_vectors",
"(",
"nrn",
",",
"neurite_type",
"=",
"neurite_type",
")",
"# In order to avoid the failure of the process in case the neurite_type does not ... | Calculates the angles between all the trunks of the neuron.
The angles are defined on the x-y plane and the trees
are sorted from the y axis and anticlock-wise. | [
"Calculates",
"the",
"angles",
"between",
"all",
"the",
"trunks",
"of",
"the",
"neuron",
".",
"The",
"angles",
"are",
"defined",
"on",
"the",
"x",
"-",
"y",
"plane",
"and",
"the",
"trees",
"are",
"sorted",
"from",
"the",
"y",
"axis",
"and",
"anticlock",
... | python | train | 40.5 |
quasipedia/swaggery | swaggery/api.py | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/api.py#L197-L234 | def operations(*operations):
'''Decorator for marking Resource methods as HTTP operations.
This decorator does a number of different things:
- It transfer onto itself docstring and annotations from the decorated
method, so as to be "transparent" with regards to introspection.
- It tra... | [
"def",
"operations",
"(",
"*",
"operations",
")",
":",
"def",
"decorator",
"(",
"method",
")",
":",
"def",
"wrapper",
"(",
"cls",
",",
"request",
",",
"start_response",
",",
"*",
"*",
"kwargs",
")",
":",
"result_cache",
"=",
"[",
"]",
"try",
":",
"yi... | Decorator for marking Resource methods as HTTP operations.
This decorator does a number of different things:
- It transfer onto itself docstring and annotations from the decorated
method, so as to be "transparent" with regards to introspection.
- It tranform the method so as to make it a ... | [
"Decorator",
"for",
"marking",
"Resource",
"methods",
"as",
"HTTP",
"operations",
"."
] | python | train | 48.052632 |
dfunckt/django-rules | rules/contrib/views.py | https://github.com/dfunckt/django-rules/blob/fcf3711122243c0c0c8124e9bb9bbb829f42ce1b/rules/contrib/views.py#L79-L145 | def permission_required(perm, fn=None, login_url=None, raise_exception=False, redirect_field_name=REDIRECT_FIELD_NAME):
"""
View decorator that checks for the given permissions before allowing the
view to execute. Use it like this::
from django.shortcuts import get_object_or_404
from rules.... | [
"def",
"permission_required",
"(",
"perm",
",",
"fn",
"=",
"None",
",",
"login_url",
"=",
"None",
",",
"raise_exception",
"=",
"False",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
")",
":",
"def",
"decorator",
"(",
"view_func",
")",
":",
"@",
"wr... | View decorator that checks for the given permissions before allowing the
view to execute. Use it like this::
from django.shortcuts import get_object_or_404
from rules.contrib.views import permission_required
from posts.models import Post
def get_post_by_pk(request, post_id):
... | [
"View",
"decorator",
"that",
"checks",
"for",
"the",
"given",
"permissions",
"before",
"allowing",
"the",
"view",
"to",
"execute",
".",
"Use",
"it",
"like",
"this",
"::"
] | python | train | 40.462687 |
cltl/KafNafParserPy | KafNafParserPy/span_data.py | https://github.com/cltl/KafNafParserPy/blob/9bc32e803c176404b255ba317479b8780ed5f569/KafNafParserPy/span_data.py#L99-L110 | def get_id_head(self):
'''
Returns the id of the target that is set as "head"
@rtype: string
@return: the target id (or None) of the head target
'''
id_head = None
for target_node in self:
if target_node.is_head():
id_head = target_nod... | [
"def",
"get_id_head",
"(",
"self",
")",
":",
"id_head",
"=",
"None",
"for",
"target_node",
"in",
"self",
":",
"if",
"target_node",
".",
"is_head",
"(",
")",
":",
"id_head",
"=",
"target_node",
".",
"get_id",
"(",
")",
"break",
"return",
"id_head"
] | Returns the id of the target that is set as "head"
@rtype: string
@return: the target id (or None) of the head target | [
"Returns",
"the",
"id",
"of",
"the",
"target",
"that",
"is",
"set",
"as",
"head"
] | python | train | 30.333333 |
Skyscanner/pycfmodel | pycfmodel/model/cf_model.py | https://github.com/Skyscanner/pycfmodel/blob/e3da4db96f59c0a5dba06ae66ad25645775e5500/pycfmodel/model/cf_model.py#L32-L39 | def parse_parameters(self, parameters):
"""Parses and sets parameters in the model."""
self.parameters = []
for param_name, param_value in parameters.items():
p = Parameter(param_name, param_value)
if p:
self.parameters.append(p) | [
"def",
"parse_parameters",
"(",
"self",
",",
"parameters",
")",
":",
"self",
".",
"parameters",
"=",
"[",
"]",
"for",
"param_name",
",",
"param_value",
"in",
"parameters",
".",
"items",
"(",
")",
":",
"p",
"=",
"Parameter",
"(",
"param_name",
",",
"param... | Parses and sets parameters in the model. | [
"Parses",
"and",
"sets",
"parameters",
"in",
"the",
"model",
"."
] | python | train | 35.875 |
jamieleshaw/lurklib | lurklib/channel.py | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L139-L174 | def cmode(self, channel, modes=''):
"""
Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel.
"""
with self.l... | [
"def",
"cmode",
"(",
"self",
",",
"channel",
",",
"modes",
"=",
"''",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"is_in_channel",
"(",
"channel",
")",
"if",
"not",
"modes",
":",
"self",
".",
"send",
"(",
"'MODE %s'",
"%",
"channel",
"... | Sets or gets the channel mode.
Required arguments:
* channel - Channel to set/get modes of.
Optional arguments:
* modes='' - Modes to set.
If not specified return the modes of the channel. | [
"Sets",
"or",
"gets",
"the",
"channel",
"mode",
".",
"Required",
"arguments",
":",
"*",
"channel",
"-",
"Channel",
"to",
"set",
"/",
"get",
"modes",
"of",
".",
"Optional",
"arguments",
":",
"*",
"modes",
"=",
"-",
"Modes",
"to",
"set",
".",
"If",
"no... | python | train | 41.222222 |
adamchainz/kwargs-only | kwargs_only.py | https://github.com/adamchainz/kwargs-only/blob/a75246283358696a6112af3baf5002fa023f5336/kwargs_only.py#L10-L36 | def kwargs_only(func):
"""
Make a function only accept keyword arguments.
This can be dropped in Python 3 in lieu of:
def foo(*, bar=default):
"""
if hasattr(inspect, 'signature'): # pragma: no cover
# Python 3
signature = inspect.signature(func)
first_arg_name = lis... | [
"def",
"kwargs_only",
"(",
"func",
")",
":",
"if",
"hasattr",
"(",
"inspect",
",",
"'signature'",
")",
":",
"# pragma: no cover",
"# Python 3",
"signature",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"first_arg_name",
"=",
"list",
"(",
"signature",
... | Make a function only accept keyword arguments.
This can be dropped in Python 3 in lieu of:
def foo(*, bar=default): | [
"Make",
"a",
"function",
"only",
"accept",
"keyword",
"arguments",
".",
"This",
"can",
"be",
"dropped",
"in",
"Python",
"3",
"in",
"lieu",
"of",
":",
"def",
"foo",
"(",
"*",
"bar",
"=",
"default",
")",
":"
] | python | train | 30.185185 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L975-L989 | def _make_module_refnode(self, builder, fromdocname, name, contnode):
"""Helper function to generate new xref node based on
current environment.
"""
# Get additional info for modules.
docname, synopsis, platform, deprecated = self.data['modules'][name]
title = name
... | [
"def",
"_make_module_refnode",
"(",
"self",
",",
"builder",
",",
"fromdocname",
",",
"name",
",",
"contnode",
")",
":",
"# Get additional info for modules.",
"docname",
",",
"synopsis",
",",
"platform",
",",
"deprecated",
"=",
"self",
".",
"data",
"[",
"'modules... | Helper function to generate new xref node based on
current environment. | [
"Helper",
"function",
"to",
"generate",
"new",
"xref",
"node",
"based",
"on",
"current",
"environment",
"."
] | python | train | 40.4 |
glitchassassin/lackey | lackey/TemplateMatchers.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/TemplateMatchers.py#L246-L253 | def _build_pyramid(self, image, levels):
""" Returns a list of reduced-size images, from smallest to original size """
pyramid = [image]
for l in range(levels-1):
if any(x < 20 for x in pyramid[-1].shape[:2]):
break
pyramid.append(cv2.pyrDown(pyramid[-1]))... | [
"def",
"_build_pyramid",
"(",
"self",
",",
"image",
",",
"levels",
")",
":",
"pyramid",
"=",
"[",
"image",
"]",
"for",
"l",
"in",
"range",
"(",
"levels",
"-",
"1",
")",
":",
"if",
"any",
"(",
"x",
"<",
"20",
"for",
"x",
"in",
"pyramid",
"[",
"-... | Returns a list of reduced-size images, from smallest to original size | [
"Returns",
"a",
"list",
"of",
"reduced",
"-",
"size",
"images",
"from",
"smallest",
"to",
"original",
"size"
] | python | train | 44 |
gwpy/gwpy | gwpy/cli/timeseries.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/cli/timeseries.py#L65-L94 | def make_plot(self):
"""Generate the plot from time series and arguments
"""
plot = Plot(figsize=self.figsize, dpi=self.dpi)
ax = plot.gca(xscale='auto-gps')
# handle user specified plot labels
if self.args.legend:
nlegargs = len(self.args.legend[0])
... | [
"def",
"make_plot",
"(",
"self",
")",
":",
"plot",
"=",
"Plot",
"(",
"figsize",
"=",
"self",
".",
"figsize",
",",
"dpi",
"=",
"self",
".",
"dpi",
")",
"ax",
"=",
"plot",
".",
"gca",
"(",
"xscale",
"=",
"'auto-gps'",
")",
"# handle user specified plot l... | Generate the plot from time series and arguments | [
"Generate",
"the",
"plot",
"from",
"time",
"series",
"and",
"arguments"
] | python | train | 37.033333 |
openstack/networking-cisco | networking_cisco/plugins/cisco/device_manager/rpc/devices_cfgagent_rpc_cb.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/device_manager/rpc/devices_cfgagent_rpc_cb.py#L58-L80 | def update_hosting_device_status(self, context, host, status_info):
"""Report status changes for hosting devices.
:param context: contains user information
:param host: originator of callback
:param status_info: Dictionary with list of hosting device ids for
each type of hos... | [
"def",
"update_hosting_device_status",
"(",
"self",
",",
"context",
",",
"host",
",",
"status_info",
")",
":",
"for",
"status",
",",
"hd_ids",
"in",
"six",
".",
"iteritems",
"(",
"status_info",
")",
":",
"# update hosting device entry in db to new status",
"hd_spec"... | Report status changes for hosting devices.
:param context: contains user information
:param host: originator of callback
:param status_info: Dictionary with list of hosting device ids for
each type of hosting device status to be updated i.e.::
{
... | [
"Report",
"status",
"changes",
"for",
"hosting",
"devices",
"."
] | python | train | 46.478261 |
napalm-automation/napalm | napalm/nxos/nxos.py | https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/nxos/nxos.py#L637-L643 | def _send_command(self, command, raw_text=False):
"""
Wrapper for NX-API show method.
Allows more code sharing between NX-API and SSH.
"""
return self.device.show(command, raw_text=raw_text) | [
"def",
"_send_command",
"(",
"self",
",",
"command",
",",
"raw_text",
"=",
"False",
")",
":",
"return",
"self",
".",
"device",
".",
"show",
"(",
"command",
",",
"raw_text",
"=",
"raw_text",
")"
] | Wrapper for NX-API show method.
Allows more code sharing between NX-API and SSH. | [
"Wrapper",
"for",
"NX",
"-",
"API",
"show",
"method",
"."
] | python | train | 32.142857 |
google-research/batch-ppo | agents/parts/normalize.py | https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/parts/normalize.py#L110-L122 | def reset(self):
"""Reset the estimates of mean and variance.
Resets the full state of this class.
Returns:
Operation.
"""
with tf.name_scope(self._name + '/reset'):
return tf.group(
self._count.assign(0),
self._mean.assign(tf.zeros_like(self._mean)),
self... | [
"def",
"reset",
"(",
"self",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"self",
".",
"_name",
"+",
"'/reset'",
")",
":",
"return",
"tf",
".",
"group",
"(",
"self",
".",
"_count",
".",
"assign",
"(",
"0",
")",
",",
"self",
".",
"_mean",
".",
... | Reset the estimates of mean and variance.
Resets the full state of this class.
Returns:
Operation. | [
"Reset",
"the",
"estimates",
"of",
"mean",
"and",
"variance",
"."
] | python | train | 27.307692 |
elliterate/capybara.py | capybara/queries/current_path_query.py | https://github.com/elliterate/capybara.py/blob/0c6ae449cc37e4445ec3cd6af95674533beedc6c/capybara/queries/current_path_query.py#L26-L54 | def resolves_for(self, session):
"""
Returns whether this query resolves for the given session.
Args:
session (Session): The session for which this query should be executed.
Returns:
bool: Whether this query resolves.
"""
if self.url:
... | [
"def",
"resolves_for",
"(",
"self",
",",
"session",
")",
":",
"if",
"self",
".",
"url",
":",
"self",
".",
"actual_path",
"=",
"session",
".",
"current_url",
"else",
":",
"result",
"=",
"urlparse",
"(",
"session",
".",
"current_url",
")",
"if",
"self",
... | Returns whether this query resolves for the given session.
Args:
session (Session): The session for which this query should be executed.
Returns:
bool: Whether this query resolves. | [
"Returns",
"whether",
"this",
"query",
"resolves",
"for",
"the",
"given",
"session",
"."
] | python | test | 30.551724 |
acutesoftware/virtual-AI-simulator | vais/simulator.py | https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/simulator.py#L107-L114 | def _move_agent(self, agent, direction, wrap_allowed=True):
"""
moves agent 'agent' in 'direction'
"""
x,y = agent.coords['x'], agent.coords['y']
print('moving agent ', agent.name, 'to x,y=', direction, 'wrap_allowed = ', wrap_allowed)
agent.coords['x'] = x + direction[0]... | [
"def",
"_move_agent",
"(",
"self",
",",
"agent",
",",
"direction",
",",
"wrap_allowed",
"=",
"True",
")",
":",
"x",
",",
"y",
"=",
"agent",
".",
"coords",
"[",
"'x'",
"]",
",",
"agent",
".",
"coords",
"[",
"'y'",
"]",
"print",
"(",
"'moving agent '",... | moves agent 'agent' in 'direction' | [
"moves",
"agent",
"agent",
"in",
"direction"
] | python | train | 44.75 |
juju/charm-helpers | charmhelpers/contrib/peerstorage/__init__.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/peerstorage/__init__.py#L192-L201 | def peer_store(key, value, relation_name='cluster'):
"""Store the key/value pair on the named peer relation `relation_name`."""
cluster_rels = relation_ids(relation_name)
if len(cluster_rels) > 0:
cluster_rid = cluster_rels[0]
relation_set(relation_id=cluster_rid,
relati... | [
"def",
"peer_store",
"(",
"key",
",",
"value",
",",
"relation_name",
"=",
"'cluster'",
")",
":",
"cluster_rels",
"=",
"relation_ids",
"(",
"relation_name",
")",
"if",
"len",
"(",
"cluster_rels",
")",
">",
"0",
":",
"cluster_rid",
"=",
"cluster_rels",
"[",
... | Store the key/value pair on the named peer relation `relation_name`. | [
"Store",
"the",
"key",
"/",
"value",
"pair",
"on",
"the",
"named",
"peer",
"relation",
"relation_name",
"."
] | python | train | 45.8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.