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
openstack/python-scciclient
scciclient/irmc/snmp.py
https://github.com/openstack/python-scciclient/blob/4585ce2f76853b9773fb190ca0cfff0aa04a7cf8/scciclient/irmc/snmp.py#L69-L86
def get_irmc_firmware_version(snmp_client): """Get irmc firmware version of the node. :param snmp_client: an SNMP client object. :raises: SNMPFailure if SNMP operation failed. :returns: a string of bmc name and irmc firmware version. """ try: bmc_name = snmp_client.get(BMC_NAME_OID) ...
[ "def", "get_irmc_firmware_version", "(", "snmp_client", ")", ":", "try", ":", "bmc_name", "=", "snmp_client", ".", "get", "(", "BMC_NAME_OID", ")", "irmc_firm_ver", "=", "snmp_client", ".", "get", "(", "IRMC_FW_VERSION_OID", ")", "return", "(", "'%(bmc)s%(sep)s%(f...
Get irmc firmware version of the node. :param snmp_client: an SNMP client object. :raises: SNMPFailure if SNMP operation failed. :returns: a string of bmc name and irmc firmware version.
[ "Get", "irmc", "firmware", "version", "of", "the", "node", "." ]
python
train
tundish/turberfield-dialogue
turberfield/dialogue/matcher.py
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/matcher.py#L70-L87
def options(self, data): """Generate folders to best match metadata. The results will be a single, perfectly matched folder, or the two nearest neighbours of an imperfect match. :param dict data: metadata matching criteria. This method is a generator. It yields :py:cla...
[ "def", "options", "(", "self", ",", "data", ")", ":", "if", "self", ".", "mapping_key", "(", "data", ")", "in", "self", ".", "keys", ":", "yield", "next", "(", "i", "for", "i", "in", "self", ".", "folders", "if", "i", ".", "metadata", "==", "data...
Generate folders to best match metadata. The results will be a single, perfectly matched folder, or the two nearest neighbours of an imperfect match. :param dict data: metadata matching criteria. This method is a generator. It yields :py:class:`turberfield.dialogue.model.Scene...
[ "Generate", "folders", "to", "best", "match", "metadata", "." ]
python
train
grycap/RADL
radl/radl.py
https://github.com/grycap/RADL/blob/03ccabb0313a48a5aa0e20c1f7983fddcb95e9cb/radl/radl.py#L1205-L1221
def __getIP(self, public): """Return the first net_interface.%d.ip for a system in a public/private network.""" maybeNot = (lambda x: x) if public else (lambda x: not x) nets_id = [net.id for net in self.networks if maybeNot(net.isPublic())] for s in self.systems: i = 0 ...
[ "def", "__getIP", "(", "self", ",", "public", ")", ":", "maybeNot", "=", "(", "lambda", "x", ":", "x", ")", "if", "public", "else", "(", "lambda", "x", ":", "not", "x", ")", "nets_id", "=", "[", "net", ".", "id", "for", "net", "in", "self", "."...
Return the first net_interface.%d.ip for a system in a public/private network.
[ "Return", "the", "first", "net_interface", ".", "%d", ".", "ip", "for", "a", "system", "in", "a", "public", "/", "private", "network", "." ]
python
train
pyQode/pyqode.core
pyqode/core/backend/workers.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/backend/workers.py#L171-L199
def finditer_noregex(string, sub, whole_word): """ Search occurrences using str.find instead of regular expressions. :param string: string to parse :param sub: search string :param whole_word: True to select whole words only """ start = 0 while True: start = string.find(sub, sta...
[ "def", "finditer_noregex", "(", "string", ",", "sub", ",", "whole_word", ")", ":", "start", "=", "0", "while", "True", ":", "start", "=", "string", ".", "find", "(", "sub", ",", "start", ")", "if", "start", "==", "-", "1", ":", "return", "if", "who...
Search occurrences using str.find instead of regular expressions. :param string: string to parse :param sub: search string :param whole_word: True to select whole words only
[ "Search", "occurrences", "using", "str", ".", "find", "instead", "of", "regular", "expressions", "." ]
python
train
openid/JWTConnect-Python-OidcService
src/oidcservice/oidc/provider_info_discovery.py
https://github.com/openid/JWTConnect-Python-OidcService/blob/759ab7adef30a7e3b9d75475e2971433b9613788/src/oidcservice/oidc/provider_info_discovery.py#L93-L178
def match_preferences(self, pcr=None, issuer=None): """ Match the clients preferences against what the provider can do. This is to prepare for later client registration and or what functionality the client actually will use. In the client configuration the client preferences are ...
[ "def", "match_preferences", "(", "self", ",", "pcr", "=", "None", ",", "issuer", "=", "None", ")", ":", "if", "not", "pcr", ":", "pcr", "=", "self", ".", "service_context", ".", "provider_info", "regreq", "=", "oidc", ".", "RegistrationRequest", "for", "...
Match the clients preferences against what the provider can do. This is to prepare for later client registration and or what functionality the client actually will use. In the client configuration the client preferences are expressed. These are then compared with the Provider Configurati...
[ "Match", "the", "clients", "preferences", "against", "what", "the", "provider", "can", "do", ".", "This", "is", "to", "prepare", "for", "later", "client", "registration", "and", "or", "what", "functionality", "the", "client", "actually", "will", "use", ".", ...
python
train
AbletonAG/abl.vpath
abl/vpath/base/fs.py
https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/fs.py#L652-L664
def isexec(self, mode=stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH): """ isexec: @rtype: bool @return: Indicates whether the path points to a file or folder which has the executable flag set. Note that on systems which do not support executables flags the result m...
[ "def", "isexec", "(", "self", ",", "mode", "=", "stat", ".", "S_IXUSR", "|", "stat", ".", "S_IXGRP", "|", "stat", ".", "S_IXOTH", ")", ":", "return", "self", ".", "connection", ".", "isexec", "(", "self", ",", "mode", ")" ]
isexec: @rtype: bool @return: Indicates whether the path points to a file or folder which has the executable flag set. Note that on systems which do not support executables flags the result may be unpredicatable. On Windows the value is determined by the file extension...
[ "isexec", ":" ]
python
train
jelmer/python-fastimport
fastimport/dates.py
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/dates.py#L30-L42
def parse_raw(s, lineno=0): """Parse a date from a raw string. The format must be exactly "seconds-since-epoch offset-utc". See the spec for details. """ timestamp_str, timezone_str = s.split(b' ', 1) timestamp = float(timestamp_str) try: timezone = parse_tz(timezone_str) except...
[ "def", "parse_raw", "(", "s", ",", "lineno", "=", "0", ")", ":", "timestamp_str", ",", "timezone_str", "=", "s", ".", "split", "(", "b' '", ",", "1", ")", "timestamp", "=", "float", "(", "timestamp_str", ")", "try", ":", "timezone", "=", "parse_tz", ...
Parse a date from a raw string. The format must be exactly "seconds-since-epoch offset-utc". See the spec for details.
[ "Parse", "a", "date", "from", "a", "raw", "string", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/models/transformer.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/transformer.py#L1861-L1871
def transformer_tall_train_uniencdec(): """Train CNN/DM with a unidirectional encoder and decoder.""" hparams = transformer_tall() hparams.max_input_seq_length = 750 hparams.max_target_seq_length = 100 hparams.optimizer = "true_adam" hparams.learning_rate_schedule = ("linear_warmup*constant*cosdecay") hpa...
[ "def", "transformer_tall_train_uniencdec", "(", ")", ":", "hparams", "=", "transformer_tall", "(", ")", "hparams", ".", "max_input_seq_length", "=", "750", "hparams", ".", "max_target_seq_length", "=", "100", "hparams", ".", "optimizer", "=", "\"true_adam\"", "hpara...
Train CNN/DM with a unidirectional encoder and decoder.
[ "Train", "CNN", "/", "DM", "with", "a", "unidirectional", "encoder", "and", "decoder", "." ]
python
train
hollenstein/maspy
maspy/core.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/core.py#L1191-L1204
def _fromJSON(cls, jsonobject): """Generates a new instance of :class:`maspy.core.MzmlPrecursor` from a decoded JSON object (as generated by :func:`maspy.core.MzmlPrecursor._reprJSON()`). :param jsonobject: decoded JSON object :returns: a new instance of :class:`MzmlPrecursor` ...
[ "def", "_fromJSON", "(", "cls", ",", "jsonobject", ")", ":", "spectrumRef", "=", "jsonobject", "[", "0", "]", "activation", "=", "[", "tuple", "(", "param", ")", "for", "param", "in", "jsonobject", "[", "1", "]", "]", "isolationWindow", "=", "[", "tupl...
Generates a new instance of :class:`maspy.core.MzmlPrecursor` from a decoded JSON object (as generated by :func:`maspy.core.MzmlPrecursor._reprJSON()`). :param jsonobject: decoded JSON object :returns: a new instance of :class:`MzmlPrecursor`
[ "Generates", "a", "new", "instance", "of", ":", "class", ":", "maspy", ".", "core", ".", "MzmlPrecursor", "from", "a", "decoded", "JSON", "object", "(", "as", "generated", "by", ":", "func", ":", "maspy", ".", "core", ".", "MzmlPrecursor", ".", "_reprJSO...
python
train
opendatateam/udata
udata/commands/worker.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/commands/worker.py#L125-L133
def status(queue, munin, munin_config): """List queued tasks aggregated by name""" if munin_config: return status_print_config(queue) queues = get_queues(queue) for queue in queues: status_print_queue(queue, munin=munin) if not munin: print('-' * 40)
[ "def", "status", "(", "queue", ",", "munin", ",", "munin_config", ")", ":", "if", "munin_config", ":", "return", "status_print_config", "(", "queue", ")", "queues", "=", "get_queues", "(", "queue", ")", "for", "queue", "in", "queues", ":", "status_print_queu...
List queued tasks aggregated by name
[ "List", "queued", "tasks", "aggregated", "by", "name" ]
python
train
simpleai-team/simpleai
simpleai/search/traditional.py
https://github.com/simpleai-team/simpleai/blob/2836befa7e970013f62e0ee75562652aacac6f65/simpleai/search/traditional.py#L52-L73
def iterative_limited_depth_first(problem, graph_search=False, viewer=None): ''' Iterative limited depth first search. If graph_search=True, will avoid exploring repeated states. Requires: SearchProblem.actions, SearchProblem.result, and SearchProblem.is_goal. ''' solution = None limit ...
[ "def", "iterative_limited_depth_first", "(", "problem", ",", "graph_search", "=", "False", ",", "viewer", "=", "None", ")", ":", "solution", "=", "None", "limit", "=", "0", "while", "not", "solution", ":", "solution", "=", "limited_depth_first", "(", "problem"...
Iterative limited depth first search. If graph_search=True, will avoid exploring repeated states. Requires: SearchProblem.actions, SearchProblem.result, and SearchProblem.is_goal.
[ "Iterative", "limited", "depth", "first", "search", "." ]
python
train
inasafe/inasafe
safe/gui/tools/batch/batch_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/batch/batch_dialog.py#L419-L568
def run_task(self, task_item, status_item, count=0, index=''): """Run a single task. :param task_item: Table task_item containing task name / details. :type task_item: QTableWidgetItem :param status_item: Table task_item that holds the task status. :type status_item: QTableWidg...
[ "def", "run_task", "(", "self", ",", "task_item", ",", "status_item", ",", "count", "=", "0", ",", "index", "=", "''", ")", ":", "self", ".", "enable_busy_cursor", "(", ")", "for", "layer_group", "in", "self", ".", "layer_group_container", ":", "layer_grou...
Run a single task. :param task_item: Table task_item containing task name / details. :type task_item: QTableWidgetItem :param status_item: Table task_item that holds the task status. :type status_item: QTableWidgetItem :param count: Count of scenarios that have been run alread...
[ "Run", "a", "single", "task", "." ]
python
train
wiheto/teneto
teneto/networkmeasures/reachability_latency.py
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/reachability_latency.py#L9-L72
def reachability_latency(tnet=None, paths=None, rratio=1, calc='global'): """ Reachability latency. This is the r-th longest temporal path. Parameters --------- data : array or dict Can either be a network (graphlet or contact), binary unidrected only. Alternative can be a paths dictionar...
[ "def", "reachability_latency", "(", "tnet", "=", "None", ",", "paths", "=", "None", ",", "rratio", "=", "1", ",", "calc", "=", "'global'", ")", ":", "if", "tnet", "is", "not", "None", "and", "paths", "is", "not", "None", ":", "raise", "ValueError", "...
Reachability latency. This is the r-th longest temporal path. Parameters --------- data : array or dict Can either be a network (graphlet or contact), binary unidrected only. Alternative can be a paths dictionary (output of teneto.networkmeasure.shortest_temporal_path) rratio: float (default...
[ "Reachability", "latency", ".", "This", "is", "the", "r", "-", "th", "longest", "temporal", "path", "." ]
python
train
galaxy-genome-annotation/python-apollo
apollo/annotations/__init__.py
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/apollo/annotations/__init__.py#L743-L758
def get_sequence_alterations(self, organism=None, sequence=None): """ [UNTESTED] Get all of the sequence's alterations :type organism: str :param organism: Organism Common Name :type sequence: str :param sequence: Sequence Name :rtype: list :return: A l...
[ "def", "get_sequence_alterations", "(", "self", ",", "organism", "=", "None", ",", "sequence", "=", "None", ")", ":", "data", "=", "{", "}", "data", "=", "self", ".", "_update_data", "(", "data", ",", "organism", ",", "sequence", ")", "return", "self", ...
[UNTESTED] Get all of the sequence's alterations :type organism: str :param organism: Organism Common Name :type sequence: str :param sequence: Sequence Name :rtype: list :return: A list of sequence alterations(?)
[ "[", "UNTESTED", "]", "Get", "all", "of", "the", "sequence", "s", "alterations" ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_normalizer.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_normalizer.py#L24-L64
def convert(model, input_features, output_features): """Convert a normalizer model to the protobuf spec. Parameters ---------- model: Normalizer A Normalizer. input_features: str Name of the input column. output_features: str Name of the output column. Returns ...
[ "def", "convert", "(", "model", ",", "input_features", ",", "output_features", ")", ":", "if", "not", "(", "_HAS_SKLEARN", ")", ":", "raise", "RuntimeError", "(", "'scikit-learn not found. scikit-learn conversion API is disabled.'", ")", "# Test the scikit-learn model", "...
Convert a normalizer model to the protobuf spec. Parameters ---------- model: Normalizer A Normalizer. input_features: str Name of the input column. output_features: str Name of the output column. Returns ------- model_spec: An object of type Model_pb. ...
[ "Convert", "a", "normalizer", "model", "to", "the", "protobuf", "spec", "." ]
python
train
zqfang/GSEApy
gseapy/gsea.py
https://github.com/zqfang/GSEApy/blob/673e9ec1391e3b14d3e8a4353117151fd2cb9345/gseapy/gsea.py#L348-L382
def load_data(self, cls_vec): """pre-processed the data frame.new filtering methods will be implement here. """ # read data in if isinstance(self.data, pd.DataFrame) : exprs = self.data.copy() # handle index is gene_names if exprs.index.dtype == 'O': ...
[ "def", "load_data", "(", "self", ",", "cls_vec", ")", ":", "# read data in", "if", "isinstance", "(", "self", ".", "data", ",", "pd", ".", "DataFrame", ")", ":", "exprs", "=", "self", ".", "data", ".", "copy", "(", ")", "# handle index is gene_names", "i...
pre-processed the data frame.new filtering methods will be implement here.
[ "pre", "-", "processed", "the", "data", "frame", ".", "new", "filtering", "methods", "will", "be", "implement", "here", "." ]
python
test
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/app/application.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/application.py#L158-L241
def _use(self, backend_name=None): """Select a backend by name. See class docstring for details. """ # See if we're in a specific testing mode, if so DONT check to see # if it's a valid backend. If it isn't, it's a good thing we # get an error later because we should have decorat...
[ "def", "_use", "(", "self", ",", "backend_name", "=", "None", ")", ":", "# See if we're in a specific testing mode, if so DONT check to see", "# if it's a valid backend. If it isn't, it's a good thing we", "# get an error later because we should have decorated our test", "# with requires_a...
Select a backend by name. See class docstring for details.
[ "Select", "a", "backend", "by", "name", ".", "See", "class", "docstring", "for", "details", "." ]
python
train
dhhagan/py-opc
opc/__init__.py
https://github.com/dhhagan/py-opc/blob/2c8f19530fb64bf5fd4ee0d694a47850161ed8a7/opc/__init__.py#L612-L642
def save_config_variables(self): """Save the configuration variables in non-volatile memory. This method should be used in conjuction with *write_config_variables*. :rtype: boolean :Example: >>> alpha.save_config_variables() True """ command = 0x43 ...
[ "def", "save_config_variables", "(", "self", ")", ":", "command", "=", "0x43", "byte_list", "=", "[", "0x3F", ",", "0x3C", ",", "0x3F", ",", "0x3C", ",", "0x43", "]", "success", "=", "[", "0xF3", ",", "0x43", ",", "0x3F", ",", "0x3C", ",", "0x3F", ...
Save the configuration variables in non-volatile memory. This method should be used in conjuction with *write_config_variables*. :rtype: boolean :Example: >>> alpha.save_config_variables() True
[ "Save", "the", "configuration", "variables", "in", "non", "-", "volatile", "memory", ".", "This", "method", "should", "be", "used", "in", "conjuction", "with", "*", "write_config_variables", "*", "." ]
python
valid
chrisvoncsefalvay/urbanpyctionary
urbanpyctionary/client.py
https://github.com/chrisvoncsefalvay/urbanpyctionary/blob/77ce3262d25d16ae9179909a34197c102adb2f06/urbanpyctionary/client.py#L115-L140
def get(self, word): """ Obtains the definition of a word from Urban Dictionary. :param word: word to be searched for :type word: str :return: a result set with all definitions for the word """ url = "https://mashape-community-urban-dictionary.p.mashape.com/defi...
[ "def", "get", "(", "self", ",", "word", ")", ":", "url", "=", "\"https://mashape-community-urban-dictionary.p.mashape.com/define?term=%s\"", "%", "word", "try", ":", "res", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "{", "\"X-Mashape-Key\"", "...
Obtains the definition of a word from Urban Dictionary. :param word: word to be searched for :type word: str :return: a result set with all definitions for the word
[ "Obtains", "the", "definition", "of", "a", "word", "from", "Urban", "Dictionary", "." ]
python
train
pantsbuild/pants
contrib/go/src/python/pants/contrib/go/tasks/go_workspace_task.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/contrib/go/src/python/pants/contrib/go/tasks/go_workspace_task.py#L56-L67
def remove_unused_links(dirpath, required_links): """Recursively remove any links in dirpath which are not contained in required_links. :param str dirpath: Absolute path of directory to search. :param container required_links: Container of "in use" links which should not be removed, ...
[ "def", "remove_unused_links", "(", "dirpath", ",", "required_links", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "dirpath", ")", ":", "for", "p", "in", "chain", "(", "dirs", ",", "files", ")", ":", "p", "=", "o...
Recursively remove any links in dirpath which are not contained in required_links. :param str dirpath: Absolute path of directory to search. :param container required_links: Container of "in use" links which should not be removed, where each link is an absolute path.
[ "Recursively", "remove", "any", "links", "in", "dirpath", "which", "are", "not", "contained", "in", "required_links", "." ]
python
train
HewlettPackard/python-hpOneView
hpOneView/resources/servers/server_profiles.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/servers/server_profiles.py#L149-L165
def get_profile_ports(self, **kwargs): """ Retrieves the port model associated with a server or server hardware type and enclosure group. Args: enclosureGroupUri (str): The URI of the enclosure group associated with the resource. serverHardwareTypeUri (st...
[ "def", "get_profile_ports", "(", "self", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "self", ".", "_helper", ".", "build_uri_with_query_string", "(", "kwargs", ",", "'/profile-ports'", ")", "return", "self", ".", "_helper", ".", "do_get", "(", "uri", ")...
Retrieves the port model associated with a server or server hardware type and enclosure group. Args: enclosureGroupUri (str): The URI of the enclosure group associated with the resource. serverHardwareTypeUri (str): The URI of the server hardware type ass...
[ "Retrieves", "the", "port", "model", "associated", "with", "a", "server", "or", "server", "hardware", "type", "and", "enclosure", "group", "." ]
python
train
sdispater/orator
orator/dbal/foreign_key_constraint.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/dbal/foreign_key_constraint.py#L189-L208
def get_quoted_foreign_columns(self, platform): """ Returns the quoted representation of the referenced table column names the foreign key constraint is associated with. But only if they were defined with one or the referenced table column name is a keyword reserved by the platf...
[ "def", "get_quoted_foreign_columns", "(", "self", ",", "platform", ")", ":", "columns", "=", "[", "]", "for", "column", "in", "self", ".", "_foreign_column_names", ".", "values", "(", ")", ":", "columns", ".", "append", "(", "column", ".", "get_quoted_name",...
Returns the quoted representation of the referenced table column names the foreign key constraint is associated with. But only if they were defined with one or the referenced table column name is a keyword reserved by the platform. Otherwise the plain unquoted value as inserted is retur...
[ "Returns", "the", "quoted", "representation", "of", "the", "referenced", "table", "column", "names", "the", "foreign", "key", "constraint", "is", "associated", "with", "." ]
python
train
toomore/goristock
grs/goristock.py
https://github.com/toomore/goristock/blob/e61f57f11a626cfbc4afbf66337fd9d1c51e3e71/grs/goristock.py#L616-L658
def XMPP_display(self,*arg): """ For XMPP Demo 輸出到 XMPP 之樣式。 """ MA = '' for i in arg: MAs = '- MA%02s: %.2f %s(%s)\n' % ( unicode(i), self.MA(i), self.MAC(i), unicode(self.MA_serial(i)[0]) ) MA = MA + MAs vol = '- Volume: %s %s(%s)' % ( ...
[ "def", "XMPP_display", "(", "self", ",", "*", "arg", ")", ":", "MA", "=", "''", "for", "i", "in", "arg", ":", "MAs", "=", "'- MA%02s: %.2f %s(%s)\\n'", "%", "(", "unicode", "(", "i", ")", ",", "self", ".", "MA", "(", "i", ")", ",", "self", ".", ...
For XMPP Demo 輸出到 XMPP 之樣式。
[ "For", "XMPP", "Demo", "輸出到", "XMPP", "之樣式。" ]
python
train
MartinThoma/hwrt
hwrt/create_ffiles.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/create_ffiles.py#L302-L322
def _normalize_features(feature_list, prepared, is_traindata): """Normalize features (mean subtraction, division by variance or range). """ if is_traindata: _calculate_feature_stats(feature_list, prepared, "featurenormalization.csv") ...
[ "def", "_normalize_features", "(", "feature_list", ",", "prepared", ",", "is_traindata", ")", ":", "if", "is_traindata", ":", "_calculate_feature_stats", "(", "feature_list", ",", "prepared", ",", "\"featurenormalization.csv\"", ")", "start", "=", "0", "for", "featu...
Normalize features (mean subtraction, division by variance or range).
[ "Normalize", "features", "(", "mean", "subtraction", "division", "by", "variance", "or", "range", ")", "." ]
python
train
theonion/django-bulbs
bulbs/api/views.py
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/api/views.py#L159-L183
def publish(self, request, **kwargs): """sets the `published` value of the `Content` :param request: a WSGI request object :param kwargs: keyword arguments (optional) :return: `rest_framework.response.Response` """ content = self.get_object() if "published" in g...
[ "def", "publish", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "content", "=", "self", ".", "get_object", "(", ")", "if", "\"published\"", "in", "get_request_data", "(", "request", ")", ":", "if", "not", "get_request_data", "(", "reque...
sets the `published` value of the `Content` :param request: a WSGI request object :param kwargs: keyword arguments (optional) :return: `rest_framework.response.Response`
[ "sets", "the", "published", "value", "of", "the", "Content" ]
python
train
olt/scriptine
scriptine/_path.py
https://github.com/olt/scriptine/blob/f4cfea939f2f3ad352b24c5f6410f79e78723d0e/scriptine/_path.py#L217-L228
def splitext(self): """ p.splitext() -> Return (p.stripext(), p.ext). Split the filename extension from this path and return the two parts. Either part may be empty. The extension is everything from '.' to the end of the last path segment. This has the property that if ...
[ "def", "splitext", "(", "self", ")", ":", "filename", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "self", ")", "return", "self", ".", "__class__", "(", "filename", ")", ",", "ext" ]
p.splitext() -> Return (p.stripext(), p.ext). Split the filename extension from this path and return the two parts. Either part may be empty. The extension is everything from '.' to the end of the last path segment. This has the property that if (a, b) == p.splitext(), then a...
[ "p", ".", "splitext", "()", "-", ">", "Return", "(", "p", ".", "stripext", "()", "p", ".", "ext", ")", "." ]
python
train
celery/cell
cell/workflow/entities.py
https://github.com/celery/cell/blob/c7f9b3a0c11ae3429eacb4114279cf2614e94a48/cell/workflow/entities.py#L73-L82
def main(self, *args, **kwargs): """Implement the actor main loop by waiting forever for messages.""" self.start(*args, **kwargs) try: while 1: body, message = yield self.receive() handler = self.get_handler(message) handler(body, messa...
[ "def", "main", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "start", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "while", "1", ":", "body", ",", "message", "=", "yield", "self", ".", "receive", ...
Implement the actor main loop by waiting forever for messages.
[ "Implement", "the", "actor", "main", "loop", "by", "waiting", "forever", "for", "messages", "." ]
python
train
OpenKMIP/PyKMIP
kmip/services/kmip_client.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/services/kmip_client.py#L969-L1033
def sign(self, data, unique_identifier=None, cryptographic_parameters=None, credential=None): """ Sign specified data using a specified signing key. Args: data (bytes): Data to be signed. Required. unique_identifier (string): The unique ID of the signing ...
[ "def", "sign", "(", "self", ",", "data", ",", "unique_identifier", "=", "None", ",", "cryptographic_parameters", "=", "None", ",", "credential", "=", "None", ")", ":", "operation", "=", "Operation", "(", "OperationEnum", ".", "SIGN", ")", "request_payload", ...
Sign specified data using a specified signing key. Args: data (bytes): Data to be signed. Required. unique_identifier (string): The unique ID of the signing key to be used. Optional, defaults to None. cryptographic_parameters (CryptographicParameters): A stru...
[ "Sign", "specified", "data", "using", "a", "specified", "signing", "key", "." ]
python
test
ask/redish
redish/types.py
https://github.com/ask/redish/blob/4845f8d5e12fd953ecad624b4e1e89f79a082a3e/redish/types.py#L322-L326
def range_by_score(self, min, max, num=None, withscores=False): """Return all the elements with score >= min and score <= max (a range query) from the sorted set.""" return self.client.zrangebyscore(self.name, min, max, num=num, withscores=withscores)
[ "def", "range_by_score", "(", "self", ",", "min", ",", "max", ",", "num", "=", "None", ",", "withscores", "=", "False", ")", ":", "return", "self", ".", "client", ".", "zrangebyscore", "(", "self", ".", "name", ",", "min", ",", "max", ",", "num", "...
Return all the elements with score >= min and score <= max (a range query) from the sorted set.
[ "Return", "all", "the", "elements", "with", "score", ">", "=", "min", "and", "score", "<", "=", "max", "(", "a", "range", "query", ")", "from", "the", "sorted", "set", "." ]
python
train
avelkoski/FRB
fred/clients/releases.py
https://github.com/avelkoski/FRB/blob/692bcf576e17bd1a81db2b7644f4f61aeb39e5c7/fred/clients/releases.py#L195-L225
def related_tags(self,release_id=None,tag_names=None,response_type=None,params=None): """ Function to request FRED related tags for a particular release. FRED tags are attributes assigned to series. Series are assigned tags and releases. Indirectly through series, it is possible ...
[ "def", "related_tags", "(", "self", ",", "release_id", "=", "None", ",", "tag_names", "=", "None", ",", "response_type", "=", "None", ",", "params", "=", "None", ")", ":", "path", "=", "'/release/related_tags?'", "params", "[", "'release_id'", "]", ",", "p...
Function to request FRED related tags for a particular release. FRED tags are attributes assigned to series. Series are assigned tags and releases. Indirectly through series, it is possible to get the tags for a category. No tags exist for a release that does not have series. `<h...
[ "Function", "to", "request", "FRED", "related", "tags", "for", "a", "particular", "release", ".", "FRED", "tags", "are", "attributes", "assigned", "to", "series", ".", "Series", "are", "assigned", "tags", "and", "releases", ".", "Indirectly", "through", "serie...
python
train
ratt-ru/PyMORESANE
pymoresane/iuwt.py
https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L384-L499
def gpu_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed, store_on_gpu): """ This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is the isotropic undecimated wavelet transform implemented for a GPU. INPUTS: in1 (...
[ "def", "gpu_iuwt_decomposition", "(", "in1", ",", "scale_count", ",", "scale_adjust", ",", "store_smoothed", ",", "store_on_gpu", ")", ":", "# The following simple kernel just allows for the construction of a 3D decomposition on the GPU.", "ker", "=", "SourceModule", "(", "\"\"...
This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is the isotropic undecimated wavelet transform implemented for a GPU. INPUTS: in1 (no default): Array on which the decomposition is to be performed. scale_count (no defaul...
[ "This", "function", "calls", "the", "a", "trous", "algorithm", "code", "to", "decompose", "the", "input", "into", "its", "wavelet", "coefficients", ".", "This", "is", "the", "isotropic", "undecimated", "wavelet", "transform", "implemented", "for", "a", "GPU", ...
python
train
Murali-group/halp
halp/utilities/undirected_graph_transformations.py
https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/utilities/undirected_graph_transformations.py#L81-L107
def from_networkx_graph(nx_graph): """Returns an UndirectedHypergraph object that is the graph equivalent of the given NetworkX Graph object. :param nx_graph: the NetworkX undirected graph object to transform. :returns: UndirectedHypergraph -- H object equivalent to the NetworkX undirected ...
[ "def", "from_networkx_graph", "(", "nx_graph", ")", ":", "import", "networkx", "as", "nx", "if", "not", "isinstance", "(", "nx_graph", ",", "nx", ".", "Graph", ")", ":", "raise", "TypeError", "(", "\"Transformation only applicable to undirected \\\n ...
Returns an UndirectedHypergraph object that is the graph equivalent of the given NetworkX Graph object. :param nx_graph: the NetworkX undirected graph object to transform. :returns: UndirectedHypergraph -- H object equivalent to the NetworkX undirected graph. :raises: TypeError -- Transform...
[ "Returns", "an", "UndirectedHypergraph", "object", "that", "is", "the", "graph", "equivalent", "of", "the", "given", "NetworkX", "Graph", "object", "." ]
python
train
Jammy2211/PyAutoLens
autolens/lens/ray_tracing.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/ray_tracing.py#L266-L317
def grid_at_redshift_from_image_plane_grid_and_redshift(self, image_plane_grid, redshift): """For an input grid of (y,x) arc-second image-plane coordinates, ray-trace the coordinates to any redshift in \ the strong lens configuration. This is performed using multi-plane ray-tracing and the exis...
[ "def", "grid_at_redshift_from_image_plane_grid_and_redshift", "(", "self", ",", "image_plane_grid", ",", "redshift", ")", ":", "# TODO : We need to come up with a better abstraction for multi-plane lensing 0_0", "image_plane_grid_stack", "=", "grids", ".", "GridStack", "(", "regula...
For an input grid of (y,x) arc-second image-plane coordinates, ray-trace the coordinates to any redshift in \ the strong lens configuration. This is performed using multi-plane ray-tracing and the existing redshifts and planes of the tracer. However, \ any redshift can be input even if a plane ...
[ "For", "an", "input", "grid", "of", "(", "y", "x", ")", "arc", "-", "second", "image", "-", "plane", "coordinates", "ray", "-", "trace", "the", "coordinates", "to", "any", "redshift", "in", "\\", "the", "strong", "lens", "configuration", "." ]
python
valid
spyder-ide/spyder
spyder/plugins/editor/utils/editor.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L278-L286
def cursor_position(self): """ Returns the QTextCursor position. The position is a tuple made up of the line number (0 based) and the column number (0 based). :return: tuple(line, column) """ return (self._editor.textCursor().blockNumber(), self._editor.t...
[ "def", "cursor_position", "(", "self", ")", ":", "return", "(", "self", ".", "_editor", ".", "textCursor", "(", ")", ".", "blockNumber", "(", ")", ",", "self", ".", "_editor", ".", "textCursor", "(", ")", ".", "columnNumber", "(", ")", ")" ]
Returns the QTextCursor position. The position is a tuple made up of the line number (0 based) and the column number (0 based). :return: tuple(line, column)
[ "Returns", "the", "QTextCursor", "position", ".", "The", "position", "is", "a", "tuple", "made", "up", "of", "the", "line", "number", "(", "0", "based", ")", "and", "the", "column", "number", "(", "0", "based", ")", "." ]
python
train
IDSIA/sacred
sacred/run.py
https://github.com/IDSIA/sacred/blob/72633776bed9b5bddf93ae7d215188e61970973a/sacred/run.py#L142-L158
def add_resource(self, filename): """Add a file as a resource. In Sacred terminology a resource is a file that the experiment needed to access during a run. In case of a MongoObserver that means making sure the file is stored in the database (but avoiding duplicates) along its p...
[ "def", "add_resource", "(", "self", ",", "filename", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "self", ".", "_emit_resource_added", "(", "filename", ")" ]
Add a file as a resource. In Sacred terminology a resource is a file that the experiment needed to access during a run. In case of a MongoObserver that means making sure the file is stored in the database (but avoiding duplicates) along its path and md5 sum. See also :py:meth:`...
[ "Add", "a", "file", "as", "a", "resource", "." ]
python
train
Parsl/parsl
parsl/dataflow/dflow.py
https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/dataflow/dflow.py#L586-L702
def submit(self, func, *args, executors='all', fn_hash=None, cache=False, **kwargs): """Add task to the dataflow system. If the app task has the executors attributes not set (default=='all') the task will be launched on a randomly selected executor from the list of executors. If the app...
[ "def", "submit", "(", "self", ",", "func", ",", "*", "args", ",", "executors", "=", "'all'", ",", "fn_hash", "=", "None", ",", "cache", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "cleanup_called", ":", "raise", "ValueError", ...
Add task to the dataflow system. If the app task has the executors attributes not set (default=='all') the task will be launched on a randomly selected executor from the list of executors. If the app task specifies a particular set of executors, it will be targeted at the specified exec...
[ "Add", "task", "to", "the", "dataflow", "system", "." ]
python
valid
gwastro/pycbc
pycbc/population/rates_functions.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/population/rates_functions.py#L58-L95
def save_bkg_falloff(fname_statmap, fname_bank, path, rhomin, lo_mchirp, hi_mchirp): ''' Read the STATMAP files to derive snr falloff for the background events. Save the output to a txt file Bank file is also provided to restrict triggers to BBH templates. Parameters ---------- ...
[ "def", "save_bkg_falloff", "(", "fname_statmap", ",", "fname_bank", ",", "path", ",", "rhomin", ",", "lo_mchirp", ",", "hi_mchirp", ")", ":", "with", "h5py", ".", "File", "(", "fname_bank", ",", "'r'", ")", "as", "bulk", ":", "mass1_bank", "=", "bulk", "...
Read the STATMAP files to derive snr falloff for the background events. Save the output to a txt file Bank file is also provided to restrict triggers to BBH templates. Parameters ---------- fname_statmap: string STATMAP file containing trigger information ...
[ "Read", "the", "STATMAP", "files", "to", "derive", "snr", "falloff", "for", "the", "background", "events", ".", "Save", "the", "output", "to", "a", "txt", "file", "Bank", "file", "is", "also", "provided", "to", "restrict", "triggers", "to", "BBH", "templat...
python
train
aio-libs/aioftp
aioftp/server.py
https://github.com/aio-libs/aioftp/blob/b45395b1aba41301b898040acade7010e6878a08/aioftp/server.py#L433-L445
async def close(self): """ :py:func:`asyncio.coroutine` Shutdown the server and close all connections. """ self.server.close() tasks = [self.server.wait_closed()] for connection in self.connections.values(): connection._dispatcher.cancel() ...
[ "async", "def", "close", "(", "self", ")", ":", "self", ".", "server", ".", "close", "(", ")", "tasks", "=", "[", "self", ".", "server", ".", "wait_closed", "(", ")", "]", "for", "connection", "in", "self", ".", "connections", ".", "values", "(", "...
:py:func:`asyncio.coroutine` Shutdown the server and close all connections.
[ ":", "py", ":", "func", ":", "asyncio", ".", "coroutine" ]
python
valid
librosa/librosa
librosa/effects.py
https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/effects.py#L101-L142
def harmonic(y, **kwargs): '''Extract harmonic elements from an audio time-series. Parameters ---------- y : np.ndarray [shape=(n,)] audio time series kwargs : additional keyword arguments. See `librosa.decompose.hpss` for details. Returns ------- y_harmonic : np.ndarra...
[ "def", "harmonic", "(", "y", ",", "*", "*", "kwargs", ")", ":", "# Compute the STFT matrix", "stft", "=", "core", ".", "stft", "(", "y", ")", "# Remove percussives", "stft_harm", "=", "decompose", ".", "hpss", "(", "stft", ",", "*", "*", "kwargs", ")", ...
Extract harmonic elements from an audio time-series. Parameters ---------- y : np.ndarray [shape=(n,)] audio time series kwargs : additional keyword arguments. See `librosa.decompose.hpss` for details. Returns ------- y_harmonic : np.ndarray [shape=(n,)] audio time ...
[ "Extract", "harmonic", "elements", "from", "an", "audio", "time", "-", "series", "." ]
python
test
mosdef-hub/mbuild
mbuild/formats/gsdwriter.py
https://github.com/mosdef-hub/mbuild/blob/dcb80a2becd5d0e6a7e3e7bcb1b59793c46a2dd3/mbuild/formats/gsdwriter.py#L242-L282
def _write_dihedral_information(gsd_file, structure): """Write the dihedrals in the system. Parameters ---------- gsd_file : The file object of the GSD file being written structure : parmed.Structure Parmed structure object holding system information """ gsd_file.dihedrals...
[ "def", "_write_dihedral_information", "(", "gsd_file", ",", "structure", ")", ":", "gsd_file", ".", "dihedrals", ".", "N", "=", "len", "(", "structure", ".", "rb_torsions", ")", "unique_dihedral_types", "=", "set", "(", ")", "for", "dihedral", "in", "structure...
Write the dihedrals in the system. Parameters ---------- gsd_file : The file object of the GSD file being written structure : parmed.Structure Parmed structure object holding system information
[ "Write", "the", "dihedrals", "in", "the", "system", "." ]
python
train
CygnusNetworks/pypureomapi
pypureomapi.py
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1129-L1145
def lookup_host(self, name): """Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFou...
[ "def", "lookup_host", "(", "self", ",", "name", ")", ":", "res", "=", "self", ".", "lookup_by_host", "(", "name", "=", "name", ")", "try", ":", "return", "dict", "(", "ip", "=", "res", "[", "\"ip-address\"", "]", ",", "mac", "=", "res", "[", "\"har...
Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but o...
[ "Look", "for", "a", "host", "object", "with", "given", "name", "and", "return", "the", "name", "mac", "and", "ip", "address" ]
python
train
Pytwitcher/pytwitcherapi
src/pytwitcherapi/session.py
https://github.com/Pytwitcher/pytwitcherapi/blob/d53ac5ad5ca113ecb7da542e8cdcbbf8c762b336/src/pytwitcherapi/session.py#L450-L466
def followed_streams(self, limit=25, offset=0): """Return the streams the current user follows. Needs authorization ``user_read``. :param limit: maximum number of results :type limit: :class:`int` :param offset: offset for pagination :type offset: :class:`int` :...
[ "def", "followed_streams", "(", "self", ",", "limit", "=", "25", ",", "offset", "=", "0", ")", ":", "r", "=", "self", ".", "kraken_request", "(", "'GET'", ",", "'streams/followed'", ",", "params", "=", "{", "'limit'", ":", "limit", ",", "'offset'", ":"...
Return the streams the current user follows. Needs authorization ``user_read``. :param limit: maximum number of results :type limit: :class:`int` :param offset: offset for pagination :type offset: :class:`int` :returns: A list of streams :rtype: :class:`list`of ...
[ "Return", "the", "streams", "the", "current", "user", "follows", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/enum_type_wrapper.py#L83-L89
def items(self): """Return a list of the (name, value) pairs of the enum. These are returned in the order they were defined in the .proto file. """ return [(value_descriptor.name, value_descriptor.number) for value_descriptor in self._enum_type.values]
[ "def", "items", "(", "self", ")", ":", "return", "[", "(", "value_descriptor", ".", "name", ",", "value_descriptor", ".", "number", ")", "for", "value_descriptor", "in", "self", ".", "_enum_type", ".", "values", "]" ]
Return a list of the (name, value) pairs of the enum. These are returned in the order they were defined in the .proto file.
[ "Return", "a", "list", "of", "the", "(", "name", "value", ")", "pairs", "of", "the", "enum", "." ]
python
train
ejeschke/ginga
ginga/canvas/CanvasObject.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/canvas/CanvasObject.py#L503-L516
def get_bbox(self, points=None): """ Get bounding box of this object. Returns ------- (p1, p2, p3, p4): a 4-tuple of the points in data coordinates, beginning with the lower-left and proceeding counter-clockwise. """ if points is None: x1, y1,...
[ "def", "get_bbox", "(", "self", ",", "points", "=", "None", ")", ":", "if", "points", "is", "None", ":", "x1", ",", "y1", ",", "x2", ",", "y2", "=", "self", ".", "get_llur", "(", ")", "return", "(", "(", "x1", ",", "y1", ")", ",", "(", "x1", ...
Get bounding box of this object. Returns ------- (p1, p2, p3, p4): a 4-tuple of the points in data coordinates, beginning with the lower-left and proceeding counter-clockwise.
[ "Get", "bounding", "box", "of", "this", "object", "." ]
python
train
numenta/htmresearch
htmresearch/support/csv_helper.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/support/csv_helper.py#L166-L252
def readDataAndReshuffle(args, categoriesInOrderOfInterest=None): """ Read data file specified in args, optionally reshuffle categories, print out some statistics, and return various data structures. This routine is pretty specific and only used in some simple test scripts. categoriesInOrderOfInterest (list)...
[ "def", "readDataAndReshuffle", "(", "args", ",", "categoriesInOrderOfInterest", "=", "None", ")", ":", "# Read data", "dataDict", "=", "readCSV", "(", "args", ".", "dataPath", ",", "1", ")", "labelRefs", ",", "dataDict", "=", "mapLabelRefs", "(", "dataDict", "...
Read data file specified in args, optionally reshuffle categories, print out some statistics, and return various data structures. This routine is pretty specific and only used in some simple test scripts. categoriesInOrderOfInterest (list) Optional list of integers representing ...
[ "Read", "data", "file", "specified", "in", "args", "optionally", "reshuffle", "categories", "print", "out", "some", "statistics", "and", "return", "various", "data", "structures", ".", "This", "routine", "is", "pretty", "specific", "and", "only", "used", "in", ...
python
train
rflamary/POT
ot/da.py
https://github.com/rflamary/POT/blob/c5108efc7b6702e1af3928bef1032e6b37734d1c/ot/da.py#L428-L636
def joint_OT_mapping_kernel(xs, xt, mu=1, eta=0.001, kerneltype='gaussian', sigma=1, bias=False, verbose=False, verbose2=False, numItermax=100, numInnerItermax=10, stopInnerThr=1e-6, stopThr=1e-5, log=False, ...
[ "def", "joint_OT_mapping_kernel", "(", "xs", ",", "xt", ",", "mu", "=", "1", ",", "eta", "=", "0.001", ",", "kerneltype", "=", "'gaussian'", ",", "sigma", "=", "1", ",", "bias", "=", "False", ",", "verbose", "=", "False", ",", "verbose2", "=", "False...
Joint OT and nonlinear mapping estimation with kernels as proposed in [8] The function solves the following optimization problem: .. math:: \min_{\gamma,L\in\mathcal{H}}\quad \|L(X_s) - n_s\gamma X_t\|^2_F + \mu<\gamma,M>_F + \eta \|L\|^2_\mathcal{H} s.t. \gamma 1 = a \...
[ "Joint", "OT", "and", "nonlinear", "mapping", "estimation", "with", "kernels", "as", "proposed", "in", "[", "8", "]" ]
python
train
openego/eDisGo
edisgo/tools/pypsa_io.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/tools/pypsa_io.py#L1825-L1858
def update_pypsa_generator_timeseries(network, generators_to_update=None, timesteps=None): """ Updates generator time series in pypsa representation. This function overwrites p_set and q_set of generators_t attribute of pypsa network. Be aware that if you call ...
[ "def", "update_pypsa_generator_timeseries", "(", "network", ",", "generators_to_update", "=", "None", ",", "timesteps", "=", "None", ")", ":", "_update_pypsa_timeseries_by_type", "(", "network", ",", "type", "=", "'generator'", ",", "components_to_update", "=", "gener...
Updates generator time series in pypsa representation. This function overwrites p_set and q_set of generators_t attribute of pypsa network. Be aware that if you call this function with `timesteps` and thus overwrite current time steps it may lead to inconsistencies in the pypsa network since only g...
[ "Updates", "generator", "time", "series", "in", "pypsa", "representation", "." ]
python
train
Nic30/hwt
hwt/hdl/statements.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/statements.py#L595-L607
def _get_stm_with_branches(stm_it): """ :return: first statement with rank > 0 or None if iterator empty """ last = None while last is None or last.rank == 0: try: last = next(stm_it) except StopIteration: last = None break return last
[ "def", "_get_stm_with_branches", "(", "stm_it", ")", ":", "last", "=", "None", "while", "last", "is", "None", "or", "last", ".", "rank", "==", "0", ":", "try", ":", "last", "=", "next", "(", "stm_it", ")", "except", "StopIteration", ":", "last", "=", ...
:return: first statement with rank > 0 or None if iterator empty
[ ":", "return", ":", "first", "statement", "with", "rank", ">", "0", "or", "None", "if", "iterator", "empty" ]
python
test
eallik/spinoff
spinoff/actor/uri.py
https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/actor/uri.py#L69-L95
def parse(cls, addr): """Parses a new `Uri` instance from a string representation of a URI. >>> u1 = Uri.parse('/foo/bar') >>> u1.node, u1.steps, u1.path, u1.name (None, ['', 'foo', 'bar'], '/foo/bar', 'bar') >>> u2 = Uri.parse('somenode:123/foo/bar') >>> u2.node, u1.ste...
[ "def", "parse", "(", "cls", ",", "addr", ")", ":", "if", "addr", ".", "endswith", "(", "'/'", ")", ":", "raise", "ValueError", "(", "\"Uris must not end in '/'\"", ")", "# pragma: no cover", "parts", "=", "addr", ".", "split", "(", "'/'", ")", "if", "':'...
Parses a new `Uri` instance from a string representation of a URI. >>> u1 = Uri.parse('/foo/bar') >>> u1.node, u1.steps, u1.path, u1.name (None, ['', 'foo', 'bar'], '/foo/bar', 'bar') >>> u2 = Uri.parse('somenode:123/foo/bar') >>> u2.node, u1.steps, u2.path, ur2.name ('s...
[ "Parses", "a", "new", "Uri", "instance", "from", "a", "string", "representation", "of", "a", "URI", "." ]
python
train
mgaitan/waliki
waliki/management/commands/moin_migration_cleanup.py
https://github.com/mgaitan/waliki/blob/5baaf6f043275920a1174ff233726f7ff4bfb5cf/waliki/management/commands/moin_migration_cleanup.py#L21-L29
def clean_meta(rst_content): """remove moinmoin metada from the top of the file""" rst = rst_content.split('\n') for i, line in enumerate(rst): if line.startswith('#'): continue break return '\n'.join(rst[i:])
[ "def", "clean_meta", "(", "rst_content", ")", ":", "rst", "=", "rst_content", ".", "split", "(", "'\\n'", ")", "for", "i", ",", "line", "in", "enumerate", "(", "rst", ")", ":", "if", "line", ".", "startswith", "(", "'#'", ")", ":", "continue", "break...
remove moinmoin metada from the top of the file
[ "remove", "moinmoin", "metada", "from", "the", "top", "of", "the", "file" ]
python
train
saulpw/visidata
visidata/canvas.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/canvas.py#L491-L494
def zoomTo(self, bbox): 'set visible area to bbox, maintaining aspectRatio if applicable' self.fixPoint(self.plotviewBox.xymin, bbox.xymin) self.zoomlevel=max(bbox.w/self.canvasBox.w, bbox.h/self.canvasBox.h)
[ "def", "zoomTo", "(", "self", ",", "bbox", ")", ":", "self", ".", "fixPoint", "(", "self", ".", "plotviewBox", ".", "xymin", ",", "bbox", ".", "xymin", ")", "self", ".", "zoomlevel", "=", "max", "(", "bbox", ".", "w", "/", "self", ".", "canvasBox",...
set visible area to bbox, maintaining aspectRatio if applicable
[ "set", "visible", "area", "to", "bbox", "maintaining", "aspectRatio", "if", "applicable" ]
python
train
inasafe/inasafe
safe/plugin.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/plugin.py#L236-L248
def _create_minimum_needs_action(self): """Create action for minimum needs dialog.""" icon = resources_path('img', 'icons', 'show-minimum-needs.svg') self.action_minimum_needs = QAction( QIcon(icon), self.tr('Minimum Needs Calculator'), self.iface.mainWindow()) se...
[ "def", "_create_minimum_needs_action", "(", "self", ")", ":", "icon", "=", "resources_path", "(", "'img'", ",", "'icons'", ",", "'show-minimum-needs.svg'", ")", "self", ".", "action_minimum_needs", "=", "QAction", "(", "QIcon", "(", "icon", ")", ",", "self", "...
Create action for minimum needs dialog.
[ "Create", "action", "for", "minimum", "needs", "dialog", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L12923-L12931
def extended_sys_state_send(self, vtol_state, landed_state, force_mavlink1=False): ''' Provides state for additional features vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t) ...
[ "def", "extended_sys_state_send", "(", "self", ",", "vtol_state", ",", "landed_state", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "extended_sys_state_encode", "(", "vtol_state", ",", "landed_state", ")", ",", ...
Provides state for additional features vtol_state : The VTOL state if applicable. Is set to MAV_VTOL_STATE_UNDEFINED if UAV is not in VTOL configuration. (uint8_t) landed_state : The landed state. Is set to MAV_LANDED_STATE_UNDEFINED if landed state is unknow...
[ "Provides", "state", "for", "additional", "features" ]
python
train
dereneaton/ipyrad
ipyrad/assemble/consens_se.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/consens_se.py#L807-L845
def calculate_depths(data, samples, lbview): """ check whether mindepth has changed, and thus whether clusters_hidepth needs to be recalculated, and get new maxlen for new highdepth clusts. if mindepth not changed then nothing changes. """ ## send jobs to be processed on engines start = tim...
[ "def", "calculate_depths", "(", "data", ",", "samples", ",", "lbview", ")", ":", "## send jobs to be processed on engines", "start", "=", "time", ".", "time", "(", ")", "printstr", "=", "\" calculating depths | {} | s5 |\"", "recaljobs", "=", "{", "}", "maxlens",...
check whether mindepth has changed, and thus whether clusters_hidepth needs to be recalculated, and get new maxlen for new highdepth clusts. if mindepth not changed then nothing changes.
[ "check", "whether", "mindepth", "has", "changed", "and", "thus", "whether", "clusters_hidepth", "needs", "to", "be", "recalculated", "and", "get", "new", "maxlen", "for", "new", "highdepth", "clusts", ".", "if", "mindepth", "not", "changed", "then", "nothing", ...
python
valid
KieranWynn/pyquaternion
pyquaternion/quaternion.py
https://github.com/KieranWynn/pyquaternion/blob/d2aad7f3fb0d4b9cc23aa72b390e9b2e1273eae9/pyquaternion/quaternion.py#L888-L918
def intermediates(cls, q0, q1, n, include_endpoints=False): """Generator method to get an iterable sequence of `n` evenly spaced quaternion rotations between any two existing quaternion endpoints lying on the unit radius hypersphere. This is a convenience function that is based on `Quat...
[ "def", "intermediates", "(", "cls", ",", "q0", ",", "q1", ",", "n", ",", "include_endpoints", "=", "False", ")", ":", "step_size", "=", "1.0", "/", "(", "n", "+", "1", ")", "if", "include_endpoints", ":", "steps", "=", "[", "i", "*", "step_size", "...
Generator method to get an iterable sequence of `n` evenly spaced quaternion rotations between any two existing quaternion endpoints lying on the unit radius hypersphere. This is a convenience function that is based on `Quaternion.slerp()` as defined above. This is a class method and i...
[ "Generator", "method", "to", "get", "an", "iterable", "sequence", "of", "n", "evenly", "spaced", "quaternion", "rotations", "between", "any", "two", "existing", "quaternion", "endpoints", "lying", "on", "the", "unit", "radius", "hypersphere", "." ]
python
train
broadinstitute/fiss
firecloud/fiss.py
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L171-L188
def space_set_acl(args): """ Assign an ACL role to list of users for a workspace """ acl_updates = [{"email": user, "accessLevel": args.role} for user in args.users] r = fapi.update_workspace_acl(args.project, args.workspace, acl_updates) fapi._check_response_code(r, 200) errors =...
[ "def", "space_set_acl", "(", "args", ")", ":", "acl_updates", "=", "[", "{", "\"email\"", ":", "user", ",", "\"accessLevel\"", ":", "args", ".", "role", "}", "for", "user", "in", "args", ".", "users", "]", "r", "=", "fapi", ".", "update_workspace_acl", ...
Assign an ACL role to list of users for a workspace
[ "Assign", "an", "ACL", "role", "to", "list", "of", "users", "for", "a", "workspace" ]
python
train
insightindustry/validator-collection
validator_collection/validators.py
https://github.com/insightindustry/validator-collection/blob/8c8047a0fa36cc88a021771279898278c4cc98e3/validator_collection/validators.py#L1082-L1219
def timezone(value, allow_empty = False, positive = True, **kwargs): """Validate that ``value`` is a valid :class:`tzinfo <python:datetime.tzinfo>`. .. caution:: This does **not** verify whether the value is a timezone that actually exists, nor can it resolve...
[ "def", "timezone", "(", "value", ",", "allow_empty", "=", "False", ",", "positive", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=too-many-branches", "original_value", "=", "value", "if", "not", "value", "and", "not", "allow_empty", ":", ...
Validate that ``value`` is a valid :class:`tzinfo <python:datetime.tzinfo>`. .. caution:: This does **not** verify whether the value is a timezone that actually exists, nor can it resolve timezone names (e.g. ``'Eastern'`` or ``'CET'``). For that kind of functionality, we recommend you utilize:...
[ "Validate", "that", "value", "is", "a", "valid", ":", "class", ":", "tzinfo", "<python", ":", "datetime", ".", "tzinfo", ">", "." ]
python
train
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L10299-L10319
def recsph(rectan): """ Convert from rectangular coordinates to spherical coordinates. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/recrad_c.html :param rectan: Rectangular coordinates of a point. :type rectan: 3-Element Array of floats :return: Distance from the origin,...
[ "def", "recsph", "(", "rectan", ")", ":", "rectan", "=", "stypes", ".", "toDoubleVector", "(", "rectan", ")", "r", "=", "ctypes", ".", "c_double", "(", ")", "colat", "=", "ctypes", ".", "c_double", "(", ")", "lon", "=", "ctypes", ".", "c_double", "("...
Convert from rectangular coordinates to spherical coordinates. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/recrad_c.html :param rectan: Rectangular coordinates of a point. :type rectan: 3-Element Array of floats :return: Distance from the origin, Angle from the posi...
[ "Convert", "from", "rectangular", "coordinates", "to", "spherical", "coordinates", "." ]
python
train
btcspry/3d-wallet-generator
gen_3dwallet/qr_tools.py
https://github.com/btcspry/3d-wallet-generator/blob/ae54800ec072f9d8259e5fe96a448d36b58b7b59/gen_3dwallet/qr_tools.py#L5-L33
def getQRArray(text, errorCorrection): """ Takes in text and errorCorrection (letter), returns 2D array of the QR code""" # White is True (1) # Black is False (0) # ECC: L7, M15, Q25, H30 # Create the object qr = pyqrcode.create(text, error=errorCorrection) # Get the terminal representation and split by lines ...
[ "def", "getQRArray", "(", "text", ",", "errorCorrection", ")", ":", "# White is True (1)", "# Black is False (0)", "# ECC: L7, M15, Q25, H30", "# Create the object", "qr", "=", "pyqrcode", ".", "create", "(", "text", ",", "error", "=", "errorCorrection", ")", "# Get t...
Takes in text and errorCorrection (letter), returns 2D array of the QR code
[ "Takes", "in", "text", "and", "errorCorrection", "(", "letter", ")", "returns", "2D", "array", "of", "the", "QR", "code" ]
python
train
cloudtools/stacker
stacker/util.py
https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/util.py#L130-L148
def get_soa_record(client, zone_id, zone_name): """Gets the SOA record for zone_name from zone_id. Args: client (:class:`botocore.client.Route53`): The connection used to interact with Route53's API. zone_id (string): The AWS Route53 zone id of the hosted zone to query. zone...
[ "def", "get_soa_record", "(", "client", ",", "zone_id", ",", "zone_name", ")", ":", "response", "=", "client", ".", "list_resource_record_sets", "(", "HostedZoneId", "=", "zone_id", ",", "StartRecordName", "=", "zone_name", ",", "StartRecordType", "=", "\"SOA\"", ...
Gets the SOA record for zone_name from zone_id. Args: client (:class:`botocore.client.Route53`): The connection used to interact with Route53's API. zone_id (string): The AWS Route53 zone id of the hosted zone to query. zone_name (string): The name of the DNS hosted zone to crea...
[ "Gets", "the", "SOA", "record", "for", "zone_name", "from", "zone_id", "." ]
python
train
caffeinehit/django-oauth2-provider
provider/views.py
https://github.com/caffeinehit/django-oauth2-provider/blob/6b5bc0d3ad706d2aaa47fa476f38406cddd01236/provider/views.py#L202-L220
def _validate_client(self, request, data): """ :return: ``tuple`` - ``(client or False, data or error)`` """ client = self.get_client(data.get('client_id')) if client is None: raise OAuthError({ 'error': 'unauthorized_client', 'error_d...
[ "def", "_validate_client", "(", "self", ",", "request", ",", "data", ")", ":", "client", "=", "self", ".", "get_client", "(", "data", ".", "get", "(", "'client_id'", ")", ")", "if", "client", "is", "None", ":", "raise", "OAuthError", "(", "{", "'error'...
:return: ``tuple`` - ``(client or False, data or error)``
[ ":", "return", ":", "tuple", "-", "(", "client", "or", "False", "data", "or", "error", ")" ]
python
train
waqasbhatti/astrobase
astrobase/timeutils.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/timeutils.py#L442-L469
def jd_to_datetime(jd, returniso=False): '''This converts a UTC JD to a Python `datetime` object or ISO date string. Parameters ---------- jd : float The Julian date measured at UTC. returniso : bool If False, returns a naive Python `datetime` object corresponding to `jd`....
[ "def", "jd_to_datetime", "(", "jd", ",", "returniso", "=", "False", ")", ":", "tt", "=", "astime", ".", "Time", "(", "jd", ",", "format", "=", "'jd'", ",", "scale", "=", "'utc'", ")", "if", "returniso", ":", "return", "tt", ".", "iso", "else", ":",...
This converts a UTC JD to a Python `datetime` object or ISO date string. Parameters ---------- jd : float The Julian date measured at UTC. returniso : bool If False, returns a naive Python `datetime` object corresponding to `jd`. If True, returns the ISO format string correspo...
[ "This", "converts", "a", "UTC", "JD", "to", "a", "Python", "datetime", "object", "or", "ISO", "date", "string", "." ]
python
valid
mfcloud/python-zvm-sdk
smtLayer/makeVM.py
https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/makeVM.py#L309-L370
def showOperandLines(rh): """ Produce help output related to operands. Input: Request Handle """ if rh.function == 'HELP': rh.printLn("N", " For the MakeVM function:") else: rh.printLn("N", "Sub-Functions(s):") rh.printLn("N", " directory - " + "Cre...
[ "def", "showOperandLines", "(", "rh", ")", ":", "if", "rh", ".", "function", "==", "'HELP'", ":", "rh", ".", "printLn", "(", "\"N\"", ",", "\" For the MakeVM function:\"", ")", "else", ":", "rh", ".", "printLn", "(", "\"N\"", ",", "\"Sub-Functions(s):\"", ...
Produce help output related to operands. Input: Request Handle
[ "Produce", "help", "output", "related", "to", "operands", "." ]
python
train
persandstrom/python-verisure
verisure/session.py
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L605-L621
def set_heat_pump_feature(self, device_label, feature): """ Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL' """ response = None try: response = requests.put( urls.set_heatpump_feature(self._giid, device_label, feature), ...
[ "def", "set_heat_pump_feature", "(", "self", ",", "device_label", ",", "feature", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "put", "(", "urls", ".", "set_heatpump_feature", "(", "self", ".", "_giid", ",", "device_label"...
Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL'
[ "Set", "heatpump", "mode", "Args", ":", "feature", ":", "QUIET", "ECONAVI", "or", "POWERFUL" ]
python
train
basho/riak-python-client
riak/transports/pool.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/pool.py#L177-L207
def transaction(self, _filter=None, default=None, yield_resource=False): """ transaction(_filter=None, default=None) Claims a resource from the pool for use in a thread-safe, reentrant manner (as part of a with statement). Resources are created as needed when all members of the ...
[ "def", "transaction", "(", "self", ",", "_filter", "=", "None", ",", "default", "=", "None", ",", "yield_resource", "=", "False", ")", ":", "resource", "=", "self", ".", "acquire", "(", "_filter", "=", "_filter", ",", "default", "=", "default", ")", "t...
transaction(_filter=None, default=None) Claims a resource from the pool for use in a thread-safe, reentrant manner (as part of a with statement). Resources are created as needed when all members of the pool are claimed or the pool is empty. :param _filter: a filter that can be ...
[ "transaction", "(", "_filter", "=", "None", "default", "=", "None", ")" ]
python
train
dictatorlib/dictator
dictator/__init__.py
https://github.com/dictatorlib/dictator/blob/b77b1709b6fff174f13b0f0c5dbe740b4c07d712/dictator/__init__.py#L208-L235
def get(self, key, default=None): """Return the value at key ``key``, or default value ``default`` which is None by default. >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc.get('l0') ['1', '2', '3', '4'] >>> dc['l0'] ['1', '2', '3', '4'] >>...
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "try", ":", "value", "=", "self", ".", "__getitem__", "(", "key", ")", "except", "KeyError", ":", "value", "=", "None", "# Py3 Redis compatibiility", "if", "isinstance", "(", ...
Return the value at key ``key``, or default value ``default`` which is None by default. >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc.get('l0') ['1', '2', '3', '4'] >>> dc['l0'] ['1', '2', '3', '4'] >>> dc.clear() :param key: key of valu...
[ "Return", "the", "value", "at", "key", "key", "or", "default", "value", "default", "which", "is", "None", "by", "default", "." ]
python
train
timothycrosley/concentration
concentration/run.py
https://github.com/timothycrosley/concentration/blob/5d07a79cdf56054c42b6e2d1c95ea51bc6678fc4/concentration/run.py#L26-L38
def improve(): """Disables access to websites that are defined as 'distractors'""" with open(settings.HOSTS_FILE, "r+") as hosts_file: contents = hosts_file.read() if not settings.START_TOKEN in contents and not settings.END_TOKEN in contents: hosts_file.write(settings.START_TOKEN + ...
[ "def", "improve", "(", ")", ":", "with", "open", "(", "settings", ".", "HOSTS_FILE", ",", "\"r+\"", ")", "as", "hosts_file", ":", "contents", "=", "hosts_file", ".", "read", "(", ")", "if", "not", "settings", ".", "START_TOKEN", "in", "contents", "and", ...
Disables access to websites that are defined as 'distractors
[ "Disables", "access", "to", "websites", "that", "are", "defined", "as", "distractors" ]
python
train
odlgroup/odl
doc/source/guide/code/functional_indepth_example.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/doc/source/guide/code/functional_indepth_example.py#L34-L56
def gradient(self): """The gradient operator.""" # First we store the functional in a variable functional = self # The class corresponding to the gradient operator. class MyGradientOperator(odl.Operator): """Class implementing the gradient operator.""" ...
[ "def", "gradient", "(", "self", ")", ":", "# First we store the functional in a variable", "functional", "=", "self", "# The class corresponding to the gradient operator.", "class", "MyGradientOperator", "(", "odl", ".", "Operator", ")", ":", "\"\"\"Class implementing the gradi...
The gradient operator.
[ "The", "gradient", "operator", "." ]
python
train
Accelize/pycosio
pycosio/storage/s3.py
https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/s3.py#L113-L127
def _get_client(self): """ S3 Boto3 client Returns: boto3.session.Session.client: client """ client_kwargs = self._storage_parameters.get('client', dict()) # Handles unsecure mode if self._unsecure: client_kwargs = client_kwargs.copy() ...
[ "def", "_get_client", "(", "self", ")", ":", "client_kwargs", "=", "self", ".", "_storage_parameters", ".", "get", "(", "'client'", ",", "dict", "(", ")", ")", "# Handles unsecure mode", "if", "self", ".", "_unsecure", ":", "client_kwargs", "=", "client_kwargs...
S3 Boto3 client Returns: boto3.session.Session.client: client
[ "S3", "Boto3", "client" ]
python
train
attm2x/m2x-python
m2x/v2/streams.py
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L76-L90
def add_value(self, value, timestamp=None): """ Method for `Update Data Stream Value <https://m2x.att.com/developer/documentation/v2/device#Update-Data-Stream-Value>`_ endpoint. :param value: The updated stream value :param timestamp: The (optional) timestamp for the upadted value :ret...
[ "def", "add_value", "(", "self", ",", "value", ",", "timestamp", "=", "None", ")", ":", "data", "=", "{", "'value'", ":", "value", "}", "if", "timestamp", ":", "data", "[", "'timestamp'", "]", "=", "timestamp", "return", "self", ".", "api", ".", "put...
Method for `Update Data Stream Value <https://m2x.att.com/developer/documentation/v2/device#Update-Data-Stream-Value>`_ endpoint. :param value: The updated stream value :param timestamp: The (optional) timestamp for the upadted value :return: The API response, see M2X API docs for details ...
[ "Method", "for", "Update", "Data", "Stream", "Value", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Update", "-", "Data", "-", "Stream", "-", "Value", ">", "_", "endpoint", "." ]
python
test
basilfx/flask-daapserver
daapserver/provider.py
https://github.com/basilfx/flask-daapserver/blob/ca595fcbc5b657cba826eccd3be5cebba0a1db0e/daapserver/provider.py#L356-L382
def get_item_data(self, session, item, byte_range=None): """ Return a file pointer to the item file. Assumes `item.file_name` points to the file on disk. """ # Parse byte range if byte_range is not None: begin, end = parse_byte_range(byte_range, max_byte=item...
[ "def", "get_item_data", "(", "self", ",", "session", ",", "item", ",", "byte_range", "=", "None", ")", ":", "# Parse byte range", "if", "byte_range", "is", "not", "None", ":", "begin", ",", "end", "=", "parse_byte_range", "(", "byte_range", ",", "max_byte", ...
Return a file pointer to the item file. Assumes `item.file_name` points to the file on disk.
[ "Return", "a", "file", "pointer", "to", "the", "item", "file", ".", "Assumes", "item", ".", "file_name", "points", "to", "the", "file", "on", "disk", "." ]
python
train
GoogleCloudPlatform/python-repo-tools
gcp_devrel/tools/requirements.py
https://github.com/GoogleCloudPlatform/python-repo-tools/blob/87422ba91814529848a2b8bf8be4294283a3e041/gcp_devrel/tools/requirements.py#L176-L188
def update_command(args): """Updates all dependencies the specified requirements file.""" updated = update_requirements_file( args.requirements_file, args.skip_packages) if updated: print('Updated requirements in {}:'.format(args.requirements_file)) for item in updated: ...
[ "def", "update_command", "(", "args", ")", ":", "updated", "=", "update_requirements_file", "(", "args", ".", "requirements_file", ",", "args", ".", "skip_packages", ")", "if", "updated", ":", "print", "(", "'Updated requirements in {}:'", ".", "format", "(", "a...
Updates all dependencies the specified requirements file.
[ "Updates", "all", "dependencies", "the", "specified", "requirements", "file", "." ]
python
train
zkbt/the-friendly-stars
thefriendlystars/constellations/constellation.py
https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/constellations/constellation.py#L183-L223
def from_text(cls, filename, **kwargs): ''' Create a constellation by reading a catalog in from a text file, as long as it's formated as in to_text() with identifiers, coordinates, magnitudes. Parameters ---------- filename : str The filename to read in. ...
[ "def", "from_text", "(", "cls", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "# FIXME -- add something here to parse id, mag, errors from the table?", "# load the table", "t", "=", "ascii", ".", "read", "(", "filename", ",", "*", "*", "kwargs", ")", "'''\n ...
Create a constellation by reading a catalog in from a text file, as long as it's formated as in to_text() with identifiers, coordinates, magnitudes. Parameters ---------- filename : str The filename to read in. **kwargs are passed to astropy.io.ascii.read()
[ "Create", "a", "constellation", "by", "reading", "a", "catalog", "in", "from", "a", "text", "file", "as", "long", "as", "it", "s", "formated", "as", "in", "to_text", "()", "with", "identifiers", "coordinates", "magnitudes", "." ]
python
train
senaite/senaite.core
bika/lims/catalog/catalog_utilities.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/catalog/catalog_utilities.py#L202-L247
def _map_content_types(archetype_tool, catalogs_definition): """ Updates the mapping for content_types against catalogs :archetype_tool: an archetype_tool object :catalogs_definition: a dictionary like { CATALOG_ID: { 'types': ['ContentType', ...], '...
[ "def", "_map_content_types", "(", "archetype_tool", ",", "catalogs_definition", ")", ":", "# This will be a dictionari like {'content_type':['catalog_id', ...]}", "ct_map", "=", "{", "}", "# This list will contain the atalog ids to be rebuild", "to_reindex", "=", "[", "]", "# get...
Updates the mapping for content_types against catalogs :archetype_tool: an archetype_tool object :catalogs_definition: a dictionary like { CATALOG_ID: { 'types': ['ContentType', ...], 'indexes': { 'UID': 'FieldIndex', ...
[ "Updates", "the", "mapping", "for", "content_types", "against", "catalogs", ":", "archetype_tool", ":", "an", "archetype_tool", "object", ":", "catalogs_definition", ":", "a", "dictionary", "like", "{", "CATALOG_ID", ":", "{", "types", ":", "[", "ContentType", "...
python
train
eaton-lab/toytree
toytree/utils.py
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L30-L41
def node_scale_root_height(self, treeheight=1): """ Returns a toytree copy with all nodes scaled so that the root height equals the value entered for treeheight. """ # make tree height = 1 * treeheight ctree = self._ttree.copy() _height = ctree.treenode.height ...
[ "def", "node_scale_root_height", "(", "self", ",", "treeheight", "=", "1", ")", ":", "# make tree height = 1 * treeheight", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "_height", "=", "ctree", ".", "treenode", ".", "height", "for", "node", "i...
Returns a toytree copy with all nodes scaled so that the root height equals the value entered for treeheight.
[ "Returns", "a", "toytree", "copy", "with", "all", "nodes", "scaled", "so", "that", "the", "root", "height", "equals", "the", "value", "entered", "for", "treeheight", "." ]
python
train
pypa/pipenv
pipenv/patched/notpip/_vendor/pkg_resources/__init__.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/pkg_resources/__init__.py#L277-L285
def with_context(self, required_by): """ If required_by is non-empty, return a version of self that is a ContextualVersionConflict. """ if not required_by: return self args = self.args + (required_by,) return ContextualVersionConflict(*args)
[ "def", "with_context", "(", "self", ",", "required_by", ")", ":", "if", "not", "required_by", ":", "return", "self", "args", "=", "self", ".", "args", "+", "(", "required_by", ",", ")", "return", "ContextualVersionConflict", "(", "*", "args", ")" ]
If required_by is non-empty, return a version of self that is a ContextualVersionConflict.
[ "If", "required_by", "is", "non", "-", "empty", "return", "a", "version", "of", "self", "that", "is", "a", "ContextualVersionConflict", "." ]
python
train
santoshphilip/eppy
eppy/modeleditor.py
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/modeleditor.py#L616-L634
def initread(self, idfname): """ Use the current IDD and read an IDF from file. If the IDD has not yet been initialised then this is done first. Parameters ---------- idf_name : str Path to an IDF file. """ with open(idfname, 'r') as _: ...
[ "def", "initread", "(", "self", ",", "idfname", ")", ":", "with", "open", "(", "idfname", ",", "'r'", ")", "as", "_", ":", "# raise nonexistent file error early if idfname doesn't exist", "pass", "iddfhandle", "=", "StringIO", "(", "iddcurrent", ".", "iddtxt", "...
Use the current IDD and read an IDF from file. If the IDD has not yet been initialised then this is done first. Parameters ---------- idf_name : str Path to an IDF file.
[ "Use", "the", "current", "IDD", "and", "read", "an", "IDF", "from", "file", ".", "If", "the", "IDD", "has", "not", "yet", "been", "initialised", "then", "this", "is", "done", "first", "." ]
python
train
vmagamedov/grpclib
grpclib/server.py
https://github.com/vmagamedov/grpclib/blob/e4a0af8d2802297586cf8d67d2d3e65f31c09dae/grpclib/server.py#L542-L551
async def wait_closed(self): """Coroutine to wait until all existing request handlers will exit properly. """ if self._server is None: raise RuntimeError('Server is not started') await self._server.wait_closed() if self._handlers: await asyncio.wai...
[ "async", "def", "wait_closed", "(", "self", ")", ":", "if", "self", ".", "_server", "is", "None", ":", "raise", "RuntimeError", "(", "'Server is not started'", ")", "await", "self", ".", "_server", ".", "wait_closed", "(", ")", "if", "self", ".", "_handler...
Coroutine to wait until all existing request handlers will exit properly.
[ "Coroutine", "to", "wait", "until", "all", "existing", "request", "handlers", "will", "exit", "properly", "." ]
python
train
SoftwareDefinedBuildings/XBOS
apps/Data_quality_analysis/Model_Data.py
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/Data_quality_analysis/Model_Data.py#L456-L497
def best_model_fit(self): """ Fit data to optimal model and return its metrics. Returns ------- dict Best model's metrics """ self.best_model.fit(self.baseline_in, self.baseline_out) self.y_true = self.baseline_out # Pan...
[ "def", "best_model_fit", "(", "self", ")", ":", "self", ".", "best_model", ".", "fit", "(", "self", ".", "baseline_in", ",", "self", ".", "baseline_out", ")", "self", ".", "y_true", "=", "self", ".", "baseline_out", "# Pandas Series", "self", ".", "y_pred"...
Fit data to optimal model and return its metrics. Returns ------- dict Best model's metrics
[ "Fit", "data", "to", "optimal", "model", "and", "return", "its", "metrics", "." ]
python
train
MacHu-GWU/angora-project
angora/dataIO/pk.py
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/dataIO/pk.py#L253-L326
def safe_dump_pk(obj, abspath, pk_protocol=pk_protocol, compress=False, enable_verbose=True): """A stable version of dump_pk, silently overwrite existing file. When your program been interrupted, you lose nothing. Typically if your program is interrupted by any reason, it only leaves a inc...
[ "def", "safe_dump_pk", "(", "obj", ",", "abspath", ",", "pk_protocol", "=", "pk_protocol", ",", "compress", "=", "False", ",", "enable_verbose", "=", "True", ")", ":", "abspath", "=", "str", "(", "abspath", ")", "# try stringlize", "temp_abspath", "=", "\"%s...
A stable version of dump_pk, silently overwrite existing file. When your program been interrupted, you lose nothing. Typically if your program is interrupted by any reason, it only leaves a incomplete file. If you use replace=True, then you also lose your old file. So a bettr way is to: 1. dump p...
[ "A", "stable", "version", "of", "dump_pk", "silently", "overwrite", "existing", "file", "." ]
python
train
edx/edx-enterprise
enterprise/admin/forms.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/forms.py#L233-L267
def clean(self): """ Clean fields that depend on each other. In this case, the form can be used to link single user or bulk link multiple users. These are mutually exclusive modes, so this method checks that only one field is passed. """ cleaned_data = super(ManageLearne...
[ "def", "clean", "(", "self", ")", ":", "cleaned_data", "=", "super", "(", "ManageLearnersForm", ",", "self", ")", ".", "clean", "(", ")", "# Here we take values from `data` (and not `cleaned_data`) as we need raw values - field clean methods", "# might \"invalidate\" the value ...
Clean fields that depend on each other. In this case, the form can be used to link single user or bulk link multiple users. These are mutually exclusive modes, so this method checks that only one field is passed.
[ "Clean", "fields", "that", "depend", "on", "each", "other", "." ]
python
valid
christophertbrown/bioscripts
ctbBio/ncbi_download.py
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L158-L195
def getFTPs(accessions, ftp, search, exclude, convert = False, threads = 1, attempt = 1, max_attempts = 2): """ download genome info from NCBI """ info = wget(ftp)[0] allMatches = [] for genome in open(info, encoding = 'utf8'): genome = str(genome) matches, genomeInfo...
[ "def", "getFTPs", "(", "accessions", ",", "ftp", ",", "search", ",", "exclude", ",", "convert", "=", "False", ",", "threads", "=", "1", ",", "attempt", "=", "1", ",", "max_attempts", "=", "2", ")", ":", "info", "=", "wget", "(", "ftp", ")", "[", ...
download genome info from NCBI
[ "download", "genome", "info", "from", "NCBI" ]
python
train
JarryShaw/PyPCAPKit
src/reassembly/ip.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/reassembly/ip.py#L109-L165
def reassembly(self, info): """Reassembly procedure. Positional arguments: * info -- Info, info dict of packets to be reassembled """ BUFID = info.bufid # Buffer Identifier FO = info.fo # Fragment Offset IHL = info.ihl # Internet Header Length ...
[ "def", "reassembly", "(", "self", ",", "info", ")", ":", "BUFID", "=", "info", ".", "bufid", "# Buffer Identifier", "FO", "=", "info", ".", "fo", "# Fragment Offset", "IHL", "=", "info", ".", "ihl", "# Internet Header Length", "MF", "=", "info", ".", "mf",...
Reassembly procedure. Positional arguments: * info -- Info, info dict of packets to be reassembled
[ "Reassembly", "procedure", "." ]
python
train
bjmorgan/vasppy
vasppy/poscar.py
https://github.com/bjmorgan/vasppy/blob/cc2d1449697b17ee1c43715a02cddcb1139a6834/vasppy/poscar.py#L261-L272
def stoichiometry( self ): """ Stoichiometry for this POSCAR, as a Counter. e.g. AB_2O_4 -> Counter( { 'A': 1, 'B': 2, O: 4 } ) Args: None Returns: None """ return Counter( { label: number for label, number in zip( self.atoms, sel...
[ "def", "stoichiometry", "(", "self", ")", ":", "return", "Counter", "(", "{", "label", ":", "number", "for", "label", ",", "number", "in", "zip", "(", "self", ".", "atoms", ",", "self", ".", "atom_numbers", ")", "}", ")" ]
Stoichiometry for this POSCAR, as a Counter. e.g. AB_2O_4 -> Counter( { 'A': 1, 'B': 2, O: 4 } ) Args: None Returns: None
[ "Stoichiometry", "for", "this", "POSCAR", "as", "a", "Counter", ".", "e", ".", "g", ".", "AB_2O_4", "-", ">", "Counter", "(", "{", "A", ":", "1", "B", ":", "2", "O", ":", "4", "}", ")", "Args", ":", "None" ]
python
train
jazzband/django-ddp
dddp/__init__.py
https://github.com/jazzband/django-ddp/blob/1e1954b06fe140346acea43582515991685e4e01/dddp/__init__.py#L69-L81
def as_dict(self, **kwargs): """Return an error dict for self.args and kwargs.""" error, reason, details, err_kwargs = self.args result = { key: val for key, val in { 'error': error, 'reason': reason, 'details': details, }.items() i...
[ "def", "as_dict", "(", "self", ",", "*", "*", "kwargs", ")", ":", "error", ",", "reason", ",", "details", ",", "err_kwargs", "=", "self", ".", "args", "result", "=", "{", "key", ":", "val", "for", "key", ",", "val", "in", "{", "'error'", ":", "er...
Return an error dict for self.args and kwargs.
[ "Return", "an", "error", "dict", "for", "self", ".", "args", "and", "kwargs", "." ]
python
test
markomanninen/abnum
remarkuple/table.py
https://github.com/markomanninen/abnum/blob/9bfc8f06f34d9a51aab038638f87e2bb5f9f4c99/remarkuple/table.py#L7-L86
def table(*args, **kw): """ Table function presents the idea of extending tags for simpler generation of some html element groups. Table has several group of tags in well defined structure. Caption header should be right after table and before thead for example. Colgroup, tfoot, tbody, tr, td and th...
[ "def", "table", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "class", "table", "(", "type", "(", "helper", ".", "table", "(", ")", ")", ")", ":", "\"\"\" Extend base table tag class \"\"\"", "def", "__init__", "(", "self", ",", "*", "args", ",", ...
Table function presents the idea of extending tags for simpler generation of some html element groups. Table has several group of tags in well defined structure. Caption header should be right after table and before thead for example. Colgroup, tfoot, tbody, tr, td and th elements has certain order which ar...
[ "Table", "function", "presents", "the", "idea", "of", "extending", "tags", "for", "simpler", "generation", "of", "some", "html", "element", "groups", ".", "Table", "has", "several", "group", "of", "tags", "in", "well", "defined", "structure", ".", "Caption", ...
python
train
shoebot/shoebot
extensions/lib/shoebotit/gtk3_utils.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L162-L167
def is_venv(directory, executable='python'): """ :param directory: base directory of python environment """ path=os.path.join(directory, 'bin', executable) return os.path.isfile(path)
[ "def", "is_venv", "(", "directory", ",", "executable", "=", "'python'", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'bin'", ",", "executable", ")", "return", "os", ".", "path", ".", "isfile", "(", "path", ")" ]
:param directory: base directory of python environment
[ ":", "param", "directory", ":", "base", "directory", "of", "python", "environment" ]
python
valid
ska-sa/hypercube
hypercube/base_cube.py
https://github.com/ska-sa/hypercube/blob/6564a9e65ccd9ed7e7a71bd643f183e1ec645b29/hypercube/base_cube.py#L774-L809
def slice_iter(self, *dim_strides, **kwargs): """ Recursively iterate over the (dimension, stride) tuples specified in dim_strides, returning the chunk start offsets for each specified dimensions. For example, the following call effectively produces 2 loops over the 'nti...
[ "def", "slice_iter", "(", "self", ",", "*", "dim_strides", ",", "*", "*", "kwargs", ")", ":", "def", "_create_slices", "(", "*", "args", ")", ":", "return", "tuple", "(", "slice", "(", "s", ",", "e", ",", "1", ")", "for", "(", "s", ",", "e", ")...
Recursively iterate over the (dimension, stride) tuples specified in dim_strides, returning the chunk start offsets for each specified dimensions. For example, the following call effectively produces 2 loops over the 'ntime' and 'nchan' dimensions in chunks of 10 and 4 respectiv...
[ "Recursively", "iterate", "over", "the", "(", "dimension", "stride", ")", "tuples", "specified", "in", "dim_strides", "returning", "the", "chunk", "start", "offsets", "for", "each", "specified", "dimensions", "." ]
python
train
wtsi-hgi/python-git-subrepo
gitsubrepo/subrepo.py
https://github.com/wtsi-hgi/python-git-subrepo/blob/bb2eb2bd9a7e51b862298ddb4168cc5b8633dad0/gitsubrepo/subrepo.py#L144-L159
def pull(directory: str) -> Commit: """ Pulls the subrepo that has been cloned into the given directory. :param directory: the directory containing the subrepo :return: the commit the subrepo is on """ if not os.path.exists(directory): raise ValueError(f"No subrepo found in \"{directory}...
[ "def", "pull", "(", "directory", ":", "str", ")", "->", "Commit", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "directory", ")", ":", "raise", "ValueError", "(", "f\"No subrepo found in \\\"{directory}\\\"\"", ")", "try", ":", "result", "=", "r...
Pulls the subrepo that has been cloned into the given directory. :param directory: the directory containing the subrepo :return: the commit the subrepo is on
[ "Pulls", "the", "subrepo", "that", "has", "been", "cloned", "into", "the", "given", "directory", ".", ":", "param", "directory", ":", "the", "directory", "containing", "the", "subrepo", ":", "return", ":", "the", "commit", "the", "subrepo", "is", "on" ]
python
train
GeospatialPython/pyshp
shapefile.py
https://github.com/GeospatialPython/pyshp/blob/71231ddc5aa54f155d4f0563c56006fffbfc84e7/shapefile.py#L635-L650
def load(self, shapefile=None): """Opens a shapefile from a filename or file-like object. Normally this method would be called by the constructor with the file name as an argument.""" if shapefile: (shapeName, ext) = os.path.splitext(shapefile) self.shapeNam...
[ "def", "load", "(", "self", ",", "shapefile", "=", "None", ")", ":", "if", "shapefile", ":", "(", "shapeName", ",", "ext", ")", "=", "os", ".", "path", ".", "splitext", "(", "shapefile", ")", "self", ".", "shapeName", "=", "shapeName", "self", ".", ...
Opens a shapefile from a filename or file-like object. Normally this method would be called by the constructor with the file name as an argument.
[ "Opens", "a", "shapefile", "from", "a", "filename", "or", "file", "-", "like", "object", ".", "Normally", "this", "method", "would", "be", "called", "by", "the", "constructor", "with", "the", "file", "name", "as", "an", "argument", "." ]
python
train
confluentinc/confluent-kafka-python
confluent_kafka/__init__.py
https://github.com/confluentinc/confluent-kafka-python/blob/5a8aeb741609e61eaccafff2a67fa494dd549e8b/confluent_kafka/__init__.py#L47-L102
def _resolve_plugins(plugins): """ Resolve embedded plugins from the wheel's library directory. For internal module use only. :param str plugins: The plugin.library.paths value """ import os from sys import platform # Location of __init__.py and the embedded library directory ...
[ "def", "_resolve_plugins", "(", "plugins", ")", ":", "import", "os", "from", "sys", "import", "platform", "# Location of __init__.py and the embedded library directory", "basedir", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "if", "platform", "in",...
Resolve embedded plugins from the wheel's library directory. For internal module use only. :param str plugins: The plugin.library.paths value
[ "Resolve", "embedded", "plugins", "from", "the", "wheel", "s", "library", "directory", "." ]
python
train
vmware/pyvmomi
pyVmomi/DynamicTypeManagerHelper.py
https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVmomi/DynamicTypeManagerHelper.py#L145-L151
def _ConvertAnnotations(self, annotations): """ Convert annotations to pyVmomi flags """ flags = 0 if annotations: for annotation in annotations: flags |= self._mapFlags.get(annotation.name, 0) return flags
[ "def", "_ConvertAnnotations", "(", "self", ",", "annotations", ")", ":", "flags", "=", "0", "if", "annotations", ":", "for", "annotation", "in", "annotations", ":", "flags", "|=", "self", ".", "_mapFlags", ".", "get", "(", "annotation", ".", "name", ",", ...
Convert annotations to pyVmomi flags
[ "Convert", "annotations", "to", "pyVmomi", "flags" ]
python
train
CalebBell/fluids
fluids/two_phase_voidage.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/two_phase_voidage.py#L517-L567
def Nishino_Yamazaki(x, rhol, rhog): r'''Calculates void fraction in two-phase flow according to the model presented in [1]_ as shown in [2]_. .. math:: \alpha = 1 - \left(\frac{1-x}{x}\frac{\rho_g}{\rho_l}\right)^{0.5} \alpha_h^{0.5} Parameters ---------- x : float ...
[ "def", "Nishino_Yamazaki", "(", "x", ",", "rhol", ",", "rhog", ")", ":", "alpha_h", "=", "homogeneous", "(", "x", ",", "rhol", ",", "rhog", ")", "return", "1", "-", "(", "(", "1", "-", "x", ")", "*", "rhog", "/", "x", "/", "rhol", ")", "**", ...
r'''Calculates void fraction in two-phase flow according to the model presented in [1]_ as shown in [2]_. .. math:: \alpha = 1 - \left(\frac{1-x}{x}\frac{\rho_g}{\rho_l}\right)^{0.5} \alpha_h^{0.5} Parameters ---------- x : float Quality at the specific tube interva...
[ "r", "Calculates", "void", "fraction", "in", "two", "-", "phase", "flow", "according", "to", "the", "model", "presented", "in", "[", "1", "]", "_", "as", "shown", "in", "[", "2", "]", "_", "." ]
python
train
fedora-infra/fedmsg
fedmsg/meta/__init__.py
https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L251-L260
def msg2long_form(msg, processor, **config): """ Return a 'long form' text representation of a message. For most message, this will just default to the terse subtitle, but for some messages a long paragraph-structured block of text may be returned. """ result = processor.long_form(msg, **config) ...
[ "def", "msg2long_form", "(", "msg", ",", "processor", ",", "*", "*", "config", ")", ":", "result", "=", "processor", ".", "long_form", "(", "msg", ",", "*", "*", "config", ")", "if", "not", "result", ":", "result", "=", "processor", ".", "subtitle", ...
Return a 'long form' text representation of a message. For most message, this will just default to the terse subtitle, but for some messages a long paragraph-structured block of text may be returned.
[ "Return", "a", "long", "form", "text", "representation", "of", "a", "message", "." ]
python
train
Azure/azure-sdk-for-python
azure-applicationinsights/azure/applicationinsights/operations/events_operations.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-applicationinsights/azure/applicationinsights/operations/events_operations.py#L36-L143
def get_by_type( self, app_id, event_type, timespan=None, filter=None, search=None, orderby=None, select=None, skip=None, top=None, format=None, count=None, apply=None, custom_headers=None, raw=False, **operation_config): """Execute OData query. Executes an OData query for events. ...
[ "def", "get_by_type", "(", "self", ",", "app_id", ",", "event_type", ",", "timespan", "=", "None", ",", "filter", "=", "None", ",", "search", "=", "None", ",", "orderby", "=", "None", ",", "select", "=", "None", ",", "skip", "=", "None", ",", "top", ...
Execute OData query. Executes an OData query for events. :param app_id: ID of the application. This is Application ID from the API Access settings blade in the Azure portal. :type app_id: str :param event_type: The type of events to query; either a standard event type...
[ "Execute", "OData", "query", "." ]
python
test
spyder-ide/spyder
spyder/widgets/tabs.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/tabs.py#L208-L228
def dropEvent(self, event): """Override Qt method""" mimeData = event.mimeData() index_from = int(mimeData.data("source-index")) index_to = self.tabAt(event.pos()) if index_to == -1: index_to = self.count() if int(mimeData.data("tabbar-id")) != id(self)...
[ "def", "dropEvent", "(", "self", ",", "event", ")", ":", "mimeData", "=", "event", ".", "mimeData", "(", ")", "index_from", "=", "int", "(", "mimeData", ".", "data", "(", "\"source-index\"", ")", ")", "index_to", "=", "self", ".", "tabAt", "(", "event"...
Override Qt method
[ "Override", "Qt", "method" ]
python
train
PmagPy/PmagPy
SPD/lib/lib_ptrm_statistics.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_ptrm_statistics.py#L73-L83
def get_DRAT(delta_x_prime, delta_y_prime, max_ptrm_check): """ Input: TRM length of best fit line (delta_x_prime), NRM length of best fit line, max_ptrm_check Output: DRAT (maximum difference produced by a ptrm check normed by best fit line), length best fit line """ L = num...
[ "def", "get_DRAT", "(", "delta_x_prime", ",", "delta_y_prime", ",", "max_ptrm_check", ")", ":", "L", "=", "numpy", ".", "sqrt", "(", "delta_x_prime", "**", "2", "+", "delta_y_prime", "**", "2", ")", "DRAT", "=", "(", "old_div", "(", "max_ptrm_check", ",", ...
Input: TRM length of best fit line (delta_x_prime), NRM length of best fit line, max_ptrm_check Output: DRAT (maximum difference produced by a ptrm check normed by best fit line), length best fit line
[ "Input", ":", "TRM", "length", "of", "best", "fit", "line", "(", "delta_x_prime", ")", "NRM", "length", "of", "best", "fit", "line", "max_ptrm_check", "Output", ":", "DRAT", "(", "maximum", "difference", "produced", "by", "a", "ptrm", "check", "normed", "b...
python
train
user-cont/conu
conu/utils/__init__.py
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L112-L141
def run_cmd(cmd, return_output=False, ignore_status=False, log_output=True, **kwargs): """ run provided command on host system using the same user as you invoked this code, raises subprocess.CalledProcessError if it fails :param cmd: list of str :param return_output: bool, return output of the comm...
[ "def", "run_cmd", "(", "cmd", ",", "return_output", "=", "False", ",", "ignore_status", "=", "False", ",", "log_output", "=", "True", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'command: \"%s\"'", "%", "' '", ".", "join", "(", "cm...
run provided command on host system using the same user as you invoked this code, raises subprocess.CalledProcessError if it fails :param cmd: list of str :param return_output: bool, return output of the command :param ignore_status: bool, do not fail in case nonzero return code :param log_output: ...
[ "run", "provided", "command", "on", "host", "system", "using", "the", "same", "user", "as", "you", "invoked", "this", "code", "raises", "subprocess", ".", "CalledProcessError", "if", "it", "fails" ]
python
train
cogniteev/docido-python-sdk
docido_sdk/toolbox/collections_ext.py
https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/collections_ext.py#L133-L163
def flatten_dict(d, prefix='', sep='.'): """In place dict flattening. """ def apply_and_resolve_conflicts(dest, item, prefix): for k, v in flatten_dict(item, prefix=prefix, sep=sep).items(): new_key = k i = 2 while new_key in d: new_key = '{key}{se...
[ "def", "flatten_dict", "(", "d", ",", "prefix", "=", "''", ",", "sep", "=", "'.'", ")", ":", "def", "apply_and_resolve_conflicts", "(", "dest", ",", "item", ",", "prefix", ")", ":", "for", "k", ",", "v", "in", "flatten_dict", "(", "item", ",", "prefi...
In place dict flattening.
[ "In", "place", "dict", "flattening", "." ]
python
train
mongodb/mongo-python-driver
pymongo/database.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/database.py#L344-L410
def create_collection(self, name, codec_options=None, read_preference=None, write_concern=None, read_concern=None, session=None, **kwargs): """Create a new :class:`~pymongo.collection.Collection` in this database. Normally collection creation ...
[ "def", "create_collection", "(", "self", ",", "name", ",", "codec_options", "=", "None", ",", "read_preference", "=", "None", ",", "write_concern", "=", "None", ",", "read_concern", "=", "None", ",", "session", "=", "None", ",", "*", "*", "kwargs", ")", ...
Create a new :class:`~pymongo.collection.Collection` in this database. Normally collection creation is automatic. This method should only be used to specify options on creation. :class:`~pymongo.errors.CollectionInvalid` will be raised if the collection already exists. ...
[ "Create", "a", "new", ":", "class", ":", "~pymongo", ".", "collection", ".", "Collection", "in", "this", "database", "." ]
python
train