repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
napalm-automation/napalm-logs
napalm_logs/device.py
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L84-L138
def _compile_messages(self): ''' Create a list of all OS messages and their compiled regexs ''' self.compiled_messages = [] if not self._config: return for message_dict in self._config.get('messages', {}): error = message_dict['error'] ...
[ "def", "_compile_messages", "(", "self", ")", ":", "self", ".", "compiled_messages", "=", "[", "]", "if", "not", "self", ".", "_config", ":", "return", "for", "message_dict", "in", "self", ".", "_config", ".", "get", "(", "'messages'", ",", "{", "}", "...
Create a list of all OS messages and their compiled regexs
[ "Create", "a", "list", "of", "all", "OS", "messages", "and", "their", "compiled", "regexs" ]
python
train
42.236364
mayfield/shellish
shellish/layout/table.py
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L704-L726
def _column_pad_filter(self, next_filter): """ Expand blank lines caused from overflow of other columns to blank whitespace. E.g. INPUT: [ ["1a", "2a"], [None, "2b"], ["1b", "2c"], [None, "2d"] ] OUTPUT:...
[ "def", "_column_pad_filter", "(", "self", ",", "next_filter", ")", ":", "next", "(", "next_filter", ")", "while", "True", ":", "line", "=", "list", "(", "(", "yield", ")", ")", "for", "i", ",", "col", "in", "enumerate", "(", "line", ")", ":", "if", ...
Expand blank lines caused from overflow of other columns to blank whitespace. E.g. INPUT: [ ["1a", "2a"], [None, "2b"], ["1b", "2c"], [None, "2d"] ] OUTPUT: [ ["1a", "2a"], [<blan...
[ "Expand", "blank", "lines", "caused", "from", "overflow", "of", "other", "columns", "to", "blank", "whitespace", ".", "E", ".", "g", ".", "INPUT", ":", "[", "[", "1a", "2a", "]", "[", "None", "2b", "]", "[", "1b", "2c", "]", "[", "None", "2d", "]...
python
train
30.173913
projectshift/shift-boiler
boiler/user/models.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/models.py#L299-L308
def cancel_email_change(self): """ Cancel email change for new users and roll back data """ if not self.email_new: return self.email_new = None self.email_confirmed = True self.email_link = None self.email_new = None self.email_link_expires = None
[ "def", "cancel_email_change", "(", "self", ")", ":", "if", "not", "self", ".", "email_new", ":", "return", "self", ".", "email_new", "=", "None", "self", ".", "email_confirmed", "=", "True", "self", ".", "email_link", "=", "None", "self", ".", "email_new",...
Cancel email change for new users and roll back data
[ "Cancel", "email", "change", "for", "new", "users", "and", "roll", "back", "data" ]
python
train
30.7
rackerlabs/fastfood
fastfood/utils.py
https://github.com/rackerlabs/fastfood/blob/543970c4cedbb3956e84a7986469fdd7e4ee8fc8/fastfood/utils.py#L63-L85
def deepupdate(original, update, levels=5): """Update, like dict.update, but deeper. Update 'original' from dict/iterable 'update'. I.e., it recurses on dicts 'levels' times if necessary. A standard dict.update is levels=0 """ if not isinstance(update, dict): update = dict(update) ...
[ "def", "deepupdate", "(", "original", ",", "update", ",", "levels", "=", "5", ")", ":", "if", "not", "isinstance", "(", "update", ",", "dict", ")", ":", "update", "=", "dict", "(", "update", ")", "if", "not", "levels", ">", "0", ":", "original", "....
Update, like dict.update, but deeper. Update 'original' from dict/iterable 'update'. I.e., it recurses on dicts 'levels' times if necessary. A standard dict.update is levels=0
[ "Update", "like", "dict", ".", "update", "but", "deeper", "." ]
python
train
35.869565
erget/StereoVision
stereovision/calibration.py
https://github.com/erget/StereoVision/blob/1adff45e291362f52188e0fd0211265845a4461a/stereovision/calibration.py#L124-L128
def export(self, output_folder): """Export matrices as ``*.npy`` files to an output folder.""" if not os.path.exists(output_folder): os.makedirs(output_folder) self._interact_with_folder(output_folder, 'w')
[ "def", "export", "(", "self", ",", "output_folder", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output_folder", ")", ":", "os", ".", "makedirs", "(", "output_folder", ")", "self", ".", "_interact_with_folder", "(", "output_folder", ",", ...
Export matrices as ``*.npy`` files to an output folder.
[ "Export", "matrices", "as", "*", ".", "npy", "files", "to", "an", "output", "folder", "." ]
python
train
47.6
coinbase/coinbase-python
coinbase/wallet/client.py
https://github.com/coinbase/coinbase-python/blob/497c28158f529e8c7d0228521b4386a890baf088/coinbase/wallet/client.py#L580-L586
def refund_order(self, order_id, **params): """https://developers.coinbase.com/api/v2#refund-an-order""" for required in ['currency']: if required not in params: raise ValueError("Missing required parameter: %s" % required) response = self._post('v2', 'orders', order_...
[ "def", "refund_order", "(", "self", ",", "order_id", ",", "*", "*", "params", ")", ":", "for", "required", "in", "[", "'currency'", "]", ":", "if", "required", "not", "in", "params", ":", "raise", "ValueError", "(", "\"Missing required parameter: %s\"", "%",...
https://developers.coinbase.com/api/v2#refund-an-order
[ "https", ":", "//", "developers", ".", "coinbase", ".", "com", "/", "api", "/", "v2#refund", "-", "an", "-", "order" ]
python
train
56.285714
MisanthropicBit/colorise
colorise/__init__.py
https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/__init__.py#L96-L127
def fprint(fmt, *args, **kwargs): """Parse and print a colored and perhaps formatted string. The remaining keyword arguments are the same as for Python's built-in print function. Colors are returning to their defaults before the function returns. """ if not fmt: return hascolor = ...
[ "def", "fprint", "(", "fmt", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "fmt", ":", "return", "hascolor", "=", "False", "target", "=", "kwargs", ".", "get", "(", "\"target\"", ",", "sys", ".", "stdout", ")", "# Format the strin...
Parse and print a colored and perhaps formatted string. The remaining keyword arguments are the same as for Python's built-in print function. Colors are returning to their defaults before the function returns.
[ "Parse", "and", "print", "a", "colored", "and", "perhaps", "formatted", "string", "." ]
python
train
28.375
jonathf/chaospy
chaospy/distributions/sampler/sequences/primes.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/distributions/sampler/sequences/primes.py#L17-L48
def create_primes(threshold): """ Generate prime values using sieve of Eratosthenes method. Args: threshold (int): The upper bound for the size of the prime values. Returns (List[int]): All primes from 2 and up to ``threshold``. """ if threshold == 2: return...
[ "def", "create_primes", "(", "threshold", ")", ":", "if", "threshold", "==", "2", ":", "return", "[", "2", "]", "elif", "threshold", "<", "2", ":", "return", "[", "]", "numbers", "=", "list", "(", "range", "(", "3", ",", "threshold", "+", "1", ",",...
Generate prime values using sieve of Eratosthenes method. Args: threshold (int): The upper bound for the size of the prime values. Returns (List[int]): All primes from 2 and up to ``threshold``.
[ "Generate", "prime", "values", "using", "sieve", "of", "Eratosthenes", "method", "." ]
python
train
25.59375
summa-tx/riemann
riemann/blake256.py
https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/blake256.py#L329-L357
def addsalt(self, salt): """ adds a salt to the hash function (OPTIONAL) should be called AFTER Init, and BEFORE update salt: a bytestring, length determined by hashbitlen. if not of sufficient length, the bytestring will be assumed to be a big endi...
[ "def", "addsalt", "(", "self", ",", "salt", ")", ":", "# fail if addsalt() was not called at the right time", "if", "self", ".", "state", "!=", "1", ":", "raise", "Exception", "(", "'addsalt() not called after init() and before update()'", ")", "# salt size is to be 4x word...
adds a salt to the hash function (OPTIONAL) should be called AFTER Init, and BEFORE update salt: a bytestring, length determined by hashbitlen. if not of sufficient length, the bytestring will be assumed to be a big endian number and pref...
[ "adds", "a", "salt", "to", "the", "hash", "function", "(", "OPTIONAL", ")", "should", "be", "called", "AFTER", "Init", "and", "BEFORE", "update", "salt", ":", "a", "bytestring", "length", "determined", "by", "hashbitlen", ".", "if", "not", "of", "sufficien...
python
train
48.896552
buckhx/QuadKey
quadkey/tile_system.py
https://github.com/buckhx/QuadKey/blob/546338f9b50b578ea765d3bf84b944db48dbec5b/quadkey/tile_system.py#L100-L114
def tile_to_quadkey(tile, level): """Transform tile coordinates to a quadkey""" tile_x = tile[0] tile_y = tile[1] quadkey = "" for i in xrange(level): bit = level - i digit = ord('0') mask = 1 << (bit - 1) # if (bit - 1) > 0 else 1 >> (bit - 1...
[ "def", "tile_to_quadkey", "(", "tile", ",", "level", ")", ":", "tile_x", "=", "tile", "[", "0", "]", "tile_y", "=", "tile", "[", "1", "]", "quadkey", "=", "\"\"", "for", "i", "in", "xrange", "(", "level", ")", ":", "bit", "=", "level", "-", "i", ...
Transform tile coordinates to a quadkey
[ "Transform", "tile", "coordinates", "to", "a", "quadkey" ]
python
train
33.333333
google/grr
grr/core/grr_response_core/lib/objectfilter.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/objectfilter.py#L732-L738
def InsertFloatArg(self, string="", **_): """Inserts a Float argument.""" try: float_value = float(string) return self.InsertArg(float_value) except (TypeError, ValueError): raise ParseError("%s is not a valid float." % string)
[ "def", "InsertFloatArg", "(", "self", ",", "string", "=", "\"\"", ",", "*", "*", "_", ")", ":", "try", ":", "float_value", "=", "float", "(", "string", ")", "return", "self", ".", "InsertArg", "(", "float_value", ")", "except", "(", "TypeError", ",", ...
Inserts a Float argument.
[ "Inserts", "a", "Float", "argument", "." ]
python
train
35.857143
daler/metaseq
metaseq/results_table.py
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L789-L798
def changed(self, thresh=0.05, idx=True): """ Changed features. {threshdoc} """ ind = self.data[self.pval_column] <= thresh if idx: return ind return self[ind]
[ "def", "changed", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "ind", "=", "self", ".", "data", "[", "self", ".", "pval_column", "]", "<=", "thresh", "if", "idx", ":", "return", "ind", "return", "self", "[", "ind", ...
Changed features. {threshdoc}
[ "Changed", "features", "." ]
python
train
21.9
jleinonen/pytmatrix
pytmatrix/tmatrix.py
https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/tmatrix.py#L222-L228
def _init_orient(self): """Retrieve the quadrature points and weights if needed. """ if self.orient == orientation.orient_averaged_fixed: (self.beta_p, self.beta_w) = quadrature.get_points_and_weights( self.or_pdf, 0, 180, self.n_beta) self._set_orient_signatu...
[ "def", "_init_orient", "(", "self", ")", ":", "if", "self", ".", "orient", "==", "orientation", ".", "orient_averaged_fixed", ":", "(", "self", ".", "beta_p", ",", "self", ".", "beta_w", ")", "=", "quadrature", ".", "get_points_and_weights", "(", "self", "...
Retrieve the quadrature points and weights if needed.
[ "Retrieve", "the", "quadrature", "points", "and", "weights", "if", "needed", "." ]
python
train
45.428571
django-treebeard/django-treebeard
treebeard/al_tree.py
https://github.com/django-treebeard/django-treebeard/blob/8042ee939cb45394909237da447f8925e3cc6aa3/treebeard/al_tree.py#L112-L124
def get_parent(self, update=False): """:returns: the parent node of the current node object.""" if self._meta.proxy_for_model: # the current node is a proxy model; the returned parent # should be the same proxy model, so we need to explicitly # fetch it as an instance...
[ "def", "get_parent", "(", "self", ",", "update", "=", "False", ")", ":", "if", "self", ".", "_meta", ".", "proxy_for_model", ":", "# the current node is a proxy model; the returned parent", "# should be the same proxy model, so we need to explicitly", "# fetch it as an instance...
:returns: the parent node of the current node object.
[ ":", "returns", ":", "the", "parent", "node", "of", "the", "current", "node", "object", "." ]
python
train
45.076923
saltstack/salt
salt/states/boto_vpc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_vpc.py#L1538-L1646
def request_vpc_peering_connection(name, requester_vpc_id=None, requester_vpc_name=None, peer_vpc_id=None, peer_vpc_name=None, conn_name=None, peer_owner_id=None, peer_region=None, region=None, key=None, keyid=None,...
[ "def", "request_vpc_peering_connection", "(", "name", ",", "requester_vpc_id", "=", "None", ",", "requester_vpc_name", "=", "None", ",", "peer_vpc_id", "=", "None", ",", "peer_vpc_name", "=", "None", ",", "conn_name", "=", "None", ",", "peer_owner_id", "=", "Non...
name Name of the state requester_vpc_id ID of the requesting VPC. Exclusive with requester_vpc_name. String type. requester_vpc_name Name tag of the requesting VPC. Exclusive with requester_vpc_id. String type. peer_vpc_id ID of the VPC tp crete VPC peering connection wi...
[ "name", "Name", "of", "the", "state" ]
python
train
29.715596
messagebird/python-rest-api
messagebird/client.py
https://github.com/messagebird/python-rest-api/blob/fb7864f178135f92d09af803bee93270e99f3963/messagebird/client.py#L151-L153
def verify_verify(self, id, token): """Verify the token of a specific verification.""" return Verify().load(self.request('verify/' + str(id), params={'token': token}))
[ "def", "verify_verify", "(", "self", ",", "id", ",", "token", ")", ":", "return", "Verify", "(", ")", ".", "load", "(", "self", ".", "request", "(", "'verify/'", "+", "str", "(", "id", ")", ",", "params", "=", "{", "'token'", ":", "token", "}", "...
Verify the token of a specific verification.
[ "Verify", "the", "token", "of", "a", "specific", "verification", "." ]
python
train
60.333333
calmjs/calmjs.parse
src/calmjs/parse/vlq.py
https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/vlq.py#L64-L83
def encode_vlq(i): """ Encode integer `i` into a VLQ encoded string. """ # shift in the sign to least significant bit raw = (-i << 1) + 1 if i < 0 else i << 1 if raw < VLQ_MULTI_CHAR: # short-circuit simple case as it doesn't need continuation return INT_B64[raw] result = [...
[ "def", "encode_vlq", "(", "i", ")", ":", "# shift in the sign to least significant bit", "raw", "=", "(", "-", "i", "<<", "1", ")", "+", "1", "if", "i", "<", "0", "else", "i", "<<", "1", "if", "raw", "<", "VLQ_MULTI_CHAR", ":", "# short-circuit simple case...
Encode integer `i` into a VLQ encoded string.
[ "Encode", "integer", "i", "into", "a", "VLQ", "encoded", "string", "." ]
python
train
28.7
peterbrittain/asciimatics
asciimatics/screen.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/screen.py#L1077-L1081
def refresh(self): """ Flush the canvas content to the underlying screen. """ self._screen.block_transfer(self._buffer, self._dx, self._dy)
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_screen", ".", "block_transfer", "(", "self", ".", "_buffer", ",", "self", ".", "_dx", ",", "self", ".", "_dy", ")" ]
Flush the canvas content to the underlying screen.
[ "Flush", "the", "canvas", "content", "to", "the", "underlying", "screen", "." ]
python
train
33.4
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_image.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/lib/mp_image.py#L462-L480
def on_menu(self, event): '''called on menu event''' state = self.state if self.popup_menu is not None: ret = self.popup_menu.find_selected(event) if ret is not None: ret.popup_pos = self.popup_pos if ret.returnkey == 'fitWindow': ...
[ "def", "on_menu", "(", "self", ",", "event", ")", ":", "state", "=", "self", ".", "state", "if", "self", ".", "popup_menu", "is", "not", "None", ":", "ret", "=", "self", ".", "popup_menu", ".", "find_selected", "(", "event", ")", "if", "ret", "is", ...
called on menu event
[ "called", "on", "menu", "event" ]
python
train
36.263158
deepmipt/DeepPavlov
deeppavlov/core/layers/tf_layers.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/layers/tf_layers.py#L30-L71
def stacked_cnn(units: tf.Tensor, n_hidden_list: List, filter_width=3, use_batch_norm=False, use_dilation=False, training_ph=None, add_l2_losses=False): """ Number of convolutional layers stacked on top of each other ...
[ "def", "stacked_cnn", "(", "units", ":", "tf", ".", "Tensor", ",", "n_hidden_list", ":", "List", ",", "filter_width", "=", "3", ",", "use_batch_norm", "=", "False", ",", "use_dilation", "=", "False", ",", "training_ph", "=", "None", ",", "add_l2_losses", "...
Number of convolutional layers stacked on top of each other Args: units: a tensorflow tensor with dimensionality [None, n_tokens, n_features] n_hidden_list: list with number of hidden units at the ouput of each layer filter_width: width of the kernel in tokens use_batch_norm: whethe...
[ "Number", "of", "convolutional", "layers", "stacked", "on", "top", "of", "each", "other" ]
python
test
45.761905
SeleniumHQ/selenium
py/selenium/webdriver/common/utils.py
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/common/utils.py#L142-L155
def keys_to_typing(value): """Processes the values that will be typed in the element.""" typing = [] for val in value: if isinstance(val, Keys): typing.append(val) elif isinstance(val, int): val = str(val) for i in range(len(val)): typing.a...
[ "def", "keys_to_typing", "(", "value", ")", ":", "typing", "=", "[", "]", "for", "val", "in", "value", ":", "if", "isinstance", "(", "val", ",", "Keys", ")", ":", "typing", ".", "append", "(", "val", ")", "elif", "isinstance", "(", "val", ",", "int...
Processes the values that will be typed in the element.
[ "Processes", "the", "values", "that", "will", "be", "typed", "in", "the", "element", "." ]
python
train
30.571429
yyuu/botornado
boto/gs/resumable_upload_handler.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/gs/resumable_upload_handler.py#L196-L240
def _query_server_pos(self, conn, file_length): """ Queries server to find out what bytes it currently has. Returns (server_start, server_end), where the values are inclusive. For example, (0, 2) would mean that the server has bytes 0, 1, *and* 2. Raises ResumableUploadExceptio...
[ "def", "_query_server_pos", "(", "self", ",", "conn", ",", "file_length", ")", ":", "resp", "=", "self", ".", "_query_server_state", "(", "conn", ",", "file_length", ")", "if", "resp", ".", "status", "==", "200", ":", "return", "(", "0", ",", "file_lengt...
Queries server to find out what bytes it currently has. Returns (server_start, server_end), where the values are inclusive. For example, (0, 2) would mean that the server has bytes 0, 1, *and* 2. Raises ResumableUploadException if problem querying server.
[ "Queries", "server", "to", "find", "out", "what", "bytes", "it", "currently", "has", "." ]
python
train
50.155556
gwastro/pycbc
pycbc/inference/sampler/base_multitemper.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/sampler/base_multitemper.py#L141-L192
def compute_acl(cls, filename, start_index=None, end_index=None, min_nsamples=10): """Computes the autocorrleation length for all model params and temperatures in the given file. Parameter values are averaged over all walkers at each iteration and temperature. The A...
[ "def", "compute_acl", "(", "cls", ",", "filename", ",", "start_index", "=", "None", ",", "end_index", "=", "None", ",", "min_nsamples", "=", "10", ")", ":", "acls", "=", "{", "}", "with", "cls", ".", "_io", "(", "filename", ",", "'r'", ")", "as", "...
Computes the autocorrleation length for all model params and temperatures in the given file. Parameter values are averaged over all walkers at each iteration and temperature. The ACL is then calculated over the averaged chain. Parameters ----------- filename : str ...
[ "Computes", "the", "autocorrleation", "length", "for", "all", "model", "params", "and", "temperatures", "in", "the", "given", "file", "." ]
python
train
42.807692
trailofbits/manticore
manticore/native/manticore.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/native/manticore.py#L42-L67
def linux(cls, path, argv=None, envp=None, entry_symbol=None, symbolic_files=None, concrete_start='', pure_symbolic=False, stdin_size=None, **kwargs): """ Constructor for Linux binary analysis. :param str path: Path to binary to analyze :param argv: Arguments to provide to the binary ...
[ "def", "linux", "(", "cls", ",", "path", ",", "argv", "=", "None", ",", "envp", "=", "None", ",", "entry_symbol", "=", "None", ",", "symbolic_files", "=", "None", ",", "concrete_start", "=", "''", ",", "pure_symbolic", "=", "False", ",", "stdin_size", ...
Constructor for Linux binary analysis. :param str path: Path to binary to analyze :param argv: Arguments to provide to the binary :type argv: list[str] :param envp: Environment to provide to the binary :type envp: dict[str, str] :param entry_symbol: Entry symbol to resol...
[ "Constructor", "for", "Linux", "binary", "analysis", "." ]
python
valid
48.538462
apache/incubator-mxnet
python/mxnet/recordio.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L115-L121
def _check_pid(self, allow_reset=False): """Check process id to ensure integrity, reset if in new process.""" if not self.pid == current_process().pid: if allow_reset: self.reset() else: raise RuntimeError("Forbidden operation in multiple processes...
[ "def", "_check_pid", "(", "self", ",", "allow_reset", "=", "False", ")", ":", "if", "not", "self", ".", "pid", "==", "current_process", "(", ")", ".", "pid", ":", "if", "allow_reset", ":", "self", ".", "reset", "(", ")", "else", ":", "raise", "Runtim...
Check process id to ensure integrity, reset if in new process.
[ "Check", "process", "id", "to", "ensure", "integrity", "reset", "if", "in", "new", "process", "." ]
python
train
45.142857
swimlane/swimlane-python
swimlane/core/fields/base/multiselect.py
https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/fields/base/multiselect.py#L93-L103
def for_json(self): """Handle multi-select vs single-select""" if self.multiselect: return super(MultiSelectField, self).for_json() value = self.get_python() if hasattr(value, 'for_json'): return value.for_json() return value
[ "def", "for_json", "(", "self", ")", ":", "if", "self", ".", "multiselect", ":", "return", "super", "(", "MultiSelectField", ",", "self", ")", ".", "for_json", "(", ")", "value", "=", "self", ".", "get_python", "(", ")", "if", "hasattr", "(", "value", ...
Handle multi-select vs single-select
[ "Handle", "multi", "-", "select", "vs", "single", "-", "select" ]
python
train
25.636364
elkan1788/ppytools
ppytools/ip2location2.py
https://github.com/elkan1788/ppytools/blob/117aeed9f669ae46e0dd6cb11c5687a5f797816c/ppytools/ip2location2.py#L207-L221
def returnData(self, dsptr): """ " get ip data from db file by data start ptr " param: dsptr """ dataPtr = dsptr & 0x00FFFFFFL dataLen = (dsptr >> 24) & 0xFF self.__f.seek(dataPtr) data = self.__f.read(dataLen) result = data[4:].split('|') ...
[ "def", "returnData", "(", "self", ",", "dsptr", ")", ":", "dataPtr", "=", "dsptr", "&", "0x00FFFFFFL", "dataLen", "=", "(", "dsptr", ">>", "24", ")", "&", "0xFF", "self", ".", "__f", ".", "seek", "(", "dataPtr", ")", "data", "=", "self", ".", "__f"...
" get ip data from db file by data start ptr " param: dsptr
[ "get", "ip", "data", "from", "db", "file", "by", "data", "start", "ptr", "param", ":", "dsptr" ]
python
train
28.666667
ungarj/mapchete
mapchete/_core.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/_core.py#L143-L165
def batch_process( self, zoom=None, tile=None, multi=cpu_count(), max_chunksize=1 ): """ Process a large batch of tiles. Parameters ---------- process : MapcheteProcess process to be run zoom : list or int either single zoom level or l...
[ "def", "batch_process", "(", "self", ",", "zoom", "=", "None", ",", "tile", "=", "None", ",", "multi", "=", "cpu_count", "(", ")", ",", "max_chunksize", "=", "1", ")", ":", "list", "(", "self", ".", "batch_processor", "(", "zoom", ",", "tile", ",", ...
Process a large batch of tiles. Parameters ---------- process : MapcheteProcess process to be run zoom : list or int either single zoom level or list of minimum and maximum zoom level; None processes all (default: None) tile : tuple ...
[ "Process", "a", "large", "batch", "of", "tiles", "." ]
python
valid
34.304348
funkybob/django-sniplates
sniplates/templatetags/sniplates.py
https://github.com/funkybob/django-sniplates/blob/cc6123a00536017b496dc685881952d98192101f/sniplates/templatetags/sniplates.py#L69-L78
def parse_widget_name(widget): ''' Parse a alias:block_name string into separate parts. ''' try: alias, block_name = widget.split(':', 1) except ValueError: raise template.TemplateSyntaxError('widget name must be "alias:block_name" - %s' % widget) return alias, block_name
[ "def", "parse_widget_name", "(", "widget", ")", ":", "try", ":", "alias", ",", "block_name", "=", "widget", ".", "split", "(", "':'", ",", "1", ")", "except", "ValueError", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'widget name must be \"alia...
Parse a alias:block_name string into separate parts.
[ "Parse", "a", "alias", ":", "block_name", "string", "into", "separate", "parts", "." ]
python
valid
30.4
rauenzi/discordbot.py
discordbot/bot_utils/config.py
https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/bot_utils/config.py#L52-L55
async def put(self, key, value, *args): """Edits a data entry.""" self._db[key] = value await self.save()
[ "async", "def", "put", "(", "self", ",", "key", ",", "value", ",", "*", "args", ")", ":", "self", ".", "_db", "[", "key", "]", "=", "value", "await", "self", ".", "save", "(", ")" ]
Edits a data entry.
[ "Edits", "a", "data", "entry", "." ]
python
train
31.5
seleniumbase/SeleniumBase
seleniumbase/fixtures/js_utils.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/js_utils.py#L634-L646
def _jq_format(code): """ DEPRECATED - Use re.escape() instead, which performs the intended action. Use before throwing raw code such as 'div[tab="advanced"]' into jQuery. Selectors with quotes inside of quotes would otherwise break jQuery. If you just want to escape quotes, there's escape_quotes_if...
[ "def", "_jq_format", "(", "code", ")", ":", "code", "=", "code", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", ".", "replace", "(", "'\\t'", ",", "'\\\\t'", ")", ".", "replace", "(", "'\\n'", ",", "'\\\\n'", ")", "code", "=", "code", ".", ...
DEPRECATED - Use re.escape() instead, which performs the intended action. Use before throwing raw code such as 'div[tab="advanced"]' into jQuery. Selectors with quotes inside of quotes would otherwise break jQuery. If you just want to escape quotes, there's escape_quotes_if_needed(). This is similar to ...
[ "DEPRECATED", "-", "Use", "re", ".", "escape", "()", "instead", "which", "performs", "the", "intended", "action", ".", "Use", "before", "throwing", "raw", "code", "such", "as", "div", "[", "tab", "=", "advanced", "]", "into", "jQuery", ".", "Selectors", ...
python
train
55.384615
crs4/pydoop
pydoop/mapreduce/api.py
https://github.com/crs4/pydoop/blob/f375be2a06f9c67eaae3ce6f605195dbca143b2b/pydoop/mapreduce/api.py#L66-L85
def get_bool(self, key, default=None): """ Same as :meth:`dict.get`, but the value is converted to a bool. The boolean value is considered, respectively, :obj:`True` or :obj:`False` if the string is equal, ignoring case, to ``'true'`` or ``'false'``. """ v = self...
[ "def", "get_bool", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "v", "=", "self", ".", "get", "(", "key", ",", "default", ")", "if", "v", "!=", "default", ":", "v", "=", "v", ".", "strip", "(", ")", ".", "lower", "(", ")", ...
Same as :meth:`dict.get`, but the value is converted to a bool. The boolean value is considered, respectively, :obj:`True` or :obj:`False` if the string is equal, ignoring case, to ``'true'`` or ``'false'``.
[ "Same", "as", ":", "meth", ":", "dict", ".", "get", "but", "the", "value", "is", "converted", "to", "a", "bool", "." ]
python
train
32.55
pyrapt/rapt
rapt/transformers/qtree/qtree_translator.py
https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/transformers/qtree/qtree_translator.py#L122-L131
def _binary(self, node): """ Translate a binary node into latex qtree node. :param node: a treebrd node :return: a qtree subtree rooted at the node """ return '[.${op}$ {left} {right} ]'\ .format(op=latex_operator[node.operator], left=self....
[ "def", "_binary", "(", "self", ",", "node", ")", ":", "return", "'[.${op}$ {left} {right} ]'", ".", "format", "(", "op", "=", "latex_operator", "[", "node", ".", "operator", "]", ",", "left", "=", "self", ".", "translate", "(", "node", ".", "left", ")", ...
Translate a binary node into latex qtree node. :param node: a treebrd node :return: a qtree subtree rooted at the node
[ "Translate", "a", "binary", "node", "into", "latex", "qtree", "node", ".", ":", "param", "node", ":", "a", "treebrd", "node", ":", "return", ":", "a", "qtree", "subtree", "rooted", "at", "the", "node" ]
python
train
38.6
deepmind/pysc2
pysc2/bin/replay_info.py
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/replay_info.py#L94-L104
def _replay_info(replay_path): """Query a replay for information.""" if not replay_path.lower().endswith("sc2replay"): print("Must be a replay.") return run_config = run_configs.get() with run_config.start(want_rgb=False) as controller: info = controller.replay_info(run_config.replay_data(replay_pa...
[ "def", "_replay_info", "(", "replay_path", ")", ":", "if", "not", "replay_path", ".", "lower", "(", ")", ".", "endswith", "(", "\"sc2replay\"", ")", ":", "print", "(", "\"Must be a replay.\"", ")", "return", "run_config", "=", "run_configs", ".", "get", "(",...
Query a replay for information.
[ "Query", "a", "replay", "for", "information", "." ]
python
train
31.454545
bcbio/bcbio-nextgen
scripts/utils/upload_to_synapse.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/upload_to_synapse.py#L50-L60
def _remote_folder(dirpath, remotes, syn): """Retrieve the remote folder for files, creating if necessary. """ if dirpath in remotes: return remotes[dirpath], remotes else: parent_dir, cur_dir = os.path.split(dirpath) parent_folder, remotes = _remote_folder(parent_dir, remotes, s...
[ "def", "_remote_folder", "(", "dirpath", ",", "remotes", ",", "syn", ")", ":", "if", "dirpath", "in", "remotes", ":", "return", "remotes", "[", "dirpath", "]", ",", "remotes", "else", ":", "parent_dir", ",", "cur_dir", "=", "os", ".", "path", ".", "spl...
Retrieve the remote folder for files, creating if necessary.
[ "Retrieve", "the", "remote", "folder", "for", "files", "creating", "if", "necessary", "." ]
python
train
43
HumanCellAtlas/cloud-blobstore
cloud_blobstore/gs.py
https://github.com/HumanCellAtlas/cloud-blobstore/blob/b8a60e8e8c0da0e39dda084cb467a34cd2d1ef0a/cloud_blobstore/gs.py#L167-L176
def delete(self, bucket: str, key: str): """ Deletes an object in a bucket. If the operation definitely did not delete anything, return False. Any other return value is treated as something was possibly deleted. """ bucket_obj = self._ensure_bucket_loaded(bucket) try: ...
[ "def", "delete", "(", "self", ",", "bucket", ":", "str", ",", "key", ":", "str", ")", ":", "bucket_obj", "=", "self", ".", "_ensure_bucket_loaded", "(", "bucket", ")", "try", ":", "bucket_obj", ".", "delete_blob", "(", "key", ")", "except", "NotFound", ...
Deletes an object in a bucket. If the operation definitely did not delete anything, return False. Any other return value is treated as something was possibly deleted.
[ "Deletes", "an", "object", "in", "a", "bucket", ".", "If", "the", "operation", "definitely", "did", "not", "delete", "anything", "return", "False", ".", "Any", "other", "return", "value", "is", "treated", "as", "something", "was", "possibly", "deleted", "." ...
python
train
39.9
coursera/courseraoauth2client
courseraoauth2client/commands/config.py
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L41-L79
def check_auth(args): """ Checks courseraoauth2client's connectivity to the coursera.org API servers for a specific application """ oauth2_instance = oauth2.build_oauth2(args.app, args) auth = oauth2_instance.build_authorizer() my_profile_url = ( 'https://api.coursera.org/api/externa...
[ "def", "check_auth", "(", "args", ")", ":", "oauth2_instance", "=", "oauth2", ".", "build_oauth2", "(", "args", ".", "app", ",", "args", ")", "auth", "=", "oauth2_instance", ".", "build_authorizer", "(", ")", "my_profile_url", "=", "(", "'https://api.coursera....
Checks courseraoauth2client's connectivity to the coursera.org API servers for a specific application
[ "Checks", "courseraoauth2client", "s", "connectivity", "to", "the", "coursera", ".", "org", "API", "servers", "for", "a", "specific", "application" ]
python
train
30.461538
gem/oq-engine
openquake/calculators/getters.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/getters.py#L609-L660
def get_ruptures(self, srcfilter=calc.filters.nofilter): """ :returns: a list of EBRuptures filtered by bounding box """ ebrs = [] with datastore.read(self.filename) as dstore: rupgeoms = dstore['rupgeoms'] for rec in self.rup_array: if src...
[ "def", "get_ruptures", "(", "self", ",", "srcfilter", "=", "calc", ".", "filters", ".", "nofilter", ")", ":", "ebrs", "=", "[", "]", "with", "datastore", ".", "read", "(", "self", ".", "filename", ")", "as", "dstore", ":", "rupgeoms", "=", "dstore", ...
:returns: a list of EBRuptures filtered by bounding box
[ ":", "returns", ":", "a", "list", "of", "EBRuptures", "filtered", "by", "bounding", "box" ]
python
train
48.826923
boriel/zxbasic
asmparse.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L329-L337
def define(self, value, lineno, namespace=None): """ Defines label value. It can be anything. Even an AST """ if self.defined: error(lineno, "label '%s' already defined at line %i" % (self.name, self.lineno)) self.value = value self.lineno = lineno self.names...
[ "def", "define", "(", "self", ",", "value", ",", "lineno", ",", "namespace", "=", "None", ")", ":", "if", "self", ".", "defined", ":", "error", "(", "lineno", ",", "\"label '%s' already defined at line %i\"", "%", "(", "self", ".", "name", ",", "self", "...
Defines label value. It can be anything. Even an AST
[ "Defines", "label", "value", ".", "It", "can", "be", "anything", ".", "Even", "an", "AST" ]
python
train
40.444444
gebn/wood
setup.py
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/setup.py#L5-L14
def _read_file(name, encoding='utf-8') -> str: """ Read the contents of a file. :param name: The name of the file in the current directory. :param encoding: The encoding of the file; defaults to utf-8. :return: The contents of the file. """ with open(name, encoding=encoding) as f: r...
[ "def", "_read_file", "(", "name", ",", "encoding", "=", "'utf-8'", ")", "->", "str", ":", "with", "open", "(", "name", ",", "encoding", "=", "encoding", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Read the contents of a file. :param name: The name of the file in the current directory. :param encoding: The encoding of the file; defaults to utf-8. :return: The contents of the file.
[ "Read", "the", "contents", "of", "a", "file", "." ]
python
train
32.5
klahnakoski/mo-logs
mo_logs/strings.py
https://github.com/klahnakoski/mo-logs/blob/0971277ac9caf28a755b766b70621916957d4fea/mo_logs/strings.py#L614-L661
def _simple_expand(template, seq): """ seq IS TUPLE OF OBJECTS IN PATH ORDER INTO THE DATA TREE seq[-1] IS THE CURRENT CONTEXT """ def replacer(found): ops = found.group(1).split("|") path = ops[0] var = path.lstrip(".") depth = min(len(seq), max(1, len(path) - len(...
[ "def", "_simple_expand", "(", "template", ",", "seq", ")", ":", "def", "replacer", "(", "found", ")", ":", "ops", "=", "found", ".", "group", "(", "1", ")", ".", "split", "(", "\"|\"", ")", "path", "=", "ops", "[", "0", "]", "var", "=", "path", ...
seq IS TUPLE OF OBJECTS IN PATH ORDER INTO THE DATA TREE seq[-1] IS THE CURRENT CONTEXT
[ "seq", "IS", "TUPLE", "OF", "OBJECTS", "IN", "PATH", "ORDER", "INTO", "THE", "DATA", "TREE", "seq", "[", "-", "1", "]", "IS", "THE", "CURRENT", "CONTEXT" ]
python
train
32.583333
pymoca/pymoca
src/pymoca/backends/xml/model.py
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/model.py#L110-L116
def create_function_f_y(self): """output function""" return ca.Function( 'y', [self.t, self.x, self.m, self.p, self.c, self.ng, self.nu], [self.y_rhs], ['t', 'x', 'm', 'p', 'c', 'ng', 'nu'], ['y'], self.func_opt)
[ "def", "create_function_f_y", "(", "self", ")", ":", "return", "ca", ".", "Function", "(", "'y'", ",", "[", "self", ".", "t", ",", "self", ".", "x", ",", "self", ".", "m", ",", "self", ".", "p", ",", "self", ".", "c", ",", "self", ".", "ng", ...
output function
[ "output", "function" ]
python
train
38.571429
boriel/zxbasic
arch/zx48k/backend/__8bit.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__8bit.py#L176-L241
def _sub8(ins): """ Pops last 2 bytes from the stack and subtract them. Then push the result onto the stack. Top-1 of the stack is subtracted Top _sub8 t1, a, b === t1 <-- a - b Optimizations: * If 2nd op is ZERO, then do NOTHING: A - 0 = A * If 1st operand is 0, then j...
[ "def", "_sub8", "(", "ins", ")", ":", "op1", ",", "op2", "=", "tuple", "(", "ins", ".", "quad", "[", "2", ":", "]", ")", "if", "is_int", "(", "op2", ")", ":", "# 2nd operand", "op2", "=", "int8", "(", "op2", ")", "output", "=", "_8bit_oper", "(...
Pops last 2 bytes from the stack and subtract them. Then push the result onto the stack. Top-1 of the stack is subtracted Top _sub8 t1, a, b === t1 <-- a - b Optimizations: * If 2nd op is ZERO, then do NOTHING: A - 0 = A * If 1st operand is 0, then just do a NEG * If...
[ "Pops", "last", "2", "bytes", "from", "the", "stack", "and", "subtract", "them", ".", "Then", "push", "the", "result", "onto", "the", "stack", ".", "Top", "-", "1", "of", "the", "stack", "is", "subtracted", "Top", "_sub8", "t1", "a", "b", "===", "t1"...
python
train
24.257576
shi-cong/PYSTUDY
PYSTUDY/ml/tensorflowlib.py
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/ml/tensorflowlib.py#L189-L198
def example_2_load_data(self): """ 加载数据 """ # 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层 self.w1 = Variable(random_normal([2, 3], stddev=1, seed=1)) self.w2 = Variable(random_normal([3, 1], stddev=1, seed=1)) # 特征向量, 区别是,这里不会在计算图中生成节点 #self.x = placeholder(float32, s...
[ "def", "example_2_load_data", "(", "self", ")", ":", "# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层", "self", ".", "w1", "=", "Variable", "(", "random_normal", "(", "[", "2", ",", "3", "]", ",", "stddev", "=", "1", ",", "seed", "=", "1", ")", ")", "self", ".", "w2...
加载数据
[ "加载数据" ]
python
train
40.3
carpedm20/ndrive
ndrive/client.py
https://github.com/carpedm20/ndrive/blob/ac58eaf8a8d46292ad752bb38047f65838b8ad2b/ndrive/client.py#L183-L202
def getRegisterUserInfo(self, svctype = "Android NDrive App ver", auth = 0): """Retrieve information about useridx :param svctype: Information about the platform you are using right now. :param auth: Authentication type :return: ``True`` when success or ``False`` when failed ""...
[ "def", "getRegisterUserInfo", "(", "self", ",", "svctype", "=", "\"Android NDrive App ver\"", ",", "auth", "=", "0", ")", ":", "data", "=", "{", "'userid'", ":", "self", ".", "user_id", ",", "'svctype'", ":", "svctype", ",", "'auth'", ":", "auth", "}", "...
Retrieve information about useridx :param svctype: Information about the platform you are using right now. :param auth: Authentication type :return: ``True`` when success or ``False`` when failed
[ "Retrieve", "information", "about", "useridx" ]
python
train
31.9
sosreport/sos
sos/plugins/__init__.py
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L718-L738
def get_option(self, optionname, default=0): """Returns the first value that matches 'optionname' in parameters passed in via the command line or set via set_option or via the global_plugin_options dictionary, in that order. optionaname may be iterable, in which case the first option th...
[ "def", "get_option", "(", "self", ",", "optionname", ",", "default", "=", "0", ")", ":", "global_options", "=", "(", "'verify'", ",", "'all_logs'", ",", "'log_size'", ",", "'plugin_timeout'", ")", "if", "optionname", "in", "global_options", ":", "return", "g...
Returns the first value that matches 'optionname' in parameters passed in via the command line or set via set_option or via the global_plugin_options dictionary, in that order. optionaname may be iterable, in which case the first option that matches any of the option names is returned.
[ "Returns", "the", "first", "value", "that", "matches", "optionname", "in", "parameters", "passed", "in", "via", "the", "command", "line", "or", "set", "via", "set_option", "or", "via", "the", "global_plugin_options", "dictionary", "in", "that", "order", "." ]
python
train
37.428571
Microsoft/botbuilder-python
libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py
https://github.com/Microsoft/botbuilder-python/blob/274663dd91c811bae6ac4488915ba5880771b0a7/libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py#L113-L149
async def parse_request(req): """ Parses and validates request :param req: :return: """ async def validate_activity(activity: Activity): if not isinstance(activity.type, str): raise TypeError('BotFrameworkAdapter.parse_request(): invalid or mi...
[ "async", "def", "parse_request", "(", "req", ")", ":", "async", "def", "validate_activity", "(", "activity", ":", "Activity", ")", ":", "if", "not", "isinstance", "(", "activity", ".", "type", ",", "str", ")", ":", "raise", "TypeError", "(", "'BotFramework...
Parses and validates request :param req: :return:
[ "Parses", "and", "validates", "request", ":", "param", "req", ":", ":", "return", ":" ]
python
test
41.540541
pyamg/pyamg
pyamg/gallery/random_sparse.py
https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/gallery/random_sparse.py#L11-L20
def _rand_sparse(m, n, density, format='csr'): """Construct base function for sprand, sprandn.""" nnz = max(min(int(m*n*density), m*n), 0) row = np.random.randint(low=0, high=m-1, size=nnz) col = np.random.randint(low=0, high=n-1, size=nnz) data = np.ones(nnz, dtype=float) # duplicate (i,j) en...
[ "def", "_rand_sparse", "(", "m", ",", "n", ",", "density", ",", "format", "=", "'csr'", ")", ":", "nnz", "=", "max", "(", "min", "(", "int", "(", "m", "*", "n", "*", "density", ")", ",", "m", "*", "n", ")", ",", "0", ")", "row", "=", "np", ...
Construct base function for sprand, sprandn.
[ "Construct", "base", "function", "for", "sprand", "sprandn", "." ]
python
train
40.6
maxcountryman/flask-login
flask_login/utils.py
https://github.com/maxcountryman/flask-login/blob/d22f80d166ee260d44e0d2d9ea973b784ef3621b/flask_login/utils.py#L142-L189
def login_user(user, remember=False, duration=None, force=False, fresh=True): ''' Logs a user in. You should pass the actual user object to this. If the user's `is_active` property is ``False``, they will not be logged in unless `force` is ``True``. This will return ``True`` if the log in attempt s...
[ "def", "login_user", "(", "user", ",", "remember", "=", "False", ",", "duration", "=", "None", ",", "force", "=", "False", ",", "fresh", "=", "True", ")", ":", "if", "not", "force", "and", "not", "user", ".", "is_active", ":", "return", "False", "use...
Logs a user in. You should pass the actual user object to this. If the user's `is_active` property is ``False``, they will not be logged in unless `force` is ``True``. This will return ``True`` if the log in attempt succeeds, and ``False`` if it fails (i.e. because the user is inactive). :param us...
[ "Logs", "a", "user", "in", ".", "You", "should", "pass", "the", "actual", "user", "object", "to", "this", ".", "If", "the", "user", "s", "is_active", "property", "is", "False", "they", "will", "not", "be", "logged", "in", "unless", "force", "is", "True...
python
train
44.75
potash/drain
drain/metrics.py
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/metrics.py#L86-L110
def precision(y_true, y_score, k=None, return_bounds=False): """ If return_bounds is False then returns precision on the labeled examples in the top k. If return_bounds is True the returns a tuple containing: - precision on the labeled examples in the top k - number of labeled exampl...
[ "def", "precision", "(", "y_true", ",", "y_score", ",", "k", "=", "None", ",", "return_bounds", "=", "False", ")", ":", "y_true", ",", "y_score", "=", "to_float", "(", "y_true", ",", "y_score", ")", "top", "=", "_argtop", "(", "y_score", ",", "k", ")...
If return_bounds is False then returns precision on the labeled examples in the top k. If return_bounds is True the returns a tuple containing: - precision on the labeled examples in the top k - number of labeled examples in the top k - lower bound of precision in the top k, assuming...
[ "If", "return_bounds", "is", "False", "then", "returns", "precision", "on", "the", "labeled", "examples", "in", "the", "top", "k", ".", "If", "return_bounds", "is", "True", "the", "returns", "a", "tuple", "containing", ":", "-", "precision", "on", "the", "...
python
train
38.36
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L1320-L1346
def resolve_to_objects_or_project(path, all_matching_results=False): ''' :param path: Path to resolve :type path: string :param all_matching_results: Whether to return a list of all matching results :type all_matching_results: boolean A thin wrapper over :meth:`resolve_existing_path` which thro...
[ "def", "resolve_to_objects_or_project", "(", "path", ",", "all_matching_results", "=", "False", ")", ":", "# Attempt to resolve name", "project", ",", "folderpath", ",", "entity_results", "=", "resolve_existing_path", "(", "path", ",", "expected", "=", "'entity'", ","...
:param path: Path to resolve :type path: string :param all_matching_results: Whether to return a list of all matching results :type all_matching_results: boolean A thin wrapper over :meth:`resolve_existing_path` which throws an error if the path does not look like a project and doesn't match a ...
[ ":", "param", "path", ":", "Path", "to", "resolve", ":", "type", "path", ":", "string", ":", "param", "all_matching_results", ":", "Whether", "to", "return", "a", "list", "of", "all", "matching", "results", ":", "type", "all_matching_results", ":", "boolean"...
python
train
54.703704
Autodesk/aomi
aomi/vault.py
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L206-L243
def connect(self, opt): """This sets up the tokens we expect to see in a way that hvac also expects.""" if not self._kwargs['verify']: LOG.warning('Skipping SSL Validation!') self.version = self.server_version() self.token = self.init_token() my_token = self....
[ "def", "connect", "(", "self", ",", "opt", ")", ":", "if", "not", "self", ".", "_kwargs", "[", "'verify'", "]", ":", "LOG", ".", "warning", "(", "'Skipping SSL Validation!'", ")", "self", ".", "version", "=", "self", ".", "server_version", "(", ")", "s...
This sets up the tokens we expect to see in a way that hvac also expects.
[ "This", "sets", "up", "the", "tokens", "we", "expect", "to", "see", "in", "a", "way", "that", "hvac", "also", "expects", "." ]
python
train
35.078947
sqlboy/fileseq
src/fileseq/frameset.py
https://github.com/sqlboy/fileseq/blob/f26c3c3c383134ce27d5dfe37793e1ebe88e69ad/src/fileseq/frameset.py#L948-L971
def isFrameRange(frange): """ Return True if the given string is a frame range. Any padding characters, such as '#' and '@' are ignored. Args: frange (str): a frame range to test Returns: bool: """ # we're willing to trim padding characte...
[ "def", "isFrameRange", "(", "frange", ")", ":", "# we're willing to trim padding characters from consideration", "# this translation is orders of magnitude faster than prior method", "frange", "=", "str", "(", "frange", ")", ".", "translate", "(", "None", ",", "''", ".", "j...
Return True if the given string is a frame range. Any padding characters, such as '#' and '@' are ignored. Args: frange (str): a frame range to test Returns: bool:
[ "Return", "True", "if", "the", "given", "string", "is", "a", "frame", "range", ".", "Any", "padding", "characters", "such", "as", "#", "and", "@", "are", "ignored", "." ]
python
train
31.25
saltstack/salt
salt/states/pkgbuild.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pkgbuild.py#L223-L380
def repo(name, keyid=None, env=None, use_passphrase=False, gnupghome='/etc/salt/gpgkeys', runas='builder', timeout=15.0): ''' Make a package repository and optionally sign it and packages present The name is directory to turn into a repo. This state is ...
[ "def", "repo", "(", "name", ",", "keyid", "=", "None", ",", "env", "=", "None", ",", "use_passphrase", "=", "False", ",", "gnupghome", "=", "'/etc/salt/gpgkeys'", ",", "runas", "=", "'builder'", ",", "timeout", "=", "15.0", ")", ":", "ret", "=", "{", ...
Make a package repository and optionally sign it and packages present The name is directory to turn into a repo. This state is best used with onchanges linked to your package building states. name The directory to find packages that will be in the repository keyid .. versionchanged:: ...
[ "Make", "a", "package", "repository", "and", "optionally", "sign", "it", "and", "packages", "present" ]
python
train
31.879747
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/modeling/rpn/inference.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/modeling/rpn/inference.py#L51-L72
def add_gt_proposals(self, proposals, targets): """ Arguments: proposals: list[BoxList] targets: list[BoxList] """ # Get the device we're operating on device = proposals[0].bbox.device gt_boxes = [target.copy_with_fields([]) for target in targets]...
[ "def", "add_gt_proposals", "(", "self", ",", "proposals", ",", "targets", ")", ":", "# Get the device we're operating on", "device", "=", "proposals", "[", "0", "]", ".", "bbox", ".", "device", "gt_boxes", "=", "[", "target", ".", "copy_with_fields", "(", "[",...
Arguments: proposals: list[BoxList] targets: list[BoxList]
[ "Arguments", ":", "proposals", ":", "list", "[", "BoxList", "]", "targets", ":", "list", "[", "BoxList", "]" ]
python
train
32.727273
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L5994-L6047
def gfoclt(occtyp, front, fshape, fframe, back, bshape, bframe, abcorr, obsrvr, step, cnfine, result=None): """ Determine time intervals when an observer sees one target occulted by, or in transit across, another. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfoclt_c.html :pa...
[ "def", "gfoclt", "(", "occtyp", ",", "front", ",", "fshape", ",", "fframe", ",", "back", ",", "bshape", ",", "bframe", ",", "abcorr", ",", "obsrvr", ",", "step", ",", "cnfine", ",", "result", "=", "None", ")", ":", "assert", "isinstance", "(", "cnfin...
Determine time intervals when an observer sees one target occulted by, or in transit across, another. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfoclt_c.html :param occtyp: Type of occultation. :type occtyp: str :param front: Name of body occulting the other. :type front: str ...
[ "Determine", "time", "intervals", "when", "an", "observer", "sees", "one", "target", "occulted", "by", "or", "in", "transit", "across", "another", "." ]
python
train
39.611111
msztolcman/versionner
versionner/vcs/git.py
https://github.com/msztolcman/versionner/blob/78fca02859e3e3eb71c9eb7ea230758944177c54/versionner/vcs/git.py#L13-L24
def tag(version, params): """Build and return full command to use with subprocess.Popen for 'git tag' command :param version: :param params: :return: list """ cmd = ['git', 'tag', '-a', '-m', 'v%s' % version, str(version)] if params: cmd.extend(params...
[ "def", "tag", "(", "version", ",", "params", ")", ":", "cmd", "=", "[", "'git'", ",", "'tag'", ",", "'-a'", ",", "'-m'", ",", "'v%s'", "%", "version", ",", "str", "(", "version", ")", "]", "if", "params", ":", "cmd", ".", "extend", "(", "params",...
Build and return full command to use with subprocess.Popen for 'git tag' command :param version: :param params: :return: list
[ "Build", "and", "return", "full", "command", "to", "use", "with", "subprocess", ".", "Popen", "for", "git", "tag", "command" ]
python
train
27.5
pantsbuild/pex
pex/bin/pex.py
https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/bin/pex.py#L627-L629
def make_relative_to_root(path): """Update options so that defaults are user relative to specified pex_root.""" return os.path.normpath(path.format(pex_root=ENV.PEX_ROOT))
[ "def", "make_relative_to_root", "(", "path", ")", ":", "return", "os", ".", "path", ".", "normpath", "(", "path", ".", "format", "(", "pex_root", "=", "ENV", ".", "PEX_ROOT", ")", ")" ]
Update options so that defaults are user relative to specified pex_root.
[ "Update", "options", "so", "that", "defaults", "are", "user", "relative", "to", "specified", "pex_root", "." ]
python
train
57.666667
mathandy/svgpathtools
svgpathtools/path.py
https://github.com/mathandy/svgpathtools/blob/fd7348a1dfd88b65ea61da02325c6605aedf8c4f/svgpathtools/path.py#L1620-L1630
def length(self, t0=0, t1=1, error=LENGTH_ERROR, min_depth=LENGTH_MIN_DEPTH): """The length of an elliptical large_arc segment requires numerical integration, and in that case it's simpler to just do a geometric approximation, as for cubic bezier curves.""" assert 0 <= t0 <= 1 and 0 <= t...
[ "def", "length", "(", "self", ",", "t0", "=", "0", ",", "t1", "=", "1", ",", "error", "=", "LENGTH_ERROR", ",", "min_depth", "=", "LENGTH_MIN_DEPTH", ")", ":", "assert", "0", "<=", "t0", "<=", "1", "and", "0", "<=", "t1", "<=", "1", "if", "_quad_...
The length of an elliptical large_arc segment requires numerical integration, and in that case it's simpler to just do a geometric approximation, as for cubic bezier curves.
[ "The", "length", "of", "an", "elliptical", "large_arc", "segment", "requires", "numerical", "integration", "and", "in", "that", "case", "it", "s", "simpler", "to", "just", "do", "a", "geometric", "approximation", "as", "for", "cubic", "bezier", "curves", "." ]
python
train
56.090909
xguse/table_enforcer
table_enforcer/main_classes.py
https://github.com/xguse/table_enforcer/blob/f3137839574bf8ea933a14ea16a8acba45e3e0c3/table_enforcer/main_classes.py#L152-L178
def validate(self, table: pd.DataFrame, failed_only=False) -> pd.DataFrame: """Return a dataframe of validation results for the appropriate series vs the vector of validators. Args: table (pd.DataFrame): A dataframe on which to apply validation logic. failed_only (bool): If ``Tr...
[ "def", "validate", "(", "self", ",", "table", ":", "pd", ".", "DataFrame", ",", "failed_only", "=", "False", ")", "->", "pd", ".", "DataFrame", ":", "series", "=", "table", "[", "self", ".", "name", "]", "self", ".", "_check_series_name", "(", "series"...
Return a dataframe of validation results for the appropriate series vs the vector of validators. Args: table (pd.DataFrame): A dataframe on which to apply validation logic. failed_only (bool): If ``True``: return only the indexes that failed to validate.
[ "Return", "a", "dataframe", "of", "validation", "results", "for", "the", "appropriate", "series", "vs", "the", "vector", "of", "validators", "." ]
python
train
33.703704
secdev/scapy
scapy/utils.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/utils.py#L1129-L1149
def read_block_idb(self, block, _): """Interface Description Block""" options = block[16:] tsresol = 1000000 while len(options) >= 4: code, length = struct.unpack(self.endian + "HH", options[:4]) # PCAP Next Generation (pcapng) Capture File Format # 4....
[ "def", "read_block_idb", "(", "self", ",", "block", ",", "_", ")", ":", "options", "=", "block", "[", "16", ":", "]", "tsresol", "=", "1000000", "while", "len", "(", "options", ")", ">=", "4", ":", "code", ",", "length", "=", "struct", ".", "unpack...
Interface Description Block
[ "Interface", "Description", "Block" ]
python
train
54.285714
StackStorm/pybind
pybind/slxos/v17s_1_02/overlay/access_list/type/vxlan/standard/seq/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/overlay/access_list/type/vxlan/standard/seq/__init__.py#L371-L392
def _set_vni_mask(self, v, load=False): """ Setter method for vni_mask, mapped from YANG variable /overlay/access_list/type/vxlan/standard/seq/vni_mask (string) If this variable is read-only (config: false) in the source YANG file, then _set_vni_mask is considered as a private method. Backends looki...
[ "def", "_set_vni_mask", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base"...
Setter method for vni_mask, mapped from YANG variable /overlay/access_list/type/vxlan/standard/seq/vni_mask (string) If this variable is read-only (config: false) in the source YANG file, then _set_vni_mask is considered as a private method. Backends looking to populate this variable should do so via ca...
[ "Setter", "method", "for", "vni_mask", "mapped", "from", "YANG", "variable", "/", "overlay", "/", "access_list", "/", "type", "/", "vxlan", "/", "standard", "/", "seq", "/", "vni_mask", "(", "string", ")", "If", "this", "variable", "is", "read", "-", "on...
python
train
85.136364
JoelBender/bacpypes
py34/bacpypes/primitivedata.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py34/bacpypes/primitivedata.py#L98-L139
def encode(self, pdu): """Encode a tag on the end of the PDU.""" # check for special encoding if (self.tagClass == Tag.contextTagClass): data = 0x08 elif (self.tagClass == Tag.openingTagClass): data = 0x0E elif (self.tagClass == Tag.closingTagClass): ...
[ "def", "encode", "(", "self", ",", "pdu", ")", ":", "# check for special encoding", "if", "(", "self", ".", "tagClass", "==", "Tag", ".", "contextTagClass", ")", ":", "data", "=", "0x08", "elif", "(", "self", ".", "tagClass", "==", "Tag", ".", "openingTa...
Encode a tag on the end of the PDU.
[ "Encode", "a", "tag", "on", "the", "end", "of", "the", "PDU", "." ]
python
train
28.714286
Microsoft/nni
src/sdk/pynni/nni/metis_tuner/Regression_GP/CreateModel.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/CreateModel.py#L30-L52
def create_model(samples_x, samples_y_aggregation, n_restarts_optimizer=250, is_white_kernel=False): ''' Trains GP regression model ''' kernel = gp.kernels.ConstantKernel(constant_value=1, constant_value_bounds=(1e-12, 1e12)) * \ ...
[ "def", "create_model", "(", "samples_x", ",", "samples_y_aggregation", ",", "n_restarts_optimizer", "=", "250", ",", "is_white_kernel", "=", "False", ")", ":", "kernel", "=", "gp", ".", "kernels", ".", "ConstantKernel", "(", "constant_value", "=", "1", ",", "c...
Trains GP regression model
[ "Trains", "GP", "regression", "model" ]
python
train
46.608696
nyergler/hieroglyph
src/hieroglyph/writer.py
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/writer.py#L135-L143
def _add_slide_footer(self, slide_no): """Add the slide footer to the output if enabled.""" if self.builder.config.slide_footer: self.body.append( '\n<div class="slide-footer">%s</div>\n' % ( self.builder.config.slide_footer, ), ...
[ "def", "_add_slide_footer", "(", "self", ",", "slide_no", ")", ":", "if", "self", ".", "builder", ".", "config", ".", "slide_footer", ":", "self", ".", "body", ".", "append", "(", "'\\n<div class=\"slide-footer\">%s</div>\\n'", "%", "(", "self", ".", "builder"...
Add the slide footer to the output if enabled.
[ "Add", "the", "slide", "footer", "to", "the", "output", "if", "enabled", "." ]
python
train
35
calmjs/calmjs.parse
src/calmjs/parse/parsers/es5.py
https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/parsers/es5.py#L1079-L1089
def p_variable_declaration_list(self, p): """ variable_declaration_list \ : variable_declaration | variable_declaration_list COMMA variable_declaration """ if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1...
[ "def", "p_variable_declaration_list", "(", "self", ",", "p", ")", ":", "if", "len", "(", "p", ")", "==", "2", ":", "p", "[", "0", "]", "=", "[", "p", "[", "1", "]", "]", "else", ":", "p", "[", "1", "]", ".", "append", "(", "p", "[", "3", ...
variable_declaration_list \ : variable_declaration | variable_declaration_list COMMA variable_declaration
[ "variable_declaration_list", "\\", ":", "variable_declaration", "|", "variable_declaration_list", "COMMA", "variable_declaration" ]
python
train
28.272727
xolox/python-coloredlogs
coloredlogs/cli.py
https://github.com/xolox/python-coloredlogs/blob/1cbf0c6bbee400c6ddbc43008143809934ec3e79/coloredlogs/cli.py#L60-L87
def main(): """Command line interface for the ``coloredlogs`` program.""" actions = [] try: # Parse the command line arguments. options, arguments = getopt.getopt(sys.argv[1:], 'cdh', [ 'convert', 'to-html', 'demo', 'help', ]) # Map command line options to actions...
[ "def", "main", "(", ")", ":", "actions", "=", "[", "]", "try", ":", "# Parse the command line arguments.", "options", ",", "arguments", "=", "getopt", ".", "getopt", "(", "sys", ".", "argv", "[", "1", ":", "]", ",", "'cdh'", ",", "[", "'convert'", ",",...
Command line interface for the ``coloredlogs`` program.
[ "Command", "line", "interface", "for", "the", "coloredlogs", "program", "." ]
python
train
35.571429
lingthio/Flask-User
flask_user/user_manager__views.py
https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/user_manager__views.py#L423-L518
def register_view(self): """ Display registration form and create new User.""" safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_LOGIN_ENDPOINT) safe_reg_next_url = self._get_safe_next_url('reg_next', self.USER_AFTER_REGISTER_ENDPOINT) # Initialize form login_form...
[ "def", "register_view", "(", "self", ")", ":", "safe_next_url", "=", "self", ".", "_get_safe_next_url", "(", "'next'", ",", "self", ".", "USER_AFTER_LOGIN_ENDPOINT", ")", "safe_reg_next_url", "=", "self", ".", "_get_safe_next_url", "(", "'reg_next'", ",", "self", ...
Display registration form and create new User.
[ "Display", "registration", "form", "and", "create", "new", "User", "." ]
python
train
48.010417
NetworkAutomation/jaide
jaide/cli.py
https://github.com/NetworkAutomation/jaide/blob/8571b987a8c24c246dc09f1bcc11cb0f045ec33f/jaide/cli.py#L302-L366
def commit(ctx, commands, blank, check, sync, comment, confirm, at_time): """ Execute a commit against the device. Purpose: This function will send set commands to a device, and commit | the changes. Options exist for confirming, comments, | synchronizing, checking, blank commits, or dela...
[ "def", "commit", "(", "ctx", ",", "commands", ",", "blank", ",", "check", ",", "sync", ",", "comment", ",", "confirm", ",", "at_time", ")", ":", "if", "not", "blank", "and", "commands", "==", "'annotate system \"\"'", ":", "raise", "click", ".", "BadPara...
Execute a commit against the device. Purpose: This function will send set commands to a device, and commit | the changes. Options exist for confirming, comments, | synchronizing, checking, blank commits, or delaying to a later | time/date. @param ctx: The click context paramte...
[ "Execute", "a", "commit", "against", "the", "device", "." ]
python
train
51.6
chdzq/ARPAbetAndIPAConvertor
arpabetandipaconvertor/model/syllable.py
https://github.com/chdzq/ARPAbetAndIPAConvertor/blob/e8b2fdbb5b7134c4f779f4d6dcd5dc30979a0a26/arpabetandipaconvertor/model/syllable.py#L72-L84
def translate_to_english_phonetic_alphabet(self, hide_stress_mark=False): ''' 转换成英音。只要一个元音的时候需要隐藏重音标识 :param hide_stress_mark: :return: ''' translations = self.stress.mark_ipa() if (not hide_stress_mark) and self.have_vowel else "" for phoneme in self._phoneme_l...
[ "def", "translate_to_english_phonetic_alphabet", "(", "self", ",", "hide_stress_mark", "=", "False", ")", ":", "translations", "=", "self", ".", "stress", ".", "mark_ipa", "(", ")", "if", "(", "not", "hide_stress_mark", ")", "and", "self", ".", "have_vowel", "...
转换成英音。只要一个元音的时候需要隐藏重音标识 :param hide_stress_mark: :return:
[ "转换成英音。只要一个元音的时候需要隐藏重音标识", ":", "param", "hide_stress_mark", ":", ":", "return", ":" ]
python
train
29.615385
WebarchivCZ/WA-KAT
src/wa_kat/templates/static/js/Lib/site-packages/components/conspect_handler.py
https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/templates/static/js/Lib/site-packages/components/conspect_handler.py#L152-L161
def get_dict(cls): """ Return dictionary with conspect / subconspect info. """ mdt = cls.get() if not mdt: return {} return conspectus.subs_by_mdt.get(mdt, {})
[ "def", "get_dict", "(", "cls", ")", ":", "mdt", "=", "cls", ".", "get", "(", ")", "if", "not", "mdt", ":", "return", "{", "}", "return", "conspectus", ".", "subs_by_mdt", ".", "get", "(", "mdt", ",", "{", "}", ")" ]
Return dictionary with conspect / subconspect info.
[ "Return", "dictionary", "with", "conspect", "/", "subconspect", "info", "." ]
python
train
21.2
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py#L499-L542
def findLibrary(name): """ Look for a library in the system. Emulate the algorithm used by dlopen. `name`must include the prefix, e.g. ``libpython2.4.so`` """ assert is_unix, "Current implementation for Unix only (Linux, Solaris, AIX)" lib = None # Look in the LD_LIBRARY_PATH lp =...
[ "def", "findLibrary", "(", "name", ")", ":", "assert", "is_unix", ",", "\"Current implementation for Unix only (Linux, Solaris, AIX)\"", "lib", "=", "None", "# Look in the LD_LIBRARY_PATH", "lp", "=", "compat", ".", "getenv", "(", "'LD_LIBRARY_PATH'", ",", "''", ")", ...
Look for a library in the system. Emulate the algorithm used by dlopen. `name`must include the prefix, e.g. ``libpython2.4.so``
[ "Look", "for", "a", "library", "in", "the", "system", "." ]
python
train
27.090909
wavefrontHQ/python-client
wavefront_api_client/api/search_api.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/search_api.py#L131-L152
def search_alert_deleted_for_facet(self, facet, **kwargs): # noqa: E501 """Lists the values of a specific facet over the customer's deleted alerts # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asy...
[ "def", "search_alert_deleted_for_facet", "(", "self", ",", "facet", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", "....
Lists the values of a specific facet over the customer's deleted alerts # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.search_alert_deleted_for_facet(facet, async_req...
[ "Lists", "the", "values", "of", "a", "specific", "facet", "over", "the", "customer", "s", "deleted", "alerts", "#", "noqa", ":", "E501" ]
python
train
46.727273
jantman/awslimitchecker
awslimitchecker/services/vpc.py
https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/services/vpc.py#L339-L359
def _update_limits_from_api(self): """ Query EC2's DescribeAccountAttributes API action and update the network interface limit, as needed. Updates ``self.limits``. More info on the network interface limit, from the docs: 'This limit is the greater of either the default limit (35...
[ "def", "_update_limits_from_api", "(", "self", ")", ":", "self", ".", "connect", "(", ")", "self", ".", "connect_resource", "(", ")", "logger", ".", "info", "(", "\"Querying EC2 DescribeAccountAttributes for limits\"", ")", "attribs", "=", "self", ".", "conn", "...
Query EC2's DescribeAccountAttributes API action and update the network interface limit, as needed. Updates ``self.limits``. More info on the network interface limit, from the docs: 'This limit is the greater of either the default limit (350) or your On-Demand Instance limit multiplied ...
[ "Query", "EC2", "s", "DescribeAccountAttributes", "API", "action", "and", "update", "the", "network", "interface", "limit", "as", "needed", ".", "Updates", "self", ".", "limits", "." ]
python
train
49.52381
stefanfoulis/django-sendsms
sendsms/backends/nexmo.py
https://github.com/stefanfoulis/django-sendsms/blob/375f469789866853253eceba936ebcff98e83c07/sendsms/backends/nexmo.py#L144-L158
def send_messages(self, messages): """ Send messages. :param list messages: List of SmsMessage instances. :returns: number of messages sended successful. :rtype: int """ counter = 0 for message in messages: res, _ = self._send(message) ...
[ "def", "send_messages", "(", "self", ",", "messages", ")", ":", "counter", "=", "0", "for", "message", "in", "messages", ":", "res", ",", "_", "=", "self", ".", "_send", "(", "message", ")", "if", "res", ":", "counter", "+=", "1", "return", "counter"...
Send messages. :param list messages: List of SmsMessage instances. :returns: number of messages sended successful. :rtype: int
[ "Send", "messages", "." ]
python
train
24.733333
OSLL/jabba
jabba/dep_extractor.py
https://github.com/OSLL/jabba/blob/71c1d008ab497020fba6ffa12a600721eb3f5ef7/jabba/dep_extractor.py#L58-L90
def get_calls_from_dict(self, file_dict, from_name, settings={}): ''' Processes unfolded yaml object to CallEdge array settings is a dict of settings for keeping information like in what section we are right now (e.g. builders, publishers) ''' calls = [] call_se...
[ "def", "get_calls_from_dict", "(", "self", ",", "file_dict", ",", "from_name", ",", "settings", "=", "{", "}", ")", ":", "calls", "=", "[", "]", "call_settings", "=", "dict", "(", "settings", ")", "# Include all possible sections", "# The way to draw them is defin...
Processes unfolded yaml object to CallEdge array settings is a dict of settings for keeping information like in what section we are right now (e.g. builders, publishers)
[ "Processes", "unfolded", "yaml", "object", "to", "CallEdge", "array" ]
python
train
36.515152
xray7224/PyPump
pypump/models/__init__.py
https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/__init__.py#L405-L420
def comment(self, comment): """ Add a :class:`Comment <pypump.models.comment.Comment>` to the object. :param comment: A :class:`Comment <pypump.models.comment.Comment>` instance, text content is also accepted. Example: >>> anote.comment(pump.Comment('I agree!'))...
[ "def", "comment", "(", "self", ",", "comment", ")", ":", "if", "isinstance", "(", "comment", ",", "six", ".", "string_types", ")", ":", "comment", "=", "self", ".", "_pump", ".", "Comment", "(", "comment", ")", "comment", ".", "in_reply_to", "=", "self...
Add a :class:`Comment <pypump.models.comment.Comment>` to the object. :param comment: A :class:`Comment <pypump.models.comment.Comment>` instance, text content is also accepted. Example: >>> anote.comment(pump.Comment('I agree!'))
[ "Add", "a", ":", "class", ":", "Comment", "<pypump", ".", "models", ".", "comment", ".", "Comment", ">", "to", "the", "object", "." ]
python
train
30.0625
kmpm/nodemcu-uploader
nodemcu_uploader/main.py
https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/main.py#L94-L108
def operation_file(uploader, cmd, filename=''): """File operations""" if cmd == 'list': operation_list(uploader) if cmd == 'do': for path in filename: uploader.file_do(path) elif cmd == 'format': uploader.file_format() elif cmd == 'remove': for path in fil...
[ "def", "operation_file", "(", "uploader", ",", "cmd", ",", "filename", "=", "''", ")", ":", "if", "cmd", "==", "'list'", ":", "operation_list", "(", "uploader", ")", "if", "cmd", "==", "'do'", ":", "for", "path", "in", "filename", ":", "uploader", ".",...
File operations
[ "File", "operations" ]
python
valid
29.6
ns1/ns1-python
ns1/__init__.py
https://github.com/ns1/ns1-python/blob/f3e1d90a3b76a1bd18f855f2c622a8a49d4b585e/ns1/__init__.py#L312-L321
def loadScopeGroupbyName(self, name, service_group_id, callback=None, errback=None): """ Load an existing Scope Group by name and service group id into a high level Scope Group object :param str name: Name of an existing Scope Group :param int service_group_id: id of the service group t...
[ "def", "loadScopeGroupbyName", "(", "self", ",", "name", ",", "service_group_id", ",", "callback", "=", "None", ",", "errback", "=", "None", ")", ":", "import", "ns1", ".", "ipam", "scope_group", "=", "ns1", ".", "ipam", ".", "Scopegroup", "(", "self", "...
Load an existing Scope Group by name and service group id into a high level Scope Group object :param str name: Name of an existing Scope Group :param int service_group_id: id of the service group the Scope group is associated with
[ "Load", "an", "existing", "Scope", "Group", "by", "name", "and", "service", "group", "id", "into", "a", "high", "level", "Scope", "Group", "object" ]
python
train
54.9
roclark/sportsreference
sportsreference/nfl/schedule.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/schedule.py#L216-L229
def week(self): """ Returns an ``int`` of the week number in the season, such as 1 for the first week of the regular season. """ if self._week.lower() == 'wild card': return WILD_CARD if self._week.lower() == 'division': return DIVISION if ...
[ "def", "week", "(", "self", ")", ":", "if", "self", ".", "_week", ".", "lower", "(", ")", "==", "'wild card'", ":", "return", "WILD_CARD", "if", "self", ".", "_week", ".", "lower", "(", ")", "==", "'division'", ":", "return", "DIVISION", "if", "self"...
Returns an ``int`` of the week number in the season, such as 1 for the first week of the regular season.
[ "Returns", "an", "int", "of", "the", "week", "number", "in", "the", "season", "such", "as", "1", "for", "the", "first", "week", "of", "the", "regular", "season", "." ]
python
train
34.5
edeposit/edeposit.amqp.calibre
src/edeposit/amqp/calibre/calibre.py
https://github.com/edeposit/edeposit.amqp.calibre/blob/60ba5de0c30452d41f6e0da58d2ec6729ebdd7f1/src/edeposit/amqp/calibre/calibre.py#L21-L43
def _wrap(text, columns=80): """ Own "dumb" reimplementation of textwrap.wrap(). This is because calling .wrap() on bigger strings can take a LOT of processor power. And I mean like 8 seconds of 3GHz CPU just to wrap 20kB of text without spaces. Args: text (str): Text to wrap. ...
[ "def", "_wrap", "(", "text", ",", "columns", "=", "80", ")", ":", "out", "=", "[", "]", "for", "cnt", ",", "char", "in", "enumerate", "(", "text", ")", ":", "out", ".", "append", "(", "char", ")", "if", "(", "cnt", "+", "1", ")", "%", "column...
Own "dumb" reimplementation of textwrap.wrap(). This is because calling .wrap() on bigger strings can take a LOT of processor power. And I mean like 8 seconds of 3GHz CPU just to wrap 20kB of text without spaces. Args: text (str): Text to wrap. columns (int): Wrap after `columns` chara...
[ "Own", "dumb", "reimplementation", "of", "textwrap", ".", "wrap", "()", "." ]
python
train
24.434783
log2timeline/plaso
plaso/output/shared_elastic.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/shared_elastic.py#L298-L316
def SetCACertificatesPath(self, ca_certificates_path): """Sets the path to the CA certificates. Args: ca_certificates_path (str): path to file containing a list of root certificates to trust. Raises: BadConfigOption: if the CA certificates file does not exist. """ if not ca_cer...
[ "def", "SetCACertificatesPath", "(", "self", ",", "ca_certificates_path", ")", ":", "if", "not", "ca_certificates_path", ":", "return", "if", "not", "os", ".", "path", ".", "exists", "(", "ca_certificates_path", ")", ":", "raise", "errors", ".", "BadConfigOption...
Sets the path to the CA certificates. Args: ca_certificates_path (str): path to file containing a list of root certificates to trust. Raises: BadConfigOption: if the CA certificates file does not exist.
[ "Sets", "the", "path", "to", "the", "CA", "certificates", "." ]
python
train
32.263158
smnorris/bcdata
bcdata/wfs.py
https://github.com/smnorris/bcdata/blob/de6b5bbc28d85e36613b51461911ee0a72a146c5/bcdata/wfs.py#L36-L48
def check_cache(path): """Return true if the cache file holding list of all datasets does not exist or is older than 30 days """ if not os.path.exists(path): return True else: # check the age mod_date = datetime.fromtimestamp(os.path.getmtime(path)) if mod_date < (dat...
[ "def", "check_cache", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "True", "else", ":", "# check the age", "mod_date", "=", "datetime", ".", "fromtimestamp", "(", "os", ".", "path", ".", "getmti...
Return true if the cache file holding list of all datasets does not exist or is older than 30 days
[ "Return", "true", "if", "the", "cache", "file", "holding", "list", "of", "all", "datasets", "does", "not", "exist", "or", "is", "older", "than", "30", "days" ]
python
train
31.153846
bitesofcode/projexui
projexui/widgets/xorbbrowserwidget/xorbbrowserwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xorbbrowserwidget.py#L373-L381
def handleCardDblClick( self, item ): """ Handles when a card item is double clicked on. :param item | <QTreeWidgetItem> """ widget = self.uiCardTREE.itemWidget(item, 0) if ( isinstance(widget, XAbstractCardWidget) ): self.emitRecordDoubl...
[ "def", "handleCardDblClick", "(", "self", ",", "item", ")", ":", "widget", "=", "self", ".", "uiCardTREE", ".", "itemWidget", "(", "item", ",", "0", ")", "if", "(", "isinstance", "(", "widget", ",", "XAbstractCardWidget", ")", ")", ":", "self", ".", "e...
Handles when a card item is double clicked on. :param item | <QTreeWidgetItem>
[ "Handles", "when", "a", "card", "item", "is", "double", "clicked", "on", ".", ":", "param", "item", "|", "<QTreeWidgetItem", ">" ]
python
train
37.444444
SKA-ScienceDataProcessor/integration-prototype
sip/science_pipeline_workflows/ical_dask/pipelines/imaging_processing.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/science_pipeline_workflows/ical_dask/pipelines/imaging_processing.py#L38-L42
def init_logging(): """Initialise Python logging.""" fmt = '%(asctime)s.%(msecs)03d | %(name)-60s | %(levelname)-7s ' \ '| %(message)s' logging.basicConfig(format=fmt, datefmt='%H:%M:%S', level=logging.DEBUG)
[ "def", "init_logging", "(", ")", ":", "fmt", "=", "'%(asctime)s.%(msecs)03d | %(name)-60s | %(levelname)-7s '", "'| %(message)s'", "logging", ".", "basicConfig", "(", "format", "=", "fmt", ",", "datefmt", "=", "'%H:%M:%S'", ",", "level", "=", "logging", ".", "DEBUG"...
Initialise Python logging.
[ "Initialise", "Python", "logging", "." ]
python
train
45.2
assamite/creamas
creamas/math.py
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/math.py#L10-L22
def gaus_pdf(x, mean, std): '''Gaussian distribution's probability density function. See, e.g. `Wikipedia <https://en.wikipedia.org/wiki/Normal_distribution>`_. :param x: point in x-axis :type x: float or numpy.ndarray :param float mean: mean or expectation :param float str: standard deviation...
[ "def", "gaus_pdf", "(", "x", ",", "mean", ",", "std", ")", ":", "return", "exp", "(", "-", "(", "(", "x", "-", "mean", ")", "/", "std", ")", "**", "2", "/", "2", ")", "/", "sqrt", "(", "2", "*", "pi", ")", "/", "std" ]
Gaussian distribution's probability density function. See, e.g. `Wikipedia <https://en.wikipedia.org/wiki/Normal_distribution>`_. :param x: point in x-axis :type x: float or numpy.ndarray :param float mean: mean or expectation :param float str: standard deviation :returns: pdf(s) in point **x*...
[ "Gaussian", "distribution", "s", "probability", "density", "function", "." ]
python
train
34.692308
d0c-s4vage/pfp
pfp/interp.py
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1744-L1769
def _handle_id(self, node, scope, ctxt, stream): """Handle an ID node (return a field object for the ID) :node: TODO :scope: TODO :ctxt: TODO :stream: TODO :returns: TODO """ if node.name == "__root": return self._root if node.name ==...
[ "def", "_handle_id", "(", "self", ",", "node", ",", "scope", ",", "ctxt", ",", "stream", ")", ":", "if", "node", ".", "name", "==", "\"__root\"", ":", "return", "self", ".", "_root", "if", "node", ".", "name", "==", "\"__this\"", "or", "node", ".", ...
Handle an ID node (return a field object for the ID) :node: TODO :scope: TODO :ctxt: TODO :stream: TODO :returns: TODO
[ "Handle", "an", "ID", "node", "(", "return", "a", "field", "object", "for", "the", "ID", ")" ]
python
train
26.692308
cackharot/suds-py3
suds/sax/date.py
https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/sax/date.py#L392-L415
def time_from_match(match_object): """Create a time object from a regular expression match. The regular expression match is expected to be from RE_TIME or RE_DATETIME. @param match_object: The regular expression match. @type value: B{re}.I{MatchObject} @return: A date object. @rtype: B{datetim...
[ "def", "time_from_match", "(", "match_object", ")", ":", "hour", "=", "int", "(", "match_object", ".", "group", "(", "'hour'", ")", ")", "minute", "=", "int", "(", "match_object", ".", "group", "(", "'minute'", ")", ")", "second", "=", "int", "(", "mat...
Create a time object from a regular expression match. The regular expression match is expected to be from RE_TIME or RE_DATETIME. @param match_object: The regular expression match. @type value: B{re}.I{MatchObject} @return: A date object. @rtype: B{datetime}.I{time}
[ "Create", "a", "time", "object", "from", "a", "regular", "expression", "match", "." ]
python
train
34.041667
rosenbrockc/fortpy
fortpy/interop/converter.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/interop/converter.py#L327-L341
def write(self, valuedict, version): """Generates the lines for the converted input file from the valuedict. :arg valuedict: a dictionary of values where the keys are ids in the template and the values obey their template rules. :arg version: the target version of the output file. ...
[ "def", "write", "(", "self", ",", "valuedict", ",", "version", ")", ":", "result", "=", "[", "]", "if", "version", "in", "self", ".", "versions", ":", "for", "tag", "in", "self", ".", "versions", "[", "version", "]", ".", "order", ":", "entry", "="...
Generates the lines for the converted input file from the valuedict. :arg valuedict: a dictionary of values where the keys are ids in the template and the values obey their template rules. :arg version: the target version of the output file.
[ "Generates", "the", "lines", "for", "the", "converted", "input", "file", "from", "the", "valuedict", "." ]
python
train
37.466667
closeio/redis-hashring
redis_hashring/__init__.py
https://github.com/closeio/redis-hashring/blob/d767018571fbfb5705b6115d81619b2e84b6e50e/redis_hashring/__init__.py#L244-L261
def update(self): """ Fetches the updated ring from Redis and updates the current ranges. """ ring = self._fetch() n_replicas = len(ring) replica_set = set([r[1] for r in self.replicas]) self.ranges = [] for n, (start, replica) in enumerate(ring): ...
[ "def", "update", "(", "self", ")", ":", "ring", "=", "self", ".", "_fetch", "(", ")", "n_replicas", "=", "len", "(", "ring", ")", "replica_set", "=", "set", "(", "[", "r", "[", "1", "]", "for", "r", "in", "self", ".", "replicas", "]", ")", "sel...
Fetches the updated ring from Redis and updates the current ranges.
[ "Fetches", "the", "updated", "ring", "from", "Redis", "and", "updates", "the", "current", "ranges", "." ]
python
train
38.833333
poldracklab/niworkflows
niworkflows/interfaces/masks.py
https://github.com/poldracklab/niworkflows/blob/254f4b4fcc5e6ecb29d2f4602a30786b913ecce5/niworkflows/interfaces/masks.py#L46-L58
def _post_run_hook(self, runtime): ''' generates a report showing slices from each axis of an arbitrary volume of in_file, with the resulting binary brain mask overlaid ''' self._anat_file = self.inputs.in_file self._mask_file = self.aggregate_outputs(runtime=runtime).mask_file ...
[ "def", "_post_run_hook", "(", "self", ",", "runtime", ")", ":", "self", ".", "_anat_file", "=", "self", ".", "inputs", ".", "in_file", "self", ".", "_mask_file", "=", "self", ".", "aggregate_outputs", "(", "runtime", "=", "runtime", ")", ".", "mask_file", ...
generates a report showing slices from each axis of an arbitrary volume of in_file, with the resulting binary brain mask overlaid
[ "generates", "a", "report", "showing", "slices", "from", "each", "axis", "of", "an", "arbitrary", "volume", "of", "in_file", "with", "the", "resulting", "binary", "brain", "mask", "overlaid" ]
python
train
45.846154
lrq3000/pyFileFixity
pyFileFixity/lib/aux_funcs.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/aux_funcs.py#L43-L47
def fullpath(relpath): '''Relative path to absolute''' if (type(relpath) is object or type(relpath) is file): relpath = relpath.name return os.path.abspath(os.path.expanduser(relpath))
[ "def", "fullpath", "(", "relpath", ")", ":", "if", "(", "type", "(", "relpath", ")", "is", "object", "or", "type", "(", "relpath", ")", "is", "file", ")", ":", "relpath", "=", "relpath", ".", "name", "return", "os", ".", "path", ".", "abspath", "("...
Relative path to absolute
[ "Relative", "path", "to", "absolute" ]
python
train
40
ranaroussi/pywallet
pywallet/utils/utils.py
https://github.com/ranaroussi/pywallet/blob/206ff224389c490d8798f660c9e79fe97ebb64cf/pywallet/utils/utils.py#L47-L53
def long_to_hex(l, size): """Encode a long value as a hex string, 0-padding to size. Note that size is the size of the resulting hex string. So, for a 32Byte long size should be 64 (two hex characters per byte".""" f_str = "{0:0%sx}" % size return ensure_bytes(f_str.format(l).lower())
[ "def", "long_to_hex", "(", "l", ",", "size", ")", ":", "f_str", "=", "\"{0:0%sx}\"", "%", "size", "return", "ensure_bytes", "(", "f_str", ".", "format", "(", "l", ")", ".", "lower", "(", ")", ")" ]
Encode a long value as a hex string, 0-padding to size. Note that size is the size of the resulting hex string. So, for a 32Byte long size should be 64 (two hex characters per byte".
[ "Encode", "a", "long", "value", "as", "a", "hex", "string", "0", "-", "padding", "to", "size", "." ]
python
train
42.857143
zyga/json-schema-validator
json_schema_validator/validator.py
https://github.com/zyga/json-schema-validator/blob/0504605da5c0a9a5b5b05c41b37661aec9652144/json_schema_validator/validator.py#L166-L169
def _push_property_schema(self, prop): """Construct a sub-schema from a property of the current schema.""" schema = Schema(self._schema.properties[prop]) self._push_schema(schema, ".properties." + prop)
[ "def", "_push_property_schema", "(", "self", ",", "prop", ")", ":", "schema", "=", "Schema", "(", "self", ".", "_schema", ".", "properties", "[", "prop", "]", ")", "self", ".", "_push_schema", "(", "schema", ",", "\".properties.\"", "+", "prop", ")" ]
Construct a sub-schema from a property of the current schema.
[ "Construct", "a", "sub", "-", "schema", "from", "a", "property", "of", "the", "current", "schema", "." ]
python
train
55.75
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_threshold_monitor.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_threshold_monitor.py#L12-L23
def threshold_monitor_hidden_threshold_monitor_sfp_apply(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") threshold_monitor_hidden = ET.SubElement(config, "threshold-monitor-hidden", xmlns="urn:brocade.com:mgmt:brocade-threshold-monitor") threshold_monito...
[ "def", "threshold_monitor_hidden_threshold_monitor_sfp_apply", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "threshold_monitor_hidden", "=", "ET", ".", "SubElement", "(", "config", ",", "\"threshold-m...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
50.25
ic-labs/django-icekit
icekit/publishing/models.py
https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit/publishing/models.py#L357-L363
def publishing_prepare_published_copy(self, draft_obj): """ Prepare published copy of draft prior to saving it """ # We call super here, somewhat perversely, to ensure this method will # be called on publishable subclasses if implemented there. mysuper = super(PublishingModel, self) ...
[ "def", "publishing_prepare_published_copy", "(", "self", ",", "draft_obj", ")", ":", "# We call super here, somewhat perversely, to ensure this method will", "# be called on publishable subclasses if implemented there.", "mysuper", "=", "super", "(", "PublishingModel", ",", "self", ...
Prepare published copy of draft prior to saving it
[ "Prepare", "published", "copy", "of", "draft", "prior", "to", "saving", "it" ]
python
train
62.857143
alfred82santa/dirty-models
dirty_models/models.py
https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L203-L228
def set_field_value(self, name, value): """ Set the value to the field modified_data """ name = self.get_real_name(name) if not name or not self._can_write_field(name): return if name in self.__deleted_fields__: self.__deleted_fields__.remove(nam...
[ "def", "set_field_value", "(", "self", ",", "name", ",", "value", ")", ":", "name", "=", "self", ".", "get_real_name", "(", "name", ")", "if", "not", "name", "or", "not", "self", ".", "_can_write_field", "(", "name", ")", ":", "return", "if", "name", ...
Set the value to the field modified_data
[ "Set", "the", "value", "to", "the", "field", "modified_data" ]
python
train
30.653846
rigetti/quantumflow
quantumflow/states.py
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L186-L191
def zero_state(qubits: Union[int, Qubits]) -> State: """Return the all-zero state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) ket[(0,) * N] = 1 return State(ket, qubits)
[ "def", "zero_state", "(", "qubits", ":", "Union", "[", "int", ",", "Qubits", "]", ")", "->", "State", ":", "N", ",", "qubits", "=", "qubits_count_tuple", "(", "qubits", ")", "ket", "=", "np", ".", "zeros", "(", "shape", "=", "[", "2", "]", "*", "...
Return the all-zero state on N qubits
[ "Return", "the", "all", "-", "zero", "state", "on", "N", "qubits" ]
python
train
37.333333
zsethna/OLGA
olga/utils.py
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L165-L259
def construct_codons_dict(alphabet_file = None): """Generate the sub_codons_right dictionary of codon suffixes. syntax of custom alphabet_files: char: list,of,amino,acids,or,codons,separated,by,commas Parameters ---------- alphabet_file : str File name for a custom al...
[ "def", "construct_codons_dict", "(", "alphabet_file", "=", "None", ")", ":", "#Some symbols can't be used in the CDR3 sequences in order to allow for", "#regular expression parsing and general manipulation.", "protected_symbols", "=", "[", "' '", ",", "'\\t'", ",", "'\\n'", ",", ...
Generate the sub_codons_right dictionary of codon suffixes. syntax of custom alphabet_files: char: list,of,amino,acids,or,codons,separated,by,commas Parameters ---------- alphabet_file : str File name for a custom alphabet definition. If no file is provided, the ...
[ "Generate", "the", "sub_codons_right", "dictionary", "of", "codon", "suffixes", "." ]
python
train
49.8
mardix/Mocha
mocha/contrib/views/auth.py
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/auth.py#L430-L537
def oauth_connect(self, provider, action): """ This endpoint doesn't check if user is logged in, because it has two functions 1. If the user is not logged in, it will try to signup the user - if the social info exist, it will login - not, it will create a new account and...
[ "def", "oauth_connect", "(", "self", ",", "provider", ",", "action", ")", ":", "valid_actions", "=", "[", "\"connect\"", ",", "\"authorized\"", ",", "\"test\"", "]", "_redirect", "=", "views", ".", "auth", ".", "Account", ".", "account_settings", "if", "is_a...
This endpoint doesn't check if user is logged in, because it has two functions 1. If the user is not logged in, it will try to signup the user - if the social info exist, it will login - not, it will create a new account and proceed 2. If user is logged in, it will try to create...
[ "This", "endpoint", "doesn", "t", "check", "if", "user", "is", "logged", "in", "because", "it", "has", "two", "functions" ]
python
train
36.490741