Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
DependencyGraph.topological_sort | (self) |
Perform a topological sort of the graph.
:return: A tuple, the first element of which is a topologically sorted
list of distributions, and the second element of which is a
list of distributions that cannot be sorted because they have
circular dependenc... |
Perform a topological sort of the graph.
:return: A tuple, the first element of which is a topologically sorted
list of distributions, and the second element of which is a
list of distributions that cannot be sorted because they have
circular dependenc... | def topological_sort(self):
"""
Perform a topological sort of the graph.
:return: A tuple, the first element of which is a topologically sorted
list of distributions, and the second element of which is a
list of distributions that cannot be sorted because they h... | [
"def",
"topological_sort",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"# Make a shallow copy of the adjacency list",
"alist",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"adjacency_list",
".",
"items",
"(",
")",
":",
"alist",
"[",
"k",
"... | [
1185,
4
] | [
1214,
41
] | python | en | ['en', 'error', 'th'] | False |
DependencyGraph.__repr__ | (self) | Representation of the graph | Representation of the graph | def __repr__(self):
"""Representation of the graph"""
output = []
for dist, adjs in self.adjacency_list.items():
output.append(self.repr_node(dist))
return '\n'.join(output) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"output",
"=",
"[",
"]",
"for",
"dist",
",",
"adjs",
"in",
"self",
".",
"adjacency_list",
".",
"items",
"(",
")",
":",
"output",
".",
"append",
"(",
"self",
".",
"repr_node",
"(",
"dist",
")",
")",
"return"... | [
1216,
4
] | [
1221,
32
] | python | en | ['en', 'en', 'en'] | True |
heappush | (heap, item) | Push item onto heap, maintaining the heap invariant. | Push item onto heap, maintaining the heap invariant. | def heappush(heap, item):
"""Push item onto heap, maintaining the heap invariant."""
heap.append(item)
_siftdown(heap, 0, len(heap)-1) | [
"def",
"heappush",
"(",
"heap",
",",
"item",
")",
":",
"heap",
".",
"append",
"(",
"item",
")",
"_siftdown",
"(",
"heap",
",",
"0",
",",
"len",
"(",
"heap",
")",
"-",
"1",
")"
] | [
129,
0
] | [
132,
35
] | python | en | ['en', 'en', 'en'] | True |
heappop | (heap) | Pop the smallest item off the heap, maintaining the heap invariant. | Pop the smallest item off the heap, maintaining the heap invariant. | def heappop(heap):
"""Pop the smallest item off the heap, maintaining the heap invariant."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
return returnitem
return lastelt | [
"def",
"heappop",
"(",
"heap",
")",
":",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"# raises appropriate IndexError if heap is empty",
"if",
"heap",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"heap",
"[",
"0",
"]",
"=",
"lastelt",
"_siftup",
"(",
... | [
134,
0
] | [
142,
18
] | python | en | ['en', 'en', 'en'] | True |
heapreplace | (heap, item) | Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable uses of
this routine unless written... | Pop and return the current smallest value, and add the new item. | def heapreplace(heap, item):
"""Pop and return the current smallest value, and add the new item.
This is more efficient than heappop() followed by heappush(), and can be
more appropriate when using a fixed-size heap. Note that the value
returned may be larger than item! That constrains reasonable use... | [
"def",
"heapreplace",
"(",
"heap",
",",
"item",
")",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"# raises appropriate IndexError if heap is empty",
"heap",
"[",
"0",
"]",
"=",
"item",
"_siftup",
"(",
"heap",
",",
"0",
")",
"return",
"returnitem"
] | [
144,
0
] | [
158,
21
] | python | en | ['en', 'en', 'en'] | True |
heappushpop | (heap, item) | Fast version of a heappush followed by a heappop. | Fast version of a heappush followed by a heappop. | def heappushpop(heap, item):
"""Fast version of a heappush followed by a heappop."""
if heap and heap[0] < item:
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item | [
"def",
"heappushpop",
"(",
"heap",
",",
"item",
")",
":",
"if",
"heap",
"and",
"heap",
"[",
"0",
"]",
"<",
"item",
":",
"item",
",",
"heap",
"[",
"0",
"]",
"=",
"heap",
"[",
"0",
"]",
",",
"item",
"_siftup",
"(",
"heap",
",",
"0",
")",
"retur... | [
160,
0
] | [
165,
15
] | python | en | ['en', 'en', 'en'] | True |
heapify | (x) | Transform list into a heap, in-place, in O(len(x)) time. | Transform list into a heap, in-place, in O(len(x)) time. | def heapify(x):
"""Transform list into a heap, in-place, in O(len(x)) time."""
n = len(x)
# Transform bottom-up. The largest index there's any point to looking at
# is the largest with a child index in-range, so must have 2*i + 1 < n,
# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2... | [
"def",
"heapify",
"(",
"x",
")",
":",
"n",
"=",
"len",
"(",
"x",
")",
"# Transform bottom-up. The largest index there's any point to looking at",
"# is the largest with a child index in-range, so must have 2*i + 1 < n,",
"# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2 ... | [
167,
0
] | [
176,
21
] | python | en | ['it', 'en', 'en'] | True |
_heappop_max | (heap) | Maxheap version of a heappop. | Maxheap version of a heappop. | def _heappop_max(heap):
"""Maxheap version of a heappop."""
lastelt = heap.pop() # raises appropriate IndexError if heap is empty
if heap:
returnitem = heap[0]
heap[0] = lastelt
_siftup_max(heap, 0)
return returnitem
return lastelt | [
"def",
"_heappop_max",
"(",
"heap",
")",
":",
"lastelt",
"=",
"heap",
".",
"pop",
"(",
")",
"# raises appropriate IndexError if heap is empty",
"if",
"heap",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"heap",
"[",
"0",
"]",
"=",
"lastelt",
"_siftup_max",... | [
178,
0
] | [
186,
18
] | python | en | ['en', 'lb', 'en'] | True |
_heapreplace_max | (heap, item) | Maxheap version of a heappop followed by a heappush. | Maxheap version of a heappop followed by a heappush. | def _heapreplace_max(heap, item):
"""Maxheap version of a heappop followed by a heappush."""
returnitem = heap[0] # raises appropriate IndexError if heap is empty
heap[0] = item
_siftup_max(heap, 0)
return returnitem | [
"def",
"_heapreplace_max",
"(",
"heap",
",",
"item",
")",
":",
"returnitem",
"=",
"heap",
"[",
"0",
"]",
"# raises appropriate IndexError if heap is empty",
"heap",
"[",
"0",
"]",
"=",
"item",
"_siftup_max",
"(",
"heap",
",",
"0",
")",
"return",
"returnitem"
] | [
188,
0
] | [
193,
21
] | python | en | ['en', 'lb', 'en'] | True |
_heapify_max | (x) | Transform list into a maxheap, in-place, in O(len(x)) time. | Transform list into a maxheap, in-place, in O(len(x)) time. | def _heapify_max(x):
"""Transform list into a maxheap, in-place, in O(len(x)) time."""
n = len(x)
for i in reversed(range(n//2)):
_siftup_max(x, i) | [
"def",
"_heapify_max",
"(",
"x",
")",
":",
"n",
"=",
"len",
"(",
"x",
")",
"for",
"i",
"in",
"reversed",
"(",
"range",
"(",
"n",
"//",
"2",
")",
")",
":",
"_siftup_max",
"(",
"x",
",",
"i",
")"
] | [
195,
0
] | [
199,
25
] | python | en | ['it', 'en', 'en'] | True |
_siftdown_max | (heap, startpos, pos) | Maxheap variant of _siftdown | Maxheap variant of _siftdown | def _siftdown_max(heap, startpos, pos):
'Maxheap variant of _siftdown'
newitem = heap[pos]
# Follow the path to the root, moving parents down until finding a place
# newitem fits.
while pos > startpos:
parentpos = (pos - 1) >> 1
parent = heap[parentpos]
if parent < newitem:
... | [
"def",
"_siftdown_max",
"(",
"heap",
",",
"startpos",
",",
"pos",
")",
":",
"newitem",
"=",
"heap",
"[",
"pos",
"]",
"# Follow the path to the root, moving parents down until finding a place",
"# newitem fits.",
"while",
"pos",
">",
"startpos",
":",
"parentpos",
"=",
... | [
277,
0
] | [
290,
23
] | python | en | ['en', 'fil', 'en'] | True |
_siftup_max | (heap, pos) | Maxheap variant of _siftup | Maxheap variant of _siftup | def _siftup_max(heap, pos):
'Maxheap variant of _siftup'
endpos = len(heap)
startpos = pos
newitem = heap[pos]
# Bubble up the larger child until hitting a leaf.
childpos = 2*pos + 1 # leftmost child position
while childpos < endpos:
# Set childpos to index of larger child.
... | [
"def",
"_siftup_max",
"(",
"heap",
",",
"pos",
")",
":",
"endpos",
"=",
"len",
"(",
"heap",
")",
"startpos",
"=",
"pos",
"newitem",
"=",
"heap",
"[",
"pos",
"]",
"# Bubble up the larger child until hitting a leaf.",
"childpos",
"=",
"2",
"*",
"pos",
"+",
"... | [
292,
0
] | [
311,
38
] | python | en | ['en', 'en', 'en'] | True |
merge | (*iterables, key=None, reverse=False) | Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to largest).
>>> list(merge([1,3,5,7], [0,2,4,8], [5,... | Merge multiple sorted inputs into a single sorted output. | def merge(*iterables, key=None, reverse=False):
'''Merge multiple sorted inputs into a single sorted output.
Similar to sorted(itertools.chain(*iterables)) but returns a generator,
does not pull the data into memory all at once, and assumes that each of
the input streams is already sorted (smallest to ... | [
"def",
"merge",
"(",
"*",
"iterables",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"h",
"=",
"[",
"]",
"h_append",
"=",
"h",
".",
"append",
"if",
"reverse",
":",
"_heapify",
"=",
"_heapify_max",
"_heappop",
"=",
"_heappop_max",
"... | [
313,
0
] | [
391,
32
] | python | en | ['en', 'en', 'en'] | True |
nsmallest | (n, iterable, key=None) | Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n]
| Find the n smallest elements in a dataset. | def nsmallest(n, iterable, key=None):
"""Find the n smallest elements in a dataset.
Equivalent to: sorted(iterable, key=key)[:n]
"""
# Short-cut for n==1 is to use min()
if n == 1:
it = iter(iterable)
sentinel = object()
if key is None:
result = min(it, default... | [
"def",
"nsmallest",
"(",
"n",
",",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# Short-cut for n==1 is to use min()",
"if",
"n",
"==",
"1",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"sentinel",
"=",
"object",
"(",
")",
"if",
"key",
"is",
"None"... | [
460,
0
] | [
521,
33
] | python | en | ['en', 'en', 'en'] | True |
nlargest | (n, iterable, key=None) | Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
| Find the n largest elements in a dataset. | def nlargest(n, iterable, key=None):
"""Find the n largest elements in a dataset.
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
"""
# Short-cut for n==1 is to use max()
if n == 1:
it = iter(iterable)
sentinel = object()
if key is None:
result = max... | [
"def",
"nlargest",
"(",
"n",
",",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# Short-cut for n==1 is to use max()",
"if",
"n",
"==",
"1",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"sentinel",
"=",
"object",
"(",
")",
"if",
"key",
"is",
"None",... | [
523,
0
] | [
582,
33
] | python | en | ['en', 'en', 'en'] | True |
send_event | (
realm: Realm, event: Mapping[str, Any], users: Union[Iterable[int], Iterable[Mapping[str, Any]]]
) | `users` is a list of user IDs, or in the case of `message` type
events, a list of dicts describing the users and metadata about
the user/message pair. | `users` is a list of user IDs, or in the case of `message` type
events, a list of dicts describing the users and metadata about
the user/message pair. | def send_event(
realm: Realm, event: Mapping[str, Any], users: Union[Iterable[int], Iterable[Mapping[str, Any]]]
) -> None:
"""`users` is a list of user IDs, or in the case of `message` type
events, a list of dicts describing the users and metadata about
the user/message pair."""
port = get_tornado_... | [
"def",
"send_event",
"(",
"realm",
":",
"Realm",
",",
"event",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
",",
"users",
":",
"Union",
"[",
"Iterable",
"[",
"int",
"]",
",",
"Iterable",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"]",
")",... | [
146,
0
] | [
157,
5
] | python | en | ['en', 'en', 'en'] | True |
ProfilerMiddleware.clear_profiling_cookies | (request, response) | Expire any cookie that initiated profiling request. | Expire any cookie that initiated profiling request. | def clear_profiling_cookies(request, response):
"""Expire any cookie that initiated profiling request."""
if 'profile_page' in request.COOKIES:
path = request.path
response.set_cookie('profile_page', max_age=0, path=path) | [
"def",
"clear_profiling_cookies",
"(",
"request",
",",
"response",
")",
":",
"if",
"'profile_page'",
"in",
"request",
".",
"COOKIES",
":",
"path",
"=",
"request",
".",
"path",
"response",
".",
"set_cookie",
"(",
"'profile_page'",
",",
"max_age",
"=",
"0",
",... | [
141,
4
] | [
145,
69
] | python | en | ['en', 'en', 'en'] | True |
do_widget_post_save_actions | (send_request: SendMessageRequest) |
This code works with the web app; mobile and other
clients should also start supporting this soon.
|
This code works with the web app; mobile and other
clients should also start supporting this soon.
| def do_widget_post_save_actions(send_request: SendMessageRequest) -> None:
"""
This code works with the web app; mobile and other
clients should also start supporting this soon.
"""
message_content = send_request.message.content
sender_id = send_request.message.sender_id
message_id = send_re... | [
"def",
"do_widget_post_save_actions",
"(",
"send_request",
":",
"SendMessageRequest",
")",
"->",
"None",
":",
"message_content",
"=",
"send_request",
".",
"message",
".",
"content",
"sender_id",
"=",
"send_request",
".",
"message",
".",
"sender_id",
"message_id",
"=... | [
46,
0
] | [
78,
75
] | python | en | ['en', 'error', 'th'] | False |
unpack | (src_dir, dst_dir) | Move everything under `src_dir` to `dst_dir`, and delete the former. | Move everything under `src_dir` to `dst_dir`, and delete the former. | def unpack(src_dir, dst_dir):
'''Move everything under `src_dir` to `dst_dir`, and delete the former.'''
for dirpath, dirnames, filenames in os.walk(src_dir):
subdir = os.path.relpath(dirpath, src_dir)
for f in filenames:
src = os.path.join(dirpath, f)
dst = os.path.join(... | [
"def",
"unpack",
"(",
"src_dir",
",",
"dst_dir",
")",
":",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"src_dir",
")",
":",
"subdir",
"=",
"os",
".",
"path",
".",
"relpath",
"(",
"dirpath",
",",
"src_dir",
")",
... | [
29,
0
] | [
48,
25
] | python | en | ['en', 'en', 'en'] | True |
Wheel.tags | (self) | List tags (py_version, abi, platform) supported by this wheel. | List tags (py_version, abi, platform) supported by this wheel. | def tags(self):
'''List tags (py_version, abi, platform) supported by this wheel.'''
return itertools.product(
self.py_version.split('.'),
self.abi.split('.'),
self.platform.split('.'),
) | [
"def",
"tags",
"(",
"self",
")",
":",
"return",
"itertools",
".",
"product",
"(",
"self",
".",
"py_version",
".",
"split",
"(",
"'.'",
")",
",",
"self",
".",
"abi",
".",
"split",
"(",
"'.'",
")",
",",
"self",
".",
"platform",
".",
"split",
"(",
"... | [
61,
4
] | [
67,
9
] | python | en | ['en', 'en', 'en'] | True |
Wheel.is_compatible | (self) | Is the wheel is compatible with the current platform? | Is the wheel is compatible with the current platform? | def is_compatible(self):
'''Is the wheel is compatible with the current platform?'''
supported_tags = set(
(t.interpreter, t.abi, t.platform) for t in sys_tags())
return next((True for t in self.tags() if t in supported_tags), False) | [
"def",
"is_compatible",
"(",
"self",
")",
":",
"supported_tags",
"=",
"set",
"(",
"(",
"t",
".",
"interpreter",
",",
"t",
".",
"abi",
",",
"t",
".",
"platform",
")",
"for",
"t",
"in",
"sys_tags",
"(",
")",
")",
"return",
"next",
"(",
"(",
"True",
... | [
69,
4
] | [
73,
78
] | python | en | ['en', 'en', 'en'] | True |
Wheel.install_as_egg | (self, destination_eggdir) | Install wheel as an egg directory. | Install wheel as an egg directory. | def install_as_egg(self, destination_eggdir):
'''Install wheel as an egg directory.'''
with zipfile.ZipFile(self.filename) as zf:
self._install_as_egg(destination_eggdir, zf) | [
"def",
"install_as_egg",
"(",
"self",
",",
"destination_eggdir",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"self",
".",
"filename",
")",
"as",
"zf",
":",
"self",
".",
"_install_as_egg",
"(",
"destination_eggdir",
",",
"zf",
")"
] | [
91,
4
] | [
94,
56
] | python | en | ['en', 'en', 'en'] | True |
Wheel._move_data_entries | (destination_eggdir, dist_data) | Move data entries to their correct location. | Move data entries to their correct location. | def _move_data_entries(destination_eggdir, dist_data):
"""Move data entries to their correct location."""
dist_data = os.path.join(destination_eggdir, dist_data)
dist_data_scripts = os.path.join(dist_data, 'scripts')
if os.path.exists(dist_data_scripts):
egg_info_scripts = os... | [
"def",
"_move_data_entries",
"(",
"destination_eggdir",
",",
"dist_data",
")",
":",
"dist_data",
"=",
"os",
".",
"path",
".",
"join",
"(",
"destination_eggdir",
",",
"dist_data",
")",
"dist_data_scripts",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dist_data",
... | [
171,
4
] | [
196,
31
] | python | en | ['en', 'en', 'en'] | True |
accuracy | (output, target, topk=(1,)) | Computes the accuracy over the k top predictions for the specified values of k | Computes the accuracy over the k top predictions for the specified values of k | def accuracy(output, target, topk=(1,)):
"""Computes the accuracy over the k top predictions for the specified values of k"""
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(t... | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"with",
"torch",
".",
"no_grad",
"(",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"_",... | [
37,
0
] | [
51,
18
] | python | en | ['en', 'en', 'en'] | True |
seed_everything | (seed=12) |
seed randoms for all libraries
|
seed randoms for all libraries
| def seed_everything(seed=12):
'''
seed randoms for all libraries
'''
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic ... | [
"def",
"seed_everything",
"(",
"seed",
"=",
"12",
")",
":",
"random",
".",
"seed",
"(",
"seed",
")",
"np",
".",
"random",
".",
"seed",
"(",
"seed",
")",
"torch",
".",
"manual_seed",
"(",
"seed",
")",
"torch",
".",
"cuda",
".",
"manual_seed_all",
"(",... | [
30,
0
] | [
40,
45
] | python | en | ['en', 'error', 'th'] | False |
train | (args, period, net, net_old, train_loader, loss_criterion, loss_activation, optimizer, class_old, class_novel, finetune) |
arguments: period, net, net_old, train_loader, loss_activation, optimizer, clss_old, clasS_novel, finetune
returns: tcost, loss_avg, acc_avg
|
arguments: period, net, net_old, train_loader, loss_activation, optimizer, clss_old, clasS_novel, finetune
returns: tcost, loss_avg, acc_avg
| def train (args, period, net, net_old, train_loader, loss_criterion, loss_activation, optimizer, class_old, class_novel, finetune):
'''
arguments: period, net, net_old, train_loader, loss_activation, optimizer, clss_old, clasS_novel, finetune
returns: tcost, loss_avg, acc_avg
'''
acc_avg = 0
nu... | [
"def",
"train",
"(",
"args",
",",
"period",
",",
"net",
",",
"net_old",
",",
"train_loader",
",",
"loss_criterion",
",",
"loss_activation",
",",
"optimizer",
",",
"class_old",
",",
"class_novel",
",",
"finetune",
")",
":",
"acc_avg",
"=",
"0",
"num_exp",
"... | [
43,
0
] | [
144,
36
] | python | en | ['en', 'error', 'th'] | False |
test | (args, net, test_loader, loss_activation, class_old, class_novel) |
arguments: net, test_loader, loss_activation, class_old, class_novel
return: tcost, acc_avg
|
arguments: net, test_loader, loss_activation, class_old, class_novel
return: tcost, acc_avg
| def test(args, net, test_loader, loss_activation, class_old, class_novel):
'''
arguments: net, test_loader, loss_activation, class_old, class_novel
return: tcost, acc_avg
'''
acc_avg = 0
num_exp = 0
tstart = time.clock()
# set net to eval
net.eval()
net_old.eval()
with tor... | [
"def",
"test",
"(",
"args",
",",
"net",
",",
"test_loader",
",",
"loss_activation",
",",
"class_old",
",",
"class_novel",
")",
":",
"acc_avg",
"=",
"0",
"num_exp",
"=",
"0",
"tstart",
"=",
"time",
".",
"clock",
"(",
")",
"# set net to eval",
"net",
".",
... | [
147,
0
] | [
201,
26
] | python | en | ['en', 'error', 'th'] | False |
get_major_minor_version | () |
Return the major-minor version of the current Python as a string, e.g.
"3.7" or "3.10".
|
Return the major-minor version of the current Python as a string, e.g.
"3.7" or "3.10".
| def get_major_minor_version():
# type: () -> str
"""
Return the major-minor version of the current Python as a string, e.g.
"3.7" or "3.10".
"""
return '{}.{}'.format(*sys.version_info) | [
"def",
"get_major_minor_version",
"(",
")",
":",
"# type: () -> str",
"return",
"'{}.{}'",
".",
"format",
"(",
"*",
"sys",
".",
"version_info",
")"
] | [
33,
0
] | [
39,
44
] | python | en | ['en', 'error', 'th'] | False |
distutils_scheme | (
dist_name, user=False, home=None, root=None, isolated=False, prefix=None
) |
Return a distutils install scheme
|
Return a distutils install scheme
| def distutils_scheme(
dist_name, user=False, home=None, root=None, isolated=False, prefix=None
):
# type:(str, bool, str, str, bool, str) -> Dict[str, str]
"""
Return a distutils install scheme
"""
from distutils.dist import Distribution
dist_args = {'name': dist_name} # type: Dict[str, Un... | [
"def",
"distutils_scheme",
"(",
"dist_name",
",",
"user",
"=",
"False",
",",
"home",
"=",
"None",
",",
"root",
"=",
"None",
",",
"isolated",
"=",
"False",
",",
"prefix",
"=",
"None",
")",
":",
"# type:(str, bool, str, str, bool, str) -> Dict[str, str]",
"from",
... | [
94,
0
] | [
155,
17
] | python | en | ['en', 'error', 'th'] | False |
get_scheme | (
dist_name, # type: str
user=False, # type: bool
home=None, # type: Optional[str]
root=None, # type: Optional[str]
isolated=False, # type: bool
prefix=None, # type: Optional[str]
) |
Get the "scheme" corresponding to the input parameters. The distutils
documentation provides the context for the available schemes:
https://docs.python.org/3/install/index.html#alternate-installation
:param dist_name: the name of the package to retrieve the scheme for, used
in the headers sche... |
Get the "scheme" corresponding to the input parameters. The distutils
documentation provides the context for the available schemes:
https://docs.python.org/3/install/index.html#alternate-installation | def get_scheme(
dist_name, # type: str
user=False, # type: bool
home=None, # type: Optional[str]
root=None, # type: Optional[str]
isolated=False, # type: bool
prefix=None, # type: Optional[str]
):
# type: (...) -> Scheme
"""
Get the "scheme" corresponding to the input parameter... | [
"def",
"get_scheme",
"(",
"dist_name",
",",
"# type: str",
"user",
"=",
"False",
",",
"# type: bool",
"home",
"=",
"None",
",",
"# type: Optional[str]",
"root",
"=",
"None",
",",
"# type: Optional[str]",
"isolated",
"=",
"False",
",",
"# type: bool",
"prefix",
"... | [
158,
0
] | [
193,
5
] | python | en | ['en', 'error', 'th'] | False |
CustomSocialAccountAdapter.authentication_error | (self, *args, **kwargs) | Make sure that auth errors get logged | Make sure that auth errors get logged | def authentication_error(self, *args, **kwargs):
"""Make sure that auth errors get logged"""
logger.error(f"Social Account authentication error: {args}, {kwargs}")
return super().authentication_error(*args, **kwargs) | [
"def",
"authentication_error",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"error",
"(",
"f\"Social Account authentication error: {args}, {kwargs}\"",
")",
"return",
"super",
"(",
")",
".",
"authentication_error",
"(",
"*",
"... | [
8,
4
] | [
11,
60
] | python | en | ['en', 'en', 'en'] | True |
build_wheel_pep517 | (
name, # type: str
backend, # type: Pep517HookCaller
metadata_directory, # type: str
build_options, # type: List[str]
tempd, # type: str
) | Build one InstallRequirement using the PEP 517 build process.
Returns path to wheel if successfully built. Otherwise, returns None.
| Build one InstallRequirement using the PEP 517 build process. | def build_wheel_pep517(
name, # type: str
backend, # type: Pep517HookCaller
metadata_directory, # type: str
build_options, # type: List[str]
tempd, # type: str
):
# type: (...) -> Optional[str]
"""Build one InstallRequirement using the PEP 517 build process.
Returns path to wheel i... | [
"def",
"build_wheel_pep517",
"(",
"name",
",",
"# type: str",
"backend",
",",
"# type: Pep517HookCaller",
"metadata_directory",
",",
"# type: str",
"build_options",
",",
"# type: List[str]",
"tempd",
",",
"# type: str",
")",
":",
"# type: (...) -> Optional[str]",
"assert",
... | [
13,
0
] | [
45,
42
] | python | en | ['en', 'en', 'en'] | True |
LoggingMiddleware.process_response | (self, request, response) |
Inlined and modified from log_request_id.middleware.
Modified to add more elements to the message, while the request is available.
|
Inlined and modified from log_request_id.middleware. | def process_response(self, request, response):
"""
Inlined and modified from log_request_id.middleware.
Modified to add more elements to the message, while the request is available.
"""
if getattr(settings, REQUEST_ID_RESPONSE_HEADER_SETTING, False) and getattr(
requ... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"getattr",
"(",
"settings",
",",
"REQUEST_ID_RESPONSE_HEADER_SETTING",
",",
"False",
")",
"and",
"getattr",
"(",
"request",
",",
"\"id\"",
",",
"None",
")",
":",
"respon... | [
22,
4
] | [
70,
23
] | python | en | ['en', 'error', 'th'] | False |
Hipaa.setUp | (self) | Setting up test. | Setting up test. | def setUp(self):
"""Setting up test."""
self.server_url = self.conf_get('main', 'url')
self.lipsum = Lipsum() | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"server_url",
"=",
"self",
".",
"conf_get",
"(",
"'main'",
",",
"'url'",
")",
"self",
".",
"lipsum",
"=",
"Lipsum",
"(",
")"
] | [
15,
4
] | [
18,
30
] | python | en | ['en', 'en', 'en'] | True |
Hipaa.test_login | (self) |
self.login_as("admin", "admin")
self.logout()
|
self.login_as("admin", "admin")
self.logout()
| def test_login(self):
page="/index"
self.login_as("admin", "admin")
reply = self.get(self.server_url + page, description="Get index")
self.logout()
"""
self.login_as("admin", "admin")
self.logout()
""" | [
"def",
"test_login",
"(",
"self",
")",
":",
"page",
"=",
"\"/index\"",
"self",
".",
"login_as",
"(",
"\"admin\"",
",",
"\"admin\"",
")",
"reply",
"=",
"self",
".",
"get",
"(",
"self",
".",
"server_url",
"+",
"page",
",",
"description",
"=",
"\"Get index\... | [
50,
4
] | [
59,
11
] | python | en | ['en', 'error', 'th'] | False |
AdminNotifyHandlerTest.test_basic | (self, mock_function: MagicMock) | A random exception passes happily through AdminNotifyHandler | A random exception passes happily through AdminNotifyHandler | def test_basic(self, mock_function: MagicMock) -> None:
mock_function.return_value = None
"""A random exception passes happily through AdminNotifyHandler"""
handler = self.get_admin_zulip_handler()
try:
raise Exception("Testing error!")
except Exception:
e... | [
"def",
"test_basic",
"(",
"self",
",",
"mock_function",
":",
"MagicMock",
")",
"->",
"None",
":",
"mock_function",
".",
"return_value",
"=",
"None",
"handler",
"=",
"self",
".",
"get_admin_zulip_handler",
"(",
")",
"try",
":",
"raise",
"Exception",
"(",
"\"T... | [
64,
4
] | [
75,
28
] | python | en | ['en', 'en', 'en'] | True |
AdminNotifyHandlerTest.test_long_exception_request | (self, mock_function: MagicMock) | A request with no stack and multi-line report.getMessage() is handled properly | A request with no stack and multi-line report.getMessage() is handled properly | def test_long_exception_request(self, mock_function: MagicMock) -> None:
mock_function.return_value = None
"""A request with no stack and multi-line report.getMessage() is handled properly"""
record = self.simulate_error()
record.exc_info = None
record.msg = "message\nmoremesssag... | [
"def",
"test_long_exception_request",
"(",
"self",
",",
"mock_function",
":",
"MagicMock",
")",
"->",
"None",
":",
"mock_function",
".",
"return_value",
"=",
"None",
"record",
"=",
"self",
".",
"simulate_error",
"(",
")",
"record",
".",
"exc_info",
"=",
"None"... | [
116,
4
] | [
130,
54
] | python | en | ['en', 'en', 'en'] | True |
AdminNotifyHandlerTest.test_request | (self, mock_function: MagicMock) | A normal request is handled properly | A normal request is handled properly | def test_request(self, mock_function: MagicMock) -> None:
mock_function.return_value = None
"""A normal request is handled properly"""
record = self.simulate_error()
assert isinstance(record, HasRequest)
report = self.run_handler(record)
self.assertIn("user", report)
... | [
"def",
"test_request",
"(",
"self",
",",
"mock_function",
":",
"MagicMock",
")",
"->",
"None",
":",
"mock_function",
".",
"return_value",
"=",
"None",
"record",
"=",
"self",
".",
"simulate_error",
"(",
")",
"assert",
"isinstance",
"(",
"record",
",",
"HasReq... | [
133,
4
] | [
237,
44
] | python | en | ['en', 'en', 'en'] | True |
default_filter | (src, dst) | The default progress/filter callback; returns True for all files | The default progress/filter callback; returns True for all files | def default_filter(src, dst):
"""The default progress/filter callback; returns True for all files"""
return dst | [
"def",
"default_filter",
"(",
"src",
",",
"dst",
")",
":",
"return",
"dst"
] | [
22,
0
] | [
24,
14
] | python | en | ['en', 'sv', 'en'] | True |
unpack_archive | (
filename, extract_dir, progress_filter=default_filter,
drivers=None) | Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``
`progress_filter` is a function taking two arguments: a source path
internal to the archive ('/'-separated), and a filesystem path where it
will be extracted. The callback must return the desired extract path
(which may be the same as... | Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` | def unpack_archive(
filename, extract_dir, progress_filter=default_filter,
drivers=None):
"""Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``
`progress_filter` is a function taking two arguments: a source path
internal to the archive ('/'-separated), and a filesystem path... | [
"def",
"unpack_archive",
"(",
"filename",
",",
"extract_dir",
",",
"progress_filter",
"=",
"default_filter",
",",
"drivers",
"=",
"None",
")",
":",
"for",
"driver",
"in",
"drivers",
"or",
"extraction_drivers",
":",
"try",
":",
"driver",
"(",
"filename",
",",
... | [
27,
0
] | [
60,
9
] | python | en | ['en', 'la', 'en'] | True |
unpack_directory | (filename, extract_dir, progress_filter=default_filter) | Unpack" a directory, using the same interface as for archives
Raises ``UnrecognizedFormat`` if `filename` is not a directory
| Unpack" a directory, using the same interface as for archives | def unpack_directory(filename, extract_dir, progress_filter=default_filter):
""""Unpack" a directory, using the same interface as for archives
Raises ``UnrecognizedFormat`` if `filename` is not a directory
"""
if not os.path.isdir(filename):
raise UnrecognizedFormat("%s is not a directory" % fi... | [
"def",
"unpack_directory",
"(",
"filename",
",",
"extract_dir",
",",
"progress_filter",
"=",
"default_filter",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"filename",
")",
":",
"raise",
"UnrecognizedFormat",
"(",
"\"%s is not a directory\"",
"%"... | [
63,
0
] | [
87,
38
] | python | en | ['en', 'en', 'en'] | True |
unpack_zipfile | (filename, extract_dir, progress_filter=default_filter) | Unpack zip `filename` to `extract_dir`
Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation
of the `progress_filter` argument.
| Unpack zip `filename` to `extract_dir` | def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
"""Unpack zip `filename` to `extract_dir`
Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined
by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation
of the `progress_filter` argument.
... | [
"def",
"unpack_zipfile",
"(",
"filename",
",",
"extract_dir",
",",
"progress_filter",
"=",
"default_filter",
")",
":",
"if",
"not",
"zipfile",
".",
"is_zipfile",
"(",
"filename",
")",
":",
"raise",
"UnrecognizedFormat",
"(",
"\"%s is not a zip file\"",
"%",
"(",
... | [
90,
0
] | [
124,
49
] | python | en | ['en', 'nl', 'ur'] | False |
unpack_tarfile | (filename, extract_dir, progress_filter=default_filter) | Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
by ``tarfile.open()``). See ``unpack_archive()`` for an explanation
of the `progress_filter` argument.
| Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` | def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
by ``tarfile.open()``). See ``unpack_archive()`` for an explanation
of the `progress_filter` a... | [
"def",
"unpack_tarfile",
"(",
"filename",
",",
"extract_dir",
",",
"progress_filter",
"=",
"default_filter",
")",
":",
"try",
":",
"tarobj",
"=",
"tarfile",
".",
"open",
"(",
"filename",
")",
"except",
"tarfile",
".",
"TarError",
"as",
"e",
":",
"raise",
"... | [
127,
0
] | [
171,
19
] | python | en | ['en', 'id', 'hi'] | False |
DetailView.get_context_data | (self, **kwargs) | Gets the context data for keypair. | Gets the context data for keypair. | def get_context_data(self, **kwargs):
"""Gets the context data for keypair."""
context = super(DetailView, self).get_context_data(**kwargs)
context['keypair'] = self._get_data()
return context | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"DetailView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"context",
"[",
"'keypair'",
"]",
"=",
"self",
".",
"_get_da... | [
81,
4
] | [
85,
22
] | python | en | ['en', 'en', 'en'] | True |
Text.escape | (self) |
Encode (escape) special XML characters.
@return: The text with XML special characters escaped.
@rtype: L{Text}
|
Encode (escape) special XML characters.
| def escape(self):
"""
Encode (escape) special XML characters.
@return: The text with XML special characters escaped.
@rtype: L{Text}
"""
if not self.escaped:
post = sax.encoder.encode(self)
escaped = ( post != self )
return Text(post, l... | [
"def",
"escape",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"escaped",
":",
"post",
"=",
"sax",
".",
"encoder",
".",
"encode",
"(",
"self",
")",
"escaped",
"=",
"(",
"post",
"!=",
"self",
")",
"return",
"Text",
"(",
"post",
",",
"lang",
"="... | [
49,
4
] | [
59,
19
] | python | en | ['en', 'error', 'th'] | False |
Text.unescape | (self) |
Decode (unescape) special XML characters.
@return: The text with escaped XML special characters decoded.
@rtype: L{Text}
|
Decode (unescape) special XML characters.
| def unescape(self):
"""
Decode (unescape) special XML characters.
@return: The text with escaped XML special characters decoded.
@rtype: L{Text}
"""
if self.escaped:
post = sax.encoder.decode(self)
return Text(post, lang=self.lang)
return s... | [
"def",
"unescape",
"(",
"self",
")",
":",
"if",
"self",
".",
"escaped",
":",
"post",
"=",
"sax",
".",
"encoder",
".",
"decode",
"(",
"self",
")",
"return",
"Text",
"(",
"post",
",",
"lang",
"=",
"self",
".",
"lang",
")",
"return",
"self"
] | [
61,
4
] | [
70,
19
] | python | en | ['en', 'error', 'th'] | False |
main | () | Left here for legacy reasons. Use the run_algorithm script from the root folder instead. | Left here for legacy reasons. Use the run_algorithm script from the root folder instead. | def main():
"""Left here for legacy reasons. Use the run_algorithm script from the root folder instead."""
from run_algorithm import main as run_algorithm_main
return run_algorithm_main() | [
"def",
"main",
"(",
")",
":",
"from",
"run_algorithm",
"import",
"main",
"as",
"run_algorithm_main",
"return",
"run_algorithm_main",
"(",
")"
] | [
3,
0
] | [
6,
31
] | python | en | ['en', 'en', 'en'] | True |
safe_name | (name) | Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
| Convert an arbitrary string to a standard distribution name | def safe_name(name):
"""Convert an arbitrary string to a standard distribution name
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
"""
return re.sub('[^A-Za-z0-9.]+', '-', name) | [
"def",
"safe_name",
"(",
"name",
")",
":",
"return",
"re",
".",
"sub",
"(",
"'[^A-Za-z0-9.]+'",
",",
"'-'",
",",
"name",
")"
] | [
53,
0
] | [
58,
46
] | python | en | ['en', 'en', 'en'] | True |
safe_version | (version) | Convert an arbitrary string to a standard version string
Spaces become dots, and all other non-alphanumeric characters become
dashes, with runs of multiple dashes condensed to a single dash.
| Convert an arbitrary string to a standard version string | def safe_version(version):
"""Convert an arbitrary string to a standard version string
Spaces become dots, and all other non-alphanumeric characters become
dashes, with runs of multiple dashes condensed to a single dash.
"""
version = version.replace(' ','.')
return re.sub('[^A-Za-z0-9.]+', '-'... | [
"def",
"safe_version",
"(",
"version",
")",
":",
"version",
"=",
"version",
".",
"replace",
"(",
"' '",
",",
"'.'",
")",
"return",
"re",
".",
"sub",
"(",
"'[^A-Za-z0-9.]+'",
",",
"'-'",
",",
"version",
")"
] | [
61,
0
] | [
68,
49
] | python | en | ['en', 'en', 'en'] | True |
to_filename | (name) | Convert a project or version name to its filename-escaped form
Any '-' characters are currently replaced with '_'.
| Convert a project or version name to its filename-escaped form | def to_filename(name):
"""Convert a project or version name to its filename-escaped form
Any '-' characters are currently replaced with '_'.
"""
return name.replace('-','_') | [
"def",
"to_filename",
"(",
"name",
")",
":",
"return",
"name",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")"
] | [
71,
0
] | [
76,
32
] | python | en | ['en', 'en', 'en'] | True |
lt | (a, b) | Same as a < b. | Same as a < b. | def lt(a, b):
"Same as a < b."
return a < b | [
"def",
"lt",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"<",
"b"
] | [
26,
0
] | [
28,
16
] | python | en | ['en', 'gd', 'en'] | True |
le | (a, b) | Same as a <= b. | Same as a <= b. | def le(a, b):
"Same as a <= b."
return a <= b | [
"def",
"le",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"<=",
"b"
] | [
30,
0
] | [
32,
17
] | python | en | ['en', 'gd', 'en'] | True |
eq | (a, b) | Same as a == b. | Same as a == b. | def eq(a, b):
"Same as a == b."
return a == b | [
"def",
"eq",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"==",
"b"
] | [
34,
0
] | [
36,
17
] | python | en | ['en', 'gd', 'en'] | True |
ne | (a, b) | Same as a != b. | Same as a != b. | def ne(a, b):
"Same as a != b."
return a != b | [
"def",
"ne",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"!=",
"b"
] | [
38,
0
] | [
40,
17
] | python | en | ['en', 'gd', 'en'] | True |
ge | (a, b) | Same as a >= b. | Same as a >= b. | def ge(a, b):
"Same as a >= b."
return a >= b | [
"def",
"ge",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
">=",
"b"
] | [
42,
0
] | [
44,
17
] | python | en | ['en', 'gd', 'en'] | True |
gt | (a, b) | Same as a > b. | Same as a > b. | def gt(a, b):
"Same as a > b."
return a > b | [
"def",
"gt",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
">",
"b"
] | [
46,
0
] | [
48,
16
] | python | en | ['en', 'gd', 'en'] | True |
not_ | (a) | Same as not a. | Same as not a. | def not_(a):
"Same as not a."
return not a | [
"def",
"not_",
"(",
"a",
")",
":",
"return",
"not",
"a"
] | [
52,
0
] | [
54,
16
] | python | en | ['en', 'en', 'en'] | True |
truth | (a) | Return True if a is true, False otherwise. | Return True if a is true, False otherwise. | def truth(a):
"Return True if a is true, False otherwise."
return True if a else False | [
"def",
"truth",
"(",
"a",
")",
":",
"return",
"True",
"if",
"a",
"else",
"False"
] | [
56,
0
] | [
58,
31
] | python | en | ['en', 'en', 'en'] | True |
is_ | (a, b) | Same as a is b. | Same as a is b. | def is_(a, b):
"Same as a is b."
return a is b | [
"def",
"is_",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"is",
"b"
] | [
60,
0
] | [
62,
17
] | python | en | ['en', 'en', 'en'] | True |
is_not | (a, b) | Same as a is not b. | Same as a is not b. | def is_not(a, b):
"Same as a is not b."
return a is not b | [
"def",
"is_not",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"is",
"not",
"b"
] | [
64,
0
] | [
66,
21
] | python | en | ['en', 'en', 'en'] | True |
abs | (a) | Same as abs(a). | Same as abs(a). | def abs(a):
"Same as abs(a)."
return _abs(a) | [
"def",
"abs",
"(",
"a",
")",
":",
"return",
"_abs",
"(",
"a",
")"
] | [
70,
0
] | [
72,
18
] | python | en | ['en', 'gl', 'en'] | True |
add | (a, b) | Same as a + b. | Same as a + b. | def add(a, b):
"Same as a + b."
return a + b | [
"def",
"add",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"+",
"b"
] | [
74,
0
] | [
76,
16
] | python | en | ['en', 'gd', 'en'] | True |
and_ | (a, b) | Same as a & b. | Same as a & b. | def and_(a, b):
"Same as a & b."
return a & b | [
"def",
"and_",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"&",
"b"
] | [
78,
0
] | [
80,
16
] | python | en | ['en', 'gd', 'en'] | True |
floordiv | (a, b) | Same as a // b. | Same as a // b. | def floordiv(a, b):
"Same as a // b."
return a // b | [
"def",
"floordiv",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"//",
"b"
] | [
82,
0
] | [
84,
17
] | python | en | ['en', 'gd', 'en'] | True |
index | (a) | Same as a.__index__(). | Same as a.__index__(). | def index(a):
"Same as a.__index__()."
return a.__index__() | [
"def",
"index",
"(",
"a",
")",
":",
"return",
"a",
".",
"__index__",
"(",
")"
] | [
86,
0
] | [
88,
24
] | python | en | ['en', 'en', 'en'] | True |
inv | (a) | Same as ~a. | Same as ~a. | def inv(a):
"Same as ~a."
return ~a | [
"def",
"inv",
"(",
"a",
")",
":",
"return",
"~",
"a"
] | [
90,
0
] | [
92,
13
] | python | en | ['en', 'gd', 'en'] | True |
lshift | (a, b) | Same as a << b. | Same as a << b. | def lshift(a, b):
"Same as a << b."
return a << b | [
"def",
"lshift",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"<<",
"b"
] | [
95,
0
] | [
97,
17
] | python | en | ['en', 'gd', 'en'] | True |
mod | (a, b) | Same as a % b. | Same as a % b. | def mod(a, b):
"Same as a % b."
return a % b | [
"def",
"mod",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"%",
"b"
] | [
99,
0
] | [
101,
16
] | python | en | ['en', 'gd', 'en'] | True |
mul | (a, b) | Same as a * b. | Same as a * b. | def mul(a, b):
"Same as a * b."
return a * b | [
"def",
"mul",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"*",
"b"
] | [
103,
0
] | [
105,
16
] | python | en | ['en', 'gd', 'en'] | True |
matmul | (a, b) | Same as a @ b. | Same as a | def matmul(a, b):
"Same as a @ b."
return a @ b | [
"def",
"matmul",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"@",
"b"
] | [
107,
0
] | [
109,
16
] | python | en | ['en', 'gd', 'en'] | True |
neg | (a) | Same as -a. | Same as -a. | def neg(a):
"Same as -a."
return -a | [
"def",
"neg",
"(",
"a",
")",
":",
"return",
"-",
"a"
] | [
111,
0
] | [
113,
13
] | python | en | ['en', 'gd', 'en'] | True |
or_ | (a, b) | Same as a | b. | Same as a | b. | def or_(a, b):
"Same as a | b."
return a | b | [
"def",
"or_",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"|",
"b"
] | [
115,
0
] | [
117,
16
] | python | en | ['en', 'gd', 'en'] | True |
pos | (a) | Same as +a. | Same as +a. | def pos(a):
"Same as +a."
return +a | [
"def",
"pos",
"(",
"a",
")",
":",
"return",
"+",
"a"
] | [
119,
0
] | [
121,
13
] | python | en | ['en', 'gd', 'en'] | True |
pow | (a, b) | Same as a ** b. | Same as a ** b. | def pow(a, b):
"Same as a ** b."
return a ** b | [
"def",
"pow",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"**",
"b"
] | [
123,
0
] | [
125,
17
] | python | en | ['en', 'gd', 'en'] | True |
rshift | (a, b) | Same as a >> b. | Same as a >> b. | def rshift(a, b):
"Same as a >> b."
return a >> b | [
"def",
"rshift",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
">>",
"b"
] | [
127,
0
] | [
129,
17
] | python | en | ['en', 'gd', 'en'] | True |
sub | (a, b) | Same as a - b. | Same as a - b. | def sub(a, b):
"Same as a - b."
return a - b | [
"def",
"sub",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"-",
"b"
] | [
131,
0
] | [
133,
16
] | python | en | ['en', 'gd', 'en'] | True |
truediv | (a, b) | Same as a / b. | Same as a / b. | def truediv(a, b):
"Same as a / b."
return a / b | [
"def",
"truediv",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"/",
"b"
] | [
135,
0
] | [
137,
16
] | python | en | ['en', 'gd', 'en'] | True |
xor | (a, b) | Same as a ^ b. | Same as a ^ b. | def xor(a, b):
"Same as a ^ b."
return a ^ b | [
"def",
"xor",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"^",
"b"
] | [
139,
0
] | [
141,
16
] | python | en | ['en', 'gd', 'en'] | True |
concat | (a, b) | Same as a + b, for a and b sequences. | Same as a + b, for a and b sequences. | def concat(a, b):
"Same as a + b, for a and b sequences."
if not hasattr(a, '__getitem__'):
msg = "'%s' object can't be concatenated" % type(a).__name__
raise TypeError(msg)
return a + b | [
"def",
"concat",
"(",
"a",
",",
"b",
")",
":",
"if",
"not",
"hasattr",
"(",
"a",
",",
"'__getitem__'",
")",
":",
"msg",
"=",
"\"'%s' object can't be concatenated\"",
"%",
"type",
"(",
"a",
")",
".",
"__name__",
"raise",
"TypeError",
"(",
"msg",
")",
"r... | [
145,
0
] | [
150,
16
] | python | en | ['en', 'en', 'en'] | True |
contains | (a, b) | Same as b in a (note reversed operands). | Same as b in a (note reversed operands). | def contains(a, b):
"Same as b in a (note reversed operands)."
return b in a | [
"def",
"contains",
"(",
"a",
",",
"b",
")",
":",
"return",
"b",
"in",
"a"
] | [
152,
0
] | [
154,
17
] | python | en | ['en', 'en', 'en'] | True |
countOf | (a, b) | Return the number of times b occurs in a. | Return the number of times b occurs in a. | def countOf(a, b):
"Return the number of times b occurs in a."
count = 0
for i in a:
if i == b:
count += 1
return count | [
"def",
"countOf",
"(",
"a",
",",
"b",
")",
":",
"count",
"=",
"0",
"for",
"i",
"in",
"a",
":",
"if",
"i",
"==",
"b",
":",
"count",
"+=",
"1",
"return",
"count"
] | [
156,
0
] | [
162,
16
] | python | en | ['en', 'en', 'en'] | True |
delitem | (a, b) | Same as del a[b]. | Same as del a[b]. | def delitem(a, b):
"Same as del a[b]."
del a[b] | [
"def",
"delitem",
"(",
"a",
",",
"b",
")",
":",
"del",
"a",
"[",
"b",
"]"
] | [
164,
0
] | [
166,
12
] | python | es | ['es', 'gd', 'it'] | False |
getitem | (a, b) | Same as a[b]. | Same as a[b]. | def getitem(a, b):
"Same as a[b]."
return a[b] | [
"def",
"getitem",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"[",
"b",
"]"
] | [
168,
0
] | [
170,
15
] | python | en | ['en', 'gd', 'en'] | True |
indexOf | (a, b) | Return the first index of b in a. | Return the first index of b in a. | def indexOf(a, b):
"Return the first index of b in a."
for i, j in enumerate(a):
if j == b:
return i
else:
raise ValueError('sequence.index(x): x not in sequence') | [
"def",
"indexOf",
"(",
"a",
",",
"b",
")",
":",
"for",
"i",
",",
"j",
"in",
"enumerate",
"(",
"a",
")",
":",
"if",
"j",
"==",
"b",
":",
"return",
"i",
"else",
":",
"raise",
"ValueError",
"(",
"'sequence.index(x): x not in sequence'",
")"
] | [
172,
0
] | [
178,
64
] | python | en | ['en', 'en', 'en'] | True |
setitem | (a, b, c) | Same as a[b] = c. | Same as a[b] = c. | def setitem(a, b, c):
"Same as a[b] = c."
a[b] = c | [
"def",
"setitem",
"(",
"a",
",",
"b",
",",
"c",
")",
":",
"a",
"[",
"b",
"]",
"=",
"c"
] | [
180,
0
] | [
182,
12
] | python | en | ['en', 'gd', 'en'] | True |
length_hint | (obj, default=0) |
Return an estimate of the number of items in obj.
This is useful for presizing containers when building from an iterable.
If the object supports len(), the result will be exact. Otherwise, it may
over- or under-estimate by an arbitrary amount. The result will be an
integer >= 0.
|
Return an estimate of the number of items in obj.
This is useful for presizing containers when building from an iterable. | def length_hint(obj, default=0):
"""
Return an estimate of the number of items in obj.
This is useful for presizing containers when building from an iterable.
If the object supports len(), the result will be exact. Otherwise, it may
over- or under-estimate by an arbitrary amount. The result will be... | [
"def",
"length_hint",
"(",
"obj",
",",
"default",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"default",
",",
"int",
")",
":",
"msg",
"=",
"(",
"\"'%s' object cannot be interpreted as an integer\"",
"%",
"type",
"(",
"default",
")",
".",
"__name__",
... | [
184,
0
] | [
221,
14
] | python | en | ['en', 'error', 'th'] | False |
iadd | (a, b) | Same as a += b. | Same as a += b. | def iadd(a, b):
"Same as a += b."
a += b
return a | [
"def",
"iadd",
"(",
"a",
",",
"b",
")",
":",
"a",
"+=",
"b",
"return",
"a"
] | [
336,
0
] | [
339,
12
] | python | en | ['en', 'gd', 'en'] | True |
iand | (a, b) | Same as a &= b. | Same as a &= b. | def iand(a, b):
"Same as a &= b."
a &= b
return a | [
"def",
"iand",
"(",
"a",
",",
"b",
")",
":",
"a",
"&=",
"b",
"return",
"a"
] | [
341,
0
] | [
344,
12
] | python | en | ['en', 'gd', 'en'] | True |
iconcat | (a, b) | Same as a += b, for a and b sequences. | Same as a += b, for a and b sequences. | def iconcat(a, b):
"Same as a += b, for a and b sequences."
if not hasattr(a, '__getitem__'):
msg = "'%s' object can't be concatenated" % type(a).__name__
raise TypeError(msg)
a += b
return a | [
"def",
"iconcat",
"(",
"a",
",",
"b",
")",
":",
"if",
"not",
"hasattr",
"(",
"a",
",",
"'__getitem__'",
")",
":",
"msg",
"=",
"\"'%s' object can't be concatenated\"",
"%",
"type",
"(",
"a",
")",
".",
"__name__",
"raise",
"TypeError",
"(",
"msg",
")",
"... | [
346,
0
] | [
352,
12
] | python | en | ['en', 'en', 'en'] | True |
ifloordiv | (a, b) | Same as a //= b. | Same as a //= b. | def ifloordiv(a, b):
"Same as a //= b."
a //= b
return a | [
"def",
"ifloordiv",
"(",
"a",
",",
"b",
")",
":",
"a",
"//=",
"b",
"return",
"a"
] | [
354,
0
] | [
357,
12
] | python | en | ['en', 'gd', 'en'] | True |
ilshift | (a, b) | Same as a <<= b. | Same as a <<= b. | def ilshift(a, b):
"Same as a <<= b."
a <<= b
return a | [
"def",
"ilshift",
"(",
"a",
",",
"b",
")",
":",
"a",
"<<=",
"b",
"return",
"a"
] | [
359,
0
] | [
362,
12
] | python | en | ['en', 'gd', 'en'] | True |
imod | (a, b) | Same as a %= b. | Same as a %= b. | def imod(a, b):
"Same as a %= b."
a %= b
return a | [
"def",
"imod",
"(",
"a",
",",
"b",
")",
":",
"a",
"%=",
"b",
"return",
"a"
] | [
364,
0
] | [
367,
12
] | python | en | ['en', 'gd', 'en'] | True |
imul | (a, b) | Same as a *= b. | Same as a *= b. | def imul(a, b):
"Same as a *= b."
a *= b
return a | [
"def",
"imul",
"(",
"a",
",",
"b",
")",
":",
"a",
"*=",
"b",
"return",
"a"
] | [
369,
0
] | [
372,
12
] | python | en | ['en', 'gd', 'en'] | True |
imatmul | (a, b) | Same as a @= b. | Same as a | def imatmul(a, b):
"Same as a @= b."
a @= b
return a | [
"def",
"imatmul",
"(",
"a",
",",
"b",
")",
":",
"a",
"@=",
"b",
"return",
"a"
] | [
374,
0
] | [
377,
12
] | python | en | ['en', 'gd', 'en'] | True |
ior | (a, b) | Same as a |= b. | Same as a |= b. | def ior(a, b):
"Same as a |= b."
a |= b
return a | [
"def",
"ior",
"(",
"a",
",",
"b",
")",
":",
"a",
"|=",
"b",
"return",
"a"
] | [
379,
0
] | [
382,
12
] | python | en | ['en', 'gd', 'en'] | True |
ipow | (a, b) | Same as a **= b. | Same as a **= b. | def ipow(a, b):
"Same as a **= b."
a **=b
return a | [
"def",
"ipow",
"(",
"a",
",",
"b",
")",
":",
"a",
"**=",
"b",
"return",
"a"
] | [
384,
0
] | [
387,
12
] | python | en | ['en', 'gd', 'en'] | True |
irshift | (a, b) | Same as a >>= b. | Same as a >>= b. | def irshift(a, b):
"Same as a >>= b."
a >>= b
return a | [
"def",
"irshift",
"(",
"a",
",",
"b",
")",
":",
"a",
">>=",
"b",
"return",
"a"
] | [
389,
0
] | [
392,
12
] | python | en | ['en', 'gd', 'en'] | True |
isub | (a, b) | Same as a -= b. | Same as a -= b. | def isub(a, b):
"Same as a -= b."
a -= b
return a | [
"def",
"isub",
"(",
"a",
",",
"b",
")",
":",
"a",
"-=",
"b",
"return",
"a"
] | [
394,
0
] | [
397,
12
] | python | en | ['en', 'gd', 'en'] | True |
itruediv | (a, b) | Same as a /= b. | Same as a /= b. | def itruediv(a, b):
"Same as a /= b."
a /= b
return a | [
"def",
"itruediv",
"(",
"a",
",",
"b",
")",
":",
"a",
"/=",
"b",
"return",
"a"
] | [
399,
0
] | [
402,
12
] | python | en | ['en', 'gd', 'en'] | True |
ixor | (a, b) | Same as a ^= b. | Same as a ^= b. | def ixor(a, b):
"Same as a ^= b."
a ^= b
return a | [
"def",
"ixor",
"(",
"a",
",",
"b",
")",
":",
"a",
"^=",
"b",
"return",
"a"
] | [
404,
0
] | [
407,
12
] | python | en | ['en', 'gd', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.