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 |
|---|---|---|---|---|---|---|---|---|
pycontribs/jira | jira/client.py | https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L2548-L2567 | def search_assignable_users_for_projects(self, username, projectKeys, startAt=0, maxResults=50):
"""Get a list of user Resources that match the search string and can be assigned issues for projects.
:param username: A string to match usernames against
:type username: str
:param projectK... | [
"def",
"search_assignable_users_for_projects",
"(",
"self",
",",
"username",
",",
"projectKeys",
",",
"startAt",
"=",
"0",
",",
"maxResults",
"=",
"50",
")",
":",
"params",
"=",
"{",
"'username'",
":",
"username",
",",
"'projectKeys'",
":",
"projectKeys",
"}",... | Get a list of user Resources that match the search string and can be assigned issues for projects.
:param username: A string to match usernames against
:type username: str
:param projectKeys: Comma-separated list of project keys to check for issue assignment permissions
:type projectKey... | [
"Get",
"a",
"list",
"of",
"user",
"Resources",
"that",
"match",
"the",
"search",
"string",
"and",
"can",
"be",
"assigned",
"issues",
"for",
"projects",
"."
] | python | train |
singularityhub/sregistry-cli | sregistry/main/google_build/delete.py | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_build/delete.py#L23-L39 | def delete_object(service, bucket_name, object_name):
'''delete object will delete a file from a bucket
Parameters
==========
storage_service: the service obtained with get_storage_service
bucket_name: the name of the bucket
object_name: the "name" parameter of the object.
'... | [
"def",
"delete_object",
"(",
"service",
",",
"bucket_name",
",",
"object_name",
")",
":",
"try",
":",
"operation",
"=",
"service",
".",
"objects",
"(",
")",
".",
"delete",
"(",
"bucket",
"=",
"bucket_name",
",",
"object",
"=",
"object_name",
")",
".",
"e... | delete object will delete a file from a bucket
Parameters
==========
storage_service: the service obtained with get_storage_service
bucket_name: the name of the bucket
object_name: the "name" parameter of the object. | [
"delete",
"object",
"will",
"delete",
"a",
"file",
"from",
"a",
"bucket"
] | python | test |
adafruit/Adafruit_Python_SSD1306 | Adafruit_SSD1306/SSD1306.py | https://github.com/adafruit/Adafruit_Python_SSD1306/blob/8819e2d203df49f2843059d981b7347d9881c82b/Adafruit_SSD1306/SSD1306.py#L184-L209 | def image(self, image):
"""Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size.
"""
if image.mode != '1':
raise ValueError('Image must be in mode 1.')
imwidth, imheight = image.size
if im... | [
"def",
"image",
"(",
"self",
",",
"image",
")",
":",
"if",
"image",
".",
"mode",
"!=",
"'1'",
":",
"raise",
"ValueError",
"(",
"'Image must be in mode 1.'",
")",
"imwidth",
",",
"imheight",
"=",
"image",
".",
"size",
"if",
"imwidth",
"!=",
"self",
".",
... | Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size. | [
"Set",
"buffer",
"to",
"value",
"of",
"Python",
"Imaging",
"Library",
"image",
".",
"The",
"image",
"should",
"be",
"in",
"1",
"bit",
"mode",
"and",
"a",
"size",
"equal",
"to",
"the",
"display",
"size",
"."
] | python | train |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L340-L367 | def send_jsonified(self, msg, stats=True):
""" Send JSON-encoded message
@param msg: JSON encoded string to send
@param stats: If set to True, will update statistics after operation
completes
"""
assert isinstance(msg, basestring), 'Can only send strings'
... | [
"def",
"send_jsonified",
"(",
"self",
",",
"msg",
",",
"stats",
"=",
"True",
")",
":",
"assert",
"isinstance",
"(",
"msg",
",",
"basestring",
")",
",",
"'Can only send strings'",
"if",
"isinstance",
"(",
"msg",
",",
"unicode",
")",
":",
"msg",
"=",
"msg"... | Send JSON-encoded message
@param msg: JSON encoded string to send
@param stats: If set to True, will update statistics after operation
completes | [
"Send",
"JSON",
"-",
"encoded",
"message"
] | python | train |
PyGithub/PyGithub | github/PullRequest.py | https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/PullRequest.py#L581-L591 | def get_commits(self):
"""
:calls: `GET /repos/:owner/:repo/pulls/:number/commits <http://developer.github.com/v3/pulls>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit`
"""
return github.PaginatedList.PaginatedList(
github.Commit... | [
"def",
"get_commits",
"(",
"self",
")",
":",
"return",
"github",
".",
"PaginatedList",
".",
"PaginatedList",
"(",
"github",
".",
"Commit",
".",
"Commit",
",",
"self",
".",
"_requester",
",",
"self",
".",
"url",
"+",
"\"/commits\"",
",",
"None",
")"
] | :calls: `GET /repos/:owner/:repo/pulls/:number/commits <http://developer.github.com/v3/pulls>`_
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` | [
":",
"calls",
":",
"GET",
"/",
"repos",
"/",
":",
"owner",
"/",
":",
"repo",
"/",
"pulls",
"/",
":",
"number",
"/",
"commits",
"<http",
":",
"//",
"developer",
".",
"github",
".",
"com",
"/",
"v3",
"/",
"pulls",
">",
"_",
":",
"rtype",
":",
":"... | python | train |
gboeing/osmnx | osmnx/core.py | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L876-L894 | def remove_isolated_nodes(G):
"""
Remove from a graph all the nodes that have no incident edges (ie, node
degree = 0).
Parameters
----------
G : networkx multidigraph
the graph from which to remove nodes
Returns
-------
networkx multidigraph
"""
isolated_nodes = [n... | [
"def",
"remove_isolated_nodes",
"(",
"G",
")",
":",
"isolated_nodes",
"=",
"[",
"node",
"for",
"node",
",",
"degree",
"in",
"dict",
"(",
"G",
".",
"degree",
"(",
")",
")",
".",
"items",
"(",
")",
"if",
"degree",
"<",
"1",
"]",
"G",
".",
"remove_nod... | Remove from a graph all the nodes that have no incident edges (ie, node
degree = 0).
Parameters
----------
G : networkx multidigraph
the graph from which to remove nodes
Returns
-------
networkx multidigraph | [
"Remove",
"from",
"a",
"graph",
"all",
"the",
"nodes",
"that",
"have",
"no",
"incident",
"edges",
"(",
"ie",
"node",
"degree",
"=",
"0",
")",
"."
] | python | train |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L399-L411 | def transition(self, index, event_time):
"""Finds the population in each state and moves them to the next state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
The time at whic... | [
"def",
"transition",
"(",
"self",
",",
"index",
",",
"event_time",
")",
":",
"for",
"state",
",",
"affected",
"in",
"self",
".",
"_get_state_pops",
"(",
"index",
")",
":",
"if",
"not",
"affected",
".",
"empty",
":",
"state",
".",
"next_state",
"(",
"af... | Finds the population in each state and moves them to the next state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
The time at which this transition occurs. | [
"Finds",
"the",
"population",
"in",
"each",
"state",
"and",
"moves",
"them",
"to",
"the",
"next",
"state",
"."
] | python | train |
PSPC-SPAC-buyandsell/von_anchor | von_anchor/anchor/base.py | https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/base.py#L803-L820 | async def sign(self, message: bytes) -> bytes:
"""
Sign message; return signature. Raise WalletState if wallet is closed.
:param message: Content to sign, as bytes
:return: signature, as bytes
"""
LOGGER.debug('BaseAnchor.sign >>> message: %s', message)
if not ... | [
"async",
"def",
"sign",
"(",
"self",
",",
"message",
":",
"bytes",
")",
"->",
"bytes",
":",
"LOGGER",
".",
"debug",
"(",
"'BaseAnchor.sign >>> message: %s'",
",",
"message",
")",
"if",
"not",
"self",
".",
"wallet",
".",
"handle",
":",
"LOGGER",
".",
"deb... | Sign message; return signature. Raise WalletState if wallet is closed.
:param message: Content to sign, as bytes
:return: signature, as bytes | [
"Sign",
"message",
";",
"return",
"signature",
".",
"Raise",
"WalletState",
"if",
"wallet",
"is",
"closed",
"."
] | python | train |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/biosignalsnotebooks/synchronisation.py | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/synchronisation.py#L315-L348 | def _shape_array(array1, array2):
"""
Function that equalises the input arrays by zero-padding the shortest one.
----------
Parameters
----------
array1: list or numpy.array
Array
array2: list or numpy.array
Array
Return
------
arrays: numpy.array
Array ... | [
"def",
"_shape_array",
"(",
"array1",
",",
"array2",
")",
":",
"if",
"len",
"(",
"array1",
")",
">",
"len",
"(",
"array2",
")",
":",
"new_array",
"=",
"array2",
"old_array",
"=",
"array1",
"else",
":",
"new_array",
"=",
"array1",
"old_array",
"=",
"arr... | Function that equalises the input arrays by zero-padding the shortest one.
----------
Parameters
----------
array1: list or numpy.array
Array
array2: list or numpy.array
Array
Return
------
arrays: numpy.array
Array containing the equal-length arrays. | [
"Function",
"that",
"equalises",
"the",
"input",
"arrays",
"by",
"zero",
"-",
"padding",
"the",
"shortest",
"one",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v7_2_0/interface/port_channel/switchport/port_security/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v7_2_0/interface/port_channel/switchport/port_security/__init__.py#L140-L163 | def _set_port_sec_violation(self, v, load=False):
"""
Setter method for port_sec_violation, mapped from YANG variable /interface/port_channel/switchport/port_security/port_sec_violation (port-sec-violation)
If this variable is read-only (config: false) in the
source YANG file, then _set_port_sec_violati... | [
"def",
"_set_port_sec_violation",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
","... | Setter method for port_sec_violation, mapped from YANG variable /interface/port_channel/switchport/port_security/port_sec_violation (port-sec-violation)
If this variable is read-only (config: false) in the
source YANG file, then _set_port_sec_violation is considered as a private
method. Backends looking to ... | [
"Setter",
"method",
"for",
"port_sec_violation",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface",
"/",
"port_channel",
"/",
"switchport",
"/",
"port_security",
"/",
"port_sec_violation",
"(",
"port",
"-",
"sec",
"-",
"violation",
")",
"If",
"this",
"varia... | python | train |
draperjames/qtpandas | qtpandas/views/CSVDialogs.py | https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/views/CSVDialogs.py#L420-L430 | def _previewFile(self):
"""Updates the preview widgets with new models for both tab panes.
"""
dataFrame = self._loadCSVDataFrame()
dataFrameModel = DataFrameModel(dataFrame, filePath=self._filename)
dataFrameModel.enableEditing(True)
self._previewTableView.setModel(data... | [
"def",
"_previewFile",
"(",
"self",
")",
":",
"dataFrame",
"=",
"self",
".",
"_loadCSVDataFrame",
"(",
")",
"dataFrameModel",
"=",
"DataFrameModel",
"(",
"dataFrame",
",",
"filePath",
"=",
"self",
".",
"_filename",
")",
"dataFrameModel",
".",
"enableEditing",
... | Updates the preview widgets with new models for both tab panes. | [
"Updates",
"the",
"preview",
"widgets",
"with",
"new",
"models",
"for",
"both",
"tab",
"panes",
"."
] | python | train |
BetterWorks/django-anonymizer | anonymizer/replacers.py | https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L60-L64 | def date(anon, obj, field, val):
"""
Returns a random date
"""
return anon.faker.date(field=field) | [
"def",
"date",
"(",
"anon",
",",
"obj",
",",
"field",
",",
"val",
")",
":",
"return",
"anon",
".",
"faker",
".",
"date",
"(",
"field",
"=",
"field",
")"
] | Returns a random date | [
"Returns",
"a",
"random",
"date"
] | python | train |
ConsenSys/mythril-classic | mythril/ethereum/interface/leveldb/client.py | https://github.com/ConsenSys/mythril-classic/blob/27af71c34b2ce94f4fae5613ec457f93df1a8f56/mythril/ethereum/interface/leveldb/client.py#L218-L249 | def search(self, expression, callback_func):
"""Search through all contract accounts.
:param expression:
:param callback_func:
"""
cnt = 0
indexer = AccountIndexer(self)
for contract, address_hash, balance in self.get_contracts():
if contract.matche... | [
"def",
"search",
"(",
"self",
",",
"expression",
",",
"callback_func",
")",
":",
"cnt",
"=",
"0",
"indexer",
"=",
"AccountIndexer",
"(",
"self",
")",
"for",
"contract",
",",
"address_hash",
",",
"balance",
"in",
"self",
".",
"get_contracts",
"(",
")",
":... | Search through all contract accounts.
:param expression:
:param callback_func: | [
"Search",
"through",
"all",
"contract",
"accounts",
"."
] | python | train |
bspaans/python-mingus | mingus/midi/sequencer.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/sequencer.py#L296-L306 | def play_Track(self, track, channel=1, bpm=120):
"""Play a Track object."""
self.notify_listeners(self.MSG_PLAY_TRACK, {'track': track, 'channel'
: channel, 'bpm': bpm})
for bar in track:
res = self.play_Bar(bar, channel, bpm)
if res != {}:
... | [
"def",
"play_Track",
"(",
"self",
",",
"track",
",",
"channel",
"=",
"1",
",",
"bpm",
"=",
"120",
")",
":",
"self",
".",
"notify_listeners",
"(",
"self",
".",
"MSG_PLAY_TRACK",
",",
"{",
"'track'",
":",
"track",
",",
"'channel'",
":",
"channel",
",",
... | Play a Track object. | [
"Play",
"a",
"Track",
"object",
"."
] | python | train |
softlayer/softlayer-python | SoftLayer/managers/vs_placement.py | https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/vs_placement.py#L110-L119 | def _get_id_from_name(self, name):
"""List placement group ids which match the given name."""
_filter = {
'placementGroups': {
'name': {'operation': name}
}
}
mask = "mask[id, name]"
results = self.client.call('Account', 'getPlacementGroups... | [
"def",
"_get_id_from_name",
"(",
"self",
",",
"name",
")",
":",
"_filter",
"=",
"{",
"'placementGroups'",
":",
"{",
"'name'",
":",
"{",
"'operation'",
":",
"name",
"}",
"}",
"}",
"mask",
"=",
"\"mask[id, name]\"",
"results",
"=",
"self",
".",
"client",
"... | List placement group ids which match the given name. | [
"List",
"placement",
"group",
"ids",
"which",
"match",
"the",
"given",
"name",
"."
] | python | train |
tmontaigu/pylas | pylas/vlrs/vlrlist.py | https://github.com/tmontaigu/pylas/blob/8335a1a7d7677f0e4bc391bb6fa3c75b42ed5b06/pylas/vlrs/vlrlist.py#L140-L170 | def get(self, vlr_type):
""" Returns the list of vlrs of the requested type
Always returns a list even if there is only one VLR of type vlr_type.
>>> import pylas
>>> las = pylas.read("pylastests/extrabytes.las")
>>> las.vlrs
[<ExtraBytesVlr(extra bytes structs: 5)>]
... | [
"def",
"get",
"(",
"self",
",",
"vlr_type",
")",
":",
"return",
"[",
"v",
"for",
"v",
"in",
"self",
".",
"vlrs",
"if",
"v",
".",
"__class__",
".",
"__name__",
"==",
"vlr_type",
"]"
] | Returns the list of vlrs of the requested type
Always returns a list even if there is only one VLR of type vlr_type.
>>> import pylas
>>> las = pylas.read("pylastests/extrabytes.las")
>>> las.vlrs
[<ExtraBytesVlr(extra bytes structs: 5)>]
>>> las.vlrs.get("WktCoordinateS... | [
"Returns",
"the",
"list",
"of",
"vlrs",
"of",
"the",
"requested",
"type",
"Always",
"returns",
"a",
"list",
"even",
"if",
"there",
"is",
"only",
"one",
"VLR",
"of",
"type",
"vlr_type",
"."
] | python | test |
mathandy/svgpathtools | svgpathtools/svg_to_paths.py | https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/svg_to_paths.py#L78-L91 | def rect2pathd(rect):
"""Converts an SVG-rect element to a Path d-string.
The rectangle will start at the (x,y) coordinate specified by the
rectangle object and proceed counter-clockwise."""
x0, y0 = float(rect.get('x', 0)), float(rect.get('y', 0))
w, h = float(rect.get('width', 0)), float(rec... | [
"def",
"rect2pathd",
"(",
"rect",
")",
":",
"x0",
",",
"y0",
"=",
"float",
"(",
"rect",
".",
"get",
"(",
"'x'",
",",
"0",
")",
")",
",",
"float",
"(",
"rect",
".",
"get",
"(",
"'y'",
",",
"0",
")",
")",
"w",
",",
"h",
"=",
"float",
"(",
"... | Converts an SVG-rect element to a Path d-string.
The rectangle will start at the (x,y) coordinate specified by the
rectangle object and proceed counter-clockwise. | [
"Converts",
"an",
"SVG",
"-",
"rect",
"element",
"to",
"a",
"Path",
"d",
"-",
"string",
".",
"The",
"rectangle",
"will",
"start",
"at",
"the",
"(",
"x",
"y",
")",
"coordinate",
"specified",
"by",
"the",
"rectangle",
"object",
"and",
"proceed",
"counter",... | python | train |
empymod/empymod | empymod/transform.py | https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/transform.py#L527-L627 | def fqwe(fEM, time, freq, qweargs):
r"""Fourier Transform using Quadrature-With-Extrapolation.
It follows the QWE methodology [Key12]_ for the Hankel transform, see
``hqwe`` for more information.
The function is called from one of the modelling routines in :mod:`model`.
Consult these modelling rou... | [
"def",
"fqwe",
"(",
"fEM",
",",
"time",
",",
"freq",
",",
"qweargs",
")",
":",
"# Get rtol, atol, nquad, maxint, diff_quad, a, b, and limit",
"rtol",
",",
"atol",
",",
"nquad",
",",
"maxint",
",",
"_",
",",
"diff_quad",
",",
"a",
",",
"b",
",",
"limit",
",... | r"""Fourier Transform using Quadrature-With-Extrapolation.
It follows the QWE methodology [Key12]_ for the Hankel transform, see
``hqwe`` for more information.
The function is called from one of the modelling routines in :mod:`model`.
Consult these modelling routines for a description of the input and... | [
"r",
"Fourier",
"Transform",
"using",
"Quadrature",
"-",
"With",
"-",
"Extrapolation",
"."
] | python | train |
axialmarket/fsq | fsq/configure.py | https://github.com/axialmarket/fsq/blob/43b84c292cb8a187599d86753b947cf73248f989/fsq/configure.py#L135-L144 | def untrigger(queue, trigger=_c.FSQ_TRIGGER):
'''Uninstalls the trigger for the specified queue -- if a queue has no
trigger, this function is a no-op.'''
trigger_path = fsq_path.trigger(queue, trigger=trigger)
_queue_ok(os.path.dirname(trigger_path))
try:
os.unlink(trigger_path)
exce... | [
"def",
"untrigger",
"(",
"queue",
",",
"trigger",
"=",
"_c",
".",
"FSQ_TRIGGER",
")",
":",
"trigger_path",
"=",
"fsq_path",
".",
"trigger",
"(",
"queue",
",",
"trigger",
"=",
"trigger",
")",
"_queue_ok",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"tr... | Uninstalls the trigger for the specified queue -- if a queue has no
trigger, this function is a no-op. | [
"Uninstalls",
"the",
"trigger",
"for",
"the",
"specified",
"queue",
"--",
"if",
"a",
"queue",
"has",
"no",
"trigger",
"this",
"function",
"is",
"a",
"no",
"-",
"op",
"."
] | python | train |
changhiskhan/poseidon | poseidon/droplet.py | https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/droplet.py#L326-L337 | def resize(self, size, wait=True):
"""
Change the size of this droplet (must be powered off)
Parameters
----------
size: str
size slug, e.g., 512mb
wait: bool, default True
Whether to block until the pending action is completed
"""
... | [
"def",
"resize",
"(",
"self",
",",
"size",
",",
"wait",
"=",
"True",
")",
":",
"return",
"self",
".",
"_action",
"(",
"'resize'",
",",
"size",
"=",
"size",
",",
"wait",
"=",
"wait",
")"
] | Change the size of this droplet (must be powered off)
Parameters
----------
size: str
size slug, e.g., 512mb
wait: bool, default True
Whether to block until the pending action is completed | [
"Change",
"the",
"size",
"of",
"this",
"droplet",
"(",
"must",
"be",
"powered",
"off",
")"
] | python | valid |
tensorforce/tensorforce | tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py | https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L64-L78 | def put(self, item, priority=None):
"""
Stores a transition in replay memory.
If the memory is full, the oldest entry is replaced.
"""
if not self._isfull():
self._memory.append(None)
position = self._next_position_then_increment()
old_priority = 0 if... | [
"def",
"put",
"(",
"self",
",",
"item",
",",
"priority",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_isfull",
"(",
")",
":",
"self",
".",
"_memory",
".",
"append",
"(",
"None",
")",
"position",
"=",
"self",
".",
"_next_position_then_increment",
... | Stores a transition in replay memory.
If the memory is full, the oldest entry is replaced. | [
"Stores",
"a",
"transition",
"in",
"replay",
"memory",
"."
] | python | valid |
siemens/django-dingos | dingos/core/utilities.py | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/core/utilities.py#L106-L129 | def get_dict(dictionary, *keys,**kwargs):
"""
This function allows traversals over several keys to
be performed by passing a list of keys::
get_dict(d,key1,key2,key3) = d[key1][key2][key3]
"""
if 'default' in kwargs:
default = kwargs['default']
else:
default = None
ex... | [
"def",
"get_dict",
"(",
"dictionary",
",",
"*",
"keys",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'default'",
"in",
"kwargs",
":",
"default",
"=",
"kwargs",
"[",
"'default'",
"]",
"else",
":",
"default",
"=",
"None",
"existing",
"=",
"dictionary",
"for... | This function allows traversals over several keys to
be performed by passing a list of keys::
get_dict(d,key1,key2,key3) = d[key1][key2][key3] | [
"This",
"function",
"allows",
"traversals",
"over",
"several",
"keys",
"to",
"be",
"performed",
"by",
"passing",
"a",
"list",
"of",
"keys",
"::"
] | python | train |
guaix-ucm/numina | numina/array/wavecalib/arccalibration.py | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/wavecalib/arccalibration.py#L324-L425 | def gen_triplets_master(wv_master, geometry=None, debugplot=0):
"""Compute information associated to triplets in master table.
Determine all the possible triplets that can be generated from the
array `wv_master`. In addition, the relative position of the
central line of each triplet is also computed.
... | [
"def",
"gen_triplets_master",
"(",
"wv_master",
",",
"geometry",
"=",
"None",
",",
"debugplot",
"=",
"0",
")",
":",
"nlines_master",
"=",
"wv_master",
".",
"size",
"# Check that the wavelengths in the master table are sorted",
"wv_previous",
"=",
"wv_master",
"[",
"0"... | Compute information associated to triplets in master table.
Determine all the possible triplets that can be generated from the
array `wv_master`. In addition, the relative position of the
central line of each triplet is also computed.
Parameters
----------
wv_master : 1d numpy array, float
... | [
"Compute",
"information",
"associated",
"to",
"triplets",
"in",
"master",
"table",
"."
] | python | train |
lago-project/lago | lago/prefix.py | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1048-L1065 | def _use_prototype(self, spec, prototypes):
"""
Populates the given spec with the values of it's declared prototype
Args:
spec (dict): spec to update
prototypes (dict): Configuration spec containing the prototypes
Returns:
dict: updated spec
... | [
"def",
"_use_prototype",
"(",
"self",
",",
"spec",
",",
"prototypes",
")",
":",
"prototype",
"=",
"spec",
"[",
"'based-on'",
"]",
"del",
"spec",
"[",
"'based-on'",
"]",
"for",
"attr",
"in",
"prototype",
":",
"if",
"attr",
"not",
"in",
"spec",
":",
"spe... | Populates the given spec with the values of it's declared prototype
Args:
spec (dict): spec to update
prototypes (dict): Configuration spec containing the prototypes
Returns:
dict: updated spec | [
"Populates",
"the",
"given",
"spec",
"with",
"the",
"values",
"of",
"it",
"s",
"declared",
"prototype"
] | python | train |
dslackw/slpkg | slpkg/sbo/slackbuild.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L216-L222 | def matching(self):
"""Return found matching SBo packages
"""
for sbo in self.package_not_found:
for pkg in self.data:
if sbo in pkg and pkg not in self.blacklist:
self.package_found.append(pkg) | [
"def",
"matching",
"(",
"self",
")",
":",
"for",
"sbo",
"in",
"self",
".",
"package_not_found",
":",
"for",
"pkg",
"in",
"self",
".",
"data",
":",
"if",
"sbo",
"in",
"pkg",
"and",
"pkg",
"not",
"in",
"self",
".",
"blacklist",
":",
"self",
".",
"pac... | Return found matching SBo packages | [
"Return",
"found",
"matching",
"SBo",
"packages"
] | python | train |
GeoPyTool/GeoPyTool | Experimental/Alpah_Shape_2D.py | https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/Experimental/Alpah_Shape_2D.py#L39-L89 | def alpha_shape(points, alpha):
"""
Compute the alpha shape (concave hull) of a set
of points.
@param points: Iterable container of points.
@param alpha: alpha value to influence the
gooeyness of the border. Smaller numbers
don't fall inward as much as larger numbers.
Too lar... | [
"def",
"alpha_shape",
"(",
"points",
",",
"alpha",
")",
":",
"if",
"len",
"(",
"points",
")",
"<",
"4",
":",
"# When you have a triangle, there is no sense",
"# in computing an alpha shape.",
"return",
"geometry",
".",
"MultiPoint",
"(",
"list",
"(",
"points",
")"... | Compute the alpha shape (concave hull) of a set
of points.
@param points: Iterable container of points.
@param alpha: alpha value to influence the
gooeyness of the border. Smaller numbers
don't fall inward as much as larger numbers.
Too large, and you lose everything! | [
"Compute",
"the",
"alpha",
"shape",
"(",
"concave",
"hull",
")",
"of",
"a",
"set",
"of",
"points",
"."
] | python | train |
kstaniek/condoor | condoor/utils.py | https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L122-L165 | def parse_inventory(inventory_output=None):
"""Parse the inventory text and return udi dict."""
udi = {
"name": "",
"description": "",
"pid": "",
"vid": "",
"sn": ""
}
if inventory_output is None:
return udi
# find the record with chassis text in name... | [
"def",
"parse_inventory",
"(",
"inventory_output",
"=",
"None",
")",
":",
"udi",
"=",
"{",
"\"name\"",
":",
"\"\"",
",",
"\"description\"",
":",
"\"\"",
",",
"\"pid\"",
":",
"\"\"",
",",
"\"vid\"",
":",
"\"\"",
",",
"\"sn\"",
":",
"\"\"",
"}",
"if",
"i... | Parse the inventory text and return udi dict. | [
"Parse",
"the",
"inventory",
"text",
"and",
"return",
"udi",
"dict",
"."
] | python | train |
django-py/django-doberman | doberman/decorators.py | https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/decorators.py#L32-L47 | def protect_login_with_captcha(func):
"""
Protect the login with a captcha after of N failed access attempts
:param func:
:return:
"""
@wraps(func)
def decorated_login(request, *args, **kwargs):
response = func(request, *args, **kwargs)
access_attempt = AccessAttempt(request... | [
"def",
"protect_login_with_captcha",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorated_login",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"func",
"(",
"request",
",",
"*",
"args",
",",
... | Protect the login with a captcha after of N failed access attempts
:param func:
:return: | [
"Protect",
"the",
"login",
"with",
"a",
"captcha",
"after",
"of",
"N",
"failed",
"access",
"attempts",
":",
"param",
"func",
":",
":",
"return",
":"
] | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/output_writers.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/output_writers.py#L651-L662 | def write(self, data):
"""Write data to the GoogleCloudStorage file.
Args:
data: string containing the data to be written.
"""
start_time = time.time()
self._get_write_buffer().write(data)
ctx = context.get()
operation.counters.Increment(COUNTER_IO_WRITE_BYTES, len(data))(ctx)
ope... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_get_write_buffer",
"(",
")",
".",
"write",
"(",
"data",
")",
"ctx",
"=",
"context",
".",
"get",
"(",
")",
"operation",
".",
"counte... | Write data to the GoogleCloudStorage file.
Args:
data: string containing the data to be written. | [
"Write",
"data",
"to",
"the",
"GoogleCloudStorage",
"file",
"."
] | python | train |
labstreaminglayer/liblsl-Python | pylsl/pylsl.py | https://github.com/labstreaminglayer/liblsl-Python/blob/1ff6fe2794f8dba286b7491d1f7a4c915b8a0605/pylsl/pylsl.py#L1003-L1008 | def set_child_value(self, name, value):
"""Set the text value of the (nameless) plain-text child of a named
child node."""
return XMLElement(lib.lsl_set_child_value(self.e,
str.encode(name),
str.... | [
"def",
"set_child_value",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"return",
"XMLElement",
"(",
"lib",
".",
"lsl_set_child_value",
"(",
"self",
".",
"e",
",",
"str",
".",
"encode",
"(",
"name",
")",
",",
"str",
".",
"encode",
"(",
"value",
"... | Set the text value of the (nameless) plain-text child of a named
child node. | [
"Set",
"the",
"text",
"value",
"of",
"the",
"(",
"nameless",
")",
"plain",
"-",
"text",
"child",
"of",
"a",
"named",
"child",
"node",
"."
] | python | test |
IdentityPython/pysaml2 | src/saml2/client.py | https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/client.py#L417-L483 | def do_attribute_query(self, entityid, subject_id,
attribute=None, sp_name_qualifier=None,
name_qualifier=None, nameid_format=None,
real_id=None, consent=None, extensions=None,
sign=False, binding=BINDING_SOAP, n... | [
"def",
"do_attribute_query",
"(",
"self",
",",
"entityid",
",",
"subject_id",
",",
"attribute",
"=",
"None",
",",
"sp_name_qualifier",
"=",
"None",
",",
"name_qualifier",
"=",
"None",
",",
"nameid_format",
"=",
"None",
",",
"real_id",
"=",
"None",
",",
"cons... | Does a attribute request to an attribute authority, this is
by default done over SOAP.
:param entityid: To whom the query should be sent
:param subject_id: The identifier of the subject
:param attribute: A dictionary of attributes and values that is
asked for
:param ... | [
"Does",
"a",
"attribute",
"request",
"to",
"an",
"attribute",
"authority",
"this",
"is",
"by",
"default",
"done",
"over",
"SOAP",
"."
] | python | train |
tango-controls/pytango | tango/databaseds/database.py | https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/databaseds/database.py#L1315-L1330 | def DbGetDevicePropertyHist(self, argin):
""" Retrieve device property history
:param argin: Str[0] = Device name
Str[1] = Property name
:type: tango.DevVarStringArray
:return: Str[0] = Property name
Str[1] = date
Str[2] = Property value number (array case)
... | [
"def",
"DbGetDevicePropertyHist",
"(",
"self",
",",
"argin",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"In DbGetDevicePropertyHist()\"",
")",
"device_name",
"=",
"argin",
"[",
"0",
"]",
"prop_name",
"=",
"argin",
"[",
"1",
"]",
"return",
"self",
... | Retrieve device property history
:param argin: Str[0] = Device name
Str[1] = Property name
:type: tango.DevVarStringArray
:return: Str[0] = Property name
Str[1] = date
Str[2] = Property value number (array case)
Str[3] = Property value 1
Str[n] = Propert... | [
"Retrieve",
"device",
"property",
"history"
] | python | train |
johnnoone/aioconsul | aioconsul/client/catalog_endpoint.py | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/catalog_endpoint.py#L330-L360 | async def services(self, *, dc=None, watch=None, consistency=None):
"""Lists services in a given DC
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
watch (Blocking): Do a blocking query
consi... | [
"async",
"def",
"services",
"(",
"self",
",",
"*",
",",
"dc",
"=",
"None",
",",
"watch",
"=",
"None",
",",
"consistency",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"dc\"",
":",
"dc",
"}",
"response",
"=",
"await",
"self",
".",
"_api",
".",
"ge... | Lists services in a given DC
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
watch (Blocking): Do a blocking query
consistency (Consistency): Force consistency
Returns:
ObjectMeta... | [
"Lists",
"services",
"in",
"a",
"given",
"DC"
] | python | train |
spyder-ide/spyder | spyder/plugins/editor/plugin.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1365-L1371 | def refresh_file_dependent_actions(self):
"""Enable/disable file dependent actions
(only if dockwidget is visible)"""
if self.dockwidget and self.dockwidget.isVisible():
enable = self.get_current_editor() is not None
for action in self.file_dependent_actions:
... | [
"def",
"refresh_file_dependent_actions",
"(",
"self",
")",
":",
"if",
"self",
".",
"dockwidget",
"and",
"self",
".",
"dockwidget",
".",
"isVisible",
"(",
")",
":",
"enable",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"is",
"not",
"None",
"for",
"act... | Enable/disable file dependent actions
(only if dockwidget is visible) | [
"Enable",
"/",
"disable",
"file",
"dependent",
"actions",
"(",
"only",
"if",
"dockwidget",
"is",
"visible",
")"
] | python | train |
RPi-Distro/python-sense-hat | sense_hat/sense_hat.py | https://github.com/RPi-Distro/python-sense-hat/blob/9a37f0923ce8dbde69514c3b8d58d30de01c9ee7/sense_hat/sense_hat.py#L650-L677 | def set_imu_config(self, compass_enabled, gyro_enabled, accel_enabled):
"""
Enables and disables the gyroscope, accelerometer and/or magnetometer
input to the orientation functions
"""
# If the consuming code always calls this just before reading the IMU
# the IMU consis... | [
"def",
"set_imu_config",
"(",
"self",
",",
"compass_enabled",
",",
"gyro_enabled",
",",
"accel_enabled",
")",
":",
"# If the consuming code always calls this just before reading the IMU",
"# the IMU consistently fails to read. So prevent unnecessary calls to",
"# IMU config functions usi... | Enables and disables the gyroscope, accelerometer and/or magnetometer
input to the orientation functions | [
"Enables",
"and",
"disables",
"the",
"gyroscope",
"accelerometer",
"and",
"/",
"or",
"magnetometer",
"input",
"to",
"the",
"orientation",
"functions"
] | python | train |
pypa/pipenv | pipenv/vendor/pexpect/popen_spawn.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/popen_spawn.py#L149-L154 | def sendline(self, s=''):
'''Wraps send(), sending string ``s`` to child process, with os.linesep
automatically appended. Returns number of bytes written. '''
n = self.send(s)
return n + self.send(self.linesep) | [
"def",
"sendline",
"(",
"self",
",",
"s",
"=",
"''",
")",
":",
"n",
"=",
"self",
".",
"send",
"(",
"s",
")",
"return",
"n",
"+",
"self",
".",
"send",
"(",
"self",
".",
"linesep",
")"
] | Wraps send(), sending string ``s`` to child process, with os.linesep
automatically appended. Returns number of bytes written. | [
"Wraps",
"send",
"()",
"sending",
"string",
"s",
"to",
"child",
"process",
"with",
"os",
".",
"linesep",
"automatically",
"appended",
".",
"Returns",
"number",
"of",
"bytes",
"written",
"."
] | python | train |
spyder-ide/spyder | spyder/utils/misc.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/misc.py#L210-L222 | def get_common_path(pathlist):
"""Return common path for all paths in pathlist"""
common = osp.normpath(osp.commonprefix(pathlist))
if len(common) > 1:
if not osp.isdir(common):
return abspardir(common)
else:
for path in pathlist:
if not osp.is... | [
"def",
"get_common_path",
"(",
"pathlist",
")",
":",
"common",
"=",
"osp",
".",
"normpath",
"(",
"osp",
".",
"commonprefix",
"(",
"pathlist",
")",
")",
"if",
"len",
"(",
"common",
")",
">",
"1",
":",
"if",
"not",
"osp",
".",
"isdir",
"(",
"common",
... | Return common path for all paths in pathlist | [
"Return",
"common",
"path",
"for",
"all",
"paths",
"in",
"pathlist"
] | python | train |
google/python-adb | adb/common.py | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L226-L238 | def Find(cls, setting_matcher, port_path=None, serial=None, timeout_ms=None):
"""Gets the first device that matches according to the keyword args."""
if port_path:
device_matcher = cls.PortPathMatcher(port_path)
usb_info = port_path
elif serial:
device_matcher... | [
"def",
"Find",
"(",
"cls",
",",
"setting_matcher",
",",
"port_path",
"=",
"None",
",",
"serial",
"=",
"None",
",",
"timeout_ms",
"=",
"None",
")",
":",
"if",
"port_path",
":",
"device_matcher",
"=",
"cls",
".",
"PortPathMatcher",
"(",
"port_path",
")",
"... | Gets the first device that matches according to the keyword args. | [
"Gets",
"the",
"first",
"device",
"that",
"matches",
"according",
"to",
"the",
"keyword",
"args",
"."
] | python | train |
noirbizarre/bumpr | tasks.py | https://github.com/noirbizarre/bumpr/blob/221dbb3deaf1cae7922f6a477f3d29d6bf0c0035/tasks.py#L57-L60 | def error(text):
'''Display an error message'''
print(red('✘ {0}'.format(text)))
sys.stdout.flush() | [
"def",
"error",
"(",
"text",
")",
":",
"print",
"(",
"red",
"(",
"'✘ {0}'.f",
"o",
"rmat(t",
"e",
"xt))",
")",
"",
"",
"sys",
".",
"stdout",
".",
"flush",
"(",
")"
] | Display an error message | [
"Display",
"an",
"error",
"message"
] | python | train |
ArabellaTech/django-basic-cms | basic_cms/managers.py | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/managers.py#L104-L110 | def drafts(self):
"""Creates a :class:`QuerySet` of drafts using the page's
:attr:`Page.publication_date`."""
pub = self.on_site().filter(status=self.model.DRAFT)
if settings.PAGE_SHOW_START_DATE:
pub = pub.filter(publication_date__gte=datetime.now())
return pub | [
"def",
"drafts",
"(",
"self",
")",
":",
"pub",
"=",
"self",
".",
"on_site",
"(",
")",
".",
"filter",
"(",
"status",
"=",
"self",
".",
"model",
".",
"DRAFT",
")",
"if",
"settings",
".",
"PAGE_SHOW_START_DATE",
":",
"pub",
"=",
"pub",
".",
"filter",
... | Creates a :class:`QuerySet` of drafts using the page's
:attr:`Page.publication_date`. | [
"Creates",
"a",
":",
"class",
":",
"QuerySet",
"of",
"drafts",
"using",
"the",
"page",
"s",
":",
"attr",
":",
"Page",
".",
"publication_date",
"."
] | python | train |
mozilla/DeepSpeech | bin/benchmark_nc.py | https://github.com/mozilla/DeepSpeech/blob/f64aa73e7fbe9dde40d4fcf23b42ab304747d152/bin/benchmark_nc.py#L121-L137 | def maybe_inspect_zip(models):
r'''
Detect if models is a list of protocolbuffer files or a ZIP file.
If the latter, then unzip it and return the list of protocolbuffer files
that were inside.
'''
if not(is_zip_file(models)):
return models
if len(models) > 1:
return models
... | [
"def",
"maybe_inspect_zip",
"(",
"models",
")",
":",
"if",
"not",
"(",
"is_zip_file",
"(",
"models",
")",
")",
":",
"return",
"models",
"if",
"len",
"(",
"models",
")",
">",
"1",
":",
"return",
"models",
"if",
"len",
"(",
"models",
")",
"<",
"1",
"... | r'''
Detect if models is a list of protocolbuffer files or a ZIP file.
If the latter, then unzip it and return the list of protocolbuffer files
that were inside. | [
"r",
"Detect",
"if",
"models",
"is",
"a",
"list",
"of",
"protocolbuffer",
"files",
"or",
"a",
"ZIP",
"file",
".",
"If",
"the",
"latter",
"then",
"unzip",
"it",
"and",
"return",
"the",
"list",
"of",
"protocolbuffer",
"files",
"that",
"were",
"inside",
"."... | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/collection.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/collection.py#L2503-L2535 | def update(self, spec, document, upsert=False, manipulate=False,
multi=False, check_keys=True, **kwargs):
"""Update a document(s) in this collection.
**DEPRECATED** - Use :meth:`replace_one`, :meth:`update_one`, or
:meth:`update_many` instead.
.. versionchanged:: 3.0
... | [
"def",
"update",
"(",
"self",
",",
"spec",
",",
"document",
",",
"upsert",
"=",
"False",
",",
"manipulate",
"=",
"False",
",",
"multi",
"=",
"False",
",",
"check_keys",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"... | Update a document(s) in this collection.
**DEPRECATED** - Use :meth:`replace_one`, :meth:`update_one`, or
:meth:`update_many` instead.
.. versionchanged:: 3.0
Removed the `safe` parameter. Pass ``w=0`` for unacknowledged write
operations. | [
"Update",
"a",
"document",
"(",
"s",
")",
"in",
"this",
"collection",
"."
] | python | train |
teepark/greenhouse | greenhouse/util.py | https://github.com/teepark/greenhouse/blob/8fd1be4f5443ba090346b5ec82fdbeb0a060d956/greenhouse/util.py#L952-L957 | def increment(self):
"increment the counter, and wake anyone waiting for the new value"
self._count += 1
waiters = self._waiters.pop(self._count, [])
if waiters:
scheduler.state.awoken_from_events.update(waiters) | [
"def",
"increment",
"(",
"self",
")",
":",
"self",
".",
"_count",
"+=",
"1",
"waiters",
"=",
"self",
".",
"_waiters",
".",
"pop",
"(",
"self",
".",
"_count",
",",
"[",
"]",
")",
"if",
"waiters",
":",
"scheduler",
".",
"state",
".",
"awoken_from_event... | increment the counter, and wake anyone waiting for the new value | [
"increment",
"the",
"counter",
"and",
"wake",
"anyone",
"waiting",
"for",
"the",
"new",
"value"
] | python | train |
Nekroze/partpy | partpy/sourcestring.py | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L493-L510 | def skip_whitespace(self, newlines=0):
"""Moves the position forwards to the next non newline space character.
If newlines >= 1 include newlines as spaces.
"""
if newlines:
while not self.eos:
if self.get_char().isspace():
self.eat_length(1... | [
"def",
"skip_whitespace",
"(",
"self",
",",
"newlines",
"=",
"0",
")",
":",
"if",
"newlines",
":",
"while",
"not",
"self",
".",
"eos",
":",
"if",
"self",
".",
"get_char",
"(",
")",
".",
"isspace",
"(",
")",
":",
"self",
".",
"eat_length",
"(",
"1",... | Moves the position forwards to the next non newline space character.
If newlines >= 1 include newlines as spaces. | [
"Moves",
"the",
"position",
"forwards",
"to",
"the",
"next",
"non",
"newline",
"space",
"character",
".",
"If",
"newlines",
">",
"=",
"1",
"include",
"newlines",
"as",
"spaces",
"."
] | python | train |
OCHA-DAP/hdx-python-utilities | src/hdx/utilities/dictandlist.py | https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/dictandlist.py#L283-L295 | def integer_value_convert(dictin, dropfailedvalues=False):
# type: (DictUpperBound, bool) -> Dict
"""Convert values of dictionary to integers
Args:
dictin (DictUpperBound): Input dictionary
dropfailedvalues (bool): Whether to drop dictionary entries where key conversion fails. Defaults to F... | [
"def",
"integer_value_convert",
"(",
"dictin",
",",
"dropfailedvalues",
"=",
"False",
")",
":",
"# type: (DictUpperBound, bool) -> Dict",
"return",
"key_value_convert",
"(",
"dictin",
",",
"valuefn",
"=",
"int",
",",
"dropfailedvalues",
"=",
"dropfailedvalues",
")"
] | Convert values of dictionary to integers
Args:
dictin (DictUpperBound): Input dictionary
dropfailedvalues (bool): Whether to drop dictionary entries where key conversion fails. Defaults to False.
Returns:
Dict: Dictionary with values converted to integers | [
"Convert",
"values",
"of",
"dictionary",
"to",
"integers"
] | python | train |
xtrementl/focus | focus/common.py | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/common.py#L252-L268 | def to_utf8(buf, errors='replace'):
""" Encodes a string into a UTF-8 compatible, ASCII string.
`buf`
string or unicode to convert.
Returns string.
* Raises a ``UnicodeEncodeError`` exception if encoding failed and
`errors` isn't set to 'replace'.
"""
if... | [
"def",
"to_utf8",
"(",
"buf",
",",
"errors",
"=",
"'replace'",
")",
":",
"if",
"isinstance",
"(",
"buf",
",",
"unicode",
")",
":",
"return",
"buf",
".",
"encode",
"(",
"'utf-8'",
",",
"errors",
")",
"else",
":",
"return",
"buf"
] | Encodes a string into a UTF-8 compatible, ASCII string.
`buf`
string or unicode to convert.
Returns string.
* Raises a ``UnicodeEncodeError`` exception if encoding failed and
`errors` isn't set to 'replace'. | [
"Encodes",
"a",
"string",
"into",
"a",
"UTF",
"-",
"8",
"compatible",
"ASCII",
"string",
"."
] | python | train |
danilobellini/audiolazy | audiolazy/lazy_stream.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_stream.py#L413-L429 | def tostream(func, module_name=None):
"""
Decorator to convert the function output into a Stream. Useful for
generator functions.
Note
----
Always use the ``module_name`` input when "decorating" a function that was
defined in other module.
"""
@wraps(func)
def new_func(*args, **kwargs):
return... | [
"def",
"tostream",
"(",
"func",
",",
"module_name",
"=",
"None",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"new_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Stream",
"(",
"func",
"(",
"*",
"args",
",",
"*",
"*",
... | Decorator to convert the function output into a Stream. Useful for
generator functions.
Note
----
Always use the ``module_name`` input when "decorating" a function that was
defined in other module. | [
"Decorator",
"to",
"convert",
"the",
"function",
"output",
"into",
"a",
"Stream",
".",
"Useful",
"for",
"generator",
"functions",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/quantum_info/synthesis/two_qubit_kak.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/synthesis/two_qubit_kak.py#L40-L97 | def euler_angles_1q(unitary_matrix):
"""Compute Euler angles for a single-qubit gate.
Find angles (theta, phi, lambda) such that
unitary_matrix = phase * Rz(phi) * Ry(theta) * Rz(lambda)
Args:
unitary_matrix (ndarray): 2x2 unitary matrix
Returns:
tuple: (theta, phi, lambda) Euler ... | [
"def",
"euler_angles_1q",
"(",
"unitary_matrix",
")",
":",
"if",
"unitary_matrix",
".",
"shape",
"!=",
"(",
"2",
",",
"2",
")",
":",
"raise",
"QiskitError",
"(",
"\"euler_angles_1q: expected 2x2 matrix\"",
")",
"phase",
"=",
"la",
".",
"det",
"(",
"unitary_mat... | Compute Euler angles for a single-qubit gate.
Find angles (theta, phi, lambda) such that
unitary_matrix = phase * Rz(phi) * Ry(theta) * Rz(lambda)
Args:
unitary_matrix (ndarray): 2x2 unitary matrix
Returns:
tuple: (theta, phi, lambda) Euler angles of SU(2)
Raises:
QiskitE... | [
"Compute",
"Euler",
"angles",
"for",
"a",
"single",
"-",
"qubit",
"gate",
"."
] | python | test |
heitzmann/gdspy | examples/photonics.py | https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/examples/photonics.py#L113-L191 | def grating(period,
number_of_teeth,
fill_frac,
width,
position,
direction,
lda=1,
sin_theta=0,
focus_distance=-1,
focus_width=-1,
evaluations=99,
layer=0,
datatype=0):
'''... | [
"def",
"grating",
"(",
"period",
",",
"number_of_teeth",
",",
"fill_frac",
",",
"width",
",",
"position",
",",
"direction",
",",
"lda",
"=",
"1",
",",
"sin_theta",
"=",
"0",
",",
"focus_distance",
"=",
"-",
"1",
",",
"focus_width",
"=",
"-",
"1",
",",
... | Straight or focusing grating.
period : grating period
number_of_teeth : number of teeth in the grating
fill_frac : filling fraction of the teeth (w.r.t. the period)
width : width of the grating
position : grating position (feed point)
direction : one of {'+... | [
"Straight",
"or",
"focusing",
"grating",
"."
] | python | train |
sosy-lab/benchexec | benchexec/util.py | https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/util.py#L76-L82 | def printOut(value, end='\n'):
"""
This function prints the given String immediately and flushes the output.
"""
sys.stdout.write(value)
sys.stdout.write(end)
sys.stdout.flush() | [
"def",
"printOut",
"(",
"value",
",",
"end",
"=",
"'\\n'",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"value",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"end",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")"
] | This function prints the given String immediately and flushes the output. | [
"This",
"function",
"prints",
"the",
"given",
"String",
"immediately",
"and",
"flushes",
"the",
"output",
"."
] | python | train |
mwickert/scikit-dsp-comm | sk_dsp_comm/pyaudio_helper.py | https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/pyaudio_helper.py#L263-L278 | def DSP_capture_add_samples_stereo(self,new_data_left,new_data_right):
"""
Append new samples to the data_capture_left array and the data_capture_right
array and increment the sample counter. If length reaches Tcapture, then the
newest samples will be kept. If Tcapture = 0 then new ... | [
"def",
"DSP_capture_add_samples_stereo",
"(",
"self",
",",
"new_data_left",
",",
"new_data_right",
")",
":",
"self",
".",
"capture_sample_count",
"=",
"self",
".",
"capture_sample_count",
"+",
"len",
"(",
"new_data_left",
")",
"+",
"len",
"(",
"new_data_right",
")... | Append new samples to the data_capture_left array and the data_capture_right
array and increment the sample counter. If length reaches Tcapture, then the
newest samples will be kept. If Tcapture = 0 then new values are not appended
to the data_capture array. | [
"Append",
"new",
"samples",
"to",
"the",
"data_capture_left",
"array",
"and",
"the",
"data_capture_right",
"array",
"and",
"increment",
"the",
"sample",
"counter",
".",
"If",
"length",
"reaches",
"Tcapture",
"then",
"the",
"newest",
"samples",
"will",
"be",
"kep... | python | valid |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/base_camera.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/base_camera.py#L343-L361 | def link(self, camera):
""" Link this camera with another camera of the same type
Linked camera's keep each-others' state in sync.
Parameters
----------
camera : instance of Camera
The other camera to link.
"""
cam1, cam2 = self, camera
# Rem... | [
"def",
"link",
"(",
"self",
",",
"camera",
")",
":",
"cam1",
",",
"cam2",
"=",
"self",
",",
"camera",
"# Remove if already linked",
"while",
"cam1",
"in",
"cam2",
".",
"_linked_cameras",
":",
"cam2",
".",
"_linked_cameras",
".",
"remove",
"(",
"cam1",
")",... | Link this camera with another camera of the same type
Linked camera's keep each-others' state in sync.
Parameters
----------
camera : instance of Camera
The other camera to link. | [
"Link",
"this",
"camera",
"with",
"another",
"camera",
"of",
"the",
"same",
"type"
] | python | train |
armstrong/armstrong.apps.related_content | armstrong/apps/related_content/admin.py | https://github.com/armstrong/armstrong.apps.related_content/blob/f57b6908d3c76c4a44b2241c676ab5d86391106c/armstrong/apps/related_content/admin.py#L46-L68 | def formfield_for_foreignkey_helper(inline, *args, **kwargs):
"""
The implementation for ``RelatedContentInline.formfield_for_foreignkey``
This takes the takes all of the ``args`` and ``kwargs`` from the call to
``formfield_for_foreignkey`` and operates on this. It returns the updated
``args`` and... | [
"def",
"formfield_for_foreignkey_helper",
"(",
"inline",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"db_field",
"=",
"args",
"[",
"0",
"]",
"if",
"db_field",
".",
"name",
"!=",
"\"related_type\"",
":",
"return",
"args",
",",
"kwargs",
"initial_fi... | The implementation for ``RelatedContentInline.formfield_for_foreignkey``
This takes the takes all of the ``args`` and ``kwargs`` from the call to
``formfield_for_foreignkey`` and operates on this. It returns the updated
``args`` and ``kwargs`` to be passed on to ``super``.
This is solely an implement... | [
"The",
"implementation",
"for",
"RelatedContentInline",
".",
"formfield_for_foreignkey"
] | python | train |
KelSolaar/Umbra | umbra/ui/widgets/basic_QPlainTextEdit.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/basic_QPlainTextEdit.py#L318-L333 | def wheelEvent(self, event):
"""
Reimplements the :meth:`QPlainTextEdit.wheelEvent` method.
:param event: Event.
:type event: QEvent
"""
if event.modifiers() == Qt.ControlModifier:
if event.delta() == 120:
self.zoom_in()
elif even... | [
"def",
"wheelEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"modifiers",
"(",
")",
"==",
"Qt",
".",
"ControlModifier",
":",
"if",
"event",
".",
"delta",
"(",
")",
"==",
"120",
":",
"self",
".",
"zoom_in",
"(",
")",
"elif",
"event"... | Reimplements the :meth:`QPlainTextEdit.wheelEvent` method.
:param event: Event.
:type event: QEvent | [
"Reimplements",
"the",
":",
"meth",
":",
"QPlainTextEdit",
".",
"wheelEvent",
"method",
"."
] | python | train |
SpockBotMC/SpockBot | spockbot/plugins/helpers/inventory.py | https://github.com/SpockBotMC/SpockBot/blob/f89911551f18357720034fbaa52837a0d09f66ea/spockbot/plugins/helpers/inventory.py#L98-L125 | def drop_slot(self, slot=None, drop_stack=False):
"""
Drop one or all items of the slot.
Does not wait for confirmation from the server. If you want that,
use a ``Task`` and ``yield inventory.async.drop_slot()`` instead.
If ``slot`` is None, drops the ``cursor_slot`` or, if tha... | [
"def",
"drop_slot",
"(",
"self",
",",
"slot",
"=",
"None",
",",
"drop_stack",
"=",
"False",
")",
":",
"if",
"slot",
"is",
"None",
":",
"if",
"self",
".",
"cursor_slot",
".",
"is_empty",
":",
"slot",
"=",
"self",
".",
"active_slot",
"else",
":",
"slot... | Drop one or all items of the slot.
Does not wait for confirmation from the server. If you want that,
use a ``Task`` and ``yield inventory.async.drop_slot()`` instead.
If ``slot`` is None, drops the ``cursor_slot`` or, if that's empty,
the currently held item (``active_slot``).
... | [
"Drop",
"one",
"or",
"all",
"items",
"of",
"the",
"slot",
"."
] | python | train |
Contraz/demosys-py | demosys/geometry/cube.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/geometry/cube.py#L6-L153 | def cube(width, height, depth, center=(0.0, 0.0, 0.0), normals=True, uvs=True) -> VAO:
"""
Creates a cube VAO with normals and texture coordinates
Args:
width (float): Width of the cube
height (float): Height of the cube
depth (float): Depth of the cube
Keyword Args:
ce... | [
"def",
"cube",
"(",
"width",
",",
"height",
",",
"depth",
",",
"center",
"=",
"(",
"0.0",
",",
"0.0",
",",
"0.0",
")",
",",
"normals",
"=",
"True",
",",
"uvs",
"=",
"True",
")",
"->",
"VAO",
":",
"width",
",",
"height",
",",
"depth",
"=",
"widt... | Creates a cube VAO with normals and texture coordinates
Args:
width (float): Width of the cube
height (float): Height of the cube
depth (float): Depth of the cube
Keyword Args:
center: center of the cube as a 3-component tuple
normals: (bool) Include normals
uvs... | [
"Creates",
"a",
"cube",
"VAO",
"with",
"normals",
"and",
"texture",
"coordinates"
] | python | valid |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgets/reftrackwidget.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/reftrackwidget.py#L104-L124 | def setup_icons(self, ):
"""Setup the icons of the ui
:returns: None
:rtype: None
:raises: None
"""
iconbtns = [("menu_border_24x24.png", self.menu_tb),
("duplicate_border_24x24.png", self.duplicate_tb),
("delete_border_24x24.png",... | [
"def",
"setup_icons",
"(",
"self",
",",
")",
":",
"iconbtns",
"=",
"[",
"(",
"\"menu_border_24x24.png\"",
",",
"self",
".",
"menu_tb",
")",
",",
"(",
"\"duplicate_border_24x24.png\"",
",",
"self",
".",
"duplicate_tb",
")",
",",
"(",
"\"delete_border_24x24.png\""... | Setup the icons of the ui
:returns: None
:rtype: None
:raises: None | [
"Setup",
"the",
"icons",
"of",
"the",
"ui"
] | python | train |
kamikaze/webdav | src/webdav/client.py | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L573-L591 | def move(self, remote_path_from, remote_path_to, overwrite=False):
"""Moves resource from one place to another on WebDAV server.
More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_MOVE
:param remote_path_from: the path to resource which will be moved,
:par... | [
"def",
"move",
"(",
"self",
",",
"remote_path_from",
",",
"remote_path_to",
",",
"overwrite",
"=",
"False",
")",
":",
"urn_from",
"=",
"Urn",
"(",
"remote_path_from",
")",
"if",
"not",
"self",
".",
"check",
"(",
"urn_from",
".",
"path",
"(",
")",
")",
... | Moves resource from one place to another on WebDAV server.
More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_MOVE
:param remote_path_from: the path to resource which will be moved,
:param remote_path_to: the path where resource will be moved.
:param overw... | [
"Moves",
"resource",
"from",
"one",
"place",
"to",
"another",
"on",
"WebDAV",
"server",
".",
"More",
"information",
"you",
"can",
"find",
"by",
"link",
"http",
":",
"//",
"webdav",
".",
"org",
"/",
"specs",
"/",
"rfc4918",
".",
"html#METHOD_MOVE"
] | python | train |
untwisted/untwisted | untwisted/iostd.py | https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/iostd.py#L67-L88 | def create_client(addr, port):
"""
Set up a TCP client and installs the basic handles Stdin, Stdout.
def send_data(client):
client.dump('GET / HTTP/1.1\r\n')
xmap(client, LOAD, iostd.put)
client = create_client('www.google.com.br', 80)
xmap(client, CONNECT, send_data)
"""
s... | [
"def",
"create_client",
"(",
"addr",
",",
"port",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"# First attempt to connect otherwise it leaves",
"# an unconnected spin instance in the reactor.",
... | Set up a TCP client and installs the basic handles Stdin, Stdout.
def send_data(client):
client.dump('GET / HTTP/1.1\r\n')
xmap(client, LOAD, iostd.put)
client = create_client('www.google.com.br', 80)
xmap(client, CONNECT, send_data) | [
"Set",
"up",
"a",
"TCP",
"client",
"and",
"installs",
"the",
"basic",
"handles",
"Stdin",
"Stdout",
"."
] | python | train |
mrstephenneal/pdfconduit | pdf/conduit/watermark/watermark.py | https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/pdf/conduit/watermark/watermark.py#L81-L133 | def draw(self, text1=None, text2=None, copyright=True, image=IMAGE_DEFAULT, rotate=30, opacity=0.08, compress=0,
flatten=False, add=False):
"""
Draw watermark PDF file.
Create watermark using either a reportlabs canvas or a PIL image.
:param text1: str
Text lin... | [
"def",
"draw",
"(",
"self",
",",
"text1",
"=",
"None",
",",
"text2",
"=",
"None",
",",
"copyright",
"=",
"True",
",",
"image",
"=",
"IMAGE_DEFAULT",
",",
"rotate",
"=",
"30",
",",
"opacity",
"=",
"0.08",
",",
"compress",
"=",
"0",
",",
"flatten",
"... | Draw watermark PDF file.
Create watermark using either a reportlabs canvas or a PIL image.
:param text1: str
Text line 1
:param text2: str
Text line 2
:param copyright: bool
Draw copyright and year to canvas
:param image: str
Logo... | [
"Draw",
"watermark",
"PDF",
"file",
"."
] | python | train |
rvswift/EB | EB/builder/utilities/screener.py | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/utilities/screener.py#L78-L148 | def screener(molecules, ensemble, sort_order):
"""
Uses the virtual screening scores for the receptors, or queries, specified in ensemble to sort the molecules in
molecules in the direction specified by sort_order.
:param molecules: a list of molecule objects (/classification/molecules.Molecules())
... | [
"def",
"screener",
"(",
"molecules",
",",
"ensemble",
",",
"sort_order",
")",
":",
"# screen",
"modified_molecules",
"=",
"[",
"]",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"molecules",
")",
")",
":",
"modified_molecules",
".",
"append",
"(",
"molec... | Uses the virtual screening scores for the receptors, or queries, specified in ensemble to sort the molecules in
molecules in the direction specified by sort_order.
:param molecules: a list of molecule objects (/classification/molecules.Molecules())
:param ensemble: a tuple with receptors, or a query, that s... | [
"Uses",
"the",
"virtual",
"screening",
"scores",
"for",
"the",
"receptors",
"or",
"queries",
"specified",
"in",
"ensemble",
"to",
"sort",
"the",
"molecules",
"in",
"molecules",
"in",
"the",
"direction",
"specified",
"by",
"sort_order",
".",
":",
"param",
"mole... | python | train |
scrapinghub/kafka-scanner | kafka_scanner/__init__.py | https://github.com/scrapinghub/kafka-scanner/blob/8a71901012e8c948180f70a485b57f8d2e7e3ec1/kafka_scanner/__init__.py#L101-L107 | def append_stat_var(self, name, get_func):
"""
get_func is a function that returns a tuple (name, value)
"""
self._stats_getters.append(get_func)
self._stats_logline += '%s: {}. ' % name
self._stats_logline_totals += 'Total %s: {}. ' % name | [
"def",
"append_stat_var",
"(",
"self",
",",
"name",
",",
"get_func",
")",
":",
"self",
".",
"_stats_getters",
".",
"append",
"(",
"get_func",
")",
"self",
".",
"_stats_logline",
"+=",
"'%s: {}. '",
"%",
"name",
"self",
".",
"_stats_logline_totals",
"+=",
"'T... | get_func is a function that returns a tuple (name, value) | [
"get_func",
"is",
"a",
"function",
"that",
"returns",
"a",
"tuple",
"(",
"name",
"value",
")"
] | python | train |
Azure/azure-kusto-python | azure-kusto-ingest/azure/kusto/ingest/_ingest_client.py | https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-ingest/azure/kusto/ingest/_ingest_client.py#L105-L121 | def ingest_from_blob(self, blob_descriptor, ingestion_properties):
"""Enqueuing an ingest command from azure blobs.
:param azure.kusto.ingest.BlobDescriptor blob_descriptor: An object that contains a description of the blob to be ingested.
:param azure.kusto.ingest.IngestionProperties ingestion_... | [
"def",
"ingest_from_blob",
"(",
"self",
",",
"blob_descriptor",
",",
"ingestion_properties",
")",
":",
"queues",
"=",
"self",
".",
"_resource_manager",
".",
"get_ingestion_queues",
"(",
")",
"queue_details",
"=",
"random",
".",
"choice",
"(",
"queues",
")",
"sto... | Enqueuing an ingest command from azure blobs.
:param azure.kusto.ingest.BlobDescriptor blob_descriptor: An object that contains a description of the blob to be ingested.
:param azure.kusto.ingest.IngestionProperties ingestion_properties: Ingestion properties. | [
"Enqueuing",
"an",
"ingest",
"command",
"from",
"azure",
"blobs",
".",
":",
"param",
"azure",
".",
"kusto",
".",
"ingest",
".",
"BlobDescriptor",
"blob_descriptor",
":",
"An",
"object",
"that",
"contains",
"a",
"description",
"of",
"the",
"blob",
"to",
"be",... | python | train |
Kortemme-Lab/klab | klab/bio/basics.py | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/basics.py#L998-L1009 | def mutation_combinations(mutations):
'''A generator which returns all non-empty combinations of ChainMutation objects, respecting residue position i.e. if two residues
have the same chain and residue ID then we do not return a combination with both residues.
Note: You need to use ChainMutation object... | [
"def",
"mutation_combinations",
"(",
"mutations",
")",
":",
"mutations",
"=",
"sorted",
"(",
"mutations",
")",
"combntn",
"=",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"itertools",
".",
"combinations",
"(",
"mutations",
",",
"x",
")",
"for",
"x"... | A generator which returns all non-empty combinations of ChainMutation objects, respecting residue position i.e. if two residues
have the same chain and residue ID then we do not return a combination with both residues.
Note: You need to use ChainMutation objects here as their equality considers the chain ... | [
"A",
"generator",
"which",
"returns",
"all",
"non",
"-",
"empty",
"combinations",
"of",
"ChainMutation",
"objects",
"respecting",
"residue",
"position",
"i",
".",
"e",
".",
"if",
"two",
"residues",
"have",
"the",
"same",
"chain",
"and",
"residue",
"ID",
"the... | python | train |
robotools/fontParts | Lib/fontParts/base/bPoint.py | https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/bPoint.py#L233-L244 | def _get_bcpOut(self):
"""
Subclasses may override this method.
"""
nextSegment = self._nextSegment
offCurves = nextSegment.offCurve
if offCurves:
bcp = offCurves[0]
x, y = relativeBCPOut(self.anchor, (bcp.x, bcp.y))
else:
x = y... | [
"def",
"_get_bcpOut",
"(",
"self",
")",
":",
"nextSegment",
"=",
"self",
".",
"_nextSegment",
"offCurves",
"=",
"nextSegment",
".",
"offCurve",
"if",
"offCurves",
":",
"bcp",
"=",
"offCurves",
"[",
"0",
"]",
"x",
",",
"y",
"=",
"relativeBCPOut",
"(",
"se... | Subclasses may override this method. | [
"Subclasses",
"may",
"override",
"this",
"method",
"."
] | python | train |
robinandeer/puzzle | puzzle/models/variant.py | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/variant.py#L146-L157 | def add_gene(self, gene):
"""Add the information of a gene
This adds a gene dict to variant['genes']
Args:
gene (dict): A gene dictionary
"""
logger.debug("Adding gene {0} to variant {1}".format(
gene, self['variant_id']))
self['gene... | [
"def",
"add_gene",
"(",
"self",
",",
"gene",
")",
":",
"logger",
".",
"debug",
"(",
"\"Adding gene {0} to variant {1}\"",
".",
"format",
"(",
"gene",
",",
"self",
"[",
"'variant_id'",
"]",
")",
")",
"self",
"[",
"'genes'",
"]",
".",
"append",
"(",
"gene"... | Add the information of a gene
This adds a gene dict to variant['genes']
Args:
gene (dict): A gene dictionary | [
"Add",
"the",
"information",
"of",
"a",
"gene"
] | python | train |
PolicyStat/jobtastic | jobtastic/task.py | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L378-L390 | def _validate_required_class_vars(self):
"""
Ensure that this subclass has defined all of the required class
variables.
"""
required_members = (
'significant_kwargs',
'herd_avoidance_timeout',
)
for required_member in required_members:
... | [
"def",
"_validate_required_class_vars",
"(",
"self",
")",
":",
"required_members",
"=",
"(",
"'significant_kwargs'",
",",
"'herd_avoidance_timeout'",
",",
")",
"for",
"required_member",
"in",
"required_members",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"requir... | Ensure that this subclass has defined all of the required class
variables. | [
"Ensure",
"that",
"this",
"subclass",
"has",
"defined",
"all",
"of",
"the",
"required",
"class",
"variables",
"."
] | python | train |
jeongyoonlee/Kaggler | kaggler/preprocessing/data.py | https://github.com/jeongyoonlee/Kaggler/blob/20661105b61958dc9a3c529c1d3b2313ab23ae32/kaggler/preprocessing/data.py#L244-L267 | def transform(self, X):
"""Encode categorical columns into sparse matrix with one-hot-encoding.
Args:
X (pandas.DataFrame): categorical columns to encode
Returns:
X_new (scipy.sparse.coo_matrix): sparse matrix encoding categorical
... | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"for",
"i",
",",
"col",
"in",
"enumerate",
"(",
"X",
".",
"columns",
")",
":",
"X_col",
"=",
"self",
".",
"_transform_col",
"(",
"X",
"[",
"col",
"]",
",",
"i",
")",
"if",
"X_col",
"is",
"not... | Encode categorical columns into sparse matrix with one-hot-encoding.
Args:
X (pandas.DataFrame): categorical columns to encode
Returns:
X_new (scipy.sparse.coo_matrix): sparse matrix encoding categorical
variables into dummy variable... | [
"Encode",
"categorical",
"columns",
"into",
"sparse",
"matrix",
"with",
"one",
"-",
"hot",
"-",
"encoding",
"."
] | python | train |
django-getpaid/django-plans | plans/views.py | https://github.com/django-getpaid/django-plans/blob/6897fcb0ed02bfba0c689292961532fe400b7ba2/plans/views.py#L179-L209 | def recalculate(self, amount, billing_info):
"""
Calculates and return pre-filled Order
"""
order = Order(pk=-1)
order.amount = amount
order.currency = self.get_currency()
country = getattr(billing_info, 'country', None)
if not country is None:
... | [
"def",
"recalculate",
"(",
"self",
",",
"amount",
",",
"billing_info",
")",
":",
"order",
"=",
"Order",
"(",
"pk",
"=",
"-",
"1",
")",
"order",
".",
"amount",
"=",
"amount",
"order",
".",
"currency",
"=",
"self",
".",
"get_currency",
"(",
")",
"count... | Calculates and return pre-filled Order | [
"Calculates",
"and",
"return",
"pre",
"-",
"filled",
"Order"
] | python | train |
inveniosoftware-contrib/invenio-groups | invenio_groups/views.py | https://github.com/inveniosoftware-contrib/invenio-groups/blob/109481d6b02701db00b72223dd4a65e167c589a6/invenio_groups/views.py#L115-L126 | def invitations():
"""List all user pending memberships."""
page = request.args.get('page', 1, type=int)
per_page = request.args.get('per_page', 5, type=int)
memberships = Membership.query_invitations(current_user, eager=True).all()
return render_template(
'invenio_groups/pending.html',
... | [
"def",
"invitations",
"(",
")",
":",
"page",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'page'",
",",
"1",
",",
"type",
"=",
"int",
")",
"per_page",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'per_page'",
",",
"5",
",",
"type",
"=",
"int"... | List all user pending memberships. | [
"List",
"all",
"user",
"pending",
"memberships",
"."
] | python | valid |
pymupdf/PyMuPDF | fitz/utils.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1986-L2003 | def horizontal_angle(C, P):
"""Return the angle to the horizontal for the connection from C to P.
This uses the arcus sine function and resolves its inherent ambiguity by
looking up in which quadrant vector S = P - C is located.
"""
S = Point(P - C).unit # unit ... | [
"def",
"horizontal_angle",
"(",
"C",
",",
"P",
")",
":",
"S",
"=",
"Point",
"(",
"P",
"-",
"C",
")",
".",
"unit",
"# unit vector 'C' -> 'P'",
"alfa",
"=",
"math",
".",
"asin",
"(",
"abs",
"(",
"S",
".",
"y",
")",
")",
"# absolute angle from horizontal"... | Return the angle to the horizontal for the connection from C to P.
This uses the arcus sine function and resolves its inherent ambiguity by
looking up in which quadrant vector S = P - C is located. | [
"Return",
"the",
"angle",
"to",
"the",
"horizontal",
"for",
"the",
"connection",
"from",
"C",
"to",
"P",
".",
"This",
"uses",
"the",
"arcus",
"sine",
"function",
"and",
"resolves",
"its",
"inherent",
"ambiguity",
"by",
"looking",
"up",
"in",
"which",
"quad... | python | train |
blockstack/blockstack-core | blockstack/lib/rpc.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L220-L234 | def parse_qs(self, qs):
"""
Parse query string, but enforce one instance of each variable.
Return a dict with the variables on success
Return None on parse error
"""
qs_state = urllib2.urlparse.parse_qs(qs)
ret = {}
for qs_var, qs_value_list in qs_state.it... | [
"def",
"parse_qs",
"(",
"self",
",",
"qs",
")",
":",
"qs_state",
"=",
"urllib2",
".",
"urlparse",
".",
"parse_qs",
"(",
"qs",
")",
"ret",
"=",
"{",
"}",
"for",
"qs_var",
",",
"qs_value_list",
"in",
"qs_state",
".",
"items",
"(",
")",
":",
"if",
"le... | Parse query string, but enforce one instance of each variable.
Return a dict with the variables on success
Return None on parse error | [
"Parse",
"query",
"string",
"but",
"enforce",
"one",
"instance",
"of",
"each",
"variable",
".",
"Return",
"a",
"dict",
"with",
"the",
"variables",
"on",
"success",
"Return",
"None",
"on",
"parse",
"error"
] | python | train |
ktbyers/netmiko | netmiko/paloalto/paloalto_panos.py | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/paloalto/paloalto_panos.py#L164-L167 | def send_command(self, *args, **kwargs):
"""Palo Alto requires an extra delay"""
kwargs["delay_factor"] = kwargs.get("delay_factor", 2.5)
return super(PaloAltoPanosBase, self).send_command(*args, **kwargs) | [
"def",
"send_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"delay_factor\"",
"]",
"=",
"kwargs",
".",
"get",
"(",
"\"delay_factor\"",
",",
"2.5",
")",
"return",
"super",
"(",
"PaloAltoPanosBase",
",",
"self"... | Palo Alto requires an extra delay | [
"Palo",
"Alto",
"requires",
"an",
"extra",
"delay"
] | python | train |
JoaoFelipe/pyposast | pyposast/utils.py | https://github.com/JoaoFelipe/pyposast/blob/497c88c66b451ff2cd7354be1af070c92e119f41/pyposast/utils.py#L132-L140 | def find_next_character(code, position, char):
"""Find next char and return its first and last positions"""
end = LineCol(code, *position)
while not end.eof and end.char() in WHITESPACE:
end.inc()
if not end.eof and end.char() == char:
return end.tuple(), inc_tuple(end.tuple())
retu... | [
"def",
"find_next_character",
"(",
"code",
",",
"position",
",",
"char",
")",
":",
"end",
"=",
"LineCol",
"(",
"code",
",",
"*",
"position",
")",
"while",
"not",
"end",
".",
"eof",
"and",
"end",
".",
"char",
"(",
")",
"in",
"WHITESPACE",
":",
"end",
... | Find next char and return its first and last positions | [
"Find",
"next",
"char",
"and",
"return",
"its",
"first",
"and",
"last",
"positions"
] | python | train |
Music-Moo/music2storage | music2storage/helpers.py | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/helpers.py#L49-L62 | def delete_local_file(file_name):
"""
Deletes the file associated with the file_name passed from local storage.
:param str file_name: Filename of the file to be deleted
:return str: Filename of the file that was just deleted
"""
try:
os.remove(file_name)
log.info(f"Deletion... | [
"def",
"delete_local_file",
"(",
"file_name",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"file_name",
")",
"log",
".",
"info",
"(",
"f\"Deletion for {file_name} has finished\"",
")",
"return",
"file_name",
"except",
"OSError",
":",
"pass"
] | Deletes the file associated with the file_name passed from local storage.
:param str file_name: Filename of the file to be deleted
:return str: Filename of the file that was just deleted | [
"Deletes",
"the",
"file",
"associated",
"with",
"the",
"file_name",
"passed",
"from",
"local",
"storage",
".",
":",
"param",
"str",
"file_name",
":",
"Filename",
"of",
"the",
"file",
"to",
"be",
"deleted",
":",
"return",
"str",
":",
"Filename",
"of",
"the"... | python | test |
StackStorm/pybind | pybind/slxos/v17s_1_02/mpls_state/ldp/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/mpls_state/ldp/__init__.py#L114-L135 | def _set_ldp_out(self, v, load=False):
"""
Setter method for ldp_out, mapped from YANG variable /mpls_state/ldp/ldp_out (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_ldp_out is considered as a private
method. Backends looking to populate this variable s... | [
"def",
"_set_ldp_out",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",... | Setter method for ldp_out, mapped from YANG variable /mpls_state/ldp/ldp_out (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_ldp_out is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_ldp_out() ... | [
"Setter",
"method",
"for",
"ldp_out",
"mapped",
"from",
"YANG",
"variable",
"/",
"mpls_state",
"/",
"ldp",
"/",
"ldp_out",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source"... | python | train |
jdoda/sdl2hl | sdl2hl/renderer.py | https://github.com/jdoda/sdl2hl/blob/3b477e1e01cea5d8e15e9e5ef3a302ea460f5946/sdl2hl/renderer.py#L127-L133 | def render_target(self):
"""Texture: The current render target, or None if using the default render target."""
render_target = lib.SDL_GetRenderTarget(self._ptr)
if render_target == ffi.NULL:
return None
else:
return Texture._from_ptr(render_target) | [
"def",
"render_target",
"(",
"self",
")",
":",
"render_target",
"=",
"lib",
".",
"SDL_GetRenderTarget",
"(",
"self",
".",
"_ptr",
")",
"if",
"render_target",
"==",
"ffi",
".",
"NULL",
":",
"return",
"None",
"else",
":",
"return",
"Texture",
".",
"_from_ptr... | Texture: The current render target, or None if using the default render target. | [
"Texture",
":",
"The",
"current",
"render",
"target",
"or",
"None",
"if",
"using",
"the",
"default",
"render",
"target",
"."
] | python | train |
pinterest/thrift-tools | thrift_tools/thrift_message.py | https://github.com/pinterest/thrift-tools/blob/64e74aec89e2491c781fc62d1c45944dc15aba28/thrift_tools/thrift_message.py#L153-L165 | def detect_protocol(cls, data, default=None):
""" TODO: support fbthrift, finagle-thrift, finagle-mux, CORBA """
if cls.is_compact_protocol(data):
return TCompactProtocol
elif cls.is_binary_protocol(data):
return TBinaryProtocol
elif cls.is_json_protocol(data):
... | [
"def",
"detect_protocol",
"(",
"cls",
",",
"data",
",",
"default",
"=",
"None",
")",
":",
"if",
"cls",
".",
"is_compact_protocol",
"(",
"data",
")",
":",
"return",
"TCompactProtocol",
"elif",
"cls",
".",
"is_binary_protocol",
"(",
"data",
")",
":",
"return... | TODO: support fbthrift, finagle-thrift, finagle-mux, CORBA | [
"TODO",
":",
"support",
"fbthrift",
"finagle",
"-",
"thrift",
"finagle",
"-",
"mux",
"CORBA"
] | python | valid |
theSage21/lanchat | lanchat/chat.py | https://github.com/theSage21/lanchat/blob/66f5dcead67fef815347b956b1d3e149a7e13b29/lanchat/chat.py#L155-L159 | def __output_thread(self):
"Output thread"
while self.alive:
instructions = self.__get_instructions()
self.__process_instructions(instructions) | [
"def",
"__output_thread",
"(",
"self",
")",
":",
"while",
"self",
".",
"alive",
":",
"instructions",
"=",
"self",
".",
"__get_instructions",
"(",
")",
"self",
".",
"__process_instructions",
"(",
"instructions",
")"
] | Output thread | [
"Output",
"thread"
] | python | train |
saltstack/salt | salt/states/elasticsearch.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/elasticsearch.py#L404-L434 | def search_template_absent(name):
'''
Ensure that the search template is absent
name
Name of the search template to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
try:
template = __salt__['elasticsearch.search_template_get'](id=name)
if t... | [
"def",
"search_template_absent",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
"}",
"try",
":",
"template",
"=",
"__salt__",
"[",
"'elasticsear... | Ensure that the search template is absent
name
Name of the search template to remove | [
"Ensure",
"that",
"the",
"search",
"template",
"is",
"absent"
] | python | train |
cgtobi/PyRMVtransport | RMVtransport/rmvjourney.py | https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvjourney.py#L35-L40 | def _platform(self) -> Optional[str]:
"""Extract platform."""
try:
return str(self.journey.MainStop.BasicStop.Dep.Platform.text)
except AttributeError:
return None | [
"def",
"_platform",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"try",
":",
"return",
"str",
"(",
"self",
".",
"journey",
".",
"MainStop",
".",
"BasicStop",
".",
"Dep",
".",
"Platform",
".",
"text",
")",
"except",
"AttributeError",
":",
... | Extract platform. | [
"Extract",
"platform",
"."
] | python | train |
qubell/contrib-python-qubell-client | qubell/api/tools/__init__.py | https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L312-L325 | def get_manifest_from_meta(metaurl, name):
"""
Extact manifest url from metadata url
:param metaurl: Url to metadata
:param name: Name of application to extract
:return:
"""
if 'http' in metaurl:
kit = yaml.safe_load(requests.get(url=metaurl).content)['kit']['applications']
else:... | [
"def",
"get_manifest_from_meta",
"(",
"metaurl",
",",
"name",
")",
":",
"if",
"'http'",
"in",
"metaurl",
":",
"kit",
"=",
"yaml",
".",
"safe_load",
"(",
"requests",
".",
"get",
"(",
"url",
"=",
"metaurl",
")",
".",
"content",
")",
"[",
"'kit'",
"]",
... | Extact manifest url from metadata url
:param metaurl: Url to metadata
:param name: Name of application to extract
:return: | [
"Extact",
"manifest",
"url",
"from",
"metadata",
"url",
":",
"param",
"metaurl",
":",
"Url",
"to",
"metadata",
":",
"param",
"name",
":",
"Name",
"of",
"application",
"to",
"extract",
":",
"return",
":"
] | python | train |
inasafe/inasafe | safe/report/expressions/map_report.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/expressions/map_report.py#L92-L142 | def exposure_summary_layer():
"""Helper method for retrieving exposure summary layer.
If the analysis is multi-exposure, then it will return the exposure
summary layer from place exposure analysis.
"""
project_context_scope = QgsExpressionContextUtils.projectScope(
QgsProject.instance())
... | [
"def",
"exposure_summary_layer",
"(",
")",
":",
"project_context_scope",
"=",
"QgsExpressionContextUtils",
".",
"projectScope",
"(",
"QgsProject",
".",
"instance",
"(",
")",
")",
"project",
"=",
"QgsProject",
".",
"instance",
"(",
")",
"key",
"=",
"provenance_laye... | Helper method for retrieving exposure summary layer.
If the analysis is multi-exposure, then it will return the exposure
summary layer from place exposure analysis. | [
"Helper",
"method",
"for",
"retrieving",
"exposure",
"summary",
"layer",
"."
] | python | train |
Gandi/gandi.cli | gandi/cli/core/base.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/base.py#L126-L157 | def json_call(cls, method, url, **kwargs):
""" Call a remote api using json format """
# retrieve api key if needed
empty_key = kwargs.pop('empty_key', False)
send_key = kwargs.pop('send_key', True)
return_header = kwargs.pop('return_header', False)
try:
apike... | [
"def",
"json_call",
"(",
"cls",
",",
"method",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"# retrieve api key if needed",
"empty_key",
"=",
"kwargs",
".",
"pop",
"(",
"'empty_key'",
",",
"False",
")",
"send_key",
"=",
"kwargs",
".",
"pop",
"(",
"'sen... | Call a remote api using json format | [
"Call",
"a",
"remote",
"api",
"using",
"json",
"format"
] | python | train |
DeV1doR/aioethereum | aioethereum/management/eth.py | https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/eth.py#L289-L331 | def eth_call(self, from_, to=None, gas=None,
gas_price=None, value=None, data=None,
block=BLOCK_TAG_LATEST):
"""https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
:param from_: From account address
:type from_: str
:param to: To account address (o... | [
"def",
"eth_call",
"(",
"self",
",",
"from_",
",",
"to",
"=",
"None",
",",
"gas",
"=",
"None",
",",
"gas_price",
"=",
"None",
",",
"value",
"=",
"None",
",",
"data",
"=",
"None",
",",
"block",
"=",
"BLOCK_TAG_LATEST",
")",
":",
"block",
"=",
"valid... | https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
:param from_: From account address
:type from_: str
:param to: To account address (optional)
:type to: str
:param gas: Gas amount for current transaction (optional)
:type gas: int
:param gas_price: Gas pr... | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"ethereum",
"/",
"wiki",
"/",
"wiki",
"/",
"JSON",
"-",
"RPC#eth_call"
] | python | train |
steveYeah/PyBomb | pybomb/clients/games_client.py | https://github.com/steveYeah/PyBomb/blob/54045d74e642f8a1c4366c24bd6a330ae3da6257/pybomb/clients/games_client.py#L88-L118 | def quick_search(self, name, platform=None, sort_by=None, desc=True):
"""
Quick search method that allows you to search for a game using only the
title and the platform
:param name: string
:param platform: int
:param sort_by: string
:param desc: bool
:ret... | [
"def",
"quick_search",
"(",
"self",
",",
"name",
",",
"platform",
"=",
"None",
",",
"sort_by",
"=",
"None",
",",
"desc",
"=",
"True",
")",
":",
"if",
"platform",
"is",
"None",
":",
"query_filter",
"=",
"\"name:{0}\"",
".",
"format",
"(",
"name",
")",
... | Quick search method that allows you to search for a game using only the
title and the platform
:param name: string
:param platform: int
:param sort_by: string
:param desc: bool
:return: pybomb.clients.Response | [
"Quick",
"search",
"method",
"that",
"allows",
"you",
"to",
"search",
"for",
"a",
"game",
"using",
"only",
"the",
"title",
"and",
"the",
"platform"
] | python | train |
calmjs/calmjs | src/calmjs/toolchain.py | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/toolchain.py#L1100-L1106 | def _validate_build_target(self, spec, target):
"""
Essentially validate that the target is inside the build_dir.
"""
if not realpath(target).startswith(spec[BUILD_DIR]):
raise ValueError('build_target %s is outside build_dir' % target) | [
"def",
"_validate_build_target",
"(",
"self",
",",
"spec",
",",
"target",
")",
":",
"if",
"not",
"realpath",
"(",
"target",
")",
".",
"startswith",
"(",
"spec",
"[",
"BUILD_DIR",
"]",
")",
":",
"raise",
"ValueError",
"(",
"'build_target %s is outside build_dir... | Essentially validate that the target is inside the build_dir. | [
"Essentially",
"validate",
"that",
"the",
"target",
"is",
"inside",
"the",
"build_dir",
"."
] | python | train |
googleapis/google-auth-library-python-oauthlib | google_auth_oauthlib/flow.py | https://github.com/googleapis/google-auth-library-python-oauthlib/blob/ba826565994cf20c073d79f534036747fdef2041/google_auth_oauthlib/flow.py#L368-L422 | def run_local_server(
self, host='localhost', port=8080,
authorization_prompt_message=_DEFAULT_AUTH_PROMPT_MESSAGE,
success_message=_DEFAULT_WEB_SUCCESS_MESSAGE,
open_browser=True,
**kwargs):
"""Run the flow using the server strategy.
The serv... | [
"def",
"run_local_server",
"(",
"self",
",",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"8080",
",",
"authorization_prompt_message",
"=",
"_DEFAULT_AUTH_PROMPT_MESSAGE",
",",
"success_message",
"=",
"_DEFAULT_WEB_SUCCESS_MESSAGE",
",",
"open_browser",
"=",
"True",
... | Run the flow using the server strategy.
The server strategy instructs the user to open the authorization URL in
their browser and will attempt to automatically open the URL for them.
It will start a local web server to listen for the authorization
response. Once authorization is complet... | [
"Run",
"the",
"flow",
"using",
"the",
"server",
"strategy",
"."
] | python | train |
saltstack/salt | salt/modules/telemetry.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/telemetry.py#L346-L388 | def delete_alarms(deployment_id, alert_id=None, metric_name=None, api_key=None, profile='telemetry'):
'''delete an alert specified by alert_id or if not specified blows away all the alerts
in the current deployment.
Returns (bool success, str message) tuple.
CLI Example:
salt myminion te... | [
"def",
"delete_alarms",
"(",
"deployment_id",
",",
"alert_id",
"=",
"None",
",",
"metric_name",
"=",
"None",
",",
"api_key",
"=",
"None",
",",
"profile",
"=",
"'telemetry'",
")",
":",
"auth",
"=",
"_auth",
"(",
"profile",
"=",
"profile",
")",
"if",
"aler... | delete an alert specified by alert_id or if not specified blows away all the alerts
in the current deployment.
Returns (bool success, str message) tuple.
CLI Example:
salt myminion telemetry.delete_alarms rs-ds033197 profile=telemetry | [
"delete",
"an",
"alert",
"specified",
"by",
"alert_id",
"or",
"if",
"not",
"specified",
"blows",
"away",
"all",
"the",
"alerts",
"in",
"the",
"current",
"deployment",
"."
] | python | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1438-L1503 | def __field_to_subfields(self, field):
"""Fully describes data represented by field, including the nested case.
In the case that the field is not a message field, we have no fields nested
within a message definition, so we can simply return that field. However, in
the nested case, we can't simply descr... | [
"def",
"__field_to_subfields",
"(",
"self",
",",
"field",
")",
":",
"# Termination condition",
"if",
"not",
"isinstance",
"(",
"field",
",",
"messages",
".",
"MessageField",
")",
":",
"return",
"[",
"[",
"field",
"]",
"]",
"result",
"=",
"[",
"]",
"for",
... | Fully describes data represented by field, including the nested case.
In the case that the field is not a message field, we have no fields nested
within a message definition, so we can simply return that field. However, in
the nested case, we can't simply describe the data with one field or even
with o... | [
"Fully",
"describes",
"data",
"represented",
"by",
"field",
"including",
"the",
"nested",
"case",
"."
] | python | train |
saltstack/salt | salt/modules/mac_user.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_user.py#L408-L418 | def _format_info(data):
'''
Return user information in a pretty way
'''
return {'gid': data.pw_gid,
'groups': list_groups(data.pw_name),
'home': data.pw_dir,
'name': data.pw_name,
'shell': data.pw_shell,
'uid': data.pw_uid,
'fullnam... | [
"def",
"_format_info",
"(",
"data",
")",
":",
"return",
"{",
"'gid'",
":",
"data",
".",
"pw_gid",
",",
"'groups'",
":",
"list_groups",
"(",
"data",
".",
"pw_name",
")",
",",
"'home'",
":",
"data",
".",
"pw_dir",
",",
"'name'",
":",
"data",
".",
"pw_n... | Return user information in a pretty way | [
"Return",
"user",
"information",
"in",
"a",
"pretty",
"way"
] | python | train |
nameko/nameko | nameko/containers.py | https://github.com/nameko/nameko/blob/88d7e5211de4fcc1c34cd7f84d7c77f0619c5f5d/nameko/containers.py#L318-L350 | def spawn_worker(self, entrypoint, args, kwargs,
context_data=None, handle_result=None):
""" Spawn a worker thread for running the service method decorated
by `entrypoint`.
``args`` and ``kwargs`` are used as parameters for the service method.
``context_data`` is u... | [
"def",
"spawn_worker",
"(",
"self",
",",
"entrypoint",
",",
"args",
",",
"kwargs",
",",
"context_data",
"=",
"None",
",",
"handle_result",
"=",
"None",
")",
":",
"if",
"self",
".",
"_being_killed",
":",
"_log",
".",
"info",
"(",
"\"Worker spawn prevented due... | Spawn a worker thread for running the service method decorated
by `entrypoint`.
``args`` and ``kwargs`` are used as parameters for the service method.
``context_data`` is used to initialize a ``WorkerContext``.
``handle_result`` is an optional function which may be passed
in b... | [
"Spawn",
"a",
"worker",
"thread",
"for",
"running",
"the",
"service",
"method",
"decorated",
"by",
"entrypoint",
"."
] | python | train |
hotdoc/hotdoc | hotdoc/core/links.py | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/links.py#L150-L172 | def upsert_link(self, link, overwrite_ref=False):
"""
Banana banana
"""
elink = self.__links.get(link.id_)
if elink:
if elink.ref is None or overwrite_ref and link.ref:
elink.ref = link.ref
# pylint: disable=protected-access
if... | [
"def",
"upsert_link",
"(",
"self",
",",
"link",
",",
"overwrite_ref",
"=",
"False",
")",
":",
"elink",
"=",
"self",
".",
"__links",
".",
"get",
"(",
"link",
".",
"id_",
")",
"if",
"elink",
":",
"if",
"elink",
".",
"ref",
"is",
"None",
"or",
"overwr... | Banana banana | [
"Banana",
"banana"
] | python | train |
mitsei/dlkit | dlkit/json_/learning/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/sessions.py#L6284-L6304 | def get_child_objective_banks(self, objective_bank_id):
"""Gets the children of the given objective bank.
arg: objective_bank_id (osid.id.Id): the ``Id`` to query
return: (osid.learning.ObjectiveBankList) - the children of the
objective bank
raise: NotFound - ``objec... | [
"def",
"get_child_objective_banks",
"(",
"self",
",",
"objective_bank_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_child_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_se... | Gets the children of the given objective bank.
arg: objective_bank_id (osid.id.Id): the ``Id`` to query
return: (osid.learning.ObjectiveBankList) - the children of the
objective bank
raise: NotFound - ``objective_bank_id`` is not found
raise: NullArgument - ``object... | [
"Gets",
"the",
"children",
"of",
"the",
"given",
"objective",
"bank",
"."
] | python | train |
KoffeinFlummi/Chronyk | chronyk/chronyk.py | https://github.com/KoffeinFlummi/Chronyk/blob/5a9f3518d2e831884dea7e8c077d6e7350df2fbe/chronyk/chronyk.py#L13-L21 | def _isdst(dt):
"""Check if date is in dst.
"""
if type(dt) == datetime.date:
dt = datetime.datetime.combine(dt, datetime.datetime.min.time())
dtc = dt.replace(year=datetime.datetime.now().year)
if time.localtime(dtc.timestamp()).tm_isdst == 1:
return True
return False | [
"def",
"_isdst",
"(",
"dt",
")",
":",
"if",
"type",
"(",
"dt",
")",
"==",
"datetime",
".",
"date",
":",
"dt",
"=",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"dt",
",",
"datetime",
".",
"datetime",
".",
"min",
".",
"time",
"(",
")",
")",
... | Check if date is in dst. | [
"Check",
"if",
"date",
"is",
"in",
"dst",
"."
] | python | train |
fictorial/pygameui | pygameui/theme.py | https://github.com/fictorial/pygameui/blob/af6a35f347d6fafa66c4255bbbe38736d842ff65/pygameui/theme.py#L151-L157 | def get_dict(self, obj, state=None, base_name='View'):
"""The style dict for a view instance.
"""
return self.get_dict_for_class(class_name=obj.__class__,
state=obj.state,
base_name=base_name) | [
"def",
"get_dict",
"(",
"self",
",",
"obj",
",",
"state",
"=",
"None",
",",
"base_name",
"=",
"'View'",
")",
":",
"return",
"self",
".",
"get_dict_for_class",
"(",
"class_name",
"=",
"obj",
".",
"__class__",
",",
"state",
"=",
"obj",
".",
"state",
",",... | The style dict for a view instance. | [
"The",
"style",
"dict",
"for",
"a",
"view",
"instance",
"."
] | python | train |
pri22296/beautifultable | beautifultable/beautifultable.py | https://github.com/pri22296/beautifultable/blob/c9638f73dff4bb1f341c9ee783e4e47f26efba0b/beautifultable/beautifultable.py#L935-L961 | def update_column(self, header, column):
"""Update a column named `header` in the table.
If length of column is smaller than number of rows, lets say
`k`, only the first `k` values in the column is updated.
Parameters
----------
header : str
Header of the co... | [
"def",
"update_column",
"(",
"self",
",",
"header",
",",
"column",
")",
":",
"index",
"=",
"self",
".",
"get_column_index",
"(",
"header",
")",
"if",
"not",
"isinstance",
"(",
"header",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"\"header must... | Update a column named `header` in the table.
If length of column is smaller than number of rows, lets say
`k`, only the first `k` values in the column is updated.
Parameters
----------
header : str
Header of the column
column : iterable
Any iter... | [
"Update",
"a",
"column",
"named",
"header",
"in",
"the",
"table",
"."
] | python | train |
tensorflow/probability | tensorflow_probability/python/sts/internal/util.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/internal/util.py#L119-L161 | def factored_joint_mvn(distributions):
"""Combine MultivariateNormals into a factored joint distribution.
Given a list of multivariate normal distributions
`dist[i] = Normal(loc[i], scale[i])`, construct the joint
distribution given by concatenating independent samples from these
distributions. This is m... | [
"def",
"factored_joint_mvn",
"(",
"distributions",
")",
":",
"graph_parents",
"=",
"[",
"tensor",
"for",
"distribution",
"in",
"distributions",
"for",
"tensor",
"in",
"distribution",
".",
"_graph_parents",
"]",
"# pylint: disable=protected-access",
"with",
"tf",
".",
... | Combine MultivariateNormals into a factored joint distribution.
Given a list of multivariate normal distributions
`dist[i] = Normal(loc[i], scale[i])`, construct the joint
distribution given by concatenating independent samples from these
distributions. This is multivariate normal with mean vector given by... | [
"Combine",
"MultivariateNormals",
"into",
"a",
"factored",
"joint",
"distribution",
"."
] | python | test |
saltstack/salt | salt/utils/openstack/nova.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/openstack/nova.py#L1129-L1136 | def _network_show(self, name, network_lst):
'''
Parse the returned network list
'''
for net in network_lst:
if net.label == name:
return net.__dict__
return {} | [
"def",
"_network_show",
"(",
"self",
",",
"name",
",",
"network_lst",
")",
":",
"for",
"net",
"in",
"network_lst",
":",
"if",
"net",
".",
"label",
"==",
"name",
":",
"return",
"net",
".",
"__dict__",
"return",
"{",
"}"
] | Parse the returned network list | [
"Parse",
"the",
"returned",
"network",
"list"
] | python | train |
jasonlaska/spherecluster | spherecluster/von_mises_fisher_mixture.py | https://github.com/jasonlaska/spherecluster/blob/701b0b1909088a56e353b363b2672580d4fe9d93/spherecluster/von_mises_fisher_mixture.py#L500-L614 | def movMF(
X,
n_clusters,
posterior_type="soft",
force_weights=None,
n_init=10,
n_jobs=1,
max_iter=300,
verbose=False,
init="random-class",
random_state=None,
tol=1e-6,
copy_x=True,
):
"""Wrapper for parallelization of _movMF and running n_init times.
"""
if n... | [
"def",
"movMF",
"(",
"X",
",",
"n_clusters",
",",
"posterior_type",
"=",
"\"soft\"",
",",
"force_weights",
"=",
"None",
",",
"n_init",
"=",
"10",
",",
"n_jobs",
"=",
"1",
",",
"max_iter",
"=",
"300",
",",
"verbose",
"=",
"False",
",",
"init",
"=",
"\... | Wrapper for parallelization of _movMF and running n_init times. | [
"Wrapper",
"for",
"parallelization",
"of",
"_movMF",
"and",
"running",
"n_init",
"times",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.