repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
quodlibet/mutagen
mutagen/_util.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/_util.py#L974-L1025
def decode_terminated(data, encoding, strict=True): """Returns the decoded data until the first NULL terminator and all data after it. Args: data (bytes): data to decode encoding (str): The codec to use strict (bool): If True will raise ValueError in case no NULL is found ...
[ "def", "decode_terminated", "(", "data", ",", "encoding", ",", "strict", "=", "True", ")", ":", "codec_info", "=", "codecs", ".", "lookup", "(", "encoding", ")", "# normalize encoding name so we can compare by name", "encoding", "=", "codec_info", ".", "name", "# ...
Returns the decoded data until the first NULL terminator and all data after it. Args: data (bytes): data to decode encoding (str): The codec to use strict (bool): If True will raise ValueError in case no NULL is found but the available data decoded successfully. Returns:...
[ "Returns", "the", "decoded", "data", "until", "the", "first", "NULL", "terminator", "and", "all", "data", "after", "it", "." ]
python
train
34.346154
IdentityPython/pysaml2
src/saml2/server.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/server.py#L832-L858
def create_authn_query_response(self, subject, session_index=None, requested_context=None, in_response_to=None, issuer=None, sign_response=False, status=None, sign_alg=None, digest_alg=None, ...
[ "def", "create_authn_query_response", "(", "self", ",", "subject", ",", "session_index", "=", "None", ",", "requested_context", "=", "None", ",", "in_response_to", "=", "None", ",", "issuer", "=", "None", ",", "sign_response", "=", "False", ",", "status", "=",...
A successful <Response> will contain one or more assertions containing authentication statements. :return:
[ "A", "successful", "<Response", ">", "will", "contain", "one", "or", "more", "assertions", "containing", "authentication", "statements", "." ]
python
train
40.925926
lyst/lightfm
lightfm/lightfm.py
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L744-L828
def predict( self, user_ids, item_ids, item_features=None, user_features=None, num_threads=1 ): """ Compute the recommendation score for user-item pairs. For details on how to use feature matrices, see the documentation on the :class:`lightfm.LightFM` class. Argumen...
[ "def", "predict", "(", "self", ",", "user_ids", ",", "item_ids", ",", "item_features", "=", "None", ",", "user_features", "=", "None", ",", "num_threads", "=", "1", ")", ":", "self", ".", "_check_initialized", "(", ")", "if", "not", "isinstance", "(", "u...
Compute the recommendation score for user-item pairs. For details on how to use feature matrices, see the documentation on the :class:`lightfm.LightFM` class. Arguments --------- user_ids: integer or np.int32 array of shape [n_pairs,] single user id or an array co...
[ "Compute", "the", "recommendation", "score", "for", "user", "-", "item", "pairs", "." ]
python
train
36.117647
svartalf/python-opus
opus/api/decoder.py
https://github.com/svartalf/python-opus/blob/a3c1d556d2772b5be659ddd08c033ddd4d566b3a/opus/api/decoder.py#L132-L150
def decode(decoder, data, length, frame_size, decode_fec, channels=2): """Decode an Opus frame Unlike the `opus_decode` function , this function takes an additional parameter `channels`, which indicates the number of channels in the frame """ pcm_size = frame_size * channels * ctypes.sizeof(ctypes...
[ "def", "decode", "(", "decoder", ",", "data", ",", "length", ",", "frame_size", ",", "decode_fec", ",", "channels", "=", "2", ")", ":", "pcm_size", "=", "frame_size", "*", "channels", "*", "ctypes", ".", "sizeof", "(", "ctypes", ".", "c_int16", ")", "p...
Decode an Opus frame Unlike the `opus_decode` function , this function takes an additional parameter `channels`, which indicates the number of channels in the frame
[ "Decode", "an", "Opus", "frame" ]
python
train
34.736842
wummel/linkchecker
linkcheck/logger/blacklist.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/logger/blacklist.py#L54-L67
def log_url (self, url_data): """ Put invalid url in blacklist, delete valid url from blacklist. """ key = (url_data.parent_url, url_data.cache_url) key = repr(key) if key in self.blacklist: if url_data.valid: del self.blacklist[key] ...
[ "def", "log_url", "(", "self", ",", "url_data", ")", ":", "key", "=", "(", "url_data", ".", "parent_url", ",", "url_data", ".", "cache_url", ")", "key", "=", "repr", "(", "key", ")", "if", "key", "in", "self", ".", "blacklist", ":", "if", "url_data",...
Put invalid url in blacklist, delete valid url from blacklist.
[ "Put", "invalid", "url", "in", "blacklist", "delete", "valid", "url", "from", "blacklist", "." ]
python
train
31.714286
abourget/gevent-socketio
socketio/namespace.py
https://github.com/abourget/gevent-socketio/blob/1cdb1594a315326987a17ce0924ea448a82fab01/socketio/namespace.py#L411-L460
def emit(self, event, *args, **kwargs): """Use this to send a structured event, with a name and arguments, to the client. By default, it uses this namespace's endpoint. You can send messages on other endpoints with something like: ``self.socket['/other_endpoint'].emit()``. ...
[ "def", "emit", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "None", ")", "if", "kwargs", ":", "raise", "ValueError", "(", "\"emit() only supports positional...
Use this to send a structured event, with a name and arguments, to the client. By default, it uses this namespace's endpoint. You can send messages on other endpoints with something like: ``self.socket['/other_endpoint'].emit()``. However, it is possible that the ``'/other...
[ "Use", "this", "to", "send", "a", "structured", "event", "with", "a", "name", "and", "arguments", "to", "the", "client", "." ]
python
valid
45.44
google/google-visualization-python
gviz_api.py
https://github.com/google/google-visualization-python/blob/cbfb4d69ad2f4ca30dc55791629280aa3214c8e3/gviz_api.py#L913-L966
def _ToJSonObj(self, columns_order=None, order_by=()): """Returns an object suitable to be converted to JSON. Args: columns_order: Optional. A list of all column IDs in the order in which you want them created in the output table. If specified, all column IDs mus...
[ "def", "_ToJSonObj", "(", "self", ",", "columns_order", "=", "None", ",", "order_by", "=", "(", ")", ")", ":", "if", "columns_order", "is", "None", ":", "columns_order", "=", "[", "col", "[", "\"id\"", "]", "for", "col", "in", "self", ".", "__columns",...
Returns an object suitable to be converted to JSON. Args: columns_order: Optional. A list of all column IDs in the order in which you want them created in the output table. If specified, all column IDs must be present. order_by: Optional. Specifies the name of ...
[ "Returns", "an", "object", "suitable", "to", "be", "converted", "to", "JSON", "." ]
python
train
34.722222
connectordb/connectordb-python
connectordb/_stream.py
https://github.com/connectordb/connectordb-python/blob/2092b0cb30898139a247176bcf433d5a4abde7cb/connectordb/_stream.py#L58-L69
def create(self, schema="{}", **kwargs): """Creates a stream given an optional JSON schema encoded as a python dict. You can also add other properties of the stream, such as the icon, datatype or description. Create accepts both a string schema and a dict-encoded schema.""" if isinstance...
[ "def", "create", "(", "self", ",", "schema", "=", "\"{}\"", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "schema", ",", "basestring", ")", ":", "strschema", "=", "schema", "schema", "=", "json", ".", "loads", "(", "schema", ")", "else"...
Creates a stream given an optional JSON schema encoded as a python dict. You can also add other properties of the stream, such as the icon, datatype or description. Create accepts both a string schema and a dict-encoded schema.
[ "Creates", "a", "stream", "given", "an", "optional", "JSON", "schema", "encoded", "as", "a", "python", "dict", ".", "You", "can", "also", "add", "other", "properties", "of", "the", "stream", "such", "as", "the", "icon", "datatype", "or", "description", "."...
python
test
50.416667
jbfavre/python-protobix
protobix/datacontainer.py
https://github.com/jbfavre/python-protobix/blob/96b7095a9c2485c9e1bdba098b7d82b93f91acb1/protobix/datacontainer.py#L37-L58
def add_item(self, host, key, value, clock=None, state=0): """ Add a single item into DataContainer :host: hostname to which item will be linked to :key: item key as defined in Zabbix :value: item value :clock: timestemp as integer. If not provided self.clock()) will be ...
[ "def", "add_item", "(", "self", ",", "host", ",", "key", ",", "value", ",", "clock", "=", "None", ",", "state", "=", "0", ")", ":", "if", "clock", "is", "None", ":", "clock", "=", "self", ".", "clock", "if", "self", ".", "_config", ".", "data_typ...
Add a single item into DataContainer :host: hostname to which item will be linked to :key: item key as defined in Zabbix :value: item value :clock: timestemp as integer. If not provided self.clock()) will be used
[ "Add", "a", "single", "item", "into", "DataContainer" ]
python
train
43.272727
DataBiosphere/toil
src/toil/resource.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/resource.py#L104-L117
def prepareSystem(cls): """ Prepares this system for the downloading and lookup of resources. This method should only be invoked on a worker node. It is idempotent but not thread-safe. """ try: resourceRootDirPath = os.environ[cls.rootDirPathEnvName] except Ke...
[ "def", "prepareSystem", "(", "cls", ")", ":", "try", ":", "resourceRootDirPath", "=", "os", ".", "environ", "[", "cls", ".", "rootDirPathEnvName", "]", "except", "KeyError", ":", "# Create directory holding local copies of requested resources ...", "resourceRootDirPath", ...
Prepares this system for the downloading and lookup of resources. This method should only be invoked on a worker node. It is idempotent but not thread-safe.
[ "Prepares", "this", "system", "for", "the", "downloading", "and", "lookup", "of", "resources", ".", "This", "method", "should", "only", "be", "invoked", "on", "a", "worker", "node", ".", "It", "is", "idempotent", "but", "not", "thread", "-", "safe", "." ]
python
train
48.5
PmagPy/PmagPy
pmagpy/mapping/map_magic.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/mapping/map_magic.py#L168-L202
def get_thellier_gui_meas_mapping(input_df, output=2): """ Get the appropriate mapping for translating measurements in Thellier GUI. This requires special handling for treat_step_num/measurement/measurement_number. Parameters ---------- input_df : pandas DataFrame MagIC records outp...
[ "def", "get_thellier_gui_meas_mapping", "(", "input_df", ",", "output", "=", "2", ")", ":", "if", "int", "(", "output", ")", "==", "2", ":", "thellier_gui_meas3_2_meas2_map", "=", "meas_magic3_2_magic2_map", ".", "copy", "(", ")", "if", "'treat_step_num'", "in",...
Get the appropriate mapping for translating measurements in Thellier GUI. This requires special handling for treat_step_num/measurement/measurement_number. Parameters ---------- input_df : pandas DataFrame MagIC records output : int output to this MagIC data model (2 or 3) Outp...
[ "Get", "the", "appropriate", "mapping", "for", "translating", "measurements", "in", "Thellier", "GUI", ".", "This", "requires", "special", "handling", "for", "treat_step_num", "/", "measurement", "/", "measurement_number", "." ]
python
train
37.714286
jilljenn/tryalgo
tryalgo/graph01.py
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/graph01.py#L10-L43
def dist01(graph, weight, source=0, target=None): """Shortest path in a 0,1 weighted graph :param graph: directed graph in listlist or listdict format :param weight: matrix or adjacency dictionary :param int source: vertex :param target: exploration stops once distance to target is found :retur...
[ "def", "dist01", "(", "graph", ",", "weight", ",", "source", "=", "0", ",", "target", "=", "None", ")", ":", "n", "=", "len", "(", "graph", ")", "dist", "=", "[", "float", "(", "'inf'", ")", "]", "*", "n", "prec", "=", "[", "None", "]", "*", ...
Shortest path in a 0,1 weighted graph :param graph: directed graph in listlist or listdict format :param weight: matrix or adjacency dictionary :param int source: vertex :param target: exploration stops once distance to target is found :returns: distance table, predecessor table :complexity: `O...
[ "Shortest", "path", "in", "a", "0", "1", "weighted", "graph" ]
python
train
31.411765
jmcarp/robobrowser
robobrowser/browser.py
https://github.com/jmcarp/robobrowser/blob/4284c11d00ae1397983e269aa180e5cf7ee5f4cf/robobrowser/browser.py#L311-L323
def follow_link(self, link, **kwargs): """Click a link. :param Tag link: Link to click :param kwargs: Keyword arguments to `Session::send` """ try: href = link['href'] except KeyError: raise exceptions.RoboError('Link element must have "href" ' ...
[ "def", "follow_link", "(", "self", ",", "link", ",", "*", "*", "kwargs", ")", ":", "try", ":", "href", "=", "link", "[", "'href'", "]", "except", "KeyError", ":", "raise", "exceptions", ".", "RoboError", "(", "'Link element must have \"href\" '", "'attribute...
Click a link. :param Tag link: Link to click :param kwargs: Keyword arguments to `Session::send`
[ "Click", "a", "link", "." ]
python
train
31.461538
frictionlessdata/datapackage-py
datapackage/package.py
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L474-L480
def _validate_zip(the_zip): """Validate zipped data package """ datapackage_jsons = [f for f in the_zip.namelist() if f.endswith('datapackage.json')] if len(datapackage_jsons) != 1: msg = 'DataPackage must have only one "datapackage.json" (had {n})' raise exceptions.DataPackageException(...
[ "def", "_validate_zip", "(", "the_zip", ")", ":", "datapackage_jsons", "=", "[", "f", "for", "f", "in", "the_zip", ".", "namelist", "(", ")", "if", "f", ".", "endswith", "(", "'datapackage.json'", ")", "]", "if", "len", "(", "datapackage_jsons", ")", "!=...
Validate zipped data package
[ "Validate", "zipped", "data", "package" ]
python
valid
50.142857
Riminder/python-riminder-api
riminder/webhook.py
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L67-L71
def isHandlerPresent(self, event_name): """Check if an event has an handler.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) return self.handlers[event_name] is not None
[ "def", "isHandlerPresent", "(", "self", ",", "event_name", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "return", "self", ".", "h...
Check if an event has an handler.
[ "Check", "if", "an", "event", "has", "an", "handler", "." ]
python
train
51
secynic/ipwhois
ipwhois/net.py
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/net.py#L857-L936
def get_http_raw(self, url=None, retry_count=3, headers=None, request_type='GET', form_data=None): """ The function for retrieving a raw HTML result via HTTP. Args: url (:obj:`str`): The URL to retrieve (required). retry_count (:obj:`int`): The numbe...
[ "def", "get_http_raw", "(", "self", ",", "url", "=", "None", ",", "retry_count", "=", "3", ",", "headers", "=", "None", ",", "request_type", "=", "'GET'", ",", "form_data", "=", "None", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "{...
The function for retrieving a raw HTML result via HTTP. Args: url (:obj:`str`): The URL to retrieve (required). retry_count (:obj:`int`): The number of times to retry in case socket errors, timeouts, connection resets, etc. are encountered. Defaults to 3....
[ "The", "function", "for", "retrieving", "a", "raw", "HTML", "result", "via", "HTTP", "." ]
python
train
35.075
Alignak-monitoring/alignak
alignak/worker.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/worker.py#L386-L466
def do_work(self, actions_queue, returns_queue, control_queue=None): # pragma: no cover """Main function of the worker. * Get checks * Launch new checks * Manage finished checks :param actions_queue: Global Queue Master->Slave :type actions_queue: Queue.Queue :p...
[ "def", "do_work", "(", "self", ",", "actions_queue", ",", "returns_queue", ",", "control_queue", "=", "None", ")", ":", "# pragma: no cover", "# restore default signal handler for the workers:", "# signal.signal(signal.SIGTERM, signal.SIG_DFL)", "self", ".", "interrupted", "=...
Main function of the worker. * Get checks * Launch new checks * Manage finished checks :param actions_queue: Global Queue Master->Slave :type actions_queue: Queue.Queue :param returns_queue: queue managed by manager :type returns_queue: Queue.Queue :retur...
[ "Main", "function", "of", "the", "worker", ".", "*", "Get", "checks", "*", "Launch", "new", "checks", "*", "Manage", "finished", "checks" ]
python
train
42.432099
MycroftAI/mycroft-precise
precise/scripts/train_generated.py
https://github.com/MycroftAI/mycroft-precise/blob/e17cebdd171906dbd8a16e282d8a7966fba2eeba/precise/scripts/train_generated.py#L156-L165
def max_run_length(x: np.ndarray, val: int): """Finds the maximum continuous length of the given value in the sequence""" if x.size == 0: return 0 else: y = np.array(x[1:] != x[:-1]) i = np.append(np.where(y), len(x) - 1) run_lengths = np.diff(np.a...
[ "def", "max_run_length", "(", "x", ":", "np", ".", "ndarray", ",", "val", ":", "int", ")", ":", "if", "x", ".", "size", "==", "0", ":", "return", "0", "else", ":", "y", "=", "np", ".", "array", "(", "x", "[", "1", ":", "]", "!=", "x", "[", ...
Finds the maximum continuous length of the given value in the sequence
[ "Finds", "the", "maximum", "continuous", "length", "of", "the", "given", "value", "in", "the", "sequence" ]
python
train
46.2
flatangle/flatlib
flatlib/protocols/behavior.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/behavior.py#L28-L69
def compute(chart): """ Computes the behavior. """ factors = [] # Planets in House1 or Conjunct Asc house1 = chart.getHouse(const.HOUSE1) planetsHouse1 = chart.objects.getObjectsInHouse(house1) asc = chart.getAngle(const.ASC) planetsConjAsc = chart.objects.getObjectsAspecting(asc, ...
[ "def", "compute", "(", "chart", ")", ":", "factors", "=", "[", "]", "# Planets in House1 or Conjunct Asc", "house1", "=", "chart", ".", "getHouse", "(", "const", ".", "HOUSE1", ")", "planetsHouse1", "=", "chart", ".", "objects", ".", "getObjectsInHouse", "(", ...
Computes the behavior.
[ "Computes", "the", "behavior", "." ]
python
train
35.690476
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L777-L882
def get_bitcoin_virtual_transactions(blockchain_opts, first_block_height, last_block_height, tx_filter=None, spv_last_block=None, first_block_hash=None, **hints): """ Get the sequence of virtualchain transactions from the blockchain. Each transaction returned will be a `nulldata` transaction (i.e. the first...
[ "def", "get_bitcoin_virtual_transactions", "(", "blockchain_opts", ",", "first_block_height", ",", "last_block_height", ",", "tx_filter", "=", "None", ",", "spv_last_block", "=", "None", ",", "first_block_hash", "=", "None", ",", "*", "*", "hints", ")", ":", "head...
Get the sequence of virtualchain transactions from the blockchain. Each transaction returned will be a `nulldata` transaction (i.e. the first output script starts with OP_RETURN). * output values will be in satoshis * `fee` will be defined, and will be the total amount sent (in satoshis) * `txindex` wil...
[ "Get", "the", "sequence", "of", "virtualchain", "transactions", "from", "the", "blockchain", ".", "Each", "transaction", "returned", "will", "be", "a", "nulldata", "transaction", "(", "i", ".", "e", ".", "the", "first", "output", "script", "starts", "with", ...
python
train
41.367925
spyder-ide/spyder
spyder/plugins/plots/widgets/figurebrowser.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/plots/widgets/figurebrowser.py#L388-L392
def load_figure(self, fig, fmt): """Set a new figure in the figure canvas.""" self.figcanvas.load_figure(fig, fmt) self.scale_image() self.figcanvas.repaint()
[ "def", "load_figure", "(", "self", ",", "fig", ",", "fmt", ")", ":", "self", ".", "figcanvas", ".", "load_figure", "(", "fig", ",", "fmt", ")", "self", ".", "scale_image", "(", ")", "self", ".", "figcanvas", ".", "repaint", "(", ")" ]
Set a new figure in the figure canvas.
[ "Set", "a", "new", "figure", "in", "the", "figure", "canvas", "." ]
python
train
37.2
saltstack/salt
salt/cloud/clouds/opennebula.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L4242-L4298
def vn_info(call=None, kwargs=None): ''' Retrieves information for the virtual network. .. versionadded:: 2016.3.0 name The name of the virtual network for which to gather information. Can be used instead of ``vn_id``. vn_id The ID of the virtual network for which to gathe...
[ "def", "vn_info", "(", "call", "=", "None", ",", "kwargs", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The vn_info function must be called with -f or --function.'", ")", "if", "kwargs", "is", "None", ":", ...
Retrieves information for the virtual network. .. versionadded:: 2016.3.0 name The name of the virtual network for which to gather information. Can be used instead of ``vn_id``. vn_id The ID of the virtual network for which to gather information. Can be used instead of ``n...
[ "Retrieves", "information", "for", "the", "virtual", "network", "." ]
python
train
26.403509
RI-imaging/ODTbrain
odtbrain/_alg3d_bpp.py
https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_alg3d_bpp.py#L26-L32
def _init_worker(X, X_shape, X_dtype): """Initializer for pool for _mprotate""" # Using a dictionary is not strictly necessary. You can also # use global variables. mprotate_dict["X"] = X mprotate_dict["X_shape"] = X_shape mprotate_dict["X_dtype"] = X_dtype
[ "def", "_init_worker", "(", "X", ",", "X_shape", ",", "X_dtype", ")", ":", "# Using a dictionary is not strictly necessary. You can also", "# use global variables.", "mprotate_dict", "[", "\"X\"", "]", "=", "X", "mprotate_dict", "[", "\"X_shape\"", "]", "=", "X_shape", ...
Initializer for pool for _mprotate
[ "Initializer", "for", "pool", "for", "_mprotate" ]
python
train
39.285714
Scout24/yamlreader
src/main/python/yamlreader/yamlreader.py
https://github.com/Scout24/yamlreader/blob/31b1adc8391447f7eca56755cb467e3cf34da631/src/main/python/yamlreader/yamlreader.py#L24-L59
def data_merge(a, b): """merges b into a and return merged result based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge and extended to also merge arrays and to replace the content of keys with the same name NOTE: tuples and arbitrary objects are not handled as i...
[ "def", "data_merge", "(", "a", ",", "b", ")", ":", "key", "=", "None", "# ## debug output", "# sys.stderr.write(\"DEBUG: %s to %s\\n\" %(b,a))", "try", ":", "if", "a", "is", "None", "or", "isinstance", "(", "a", ",", "(", "six", ".", "string_types", ",", "fl...
merges b into a and return merged result based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge and extended to also merge arrays and to replace the content of keys with the same name NOTE: tuples and arbitrary objects are not handled as it is totally ambiguous what s...
[ "merges", "b", "into", "a", "and", "return", "merged", "result", "based", "on", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "7204805", "/", "python", "-", "dictionaries", "-", "of", "-", "dictionaries", "-", "merge", "and", "ex...
python
train
41.111111
Yelp/detect-secrets
detect_secrets/core/code_snippet.py
https://github.com/Yelp/detect-secrets/blob/473923ea71f1ac2b5ea1eacc49b98f97967e3d05/detect_secrets/core/code_snippet.py#L45-L50
def _get_lines_in_file(self, filename): """ :rtype: list """ with codecs.open(filename, encoding='utf-8') as file: return file.read().splitlines()
[ "def", "_get_lines_in_file", "(", "self", ",", "filename", ")", ":", "with", "codecs", ".", "open", "(", "filename", ",", "encoding", "=", "'utf-8'", ")", "as", "file", ":", "return", "file", ".", "read", "(", ")", ".", "splitlines", "(", ")" ]
:rtype: list
[ ":", "rtype", ":", "list" ]
python
train
30.833333
wbond/oscrypto
oscrypto/_osx/asymmetric.py
https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_osx/asymmetric.py#L574-L595
def _load_x509(certificate): """ Loads an ASN.1 object of an x509 certificate into a Certificate object :param certificate: An asn1crypto.x509.Certificate object :return: A Certificate object """ source = certificate.dump() cf_source = None try: cf_source = CF...
[ "def", "_load_x509", "(", "certificate", ")", ":", "source", "=", "certificate", ".", "dump", "(", ")", "cf_source", "=", "None", "try", ":", "cf_source", "=", "CFHelpers", ".", "cf_data_from_bytes", "(", "source", ")", "sec_key_ref", "=", "Security", ".", ...
Loads an ASN.1 object of an x509 certificate into a Certificate object :param certificate: An asn1crypto.x509.Certificate object :return: A Certificate object
[ "Loads", "an", "ASN", ".", "1", "object", "of", "an", "x509", "certificate", "into", "a", "Certificate", "object" ]
python
valid
26.227273
pycontribs/pyrax
pyrax/clouddatabases.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L700-L702
def list_databases(self, instance, limit=None, marker=None): """Returns all databases for the specified instance.""" return instance.list_databases(limit=limit, marker=marker)
[ "def", "list_databases", "(", "self", ",", "instance", ",", "limit", "=", "None", ",", "marker", "=", "None", ")", ":", "return", "instance", ".", "list_databases", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ")" ]
Returns all databases for the specified instance.
[ "Returns", "all", "databases", "for", "the", "specified", "instance", "." ]
python
train
63
google/openhtf
openhtf/util/threads.py
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/threads.py#L101-L118
def loop(_=None, force=False): # pylint: disable=invalid-name """Causes a function to loop indefinitely.""" if not force: raise AttributeError( 'threads.loop() is DEPRECATED. If you really like this and want to ' 'keep it, file an issue at https://github.com/google/openhtf/issues ' 'a...
[ "def", "loop", "(", "_", "=", "None", ",", "force", "=", "False", ")", ":", "# pylint: disable=invalid-name", "if", "not", "force", ":", "raise", "AttributeError", "(", "'threads.loop() is DEPRECATED. If you really like this and want to '", "'keep it, file an issue at http...
Causes a function to loop indefinitely.
[ "Causes", "a", "function", "to", "loop", "indefinitely", "." ]
python
train
37.888889
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/processing_controller/scheduler/scheduler.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/processing_controller/scheduler/scheduler.py#L66-L97
def _monitor_events(self): """Watch for Processing Block events.""" LOG.info("Starting to monitor PB events") check_counter = 0 while True: if check_counter == 50: check_counter = 0 LOG.debug('Checking for PB events...') published_...
[ "def", "_monitor_events", "(", "self", ")", ":", "LOG", ".", "info", "(", "\"Starting to monitor PB events\"", ")", "check_counter", "=", "0", "while", "True", ":", "if", "check_counter", "==", "50", ":", "check_counter", "=", "0", "LOG", ".", "debug", "(", ...
Watch for Processing Block events.
[ "Watch", "for", "Processing", "Block", "events", "." ]
python
train
44.3125
Calysto/calysto
calysto/ai/conx.py
https://github.com/Calysto/calysto/blob/20813c0f48096317aa775d03a5c6b20f12fafc93/calysto/ai/conx.py#L911-L919
def getLayerIndex(self, layer): """ Given a reference to a layer, returns the index of that layer in self.layers. """ for i in range(len(self.layers)): if layer == self.layers[i]: # shallow cmp return i return -1 # not in list
[ "def", "getLayerIndex", "(", "self", ",", "layer", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "layers", ")", ")", ":", "if", "layer", "==", "self", ".", "layers", "[", "i", "]", ":", "# shallow cmp", "return", "i", "return",...
Given a reference to a layer, returns the index of that layer in self.layers.
[ "Given", "a", "reference", "to", "a", "layer", "returns", "the", "index", "of", "that", "layer", "in", "self", ".", "layers", "." ]
python
train
34.222222
CalebBell/thermo
thermo/vapor_pressure.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/vapor_pressure.py#L186-L237
def Wagner_original(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the Wagner equation (3, 6 form). Requires critical temperature and pressure as well as four coefficients specific to each chemical. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6} ...
[ "def", "Wagner_original", "(", "T", ",", "Tc", ",", "Pc", ",", "a", ",", "b", ",", "c", ",", "d", ")", ":", "Tr", "=", "T", "/", "Tc", "tau", "=", "1.0", "-", "Tr", "return", "Pc", "*", "exp", "(", "(", "a", "*", "tau", "+", "b", "*", "...
r'''Calculates vapor pressure using the Wagner equation (3, 6 form). Requires critical temperature and pressure as well as four coefficients specific to each chemical. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6} {T_r} \tau = 1 - \frac{T...
[ "r", "Calculates", "vapor", "pressure", "using", "the", "Wagner", "equation", "(", "3", "6", "form", ")", "." ]
python
valid
28.480769
haifengat/hf_ctp_py_proxy
py_ctp/trade.py
https://github.com/haifengat/hf_ctp_py_proxy/blob/c2dc6dbde45aa6b097f75380474e91510d3f5d12/py_ctp/trade.py#L454-L513
def ReqOrderInsert(self, pInstrument: str, pDirection: DirectType, pOffset: OffsetType, pPrice: float = 0.0, pVolume: int = 1, pType: OrderType = OrderType.Limit, pCustom: int = 0): """委托 :param pInstrument: :param pDirection: :param pOffset: :param pPrice: :param pVolum...
[ "def", "ReqOrderInsert", "(", "self", ",", "pInstrument", ":", "str", ",", "pDirection", ":", "DirectType", ",", "pOffset", ":", "OffsetType", ",", "pPrice", ":", "float", "=", "0.0", ",", "pVolume", ":", "int", "=", "1", ",", "pType", ":", "OrderType", ...
委托 :param pInstrument: :param pDirection: :param pOffset: :param pPrice: :param pVolume: :param pType: :param pCustom: :return:
[ "委托" ]
python
train
51.883333
pywbem/pywbem
pywbem/mof_compiler.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/mof_compiler.py#L1200-L1258
def _fixStringValue(s, p): """Clean up string value including special characters, etc.""" # pylint: disable=too-many-branches s = s[1:-1] rv = '' esc = False i = -1 while i < len(s) - 1: i += 1 ch = s[i] if ch == '\\' and not esc: esc = True c...
[ "def", "_fixStringValue", "(", "s", ",", "p", ")", ":", "# pylint: disable=too-many-branches", "s", "=", "s", "[", "1", ":", "-", "1", "]", "rv", "=", "''", "esc", "=", "False", "i", "=", "-", "1", "while", "i", "<", "len", "(", "s", ")", "-", ...
Clean up string value including special characters, etc.
[ "Clean", "up", "string", "value", "including", "special", "characters", "etc", "." ]
python
train
25.440678
joferkington/mplstereonet
mplstereonet/stereonet_math.py
https://github.com/joferkington/mplstereonet/blob/f6d78ca49807915d4223e864e12bb24d497cc2d6/mplstereonet/stereonet_math.py#L356-L380
def mean_vector(lons, lats): """ Returns the resultant vector from a series of longitudes and latitudes Parameters ---------- lons : array-like A sequence of longitudes (in radians) lats : array-like A sequence of latitudes (in radians) Returns ------- mean_vec : tu...
[ "def", "mean_vector", "(", "lons", ",", "lats", ")", ":", "xyz", "=", "sph2cart", "(", "lons", ",", "lats", ")", "xyz", "=", "np", ".", "vstack", "(", "xyz", ")", ".", "T", "mean_vec", "=", "xyz", ".", "mean", "(", "axis", "=", "0", ")", "r_val...
Returns the resultant vector from a series of longitudes and latitudes Parameters ---------- lons : array-like A sequence of longitudes (in radians) lats : array-like A sequence of latitudes (in radians) Returns ------- mean_vec : tuple (lon, lat) in radians r_v...
[ "Returns", "the", "resultant", "vector", "from", "a", "series", "of", "longitudes", "and", "latitudes" ]
python
train
27.08
DLR-RM/RAFCON
source/rafcon/gui/models/selection.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/selection.py#L66-L99
def updates_selection(update_selection): """ Decorator indicating that the decorated method could change the selection""" def handle_update(selection, *args, **kwargs): """Check for changes in the selection If the selection is changed by the decorated method, the internal core element lists are...
[ "def", "updates_selection", "(", "update_selection", ")", ":", "def", "handle_update", "(", "selection", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Check for changes in the selection\n\n If the selection is changed by the decorated method, the internal c...
Decorator indicating that the decorated method could change the selection
[ "Decorator", "indicating", "that", "the", "decorated", "method", "could", "change", "the", "selection" ]
python
train
51
FactoryBoy/factory_boy
factory/declarations.py
https://github.com/FactoryBoy/factory_boy/blob/edaa7c7f5a14065b229927903bd7989cc93cd069/factory/declarations.py#L255-L272
def evaluate(self, instance, step, extra): """Evaluate the current ContainerAttribute. Args: obj (LazyStub): a lazy stub of the object being constructed, if needed. containers (list of LazyStub): a list of lazy stubs of factories being evaluated i...
[ "def", "evaluate", "(", "self", ",", "instance", ",", "step", ",", "extra", ")", ":", "# Strip the current instance from the chain", "chain", "=", "step", ".", "chain", "[", "1", ":", "]", "if", "self", ".", "strict", "and", "not", "chain", ":", "raise", ...
Evaluate the current ContainerAttribute. Args: obj (LazyStub): a lazy stub of the object being constructed, if needed. containers (list of LazyStub): a list of lazy stubs of factories being evaluated in a chain, each item being a future field of ...
[ "Evaluate", "the", "current", "ContainerAttribute", "." ]
python
train
38.666667
iLampard/x-utils
xutils/misc.py
https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/misc.py#L8-L22
def valid_dict(d, keys=None): """ 检查是否字典中含有值为None的键(给定键的名称则检查给定的键,如果没有,则检查全部键) - 如果没有值为None的键,则返回True,反之False - 如果keys中的键不存在于d中,也返回False """ if keys is None: d_ = d else: d_ = itemfilter(lambda item: item[0] in keys, d) if len(d_) != len(keys): return Fal...
[ "def", "valid_dict", "(", "d", ",", "keys", "=", "None", ")", ":", "if", "keys", "is", "None", ":", "d_", "=", "d", "else", ":", "d_", "=", "itemfilter", "(", "lambda", "item", ":", "item", "[", "0", "]", "in", "keys", ",", "d", ")", "if", "l...
检查是否字典中含有值为None的键(给定键的名称则检查给定的键,如果没有,则检查全部键) - 如果没有值为None的键,则返回True,反之False - 如果keys中的键不存在于d中,也返回False
[ "检查是否字典中含有值为None的键", "(", "给定键的名称则检查给定的键,如果没有,则检查全部键", ")", "-", "如果没有值为None的键,则返回True,反之False", "-", "如果keys中的键不存在于d中,也返回False" ]
python
train
25.8
hph/mov
mov.py
https://github.com/hph/mov/blob/36a18d92836e1aff74ca02e16ce09d1c46e111b9/mov.py#L111-L118
def destroy(): """Destroy a database.""" if not os.path.exists(ARGS.database): exit('Error: The database does not exist; you must create it first.') if ARGS.force: os.remove(ARGS.database) elif raw_input('Destroy {0} [y/n]? '.format(ARGS.database)) in ('y', 'Y'): os.remove(ARGS.d...
[ "def", "destroy", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "ARGS", ".", "database", ")", ":", "exit", "(", "'Error: The database does not exist; you must create it first.'", ")", "if", "ARGS", ".", "force", ":", "os", ".", "remove",...
Destroy a database.
[ "Destroy", "a", "database", "." ]
python
train
40.125
michaelaye/pyciss
pyciss/ringcube.py
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/ringcube.py#L59-L71
def mad(arr, relative=True): """ Median Absolute Deviation: a "Robust" version of standard deviation. Indices variabililty of the sample. https://en.wikipedia.org/wiki/Median_absolute_deviation """ with warnings.catch_warnings(): warnings.simplefilter("ignore") med = np.nanme...
[ "def", "mad", "(", "arr", ",", "relative", "=", "True", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"ignore\"", ")", "med", "=", "np", ".", "nanmedian", "(", "arr", ",", "axis", "=", "1"...
Median Absolute Deviation: a "Robust" version of standard deviation. Indices variabililty of the sample. https://en.wikipedia.org/wiki/Median_absolute_deviation
[ "Median", "Absolute", "Deviation", ":", "a", "Robust", "version", "of", "standard", "deviation", ".", "Indices", "variabililty", "of", "the", "sample", ".", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Median_absolute_deviation" ]
python
train
37
square/pylink
pylink/jlink.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L2897-L2912
def memory_write16(self, addr, data, zone=None): """Writes half-words to memory of a target system. Args: self (JLink): the ``JLink`` instance addr (int): start address to write to data (list): list of half-words to write zone (str): optional memory zone to acces...
[ "def", "memory_write16", "(", "self", ",", "addr", ",", "data", ",", "zone", "=", "None", ")", ":", "return", "self", ".", "memory_write", "(", "addr", ",", "data", ",", "zone", ",", "16", ")" ]
Writes half-words to memory of a target system. Args: self (JLink): the ``JLink`` instance addr (int): start address to write to data (list): list of half-words to write zone (str): optional memory zone to access Returns: Number of half-words written t...
[ "Writes", "half", "-", "words", "to", "memory", "of", "a", "target", "system", "." ]
python
train
31.75
aiogram/aiogram
aiogram/types/message.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/message.py#L583-L602
async def answer_media_group(self, media: typing.Union[MediaGroup, typing.List], disable_notification: typing.Union[base.Boolean, None] = None, reply=False) -> typing.List[Message]: """ Use this method to send a group of photos or videos ...
[ "async", "def", "answer_media_group", "(", "self", ",", "media", ":", "typing", ".", "Union", "[", "MediaGroup", ",", "typing", ".", "List", "]", ",", "disable_notification", ":", "typing", ".", "Union", "[", "base", ".", "Boolean", ",", "None", "]", "="...
Use this method to send a group of photos or videos as an album. Source: https://core.telegram.org/bots/api#sendmediagroup :param media: A JSON-serialized array describing photos and videos to be sent :type media: :obj:`typing.Union[types.MediaGroup, typing.List]` :param disable_notifi...
[ "Use", "this", "method", "to", "send", "a", "group", "of", "photos", "or", "videos", "as", "an", "album", "." ]
python
train
60.95
saltstack/salt
salt/utils/jinja.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/jinja.py#L313-L329
def tojson(val, indent=None): ''' Implementation of tojson filter (only present in Jinja 2.9 and later). If Jinja 2.9 or later is installed, then the upstream version of this filter will be used. ''' options = {'ensure_ascii': True} if indent is not None: options['indent'] = indent ...
[ "def", "tojson", "(", "val", ",", "indent", "=", "None", ")", ":", "options", "=", "{", "'ensure_ascii'", ":", "True", "}", "if", "indent", "is", "not", "None", ":", "options", "[", "'indent'", "]", "=", "indent", "return", "(", "salt", ".", "utils",...
Implementation of tojson filter (only present in Jinja 2.9 and later). If Jinja 2.9 or later is installed, then the upstream version of this filter will be used.
[ "Implementation", "of", "tojson", "filter", "(", "only", "present", "in", "Jinja", "2", ".", "9", "and", "later", ")", ".", "If", "Jinja", "2", ".", "9", "or", "later", "is", "installed", "then", "the", "upstream", "version", "of", "this", "filter", "w...
python
train
30.294118
peerplays-network/python-peerplays
peerplays/cli/account.py
https://github.com/peerplays-network/python-peerplays/blob/188f04238e7e21d5f73e9b01099eea44289ef6b7/peerplays/cli/account.py#L129-L138
def balance(ctx, accounts): """ Show Account balances """ t = PrettyTable(["Account", "Amount"]) t.align = "r" for a in accounts: account = Account(a, peerplays_instance=ctx.peerplays) for b in account.balances: t.add_row([str(a), str(b)]) click.echo(str(t))
[ "def", "balance", "(", "ctx", ",", "accounts", ")", ":", "t", "=", "PrettyTable", "(", "[", "\"Account\"", ",", "\"Amount\"", "]", ")", "t", ".", "align", "=", "\"r\"", "for", "a", "in", "accounts", ":", "account", "=", "Account", "(", "a", ",", "p...
Show Account balances
[ "Show", "Account", "balances" ]
python
train
30.1
saltstack/salt
salt/modules/azurearm_network.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L1600-L1631
def network_interfaces_list(resource_group, **kwargs): ''' .. versionadded:: 2019.2.0 List all network interfaces within a resource group. :param resource_group: The resource group name to list network interfaces within. CLI Example: .. code-block:: bash salt-call azurearm_n...
[ "def", "network_interfaces_list", "(", "resource_group", ",", "*", "*", "kwargs", ")", ":", "result", "=", "{", "}", "netconn", "=", "__utils__", "[", "'azurearm.get_client'", "]", "(", "'network'", ",", "*", "*", "kwargs", ")", "try", ":", "nics", "=", ...
.. versionadded:: 2019.2.0 List all network interfaces within a resource group. :param resource_group: The resource group name to list network interfaces within. CLI Example: .. code-block:: bash salt-call azurearm_network.network_interfaces_list testgroup
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
python
train
26.15625
cs01/pygdbmi
pygdbmi/gdbmiparser.py
https://github.com/cs01/pygdbmi/blob/709c781794d3c3b903891f83da011d2d995895d1/pygdbmi/gdbmiparser.py#L40-L102
def parse_response(gdb_mi_text): """Parse gdb mi text and turn it into a dictionary. See https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Stream-Records.html#GDB_002fMI-Stream-Records for details on types of gdb mi output. Args: gdb_mi_text (str): String output from gdb Returns: ...
[ "def", "parse_response", "(", "gdb_mi_text", ")", ":", "stream", "=", "StringStream", "(", "gdb_mi_text", ",", "debug", "=", "_DEBUG", ")", "if", "_GDB_MI_NOTIFY_RE", ".", "match", "(", "gdb_mi_text", ")", ":", "token", ",", "message", ",", "payload", "=", ...
Parse gdb mi text and turn it into a dictionary. See https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Stream-Records.html#GDB_002fMI-Stream-Records for details on types of gdb mi output. Args: gdb_mi_text (str): String output from gdb Returns: dict with the following keys: ...
[ "Parse", "gdb", "mi", "text", "and", "turn", "it", "into", "a", "dictionary", "." ]
python
valid
31.984127
cytoscape/py2cytoscape
py2cytoscape/cyrest/styles.py
https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/styles.py#L62-L76
def createStyle(self, body, verbose=None): """ Creates a new Visual Style using the message body. Returns the title of the new Visual Style. If the title of the Visual Style already existed in the session, a new one will be automatically generated and returned. :param body: The...
[ "def", "createStyle", "(", "self", ",", "body", ",", "verbose", "=", "None", ")", ":", "PARAMS", "=", "set_param", "(", "[", "'body'", "]", ",", "[", "body", "]", ")", "response", "=", "api", "(", "url", "=", "self", ".", "___url", "+", "'styles'",...
Creates a new Visual Style using the message body. Returns the title of the new Visual Style. If the title of the Visual Style already existed in the session, a new one will be automatically generated and returned. :param body: The details of the new Visual Style to be created. :param ...
[ "Creates", "a", "new", "Visual", "Style", "using", "the", "message", "body", ".", "Returns", "the", "title", "of", "the", "new", "Visual", "Style", ".", "If", "the", "title", "of", "the", "Visual", "Style", "already", "existed", "in", "the", "session", "...
python
train
40.4
ray-project/ray
python/ray/worker.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L830-L921
def _process_task(self, task, function_execution_info): """Execute a task assigned to this worker. This method deserializes a task from the scheduler, and attempts to execute the task. If the task succeeds, the outputs are stored in the local object store. If the task throws an exceptio...
[ "def", "_process_task", "(", "self", ",", "task", ",", "function_execution_info", ")", ":", "assert", "self", ".", "current_task_id", ".", "is_nil", "(", ")", "assert", "self", ".", "task_context", ".", "task_index", "==", "0", "assert", "self", ".", "task_c...
Execute a task assigned to this worker. This method deserializes a task from the scheduler, and attempts to execute the task. If the task succeeds, the outputs are stored in the local object store. If the task throws an exception, RayTaskError objects are stored in the object store to r...
[ "Execute", "a", "task", "assigned", "to", "this", "worker", "." ]
python
train
47.532609
openstack/networking-cisco
networking_cisco/db/migration/alembic_migrations/env.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/db/migration/alembic_migrations/env.py#L96-L119
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ set_mysql_engine() engine = session.create_engine(neutron_config.database.connection) connection = engine.connect() context.co...
[ "def", "run_migrations_online", "(", ")", ":", "set_mysql_engine", "(", ")", "engine", "=", "session", ".", "create_engine", "(", "neutron_config", ".", "database", ".", "connection", ")", "connection", "=", "engine", ".", "connect", "(", ")", "context", ".", ...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "online", "mode", "." ]
python
train
26.291667
tensorflow/tensor2tensor
tensor2tensor/bin/t2t_datagen.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/bin/t2t_datagen.py#L260-L275
def generate_data_for_env_problem(problem_name): """Generate data for `EnvProblem`s.""" assert FLAGS.env_problem_max_env_steps > 0, ("--env_problem_max_env_steps " "should be greater than zero") assert FLAGS.env_problem_batch_size > 0, ("--env_problem_batch_size shou...
[ "def", "generate_data_for_env_problem", "(", "problem_name", ")", ":", "assert", "FLAGS", ".", "env_problem_max_env_steps", ">", "0", ",", "(", "\"--env_problem_max_env_steps \"", "\"should be greater than zero\"", ")", "assert", "FLAGS", ".", "env_problem_batch_size", ">",...
Generate data for `EnvProblem`s.
[ "Generate", "data", "for", "EnvProblem", "s", "." ]
python
train
60.125
peri-source/peri
peri/interpolation.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/interpolation.py#L113-L128
def _eval_firstorder(self, rvecs, data, sigma): """The first-order Barnes approximation""" if not self.blocksize: dist_between_points = self._distance_matrix(rvecs, self.x) gaussian_weights = self._weight(dist_between_points, sigma=sigma) return gaussian_weights.dot(d...
[ "def", "_eval_firstorder", "(", "self", ",", "rvecs", ",", "data", ",", "sigma", ")", ":", "if", "not", "self", ".", "blocksize", ":", "dist_between_points", "=", "self", ".", "_distance_matrix", "(", "rvecs", ",", "self", ".", "x", ")", "gaussian_weights"...
The first-order Barnes approximation
[ "The", "first", "-", "order", "Barnes", "approximation" ]
python
valid
52.125
ixc/python-edtf
edtf/convert.py
https://github.com/ixc/python-edtf/blob/ec2124d3df75f8dd72571026380ce8dd16f3dd6b/edtf/convert.py#L66-L79
def struct_time_to_jd(st): """ Return a float number representing the Julian Date for the given `struct_time`. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` are ignored. """ year, month, day = st[:3] hours, minutes, seconds = st[3:6] # Convert time of day to fraction of day ...
[ "def", "struct_time_to_jd", "(", "st", ")", ":", "year", ",", "month", ",", "day", "=", "st", "[", ":", "3", "]", "hours", ",", "minutes", ",", "seconds", "=", "st", "[", "3", ":", "6", "]", "# Convert time of day to fraction of day", "day", "+=", "jdu...
Return a float number representing the Julian Date for the given `struct_time`. NOTE: extra fields `tm_wday`, `tm_yday`, and `tm_isdst` are ignored.
[ "Return", "a", "float", "number", "representing", "the", "Julian", "Date", "for", "the", "given", "struct_time", "." ]
python
train
29.214286
dcwatson/drill
drill.py
https://github.com/dcwatson/drill/blob/b8a30ec0fd5b5bf55154bd44c1c75f5f5945691b/drill.py#L548-L576
def parse(url_or_path, encoding=None, handler_class=DrillHandler): """ :param url_or_path: A file-like object, a filesystem path, a URL, or a string containing XML :rtype: :class:`XmlElement` """ handler = handler_class() parser = expat.ParserCreate(encoding) parser.buffer_text = 1 parse...
[ "def", "parse", "(", "url_or_path", ",", "encoding", "=", "None", ",", "handler_class", "=", "DrillHandler", ")", ":", "handler", "=", "handler_class", "(", ")", "parser", "=", "expat", ".", "ParserCreate", "(", "encoding", ")", "parser", ".", "buffer_text",...
:param url_or_path: A file-like object, a filesystem path, a URL, or a string containing XML :rtype: :class:`XmlElement`
[ ":", "param", "url_or_path", ":", "A", "file", "-", "like", "object", "a", "filesystem", "path", "a", "URL", "or", "a", "string", "containing", "XML", ":", "rtype", ":", ":", "class", ":", "XmlElement" ]
python
valid
40.724138
networks-lab/metaknowledge
metaknowledge/scopus/recordScopus.py
https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/scopus/recordScopus.py#L107-L164
def createCitation(self, multiCite = False): """Overwriting the general [citation creator](./ExtendedRecord.html#metaknowledge.ExtendedRecord.createCitation) to deal with scopus weirdness. Creates a citation string, using the same format as other WOS citations, for the [Record](./Record.html#metaknowle...
[ "def", "createCitation", "(", "self", ",", "multiCite", "=", "False", ")", ":", "#Need to put the import here to avoid circular import issues", "from", ".", ".", "citation", "import", "Citation", "valsStr", "=", "''", "if", "multiCite", ":", "auths", "=", "[", "]"...
Overwriting the general [citation creator](./ExtendedRecord.html#metaknowledge.ExtendedRecord.createCitation) to deal with scopus weirdness. Creates a citation string, using the same format as other WOS citations, for the [Record](./Record.html#metaknowledge.Record) by reading the relevant special tags (`'year...
[ "Overwriting", "the", "general", "[", "citation", "creator", "]", "(", ".", "/", "ExtendedRecord", ".", "html#metaknowledge", ".", "ExtendedRecord", ".", "createCitation", ")", "to", "deal", "with", "scopus", "weirdness", "." ]
python
train
44.465517
ryanpetrello/sdb
sdb.py
https://github.com/ryanpetrello/sdb/blob/4a198757a17e753ac88081d192ecc952b4228a36/sdb.py#L65-L75
def global_matches(self, text): """Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace that match. """ matches = [] n = len(text) for word in self.namespace: if wor...
[ "def", "global_matches", "(", "self", ",", "text", ")", ":", "matches", "=", "[", "]", "n", "=", "len", "(", "text", ")", "for", "word", "in", "self", ".", "namespace", ":", "if", "word", "[", ":", "n", "]", "==", "text", "and", "word", "!=", "...
Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace that match.
[ "Compute", "matches", "when", "text", "is", "a", "simple", "name", ".", "Return", "a", "list", "of", "all", "keywords", "built", "-", "in", "functions", "and", "names", "currently", "defined", "in", "self", ".", "namespace", "that", "match", "." ]
python
train
37.363636
softlayer/softlayer-python
SoftLayer/CLI/formatting.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/formatting.py#L413-L425
def _format_list(result): """Format list responses into a table.""" if not result: return result if isinstance(result[0], dict): return _format_list_objects(result) table = Table(['value']) for item in result: table.add_row([iter_to_table(item)]) return table
[ "def", "_format_list", "(", "result", ")", ":", "if", "not", "result", ":", "return", "result", "if", "isinstance", "(", "result", "[", "0", "]", ",", "dict", ")", ":", "return", "_format_list_objects", "(", "result", ")", "table", "=", "Table", "(", "...
Format list responses into a table.
[ "Format", "list", "responses", "into", "a", "table", "." ]
python
train
22.923077
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L6056-L6061
def Show(self, waitTime: float = OPERATION_WAIT_TIME) -> bool: """ Call native `ShowWindow(SW.Show)`. Return bool, True if succeed otherwise False. """ return self.ShowWindow(SW.Show, waitTime)
[ "def", "Show", "(", "self", ",", "waitTime", ":", "float", "=", "OPERATION_WAIT_TIME", ")", "->", "bool", ":", "return", "self", ".", "ShowWindow", "(", "SW", ".", "Show", ",", "waitTime", ")" ]
Call native `ShowWindow(SW.Show)`. Return bool, True if succeed otherwise False.
[ "Call", "native", "ShowWindow", "(", "SW", ".", "Show", ")", ".", "Return", "bool", "True", "if", "succeed", "otherwise", "False", "." ]
python
valid
38
juju/charm-helpers
charmhelpers/core/host.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L143-L173
def service_reload(service_name, restart_on_failure=False, **kwargs): """Reload a system service, optionally falling back to restart if reload fails. The specified service name is managed via the system level init system. Some init systems (e.g. upstart) require that additional arguments be provide...
[ "def", "service_reload", "(", "service_name", ",", "restart_on_failure", "=", "False", ",", "*", "*", "kwargs", ")", ":", "service_result", "=", "service", "(", "'reload'", ",", "service_name", ",", "*", "*", "kwargs", ")", "if", "not", "service_result", "an...
Reload a system service, optionally falling back to restart if reload fails. The specified service name is managed via the system level init system. Some init systems (e.g. upstart) require that additional arguments be provided in order to directly control service instances whereas other init syste...
[ "Reload", "a", "system", "service", "optionally", "falling", "back", "to", "restart", "if", "reload", "fails", "." ]
python
train
52.741935
xtuml/pyxtuml
examples/print_packageable_elements.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/examples/print_packageable_elements.py#L54-L59
def accept_EP_PKG(self, inst): ''' A Package contains packageable elements ''' for child in many(inst).PE_PE[8000](): self.accept(child)
[ "def", "accept_EP_PKG", "(", "self", ",", "inst", ")", ":", "for", "child", "in", "many", "(", "inst", ")", ".", "PE_PE", "[", "8000", "]", "(", ")", ":", "self", ".", "accept", "(", "child", ")" ]
A Package contains packageable elements
[ "A", "Package", "contains", "packageable", "elements" ]
python
test
29.166667
pypa/pipenv
pipenv/vendor/tomlkit/parser.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/tomlkit/parser.py#L469-L542
def _parse_value(self): # type: () -> Item """ Attempts to parse a value at the current position. """ self.mark() c = self._current trivia = Trivia() if c == StringType.SLB.value: return self._parse_basic_string() elif c == StringType.SLL.val...
[ "def", "_parse_value", "(", "self", ")", ":", "# type: () -> Item", "self", ".", "mark", "(", ")", "c", "=", "self", ".", "_current", "trivia", "=", "Trivia", "(", ")", "if", "c", "==", "StringType", ".", "SLB", ".", "value", ":", "return", "self", "...
Attempts to parse a value at the current position.
[ "Attempts", "to", "parse", "a", "value", "at", "the", "current", "position", "." ]
python
train
31.554054
ruipgil/TrackToTrip
tracktotrip/compression.py
https://github.com/ruipgil/TrackToTrip/blob/5537c14ee9748091b5255b658ab528e1d6227f99/tracktotrip/compression.py#L75-L98
def drp(points, epsilon): """ Douglas ramer peucker Based on https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm Args: points (:obj:`list` of :obj:`Point`) epsilon (float): drp threshold Returns: :obj:`list` of :obj:`Point` """ dmax = 0.0 i...
[ "def", "drp", "(", "points", ",", "epsilon", ")", ":", "dmax", "=", "0.0", "index", "=", "0", "for", "i", "in", "range", "(", "1", ",", "len", "(", "points", ")", "-", "1", ")", ":", "dist", "=", "point_line_distance", "(", "points", "[", "i", ...
Douglas ramer peucker Based on https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm Args: points (:obj:`list` of :obj:`Point`) epsilon (float): drp threshold Returns: :obj:`list` of :obj:`Point`
[ "Douglas", "ramer", "peucker" ]
python
train
26.583333
annoviko/pyclustering
pyclustering/utils/__init__.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/utils/__init__.py#L1216-L1227
def list_math_substraction_number(a, b): """! @brief Calculates subtraction between list and number. @details Each element from list 'a' is subtracted by number 'b'. @param[in] a (list): List of elements that supports mathematical subtraction. @param[in] b (list): Value that supports math...
[ "def", "list_math_substraction_number", "(", "a", ",", "b", ")", ":", "return", "[", "a", "[", "i", "]", "-", "b", "for", "i", "in", "range", "(", "len", "(", "a", ")", ")", "]" ]
! @brief Calculates subtraction between list and number. @details Each element from list 'a' is subtracted by number 'b'. @param[in] a (list): List of elements that supports mathematical subtraction. @param[in] b (list): Value that supports mathematical subtraction. @return (list) R...
[ "!" ]
python
valid
39.5
StyXman/ayrton
ayrton/parser/pyparser/pylexer.py
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/pylexer.py#L33-L48
def notChainStr (states, s): """XXX I'm not sure this is how it should be done, but I'm going to try it anyway. Note that for this case, I require only single character arcs, since I would have to basically invert all accepting states and non-accepting states of any sub-NFA's. """ assert len(s)...
[ "def", "notChainStr", "(", "states", ",", "s", ")", ":", "assert", "len", "(", "s", ")", ">", "0", "arcs", "=", "list", "(", "map", "(", "lambda", "x", ":", "newArcPair", "(", "states", ",", "x", ")", ",", "s", ")", ")", "finish", "=", "len", ...
XXX I'm not sure this is how it should be done, but I'm going to try it anyway. Note that for this case, I require only single character arcs, since I would have to basically invert all accepting states and non-accepting states of any sub-NFA's.
[ "XXX", "I", "m", "not", "sure", "this", "is", "how", "it", "should", "be", "done", "but", "I", "m", "going", "to", "try", "it", "anyway", ".", "Note", "that", "for", "this", "case", "I", "require", "only", "single", "character", "arcs", "since", "I",...
python
train
41.25
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/threshold_monitor/interface/policy/area/alert/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/threshold_monitor/interface/policy/area/alert/__init__.py#L127-L148
def _set_below(self, v, load=False): """ Setter method for below, mapped from YANG variable /rbridge_id/threshold_monitor/interface/policy/area/alert/below (container) If this variable is read-only (config: false) in the source YANG file, then _set_below is considered as a private method. Backends l...
[ "def", "_set_below", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for below, mapped from YANG variable /rbridge_id/threshold_monitor/interface/policy/area/alert/below (container) If this variable is read-only (config: false) in the source YANG file, then _set_below is considered as a private method. Backends looking to populate this variable should do so...
[ "Setter", "method", "for", "below", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "threshold_monitor", "/", "interface", "/", "policy", "/", "area", "/", "alert", "/", "below", "(", "container", ")", "If", "this", "variable", "is", "read", ...
python
train
74.636364
f3at/feat
src/feat/models/call.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/models/call.py#L233-L245
def value_call(method_name, *args, **kwargs): """ Creates an effect that will call value's method with specified name with the specified arguments and keywords. @param method_name: the name of method belonging to the value. @type method_name: str """ def value_call(value, context, **_params...
[ "def", "value_call", "(", "method_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "value_call", "(", "value", ",", "context", ",", "*", "*", "_params", ")", ":", "method", "=", "getattr", "(", "value", ",", "method_name", ")", "ret...
Creates an effect that will call value's method with specified name with the specified arguments and keywords. @param method_name: the name of method belonging to the value. @type method_name: str
[ "Creates", "an", "effect", "that", "will", "call", "value", "s", "method", "with", "specified", "name", "with", "the", "specified", "arguments", "and", "keywords", "." ]
python
train
32.384615
mikedh/trimesh
trimesh/interfaces/gmsh.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/interfaces/gmsh.py#L101-L210
def to_volume(mesh, file_name=None, max_element=None, mesher_id=1): """ Convert a surface mesh to a 3D volume mesh generated by gmsh. An easy way to install the gmsh sdk is through the gmsh-sdk package on pypi, which downloads and sets up gmsh: pip inst...
[ "def", "to_volume", "(", "mesh", ",", "file_name", "=", "None", ",", "max_element", "=", "None", ",", "mesher_id", "=", "1", ")", ":", "# checks mesher selection", "if", "mesher_id", "not", "in", "[", "1", ",", "4", ",", "7", ",", "10", "]", ":", "ra...
Convert a surface mesh to a 3D volume mesh generated by gmsh. An easy way to install the gmsh sdk is through the gmsh-sdk package on pypi, which downloads and sets up gmsh: pip install gmsh-sdk Algorithm details, although check gmsh docs for more information: The "Delaunay" algorithm is split ...
[ "Convert", "a", "surface", "mesh", "to", "a", "3D", "volume", "mesh", "generated", "by", "gmsh", "." ]
python
train
33.627273
visio2img/visio2img
visio2img/visio2img.py
https://github.com/visio2img/visio2img/blob/60a1359abd2e8cf0d7dfa340fc7c9ace5572b7ac/visio2img/visio2img.py#L31-L44
def filter_pages(pages, pagenum, pagename): """ Choices pages by pagenum and pagename """ if pagenum: try: pages = [list(pages)[pagenum - 1]] except IndexError: raise IndexError('Invalid page number: %d' % pagenum) if pagename: pages = [page for page in pages...
[ "def", "filter_pages", "(", "pages", ",", "pagenum", ",", "pagename", ")", ":", "if", "pagenum", ":", "try", ":", "pages", "=", "[", "list", "(", "pages", ")", "[", "pagenum", "-", "1", "]", "]", "except", "IndexError", ":", "raise", "IndexError", "(...
Choices pages by pagenum and pagename
[ "Choices", "pages", "by", "pagenum", "and", "pagename" ]
python
train
31.857143
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookapp.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookapp.py#L495-L521
def _confirm_exit(self): """confirm shutdown on ^C A second ^C, or answering 'y' within 5s will cause shutdown, otherwise original SIGINT handler will be restored. This doesn't work on Windows. """ # FIXME: remove this delay when pyzmq dependency is >= 2...
[ "def", "_confirm_exit", "(", "self", ")", ":", "# FIXME: remove this delay when pyzmq dependency is >= 2.1.11", "time", ".", "sleep", "(", "0.1", ")", "sys", ".", "stdout", ".", "write", "(", "\"Shutdown Notebook Server (y/[n])? \"", ")", "sys", ".", "stdout", ".", ...
confirm shutdown on ^C A second ^C, or answering 'y' within 5s will cause shutdown, otherwise original SIGINT handler will be restored. This doesn't work on Windows.
[ "confirm", "shutdown", "on", "^C", "A", "second", "^C", "or", "answering", "y", "within", "5s", "will", "cause", "shutdown", "otherwise", "original", "SIGINT", "handler", "will", "be", "restored", ".", "This", "doesn", "t", "work", "on", "Windows", "." ]
python
test
38.703704
apache/incubator-superset
superset/tasks/cache.py
https://github.com/apache/incubator-superset/blob/ca2996c78f679260eb79c6008e276733df5fb653/superset/tasks/cache.py#L280-L316
def cache_warmup(strategy_name, *args, **kwargs): """ Warm up cache. This task periodically hits charts to warm up the cache. """ logger.info('Loading strategy') class_ = None for class_ in strategies: if class_.name == strategy_name: break else: message = f...
[ "def", "cache_warmup", "(", "strategy_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "'Loading strategy'", ")", "class_", "=", "None", "for", "class_", "in", "strategies", ":", "if", "class_", ".", "name", "==", ...
Warm up cache. This task periodically hits charts to warm up the cache.
[ "Warm", "up", "cache", "." ]
python
train
26.702703
LogicalDash/LiSE
LiSE/LiSE/engine.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/engine.py#L806-L841
def _remember_avatarness( self, character, graph, node, is_avatar=True, branch=None, turn=None, tick=None ): """Use this to record a change in avatarness. Should be called whenever a node that wasn't an avatar of a character now is, and whenever a node th...
[ "def", "_remember_avatarness", "(", "self", ",", "character", ",", "graph", ",", "node", ",", "is_avatar", "=", "True", ",", "branch", "=", "None", ",", "turn", "=", "None", ",", "tick", "=", "None", ")", ":", "branch", "=", "branch", "or", "self", "...
Use this to record a change in avatarness. Should be called whenever a node that wasn't an avatar of a character now is, and whenever a node that was an avatar of a character now isn't. ``character`` is the one using the node as an avatar, ``graph`` is the character the node is...
[ "Use", "this", "to", "record", "a", "change", "in", "avatarness", "." ]
python
train
25.888889
pkgw/pwkit
pwkit/environments/casa/cscript_importalma.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/cscript_importalma.py#L12-L31
def in_casapy (helper, asdm=None, ms=None): """This function is run inside the weirdo casapy IPython environment! A strange set of modules is available, and the `pwkit.environments.casa.scripting` system sets up a very particular environment to allow encapsulated scripting. """ if asdm is None:...
[ "def", "in_casapy", "(", "helper", ",", "asdm", "=", "None", ",", "ms", "=", "None", ")", ":", "if", "asdm", "is", "None", ":", "raise", "ValueError", "(", "'asdm'", ")", "if", "ms", "is", "None", ":", "raise", "ValueError", "(", "'ms'", ")", "help...
This function is run inside the weirdo casapy IPython environment! A strange set of modules is available, and the `pwkit.environments.casa.scripting` system sets up a very particular environment to allow encapsulated scripting.
[ "This", "function", "is", "run", "inside", "the", "weirdo", "casapy", "IPython", "environment!", "A", "strange", "set", "of", "modules", "is", "available", "and", "the", "pwkit", ".", "environments", ".", "casa", ".", "scripting", "system", "sets", "up", "a"...
python
train
32.05
dtmilano/AndroidViewClient
src/com/dtmilano/android/culebron.py
https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/culebron.py#L911-L918
def command(self, keycode): ''' Presses a key. Generates the actual key press on the device and prints the line in the script. ''' self.device.press(keycode) self.printOperation(None, Operation.PRESS, keycode)
[ "def", "command", "(", "self", ",", "keycode", ")", ":", "self", ".", "device", ".", "press", "(", "keycode", ")", "self", ".", "printOperation", "(", "None", ",", "Operation", ".", "PRESS", ",", "keycode", ")" ]
Presses a key. Generates the actual key press on the device and prints the line in the script.
[ "Presses", "a", "key", ".", "Generates", "the", "actual", "key", "press", "on", "the", "device", "and", "prints", "the", "line", "in", "the", "script", "." ]
python
train
31.375
splunk/splunk-sdk-python
examples/analytics/bottle.py
https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L455-L465
def install(self, plugin): ''' Add a plugin to the list of plugins and prepare it for beeing applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API. ''' if hasattr(plugin, 'setup'): plugin.setup(s...
[ "def", "install", "(", "self", ",", "plugin", ")", ":", "if", "hasattr", "(", "plugin", ",", "'setup'", ")", ":", "plugin", ".", "setup", "(", "self", ")", "if", "not", "callable", "(", "plugin", ")", "and", "not", "hasattr", "(", "plugin", ",", "'...
Add a plugin to the list of plugins and prepare it for beeing applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API.
[ "Add", "a", "plugin", "to", "the", "list", "of", "plugins", "and", "prepare", "it", "for", "beeing", "applied", "to", "all", "routes", "of", "this", "application", ".", "A", "plugin", "may", "be", "a", "simple", "decorator", "or", "an", "object", "that",...
python
train
48.818182
DAI-Lab/Copulas
copulas/univariate/gaussian.py
https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/univariate/gaussian.py#L34-L55
def fit(self, X): """Fit the model. Arguments: X: `np.ndarray` of shape (n, 1). Returns: None """ if isinstance(X, (pd.Series, pd.DataFrame)): self.name = X.name self.constant_value = self._get_constant_value(X) if self.cons...
[ "def", "fit", "(", "self", ",", "X", ")", ":", "if", "isinstance", "(", "X", ",", "(", "pd", ".", "Series", ",", "pd", ".", "DataFrame", ")", ")", ":", "self", ".", "name", "=", "X", ".", "name", "self", ".", "constant_value", "=", "self", ".",...
Fit the model. Arguments: X: `np.ndarray` of shape (n, 1). Returns: None
[ "Fit", "the", "model", "." ]
python
train
21.545455
PlaidWeb/Publ
publ/view.py
https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/view.py#L206-L212
def newest(self): """ Gets the newest entry in the view, regardless of sort order """ if self._order_by == 'newest': return self.first if self._order_by == 'oldest': return self.last return max(self.entries, key=lambda x: (x.date, x.id))
[ "def", "newest", "(", "self", ")", ":", "if", "self", ".", "_order_by", "==", "'newest'", ":", "return", "self", ".", "first", "if", "self", ".", "_order_by", "==", "'oldest'", ":", "return", "self", ".", "last", "return", "max", "(", "self", ".", "e...
Gets the newest entry in the view, regardless of sort order
[ "Gets", "the", "newest", "entry", "in", "the", "view", "regardless", "of", "sort", "order" ]
python
train
41
pjuren/pyokit
src/pyokit/util/meta.py
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L198-L203
def _fill(self): """Advance the iterator without returning the old head.""" prev = self._head super(AutoApplyIterator, self)._fill() if self._head is not None: self.on_next(self._head, prev)
[ "def", "_fill", "(", "self", ")", ":", "prev", "=", "self", ".", "_head", "super", "(", "AutoApplyIterator", ",", "self", ")", ".", "_fill", "(", ")", "if", "self", ".", "_head", "is", "not", "None", ":", "self", ".", "on_next", "(", "self", ".", ...
Advance the iterator without returning the old head.
[ "Advance", "the", "iterator", "without", "returning", "the", "old", "head", "." ]
python
train
34.5
tdryer/hangups
hangups/ui/__main__.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/ui/__main__.py#L236-L253
def _on_event(self, conv_event): """Open conversation tab for new messages & pass events to notifier.""" conv = self._conv_list.get(conv_event.conversation_id) user = conv.get_user(conv_event.user_id) show_notification = all(( isinstance(conv_event, hangups.ChatMessageEvent),...
[ "def", "_on_event", "(", "self", ",", "conv_event", ")", ":", "conv", "=", "self", ".", "_conv_list", ".", "get", "(", "conv_event", ".", "conversation_id", ")", "user", "=", "conv", ".", "get_user", "(", "conv_event", ".", "user_id", ")", "show_notificati...
Open conversation tab for new messages & pass events to notifier.
[ "Open", "conversation", "tab", "for", "new", "messages", "&", "pass", "events", "to", "notifier", "." ]
python
valid
43.222222
RJT1990/pyflux
pyflux/families/normal.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/normal.py#L291-L306
def pdf(self, mu): """ PDF for Normal prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu) """ if self.transform is not None: mu = self.transfor...
[ "def", "pdf", "(", "self", ",", "mu", ")", ":", "if", "self", ".", "transform", "is", "not", "None", ":", "mu", "=", "self", ".", "transform", "(", "mu", ")", "return", "(", "1.0", "/", "float", "(", "self", ".", "sigma0", ")", ")", "*", "np", ...
PDF for Normal prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - p(mu)
[ "PDF", "for", "Normal", "prior" ]
python
train
26.0625
inveniosoftware/invenio-oauthclient
invenio_oauthclient/contrib/cern.py
https://github.com/inveniosoftware/invenio-oauthclient/blob/2500dc6935738107617aeade79e050d7608004bb/invenio_oauthclient/contrib/cern.py#L288-L297
def get_resource(remote): """Query CERN Resources to get user info and groups.""" cached_resource = session.pop('cern_resource', None) if cached_resource: return cached_resource response = remote.get(REMOTE_APP_RESOURCE_API_URL) dict_response = get_dict_from_response(response) session['...
[ "def", "get_resource", "(", "remote", ")", ":", "cached_resource", "=", "session", ".", "pop", "(", "'cern_resource'", ",", "None", ")", "if", "cached_resource", ":", "return", "cached_resource", "response", "=", "remote", ".", "get", "(", "REMOTE_APP_RESOURCE_A...
Query CERN Resources to get user info and groups.
[ "Query", "CERN", "Resources", "to", "get", "user", "info", "and", "groups", "." ]
python
train
36.7
CodeReclaimers/neat-python
neat/graphs.py
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/graphs.py#L58-L90
def feed_forward_layers(inputs, outputs, connections): """ Collect the layers whose members can be evaluated in parallel in a feed-forward network. :param inputs: list of the network input nodes :param outputs: list of the output node identifiers :param connections: list of (input, output) connectio...
[ "def", "feed_forward_layers", "(", "inputs", ",", "outputs", ",", "connections", ")", ":", "required", "=", "required_for_output", "(", "inputs", ",", "outputs", ",", "connections", ")", "layers", "=", "[", "]", "s", "=", "set", "(", "inputs", ")", "while"...
Collect the layers whose members can be evaluated in parallel in a feed-forward network. :param inputs: list of the network input nodes :param outputs: list of the output node identifiers :param connections: list of (input, output) connections in the network. Returns a list of layers, with each layer c...
[ "Collect", "the", "layers", "whose", "members", "can", "be", "evaluated", "in", "parallel", "in", "a", "feed", "-", "forward", "network", ".", ":", "param", "inputs", ":", "list", "of", "the", "network", "input", "nodes", ":", "param", "outputs", ":", "l...
python
train
35.515152
pandas-dev/pandas
pandas/core/arrays/interval.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/interval.py#L1078-L1102
def maybe_convert_platform_interval(values): """ Try to do platform conversion, with special casing for IntervalArray. Wrapper around maybe_convert_platform that alters the default return dtype in certain cases to be compatible with IntervalArray. For example, empty lists return with integer dtype ...
[ "def", "maybe_convert_platform_interval", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "list", ",", "tuple", ")", ")", "and", "len", "(", "values", ")", "==", "0", ":", "# GH 19016", "# empty lists/tuples get object dtype by default, but t...
Try to do platform conversion, with special casing for IntervalArray. Wrapper around maybe_convert_platform that alters the default return dtype in certain cases to be compatible with IntervalArray. For example, empty lists return with integer dtype instead of object dtype, which is prohibited for Inte...
[ "Try", "to", "do", "platform", "conversion", "with", "special", "casing", "for", "IntervalArray", ".", "Wrapper", "around", "maybe_convert_platform", "that", "alters", "the", "default", "return", "dtype", "in", "certain", "cases", "to", "be", "compatible", "with",...
python
train
33.92
gem/oq-engine
openquake/calculators/base.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L498-L522
def init(self): """ To be overridden to initialize the datasets needed by the calculation """ oq = self.oqparam if not oq.risk_imtls: if self.datastore.parent: oq.risk_imtls = ( self.datastore.parent['oqparam'].risk_imtls) i...
[ "def", "init", "(", "self", ")", ":", "oq", "=", "self", ".", "oqparam", "if", "not", "oq", ".", "risk_imtls", ":", "if", "self", ".", "datastore", ".", "parent", ":", "oq", ".", "risk_imtls", "=", "(", "self", ".", "datastore", ".", "parent", "[",...
To be overridden to initialize the datasets needed by the calculation
[ "To", "be", "overridden", "to", "initialize", "the", "datasets", "needed", "by", "the", "calculation" ]
python
train
48.84
osrg/ryu
ryu/lib/lacplib.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/lacplib.py#L268-L272
def _set_slave_timeout(self, dpid, port, timeout): """set the timeout time at some port of some datapath.""" slave = self._get_slave(dpid, port) if slave: slave['timeout'] = timeout
[ "def", "_set_slave_timeout", "(", "self", ",", "dpid", ",", "port", ",", "timeout", ")", ":", "slave", "=", "self", ".", "_get_slave", "(", "dpid", ",", "port", ")", "if", "slave", ":", "slave", "[", "'timeout'", "]", "=", "timeout" ]
set the timeout time at some port of some datapath.
[ "set", "the", "timeout", "time", "at", "some", "port", "of", "some", "datapath", "." ]
python
train
42.6
openfisca/openfisca-core
openfisca_core/taxbenefitsystems.py
https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/taxbenefitsystems.py#L167-L180
def replace_variable(self, variable): """ Replaces an existing OpenFisca variable in the tax and benefit system by a new one. The new variable must have the same name than the replaced one. If no variable with the given name exists in the tax and benefit system, no error will be raised...
[ "def", "replace_variable", "(", "self", ",", "variable", ")", ":", "name", "=", "variable", ".", "__name__", "if", "self", ".", "variables", ".", "get", "(", "name", ")", "is", "not", "None", ":", "del", "self", ".", "variables", "[", "name", "]", "s...
Replaces an existing OpenFisca variable in the tax and benefit system by a new one. The new variable must have the same name than the replaced one. If no variable with the given name exists in the tax and benefit system, no error will be raised and the new variable will be simply added. :para...
[ "Replaces", "an", "existing", "OpenFisca", "variable", "in", "the", "tax", "and", "benefit", "system", "by", "a", "new", "one", "." ]
python
train
44.428571
apache/incubator-mxnet
example/ssd/symbol/common.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/common.py#L21-L55
def conv_act_layer(from_layer, name, num_filter, kernel=(1,1), pad=(0,0), \ stride=(1,1), act_type="relu", use_batchnorm=False): """ wrapper for a small Convolution group Parameters: ---------- from_layer : mx.symbol continue on which layer name : str base name of the new la...
[ "def", "conv_act_layer", "(", "from_layer", ",", "name", ",", "num_filter", ",", "kernel", "=", "(", "1", ",", "1", ")", ",", "pad", "=", "(", "0", ",", "0", ")", ",", "stride", "=", "(", "1", ",", "1", ")", ",", "act_type", "=", "\"relu\"", ",...
wrapper for a small Convolution group Parameters: ---------- from_layer : mx.symbol continue on which layer name : str base name of the new layers num_filter : int how many filters to use in Convolution layer kernel : tuple (int, int) kernel size (h, w) pad :...
[ "wrapper", "for", "a", "small", "Convolution", "group" ]
python
train
31.314286
mitsei/dlkit
dlkit/handcar/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L1861-L1877
def can_lookup_objective_prerequisites(self): """Tests if this user can perform Objective lookups. A return of true does not guarantee successful authorization. A return of false indicates that it is known all methods in this session will result in a PermissionDenied. This is intended a...
[ "def", "can_lookup_objective_prerequisites", "(", "self", ")", ":", "url_path", "=", "construct_url", "(", "'authorization'", ",", "bank_id", "=", "self", ".", "_catalog_idstr", ")", "return", "self", ".", "_get_request", "(", "url_path", ")", "[", "'objectiveRequ...
Tests if this user can perform Objective lookups. A return of true does not guarantee successful authorization. A return of false indicates that it is known all methods in this session will result in a PermissionDenied. This is intended as a hint to an application that may opt not to of...
[ "Tests", "if", "this", "user", "can", "perform", "Objective", "lookups", "." ]
python
train
46.470588
matthewdeanmartin/jiggle_version
jiggle_version/jiggle_class.py
https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/jiggle_class.py#L391-L414
def jiggle_text_file(self): # type: () -> int """ Update ver strings in a non-python, ordinary text file in root of package (next to setup.py). :return: """ changed = 0 files_to_update = [] for version_txt in self.file_inventory.text_files: if os.pat...
[ "def", "jiggle_text_file", "(", "self", ")", ":", "# type: () -> int", "changed", "=", "0", "files_to_update", "=", "[", "]", "for", "version_txt", "in", "self", ".", "file_inventory", ".", "text_files", ":", "if", "os", ".", "path", ".", "isfile", "(", "v...
Update ver strings in a non-python, ordinary text file in root of package (next to setup.py). :return:
[ "Update", "ver", "strings", "in", "a", "non", "-", "python", "ordinary", "text", "file", "in", "root", "of", "package", "(", "next", "to", "setup", ".", "py", ")", ".", ":", "return", ":" ]
python
train
40.5
jilljenn/tryalgo
tryalgo/kruskal.py
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/kruskal.py#L28-L45
def union(self, x, y): """Merges part that contain x and part containing y :returns: False if x, y are already in same part :complexity: O(inverse_ackerman(n)) """ repr_x = self.find(x) repr_y = self.find(y) if repr_x == repr_y: # already in the same compon...
[ "def", "union", "(", "self", ",", "x", ",", "y", ")", ":", "repr_x", "=", "self", ".", "find", "(", "x", ")", "repr_y", "=", "self", ".", "find", "(", "y", ")", "if", "repr_x", "==", "repr_y", ":", "# already in the same component", "return", "False"...
Merges part that contain x and part containing y :returns: False if x, y are already in same part :complexity: O(inverse_ackerman(n))
[ "Merges", "part", "that", "contain", "x", "and", "part", "containing", "y" ]
python
train
34.111111
zblz/naima
naima/radiative.py
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L173-L177
def _nelec(self): """ Particles per unit lorentz factor """ pd = self.particle_distribution(self._gam * mec2) return pd.to(1 / mec2_unit).value
[ "def", "_nelec", "(", "self", ")", ":", "pd", "=", "self", ".", "particle_distribution", "(", "self", ".", "_gam", "*", "mec2", ")", "return", "pd", ".", "to", "(", "1", "/", "mec2_unit", ")", ".", "value" ]
Particles per unit lorentz factor
[ "Particles", "per", "unit", "lorentz", "factor" ]
python
train
34.2
romana/vpc-router
vpcrouter/watcher/__init__.py
https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/__init__.py#L166-L187
def start_plugins(conf, watcher_plugin_class, health_plugin_class, sleep_time): """ Start the working threads: - Health monitor (the health plugin) - Config change monitor (the watcher plugin) """ # No matter what the chosen plugin to watch for config updates: We get a # ...
[ "def", "start_plugins", "(", "conf", ",", "watcher_plugin_class", ",", "health_plugin_class", ",", "sleep_time", ")", ":", "# No matter what the chosen plugin to watch for config updates: We get a", "# plugin-handle back. This gives us a start(), stop() and", "# get_route_spec_queue() fu...
Start the working threads: - Health monitor (the health plugin) - Config change monitor (the watcher plugin)
[ "Start", "the", "working", "threads", ":" ]
python
train
35.136364
trevisanj/a99
a99/gui/a_WBase.py
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/a_WBase.py#L42-L44
def add_log(self, x, flag_also_show=False): """Delegates to parent form""" self.parent_form.add_log(x, flag_also_show)
[ "def", "add_log", "(", "self", ",", "x", ",", "flag_also_show", "=", "False", ")", ":", "self", ".", "parent_form", ".", "add_log", "(", "x", ",", "flag_also_show", ")" ]
Delegates to parent form
[ "Delegates", "to", "parent", "form" ]
python
train
44.666667
willkg/phil
phil/util.py
https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L77-L90
def err(*output, **kwargs): """Writes output to stderr. :arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap the output. """ output = 'Error: ' + ' '.join([str(o) for o in output]) if kwargs.get('wrap') is not False: output = '\n'.join(wrap(output, kwargs.get('indent',...
[ "def", "err", "(", "*", "output", ",", "*", "*", "kwargs", ")", ":", "output", "=", "'Error: '", "+", "' '", ".", "join", "(", "[", "str", "(", "o", ")", "for", "o", "in", "output", "]", ")", "if", "kwargs", ".", "get", "(", "'wrap'", ")", "i...
Writes output to stderr. :arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap the output.
[ "Writes", "output", "to", "stderr", "." ]
python
train
34.428571
MisterY/gnucash-portfolio
gnucash_portfolio/splitsaggregate.py
https://github.com/MisterY/gnucash-portfolio/blob/bfaad8345a5479d1cd111acee1939e25c2a638c2/gnucash_portfolio/splitsaggregate.py#L27-L33
def get(self, split_id: str) -> Split: """ load transaction by id """ query = ( self.query .filter(Split.guid == split_id) ) return query.one()
[ "def", "get", "(", "self", ",", "split_id", ":", "str", ")", "->", "Split", ":", "query", "=", "(", "self", ".", "query", ".", "filter", "(", "Split", ".", "guid", "==", "split_id", ")", ")", "return", "query", ".", "one", "(", ")" ]
load transaction by id
[ "load", "transaction", "by", "id" ]
python
train
27.571429
resync/resync
resync/list_base_with_index.py
https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/list_base_with_index.py#L387-L404
def part_name(self, basename='/tmp/sitemap.xml', part_number=0): """Name (file or URI) for one component sitemap. Works for both filenames and URIs because manipulates only the end of the string. Abstracting this into a function that starts from the basename to get prefix and s...
[ "def", "part_name", "(", "self", ",", "basename", "=", "'/tmp/sitemap.xml'", ",", "part_number", "=", "0", ")", ":", "# Work out how to name the sitemaps, attempt to add %05d before", "# \".xml$\", else append", "sitemap_prefix", "=", "basename", "sitemap_suffix", "=", "'.x...
Name (file or URI) for one component sitemap. Works for both filenames and URIs because manipulates only the end of the string. Abstracting this into a function that starts from the basename to get prefix and suffix each time seems a bit wasteful but perhaps not worth worrying ...
[ "Name", "(", "file", "or", "URI", ")", "for", "one", "component", "sitemap", "." ]
python
train
44.444444
DataDog/integrations-core
zk/datadog_checks/zk/zk.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/zk/datadog_checks/zk/zk.py#L250-L338
def parse_stat(self, buf): """ `buf` is a readable file-like object returns a tuple: (metrics, tags, mode, version) """ metrics = [] buf.seek(0) # Check the version line to make sure we parse the rest of the # body correctly. Particularly, the Connections...
[ "def", "parse_stat", "(", "self", ",", "buf", ")", ":", "metrics", "=", "[", "]", "buf", ".", "seek", "(", "0", ")", "# Check the version line to make sure we parse the rest of the", "# body correctly. Particularly, the Connections val was added in", "# >= 3.4.4.", "start_l...
`buf` is a readable file-like object returns a tuple: (metrics, tags, mode, version)
[ "buf", "is", "a", "readable", "file", "-", "like", "object", "returns", "a", "tuple", ":", "(", "metrics", "tags", "mode", "version", ")" ]
python
train
41
joke2k/faker
faker/providers/date_time/__init__.py
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/date_time/__init__.py#L1368-L1376
def unix_time(self, end_datetime=None, start_datetime=None): """ Get a timestamp between January 1, 1970 and now, unless passed explicit start_datetime or end_datetime values. :example 1061306726 """ start_datetime = self._parse_start_datetime(start_datetime) end_...
[ "def", "unix_time", "(", "self", ",", "end_datetime", "=", "None", ",", "start_datetime", "=", "None", ")", ":", "start_datetime", "=", "self", ".", "_parse_start_datetime", "(", "start_datetime", ")", "end_datetime", "=", "self", ".", "_parse_end_datetime", "("...
Get a timestamp between January 1, 1970 and now, unless passed explicit start_datetime or end_datetime values. :example 1061306726
[ "Get", "a", "timestamp", "between", "January", "1", "1970", "and", "now", "unless", "passed", "explicit", "start_datetime", "or", "end_datetime", "values", ".", ":", "example", "1061306726" ]
python
train
48.444444
wakatime/wakatime
wakatime/configs.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/configs.py#L44-L64
def parseConfigFile(configFile=None): """Returns a configparser.SafeConfigParser instance with configs read from the config file. Default location of the config file is at ~/.wakatime.cfg. """ # get config file location from ENV if not configFile: configFile = getConfigFile() confi...
[ "def", "parseConfigFile", "(", "configFile", "=", "None", ")", ":", "# get config file location from ENV", "if", "not", "configFile", ":", "configFile", "=", "getConfigFile", "(", ")", "configs", "=", "configparser", ".", "ConfigParser", "(", "delimiters", "=", "(...
Returns a configparser.SafeConfigParser instance with configs read from the config file. Default location of the config file is at ~/.wakatime.cfg.
[ "Returns", "a", "configparser", ".", "SafeConfigParser", "instance", "with", "configs", "read", "from", "the", "config", "file", ".", "Default", "location", "of", "the", "config", "file", "is", "at", "~", "/", ".", "wakatime", ".", "cfg", "." ]
python
train
32.428571
michael-lazar/rtv
rtv/page.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/page.py#L235-L241
def move_page_bottom(self): """ Move the cursor to the last item on the page. """ self.nav.page_index = self.content.range[1] self.nav.cursor_index = 0 self.nav.inverted = True
[ "def", "move_page_bottom", "(", "self", ")", ":", "self", ".", "nav", ".", "page_index", "=", "self", ".", "content", ".", "range", "[", "1", "]", "self", ".", "nav", ".", "cursor_index", "=", "0", "self", ".", "nav", ".", "inverted", "=", "True" ]
Move the cursor to the last item on the page.
[ "Move", "the", "cursor", "to", "the", "last", "item", "on", "the", "page", "." ]
python
train
31.142857
androguard/androguard
androguard/session.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/session.py#L18-L69
def Save(session, filename=None): """ save your session to use it later. Returns the filename of the written file. If not filename is given, a file named `androguard_session_<DATE>.ag` will be created in the current working directory. `<DATE>` is a timestamp with the following format: `%Y-%m-%d...
[ "def", "Save", "(", "session", ",", "filename", "=", "None", ")", ":", "if", "not", "filename", ":", "filename", "=", "\"androguard_session_{:%Y-%m-%d_%H%M%S}.ag\"", ".", "format", "(", "datetime", ".", "datetime", ".", "now", "(", ")", ")", "if", "os", "....
save your session to use it later. Returns the filename of the written file. If not filename is given, a file named `androguard_session_<DATE>.ag` will be created in the current working directory. `<DATE>` is a timestamp with the following format: `%Y-%m-%d_%H%M%S`. This function will overwrite ex...
[ "save", "your", "session", "to", "use", "it", "later", "." ]
python
train
33.653846
DataBiosphere/toil
src/toil/resource.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/resource.py#L477-L500
def localize(self): """ Check if this module was saved as a resource. If it was, return a new module descriptor that points to a local copy of that resource. Should only be called on a worker node. On the leader, this method returns this resource, i.e. self. :rtype: toil.resourc...
[ "def", "localize", "(", "self", ")", ":", "if", "not", "self", ".", "_runningOnWorker", "(", ")", ":", "log", ".", "warn", "(", "'The localize() method should only be invoked on a worker.'", ")", "resource", "=", "Resource", ".", "lookup", "(", "self", ".", "_...
Check if this module was saved as a resource. If it was, return a new module descriptor that points to a local copy of that resource. Should only be called on a worker node. On the leader, this method returns this resource, i.e. self. :rtype: toil.resource.Resource
[ "Check", "if", "this", "module", "was", "saved", "as", "a", "resource", ".", "If", "it", "was", "return", "a", "new", "module", "descriptor", "that", "points", "to", "a", "local", "copy", "of", "that", "resource", ".", "Should", "only", "be", "called", ...
python
train
45.708333
fake-name/ChromeController
ChromeController/Generator/Generated.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L2271-L2329
def Network_setCookie(self, name, value, **kwargs): """ Function path: Network.setCookie Domain: Network Method name: setCookie WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'name' (type: string) -> Cookie name. 'value' (type: string) -> Cookie valu...
[ "def", "Network_setCookie", "(", "self", ",", "name", ",", "value", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "name", ",", "(", "str", ",", ")", ")", ",", "\"Argument 'name' must be of type '['str']'. Received type: '%s'\"", "%", "type", ...
Function path: Network.setCookie Domain: Network Method name: setCookie WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'name' (type: string) -> Cookie name. 'value' (type: string) -> Cookie value. Optional arguments: 'url' (type: string) -> The ...
[ "Function", "path", ":", "Network", ".", "setCookie", "Domain", ":", "Network", "Method", "name", ":", "setCookie", "WARNING", ":", "This", "function", "is", "marked", "Experimental", "!", "Parameters", ":", "Required", "arguments", ":", "name", "(", "type", ...
python
train
45.067797