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 |
|---|---|---|---|---|---|---|---|---|---|
lablup/backend.ai-client-py | src/ai/backend/client/cli/files.py | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/files.py#L17-L35 | def upload(sess_id_or_alias, files):
"""
Upload files to user's home folder.
\b
SESSID: Session ID or its alias given when creating the session.
FILES: Path to upload.
"""
if len(files) < 1:
return
with Session() as session:
try:
print_wait('Uploading files..... | [
"def",
"upload",
"(",
"sess_id_or_alias",
",",
"files",
")",
":",
"if",
"len",
"(",
"files",
")",
"<",
"1",
":",
"return",
"with",
"Session",
"(",
")",
"as",
"session",
":",
"try",
":",
"print_wait",
"(",
"'Uploading files...'",
")",
"kernel",
"=",
"se... | Upload files to user's home folder.
\b
SESSID: Session ID or its alias given when creating the session.
FILES: Path to upload. | [
"Upload",
"files",
"to",
"user",
"s",
"home",
"folder",
"."
] | python | train | 27.894737 |
dshean/pygeotools | pygeotools/lib/geolib.py | https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/geolib.py#L331-L340 | def lon360to180(lon):
"""Convert longitude from (0, 360) to (-180, 180)
"""
if np.any(lon > 360.0) or np.any(lon < 0.0):
print("Warning: lon outside expected range")
lon = wraplon(lon)
#lon[lon > 180.0] -= 360.0
#lon180 = (lon+180) - np.floor((lon+180)/360)*360 - 180
lon = lon - ... | [
"def",
"lon360to180",
"(",
"lon",
")",
":",
"if",
"np",
".",
"any",
"(",
"lon",
">",
"360.0",
")",
"or",
"np",
".",
"any",
"(",
"lon",
"<",
"0.0",
")",
":",
"print",
"(",
"\"Warning: lon outside expected range\"",
")",
"lon",
"=",
"wraplon",
"(",
"lo... | Convert longitude from (0, 360) to (-180, 180) | [
"Convert",
"longitude",
"from",
"(",
"0",
"360",
")",
"to",
"(",
"-",
"180",
"180",
")"
] | python | train | 35.3 |
WebarchivCZ/WA-KAT | src/wa_kat/templates/static/js/Lib/site-packages/components/conspect_handler.py | https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/templates/static/js/Lib/site-packages/components/conspect_handler.py#L212-L224 | def show_error(cls, error=True):
"""
Show `error` around the conspect elements. If the `error` is ``False``,
hide it.
"""
if error:
cls.input_el.style.border = "2px solid red"
cls.conspect_el.style.border = "2px solid red"
cls.subconspect_el.st... | [
"def",
"show_error",
"(",
"cls",
",",
"error",
"=",
"True",
")",
":",
"if",
"error",
":",
"cls",
".",
"input_el",
".",
"style",
".",
"border",
"=",
"\"2px solid red\"",
"cls",
".",
"conspect_el",
".",
"style",
".",
"border",
"=",
"\"2px solid red\"",
"cl... | Show `error` around the conspect elements. If the `error` is ``False``,
hide it. | [
"Show",
"error",
"around",
"the",
"conspect",
"elements",
".",
"If",
"the",
"error",
"is",
"False",
"hide",
"it",
"."
] | python | train | 37.769231 |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L1275-L1288 | def read_stdout(self):
"""
Reads the standard output of the QEMU process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._stdout_file:
try:
with open(self._stdout_file, "rb") as file:
out... | [
"def",
"read_stdout",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"_stdout_file",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_stdout_file",
",",
"\"rb\"",
")",
"as",
"file",
":",
"output",
"=",
"file",
".",
"read",
"(",
... | Reads the standard output of the QEMU process.
Only use when the process has been stopped or has crashed. | [
"Reads",
"the",
"standard",
"output",
"of",
"the",
"QEMU",
"process",
".",
"Only",
"use",
"when",
"the",
"process",
"has",
"been",
"stopped",
"or",
"has",
"crashed",
"."
] | python | train | 35.357143 |
mathiasertl/django-ca | ca/django_ca/models.py | https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/models.py#L272-L274 | def issuer(self):
"""The certificate issuer field as :py:class:`~django_ca.subject.Subject`."""
return Subject([(s.oid, s.value) for s in self.x509.issuer]) | [
"def",
"issuer",
"(",
"self",
")",
":",
"return",
"Subject",
"(",
"[",
"(",
"s",
".",
"oid",
",",
"s",
".",
"value",
")",
"for",
"s",
"in",
"self",
".",
"x509",
".",
"issuer",
"]",
")"
] | The certificate issuer field as :py:class:`~django_ca.subject.Subject`. | [
"The",
"certificate",
"issuer",
"field",
"as",
":",
"py",
":",
"class",
":",
"~django_ca",
".",
"subject",
".",
"Subject",
"."
] | python | train | 56.666667 |
kytos/kytos-utils | kytos/cli/commands/napps/parser.py | https://github.com/kytos/kytos-utils/blob/b4750c618d15cff75970ea6124bda4d2b9a33578/kytos/cli/commands/napps/parser.py#L57-L61 | def call(subcommand, args):
"""Call a subcommand passing the args."""
args['<napp>'] = parse_napps(args['<napp>'])
func = getattr(NAppsAPI, subcommand)
func(args) | [
"def",
"call",
"(",
"subcommand",
",",
"args",
")",
":",
"args",
"[",
"'<napp>'",
"]",
"=",
"parse_napps",
"(",
"args",
"[",
"'<napp>'",
"]",
")",
"func",
"=",
"getattr",
"(",
"NAppsAPI",
",",
"subcommand",
")",
"func",
"(",
"args",
")"
] | Call a subcommand passing the args. | [
"Call",
"a",
"subcommand",
"passing",
"the",
"args",
"."
] | python | train | 34.8 |
SiLab-Bonn/pyBAR | pybar/daq/readout_utils.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L428-L499 | def interpret_pixel_data(data, dc, pixel_array, invert=True):
'''Takes the pixel raw data and interprets them. This includes consistency checks and pixel/data matching.
The data has to come from one double column only but can have more than one pixel bit (e.g. TDAC = 5 bit).
Parameters
----------
... | [
"def",
"interpret_pixel_data",
"(",
"data",
",",
"dc",
",",
"pixel_array",
",",
"invert",
"=",
"True",
")",
":",
"# data validity cut, VR has to follow an AR\r",
"index_value",
"=",
"np",
".",
"where",
"(",
"is_address_record",
"(",
"data",
")",
")",
"[",
"0",
... | Takes the pixel raw data and interprets them. This includes consistency checks and pixel/data matching.
The data has to come from one double column only but can have more than one pixel bit (e.g. TDAC = 5 bit).
Parameters
----------
data : numpy.ndarray
The raw data words.
dc : int
... | [
"Takes",
"the",
"pixel",
"raw",
"data",
"and",
"interprets",
"them",
".",
"This",
"includes",
"consistency",
"checks",
"and",
"pixel",
"/",
"data",
"matching",
".",
"The",
"data",
"has",
"to",
"come",
"from",
"one",
"double",
"column",
"only",
"but",
"can"... | python | train | 51.194444 |
willemarcel/osmcha | osmcha/changeset.py | https://github.com/willemarcel/osmcha/blob/9a22ed11834ed20c6b91e7b5685f66880ea09350/osmcha/changeset.py#L227-L232 | def get_area(self, geojson):
"""Read the first feature from the geojson and return it as a Polygon
object.
"""
geojson = json.load(open(geojson, 'r'))
self.area = Polygon(geojson['features'][0]['geometry']['coordinates'][0]) | [
"def",
"get_area",
"(",
"self",
",",
"geojson",
")",
":",
"geojson",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"geojson",
",",
"'r'",
")",
")",
"self",
".",
"area",
"=",
"Polygon",
"(",
"geojson",
"[",
"'features'",
"]",
"[",
"0",
"]",
"[",
"'g... | Read the first feature from the geojson and return it as a Polygon
object. | [
"Read",
"the",
"first",
"feature",
"from",
"the",
"geojson",
"and",
"return",
"it",
"as",
"a",
"Polygon",
"object",
"."
] | python | valid | 43.166667 |
numenta/nupic | src/nupic/swarming/hypersearch/extended_logger.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/extended_logger.py#L47-L56 | def debug(self, msg, *args, **kwargs):
"""
Log 'msg % args' with severity 'DEBUG'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)
"""
self._baseLogger.debug(self, self.getExtendedM... | [
"def",
"debug",
"(",
"self",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_baseLogger",
".",
"debug",
"(",
"self",
",",
"self",
".",
"getExtendedMsg",
"(",
"msg",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
... | Log 'msg % args' with severity 'DEBUG'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.debug("Houston, we have a %s", "thorny problem", exc_info=1) | [
"Log",
"msg",
"%",
"args",
"with",
"severity",
"DEBUG",
"."
] | python | valid | 33.6 |
scott-griffiths/bitstring | bitstring.py | https://github.com/scott-griffiths/bitstring/blob/ab40ae7f0b43fe223a39b63cbc0529b09f3ef653/bitstring.py#L2183-L2188 | def _ilshift(self, n):
"""Shift bits by n to the left in place. Return self."""
assert 0 < n <= self.len
self._append(Bits(n))
self._truncatestart(n)
return self | [
"def",
"_ilshift",
"(",
"self",
",",
"n",
")",
":",
"assert",
"0",
"<",
"n",
"<=",
"self",
".",
"len",
"self",
".",
"_append",
"(",
"Bits",
"(",
"n",
")",
")",
"self",
".",
"_truncatestart",
"(",
"n",
")",
"return",
"self"
] | Shift bits by n to the left in place. Return self. | [
"Shift",
"bits",
"by",
"n",
"to",
"the",
"left",
"in",
"place",
".",
"Return",
"self",
"."
] | python | train | 32.666667 |
HDI-Project/ballet | ballet/util/fs.py | https://github.com/HDI-Project/ballet/blob/6f4d4b87b8234cb6bb38b9e9484a58ef8fe8fdb2/ballet/util/fs.py#L82-L110 | def synctree(src, dst, onexist=None):
"""Recursively sync files at directory src to dst
This is more or less equivalent to::
cp -n -R ${src}/ ${dst}/
If a file at the same path exists in src and dst, it is NOT overwritten
in dst. Pass ``onexist`` in order to raise an error on such conditions.
... | [
"def",
"synctree",
"(",
"src",
",",
"dst",
",",
"onexist",
"=",
"None",
")",
":",
"src",
"=",
"pathlib",
".",
"Path",
"(",
"src",
")",
".",
"resolve",
"(",
")",
"dst",
"=",
"pathlib",
".",
"Path",
"(",
"dst",
")",
".",
"resolve",
"(",
")",
"if"... | Recursively sync files at directory src to dst
This is more or less equivalent to::
cp -n -R ${src}/ ${dst}/
If a file at the same path exists in src and dst, it is NOT overwritten
in dst. Pass ``onexist`` in order to raise an error on such conditions.
Args:
src (path-like): source di... | [
"Recursively",
"sync",
"files",
"at",
"directory",
"src",
"to",
"dst"
] | python | train | 29.310345 |
elliterate/capybara.py | capybara/__init__.py | https://github.com/elliterate/capybara.py/blob/0c6ae449cc37e4445ec3cd6af95674533beedc6c/capybara/__init__.py#L170-L189 | def current_session():
"""
Returns the :class:`Session` for the current driver and app, instantiating one if needed.
Returns:
Session: The :class:`Session` for the current driver and app.
"""
driver = current_driver or default_driver
session_key = "{driver}:{session}:{app}".format(
... | [
"def",
"current_session",
"(",
")",
":",
"driver",
"=",
"current_driver",
"or",
"default_driver",
"session_key",
"=",
"\"{driver}:{session}:{app}\"",
".",
"format",
"(",
"driver",
"=",
"driver",
",",
"session",
"=",
"session_name",
",",
"app",
"=",
"str",
"(",
... | Returns the :class:`Session` for the current driver and app, instantiating one if needed.
Returns:
Session: The :class:`Session` for the current driver and app. | [
"Returns",
"the",
":",
"class",
":",
"Session",
"for",
"the",
"current",
"driver",
"and",
"app",
"instantiating",
"one",
"if",
"needed",
"."
] | python | test | 29.3 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/preprocessor.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/preprocessor.py#L31-L61 | def merge_includes(code):
"""Merge all includes recursively."""
pattern = '\#\s*include\s*"(?P<filename>[a-zA-Z0-9\_\-\.\/]+)"'
regex = re.compile(pattern)
includes = []
def replace(match):
filename = match.group("filename")
if filename not in includes:
includes.append... | [
"def",
"merge_includes",
"(",
"code",
")",
":",
"pattern",
"=",
"'\\#\\s*include\\s*\"(?P<filename>[a-zA-Z0-9\\_\\-\\.\\/]+)\"'",
"regex",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
"includes",
"=",
"[",
"]",
"def",
"replace",
"(",
"match",
")",
":",
"filen... | Merge all includes recursively. | [
"Merge",
"all",
"includes",
"recursively",
"."
] | python | train | 29.322581 |
juju/python-libjuju | juju/application.py | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/application.py#L104-L131 | async def add_unit(self, count=1, to=None):
"""Add one or more units to this application.
:param int count: Number of units to add
:param str to: Placement directive, e.g.::
'23' - machine 23
'lxc:7' - new lxc container on machine 7
'24/lxc/3' - lxc container... | [
"async",
"def",
"add_unit",
"(",
"self",
",",
"count",
"=",
"1",
",",
"to",
"=",
"None",
")",
":",
"app_facade",
"=",
"client",
".",
"ApplicationFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
")",
"log",
".",
"debug",
"(",
"'Adding %s u... | Add one or more units to this application.
:param int count: Number of units to add
:param str to: Placement directive, e.g.::
'23' - machine 23
'lxc:7' - new lxc container on machine 7
'24/lxc/3' - lxc container 3 or machine 24
If None, a new machine is... | [
"Add",
"one",
"or",
"more",
"units",
"to",
"this",
"application",
"."
] | python | train | 32.642857 |
HEPData/hepdata-validator | hepdata_validator/__init__.py | https://github.com/HEPData/hepdata-validator/blob/d0b0cab742a009c8f0e8aac9f8c8e434a524d43c/hepdata_validator/__init__.py#L88-L96 | def add_validation_message(self, message):
"""
Adds a message to the messages dict
:param message:
"""
if message.file not in self.messages:
self.messages[message.file] = []
self.messages[message.file].append(message) | [
"def",
"add_validation_message",
"(",
"self",
",",
"message",
")",
":",
"if",
"message",
".",
"file",
"not",
"in",
"self",
".",
"messages",
":",
"self",
".",
"messages",
"[",
"message",
".",
"file",
"]",
"=",
"[",
"]",
"self",
".",
"messages",
"[",
"... | Adds a message to the messages dict
:param message: | [
"Adds",
"a",
"message",
"to",
"the",
"messages",
"dict",
":",
"param",
"message",
":"
] | python | train | 30 |
Gandi/gandi.cli | gandi/cli/modules/forward.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/forward.py#L47-L70 | def update(cls, domain, source, dest_add, dest_del):
"""Update a domain mail forward destinations."""
result = None
if dest_add or dest_del:
current_destinations = cls.get_destinations(domain, source)
fwds = current_destinations[:]
if dest_add:
... | [
"def",
"update",
"(",
"cls",
",",
"domain",
",",
"source",
",",
"dest_add",
",",
"dest_del",
")",
":",
"result",
"=",
"None",
"if",
"dest_add",
"or",
"dest_del",
":",
"current_destinations",
"=",
"cls",
".",
"get_destinations",
"(",
"domain",
",",
"source"... | Update a domain mail forward destinations. | [
"Update",
"a",
"domain",
"mail",
"forward",
"destinations",
"."
] | python | train | 38.5 |
tensorflow/mesh | mesh_tensorflow/placement_mesh_impl.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/placement_mesh_impl.py#L185-L202 | def Print(self, x, data, message, **kwargs): # pylint: disable=invalid-name
"""call tf.Print.
Args:
x: a LaidOutTensor
data: a list of LaidOutTensor
message: a string
**kwargs: keyword arguments to tf.print
Returns:
a LaidOutTensor
"""
tf.logging.info("PlacementMeshIm... | [
"def",
"Print",
"(",
"self",
",",
"x",
",",
"data",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=invalid-name",
"tf",
".",
"logging",
".",
"info",
"(",
"\"PlacementMeshImpl::Print\"",
")",
"new_slices",
"=",
"x",
".",
"tensor_list",
... | call tf.Print.
Args:
x: a LaidOutTensor
data: a list of LaidOutTensor
message: a string
**kwargs: keyword arguments to tf.print
Returns:
a LaidOutTensor | [
"call",
"tf",
".",
"Print",
"."
] | python | train | 30.888889 |
jrabbit/hitman | hitman.py | https://github.com/jrabbit/hitman/blob/407351cb729956e2e1673d0aae741e1fa5f61b31/hitman.py#L348-L362 | def directory():
"""Construct hitman_dir from os name"""
home = os.path.expanduser('~')
if platform.system() == 'Linux':
hitman_dir = os.path.join(home, '.hitman')
elif platform.system() == 'Darwin':
hitman_dir = os.path.join(home, 'Library', 'Application Support',
... | [
"def",
"directory",
"(",
")",
":",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Linux'",
":",
"hitman_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"home",
",",
"'.hitman'"... | Construct hitman_dir from os name | [
"Construct",
"hitman_dir",
"from",
"os",
"name"
] | python | train | 39 |
tango-controls/pytango | tango/encoded_attribute.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/encoded_attribute.py#L311-L355 | def __EncodedAttribute_generic_encode_rgb24(self, rgb24, width=0, height=0, quality=0, format=_ImageFormat.RawImage):
"""Internal usage only"""
if not is_seq(rgb24):
raise TypeError("Expected sequence (str, numpy.ndarray, list, tuple "
"or bytearray) as first argument")
is_s... | [
"def",
"__EncodedAttribute_generic_encode_rgb24",
"(",
"self",
",",
"rgb24",
",",
"width",
"=",
"0",
",",
"height",
"=",
"0",
",",
"quality",
"=",
"0",
",",
"format",
"=",
"_ImageFormat",
".",
"RawImage",
")",
":",
"if",
"not",
"is_seq",
"(",
"rgb24",
")... | Internal usage only | [
"Internal",
"usage",
"only"
] | python | train | 43.911111 |
pytroll/satpy | satpy/readers/utils.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/utils.py#L105-L124 | def _lonlat_from_geos_angle(x, y, geos_area):
"""Get lons and lats from x, y in projection coordinates."""
h = (geos_area.proj_dict['h'] + geos_area.proj_dict['a']) / 1000
b__ = (geos_area.proj_dict['a'] / geos_area.proj_dict['b']) ** 2
sd = np.sqrt((h * np.cos(x) * np.cos(y)) ** 2 -
(... | [
"def",
"_lonlat_from_geos_angle",
"(",
"x",
",",
"y",
",",
"geos_area",
")",
":",
"h",
"=",
"(",
"geos_area",
".",
"proj_dict",
"[",
"'h'",
"]",
"+",
"geos_area",
".",
"proj_dict",
"[",
"'a'",
"]",
")",
"/",
"1000",
"b__",
"=",
"(",
"geos_area",
".",... | Get lons and lats from x, y in projection coordinates. | [
"Get",
"lons",
"and",
"lats",
"from",
"x",
"y",
"in",
"projection",
"coordinates",
"."
] | python | train | 39.15 |
instaloader/instaloader | instaloader/instaloadercontext.py | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L268-L276 | def _dump_query_timestamps(self, current_time: float):
"""Output the number of GraphQL queries grouped by their query_hash within the last time."""
windows = [10, 11, 15, 20, 30, 60]
print("GraphQL requests:", file=sys.stderr)
for query_hash, times in self._graphql_query_timestamps.items... | [
"def",
"_dump_query_timestamps",
"(",
"self",
",",
"current_time",
":",
"float",
")",
":",
"windows",
"=",
"[",
"10",
",",
"11",
",",
"15",
",",
"20",
",",
"30",
",",
"60",
"]",
"print",
"(",
"\"GraphQL requests:\"",
",",
"file",
"=",
"sys",
".",
"st... | Output the number of GraphQL queries grouped by their query_hash within the last time. | [
"Output",
"the",
"number",
"of",
"GraphQL",
"queries",
"grouped",
"by",
"their",
"query_hash",
"within",
"the",
"last",
"time",
"."
] | python | train | 68.666667 |
CityOfZion/neo-python-core | neocore/Cryptography/ECCurve.py | https://github.com/CityOfZion/neo-python-core/blob/786c02cc2f41712d70b1f064ae3d67f86167107f/neocore/Cryptography/ECCurve.py#L864-L870 | def secp256k1():
"""
create the secp256k1 curve
"""
GFp = FiniteField(2 ** 256 - 2 ** 32 - 977) # This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
ec = EllipticCurve(GFp, 0, 7)
return ECDSA(ec, ec.point(0x79BE667EF9DCBBAC55A062... | [
"def",
"secp256k1",
"(",
")",
":",
"GFp",
"=",
"FiniteField",
"(",
"2",
"**",
"256",
"-",
"2",
"**",
"32",
"-",
"977",
")",
"# This is P from below... aka FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F",
"ec",
"=",
"EllipticCurve",
"(",
"GFp",
",",... | create the secp256k1 curve | [
"create",
"the",
"secp256k1",
"curve"
] | python | train | 68.285714 |
gnosis/gnosis-py | gnosis/safe/safe_service.py | https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L575-L588 | def estimate_tx_operational_gas(self, safe_address: str, data_bytes_length: int):
"""
Estimates the gas for the verification of the signatures and other safe related tasks
before and after executing a transaction.
Calculation will be the sum of:
- Base cost of 15000 gas
... | [
"def",
"estimate_tx_operational_gas",
"(",
"self",
",",
"safe_address",
":",
"str",
",",
"data_bytes_length",
":",
"int",
")",
":",
"threshold",
"=",
"self",
".",
"retrieve_threshold",
"(",
"safe_address",
")",
"return",
"15000",
"+",
"data_bytes_length",
"//",
... | Estimates the gas for the verification of the signatures and other safe related tasks
before and after executing a transaction.
Calculation will be the sum of:
- Base cost of 15000 gas
- 100 of gas per word of `data_bytes`
- Validate the signatures 5000 * threshold (ecrecov... | [
"Estimates",
"the",
"gas",
"for",
"the",
"verification",
"of",
"the",
"signatures",
"and",
"other",
"safe",
"related",
"tasks",
"before",
"and",
"after",
"executing",
"a",
"transaction",
".",
"Calculation",
"will",
"be",
"the",
"sum",
"of",
":",
"-",
"Base",... | python | test | 56.285714 |
theolind/pymysensors | mysensors/gateway_mqtt.py | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L34-L49 | def _handle_subscription(self, topics):
"""Handle subscription of topics."""
if not isinstance(topics, list):
topics = [topics]
for topic in topics:
topic_levels = topic.split('/')
try:
qos = int(topic_levels[-2])
except ValueError:... | [
"def",
"_handle_subscription",
"(",
"self",
",",
"topics",
")",
":",
"if",
"not",
"isinstance",
"(",
"topics",
",",
"list",
")",
":",
"topics",
"=",
"[",
"topics",
"]",
"for",
"topic",
"in",
"topics",
":",
"topic_levels",
"=",
"topic",
".",
"split",
"(... | Handle subscription of topics. | [
"Handle",
"subscription",
"of",
"topics",
"."
] | python | train | 40.9375 |
SmokinCaterpillar/pypet | examples/example_24_large_scale_brian2_simulation/clusternet.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/examples/example_24_large_scale_brian2_simulation/clusternet.py#L287-L325 | def pre_build(self, traj, brian_list, network_dict):
"""Pre-builds the connections.
Pre-build is only performed if none of the
relevant parameters is explored and the relevant neuron groups
exist.
:param traj: Trajectory container
:param brian_list:
List o... | [
"def",
"pre_build",
"(",
"self",
",",
"traj",
",",
"brian_list",
",",
"network_dict",
")",
":",
"self",
".",
"_pre_build",
"=",
"not",
"_explored_parameters_in_group",
"(",
"traj",
",",
"traj",
".",
"parameters",
".",
"connections",
")",
"self",
".",
"_pre_b... | Pre-builds the connections.
Pre-build is only performed if none of the
relevant parameters is explored and the relevant neuron groups
exist.
:param traj: Trajectory container
:param brian_list:
List of objects passed to BRIAN network constructor.
Adds... | [
"Pre",
"-",
"builds",
"the",
"connections",
"."
] | python | test | 26.487179 |
mitsei/dlkit | dlkit/json_/resource/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/objects.py#L185-L190 | def _init_map(self, record_types=None, **kwargs):
"""Initialize form map"""
osid_objects.OsidObjectForm._init_map(self, record_types=record_types)
self._my_map['assignedBinIds'] = [str(kwargs['bin_id'])]
self._my_map['group'] = self._group_default
self._my_map['avatarId'] = self.... | [
"def",
"_init_map",
"(",
"self",
",",
"record_types",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"osid_objects",
".",
"OsidObjectForm",
".",
"_init_map",
"(",
"self",
",",
"record_types",
"=",
"record_types",
")",
"self",
".",
"_my_map",
"[",
"'assign... | Initialize form map | [
"Initialize",
"form",
"map"
] | python | train | 55 |
widdowquinn/pyani | pyani/pyani_tools.py | https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L33-L37 | def add_tot_length(self, qname, sname, value, sym=True):
"""Add a total length value to self.alignment_lengths."""
self.alignment_lengths.loc[qname, sname] = value
if sym:
self.alignment_lengths.loc[sname, qname] = value | [
"def",
"add_tot_length",
"(",
"self",
",",
"qname",
",",
"sname",
",",
"value",
",",
"sym",
"=",
"True",
")",
":",
"self",
".",
"alignment_lengths",
".",
"loc",
"[",
"qname",
",",
"sname",
"]",
"=",
"value",
"if",
"sym",
":",
"self",
".",
"alignment_... | Add a total length value to self.alignment_lengths. | [
"Add",
"a",
"total",
"length",
"value",
"to",
"self",
".",
"alignment_lengths",
"."
] | python | train | 50.4 |
GNS3/gns3-server | gns3server/compute/docker/__init__.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L117-L167 | def http_query(self, method, path, data={}, params={}, timeout=300):
"""
Make a query to the docker daemon
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionnary with the body. Will be transformed to a JSON
:param params: Parameters added as a q... | [
"def",
"http_query",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
"=",
"{",
"}",
",",
"params",
"=",
"{",
"}",
",",
"timeout",
"=",
"300",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"if",
"timeout",
"is",
"None",
":... | Make a query to the docker daemon
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionnary with the body. Will be transformed to a JSON
:param params: Parameters added as a query arg
:param timeout: Timeout
:returns: HTTP response | [
"Make",
"a",
"query",
"to",
"the",
"docker",
"daemon"
] | python | train | 45.098039 |
KelSolaar/Umbra | umbra/components/factory/script_editor/script_editor.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/factory/script_editor/script_editor.py#L3099-L3114 | def get_editorTab(self, editor):
"""
Returns the **Script_Editor_tabWidget** Widget tab associated with the given editor.
:param editor: Editor to search tab for.
:type editor: Editor
:return: Tab index.
:rtype: Editor
"""
for i in range(self.Script_Edit... | [
"def",
"get_editorTab",
"(",
"self",
",",
"editor",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"Script_Editor_tabWidget",
".",
"count",
"(",
")",
")",
":",
"if",
"not",
"self",
".",
"get_widget",
"(",
"i",
")",
"==",
"editor",
":",
"conti... | Returns the **Script_Editor_tabWidget** Widget tab associated with the given editor.
:param editor: Editor to search tab for.
:type editor: Editor
:return: Tab index.
:rtype: Editor | [
"Returns",
"the",
"**",
"Script_Editor_tabWidget",
"**",
"Widget",
"tab",
"associated",
"with",
"the",
"given",
"editor",
"."
] | python | train | 31.375 |
joelfrederico/SciSalt | scisalt/numpy/functions.py | https://github.com/joelfrederico/SciSalt/blob/7bf57c49c7dde0a8b0aa337fbd2fbd527ce7a67f/scisalt/numpy/functions.py#L7-L22 | def gaussian(x, mu, sigma):
"""
Gaussian function of the form :math:`\\frac{1}{\\sqrt{2 \\pi}\\sigma} e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}`.
.. versionadded:: 1.5
Parameters
----------
x : float
Function variable :math:`x`.
mu : float
Mean of the Gaussian function.
sigma... | [
"def",
"gaussian",
"(",
"x",
",",
"mu",
",",
"sigma",
")",
":",
"return",
"_np",
".",
"exp",
"(",
"-",
"(",
"x",
"-",
"mu",
")",
"**",
"2",
"/",
"(",
"2",
"*",
"sigma",
"**",
"2",
")",
")",
"/",
"(",
"_np",
".",
"sqrt",
"(",
"2",
"*",
"... | Gaussian function of the form :math:`\\frac{1}{\\sqrt{2 \\pi}\\sigma} e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}`.
.. versionadded:: 1.5
Parameters
----------
x : float
Function variable :math:`x`.
mu : float
Mean of the Gaussian function.
sigma : float
Standard deviation of t... | [
"Gaussian",
"function",
"of",
"the",
"form",
":",
"math",
":",
"\\\\",
"frac",
"{",
"1",
"}",
"{",
"\\\\",
"sqrt",
"{",
"2",
"\\\\",
"pi",
"}",
"\\\\",
"sigma",
"}",
"e^",
"{",
"-",
"\\\\",
"frac",
"{",
"(",
"x",
"-",
"\\\\",
"mu",
")",
"^2",
... | python | valid | 28.0625 |
tensorflow/probability | tensorflow_probability/python/distributions/lkj.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/lkj.py#L59-L63 | def _replicate(n, tensor):
"""Replicate the input tensor n times along a new (major) dimension."""
# TODO(axch) Does this already exist somewhere? Should it get contributed?
multiples = tf.concat([[n], tf.ones_like(tensor.shape)], axis=0)
return tf.tile(tf.expand_dims(tensor, axis=0), multiples) | [
"def",
"_replicate",
"(",
"n",
",",
"tensor",
")",
":",
"# TODO(axch) Does this already exist somewhere? Should it get contributed?",
"multiples",
"=",
"tf",
".",
"concat",
"(",
"[",
"[",
"n",
"]",
",",
"tf",
".",
"ones_like",
"(",
"tensor",
".",
"shape",
")",
... | Replicate the input tensor n times along a new (major) dimension. | [
"Replicate",
"the",
"input",
"tensor",
"n",
"times",
"along",
"a",
"new",
"(",
"major",
")",
"dimension",
"."
] | python | test | 60.2 |
facelessuser/pyspelling | pyspelling/filters/ooxml.py | https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/ooxml.py#L93-L114 | def determine_file_type(self, z):
"""Determine file type."""
content = z.read('[Content_Types].xml')
with io.BytesIO(content) as b:
encoding = self._analyze_file(b)
if encoding is None:
encoding = 'utf-8'
b.seek(0)
text = b.read().... | [
"def",
"determine_file_type",
"(",
"self",
",",
"z",
")",
":",
"content",
"=",
"z",
".",
"read",
"(",
"'[Content_Types].xml'",
")",
"with",
"io",
".",
"BytesIO",
"(",
"content",
")",
"as",
"b",
":",
"encoding",
"=",
"self",
".",
"_analyze_file",
"(",
"... | Determine file type. | [
"Determine",
"file",
"type",
"."
] | python | train | 41.818182 |
philipsoutham/py-mysql2pgsql | mysql2pgsql/lib/postgres_db_writer.py | https://github.com/philipsoutham/py-mysql2pgsql/blob/66dc2a3a3119263b3fe77300fb636346509787ef/mysql2pgsql/lib/postgres_db_writer.py#L144-L154 | def write_table(self, table):
"""Send DDL to create the specified `table`
:Parameters:
- `table`: an instance of a :py:class:`mysql2pgsql.lib.mysql_reader.MysqlReader.Table` object that represents the table to read/write.
Returns None
"""
table_sql, serial_key_sql = s... | [
"def",
"write_table",
"(",
"self",
",",
"table",
")",
":",
"table_sql",
",",
"serial_key_sql",
"=",
"super",
"(",
"PostgresDbWriter",
",",
"self",
")",
".",
"write_table",
"(",
"table",
")",
"for",
"sql",
"in",
"serial_key_sql",
"+",
"table_sql",
":",
"sel... | Send DDL to create the specified `table`
:Parameters:
- `table`: an instance of a :py:class:`mysql2pgsql.lib.mysql_reader.MysqlReader.Table` object that represents the table to read/write.
Returns None | [
"Send",
"DDL",
"to",
"create",
"the",
"specified",
"table"
] | python | test | 39.454545 |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L485-L492 | def render_pull_base_image(self):
"""Configure pull_base_image"""
phase = 'prebuild_plugins'
plugin = 'pull_base_image'
if self.user_params.parent_images_digests.value:
self.pt.set_plugin_arg(phase, plugin, 'parent_images_digests',
self.use... | [
"def",
"render_pull_base_image",
"(",
"self",
")",
":",
"phase",
"=",
"'prebuild_plugins'",
"plugin",
"=",
"'pull_base_image'",
"if",
"self",
".",
"user_params",
".",
"parent_images_digests",
".",
"value",
":",
"self",
".",
"pt",
".",
"set_plugin_arg",
"(",
"pha... | Configure pull_base_image | [
"Configure",
"pull_base_image"
] | python | train | 43.75 |
HIPS/autograd | examples/data.py | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/data.py#L53-L67 | def make_pinwheel(radial_std, tangential_std, num_classes, num_per_class, rate,
rs=npr.RandomState(0)):
"""Based on code by Ryan P. Adams."""
rads = np.linspace(0, 2*np.pi, num_classes, endpoint=False)
features = rs.randn(num_classes*num_per_class, 2) \
* np.array([radial_std, tan... | [
"def",
"make_pinwheel",
"(",
"radial_std",
",",
"tangential_std",
",",
"num_classes",
",",
"num_per_class",
",",
"rate",
",",
"rs",
"=",
"npr",
".",
"RandomState",
"(",
"0",
")",
")",
":",
"rads",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
... | Based on code by Ryan P. Adams. | [
"Based",
"on",
"code",
"by",
"Ryan",
"P",
".",
"Adams",
"."
] | python | train | 44.266667 |
Unity-Technologies/ml-agents | ml-agents/mlagents/trainers/barracuda.py | https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/barracuda.py#L63-L73 | def fuse_batchnorm_weights(gamma, beta, mean, var, epsilon):
# https://github.com/Tencent/ncnn/blob/master/src/layer/batchnorm.cpp
""" float sqrt_var = sqrt(var_data[i]);
a_data[i] = bias_data[i] - slope_data[i] * mean_data[i] / sqrt_var;
b_data[i] = slope_data[i] / sqrt_var;
...
... | [
"def",
"fuse_batchnorm_weights",
"(",
"gamma",
",",
"beta",
",",
"mean",
",",
"var",
",",
"epsilon",
")",
":",
"# https://github.com/Tencent/ncnn/blob/master/src/layer/batchnorm.cpp",
"scale",
"=",
"gamma",
"/",
"np",
".",
"sqrt",
"(",
"var",
"+",
"epsilon",
")",
... | float sqrt_var = sqrt(var_data[i]);
a_data[i] = bias_data[i] - slope_data[i] * mean_data[i] / sqrt_var;
b_data[i] = slope_data[i] / sqrt_var;
...
ptr[i] = b * ptr[i] + a; | [
"float",
"sqrt_var",
"=",
"sqrt",
"(",
"var_data",
"[",
"i",
"]",
")",
";",
"a_data",
"[",
"i",
"]",
"=",
"bias_data",
"[",
"i",
"]",
"-",
"slope_data",
"[",
"i",
"]",
"*",
"mean_data",
"[",
"i",
"]",
"/",
"sqrt_var",
";",
"b_data",
"[",
"i",
"... | python | train | 42.454545 |
mcrute/pydora | pydora/utils.py | https://github.com/mcrute/pydora/blob/d9e353e7f19da741dcf372246b4d5640cb788488/pydora/utils.py#L178-L192 | def iterate_forever(func, *args, **kwargs):
"""Iterate over a finite iterator forever
When the iterator is exhausted will call the function again to generate a
new iterator and keep iterating.
"""
output = func(*args, **kwargs)
while True:
try:
playlist_item = next(output)
... | [
"def",
"iterate_forever",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"while",
"True",
":",
"try",
":",
"playlist_item",
"=",
"next",
"(",
"output",
")",
... | Iterate over a finite iterator forever
When the iterator is exhausted will call the function again to generate a
new iterator and keep iterating. | [
"Iterate",
"over",
"a",
"finite",
"iterator",
"forever"
] | python | valid | 30.333333 |
miguelgrinberg/Flask-SocketIO | flask_socketio/namespace.py | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/namespace.py#L28-L34 | def emit(self, event, data=None, room=None, include_self=True,
namespace=None, callback=None):
"""Emit a custom event to one or more connected clients."""
return self.socketio.emit(event, data, room=room,
include_self=include_self,
... | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"data",
"=",
"None",
",",
"room",
"=",
"None",
",",
"include_self",
"=",
"True",
",",
"namespace",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"socketio",
".",
"emit",
"... | Emit a custom event to one or more connected clients. | [
"Emit",
"a",
"custom",
"event",
"to",
"one",
"or",
"more",
"connected",
"clients",
"."
] | python | train | 59.142857 |
thumbor-community/redis | tc_redis/storages/redis_storage.py | https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/storages/redis_storage.py#L28-L38 | def get_storage(self):
'''Get the storage instance.
:return Redis: Redis instance
'''
if self.storage:
return self.storage
self.storage = self.reconnect_redis()
return self.storage | [
"def",
"get_storage",
"(",
"self",
")",
":",
"if",
"self",
".",
"storage",
":",
"return",
"self",
".",
"storage",
"self",
".",
"storage",
"=",
"self",
".",
"reconnect_redis",
"(",
")",
"return",
"self",
".",
"storage"
] | Get the storage instance.
:return Redis: Redis instance | [
"Get",
"the",
"storage",
"instance",
"."
] | python | train | 21.181818 |
librosa/librosa | librosa/display.py | https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/display.py#L352-L354 | def __envelope(x, hop):
'''Compute the max-envelope of x at a stride/frame length of h'''
return util.frame(x, hop_length=hop, frame_length=hop).max(axis=0) | [
"def",
"__envelope",
"(",
"x",
",",
"hop",
")",
":",
"return",
"util",
".",
"frame",
"(",
"x",
",",
"hop_length",
"=",
"hop",
",",
"frame_length",
"=",
"hop",
")",
".",
"max",
"(",
"axis",
"=",
"0",
")"
] | Compute the max-envelope of x at a stride/frame length of h | [
"Compute",
"the",
"max",
"-",
"envelope",
"of",
"x",
"at",
"a",
"stride",
"/",
"frame",
"length",
"of",
"h"
] | python | test | 54 |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L4211-L4232 | def CSS_setMediaText(self, styleSheetId, range, text):
"""
Function path: CSS.setMediaText
Domain: CSS
Method name: setMediaText
Parameters:
Required arguments:
'styleSheetId' (type: StyleSheetId) -> No description
'range' (type: SourceRange) -> No description
'text' (type: string) ->... | [
"def",
"CSS_setMediaText",
"(",
"self",
",",
"styleSheetId",
",",
"range",
",",
"text",
")",
":",
"assert",
"isinstance",
"(",
"text",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'text' must be of type '['str']'. Received type: '%s'\"",
"%",
"type",
"(",
"t... | Function path: CSS.setMediaText
Domain: CSS
Method name: setMediaText
Parameters:
Required arguments:
'styleSheetId' (type: StyleSheetId) -> No description
'range' (type: SourceRange) -> No description
'text' (type: string) -> No description
Returns:
'media' (type: CSSMedia) -> The... | [
"Function",
"path",
":",
"CSS",
".",
"setMediaText",
"Domain",
":",
"CSS",
"Method",
"name",
":",
"setMediaText",
"Parameters",
":",
"Required",
"arguments",
":",
"styleSheetId",
"(",
"type",
":",
"StyleSheetId",
")",
"-",
">",
"No",
"description",
"range",
... | python | train | 33.136364 |
apache/incubator-mxnet | example/cnn_text_classification/data_helpers.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L153-L165 | def batch_iter(data, batch_size, num_epochs):
"""Generates a batch iterator for a dataset."""
data = np.array(data)
data_size = len(data)
num_batches_per_epoch = int(len(data)/batch_size) + 1
for epoch in range(num_epochs):
# Shuffle the data at each epoch
shuffle_indices = np.random... | [
"def",
"batch_iter",
"(",
"data",
",",
"batch_size",
",",
"num_epochs",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
")",
"data_size",
"=",
"len",
"(",
"data",
")",
"num_batches_per_epoch",
"=",
"int",
"(",
"len",
"(",
"data",
")",
"/",
"b... | Generates a batch iterator for a dataset. | [
"Generates",
"a",
"batch",
"iterator",
"for",
"a",
"dataset",
"."
] | python | train | 47.384615 |
Qiskit/qiskit-terra | qiskit/pulse/ops.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/pulse/ops.py#L54-L64 | def shift(schedule: ScheduleComponent, time: int, name: str = None) -> Schedule:
"""Return schedule shifted by `time`.
Args:
schedule: The schedule to shift
time: The time to shift by
name: Name of shifted schedule. Defaults to name of `schedule`
"""
if name is None:
nam... | [
"def",
"shift",
"(",
"schedule",
":",
"ScheduleComponent",
",",
"time",
":",
"int",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Schedule",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"schedule",
".",
"name",
"return",
"union",
"(",
"(",
... | Return schedule shifted by `time`.
Args:
schedule: The schedule to shift
time: The time to shift by
name: Name of shifted schedule. Defaults to name of `schedule` | [
"Return",
"schedule",
"shifted",
"by",
"time",
"."
] | python | test | 33.909091 |
saltstack/salt | salt/modules/vsphere.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L4164-L4198 | def _get_dvportgroup_dict(pg_ref):
'''
Returns a dictionary with a distributed virutal portgroup data
pg_ref
Portgroup reference
'''
props = salt.utils.vmware.get_properties_of_managed_object(
pg_ref, ['name', 'config.description', 'config.numPorts',
'config.type',... | [
"def",
"_get_dvportgroup_dict",
"(",
"pg_ref",
")",
":",
"props",
"=",
"salt",
".",
"utils",
".",
"vmware",
".",
"get_properties_of_managed_object",
"(",
"pg_ref",
",",
"[",
"'name'",
",",
"'config.description'",
",",
"'config.numPorts'",
",",
"'config.type'",
","... | Returns a dictionary with a distributed virutal portgroup data
pg_ref
Portgroup reference | [
"Returns",
"a",
"dictionary",
"with",
"a",
"distributed",
"virutal",
"portgroup",
"data"
] | python | train | 40.342857 |
PyCQA/pylint | pylint/checkers/design_analysis.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L299-L304 | def open(self):
"""initialize visit variables"""
self.stats = self.linter.add_stats()
self._returns = []
self._branches = defaultdict(int)
self._stmts = [] | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"stats",
"=",
"self",
".",
"linter",
".",
"add_stats",
"(",
")",
"self",
".",
"_returns",
"=",
"[",
"]",
"self",
".",
"_branches",
"=",
"defaultdict",
"(",
"int",
")",
"self",
".",
"_stmts",
"=",
... | initialize visit variables | [
"initialize",
"visit",
"variables"
] | python | test | 31.666667 |
BlackEarth/bl | bl/zip.py | https://github.com/BlackEarth/bl/blob/edf6f37dac718987260b90ad0e7f7fe084a7c1a3/bl/zip.py#L20-L30 | def write(self, fn=None):
"""copy the zip file from its filename to the given filename."""
fn = fn or self.fn
if not os.path.exists(os.path.dirname(fn)):
os.makedirs(os.path.dirname(fn))
f = open(self.fn, 'rb')
b = f.read()
f.close()
f = open(fn, 'wb')... | [
"def",
"write",
"(",
"self",
",",
"fn",
"=",
"None",
")",
":",
"fn",
"=",
"fn",
"or",
"self",
".",
"fn",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"fn",
")",
")",
":",
"os",
".",
"makedirs",
... | copy the zip file from its filename to the given filename. | [
"copy",
"the",
"zip",
"file",
"from",
"its",
"filename",
"to",
"the",
"given",
"filename",
"."
] | python | train | 31.545455 |
EconForge/dolo | dolo/numeric/extern/qz.py | https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/extern/qz.py#L6-L18 | def qzordered(A,B,crit=1.0):
"Eigenvalues bigger than crit are sorted in the top-left."
TOL = 1e-10
def select(alpha, beta):
return alpha**2>crit*beta**2
[S,T,alpha,beta,U,V] = ordqz(A,B,output='real',sort=select)
eigval = abs(numpy.diag(S)/numpy.diag(T))
return [S,T,U,V,eigval] | [
"def",
"qzordered",
"(",
"A",
",",
"B",
",",
"crit",
"=",
"1.0",
")",
":",
"TOL",
"=",
"1e-10",
"def",
"select",
"(",
"alpha",
",",
"beta",
")",
":",
"return",
"alpha",
"**",
"2",
">",
"crit",
"*",
"beta",
"**",
"2",
"[",
"S",
",",
"T",
",",
... | Eigenvalues bigger than crit are sorted in the top-left. | [
"Eigenvalues",
"bigger",
"than",
"crit",
"are",
"sorted",
"in",
"the",
"top",
"-",
"left",
"."
] | python | train | 23.384615 |
tensorflow/cleverhans | cleverhans/utils_tf.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils_tf.py#L526-L531 | def get_available_gpus():
"""
Returns a list of string names of all available GPUs
"""
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU'] | [
"def",
"get_available_gpus",
"(",
")",
":",
"local_device_protos",
"=",
"device_lib",
".",
"list_local_devices",
"(",
")",
"return",
"[",
"x",
".",
"name",
"for",
"x",
"in",
"local_device_protos",
"if",
"x",
".",
"device_type",
"==",
"'GPU'",
"]"
] | Returns a list of string names of all available GPUs | [
"Returns",
"a",
"list",
"of",
"string",
"names",
"of",
"all",
"available",
"GPUs"
] | python | train | 36 |
Chilipp/model-organization | model_organization/config.py | https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/config.py#L45-L83 | def get_configdir(name):
"""
Return the string representing the configuration directory.
The directory is chosen as follows:
1. If the ``name.upper() + CONFIGDIR`` environment variable is supplied,
choose that.
2a. On Linux, choose `$HOME/.config`.
2b. On other platforms, choose `$HOM... | [
"def",
"get_configdir",
"(",
"name",
")",
":",
"configdir",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'%sCONFIGDIR'",
"%",
"name",
".",
"upper",
"(",
")",
")",
"if",
"configdir",
"is",
"not",
"None",
":",
"return",
"os",
".",
"path",
".",
"abspath... | Return the string representing the configuration directory.
The directory is chosen as follows:
1. If the ``name.upper() + CONFIGDIR`` environment variable is supplied,
choose that.
2a. On Linux, choose `$HOME/.config`.
2b. On other platforms, choose `$HOME/.matplotlib`.
3. If the chosen... | [
"Return",
"the",
"string",
"representing",
"the",
"configuration",
"directory",
"."
] | python | train | 26.179487 |
materials-data-facility/toolbox | mdf_toolbox/search_helper.py | https://github.com/materials-data-facility/toolbox/blob/2a4ac2b6a892238263008efa6a5f3923d9a83505/mdf_toolbox/search_helper.py#L606-L645 | def exclude_range(self, field, start="*", stop="*", inclusive=True, new_group=False):
"""Exclude a ``field:[some range]`` term from the query.
Matches will not have any ``value`` in the range in the ``field``.
Arguments:
field (str): The field to check for the value.
... | [
"def",
"exclude_range",
"(",
"self",
",",
"field",
",",
"start",
"=",
"\"*\"",
",",
"stop",
"=",
"\"*\"",
",",
"inclusive",
"=",
"True",
",",
"new_group",
"=",
"False",
")",
":",
"# Accept None as *",
"if",
"start",
"is",
"None",
":",
"start",
"=",
"\"... | Exclude a ``field:[some range]`` term from the query.
Matches will not have any ``value`` in the range in the ``field``.
Arguments:
field (str): The field to check for the value.
The field must be namespaced according to Elasticsearch rules
using the ... | [
"Exclude",
"a",
"field",
":",
"[",
"some",
"range",
"]",
"term",
"from",
"the",
"query",
".",
"Matches",
"will",
"not",
"have",
"any",
"value",
"in",
"the",
"range",
"in",
"the",
"field",
"."
] | python | train | 45.9 |
gem/oq-engine | openquake/hmtk/faults/fault_models.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/faults/fault_models.py#L509-L557 | def generate_fault_source_model(self):
'''
Creates a resulting `openquake.hmtk` fault source set.
:returns:
source_model - list of instances of either the :class:
`openquake.hmtk.sources.simple_fault_source.mtkSimpleFaultSource`
or :class:
`openqu... | [
"def",
"generate_fault_source_model",
"(",
"self",
")",
":",
"source_model",
"=",
"[",
"]",
"model_weight",
"=",
"[",
"]",
"for",
"iloc",
"in",
"range",
"(",
"0",
",",
"self",
".",
"get_number_mfd_models",
"(",
")",
")",
":",
"model_mfd",
"=",
"EvenlyDiscr... | Creates a resulting `openquake.hmtk` fault source set.
:returns:
source_model - list of instances of either the :class:
`openquake.hmtk.sources.simple_fault_source.mtkSimpleFaultSource`
or :class:
`openquake.hmtk.sources.complex_fault_source.mtkComplexFaultSource... | [
"Creates",
"a",
"resulting",
"openquake",
".",
"hmtk",
"fault",
"source",
"set",
"."
] | python | train | 38.918367 |
ioos/compliance-checker | compliance_checker/cf/cf.py | https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cf/cf.py#L1442-L1478 | def _check_flag_meanings(self, ds, name):
'''
Check a variable's flag_meanings attribute for compliance under CF
- flag_meanings exists
- flag_meanings is a string
- flag_meanings elements are valid strings
:param netCDF4.Dataset ds: An open netCDF dataset
:para... | [
"def",
"_check_flag_meanings",
"(",
"self",
",",
"ds",
",",
"name",
")",
":",
"variable",
"=",
"ds",
".",
"variables",
"[",
"name",
"]",
"flag_meanings",
"=",
"getattr",
"(",
"variable",
",",
"'flag_meanings'",
",",
"None",
")",
"valid_meanings",
"=",
"Tes... | Check a variable's flag_meanings attribute for compliance under CF
- flag_meanings exists
- flag_meanings is a string
- flag_meanings elements are valid strings
:param netCDF4.Dataset ds: An open netCDF dataset
:param str name: Variable name
:rtype: compliance_checker.b... | [
"Check",
"a",
"variable",
"s",
"flag_meanings",
"attribute",
"for",
"compliance",
"under",
"CF"
] | python | train | 45.189189 |
CalebBell/ht | ht/boiling_nucleic.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/boiling_nucleic.py#L340-L494 | def Stephan_Abdelsalam(rhol, rhog, mul, kl, Cpl, Hvap, sigma, Tsat, Te=None,
q=None, kw=401, rhow=8.96, Cpw=384, angle=None,
correlation='general'):
r'''Calculates heat transfer coefficient for a evaporator operating
in the nucleate boiling regime according to [2]... | [
"def",
"Stephan_Abdelsalam",
"(",
"rhol",
",",
"rhog",
",",
"mul",
",",
"kl",
",",
"Cpl",
",",
"Hvap",
",",
"sigma",
",",
"Tsat",
",",
"Te",
"=",
"None",
",",
"q",
"=",
"None",
",",
"kw",
"=",
"401",
",",
"rhow",
"=",
"8.96",
",",
"Cpw",
"=",
... | r'''Calculates heat transfer coefficient for a evaporator operating
in the nucleate boiling regime according to [2]_ as presented in [1]_.
Five variants are possible.
Either heat flux or excess temperature is required. The forms for `Te` are
not shown here, but are similar to those of the other functio... | [
"r",
"Calculates",
"heat",
"transfer",
"coefficient",
"for",
"a",
"evaporator",
"operating",
"in",
"the",
"nucleate",
"boiling",
"regime",
"according",
"to",
"[",
"2",
"]",
"_",
"as",
"presented",
"in",
"[",
"1",
"]",
"_",
".",
"Five",
"variants",
"are",
... | python | train | 33.935484 |
openstack/horizon | horizon/workflows/views.py | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L121-L127 | def get_template_names(self):
"""Returns the template name to use for this request."""
if self.request.is_ajax():
template = self.ajax_template_name
else:
template = self.template_name
return template | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":",
"template",
"=",
"self",
".",
"ajax_template_name",
"else",
":",
"template",
"=",
"self",
".",
"template_name",
"return",
"template"
] | Returns the template name to use for this request. | [
"Returns",
"the",
"template",
"name",
"to",
"use",
"for",
"this",
"request",
"."
] | python | train | 35.714286 |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L155-L177 | def rhsm_register(self, rhsm):
"""Register the host on the RHSM.
:param rhsm: a dict of parameters (login, password, pool_id)
"""
# Get rhsm credentials
login = rhsm.get('login')
password = rhsm.get('password', os.environ.get('RHN_PW'))
pool_id = rhsm.get('pool_i... | [
"def",
"rhsm_register",
"(",
"self",
",",
"rhsm",
")",
":",
"# Get rhsm credentials",
"login",
"=",
"rhsm",
".",
"get",
"(",
"'login'",
")",
"password",
"=",
"rhsm",
".",
"get",
"(",
"'password'",
",",
"os",
".",
"environ",
".",
"get",
"(",
"'RHN_PW'",
... | Register the host on the RHSM.
:param rhsm: a dict of parameters (login, password, pool_id) | [
"Register",
"the",
"host",
"on",
"the",
"RHSM",
"."
] | python | train | 40.521739 |
tgbugs/pyontutils | ilxutils/ilxutils/mydifflib.py | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/mydifflib.py#L7-L24 | def diff(s1, s2):
''' --word-diff=porcelain clone'''
delta = difflib.Differ().compare(s1.split(), s2.split())
difflist = []
fullline = ''
for line in delta:
if line[0] == '?':
continue
elif line[0] == ' ':
fullline += line.strip() + ' '
else:
... | [
"def",
"diff",
"(",
"s1",
",",
"s2",
")",
":",
"delta",
"=",
"difflib",
".",
"Differ",
"(",
")",
".",
"compare",
"(",
"s1",
".",
"split",
"(",
")",
",",
"s2",
".",
"split",
"(",
")",
")",
"difflist",
"=",
"[",
"]",
"fullline",
"=",
"''",
"for... | --word-diff=porcelain clone | [
"--",
"word",
"-",
"diff",
"=",
"porcelain",
"clone"
] | python | train | 30.555556 |
modin-project/modin | modin/pandas/base.py | https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/pandas/base.py#L2561-L2615 | def sort_values(
self,
by,
axis=0,
ascending=True,
inplace=False,
kind="quicksort",
na_position="last",
):
"""Sorts by a column/row or list of columns/rows.
Args:
by: A list of labels for the axis to sort over.
... | [
"def",
"sort_values",
"(",
"self",
",",
"by",
",",
"axis",
"=",
"0",
",",
"ascending",
"=",
"True",
",",
"inplace",
"=",
"False",
",",
"kind",
"=",
"\"quicksort\"",
",",
"na_position",
"=",
"\"last\"",
",",
")",
":",
"axis",
"=",
"self",
".",
"_get_a... | Sorts by a column/row or list of columns/rows.
Args:
by: A list of labels for the axis to sort over.
axis: The axis to sort.
ascending: Sort in ascending or descending order.
inplace: If true, do the operation inplace.
kind: How to sort.
... | [
"Sorts",
"by",
"a",
"column",
"/",
"row",
"or",
"list",
"of",
"columns",
"/",
"rows",
".",
"Args",
":",
"by",
":",
"A",
"list",
"of",
"labels",
"for",
"the",
"axis",
"to",
"sort",
"over",
".",
"axis",
":",
"The",
"axis",
"to",
"sort",
".",
"ascen... | python | train | 36.018182 |
zwischenloesung/ardu-report-lib | libardurep/datastore.py | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datastore.py#L190-L205 | def get_json(self, prettyprint=False, translate=True):
"""
Get the data in JSON form
"""
j = []
if translate:
d = self.get_translated_data()
else:
d = self.data
for k in d:
j.append(d[k])
if prettyprint:
j = ... | [
"def",
"get_json",
"(",
"self",
",",
"prettyprint",
"=",
"False",
",",
"translate",
"=",
"True",
")",
":",
"j",
"=",
"[",
"]",
"if",
"translate",
":",
"d",
"=",
"self",
".",
"get_translated_data",
"(",
")",
"else",
":",
"d",
"=",
"self",
".",
"data... | Get the data in JSON form | [
"Get",
"the",
"data",
"in",
"JSON",
"form"
] | python | valid | 25.75 |
google/apitools | apitools/base/py/http_wrapper.py | https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/http_wrapper.py#L313-L356 | def MakeRequest(http, http_request, retries=7, max_retry_wait=60,
redirections=5,
retry_func=HandleExceptionsAndRebuildHttpConnections,
check_response_func=CheckResponse):
"""Send http_request via the given http, performing error/retry handling.
Args:
http:... | [
"def",
"MakeRequest",
"(",
"http",
",",
"http_request",
",",
"retries",
"=",
"7",
",",
"max_retry_wait",
"=",
"60",
",",
"redirections",
"=",
"5",
",",
"retry_func",
"=",
"HandleExceptionsAndRebuildHttpConnections",
",",
"check_response_func",
"=",
"CheckResponse",
... | Send http_request via the given http, performing error/retry handling.
Args:
http: An httplib2.Http instance, or a http multiplexer that delegates to
an underlying http, for example, HTTPMultiplexer.
http_request: A Request to send.
retries: (int, default 7) Number of retries to attempt... | [
"Send",
"http_request",
"via",
"the",
"given",
"http",
"performing",
"error",
"/",
"retry",
"handling",
"."
] | python | train | 40.681818 |
ekmmetering/ekmmeters | ekmmeters.py | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L3503-L3513 | def makeAB(self):
""" Munge A and B reads into single serial block with only unique fields."""
for fld in self.m_blk_a:
compare_fld = fld.upper()
if not "RESERVED" in compare_fld and not "CRC" in compare_fld:
self.m_req[fld] = self.m_blk_a[fld]
for fld in ... | [
"def",
"makeAB",
"(",
"self",
")",
":",
"for",
"fld",
"in",
"self",
".",
"m_blk_a",
":",
"compare_fld",
"=",
"fld",
".",
"upper",
"(",
")",
"if",
"not",
"\"RESERVED\"",
"in",
"compare_fld",
"and",
"not",
"\"CRC\"",
"in",
"compare_fld",
":",
"self",
"."... | Munge A and B reads into single serial block with only unique fields. | [
"Munge",
"A",
"and",
"B",
"reads",
"into",
"single",
"serial",
"block",
"with",
"only",
"unique",
"fields",
"."
] | python | test | 45.545455 |
Damgaard/PyImgur | pyimgur/__init__.py | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L66-L70 | def _get_album_or_image(json, imgur):
"""Return a gallery image/album depending on what the json represent."""
if json['is_album']:
return Gallery_album(json, imgur, has_fetched=False)
return Gallery_image(json, imgur) | [
"def",
"_get_album_or_image",
"(",
"json",
",",
"imgur",
")",
":",
"if",
"json",
"[",
"'is_album'",
"]",
":",
"return",
"Gallery_album",
"(",
"json",
",",
"imgur",
",",
"has_fetched",
"=",
"False",
")",
"return",
"Gallery_image",
"(",
"json",
",",
"imgur",... | Return a gallery image/album depending on what the json represent. | [
"Return",
"a",
"gallery",
"image",
"/",
"album",
"depending",
"on",
"what",
"the",
"json",
"represent",
"."
] | python | train | 46.8 |
ensime/ensime-vim | ensime_shared/client.py | https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/client.py#L248-L267 | def send_at_position(self, what, useSelection, where="range"):
"""Ask the server to perform an operation on a range (sometimes named point)
`what` is used as the prefix for the typehint.
If `useSelection` is `False` the range is calculated based on the word under de
cursor. Current sel... | [
"def",
"send_at_position",
"(",
"self",
",",
"what",
",",
"useSelection",
",",
"where",
"=",
"\"range\"",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'send_at_position: in'",
")",
"b",
",",
"e",
"=",
"self",
".",
"editor",
".",
"selection_pos",
"("... | Ask the server to perform an operation on a range (sometimes named point)
`what` is used as the prefix for the typehint.
If `useSelection` is `False` the range is calculated based on the word under de
cursor. Current selection start and end is used as the range otherwise.
`where` defi... | [
"Ask",
"the",
"server",
"to",
"perform",
"an",
"operation",
"on",
"a",
"range",
"(",
"sometimes",
"named",
"point",
")"
] | python | train | 50.25 |
spacetelescope/drizzlepac | drizzlepac/pixtosky.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/pixtosky.py#L102-L187 | def xy2rd(input,x=None,y=None,coords=None, coordfile=None,colnames=None,separator=None,
hms=True, precision=6,output=None,verbose=True):
""" Primary interface to perform coordinate transformations from
pixel to sky coordinates using STWCS and full distortion models
read from the input im... | [
"def",
"xy2rd",
"(",
"input",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"coordfile",
"=",
"None",
",",
"colnames",
"=",
"None",
",",
"separator",
"=",
"None",
",",
"hms",
"=",
"True",
",",
"precision",
"=",
"6... | Primary interface to perform coordinate transformations from
pixel to sky coordinates using STWCS and full distortion models
read from the input image header. | [
"Primary",
"interface",
"to",
"perform",
"coordinate",
"transformations",
"from",
"pixel",
"to",
"sky",
"coordinates",
"using",
"STWCS",
"and",
"full",
"distortion",
"models",
"read",
"from",
"the",
"input",
"image",
"header",
"."
] | python | train | 34.895349 |
manns/pyspread | pyspread/src/lib/vlc.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L4134-L4152 | def libvlc_media_add_option(p_md, psz_options):
'''Add an option to the media.
This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis.
@note: The options are listed in 'vlc --long-help' from the... | [
"def",
"libvlc_media_add_option",
"(",
"p_md",
",",
"psz_options",
")",
":",
"f",
"=",
"_Cfunctions",
".",
"get",
"(",
"'libvlc_media_add_option'",
",",
"None",
")",
"or",
"_Cfunction",
"(",
"'libvlc_media_add_option'",
",",
"(",
"(",
"1",
",",
")",
",",
"("... | Add an option to the media.
This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis.
@note: The options are listed in 'vlc --long-help' from the command line,
e.g. "-sout-all". Keep in mind that ... | [
"Add",
"an",
"option",
"to",
"the",
"media",
".",
"This",
"option",
"will",
"be",
"used",
"to",
"determine",
"how",
"the",
"media_player",
"will",
"read",
"the",
"media",
".",
"This",
"allows",
"to",
"use",
"VLC",
"s",
"advanced",
"reading",
"/",
"stream... | python | train | 53.526316 |
shad7/tvrenamer | tvrenamer/core/episode.py | https://github.com/shad7/tvrenamer/blob/7fb59cb02669357e73b7acb92dcb6d74fdff4654/tvrenamer/core/episode.py#L237-L249 | def rename(self):
"""Renames media file to formatted name.
After parsing data from initial media filename and searching
for additional data to using a data service, a formatted
filename will be generated and the media file will be renamed
to the generated name and optionally rel... | [
"def",
"rename",
"(",
"self",
")",
":",
"renamer",
".",
"execute",
"(",
"self",
".",
"original",
",",
"self",
".",
"out_location",
")",
"if",
"cfg",
".",
"CONF",
".",
"move_files_enabled",
":",
"LOG",
".",
"debug",
"(",
"'relocated: %s'",
",",
"self",
... | Renames media file to formatted name.
After parsing data from initial media filename and searching
for additional data to using a data service, a formatted
filename will be generated and the media file will be renamed
to the generated name and optionally relocated. | [
"Renames",
"media",
"file",
"to",
"formatted",
"name",
"."
] | python | train | 40.538462 |
flatangle/flatlib | flatlib/tools/planetarytime.py | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/planetarytime.py#L98-L101 | def getHourTable(date, pos):
""" Returns an HourTable object. """
table = hourTable(date, pos)
return HourTable(table, date) | [
"def",
"getHourTable",
"(",
"date",
",",
"pos",
")",
":",
"table",
"=",
"hourTable",
"(",
"date",
",",
"pos",
")",
"return",
"HourTable",
"(",
"table",
",",
"date",
")"
] | Returns an HourTable object. | [
"Returns",
"an",
"HourTable",
"object",
"."
] | python | train | 33.25 |
tapilab/brandelion | brandelion/cli/collect.py | https://github.com/tapilab/brandelion/blob/40a5a5333cf704182c8666d1fbbbdadc7ff88546/brandelion/cli/collect.py#L160-L168 | def fetch_list_members(list_url):
""" Get all members of the list specified by the given url. E.g., https://twitter.com/lore77/lists/libri-cultura-education """
match = re.match(r'.+twitter\.com\/(.+)\/lists\/(.+)', list_url)
if not match:
print('cannot parse list url %s' % list_url)
return ... | [
"def",
"fetch_list_members",
"(",
"list_url",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'.+twitter\\.com\\/(.+)\\/lists\\/(.+)'",
",",
"list_url",
")",
"if",
"not",
"match",
":",
"print",
"(",
"'cannot parse list url %s'",
"%",
"list_url",
")",
"return",
... | Get all members of the list specified by the given url. E.g., https://twitter.com/lore77/lists/libri-cultura-education | [
"Get",
"all",
"members",
"of",
"the",
"list",
"specified",
"by",
"the",
"given",
"url",
".",
"E",
".",
"g",
".",
"https",
":",
"//",
"twitter",
".",
"com",
"/",
"lore77",
"/",
"lists",
"/",
"libri",
"-",
"cultura",
"-",
"education"
] | python | train | 52 |
projectatomic/atomic-reactor | atomic_reactor/plugins/post_koji_upload.py | https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/plugins/post_koji_upload.py#L380-L467 | def get_output(self, buildroot_id):
"""
Build the 'output' section of the metadata.
:return: list, Output instances
"""
def add_buildroot_id(output):
logfile, metadata = output
metadata.update({'buildroot_id': buildroot_id})
return Output(fil... | [
"def",
"get_output",
"(",
"self",
",",
"buildroot_id",
")",
":",
"def",
"add_buildroot_id",
"(",
"output",
")",
":",
"logfile",
",",
"metadata",
"=",
"output",
"metadata",
".",
"update",
"(",
"{",
"'buildroot_id'",
":",
"buildroot_id",
"}",
")",
"return",
... | Build the 'output' section of the metadata.
:return: list, Output instances | [
"Build",
"the",
"output",
"section",
"of",
"the",
"metadata",
"."
] | python | train | 39.238636 |
pandas-dev/pandas | pandas/core/indexing.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexing.py#L1275-L1366 | def _convert_to_indexer(self, obj, axis=None, is_setter=False,
raise_missing=False):
"""
Convert indexing key into something we can use to do actual fancy
indexing on an ndarray
Examples
ix[:5] -> slice(0, 5)
ix[[1,2,3]] -> [1,2,3]
ix[... | [
"def",
"_convert_to_indexer",
"(",
"self",
",",
"obj",
",",
"axis",
"=",
"None",
",",
"is_setter",
"=",
"False",
",",
"raise_missing",
"=",
"False",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"self",
".",
"axis",
"or",
"0",
"labels",
"="... | Convert indexing key into something we can use to do actual fancy
indexing on an ndarray
Examples
ix[:5] -> slice(0, 5)
ix[[1,2,3]] -> [1,2,3]
ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)
Going by Zen of Python?
'In the face of ambiguity, re... | [
"Convert",
"indexing",
"key",
"into",
"something",
"we",
"can",
"use",
"to",
"do",
"actual",
"fancy",
"indexing",
"on",
"an",
"ndarray"
] | python | train | 32.815217 |
xeroc/python-graphenelib | graphenecommon/chain.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/chain.py#L229-L245 | def sign(self, tx=None, wifs=[]):
""" Sign a provided transaction witht he provided key(s)
:param dict tx: The transaction to be signed and returned
:param string wifs: One or many wif keys to use for signing
a transaction. If not present, the keys will be loaded
... | [
"def",
"sign",
"(",
"self",
",",
"tx",
"=",
"None",
",",
"wifs",
"=",
"[",
"]",
")",
":",
"if",
"tx",
":",
"txbuffer",
"=",
"self",
".",
"transactionbuilder_class",
"(",
"tx",
",",
"blockchain_instance",
"=",
"self",
")",
"else",
":",
"txbuffer",
"="... | Sign a provided transaction witht he provided key(s)
:param dict tx: The transaction to be signed and returned
:param string wifs: One or many wif keys to use for signing
a transaction. If not present, the keys will be loaded
from the wallet as defined in "missin... | [
"Sign",
"a",
"provided",
"transaction",
"witht",
"he",
"provided",
"key",
"(",
"s",
")"
] | python | valid | 40.941176 |
fastai/fastai | fastai/vision/data.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/vision/data.py#L173-L180 | def normalize(self, stats:Collection[Tensor]=None, do_x:bool=True, do_y:bool=False)->None:
"Add normalize transform using `stats` (defaults to `DataBunch.batch_stats`)"
if getattr(self,'norm',False): raise Exception('Can not call normalize twice')
if stats is None: self.stats = self.batch_stats(... | [
"def",
"normalize",
"(",
"self",
",",
"stats",
":",
"Collection",
"[",
"Tensor",
"]",
"=",
"None",
",",
"do_x",
":",
"bool",
"=",
"True",
",",
"do_y",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"if",
"getattr",
"(",
"self",
",",
"'norm'",
... | Add normalize transform using `stats` (defaults to `DataBunch.batch_stats`) | [
"Add",
"normalize",
"transform",
"using",
"stats",
"(",
"defaults",
"to",
"DataBunch",
".",
"batch_stats",
")"
] | python | train | 61.75 |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/preprocess/local_preprocess.py#L37-L66 | def parse_arguments(argv):
"""Parse command line arguments.
Args:
argv: list of command line arguments, includeing programe name.
Returns:
An argparse Namespace object.
"""
parser = argparse.ArgumentParser(
description='Runs Preprocessing on structured CSV data.')
parser.add_argument('--inpu... | [
"def",
"parse_arguments",
"(",
"argv",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Runs Preprocessing on structured CSV data.'",
")",
"parser",
".",
"add_argument",
"(",
"'--input-file-pattern'",
",",
"type",
"=",
"str",
",... | Parse command line arguments.
Args:
argv: list of command line arguments, includeing programe name.
Returns:
An argparse Namespace object. | [
"Parse",
"command",
"line",
"arguments",
"."
] | python | train | 32.2 |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/api.py | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/api.py#L35-L59 | def init_app(self, app=None, blueprint=None, additional_blueprints=None):
"""Update flask application with our api
:param Application app: a flask application
"""
if app is not None:
self.app = app
if blueprint is not None:
self.blueprint = blueprint
... | [
"def",
"init_app",
"(",
"self",
",",
"app",
"=",
"None",
",",
"blueprint",
"=",
"None",
",",
"additional_blueprints",
"=",
"None",
")",
":",
"if",
"app",
"is",
"not",
"None",
":",
"self",
".",
"app",
"=",
"app",
"if",
"blueprint",
"is",
"not",
"None"... | Update flask application with our api
:param Application app: a flask application | [
"Update",
"flask",
"application",
"with",
"our",
"api"
] | python | train | 33.36 |
bdcht/grandalf | grandalf/layouts.py | https://github.com/bdcht/grandalf/blob/b0a604afa79e5201eebe5feb56ae5ec7afc07b95/grandalf/layouts.py#L222-L238 | def _medianindex(self,v):
"""
find new position of vertex v according to adjacency in layer l+dir.
position is given by the median value of adjacent positions.
median heuristic is proven to achieve at most 3 times the minimum
of crossings (while barycenter achieve in theory the o... | [
"def",
"_medianindex",
"(",
"self",
",",
"v",
")",
":",
"assert",
"self",
".",
"prevlayer",
"(",
")",
"!=",
"None",
"N",
"=",
"self",
".",
"_neighbors",
"(",
"v",
")",
"g",
"=",
"self",
".",
"layout",
".",
"grx",
"pos",
"=",
"[",
"g",
"[",
"x",... | find new position of vertex v according to adjacency in layer l+dir.
position is given by the median value of adjacent positions.
median heuristic is proven to achieve at most 3 times the minimum
of crossings (while barycenter achieve in theory the order of |V|) | [
"find",
"new",
"position",
"of",
"vertex",
"v",
"according",
"to",
"adjacency",
"in",
"layer",
"l",
"+",
"dir",
".",
"position",
"is",
"given",
"by",
"the",
"median",
"value",
"of",
"adjacent",
"positions",
".",
"median",
"heuristic",
"is",
"proven",
"to",... | python | train | 38.235294 |
user-cont/conu | conu/backend/docker/skopeo.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/skopeo.py#L23-L65 | def transport_param(image):
""" Parse DockerImage info into skopeo parameter
:param image: DockerImage
:return: string. skopeo parameter specifying image
"""
transports = {SkopeoTransport.CONTAINERS_STORAGE: "containers-storage:",
SkopeoTransport.DIRECTORY: "dir:",
... | [
"def",
"transport_param",
"(",
"image",
")",
":",
"transports",
"=",
"{",
"SkopeoTransport",
".",
"CONTAINERS_STORAGE",
":",
"\"containers-storage:\"",
",",
"SkopeoTransport",
".",
"DIRECTORY",
":",
"\"dir:\"",
",",
"SkopeoTransport",
".",
"DOCKER",
":",
"\"docker:/... | Parse DockerImage info into skopeo parameter
:param image: DockerImage
:return: string. skopeo parameter specifying image | [
"Parse",
"DockerImage",
"info",
"into",
"skopeo",
"parameter"
] | python | train | 39.395349 |
titusjan/argos | argos/application.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/application.py#L314-L351 | def addNewMainWindow(self, settings=None, inspectorFullName=None):
""" Creates and shows a new MainWindow.
If inspectorFullName is set, it will set the identifier from that name.
If the inspector identifier is not found in the registry, a KeyError is raised.
"""
mainWind... | [
"def",
"addNewMainWindow",
"(",
"self",
",",
"settings",
"=",
"None",
",",
"inspectorFullName",
"=",
"None",
")",
":",
"mainWindow",
"=",
"MainWindow",
"(",
"self",
")",
"self",
".",
"mainWindows",
".",
"append",
"(",
"mainWindow",
")",
"self",
".",
"windo... | Creates and shows a new MainWindow.
If inspectorFullName is set, it will set the identifier from that name.
If the inspector identifier is not found in the registry, a KeyError is raised. | [
"Creates",
"and",
"shows",
"a",
"new",
"MainWindow",
"."
] | python | train | 40.973684 |
JoseAntFer/pyny3d | pyny3d/geoms.py | https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L1293-L1303 | def mirror(self, axes='x'):
"""
Generates a symmetry of the Polyhedron respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Polyhedron``
"""
polygon = np.array([[0,0], [0,1], [1,1]])
space ... | [
"def",
"mirror",
"(",
"self",
",",
"axes",
"=",
"'x'",
")",
":",
"polygon",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
"]",
",",
"[",
"1",
",",
"1",
"]",
"]",
")",
"space",
"=",
"Space",
"(",
"P... | Generates a symmetry of the Polyhedron respect global axes.
:param axes: 'x', 'y', 'z', 'xy', 'xz', 'yz'...
:type axes: str
:returns: ``pyny.Polyhedron`` | [
"Generates",
"a",
"symmetry",
"of",
"the",
"Polyhedron",
"respect",
"global",
"axes",
".",
":",
"param",
"axes",
":",
"x",
"y",
"z",
"xy",
"xz",
"yz",
"...",
":",
"type",
"axes",
":",
"str",
":",
"returns",
":",
"pyny",
".",
"Polyhedron"
] | python | train | 37.727273 |
cloudendpoints/endpoints-python | endpoints/api_config.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L2001-L2026 | def __get_merged_api_info(self, services):
"""Builds a description of an API.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
Returns:
The _ApiInfo object to use for the API that the given services implement.
Raises:
ApiConfigurationErr... | [
"def",
"__get_merged_api_info",
"(",
"self",
",",
"services",
")",
":",
"merged_api_info",
"=",
"services",
"[",
"0",
"]",
".",
"api_info",
"# Verify that, if there are multiple classes here, they're allowed to",
"# implement the same API.",
"for",
"service",
"in",
"service... | Builds a description of an API.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
Returns:
The _ApiInfo object to use for the API that the given services implement.
Raises:
ApiConfigurationError: If there's something wrong with the API
... | [
"Builds",
"a",
"description",
"of",
"an",
"API",
"."
] | python | train | 36.576923 |
discogs/python-cas-client | cas_client/cas_client.py | https://github.com/discogs/python-cas-client/blob/f1efa2f49a22d43135014cb1b8d9dd3875304318/cas_client/cas_client.py#L77-L83 | def delete_session(self, ticket):
'''
Delete a session record associated with a service ticket.
'''
assert isinstance(self.session_storage_adapter, CASSessionAdapter)
logging.debug('[CAS] Deleting session for ticket {}'.format(ticket))
self.session_storage_adapter.delete(... | [
"def",
"delete_session",
"(",
"self",
",",
"ticket",
")",
":",
"assert",
"isinstance",
"(",
"self",
".",
"session_storage_adapter",
",",
"CASSessionAdapter",
")",
"logging",
".",
"debug",
"(",
"'[CAS] Deleting session for ticket {}'",
".",
"format",
"(",
"ticket",
... | Delete a session record associated with a service ticket. | [
"Delete",
"a",
"session",
"record",
"associated",
"with",
"a",
"service",
"ticket",
"."
] | python | train | 45.857143 |
rigetti/quantumflow | quantumflow/forest/__init__.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/forest/__init__.py#L188-L213 | def pyquil_to_circuit(program: pyquil.Program) -> Circuit:
"""Convert a protoquil pyQuil program to a QuantumFlow Circuit"""
circ = Circuit()
for inst in program.instructions:
# print(type(inst))
if isinstance(inst, pyquil.Declare): # Ignore
continue
if isinst... | [
"def",
"pyquil_to_circuit",
"(",
"program",
":",
"pyquil",
".",
"Program",
")",
"->",
"Circuit",
":",
"circ",
"=",
"Circuit",
"(",
")",
"for",
"inst",
"in",
"program",
".",
"instructions",
":",
"# print(type(inst))",
"if",
"isinstance",
"(",
"inst",
",",
"... | Convert a protoquil pyQuil program to a QuantumFlow Circuit | [
"Convert",
"a",
"protoquil",
"pyQuil",
"program",
"to",
"a",
"QuantumFlow",
"Circuit"
] | python | train | 37.615385 |
not-na/peng3d | peng3d/model.py | https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/model.py#L487-L493 | def getVertices(self,data):
"""
Returns the vertices of this region already transformed and ready-to-use.
Internally uses :py:meth:`Bone.transformVertices()`\ .
"""
return self.bone.transformVertices(data,self.vertices,self.dims) | [
"def",
"getVertices",
"(",
"self",
",",
"data",
")",
":",
"return",
"self",
".",
"bone",
".",
"transformVertices",
"(",
"data",
",",
"self",
".",
"vertices",
",",
"self",
".",
"dims",
")"
] | Returns the vertices of this region already transformed and ready-to-use.
Internally uses :py:meth:`Bone.transformVertices()`\ . | [
"Returns",
"the",
"vertices",
"of",
"this",
"region",
"already",
"transformed",
"and",
"ready",
"-",
"to",
"-",
"use",
".",
"Internally",
"uses",
":",
"py",
":",
"meth",
":",
"Bone",
".",
"transformVertices",
"()",
"\\",
"."
] | python | test | 38.857143 |
wummel/dosage | dosagelib/plugins/t.py | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/plugins/t.py#L185-L189 | def namer(cls, imageUrl, pageUrl):
"""Use page URL sequence which is apparently increasing."""
num = pageUrl.split('/')[-1]
ext = imageUrl.rsplit('.', 1)[1]
return "thethinhline-%s.%s" % (num, ext) | [
"def",
"namer",
"(",
"cls",
",",
"imageUrl",
",",
"pageUrl",
")",
":",
"num",
"=",
"pageUrl",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"ext",
"=",
"imageUrl",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"[",
"1",
"]",
"return",
"\"theth... | Use page URL sequence which is apparently increasing. | [
"Use",
"page",
"URL",
"sequence",
"which",
"is",
"apparently",
"increasing",
"."
] | python | train | 45 |
icometrix/dicom2nifti | dicom2nifti/common.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L478-L492 | def write_bvec_file(bvecs, bvec_file):
"""
Write an array of bvecs to a bvec file
:param bvecs: array with the vectors
:param bvec_file: filepath to write to
"""
if bvec_file is None:
return
logger.info('Saving BVEC file: %s' % bvec_file)
with open(bvec_file, 'w') as text_file:
... | [
"def",
"write_bvec_file",
"(",
"bvecs",
",",
"bvec_file",
")",
":",
"if",
"bvec_file",
"is",
"None",
":",
"return",
"logger",
".",
"info",
"(",
"'Saving BVEC file: %s'",
"%",
"bvec_file",
")",
"with",
"open",
"(",
"bvec_file",
",",
"'w'",
")",
"as",
"text_... | Write an array of bvecs to a bvec file
:param bvecs: array with the vectors
:param bvec_file: filepath to write to | [
"Write",
"an",
"array",
"of",
"bvecs",
"to",
"a",
"bvec",
"file"
] | python | train | 39 |
neighbordog/deviantart | deviantart/api.py | https://github.com/neighbordog/deviantart/blob/5612f1d5e2139a48c9d793d7fd19cde7e162d7b1/deviantart/api.py#L867-L888 | def get_users(self, usernames):
"""Fetch user info for given usernames
:param username: The usernames you want metadata for (max. 50)
"""
if self.standard_grant_type is not "authorization_code":
raise DeviantartError("Authentication through Authorization Code (Grant Type) ... | [
"def",
"get_users",
"(",
"self",
",",
"usernames",
")",
":",
"if",
"self",
".",
"standard_grant_type",
"is",
"not",
"\"authorization_code\"",
":",
"raise",
"DeviantartError",
"(",
"\"Authentication through Authorization Code (Grant Type) is required in order to connect to this ... | Fetch user info for given usernames
:param username: The usernames you want metadata for (max. 50) | [
"Fetch",
"user",
"info",
"for",
"given",
"usernames"
] | python | train | 28.045455 |
CybOXProject/mixbox | mixbox/datautils.py | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/datautils.py#L83-L104 | def needkwargs(*argnames):
"""Function decorator which checks that the decorated function is called
with a set of required kwargs.
Args:
*argnames: String keyword argument names.
Raises:
ValueError: If a required kwarg is missing in the decorated function
call.
"""
... | [
"def",
"needkwargs",
"(",
"*",
"argnames",
")",
":",
"required",
"=",
"set",
"(",
"argnames",
")",
"def",
"decorator",
"(",
"func",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"missing",
"=",
"required",
"-",
"set... | Function decorator which checks that the decorated function is called
with a set of required kwargs.
Args:
*argnames: String keyword argument names.
Raises:
ValueError: If a required kwarg is missing in the decorated function
call. | [
"Function",
"decorator",
"which",
"checks",
"that",
"the",
"decorated",
"function",
"is",
"called",
"with",
"a",
"set",
"of",
"required",
"kwargs",
"."
] | python | train | 29 |
blockadeio/analyst_toolbench | blockade/api.py | https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/api.py#L70-L88 | def _endpoint(self, endpoint, action, *url_args):
"""Return the URL for the action.
:param str endpoint: The controller
:param str action: The action provided by the controller
:param url_args: Additional endpoints(for endpoints that take part of
the url as opti... | [
"def",
"_endpoint",
"(",
"self",
",",
"endpoint",
",",
"action",
",",
"*",
"url_args",
")",
":",
"args",
"=",
"(",
"self",
".",
"api_base",
",",
"endpoint",
",",
"action",
")",
"if",
"action",
"==",
"''",
":",
"args",
"=",
"(",
"self",
".",
"api_ba... | Return the URL for the action.
:param str endpoint: The controller
:param str action: The action provided by the controller
:param url_args: Additional endpoints(for endpoints that take part of
the url as option)
:return: Full URL for the requested action | [
"Return",
"the",
"URL",
"for",
"the",
"action",
"."
] | python | train | 37.263158 |
ska-sa/katcp-python | katcp/resource_client.py | https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1413-L1416 | def until_any_child_in_state(self, state, timeout=None):
"""Return a tornado Future; resolves when any client is in specified state"""
return until_any(*[r.until_state(state) for r in dict.values(self.children)],
timeout=timeout) | [
"def",
"until_any_child_in_state",
"(",
"self",
",",
"state",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"until_any",
"(",
"*",
"[",
"r",
".",
"until_state",
"(",
"state",
")",
"for",
"r",
"in",
"dict",
".",
"values",
"(",
"self",
".",
"children"... | Return a tornado Future; resolves when any client is in specified state | [
"Return",
"a",
"tornado",
"Future",
";",
"resolves",
"when",
"any",
"client",
"is",
"in",
"specified",
"state"
] | python | train | 66.75 |
taborlab/FlowCal | FlowCal/mef.py | https://github.com/taborlab/FlowCal/blob/031a7af82acb1d46879a8e384a1a00f27f0bdc7a/FlowCal/mef.py#L36-L213 | def clustering_gmm(data,
n_clusters,
tol=1e-7,
min_covar=None,
scale='logicle'):
"""
Find clusters in an array using a Gaussian Mixture Model.
Before clustering, `data` can be automatically rescaled as specified by
the `scale` ... | [
"def",
"clustering_gmm",
"(",
"data",
",",
"n_clusters",
",",
"tol",
"=",
"1e-7",
",",
"min_covar",
"=",
"None",
",",
"scale",
"=",
"'logicle'",
")",
":",
"# Initialize min_covar parameter",
"# Parameter is initialized differently depending on scikit's version",
"if",
"... | Find clusters in an array using a Gaussian Mixture Model.
Before clustering, `data` can be automatically rescaled as specified by
the `scale` argument.
Parameters
----------
data : FCSData or array_like
Data to cluster.
n_clusters : int
Number of clusters to find.
tol : flo... | [
"Find",
"clusters",
"in",
"an",
"array",
"using",
"a",
"Gaussian",
"Mixture",
"Model",
"."
] | python | train | 36.764045 |
ucsb-cs-education/hairball | hairball/plugins/checks.py | https://github.com/ucsb-cs-education/hairball/blob/c6da8971f8a34e88ce401d36b51431715e1dff5b/hairball/plugins/checks.py#L120-L127 | def get_receive(self, script_list):
"""Return a list of received events contained in script_list."""
events = defaultdict(set)
for script in script_list:
if self.script_start_type(script) == self.HAT_WHEN_I_RECEIVE:
event = script.blocks[0].args[0].lower()
... | [
"def",
"get_receive",
"(",
"self",
",",
"script_list",
")",
":",
"events",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"script",
"in",
"script_list",
":",
"if",
"self",
".",
"script_start_type",
"(",
"script",
")",
"==",
"self",
".",
"HAT_WHEN_I_RECEIVE",
... | Return a list of received events contained in script_list. | [
"Return",
"a",
"list",
"of",
"received",
"events",
"contained",
"in",
"script_list",
"."
] | python | train | 45.625 |
noobermin/pys | pys/__init__.py | https://github.com/noobermin/pys/blob/e01b74210c65eb96d019bb42e0a3c9e6676da943/pys/__init__.py#L10-L23 | def conv(arg,default=None,func=None):
'''
essentially, the generalization of
arg if arg else default
or
func(arg) if arg else default
'''
if func:
return func(arg) if arg else default;
else:
return arg if arg else default; | [
"def",
"conv",
"(",
"arg",
",",
"default",
"=",
"None",
",",
"func",
"=",
"None",
")",
":",
"if",
"func",
":",
"return",
"func",
"(",
"arg",
")",
"if",
"arg",
"else",
"default",
"else",
":",
"return",
"arg",
"if",
"arg",
"else",
"default"
] | essentially, the generalization of
arg if arg else default
or
func(arg) if arg else default | [
"essentially",
"the",
"generalization",
"of",
"arg",
"if",
"arg",
"else",
"default"
] | python | train | 18.857143 |
T-002/pycast | pycast/common/matrix.py | https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L642-L729 | def householder(self):
"""Return Matrices u,b,v with self = ubv and b is in bidiagonal form
The algorithm uses householder transformations.
:return tuple (u,b,v): A tuple with the Matrix u, b and v.
and self = ubv (except some rounding errors)
u is a unitary mat... | [
"def",
"householder",
"(",
"self",
")",
":",
"# copy instance to transform it to bidiagonal form.",
"bidiagMatrix",
"=",
"Matrix",
".",
"from_two_dim_array",
"(",
"self",
".",
"get_width",
"(",
")",
",",
"self",
".",
"get_height",
"(",
")",
",",
"self",
".",
"ma... | Return Matrices u,b,v with self = ubv and b is in bidiagonal form
The algorithm uses householder transformations.
:return tuple (u,b,v): A tuple with the Matrix u, b and v.
and self = ubv (except some rounding errors)
u is a unitary matrix
b is a bidiago... | [
"Return",
"Matrices",
"u",
"b",
"v",
"with",
"self",
"=",
"ubv",
"and",
"b",
"is",
"in",
"bidiagonal",
"form"
] | python | train | 40.602273 |
Azure/azure-sdk-for-python | azure-mgmt-resource/azure/mgmt/resource/resources/resource_management_client.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-resource/azure/mgmt/resource/resources/resource_management_client.py#L96-L120 | def models(cls, api_version=DEFAULT_API_VERSION):
"""Module depends on the API version:
* 2016-02-01: :mod:`v2016_02_01.models<azure.mgmt.resource.resources.v2016_02_01.models>`
* 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.resources.v2016_09_01.models>`
* 2017-05-... | [
"def",
"models",
"(",
"cls",
",",
"api_version",
"=",
"DEFAULT_API_VERSION",
")",
":",
"if",
"api_version",
"==",
"'2016-02-01'",
":",
"from",
".",
"v2016_02_01",
"import",
"models",
"return",
"models",
"elif",
"api_version",
"==",
"'2016-09-01'",
":",
"from",
... | Module depends on the API version:
* 2016-02-01: :mod:`v2016_02_01.models<azure.mgmt.resource.resources.v2016_02_01.models>`
* 2016-09-01: :mod:`v2016_09_01.models<azure.mgmt.resource.resources.v2016_09_01.models>`
* 2017-05-10: :mod:`v2017_05_10.models<azure.mgmt.resource.resources.v2... | [
"Module",
"depends",
"on",
"the",
"API",
"version",
":"
] | python | test | 49.4 |
orb-framework/orb | orb/core/schema.py | https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/schema.py#L381-L412 | def register(self, item):
"""
Registers a new orb object to this schema. This could be a column, index, or collector -- including
a virtual object defined through the orb.virtual decorator.
:param item: <variant>
:return:
"""
if callable(item) and hasattr(item,... | [
"def",
"register",
"(",
"self",
",",
"item",
")",
":",
"if",
"callable",
"(",
"item",
")",
"and",
"hasattr",
"(",
"item",
",",
"'__orb__'",
")",
":",
"item",
"=",
"item",
".",
"__orb__",
"key",
"=",
"item",
".",
"name",
"(",
")",
"model",
"=",
"s... | Registers a new orb object to this schema. This could be a column, index, or collector -- including
a virtual object defined through the orb.virtual decorator.
:param item: <variant>
:return: | [
"Registers",
"a",
"new",
"orb",
"object",
"to",
"this",
"schema",
".",
"This",
"could",
"be",
"a",
"column",
"index",
"or",
"collector",
"--",
"including",
"a",
"virtual",
"object",
"defined",
"through",
"the",
"orb",
".",
"virtual",
"decorator",
"."
] | python | train | 30.75 |
TissueMAPS/TmClient | src/python/tmclient/api.py | https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/api.py#L1052-L1083 | def get_microscope_files(self, plate_name, acquisition_name):
'''Gets status and name of files that have been registered for upload.
Parameters
----------
plate_name: str
name of the parent plate
acquisition_name: str
name of the parent acquisition
... | [
"def",
"get_microscope_files",
"(",
"self",
",",
"plate_name",
",",
"acquisition_name",
")",
":",
"logger",
".",
"info",
"(",
"'get names of already uploaded files for experiment \"%s\", '",
"'plate \"%s\" and acquisition \"%s\"'",
",",
"self",
".",
"experiment_name",
",",
... | Gets status and name of files that have been registered for upload.
Parameters
----------
plate_name: str
name of the parent plate
acquisition_name: str
name of the parent acquisition
Returns
-------
List[Dict[str, str]]
names... | [
"Gets",
"status",
"and",
"name",
"of",
"files",
"that",
"have",
"been",
"registered",
"for",
"upload",
"."
] | python | train | 38.4375 |
DarkEnergySurvey/ugali | ugali/utils/skymap.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/skymap.py#L94-L149 | def randomPositions(input, nside_pix, n=1):
"""
Generate n random positions within a full HEALPix mask of booleans, or a set of (lon, lat) coordinates.
Parameters:
-----------
input : (1) full HEALPix mask of booleans, or (2) a set of (lon, lat) coordinates for catalog objects that define the o... | [
"def",
"randomPositions",
"(",
"input",
",",
"nside_pix",
",",
"n",
"=",
"1",
")",
":",
"input",
"=",
"np",
".",
"array",
"(",
"input",
")",
"if",
"len",
"(",
"input",
".",
"shape",
")",
"==",
"1",
":",
"if",
"hp",
".",
"npix2nside",
"(",
"len",
... | Generate n random positions within a full HEALPix mask of booleans, or a set of (lon, lat) coordinates.
Parameters:
-----------
input : (1) full HEALPix mask of booleans, or (2) a set of (lon, lat) coordinates for catalog objects that define the occupied pixels.
nside_pix : nside_pix is meant to be... | [
"Generate",
"n",
"random",
"positions",
"within",
"a",
"full",
"HEALPix",
"mask",
"of",
"booleans",
"or",
"a",
"set",
"of",
"(",
"lon",
"lat",
")",
"coordinates",
"."
] | python | train | 39.714286 |
JoelBender/bacpypes | py25/bacpypes/apdu.py | https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/apdu.py#L173-L251 | def encode(self, pdu):
"""encode the contents of the APCI into the PDU."""
if _debug: APCI._debug("encode %r", pdu)
PCI.update(pdu, self)
if (self.apduType == ConfirmedRequestPDU.pduType):
# PDU type
buff = self.apduType << 4
if self.apduSeg:
... | [
"def",
"encode",
"(",
"self",
",",
"pdu",
")",
":",
"if",
"_debug",
":",
"APCI",
".",
"_debug",
"(",
"\"encode %r\"",
",",
"pdu",
")",
"PCI",
".",
"update",
"(",
"pdu",
",",
"self",
")",
"if",
"(",
"self",
".",
"apduType",
"==",
"ConfirmedRequestPDU"... | encode the contents of the APCI into the PDU. | [
"encode",
"the",
"contents",
"of",
"the",
"APCI",
"into",
"the",
"PDU",
"."
] | python | train | 31.265823 |
peterwittek/ncpol2sdpa | ncpol2sdpa/physics_utils.py | https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/physics_utils.py#L124-L163 | def pauli_constraints(X, Y, Z):
"""Return a set of constraints that define Pauli spin operators.
:param X: List of Pauli X operator on sites.
:type X: list of :class:`sympy.physics.quantum.operator.HermitianOperator`.
:param Y: List of Pauli Y operator on sites.
:type Y: list of :class:`sympy.phys... | [
"def",
"pauli_constraints",
"(",
"X",
",",
"Y",
",",
"Z",
")",
":",
"substitutions",
"=",
"{",
"}",
"n_vars",
"=",
"len",
"(",
"X",
")",
"for",
"i",
"in",
"range",
"(",
"n_vars",
")",
":",
"# They square to the identity",
"substitutions",
"[",
"X",
"["... | Return a set of constraints that define Pauli spin operators.
:param X: List of Pauli X operator on sites.
:type X: list of :class:`sympy.physics.quantum.operator.HermitianOperator`.
:param Y: List of Pauli Y operator on sites.
:type Y: list of :class:`sympy.physics.quantum.operator.HermitianOperator`... | [
"Return",
"a",
"set",
"of",
"constraints",
"that",
"define",
"Pauli",
"spin",
"operators",
"."
] | python | train | 42.25 |
PlaidWeb/Publ | publ/category.py | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/category.py#L154-L158 | def sort_name(self):
""" Get the sorting name of this category """
if self._record and self._record.sort_name:
return self._record.sort_name
return self.name | [
"def",
"sort_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_record",
"and",
"self",
".",
"_record",
".",
"sort_name",
":",
"return",
"self",
".",
"_record",
".",
"sort_name",
"return",
"self",
".",
"name"
] | Get the sorting name of this category | [
"Get",
"the",
"sorting",
"name",
"of",
"this",
"category"
] | python | train | 37.8 |
minhhh/pelican_git | pelican_git/plugin.py | https://github.com/minhhh/pelican_git/blob/9e4758adb5c70b95979f1953823a2fcf1c76e50c/pelican_git/plugin.py#L147-L153 | def register():
"""Plugin registration."""
from pelican import signals
signals.initialized.connect(setup_git)
signals.article_generator_finalized.connect(replace_git_url) | [
"def",
"register",
"(",
")",
":",
"from",
"pelican",
"import",
"signals",
"signals",
".",
"initialized",
".",
"connect",
"(",
"setup_git",
")",
"signals",
".",
"article_generator_finalized",
".",
"connect",
"(",
"replace_git_url",
")"
] | Plugin registration. | [
"Plugin",
"registration",
"."
] | python | train | 26 |
riga/law | law/util.py | https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/util.py#L286-L309 | def merge_dicts(*dicts, **kwargs):
""" merge_dicts(*dicts, cls=None)
Takes multiple *dicts* and returns a single merged dict. The merging takes place in order of the
passed dicts and therefore, values of rear objects have precedence in case of field collisions.
The class of the returned merged dict is c... | [
"def",
"merge_dicts",
"(",
"*",
"dicts",
",",
"*",
"*",
"kwargs",
")",
":",
"# get or infer the class",
"cls",
"=",
"kwargs",
".",
"get",
"(",
"\"cls\"",
",",
"None",
")",
"if",
"cls",
"is",
"None",
":",
"for",
"d",
"in",
"dicts",
":",
"if",
"isinsta... | merge_dicts(*dicts, cls=None)
Takes multiple *dicts* and returns a single merged dict. The merging takes place in order of the
passed dicts and therefore, values of rear objects have precedence in case of field collisions.
The class of the returned merged dict is configurable via *cls*. If it is *None*, the... | [
"merge_dicts",
"(",
"*",
"dicts",
"cls",
"=",
"None",
")",
"Takes",
"multiple",
"*",
"dicts",
"*",
"and",
"returns",
"a",
"single",
"merged",
"dict",
".",
"The",
"merging",
"takes",
"place",
"in",
"order",
"of",
"the",
"passed",
"dicts",
"and",
"therefor... | python | train | 36.291667 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.