repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
sosy-lab/benchexec
benchexec/tablegenerator/__init__.py
https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/tablegenerator/__init__.py#L91-L112
def parse_table_definition_file(file): ''' Read an parse the XML of a table-definition file. @return: an ElementTree object for the table definition ''' logging.info("Reading table definition from '%s'...", file) if not os.path.isfile(file): logging.error("File '%s' does not exist.", fil...
[ "def", "parse_table_definition_file", "(", "file", ")", ":", "logging", ".", "info", "(", "\"Reading table definition from '%s'...\"", ",", "file", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "file", ")", ":", "logging", ".", "error", "(", "\"Fi...
Read an parse the XML of a table-definition file. @return: an ElementTree object for the table definition
[ "Read", "an", "parse", "the", "XML", "of", "a", "table", "-", "definition", "file", "." ]
python
train
apache/incubator-mxnet
python/mxnet/rnn/rnn_cell.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L190-L223
def begin_state(self, func=symbol.zeros, **kwargs): """Initial state for this cell. Parameters ---------- func : callable, default symbol.zeros Function for creating initial state. Can be symbol.zeros, symbol.uniform, symbol.Variable etc. Use symbol.V...
[ "def", "begin_state", "(", "self", ",", "func", "=", "symbol", ".", "zeros", ",", "*", "*", "kwargs", ")", ":", "assert", "not", "self", ".", "_modified", ",", "\"After applying modifier cells (e.g. DropoutCell) the base \"", "\"cell cannot be called directly. Call the ...
Initial state for this cell. Parameters ---------- func : callable, default symbol.zeros Function for creating initial state. Can be symbol.zeros, symbol.uniform, symbol.Variable etc. Use symbol.Variable if you want to directly feed input as state...
[ "Initial", "state", "for", "this", "cell", "." ]
python
train
GNS3/gns3-server
gns3server/compute/dynamips/__init__.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/__init__.py#L270-L314
def start_new_hypervisor(self, working_dir=None): """ Creates a new Dynamips process and start it. :param working_dir: working directory :returns: the new hypervisor instance """ if not self._dynamips_path: self.find_dynamips() if not working_dir: ...
[ "def", "start_new_hypervisor", "(", "self", ",", "working_dir", "=", "None", ")", ":", "if", "not", "self", ".", "_dynamips_path", ":", "self", ".", "find_dynamips", "(", ")", "if", "not", "working_dir", ":", "working_dir", "=", "tempfile", ".", "gettempdir"...
Creates a new Dynamips process and start it. :param working_dir: working directory :returns: the new hypervisor instance
[ "Creates", "a", "new", "Dynamips", "process", "and", "start", "it", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py#L2289-L2315
def auto_rewrite_input(self, cmd): """Print to the screen the rewritten form of the user's command. This shows visual feedback by rewriting input lines that cause automatic calling to kick in, like:: /f x into:: ------> f(x) after the user's input prompt....
[ "def", "auto_rewrite_input", "(", "self", ",", "cmd", ")", ":", "if", "not", "self", ".", "show_rewritten_input", ":", "return", "rw", "=", "self", ".", "prompt_manager", ".", "render", "(", "'rewrite'", ")", "+", "cmd", "try", ":", "# plain ascii works bett...
Print to the screen the rewritten form of the user's command. This shows visual feedback by rewriting input lines that cause automatic calling to kick in, like:: /f x into:: ------> f(x) after the user's input prompt. This helps the user understand that the ...
[ "Print", "to", "the", "screen", "the", "rewritten", "form", "of", "the", "user", "s", "command", "." ]
python
test
vbwagner/ctypescrypto
ctypescrypto/x509.py
https://github.com/vbwagner/ctypescrypto/blob/33c32904cf5e04901f87f90e2499634b8feecd3e/ctypescrypto/x509.py#L344-L351
def _X509__asn1date_to_datetime(asn1date): """ Converts openssl ASN1_TIME object to python datetime.datetime """ bio = Membio() libcrypto.ASN1_TIME_print(bio.bio, asn1date) pydate = datetime.strptime(str(bio), "%b %d %H:%M:%S %Y %Z") return pydate.replace(tzinfo=utc)
[ "def", "_X509__asn1date_to_datetime", "(", "asn1date", ")", ":", "bio", "=", "Membio", "(", ")", "libcrypto", ".", "ASN1_TIME_print", "(", "bio", ".", "bio", ",", "asn1date", ")", "pydate", "=", "datetime", ".", "strptime", "(", "str", "(", "bio", ")", "...
Converts openssl ASN1_TIME object to python datetime.datetime
[ "Converts", "openssl", "ASN1_TIME", "object", "to", "python", "datetime", ".", "datetime" ]
python
train
baszoetekouw/janus-py
sr/sr.py
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L171-L177
def get(self, eid): """ Returns a dict with the complete record of the entity with the given eID """ data = self._http_req('connections/%u' % eid) self.debug(0x01, data['decoded']) return data['decoded']
[ "def", "get", "(", "self", ",", "eid", ")", ":", "data", "=", "self", ".", "_http_req", "(", "'connections/%u'", "%", "eid", ")", "self", ".", "debug", "(", "0x01", ",", "data", "[", "'decoded'", "]", ")", "return", "data", "[", "'decoded'", "]" ]
Returns a dict with the complete record of the entity with the given eID
[ "Returns", "a", "dict", "with", "the", "complete", "record", "of", "the", "entity", "with", "the", "given", "eID" ]
python
train
RedHatInsights/insights-core
insights/parsers/multipath_conf.py
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/multipath_conf.py#L209-L216
def get_tree_from_initramfs(root=None): """ This is a helper function to get a multipath configuration(from initramfs image) component for your local machine or an archive. It's for use in interactive sessions. """ from insights import run return run(MultipathConfTreeInitramfs, root=root).ge...
[ "def", "get_tree_from_initramfs", "(", "root", "=", "None", ")", ":", "from", "insights", "import", "run", "return", "run", "(", "MultipathConfTreeInitramfs", ",", "root", "=", "root", ")", ".", "get", "(", "MultipathConfTreeInitramfs", ")" ]
This is a helper function to get a multipath configuration(from initramfs image) component for your local machine or an archive. It's for use in interactive sessions.
[ "This", "is", "a", "helper", "function", "to", "get", "a", "multipath", "configuration", "(", "from", "initramfs", "image", ")", "component", "for", "your", "local", "machine", "or", "an", "archive", ".", "It", "s", "for", "use", "in", "interactive", "sess...
python
train
campaignmonitor/createsend-python
lib/createsend/list.py
https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/list.py#L56-L60
def delete_custom_field(self, custom_field_key): """Deletes a custom field associated with this list.""" custom_field_key = quote(custom_field_key, '') response = self._delete("/lists/%s/customfields/%s.json" % (self.list_id, custom_field_key))
[ "def", "delete_custom_field", "(", "self", ",", "custom_field_key", ")", ":", "custom_field_key", "=", "quote", "(", "custom_field_key", ",", "''", ")", "response", "=", "self", ".", "_delete", "(", "\"/lists/%s/customfields/%s.json\"", "%", "(", "self", ".", "l...
Deletes a custom field associated with this list.
[ "Deletes", "a", "custom", "field", "associated", "with", "this", "list", "." ]
python
train
JNRowe/upoints
upoints/baken.py
https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/baken.py#L87-L94
def locator(self, value): """Update the locator, and trigger a latitude and longitude update. Args: value (str): New Maidenhead locator string """ self._locator = value self._latitude, self._longitude = utils.from_grid_locator(value)
[ "def", "locator", "(", "self", ",", "value", ")", ":", "self", ".", "_locator", "=", "value", "self", ".", "_latitude", ",", "self", ".", "_longitude", "=", "utils", ".", "from_grid_locator", "(", "value", ")" ]
Update the locator, and trigger a latitude and longitude update. Args: value (str): New Maidenhead locator string
[ "Update", "the", "locator", "and", "trigger", "a", "latitude", "and", "longitude", "update", "." ]
python
train
objectrocket/python-client
scripts/check_docs.py
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/scripts/check_docs.py#L238-L248
def _valid_directory(self, path): """Ensure that the given path is valid. :param str path: A valid directory path. :raises: :py:class:`argparse.ArgumentTypeError` :returns: An absolute directory path. """ abspath = os.path.abspath(path) if not os.path.isdir(abspa...
[ "def", "_valid_directory", "(", "self", ",", "path", ")", ":", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "abspath", ")", ":", "raise", "argparse", ".", "ArgumentTypeError", ...
Ensure that the given path is valid. :param str path: A valid directory path. :raises: :py:class:`argparse.ArgumentTypeError` :returns: An absolute directory path.
[ "Ensure", "that", "the", "given", "path", "is", "valid", "." ]
python
train
dade-ai/snipy
snipy/io/fileutil.py
https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L207-L228
def listdir(p, match='*', exclude='', listtype='file', matchfun=None): """ list file(or folder) for this path (NOT recursive) :param p: :param match: :param exclude: :param listtype: ('file' | 'filepath' |'dir' | 'all') :param matchfun: match fun (default fnmatch.fnmatch) True/False = matchf...
[ "def", "listdir", "(", "p", ",", "match", "=", "'*'", ",", "exclude", "=", "''", ",", "listtype", "=", "'file'", ",", "matchfun", "=", "None", ")", ":", "if", "listtype", "==", "'file'", ":", "gen", "=", "listfile", "(", "p", ")", "elif", "listtype...
list file(or folder) for this path (NOT recursive) :param p: :param match: :param exclude: :param listtype: ('file' | 'filepath' |'dir' | 'all') :param matchfun: match fun (default fnmatch.fnmatch) True/False = matchfun(name, pattern) :rtype:
[ "list", "file", "(", "or", "folder", ")", "for", "this", "path", "(", "NOT", "recursive", ")", ":", "param", "p", ":", ":", "param", "match", ":", ":", "param", "exclude", ":", ":", "param", "listtype", ":", "(", "file", "|", "filepath", "|", "dir"...
python
valid
wq/django-rest-pandas
rest_pandas/serializers.py
https://github.com/wq/django-rest-pandas/blob/544177e576a8d54cb46cea6240586c07216f6c49/rest_pandas/serializers.py#L69-L83
def get_index_fields(self): """ List of fields to use for index """ index_fields = self.get_meta_option('index', []) if index_fields: return index_fields model = getattr(self.model_serializer_meta, 'model', None) if model: pk_name = model....
[ "def", "get_index_fields", "(", "self", ")", ":", "index_fields", "=", "self", ".", "get_meta_option", "(", "'index'", ",", "[", "]", ")", "if", "index_fields", ":", "return", "index_fields", "model", "=", "getattr", "(", "self", ".", "model_serializer_meta", ...
List of fields to use for index
[ "List", "of", "fields", "to", "use", "for", "index" ]
python
train
CyberZHG/keras-word-char-embd
keras_wc_embd/word_char_embd.py
https://github.com/CyberZHG/keras-word-char-embd/blob/cca6ddff01b6264dd0d12613bb9ed308e1367b8c/keras_wc_embd/word_char_embd.py#L278-L313
def get_embedding_weights_from_file(word_dict, file_path, ignore_case=False): """Load pre-trained embeddings from a text file. Each line in the file should look like this: word feature_dim_1 feature_dim_2 ... feature_dim_n The `feature_dim_i` should be a floating point number. :param word_dic...
[ "def", "get_embedding_weights_from_file", "(", "word_dict", ",", "file_path", ",", "ignore_case", "=", "False", ")", ":", "pre_trained", "=", "{", "}", "with", "codecs", ".", "open", "(", "file_path", ",", "'r'", ",", "'utf8'", ")", "as", "reader", ":", "f...
Load pre-trained embeddings from a text file. Each line in the file should look like this: word feature_dim_1 feature_dim_2 ... feature_dim_n The `feature_dim_i` should be a floating point number. :param word_dict: A dict that maps words to indice. :param file_path: The location of the text f...
[ "Load", "pre", "-", "trained", "embeddings", "from", "a", "text", "file", "." ]
python
train
nimbusproject/dashi
dashi/bootstrap/__init__.py
https://github.com/nimbusproject/dashi/blob/368b3963ec8abd60aebe0f81915429b45cbf4b5a/dashi/bootstrap/__init__.py#L212-L235
def _dict_from_dotted(key, val): """takes a key value pair like: key: "this.is.a.key" val: "the value" and returns a dictionary like: {"this": {"is": {"a": {"key": "the value" } } } } """ split_...
[ "def", "_dict_from_dotted", "(", "key", ",", "val", ")", ":", "split_key", "=", "key", ".", "split", "(", "\".\"", ")", "split_key", ".", "reverse", "(", ")", "for", "key_part", "in", "split_key", ":", "new_dict", "=", "DotDict", "(", ")", "new_dict", ...
takes a key value pair like: key: "this.is.a.key" val: "the value" and returns a dictionary like: {"this": {"is": {"a": {"key": "the value" } } } }
[ "takes", "a", "key", "value", "pair", "like", ":", "key", ":", "this", ".", "is", ".", "a", ".", "key", "val", ":", "the", "value" ]
python
train
juju/charm-helpers
charmhelpers/contrib/openstack/utils.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/utils.py#L662-L691
def ensure_block_device(block_device): ''' Confirm block_device, create as loopback if necessary. :param block_device: str: Full path of block device to ensure. :returns: str: Full path of ensured block device. ''' _none = ['None', 'none', None] if (block_device in _none): error_ou...
[ "def", "ensure_block_device", "(", "block_device", ")", ":", "_none", "=", "[", "'None'", ",", "'none'", ",", "None", "]", "if", "(", "block_device", "in", "_none", ")", ":", "error_out", "(", "'prepare_storage(): Missing required input: block_device=%s.'", "%", "...
Confirm block_device, create as loopback if necessary. :param block_device: str: Full path of block device to ensure. :returns: str: Full path of ensured block device.
[ "Confirm", "block_device", "create", "as", "loopback", "if", "necessary", "." ]
python
train
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L482-L499
def stop(self): """ Stop services and requestors and then connection. :return: self """ LOGGER.debug("rabbitmq.Driver.stop") for requester in self.requester_registry: requester.stop() self.requester_registry.clear() for service in self.service...
[ "def", "stop", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Driver.stop\"", ")", "for", "requester", "in", "self", ".", "requester_registry", ":", "requester", ".", "stop", "(", ")", "self", ".", "requester_registry", ".", "clear", "(", ...
Stop services and requestors and then connection. :return: self
[ "Stop", "services", "and", "requestors", "and", "then", "connection", ".", ":", "return", ":", "self" ]
python
train
MrYsLab/pymata-aio
pymata_aio/pymata_core.py
https://github.com/MrYsLab/pymata-aio/blob/015081a4628b9d47dfe3f8d6c698ff903f107810/pymata_aio/pymata_core.py#L1726-L1742
async def _report_version(self): """ This is a private message handler method. This method reads the following 2 bytes after the report version command (0xF9 - non sysex). The first byte is the major number and the second byte is the minor number. :returns: None ...
[ "async", "def", "_report_version", "(", "self", ")", ":", "# get next two bytes", "major", "=", "await", "self", ".", "read", "(", ")", "version_string", "=", "str", "(", "major", ")", "minor", "=", "await", "self", ".", "read", "(", ")", "version_string",...
This is a private message handler method. This method reads the following 2 bytes after the report version command (0xF9 - non sysex). The first byte is the major number and the second byte is the minor number. :returns: None
[ "This", "is", "a", "private", "message", "handler", "method", ".", "This", "method", "reads", "the", "following", "2", "bytes", "after", "the", "report", "version", "command", "(", "0xF9", "-", "non", "sysex", ")", ".", "The", "first", "byte", "is", "the...
python
train
aiogram/aiogram
aiogram/bot/bot.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1270-L1288
async def get_chat_administrators(self, chat_id: typing.Union[base.Integer, base.String] ) -> typing.List[types.ChatMember]: """ Use this method to get a list of administrators in a chat. Source: https://core.telegram.org/bots/api#getchatadministrators ...
[ "async", "def", "get_chat_administrators", "(", "self", ",", "chat_id", ":", "typing", ".", "Union", "[", "base", ".", "Integer", ",", "base", ".", "String", "]", ")", "->", "typing", ".", "List", "[", "types", ".", "ChatMember", "]", ":", "payload", "...
Use this method to get a list of administrators in a chat. Source: https://core.telegram.org/bots/api#getchatadministrators :param chat_id: Unique identifier for the target chat or username of the target supergroup or channel :type chat_id: :obj:`typing.Union[base.Integer, base.String]` ...
[ "Use", "this", "method", "to", "get", "a", "list", "of", "administrators", "in", "a", "chat", "." ]
python
train
Projectplace/basepage
basepage/base_page.py
https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/base_page.py#L511-L524
def get_visible_children(self, parent, locator, params=None, timeout=None): """ Get child-elements both present AND visible in the DOM. If timeout is 0 (zero) return WebElement instance or None, else we wait and retry for timeout and raise TimeoutException should the element not be foun...
[ "def", "get_visible_children", "(", "self", ",", "parent", ",", "locator", ",", "params", "=", "None", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "get_present_children", "(", "parent", ",", "locator", ",", "params", ",", "timeout", ",", ...
Get child-elements both present AND visible in the DOM. If timeout is 0 (zero) return WebElement instance or None, else we wait and retry for timeout and raise TimeoutException should the element not be found. :param parent: parent-element :param locator: locator tuple :param p...
[ "Get", "child", "-", "elements", "both", "present", "AND", "visible", "in", "the", "DOM", "." ]
python
train
bitesofcode/projexui
projexui/xdatatype.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xdatatype.py#L70-L87
def saveDataSet( settings, key, dataSet ): """ Records the dataset settings to the inputed data set for the given key. :param settings | <QSettings> key | <str> dataSet | <projex.dataset.DataSet> """ for datakey, value in dataSet.items(): datat...
[ "def", "saveDataSet", "(", "settings", ",", "key", ",", "dataSet", ")", ":", "for", "datakey", ",", "value", "in", "dataSet", ".", "items", "(", ")", ":", "datatype", "=", "type", "(", "value", ")", ".", "__name__", "if", "(", "datatype", "in", "_dat...
Records the dataset settings to the inputed data set for the given key. :param settings | <QSettings> key | <str> dataSet | <projex.dataset.DataSet>
[ "Records", "the", "dataset", "settings", "to", "the", "inputed", "data", "set", "for", "the", "given", "key", ".", ":", "param", "settings", "|", "<QSettings", ">", "key", "|", "<str", ">", "dataSet", "|", "<projex", ".", "dataset", ".", "DataSet", ">" ]
python
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L1426-L1449
def remove_edge(self, u, v, key=None): """Version of remove_edge that's much like normal networkx but only deletes once, since the database doesn't keep separate adj and succ mappings """ try: d = self.adj[u][v] except KeyError: raise NetworkXErro...
[ "def", "remove_edge", "(", "self", ",", "u", ",", "v", ",", "key", "=", "None", ")", ":", "try", ":", "d", "=", "self", ".", "adj", "[", "u", "]", "[", "v", "]", "except", "KeyError", ":", "raise", "NetworkXError", "(", "\"The edge {}-{} is not in th...
Version of remove_edge that's much like normal networkx but only deletes once, since the database doesn't keep separate adj and succ mappings
[ "Version", "of", "remove_edge", "that", "s", "much", "like", "normal", "networkx", "but", "only", "deletes", "once", "since", "the", "database", "doesn", "t", "keep", "separate", "adj", "and", "succ", "mappings" ]
python
train
mattloper/chumpy
chumpy/monitor.py
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/monitor.py#L139-L144
def record(self, ch_node): ''' Incremental changes ''' rec = self.serialize_node(ch_node) self.history.append(rec)
[ "def", "record", "(", "self", ",", "ch_node", ")", ":", "rec", "=", "self", ".", "serialize_node", "(", "ch_node", ")", "self", ".", "history", ".", "append", "(", "rec", ")" ]
Incremental changes
[ "Incremental", "changes" ]
python
train
rbarrois/mpdlcd
mpdlcd/vendor/lcdproc/server.py
https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/vendor/lcdproc/server.py#L155-L168
def del_key(self, ref): """ Delete a key. (ref) Return None or LCDd response on error """ if ref not in self.keys: response = self.request("client_del_key %s" % (ref)) self.keys.remove(ref) if "success" in response: ret...
[ "def", "del_key", "(", "self", ",", "ref", ")", ":", "if", "ref", "not", "in", "self", ".", "keys", ":", "response", "=", "self", ".", "request", "(", "\"client_del_key %s\"", "%", "(", "ref", ")", ")", "self", ".", "keys", ".", "remove", "(", "ref...
Delete a key. (ref) Return None or LCDd response on error
[ "Delete", "a", "key", "." ]
python
train
masci/django-appengine-toolkit
appengine_toolkit/storage.py
https://github.com/masci/django-appengine-toolkit/blob/9ffe8b05a263889787fb34a3e28ebc66b1f0a1d2/appengine_toolkit/storage.py#L64-L68
def listdir(self, name): """ TODO collect directories """ return [], [obj.filename for obj in cloudstorage.listbucket(self.path(name))]
[ "def", "listdir", "(", "self", ",", "name", ")", ":", "return", "[", "]", ",", "[", "obj", ".", "filename", "for", "obj", "in", "cloudstorage", ".", "listbucket", "(", "self", ".", "path", "(", "name", ")", ")", "]" ]
TODO collect directories
[ "TODO", "collect", "directories" ]
python
train
ryanjdillon/pyotelem
pyotelem/plots/plotutils.py
https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotutils.py#L92-L101
def nsamples_to_minsec(x, pos): '''Convert axes labels to experiment duration in minutes/seconds Notes ----- Matplotlib FuncFormatter function https://matplotlib.org/examples/pylab_examples/custom_ticker1.html ''' h, m, s = hourminsec(x/16.0) return '{:2.0f}′ {:2.1f}″'.format(m+(h*60), ...
[ "def", "nsamples_to_minsec", "(", "x", ",", "pos", ")", ":", "h", ",", "m", ",", "s", "=", "hourminsec", "(", "x", "/", "16.0", ")", "return", "'{:2.0f}′ {:2.1f}″'.for", "m", "at(m+(", "h", "*", "6", "0", ")", ",", " s", ")", "", "", "" ]
Convert axes labels to experiment duration in minutes/seconds Notes ----- Matplotlib FuncFormatter function https://matplotlib.org/examples/pylab_examples/custom_ticker1.html
[ "Convert", "axes", "labels", "to", "experiment", "duration", "in", "minutes", "/", "seconds" ]
python
train
rasbt/biopandas
biopandas/pdb/pandas_pdb.py
https://github.com/rasbt/biopandas/blob/615a7cf272692c12bbcfd9d1f217eab440120235/biopandas/pdb/pandas_pdb.py#L95-L110
def fetch_pdb(self, pdb_code): """Fetches PDB file contents from the Protein Databank at rcsb.org. Parameters ---------- pdb_code : str A 4-letter PDB code, e.g., "3eiy". Returns --------- self """ self.pdb_path, self.pdb_text = self...
[ "def", "fetch_pdb", "(", "self", ",", "pdb_code", ")", ":", "self", ".", "pdb_path", ",", "self", ".", "pdb_text", "=", "self", ".", "_fetch_pdb", "(", "pdb_code", ")", "self", ".", "_df", "=", "self", ".", "_construct_df", "(", "pdb_lines", "=", "self...
Fetches PDB file contents from the Protein Databank at rcsb.org. Parameters ---------- pdb_code : str A 4-letter PDB code, e.g., "3eiy". Returns --------- self
[ "Fetches", "PDB", "file", "contents", "from", "the", "Protein", "Databank", "at", "rcsb", ".", "org", "." ]
python
train
adafruit/Adafruit_Python_BluefruitLE
Adafruit_BluefruitLE/corebluetooth/metadata.py
https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/corebluetooth/metadata.py#L71-L79
def add(self, cbobject, metadata): """Add the specified CoreBluetooth item with the associated metadata if it doesn't already exist. Returns the newly created or preexisting metadata item. """ with self._lock: if cbobject not in self._metadata: self._...
[ "def", "add", "(", "self", ",", "cbobject", ",", "metadata", ")", ":", "with", "self", ".", "_lock", ":", "if", "cbobject", "not", "in", "self", ".", "_metadata", ":", "self", ".", "_metadata", "[", "cbobject", "]", "=", "metadata", "return", "self", ...
Add the specified CoreBluetooth item with the associated metadata if it doesn't already exist. Returns the newly created or preexisting metadata item.
[ "Add", "the", "specified", "CoreBluetooth", "item", "with", "the", "associated", "metadata", "if", "it", "doesn", "t", "already", "exist", ".", "Returns", "the", "newly", "created", "or", "preexisting", "metadata", "item", "." ]
python
valid
boriel/zxbasic
arch/zx48k/optimizer.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L524-L535
def getv(self, r): """ Like the above, but returns the <int> value. """ v = self.get(r) if not is_unknown(v): try: v = int(v) except ValueError: v = None else: v = None return v
[ "def", "getv", "(", "self", ",", "r", ")", ":", "v", "=", "self", ".", "get", "(", "r", ")", "if", "not", "is_unknown", "(", "v", ")", ":", "try", ":", "v", "=", "int", "(", "v", ")", "except", "ValueError", ":", "v", "=", "None", "else", "...
Like the above, but returns the <int> value.
[ "Like", "the", "above", "but", "returns", "the", "<int", ">", "value", "." ]
python
train
Becksteinlab/GromacsWrapper
gromacs/run.py
https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L339-L358
def get_double_or_single_prec_mdrun(): """Return double precision ``mdrun`` or fall back to single precision. This convenience function tries :func:`gromacs.mdrun_d` first and if it cannot run it, falls back to :func:`gromacs.mdrun` (without further checking). .. versionadded:: 0.5.1 """ t...
[ "def", "get_double_or_single_prec_mdrun", "(", ")", ":", "try", ":", "gromacs", ".", "mdrun_d", "(", "h", "=", "True", ",", "stdout", "=", "False", ",", "stderr", "=", "False", ")", "logger", ".", "debug", "(", "\"using double precision gromacs.mdrun_d\"", ")"...
Return double precision ``mdrun`` or fall back to single precision. This convenience function tries :func:`gromacs.mdrun_d` first and if it cannot run it, falls back to :func:`gromacs.mdrun` (without further checking). .. versionadded:: 0.5.1
[ "Return", "double", "precision", "mdrun", "or", "fall", "back", "to", "single", "precision", "." ]
python
valid
mardix/Mocha
mocha/core.py
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/core.py#L858-L864
def _setup_db(cls): """ Setup the DB connection if DB_URL is set """ uri = cls._app.config.get("DB_URL") if uri: db.connect__(uri, cls._app)
[ "def", "_setup_db", "(", "cls", ")", ":", "uri", "=", "cls", ".", "_app", ".", "config", ".", "get", "(", "\"DB_URL\"", ")", "if", "uri", ":", "db", ".", "connect__", "(", "uri", ",", "cls", ".", "_app", ")" ]
Setup the DB connection if DB_URL is set
[ "Setup", "the", "DB", "connection", "if", "DB_URL", "is", "set" ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/textio.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L1296-L1328
def dump_registers(cls, registers, arch = None): """ Dump the x86/x64 processor register values. The output mimics that of the WinDBG debugger. @type registers: dict( str S{->} int ) @param registers: Dictionary mapping register names to their values. @type arch: str ...
[ "def", "dump_registers", "(", "cls", ",", "registers", ",", "arch", "=", "None", ")", ":", "if", "registers", "is", "None", ":", "return", "''", "if", "arch", "is", "None", ":", "if", "'Eax'", "in", "registers", ":", "arch", "=", "win32", ".", "ARCH_...
Dump the x86/x64 processor register values. The output mimics that of the WinDBG debugger. @type registers: dict( str S{->} int ) @param registers: Dictionary mapping register names to their values. @type arch: str @param arch: Architecture of the machine whose registers were...
[ "Dump", "the", "x86", "/", "x64", "processor", "register", "values", ".", "The", "output", "mimics", "that", "of", "the", "WinDBG", "debugger", "." ]
python
train
joytunes/JTLocalize
localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/create_localized_strings_from_ib_files.py#L106-L136
def add_string_pairs_from_attributed_ui_element(results, ui_element, comment_prefix): """ Adds string pairs from a UI element with attributed text Args: results (list): The list to add the results to. attributed_element (element): The element from the xib that contains, to extract the fragments...
[ "def", "add_string_pairs_from_attributed_ui_element", "(", "results", ",", "ui_element", ",", "comment_prefix", ")", ":", "attributed_strings", "=", "ui_element", ".", "getElementsByTagName", "(", "'attributedString'", ")", "if", "attributed_strings", ".", "length", "==",...
Adds string pairs from a UI element with attributed text Args: results (list): The list to add the results to. attributed_element (element): The element from the xib that contains, to extract the fragments from. comment_prefix (str): The prefix of the comment to use for extracted string ...
[ "Adds", "string", "pairs", "from", "a", "UI", "element", "with", "attributed", "text" ]
python
train
tensorflow/tensor2tensor
tensor2tensor/utils/metrics.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/metrics.py#L764-L778
def pearson_correlation_coefficient(predictions, labels, weights_fn=None): """Calculate pearson correlation coefficient. Args: predictions: The raw predictions. labels: The actual labels. weights_fn: Weighting function. Returns: The pearson correlation coefficient. """ del weights_fn _, pe...
[ "def", "pearson_correlation_coefficient", "(", "predictions", ",", "labels", ",", "weights_fn", "=", "None", ")", ":", "del", "weights_fn", "_", ",", "pearson", "=", "tf", ".", "contrib", ".", "metrics", ".", "streaming_pearson_correlation", "(", "predictions", ...
Calculate pearson correlation coefficient. Args: predictions: The raw predictions. labels: The actual labels. weights_fn: Weighting function. Returns: The pearson correlation coefficient.
[ "Calculate", "pearson", "correlation", "coefficient", "." ]
python
train
tritemio/PyBroMo
pybromo/psflib.py
https://github.com/tritemio/PyBroMo/blob/b75f82a4551ff37e7c7a7e6954c536451f3e6d06/pybromo/psflib.py#L120-L129
def hash(self): """Return an hash string computed on the PSF data.""" hash_list = [] for key, value in sorted(self.__dict__.items()): if not callable(value): if isinstance(value, np.ndarray): hash_list.append(value.tostring()) else:...
[ "def", "hash", "(", "self", ")", ":", "hash_list", "=", "[", "]", "for", "key", ",", "value", "in", "sorted", "(", "self", ".", "__dict__", ".", "items", "(", ")", ")", ":", "if", "not", "callable", "(", "value", ")", ":", "if", "isinstance", "("...
Return an hash string computed on the PSF data.
[ "Return", "an", "hash", "string", "computed", "on", "the", "PSF", "data", "." ]
python
valid
sibirrer/lenstronomy
lenstronomy/LensModel/Profiles/coreBurkert.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/coreBurkert.py#L113-L132
def coreBurkAlpha(self, R, Rs, rho0, r_core, ax_x, ax_y): """ deflection angle :param R: :param Rs: :param rho0: :param r_core: :param ax_x: :param ax_y: :return: """ x = R * Rs ** -1 p = Rs * r_core ** -1 gx = sel...
[ "def", "coreBurkAlpha", "(", "self", ",", "R", ",", "Rs", ",", "rho0", ",", "r_core", ",", "ax_x", ",", "ax_y", ")", ":", "x", "=", "R", "*", "Rs", "**", "-", "1", "p", "=", "Rs", "*", "r_core", "**", "-", "1", "gx", "=", "self", ".", "_G",...
deflection angle :param R: :param Rs: :param rho0: :param r_core: :param ax_x: :param ax_y: :return:
[ "deflection", "angle" ]
python
train
secdev/scapy
scapy/arch/bpf/supersocket.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/arch/bpf/supersocket.py#L289-L306
def recv(self, x=BPF_BUFFER_LENGTH): """Receive a frame from the network""" if self.buffered_frames(): # Get a frame from the buffer return self.get_frame() # Get data from BPF try: bpf_buffer = os.read(self.ins, x) except EnvironmentError as...
[ "def", "recv", "(", "self", ",", "x", "=", "BPF_BUFFER_LENGTH", ")", ":", "if", "self", ".", "buffered_frames", "(", ")", ":", "# Get a frame from the buffer", "return", "self", ".", "get_frame", "(", ")", "# Get data from BPF", "try", ":", "bpf_buffer", "=", ...
Receive a frame from the network
[ "Receive", "a", "frame", "from", "the", "network" ]
python
train
Autodesk/pyccc
pyccc/python.py
https://github.com/Autodesk/pyccc/blob/011698e78d49a83ac332e0578a4a2a865b75ef8d/pyccc/python.py#L292-L311
def prepare_namespace(self, func): """ Prepares the function to be run after deserializing it. Re-associates any previously bound variables and modules from the closure Returns: callable: ready-to-call function """ if self.is_imethod: to_run = get...
[ "def", "prepare_namespace", "(", "self", ",", "func", ")", ":", "if", "self", ".", "is_imethod", ":", "to_run", "=", "getattr", "(", "self", ".", "obj", ",", "self", ".", "imethod_name", ")", "else", ":", "to_run", "=", "func", "for", "varname", ",", ...
Prepares the function to be run after deserializing it. Re-associates any previously bound variables and modules from the closure Returns: callable: ready-to-call function
[ "Prepares", "the", "function", "to", "be", "run", "after", "deserializing", "it", ".", "Re", "-", "associates", "any", "previously", "bound", "variables", "and", "modules", "from", "the", "closure" ]
python
train
Chilipp/docrep
docrep/__init__.py
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L45-L105
def safe_modulo(s, meta, checked='', print_warning=True, stacklevel=2): """Safe version of the modulo operation (%) of strings Parameters ---------- s: str string to apply the modulo operation with meta: dict or tuple meta informations to insert (usually via ``s % meta``) checke...
[ "def", "safe_modulo", "(", "s", ",", "meta", ",", "checked", "=", "''", ",", "print_warning", "=", "True", ",", "stacklevel", "=", "2", ")", ":", "try", ":", "return", "s", "%", "meta", "except", "(", "ValueError", ",", "TypeError", ",", "KeyError", ...
Safe version of the modulo operation (%) of strings Parameters ---------- s: str string to apply the modulo operation with meta: dict or tuple meta informations to insert (usually via ``s % meta``) checked: {'KEY', 'VALUE'}, optional Security parameter for the recursive stru...
[ "Safe", "version", "of", "the", "modulo", "operation", "(", "%", ")", "of", "strings" ]
python
train
cltk/cltk
cltk/prosody/old_norse/verse.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/prosody/old_norse/verse.py#L357-L372
def from_short_lines_text(self, text: str): """ Example from Völsupá 28 >>> stanza = "Ein sat hon úti,\\nþá er inn aldni kom\\nyggjungr ása\\nok í augu leit.\\nHvers fregnið mik?\\nHví freistið mín?\\nAllt veit ek, Óðinn,\\nhvar þú auga falt,\\ní inum mæra\\nMímisbrunni.\\nDrekkr mjöð Mímir\\nmo...
[ "def", "from_short_lines_text", "(", "self", ",", "text", ":", "str", ")", ":", "Metre", ".", "from_short_lines_text", "(", "self", ",", "text", ")", "self", ".", "short_lines", "=", "[", "ShortLine", "(", "line", ")", "for", "line", "in", "text", ".", ...
Example from Völsupá 28 >>> stanza = "Ein sat hon úti,\\nþá er inn aldni kom\\nyggjungr ása\\nok í augu leit.\\nHvers fregnið mik?\\nHví freistið mín?\\nAllt veit ek, Óðinn,\\nhvar þú auga falt,\\ní inum mæra\\nMímisbrunni.\\nDrekkr mjöð Mímir\\nmorgun hverjan\\naf veði Valföðrs.\\nVituð ér enn - eða hvat?" ...
[ "Example", "from", "Völsupá", "28", ">>>", "stanza", "=", "Ein", "sat", "hon", "úti", "\\\\", "nþá", "er", "inn", "aldni", "kom", "\\\\", "nyggjungr", "ása", "\\\\", "nok", "í", "augu", "leit", ".", "\\\\", "nHvers", "fregnið", "mik?", "\\\\", "nHví", ...
python
train
sassoftware/saspy
saspy/sasViyaML.py
https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasViyaML.py#L303-L337
def svmachine(self, data: ['SASdata', str] = None, autotune: str = None, code: str = None, id: str = None, input: [str, list, dict] = None, kernel: str = None, output: [str, bool, 'SASdata'] = None, ...
[ "def", "svmachine", "(", "self", ",", "data", ":", "[", "'SASdata'", ",", "str", "]", "=", "None", ",", "autotune", ":", "str", "=", "None", ",", "code", ":", "str", "=", "None", ",", "id", ":", "str", "=", "None", ",", "input", ":", "[", "str"...
Python method to call the SVMACHINE procedure Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_svmachine_toc.htm&docsetVersion=8.3&locale=en :param data: SASdata object or string. This parameter is required. :parm autotune: The autotune variable c...
[ "Python", "method", "to", "call", "the", "SVMACHINE", "procedure" ]
python
train
sibirrer/lenstronomy
lenstronomy/Workflow/psf_fitting.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Workflow/psf_fitting.py#L146-L169
def image_single_point_source(self, image_model_class, kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps): """ return model without including the point source contributions as a list (for each point source individually) :param image_model_class: ImageMode...
[ "def", "image_single_point_source", "(", "self", ",", "image_model_class", ",", "kwargs_lens", ",", "kwargs_source", ",", "kwargs_lens_light", ",", "kwargs_ps", ")", ":", "# reconstructed model with given psf", "model", ",", "error_map", ",", "cov_param", ",", "param", ...
return model without including the point source contributions as a list (for each point source individually) :param image_model_class: ImageModel class instance :param kwargs_lens: lens model kwargs list :param kwargs_source: source model kwargs list :param kwargs_lens_light: lens light ...
[ "return", "model", "without", "including", "the", "point", "source", "contributions", "as", "a", "list", "(", "for", "each", "point", "source", "individually", ")", ":", "param", "image_model_class", ":", "ImageModel", "class", "instance", ":", "param", "kwargs_...
python
train
paylogic/pip-accel
pip_accel/config.py
https://github.com/paylogic/pip-accel/blob/ccad1b784927a322d996db593403b1d2d2e22666/pip_accel/config.py#L123-L143
def load_configuration_file(self, configuration_file): """ Load configuration defaults from a configuration file. :param configuration_file: The pathname of a configuration file (a string). :raises: :exc:`Exception` when the configuration file cannot b...
[ "def", "load_configuration_file", "(", "self", ",", "configuration_file", ")", ":", "configuration_file", "=", "parse_path", "(", "configuration_file", ")", "logger", ".", "debug", "(", "\"Loading configuration file: %s\"", ",", "configuration_file", ")", "parser", "=",...
Load configuration defaults from a configuration file. :param configuration_file: The pathname of a configuration file (a string). :raises: :exc:`Exception` when the configuration file cannot be loaded.
[ "Load", "configuration", "defaults", "from", "a", "configuration", "file", "." ]
python
train
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/bindepend.py#L499-L542
def findLibrary(name): """ Look for a library in the system. Emulate the algorithm used by dlopen. `name`must include the prefix, e.g. ``libpython2.4.so`` """ assert is_unix, "Current implementation for Unix only (Linux, Solaris, AIX)" lib = None # Look in the LD_LIBRARY_PATH lp =...
[ "def", "findLibrary", "(", "name", ")", ":", "assert", "is_unix", ",", "\"Current implementation for Unix only (Linux, Solaris, AIX)\"", "lib", "=", "None", "# Look in the LD_LIBRARY_PATH", "lp", "=", "compat", ".", "getenv", "(", "'LD_LIBRARY_PATH'", ",", "''", ")", ...
Look for a library in the system. Emulate the algorithm used by dlopen. `name`must include the prefix, e.g. ``libpython2.4.so``
[ "Look", "for", "a", "library", "in", "the", "system", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_ip_policy.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_ip_policy.py#L44-L58
def hide_routemap_holder_route_map_instance(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") hide_routemap_holder = ET.SubElement(config, "hide-routemap-holder", xmlns="urn:brocade.com:mgmt:brocade-ip-policy") route_map = ET.SubElement(hide_routemap_holde...
[ "def", "hide_routemap_holder_route_map_instance", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "hide_routemap_holder", "=", "ET", ".", "SubElement", "(", "config", ",", "\"hide-routemap-holder\"", "...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
ladybug-tools/uwg
uwg/element.py
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/element.py#L233-L254
def qsat(self,temp,pres,parameter): """ Calculate (qsat_lst) vector of saturation humidity from: temp = vector of element layer temperatures pres = pressure (at current timestep). """ gamw = (parameter.cl - parameter.cpv) / parameter.rv betaw = (parameter....
[ "def", "qsat", "(", "self", ",", "temp", ",", "pres", ",", "parameter", ")", ":", "gamw", "=", "(", "parameter", ".", "cl", "-", "parameter", ".", "cpv", ")", "/", "parameter", ".", "rv", "betaw", "=", "(", "parameter", ".", "lvtt", "/", "parameter...
Calculate (qsat_lst) vector of saturation humidity from: temp = vector of element layer temperatures pres = pressure (at current timestep).
[ "Calculate", "(", "qsat_lst", ")", "vector", "of", "saturation", "humidity", "from", ":", "temp", "=", "vector", "of", "element", "layer", "temperatures", "pres", "=", "pressure", "(", "at", "current", "timestep", ")", "." ]
python
train
Erotemic/utool
utool/util_hash.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_hash.py#L829-L897
def get_file_hash(fpath, blocksize=65536, hasher=None, stride=1, hexdigest=False): r""" For better hashes use hasher=hashlib.sha256, and keep stride=1 Args: fpath (str): file path string blocksize (int): 2 ** 16. Affects speed of reading file hasher (None): defau...
[ "def", "get_file_hash", "(", "fpath", ",", "blocksize", "=", "65536", ",", "hasher", "=", "None", ",", "stride", "=", "1", ",", "hexdigest", "=", "False", ")", ":", "if", "hasher", "is", "None", ":", "hasher", "=", "hashlib", ".", "sha1", "(", ")", ...
r""" For better hashes use hasher=hashlib.sha256, and keep stride=1 Args: fpath (str): file path string blocksize (int): 2 ** 16. Affects speed of reading file hasher (None): defaults to sha1 for fast (but insecure) hashing stride (int): strides > 1 skip data to hash, useful f...
[ "r", "For", "better", "hashes", "use", "hasher", "=", "hashlib", ".", "sha256", "and", "keep", "stride", "=", "1" ]
python
train
python-openxml/python-docx
docx/text/parfmt.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/text/parfmt.py#L114-L128
def line_spacing(self): """ |float| or |Length| value specifying the space between baselines in successive lines of the paragraph. A value of |None| indicates line spacing is inherited from the style hierarchy. A float value, e.g. ``2.0`` or ``1.75``, indicates spacing is applied...
[ "def", "line_spacing", "(", "self", ")", ":", "pPr", "=", "self", ".", "_element", ".", "pPr", "if", "pPr", "is", "None", ":", "return", "None", "return", "self", ".", "_line_spacing", "(", "pPr", ".", "spacing_line", ",", "pPr", ".", "spacing_lineRule",...
|float| or |Length| value specifying the space between baselines in successive lines of the paragraph. A value of |None| indicates line spacing is inherited from the style hierarchy. A float value, e.g. ``2.0`` or ``1.75``, indicates spacing is applied in multiples of line heights. A |Le...
[ "|float|", "or", "|Length|", "value", "specifying", "the", "space", "between", "baselines", "in", "successive", "lines", "of", "the", "paragraph", ".", "A", "value", "of", "|None|", "indicates", "line", "spacing", "is", "inherited", "from", "the", "style", "hi...
python
train
DataDog/integrations-core
datadog_checks_dev/datadog_checks/dev/tooling/requirements.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/requirements.py#L163-L174
def read_packages(reqs_file): """ Generator yielding one Package instance for every corresponing line in a requirements file """ for line in stream_file_lines(reqs_file): line = line.strip() if not line.startswith(('#', '--hash')): match = DEP_PATTERN.match(line) ...
[ "def", "read_packages", "(", "reqs_file", ")", ":", "for", "line", "in", "stream_file_lines", "(", "reqs_file", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "not", "line", ".", "startswith", "(", "(", "'#'", ",", "'--hash'", ")", ")", ...
Generator yielding one Package instance for every corresponing line in a requirements file
[ "Generator", "yielding", "one", "Package", "instance", "for", "every", "corresponing", "line", "in", "a", "requirements", "file" ]
python
train
HewlettPackard/python-hpOneView
hpOneView/oneview_client.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/oneview_client.py#L1081-L1090
def certificate_rabbitmq(self): """ Gets the Certificate RabbitMQ API client. Returns: CertificateRabbitMQ: """ if not self.__certificate_rabbitmq: self.__certificate_rabbitmq = CertificateRabbitMQ(self.__connection) return self.__certificate_rabb...
[ "def", "certificate_rabbitmq", "(", "self", ")", ":", "if", "not", "self", ".", "__certificate_rabbitmq", ":", "self", ".", "__certificate_rabbitmq", "=", "CertificateRabbitMQ", "(", "self", ".", "__connection", ")", "return", "self", ".", "__certificate_rabbitmq" ]
Gets the Certificate RabbitMQ API client. Returns: CertificateRabbitMQ:
[ "Gets", "the", "Certificate", "RabbitMQ", "API", "client", "." ]
python
train
sendgrid/sendgrid-python
sendgrid/helpers/mail/mail.py
https://github.com/sendgrid/sendgrid-python/blob/266c2abde7a35dfcce263e06bedc6a0bbdebeac9/sendgrid/helpers/mail/mail.py#L500-L526
def add_substitution(self, substitution): """Add a substitution to the email :param value: Add a substitution to the email :type value: Substitution """ if substitution.personalization: try: personalization = \ self._personalizatio...
[ "def", "add_substitution", "(", "self", ",", "substitution", ")", ":", "if", "substitution", ".", "personalization", ":", "try", ":", "personalization", "=", "self", ".", "_personalizations", "[", "substitution", ".", "personalization", "]", "has_internal_personaliz...
Add a substitution to the email :param value: Add a substitution to the email :type value: Substitution
[ "Add", "a", "substitution", "to", "the", "email" ]
python
train
mattjj/pybasicbayes
pybasicbayes/util/stats.py
https://github.com/mattjj/pybasicbayes/blob/76aef00f011415cc5c858cd1a101f3aab971a62d/pybasicbayes/util/stats.py#L124-L150
def sample_truncated_gaussian(mu=0, sigma=1, lb=-np.Inf, ub=np.Inf): """ Sample a truncated normal with the specified params. This is not the most stable way but it works as long as the truncation region is not too far from the mean. """ # Broadcast arrays to be of the same shape mu, sigma, ...
[ "def", "sample_truncated_gaussian", "(", "mu", "=", "0", ",", "sigma", "=", "1", ",", "lb", "=", "-", "np", ".", "Inf", ",", "ub", "=", "np", ".", "Inf", ")", ":", "# Broadcast arrays to be of the same shape", "mu", ",", "sigma", ",", "lb", ",", "ub", ...
Sample a truncated normal with the specified params. This is not the most stable way but it works as long as the truncation region is not too far from the mean.
[ "Sample", "a", "truncated", "normal", "with", "the", "specified", "params", ".", "This", "is", "not", "the", "most", "stable", "way", "but", "it", "works", "as", "long", "as", "the", "truncation", "region", "is", "not", "too", "far", "from", "the", "mean...
python
train
janpipek/physt
physt/histogram1d.py
https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram1d.py#L208-L220
def mean(self) -> Optional[float]: """Statistical mean of all values entered into histogram. This number is precise, because we keep the necessary data separate from bin contents. """ if self._stats: # TODO: should be true always? if self.total > 0: ...
[ "def", "mean", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "if", "self", ".", "_stats", ":", "# TODO: should be true always?", "if", "self", ".", "total", ">", "0", ":", "return", "self", ".", "_stats", "[", "\"sum\"", "]", "/", "self",...
Statistical mean of all values entered into histogram. This number is precise, because we keep the necessary data separate from bin contents.
[ "Statistical", "mean", "of", "all", "values", "entered", "into", "histogram", "." ]
python
train
mandiant/ioc_writer
ioc_writer/ioc_common.py
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_common.py#L951-L963
def make_serviceitem_servicedllmd5sum(servicedll_md5, condition='is', negate=False): """ Create a node for ServiceItem/serviceDLLmd5sum :return: A IndicatorItem represented as an Element node """ document = 'ServiceItem' search = 'ServiceItem/serviceDLLmd5sum' content_type = 'md5' c...
[ "def", "make_serviceitem_servicedllmd5sum", "(", "servicedll_md5", ",", "condition", "=", "'is'", ",", "negate", "=", "False", ")", ":", "document", "=", "'ServiceItem'", "search", "=", "'ServiceItem/serviceDLLmd5sum'", "content_type", "=", "'md5'", "content", "=", ...
Create a node for ServiceItem/serviceDLLmd5sum :return: A IndicatorItem represented as an Element node
[ "Create", "a", "node", "for", "ServiceItem", "/", "serviceDLLmd5sum", ":", "return", ":", "A", "IndicatorItem", "represented", "as", "an", "Element", "node" ]
python
train
tnkteja/myhelp
virtualEnvironment/lib/python2.7/site-packages/coverage/files.py
https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/files.py#L288-L309
def find_python_files(dirname): """Yield all of the importable Python files in `dirname`, recursively. To be importable, the files have to be in a directory with a __init__.py, except for `dirname` itself, which isn't required to have one. The assumption is that `dirname` was specified directly, so th...
[ "def", "find_python_files", "(", "dirname", ")", ":", "for", "i", ",", "(", "dirpath", ",", "dirnames", ",", "filenames", ")", "in", "enumerate", "(", "os", ".", "walk", "(", "dirname", ")", ")", ":", "if", "i", ">", "0", "and", "'__init__.py'", "not...
Yield all of the importable Python files in `dirname`, recursively. To be importable, the files have to be in a directory with a __init__.py, except for `dirname` itself, which isn't required to have one. The assumption is that `dirname` was specified directly, so the user knows best, but subdirectori...
[ "Yield", "all", "of", "the", "importable", "Python", "files", "in", "dirname", "recursively", "." ]
python
test
Alignak-monitoring/alignak
alignak/objects/satellitelink.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/satellitelink.py#L937-L949
def get_broks(self, broker_name): """Send a HTTP request to the satellite (GET /_broks) Get broks from the satellite. Un-serialize data received. :param broker_name: the concerned broker link :type broker_name: BrokerLink :return: Broks list on success, [] on failure ...
[ "def", "get_broks", "(", "self", ",", "broker_name", ")", ":", "res", "=", "self", ".", "con", ".", "get", "(", "'_broks'", ",", "{", "'broker_name'", ":", "broker_name", "}", ",", "wait", "=", "False", ")", "logger", ".", "debug", "(", "\"Got broks fr...
Send a HTTP request to the satellite (GET /_broks) Get broks from the satellite. Un-serialize data received. :param broker_name: the concerned broker link :type broker_name: BrokerLink :return: Broks list on success, [] on failure :rtype: list
[ "Send", "a", "HTTP", "request", "to", "the", "satellite", "(", "GET", "/", "_broks", ")", "Get", "broks", "from", "the", "satellite", ".", "Un", "-", "serialize", "data", "received", "." ]
python
train
saltstack/salt
salt/renderers/cheetah.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/renderers/cheetah.py#L19-L36
def render(cheetah_data, saltenv='base', sls='', method='xml', **kws): ''' Render a Cheetah template. :rtype: A Python data structure ''' if not HAS_LIBS: return {} if not isinstance(cheetah_data, six.string_types): cheetah_data = cheetah_data.read() if cheetah_data.starts...
[ "def", "render", "(", "cheetah_data", ",", "saltenv", "=", "'base'", ",", "sls", "=", "''", ",", "method", "=", "'xml'", ",", "*", "*", "kws", ")", ":", "if", "not", "HAS_LIBS", ":", "return", "{", "}", "if", "not", "isinstance", "(", "cheetah_data",...
Render a Cheetah template. :rtype: A Python data structure
[ "Render", "a", "Cheetah", "template", "." ]
python
train
samuelcolvin/pydantic
pydantic/utils.py
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L120-L134
def import_string(dotted_path: str) -> Any: """ Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import fails. """ try: module_path, class_name = dotted_path.strip(' ').rsplit('.', 1...
[ "def", "import_string", "(", "dotted_path", ":", "str", ")", "->", "Any", ":", "try", ":", "module_path", ",", "class_name", "=", "dotted_path", ".", "strip", "(", "' '", ")", ".", "rsplit", "(", "'.'", ",", "1", ")", "except", "ValueError", "as", "e",...
Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import fails.
[ "Stolen", "approximately", "from", "django", ".", "Import", "a", "dotted", "module", "path", "and", "return", "the", "attribute", "/", "class", "designated", "by", "the", "last", "name", "in", "the", "path", ".", "Raise", "ImportError", "if", "the", "import"...
python
train
senaite/senaite.jsonapi
src/senaite/jsonapi/api.py
https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L560-L570
def search(**kw): """Search the catalog adapter :returns: Catalog search results :rtype: iterable """ portal = get_portal() catalog = ICatalog(portal) catalog_query = ICatalogQuery(catalog) query = catalog_query.make_query(**kw) return catalog(query)
[ "def", "search", "(", "*", "*", "kw", ")", ":", "portal", "=", "get_portal", "(", ")", "catalog", "=", "ICatalog", "(", "portal", ")", "catalog_query", "=", "ICatalogQuery", "(", "catalog", ")", "query", "=", "catalog_query", ".", "make_query", "(", "*",...
Search the catalog adapter :returns: Catalog search results :rtype: iterable
[ "Search", "the", "catalog", "adapter" ]
python
train
oceanprotocol/squid-py
squid_py/agreements/service_agreement.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement.py#L226-L245
def get_service_agreement_hash( self, agreement_id, asset_id, consumer_address, publisher_address, keeper): """Return the hash of the service agreement values to be signed by a consumer. :param agreement_id:id of the agreement, hex str :param asset_id: :param consumer_addres...
[ "def", "get_service_agreement_hash", "(", "self", ",", "agreement_id", ",", "asset_id", ",", "consumer_address", ",", "publisher_address", ",", "keeper", ")", ":", "agreement_hash", "=", "ServiceAgreement", ".", "generate_service_agreement_hash", "(", "self", ".", "te...
Return the hash of the service agreement values to be signed by a consumer. :param agreement_id:id of the agreement, hex str :param asset_id: :param consumer_address: ethereum account address of consumer, hex str :param publisher_address: ethereum account address of publisher, hex str ...
[ "Return", "the", "hash", "of", "the", "service", "agreement", "values", "to", "be", "signed", "by", "a", "consumer", "." ]
python
train
pudo-attic/scrapekit
scrapekit/tasks.py
https://github.com/pudo-attic/scrapekit/blob/cfd258120922fcd571430cdf00ba50f3cf18dc15/scrapekit/tasks.py#L176-L188
def pipe(self, other_task): """ Add a pipe listener to the execution of this task. The output of this task is required to be an iterable. Each item in the iterable will be queued as the sole argument to an execution of the listener task. Can also be written as:: pip...
[ "def", "pipe", "(", "self", ",", "other_task", ")", ":", "other_task", ".", "_source", "=", "self", "self", ".", "_listeners", ".", "append", "(", "PipeListener", "(", "other_task", ")", ")", "return", "other_task" ]
Add a pipe listener to the execution of this task. The output of this task is required to be an iterable. Each item in the iterable will be queued as the sole argument to an execution of the listener task. Can also be written as:: pipeline = task1 | task2
[ "Add", "a", "pipe", "listener", "to", "the", "execution", "of", "this", "task", ".", "The", "output", "of", "this", "task", "is", "required", "to", "be", "an", "iterable", ".", "Each", "item", "in", "the", "iterable", "will", "be", "queued", "as", "the...
python
train
gem/oq-engine
openquake/hazardlib/gsim/rietbrock_2013.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L109-L120
def _get_distance_scaling_term(self, C, rjb, mag): """ Returns the distance scaling component of the model Equation 10, Page 63 """ # Depth adjusted distance, equation 11 (Page 63) rval = np.sqrt(rjb ** 2.0 + C["c11"] ** 2.0) f_0, f_1, f_2 = self._get_distance_seg...
[ "def", "_get_distance_scaling_term", "(", "self", ",", "C", ",", "rjb", ",", "mag", ")", ":", "# Depth adjusted distance, equation 11 (Page 63)", "rval", "=", "np", ".", "sqrt", "(", "rjb", "**", "2.0", "+", "C", "[", "\"c11\"", "]", "**", "2.0", ")", "f_0...
Returns the distance scaling component of the model Equation 10, Page 63
[ "Returns", "the", "distance", "scaling", "component", "of", "the", "model", "Equation", "10", "Page", "63" ]
python
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_image_attention.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_image_attention.py#L558-L569
def prepare_encoder(inputs, hparams, attention_type="local_1d"): """Prepare encoder for images.""" x = prepare_image(inputs, hparams, name="enc_channels") # Add position signals. x = add_pos_signals(x, hparams, "enc_pos") x_shape = common_layers.shape_list(x) if attention_type == "local_1d": x = tf.resh...
[ "def", "prepare_encoder", "(", "inputs", ",", "hparams", ",", "attention_type", "=", "\"local_1d\"", ")", ":", "x", "=", "prepare_image", "(", "inputs", ",", "hparams", ",", "name", "=", "\"enc_channels\"", ")", "# Add position signals.", "x", "=", "add_pos_sign...
Prepare encoder for images.
[ "Prepare", "encoder", "for", "images", "." ]
python
train
piotr-rusin/spam-lists
spam_lists/validation.py
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/validation.py#L15-L22
def is_valid_host(value): """Check if given value is a valid host string. :param value: a value to test :returns: True if the value is valid """ host_validators = validators.ipv4, validators.ipv6, validators.domain return any(f(value) for f in host_validators)
[ "def", "is_valid_host", "(", "value", ")", ":", "host_validators", "=", "validators", ".", "ipv4", ",", "validators", ".", "ipv6", ",", "validators", ".", "domain", "return", "any", "(", "f", "(", "value", ")", "for", "f", "in", "host_validators", ")" ]
Check if given value is a valid host string. :param value: a value to test :returns: True if the value is valid
[ "Check", "if", "given", "value", "is", "a", "valid", "host", "string", "." ]
python
train
plivo/sharq
sharq/utils.py
https://github.com/plivo/sharq/blob/32bbfbdcbbaa8e154271ffd125ac4500382f3d19/sharq/utils.py#L9-L28
def is_valid_identifier(identifier): """Checks if the given identifier is valid or not. A valid identifier may consists of the following characters with a maximum length of 100 characters, minimum of 1 character. Valid characters for an identifier, - A to Z - a to z - 0 to 9 ...
[ "def", "is_valid_identifier", "(", "identifier", ")", ":", "if", "not", "isinstance", "(", "identifier", ",", "basestring", ")", ":", "return", "False", "if", "len", "(", "identifier", ")", ">", "100", "or", "len", "(", "identifier", ")", "<", "1", ":", ...
Checks if the given identifier is valid or not. A valid identifier may consists of the following characters with a maximum length of 100 characters, minimum of 1 character. Valid characters for an identifier, - A to Z - a to z - 0 to 9 - _ (underscore) - - (hypen)
[ "Checks", "if", "the", "given", "identifier", "is", "valid", "or", "not", ".", "A", "valid", "identifier", "may", "consists", "of", "the", "following", "characters", "with", "a", "maximum", "length", "of", "100", "characters", "minimum", "of", "1", "characte...
python
train
ModisWorks/modis
modis/discord_modis/modules/music/_musicplayer.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L892-L909
def update_queue(self): """Updates the queue in the music player """ self.logger.debug("Updating queue display") queue_display = [] for i in range(self.queue_display): try: if len(self.queue[i][1]) > 40: songname = self.queue[i][1][:37] +...
[ "def", "update_queue", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Updating queue display\"", ")", "queue_display", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "queue_display", ")", ":", "try", ":", "if", "len", ...
Updates the queue in the music player
[ "Updates", "the", "queue", "in", "the", "music", "player" ]
python
train
pantsbuild/pants
src/python/pants/option/parser.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/option/parser.py#L267-L283
def _unnormalized_option_registrations_iter(self): """Returns an iterator over the raw registration arguments of each option in this parser. Each yielded item is an (args, kwargs) pair, exactly as passed to register(), except for substituting list and dict types with list_option/dict_option. Note that...
[ "def", "_unnormalized_option_registrations_iter", "(", "self", ")", ":", "# First yield any recursive options we inherit from our parent.", "if", "self", ".", "_parent_parser", ":", "for", "args", ",", "kwargs", "in", "self", ".", "_parent_parser", ".", "_recursive_option_r...
Returns an iterator over the raw registration arguments of each option in this parser. Each yielded item is an (args, kwargs) pair, exactly as passed to register(), except for substituting list and dict types with list_option/dict_option. Note that recursive options we inherit from a parent will also be y...
[ "Returns", "an", "iterator", "over", "the", "raw", "registration", "arguments", "of", "each", "option", "in", "this", "parser", "." ]
python
train
gabstopper/smc-python
smc/vpn/elements.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/vpn/elements.py#L436-L455
def create(self, name, site_element): """ Create a VPN site for an internal or external gateway :param str name: name of site :param list site_element: list of protected networks/hosts :type site_element: list[str,Element] :raises CreateElementFailed: create element fail...
[ "def", "create", "(", "self", ",", "name", ",", "site_element", ")", ":", "site_element", "=", "element_resolver", "(", "site_element", ")", "json", "=", "{", "'name'", ":", "name", ",", "'site_element'", ":", "site_element", "}", "return", "ElementCreator", ...
Create a VPN site for an internal or external gateway :param str name: name of site :param list site_element: list of protected networks/hosts :type site_element: list[str,Element] :raises CreateElementFailed: create element failed with reason :return: href of new element ...
[ "Create", "a", "VPN", "site", "for", "an", "internal", "or", "external", "gateway" ]
python
train
pytest-dev/pytest-xprocess
xprocess.py
https://github.com/pytest-dev/pytest-xprocess/blob/c3ee760b02dce2d0eed960b3ab0e28379853c3ef/xprocess.py#L78-L135
def ensure(self, name, preparefunc, restart=False): """ returns (PID, logfile) from a newly started or already running process. @param name: name of the external process, used for caching info across test runs. @param preparefunc: A subclass of ...
[ "def", "ensure", "(", "self", ",", "name", ",", "preparefunc", ",", "restart", "=", "False", ")", ":", "from", "subprocess", "import", "Popen", ",", "STDOUT", "info", "=", "self", ".", "getinfo", "(", "name", ")", "if", "not", "restart", "and", "not", ...
returns (PID, logfile) from a newly started or already running process. @param name: name of the external process, used for caching info across test runs. @param preparefunc: A subclass of ProcessStarter. @param restart: force restarting the pr...
[ "returns", "(", "PID", "logfile", ")", "from", "a", "newly", "started", "or", "already", "running", "process", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/models/image_transformer.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer.py#L779-L786
def imagetransformer_sep_channels_16l_16h_imgnet_lrg_loc_128(): """separate rgb embeddings.""" hparams = imagetransformer_sep_channels_12l_16h_imagenet_large() hparams.num_hidden_layers = 16 hparams.local_attention = True hparams.batch_size = 1 hparams.block_length = 128 return hparams
[ "def", "imagetransformer_sep_channels_16l_16h_imgnet_lrg_loc_128", "(", ")", ":", "hparams", "=", "imagetransformer_sep_channels_12l_16h_imagenet_large", "(", ")", "hparams", ".", "num_hidden_layers", "=", "16", "hparams", ".", "local_attention", "=", "True", "hparams", "."...
separate rgb embeddings.
[ "separate", "rgb", "embeddings", "." ]
python
train
openvax/topiary
topiary/rna/cufflinks.py
https://github.com/openvax/topiary/blob/04f0077bc4bf1ad350a0e78c26fa48c55fe7813b/topiary/rna/cufflinks.py#L234-L243
def load_cufflinks_fpkm_dict(*args, **kwargs): """ Returns dictionary mapping feature identifier (either transcript or gene ID) to FPKM expression value. """ return { row.id: row.fpkm for (_, row) in load_cufflinks_dataframe(*args, **kwargs).iterrows() }
[ "def", "load_cufflinks_fpkm_dict", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "{", "row", ".", "id", ":", "row", ".", "fpkm", "for", "(", "_", ",", "row", ")", "in", "load_cufflinks_dataframe", "(", "*", "args", ",", "*", "*", "...
Returns dictionary mapping feature identifier (either transcript or gene ID) to FPKM expression value.
[ "Returns", "dictionary", "mapping", "feature", "identifier", "(", "either", "transcript", "or", "gene", "ID", ")", "to", "FPKM", "expression", "value", "." ]
python
train
googleapis/google-cloud-python
spanner/google/cloud/spanner_v1/database.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/database.py#L242-L255
def reload(self): """Reload this database. Refresh any configured schema into :attr:`ddl_statements`. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDDL :raises NotFound: if the data...
[ "def", "reload", "(", "self", ")", ":", "api", "=", "self", ".", "_instance", ".", "_client", ".", "database_admin_api", "metadata", "=", "_metadata_with_prefix", "(", "self", ".", "name", ")", "response", "=", "api", ".", "get_database_ddl", "(", "self", ...
Reload this database. Refresh any configured schema into :attr:`ddl_statements`. See https://cloud.google.com/spanner/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDDL :raises NotFound: if the database does not exist
[ "Reload", "this", "database", "." ]
python
train
mongolab/mongoctl
mongoctl/utils.py
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/utils.py#L253-L268
def is_same_host(host1, host2): """ Returns true if host1 == host2 OR map to the same host (using DNS) """ try: if host1 == host2: return True else: ips1 = get_host_ips(host1) ips2 = get_host_ips(host2) return len(set(ips1) & set(ips2)) >...
[ "def", "is_same_host", "(", "host1", ",", "host2", ")", ":", "try", ":", "if", "host1", "==", "host2", ":", "return", "True", "else", ":", "ips1", "=", "get_host_ips", "(", "host1", ")", "ips2", "=", "get_host_ips", "(", "host2", ")", "return", "len", ...
Returns true if host1 == host2 OR map to the same host (using DNS)
[ "Returns", "true", "if", "host1", "==", "host2", "OR", "map", "to", "the", "same", "host", "(", "using", "DNS", ")" ]
python
train
rocky/python-xdis
xdis/verify.py
https://github.com/rocky/python-xdis/blob/46a2902ae8f5d8eee495eed67ac0690fd545453d/xdis/verify.py#L101-L151
def verify_file(real_source_filename, real_bytecode_filename): """Compile *real_source_filename* using the running Python interpreter. Then write bytecode out to a new place again using Python's routines. Next load it in using two of our routines. Compare that the code objects there are equal. ...
[ "def", "verify_file", "(", "real_source_filename", ",", "real_bytecode_filename", ")", ":", "tempdir", "=", "tempfile", ".", "gettempdir", "(", ")", "source_filename", "=", "os", ".", "path", ".", "join", "(", "tempdir", ",", "\"testing.py\"", ")", "if", "not"...
Compile *real_source_filename* using the running Python interpreter. Then write bytecode out to a new place again using Python's routines. Next load it in using two of our routines. Compare that the code objects there are equal. Next write out the bytecode (using the same Python bytecode w...
[ "Compile", "*", "real_source_filename", "*", "using", "the", "running", "Python", "interpreter", ".", "Then", "write", "bytecode", "out", "to", "a", "new", "place", "again", "using", "Python", "s", "routines", "." ]
python
train
inasafe/inasafe
safe/gui/tools/shake_grid/shake_grid.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/shake_grid/shake_grid.py#L453-L491
def mmi_to_vrt(self, force_flag=True): """Save the mmi_data to an ogr vrt text file. :param force_flag: Whether to force the regeneration of the output file. Defaults to False. :type force_flag: bool :returns: The absolute file system path to the .vrt text file. :rt...
[ "def", "mmi_to_vrt", "(", "self", ",", "force_flag", "=", "True", ")", ":", "# Ensure the delimited mmi file exists", "LOGGER", ".", "debug", "(", "'mmi_to_vrt requested.'", ")", "vrt_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "output_dir", ...
Save the mmi_data to an ogr vrt text file. :param force_flag: Whether to force the regeneration of the output file. Defaults to False. :type force_flag: bool :returns: The absolute file system path to the .vrt text file. :rtype: str :raises: None
[ "Save", "the", "mmi_data", "to", "an", "ogr", "vrt", "text", "file", "." ]
python
train
matiasb/python-unrar
unrar/rarfile.py
https://github.com/matiasb/python-unrar/blob/b1ac46cbcf42f3d3c5c69ab971fe97369a4da617/unrar/rarfile.py#L315-L323
def extractall(self, path=None, members=None, pwd=None): """Extract all members from the archive to the current working directory. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by namelist(). """ ...
[ "def", "extractall", "(", "self", ",", "path", "=", "None", ",", "members", "=", "None", ",", "pwd", "=", "None", ")", ":", "if", "members", "is", "None", ":", "members", "=", "self", ".", "namelist", "(", ")", "self", ".", "_extract_members", "(", ...
Extract all members from the archive to the current working directory. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by namelist().
[ "Extract", "all", "members", "from", "the", "archive", "to", "the", "current", "working", "directory", ".", "path", "specifies", "a", "different", "directory", "to", "extract", "to", ".", "members", "is", "optional", "and", "must", "be", "a", "subset", "of",...
python
valid
Meseira/subordinate
subordinate/idmap.py
https://github.com/Meseira/subordinate/blob/3438df304af3dccc5bd1515231402afa708f1cc3/subordinate/idmap.py#L177-L185
def who_has(self, subid): """Return a list of names who own subid in their id range set.""" answer = [] for name in self.__map: if subid in self.__map[name] and not name in answer: answer.append(name) return answer
[ "def", "who_has", "(", "self", ",", "subid", ")", ":", "answer", "=", "[", "]", "for", "name", "in", "self", ".", "__map", ":", "if", "subid", "in", "self", ".", "__map", "[", "name", "]", "and", "not", "name", "in", "answer", ":", "answer", ".",...
Return a list of names who own subid in their id range set.
[ "Return", "a", "list", "of", "names", "who", "own", "subid", "in", "their", "id", "range", "set", "." ]
python
train
jstitch/MambuPy
MambuPy/rest/mambustruct.py
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambustruct.py#L299-L355
def init(self, attrs={}, *args, **kwargs): """Default initialization from a dictionary responded by Mambu in to the elements of the Mambu object. It assings the response to attrs attribute and converts each of its elements from a string to an adequate python object: number, dat...
[ "def", "init", "(", "self", ",", "attrs", "=", "{", "}", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "attrs", "=", "attrs", "self", ".", "preprocess", "(", ")", "self", ".", "convertDict2Attrs", "(", "*", "args", ",", "*", ...
Default initialization from a dictionary responded by Mambu in to the elements of the Mambu object. It assings the response to attrs attribute and converts each of its elements from a string to an adequate python object: number, datetime, etc. Basically it stores the response ...
[ "Default", "initialization", "from", "a", "dictionary", "responded", "by", "Mambu" ]
python
train
disqus/nydus
nydus/contrib/ketama.py
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/contrib/ketama.py#L109-L118
def add_node(self, node, weight=1): """ Adds node to circle and rebuild it. """ self._nodes.add(node) self._weights[node] = weight self._hashring = dict() self._sorted_keys = [] self._build_circle()
[ "def", "add_node", "(", "self", ",", "node", ",", "weight", "=", "1", ")", ":", "self", ".", "_nodes", ".", "add", "(", "node", ")", "self", ".", "_weights", "[", "node", "]", "=", "weight", "self", ".", "_hashring", "=", "dict", "(", ")", "self"...
Adds node to circle and rebuild it.
[ "Adds", "node", "to", "circle", "and", "rebuild", "it", "." ]
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/widgets/tooltip.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/tooltip.py#L235-L250
def add_widget(self, widget): """Add the given widget to the tooltip :param widget: the widget to add :type widget: QtGui.QWidget :returns: None :rtype: None :raises: None """ if self._buttons.get(widget): return btn = self.create_butt...
[ "def", "add_widget", "(", "self", ",", "widget", ")", ":", "if", "self", ".", "_buttons", ".", "get", "(", "widget", ")", ":", "return", "btn", "=", "self", ".", "create_button", "(", "widget", ")", "cb", "=", "partial", "(", "self", ".", "focus_widg...
Add the given widget to the tooltip :param widget: the widget to add :type widget: QtGui.QWidget :returns: None :rtype: None :raises: None
[ "Add", "the", "given", "widget", "to", "the", "tooltip" ]
python
train
walkr/nanoservice
nanoservice/core.py
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L67-L77
def initialize(self, timeouts): """ Bind or connect the nanomsg socket to some address """ # Bind or connect to address if self.bind is True: self.socket.bind(self.address) else: self.socket.connect(self.address) # Set send and recv timeouts self...
[ "def", "initialize", "(", "self", ",", "timeouts", ")", ":", "# Bind or connect to address", "if", "self", ".", "bind", "is", "True", ":", "self", ".", "socket", ".", "bind", "(", "self", ".", "address", ")", "else", ":", "self", ".", "socket", ".", "c...
Bind or connect the nanomsg socket to some address
[ "Bind", "or", "connect", "the", "nanomsg", "socket", "to", "some", "address" ]
python
train
frmdstryr/enamlx
enamlx/core/looper.py
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/core/looper.py#L157-L186
def _prefetch_items(self,change): """ When the current_row in the model changes (whether from scrolling) or set by the application. Make sure the results are loaded! """ if self.is_initialized: view = self.item_view upper_limit = view.iterabl...
[ "def", "_prefetch_items", "(", "self", ",", "change", ")", ":", "if", "self", ".", "is_initialized", ":", "view", "=", "self", ".", "item_view", "upper_limit", "=", "view", ".", "iterable_index", "+", "view", ".", "iterable_fetch_size", "-", "view", ".", "...
When the current_row in the model changes (whether from scrolling) or set by the application. Make sure the results are loaded!
[ "When", "the", "current_row", "in", "the", "model", "changes", "(", "whether", "from", "scrolling", ")", "or", "set", "by", "the", "application", ".", "Make", "sure", "the", "results", "are", "loaded!" ]
python
train
inasafe/inasafe
scripts/create_api_docs.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/scripts/create_api_docs.py#L88-L104
def create_module_rst_file(module_name): """Function for creating content in each .rst file for a module. :param module_name: name of the module. :type module_name: str :returns: A content for auto module. :rtype: str """ return_text = 'Module: ' + module_name dash = '=' * len(return...
[ "def", "create_module_rst_file", "(", "module_name", ")", ":", "return_text", "=", "'Module: '", "+", "module_name", "dash", "=", "'='", "*", "len", "(", "return_text", ")", "return_text", "+=", "'\\n'", "+", "dash", "+", "'\\n\\n'", "return_text", "+=", "'.....
Function for creating content in each .rst file for a module. :param module_name: name of the module. :type module_name: str :returns: A content for auto module. :rtype: str
[ "Function", "for", "creating", "content", "in", "each", ".", "rst", "file", "for", "a", "module", "." ]
python
train
etesync/radicale_storage_etesync
radicale_storage_etesync/__init__.py
https://github.com/etesync/radicale_storage_etesync/blob/73d549bad7a37f060ece65c653c18a859a9962f2/radicale_storage_etesync/__init__.py#L399-L413
def get_meta(self, key=None): """Get metadata value for collection.""" if self.is_fake: return {} if key == "tag": return self.tag elif key is None: ret = {} for key in self.journal.info.keys(): ret[key] = self.meta_mapping...
[ "def", "get_meta", "(", "self", ",", "key", "=", "None", ")", ":", "if", "self", ".", "is_fake", ":", "return", "{", "}", "if", "key", "==", "\"tag\"", ":", "return", "self", ".", "tag", "elif", "key", "is", "None", ":", "ret", "=", "{", "}", "...
Get metadata value for collection.
[ "Get", "metadata", "value", "for", "collection", "." ]
python
train
Azure/msrest-for-python
msrest/universal_http/async_requests.py
https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/universal_http/async_requests.py#L87-L91
async def send(self, request: ClientRequest, **kwargs: Any) -> AsyncClientResponse: # type: ignore """Send the request using this HTTP sender. """ requests_kwargs = self._configure_send(request, **kwargs) return await super(AsyncRequestsHTTPSender, self).send(request, **requests_kwargs)
[ "async", "def", "send", "(", "self", ",", "request", ":", "ClientRequest", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "AsyncClientResponse", ":", "# type: ignore", "requests_kwargs", "=", "self", ".", "_configure_send", "(", "request", ",", "*", "*", ...
Send the request using this HTTP sender.
[ "Send", "the", "request", "using", "this", "HTTP", "sender", "." ]
python
train
zsims/dic
dic/container.py
https://github.com/zsims/dic/blob/bb4e615c236e6cfe804bd7286a5af081007325ce/dic/container.py#L211-L219
def register_instance(self, class_type, instance, register_as=None): """ Registers the given instance (already created). :param class_type: The class type. :param instance: The instance to register. :param register_as: The types to register the class as, defaults to the given cla...
[ "def", "register_instance", "(", "self", ",", "class_type", ",", "instance", ",", "register_as", "=", "None", ")", ":", "registration", "=", "_InstanceRegistration", "(", "instance", ")", "self", ".", "_register", "(", "class_type", ",", "registration", ",", "...
Registers the given instance (already created). :param class_type: The class type. :param instance: The instance to register. :param register_as: The types to register the class as, defaults to the given class_type.
[ "Registers", "the", "given", "instance", "(", "already", "created", ")", ".", ":", "param", "class_type", ":", "The", "class", "type", ".", ":", "param", "instance", ":", "The", "instance", "to", "register", ".", ":", "param", "register_as", ":", "The", ...
python
train
samghelms/mathviz
mathviz_hopper/src/indices.py
https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/indices.py#L110-L118
def _convert_query(self, query): """ Convert query into an indexable string. """ query = self.dictionary.doc2bow(self._tokenize_latex(query)) sims = self.index[query] neighbors = sorted(sims, key=lambda item: -item[1]) neighbors = {"neighbors":[{self.columns[0]: {...
[ "def", "_convert_query", "(", "self", ",", "query", ")", ":", "query", "=", "self", ".", "dictionary", ".", "doc2bow", "(", "self", ".", "_tokenize_latex", "(", "query", ")", ")", "sims", "=", "self", ".", "index", "[", "query", "]", "neighbors", "=", ...
Convert query into an indexable string.
[ "Convert", "query", "into", "an", "indexable", "string", "." ]
python
train
waqasbhatti/astrobase
astrobase/lcproc/tfa.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcproc/tfa.py#L1335-L1456
def parallel_tfa_lclist(lclist, templateinfo, timecols=None, magcols=None, errcols=None, lcformat='hat-sql', lcformatdir=None, interp='nearest', ...
[ "def", "parallel_tfa_lclist", "(", "lclist", ",", "templateinfo", ",", "timecols", "=", "None", ",", "magcols", "=", "None", ",", "errcols", "=", "None", ",", "lcformat", "=", "'hat-sql'", ",", "lcformatdir", "=", "None", ",", "interp", "=", "'nearest'", "...
This applies TFA in parallel to all LCs in the given list of file names. Parameters ---------- lclist : str This is a list of light curve files to apply TFA correction to. templateinfo : dict or str This is either the dict produced by `tfa_templates_lclist` or the pickle produ...
[ "This", "applies", "TFA", "in", "parallel", "to", "all", "LCs", "in", "the", "given", "list", "of", "file", "names", "." ]
python
valid
yfpeng/bioc
bioc/utils.py
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/utils.py#L74-L80
def shorten_text(text: str): """Return a short repr of text if it is longer than 40""" if len(text) <= 40: text = text else: text = text[:17] + ' ... ' + text[-17:] return repr(text)
[ "def", "shorten_text", "(", "text", ":", "str", ")", ":", "if", "len", "(", "text", ")", "<=", "40", ":", "text", "=", "text", "else", ":", "text", "=", "text", "[", ":", "17", "]", "+", "' ... '", "+", "text", "[", "-", "17", ":", "]", "retu...
Return a short repr of text if it is longer than 40
[ "Return", "a", "short", "repr", "of", "text", "if", "it", "is", "longer", "than", "40" ]
python
train
habnabit/panglery
panglery/pangler.py
https://github.com/habnabit/panglery/blob/4d62e408c4bfaae126c93a6151ded1e8dc75bcc8/panglery/pangler.py#L141-L156
def stored_bind(self, instance): """Bind an instance to this Pangler, using the bound Pangler store. This method functions identically to `bind`, except that it might return a Pangler which was previously bound to the provided instance. """ if self.id is None: retu...
[ "def", "stored_bind", "(", "self", ",", "instance", ")", ":", "if", "self", ".", "id", "is", "None", ":", "return", "self", ".", "bind", "(", "instance", ")", "store", "=", "self", ".", "_bound_pangler_store", ".", "setdefault", "(", "instance", ",", "...
Bind an instance to this Pangler, using the bound Pangler store. This method functions identically to `bind`, except that it might return a Pangler which was previously bound to the provided instance.
[ "Bind", "an", "instance", "to", "this", "Pangler", "using", "the", "bound", "Pangler", "store", "." ]
python
train
omtinez/pddb
pddb/pddb.py
https://github.com/omtinez/pddb/blob/a24cee0702c8286c5c466c51ca65cf8dbc2c183c/pddb/pddb.py#L473-L525
def find_one(self, tname, where=None, where_not=None, columns=None, astype=None): ''' Find a single record in the provided table from the database. If multiple match, return the first one based on the internal order of the records. If no records are found, return empty dictionary, string...
[ "def", "find_one", "(", "self", ",", "tname", ",", "where", "=", "None", ",", "where_not", "=", "None", ",", "columns", "=", "None", ",", "astype", "=", "None", ")", ":", "records", "=", "self", ".", "find", "(", "tname", ",", "where", "=", "where"...
Find a single record in the provided table from the database. If multiple match, return the first one based on the internal order of the records. If no records are found, return empty dictionary, string or series depending on the value of `astype`. Parameters ---------- tname : ...
[ "Find", "a", "single", "record", "in", "the", "provided", "table", "from", "the", "database", ".", "If", "multiple", "match", "return", "the", "first", "one", "based", "on", "the", "internal", "order", "of", "the", "records", ".", "If", "no", "records", ...
python
train
inasafe/inasafe
safe/processors/post_processor_functions.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/processors/post_processor_functions.py#L29-L44
def multiply(**kwargs): """Simple postprocessor where we multiply the input values. :param kwargs: Dictionary of values to multiply :type kwargs: dict :return: The result. :rtype: float """ result = 1 for i in list(kwargs.values()): if not i: # If one value is null,...
[ "def", "multiply", "(", "*", "*", "kwargs", ")", ":", "result", "=", "1", "for", "i", "in", "list", "(", "kwargs", ".", "values", "(", ")", ")", ":", "if", "not", "i", ":", "# If one value is null, we return null.", "return", "i", "result", "*=", "i", ...
Simple postprocessor where we multiply the input values. :param kwargs: Dictionary of values to multiply :type kwargs: dict :return: The result. :rtype: float
[ "Simple", "postprocessor", "where", "we", "multiply", "the", "input", "values", "." ]
python
train
ask/redish
redish/types.py
https://github.com/ask/redish/blob/4845f8d5e12fd953ecad624b4e1e89f79a082a3e/redish/types.py#L167-L178
def union(self, other): """Return the union of sets as a new set. (i.e. all elements that are in either set.) Operates on either redish.types.Set or __builtins__.set. """ if isinstance(other, self.__class__): return self.client.sunion([self.name, other.name]) ...
[ "def", "union", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "self", ".", "__class__", ")", ":", "return", "self", ".", "client", ".", "sunion", "(", "[", "self", ".", "name", ",", "other", ".", "name", "]", ")", "e...
Return the union of sets as a new set. (i.e. all elements that are in either set.) Operates on either redish.types.Set or __builtins__.set.
[ "Return", "the", "union", "of", "sets", "as", "a", "new", "set", "." ]
python
train
icgood/pymap
pymap/parsing/response/code.py
https://github.com/icgood/pymap/blob/e77d9a54d760e3cbe044a548883bb4299ed61dc2/pymap/parsing/response/code.py#L29-L35
def string(self) -> bytes: """The capabilities string without the enclosing square brackets.""" if self._raw is not None: return self._raw self._raw = raw = BytesFormat(b' ').join( [b'CAPABILITY', b'IMAP4rev1'] + self.capabilities) return raw
[ "def", "string", "(", "self", ")", "->", "bytes", ":", "if", "self", ".", "_raw", "is", "not", "None", ":", "return", "self", ".", "_raw", "self", ".", "_raw", "=", "raw", "=", "BytesFormat", "(", "b' '", ")", ".", "join", "(", "[", "b'CAPABILITY'"...
The capabilities string without the enclosing square brackets.
[ "The", "capabilities", "string", "without", "the", "enclosing", "square", "brackets", "." ]
python
train
mkoura/dump2polarion
dump2polarion/csv_unicode.py
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/csv_unicode.py#L8-L15
def get_csv_reader(csvfile, dialect=csv.excel, encoding="utf-8", **kwds): """Returns csv reader.""" try: # pylint: disable=pointless-statement unicode return UnicodeReader(csvfile, dialect=dialect, encoding=encoding, **kwds) except NameError: return csv.reader(csvfile, dialec...
[ "def", "get_csv_reader", "(", "csvfile", ",", "dialect", "=", "csv", ".", "excel", ",", "encoding", "=", "\"utf-8\"", ",", "*", "*", "kwds", ")", ":", "try", ":", "# pylint: disable=pointless-statement", "unicode", "return", "UnicodeReader", "(", "csvfile", ",...
Returns csv reader.
[ "Returns", "csv", "reader", "." ]
python
train
ejeschke/ginga
ginga/rv/plugins/Pan.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Pan.py#L420-L429
def pan_pan_cb(self, fitsimage, event): """Pan event in the pan window. Just pan the channel viewer. """ chviewer = self.fv.getfocus_viewer() bd = chviewer.get_bindings() if hasattr(bd, 'pa_pan'): return bd.pa_pan(chviewer, event) return False
[ "def", "pan_pan_cb", "(", "self", ",", "fitsimage", ",", "event", ")", ":", "chviewer", "=", "self", ".", "fv", ".", "getfocus_viewer", "(", ")", "bd", "=", "chviewer", ".", "get_bindings", "(", ")", "if", "hasattr", "(", "bd", ",", "'pa_pan'", ")", ...
Pan event in the pan window. Just pan the channel viewer.
[ "Pan", "event", "in", "the", "pan", "window", ".", "Just", "pan", "the", "channel", "viewer", "." ]
python
train
dade-ai/snipy
snipy/io/fileutil.py
https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L32-L42
def readlines(filepath): """ read lines from a textfile :param filepath: :return: list[line] """ with open(filepath, 'rt') as f: lines = f.readlines() lines = map(str.strip, lines) lines = [l for l in lines if l] return lines
[ "def", "readlines", "(", "filepath", ")", ":", "with", "open", "(", "filepath", ",", "'rt'", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "lines", "=", "map", "(", "str", ".", "strip", ",", "lines", ")", "lines", "=", "[", ...
read lines from a textfile :param filepath: :return: list[line]
[ "read", "lines", "from", "a", "textfile", ":", "param", "filepath", ":", ":", "return", ":", "list", "[", "line", "]" ]
python
valid
PmagPy/PmagPy
pmagpy/ipmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/ipmag.py#L7630-L7733
def iplot_hys(fignum, B, M, s): """ function to plot hysteresis data This function has been adapted from pmagplotlib.iplot_hys for specific use within a Jupyter notebook. Parameters ----------- fignum : reference number for matplotlib figure being created B : list of B (flux density) v...
[ "def", "iplot_hys", "(", "fignum", ",", "B", ",", "M", ",", "s", ")", ":", "if", "fignum", "!=", "0", ":", "plt", ".", "figure", "(", "num", "=", "fignum", ")", "plt", ".", "clf", "(", ")", "hpars", "=", "{", "}", "# close up loop", "Npts", "="...
function to plot hysteresis data This function has been adapted from pmagplotlib.iplot_hys for specific use within a Jupyter notebook. Parameters ----------- fignum : reference number for matplotlib figure being created B : list of B (flux density) values of hysteresis experiment M : list ...
[ "function", "to", "plot", "hysteresis", "data" ]
python
train
tradenity/python-sdk
tradenity/resources/measurement_settings.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/measurement_settings.py#L55-L69
def weight_unit(self, weight_unit): """Sets the weight_unit of this MeasurementSettings. :param weight_unit: The weight_unit of this MeasurementSettings. :type: str """ allowed_values = ["pound", "kilogram"] # noqa: E501 if weight_unit is not None and weight_unit not i...
[ "def", "weight_unit", "(", "self", ",", "weight_unit", ")", ":", "allowed_values", "=", "[", "\"pound\"", ",", "\"kilogram\"", "]", "# noqa: E501", "if", "weight_unit", "is", "not", "None", "and", "weight_unit", "not", "in", "allowed_values", ":", "raise", "Va...
Sets the weight_unit of this MeasurementSettings. :param weight_unit: The weight_unit of this MeasurementSettings. :type: str
[ "Sets", "the", "weight_unit", "of", "this", "MeasurementSettings", "." ]
python
train
readbeyond/aeneas
aeneas/audiofile.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L607-L630
def write(self, file_path): """ Write the audio data to file. Return ``True`` on success, or ``False`` otherwise. :param string file_path: the path of the output file to be written :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initial...
[ "def", "write", "(", "self", ",", "file_path", ")", ":", "if", "self", ".", "__samples", "is", "None", ":", "if", "self", ".", "file_path", "is", "None", ":", "self", ".", "log_exc", "(", "u\"AudioFile object not initialized\"", ",", "None", ",", "True", ...
Write the audio data to file. Return ``True`` on success, or ``False`` otherwise. :param string file_path: the path of the output file to be written :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initialized yet .. versionadded:: 1.2.0
[ "Write", "the", "audio", "data", "to", "file", ".", "Return", "True", "on", "success", "or", "False", "otherwise", "." ]
python
train
seleniumbase/SeleniumBase
seleniumbase/core/log_helper.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/core/log_helper.py#L107-L132
def log_folder_setup(log_path, archive_logs=False): """ Handle Logging """ if log_path.endswith("/"): log_path = log_path[:-1] if not os.path.exists(log_path): try: os.makedirs(log_path) except Exception: pass # Should only be reachable during multi-threaded ...
[ "def", "log_folder_setup", "(", "log_path", ",", "archive_logs", "=", "False", ")", ":", "if", "log_path", ".", "endswith", "(", "\"/\"", ")", ":", "log_path", "=", "log_path", "[", ":", "-", "1", "]", "if", "not", "os", ".", "path", ".", "exists", "...
Handle Logging
[ "Handle", "Logging" ]
python
train