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 |
|---|---|---|---|---|---|---|---|---|
adafruit/Adafruit_Python_BluefruitLE | Adafruit_BluefruitLE/corebluetooth/adapter.py | https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/corebluetooth/adapter.py#L59-L69 | def _state_changed(self, state):
"""Called when the power state changes."""
logger.debug('Adapter state change: {0}'.format(state))
# Handle when powered on.
if state == 5:
self._powered_off.clear()
self._powered_on.set()
# Handle when powered off.
... | [
"def",
"_state_changed",
"(",
"self",
",",
"state",
")",
":",
"logger",
".",
"debug",
"(",
"'Adapter state change: {0}'",
".",
"format",
"(",
"state",
")",
")",
"# Handle when powered on.",
"if",
"state",
"==",
"5",
":",
"self",
".",
"_powered_off",
".",
"cl... | Called when the power state changes. | [
"Called",
"when",
"the",
"power",
"state",
"changes",
"."
] | python | valid |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/textio.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L238-L265 | def string_list_file(cls, filename):
"""
Read a list of string values from a file.
The file format is:
- # anywhere in the line begins a comment
- leading and trailing spaces are ignored
- empty lines are ignored
- strings cannot span over a single line
... | [
"def",
"string_list_file",
"(",
"cls",
",",
"filename",
")",
":",
"count",
"=",
"0",
"result",
"=",
"list",
"(",
")",
"fd",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"for",
"line",
"in",
"fd",
":",
"count",
"=",
"count",
"+",
"1",
"if",
"'#'... | Read a list of string values from a file.
The file format is:
- # anywhere in the line begins a comment
- leading and trailing spaces are ignored
- empty lines are ignored
- strings cannot span over a single line
@type filename: str
@param filename: Name o... | [
"Read",
"a",
"list",
"of",
"string",
"values",
"from",
"a",
"file",
"."
] | python | train |
PyMLGame/pymlgame | pymlgame/controller.py | https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L72-L85 | def _del_controller(self, uid):
"""
Remove controller from internal list and tell the game.
:param uid: Unique id of the controller
:type uid: str
"""
try:
self.controllers.pop(uid)
e = Event(uid, E_DISCONNECT)
self.queue.put_nowait(e)... | [
"def",
"_del_controller",
"(",
"self",
",",
"uid",
")",
":",
"try",
":",
"self",
".",
"controllers",
".",
"pop",
"(",
"uid",
")",
"e",
"=",
"Event",
"(",
"uid",
",",
"E_DISCONNECT",
")",
"self",
".",
"queue",
".",
"put_nowait",
"(",
"e",
")",
"exce... | Remove controller from internal list and tell the game.
:param uid: Unique id of the controller
:type uid: str | [
"Remove",
"controller",
"from",
"internal",
"list",
"and",
"tell",
"the",
"game",
"."
] | python | train |
SmokinCaterpillar/pypet | pypet/utils/storagefactory.py | https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/utils/storagefactory.py#L18-L25 | def _create_storage(storage_service, trajectory=None, **kwargs):
"""Creates a service from a constructor and checks which kwargs are not used"""
kwargs_copy = kwargs.copy()
kwargs_copy['trajectory'] = trajectory
matching_kwargs = get_matching_kwargs(storage_service, kwargs_copy)
storage_service = st... | [
"def",
"_create_storage",
"(",
"storage_service",
",",
"trajectory",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs_copy",
"=",
"kwargs",
".",
"copy",
"(",
")",
"kwargs_copy",
"[",
"'trajectory'",
"]",
"=",
"trajectory",
"matching_kwargs",
"=",
"get... | Creates a service from a constructor and checks which kwargs are not used | [
"Creates",
"a",
"service",
"from",
"a",
"constructor",
"and",
"checks",
"which",
"kwargs",
"are",
"not",
"used"
] | python | test |
materialsproject/pymatgen | pymatgen/core/sites.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/sites.py#L488-L507 | def is_periodic_image(self, other, tolerance=1e-8, check_lattice=True):
"""
Returns True if sites are periodic images of each other.
Args:
other (PeriodicSite): Other site
tolerance (float): Tolerance to compare fractional coordinates
check_lattice (bool): Wh... | [
"def",
"is_periodic_image",
"(",
"self",
",",
"other",
",",
"tolerance",
"=",
"1e-8",
",",
"check_lattice",
"=",
"True",
")",
":",
"if",
"check_lattice",
"and",
"self",
".",
"lattice",
"!=",
"other",
".",
"lattice",
":",
"return",
"False",
"if",
"self",
... | Returns True if sites are periodic images of each other.
Args:
other (PeriodicSite): Other site
tolerance (float): Tolerance to compare fractional coordinates
check_lattice (bool): Whether to check if the two sites have the
same lattice.
Returns:
... | [
"Returns",
"True",
"if",
"sites",
"are",
"periodic",
"images",
"of",
"each",
"other",
"."
] | python | train |
openid/python-openid | openid/consumer/consumer.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/consumer/consumer.py#L1326-L1362 | def _getOpenID1SessionType(self, assoc_response):
"""Given an association response message, extract the OpenID
1.X session type.
This function mostly takes care of the 'no-encryption' default
behavior in OpenID 1.
If the association type is plain-text, this function will
... | [
"def",
"_getOpenID1SessionType",
"(",
"self",
",",
"assoc_response",
")",
":",
"# If it's an OpenID 1 message, allow session_type to default",
"# to None (which signifies \"no-encryption\")",
"session_type",
"=",
"assoc_response",
".",
"getArg",
"(",
"OPENID1_NS",
",",
"'session_... | Given an association response message, extract the OpenID
1.X session type.
This function mostly takes care of the 'no-encryption' default
behavior in OpenID 1.
If the association type is plain-text, this function will
return 'no-encryption'
@returns: The association t... | [
"Given",
"an",
"association",
"response",
"message",
"extract",
"the",
"OpenID",
"1",
".",
"X",
"session",
"type",
"."
] | python | train |
decryptus/httpdis | httpdis/httpdis.py | https://github.com/decryptus/httpdis/blob/5d198cdc5558f416634602689b3df2c8aeb34984/httpdis/httpdis.py#L1018-L1112 | def register(handler,
op,
safe_init = None,
at_start = None,
name = None,
at_stop = None,
static = False,
root = None,
replacement = None,
charset ... | [
"def",
"register",
"(",
"handler",
",",
"op",
",",
"safe_init",
"=",
"None",
",",
"at_start",
"=",
"None",
",",
"name",
"=",
"None",
",",
"at_stop",
"=",
"None",
",",
"static",
"=",
"False",
",",
"root",
"=",
"None",
",",
"replacement",
"=",
"None",
... | Register a command
@handler: function to execute when the command is received
@op: http method(s)
@safe_init: called by the safe_init() function of this module
@at_start: called once just before the server starts
@at_stop: called once just before the server stops
@name: name of the command (if n... | [
"Register",
"a",
"command",
"@handler",
":",
"function",
"to",
"execute",
"when",
"the",
"command",
"is",
"received",
"@op",
":",
"http",
"method",
"(",
"s",
")",
"@safe_init",
":",
"called",
"by",
"the",
"safe_init",
"()",
"function",
"of",
"this",
"modul... | python | train |
googlefonts/fontbakery | Lib/fontbakery/reporters/html.py | https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/reporters/html.py#L104-L108 | def html_for_check(self, check) -> str:
"""Return HTML string for complete single check."""
check["logs"].sort(key=lambda c: LOGLEVELS.index(c["status"]))
logs = "<ul>" + "".join([self.log_html(log) for log in check["logs"]]) + "</ul>"
return logs | [
"def",
"html_for_check",
"(",
"self",
",",
"check",
")",
"->",
"str",
":",
"check",
"[",
"\"logs\"",
"]",
".",
"sort",
"(",
"key",
"=",
"lambda",
"c",
":",
"LOGLEVELS",
".",
"index",
"(",
"c",
"[",
"\"status\"",
"]",
")",
")",
"logs",
"=",
"\"<ul>\... | Return HTML string for complete single check. | [
"Return",
"HTML",
"string",
"for",
"complete",
"single",
"check",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/grading/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/sessions.py#L4756-L4779 | def alias_gradebook(self, gradebook_id, alias_id):
"""Adds an ``Id`` to a ``Gradebook`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Gradebook`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id`` . If the alias is a pointer... | [
"def",
"alias_gradebook",
"(",
"self",
",",
"gradebook_id",
",",
"alias_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinLookupSession.alias_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_cat... | Adds an ``Id`` to a ``Gradebook`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Gradebook`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id`` . If the alias is a pointer to another gradebook, it is
reassigned to the given g... | [
"Adds",
"an",
"Id",
"to",
"a",
"Gradebook",
"for",
"the",
"purpose",
"of",
"creating",
"compatibility",
"."
] | python | train |
amol-/depot | examples/turbogears/depotexample/model/auth.py | https://github.com/amol-/depot/blob/82104d2ae54f8ef55f05fb5a3f148cdc9f928959/examples/turbogears/depotexample/model/auth.py#L101-L103 | def by_user_name(cls, username):
"""Return the user object whose user name is ``username``."""
return DBSession.query(cls).filter_by(user_name=username).first() | [
"def",
"by_user_name",
"(",
"cls",
",",
"username",
")",
":",
"return",
"DBSession",
".",
"query",
"(",
"cls",
")",
".",
"filter_by",
"(",
"user_name",
"=",
"username",
")",
".",
"first",
"(",
")"
] | Return the user object whose user name is ``username``. | [
"Return",
"the",
"user",
"object",
"whose",
"user",
"name",
"is",
"username",
"."
] | python | train |
NuGrid/NuGridPy | nugridpy/mesa.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/mesa.py#L3827-L3944 | def abu_profiles(p,ifig=1,xlm=xlm,ylm=(-8,0),show=False,abunds='All',xaxis=xaxis_type, figsize1=(8,8)):
'''Four panels of abundance plots
Parameters
----------
p : instance
mesa_profile instance
xlm : tuple
xlimits: mass_min, mass_max
abus : 'All' plots many 'commonly used'... | [
"def",
"abu_profiles",
"(",
"p",
",",
"ifig",
"=",
"1",
",",
"xlm",
"=",
"xlm",
",",
"ylm",
"=",
"(",
"-",
"8",
",",
"0",
")",
",",
"show",
"=",
"False",
",",
"abunds",
"=",
"'All'",
",",
"xaxis",
"=",
"xaxis_type",
",",
"figsize1",
"=",
"(",
... | Four panels of abundance plots
Parameters
----------
p : instance
mesa_profile instance
xlm : tuple
xlimits: mass_min, mass_max
abus : 'All' plots many 'commonly used' isotopes up to Fe if they are in your mesa output.
otherwise provide a list of lists of desired abus
... | [
"Four",
"panels",
"of",
"abundance",
"plots"
] | python | train |
CalebBell/ht | ht/boiling_nucleic.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/boiling_nucleic.py#L1059-L1114 | def Serth_HEDH(D, sigma, Hvap, rhol, rhog):
r'''Calculates critical heat flux for nucleic boiling of a tube bundle
according to [2]_, citing [3]_, and using [1]_ as the original form.
.. math::
q_c = KH_{vap} \rho_g^{0.5}\left[\sigma g (\rho_L-\rho_g)\right]^{0.25}
K = 0.123 (R^*)^{-0.25} ... | [
"def",
"Serth_HEDH",
"(",
"D",
",",
"sigma",
",",
"Hvap",
",",
"rhol",
",",
"rhog",
")",
":",
"R",
"=",
"D",
"/",
"2",
"*",
"(",
"g",
"*",
"(",
"rhol",
"-",
"rhog",
")",
"/",
"sigma",
")",
"**",
"0.5",
"if",
"0.12",
"<=",
"R",
"<=",
"1.17",... | r'''Calculates critical heat flux for nucleic boiling of a tube bundle
according to [2]_, citing [3]_, and using [1]_ as the original form.
.. math::
q_c = KH_{vap} \rho_g^{0.5}\left[\sigma g (\rho_L-\rho_g)\right]^{0.25}
K = 0.123 (R^*)^{-0.25} \text{ for 0.12 < R* < 1.17}
K = 0.118
... | [
"r",
"Calculates",
"critical",
"heat",
"flux",
"for",
"nucleic",
"boiling",
"of",
"a",
"tube",
"bundle",
"according",
"to",
"[",
"2",
"]",
"_",
"citing",
"[",
"3",
"]",
"_",
"and",
"using",
"[",
"1",
"]",
"_",
"as",
"the",
"original",
"form",
"."
] | python | train |
dereneaton/ipyrad | ipyrad/analysis/sratools.py | https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/sratools.py#L441-L462 | def fields_checker(fields):
"""
returns a fields argument formatted as a list of strings.
and doesn't allow zero.
"""
## make sure fields will work
if isinstance(fields, int):
fields = str(fields)
if isinstance(fields, str):
if "," in fields:
fields = [str(i) for ... | [
"def",
"fields_checker",
"(",
"fields",
")",
":",
"## make sure fields will work",
"if",
"isinstance",
"(",
"fields",
",",
"int",
")",
":",
"fields",
"=",
"str",
"(",
"fields",
")",
"if",
"isinstance",
"(",
"fields",
",",
"str",
")",
":",
"if",
"\",\"",
... | returns a fields argument formatted as a list of strings.
and doesn't allow zero. | [
"returns",
"a",
"fields",
"argument",
"formatted",
"as",
"a",
"list",
"of",
"strings",
".",
"and",
"doesn",
"t",
"allow",
"zero",
"."
] | python | valid |
truemped/tornadotools | tornadotools/mongrel2/handler.py | https://github.com/truemped/tornadotools/blob/d22632b83810afc353fa886fbc9e265bee78653f/tornadotools/mongrel2/handler.py#L59-L68 | def _create_listening_stream(self, pull_addr):
"""
Create a stream listening for Requests. The `self._recv_callback`
method is asociated with incoming requests.
"""
sock = self._zmq_context.socket(zmq.PULL)
sock.connect(pull_addr)
stream = ZMQStream(sock, io_loop=... | [
"def",
"_create_listening_stream",
"(",
"self",
",",
"pull_addr",
")",
":",
"sock",
"=",
"self",
".",
"_zmq_context",
".",
"socket",
"(",
"zmq",
".",
"PULL",
")",
"sock",
".",
"connect",
"(",
"pull_addr",
")",
"stream",
"=",
"ZMQStream",
"(",
"sock",
","... | Create a stream listening for Requests. The `self._recv_callback`
method is asociated with incoming requests. | [
"Create",
"a",
"stream",
"listening",
"for",
"Requests",
".",
"The",
"self",
".",
"_recv_callback",
"method",
"is",
"asociated",
"with",
"incoming",
"requests",
"."
] | python | train |
hyperboria/python-cjdns | setup.py | https://github.com/hyperboria/python-cjdns/blob/a9ae5d6d2e99c18f9fc50a9589729cd176efa900/setup.py#L20-L29 | def readme(fname):
"""Reads a markdown file and returns the contents formatted as rst"""
md = open(os.path.join(os.path.dirname(__file__), fname)).read()
output = md
try:
import pypandoc
output = pypandoc.convert(md, 'rst', format='md')
except ImportError:
pass
return out... | [
"def",
"readme",
"(",
"fname",
")",
":",
"md",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"fname",
")",
")",
".",
"read",
"(",
")",
"output",
"=",
"md",
"try",
":",
"im... | Reads a markdown file and returns the contents formatted as rst | [
"Reads",
"a",
"markdown",
"file",
"and",
"returns",
"the",
"contents",
"formatted",
"as",
"rst"
] | python | train |
f3at/feat | src/feat/agencies/agency.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/agencies/agency.py#L1339-L1343 | def snapshot_agents(self, force=False):
'''snapshot agents if number of entries from last snapshot if greater
than 1000. Use force=True to override.'''
for agent in self._agents:
agent.check_if_should_snapshot(force) | [
"def",
"snapshot_agents",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"for",
"agent",
"in",
"self",
".",
"_agents",
":",
"agent",
".",
"check_if_should_snapshot",
"(",
"force",
")"
] | snapshot agents if number of entries from last snapshot if greater
than 1000. Use force=True to override. | [
"snapshot",
"agents",
"if",
"number",
"of",
"entries",
"from",
"last",
"snapshot",
"if",
"greater",
"than",
"1000",
".",
"Use",
"force",
"=",
"True",
"to",
"override",
"."
] | python | train |
foliant-docs/foliantcontrib.includes | foliant/preprocessors/includes.py | https://github.com/foliant-docs/foliantcontrib.includes/blob/4bd89f6d287c9e21246d984c90ad05c2ccd24fcc/foliant/preprocessors/includes.py#L53-L108 | def _sync_repo(self, repo_url: str, revision: str or None = None) -> Path:
'''Clone a Git repository to the cache dir. If it has been cloned before, update it.
:param repo_url: Repository URL
:param revision: Revision: branch, commit hash, or tag
:returns: Path to the cloned repository... | [
"def",
"_sync_repo",
"(",
"self",
",",
"repo_url",
":",
"str",
",",
"revision",
":",
"str",
"or",
"None",
"=",
"None",
")",
"->",
"Path",
":",
"repo_name",
"=",
"repo_url",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
".",
"rsplit",
"(",
"'... | Clone a Git repository to the cache dir. If it has been cloned before, update it.
:param repo_url: Repository URL
:param revision: Revision: branch, commit hash, or tag
:returns: Path to the cloned repository | [
"Clone",
"a",
"Git",
"repository",
"to",
"the",
"cache",
"dir",
".",
"If",
"it",
"has",
"been",
"cloned",
"before",
"update",
"it",
"."
] | python | train |
zeehio/parmap | parmap/parmap.py | https://github.com/zeehio/parmap/blob/368b77e1a49ff30aef9de2274ad430ad43a3f617/parmap/parmap.py#L220-L273 | def _map_or_starmap(function, iterable, args, kwargs, map_or_starmap):
"""
Shared function between parmap.map and parmap.starmap.
Refer to those functions for details.
"""
arg_newarg = (("parallel", "pm_parallel"), ("chunksize", "pm_chunksize"),
("pool", "pm_pool"), ("processes", "... | [
"def",
"_map_or_starmap",
"(",
"function",
",",
"iterable",
",",
"args",
",",
"kwargs",
",",
"map_or_starmap",
")",
":",
"arg_newarg",
"=",
"(",
"(",
"\"parallel\"",
",",
"\"pm_parallel\"",
")",
",",
"(",
"\"chunksize\"",
",",
"\"pm_chunksize\"",
")",
",",
"... | Shared function between parmap.map and parmap.starmap.
Refer to those functions for details. | [
"Shared",
"function",
"between",
"parmap",
".",
"map",
"and",
"parmap",
".",
"starmap",
".",
"Refer",
"to",
"those",
"functions",
"for",
"details",
"."
] | python | train |
Nic30/hwt | hwt/hdl/types/arrayCast.py | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/arrayCast.py#L11-L49 | def getBits_from_array(array, wordWidth, start, end,
reinterpretElmToType=None):
"""
Gets value of bits between selected range from memory
:param start: bit address of start of bit of bits
:param end: bit address of first bit behind bits
:return: instance of BitsVal (derived ... | [
"def",
"getBits_from_array",
"(",
"array",
",",
"wordWidth",
",",
"start",
",",
"end",
",",
"reinterpretElmToType",
"=",
"None",
")",
":",
"inPartOffset",
"=",
"0",
"value",
"=",
"Bits",
"(",
"end",
"-",
"start",
",",
"None",
")",
".",
"fromPy",
"(",
"... | Gets value of bits between selected range from memory
:param start: bit address of start of bit of bits
:param end: bit address of first bit behind bits
:return: instance of BitsVal (derived from SimBits type) which contains
copy of selected bits | [
"Gets",
"value",
"of",
"bits",
"between",
"selected",
"range",
"from",
"memory"
] | python | test |
croscon/fleaker | fleaker/component.py | https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/component.py#L222-L241 | def clear_context(self, app=None):
"""Clear the component's context.
Keyword Args:
app (flask.Flask, optional): The app to clear this component's
context for. If omitted, the value from ``Component.app`` is
used.
"""
if (app is None and self._... | [
"def",
"clear_context",
"(",
"self",
",",
"app",
"=",
"None",
")",
":",
"if",
"(",
"app",
"is",
"None",
"and",
"self",
".",
"_context",
"is",
"_CONTEXT_MISSING",
"and",
"not",
"in_app_context",
"(",
")",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Attempt... | Clear the component's context.
Keyword Args:
app (flask.Flask, optional): The app to clear this component's
context for. If omitted, the value from ``Component.app`` is
used. | [
"Clear",
"the",
"component",
"s",
"context",
"."
] | python | train |
KelSolaar/Foundations | foundations/namespace.py | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/namespace.py#L67-L95 | def get_namespace(attribute, namespace_splitter=NAMESPACE_SPLITTER, root_only=False):
"""
Returns given attribute foundations.namespace.
Usage::
>>> get_namespace("grandParent|parent|child")
u'grandParent|parent'
>>> get_namespace("grandParent|parent|child", root_only=True)
... | [
"def",
"get_namespace",
"(",
"attribute",
",",
"namespace_splitter",
"=",
"NAMESPACE_SPLITTER",
",",
"root_only",
"=",
"False",
")",
":",
"attribute_tokens",
"=",
"attribute",
".",
"split",
"(",
"namespace_splitter",
")",
"if",
"len",
"(",
"attribute_tokens",
")",... | Returns given attribute foundations.namespace.
Usage::
>>> get_namespace("grandParent|parent|child")
u'grandParent|parent'
>>> get_namespace("grandParent|parent|child", root_only=True)
u'grandParent'
:param attribute: Attribute.
:type attribute: unicode
:param namespac... | [
"Returns",
"given",
"attribute",
"foundations",
".",
"namespace",
"."
] | python | train |
rigetti/pyquil | pyquil/paulis.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/paulis.py#L952-L995 | def trotterize(first_pauli_term, second_pauli_term, trotter_order=1,
trotter_steps=1):
"""
Create a Quil program that approximates exp( (A + B)t) where A and B are
PauliTerm operators.
:param PauliTerm first_pauli_term: PauliTerm denoted `A`
:param PauliTerm second_pauli_term: PauliT... | [
"def",
"trotterize",
"(",
"first_pauli_term",
",",
"second_pauli_term",
",",
"trotter_order",
"=",
"1",
",",
"trotter_steps",
"=",
"1",
")",
":",
"if",
"not",
"(",
"1",
"<=",
"trotter_order",
"<",
"5",
")",
":",
"raise",
"ValueError",
"(",
"\"trotterize only... | Create a Quil program that approximates exp( (A + B)t) where A and B are
PauliTerm operators.
:param PauliTerm first_pauli_term: PauliTerm denoted `A`
:param PauliTerm second_pauli_term: PauliTerm denoted `B`
:param int trotter_order: Optional argument indicating the Suzuki-Trotter
... | [
"Create",
"a",
"Quil",
"program",
"that",
"approximates",
"exp",
"(",
"(",
"A",
"+",
"B",
")",
"t",
")",
"where",
"A",
"and",
"B",
"are",
"PauliTerm",
"operators",
"."
] | python | train |
Microsoft/nni | tools/nni_cmd/nnictl_utils.py | https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/nnictl_utils.py#L304-L311 | def log_internal(args, filetype):
'''internal function to call get_log_content'''
file_name = get_config_filename(args)
if filetype == 'stdout':
file_full_path = os.path.join(NNICTL_HOME_DIR, file_name, 'stdout')
else:
file_full_path = os.path.join(NNICTL_HOME_DIR, file_name, 'stderr')
... | [
"def",
"log_internal",
"(",
"args",
",",
"filetype",
")",
":",
"file_name",
"=",
"get_config_filename",
"(",
"args",
")",
"if",
"filetype",
"==",
"'stdout'",
":",
"file_full_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"NNICTL_HOME_DIR",
",",
"file_name"... | internal function to call get_log_content | [
"internal",
"function",
"to",
"call",
"get_log_content"
] | python | train |
eerimoq/bincopy | bincopy.py | https://github.com/eerimoq/bincopy/blob/5e02cd001c3e9b54729425db6bffad5f03e1beac/bincopy.py#L754-L773 | def add_srec(self, records, overwrite=False):
"""Add given Motorola S-Records string. Set `overwrite` to ``True`` to
allow already added data to be overwritten.
"""
for record in StringIO(records):
type_, address, size, data = unpack_srec(record.strip())
if typ... | [
"def",
"add_srec",
"(",
"self",
",",
"records",
",",
"overwrite",
"=",
"False",
")",
":",
"for",
"record",
"in",
"StringIO",
"(",
"records",
")",
":",
"type_",
",",
"address",
",",
"size",
",",
"data",
"=",
"unpack_srec",
"(",
"record",
".",
"strip",
... | Add given Motorola S-Records string. Set `overwrite` to ``True`` to
allow already added data to be overwritten. | [
"Add",
"given",
"Motorola",
"S",
"-",
"Records",
"string",
".",
"Set",
"overwrite",
"to",
"True",
"to",
"allow",
"already",
"added",
"data",
"to",
"be",
"overwritten",
"."
] | python | train |
klmitch/turnstile | turnstile/limits.py | https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/limits.py#L198-L229 | def decode(cls, key):
"""
Decode a bucket key into a BucketKey instance.
:param key: The string form of a bucket key.
:returns: A suitable instance of BucketKey corresponding to
the passed-in key.
"""
# Determine bucket key version
prefix, sep... | [
"def",
"decode",
"(",
"cls",
",",
"key",
")",
":",
"# Determine bucket key version",
"prefix",
",",
"sep",
",",
"param_str",
"=",
"key",
".",
"partition",
"(",
"':'",
")",
"if",
"sep",
"!=",
"':'",
"or",
"prefix",
"not",
"in",
"cls",
".",
"_prefix_to_ver... | Decode a bucket key into a BucketKey instance.
:param key: The string form of a bucket key.
:returns: A suitable instance of BucketKey corresponding to
the passed-in key. | [
"Decode",
"a",
"bucket",
"key",
"into",
"a",
"BucketKey",
"instance",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/electronic_structure/boltztrap.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/boltztrap.py#L1125-L1196 | def get_thermal_conductivity(self, output='eigs', doping_levels=True,
k_el=True, relaxation_time=1e-14):
"""
Gives the electronic part of the thermal conductivity in either a
full 3x3 tensor form,
as 3 eigenvalues, or as the average value (trace/3.0) If
... | [
"def",
"get_thermal_conductivity",
"(",
"self",
",",
"output",
"=",
"'eigs'",
",",
"doping_levels",
"=",
"True",
",",
"k_el",
"=",
"True",
",",
"relaxation_time",
"=",
"1e-14",
")",
":",
"result",
"=",
"None",
"result_doping",
"=",
"None",
"if",
"doping_leve... | Gives the electronic part of the thermal conductivity in either a
full 3x3 tensor form,
as 3 eigenvalues, or as the average value (trace/3.0) If
doping_levels=True, the results are given at
different p and n doping levels (given by self.doping), otherwise it
is given as a series ... | [
"Gives",
"the",
"electronic",
"part",
"of",
"the",
"thermal",
"conductivity",
"in",
"either",
"a",
"full",
"3x3",
"tensor",
"form",
"as",
"3",
"eigenvalues",
"or",
"as",
"the",
"average",
"value",
"(",
"trace",
"/",
"3",
".",
"0",
")",
"If",
"doping_leve... | python | train |
watson-developer-cloud/python-sdk | ibm_watson/speech_to_text_v1_adapter.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/speech_to_text_v1_adapter.py#L28-L241 | def recognize_using_websocket(self,
audio,
content_type,
recognize_callback,
model=None,
language_customization_id=None,
... | [
"def",
"recognize_using_websocket",
"(",
"self",
",",
"audio",
",",
"content_type",
",",
"recognize_callback",
",",
"model",
"=",
"None",
",",
"language_customization_id",
"=",
"None",
",",
"acoustic_customization_id",
"=",
"None",
",",
"customization_weight",
"=",
... | Sends audio for speech recognition using web sockets.
:param AudioSource audio: The audio to transcribe in the format specified by the
`Content-Type` header.
:param str content_type: The type of the input: audio/basic, audio/flac,
audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg... | [
"Sends",
"audio",
"for",
"speech",
"recognition",
"using",
"web",
"sockets",
"."
] | python | train |
angr/angr | angr/analyses/cfg/cfg_base.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/cfg/cfg_base.py#L2027-L2046 | def _resolve_indirect_jump_timelessly(self, addr, block, func_addr, jumpkind):
"""
Checks if MIPS32 and calls MIPS32 check, otherwise false
:param int addr: irsb address
:param pyvex.IRSB block: irsb
:param int func_addr: Function address
:return: If it was resolved and ... | [
"def",
"_resolve_indirect_jump_timelessly",
"(",
"self",
",",
"addr",
",",
"block",
",",
"func_addr",
",",
"jumpkind",
")",
":",
"if",
"block",
".",
"statements",
"is",
"None",
":",
"block",
"=",
"self",
".",
"project",
".",
"factory",
".",
"block",
"(",
... | Checks if MIPS32 and calls MIPS32 check, otherwise false
:param int addr: irsb address
:param pyvex.IRSB block: irsb
:param int func_addr: Function address
:return: If it was resolved and targets alongside it
:rtype: tuple | [
"Checks",
"if",
"MIPS32",
"and",
"calls",
"MIPS32",
"check",
"otherwise",
"false"
] | python | train |
assamite/creamas | creamas/core/environment.py | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/environment.py#L319-L335 | def destroy(self, folder=None, as_coro=False):
'''Destroy the environment.
Does the following:
1. calls :py:meth:`~creamas.core.Environment.save_info`
2. for each agent: calls :py:meth:`close`
3. Shuts down its RPC-service.
'''
async def _destroy(folder):
... | [
"def",
"destroy",
"(",
"self",
",",
"folder",
"=",
"None",
",",
"as_coro",
"=",
"False",
")",
":",
"async",
"def",
"_destroy",
"(",
"folder",
")",
":",
"ret",
"=",
"self",
".",
"save_info",
"(",
"folder",
")",
"for",
"a",
"in",
"self",
".",
"get_ag... | Destroy the environment.
Does the following:
1. calls :py:meth:`~creamas.core.Environment.save_info`
2. for each agent: calls :py:meth:`close`
3. Shuts down its RPC-service. | [
"Destroy",
"the",
"environment",
"."
] | python | train |
RJT1990/pyflux | pyflux/inference/bbvi.py | https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/inference/bbvi.py#L54-L62 | def change_parameters(self,params):
"""
Utility function for changing the approximate distribution parameters
"""
no_of_params = 0
for core_param in range(len(self.q)):
for approx_param in range(self.q[core_param].param_no):
self.q[core_param].vi_chang... | [
"def",
"change_parameters",
"(",
"self",
",",
"params",
")",
":",
"no_of_params",
"=",
"0",
"for",
"core_param",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"q",
")",
")",
":",
"for",
"approx_param",
"in",
"range",
"(",
"self",
".",
"q",
"[",
"core_... | Utility function for changing the approximate distribution parameters | [
"Utility",
"function",
"for",
"changing",
"the",
"approximate",
"distribution",
"parameters"
] | python | train |
mediawiki-utilities/python-mwoauth | mwoauth/flask.py | https://github.com/mediawiki-utilities/python-mwoauth/blob/cd6990753ec3d59b7cfd96a76459f71ef4790cd3/mwoauth/flask.py#L200-L210 | def mwapi_session(self, *args, **kwargs):
"""
Create :class:`mwapi.Session` that is authorized for the current
user.
`args` and `kwargs` are passed directly to :class:`mwapi.Session`
"""
import mwapi
auth1 = self.generate_auth()
return mwapi.Session(*args... | [
"def",
"mwapi_session",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"mwapi",
"auth1",
"=",
"self",
".",
"generate_auth",
"(",
")",
"return",
"mwapi",
".",
"Session",
"(",
"*",
"args",
",",
"user_agent",
"=",
"self",
".... | Create :class:`mwapi.Session` that is authorized for the current
user.
`args` and `kwargs` are passed directly to :class:`mwapi.Session` | [
"Create",
":",
"class",
":",
"mwapi",
".",
"Session",
"that",
"is",
"authorized",
"for",
"the",
"current",
"user",
"."
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/websocket/recognize_listener.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/websocket/recognize_listener.py#L139-L150 | def on_open(self, ws):
"""
Callback executed when a connection is opened to the server.
Handles streaming of audio to the server.
:param ws: Websocket client
"""
self.callback.on_connected()
# Send initialization message
init_data = self.build_start_mess... | [
"def",
"on_open",
"(",
"self",
",",
"ws",
")",
":",
"self",
".",
"callback",
".",
"on_connected",
"(",
")",
"# Send initialization message",
"init_data",
"=",
"self",
".",
"build_start_message",
"(",
"self",
".",
"options",
")",
"self",
".",
"ws_client",
"."... | Callback executed when a connection is opened to the server.
Handles streaming of audio to the server.
:param ws: Websocket client | [
"Callback",
"executed",
"when",
"a",
"connection",
"is",
"opened",
"to",
"the",
"server",
".",
"Handles",
"streaming",
"of",
"audio",
"to",
"the",
"server",
"."
] | python | train |
CityOfZion/neo-python | neo/Wallets/Wallet.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Wallets/Wallet.py#L560-L581 | def GetTokenBalance(self, token, watch_only=0):
"""
Get the balance of the specified token.
Args:
token (NEP5Token): an instance of type neo.Wallets.NEP5Token to get the balance from.
watch_only (bool): True, to limit to watch only wallets.
Returns:
... | [
"def",
"GetTokenBalance",
"(",
"self",
",",
"token",
",",
"watch_only",
"=",
"0",
")",
":",
"total",
"=",
"Decimal",
"(",
"0",
")",
"if",
"watch_only",
">",
"0",
":",
"for",
"addr",
"in",
"self",
".",
"_watch_only",
":",
"balance",
"=",
"token",
".",... | Get the balance of the specified token.
Args:
token (NEP5Token): an instance of type neo.Wallets.NEP5Token to get the balance from.
watch_only (bool): True, to limit to watch only wallets.
Returns:
Decimal: total balance for `token`. | [
"Get",
"the",
"balance",
"of",
"the",
"specified",
"token",
"."
] | python | train |
AguaClara/aguaclara | aguaclara/core/physchem.py | https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/core/physchem.py#L219-L230 | def headloss_fric(FlowRate, Diam, Length, Nu, PipeRough):
"""Return the major head loss (due to wall shear) in a pipe.
This equation applies to both laminar and turbulent flows.
"""
#Checking input validity - inputs not checked here are checked by
#functions this function calls.
ut.check_range(... | [
"def",
"headloss_fric",
"(",
"FlowRate",
",",
"Diam",
",",
"Length",
",",
"Nu",
",",
"PipeRough",
")",
":",
"#Checking input validity - inputs not checked here are checked by",
"#functions this function calls.",
"ut",
".",
"check_range",
"(",
"[",
"Length",
",",
"\">0\"... | Return the major head loss (due to wall shear) in a pipe.
This equation applies to both laminar and turbulent flows. | [
"Return",
"the",
"major",
"head",
"loss",
"(",
"due",
"to",
"wall",
"shear",
")",
"in",
"a",
"pipe",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xlogrecordwidget/xlogrecordwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xlogrecordwidget/xlogrecordwidget.py#L358-L376 | def setActiveLevels(self, levels):
"""
Defines the levels for this widgets visible/processed levels.
:param levels | [<int>, ..]
"""
self._activeLevels = levels
tree = self.uiRecordTREE
tree.setUpdatesEnabled(False)
tree.blockSignals... | [
"def",
"setActiveLevels",
"(",
"self",
",",
"levels",
")",
":",
"self",
".",
"_activeLevels",
"=",
"levels",
"tree",
"=",
"self",
".",
"uiRecordTREE",
"tree",
".",
"setUpdatesEnabled",
"(",
"False",
")",
"tree",
".",
"blockSignals",
"(",
"True",
")",
"for"... | Defines the levels for this widgets visible/processed levels.
:param levels | [<int>, ..] | [
"Defines",
"the",
"levels",
"for",
"this",
"widgets",
"visible",
"/",
"processed",
"levels",
".",
":",
"param",
"levels",
"|",
"[",
"<int",
">",
"..",
"]"
] | python | train |
materialsproject/pymatgen | pymatgen/io/abinit/tasks.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L770-L817 | def select_qadapter(self, pconfs):
"""
Given a list of parallel configurations, pconfs, this method select an `optimal` configuration
according to some criterion as well as the :class:`QueueAdapter` to use.
Args:
pconfs: :class:`ParalHints` object with the list of parallel c... | [
"def",
"select_qadapter",
"(",
"self",
",",
"pconfs",
")",
":",
"# Order the list of configurations according to policy.",
"policy",
",",
"max_ncpus",
"=",
"self",
".",
"policy",
",",
"self",
".",
"max_cores",
"pconfs",
"=",
"pconfs",
".",
"get_ordered_with_policy",
... | Given a list of parallel configurations, pconfs, this method select an `optimal` configuration
according to some criterion as well as the :class:`QueueAdapter` to use.
Args:
pconfs: :class:`ParalHints` object with the list of parallel configurations
Returns:
:class:`Par... | [
"Given",
"a",
"list",
"of",
"parallel",
"configurations",
"pconfs",
"this",
"method",
"select",
"an",
"optimal",
"configuration",
"according",
"to",
"some",
"criterion",
"as",
"well",
"as",
"the",
":",
"class",
":",
"QueueAdapter",
"to",
"use",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_ras_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_ras_ext.py#L52-L64 | def show_raslog_output_show_all_raslog_number_of_entries(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
show_raslog = ET.Element("show_raslog")
config = show_raslog
output = ET.SubElement(show_raslog, "output")
show_all_raslog = ET.SubEl... | [
"def",
"show_raslog_output_show_all_raslog_number_of_entries",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"show_raslog",
"=",
"ET",
".",
"Element",
"(",
"\"show_raslog\"",
")",
"config",
"=",
"s... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
stephen-bunn/file-config | src/file_config/utils.py | https://github.com/stephen-bunn/file-config/blob/93429360c949985202e1f2b9cd0340731819ba75/src/file_config/utils.py#L320-L333 | def is_array_type(type_):
""" Checks if the given type is a array type.
:param type_: The type to check
:return: True if the type is a array type, otherwise False
:rtype: bool
"""
array_types = _get_types(Types.ARRAY)
if is_typing_type(type_):
return type_ in array_types or (
... | [
"def",
"is_array_type",
"(",
"type_",
")",
":",
"array_types",
"=",
"_get_types",
"(",
"Types",
".",
"ARRAY",
")",
"if",
"is_typing_type",
"(",
"type_",
")",
":",
"return",
"type_",
"in",
"array_types",
"or",
"(",
"hasattr",
"(",
"type_",
",",
"\"__origin_... | Checks if the given type is a array type.
:param type_: The type to check
:return: True if the type is a array type, otherwise False
:rtype: bool | [
"Checks",
"if",
"the",
"given",
"type",
"is",
"a",
"array",
"type",
"."
] | python | train |
tomnor/channelpack | channelpack/pack.py | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L613-L624 | def set_stopextend(self, n):
"""Extend the True elements by n when setting the conditions
based on a 'stopcond' condition.
n is an integer >= 0.
.. note::
Updates the mask if not no_auto.
"""
self.conconf.set_condition('stopextend', n)
if not self.no_... | [
"def",
"set_stopextend",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"conconf",
".",
"set_condition",
"(",
"'stopextend'",
",",
"n",
")",
"if",
"not",
"self",
".",
"no_auto",
":",
"self",
".",
"make_mask",
"(",
")"
] | Extend the True elements by n when setting the conditions
based on a 'stopcond' condition.
n is an integer >= 0.
.. note::
Updates the mask if not no_auto. | [
"Extend",
"the",
"True",
"elements",
"by",
"n",
"when",
"setting",
"the",
"conditions",
"based",
"on",
"a",
"stopcond",
"condition",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/structural/validate.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/validate.py#L77-L96 | def _survivor_merge(call_vcf, truth_vcf, stats, work_dir, data):
"""Perform a merge of two callsets using SURVIVOR,
"""
out_file = os.path.join(work_dir, "eval-merge.vcf")
if not utils.file_uptodate(out_file, call_vcf):
in_call_vcf = call_vcf.replace(".vcf.gz", ".vcf")
if not utils.file_... | [
"def",
"_survivor_merge",
"(",
"call_vcf",
",",
"truth_vcf",
",",
"stats",
",",
"work_dir",
",",
"data",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"eval-merge.vcf\"",
")",
"if",
"not",
"utils",
".",
"file_uptodate",... | Perform a merge of two callsets using SURVIVOR, | [
"Perform",
"a",
"merge",
"of",
"two",
"callsets",
"using",
"SURVIVOR"
] | python | train |
hvac/hvac | hvac/api/secrets_engines/transit.py | https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/transit.py#L759-L792 | def restore_key(self, backup, name=None, force=False, mount_point=DEFAULT_MOUNT_POINT):
"""Restore the backup as a named key.
This will restore the key configurations and all the versions of the named key along with HMAC keys. The input
to this endpoint should be the output of /backup endpoint.... | [
"def",
"restore_key",
"(",
"self",
",",
"backup",
",",
"name",
"=",
"None",
",",
"force",
"=",
"False",
",",
"mount_point",
"=",
"DEFAULT_MOUNT_POINT",
")",
":",
"params",
"=",
"{",
"'backup'",
":",
"backup",
",",
"'force'",
":",
"force",
",",
"}",
"ap... | Restore the backup as a named key.
This will restore the key configurations and all the versions of the named key along with HMAC keys. The input
to this endpoint should be the output of /backup endpoint. For safety, by default the backend will refuse to
restore to an existing key. If you want ... | [
"Restore",
"the",
"backup",
"as",
"a",
"named",
"key",
"."
] | python | train |
getnikola/coil | coil/utils.py | https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/utils.py#L70-L90 | def ask_yesno(query, default=None):
"""Ask a yes/no question."""
if default is None:
default_q = ' [y/n]'
elif default is True:
default_q = ' [Y/n]'
elif default is False:
default_q = ' [y/N]'
if sys.version_info[0] == 3:
inp = raw_input("{query}{default_q} ".format(
... | [
"def",
"ask_yesno",
"(",
"query",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"None",
":",
"default_q",
"=",
"' [y/n]'",
"elif",
"default",
"is",
"True",
":",
"default_q",
"=",
"' [Y/n]'",
"elif",
"default",
"is",
"False",
":",
"default... | Ask a yes/no question. | [
"Ask",
"a",
"yes",
"/",
"no",
"question",
"."
] | python | train |
sentinel-hub/sentinelhub-py | sentinelhub/geometry.py | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geometry.py#L284-L297 | def get_partition(self, num_x=1, num_y=1):
""" Partitions bounding box into smaller bounding boxes of the same size.
:param num_x: Number of parts BBox will be horizontally divided into.
:type num_x: int
:param num_y: Number of parts BBox will be vertically divided into.
:type n... | [
"def",
"get_partition",
"(",
"self",
",",
"num_x",
"=",
"1",
",",
"num_y",
"=",
"1",
")",
":",
"size_x",
",",
"size_y",
"=",
"(",
"self",
".",
"max_x",
"-",
"self",
".",
"min_x",
")",
"/",
"num_x",
",",
"(",
"self",
".",
"max_y",
"-",
"self",
"... | Partitions bounding box into smaller bounding boxes of the same size.
:param num_x: Number of parts BBox will be horizontally divided into.
:type num_x: int
:param num_y: Number of parts BBox will be vertically divided into.
:type num_y: int or None
:return: Two-dimensional list... | [
"Partitions",
"bounding",
"box",
"into",
"smaller",
"bounding",
"boxes",
"of",
"the",
"same",
"size",
"."
] | python | train |
twilio/twilio-python | twilio/rest/api/v2010/account/sip/credential_list/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/sip/credential_list/__init__.py#L288-L301 | def credentials(self):
"""
Access the credentials
:returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList
:rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList
"""
if self._credentials is None:
self.... | [
"def",
"credentials",
"(",
"self",
")",
":",
"if",
"self",
".",
"_credentials",
"is",
"None",
":",
"self",
".",
"_credentials",
"=",
"CredentialList",
"(",
"self",
".",
"_version",
",",
"account_sid",
"=",
"self",
".",
"_solution",
"[",
"'account_sid'",
"]... | Access the credentials
:returns: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList
:rtype: twilio.rest.api.v2010.account.sip.credential_list.credential.CredentialList | [
"Access",
"the",
"credentials"
] | python | train |
SeattleTestbed/seash | pyreadline/console/console.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L803-L820 | def install_readline(hook):
'''Set up things for the interpreter to call
our function like GNU readline.'''
global readline_hook, readline_ref
# save the hook so the wrapper can call it
readline_hook = hook
# get the address of PyOS_ReadlineFunctionPointer so we can update it
PyOS_RF... | [
"def",
"install_readline",
"(",
"hook",
")",
":",
"global",
"readline_hook",
",",
"readline_ref",
"# save the hook so the wrapper can call it\r",
"readline_hook",
"=",
"hook",
"# get the address of PyOS_ReadlineFunctionPointer so we can update it\r",
"PyOS_RFP",
"=",
"c_void_p",
... | Set up things for the interpreter to call
our function like GNU readline. | [
"Set",
"up",
"things",
"for",
"the",
"interpreter",
"to",
"call",
"our",
"function",
"like",
"GNU",
"readline",
"."
] | python | train |
mikedh/trimesh | trimesh/path/simplify.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/simplify.py#L15-L104 | def fit_circle_check(points,
scale,
prior=None,
final=False,
verbose=False):
"""
Fit a circle, and reject the fit if:
* the radius is larger than tol.radius_min*scale or tol.radius_max*scale
* any segment spans more than... | [
"def",
"fit_circle_check",
"(",
"points",
",",
"scale",
",",
"prior",
"=",
"None",
",",
"final",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"# an arc needs at least three points",
"if",
"len",
"(",
"points",
")",
"<",
"3",
":",
"return",
"None",... | Fit a circle, and reject the fit if:
* the radius is larger than tol.radius_min*scale or tol.radius_max*scale
* any segment spans more than tol.seg_angle
* any segment is longer than tol.seg_frac*scale
* the fit deviates by more than tol.radius_frac*radius
* the segments on the ends deviate from tan... | [
"Fit",
"a",
"circle",
"and",
"reject",
"the",
"fit",
"if",
":",
"*",
"the",
"radius",
"is",
"larger",
"than",
"tol",
".",
"radius_min",
"*",
"scale",
"or",
"tol",
".",
"radius_max",
"*",
"scale",
"*",
"any",
"segment",
"spans",
"more",
"than",
"tol",
... | python | train |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_1/profile_regions/profile_regions_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/profile_regions/profile_regions_client.py#L28-L41 | def get_geo_region(self, ip):
"""GetGeoRegion.
[Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address.
:param str ip:
:rtype: :class:`<GeoRegion> <azure.devops.v5_1.profile-regions.models.GeoRegion>`
"""
query_parameters = {}
... | [
"def",
"get_geo_region",
"(",
"self",
",",
"ip",
")",
":",
"query_parameters",
"=",
"{",
"}",
"if",
"ip",
"is",
"not",
"None",
":",
"query_parameters",
"[",
"'ip'",
"]",
"=",
"self",
".",
"_serialize",
".",
"query",
"(",
"'ip'",
",",
"ip",
",",
"'str... | GetGeoRegion.
[Preview API] Lookup up country/region based on provided IPv4, null if using the remote IPv4 address.
:param str ip:
:rtype: :class:`<GeoRegion> <azure.devops.v5_1.profile-regions.models.GeoRegion>` | [
"GetGeoRegion",
".",
"[",
"Preview",
"API",
"]",
"Lookup",
"up",
"country",
"/",
"region",
"based",
"on",
"provided",
"IPv4",
"null",
"if",
"using",
"the",
"remote",
"IPv4",
"address",
".",
":",
"param",
"str",
"ip",
":",
":",
"rtype",
":",
":",
"class... | python | train |
lipoja/URLExtract | urlextract/cachefile.py | https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/cachefile.py#L77-L94 | def _get_default_cache_file_path(self):
"""
Returns default cache file path
:return: default cache file path (to data directory)
:rtype: str
"""
default_list_path = os.path.join(
self._get_default_cache_dir(), self._CACHE_FILE_NAME)
if not os.access... | [
"def",
"_get_default_cache_file_path",
"(",
"self",
")",
":",
"default_list_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_get_default_cache_dir",
"(",
")",
",",
"self",
".",
"_CACHE_FILE_NAME",
")",
"if",
"not",
"os",
".",
"access",
"(",
... | Returns default cache file path
:return: default cache file path (to data directory)
:rtype: str | [
"Returns",
"default",
"cache",
"file",
"path"
] | python | train |
evolbioinfo/pastml | pastml/parsimony.py | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/parsimony.py#L114-L143 | def acctran(tree, character, feature=PARS_STATES):
"""
ACCTRAN (accelerated transformation) (Farris, 1970) aims at reducing the number of ambiguities
in the parsimonious result. ACCTRAN forces the state changes to be performed as close to the root as possible,
and therefore prioritises the reverse mutat... | [
"def",
"acctran",
"(",
"tree",
",",
"character",
",",
"feature",
"=",
"PARS_STATES",
")",
":",
"ps_feature_down",
"=",
"get_personalized_feature_name",
"(",
"character",
",",
"BU_PARS_STATES",
")",
"for",
"node",
"in",
"tree",
".",
"traverse",
"(",
"'preorder'",... | ACCTRAN (accelerated transformation) (Farris, 1970) aims at reducing the number of ambiguities
in the parsimonious result. ACCTRAN forces the state changes to be performed as close to the root as possible,
and therefore prioritises the reverse mutations.
if N is not a tip:
L, R <- left and right ch... | [
"ACCTRAN",
"(",
"accelerated",
"transformation",
")",
"(",
"Farris",
"1970",
")",
"aims",
"at",
"reducing",
"the",
"number",
"of",
"ambiguities",
"in",
"the",
"parsimonious",
"result",
".",
"ACCTRAN",
"forces",
"the",
"state",
"changes",
"to",
"be",
"performed... | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_help.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_help.py#L90-L94 | def idle_task(self):
'''called on idle'''
if self.module('console') is not None and not self.menu_added_console:
self.menu_added_console = True
self.module('console').add_menu(self.menu) | [
"def",
"idle_task",
"(",
"self",
")",
":",
"if",
"self",
".",
"module",
"(",
"'console'",
")",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"menu_added_console",
":",
"self",
".",
"menu_added_console",
"=",
"True",
"self",
".",
"module",
"(",
"'consol... | called on idle | [
"called",
"on",
"idle"
] | python | train |
fake-name/ChromeController | ChromeController/Generator/Generated.py | https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L2889-L2908 | def CacheStorage_deleteEntry(self, cacheId, request):
"""
Function path: CacheStorage.deleteEntry
Domain: CacheStorage
Method name: deleteEntry
Parameters:
Required arguments:
'cacheId' (type: CacheId) -> Id of cache where the entry will be deleted.
'request' (type: string) -> URL spec of ... | [
"def",
"CacheStorage_deleteEntry",
"(",
"self",
",",
"cacheId",
",",
"request",
")",
":",
"assert",
"isinstance",
"(",
"request",
",",
"(",
"str",
",",
")",
")",
",",
"\"Argument 'request' must be of type '['str']'. Received type: '%s'\"",
"%",
"type",
"(",
"request... | Function path: CacheStorage.deleteEntry
Domain: CacheStorage
Method name: deleteEntry
Parameters:
Required arguments:
'cacheId' (type: CacheId) -> Id of cache where the entry will be deleted.
'request' (type: string) -> URL spec of the request.
No return value.
Description: Deletes a ... | [
"Function",
"path",
":",
"CacheStorage",
".",
"deleteEntry",
"Domain",
":",
"CacheStorage",
"Method",
"name",
":",
"deleteEntry",
"Parameters",
":",
"Required",
"arguments",
":",
"cacheId",
"(",
"type",
":",
"CacheId",
")",
"-",
">",
"Id",
"of",
"cache",
"wh... | python | train |
BYU-PCCL/holodeck | holodeck/environments.py | https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/environments.py#L357-L367 | def set_control_scheme(self, agent_name, control_scheme):
"""Set the control scheme for a specific agent.
Args:
agent_name (str): The name of the agent to set the control scheme for.
control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`)
... | [
"def",
"set_control_scheme",
"(",
"self",
",",
"agent_name",
",",
"control_scheme",
")",
":",
"if",
"agent_name",
"not",
"in",
"self",
".",
"agents",
":",
"print",
"(",
"\"No such agent %s\"",
"%",
"agent_name",
")",
"else",
":",
"self",
".",
"agents",
"[",
... | Set the control scheme for a specific agent.
Args:
agent_name (str): The name of the agent to set the control scheme for.
control_scheme (int): A control scheme value (see :obj:`holodeck.agents.ControlSchemes`) | [
"Set",
"the",
"control",
"scheme",
"for",
"a",
"specific",
"agent",
"."
] | python | train |
markovmodel/PyEMMA | pyemma/coordinates/data/featurization/featurizer.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/data/featurization/featurizer.py#L236-L253 | def _check_indices(self, pair_inds, pair_n=2):
"""ensure pairs are valid (shapes, all atom indices available?, etc.)
"""
pair_inds = np.array(pair_inds).astype(dtype=np.int, casting='safe')
if pair_inds.ndim != 2:
raise ValueError("pair indices has to be a matrix.")
... | [
"def",
"_check_indices",
"(",
"self",
",",
"pair_inds",
",",
"pair_n",
"=",
"2",
")",
":",
"pair_inds",
"=",
"np",
".",
"array",
"(",
"pair_inds",
")",
".",
"astype",
"(",
"dtype",
"=",
"np",
".",
"int",
",",
"casting",
"=",
"'safe'",
")",
"if",
"p... | ensure pairs are valid (shapes, all atom indices available?, etc.) | [
"ensure",
"pairs",
"are",
"valid",
"(",
"shapes",
"all",
"atom",
"indices",
"available?",
"etc",
".",
")"
] | python | train |
learningequality/morango | morango/api/permissions.py | https://github.com/learningequality/morango/blob/c3ec2554b026f65ac5f0fc5c9d439277fbac14f9/morango/api/permissions.py#L15-L43 | def authenticate_credentials(self, userargs, password, request=None):
"""
Authenticate the userargs and password against Django auth backends.
The "userargs" string may be just the username, or a querystring-encoded set of params.
"""
credentials = {
'password': pass... | [
"def",
"authenticate_credentials",
"(",
"self",
",",
"userargs",
",",
"password",
",",
"request",
"=",
"None",
")",
":",
"credentials",
"=",
"{",
"'password'",
":",
"password",
"}",
"if",
"\"=\"",
"not",
"in",
"userargs",
":",
"# if it doesn't seem to be in quer... | Authenticate the userargs and password against Django auth backends.
The "userargs" string may be just the username, or a querystring-encoded set of params. | [
"Authenticate",
"the",
"userargs",
"and",
"password",
"against",
"Django",
"auth",
"backends",
".",
"The",
"userargs",
"string",
"may",
"be",
"just",
"the",
"username",
"or",
"a",
"querystring",
"-",
"encoded",
"set",
"of",
"params",
"."
] | python | valid |
saltstack/salt | salt/transport/tcp.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/transport/tcp.py#L650-L676 | def post_fork(self, payload_handler, io_loop):
'''
After forking we need to create all of the local sockets to listen to the
router
payload_handler: function to call with your payloads
'''
self.payload_handler = payload_handler
self.io_loop = io_loop
self... | [
"def",
"post_fork",
"(",
"self",
",",
"payload_handler",
",",
"io_loop",
")",
":",
"self",
".",
"payload_handler",
"=",
"payload_handler",
"self",
".",
"io_loop",
"=",
"io_loop",
"self",
".",
"serial",
"=",
"salt",
".",
"payload",
".",
"Serial",
"(",
"self... | After forking we need to create all of the local sockets to listen to the
router
payload_handler: function to call with your payloads | [
"After",
"forking",
"we",
"need",
"to",
"create",
"all",
"of",
"the",
"local",
"sockets",
"to",
"listen",
"to",
"the",
"router"
] | python | train |
camsci/meteor-pi | src/pythonModules/meteorpi_client/meteorpi_client/__init__.py | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L133-L158 | def search_files(self, search=None):
"""
Search for files, returning a FileRecord for each result. FileRecords have two additional
methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file
content and download that content to a named file o... | [
"def",
"search_files",
"(",
"self",
",",
"search",
"=",
"None",
")",
":",
"if",
"search",
"is",
"None",
":",
"search",
"=",
"model",
".",
"FileRecordSearch",
"(",
")",
"search_string",
"=",
"_to_encoded_string",
"(",
"search",
")",
"url",
"=",
"self",
".... | Search for files, returning a FileRecord for each result. FileRecords have two additional
methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file
content and download that content to a named file on disk, respectively.
:param FileRecordSearch se... | [
"Search",
"for",
"files",
"returning",
"a",
"FileRecord",
"for",
"each",
"result",
".",
"FileRecords",
"have",
"two",
"additional",
"methods",
"patched",
"into",
"them",
"get_url",
"()",
"and",
"download_to",
"(",
"file_name",
")",
"which",
"will",
"retrieve",
... | python | train |
wummel/linkchecker | third_party/dnspython/dns/rdatatype.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/rdatatype.py#L214-L222 | def is_metatype(rdtype):
"""True if the type is a metatype.
@param rdtype: the type
@type rdtype: int
@rtype: bool"""
if rdtype >= TKEY and rdtype <= ANY or rdtype in _metatypes:
return True
return False | [
"def",
"is_metatype",
"(",
"rdtype",
")",
":",
"if",
"rdtype",
">=",
"TKEY",
"and",
"rdtype",
"<=",
"ANY",
"or",
"rdtype",
"in",
"_metatypes",
":",
"return",
"True",
"return",
"False"
] | True if the type is a metatype.
@param rdtype: the type
@type rdtype: int
@rtype: bool | [
"True",
"if",
"the",
"type",
"is",
"a",
"metatype",
"."
] | python | train |
joopert/nad_receiver | nad_receiver/__init__.py | https://github.com/joopert/nad_receiver/blob/416de0173a330c75cc73f9c90b0c5df32e5e0ba3/nad_receiver/__init__.py#L320-L365 | def exec_command(self, domain, function, operator, value=None):
"""
Write a command to the receiver and read the value it returns.
"""
if operator in CMDS[domain][function]['supported_operators']:
if operator is '=' and value is None:
raise ValueError('No valu... | [
"def",
"exec_command",
"(",
"self",
",",
"domain",
",",
"function",
",",
"operator",
",",
"value",
"=",
"None",
")",
":",
"if",
"operator",
"in",
"CMDS",
"[",
"domain",
"]",
"[",
"function",
"]",
"[",
"'supported_operators'",
"]",
":",
"if",
"operator",
... | Write a command to the receiver and read the value it returns. | [
"Write",
"a",
"command",
"to",
"the",
"receiver",
"and",
"read",
"the",
"value",
"it",
"returns",
"."
] | python | test |
SatelliteQE/nailgun | nailgun/config.py | https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/config.py#L194-L235 | def save(self, label='default', path=None):
"""Save the current connection configuration to a file.
This method is thread safe.
:param label: A string. An identifier for the current configuration.
This allows multiple configurations with unique labels to be saved
in a s... | [
"def",
"save",
"(",
"self",
",",
"label",
"=",
"'default'",
",",
"path",
"=",
"None",
")",
":",
"# What will we write out?",
"cfg",
"=",
"vars",
"(",
"self",
")",
"if",
"'version'",
"in",
"cfg",
":",
"# pragma: no cover",
"cfg",
"[",
"'version'",
"]",
"=... | Save the current connection configuration to a file.
This method is thread safe.
:param label: A string. An identifier for the current configuration.
This allows multiple configurations with unique labels to be saved
in a single file. If a configuration identified by ``label``
... | [
"Save",
"the",
"current",
"connection",
"configuration",
"to",
"a",
"file",
"."
] | python | train |
aws/aws-xray-sdk-python | aws_xray_sdk/core/sampling/sampling_rule.py | https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/core/sampling/sampling_rule.py#L55-L69 | def snapshot_statistics(self):
"""
Take a snapshot of request/borrow/sampled count for reporting
back to X-Ray back-end by ``TargetPoller`` and reset those counters.
"""
with self._lock:
stats = {
'request_count': self.request_count,
'... | [
"def",
"snapshot_statistics",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"stats",
"=",
"{",
"'request_count'",
":",
"self",
".",
"request_count",
",",
"'borrow_count'",
":",
"self",
".",
"borrow_count",
",",
"'sampled_count'",
":",
"self",
"."... | Take a snapshot of request/borrow/sampled count for reporting
back to X-Ray back-end by ``TargetPoller`` and reset those counters. | [
"Take",
"a",
"snapshot",
"of",
"request",
"/",
"borrow",
"/",
"sampled",
"count",
"for",
"reporting",
"back",
"to",
"X",
"-",
"Ray",
"back",
"-",
"end",
"by",
"TargetPoller",
"and",
"reset",
"those",
"counters",
"."
] | python | train |
Parsely/birding | src/birding/config.py | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L189-L224 | def overlay(upper, lower):
"""Return the overlay of `upper` dict onto `lower` dict.
This operation is similar to `dict.update`, but recurses when it encounters
a dict/mapping, as to allow nested leaf values in the lower collection
which are not in the upper collection. Whenever the upper collection has... | [
"def",
"overlay",
"(",
"upper",
",",
"lower",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"upper",
":",
"if",
"is_mapping",
"(",
"upper",
"[",
"key",
"]",
")",
":",
"lower_value",
"=",
"lower",
".",
"get",
"(",
"key",
",",
"{",
"}",
... | Return the overlay of `upper` dict onto `lower` dict.
This operation is similar to `dict.update`, but recurses when it encounters
a dict/mapping, as to allow nested leaf values in the lower collection
which are not in the upper collection. Whenever the upper collection has a
value, its value is used.
... | [
"Return",
"the",
"overlay",
"of",
"upper",
"dict",
"onto",
"lower",
"dict",
"."
] | python | train |
phn/lineid_plot | lineid_plot/lineid_plot.py | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L233-L239 | def initial_annotate_kwargs():
"""Return default parameters passed to Axes.annotate to create labels."""
return dict(
xycoords="data", textcoords="data",
rotation=90, horizontalalignment="center", verticalalignment="center",
arrowprops=dict(arrowstyle="-", relpos=(0.5, 0.0))
) | [
"def",
"initial_annotate_kwargs",
"(",
")",
":",
"return",
"dict",
"(",
"xycoords",
"=",
"\"data\"",
",",
"textcoords",
"=",
"\"data\"",
",",
"rotation",
"=",
"90",
",",
"horizontalalignment",
"=",
"\"center\"",
",",
"verticalalignment",
"=",
"\"center\"",
",",
... | Return default parameters passed to Axes.annotate to create labels. | [
"Return",
"default",
"parameters",
"passed",
"to",
"Axes",
".",
"annotate",
"to",
"create",
"labels",
"."
] | python | train |
Rapptz/discord.py | discord/channel.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L740-L745 | async def create_voice_channel(self, name, *, overwrites=None, reason=None, **options):
"""|coro|
A shortcut method to :meth:`Guild.create_voice_channel` to create a :class:`VoiceChannel` in the category.
"""
return await self.guild.create_voice_channel(name, overwrites=overwrites, cate... | [
"async",
"def",
"create_voice_channel",
"(",
"self",
",",
"name",
",",
"*",
",",
"overwrites",
"=",
"None",
",",
"reason",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"return",
"await",
"self",
".",
"guild",
".",
"create_voice_channel",
"(",
"name",... | |coro|
A shortcut method to :meth:`Guild.create_voice_channel` to create a :class:`VoiceChannel` in the category. | [
"|coro|"
] | python | train |
DistrictDataLabs/yellowbrick | yellowbrick/contrib/missing/bar.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/contrib/missing/bar.py#L142-L163 | def draw_stacked_bar(self, nan_col_counts):
"""Draws a horizontal stacked bar chart with different colors
for each count of nan values per label.
"""
for index, nan_values in enumerate(nan_col_counts):
label, nan_col_counts = nan_values
if index == 0:
... | [
"def",
"draw_stacked_bar",
"(",
"self",
",",
"nan_col_counts",
")",
":",
"for",
"index",
",",
"nan_values",
"in",
"enumerate",
"(",
"nan_col_counts",
")",
":",
"label",
",",
"nan_col_counts",
"=",
"nan_values",
"if",
"index",
"==",
"0",
":",
"# first draw shou... | Draws a horizontal stacked bar chart with different colors
for each count of nan values per label. | [
"Draws",
"a",
"horizontal",
"stacked",
"bar",
"chart",
"with",
"different",
"colors",
"for",
"each",
"count",
"of",
"nan",
"values",
"per",
"label",
"."
] | python | train |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoL3.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoL3.py#L82-L108 | def alterar(self, id_groupl3, name):
"""Change Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: None
:raise InvalidPara... | [
"def",
"alterar",
"(",
"self",
",",
"id_groupl3",
",",
"name",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_groupl3",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Group L3 is invalid or was not informed.'",
")",
"url",
"=",
"'groupl3/... | Change Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: None
:raise InvalidParameterError: The identifier of Group L3 or name i... | [
"Change",
"Group",
"L3",
"from",
"by",
"the",
"identifier",
"."
] | python | train |
kolypto/py-good | good/schema/compiler.py | https://github.com/kolypto/py-good/blob/192ef19e79f6fd95c1cbd7c378a3074c7ad7a6d4/good/schema/compiler.py#L266-L295 | def _compile_literal(self, schema):
""" Compile literal schema: type and value matching """
# Prepare self
self.compiled_type = const.COMPILED_TYPE.LITERAL
self.name = get_literal_name(schema)
# Error partials
schema_type = type(schema)
err_type = self.Invalid(_... | [
"def",
"_compile_literal",
"(",
"self",
",",
"schema",
")",
":",
"# Prepare self",
"self",
".",
"compiled_type",
"=",
"const",
".",
"COMPILED_TYPE",
".",
"LITERAL",
"self",
".",
"name",
"=",
"get_literal_name",
"(",
"schema",
")",
"# Error partials",
"schema_typ... | Compile literal schema: type and value matching | [
"Compile",
"literal",
"schema",
":",
"type",
"and",
"value",
"matching"
] | python | train |
volafiled/python-volapi | volapi/volapi.py | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L348-L355 | def run_queues(self):
"""Run all queues that have data queued"""
if self.exception:
# pylint: disable=raising-bad-type
raise self.exception
listeners = self.__listeners_for_thread
return sum(l.process() for l in listeners) > 0 | [
"def",
"run_queues",
"(",
"self",
")",
":",
"if",
"self",
".",
"exception",
":",
"# pylint: disable=raising-bad-type",
"raise",
"self",
".",
"exception",
"listeners",
"=",
"self",
".",
"__listeners_for_thread",
"return",
"sum",
"(",
"l",
".",
"process",
"(",
"... | Run all queues that have data queued | [
"Run",
"all",
"queues",
"that",
"have",
"data",
"queued"
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/assistant_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/assistant_v1.py#L5987-L5997 | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'text') and self.text is not None:
_dict['text'] = self.text
if hasattr(self, '_additionalProperties'):
for _key in self._additionalProperties:
... | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'text'",
")",
"and",
"self",
".",
"text",
"is",
"not",
"None",
":",
"_dict",
"[",
"'text'",
"]",
"=",
"self",
".",
"text",
"if",
"hasattr",
"(",... | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | python | train |
pazz/urwidtrees | urwidtrees/nested.py | https://github.com/pazz/urwidtrees/blob/d1fa38ce4f37db00bdfc574b856023b5db4c7ead/urwidtrees/nested.py#L94-L100 | def _get_subtree_for(self, pos):
"""returns Tree that manages pos[-1]"""
res = self._tree
candidate = self._lookup_entry(self._tree, pos[:-1])
if isinstance(candidate, Tree):
res = candidate
return res | [
"def",
"_get_subtree_for",
"(",
"self",
",",
"pos",
")",
":",
"res",
"=",
"self",
".",
"_tree",
"candidate",
"=",
"self",
".",
"_lookup_entry",
"(",
"self",
".",
"_tree",
",",
"pos",
"[",
":",
"-",
"1",
"]",
")",
"if",
"isinstance",
"(",
"candidate",... | returns Tree that manages pos[-1] | [
"returns",
"Tree",
"that",
"manages",
"pos",
"[",
"-",
"1",
"]"
] | python | train |
KrishnaswamyLab/graphtools | graphtools/graphs.py | https://github.com/KrishnaswamyLab/graphtools/blob/44685352be7df2005d44722903092207967457f2/graphtools/graphs.py#L595-L635 | def build_landmark_op(self):
"""Build the landmark operator
Calculates spectral clusters on the kernel, and calculates transition
probabilities between cluster centers by using transition probabilities
between samples assigned to each cluster.
"""
tasklogger.log_start("l... | [
"def",
"build_landmark_op",
"(",
"self",
")",
":",
"tasklogger",
".",
"log_start",
"(",
"\"landmark operator\"",
")",
"is_sparse",
"=",
"sparse",
".",
"issparse",
"(",
"self",
".",
"kernel",
")",
"# spectral clustering",
"tasklogger",
".",
"log_start",
"(",
"\"S... | Build the landmark operator
Calculates spectral clusters on the kernel, and calculates transition
probabilities between cluster centers by using transition probabilities
between samples assigned to each cluster. | [
"Build",
"the",
"landmark",
"operator"
] | python | train |
rtfd/recommonmark | recommonmark/transform.py | https://github.com/rtfd/recommonmark/blob/815d75ea503f30af26ab67c6820078f84875b1fc/recommonmark/transform.py#L262-L283 | def find_replace(self, node):
"""Try to find replace node for current node.
Parameters
----------
node : docutil node
Node to find replacement for.
Returns
-------
nodes : node or list of node
The replacement nodes of current node.
... | [
"def",
"find_replace",
"(",
"self",
",",
"node",
")",
":",
"newnode",
"=",
"None",
"if",
"isinstance",
"(",
"node",
",",
"nodes",
".",
"Sequential",
")",
":",
"newnode",
"=",
"self",
".",
"auto_toc_tree",
"(",
"node",
")",
"elif",
"isinstance",
"(",
"n... | Try to find replace node for current node.
Parameters
----------
node : docutil node
Node to find replacement for.
Returns
-------
nodes : node or list of node
The replacement nodes of current node.
Returns None if no replacement can ... | [
"Try",
"to",
"find",
"replace",
"node",
"for",
"current",
"node",
"."
] | python | train |
LogicalDash/LiSE | ELiDE/ELiDE/game.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/game.py#L189-L199 | def wait_command(self, start_func, turns=1, end_func=None):
"""Call ``start_func``, and wait to call ``end_func`` after simulating ``turns`` (default 1)
:param start_func: function to call before waiting
:param turns: number of turns to wait
:param end_func: function to call after waiti... | [
"def",
"wait_command",
"(",
"self",
",",
"start_func",
",",
"turns",
"=",
"1",
",",
"end_func",
"=",
"None",
")",
":",
"start_func",
"(",
")",
"self",
".",
"wait_turns",
"(",
"turns",
",",
"cb",
"=",
"end_func",
")"
] | Call ``start_func``, and wait to call ``end_func`` after simulating ``turns`` (default 1)
:param start_func: function to call before waiting
:param turns: number of turns to wait
:param end_func: function to call after waiting
:return: ``None`` | [
"Call",
"start_func",
"and",
"wait",
"to",
"call",
"end_func",
"after",
"simulating",
"turns",
"(",
"default",
"1",
")"
] | python | train |
mar10/wsgidav | wsgidav/server/server_cli.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/server/server_cli.py#L520-L603 | def _run__cherrypy(app, config, mode):
"""Run WsgiDAV using cherrypy.wsgiserver if CherryPy is installed."""
assert mode == "cherrypy-wsgiserver"
try:
from cherrypy import wsgiserver
from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter
_logger.warning("WARNING: cherrypy.ws... | [
"def",
"_run__cherrypy",
"(",
"app",
",",
"config",
",",
"mode",
")",
":",
"assert",
"mode",
"==",
"\"cherrypy-wsgiserver\"",
"try",
":",
"from",
"cherrypy",
"import",
"wsgiserver",
"from",
"cherrypy",
".",
"wsgiserver",
".",
"ssl_builtin",
"import",
"BuiltinSSL... | Run WsgiDAV using cherrypy.wsgiserver if CherryPy is installed. | [
"Run",
"WsgiDAV",
"using",
"cherrypy",
".",
"wsgiserver",
"if",
"CherryPy",
"is",
"installed",
"."
] | python | valid |
davidchua/pymessenger | pymessenger/bot.py | https://github.com/davidchua/pymessenger/blob/c3aedb65b7a50e0ec82c0df39a566fceec734c85/pymessenger/bot.py#L177-L187 | def send_image(self, recipient_id, image_path, notification_type=NotificationType.regular):
"""Send an image to the specified recipient.
Image must be PNG or JPEG or GIF (more might be supported).
https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment
... | [
"def",
"send_image",
"(",
"self",
",",
"recipient_id",
",",
"image_path",
",",
"notification_type",
"=",
"NotificationType",
".",
"regular",
")",
":",
"return",
"self",
".",
"send_attachment",
"(",
"recipient_id",
",",
"\"image\"",
",",
"image_path",
",",
"notif... | Send an image to the specified recipient.
Image must be PNG or JPEG or GIF (more might be supported).
https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment
Input:
recipient_id: recipient id to send to
image_path: path to image to be s... | [
"Send",
"an",
"image",
"to",
"the",
"specified",
"recipient",
".",
"Image",
"must",
"be",
"PNG",
"or",
"JPEG",
"or",
"GIF",
"(",
"more",
"might",
"be",
"supported",
")",
".",
"https",
":",
"//",
"developers",
".",
"facebook",
".",
"com",
"/",
"docs",
... | python | train |
a1ezzz/wasp-general | wasp_general/signals/signals.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/signals/signals.py#L299-L304 | def stop_proxying(self, signal_source, *signal_names, weak_ref=False):
""" :meth:`.WSignalProxyProto.stop_proxying` implementation
"""
callback = self.__callback if weak_ref is False else self.__weak_ref_callback
for signal_name in signal_names:
signal_source.remove_callback(signal_name, callback) | [
"def",
"stop_proxying",
"(",
"self",
",",
"signal_source",
",",
"*",
"signal_names",
",",
"weak_ref",
"=",
"False",
")",
":",
"callback",
"=",
"self",
".",
"__callback",
"if",
"weak_ref",
"is",
"False",
"else",
"self",
".",
"__weak_ref_callback",
"for",
"sig... | :meth:`.WSignalProxyProto.stop_proxying` implementation | [
":",
"meth",
":",
".",
"WSignalProxyProto",
".",
"stop_proxying",
"implementation"
] | python | train |
has2k1/plotnine | plotnine/utils.py | https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/utils.py#L398-L424 | def defaults(d1, d2):
"""
Update a copy of d1 with the contents of d2 that are
not in d1. d1 and d2 are dictionary like objects.
Parameters
----------
d1 : dict | dataframe
dict with the preferred values
d2 : dict | dataframe
dict with the default values
Returns
---... | [
"def",
"defaults",
"(",
"d1",
",",
"d2",
")",
":",
"d1",
"=",
"d1",
".",
"copy",
"(",
")",
"tolist",
"=",
"isinstance",
"(",
"d2",
",",
"pd",
".",
"DataFrame",
")",
"keys",
"=",
"(",
"k",
"for",
"k",
"in",
"d2",
"if",
"k",
"not",
"in",
"d1",
... | Update a copy of d1 with the contents of d2 that are
not in d1. d1 and d2 are dictionary like objects.
Parameters
----------
d1 : dict | dataframe
dict with the preferred values
d2 : dict | dataframe
dict with the default values
Returns
-------
out : dict | dataframe
... | [
"Update",
"a",
"copy",
"of",
"d1",
"with",
"the",
"contents",
"of",
"d2",
"that",
"are",
"not",
"in",
"d1",
".",
"d1",
"and",
"d2",
"are",
"dictionary",
"like",
"objects",
"."
] | python | train |
brocade/pynos | pynos/versions/base/yang/tailf_netconf_transactions.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/tailf_netconf_transactions.py#L42-L55 | def start_transaction_input_target_target_candidate_candidate(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
start_transaction = ET.Element("start_transaction")
config = start_transaction
input = ET.SubElement(start_transaction, "input")
... | [
"def",
"start_transaction_input_target_target_candidate_candidate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"start_transaction",
"=",
"ET",
".",
"Element",
"(",
"\"start_transaction\"",
")",
"con... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
google/transitfeed | transitfeed/shapelib.py | https://github.com/google/transitfeed/blob/eb2991a3747ba541b2cb66502b305b6304a1f85f/transitfeed/shapelib.py#L413-L423 | def FindMatchingPolys(self, start_point, end_point, max_radius=150):
"""
Returns a list of polylines in the collection that have endpoints
within max_radius of the given start and end points.
"""
matches = []
for shape in self._name_to_shape.itervalues():
if start_point.GetDistanceMeters(s... | [
"def",
"FindMatchingPolys",
"(",
"self",
",",
"start_point",
",",
"end_point",
",",
"max_radius",
"=",
"150",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"shape",
"in",
"self",
".",
"_name_to_shape",
".",
"itervalues",
"(",
")",
":",
"if",
"start_point",
... | Returns a list of polylines in the collection that have endpoints
within max_radius of the given start and end points. | [
"Returns",
"a",
"list",
"of",
"polylines",
"in",
"the",
"collection",
"that",
"have",
"endpoints",
"within",
"max_radius",
"of",
"the",
"given",
"start",
"and",
"end",
"points",
"."
] | python | train |
mdickinson/bigfloat | bigfloat/core.py | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L1805-L1815 | def cosh(x, context=None):
"""
Return the hyperbolic cosine of x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_cosh,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"cosh",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_cosh",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
... | Return the hyperbolic cosine of x. | [
"Return",
"the",
"hyperbolic",
"cosine",
"of",
"x",
"."
] | python | train |
geophysics-ubonn/reda | lib/reda/utils/filter_config_types.py | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/filter_config_types.py#L100-L155 | def _filter_dipole_dipole(configs):
"""Filter dipole-dipole configurations
A dipole-dipole configuration is defined using the following criteria:
* equal distance between the two current electrodes and between the two
voltage electrodes
* no overlap of dipoles
Parameters
---... | [
"def",
"_filter_dipole_dipole",
"(",
"configs",
")",
":",
"# check that dipoles have equal size",
"dist_ab",
"=",
"np",
".",
"abs",
"(",
"configs",
"[",
":",
",",
"0",
"]",
"-",
"configs",
"[",
":",
",",
"1",
"]",
")",
"dist_mn",
"=",
"np",
".",
"abs",
... | Filter dipole-dipole configurations
A dipole-dipole configuration is defined using the following criteria:
* equal distance between the two current electrodes and between the two
voltage electrodes
* no overlap of dipoles
Parameters
----------
configs: numpy.ndarray
... | [
"Filter",
"dipole",
"-",
"dipole",
"configurations"
] | python | train |
OCR-D/core | ocrd/ocrd/workspace.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd/ocrd/workspace.py#L58-L71 | def download_url(self, url, **kwargs):
"""
Download a URL to the workspace.
Args:
url (string): URL to download to directory
**kwargs : See :py:mod:`ocrd.resolver.Resolver`
Returns:
The local filename of the downloaded file
"""
if sel... | [
"def",
"download_url",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"baseurl",
"and",
"'://'",
"not",
"in",
"url",
":",
"url",
"=",
"join",
"(",
"self",
".",
"baseurl",
",",
"url",
")",
"return",
"self",
".",
"re... | Download a URL to the workspace.
Args:
url (string): URL to download to directory
**kwargs : See :py:mod:`ocrd.resolver.Resolver`
Returns:
The local filename of the downloaded file | [
"Download",
"a",
"URL",
"to",
"the",
"workspace",
"."
] | python | train |
xmikos/soapy_power | soapypower/power.py | https://github.com/xmikos/soapy_power/blob/46e12659b8d08af764dc09a1f31b0e85a68f808f/soapypower/power.py#L274-L330 | def sweep(self, min_freq, max_freq, bins, repeats, runs=0, time_limit=0, overlap=0,
fft_window='hann', fft_overlap=0.5, crop=False, log_scale=True, remove_dc=False, detrend=None, lnb_lo=0,
tune_delay=0, reset_stream=False, base_buffer_size=0, max_buffer_size=0, max_threads=0, max_queue_size=... | [
"def",
"sweep",
"(",
"self",
",",
"min_freq",
",",
"max_freq",
",",
"bins",
",",
"repeats",
",",
"runs",
"=",
"0",
",",
"time_limit",
"=",
"0",
",",
"overlap",
"=",
"0",
",",
"fft_window",
"=",
"'hann'",
",",
"fft_overlap",
"=",
"0.5",
",",
"crop",
... | Sweep spectrum using frequency hopping | [
"Sweep",
"spectrum",
"using",
"frequency",
"hopping"
] | python | test |
ucbvislab/radiotool | radiotool/composer/composition.py | https://github.com/ucbvislab/radiotool/blob/01c9d878a811cf400b1482896d641d9c95e83ded/radiotool/composer/composition.py#L175-L203 | def extended_fade_in(self, segment, duration):
"""Add a fade-in to a segment that extends the beginning of the
segment.
:param segment: Segment to fade in
:type segment: :py:class:`radiotool.composer.Segment`
:param duration: Duration of fade-in (in seconds)
:returns: Th... | [
"def",
"extended_fade_in",
"(",
"self",
",",
"segment",
",",
"duration",
")",
":",
"dur",
"=",
"int",
"(",
"duration",
"*",
"segment",
".",
"track",
".",
"samplerate",
")",
"if",
"segment",
".",
"start",
"-",
"dur",
">=",
"0",
":",
"segment",
".",
"s... | Add a fade-in to a segment that extends the beginning of the
segment.
:param segment: Segment to fade in
:type segment: :py:class:`radiotool.composer.Segment`
:param duration: Duration of fade-in (in seconds)
:returns: The fade that has been added to the composition
:rty... | [
"Add",
"a",
"fade",
"-",
"in",
"to",
"a",
"segment",
"that",
"extends",
"the",
"beginning",
"of",
"the",
"segment",
"."
] | python | train |
SuperCowPowers/workbench | workbench_apps/workbench_cli/workbench_shell.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/workbench_shell.py#L276-L296 | def _connect(self, server_info):
"""Connect to the workbench server"""
# First we do a temp connect with a short heartbeat
_tmp_connect = zerorpc.Client(timeout=300, heartbeat=2)
_tmp_connect.connect('tcp://'+server_info['server']+':'+server_info['port'])
try:
_tmp_c... | [
"def",
"_connect",
"(",
"self",
",",
"server_info",
")",
":",
"# First we do a temp connect with a short heartbeat",
"_tmp_connect",
"=",
"zerorpc",
".",
"Client",
"(",
"timeout",
"=",
"300",
",",
"heartbeat",
"=",
"2",
")",
"_tmp_connect",
".",
"connect",
"(",
... | Connect to the workbench server | [
"Connect",
"to",
"the",
"workbench",
"server"
] | python | train |
SmartTeleMax/iktomi | iktomi/auth.py | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L104-L126 | def login(self, template='login'):
'''
This property will return component which will handle login requests.
auth.login(template='login.html')
'''
def _login(env, data):
form = self._login_form(env)
next = env.request.GET.get('next', '/')
... | [
"def",
"login",
"(",
"self",
",",
"template",
"=",
"'login'",
")",
":",
"def",
"_login",
"(",
"env",
",",
"data",
")",
":",
"form",
"=",
"self",
".",
"_login_form",
"(",
"env",
")",
"next",
"=",
"env",
".",
"request",
".",
"GET",
".",
"get",
"(",... | This property will return component which will handle login requests.
auth.login(template='login.html') | [
"This",
"property",
"will",
"return",
"component",
"which",
"will",
"handle",
"login",
"requests",
"."
] | python | train |
google/grr | grr/server/grr_response_server/flows/general/filesystem.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/flows/general/filesystem.py#L818-L833 | def FindNode(self, component_path):
"""Find the node in the component_tree from component_path.
Args:
component_path: A list of components which reference a node in the
component tree. This allows us to resume processing in the tree.
Returns:
A node in the component_tree.
"""
#... | [
"def",
"FindNode",
"(",
"self",
",",
"component_path",
")",
":",
"# Find the node that the component path is referring to.",
"node",
"=",
"self",
".",
"state",
".",
"component_tree",
"for",
"component",
"in",
"component_path",
":",
"node",
"=",
"node",
"[",
"compone... | Find the node in the component_tree from component_path.
Args:
component_path: A list of components which reference a node in the
component tree. This allows us to resume processing in the tree.
Returns:
A node in the component_tree. | [
"Find",
"the",
"node",
"in",
"the",
"component_tree",
"from",
"component_path",
"."
] | python | train |
heikomuller/sco-datastore | scodata/image.py | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L410-L430 | def get_directory(self, identifier):
"""Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is ... | [
"def",
"get_directory",
"(",
"self",
",",
"identifier",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"identifier",
"[",
":",
"2",
"]",
")",
",",
"identifier",
")"
] | Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is to avoid having too many
sub-folders in ... | [
"Implements",
"the",
"policy",
"for",
"naming",
"directories",
"for",
"image",
"objects",
".",
"Image",
"object",
"directories",
"are",
"name",
"by",
"their",
"identifier",
".",
"In",
"addition",
"these",
"directories",
"are",
"grouped",
"in",
"parent",
"directo... | python | train |
quantumlib/Cirq | dev_tools/auto_merge.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/auto_merge.py#L203-L220 | def edit_comment(repo: GithubRepository, text: str, comment_id: int) -> None:
"""
References:
https://developer.github.com/v3/issues/comments/#edit-a-comment
"""
url = ("https://api.github.com/repos/{}/{}/issues/comments/{}"
"?access_token={}".format(repo.organization,
... | [
"def",
"edit_comment",
"(",
"repo",
":",
"GithubRepository",
",",
"text",
":",
"str",
",",
"comment_id",
":",
"int",
")",
"->",
"None",
":",
"url",
"=",
"(",
"\"https://api.github.com/repos/{}/{}/issues/comments/{}\"",
"\"?access_token={}\"",
".",
"format",
"(",
"... | References:
https://developer.github.com/v3/issues/comments/#edit-a-comment | [
"References",
":",
"https",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"issues",
"/",
"comments",
"/",
"#edit",
"-",
"a",
"-",
"comment"
] | python | train |
Nic30/hwt | hwt/hdl/statements.py | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/statements.py#L564-L578 | def isSameStatementList(stmListA: List[HdlStatement],
stmListB: List[HdlStatement]) -> bool:
"""
:return: True if two lists of HdlStatement instances are same
"""
if stmListA is stmListB:
return True
if stmListA is None or stmListB is None:
return False
f... | [
"def",
"isSameStatementList",
"(",
"stmListA",
":",
"List",
"[",
"HdlStatement",
"]",
",",
"stmListB",
":",
"List",
"[",
"HdlStatement",
"]",
")",
"->",
"bool",
":",
"if",
"stmListA",
"is",
"stmListB",
":",
"return",
"True",
"if",
"stmListA",
"is",
"None",... | :return: True if two lists of HdlStatement instances are same | [
":",
"return",
":",
"True",
"if",
"two",
"lists",
"of",
"HdlStatement",
"instances",
"are",
"same"
] | python | test |
rdussurget/py-altimetry | altimetry/tools/nctools.py | https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/tools/nctools.py#L73-L83 | def add(self,dimlist,dimvalues):
'''
add dimensions
:parameter dimlist: list of dimensions
:parameter dimvalues: list of values for dimlist
'''
for i,d in enumerate(dimlist):
self[d] = dimvalues[i]
self.set_ndims() | [
"def",
"add",
"(",
"self",
",",
"dimlist",
",",
"dimvalues",
")",
":",
"for",
"i",
",",
"d",
"in",
"enumerate",
"(",
"dimlist",
")",
":",
"self",
"[",
"d",
"]",
"=",
"dimvalues",
"[",
"i",
"]",
"self",
".",
"set_ndims",
"(",
")"
] | add dimensions
:parameter dimlist: list of dimensions
:parameter dimvalues: list of values for dimlist | [
"add",
"dimensions",
":",
"parameter",
"dimlist",
":",
"list",
"of",
"dimensions",
":",
"parameter",
"dimvalues",
":",
"list",
"of",
"values",
"for",
"dimlist"
] | python | train |
flypenguin/python-cattleprod | cattleprod/__init__.py | https://github.com/flypenguin/python-cattleprod/blob/05043c91de78d211968db65413d3db4fd44c89e4/cattleprod/__init__.py#L55-L76 | def poke(url, accesskey=None, secretkey=None, __method__='GET', **req_args):
"""
Poke the Rancher API. Returns a Rod object instance. Central starting
point for the cattleprod package.
:param url: The full Rancher URL to the API endpoint.
:param accesskey: The rancher access key, optional.
:para... | [
"def",
"poke",
"(",
"url",
",",
"accesskey",
"=",
"None",
",",
"secretkey",
"=",
"None",
",",
"__method__",
"=",
"'GET'",
",",
"*",
"*",
"req_args",
")",
":",
"if",
"accesskey",
"and",
"secretkey",
":",
"req_args",
"[",
"'auth'",
"]",
"=",
"(",
"acce... | Poke the Rancher API. Returns a Rod object instance. Central starting
point for the cattleprod package.
:param url: The full Rancher URL to the API endpoint.
:param accesskey: The rancher access key, optional.
:param secretkey: The rancher secret key, optional.
:param __method__: Internal method, do... | [
"Poke",
"the",
"Rancher",
"API",
".",
"Returns",
"a",
"Rod",
"object",
"instance",
".",
"Central",
"starting",
"point",
"for",
"the",
"cattleprod",
"package",
".",
":",
"param",
"url",
":",
"The",
"full",
"Rancher",
"URL",
"to",
"the",
"API",
"endpoint",
... | python | train |
balloob/pychromecast | pychromecast/__init__.py | https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/__init__.py#L315-L331 | def wait(self, timeout=None):
"""
Waits until the cast device is ready for communication. The device
is ready as soon a status message has been received.
If the worker thread is not already running, it will be started.
If the status has already been received then the method ret... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"socket_client",
".",
"isAlive",
"(",
")",
":",
"self",
".",
"socket_client",
".",
"start",
"(",
")",
"self",
".",
"status_event",
".",
"wait",
"(",
"timeout... | Waits until the cast device is ready for communication. The device
is ready as soon a status message has been received.
If the worker thread is not already running, it will be started.
If the status has already been received then the method returns
immediately.
:param timeout:... | [
"Waits",
"until",
"the",
"cast",
"device",
"is",
"ready",
"for",
"communication",
".",
"The",
"device",
"is",
"ready",
"as",
"soon",
"a",
"status",
"message",
"has",
"been",
"received",
"."
] | python | train |
attm2x/m2x-python | m2x/v2/devices.py | https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L156-L167 | def post_update(self, **values):
""" Method for `Post Device Update (Single Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Update--Single-Values-to-Multiple-Streams->` endpoint.
:param values: The values being posted, formatted according to the API docs
... | [
"def",
"post_update",
"(",
"self",
",",
"*",
"*",
"values",
")",
":",
"return",
"self",
".",
"api",
".",
"post",
"(",
"self",
".",
"subpath",
"(",
"'/update'",
")",
",",
"data",
"=",
"values",
")"
] | Method for `Post Device Update (Single Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Update--Single-Values-to-Multiple-Streams->` endpoint.
:param values: The values being posted, formatted according to the API docs
:type values: dict
:return: T... | [
"Method",
"for",
"Post",
"Device",
"Update",
"(",
"Single",
"Values",
"to",
"Multiple",
"Streams",
")",
"<https",
":",
"//",
"m2x",
".",
"att",
".",
"com",
"/",
"developer",
"/",
"documentation",
"/",
"v2",
"/",
"device#Post",
"-",
"Device",
"-",
"Update... | python | test |
ARMmbed/icetea | icetea_lib/Plugin/PluginManager.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/Plugin/PluginManager.py#L161-L173 | def load_default_run_plugins(self):
"""
Load default run level plugins from icetea_lib.Plugin.plugins.default_plugins.
:return: Nothing
"""
for plugin_name, plugin_class in default_plugins.items():
if issubclass(plugin_class, RunPluginBase):
try:
... | [
"def",
"load_default_run_plugins",
"(",
"self",
")",
":",
"for",
"plugin_name",
",",
"plugin_class",
"in",
"default_plugins",
".",
"items",
"(",
")",
":",
"if",
"issubclass",
"(",
"plugin_class",
",",
"RunPluginBase",
")",
":",
"try",
":",
"self",
".",
"regi... | Load default run level plugins from icetea_lib.Plugin.plugins.default_plugins.
:return: Nothing | [
"Load",
"default",
"run",
"level",
"plugins",
"from",
"icetea_lib",
".",
"Plugin",
".",
"plugins",
".",
"default_plugins",
"."
] | python | train |
foremast/foremast | src/foremast/pipeline/clean_pipelines.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/pipeline/clean_pipelines.py#L28-L47 | def delete_pipeline(app='', pipeline_name=''):
"""Delete _pipeline_name_ from _app_."""
safe_pipeline_name = normalize_pipeline_name(name=pipeline_name)
LOG.warning('Deleting Pipeline: %s', safe_pipeline_name)
url = '{host}/pipelines/{app}/{pipeline}'.format(host=API_URL, app=app, pipeline=safe_pipeli... | [
"def",
"delete_pipeline",
"(",
"app",
"=",
"''",
",",
"pipeline_name",
"=",
"''",
")",
":",
"safe_pipeline_name",
"=",
"normalize_pipeline_name",
"(",
"name",
"=",
"pipeline_name",
")",
"LOG",
".",
"warning",
"(",
"'Deleting Pipeline: %s'",
",",
"safe_pipeline_nam... | Delete _pipeline_name_ from _app_. | [
"Delete",
"_pipeline_name_",
"from",
"_app_",
"."
] | python | train |
TheHive-Project/Cortex-Analyzers | analyzers/GreyNoise/greynoise.py | https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/GreyNoise/greynoise.py#L16-L44 | def _get_level(current_level, new_intention):
"""
Map GreyNoise intentions to Cortex maliciousness levels.
Accept a Cortex level and a GreyNoise intention, the return the more malicious of the two.
:param current_level: A Cortex maliciousness level
https://github.com/TheHive... | [
"def",
"_get_level",
"(",
"current_level",
",",
"new_intention",
")",
":",
"intention_level_map",
"=",
"OrderedDict",
"(",
"[",
"(",
"'info'",
",",
"'info'",
")",
",",
"(",
"'benign'",
",",
"'safe'",
")",
",",
"(",
"'suspicious'",
",",
"'suspicious'",
")",
... | Map GreyNoise intentions to Cortex maliciousness levels.
Accept a Cortex level and a GreyNoise intention, the return the more malicious of the two.
:param current_level: A Cortex maliciousness level
https://github.com/TheHive-Project/CortexDocs/blob/master/api/how-to-create-an-analyzer.md#o... | [
"Map",
"GreyNoise",
"intentions",
"to",
"Cortex",
"maliciousness",
"levels",
".",
"Accept",
"a",
"Cortex",
"level",
"and",
"a",
"GreyNoise",
"intention",
"the",
"return",
"the",
"more",
"malicious",
"of",
"the",
"two",
"."
] | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/handlers.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/handlers.py#L1582-L1602 | def _check_mr_state(cls, state, mr_id):
"""Check MapreduceState.
Args:
state: an MapreduceState instance.
mr_id: mapreduce id.
Returns:
True if state is valid. False if not and this task should be dropped.
"""
if state is None:
logging.warning(
"Mapreduce State fo... | [
"def",
"_check_mr_state",
"(",
"cls",
",",
"state",
",",
"mr_id",
")",
":",
"if",
"state",
"is",
"None",
":",
"logging",
".",
"warning",
"(",
"\"Mapreduce State for job %s is missing. Dropping Task.\"",
",",
"mr_id",
")",
"return",
"False",
"if",
"not",
"state",... | Check MapreduceState.
Args:
state: an MapreduceState instance.
mr_id: mapreduce id.
Returns:
True if state is valid. False if not and this task should be dropped. | [
"Check",
"MapreduceState",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/qc/qsignature.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qsignature.py#L186-L194 | def _slice_vcf_chr21(vcf_file, out_dir):
"""
Slice chr21 of qsignature SNPs to reduce computation time
"""
tmp_file = os.path.join(out_dir, "chr21_qsignature.vcf")
if not utils.file_exists(tmp_file):
cmd = ("grep chr21 {vcf_file} > {tmp_file}").format(**locals())
out = subprocess.che... | [
"def",
"_slice_vcf_chr21",
"(",
"vcf_file",
",",
"out_dir",
")",
":",
"tmp_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"chr21_qsignature.vcf\"",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"tmp_file",
")",
":",
"cmd",
"=",
... | Slice chr21 of qsignature SNPs to reduce computation time | [
"Slice",
"chr21",
"of",
"qsignature",
"SNPs",
"to",
"reduce",
"computation",
"time"
] | python | train |
buriburisuri/sugartensor | sugartensor/sg_layer.py | https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_layer.py#L33-L58 | def sg_dense(tensor, opt):
r"""Applies a full connection.
Args:
tensor: A 2-D tensor (automatically passed by decorator).
opt:
in_dim: An `integer`. The size of input dimension.
dim: An `integer`. The size of output dimension.
bias: Boolean. If True, biases are added.
... | [
"def",
"sg_dense",
"(",
"tensor",
",",
"opt",
")",
":",
"# parameter initialize",
"w",
"=",
"tf",
".",
"sg_initializer",
".",
"he_uniform",
"(",
"'W'",
",",
"(",
"opt",
".",
"in_dim",
",",
"opt",
".",
"dim",
")",
",",
"regularizer",
"=",
"opt",
".",
... | r"""Applies a full connection.
Args:
tensor: A 2-D tensor (automatically passed by decorator).
opt:
in_dim: An `integer`. The size of input dimension.
dim: An `integer`. The size of output dimension.
bias: Boolean. If True, biases are added.
regularizer: A (Tensor -... | [
"r",
"Applies",
"a",
"full",
"connection",
".",
"Args",
":",
"tensor",
":",
"A",
"2",
"-",
"D",
"tensor",
"(",
"automatically",
"passed",
"by",
"decorator",
")",
".",
"opt",
":",
"in_dim",
":",
"An",
"integer",
".",
"The",
"size",
"of",
"input",
"dim... | python | train |
senaite/senaite.core | bika/lims/content/contact.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/contact.py#L309-L316 | def _addLocalOwnerRole(self, username):
"""Add local owner role from parent object
"""
parent = self.getParent()
if parent.portal_type == "Client":
parent.manage_setLocalRoles(username, ["Owner", ])
# reindex object security
self._recursive_reindex_obj... | [
"def",
"_addLocalOwnerRole",
"(",
"self",
",",
"username",
")",
":",
"parent",
"=",
"self",
".",
"getParent",
"(",
")",
"if",
"parent",
".",
"portal_type",
"==",
"\"Client\"",
":",
"parent",
".",
"manage_setLocalRoles",
"(",
"username",
",",
"[",
"\"Owner\""... | Add local owner role from parent object | [
"Add",
"local",
"owner",
"role",
"from",
"parent",
"object"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.