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
goldsborough/ecstasy
ecstasy/parser.py
https://github.com/goldsborough/ecstasy/blob/7faa54708d506696c2607ddb68866e66768072ad/ecstasy/parser.py#L133-L225
def get_flags(self, args): """ Checks and retrieves positional and 'always' (keyword) flags from the many ways in which they may be passed to the constructor (or the beautify() method on package-level). Positional arguments can be passed either: * Individually, where each flag-combination is one position...
[ "def", "get_flags", "(", "self", ",", "args", ")", ":", "positional", "=", "[", "]", "for", "argument", "in", "args", ":", "# A flag is an instance of a subclass of", "# flags.Flags if it was passed alone", "if", "isinstance", "(", "argument", ",", "flags", ".", "...
Checks and retrieves positional and 'always' (keyword) flags from the many ways in which they may be passed to the constructor (or the beautify() method on package-level). Positional arguments can be passed either: * Individually, where each flag-combination is one positional argument. * Packaged inside a l...
[ "Checks", "and", "retrieves", "positional", "and", "always", "(", "keyword", ")", "flags", "from", "the", "many", "ways", "in", "which", "they", "may", "be", "passed", "to", "the", "constructor", "(", "or", "the", "beautify", "()", "method", "on", "package...
python
train
tcalmant/python-javaobj
javaobj/core.py
https://github.com/tcalmant/python-javaobj/blob/e042c2cbf1ce9de659b6cb9290b5ccd5442514d1/javaobj/core.py#L572-L607
def _read_and_exec_opcode(self, ident=0, expect=None): """ Reads the next opcode, and executes its handler :param ident: Log identation level :param expect: A list of expected opcodes :return: A tuple: (opcode, result of the handler) :raise IOError: Read opcode is not on...
[ "def", "_read_and_exec_opcode", "(", "self", ",", "ident", "=", "0", ",", "expect", "=", "None", ")", ":", "position", "=", "self", ".", "object_stream", ".", "tell", "(", ")", "(", "opid", ",", ")", "=", "self", ".", "_readStruct", "(", "\">B\"", ")...
Reads the next opcode, and executes its handler :param ident: Log identation level :param expect: A list of expected opcodes :return: A tuple: (opcode, result of the handler) :raise IOError: Read opcode is not one of the expected ones :raise RuntimeError: Unknown opcode
[ "Reads", "the", "next", "opcode", "and", "executes", "its", "handler" ]
python
train
cds-astro/mocpy
mocpy/tmoc/tmoc.py
https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L56-L82
def from_time_ranges(cls, min_times, max_times, delta_t=DEFAULT_OBSERVATION_TIME): """ Create a TimeMOC from a range defined by two `astropy.time.Time` Parameters ---------- min_times : `astropy.time.Time` astropy times defining the left part of the intervals ...
[ "def", "from_time_ranges", "(", "cls", ",", "min_times", ",", "max_times", ",", "delta_t", "=", "DEFAULT_OBSERVATION_TIME", ")", ":", "min_times_arr", "=", "np", ".", "asarray", "(", "min_times", ".", "jd", "*", "TimeMOC", ".", "DAY_MICRO_SEC", ",", "dtype", ...
Create a TimeMOC from a range defined by two `astropy.time.Time` Parameters ---------- min_times : `astropy.time.Time` astropy times defining the left part of the intervals max_times : `astropy.time.Time` astropy times defining the right part of the intervals ...
[ "Create", "a", "TimeMOC", "from", "a", "range", "defined", "by", "two", "astropy", ".", "time", ".", "Time" ]
python
train
ibis-project/ibis
ibis/pandas/execution/window.py
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/pandas/execution/window.py#L255-L291
def execute_series_lead_lag_timedelta( op, data, offset, default, aggcontext=None, **kwargs ): """An implementation of shifting a column relative to another one that is in units of time rather than rows. """ # lagging adds time (delayed), leading subtracts time (moved up) func = operator.add if ...
[ "def", "execute_series_lead_lag_timedelta", "(", "op", ",", "data", ",", "offset", ",", "default", ",", "aggcontext", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# lagging adds time (delayed), leading subtracts time (moved up)", "func", "=", "operator", ".", "a...
An implementation of shifting a column relative to another one that is in units of time rather than rows.
[ "An", "implementation", "of", "shifting", "a", "column", "relative", "to", "another", "one", "that", "is", "in", "units", "of", "time", "rather", "than", "rows", "." ]
python
train
jason-weirather/pythologist
pythologist/__init__.py
https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L409-L451
def merge_scores(self,df_addition,reference_markers='all', addition_markers='all',on=['project_name','sample_name','frame_name','cell_index']): """ Combine CellDataFrames that differ by score composition Args: df_addition (CellDataFrame): The Ce...
[ "def", "merge_scores", "(", "self", ",", "df_addition", ",", "reference_markers", "=", "'all'", ",", "addition_markers", "=", "'all'", ",", "on", "=", "[", "'project_name'", ",", "'sample_name'", ",", "'frame_name'", ",", "'cell_index'", "]", ")", ":", "if", ...
Combine CellDataFrames that differ by score composition Args: df_addition (CellDataFrame): The CellDataFrame to merge scores in from reference_markers (list): which scored call names to keep in the this object (default: all) addition_markers (list): which scored call names t...
[ "Combine", "CellDataFrames", "that", "differ", "by", "score", "composition" ]
python
train
saltstack/salt
salt/returners/cassandra_cql_return.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/cassandra_cql_return.py#L192-L243
def returner(ret): ''' Return data to one of potentially many clustered cassandra nodes ''' query = '''INSERT INTO {keyspace}.salt_returns ( jid, minion_id, fun, alter_time, full_ret, return, success ) VALUES (?, ?, ?, ?, ?, ?, ?)'''.format(keyspace=_get_keyspace()) ...
[ "def", "returner", "(", "ret", ")", ":", "query", "=", "'''INSERT INTO {keyspace}.salt_returns (\n jid, minion_id, fun, alter_time, full_ret, return, success\n ) VALUES (?, ?, ?, ?, ?, ?, ?)'''", ".", "format", "(", "keyspace", "=", "_get_keyspace", "(", ...
Return data to one of potentially many clustered cassandra nodes
[ "Return", "data", "to", "one", "of", "potentially", "many", "clustered", "cassandra", "nodes" ]
python
train
wandb/client
wandb/apis/internal.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/apis/internal.py#L445-L488
def run_config(self, project, run=None, entity=None): """Get the relevant configs for a run Args: project (str): The project to download, (can include bucket) run (str, optional): The run to download entity (str, optional): The entity to scope this project to. ...
[ "def", "run_config", "(", "self", ",", "project", ",", "run", "=", "None", ",", "entity", "=", "None", ")", ":", "query", "=", "gql", "(", "'''\n query Model($name: String!, $entity: String!, $run: String!) {\n model(name: $name, entityName: $entity) {\n ...
Get the relevant configs for a run Args: project (str): The project to download, (can include bucket) run (str, optional): The run to download entity (str, optional): The entity to scope this project to.
[ "Get", "the", "relevant", "configs", "for", "a", "run" ]
python
train
fm4d/PyMarkovTextGenerator
markov.py
https://github.com/fm4d/PyMarkovTextGenerator/blob/4a7e8e2cfe14c9745aba6b9df7d7b402a9029a37/markov.py#L157-L168
def remove_chain(self, name): """ Remove chain from current shelve file Args: name: chain name """ if name in self.chains: delattr(self.chains, name) else: raise ValueError("Chain with this name not found")
[ "def", "remove_chain", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "chains", ":", "delattr", "(", "self", ".", "chains", ",", "name", ")", "else", ":", "raise", "ValueError", "(", "\"Chain with this name not found\"", ")" ]
Remove chain from current shelve file Args: name: chain name
[ "Remove", "chain", "from", "current", "shelve", "file" ]
python
test
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L453-L459
def store_validator_set(self, height, validators): """Store validator set at a given `height`. NOTE: If the validator set already exists at that `height` then an exception will be raised. """ return backend.query.store_validator_set(self.connection, {'height': height, ...
[ "def", "store_validator_set", "(", "self", ",", "height", ",", "validators", ")", ":", "return", "backend", ".", "query", ".", "store_validator_set", "(", "self", ".", "connection", ",", "{", "'height'", ":", "height", ",", "'validators'", ":", "validators", ...
Store validator set at a given `height`. NOTE: If the validator set already exists at that `height` then an exception will be raised.
[ "Store", "validator", "set", "at", "a", "given", "height", ".", "NOTE", ":", "If", "the", "validator", "set", "already", "exists", "at", "that", "height", "then", "an", "exception", "will", "be", "raised", "." ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/utils_swiss_gmpe.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/utils_swiss_gmpe.py#L55-L78
def _compute_phi_ss(C, mag, c1_dists, log_phi_ss, mean_phi_ss): """ Returns the embeded logic tree for single station sigma as defined to be used in the Swiss Hazard Model 2014: the single station sigma branching levels combines with equal weights: the phi_ss reported as function of magnitude as...
[ "def", "_compute_phi_ss", "(", "C", ",", "mag", ",", "c1_dists", ",", "log_phi_ss", ",", "mean_phi_ss", ")", ":", "phi_ss", "=", "0", "if", "mag", "<", "C", "[", "'Mc1'", "]", ":", "phi_ss", "=", "c1_dists", "elif", "mag", ">=", "C", "[", "'Mc1'", ...
Returns the embeded logic tree for single station sigma as defined to be used in the Swiss Hazard Model 2014: the single station sigma branching levels combines with equal weights: the phi_ss reported as function of magnitude as proposed by Rodriguez-Marek et al (2013) with the mean (mean_phi_ss) si...
[ "Returns", "the", "embeded", "logic", "tree", "for", "single", "station", "sigma", "as", "defined", "to", "be", "used", "in", "the", "Swiss", "Hazard", "Model", "2014", ":", "the", "single", "station", "sigma", "branching", "levels", "combines", "with", "equ...
python
train
google/grr
grr/server/grr_response_server/data_store.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/data_store.py#L612-L645
def LockRetryWrapper(self, subject, retrywrap_timeout=1, retrywrap_max_timeout=10, blocking=True, lease_time=None): """Retry a DBSubjectLock until it succeeds. Args: subject: The subject whi...
[ "def", "LockRetryWrapper", "(", "self", ",", "subject", ",", "retrywrap_timeout", "=", "1", ",", "retrywrap_max_timeout", "=", "10", ",", "blocking", "=", "True", ",", "lease_time", "=", "None", ")", ":", "timeout", "=", "0", "while", "timeout", "<", "retr...
Retry a DBSubjectLock until it succeeds. Args: subject: The subject which the lock applies to. retrywrap_timeout: How long to wait before retrying the lock. retrywrap_max_timeout: The maximum time to wait for a retry until we raise. blocking: If False, raise on first lock failure. ...
[ "Retry", "a", "DBSubjectLock", "until", "it", "succeeds", "." ]
python
train
SHTOOLS/SHTOOLS
pyshtools/shclasses/shgravcoeffs.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shgravcoeffs.py#L248-L317
def from_zeros(self, lmax, gm, r0, omega=None, errors=False, normalization='4pi', csphase=1): """ Initialize the class with spherical harmonic coefficients set to zero from degree 1 to lmax, and set the degree 0 term to 1. Usage ----- x = SHGravCoeffs....
[ "def", "from_zeros", "(", "self", ",", "lmax", ",", "gm", ",", "r0", ",", "omega", "=", "None", ",", "errors", "=", "False", ",", "normalization", "=", "'4pi'", ",", "csphase", "=", "1", ")", ":", "if", "normalization", ".", "lower", "(", ")", "not...
Initialize the class with spherical harmonic coefficients set to zero from degree 1 to lmax, and set the degree 0 term to 1. Usage ----- x = SHGravCoeffs.from_zeros(lmax, gm, r0, [omega, errors, normalization, csphase]) Returns...
[ "Initialize", "the", "class", "with", "spherical", "harmonic", "coefficients", "set", "to", "zero", "from", "degree", "1", "to", "lmax", "and", "set", "the", "degree", "0", "term", "to", "1", "." ]
python
train
gbiggs/rtctree
rtctree/ports.py
https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/ports.py#L192-L205
def connections(self): '''A list of connections to or from this port. This list will be created at the first reference to this property. This means that the first reference may be delayed by CORBA calls, but others will return quickly (unless a delayed reparse has been triggered...
[ "def", "connections", "(", "self", ")", ":", "with", "self", ".", "_mutex", ":", "if", "not", "self", ".", "_connections", ":", "self", ".", "_connections", "=", "[", "Connection", "(", "cp", ",", "self", ")", "for", "cp", "in", "self", ".", "_obj", ...
A list of connections to or from this port. This list will be created at the first reference to this property. This means that the first reference may be delayed by CORBA calls, but others will return quickly (unless a delayed reparse has been triggered).
[ "A", "list", "of", "connections", "to", "or", "from", "this", "port", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/coremltools/models/neural_network.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/neural_network.py#L2271-L2305
def add_l2_normalize(self, name, input_name, output_name, epsilon = 1e-5): """ Add L2 normalize layer. Normalizes the input by the L2 norm, i.e. divides by the the square root of the sum of squares of all elements of the input along C, H and W dimensions. Parameters ---------- ...
[ "def", "add_l2_normalize", "(", "self", ",", "name", ",", "input_name", ",", "output_name", ",", "epsilon", "=", "1e-5", ")", ":", "spec", "=", "self", ".", "spec", "nn_spec", "=", "self", ".", "nn_spec", "# Add a new layer", "spec_layer", "=", "nn_spec", ...
Add L2 normalize layer. Normalizes the input by the L2 norm, i.e. divides by the the square root of the sum of squares of all elements of the input along C, H and W dimensions. Parameters ---------- name: str The name of this layer. input_name: str The i...
[ "Add", "L2", "normalize", "layer", ".", "Normalizes", "the", "input", "by", "the", "L2", "norm", "i", ".", "e", ".", "divides", "by", "the", "the", "square", "root", "of", "the", "sum", "of", "squares", "of", "all", "elements", "of", "the", "input", ...
python
train
inveniosoftware-attic/invenio-utils
invenio_utils/orcid.py
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/orcid.py#L26-L41
def search_authors(self, query): query = query.replace(" ", "+") """ FIXME: Don't create a process to do this! """ p = subprocess.Popen("curl -H 'Accept: application/orcid+json' \ 'http://pub.sandbox-1.orcid.org/search/orcid-bio?q=" + ...
[ "def", "search_authors", "(", "self", ",", "query", ")", ":", "query", "=", "query", ".", "replace", "(", "\" \"", ",", "\"+\"", ")", "p", "=", "subprocess", ".", "Popen", "(", "\"curl -H 'Accept: application/orcid+json' \\\n 'http://pub.sa...
FIXME: Don't create a process to do this!
[ "FIXME", ":", "Don", "t", "create", "a", "process", "to", "do", "this!" ]
python
train
etobella/python-xmlsig
src/xmlsig/signature_context.py
https://github.com/etobella/python-xmlsig/blob/120a50935a4d4c2c972cfa3f8519bbce7e30d67b/src/xmlsig/signature_context.py#L171-L205
def transform(self, transform, node): """ Transforms a node following the transform especification :param transform: Transform node :type transform: lxml.etree.Element :param node: Element to transform :type node: str :return: Transformed node in a String ...
[ "def", "transform", "(", "self", ",", "transform", ",", "node", ")", ":", "method", "=", "transform", ".", "get", "(", "'Algorithm'", ")", "if", "method", "not", "in", "constants", ".", "TransformUsageDSigTransform", ":", "raise", "Exception", "(", "'Method ...
Transforms a node following the transform especification :param transform: Transform node :type transform: lxml.etree.Element :param node: Element to transform :type node: str :return: Transformed node in a String
[ "Transforms", "a", "node", "following", "the", "transform", "especification", ":", "param", "transform", ":", "Transform", "node", ":", "type", "transform", ":", "lxml", ".", "etree", ".", "Element", ":", "param", "node", ":", "Element", "to", "transform", "...
python
train
PmagPy/PmagPy
programs/deprecated/basemap_magic.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/deprecated/basemap_magic.py#L17-L169
def main(): """ NAME basemap_magic.py NB: this program no longer maintained - use plot_map_pts.py for greater functionality DESCRIPTION makes a map of locations in er_sites.txt SYNTAX basemap_magic.py [command line options] OPTIONS -h prints help message ...
[ "def", "main", "(", ")", ":", "dir_path", "=", "'.'", "sites_file", "=", "'er_sites.txt'", "ocean", "=", "0", "res", "=", "'i'", "proj", "=", "'merc'", "prn_name", "=", "0", "prn_loc", "=", "0", "fancy", "=", "0", "rivers", ",", "boundaries", "=", "0...
NAME basemap_magic.py NB: this program no longer maintained - use plot_map_pts.py for greater functionality DESCRIPTION makes a map of locations in er_sites.txt SYNTAX basemap_magic.py [command line options] OPTIONS -h prints help message and quits -f SFI...
[ "NAME", "basemap_magic", ".", "py", "NB", ":", "this", "program", "no", "longer", "maintained", "-", "use", "plot_map_pts", ".", "py", "for", "greater", "functionality" ]
python
train
openstack/networking-cisco
networking_cisco/apps/saf/server/dfa_server.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/dfa_server.py#L703-L799
def network_create_func(self, net): """Create network in database and dcnm :param net: network dictionary """ net_id = net['id'] net_name = net.get('name') network_db_elem = self.get_network(net_id) # Check if the source of network creation is FW and if yes, skip ...
[ "def", "network_create_func", "(", "self", ",", "net", ")", ":", "net_id", "=", "net", "[", "'id'", "]", "net_name", "=", "net", ".", "get", "(", "'name'", ")", "network_db_elem", "=", "self", ".", "get_network", "(", "net_id", ")", "# Check if the source ...
Create network in database and dcnm :param net: network dictionary
[ "Create", "network", "in", "database", "and", "dcnm", ":", "param", "net", ":", "network", "dictionary" ]
python
train
atlassian-api/atlassian-python-api
atlassian/jira.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L631-L646
def create_or_update_issue_remote_links(self, issue_key, link_url, title, global_id=None, relationship=None): """ Add Remote Link to Issue, update url if global_id is passed :param issue_key: str :param link_url: str :param title: str :param global_id: str, OPTIONAL: ...
[ "def", "create_or_update_issue_remote_links", "(", "self", ",", "issue_key", ",", "link_url", ",", "title", ",", "global_id", "=", "None", ",", "relationship", "=", "None", ")", ":", "url", "=", "'rest/api/2/issue/{issue_key}/remotelink'", ".", "format", "(", "iss...
Add Remote Link to Issue, update url if global_id is passed :param issue_key: str :param link_url: str :param title: str :param global_id: str, OPTIONAL: :param relationship: str, OPTIONAL: Default by built-in method: 'Web Link'
[ "Add", "Remote", "Link", "to", "Issue", "update", "url", "if", "global_id", "is", "passed", ":", "param", "issue_key", ":", "str", ":", "param", "link_url", ":", "str", ":", "param", "title", ":", "str", ":", "param", "global_id", ":", "str", "OPTIONAL",...
python
train
bopo/mootdx
mootdx/quotes.py
https://github.com/bopo/mootdx/blob/7c4623e9464c75d3c87a06d48fe8734b027374fa/mootdx/quotes.py#L212-L248
def index( self, symbol='000001', market='sh', category='9', start='0', offset='100'): ''' 获取指数k线 K线种类: - 0 5分钟K线 - 1 15分钟K线 - 2 30分钟K线 - 3 1小时K线 - 4 日K线 - 5 周K线 - 6 月K线 - 7 1分钟 ...
[ "def", "index", "(", "self", ",", "symbol", "=", "'000001'", ",", "market", "=", "'sh'", ",", "category", "=", "'9'", ",", "start", "=", "'0'", ",", "offset", "=", "'100'", ")", ":", "market", "=", "1", "if", "market", "==", "'sh'", "else", "0", ...
获取指数k线 K线种类: - 0 5分钟K线 - 1 15分钟K线 - 2 30分钟K线 - 3 1小时K线 - 4 日K线 - 5 周K线 - 6 月K线 - 7 1分钟 - 8 1分钟K线 - 9 日K线 - 10 季K线 - 11 年K线 :param symbol: 股票代码 :param category: 数据类别 :param market: 证券市场 ...
[ "获取指数k线" ]
python
train
sprockets/sprockets.http
sprockets/http/app.py
https://github.com/sprockets/sprockets.http/blob/8baa4cdc1fa35a162ee226fd6cc4170a0ca0ecd3/sprockets/http/app.py#L87-L104
def start(self, io_loop): """ Run the ``before_run`` callbacks and queue to ``on_start`` callbacks. :param tornado.ioloop.IOLoop io_loop: loop to start the app on. """ for callback in self.before_run_callbacks: try: callback(self.tornado_application,...
[ "def", "start", "(", "self", ",", "io_loop", ")", ":", "for", "callback", "in", "self", ".", "before_run_callbacks", ":", "try", ":", "callback", "(", "self", ".", "tornado_application", ",", "io_loop", ")", "except", "Exception", ":", "self", ".", "logger...
Run the ``before_run`` callbacks and queue to ``on_start`` callbacks. :param tornado.ioloop.IOLoop io_loop: loop to start the app on.
[ "Run", "the", "before_run", "callbacks", "and", "queue", "to", "on_start", "callbacks", "." ]
python
train
langloisjp/pysvcmetrics
statsdclient.py
https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/statsdclient.py#L88-L98
def timeit(self, metric, func, *args, **kwargs): """ Times given function and log metric in ms for duration of execution. >>> import time >>> client = StatsdClient() >>> client.timeit("latency", time.sleep, 0.5) """ (res, seconds) = timeit(func, *args, **kwargs) ...
[ "def", "timeit", "(", "self", ",", "metric", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "(", "res", ",", "seconds", ")", "=", "timeit", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "timing", ...
Times given function and log metric in ms for duration of execution. >>> import time >>> client = StatsdClient() >>> client.timeit("latency", time.sleep, 0.5)
[ "Times", "given", "function", "and", "log", "metric", "in", "ms", "for", "duration", "of", "execution", "." ]
python
train
apache/incubator-heron
heron/tools/tracker/src/python/config.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/tracker/src/python/config.py#L51-L58
def validate_extra_link(self, extra_link): """validate extra link""" if EXTRA_LINK_NAME_KEY not in extra_link or EXTRA_LINK_FORMATTER_KEY not in extra_link: raise Exception("Invalid extra.links format. " + "Extra link must include a 'name' and 'formatter' field") self.validated_...
[ "def", "validate_extra_link", "(", "self", ",", "extra_link", ")", ":", "if", "EXTRA_LINK_NAME_KEY", "not", "in", "extra_link", "or", "EXTRA_LINK_FORMATTER_KEY", "not", "in", "extra_link", ":", "raise", "Exception", "(", "\"Invalid extra.links format. \"", "+", "\"Ext...
validate extra link
[ "validate", "extra", "link" ]
python
valid
andy-z/ged4py
ged4py/detail/date.py
https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/detail/date.py#L214-L234
def parse(cls, datestr): """Parse string <DATE_VALUE> string and make :py:class:`DateValue` instance out of it. :param str datestr: String with GEDCOM date, range, period, etc. """ # some apps generate DATE recods without any value, which is # non-standard, return empty ...
[ "def", "parse", "(", "cls", ",", "datestr", ")", ":", "# some apps generate DATE recods without any value, which is", "# non-standard, return empty DateValue for those", "if", "not", "datestr", ":", "return", "cls", "(", ")", "for", "regex", ",", "tmpl", "in", "DATES", ...
Parse string <DATE_VALUE> string and make :py:class:`DateValue` instance out of it. :param str datestr: String with GEDCOM date, range, period, etc.
[ "Parse", "string", "<DATE_VALUE", ">", "string", "and", "make", ":", "py", ":", "class", ":", "DateValue", "instance", "out", "of", "it", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/vasp/outputs.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/outputs.py#L3491-L3542
def get_band_structure_from_vasp_multiple_branches(dir_name, efermi=None, projections=False): """ This method is used to get band structure info from a VASP directory. It takes into account that the run can be divided in several branches named "branch_x...
[ "def", "get_band_structure_from_vasp_multiple_branches", "(", "dir_name", ",", "efermi", "=", "None", ",", "projections", "=", "False", ")", ":", "# TODO: Add better error handling!!!", "if", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", ...
This method is used to get band structure info from a VASP directory. It takes into account that the run can be divided in several branches named "branch_x". If the run has not been divided in branches the method will turn to parsing vasprun.xml directly. The method returns None is there"s a parsing er...
[ "This", "method", "is", "used", "to", "get", "band", "structure", "info", "from", "a", "VASP", "directory", ".", "It", "takes", "into", "account", "that", "the", "run", "can", "be", "divided", "in", "several", "branches", "named", "branch_x", ".", "If", ...
python
train
djaodjin/djaodjin-deployutils
deployutils/apps/django/mixins.py
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mixins.py#L59-L69
def get_accessibles(request, roles=None): """ Returns the list of *dictionnaries* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present. """ results = [] for role_name, organizations in six.iteritems(request.session.get( ...
[ "def", "get_accessibles", "(", "request", ",", "roles", "=", "None", ")", ":", "results", "=", "[", "]", "for", "role_name", ",", "organizations", "in", "six", ".", "iteritems", "(", "request", ".", "session", ".", "get", "(", "'roles'", ",", "{", "}",...
Returns the list of *dictionnaries* for which the accounts are accessibles by ``request.user`` filtered by ``roles`` if present.
[ "Returns", "the", "list", "of", "*", "dictionnaries", "*", "for", "which", "the", "accounts", "are", "accessibles", "by", "request", ".", "user", "filtered", "by", "roles", "if", "present", "." ]
python
train
pyviz/holoviews
holoviews/core/options.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/options.py#L1336-L1343
def set_display_hook(cls, group, objtype, hook): """ Specify a display hook that will be applied to objects of type objtype. The group specifies the set to which the display hook belongs, allowing the Store to compute the precedence within each group. """ cls._dis...
[ "def", "set_display_hook", "(", "cls", ",", "group", ",", "objtype", ",", "hook", ")", ":", "cls", ".", "_display_hooks", "[", "group", "]", "[", "objtype", "]", "=", "hook" ]
Specify a display hook that will be applied to objects of type objtype. The group specifies the set to which the display hook belongs, allowing the Store to compute the precedence within each group.
[ "Specify", "a", "display", "hook", "that", "will", "be", "applied", "to", "objects", "of", "type", "objtype", ".", "The", "group", "specifies", "the", "set", "to", "which", "the", "display", "hook", "belongs", "allowing", "the", "Store", "to", "compute", "...
python
train
pecan/pecan
pecan/core.py
https://github.com/pecan/pecan/blob/833d0653fa0e6bbfb52545b091c30182105f4a82/pecan/core.py#L348-L404
def get_args(self, state, all_params, remainder, argspec, im_self): ''' Determines the arguments for a controller based upon parameters passed the argument specification for the controller. ''' args = [] varargs = [] kwargs = dict() valid_args = argspec.ar...
[ "def", "get_args", "(", "self", ",", "state", ",", "all_params", ",", "remainder", ",", "argspec", ",", "im_self", ")", ":", "args", "=", "[", "]", "varargs", "=", "[", "]", "kwargs", "=", "dict", "(", ")", "valid_args", "=", "argspec", ".", "args", ...
Determines the arguments for a controller based upon parameters passed the argument specification for the controller.
[ "Determines", "the", "arguments", "for", "a", "controller", "based", "upon", "parameters", "passed", "the", "argument", "specification", "for", "the", "controller", "." ]
python
train
inveniosoftware/invenio-oauth2server
invenio_oauth2server/forms.py
https://github.com/inveniosoftware/invenio-oauth2server/blob/7033d3495c1a2b830e101e43918e92a37bbb49f2/invenio_oauth2server/forms.py#L26-L58
def scopes_multi_checkbox(field, **kwargs): """Render multi checkbox widget.""" kwargs.setdefault('type', 'checkbox') field_id = kwargs.pop('id', field.id) html = [u'<div class="row">'] for value, label, checked in field.iter_choices(): choice_id = u'%s-%s' % (field_id, value) opt...
[ "def", "scopes_multi_checkbox", "(", "field", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'type'", ",", "'checkbox'", ")", "field_id", "=", "kwargs", ".", "pop", "(", "'id'", ",", "field", ".", "id", ")", "html", "=", "[", "...
Render multi checkbox widget.
[ "Render", "multi", "checkbox", "widget", "." ]
python
train
zomux/deepy
deepy/layers/block.py
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/layers/block.py#L64-L71
def load_params(self, path, exclude_free_params=False): from deepy.core import graph """ Load parameters to the block. """ from deepy.core.comp_graph import ComputationalGraph model = graph.compile(blocks=[self]) model.load_params(path, exclude_free_params=exclude...
[ "def", "load_params", "(", "self", ",", "path", ",", "exclude_free_params", "=", "False", ")", ":", "from", "deepy", ".", "core", "import", "graph", "from", "deepy", ".", "core", ".", "comp_graph", "import", "ComputationalGraph", "model", "=", "graph", ".", ...
Load parameters to the block.
[ "Load", "parameters", "to", "the", "block", "." ]
python
test
manns/pyspread
pyspread/src/gui/_grid.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid.py#L504-L526
def OnLinkBitmap(self, event): """Link bitmap event handler""" # Get file name wildcard = "*" message = _("Select bitmap for current cell") style = wx.OPEN | wx.CHANGE_DIR filepath, __ = \ self.grid.interfaces.get_filepath_findex_from_user(wildcard, ...
[ "def", "OnLinkBitmap", "(", "self", ",", "event", ")", ":", "# Get file name", "wildcard", "=", "\"*\"", "message", "=", "_", "(", "\"Select bitmap for current cell\"", ")", "style", "=", "wx", ".", "OPEN", "|", "wx", ".", "CHANGE_DIR", "filepath", ",", "__"...
Link bitmap event handler
[ "Link", "bitmap", "event", "handler" ]
python
train
romanz/trezor-agent
libagent/util.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/util.py#L87-L102
def crc24(blob): """See https://tools.ietf.org/html/rfc4880#section-6.1 for details.""" CRC24_INIT = 0x0B704CE CRC24_POLY = 0x1864CFB crc = CRC24_INIT for octet in bytearray(blob): crc ^= (octet << 16) for _ in range(8): crc <<= 1 if crc & 0x1000000: ...
[ "def", "crc24", "(", "blob", ")", ":", "CRC24_INIT", "=", "0x0B704CE", "CRC24_POLY", "=", "0x1864CFB", "crc", "=", "CRC24_INIT", "for", "octet", "in", "bytearray", "(", "blob", ")", ":", "crc", "^=", "(", "octet", "<<", "16", ")", "for", "_", "in", "...
See https://tools.ietf.org/html/rfc4880#section-6.1 for details.
[ "See", "https", ":", "//", "tools", ".", "ietf", ".", "org", "/", "html", "/", "rfc4880#section", "-", "6", ".", "1", "for", "details", "." ]
python
train
nornir-automation/nornir
nornir/plugins/tasks/networking/napalm_cli.py
https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/plugins/tasks/networking/napalm_cli.py#L6-L19
def napalm_cli(task: Task, commands: List[str]) -> Result: """ Run commands on remote devices using napalm Arguments: commands: commands to execute Returns: Result object with the following attributes set: * result (``dict``): result of the commands execution """ devi...
[ "def", "napalm_cli", "(", "task", ":", "Task", ",", "commands", ":", "List", "[", "str", "]", ")", "->", "Result", ":", "device", "=", "task", ".", "host", ".", "get_connection", "(", "\"napalm\"", ",", "task", ".", "nornir", ".", "config", ")", "res...
Run commands on remote devices using napalm Arguments: commands: commands to execute Returns: Result object with the following attributes set: * result (``dict``): result of the commands execution
[ "Run", "commands", "on", "remote", "devices", "using", "napalm" ]
python
train
qacafe/cdrouter.py
cdrouter/packages.py
https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/packages.py#L329-L341
def bulk_edit(self, _fields, ids=None, filter=None, type=None, all=False): # pylint: disable=redefined-builtin """Bulk edit a set of packages. :param _fields: :class:`packages.Package <packages.Package>` object :param ids: (optional) Int list of package IDs. :param filter: (optional) St...
[ "def", "bulk_edit", "(", "self", ",", "_fields", ",", "ids", "=", "None", ",", "filter", "=", "None", ",", "type", "=", "None", ",", "all", "=", "False", ")", ":", "# pylint: disable=redefined-builtin", "schema", "=", "PackageSchema", "(", "exclude", "=", ...
Bulk edit a set of packages. :param _fields: :class:`packages.Package <packages.Package>` object :param ids: (optional) Int list of package IDs. :param filter: (optional) String list of filters. :param type: (optional) `union` or `inter` as string. :param all: (optional) Apply t...
[ "Bulk", "edit", "a", "set", "of", "packages", "." ]
python
train
pbrisk/timewave
timewave/producers.py
https://github.com/pbrisk/timewave/blob/cf641391d1607a424042724c8b990d43ee270ef6/timewave/producers.py#L55-L61
def initialize_path(self, path_num=None): """ inits producer for next path, i.e. sets current state to initial state""" for p in self.producers: p.initialize_path(path_num) # self.state = copy(self.initial_state) # self.state.path = path_num self.random.seed(hash(self...
[ "def", "initialize_path", "(", "self", ",", "path_num", "=", "None", ")", ":", "for", "p", "in", "self", ".", "producers", ":", "p", ".", "initialize_path", "(", "path_num", ")", "# self.state = copy(self.initial_state)", "# self.state.path = path_num", "self", "....
inits producer for next path, i.e. sets current state to initial state
[ "inits", "producer", "for", "next", "path", "i", ".", "e", ".", "sets", "current", "state", "to", "initial", "state" ]
python
train
StackStorm/pybind
pybind/slxos/v17s_1_02/brocade_mpls_rpc/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/brocade_mpls_rpc/__init__.py#L1713-L1734
def _set_show_mpls_lsp_name_debug(self, v, load=False): """ Setter method for show_mpls_lsp_name_debug, mapped from YANG variable /brocade_mpls_rpc/show_mpls_lsp_name_debug (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_mpls_lsp_name_debug is considered as a ...
[ "def", "_set_show_mpls_lsp_name_debug", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v",...
Setter method for show_mpls_lsp_name_debug, mapped from YANG variable /brocade_mpls_rpc/show_mpls_lsp_name_debug (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_mpls_lsp_name_debug is considered as a private method. Backends looking to populate this variable shoul...
[ "Setter", "method", "for", "show_mpls_lsp_name_debug", "mapped", "from", "YANG", "variable", "/", "brocade_mpls_rpc", "/", "show_mpls_lsp_name_debug", "(", "rpc", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", ...
python
train
GetmeUK/MongoFrames
snippets/comparable.py
https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/snippets/comparable.py#L310-L323
def logged_delete(self, user): """Delete the document and log the event in the change log""" self.delete() # Log the change entry = ChangeLogEntry({ 'type': 'DELETED', 'documents': [self], 'user': user }) entry.insert() r...
[ "def", "logged_delete", "(", "self", ",", "user", ")", ":", "self", ".", "delete", "(", ")", "# Log the change", "entry", "=", "ChangeLogEntry", "(", "{", "'type'", ":", "'DELETED'", ",", "'documents'", ":", "[", "self", "]", ",", "'user'", ":", "user", ...
Delete the document and log the event in the change log
[ "Delete", "the", "document", "and", "log", "the", "event", "in", "the", "change", "log" ]
python
train
CiscoDevNet/webexteamssdk
webexteamssdk/api/rooms.py
https://github.com/CiscoDevNet/webexteamssdk/blob/6fc2cc3557e080ba4b2a380664cb2a0532ae45cd/webexteamssdk/api/rooms.py#L76-L133
def list(self, teamId=None, type=None, sortBy=None, max=None, **request_parameters): """List rooms. By default, lists rooms to which the authenticated user belongs. This method supports Webex Teams's implementation of RFC5988 Web Linking to provide pagination support. It ...
[ "def", "list", "(", "self", ",", "teamId", "=", "None", ",", "type", "=", "None", ",", "sortBy", "=", "None", ",", "max", "=", "None", ",", "*", "*", "request_parameters", ")", ":", "check_type", "(", "teamId", ",", "basestring", ")", "check_type", "...
List rooms. By default, lists rooms to which the authenticated user belongs. This method supports Webex Teams's implementation of RFC5988 Web Linking to provide pagination support. It returns a generator container that incrementally yields all rooms returned by the query. The...
[ "List", "rooms", "." ]
python
test
biosustain/optlang
optlang/scipy_interface.py
https://github.com/biosustain/optlang/blob/13673ac26f6b3ba37a2ef392489722c52e3c5ff1/optlang/scipy_interface.py#L111-L122
def add_variable(self, name): """Add a variable to the problem""" if name in self._variables: raise ValueError( "A variable named " + name + " already exists." ) self._variables[name] = len(self._variables) self.bounds[name] = (0, None) ne...
[ "def", "add_variable", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_variables", ":", "raise", "ValueError", "(", "\"A variable named \"", "+", "name", "+", "\" already exists.\"", ")", "self", ".", "_variables", "[", "name", "]", ...
Add a variable to the problem
[ "Add", "a", "variable", "to", "the", "problem" ]
python
train
Toblerity/rtree
rtree/index.py
https://github.com/Toblerity/rtree/blob/5d33357c8e88f1a8344415dc15a7d2440211b281/rtree/index.py#L1363-L1366
def deleteByteArray(self, context, page, returnError): """please override""" returnError.contents.value = self.IllegalStateError raise NotImplementedError("You must override this method.")
[ "def", "deleteByteArray", "(", "self", ",", "context", ",", "page", ",", "returnError", ")", ":", "returnError", ".", "contents", ".", "value", "=", "self", ".", "IllegalStateError", "raise", "NotImplementedError", "(", "\"You must override this method.\"", ")" ]
please override
[ "please", "override" ]
python
test
JukeboxPipeline/jukebox-core
src/jukeboxcore/addons/guerilla/guerillamgmt.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/guerilla/guerillamgmt.py#L2342-L2353
def user_view_prj(self, ): """View the project that is currently selected :returns: None :rtype: None :raises: None """ i = self.user_prj_tablev.currentIndex() item = i.internalPointer() if item: prj = item.internal_data() self.vie...
[ "def", "user_view_prj", "(", "self", ",", ")", ":", "i", "=", "self", ".", "user_prj_tablev", ".", "currentIndex", "(", ")", "item", "=", "i", ".", "internalPointer", "(", ")", "if", "item", ":", "prj", "=", "item", ".", "internal_data", "(", ")", "s...
View the project that is currently selected :returns: None :rtype: None :raises: None
[ "View", "the", "project", "that", "is", "currently", "selected" ]
python
train
python-security/pyt
pyt/cfg/expr_visitor_helper.py
https://github.com/python-security/pyt/blob/efc0cfb716e40e0c8df4098f1cc8cf43723cd31f/pyt/cfg/expr_visitor_helper.py#L43-L48
def return_connection_handler(nodes, exit_node): """Connect all return statements to the Exit node.""" for function_body_node in nodes: if isinstance(function_body_node, ConnectToExitNode): if exit_node not in function_body_node.outgoing: function_body_node.connect(exit_node)
[ "def", "return_connection_handler", "(", "nodes", ",", "exit_node", ")", ":", "for", "function_body_node", "in", "nodes", ":", "if", "isinstance", "(", "function_body_node", ",", "ConnectToExitNode", ")", ":", "if", "exit_node", "not", "in", "function_body_node", ...
Connect all return statements to the Exit node.
[ "Connect", "all", "return", "statements", "to", "the", "Exit", "node", "." ]
python
train
klmitch/requiem
requiem/processor.py
https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/processor.py#L104-L127
def proc_response(self, resp, startidx=None): """ Post-process a response through all processors in the stack, in reverse order. For convenience, returns the response passed to the method. The startidx argument is an internal interface only used by the proc_request() an...
[ "def", "proc_response", "(", "self", ",", "resp", ",", "startidx", "=", "None", ")", ":", "# If we're empty, bail out early", "if", "not", "self", ":", "return", "resp", "# Select appropriate starting index", "if", "startidx", "is", "None", ":", "startidx", "=", ...
Post-process a response through all processors in the stack, in reverse order. For convenience, returns the response passed to the method. The startidx argument is an internal interface only used by the proc_request() and proc_exception() methods to process a response through a...
[ "Post", "-", "process", "a", "response", "through", "all", "processors", "in", "the", "stack", "in", "reverse", "order", ".", "For", "convenience", "returns", "the", "response", "passed", "to", "the", "method", "." ]
python
train
pycontribs/pyrax
pyrax/clouddatabases.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L395-L406
def get_database(self, name): """ Finds the database in this instance with the specified name, and returns a CloudDatabaseDatabase object. If no match is found, a NoSuchDatabase exception is raised. """ try: return [db for db in self.list_databases() ...
[ "def", "get_database", "(", "self", ",", "name", ")", ":", "try", ":", "return", "[", "db", "for", "db", "in", "self", ".", "list_databases", "(", ")", "if", "db", ".", "name", "==", "name", "]", "[", "0", "]", "except", "IndexError", ":", "raise",...
Finds the database in this instance with the specified name, and returns a CloudDatabaseDatabase object. If no match is found, a NoSuchDatabase exception is raised.
[ "Finds", "the", "database", "in", "this", "instance", "with", "the", "specified", "name", "and", "returns", "a", "CloudDatabaseDatabase", "object", ".", "If", "no", "match", "is", "found", "a", "NoSuchDatabase", "exception", "is", "raised", "." ]
python
train
Kozea/pygal
pygal/graph/box.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/box.py#L67-L81
def _compute(self): """ Compute parameters necessary for later steps within the rendering process """ for serie in self.series: serie.points, serie.outliers = \ self._box_points(serie.values, self.box_mode) self._x_pos = [(i + .5) / self._orde...
[ "def", "_compute", "(", "self", ")", ":", "for", "serie", "in", "self", ".", "series", ":", "serie", ".", "points", ",", "serie", ".", "outliers", "=", "self", ".", "_box_points", "(", "serie", ".", "values", ",", "self", ".", "box_mode", ")", "self"...
Compute parameters necessary for later steps within the rendering process
[ "Compute", "parameters", "necessary", "for", "later", "steps", "within", "the", "rendering", "process" ]
python
train
GMadorell/abris
abris_transform/transformations/transformer.py
https://github.com/GMadorell/abris/blob/0d8ab7ec506835a45fae6935d129f5d7e6937bb2/abris_transform/transformations/transformer.py#L48-L66
def __add_target_data(self, transformed_data, original_data): """ Picks up the target data from the original_data and appends it as a column to the transformed_data. Both arguments are expected to be np.array's. """ model = self.__config.get_data_model() target_fe...
[ "def", "__add_target_data", "(", "self", ",", "transformed_data", ",", "original_data", ")", ":", "model", "=", "self", ".", "__config", ".", "get_data_model", "(", ")", "target_feature", "=", "model", ".", "find_target_feature", "(", ")", "name", "=", "target...
Picks up the target data from the original_data and appends it as a column to the transformed_data. Both arguments are expected to be np.array's.
[ "Picks", "up", "the", "target", "data", "from", "the", "original_data", "and", "appends", "it", "as", "a", "column", "to", "the", "transformed_data", ".", "Both", "arguments", "are", "expected", "to", "be", "np", ".", "array", "s", "." ]
python
train
mikedh/trimesh
trimesh/path/packing.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/packing.py#L225-L324
def multipack(polygons, sheet_size=None, iterations=50, density_escape=.95, spacing=0.094, quantity=None): """ Pack polygons into a rectangle by taking each Polygon's OBB and then packing that as a rectangle. Parameters ---------...
[ "def", "multipack", "(", "polygons", ",", "sheet_size", "=", "None", ",", "iterations", "=", "50", ",", "density_escape", "=", ".95", ",", "spacing", "=", "0.094", ",", "quantity", "=", "None", ")", ":", "from", ".", "polygons", "import", "polygons_obb", ...
Pack polygons into a rectangle by taking each Polygon's OBB and then packing that as a rectangle. Parameters ------------ polygons : (n,) shapely.geometry.Polygon Source geometry sheet_size : (2,) float Size of rectangular sheet iterations : int Number of times to run the loop...
[ "Pack", "polygons", "into", "a", "rectangle", "by", "taking", "each", "Polygon", "s", "OBB", "and", "then", "packing", "that", "as", "a", "rectangle", "." ]
python
train
treethought/flask-assistant
flask_assistant/hass.py
https://github.com/treethought/flask-assistant/blob/9331b9796644dfa987bcd97a13e78e9ab62923d3/flask_assistant/hass.py#L52-L54
def is_state(self, entity_id, state): """Checks if the entity has the given state""" return remote.is_state(self.api, entity_id, state)
[ "def", "is_state", "(", "self", ",", "entity_id", ",", "state", ")", ":", "return", "remote", ".", "is_state", "(", "self", ".", "api", ",", "entity_id", ",", "state", ")" ]
Checks if the entity has the given state
[ "Checks", "if", "the", "entity", "has", "the", "given", "state" ]
python
train
Julius2342/pyvlx
pyvlx/parameter.py
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L37-L45
def is_valid_int(value): """Test if value can be rendered out of int.""" if 0 <= value <= Parameter.MAX: # This includes ON and OFF return True if value == Parameter.UNKNOWN_VALUE: return True if value == Parameter.CURRENT_POSITION: return True ...
[ "def", "is_valid_int", "(", "value", ")", ":", "if", "0", "<=", "value", "<=", "Parameter", ".", "MAX", ":", "# This includes ON and OFF", "return", "True", "if", "value", "==", "Parameter", ".", "UNKNOWN_VALUE", ":", "return", "True", "if", "value", "==", ...
Test if value can be rendered out of int.
[ "Test", "if", "value", "can", "be", "rendered", "out", "of", "int", "." ]
python
train
RRZE-HPC/kerncraft
kerncraft/kernel.py
https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kernel.py#L355-L375
def index_order(self, sources=True, destinations=True): """ Return the order of indices as they appear in array references. Use *source* and *destination* to filter output """ if sources: arefs = chain(*self.sources.values()) else: arefs = [] ...
[ "def", "index_order", "(", "self", ",", "sources", "=", "True", ",", "destinations", "=", "True", ")", ":", "if", "sources", ":", "arefs", "=", "chain", "(", "*", "self", ".", "sources", ".", "values", "(", ")", ")", "else", ":", "arefs", "=", "[",...
Return the order of indices as they appear in array references. Use *source* and *destination* to filter output
[ "Return", "the", "order", "of", "indices", "as", "they", "appear", "in", "array", "references", "." ]
python
test
googleapis/google-cloud-python
bigtable/google/cloud/bigtable/row_data.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable/row_data.py#L432-L437
def _create_retry_request(self): """Helper for :meth:`__iter__`.""" req_manager = _ReadRowsRequestManager( self.request, self.last_scanned_row_key, self._counter ) return req_manager.build_updated_request()
[ "def", "_create_retry_request", "(", "self", ")", ":", "req_manager", "=", "_ReadRowsRequestManager", "(", "self", ".", "request", ",", "self", ".", "last_scanned_row_key", ",", "self", ".", "_counter", ")", "return", "req_manager", ".", "build_updated_request", "...
Helper for :meth:`__iter__`.
[ "Helper", "for", ":", "meth", ":", "__iter__", "." ]
python
train
tensorflow/cleverhans
cleverhans_tutorials/mnist_tutorial_pytorch.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans_tutorials/mnist_tutorial_pytorch.py#L68-L170
def mnist_tutorial(nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE, train_end=-1, test_end=-1, learning_rate=LEARNING_RATE): """ MNIST cleverhans tutorial :param nb_epochs: number of epochs to train model :param batch_size: size of training batches :param learning_rate: learning rate for trainin...
[ "def", "mnist_tutorial", "(", "nb_epochs", "=", "NB_EPOCHS", ",", "batch_size", "=", "BATCH_SIZE", ",", "train_end", "=", "-", "1", ",", "test_end", "=", "-", "1", ",", "learning_rate", "=", "LEARNING_RATE", ")", ":", "# Train a pytorch MNIST model", "torch_mode...
MNIST cleverhans tutorial :param nb_epochs: number of epochs to train model :param batch_size: size of training batches :param learning_rate: learning rate for training :return: an AccuracyReport object
[ "MNIST", "cleverhans", "tutorial", ":", "param", "nb_epochs", ":", "number", "of", "epochs", "to", "train", "model", ":", "param", "batch_size", ":", "size", "of", "training", "batches", ":", "param", "learning_rate", ":", "learning", "rate", "for", "training"...
python
train
AshleySetter/optoanalysis
optoanalysis/optoanalysis/optoanalysis.py
https://github.com/AshleySetter/optoanalysis/blob/9d390acc834d70024d47b574aea14189a5a5714e/optoanalysis/optoanalysis/optoanalysis.py#L2605-L2651
def animate_2Dscatter(x, y, NumAnimatedPoints=50, NTrailPoints=20, xlabel="", ylabel="", xlims=None, ylims=None, filename="testAnim.mp4", bitrate=1e5, dpi=5e2, fps=30, figsize = [6, 6]): """ Animates x and y - where x and y are 1d arrays of x and y positions and it plots x[i:i+NTrailPoints] a...
[ "def", "animate_2Dscatter", "(", "x", ",", "y", ",", "NumAnimatedPoints", "=", "50", ",", "NTrailPoints", "=", "20", ",", "xlabel", "=", "\"\"", ",", "ylabel", "=", "\"\"", ",", "xlims", "=", "None", ",", "ylims", "=", "None", ",", "filename", "=", "...
Animates x and y - where x and y are 1d arrays of x and y positions and it plots x[i:i+NTrailPoints] and y[i:i+NTrailPoints] against each other and iterates through i.
[ "Animates", "x", "and", "y", "-", "where", "x", "and", "y", "are", "1d", "arrays", "of", "x", "and", "y", "positions", "and", "it", "plots", "x", "[", "i", ":", "i", "+", "NTrailPoints", "]", "and", "y", "[", "i", ":", "i", "+", "NTrailPoints", ...
python
train
PaulHancock/Aegean
AegeanTools/wcs_helpers.py
https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/wcs_helpers.py#L602-L619
def get_beamarea_pix(self, ra, dec): """ Calculate the area of the beam in square pixels. Parameters ---------- ra, dec : float The sky position (degrees). Returns ------- area : float The area of the beam in square pixels. ...
[ "def", "get_beamarea_pix", "(", "self", ",", "ra", ",", "dec", ")", ":", "beam", "=", "self", ".", "get_pixbeam", "(", "ra", ",", "dec", ")", "if", "beam", "is", "None", ":", "return", "0", "return", "beam", ".", "a", "*", "beam", ".", "b", "*", ...
Calculate the area of the beam in square pixels. Parameters ---------- ra, dec : float The sky position (degrees). Returns ------- area : float The area of the beam in square pixels.
[ "Calculate", "the", "area", "of", "the", "beam", "in", "square", "pixels", "." ]
python
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/router.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/router.py#L835-L851
def set_ghost_status(self, ghost_status): """ Sets ghost RAM status :param ghost_status: state flag indicating status 0 => Do not use IOS ghosting 1 => This is a ghost instance 2 => Use an existing ghost instance """ yield from self._hypervisor.send('vm ...
[ "def", "set_ghost_status", "(", "self", ",", "ghost_status", ")", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'vm set_ghost_status \"{name}\" {ghost_status}'", ".", "format", "(", "name", "=", "self", ".", "_name", ",", "ghost_status", "...
Sets ghost RAM status :param ghost_status: state flag indicating status 0 => Do not use IOS ghosting 1 => This is a ghost instance 2 => Use an existing ghost instance
[ "Sets", "ghost", "RAM", "status" ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/tiger.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tiger.py#L93-L116
def __add_sentence_to_document(self, sentence): """ Converts a sentence into a TigerSentenceGraph and adds all its nodes, edges (and their features) to this document graph. This also adds a ``dominance_relation`` edge from the root node of this document graph to the root node of...
[ "def", "__add_sentence_to_document", "(", "self", ",", "sentence", ")", ":", "sentence_graph", "=", "TigerSentenceGraph", "(", "sentence", ")", "self", ".", "tokens", ".", "extend", "(", "sentence_graph", ".", "tokens", ")", "sentence_root_node_id", "=", "sentence...
Converts a sentence into a TigerSentenceGraph and adds all its nodes, edges (and their features) to this document graph. This also adds a ``dominance_relation`` edge from the root node of this document graph to the root node of the sentence and appends the sentence root node ID to ``sel...
[ "Converts", "a", "sentence", "into", "a", "TigerSentenceGraph", "and", "adds", "all", "its", "nodes", "edges", "(", "and", "their", "features", ")", "to", "this", "document", "graph", "." ]
python
train
brocade/pynos
pynos/versions/base/services.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/services.py#L126-L176
def vrrpe(self, **kwargs): """Enable or Disable Vrrpe. Args: ip_version (str): The IP version ('4' or '6') for which vrrpe should be enabled/disabled. Default: `4`. enable (bool): If vrrpe should be enabled or disabled. Default: ``True``. ...
[ "def", "vrrpe", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ip_version", "=", "kwargs", ".", "pop", "(", "'ip_version'", ",", "'4'", ")", "enable", "=", "kwargs", ".", "pop", "(", "'enable'", ",", "True", ")", "get", "=", "kwargs", ".", "pop",...
Enable or Disable Vrrpe. Args: ip_version (str): The IP version ('4' or '6') for which vrrpe should be enabled/disabled. Default: `4`. enable (bool): If vrrpe should be enabled or disabled. Default: ``True``. get (bool): Get config instead of...
[ "Enable", "or", "Disable", "Vrrpe", ".", "Args", ":", "ip_version", "(", "str", ")", ":", "The", "IP", "version", "(", "4", "or", "6", ")", "for", "which", "vrrpe", "should", "be", "enabled", "/", "disabled", ".", "Default", ":", "4", ".", "enable", ...
python
train
lord63/tldr.py
tldr/config.py
https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/config.py#L14-L38
def get_config(): """Get the configurations from .tldrrc and return it as a dict.""" config_path = path.join( (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')), '.tldrrc') if not path.exists(config_path): sys.exit("Can't find config file at: {0}. You may use `tldr init` " ...
[ "def", "get_config", "(", ")", ":", "config_path", "=", "path", ".", "join", "(", "(", "os", ".", "environ", ".", "get", "(", "'TLDR_CONFIG_DIR'", ")", "or", "path", ".", "expanduser", "(", "'~'", ")", ")", ",", "'.tldrrc'", ")", "if", "not", "path",...
Get the configurations from .tldrrc and return it as a dict.
[ "Get", "the", "configurations", "from", ".", "tldrrc", "and", "return", "it", "as", "a", "dict", "." ]
python
train
saltstack/salt
salt/utils/decorators/signature.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/decorators/signature.py#L18-L43
def identical_signature_wrapper(original_function, wrapped_function): ''' Return a function with identical signature as ``original_function``'s which will call the ``wrapped_function``. ''' context = {'__wrapped__': wrapped_function} function_def = compile( 'def {0}({1}):\n' ' ...
[ "def", "identical_signature_wrapper", "(", "original_function", ",", "wrapped_function", ")", ":", "context", "=", "{", "'__wrapped__'", ":", "wrapped_function", "}", "function_def", "=", "compile", "(", "'def {0}({1}):\\n'", "' return __wrapped__({2})'", ".", "format"...
Return a function with identical signature as ``original_function``'s which will call the ``wrapped_function``.
[ "Return", "a", "function", "with", "identical", "signature", "as", "original_function", "s", "which", "will", "call", "the", "wrapped_function", "." ]
python
train
ereOn/azmq
azmq/common.py
https://github.com/ereOn/azmq/blob/9f40d6d721eea7f7659ec6cc668811976db59854/azmq/common.py#L361-L374
async def read(self): """ Read from the box in a blocking manner. :returns: An item from the box. """ result = await self._queue.get() self._can_write.set() if self._queue.empty(): self._can_read.clear() return result
[ "async", "def", "read", "(", "self", ")", ":", "result", "=", "await", "self", ".", "_queue", ".", "get", "(", ")", "self", ".", "_can_write", ".", "set", "(", ")", "if", "self", ".", "_queue", ".", "empty", "(", ")", ":", "self", ".", "_can_read...
Read from the box in a blocking manner. :returns: An item from the box.
[ "Read", "from", "the", "box", "in", "a", "blocking", "manner", "." ]
python
train
fdiskyou/kcshell
kcshell/kcshell.py
https://github.com/fdiskyou/kcshell/blob/f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f/kcshell/kcshell.py#L44-L51
def do_setmode(self, arg): ''' shift from ASM to DISASM ''' op_modes = config.get_op_modes() if arg in op_modes: op_mode = op_modes[arg] op_mode.cmdloop() else: print("Error: unknown operational mode, please use 'help setmode'.")
[ "def", "do_setmode", "(", "self", ",", "arg", ")", ":", "op_modes", "=", "config", ".", "get_op_modes", "(", ")", "if", "arg", "in", "op_modes", ":", "op_mode", "=", "op_modes", "[", "arg", "]", "op_mode", ".", "cmdloop", "(", ")", "else", ":", "prin...
shift from ASM to DISASM
[ "shift", "from", "ASM", "to", "DISASM" ]
python
train
senaite/senaite.core
bika/lims/setuphandlers.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/setuphandlers.py#L434-L441
def setup_catalog_mappings(portal): """Setup portal_type -> catalog mappings """ logger.info("*** Setup Catalog Mappings ***") at = api.get_tool("archetype_tool") for portal_type, catalogs in CATALOG_MAPPINGS: at.setCatalogsByType(portal_type, catalogs)
[ "def", "setup_catalog_mappings", "(", "portal", ")", ":", "logger", ".", "info", "(", "\"*** Setup Catalog Mappings ***\"", ")", "at", "=", "api", ".", "get_tool", "(", "\"archetype_tool\"", ")", "for", "portal_type", ",", "catalogs", "in", "CATALOG_MAPPINGS", ":"...
Setup portal_type -> catalog mappings
[ "Setup", "portal_type", "-", ">", "catalog", "mappings" ]
python
train
core/uricore
uricore/wkz_urls.py
https://github.com/core/uricore/blob/dc5ef4be7bd93da4c39e5c1cbd1ae4f3ad3f1f2a/uricore/wkz_urls.py#L412-L425
def url_unquote(s, charset='utf-8', errors='replace'): """URL decode a single string with a given decoding. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a `HTTPUnicodeError` is raised. :param s: th...
[ "def", "url_unquote", "(", "s", ",", "charset", "=", "'utf-8'", ",", "errors", "=", "'replace'", ")", ":", "if", "isinstance", "(", "s", ",", "unicode", ")", ":", "s", "=", "s", ".", "encode", "(", "charset", ")", "return", "_decode_unicode", "(", "_...
URL decode a single string with a given decoding. Per default encoding errors are ignored. If you want a different behavior you can set `errors` to ``'replace'`` or ``'strict'``. In strict mode a `HTTPUnicodeError` is raised. :param s: the string to unquote. :param charset: the charset to be use...
[ "URL", "decode", "a", "single", "string", "with", "a", "given", "decoding", "." ]
python
train
aparo/pyes
pyes/models.py
https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/models.py#L58-L64
def delete(self, bulk=False): """ Delete the object """ meta = self._meta conn = meta['connection'] conn.delete(meta.index, meta.type, meta.id, bulk=bulk)
[ "def", "delete", "(", "self", ",", "bulk", "=", "False", ")", ":", "meta", "=", "self", ".", "_meta", "conn", "=", "meta", "[", "'connection'", "]", "conn", ".", "delete", "(", "meta", ".", "index", ",", "meta", ".", "type", ",", "meta", ".", "id...
Delete the object
[ "Delete", "the", "object" ]
python
train
blackecho/Deep-Learning-TensorFlow
yadlt/utils/utilities.py
https://github.com/blackecho/Deep-Learning-TensorFlow/blob/ddeb1f2848da7b7bee166ad2152b4afc46bb2086/yadlt/utils/utilities.py#L102-L112
def to_one_hot(dataY): """Convert the vector of labels dataY into one-hot encoding. :param dataY: vector of labels :return: one-hot encoded labels """ nc = 1 + np.max(dataY) onehot = [np.zeros(nc, dtype=np.int8) for _ in dataY] for i, j in enumerate(dataY): onehot[i][j] = 1 retu...
[ "def", "to_one_hot", "(", "dataY", ")", ":", "nc", "=", "1", "+", "np", ".", "max", "(", "dataY", ")", "onehot", "=", "[", "np", ".", "zeros", "(", "nc", ",", "dtype", "=", "np", ".", "int8", ")", "for", "_", "in", "dataY", "]", "for", "i", ...
Convert the vector of labels dataY into one-hot encoding. :param dataY: vector of labels :return: one-hot encoded labels
[ "Convert", "the", "vector", "of", "labels", "dataY", "into", "one", "-", "hot", "encoding", "." ]
python
train
bitprophet/ssh
ssh/agent.py
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/agent.py#L199-L219
def connect(self): """ Method automatically called by the run() method of the AgentProxyThread """ if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'): conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: retry_on_signal(lambd...
[ "def", "connect", "(", "self", ")", ":", "if", "(", "'SSH_AUTH_SOCK'", "in", "os", ".", "environ", ")", "and", "(", "sys", ".", "platform", "!=", "'win32'", ")", ":", "conn", "=", "socket", ".", "socket", "(", "socket", ".", "AF_UNIX", ",", "socket",...
Method automatically called by the run() method of the AgentProxyThread
[ "Method", "automatically", "called", "by", "the", "run", "()", "method", "of", "the", "AgentProxyThread" ]
python
train
contentful/contentful-management.py
contentful_management/utils.py
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/utils.py#L73-L87
def camel_case(snake_str): """ Returns a camel-cased version of a string. :param a_string: any :class:`str` object. Usage: >>> camel_case('foo_bar') "fooBar" """ components = snake_str.split('_') # We capitalize the first letter of each component except the first one #...
[ "def", "camel_case", "(", "snake_str", ")", ":", "components", "=", "snake_str", ".", "split", "(", "'_'", ")", "# We capitalize the first letter of each component except the first one", "# with the 'title' method and join them together.", "return", "components", "[", "0", "]...
Returns a camel-cased version of a string. :param a_string: any :class:`str` object. Usage: >>> camel_case('foo_bar') "fooBar"
[ "Returns", "a", "camel", "-", "cased", "version", "of", "a", "string", "." ]
python
train
JoaoFelipe/pyposast
pyposast/__init__.py
https://github.com/JoaoFelipe/pyposast/blob/497c88c66b451ff2cd7354be1af070c92e119f41/pyposast/__init__.py#L12-L27
def parse(code, filename='<unknown>', mode='exec', tree=None): """Parse the source into an AST node with PyPosAST. Enhance nodes with positions Arguments: code -- code text Keyword Arguments: filename -- code path mode -- execution mode (exec, eval, single) tree -- current tree, if i...
[ "def", "parse", "(", "code", ",", "filename", "=", "'<unknown>'", ",", "mode", "=", "'exec'", ",", "tree", "=", "None", ")", ":", "visitor", "=", "Visitor", "(", "code", ",", "filename", ",", "mode", ",", "tree", "=", "tree", ")", "return", "visitor"...
Parse the source into an AST node with PyPosAST. Enhance nodes with positions Arguments: code -- code text Keyword Arguments: filename -- code path mode -- execution mode (exec, eval, single) tree -- current tree, if it was optimized
[ "Parse", "the", "source", "into", "an", "AST", "node", "with", "PyPosAST", ".", "Enhance", "nodes", "with", "positions" ]
python
train
MartijnBraam/pyElectronics
electronics/devices/bmp180.py
https://github.com/MartijnBraam/pyElectronics/blob/a20878c9fa190135f1e478e9ea0b54ca43ff308e/electronics/devices/bmp180.py#L87-L104
def temperature(self): """Get the temperature from the sensor. :returns: The temperature in degree celcius as a float :example: >>> sensor = BMP180(gw) >>> sensor.load_calibration() >>> sensor.temperature() 21.4 """ ut = self.get_raw_temp() ...
[ "def", "temperature", "(", "self", ")", ":", "ut", "=", "self", ".", "get_raw_temp", "(", ")", "x1", "=", "(", "(", "ut", "-", "self", ".", "cal", "[", "'AC6'", "]", ")", "*", "self", ".", "cal", "[", "'AC5'", "]", ")", ">>", "15", "x2", "=",...
Get the temperature from the sensor. :returns: The temperature in degree celcius as a float :example: >>> sensor = BMP180(gw) >>> sensor.load_calibration() >>> sensor.temperature() 21.4
[ "Get", "the", "temperature", "from", "the", "sensor", "." ]
python
train
emirozer/fake2db
fake2db/sqlite_handler.py
https://github.com/emirozer/fake2db/blob/568cf42afb3ac10fc15c4faaa1cdb84fc1f4946c/fake2db/sqlite_handler.py#L17-L33
def fake2db_sqlite_initiator(self, number_of_rows, name=None, custom=None): '''Main handler for the operation ''' rows = number_of_rows conn = self.database_caller_creator(name) if custom: self.custom_db_creator(rows, conn, custom) conn.close() ...
[ "def", "fake2db_sqlite_initiator", "(", "self", ",", "number_of_rows", ",", "name", "=", "None", ",", "custom", "=", "None", ")", ":", "rows", "=", "number_of_rows", "conn", "=", "self", ".", "database_caller_creator", "(", "name", ")", "if", "custom", ":", ...
Main handler for the operation
[ "Main", "handler", "for", "the", "operation" ]
python
train
robgolding/tasklib
tasklib/task.py
https://github.com/robgolding/tasklib/blob/0ad882377639865283021041f19add5aeb10126a/tasklib/task.py#L551-L568
def get(self, **kwargs): """ Performs the query and returns a single object matching the given keyword arguments. """ clone = self.filter(**kwargs) num = len(clone) if num == 1: return clone._result_cache[0] if not num: raise Task.D...
[ "def", "get", "(", "self", ",", "*", "*", "kwargs", ")", ":", "clone", "=", "self", ".", "filter", "(", "*", "*", "kwargs", ")", "num", "=", "len", "(", "clone", ")", "if", "num", "==", "1", ":", "return", "clone", ".", "_result_cache", "[", "0...
Performs the query and returns a single object matching the given keyword arguments.
[ "Performs", "the", "query", "and", "returns", "a", "single", "object", "matching", "the", "given", "keyword", "arguments", "." ]
python
train
amorison/loam
loam/tools.py
https://github.com/amorison/loam/blob/a566c943a75e068a4510099331a1ddfe5bbbdd94/loam/tools.py#L15-L32
def switch_opt(default, shortname, help_msg): """Define a switchable ConfOpt. This creates a boolean option. If you use it in your CLI, it can be switched on and off by prepending + or - to its name: +opt / -opt. Args: default (bool): the default value of the swith option. shortname (s...
[ "def", "switch_opt", "(", "default", ",", "shortname", ",", "help_msg", ")", ":", "return", "ConfOpt", "(", "bool", "(", "default", ")", ",", "True", ",", "shortname", ",", "dict", "(", "action", "=", "internal", ".", "Switch", ")", ",", "True", ",", ...
Define a switchable ConfOpt. This creates a boolean option. If you use it in your CLI, it can be switched on and off by prepending + or - to its name: +opt / -opt. Args: default (bool): the default value of the swith option. shortname (str): short name of the option, no shortname will be u...
[ "Define", "a", "switchable", "ConfOpt", "." ]
python
test
modin-project/modin
modin/pandas/indexing.py
https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/pandas/indexing.py#L294-L315
def _compute_enlarge_labels(self, locator, base_index): """Helper for _enlarge_axis, compute common labels and extra labels. Returns: nan_labels: The labels needs to be added """ # base_index_type can be pd.Index or pd.DatetimeIndex # depending on user input and pan...
[ "def", "_compute_enlarge_labels", "(", "self", ",", "locator", ",", "base_index", ")", ":", "# base_index_type can be pd.Index or pd.DatetimeIndex", "# depending on user input and pandas behavior", "# See issue #2264", "base_index_type", "=", "type", "(", "base_index", ")", "lo...
Helper for _enlarge_axis, compute common labels and extra labels. Returns: nan_labels: The labels needs to be added
[ "Helper", "for", "_enlarge_axis", "compute", "common", "labels", "and", "extra", "labels", "." ]
python
train
PlaidWeb/Publ
publ/entry.py
https://github.com/PlaidWeb/Publ/blob/ce7893632ddc3cb70b4978a41ffd7dd06fa13565/publ/entry.py#L293-L310
def _get_card(self, text, **kwargs): """ Render out the tags for a Twitter/OpenGraph card for this entry. """ def og_tag(key, val): """ produce an OpenGraph tag with the given key and value """ return utils.make_tag('meta', {'property': key, 'content': val}, start_end=True) ...
[ "def", "_get_card", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "def", "og_tag", "(", "key", ",", "val", ")", ":", "\"\"\" produce an OpenGraph tag with the given key and value \"\"\"", "return", "utils", ".", "make_tag", "(", "'meta'", ",", "...
Render out the tags for a Twitter/OpenGraph card for this entry.
[ "Render", "out", "the", "tags", "for", "a", "Twitter", "/", "OpenGraph", "card", "for", "this", "entry", "." ]
python
train
tango-controls/pytango
tango/utils.py
https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/utils.py#L612-L629
def is_int(tg_type, inc_array=False): """Tells if the given tango type is integer :param tg_type: tango type :type tg_type: :class:`tango.CmdArgType` :param inc_array: (optional, default is False) determines if include array in the list of checked types :type inc_array: :py:ob...
[ "def", "is_int", "(", "tg_type", ",", "inc_array", "=", "False", ")", ":", "global", "_scalar_int_types", ",", "_array_int_types", "if", "tg_type", "in", "_scalar_int_types", ":", "return", "True", "if", "not", "inc_array", ":", "return", "False", "return", "t...
Tells if the given tango type is integer :param tg_type: tango type :type tg_type: :class:`tango.CmdArgType` :param inc_array: (optional, default is False) determines if include array in the list of checked types :type inc_array: :py:obj:`bool` :return: True if the given tang...
[ "Tells", "if", "the", "given", "tango", "type", "is", "integer" ]
python
train
xflr6/features
features/tools.py
https://github.com/xflr6/features/blob/f985304dd642da6ecdc66d85167d00daa4efe5f4/features/tools.py#L10-L18
def uniqued(iterable): """Return unique list of items preserving order. >>> uniqued([3, 2, 1, 3, 2, 1, 0]) [3, 2, 1, 0] """ seen = set() add = seen.add return [i for i in iterable if i not in seen and not add(i)]
[ "def", "uniqued", "(", "iterable", ")", ":", "seen", "=", "set", "(", ")", "add", "=", "seen", ".", "add", "return", "[", "i", "for", "i", "in", "iterable", "if", "i", "not", "in", "seen", "and", "not", "add", "(", "i", ")", "]" ]
Return unique list of items preserving order. >>> uniqued([3, 2, 1, 3, 2, 1, 0]) [3, 2, 1, 0]
[ "Return", "unique", "list", "of", "items", "preserving", "order", "." ]
python
train
OSSOS/MOP
src/jjk/preproc/cfeps_object.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/jjk/preproc/cfeps_object.py#L57-L75
def getData(file_id,ra,dec): """Create a link that connects to a getData URL""" DATA="www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca" BASE="http://"+DATA+"/authProxy/getData" archive="CFHT" wcs="corrected" import re groups=re.match('^(?P<file_id>\d{6}).*',file_id) if not groups: return No...
[ "def", "getData", "(", "file_id", ",", "ra", ",", "dec", ")", ":", "DATA", "=", "\"www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca\"", "BASE", "=", "\"http://\"", "+", "DATA", "+", "\"/authProxy/getData\"", "archive", "=", "\"CFHT\"", "wcs", "=", "\"corrected\"", "import", ...
Create a link that connects to a getData URL
[ "Create", "a", "link", "that", "connects", "to", "a", "getData", "URL" ]
python
train
googleapis/google-cloud-python
firestore/google/cloud/firestore_v1beta1/client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/firestore/google/cloud/firestore_v1beta1/client.py#L412-L435
def _get_reference(document_path, reference_map): """Get a document reference from a dictionary. This just wraps a simple dictionary look-up with a helpful error that is specific to :meth:`~.firestore.client.Client.get_all`, the **public** caller of this function. Args: document_path (str)...
[ "def", "_get_reference", "(", "document_path", ",", "reference_map", ")", ":", "try", ":", "return", "reference_map", "[", "document_path", "]", "except", "KeyError", ":", "msg", "=", "_BAD_DOC_TEMPLATE", ".", "format", "(", "document_path", ")", "raise", "Value...
Get a document reference from a dictionary. This just wraps a simple dictionary look-up with a helpful error that is specific to :meth:`~.firestore.client.Client.get_all`, the **public** caller of this function. Args: document_path (str): A fully-qualified document path. reference_map ...
[ "Get", "a", "document", "reference", "from", "a", "dictionary", "." ]
python
train
rocky/python-xdis
xdis/std.py
https://github.com/rocky/python-xdis/blob/46a2902ae8f5d8eee495eed67ac0690fd545453d/xdis/std.py#L135-L141
def dis(self, x=None, file=None): """Disassemble classes, methods, functions, generators, or code. With no argument, disassemble the last traceback. """ self._print(self.Bytecode(x).dis(), file)
[ "def", "dis", "(", "self", ",", "x", "=", "None", ",", "file", "=", "None", ")", ":", "self", ".", "_print", "(", "self", ".", "Bytecode", "(", "x", ")", ".", "dis", "(", ")", ",", "file", ")" ]
Disassemble classes, methods, functions, generators, or code. With no argument, disassemble the last traceback.
[ "Disassemble", "classes", "methods", "functions", "generators", "or", "code", "." ]
python
train
objectrocket/python-client
objectrocket/auth.py
https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/auth.py#L86-L96
def _refresh(self): """Refresh the API token using the currently bound credentials. This is simply a convenience method to be invoked automatically if authentication fails during normal client use. """ # Request and set a new API token. new_token = self.authenticate(self...
[ "def", "_refresh", "(", "self", ")", ":", "# Request and set a new API token.", "new_token", "=", "self", ".", "authenticate", "(", "self", ".", "_username", ",", "self", ".", "_password", ")", "self", ".", "_token", "=", "new_token", "logger", ".", "info", ...
Refresh the API token using the currently bound credentials. This is simply a convenience method to be invoked automatically if authentication fails during normal client use.
[ "Refresh", "the", "API", "token", "using", "the", "currently", "bound", "credentials", "." ]
python
train
jvarho/pylibscrypt
pylibscrypt/libsodium_load.py
https://github.com/jvarho/pylibscrypt/blob/f2ff02e49f44aa620e308a4a64dd8376b9510f99/pylibscrypt/libsodium_load.py#L19-L71
def get_libsodium(): '''Locate the libsodium C library''' __SONAMES = (13, 10, 5, 4) # Import libsodium from system sys_sodium = ctypes.util.find_library('sodium') if sys_sodium is None: sys_sodium = ctypes.util.find_library('libsodium') if sys_sodium: try: return c...
[ "def", "get_libsodium", "(", ")", ":", "__SONAMES", "=", "(", "13", ",", "10", ",", "5", ",", "4", ")", "# Import libsodium from system", "sys_sodium", "=", "ctypes", ".", "util", ".", "find_library", "(", "'sodium'", ")", "if", "sys_sodium", "is", "None",...
Locate the libsodium C library
[ "Locate", "the", "libsodium", "C", "library" ]
python
train
marshmallow-code/webargs
src/webargs/pyramidparser.py
https://github.com/marshmallow-code/webargs/blob/40cc2d25421d15d9630b1a819f1dcefbbf01ed95/src/webargs/pyramidparser.py#L88-L101
def handle_error(self, error, req, schema, error_status_code, error_headers): """Handles errors during parsing. Aborts the current HTTP request and responds with a 400 error. """ status_code = error_status_code or self.DEFAULT_VALIDATION_STATUS response = exception_response( ...
[ "def", "handle_error", "(", "self", ",", "error", ",", "req", ",", "schema", ",", "error_status_code", ",", "error_headers", ")", ":", "status_code", "=", "error_status_code", "or", "self", ".", "DEFAULT_VALIDATION_STATUS", "response", "=", "exception_response", "...
Handles errors during parsing. Aborts the current HTTP request and responds with a 400 error.
[ "Handles", "errors", "during", "parsing", ".", "Aborts", "the", "current", "HTTP", "request", "and", "responds", "with", "a", "400", "error", "." ]
python
train
gwastro/pycbc
pycbc/strain/lines.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/strain/lines.py#L41-L77
def avg_inner_product(data1, data2, bin_size): """ Calculate the time-domain inner product averaged over bins. Parameters ---------- data1: pycbc.types.TimeSeries First data set. data2: pycbc.types.TimeSeries Second data set, with same duration and sample rate as data1. bin_size...
[ "def", "avg_inner_product", "(", "data1", ",", "data2", ",", "bin_size", ")", ":", "assert", "data1", ".", "duration", "==", "data2", ".", "duration", "assert", "data1", ".", "sample_rate", "==", "data2", ".", "sample_rate", "seglen", "=", "int", "(", "bin...
Calculate the time-domain inner product averaged over bins. Parameters ---------- data1: pycbc.types.TimeSeries First data set. data2: pycbc.types.TimeSeries Second data set, with same duration and sample rate as data1. bin_size: float Duration of the bins the data will be d...
[ "Calculate", "the", "time", "-", "domain", "inner", "product", "averaged", "over", "bins", "." ]
python
train
saltstack/salt
salt/cloud/clouds/cloudstack.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/cloudstack.py#L218-L228
def get_ip(data): ''' Return the IP address of the VM If the VM has public IP as defined by libcloud module then use it Otherwise try to extract the private IP and use that one. ''' try: ip = data.public_ips[0] except Exception: ip = data.private_ips[0] return ip
[ "def", "get_ip", "(", "data", ")", ":", "try", ":", "ip", "=", "data", ".", "public_ips", "[", "0", "]", "except", "Exception", ":", "ip", "=", "data", ".", "private_ips", "[", "0", "]", "return", "ip" ]
Return the IP address of the VM If the VM has public IP as defined by libcloud module then use it Otherwise try to extract the private IP and use that one.
[ "Return", "the", "IP", "address", "of", "the", "VM", "If", "the", "VM", "has", "public", "IP", "as", "defined", "by", "libcloud", "module", "then", "use", "it", "Otherwise", "try", "to", "extract", "the", "private", "IP", "and", "use", "that", "one", "...
python
train
dmlc/gluon-nlp
scripts/machine_translation/bleu.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/machine_translation/bleu.py#L76-L110
def _tokenize_mteval_13a(segment): r""" Tokenizes a string following the tokenizer in mteval-v13a.pl. See https://github.com/moses-smt/mosesdecoder/" "blob/master/scripts/generic/mteval-v14.pl#L917-L942 Parameters ---------- segment: str A string to be tokenized Returns ...
[ "def", "_tokenize_mteval_13a", "(", "segment", ")", ":", "norm", "=", "segment", ".", "rstrip", "(", ")", "norm", "=", "norm", ".", "replace", "(", "'<skipped>'", ",", "''", ")", "norm", "=", "norm", ".", "replace", "(", "'-\\n'", ",", "''", ")", "no...
r""" Tokenizes a string following the tokenizer in mteval-v13a.pl. See https://github.com/moses-smt/mosesdecoder/" "blob/master/scripts/generic/mteval-v14.pl#L917-L942 Parameters ---------- segment: str A string to be tokenized Returns ------- The tokenized string
[ "r", "Tokenizes", "a", "string", "following", "the", "tokenizer", "in", "mteval", "-", "v13a", ".", "pl", ".", "See", "https", ":", "//", "github", ".", "com", "/", "moses", "-", "smt", "/", "mosesdecoder", "/", "blob", "/", "master", "/", "scripts", ...
python
train
LonamiWebs/Telethon
telethon/network/mtprotosender.py
https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/network/mtprotosender.py#L334-L347
def _start_reconnect(self, error): """Starts a reconnection in the background.""" if self._user_connected and not self._reconnecting: # We set reconnecting to True here and not inside the new task # because it may happen that send/recv loop calls this again # while th...
[ "def", "_start_reconnect", "(", "self", ",", "error", ")", ":", "if", "self", ".", "_user_connected", "and", "not", "self", ".", "_reconnecting", ":", "# We set reconnecting to True here and not inside the new task", "# because it may happen that send/recv loop calls this again...
Starts a reconnection in the background.
[ "Starts", "a", "reconnection", "in", "the", "background", "." ]
python
train
automl/HpBandSter
hpbandster/optimizers/config_generators/kde.py
https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/config_generators/kde.py#L50-L82
def get_config(self, budget): """ Function to sample a new configuration This function is called inside Hyperband to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled returns: config should return a valid configuration ...
[ "def", "get_config", "(", "self", ",", "budget", ")", ":", "# No observations available for this budget sample from the prior", "if", "len", "(", "self", ".", "kde_models", ".", "keys", "(", ")", ")", "==", "0", ":", "return", "self", ".", "configspace", ".", ...
Function to sample a new configuration This function is called inside Hyperband to query a new configuration Parameters: ----------- budget: float the budget for which this configuration is scheduled returns: config should return a valid configuration
[ "Function", "to", "sample", "a", "new", "configuration" ]
python
train
xsleonard/pystmark
pystmark.py
https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L510-L517
def bcc(self, bcc): ''' :param bcc: Email addresses for the 'Bcc' API field. :type bcc: :keyword:`list` or `str` ''' if isinstance(bcc, basestring): bcc = bcc.split(',') self._bcc = bcc
[ "def", "bcc", "(", "self", ",", "bcc", ")", ":", "if", "isinstance", "(", "bcc", ",", "basestring", ")", ":", "bcc", "=", "bcc", ".", "split", "(", "','", ")", "self", ".", "_bcc", "=", "bcc" ]
:param bcc: Email addresses for the 'Bcc' API field. :type bcc: :keyword:`list` or `str`
[ ":", "param", "bcc", ":", "Email", "addresses", "for", "the", "Bcc", "API", "field", ".", ":", "type", "bcc", ":", ":", "keyword", ":", "list", "or", "str" ]
python
train
dwavesystems/minorminer
examples/fourcolor.py
https://github.com/dwavesystems/minorminer/blob/05cac6db180adf8223a613dff808248e3048b07d/examples/fourcolor.py#L83-L126
def chimera_block_quotient(G, blocks): """ Extract the blocks from a graph, and returns a block-quotient graph according to the acceptability functions block_good and eblock_good Inputs: G: a networkx graph blocks: a tuple of tuples """ from networkx import Graph from i...
[ "def", "chimera_block_quotient", "(", "G", ",", "blocks", ")", ":", "from", "networkx", "import", "Graph", "from", "itertools", "import", "product", "BG", "=", "Graph", "(", ")", "blockid", "=", "{", "}", "for", "i", ",", "b", "in", "enumerate", "(", "...
Extract the blocks from a graph, and returns a block-quotient graph according to the acceptability functions block_good and eblock_good Inputs: G: a networkx graph blocks: a tuple of tuples
[ "Extract", "the", "blocks", "from", "a", "graph", "and", "returns", "a", "block", "-", "quotient", "graph", "according", "to", "the", "acceptability", "functions", "block_good", "and", "eblock_good" ]
python
test
beczkowb/csvparser
csvparser/parser.py
https://github.com/beczkowb/csvparser/blob/f9f9bd37e10e3c1c223d559194367b25900a822a/csvparser/parser.py#L41-L52
def is_valid(self): """ Validates single instance. Returns boolean value and store errors in self.errors """ self.errors = [] for field in self.get_all_field_names_declared_by_user(): getattr(type(self), field).is_valid(self, type(self), field) field_erro...
[ "def", "is_valid", "(", "self", ")", ":", "self", ".", "errors", "=", "[", "]", "for", "field", "in", "self", ".", "get_all_field_names_declared_by_user", "(", ")", ":", "getattr", "(", "type", "(", "self", ")", ",", "field", ")", ".", "is_valid", "(",...
Validates single instance. Returns boolean value and store errors in self.errors
[ "Validates", "single", "instance", ".", "Returns", "boolean", "value", "and", "store", "errors", "in", "self", ".", "errors" ]
python
train
dpkp/kafka-python
kafka/coordinator/base.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/base.py#L242-L270
def ensure_coordinator_ready(self): """Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue). """ with self._client._lock, self._lock: while self.coordinator_unknown(): # Prior to 0.8.2 there w...
[ "def", "ensure_coordinator_ready", "(", "self", ")", ":", "with", "self", ".", "_client", ".", "_lock", ",", "self", ".", "_lock", ":", "while", "self", ".", "coordinator_unknown", "(", ")", ":", "# Prior to 0.8.2 there was no group coordinator", "# so we will just ...
Block until the coordinator for this group is known (and we have an active connection -- java client uses unsent queue).
[ "Block", "until", "the", "coordinator", "for", "this", "group", "is", "known", "(", "and", "we", "have", "an", "active", "connection", "--", "java", "client", "uses", "unsent", "queue", ")", "." ]
python
train
tradenity/python-sdk
tradenity/resources/tax_rate.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/tax_rate.py#L840-L861
def replace_tax_rate_by_id(cls, tax_rate_id, tax_rate, **kwargs): """Replace TaxRate Replace all attributes of TaxRate This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.replace_tax_rate_by_id(ta...
[ "def", "replace_tax_rate_by_id", "(", "cls", ",", "tax_rate_id", ",", "tax_rate", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", ...
Replace TaxRate Replace all attributes of TaxRate This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.replace_tax_rate_by_id(tax_rate_id, tax_rate, async=True) >>> result = thread.get() :...
[ "Replace", "TaxRate" ]
python
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L444-L491
def get_urls(config, log): """Wait for AppVeyor job to finish and get all artifacts' URLs. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Paths and URLs from artifacts_urls. :rtype: dict """ ...
[ "def", "get_urls", "(", "config", ",", "log", ")", ":", "# Wait for job to be queued. Once it is we'll have the \"version\".", "build_version", "=", "None", "for", "_", "in", "range", "(", "3", ")", ":", "build_version", "=", "query_build_version", "(", "config", ")...
Wait for AppVeyor job to finish and get all artifacts' URLs. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Paths and URLs from artifacts_urls. :rtype: dict
[ "Wait", "for", "AppVeyor", "job", "to", "finish", "and", "get", "all", "artifacts", "URLs", "." ]
python
train
materialsvirtuallab/monty
monty/subprocess.py
https://github.com/materialsvirtuallab/monty/blob/d99d6f3c68372d83489d28ff515566c93cd569e2/monty/subprocess.py#L59-L99
def run(self, timeout=None, **kwargs): """ Run a command in a separated thread and wait timeout seconds. kwargs are keyword arguments passed to Popen. Return: self """ from subprocess import Popen, PIPE def target(**kw): try: # print(...
[ "def", "run", "(", "self", ",", "timeout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "subprocess", "import", "Popen", ",", "PIPE", "def", "target", "(", "*", "*", "kw", ")", ":", "try", ":", "# print('Thread started')", "self", ".", "pr...
Run a command in a separated thread and wait timeout seconds. kwargs are keyword arguments passed to Popen. Return: self
[ "Run", "a", "command", "in", "a", "separated", "thread", "and", "wait", "timeout", "seconds", ".", "kwargs", "are", "keyword", "arguments", "passed", "to", "Popen", "." ]
python
train
csparpa/pyowm
pyowm/weatherapi25/owm25.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/owm25.py#L1113-L1132
def uvindex_forecast_around_coords(self, lat, lon): """ Queries the OWM Weather API for forecast Ultra Violet values in the next 8 days in the surroundings of the provided geocoordinates. :param lat: the location's latitude, must be between -90.0 and 90.0 :type lat: int/float ...
[ "def", "uvindex_forecast_around_coords", "(", "self", ",", "lat", ",", "lon", ")", ":", "geo", ".", "assert_is_lon", "(", "lon", ")", "geo", ".", "assert_is_lat", "(", "lat", ")", "params", "=", "{", "'lon'", ":", "lon", ",", "'lat'", ":", "lat", "}", ...
Queries the OWM Weather API for forecast Ultra Violet values in the next 8 days in the surroundings of the provided geocoordinates. :param lat: the location's latitude, must be between -90.0 and 90.0 :type lat: int/float :param lon: the location's longitude, must be between -180.0 and 1...
[ "Queries", "the", "OWM", "Weather", "API", "for", "forecast", "Ultra", "Violet", "values", "in", "the", "next", "8", "days", "in", "the", "surroundings", "of", "the", "provided", "geocoordinates", "." ]
python
train
awickert/gFlex
gflex/base.py
https://github.com/awickert/gFlex/blob/3ac32249375b0f8d342a142585d86ea4d905a5a0/gflex/base.py#L927-L1008
def FD(self): """ Set-up for the finite difference solution method """ if self.Verbose: print("Finite Difference Solution Technique") # Used to check for coeff_matrix here, but now doing so in self.bc_check() # called by f1d and f2d at the start # # Define a stress-based qs = q0 ...
[ "def", "FD", "(", "self", ")", ":", "if", "self", ".", "Verbose", ":", "print", "(", "\"Finite Difference Solution Technique\"", ")", "# Used to check for coeff_matrix here, but now doing so in self.bc_check()", "# called by f1d and f2d at the start", "# ", "# Define a stress-bas...
Set-up for the finite difference solution method
[ "Set", "-", "up", "for", "the", "finite", "difference", "solution", "method" ]
python
train
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L9404-L9528
def get_description(self): """Returns information about the virtual system as arrays of instruction items. In each array, the items with the same indices correspond and jointly represent an import instruction for VirtualBox. The list below identifies the value sets that are possible dep...
[ "def", "get_description", "(", "self", ")", ":", "(", "types", ",", "refs", ",", "ovf_values", ",", "v_box_values", ",", "extra_config_values", ")", "=", "self", ".", "_call", "(", "\"getDescription\"", ")", "types", "=", "[", "VirtualSystemDescriptionType", "...
Returns information about the virtual system as arrays of instruction items. In each array, the items with the same indices correspond and jointly represent an import instruction for VirtualBox. The list below identifies the value sets that are possible depending on the :py:class:`Virtu...
[ "Returns", "information", "about", "the", "virtual", "system", "as", "arrays", "of", "instruction", "items", ".", "In", "each", "array", "the", "items", "with", "the", "same", "indices", "correspond", "and", "jointly", "represent", "an", "import", "instruction",...
python
train
willkg/socorro-siggen
siggen/rules.py
https://github.com/willkg/socorro-siggen/blob/db7e3233e665a458a961c48da22e93a69b1d08d6/siggen/rules.py#L268-L351
def _do_generate(self, source_list, hang_type, crashed_thread, delimiter=' | '): """ each element of signatureList names a frame in the crash stack; and is: - a prefix of a relevant frame: Append this element to the signature - a relevant frame: Append this element and stop looking ...
[ "def", "_do_generate", "(", "self", ",", "source_list", ",", "hang_type", ",", "crashed_thread", ",", "delimiter", "=", "' | '", ")", ":", "notes", "=", "[", "]", "debug_notes", "=", "[", "]", "# shorten source_list to the first signatureSentinel", "sentinel_locatio...
each element of signatureList names a frame in the crash stack; and is: - a prefix of a relevant frame: Append this element to the signature - a relevant frame: Append this element and stop looking - irrelevant: Append this element only after seeing a prefix frame The signature is ...
[ "each", "element", "of", "signatureList", "names", "a", "frame", "in", "the", "crash", "stack", ";", "and", "is", ":", "-", "a", "prefix", "of", "a", "relevant", "frame", ":", "Append", "this", "element", "to", "the", "signature", "-", "a", "relevant", ...
python
train
saltstack/salt
salt/states/boto_cognitoidentity.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_cognitoidentity.py#L66-L90
def _get_object(objname, objtype): ''' Helper function to retrieve objtype from pillars if objname is string_types, used for SupportedLoginProviders and OpenIdConnectProviderARNs. ''' ret = None if objname is None: return ret if isinstance(objname, string_types): if objn...
[ "def", "_get_object", "(", "objname", ",", "objtype", ")", ":", "ret", "=", "None", "if", "objname", "is", "None", ":", "return", "ret", "if", "isinstance", "(", "objname", ",", "string_types", ")", ":", "if", "objname", "in", "__opts__", ":", "ret", "...
Helper function to retrieve objtype from pillars if objname is string_types, used for SupportedLoginProviders and OpenIdConnectProviderARNs.
[ "Helper", "function", "to", "retrieve", "objtype", "from", "pillars", "if", "objname", "is", "string_types", "used", "for", "SupportedLoginProviders", "and", "OpenIdConnectProviderARNs", "." ]
python
train
MolSSI-BSE/basis_set_exchange
basis_set_exchange/api.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/api.py#L297-L314
def get_metadata(data_dir=None): '''Obtain the metadata for all basis sets The metadata includes information such as the display name of the basis set, its versions, and what elements are included in the basis set The data is read from the METADATA.json file in the `data_dir` directory. Parameter...
[ "def", "get_metadata", "(", "data_dir", "=", "None", ")", ":", "data_dir", "=", "fix_data_dir", "(", "data_dir", ")", "metadata_file", "=", "os", ".", "path", ".", "join", "(", "data_dir", ",", "\"METADATA.json\"", ")", "return", "fileio", ".", "read_metadat...
Obtain the metadata for all basis sets The metadata includes information such as the display name of the basis set, its versions, and what elements are included in the basis set The data is read from the METADATA.json file in the `data_dir` directory. Parameters ---------- data_dir : str ...
[ "Obtain", "the", "metadata", "for", "all", "basis", "sets" ]
python
train