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 |
|---|---|---|---|---|---|---|---|---|---|
apple/turicreate | src/unity/python/turicreate/toolkits/_feature_engineering/_transformer_chain.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_feature_engineering/_transformer_chain.py#L348-L361 | def _load_version(cls, unpickler, version):
"""
An function to load an object with a specific version of the class.
Parameters
----------
pickler : file
A GLUnpickler file handle.
version : int
A version number as maintained by the class writer.
... | [
"def",
"_load_version",
"(",
"cls",
",",
"unpickler",
",",
"version",
")",
":",
"obj",
"=",
"unpickler",
".",
"load",
"(",
")",
"return",
"TransformerChain",
"(",
"obj",
".",
"_state",
"[",
"\"steps\"",
"]",
")"
] | An function to load an object with a specific version of the class.
Parameters
----------
pickler : file
A GLUnpickler file handle.
version : int
A version number as maintained by the class writer. | [
"An",
"function",
"to",
"load",
"an",
"object",
"with",
"a",
"specific",
"version",
"of",
"the",
"class",
"."
] | python | train | 28.714286 |
PythonCharmers/python-future | src/future/backports/email/message.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/message.py#L704-L724 | def del_param(self, param, header='content-type', requote=True):
"""Remove the given parameter completely from the Content-Type header.
The header will be re-written in place without the parameter or its
value. All values will be quoted as necessary unless requote is
False. Optional he... | [
"def",
"del_param",
"(",
"self",
",",
"param",
",",
"header",
"=",
"'content-type'",
",",
"requote",
"=",
"True",
")",
":",
"if",
"header",
"not",
"in",
"self",
":",
"return",
"new_ctype",
"=",
"''",
"for",
"p",
",",
"v",
"in",
"self",
".",
"get_para... | Remove the given parameter completely from the Content-Type header.
The header will be re-written in place without the parameter or its
value. All values will be quoted as necessary unless requote is
False. Optional header specifies an alternative to the Content-Type
header. | [
"Remove",
"the",
"given",
"parameter",
"completely",
"from",
"the",
"Content",
"-",
"Type",
"header",
"."
] | python | train | 43.952381 |
HPCC-Cloud-Computing/CAL | calplus/v1/object_storage/client.py | https://github.com/HPCC-Cloud-Computing/CAL/blob/7134b3dfe9ee3a383506a592765c7a12fa4ca1e9/calplus/v1/object_storage/client.py#L62-L71 | def update_container(self, container, metadata, **kwargs):
"""Update container metadata
:param container: container name (Container is equivalent to
Bucket term in Amazon).
:param metadata(dict): additional metadata to include in the request.
:param **kwargs(di... | [
"def",
"update_container",
"(",
"self",
",",
"container",
",",
"metadata",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"'update_object() with %s is success.'",
",",
"self",
".",
"driver",
")",
"return",
"self",
".",
"driver",
".",
"update_co... | Update container metadata
:param container: container name (Container is equivalent to
Bucket term in Amazon).
:param metadata(dict): additional metadata to include in the request.
:param **kwargs(dict): extend args for specific driver. | [
"Update",
"container",
"metadata"
] | python | train | 50.5 |
SuperCowPowers/bat | bat/dataframe_cache.py | https://github.com/SuperCowPowers/bat/blob/069e6bc52843dc07760969c531cc442ca7da8e0c/bat/dataframe_cache.py#L27-L33 | def add_rows(self, list_of_rows):
"""Add a list of rows to the DataFrameCache class"""
for row in list_of_rows:
self.row_deque.append(row)
self.time_deque.append(time.time())
# Update the data structure
self.update() | [
"def",
"add_rows",
"(",
"self",
",",
"list_of_rows",
")",
":",
"for",
"row",
"in",
"list_of_rows",
":",
"self",
".",
"row_deque",
".",
"append",
"(",
"row",
")",
"self",
".",
"time_deque",
".",
"append",
"(",
"time",
".",
"time",
"(",
")",
")",
"# Up... | Add a list of rows to the DataFrameCache class | [
"Add",
"a",
"list",
"of",
"rows",
"to",
"the",
"DataFrameCache",
"class"
] | python | train | 38 |
glitchassassin/lackey | lackey/RegionMatching.py | https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L449-L454 | def getBitmap(self):
""" Captures screen area of this region, at least the part that is on the screen
Returns image as numpy array
"""
return PlatformManager.getBitmapFromRect(self.x, self.y, self.w, self.h) | [
"def",
"getBitmap",
"(",
"self",
")",
":",
"return",
"PlatformManager",
".",
"getBitmapFromRect",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"w",
",",
"self",
".",
"h",
")"
] | Captures screen area of this region, at least the part that is on the screen
Returns image as numpy array | [
"Captures",
"screen",
"area",
"of",
"this",
"region",
"at",
"least",
"the",
"part",
"that",
"is",
"on",
"the",
"screen"
] | python | train | 39.166667 |
SCIP-Interfaces/PySCIPOpt | examples/finished/eoq_en.py | https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/eoq_en.py#L10-L53 | def eoq(I,F,h,d,w,W,a0,aK,K):
"""eoq -- multi-item capacitated economic ordering quantity model
Parameters:
- I: set of items
- F[i]: ordering cost for item i
- h[i]: holding cost for item i
- d[i]: demand for item i
- w[i]: unit weight for item i
- W: capacity (... | [
"def",
"eoq",
"(",
"I",
",",
"F",
",",
"h",
",",
"d",
",",
"w",
",",
"W",
",",
"a0",
",",
"aK",
",",
"K",
")",
":",
"# construct points for piecewise-linear relation, store in a,b",
"a",
",",
"b",
"=",
"{",
"}",
",",
"{",
"}",
"delta",
"=",
"float"... | eoq -- multi-item capacitated economic ordering quantity model
Parameters:
- I: set of items
- F[i]: ordering cost for item i
- h[i]: holding cost for item i
- d[i]: demand for item i
- w[i]: unit weight for item i
- W: capacity (limit on order quantity)
- a0... | [
"eoq",
"--",
"multi",
"-",
"item",
"capacitated",
"economic",
"ordering",
"quantity",
"model",
"Parameters",
":",
"-",
"I",
":",
"set",
"of",
"items",
"-",
"F",
"[",
"i",
"]",
":",
"ordering",
"cost",
"for",
"item",
"i",
"-",
"h",
"[",
"i",
"]",
":... | python | train | 36.840909 |
edx/django-user-tasks | user_tasks/signals.py | https://github.com/edx/django-user-tasks/blob/6a9cf3821f4d8e202e6b48703e6a62e2a889adfb/user_tasks/signals.py#L27-L53 | def create_user_task(sender=None, body=None, **kwargs): # pylint: disable=unused-argument
"""
Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.
Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
the new :py:class:`UserTaskMixin`.
"""
... | [
"def",
"create_user_task",
"(",
"sender",
"=",
"None",
",",
"body",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=unused-argument",
"try",
":",
"task_class",
"=",
"import_string",
"(",
"sender",
")",
"except",
"ImportError",
":",
"return",... | Create a :py:class:`UserTaskStatus` record for each :py:class:`UserTaskMixin`.
Also creates a :py:class:`UserTaskStatus` for each chain, chord, or group containing
the new :py:class:`UserTaskMixin`. | [
"Create",
"a",
":",
"py",
":",
"class",
":",
"UserTaskStatus",
"record",
"for",
"each",
":",
"py",
":",
"class",
":",
"UserTaskMixin",
"."
] | python | train | 50.222222 |
rigetti/quantumflow | examples/weyl.py | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/examples/weyl.py#L100-L162 | def display_weyl(decomps):
"""Construct and display 3D plot of canonical coordinates"""
tx, ty, tz = list(zip(*decomps))
rcParams['axes.labelsize'] = 24
rcParams['font.family'] = 'serif'
rcParams['font.serif'] = ['Computer Modern Roman']
rcParams['text.usetex'] = True
fig = pyplot.figure()
... | [
"def",
"display_weyl",
"(",
"decomps",
")",
":",
"tx",
",",
"ty",
",",
"tz",
"=",
"list",
"(",
"zip",
"(",
"*",
"decomps",
")",
")",
"rcParams",
"[",
"'axes.labelsize'",
"]",
"=",
"24",
"rcParams",
"[",
"'font.family'",
"]",
"=",
"'serif'",
"rcParams",... | Construct and display 3D plot of canonical coordinates | [
"Construct",
"and",
"display",
"3D",
"plot",
"of",
"canonical",
"coordinates"
] | python | train | 35.904762 |
googledatalab/pydatalab | solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/solutionbox/structured_data/mltoolbox/_structured_data/trainer/task.py#L135-L228 | def parse_arguments(argv):
"""Parse the command line arguments."""
parser = argparse.ArgumentParser(
description=('Train a regression or classification model. Note that if '
'using a DNN model, --layer-size1=NUM, --layer-size2=NUM, '
'should be used. '))
# I/O file par... | [
"def",
"parse_arguments",
"(",
"argv",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"(",
"'Train a regression or classification model. Note that if '",
"'using a DNN model, --layer-size1=NUM, --layer-size2=NUM, '",
"'should be used. '",
")"... | Parse the command line arguments. | [
"Parse",
"the",
"command",
"line",
"arguments",
"."
] | python | train | 43.925532 |
emilydolson/avida-spatial-tools | avidaspatial/visualizations.py | https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/visualizations.py#L182-L227 | def plot_phens_circles(phen_grid, **kwargs):
"""
Plots phenotypes represented as concentric circles. Each circle represents
one task that the phenotype can perform, with larger circles representing
more complex tasks.
Arguments: phen_grid - a 2D array of strings representing binary numbers
kwa... | [
"def",
"plot_phens_circles",
"(",
"phen_grid",
",",
"*",
"*",
"kwargs",
")",
":",
"denom",
",",
"palette",
"=",
"get_kwargs",
"(",
"phen_grid",
",",
"kwargs",
",",
"True",
")",
"n_tasks",
"=",
"len",
"(",
"palette",
")",
"grid",
"=",
"phen_grid",
"for",
... | Plots phenotypes represented as concentric circles. Each circle represents
one task that the phenotype can perform, with larger circles representing
more complex tasks.
Arguments: phen_grid - a 2D array of strings representing binary numbers
kwargs:
palette - a seaborn palette (list of ... | [
"Plots",
"phenotypes",
"represented",
"as",
"concentric",
"circles",
".",
"Each",
"circle",
"represents",
"one",
"task",
"that",
"the",
"phenotype",
"can",
"perform",
"with",
"larger",
"circles",
"representing",
"more",
"complex",
"tasks",
"."
] | python | train | 42.065217 |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/bson/__init__.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/__init__.py#L618-L620 | def _encode_timestamp(name, value, dummy0, dummy1):
"""Encode bson.timestamp.Timestamp."""
return b"\x11" + name + _PACK_TIMESTAMP(value.inc, value.time) | [
"def",
"_encode_timestamp",
"(",
"name",
",",
"value",
",",
"dummy0",
",",
"dummy1",
")",
":",
"return",
"b\"\\x11\"",
"+",
"name",
"+",
"_PACK_TIMESTAMP",
"(",
"value",
".",
"inc",
",",
"value",
".",
"time",
")"
] | Encode bson.timestamp.Timestamp. | [
"Encode",
"bson",
".",
"timestamp",
".",
"Timestamp",
"."
] | python | train | 53 |
manns/pyspread | pyspread/src/gui/_grid.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L1016-L1028 | def OnRangeSelected(self, event):
"""Event handler for grid selection"""
# If grid editing is disabled then pyspread is in selection mode
if not self.grid.IsEditable():
selection = self.grid.selection
row, col, __ = self.grid.sel_mode_cursor
if (row, col) in ... | [
"def",
"OnRangeSelected",
"(",
"self",
",",
"event",
")",
":",
"# If grid editing is disabled then pyspread is in selection mode",
"if",
"not",
"self",
".",
"grid",
".",
"IsEditable",
"(",
")",
":",
"selection",
"=",
"self",
".",
"grid",
".",
"selection",
"row",
... | Event handler for grid selection | [
"Event",
"handler",
"for",
"grid",
"selection"
] | python | train | 42.692308 |
BernardFW/bernard | src/bernard/conf/loader.py | https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/conf/loader.py#L84-L94 | def _settings(self) -> Settings:
"""
Return the actual settings object, or create it if missing.
"""
if self.__dict__['__settings'] is None:
self.__dict__['__settings'] = Settings()
for file_path in self._get_files():
if file_path:
... | [
"def",
"_settings",
"(",
"self",
")",
"->",
"Settings",
":",
"if",
"self",
".",
"__dict__",
"[",
"'__settings'",
"]",
"is",
"None",
":",
"self",
".",
"__dict__",
"[",
"'__settings'",
"]",
"=",
"Settings",
"(",
")",
"for",
"file_path",
"in",
"self",
"."... | Return the actual settings object, or create it if missing. | [
"Return",
"the",
"actual",
"settings",
"object",
"or",
"create",
"it",
"if",
"missing",
"."
] | python | train | 41.272727 |
saltstack/salt | salt/modules/lxc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L954-L985 | def _get_veths(net_data):
'''
Parse the nic setup inside lxc conf tuples back to a dictionary indexed by
network interface
'''
if isinstance(net_data, dict):
net_data = list(net_data.items())
nics = salt.utils.odict.OrderedDict()
current_nic = salt.utils.odict.OrderedDict()
no_na... | [
"def",
"_get_veths",
"(",
"net_data",
")",
":",
"if",
"isinstance",
"(",
"net_data",
",",
"dict",
")",
":",
"net_data",
"=",
"list",
"(",
"net_data",
".",
"items",
"(",
")",
")",
"nics",
"=",
"salt",
".",
"utils",
".",
"odict",
".",
"OrderedDict",
"(... | Parse the nic setup inside lxc conf tuples back to a dictionary indexed by
network interface | [
"Parse",
"the",
"nic",
"setup",
"inside",
"lxc",
"conf",
"tuples",
"back",
"to",
"a",
"dictionary",
"indexed",
"by",
"network",
"interface"
] | python | train | 39.46875 |
Yelp/venv-update | venv_update.py | https://github.com/Yelp/venv-update/blob/6feae7ab09ee870c582b97443cfa8f0dc8626ba7/venv_update.py#L163-L175 | def exec_(argv): # never returns
"""Wrapper to os.execv which shows the command and runs any atexit handlers (for coverage's sake).
Like os.execv, this function never returns.
"""
# info('EXEC' + colorize(argv)) # TODO: debug logging by environment variable
# in python3, sys.exitfunc has gone awa... | [
"def",
"exec_",
"(",
"argv",
")",
":",
"# never returns",
"# info('EXEC' + colorize(argv)) # TODO: debug logging by environment variable",
"# in python3, sys.exitfunc has gone away, and atexit._run_exitfuncs seems to be the only pubic-ish interface",
"# https://hg.python.org/cpython/file/3.4/Mo... | Wrapper to os.execv which shows the command and runs any atexit handlers (for coverage's sake).
Like os.execv, this function never returns. | [
"Wrapper",
"to",
"os",
".",
"execv",
"which",
"shows",
"the",
"command",
"and",
"runs",
"any",
"atexit",
"handlers",
"(",
"for",
"coverage",
"s",
"sake",
")",
".",
"Like",
"os",
".",
"execv",
"this",
"function",
"never",
"returns",
"."
] | python | train | 42.230769 |
MoseleyBioinformaticsLab/nmrstarlib | nmrstarlib/plsimulator.py | https://github.com/MoseleyBioinformaticsLab/nmrstarlib/blob/f2adabbca04d5a134ce6ba3211099d1457787ff2/nmrstarlib/plsimulator.py#L131-L142 | def _to_autoassign(self):
"""Save :class:`~nmrstarlib.plsimulator.PeakList` into AutoAssign-formatted string.
:return: Peak list representation in AutoAssign format.
:rtype: :py:class:`str`
"""
autoassign_str = "#Index\t\t{}\t\tIntensity\t\tWorkbook\n".format(
"\t\t"... | [
"def",
"_to_autoassign",
"(",
"self",
")",
":",
"autoassign_str",
"=",
"\"#Index\\t\\t{}\\t\\tIntensity\\t\\tWorkbook\\n\"",
".",
"format",
"(",
"\"\\t\\t\"",
".",
"join",
"(",
"[",
"str",
"(",
"i",
"+",
"1",
")",
"+",
"\"Dim\"",
"for",
"i",
"in",
"range",
"... | Save :class:`~nmrstarlib.plsimulator.PeakList` into AutoAssign-formatted string.
:return: Peak list representation in AutoAssign format.
:rtype: :py:class:`str` | [
"Save",
":",
"class",
":",
"~nmrstarlib",
".",
"plsimulator",
".",
"PeakList",
"into",
"AutoAssign",
"-",
"formatted",
"string",
"."
] | python | train | 54.833333 |
yyuu/botornado | boto/sdb/db/sequence.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/sdb/db/sequence.py#L158-L176 | def set(self, val):
"""Set the value"""
import time
now = time.time()
expected_value = []
new_val = {}
new_val['timestamp'] = now
if self._value != None:
new_val['last_value'] = self._value
expected_value = ['current_value', str(self._value... | [
"def",
"set",
"(",
"self",
",",
"val",
")",
":",
"import",
"time",
"now",
"=",
"time",
".",
"time",
"(",
")",
"expected_value",
"=",
"[",
"]",
"new_val",
"=",
"{",
"}",
"new_val",
"[",
"'timestamp'",
"]",
"=",
"now",
"if",
"self",
".",
"_value",
... | Set the value | [
"Set",
"the",
"value"
] | python | train | 34.473684 |
ashleysommer/sanicpluginsframework | spf/plugin.py | https://github.com/ashleysommer/sanicpluginsframework/blob/2cb1656d9334f04c30c738074784b0450c1b893e/spf/plugin.py#L191-L197 | def first_plugin_context(self):
"""Returns the context is associated with the first app this plugin was
registered on"""
# Note, because registrations are stored in a set, its not _really_
# the first one, but whichever one it sees first in the set.
first_spf_reg = next(iter(sel... | [
"def",
"first_plugin_context",
"(",
"self",
")",
":",
"# Note, because registrations are stored in a set, its not _really_",
"# the first one, but whichever one it sees first in the set.",
"first_spf_reg",
"=",
"next",
"(",
"iter",
"(",
"self",
".",
"registrations",
")",
")",
"... | Returns the context is associated with the first app this plugin was
registered on | [
"Returns",
"the",
"context",
"is",
"associated",
"with",
"the",
"first",
"app",
"this",
"plugin",
"was",
"registered",
"on"
] | python | train | 55.285714 |
ekalinin/marktime.py | marktime.py | https://github.com/ekalinin/marktime.py/blob/111897cfa30f570155bb009ea653ce402457b17d/marktime.py#L123-L135 | def duration(label, stop_it=True, stop_at=None):
"""Returns duration in seconds for label"""
if label not in labels:
return None
if "duration" in labels[label]:
return Duration(labels[label]["duration"])
if stop_it:
return stop(label, at=stop_at)
else:
return None | [
"def",
"duration",
"(",
"label",
",",
"stop_it",
"=",
"True",
",",
"stop_at",
"=",
"None",
")",
":",
"if",
"label",
"not",
"in",
"labels",
":",
"return",
"None",
"if",
"\"duration\"",
"in",
"labels",
"[",
"label",
"]",
":",
"return",
"Duration",
"(",
... | Returns duration in seconds for label | [
"Returns",
"duration",
"in",
"seconds",
"for",
"label"
] | python | train | 23.615385 |
reingart/gui2py | gui/resource.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/resource.py#L34-L38 | def save(filename, rsrc):
"Save the resource to the source file"
s = pprint.pformat(rsrc)
## s = s.encode("utf8")
open(filename, "w").write(s) | [
"def",
"save",
"(",
"filename",
",",
"rsrc",
")",
":",
"s",
"=",
"pprint",
".",
"pformat",
"(",
"rsrc",
")",
"## s = s.encode(\"utf8\")",
"open",
"(",
"filename",
",",
"\"w\"",
")",
".",
"write",
"(",
"s",
")"
] | Save the resource to the source file | [
"Save",
"the",
"resource",
"to",
"the",
"source",
"file"
] | python | test | 30.8 |
pyviz/holoviews | holoviews/plotting/mpl/plot.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/mpl/plot.py#L775-L980 | def _compute_gridspec(self, layout):
"""
Computes the tallest and widest cell for each row and column
by examining the Layouts in the GridSpace. The GridSpec is then
instantiated and the LayoutPlots are configured with the
appropriate embedded layout_types. The first element of t... | [
"def",
"_compute_gridspec",
"(",
"self",
",",
"layout",
")",
":",
"layout_items",
"=",
"layout",
".",
"grid_items",
"(",
")",
"layout_dimensions",
"=",
"layout",
".",
"kdims",
"if",
"isinstance",
"(",
"layout",
",",
"NdLayout",
")",
"else",
"None",
"layouts"... | Computes the tallest and widest cell for each row and column
by examining the Layouts in the GridSpace. The GridSpec is then
instantiated and the LayoutPlots are configured with the
appropriate embedded layout_types. The first element of the
returned tuple is a dictionary of all the Layo... | [
"Computes",
"the",
"tallest",
"and",
"widest",
"cell",
"for",
"each",
"row",
"and",
"column",
"by",
"examining",
"the",
"Layouts",
"in",
"the",
"GridSpace",
".",
"The",
"GridSpec",
"is",
"then",
"instantiated",
"and",
"the",
"LayoutPlots",
"are",
"configured",... | python | train | 46.674757 |
SUNCAT-Center/CatHub | cathub/classification.py | https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/classification.py#L260-L276 | def get_under_bridge(self):
"""Return element closest to the adsorbate in the subsurface layer"""
C0 = self.B[-1:] * (3, 3, 1)
ads_pos = C0.positions[4]
C = self.get_subsurface_layer() * (3, 3, 1)
dis = self.B.cell[0][0] * 2
ret = None
for ele in C:
... | [
"def",
"get_under_bridge",
"(",
"self",
")",
":",
"C0",
"=",
"self",
".",
"B",
"[",
"-",
"1",
":",
"]",
"*",
"(",
"3",
",",
"3",
",",
"1",
")",
"ads_pos",
"=",
"C0",
".",
"positions",
"[",
"4",
"]",
"C",
"=",
"self",
".",
"get_subsurface_layer"... | Return element closest to the adsorbate in the subsurface layer | [
"Return",
"element",
"closest",
"to",
"the",
"adsorbate",
"in",
"the",
"subsurface",
"layer"
] | python | train | 27.411765 |
dixudx/rtcclient | rtcclient/workitem.py | https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/workitem.py#L760-L797 | def addAttachment(self, filepath):
"""Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment
"""
proj_id = self.contextId
fa = self.rtc_obj.getFiledA... | [
"def",
"addAttachment",
"(",
"self",
",",
"filepath",
")",
":",
"proj_id",
"=",
"self",
".",
"contextId",
"fa",
"=",
"self",
".",
"rtc_obj",
".",
"getFiledAgainst",
"(",
"self",
".",
"filedAgainst",
",",
"projectarea_id",
"=",
"proj_id",
")",
"fa_id",
"=",... | Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment | [
"Upload",
"attachment",
"to",
"a",
"workitem"
] | python | train | 39.315789 |
tnkteja/myhelp | virtualEnvironment/lib/python2.7/site-packages/coverage/__init__.py | https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/__init__.py#L26-L61 | def _singleton_method(name):
"""Return a function to the `name` method on a singleton `coverage` object.
The singleton object is created the first time one of these functions is
called.
"""
# Disable pylint msg W0612, because a bunch of variables look unused, but
# they're accessed via locals(... | [
"def",
"_singleton_method",
"(",
"name",
")",
":",
"# Disable pylint msg W0612, because a bunch of variables look unused, but",
"# they're accessed via locals().",
"# pylint: disable=W0612",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Singlet... | Return a function to the `name` method on a singleton `coverage` object.
The singleton object is created the first time one of these functions is
called. | [
"Return",
"a",
"function",
"to",
"the",
"name",
"method",
"on",
"a",
"singleton",
"coverage",
"object",
"."
] | python | test | 31.277778 |
tensorflow/datasets | tensorflow_datasets/text/cnn_dailymail.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/text/cnn_dailymail.py#L111-L126 | def _find_files(dl_paths, publisher, url_dict):
"""Find files corresponding to urls."""
if publisher == 'cnn':
top_dir = os.path.join(dl_paths['cnn_stories'], 'cnn', 'stories')
elif publisher == 'dm':
top_dir = os.path.join(dl_paths['dm_stories'], 'dailymail', 'stories')
else:
logging.fatal('Unsuppo... | [
"def",
"_find_files",
"(",
"dl_paths",
",",
"publisher",
",",
"url_dict",
")",
":",
"if",
"publisher",
"==",
"'cnn'",
":",
"top_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dl_paths",
"[",
"'cnn_stories'",
"]",
",",
"'cnn'",
",",
"'stories'",
")",
... | Find files corresponding to urls. | [
"Find",
"files",
"corresponding",
"to",
"urls",
"."
] | python | train | 35.625 |
ronaldguillen/wave | wave/renderers.py | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/renderers.py#L667-L685 | def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Render the HTML for the browsable API representation.
"""
self.accepted_media_type = accepted_media_type or ''
self.renderer_context = renderer_context or {}
template = loader.get_template(self.... | [
"def",
"render",
"(",
"self",
",",
"data",
",",
"accepted_media_type",
"=",
"None",
",",
"renderer_context",
"=",
"None",
")",
":",
"self",
".",
"accepted_media_type",
"=",
"accepted_media_type",
"or",
"''",
"self",
".",
"renderer_context",
"=",
"renderer_contex... | Render the HTML for the browsable API representation. | [
"Render",
"the",
"HTML",
"for",
"the",
"browsable",
"API",
"representation",
"."
] | python | train | 45.421053 |
jazzband/django-mongonaut | mongonaut/mixins.py | https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L67-L84 | def get_mongoadmins(self):
""" Returns a list of all mongoadmin implementations for the site """
apps = []
for app_name in settings.INSTALLED_APPS:
mongoadmin = "{0}.mongoadmin".format(app_name)
try:
module = import_module(mongoadmin)
except Im... | [
"def",
"get_mongoadmins",
"(",
"self",
")",
":",
"apps",
"=",
"[",
"]",
"for",
"app_name",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"mongoadmin",
"=",
"\"{0}.mongoadmin\"",
".",
"format",
"(",
"app_name",
")",
"try",
":",
"module",
"=",
"import_module",... | Returns a list of all mongoadmin implementations for the site | [
"Returns",
"a",
"list",
"of",
"all",
"mongoadmin",
"implementations",
"for",
"the",
"site"
] | python | valid | 33.333333 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/interactive.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/interactive.py#L1206-L1225 | def do_quit(self, arg):
"""
quit - close the debugging session
q - close the debugging session
"""
if self.cmdprefix:
raise CmdError("prefix not allowed")
if arg:
raise CmdError("too many arguments")
if self.confirm_quit:
count ... | [
"def",
"do_quit",
"(",
"self",
",",
"arg",
")",
":",
"if",
"self",
".",
"cmdprefix",
":",
"raise",
"CmdError",
"(",
"\"prefix not allowed\"",
")",
"if",
"arg",
":",
"raise",
"CmdError",
"(",
"\"too many arguments\"",
")",
"if",
"self",
".",
"confirm_quit",
... | quit - close the debugging session
q - close the debugging session | [
"quit",
"-",
"close",
"the",
"debugging",
"session",
"q",
"-",
"close",
"the",
"debugging",
"session"
] | python | train | 33.75 |
optimizely/python-sdk | optimizely/project_config.py | https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L434-L476 | def get_variable_value_for_variation(self, variable, variation):
""" Get the variable value for the given variation.
Args:
variable: The Variable for which we are getting the value.
variation: The Variation for which we are getting the variable value.
Returns:
The variable value or None ... | [
"def",
"get_variable_value_for_variation",
"(",
"self",
",",
"variable",
",",
"variation",
")",
":",
"if",
"not",
"variable",
"or",
"not",
"variation",
":",
"return",
"None",
"if",
"variation",
".",
"id",
"not",
"in",
"self",
".",
"variation_variable_usage_map",... | Get the variable value for the given variation.
Args:
variable: The Variable for which we are getting the value.
variation: The Variation for which we are getting the variable value.
Returns:
The variable value or None if any of the inputs are invalid. | [
"Get",
"the",
"variable",
"value",
"for",
"the",
"given",
"variation",
"."
] | python | train | 30.325581 |
gitpython-developers/GitPython | git/repo/base.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/repo/base.py#L438-L457 | def config_reader(self, config_level=None):
"""
:return:
GitConfigParser allowing to read the full git configuration, but not to write it
The configuration will include values from the system, user and repository
configuration files.
:param config_level:
... | [
"def",
"config_reader",
"(",
"self",
",",
"config_level",
"=",
"None",
")",
":",
"files",
"=",
"None",
"if",
"config_level",
"is",
"None",
":",
"files",
"=",
"[",
"self",
".",
"_get_config_path",
"(",
"f",
")",
"for",
"f",
"in",
"self",
".",
"config_le... | :return:
GitConfigParser allowing to read the full git configuration, but not to write it
The configuration will include values from the system, user and repository
configuration files.
:param config_level:
For possible values, see config_writer method
... | [
":",
"return",
":",
"GitConfigParser",
"allowing",
"to",
"read",
"the",
"full",
"git",
"configuration",
"but",
"not",
"to",
"write",
"it"
] | python | train | 46.2 |
numenta/nupic | src/nupic/swarming/hypersearch_v2.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch_v2.py#L1162-L1388 | def _readPermutationsFile(self, filename, modelDescription):
"""
Read the permutations file and initialize the following member variables:
_predictedField: field name of the field we are trying to
predict
_permutations: Dict containing the full permutations dictionary.
_flatten... | [
"def",
"_readPermutationsFile",
"(",
"self",
",",
"filename",
",",
"modelDescription",
")",
":",
"# Open and execute the permutations file",
"vars",
"=",
"{",
"}",
"permFile",
"=",
"execfile",
"(",
"filename",
",",
"globals",
"(",
")",
",",
"vars",
")",
"# Read ... | Read the permutations file and initialize the following member variables:
_predictedField: field name of the field we are trying to
predict
_permutations: Dict containing the full permutations dictionary.
_flattenedPermutations: Dict containing the flattened version of
_permu... | [
"Read",
"the",
"permutations",
"file",
"and",
"initialize",
"the",
"following",
"member",
"variables",
":",
"_predictedField",
":",
"field",
"name",
"of",
"the",
"field",
"we",
"are",
"trying",
"to",
"predict",
"_permutations",
":",
"Dict",
"containing",
"the",
... | python | valid | 45.859031 |
geophysics-ubonn/crtomo_tools | src/sd_plot.py | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sd_plot.py#L214-L231 | def load_grid(self, alpha):
'''Load grid and calculate alpha values from the coverage/2.5.
'''
grid = CRGrid.crt_grid(self.dirs[0] + '/grid/elem.dat',
self.dirs[0] + '/grid/elec.dat')
self.plotman = CRPlot.plotManager(grid=grid)
name = self.dirs[0]... | [
"def",
"load_grid",
"(",
"self",
",",
"alpha",
")",
":",
"grid",
"=",
"CRGrid",
".",
"crt_grid",
"(",
"self",
".",
"dirs",
"[",
"0",
"]",
"+",
"'/grid/elem.dat'",
",",
"self",
".",
"dirs",
"[",
"0",
"]",
"+",
"'/grid/elec.dat'",
")",
"self",
".",
"... | Load grid and calculate alpha values from the coverage/2.5. | [
"Load",
"grid",
"and",
"calculate",
"alpha",
"values",
"from",
"the",
"coverage",
"/",
"2",
".",
"5",
"."
] | python | train | 43.111111 |
Brazelton-Lab/bio_utils | bio_utils/verifiers/b6.py | https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/verifiers/b6.py#L45-L123 | def b6_verifier(entries, line=None):
"""Raises error if invalid B6/M8 format detected
Args:
entries (list): A list of B6Entry instances
line (int): Line number of first entry
Raises:
FormatError: Error when B6/M8 format incorrect with descriptive message
Example:
>>> ... | [
"def",
"b6_verifier",
"(",
"entries",
",",
"line",
"=",
"None",
")",
":",
"regex",
"=",
"r'^.+\\t.+\\t\\d+\\.?\\d*\\t\\d+\\t\\d+\\t\\d+\\t\\d+\\t\\d+\\t\\d+\\t\\d+\\t'",
"+",
"r'\\d+\\.?\\d*(e-)?\\d*\\t\\d+\\.?\\d*{0}$'",
".",
"format",
"(",
"os",
".",
"linesep",
")",
"de... | Raises error if invalid B6/M8 format detected
Args:
entries (list): A list of B6Entry instances
line (int): Line number of first entry
Raises:
FormatError: Error when B6/M8 format incorrect with descriptive message
Example:
>>> from bio_utils.iterators import b6_iter
... | [
"Raises",
"error",
"if",
"invalid",
"B6",
"/",
"M8",
"format",
"detected"
] | python | train | 40.253165 |
DLR-RM/RAFCON | source/rafcon/gui/models/auto_backup.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/auto_backup.py#L92-L98 | def move_dirty_lock_file(dirty_lock_file, sm_path):
""" Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore """
if dirty_lock_file is not None \
and not dirty_lock_file == os.path.join(sm_path, dirty_lock_file.split(os.sep)[-1]):
logger.debug("M... | [
"def",
"move_dirty_lock_file",
"(",
"dirty_lock_file",
",",
"sm_path",
")",
":",
"if",
"dirty_lock_file",
"is",
"not",
"None",
"and",
"not",
"dirty_lock_file",
"==",
"os",
".",
"path",
".",
"join",
"(",
"sm_path",
",",
"dirty_lock_file",
".",
"split",
"(",
"... | Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore | [
"Move",
"the",
"dirt_lock",
"file",
"to",
"the",
"sm_path",
"and",
"thereby",
"is",
"not",
"found",
"by",
"auto",
"recovery",
"of",
"backup",
"anymore"
] | python | train | 83.142857 |
slundberg/shap | shap/benchmark/methods.py | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L35-L40 | def kernel_shap_1000_meanref(model, data):
""" Kernel SHAP 1000 mean ref.
color = red_blue_circle(0.5)
linestyle = solid
"""
return lambda X: KernelExplainer(model.predict, kmeans(data, 1)).shap_values(X, nsamples=1000, l1_reg=0) | [
"def",
"kernel_shap_1000_meanref",
"(",
"model",
",",
"data",
")",
":",
"return",
"lambda",
"X",
":",
"KernelExplainer",
"(",
"model",
".",
"predict",
",",
"kmeans",
"(",
"data",
",",
"1",
")",
")",
".",
"shap_values",
"(",
"X",
",",
"nsamples",
"=",
"... | Kernel SHAP 1000 mean ref.
color = red_blue_circle(0.5)
linestyle = solid | [
"Kernel",
"SHAP",
"1000",
"mean",
"ref",
".",
"color",
"=",
"red_blue_circle",
"(",
"0",
".",
"5",
")",
"linestyle",
"=",
"solid"
] | python | train | 40.666667 |
TaurusOlson/fntools | fntools/fntools.py | https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L213-L232 | def reductions(fn, seq, acc=None):
"""Return the intermediate values of a reduction
:param fn: a function
:param seq: a sequence
:param acc: the accumulator
:returns: a list
>>> reductions(lambda x, y: x + y, [1, 2, 3])
[1, 3, 6]
>>> reductions(lambda x, y: x + y, [1, 2, 3], 10)
[... | [
"def",
"reductions",
"(",
"fn",
",",
"seq",
",",
"acc",
"=",
"None",
")",
":",
"indexes",
"=",
"xrange",
"(",
"len",
"(",
"seq",
")",
")",
"if",
"acc",
":",
"return",
"map",
"(",
"lambda",
"i",
":",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
... | Return the intermediate values of a reduction
:param fn: a function
:param seq: a sequence
:param acc: the accumulator
:returns: a list
>>> reductions(lambda x, y: x + y, [1, 2, 3])
[1, 3, 6]
>>> reductions(lambda x, y: x + y, [1, 2, 3], 10)
[11, 13, 16] | [
"Return",
"the",
"intermediate",
"values",
"of",
"a",
"reduction"
] | python | train | 26.95 |
gwastro/pycbc | pycbc/results/scatter_histograms.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/results/scatter_histograms.py#L146-L159 | def construct_kde(samples_array, use_kombine=False):
"""Constructs a KDE from the given samples.
"""
if use_kombine:
try:
import kombine
except ImportError:
raise ImportError("kombine is not installed.")
# construct the kde
if use_kombine:
kde = kombin... | [
"def",
"construct_kde",
"(",
"samples_array",
",",
"use_kombine",
"=",
"False",
")",
":",
"if",
"use_kombine",
":",
"try",
":",
"import",
"kombine",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"\"kombine is not installed.\"",
")",
"# construct the kde... | Constructs a KDE from the given samples. | [
"Constructs",
"a",
"KDE",
"from",
"the",
"given",
"samples",
"."
] | python | train | 30.142857 |
dmlc/gluon-nlp | src/gluonnlp/embedding/evaluation.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/embedding/evaluation.py#L501-L518 | def hybrid_forward(self, F, words1, words2, words3): # pylint: disable=arguments-differ, unused-argument
"""Compute analogies for given question words.
Parameters
----------
words1 : Symbol or NDArray
Word indices of first question words. Shape (batch_size, ).
words... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"words1",
",",
"words2",
",",
"words3",
")",
":",
"# pylint: disable=arguments-differ, unused-argument",
"return",
"self",
".",
"analogy",
"(",
"words1",
",",
"words2",
",",
"words3",
")"
] | Compute analogies for given question words.
Parameters
----------
words1 : Symbol or NDArray
Word indices of first question words. Shape (batch_size, ).
words2 : Symbol or NDArray
Word indices of second question words. Shape (batch_size, ).
words3 : Symbo... | [
"Compute",
"analogies",
"for",
"given",
"question",
"words",
"."
] | python | train | 39.722222 |
jamieleshaw/lurklib | lurklib/__init__.py | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/__init__.py#L27-L84 | def process_once(self, timeout=0.01):
"""
Handles an event and calls it's handler
Optional arguments:
* timeout=0.01 - Wait for an event until the timeout is reached.
"""
try:
event = self.recv(timeout)
if event:
event_t = event[0]
... | [
"def",
"process_once",
"(",
"self",
",",
"timeout",
"=",
"0.01",
")",
":",
"try",
":",
"event",
"=",
"self",
".",
"recv",
"(",
"timeout",
")",
"if",
"event",
":",
"event_t",
"=",
"event",
"[",
"0",
"]",
"event_c",
"=",
"event",
"[",
"1",
"]",
"if... | Handles an event and calls it's handler
Optional arguments:
* timeout=0.01 - Wait for an event until the timeout is reached. | [
"Handles",
"an",
"event",
"and",
"calls",
"it",
"s",
"handler",
"Optional",
"arguments",
":",
"*",
"timeout",
"=",
"0",
".",
"01",
"-",
"Wait",
"for",
"an",
"event",
"until",
"the",
"timeout",
"is",
"reached",
"."
] | python | train | 44.310345 |
mastro35/flows | flows/FlowsManager.py | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/FlowsManager.py#L130-L140 | def _start_actions(self):
"""
Start all the actions for the recipes
"""
Global.LOGGER.info("starting actions")
for recipe in Global.CONFIG_MANAGER.recipes:
Global.CONFIG_MANAGER.read_recipe(recipe)
list(map(lambda section: self._start_action_for_section(
... | [
"def",
"_start_actions",
"(",
"self",
")",
":",
"Global",
".",
"LOGGER",
".",
"info",
"(",
"\"starting actions\"",
")",
"for",
"recipe",
"in",
"Global",
".",
"CONFIG_MANAGER",
".",
"recipes",
":",
"Global",
".",
"CONFIG_MANAGER",
".",
"read_recipe",
"(",
"re... | Start all the actions for the recipes | [
"Start",
"all",
"the",
"actions",
"for",
"the",
"recipes"
] | python | train | 32.818182 |
epfl-lts2/pygsp | pygsp/graphs/_io.py | https://github.com/epfl-lts2/pygsp/blob/8ce5bde39206129287375af24fdbcd7edddca8c5/pygsp/graphs/_io.py#L333-L403 | def from_graphtool(cls, graph, weight='weight'):
r"""Import a graph from graph-tool.
Edge weights are retrieved as an edge property,
under the name specified by the ``weight`` parameter.
Signals are retrieved from node properties,
and stored in the :attr:`signals` dictionary un... | [
"def",
"from_graphtool",
"(",
"cls",
",",
"graph",
",",
"weight",
"=",
"'weight'",
")",
":",
"gt",
"=",
"_import_graphtool",
"(",
")",
"import",
"graph_tool",
".",
"spectral",
"from",
".",
"graph",
"import",
"Graph",
"weight",
"=",
"graph",
".",
"edge_prop... | r"""Import a graph from graph-tool.
Edge weights are retrieved as an edge property,
under the name specified by the ``weight`` parameter.
Signals are retrieved from node properties,
and stored in the :attr:`signals` dictionary under the property name.
`N`-dimensional signals th... | [
"r",
"Import",
"a",
"graph",
"from",
"graph",
"-",
"tool",
"."
] | python | train | 32.957746 |
backbohne/docx-xslt | docxxslt/engines.py | https://github.com/backbohne/docx-xslt/blob/d4cc76776a75b8213660c3c1717d42afe5189e15/docxxslt/engines.py#L39-L43 | def root(self, value):
"""Set new XML tree"""
self._xml = t2s(value)
self._root = value | [
"def",
"root",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_xml",
"=",
"t2s",
"(",
"value",
")",
"self",
".",
"_root",
"=",
"value"
] | Set new XML tree | [
"Set",
"new",
"XML",
"tree"
] | python | train | 21.6 |
fhcrc/taxtastic | taxtastic/refpkg.py | https://github.com/fhcrc/taxtastic/blob/4e874b7f2cc146178828bfba386314f8c342722b/taxtastic/refpkg.py#L443-L452 | def update_metadata(self, key, value):
"""Set *key* in the metadata to *value*.
Returns the previous value of *key*, or None if the key was
not previously set.
"""
old_value = self.contents['metadata'].get(key)
self.contents['metadata'][key] = value
self._log('Up... | [
"def",
"update_metadata",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"old_value",
"=",
"self",
".",
"contents",
"[",
"'metadata'",
"]",
".",
"get",
"(",
"key",
")",
"self",
".",
"contents",
"[",
"'metadata'",
"]",
"[",
"key",
"]",
"=",
"value",... | Set *key* in the metadata to *value*.
Returns the previous value of *key*, or None if the key was
not previously set. | [
"Set",
"*",
"key",
"*",
"in",
"the",
"metadata",
"to",
"*",
"value",
"*",
"."
] | python | train | 37.4 |
MartinThoma/mpu | mpu/io.py | https://github.com/MartinThoma/mpu/blob/61bc36d0192ca90c0bcf9b8a5d7d0d8520e20ff6/mpu/io.py#L277-L306 | def hash(filepath, method='sha1', buffer_size=65536):
"""
Calculate a hash of a local file.
Parameters
----------
filepath : str
method : {'sha1', 'md5'}
buffer_size : int, optional (default: 65536 byte = 64 KiB)
in byte
Returns
-------
hash : str
"""
if method ... | [
"def",
"hash",
"(",
"filepath",
",",
"method",
"=",
"'sha1'",
",",
"buffer_size",
"=",
"65536",
")",
":",
"if",
"method",
"==",
"'sha1'",
":",
"hash_function",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"elif",
"method",
"==",
"'md5'",
":",
"hash_function",
... | Calculate a hash of a local file.
Parameters
----------
filepath : str
method : {'sha1', 'md5'}
buffer_size : int, optional (default: 65536 byte = 64 KiB)
in byte
Returns
-------
hash : str | [
"Calculate",
"a",
"hash",
"of",
"a",
"local",
"file",
"."
] | python | train | 26.233333 |
nicolargo/glances | glances/plugins/glances_plugin.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L311-L364 | def get_stats_snmp(self, bulk=False, snmp_oid=None):
"""Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request.
"""
snmp_oid = snmp_oid or {}
from glances.snmp import GlancesSNMPClient
# Init the SNMP request
clientsnmp = GlancesSNMP... | [
"def",
"get_stats_snmp",
"(",
"self",
",",
"bulk",
"=",
"False",
",",
"snmp_oid",
"=",
"None",
")",
":",
"snmp_oid",
"=",
"snmp_oid",
"or",
"{",
"}",
"from",
"glances",
".",
"snmp",
"import",
"GlancesSNMPClient",
"# Init the SNMP request",
"clientsnmp",
"=",
... | Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request. | [
"Update",
"stats",
"using",
"SNMP",
"."
] | python | train | 39.833333 |
dokterbob/django-multilingual-model | multilingual_model/forms.py | https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/forms.py#L68-L94 | def _get_default_language(self):
"""
If a default language has been set, and is still available in
`self.available_languages`, return it and remove it from the list.
If not, simply pop the first available language.
"""
assert hasattr(self, 'available_languages'), \
... | [
"def",
"_get_default_language",
"(",
"self",
")",
":",
"assert",
"hasattr",
"(",
"self",
",",
"'available_languages'",
")",
",",
"'No available languages have been generated.'",
"assert",
"len",
"(",
"self",
".",
"available_languages",
")",
">",
"0",
",",
"'No avail... | If a default language has been set, and is still available in
`self.available_languages`, return it and remove it from the list.
If not, simply pop the first available language. | [
"If",
"a",
"default",
"language",
"has",
"been",
"set",
"and",
"is",
"still",
"available",
"in",
"self",
".",
"available_languages",
"return",
"it",
"and",
"remove",
"it",
"from",
"the",
"list",
"."
] | python | train | 34.703704 |
graphql-python/graphql-core-next | graphql/execution/execute.py | https://github.com/graphql-python/graphql-core-next/blob/073dce3f002f897d40f9348ffd8f107815160540/graphql/execution/execute.py#L1155-L1175 | def default_field_resolver(source, info, **args):
"""Default field resolver.
If a resolve function is not given, then a default resolve behavior is used which
takes the property of the source object of the same name as the field and returns
it as the result, or if it's a function, returns the result of... | [
"def",
"default_field_resolver",
"(",
"source",
",",
"info",
",",
"*",
"*",
"args",
")",
":",
"# Ensure source is a value for which property access is acceptable.",
"field_name",
"=",
"info",
".",
"field_name",
"value",
"=",
"(",
"source",
".",
"get",
"(",
"field_na... | Default field resolver.
If a resolve function is not given, then a default resolve behavior is used which
takes the property of the source object of the same name as the field and returns
it as the result, or if it's a function, returns the result of calling that function
while passing along args and c... | [
"Default",
"field",
"resolver",
"."
] | python | train | 38.285714 |
defnull/contexter | contexter.py | https://github.com/defnull/contexter/blob/12113375bd748f40a8a26e59847dbe291b957c0d/contexter.py#L158-L162 | def pop_all(self):
""" Preserve the context stack by transferring it to a new instance """
ret = ExitStack()
ret._context_stack.append(self._context_stack.pop())
self._context_stack.append([]) | [
"def",
"pop_all",
"(",
"self",
")",
":",
"ret",
"=",
"ExitStack",
"(",
")",
"ret",
".",
"_context_stack",
".",
"append",
"(",
"self",
".",
"_context_stack",
".",
"pop",
"(",
")",
")",
"self",
".",
"_context_stack",
".",
"append",
"(",
"[",
"]",
")"
] | Preserve the context stack by transferring it to a new instance | [
"Preserve",
"the",
"context",
"stack",
"by",
"transferring",
"it",
"to",
"a",
"new",
"instance"
] | python | train | 44 |
zeth/inputs | inputs.py | https://github.com/zeth/inputs/blob/a46681dbf77d6ab07834f550e5855c1f50701f99/inputs.py#L3350-L3354 | def _find_by(self, key):
"""Find devices."""
by_path = glob.glob('/dev/input/by-{key}/*-event-*'.format(key=key))
for device_path in by_path:
self._parse_device_path(device_path) | [
"def",
"_find_by",
"(",
"self",
",",
"key",
")",
":",
"by_path",
"=",
"glob",
".",
"glob",
"(",
"'/dev/input/by-{key}/*-event-*'",
".",
"format",
"(",
"key",
"=",
"key",
")",
")",
"for",
"device_path",
"in",
"by_path",
":",
"self",
".",
"_parse_device_path... | Find devices. | [
"Find",
"devices",
"."
] | python | train | 42 |
pyviz/holoviews | holoviews/ipython/archive.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/ipython/archive.py#L225-L274 | def _export_with_html(self): # pragma: no cover
"Computes substitutions before using nbconvert with preprocessors"
self.export_success = False
try:
tstamp = time.strftime(self.timestamp_format, self._timestamp)
substitutions = {}
for (basena... | [
"def",
"_export_with_html",
"(",
"self",
")",
":",
"# pragma: no cover",
"self",
".",
"export_success",
"=",
"False",
"try",
":",
"tstamp",
"=",
"time",
".",
"strftime",
"(",
"self",
".",
"timestamp_format",
",",
"self",
".",
"_timestamp",
")",
"substitutions"... | Computes substitutions before using nbconvert with preprocessors | [
"Computes",
"substitutions",
"before",
"using",
"nbconvert",
"with",
"preprocessors"
] | python | train | 54.48 |
saltstack/salt | salt/modules/lxc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2109-L2147 | def ls_(active=None, cache=True, path=None):
'''
Return a list of the containers available on the minion
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
active
If ``True``, return only active (i.e. running) containe... | [
"def",
"ls_",
"(",
"active",
"=",
"None",
",",
"cache",
"=",
"True",
",",
"path",
"=",
"None",
")",
":",
"contextvar",
"=",
"'lxc.ls{0}'",
".",
"format",
"(",
"path",
")",
"if",
"active",
":",
"contextvar",
"+=",
"'.active'",
"if",
"cache",
"and",
"(... | Return a list of the containers available on the minion
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
active
If ``True``, return only active (i.e. running) containers
.. versionadded:: 2015.5.0
CLI Example:
... | [
"Return",
"a",
"list",
"of",
"the",
"containers",
"available",
"on",
"the",
"minion"
] | python | train | 25.205128 |
chrisrink10/basilisp | src/basilisp/lang/compiler/generator.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1909-L1924 | def _interop_prop_to_py_ast(
ctx: GeneratorContext, node: HostField, is_assigning: bool = False
) -> GeneratedPyAST:
"""Generate a Python AST node for Python interop property access."""
assert node.op == NodeOp.HOST_FIELD
target_ast = gen_py_ast(ctx, node.target)
return GeneratedPyAST(
nod... | [
"def",
"_interop_prop_to_py_ast",
"(",
"ctx",
":",
"GeneratorContext",
",",
"node",
":",
"HostField",
",",
"is_assigning",
":",
"bool",
"=",
"False",
")",
"->",
"GeneratedPyAST",
":",
"assert",
"node",
".",
"op",
"==",
"NodeOp",
".",
"HOST_FIELD",
"target_ast"... | Generate a Python AST node for Python interop property access. | [
"Generate",
"a",
"Python",
"AST",
"node",
"for",
"Python",
"interop",
"property",
"access",
"."
] | python | test | 32.25 |
kennethreitz/requests-html | requests_html.py | https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L154-L164 | def lxml(self) -> HtmlElement:
"""`lxml <http://lxml.de>`_ representation of the
:class:`Element <Element>` or :class:`HTML <HTML>`.
"""
if self._lxml is None:
try:
self._lxml = soup_parse(self.html, features='html.parser')
except ValueError:
... | [
"def",
"lxml",
"(",
"self",
")",
"->",
"HtmlElement",
":",
"if",
"self",
".",
"_lxml",
"is",
"None",
":",
"try",
":",
"self",
".",
"_lxml",
"=",
"soup_parse",
"(",
"self",
".",
"html",
",",
"features",
"=",
"'html.parser'",
")",
"except",
"ValueError",... | `lxml <http://lxml.de>`_ representation of the
:class:`Element <Element>` or :class:`HTML <HTML>`. | [
"lxml",
"<http",
":",
"//",
"lxml",
".",
"de",
">",
"_",
"representation",
"of",
"the",
":",
"class",
":",
"Element",
"<Element",
">",
"or",
":",
"class",
":",
"HTML",
"<HTML",
">",
"."
] | python | train | 36 |
zhemao/funktown | funktown/dictionary.py | https://github.com/zhemao/funktown/blob/8d5c5a8bdad2b85b33b4cea3febd820c2657c375/funktown/dictionary.py#L22-L28 | def assoc(self, key, value):
'''Returns a new ImmutableDict instance with value associated with key.
The implicit parameter is not modified.'''
copydict = ImmutableDict()
copydict.tree = self.tree.assoc(hash(key), (key, value))
copydict._length = self._length + 1
return c... | [
"def",
"assoc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"copydict",
"=",
"ImmutableDict",
"(",
")",
"copydict",
".",
"tree",
"=",
"self",
".",
"tree",
".",
"assoc",
"(",
"hash",
"(",
"key",
")",
",",
"(",
"key",
",",
"value",
")",
")",
... | Returns a new ImmutableDict instance with value associated with key.
The implicit parameter is not modified. | [
"Returns",
"a",
"new",
"ImmutableDict",
"instance",
"with",
"value",
"associated",
"with",
"key",
".",
"The",
"implicit",
"parameter",
"is",
"not",
"modified",
"."
] | python | train | 45.857143 |
numenta/nupic | src/nupic/data/generators/sequence_machine.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/sequence_machine.py#L50-L69 | def generateFromNumbers(self, numbers):
"""
Generate a sequence from a list of numbers.
Note: Any `None` in the list of numbers is considered a reset.
@param numbers (list) List of numbers
@return (list) Generated sequence
"""
sequence = []
for number in numbers:
if number == N... | [
"def",
"generateFromNumbers",
"(",
"self",
",",
"numbers",
")",
":",
"sequence",
"=",
"[",
"]",
"for",
"number",
"in",
"numbers",
":",
"if",
"number",
"==",
"None",
":",
"sequence",
".",
"append",
"(",
"number",
")",
"else",
":",
"pattern",
"=",
"self"... | Generate a sequence from a list of numbers.
Note: Any `None` in the list of numbers is considered a reset.
@param numbers (list) List of numbers
@return (list) Generated sequence | [
"Generate",
"a",
"sequence",
"from",
"a",
"list",
"of",
"numbers",
"."
] | python | valid | 22.65 |
stevearc/dql | dql/models.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/models.py#L10-L15 | def format_throughput(available, used=None):
""" Format the read/write throughput for display """
if used is None:
return str(available)
percent = float(used) / available
return "{0:.0f}/{1:.0f} ({2:.0%})".format(used, available, percent) | [
"def",
"format_throughput",
"(",
"available",
",",
"used",
"=",
"None",
")",
":",
"if",
"used",
"is",
"None",
":",
"return",
"str",
"(",
"available",
")",
"percent",
"=",
"float",
"(",
"used",
")",
"/",
"available",
"return",
"\"{0:.0f}/{1:.0f} ({2:.0%})\"",... | Format the read/write throughput for display | [
"Format",
"the",
"read",
"/",
"write",
"throughput",
"for",
"display"
] | python | train | 42.833333 |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L228-L278 | def _build_unicode_character_database(self):
"""
Function for parsing the Unicode character data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
filename = "Uni... | [
"def",
"_build_unicode_character_database",
"(",
"self",
")",
":",
"filename",
"=",
"\"UnicodeData.txt\"",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"tag",
"=",
"re",
".",
"com... | Function for parsing the Unicode character data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/ | [
"Function",
"for",
"parsing",
"the",
"Unicode",
"character",
"data",
"from",
"the",
"Unicode",
"Character",
"Database",
"(",
"UCD",
")",
"and",
"generating",
"a",
"lookup",
"table",
".",
"For",
"more",
"info",
"on",
"the",
"UCD",
"see",
"the",
"following",
... | python | train | 63.901961 |
senaite/senaite.core | bika/lims/utils/analysisrequest.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/utils/analysisrequest.py#L371-L461 | def create_partition(analysis_request, request, analyses, sample_type=None,
container=None, preservation=None, skip_fields=None,
remove_primary_analyses=True):
"""
Creates a partition for the analysis_request (primary) passed in
:param analysis_request: uid/brain/ob... | [
"def",
"create_partition",
"(",
"analysis_request",
",",
"request",
",",
"analyses",
",",
"sample_type",
"=",
"None",
",",
"container",
"=",
"None",
",",
"preservation",
"=",
"None",
",",
"skip_fields",
"=",
"None",
",",
"remove_primary_analyses",
"=",
"True",
... | Creates a partition for the analysis_request (primary) passed in
:param analysis_request: uid/brain/object of IAnalysisRequest type
:param request: the current request object
:param analyses: uids/brains/objects of IAnalysis type
:param sampletype: uid/brain/object of SampleType
:param container: ui... | [
"Creates",
"a",
"partition",
"for",
"the",
"analysis_request",
"(",
"primary",
")",
"passed",
"in",
":",
"param",
"analysis_request",
":",
"uid",
"/",
"brain",
"/",
"object",
"of",
"IAnalysisRequest",
"type",
":",
"param",
"request",
":",
"the",
"current",
"... | python | train | 39.813187 |
saltstack/salt | salt/runners/f5.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/f5.py#L45-L61 | def _connect(self):
'''
Connect to F5
'''
try:
self.bigIP = f5.BIGIP(hostname=self.lb,
username=self.username,
password=self.password,
fromurl=True,
... | [
"def",
"_connect",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"bigIP",
"=",
"f5",
".",
"BIGIP",
"(",
"hostname",
"=",
"self",
".",
"lb",
",",
"username",
"=",
"self",
".",
"username",
",",
"password",
"=",
"self",
".",
"password",
",",
"fromur... | Connect to F5 | [
"Connect",
"to",
"F5"
] | python | train | 32.411765 |
chrisrink10/basilisp | src/basilisp/lang/compiler/generator.py | https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1139-L1209 | def __multi_arity_fn_to_py_ast( # pylint: disable=too-many-locals
ctx: GeneratorContext,
node: Fn,
methods: Collection[FnMethod],
def_name: Optional[str] = None,
meta_node: Optional[MetaNode] = None,
) -> GeneratedPyAST:
"""Return a Python AST node for a function with multiple arities."""
a... | [
"def",
"__multi_arity_fn_to_py_ast",
"(",
"# pylint: disable=too-many-locals",
"ctx",
":",
"GeneratorContext",
",",
"node",
":",
"Fn",
",",
"methods",
":",
"Collection",
"[",
"FnMethod",
"]",
",",
"def_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
... | Return a Python AST node for a function with multiple arities. | [
"Return",
"a",
"Python",
"AST",
"node",
"for",
"a",
"function",
"with",
"multiple",
"arities",
"."
] | python | test | 34.929577 |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L1933-L1979 | def line_to_args(self, line):
"""This will convert the line passed into the do_xxx functions into
an array of arguments and handle the Output Redirection Operator.
"""
# Note: using shlex.split causes quoted substrings to stay together.
args = shlex.split(line)
self.redir... | [
"def",
"line_to_args",
"(",
"self",
",",
"line",
")",
":",
"# Note: using shlex.split causes quoted substrings to stay together.",
"args",
"=",
"shlex",
".",
"split",
"(",
"line",
")",
"self",
".",
"redirect_filename",
"=",
"''",
"self",
".",
"redirect_dev",
"=",
... | This will convert the line passed into the do_xxx functions into
an array of arguments and handle the Output Redirection Operator. | [
"This",
"will",
"convert",
"the",
"line",
"passed",
"into",
"the",
"do_xxx",
"functions",
"into",
"an",
"array",
"of",
"arguments",
"and",
"handle",
"the",
"Output",
"Redirection",
"Operator",
"."
] | python | train | 46.340426 |
bwohlberg/sporco | sporco/dictlrn/prlcnscdl.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/prlcnscdl.py#L1017-L1033 | def step(self):
"""Do a single iteration over all cbpdn and ccmod steps. Those that
are not coupled on the K axis are performed in parallel."""
# If the nproc parameter of __init__ is zero, just iterate
# over the K consensus instances instead of using
# multiprocessing to do th... | [
"def",
"step",
"(",
"self",
")",
":",
"# If the nproc parameter of __init__ is zero, just iterate",
"# over the K consensus instances instead of using",
"# multiprocessing to do the computations in parallel. This is",
"# useful for debugging and timing comparisons.",
"if",
"self",
".",
"np... | Do a single iteration over all cbpdn and ccmod steps. Those that
are not coupled on the K axis are performed in parallel. | [
"Do",
"a",
"single",
"iteration",
"over",
"all",
"cbpdn",
"and",
"ccmod",
"steps",
".",
"Those",
"that",
"are",
"not",
"coupled",
"on",
"the",
"K",
"axis",
"are",
"performed",
"in",
"parallel",
"."
] | python | train | 38.588235 |
aboSamoor/polyglot | polyglot/downloader.py | https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1361-L1376 | def _check_package(pkg_xml, zipfilename, zf):
"""
Helper for ``build_index()``: Perform some checks to make sure that
the given package is consistent.
"""
# The filename must patch the id given in the XML file.
uid = os.path.splitext(os.path.split(zipfilename)[1])[0]
if pkg_xml.get('id') != uid:
raise... | [
"def",
"_check_package",
"(",
"pkg_xml",
",",
"zipfilename",
",",
"zf",
")",
":",
"# The filename must patch the id given in the XML file.",
"uid",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"zipfilename",
")",
"[",
"1"... | Helper for ``build_index()``: Perform some checks to make sure that
the given package is consistent. | [
"Helper",
"for",
"build_index",
"()",
":",
"Perform",
"some",
"checks",
"to",
"make",
"sure",
"that",
"the",
"given",
"package",
"is",
"consistent",
"."
] | python | train | 41.4375 |
dcaune/perseus-lib-python-common | majormode/perseus/utils/amqp.py | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/amqp.py#L225-L248 | def run(self):
"""
Consume message from the Advanced Message Queuing Protocol
(AMPQ) compliant broker as soon as they are queued, and call
the instance method ``__on_message_received`` that the
inheriting class must have implemented.
"""
self._setUp()
nam... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_setUp",
"(",
")",
"naming",
"=",
"'skunkworks.lbs.%s.%s.%s'",
"%",
"(",
"settings",
".",
"ENVIRONMENT_STAGE",
",",
"self",
".",
"service_name",
".",
"lower",
"(",
")",
",",
"self",
".",
"message_type",
... | Consume message from the Advanced Message Queuing Protocol
(AMPQ) compliant broker as soon as they are queued, and call
the instance method ``__on_message_received`` that the
inheriting class must have implemented. | [
"Consume",
"message",
"from",
"the",
"Advanced",
"Message",
"Queuing",
"Protocol",
"(",
"AMPQ",
")",
"compliant",
"broker",
"as",
"soon",
"as",
"they",
"are",
"queued",
"and",
"call",
"the",
"instance",
"method",
"__on_message_received",
"that",
"the",
"inheriti... | python | train | 43.25 |
quantopian/zipline | zipline/pipeline/mixins.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/mixins.py#L297-L323 | def make_aliased_type(cls, other_base):
"""
Factory for making Aliased{Filter,Factor,Classifier}.
"""
docstring = dedent(
"""
A {t} that names another {t}.
Parameters
----------
term : {t}
{{name}}
"""
... | [
"def",
"make_aliased_type",
"(",
"cls",
",",
"other_base",
")",
":",
"docstring",
"=",
"dedent",
"(",
"\"\"\"\n A {t} that names another {t}.\n\n Parameters\n ----------\n term : {t}\n {{name}}\n \"\"\"",
")",
".",
"form... | Factory for making Aliased{Filter,Factor,Classifier}. | [
"Factory",
"for",
"making",
"Aliased",
"{",
"Filter",
"Factor",
"Classifier",
"}",
"."
] | python | train | 25.851852 |
jjgomera/iapws | iapws/iapws97.py | https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L590-L648 | def _h2ab_s(s):
"""Define the saturated line boundary between Region 4 and 2a-2b, h=f(s)
Parameters
----------
s : float
Specific entropy, [kJ/kgK]
Returns
-------
h : float
Specific enthalpy, [kJ/kg]
Notes
------
Raise :class:`NotImplementedError` if input isn... | [
"def",
"_h2ab_s",
"(",
"s",
")",
":",
"# Check input parameters",
"if",
"s",
"<",
"5.85",
"or",
"s",
">",
"9.155759395",
":",
"raise",
"NotImplementedError",
"(",
"\"Incoming out of bound\"",
")",
"sigma1",
"=",
"s",
"/",
"5.21",
"sigma2",
"=",
"s",
"/",
"... | Define the saturated line boundary between Region 4 and 2a-2b, h=f(s)
Parameters
----------
s : float
Specific entropy, [kJ/kgK]
Returns
-------
h : float
Specific enthalpy, [kJ/kg]
Notes
------
Raise :class:`NotImplementedError` if input isn't in limit:
*... | [
"Define",
"the",
"saturated",
"line",
"boundary",
"between",
"Region",
"4",
"and",
"2a",
"-",
"2b",
"h",
"=",
"f",
"(",
"s",
")"
] | python | train | 35.677966 |
datascopeanalytics/traces | traces/timeseries.py | https://github.com/datascopeanalytics/traces/blob/420611151a05fea88a07bc5200fefffdc37cc95b/traces/timeseries.py#L546-L551 | def mean(self, start=None, end=None, mask=None):
"""This calculated the average value of the time series over the given
time range from `start` to `end`, when `mask` is truthy.
"""
return self.distribution(start=start, end=end, mask=mask).mean() | [
"def",
"mean",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"mask",
"=",
"None",
")",
":",
"return",
"self",
".",
"distribution",
"(",
"start",
"=",
"start",
",",
"end",
"=",
"end",
",",
"mask",
"=",
"mask",
")",
".",
"... | This calculated the average value of the time series over the given
time range from `start` to `end`, when `mask` is truthy. | [
"This",
"calculated",
"the",
"average",
"value",
"of",
"the",
"time",
"series",
"over",
"the",
"given",
"time",
"range",
"from",
"start",
"to",
"end",
"when",
"mask",
"is",
"truthy",
"."
] | python | train | 45.5 |
a1ezzz/wasp-general | wasp_general/task/thread_tracker.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread_tracker.py#L571-L581 | def task_dropped(self):
""" Track (if required) drop event and do the same job as :meth:`.WScheduleRecord.task_dropped`
method do
:return: None
"""
tracker = self.task().tracker_storage()
if tracker is not None and self.track_drop() is True:
details = self.task().event_details(WTrackerEvents.drop)
tr... | [
"def",
"task_dropped",
"(",
"self",
")",
":",
"tracker",
"=",
"self",
".",
"task",
"(",
")",
".",
"tracker_storage",
"(",
")",
"if",
"tracker",
"is",
"not",
"None",
"and",
"self",
".",
"track_drop",
"(",
")",
"is",
"True",
":",
"details",
"=",
"self"... | Track (if required) drop event and do the same job as :meth:`.WScheduleRecord.task_dropped`
method do
:return: None | [
"Track",
"(",
"if",
"required",
")",
"drop",
"event",
"and",
"do",
"the",
"same",
"job",
"as",
":",
"meth",
":",
".",
"WScheduleRecord",
".",
"task_dropped",
"method",
"do"
] | python | train | 36.545455 |
aleju/imgaug | imgaug/augmentables/segmaps.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/segmaps.py#L555-L567 | def deepcopy(self):
"""
Create a deep copy of the segmentation map object.
Returns
-------
imgaug.SegmentationMapOnImage
Deep copy.
"""
segmap = SegmentationMapOnImage(self.arr, shape=self.shape, nb_classes=self.nb_classes)
segmap.input_was =... | [
"def",
"deepcopy",
"(",
"self",
")",
":",
"segmap",
"=",
"SegmentationMapOnImage",
"(",
"self",
".",
"arr",
",",
"shape",
"=",
"self",
".",
"shape",
",",
"nb_classes",
"=",
"self",
".",
"nb_classes",
")",
"segmap",
".",
"input_was",
"=",
"self",
".",
"... | Create a deep copy of the segmentation map object.
Returns
-------
imgaug.SegmentationMapOnImage
Deep copy. | [
"Create",
"a",
"deep",
"copy",
"of",
"the",
"segmentation",
"map",
"object",
"."
] | python | valid | 26.538462 |
wummel/linkchecker | linkcheck/bookmarks/chromium.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/bookmarks/chromium.py#L84-L88 | def parse_bookmark_json (data):
"""Parse complete JSON data for Chromium Bookmarks."""
for entry in data["roots"].values():
for url, name in parse_bookmark_node(entry):
yield url, name | [
"def",
"parse_bookmark_json",
"(",
"data",
")",
":",
"for",
"entry",
"in",
"data",
"[",
"\"roots\"",
"]",
".",
"values",
"(",
")",
":",
"for",
"url",
",",
"name",
"in",
"parse_bookmark_node",
"(",
"entry",
")",
":",
"yield",
"url",
",",
"name"
] | Parse complete JSON data for Chromium Bookmarks. | [
"Parse",
"complete",
"JSON",
"data",
"for",
"Chromium",
"Bookmarks",
"."
] | python | train | 41.6 |
cldf/clts | src/pyclts/soundclasses.py | https://github.com/cldf/clts/blob/2798554c9c4e668bce0e4f5b0d91cf03c2d7c13a/src/pyclts/soundclasses.py#L27-L51 | def resolve_sound(self, sound):
"""Function tries to identify a sound in the data.
Notes
-----
The function tries to resolve sounds to take a sound with less complex
features in order to yield the next approximate sound class, if the
transcription data are sound classes.... | [
"def",
"resolve_sound",
"(",
"self",
",",
"sound",
")",
":",
"sound",
"=",
"sound",
"if",
"isinstance",
"(",
"sound",
",",
"Symbol",
")",
"else",
"self",
".",
"system",
"[",
"sound",
"]",
"if",
"sound",
".",
"name",
"in",
"self",
".",
"data",
":",
... | Function tries to identify a sound in the data.
Notes
-----
The function tries to resolve sounds to take a sound with less complex
features in order to yield the next approximate sound class, if the
transcription data are sound classes. | [
"Function",
"tries",
"to",
"identify",
"a",
"sound",
"in",
"the",
"data",
"."
] | python | valid | 44.56 |
PmagPy/PmagPy | programs/thellier_gui.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/thellier_gui.py#L465-L495 | def get_DIR(self, WD=None):
"""
open dialog box for choosing a working directory
"""
if "-WD" in sys.argv and FIRST_RUN:
ind = sys.argv.index('-WD')
self.WD = sys.argv[ind + 1]
elif not WD: # if no arg was passed in for WD, make a dialog to choose one
... | [
"def",
"get_DIR",
"(",
"self",
",",
"WD",
"=",
"None",
")",
":",
"if",
"\"-WD\"",
"in",
"sys",
".",
"argv",
"and",
"FIRST_RUN",
":",
"ind",
"=",
"sys",
".",
"argv",
".",
"index",
"(",
"'-WD'",
")",
"self",
".",
"WD",
"=",
"sys",
".",
"argv",
"[... | open dialog box for choosing a working directory | [
"open",
"dialog",
"box",
"for",
"choosing",
"a",
"working",
"directory"
] | python | train | 40.967742 |
deschler/django-modeltranslation | modeltranslation/translator.py | https://github.com/deschler/django-modeltranslation/blob/18fec04a5105cbd83fc3759f4fda20135b3a848c/modeltranslation/translator.py#L313-L360 | def populate_translation_fields(sender, kwargs):
"""
When models are created or loaded from fixtures, replicates values
provided for translatable fields to some / all empty translation fields,
according to the current population mode.
Population is performed only on keys (field names) present in kw... | [
"def",
"populate_translation_fields",
"(",
"sender",
",",
"kwargs",
")",
":",
"populate",
"=",
"mt_settings",
".",
"AUTO_POPULATE",
"if",
"not",
"populate",
":",
"return",
"if",
"populate",
"is",
"True",
":",
"# What was meant by ``True`` is now called ``all``.",
"pop... | When models are created or loaded from fixtures, replicates values
provided for translatable fields to some / all empty translation fields,
according to the current population mode.
Population is performed only on keys (field names) present in kwargs.
Nothing is returned, but passed kwargs dictionary i... | [
"When",
"models",
"are",
"created",
"or",
"loaded",
"from",
"fixtures",
"replicates",
"values",
"provided",
"for",
"translatable",
"fields",
"to",
"some",
"/",
"all",
"empty",
"translation",
"fields",
"according",
"to",
"the",
"current",
"population",
"mode",
".... | python | train | 45.833333 |
chrippa/python-librtmp | librtmp/rtmp.py | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L193-L228 | def create_stream(self, seek=None, writeable=False, update_buffer=True):
"""Prepares the session for streaming of audio/video
and returns a :class:`RTMPStream` object.
:param seek: int, Attempt to seek to this position.
:param writeable: bool, Make the stream writeable instead of rea... | [
"def",
"create_stream",
"(",
"self",
",",
"seek",
"=",
"None",
",",
"writeable",
"=",
"False",
",",
"update_buffer",
"=",
"True",
")",
":",
"if",
"writeable",
":",
"librtmp",
".",
"RTMP_EnableWrite",
"(",
"self",
".",
"rtmp",
")",
"# Calling handle_packet() ... | Prepares the session for streaming of audio/video
and returns a :class:`RTMPStream` object.
:param seek: int, Attempt to seek to this position.
:param writeable: bool, Make the stream writeable instead of readable.
:param update_buffer: bool, When enabled will attempt to speed up
... | [
"Prepares",
"the",
"session",
"for",
"streaming",
"of",
"audio",
"/",
"video",
"and",
"returns",
"a",
":",
"class",
":",
"RTMPStream",
"object",
"."
] | python | train | 35.944444 |
ARMmbed/icetea | icetea_lib/tools/file/SessionFiles.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/file/SessionFiles.py#L218-L228 | def _ends_with(self, string_to_edit, end): # pylint: disable=no-self-use
"""
Check if string ends with characters in end, if not merge end to string.
:param string_to_edit: string to check and edit.
:param end: str
:return: string_to_edit or string_to_edit + end
"""
... | [
"def",
"_ends_with",
"(",
"self",
",",
"string_to_edit",
",",
"end",
")",
":",
"# pylint: disable=no-self-use",
"if",
"not",
"string_to_edit",
".",
"endswith",
"(",
"end",
")",
":",
"return",
"string_to_edit",
"+",
"end",
"return",
"string_to_edit"
] | Check if string ends with characters in end, if not merge end to string.
:param string_to_edit: string to check and edit.
:param end: str
:return: string_to_edit or string_to_edit + end | [
"Check",
"if",
"string",
"ends",
"with",
"characters",
"in",
"end",
"if",
"not",
"merge",
"end",
"to",
"string",
"."
] | python | train | 38.272727 |
ThePlasmaRailgun/py-rolldice | rolldice/rolldice.py | https://github.com/ThePlasmaRailgun/py-rolldice/blob/dc46d1d3e765592e76c52fd812b4f3b7425db552/rolldice/rolldice.py#L242-L253 | def roll_dice(self): # Roll dice with current roll
"""
Rolls dicebag and sets last_roll and last_explanation to roll results
:return: Roll results.
"""
roll = roll_dice(self.roll, floats=self.floats, functions=self.functions)
self._last_roll = roll[0]
self._las... | [
"def",
"roll_dice",
"(",
"self",
")",
":",
"# Roll dice with current roll",
"roll",
"=",
"roll_dice",
"(",
"self",
".",
"roll",
",",
"floats",
"=",
"self",
".",
"floats",
",",
"functions",
"=",
"self",
".",
"functions",
")",
"self",
".",
"_last_roll",
"=",... | Rolls dicebag and sets last_roll and last_explanation to roll results
:return: Roll results. | [
"Rolls",
"dicebag",
"and",
"sets",
"last_roll",
"and",
"last_explanation",
"to",
"roll",
"results"
] | python | train | 32.166667 |
cloudnull/cloudlib | cloudlib/parse_ini.py | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/parse_ini.py#L114-L139 | def check_perms(self, perms='0600,0400'):
"""Check and enforce the permissions of the config file.
Enforce permission on a provided configuration file. This will check
and see if the permission are set based on the permission octet as
set in the ``perms`` value. ``perms`` is a comma sep... | [
"def",
"check_perms",
"(",
"self",
",",
"perms",
"=",
"'0600,0400'",
")",
":",
"confpath",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"self",
".",
"config_file",
")",
"mode",
"=",
"stat",
".",
"S_IMODE",
"(",
"os",
".",
"stat",
"(",
"confpath",
")... | Check and enforce the permissions of the config file.
Enforce permission on a provided configuration file. This will check
and see if the permission are set based on the permission octet as
set in the ``perms`` value. ``perms`` is a comma separated list
of acceptable perms in octal form... | [
"Check",
"and",
"enforce",
"the",
"permissions",
"of",
"the",
"config",
"file",
"."
] | python | train | 39.038462 |
saltstack/salt | salt/states/pyenv.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pyenv.py#L104-L139 | def installed(name, default=False, user=None):
'''
Verify that the specified python is installed with pyenv. pyenv is
installed if necessary.
name
The version of python to install
default : False
Whether to make this python the default.
user: None
The user to run pyenv... | [
"def",
"installed",
"(",
"name",
",",
"default",
"=",
"False",
",",
"user",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"None",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"if",
"nam... | Verify that the specified python is installed with pyenv. pyenv is
installed if necessary.
name
The version of python to install
default : False
Whether to make this python the default.
user: None
The user to run pyenv as.
.. versionadded:: 0.17.0
.. versionadded... | [
"Verify",
"that",
"the",
"specified",
"python",
"is",
"installed",
"with",
"pyenv",
".",
"pyenv",
"is",
"installed",
"if",
"necessary",
"."
] | python | train | 27.666667 |
dask/dask-ml | dask_ml/metrics/scorer.py | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/metrics/scorer.py#L22-L51 | def get_scorer(scoring, compute=True):
"""Get a scorer from string
Parameters
----------
scoring : str | callable
scoring method as string. If callable it is returned as is.
Returns
-------
scorer : callable
The scorer.
"""
# This is the same as sklearns, only we us... | [
"def",
"get_scorer",
"(",
"scoring",
",",
"compute",
"=",
"True",
")",
":",
"# This is the same as sklearns, only we use our SCORERS dict,",
"# and don't have back-compat code",
"if",
"isinstance",
"(",
"scoring",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
... | Get a scorer from string
Parameters
----------
scoring : str | callable
scoring method as string. If callable it is returned as is.
Returns
-------
scorer : callable
The scorer. | [
"Get",
"a",
"scorer",
"from",
"string"
] | python | train | 25.866667 |
nickoala/telepot | telepot/helper.py | https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/helper.py#L925-L967 | def openable(cls):
"""
A class decorator to fill in certain methods and properties to ensure
a class can be used by :func:`.create_open`.
These instance methods and property will be added, if not defined
by the class:
- ``open(self, initial_msg, seed)``
- ``on_message(self, msg)``
- ``... | [
"def",
"openable",
"(",
"cls",
")",
":",
"def",
"open",
"(",
"self",
",",
"initial_msg",
",",
"seed",
")",
":",
"pass",
"def",
"on_message",
"(",
"self",
",",
"msg",
")",
":",
"raise",
"NotImplementedError",
"(",
")",
"def",
"on_close",
"(",
"self",
... | A class decorator to fill in certain methods and properties to ensure
a class can be used by :func:`.create_open`.
These instance methods and property will be added, if not defined
by the class:
- ``open(self, initial_msg, seed)``
- ``on_message(self, msg)``
- ``on_close(self, ex)``
- ``cl... | [
"A",
"class",
"decorator",
"to",
"fill",
"in",
"certain",
"methods",
"and",
"properties",
"to",
"ensure",
"a",
"class",
"can",
"be",
"used",
"by",
":",
"func",
":",
".",
"create_open",
"."
] | python | train | 25.976744 |
vingd/vingd-api-python | vingd/client.py | https://github.com/vingd/vingd-api-python/blob/7548a49973a472f7277c8ef847563faa7b6f3706/vingd/client.py#L564-L593 | def authorized_create_user(self, identities=None, primary=None, permissions=None):
"""Creates Vingd user (profile & account), links it with the provided
identities (to be verified later), and sets the delegate-user
permissions (creator being the delegate). Returns Vingd user's `huid`
(ha... | [
"def",
"authorized_create_user",
"(",
"self",
",",
"identities",
"=",
"None",
",",
"primary",
"=",
"None",
",",
"permissions",
"=",
"None",
")",
":",
"return",
"self",
".",
"request",
"(",
"'post'",
",",
"'id/users/'",
",",
"json",
".",
"dumps",
"(",
"{"... | Creates Vingd user (profile & account), links it with the provided
identities (to be verified later), and sets the delegate-user
permissions (creator being the delegate). Returns Vingd user's `huid`
(hashed user id).
Example::
vingd.authorized_create_user(
... | [
"Creates",
"Vingd",
"user",
"(",
"profile",
"&",
"account",
")",
"links",
"it",
"with",
"the",
"provided",
"identities",
"(",
"to",
"be",
"verified",
"later",
")",
"and",
"sets",
"the",
"delegate",
"-",
"user",
"permissions",
"(",
"creator",
"being",
"the"... | python | train | 40.5 |
batiste/django-page-cms | pages/admin/forms.py | https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/admin/forms.py#L23-L37 | def automatic_slug_renaming(slug, is_slug_safe):
"""Helper to add numbers to slugs"""
if not isinstance(is_slug_safe, collections.Callable):
raise TypeError('is_slug_safe must be callable')
if is_slug_safe(slug):
return slug
count = 2
new_slug = slug + "-" + str(count)
while no... | [
"def",
"automatic_slug_renaming",
"(",
"slug",
",",
"is_slug_safe",
")",
":",
"if",
"not",
"isinstance",
"(",
"is_slug_safe",
",",
"collections",
".",
"Callable",
")",
":",
"raise",
"TypeError",
"(",
"'is_slug_safe must be callable'",
")",
"if",
"is_slug_safe",
"(... | Helper to add numbers to slugs | [
"Helper",
"to",
"add",
"numbers",
"to",
"slugs"
] | python | train | 28 |
jpscaletti/solution | solution/fields/splitted_datetime.py | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/splitted_datetime.py#L76-L81 | def _to_utc(self, dt):
"""Takes a naive timezone with an localized value and return it formatted
as utc."""
tz = self._get_tz()
loc_dt = tz.localize(dt)
return loc_dt.astimezone(pytz.utc) | [
"def",
"_to_utc",
"(",
"self",
",",
"dt",
")",
":",
"tz",
"=",
"self",
".",
"_get_tz",
"(",
")",
"loc_dt",
"=",
"tz",
".",
"localize",
"(",
"dt",
")",
"return",
"loc_dt",
".",
"astimezone",
"(",
"pytz",
".",
"utc",
")"
] | Takes a naive timezone with an localized value and return it formatted
as utc. | [
"Takes",
"a",
"naive",
"timezone",
"with",
"an",
"localized",
"value",
"and",
"return",
"it",
"formatted",
"as",
"utc",
"."
] | python | train | 37 |
udragon/pybrctl | pybrctl/pybrctl.py | https://github.com/udragon/pybrctl/blob/9e834a605b57bd969a81c56a886dee81f7d715c1/pybrctl/pybrctl.py#L73-L76 | def setpathcost(self, port, cost):
""" Set port path cost value for STP protocol. """
_runshell([brctlexe, 'setpathcost', self.name, port, str(cost)],
"Could not set path cost in port %s in %s." % (port, self.name)) | [
"def",
"setpathcost",
"(",
"self",
",",
"port",
",",
"cost",
")",
":",
"_runshell",
"(",
"[",
"brctlexe",
",",
"'setpathcost'",
",",
"self",
".",
"name",
",",
"port",
",",
"str",
"(",
"cost",
")",
"]",
",",
"\"Could not set path cost in port %s in %s.\"",
... | Set port path cost value for STP protocol. | [
"Set",
"port",
"path",
"cost",
"value",
"for",
"STP",
"protocol",
"."
] | python | train | 60 |
dnanexus/dx-toolkit | src/python/dxpy/utils/pretty_print.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/pretty_print.py#L112-L182 | def format_table(table, column_names=None, column_specs=None, max_col_width=32,
report_dimensions=False):
''' Table pretty printer.
Expects tables to be given as arrays of arrays.
Example:
print format_table([[1, "2"], [3, "456"]], column_names=['A', 'B'])
'''
if len(tabl... | [
"def",
"format_table",
"(",
"table",
",",
"column_names",
"=",
"None",
",",
"column_specs",
"=",
"None",
",",
"max_col_width",
"=",
"32",
",",
"report_dimensions",
"=",
"False",
")",
":",
"if",
"len",
"(",
"table",
")",
">",
"0",
":",
"col_widths",
"=",
... | Table pretty printer.
Expects tables to be given as arrays of arrays.
Example:
print format_table([[1, "2"], [3, "456"]], column_names=['A', 'B']) | [
"Table",
"pretty",
"printer",
".",
"Expects",
"tables",
"to",
"be",
"given",
"as",
"arrays",
"of",
"arrays",
"."
] | python | train | 42.15493 |
annoviko/pyclustering | pyclustering/nnet/dynamic_visualizer.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/dynamic_visualizer.py#L129-L162 | def __get_canonical_separate(self, input_separate):
"""!
@brief Return unified representation of separation value.
@details It represents list whose size is equal to amount of dynamics, where index of dynamic will show
where it should be displayed.
@param[in] inp... | [
"def",
"__get_canonical_separate",
"(",
"self",
",",
"input_separate",
")",
":",
"if",
"(",
"isinstance",
"(",
"input_separate",
",",
"list",
")",
")",
":",
"separate",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"self",
".",
"dynamics",
"[",
"0",
"]",
")",
... | !
@brief Return unified representation of separation value.
@details It represents list whose size is equal to amount of dynamics, where index of dynamic will show
where it should be displayed.
@param[in] input_separate (bool|list): Input separate representation that shou... | [
"!"
] | python | valid | 42.647059 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_snmp.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_snmp.py#L672-L686 | def snmp_server_group_notify(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
snmp_server = ET.SubElement(config, "snmp-server", xmlns="urn:brocade.com:mgmt:brocade-snmp")
group = ET.SubElement(snmp_server, "group")
group_name_key = ET.SubElement(... | [
"def",
"snmp_server_group_notify",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"snmp_server",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"snmp-server\"",
",",
"xmlns",
"=",
"\"urn:br... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 46 |
Richienb/quilt | src/quilt_lang/__init__.py | https://github.com/Richienb/quilt/blob/4a659cac66f5286ad046d54a12fd850be5606643/src/quilt_lang/__init__.py#L1865-L1902 | def case(text, casingformat='sentence'):
"""
Change the casing of some text.
:type text: string
:param text: The text to change the casing of.
:type casingformat: string
:param casingformat: The format of casing to apply to the text. Can be 'uppercase', 'lowercase', 'sentence' or 'caterpillar'... | [
"def",
"case",
"(",
"text",
",",
"casingformat",
"=",
"'sentence'",
")",
":",
"# If the lowercase version of the casing format is 'uppercase'",
"if",
"casingformat",
".",
"lower",
"(",
")",
"==",
"'uppercase'",
":",
"# Return the uppercase version",
"return",
"str",
"("... | Change the casing of some text.
:type text: string
:param text: The text to change the casing of.
:type casingformat: string
:param casingformat: The format of casing to apply to the text. Can be 'uppercase', 'lowercase', 'sentence' or 'caterpillar'.
:raises ValueError: Invalid text format specif... | [
"Change",
"the",
"casing",
"of",
"some",
"text",
"."
] | python | train | 33.631579 |
CTPUG/wafer | wafer/schedule/admin.py | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L89-L103 | def find_duplicate_schedule_items(all_items):
"""Find talks / pages assigned to mulitple schedule items"""
duplicates = []
seen_talks = {}
for item in all_items:
if item.talk and item.talk in seen_talks:
duplicates.append(item)
if seen_talks[item.talk] not in duplicates:
... | [
"def",
"find_duplicate_schedule_items",
"(",
"all_items",
")",
":",
"duplicates",
"=",
"[",
"]",
"seen_talks",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"talk",
"and",
"item",
".",
"talk",
"in",
"seen_talks",
":",
"duplicates... | Find talks / pages assigned to mulitple schedule items | [
"Find",
"talks",
"/",
"pages",
"assigned",
"to",
"mulitple",
"schedule",
"items"
] | python | train | 43.4 |
AshleySetter/optoanalysis | optoanalysis/optoanalysis/optoanalysis.py | https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/optoanalysis.py#L1237-L1298 | def calc_phase_space(self, freq, ConvFactor, PeakWidth=10000, FractionOfSampleFreq=1, timeStart=None, timeEnd =None, PointsOfPadding=500, ShowPSD=False):
"""
Calculates the position and velocity (in m) for use in plotting the phase space distribution.
Parameters
----------
freq ... | [
"def",
"calc_phase_space",
"(",
"self",
",",
"freq",
",",
"ConvFactor",
",",
"PeakWidth",
"=",
"10000",
",",
"FractionOfSampleFreq",
"=",
"1",
",",
"timeStart",
"=",
"None",
",",
"timeEnd",
"=",
"None",
",",
"PointsOfPadding",
"=",
"500",
",",
"ShowPSD",
"... | Calculates the position and velocity (in m) for use in plotting the phase space distribution.
Parameters
----------
freq : float
The frequenecy of the peak (Trapping frequency of the dimension of interest)
ConvFactor : float (or ufloat)
The conversion factor betw... | [
"Calculates",
"the",
"position",
"and",
"velocity",
"(",
"in",
"m",
")",
"for",
"use",
"in",
"plotting",
"the",
"phase",
"space",
"distribution",
"."
] | python | train | 45.080645 |
opennode/waldur-core | waldur_core/logging/elasticsearch_client.py | https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/elasticsearch_client.py#L227-L249 | def prepare_search_body(self, should_terms=None, must_terms=None, must_not_terms=None, search_text='', start=None, end=None):
"""
Prepare body for elasticsearch query
Search parameters
^^^^^^^^^^^^^^^^^
These parameters are dictionaries and have format: <term>: [<value 1>, <val... | [
"def",
"prepare_search_body",
"(",
"self",
",",
"should_terms",
"=",
"None",
",",
"must_terms",
"=",
"None",
",",
"must_not_terms",
"=",
"None",
",",
"search_text",
"=",
"''",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"self",
".",
"... | Prepare body for elasticsearch query
Search parameters
^^^^^^^^^^^^^^^^^
These parameters are dictionaries and have format: <term>: [<value 1>, <value 2> ...]
should_terms: it resembles logical OR
must_terms: it resembles logical AND
must_not_terms: it resembles logical... | [
"Prepare",
"body",
"for",
"elasticsearch",
"query"
] | python | train | 39.869565 |
DarkEnergySurvey/ugali | ugali/utils/healpix.py | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/healpix.py#L316-L321 | def ang2disc(nside, lon, lat, radius, inclusive=False, fact=4, nest=False):
"""
Wrap `query_disc` to use lon, lat, and radius in degrees.
"""
vec = ang2vec(lon,lat)
return query_disc(nside,vec,radius,inclusive,fact,nest) | [
"def",
"ang2disc",
"(",
"nside",
",",
"lon",
",",
"lat",
",",
"radius",
",",
"inclusive",
"=",
"False",
",",
"fact",
"=",
"4",
",",
"nest",
"=",
"False",
")",
":",
"vec",
"=",
"ang2vec",
"(",
"lon",
",",
"lat",
")",
"return",
"query_disc",
"(",
"... | Wrap `query_disc` to use lon, lat, and radius in degrees. | [
"Wrap",
"query_disc",
"to",
"use",
"lon",
"lat",
"and",
"radius",
"in",
"degrees",
"."
] | python | train | 39.166667 |
SKA-ScienceDataProcessor/integration-prototype | sip/examples/flask_processing_controller/app/old.db/config_db_redis.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/examples/flask_processing_controller/app/old.db/config_db_redis.py#L49-L51 | def set_value(self, key, field, value):
"""Add the state of the key and field"""
self._db.hset(key, field, value) | [
"def",
"set_value",
"(",
"self",
",",
"key",
",",
"field",
",",
"value",
")",
":",
"self",
".",
"_db",
".",
"hset",
"(",
"key",
",",
"field",
",",
"value",
")"
] | Add the state of the key and field | [
"Add",
"the",
"state",
"of",
"the",
"key",
"and",
"field"
] | python | train | 42.333333 |
jtwhite79/pyemu | pyemu/pst/pst_handler.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L742-L856 | def _load_version2(self,filename):
"""load a version 2 control file
"""
self.lcount = 0
self.comments = {}
self.prior_information = self.null_prior
assert os.path.exists(filename), "couldn't find control file {0}".format(filename)
f = open(filename, 'r')
... | [
"def",
"_load_version2",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"lcount",
"=",
"0",
"self",
".",
"comments",
"=",
"{",
"}",
"self",
".",
"prior_information",
"=",
"self",
".",
"null_prior",
"assert",
"os",
".",
"path",
".",
"exists",
"(",... | load a version 2 control file | [
"load",
"a",
"version",
"2",
"control",
"file"
] | python | train | 52.895652 |
SeattleTestbed/seash | pyreadline/modes/basemode.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/basemode.py#L272-L276 | def possible_completions(self, e): # (M-?)
u"""List the possible completions of the text before point. """
completions = self._get_completions()
self._display_completions(completions)
self.finalize() | [
"def",
"possible_completions",
"(",
"self",
",",
"e",
")",
":",
"# (M-?)\r",
"completions",
"=",
"self",
".",
"_get_completions",
"(",
")",
"self",
".",
"_display_completions",
"(",
"completions",
")",
"self",
".",
"finalize",
"(",
")"
] | u"""List the possible completions of the text before point. | [
"u",
"List",
"the",
"possible",
"completions",
"of",
"the",
"text",
"before",
"point",
"."
] | python | train | 46.2 |
LionelAuroux/pyrser | pyrser/dsl.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/dsl.py#L715-L718 | def hook_param(self, hook, p):
"""Parse a hook parameter"""
hook.listparam.append(p.pair)
return True | [
"def",
"hook_param",
"(",
"self",
",",
"hook",
",",
"p",
")",
":",
"hook",
".",
"listparam",
".",
"append",
"(",
"p",
".",
"pair",
")",
"return",
"True"
] | Parse a hook parameter | [
"Parse",
"a",
"hook",
"parameter"
] | python | test | 27.5 |
hyperledger/indy-sdk | wrappers/python/indy/anoncreds.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/anoncreds.py#L501-L564 | async def prover_create_credential_req(wallet_handle: int,
prover_did: str,
cred_offer_json: str,
cred_def_json: str,
master_secret_id: str) -> (str, str):
"""
... | [
"async",
"def",
"prover_create_credential_req",
"(",
"wallet_handle",
":",
"int",
",",
"prover_did",
":",
"str",
",",
"cred_offer_json",
":",
"str",
",",
"cred_def_json",
":",
"str",
",",
"master_secret_id",
":",
"str",
")",
"->",
"(",
"str",
",",
"str",
")"... | Creates a clam request for the given credential offer.
The method creates a blinded master secret for a master secret identified by a provided name.
The master secret identified by the name must be already stored in the secure wallet (see prover_create_master_secret)
The blinded master secret is a part of ... | [
"Creates",
"a",
"clam",
"request",
"for",
"the",
"given",
"credential",
"offer",
"."
] | python | train | 53.0625 |
marcomusy/vtkplotter | vtkplotter/actors.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/actors.py#L1453-L1492 | def threshold(self, scalars, vmin=None, vmax=None, useCells=False):
"""
Extracts cells where scalar value satisfies threshold criterion.
:param scalars: name of the scalars array.
:type scalars: str, list
:param float vmin: minimum value of the scalar
:param float vmax: ... | [
"def",
"threshold",
"(",
"self",
",",
"scalars",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
",",
"useCells",
"=",
"False",
")",
":",
"if",
"utils",
".",
"isSequence",
"(",
"scalars",
")",
":",
"self",
".",
"addPointScalars",
"(",
"scalars",
... | Extracts cells where scalar value satisfies threshold criterion.
:param scalars: name of the scalars array.
:type scalars: str, list
:param float vmin: minimum value of the scalar
:param float vmax: maximum value of the scalar
:param bool useCells: if `True`, assume array scalar... | [
"Extracts",
"cells",
"where",
"scalar",
"value",
"satisfies",
"threshold",
"criterion",
"."
] | python | train | 35.65 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/textio.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L1496-L1532 | def dump_code(disassembly, pc = None,
bLowercase = True,
bits = None):
"""
Dump a disassembly. Optionally mark where the program counter is.
... | [
"def",
"dump_code",
"(",
"disassembly",
",",
"pc",
"=",
"None",
",",
"bLowercase",
"=",
"True",
",",
"bits",
"=",
"None",
")",
":",
"if",
"not",
"disassembly",
":",
"return",
"''",
"table",
"=",
"Table",
"(",
"sep",
"=",
"' | '",
")",
"for",
"(",
"... | Dump a disassembly. Optionally mark where the program counter is.
@type disassembly: list of tuple( int, int, str, str )
@param disassembly: Disassembly dump as returned by
L{Process.disassemble} or L{Thread.disassemble_around_pc}.
@type pc: int
@param pc: (Optional) Prog... | [
"Dump",
"a",
"disassembly",
".",
"Optionally",
"mark",
"where",
"the",
"program",
"counter",
"is",
"."
] | python | train | 37.891892 |
santoshphilip/eppy | eppy/loops.py | https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/loops.py#L81-L92 | def branchlist2branches(data, commdct, branchlist):
"""get branches from the branchlist"""
objkey = 'BranchList'.upper()
theobjects = data.dt[objkey]
fieldlists = []
objnames = [obj[1] for obj in theobjects]
for theobject in theobjects:
fieldlists.append(list(range(2, len(theobject))))
... | [
"def",
"branchlist2branches",
"(",
"data",
",",
"commdct",
",",
"branchlist",
")",
":",
"objkey",
"=",
"'BranchList'",
".",
"upper",
"(",
")",
"theobjects",
"=",
"data",
".",
"dt",
"[",
"objkey",
"]",
"fieldlists",
"=",
"[",
"]",
"objnames",
"=",
"[",
... | get branches from the branchlist | [
"get",
"branches",
"from",
"the",
"branchlist"
] | python | train | 42.416667 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.