repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
wummel/dosage | dosagelib/plugins/s.py | https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/plugins/s.py#L332-L336 | def namer(cls, imageUrl, pageUrl):
"""Use strip index number for image name."""
index = int(compile(r'id=(\d+)').search(pageUrl).group(1))
ext = imageUrl.rsplit('.', 1)[1]
return "SnowFlakes-%d.%s" % (index, ext) | [
"def",
"namer",
"(",
"cls",
",",
"imageUrl",
",",
"pageUrl",
")",
":",
"index",
"=",
"int",
"(",
"compile",
"(",
"r'id=(\\d+)'",
")",
".",
"search",
"(",
"pageUrl",
")",
".",
"group",
"(",
"1",
")",
")",
"ext",
"=",
"imageUrl",
".",
"rsplit",
"(",
... | Use strip index number for image name. | [
"Use",
"strip",
"index",
"number",
"for",
"image",
"name",
"."
] | python | train |
guaix-ucm/numina | numina/array/display/iofunctions.py | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/display/iofunctions.py#L140-L256 | def read_value(ftype, prompt, default=None, minval=None, maxval=None,
allowed_single_chars=None, question_mark=True):
"""Return value read from keyboard
Parameters
----------
ftype : int() or float()
Function defining the expected type.
prompt : str
Prompt string.
... | [
"def",
"read_value",
"(",
"ftype",
",",
"prompt",
",",
"default",
"=",
"None",
",",
"minval",
"=",
"None",
",",
"maxval",
"=",
"None",
",",
"allowed_single_chars",
"=",
"None",
",",
"question_mark",
"=",
"True",
")",
":",
"# avoid PyCharm warning 'might be ref... | Return value read from keyboard
Parameters
----------
ftype : int() or float()
Function defining the expected type.
prompt : str
Prompt string.
default : int or None
Default value.
minval : int or None
Mininum allowed value.
maxval : int or None
Maxim... | [
"Return",
"value",
"read",
"from",
"keyboard"
] | python | train |
opencobra/memote | memote/support/helpers.py | https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/helpers.py#L664-L764 | def find_met_in_model(model, mnx_id, compartment_id=None):
"""
Return specific metabolites by looking up IDs in METANETX_SHORTLIST.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
mnx_id : string
Memote internal MetaNetX metabolite identifier u... | [
"def",
"find_met_in_model",
"(",
"model",
",",
"mnx_id",
",",
"compartment_id",
"=",
"None",
")",
":",
"def",
"compare_annotation",
"(",
"annotation",
")",
":",
"\"\"\"\n Return annotation IDs that match to METANETX_SHORTLIST references.\n\n Compares the set of META... | Return specific metabolites by looking up IDs in METANETX_SHORTLIST.
Parameters
----------
model : cobra.Model
The metabolic model under investigation.
mnx_id : string
Memote internal MetaNetX metabolite identifier used to map between
cross-references in the METANETX_SHORTLIST.
... | [
"Return",
"specific",
"metabolites",
"by",
"looking",
"up",
"IDs",
"in",
"METANETX_SHORTLIST",
"."
] | python | train |
Gorialis/jishaku | jishaku/cog.py | https://github.com/Gorialis/jishaku/blob/fc7c479b9d510ede189a929c8aa6f7c8ef7f9a6e/jishaku/cog.py#L175-L184 | async def jsk_hide(self, ctx: commands.Context):
"""
Hides Jishaku from the help command.
"""
if self.jsk.hidden:
return await ctx.send("Jishaku is already hidden.")
self.jsk.hidden = True
await ctx.send("Jishaku is now hidden.") | [
"async",
"def",
"jsk_hide",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
")",
":",
"if",
"self",
".",
"jsk",
".",
"hidden",
":",
"return",
"await",
"ctx",
".",
"send",
"(",
"\"Jishaku is already hidden.\"",
")",
"self",
".",
"jsk",
".",
"h... | Hides Jishaku from the help command. | [
"Hides",
"Jishaku",
"from",
"the",
"help",
"command",
"."
] | python | train |
JdeRobot/base | src/libs/comm_py/comm/ros/listenerLaser.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/libs/comm_py/comm/ros/listenerLaser.py#L79-L84 | def start (self):
'''
Starts (Subscribes) the client.
'''
self.sub = rospy.Subscriber(self.topic, LaserScan, self.__callback) | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"sub",
"=",
"rospy",
".",
"Subscriber",
"(",
"self",
".",
"topic",
",",
"LaserScan",
",",
"self",
".",
"__callback",
")"
] | Starts (Subscribes) the client. | [
"Starts",
"(",
"Subscribes",
")",
"the",
"client",
"."
] | python | train |
richardchien/python-cqhttp | cqhttp_helper.py | https://github.com/richardchien/python-cqhttp/blob/1869819a8f89001e3f70668e31afc6c78f7f5bc2/cqhttp_helper.py#L212-L225 | def send_private_msg(self, *, user_id, message, auto_escape=False):
'''
发送私聊消息
------------
:param int user_id: 对方 QQ 号
:param str | list[ dict[ str, unknown ] ] message: 要发送的内容
:param bool auto_escape: 消息内容是否作为纯文本发送(即不解析 CQ 码),`message` 数据类型为 `list` 时无效
:return... | [
"def",
"send_private_msg",
"(",
"self",
",",
"*",
",",
"user_id",
",",
"message",
",",
"auto_escape",
"=",
"False",
")",
":",
"return",
"super",
"(",
")",
".",
"__getattr__",
"(",
"'send_private_msg'",
")",
"(",
"user_id",
"=",
"user_id",
",",
"message",
... | 发送私聊消息
------------
:param int user_id: 对方 QQ 号
:param str | list[ dict[ str, unknown ] ] message: 要发送的内容
:param bool auto_escape: 消息内容是否作为纯文本发送(即不解析 CQ 码),`message` 数据类型为 `list` 时无效
:return: {"message_id": int 消息ID}
:rtype: dict[string, int] | [
"发送私聊消息"
] | python | valid |
msiemens/tinydb | tinydb/database.py | https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L179-L200 | def table(self, name=DEFAULT_TABLE, **options):
"""
Get access to a specific table.
Creates a new table, if it hasn't been created before, otherwise it
returns the cached :class:`~tinydb.Table` object.
:param name: The name of the table.
:type name: str
:param c... | [
"def",
"table",
"(",
"self",
",",
"name",
"=",
"DEFAULT_TABLE",
",",
"*",
"*",
"options",
")",
":",
"if",
"name",
"in",
"self",
".",
"_table_cache",
":",
"return",
"self",
".",
"_table_cache",
"[",
"name",
"]",
"table_class",
"=",
"options",
".",
"pop"... | Get access to a specific table.
Creates a new table, if it hasn't been created before, otherwise it
returns the cached :class:`~tinydb.Table` object.
:param name: The name of the table.
:type name: str
:param cache_size: How many query results to cache.
:param table_cla... | [
"Get",
"access",
"to",
"a",
"specific",
"table",
"."
] | python | train |
corydolphin/flask-cors | flask_cors/core.py | https://github.com/corydolphin/flask-cors/blob/13fbb1ea4c1bb422de91a726c3c7f1038d3743a3/flask_cors/core.py#L283-L295 | def get_cors_options(appInstance, *dicts):
"""
Compute CORS options for an application by combining the DEFAULT_OPTIONS,
the app's configuration-specified options and any dictionaries passed. The
last specified option wins.
"""
options = DEFAULT_OPTIONS.copy()
options.update(get_app_kwarg_di... | [
"def",
"get_cors_options",
"(",
"appInstance",
",",
"*",
"dicts",
")",
":",
"options",
"=",
"DEFAULT_OPTIONS",
".",
"copy",
"(",
")",
"options",
".",
"update",
"(",
"get_app_kwarg_dict",
"(",
"appInstance",
")",
")",
"if",
"dicts",
":",
"for",
"d",
"in",
... | Compute CORS options for an application by combining the DEFAULT_OPTIONS,
the app's configuration-specified options and any dictionaries passed. The
last specified option wins. | [
"Compute",
"CORS",
"options",
"for",
"an",
"application",
"by",
"combining",
"the",
"DEFAULT_OPTIONS",
"the",
"app",
"s",
"configuration",
"-",
"specified",
"options",
"and",
"any",
"dictionaries",
"passed",
".",
"The",
"last",
"specified",
"option",
"wins",
"."... | python | valid |
GNS3/gns3-server | gns3server/compute/dynamips/nios/nio.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nios/nio.py#L95-L119 | def bind_filter(self, direction, filter_name):
"""
Adds a packet filter to this NIO.
Filter "freq_drop" drops packets.
Filter "capture" captures packets.
:param direction: "in", "out" or "both"
:param filter_name: name of the filter to apply
"""
if direc... | [
"def",
"bind_filter",
"(",
"self",
",",
"direction",
",",
"filter_name",
")",
":",
"if",
"direction",
"not",
"in",
"self",
".",
"_dynamips_direction",
":",
"raise",
"DynamipsError",
"(",
"\"Unknown direction {} to bind filter {}:\"",
".",
"format",
"(",
"direction",... | Adds a packet filter to this NIO.
Filter "freq_drop" drops packets.
Filter "capture" captures packets.
:param direction: "in", "out" or "both"
:param filter_name: name of the filter to apply | [
"Adds",
"a",
"packet",
"filter",
"to",
"this",
"NIO",
".",
"Filter",
"freq_drop",
"drops",
"packets",
".",
"Filter",
"capture",
"captures",
"packets",
"."
] | python | train |
huyingxi/Synonyms | synonyms/utils.py | https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L255-L259 | def is_digit(obj):
'''
Check if an object is Number
'''
return isinstance(obj, (numbers.Integral, numbers.Complex, numbers.Real)) | [
"def",
"is_digit",
"(",
"obj",
")",
":",
"return",
"isinstance",
"(",
"obj",
",",
"(",
"numbers",
".",
"Integral",
",",
"numbers",
".",
"Complex",
",",
"numbers",
".",
"Real",
")",
")"
] | Check if an object is Number | [
"Check",
"if",
"an",
"object",
"is",
"Number"
] | python | train |
JosuaKrause/quick_server | quick_server/quick_server.py | https://github.com/JosuaKrause/quick_server/blob/55dc7c5fe726a341f8476f749fe0f9da156fc1cb/quick_server/quick_server.py#L2768-L2785 | def can_ignore_error(self, reqhnd=None):
"""Tests if the error is worth reporting.
"""
value = sys.exc_info()[1]
try:
if isinstance(value, BrokenPipeError) or \
isinstance(value, ConnectionResetError):
return True
except NameError:
... | [
"def",
"can_ignore_error",
"(",
"self",
",",
"reqhnd",
"=",
"None",
")",
":",
"value",
"=",
"sys",
".",
"exc_info",
"(",
")",
"[",
"1",
"]",
"try",
":",
"if",
"isinstance",
"(",
"value",
",",
"BrokenPipeError",
")",
"or",
"isinstance",
"(",
"value",
... | Tests if the error is worth reporting. | [
"Tests",
"if",
"the",
"error",
"is",
"worth",
"reporting",
"."
] | python | train |
tango-controls/pytango | tango/databaseds/database.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/databaseds/database.py#L416-L444 | def DbDeleteDeviceAttributeProperty(self, argin):
""" delete a device attribute property from the database
:param argin: Str[0] = Device name
Str[1] = Attribute name
Str[2] = Property name
Str[n] = Property name
:type: tango.DevVarStringArray
:return:
:rt... | [
"def",
"DbDeleteDeviceAttributeProperty",
"(",
"self",
",",
"argin",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"In DbDeleteDeviceAttributeProperty()\"",
")",
"if",
"len",
"(",
"argin",
")",
"<",
"3",
":",
"self",
".",
"warn_stream",
"(",
"\"DataBase:... | delete a device attribute property from the database
:param argin: Str[0] = Device name
Str[1] = Attribute name
Str[2] = Property name
Str[n] = Property name
:type: tango.DevVarStringArray
:return:
:rtype: tango.DevVoid | [
"delete",
"a",
"device",
"attribute",
"property",
"from",
"the",
"database"
] | python | train |
ihmeuw/vivarium | src/vivarium/framework/randomness.py | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/randomness.py#L659-L675 | def register_simulants(self, simulants: pd.DataFrame):
"""Adds new simulants to the randomness mapping.
Parameters
----------
simulants :
A table with state data representing the new simulants. Each simulant should
pass through this function exactly once.
... | [
"def",
"register_simulants",
"(",
"self",
",",
"simulants",
":",
"pd",
".",
"DataFrame",
")",
":",
"if",
"not",
"all",
"(",
"k",
"in",
"simulants",
".",
"columns",
"for",
"k",
"in",
"self",
".",
"_key_columns",
")",
":",
"raise",
"RandomnessError",
"(",
... | Adds new simulants to the randomness mapping.
Parameters
----------
simulants :
A table with state data representing the new simulants. Each simulant should
pass through this function exactly once.
Raises
------
RandomnessError :
If ... | [
"Adds",
"new",
"simulants",
"to",
"the",
"randomness",
"mapping",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xganttwidget/xganttwidgetitem.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xganttwidget/xganttwidgetitem.py#L402-L419 | def setItemStyle(self, itemStyle):
"""
Sets the item style that will be used for this widget. If you are
trying to set a style on an item that has children, make sure to turn
off the useGroupStyleWithChildren option, or it will always display as
a group.
... | [
"def",
"setItemStyle",
"(",
"self",
",",
"itemStyle",
")",
":",
"self",
".",
"_itemStyle",
"=",
"itemStyle",
"# initialize the group icon for group style\r",
"if",
"itemStyle",
"==",
"XGanttWidgetItem",
".",
"ItemStyle",
".",
"Group",
"and",
"self",
".",
"icon",
"... | Sets the item style that will be used for this widget. If you are
trying to set a style on an item that has children, make sure to turn
off the useGroupStyleWithChildren option, or it will always display as
a group.
:param itemStyle | <XGanttWidgetItem.ItemStyle> | [
"Sets",
"the",
"item",
"style",
"that",
"will",
"be",
"used",
"for",
"this",
"widget",
".",
"If",
"you",
"are",
"trying",
"to",
"set",
"a",
"style",
"on",
"an",
"item",
"that",
"has",
"children",
"make",
"sure",
"to",
"turn",
"off",
"the",
"useGroupSty... | python | train |
saltstack/salt | salt/modules/neutron.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/neutron.py#L348-L366 | def update_port(port, name, admin_state_up=True, profile=None):
'''
Updates a port
CLI Example:
.. code-block:: bash
salt '*' neutron.update_port port-name network-name new-port-name
:param port: Port name or ID
:param name: Name of this port
:param admin_state_up: Set admin stat... | [
"def",
"update_port",
"(",
"port",
",",
"name",
",",
"admin_state_up",
"=",
"True",
",",
"profile",
"=",
"None",
")",
":",
"conn",
"=",
"_auth",
"(",
"profile",
")",
"return",
"conn",
".",
"update_port",
"(",
"port",
",",
"name",
",",
"admin_state_up",
... | Updates a port
CLI Example:
.. code-block:: bash
salt '*' neutron.update_port port-name network-name new-port-name
:param port: Port name or ID
:param name: Name of this port
:param admin_state_up: Set admin state up to true or false,
default: true (Optional)
:param profi... | [
"Updates",
"a",
"port"
] | python | train |
ronhanson/python-tbx | tbx/text.py | https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/text.py#L310-L318 | def dict_to_xml(xml_dict):
"""
Converts a dictionary to an XML ElementTree Element
"""
import lxml.etree as etree
root_tag = list(xml_dict.keys())[0]
root = etree.Element(root_tag)
_dict_to_xml_recurse(root, xml_dict[root_tag])
return root | [
"def",
"dict_to_xml",
"(",
"xml_dict",
")",
":",
"import",
"lxml",
".",
"etree",
"as",
"etree",
"root_tag",
"=",
"list",
"(",
"xml_dict",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"root",
"=",
"etree",
".",
"Element",
"(",
"root_tag",
")",
"_dict_to... | Converts a dictionary to an XML ElementTree Element | [
"Converts",
"a",
"dictionary",
"to",
"an",
"XML",
"ElementTree",
"Element"
] | python | train |
pandas-dev/pandas | pandas/core/computation/expr.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/expr.py#L94-L116 | def _replace_locals(tok):
"""Replace local variables with a syntactically valid name.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple of int, str
Either the input or token or the replac... | [
"def",
"_replace_locals",
"(",
"tok",
")",
":",
"toknum",
",",
"tokval",
"=",
"tok",
"if",
"toknum",
"==",
"tokenize",
".",
"OP",
"and",
"tokval",
"==",
"'@'",
":",
"return",
"tokenize",
".",
"OP",
",",
"_LOCAL_TAG",
"return",
"toknum",
",",
"tokval"
] | Replace local variables with a syntactically valid name.
Parameters
----------
tok : tuple of int, str
ints correspond to the all caps constants in the tokenize module
Returns
-------
t : tuple of int, str
Either the input or token or the replacement values
Notes
-----... | [
"Replace",
"local",
"variables",
"with",
"a",
"syntactically",
"valid",
"name",
"."
] | python | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/build.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/build.py#L105-L152 | def compile_pycos(toc):
"""Given a TOC or equivalent list of tuples, generates all the required
pyc/pyo files, writing in a local directory if required, and returns the
list of tuples with the updated pathnames.
"""
global BUILDPATH
# For those modules that need to be rebuilt, use the build dir... | [
"def",
"compile_pycos",
"(",
"toc",
")",
":",
"global",
"BUILDPATH",
"# For those modules that need to be rebuilt, use the build directory",
"# PyInstaller creates during the build process.",
"basepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"BUILDPATH",
",",
"\"localpyco... | Given a TOC or equivalent list of tuples, generates all the required
pyc/pyo files, writing in a local directory if required, and returns the
list of tuples with the updated pathnames. | [
"Given",
"a",
"TOC",
"or",
"equivalent",
"list",
"of",
"tuples",
"generates",
"all",
"the",
"required",
"pyc",
"/",
"pyo",
"files",
"writing",
"in",
"a",
"local",
"directory",
"if",
"required",
"and",
"returns",
"the",
"list",
"of",
"tuples",
"with",
"the"... | python | train |
saltstack/salt | salt/cloud/clouds/profitbricks.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/profitbricks.py#L679-L689 | def get_node(conn, name):
'''
Return a node for the named VM
'''
datacenter_id = get_datacenter_id()
for item in conn.list_servers(datacenter_id)['items']:
if item['properties']['name'] == name:
node = {'id': item['id']}
node.update(item['properties'])
re... | [
"def",
"get_node",
"(",
"conn",
",",
"name",
")",
":",
"datacenter_id",
"=",
"get_datacenter_id",
"(",
")",
"for",
"item",
"in",
"conn",
".",
"list_servers",
"(",
"datacenter_id",
")",
"[",
"'items'",
"]",
":",
"if",
"item",
"[",
"'properties'",
"]",
"["... | Return a node for the named VM | [
"Return",
"a",
"node",
"for",
"the",
"named",
"VM"
] | python | train |
tensorflow/probability | tensorflow_probability/python/bijectors/bijector.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/bijector.py#L112-L120 | def _merge(self, old, new, use_equals=False):
"""Helper to merge which handles merging one value."""
if old is None:
return new
if new is None:
return old
if (old == new) if use_equals else (old is new):
return old
raise ValueError("Incompatible values: %s != %s" % (old, new)) | [
"def",
"_merge",
"(",
"self",
",",
"old",
",",
"new",
",",
"use_equals",
"=",
"False",
")",
":",
"if",
"old",
"is",
"None",
":",
"return",
"new",
"if",
"new",
"is",
"None",
":",
"return",
"old",
"if",
"(",
"old",
"==",
"new",
")",
"if",
"use_equa... | Helper to merge which handles merging one value. | [
"Helper",
"to",
"merge",
"which",
"handles",
"merging",
"one",
"value",
"."
] | python | test |
kristianfoerster/melodist | melodist/stationstatistics.py | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L188-L223 | def to_json(self, filename=None):
"""
Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data
"""
def json_encoder(obj):
if isinstance(obj, pd.DataFrame) or isinstance(obj, pd.Series)... | [
"def",
"to_json",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"def",
"json_encoder",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"pd",
".",
"DataFrame",
")",
"or",
"isinstance",
"(",
"obj",
",",
"pd",
".",
"Series",
")",
":"... | Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data | [
"Exports",
"statistical",
"data",
"to",
"a",
"JSON",
"formatted",
"file"
] | python | train |
knaperek/djangosaml2 | djangosaml2/views.py | https://github.com/knaperek/djangosaml2/blob/643969701d3b4257a8d64c5c577602ebaa61de70/djangosaml2/views.py#L362-L408 | def logout(request, config_loader_path=None):
"""SAML Logout Request initiator
This view initiates the SAML2 Logout request
using the pysaml2 library to create the LogoutRequest.
"""
state = StateCache(request.session)
conf = get_config(config_loader_path, request)
client = Saml2Client(con... | [
"def",
"logout",
"(",
"request",
",",
"config_loader_path",
"=",
"None",
")",
":",
"state",
"=",
"StateCache",
"(",
"request",
".",
"session",
")",
"conf",
"=",
"get_config",
"(",
"config_loader_path",
",",
"request",
")",
"client",
"=",
"Saml2Client",
"(",
... | SAML Logout Request initiator
This view initiates the SAML2 Logout request
using the pysaml2 library to create the LogoutRequest. | [
"SAML",
"Logout",
"Request",
"initiator"
] | python | train |
krinj/k-util | k_util/region.py | https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/region.py#L78-L85 | def is_in_bounds(self, width, height) -> bool:
""" Check if this entire region is contained within the bounds of a given stage size."""
if self._top < 0 \
or self._bottom > height \
or self._left < 0 \
or self._right > width:
return False
... | [
"def",
"is_in_bounds",
"(",
"self",
",",
"width",
",",
"height",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_top",
"<",
"0",
"or",
"self",
".",
"_bottom",
">",
"height",
"or",
"self",
".",
"_left",
"<",
"0",
"or",
"self",
".",
"_right",
">",
"wi... | Check if this entire region is contained within the bounds of a given stage size. | [
"Check",
"if",
"this",
"entire",
"region",
"is",
"contained",
"within",
"the",
"bounds",
"of",
"a",
"given",
"stage",
"size",
"."
] | python | train |
coldfix/udiskie | udiskie/config.py | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/config.py#L126-L138 | def value(self, kind, device):
"""
Get the value for the device object associated with this filter.
If :meth:`match` is False for the device, the return value of this
method is undefined.
"""
self._log.debug(_('{0}(match={1!r}, {2}={3!r}) used for {4}',
... | [
"def",
"value",
"(",
"self",
",",
"kind",
",",
"device",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"_",
"(",
"'{0}(match={1!r}, {2}={3!r}) used for {4}'",
",",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"_match",
",",
"kind",
",... | Get the value for the device object associated with this filter.
If :meth:`match` is False for the device, the return value of this
method is undefined. | [
"Get",
"the",
"value",
"for",
"the",
"device",
"object",
"associated",
"with",
"this",
"filter",
"."
] | python | train |
dropbox/stone | stone/backends/python_rsrc/stone_serializers.py | https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/python_rsrc/stone_serializers.py#L582-L612 | def decode_struct(self, data_type, obj):
"""
The data_type argument must be a Struct.
See json_compat_obj_decode() for argument descriptions.
"""
if obj is None and data_type.has_default():
return data_type.get_default()
elif not isinstance(obj, dict):
... | [
"def",
"decode_struct",
"(",
"self",
",",
"data_type",
",",
"obj",
")",
":",
"if",
"obj",
"is",
"None",
"and",
"data_type",
".",
"has_default",
"(",
")",
":",
"return",
"data_type",
".",
"get_default",
"(",
")",
"elif",
"not",
"isinstance",
"(",
"obj",
... | The data_type argument must be a Struct.
See json_compat_obj_decode() for argument descriptions. | [
"The",
"data_type",
"argument",
"must",
"be",
"a",
"Struct",
".",
"See",
"json_compat_obj_decode",
"()",
"for",
"argument",
"descriptions",
"."
] | python | train |
projectshift/shift-boiler | boiler/user/models.py | https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L215-L218 | def lock_account(self, minutes=30):
""" Lock user account for a period """
period = datetime.timedelta(minutes=minutes)
self.locked_until = datetime.datetime.utcnow() + period | [
"def",
"lock_account",
"(",
"self",
",",
"minutes",
"=",
"30",
")",
":",
"period",
"=",
"datetime",
".",
"timedelta",
"(",
"minutes",
"=",
"minutes",
")",
"self",
".",
"locked_until",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"per... | Lock user account for a period | [
"Lock",
"user",
"account",
"for",
"a",
"period"
] | python | train |
Netflix-Skunkworks/swag-client | swag_client/backends/file.py | https://github.com/Netflix-Skunkworks/swag-client/blob/e43816a85c4f48011cf497a4eae14f9df71fee0f/swag_client/backends/file.py#L105-L111 | def get_all(self):
"""Gets all items in file."""
logger.debug('Fetching items. Path: {data_file}'.format(
data_file=self.data_file
))
return load_file(self.data_file) | [
"def",
"get_all",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Fetching items. Path: {data_file}'",
".",
"format",
"(",
"data_file",
"=",
"self",
".",
"data_file",
")",
")",
"return",
"load_file",
"(",
"self",
".",
"data_file",
")"
] | Gets all items in file. | [
"Gets",
"all",
"items",
"in",
"file",
"."
] | python | train |
GGiecold/Cluster_Ensembles | src/Cluster_Ensembles/Cluster_Ensembles.py | https://github.com/GGiecold/Cluster_Ensembles/blob/d1b1ce9f541fc937ac7c677e964520e0e9163dc7/src/Cluster_Ensembles/Cluster_Ensembles.py#L186-L215 | def store_hypergraph_adjacency(hypergraph_adjacency, hdf5_file_name):
"""Write an hypergraph adjacency to disk to disk in an HDF5 data structure.
Parameters
----------
hypergraph_adjacency : compressed sparse row matrix
hdf5_file_name : file handle or string
"""
assert(hypergra... | [
"def",
"store_hypergraph_adjacency",
"(",
"hypergraph_adjacency",
",",
"hdf5_file_name",
")",
":",
"assert",
"(",
"hypergraph_adjacency",
".",
"__class__",
"==",
"scipy",
".",
"sparse",
".",
"csr",
".",
"csr_matrix",
")",
"byte_counts",
"=",
"hypergraph_adjacency",
... | Write an hypergraph adjacency to disk to disk in an HDF5 data structure.
Parameters
----------
hypergraph_adjacency : compressed sparse row matrix
hdf5_file_name : file handle or string | [
"Write",
"an",
"hypergraph",
"adjacency",
"to",
"disk",
"to",
"disk",
"in",
"an",
"HDF5",
"data",
"structure",
".",
"Parameters",
"----------",
"hypergraph_adjacency",
":",
"compressed",
"sparse",
"row",
"matrix",
"hdf5_file_name",
":",
"file",
"handle",
"or",
"... | python | train |
unitedstack/steth | stetho/agent/api.py | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L74-L88 | def add_vlan_to_interface(self, interface, vlan_id):
"""Add vlan interface.
ip link add link eth0 name eth0.10 type vlan id 10
"""
subif = '%s.%s' % (interface, vlan_id)
vlan_id = '%s' % vlan_id
cmd = ['ip', 'link', 'add', 'link', interface, 'name',
subif,... | [
"def",
"add_vlan_to_interface",
"(",
"self",
",",
"interface",
",",
"vlan_id",
")",
":",
"subif",
"=",
"'%s.%s'",
"%",
"(",
"interface",
",",
"vlan_id",
")",
"vlan_id",
"=",
"'%s'",
"%",
"vlan_id",
"cmd",
"=",
"[",
"'ip'",
",",
"'link'",
",",
"'add'",
... | Add vlan interface.
ip link add link eth0 name eth0.10 type vlan id 10 | [
"Add",
"vlan",
"interface",
"."
] | python | train |
abilian/abilian-core | abilian/web/views/object.py | https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/web/views/object.py#L625-L631 | def get_item(self, obj):
"""Return a result item.
:param obj: Instance object
:returns: a dictionnary with at least `id` and `text` values
"""
return {"id": obj.id, "text": self.get_label(obj), "name": obj.name} | [
"def",
"get_item",
"(",
"self",
",",
"obj",
")",
":",
"return",
"{",
"\"id\"",
":",
"obj",
".",
"id",
",",
"\"text\"",
":",
"self",
".",
"get_label",
"(",
"obj",
")",
",",
"\"name\"",
":",
"obj",
".",
"name",
"}"
] | Return a result item.
:param obj: Instance object
:returns: a dictionnary with at least `id` and `text` values | [
"Return",
"a",
"result",
"item",
"."
] | python | train |
onnx/onnxmltools | onnxutils/onnxconverter_common/optimizer.py | https://github.com/onnx/onnxmltools/blob/d4e4c31990fc2d9fd1f92139f497d360914c9df2/onnxutils/onnxconverter_common/optimizer.py#L60-L65 | def in_single_path_and_inner(self):
"""
Test if a node is not linking to any fan in or out node.
"""
return len(self.successor) == 1 and self.successor[0] is not None and not self.successor[0].in_or_out and \
len(self.precedence) == 1 and self.precedence[0] is not None and... | [
"def",
"in_single_path_and_inner",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"successor",
")",
"==",
"1",
"and",
"self",
".",
"successor",
"[",
"0",
"]",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"successor",
"[",
"0",
"]",
".",... | Test if a node is not linking to any fan in or out node. | [
"Test",
"if",
"a",
"node",
"is",
"not",
"linking",
"to",
"any",
"fan",
"in",
"or",
"out",
"node",
"."
] | python | train |
CiscoTestAutomation/yang | ncdiff/src/yang/ncdiff/restconf.py | https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/ncdiff/src/yang/ncdiff/restconf.py#L273-L326 | def get_json(self, instance=True):
'''get_json
High-level api: get_json returns json_val of the config node.
Parameters
----------
instance : `bool`
True if only one instance of list or leaf-list is required. False if
all instances of list or leaf-list ... | [
"def",
"get_json",
"(",
"self",
",",
"instance",
"=",
"True",
")",
":",
"def",
"get_json_instance",
"(",
"node",
")",
":",
"pk",
"=",
"Parker",
"(",
"xml_fromstring",
"=",
"_fromstring",
",",
"dict_type",
"=",
"OrderedDict",
")",
"default_ns",
"=",
"{",
... | get_json
High-level api: get_json returns json_val of the config node.
Parameters
----------
instance : `bool`
True if only one instance of list or leaf-list is required. False if
all instances of list or leaf-list are needed.
Returns
-------
... | [
"get_json"
] | python | train |
wavycloud/pyboto3 | pyboto3/dynamodb.py | https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/dynamodb.py#L2657-L3215 | def query(TableName=None, IndexName=None, Select=None, AttributesToGet=None, Limit=None, ConsistentRead=None, KeyConditions=None, QueryFilter=None, ConditionalOperator=None, ScanIndexForward=None, ExclusiveStartKey=None, ReturnConsumedCapacity=None, ProjectionExpression=None, FilterExpression=None, KeyConditionExpressi... | [
"def",
"query",
"(",
"TableName",
"=",
"None",
",",
"IndexName",
"=",
"None",
",",
"Select",
"=",
"None",
",",
"AttributesToGet",
"=",
"None",
",",
"Limit",
"=",
"None",
",",
"ConsistentRead",
"=",
"None",
",",
"KeyConditions",
"=",
"None",
",",
"QueryFi... | A Query operation uses the primary key of a table or a secondary index to directly access items from that table or index.
Use the KeyConditionExpression parameter to provide a specific value for the partition key. The Query operation will return all of the items from the table or index with that partition key value... | [
"A",
"Query",
"operation",
"uses",
"the",
"primary",
"key",
"of",
"a",
"table",
"or",
"a",
"secondary",
"index",
"to",
"directly",
"access",
"items",
"from",
"that",
"table",
"or",
"index",
".",
"Use",
"the",
"KeyConditionExpression",
"parameter",
"to",
"pro... | python | train |
justanr/flask-allows | src/flask_allows/overrides.py | https://github.com/justanr/flask-allows/blob/39fa5c8692836a33646ea43b4081e7c2181ec7c4/src/flask_allows/overrides.py#L180-L187 | def override(self, override, use_parent=False):
"""
Allows temporarily pushing an override context, yields the new context
into the following block.
"""
self.push(override, use_parent)
yield self.current
self.pop() | [
"def",
"override",
"(",
"self",
",",
"override",
",",
"use_parent",
"=",
"False",
")",
":",
"self",
".",
"push",
"(",
"override",
",",
"use_parent",
")",
"yield",
"self",
".",
"current",
"self",
".",
"pop",
"(",
")"
] | Allows temporarily pushing an override context, yields the new context
into the following block. | [
"Allows",
"temporarily",
"pushing",
"an",
"override",
"context",
"yields",
"the",
"new",
"context",
"into",
"the",
"following",
"block",
"."
] | python | test |
fake-name/ChromeController | ChromeController/transport.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/transport.py#L630-L664 | def recv(self, tab_key, message_id=None, timeout=30):
'''
Recieve a message, optionally filtering for a specified message id.
If `message_id` is none, the first command in the receive queue is returned.
If `message_id` is not none, the command waits untill a message is received with
the specified id, or it t... | [
"def",
"recv",
"(",
"self",
",",
"tab_key",
",",
"message_id",
"=",
"None",
",",
"timeout",
"=",
"30",
")",
":",
"self",
".",
"__check_open_socket",
"(",
"tab_key",
")",
"# First, check if the message has already been received.",
"for",
"idx",
"in",
"range",
"("... | Recieve a message, optionally filtering for a specified message id.
If `message_id` is none, the first command in the receive queue is returned.
If `message_id` is not none, the command waits untill a message is received with
the specified id, or it times out.
Timeout is the number of seconds to wait for a re... | [
"Recieve",
"a",
"message",
"optionally",
"filtering",
"for",
"a",
"specified",
"message",
"id",
"."
] | python | train |
dschien/PyExcelModelingHelper | excel_helper/__init__.py | https://github.com/dschien/PyExcelModelingHelper/blob/d00d98ae2f28ad71cfcd2a365c3045e439517df2/excel_helper/__init__.py#L379-L422 | def growth_coefficients(start_date, end_date, ref_date, alpha, samples):
"""
Build a matrix of growth factors according to the CAGR formula y'=y0 (1+a)^(t'-t0).
a growth rate alpha
t0 start date
t' end date
y' output
y0 start value
"""
start_offset = 0
if ref_date < start_dat... | [
"def",
"growth_coefficients",
"(",
"start_date",
",",
"end_date",
",",
"ref_date",
",",
"alpha",
",",
"samples",
")",
":",
"start_offset",
"=",
"0",
"if",
"ref_date",
"<",
"start_date",
":",
"offset_delta",
"=",
"rdelta",
".",
"relativedelta",
"(",
"start_date... | Build a matrix of growth factors according to the CAGR formula y'=y0 (1+a)^(t'-t0).
a growth rate alpha
t0 start date
t' end date
y' output
y0 start value | [
"Build",
"a",
"matrix",
"of",
"growth",
"factors",
"according",
"to",
"the",
"CAGR",
"formula",
"y",
"=",
"y0",
"(",
"1",
"+",
"a",
")",
"^",
"(",
"t",
"-",
"t0",
")",
"."
] | python | train |
elmotec/massedit | massedit.py | https://github.com/elmotec/massedit/blob/57e22787354896d63a8850312314b19aa0308906/massedit.py#L170-L193 | def edit_content(self, original_lines, file_name):
"""Processes a file contents.
First processes the contents line by line applying the registered
expressions, then process the resulting contents using the
registered functions.
Arguments:
original_lines (list of str):... | [
"def",
"edit_content",
"(",
"self",
",",
"original_lines",
",",
"file_name",
")",
":",
"lines",
"=",
"[",
"self",
".",
"edit_line",
"(",
"line",
")",
"for",
"line",
"in",
"original_lines",
"]",
"for",
"function",
"in",
"self",
".",
"_functions",
":",
"tr... | Processes a file contents.
First processes the contents line by line applying the registered
expressions, then process the resulting contents using the
registered functions.
Arguments:
original_lines (list of str): file content.
file_name (str): name of the file. | [
"Processes",
"a",
"file",
"contents",
"."
] | python | train |
biolink/biolink-model | metamodel/generators/jsonldgen.py | https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/jsonldgen.py#L102-L104 | def cli(yamlfile, format, context):
""" Generate JSONLD file from biolink schema """
print(JSONLDGenerator(yamlfile, format).serialize(context=context)) | [
"def",
"cli",
"(",
"yamlfile",
",",
"format",
",",
"context",
")",
":",
"print",
"(",
"JSONLDGenerator",
"(",
"yamlfile",
",",
"format",
")",
".",
"serialize",
"(",
"context",
"=",
"context",
")",
")"
] | Generate JSONLD file from biolink schema | [
"Generate",
"JSONLD",
"file",
"from",
"biolink",
"schema"
] | python | train |
etcher-be/epab | epab/utils/_repo.py | https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/utils/_repo.py#L175-L183 | def ensure():
"""
Makes sure the current working directory is a Git repository.
"""
LOGGER.debug('checking repository')
if not os.path.exists('.git'):
LOGGER.error('This command is meant to be ran in a Git repository.')
sys.exit(-1)
LOGGER.debug('r... | [
"def",
"ensure",
"(",
")",
":",
"LOGGER",
".",
"debug",
"(",
"'checking repository'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"'.git'",
")",
":",
"LOGGER",
".",
"error",
"(",
"'This command is meant to be ran in a Git repository.'",
")",
"sys"... | Makes sure the current working directory is a Git repository. | [
"Makes",
"sure",
"the",
"current",
"working",
"directory",
"is",
"a",
"Git",
"repository",
"."
] | python | train |
blockchain/api-v1-client-python | blockchain/createwallet.py | https://github.com/blockchain/api-v1-client-python/blob/52ea562f824f04303e75239364e06722bec8620f/blockchain/createwallet.py#L10-L35 | def create_wallet(password, api_code, service_url, priv=None, label=None, email=None):
"""Create a new Blockchain.info wallet. It can be created containing a
pre-generated private key or will otherwise generate a new private key.
:param str password: password for the new wallet. At least 10 c... | [
"def",
"create_wallet",
"(",
"password",
",",
"api_code",
",",
"service_url",
",",
"priv",
"=",
"None",
",",
"label",
"=",
"None",
",",
"email",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'password'",
":",
"password",
",",
"'api_code'",
":",
"api_code",... | Create a new Blockchain.info wallet. It can be created containing a
pre-generated private key or will otherwise generate a new private key.
:param str password: password for the new wallet. At least 10 characters.
:param str api_code: API code with create wallets permission
:param str... | [
"Create",
"a",
"new",
"Blockchain",
".",
"info",
"wallet",
".",
"It",
"can",
"be",
"created",
"containing",
"a",
"pre",
"-",
"generated",
"private",
"key",
"or",
"will",
"otherwise",
"generate",
"a",
"new",
"private",
"key",
"."
] | python | train |
inspirehep/refextract | refextract/references/regexs.py | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/regexs.py#L733-L772 | def get_reference_line_numeration_marker_patterns(prefix=u''):
"""Return a list of compiled regex patterns used to search for the marker
of a reference line in a full-text document.
@param prefix: (string) the possible prefix to a reference line
@return: (list) of compiled regex patterns.
"... | [
"def",
"get_reference_line_numeration_marker_patterns",
"(",
"prefix",
"=",
"u''",
")",
":",
"title",
"=",
"u\"\"",
"if",
"type",
"(",
"prefix",
")",
"in",
"(",
"str",
",",
"unicode",
")",
":",
"title",
"=",
"prefix",
"g_name",
"=",
"u'(?P<mark>'",
"g_close"... | Return a list of compiled regex patterns used to search for the marker
of a reference line in a full-text document.
@param prefix: (string) the possible prefix to a reference line
@return: (list) of compiled regex patterns. | [
"Return",
"a",
"list",
"of",
"compiled",
"regex",
"patterns",
"used",
"to",
"search",
"for",
"the",
"marker",
"of",
"a",
"reference",
"line",
"in",
"a",
"full",
"-",
"text",
"document",
"."
] | python | train |
zomux/deepy | deepy/networks/network.py | https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/networks/network.py#L284-L291 | def report(self):
"""
Print network statistics.
"""
logging.info("network inputs: %s", " ".join(map(str, self.input_variables)))
logging.info("network targets: %s", " ".join(map(str, self.target_variables)))
logging.info("network parameters: %s", " ".join(map(str, self.al... | [
"def",
"report",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"\"network inputs: %s\"",
",",
"\" \"",
".",
"join",
"(",
"map",
"(",
"str",
",",
"self",
".",
"input_variables",
")",
")",
")",
"logging",
".",
"info",
"(",
"\"network targets: %s\"",
... | Print network statistics. | [
"Print",
"network",
"statistics",
"."
] | python | test |
jaywink/federation | federation/protocols/diaspora/encrypted.py | https://github.com/jaywink/federation/blob/59d31bb37e662891dbea72c1dee05dc53146c78b/federation/protocols/diaspora/encrypted.py#L69-L88 | def encrypt(payload, public_key):
"""
Encrypt a payload using an encrypted JSON wrapper.
See: https://diaspora.github.io/diaspora_federation/federation/encryption.html
:param payload: Payload document as a string.
:param public_key: Public key of recipient as an RSA object.
... | [
"def",
"encrypt",
"(",
"payload",
",",
"public_key",
")",
":",
"iv",
",",
"key",
",",
"encrypter",
"=",
"EncryptedPayload",
".",
"get_iv_key_encrypter",
"(",
")",
"aes_key_json",
"=",
"EncryptedPayload",
".",
"get_aes_key_json",
"(",
"iv",
",",
"key",
")",
"... | Encrypt a payload using an encrypted JSON wrapper.
See: https://diaspora.github.io/diaspora_federation/federation/encryption.html
:param payload: Payload document as a string.
:param public_key: Public key of recipient as an RSA object.
:return: Encrypted JSON wrapper as dict. | [
"Encrypt",
"a",
"payload",
"using",
"an",
"encrypted",
"JSON",
"wrapper",
"."
] | python | train |
bitesofcode/projexui | projexui/dialogs/xshortcutdialog/xshortcutdialog.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xshortcutdialog/xshortcutdialog.py#L77-L90 | def accept( self ):
"""
Saves the current settings for the actions in the list and exits the
dialog.
"""
if ( not self.save() ):
return
for i in range(self.uiActionTREE.topLevelItemCount()):
item = self.uiActionTREE.topLevelItem(i)
... | [
"def",
"accept",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"save",
"(",
")",
")",
":",
"return",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"uiActionTREE",
".",
"topLevelItemCount",
"(",
")",
")",
":",
"item",
"=",
"self",
".",
"uiA... | Saves the current settings for the actions in the list and exits the
dialog. | [
"Saves",
"the",
"current",
"settings",
"for",
"the",
"actions",
"in",
"the",
"list",
"and",
"exits",
"the",
"dialog",
"."
] | python | train |
CalebBell/fluids | fluids/particle_size_distribution.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L851-L887 | def pdf_Gates_Gaudin_Schuhman_basis_integral(d, d_characteristic, m, n):
r'''Calculates the integral of the multiplication of d^n by the Gates,
Gaudin and Schuhman (GGS) model given a particle diameter `d`,
characteristic (maximum) particle diameter `d_characteristic`, and exponent
`m`.
.. mat... | [
"def",
"pdf_Gates_Gaudin_Schuhman_basis_integral",
"(",
"d",
",",
"d_characteristic",
",",
"m",
",",
"n",
")",
":",
"return",
"m",
"/",
"(",
"m",
"+",
"n",
")",
"*",
"d",
"**",
"n",
"*",
"(",
"d",
"/",
"d_characteristic",
")",
"**",
"m"
] | r'''Calculates the integral of the multiplication of d^n by the Gates,
Gaudin and Schuhman (GGS) model given a particle diameter `d`,
characteristic (maximum) particle diameter `d_characteristic`, and exponent
`m`.
.. math::
\int d^n\cdot q(d)\; dd =\frac{m}{m+n} d^n \left(\frac{d}
... | [
"r",
"Calculates",
"the",
"integral",
"of",
"the",
"multiplication",
"of",
"d^n",
"by",
"the",
"Gates",
"Gaudin",
"and",
"Schuhman",
"(",
"GGS",
")",
"model",
"given",
"a",
"particle",
"diameter",
"d",
"characteristic",
"(",
"maximum",
")",
"particle",
"diam... | python | train |
UCSBarchlab/PyRTL | pyrtl/transform.py | https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/transform.py#L166-L182 | def clone_wire(old_wire, name=None):
"""
Makes a copy of any existing wire
:param old_wire: The wire to clone
:param name: a name fo rhte new wire
Note that this function is mainly intended to be used when the
two wires are from different blocks. Making two wires with the
same name in the ... | [
"def",
"clone_wire",
"(",
"old_wire",
",",
"name",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"old_wire",
",",
"Const",
")",
":",
"return",
"Const",
"(",
"old_wire",
".",
"val",
",",
"old_wire",
".",
"bitwidth",
")",
"else",
":",
"if",
"name",
"... | Makes a copy of any existing wire
:param old_wire: The wire to clone
:param name: a name fo rhte new wire
Note that this function is mainly intended to be used when the
two wires are from different blocks. Making two wires with the
same name in the same block is not allowed | [
"Makes",
"a",
"copy",
"of",
"any",
"existing",
"wire"
] | python | train |
devassistant/devassistant | devassistant/excepthook.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/excepthook.py#L24-L31 | def is_local_subsection(command_dict):
"""Returns True if command dict is "local subsection", meaning
that it is "if", "else" or "for" (not a real call, but calls
run_section recursively."""
for local_com in ['if ', 'for ', 'else ']:
if list(command_dict.keys())[0].startswith(local_com):
... | [
"def",
"is_local_subsection",
"(",
"command_dict",
")",
":",
"for",
"local_com",
"in",
"[",
"'if '",
",",
"'for '",
",",
"'else '",
"]",
":",
"if",
"list",
"(",
"command_dict",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
".",
"startswith",
"(",
"local_c... | Returns True if command dict is "local subsection", meaning
that it is "if", "else" or "for" (not a real call, but calls
run_section recursively. | [
"Returns",
"True",
"if",
"command",
"dict",
"is",
"local",
"subsection",
"meaning",
"that",
"it",
"is",
"if",
"else",
"or",
"for",
"(",
"not",
"a",
"real",
"call",
"but",
"calls",
"run_section",
"recursively",
"."
] | python | train |
saltstack/salt | salt/executors/sudo.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/executors/sudo.py#L25-L79 | def execute(opts, data, func, args, kwargs):
'''
Allow for the calling of execution modules via sudo.
This module is invoked by the minion if the ``sudo_user`` minion config is
present.
Example minion config:
.. code-block:: yaml
sudo_user: saltdev
Once this setting is made, any... | [
"def",
"execute",
"(",
"opts",
",",
"data",
",",
"func",
",",
"args",
",",
"kwargs",
")",
":",
"cmd",
"=",
"[",
"'sudo'",
",",
"'-u'",
",",
"opts",
".",
"get",
"(",
"'sudo_user'",
")",
",",
"'salt-call'",
",",
"'--out'",
",",
"'json'",
",",
"'--met... | Allow for the calling of execution modules via sudo.
This module is invoked by the minion if the ``sudo_user`` minion config is
present.
Example minion config:
.. code-block:: yaml
sudo_user: saltdev
Once this setting is made, any execution module call done by the minion will be
run... | [
"Allow",
"for",
"the",
"calling",
"of",
"execution",
"modules",
"via",
"sudo",
"."
] | python | train |
MacHu-GWU/angora-project | angora/algorithm/iterable.py | https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/algorithm/iterable.py#L194-L209 | def running_windows(iterable, size):
"""Generate n-size running windows.
Usage::
>>> for i in running_windows([1, 2, 3, 4, 5], size=3):
... print(i)
[1, 2, 3]
[2, 3, 4]
[3, 4, 5]
"""
fifo = collections.deque(maxlen=size)
for i in iterable:
fifo.a... | [
"def",
"running_windows",
"(",
"iterable",
",",
"size",
")",
":",
"fifo",
"=",
"collections",
".",
"deque",
"(",
"maxlen",
"=",
"size",
")",
"for",
"i",
"in",
"iterable",
":",
"fifo",
".",
"append",
"(",
"i",
")",
"if",
"len",
"(",
"fifo",
")",
"==... | Generate n-size running windows.
Usage::
>>> for i in running_windows([1, 2, 3, 4, 5], size=3):
... print(i)
[1, 2, 3]
[2, 3, 4]
[3, 4, 5] | [
"Generate",
"n",
"-",
"size",
"running",
"windows",
"."
] | python | train |
openid/python-openid | openid/extensions/draft/pape2.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/draft/pape2.py#L100-L129 | def parseExtensionArgs(self, args):
"""Set the state of this request to be that expressed in these
PAPE arguments
@param args: The PAPE arguments without a namespace
@rtype: None
@raises ValueError: When the max_auth_age is not parseable as
an integer
"""
... | [
"def",
"parseExtensionArgs",
"(",
"self",
",",
"args",
")",
":",
"# preferred_auth_policies is a space-separated list of policy URIs",
"self",
".",
"preferred_auth_policies",
"=",
"[",
"]",
"policies_str",
"=",
"args",
".",
"get",
"(",
"'preferred_auth_policies'",
")",
... | Set the state of this request to be that expressed in these
PAPE arguments
@param args: The PAPE arguments without a namespace
@rtype: None
@raises ValueError: When the max_auth_age is not parseable as
an integer | [
"Set",
"the",
"state",
"of",
"this",
"request",
"to",
"be",
"that",
"expressed",
"in",
"these",
"PAPE",
"arguments"
] | python | train |
Alignak-monitoring/alignak | alignak/objects/servicedependency.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicedependency.py#L206-L303 | def explode(self, hostgroups):
# pylint: disable=too-many-locals, too-many-branches
"""Explode all service dependency for each member of hostgroups
Each member of dependent hostgroup or hostgroup in dependency have to get a copy of
service dependencies (quite complex to parse)
:... | [
"def",
"explode",
"(",
"self",
",",
"hostgroups",
")",
":",
"# pylint: disable=too-many-locals, too-many-branches",
"# The \"old\" services will be removed. All services with",
"# more than one host or a host group will be in it",
"srvdep_to_remove",
"=",
"[",
"]",
"# Then for every ho... | Explode all service dependency for each member of hostgroups
Each member of dependent hostgroup or hostgroup in dependency have to get a copy of
service dependencies (quite complex to parse)
:param hostgroups: used to look for hostgroup
:type hostgroups: alignak.objects.hostgroup.Hostgr... | [
"Explode",
"all",
"service",
"dependency",
"for",
"each",
"member",
"of",
"hostgroups",
"Each",
"member",
"of",
"dependent",
"hostgroup",
"or",
"hostgroup",
"in",
"dependency",
"have",
"to",
"get",
"a",
"copy",
"of",
"service",
"dependencies",
"(",
"quite",
"c... | python | train |
michal-stuglik/django-blastplus | blastplus/features/record.py | https://github.com/michal-stuglik/django-blastplus/blob/4f5e15fb9f8069c3bed5f8fd941c4b9891daad4b/blastplus/features/record.py#L119-L121 | def get_id(self):
"""Returns unique id of an alignment. """
return hash(str(self.title) + str(self.best_score()) + str(self.hit_def)) | [
"def",
"get_id",
"(",
"self",
")",
":",
"return",
"hash",
"(",
"str",
"(",
"self",
".",
"title",
")",
"+",
"str",
"(",
"self",
".",
"best_score",
"(",
")",
")",
"+",
"str",
"(",
"self",
".",
"hit_def",
")",
")"
] | Returns unique id of an alignment. | [
"Returns",
"unique",
"id",
"of",
"an",
"alignment",
"."
] | python | train |
odlgroup/odl | odl/trafos/wavelet.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/trafos/wavelet.py#L424-L432 | def _call(self, x):
"""Return wavelet transform of ``x``."""
if self.impl == 'pywt':
coeffs = pywt.wavedecn(
x, wavelet=self.pywt_wavelet, level=self.nlevels,
mode=self.pywt_pad_mode, axes=self.axes)
return pywt.ravel_coeffs(coeffs, axes=self.axes)... | [
"def",
"_call",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"impl",
"==",
"'pywt'",
":",
"coeffs",
"=",
"pywt",
".",
"wavedecn",
"(",
"x",
",",
"wavelet",
"=",
"self",
".",
"pywt_wavelet",
",",
"level",
"=",
"self",
".",
"nlevels",
",",
"... | Return wavelet transform of ``x``. | [
"Return",
"wavelet",
"transform",
"of",
"x",
"."
] | python | train |
getgauge/gauge-python | getgauge/parser_redbaron.py | https://github.com/getgauge/gauge-python/blob/90f3547dcfd2d16d51f116cdd4e53527eeab1a57/getgauge/parser_redbaron.py#L62-L80 | def _step_decorator_args(self, decorator):
"""
Get arguments passed to step decorators converted to python objects.
"""
args = decorator.call.value
step = None
if len(args) == 1:
try:
step = args[0].value.to_python()
except (ValueEr... | [
"def",
"_step_decorator_args",
"(",
"self",
",",
"decorator",
")",
":",
"args",
"=",
"decorator",
".",
"call",
".",
"value",
"step",
"=",
"None",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"try",
":",
"step",
"=",
"args",
"[",
"0",
"]",
".",
... | Get arguments passed to step decorators converted to python objects. | [
"Get",
"arguments",
"passed",
"to",
"step",
"decorators",
"converted",
"to",
"python",
"objects",
"."
] | python | test |
openpaperwork/paperwork-backend | paperwork_backend/index.py | https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L387-L401 | def add_doc(self, doc, index_update=True, label_guesser_update=True):
"""
Add a document to the index
"""
if not self.index_writer and index_update:
self.index_writer = self.index.writer()
if not self.label_guesser_updater and label_guesser_update:
self.la... | [
"def",
"add_doc",
"(",
"self",
",",
"doc",
",",
"index_update",
"=",
"True",
",",
"label_guesser_update",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"index_writer",
"and",
"index_update",
":",
"self",
".",
"index_writer",
"=",
"self",
".",
"index",
... | Add a document to the index | [
"Add",
"a",
"document",
"to",
"the",
"index"
] | python | train |
sludgedesk/metoffer | metoffer.py | https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L323-L340 | def parse_sitelist(sitelist):
"""Return list of Site instances from retrieved sitelist data"""
sites = []
for site in sitelist["Locations"]["Location"]:
try:
ident = site["id"]
name = site["name"]
except KeyError:
ident = site["@id"] # Difference between l... | [
"def",
"parse_sitelist",
"(",
"sitelist",
")",
":",
"sites",
"=",
"[",
"]",
"for",
"site",
"in",
"sitelist",
"[",
"\"Locations\"",
"]",
"[",
"\"Location\"",
"]",
":",
"try",
":",
"ident",
"=",
"site",
"[",
"\"id\"",
"]",
"name",
"=",
"site",
"[",
"\"... | Return list of Site instances from retrieved sitelist data | [
"Return",
"list",
"of",
"Site",
"instances",
"from",
"retrieved",
"sitelist",
"data"
] | python | train |
rosenbrockc/fortpy | fortpy/scripts/analyze.py | https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L246-L251 | def _complete_cases(self, text, line, istart, iend):
"""Returns the completion list of possible test cases for the active unit test."""
if text == "":
return list(self.live.keys())
else:
return [c for c in self.live if c.startswith(text)] | [
"def",
"_complete_cases",
"(",
"self",
",",
"text",
",",
"line",
",",
"istart",
",",
"iend",
")",
":",
"if",
"text",
"==",
"\"\"",
":",
"return",
"list",
"(",
"self",
".",
"live",
".",
"keys",
"(",
")",
")",
"else",
":",
"return",
"[",
"c",
"for"... | Returns the completion list of possible test cases for the active unit test. | [
"Returns",
"the",
"completion",
"list",
"of",
"possible",
"test",
"cases",
"for",
"the",
"active",
"unit",
"test",
"."
] | python | train |
carter-j-h/iterable-python-wrapper | iterablepythonwrapper/client.py | https://github.com/carter-j-h/iterable-python-wrapper/blob/10d5db034ddfdfc3333efeee07fc9228b6a998c4/iterablepythonwrapper/client.py#L1435-L1454 | def disable_device(self, token, email=None, user_id=None):
"""
This request manually disable pushes to a device until it comes
online again.
"""
call = "/api/users/disableDevice"
payload ={}
payload["token"] = str(token)
if email is not None:
payload["email"] = str(email)
if user_id is not N... | [
"def",
"disable_device",
"(",
"self",
",",
"token",
",",
"email",
"=",
"None",
",",
"user_id",
"=",
"None",
")",
":",
"call",
"=",
"\"/api/users/disableDevice\"",
"payload",
"=",
"{",
"}",
"payload",
"[",
"\"token\"",
"]",
"=",
"str",
"(",
"token",
")",
... | This request manually disable pushes to a device until it comes
online again. | [
"This",
"request",
"manually",
"disable",
"pushes",
"to",
"a",
"device",
"until",
"it",
"comes",
"online",
"again",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/video/epva.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/epva.py#L53-L124 | def van_image_enc_2d(x, first_depth, reuse=False, hparams=None):
"""The image encoder for the VAN.
Similar architecture as Ruben's paper
(http://proceedings.mlr.press/v70/villegas17a/villegas17a.pdf).
Args:
x: The image to encode.
first_depth: The depth of the first layer. Depth is increased in subseq... | [
"def",
"van_image_enc_2d",
"(",
"x",
",",
"first_depth",
",",
"reuse",
"=",
"False",
",",
"hparams",
"=",
"None",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"'van_image_enc'",
",",
"reuse",
"=",
"reuse",
")",
":",
"enc_history",
"=",
"[",
"x",
... | The image encoder for the VAN.
Similar architecture as Ruben's paper
(http://proceedings.mlr.press/v70/villegas17a/villegas17a.pdf).
Args:
x: The image to encode.
first_depth: The depth of the first layer. Depth is increased in subsequent
layers.
reuse: To reuse in variable scope or not.
h... | [
"The",
"image",
"encoder",
"for",
"the",
"VAN",
"."
] | python | train |
alorence/django-modern-rpc | modernrpc/system_methods.py | https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/system_methods.py#L7-L12 | def __system_listMethods(**kwargs):
"""Returns a list of all methods available in the current entry point"""
entry_point = kwargs.get(ENTRY_POINT_KEY)
protocol = kwargs.get(PROTOCOL_KEY)
return registry.get_all_method_names(entry_point, protocol, sort_methods=True) | [
"def",
"__system_listMethods",
"(",
"*",
"*",
"kwargs",
")",
":",
"entry_point",
"=",
"kwargs",
".",
"get",
"(",
"ENTRY_POINT_KEY",
")",
"protocol",
"=",
"kwargs",
".",
"get",
"(",
"PROTOCOL_KEY",
")",
"return",
"registry",
".",
"get_all_method_names",
"(",
... | Returns a list of all methods available in the current entry point | [
"Returns",
"a",
"list",
"of",
"all",
"methods",
"available",
"in",
"the",
"current",
"entry",
"point"
] | python | train |
ekiro/haps | haps/container.py | https://github.com/ekiro/haps/blob/64b6746187e44dadb23b842607d294e03c30a0be/haps/container.py#L96-L145 | def configure(config: List[Egg], subclass: 'Container' = None) -> None:
"""
Configure haps manually, an alternative
to :func:`~haps.Container.autodiscover`
:param config: List of configured Eggs
:param subclass: Optional Container subclass that should be used
"""
... | [
"def",
"configure",
"(",
"config",
":",
"List",
"[",
"Egg",
"]",
",",
"subclass",
":",
"'Container'",
"=",
"None",
")",
"->",
"None",
":",
"profiles",
"=",
"Configuration",
"(",
")",
".",
"get_var",
"(",
"PROFILES",
",",
"tuple",
")",
"assert",
"isinst... | Configure haps manually, an alternative
to :func:`~haps.Container.autodiscover`
:param config: List of configured Eggs
:param subclass: Optional Container subclass that should be used | [
"Configure",
"haps",
"manually",
"an",
"alternative",
"to",
":",
"func",
":",
"~haps",
".",
"Container",
".",
"autodiscover"
] | python | train |
DecBayComp/RWA-python | rwa/generic.py | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L241-L274 | def pokeStorable(self, storable, objname, obj, container, visited=None, _stack=None, **kwargs):
"""
Arguments:
storable (StorableHandler): storable instance.
objname (any): record reference.
obj (any): object to be serialized.
container (any): containe... | [
"def",
"pokeStorable",
"(",
"self",
",",
"storable",
",",
"objname",
",",
"obj",
",",
"container",
",",
"visited",
"=",
"None",
",",
"_stack",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"#print((objname, storable.storable_type)) # debug",
"storable",
".",... | Arguments:
storable (StorableHandler): storable instance.
objname (any): record reference.
obj (any): object to be serialized.
container (any): container.
visited (dict): map of the previously serialized objects that are
passed by referenc... | [
"Arguments",
":"
] | python | train |
ktbyers/netmiko | netmiko/linux/linux_ssh.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L135-L139 | def remote_file_size(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
return self._remote_file_size_unix(
remote_cmd=remote_cmd, remote_file=remote_file
) | [
"def",
"remote_file_size",
"(",
"self",
",",
"remote_cmd",
"=",
"\"\"",
",",
"remote_file",
"=",
"None",
")",
":",
"return",
"self",
".",
"_remote_file_size_unix",
"(",
"remote_cmd",
"=",
"remote_cmd",
",",
"remote_file",
"=",
"remote_file",
")"
] | Get the file size of the remote file. | [
"Get",
"the",
"file",
"size",
"of",
"the",
"remote",
"file",
"."
] | python | train |
cocoakekeyu/cancan | cancan/ability.py | https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L62-L70 | def relevant_rules_for_match(self, action, subject):
"""retrive match action and subject"""
matches = []
for rule in self.rules:
rule.expanded_actions = self.expand_actions(rule.actions)
if rule.is_relevant(action, subject):
matches.append(rule)
r... | [
"def",
"relevant_rules_for_match",
"(",
"self",
",",
"action",
",",
"subject",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"rule",
"in",
"self",
".",
"rules",
":",
"rule",
".",
"expanded_actions",
"=",
"self",
".",
"expand_actions",
"(",
"rule",
".",
"act... | retrive match action and subject | [
"retrive",
"match",
"action",
"and",
"subject"
] | python | train |
Kensuke-Mitsuzawa/JapaneseTokenizers | JapaneseTokenizer/common/text_preprocess.py | https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/blob/3bdfb6be73de0f78e5c08f3a51376ad3efa00b6c/JapaneseTokenizer/common/text_preprocess.py#L50-L74 | def normalize_text(input_text,
dictionary_mode='ipadic',
new_line_replaced='。',
is_replace_eos=True,
is_kana=True,
is_ascii=True,
is_digit=True):
# type: (text_type,text_type,text_type,bool,bool,bool,bo... | [
"def",
"normalize_text",
"(",
"input_text",
",",
"dictionary_mode",
"=",
"'ipadic'",
",",
"new_line_replaced",
"=",
"'。',",
"",
"is_replace_eos",
"=",
"True",
",",
"is_kana",
"=",
"True",
",",
"is_ascii",
"=",
"True",
",",
"is_digit",
"=",
"True",
")",
":",
... | * What you can do
- It converts input-text into normalized-text which is good for tokenizer input.
* Params
- new_line_replaced: a string which replaces from \n string. | [
"*",
"What",
"you",
"can",
"do",
"-",
"It",
"converts",
"input",
"-",
"text",
"into",
"normalized",
"-",
"text",
"which",
"is",
"good",
"for",
"tokenizer",
"input",
"."
] | python | train |
biolink/ontobio | ontobio/golr/golr_query.py | https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/golr/golr_query.py#L241-L269 | def goassoc_fieldmap(relationship_type=ACTS_UPSTREAM_OF_OR_WITHIN):
"""
Returns a mapping of canonical monarch fields to amigo-golr.
See: https://github.com/geneontology/amigo/blob/master/metadata/ann-config.yaml
"""
return {
M.SUBJECT: 'bioentity',
M.SUBJECT_CLOSURE: 'bioentity',
... | [
"def",
"goassoc_fieldmap",
"(",
"relationship_type",
"=",
"ACTS_UPSTREAM_OF_OR_WITHIN",
")",
":",
"return",
"{",
"M",
".",
"SUBJECT",
":",
"'bioentity'",
",",
"M",
".",
"SUBJECT_CLOSURE",
":",
"'bioentity'",
",",
"## In the GO AmiGO instance, the type field is not correct... | Returns a mapping of canonical monarch fields to amigo-golr.
See: https://github.com/geneontology/amigo/blob/master/metadata/ann-config.yaml | [
"Returns",
"a",
"mapping",
"of",
"canonical",
"monarch",
"fields",
"to",
"amigo",
"-",
"golr",
"."
] | python | train |
RetailMeNotSandbox/acky | acky/ec2.py | https://github.com/RetailMeNotSandbox/acky/blob/fcd4d092c42892ede7c924cafc41e9cf4be3fb9f/acky/ec2.py#L473-L483 | def get(self, volume_ids=None, filters=None):
"""List EBS Volume info."""
params = {}
if filters:
params["filters"] = make_filters(filters)
if isinstance(volume_ids, str):
volume_ids = [volume_ids]
return self.call("DescribeVolumes",
... | [
"def",
"get",
"(",
"self",
",",
"volume_ids",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"filters",
":",
"params",
"[",
"\"filters\"",
"]",
"=",
"make_filters",
"(",
"filters",
")",
"if",
"isinstance",
"(",
"vo... | List EBS Volume info. | [
"List",
"EBS",
"Volume",
"info",
"."
] | python | train |
SmokinCaterpillar/pypet | pypet/naturalnaming.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/naturalnaming.py#L3115-L3170 | def f_get(self, name, fast_access=False, with_links=True,
shortcuts=True, max_depth=None, auto_load=False):
"""Searches and returns an item (parameter/result/group node) with the given `name`.
:param name: Name of the item (full name or parts of the full name)
:param fast_access:... | [
"def",
"f_get",
"(",
"self",
",",
"name",
",",
"fast_access",
"=",
"False",
",",
"with_links",
"=",
"True",
",",
"shortcuts",
"=",
"True",
",",
"max_depth",
"=",
"None",
",",
"auto_load",
"=",
"False",
")",
":",
"return",
"self",
".",
"_nn_interface",
... | Searches and returns an item (parameter/result/group node) with the given `name`.
:param name: Name of the item (full name or parts of the full name)
:param fast_access: Whether fast access should be applied.
:param with_links:
If links are considered. Cannot be set to ``False`` ... | [
"Searches",
"and",
"returns",
"an",
"item",
"(",
"parameter",
"/",
"result",
"/",
"group",
"node",
")",
"with",
"the",
"given",
"name",
"."
] | python | test |
IdentityPython/pysaml2 | src/saml2/assertion.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/assertion.py#L69-L141 | def filter_on_attributes(ava, required=None, optional=None, acs=None,
fail_on_unfulfilled_requirements=True):
""" Filter
:param ava: An attribute value assertion as a dictionary
:param required: list of RequestedAttribute instances defined to be
required
:param optional... | [
"def",
"filter_on_attributes",
"(",
"ava",
",",
"required",
"=",
"None",
",",
"optional",
"=",
"None",
",",
"acs",
"=",
"None",
",",
"fail_on_unfulfilled_requirements",
"=",
"True",
")",
":",
"def",
"_match_attr_name",
"(",
"attr",
",",
"ava",
")",
":",
"l... | Filter
:param ava: An attribute value assertion as a dictionary
:param required: list of RequestedAttribute instances defined to be
required
:param optional: list of RequestedAttribute instances defined to be
optional
:param fail_on_unfulfilled_requirements: If required attributes
... | [
"Filter"
] | python | train |
classner/pymp | pymp/__init__.py | https://github.com/classner/pymp/blob/9895ec2ec01ad2778a400449cbfa17f162491180/pymp/__init__.py#L186-L207 | def range(self, start, stop=None, step=1):
"""
Get the correctly distributed parallel chunks.
This corresponds to using the OpenMP 'static' schedule.
"""
self._assert_active()
if stop is None:
start, stop = 0, start
full_list = range(start, stop, step... | [
"def",
"range",
"(",
"self",
",",
"start",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"1",
")",
":",
"self",
".",
"_assert_active",
"(",
")",
"if",
"stop",
"is",
"None",
":",
"start",
",",
"stop",
"=",
"0",
",",
"start",
"full_list",
"=",
"range... | Get the correctly distributed parallel chunks.
This corresponds to using the OpenMP 'static' schedule. | [
"Get",
"the",
"correctly",
"distributed",
"parallel",
"chunks",
"."
] | python | train |
HttpRunner/HttpRunner | httprunner/validator.py | https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/validator.py#L141-L171 | def get_uniform_comparator(comparator):
""" convert comparator alias to uniform name
"""
if comparator in ["eq", "equals", "==", "is"]:
return "equals"
elif comparator in ["lt", "less_than"]:
return "less_than"
elif comparator in ["le", "less_than_or_equals"]:
return "less_th... | [
"def",
"get_uniform_comparator",
"(",
"comparator",
")",
":",
"if",
"comparator",
"in",
"[",
"\"eq\"",
",",
"\"equals\"",
",",
"\"==\"",
",",
"\"is\"",
"]",
":",
"return",
"\"equals\"",
"elif",
"comparator",
"in",
"[",
"\"lt\"",
",",
"\"less_than\"",
"]",
":... | convert comparator alias to uniform name | [
"convert",
"comparator",
"alias",
"to",
"uniform",
"name"
] | python | train |
jpscaletti/solution | solution/fields/file/helpers.py | https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/file/helpers.py#L247-L324 | def save(self, filesto, upload_to=None, name=None, secret=None, prefix=None,
allowed=None, denied=None, max_size=None, **kwargs):
"""
Except for `filesto`, all of these parameters are optional, so only
bother setting the ones relevant to *this upload*.
filesto
: A... | [
"def",
"save",
"(",
"self",
",",
"filesto",
",",
"upload_to",
"=",
"None",
",",
"name",
"=",
"None",
",",
"secret",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"allowed",
"=",
"None",
",",
"denied",
"=",
"None",
",",
"max_size",
"=",
"None",
",",... | Except for `filesto`, all of these parameters are optional, so only
bother setting the ones relevant to *this upload*.
filesto
: A `werkzeug.FileUploader`.
upload_to
: Relative path to where to upload
secret
: If True, instead of the original filename, a ... | [
"Except",
"for",
"filesto",
"all",
"of",
"these",
"parameters",
"are",
"optional",
"so",
"only",
"bother",
"setting",
"the",
"ones",
"relevant",
"to",
"*",
"this",
"upload",
"*",
"."
] | python | train |
pandas-dev/pandas | pandas/io/parquet.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/parquet.py#L254-L282 | def read_parquet(path, engine='auto', columns=None, **kwargs):
"""
Load a parquet object from the file path, returning a DataFrame.
.. versionadded 0.21.0
Parameters
----------
path : string
File path
engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto'
Parquet libra... | [
"def",
"read_parquet",
"(",
"path",
",",
"engine",
"=",
"'auto'",
",",
"columns",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"impl",
"=",
"get_engine",
"(",
"engine",
")",
"return",
"impl",
".",
"read",
"(",
"path",
",",
"columns",
"=",
"columns... | Load a parquet object from the file path, returning a DataFrame.
.. versionadded 0.21.0
Parameters
----------
path : string
File path
engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto'
Parquet library to use. If 'auto', then the option
``io.parquet.engine`` is used... | [
"Load",
"a",
"parquet",
"object",
"from",
"the",
"file",
"path",
"returning",
"a",
"DataFrame",
"."
] | python | train |
openvax/mhcflurry | mhcflurry/class1_affinity_predictor.py | https://github.com/openvax/mhcflurry/blob/deb7c1629111254b484a2711619eb2347db36524/mhcflurry/class1_affinity_predictor.py#L456-L472 | def model_name(allele, num):
"""
Generate a model name
Parameters
----------
allele : string
num : int
Returns
-------
string
"""
random_string = hashlib.sha1(
str(time.time()).encode()).hexdigest()[:16]
... | [
"def",
"model_name",
"(",
"allele",
",",
"num",
")",
":",
"random_string",
"=",
"hashlib",
".",
"sha1",
"(",
"str",
"(",
"time",
".",
"time",
"(",
")",
")",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")",
"[",
":",
"16",
"]",
"return",
... | Generate a model name
Parameters
----------
allele : string
num : int
Returns
-------
string | [
"Generate",
"a",
"model",
"name",
"Parameters",
"----------",
"allele",
":",
"string",
"num",
":",
"int"
] | python | train |
glyph/automat | automat/_visualize.py | https://github.com/glyph/automat/blob/80c6eb925eeef120443f4f9c81398bea629884b8/automat/_visualize.py#L18-L28 | def elementMaker(name, *children, **attrs):
"""
Construct a string from the HTML element description.
"""
formattedAttrs = ' '.join('{}={}'.format(key, _gvquote(str(value)))
for key, value in sorted(attrs.items()))
formattedChildren = ''.join(children)
return u'<{na... | [
"def",
"elementMaker",
"(",
"name",
",",
"*",
"children",
",",
"*",
"*",
"attrs",
")",
":",
"formattedAttrs",
"=",
"' '",
".",
"join",
"(",
"'{}={}'",
".",
"format",
"(",
"key",
",",
"_gvquote",
"(",
"str",
"(",
"value",
")",
")",
")",
"for",
"key"... | Construct a string from the HTML element description. | [
"Construct",
"a",
"string",
"from",
"the",
"HTML",
"element",
"description",
"."
] | python | train |
ThreatResponse/margaritashotgun | margaritashotgun/repository.py | https://github.com/ThreatResponse/margaritashotgun/blob/6dee53ef267959b214953439968244cc46a19690/margaritashotgun/repository.py#L290-L308 | def fetch_module(self, module):
"""
Download and verify kernel module
:type module: str
:param module: kernel module path
"""
tm = int(time.time())
datestamp = datetime.utcfromtimestamp(tm).isoformat()
filename = "lime-{0}-{1}.ko".format(datestamp, module... | [
"def",
"fetch_module",
"(",
"self",
",",
"module",
")",
":",
"tm",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"datestamp",
"=",
"datetime",
".",
"utcfromtimestamp",
"(",
"tm",
")",
".",
"isoformat",
"(",
")",
"filename",
"=",
"\"lime-{0}-{1}.... | Download and verify kernel module
:type module: str
:param module: kernel module path | [
"Download",
"and",
"verify",
"kernel",
"module"
] | python | train |
wummel/linkchecker | linkcheck/checker/urlbase.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/urlbase.py#L306-L311 | def add_info (self, s):
"""
Add an info string.
"""
if s not in self.info:
self.info.append(s) | [
"def",
"add_info",
"(",
"self",
",",
"s",
")",
":",
"if",
"s",
"not",
"in",
"self",
".",
"info",
":",
"self",
".",
"info",
".",
"append",
"(",
"s",
")"
] | Add an info string. | [
"Add",
"an",
"info",
"string",
"."
] | python | train |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L635-L729 | def findOverlappingSNPsWithGoldStandard(prefix, gold_prefixe, out_prefix,
use_marker_names=False):
"""Find the overlapping SNPs in 4 different data sets."""
# Reading the main file
sourceSnpToExtract = {}
if use_marker_names:
sourceSnpToExtract = set()
... | [
"def",
"findOverlappingSNPsWithGoldStandard",
"(",
"prefix",
",",
"gold_prefixe",
",",
"out_prefix",
",",
"use_marker_names",
"=",
"False",
")",
":",
"# Reading the main file",
"sourceSnpToExtract",
"=",
"{",
"}",
"if",
"use_marker_names",
":",
"sourceSnpToExtract",
"="... | Find the overlapping SNPs in 4 different data sets. | [
"Find",
"the",
"overlapping",
"SNPs",
"in",
"4",
"different",
"data",
"sets",
"."
] | python | train |
gem/oq-engine | openquake/hmtk/comparison/rate_grids.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L114-L144 | def from_model_files(cls, limits, input_model, investigation_time=1.0,
simple_mesh_spacing=1.0, complex_mesh_spacing=5.0,
mfd_width=0.1, area_discretisation=10.0):
"""
Reads the hazard model from a file
:param list limits:
Grid conf... | [
"def",
"from_model_files",
"(",
"cls",
",",
"limits",
",",
"input_model",
",",
"investigation_time",
"=",
"1.0",
",",
"simple_mesh_spacing",
"=",
"1.0",
",",
"complex_mesh_spacing",
"=",
"5.0",
",",
"mfd_width",
"=",
"0.1",
",",
"area_discretisation",
"=",
"10.0... | Reads the hazard model from a file
:param list limits:
Grid configuration [west, east, xspc, south, north, yspc,
upper, lower, zspc]
:param str input_model:
Path to input source model
:param float investigation_time:
Investig... | [
"Reads",
"the",
"hazard",
"model",
"from",
"a",
"file"
] | python | train |
westurner/pyrpo | pyrpo/pyrpo.py | https://github.com/westurner/pyrpo/blob/2a910af055dc405b761571a52ef87842397ddadf/pyrpo/pyrpo.py#L666-L686 | def lately(self, count=15):
"""
Show ``count`` most-recently modified files by mtime
Yields:
tuple: (strftime-formatted mtime, self.fpath-relative file path)
"""
excludes = '|'.join(('*.pyc', '*.swp', '*.bak', '*~'))
cmd = ('''find . -printf "%%T@ %%p\\n" '''... | [
"def",
"lately",
"(",
"self",
",",
"count",
"=",
"15",
")",
":",
"excludes",
"=",
"'|'",
".",
"join",
"(",
"(",
"'*.pyc'",
",",
"'*.swp'",
",",
"'*.bak'",
",",
"'*~'",
")",
")",
"cmd",
"=",
"(",
"'''find . -printf \"%%T@ %%p\\\\n\" '''",
"'''| egrep -v '%s... | Show ``count`` most-recently modified files by mtime
Yields:
tuple: (strftime-formatted mtime, self.fpath-relative file path) | [
"Show",
"count",
"most",
"-",
"recently",
"modified",
"files",
"by",
"mtime"
] | python | train |
uber/tchannel-python | tchannel/tornado/connection.py | https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/connection.py#L359-L402 | def initiate_handshake(self, headers, timeout=None):
"""Initiate a handshake with the remote host.
:param headers:
A dictionary of headers to send.
:returns:
A future that resolves (with a value of None) when the handshake
is complete.
"""
io_... | [
"def",
"initiate_handshake",
"(",
"self",
",",
"headers",
",",
"timeout",
"=",
"None",
")",
":",
"io_loop",
"=",
"IOLoop",
".",
"current",
"(",
")",
"timeout",
"=",
"timeout",
"or",
"DEFAULT_INIT_TIMEOUT_SECS",
"self",
".",
"writer",
".",
"put",
"(",
"mess... | Initiate a handshake with the remote host.
:param headers:
A dictionary of headers to send.
:returns:
A future that resolves (with a value of None) when the handshake
is complete. | [
"Initiate",
"a",
"handshake",
"with",
"the",
"remote",
"host",
"."
] | python | train |
Equitable/trump | trump/orm.py | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/orm.py#L212-L236 | def delete(self, symbol):
"""
Deletes a Symbol.
Parameters
----------
symbol : str or Symbol
"""
if isinstance(symbol, (str, unicode)):
sym = self.get(symbol)
elif isinstance(symbol, Symbol):
sym = symbol
... | [
"def",
"delete",
"(",
"self",
",",
"symbol",
")",
":",
"if",
"isinstance",
"(",
"symbol",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"sym",
"=",
"self",
".",
"get",
"(",
"symbol",
")",
"elif",
"isinstance",
"(",
"symbol",
",",
"Symbol",
")",
... | Deletes a Symbol.
Parameters
----------
symbol : str or Symbol | [
"Deletes",
"a",
"Symbol",
".",
"Parameters",
"----------",
"symbol",
":",
"str",
"or",
"Symbol"
] | python | train |
intuition-io/intuition | intuition/core/analyzes.py | https://github.com/intuition-io/intuition/blob/cd517e6b3b315a743eb4d0d0dc294e264ab913ce/intuition/core/analyzes.py#L111-L133 | def overall_metrics(self, timestamp='one_month', metrics=None):
'''
Use zipline results to compute some performance indicators
'''
perfs = dict()
# If no rolling perfs provided, computes it
if metrics is None:
metrics = self.rolling_performances(timestamp=tim... | [
"def",
"overall_metrics",
"(",
"self",
",",
"timestamp",
"=",
"'one_month'",
",",
"metrics",
"=",
"None",
")",
":",
"perfs",
"=",
"dict",
"(",
")",
"# If no rolling perfs provided, computes it",
"if",
"metrics",
"is",
"None",
":",
"metrics",
"=",
"self",
".",
... | Use zipline results to compute some performance indicators | [
"Use",
"zipline",
"results",
"to",
"compute",
"some",
"performance",
"indicators"
] | python | train |
bitprophet/releases | releases/models.py | https://github.com/bitprophet/releases/blob/97a763e41bbe7374106a1c648b89346a0d935429/releases/models.py#L82-L125 | def default_spec(self, manager):
"""
Given the current release-lines structure, return a default Spec.
Specifics:
* For feature-like issues, only the highest major release is used, so
given a ``manager`` with top level keys of ``[1, 2]``, this would
return ``Spec(">... | [
"def",
"default_spec",
"(",
"self",
",",
"manager",
")",
":",
"# TODO: I feel like this + the surrounding bits in add_to_manager()",
"# could be consolidated & simplified...",
"specstr",
"=",
"\"\"",
"# Make sure truly-default spec skips 0.x if prehistory was unstable.",
"stable_families... | Given the current release-lines structure, return a default Spec.
Specifics:
* For feature-like issues, only the highest major release is used, so
given a ``manager`` with top level keys of ``[1, 2]``, this would
return ``Spec(">=2")``.
* When ``releases_always_forward... | [
"Given",
"the",
"current",
"release",
"-",
"lines",
"structure",
"return",
"a",
"default",
"Spec",
"."
] | python | train |
pepkit/peppy | peppy/utils.py | https://github.com/pepkit/peppy/blob/f0f725e1557936b81c86573a77400e6f8da78f05/peppy/utils.py#L540-L557 | def is_command_callable(command, name=""):
"""
Check if command can be called.
:param str command: actual command to call
:param str name: nickname/alias by which to reference the command, optional
:return bool: whether given command's call succeeded
"""
# Use `command` to see if command i... | [
"def",
"is_command_callable",
"(",
"command",
",",
"name",
"=",
"\"\"",
")",
":",
"# Use `command` to see if command is callable, store exit code",
"code",
"=",
"os",
".",
"system",
"(",
"\"command -v {0} >/dev/null 2>&1 || {{ exit 1; }}\"",
".",
"format",
"(",
"command",
... | Check if command can be called.
:param str command: actual command to call
:param str name: nickname/alias by which to reference the command, optional
:return bool: whether given command's call succeeded | [
"Check",
"if",
"command",
"can",
"be",
"called",
"."
] | python | train |
apache/spark | python/pyspark/streaming/context.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/streaming/context.py#L350-L356 | def addStreamingListener(self, streamingListener):
"""
Add a [[org.apache.spark.streaming.scheduler.StreamingListener]] object for
receiving system events related to streaming.
"""
self._jssc.addStreamingListener(self._jvm.JavaStreamingListenerWrapper(
self._jvm.Pytho... | [
"def",
"addStreamingListener",
"(",
"self",
",",
"streamingListener",
")",
":",
"self",
".",
"_jssc",
".",
"addStreamingListener",
"(",
"self",
".",
"_jvm",
".",
"JavaStreamingListenerWrapper",
"(",
"self",
".",
"_jvm",
".",
"PythonStreamingListenerWrapper",
"(",
... | Add a [[org.apache.spark.streaming.scheduler.StreamingListener]] object for
receiving system events related to streaming. | [
"Add",
"a",
"[[",
"org",
".",
"apache",
".",
"spark",
".",
"streaming",
".",
"scheduler",
".",
"StreamingListener",
"]]",
"object",
"for",
"receiving",
"system",
"events",
"related",
"to",
"streaming",
"."
] | python | train |
kislyuk/aegea | aegea/packages/github3/session.py | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/session.py#L108-L121 | def token_auth(self, token):
"""Use an application token for authentication.
:param str token: Application token retrieved from GitHub's
/authorizations endpoint
"""
if not token:
return
self.headers.update({
'Authorization': 'token {0}'.form... | [
"def",
"token_auth",
"(",
"self",
",",
"token",
")",
":",
"if",
"not",
"token",
":",
"return",
"self",
".",
"headers",
".",
"update",
"(",
"{",
"'Authorization'",
":",
"'token {0}'",
".",
"format",
"(",
"token",
")",
"}",
")",
"# Unset username/password so... | Use an application token for authentication.
:param str token: Application token retrieved from GitHub's
/authorizations endpoint | [
"Use",
"an",
"application",
"token",
"for",
"authentication",
"."
] | python | train |
QualiSystems/vCenterShell | package/cloudshell/cp/vcenter/commands/save_sandbox.py | https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/save_sandbox.py#L38-L91 | def save_app(self, si, logger, vcenter_data_model, reservation_id, save_app_actions, cancellation_context):
"""
Cretaes an artifact of an app, that can later be restored
:param vcenter_data_model: VMwarevCenterResourceModel
:param vim.ServiceInstance si: py_vmomi service instance
... | [
"def",
"save_app",
"(",
"self",
",",
"si",
",",
"logger",
",",
"vcenter_data_model",
",",
"reservation_id",
",",
"save_app_actions",
",",
"cancellation_context",
")",
":",
"results",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"'Save Sandbox command starting on '",... | Cretaes an artifact of an app, that can later be restored
:param vcenter_data_model: VMwarevCenterResourceModel
:param vim.ServiceInstance si: py_vmomi service instance
:type si: vim.ServiceInstance
:param logger: Logger
:type logger: cloudshell.core.logger.qs_logger.get_qs_logg... | [
"Cretaes",
"an",
"artifact",
"of",
"an",
"app",
"that",
"can",
"later",
"be",
"restored"
] | python | train |
pandas-dev/pandas | pandas/io/pytables.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L2518-L2549 | def read_array(self, key, start=None, stop=None):
""" read an array for the specified node (off of group """
import tables
node = getattr(self.group, key)
attrs = node._v_attrs
transposed = getattr(attrs, 'transposed', False)
if isinstance(node, tables.VLArray):
... | [
"def",
"read_array",
"(",
"self",
",",
"key",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"import",
"tables",
"node",
"=",
"getattr",
"(",
"self",
".",
"group",
",",
"key",
")",
"attrs",
"=",
"node",
".",
"_v_attrs",
"transposed",
... | read an array for the specified node (off of group | [
"read",
"an",
"array",
"for",
"the",
"specified",
"node",
"(",
"off",
"of",
"group"
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/language_translator_v3.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/language_translator_v3.py#L568-L573 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'languages') and self.languages is not None:
_dict['languages'] = [x._to_dict() for x in self.languages]
return _dict | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'languages'",
")",
"and",
"self",
".",
"languages",
"is",
"not",
"None",
":",
"_dict",
"[",
"'languages'",
"]",
"=",
"[",
"x",
".",
"_to_dict",
"(... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
log2timeline/dfdatetime | dfdatetime/precisions.py | https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/precisions.py#L78-L101 | def CopyToDateTimeString(cls, time_elements_tuple, fraction_of_second):
"""Copies the time elements and fraction of second to a string.
Args:
time_elements_tuple (tuple[int, int, int, int, int, int]):
time elements, contains year, month, day of month, hours, minutes and
seconds.
... | [
"def",
"CopyToDateTimeString",
"(",
"cls",
",",
"time_elements_tuple",
",",
"fraction_of_second",
")",
":",
"if",
"fraction_of_second",
"<",
"0.0",
"or",
"fraction_of_second",
">=",
"1.0",
":",
"raise",
"ValueError",
"(",
"'Fraction of second value: {0:f} out of bounds.'"... | Copies the time elements and fraction of second to a string.
Args:
time_elements_tuple (tuple[int, int, int, int, int, int]):
time elements, contains year, month, day of month, hours, minutes and
seconds.
fraction_of_second (decimal.Decimal): fraction of second, which must be a
... | [
"Copies",
"the",
"time",
"elements",
"and",
"fraction",
"of",
"second",
"to",
"a",
"string",
"."
] | python | train |
Gandi/gandi.cli | gandi/cli/modules/paas.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/paas.py#L193-L234 | def update(cls, id, name, size, quantity, password, sshkey, upgrade,
console, snapshot_profile, reset_mysql_password, background):
"""Update a PaaS instance."""
if not background and not cls.intty():
background = True
paas_params = {}
if name:
paa... | [
"def",
"update",
"(",
"cls",
",",
"id",
",",
"name",
",",
"size",
",",
"quantity",
",",
"password",
",",
"sshkey",
",",
"upgrade",
",",
"console",
",",
"snapshot_profile",
",",
"reset_mysql_password",
",",
"background",
")",
":",
"if",
"not",
"background",... | Update a PaaS instance. | [
"Update",
"a",
"PaaS",
"instance",
"."
] | python | train |
mikedh/trimesh | trimesh/path/entities.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/entities.py#L43-L50 | def closed(self):
"""
If the first point is the same as the end point
the entity is closed
"""
closed = (len(self.points) > 2 and
self.points[0] == self.points[-1])
return closed | [
"def",
"closed",
"(",
"self",
")",
":",
"closed",
"=",
"(",
"len",
"(",
"self",
".",
"points",
")",
">",
"2",
"and",
"self",
".",
"points",
"[",
"0",
"]",
"==",
"self",
".",
"points",
"[",
"-",
"1",
"]",
")",
"return",
"closed"
] | If the first point is the same as the end point
the entity is closed | [
"If",
"the",
"first",
"point",
"is",
"the",
"same",
"as",
"the",
"end",
"point",
"the",
"entity",
"is",
"closed"
] | python | train |
bwohlberg/sporco | sporco/dictlrn/onlinecdl.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/onlinecdl.py#L209-L238 | def solve(self, S, dimK=None):
"""Compute sparse coding and dictionary update for training
data `S`."""
# Use dimK specified in __init__ as default
if dimK is None and self.dimK is not None:
dimK = self.dimK
# Start solve timer
self.timer.start(['solve', 'so... | [
"def",
"solve",
"(",
"self",
",",
"S",
",",
"dimK",
"=",
"None",
")",
":",
"# Use dimK specified in __init__ as default",
"if",
"dimK",
"is",
"None",
"and",
"self",
".",
"dimK",
"is",
"not",
"None",
":",
"dimK",
"=",
"self",
".",
"dimK",
"# Start solve tim... | Compute sparse coding and dictionary update for training
data `S`. | [
"Compute",
"sparse",
"coding",
"and",
"dictionary",
"update",
"for",
"training",
"data",
"S",
"."
] | python | train |
rapidpro/expressions | python/temba_expressions/utils.py | https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/utils.py#L22-L31 | def decimal_round(number, num_digits, rounding=ROUND_HALF_UP):
"""
Rounding for decimals with support for negative digits
"""
exp = Decimal(10) ** -num_digits
if num_digits >= 0:
return number.quantize(exp, rounding)
else:
return exp * (number / exp).to_integral_value(rounding) | [
"def",
"decimal_round",
"(",
"number",
",",
"num_digits",
",",
"rounding",
"=",
"ROUND_HALF_UP",
")",
":",
"exp",
"=",
"Decimal",
"(",
"10",
")",
"**",
"-",
"num_digits",
"if",
"num_digits",
">=",
"0",
":",
"return",
"number",
".",
"quantize",
"(",
"exp"... | Rounding for decimals with support for negative digits | [
"Rounding",
"for",
"decimals",
"with",
"support",
"for",
"negative",
"digits"
] | python | train |
vmalyi/adb_android | adb_android/adb_android.py | https://github.com/vmalyi/adb_android/blob/de53dc54f27b14dc8c2ae64b136a60a59e1a1cb1/adb_android/adb_android.py#L103-L111 | def uninstall(app, opts=[]):
"""
Uninstall app from target
:param app: app name to uninstall from target (e.g. "com.example.android.valid")
:param opts: list command options (e.g. ["-r", "-a"])
:return: result of _exec_command() execution
"""
adb_full_cmd = [v.ADB_COMMAND_PREFIX, v.ADB_COMMA... | [
"def",
"uninstall",
"(",
"app",
",",
"opts",
"=",
"[",
"]",
")",
":",
"adb_full_cmd",
"=",
"[",
"v",
".",
"ADB_COMMAND_PREFIX",
",",
"v",
".",
"ADB_COMMAND_UNINSTALL",
",",
"_convert_opts",
"(",
"opts",
")",
",",
"app",
"]",
"return",
"_exec_command",
"(... | Uninstall app from target
:param app: app name to uninstall from target (e.g. "com.example.android.valid")
:param opts: list command options (e.g. ["-r", "-a"])
:return: result of _exec_command() execution | [
"Uninstall",
"app",
"from",
"target",
":",
"param",
"app",
":",
"app",
"name",
"to",
"uninstall",
"from",
"target",
"(",
"e",
".",
"g",
".",
"com",
".",
"example",
".",
"android",
".",
"valid",
")",
":",
"param",
"opts",
":",
"list",
"command",
"opti... | python | train |
yyuu/botornado | boto/dynamodb/layer2.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/layer2.py#L258-L290 | def build_key_from_values(self, schema, hash_key, range_key=None):
"""
Build a Key structure to be used for accessing items
in Amazon DynamoDB. This method takes the supplied hash_key
and optional range_key and validates them against the
schema. If there is a mismatch, a TypeEr... | [
"def",
"build_key_from_values",
"(",
"self",
",",
"schema",
",",
"hash_key",
",",
"range_key",
"=",
"None",
")",
":",
"dynamodb_key",
"=",
"{",
"}",
"dynamodb_value",
"=",
"self",
".",
"dynamize_value",
"(",
"hash_key",
")",
"if",
"dynamodb_value",
".",
"key... | Build a Key structure to be used for accessing items
in Amazon DynamoDB. This method takes the supplied hash_key
and optional range_key and validates them against the
schema. If there is a mismatch, a TypeError is raised.
Otherwise, a Python dict version of a Amazon DynamoDB Key
... | [
"Build",
"a",
"Key",
"structure",
"to",
"be",
"used",
"for",
"accessing",
"items",
"in",
"Amazon",
"DynamoDB",
".",
"This",
"method",
"takes",
"the",
"supplied",
"hash_key",
"and",
"optional",
"range_key",
"and",
"validates",
"them",
"against",
"the",
"schema"... | python | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/checkers/_checkers.py | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_checkers.py#L67-L83 | def check_first_party_caveat(self, ctx, cav):
''' Checks the caveat against all registered caveat conditions.
:return: error message string if any or None
'''
try:
cond, arg = parse_caveat(cav)
except ValueError as ex:
# If we can't parse it, perhaps it's ... | [
"def",
"check_first_party_caveat",
"(",
"self",
",",
"ctx",
",",
"cav",
")",
":",
"try",
":",
"cond",
",",
"arg",
"=",
"parse_caveat",
"(",
"cav",
")",
"except",
"ValueError",
"as",
"ex",
":",
"# If we can't parse it, perhaps it's in some other format,",
"# return... | Checks the caveat against all registered caveat conditions.
:return: error message string if any or None | [
"Checks",
"the",
"caveat",
"against",
"all",
"registered",
"caveat",
"conditions",
".",
":",
"return",
":",
"error",
"message",
"string",
"if",
"any",
"or",
"None"
] | python | train |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L676-L710 | def get_unknown_check_result_brok(cmd_line):
"""Create unknown check result brok and fill it with command data
:param cmd_line: command line to extract data
:type cmd_line: str
:return: unknown check result brok
:rtype: alignak.objects.brok.Brok
"""
match = re.ma... | [
"def",
"get_unknown_check_result_brok",
"(",
"cmd_line",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'^\\[([0-9]{10})] PROCESS_(SERVICE)_CHECK_RESULT;'",
"r'([^\\;]*);([^\\;]*);([^\\;]*);([^\\|]*)(?:\\|(.*))?'",
",",
"cmd_line",
")",
"if",
"not",
"match",
":",
"match... | Create unknown check result brok and fill it with command data
:param cmd_line: command line to extract data
:type cmd_line: str
:return: unknown check result brok
:rtype: alignak.objects.brok.Brok | [
"Create",
"unknown",
"check",
"result",
"brok",
"and",
"fill",
"it",
"with",
"command",
"data"
] | python | train |
ladybug-tools/ladybug | ladybug/skymodel.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/skymodel.py#L411-L462 | def _dirint_bins(ktp, alt, w, dktp):
"""
Determine the bins for the DIRINT coefficients.
Args:
ktp : Altitude-independent clearness index
alt : Solar altitude angle
w : precipitable water estimated from surface dew-point temperature
dktp : stability index
Returns:
... | [
"def",
"_dirint_bins",
"(",
"ktp",
",",
"alt",
",",
"w",
",",
"dktp",
")",
":",
"it",
"=",
"range",
"(",
"len",
"(",
"ktp",
")",
")",
"# Create kt_prime bins",
"ktp_bin",
"=",
"[",
"-",
"1",
"]",
"*",
"len",
"(",
"ktp",
")",
"ktp_bin",
"=",
"[",
... | Determine the bins for the DIRINT coefficients.
Args:
ktp : Altitude-independent clearness index
alt : Solar altitude angle
w : precipitable water estimated from surface dew-point temperature
dktp : stability index
Returns:
tuple of ktp_bin, alt_bin, w_bin, dktp_bin | [
"Determine",
"the",
"bins",
"for",
"the",
"DIRINT",
"coefficients",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.