Unnamed: 0
int64
0
10k
repository_name
stringlengths
7
54
func_path_in_repository
stringlengths
5
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
100
30.3k
language
stringclasses
1 value
func_code_string
stringlengths
100
30.3k
func_code_tokens
stringlengths
138
33.2k
func_documentation_string
stringlengths
1
15k
func_documentation_tokens
stringlengths
5
5.14k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
900
Microsoft/nni
src/sdk/pynni/nni/networkmorphism_tuner/bayesian.py
IncrementalGaussianProcess.incremental_fit
def incremental_fit(self, train_x, train_y): """ Incrementally fit the regressor. """ if not self._first_fitted: raise ValueError("The first_fit function needs to be called first.") train_x, train_y = np.array(train_x), np.array(train_y) # Incrementally compute K up...
python
def incremental_fit(self, train_x, train_y): """ Incrementally fit the regressor. """ if not self._first_fitted: raise ValueError("The first_fit function needs to be called first.") train_x, train_y = np.array(train_x), np.array(train_y) # Incrementally compute K up...
['def', 'incremental_fit', '(', 'self', ',', 'train_x', ',', 'train_y', ')', ':', 'if', 'not', 'self', '.', '_first_fitted', ':', 'raise', 'ValueError', '(', '"The first_fit function needs to be called first."', ')', 'train_x', ',', 'train_y', '=', 'np', '.', 'array', '(', 'train_x', ')', ',', 'np', '.', 'array', '(', ...
Incrementally fit the regressor.
['Incrementally', 'fit', 'the', 'regressor', '.']
train
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/bayesian.py#L160-L190
901
aamalev/aiohttp_apiset
aiohttp_apiset/compat.py
CompatRouter.add_post
def add_post(self, *args, **kwargs): """ Shortcut for add_route with method POST """ return self.add_route(hdrs.METH_POST, *args, **kwargs)
python
def add_post(self, *args, **kwargs): """ Shortcut for add_route with method POST """ return self.add_route(hdrs.METH_POST, *args, **kwargs)
['def', 'add_post', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'return', 'self', '.', 'add_route', '(', 'hdrs', '.', 'METH_POST', ',', '*', 'args', ',', '*', '*', 'kwargs', ')']
Shortcut for add_route with method POST
['Shortcut', 'for', 'add_route', 'with', 'method', 'POST']
train
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/compat.py#L358-L362
902
saltstack/salt
salt/states/schedule.py
disabled
def disabled(name, **kwargs): ''' Ensure a job is disabled in the schedule name The unique name that is given to the scheduled job. persist Whether the job should persist between minion restarts, defaults to True. ''' ret = {'name': name, 'result': True, ...
python
def disabled(name, **kwargs): ''' Ensure a job is disabled in the schedule name The unique name that is given to the scheduled job. persist Whether the job should persist between minion restarts, defaults to True. ''' ret = {'name': name, 'result': True, ...
['def', 'disabled', '(', 'name', ',', '*', '*', 'kwargs', ')', ':', 'ret', '=', '{', "'name'", ':', 'name', ',', "'result'", ':', 'True', ',', "'changes'", ':', '{', '}', ',', "'comment'", ':', '[', ']', '}', 'current_schedule', '=', '__salt__', '[', "'schedule.list'", ']', '(', 'show_all', '=', 'True', ',', 'return_ya...
Ensure a job is disabled in the schedule name The unique name that is given to the scheduled job. persist Whether the job should persist between minion restarts, defaults to True.
['Ensure', 'a', 'job', 'is', 'disabled', 'in', 'the', 'schedule']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/schedule.py#L344-L379
903
basho/riak-python-client
riak/client/operations.py
RiakClientOperations.paginate_stream_index
def paginate_stream_index(self, bucket, index, startkey, endkey=None, max_results=1000, return_terms=None, continuation=None, timeout=None, term_regex=None): """ Iterates over a streaming paginated index query. Thi...
python
def paginate_stream_index(self, bucket, index, startkey, endkey=None, max_results=1000, return_terms=None, continuation=None, timeout=None, term_regex=None): """ Iterates over a streaming paginated index query. Thi...
['def', 'paginate_stream_index', '(', 'self', ',', 'bucket', ',', 'index', ',', 'startkey', ',', 'endkey', '=', 'None', ',', 'max_results', '=', '1000', ',', 'return_terms', '=', 'None', ',', 'continuation', '=', 'None', ',', 'timeout', '=', 'None', ',', 'term_regex', '=', 'None', ')', ':', '# TODO FUTURE: implement "r...
Iterates over a streaming paginated index query. This is equivalent to calling :meth:`stream_index` and then successively calling :meth:`~riak.client.index_page.IndexPage.next_page` until all results are exhausted. Because limiting the result set is necessary to invoke paginatio...
['Iterates', 'over', 'a', 'streaming', 'paginated', 'index', 'query', '.', 'This', 'is', 'equivalent', 'to', 'calling', ':', 'meth', ':', 'stream_index', 'and', 'then', 'successively', 'calling', ':', 'meth', ':', '~riak', '.', 'client', '.', 'index_page', '.', 'IndexPage', '.', 'next_page', 'until', 'all', 'results', ...
train
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/operations.py#L303-L373
904
openvax/mhcflurry
mhcflurry/class1_affinity_predictor.py
Class1AffinityPredictor.filter_networks
def filter_networks(self, predicate): """ Return a new Class1AffinityPredictor containing a subset of this predictor's neural networks. Parameters ---------- predicate : Class1NeuralNetwork -> boolean Function specifying which neural networks to include ...
python
def filter_networks(self, predicate): """ Return a new Class1AffinityPredictor containing a subset of this predictor's neural networks. Parameters ---------- predicate : Class1NeuralNetwork -> boolean Function specifying which neural networks to include ...
['def', 'filter_networks', '(', 'self', ',', 'predicate', ')', ':', 'allele_to_allele_specific_models', '=', '{', '}', 'for', '(', 'allele', ',', 'models', ')', 'in', 'self', '.', 'allele_to_allele_specific_models', '.', 'items', '(', ')', ':', 'allele_to_allele_specific_models', '[', 'allele', ']', '=', '[', 'm', 'for...
Return a new Class1AffinityPredictor containing a subset of this predictor's neural networks. Parameters ---------- predicate : Class1NeuralNetwork -> boolean Function specifying which neural networks to include Returns ------- Class1AffinityPredicto...
['Return', 'a', 'new', 'Class1AffinityPredictor', 'containing', 'a', 'subset', 'of', 'this', 'predictor', 's', 'neural', 'networks', '.']
train
https://github.com/openvax/mhcflurry/blob/deb7c1629111254b484a2711619eb2347db36524/mhcflurry/class1_affinity_predictor.py#L1130-L1157
905
scidash/sciunit
sciunit/__main__.py
make_nb
def make_nb(config, path=None, stop_on_error=True, just_tests=False): """Create a Jupyter notebook sciunit tests for the given configuration.""" root, nb_name = nb_name_from_path(config, path) clean = lambda varStr: re.sub('\W|^(?=\d)', '_', varStr) name = clean(nb_name) mpl_style = config.get('mis...
python
def make_nb(config, path=None, stop_on_error=True, just_tests=False): """Create a Jupyter notebook sciunit tests for the given configuration.""" root, nb_name = nb_name_from_path(config, path) clean = lambda varStr: re.sub('\W|^(?=\d)', '_', varStr) name = clean(nb_name) mpl_style = config.get('mis...
['def', 'make_nb', '(', 'config', ',', 'path', '=', 'None', ',', 'stop_on_error', '=', 'True', ',', 'just_tests', '=', 'False', ')', ':', 'root', ',', 'nb_name', '=', 'nb_name_from_path', '(', 'config', ',', 'path', ')', 'clean', '=', 'lambda', 'varStr', ':', 're', '.', 'sub', '(', "'\\W|^(?=\\d)'", ',', "'_'", ',', 'v...
Create a Jupyter notebook sciunit tests for the given configuration.
['Create', 'a', 'Jupyter', 'notebook', 'sciunit', 'tests', 'for', 'the', 'given', 'configuration', '.']
train
https://github.com/scidash/sciunit/blob/41b2e38c45c0776727ab1f281a572b65be19cea1/sciunit/__main__.py#L180-L205
906
softlayer/softlayer-python
SoftLayer/CLI/order/place.py
cli
def cli(env, package_keyname, location, preset, verify, billing, complex_type, quantity, extras, order_items): """Place or verify an order. This CLI command is used for placing/verifying an order of the specified package in the given location (denoted by a datacenter's long name). Orders made via t...
python
def cli(env, package_keyname, location, preset, verify, billing, complex_type, quantity, extras, order_items): """Place or verify an order. This CLI command is used for placing/verifying an order of the specified package in the given location (denoted by a datacenter's long name). Orders made via t...
['def', 'cli', '(', 'env', ',', 'package_keyname', ',', 'location', ',', 'preset', ',', 'verify', ',', 'billing', ',', 'complex_type', ',', 'quantity', ',', 'extras', ',', 'order_items', ')', ':', 'manager', '=', 'ordering', '.', 'OrderingManager', '(', 'env', '.', 'client', ')', 'if', 'extras', ':', 'try', ':', 'extra...
Place or verify an order. This CLI command is used for placing/verifying an order of the specified package in the given location (denoted by a datacenter's long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_order() with the s...
['Place', 'or', 'verify', 'an', 'order', '.']
train
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/place.py#L41-L120
907
zapier/django-rest-hooks
rest_hooks/models.py
custom_action
def custom_action(sender, action, instance, user=None, **kwargs): """ Manually trigger a custom action (or even a standard action). """ opts = get_opts(instance) model = '.'.join([opts.app_label, opts.object_name]) dis...
python
def custom_action(sender, action, instance, user=None, **kwargs): """ Manually trigger a custom action (or even a standard action). """ opts = get_opts(instance) model = '.'.join([opts.app_label, opts.object_name]) dis...
['def', 'custom_action', '(', 'sender', ',', 'action', ',', 'instance', ',', 'user', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'opts', '=', 'get_opts', '(', 'instance', ')', 'model', '=', "'.'", '.', 'join', '(', '[', 'opts', '.', 'app_label', ',', 'opts', '.', 'object_name', ']', ')', 'distill_model_event', '(',...
Manually trigger a custom action (or even a standard action).
['Manually', 'trigger', 'a', 'custom', 'action', '(', 'or', 'even', 'a', 'standard', 'action', ')', '.']
train
https://github.com/zapier/django-rest-hooks/blob/cf4f9588cd9f2d4696f2f0654a205722ee19b80e/rest_hooks/models.py#L158-L167
908
istresearch/scrapy-cluster
kafka-monitor/kafka_monitor.py
KafkaMonitor._dump_stats
def _dump_stats(self): ''' Dumps the stats out ''' extras = {} if 'total' in self.stats_dict: self.logger.debug("Compiling total/fail dump stats") for key in self.stats_dict['total']: final = 'total_{t}'.format(t=key) extras...
python
def _dump_stats(self): ''' Dumps the stats out ''' extras = {} if 'total' in self.stats_dict: self.logger.debug("Compiling total/fail dump stats") for key in self.stats_dict['total']: final = 'total_{t}'.format(t=key) extras...
['def', '_dump_stats', '(', 'self', ')', ':', 'extras', '=', '{', '}', 'if', "'total'", 'in', 'self', '.', 'stats_dict', ':', 'self', '.', 'logger', '.', 'debug', '(', '"Compiling total/fail dump stats"', ')', 'for', 'key', 'in', 'self', '.', 'stats_dict', '[', "'total'", ']', ':', 'final', '=', "'total_{t}'", '.', 'fo...
Dumps the stats out
['Dumps', 'the', 'stats', 'out']
train
https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/kafka-monitor/kafka_monitor.py#L367-L392
909
joealcorn/xbox
xbox/resource.py
Clip.get
def get(cls, xuid, scid, clip_id): ''' Gets a specific game clip :param xuid: xuid of an xbox live user :param scid: scid of a clip :param clip_id: id of a clip ''' url = ( 'https://gameclipsmetadata.xboxlive.com/users' '/xuid(%(xuid)s)/sc...
python
def get(cls, xuid, scid, clip_id): ''' Gets a specific game clip :param xuid: xuid of an xbox live user :param scid: scid of a clip :param clip_id: id of a clip ''' url = ( 'https://gameclipsmetadata.xboxlive.com/users' '/xuid(%(xuid)s)/sc...
['def', 'get', '(', 'cls', ',', 'xuid', ',', 'scid', ',', 'clip_id', ')', ':', 'url', '=', '(', "'https://gameclipsmetadata.xboxlive.com/users'", "'/xuid(%(xuid)s)/scids/%(scid)s/clips/%(clip_id)s'", '%', '{', "'xuid'", ':', 'xuid', ',', "'scid'", ':', 'scid', ',', "'clip_id'", ':', 'clip_id', ',', '}', ')', 'resp', '=...
Gets a specific game clip :param xuid: xuid of an xbox live user :param scid: scid of a clip :param clip_id: id of a clip
['Gets', 'a', 'specific', 'game', 'clip']
train
https://github.com/joealcorn/xbox/blob/3d2aeba10244dcb58d714d76fc88487c74bd1510/xbox/resource.py#L201-L234
910
quantmind/ccy
ccy/core/currency.py
currency_pair
def currency_pair(code): '''Construct a :class:`ccy_pair` from a six letter string.''' c = str(code) c1 = currency(c[:3]) c2 = currency(c[3:]) return ccy_pair(c1, c2)
python
def currency_pair(code): '''Construct a :class:`ccy_pair` from a six letter string.''' c = str(code) c1 = currency(c[:3]) c2 = currency(c[3:]) return ccy_pair(c1, c2)
['def', 'currency_pair', '(', 'code', ')', ':', 'c', '=', 'str', '(', 'code', ')', 'c1', '=', 'currency', '(', 'c', '[', ':', '3', ']', ')', 'c2', '=', 'currency', '(', 'c', '[', '3', ':', ']', ')', 'return', 'ccy_pair', '(', 'c1', ',', 'c2', ')']
Construct a :class:`ccy_pair` from a six letter string.
['Construct', 'a', ':', 'class', ':', 'ccy_pair', 'from', 'a', 'six', 'letter', 'string', '.']
train
https://github.com/quantmind/ccy/blob/068cf6887489087cd26657a937a932e82106b47f/ccy/core/currency.py#L211-L216
911
hydpy-dev/hydpy
hydpy/auxs/xmltools.py
XMLSelector.devices
def devices(self) -> selectiontools.Selection: """The additional devices defined for the respective `reader` or `writer` element contained within a |Selection| object. ToDo If the `reader` or `writer` element does not define its own additional devices, |XMLInterface.devices| of |XMLInte...
python
def devices(self) -> selectiontools.Selection: """The additional devices defined for the respective `reader` or `writer` element contained within a |Selection| object. ToDo If the `reader` or `writer` element does not define its own additional devices, |XMLInterface.devices| of |XMLInte...
['def', 'devices', '(', 'self', ')', '->', 'selectiontools', '.', 'Selection', ':', 'devices', '=', 'self', '.', 'find', '(', "'devices'", ')', 'master', '=', 'self', 'while', 'devices', 'is', 'None', ':', 'master', '=', 'master', '.', 'master', 'devices', '=', 'master', '.', 'find', '(', "'devices'", ')', 'return', '_...
The additional devices defined for the respective `reader` or `writer` element contained within a |Selection| object. ToDo If the `reader` or `writer` element does not define its own additional devices, |XMLInterface.devices| of |XMLInterface| is used. >>> from hydpy.core.examples impo...
['The', 'additional', 'devices', 'defined', 'for', 'the', 'respective', 'reader', 'or', 'writer', 'element', 'contained', 'within', 'a', '|Selection|', 'object', '.', 'ToDo']
train
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/xmltools.py#L875-L904
912
JelleAalbers/multihist
multihist.py
Histdd.std
def std(self, axis): """Returns d-1 dimensional histogram of (estimated) std value along axis NB this is very different from just std of the histogram values (which describe bin counts) """ def weighted_std(values, weights, axis): # Stolen from http://stackoverflow.com/questi...
python
def std(self, axis): """Returns d-1 dimensional histogram of (estimated) std value along axis NB this is very different from just std of the histogram values (which describe bin counts) """ def weighted_std(values, weights, axis): # Stolen from http://stackoverflow.com/questi...
['def', 'std', '(', 'self', ',', 'axis', ')', ':', 'def', 'weighted_std', '(', 'values', ',', 'weights', ',', 'axis', ')', ':', '# Stolen from http://stackoverflow.com/questions/2413522', 'average', '=', 'np', '.', 'average', '(', 'values', ',', 'weights', '=', 'weights', ',', 'axis', '=', 'axis', ')', 'average', '=', ...
Returns d-1 dimensional histogram of (estimated) std value along axis NB this is very different from just std of the histogram values (which describe bin counts)
['Returns', 'd', '-', '1', 'dimensional', 'histogram', 'of', '(', 'estimated', ')', 'std', 'value', 'along', 'axis', 'NB', 'this', 'is', 'very', 'different', 'from', 'just', 'std', 'of', 'the', 'histogram', 'values', '(', 'which', 'describe', 'bin', 'counts', ')']
train
https://github.com/JelleAalbers/multihist/blob/072288277f807e7e388fdf424c3921c80576f3ab/multihist.py#L560-L580
913
broadinstitute/fiss
firecloud/method.py
Method.inputs_outputs
def inputs_outputs(self): """Get information on method inputs & outputs.""" r = fapi.get_inputs_outputs(self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
python
def inputs_outputs(self): """Get information on method inputs & outputs.""" r = fapi.get_inputs_outputs(self.namespace, self.name, self.snapshot_id, self.api_url) fapi._check_response_code(r, 200) return r.json()
['def', 'inputs_outputs', '(', 'self', ')', ':', 'r', '=', 'fapi', '.', 'get_inputs_outputs', '(', 'self', '.', 'namespace', ',', 'self', '.', 'name', ',', 'self', '.', 'snapshot_id', ',', 'self', '.', 'api_url', ')', 'fapi', '.', '_check_response_code', '(', 'r', ',', '200', ')', 'return', 'r', '.', 'json', '(', ')']
Get information on method inputs & outputs.
['Get', 'information', 'on', 'method', 'inputs', '&', 'outputs', '.']
train
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/method.py#L62-L67
914
AbletonAG/abl.vpath
abl/vpath/base/fs.py
BaseUri.open
def open(self, options=None, mimetype='application/octet-stream'): """ open: return a file like object for self. The method can be used with the 'with' statment. """ return self.connection.open(self, options, mimetype)
python
def open(self, options=None, mimetype='application/octet-stream'): """ open: return a file like object for self. The method can be used with the 'with' statment. """ return self.connection.open(self, options, mimetype)
['def', 'open', '(', 'self', ',', 'options', '=', 'None', ',', 'mimetype', '=', "'application/octet-stream'", ')', ':', 'return', 'self', '.', 'connection', '.', 'open', '(', 'self', ',', 'options', ',', 'mimetype', ')']
open: return a file like object for self. The method can be used with the 'with' statment.
['open', ':', 'return', 'a', 'file', 'like', 'object', 'for', 'self', '.', 'The', 'method', 'can', 'be', 'used', 'with', 'the', 'with', 'statment', '.']
train
https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/fs.py#L593-L598
915
Unidata/siphon
siphon/cdmr/dataset.py
Group.path
def path(self): """Return the full path to the Group, including any parent Groups.""" # If root, return '/' if self.dataset is self: return '' else: # Otherwise recurse return self.dataset.path + '/' + self.name
python
def path(self): """Return the full path to the Group, including any parent Groups.""" # If root, return '/' if self.dataset is self: return '' else: # Otherwise recurse return self.dataset.path + '/' + self.name
['def', 'path', '(', 'self', ')', ':', "# If root, return '/'", 'if', 'self', '.', 'dataset', 'is', 'self', ':', 'return', "''", 'else', ':', '# Otherwise recurse', 'return', 'self', '.', 'dataset', '.', 'path', '+', "'/'", '+', 'self', '.', 'name']
Return the full path to the Group, including any parent Groups.
['Return', 'the', 'full', 'path', 'to', 'the', 'Group', 'including', 'any', 'parent', 'Groups', '.']
train
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/dataset.py#L53-L59
916
spyder-ide/spyder
spyder/plugins/editor/panels/linenumber.py
LineNumberArea.mouseMoveEvent
def mouseMoveEvent(self, event): """Override Qt method. Show code analisis, if left button pressed select lines. """ line_number = self.editor.get_linenumber_from_mouse_event(event) block = self.editor.document().findBlockByNumber(line_number-1) data = block.userData() ...
python
def mouseMoveEvent(self, event): """Override Qt method. Show code analisis, if left button pressed select lines. """ line_number = self.editor.get_linenumber_from_mouse_event(event) block = self.editor.document().findBlockByNumber(line_number-1) data = block.userData() ...
['def', 'mouseMoveEvent', '(', 'self', ',', 'event', ')', ':', 'line_number', '=', 'self', '.', 'editor', '.', 'get_linenumber_from_mouse_event', '(', 'event', ')', 'block', '=', 'self', '.', 'editor', '.', 'document', '(', ')', '.', 'findBlockByNumber', '(', 'line_number', '-', '1', ')', 'data', '=', 'block', '.', 'us...
Override Qt method. Show code analisis, if left button pressed select lines.
['Override', 'Qt', 'method', '.']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/linenumber.py#L114-L134
917
adamrehn/slidingwindow
slidingwindow/SlidingWindow.py
generate
def generate(data, dimOrder, maxWindowSize, overlapPercent, transforms = []): """ Generates a set of sliding windows for the specified dataset. """ # Determine the dimensions of the input data width = data.shape[dimOrder.index('w')] height = data.shape[dimOrder.index('h')] # Generate the windows return gene...
python
def generate(data, dimOrder, maxWindowSize, overlapPercent, transforms = []): """ Generates a set of sliding windows for the specified dataset. """ # Determine the dimensions of the input data width = data.shape[dimOrder.index('w')] height = data.shape[dimOrder.index('h')] # Generate the windows return gene...
['def', 'generate', '(', 'data', ',', 'dimOrder', ',', 'maxWindowSize', ',', 'overlapPercent', ',', 'transforms', '=', '[', ']', ')', ':', '# Determine the dimensions of the input data', 'width', '=', 'data', '.', 'shape', '[', 'dimOrder', '.', 'index', '(', "'w'", ')', ']', 'height', '=', 'data', '.', 'shape', '[', 'd...
Generates a set of sliding windows for the specified dataset.
['Generates', 'a', 'set', 'of', 'sliding', 'windows', 'for', 'the', 'specified', 'dataset', '.']
train
https://github.com/adamrehn/slidingwindow/blob/17ea9395b48671e8cb7321b9510c6b25fec5e45f/slidingwindow/SlidingWindow.py#L87-L97
918
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
relaxNgValidCtxtCore.setValidityErrorHandler
def setValidityErrorHandler(self, err_func, warn_func, arg=None): """ Register error and warning handlers for RelaxNG validation. These will be called back as f(msg,arg) """ libxml2mod.xmlRelaxNGSetValidErrors(self._o, err_func, warn_func, arg)
python
def setValidityErrorHandler(self, err_func, warn_func, arg=None): """ Register error and warning handlers for RelaxNG validation. These will be called back as f(msg,arg) """ libxml2mod.xmlRelaxNGSetValidErrors(self._o, err_func, warn_func, arg)
['def', 'setValidityErrorHandler', '(', 'self', ',', 'err_func', ',', 'warn_func', ',', 'arg', '=', 'None', ')', ':', 'libxml2mod', '.', 'xmlRelaxNGSetValidErrors', '(', 'self', '.', '_o', ',', 'err_func', ',', 'warn_func', ',', 'arg', ')']
Register error and warning handlers for RelaxNG validation. These will be called back as f(msg,arg)
['Register', 'error', 'and', 'warning', 'handlers', 'for', 'RelaxNG', 'validation', '.', 'These', 'will', 'be', 'called', 'back', 'as', 'f', '(', 'msg', 'arg', ')']
train
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L705-L710
919
lsbardel/python-stdnet
stdnet/odm/session.py
SessionModel.expunge
def expunge(self, instance): '''Remove *instance* from the :class:`Session`. Instance could be a :class:`Model` or an id. :parameter instance: a :class:`Model` or an *id* :rtype: the :class:`Model` removed from session or ``None`` if it was not in the session. ''' instance = self.pop(instan...
python
def expunge(self, instance): '''Remove *instance* from the :class:`Session`. Instance could be a :class:`Model` or an id. :parameter instance: a :class:`Model` or an *id* :rtype: the :class:`Model` removed from session or ``None`` if it was not in the session. ''' instance = self.pop(instan...
['def', 'expunge', '(', 'self', ',', 'instance', ')', ':', 'instance', '=', 'self', '.', 'pop', '(', 'instance', ')', 'instance', '.', 'session', '=', 'None', 'return', 'instance']
Remove *instance* from the :class:`Session`. Instance could be a :class:`Model` or an id. :parameter instance: a :class:`Model` or an *id* :rtype: the :class:`Model` removed from session or ``None`` if it was not in the session.
['Remove', '*', 'instance', '*', 'from', 'the', ':', 'class', ':', 'Session', '.', 'Instance', 'could', 'be', 'a', ':', 'class', ':', 'Model', 'or', 'an', 'id', '.', ':', 'parameter', 'instance', ':', 'a', ':', 'class', ':', 'Model', 'or', 'an', '*', 'id', '*', ':', 'rtype', ':', 'the', ':', 'class', ':', 'Model', 'rem...
train
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/odm/session.py#L192-L202
920
gem/oq-engine
openquake/baselib/datastore.py
get_calc_ids
def get_calc_ids(datadir=None): """ Extract the available calculation IDs from the datadir, in order. """ datadir = datadir or get_datadir() if not os.path.exists(datadir): return [] calc_ids = set() for f in os.listdir(datadir): mo = re.match(CALC_REGEX, f) if mo: ...
python
def get_calc_ids(datadir=None): """ Extract the available calculation IDs from the datadir, in order. """ datadir = datadir or get_datadir() if not os.path.exists(datadir): return [] calc_ids = set() for f in os.listdir(datadir): mo = re.match(CALC_REGEX, f) if mo: ...
['def', 'get_calc_ids', '(', 'datadir', '=', 'None', ')', ':', 'datadir', '=', 'datadir', 'or', 'get_datadir', '(', ')', 'if', 'not', 'os', '.', 'path', '.', 'exists', '(', 'datadir', ')', ':', 'return', '[', ']', 'calc_ids', '=', 'set', '(', ')', 'for', 'f', 'in', 'os', '.', 'listdir', '(', 'datadir', ')', ':', 'mo', ...
Extract the available calculation IDs from the datadir, in order.
['Extract', 'the', 'available', 'calculation', 'IDs', 'from', 'the', 'datadir', 'in', 'order', '.']
train
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/datastore.py#L46-L58
921
OSSOS/MOP
src/ossos/core/ossos/ssos.py
TrackTarget.query_ssos
def query_ssos(self, target_name, lunation_count=None): """Send a query to the SSOS web service, looking for available observations using the given track. :param target_name: name of target to query against SSOIS db :param lunation_count: ignored :rtype: SSOSData """ # ...
python
def query_ssos(self, target_name, lunation_count=None): """Send a query to the SSOS web service, looking for available observations using the given track. :param target_name: name of target to query against SSOIS db :param lunation_count: ignored :rtype: SSOSData """ # ...
['def', 'query_ssos', '(', 'self', ',', 'target_name', ',', 'lunation_count', '=', 'None', ')', ':', '# we observe ~ a week either side of new moon', "# but we don't know when in the dark run the discovery happened", '# so be generous with the search boundaries, add extra 2 weeks', '# current date just has to be the ni...
Send a query to the SSOS web service, looking for available observations using the given track. :param target_name: name of target to query against SSOIS db :param lunation_count: ignored :rtype: SSOSData
['Send', 'a', 'query', 'to', 'the', 'SSOS', 'web', 'service', 'looking', 'for', 'available', 'observations', 'using', 'the', 'given', 'track', '.']
train
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/ssos.py#L189-L239
922
DataBiosphere/toil
src/toil/serviceManager.py
ServiceManager.getServiceJobsToStart
def getServiceJobsToStart(self, maxWait): """ :param float maxWait: Time in seconds to wait to get a job before returning. :return: a tuple of (serviceJobStoreID, memory, cores, disk, ..) representing a service job to start. :rtype: toil.job.ServiceJobNode """ try...
python
def getServiceJobsToStart(self, maxWait): """ :param float maxWait: Time in seconds to wait to get a job before returning. :return: a tuple of (serviceJobStoreID, memory, cores, disk, ..) representing a service job to start. :rtype: toil.job.ServiceJobNode """ try...
['def', 'getServiceJobsToStart', '(', 'self', ',', 'maxWait', ')', ':', 'try', ':', 'serviceJob', '=', 'self', '.', '_serviceJobGraphsToStart', '.', 'get', '(', 'timeout', '=', 'maxWait', ')', 'assert', 'self', '.', 'jobsIssuedToServiceManager', '>=', '0', 'self', '.', 'jobsIssuedToServiceManager', '-=', '1', 'return',...
:param float maxWait: Time in seconds to wait to get a job before returning. :return: a tuple of (serviceJobStoreID, memory, cores, disk, ..) representing a service job to start. :rtype: toil.job.ServiceJobNode
[':', 'param', 'float', 'maxWait', ':', 'Time', 'in', 'seconds', 'to', 'wait', 'to', 'get', 'a', 'job', 'before', 'returning', '.', ':', 'return', ':', 'a', 'tuple', 'of', '(', 'serviceJobStoreID', 'memory', 'cores', 'disk', '..', ')', 'representing', 'a', 'service', 'job', 'to', 'start', '.', ':', 'rtype', ':', 'toil'...
train
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/serviceManager.py#L106-L119
923
keon/algorithms
algorithms/strings/first_unique_char.py
first_unique_char
def first_unique_char(s): """ :type s: str :rtype: int """ if (len(s) == 1): return 0 ban = [] for i in range(len(s)): if all(s[i] != s[k] for k in range(i + 1, len(s))) == True and s[i] not in ban: return i else: ban.append(s[i]) return -1
python
def first_unique_char(s): """ :type s: str :rtype: int """ if (len(s) == 1): return 0 ban = [] for i in range(len(s)): if all(s[i] != s[k] for k in range(i + 1, len(s))) == True and s[i] not in ban: return i else: ban.append(s[i]) return -1
['def', 'first_unique_char', '(', 's', ')', ':', 'if', '(', 'len', '(', 's', ')', '==', '1', ')', ':', 'return', '0', 'ban', '=', '[', ']', 'for', 'i', 'in', 'range', '(', 'len', '(', 's', ')', ')', ':', 'if', 'all', '(', 's', '[', 'i', ']', '!=', 's', '[', 'k', ']', 'for', 'k', 'in', 'range', '(', 'i', '+', '1', ',', ...
:type s: str :rtype: int
[':', 'type', 's', ':', 'str', ':', 'rtype', ':', 'int']
train
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/strings/first_unique_char.py#L14-L27
924
galaxyproject/pulsar
pulsar/client/manager.py
ClientManager.get_client
def get_client(self, destination_params, job_id, **kwargs): """Build a client given specific destination parameters and job_id.""" destination_params = _parse_destination_params(destination_params) destination_params.update(**kwargs) job_manager_interface_class = self.job_manager_interfa...
python
def get_client(self, destination_params, job_id, **kwargs): """Build a client given specific destination parameters and job_id.""" destination_params = _parse_destination_params(destination_params) destination_params.update(**kwargs) job_manager_interface_class = self.job_manager_interfa...
['def', 'get_client', '(', 'self', ',', 'destination_params', ',', 'job_id', ',', '*', '*', 'kwargs', ')', ':', 'destination_params', '=', '_parse_destination_params', '(', 'destination_params', ')', 'destination_params', '.', 'update', '(', '*', '*', 'kwargs', ')', 'job_manager_interface_class', '=', 'self', '.', 'job...
Build a client given specific destination parameters and job_id.
['Build', 'a', 'client', 'given', 'specific', 'destination', 'parameters', 'and', 'job_id', '.']
train
https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/client/manager.py#L83-L90
925
seperman/s3utils
s3utils/s3utils.py
S3utils.ls
def ls(self, folder="", begin_from_file="", num=-1, get_grants=False, all_grant_data=False): """ gets the list of file names (keys) in a s3 folder Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results ...
python
def ls(self, folder="", begin_from_file="", num=-1, get_grants=False, all_grant_data=False): """ gets the list of file names (keys) in a s3 folder Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results ...
['def', 'ls', '(', 'self', ',', 'folder', '=', '""', ',', 'begin_from_file', '=', '""', ',', 'num', '=', '-', '1', ',', 'get_grants', '=', 'False', ',', 'all_grant_data', '=', 'False', ')', ':', "# S3 object key can't start with /", 'folder', '=', 're', '.', 'sub', '(', 'r"^/"', ',', '""', ',', 'folder', ')', 'bucket_f...
gets the list of file names (keys) in a s3 folder Parameters ---------- folder : string Path to file on S3 num: integer, optional number of results to return, by default it returns all results. begin_from_file: string, optional which file t...
['gets', 'the', 'list', 'of', 'file', 'names', '(', 'keys', ')', 'in', 'a', 's3', 'folder']
train
https://github.com/seperman/s3utils/blob/aea41388a023dcf1e95588402077e31097514cf1/s3utils/s3utils.py#L613-L667
926
kytos/python-openflow
pyof/v0x04/controller2switch/meter_mod.py
MeterBandHeader.unpack
def unpack(self, buff=None, offset=0): """Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: ...
python
def unpack(self, buff=None, offset=0): """Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: ...
['def', 'unpack', '(', 'self', ',', 'buff', '=', 'None', ',', 'offset', '=', '0', ')', ':', 'band_type', '=', 'UBInt16', '(', 'enum_ref', '=', 'MeterBandType', ')', 'band_type', '.', 'unpack', '(', 'buff', ',', 'offset', ')', 'self', '.', '__class__', '=', 'MeterBandType', '(', 'band_type', '.', 'value', ')', '.', 'fin...
Unpack *buff* into this object. This method will convert a binary data into a readable value according to the attribute format. Args: buff (bytes): Binary buffer. offset (int): Where to begin unpacking. Raises: :exc:`~.exceptions.UnpackException`: I...
['Unpack', '*', 'buff', '*', 'into', 'this', 'object', '.']
train
https://github.com/kytos/python-openflow/blob/4f2d0d08ab28e102ed88fe57a4ee17729f1e1bb7/pyof/v0x04/controller2switch/meter_mod.py#L96-L117
927
pyopenapi/pyswagger
pyswagger/utils.py
walk
def walk(start, ofn, cyc=None): """ Non recursive DFS to detect cycles :param start: start vertex in graph :param ofn: function to get the list of outgoing edges of a vertex :param cyc: list of existing cycles, cycles are represented in a list started with minimum vertex. :return: cycles :rtype...
python
def walk(start, ofn, cyc=None): """ Non recursive DFS to detect cycles :param start: start vertex in graph :param ofn: function to get the list of outgoing edges of a vertex :param cyc: list of existing cycles, cycles are represented in a list started with minimum vertex. :return: cycles :rtype...
['def', 'walk', '(', 'start', ',', 'ofn', ',', 'cyc', '=', 'None', ')', ':', 'ctx', ',', 'stk', '=', '{', '}', ',', '[', 'start', ']', 'cyc', '=', '[', ']', 'if', 'cyc', '==', 'None', 'else', 'cyc', 'while', 'len', '(', 'stk', ')', ':', 'top', '=', 'stk', '[', '-', '1', ']', 'if', 'top', 'not', 'in', 'ctx', ':', 'ctx',...
Non recursive DFS to detect cycles :param start: start vertex in graph :param ofn: function to get the list of outgoing edges of a vertex :param cyc: list of existing cycles, cycles are represented in a list started with minimum vertex. :return: cycles :rtype: list of lists
['Non', 'recursive', 'DFS', 'to', 'detect', 'cycles']
train
https://github.com/pyopenapi/pyswagger/blob/333c4ca08e758cd2194943d9904a3eda3fe43977/pyswagger/utils.py#L439-L480
928
saltstack/salt
salt/modules/postgres.py
default_privileges_revoke
def default_privileges_revoke(name, object_name, object_type, defprivileges=None, prepend='public', maintenance_db=None, user=None, host=None, port=None, password=None, runas=None): ''' .. versionadded:: 2019.0.0 Revoke default...
python
def default_privileges_revoke(name, object_name, object_type, defprivileges=None, prepend='public', maintenance_db=None, user=None, host=None, port=None, password=None, runas=None): ''' .. versionadded:: 2019.0.0 Revoke default...
['def', 'default_privileges_revoke', '(', 'name', ',', 'object_name', ',', 'object_type', ',', 'defprivileges', '=', 'None', ',', 'prepend', '=', "'public'", ',', 'maintenance_db', '=', 'None', ',', 'user', '=', 'None', ',', 'host', '=', 'None', ',', 'port', '=', 'None', ',', 'password', '=', 'None', ',', 'runas', '=',...
.. versionadded:: 2019.0.0 Revoke default privileges on a postgres object CLI Example: .. code-block:: bash salt '*' postgres.default_privileges_revoke user_name table_name table \\ SELECT,UPDATE maintenance_db=db_name name Name of the role whose default privileges should be ...
['..', 'versionadded', '::', '2019', '.', '0', '.', '0']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postgres.py#L3331-L3434
929
noahbenson/neuropythy
neuropythy/util/core.py
czdivide
def czdivide(a, b, null=0): ''' czdivide(a, b) returns the quotient a / b as a numpy array object. Like numpy's divide function or a/b syntax, czdivide will thread over the latest dimension possible. Unlike numpy's divide, czdivide works with sparse matrices. Additionally, czdivide multiplies a by t...
python
def czdivide(a, b, null=0): ''' czdivide(a, b) returns the quotient a / b as a numpy array object. Like numpy's divide function or a/b syntax, czdivide will thread over the latest dimension possible. Unlike numpy's divide, czdivide works with sparse matrices. Additionally, czdivide multiplies a by t...
['def', 'czdivide', '(', 'a', ',', 'b', ',', 'null', '=', '0', ')', ':', 'if', 'null', '==', '0', ':', 'return', 'a', '.', 'multiply', '(', 'zinv', '(', 'b', ')', ')', 'if', 'sps', '.', 'issparse', '(', 'a', ')', 'else', 'a', '*', 'zinv', '(', 'b', ')', 'elif', 'sps', '.', 'issparse', '(', 'b', ')', ':', 'b', '=', 'b',...
czdivide(a, b) returns the quotient a / b as a numpy array object. Like numpy's divide function or a/b syntax, czdivide will thread over the latest dimension possible. Unlike numpy's divide, czdivide works with sparse matrices. Additionally, czdivide multiplies a by the zinv of b, so divide-by-zero en...
['czdivide', '(', 'a', 'b', ')', 'returns', 'the', 'quotient', 'a', '/', 'b', 'as', 'a', 'numpy', 'array', 'object', '.', 'Like', 'numpy', 's', 'divide', 'function', 'or', 'a', '/', 'b', 'syntax', 'czdivide', 'will', 'thread', 'over', 'the', 'latest', 'dimension', 'possible', '.', 'Unlike', 'numpy', 's', 'divide', 'czd...
train
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/util/core.py#L716-L741
930
evhub/coconut
coconut/command/util.py
splitname
def splitname(path): """Split a path into a directory, name, and extensions.""" dirpath, filename = os.path.split(path) # we don't use os.path.splitext here because we want all extensions, # not just the last, to be put in exts name, exts = filename.split(os.extsep, 1) return dirpath, name, ext...
python
def splitname(path): """Split a path into a directory, name, and extensions.""" dirpath, filename = os.path.split(path) # we don't use os.path.splitext here because we want all extensions, # not just the last, to be put in exts name, exts = filename.split(os.extsep, 1) return dirpath, name, ext...
['def', 'splitname', '(', 'path', ')', ':', 'dirpath', ',', 'filename', '=', 'os', '.', 'path', '.', 'split', '(', 'path', ')', "# we don't use os.path.splitext here because we want all extensions,", '# not just the last, to be put in exts', 'name', ',', 'exts', '=', 'filename', '.', 'split', '(', 'os', '.', 'extsep',...
Split a path into a directory, name, and extensions.
['Split', 'a', 'path', 'into', 'a', 'directory', 'name', 'and', 'extensions', '.']
train
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/command/util.py#L219-L225
931
inasafe/inasafe
safe/gis/raster/reclassify.py
reclassify
def reclassify(layer, exposure_key=None, overwrite_input=False): """Reclassify a continuous raster layer. Issue https://github.com/inasafe/inasafe/issues/3182 This function is a wrapper for the code from https://github.com/chiatt/gdal_reclassify For instance if you want to reclassify like this t...
python
def reclassify(layer, exposure_key=None, overwrite_input=False): """Reclassify a continuous raster layer. Issue https://github.com/inasafe/inasafe/issues/3182 This function is a wrapper for the code from https://github.com/chiatt/gdal_reclassify For instance if you want to reclassify like this t...
['def', 'reclassify', '(', 'layer', ',', 'exposure_key', '=', 'None', ',', 'overwrite_input', '=', 'False', ')', ':', 'output_layer_name', '=', 'reclassify_raster_steps', '[', "'output_layer_name'", ']', 'output_layer_name', '=', 'output_layer_name', '%', 'layer', '.', 'keywords', '[', "'layer_purpose'", ']', 'if', 'ex...
Reclassify a continuous raster layer. Issue https://github.com/inasafe/inasafe/issues/3182 This function is a wrapper for the code from https://github.com/chiatt/gdal_reclassify For instance if you want to reclassify like this table : Original Value | Class - ∞ < val <=...
['Reclassify', 'a', 'continuous', 'raster', 'layer', '.']
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/raster/reclassify.py#L29-L155
932
flyte/xbee-helper
xbee_helper/device.py
ZigBee._get_parameter
def _get_parameter(self, parameter, dest_addr_long=None): """ Fetches and returns the value of the specified parameter. """ frame = self._send_and_wait( command=parameter, dest_addr_long=dest_addr_long) return frame["parameter"]
python
def _get_parameter(self, parameter, dest_addr_long=None): """ Fetches and returns the value of the specified parameter. """ frame = self._send_and_wait( command=parameter, dest_addr_long=dest_addr_long) return frame["parameter"]
['def', '_get_parameter', '(', 'self', ',', 'parameter', ',', 'dest_addr_long', '=', 'None', ')', ':', 'frame', '=', 'self', '.', '_send_and_wait', '(', 'command', '=', 'parameter', ',', 'dest_addr_long', '=', 'dest_addr_long', ')', 'return', 'frame', '[', '"parameter"', ']']
Fetches and returns the value of the specified parameter.
['Fetches', 'and', 'returns', 'the', 'value', 'of', 'the', 'specified', 'parameter', '.']
train
https://github.com/flyte/xbee-helper/blob/8b47675ad44d8a57defea459682d129379af348d/xbee_helper/device.py#L166-L172
933
Koed00/django-q
django_q/tasks.py
Chain.result
def result(self, wait=0): """ return the full list of results from the chain when it finishes. blocks until timeout. :param int wait: how many milliseconds to wait for a result :return: an unsorted list of results """ if self.started: return result_group(self....
python
def result(self, wait=0): """ return the full list of results from the chain when it finishes. blocks until timeout. :param int wait: how many milliseconds to wait for a result :return: an unsorted list of results """ if self.started: return result_group(self....
['def', 'result', '(', 'self', ',', 'wait', '=', '0', ')', ':', 'if', 'self', '.', 'started', ':', 'return', 'result_group', '(', 'self', '.', 'group', ',', 'wait', '=', 'wait', ',', 'count', '=', 'self', '.', 'length', '(', ')', ',', 'cached', '=', 'self', '.', 'cached', ')']
return the full list of results from the chain when it finishes. blocks until timeout. :param int wait: how many milliseconds to wait for a result :return: an unsorted list of results
['return', 'the', 'full', 'list', 'of', 'results', 'from', 'the', 'chain', 'when', 'it', 'finishes', '.', 'blocks', 'until', 'timeout', '.', ':', 'param', 'int', 'wait', ':', 'how', 'many', 'milliseconds', 'to', 'wait', 'for', 'a', 'result', ':', 'return', ':', 'an', 'unsorted', 'list', 'of', 'results']
train
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L542-L549
934
haaksmash/pyutils
utils/lists.py
flatten
def flatten(iterable): """Fully flattens an iterable: In: flatten([1,2,3,4,[5,6,[7,8]]]) Out: [1,2,3,4,5,6,7,8] """ container = iterable.__class__ placeholder = [] for item in iterable: try: placeholder.extend(flatten(item)) except TypeError: placehol...
python
def flatten(iterable): """Fully flattens an iterable: In: flatten([1,2,3,4,[5,6,[7,8]]]) Out: [1,2,3,4,5,6,7,8] """ container = iterable.__class__ placeholder = [] for item in iterable: try: placeholder.extend(flatten(item)) except TypeError: placehol...
['def', 'flatten', '(', 'iterable', ')', ':', 'container', '=', 'iterable', '.', '__class__', 'placeholder', '=', '[', ']', 'for', 'item', 'in', 'iterable', ':', 'try', ':', 'placeholder', '.', 'extend', '(', 'flatten', '(', 'item', ')', ')', 'except', 'TypeError', ':', 'placeholder', '.', 'append', '(', 'item', ')', '...
Fully flattens an iterable: In: flatten([1,2,3,4,[5,6,[7,8]]]) Out: [1,2,3,4,5,6,7,8]
['Fully', 'flattens', 'an', 'iterable', ':', 'In', ':', 'flatten', '(', '[', '1', '2', '3', '4', '[', '5', '6', '[', '7', '8', ']]]', ')', 'Out', ':', '[', '1', '2', '3', '4', '5', '6', '7', '8', ']']
train
https://github.com/haaksmash/pyutils/blob/6ba851d11e53812dfc9017537a4f2de198851708/utils/lists.py#L17-L31
935
bradrf/configstruct
configstruct/config_struct.py
ConfigStruct.save
def save(self, conflict_resolver=choose_mine): '''Save all options in memory to the `config_file`. Options are read once more from the file (to allow other writers to save configuration), keys in conflict are resolved, and the final results are written back to the file. :param conflic...
python
def save(self, conflict_resolver=choose_mine): '''Save all options in memory to the `config_file`. Options are read once more from the file (to allow other writers to save configuration), keys in conflict are resolved, and the final results are written back to the file. :param conflic...
['def', 'save', '(', 'self', ',', 'conflict_resolver', '=', 'choose_mine', ')', ':', 'config', '=', 'self', '.', '_load', '(', 'conflict_resolver', ')', '# in case some other process has added items', 'with', 'open', '(', 'self', '.', '_config_file', ',', "'wb'", ')', 'as', 'cf', ':', 'config', '.', 'write', '(', 'cf',...
Save all options in memory to the `config_file`. Options are read once more from the file (to allow other writers to save configuration), keys in conflict are resolved, and the final results are written back to the file. :param conflict_resolver: a simple lambda or function to choose when an o...
['Save', 'all', 'options', 'in', 'memory', 'to', 'the', 'config_file', '.']
train
https://github.com/bradrf/configstruct/blob/aeea8fbba1e2daa0a0c38eeb9622d1716c0bb3e8/configstruct/config_struct.py#L97-L110
936
EmbodiedCognition/py-c3d
c3d.py
Group.add_param
def add_param(self, name, **kwargs): '''Add a parameter to this group. Parameters ---------- name : str Name of the parameter to add to this group. The name will automatically be case-normalized. Additional keyword arguments will be passed to the `Param`...
python
def add_param(self, name, **kwargs): '''Add a parameter to this group. Parameters ---------- name : str Name of the parameter to add to this group. The name will automatically be case-normalized. Additional keyword arguments will be passed to the `Param`...
['def', 'add_param', '(', 'self', ',', 'name', ',', '*', '*', 'kwargs', ')', ':', 'self', '.', 'params', '[', 'name', '.', 'upper', '(', ')', ']', '=', 'Param', '(', 'name', '.', 'upper', '(', ')', ',', '*', '*', 'kwargs', ')']
Add a parameter to this group. Parameters ---------- name : str Name of the parameter to add to this group. The name will automatically be case-normalized. Additional keyword arguments will be passed to the `Param` constructor.
['Add', 'a', 'parameter', 'to', 'this', 'group', '.']
train
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L425-L436
937
tensorflow/tensorboard
tensorboard/compat/tensorflow_stub/io/gfile.py
S3FileSystem.glob
def glob(self, filename): """Returns a list of files that match the given pattern(s).""" # Only support prefix with * at the end and no ? in the string star_i = filename.find('*') quest_i = filename.find('?') if quest_i >= 0: raise NotImplementedError( ...
python
def glob(self, filename): """Returns a list of files that match the given pattern(s).""" # Only support prefix with * at the end and no ? in the string star_i = filename.find('*') quest_i = filename.find('?') if quest_i >= 0: raise NotImplementedError( ...
['def', 'glob', '(', 'self', ',', 'filename', ')', ':', '# Only support prefix with * at the end and no ? in the string', 'star_i', '=', 'filename', '.', 'find', '(', "'*'", ')', 'quest_i', '=', 'filename', '.', 'find', '(', "'?'", ')', 'if', 'quest_i', '>=', '0', ':', 'raise', 'NotImplementedError', '(', '"{} not supp...
Returns a list of files that match the given pattern(s).
['Returns', 'a', 'list', 'of', 'files', 'that', 'match', 'the', 'given', 'pattern', '(', 's', ')', '.']
train
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/compat/tensorflow_stub/io/gfile.py#L231-L256
938
spacetelescope/stsci.tools
lib/stsci/tools/fileutil.py
parseFilename
def parseFilename(filename): """ Parse out filename from any specified extensions. Returns rootname and string version of extension name. """ # Parse out any extension specified in filename _indx = filename.find('[') if _indx > 0: # Read extension name provided _fname = fil...
python
def parseFilename(filename): """ Parse out filename from any specified extensions. Returns rootname and string version of extension name. """ # Parse out any extension specified in filename _indx = filename.find('[') if _indx > 0: # Read extension name provided _fname = fil...
['def', 'parseFilename', '(', 'filename', ')', ':', '# Parse out any extension specified in filename', '_indx', '=', 'filename', '.', 'find', '(', "'['", ')', 'if', '_indx', '>', '0', ':', '# Read extension name provided', '_fname', '=', 'filename', '[', ':', '_indx', ']', '_extn', '=', 'filename', '[', '_indx', '+', '...
Parse out filename from any specified extensions. Returns rootname and string version of extension name.
['Parse', 'out', 'filename', 'from', 'any', 'specified', 'extensions', '.']
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L826-L843
939
angr/angr
angr/analyses/decompiler/clinic.py
Clinic._make_callsites
def _make_callsites(self, stack_pointer_tracker=None): """ Simplify all function call statements. :return: None """ # Computing reaching definitions rd = self.project.analyses.ReachingDefinitions(func=self.function, func_graph=self.graph, observe_all=True) f...
python
def _make_callsites(self, stack_pointer_tracker=None): """ Simplify all function call statements. :return: None """ # Computing reaching definitions rd = self.project.analyses.ReachingDefinitions(func=self.function, func_graph=self.graph, observe_all=True) f...
['def', '_make_callsites', '(', 'self', ',', 'stack_pointer_tracker', '=', 'None', ')', ':', '# Computing reaching definitions', 'rd', '=', 'self', '.', 'project', '.', 'analyses', '.', 'ReachingDefinitions', '(', 'func', '=', 'self', '.', 'function', ',', 'func_graph', '=', 'self', '.', 'graph', ',', 'observe_all', '=...
Simplify all function call statements. :return: None
['Simplify', 'all', 'function', 'call', 'statements', '.']
train
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/decompiler/clinic.py#L213-L231
940
noahbenson/neuropythy
neuropythy/geometry/util.py
vector_angle_cos
def vector_angle_cos(u, v): ''' vector_angle_cos(u, v) yields the cosine of the angle between the two vectors u and v. If u or v (or both) is a (d x n) matrix of n vectors, the result will be a length n vector of the cosines. ''' u = np.asarray(u) v = np.asarray(v) return (u * v).sum(0) ...
python
def vector_angle_cos(u, v): ''' vector_angle_cos(u, v) yields the cosine of the angle between the two vectors u and v. If u or v (or both) is a (d x n) matrix of n vectors, the result will be a length n vector of the cosines. ''' u = np.asarray(u) v = np.asarray(v) return (u * v).sum(0) ...
['def', 'vector_angle_cos', '(', 'u', ',', 'v', ')', ':', 'u', '=', 'np', '.', 'asarray', '(', 'u', ')', 'v', '=', 'np', '.', 'asarray', '(', 'v', ')', 'return', '(', 'u', '*', 'v', ')', '.', 'sum', '(', '0', ')', '/', 'np', '.', 'sqrt', '(', '(', 'u', '**', '2', ')', '.', 'sum', '(', '0', ')', '*', '(', 'v', '**', '2'...
vector_angle_cos(u, v) yields the cosine of the angle between the two vectors u and v. If u or v (or both) is a (d x n) matrix of n vectors, the result will be a length n vector of the cosines.
['vector_angle_cos', '(', 'u', 'v', ')', 'yields', 'the', 'cosine', 'of', 'the', 'angle', 'between', 'the', 'two', 'vectors', 'u', 'and', 'v', '.', 'If', 'u', 'or', 'v', '(', 'or', 'both', ')', 'is', 'a', '(', 'd', 'x', 'n', ')', 'matrix', 'of', 'n', 'vectors', 'the', 'result', 'will', 'be', 'a', 'length', 'n', 'vector...
train
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/geometry/util.py#L23-L31
941
ampl/amplpy
amplpy/errorhandler.py
ErrorHandler.error
def error(self, amplexception): """ Receives notification of an error. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Error:\n{:s}'.format(msg)) raise amplexception
python
def error(self, amplexception): """ Receives notification of an error. """ msg = '\t'+str(amplexception).replace('\n', '\n\t') print('Error:\n{:s}'.format(msg)) raise amplexception
['def', 'error', '(', 'self', ',', 'amplexception', ')', ':', 'msg', '=', "'\\t'", '+', 'str', '(', 'amplexception', ')', '.', 'replace', '(', "'\\n'", ',', "'\\n\\t'", ')', 'print', '(', "'Error:\\n{:s}'", '.', 'format', '(', 'msg', ')', ')', 'raise', 'amplexception']
Receives notification of an error.
['Receives', 'notification', 'of', 'an', 'error', '.']
train
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/errorhandler.py#L18-L24
942
HacKanCuBa/passphrase-py
passphrase/aux.py
Aux.make_chars_uppercase
def make_chars_uppercase( lst: Union[list, tuple, str, set], uppercase: int ) -> Union[list, tuple, str, set]: """Make uppercase some randomly selected characters. The characters can be in a (mix of) string, list, tuple or set. Keyword arguments: lst -- the ...
python
def make_chars_uppercase( lst: Union[list, tuple, str, set], uppercase: int ) -> Union[list, tuple, str, set]: """Make uppercase some randomly selected characters. The characters can be in a (mix of) string, list, tuple or set. Keyword arguments: lst -- the ...
['def', 'make_chars_uppercase', '(', 'lst', ':', 'Union', '[', 'list', ',', 'tuple', ',', 'str', ',', 'set', ']', ',', 'uppercase', ':', 'int', ')', '->', 'Union', '[', 'list', ',', 'tuple', ',', 'str', ',', 'set', ']', ':', 'if', 'not', 'isinstance', '(', 'lst', ',', '(', 'list', ',', 'tuple', ',', 'str', ',', 'set', ...
Make uppercase some randomly selected characters. The characters can be in a (mix of) string, list, tuple or set. Keyword arguments: lst -- the object to make all chars uppercase, which can be a (mix of) list, tuple, string or set. uppercase -- Number of characters to be set as...
['Make', 'uppercase', 'some', 'randomly', 'selected', 'characters', '.']
train
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/aux.py#L120-L183
943
VasilyStepanov/pywidl
pywidl/grammar.py
p_SingleType_any
def p_SingleType_any(p): """SingleType : any TypeSuffixStartingWithArray""" p[0] = helper.unwrapTypeSuffix(model.SimpleType( model.SimpleType.ANY), p[2])
python
def p_SingleType_any(p): """SingleType : any TypeSuffixStartingWithArray""" p[0] = helper.unwrapTypeSuffix(model.SimpleType( model.SimpleType.ANY), p[2])
['def', 'p_SingleType_any', '(', 'p', ')', ':', 'p', '[', '0', ']', '=', 'helper', '.', 'unwrapTypeSuffix', '(', 'model', '.', 'SimpleType', '(', 'model', '.', 'SimpleType', '.', 'ANY', ')', ',', 'p', '[', '2', ']', ')']
SingleType : any TypeSuffixStartingWithArray
['SingleType', ':', 'any', 'TypeSuffixStartingWithArray']
train
https://github.com/VasilyStepanov/pywidl/blob/8d84b2e53157bfe276bf16301c19e8b6b32e861e/pywidl/grammar.py#L714-L717
944
swisscom/cleanerversion
versions/admin.py
VersionedAdmin.get_object
def get_object(self, request, object_id, from_field=None): """ our implementation of get_object allows for cloning when updating an object, not cloning when the button 'save but not clone' is pushed and at no other time will clone be called """ # from_field breaks in 1.7....
python
def get_object(self, request, object_id, from_field=None): """ our implementation of get_object allows for cloning when updating an object, not cloning when the button 'save but not clone' is pushed and at no other time will clone be called """ # from_field breaks in 1.7....
['def', 'get_object', '(', 'self', ',', 'request', ',', 'object_id', ',', 'from_field', '=', 'None', ')', ':', '# from_field breaks in 1.7.8', 'obj', '=', 'super', '(', 'VersionedAdmin', ',', 'self', ')', '.', 'get_object', '(', 'request', ',', 'object_id', ')', '# Only clone if update view as get_object() is also call...
our implementation of get_object allows for cloning when updating an object, not cloning when the button 'save but not clone' is pushed and at no other time will clone be called
['our', 'implementation', 'of', 'get_object', 'allows', 'for', 'cloning', 'when', 'updating', 'an', 'object', 'not', 'cloning', 'when', 'the', 'button', 'save', 'but', 'not', 'clone', 'is', 'pushed', 'and', 'at', 'no', 'other', 'time', 'will', 'clone', 'be', 'called']
train
https://github.com/swisscom/cleanerversion/blob/becadbab5d7b474a0e9a596b99e97682402d2f2c/versions/admin.py#L240-L259
945
rosenbrockc/fortpy
fortpy/scripts/analyze.py
FortpyShell.do_rmfit
def do_rmfit(self, arg): """Removes a fit function from a variable. See 'fit'.""" if arg in self.curargs["fits"]: del self.curargs["fits"][arg] #We also need to remove the variable entry if it exists. if "timing" in arg: fitvar = "{}|fit".format(arg) ...
python
def do_rmfit(self, arg): """Removes a fit function from a variable. See 'fit'.""" if arg in self.curargs["fits"]: del self.curargs["fits"][arg] #We also need to remove the variable entry if it exists. if "timing" in arg: fitvar = "{}|fit".format(arg) ...
['def', 'do_rmfit', '(', 'self', ',', 'arg', ')', ':', 'if', 'arg', 'in', 'self', '.', 'curargs', '[', '"fits"', ']', ':', 'del', 'self', '.', 'curargs', '[', '"fits"', ']', '[', 'arg', ']', '#We also need to remove the variable entry if it exists.', 'if', '"timing"', 'in', 'arg', ':', 'fitvar', '=', '"{}|fit"', '.', '...
Removes a fit function from a variable. See 'fit'.
['Removes', 'a', 'fit', 'function', 'from', 'a', 'variable', '.', 'See', 'fit', '.']
train
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/scripts/analyze.py#L822-L832
946
mitsei/dlkit
dlkit/json_/logging_/sessions.py
LogEntryAdminSession.alias_log_entry
def alias_log_entry(self, log_entry_id, alias_id): """Adds an ``Id`` to a ``LogEntry`` for the purpose of creating compatibility. The primary ``Id`` of the ``LogEntry`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to...
python
def alias_log_entry(self, log_entry_id, alias_id): """Adds an ``Id`` to a ``LogEntry`` for the purpose of creating compatibility. The primary ``Id`` of the ``LogEntry`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to...
['def', 'alias_log_entry', '(', 'self', ',', 'log_entry_id', ',', 'alias_id', ')', ':', '# Implemented from template for', '# osid.resource.ResourceAdminSession.alias_resources_template', 'self', '.', '_alias_id', '(', 'primary_id', '=', 'log_entry_id', ',', 'equivalent_id', '=', 'alias_id', ')']
Adds an ``Id`` to a ``LogEntry`` for the purpose of creating compatibility. The primary ``Id`` of the ``LogEntry`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another log entry, it is reassigned to the given log ...
['Adds', 'an', 'Id', 'to', 'a', 'LogEntry', 'for', 'the', 'purpose', 'of', 'creating', 'compatibility', '.']
train
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1160-L1181
947
edx/django-config-models
config_models/templatetags.py
submit_row
def submit_row(context): """ Overrides 'django.contrib.admin.templatetags.admin_modify.submit_row'. Manipulates the context going into that function by hiding all of the buttons in the submit row if the key `readonly` is set in the context. """ ctx = original_submit_row(context) if context...
python
def submit_row(context): """ Overrides 'django.contrib.admin.templatetags.admin_modify.submit_row'. Manipulates the context going into that function by hiding all of the buttons in the submit row if the key `readonly` is set in the context. """ ctx = original_submit_row(context) if context...
['def', 'submit_row', '(', 'context', ')', ':', 'ctx', '=', 'original_submit_row', '(', 'context', ')', 'if', 'context', '.', 'get', '(', "'readonly'", ',', 'False', ')', ':', 'ctx', '.', 'update', '(', '{', "'show_delete_link'", ':', 'False', ',', "'show_save_as_new'", ':', 'False', ',', "'show_save_and_add_another'",...
Overrides 'django.contrib.admin.templatetags.admin_modify.submit_row'. Manipulates the context going into that function by hiding all of the buttons in the submit row if the key `readonly` is set in the context.
['Overrides', 'django', '.', 'contrib', '.', 'admin', '.', 'templatetags', '.', 'admin_modify', '.', 'submit_row', '.']
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/templatetags.py#L12-L30
948
blankenberg/pyBamParser
lib/pyBamParser/read/__init__.py
BAMRead.indel_at
def indel_at( self, position, check_insertions=True, check_deletions=True, one_based=True ): """Does the read contain an indel at the given position? Return True if the read contains an insertion at the given position (position must be the base before the insertion event) or if the read ...
python
def indel_at( self, position, check_insertions=True, check_deletions=True, one_based=True ): """Does the read contain an indel at the given position? Return True if the read contains an insertion at the given position (position must be the base before the insertion event) or if the read ...
['def', 'indel_at', '(', 'self', ',', 'position', ',', 'check_insertions', '=', 'True', ',', 'check_deletions', '=', 'True', ',', 'one_based', '=', 'True', ')', ':', '(', 'insertions', ',', 'deletions', ')', '=', 'self', '.', 'get_indels', '(', 'one_based', '=', 'one_based', ')', 'if', 'check_insertions', ':', 'for', '...
Does the read contain an indel at the given position? Return True if the read contains an insertion at the given position (position must be the base before the insertion event) or if the read contains a deletion where the base at position is deleted. Return False otherwise.
['Does', 'the', 'read', 'contain', 'an', 'indel', 'at', 'the', 'given', 'position?', 'Return', 'True', 'if', 'the', 'read', 'contains', 'an', 'insertion', 'at', 'the', 'given', 'position', '(', 'position', 'must', 'be', 'the', 'base', 'before', 'the', 'insertion', 'event', ')', 'or', 'if', 'the', 'read', 'contains', 'a...
train
https://github.com/blankenberg/pyBamParser/blob/5a357f23ae51b97f3167e8da18ff0cb6db8ca4a0/lib/pyBamParser/read/__init__.py#L240-L255
949
bububa/pyTOP
pyTOP/crawler.py
Crawler.get_cats
def get_cats(self): '''Get top keywords categories''' start_url = 'http://top.taobao.com/index.php?from=tbsy' rs = self.fetch(start_url) if not rs: return None soup = BeautifulSoup(rs.content, convertEntities=BeautifulSoup.HTML_ENTITIES, markupMassage=hexentityMassage) ca...
python
def get_cats(self): '''Get top keywords categories''' start_url = 'http://top.taobao.com/index.php?from=tbsy' rs = self.fetch(start_url) if not rs: return None soup = BeautifulSoup(rs.content, convertEntities=BeautifulSoup.HTML_ENTITIES, markupMassage=hexentityMassage) ca...
['def', 'get_cats', '(', 'self', ')', ':', 'start_url', '=', "'http://top.taobao.com/index.php?from=tbsy'", 'rs', '=', 'self', '.', 'fetch', '(', 'start_url', ')', 'if', 'not', 'rs', ':', 'return', 'None', 'soup', '=', 'BeautifulSoup', '(', 'rs', '.', 'content', ',', 'convertEntities', '=', 'BeautifulSoup', '.', 'HTML_...
Get top keywords categories
['Get', 'top', 'keywords', 'categories']
train
https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/crawler.py#L308-L319
950
RudolfCardinal/pythonlib
cardinal_pythonlib/tools/backup_mysql_database.py
cmdargs
def cmdargs(mysqldump: str, username: str, password: str, database: str, verbose: bool, with_drop_create_database: bool, max_allowed_packet: str, hide_password: bool = False) -> List[str]: """ Returns command arguments for a ``m...
python
def cmdargs(mysqldump: str, username: str, password: str, database: str, verbose: bool, with_drop_create_database: bool, max_allowed_packet: str, hide_password: bool = False) -> List[str]: """ Returns command arguments for a ``m...
['def', 'cmdargs', '(', 'mysqldump', ':', 'str', ',', 'username', ':', 'str', ',', 'password', ':', 'str', ',', 'database', ':', 'str', ',', 'verbose', ':', 'bool', ',', 'with_drop_create_database', ':', 'bool', ',', 'max_allowed_packet', ':', 'str', ',', 'hide_password', ':', 'bool', '=', 'False', ')', '->', 'List', '...
Returns command arguments for a ``mysqldump`` call. Args: mysqldump: ``mysqldump`` executable filename username: user name password: password database: database name verbose: verbose output? with_drop_create_database: produce commands to ``DROP`` the database ...
['Returns', 'command', 'arguments', 'for', 'a', 'mysqldump', 'call', '.']
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/tools/backup_mysql_database.py#L46-L90
951
pypa/setuptools
setuptools/__init__.py
_find_all_simple
def _find_all_simple(path): """ Find all files under 'path' """ results = ( os.path.join(base, file) for base, dirs, files in os.walk(path, followlinks=True) for file in files ) return filter(os.path.isfile, results)
python
def _find_all_simple(path): """ Find all files under 'path' """ results = ( os.path.join(base, file) for base, dirs, files in os.walk(path, followlinks=True) for file in files ) return filter(os.path.isfile, results)
['def', '_find_all_simple', '(', 'path', ')', ':', 'results', '=', '(', 'os', '.', 'path', '.', 'join', '(', 'base', ',', 'file', ')', 'for', 'base', ',', 'dirs', ',', 'files', 'in', 'os', '.', 'walk', '(', 'path', ',', 'followlinks', '=', 'True', ')', 'for', 'file', 'in', 'files', ')', 'return', 'filter', '(', 'os', '...
Find all files under 'path'
['Find', 'all', 'files', 'under', 'path']
train
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/__init__.py#L203-L212
952
sorgerlab/indra
indra/sources/trips/api.py
process_xml
def process_xml(xml_string): """Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor ...
python
def process_xml(xml_string): """Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor ...
['def', 'process_xml', '(', 'xml_string', ')', ':', 'tp', '=', 'TripsProcessor', '(', 'xml_string', ')', 'if', 'tp', '.', 'tree', 'is', 'None', ':', 'return', 'None', 'tp', '.', 'get_modifications_indirect', '(', ')', 'tp', '.', 'get_activations_causal', '(', ')', 'tp', '.', 'get_activations_stimulate', '(', ')', 'tp',...
Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor A TripsProcessor containing the ...
['Return', 'a', 'TripsProcessor', 'by', 'processing', 'a', 'TRIPS', 'EKB', 'XML', 'string', '.']
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L102-L134
953
Julius2342/pyvlx
pyvlx/string_helper.py
string_to_bytes
def string_to_bytes(string, size): """Convert string to bytes add padding.""" if len(string) > size: raise PyVLXException("string_to_bytes::string_to_large") encoded = bytes(string, encoding='utf-8') return encoded + bytes(size-len(encoded))
python
def string_to_bytes(string, size): """Convert string to bytes add padding.""" if len(string) > size: raise PyVLXException("string_to_bytes::string_to_large") encoded = bytes(string, encoding='utf-8') return encoded + bytes(size-len(encoded))
['def', 'string_to_bytes', '(', 'string', ',', 'size', ')', ':', 'if', 'len', '(', 'string', ')', '>', 'size', ':', 'raise', 'PyVLXException', '(', '"string_to_bytes::string_to_large"', ')', 'encoded', '=', 'bytes', '(', 'string', ',', 'encoding', '=', "'utf-8'", ')', 'return', 'encoded', '+', 'bytes', '(', 'size', '-'...
Convert string to bytes add padding.
['Convert', 'string', 'to', 'bytes', 'add', 'padding', '.']
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/string_helper.py#L5-L10
954
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
resnet_model_fn
def resnet_model_fn(features, labels, mode, model_class, resnet_size, weight_decay, learning_rate_fn, momentum, data_format, version, loss_scale, loss_filter_fn=None, dtype=resnet_model.DEFAULT_DTYPE, label_smoothing=0.0, enable_lars=False)...
python
def resnet_model_fn(features, labels, mode, model_class, resnet_size, weight_decay, learning_rate_fn, momentum, data_format, version, loss_scale, loss_filter_fn=None, dtype=resnet_model.DEFAULT_DTYPE, label_smoothing=0.0, enable_lars=False)...
['def', 'resnet_model_fn', '(', 'features', ',', 'labels', ',', 'mode', ',', 'model_class', ',', 'resnet_size', ',', 'weight_decay', ',', 'learning_rate_fn', ',', 'momentum', ',', 'data_format', ',', 'version', ',', 'loss_scale', ',', 'loss_filter_fn', '=', 'None', ',', 'dtype', '=', 'resnet_model', '.', 'DEFAULT_DTYPE...
Shared functionality for different resnet model_fns. Initializes the ResnetModel representing the model layers and uses that model to build the necessary EstimatorSpecs for the `mode` in question. For training, this means building losses, the optimizer, and the train op that get passed into the EstimatorSpec. ...
['Shared', 'functionality', 'for', 'different', 'resnet', 'model_fns', '.']
train
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L221-L402
955
tcalmant/ipopo
pelix/rsa/__init__.py
RemoteServiceAdminEvent.fromimporterror
def fromimporterror(cls, bundle, importerid, rsid, exception, endpoint): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from an import error """ ...
python
def fromimporterror(cls, bundle, importerid, rsid, exception, endpoint): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from an import error """ ...
['def', 'fromimporterror', '(', 'cls', ',', 'bundle', ',', 'importerid', ',', 'rsid', ',', 'exception', ',', 'endpoint', ')', ':', '# type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent', 'return', 'RemoteServiceAdminEvent', '(', '...
Creates a RemoteServiceAdminEvent object from an import error
['Creates', 'a', 'RemoteServiceAdminEvent', 'object', 'from', 'an', 'import', 'error']
train
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/rsa/__init__.py#L929-L943
956
cdgriffith/Reusables
reusables/file_operations.py
dup_finder
def dup_finder(file_path, directory=".", enable_scandir=False): """ Check a directory for duplicates of the specified file. This is meant for a single file only, for checking a directory for dups, use directory_duplicates. This is designed to be as fast as possible by doing lighter checks befor...
python
def dup_finder(file_path, directory=".", enable_scandir=False): """ Check a directory for duplicates of the specified file. This is meant for a single file only, for checking a directory for dups, use directory_duplicates. This is designed to be as fast as possible by doing lighter checks befor...
['def', 'dup_finder', '(', 'file_path', ',', 'directory', '=', '"."', ',', 'enable_scandir', '=', 'False', ')', ':', 'size', '=', 'os', '.', 'path', '.', 'getsize', '(', 'file_path', ')', 'if', 'size', '==', '0', ':', 'for', 'empty_file', 'in', 'remove_empty_files', '(', 'directory', ',', 'dry_run', '=', 'True', ')', '...
Check a directory for duplicates of the specified file. This is meant for a single file only, for checking a directory for dups, use directory_duplicates. This is designed to be as fast as possible by doing lighter checks before progressing to more extensive ones, in order they are: 1. File si...
['Check', 'a', 'directory', 'for', 'duplicates', 'of', 'the', 'specified', 'file', '.', 'This', 'is', 'meant', 'for', 'a', 'single', 'file', 'only', 'for', 'checking', 'a', 'directory', 'for', 'dups', 'use', 'directory_duplicates', '.']
train
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/file_operations.py#L630-L681
957
ozak/georasters
georasters/georasters.py
aggregate
def aggregate(raster, ndv, block_size): ''' Aggregate raster to smaller resolution, by adding cells. Usage: aggregate(raster, ndv, block_size) where: raster is a Numpy array created by importing the raster (e.g. geotiff) ndv is the NoData Value for the raster (can b...
python
def aggregate(raster, ndv, block_size): ''' Aggregate raster to smaller resolution, by adding cells. Usage: aggregate(raster, ndv, block_size) where: raster is a Numpy array created by importing the raster (e.g. geotiff) ndv is the NoData Value for the raster (can b...
['def', 'aggregate', '(', 'raster', ',', 'ndv', ',', 'block_size', ')', ':', 'raster2', '=', 'block_reduce', '(', 'raster', ',', 'block_size', ',', 'func', '=', 'np', '.', 'ma', '.', 'sum', ')', 'return', 'raster2']
Aggregate raster to smaller resolution, by adding cells. Usage: aggregate(raster, ndv, block_size) where: raster is a Numpy array created by importing the raster (e.g. geotiff) ndv is the NoData Value for the raster (can be read using the get_geo_info function) ...
['Aggregate', 'raster', 'to', 'smaller', 'resolution', 'by', 'adding', 'cells', '.', 'Usage', ':', 'aggregate', '(', 'raster', 'ndv', 'block_size', ')']
train
https://github.com/ozak/georasters/blob/0612bd91bb2a2cb2f1d59ba89c1ff131dae27d70/georasters/georasters.py#L111-L134
958
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py
check_extract_from_egg
def check_extract_from_egg(pth, todir=None): r""" Check if path points to a file inside a python egg file, extract the file from the egg to a cache directory (following pkg_resources convention) and return [(extracted path, egg file path, relative path inside egg file)]. Otherwise, just return [...
python
def check_extract_from_egg(pth, todir=None): r""" Check if path points to a file inside a python egg file, extract the file from the egg to a cache directory (following pkg_resources convention) and return [(extracted path, egg file path, relative path inside egg file)]. Otherwise, just return [...
['def', 'check_extract_from_egg', '(', 'pth', ',', 'todir', '=', 'None', ')', ':', 'rv', '=', '[', ']', 'if', 'os', '.', 'path', '.', 'altsep', ':', 'pth', '=', 'pth', '.', 'replace', '(', 'os', '.', 'path', '.', 'altsep', ',', 'os', '.', 'path', '.', 'sep', ')', 'components', '=', 'pth', '.', 'split', '(', 'os', '.', ...
r""" Check if path points to a file inside a python egg file, extract the file from the egg to a cache directory (following pkg_resources convention) and return [(extracted path, egg file path, relative path inside egg file)]. Otherwise, just return [(original path, None, None)]. If path points ...
['r', 'Check', 'if', 'path', 'points', 'to', 'a', 'file', 'inside', 'a', 'python', 'egg', 'file', 'extract', 'the', 'file', 'from', 'the', 'egg', 'to', 'a', 'cache', 'directory', '(', 'following', 'pkg_resources', 'convention', ')', 'and', 'return', '[', '(', 'extracted', 'path', 'egg', 'file', 'path', 'relative', 'pat...
train
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py#L178-L228
959
SiLab-Bonn/pyBAR_fei4_interpreter
pybar_fei4_interpreter/analysis_utils.py
hist_3d_index
def hist_3d_index(x, y, z, shape): """ Fast 3d histogram of 3D indices with C++ inner loop optimization. Is more than 2 orders faster than np.histogramdd(). The indices are given in x, y, z coordinates and have to fit into a histogram of the dimensions shape. Parameters ---------- x : array ...
python
def hist_3d_index(x, y, z, shape): """ Fast 3d histogram of 3D indices with C++ inner loop optimization. Is more than 2 orders faster than np.histogramdd(). The indices are given in x, y, z coordinates and have to fit into a histogram of the dimensions shape. Parameters ---------- x : array ...
['def', 'hist_3d_index', '(', 'x', ',', 'y', ',', 'z', ',', 'shape', ')', ':', 'if', 'len', '(', 'shape', ')', '!=', '3', ':', 'raise', 'InvalidInputError', '(', "'The shape has to describe a 3-d histogram'", ')', '# change memory alignment for c++ library', 'x', '=', 'np', '.', 'ascontiguousarray', '(', 'x', '.', 'ast...
Fast 3d histogram of 3D indices with C++ inner loop optimization. Is more than 2 orders faster than np.histogramdd(). The indices are given in x, y, z coordinates and have to fit into a histogram of the dimensions shape. Parameters ---------- x : array like y : array like z : array like ...
['Fast', '3d', 'histogram', 'of', '3D', 'indices', 'with', 'C', '++', 'inner', 'loop', 'optimization', '.', 'Is', 'more', 'than', '2', 'orders', 'faster', 'than', 'np', '.', 'histogramdd', '()', '.', 'The', 'indices', 'are', 'given', 'in', 'x', 'y', 'z', 'coordinates', 'and', 'have', 'to', 'fit', 'into', 'a', 'histogra...
train
https://github.com/SiLab-Bonn/pyBAR_fei4_interpreter/blob/0f8df18557598d6db0c64baa708e587c84bb787b/pybar_fei4_interpreter/analysis_utils.py#L114-L140
960
wummel/dosage
dosagelib/scraper.py
Scraper.setComplete
def setComplete(self, basepath): """Set complete flag for this comic, ie. all comics are downloaded.""" if self.endOfLife: filename = self.getCompleteFile(basepath) if not os.path.exists(filename): with open(filename, 'w') as f: f.write('All co...
python
def setComplete(self, basepath): """Set complete flag for this comic, ie. all comics are downloaded.""" if self.endOfLife: filename = self.getCompleteFile(basepath) if not os.path.exists(filename): with open(filename, 'w') as f: f.write('All co...
['def', 'setComplete', '(', 'self', ',', 'basepath', ')', ':', 'if', 'self', '.', 'endOfLife', ':', 'filename', '=', 'self', '.', 'getCompleteFile', '(', 'basepath', ')', 'if', 'not', 'os', '.', 'path', '.', 'exists', '(', 'filename', ')', ':', 'with', 'open', '(', 'filename', ',', "'w'", ')', 'as', 'f', ':', 'f', '.',...
Set complete flag for this comic, ie. all comics are downloaded.
['Set', 'complete', 'flag', 'for', 'this', 'comic', 'ie', '.', 'all', 'comics', 'are', 'downloaded', '.']
train
https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/dosagelib/scraper.py#L272-L278
961
jwodder/doapi
doapi/image.py
Image.fetch
def fetch(self): """ Fetch & return a new `Image` object representing the image's current state :rtype: Image :raises DOAPIError: if the API endpoint replies with an error (e.g., if the image no longer exists) """ api = self.doapi_manager retu...
python
def fetch(self): """ Fetch & return a new `Image` object representing the image's current state :rtype: Image :raises DOAPIError: if the API endpoint replies with an error (e.g., if the image no longer exists) """ api = self.doapi_manager retu...
['def', 'fetch', '(', 'self', ')', ':', 'api', '=', 'self', '.', 'doapi_manager', 'return', 'api', '.', '_image', '(', 'api', '.', 'request', '(', 'self', '.', 'url', ')', '[', '"image"', ']', ')']
Fetch & return a new `Image` object representing the image's current state :rtype: Image :raises DOAPIError: if the API endpoint replies with an error (e.g., if the image no longer exists)
['Fetch', '&', 'return', 'a', 'new', 'Image', 'object', 'representing', 'the', 'image', 's', 'current', 'state']
train
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/image.py#L69-L79
962
phaethon/kamene
kamene/modules/p0f.py
p0f
def p0f(pkt): """Passive OS fingerprinting: which OS emitted this TCP packet ? p0f(packet) -> accuracy, [list of guesses] """ db, sig = packet2p0f(pkt) if db: pb = db.get_base() else: pb = [] if not pb: warning("p0f base empty.") return [] #s = len(pb[0][0]) r...
python
def p0f(pkt): """Passive OS fingerprinting: which OS emitted this TCP packet ? p0f(packet) -> accuracy, [list of guesses] """ db, sig = packet2p0f(pkt) if db: pb = db.get_base() else: pb = [] if not pb: warning("p0f base empty.") return [] #s = len(pb[0][0]) r...
['def', 'p0f', '(', 'pkt', ')', ':', 'db', ',', 'sig', '=', 'packet2p0f', '(', 'pkt', ')', 'if', 'db', ':', 'pb', '=', 'db', '.', 'get_base', '(', ')', 'else', ':', 'pb', '=', '[', ']', 'if', 'not', 'pb', ':', 'warning', '(', '"p0f base empty."', ')', 'return', '[', ']', '#s = len(pb[0][0])', 'r', '=', '[', ']', 'max',...
Passive OS fingerprinting: which OS emitted this TCP packet ? p0f(packet) -> accuracy, [list of guesses]
['Passive', 'OS', 'fingerprinting', ':', 'which', 'OS', 'emitted', 'this', 'TCP', 'packet', '?', 'p0f', '(', 'packet', ')', '-', '>', 'accuracy', '[', 'list', 'of', 'guesses', ']']
train
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/p0f.py#L264-L283
963
manns/pyspread
pyspread/src/lib/vlc.py
debug_callback
def debug_callback(event, *args, **kwds): '''Example callback, useful for debugging. ''' l = ['event %s' % (event.type,)] if args: l.extend(map(str, args)) if kwds: l.extend(sorted('%s=%s' % t for t in kwds.items())) print('Debug callback (%s)' % ', '.join(l))
python
def debug_callback(event, *args, **kwds): '''Example callback, useful for debugging. ''' l = ['event %s' % (event.type,)] if args: l.extend(map(str, args)) if kwds: l.extend(sorted('%s=%s' % t for t in kwds.items())) print('Debug callback (%s)' % ', '.join(l))
['def', 'debug_callback', '(', 'event', ',', '*', 'args', ',', '*', '*', 'kwds', ')', ':', 'l', '=', '[', "'event %s'", '%', '(', 'event', '.', 'type', ',', ')', ']', 'if', 'args', ':', 'l', '.', 'extend', '(', 'map', '(', 'str', ',', 'args', ')', ')', 'if', 'kwds', ':', 'l', '.', 'extend', '(', 'sorted', '(', "'%s=%s'...
Example callback, useful for debugging.
['Example', 'callback', 'useful', 'for', 'debugging', '.']
train
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L6882-L6890
964
squeaky-pl/japronto
misc/cpu.py
save
def save(): """ save function """ results = {} cpu_number = 0 while True: try: _file = open( CPU_PREFIX + 'cpu{}/cpufreq/scaling_governor'.format(cpu_number)) except: break governor = _file.read().strip() results.setdefaul...
python
def save(): """ save function """ results = {} cpu_number = 0 while True: try: _file = open( CPU_PREFIX + 'cpu{}/cpufreq/scaling_governor'.format(cpu_number)) except: break governor = _file.read().strip() results.setdefaul...
['def', 'save', '(', ')', ':', 'results', '=', '{', '}', 'cpu_number', '=', '0', 'while', 'True', ':', 'try', ':', '_file', '=', 'open', '(', 'CPU_PREFIX', '+', "'cpu{}/cpufreq/scaling_governor'", '.', 'format', '(', 'cpu_number', ')', ')', 'except', ':', 'break', 'governor', '=', '_file', '.', 'read', '(', ')', '.', '...
save function
['save', 'function']
train
https://github.com/squeaky-pl/japronto/blob/a526277a2f59100388c9f39d4ca22bfb4909955b/misc/cpu.py#L14-L45
965
theonion/django-bulbs
bulbs/special_coverage/models.py
SpecialCoverage._save_percolator
def _save_percolator(self): """ Saves the query field as an elasticsearch percolator """ index = Content.search_objects.mapping.index query_filter = self.get_content(published=False).to_dict() q = {} if "query" in query_filter: q = {"query": query_fi...
python
def _save_percolator(self): """ Saves the query field as an elasticsearch percolator """ index = Content.search_objects.mapping.index query_filter = self.get_content(published=False).to_dict() q = {} if "query" in query_filter: q = {"query": query_fi...
['def', '_save_percolator', '(', 'self', ')', ':', 'index', '=', 'Content', '.', 'search_objects', '.', 'mapping', '.', 'index', 'query_filter', '=', 'self', '.', 'get_content', '(', 'published', '=', 'False', ')', '.', 'to_dict', '(', ')', 'q', '=', '{', '}', 'if', '"query"', 'in', 'query_filter', ':', 'q', '=', '{', ...
Saves the query field as an elasticsearch percolator
['Saves', 'the', 'query', 'field', 'as', 'an', 'elasticsearch', 'percolator']
train
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/special_coverage/models.py#L102-L144
966
hubo1016/vlcp
vlcp/event/lock.py
Semaphore.create
def create(self): """ Create the subqueue to change the default behavior of Lock to semaphore. """ self.queue = self.scheduler.queue.addSubQueue(self.priority, LockEvent.createMatcher(self.context, self.key), maxdefault = self.size, defaultQueueCl...
python
def create(self): """ Create the subqueue to change the default behavior of Lock to semaphore. """ self.queue = self.scheduler.queue.addSubQueue(self.priority, LockEvent.createMatcher(self.context, self.key), maxdefault = self.size, defaultQueueCl...
['def', 'create', '(', 'self', ')', ':', 'self', '.', 'queue', '=', 'self', '.', 'scheduler', '.', 'queue', '.', 'addSubQueue', '(', 'self', '.', 'priority', ',', 'LockEvent', '.', 'createMatcher', '(', 'self', '.', 'context', ',', 'self', '.', 'key', ')', ',', 'maxdefault', '=', 'self', '.', 'size', ',', 'defaultQueue...
Create the subqueue to change the default behavior of Lock to semaphore.
['Create', 'the', 'subqueue', 'to', 'change', 'the', 'default', 'behavior', 'of', 'Lock', 'to', 'semaphore', '.']
train
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/event/lock.py#L141-L146
967
btel/svg_utils
src/svgutils/compose.py
Figure.tostr
def tostr(self): """Export SVG as a string""" element = _transform.SVGFigure(self.width, self.height) element.append(self) svgstr = element.to_str() return svgstr
python
def tostr(self): """Export SVG as a string""" element = _transform.SVGFigure(self.width, self.height) element.append(self) svgstr = element.to_str() return svgstr
['def', 'tostr', '(', 'self', ')', ':', 'element', '=', '_transform', '.', 'SVGFigure', '(', 'self', '.', 'width', ',', 'self', '.', 'height', ')', 'element', '.', 'append', '(', 'self', ')', 'svgstr', '=', 'element', '.', 'to_str', '(', ')', 'return', 'svgstr']
Export SVG as a string
['Export', 'SVG', 'as', 'a', 'string']
train
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L304-L309
968
TkTech/Jawa
jawa/util/bytecode.py
load_bytecode_definitions
def load_bytecode_definitions(*, path=None) -> dict: """Load bytecode definitions from JSON file. If no path is provided the default bytecode.json will be loaded. :param path: Either None or a path to a JSON file to load containing bytecode definitions. """ if path is not None: ...
python
def load_bytecode_definitions(*, path=None) -> dict: """Load bytecode definitions from JSON file. If no path is provided the default bytecode.json will be loaded. :param path: Either None or a path to a JSON file to load containing bytecode definitions. """ if path is not None: ...
['def', 'load_bytecode_definitions', '(', '*', ',', 'path', '=', 'None', ')', '->', 'dict', ':', 'if', 'path', 'is', 'not', 'None', ':', 'with', 'open', '(', 'path', ',', "'rb'", ')', 'as', 'file_in', ':', 'j', '=', 'json', '.', 'load', '(', 'file_in', ')', 'else', ':', 'try', ':', 'j', '=', 'json', '.', 'loads', '(', ...
Load bytecode definitions from JSON file. If no path is provided the default bytecode.json will be loaded. :param path: Either None or a path to a JSON file to load containing bytecode definitions.
['Load', 'bytecode', 'definitions', 'from', 'JSON', 'file', '.']
train
https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/bytecode.py#L262-L293
969
saltstack/salt
salt/modules/status.py
version
def version(): ''' Return the system version for this minion .. versionchanged:: 2016.11.4 Added support for AIX .. versionchanged:: 2018.3.0 Added support for OpenBSD CLI Example: .. code-block:: bash salt '*' status.version ''' def linux_version(): ...
python
def version(): ''' Return the system version for this minion .. versionchanged:: 2016.11.4 Added support for AIX .. versionchanged:: 2018.3.0 Added support for OpenBSD CLI Example: .. code-block:: bash salt '*' status.version ''' def linux_version(): ...
['def', 'version', '(', ')', ':', 'def', 'linux_version', '(', ')', ':', "'''\n linux specific implementation of version\n '''", 'try', ':', 'with', 'salt', '.', 'utils', '.', 'files', '.', 'fopen', '(', "'/proc/version'", ',', "'r'", ')', 'as', 'fp_', ':', 'return', 'salt', '.', 'utils', '.', 'stringutil...
Return the system version for this minion .. versionchanged:: 2016.11.4 Added support for AIX .. versionchanged:: 2018.3.0 Added support for OpenBSD CLI Example: .. code-block:: bash salt '*' status.version
['Return', 'the', 'system', 'version', 'for', 'this', 'minion']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1551-L1592
970
soasme/dogeon
dson/__init__.py
loads
def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): r"""Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a DSON document) to a Python object. If ``s`` is a ``str`` instance and is encoded with a...
python
def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): r"""Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a DSON document) to a Python object. If ``s`` is a ``str`` instance and is encoded with a...
['def', 'loads', '(', 's', ',', 'encoding', '=', 'None', ',', 'cls', '=', 'None', ',', 'object_hook', '=', 'None', ',', 'parse_float', '=', 'None', ',', 'parse_int', '=', 'None', ',', 'parse_constant', '=', 'None', ',', 'object_pairs_hook', '=', 'None', ',', '*', '*', 'kw', ')', ':', 'if', '(', 'cls', 'is', 'None', 'an...
r"""Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a DSON document) to a Python object. If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name must be specified. Encodings that are not ASCII based...
['r', 'Deserialize', 's', '(', 'a', 'str', 'or', 'unicode', 'instance', 'containing', 'a', 'DSON', 'document', ')', 'to', 'a', 'Python', 'object', '.']
train
https://github.com/soasme/dogeon/blob/496b9a5b099946d14434ed0cd7a94a270f607207/dson/__init__.py#L296-L354
971
moderngl/moderngl
moderngl/context.py
Context.core_profile_check
def core_profile_check(self) -> None: ''' Core profile check. FOR DEBUG PURPOSES ONLY ''' profile_mask = self.info['GL_CONTEXT_PROFILE_MASK'] if profile_mask != 1: warnings.warn('The window should request a CORE OpenGL profile') version_code...
python
def core_profile_check(self) -> None: ''' Core profile check. FOR DEBUG PURPOSES ONLY ''' profile_mask = self.info['GL_CONTEXT_PROFILE_MASK'] if profile_mask != 1: warnings.warn('The window should request a CORE OpenGL profile') version_code...
['def', 'core_profile_check', '(', 'self', ')', '->', 'None', ':', 'profile_mask', '=', 'self', '.', 'info', '[', "'GL_CONTEXT_PROFILE_MASK'", ']', 'if', 'profile_mask', '!=', '1', ':', 'warnings', '.', 'warn', '(', "'The window should request a CORE OpenGL profile'", ')', 'version_code', '=', 'self', '.', 'version_cod...
Core profile check. FOR DEBUG PURPOSES ONLY
['Core', 'profile', 'check', '.']
train
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L1072-L1089
972
vtkiorg/vtki
vtki/grid.py
UniformGrid._from_specs
def _from_specs(self, dims, spacing=(1.0,1.0,1.0), origin=(0.0, 0.0, 0.0)): """ Create VTK image data directly from numpy arrays. A uniform grid is defined by the node spacings for each axis (uniform along each individual axis) and the number of nodes on each axis. These are rela...
python
def _from_specs(self, dims, spacing=(1.0,1.0,1.0), origin=(0.0, 0.0, 0.0)): """ Create VTK image data directly from numpy arrays. A uniform grid is defined by the node spacings for each axis (uniform along each individual axis) and the number of nodes on each axis. These are rela...
['def', '_from_specs', '(', 'self', ',', 'dims', ',', 'spacing', '=', '(', '1.0', ',', '1.0', ',', '1.0', ')', ',', 'origin', '=', '(', '0.0', ',', '0.0', ',', '0.0', ')', ')', ':', 'xn', ',', 'yn', ',', 'zn', '=', 'dims', '[', '0', ']', ',', 'dims', '[', '1', ']', ',', 'dims', '[', '2', ']', 'xs', ',', 'ys', ',', 'zs'...
Create VTK image data directly from numpy arrays. A uniform grid is defined by the node spacings for each axis (uniform along each individual axis) and the number of nodes on each axis. These are relative to a specified origin (default is ``(0.0, 0.0, 0.0)``). Parameters -------...
['Create', 'VTK', 'image', 'data', 'directly', 'from', 'numpy', 'arrays', '.', 'A', 'uniform', 'grid', 'is', 'defined', 'by', 'the', 'node', 'spacings', 'for', 'each', 'axis', '(', 'uniform', 'along', 'each', 'individual', 'axis', ')', 'and', 'the', 'number', 'of', 'nodes', 'on', 'each', 'axis', '.', 'These', 'are', 'r...
train
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/grid.py#L369-L392
973
datacats/datacats
datacats/environment.py
Environment.data_complete
def data_complete(self): """ Return True if all the expected datadir files are present """ return task.data_complete(self.datadir, self.sitedir, self._get_container_name)
python
def data_complete(self): """ Return True if all the expected datadir files are present """ return task.data_complete(self.datadir, self.sitedir, self._get_container_name)
['def', 'data_complete', '(', 'self', ')', ':', 'return', 'task', '.', 'data_complete', '(', 'self', '.', 'datadir', ',', 'self', '.', 'sitedir', ',', 'self', '.', '_get_container_name', ')']
Return True if all the expected datadir files are present
['Return', 'True', 'if', 'all', 'the', 'expected', 'datadir', 'files', 'are', 'present']
train
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L182-L187
974
foremast/foremast
src/foremast/consts.py
extract_formats
def extract_formats(config_handle): """Get application formats. See :class:`gogoutils.Formats` for available options. Args: config_handle (configparser.ConfigParser): Instance of configurations. Returns: dict: Formats in ``{$format_type: $format_pattern}``. """ configurations...
python
def extract_formats(config_handle): """Get application formats. See :class:`gogoutils.Formats` for available options. Args: config_handle (configparser.ConfigParser): Instance of configurations. Returns: dict: Formats in ``{$format_type: $format_pattern}``. """ configurations...
['def', 'extract_formats', '(', 'config_handle', ')', ':', 'configurations', '=', 'dict', '(', 'config_handle', ')', 'formats', '=', 'dict', '(', 'configurations', '.', 'get', '(', "'formats'", ',', '{', '}', ')', ')', 'return', 'formats']
Get application formats. See :class:`gogoutils.Formats` for available options. Args: config_handle (configparser.ConfigParser): Instance of configurations. Returns: dict: Formats in ``{$format_type: $format_pattern}``.
['Get', 'application', 'formats', '.']
train
https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/consts.py#L77-L91
975
Telefonica/toolium
toolium/utils.py
Utils.get_center
def get_center(self, element): """Get center coordinates of an element :param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value) :returns: dict with center coordinates """ web_element = self.get_web_element(element) loca...
python
def get_center(self, element): """Get center coordinates of an element :param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value) :returns: dict with center coordinates """ web_element = self.get_web_element(element) loca...
['def', 'get_center', '(', 'self', ',', 'element', ')', ':', 'web_element', '=', 'self', '.', 'get_web_element', '(', 'element', ')', 'location', '=', 'web_element', '.', 'location', 'size', '=', 'web_element', '.', 'size', 'return', '{', "'x'", ':', 'location', '[', "'x'", ']', '+', '(', 'size', '[', "'width'", ']', '...
Get center coordinates of an element :param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value) :returns: dict with center coordinates
['Get', 'center', 'coordinates', 'of', 'an', 'element']
train
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/utils.py#L561-L570
976
casacore/python-casacore
casacore/tables/msutil.py
addImagingColumns
def addImagingColumns(msname, ack=True): """ Add the columns to an MS needed for the casa imager. It adds the columns MODEL_DATA, CORRECTED_DATA, and IMAGING_WEIGHT. It also sets the CHANNEL_SELECTION keyword needed for the older casa imagers. A column is not added if already existing. """ ...
python
def addImagingColumns(msname, ack=True): """ Add the columns to an MS needed for the casa imager. It adds the columns MODEL_DATA, CORRECTED_DATA, and IMAGING_WEIGHT. It also sets the CHANNEL_SELECTION keyword needed for the older casa imagers. A column is not added if already existing. """ ...
['def', 'addImagingColumns', '(', 'msname', ',', 'ack', '=', 'True', ')', ':', '# numpy is needed', 'import', 'numpy', 'as', 'np', '# Open the MS', 't', '=', 'table', '(', 'msname', ',', 'readonly', '=', 'False', ',', 'ack', '=', 'False', ')', 'cnames', '=', 't', '.', 'colnames', '(', ')', '# Get the description of the...
Add the columns to an MS needed for the casa imager. It adds the columns MODEL_DATA, CORRECTED_DATA, and IMAGING_WEIGHT. It also sets the CHANNEL_SELECTION keyword needed for the older casa imagers. A column is not added if already existing.
['Add', 'the', 'columns', 'to', 'an', 'MS', 'needed', 'for', 'the', 'casa', 'imager', '.']
train
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/tables/msutil.py#L48-L128
977
rstoneback/pysatMagVect
pysatMagVect/satellite.py
add_mag_drifts
def add_mag_drifts(inst): """Adds ion drifts in magnetic coordinates using ion drifts in S/C coordinates along with pre-calculated unit vectors for magnetic coordinates. Note ---- Requires ion drifts under labels 'iv_*' where * = (x,y,z) along with unit vectors labels 'unit_zonal_*'...
python
def add_mag_drifts(inst): """Adds ion drifts in magnetic coordinates using ion drifts in S/C coordinates along with pre-calculated unit vectors for magnetic coordinates. Note ---- Requires ion drifts under labels 'iv_*' where * = (x,y,z) along with unit vectors labels 'unit_zonal_*'...
['def', 'add_mag_drifts', '(', 'inst', ')', ':', 'inst', '[', "'iv_zon'", ']', '=', '{', "'data'", ':', 'inst', '[', "'unit_zon_x'", ']', '*', 'inst', '[', "'iv_x'", ']', '+', 'inst', '[', "'unit_zon_y'", ']', '*', 'inst', '[', "'iv_y'", ']', '+', 'inst', '[', "'unit_zon_z'", ']', '*', 'inst', '[', "'iv_z'", ']', ',', ...
Adds ion drifts in magnetic coordinates using ion drifts in S/C coordinates along with pre-calculated unit vectors for magnetic coordinates. Note ---- Requires ion drifts under labels 'iv_*' where * = (x,y,z) along with unit vectors labels 'unit_zonal_*', 'unit_fa_*', and 'unit_mer_*', ...
['Adds', 'ion', 'drifts', 'in', 'magnetic', 'coordinates', 'using', 'ion', 'drifts', 'in', 'S', '/', 'C', 'coordinates', 'along', 'with', 'pre', '-', 'calculated', 'unit', 'vectors', 'for', 'magnetic', 'coordinates', '.', 'Note', '----', 'Requires', 'ion', 'drifts', 'under', 'labels', 'iv_', '*', 'where', '*', '=', '('...
train
https://github.com/rstoneback/pysatMagVect/blob/3fdc87ffbe05be58123f80f880d1237c2f34c7be/pysatMagVect/satellite.py#L345-L415
978
lxyu/pinyin
pinyin/cedict.py
_words_at_the_beginning
def _words_at_the_beginning(word, tree, prefix=""): ''' We return all portions of the tree corresponding to the beginning of `word`. This is used recursively, so we pass the prefix so we can return meaningful words+translations. ''' l = [] if "" in tree: l.append([prefix, tree[""]]) ...
python
def _words_at_the_beginning(word, tree, prefix=""): ''' We return all portions of the tree corresponding to the beginning of `word`. This is used recursively, so we pass the prefix so we can return meaningful words+translations. ''' l = [] if "" in tree: l.append([prefix, tree[""]]) ...
['def', '_words_at_the_beginning', '(', 'word', ',', 'tree', ',', 'prefix', '=', '""', ')', ':', 'l', '=', '[', ']', 'if', '""', 'in', 'tree', ':', 'l', '.', 'append', '(', '[', 'prefix', ',', 'tree', '[', '""', ']', ']', ')', 'if', 'len', '(', 'word', ')', '>', '0', 'and', 'word', '[', '0', ']', 'in', 'tree', ':', 'l'...
We return all portions of the tree corresponding to the beginning of `word`. This is used recursively, so we pass the prefix so we can return meaningful words+translations.
['We', 'return', 'all', 'portions', 'of', 'the', 'tree', 'corresponding', 'to', 'the', 'beginning', 'of', 'word', '.', 'This', 'is', 'used', 'recursively', 'so', 'we', 'pass', 'the', 'prefix', 'so', 'we', 'can', 'return', 'meaningful', 'words', '+', 'translations', '.']
train
https://github.com/lxyu/pinyin/blob/f9cac5902b0cfaf91d93af633dfc75a51d2bf0cd/pinyin/cedict.py#L104-L119
979
fprimex/zdesk
zdesk/zdesk_api.py
ZendeskAPI.help_center_categories_list
def help_center_categories_list(self, locale=None, sort_by=None, sort_order=None, **kwargs): "https://developer.zendesk.com/rest_api/docs/help_center/categories#list-categories" api_path = "/api/v2/help_center/categories.json" if locale: api_opt_path = "/api/v2/help_center/{locale}/c...
python
def help_center_categories_list(self, locale=None, sort_by=None, sort_order=None, **kwargs): "https://developer.zendesk.com/rest_api/docs/help_center/categories#list-categories" api_path = "/api/v2/help_center/categories.json" if locale: api_opt_path = "/api/v2/help_center/{locale}/c...
['def', 'help_center_categories_list', '(', 'self', ',', 'locale', '=', 'None', ',', 'sort_by', '=', 'None', ',', 'sort_order', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'api_path', '=', '"/api/v2/help_center/categories.json"', 'if', 'locale', ':', 'api_opt_path', '=', '"/api/v2/help_center/{locale}/categories.js...
https://developer.zendesk.com/rest_api/docs/help_center/categories#list-categories
['https', ':', '//', 'developer', '.', 'zendesk', '.', 'com', '/', 'rest_api', '/', 'docs', '/', 'help_center', '/', 'categories#list', '-', 'categories']
train
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L1686-L1704
980
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_noise_filter
def set_noise_filter(self, user_gpio, steady, active): """ Sets a noise filter on a GPIO. Level changes on the GPIO are ignored until a level which has been stable for [*steady*] microseconds is detected. Level changes on the GPIO are then reported for [*active*] microse...
python
def set_noise_filter(self, user_gpio, steady, active): """ Sets a noise filter on a GPIO. Level changes on the GPIO are ignored until a level which has been stable for [*steady*] microseconds is detected. Level changes on the GPIO are then reported for [*active*] microse...
['def', 'set_noise_filter', '(', 'self', ',', 'user_gpio', ',', 'steady', ',', 'active', ')', ':', '# pigpio message format', '# I p1 user_gpio', '# I p2 steady', '# I p3 4', '## extension ##', '# I active', 'extents', '=', '[', 'struct', '.', 'pack', '(', '"I"', ',', 'active', ')', ']', 'res', '=', 'yield', 'from', 's...
Sets a noise filter on a GPIO. Level changes on the GPIO are ignored until a level which has been stable for [*steady*] microseconds is detected. Level changes on the GPIO are then reported for [*active*] microseconds after which the process repeats. user_gpio:= 0-31 ...
['Sets', 'a', 'noise', 'filter', 'on', 'a', 'GPIO', '.', 'Level', 'changes', 'on', 'the', 'GPIO', 'are', 'ignored', 'until', 'a', 'level', 'which', 'has', 'been', 'stable', 'for', '[', '*', 'steady', '*', ']', 'microseconds', 'is', 'detected', '.', 'Level', 'changes', 'on', 'the', 'GPIO', 'are', 'then', 'reported', 'fo...
train
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L937-L969
981
angr/angr
angr/state_plugins/solver.py
SimSolver.simplify
def simplify(self, e=None): """ Simplifies `e`. If `e` is None, simplifies the constraints of this state. """ if e is None: return self._solver.simplify() elif isinstance(e, (int, float, bool)): return e elif isinstance(e, claripy.ast.Base)...
python
def simplify(self, e=None): """ Simplifies `e`. If `e` is None, simplifies the constraints of this state. """ if e is None: return self._solver.simplify() elif isinstance(e, (int, float, bool)): return e elif isinstance(e, claripy.ast.Base)...
['def', 'simplify', '(', 'self', ',', 'e', '=', 'None', ')', ':', 'if', 'e', 'is', 'None', ':', 'return', 'self', '.', '_solver', '.', 'simplify', '(', ')', 'elif', 'isinstance', '(', 'e', ',', '(', 'int', ',', 'float', ',', 'bool', ')', ')', ':', 'return', 'e', 'elif', 'isinstance', '(', 'e', ',', 'claripy', '.', 'ast...
Simplifies `e`. If `e` is None, simplifies the constraints of this state.
['Simplifies', 'e', '.', 'If', 'e', 'is', 'None', 'simplifies', 'the', 'constraints', 'of', 'this', 'state', '.']
train
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/solver.py#L850-L866
982
mrname/haralyzer
haralyzer/multihar.py
MultiHarParser.time_to_first_byte
def time_to_first_byte(self): """ The aggregate time to first byte for all pages. """ ttfb = [] for page in self.pages: if page.time_to_first_byte is not None: ttfb.append(page.time_to_first_byte) return round(mean(ttfb), self.decimal_precision...
python
def time_to_first_byte(self): """ The aggregate time to first byte for all pages. """ ttfb = [] for page in self.pages: if page.time_to_first_byte is not None: ttfb.append(page.time_to_first_byte) return round(mean(ttfb), self.decimal_precision...
['def', 'time_to_first_byte', '(', 'self', ')', ':', 'ttfb', '=', '[', ']', 'for', 'page', 'in', 'self', '.', 'pages', ':', 'if', 'page', '.', 'time_to_first_byte', 'is', 'not', 'None', ':', 'ttfb', '.', 'append', '(', 'page', '.', 'time_to_first_byte', ')', 'return', 'round', '(', 'mean', '(', 'ttfb', ')', ',', 'self'...
The aggregate time to first byte for all pages.
['The', 'aggregate', 'time', 'to', 'first', 'byte', 'for', 'all', 'pages', '.']
train
https://github.com/mrname/haralyzer/blob/5ef38b8cfc044d2dfeacf2dd4d1efb810228309d/haralyzer/multihar.py#L105-L113
983
latchset/jwcrypto
jwcrypto/jwk.py
JWK.from_pem
def from_pem(cls, data, password=None): """Creates a key from PKCS#8 formatted data loaded from a PEM file. See the function `import_from_pem` for details. :param data(bytes): The data contained in a PEM file. :param password(bytes): An optional password to unwrap the key. ""...
python
def from_pem(cls, data, password=None): """Creates a key from PKCS#8 formatted data loaded from a PEM file. See the function `import_from_pem` for details. :param data(bytes): The data contained in a PEM file. :param password(bytes): An optional password to unwrap the key. ""...
['def', 'from_pem', '(', 'cls', ',', 'data', ',', 'password', '=', 'None', ')', ':', 'obj', '=', 'cls', '(', ')', 'obj', '.', 'import_from_pem', '(', 'data', ',', 'password', ')', 'return', 'obj']
Creates a key from PKCS#8 formatted data loaded from a PEM file. See the function `import_from_pem` for details. :param data(bytes): The data contained in a PEM file. :param password(bytes): An optional password to unwrap the key.
['Creates', 'a', 'key', 'from', 'PKCS#8', 'formatted', 'data', 'loaded', 'from', 'a', 'PEM', 'file', '.', 'See', 'the', 'function', 'import_from_pem', 'for', 'details', '.']
train
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L837-L846
984
bunq/sdk_python
bunq/sdk/security.py
_add_header_client_encryption_hmac
def _add_header_client_encryption_hmac(request_bytes, key, iv, custom_headers): """ :type request_bytes: bytes :type key: bytes :type iv: bytes :type custom_headers: dict[str, str] :rtype: None """ hashed = hmac.new(key, iv + request_bytes, sha1) hashed_base64 = base64.b64encode(ha...
python
def _add_header_client_encryption_hmac(request_bytes, key, iv, custom_headers): """ :type request_bytes: bytes :type key: bytes :type iv: bytes :type custom_headers: dict[str, str] :rtype: None """ hashed = hmac.new(key, iv + request_bytes, sha1) hashed_base64 = base64.b64encode(ha...
['def', '_add_header_client_encryption_hmac', '(', 'request_bytes', ',', 'key', ',', 'iv', ',', 'custom_headers', ')', ':', 'hashed', '=', 'hmac', '.', 'new', '(', 'key', ',', 'iv', '+', 'request_bytes', ',', 'sha1', ')', 'hashed_base64', '=', 'base64', '.', 'b64encode', '(', 'hashed', '.', 'digest', '(', ')', ')', '.'...
:type request_bytes: bytes :type key: bytes :type iv: bytes :type custom_headers: dict[str, str] :rtype: None
[':', 'type', 'request_bytes', ':', 'bytes', ':', 'type', 'key', ':', 'bytes', ':', 'type', 'iv', ':', 'bytes', ':', 'type', 'custom_headers', ':', 'dict', '[', 'str', 'str', ']']
train
https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/security.py#L221-L233
985
saltstack/salt
salt/wheel/pillar_roots.py
list_env
def list_env(saltenv='base'): ''' Return all of the file paths found in an environment ''' ret = {} if saltenv not in __opts__['pillar_roots']: return ret for f_root in __opts__['pillar_roots'][saltenv]: ret[f_root] = {} for root, dirs, files in salt.utils.path.os_walk(f_...
python
def list_env(saltenv='base'): ''' Return all of the file paths found in an environment ''' ret = {} if saltenv not in __opts__['pillar_roots']: return ret for f_root in __opts__['pillar_roots'][saltenv]: ret[f_root] = {} for root, dirs, files in salt.utils.path.os_walk(f_...
['def', 'list_env', '(', 'saltenv', '=', "'base'", ')', ':', 'ret', '=', '{', '}', 'if', 'saltenv', 'not', 'in', '__opts__', '[', "'pillar_roots'", ']', ':', 'return', 'ret', 'for', 'f_root', 'in', '__opts__', '[', "'pillar_roots'", ']', '[', 'saltenv', ']', ':', 'ret', '[', 'f_root', ']', '=', '{', '}', 'for', 'root',...
Return all of the file paths found in an environment
['Return', 'all', 'of', 'the', 'file', 'paths', 'found', 'in', 'an', 'environment']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/pillar_roots.py#L39-L66
986
sorgerlab/indra
indra/statements/resources.py
get_valid_location
def get_valid_location(location): """Check if the given location represents a valid cellular component.""" # If we're given None, return None if location is not None and cellular_components.get(location) is None: loc = cellular_components_reverse.get(location) if loc is None: rai...
python
def get_valid_location(location): """Check if the given location represents a valid cellular component.""" # If we're given None, return None if location is not None and cellular_components.get(location) is None: loc = cellular_components_reverse.get(location) if loc is None: rai...
['def', 'get_valid_location', '(', 'location', ')', ':', "# If we're given None, return None", 'if', 'location', 'is', 'not', 'None', 'and', 'cellular_components', '.', 'get', '(', 'location', ')', 'is', 'None', ':', 'loc', '=', 'cellular_components_reverse', '.', 'get', '(', 'location', ')', 'if', 'loc', 'is', 'None',...
Check if the given location represents a valid cellular component.
['Check', 'if', 'the', 'given', 'location', 'represents', 'a', 'valid', 'cellular', 'component', '.']
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/resources.py#L26-L35
987
DLR-RM/RAFCON
source/rafcon/core/start.py
parse_state_machine_path
def parse_state_machine_path(path): """Parser for argparse checking pfor a proper state machine path :param str path: Input path from the user :return: The path :raises argparse.ArgumentTypeError: if the path does not contain a statemachine.json file """ sm_root_file = join(path, storage.STATEM...
python
def parse_state_machine_path(path): """Parser for argparse checking pfor a proper state machine path :param str path: Input path from the user :return: The path :raises argparse.ArgumentTypeError: if the path does not contain a statemachine.json file """ sm_root_file = join(path, storage.STATEM...
['def', 'parse_state_machine_path', '(', 'path', ')', ':', 'sm_root_file', '=', 'join', '(', 'path', ',', 'storage', '.', 'STATEMACHINE_FILE', ')', 'if', 'exists', '(', 'sm_root_file', ')', ':', 'return', 'path', 'else', ':', 'sm_root_file', '=', 'join', '(', 'path', ',', 'storage', '.', 'STATEMACHINE_FILE_OLD', ')', '...
Parser for argparse checking pfor a proper state machine path :param str path: Input path from the user :return: The path :raises argparse.ArgumentTypeError: if the path does not contain a statemachine.json file
['Parser', 'for', 'argparse', 'checking', 'pfor', 'a', 'proper', 'state', 'machine', 'path']
train
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/start.py#L98-L113
988
spyder-ide/spyder
spyder/widgets/comboboxes.py
is_module_or_package
def is_module_or_package(path): """Return True if path is a Python module/package""" is_module = osp.isfile(path) and osp.splitext(path)[1] in ('.py', '.pyw') is_package = osp.isdir(path) and osp.isfile(osp.join(path, '__init__.py')) return is_module or is_package
python
def is_module_or_package(path): """Return True if path is a Python module/package""" is_module = osp.isfile(path) and osp.splitext(path)[1] in ('.py', '.pyw') is_package = osp.isdir(path) and osp.isfile(osp.join(path, '__init__.py')) return is_module or is_package
['def', 'is_module_or_package', '(', 'path', ')', ':', 'is_module', '=', 'osp', '.', 'isfile', '(', 'path', ')', 'and', 'osp', '.', 'splitext', '(', 'path', ')', '[', '1', ']', 'in', '(', "'.py'", ',', "'.pyw'", ')', 'is_package', '=', 'osp', '.', 'isdir', '(', 'path', ')', 'and', 'osp', '.', 'isfile', '(', 'osp', '.',...
Return True if path is a Python module/package
['Return', 'True', 'if', 'path', 'is', 'a', 'Python', 'module', '/', 'package']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/comboboxes.py#L336-L340
989
log2timeline/plaso
plaso/storage/sqlite/sqlite_file.py
SQLiteStorageFile.GetSortedEvents
def GetSortedEvents(self, time_range=None): """Retrieves the events in increasing chronological order. Args: time_range (Optional[TimeRange]): time range used to filter events that fall in a specific period. Yield: EventObject: event. """ filter_expression = None if time_...
python
def GetSortedEvents(self, time_range=None): """Retrieves the events in increasing chronological order. Args: time_range (Optional[TimeRange]): time range used to filter events that fall in a specific period. Yield: EventObject: event. """ filter_expression = None if time_...
['def', 'GetSortedEvents', '(', 'self', ',', 'time_range', '=', 'None', ')', ':', 'filter_expression', '=', 'None', 'if', 'time_range', ':', 'filter_expression', '=', '[', ']', 'if', 'time_range', '.', 'start_timestamp', ':', 'filter_expression', '.', 'append', '(', "'_timestamp >= {0:d}'", '.', 'format', '(', 'time_ra...
Retrieves the events in increasing chronological order. Args: time_range (Optional[TimeRange]): time range used to filter events that fall in a specific period. Yield: EventObject: event.
['Retrieves', 'the', 'events', 'in', 'increasing', 'chronological', 'order', '.']
train
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/storage/sqlite/sqlite_file.py#L920-L956
990
mattimck/python-exist
exist/auth.py
ExistAuth.browser_authorize
def browser_authorize(self): """ Open a browser to the authorization url and spool up a CherryPy server to accept the response """ url = self.authorize_url() # Open the web browser in a new thread for command-line browser support threading.Timer(1, webbrowser.open...
python
def browser_authorize(self): """ Open a browser to the authorization url and spool up a CherryPy server to accept the response """ url = self.authorize_url() # Open the web browser in a new thread for command-line browser support threading.Timer(1, webbrowser.open...
['def', 'browser_authorize', '(', 'self', ')', ':', 'url', '=', 'self', '.', 'authorize_url', '(', ')', '# Open the web browser in a new thread for command-line browser support', 'threading', '.', 'Timer', '(', '1', ',', 'webbrowser', '.', 'open', ',', 'args', '=', '(', 'url', ',', ')', ')', '.', 'start', '(', ')', 'se...
Open a browser to the authorization url and spool up a CherryPy server to accept the response
['Open', 'a', 'browser', 'to', 'the', 'authorization', 'url', 'and', 'spool', 'up', 'a', 'CherryPy', 'server', 'to', 'accept', 'the', 'response']
train
https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/auth.py#L116-L135
991
bcbio/bcbio-nextgen
bcbio/hla/optitype.py
run
def run(data): """HLA typing with OptiType, parsing output from called genotype files. """ hlas = [] for hla_fq in tz.get_in(["hla", "fastq"], data, []): hla_type = re.search("[.-](?P<hlatype>HLA-[\w-]+).fq", hla_fq).group("hlatype") if hla_type in SUPPORTED_HLAS: if utils.fi...
python
def run(data): """HLA typing with OptiType, parsing output from called genotype files. """ hlas = [] for hla_fq in tz.get_in(["hla", "fastq"], data, []): hla_type = re.search("[.-](?P<hlatype>HLA-[\w-]+).fq", hla_fq).group("hlatype") if hla_type in SUPPORTED_HLAS: if utils.fi...
['def', 'run', '(', 'data', ')', ':', 'hlas', '=', '[', ']', 'for', 'hla_fq', 'in', 'tz', '.', 'get_in', '(', '[', '"hla"', ',', '"fastq"', ']', ',', 'data', ',', '[', ']', ')', ':', 'hla_type', '=', 're', '.', 'search', '(', '"[.-](?P<hlatype>HLA-[\\w-]+).fq"', ',', 'hla_fq', ')', '.', 'group', '(', '"hlatype"', ')', ...
HLA typing with OptiType, parsing output from called genotype files.
['HLA', 'typing', 'with', 'OptiType', 'parsing', 'output', 'from', 'called', 'genotype', 'files', '.']
train
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L23-L50
992
ambitioninc/django-entity
entity/models.py
EntityGroup.bulk_overwrite
def bulk_overwrite(self, entities_and_kinds): """ Update the group to the given entities and sub-entity groups. After this operation, the only members of this EntityGroup will be the given entities, and sub-entity groups. :type entities_and_kinds: List of (Entity, EntityKind) p...
python
def bulk_overwrite(self, entities_and_kinds): """ Update the group to the given entities and sub-entity groups. After this operation, the only members of this EntityGroup will be the given entities, and sub-entity groups. :type entities_and_kinds: List of (Entity, EntityKind) p...
['def', 'bulk_overwrite', '(', 'self', ',', 'entities_and_kinds', ')', ':', 'EntityGroupMembership', '.', 'objects', '.', 'filter', '(', 'entity_group', '=', 'self', ')', '.', 'delete', '(', ')', 'return', 'self', '.', 'bulk_add_entities', '(', 'entities_and_kinds', ')']
Update the group to the given entities and sub-entity groups. After this operation, the only members of this EntityGroup will be the given entities, and sub-entity groups. :type entities_and_kinds: List of (Entity, EntityKind) pairs. :param entities_and_kinds: A list of entity, entity-...
['Update', 'the', 'group', 'to', 'the', 'given', 'entities', 'and', 'sub', '-', 'entity', 'groups', '.']
train
https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/models.py#L493-L507
993
pantsbuild/pants
src/python/pants/base/exception_sink.py
SignalHandler.signal_handler_mapping
def signal_handler_mapping(self): """A dict mapping (signal number) -> (a method handling the signal).""" # Could use an enum here, but we never end up doing any matching on the specific signal value, # instead just iterating over the registered signals to set handlers, so a dict is probably # better. ...
python
def signal_handler_mapping(self): """A dict mapping (signal number) -> (a method handling the signal).""" # Could use an enum here, but we never end up doing any matching on the specific signal value, # instead just iterating over the registered signals to set handlers, so a dict is probably # better. ...
['def', 'signal_handler_mapping', '(', 'self', ')', ':', '# Could use an enum here, but we never end up doing any matching on the specific signal value,', '# instead just iterating over the registered signals to set handlers, so a dict is probably', '# better.', 'return', '{', 'signal', '.', 'SIGINT', ':', 'self', '.',...
A dict mapping (signal number) -> (a method handling the signal).
['A', 'dict', 'mapping', '(', 'signal', 'number', ')', '-', '>', '(', 'a', 'method', 'handling', 'the', 'signal', ')', '.']
train
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/exception_sink.py#L40-L49
994
geomet/geomet
geomet/wkb.py
_get_geom_type
def _get_geom_type(type_bytes): """Get the GeoJSON geometry type label from a WKB type byte string. :param type_bytes: 4 byte string in big endian byte order containing a WKB type number. It may also contain a "has SRID" flag in the high byte (the first type, since this is big endian by...
python
def _get_geom_type(type_bytes): """Get the GeoJSON geometry type label from a WKB type byte string. :param type_bytes: 4 byte string in big endian byte order containing a WKB type number. It may also contain a "has SRID" flag in the high byte (the first type, since this is big endian by...
['def', '_get_geom_type', '(', 'type_bytes', ')', ':', '# slice off the high byte, which may contain the SRID flag', 'high_byte', '=', 'type_bytes', '[', '0', ']', 'if', 'six', '.', 'PY3', ':', 'high_byte', '=', 'bytes', '(', '[', 'high_byte', ']', ')', 'has_srid', '=', 'high_byte', '==', "b'\\x20'", 'if', 'has_srid', ...
Get the GeoJSON geometry type label from a WKB type byte string. :param type_bytes: 4 byte string in big endian byte order containing a WKB type number. It may also contain a "has SRID" flag in the high byte (the first type, since this is big endian byte order), indicated as 0x20. If the SR...
['Get', 'the', 'GeoJSON', 'geometry', 'type', 'label', 'from', 'a', 'WKB', 'type', 'byte', 'string', '.']
train
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L110-L147
995
docker/docker-py
docker/types/daemon.py
CancellableStream.close
def close(self): """ Closes the event streaming. """ if not self._response.raw.closed: # find the underlying socket object # based on api.client._get_raw_response_socket sock_fp = self._response.raw._fp.fp if hasattr(sock_fp, 'raw'): ...
python
def close(self): """ Closes the event streaming. """ if not self._response.raw.closed: # find the underlying socket object # based on api.client._get_raw_response_socket sock_fp = self._response.raw._fp.fp if hasattr(sock_fp, 'raw'): ...
['def', 'close', '(', 'self', ')', ':', 'if', 'not', 'self', '.', '_response', '.', 'raw', '.', 'closed', ':', '# find the underlying socket object', '# based on api.client._get_raw_response_socket', 'sock_fp', '=', 'self', '.', '_response', '.', 'raw', '.', '_fp', '.', 'fp', 'if', 'hasattr', '(', 'sock_fp', ',', "'raw...
Closes the event streaming.
['Closes', 'the', 'event', 'streaming', '.']
train
https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/types/daemon.py#L40-L74
996
log2timeline/plaso
plaso/containers/artifacts.py
OperatingSystemArtifact.version_tuple
def version_tuple(self): """tuple[int]: version tuple or None if version is not set or invalid.""" try: return tuple([int(digit, 10) for digit in self.version.split('.')]) except (AttributeError, TypeError, ValueError): return None
python
def version_tuple(self): """tuple[int]: version tuple or None if version is not set or invalid.""" try: return tuple([int(digit, 10) for digit in self.version.split('.')]) except (AttributeError, TypeError, ValueError): return None
['def', 'version_tuple', '(', 'self', ')', ':', 'try', ':', 'return', 'tuple', '(', '[', 'int', '(', 'digit', ',', '10', ')', 'for', 'digit', 'in', 'self', '.', 'version', '.', 'split', '(', "'.'", ')', ']', ')', 'except', '(', 'AttributeError', ',', 'TypeError', ',', 'ValueError', ')', ':', 'return', 'None']
tuple[int]: version tuple or None if version is not set or invalid.
['tuple', '[', 'int', ']', ':', 'version', 'tuple', 'or', 'None', 'if', 'version', 'is', 'not', 'set', 'or', 'invalid', '.']
train
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/containers/artifacts.py#L135-L140
997
KelSolaar/Foundations
foundations/nodes.py
AbstractCompositeNode.remove_child
def remove_child(self, index): """ Removes child at given index from the Node children. Usage:: >>> node_a = AbstractCompositeNode("MyNodeA") >>> node_b = AbstractCompositeNode("MyNodeB", node_a) >>> node_c = AbstractCompositeNode("MyNodeC", node_a) ...
python
def remove_child(self, index): """ Removes child at given index from the Node children. Usage:: >>> node_a = AbstractCompositeNode("MyNodeA") >>> node_b = AbstractCompositeNode("MyNodeB", node_a) >>> node_c = AbstractCompositeNode("MyNodeC", node_a) ...
['def', 'remove_child', '(', 'self', ',', 'index', ')', ':', 'if', 'index', '<', '0', 'or', 'index', '>', 'len', '(', 'self', '.', '__children', ')', ':', 'return', 'child', '=', 'self', '.', '__children', '.', 'pop', '(', 'index', ')', 'child', '.', 'parent', '=', 'None', 'return', 'child']
Removes child at given index from the Node children. Usage:: >>> node_a = AbstractCompositeNode("MyNodeA") >>> node_b = AbstractCompositeNode("MyNodeB", node_a) >>> node_c = AbstractCompositeNode("MyNodeC", node_a) >>> node_a.remove_child(1) True ...
['Removes', 'child', 'at', 'given', 'index', 'from', 'the', 'Node', 'children', '.']
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/nodes.py#L775-L800
998
rflamary/POT
ot/da.py
BaseTransport.fit
def fit(self, Xs=None, ys=None, Xt=None, yt=None): """Build a coupling matrix from source and target sets of samples (Xs, ys) and (Xt, yt) Parameters ---------- Xs : array-like, shape (n_source_samples, n_features) The training input samples. ys : array-like,...
python
def fit(self, Xs=None, ys=None, Xt=None, yt=None): """Build a coupling matrix from source and target sets of samples (Xs, ys) and (Xt, yt) Parameters ---------- Xs : array-like, shape (n_source_samples, n_features) The training input samples. ys : array-like,...
['def', 'fit', '(', 'self', ',', 'Xs', '=', 'None', ',', 'ys', '=', 'None', ',', 'Xt', '=', 'None', ',', 'yt', '=', 'None', ')', ':', '# check the necessary inputs parameters are here', 'if', 'check_params', '(', 'Xs', '=', 'Xs', ',', 'Xt', '=', 'Xt', ')', ':', '# pairwise distance', 'self', '.', 'cost_', '=', 'dist', ...
Build a coupling matrix from source and target sets of samples (Xs, ys) and (Xt, yt) Parameters ---------- Xs : array-like, shape (n_source_samples, n_features) The training input samples. ys : array-like, shape (n_source_samples,) The class labels ...
['Build', 'a', 'coupling', 'matrix', 'from', 'source', 'and', 'target', 'sets', 'of', 'samples', '(', 'Xs', 'ys', ')', 'and', '(', 'Xt', 'yt', ')']
train
https://github.com/rflamary/POT/blob/c5108efc7b6702e1af3928bef1032e6b37734d1c/ot/da.py#L783-L841
999
dls-controls/pymalcolm
malcolm/modules/web/controllers/websocketclientcomms.py
WebsocketClientComms.sync_proxy
def sync_proxy(self, mri, block): """Abstract method telling the ClientComms to sync this proxy Block with its remote counterpart. Should wait until it is connected Args: mri (str): The mri for the remote block block (BlockModel): The local proxy Block to keep in sync ...
python
def sync_proxy(self, mri, block): """Abstract method telling the ClientComms to sync this proxy Block with its remote counterpart. Should wait until it is connected Args: mri (str): The mri for the remote block block (BlockModel): The local proxy Block to keep in sync ...
['def', 'sync_proxy', '(', 'self', ',', 'mri', ',', 'block', ')', ':', '# Send a root Subscribe to the server', 'subscribe', '=', 'Subscribe', '(', 'path', '=', '[', 'mri', ']', ',', 'delta', '=', 'True', ')', 'done_queue', '=', 'Queue', '(', ')', 'def', 'handle_response', '(', 'response', ')', ':', '# Called from torn...
Abstract method telling the ClientComms to sync this proxy Block with its remote counterpart. Should wait until it is connected Args: mri (str): The mri for the remote block block (BlockModel): The local proxy Block to keep in sync
['Abstract', 'method', 'telling', 'the', 'ClientComms', 'to', 'sync', 'this', 'proxy', 'Block', 'with', 'its', 'remote', 'counterpart', '.', 'Should', 'wait', 'until', 'it', 'is', 'connected']
train
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/web/controllers/websocketclientcomms.py#L139-L163