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 |
|---|---|---|---|---|---|---|---|---|---|
pysathq/pysat | examples/lsu.py | https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/examples/lsu.py#L358-L368 | def parse_formula(fml_file):
"""
Parse and return MaxSAT formula.
"""
if re.search('\.wcnf(\.(gz|bz2|lzma|xz))?$', fml_file):
fml = WCNF(from_file=fml_file)
else: # expecting '*.cnf'
fml = CNF(from_file=fml_file).weighted()
return fml | [
"def",
"parse_formula",
"(",
"fml_file",
")",
":",
"if",
"re",
".",
"search",
"(",
"'\\.wcnf(\\.(gz|bz2|lzma|xz))?$'",
",",
"fml_file",
")",
":",
"fml",
"=",
"WCNF",
"(",
"from_file",
"=",
"fml_file",
")",
"else",
":",
"# expecting '*.cnf'",
"fml",
"=",
"CNF... | Parse and return MaxSAT formula. | [
"Parse",
"and",
"return",
"MaxSAT",
"formula",
"."
] | python | train | 24.636364 |
angr/angr | angr/simos/javavm.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/simos/javavm.py#L265-L297 | def get_default_value_by_type(type_, state=None):
"""
Java specify defaults values for primitive and reference types. This
method returns the default value for a given type.
:param str type_: Name of type.
:return: Default value for this type.
"""
if... | [
"def",
"get_default_value_by_type",
"(",
"type_",
",",
"state",
"=",
"None",
")",
":",
"if",
"type_",
"in",
"[",
"'byte'",
",",
"'char'",
",",
"'short'",
",",
"'int'",
",",
"'boolean'",
"]",
":",
"return",
"BVS",
"(",
"'default_value_{}'",
".",
"format",
... | Java specify defaults values for primitive and reference types. This
method returns the default value for a given type.
:param str type_: Name of type.
:return: Default value for this type. | [
"Java",
"specify",
"defaults",
"values",
"for",
"primitive",
"and",
"reference",
"types",
".",
"This",
"method",
"returns",
"the",
"default",
"value",
"for",
"a",
"given",
"type",
"."
] | python | train | 49.909091 |
gwpy/gwpy | gwpy/table/io/hacr.py | https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/table/io/hacr.py#L75-L88 | def get_hacr_channels(db=None, gps=None, connection=None,
**conectkwargs):
"""Return the names of all channels present in the given HACR database
"""
# connect if needed
if connection is None:
if gps is None:
gps = from_gps('now')
if db is None:
... | [
"def",
"get_hacr_channels",
"(",
"db",
"=",
"None",
",",
"gps",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"*",
"*",
"conectkwargs",
")",
":",
"# connect if needed",
"if",
"connection",
"is",
"None",
":",
"if",
"gps",
"is",
"None",
":",
"gps",
"... | Return the names of all channels present in the given HACR database | [
"Return",
"the",
"names",
"of",
"all",
"channels",
"present",
"in",
"the",
"given",
"HACR",
"database"
] | python | train | 36.642857 |
nugget/python-insteonplm | insteonplm/messages/userdata.py | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/userdata.py#L53-L63 | def human(self):
"""Emit the address in human-readible format (AA.BB.CC)."""
strout = ''
first = True
for i in range(0, 28, 2):
if first:
first = False
else:
strout = strout + '.'
strout = strout + self.hex[i:i + 2]
... | [
"def",
"human",
"(",
"self",
")",
":",
"strout",
"=",
"''",
"first",
"=",
"True",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"28",
",",
"2",
")",
":",
"if",
"first",
":",
"first",
"=",
"False",
"else",
":",
"strout",
"=",
"strout",
"+",
"'.'",
... | Emit the address in human-readible format (AA.BB.CC). | [
"Emit",
"the",
"address",
"in",
"human",
"-",
"readible",
"format",
"(",
"AA",
".",
"BB",
".",
"CC",
")",
"."
] | python | train | 29.727273 |
watchforstock/evohome-client | evohomeclient/__init__.py | https://github.com/watchforstock/evohome-client/blob/f1cb9273e97946d79c0651f00a218abbf7ada53a/evohomeclient/__init__.py#L266-L275 | def set_temperature(self, zone, temperature, until=None):
"""Sets the temperature of the given zone."""
if until is None:
data = {"Value": temperature, "Status": "Hold", "NextTime": None}
else:
data = {"Value": temperature,
"Status": "Temporary",
... | [
"def",
"set_temperature",
"(",
"self",
",",
"zone",
",",
"temperature",
",",
"until",
"=",
"None",
")",
":",
"if",
"until",
"is",
"None",
":",
"data",
"=",
"{",
"\"Value\"",
":",
"temperature",
",",
"\"Status\"",
":",
"\"Hold\"",
",",
"\"NextTime\"",
":"... | Sets the temperature of the given zone. | [
"Sets",
"the",
"temperature",
"of",
"the",
"given",
"zone",
"."
] | python | train | 42 |
LuminosoInsight/ordered-set | ordered_set.py | https://github.com/LuminosoInsight/ordered-set/blob/a29eaedcedfe5072bcee11bdef61dea321d5e9f9/ordered_set.py#L209-L226 | def pop(self):
"""
Remove and return the last element from the set.
Raises KeyError if the set is empty.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.pop()
3
"""
if not self.items:
raise KeyError("Set is empty")
... | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"items",
":",
"raise",
"KeyError",
"(",
"\"Set is empty\"",
")",
"elem",
"=",
"self",
".",
"items",
"[",
"-",
"1",
"]",
"del",
"self",
".",
"items",
"[",
"-",
"1",
"]",
"del",
"self",... | Remove and return the last element from the set.
Raises KeyError if the set is empty.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset.pop()
3 | [
"Remove",
"and",
"return",
"the",
"last",
"element",
"from",
"the",
"set",
"."
] | python | train | 22.388889 |
ziwenxie/netease-dl | netease/logger.py | https://github.com/ziwenxie/netease-dl/blob/84b226fc07b10f7f66580f0fc69f10356f66b5c3/netease/logger.py#L24-L38 | def get_logger(name):
"""Return a logger with a file handler."""
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
# File output handler
file_handler = logging.FileHandler(log_path)
file_handler.setLevel(logging.INFO)
formatter = logging.Formatter(
'%(asctime)s %(name)1... | [
"def",
"get_logger",
"(",
"name",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"INFO",
")",
"# File output handler",
"file_handler",
"=",
"logging",
".",
"FileHandler",
"(",
"log_path... | Return a logger with a file handler. | [
"Return",
"a",
"logger",
"with",
"a",
"file",
"handler",
"."
] | python | train | 32.266667 |
spacetelescope/drizzlepac | drizzlepac/wcs_functions.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/wcs_functions.py#L806-L858 | def fitlin(imgarr,refarr):
""" Compute the least-squares fit between two arrays.
A Python translation of 'FITLIN' from 'drutil.f' (Drizzle V2.9).
"""
# Initialize variables
_mat = np.zeros((3,3),dtype=np.float64)
_xorg = imgarr[0][0]
_yorg = imgarr[0][1]
_xoorg = refarr[0][0]
_yo... | [
"def",
"fitlin",
"(",
"imgarr",
",",
"refarr",
")",
":",
"# Initialize variables",
"_mat",
"=",
"np",
".",
"zeros",
"(",
"(",
"3",
",",
"3",
")",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"_xorg",
"=",
"imgarr",
"[",
"0",
"]",
"[",
"0",
"]",
... | Compute the least-squares fit between two arrays.
A Python translation of 'FITLIN' from 'drutil.f' (Drizzle V2.9). | [
"Compute",
"the",
"least",
"-",
"squares",
"fit",
"between",
"two",
"arrays",
".",
"A",
"Python",
"translation",
"of",
"FITLIN",
"from",
"drutil",
".",
"f",
"(",
"Drizzle",
"V2",
".",
"9",
")",
"."
] | python | train | 33.207547 |
mdgoldberg/sportsref | sportsref/nfl/boxscores.py | https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nfl/boxscores.py#L370-L378 | def ref_info(self):
"""Gets a dictionary of ref positions and the ref IDs of the refs for
that game.
:returns: A dictionary of ref positions and IDs.
"""
doc = self.get_doc()
table = doc('table#officials')
return sportsref.utils.parse_info_table(table) | [
"def",
"ref_info",
"(",
"self",
")",
":",
"doc",
"=",
"self",
".",
"get_doc",
"(",
")",
"table",
"=",
"doc",
"(",
"'table#officials'",
")",
"return",
"sportsref",
".",
"utils",
".",
"parse_info_table",
"(",
"table",
")"
] | Gets a dictionary of ref positions and the ref IDs of the refs for
that game.
:returns: A dictionary of ref positions and IDs. | [
"Gets",
"a",
"dictionary",
"of",
"ref",
"positions",
"and",
"the",
"ref",
"IDs",
"of",
"the",
"refs",
"for",
"that",
"game",
"."
] | python | test | 33.444444 |
scour-project/scour | scour/scour.py | https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L1885-L1894 | def taint(taintedSet, taintedAttribute):
u"""Adds an attribute to a set of attributes.
Related attributes are also included."""
taintedSet.add(taintedAttribute)
if taintedAttribute == 'marker':
taintedSet |= set(['marker-start', 'marker-mid', 'marker-end'])
if taintedAttribute in ['marker-s... | [
"def",
"taint",
"(",
"taintedSet",
",",
"taintedAttribute",
")",
":",
"taintedSet",
".",
"add",
"(",
"taintedAttribute",
")",
"if",
"taintedAttribute",
"==",
"'marker'",
":",
"taintedSet",
"|=",
"set",
"(",
"[",
"'marker-start'",
",",
"'marker-mid'",
",",
"'ma... | u"""Adds an attribute to a set of attributes.
Related attributes are also included. | [
"u",
"Adds",
"an",
"attribute",
"to",
"a",
"set",
"of",
"attributes",
"."
] | python | train | 40.1 |
saltstack/salt | salt/modules/nfs3.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nfs3.py#L69-L82 | def del_export(exports='/etc/exports', path=None):
'''
Remove an export
CLI Example:
.. code-block:: bash
salt '*' nfs.del_export /media/storage
'''
edict = list_exports(exports)
del edict[path]
_write_exports(exports, edict)
return edict | [
"def",
"del_export",
"(",
"exports",
"=",
"'/etc/exports'",
",",
"path",
"=",
"None",
")",
":",
"edict",
"=",
"list_exports",
"(",
"exports",
")",
"del",
"edict",
"[",
"path",
"]",
"_write_exports",
"(",
"exports",
",",
"edict",
")",
"return",
"edict"
] | Remove an export
CLI Example:
.. code-block:: bash
salt '*' nfs.del_export /media/storage | [
"Remove",
"an",
"export"
] | python | train | 19.428571 |
hotdoc/hotdoc | hotdoc/utils/loggable.py | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/utils/loggable.py#L213-L222 | def _log(code, message, level, domain):
"""Call this to add an entry in the journal"""
entry = LogEntry(level, domain, code, message)
Logger.journal.append(entry)
if Logger.silent:
return
if level >= Logger._verbosity:
_print_entry(entry) | [
"def",
"_log",
"(",
"code",
",",
"message",
",",
"level",
",",
"domain",
")",
":",
"entry",
"=",
"LogEntry",
"(",
"level",
",",
"domain",
",",
"code",
",",
"message",
")",
"Logger",
".",
"journal",
".",
"append",
"(",
"entry",
")",
"if",
"Logger",
... | Call this to add an entry in the journal | [
"Call",
"this",
"to",
"add",
"an",
"entry",
"in",
"the",
"journal"
] | python | train | 29.5 |
pasztorpisti/py-flags | src/flags.py | https://github.com/pasztorpisti/py-flags/blob/bc48adb5edd7340ea1a686622d7993b4bcf4bfc2/src/flags.py#L95-L112 | def process_inline_members_definition(members):
"""
:param members: this can be any of the following:
- a string containing a space and/or comma separated list of names: e.g.:
"item1 item2 item3" OR "item1,item2,item3" OR "item1, item2, item3"
- tuple/list/Set of strings (names)
- Mapping of (... | [
"def",
"process_inline_members_definition",
"(",
"members",
")",
":",
"if",
"isinstance",
"(",
"members",
",",
"str",
")",
":",
"members",
"=",
"(",
"(",
"name",
",",
"UNDEFINED",
")",
"for",
"name",
"in",
"members",
".",
"replace",
"(",
"','",
",",
"' '... | :param members: this can be any of the following:
- a string containing a space and/or comma separated list of names: e.g.:
"item1 item2 item3" OR "item1,item2,item3" OR "item1, item2, item3"
- tuple/list/Set of strings (names)
- Mapping of (name, data) pairs
- any kind of iterable that yields (na... | [
":",
"param",
"members",
":",
"this",
"can",
"be",
"any",
"of",
"the",
"following",
":",
"-",
"a",
"string",
"containing",
"a",
"space",
"and",
"/",
"or",
"comma",
"separated",
"list",
"of",
"names",
":",
"e",
".",
"g",
".",
":",
"item1",
"item2",
... | python | train | 46.666667 |
twilio/twilio-python | twilio/rest/autopilot/v1/assistant/model_build.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/autopilot/v1/assistant/model_build.py#L119-L137 | def create(self, status_callback=values.unset, unique_name=values.unset):
"""
Create a new ModelBuildInstance
:param unicode status_callback: The URL we should call using a POST method to send status information to your application
:param unicode unique_name: An application-defined stri... | [
"def",
"create",
"(",
"self",
",",
"status_callback",
"=",
"values",
".",
"unset",
",",
"unique_name",
"=",
"values",
".",
"unset",
")",
":",
"data",
"=",
"values",
".",
"of",
"(",
"{",
"'StatusCallback'",
":",
"status_callback",
",",
"'UniqueName'",
":",
... | Create a new ModelBuildInstance
:param unicode status_callback: The URL we should call using a POST method to send status information to your application
:param unicode unique_name: An application-defined string that uniquely identifies the new resource
:returns: Newly created ModelBuildInstan... | [
"Create",
"a",
"new",
"ModelBuildInstance"
] | python | train | 42.526316 |
brutasse/graphite-api | graphite_api/functions.py | https://github.com/brutasse/graphite-api/blob/0886b7adcf985a1e8bcb084f6dd1dc166a3f3dff/graphite_api/functions.py#L3298-L3335 | def aggregateLine(requestContext, seriesList, func='avg'):
"""
Takes a metric or wildcard seriesList and draws a horizontal line
based on the function applied to each series.
Note: By default, the graphite renderer consolidates data points by
averaging data points over time. If you are using the 'm... | [
"def",
"aggregateLine",
"(",
"requestContext",
",",
"seriesList",
",",
"func",
"=",
"'avg'",
")",
":",
"t_funcs",
"=",
"{",
"'avg'",
":",
"safeAvg",
",",
"'min'",
":",
"safeMin",
",",
"'max'",
":",
"safeMax",
"}",
"if",
"func",
"not",
"in",
"t_funcs",
... | Takes a metric or wildcard seriesList and draws a horizontal line
based on the function applied to each series.
Note: By default, the graphite renderer consolidates data points by
averaging data points over time. If you are using the 'min' or 'max'
function for aggregateLine, this can cause an unusual ... | [
"Takes",
"a",
"metric",
"or",
"wildcard",
"seriesList",
"and",
"draws",
"a",
"horizontal",
"line",
"based",
"on",
"the",
"function",
"applied",
"to",
"each",
"series",
"."
] | python | train | 36.526316 |
opendatateam/udata | udata/core/tags/tasks.py | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/tags/tasks.py#L38-L48 | def count_tags(self):
'''Count tag occurences by type and update the tag collection'''
for key, model in TAGGED.items():
collection = '{0}_tags'.format(key)
results = (model.objects(tags__exists=True)
.map_reduce(map_tags, reduce_tags, collection))
for result in r... | [
"def",
"count_tags",
"(",
"self",
")",
":",
"for",
"key",
",",
"model",
"in",
"TAGGED",
".",
"items",
"(",
")",
":",
"collection",
"=",
"'{0}_tags'",
".",
"format",
"(",
"key",
")",
"results",
"=",
"(",
"model",
".",
"objects",
"(",
"tags__exists",
"... | Count tag occurences by type and update the tag collection | [
"Count",
"tag",
"occurences",
"by",
"type",
"and",
"update",
"the",
"tag",
"collection"
] | python | train | 50.090909 |
gabstopper/smc-python | smc/examples/ip_lists.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L113-L125 | def download_as_json(name):
"""
Download IPList as json. This would allow for easily
manipulation of the IPList, but generally recommended only for
smaller lists
:param str name: name of IPList
:return: None
"""
location = list(IPList.objects.filter(name))
if location:
ipli... | [
"def",
"download_as_json",
"(",
"name",
")",
":",
"location",
"=",
"list",
"(",
"IPList",
".",
"objects",
".",
"filter",
"(",
"name",
")",
")",
"if",
"location",
":",
"iplist",
"=",
"location",
"[",
"0",
"]",
"return",
"iplist",
".",
"download",
"(",
... | Download IPList as json. This would allow for easily
manipulation of the IPList, but generally recommended only for
smaller lists
:param str name: name of IPList
:return: None | [
"Download",
"IPList",
"as",
"json",
".",
"This",
"would",
"allow",
"for",
"easily",
"manipulation",
"of",
"the",
"IPList",
"but",
"generally",
"recommended",
"only",
"for",
"smaller",
"lists"
] | python | train | 28.538462 |
pandas-dev/pandas | pandas/io/excel/_openpyxl.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/excel/_openpyxl.py#L98-L123 | def _convert_to_color(cls, color_spec):
"""
Convert ``color_spec`` to an openpyxl v2 Color object
Parameters
----------
color_spec : str, dict
A 32-bit ARGB hex string, or a dict with zero or more of the
following keys.
'rgb'
... | [
"def",
"_convert_to_color",
"(",
"cls",
",",
"color_spec",
")",
":",
"from",
"openpyxl",
".",
"styles",
"import",
"Color",
"if",
"isinstance",
"(",
"color_spec",
",",
"str",
")",
":",
"return",
"Color",
"(",
"color_spec",
")",
"else",
":",
"return",
"Color... | Convert ``color_spec`` to an openpyxl v2 Color object
Parameters
----------
color_spec : str, dict
A 32-bit ARGB hex string, or a dict with zero or more of the
following keys.
'rgb'
'indexed'
'auto'
'theme'
... | [
"Convert",
"color_spec",
"to",
"an",
"openpyxl",
"v2",
"Color",
"object",
"Parameters",
"----------",
"color_spec",
":",
"str",
"dict",
"A",
"32",
"-",
"bit",
"ARGB",
"hex",
"string",
"or",
"a",
"dict",
"with",
"zero",
"or",
"more",
"of",
"the",
"following... | python | train | 26.115385 |
pjuren/pyokit | src/pyokit/datastruct/genomicInterval.py | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/genomicInterval.py#L650-L664 | def subtract(self, es):
"""
Subtract the BED elements in es from self.
:param es: a list of BED elements (or anything with chrom, start, end)
:return: a list of BED elements which represent what is left of
self after the subtraction. This might be an empty list.
"""
workingSet = [s... | [
"def",
"subtract",
"(",
"self",
",",
"es",
")",
":",
"workingSet",
"=",
"[",
"self",
"]",
"for",
"e",
"in",
"es",
":",
"newWorkingSet",
"=",
"[",
"]",
"for",
"w",
"in",
"workingSet",
":",
"newWorkingSet",
"+=",
"w",
".",
"__singleIntersect",
"(",
"e"... | Subtract the BED elements in es from self.
:param es: a list of BED elements (or anything with chrom, start, end)
:return: a list of BED elements which represent what is left of
self after the subtraction. This might be an empty list. | [
"Subtract",
"the",
"BED",
"elements",
"in",
"es",
"from",
"self",
"."
] | python | train | 32.133333 |
KE-works/pykechain | pykechain/helpers.py | https://github.com/KE-works/pykechain/blob/b0296cf34328fd41660bf6f0b9114fd0167c40c4/pykechain/helpers.py#L9-L118 | def get_project(url=None, username=None, password=None, token=None, scope=None, scope_id=None,
env_filename=None, status=ScopeStatus.ACTIVE):
"""
Retrieve and return the KE-chain project to be used throughout an app.
This helper is made to bootstrap a pykechain enabled python script or an j... | [
"def",
"get_project",
"(",
"url",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"token",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"scope_id",
"=",
"None",
",",
"env_filename",
"=",
"None",
",",
"status",
"=",
"Scop... | Retrieve and return the KE-chain project to be used throughout an app.
This helper is made to bootstrap a pykechain enabled python script or an jupyter notebook with the correct
project (technically this is a `pykechain.models.Scope` model).
When no parameters are passed in this function, it will try to r... | [
"Retrieve",
"and",
"return",
"the",
"KE",
"-",
"chain",
"project",
"to",
"be",
"used",
"throughout",
"an",
"app",
"."
] | python | train | 50.427273 |
zhanglab/psamm | psamm/command.py | https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/command.py#L248-L268 | def _create_executor(self, handler, args, cpus_per_worker=1):
"""Return a new :class:`.Executor` instance."""
if self._args.parallel > 0:
workers = self._args.parallel
else:
try:
workers = mp.cpu_count() // cpus_per_worker
except NotImplemented... | [
"def",
"_create_executor",
"(",
"self",
",",
"handler",
",",
"args",
",",
"cpus_per_worker",
"=",
"1",
")",
":",
"if",
"self",
".",
"_args",
".",
"parallel",
">",
"0",
":",
"workers",
"=",
"self",
".",
"_args",
".",
"parallel",
"else",
":",
"try",
":... | Return a new :class:`.Executor` instance. | [
"Return",
"a",
"new",
":",
"class",
":",
".",
"Executor",
"instance",
"."
] | python | train | 36.52381 |
Kozea/cairocffi | cairocffi/context.py | https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1629-L1643 | def clip_extents(self):
"""Computes a bounding box in user coordinates
covering the area inside the current clip.
:return:
A ``(x1, y1, x2, y2)`` tuple of floats:
the left, top, right and bottom of the resulting extents,
respectively.
"""
ext... | [
"def",
"clip_extents",
"(",
"self",
")",
":",
"extents",
"=",
"ffi",
".",
"new",
"(",
"'double[4]'",
")",
"cairo",
".",
"cairo_clip_extents",
"(",
"self",
".",
"_pointer",
",",
"extents",
"+",
"0",
",",
"extents",
"+",
"1",
",",
"extents",
"+",
"2",
... | Computes a bounding box in user coordinates
covering the area inside the current clip.
:return:
A ``(x1, y1, x2, y2)`` tuple of floats:
the left, top, right and bottom of the resulting extents,
respectively. | [
"Computes",
"a",
"bounding",
"box",
"in",
"user",
"coordinates",
"covering",
"the",
"area",
"inside",
"the",
"current",
"clip",
"."
] | python | train | 33.666667 |
cytoscape/py2cytoscape | py2cytoscape/cyrest/layout.py | https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/layout.py#L380-L452 | def fruchterman_rheingold(self,attraction_multiplier=None,conflict_avoidance=None,\
defaultEdgeWeight=None,EdgeAttribute=None,gravity_multiplier=None,\
layout3D=None,max_distance_factor=None,maxWeightCutoff=None,minWeightCutoff=None,\
network=None,nIterations=None,NodeAttribute=None,nodeList=None,randomize=None,\... | [
"def",
"fruchterman_rheingold",
"(",
"self",
",",
"attraction_multiplier",
"=",
"None",
",",
"conflict_avoidance",
"=",
"None",
",",
"defaultEdgeWeight",
"=",
"None",
",",
"EdgeAttribute",
"=",
"None",
",",
"gravity_multiplier",
"=",
"None",
",",
"layout3D",
"=",
... | Execute the Edge-weighted Force directed (BioLayout) on a network
:param attraction_multiplier (string, optional): Divisor to calculate the a
ttraction force, in numeric value
:param conflict_avoidance (string, optional): Constant force applied to avo
id conflicts, in numeric value
:param defaultEdgeWeight... | [
"Execute",
"the",
"Edge",
"-",
"weighted",
"Force",
"directed",
"(",
"BioLayout",
")",
"on",
"a",
"network"
] | python | train | 59.821918 |
lawsie/guizero | guizero/Combo.py | https://github.com/lawsie/guizero/blob/84c7f0b314fa86f9fc88eb11c9a0f6c4b57155e2/guizero/Combo.py#L284-L292 | def _set_option_by_index(self, index):
"""
Sets a single option in the Combo by its index, returning True if it was able too.
"""
if index < len(self._options):
self._selected.set(self._options[index])
return True
else:
return False | [
"def",
"_set_option_by_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"<",
"len",
"(",
"self",
".",
"_options",
")",
":",
"self",
".",
"_selected",
".",
"set",
"(",
"self",
".",
"_options",
"[",
"index",
"]",
")",
"return",
"True",
"else... | Sets a single option in the Combo by its index, returning True if it was able too. | [
"Sets",
"a",
"single",
"option",
"in",
"the",
"Combo",
"by",
"its",
"index",
"returning",
"True",
"if",
"it",
"was",
"able",
"too",
"."
] | python | train | 33.333333 |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/dataframeeditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1249-L1257 | def get_value(self):
"""Return modified Dataframe -- this is *not* a copy"""
# It is import to avoid accessing Qt C++ object as it has probably
# already been destroyed, due to the Qt.WA_DeleteOnClose attribute
df = self.dataModel.get_data()
if self.is_series:
r... | [
"def",
"get_value",
"(",
"self",
")",
":",
"# It is import to avoid accessing Qt C++ object as it has probably\r",
"# already been destroyed, due to the Qt.WA_DeleteOnClose attribute\r",
"df",
"=",
"self",
".",
"dataModel",
".",
"get_data",
"(",
")",
"if",
"self",
".",
"is_se... | Return modified Dataframe -- this is *not* a copy | [
"Return",
"modified",
"Dataframe",
"--",
"this",
"is",
"*",
"not",
"*",
"a",
"copy"
] | python | train | 41 |
thomasdelaet/python-velbus | velbus/messages/channel_name_request.py | https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/channel_name_request.py#L56-L65 | def data_to_binary(self):
"""
:return: bytes
"""
tmp = 0x00
if 1 in self.channels:
tmp += 0x03
if 2 in self.channels:
tmp += 0x0c
return bytes([COMMAND_CODE, tmp]) | [
"def",
"data_to_binary",
"(",
"self",
")",
":",
"tmp",
"=",
"0x00",
"if",
"1",
"in",
"self",
".",
"channels",
":",
"tmp",
"+=",
"0x03",
"if",
"2",
"in",
"self",
".",
"channels",
":",
"tmp",
"+=",
"0x0c",
"return",
"bytes",
"(",
"[",
"COMMAND_CODE",
... | :return: bytes | [
":",
"return",
":",
"bytes"
] | python | train | 23.4 |
genialis/resolwe | resolwe/elastic/builder.py | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L310-L315 | def process_delete(self, obj, pk_set=None, action=None, update_fields=None, **kwargs):
"""Recreate queryset from the index and rebuild the index."""
build_kwargs = self.delete_cache.take(obj)
if build_kwargs:
self.index.build(**build_kwargs) | [
"def",
"process_delete",
"(",
"self",
",",
"obj",
",",
"pk_set",
"=",
"None",
",",
"action",
"=",
"None",
",",
"update_fields",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"build_kwargs",
"=",
"self",
".",
"delete_cache",
".",
"take",
"(",
"obj",
... | Recreate queryset from the index and rebuild the index. | [
"Recreate",
"queryset",
"from",
"the",
"index",
"and",
"rebuild",
"the",
"index",
"."
] | python | train | 45.5 |
msztolcman/versionner | versionner/vcs/git.py | https://github.com/msztolcman/versionner/blob/78fca02859e3e3eb71c9eb7ea230758944177c54/versionner/vcs/git.py#L93-L109 | def raise_if_cant_commit(self):
"""Verify VCS status and raise an error if commit is disallowed
:return:
"""
cmd = self._command.status()
(code, stdout, stderr) = self._exec(cmd)
if code:
raise errors.VCSError('Can\'t verify VCS status. Process exited with ... | [
"def",
"raise_if_cant_commit",
"(",
"self",
")",
":",
"cmd",
"=",
"self",
".",
"_command",
".",
"status",
"(",
")",
"(",
"code",
",",
"stdout",
",",
"stderr",
")",
"=",
"self",
".",
"_exec",
"(",
"cmd",
")",
"if",
"code",
":",
"raise",
"errors",
".... | Verify VCS status and raise an error if commit is disallowed
:return: | [
"Verify",
"VCS",
"status",
"and",
"raise",
"an",
"error",
"if",
"commit",
"is",
"disallowed"
] | python | train | 36.117647 |
ansible/molecule | molecule/provisioner/ansible.py | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/provisioner/ansible.py#L807-L822 | def _link_or_update_vars(self):
"""
Creates or updates the symlink to group_vars and returns None.
:returns: None
"""
for d, source in self.links.items():
target = os.path.join(self.inventory_directory, d)
source = os.path.join(self._config.scenario.direc... | [
"def",
"_link_or_update_vars",
"(",
"self",
")",
":",
"for",
"d",
",",
"source",
"in",
"self",
".",
"links",
".",
"items",
"(",
")",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"inventory_directory",
",",
"d",
")",
"source",... | Creates or updates the symlink to group_vars and returns None.
:returns: None | [
"Creates",
"or",
"updates",
"the",
"symlink",
"to",
"group_vars",
"and",
"returns",
"None",
"."
] | python | train | 38.6875 |
pebble/libpebble2 | libpebble2/protocol/base/__init__.py | https://github.com/pebble/libpebble2/blob/23e2eb92cfc084e6f9e8c718711ac994ef606d18/libpebble2/protocol/base/__init__.py#L143-L153 | def serialise_packet(self):
"""
Serialise a message, including framing information inferred from the ``Meta`` inner class of the packet.
``self.Meta.endpoint`` must be defined to call this method.
:return: A serialised message, ready to be sent to the Pebble.
"""
if not ... | [
"def",
"serialise_packet",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_Meta'",
")",
":",
"raise",
"ReferenceError",
"(",
"\"Can't serialise a packet that doesn't have an endpoint ID.\"",
")",
"serialised",
"=",
"self",
".",
"serialise",
"(",
... | Serialise a message, including framing information inferred from the ``Meta`` inner class of the packet.
``self.Meta.endpoint`` must be defined to call this method.
:return: A serialised message, ready to be sent to the Pebble. | [
"Serialise",
"a",
"message",
"including",
"framing",
"information",
"inferred",
"from",
"the",
"Meta",
"inner",
"class",
"of",
"the",
"packet",
".",
"self",
".",
"Meta",
".",
"endpoint",
"must",
"be",
"defined",
"to",
"call",
"this",
"method",
"."
] | python | train | 50.363636 |
redbridge/molnctrl | molnctrl/csobjects.py | https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/csobjects.py#L155-L158 | def update(self):
""" Update the state """
vm = self._cs_api.list_virtualmachines(id=self.id)[0]
self.is_running = self._is_running(vm.state) | [
"def",
"update",
"(",
"self",
")",
":",
"vm",
"=",
"self",
".",
"_cs_api",
".",
"list_virtualmachines",
"(",
"id",
"=",
"self",
".",
"id",
")",
"[",
"0",
"]",
"self",
".",
"is_running",
"=",
"self",
".",
"_is_running",
"(",
"vm",
".",
"state",
")"
... | Update the state | [
"Update",
"the",
"state"
] | python | train | 40.5 |
zero-os/0-core | client/py-client/zeroos/core0/client/client.py | https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L626-L640 | def download(self, remote, writer):
"""
Downloads a file
:param remote: remote file name
:param writer: an object the implements the write(bytes) interface (typical a file descriptor)
:return:
"""
fd = self.open(remote)
while True:
chunk = sel... | [
"def",
"download",
"(",
"self",
",",
"remote",
",",
"writer",
")",
":",
"fd",
"=",
"self",
".",
"open",
"(",
"remote",
")",
"while",
"True",
":",
"chunk",
"=",
"self",
".",
"read",
"(",
"fd",
")",
"if",
"chunk",
"==",
"b''",
":",
"break",
"writer... | Downloads a file
:param remote: remote file name
:param writer: an object the implements the write(bytes) interface (typical a file descriptor)
:return: | [
"Downloads",
"a",
"file",
":",
"param",
"remote",
":",
"remote",
"file",
"name",
":",
"param",
"writer",
":",
"an",
"object",
"the",
"implements",
"the",
"write",
"(",
"bytes",
")",
"interface",
"(",
"typical",
"a",
"file",
"descriptor",
")",
":",
"retur... | python | train | 28.133333 |
enkore/i3pystatus | i3pystatus/weather/__init__.py | https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/weather/__init__.py#L276-L306 | def get_color_data(self, condition):
'''
Disambiguate similarly-named weather conditions, and return the icon
and color that match.
'''
if condition not in self.color_icons:
# Check for similarly-named conditions if no exact match found
condition_lc = cond... | [
"def",
"get_color_data",
"(",
"self",
",",
"condition",
")",
":",
"if",
"condition",
"not",
"in",
"self",
".",
"color_icons",
":",
"# Check for similarly-named conditions if no exact match found",
"condition_lc",
"=",
"condition",
".",
"lower",
"(",
")",
"if",
"'clo... | Disambiguate similarly-named weather conditions, and return the icon
and color that match. | [
"Disambiguate",
"similarly",
"-",
"named",
"weather",
"conditions",
"and",
"return",
"the",
"icon",
"and",
"color",
"that",
"match",
"."
] | python | train | 42.096774 |
wummel/dosage | dosagelib/util.py | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/util.py#L268-L275 | def check_robotstxt(url, session):
"""Check if robots.txt allows our user agent for the given URL.
@raises: IOError if URL is not allowed
"""
roboturl = get_roboturl(url)
rp = get_robotstxt_parser(roboturl, session=session)
if not rp.can_fetch(UserAgent, str(url)):
raise IOError("%s is d... | [
"def",
"check_robotstxt",
"(",
"url",
",",
"session",
")",
":",
"roboturl",
"=",
"get_roboturl",
"(",
"url",
")",
"rp",
"=",
"get_robotstxt_parser",
"(",
"roboturl",
",",
"session",
"=",
"session",
")",
"if",
"not",
"rp",
".",
"can_fetch",
"(",
"UserAgent"... | Check if robots.txt allows our user agent for the given URL.
@raises: IOError if URL is not allowed | [
"Check",
"if",
"robots",
".",
"txt",
"allows",
"our",
"user",
"agent",
"for",
"the",
"given",
"URL",
"."
] | python | train | 43.5 |
inveniosoftware/invenio-oauthclient | invenio_oauthclient/handlers.py | https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/handlers.py#L351-L373 | def disconnect_handler(remote, *args, **kwargs):
"""Handle unlinking of remote account.
This default handler will just delete the remote account link. You may
wish to extend this module to perform clean-up in the remote service
before removing the link (e.g. removing install webhooks).
:param remo... | [
"def",
"disconnect_handler",
"(",
"remote",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"current_user",
".",
"is_authenticated",
":",
"return",
"current_app",
".",
"login_manager",
".",
"unauthorized",
"(",
")",
"with",
"db",
".",
"se... | Handle unlinking of remote account.
This default handler will just delete the remote account link. You may
wish to extend this module to perform clean-up in the remote service
before removing the link (e.g. removing install webhooks).
:param remote: The remote application.
:returns: Redirect respo... | [
"Handle",
"unlinking",
"of",
"remote",
"account",
"."
] | python | train | 33.652174 |
openpermissions/perch | perch/views.py | https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/views.py#L50-L65 | def create_design_doc(self):
"""Create a design document from a Python map function"""
source = [x for x in inspect.getsourcelines(self.func)[0]
if not x.startswith('@')]
doc = {
'_id': '_design/{}'.format(self.name),
'language': 'python',
'... | [
"def",
"create_design_doc",
"(",
"self",
")",
":",
"source",
"=",
"[",
"x",
"for",
"x",
"in",
"inspect",
".",
"getsourcelines",
"(",
"self",
".",
"func",
")",
"[",
"0",
"]",
"if",
"not",
"x",
".",
"startswith",
"(",
"'@'",
")",
"]",
"doc",
"=",
"... | Create a design document from a Python map function | [
"Create",
"a",
"design",
"document",
"from",
"a",
"Python",
"map",
"function"
] | python | train | 28 |
bwhite/hadoopy | hadoopy/_hdfs.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_hdfs.py#L193-L201 | def put(local_path, hdfs_path):
"""Put a file on hdfs
:param local_path: Source (str)
:param hdfs_path: Destination (str)
:raises: IOError: If unsuccessful
"""
cmd = "hadoop fs -put %s %s" % (local_path, hdfs_path)
rcode, stdout, stderr = _checked_hadoop_fs_command(cmd) | [
"def",
"put",
"(",
"local_path",
",",
"hdfs_path",
")",
":",
"cmd",
"=",
"\"hadoop fs -put %s %s\"",
"%",
"(",
"local_path",
",",
"hdfs_path",
")",
"rcode",
",",
"stdout",
",",
"stderr",
"=",
"_checked_hadoop_fs_command",
"(",
"cmd",
")"
] | Put a file on hdfs
:param local_path: Source (str)
:param hdfs_path: Destination (str)
:raises: IOError: If unsuccessful | [
"Put",
"a",
"file",
"on",
"hdfs"
] | python | train | 32.333333 |
StackStorm/pybind | pybind/slxos/v17s_1_02/qos_mpls/map_apply/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/qos_mpls/map_apply/__init__.py#L100-L121 | def _set_apply_exp_traffic_class_map_name(self, v, load=False):
"""
Setter method for apply_exp_traffic_class_map_name, mapped from YANG variable /qos_mpls/map_apply/apply_exp_traffic_class_map_name (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_apply_exp_tr... | [
"def",
"_set_apply_exp_traffic_class_map_name",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"("... | Setter method for apply_exp_traffic_class_map_name, mapped from YANG variable /qos_mpls/map_apply/apply_exp_traffic_class_map_name (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_apply_exp_traffic_class_map_name is considered as a private
method. Backends looking... | [
"Setter",
"method",
"for",
"apply_exp_traffic_class_map_name",
"mapped",
"from",
"YANG",
"variable",
"/",
"qos_mpls",
"/",
"map_apply",
"/",
"apply_exp_traffic_class_map_name",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config"... | python | train | 96.772727 |
mlperf/training | rnn_translator/pytorch/seq2seq/train/fp_optimizers.py | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/train/fp_optimizers.py#L149-L163 | def step(self, loss, optimizer, scheduler, update=True):
"""
Performs one step of the optimizer.
:param loss: value of loss function
:param optimizer: optimizer
:param update: if True executes weight update
"""
loss.backward()
if update:
if se... | [
"def",
"step",
"(",
"self",
",",
"loss",
",",
"optimizer",
",",
"scheduler",
",",
"update",
"=",
"True",
")",
":",
"loss",
".",
"backward",
"(",
")",
"if",
"update",
":",
"if",
"self",
".",
"grad_clip",
"!=",
"float",
"(",
"'inf'",
")",
":",
"clip_... | Performs one step of the optimizer.
:param loss: value of loss function
:param optimizer: optimizer
:param update: if True executes weight update | [
"Performs",
"one",
"step",
"of",
"the",
"optimizer",
"."
] | python | train | 33.4 |
f3at/feat | tools/pep8.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/tools/pep8.py#L608-L647 | def check_all(self):
"""
Run all checks on the input file.
"""
self.file_errors = 0
self.line_number = 0
self.indent_char = None
self.indent_level = 0
self.previous_logical = ''
self.blank_lines = 0
self.tokens = []
parens = 0
... | [
"def",
"check_all",
"(",
"self",
")",
":",
"self",
".",
"file_errors",
"=",
"0",
"self",
".",
"line_number",
"=",
"0",
"self",
".",
"indent_char",
"=",
"None",
"self",
".",
"indent_level",
"=",
"0",
"self",
".",
"previous_logical",
"=",
"''",
"self",
"... | Run all checks on the input file. | [
"Run",
"all",
"checks",
"on",
"the",
"input",
"file",
"."
] | python | train | 41.3 |
pypa/pipenv | pipenv/patched/notpip/_vendor/pkg_resources/__init__.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/pkg_resources/__init__.py#L1028-L1035 | def add(self, dist):
"""Add `dist` if we ``can_add()`` it and it has not already been added
"""
if self.can_add(dist) and dist.has_version():
dists = self._distmap.setdefault(dist.key, [])
if dist not in dists:
dists.append(dist)
dists.sort... | [
"def",
"add",
"(",
"self",
",",
"dist",
")",
":",
"if",
"self",
".",
"can_add",
"(",
"dist",
")",
"and",
"dist",
".",
"has_version",
"(",
")",
":",
"dists",
"=",
"self",
".",
"_distmap",
".",
"setdefault",
"(",
"dist",
".",
"key",
",",
"[",
"]",
... | Add `dist` if we ``can_add()`` it and it has not already been added | [
"Add",
"dist",
"if",
"we",
"can_add",
"()",
"it",
"and",
"it",
"has",
"not",
"already",
"been",
"added"
] | python | train | 45.375 |
xtrementl/focus | focus/plugin/modules/im.py | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L93-L119 | def _pidgin_status(status, message):
""" Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('im.pidgin.purple.PurpleService',
'/im... | [
"def",
"_pidgin_status",
"(",
"status",
",",
"message",
")",
":",
"try",
":",
"iface",
"=",
"_dbus_get_interface",
"(",
"'im.pidgin.purple.PurpleService'",
",",
"'/im/pidgin/purple/PurpleObject'",
",",
"'im.pidgin.purple.PurpleInterface'",
")",
"if",
"iface",
":",
"# cr... | Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Pidgin",
"IM",
"application",
"."
] | python | train | 30.407407 |
oauthlib/oauthlib | oauthlib/oauth1/rfc5849/signature.py | https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth1/rfc5849/signature.py#L634-L661 | def verify_hmac_sha1(request, client_secret=None,
resource_owner_secret=None):
"""Verify a HMAC-SHA1 signature.
Per `section 3.4`_ of the spec.
.. _`section 3.4`: https://tools.ietf.org/html/rfc5849#section-3.4
To satisfy `RFC2616 section 5.2`_ item 1, the request argument's uri
... | [
"def",
"verify_hmac_sha1",
"(",
"request",
",",
"client_secret",
"=",
"None",
",",
"resource_owner_secret",
"=",
"None",
")",
":",
"norm_params",
"=",
"normalize_parameters",
"(",
"request",
".",
"params",
")",
"bs_uri",
"=",
"base_string_uri",
"(",
"request",
"... | Verify a HMAC-SHA1 signature.
Per `section 3.4`_ of the spec.
.. _`section 3.4`: https://tools.ietf.org/html/rfc5849#section-3.4
To satisfy `RFC2616 section 5.2`_ item 1, the request argument's uri
attribute MUST be an absolute URI whose netloc part identifies the
origin server or gateway on whic... | [
"Verify",
"a",
"HMAC",
"-",
"SHA1",
"signature",
"."
] | python | train | 40.535714 |
d0c-s4vage/pfp | pfp/fields.py | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L759-L777 | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if save_offset and stream is not None:
self._pfp__offset = stream.tell()
# returns... | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
"and",
"stream",
"is",
"not",
"None",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"# returns eithe... | Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None | [
"Build",
"the",
"field",
"and",
"write",
"the",
"result",
"into",
"the",
"stream"
] | python | train | 30.473684 |
neurosynth/neurosynth | neurosynth/analysis/classify.py | https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/classify.py#L150-L209 | def classify_regions(dataset, masks, method='ERF', threshold=0.08,
remove_overlap=True, regularization='scale',
output='summary', studies=None, features=None,
class_weight='auto', classifier=None,
cross_val='4-Fold', param_grid=None, sc... | [
"def",
"classify_regions",
"(",
"dataset",
",",
"masks",
",",
"method",
"=",
"'ERF'",
",",
"threshold",
"=",
"0.08",
",",
"remove_overlap",
"=",
"True",
",",
"regularization",
"=",
"'scale'",
",",
"output",
"=",
"'summary'",
",",
"studies",
"=",
"None",
",... | Perform classification on specified regions
Given a set of masks, this function retrieves studies associated with
each mask at the specified threshold, optionally removes overlap and
filters by studies and features. Then it trains an algorithm to
classify studies based on features and t... | [
"Perform",
"classification",
"on",
"specified",
"regions"
] | python | test | 53.45 |
jrief/djangocms-cascade | cmsplugin_cascade/plugin_base.py | https://github.com/jrief/djangocms-cascade/blob/58996f990c4068e5d50f0db6030a5c0e06b682e5/cmsplugin_cascade/plugin_base.py#L480-L488 | def in_edit_mode(self, request, placeholder):
"""
Returns True, if the plugin is in "edit mode".
"""
toolbar = getattr(request, 'toolbar', None)
edit_mode = getattr(toolbar, 'edit_mode', False) and getattr(placeholder, 'is_editable', True)
if edit_mode:
edit_m... | [
"def",
"in_edit_mode",
"(",
"self",
",",
"request",
",",
"placeholder",
")",
":",
"toolbar",
"=",
"getattr",
"(",
"request",
",",
"'toolbar'",
",",
"None",
")",
"edit_mode",
"=",
"getattr",
"(",
"toolbar",
",",
"'edit_mode'",
",",
"False",
")",
"and",
"g... | Returns True, if the plugin is in "edit mode". | [
"Returns",
"True",
"if",
"the",
"plugin",
"is",
"in",
"edit",
"mode",
"."
] | python | train | 43.333333 |
ehansis/ozelot | ozelot/etl/tasks.py | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/tasks.py#L18-L32 | def get_task_param_string(task):
"""Get all parameters of a task as one string
Returns:
str: task parameter string
"""
# get dict str -> str from luigi
param_dict = task.to_str_params()
# sort keys, serialize
items = []
for key in sorted(param_dict.keys()):
items.append... | [
"def",
"get_task_param_string",
"(",
"task",
")",
":",
"# get dict str -> str from luigi",
"param_dict",
"=",
"task",
".",
"to_str_params",
"(",
")",
"# sort keys, serialize",
"items",
"=",
"[",
"]",
"for",
"key",
"in",
"sorted",
"(",
"param_dict",
".",
"keys",
... | Get all parameters of a task as one string
Returns:
str: task parameter string | [
"Get",
"all",
"parameters",
"of",
"a",
"task",
"as",
"one",
"string"
] | python | train | 26.266667 |
xtuml/pyxtuml | bridgepoint/oal.py | https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/oal.py#L1634-L1638 | def p_navigation_step_2(self, p):
'''navigation_step : ARROW identifier LSQBR identifier DOT phrase RSQBR'''
p[0] = NavigationStepNode(key_letter=p[2],
rel_id=p[4],
phrase=p[6]) | [
"def",
"p_navigation_step_2",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"NavigationStepNode",
"(",
"key_letter",
"=",
"p",
"[",
"2",
"]",
",",
"rel_id",
"=",
"p",
"[",
"4",
"]",
",",
"phrase",
"=",
"p",
"[",
"6",
"]",
")"
] | navigation_step : ARROW identifier LSQBR identifier DOT phrase RSQBR | [
"navigation_step",
":",
"ARROW",
"identifier",
"LSQBR",
"identifier",
"DOT",
"phrase",
"RSQBR"
] | python | test | 51.4 |
aiogram/aiogram | aiogram/contrib/middlewares/logging.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/logging.py#L233-L245 | def make_prefix(self, prefix, iterable):
"""
Add prefix to the label
:param prefix:
:param iterable:
:return:
"""
if not prefix:
yield from iterable
for key, value in iterable:
yield f"{prefix}_{key}", value | [
"def",
"make_prefix",
"(",
"self",
",",
"prefix",
",",
"iterable",
")",
":",
"if",
"not",
"prefix",
":",
"yield",
"from",
"iterable",
"for",
"key",
",",
"value",
"in",
"iterable",
":",
"yield",
"f\"{prefix}_{key}\"",
",",
"value"
] | Add prefix to the label
:param prefix:
:param iterable:
:return: | [
"Add",
"prefix",
"to",
"the",
"label"
] | python | train | 21.923077 |
bunq/sdk_python | bunq/sdk/model/generated/endpoint.py | https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/endpoint.py#L6532-L6544 | def get_referenced_object(self):
"""
:rtype: core.BunqModel
:raise: BunqException
"""
if self._TabUsageSingle is not None:
return self._TabUsageSingle
if self._TabUsageMultiple is not None:
return self._TabUsageMultiple
raise exception.B... | [
"def",
"get_referenced_object",
"(",
"self",
")",
":",
"if",
"self",
".",
"_TabUsageSingle",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_TabUsageSingle",
"if",
"self",
".",
"_TabUsageMultiple",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_TabUsa... | :rtype: core.BunqModel
:raise: BunqException | [
":",
"rtype",
":",
"core",
".",
"BunqModel",
":",
"raise",
":",
"BunqException"
] | python | train | 26.538462 |
yyuu/botornado | boto/dynamodb/layer2.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/layer2.py#L299-L316 | def list_tables(self, limit=None, start_table=None):
"""
Return a list of the names of all Tables associated with the
current account and region.
TODO - Layer2 should probably automatically handle pagination.
:type limit: int
:param limit: The maximum number of tables to... | [
"def",
"list_tables",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"start_table",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"layer1",
".",
"list_tables",
"(",
"limit",
",",
"start_table",
")",
"return",
"result",
"[",
"'TableNames'",
"]"
] | Return a list of the names of all Tables associated with the
current account and region.
TODO - Layer2 should probably automatically handle pagination.
:type limit: int
:param limit: The maximum number of tables to return.
:type start_table: str
:param limit: The name o... | [
"Return",
"a",
"list",
"of",
"the",
"names",
"of",
"all",
"Tables",
"associated",
"with",
"the",
"current",
"account",
"and",
"region",
".",
"TODO",
"-",
"Layer2",
"should",
"probably",
"automatically",
"handle",
"pagination",
"."
] | python | train | 41.666667 |
geophysics-ubonn/reda | lib/reda/containers/SIP.py | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/containers/SIP.py#L92-L153 | def reduce_duplicate_frequencies(self):
"""In case multiple frequencies were measured, average them and compute
std, min, max values for zt.
In case timesteps were added (i.e., multiple separate measurements),
group over those and average for each timestep.
Examples
---... | [
"def",
"reduce_duplicate_frequencies",
"(",
"self",
")",
":",
"group_keys",
"=",
"[",
"'frequency'",
",",
"]",
"if",
"'timestep'",
"in",
"self",
".",
"data",
".",
"columns",
":",
"group_keys",
"=",
"group_keys",
"+",
"[",
"'timestep'",
",",
"]",
"g",
"=",
... | In case multiple frequencies were measured, average them and compute
std, min, max values for zt.
In case timesteps were added (i.e., multiple separate measurements),
group over those and average for each timestep.
Examples
--------
::
import tempfile
... | [
"In",
"case",
"multiple",
"frequencies",
"were",
"measured",
"average",
"them",
"and",
"compute",
"std",
"min",
"max",
"values",
"for",
"zt",
"."
] | python | train | 34.209677 |
google/transitfeed | kmlwriter.py | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/kmlwriter.py#L415-L436 | def _CreateStopPlacemark(self, stop_folder, stop, style_id):
"""Creates a new stop <Placemark/> element.
Args:
stop_folder: the KML folder the placemark will be added to.
stop: the actual Stop to create a placemark for.
style_id: optional argument indicating a style id to add to the placemark... | [
"def",
"_CreateStopPlacemark",
"(",
"self",
",",
"stop_folder",
",",
"stop",
",",
"style_id",
")",
":",
"desc_items",
"=",
"[",
"]",
"desc_items",
".",
"append",
"(",
"\"Stop id: %s\"",
"%",
"stop",
".",
"stop_id",
")",
"if",
"stop",
".",
"stop_desc",
":",... | Creates a new stop <Placemark/> element.
Args:
stop_folder: the KML folder the placemark will be added to.
stop: the actual Stop to create a placemark for.
style_id: optional argument indicating a style id to add to the placemark. | [
"Creates",
"a",
"new",
"stop",
"<Placemark",
"/",
">",
"element",
"."
] | python | train | 44.636364 |
qweeze/wex-api-client | wex/client.py | https://github.com/qweeze/wex-api-client/blob/e84d139be229aab2c7c5eda5976b812be651807b/wex/client.py#L233-L250 | def create_coupon(self, currency, amount, receiver):
"""
This method allows you to create Coupons.
Please, note: In order to use this method, you need the Coupon key privilege. You can make a request to
enable it by submitting a ticket to Support..
You need to create the API key ... | [
"def",
"create_coupon",
"(",
"self",
",",
"currency",
",",
"amount",
",",
"receiver",
")",
":",
"return",
"self",
".",
"_trade_api_call",
"(",
"'CreateCoupon'",
",",
"currency",
"=",
"currency",
",",
"amount",
"=",
"amount",
",",
"receiver",
"=",
"receiver",... | This method allows you to create Coupons.
Please, note: In order to use this method, you need the Coupon key privilege. You can make a request to
enable it by submitting a ticket to Support..
You need to create the API key that you are going to use for this method in advance. Please provide
... | [
"This",
"method",
"allows",
"you",
"to",
"create",
"Coupons",
".",
"Please",
"note",
":",
"In",
"order",
"to",
"use",
"this",
"method",
"you",
"need",
"the",
"Coupon",
"key",
"privilege",
".",
"You",
"can",
"make",
"a",
"request",
"to",
"enable",
"it",
... | python | train | 63.277778 |
Rapptz/discord.py | discord/shard.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/shard.py#L297-L359 | async def change_presence(self, *, activity=None, status=None, afk=False, shard_id=None):
"""|coro|
Changes the client's presence.
The activity parameter is a :class:`Activity` object (not a string) that represents
the activity being done currently. This could also be the slimmed down ... | [
"async",
"def",
"change_presence",
"(",
"self",
",",
"*",
",",
"activity",
"=",
"None",
",",
"status",
"=",
"None",
",",
"afk",
"=",
"False",
",",
"shard_id",
"=",
"None",
")",
":",
"if",
"status",
"is",
"None",
":",
"status",
"=",
"'online'",
"statu... | |coro|
Changes the client's presence.
The activity parameter is a :class:`Activity` object (not a string) that represents
the activity being done currently. This could also be the slimmed down versions,
:class:`Game` and :class:`Streaming`.
Example: ::
game = disc... | [
"|coro|"
] | python | train | 36.730159 |
AtteqCom/zsl | src/zsl/utils/cache_helper.py | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/cache_helper.py#L181-L194 | def create_key_for_data(prefix, data, key_params):
"""
From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator)
"""
d = data.get_data()
values = []
for k in key_params:
if k in d and type(d[k]) is list:
values.append("{0}:{1}".f... | [
"def",
"create_key_for_data",
"(",
"prefix",
",",
"data",
",",
"key_params",
")",
":",
"d",
"=",
"data",
".",
"get_data",
"(",
")",
"values",
"=",
"[",
"]",
"for",
"k",
"in",
"key_params",
":",
"if",
"k",
"in",
"d",
"and",
"type",
"(",
"d",
"[",
... | From ``data`` params in task create corresponding key with help of ``key_params`` (defined in decorator) | [
"From",
"data",
"params",
"in",
"task",
"create",
"corresponding",
"key",
"with",
"help",
"of",
"key_params",
"(",
"defined",
"in",
"decorator",
")"
] | python | train | 35.642857 |
baliame/http-hmac-python | httphmac/v2.py | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L165-L177 | def unroll_auth_headers(self, authheaders, exclude_signature=False, sep=",", quote=True):
"""Converts an authorization header dict-like object into a string representing the authorization.
Keyword arguments:
authheaders -- A string-indexable object which contains the headers appropriate for thi... | [
"def",
"unroll_auth_headers",
"(",
"self",
",",
"authheaders",
",",
"exclude_signature",
"=",
"False",
",",
"sep",
"=",
"\",\"",
",",
"quote",
"=",
"True",
")",
":",
"res",
"=",
"\"\"",
"ordered",
"=",
"collections",
".",
"OrderedDict",
"(",
"sorted",
"(",... | Converts an authorization header dict-like object into a string representing the authorization.
Keyword arguments:
authheaders -- A string-indexable object which contains the headers appropriate for this signature version. | [
"Converts",
"an",
"authorization",
"header",
"dict",
"-",
"like",
"object",
"into",
"a",
"string",
"representing",
"the",
"authorization",
"."
] | python | train | 59.923077 |
materialsproject/pymatgen | pymatgen/io/abinit/flows.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L268-L275 | def reload(self):
"""
Reload the flow from the pickle file. Used when we are monitoring the flow
executed by the scheduler. In this case, indeed, the flow might have been changed
by the scheduler and we have to reload the new flow in memory.
"""
new = self.__class__.pickl... | [
"def",
"reload",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"__class__",
".",
"pickle_load",
"(",
"self",
".",
"workdir",
")",
"self",
"=",
"new"
] | Reload the flow from the pickle file. Used when we are monitoring the flow
executed by the scheduler. In this case, indeed, the flow might have been changed
by the scheduler and we have to reload the new flow in memory. | [
"Reload",
"the",
"flow",
"from",
"the",
"pickle",
"file",
".",
"Used",
"when",
"we",
"are",
"monitoring",
"the",
"flow",
"executed",
"by",
"the",
"scheduler",
".",
"In",
"this",
"case",
"indeed",
"the",
"flow",
"might",
"have",
"been",
"changed",
"by",
"... | python | train | 44 |
fabiobatalha/crossrefapi | crossref/restful.py | https://github.com/fabiobatalha/crossrefapi/blob/53f84ee0d8a8fc6ad9b2493f51c5151e66d2faf7/crossref/restful.py#L1594-L1603 | def works(self, prefix_id):
"""
This method retrieve a iterable of Works of the given prefix.
args: Crossref Prefix (String)
return: Works()
"""
context = '%s/%s' % (self.ENDPOINT, str(prefix_id))
return Works(context=context) | [
"def",
"works",
"(",
"self",
",",
"prefix_id",
")",
":",
"context",
"=",
"'%s/%s'",
"%",
"(",
"self",
".",
"ENDPOINT",
",",
"str",
"(",
"prefix_id",
")",
")",
"return",
"Works",
"(",
"context",
"=",
"context",
")"
] | This method retrieve a iterable of Works of the given prefix.
args: Crossref Prefix (String)
return: Works() | [
"This",
"method",
"retrieve",
"a",
"iterable",
"of",
"Works",
"of",
"the",
"given",
"prefix",
"."
] | python | train | 27.5 |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L683-L696 | def transform_rest_response(self, response_body):
"""Translates an apiserving REST response so it's ready to return.
Currently, the only thing that needs to be fixed here is indentation,
so it's consistent with what the live app will return.
Args:
response_body: A string containing the backend r... | [
"def",
"transform_rest_response",
"(",
"self",
",",
"response_body",
")",
":",
"body_json",
"=",
"json",
".",
"loads",
"(",
"response_body",
")",
"return",
"json",
".",
"dumps",
"(",
"body_json",
",",
"indent",
"=",
"1",
",",
"sort_keys",
"=",
"True",
")"
... | Translates an apiserving REST response so it's ready to return.
Currently, the only thing that needs to be fixed here is indentation,
so it's consistent with what the live app will return.
Args:
response_body: A string containing the backend response.
Returns:
A reformatted version of the... | [
"Translates",
"an",
"apiserving",
"REST",
"response",
"so",
"it",
"s",
"ready",
"to",
"return",
"."
] | python | train | 34.857143 |
chaoss/grimoirelab-manuscripts | manuscripts/report.py | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/report.py#L556-L616 | def sec_project_community(self, project=None):
"""
Generate the data for the Communication section in a Project report
:return:
"""
def create_csv(metric1, csv_labels, file_label):
esfilters = None
csv_labels = csv_labels.replace("_", "") # LaTeX not sup... | [
"def",
"sec_project_community",
"(",
"self",
",",
"project",
"=",
"None",
")",
":",
"def",
"create_csv",
"(",
"metric1",
",",
"csv_labels",
",",
"file_label",
")",
":",
"esfilters",
"=",
"None",
"csv_labels",
"=",
"csv_labels",
".",
"replace",
"(",
"\"_\"",
... | Generate the data for the Communication section in a Project report
:return: | [
"Generate",
"the",
"data",
"for",
"the",
"Communication",
"section",
"in",
"a",
"Project",
"report",
":",
"return",
":"
] | python | train | 36.754098 |
StackStorm/pybind | pybind/slxos/v17s_1_02/bd_vc_peer_state/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/bd_vc_peer_state/__init__.py#L141-L164 | def _set_bd_vc_peer_counter(self, v, load=False):
"""
Setter method for bd_vc_peer_counter, mapped from YANG variable /bd_vc_peer_state/bd_vc_peer_counter (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_bd_vc_peer_counter is considered as a private
method... | [
"def",
"_set_bd_vc_peer_counter",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
","... | Setter method for bd_vc_peer_counter, mapped from YANG variable /bd_vc_peer_state/bd_vc_peer_counter (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_bd_vc_peer_counter is considered as a private
method. Backends looking to populate this variable should
do so ... | [
"Setter",
"method",
"for",
"bd_vc_peer_counter",
"mapped",
"from",
"YANG",
"variable",
"/",
"bd_vc_peer_state",
"/",
"bd_vc_peer_counter",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the"... | python | train | 77.833333 |
ensime/ensime-vim | ensime_shared/client.py | https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/client.py#L272-L279 | def set_position(self, decl_pos):
"""Set editor position from ENSIME declPos data."""
if decl_pos["typehint"] == "LineSourcePosition":
self.editor.set_cursor(decl_pos['line'], 0)
else: # OffsetSourcePosition
point = decl_pos["offset"]
row, col = self.editor.p... | [
"def",
"set_position",
"(",
"self",
",",
"decl_pos",
")",
":",
"if",
"decl_pos",
"[",
"\"typehint\"",
"]",
"==",
"\"LineSourcePosition\"",
":",
"self",
".",
"editor",
".",
"set_cursor",
"(",
"decl_pos",
"[",
"'line'",
"]",
",",
"0",
")",
"else",
":",
"# ... | Set editor position from ENSIME declPos data. | [
"Set",
"editor",
"position",
"from",
"ENSIME",
"declPos",
"data",
"."
] | python | train | 47.125 |
Erotemic/utool | utool/util_alg.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_alg.py#L2632-L2728 | def solve_boolexpr():
"""
sudo pip install git+https://github.com/tpircher/quine-mccluskey.git
sudo pip uninstall quine_mccluskey
pip uninstall quine_mccluskey
pip install git+https://github.com/tpircher/quine-mccluskey.git
Args:
varnames (?):
Returns:
?:
CommandLine... | [
"def",
"solve_boolexpr",
"(",
")",
":",
"#false_cases = [",
"# int('111', 2),",
"# int('011', 2),",
"# int('001', 2),",
"#]",
"#true_cases = list(set(range(2 ** 3)) - set(false_cases))",
"varnames",
"=",
"[",
"'sa'",
",",
"'said'",
",",
"'aid'",
"]",
"#import utool a... | sudo pip install git+https://github.com/tpircher/quine-mccluskey.git
sudo pip uninstall quine_mccluskey
pip uninstall quine_mccluskey
pip install git+https://github.com/tpircher/quine-mccluskey.git
Args:
varnames (?):
Returns:
?:
CommandLine:
python -m utool.util_alg... | [
"sudo",
"pip",
"install",
"git",
"+",
"https",
":",
"//",
"github",
".",
"com",
"/",
"tpircher",
"/",
"quine",
"-",
"mccluskey",
".",
"git",
"sudo",
"pip",
"uninstall",
"quine_mccluskey",
"pip",
"uninstall",
"quine_mccluskey"
] | python | train | 31.587629 |
Gandi/gandi.cli | gandi/cli/modules/disk.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/disk.py#L236-L272 | def create(cls, name, vm, size, snapshotprofile, datacenter,
source, disk_type='data', background=False):
""" Create a disk and attach it to a vm. """
if isinstance(size, tuple):
prefix, size = size
if source:
size = None
disk_params = cls.disk_par... | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"vm",
",",
"size",
",",
"snapshotprofile",
",",
"datacenter",
",",
"source",
",",
"disk_type",
"=",
"'data'",
",",
"background",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"size",
",",
"tuple",
")",
... | Create a disk and attach it to a vm. | [
"Create",
"a",
"disk",
"and",
"attach",
"it",
"to",
"a",
"vm",
"."
] | python | train | 31.891892 |
dcwatson/drill | drill.py | https://github.com/dcwatson/drill/blob/b8a30ec0fd5b5bf55154bd44c1c75f5f5945691b/drill.py#L307-L312 | def items(self):
"""
A generator yielding ``(key, value)`` attribute pairs, sorted by key name.
"""
for key in sorted(self.attrs):
yield key, self.attrs[key] | [
"def",
"items",
"(",
"self",
")",
":",
"for",
"key",
"in",
"sorted",
"(",
"self",
".",
"attrs",
")",
":",
"yield",
"key",
",",
"self",
".",
"attrs",
"[",
"key",
"]"
] | A generator yielding ``(key, value)`` attribute pairs, sorted by key name. | [
"A",
"generator",
"yielding",
"(",
"key",
"value",
")",
"attribute",
"pairs",
"sorted",
"by",
"key",
"name",
"."
] | python | valid | 32.666667 |
divio/cmsplugin-filer | cmsplugin_filer_teaser/cms_plugins.py | https://github.com/divio/cmsplugin-filer/blob/4f9b0307dd768852ead64e651b743a165b3efccb/cmsplugin_filer_teaser/cms_plugins.py#L42-L75 | def _get_thumbnail_options(self, context, instance):
"""
Return the size and options of the thumbnail that should be inserted
"""
width, height = None, None
subject_location = False
placeholder_width = context.get('width', None)
placeholder_height = context.get('h... | [
"def",
"_get_thumbnail_options",
"(",
"self",
",",
"context",
",",
"instance",
")",
":",
"width",
",",
"height",
"=",
"None",
",",
"None",
"subject_location",
"=",
"False",
"placeholder_width",
"=",
"context",
".",
"get",
"(",
"'width'",
",",
"None",
")",
... | Return the size and options of the thumbnail that should be inserted | [
"Return",
"the",
"size",
"and",
"options",
"of",
"the",
"thumbnail",
"that",
"should",
"be",
"inserted"
] | python | train | 49.735294 |
f3at/feat | tools/pep8.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/tools/pep8.py#L510-L518 | def readline_check_physical(self):
"""
Check and return the next physical line. This method can be
used to feed tokenize.generate_tokens.
"""
line = self.readline()
if line:
self.check_physical(line)
return line | [
"def",
"readline_check_physical",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"line",
":",
"self",
".",
"check_physical",
"(",
"line",
")",
"return",
"line"
] | Check and return the next physical line. This method can be
used to feed tokenize.generate_tokens. | [
"Check",
"and",
"return",
"the",
"next",
"physical",
"line",
".",
"This",
"method",
"can",
"be",
"used",
"to",
"feed",
"tokenize",
".",
"generate_tokens",
"."
] | python | train | 30.111111 |
juju/charm-helpers | charmhelpers/fetch/centos.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/fetch/centos.py#L140-L171 | def _run_yum_command(cmd, fatal=False):
"""Run an YUM command.
Checks the output and retry if the fatal flag is set to True.
:param: cmd: str: The yum command to run.
:param: fatal: bool: Whether the command's output should be checked and
retried.
"""
env = os.environ.copy()
if fa... | [
"def",
"_run_yum_command",
"(",
"cmd",
",",
"fatal",
"=",
"False",
")",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"if",
"fatal",
":",
"retry_count",
"=",
"0",
"result",
"=",
"None",
"# If the command is considered \"fatal\", we need to retr... | Run an YUM command.
Checks the output and retry if the fatal flag is set to True.
:param: cmd: str: The yum command to run.
:param: fatal: bool: Whether the command's output should be checked and
retried. | [
"Run",
"an",
"YUM",
"command",
"."
] | python | train | 32.4375 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L621-L627 | def _get_point_data_handler_for(self, point):
"""Used by point instances and data callbacks"""
with self.__point_data_handlers:
try:
return self.__point_data_handlers[point]
except KeyError:
return self.__point_data_handlers.setdefault(point, Point... | [
"def",
"_get_point_data_handler_for",
"(",
"self",
",",
"point",
")",
":",
"with",
"self",
".",
"__point_data_handlers",
":",
"try",
":",
"return",
"self",
".",
"__point_data_handlers",
"[",
"point",
"]",
"except",
"KeyError",
":",
"return",
"self",
".",
"__po... | Used by point instances and data callbacks | [
"Used",
"by",
"point",
"instances",
"and",
"data",
"callbacks"
] | python | train | 49.285714 |
juju/charm-helpers | charmhelpers/contrib/openstack/audits/openstack_security_guide.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/audits/openstack_security_guide.py#L104-L116 | def _stat(file):
"""
Get the Ownership information from a file.
:param file: The path to a file to stat
:type file: str
:returns: owner, group, and mode of the specified file
:rtype: Ownership
:raises subprocess.CalledProcessError: If the underlying stat fails
"""
out = subprocess.c... | [
"def",
"_stat",
"(",
"file",
")",
":",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'stat'",
",",
"'-c'",
",",
"'%U %G %a'",
",",
"file",
"]",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"Ownership",
"(",
"*",
"out",
".",
"strip",... | Get the Ownership information from a file.
:param file: The path to a file to stat
:type file: str
:returns: owner, group, and mode of the specified file
:rtype: Ownership
:raises subprocess.CalledProcessError: If the underlying stat fails | [
"Get",
"the",
"Ownership",
"information",
"from",
"a",
"file",
"."
] | python | train | 32.615385 |
totalgood/nlpia | src/nlpia/loaders.py | https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/loaders.py#L549-L567 | def series_strip(series, startswith=None, endswith=None, startsorendswith=None, ignorecase=True):
""" Strip a suffix/prefix str (`endswith`/`startswith` str) from a `df` columns or pd.Series of type str """
if ignorecase:
mask = series.str.lower()
endswith = endswith.lower()
else:
ma... | [
"def",
"series_strip",
"(",
"series",
",",
"startswith",
"=",
"None",
",",
"endswith",
"=",
"None",
",",
"startsorendswith",
"=",
"None",
",",
"ignorecase",
"=",
"True",
")",
":",
"if",
"ignorecase",
":",
"mask",
"=",
"series",
".",
"str",
".",
"lower",
... | Strip a suffix/prefix str (`endswith`/`startswith` str) from a `df` columns or pd.Series of type str | [
"Strip",
"a",
"suffix",
"/",
"prefix",
"str",
"(",
"endswith",
"/",
"startswith",
"str",
")",
"from",
"a",
"df",
"columns",
"or",
"pd",
".",
"Series",
"of",
"type",
"str"
] | python | train | 44.473684 |
pymupdf/PyMuPDF | fitz/fitz.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L2488-L2492 | def _forget_page(self, page):
"""Remove a page from document page dict."""
pid = id(page)
if pid in self._page_refs:
self._page_refs[pid] = None | [
"def",
"_forget_page",
"(",
"self",
",",
"page",
")",
":",
"pid",
"=",
"id",
"(",
"page",
")",
"if",
"pid",
"in",
"self",
".",
"_page_refs",
":",
"self",
".",
"_page_refs",
"[",
"pid",
"]",
"=",
"None"
] | Remove a page from document page dict. | [
"Remove",
"a",
"page",
"from",
"document",
"page",
"dict",
"."
] | python | train | 35.2 |
pyvisa/pyvisa | pyvisa/shell.py | https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/shell.py#L121-L136 | def do_list(self, args):
"""List all connected resources."""
try:
resources = self.resource_manager.list_resources_info()
except Exception as e:
print(e)
else:
self.resources = []
for ndx, (resource_name, value) in enumerate(resources.item... | [
"def",
"do_list",
"(",
"self",
",",
"args",
")",
":",
"try",
":",
"resources",
"=",
"self",
".",
"resource_manager",
".",
"list_resources_info",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"e",
")",
"else",
":",
"self",
".",
"resourc... | List all connected resources. | [
"List",
"all",
"connected",
"resources",
"."
] | python | train | 36.8125 |
pyviz/holoviews | holoviews/plotting/links.py | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/links.py#L62-L78 | def link(self):
"""
Registers the Link
"""
if self.source in self.registry:
links = self.registry[self.source]
params = {
k: v for k, v in self.get_param_values() if k != 'name'}
for link in links:
link_params = {
... | [
"def",
"link",
"(",
"self",
")",
":",
"if",
"self",
".",
"source",
"in",
"self",
".",
"registry",
":",
"links",
"=",
"self",
".",
"registry",
"[",
"self",
".",
"source",
"]",
"params",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"self"... | Registers the Link | [
"Registers",
"the",
"Link"
] | python | train | 39.411765 |
denisenkom/django-sqlserver | sqlserver/base.py | https://github.com/denisenkom/django-sqlserver/blob/f5d5dc8637799746f1bd11bd8c479d3acd468581/sqlserver/base.py#L87-L92 | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string
"""
major, minor, _, _ = self.get_server_version(make_connection=make_connection)
return '{}.{}'.format(major, minor) | [
"def",
"__get_dbms_version",
"(",
"self",
",",
"make_connection",
"=",
"True",
")",
":",
"major",
",",
"minor",
",",
"_",
",",
"_",
"=",
"self",
".",
"get_server_version",
"(",
"make_connection",
"=",
"make_connection",
")",
"return",
"'{}.{}'",
".",
"format... | Returns the 'DBMS Version' string | [
"Returns",
"the",
"DBMS",
"Version",
"string"
] | python | train | 40.333333 |
Esri/ArcREST | src/arcrest/manageportal/administration.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageportal/administration.py#L745-L754 | def SSLCertificates(self):
"""
Lists certificates.
"""
url = self._url + "/SSLCertificate"
params = {"f" : "json"}
return self._post(url=url,
param_dict=params,
proxy_url=self._proxy_url,
proxy_... | [
"def",
"SSLCertificates",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_url",
"+",
"\"/SSLCertificate\"",
"params",
"=",
"{",
"\"f\"",
":",
"\"json\"",
"}",
"return",
"self",
".",
"_post",
"(",
"url",
"=",
"url",
",",
"param_dict",
"=",
"params",
"... | Lists certificates. | [
"Lists",
"certificates",
"."
] | python | train | 33.3 |
inasafe/inasafe | safe/report/extractors/action_notes.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/action_notes.py#L54-L201 | def notes_assumptions_extractor(impact_report, component_metadata):
"""Extracting notes and assumptions of the exposure layer
:param impact_report: the impact report that acts as a proxy to fetch
all the data that extractor needed
:type impact_report: safe.report.impact_report.ImpactReport
:pa... | [
"def",
"notes_assumptions_extractor",
"(",
"impact_report",
",",
"component_metadata",
")",
":",
"context",
"=",
"{",
"}",
"provenance",
"=",
"impact_report",
".",
"impact_function",
".",
"provenance",
"extra_args",
"=",
"component_metadata",
".",
"extra_args",
"hazar... | Extracting notes and assumptions of the exposure layer
:param impact_report: the impact report that acts as a proxy to fetch
all the data that extractor needed
:type impact_report: safe.report.impact_report.ImpactReport
:param component_metadata: the component metadata. Used to obtain
info... | [
"Extracting",
"notes",
"and",
"assumptions",
"of",
"the",
"exposure",
"layer"
] | python | train | 39.858108 |
jbasko/configmanager | configmanager/sections.py | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L536-L587 | def load_values(self, dictionary, as_defaults=False, flat=False):
"""
Import config values from a dictionary.
When ``as_defaults`` is set to ``True``, the values
imported will be set as defaults. This can be used to
declare the sections and items of configuration.
Values... | [
"def",
"load_values",
"(",
"self",
",",
"dictionary",
",",
"as_defaults",
"=",
"False",
",",
"flat",
"=",
"False",
")",
":",
"if",
"flat",
":",
"# Deflatten the dictionary and then pass on to the normal case.",
"separator",
"=",
"self",
".",
"settings",
".",
"str_... | Import config values from a dictionary.
When ``as_defaults`` is set to ``True``, the values
imported will be set as defaults. This can be used to
declare the sections and items of configuration.
Values of sections and items in ``dictionary`` can be
dictionaries as well as instan... | [
"Import",
"config",
"values",
"from",
"a",
"dictionary",
"."
] | python | train | 40.653846 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L27-L39 | def flat_list(lst):
"""This function flatten given nested list.
Argument:
nested list
Returns:
flat list
"""
if isinstance(lst, list):
for item in lst:
for i in flat_list(item):
yield i
else:
yield lst | [
"def",
"flat_list",
"(",
"lst",
")",
":",
"if",
"isinstance",
"(",
"lst",
",",
"list",
")",
":",
"for",
"item",
"in",
"lst",
":",
"for",
"i",
"in",
"flat_list",
"(",
"item",
")",
":",
"yield",
"i",
"else",
":",
"yield",
"lst"
] | This function flatten given nested list.
Argument:
nested list
Returns:
flat list | [
"This",
"function",
"flatten",
"given",
"nested",
"list",
".",
"Argument",
":",
"nested",
"list",
"Returns",
":",
"flat",
"list"
] | python | train | 21 |
senaite/senaite.core | bika/lims/idserver.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/idserver.py#L370-L384 | def get_seq_number_from_id(id, id_template, prefix, **kw):
"""Return the sequence number of the given ID
"""
separator = kw.get("separator", "-")
postfix = id.replace(prefix, "").strip(separator)
postfix_segments = postfix.split(separator)
seq_number = 0
possible_seq_nums = filter(lambda n: ... | [
"def",
"get_seq_number_from_id",
"(",
"id",
",",
"id_template",
",",
"prefix",
",",
"*",
"*",
"kw",
")",
":",
"separator",
"=",
"kw",
".",
"get",
"(",
"\"separator\"",
",",
"\"-\"",
")",
"postfix",
"=",
"id",
".",
"replace",
"(",
"prefix",
",",
"\"\"",... | Return the sequence number of the given ID | [
"Return",
"the",
"sequence",
"number",
"of",
"the",
"given",
"ID"
] | python | train | 39.666667 |
Qiskit/qiskit-terra | qiskit/transpiler/coupling.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/coupling.py#L115-L124 | def is_connected(self):
"""
Test if the graph is connected.
Return True if connected, False otherwise
"""
try:
return nx.is_weakly_connected(self.graph)
except nx.exception.NetworkXException:
return False | [
"def",
"is_connected",
"(",
"self",
")",
":",
"try",
":",
"return",
"nx",
".",
"is_weakly_connected",
"(",
"self",
".",
"graph",
")",
"except",
"nx",
".",
"exception",
".",
"NetworkXException",
":",
"return",
"False"
] | Test if the graph is connected.
Return True if connected, False otherwise | [
"Test",
"if",
"the",
"graph",
"is",
"connected",
"."
] | python | test | 26.8 |
theislab/scvelo | scvelo/preprocessing/moments.py | https://github.com/theislab/scvelo/blob/c7a96d70edfe705e86bf364434a9527d4fd8df11/scvelo/preprocessing/moments.py#L10-L61 | def moments(data, n_neighbors=30, n_pcs=30, mode='connectivities', method='umap', metric='euclidean', use_rep=None,
recurse_neighbors=False, renormalize=False, copy=False):
"""Computes moments for velocity estimation.
Arguments
---------
data: :class:`~anndata.AnnData`
Annotated dat... | [
"def",
"moments",
"(",
"data",
",",
"n_neighbors",
"=",
"30",
",",
"n_pcs",
"=",
"30",
",",
"mode",
"=",
"'connectivities'",
",",
"method",
"=",
"'umap'",
",",
"metric",
"=",
"'euclidean'",
",",
"use_rep",
"=",
"None",
",",
"recurse_neighbors",
"=",
"Fal... | Computes moments for velocity estimation.
Arguments
---------
data: :class:`~anndata.AnnData`
Annotated data matrix.
n_neighbors: `int` (default: 30)
Number of neighbors to use.
n_pcs: `int` (default: 30)
Number of principal components to use.
mode: `'connectivities'` or... | [
"Computes",
"moments",
"for",
"velocity",
"estimation",
"."
] | python | train | 47.461538 |
Microsoft/nni | src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/networkmorphism_tuner.py#L213-L228 | def update(self, other_info, graph, metric_value, model_id):
""" Update the controller with evaluation result of a neural architecture.
Parameters
----------
other_info: any object
In our case it is the father ID in the search tree.
graph: Graph
An instan... | [
"def",
"update",
"(",
"self",
",",
"other_info",
",",
"graph",
",",
"metric_value",
",",
"model_id",
")",
":",
"father_id",
"=",
"other_info",
"self",
".",
"bo",
".",
"fit",
"(",
"[",
"graph",
".",
"extract_descriptor",
"(",
")",
"]",
",",
"[",
"metric... | Update the controller with evaluation result of a neural architecture.
Parameters
----------
other_info: any object
In our case it is the father ID in the search tree.
graph: Graph
An instance of Graph. The trained neural architecture.
metric_value: float... | [
"Update",
"the",
"controller",
"with",
"evaluation",
"result",
"of",
"a",
"neural",
"architecture",
"."
] | python | train | 37.625 |
LonamiWebs/Telethon | telethon/tl/custom/messagebutton.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/tl/custom/messagebutton.py#L57-L60 | def url(self):
"""The url ``str`` for :tl:`KeyboardButtonUrl` objects."""
if isinstance(self.button, types.KeyboardButtonUrl):
return self.button.url | [
"def",
"url",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"button",
",",
"types",
".",
"KeyboardButtonUrl",
")",
":",
"return",
"self",
".",
"button",
".",
"url"
] | The url ``str`` for :tl:`KeyboardButtonUrl` objects. | [
"The",
"url",
"str",
"for",
":",
"tl",
":",
"KeyboardButtonUrl",
"objects",
"."
] | python | train | 43.5 |
istresearch/scrapy-cluster | redis-monitor/plugins/stats_monitor.py | https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/redis-monitor/plugins/stats_monitor.py#L109-L146 | def _get_plugin_stats(self, name):
'''
Used for getting stats for Plugin based stuff, like Kafka Monitor
and Redis Monitor
@param name: the main class stats name
@return: A formatted dict of stats
'''
the_dict = {}
keys = self.redis_conn.keys('stats:{n}:... | [
"def",
"_get_plugin_stats",
"(",
"self",
",",
"name",
")",
":",
"the_dict",
"=",
"{",
"}",
"keys",
"=",
"self",
".",
"redis_conn",
".",
"keys",
"(",
"'stats:{n}:*'",
".",
"format",
"(",
"n",
"=",
"name",
")",
")",
"for",
"key",
"in",
"keys",
":",
"... | Used for getting stats for Plugin based stuff, like Kafka Monitor
and Redis Monitor
@param name: the main class stats name
@return: A formatted dict of stats | [
"Used",
"for",
"getting",
"stats",
"for",
"Plugin",
"based",
"stuff",
"like",
"Kafka",
"Monitor",
"and",
"Redis",
"Monitor"
] | python | train | 36.394737 |
singularityhub/sregistry-cli | sregistry/main/__template__/push.py | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/__template__/push.py#L28-L52 | def push(self, path, name, tag=None):
'''push an image to Singularity Registry
path: should correspond to an absolte image path (or derive it)
name: should be the complete uri that the user has requested to push.
tag: should correspond with an image tag. This is provided to mirror Docker
'''
... | [
"def",
"push",
"(",
"self",
",",
"path",
",",
"name",
",",
"tag",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"bot",
".",
"debug",
"(",
"\"PUSH %s\"",
"%",
"path",
")",
"if",
"not",
"os",
".",
"path"... | push an image to Singularity Registry
path: should correspond to an absolte image path (or derive it)
name: should be the complete uri that the user has requested to push.
tag: should correspond with an image tag. This is provided to mirror Docker | [
"push",
"an",
"image",
"to",
"Singularity",
"Registry",
"path",
":",
"should",
"correspond",
"to",
"an",
"absolte",
"image",
"path",
"(",
"or",
"derive",
"it",
")",
"name",
":",
"should",
"be",
"the",
"complete",
"uri",
"that",
"the",
"user",
"has",
"req... | python | test | 37 |
python-diamond/Diamond | src/diamond/handler/graphite.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphite.py#L126-L142 | def _send_data(self, data):
"""
Try to send all data in buffer.
"""
try:
self.socket.sendall(data)
self._reset_errors()
except:
self._close()
self._throttle_error("GraphiteHandler: Socket error, "
"t... | [
"def",
"_send_data",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"self",
".",
"socket",
".",
"sendall",
"(",
"data",
")",
"self",
".",
"_reset_errors",
"(",
")",
"except",
":",
"self",
".",
"_close",
"(",
")",
"self",
".",
"_throttle_error",
"(",... | Try to send all data in buffer. | [
"Try",
"to",
"send",
"all",
"data",
"in",
"buffer",
"."
] | python | train | 28.529412 |
markovmodel/msmtools | msmtools/estimation/sparse/prior.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/estimation/sparse/prior.py#L86-L117 | def prior_rev(C, alpha=-1.0):
r"""Prior counts for sampling of reversible transition
matrices.
Prior is defined as
b_ij= alpha if i<=j
b_ij=0 else
The reversible prior adds -1 to the upper triagular part of
the given count matrix. This prior respects the fact that
for a revers... | [
"def",
"prior_rev",
"(",
"C",
",",
"alpha",
"=",
"-",
"1.0",
")",
":",
"ind",
"=",
"np",
".",
"triu_indices",
"(",
"C",
".",
"shape",
"[",
"0",
"]",
")",
"B",
"=",
"np",
".",
"zeros",
"(",
"C",
".",
"shape",
")",
"B",
"[",
"ind",
"]",
"=",
... | r"""Prior counts for sampling of reversible transition
matrices.
Prior is defined as
b_ij= alpha if i<=j
b_ij=0 else
The reversible prior adds -1 to the upper triagular part of
the given count matrix. This prior respects the fact that
for a reversible transition matrix the degrees... | [
"r",
"Prior",
"counts",
"for",
"sampling",
"of",
"reversible",
"transition",
"matrices",
"."
] | python | train | 24.1875 |
GemHQ/round-py | round/__init__.py | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/__init__.py#L65-L89 | def authorizer(self, schemes, resource, action, request_args):
"""Construct the Authorization header for a request.
Args:
schemes (list of str): Authentication schemes supported for the
requested action.
resource (str): Object upon which an action is being performed.
... | [
"def",
"authorizer",
"(",
"self",
",",
"schemes",
",",
"resource",
",",
"action",
",",
"request_args",
")",
":",
"if",
"not",
"schemes",
":",
"return",
"u''",
",",
"u''",
"for",
"scheme",
"in",
"schemes",
":",
"if",
"scheme",
"in",
"self",
".",
"scheme... | Construct the Authorization header for a request.
Args:
schemes (list of str): Authentication schemes supported for the
requested action.
resource (str): Object upon which an action is being performed.
action (str): Action being performed.
request_args (list ... | [
"Construct",
"the",
"Authorization",
"header",
"for",
"a",
"request",
"."
] | python | train | 42.76 |
thieman/dagobah | dagobah/daemon/daemon.py | https://github.com/thieman/dagobah/blob/e624180c2291034960302c9e0b818b65b5a7ee11/dagobah/daemon/daemon.py#L27-L42 | def replace_nones(dict_or_list):
"""Update a dict or list in place to replace
'none' string values with Python None."""
def replace_none_in_value(value):
if isinstance(value, basestring) and value.lower() == "none":
return None
return value
items = dict_or_list.iteritems() ... | [
"def",
"replace_nones",
"(",
"dict_or_list",
")",
":",
"def",
"replace_none_in_value",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"basestring",
")",
"and",
"value",
".",
"lower",
"(",
")",
"==",
"\"none\"",
":",
"return",
"None",
"retur... | Update a dict or list in place to replace
'none' string values with Python None. | [
"Update",
"a",
"dict",
"or",
"list",
"in",
"place",
"to",
"replace",
"none",
"string",
"values",
"with",
"Python",
"None",
"."
] | python | train | 34.9375 |
allenai/allennlp | allennlp/semparse/type_declarations/wikitables_lambda_dcs.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/type_declarations/wikitables_lambda_dcs.py#L83-L123 | def resolve(self, other: Type) -> Optional[Type]:
"""See ``PlaceholderType.resolve``"""
if not isinstance(other, NltkComplexType):
return None
expected_second = ComplexType(NUMBER_TYPE,
ComplexType(ANY_TYPE, ComplexType(ComplexType(ANY_TYPE, ANY_... | [
"def",
"resolve",
"(",
"self",
",",
"other",
":",
"Type",
")",
"->",
"Optional",
"[",
"Type",
"]",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"NltkComplexType",
")",
":",
"return",
"None",
"expected_second",
"=",
"ComplexType",
"(",
"NUMBER_TYPE",
... | See ``PlaceholderType.resolve`` | [
"See",
"PlaceholderType",
".",
"resolve"
] | python | train | 48.682927 |
evandempsey/fp-growth | pyfpgrowth/pyfpgrowth.py | https://github.com/evandempsey/fp-growth/blob/6bf4503024e86c5bbea8a05560594f2f7f061c15/pyfpgrowth/pyfpgrowth.py#L148-L155 | def mine_patterns(self, threshold):
"""
Mine the constructed FP tree for frequent patterns.
"""
if self.tree_has_single_path(self.root):
return self.generate_pattern_list()
else:
return self.zip_patterns(self.mine_sub_trees(threshold)) | [
"def",
"mine_patterns",
"(",
"self",
",",
"threshold",
")",
":",
"if",
"self",
".",
"tree_has_single_path",
"(",
"self",
".",
"root",
")",
":",
"return",
"self",
".",
"generate_pattern_list",
"(",
")",
"else",
":",
"return",
"self",
".",
"zip_patterns",
"(... | Mine the constructed FP tree for frequent patterns. | [
"Mine",
"the",
"constructed",
"FP",
"tree",
"for",
"frequent",
"patterns",
"."
] | python | train | 36.5 |
hazelcast/hazelcast-python-client | hazelcast/proxy/map.py | https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/map.py#L544-L574 | def put_if_absent(self, key, value, ttl=-1):
"""
Associates the specified key with the given value if it is not already associated. If ttl is provided, entry
will expire and get evicted after the ttl.
This is equivalent to:
>>> if not map.contains_key(key):
>>> ... | [
"def",
"put_if_absent",
"(",
"self",
",",
"key",
",",
"value",
",",
"ttl",
"=",
"-",
"1",
")",
":",
"check_not_none",
"(",
"key",
",",
"\"key can't be None\"",
")",
"check_not_none",
"(",
"value",
",",
"\"value can't be None\"",
")",
"key_data",
"=",
"self",... | Associates the specified key with the given value if it is not already associated. If ttl is provided, entry
will expire and get evicted after the ttl.
This is equivalent to:
>>> if not map.contains_key(key):
>>> return map.put(key,value)
>>> else:
>>... | [
"Associates",
"the",
"specified",
"key",
"with",
"the",
"given",
"value",
"if",
"it",
"is",
"not",
"already",
"associated",
".",
"If",
"ttl",
"is",
"provided",
"entry",
"will",
"expire",
"and",
"get",
"evicted",
"after",
"the",
"ttl",
"."
] | python | train | 44.774194 |
6809/MC6809 | MC6809/components/mc6809_ops_logic.py | https://github.com/6809/MC6809/blob/6ba2f5106df46689017b5d0b6d84d43b7ee6a240/MC6809/components/mc6809_ops_logic.py#L292-L300 | def instruction_ROL_memory(self, opcode, ea, m):
""" Rotate memory left """
r = self.ROL(m)
# log.debug("$%x ROL memory value $%x << 1 | Carry = $%x and write it to $%x \t| %s" % (
# self.program_counter,
# m, r, ea,
# self.cfg.mem_info.get_shortest(ea)
# )... | [
"def",
"instruction_ROL_memory",
"(",
"self",
",",
"opcode",
",",
"ea",
",",
"m",
")",
":",
"r",
"=",
"self",
".",
"ROL",
"(",
"m",
")",
"# log.debug(\"$%x ROL memory value $%x << 1 | Carry = $%x and write it to $%x \\t| %s\" % (",
"# self.program_counter,... | Rotate memory left | [
"Rotate",
"memory",
"left"
] | python | train | 37.888889 |
JoeVirtual/KonFoo | konfoo/options.py | https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/options.py#L72-L87 | def verbose_option(default=False):
""" Attaches the option ``verbose`` with its *default* value to the
keyword arguments when the option does not exist. All positional
arguments and keyword arguments are forwarded unchanged.
"""
def decorator(method):
@wraps(method)
def wrapper(*arg... | [
"def",
"verbose_option",
"(",
"default",
"=",
"False",
")",
":",
"def",
"decorator",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"option",
"=",
"Option",
".",
"ve... | Attaches the option ``verbose`` with its *default* value to the
keyword arguments when the option does not exist. All positional
arguments and keyword arguments are forwarded unchanged. | [
"Attaches",
"the",
"option",
"verbose",
"with",
"its",
"*",
"default",
"*",
"value",
"to",
"the",
"keyword",
"arguments",
"when",
"the",
"option",
"does",
"not",
"exist",
".",
"All",
"positional",
"arguments",
"and",
"keyword",
"arguments",
"are",
"forwarded",... | python | train | 32 |
pantsbuild/pants | src/python/pants/init/extension_loader.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/init/extension_loader.py#L99-L112 | def load_build_configuration_from_source(build_configuration, backends=None):
"""Installs pants backend packages to provide BUILD file symbols and cli goals.
:param BuildConfiguration build_configuration: The BuildConfiguration (for adding aliases).
:param backends: An optional list of additional packages to loa... | [
"def",
"load_build_configuration_from_source",
"(",
"build_configuration",
",",
"backends",
"=",
"None",
")",
":",
"# pants.build_graph and pants.core_task must always be loaded, and before any other backends.",
"# TODO: Consider replacing the \"backend\" nomenclature here. pants.build_graph a... | Installs pants backend packages to provide BUILD file symbols and cli goals.
:param BuildConfiguration build_configuration: The BuildConfiguration (for adding aliases).
:param backends: An optional list of additional packages to load backends from.
:raises: :class:``pants.base.exceptions.BuildConfigurationError`... | [
"Installs",
"pants",
"backend",
"packages",
"to",
"provide",
"BUILD",
"file",
"symbols",
"and",
"cli",
"goals",
"."
] | python | train | 62.357143 |
cqparts/cqparts | src/cqparts_fasteners/solidtypes/threads/base.py | https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/threads/base.py#L26-L204 | def profile_to_cross_section(profile, lefthand=False, start_count=1, min_vertices=20):
r"""
Converts a thread profile to it's equivalent cross-section.
**Profile:**
The thread profile contains a single wire along the XZ plane
(note: wire will be projected onto the XZ plane; Y-coords will be ignore... | [
"def",
"profile_to_cross_section",
"(",
"profile",
",",
"lefthand",
"=",
"False",
",",
"start_count",
"=",
"1",
",",
"min_vertices",
"=",
"20",
")",
":",
"# verify parameter(s)",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"cadquery",
".",
"Workplane",
")"... | r"""
Converts a thread profile to it's equivalent cross-section.
**Profile:**
The thread profile contains a single wire along the XZ plane
(note: wire will be projected onto the XZ plane; Y-coords will be ignored).
The profile is expected to be of 1 thread rotation, so it's height
(along the Z... | [
"r",
"Converts",
"a",
"thread",
"profile",
"to",
"it",
"s",
"equivalent",
"cross",
"-",
"section",
"."
] | python | train | 39.083799 |
bfarr/kombine | examples/kepler/correlated_likelihood.py | https://github.com/bfarr/kombine/blob/50c946dee5da33e7baab71d9bd6c265ff02ffb13/examples/kepler/correlated_likelihood.py#L8-L23 | def generate_covariance(ts, sigma, tau):
r"""Generates a covariance matrix according to an
squared-exponential autocovariance
.. math::
\left\langle x_i x_j \right\rangle = \sigma_0^2 \delta_{ij} + \sigma^2 \exp\left[ - \frac{\left| t_i - t_j\right|^2}{2 \tau^2} \right]
"""
ndim = ... | [
"def",
"generate_covariance",
"(",
"ts",
",",
"sigma",
",",
"tau",
")",
":",
"ndim",
"=",
"ts",
".",
"shape",
"[",
"0",
"]",
"tis",
"=",
"ts",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"tjs",
"=",
"ts",
"[",
"np",
".",
"newaxis",
",",
":",
"]... | r"""Generates a covariance matrix according to an
squared-exponential autocovariance
.. math::
\left\langle x_i x_j \right\rangle = \sigma_0^2 \delta_{ij} + \sigma^2 \exp\left[ - \frac{\left| t_i - t_j\right|^2}{2 \tau^2} \right] | [
"r",
"Generates",
"a",
"covariance",
"matrix",
"according",
"to",
"an",
"squared",
"-",
"exponential",
"autocovariance",
"..",
"math",
"::",
"\\",
"left",
"\\",
"langle",
"x_i",
"x_j",
"\\",
"right",
"\\",
"rangle",
"=",
"\\",
"sigma_0^2",
"\\",
"delta_",
... | python | train | 27.4375 |
binux/pyspider | pyspider/libs/response.py | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L129-L137 | def json(self):
"""Returns the json-encoded content of the response, if any."""
if hasattr(self, '_json'):
return self._json
try:
self._json = json.loads(self.text or self.content)
except ValueError:
self._json = None
return self._json | [
"def",
"json",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_json'",
")",
":",
"return",
"self",
".",
"_json",
"try",
":",
"self",
".",
"_json",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"text",
"or",
"self",
".",
"content",
")"... | Returns the json-encoded content of the response, if any. | [
"Returns",
"the",
"json",
"-",
"encoded",
"content",
"of",
"the",
"response",
"if",
"any",
"."
] | python | train | 33.666667 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.