nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
llSourcell/AI_Artist
3038c06c2e389b9c919c881c9a169efe2fd7810e
lib/python2.7/site-packages/pip/_vendor/requests/models.py
python
PreparedRequest.prepare_auth
(self, auth, url='')
Prepares the given HTTP auth data.
Prepares the given HTTP auth data.
[ "Prepares", "the", "given", "HTTP", "auth", "data", "." ]
def prepare_auth(self, auth, url=''): """Prepares the given HTTP auth data.""" # If no Auth is explicitly provided, extract it from the URL first. if auth is None: url_auth = get_auth_from_url(self.url) auth = url_auth if any(url_auth) else None if auth: if isinstance(auth, tuple) and len(auth) == 2: # special-case basic HTTP auth auth = HTTPBasicAuth(*auth) # Allow auth to make its changes. r = auth(self) # Update self to reflect the auth changes. self.__dict__.update(r.__dict__) # Recompute Content-Length self.prepare_content_length(self.body)
[ "def", "prepare_auth", "(", "self", ",", "auth", ",", "url", "=", "''", ")", ":", "# If no Auth is explicitly provided, extract it from the URL first.", "if", "auth", "is", "None", ":", "url_auth", "=", "get_auth_from_url", "(", "self", ".", "url", ")", "auth", ...
https://github.com/llSourcell/AI_Artist/blob/3038c06c2e389b9c919c881c9a169efe2fd7810e/lib/python2.7/site-packages/pip/_vendor/requests/models.py#L480-L500
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/lyric/config_flow.py
python
OAuth2FlowHandler.async_step_reauth_confirm
(self, user_input=None)
return await self.async_step_user()
Dialog that informs the user that reauth is required.
Dialog that informs the user that reauth is required.
[ "Dialog", "that", "informs", "the", "user", "that", "reauth", "is", "required", "." ]
async def async_step_reauth_confirm(self, user_input=None): """Dialog that informs the user that reauth is required.""" if user_input is None: return self.async_show_form( step_id="reauth_confirm", data_schema=vol.Schema({}), ) return await self.async_step_user()
[ "async", "def", "async_step_reauth_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"reauth_confirm\"", ",", "data_schema", "=", "vol", ".",...
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/lyric/config_flow.py#L27-L34
linxid/Machine_Learning_Study_Path
558e82d13237114bbb8152483977806fc0c222af
Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py
python
Serializer.loads
(self, request, data)
[]
def loads(self, request, data): # Short circuit if we've been given an empty set of data if not data: return # Determine what version of the serializer the data was serialized # with try: ver, data = data.split(b",", 1) except ValueError: ver = b"cc=0" # Make sure that our "ver" is actually a version and isn't a false # positive from a , being in the data stream. if ver[:3] != b"cc=": data = ver + data ver = b"cc=0" # Get the version number out of the cc=N ver = ver.split(b"=", 1)[-1].decode("ascii") # Dispatch to the actual load method for the given version try: return getattr(self, "_loads_v{0}".format(ver))(request, data) except AttributeError: # This is a version we don't have a loads function for, so we'll # just treat it as a miss and return None return
[ "def", "loads", "(", "self", ",", "request", ",", "data", ")", ":", "# Short circuit if we've been given an empty set of data", "if", "not", "data", ":", "return", "# Determine what version of the serializer the data was serialized", "# with", "try", ":", "ver", ",", "dat...
https://github.com/linxid/Machine_Learning_Study_Path/blob/558e82d13237114bbb8152483977806fc0c222af/Machine Learning In Action/Chapter5-LogisticRegression/venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py#L91-L118
TuSimple/simpledet
97413463f0bc3116f684eaf7031fd3dd6ded3149
core/detection_module.py
python
DetModule.forward
(self, data_batch, is_train=None)
Forward computation. It supports data batches with different shapes, such as different batch sizes or different image sizes. If reshaping of data batch relates to modification of symbol or module, such as changing image layout ordering or switching from training to predicting, module rebinding is required. See Also ---------- :meth:`BaseModule.forward`. Parameters ---------- data_batch : DataBatch Could be anything with similar API implemented. is_train : bool Default is ``None``, which means ``is_train`` takes the value of ``self.for_training``.
Forward computation. It supports data batches with different shapes, such as different batch sizes or different image sizes. If reshaping of data batch relates to modification of symbol or module, such as changing image layout ordering or switching from training to predicting, module rebinding is required.
[ "Forward", "computation", ".", "It", "supports", "data", "batches", "with", "different", "shapes", "such", "as", "different", "batch", "sizes", "or", "different", "image", "sizes", ".", "If", "reshaping", "of", "data", "batch", "relates", "to", "modification", ...
def forward(self, data_batch, is_train=None): """Forward computation. It supports data batches with different shapes, such as different batch sizes or different image sizes. If reshaping of data batch relates to modification of symbol or module, such as changing image layout ordering or switching from training to predicting, module rebinding is required. See Also ---------- :meth:`BaseModule.forward`. Parameters ---------- data_batch : DataBatch Could be anything with similar API implemented. is_train : bool Default is ``None``, which means ``is_train`` takes the value of ``self.for_training``. """ assert self.binded and self.params_initialized curr_data_shapes = tuple(i.shape for i in self._data_shapes) if isinstance(data_batch, list): assert data_batch is not None, "Encountered empty data batch" new_data_shapes = [] for i in range(len(data_batch[0].data)): shape = data_batch[0].data[i].shape for db in data_batch: assert shape == db.data[i].shape, \ "All data batches in a list need to have the same shape" new_batch_size = len(data_batch) * shape[0] new_data_shapes.append((new_batch_size,) + shape[1:]) new_data_shapes = tuple(new_data_shapes) else: new_data_shapes = tuple(i.shape for i in data_batch.data) if curr_data_shapes != new_data_shapes: if hasattr(data_batch, "provide_data") and data_batch.provide_data: new_dshape = data_batch.provide_data else: new_dshape = [DataDesc(i.name, shape, i.dtype, i.layout) \ for i, shape in zip(self._data_shapes, new_data_shapes)] if hasattr(data_batch, "provide_label") and data_batch.provide_label: new_lshape = data_batch.provide_label elif hasattr(data_batch, "label") and data_batch.label: new_lshape = [DataDesc(i.name, j.shape, i.dtype, i.layout) \ for i, j in zip(self._label_shapes, data_batch.label)] else: new_lshape = None self.reshape(new_dshape, new_lshape) self._exec_group.forward(data_batch, is_train)
[ "def", "forward", "(", "self", ",", "data_batch", ",", "is_train", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "curr_data_shapes", "=", "tuple", "(", "i", ".", "shape", "for", "i", "in", "self", ".", ...
https://github.com/TuSimple/simpledet/blob/97413463f0bc3116f684eaf7031fd3dd6ded3149/core/detection_module.py#L592-L644
dabeaz/ply
559a7a1feabb0853be79d4f4dd9e9e9e5ea0d08c
example/yply/ylex.py
python
t_code_ignore_char
(t)
r'\'([^\\\n]|(\\.))*?\
r'\'([^\\\n]|(\\.))*?\
[ "r", "\\", "(", "[", "^", "\\\\\\", "n", "]", "|", "(", "\\\\", ".", "))", "*", "?", "\\" ]
def t_code_ignore_char(t): r'\'([^\\\n]|(\\.))*?\''
[ "def", "t_code_ignore_char", "(", "t", ")", ":" ]
https://github.com/dabeaz/ply/blob/559a7a1feabb0853be79d4f4dd9e9e9e5ea0d08c/example/yply/ylex.py#L75-L76
TheAlgorithms/Python
9af2eef9b3761bf51580dedfb6fa7136ca0c5c2c
project_euler/problem_064/sol1.py
python
solution
(n: int = 10000)
return count_odd_periods
Returns the count of numbers <= 10000 with odd periods. This function calls continuous_fraction_period for numbers which are not perfect squares. This is checked in if sr - floor(sr) != 0 statement. If an odd period is returned by continuous_fraction_period, count_odd_periods is increased by 1. >>> solution(2) 1 >>> solution(5) 2 >>> solution(7) 2 >>> solution(11) 3 >>> solution(13) 4
Returns the count of numbers <= 10000 with odd periods. This function calls continuous_fraction_period for numbers which are not perfect squares. This is checked in if sr - floor(sr) != 0 statement. If an odd period is returned by continuous_fraction_period, count_odd_periods is increased by 1.
[ "Returns", "the", "count", "of", "numbers", "<", "=", "10000", "with", "odd", "periods", ".", "This", "function", "calls", "continuous_fraction_period", "for", "numbers", "which", "are", "not", "perfect", "squares", ".", "This", "is", "checked", "in", "if", ...
def solution(n: int = 10000) -> int: """ Returns the count of numbers <= 10000 with odd periods. This function calls continuous_fraction_period for numbers which are not perfect squares. This is checked in if sr - floor(sr) != 0 statement. If an odd period is returned by continuous_fraction_period, count_odd_periods is increased by 1. >>> solution(2) 1 >>> solution(5) 2 >>> solution(7) 2 >>> solution(11) 3 >>> solution(13) 4 """ count_odd_periods = 0 for i in range(2, n + 1): sr = sqrt(i) if sr - floor(sr) != 0: if continuous_fraction_period(i) % 2 == 1: count_odd_periods += 1 return count_odd_periods
[ "def", "solution", "(", "n", ":", "int", "=", "10000", ")", "->", "int", ":", "count_odd_periods", "=", "0", "for", "i", "in", "range", "(", "2", ",", "n", "+", "1", ")", ":", "sr", "=", "sqrt", "(", "i", ")", "if", "sr", "-", "floor", "(", ...
https://github.com/TheAlgorithms/Python/blob/9af2eef9b3761bf51580dedfb6fa7136ca0c5c2c/project_euler/problem_064/sol1.py#L47-L73
FederatedAI/FATE
32540492623568ecd1afcb367360133616e02fa3
python/federatedml/transfer_learning/hetero_ftl/ftl_base.py
python
FTL.learning_rate_decay
(self, learning_rate, epoch)
return learning_rate * 1 / np.sqrt(epoch + 1)
learning_rate decay
learning_rate decay
[ "learning_rate", "decay" ]
def learning_rate_decay(self, learning_rate, epoch): """ learning_rate decay """ return learning_rate * 1 / np.sqrt(epoch + 1)
[ "def", "learning_rate_decay", "(", "self", ",", "learning_rate", ",", "epoch", ")", ":", "return", "learning_rate", "*", "1", "/", "np", ".", "sqrt", "(", "epoch", "+", "1", ")" ]
https://github.com/FederatedAI/FATE/blob/32540492623568ecd1afcb367360133616e02fa3/python/federatedml/transfer_learning/hetero_ftl/ftl_base.py#L167-L171
huawei-noah/CV-Backbones
03e8cdfe92494a55ddfb11cc875ff2e1c33f91da
versatile_filters/vcnn.py
python
vgg11
(pretrained=False, **kwargs)
return model
VGG 11-layer model (configuration "A") Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
VGG 11-layer model (configuration "A")
[ "VGG", "11", "-", "layer", "model", "(", "configuration", "A", ")" ]
def vgg11(pretrained=False, **kwargs): """VGG 11-layer model (configuration "A") Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ if pretrained: kwargs['init_weights'] = False model = VGG(make_layers(cfg['A']), **kwargs) if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['vgg11'])) return model
[ "def", "vgg11", "(", "pretrained", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "pretrained", ":", "kwargs", "[", "'init_weights'", "]", "=", "False", "model", "=", "VGG", "(", "make_layers", "(", "cfg", "[", "'A'", "]", ")", ",", "*", "*...
https://github.com/huawei-noah/CV-Backbones/blob/03e8cdfe92494a55ddfb11cc875ff2e1c33f91da/versatile_filters/vcnn.py#L132-L143
marcosfede/algorithms
1ee7c815f9d556c9cef4d4b0d21ee3a409d21629
dp/matrix_chain_order.py
python
main
()
[]
def main(): array = [30, 35, 15, 5, 10, 20, 25] n = len(array) # Size of matrix created from above array will be # 30*35 35*15 15*5 5*10 10*20 20*25 matrix, optimal_solution = matrix_chain_order(array) print("No. of Operation required: " + str((matrix[1][n - 1]))) print_optimal_solution(optimal_solution, 1, n - 1)
[ "def", "main", "(", ")", ":", "array", "=", "[", "30", ",", "35", ",", "15", ",", "5", ",", "10", ",", "20", ",", "25", "]", "n", "=", "len", "(", "array", ")", "# Size of matrix created from above array will be", "# 30*35 35*15 15*5 5*10 10*20 20*25", "ma...
https://github.com/marcosfede/algorithms/blob/1ee7c815f9d556c9cef4d4b0d21ee3a409d21629/dp/matrix_chain_order.py#L39-L47
nucleic/enaml
65c2a2a2d765e88f2e1103046680571894bb41ed
enaml/qt/qt_scintilla.py
python
QtScintilla.set_autocomplete
(self, mode)
Set the autocompletion mode
Set the autocompletion mode
[ "Set", "the", "autocompletion", "mode" ]
def set_autocomplete(self, mode): """ Set the autocompletion mode """ self.widget.setAutoCompletionSource(AUTOCOMPLETION_SOURCE[mode])
[ "def", "set_autocomplete", "(", "self", ",", "mode", ")", ":", "self", ".", "widget", ".", "setAutoCompletionSource", "(", "AUTOCOMPLETION_SOURCE", "[", "mode", "]", ")" ]
https://github.com/nucleic/enaml/blob/65c2a2a2d765e88f2e1103046680571894bb41ed/enaml/qt/qt_scintilla.py#L480-L484
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/_pyio.py
python
TextIOWrapper.fileno
(self)
return self.buffer.fileno()
[]
def fileno(self): return self.buffer.fileno()
[ "def", "fileno", "(", "self", ")", ":", "return", "self", ".", "buffer", ".", "fileno", "(", ")" ]
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/_pyio.py#L2223-L2224
gramps-project/gramps
04d4651a43eb210192f40a9f8c2bad8ee8fa3753
gramps/gen/git_revision.py
python
get_git_revision
(path="")
Return the short commit hash of the latest commit.
Return the short commit hash of the latest commit.
[ "Return", "the", "short", "commit", "hash", "of", "the", "latest", "commit", "." ]
def get_git_revision(path=""): """ Return the short commit hash of the latest commit. """ stdout = "" command = ['git', 'log', '-1', '--format=%h', path] try: proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = proc.communicate() except OSError: return "" # subprocess failed # subprocess worked if stdout and len(stdout) > 0: # has output try: stdout = stdout.decode("utf-8", errors='replace') except UnicodeDecodeError: pass return "-" + stdout if stdout else "" else: # no output from git log return ""
[ "def", "get_git_revision", "(", "path", "=", "\"\"", ")", ":", "stdout", "=", "\"\"", "command", "=", "[", "'git'", ",", "'log'", ",", "'-1'", ",", "'--format=%h'", ",", "path", "]", "try", ":", "proc", "=", "subprocess", ".", "Popen", "(", "command", ...
https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/gen/git_revision.py#L28-L49
i-pan/kaggle-rsna18
2db498fe99615d935aa676f04847d0c562fd8e46
models/DeformableConvNets/lib/dataset/coco.py
python
coco._load_coco_annotation
(self, index)
return roi_rec
coco ann: [u'segmentation', u'area', u'iscrowd', u'image_id', u'bbox', u'category_id', u'id'] iscrowd: crowd instances are handled by marking their overlaps with all categories to -1 and later excluded in training bbox: [x1, y1, w, h] :param index: coco image id :return: roidb entry
coco ann: [u'segmentation', u'area', u'iscrowd', u'image_id', u'bbox', u'category_id', u'id'] iscrowd: crowd instances are handled by marking their overlaps with all categories to -1 and later excluded in training bbox: [x1, y1, w, h] :param index: coco image id :return: roidb entry
[ "coco", "ann", ":", "[", "u", "segmentation", "u", "area", "u", "iscrowd", "u", "image_id", "u", "bbox", "u", "category_id", "u", "id", "]", "iscrowd", ":", "crowd", "instances", "are", "handled", "by", "marking", "their", "overlaps", "with", "all", "cat...
def _load_coco_annotation(self, index): """ coco ann: [u'segmentation', u'area', u'iscrowd', u'image_id', u'bbox', u'category_id', u'id'] iscrowd: crowd instances are handled by marking their overlaps with all categories to -1 and later excluded in training bbox: [x1, y1, w, h] :param index: coco image id :return: roidb entry """ im_ann = self.coco.loadImgs(index)[0] width = im_ann['width'] height = im_ann['height'] annIds = self.coco.getAnnIds(imgIds=index, iscrowd=False) objs = self.coco.loadAnns(annIds) # sanitize bboxes valid_objs = [] for obj in objs: x, y, w, h = obj['bbox'] x1 = np.max((0, x)) y1 = np.max((0, y)) x2 = np.min((width - 1, x1 + np.max((0, w - 1)))) y2 = np.min((height - 1, y1 + np.max((0, h - 1)))) if obj['area'] > 0 and x2 >= x1 and y2 >= y1: obj['clean_bbox'] = [x1, y1, x2, y2] valid_objs.append(obj) objs = valid_objs num_objs = len(objs) boxes = np.zeros((num_objs, 4), dtype=np.uint16) gt_classes = np.zeros((num_objs), dtype=np.int32) overlaps = np.zeros((num_objs, self.num_classes), dtype=np.float32) for ix, obj in enumerate(objs): cls = self._coco_ind_to_class_ind[obj['category_id']] boxes[ix, :] = obj['clean_bbox'] gt_classes[ix] = cls if obj['iscrowd']: overlaps[ix, :] = -1.0 else: overlaps[ix, cls] = 1.0 roi_rec = {'image': self.image_path_from_index(index), 'height': height, 'width': width, 'boxes': boxes, 'gt_classes': gt_classes, 'gt_overlaps': overlaps, 'max_classes': overlaps.argmax(axis=1), 'max_overlaps': overlaps.max(axis=1), 'flipped': False} return roi_rec
[ "def", "_load_coco_annotation", "(", "self", ",", "index", ")", ":", "im_ann", "=", "self", ".", "coco", ".", "loadImgs", "(", "index", ")", "[", "0", "]", "width", "=", "im_ann", "[", "'width'", "]", "height", "=", "im_ann", "[", "'height'", "]", "a...
https://github.com/i-pan/kaggle-rsna18/blob/2db498fe99615d935aa676f04847d0c562fd8e46/models/DeformableConvNets/lib/dataset/coco.py#L142-L196
wbond/oscrypto
d40c62577706682a0f6da5616ad09964f1c9137d
oscrypto/_openssl/symmetric.py
python
aes_cbc_pkcs7_decrypt
(key, data, iv)
return _decrypt(cipher, key, data, iv, True)
Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key :param key: The encryption key - a byte string either 16, 24 or 32 bytes long :param data: The ciphertext - a byte string :param iv: The initialization vector - a byte string 16-bytes long :raises: ValueError - when any of the parameters contain an invalid value TypeError - when any of the parameters are of the wrong type OSError - when an error is returned by OpenSSL :return: A byte string of the plaintext
Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key
[ "Decrypts", "AES", "ciphertext", "in", "CBC", "mode", "using", "a", "128", "192", "or", "256", "bit", "key" ]
def aes_cbc_pkcs7_decrypt(key, data, iv): """ Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key :param key: The encryption key - a byte string either 16, 24 or 32 bytes long :param data: The ciphertext - a byte string :param iv: The initialization vector - a byte string 16-bytes long :raises: ValueError - when any of the parameters contain an invalid value TypeError - when any of the parameters are of the wrong type OSError - when an error is returned by OpenSSL :return: A byte string of the plaintext """ cipher = _calculate_aes_cipher(key) if len(iv) != 16: raise ValueError(pretty_message( ''' iv must be 16 bytes long - is %s ''', len(iv) )) return _decrypt(cipher, key, data, iv, True)
[ "def", "aes_cbc_pkcs7_decrypt", "(", "key", ",", "data", ",", "iv", ")", ":", "cipher", "=", "_calculate_aes_cipher", "(", "key", ")", "if", "len", "(", "iv", ")", "!=", "16", ":", "raise", "ValueError", "(", "pretty_message", "(", "'''\n iv must ...
https://github.com/wbond/oscrypto/blob/d40c62577706682a0f6da5616ad09964f1c9137d/oscrypto/_openssl/symmetric.py#L152-L184
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/gdata/codesearch/service.py
python
CodesearchService.__init__
(self, email=None, password=None, source=None, server='www.google.com', additional_headers=None, **kwargs)
Creates a client for the Google codesearch service. Args: email: string (optional) The user's email address, used for authentication. password: string (optional) The user's password. source: string (optional) The name of the user's application. server: string (optional) The name of the server to which a connection will be opened. Default value: 'www.google.com'. **kwargs: The other parameters to pass to gdata.service.GDataService constructor.
Creates a client for the Google codesearch service.
[ "Creates", "a", "client", "for", "the", "Google", "codesearch", "service", "." ]
def __init__(self, email=None, password=None, source=None, server='www.google.com', additional_headers=None, **kwargs): """Creates a client for the Google codesearch service. Args: email: string (optional) The user's email address, used for authentication. password: string (optional) The user's password. source: string (optional) The name of the user's application. server: string (optional) The name of the server to which a connection will be opened. Default value: 'www.google.com'. **kwargs: The other parameters to pass to gdata.service.GDataService constructor. """ gdata.service.GDataService.__init__( self, email=email, password=password, service='codesearch', source=source, server=server, additional_headers=additional_headers, **kwargs)
[ "def", "__init__", "(", "self", ",", "email", "=", "None", ",", "password", "=", "None", ",", "source", "=", "None", ",", "server", "=", "'www.google.com'", ",", "additional_headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "gdata", ".", "servi...
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/gdata/codesearch/service.py#L33-L50
Fizzadar/pyinfra
ff0913d6a172966760b63fe59e55dff9ea852e0d
pyinfra/facts/server.py
python
KernelModules.process
(output)
return modules
[]
def process(output): modules = {} for line in output: name, size, instances, depends, state, _ = line.split(' ', 5) instances = int(instances) module = { 'size': size, 'instances': instances, 'state': state, } if depends != '-': module['depends'] = [ value for value in depends.split(',') if value ] modules[name] = module return modules
[ "def", "process", "(", "output", ")", ":", "modules", "=", "{", "}", "for", "line", "in", "output", ":", "name", ",", "size", ",", "instances", ",", "depends", ",", "state", ",", "_", "=", "line", ".", "split", "(", "' '", ",", "5", ")", "instanc...
https://github.com/Fizzadar/pyinfra/blob/ff0913d6a172966760b63fe59e55dff9ea852e0d/pyinfra/facts/server.py#L212-L234
qtile/qtile
803dc06fc1f8b121a1d8fe047f26a43812cd427f
libqtile/backend/x11/window.py
python
Window.cmd_static
( self, screen: Optional[int] = None, x: Optional[int] = None, y: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, )
Makes this window a static window, attached to a Screen If any of the arguments are left unspecified, the values given by the window itself are used instead. So, for a window that's aware of its appropriate size and location (like dzen), you don't have to specify anything.
Makes this window a static window, attached to a Screen
[ "Makes", "this", "window", "a", "static", "window", "attached", "to", "a", "Screen" ]
def cmd_static( self, screen: Optional[int] = None, x: Optional[int] = None, y: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, ) -> None: """Makes this window a static window, attached to a Screen If any of the arguments are left unspecified, the values given by the window itself are used instead. So, for a window that's aware of its appropriate size and location (like dzen), you don't have to specify anything. """ self.defunct = True if screen is None: screen = self.qtile.current_screen else: screen = self.qtile.screens[screen] if self.group: self.group.remove(self) s = Static(self.window, self.qtile, screen, x, y, width, height) self.qtile.windows_map[self.window.wid] = s self.qtile.core.update_client_list(self.qtile.windows_map) hook.fire("client_managed", s)
[ "def", "cmd_static", "(", "self", ",", "screen", ":", "Optional", "[", "int", "]", "=", "None", ",", "x", ":", "Optional", "[", "int", "]", "=", "None", ",", "y", ":", "Optional", "[", "int", "]", "=", "None", ",", "width", ":", "Optional", "[", ...
https://github.com/qtile/qtile/blob/803dc06fc1f8b121a1d8fe047f26a43812cd427f/libqtile/backend/x11/window.py#L1381-L1406
pywavefront/PyWavefront
7ae734c3317e2af59b93f3e24b68e5a57a2088ab
pywavefront/texture.py
python
Texture.path
(self)
return str(self._path)
str: search_path + name
str: search_path + name
[ "str", ":", "search_path", "+", "name" ]
def path(self): """str: search_path + name""" return str(self._path)
[ "def", "path", "(", "self", ")", ":", "return", "str", "(", "self", ".", "_path", ")" ]
https://github.com/pywavefront/PyWavefront/blob/7ae734c3317e2af59b93f3e24b68e5a57a2088ab/pywavefront/texture.py#L244-L246
SamSchott/maestral
a32653bac7b5a76cb326d4fd5a4fb2c11f19a2fc
src/maestral/sync.py
python
SyncEngine.excluded_items
(self)
return self._excluded_items
List of all files and folders excluded from sync. Changes are saved to the config file. If a parent folder is excluded, its children will automatically be removed from the list. If only children are given but not the parent folder, any new items added to the parent will be synced. Change this property *before* downloading newly included items or deleting excluded items.
List of all files and folders excluded from sync. Changes are saved to the config file. If a parent folder is excluded, its children will automatically be removed from the list. If only children are given but not the parent folder, any new items added to the parent will be synced. Change this property *before* downloading newly included items or deleting excluded items.
[ "List", "of", "all", "files", "and", "folders", "excluded", "from", "sync", ".", "Changes", "are", "saved", "to", "the", "config", "file", ".", "If", "a", "parent", "folder", "is", "excluded", "its", "children", "will", "automatically", "be", "removed", "f...
def excluded_items(self) -> List[str]: """List of all files and folders excluded from sync. Changes are saved to the config file. If a parent folder is excluded, its children will automatically be removed from the list. If only children are given but not the parent folder, any new items added to the parent will be synced. Change this property *before* downloading newly included items or deleting excluded items.""" return self._excluded_items
[ "def", "excluded_items", "(", "self", ")", "->", "List", "[", "str", "]", ":", "return", "self", ".", "_excluded_items" ]
https://github.com/SamSchott/maestral/blob/a32653bac7b5a76cb326d4fd5a4fb2c11f19a2fc/src/maestral/sync.py#L593-L599
ConvLab/ConvLab
a04582a77537c1a706fbf64715baa9ad0be1301a
convlab/modules/policy/user/multiwoz/policy_agenda_multiwoz.py
python
Goal.task_complete
(self)
return True
Check that all requests have been met Returns: (boolean): True to accomplish.
Check that all requests have been met Returns: (boolean): True to accomplish.
[ "Check", "that", "all", "requests", "have", "been", "met", "Returns", ":", "(", "boolean", ")", ":", "True", "to", "accomplish", "." ]
def task_complete(self): """ Check that all requests have been met Returns: (boolean): True to accomplish. """ for domain in self.domains: if 'reqt' in self.domain_goals[domain]: reqt_vals = self.domain_goals[domain]['reqt'].values() for val in reqt_vals: if val in NOT_SURE_VALS: return False if 'booked' in self.domain_goals[domain]: if self.domain_goals[domain]['booked'] in NOT_SURE_VALS: return False return True
[ "def", "task_complete", "(", "self", ")", ":", "for", "domain", "in", "self", ".", "domains", ":", "if", "'reqt'", "in", "self", ".", "domain_goals", "[", "domain", "]", ":", "reqt_vals", "=", "self", ".", "domain_goals", "[", "domain", "]", "[", "'req...
https://github.com/ConvLab/ConvLab/blob/a04582a77537c1a706fbf64715baa9ad0be1301a/convlab/modules/policy/user/multiwoz/policy_agenda_multiwoz.py#L294-L310
wagtail/wagtail
ba8207a5d82c8a1de8f5f9693a7cd07421762999
wagtail/core/models/__init__.py
python
PageViewRestriction.save
(self, user=None, **kwargs)
Custom save handler to include logging. :param user: the user add/updating the view restriction :param specific_instance: the specific model instance the restriction applies to
Custom save handler to include logging. :param user: the user add/updating the view restriction :param specific_instance: the specific model instance the restriction applies to
[ "Custom", "save", "handler", "to", "include", "logging", ".", ":", "param", "user", ":", "the", "user", "add", "/", "updating", "the", "view", "restriction", ":", "param", "specific_instance", ":", "the", "specific", "model", "instance", "the", "restriction", ...
def save(self, user=None, **kwargs): """ Custom save handler to include logging. :param user: the user add/updating the view restriction :param specific_instance: the specific model instance the restriction applies to """ specific_instance = self.page.specific is_new = self.id is None super().save(**kwargs) if specific_instance: log( instance=specific_instance, action='wagtail.view_restriction.create' if is_new else 'wagtail.view_restriction.edit', user=user, data={ 'restriction': { 'type': self.restriction_type, 'title': force_str(dict(self.RESTRICTION_CHOICES).get(self.restriction_type)) } } )
[ "def", "save", "(", "self", ",", "user", "=", "None", ",", "*", "*", "kwargs", ")", ":", "specific_instance", "=", "self", ".", "page", ".", "specific", "is_new", "=", "self", ".", "id", "is", "None", "super", "(", ")", ".", "save", "(", "*", "*"...
https://github.com/wagtail/wagtail/blob/ba8207a5d82c8a1de8f5f9693a7cd07421762999/wagtail/core/models/__init__.py#L2770-L2791
googlefonts/gftools
8ad55dd4d7e38729524329c79f236476f1576e67
Lib/gftools/utils.py
python
download_file
(url, dst_path=None)
Download a file from a url. If no dst_path is specified, store the file as a BytesIO object
Download a file from a url. If no dst_path is specified, store the file as a BytesIO object
[ "Download", "a", "file", "from", "a", "url", ".", "If", "no", "dst_path", "is", "specified", "store", "the", "file", "as", "a", "BytesIO", "object" ]
def download_file(url, dst_path=None): """Download a file from a url. If no dst_path is specified, store the file as a BytesIO object""" request = requests.get(url, stream=True) if not dst_path: return BytesIO(request.content) with open(dst_path, 'wb') as downloaded_file: downloaded_file.write(request.content)
[ "def", "download_file", "(", "url", ",", "dst_path", "=", "None", ")", ":", "request", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "if", "not", "dst_path", ":", "return", "BytesIO", "(", "request", ".", "content", ")", "...
https://github.com/googlefonts/gftools/blob/8ad55dd4d7e38729524329c79f236476f1576e67/Lib/gftools/utils.py#L200-L207
smart-mobile-software/gitstack
d9fee8f414f202143eb6e620529e8e5539a2af56
python/Lib/zipfile.py
python
ZipFile.close
(self)
Close the file, and for mode "w" and "a" write the ending records.
Close the file, and for mode "w" and "a" write the ending records.
[ "Close", "the", "file", "and", "for", "mode", "w", "and", "a", "write", "the", "ending", "records", "." ]
def close(self): """Close the file, and for mode "w" and "a" write the ending records.""" if self.fp is None: return if self.mode in ("w", "a") and self._didModify: # write ending records count = 0 pos1 = self.fp.tell() for zinfo in self.filelist: # write central directory count = count + 1 dt = zinfo.date_time dosdate = (dt[0] - 1980) << 9 | dt[1] << 5 | dt[2] dostime = dt[3] << 11 | dt[4] << 5 | (dt[5] // 2) extra = [] if zinfo.file_size > ZIP64_LIMIT \ or zinfo.compress_size > ZIP64_LIMIT: extra.append(zinfo.file_size) extra.append(zinfo.compress_size) file_size = 0xffffffff compress_size = 0xffffffff else: file_size = zinfo.file_size compress_size = zinfo.compress_size if zinfo.header_offset > ZIP64_LIMIT: extra.append(zinfo.header_offset) header_offset = 0xffffffffL else: header_offset = zinfo.header_offset extra_data = zinfo.extra if extra: # Append a ZIP64 field to the extra's extra_data = struct.pack( '<HH' + 'Q'*len(extra), 1, 8*len(extra), *extra) + extra_data extract_version = max(45, zinfo.extract_version) create_version = max(45, zinfo.create_version) else: extract_version = zinfo.extract_version create_version = zinfo.create_version try: filename, flag_bits = zinfo._encodeFilenameFlags() centdir = struct.pack(structCentralDir, stringCentralDir, create_version, zinfo.create_system, extract_version, zinfo.reserved, flag_bits, zinfo.compress_type, dostime, dosdate, zinfo.CRC, compress_size, file_size, len(filename), len(extra_data), len(zinfo.comment), 0, zinfo.internal_attr, zinfo.external_attr, header_offset) except DeprecationWarning: print >>sys.stderr, (structCentralDir, stringCentralDir, create_version, zinfo.create_system, extract_version, zinfo.reserved, zinfo.flag_bits, zinfo.compress_type, dostime, dosdate, zinfo.CRC, compress_size, file_size, len(zinfo.filename), len(extra_data), len(zinfo.comment), 0, zinfo.internal_attr, zinfo.external_attr, header_offset) raise self.fp.write(centdir) self.fp.write(filename) self.fp.write(extra_data) self.fp.write(zinfo.comment) pos2 = self.fp.tell() # Write end-of-zip-archive record centDirCount = count centDirSize = pos2 - pos1 centDirOffset = pos1 if (centDirCount >= ZIP_FILECOUNT_LIMIT or centDirOffset > ZIP64_LIMIT or centDirSize > ZIP64_LIMIT): # Need to write the ZIP64 end-of-archive records zip64endrec = struct.pack( structEndArchive64, stringEndArchive64, 44, 45, 45, 0, 0, centDirCount, centDirCount, centDirSize, centDirOffset) self.fp.write(zip64endrec) zip64locrec = struct.pack( structEndArchive64Locator, stringEndArchive64Locator, 0, pos2, 1) self.fp.write(zip64locrec) centDirCount = min(centDirCount, 0xFFFF) centDirSize = min(centDirSize, 0xFFFFFFFF) centDirOffset = min(centDirOffset, 0xFFFFFFFF) # check for valid comment length if len(self.comment) >= ZIP_MAX_COMMENT: if self.debug > 0: msg = 'Archive comment is too long; truncating to %d bytes' \ % ZIP_MAX_COMMENT self.comment = self.comment[:ZIP_MAX_COMMENT] endrec = struct.pack(structEndArchive, stringEndArchive, 0, 0, centDirCount, centDirCount, centDirSize, centDirOffset, len(self.comment)) self.fp.write(endrec) self.fp.write(self.comment) self.fp.flush() if not self._filePassed: self.fp.close() self.fp = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "fp", "is", "None", ":", "return", "if", "self", ".", "mode", "in", "(", "\"w\"", ",", "\"a\"", ")", "and", "self", ".", "_didModify", ":", "# write ending records", "count", "=", "0", "pos1",...
https://github.com/smart-mobile-software/gitstack/blob/d9fee8f414f202143eb6e620529e8e5539a2af56/python/Lib/zipfile.py#L1152-L1260
jd/tenacity
005ef22015ec4fda8646bf9dce7aaa1a4fa121d2
tenacity/wait.py
python
wait_base.__radd__
(self, other: "wait_base")
return self.__add__(other)
[]
def __radd__(self, other: "wait_base") -> typing.Union["wait_combine", "wait_base"]: # make it possible to use multiple waits with the built-in sum function if other == 0: return self return self.__add__(other)
[ "def", "__radd__", "(", "self", ",", "other", ":", "\"wait_base\"", ")", "->", "typing", ".", "Union", "[", "\"wait_combine\"", ",", "\"wait_base\"", "]", ":", "# make it possible to use multiple waits with the built-in sum function", "if", "other", "==", "0", ":", ...
https://github.com/jd/tenacity/blob/005ef22015ec4fda8646bf9dce7aaa1a4fa121d2/tenacity/wait.py#L37-L41
albertz/music-player
d23586f5bf657cbaea8147223be7814d117ae73d
mac/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/netrepr.py
python
ObjectPool.referenceForObject
(self, obj)
return rval
[]
def referenceForObject(self, obj): obj_id = id(obj) rval = self.obj_ids.get(obj_id) if rval is None: ident = self._identfactory.next() rval = ObjectReference(self, ident, type_string(obj), obj, obj_id) rval = rval.alloc().autorelease() return rval
[ "def", "referenceForObject", "(", "self", ",", "obj", ")", ":", "obj_id", "=", "id", "(", "obj", ")", "rval", "=", "self", ".", "obj_ids", ".", "get", "(", "obj_id", ")", "if", "rval", "is", "None", ":", "ident", "=", "self", ".", "_identfactory", ...
https://github.com/albertz/music-player/blob/d23586f5bf657cbaea8147223be7814d117ae73d/mac/pyobjc-core/Examples/NonFunctional/RemotePyInterpreter/netrepr.py#L133-L140
Pext/Pext
f13e455e8003e7719e583dcff1fdb2826b6e10e0
pext/__main__.py
python
ModuleManager.unload
(self, index: int, for_reload=False, window=None)
Unload a module by tab index.
Unload a module by tab index.
[ "Unload", "a", "module", "by", "tab", "index", "." ]
def unload(self, index: int, for_reload=False, window=None) -> None: """Unload a module by tab index.""" Core.remove_module(index) if window: window.remove_module(index, for_reload)
[ "def", "unload", "(", "self", ",", "index", ":", "int", ",", "for_reload", "=", "False", ",", "window", "=", "None", ")", "->", "None", ":", "Core", ".", "remove_module", "(", "index", ")", "if", "window", ":", "window", ".", "remove_module", "(", "i...
https://github.com/Pext/Pext/blob/f13e455e8003e7719e583dcff1fdb2826b6e10e0/pext/__main__.py#L1455-L1459
k2kobayashi/sprocket
e16d9c8c49ef8aa15a5dec89bfb0049a9baf845e
example/download_speech_corpus.py
python
ExtensionList.itemize_in_directory
(self, directory, recurse=False)
Search for audio files with the designated extensions in the directory. Parameters ---------- directory : Path The path of the directory where audio files are searched for. recurse : bool `True` if audio files in subdirectories must be searched. Returns ------- Generator[Path, None, None] paths of audio files.
Search for audio files with the designated extensions in the directory.
[ "Search", "for", "audio", "files", "with", "the", "designated", "extensions", "in", "the", "directory", "." ]
def itemize_in_directory(self, directory, recurse=False): """ Search for audio files with the designated extensions in the directory. Parameters ---------- directory : Path The path of the directory where audio files are searched for. recurse : bool `True` if audio files in subdirectories must be searched. Returns ------- Generator[Path, None, None] paths of audio files. """ query_prefix = ("**/" if recurse else "") + "*." for extension in self.extensions: yield from directory.glob(query_prefix + extension)
[ "def", "itemize_in_directory", "(", "self", ",", "directory", ",", "recurse", "=", "False", ")", ":", "query_prefix", "=", "(", "\"**/\"", "if", "recurse", "else", "\"\"", ")", "+", "\"*.\"", "for", "extension", "in", "self", ".", "extensions", ":", "yield...
https://github.com/k2kobayashi/sprocket/blob/e16d9c8c49ef8aa15a5dec89bfb0049a9baf845e/example/download_speech_corpus.py#L247-L265
davidteather/TikTok-Api
a356324ab3171d473619fdf3e1dd71e5996cfc29
TikTokApi/tiktok.py
python
TikTokApi.get_music_object_full_by_api
(self, id, **kwargs)
return res["musicInfo"]
Returns a music object for a specific sound id, but using the API rather than HTML requests. ##### Parameters * id: The sound id to get the object for This can be found by using other methods.
Returns a music object for a specific sound id, but using the API rather than HTML requests.
[ "Returns", "a", "music", "object", "for", "a", "specific", "sound", "id", "but", "using", "the", "API", "rather", "than", "HTML", "requests", "." ]
def get_music_object_full_by_api(self, id, **kwargs): """Returns a music object for a specific sound id, but using the API rather than HTML requests. ##### Parameters * id: The sound id to get the object for This can be found by using other methods. """ ( region, language, proxy, maxCount, device_id, ) = self.__process_kwargs__(kwargs) kwargs["custom_device_id"] = device_id api_url = "{}node/share/music/-{}?{}".format( BASE_URL, id, self.__add_url_params__() ) res = self.get_data(url=api_url, **kwargs) if res.get("statusCode", 200) == 10203: raise TikTokNotFoundError() return res["musicInfo"]
[ "def", "get_music_object_full_by_api", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "(", "region", ",", "language", ",", "proxy", ",", "maxCount", ",", "device_id", ",", ")", "=", "self", ".", "__process_kwargs__", "(", "kwargs", ")", "kwar...
https://github.com/davidteather/TikTok-Api/blob/a356324ab3171d473619fdf3e1dd71e5996cfc29/TikTokApi/tiktok.py#L1022-L1047
ales-tsurko/cells
4cf7e395cd433762bea70cdc863a346f3a6fe1d0
packaging/macos/python/lib/python3.7/tkinter/tix.py
python
Tree.close
(self, entrypath)
Close the entry given by entryPath if its mode is close.
Close the entry given by entryPath if its mode is close.
[ "Close", "the", "entry", "given", "by", "entryPath", "if", "its", "mode", "is", "close", "." ]
def close(self, entrypath): '''Close the entry given by entryPath if its mode is close.''' self.tk.call(self._w, 'close', entrypath)
[ "def", "close", "(", "self", ",", "entrypath", ")", ":", "self", ".", "tk", ".", "call", "(", "self", ".", "_w", ",", "'close'", ",", "entrypath", ")" ]
https://github.com/ales-tsurko/cells/blob/4cf7e395cd433762bea70cdc863a346f3a6fe1d0/packaging/macos/python/lib/python3.7/tkinter/tix.py#L1522-L1524
omz/PythonistaAppTemplate
f560f93f8876d82a21d108977f90583df08d55af
PythonistaAppTemplate/PythonistaKit.framework/pylib/site-packages/reportlab/platypus/figures.py
python
FlexFigure._scale
(self,availWidth,availHeight)
Rescale to fit according to the rules, but only once
Rescale to fit according to the rules, but only once
[ "Rescale", "to", "fit", "according", "to", "the", "rules", "but", "only", "once" ]
def _scale(self,availWidth,availHeight): "Rescale to fit according to the rules, but only once" if self._scaleFactor is None or self.width>availWidth or self.height>availHeight: w, h = Figure.wrap(self, availWidth, availHeight) captionHeight = h - self.figureHeight if self.scaleFactor is None: #scale factor None means auto self._scaleFactor = min(availWidth/self.width,(availHeight-captionHeight)/self.figureHeight) else: #they provided a factor self._scaleFactor = self.scaleFactor if self._scaleFactor<1 and self.shrinkToFit: self.width = self.width * self._scaleFactor - 0.0001 self.figureHeight = self.figureHeight * self._scaleFactor elif self._scaleFactor>1 and self.growToFit: self.width = self.width*self._scaleFactor - 0.0001 self.figureHeight = self.figureHeight * self._scaleFactor
[ "def", "_scale", "(", "self", ",", "availWidth", ",", "availHeight", ")", ":", "if", "self", ".", "_scaleFactor", "is", "None", "or", "self", ".", "width", ">", "availWidth", "or", "self", ".", "height", ">", "availHeight", ":", "w", ",", "h", "=", "...
https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib/site-packages/reportlab/platypus/figures.py#L195-L210
pypa/setuptools
9f37366aab9cd8f6baa23e6a77cfdb8daf97757e
setuptools/_distutils/msvccompiler.py
python
MSVCCompiler.link
(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None)
[]
def link(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args(objects, output_dir) fixed_args = self._fix_lib_args(libraries, library_dirs, runtime_library_dirs) (libraries, library_dirs, runtime_library_dirs) = fixed_args if runtime_library_dirs: self.warn ("I don't know what to do with 'runtime_library_dirs': " + str (runtime_library_dirs)) lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) if output_dir is not None: output_filename = os.path.join(output_dir, output_filename) if self._need_link(objects, output_filename): if target_desc == CCompiler.EXECUTABLE: if debug: ldflags = self.ldflags_shared_debug[1:] else: ldflags = self.ldflags_shared[1:] else: if debug: ldflags = self.ldflags_shared_debug else: ldflags = self.ldflags_shared export_opts = [] for sym in (export_symbols or []): export_opts.append("/EXPORT:" + sym) ld_args = (ldflags + lib_opts + export_opts + objects + ['/OUT:' + output_filename]) # The MSVC linker generates .lib and .exp files, which cannot be # suppressed by any linker switches. The .lib files may even be # needed! Make sure they are generated in the temporary build # directory. Since they have different names for debug and release # builds, they can go into the same directory. if export_symbols is not None: (dll_name, dll_ext) = os.path.splitext( os.path.basename(output_filename)) implib_file = os.path.join( os.path.dirname(objects[0]), self.library_filename(dll_name)) ld_args.append ('/IMPLIB:' + implib_file) if extra_preargs: ld_args[:0] = extra_preargs if extra_postargs: ld_args.extend(extra_postargs) self.mkpath(os.path.dirname(output_filename)) try: self.spawn([self.linker] + ld_args) except DistutilsExecError as msg: raise LinkError(msg) else: log.debug("skipping %s (up-to-date)", output_filename)
[ "def", "link", "(", "self", ",", "target_desc", ",", "objects", ",", "output_filename", ",", "output_dir", "=", "None", ",", "libraries", "=", "None", ",", "library_dirs", "=", "None", ",", "runtime_library_dirs", "=", "None", ",", "export_symbols", "=", "No...
https://github.com/pypa/setuptools/blob/9f37366aab9cd8f6baa23e6a77cfdb8daf97757e/setuptools/_distutils/msvccompiler.py#L453-L529
IOActive/XDiFF
552d3394e119ca4ced8115f9fd2d7e26760e40b1
classes/db.py
python
Db.get_software
(self)
return self.restrict_software
Get the current software ids restriction
Get the current software ids restriction
[ "Get", "the", "current", "software", "ids", "restriction" ]
def get_software(self): """Get the current software ids restriction""" return self.restrict_software
[ "def", "get_software", "(", "self", ")", ":", "return", "self", ".", "restrict_software" ]
https://github.com/IOActive/XDiFF/blob/552d3394e119ca4ced8115f9fd2d7e26760e40b1/classes/db.py#L100-L102
tdryer/hangups
f0b37be1d46e71b30337227d7c46192cc726dcb4
examples/common.py
python
run_example
(example_coroutine, *extra_args)
Run a hangups example coroutine. Args: example_coroutine (coroutine): Coroutine to run with a connected hangups client and arguments namespace as arguments. extra_args (str): Any extra command line arguments required by the example.
Run a hangups example coroutine.
[ "Run", "a", "hangups", "example", "coroutine", "." ]
def run_example(example_coroutine, *extra_args): """Run a hangups example coroutine. Args: example_coroutine (coroutine): Coroutine to run with a connected hangups client and arguments namespace as arguments. extra_args (str): Any extra command line arguments required by the example. """ args = _get_parser(extra_args).parse_args() logging.basicConfig(level=logging.DEBUG if args.debug else logging.WARNING) # Obtain hangups authentication cookies, prompting for credentials from # standard input if necessary. cookies = hangups.auth.get_auth_stdin(args.token_path) client = hangups.Client(cookies) loop = asyncio.get_event_loop() task = asyncio.ensure_future(_async_main(example_coroutine, client, args), loop=loop) try: loop.run_until_complete(task) except KeyboardInterrupt: task.cancel() loop.run_until_complete(task) finally: loop.close()
[ "def", "run_example", "(", "example_coroutine", ",", "*", "extra_args", ")", ":", "args", "=", "_get_parser", "(", "extra_args", ")", ".", "parse_args", "(", ")", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", "if", "args", ".",...
https://github.com/tdryer/hangups/blob/f0b37be1d46e71b30337227d7c46192cc726dcb4/examples/common.py#L12-L37
nschloe/quadpy
c4c076d8ddfa968486a2443a95e2fb3780dcde0f
src/quadpy/e2r2/_helpers.py
python
E2r2Scheme.plot
(self, show_axes=False)
[]
def plot(self, show_axes=False): from matplotlib import pyplot as plt ax = plt.gca() plt.axis("equal") if not show_axes: ax.set_axis_off() I0 = 2 * math.pi plot_disks(plt, self.points.T, self.weights, I0)
[ "def", "plot", "(", "self", ",", "show_axes", "=", "False", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "ax", "=", "plt", ".", "gca", "(", ")", "plt", ".", "axis", "(", "\"equal\"", ")", "if", "not", "show_axes", ":", "ax", "."...
https://github.com/nschloe/quadpy/blob/c4c076d8ddfa968486a2443a95e2fb3780dcde0f/src/quadpy/e2r2/_helpers.py#L28-L38
dbsr/vimfox
4a0145937226843b4b8b5681136ab9a45fb5d066
vimfox/server/server.py
python
send_vimfox_file
(filename)
[]
def send_vimfox_file(filename): app.logger.info(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', filename)) try: return send_file(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', filename)) except: return Response(':(', status=404)
[ "def", "send_vimfox_file", "(", "filename", ")", ":", "app", ".", "logger", ".", "info", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'assets'"...
https://github.com/dbsr/vimfox/blob/4a0145937226843b4b8b5681136ab9a45fb5d066/vimfox/server/server.py#L18-L23
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py
python
WorkerChannelList.__repr__
(self)
return '<Twilio.Taskrouter.V1.WorkerChannelList>'
Provide a friendly representation :returns: Machine friendly representation :rtype: str
Provide a friendly representation
[ "Provide", "a", "friendly", "representation" ]
def __repr__(self): """ Provide a friendly representation :returns: Machine friendly representation :rtype: str """ return '<Twilio.Taskrouter.V1.WorkerChannelList>'
[ "def", "__repr__", "(", "self", ")", ":", "return", "'<Twilio.Taskrouter.V1.WorkerChannelList>'" ]
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/taskrouter/v1/workspace/worker/worker_channel.py#L145-L152
stoq/stoq
c26991644d1affcf96bc2e0a0434796cabdf8448
stoqlib/domain/workorder.py
python
WorkOrder.finish
(self, current_branch: Branch, user: LoginUser)
Finishes this work order's task The :obj:`.execution_responsible` has finished working on this order's task. It's possible now to give the equipment back to the |client| and create a |sale| so we are able to :meth:`deliver <.deliver>` this order.
Finishes this work order's task
[ "Finishes", "this", "work", "order", "s", "task" ]
def finish(self, current_branch: Branch, user: LoginUser): """Finishes this work order's task The :obj:`.execution_responsible` has finished working on this order's task. It's possible now to give the equipment back to the |client| and create a |sale| so we are able to :meth:`deliver <.deliver>` this order. """ assert self.can_finish(current_branch) self.finish_date = localnow() # Make sure we are not overwriting this value, since we can reopen the # order and finish again if not self.execution_branch: self.execution_branch = current_branch self._change_status(self.STATUS_WORK_FINISHED, user)
[ "def", "finish", "(", "self", ",", "current_branch", ":", "Branch", ",", "user", ":", "LoginUser", ")", ":", "assert", "self", ".", "can_finish", "(", "current_branch", ")", "self", ".", "finish_date", "=", "localnow", "(", ")", "# Make sure we are not overwri...
https://github.com/stoq/stoq/blob/c26991644d1affcf96bc2e0a0434796cabdf8448/stoqlib/domain/workorder.py#L1085-L1099
collinsctk/PyQYT
7af3673955f94ff1b2df2f94220cd2dab2e252af
ExtentionPackages/tornado/auth.py
python
OpenIdMixin.get_authenticated_user
(self, callback, http_client=None)
Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the `authenticate_redirect()` method (which is often the same as the one that calls it; in that case you would call `get_authenticated_user` if the ``openid.mode`` parameter is present and `authenticate_redirect` if it is not). The result of this method will generally be used to set a cookie.
Fetches the authenticated user data upon redirect.
[ "Fetches", "the", "authenticated", "user", "data", "upon", "redirect", "." ]
def get_authenticated_user(self, callback, http_client=None): """Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the `authenticate_redirect()` method (which is often the same as the one that calls it; in that case you would call `get_authenticated_user` if the ``openid.mode`` parameter is present and `authenticate_redirect` if it is not). The result of this method will generally be used to set a cookie. """ # Verify the OpenID response via direct request to the OP args = dict((k, v[-1]) for k, v in self.request.arguments.items()) args["openid.mode"] = u("check_authentication") url = self._OPENID_ENDPOINT if http_client is None: http_client = self.get_auth_http_client() http_client.fetch(url, functools.partial( self._on_authentication_verified, callback), method="POST", body=urllib_parse.urlencode(args))
[ "def", "get_authenticated_user", "(", "self", ",", "callback", ",", "http_client", "=", "None", ")", ":", "# Verify the OpenID response via direct request to the OP", "args", "=", "dict", "(", "(", "k", ",", "v", "[", "-", "1", "]", ")", "for", "k", ",", "v"...
https://github.com/collinsctk/PyQYT/blob/7af3673955f94ff1b2df2f94220cd2dab2e252af/ExtentionPackages/tornado/auth.py#L178-L197
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/categories/category_with_axiom.py
python
CategoryWithAxiom.extra_super_categories
(self)
return []
Return the extra super categories of a category with axiom. Default implementation which returns ``[]``. EXAMPLES:: sage: FiniteSets().extra_super_categories() []
Return the extra super categories of a category with axiom.
[ "Return", "the", "extra", "super", "categories", "of", "a", "category", "with", "axiom", "." ]
def extra_super_categories(self): """ Return the extra super categories of a category with axiom. Default implementation which returns ``[]``. EXAMPLES:: sage: FiniteSets().extra_super_categories() [] """ return []
[ "def", "extra_super_categories", "(", "self", ")", ":", "return", "[", "]" ]
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/categories/category_with_axiom.py#L2123-L2134
cuthbertLab/music21
bd30d4663e52955ed922c10fdf541419d8c67671
music21/text.py
python
Trigram.makeWords
(self, count)
return ''.join(text)
returns a string of made-up words based on the known text.
returns a string of made-up words based on the known text.
[ "returns", "a", "string", "of", "made", "-", "up", "words", "based", "on", "the", "known", "text", "." ]
def makeWords(self, count): ''' returns a string of made-up words based on the known text. ''' text = [] k = ' ' while count: n = self.likely(k) text.append(n) k = k[1] + n if n in ' \t': count -= 1 return ''.join(text)
[ "def", "makeWords", "(", "self", ",", "count", ")", ":", "text", "=", "[", "]", "k", "=", "' '", "while", "count", ":", "n", "=", "self", ".", "likely", "(", "k", ")", "text", ".", "append", "(", "n", ")", "k", "=", "k", "[", "1", "]", "+"...
https://github.com/cuthbertLab/music21/blob/bd30d4663e52955ed922c10fdf541419d8c67671/music21/text.py#L579-L591
phimpme/phimpme-generator
ba6d11190b9016238f27672e1ad55e6a875b74a0
Phimpme/site-packages/coverage/files.py
python
FnmatchMatcher.match
(self, fpath)
return False
Does `fpath` match one of our filename patterns?
Does `fpath` match one of our filename patterns?
[ "Does", "fpath", "match", "one", "of", "our", "filename", "patterns?" ]
def match(self, fpath): """Does `fpath` match one of our filename patterns?""" for pat in self.pats: if fnmatch.fnmatch(fpath, pat): return True return False
[ "def", "match", "(", "self", ",", "fpath", ")", ":", "for", "pat", "in", "self", ".", "pats", ":", "if", "fnmatch", ".", "fnmatch", "(", "fpath", ",", "pat", ")", ":", "return", "True", "return", "False" ]
https://github.com/phimpme/phimpme-generator/blob/ba6d11190b9016238f27672e1ad55e6a875b74a0/Phimpme/site-packages/coverage/files.py#L188-L193
O365/python-o365
7f77005c3cee8177d0141e79b8eda8a7b60c5124
O365/calendar.py
python
Event.organizer
(self)
return self.__organizer
Organizer of the meeting event :rtype: Recipient
Organizer of the meeting event
[ "Organizer", "of", "the", "meeting", "event" ]
def organizer(self): """ Organizer of the meeting event :rtype: Recipient """ return self.__organizer
[ "def", "organizer", "(", "self", ")", ":", "return", "self", ".", "__organizer" ]
https://github.com/O365/python-o365/blob/7f77005c3cee8177d0141e79b8eda8a7b60c5124/O365/calendar.py#L1195-L1200
gorakhargosh/watchdog
77e1f4668bc42b4a8706b181d882fd68c05ab8b9
src/watchdog/utils/patterns.py
python
match_any_paths
(paths, included_patterns=None, excluded_patterns=None, case_sensitive=True)
return False
Matches from a set of paths based on acceptable patterns and ignorable patterns. :param pathnames: A list of path names that will be filtered based on matching and ignored patterns. :param included_patterns: Allow filenames matching wildcard patterns specified in this list. If no pattern list is specified, ["*"] is used as the default pattern, which matches all files. :param excluded_patterns: Ignores filenames matching wildcard patterns specified in this list. If no pattern list is specified, no files are ignored. :param case_sensitive: ``True`` if matching should be case-sensitive; ``False`` otherwise. :returns: ``True`` if any of the paths matches; ``False`` otherwise.
Matches from a set of paths based on acceptable patterns and ignorable patterns. :param pathnames: A list of path names that will be filtered based on matching and ignored patterns. :param included_patterns: Allow filenames matching wildcard patterns specified in this list. If no pattern list is specified, ["*"] is used as the default pattern, which matches all files. :param excluded_patterns: Ignores filenames matching wildcard patterns specified in this list. If no pattern list is specified, no files are ignored. :param case_sensitive: ``True`` if matching should be case-sensitive; ``False`` otherwise. :returns: ``True`` if any of the paths matches; ``False`` otherwise.
[ "Matches", "from", "a", "set", "of", "paths", "based", "on", "acceptable", "patterns", "and", "ignorable", "patterns", ".", ":", "param", "pathnames", ":", "A", "list", "of", "path", "names", "that", "will", "be", "filtered", "based", "on", "matching", "an...
def match_any_paths(paths, included_patterns=None, excluded_patterns=None, case_sensitive=True): """ Matches from a set of paths based on acceptable patterns and ignorable patterns. :param pathnames: A list of path names that will be filtered based on matching and ignored patterns. :param included_patterns: Allow filenames matching wildcard patterns specified in this list. If no pattern list is specified, ["*"] is used as the default pattern, which matches all files. :param excluded_patterns: Ignores filenames matching wildcard patterns specified in this list. If no pattern list is specified, no files are ignored. :param case_sensitive: ``True`` if matching should be case-sensitive; ``False`` otherwise. :returns: ``True`` if any of the paths matches; ``False`` otherwise. """ included = ["*"] if included_patterns is None else included_patterns excluded = [] if excluded_patterns is None else excluded_patterns for path in paths: if _match_path(path, set(included), set(excluded), case_sensitive): return True return False
[ "def", "match_any_paths", "(", "paths", ",", "included_patterns", "=", "None", ",", "excluded_patterns", "=", "None", ",", "case_sensitive", "=", "True", ")", ":", "included", "=", "[", "\"*\"", "]", "if", "included_patterns", "is", "None", "else", "included_p...
https://github.com/gorakhargosh/watchdog/blob/77e1f4668bc42b4a8706b181d882fd68c05ab8b9/src/watchdog/utils/patterns.py#L62-L87
google-research/albert
932b41f0319fbef7efd069d5ff545e3358574e19
tokenization.py
python
encode_pieces
(sp_model, text, return_unicode=True, sample=False)
return new_pieces
turn sentences into word pieces.
turn sentences into word pieces.
[ "turn", "sentences", "into", "word", "pieces", "." ]
def encode_pieces(sp_model, text, return_unicode=True, sample=False): """turn sentences into word pieces.""" if six.PY2 and isinstance(text, six.text_type): text = six.ensure_binary(text, "utf-8") if not sample: pieces = sp_model.EncodeAsPieces(text) else: pieces = sp_model.SampleEncodeAsPieces(text, 64, 0.1) new_pieces = [] for piece in pieces: piece = printable_text(piece) if len(piece) > 1 and piece[-1] == "," and piece[-2].isdigit(): cur_pieces = sp_model.EncodeAsPieces( six.ensure_binary(piece[:-1]).replace(SPIECE_UNDERLINE, b"")) if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE: if len(cur_pieces[0]) == 1: cur_pieces = cur_pieces[1:] else: cur_pieces[0] = cur_pieces[0][1:] cur_pieces.append(piece[-1]) new_pieces.extend(cur_pieces) else: new_pieces.append(piece) # note(zhiliny): convert back to unicode for py2 if six.PY2 and return_unicode: ret_pieces = [] for piece in new_pieces: if isinstance(piece, str): piece = six.ensure_text(piece, "utf-8") ret_pieces.append(piece) new_pieces = ret_pieces return new_pieces
[ "def", "encode_pieces", "(", "sp_model", ",", "text", ",", "return_unicode", "=", "True", ",", "sample", "=", "False", ")", ":", "if", "six", ".", "PY2", "and", "isinstance", "(", "text", ",", "six", ".", "text_type", ")", ":", "text", "=", "six", "....
https://github.com/google-research/albert/blob/932b41f0319fbef7efd069d5ff545e3358574e19/tokenization.py#L54-L89
caktus/django-timepiece
52515dec027664890efbc535429e1ba1ee152f40
timepiece/reports/forms.py
python
BillableHoursReportForm.__init__
(self, *args, **kwargs)
If the 'select_all' argument is given, any data values for users, activities, and project_types are overwritten with all available choices.
If the 'select_all' argument is given, any data values for users, activities, and project_types are overwritten with all available choices.
[ "If", "the", "select_all", "argument", "is", "given", "any", "data", "values", "for", "users", "activities", "and", "project_types", "are", "overwritten", "with", "all", "available", "choices", "." ]
def __init__(self, *args, **kwargs): """ If the 'select_all' argument is given, any data values for users, activities, and project_types are overwritten with all available choices. """ select_all = kwargs.pop('select_all', False) super(BillableHoursReportForm, self).__init__(*args, **kwargs) self.fields['from_date'].required = True self.fields['to_date'].required = True user_ids = Entry.no_join.values_list('user', flat=True) users = User.objects.filter(id__in=user_ids) activities = Activity.objects.all() project_types = Attribute.objects.all() self.fields['users'].queryset = users self.fields['activities'].queryset = activities self.fields['project_types'].queryset = project_types if select_all: self.data['users'] = list(users.values_list('id', flat=True)) self.data['activities'] = list(activities.values_list('id', flat=True)) self.data['project_types'] = list(project_types.values_list('id', flat=True))
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "select_all", "=", "kwargs", ".", "pop", "(", "'select_all'", ",", "False", ")", "super", "(", "BillableHoursReportForm", ",", "self", ")", ".", "__init__", "(", "*", ...
https://github.com/caktus/django-timepiece/blob/52515dec027664890efbc535429e1ba1ee152f40/timepiece/reports/forms.py#L30-L56
sham00n/buster
131437e6128b6ad85fa2a9f17ad51311c885b8c2
buster/lib/modules/github.py
python
email2github
(email,response)
[]
def email2github(email,response): try: if response.status_code==200: data=response.json() if data['items'] != []: return data['items'][0]['html_url'] else: return "" else: return "" except: print("[=]Warning:Something went wrong while attempting to scrap github.com") return ""
[ "def", "email2github", "(", "email", ",", "response", ")", ":", "try", ":", "if", "response", ".", "status_code", "==", "200", ":", "data", "=", "response", ".", "json", "(", ")", "if", "data", "[", "'items'", "]", "!=", "[", "]", ":", "return", "d...
https://github.com/sham00n/buster/blob/131437e6128b6ad85fa2a9f17ad51311c885b8c2/buster/lib/modules/github.py#L4-L18
scrapinghub/splash
802d8391984bae049ef95a3fe1a74feaee95a233
splash/har_builder.py
python
HarBuilder.store_reply_finished
(self, req_id, reply, content)
Store information about a finished reply.
Store information about a finished reply.
[ "Store", "information", "about", "a", "finished", "reply", "." ]
def store_reply_finished(self, req_id, reply, content): """ Store information about a finished reply. """ if not self.log.has_entry(req_id): return entry = self.log.get_mutable_entry(req_id) entry["_splash_processing_state"] = self.REQUEST_FINISHED # update timings now = datetime.utcnow() start_time = entry['_tmp']['start_time'] response_start_time = entry['_tmp']['response_start_time'] receive_time = get_duration(response_start_time, now) total_time = get_duration(start_time, now) entry["timings"]["receive"] = receive_time entry["time"] = total_time if not entry["timings"]["send"]: wait_time = entry["timings"]["wait"] entry["timings"]["send"] = total_time - receive_time - wait_time if entry["timings"]["send"] < 1e-6: entry["timings"]["send"] = 0 # update other reply information entry["response"].update(reply2har(reply, content=content))
[ "def", "store_reply_finished", "(", "self", ",", "req_id", ",", "reply", ",", "content", ")", ":", "if", "not", "self", ".", "log", ".", "has_entry", "(", "req_id", ")", ":", "return", "entry", "=", "self", ".", "log", ".", "get_mutable_entry", "(", "r...
https://github.com/scrapinghub/splash/blob/802d8391984bae049ef95a3fe1a74feaee95a233/splash/har_builder.py#L122-L149
unknown-horizons/unknown-horizons
7397fb333006d26c3d9fe796c7bd9cb8c3b43a49
horizons/scenario/conditions.py
python
_get_player_settlements
(session)
return session.world.player.settlements
Helper generator, returns settlements of local player.
Helper generator, returns settlements of local player.
[ "Helper", "generator", "returns", "settlements", "of", "local", "player", "." ]
def _get_player_settlements(session): """Helper generator, returns settlements of local player.""" return session.world.player.settlements
[ "def", "_get_player_settlements", "(", "session", ")", ":", "return", "session", ".", "world", ".", "player", ".", "settlements" ]
https://github.com/unknown-horizons/unknown-horizons/blob/7397fb333006d26c3d9fe796c7bd9cb8c3b43a49/horizons/scenario/conditions.py#L254-L256
EducationalTestingService/skll
1502fe8455cbb2c76cfc819db66f02f8ae11d321
skll/experiments/utils.py
python
_get_stat_float
(label_result_dict, stat)
A helper function to get output for the precision, recall, and f-score columns in the confusion matrix. Parameters ---------- label_result_dict : dict Dictionary containing the stat we'd like to retrieve for a particular label. stat : str The statistic we're looking for in the dictionary. Returns ------- stat_float : float The value of the stat if it's in the dictionary, and NaN otherwise.
A helper function to get output for the precision, recall, and f-score columns in the confusion matrix.
[ "A", "helper", "function", "to", "get", "output", "for", "the", "precision", "recall", "and", "f", "-", "score", "columns", "in", "the", "confusion", "matrix", "." ]
def _get_stat_float(label_result_dict, stat): """ A helper function to get output for the precision, recall, and f-score columns in the confusion matrix. Parameters ---------- label_result_dict : dict Dictionary containing the stat we'd like to retrieve for a particular label. stat : str The statistic we're looking for in the dictionary. Returns ------- stat_float : float The value of the stat if it's in the dictionary, and NaN otherwise. """ if stat in label_result_dict and label_result_dict[stat] is not None: return label_result_dict[stat] else: return float('nan')
[ "def", "_get_stat_float", "(", "label_result_dict", ",", "stat", ")", ":", "if", "stat", "in", "label_result_dict", "and", "label_result_dict", "[", "stat", "]", "is", "not", "None", ":", "return", "label_result_dict", "[", "stat", "]", "else", ":", "return", ...
https://github.com/EducationalTestingService/skll/blob/1502fe8455cbb2c76cfc819db66f02f8ae11d321/skll/experiments/utils.py#L236-L258
IntelPython/sdc
1ebf55c00ef38dfbd401a70b3945e352a5a38b87
sdc/timsort.py
python
sort
(key_arrs, lo, hi, data)
[]
def sort(key_arrs, lo, hi, data): # pragma: no cover nRemaining = hi - lo if nRemaining < 2: return # Arrays of size 0 and 1 are always sorted # If array is small, do a "mini-TimSort" with no merges if nRemaining < MIN_MERGE: initRunLen = countRunAndMakeAscending(key_arrs, lo, hi, data) binarySort(key_arrs, lo, hi, lo + initRunLen, data) return # March over the array once, left to right, finding natural runs, # extending short natural runs to minRun elements, and merging runs # to maintain stack invariant. (stackSize, runBase, runLen, tmpLength, tmp, tmp_data, minGallop) = init_sort_start(key_arrs, data) minRun = minRunLength(nRemaining) while True: # emulating do-while # Identify next run run_len = countRunAndMakeAscending(key_arrs, lo, hi, data) # If run is short, extend to min(minRun, nRemaining) if run_len < minRun: force = nRemaining if nRemaining <= minRun else minRun binarySort(key_arrs, lo, lo + force, lo + run_len, data) run_len = force # Push run onto pending-run stack, and maybe merge stackSize = pushRun(stackSize, runBase, runLen, lo, run_len) stackSize, tmpLength, tmp, tmp_data, minGallop = mergeCollapse( stackSize, runBase, runLen, key_arrs, data, tmpLength, tmp, tmp_data, minGallop) # Advance to find next run lo += run_len nRemaining -= run_len if nRemaining == 0: break # Merge all remaining runs to complete sort assert lo == hi stackSize, tmpLength, tmp, tmp_data, minGallop = mergeForceCollapse( stackSize, runBase, runLen, key_arrs, data, tmpLength, tmp, tmp_data, minGallop) assert stackSize == 1
[ "def", "sort", "(", "key_arrs", ",", "lo", ",", "hi", ",", "data", ")", ":", "# pragma: no cover", "nRemaining", "=", "hi", "-", "lo", "if", "nRemaining", "<", "2", ":", "return", "# Arrays of size 0 and 1 are always sorted", "# If array is small, do a \"mini-TimSor...
https://github.com/IntelPython/sdc/blob/1ebf55c00ef38dfbd401a70b3945e352a5a38b87/sdc/timsort.py#L88-L135
Parsely/pykafka
e7665bf36bfe521050fdcb017c68e92365bd89ed
pykafka/handlers.py
python
ResponseFuture.get
(self, response_cls=None, timeout=None, **response_kwargs)
Block until data is ready and return. Raises an exception if there was an error.
Block until data is ready and return.
[ "Block", "until", "data", "is", "ready", "and", "return", "." ]
def get(self, response_cls=None, timeout=None, **response_kwargs): """Block until data is ready and return. Raises an exception if there was an error. """ self._ready.wait(timeout) if self.error: raise self.error if response_cls: return response_cls(self.response, **response_kwargs) else: return self.response
[ "def", "get", "(", "self", ",", "response_cls", "=", "None", ",", "timeout", "=", "None", ",", "*", "*", "response_kwargs", ")", ":", "self", ".", "_ready", ".", "wait", "(", "timeout", ")", "if", "self", ".", "error", ":", "raise", "self", ".", "e...
https://github.com/Parsely/pykafka/blob/e7665bf36bfe521050fdcb017c68e92365bd89ed/pykafka/handlers.py#L67-L78
ukBaz/python-bluezero
e6b4e96342de6c66571a6660d711c018f8c6b470
bluezero/adapter.py
python
Adapter.discoverabletimeout
(self)
return self.adapter_props.Get(constants.ADAPTER_INTERFACE, 'DiscoverableTimeout')
Discoverable timeout of the Adapter.
Discoverable timeout of the Adapter.
[ "Discoverable", "timeout", "of", "the", "Adapter", "." ]
def discoverabletimeout(self): """Discoverable timeout of the Adapter.""" return self.adapter_props.Get(constants.ADAPTER_INTERFACE, 'DiscoverableTimeout')
[ "def", "discoverabletimeout", "(", "self", ")", ":", "return", "self", ".", "adapter_props", ".", "Get", "(", "constants", ".", "ADAPTER_INTERFACE", ",", "'DiscoverableTimeout'", ")" ]
https://github.com/ukBaz/python-bluezero/blob/e6b4e96342de6c66571a6660d711c018f8c6b470/bluezero/adapter.py#L189-L192
scikit-hep/awkward-0.x
dd885bef15814f588b58944d2505296df4aaae0e
awkward0/array/base.py
python
AwkwardArray.count
(self)
return self._reduce(None, 0, None)
[]
def count(self): return self._reduce(None, 0, None)
[ "def", "count", "(", "self", ")", ":", "return", "self", ".", "_reduce", "(", "None", ",", "0", ",", "None", ")" ]
https://github.com/scikit-hep/awkward-0.x/blob/dd885bef15814f588b58944d2505296df4aaae0e/awkward0/array/base.py#L199-L200
theatlantic/django-nested-admin
2554f51f6d05489dd2d81b24c60b59781fda4e8a
nested_admin/__init__.py
python
module.__dir__
(self)
return result
Just show what we want to show.
Just show what we want to show.
[ "Just", "show", "what", "we", "want", "to", "show", "." ]
def __dir__(self): """Just show what we want to show.""" result = list(new_module.__all__) result.extend(('__file__', '__path__', '__doc__', '__all__', '__docformat__', '__name__', '__path__', '__package__', '__version__')) return result
[ "def", "__dir__", "(", "self", ")", ":", "result", "=", "list", "(", "new_module", ".", "__all__", ")", "result", ".", "extend", "(", "(", "'__file__'", ",", "'__path__'", ",", "'__doc__'", ",", "'__all__'", ",", "'__docformat__'", ",", "'__name__'", ",", ...
https://github.com/theatlantic/django-nested-admin/blob/2554f51f6d05489dd2d81b24c60b59781fda4e8a/nested_admin/__init__.py#L54-L60
dabeaz/python-cookbook
6e46b78e5644b3e5bf7426d900e2203b7cc630da
src/2/writing_a_simple_recursive_descent_parser/example.py
python
ExpressionEvaluator._expect
(self,toktype)
Consume next token if it matches toktype or raise SyntaxError
Consume next token if it matches toktype or raise SyntaxError
[ "Consume", "next", "token", "if", "it", "matches", "toktype", "or", "raise", "SyntaxError" ]
def _expect(self,toktype): 'Consume next token if it matches toktype or raise SyntaxError' if not self._accept(toktype): raise SyntaxError('Expected ' + toktype)
[ "def", "_expect", "(", "self", ",", "toktype", ")", ":", "if", "not", "self", ".", "_accept", "(", "toktype", ")", ":", "raise", "SyntaxError", "(", "'Expected '", "+", "toktype", ")" ]
https://github.com/dabeaz/python-cookbook/blob/6e46b78e5644b3e5bf7426d900e2203b7cc630da/src/2/writing_a_simple_recursive_descent_parser/example.py#L60-L63
google/tf-quant-finance
8fd723689ebf27ff4bb2bd2acb5f6091c5e07309
tf_quant_finance/experimental/pricing_platform/framework/core/processed_market_data.py
python
ProcessedMarketData.yield_curve
(self, curve_type: curve_types.CurveType)
The yield curve object.
The yield curve object.
[ "The", "yield", "curve", "object", "." ]
def yield_curve(self, curve_type: curve_types.CurveType) -> RateCurve: """The yield curve object.""" pass
[ "def", "yield_curve", "(", "self", ",", "curve_type", ":", "curve_types", ".", "CurveType", ")", "->", "RateCurve", ":", "pass" ]
https://github.com/google/tf-quant-finance/blob/8fd723689ebf27ff4bb2bd2acb5f6091c5e07309/tf_quant_finance/experimental/pricing_platform/framework/core/processed_market_data.py#L226-L228
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/django/contrib/staticfiles/handlers.py
python
StaticFilesHandler._should_handle
(self, path)
return path.startswith(self.base_url[2]) and not self.base_url[1]
Checks if the path should be handled. Ignores the path if: * the host is provided as part of the base_url * the request's path isn't under the media path (or equal)
Checks if the path should be handled. Ignores the path if:
[ "Checks", "if", "the", "path", "should", "be", "handled", ".", "Ignores", "the", "path", "if", ":" ]
def _should_handle(self, path): """ Checks if the path should be handled. Ignores the path if: * the host is provided as part of the base_url * the request's path isn't under the media path (or equal) """ return path.startswith(self.base_url[2]) and not self.base_url[1]
[ "def", "_should_handle", "(", "self", ",", "path", ")", ":", "return", "path", ".", "startswith", "(", "self", ".", "base_url", "[", "2", "]", ")", "and", "not", "self", ".", "base_url", "[", "1", "]" ]
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/django/contrib/staticfiles/handlers.py#L31-L38
holoviz/datashader
25578abde75c7fa28c6633b33cb8d8a1e433da67
datashader/glyphs/line.py
python
LinesAxis1.compute_x_bounds
(self, df)
return self.maybe_expand_bounds((min(mins), max(maxes)))
[]
def compute_x_bounds(self, df): xs = tuple(df[xlabel] for xlabel in self.x) bounds_list = [self._compute_bounds(xcol) for xcol in xs] mins, maxes = zip(*bounds_list) return self.maybe_expand_bounds((min(mins), max(maxes)))
[ "def", "compute_x_bounds", "(", "self", ",", "df", ")", ":", "xs", "=", "tuple", "(", "df", "[", "xlabel", "]", "for", "xlabel", "in", "self", ".", "x", ")", "bounds_list", "=", "[", "self", ".", "_compute_bounds", "(", "xcol", ")", "for", "xcol", ...
https://github.com/holoviz/datashader/blob/25578abde75c7fa28c6633b33cb8d8a1e433da67/datashader/glyphs/line.py#L205-L211
PokemonGoF/PokemonGo-Bot-Desktop
4bfa94f0183406c6a86f93645eff7abd3ad4ced8
build/pywin/Lib/wsgiref/handlers.py
python
BaseHandler.handle_error
(self)
Log current error, and send error output to client if possible
Log current error, and send error output to client if possible
[ "Log", "current", "error", "and", "send", "error", "output", "to", "client", "if", "possible" ]
def handle_error(self): """Log current error, and send error output to client if possible""" self.log_exception(sys.exc_info()) if not self.headers_sent: self.result = self.error_output(self.environ, self.start_response) self.finish_response()
[ "def", "handle_error", "(", "self", ")", ":", "self", ".", "log_exception", "(", "sys", ".", "exc_info", "(", ")", ")", "if", "not", "self", ".", "headers_sent", ":", "self", ".", "result", "=", "self", ".", "error_output", "(", "self", ".", "environ",...
https://github.com/PokemonGoF/PokemonGo-Bot-Desktop/blob/4bfa94f0183406c6a86f93645eff7abd3ad4ced8/build/pywin/Lib/wsgiref/handlers.py#L301-L306
tobegit3hub/deep_image_model
8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e
java_predict_client/src/main/proto/tensorflow/python/training/moving_averages.py
python
_zero_debias
(unbiased_var, value, decay)
Compute the delta required for a debiased Variable. All exponential moving averages initialized with Tensors are initialized to 0, and therefore are biased to 0. Variables initialized to 0 and used as EMAs are similarly biased. This function creates the debias updated amount according to a scale factor, as in https://arxiv.org/abs/1412.6980. To demonstrate the bias the results from 0-initialization, take an EMA that was initialized to `0` with decay `b`. After `t` timesteps of seeing the constant `c`, the variable have the following value: ``` EMA = 0*b^(t) + c*(1 - b)*b^(t-1) + c*(1 - b)*b^(t-2) + ... = c*(1 - b^t) ``` To have the true value `c`, we would divide by the scale factor `1 - b^t`. In order to perform debiasing, we use two shadow variables. One keeps track of the biased estimate, and the other keeps track of the number of updates that have occurred. Args: unbiased_var: A Variable representing the current value of the unbiased EMA. value: A Tensor representing the most recent value. decay: A Tensor representing `1-decay` for the EMA. Returns: The amount that the unbiased variable should be updated. Computing this tensor will also update the shadow variables appropriately.
Compute the delta required for a debiased Variable.
[ "Compute", "the", "delta", "required", "for", "a", "debiased", "Variable", "." ]
def _zero_debias(unbiased_var, value, decay): """Compute the delta required for a debiased Variable. All exponential moving averages initialized with Tensors are initialized to 0, and therefore are biased to 0. Variables initialized to 0 and used as EMAs are similarly biased. This function creates the debias updated amount according to a scale factor, as in https://arxiv.org/abs/1412.6980. To demonstrate the bias the results from 0-initialization, take an EMA that was initialized to `0` with decay `b`. After `t` timesteps of seeing the constant `c`, the variable have the following value: ``` EMA = 0*b^(t) + c*(1 - b)*b^(t-1) + c*(1 - b)*b^(t-2) + ... = c*(1 - b^t) ``` To have the true value `c`, we would divide by the scale factor `1 - b^t`. In order to perform debiasing, we use two shadow variables. One keeps track of the biased estimate, and the other keeps track of the number of updates that have occurred. Args: unbiased_var: A Variable representing the current value of the unbiased EMA. value: A Tensor representing the most recent value. decay: A Tensor representing `1-decay` for the EMA. Returns: The amount that the unbiased variable should be updated. Computing this tensor will also update the shadow variables appropriately. """ with variable_scope.variable_scope( "ZeroDebias", values=[unbiased_var, value, decay]) as scope: with ops.colocate_with(unbiased_var): biased_var = variable_scope.get_variable( unbiased_var.op.name + "_biased", initializer=init_ops.zeros_initializer( unbiased_var.get_shape(), dtype=unbiased_var.dtype), trainable=False) # Initializing the local_step to `0` would cause problems with the # debiasing equation, so we instead initialize to `1`. local_step = variable_scope.get_variable( unbiased_var.op.name + "_local_step", initializer=init_ops.ones_initializer([], dtype=unbiased_var.dtype), trainable=False) # Get an update ops for both shadow variables. update_biased = state_ops.assign_sub(biased_var, (biased_var - value) * decay, name=scope.name) update_local_step = local_step.assign_add(1) # Compute the value of the delta to update the unbiased EMA. Make sure to # use the new values of the biased variable and the local step. with ops.control_dependencies([update_biased, update_local_step]): # This function gets `1 - decay`, so use `1.0 - decay` in the exponent. unbiased_ema_delta = (unbiased_var - biased_var.ref() / (1 - math_ops.pow(1.0 - decay, local_step.ref()))) return unbiased_ema_delta
[ "def", "_zero_debias", "(", "unbiased_var", ",", "value", ",", "decay", ")", ":", "with", "variable_scope", ".", "variable_scope", "(", "\"ZeroDebias\"", ",", "values", "=", "[", "unbiased_var", ",", "value", ",", "decay", "]", ")", "as", "scope", ":", "wi...
https://github.com/tobegit3hub/deep_image_model/blob/8a53edecd9e00678b278bb10f6fb4bdb1e4ee25e/java_predict_client/src/main/proto/tensorflow/python/training/moving_averages.py#L136-L196
danirus/django-comments-xtd
c2ec50226d219d98fe0faeae4e66e8a676b47e5b
django_comments_xtd/api/serializers.py
python
WriteCommentSerializer.validate_reply_to
(self, value)
return value
[]
def validate_reply_to(self, value): if value != 0: try: parent = get_model().objects.get(pk=value) except get_model().DoesNotExist: raise serializers.ValidationError( "reply_to comment does not exist") else: max = max_thread_level_for_content_type(parent.content_type) if parent.level == max: raise serializers.ValidationError( "Max thread level reached") return value
[ "def", "validate_reply_to", "(", "self", ",", "value", ")", ":", "if", "value", "!=", "0", ":", "try", ":", "parent", "=", "get_model", "(", ")", ".", "objects", ".", "get", "(", "pk", "=", "value", ")", "except", "get_model", "(", ")", ".", "DoesN...
https://github.com/danirus/django-comments-xtd/blob/c2ec50226d219d98fe0faeae4e66e8a676b47e5b/django_comments_xtd/api/serializers.py#L70-L82
spotify/luigi
c3b66f4a5fa7eaa52f9a72eb6704b1049035c789
luigi/configuration/core.py
python
_check_parser
(parser_class, parser)
[]
def _check_parser(parser_class, parser): if not parser_class.enabled: msg = ( "Parser not installed yet. " "Please, install luigi with required parser:\n" "pip install luigi[{parser}]" ) raise ImportError(msg.format(parser=parser))
[ "def", "_check_parser", "(", "parser_class", ",", "parser", ")", ":", "if", "not", "parser_class", ".", "enabled", ":", "msg", "=", "(", "\"Parser not installed yet. \"", "\"Please, install luigi with required parser:\\n\"", "\"pip install luigi[{parser}]\"", ")", "raise", ...
https://github.com/spotify/luigi/blob/c3b66f4a5fa7eaa52f9a72eb6704b1049035c789/luigi/configuration/core.py#L46-L53
inkandswitch/livebook
93c8d467734787366ad084fc3566bf5cbe249c51
public/pypyjs/modules/datetime.py
python
date.ctime
(self)
return "%s %s %2d 00:00:00 %04d" % ( _DAYNAMES[weekday], _MONTHNAMES[self._month], self._day, self._year)
Return ctime() style string.
Return ctime() style string.
[ "Return", "ctime", "()", "style", "string", "." ]
def ctime(self): "Return ctime() style string." weekday = self.toordinal() % 7 or 7 return "%s %s %2d 00:00:00 %04d" % ( _DAYNAMES[weekday], _MONTHNAMES[self._month], self._day, self._year)
[ "def", "ctime", "(", "self", ")", ":", "weekday", "=", "self", ".", "toordinal", "(", ")", "%", "7", "or", "7", "return", "\"%s %s %2d 00:00:00 %04d\"", "%", "(", "_DAYNAMES", "[", "weekday", "]", ",", "_MONTHNAMES", "[", "self", ".", "_month", "]", ",...
https://github.com/inkandswitch/livebook/blob/93c8d467734787366ad084fc3566bf5cbe249c51/public/pypyjs/modules/datetime.py#L811-L817
apache/libcloud
90971e17bfd7b6bb97b2489986472c531cc8e140
libcloud/compute/drivers/ec2.py
python
BaseEC2NodeDriver.ex_delete_subnet
(self, subnet)
return self._get_boolean(res)
Deletes a VPC subnet. :param subnet: The subnet to delete :type subnet: :class:`.EC2NetworkSubnet` :rtype: ``bool``
Deletes a VPC subnet.
[ "Deletes", "a", "VPC", "subnet", "." ]
def ex_delete_subnet(self, subnet): """ Deletes a VPC subnet. :param subnet: The subnet to delete :type subnet: :class:`.EC2NetworkSubnet` :rtype: ``bool`` """ params = {"Action": "DeleteSubnet", "SubnetId": subnet.id} res = self.connection.request(self.path, params=params).object return self._get_boolean(res)
[ "def", "ex_delete_subnet", "(", "self", ",", "subnet", ")", ":", "params", "=", "{", "\"Action\"", ":", "\"DeleteSubnet\"", ",", "\"SubnetId\"", ":", "subnet", ".", "id", "}", "res", "=", "self", ".", "connection", ".", "request", "(", "self", ".", "path...
https://github.com/apache/libcloud/blob/90971e17bfd7b6bb97b2489986472c531cc8e140/libcloud/compute/drivers/ec2.py#L2647-L2660
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/setuptools/__init__.py
python
Command.reinitialize_command
(self, command, reinit_subcommands=0, **kw)
return cmd
[]
def reinitialize_command(self, command, reinit_subcommands=0, **kw): cmd = _Command.reinitialize_command(self, command, reinit_subcommands) vars(cmd).update(kw) return cmd
[ "def", "reinitialize_command", "(", "self", ",", "command", ",", "reinit_subcommands", "=", "0", ",", "*", "*", "kw", ")", ":", "cmd", "=", "_Command", ".", "reinitialize_command", "(", "self", ",", "command", ",", "reinit_subcommands", ")", "vars", "(", "...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/setuptools/__init__.py#L150-L153
OpenAgricultureFoundation/openag-device-software
a51d2de399c0a6781ae51d0dcfaae1583d75f346
device/utilities/communication/i2c/main.py
python
I2C.read
( self, num_bytes: int, retry: bool = True, disable_mux: bool = False )
Reads num bytes from device. Returns byte array.
Reads num bytes from device. Returns byte array.
[ "Reads", "num", "bytes", "from", "device", ".", "Returns", "byte", "array", "." ]
def read( self, num_bytes: int, retry: bool = True, disable_mux: bool = False ) -> bytes: """Reads num bytes from device. Returns byte array.""" with self.i2c_lock: self.manage_mux("read bytes", disable_mux) #self.logger.debug("Reading {} bytes".format(num_bytes)) bytes_ = bytes(self.io.read(self.address, num_bytes)) #self.logger.debug("Read bytes: {}".format(byte_str(bytes_))) return bytes_
[ "def", "read", "(", "self", ",", "num_bytes", ":", "int", ",", "retry", ":", "bool", "=", "True", ",", "disable_mux", ":", "bool", "=", "False", ")", "->", "bytes", ":", "with", "self", ".", "i2c_lock", ":", "self", ".", "manage_mux", "(", "\"read by...
https://github.com/OpenAgricultureFoundation/openag-device-software/blob/a51d2de399c0a6781ae51d0dcfaae1583d75f346/device/utilities/communication/i2c/main.py#L112-L121
dipy/dipy
be956a529465b28085f8fc435a756947ddee1c89
dipy/reconst/shore.py
python
shore_matrix_pdf
(radial_order, zeta, rtab)
return psi
r"""Compute the SHORE propagator matrix [1]_" Parameters ---------- radial_order : unsigned int, an even integer that represent the order of the basis zeta : unsigned int, scale factor rtab : array, shape (N,3) real space points in which calculates the pdf References ---------- .. [1] Merlet S. et al., "Continuous diffusion signal, EAP and ODF estimation via Compressive Sensing in diffusion MRI", Medical Image Analysis, 2013.
r"""Compute the SHORE propagator matrix [1]_"
[ "r", "Compute", "the", "SHORE", "propagator", "matrix", "[", "1", "]", "_" ]
def shore_matrix_pdf(radial_order, zeta, rtab): r"""Compute the SHORE propagator matrix [1]_" Parameters ---------- radial_order : unsigned int, an even integer that represent the order of the basis zeta : unsigned int, scale factor rtab : array, shape (N,3) real space points in which calculates the pdf References ---------- .. [1] Merlet S. et al., "Continuous diffusion signal, EAP and ODF estimation via Compressive Sensing in diffusion MRI", Medical Image Analysis, 2013. """ r, theta, phi = cart2sphere(rtab[:, 0], rtab[:, 1], rtab[:, 2]) theta[np.isnan(theta)] = 0 F = radial_order / 2 n_c = int(np.round(1 / 6.0 * (F + 1) * (F + 2) * (4 * F + 3))) psi = np.zeros((r.shape[0], n_c)) counter = 0 for l in range(0, radial_order + 1, 2): for n in range(l, int((radial_order + l) / 2) + 1): for m in range(-l, l + 1): psi[:, counter] = real_sh_descoteaux_from_index( m, l, theta, phi) * \ genlaguerre(n - l, l + 0.5)(4 * np.pi ** 2 * zeta * r ** 2) *\ np.exp(-2 * np.pi ** 2 * zeta * r ** 2) *\ _kappa_pdf(zeta, n, l) *\ (4 * np.pi ** 2 * zeta * r ** 2) ** (l / 2) * \ (-1) ** (n - l / 2) counter += 1 return psi
[ "def", "shore_matrix_pdf", "(", "radial_order", ",", "zeta", ",", "rtab", ")", ":", "r", ",", "theta", ",", "phi", "=", "cart2sphere", "(", "rtab", "[", ":", ",", "0", "]", ",", "rtab", "[", ":", ",", "1", "]", ",", "rtab", "[", ":", ",", "2", ...
https://github.com/dipy/dipy/blob/be956a529465b28085f8fc435a756947ddee1c89/dipy/reconst/shore.py#L570-L607
hatRiot/zarp
2e772350a01c2aeed3f4da9685cd0cc5d6b3ecad
src/lib/scapy/modules/nmap.py
python
NmapKnowledgeBase.lazy_init
(self)
[]
def lazy_init(self): try: f=open(self.filename) except IOError: return self.base = [] name = None try: for l in f: l = l.strip() if not l or l[0] == "#": continue if l[:12] == "Fingerprint ": if name is not None: self.base.append((name,sig)) name = l[12:].strip() sig={} p = self.base continue elif l[:6] == "Class ": continue op = l.find("(") cl = l.find(")") if op < 0 or cl < 0: warning("error reading nmap os fp base file") continue test = l[:op] s = map(lambda x: x.split("="), l[op+1:cl].split("%")) si = {} for n,v in s: si[n] = v sig[test]=si if name is not None: self.base.append((name,sig)) except: self.base = None warning("Can't read nmap database [%s](new nmap version ?)" % self.filename) f.close()
[ "def", "lazy_init", "(", "self", ")", ":", "try", ":", "f", "=", "open", "(", "self", ".", "filename", ")", "except", "IOError", ":", "return", "self", ".", "base", "=", "[", "]", "name", "=", "None", "try", ":", "for", "l", "in", "f", ":", "l"...
https://github.com/hatRiot/zarp/blob/2e772350a01c2aeed3f4da9685cd0cc5d6b3ecad/src/lib/scapy/modules/nmap.py#L25-L63
yuanxiaosc/Multiple-Relations-Extraction-Only-Look-Once
3d1fc216c6aedc0494e52f2ff142af856dcb673f
experimental_loss_function/run_multiple_relations_extraction_balanced_loss.py
python
DataProcessor.get_labels
(self)
Gets the list of labels for this data set.
Gets the list of labels for this data set.
[ "Gets", "the", "list", "of", "labels", "for", "this", "data", "set", "." ]
def get_labels(self): """Gets the list of labels for this data set.""" raise NotImplementedError()
[ "def", "get_labels", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/yuanxiaosc/Multiple-Relations-Extraction-Only-Look-Once/blob/3d1fc216c6aedc0494e52f2ff142af856dcb673f/experimental_loss_function/run_multiple_relations_extraction_balanced_loss.py#L188-L190
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/vpc/v20170312/vpc_client.py
python
VpcClient.CreateLocalGateway
(self, request)
该接口用于创建用于CDC的本地网关。 :param request: Request instance for CreateLocalGateway. :type request: :class:`tencentcloud.vpc.v20170312.models.CreateLocalGatewayRequest` :rtype: :class:`tencentcloud.vpc.v20170312.models.CreateLocalGatewayResponse`
该接口用于创建用于CDC的本地网关。
[ "该接口用于创建用于CDC的本地网关。" ]
def CreateLocalGateway(self, request): """该接口用于创建用于CDC的本地网关。 :param request: Request instance for CreateLocalGateway. :type request: :class:`tencentcloud.vpc.v20170312.models.CreateLocalGatewayRequest` :rtype: :class:`tencentcloud.vpc.v20170312.models.CreateLocalGatewayResponse` """ try: params = request._serialize() body = self.call("CreateLocalGateway", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.CreateLocalGatewayResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "CreateLocalGateway", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"CreateLocalGateway\"", ",", "params", ")", "response", "=", "json", ".", "loa...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/vpc/v20170312/vpc_client.py#L1185-L1210
smartbgp/yabgp
f073633a813899cd9b413bc28ea2f7737deee141
yabgp/core/timer.py
python
BGPTimer.reset
(self, seconds_fromnow)
Resets an already running timer, or starts it if it wasn't running. :param seconds_fromnow : restart timer
Resets an already running timer, or starts it if it wasn't running.
[ "Resets", "an", "already", "running", "timer", "or", "starts", "it", "if", "it", "wasn", "t", "running", "." ]
def reset(self, seconds_fromnow): """Resets an already running timer, or starts it if it wasn't running. :param seconds_fromnow : restart timer """ try: self.status = True self.delayed_call.reset(seconds_fromnow) except (AttributeError, error.AlreadyCalled, error.AlreadyCancelled): self.delayed_call = reactor.callLater(seconds_fromnow, self.callable)
[ "def", "reset", "(", "self", ",", "seconds_fromnow", ")", ":", "try", ":", "self", ".", "status", "=", "True", "self", ".", "delayed_call", ".", "reset", "(", "seconds_fromnow", ")", "except", "(", "AttributeError", ",", "error", ".", "AlreadyCalled", ",",...
https://github.com/smartbgp/yabgp/blob/f073633a813899cd9b413bc28ea2f7737deee141/yabgp/core/timer.py#L44-L54
angr/angr
4b04d56ace135018083d36d9083805be8146688b
angr/state_plugins/trace_additions.py
python
FormatInfoDontConstrain.__init__
(self, addr, func_name, check_symbolic_arg)
[]
def __init__(self, addr, func_name, check_symbolic_arg): self.addr = addr self.func_name = func_name self.check_symbolic_arg = check_symbolic_arg
[ "def", "__init__", "(", "self", ",", "addr", ",", "func_name", ",", "check_symbolic_arg", ")", ":", "self", ".", "addr", "=", "addr", "self", ".", "func_name", "=", "func_name", "self", ".", "check_symbolic_arg", "=", "check_symbolic_arg" ]
https://github.com/angr/angr/blob/4b04d56ace135018083d36d9083805be8146688b/angr/state_plugins/trace_additions.py#L110-L113
JBakamovic/cxxd
142c19649b036bd6f6bdcd4684de735ea11a6c94
parser/cxxd_config_parser.py
python
CxxdConfigParser._extract_clang_format_binary_path
(self, config)
return None
[]
def _extract_clang_format_binary_path(self, config): if 'clang-format' in config: if 'binary' in config['clang-format']: return config['clang-format']['binary'] return None
[ "def", "_extract_clang_format_binary_path", "(", "self", ",", "config", ")", ":", "if", "'clang-format'", "in", "config", ":", "if", "'binary'", "in", "config", "[", "'clang-format'", "]", ":", "return", "config", "[", "'clang-format'", "]", "[", "'binary'", "...
https://github.com/JBakamovic/cxxd/blob/142c19649b036bd6f6bdcd4684de735ea11a6c94/parser/cxxd_config_parser.py#L226-L230
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-darwin/x64/tornado/template.py
python
_ChunkList.__init__
(self, chunks)
[]
def __init__(self, chunks): self.chunks = chunks
[ "def", "__init__", "(", "self", ",", "chunks", ")", ":", "self", ".", "chunks", "=", "chunks" ]
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-darwin/x64/tornado/template.py#L506-L507
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/layout/updatemenu/_pad.py
python
Pad.r
(self)
return self["r"]
The amount of padding (in px) on the right side of the component. The 'r' property is a number and may be specified as: - An int or float Returns ------- int|float
The amount of padding (in px) on the right side of the component. The 'r' property is a number and may be specified as: - An int or float
[ "The", "amount", "of", "padding", "(", "in", "px", ")", "on", "the", "right", "side", "of", "the", "component", ".", "The", "r", "property", "is", "a", "number", "and", "may", "be", "specified", "as", ":", "-", "An", "int", "or", "float" ]
def r(self): """ The amount of padding (in px) on the right side of the component. The 'r' property is a number and may be specified as: - An int or float Returns ------- int|float """ return self["r"]
[ "def", "r", "(", "self", ")", ":", "return", "self", "[", "\"r\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/layout/updatemenu/_pad.py#L58-L70
microsoft/azure-devops-python-api
451cade4c475482792cbe9e522c1fee32393139e
azure-devops/azure/devops/v5_1/feature_availability/feature_availability_client.py
python
FeatureAvailabilityClient.get_feature_flag_by_name_and_user_id
(self, name, user_id, check_feature_exists=None)
return self._deserialize('FeatureFlag', response)
GetFeatureFlagByNameAndUserId. [Preview API] Retrieve information on a single feature flag and its current states for a user :param str name: The name of the feature to retrieve :param str user_id: The id of the user to check :param bool check_feature_exists: Check if feature exists :rtype: :class:`<FeatureFlag> <azure.devops.v5_1.feature_availability.models.FeatureFlag>`
GetFeatureFlagByNameAndUserId. [Preview API] Retrieve information on a single feature flag and its current states for a user :param str name: The name of the feature to retrieve :param str user_id: The id of the user to check :param bool check_feature_exists: Check if feature exists :rtype: :class:`<FeatureFlag> <azure.devops.v5_1.feature_availability.models.FeatureFlag>`
[ "GetFeatureFlagByNameAndUserId", ".", "[", "Preview", "API", "]", "Retrieve", "information", "on", "a", "single", "feature", "flag", "and", "its", "current", "states", "for", "a", "user", ":", "param", "str", "name", ":", "The", "name", "of", "the", "feature...
def get_feature_flag_by_name_and_user_id(self, name, user_id, check_feature_exists=None): """GetFeatureFlagByNameAndUserId. [Preview API] Retrieve information on a single feature flag and its current states for a user :param str name: The name of the feature to retrieve :param str user_id: The id of the user to check :param bool check_feature_exists: Check if feature exists :rtype: :class:`<FeatureFlag> <azure.devops.v5_1.feature_availability.models.FeatureFlag>` """ route_values = {} if name is not None: route_values['name'] = self._serialize.url('name', name, 'str') query_parameters = {} if user_id is not None: query_parameters['userId'] = self._serialize.query('user_id', user_id, 'str') if check_feature_exists is not None: query_parameters['checkFeatureExists'] = self._serialize.query('check_feature_exists', check_feature_exists, 'bool') response = self._send(http_method='GET', location_id='3e2b80f8-9e6f-441e-8393-005610692d9c', version='5.1-preview.1', route_values=route_values, query_parameters=query_parameters) return self._deserialize('FeatureFlag', response)
[ "def", "get_feature_flag_by_name_and_user_id", "(", "self", ",", "name", ",", "user_id", ",", "check_feature_exists", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "name", "is", "not", "None", ":", "route_values", "[", "'name'", "]", "=", "self...
https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/v5_1/feature_availability/feature_availability_client.py#L86-L107
panpanpandas/ultrafinance
ce3594dbfef747cba0c39f059316df7c208aac40
ultrafinance/dam/excelLib.py
python
ExcelLib.readRow
(self, row, startCol=0, endCol=-1)
return self.__operation.readRow(row, startCol, endCol)
read row
read row
[ "read", "row" ]
def readRow(self, row, startCol=0, endCol=-1): ''' read row ''' return self.__operation.readRow(row, startCol, endCol)
[ "def", "readRow", "(", "self", ",", "row", ",", "startCol", "=", "0", ",", "endCol", "=", "-", "1", ")", ":", "return", "self", ".", "__operation", ".", "readRow", "(", "row", ",", "startCol", ",", "endCol", ")" ]
https://github.com/panpanpandas/ultrafinance/blob/ce3594dbfef747cba0c39f059316df7c208aac40/ultrafinance/dam/excelLib.py#L45-L47
skelsec/pypykatz
dd129ff36e00593d1340776b517f7e749ad8d314
pypykatz/commons/winapi/local/function_defs/kernel32.py
python
MemoryBasicInformation.is_free
(self)
return self.State == MEM_FREE
@rtype: bool @return: C{True} if the memory in this region is free.
[]
def is_free(self): """ @rtype: bool @return: C{True} if the memory in this region is free. """ return self.State == MEM_FREE
[ "def", "is_free", "(", "self", ")", ":", "return", "self", ".", "State", "==", "MEM_FREE" ]
https://github.com/skelsec/pypykatz/blob/dd129ff36e00593d1340776b517f7e749ad8d314/pypykatz/commons/winapi/local/function_defs/kernel32.py#L196-L201
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_adm_ca_server_cert.py
python
Utils.get_resource_file
(sfile, sfile_type='yaml')
return contents
return the service file
return the service file
[ "return", "the", "service", "file" ]
def get_resource_file(sfile, sfile_type='yaml'): ''' return the service file ''' contents = None with open(sfile) as sfd: contents = sfd.read() if sfile_type == 'yaml': # AUDIT:no-member makes sense here due to ruamel.YAML/PyYAML usage # pylint: disable=no-member if hasattr(yaml, 'RoundTripLoader'): contents = yaml.load(contents, yaml.RoundTripLoader) else: contents = yaml.safe_load(contents) elif sfile_type == 'json': contents = json.loads(contents) return contents
[ "def", "get_resource_file", "(", "sfile", ",", "sfile_type", "=", "'yaml'", ")", ":", "contents", "=", "None", "with", "open", "(", "sfile", ")", "as", "sfd", ":", "contents", "=", "sfd", ".", "read", "(", ")", "if", "sfile_type", "==", "'yaml'", ":", ...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_adm_ca_server_cert.py#L1287-L1303
albertz/PyCParser
080a7b0472444fd366006c44fc15e388122989bd
sortedcontainers/sortedlist.py
python
SortedListWithKey.__repr__
(self)
return temp.format( self.__class__.__name__, repr(list(self)), repr(self._key), repr(self._load) )
Return string representation of sequence.
Return string representation of sequence.
[ "Return", "string", "representation", "of", "sequence", "." ]
def __repr__(self): """Return string representation of sequence.""" temp = '{0}({1}, key={2}, load={3})' return temp.format( self.__class__.__name__, repr(list(self)), repr(self._key), repr(self._load) )
[ "def", "__repr__", "(", "self", ")", ":", "temp", "=", "'{0}({1}, key={2}, load={3})'", "return", "temp", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "repr", "(", "list", "(", "self", ")", ")", ",", "repr", "(", "self", ".", "_k...
https://github.com/albertz/PyCParser/blob/080a7b0472444fd366006c44fc15e388122989bd/sortedcontainers/sortedlist.py#L2308-L2316
leapcode/bitmask_client
d2fe20df24fc6eaf146fa5ce1e847de6ab515688
src/leap/bitmask/gui/eip_status.py
python
EIPStatusWidget.set_eip_status_menu
(self, eip_status_menu)
Sets the eip_status_menu to use. :param eip_status_menu: eip_status_menu to be used :type eip_status_menu: QtGui.QMenu
Sets the eip_status_menu to use.
[ "Sets", "the", "eip_status_menu", "to", "use", "." ]
def set_eip_status_menu(self, eip_status_menu): """ Sets the eip_status_menu to use. :param eip_status_menu: eip_status_menu to be used :type eip_status_menu: QtGui.QMenu """ leap_assert_type(eip_status_menu, QtGui.QMenu) self._eip_status_menu = eip_status_menu
[ "def", "set_eip_status_menu", "(", "self", ",", "eip_status_menu", ")", ":", "leap_assert_type", "(", "eip_status_menu", ",", "QtGui", ".", "QMenu", ")", "self", ".", "_eip_status_menu", "=", "eip_status_menu" ]
https://github.com/leapcode/bitmask_client/blob/d2fe20df24fc6eaf146fa5ce1e847de6ab515688/src/leap/bitmask/gui/eip_status.py#L266-L274
FSecureLABS/Jandroid
e31d0dab58a2bfd6ed8e0a387172b8bd7c893436
libs/platform-tools/platform-tools_linux/systrace/catapult/devil/devil/utils/lsusb.py
python
lsusb
()
return devices
Call lsusb and return the parsed output.
Call lsusb and return the parsed output.
[ "Call", "lsusb", "and", "return", "the", "parsed", "output", "." ]
def lsusb(): """Call lsusb and return the parsed output.""" _, lsusb_list_output = cmd_helper.GetCmdStatusAndOutputWithTimeout( ['lsusb'], timeout=10) devices = [] for line in lsusb_list_output.splitlines(): m = _LSUSB_BUS_DEVICE_RE.match(line) if m: bus_num = m.group(1) dev_num = m.group(2) try: devices.append(_lsusbv_on_device(bus_num, dev_num)) except cmd_helper.TimeoutError: # Will be blacklisted if it is in expected device file, but times out. logger.info('lsusb -v %s:%s timed out.', bus_num, dev_num) return devices
[ "def", "lsusb", "(", ")", ":", "_", ",", "lsusb_list_output", "=", "cmd_helper", ".", "GetCmdStatusAndOutputWithTimeout", "(", "[", "'lsusb'", "]", ",", "timeout", "=", "10", ")", "devices", "=", "[", "]", "for", "line", "in", "lsusb_list_output", ".", "sp...
https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_linux/systrace/catapult/devil/devil/utils/lsusb.py#L137-L152
quartiq/rayopt
3890c72b8f56253bdce309b0fe42beda91c6d3e0
rayopt/transformations.py
python
quaternion_slerp
(quat0, quat1, fraction, spin=0, shortestpath=True)
return q0
Return spherical linear interpolation between two quaternions. >>> q0 = random_quaternion() >>> q1 = random_quaternion() >>> q = quaternion_slerp(q0, q1, 0) >>> numpy.allclose(q, q0) True >>> q = quaternion_slerp(q0, q1, 1, 1) >>> numpy.allclose(q, q1) True >>> q = quaternion_slerp(q0, q1, 0.5) >>> angle = math.acos(numpy.dot(q0, q)) >>> numpy.allclose(2, math.acos(numpy.dot(q0, q1)) / angle) or \ numpy.allclose(2, math.acos(-numpy.dot(q0, q1)) / angle) True
Return spherical linear interpolation between two quaternions.
[ "Return", "spherical", "linear", "interpolation", "between", "two", "quaternions", "." ]
def quaternion_slerp(quat0, quat1, fraction, spin=0, shortestpath=True): """Return spherical linear interpolation between two quaternions. >>> q0 = random_quaternion() >>> q1 = random_quaternion() >>> q = quaternion_slerp(q0, q1, 0) >>> numpy.allclose(q, q0) True >>> q = quaternion_slerp(q0, q1, 1, 1) >>> numpy.allclose(q, q1) True >>> q = quaternion_slerp(q0, q1, 0.5) >>> angle = math.acos(numpy.dot(q0, q)) >>> numpy.allclose(2, math.acos(numpy.dot(q0, q1)) / angle) or \ numpy.allclose(2, math.acos(-numpy.dot(q0, q1)) / angle) True """ q0 = unit_vector(quat0[:4]) q1 = unit_vector(quat1[:4]) if fraction == 0.0: return q0 elif fraction == 1.0: return q1 d = numpy.dot(q0, q1) if abs(abs(d) - 1.0) < _EPS: return q0 if shortestpath and d < 0.0: # invert rotation d = -d numpy.negative(q1, q1) angle = math.acos(d) + spin * math.pi if abs(angle) < _EPS: return q0 isin = 1.0 / math.sin(angle) q0 *= math.sin((1.0 - fraction) * angle) * isin q1 *= math.sin(fraction * angle) * isin q0 += q1 return q0
[ "def", "quaternion_slerp", "(", "quat0", ",", "quat1", ",", "fraction", ",", "spin", "=", "0", ",", "shortestpath", "=", "True", ")", ":", "q0", "=", "unit_vector", "(", "quat0", "[", ":", "4", "]", ")", "q1", "=", "unit_vector", "(", "quat1", "[", ...
https://github.com/quartiq/rayopt/blob/3890c72b8f56253bdce309b0fe42beda91c6d3e0/rayopt/transformations.py#L1420-L1458
emesene/emesene
4548a4098310e21b16437bb36223a7f632a4f7bc
emesene/gui/gtkui/AdiumTextBox.py
python
OutputText.__init__
(self, config, handler)
constructor
constructor
[ "constructor" ]
def __init__(self, config, handler): '''constructor''' gtk.ScrolledWindow.__init__(self) gui.base.OutputText.__init__(self, config) self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.set_shadow_type(gtk.SHADOW_IN) self.loaded = False self.view = OutputView(gui.theme.conv_theme, handler) self.view.connect('search_request', self._search_request_cb) self.clear() self.view.show() self.add(self.view)
[ "def", "__init__", "(", "self", ",", "config", ",", "handler", ")", ":", "gtk", ".", "ScrolledWindow", ".", "__init__", "(", "self", ")", "gui", ".", "base", ".", "OutputText", ".", "__init__", "(", "self", ",", "config", ")", "self", ".", "set_policy"...
https://github.com/emesene/emesene/blob/4548a4098310e21b16437bb36223a7f632a4f7bc/emesene/gui/gtkui/AdiumTextBox.py#L184-L197
openstack/swift
b8d7c3dcb817504dcc0959ba52cc4ed2cf66c100
swift/obj/diskfile.py
python
DiskFileManager._update_suffix_hashes
(self, hashes, ondisk_info)
Applies policy specific updates to the given dict of md5 hashes for the given ondisk_info. :param hashes: a dict of md5 hashes to be updated :param ondisk_info: a dict describing the state of ondisk files, as returned by get_ondisk_files
Applies policy specific updates to the given dict of md5 hashes for the given ondisk_info.
[ "Applies", "policy", "specific", "updates", "to", "the", "given", "dict", "of", "md5", "hashes", "for", "the", "given", "ondisk_info", "." ]
def _update_suffix_hashes(self, hashes, ondisk_info): """ Applies policy specific updates to the given dict of md5 hashes for the given ondisk_info. :param hashes: a dict of md5 hashes to be updated :param ondisk_info: a dict describing the state of ondisk files, as returned by get_ondisk_files """ if 'data_info' in ondisk_info: file_info = ondisk_info['data_info'] hashes[None].update( file_info['timestamp'].internal + file_info['ext'])
[ "def", "_update_suffix_hashes", "(", "self", ",", "hashes", ",", "ondisk_info", ")", ":", "if", "'data_info'", "in", "ondisk_info", ":", "file_info", "=", "ondisk_info", "[", "'data_info'", "]", "hashes", "[", "None", "]", ".", "update", "(", "file_info", "[...
https://github.com/openstack/swift/blob/b8d7c3dcb817504dcc0959ba52cc4ed2cf66c100/swift/obj/diskfile.py#L3031-L3043
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/utils/jinja.py
python
lst_avg
(lst)
return float(lst)
Returns the average value of a list. .. code-block:: jinja {% my_list = [1,2,3,4] -%} {{ set my_list | avg }} will be rendered as: .. code-block:: yaml 2.5
Returns the average value of a list.
[ "Returns", "the", "average", "value", "of", "a", "list", "." ]
def lst_avg(lst): """ Returns the average value of a list. .. code-block:: jinja {% my_list = [1,2,3,4] -%} {{ set my_list | avg }} will be rendered as: .. code-block:: yaml 2.5 """ if not isinstance(lst, Hashable): return float(sum(lst) / len(lst)) return float(lst)
[ "def", "lst_avg", "(", "lst", ")", ":", "if", "not", "isinstance", "(", "lst", ",", "Hashable", ")", ":", "return", "float", "(", "sum", "(", "lst", ")", "/", "len", "(", "lst", ")", ")", "return", "float", "(", "lst", ")" ]
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/utils/jinja.py#L598-L615
yuanxiaosc/Multiple-Relations-Extraction-Only-Look-Once
3d1fc216c6aedc0494e52f2ff142af856dcb673f
bert/run_classifier.py
python
file_based_input_fn_builder
(input_file, seq_length, is_training, drop_remainder)
return input_fn
Creates an `input_fn` closure to be passed to TPUEstimator.
Creates an `input_fn` closure to be passed to TPUEstimator.
[ "Creates", "an", "input_fn", "closure", "to", "be", "passed", "to", "TPUEstimator", "." ]
def file_based_input_fn_builder(input_file, seq_length, is_training, drop_remainder): """Creates an `input_fn` closure to be passed to TPUEstimator.""" name_to_features = { "input_ids": tf.FixedLenFeature([seq_length], tf.int64), "input_mask": tf.FixedLenFeature([seq_length], tf.int64), "segment_ids": tf.FixedLenFeature([seq_length], tf.int64), "label_ids": tf.FixedLenFeature([], tf.int64), "is_real_example": tf.FixedLenFeature([], tf.int64), } def _decode_record(record, name_to_features): """Decodes a record to a TensorFlow example.""" example = tf.parse_single_example(record, name_to_features) # tf.Example only supports tf.int64, but the TPU only supports tf.int32. # So cast all int64 to int32. for name in list(example.keys()): t = example[name] if t.dtype == tf.int64: t = tf.to_int32(t) example[name] = t return example def input_fn(params): """The actual input function.""" batch_size = params["batch_size"] # For training, we want a lot of parallel reading and shuffling. # For eval, we want no shuffling and parallel reading doesn't matter. d = tf.data.TFRecordDataset(input_file) if is_training: d = d.repeat() d = d.shuffle(buffer_size=100) d = d.apply( tf.contrib.data.map_and_batch( lambda record: _decode_record(record, name_to_features), batch_size=batch_size, drop_remainder=drop_remainder)) return d return input_fn
[ "def", "file_based_input_fn_builder", "(", "input_file", ",", "seq_length", ",", "is_training", ",", "drop_remainder", ")", ":", "name_to_features", "=", "{", "\"input_ids\"", ":", "tf", ".", "FixedLenFeature", "(", "[", "seq_length", "]", ",", "tf", ".", "int64...
https://github.com/yuanxiaosc/Multiple-Relations-Extraction-Only-Look-Once/blob/3d1fc216c6aedc0494e52f2ff142af856dcb673f/bert/run_classifier.py#L509-L554
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/layout/ternary/caxis/_tickformatstop.py
python
Tickformatstop.__init__
( self, arg=None, dtickrange=None, enabled=None, name=None, templateitemname=None, value=None, **kwargs )
Construct a new Tickformatstop object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.ternary .caxis.Tickformatstop` dtickrange range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat" Returns ------- Tickformatstop
Construct a new Tickformatstop object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.ternary .caxis.Tickformatstop` dtickrange range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat"
[ "Construct", "a", "new", "Tickformatstop", "object", "Parameters", "----------", "arg", "dict", "of", "properties", "compatible", "with", "this", "constructor", "or", "an", "instance", "of", ":", "class", ":", "plotly", ".", "graph_objs", ".", "layout", ".", "...
def __init__( self, arg=None, dtickrange=None, enabled=None, name=None, templateitemname=None, value=None, **kwargs ): """ Construct a new Tickformatstop object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.ternary .caxis.Tickformatstop` dtickrange range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat" Returns ------- Tickformatstop """ super(Tickformatstop, self).__init__("tickformatstops") if "_parent" in kwargs: self._parent = kwargs["_parent"] return # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = _copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.layout.ternary.caxis.Tickformatstop constructor must be a dict or an instance of :class:`plotly.graph_objs.layout.ternary.caxis.Tickformatstop`""" ) # Handle skip_invalid # ------------------- self._skip_invalid = kwargs.pop("skip_invalid", False) self._validate = kwargs.pop("_validate", True) # Populate data dict with properties # ---------------------------------- _v = arg.pop("dtickrange", None) _v = dtickrange if dtickrange is not None else _v if _v is not None: self["dtickrange"] = _v _v = arg.pop("enabled", None) _v = enabled if enabled is not None else _v if _v is not None: self["enabled"] = _v _v = arg.pop("name", None) _v = name if name is not None else _v if _v is not None: self["name"] = _v _v = arg.pop("templateitemname", None) _v = templateitemname if templateitemname is not None else _v if _v is not None: self["templateitemname"] = _v _v = arg.pop("value", None) _v = value if value is not None else _v if _v is not None: self["value"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "dtickrange", "=", "None", ",", "enabled", "=", "None", ",", "name", "=", "None", ",", "templateitemname", "=", "None", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "sup...
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/layout/ternary/caxis/_tickformatstop.py#L173-L283
digidotcom/xbee-python
0757f4be0017530c205175fbee8f9f61be9614d1
digi/xbee/filesystem.py
python
FileSystemManager.read_file
(self, file, offset=0, progress_cb=None)
return _ReadFileProcess(self, file, offset, self.DEFAULT_TIMEOUT, read_callback=progress_cb)
Reads from the provided file starting at the given offset. If there is no progress callback the function blocks until the required amount of bytes is read. Args: file (:class:`.FileSystemElement` or String): File to read or its absolute path. offset (Integer, optional, default=0): File offset to start reading. progress_cb (Function, optional, default=`None`): Function called when new data is read. Receives four arguments: * The chunk of data read as byte array. * The progress percentage as float. * The total size of the file. * The status when process finishes. Returns: :class:`.FileProcess`: The process to read data from the file. Raises: FileSystemException: If there is any error performing the operation and `progress_cb` is `None`. ValueError: If any of the parameters is invalid. .. seealso:: | :meth:`.get_file`
Reads from the provided file starting at the given offset. If there is no progress callback the function blocks until the required amount of bytes is read.
[ "Reads", "from", "the", "provided", "file", "starting", "at", "the", "given", "offset", ".", "If", "there", "is", "no", "progress", "callback", "the", "function", "blocks", "until", "the", "required", "amount", "of", "bytes", "is", "read", "." ]
def read_file(self, file, offset=0, progress_cb=None): """ Reads from the provided file starting at the given offset. If there is no progress callback the function blocks until the required amount of bytes is read. Args: file (:class:`.FileSystemElement` or String): File to read or its absolute path. offset (Integer, optional, default=0): File offset to start reading. progress_cb (Function, optional, default=`None`): Function called when new data is read. Receives four arguments: * The chunk of data read as byte array. * The progress percentage as float. * The total size of the file. * The status when process finishes. Returns: :class:`.FileProcess`: The process to read data from the file. Raises: FileSystemException: If there is any error performing the operation and `progress_cb` is `None`. ValueError: If any of the parameters is invalid. .. seealso:: | :meth:`.get_file` """ return _ReadFileProcess(self, file, offset, self.DEFAULT_TIMEOUT, read_callback=progress_cb)
[ "def", "read_file", "(", "self", ",", "file", ",", "offset", "=", "0", ",", "progress_cb", "=", "None", ")", ":", "return", "_ReadFileProcess", "(", "self", ",", "file", ",", "offset", ",", "self", ".", "DEFAULT_TIMEOUT", ",", "read_callback", "=", "prog...
https://github.com/digidotcom/xbee-python/blob/0757f4be0017530c205175fbee8f9f61be9614d1/digi/xbee/filesystem.py#L1258-L1289
krintoxi/NoobSec-Toolkit
38738541cbc03cedb9a3b3ed13b629f781ad64f6
NoobSecToolkit /tools/inject/thirdparty/gprof2dot/gprof2dot.py
python
DotWriter.begin_graph
(self)
[]
def begin_graph(self): self.write('digraph {\n')
[ "def", "begin_graph", "(", "self", ")", ":", "self", ".", "write", "(", "'digraph {\\n'", ")" ]
https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/inject/thirdparty/gprof2dot/gprof2dot.py#L2353-L2354
asyml/texar
a23f021dae289a3d768dc099b220952111da04fd
texar/tf/modules/decoders/rnn_decoder_base.py
python
RNNDecoderBase.vocab_size
(self)
return self._vocab_size
The vocab size.
The vocab size.
[ "The", "vocab", "size", "." ]
def vocab_size(self): """The vocab size. """ return self._vocab_size
[ "def", "vocab_size", "(", "self", ")", ":", "return", "self", ".", "_vocab_size" ]
https://github.com/asyml/texar/blob/a23f021dae289a3d768dc099b220952111da04fd/texar/tf/modules/decoders/rnn_decoder_base.py#L564-L567
google/coursebuilder-core
08f809db3226d9269e30d5edd0edd33bd22041f4
coursebuilder/modules/courses/triggers.py
python
ContentTrigger.type
(self)
return None if self.content is None else self.content.type
Returns associated course content type if one exists, or None.
Returns associated course content type if one exists, or None.
[ "Returns", "associated", "course", "content", "type", "if", "one", "exists", "or", "None", "." ]
def type(self): """Returns associated course content type if one exists, or None.""" return None if self.content is None else self.content.type
[ "def", "type", "(", "self", ")", ":", "return", "None", "if", "self", ".", "content", "is", "None", "else", "self", ".", "content", ".", "type" ]
https://github.com/google/coursebuilder-core/blob/08f809db3226d9269e30d5edd0edd33bd22041f4/coursebuilder/modules/courses/triggers.py#L1288-L1290
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/libs/azure/src/azure/abfs/abfs.py
python
ABFS._local_copy_file
(self, local_src, remote_dst, chunk_size=UPLOAD_CHUCK_SIZE)
A wraper function for copying local Files
A wraper function for copying local Files
[ "A", "wraper", "function", "for", "copying", "local", "Files" ]
def _local_copy_file(self, local_src, remote_dst, chunk_size=UPLOAD_CHUCK_SIZE): """ A wraper function for copying local Files """ if os.path.isfile(local_src): if self.exists(remote_dst): LOG.info('%s already exists. Skipping.' % remote_dst) return src = file(local_src) try: try: self.create(remote_dst) chunk = src.read(chunk_size) offset = 0 while chunk: size = len(chunk) self._append(remote_dst, chunk, size=size, params={'position': offset}) offset += size chunk = src.read(chunk_size) self.flush(remote_dst, params={'position': offset}) except: LOG.exception(_('Copying %s -> %s failed.') % (local_src, remote_dst)) raise finally: src.close() else: LOG.info(_('Skipping %s (not a file).') % local_src)
[ "def", "_local_copy_file", "(", "self", ",", "local_src", ",", "remote_dst", ",", "chunk_size", "=", "UPLOAD_CHUCK_SIZE", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "local_src", ")", ":", "if", "self", ".", "exists", "(", "remote_dst", ")", "...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/libs/azure/src/azure/abfs/abfs.py#L625-L652
hequan2017/autoops
5e717a2d86dd37cd2cfaf6db3d9613a0c41c49ae
script/connections.py
python
Connection._send_autocommit_mode
(self)
Set whether or not to commit after every execute()
Set whether or not to commit after every execute()
[ "Set", "whether", "or", "not", "to", "commit", "after", "every", "execute", "()" ]
def _send_autocommit_mode(self): """Set whether or not to commit after every execute()""" self._execute_command(COMMAND.COM_QUERY, "SET AUTOCOMMIT = %s" % self.escape(self.autocommit_mode)) self._read_ok_packet()
[ "def", "_send_autocommit_mode", "(", "self", ")", ":", "self", ".", "_execute_command", "(", "COMMAND", ".", "COM_QUERY", ",", "\"SET AUTOCOMMIT = %s\"", "%", "self", ".", "escape", "(", "self", ".", "autocommit_mode", ")", ")", "self", ".", "_read_ok_packet", ...
https://github.com/hequan2017/autoops/blob/5e717a2d86dd37cd2cfaf6db3d9613a0c41c49ae/script/connections.py#L774-L778
AstusRush/AMaDiA
e2ad87318d9dd30bc24428e05c29cb32a29c83aa
External_Libraries/python_control_master/control/frdata.py
python
FrequencyResponseData.eval
(self, omega)
return self._evalfr(omega)
Evaluate a transfer function at a single angular frequency. self.evalfr(omega) returns the value of the frequency response at frequency omega. Note that a "normal" FRD only returns values for which there is an entry in the omega vector. An interpolating FRD can return intermediate values.
Evaluate a transfer function at a single angular frequency.
[ "Evaluate", "a", "transfer", "function", "at", "a", "single", "angular", "frequency", "." ]
def eval(self, omega): """Evaluate a transfer function at a single angular frequency. self.evalfr(omega) returns the value of the frequency response at frequency omega. Note that a "normal" FRD only returns values for which there is an entry in the omega vector. An interpolating FRD can return intermediate values. """ return self._evalfr(omega)
[ "def", "eval", "(", "self", ",", "omega", ")", ":", "return", "self", ".", "_evalfr", "(", "omega", ")" ]
https://github.com/AstusRush/AMaDiA/blob/e2ad87318d9dd30bc24428e05c29cb32a29c83aa/External_Libraries/python_control_master/control/frdata.py#L357-L368
sqlmapproject/sqlmap
3b07b70864624dff4c29dcaa8a61c78e7f9189f7
thirdparty/pydes/pyDes.py
python
_baseDes.getMode
(self)
return self._mode
getMode() -> pyDes.ECB or pyDes.CBC
getMode() -> pyDes.ECB or pyDes.CBC
[ "getMode", "()", "-", ">", "pyDes", ".", "ECB", "or", "pyDes", ".", "CBC" ]
def getMode(self): """getMode() -> pyDes.ECB or pyDes.CBC""" return self._mode
[ "def", "getMode", "(", "self", ")", ":", "return", "self", ".", "_mode" ]
https://github.com/sqlmapproject/sqlmap/blob/3b07b70864624dff4c29dcaa8a61c78e7f9189f7/thirdparty/pydes/pyDes.py#L135-L137
tosher/Mediawiker
81bf97cace59bedcb1668e7830b85c36e014428e
lib/Crypto.win.x64/Crypto/Hash/keccak.py
python
Keccak_Hash.update
(self, data)
return self
Continue hashing of a message by consuming the next chunk of data. Args: data (byte string/byte array/memoryview): The next chunk of the message being hashed.
Continue hashing of a message by consuming the next chunk of data.
[ "Continue", "hashing", "of", "a", "message", "by", "consuming", "the", "next", "chunk", "of", "data", "." ]
def update(self, data): """Continue hashing of a message by consuming the next chunk of data. Args: data (byte string/byte array/memoryview): The next chunk of the message being hashed. """ if self._digest_done and not self._update_after_digest: raise TypeError("You can only call 'digest' or 'hexdigest' on this object") result = _raw_keccak_lib.keccak_absorb(self._state.get(), c_uint8_ptr(data), c_size_t(len(data))) if result: raise ValueError("Error %d while updating keccak" % result) return self
[ "def", "update", "(", "self", ",", "data", ")", ":", "if", "self", ".", "_digest_done", "and", "not", "self", ".", "_update_after_digest", ":", "raise", "TypeError", "(", "\"You can only call 'digest' or 'hexdigest' on this object\"", ")", "result", "=", "_raw_kecca...
https://github.com/tosher/Mediawiker/blob/81bf97cace59bedcb1668e7830b85c36e014428e/lib/Crypto.win.x64/Crypto/Hash/keccak.py#L81-L96
CedricGuillemet/Imogen
ee417b42747ed5b46cb11b02ef0c3630000085b3
bin/Lib/functools.py
python
_le_from_lt
(self, other, NotImplemented=NotImplemented)
return op_result or self == other
Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
Return a <= b. Computed by
[ "Return", "a", "<", "=", "b", ".", "Computed", "by" ]
def _le_from_lt(self, other, NotImplemented=NotImplemented): 'Return a <= b. Computed by @total_ordering from (a < b) or (a == b).' op_result = self.__lt__(other) return op_result or self == other
[ "def", "_le_from_lt", "(", "self", ",", "other", ",", "NotImplemented", "=", "NotImplemented", ")", ":", "op_result", "=", "self", ".", "__lt__", "(", "other", ")", "return", "op_result", "or", "self", "==", "other" ]
https://github.com/CedricGuillemet/Imogen/blob/ee417b42747ed5b46cb11b02ef0c3630000085b3/bin/Lib/functools.py#L98-L101
nathanlopez/Stitch
8e22e91c94237959c02d521aab58dc7e3d994cea
Application/stitch_osxshell.py
python
st_osxshell.help_location
(self)
[]
def help_location(self): st_help_location()
[ "def", "help_location", "(", "self", ")", ":", "st_help_location", "(", ")" ]
https://github.com/nathanlopez/Stitch/blob/8e22e91c94237959c02d521aab58dc7e3d994cea/Application/stitch_osxshell.py#L249-L249
wrye-bash/wrye-bash
d495c47cfdb44475befa523438a40c4419cb386f
Mopy/bash/patcher/patchers/preservers.py
python
ImportCellsPatcher.buildPatch
(self, log, progress, __attrgetters=attrgetter_cache)
Adds merged lists to patchfile.
Adds merged lists to patchfile.
[ "Adds", "merged", "lists", "to", "patchfile", "." ]
def buildPatch(self, log, progress, __attrgetters=attrgetter_cache): """Adds merged lists to patchfile.""" def handlePatchCellBlock(patchCellBlock): """This function checks if an attribute or flag in CellData has a value which is different to the corresponding value in the bash patch file. The Patch file will contain the last corresponding record found when it is created regardless of tags. If the CellData value is different, then the value is copied to the bash patch, and the cell is flagged as modified. Modified cell Blocks are kept, the other are discarded.""" modified = False patch_cell = patchCellBlock.cell patch_cell_fid = patch_cell.fid for attr,value in cellData[patch_cell_fid].items(): curr_value = __attrgetters[attr](patch_cell) ##: If we made MelSorted sort on load too, we could drop this - # but that might be too expensive? Maybe add a parameter to # MelSorted to sort on load only for specific subrecords? if attr == u'regions': if set(value).difference(set(curr_value)): setattr_deep(patch_cell, attr, value) modified = True else: if value != curr_value: setattr_deep(patch_cell, attr, value) modified = True if modified: patch_cell.setChanged() keep(patch_cell_fid) return modified if not self.isActive: return keep = self.patchFile.getKeeper() cellData, count = self.cellData, Counter() for cellBlock in self.patchFile.tops[b'CELL'].cellBlocks: cell_fid = cellBlock.cell.fid if cell_fid in cellData and handlePatchCellBlock(cellBlock): count[cell_fid[0]] += 1 for worldBlock in self.patchFile.tops[b'WRLD'].worldBlocks: keepWorld = False for cellBlock in worldBlock.cellBlocks: cell_fid = cellBlock.cell.fid if cell_fid in cellData and handlePatchCellBlock(cellBlock): count[cell_fid[0]] += 1 keepWorld = True if worldBlock.worldCellBlock: cell_fid = worldBlock.worldCellBlock.cell.fid if cell_fid in cellData and handlePatchCellBlock( worldBlock.worldCellBlock): count[cell_fid[0]] += 1 keepWorld = True if keepWorld: keep(worldBlock.world.fid) self.cellData.clear() self._patchLog(log, count)
[ "def", "buildPatch", "(", "self", ",", "log", ",", "progress", ",", "__attrgetters", "=", "attrgetter_cache", ")", ":", "def", "handlePatchCellBlock", "(", "patchCellBlock", ")", ":", "\"\"\"This function checks if an attribute or flag in CellData has\n a value whi...
https://github.com/wrye-bash/wrye-bash/blob/d495c47cfdb44475befa523438a40c4419cb386f/Mopy/bash/patcher/patchers/preservers.py#L492-L546