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 |
|---|---|---|---|---|---|---|---|---|---|
rocky/python3-trepan | trepan/processor/cmdproc.py | https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/processor/cmdproc.py#L107-L112 | def run_hooks(obj, hooks, *args):
"""Run each function in `hooks' with args"""
for hook in hooks:
if hook(obj, *args): return True
pass
return False | [
"def",
"run_hooks",
"(",
"obj",
",",
"hooks",
",",
"*",
"args",
")",
":",
"for",
"hook",
"in",
"hooks",
":",
"if",
"hook",
"(",
"obj",
",",
"*",
"args",
")",
":",
"return",
"True",
"pass",
"return",
"False"
] | Run each function in `hooks' with args | [
"Run",
"each",
"function",
"in",
"hooks",
"with",
"args"
] | python | test | 28.5 |
MartinThoma/hwrt | hwrt/serve.py | https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/serve.py#L164-L180 | def _get_part(pointlist, strokes):
"""Get some strokes of pointlist
Parameters
----------
pointlist : list of lists of dicts
strokes : list of integers
Returns
-------
list of lists of dicts
"""
result = []
strokes = sorted(strokes)
for stroke_index in strokes:
... | [
"def",
"_get_part",
"(",
"pointlist",
",",
"strokes",
")",
":",
"result",
"=",
"[",
"]",
"strokes",
"=",
"sorted",
"(",
"strokes",
")",
"for",
"stroke_index",
"in",
"strokes",
":",
"result",
".",
"append",
"(",
"pointlist",
"[",
"stroke_index",
"]",
")",... | Get some strokes of pointlist
Parameters
----------
pointlist : list of lists of dicts
strokes : list of integers
Returns
-------
list of lists of dicts | [
"Get",
"some",
"strokes",
"of",
"pointlist"
] | python | train | 21.176471 |
portfors-lab/sparkle | sparkle/gui/stim/stimulusview.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulusview.py#L549-L556 | def paint(self, painter, option, index):
"""Uses the :meth:`paint<sparkle.gui.stim.components.qcomponents.QStimulusComponent.paint>`
method of the component it represents to fill in an appropriately
sized rectange. :qtdoc:`Re-implemented<QStyledItemDelegate.paint>`"""
component = index... | [
"def",
"paint",
"(",
"self",
",",
"painter",
",",
"option",
",",
"index",
")",
":",
"component",
"=",
"index",
".",
"model",
"(",
")",
".",
"data",
"(",
"index",
",",
"role",
"=",
"QtCore",
".",
"Qt",
".",
"UserRole",
")",
"painter",
".",
"drawRect... | Uses the :meth:`paint<sparkle.gui.stim.components.qcomponents.QStimulusComponent.paint>`
method of the component it represents to fill in an appropriately
sized rectange. :qtdoc:`Re-implemented<QStyledItemDelegate.paint>` | [
"Uses",
"the",
":",
"meth",
":",
"paint<sparkle",
".",
"gui",
".",
"stim",
".",
"components",
".",
"qcomponents",
".",
"QStimulusComponent",
".",
"paint",
">",
"method",
"of",
"the",
"component",
"it",
"represents",
"to",
"fill",
"in",
"an",
"appropriately",... | python | train | 57.375 |
gwastro/pycbc | pycbc/tmpltbank/brute_force_methods.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/brute_force_methods.py#L349-L419 | def stack_xi_direction_brute(xis, bestMasses, bestXis, direction_num,
req_match, massRangeParams, metricParams, fUpper,
scaleFactor=0.8, numIterations=3000):
"""
This function is used to assess the depth of the xi_space in a specified
dimension at a ... | [
"def",
"stack_xi_direction_brute",
"(",
"xis",
",",
"bestMasses",
",",
"bestXis",
",",
"direction_num",
",",
"req_match",
",",
"massRangeParams",
",",
"metricParams",
",",
"fUpper",
",",
"scaleFactor",
"=",
"0.8",
",",
"numIterations",
"=",
"3000",
")",
":",
"... | This function is used to assess the depth of the xi_space in a specified
dimension at a specified point in the higher dimensions. It does this by
iteratively throwing points at the space to find maxima and minima.
Parameters
-----------
xis : list or array
Position in the xi space at which... | [
"This",
"function",
"is",
"used",
"to",
"assess",
"the",
"depth",
"of",
"the",
"xi_space",
"in",
"a",
"specified",
"dimension",
"at",
"a",
"specified",
"point",
"in",
"the",
"higher",
"dimensions",
".",
"It",
"does",
"this",
"by",
"iteratively",
"throwing",
... | python | train | 47.366197 |
flask-restful/flask-restful | flask_restful/inputs.py | https://github.com/flask-restful/flask-restful/blob/25544d697c1f82bafbd1320960df459f58a58e03/flask_restful/inputs.py#L237-L254 | def boolean(value):
"""Parse the string ``"true"`` or ``"false"`` as a boolean (case
insensitive). Also accepts ``"1"`` and ``"0"`` as ``True``/``False``
(respectively). If the input is from the request JSON body, the type is
already a native python boolean, and will be passed through without
furthe... | [
"def",
"boolean",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"value",
"if",
"not",
"value",
":",
"raise",
"ValueError",
"(",
"\"boolean type must be non-null\"",
")",
"value",
"=",
"value",
".",
"lower",
"(",... | Parse the string ``"true"`` or ``"false"`` as a boolean (case
insensitive). Also accepts ``"1"`` and ``"0"`` as ``True``/``False``
(respectively). If the input is from the request JSON body, the type is
already a native python boolean, and will be passed through without
further parsing. | [
"Parse",
"the",
"string",
"true",
"or",
"false",
"as",
"a",
"boolean",
"(",
"case",
"insensitive",
")",
".",
"Also",
"accepts",
"1",
"and",
"0",
"as",
"True",
"/",
"False",
"(",
"respectively",
")",
".",
"If",
"the",
"input",
"is",
"from",
"the",
"re... | python | train | 36.444444 |
saltstack/salt | salt/states/grafana_dashboard.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/grafana_dashboard.py#L365-L380 | def _ensure_pinned_rows(dashboard):
'''Pin rows to the top of the dashboard.'''
pinned_row_titles = __salt__['pillar.get'](_PINNED_ROWS_PILLAR)
if not pinned_row_titles:
return
pinned_row_titles_lower = []
for title in pinned_row_titles:
pinned_row_titles_lower.append(title.lower())... | [
"def",
"_ensure_pinned_rows",
"(",
"dashboard",
")",
":",
"pinned_row_titles",
"=",
"__salt__",
"[",
"'pillar.get'",
"]",
"(",
"_PINNED_ROWS_PILLAR",
")",
"if",
"not",
"pinned_row_titles",
":",
"return",
"pinned_row_titles_lower",
"=",
"[",
"]",
"for",
"title",
"i... | Pin rows to the top of the dashboard. | [
"Pin",
"rows",
"to",
"the",
"top",
"of",
"the",
"dashboard",
"."
] | python | train | 34.75 |
numenta/htmresearch | projects/combined_sequences/combined_sequences.py | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/combined_sequences/combined_sequences.py#L369-L578 | def runExperiment(args):
"""
Runs the experiment. The code is organized around what we need for specific
figures in the paper.
args is a dict representing the various parameters. We do it this way to
support multiprocessing. The function returns the args dict updated with a
number of additional keys conta... | [
"def",
"runExperiment",
"(",
"args",
")",
":",
"numObjects",
"=",
"args",
".",
"get",
"(",
"\"numObjects\"",
",",
"10",
")",
"numSequences",
"=",
"args",
".",
"get",
"(",
"\"numSequences\"",
",",
"10",
")",
"numFeatures",
"=",
"args",
".",
"get",
"(",
... | Runs the experiment. The code is organized around what we need for specific
figures in the paper.
args is a dict representing the various parameters. We do it this way to
support multiprocessing. The function returns the args dict updated with a
number of additional keys containing performance metrics. | [
"Runs",
"the",
"experiment",
".",
"The",
"code",
"is",
"organized",
"around",
"what",
"we",
"need",
"for",
"specific",
"figures",
"in",
"the",
"paper",
"."
] | python | train | 37.019048 |
nerdvegas/rez | src/rez/vendor/amqp/serialization.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/amqp/serialization.py#L315-L328 | def write_shortstr(self, s):
"""Write a string up to 255 bytes long (after any encoding).
If passed a unicode string, encode with UTF-8.
"""
self._flushbits()
if isinstance(s, string):
s = s.encode('utf-8')
if len(s) > 255:
raise FrameSyntaxError... | [
"def",
"write_shortstr",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"_flushbits",
"(",
")",
"if",
"isinstance",
"(",
"s",
",",
"string",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"len",
"(",
"s",
")",
">",
"255",
":"... | Write a string up to 255 bytes long (after any encoding).
If passed a unicode string, encode with UTF-8. | [
"Write",
"a",
"string",
"up",
"to",
"255",
"bytes",
"long",
"(",
"after",
"any",
"encoding",
")",
"."
] | python | train | 31 |
gwastro/pycbc | pycbc/fft/fftw.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/fft/fftw.py#L494-L516 | def verify_fft_options(opt,parser):
"""Parses the FFT options and verifies that they are
reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes.
parser : object
OptionParser instance.
... | [
"def",
"verify_fft_options",
"(",
"opt",
",",
"parser",
")",
":",
"if",
"opt",
".",
"fftw_measure_level",
"not",
"in",
"[",
"0",
",",
"1",
",",
"2",
",",
"3",
"]",
":",
"parser",
".",
"error",
"(",
"\"{0} is not a valid FFTW measure level.\"",
".",
"format... | Parses the FFT options and verifies that they are
reasonable.
Parameters
----------
opt : object
Result of parsing the CLI with OptionParser, or any object with the
required attributes.
parser : object
OptionParser instance. | [
"Parses",
"the",
"FFT",
"options",
"and",
"verifies",
"that",
"they",
"are",
"reasonable",
"."
] | python | train | 45.086957 |
senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L746-L758 | def is_uid(uid):
"""Checks if the passed in uid is a valid UID
:param uid: The uid to check
:type uid: string
:return: True if the uid is a valid 32 alphanumeric uid or '0'
:rtype: bool
"""
if not isinstance(uid, basestring):
return False
if uid != "0" and len(uid) != 32:
... | [
"def",
"is_uid",
"(",
"uid",
")",
":",
"if",
"not",
"isinstance",
"(",
"uid",
",",
"basestring",
")",
":",
"return",
"False",
"if",
"uid",
"!=",
"\"0\"",
"and",
"len",
"(",
"uid",
")",
"!=",
"32",
":",
"return",
"False",
"return",
"True"
] | Checks if the passed in uid is a valid UID
:param uid: The uid to check
:type uid: string
:return: True if the uid is a valid 32 alphanumeric uid or '0'
:rtype: bool | [
"Checks",
"if",
"the",
"passed",
"in",
"uid",
"is",
"a",
"valid",
"UID"
] | python | train | 26 |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/__init__.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/__init__.py#L350-L358 | def drawing_update(self):
'''update line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_line.append(self.click_position)
if len(self.draw_line) > 1:
self.mpstate.map.add_object(mp_slipmap.Sli... | [
"def",
"drawing_update",
"(",
"self",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"mavproxy_map",
"import",
"mp_slipmap",
"if",
"self",
".",
"draw_callback",
"is",
"None",
":",
"return",
"self",
".",
"draw_line",
".",
"append",
"(",
"self",
".",
"cl... | update line drawing | [
"update",
"line",
"drawing"
] | python | train | 50.888889 |
mbj4668/pyang | pyang/yin_parser.py | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/yin_parser.py#L377-L390 | def search_definition(self, module, keyword, arg):
"""Search for a defintion with `keyword` `name`
Search the module and its submodules."""
r = module.search_one(keyword, arg)
if r is not None:
return r
for i in module.search('include'):
modulename = i.arg... | [
"def",
"search_definition",
"(",
"self",
",",
"module",
",",
"keyword",
",",
"arg",
")",
":",
"r",
"=",
"module",
".",
"search_one",
"(",
"keyword",
",",
"arg",
")",
"if",
"r",
"is",
"not",
"None",
":",
"return",
"r",
"for",
"i",
"in",
"module",
".... | Search for a defintion with `keyword` `name`
Search the module and its submodules. | [
"Search",
"for",
"a",
"defintion",
"with",
"keyword",
"name",
"Search",
"the",
"module",
"and",
"its",
"submodules",
"."
] | python | train | 37.5 |
SoCo/SoCo | soco/ms_data_structures.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/ms_data_structures.py#L151-L160 | def from_dict(cls, dict_in):
"""Initialize the class from a dict.
:param dict_in: The dictionary that contains the item content. Required
fields are listed class variable by that name
:type dict_in: dict
"""
kwargs = dict_in.copy()
args = [kwargs.pop(key) for... | [
"def",
"from_dict",
"(",
"cls",
",",
"dict_in",
")",
":",
"kwargs",
"=",
"dict_in",
".",
"copy",
"(",
")",
"args",
"=",
"[",
"kwargs",
".",
"pop",
"(",
"key",
")",
"for",
"key",
"in",
"cls",
".",
"required_fields",
"]",
"return",
"cls",
"(",
"*",
... | Initialize the class from a dict.
:param dict_in: The dictionary that contains the item content. Required
fields are listed class variable by that name
:type dict_in: dict | [
"Initialize",
"the",
"class",
"from",
"a",
"dict",
"."
] | python | train | 37.5 |
OSSOS/MOP | src/jjk/preproc/MOPwindow.py | https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/MOPwindow.py#L41-L133 | def list(self,header,choices):
"Display list of choices. As many as we can get in a page."
if not self.__list_window:
(y,x)=self.__main.getmaxyx()
self.__list_window = self.__main.subwin(35,x,0,0)
_lw=self.__list_window
_lw.keypad(1)
(y_ma... | [
"def",
"list",
"(",
"self",
",",
"header",
",",
"choices",
")",
":",
"if",
"not",
"self",
".",
"__list_window",
":",
"(",
"y",
",",
"x",
")",
"=",
"self",
".",
"__main",
".",
"getmaxyx",
"(",
")",
"self",
".",
"__list_window",
"=",
"self",
".",
"... | Display list of choices. As many as we can get in a page. | [
"Display",
"list",
"of",
"choices",
".",
"As",
"many",
"as",
"we",
"can",
"get",
"in",
"a",
"page",
"."
] | python | train | 36.817204 |
chrisspen/burlap | burlap/deb.py | https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/deb.py#L162-L173 | def apt_key_exists(keyid):
"""
Check if the given key id exists in apt keyring.
"""
# Command extracted from apt-key source
gpg_cmd = 'gpg --ignore-time-conflict --no-options --no-default-keyring --keyring /etc/apt/trusted.gpg'
with settings(hide('everything'), warn_only=True):
res = r... | [
"def",
"apt_key_exists",
"(",
"keyid",
")",
":",
"# Command extracted from apt-key source",
"gpg_cmd",
"=",
"'gpg --ignore-time-conflict --no-options --no-default-keyring --keyring /etc/apt/trusted.gpg'",
"with",
"settings",
"(",
"hide",
"(",
"'everything'",
")",
",",
"warn_only"... | Check if the given key id exists in apt keyring. | [
"Check",
"if",
"the",
"given",
"key",
"id",
"exists",
"in",
"apt",
"keyring",
"."
] | python | valid | 32.25 |
googleapis/google-cloud-python | firestore/google/cloud/firestore_v1beta1/collection.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/collection.py#L325-L343 | def start_after(self, document_fields):
"""Start query after a cursor with this collection as parent.
See
:meth:`~.firestore_v1beta1.query.Query.start_after` for
more information on this method.
Args:
document_fields (Union[~.firestore_v1beta1.\
docu... | [
"def",
"start_after",
"(",
"self",
",",
"document_fields",
")",
":",
"query",
"=",
"query_mod",
".",
"Query",
"(",
"self",
")",
"return",
"query",
".",
"start_after",
"(",
"document_fields",
")"
] | Start query after a cursor with this collection as parent.
See
:meth:`~.firestore_v1beta1.query.Query.start_after` for
more information on this method.
Args:
document_fields (Union[~.firestore_v1beta1.\
document.DocumentSnapshot, dict, list, tuple]): a docum... | [
"Start",
"query",
"after",
"a",
"cursor",
"with",
"this",
"collection",
"as",
"parent",
"."
] | python | train | 39.736842 |
SheffieldML/GPy | GPy/util/linalg.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/util/linalg.py#L339-L349 | def DSYR_numpy(A, x, alpha=1.):
"""
Performs a symmetric rank-1 update operation:
A <- A + alpha * np.dot(x,x.T)
:param A: Symmetric NxN np.array
:param x: Nx1 np.array
:param alpha: scalar
"""
A += alpha * np.dot(x[:, None], x[None, :]) | [
"def",
"DSYR_numpy",
"(",
"A",
",",
"x",
",",
"alpha",
"=",
"1.",
")",
":",
"A",
"+=",
"alpha",
"*",
"np",
".",
"dot",
"(",
"x",
"[",
":",
",",
"None",
"]",
",",
"x",
"[",
"None",
",",
":",
"]",
")"
] | Performs a symmetric rank-1 update operation:
A <- A + alpha * np.dot(x,x.T)
:param A: Symmetric NxN np.array
:param x: Nx1 np.array
:param alpha: scalar | [
"Performs",
"a",
"symmetric",
"rank",
"-",
"1",
"update",
"operation",
":",
"A",
"<",
"-",
"A",
"+",
"alpha",
"*",
"np",
".",
"dot",
"(",
"x",
"x",
".",
"T",
")"
] | python | train | 23.727273 |
kubernetes-client/python | kubernetes/client/apis/apps_v1_api.py | https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/apps_v1_api.py#L5070-L5093 | def read_namespaced_deployment(self, name, namespace, **kwargs):
"""
read the specified Deployment
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_deployment(name, namespace... | [
"def",
"read_namespaced_deployment",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
"."... | read the specified Deployment
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_deployment(name, namespace, async_req=True)
>>> result = thread.get()
:param async_req bool
... | [
"read",
"the",
"specified",
"Deployment",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"pass",
"async_req",
"=",
"True",
">>>",
"thread",
"=",
"api",
... | python | train | 57.416667 |
IBMStreams/pypi.streamsx | streamsx/rest_primitives.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest_primitives.py#L1223-L1245 | def retrieve_console_log(self, filename=None, dir=None):
"""Retrieves the application console log (standard out and error)
files for this PE and saves them as a plain text file.
An existing file with the same name will be overwritten.
Args:
filename (str): name of the creat... | [
"def",
"retrieve_console_log",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"dir",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"consoleLog\"",
")",
"and",
"self",
".",
"consoleLog",
"is",
"not",
"None",
":",
"logger",
".",
"debug",
"... | Retrieves the application console log (standard out and error)
files for this PE and saves them as a plain text file.
An existing file with the same name will be overwritten.
Args:
filename (str): name of the created file. Defaults to `pe_<id>_<timestamp>.stdouterr` where `id` is t... | [
"Retrieves",
"the",
"application",
"console",
"log",
"(",
"standard",
"out",
"and",
"error",
")",
"files",
"for",
"this",
"PE",
"and",
"saves",
"them",
"as",
"a",
"plain",
"text",
"file",
"."
] | python | train | 51.782609 |
PyCQA/pylint | pylint/config.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/config.py#L643-L645 | def global_set_option(self, opt, value):
"""set option on the correct option provider"""
self._all_options[opt].set_option(opt, value) | [
"def",
"global_set_option",
"(",
"self",
",",
"opt",
",",
"value",
")",
":",
"self",
".",
"_all_options",
"[",
"opt",
"]",
".",
"set_option",
"(",
"opt",
",",
"value",
")"
] | set option on the correct option provider | [
"set",
"option",
"on",
"the",
"correct",
"option",
"provider"
] | python | test | 49.333333 |
angr/angr | angr/state_plugins/fast_memory.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/fast_memory.py#L42-L50 | def _handle_uninitialized_read(self, addr, inspect=True, events=True):
"""
The default uninitialized read handler. Returns symbolic bytes.
"""
if self._uninitialized_read_handler is None:
v = self.state.solver.Unconstrained("%s_%s" % (self.id, addr), self.width*self.state.arc... | [
"def",
"_handle_uninitialized_read",
"(",
"self",
",",
"addr",
",",
"inspect",
"=",
"True",
",",
"events",
"=",
"True",
")",
":",
"if",
"self",
".",
"_uninitialized_read_handler",
"is",
"None",
":",
"v",
"=",
"self",
".",
"state",
".",
"solver",
".",
"Un... | The default uninitialized read handler. Returns symbolic bytes. | [
"The",
"default",
"uninitialized",
"read",
"handler",
".",
"Returns",
"symbolic",
"bytes",
"."
] | python | train | 63.666667 |
signalfx/signalfx-python | signalfx/pyformance/registry.py | https://github.com/signalfx/signalfx-python/blob/650eb9a2b301bcc795e4e3a8c031574ade69849d/signalfx/pyformance/registry.py#L93-L95 | def counter(self, key, **dims):
"""Adds counter with dimensions to the registry"""
return super(RegexRegistry, self).counter(self._get_key(key), **dims) | [
"def",
"counter",
"(",
"self",
",",
"key",
",",
"*",
"*",
"dims",
")",
":",
"return",
"super",
"(",
"RegexRegistry",
",",
"self",
")",
".",
"counter",
"(",
"self",
".",
"_get_key",
"(",
"key",
")",
",",
"*",
"*",
"dims",
")"
] | Adds counter with dimensions to the registry | [
"Adds",
"counter",
"with",
"dimensions",
"to",
"the",
"registry"
] | python | train | 55.333333 |
metric-learn/metric-learn | metric_learn/mmc.py | https://github.com/metric-learn/metric-learn/blob/d945df1342c69012608bb70b92520392a0853de6/metric_learn/mmc.py#L305-L316 | def _fS1(self, pos_pairs, A):
"""The gradient of the similarity constraint function w.r.t. A.
f = \sum_{ij}(x_i-x_j)A(x_i-x_j)' = \sum_{ij}d_ij*A*d_ij'
df/dA = d(d_ij*A*d_ij')/dA
Note that d_ij*A*d_ij' = tr(d_ij*A*d_ij') = tr(d_ij'*d_ij*A)
so, d(d_ij*A*d_ij')/dA = d_ij'*d_ij
"""
dim = pos_... | [
"def",
"_fS1",
"(",
"self",
",",
"pos_pairs",
",",
"A",
")",
":",
"dim",
"=",
"pos_pairs",
".",
"shape",
"[",
"2",
"]",
"diff",
"=",
"pos_pairs",
"[",
":",
",",
"0",
",",
":",
"]",
"-",
"pos_pairs",
"[",
":",
",",
"1",
",",
":",
"]",
"return"... | The gradient of the similarity constraint function w.r.t. A.
f = \sum_{ij}(x_i-x_j)A(x_i-x_j)' = \sum_{ij}d_ij*A*d_ij'
df/dA = d(d_ij*A*d_ij')/dA
Note that d_ij*A*d_ij' = tr(d_ij*A*d_ij') = tr(d_ij'*d_ij*A)
so, d(d_ij*A*d_ij')/dA = d_ij'*d_ij | [
"The",
"gradient",
"of",
"the",
"similarity",
"constraint",
"function",
"w",
".",
"r",
".",
"t",
".",
"A",
"."
] | python | train | 35 |
CodyKochmann/generators | generators/multi_ops.py | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/multi_ops.py#L10-L23 | def multi_ops(data_stream, *funcs):
""" fork a generator with multiple operations/functions
data_stream - an iterable data structure (ie: list/generator/tuple)
funcs - every function that will be applied to the data_stream """
assert all(callable(func) for func in funcs), 'multi_ops ... | [
"def",
"multi_ops",
"(",
"data_stream",
",",
"*",
"funcs",
")",
":",
"assert",
"all",
"(",
"callable",
"(",
"func",
")",
"for",
"func",
"in",
"funcs",
")",
",",
"'multi_ops can only apply functions to the first argument'",
"assert",
"len",
"(",
"funcs",
")",
"... | fork a generator with multiple operations/functions
data_stream - an iterable data structure (ie: list/generator/tuple)
funcs - every function that will be applied to the data_stream | [
"fork",
"a",
"generator",
"with",
"multiple",
"operations",
"/",
"functions"
] | python | train | 43.285714 |
FNNDSC/pfdicom | pfdicom/pfdicom.py | https://github.com/FNNDSC/pfdicom/blob/91a0426c514a3496cb2e0576481055a47afee8d8/pfdicom/pfdicom.py#L377-L391 | def ret_dump(self, d_ret, **kwargs):
"""
JSON print results to console (or caller)
"""
b_print = True
for k, v in kwargs.items():
if k == 'JSONprint': b_print = bool(v)
if b_print:
print(
json.dumps(
... | [
"def",
"ret_dump",
"(",
"self",
",",
"d_ret",
",",
"*",
"*",
"kwargs",
")",
":",
"b_print",
"=",
"True",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'JSONprint'",
":",
"b_print",
"=",
"bool",
"(",
"v",
"... | JSON print results to console (or caller) | [
"JSON",
"print",
"results",
"to",
"console",
"(",
"or",
"caller",
")"
] | python | train | 27.933333 |
codelv/enaml-native | src/enamlnative/android/android_popup_window.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L82-L94 | def init_widget(self):
""" Set the listeners
"""
w = self.window
d = self.declaration
self.set_background_color(d.background_color)
self.set_touchable(d.touchable)
self.set_outside_touchable(d.outside_touchable)
# Listen for events
w.setOnDismissL... | [
"def",
"init_widget",
"(",
"self",
")",
":",
"w",
"=",
"self",
".",
"window",
"d",
"=",
"self",
".",
"declaration",
"self",
".",
"set_background_color",
"(",
"d",
".",
"background_color",
")",
"self",
".",
"set_touchable",
"(",
"d",
".",
"touchable",
")"... | Set the listeners | [
"Set",
"the",
"listeners"
] | python | train | 32.692308 |
mozilla/treeherder | treeherder/model/models.py | https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/model/models.py#L832-L849 | def _update_failure_type(self):
"""
Updates the failure type of this Note's Job.
Set the linked Job's failure type to that of the most recent JobNote or
set to Not Classified if there are no JobNotes.
This is called when JobNotes are created (via .save()) and deleted (via
... | [
"def",
"_update_failure_type",
"(",
"self",
")",
":",
"# update the job classification",
"note",
"=",
"JobNote",
".",
"objects",
".",
"filter",
"(",
"job",
"=",
"self",
".",
"job",
")",
".",
"order_by",
"(",
"'-created'",
")",
".",
"first",
"(",
")",
"if",... | Updates the failure type of this Note's Job.
Set the linked Job's failure type to that of the most recent JobNote or
set to Not Classified if there are no JobNotes.
This is called when JobNotes are created (via .save()) and deleted (via
.delete()) and is used to resolved the FailureCla... | [
"Updates",
"the",
"failure",
"type",
"of",
"this",
"Note",
"s",
"Job",
"."
] | python | train | 43.833333 |
RudolfCardinal/pythonlib | cardinal_pythonlib/file_io.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/file_io.py#L136-L150 | def get_lines_without_comments(filename: str) -> List[str]:
"""
Reads a file, and returns all lines as a list, left- and right-stripping
the lines and removing everything on a line after the first ``#``.
NOTE: does not cope well with quoted ``#`` symbols!
"""
lines = []
with open(filename) a... | [
"def",
"get_lines_without_comments",
"(",
"filename",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"lines",
"=",
"[",
"]",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"parti... | Reads a file, and returns all lines as a list, left- and right-stripping
the lines and removing everything on a line after the first ``#``.
NOTE: does not cope well with quoted ``#`` symbols! | [
"Reads",
"a",
"file",
"and",
"returns",
"all",
"lines",
"as",
"a",
"list",
"left",
"-",
"and",
"right",
"-",
"stripping",
"the",
"lines",
"and",
"removing",
"everything",
"on",
"a",
"line",
"after",
"the",
"first",
"#",
".",
"NOTE",
":",
"does",
"not",... | python | train | 36.333333 |
krinj/k-util | k_util/region.py | https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/region.py#L97-L103 | def canvas_resize(self, scale):
""" Resize this region against the entire axis space. """
self._top *= scale
self._bottom *= scale
self._left *= scale
self._right *= scale
self._calibrate_to_rect() | [
"def",
"canvas_resize",
"(",
"self",
",",
"scale",
")",
":",
"self",
".",
"_top",
"*=",
"scale",
"self",
".",
"_bottom",
"*=",
"scale",
"self",
".",
"_left",
"*=",
"scale",
"self",
".",
"_right",
"*=",
"scale",
"self",
".",
"_calibrate_to_rect",
"(",
"... | Resize this region against the entire axis space. | [
"Resize",
"this",
"region",
"against",
"the",
"entire",
"axis",
"space",
"."
] | python | train | 34.142857 |
xmikos/soapy_power | soapypower/power.py | https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L91-L93 | def time_to_repeats(self, bins, integration_time):
"""Convert integration time to number of repeats"""
return math.ceil((self.device.sample_rate * integration_time) / bins) | [
"def",
"time_to_repeats",
"(",
"self",
",",
"bins",
",",
"integration_time",
")",
":",
"return",
"math",
".",
"ceil",
"(",
"(",
"self",
".",
"device",
".",
"sample_rate",
"*",
"integration_time",
")",
"/",
"bins",
")"
] | Convert integration time to number of repeats | [
"Convert",
"integration",
"time",
"to",
"number",
"of",
"repeats"
] | python | test | 62 |
hyperledger/indy-node | data/migrations/deb/disabled_1_0_97_to_1_0_96.py | https://github.com/hyperledger/indy-node/blob/8fabd364eaf7d940a56df2911d9215b1e512a2de/data/migrations/deb/disabled_1_0_97_to_1_0_96.py#L23-L72 | def _migrate_ledger(data_directory,
old_ledger_file, new_ledger_file,
serializer: MappingSerializer = None):
"""
Test for the directory, open old and new ledger, migrate data, rename directories
"""
# we should have ChunkedFileStorage implementation of the Ledger... | [
"def",
"_migrate_ledger",
"(",
"data_directory",
",",
"old_ledger_file",
",",
"new_ledger_file",
",",
"serializer",
":",
"MappingSerializer",
"=",
"None",
")",
":",
"# we should have ChunkedFileStorage implementation of the Ledger",
"if",
"not",
"os",
".",
"path",
".",
... | Test for the directory, open old and new ledger, migrate data, rename directories | [
"Test",
"for",
"the",
"directory",
"open",
"old",
"and",
"new",
"ledger",
"migrate",
"data",
"rename",
"directories"
] | python | train | 40.34 |
OCR-D/core | ocrd/ocrd/workspace.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd/ocrd/workspace.py#L58-L71 | def download_url(self, url, **kwargs):
"""
Download a URL to the workspace.
Args:
url (string): URL to download to directory
**kwargs : See :py:mod:`ocrd.resolver.Resolver`
Returns:
The local filename of the downloaded file
"""
if sel... | [
"def",
"download_url",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"baseurl",
"and",
"'://'",
"not",
"in",
"url",
":",
"url",
"=",
"join",
"(",
"self",
".",
"baseurl",
",",
"url",
")",
"return",
"self",
".",
"re... | Download a URL to the workspace.
Args:
url (string): URL to download to directory
**kwargs : See :py:mod:`ocrd.resolver.Resolver`
Returns:
The local filename of the downloaded file | [
"Download",
"a",
"URL",
"to",
"the",
"workspace",
"."
] | python | train | 33 |
Crunch-io/crunch-cube | src/cr/cube/measures/wishart_pairwise_significance.py | https://github.com/Crunch-io/crunch-cube/blob/a837840755690eb14b2ec8e8d93b4104e01c854f/src/cr/cube/measures/wishart_pairwise_significance.py#L97-L109 | def _intersperse_insertion_rows_and_columns(self, pairwise_pvals):
"""Return pvals matrix with inserted NaN rows and columns, as numpy.ndarray.
Each insertion (a header or a subtotal) creates an offset in the calculated
pvals. These need to be taken into account when converting each pval to a
... | [
"def",
"_intersperse_insertion_rows_and_columns",
"(",
"self",
",",
"pairwise_pvals",
")",
":",
"for",
"i",
"in",
"self",
".",
"_insertion_indices",
":",
"pairwise_pvals",
"=",
"np",
".",
"insert",
"(",
"pairwise_pvals",
",",
"i",
",",
"np",
".",
"nan",
",",
... | Return pvals matrix with inserted NaN rows and columns, as numpy.ndarray.
Each insertion (a header or a subtotal) creates an offset in the calculated
pvals. These need to be taken into account when converting each pval to a
corresponding column letter. For this reason, we need to insert an all-... | [
"Return",
"pvals",
"matrix",
"with",
"inserted",
"NaN",
"rows",
"and",
"columns",
"as",
"numpy",
".",
"ndarray",
"."
] | python | train | 58.076923 |
zhanglab/psamm | psamm/fastcore.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/fastcore.py#L116-L145 | def find_sparse_mode(self, core, additional, scaling, weights={}):
"""Find a sparse mode containing reactions of the core subset.
Return an iterator of the support of a sparse mode that contains as
many reactions from core as possible, and as few reactions from
additional as possible (a... | [
"def",
"find_sparse_mode",
"(",
"self",
",",
"core",
",",
"additional",
",",
"scaling",
",",
"weights",
"=",
"{",
"}",
")",
":",
"if",
"len",
"(",
"core",
")",
"==",
"0",
":",
"return",
"self",
".",
"lp7",
"(",
"core",
")",
"k",
"=",
"set",
"(",
... | Find a sparse mode containing reactions of the core subset.
Return an iterator of the support of a sparse mode that contains as
many reactions from core as possible, and as few reactions from
additional as possible (approximately). A dictionary of weights can be
supplied which gives fur... | [
"Find",
"a",
"sparse",
"mode",
"containing",
"reactions",
"of",
"the",
"core",
"subset",
"."
] | python | train | 34.366667 |
bwesterb/displays | src/table.py | https://github.com/bwesterb/displays/blob/37764a3ce1be5e7b3c3bee8e4853554ed0417a82/src/table.py#L184-L194 | def layout(self):
""" Calculate the widths of the columns to set the table """
ret = []
for row in self.rows:
if len(row) > len(ret):
ret += [0] * (len(row) - len(ret))
for n, field in enumera... | [
"def",
"layout",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
".",
"rows",
":",
"if",
"len",
"(",
"row",
")",
">",
"len",
"(",
"ret",
")",
":",
"ret",
"+=",
"[",
"0",
"]",
"*",
"(",
"len",
"(",
"row",
")",
"-",... | Calculate the widths of the columns to set the table | [
"Calculate",
"the",
"widths",
"of",
"the",
"columns",
"to",
"set",
"the",
"table"
] | python | train | 47.545455 |
jciskey/pygraph | pygraph/functions/planarity/kocay_algorithm.py | https://github.com/jciskey/pygraph/blob/037bb2f32503fecb60d62921f9766d54109f15e2/pygraph/functions/planarity/kocay_algorithm.py#L968-L974 | def B(u, v, dfs_data):
"""The branch at u containing v is the set of all edges incident on v or any descendant of v, if a(v) == u."""
"""Bu(v) = {wx | w is in S*(v)}"""
if a(v, dfs_data) != u:
return None
return list(set([edge_id for w in S_star(v, dfs_data) for edge_id in dfs_data['graph'].get... | [
"def",
"B",
"(",
"u",
",",
"v",
",",
"dfs_data",
")",
":",
"\"\"\"Bu(v) = {wx | w is in S*(v)}\"\"\"",
"if",
"a",
"(",
"v",
",",
"dfs_data",
")",
"!=",
"u",
":",
"return",
"None",
"return",
"list",
"(",
"set",
"(",
"[",
"edge_id",
"for",
"w",
"in",
"... | The branch at u containing v is the set of all edges incident on v or any descendant of v, if a(v) == u. | [
"The",
"branch",
"at",
"u",
"containing",
"v",
"is",
"the",
"set",
"of",
"all",
"edges",
"incident",
"on",
"v",
"or",
"any",
"descendant",
"of",
"v",
"if",
"a",
"(",
"v",
")",
"==",
"u",
"."
] | python | train | 47.714286 |
hadim/pygraphml | pygraphml/edge.py | https://github.com/hadim/pygraphml/blob/dce007bd7f078427c73a2a1d6f4b834af1b4dc03/pygraphml/edge.py#L29-L39 | def node(self, node):
"""
Return the other node
"""
if node == self.node1:
return self.node2
elif node == self.node2:
return self.node1
else:
return None | [
"def",
"node",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"==",
"self",
".",
"node1",
":",
"return",
"self",
".",
"node2",
"elif",
"node",
"==",
"self",
".",
"node2",
":",
"return",
"self",
".",
"node1",
"else",
":",
"return",
"None"
] | Return the other node | [
"Return",
"the",
"other",
"node"
] | python | valid | 20.727273 |
mbedmicro/pyOCD | pyocd/flash/flash_builder.py | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/flash/flash_builder.py#L214-L223 | def _enable_read_access(self):
"""! @brief Ensure flash is accessible by initing the algo for verify.
Not all flash memories are always accessible. For instance, external QSPI. Initing the
flash algo for the VERIFY operation is the canonical way to ensure that the flash is
memor... | [
"def",
"_enable_read_access",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"algo_inited_for_read",
":",
"self",
".",
"flash",
".",
"init",
"(",
"self",
".",
"flash",
".",
"Operation",
".",
"VERIFY",
")",
"self",
".",
"algo_inited_for_read",
"=",
"True"... | ! @brief Ensure flash is accessible by initing the algo for verify.
Not all flash memories are always accessible. For instance, external QSPI. Initing the
flash algo for the VERIFY operation is the canonical way to ensure that the flash is
memory mapped and accessible. | [
"!"
] | python | train | 49.1 |
pgmpy/pgmpy | pgmpy/extern/tabulate.py | https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/extern/tabulate.py#L840-L847 | def _build_row(padded_cells, colwidths, colaligns, rowfmt):
"Return a string which represents a row of data cells."
if not rowfmt:
return None
if hasattr(rowfmt, "__call__"):
return rowfmt(padded_cells, colwidths, colaligns)
else:
return _build_simple_row(padded_cells, rowfmt) | [
"def",
"_build_row",
"(",
"padded_cells",
",",
"colwidths",
",",
"colaligns",
",",
"rowfmt",
")",
":",
"if",
"not",
"rowfmt",
":",
"return",
"None",
"if",
"hasattr",
"(",
"rowfmt",
",",
"\"__call__\"",
")",
":",
"return",
"rowfmt",
"(",
"padded_cells",
","... | Return a string which represents a row of data cells. | [
"Return",
"a",
"string",
"which",
"represents",
"a",
"row",
"of",
"data",
"cells",
"."
] | python | train | 38.75 |
scanny/python-pptx | pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/fonts.py#L324-L339 | def _iter_names(self):
"""
Generate a key/value pair for each name in this table. The key is a
(platform_id, name_id) 2-tuple and the value is the unicode text
corresponding to that key.
"""
table_format, count, strings_offset = self._table_header
table_bytes = se... | [
"def",
"_iter_names",
"(",
"self",
")",
":",
"table_format",
",",
"count",
",",
"strings_offset",
"=",
"self",
".",
"_table_header",
"table_bytes",
"=",
"self",
".",
"_table_bytes",
"for",
"idx",
"in",
"range",
"(",
"count",
")",
":",
"platform_id",
",",
"... | Generate a key/value pair for each name in this table. The key is a
(platform_id, name_id) 2-tuple and the value is the unicode text
corresponding to that key. | [
"Generate",
"a",
"key",
"/",
"value",
"pair",
"for",
"each",
"name",
"in",
"this",
"table",
".",
"The",
"key",
"is",
"a",
"(",
"platform_id",
"name_id",
")",
"2",
"-",
"tuple",
"and",
"the",
"value",
"is",
"the",
"unicode",
"text",
"corresponding",
"to... | python | train | 36.125 |
modin-project/modin | modin/pandas/base.py | https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/pandas/base.py#L1264-L1274 | def get_dtype_counts(self):
"""Get the counts of dtypes in this object.
Returns:
The counts of dtypes in this object.
"""
if hasattr(self, "dtype"):
return pandas.Series({str(self.dtype): 1})
result = self.dtypes.value_counts()
result.ind... | [
"def",
"get_dtype_counts",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"dtype\"",
")",
":",
"return",
"pandas",
".",
"Series",
"(",
"{",
"str",
"(",
"self",
".",
"dtype",
")",
":",
"1",
"}",
")",
"result",
"=",
"self",
".",
"dtypes"... | Get the counts of dtypes in this object.
Returns:
The counts of dtypes in this object. | [
"Get",
"the",
"counts",
"of",
"dtypes",
"in",
"this",
"object",
".",
"Returns",
":",
"The",
"counts",
"of",
"dtypes",
"in",
"this",
"object",
"."
] | python | train | 33.818182 |
ejeschke/ginga | ginga/BaseImage.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/BaseImage.py#L293-L300 | def cutout_data(self, x1, y1, x2, y2, xstep=1, ystep=1, astype=None):
"""cut out data area based on coords.
"""
view = np.s_[y1:y2:ystep, x1:x2:xstep]
data = self._slice(view)
if astype:
data = data.astype(astype, copy=False)
return data | [
"def",
"cutout_data",
"(",
"self",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"xstep",
"=",
"1",
",",
"ystep",
"=",
"1",
",",
"astype",
"=",
"None",
")",
":",
"view",
"=",
"np",
".",
"s_",
"[",
"y1",
":",
"y2",
":",
"ystep",
",",
"x1"... | cut out data area based on coords. | [
"cut",
"out",
"data",
"area",
"based",
"on",
"coords",
"."
] | python | train | 36.25 |
shad7/tvrenamer | tvrenamer/core/episode.py | https://github.com/shad7/tvrenamer/blob/7fb59cb02669357e73b7acb92dcb6d74fdff4654/tvrenamer/core/episode.py#L191-L214 | def enhance(self):
"""Load metadata from a data service to improve naming.
:raises tvrenamer.exceptions.ShowNotFound:
when unable to find show/series name based on parsed name
:raises tvrenamer.exceptions.EpisodeNotFound:
when unable to find episode name(s) based on pars... | [
"def",
"enhance",
"(",
"self",
")",
":",
"series",
",",
"error",
"=",
"self",
".",
"api",
".",
"get_series_by_name",
"(",
"self",
".",
"series_name",
")",
"if",
"series",
"is",
"None",
":",
"self",
".",
"messages",
".",
"append",
"(",
"str",
"(",
"er... | Load metadata from a data service to improve naming.
:raises tvrenamer.exceptions.ShowNotFound:
when unable to find show/series name based on parsed name
:raises tvrenamer.exceptions.EpisodeNotFound:
when unable to find episode name(s) based on parsed data | [
"Load",
"metadata",
"from",
"a",
"data",
"service",
"to",
"improve",
"naming",
"."
] | python | train | 37.833333 |
ibis-project/ibis | ibis/impala/client.py | https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/impala/client.py#L1045-L1050 | def get_options(self):
"""
Return current query options for the Impala session
"""
query = 'SET'
return dict(row[:2] for row in self.con.fetchall(query)) | [
"def",
"get_options",
"(",
"self",
")",
":",
"query",
"=",
"'SET'",
"return",
"dict",
"(",
"row",
"[",
":",
"2",
"]",
"for",
"row",
"in",
"self",
".",
"con",
".",
"fetchall",
"(",
"query",
")",
")"
] | Return current query options for the Impala session | [
"Return",
"current",
"query",
"options",
"for",
"the",
"Impala",
"session"
] | python | train | 31.333333 |
zaturox/glin | glin/app.py | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/app.py#L47-L54 | def set_brightness(self, brightness):
"""set general brightness in range 0...1"""
brightness = min([1.0, max([brightness, 0.0])]) # enforces range 0 ... 1
self.state.brightness = brightness
self._repeat_last_frame()
sequence_number = self.zmq_publisher.publish_brightness(brightne... | [
"def",
"set_brightness",
"(",
"self",
",",
"brightness",
")",
":",
"brightness",
"=",
"min",
"(",
"[",
"1.0",
",",
"max",
"(",
"[",
"brightness",
",",
"0.0",
"]",
")",
"]",
")",
"# enforces range 0 ... 1",
"self",
".",
"state",
".",
"brightness",
"=",
... | set general brightness in range 0...1 | [
"set",
"general",
"brightness",
"in",
"range",
"0",
"...",
"1"
] | python | train | 58 |
ansible/tower-cli | tower_cli/cli/resource.py | https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/tower_cli/cli/resource.py#L273-L380 | def get_command(self, ctx, name):
"""Retrieve the appropriate method from the Resource,
decorate it as a click command, and return that method.
"""
# Sanity check: Does a method exist corresponding to this
# command? If not, None is returned for click to raise
# exception... | [
"def",
"get_command",
"(",
"self",
",",
"ctx",
",",
"name",
")",
":",
"# Sanity check: Does a method exist corresponding to this",
"# command? If not, None is returned for click to raise",
"# exception.",
"if",
"not",
"hasattr",
"(",
"self",
".",
"resource",
",",
"name",
... | Retrieve the appropriate method from the Resource,
decorate it as a click command, and return that method. | [
"Retrieve",
"the",
"appropriate",
"method",
"from",
"the",
"Resource",
"decorate",
"it",
"as",
"a",
"click",
"command",
"and",
"return",
"that",
"method",
"."
] | python | valid | 42.212963 |
AnalogJ/lexicon | lexicon/providers/hetzner.py | https://github.com/AnalogJ/lexicon/blob/9330b871988753cad44fe2876a217b4c67b1fa0e/lexicon/providers/hetzner.py#L357-L370 | def _convert_content(self, rdtype, content):
"""
Converts type dependent record content into well formed and fully qualified
content for domain zone and returns content.
"""
if rdtype == 'TXT':
if content[0] != '"':
content = '"' + content
... | [
"def",
"_convert_content",
"(",
"self",
",",
"rdtype",
",",
"content",
")",
":",
"if",
"rdtype",
"==",
"'TXT'",
":",
"if",
"content",
"[",
"0",
"]",
"!=",
"'\"'",
":",
"content",
"=",
"'\"'",
"+",
"content",
"if",
"content",
"[",
"-",
"1",
"]",
"!=... | Converts type dependent record content into well formed and fully qualified
content for domain zone and returns content. | [
"Converts",
"type",
"dependent",
"record",
"content",
"into",
"well",
"formed",
"and",
"fully",
"qualified",
"content",
"for",
"domain",
"zone",
"and",
"returns",
"content",
"."
] | python | train | 37.142857 |
QuantEcon/QuantEcon.py | quantecon/estspec.py | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/estspec.py#L9-L67 | def smooth(x, window_len=7, window='hanning'):
"""
Smooth the data in x using convolution with a window of requested
size and type.
Parameters
----------
x : array_like(float)
A flat NumPy array containing the data to smooth
window_len : scalar(int), optional
An odd integer ... | [
"def",
"smooth",
"(",
"x",
",",
"window_len",
"=",
"7",
",",
"window",
"=",
"'hanning'",
")",
":",
"if",
"len",
"(",
"x",
")",
"<",
"window_len",
":",
"raise",
"ValueError",
"(",
"\"Input vector length must be >= window length.\"",
")",
"if",
"window_len",
"... | Smooth the data in x using convolution with a window of requested
size and type.
Parameters
----------
x : array_like(float)
A flat NumPy array containing the data to smooth
window_len : scalar(int), optional
An odd integer giving the length of the window. Defaults to 7.
window... | [
"Smooth",
"the",
"data",
"in",
"x",
"using",
"convolution",
"with",
"a",
"window",
"of",
"requested",
"size",
"and",
"type",
"."
] | python | train | 30.711864 |
CGATOxford/UMI-tools | umi_tools/count.py | https://github.com/CGATOxford/UMI-tools/blob/c4b5d84aac391d59916d294f8f4f8f5378abcfbe/umi_tools/count.py#L65-L227 | def main(argv=None):
"""script main.
parses command line options in sys.argv, unless *argv* is given.
"""
if argv is None:
argv = sys.argv
# setup command line parser
parser = U.OptionParser(version="%prog version: $Id$",
usage=usage,
... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"# setup command line parser",
"parser",
"=",
"U",
".",
"OptionParser",
"(",
"version",
"=",
"\"%prog version: $Id$\"",
",",
"usage",
"=",
... | script main.
parses command line options in sys.argv, unless *argv* is given. | [
"script",
"main",
"."
] | python | train | 30.288344 |
kyan001/PyConsoleIOTools | consoleiotools.py | https://github.com/kyan001/PyConsoleIOTools/blob/cc0cc2b9caf62a0fd1a9a72952a6f8c4d17694c4/consoleiotools.py#L55-L57 | def title(msg, **options):
"""print something like a title"""
return echo(Style.BRIGHT + Fore.CYAN + "__{}__________________________".format(msg.upper().strip()) + Style.RESET_ALL + Fore.RESET, **options) | [
"def",
"title",
"(",
"msg",
",",
"*",
"*",
"options",
")",
":",
"return",
"echo",
"(",
"Style",
".",
"BRIGHT",
"+",
"Fore",
".",
"CYAN",
"+",
"\"__{}__________________________\"",
".",
"format",
"(",
"msg",
".",
"upper",
"(",
")",
".",
"strip",
"(",
... | print something like a title | [
"print",
"something",
"like",
"a",
"title"
] | python | train | 70 |
SeleniumHQ/selenium | py/selenium/webdriver/common/proxy.py | https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/proxy.py#L254-L263 | def socks_proxy(self, value):
"""
Sets socks proxy setting.
:Args:
- value: The socks proxy value.
"""
self._verify_proxy_type_compatibility(ProxyType.MANUAL)
self.proxyType = ProxyType.MANUAL
self.socksProxy = value | [
"def",
"socks_proxy",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_verify_proxy_type_compatibility",
"(",
"ProxyType",
".",
"MANUAL",
")",
"self",
".",
"proxyType",
"=",
"ProxyType",
".",
"MANUAL",
"self",
".",
"socksProxy",
"=",
"value"
] | Sets socks proxy setting.
:Args:
- value: The socks proxy value. | [
"Sets",
"socks",
"proxy",
"setting",
"."
] | python | train | 27.3 |
mitsei/dlkit | dlkit/json_/assessment_authoring/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment_authoring/sessions.py#L1295-L1313 | def get_assessment_parts_by_banks(self, bank_ids):
"""Gets the list of assessment part corresponding to a list of ``Banks``.
arg: bank_ids (osid.id.IdList): list of bank ``Ids``
return: (osid.assessment.authoring.AssessmentPartList) - list of
assessment parts
raise: ... | [
"def",
"get_assessment_parts_by_banks",
"(",
"self",
",",
"bank_ids",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceBinSession.get_resources_by_bins",
"assessment_part_list",
"=",
"[",
"]",
"for",
"bank_id",
"in",
"bank_ids",
":",
"assessment_part_list",... | Gets the list of assessment part corresponding to a list of ``Banks``.
arg: bank_ids (osid.id.IdList): list of bank ``Ids``
return: (osid.assessment.authoring.AssessmentPartList) - list of
assessment parts
raise: NullArgument - ``bank_ids`` is ``null``
raise: Operat... | [
"Gets",
"the",
"list",
"of",
"assessment",
"part",
"corresponding",
"to",
"a",
"list",
"of",
"Banks",
"."
] | python | train | 46.210526 |
orb-framework/orb | orb/core/index.py | https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/index.py#L85-L93 | def columns(self):
"""
Returns the list of column names that this index will be expecting as \
inputs when it is called.
:return [<str>, ..]
"""
schema = self.schema()
return [schema.column(col) for col in self.__columns] | [
"def",
"columns",
"(",
"self",
")",
":",
"schema",
"=",
"self",
".",
"schema",
"(",
")",
"return",
"[",
"schema",
".",
"column",
"(",
"col",
")",
"for",
"col",
"in",
"self",
".",
"__columns",
"]"
] | Returns the list of column names that this index will be expecting as \
inputs when it is called.
:return [<str>, ..] | [
"Returns",
"the",
"list",
"of",
"column",
"names",
"that",
"this",
"index",
"will",
"be",
"expecting",
"as",
"\\",
"inputs",
"when",
"it",
"is",
"called",
".",
":",
"return",
"[",
"<str",
">",
"..",
"]"
] | python | train | 31.333333 |
rigetti/pyquil | pyquil/latex/latex_generation.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/latex/latex_generation.py#L441-L451 | def _phase(self, line, pos):
"""
Places a phase / control circle on a qubit line at a given position.
:param int line: Qubit line at which to place the circle.
:param float pos: Position at which to place the circle.
:return: Latex string representing a control circle at the giv... | [
"def",
"_phase",
"(",
"self",
",",
"line",
",",
"pos",
")",
":",
"phase_str",
"=",
"\"\\n\\\\node[phase] ({}) at ({},-{}) {{}};\"",
"return",
"phase_str",
".",
"format",
"(",
"self",
".",
"_op",
"(",
"line",
")",
",",
"pos",
",",
"line",
")"
] | Places a phase / control circle on a qubit line at a given position.
:param int line: Qubit line at which to place the circle.
:param float pos: Position at which to place the circle.
:return: Latex string representing a control circle at the given position.
:rtype: string | [
"Places",
"a",
"phase",
"/",
"control",
"circle",
"on",
"a",
"qubit",
"line",
"at",
"a",
"given",
"position",
"."
] | python | train | 43.363636 |
bapakode/OmMongo | ommongo/session.py | https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/session.py#L171-L178 | def insert(self, item, safe=None): # pragma: nocover
''' [DEPRECATED] Please use save() instead. This actually calls
the underlying save function, so the name is confusing.
Insert an item into the work queue and flushes.'''
warnings.warn('Insert will be deprecated soon and removed in 1.0. Please use insert',... | [
"def",
"insert",
"(",
"self",
",",
"item",
",",
"safe",
"=",
"None",
")",
":",
"# pragma: nocover",
"warnings",
".",
"warn",
"(",
"'Insert will be deprecated soon and removed in 1.0. Please use insert'",
",",
"PendingDeprecationWarning",
")",
"self",
".",
"add",
"(",
... | [DEPRECATED] Please use save() instead. This actually calls
the underlying save function, so the name is confusing.
Insert an item into the work queue and flushes. | [
"[",
"DEPRECATED",
"]",
"Please",
"use",
"save",
"()",
"instead",
".",
"This",
"actually",
"calls",
"the",
"underlying",
"save",
"function",
"so",
"the",
"name",
"is",
"confusing",
"."
] | python | train | 46.875 |
MacHu-GWU/angora-project | angora/math/interp.py | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/interp.py#L196-L210 | def linear_interpolate_by_datetime(datetime_axis, y_axis, datetime_new_axis,
enable_warning=True):
"""A datetime-version that takes datetime object list as x_axis
"""
numeric_datetime_axis = [
totimestamp(a_datetime) for a_datetime in datetime_axis
]
numer... | [
"def",
"linear_interpolate_by_datetime",
"(",
"datetime_axis",
",",
"y_axis",
",",
"datetime_new_axis",
",",
"enable_warning",
"=",
"True",
")",
":",
"numeric_datetime_axis",
"=",
"[",
"totimestamp",
"(",
"a_datetime",
")",
"for",
"a_datetime",
"in",
"datetime_axis",
... | A datetime-version that takes datetime object list as x_axis | [
"A",
"datetime",
"-",
"version",
"that",
"takes",
"datetime",
"object",
"list",
"as",
"x_axis"
] | python | train | 36.066667 |
AntagonistHQ/openprovider.py | openprovider/util.py | https://github.com/AntagonistHQ/openprovider.py/blob/5871c3d5b3661e23667f147f49f20389c817a0a4/openprovider/util.py#L25-L33 | def snake_to_camel(value):
"""
Converts a snake_case_string to a camelCaseString.
>>> snake_to_camel("foo_bar_baz")
'fooBarBaz'
"""
camel = "".join(word.title() for word in value.split("_"))
return value[:1].lower() + camel[1:] | [
"def",
"snake_to_camel",
"(",
"value",
")",
":",
"camel",
"=",
"\"\"",
".",
"join",
"(",
"word",
".",
"title",
"(",
")",
"for",
"word",
"in",
"value",
".",
"split",
"(",
"\"_\"",
")",
")",
"return",
"value",
"[",
":",
"1",
"]",
".",
"lower",
"(",... | Converts a snake_case_string to a camelCaseString.
>>> snake_to_camel("foo_bar_baz")
'fooBarBaz' | [
"Converts",
"a",
"snake_case_string",
"to",
"a",
"camelCaseString",
"."
] | python | train | 27.555556 |
econ-ark/HARK | HARK/core.py | https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/core.py#L1191-L1230 | def copy_module(target_path, my_directory_full_path, my_module):
'''
Helper function for copy_module_to_local(). Provides the actual copy
functionality, with highly cautious safeguards against copying over
important things.
Parameters
----------
target_path : string
String, file pat... | [
"def",
"copy_module",
"(",
"target_path",
",",
"my_directory_full_path",
",",
"my_module",
")",
":",
"if",
"target_path",
"==",
"'q'",
"or",
"target_path",
"==",
"'Q'",
":",
"print",
"(",
"\"Goodbye!\"",
")",
"return",
"elif",
"target_path",
"==",
"os",
".",
... | Helper function for copy_module_to_local(). Provides the actual copy
functionality, with highly cautious safeguards against copying over
important things.
Parameters
----------
target_path : string
String, file path to target location
my_directory_full_path: string
String, full... | [
"Helper",
"function",
"for",
"copy_module_to_local",
"()",
".",
"Provides",
"the",
"actual",
"copy",
"functionality",
"with",
"highly",
"cautious",
"safeguards",
"against",
"copying",
"over",
"important",
"things",
"."
] | python | train | 41.85 |
spyder-ide/spyder | spyder/preferences/languageserver.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L955-L968 | def setup_docstring_style_convention(self, text):
"""Handle convention changes."""
if text == 'Custom':
self.docstring_style_select.label.setText(
_("Show the following errors:"))
self.docstring_style_ignore.label.setText(
_("Ignore the following e... | [
"def",
"setup_docstring_style_convention",
"(",
"self",
",",
"text",
")",
":",
"if",
"text",
"==",
"'Custom'",
":",
"self",
".",
"docstring_style_select",
".",
"label",
".",
"setText",
"(",
"_",
"(",
"\"Show the following errors:\"",
")",
")",
"self",
".",
"do... | Handle convention changes. | [
"Handle",
"convention",
"changes",
"."
] | python | train | 47.285714 |
Grokzen/pykwalify | pykwalify/rule.py | https://github.com/Grokzen/pykwalify/blob/02b7e21eafb97926f17b7c33e2ee7b3ea67c3ef7/pykwalify/rule.py#L319-L364 | def keywords(self):
"""
Returns a list of all keywords that this rule object has defined.
A keyword is considered defined if the value it returns != None.
"""
defined_keywords = [
('allowempty_map', 'allowempty_map'),
('assertion', 'assertion'),
... | [
"def",
"keywords",
"(",
"self",
")",
":",
"defined_keywords",
"=",
"[",
"(",
"'allowempty_map'",
",",
"'allowempty_map'",
")",
",",
"(",
"'assertion'",
",",
"'assertion'",
")",
",",
"(",
"'default'",
",",
"'default'",
")",
",",
"(",
"'class'",
",",
"'class... | Returns a list of all keywords that this rule object has defined.
A keyword is considered defined if the value it returns != None. | [
"Returns",
"a",
"list",
"of",
"all",
"keywords",
"that",
"this",
"rule",
"object",
"has",
"defined",
".",
"A",
"keyword",
"is",
"considered",
"defined",
"if",
"the",
"value",
"it",
"returns",
"!",
"=",
"None",
"."
] | python | train | 34.782609 |
mcs07/ChemDataExtractor | chemdataextractor/cli/chemdner.py | https://github.com/mcs07/ChemDataExtractor/blob/349a3bea965f2073141d62043b89319222e46af1/chemdataextractor/cli/chemdner.py#L89-L102 | def tag(ctx, corpus, output):
"""Tag chemical entities and write CHEMDNER annotations predictions file."""
click.echo('chemdataextractor.chemdner.tag')
for line in corpus:
pmid, title, abstract = line.strip().split(u'\t')
# print(pmid)
counter = 1
d = Document(Title(title), P... | [
"def",
"tag",
"(",
"ctx",
",",
"corpus",
",",
"output",
")",
":",
"click",
".",
"echo",
"(",
"'chemdataextractor.chemdner.tag'",
")",
"for",
"line",
"in",
"corpus",
":",
"pmid",
",",
"title",
",",
"abstract",
"=",
"line",
".",
"strip",
"(",
")",
".",
... | Tag chemical entities and write CHEMDNER annotations predictions file. | [
"Tag",
"chemical",
"entities",
"and",
"write",
"CHEMDNER",
"annotations",
"predictions",
"file",
"."
] | python | train | 46.285714 |
SmokinCaterpillar/pypet | pypet/naturalnaming.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/naturalnaming.py#L926-L979 | def _translate_shortcut(self, name):
"""Maps a given shortcut to corresponding name
* 'run_X' or 'r_X' to 'run_XXXXXXXXX'
* 'crun' to the current run name in case of a
single run instance if trajectory is used via `v_crun`
* 'par' 'parameters'
* 'dpar' to 'derived_p... | [
"def",
"_translate_shortcut",
"(",
"self",
",",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"int",
")",
":",
"return",
"True",
",",
"self",
".",
"_root_instance",
".",
"f_wildcard",
"(",
"'$'",
",",
"name",
")",
"if",
"name",
".",
"startswi... | Maps a given shortcut to corresponding name
* 'run_X' or 'r_X' to 'run_XXXXXXXXX'
* 'crun' to the current run name in case of a
single run instance if trajectory is used via `v_crun`
* 'par' 'parameters'
* 'dpar' to 'derived_parameters'
* 'res' to 'results'
... | [
"Maps",
"a",
"given",
"shortcut",
"to",
"corresponding",
"name"
] | python | test | 32.574074 |
tchellomello/python-arlo | pyarlo/media.py | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/media.py#L38-L87 | def load(self, days=PRELOAD_DAYS, only_cameras=None,
date_from=None, date_to=None, limit=None):
"""Load Arlo videos from the given criteria
:param days: number of days to retrieve
:param only_cameras: retrieve only <ArloCamera> on that list
:param date_from: refine from in... | [
"def",
"load",
"(",
"self",
",",
"days",
"=",
"PRELOAD_DAYS",
",",
"only_cameras",
"=",
"None",
",",
"date_from",
"=",
"None",
",",
"date_to",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"videos",
"=",
"[",
"]",
"url",
"=",
"LIBRARY_ENDPOINT",
... | Load Arlo videos from the given criteria
:param days: number of days to retrieve
:param only_cameras: retrieve only <ArloCamera> on that list
:param date_from: refine from initial date
:param date_to: refine final date
:param limit: define number of objects to return | [
"Load",
"Arlo",
"videos",
"from",
"the",
"given",
"criteria"
] | python | train | 36.78 |
bakwc/PySyncObj | pysyncobj/transport.py | https://github.com/bakwc/PySyncObj/blob/be3b0aaa932d5156f5df140c23c962430f51b7b8/pysyncobj/transport.py#L441-L458 | def _onOutgoingMessageReceived(self, conn, message):
"""
Callback for receiving a message on a new outgoing connection. Used only if encryption is enabled to exchange the random keys.
Once the key exchange is done, this triggers the onNodeConnected callback, and further messages are deferred to ... | [
"def",
"_onOutgoingMessageReceived",
"(",
"self",
",",
"conn",
",",
"message",
")",
":",
"if",
"not",
"conn",
".",
"sendRandKey",
":",
"conn",
".",
"sendRandKey",
"=",
"message",
"conn",
".",
"send",
"(",
"self",
".",
"_selfNode",
".",
"address",
")",
"n... | Callback for receiving a message on a new outgoing connection. Used only if encryption is enabled to exchange the random keys.
Once the key exchange is done, this triggers the onNodeConnected callback, and further messages are deferred to the onMessageReceived callback.
:param conn: connection object
... | [
"Callback",
"for",
"receiving",
"a",
"message",
"on",
"a",
"new",
"outgoing",
"connection",
".",
"Used",
"only",
"if",
"encryption",
"is",
"enabled",
"to",
"exchange",
"the",
"random",
"keys",
".",
"Once",
"the",
"key",
"exchange",
"is",
"done",
"this",
"t... | python | test | 43 |
prompt-toolkit/pyvim | pyvim/window_arrangement.py | https://github.com/prompt-toolkit/pyvim/blob/5928b53b9d700863c1a06d2181a034a955f94594/pyvim/window_arrangement.py#L283-L291 | def hsplit(self, location=None, new=False, text=None):
""" Split horizontally. """
assert location is None or text is None or new is False # Don't pass two of them.
if location or text or new:
editor_buffer = self._get_or_create_editor_buffer(location=location, text=text)
e... | [
"def",
"hsplit",
"(",
"self",
",",
"location",
"=",
"None",
",",
"new",
"=",
"False",
",",
"text",
"=",
"None",
")",
":",
"assert",
"location",
"is",
"None",
"or",
"text",
"is",
"None",
"or",
"new",
"is",
"False",
"# Don't pass two of them.",
"if",
"lo... | Split horizontally. | [
"Split",
"horizontally",
"."
] | python | train | 43.888889 |
ynop/audiomate | audiomate/utils/audio.py | https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/audio.py#L89-L137 | def read_frames(file_path, frame_size, hop_size, start=0.0,
end=float('inf'), buffer_size=5760000):
"""
Read an audio file frame by frame. The frames are yielded one after another.
Args:
file_path (str): Path to the file to read.
frame_size (int): The number of samples per f... | [
"def",
"read_frames",
"(",
"file_path",
",",
"frame_size",
",",
"hop_size",
",",
"start",
"=",
"0.0",
",",
"end",
"=",
"float",
"(",
"'inf'",
")",
",",
"buffer_size",
"=",
"5760000",
")",
":",
"rest_samples",
"=",
"np",
".",
"array",
"(",
"[",
"]",
"... | Read an audio file frame by frame. The frames are yielded one after another.
Args:
file_path (str): Path to the file to read.
frame_size (int): The number of samples per frame.
hop_size (int): The number of samples between two frames.
start (float): Start in seconds to read from.
... | [
"Read",
"an",
"audio",
"file",
"frame",
"by",
"frame",
".",
"The",
"frames",
"are",
"yielded",
"one",
"after",
"another",
"."
] | python | train | 39.142857 |
OLC-Bioinformatics/sipprverse | pointfinder/PointFinder.py | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/pointfinder/PointFinder.py#L773-L931 | def find_codon_mismatches(sbjct_start, sbjct_seq, qry_seq):
"""
This function takes two alligned sequence (subject and query), and
the position on the subject where the alignment starts. The sequences
are compared codon by codon. If a mis matches is found it is saved in
'mis_matches'. If a gap is ... | [
"def",
"find_codon_mismatches",
"(",
"sbjct_start",
",",
"sbjct_seq",
",",
"qry_seq",
")",
":",
"mis_matches",
"=",
"[",
"]",
"# Find start pos of first codon in frame, i_start",
"codon_offset",
"=",
"(",
"sbjct_start",
"-",
"1",
")",
"%",
"3",
"i_start",
"=",
"0"... | This function takes two alligned sequence (subject and query), and
the position on the subject where the alignment starts. The sequences
are compared codon by codon. If a mis matches is found it is saved in
'mis_matches'. If a gap is found the function get_inframe_gap is used
to find the indel sequen... | [
"This",
"function",
"takes",
"two",
"alligned",
"sequence",
"(",
"subject",
"and",
"query",
")",
"and",
"the",
"position",
"on",
"the",
"subject",
"where",
"the",
"alignment",
"starts",
".",
"The",
"sequences",
"are",
"compared",
"codon",
"by",
"codon",
".",... | python | train | 44.591195 |
edx/ease | ease/create.py | https://github.com/edx/ease/blob/a7890ed403da94d03726b0639cd8ebda45af6bbb/ease/create.py#L90-L134 | def create_generic(numeric_values, textual_values, target, algorithm = util_functions.AlgorithmTypes.regression):
"""
Creates a model from a generic list numeric values and text values
numeric_values - A list of lists that are the predictors
textual_values - A list of lists that are the predictors
(... | [
"def",
"create_generic",
"(",
"numeric_values",
",",
"textual_values",
",",
"target",
",",
"algorithm",
"=",
"util_functions",
".",
"AlgorithmTypes",
".",
"regression",
")",
":",
"algorithm",
"=",
"select_algorithm",
"(",
"target",
")",
"#Initialize a result dictionar... | Creates a model from a generic list numeric values and text values
numeric_values - A list of lists that are the predictors
textual_values - A list of lists that are the predictors
(each item in textual_values corresponds to the similarly indexed counterpart in numeric_values)
target - The variable that... | [
"Creates",
"a",
"model",
"from",
"a",
"generic",
"list",
"numeric",
"values",
"and",
"text",
"values",
"numeric_values",
"-",
"A",
"list",
"of",
"lists",
"that",
"are",
"the",
"predictors",
"textual_values",
"-",
"A",
"list",
"of",
"lists",
"that",
"are",
... | python | valid | 45.888889 |
JNRowe/upoints | upoints/kml.py | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/kml.py#L177-L188 | def export_kml_file(self):
"""Generate KML element tree from ``Placemarks``.
Returns:
etree.ElementTree: KML element tree depicting ``Placemarks``
"""
kml = create_elem('kml')
kml.Document = create_elem('Document')
for place in sorted(self.values(), key=lambd... | [
"def",
"export_kml_file",
"(",
"self",
")",
":",
"kml",
"=",
"create_elem",
"(",
"'kml'",
")",
"kml",
".",
"Document",
"=",
"create_elem",
"(",
"'Document'",
")",
"for",
"place",
"in",
"sorted",
"(",
"self",
".",
"values",
"(",
")",
",",
"key",
"=",
... | Generate KML element tree from ``Placemarks``.
Returns:
etree.ElementTree: KML element tree depicting ``Placemarks`` | [
"Generate",
"KML",
"element",
"tree",
"from",
"Placemarks",
"."
] | python | train | 34 |
tonioo/sievelib | sievelib/managesieve.py | https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L58-L71 | def authentication_required(meth):
"""Simple class method decorator.
Checks if the client is currently connected.
:param meth: the original called method
"""
def check(cls, *args, **kwargs):
if cls.authenticated:
return meth(cls, *args, **kwargs)
raise Error("Authentic... | [
"def",
"authentication_required",
"(",
"meth",
")",
":",
"def",
"check",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cls",
".",
"authenticated",
":",
"return",
"meth",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs... | Simple class method decorator.
Checks if the client is currently connected.
:param meth: the original called method | [
"Simple",
"class",
"method",
"decorator",
"."
] | python | train | 24.357143 |
juicer/juicer | juicer/admin/JuicerAdmin.py | https://github.com/juicer/juicer/blob/0c9f0fd59e293d45df6b46e81f675d33221c600d/juicer/admin/JuicerAdmin.py#L376-L410 | def delete_repo(self, repo_name=None, envs=[], query='/repositories/'):
"""
`repo_name` - Name of repository to delete
Delete repo in specified environments
"""
orphan_query = '/content/orphans/rpm/'
juicer.utils.Log.log_debug("Delete Repo: %s", repo_name)
for e... | [
"def",
"delete_repo",
"(",
"self",
",",
"repo_name",
"=",
"None",
",",
"envs",
"=",
"[",
"]",
",",
"query",
"=",
"'/repositories/'",
")",
":",
"orphan_query",
"=",
"'/content/orphans/rpm/'",
"juicer",
".",
"utils",
".",
"Log",
".",
"log_debug",
"(",
"\"Del... | `repo_name` - Name of repository to delete
Delete repo in specified environments | [
"repo_name",
"-",
"Name",
"of",
"repository",
"to",
"delete"
] | python | train | 53.085714 |
CalebBell/ht | ht/condensation.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/condensation.py#L156-L222 | def Akers_Deans_Crosser(m, rhog, rhol, kl, mul, Cpl, D, x):
r'''Calculates heat transfer coefficient for condensation
of a pure chemical inside a vertical tube or tube bundle, as presented in
[2]_ according to [1]_.
.. math::
Nu = \frac{hD_i}{k_l} = C Re_e^n Pr_l^{1/3}
C = 0.02... | [
"def",
"Akers_Deans_Crosser",
"(",
"m",
",",
"rhog",
",",
"rhol",
",",
"kl",
",",
"mul",
",",
"Cpl",
",",
"D",
",",
"x",
")",
":",
"G",
"=",
"m",
"/",
"(",
"pi",
"/",
"4",
"*",
"D",
"**",
"2",
")",
"Ge",
"=",
"G",
"*",
"(",
"(",
"1",
"-... | r'''Calculates heat transfer coefficient for condensation
of a pure chemical inside a vertical tube or tube bundle, as presented in
[2]_ according to [1]_.
.. math::
Nu = \frac{hD_i}{k_l} = C Re_e^n Pr_l^{1/3}
C = 0.0265, n=0.8 \text{ for } Re_e > 5\times10^4
C = 5... | [
"r",
"Calculates",
"heat",
"transfer",
"coefficient",
"for",
"condensation",
"of",
"a",
"pure",
"chemical",
"inside",
"a",
"vertical",
"tube",
"or",
"tube",
"bundle",
"as",
"presented",
"in",
"[",
"2",
"]",
"_",
"according",
"to",
"[",
"1",
"]",
"_",
"."... | python | train | 26.850746 |
aws/aws-xray-sdk-python | aws_xray_sdk/core/models/subsegment.py | https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/core/models/subsegment.py#L111-L118 | def add_subsegment(self, subsegment):
"""
Add input subsegment as a child subsegment and increment
reference counter and total subsegments counter of the
parent segment.
"""
super(Subsegment, self).add_subsegment(subsegment)
self.parent_segment.increment() | [
"def",
"add_subsegment",
"(",
"self",
",",
"subsegment",
")",
":",
"super",
"(",
"Subsegment",
",",
"self",
")",
".",
"add_subsegment",
"(",
"subsegment",
")",
"self",
".",
"parent_segment",
".",
"increment",
"(",
")"
] | Add input subsegment as a child subsegment and increment
reference counter and total subsegments counter of the
parent segment. | [
"Add",
"input",
"subsegment",
"as",
"a",
"child",
"subsegment",
"and",
"increment",
"reference",
"counter",
"and",
"total",
"subsegments",
"counter",
"of",
"the",
"parent",
"segment",
"."
] | python | train | 38.125 |
htm-community/menorah | menorah/riverstream.py | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/riverstream.py#L94-L103 | def next(self):
"""
Returns the next data value.
:return: (float|int) the next data value
"""
out = self.peek()[self._headers.index(self._field)]
self._cursor += 1
if out is not None:
self._lastValue = out
return out | [
"def",
"next",
"(",
"self",
")",
":",
"out",
"=",
"self",
".",
"peek",
"(",
")",
"[",
"self",
".",
"_headers",
".",
"index",
"(",
"self",
".",
"_field",
")",
"]",
"self",
".",
"_cursor",
"+=",
"1",
"if",
"out",
"is",
"not",
"None",
":",
"self",... | Returns the next data value.
:return: (float|int) the next data value | [
"Returns",
"the",
"next",
"data",
"value",
".",
":",
"return",
":",
"(",
"float|int",
")",
"the",
"next",
"data",
"value"
] | python | train | 24.5 |
Captricity/captools | captools/api/client.py | https://github.com/Captricity/captools/blob/e7dc069ff5ede95d4956c7a0a4614d0e53e5a955/captools/api/client.py#L280-L306 | def _encode_multipart_formdata(fields, files):
"""
Create a multipart encoded form for use in PUTing and POSTing.
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return (content_type, bo... | [
"def",
"_encode_multipart_formdata",
"(",
"fields",
",",
"files",
")",
":",
"BOUNDARY",
"=",
"'----------A_vEry_UnlikelY_bouNdary_$'",
"CRLF",
"=",
"'\\r\\n'",
"L",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
")",
"in",
"fields",
":",
"L",
".",
"append",... | Create a multipart encoded form for use in PUTing and POSTing.
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return (content_type, body) ready for httplib.HTTP instance | [
"Create",
"a",
"multipart",
"encoded",
"form",
"for",
"use",
"in",
"PUTing",
"and",
"POSTing",
"."
] | python | train | 39.37037 |
chainer/chainerui | chainerui/migration/env.py | https://github.com/chainer/chainerui/blob/87ad25e875bc332bfdad20197fd3d0cb81a078e8/chainerui/migration/env.py#L7-L23 | def run_migrations_online(config):
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine and associate a
connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolcl... | [
"def",
"run_migrations_online",
"(",
"config",
")",
":",
"connectable",
"=",
"engine_from_config",
"(",
"config",
".",
"get_section",
"(",
"config",
".",
"config_ini_section",
")",
",",
"prefix",
"=",
"'sqlalchemy.'",
",",
"poolclass",
"=",
"pool",
".",
"NullPoo... | Run migrations in 'online' mode.
In this scenario we need to create an Engine and associate a
connection with the context. | [
"Run",
"migrations",
"in",
"online",
"mode",
"."
] | python | train | 30.705882 |
tsileo/dirtools | dirtools.py | https://github.com/tsileo/dirtools/blob/34be55b20b4ef506869487b5fa5c6ea020604f80/dirtools.py#L245-L265 | def walk(self):
""" Walk the directory like os.path
(yields a 3-tuple (dirpath, dirnames, filenames)
except it exclude all files/directories on the fly. """
for root, dirs, files in os.walk(self.path, topdown=True):
# TODO relative walk, recursive call if root excluder found?... | [
"def",
"walk",
"(",
"self",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"path",
",",
"topdown",
"=",
"True",
")",
":",
"# TODO relative walk, recursive call if root excluder found???",
"#root_excluder = get_root... | Walk the directory like os.path
(yields a 3-tuple (dirpath, dirnames, filenames)
except it exclude all files/directories on the fly. | [
"Walk",
"the",
"directory",
"like",
"os",
".",
"path",
"(",
"yields",
"a",
"3",
"-",
"tuple",
"(",
"dirpath",
"dirnames",
"filenames",
")",
"except",
"it",
"exclude",
"all",
"files",
"/",
"directories",
"on",
"the",
"fly",
"."
] | python | train | 43.809524 |
Diaoul/pyjulius | pyjulius/core.py | https://github.com/Diaoul/pyjulius/blob/48f2752ff4e0f3bd7b578754b1c583cabdc24b09/pyjulius/core.py#L137-L142 | def disconnect(self):
"""Disconnect from the server"""
logger.info(u'Disconnecting')
self.sock.shutdown(socket.SHUT_RDWR)
self.sock.close()
self.state = DISCONNECTED | [
"def",
"disconnect",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"u'Disconnecting'",
")",
"self",
".",
"sock",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"self",
".",
"sock",
".",
"close",
"(",
")",
"self",
".",
"state",
"=",
"DISC... | Disconnect from the server | [
"Disconnect",
"from",
"the",
"server"
] | python | valid | 33.333333 |
gem/oq-engine | openquake/hazardlib/gsim/base.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/base.py#L468-L512 | def _truncnorm_sf(truncation_level, values):
"""
Survival function for truncated normal distribution.
Assumes zero mean, standard deviation equal to one and symmetric
truncation.
:param truncation_level:
Positive float number representing the truncation on both sides
around the mea... | [
"def",
"_truncnorm_sf",
"(",
"truncation_level",
",",
"values",
")",
":",
"# notation from http://en.wikipedia.org/wiki/Truncated_normal_distribution.",
"# given that mu = 0 and sigma = 1, we have alpha = a and beta = b.",
"# \"CDF\" in comments refers to cumulative distribution function",
"# ... | Survival function for truncated normal distribution.
Assumes zero mean, standard deviation equal to one and symmetric
truncation.
:param truncation_level:
Positive float number representing the truncation on both sides
around the mean, in units of sigma.
:param values:
Numpy ar... | [
"Survival",
"function",
"for",
"truncated",
"normal",
"distribution",
"."
] | python | train | 39.288889 |
adamreeve/npTDMS | nptdms/tdms.py | https://github.com/adamreeve/npTDMS/blob/d7d6632d4ebc2e78ed941477c2f1c56bd7493d74/nptdms/tdms.py#L1017-L1024 | def _read_value(self, file):
"""Read a single value from the given file"""
if self.data_type.nptype is not None:
dtype = (np.dtype(self.data_type.nptype).newbyteorder(
self.endianness))
return fromfile(file, dtype=dtype, count=1)
return self.data_type.rea... | [
"def",
"_read_value",
"(",
"self",
",",
"file",
")",
":",
"if",
"self",
".",
"data_type",
".",
"nptype",
"is",
"not",
"None",
":",
"dtype",
"=",
"(",
"np",
".",
"dtype",
"(",
"self",
".",
"data_type",
".",
"nptype",
")",
".",
"newbyteorder",
"(",
"... | Read a single value from the given file | [
"Read",
"a",
"single",
"value",
"from",
"the",
"given",
"file"
] | python | train | 42.125 |
Yelp/threat_intel | threat_intel/util/api_cache.py | https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L47-L58 | def _read_cache_from_file(self):
"""Read the contents of the cache from a file on disk."""
cache = {}
try:
with(open(self._cache_file_name, 'r')) as fp:
contents = fp.read()
cache = simplejson.loads(contents)
except (IOError, JSONDecodeError):
... | [
"def",
"_read_cache_from_file",
"(",
"self",
")",
":",
"cache",
"=",
"{",
"}",
"try",
":",
"with",
"(",
"open",
"(",
"self",
".",
"_cache_file_name",
",",
"'r'",
")",
")",
"as",
"fp",
":",
"contents",
"=",
"fp",
".",
"read",
"(",
")",
"cache",
"=",... | Read the contents of the cache from a file on disk. | [
"Read",
"the",
"contents",
"of",
"the",
"cache",
"from",
"a",
"file",
"on",
"disk",
"."
] | python | train | 36.583333 |
evolbioinfo/pastml | pastml/models/generator.py | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/models/generator.py#L4-L18 | def get_diagonalisation(frequencies, rate_matrix=None):
"""
Normalises and diagonalises the rate matrix.
:param frequencies: character state frequencies.
:type frequencies: numpy.array
:param rate_matrix: (optional) rate matrix (by default an all-equal-rate matrix is used)
:type rate_matrix: nu... | [
"def",
"get_diagonalisation",
"(",
"frequencies",
",",
"rate_matrix",
"=",
"None",
")",
":",
"Q",
"=",
"get_normalised_generator",
"(",
"frequencies",
",",
"rate_matrix",
")",
"d",
",",
"A",
"=",
"np",
".",
"linalg",
".",
"eig",
"(",
"Q",
")",
"return",
... | Normalises and diagonalises the rate matrix.
:param frequencies: character state frequencies.
:type frequencies: numpy.array
:param rate_matrix: (optional) rate matrix (by default an all-equal-rate matrix is used)
:type rate_matrix: numpy.ndarray
:return: matrix diagonalisation (d, A, A^{-1})
... | [
"Normalises",
"and",
"diagonalises",
"the",
"rate",
"matrix",
"."
] | python | train | 39.733333 |
mfcloud/python-zvm-sdk | zvmsdk/dist.py | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/dist.py#L1205-L1222 | def _delete_vdev_info(self, vdev):
"""handle vdev related info."""
vdev = vdev.lower()
network_config_file_name = self._get_network_file()
device = self._get_device_name(vdev)
cmd = '\n'.join(("num=$(sed -n '/auto %s/=' %s)" % (device,
... | [
"def",
"_delete_vdev_info",
"(",
"self",
",",
"vdev",
")",
":",
"vdev",
"=",
"vdev",
".",
"lower",
"(",
")",
"network_config_file_name",
"=",
"self",
".",
"_get_network_file",
"(",
")",
"device",
"=",
"self",
".",
"_get_device_name",
"(",
"vdev",
")",
"cmd... | handle vdev related info. | [
"handle",
"vdev",
"related",
"info",
"."
] | python | train | 52.555556 |
morse-talk/morse-talk | morse_talk/sound.py | https://github.com/morse-talk/morse-talk/blob/71e09ace0aa554d28cada5ee658e43758305b8fa/morse_talk/sound.py#L118-L125 | def calculate_wave(i, lst_bin, wpm=WPM, frequency=FREQUENCY, framerate=FRAMERATE, amplitude=AMPLITUDE, seconds_per_dot=SECONDS_PER_DOT):
"""
Returns product of a sin wave and morse code (dit, dah, silent)
"""
bit = morse_bin(i=i, lst_bin=lst_bin, wpm=wpm, framerate=framerate,
default... | [
"def",
"calculate_wave",
"(",
"i",
",",
"lst_bin",
",",
"wpm",
"=",
"WPM",
",",
"frequency",
"=",
"FREQUENCY",
",",
"framerate",
"=",
"FRAMERATE",
",",
"amplitude",
"=",
"AMPLITUDE",
",",
"seconds_per_dot",
"=",
"SECONDS_PER_DOT",
")",
":",
"bit",
"=",
"mo... | Returns product of a sin wave and morse code (dit, dah, silent) | [
"Returns",
"product",
"of",
"a",
"sin",
"wave",
"and",
"morse",
"code",
"(",
"dit",
"dah",
"silent",
")"
] | python | train | 58.5 |
maljovec/topopy | topopy/MorseComplex.py | https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseComplex.py#L380-L406 | def to_json(self):
""" Writes the complete Morse complex merge hierarchy to a
string object.
@ Out, a string object storing the entire merge hierarchy of
all maxima.
"""
capsule = {}
capsule["Hierarchy"] = []
for (
dying,
... | [
"def",
"to_json",
"(",
"self",
")",
":",
"capsule",
"=",
"{",
"}",
"capsule",
"[",
"\"Hierarchy\"",
"]",
"=",
"[",
"]",
"for",
"(",
"dying",
",",
"(",
"persistence",
",",
"surviving",
",",
"saddle",
")",
",",
")",
"in",
"self",
".",
"merge_sequence",... | Writes the complete Morse complex merge hierarchy to a
string object.
@ Out, a string object storing the entire merge hierarchy of
all maxima. | [
"Writes",
"the",
"complete",
"Morse",
"complex",
"merge",
"hierarchy",
"to",
"a",
"string",
"object",
"."
] | python | train | 33.481481 |
RRZE-HPC/kerncraft | kerncraft/kerncraft.py | https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kerncraft.py#L189-L202 | def check_arguments(args, parser):
"""Check arguments passed by user that are not checked by argparse itself."""
if args.asm_block not in ['auto', 'manual']:
try:
args.asm_block = int(args.asm_block)
except ValueError:
parser.error('--asm-block can only be "auto", "manual... | [
"def",
"check_arguments",
"(",
"args",
",",
"parser",
")",
":",
"if",
"args",
".",
"asm_block",
"not",
"in",
"[",
"'auto'",
",",
"'manual'",
"]",
":",
"try",
":",
"args",
".",
"asm_block",
"=",
"int",
"(",
"args",
".",
"asm_block",
")",
"except",
"Va... | Check arguments passed by user that are not checked by argparse itself. | [
"Check",
"arguments",
"passed",
"by",
"user",
"that",
"are",
"not",
"checked",
"by",
"argparse",
"itself",
"."
] | python | test | 40.071429 |
hydpy-dev/hydpy | hydpy/auxs/anntools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/anntools.py#L366-L384 | def nmb_neurons(self) -> Tuple[int, ...]:
"""Number of neurons of the hidden layers.
>>> from hydpy import ANN
>>> ann = ANN(None)
>>> ann(nmb_inputs=2, nmb_neurons=(2, 1), nmb_outputs=3)
>>> ann.nmb_neurons
(2, 1)
>>> ann.nmb_neurons = (3,)
>>> ann.nmb_n... | [
"def",
"nmb_neurons",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"...",
"]",
":",
"return",
"tuple",
"(",
"numpy",
".",
"asarray",
"(",
"self",
".",
"_cann",
".",
"nmb_neurons",
")",
")"
] | Number of neurons of the hidden layers.
>>> from hydpy import ANN
>>> ann = ANN(None)
>>> ann(nmb_inputs=2, nmb_neurons=(2, 1), nmb_outputs=3)
>>> ann.nmb_neurons
(2, 1)
>>> ann.nmb_neurons = (3,)
>>> ann.nmb_neurons
(3,)
>>> del ann.nmb_neurons
... | [
"Number",
"of",
"neurons",
"of",
"the",
"hidden",
"layers",
"."
] | python | train | 33.315789 |
svinota/mdns | mdns/zeroconf.py | https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1806-L1835 | def unregister_service(self, info):
"""Unregister a service."""
try:
del(self.services[info.name.lower()])
except:
pass
now = current_time_millis()
next_time = now
i = 0
while i < 3:
if now < next_time:
self.wait... | [
"def",
"unregister_service",
"(",
"self",
",",
"info",
")",
":",
"try",
":",
"del",
"(",
"self",
".",
"services",
"[",
"info",
".",
"name",
".",
"lower",
"(",
")",
"]",
")",
"except",
":",
"pass",
"now",
"=",
"current_time_millis",
"(",
")",
"next_ti... | Unregister a service. | [
"Unregister",
"a",
"service",
"."
] | python | train | 38.066667 |
limpyd/redis-limpyd | limpyd/fields.py | https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L1259-L1274 | def exists(self, value=None):
"""
Return True if the given pk value exists for the given class.
If no value is given, we use the value of the current field, which
is the value of the "_pk" attribute of its instance.
"""
try:
if not value:
value... | [
"def",
"exists",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"try",
":",
"if",
"not",
"value",
":",
"value",
"=",
"self",
".",
"get",
"(",
")",
"except",
"(",
"AttributeError",
",",
"DoesNotExist",
")",
":",
"# If the instance is deleted, the _pk att... | Return True if the given pk value exists for the given class.
If no value is given, we use the value of the current field, which
is the value of the "_pk" attribute of its instance. | [
"Return",
"True",
"if",
"the",
"given",
"pk",
"value",
"exists",
"for",
"the",
"given",
"class",
".",
"If",
"no",
"value",
"is",
"given",
"we",
"use",
"the",
"value",
"of",
"the",
"current",
"field",
"which",
"is",
"the",
"value",
"of",
"the",
"_pk",
... | python | train | 43.4375 |
zhmcclient/python-zhmcclient | zhmcclient_mock/_urihandler.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L2060-L2072 | def get(method, hmc, uri, uri_parms, logon_required):
"""Operation: List Storage Groups (always global but with filters)."""
query_str = uri_parms[0]
filter_args = parse_query_parms(method, uri, query_str)
result_storage_groups = []
for sg in hmc.consoles.console.storage_groups.l... | [
"def",
"get",
"(",
"method",
",",
"hmc",
",",
"uri",
",",
"uri_parms",
",",
"logon_required",
")",
":",
"query_str",
"=",
"uri_parms",
"[",
"0",
"]",
"filter_args",
"=",
"parse_query_parms",
"(",
"method",
",",
"uri",
",",
"query_str",
")",
"result_storage... | Operation: List Storage Groups (always global but with filters). | [
"Operation",
":",
"List",
"Storage",
"Groups",
"(",
"always",
"global",
"but",
"with",
"filters",
")",
"."
] | python | train | 52.846154 |
KnowledgeLinks/rdfframework | rdfframework/rdfclass/rdffactories.py | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdffactories.py#L129-L140 | def conv_defs(self):
""" Reads through the JSON object and converts them to Dataset """
log.setLevel(self.log_level)
start = datetime.datetime.now()
log.debug(" Converting to a Dataset: %s Triples", len(self.results))
self.defs = RdfDataset(self.results,
... | [
"def",
"conv_defs",
"(",
"self",
")",
":",
"log",
".",
"setLevel",
"(",
"self",
".",
"log_level",
")",
"start",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"log",
".",
"debug",
"(",
"\" Converting to a Dataset: %s Triples\"",
",",
"len",
"(",
... | Reads through the JSON object and converts them to Dataset | [
"Reads",
"through",
"the",
"JSON",
"object",
"and",
"converts",
"them",
"to",
"Dataset"
] | python | train | 43.583333 |
samirelanduk/quickplots | quickplots/series.py | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/series.py#L89-L100 | def color(self, color=None):
"""Returns or sets (if a value is provided) the series' colour.
:param str color: If given, the series' colour will be set to this.
:rtype: ``str``"""
if color is None:
return self._color
else:
if not isinstance(color, str):
... | [
"def",
"color",
"(",
"self",
",",
"color",
"=",
"None",
")",
":",
"if",
"color",
"is",
"None",
":",
"return",
"self",
".",
"_color",
"else",
":",
"if",
"not",
"isinstance",
"(",
"color",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"color must ... | Returns or sets (if a value is provided) the series' colour.
:param str color: If given, the series' colour will be set to this.
:rtype: ``str`` | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"series",
"colour",
"."
] | python | train | 34.666667 |
fvdsn/py-xml-escpos | xmlescpos/escpos.py | https://github.com/fvdsn/py-xml-escpos/blob/7f77e039c960d5773fb919aed02ba392dccbc360/xmlescpos/escpos.py#L134-L143 | def enforce_type(self, attr, val):
"""converts a value to the attribute's type"""
if not attr in self.types:
return utfstr(val)
elif self.types[attr] == 'int':
return int(float(val))
elif self.types[attr] == 'float':
return float(val)
else:
... | [
"def",
"enforce_type",
"(",
"self",
",",
"attr",
",",
"val",
")",
":",
"if",
"not",
"attr",
"in",
"self",
".",
"types",
":",
"return",
"utfstr",
"(",
"val",
")",
"elif",
"self",
".",
"types",
"[",
"attr",
"]",
"==",
"'int'",
":",
"return",
"int",
... | converts a value to the attribute's type | [
"converts",
"a",
"value",
"to",
"the",
"attribute",
"s",
"type"
] | python | train | 33.8 |
Grk0/python-libconf | libconf.py | https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L695-L701 | def dump_collection(cfg, f, indent=0):
'''Save a collection of attributes'''
for i, value in enumerate(cfg):
dump_value(None, value, f, indent)
if i < len(cfg) - 1:
f.write(u',\n') | [
"def",
"dump_collection",
"(",
"cfg",
",",
"f",
",",
"indent",
"=",
"0",
")",
":",
"for",
"i",
",",
"value",
"in",
"enumerate",
"(",
"cfg",
")",
":",
"dump_value",
"(",
"None",
",",
"value",
",",
"f",
",",
"indent",
")",
"if",
"i",
"<",
"len",
... | Save a collection of attributes | [
"Save",
"a",
"collection",
"of",
"attributes"
] | python | train | 30.142857 |
danijar/layered | layered/network.py | https://github.com/danijar/layered/blob/c1c09d95f90057a91ae24c80b74f415680b97338/layered/network.py#L154-L167 | def feed(self, weights, data):
"""
Evaluate the network with alternative weights on the input data and
return the output activation.
"""
assert len(data) == self.layers[0].size
self.layers[0].apply(data)
# Propagate trough the remaining layers.
connections... | [
"def",
"feed",
"(",
"self",
",",
"weights",
",",
"data",
")",
":",
"assert",
"len",
"(",
"data",
")",
"==",
"self",
".",
"layers",
"[",
"0",
"]",
".",
"size",
"self",
".",
"layers",
"[",
"0",
"]",
".",
"apply",
"(",
"data",
")",
"# Propagate trou... | Evaluate the network with alternative weights on the input data and
return the output activation. | [
"Evaluate",
"the",
"network",
"with",
"alternative",
"weights",
"on",
"the",
"input",
"data",
"and",
"return",
"the",
"output",
"activation",
"."
] | python | train | 43.142857 |
nion-software/nionswift-io | nionswift_plugin/DM_IO/dm3_image_utils.py | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/DM_IO/dm3_image_utils.py#L171-L256 | def load_image(file) -> DataAndMetadata.DataAndMetadata:
"""
Loads the image from the file-like object or string file.
If file is a string, the file is opened and then read.
Returns a numpy ndarray of our best guess for the most important image
in the file.
"""
if isinstance(file, str) or is... | [
"def",
"load_image",
"(",
"file",
")",
"->",
"DataAndMetadata",
".",
"DataAndMetadata",
":",
"if",
"isinstance",
"(",
"file",
",",
"str",
")",
"or",
"isinstance",
"(",
"file",
",",
"str",
")",
":",
"with",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"as",... | Loads the image from the file-like object or string file.
If file is a string, the file is opened and then read.
Returns a numpy ndarray of our best guess for the most important image
in the file. | [
"Loads",
"the",
"image",
"from",
"the",
"file",
"-",
"like",
"object",
"or",
"string",
"file",
".",
"If",
"file",
"is",
"a",
"string",
"the",
"file",
"is",
"opened",
"and",
"then",
"read",
".",
"Returns",
"a",
"numpy",
"ndarray",
"of",
"our",
"best",
... | python | train | 59.197674 |
google/grumpy | third_party/pypy/_sre.py | https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L317-L328 | def group(self, *args):
"""Returns one or more subgroups of the match. Each argument is either a
group index or a group name."""
if len(args) == 0:
args = (0,)
grouplist = []
for group in args:
grouplist.append(self._get_slice(self._get_index(group), None)... | [
"def",
"group",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"args",
"=",
"(",
"0",
",",
")",
"grouplist",
"=",
"[",
"]",
"for",
"group",
"in",
"args",
":",
"grouplist",
".",
"append",
"(",
"self",
"... | Returns one or more subgroups of the match. Each argument is either a
group index or a group name. | [
"Returns",
"one",
"or",
"more",
"subgroups",
"of",
"the",
"match",
".",
"Each",
"argument",
"is",
"either",
"a",
"group",
"index",
"or",
"a",
"group",
"name",
"."
] | python | valid | 35.333333 |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2027-L2098 | def create_host_call(model_dir):
"""Construct a host_call writing scalar summaries.
Args:
model_dir: String containing path to train
Returns:
(fn, args) Pair to be called by TPUEstimator as the host_call.
"""
graph = tf.get_default_graph()
summaries = graph.get_collection(tf.GraphKeys.SUMMARIES)
... | [
"def",
"create_host_call",
"(",
"model_dir",
")",
":",
"graph",
"=",
"tf",
".",
"get_default_graph",
"(",
")",
"summaries",
"=",
"graph",
".",
"get_collection",
"(",
"tf",
".",
"GraphKeys",
".",
"SUMMARIES",
")",
"gs_t",
"=",
"tf",
".",
"reshape",
"(",
"... | Construct a host_call writing scalar summaries.
Args:
model_dir: String containing path to train
Returns:
(fn, args) Pair to be called by TPUEstimator as the host_call. | [
"Construct",
"a",
"host_call",
"writing",
"scalar",
"summaries",
"."
] | python | train | 39.5 |
Qiskit/qiskit-terra | qiskit/tools/qcvv/tomography.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/tools/qcvv/tomography.py#L924-L964 | def build_wigner_circuits(circuit, phis, thetas, qubits,
qreg, creg):
"""Create the circuits to rotate to points in phase space
Args:
circuit (QuantumCircuit): The circuit to be appended with tomography
state preparation and/or measurements.
... | [
"def",
"build_wigner_circuits",
"(",
"circuit",
",",
"phis",
",",
"thetas",
",",
"qubits",
",",
"qreg",
",",
"creg",
")",
":",
"if",
"not",
"isinstance",
"(",
"circuit",
",",
"QuantumCircuit",
")",
":",
"raise",
"QiskitError",
"(",
"'Input circuit must be a Qu... | Create the circuits to rotate to points in phase space
Args:
circuit (QuantumCircuit): The circuit to be appended with tomography
state preparation and/or measurements.
phis (np.matrix[[complex]]): phis
thetas (np.matrix[[complex]]): thetas
qubits (l... | [
"Create",
"the",
"circuits",
"to",
"rotate",
"to",
"points",
"in",
"phase",
"space",
"Args",
":",
"circuit",
"(",
"QuantumCircuit",
")",
":",
"The",
"circuit",
"to",
"be",
"appended",
"with",
"tomography",
"state",
"preparation",
"and",
"/",
"or",
"measureme... | python | test | 41.634146 |
ianmiell/shutit | shutit_class.py | https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1799-L1819 | def interact(self,
msg='SHUTIT PAUSE POINT',
shutit_pexpect_child=None,
print_input=True,
level=1,
resize=True,
color='32',
default_msg=None,
wait=-1):
"""Same as pause_point, but sets up the terminal ready for unm... | [
"def",
"interact",
"(",
"self",
",",
"msg",
"=",
"'SHUTIT PAUSE POINT'",
",",
"shutit_pexpect_child",
"=",
"None",
",",
"print_input",
"=",
"True",
",",
"level",
"=",
"1",
",",
"resize",
"=",
"True",
",",
"color",
"=",
"'32'",
",",
"default_msg",
"=",
"N... | Same as pause_point, but sets up the terminal ready for unmediated
interaction. | [
"Same",
"as",
"pause_point",
"but",
"sets",
"up",
"the",
"terminal",
"ready",
"for",
"unmediated",
"interaction",
"."
] | python | train | 34.190476 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.