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 |
|---|---|---|---|---|---|---|---|---|---|
gitpython-developers/GitPython | git/index/base.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/index/base.py#L1206-L1239 | def diff(self, other=diff.Diffable.Index, paths=None, create_patch=False, **kwargs):
"""Diff this index against the working copy or a Tree or Commit object
For a documentation of the parameters and return values, see
Diffable.diff
:note:
Will only work with indices that rep... | [
"def",
"diff",
"(",
"self",
",",
"other",
"=",
"diff",
".",
"Diffable",
".",
"Index",
",",
"paths",
"=",
"None",
",",
"create_patch",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# index against index is always empty",
"if",
"other",
"is",
"self",
"... | Diff this index against the working copy or a Tree or Commit object
For a documentation of the parameters and return values, see
Diffable.diff
:note:
Will only work with indices that represent the default git index as
they have not been initialized with a stream. | [
"Diff",
"this",
"index",
"against",
"the",
"working",
"copy",
"or",
"a",
"Tree",
"or",
"Commit",
"object"
] | python | train | 42.911765 |
minhhoit/yacms | yacms/forms/forms.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/forms/forms.py#L202-L229 | def save(self, **kwargs):
"""
Create a ``FormEntry`` instance and related ``FieldEntry``
instances for each form field.
"""
entry = super(FormForForm, self).save(commit=False)
entry.form = self.form
entry.entry_time = now()
entry.save()
entry_field... | [
"def",
"save",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"entry",
"=",
"super",
"(",
"FormForForm",
",",
"self",
")",
".",
"save",
"(",
"commit",
"=",
"False",
")",
"entry",
".",
"form",
"=",
"self",
".",
"form",
"entry",
".",
"entry_time",
... | Create a ``FormEntry`` instance and related ``FieldEntry``
instances for each form field. | [
"Create",
"a",
"FormEntry",
"instance",
"and",
"related",
"FieldEntry",
"instances",
"for",
"each",
"form",
"field",
"."
] | python | train | 43.428571 |
eraclitux/ipcampy | ipcampy/sentry.py | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcampy/sentry.py#L34-L39 | def watch(cams, path=None, delay=10):
"""Get screenshots from all cams at defined intervall."""
while True:
for c in cams:
c.snap(path)
time.sleep(delay) | [
"def",
"watch",
"(",
"cams",
",",
"path",
"=",
"None",
",",
"delay",
"=",
"10",
")",
":",
"while",
"True",
":",
"for",
"c",
"in",
"cams",
":",
"c",
".",
"snap",
"(",
"path",
")",
"time",
".",
"sleep",
"(",
"delay",
")"
] | Get screenshots from all cams at defined intervall. | [
"Get",
"screenshots",
"from",
"all",
"cams",
"at",
"defined",
"intervall",
"."
] | python | train | 30.666667 |
acorg/dark-matter | dark/alignments.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/alignments.py#L375-L384 | def hsps(self):
"""
Provide access to all HSPs for all alignments of all reads.
@return: A generator that yields HSPs (or LSPs).
"""
for readAlignments in self:
for alignment in readAlignments:
for hsp in alignment.hsps:
yield hsp | [
"def",
"hsps",
"(",
"self",
")",
":",
"for",
"readAlignments",
"in",
"self",
":",
"for",
"alignment",
"in",
"readAlignments",
":",
"for",
"hsp",
"in",
"alignment",
".",
"hsps",
":",
"yield",
"hsp"
] | Provide access to all HSPs for all alignments of all reads.
@return: A generator that yields HSPs (or LSPs). | [
"Provide",
"access",
"to",
"all",
"HSPs",
"for",
"all",
"alignments",
"of",
"all",
"reads",
"."
] | python | train | 31 |
PlaidWeb/Publ | publ/rendering.py | https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/rendering.py#L135-L167 | def render_error(category, error_message, error_codes, exception=None):
""" Render an error page.
Arguments:
category -- The category of the request
error_message -- The message to provide to the error template
error_codes -- The applicable HTTP error code(s). Will usually be an
integer or... | [
"def",
"render_error",
"(",
"category",
",",
"error_message",
",",
"error_codes",
",",
"exception",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"error_codes",
",",
"int",
")",
":",
"error_codes",
"=",
"[",
"error_codes",
"]",
"error_code",
"=",
"error_co... | Render an error page.
Arguments:
category -- The category of the request
error_message -- The message to provide to the error template
error_codes -- The applicable HTTP error code(s). Will usually be an
integer or a list of integers; the HTTP error response will always
be the first er... | [
"Render",
"an",
"error",
"page",
"."
] | python | train | 36.848485 |
blueset/ehForwarderBot | ehforwarderbot/utils.py | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L60-L76 | def get_data_path(module_id: str) -> Path:
"""
Get the path for persistent storage of a module.
This method creates the queried path if not existing.
Args:
module_id (str): Module ID
Returns:
The data path of indicated module.
"""
profile = coordinator.profile
... | [
"def",
"get_data_path",
"(",
"module_id",
":",
"str",
")",
"->",
"Path",
":",
"profile",
"=",
"coordinator",
".",
"profile",
"data_path",
"=",
"get_base_path",
"(",
")",
"/",
"'profiles'",
"/",
"profile",
"/",
"module_id",
"if",
"not",
"data_path",
".",
"e... | Get the path for persistent storage of a module.
This method creates the queried path if not existing.
Args:
module_id (str): Module ID
Returns:
The data path of indicated module. | [
"Get",
"the",
"path",
"for",
"persistent",
"storage",
"of",
"a",
"module",
".",
"This",
"method",
"creates",
"the",
"queried",
"path",
"if",
"not",
"existing",
".",
"Args",
":",
"module_id",
"(",
"str",
")",
":",
"Module",
"ID"
] | python | train | 26.823529 |
bio2bel/bio2bel | src/bio2bel/manager/namespace_manager.py | https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/namespace_manager.py#L522-L533 | def add_cli_write_bel_namespace(main: click.Group) -> click.Group: # noqa: D202
"""Add a ``write_bel_namespace`` command to main :mod:`click` function."""
@main.command()
@click.option('-d', '--directory', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),
help='output... | [
"def",
"add_cli_write_bel_namespace",
"(",
"main",
":",
"click",
".",
"Group",
")",
"->",
"click",
".",
"Group",
":",
"# noqa: D202",
"@",
"main",
".",
"command",
"(",
")",
"@",
"click",
".",
"option",
"(",
"'-d'",
",",
"'--directory'",
",",
"type",
"=",... | Add a ``write_bel_namespace`` command to main :mod:`click` function. | [
"Add",
"a",
"write_bel_namespace",
"command",
"to",
"main",
":",
"mod",
":",
"click",
"function",
"."
] | python | valid | 45.25 |
katerina7479/pypdflite | pypdflite/session.py | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/session.py#L107-L119 | def _add_page(self, text):
""" Helper function for PDFText, to have the document
add a page, and retry adding a large block of
text that would otherwise have been to long for the
page.
"""
save_cursor = self.parent.document.page.cursor.copy()
... | [
"def",
"_add_page",
"(",
"self",
",",
"text",
")",
":",
"save_cursor",
"=",
"self",
".",
"parent",
".",
"document",
".",
"page",
".",
"cursor",
".",
"copy",
"(",
")",
"save_cursor",
".",
"x_reset",
"(",
")",
"save_cursor",
".",
"y_reset",
"(",
")",
"... | Helper function for PDFText, to have the document
add a page, and retry adding a large block of
text that would otherwise have been to long for the
page. | [
"Helper",
"function",
"for",
"PDFText",
"to",
"have",
"the",
"document",
"add",
"a",
"page",
"and",
"retry",
"adding",
"a",
"large",
"block",
"of",
"text",
"that",
"would",
"otherwise",
"have",
"been",
"to",
"long",
"for",
"the",
"page",
"."
] | python | test | 38.461538 |
fabaff/python-mystrom | pymystrom/bulb.py | https://github.com/fabaff/python-mystrom/blob/86410f8952104651ef76ad37c84c29740c50551e/pymystrom/bulb.py#L176-L183 | def set_flashing(self, duration, hsv1, hsv2):
"""Turn the bulb on, flashing with two colors."""
self.set_transition_time(100)
for step in range(0, int(duration/2)):
self.set_color_hsv(hsv1[0], hsv1[1], hsv1[2])
time.sleep(1)
self.set_color_hsv(hsv2[0], hsv2[1]... | [
"def",
"set_flashing",
"(",
"self",
",",
"duration",
",",
"hsv1",
",",
"hsv2",
")",
":",
"self",
".",
"set_transition_time",
"(",
"100",
")",
"for",
"step",
"in",
"range",
"(",
"0",
",",
"int",
"(",
"duration",
"/",
"2",
")",
")",
":",
"self",
".",... | Turn the bulb on, flashing with two colors. | [
"Turn",
"the",
"bulb",
"on",
"flashing",
"with",
"two",
"colors",
"."
] | python | train | 43.625 |
wummel/linkchecker | third_party/dnspython/dns/rdataclass.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/rdataclass.py#L72-L89 | def from_text(text):
"""Convert text into a DNS rdata class value.
@param text: the text
@type text: string
@rtype: int
@raises dns.rdataclass.UnknownRdataClass: the class is unknown
@raises ValueError: the rdata class value is not >= 0 and <= 65535
"""
value = _by_text.get(text.upper()... | [
"def",
"from_text",
"(",
"text",
")",
":",
"value",
"=",
"_by_text",
".",
"get",
"(",
"text",
".",
"upper",
"(",
")",
")",
"if",
"value",
"is",
"None",
":",
"match",
"=",
"_unknown_class_pattern",
".",
"match",
"(",
"text",
")",
"if",
"match",
"==",
... | Convert text into a DNS rdata class value.
@param text: the text
@type text: string
@rtype: int
@raises dns.rdataclass.UnknownRdataClass: the class is unknown
@raises ValueError: the rdata class value is not >= 0 and <= 65535 | [
"Convert",
"text",
"into",
"a",
"DNS",
"rdata",
"class",
"value",
"."
] | python | train | 33.5 |
python-rope/rope | rope/contrib/autoimport.py | https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/contrib/autoimport.py#L107-L121 | def generate_modules_cache(self, modules, underlined=None,
task_handle=taskhandle.NullTaskHandle()):
"""Generate global name cache for modules listed in `modules`"""
job_set = task_handle.create_jobset(
'Generatig autoimport cache for modules', len(modules))
... | [
"def",
"generate_modules_cache",
"(",
"self",
",",
"modules",
",",
"underlined",
"=",
"None",
",",
"task_handle",
"=",
"taskhandle",
".",
"NullTaskHandle",
"(",
")",
")",
":",
"job_set",
"=",
"task_handle",
".",
"create_jobset",
"(",
"'Generatig autoimport cache f... | Generate global name cache for modules listed in `modules` | [
"Generate",
"global",
"name",
"cache",
"for",
"modules",
"listed",
"in",
"modules"
] | python | train | 49.266667 |
tensorflow/tensor2tensor | tensor2tensor/trax/models/resnet.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/models/resnet.py#L109-L118 | def WideResnetBlock(channels, strides=(1, 1), channel_mismatch=False):
"""WideResnet convolutational block."""
main = layers.Serial(layers.BatchNorm(), layers.Relu(),
layers.Conv(channels, (3, 3), strides, padding='SAME'),
layers.BatchNorm(), layers.Relu(),
... | [
"def",
"WideResnetBlock",
"(",
"channels",
",",
"strides",
"=",
"(",
"1",
",",
"1",
")",
",",
"channel_mismatch",
"=",
"False",
")",
":",
"main",
"=",
"layers",
".",
"Serial",
"(",
"layers",
".",
"BatchNorm",
"(",
")",
",",
"layers",
".",
"Relu",
"("... | WideResnet convolutational block. | [
"WideResnet",
"convolutational",
"block",
"."
] | python | train | 59.2 |
Capitains/MyCapytain | MyCapytain/common/reference/_capitains_cts.py | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L534-L612 | def upTo(self, key):
""" Returns the urn up to given level using URN Constants
:param key: Identifier of the wished resource using URN constants
:type key: int
:returns: String representation of the partial URN requested
:rtype: str
:Example:
>>> a = URN(... | [
"def",
"upTo",
"(",
"self",
",",
"key",
")",
":",
"middle",
"=",
"[",
"component",
"for",
"component",
"in",
"[",
"self",
".",
"__parsed",
"[",
"\"textgroup\"",
"]",
",",
"self",
".",
"__parsed",
"[",
"\"work\"",
"]",
",",
"self",
".",
"__parsed",
"[... | Returns the urn up to given level using URN Constants
:param key: Identifier of the wished resource using URN constants
:type key: int
:returns: String representation of the partial URN requested
:rtype: str
:Example:
>>> a = URN(urn="urn:cts:latinLit:phi1294.phi... | [
"Returns",
"the",
"urn",
"up",
"to",
"given",
"level",
"using",
"URN",
"Constants"
] | python | train | 37.227848 |
fermiPy/fermipy | fermipy/jobs/job_archive.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/job_archive.py#L371-L386 | def create_from_row(cls, table_row):
"""Create a `JobDetails` from an `astropy.table.row.Row` """
kwargs = {}
for key in table_row.colnames:
kwargs[key] = table_row[key]
infile_refs = kwargs.pop('infile_refs')
outfile_refs = kwargs.pop('outfile_refs')
rmfile_... | [
"def",
"create_from_row",
"(",
"cls",
",",
"table_row",
")",
":",
"kwargs",
"=",
"{",
"}",
"for",
"key",
"in",
"table_row",
".",
"colnames",
":",
"kwargs",
"[",
"key",
"]",
"=",
"table_row",
"[",
"key",
"]",
"infile_refs",
"=",
"kwargs",
".",
"pop",
... | Create a `JobDetails` from an `astropy.table.row.Row` | [
"Create",
"a",
"JobDetails",
"from",
"an",
"astropy",
".",
"table",
".",
"row",
".",
"Row"
] | python | train | 44.6875 |
yjzhang/uncurl_python | uncurl/ensemble.py | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/ensemble.py#L150-L177 | def nmf_tsne(data, k, n_runs=10, init='enhanced', **params):
"""
runs tsne-consensus-NMF
1. run a bunch of NMFs, get W and H
2. run tsne + km on all WH matrices
3. run consensus clustering on all km results
4. use consensus clustering as initialization for a new run of NMF
5. return the W a... | [
"def",
"nmf_tsne",
"(",
"data",
",",
"k",
",",
"n_runs",
"=",
"10",
",",
"init",
"=",
"'enhanced'",
",",
"*",
"*",
"params",
")",
":",
"clusters",
"=",
"[",
"]",
"nmf",
"=",
"NMF",
"(",
"k",
")",
"tsne",
"=",
"TSNE",
"(",
"2",
")",
"km",
"=",... | runs tsne-consensus-NMF
1. run a bunch of NMFs, get W and H
2. run tsne + km on all WH matrices
3. run consensus clustering on all km results
4. use consensus clustering as initialization for a new run of NMF
5. return the W and H from the resulting NMF run | [
"runs",
"tsne",
"-",
"consensus",
"-",
"NMF"
] | python | train | 35.392857 |
alexprengere/currencyconverter | currency_converter/currency_converter.py | https://github.com/alexprengere/currencyconverter/blob/e3cb0d693819c0c824214225b23a47e9380f71df/currency_converter/currency_converter.py#L147-L159 | def load_file(self, currency_file):
"""To be subclassed if alternate methods of loading data.
"""
if currency_file.startswith(('http://', 'https://')):
content = urlopen(currency_file).read()
else:
with open(currency_file, 'rb') as f:
content = f.r... | [
"def",
"load_file",
"(",
"self",
",",
"currency_file",
")",
":",
"if",
"currency_file",
".",
"startswith",
"(",
"(",
"'http://'",
",",
"'https://'",
")",
")",
":",
"content",
"=",
"urlopen",
"(",
"currency_file",
")",
".",
"read",
"(",
")",
"else",
":",
... | To be subclassed if alternate methods of loading data. | [
"To",
"be",
"subclassed",
"if",
"alternate",
"methods",
"of",
"loading",
"data",
"."
] | python | test | 38 |
spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/figurebrowser.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/figurebrowser.py#L40-L76 | def _handle_display_data(self, msg):
"""
Reimplemented to handle communications between the figure explorer
and the kernel.
"""
img = None
data = msg['content']['data']
if 'image/svg+xml' in data:
fmt = 'image/svg+xml'
img = data['image/svg... | [
"def",
"_handle_display_data",
"(",
"self",
",",
"msg",
")",
":",
"img",
"=",
"None",
"data",
"=",
"msg",
"[",
"'content'",
"]",
"[",
"'data'",
"]",
"if",
"'image/svg+xml'",
"in",
"data",
":",
"fmt",
"=",
"'image/svg+xml'",
"img",
"=",
"data",
"[",
"'i... | Reimplemented to handle communications between the figure explorer
and the kernel. | [
"Reimplemented",
"to",
"handle",
"communications",
"between",
"the",
"figure",
"explorer",
"and",
"the",
"kernel",
"."
] | python | train | 45.567568 |
kubernetes-client/python | kubernetes/client/api_client.py | https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/api_client.py#L500-L523 | def update_params_for_auth(self, headers, querys, auth_settings):
"""
Updates header and query params based on authentication setting.
:param headers: Header parameters dict to be updated.
:param querys: Query parameters tuple list to be updated.
:param auth_settings: Authentica... | [
"def",
"update_params_for_auth",
"(",
"self",
",",
"headers",
",",
"querys",
",",
"auth_settings",
")",
":",
"if",
"not",
"auth_settings",
":",
"return",
"for",
"auth",
"in",
"auth_settings",
":",
"auth_setting",
"=",
"self",
".",
"configuration",
".",
"auth_s... | Updates header and query params based on authentication setting.
:param headers: Header parameters dict to be updated.
:param querys: Query parameters tuple list to be updated.
:param auth_settings: Authentication setting identifiers list. | [
"Updates",
"header",
"and",
"query",
"params",
"based",
"on",
"authentication",
"setting",
"."
] | python | train | 42.416667 |
gem/oq-engine | openquake/hazardlib/sourceconverter.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L597-L612 | def convert_npdist(self, node):
"""
Convert the given node into a Nodal Plane Distribution.
:param node: a nodalPlaneDist node
:returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance
"""
with context(self.fname, node):
npdist = []
for np ... | [
"def",
"convert_npdist",
"(",
"self",
",",
"node",
")",
":",
"with",
"context",
"(",
"self",
".",
"fname",
",",
"node",
")",
":",
"npdist",
"=",
"[",
"]",
"for",
"np",
"in",
"node",
".",
"nodalPlaneDist",
":",
"prob",
",",
"strike",
",",
"dip",
","... | Convert the given node into a Nodal Plane Distribution.
:param node: a nodalPlaneDist node
:returns: a :class:`openquake.hazardlib.geo.NodalPlane` instance | [
"Convert",
"the",
"given",
"node",
"into",
"a",
"Nodal",
"Plane",
"Distribution",
"."
] | python | train | 42.375 |
numba/llvmlite | llvmlite/ir/values.py | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/values.py#L622-L627 | def insert_basic_block(self, before, name=''):
"""Insert block before
"""
blk = Block(parent=self, name=name)
self.blocks.insert(before, blk)
return blk | [
"def",
"insert_basic_block",
"(",
"self",
",",
"before",
",",
"name",
"=",
"''",
")",
":",
"blk",
"=",
"Block",
"(",
"parent",
"=",
"self",
",",
"name",
"=",
"name",
")",
"self",
".",
"blocks",
".",
"insert",
"(",
"before",
",",
"blk",
")",
"return... | Insert block before | [
"Insert",
"block",
"before"
] | python | train | 31.166667 |
nicolargo/glances | glances/plugins/glances_raid.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L154-L169 | def raid_alert(self, status, used, available, type):
"""RAID alert messages.
[available/used] means that ideally the array may have _available_
devices however, _used_ devices are in use.
Obviously when used >= available then things are good.
"""
if type == 'raid0':
... | [
"def",
"raid_alert",
"(",
"self",
",",
"status",
",",
"used",
",",
"available",
",",
"type",
")",
":",
"if",
"type",
"==",
"'raid0'",
":",
"return",
"'OK'",
"if",
"status",
"==",
"'inactive'",
":",
"return",
"'CRITICAL'",
"if",
"used",
"is",
"None",
"o... | RAID alert messages.
[available/used] means that ideally the array may have _available_
devices however, _used_ devices are in use.
Obviously when used >= available then things are good. | [
"RAID",
"alert",
"messages",
"."
] | python | train | 33.875 |
sunlightlabs/django-mediasync | mediasync/backends/s3.py | https://github.com/sunlightlabs/django-mediasync/blob/aa8ce4cfff757bbdb488463c64c0863cca6a1932/mediasync/backends/s3.py#L43-L56 | def remote_media_url(self, with_ssl=False):
"""
Returns the base remote media URL. In this case, we can safely make
some assumptions on the URL string based on bucket names, and having
public ACL on.
args:
with_ssl: (bool) If True, return an HTTPS url.
... | [
"def",
"remote_media_url",
"(",
"self",
",",
"with_ssl",
"=",
"False",
")",
":",
"protocol",
"=",
"'http'",
"if",
"with_ssl",
"is",
"False",
"else",
"'https'",
"url",
"=",
"(",
"self",
".",
"aws_bucket_cname",
"and",
"\"%s://%s\"",
"or",
"\"%s://s3.amazonaws.c... | Returns the base remote media URL. In this case, we can safely make
some assumptions on the URL string based on bucket names, and having
public ACL on.
args:
with_ssl: (bool) If True, return an HTTPS url. | [
"Returns",
"the",
"base",
"remote",
"media",
"URL",
".",
"In",
"this",
"case",
"we",
"can",
"safely",
"make",
"some",
"assumptions",
"on",
"the",
"URL",
"string",
"based",
"on",
"bucket",
"names",
"and",
"having",
"public",
"ACL",
"on",
".",
"args",
":",... | python | train | 41.428571 |
theislab/scanpy | scanpy/tools/_sim.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/tools/_sim.py#L484-L491 | def nhill_i(self,x,threshold=0.1,power=2):
""" Normalized inhibiting hill function.
Is equivalent to 1-nhill_a(self,x,power,threshold).
"""
x_pow = np.power(x,power)
threshold_pow = np.power(threshold,power)
return threshold_pow / (x_pow + threshold_pow) * (1 - x_pow... | [
"def",
"nhill_i",
"(",
"self",
",",
"x",
",",
"threshold",
"=",
"0.1",
",",
"power",
"=",
"2",
")",
":",
"x_pow",
"=",
"np",
".",
"power",
"(",
"x",
",",
"power",
")",
"threshold_pow",
"=",
"np",
".",
"power",
"(",
"threshold",
",",
"power",
")",... | Normalized inhibiting hill function.
Is equivalent to 1-nhill_a(self,x,power,threshold). | [
"Normalized",
"inhibiting",
"hill",
"function",
"."
] | python | train | 39.25 |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/textio.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L967-L972 | def green(cls):
"Make the text foreground color green."
wAttributes = cls._get_text_attributes()
wAttributes &= ~win32.FOREGROUND_MASK
wAttributes |= win32.FOREGROUND_GREEN
cls._set_text_attributes(wAttributes) | [
"def",
"green",
"(",
"cls",
")",
":",
"wAttributes",
"=",
"cls",
".",
"_get_text_attributes",
"(",
")",
"wAttributes",
"&=",
"~",
"win32",
".",
"FOREGROUND_MASK",
"wAttributes",
"|=",
"win32",
".",
"FOREGROUND_GREEN",
"cls",
".",
"_set_text_attributes",
"(",
"... | Make the text foreground color green. | [
"Make",
"the",
"text",
"foreground",
"color",
"green",
"."
] | python | train | 41 |
ArabellaTech/django-basic-cms | basic_cms/models.py | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/models.py#L124-L145 | def save(self, *args, **kwargs):
"""Override the default ``save`` method."""
if not self.status:
self.status = self.DRAFT
# Published pages should always have a publication date
if self.publication_date is None and self.status == self.PUBLISHED:
self.publication_d... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"status",
":",
"self",
".",
"status",
"=",
"self",
".",
"DRAFT",
"# Published pages should always have a publication date",
"if",
"self",
".",
"publi... | Override the default ``save`` method. | [
"Override",
"the",
"default",
"save",
"method",
"."
] | python | train | 50.363636 |
peo3/cgroup-utils | cgutils/cgroup.py | https://github.com/peo3/cgroup-utils/blob/fd7e99f438ce334bac5669fba0d08a6502fd7a82/cgutils/cgroup.py#L917-L935 | def scan_cgroups(subsys_name, filters=list()):
"""
It returns a control group hierarchy which belong to the subsys_name.
When collecting cgroups, filters are applied to the cgroups. See pydoc
of apply_filters method of CGroup for more information about the filters.
"""
status = SubsystemStatus()... | [
"def",
"scan_cgroups",
"(",
"subsys_name",
",",
"filters",
"=",
"list",
"(",
")",
")",
":",
"status",
"=",
"SubsystemStatus",
"(",
")",
"if",
"subsys_name",
"not",
"in",
"status",
".",
"get_all",
"(",
")",
":",
"raise",
"NoSuchSubsystemError",
"(",
"\"No s... | It returns a control group hierarchy which belong to the subsys_name.
When collecting cgroups, filters are applied to the cgroups. See pydoc
of apply_filters method of CGroup for more information about the filters. | [
"It",
"returns",
"a",
"control",
"group",
"hierarchy",
"which",
"belong",
"to",
"the",
"subsys_name",
".",
"When",
"collecting",
"cgroups",
"filters",
"are",
"applied",
"to",
"the",
"cgroups",
".",
"See",
"pydoc",
"of",
"apply_filters",
"method",
"of",
"CGroup... | python | train | 44.526316 |
Ouranosinc/xclim | xclim/indices.py | https://github.com/Ouranosinc/xclim/blob/2080d139188bd8de2aeca097a025c2d89d6e0e09/xclim/indices.py#L1209-L1245 | def max_n_day_precipitation_amount(pr, window=1, freq='YS'):
r"""Highest precipitation amount cumulated over a n-day moving window.
Calculate the n-day rolling sum of the original daily total precipitation series
and determine the maximum value over each period.
Parameters
----------
da : xarr... | [
"def",
"max_n_day_precipitation_amount",
"(",
"pr",
",",
"window",
"=",
"1",
",",
"freq",
"=",
"'YS'",
")",
":",
"# rolling sum of the values",
"arr",
"=",
"pr",
".",
"rolling",
"(",
"time",
"=",
"window",
",",
"center",
"=",
"False",
")",
".",
"sum",
"(... | r"""Highest precipitation amount cumulated over a n-day moving window.
Calculate the n-day rolling sum of the original daily total precipitation series
and determine the maximum value over each period.
Parameters
----------
da : xarray.DataArray
Daily precipitation values [Kg m-2 s-1] or [mm... | [
"r",
"Highest",
"precipitation",
"amount",
"cumulated",
"over",
"a",
"n",
"-",
"day",
"moving",
"window",
"."
] | python | train | 32.72973 |
PyCQA/astroid | astroid/_ast.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/_ast.py#L34-L40 | def parse_function_type_comment(type_comment: str) -> Optional[FunctionType]:
"""Given a correct type comment, obtain a FunctionType object"""
if _ast_py3 is None:
return None
func_type = _ast_py3.parse(type_comment, "<type_comment>", "func_type")
return FunctionType(argtypes=func_type.argtypes... | [
"def",
"parse_function_type_comment",
"(",
"type_comment",
":",
"str",
")",
"->",
"Optional",
"[",
"FunctionType",
"]",
":",
"if",
"_ast_py3",
"is",
"None",
":",
"return",
"None",
"func_type",
"=",
"_ast_py3",
".",
"parse",
"(",
"type_comment",
",",
"\"<type_c... | Given a correct type comment, obtain a FunctionType object | [
"Given",
"a",
"correct",
"type",
"comment",
"obtain",
"a",
"FunctionType",
"object"
] | python | train | 48.857143 |
estnltk/estnltk | estnltk/text.py | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L650-L658 | def endings(self):
"""The list of word endings.
Ambiguous cases are separated with pipe character by default.
Use :py:meth:`~estnltk.text.Text.get_analysis_element` to specify custom separator for ambiguous entries.
"""
if not self.is_tagged(ANALYSIS):
self.tag_analy... | [
"def",
"endings",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_tagged",
"(",
"ANALYSIS",
")",
":",
"self",
".",
"tag_analysis",
"(",
")",
"return",
"self",
".",
"get_analysis_element",
"(",
"ENDING",
")"
] | The list of word endings.
Ambiguous cases are separated with pipe character by default.
Use :py:meth:`~estnltk.text.Text.get_analysis_element` to specify custom separator for ambiguous entries. | [
"The",
"list",
"of",
"word",
"endings",
"."
] | python | train | 40.666667 |
NyashniyVladya/RusPhonetic | RusPhonetic/phonetic_module.py | https://github.com/NyashniyVladya/RusPhonetic/blob/4ecf19c59b8e84fc6376282adec2b6d84758c0af/RusPhonetic/phonetic_module.py#L327-L338 | def get_variant(self, return_deaf):
"""
Возвращает вариант буквы.
:return_deaf:
True - вернуть глухой вариант. Если False - звонкий.
"""
return_deaf = bool(return_deaf)
for variants in self.sonorus_deaf_pairs:
if self.__letter in variants:
... | [
"def",
"get_variant",
"(",
"self",
",",
"return_deaf",
")",
":",
"return_deaf",
"=",
"bool",
"(",
"return_deaf",
")",
"for",
"variants",
"in",
"self",
".",
"sonorus_deaf_pairs",
":",
"if",
"self",
".",
"__letter",
"in",
"variants",
":",
"return",
"variants",... | Возвращает вариант буквы.
:return_deaf:
True - вернуть глухой вариант. Если False - звонкий. | [
"Возвращает",
"вариант",
"буквы",
"."
] | python | train | 31.25 |
ConsenSys/mythril-classic | mythril/support/support_utils.py | https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/support/support_utils.py#L29-L41 | def get_code_hash(code: str) -> str:
"""
:param code: bytecode
:return: Returns hash of the given bytecode
"""
code = code[2:] if code[:2] == "0x" else code
try:
keccak = sha3.keccak_256()
keccak.update(bytes.fromhex(code))
return "0x" + keccak.hexdigest()
except Valu... | [
"def",
"get_code_hash",
"(",
"code",
":",
"str",
")",
"->",
"str",
":",
"code",
"=",
"code",
"[",
"2",
":",
"]",
"if",
"code",
"[",
":",
"2",
"]",
"==",
"\"0x\"",
"else",
"code",
"try",
":",
"keccak",
"=",
"sha3",
".",
"keccak_256",
"(",
")",
"... | :param code: bytecode
:return: Returns hash of the given bytecode | [
":",
"param",
"code",
":",
"bytecode",
":",
"return",
":",
"Returns",
"hash",
"of",
"the",
"given",
"bytecode"
] | python | train | 32.307692 |
tensorflow/cleverhans | cleverhans/attacks/momentum_iterative_method.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attacks/momentum_iterative_method.py#L43-L123 | def generate(self, x, **kwargs):
"""
Generate symbolic graph for adversarial examples and return.
:param x: The model's symbolic inputs.
:param kwargs: Keyword arguments. See `parse_params` for documentation.
"""
# Parse and save attack-specific parameters
assert self.parse_params(**kwargs)... | [
"def",
"generate",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"# Parse and save attack-specific parameters",
"assert",
"self",
".",
"parse_params",
"(",
"*",
"*",
"kwargs",
")",
"asserts",
"=",
"[",
"]",
"# If a data range was specified, check that ... | Generate symbolic graph for adversarial examples and return.
:param x: The model's symbolic inputs.
:param kwargs: Keyword arguments. See `parse_params` for documentation. | [
"Generate",
"symbolic",
"graph",
"for",
"adversarial",
"examples",
"and",
"return",
"."
] | python | train | 35.506173 |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L4012-L4053 | def strace_data_access_event(self,
operation,
address,
data,
data_mask=None,
access_width=4,
address_range=0):
"""... | [
"def",
"strace_data_access_event",
"(",
"self",
",",
"operation",
",",
"address",
",",
"data",
",",
"data_mask",
"=",
"None",
",",
"access_width",
"=",
"4",
",",
"address_range",
"=",
"0",
")",
":",
"cmd",
"=",
"enums",
".",
"JLinkStraceCommand",
".",
"TRA... | Sets an event to trigger trace logic when data access is made.
Data access corresponds to either a read or write.
Args:
self (JLink): the ``JLink`` instance.
operation (int): one of the operations in ``JLinkStraceOperation``.
address (int): the address of the load/store d... | [
"Sets",
"an",
"event",
"to",
"trigger",
"trace",
"logic",
"when",
"data",
"access",
"is",
"made",
"."
] | python | train | 41.380952 |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L81-L94 | def list_processed_parameter_groups(self):
"""
Returns the existing parameter groups.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/a... | [
"def",
"list_processed_parameter_groups",
"(",
"self",
")",
":",
"# Server does not do pagination on listings of this resource.",
"# Return an iterator anyway for similarity with other API methods",
"path",
"=",
"'/archive/{}/parameter-groups'",
".",
"format",
"(",
"self",
".",
"_ins... | Returns the existing parameter groups.
:rtype: ~collections.Iterable[str] | [
"Returns",
"the",
"existing",
"parameter",
"groups",
"."
] | python | train | 41.571429 |
google/tangent | tangent/ast.py | https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/ast.py#L25-L39 | def get_name(node):
"""Get the name of a variable.
Args:
node: A `Name`, `Subscript` or `Attribute` node.
Returns:
The name of the variable e.g. `'x'` for `x`, `x.i` and `x[i]`.
"""
if isinstance(node, gast.Name):
return node.id
elif isinstance(node, (gast.Subscript, gast.Attribute)):
retu... | [
"def",
"get_name",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"gast",
".",
"Name",
")",
":",
"return",
"node",
".",
"id",
"elif",
"isinstance",
"(",
"node",
",",
"(",
"gast",
".",
"Subscript",
",",
"gast",
".",
"Attribute",
")",
"... | Get the name of a variable.
Args:
node: A `Name`, `Subscript` or `Attribute` node.
Returns:
The name of the variable e.g. `'x'` for `x`, `x.i` and `x[i]`. | [
"Get",
"the",
"name",
"of",
"a",
"variable",
"."
] | python | train | 23.8 |
Fizzadar/pyinfra | pyinfra/modules/ssh.py | https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/modules/ssh.py#L112-L154 | def download(
state, host, hostname, filename,
local_filename=None, force=False,
ssh_keyscan=False, ssh_user=None,
):
'''
Download files from other servers using ``scp``.
+ hostname: hostname to upload to
+ filename: file to download
+ local_filename: where to download the file to (defa... | [
"def",
"download",
"(",
"state",
",",
"host",
",",
"hostname",
",",
"filename",
",",
"local_filename",
"=",
"None",
",",
"force",
"=",
"False",
",",
"ssh_keyscan",
"=",
"False",
",",
"ssh_user",
"=",
"None",
",",
")",
":",
"local_filename",
"=",
"local_f... | Download files from other servers using ``scp``.
+ hostname: hostname to upload to
+ filename: file to download
+ local_filename: where to download the file to (defaults to ``filename``)
+ force: always download the file, even if present locally
+ ssh_keyscan: execute ``ssh.keyscan`` before uploadi... | [
"Download",
"files",
"from",
"other",
"servers",
"using",
"scp",
"."
] | python | train | 30.813953 |
sendgrid/sendgrid-python | examples/helpers/mail_example.py | https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/examples/helpers/mail_example.py#L95-L103 | def build_attachment2():
"""Build attachment mock."""
attachment = Attachment()
attachment.content = "BwdW"
attachment.type = "image/png"
attachment.filename = "banner.png"
attachment.disposition = "inline"
attachment.content_id = "Banner"
return attachment | [
"def",
"build_attachment2",
"(",
")",
":",
"attachment",
"=",
"Attachment",
"(",
")",
"attachment",
".",
"content",
"=",
"\"BwdW\"",
"attachment",
".",
"type",
"=",
"\"image/png\"",
"attachment",
".",
"filename",
"=",
"\"banner.png\"",
"attachment",
".",
"dispos... | Build attachment mock. | [
"Build",
"attachment",
"mock",
"."
] | python | train | 31.222222 |
bhmm/bhmm | bhmm/_external/sklearn/base.py | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/_external/sklearn/base.py#L67-L90 | def _get_param_names(cls):
"""Get parameter names for the estimator"""
# fetch the constructor or the original constructor before
# deprecation wrapping if any
init = getattr(cls.__init__, 'deprecated_original', cls.__init__)
if init is object.__init__:
# No explicit ... | [
"def",
"_get_param_names",
"(",
"cls",
")",
":",
"# fetch the constructor or the original constructor before",
"# deprecation wrapping if any",
"init",
"=",
"getattr",
"(",
"cls",
".",
"__init__",
",",
"'deprecated_original'",
",",
"cls",
".",
"__init__",
")",
"if",
"in... | Get parameter names for the estimator | [
"Get",
"parameter",
"names",
"for",
"the",
"estimator"
] | python | train | 43.625 |
fulfilio/fulfil-python-api | fulfil_client/client.py | https://github.com/fulfilio/fulfil-python-api/blob/180ac969c427b1292439a0371866aa5f169ffa6b/fulfil_client/client.py#L421-L454 | def find(self, filter=None, page=1, per_page=10, fields=None, context=None):
"""
Find records that match the filter.
Pro Tip: The fields could have nested fields names if the field is
a relationship type. For example if you were looking up an order
and also want to get the shipp... | [
"def",
"find",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"page",
"=",
"1",
",",
"per_page",
"=",
"10",
",",
"fields",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"filter",
"is",
"None",
":",
"filter",
"=",
"[",
"]",
"rv",
"=",... | Find records that match the filter.
Pro Tip: The fields could have nested fields names if the field is
a relationship type. For example if you were looking up an order
and also want to get the shipping address country then fields would be:
`['shipment_address', 'shipment_address.co... | [
"Find",
"records",
"that",
"match",
"the",
"filter",
"."
] | python | train | 40.117647 |
Yelp/threat_intel | threat_intel/opendns.py | https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L192-L202 | def whois_domains(self, domains):
"""Calls WHOIS domain end point
Args:
domains: An enumerable of domains
Returns:
A dict of {domain: domain_result}
"""
api_name = 'opendns-whois-domain'
fmt_url_path = u'whois/{0}'
return self._multi_get(a... | [
"def",
"whois_domains",
"(",
"self",
",",
"domains",
")",
":",
"api_name",
"=",
"'opendns-whois-domain'",
"fmt_url_path",
"=",
"u'whois/{0}'",
"return",
"self",
".",
"_multi_get",
"(",
"api_name",
",",
"fmt_url_path",
",",
"domains",
")"
] | Calls WHOIS domain end point
Args:
domains: An enumerable of domains
Returns:
A dict of {domain: domain_result} | [
"Calls",
"WHOIS",
"domain",
"end",
"point"
] | python | train | 31 |
inasafe/inasafe | safe/gis/vector/tools.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L479-L524 | def measure(self, geometry):
"""Measure the length or the area of a geometry.
:param geometry: The geometry.
:type geometry: QgsGeometry
:return: The geometric size in the expected exposure unit.
:rtype: float
"""
message = 'Size with NaN value : geometry valid=... | [
"def",
"measure",
"(",
"self",
",",
"geometry",
")",
":",
"message",
"=",
"'Size with NaN value : geometry valid={valid}, WKT={wkt}'",
"feature_size",
"=",
"0",
"if",
"geometry",
".",
"isMultipart",
"(",
")",
":",
"# Be careful, the size calculator is not working well on a"... | Measure the length or the area of a geometry.
:param geometry: The geometry.
:type geometry: QgsGeometry
:return: The geometric size in the expected exposure unit.
:rtype: float | [
"Measure",
"the",
"length",
"or",
"the",
"area",
"of",
"a",
"geometry",
"."
] | python | train | 39.73913 |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/flask/app.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/flask/app.py#L600-L612 | def make_config(self, instance_relative=False):
"""Used to create the config attribute by the Flask constructor.
The `instance_relative` parameter is passed in from the constructor
of Flask (there named `instance_relative_config`) and indicates if
the config should be relative to the ins... | [
"def",
"make_config",
"(",
"self",
",",
"instance_relative",
"=",
"False",
")",
":",
"root_path",
"=",
"self",
".",
"root_path",
"if",
"instance_relative",
":",
"root_path",
"=",
"self",
".",
"instance_path",
"return",
"Config",
"(",
"root_path",
",",
"self",
... | Used to create the config attribute by the Flask constructor.
The `instance_relative` parameter is passed in from the constructor
of Flask (there named `instance_relative_config`) and indicates if
the config should be relative to the instance path or the root path
of the application.
... | [
"Used",
"to",
"create",
"the",
"config",
"attribute",
"by",
"the",
"Flask",
"constructor",
".",
"The",
"instance_relative",
"parameter",
"is",
"passed",
"in",
"from",
"the",
"constructor",
"of",
"Flask",
"(",
"there",
"named",
"instance_relative_config",
")",
"a... | python | test | 43.692308 |
mgedmin/imgdiff | imgdiff.py | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L169-L189 | def pick_orientation(img1, img2, spacing, desired_aspect=1.618):
"""Pick a tiling orientation for two images.
Returns either 'lr' for left-and-right, or 'tb' for top-and-bottom.
Picks the one that makes the combined image have a better aspect
ratio, where 'better' is defined as 'closer to 1:1.618'.
... | [
"def",
"pick_orientation",
"(",
"img1",
",",
"img2",
",",
"spacing",
",",
"desired_aspect",
"=",
"1.618",
")",
":",
"w1",
",",
"h1",
"=",
"img1",
".",
"size",
"w2",
",",
"h2",
"=",
"img2",
".",
"size",
"size_a",
"=",
"(",
"w1",
"+",
"spacing",
"+",... | Pick a tiling orientation for two images.
Returns either 'lr' for left-and-right, or 'tb' for top-and-bottom.
Picks the one that makes the combined image have a better aspect
ratio, where 'better' is defined as 'closer to 1:1.618'. | [
"Pick",
"a",
"tiling",
"orientation",
"for",
"two",
"images",
"."
] | python | train | 35.190476 |
ttroy50/pyephember | pyephember/pyephember.py | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L373-L402 | def set_mode_by_id(self, zone_id, mode):
"""
Set the mode by using the zone id
Supported zones are available in the enum Mode
"""
if not self._do_auth():
raise RuntimeError("Unable to login")
data = {
"ZoneId": zone_id,
"mode": mode.va... | [
"def",
"set_mode_by_id",
"(",
"self",
",",
"zone_id",
",",
"mode",
")",
":",
"if",
"not",
"self",
".",
"_do_auth",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to login\"",
")",
"data",
"=",
"{",
"\"ZoneId\"",
":",
"zone_id",
",",
"\"mode\"",
"... | Set the mode by using the zone id
Supported zones are available in the enum Mode | [
"Set",
"the",
"mode",
"by",
"using",
"the",
"zone",
"id",
"Supported",
"zones",
"are",
"available",
"in",
"the",
"enum",
"Mode"
] | python | train | 27.733333 |
SiLab-Bonn/pyBAR | pybar/scans/analyze_source_scan_gdac_data.py | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/scans/analyze_source_scan_gdac_data.py#L77-L106 | def plot_result(x_p, y_p, y_p_e, smoothed_data, smoothed_data_diff, filename=None):
''' Fit spline to the profile histogramed data, differentiate, determine MPV and plot.
Parameters
----------
x_p, y_p : array like
data points (x,y)
y_p_e : array like
error bars in y... | [
"def",
"plot_result",
"(",
"x_p",
",",
"y_p",
",",
"y_p_e",
",",
"smoothed_data",
",",
"smoothed_data_diff",
",",
"filename",
"=",
"None",
")",
":",
"logging",
".",
"info",
"(",
"'Plot results'",
")",
"plt",
".",
"close",
"(",
")",
"p1",
"=",
"plt",
".... | Fit spline to the profile histogramed data, differentiate, determine MPV and plot.
Parameters
----------
x_p, y_p : array like
data points (x,y)
y_p_e : array like
error bars in y | [
"Fit",
"spline",
"to",
"the",
"profile",
"histogramed",
"data",
"differentiate",
"determine",
"MPV",
"and",
"plot",
".",
"Parameters",
"----------",
"x_p",
"y_p",
":",
"array",
"like",
"data",
"points",
"(",
"x",
"y",
")",
"y_p_e",
":",
"array",
"like",
"e... | python | train | 61.233333 |
CityOfZion/neo-python | neo/api/JSONRPC/JsonRpcApi.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/api/JSONRPC/JsonRpcApi.py#L497-L508 | def list_address(self):
"""Get information about all the addresses present on the open wallet"""
result = []
for addrStr in self.wallet.Addresses:
addr = self.wallet.GetAddress(addrStr)
result.append({
"address": addrStr,
"haskey": not addr... | [
"def",
"list_address",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"addrStr",
"in",
"self",
".",
"wallet",
".",
"Addresses",
":",
"addr",
"=",
"self",
".",
"wallet",
".",
"GetAddress",
"(",
"addrStr",
")",
"result",
".",
"append",
"(",
"{"... | Get information about all the addresses present on the open wallet | [
"Get",
"information",
"about",
"all",
"the",
"addresses",
"present",
"on",
"the",
"open",
"wallet"
] | python | train | 36.416667 |
GNS3/gns3-server | gns3server/compute/base_manager.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L388-L428 | def create_nio(self, nio_settings):
"""
Creates a new NIO.
:param nio_settings: information to create the NIO
:returns: a NIO object
"""
nio = None
if nio_settings["type"] == "nio_udp":
lport = nio_settings["lport"]
rhost = nio_settings[... | [
"def",
"create_nio",
"(",
"self",
",",
"nio_settings",
")",
":",
"nio",
"=",
"None",
"if",
"nio_settings",
"[",
"\"type\"",
"]",
"==",
"\"nio_udp\"",
":",
"lport",
"=",
"nio_settings",
"[",
"\"lport\"",
"]",
"rhost",
"=",
"nio_settings",
"[",
"\"rhost\"",
... | Creates a new NIO.
:param nio_settings: information to create the NIO
:returns: a NIO object | [
"Creates",
"a",
"new",
"NIO",
"."
] | python | train | 50.365854 |
matrix-org/matrix-python-sdk | matrix_client/crypto/olm_device.py | https://github.com/matrix-org/matrix-python-sdk/blob/e734cce3ccd35f2d355c6a19a7a701033472498a/matrix_client/crypto/olm_device.py#L63-L78 | def upload_identity_keys(self):
"""Uploads this device's identity keys to HS.
This device must be the one used when logging in.
"""
device_keys = {
'user_id': self.user_id,
'device_id': self.device_id,
'algorithms': self._algorithms,
'keys... | [
"def",
"upload_identity_keys",
"(",
"self",
")",
":",
"device_keys",
"=",
"{",
"'user_id'",
":",
"self",
".",
"user_id",
",",
"'device_id'",
":",
"self",
".",
"device_id",
",",
"'algorithms'",
":",
"self",
".",
"_algorithms",
",",
"'keys'",
":",
"{",
"'{}:... | Uploads this device's identity keys to HS.
This device must be the one used when logging in. | [
"Uploads",
"this",
"device",
"s",
"identity",
"keys",
"to",
"HS",
"."
] | python | train | 40.3125 |
Rapptz/discord.py | discord/channel.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L1125-L1154 | async def edit(self, **fields):
"""|coro|
Edits the group.
Parameters
-----------
name: Optional[:class:`str`]
The new name to change the group to.
Could be ``None`` to remove the name.
icon: Optional[:class:`bytes`]
A :term:`py:bytes... | [
"async",
"def",
"edit",
"(",
"self",
",",
"*",
"*",
"fields",
")",
":",
"try",
":",
"icon_bytes",
"=",
"fields",
"[",
"'icon'",
"]",
"except",
"KeyError",
":",
"pass",
"else",
":",
"if",
"icon_bytes",
"is",
"not",
"None",
":",
"fields",
"[",
"'icon'"... | |coro|
Edits the group.
Parameters
-----------
name: Optional[:class:`str`]
The new name to change the group to.
Could be ``None`` to remove the name.
icon: Optional[:class:`bytes`]
A :term:`py:bytes-like object` representing the new icon.
... | [
"|coro|"
] | python | train | 26.966667 |
pantsbuild/pants | src/python/pants/scm/git.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/scm/git.py#L76-L92 | def _invoke(cls, cmd):
"""Invoke the given command, and return a tuple of process and raw binary output.
stderr flows to wherever its currently mapped for the parent process - generally to
the terminal where the user can see the error.
:param list cmd: The command in the form of a list of strings
... | [
"def",
"_invoke",
"(",
"cls",
",",
"cmd",
")",
":",
"try",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"except",
"OSError",
"as",
"e",
":",
"# Binary DNE or is not executable",
"raise",
... | Invoke the given command, and return a tuple of process and raw binary output.
stderr flows to wherever its currently mapped for the parent process - generally to
the terminal where the user can see the error.
:param list cmd: The command in the form of a list of strings
:returns: The completed proces... | [
"Invoke",
"the",
"given",
"command",
"and",
"return",
"a",
"tuple",
"of",
"process",
"and",
"raw",
"binary",
"output",
"."
] | python | train | 43.882353 |
martinpitt/python-dbusmock | dbusmock/templates/networkmanager.py | https://github.com/martinpitt/python-dbusmock/blob/26f65f78bc0ed347233f699a8d6ee0e6880e7eb0/dbusmock/templates/networkmanager.py#L461-L557 | def AddWiFiConnection(self, dev_path, connection_name, ssid_name, key_mgmt):
'''Add an available connection to an existing WiFi device and access point.
You have to specify WiFi Device path, Connection object name,
SSID and key management.
The SSID must match one of the previously created access point... | [
"def",
"AddWiFiConnection",
"(",
"self",
",",
"dev_path",
",",
"connection_name",
",",
"ssid_name",
",",
"key_mgmt",
")",
":",
"dev_obj",
"=",
"dbusmock",
".",
"get_object",
"(",
"dev_path",
")",
"connection_path",
"=",
"'/org/freedesktop/NetworkManager/Settings/'",
... | Add an available connection to an existing WiFi device and access point.
You have to specify WiFi Device path, Connection object name,
SSID and key management.
The SSID must match one of the previously created access points.
Please note that this does not set any global properties.
Returns the n... | [
"Add",
"an",
"available",
"connection",
"to",
"an",
"existing",
"WiFi",
"device",
"and",
"access",
"point",
"."
] | python | train | 38.680412 |
DigitalGlobe/gbdxtools | gbdxtools/images/mixins/geo.py | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L147-L155 | def ndwi(self):
"""
Calculates Normalized Difference Water Index using Coastal and NIR2 bands for WV02, WV03.
For Landsat8 and sentinel2 calculated by using Green and NIR bands.
Returns: numpy array of ndwi values
"""
data = self._read(self[self._ndwi_bands,...]).astype(... | [
"def",
"ndwi",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_read",
"(",
"self",
"[",
"self",
".",
"_ndwi_bands",
",",
"...",
"]",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"return",
"(",
"data",
"[",
"1",
",",
":",
",",
":",
"... | Calculates Normalized Difference Water Index using Coastal and NIR2 bands for WV02, WV03.
For Landsat8 and sentinel2 calculated by using Green and NIR bands.
Returns: numpy array of ndwi values | [
"Calculates",
"Normalized",
"Difference",
"Water",
"Index",
"using",
"Coastal",
"and",
"NIR2",
"bands",
"for",
"WV02",
"WV03",
".",
"For",
"Landsat8",
"and",
"sentinel2",
"calculated",
"by",
"using",
"Green",
"and",
"NIR",
"bands",
"."
] | python | valid | 44 |
pydata/xarray | xarray/coding/cftimeindex.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/cftimeindex.py#L241-L301 | def _partial_date_slice(self, resolution, parsed):
"""Adapted from
pandas.tseries.index.DatetimeIndex._partial_date_slice
Note that when using a CFTimeIndex, if a partial-date selection
returns a single element, it will never be converted to a scalar
coordinate; this is in sligh... | [
"def",
"_partial_date_slice",
"(",
"self",
",",
"resolution",
",",
"parsed",
")",
":",
"start",
",",
"end",
"=",
"_parsed_string_to_bounds",
"(",
"self",
".",
"date_type",
",",
"resolution",
",",
"parsed",
")",
"times",
"=",
"self",
".",
"_data",
"if",
"se... | Adapted from
pandas.tseries.index.DatetimeIndex._partial_date_slice
Note that when using a CFTimeIndex, if a partial-date selection
returns a single element, it will never be converted to a scalar
coordinate; this is in slight contrast to the behavior when using
a DatetimeIndex,... | [
"Adapted",
"from",
"pandas",
".",
"tseries",
".",
"index",
".",
"DatetimeIndex",
".",
"_partial_date_slice"
] | python | train | 40.967213 |
ArchiveTeam/wpull | wpull/url.py | https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/url.py#L641-L662 | def split_query(qs, keep_blank_values=False):
'''Split the query string.
Note for empty values: If an equal sign (``=``) is present, the value
will be an empty string (``''``). Otherwise, the value will be ``None``::
>>> list(split_query('a=&b', keep_blank_values=True))
[('a', ''), ('b', N... | [
"def",
"split_query",
"(",
"qs",
",",
"keep_blank_values",
"=",
"False",
")",
":",
"items",
"=",
"[",
"]",
"for",
"pair",
"in",
"qs",
".",
"split",
"(",
"'&'",
")",
":",
"name",
",",
"delim",
",",
"value",
"=",
"pair",
".",
"partition",
"(",
"'='",... | Split the query string.
Note for empty values: If an equal sign (``=``) is present, the value
will be an empty string (``''``). Otherwise, the value will be ``None``::
>>> list(split_query('a=&b', keep_blank_values=True))
[('a', ''), ('b', None)]
No processing is done on the actual values... | [
"Split",
"the",
"query",
"string",
"."
] | python | train | 28.363636 |
Cognexa/cxflow | cxflow/hooks/abstract_hook.py | https://github.com/Cognexa/cxflow/blob/dd609e6b0bd854424a8f86781dd77801a13038f9/cxflow/hooks/abstract_hook.py#L84-L94 | def after_epoch_profile(self, epoch_id: int, profile: TimeProfile, train_stream_name: str, extra_streams: Iterable[str]) -> None:
"""
After epoch profile event.
This event provides opportunity to process time profile of the finished epoch.
:param epoch_id: finished epoch id
:pa... | [
"def",
"after_epoch_profile",
"(",
"self",
",",
"epoch_id",
":",
"int",
",",
"profile",
":",
"TimeProfile",
",",
"train_stream_name",
":",
"str",
",",
"extra_streams",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"None",
":",
"pass"
] | After epoch profile event.
This event provides opportunity to process time profile of the finished epoch.
:param epoch_id: finished epoch id
:param profile: dictionary of lists of event timings that were measured during the epoch
:param extra_streams: enumeration of additional stream n... | [
"After",
"epoch",
"profile",
"event",
"."
] | python | train | 44.454545 |
has2k1/mizani | mizani/palettes.py | https://github.com/has2k1/mizani/blob/312d0550ee0136fd1b0384829b33f3b2065f47c8/mizani/palettes.py#L651-L682 | def manual_pal(values):
"""
Create a palette from a list of values
Parameters
----------
values : sequence
Values that will be returned by the palette function.
Returns
-------
out : function
A function palette that takes a single
:class:`int` parameter ``n`` an... | [
"def",
"manual_pal",
"(",
"values",
")",
":",
"max_n",
"=",
"len",
"(",
"values",
")",
"def",
"_manual_pal",
"(",
"n",
")",
":",
"if",
"n",
">",
"max_n",
":",
"msg",
"=",
"(",
"\"Palette can return a maximum of {} values. \"",
"\"{} were requested from it.\"",
... | Create a palette from a list of values
Parameters
----------
values : sequence
Values that will be returned by the palette function.
Returns
-------
out : function
A function palette that takes a single
:class:`int` parameter ``n`` and returns ``n`` values.
Example... | [
"Create",
"a",
"palette",
"from",
"a",
"list",
"of",
"values"
] | python | valid | 22.6875 |
angr/pyvex | pyvex/block.py | https://github.com/angr/pyvex/blob/c418edc1146982b2a0579bf56e5993c1c7046b19/pyvex/block.py#L444-L471 | def _pp_str(self):
"""
Return the pretty-printed IRSB.
:rtype: str
"""
sa = []
sa.append("IRSB {")
if self.statements is not None:
sa.append(" %s" % self.tyenv)
sa.append("")
if self.statements is not None:
for i, s in en... | [
"def",
"_pp_str",
"(",
"self",
")",
":",
"sa",
"=",
"[",
"]",
"sa",
".",
"append",
"(",
"\"IRSB {\"",
")",
"if",
"self",
".",
"statements",
"is",
"not",
"None",
":",
"sa",
".",
"append",
"(",
"\" %s\"",
"%",
"self",
".",
"tyenv",
")",
"sa",
"."... | Return the pretty-printed IRSB.
:rtype: str | [
"Return",
"the",
"pretty",
"-",
"printed",
"IRSB",
"."
] | python | train | 44.75 |
pallets/werkzeug | src/werkzeug/_reloader.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/_reloader.py#L63-L113 | def _get_args_for_reloading():
"""Returns the executable. This contains a workaround for windows
if the executable is incorrectly reported to not have the .exe
extension which can cause bugs on reloading. This also contains
a workaround for linux where the file is executable (possibly with
a progra... | [
"def",
"_get_args_for_reloading",
"(",
")",
":",
"rv",
"=",
"[",
"sys",
".",
"executable",
"]",
"py_script",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",... | Returns the executable. This contains a workaround for windows
if the executable is incorrectly reported to not have the .exe
extension which can cause bugs on reloading. This also contains
a workaround for linux where the file is executable (possibly with
a program other than python) | [
"Returns",
"the",
"executable",
".",
"This",
"contains",
"a",
"workaround",
"for",
"windows",
"if",
"the",
"executable",
"is",
"incorrectly",
"reported",
"to",
"not",
"have",
"the",
".",
"exe",
"extension",
"which",
"can",
"cause",
"bugs",
"on",
"reloading",
... | python | train | 36.490196 |
oleiade/durations | durations/parser.py | https://github.com/oleiade/durations/blob/62c176dfa7d36d5c59bf93bdebfdc80ab53757bd/durations/parser.py#L43-L93 | def extract_tokens(representation, separators=SEPARATOR_CHARACTERS):
"""Extracts durations tokens from a duration representation.
Parses the string representation incrementaly and raises
on first error met.
:param representation: duration representation
:type representation: string
"""
... | [
"def",
"extract_tokens",
"(",
"representation",
",",
"separators",
"=",
"SEPARATOR_CHARACTERS",
")",
":",
"buff",
"=",
"\"\"",
"elements",
"=",
"[",
"]",
"last_index",
"=",
"0",
"last_token",
"=",
"None",
"for",
"index",
",",
"c",
"in",
"enumerate",
"(",
"... | Extracts durations tokens from a duration representation.
Parses the string representation incrementaly and raises
on first error met.
:param representation: duration representation
:type representation: string | [
"Extracts",
"durations",
"tokens",
"from",
"a",
"duration",
"representation",
"."
] | python | train | 32.901961 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/filesysitemdata.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/filesysitemdata.py#L10-L24 | def taskfileinfo_element_data(tfi, role):
"""Return the data for the element (e.g. the Asset or Shot)
:param tfi: the :class:`jukeboxcore.filesys.TaskFileInfo` holds the data
:type tfi: :class:`jukeboxcore.filesys.TaskFileInfo`
:param role: item data role
:type role: QtCore.Qt.ItemDataRole
:ret... | [
"def",
"taskfileinfo_element_data",
"(",
"tfi",
",",
"role",
")",
":",
"task",
"=",
"tfi",
".",
"task",
"element",
"=",
"task",
".",
"element",
"if",
"role",
"==",
"QtCore",
".",
"Qt",
".",
"DisplayRole",
"or",
"role",
"==",
"QtCore",
".",
"Qt",
".",
... | Return the data for the element (e.g. the Asset or Shot)
:param tfi: the :class:`jukeboxcore.filesys.TaskFileInfo` holds the data
:type tfi: :class:`jukeboxcore.filesys.TaskFileInfo`
:param role: item data role
:type role: QtCore.Qt.ItemDataRole
:returns: data for the element
:rtype: depending ... | [
"Return",
"the",
"data",
"for",
"the",
"element",
"(",
"e",
".",
"g",
".",
"the",
"Asset",
"or",
"Shot",
")"
] | python | train | 35.4 |
pycampers/zproc | zproc/context.py | https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/context.py#L201-L218 | def create_state(self, value: dict = None, *, namespace: str = None):
"""
Creates a new :py:class:`State` object, sharing the same zproc server as this Context.
:param value:
If provided, call ``state.update(value)``.
:param namespace:
Use this as the namespace f... | [
"def",
"create_state",
"(",
"self",
",",
"value",
":",
"dict",
"=",
"None",
",",
"*",
",",
"namespace",
":",
"str",
"=",
"None",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"self",
".",
"namespace",
"state",
"=",
"State",
"(",
... | Creates a new :py:class:`State` object, sharing the same zproc server as this Context.
:param value:
If provided, call ``state.update(value)``.
:param namespace:
Use this as the namespace for the :py:class:`State` object,
instead of this :py:class:`Context`\ 's names... | [
"Creates",
"a",
"new",
":",
"py",
":",
"class",
":",
"State",
"object",
"sharing",
"the",
"same",
"zproc",
"server",
"as",
"this",
"Context",
"."
] | python | train | 37.944444 |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L709-L762 | def get_exports(client, bucket, prefix, latest=True):
"""Find exports for a given account
"""
keys = client.list_objects_v2(
Bucket=bucket, Prefix=prefix, Delimiter='/').get('CommonPrefixes', [])
found = []
years = []
for y in keys:
part = y['Prefix'].rsplit('/', 2)[-2]
i... | [
"def",
"get_exports",
"(",
"client",
",",
"bucket",
",",
"prefix",
",",
"latest",
"=",
"True",
")",
":",
"keys",
"=",
"client",
".",
"list_objects_v2",
"(",
"Bucket",
"=",
"bucket",
",",
"Prefix",
"=",
"prefix",
",",
"Delimiter",
"=",
"'/'",
")",
".",
... | Find exports for a given account | [
"Find",
"exports",
"for",
"a",
"given",
"account"
] | python | train | 30.12963 |
nccgroup/opinel | opinel/utils/credentials.py | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/credentials.py#L57-L93 | def assume_role(role_name, credentials, role_arn, role_session_name, silent = False):
"""
Assume role and save credentials
:param role_name:
:param credentials:
:param role_arn:
:param role_session_name:
:param silent:
:return:
"""
external_id = credentials.pop('ExternalId') if ... | [
"def",
"assume_role",
"(",
"role_name",
",",
"credentials",
",",
"role_arn",
",",
"role_session_name",
",",
"silent",
"=",
"False",
")",
":",
"external_id",
"=",
"credentials",
".",
"pop",
"(",
"'ExternalId'",
")",
"if",
"'ExternalId'",
"in",
"credentials",
"e... | Assume role and save credentials
:param role_name:
:param credentials:
:param role_arn:
:param role_session_name:
:param silent:
:return: | [
"Assume",
"role",
"and",
"save",
"credentials"
] | python | train | 39.540541 |
kpdyer/regex2dfa | third_party/re2/lib/codereview/codereview.py | https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/lib/codereview/codereview.py#L1776-L1802 | def gofmt(ui, repo, *pats, **opts):
"""apply gofmt to modified files
Applies gofmt to the modified files in the repository that match
the given patterns.
"""
if codereview_disabled:
raise hg_util.Abort(codereview_disabled)
files = ChangedExistingFiles(ui, repo, pats, opts)
files = gofmt_required(files)
if n... | [
"def",
"gofmt",
"(",
"ui",
",",
"repo",
",",
"*",
"pats",
",",
"*",
"*",
"opts",
")",
":",
"if",
"codereview_disabled",
":",
"raise",
"hg_util",
".",
"Abort",
"(",
"codereview_disabled",
")",
"files",
"=",
"ChangedExistingFiles",
"(",
"ui",
",",
"repo",
... | apply gofmt to modified files
Applies gofmt to the modified files in the repository that match
the given patterns. | [
"apply",
"gofmt",
"to",
"modified",
"files"
] | python | train | 26 |
saltstack/salt | salt/utils/oset.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/oset.py#L162-L175 | def discard(self, key):
"""
Remove an element. Do not raise an exception if absent.
The MutableSet mixin uses this to implement the .remove() method, which
*does* raise an error when asked to remove a non-existent item.
"""
if key in self:
i = self.map[key]
... | [
"def",
"discard",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
":",
"i",
"=",
"self",
".",
"map",
"[",
"key",
"]",
"del",
"self",
".",
"items",
"[",
"i",
"]",
"del",
"self",
".",
"map",
"[",
"key",
"]",
"for",
"k",
",",
"v"... | Remove an element. Do not raise an exception if absent.
The MutableSet mixin uses this to implement the .remove() method, which
*does* raise an error when asked to remove a non-existent item. | [
"Remove",
"an",
"element",
".",
"Do",
"not",
"raise",
"an",
"exception",
"if",
"absent",
"."
] | python | train | 33.928571 |
googleapis/google-cloud-python | bigtable/google/cloud/bigtable_v2/gapic/bigtable_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable_v2/gapic/bigtable_client.py#L452-L540 | def mutate_rows(
self,
table_name,
entries,
app_profile_id=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Mutates multiple rows in a batch. Each individual row is muta... | [
"def",
"mutate_rows",
"(",
"self",
",",
"table_name",
",",
"entries",
",",
"app_profile_id",
"=",
"None",
",",
"retry",
"=",
"google",
".",
"api_core",
".",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
"=",
"google",
".",
"api_core",
".",
"... | Mutates multiple rows in a batch. Each individual row is mutated
atomically as in MutateRow, but the entire batch is not executed
atomically.
Example:
>>> from google.cloud import bigtable_v2
>>>
>>> client = bigtable_v2.BigtableClient()
>>>
... | [
"Mutates",
"multiple",
"rows",
"in",
"a",
"batch",
".",
"Each",
"individual",
"row",
"is",
"mutated",
"atomically",
"as",
"in",
"MutateRow",
"but",
"the",
"entire",
"batch",
"is",
"not",
"executed",
"atomically",
"."
] | python | train | 43.235955 |
wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/__init__.py | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L2021-L2090 | def sweep_channels_slow(self, sampling_window_ms, n_sampling_windows,
delay_between_windows_ms, interleave_samples,
use_rms, channel_mask):
'''
Measure voltage across load of each of the following control board
feedback circuits:
... | [
"def",
"sweep_channels_slow",
"(",
"self",
",",
"sampling_window_ms",
",",
"n_sampling_windows",
",",
"delay_between_windows_ms",
",",
"interleave_samples",
",",
"use_rms",
",",
"channel_mask",
")",
":",
"channel_count",
"=",
"len",
"(",
"channel_mask",
")",
"scan_cou... | Measure voltage across load of each of the following control board
feedback circuits:
- Reference _(i.e., attenuated high-voltage amplifier output)_.
- Load _(i.e., voltage across DMF device)_.
For each channel in the channel mask. The measured voltage _(i.e.,
``V2``)_ can be... | [
"Measure",
"voltage",
"across",
"load",
"of",
"each",
"of",
"the",
"following",
"control",
"board",
"feedback",
"circuits",
":"
] | python | train | 44.428571 |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2397-L2401 | def nps_survey_responses(self, survey_id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/nps-api/responses#list-responses"
api_path = "/api/v2/nps/surveys/{survey_id}/responses.json"
api_path = api_path.format(survey_id=survey_id)
return self.call(api_path, **kwargs) | [
"def",
"nps_survey_responses",
"(",
"self",
",",
"survey_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/nps/surveys/{survey_id}/responses.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"survey_id",
"=",
"survey_id",
")",
"return",
"... | https://developer.zendesk.com/rest_api/docs/nps-api/responses#list-responses | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"nps",
"-",
"api",
"/",
"responses#list",
"-",
"responses"
] | python | train | 60.8 |
apache/airflow | airflow/contrib/hooks/qubole_hook.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/qubole_hook.py#L164-L190 | def get_results(self, ti=None, fp=None, inline=True, delim=None, fetch=True):
"""
Get results (or just s3 locations) of a command from Qubole and save into a file
:param ti: Task Instance of the dag, used to determine the Quboles command id
:param fp: Optional file pointer, will create o... | [
"def",
"get_results",
"(",
"self",
",",
"ti",
"=",
"None",
",",
"fp",
"=",
"None",
",",
"inline",
"=",
"True",
",",
"delim",
"=",
"None",
",",
"fetch",
"=",
"True",
")",
":",
"if",
"fp",
"is",
"None",
":",
"iso",
"=",
"datetime",
".",
"datetime",... | Get results (or just s3 locations) of a command from Qubole and save into a file
:param ti: Task Instance of the dag, used to determine the Quboles command id
:param fp: Optional file pointer, will create one and return if None passed
:param inline: True to download actual results, False to get ... | [
"Get",
"results",
"(",
"or",
"just",
"s3",
"locations",
")",
"of",
"a",
"command",
"from",
"Qubole",
"and",
"save",
"into",
"a",
"file",
":",
"param",
"ti",
":",
"Task",
"Instance",
"of",
"the",
"dag",
"used",
"to",
"determine",
"the",
"Quboles",
"comm... | python | test | 49.185185 |
PSU-OIT-ARC/django-local-settings | local_settings/settings.py | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/settings.py#L137-L249 | def _parse_path(self, path):
"""Parse ``path`` into segments.
Paths must start with a WORD (i.e., a top level Django setting
name). Path segments are separated by dots. Compound path
segments (i.e., a name with a dot in it) can be grouped inside
parentheses.
Examples::
... | [
"def",
"_parse_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"'path cannot be empty'",
")",
"segments",
"=",
"[",
"]",
"path_iter",
"=",
"zip",
"(",
"iter",
"(",
"path",
")",
",",
"chain",
"(",
"path",... | Parse ``path`` into segments.
Paths must start with a WORD (i.e., a top level Django setting
name). Path segments are separated by dots. Compound path
segments (i.e., a name with a dot in it) can be grouped inside
parentheses.
Examples::
>>> settings = Settings()
... | [
"Parse",
"path",
"into",
"segments",
"."
] | python | train | 35.433628 |
Scoppio/RagnarokEngine3 | Tutorials/Platforming Block - PyGame Release/Game/Code/Ragnarok.py | https://github.com/Scoppio/RagnarokEngine3/blob/4395d419ccd64fe9327c41f200b72ee0176ad896/Tutorials/Platforming Block - PyGame Release/Game/Code/Ragnarok.py#L1974-L1990 | def is_colliding(self, other):
"""Check to see if two circles are colliding."""
if isinstance(other, BoundingCircle):
#Calculate the distance between two circles.
distance = Vector2.distance(self.coords, other.coords)
#Check to see if the sum of thier radi are greate... | [
"def",
"is_colliding",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"BoundingCircle",
")",
":",
"#Calculate the distance between two circles.",
"distance",
"=",
"Vector2",
".",
"distance",
"(",
"self",
".",
"coords",
",",
"other",
... | Check to see if two circles are colliding. | [
"Check",
"to",
"see",
"if",
"two",
"circles",
"are",
"colliding",
"."
] | python | train | 41.705882 |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/server_selectors.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/server_selectors.py#L132-L146 | def apply_tag_sets(tag_sets, selection):
"""All servers match a list of tag sets.
tag_sets is a list of dicts. The empty tag set {} matches any server,
and may be provided at the end of the list as a fallback. So
[{'a': 'value'}, {}] expresses a preference for servers tagged
{'a': 'value'}, but acc... | [
"def",
"apply_tag_sets",
"(",
"tag_sets",
",",
"selection",
")",
":",
"for",
"tag_set",
"in",
"tag_sets",
":",
"with_tag_set",
"=",
"apply_single_tag_set",
"(",
"tag_set",
",",
"selection",
")",
"if",
"with_tag_set",
":",
"return",
"with_tag_set",
"return",
"sel... | All servers match a list of tag sets.
tag_sets is a list of dicts. The empty tag set {} matches any server,
and may be provided at the end of the list as a fallback. So
[{'a': 'value'}, {}] expresses a preference for servers tagged
{'a': 'value'}, but accepts any server if none matches the first
pr... | [
"All",
"servers",
"match",
"a",
"list",
"of",
"tag",
"sets",
"."
] | python | train | 38.133333 |
SKA-ScienceDataProcessor/integration-prototype | sip/execution_control/configuration_db/sip_config_db/_config_db_redis.py | https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/_config_db_redis.py#L470-L491 | def remove_from_list(self, key: str, value, count: int = 0,
pipeline: bool = False):
"""Remove specified value(s) from the list stored at key.
Args:
key (str): Key where the list is stored.
value: value to remove
count (int): Number of entrie... | [
"def",
"remove_from_list",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
",",
"count",
":",
"int",
"=",
"0",
",",
"pipeline",
":",
"bool",
"=",
"False",
")",
":",
"if",
"pipeline",
":",
"if",
"redis",
".",
"__version__",
"==",
"'2.10.6'",
":",
... | Remove specified value(s) from the list stored at key.
Args:
key (str): Key where the list is stored.
value: value to remove
count (int): Number of entries to remove, default 0 == all
pipeline(bool): If True, start a transaction block. Default False. | [
"Remove",
"specified",
"value",
"(",
"s",
")",
"from",
"the",
"list",
"stored",
"at",
"key",
"."
] | python | train | 39.727273 |
gautammishra/lyft-rides-python-sdk | examples/utils.py | https://github.com/gautammishra/lyft-rides-python-sdk/blob/b6d96a0fceaf7dc3425153c418a8e25c57803431/examples/utils.py#L113-L140 | def import_oauth2_credentials(filename=STORAGE_FILENAME):
"""Import OAuth 2.0 session credentials from storage file.
Parameters
filename (str)
Name of storage file.
Returns
credentials (dict)
All your app credentials and information
imported from the confi... | [
"def",
"import_oauth2_credentials",
"(",
"filename",
"=",
"STORAGE_FILENAME",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"storage_file",
":",
"storage",
"=",
"safe_load",
"(",
"storage_file",
")",
"# depending on OAuth 2.0 grant_type, these valu... | Import OAuth 2.0 session credentials from storage file.
Parameters
filename (str)
Name of storage file.
Returns
credentials (dict)
All your app credentials and information
imported from the configuration file. | [
"Import",
"OAuth",
"2",
".",
"0",
"session",
"credentials",
"from",
"storage",
"file",
".",
"Parameters",
"filename",
"(",
"str",
")",
"Name",
"of",
"storage",
"file",
".",
"Returns",
"credentials",
"(",
"dict",
")",
"All",
"your",
"app",
"credentials",
"a... | python | train | 33.428571 |
alex-kostirin/pyatomac | atomac/ldtpd/text.py | https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/text.py#L47-L62 | def keypress(self, data):
"""
Press key. NOTE: keyrelease should be called
@param data: data to type.
@type data: string
@return: 1 on success.
@rtype: integer
"""
try:
window = self._get_front_most_window()
except (IndexError,):
... | [
"def",
"keypress",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"window",
"=",
"self",
".",
"_get_front_most_window",
"(",
")",
"except",
"(",
"IndexError",
",",
")",
":",
"window",
"=",
"self",
".",
"_get_any_window",
"(",
")",
"key_press_action",
"=... | Press key. NOTE: keyrelease should be called
@param data: data to type.
@type data: string
@return: 1 on success.
@rtype: integer | [
"Press",
"key",
".",
"NOTE",
":",
"keyrelease",
"should",
"be",
"called"
] | python | valid | 26.0625 |
brocade/pynos | pynos/versions/base/yang/brocade_lag.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_lag.py#L12-L23 | def get_port_channel_detail_input_last_aggregator_id(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_port_channel_detail = ET.Element("get_port_channel_detail")
config = get_port_channel_detail
input = ET.SubElement(get_port_channel_detail, "... | [
"def",
"get_port_channel_detail_input_last_aggregator_id",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_port_channel_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_port_channel_detail\"",
")",
"... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 45.5 |
tango-controls/pytango | tango/databaseds/database.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/databaseds/database.py#L339-L351 | def DbGetAttributeAliasList(self, argin):
""" Get attribute alias list for a specified filter
:param argin: attribute alias filter string (eg: att*)
:type: tango.DevString
:return: attribute aliases
:rtype: tango.DevVarStringArray """
self._log.debug("In DbGetAttributeAl... | [
"def",
"DbGetAttributeAliasList",
"(",
"self",
",",
"argin",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"In DbGetAttributeAliasList()\"",
")",
"if",
"not",
"argin",
":",
"argin",
"=",
"\"%\"",
"else",
":",
"argin",
"=",
"replace_wildcard",
"(",
"arg... | Get attribute alias list for a specified filter
:param argin: attribute alias filter string (eg: att*)
:type: tango.DevString
:return: attribute aliases
:rtype: tango.DevVarStringArray | [
"Get",
"attribute",
"alias",
"list",
"for",
"a",
"specified",
"filter"
] | python | train | 36.769231 |
fredrike/pypoint | pypoint/__init__.py | https://github.com/fredrike/pypoint/blob/b5c9a701d2b7e24d796aa7f8c410360b61d8ec8a/pypoint/__init__.py#L149-L161 | def update_webhook(self, webhook_url, webhook_id, events=None):
"""Register webhook (if it doesn't exit)."""
hooks = self._request(MINUT_WEBHOOKS_URL, request_type='GET')['hooks']
try:
self._webhook = next(
hook for hook in hooks if hook['url'] == webhook_url)
... | [
"def",
"update_webhook",
"(",
"self",
",",
"webhook_url",
",",
"webhook_id",
",",
"events",
"=",
"None",
")",
":",
"hooks",
"=",
"self",
".",
"_request",
"(",
"MINUT_WEBHOOKS_URL",
",",
"request_type",
"=",
"'GET'",
")",
"[",
"'hooks'",
"]",
"try",
":",
... | Register webhook (if it doesn't exit). | [
"Register",
"webhook",
"(",
"if",
"it",
"doesn",
"t",
"exit",
")",
"."
] | python | train | 51.461538 |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/deploy_vm.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/deploy_vm.py#L21-L36 | def execute_deploy_from_linked_clone(self, si, logger, vcenter_data_model, reservation_id, deployment_params, cancellation_context, folder_manager):
"""
Calls the deployer to deploy vm from snapshot
:param cancellation_context:
:param str reservation_id:
:param si:
:param... | [
"def",
"execute_deploy_from_linked_clone",
"(",
"self",
",",
"si",
",",
"logger",
",",
"vcenter_data_model",
",",
"reservation_id",
",",
"deployment_params",
",",
"cancellation_context",
",",
"folder_manager",
")",
":",
"self",
".",
"_prepare_deployed_apps_folder",
"(",... | Calls the deployer to deploy vm from snapshot
:param cancellation_context:
:param str reservation_id:
:param si:
:param logger:
:type deployment_params: DeployFromLinkedClone
:param vcenter_data_model:
:return: | [
"Calls",
"the",
"deployer",
"to",
"deploy",
"vm",
"from",
"snapshot",
":",
"param",
"cancellation_context",
":",
":",
"param",
"str",
"reservation_id",
":",
":",
"param",
"si",
":",
":",
"param",
"logger",
":",
":",
"type",
"deployment_params",
":",
"DeployF... | python | train | 49.1875 |
aws/sagemaker-python-sdk | src/sagemaker/session.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/session.py#L213-L317 | def train(self, input_mode, input_config, role, job_name, output_config, # noqa: C901
resource_config, vpc_config, hyperparameters, stop_condition, tags, metric_definitions,
enable_network_isolation=False, image=None, algorithm_arn=None,
encrypt_inter_container_traffic=False):... | [
"def",
"train",
"(",
"self",
",",
"input_mode",
",",
"input_config",
",",
"role",
",",
"job_name",
",",
"output_config",
",",
"# noqa: C901",
"resource_config",
",",
"vpc_config",
",",
"hyperparameters",
",",
"stop_condition",
",",
"tags",
",",
"metric_definitions... | Create an Amazon SageMaker training job.
Args:
input_mode (str): The input mode that the algorithm supports. Valid modes:
* 'File' - Amazon SageMaker copies the training dataset from the S3 location to
a directory in the Docker container.
* 'Pipe... | [
"Create",
"an",
"Amazon",
"SageMaker",
"training",
"job",
"."
] | python | train | 53.533333 |
SALib/SALib | src/SALib/sample/sobol_sequence.py | https://github.com/SALib/SALib/blob/9744d73bb17cfcffc8282c7dc4a727efdc4bea3f/src/SALib/sample/sobol_sequence.py#L51-L93 | def sample(N, D):
"""Generate (N x D) numpy array of Sobol sequence samples"""
scale = 31
result = np.zeros([N, D])
if D > len(directions) + 1:
raise ValueError("Error in Sobol sequence: not enough dimensions")
L = int(math.ceil(math.log(N) / math.log(2)))
if L > scale:
... | [
"def",
"sample",
"(",
"N",
",",
"D",
")",
":",
"scale",
"=",
"31",
"result",
"=",
"np",
".",
"zeros",
"(",
"[",
"N",
",",
"D",
"]",
")",
"if",
"D",
">",
"len",
"(",
"directions",
")",
"+",
"1",
":",
"raise",
"ValueError",
"(",
"\"Error in Sobol... | Generate (N x D) numpy array of Sobol sequence samples | [
"Generate",
"(",
"N",
"x",
"D",
")",
"numpy",
"array",
"of",
"Sobol",
"sequence",
"samples"
] | python | train | 33.581395 |
draperjames/qtpandas | qtpandas/views/DataTableView.py | https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/views/DataTableView.py#L331-L347 | def setViewModel(self, model):
"""Sets the model for the enclosed TableView in this widget.
Args:
model (DataFrameModel): The model to be displayed by
the Table View.
"""
if isinstance(model, DataFrameModel):
self.enableEditing(False)
... | [
"def",
"setViewModel",
"(",
"self",
",",
"model",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"DataFrameModel",
")",
":",
"self",
".",
"enableEditing",
"(",
"False",
")",
"self",
".",
"uncheckButton",
"(",
")",
"selectionModel",
"=",
"self",
".",
"t... | Sets the model for the enclosed TableView in this widget.
Args:
model (DataFrameModel): The model to be displayed by
the Table View. | [
"Sets",
"the",
"model",
"for",
"the",
"enclosed",
"TableView",
"in",
"this",
"widget",
"."
] | python | train | 34.882353 |
square/connect-python-sdk | squareconnect/models/create_checkout_request.py | https://github.com/square/connect-python-sdk/blob/adc1d09e817986cdc607391580f71d6b48ed4066/squareconnect/models/create_checkout_request.py#L189-L203 | def pre_populate_buyer_email(self, pre_populate_buyer_email):
"""
Sets the pre_populate_buyer_email of this CreateCheckoutRequest.
If provided, the buyer's email is pre-populated on the checkout page as an editable text field. Default: none; only exists if explicitly set.
:param pre_po... | [
"def",
"pre_populate_buyer_email",
"(",
"self",
",",
"pre_populate_buyer_email",
")",
":",
"if",
"pre_populate_buyer_email",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid value for `pre_populate_buyer_email`, must not be `None`\"",
")",
"if",
"len",
"(",
"pre_po... | Sets the pre_populate_buyer_email of this CreateCheckoutRequest.
If provided, the buyer's email is pre-populated on the checkout page as an editable text field. Default: none; only exists if explicitly set.
:param pre_populate_buyer_email: The pre_populate_buyer_email of this CreateCheckoutRequest.
... | [
"Sets",
"the",
"pre_populate_buyer_email",
"of",
"this",
"CreateCheckoutRequest",
".",
"If",
"provided",
"the",
"buyer",
"s",
"email",
"is",
"pre",
"-",
"populated",
"on",
"the",
"checkout",
"page",
"as",
"an",
"editable",
"text",
"field",
".",
"Default",
":",... | python | train | 52.2 |
theonion/django-bulbs | bulbs/content/managers.py | https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/content/managers.py#L18-L31 | def evergreen(self, included_channel_ids=None, excluded_channel_ids=None, **kwargs):
"""
Search containing any evergreen piece of Content.
:included_channel_ids list: Contains ids for channel ids relevant to the query.
:excluded_channel_ids list: Contains ids for channel ids excluded fr... | [
"def",
"evergreen",
"(",
"self",
",",
"included_channel_ids",
"=",
"None",
",",
"excluded_channel_ids",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"eqs",
"=",
"self",
".",
"search",
"(",
"*",
"*",
"kwargs",
")",
"eqs",
"=",
"eqs",
".",
"filter",
... | Search containing any evergreen piece of Content.
:included_channel_ids list: Contains ids for channel ids relevant to the query.
:excluded_channel_ids list: Contains ids for channel ids excluded from the query. | [
"Search",
"containing",
"any",
"evergreen",
"piece",
"of",
"Content",
"."
] | python | train | 46.642857 |
rackerlabs/timid | timid/environment.py | https://github.com/rackerlabs/timid/blob/b1c6aa159ab380a033740f4aa392cf0d125e0ac6/timid/environment.py#L427-L448 | def call(self, args, **kwargs):
"""
A thin wrapper around ``subprocess.Popen``. Takes the same
options as ``subprocess.Popen``, with the exception of the
``cwd``, and ``env`` parameters, which come from the
``Environment`` instance. Note that if the sole positional
argu... | [
"def",
"call",
"(",
"self",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Convert string args into a sequence",
"if",
"isinstance",
"(",
"args",
",",
"six",
".",
"string_types",
")",
":",
"args",
"=",
"shlex",
".",
"split",
"(",
"args",
")",
"# Subs... | A thin wrapper around ``subprocess.Popen``. Takes the same
options as ``subprocess.Popen``, with the exception of the
``cwd``, and ``env`` parameters, which come from the
``Environment`` instance. Note that if the sole positional
argument is a string, it will be converted into a sequen... | [
"A",
"thin",
"wrapper",
"around",
"subprocess",
".",
"Popen",
".",
"Takes",
"the",
"same",
"options",
"as",
"subprocess",
".",
"Popen",
"with",
"the",
"exception",
"of",
"the",
"cwd",
"and",
"env",
"parameters",
"which",
"come",
"from",
"the",
"Environment",... | python | test | 35.363636 |
asmodehn/filefinder2 | filefinder2/_fileloader2.py | https://github.com/asmodehn/filefinder2/blob/3f0b211ce11a34562e2a2160e039ae5290b68d6b/filefinder2/_fileloader2.py#L326-L336 | def get_source(self, name):
"""Concrete implementation of InspectLoader.get_source."""
path = self.get_filename(name)
try:
source_bytes = self.get_data(path)
except OSError as exc:
e = _ImportError('source not available through get_data()',
... | [
"def",
"get_source",
"(",
"self",
",",
"name",
")",
":",
"path",
"=",
"self",
".",
"get_filename",
"(",
"name",
")",
"try",
":",
"source_bytes",
"=",
"self",
".",
"get_data",
"(",
"path",
")",
"except",
"OSError",
"as",
"exc",
":",
"e",
"=",
"_Import... | Concrete implementation of InspectLoader.get_source. | [
"Concrete",
"implementation",
"of",
"InspectLoader",
".",
"get_source",
"."
] | python | train | 38.090909 |
palantir/typedjsonrpc | typedjsonrpc/parameter_checker.py | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/parameter_checker.py#L58-L73 | def check_types(parameters, parameter_types, strict_floats):
"""Checks that the given parameters have the correct types.
:param parameters: List of (name, value) pairs of the given parameters
:type parameters: dict[str, object]
:param parameter_types: Parameter type by name.
:type parameter_types: ... | [
"def",
"check_types",
"(",
"parameters",
",",
"parameter_types",
",",
"strict_floats",
")",
":",
"for",
"name",
",",
"parameter_type",
"in",
"parameter_types",
".",
"items",
"(",
")",
":",
"if",
"name",
"not",
"in",
"parameters",
":",
"raise",
"InvalidParamsEr... | Checks that the given parameters have the correct types.
:param parameters: List of (name, value) pairs of the given parameters
:type parameters: dict[str, object]
:param parameter_types: Parameter type by name.
:type parameter_types: dict[str, type]
:param strict_floats: If False, treat integers a... | [
"Checks",
"that",
"the",
"given",
"parameters",
"have",
"the",
"correct",
"types",
"."
] | python | train | 53.25 |
jantman/awslimitchecker | awslimitchecker/services/iam.py | https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/services/iam.py#L65-L76 | def find_usage(self):
"""
Determine the current usage for each limit of this service,
and update corresponding Limit via
:py:meth:`~.AwsLimit._add_current_usage`.
"""
logger.debug("Checking usage for service %s", self.service_name)
for lim in self.limits.values():... | [
"def",
"find_usage",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Checking usage for service %s\"",
",",
"self",
".",
"service_name",
")",
"for",
"lim",
"in",
"self",
".",
"limits",
".",
"values",
"(",
")",
":",
"lim",
".",
"_reset_usage",
"(",
... | Determine the current usage for each limit of this service,
and update corresponding Limit via
:py:meth:`~.AwsLimit._add_current_usage`. | [
"Determine",
"the",
"current",
"usage",
"for",
"each",
"limit",
"of",
"this",
"service",
"and",
"update",
"corresponding",
"Limit",
"via",
":",
"py",
":",
"meth",
":",
"~",
".",
"AwsLimit",
".",
"_add_current_usage",
"."
] | python | train | 38 |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L4683-L4692 | def validateDocumentFinal(self, ctxt):
"""Does the final step for the document validation once all
the incremental validation steps have been completed
basically it does the following checks described by the XML
Rec Check all the IDREF/IDREFS attributes definition for
v... | [
"def",
"validateDocumentFinal",
"(",
"self",
",",
"ctxt",
")",
":",
"if",
"ctxt",
"is",
"None",
":",
"ctxt__o",
"=",
"None",
"else",
":",
"ctxt__o",
"=",
"ctxt",
".",
"_o",
"ret",
"=",
"libxml2mod",
".",
"xmlValidateDocumentFinal",
"(",
"ctxt__o",
",",
"... | Does the final step for the document validation once all
the incremental validation steps have been completed
basically it does the following checks described by the XML
Rec Check all the IDREF/IDREFS attributes definition for
validity | [
"Does",
"the",
"final",
"step",
"for",
"the",
"document",
"validation",
"once",
"all",
"the",
"incremental",
"validation",
"steps",
"have",
"been",
"completed",
"basically",
"it",
"does",
"the",
"following",
"checks",
"described",
"by",
"the",
"XML",
"Rec",
"C... | python | train | 48.1 |
ktbyers/netmiko | netmiko/scp_handler.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_handler.py#L155-L163 | def verify_space_available(self, search_pattern=r"(\d+) \w+ free"):
"""Verify sufficient space is available on destination file system (return boolean)."""
if self.direction == "put":
space_avail = self.remote_space_available(search_pattern=search_pattern)
elif self.direction == "get... | [
"def",
"verify_space_available",
"(",
"self",
",",
"search_pattern",
"=",
"r\"(\\d+) \\w+ free\"",
")",
":",
"if",
"self",
".",
"direction",
"==",
"\"put\"",
":",
"space_avail",
"=",
"self",
".",
"remote_space_available",
"(",
"search_pattern",
"=",
"search_pattern"... | Verify sufficient space is available on destination file system (return boolean). | [
"Verify",
"sufficient",
"space",
"is",
"available",
"on",
"destination",
"file",
"system",
"(",
"return",
"boolean",
")",
"."
] | python | train | 50.555556 |
dcwatson/bbcode | bbcode.py | https://github.com/dcwatson/bbcode/blob/eb6f7ff140a78ddb1641102d7382479c4d7c1c78/bbcode.py#L372-L426 | def tokenize(self, data):
"""
Tokenizes the given string. A token is a 4-tuple of the form:
(token_type, tag_name, tag_options, token_text)
token_type
One of: TOKEN_TAG_START, TOKEN_TAG_END, TOKEN_NEWLINE, TOKEN_DATA
tag_name
The name... | [
"def",
"tokenize",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"data",
".",
"replace",
"(",
"'\\r\\n'",
",",
"'\\n'",
")",
".",
"replace",
"(",
"'\\r'",
",",
"'\\n'",
")",
"pos",
"=",
"start",
"=",
"end",
"=",
"0",
"ld",
"=",
"len",
"(",
"... | Tokenizes the given string. A token is a 4-tuple of the form:
(token_type, tag_name, tag_options, token_text)
token_type
One of: TOKEN_TAG_START, TOKEN_TAG_END, TOKEN_NEWLINE, TOKEN_DATA
tag_name
The name of the tag if token_type=TOKEN_TAG_*, otherwi... | [
"Tokenizes",
"the",
"given",
"string",
".",
"A",
"token",
"is",
"a",
"4",
"-",
"tuple",
"of",
"the",
"form",
":"
] | python | train | 44.109091 |
PMEAL/OpenPNM | openpnm/core/Base.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/core/Base.py#L1008-L1112 | def interleave_data(self, prop):
r"""
Retrieves requested property from associated objects, to produce a full
Np or Nt length array.
Parameters
----------
prop : string
The property name to be retrieved
Returns
-------
A full length (... | [
"def",
"interleave_data",
"(",
"self",
",",
"prop",
")",
":",
"element",
"=",
"self",
".",
"_parse_element",
"(",
"prop",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
",",
"single",
"=",
"True",
")",
"N",
"=",
"self",
".",
"project",
".",
"network... | r"""
Retrieves requested property from associated objects, to produce a full
Np or Nt length array.
Parameters
----------
prop : string
The property name to be retrieved
Returns
-------
A full length (Np or Nt) array of requested property val... | [
"r",
"Retrieves",
"requested",
"property",
"from",
"associated",
"objects",
"to",
"produce",
"a",
"full",
"Np",
"or",
"Nt",
"length",
"array",
"."
] | python | train | 39.438095 |
saltstack/salt | salt/utils/network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1102-L1115 | def _get_iface_info(iface):
'''
If `iface` is available, return interface info and no error, otherwise
return no info and log and return an error
'''
iface_info = interfaces()
if iface in iface_info.keys():
return iface_info, False
else:
error_msg = ('Interface "{0}" not in ... | [
"def",
"_get_iface_info",
"(",
"iface",
")",
":",
"iface_info",
"=",
"interfaces",
"(",
")",
"if",
"iface",
"in",
"iface_info",
".",
"keys",
"(",
")",
":",
"return",
"iface_info",
",",
"False",
"else",
":",
"error_msg",
"=",
"(",
"'Interface \"{0}\" not in a... | If `iface` is available, return interface info and no error, otherwise
return no info and log and return an error | [
"If",
"iface",
"is",
"available",
"return",
"interface",
"info",
"and",
"no",
"error",
"otherwise",
"return",
"no",
"info",
"and",
"log",
"and",
"return",
"an",
"error"
] | python | train | 33.285714 |
picklepete/pyicloud | pyicloud/services/findmyiphone.py | https://github.com/picklepete/pyicloud/blob/9bb6d750662ce24c8febc94807ddbdcdf3cadaa2/pyicloud/services/findmyiphone.py#L169-L193 | def lost_device(
self, number,
text='This iPhone has been lost. Please call me.',
newpasscode=""
):
""" Send a request to the device to trigger 'lost mode'.
The device will show the message in `text`, and if a number has
been passed, then the person holding the devic... | [
"def",
"lost_device",
"(",
"self",
",",
"number",
",",
"text",
"=",
"'This iPhone has been lost. Please call me.'",
",",
"newpasscode",
"=",
"\"\"",
")",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"{",
"'text'",
":",
"text",
",",
"'userText'",
":",
"True",... | Send a request to the device to trigger 'lost mode'.
The device will show the message in `text`, and if a number has
been passed, then the person holding the device can call
the number without entering the passcode. | [
"Send",
"a",
"request",
"to",
"the",
"device",
"to",
"trigger",
"lost",
"mode",
"."
] | python | train | 30.6 |
heigeo/climata | climata/acis/__init__.py | https://github.com/heigeo/climata/blob/2028bdbd40e1c8985b0b62f7cb969ce7dfa8f1bd/climata/acis/__init__.py#L147-L158 | def get_field_names(self):
"""
ACIS web service returns "meta" and "data" for each station;
Use meta attributes as field names
"""
field_names = super(StationDataIO, self).get_field_names()
if set(field_names) == set(['meta', 'data']):
meta_fields = list(self.... | [
"def",
"get_field_names",
"(",
"self",
")",
":",
"field_names",
"=",
"super",
"(",
"StationDataIO",
",",
"self",
")",
".",
"get_field_names",
"(",
")",
"if",
"set",
"(",
"field_names",
")",
"==",
"set",
"(",
"[",
"'meta'",
",",
"'data'",
"]",
")",
":",... | ACIS web service returns "meta" and "data" for each station;
Use meta attributes as field names | [
"ACIS",
"web",
"service",
"returns",
"meta",
"and",
"data",
"for",
"each",
"station",
";",
"Use",
"meta",
"attributes",
"as",
"field",
"names"
] | python | train | 44 |
calmjs/calmjs | src/calmjs/base.py | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L379-L389 | def resolve_parent_registry_name(self, registry_name, suffix):
"""
Subclasses should override to specify the default suffix, as the
invocation is done without a suffix.
"""
if not registry_name.endswith(suffix):
raise ValueError(
"child module registr... | [
"def",
"resolve_parent_registry_name",
"(",
"self",
",",
"registry_name",
",",
"suffix",
")",
":",
"if",
"not",
"registry_name",
".",
"endswith",
"(",
"suffix",
")",
":",
"raise",
"ValueError",
"(",
"\"child module registry name defined with invalid suffix \"",
"\"('%s'... | Subclasses should override to specify the default suffix, as the
invocation is done without a suffix. | [
"Subclasses",
"should",
"override",
"to",
"specify",
"the",
"default",
"suffix",
"as",
"the",
"invocation",
"is",
"done",
"without",
"a",
"suffix",
"."
] | python | train | 42.272727 |
aetros/aetros-cli | aetros/utils/image.py | https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/utils/image.py#L40-L57 | def upscale(image, ratio):
"""
return upscaled image array
Arguments:
image -- a (H,W,C) numpy.ndarray
ratio -- scaling factor (>1)
"""
if not isinstance(image, np.ndarray):
raise ValueError('Expected ndarray')
if ratio < 1:
raise ValueError('Ratio must be greater than 1 ... | [
"def",
"upscale",
"(",
"image",
",",
"ratio",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"'Expected ndarray'",
")",
"if",
"ratio",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'Rat... | return upscaled image array
Arguments:
image -- a (H,W,C) numpy.ndarray
ratio -- scaling factor (>1) | [
"return",
"upscaled",
"image",
"array",
"Arguments",
":",
"image",
"--",
"a",
"(",
"H",
"W",
"C",
")",
"numpy",
".",
"ndarray",
"ratio",
"--",
"scaling",
"factor",
"(",
">",
"1",
")"
] | python | train | 36.888889 |
goose3/goose3 | goose3/__init__.py | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/__init__.py#L123-L140 | def __crawl(self, crawl_candidate):
''' wrap the crawling functionality '''
def crawler_wrapper(parser, parsers_lst, crawl_candidate):
try:
crawler = Crawler(self.config, self.fetcher)
article = crawler.crawl(crawl_candidate)
except (UnicodeDecodeE... | [
"def",
"__crawl",
"(",
"self",
",",
"crawl_candidate",
")",
":",
"def",
"crawler_wrapper",
"(",
"parser",
",",
"parsers_lst",
",",
"crawl_candidate",
")",
":",
"try",
":",
"crawler",
"=",
"Crawler",
"(",
"self",
".",
"config",
",",
"self",
".",
"fetcher",
... | wrap the crawling functionality | [
"wrap",
"the",
"crawling",
"functionality"
] | python | valid | 44.333333 |
KelSolaar/Umbra | umbra/ui/highlighters.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/highlighters.py#L293-L303 | def highlightBlock(self, block):
"""
Reimplements the :meth:`QSyntaxHighlighter.highlightBlock` method.
:param block: Text block.
:type block: QString
"""
raise NotImplementedError("{0} | '{1}' must be implemented by '{2}' subclasses!".format(self.__class__.__name__,
... | [
"def",
"highlightBlock",
"(",
"self",
",",
"block",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"{0} | '{1}' must be implemented by '{2}' subclasses!\"",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"highlightBlock",
".",
"__... | Reimplements the :meth:`QSyntaxHighlighter.highlightBlock` method.
:param block: Text block.
:type block: QString | [
"Reimplements",
"the",
":",
"meth",
":",
"QSyntaxHighlighter",
".",
"highlightBlock",
"method",
"."
] | python | train | 50.454545 |
peterpakos/ppipa | ppipa/freeipaserver.py | https://github.com/peterpakos/ppipa/blob/cc7565fe9afa079437cccfaf8d6b8c3da3f080ee/ppipa/freeipaserver.py#L113-L116 | def _set_hostname_domain(self):
"""Extract hostname and domain"""
self._hostname, _, self._domain = str(self._fqdn).partition('.')
log.debug('Hostname: %s, Domain: %s' % (self._hostname, self._domain)) | [
"def",
"_set_hostname_domain",
"(",
"self",
")",
":",
"self",
".",
"_hostname",
",",
"_",
",",
"self",
".",
"_domain",
"=",
"str",
"(",
"self",
".",
"_fqdn",
")",
".",
"partition",
"(",
"'.'",
")",
"log",
".",
"debug",
"(",
"'Hostname: %s, Domain: %s'",
... | Extract hostname and domain | [
"Extract",
"hostname",
"and",
"domain"
] | python | train | 55.5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.