repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
tarzanjw/python-mysql-binlog-to-blinker
setup.py
https://github.com/tarzanjw/python-mysql-binlog-to-blinker/blob/d61ab5962345377e142a225b16f731ab4196fc26/setup.py#L150-L164
def _lint(): """Run lint and return an exit code.""" # Flake8 doesn't have an easy way to run checks using a Python function, so # just fork off another process to do it. # Python 3 compat: # - The result of subprocess call outputs are byte strings, meaning we need # to pass a byte string to ...
[ "def", "_lint", "(", ")", ":", "# Flake8 doesn't have an easy way to run checks using a Python function, so", "# just fork off another process to do it.", "# Python 3 compat:", "# - The result of subprocess call outputs are byte strings, meaning we need", "# to pass a byte string to endswith.", ...
Run lint and return an exit code.
[ "Run", "lint", "and", "return", "an", "exit", "code", "." ]
python
train
42.133333
openstack/pyghmi
pyghmi/ipmi/console.py
https://github.com/openstack/pyghmi/blob/f710b1d30a8eed19a9e86f01f9351c737666f3e5/pyghmi/ipmi/console.py#L459-L531
def _got_sol_payload(self, payload): """SOL payload callback """ # TODO(jbjohnso) test cases to throw some likely scenarios at functions # for example, retry with new data, retry with no new data # retry with unexpected sequence number if type(payload) == dict: # we rece...
[ "def", "_got_sol_payload", "(", "self", ",", "payload", ")", ":", "# TODO(jbjohnso) test cases to throw some likely scenarios at functions", "# for example, retry with new data, retry with no new data", "# retry with unexpected sequence number", "if", "type", "(", "payload", ")", "==...
SOL payload callback
[ "SOL", "payload", "callback" ]
python
train
49.041096
rodluger/everest
everest/basecamp.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/basecamp.py#L1077-L1178
def lnlike(self, model, refactor=False, pos_tol=2.5, neg_tol=50., full_output=False): r""" Return the likelihood of the astrophysical model `model`. Returns the likelihood of `model` marginalized over the PLD model. :param ndarray model: A vector of the same shape as `se...
[ "def", "lnlike", "(", "self", ",", "model", ",", "refactor", "=", "False", ",", "pos_tol", "=", "2.5", ",", "neg_tol", "=", "50.", ",", "full_output", "=", "False", ")", ":", "lnl", "=", "0", "# Re-factorize the Cholesky decomposition?", "try", ":", "self"...
r""" Return the likelihood of the astrophysical model `model`. Returns the likelihood of `model` marginalized over the PLD model. :param ndarray model: A vector of the same shape as `self.time` \ corresponding to the astrophysical model. :param bool refactor: Re-compute ...
[ "r", "Return", "the", "likelihood", "of", "the", "astrophysical", "model", "model", "." ]
python
train
43.980392
django-danceschool/django-danceschool
danceschool/core/classreg.py
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/classreg.py#L666-L699
def form_valid(self,form): ''' Even if this form is valid, the handlers for this form may have added messages to the request. In that case, then the page should be handled as if the form were invalid. Otherwise, update the session data with the form data and then move to the ne...
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "reg", "=", "self", ".", "temporaryRegistration", "# The session expires after a period of inactivity that is specified in preferences.", "expiry", "=", "timezone", ".", "now", "(", ")", "+", "timedelta", "(", "...
Even if this form is valid, the handlers for this form may have added messages to the request. In that case, then the page should be handled as if the form were invalid. Otherwise, update the session data with the form data and then move to the next view
[ "Even", "if", "this", "form", "is", "valid", "the", "handlers", "for", "this", "form", "may", "have", "added", "messages", "to", "the", "request", ".", "In", "that", "case", "then", "the", "page", "should", "be", "handled", "as", "if", "the", "form", "...
python
train
50.676471
inveniosoftware/invenio-communities
invenio_communities/forms.py
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/forms.py#L154-L161
def validate_identifier(self, field): """Validate field identifier.""" if field.data: field.data = field.data.lower() if Community.get(field.data, with_deleted=True): raise validators.ValidationError( _('The identifier already exists. ' ...
[ "def", "validate_identifier", "(", "self", ",", "field", ")", ":", "if", "field", ".", "data", ":", "field", ".", "data", "=", "field", ".", "data", ".", "lower", "(", ")", "if", "Community", ".", "get", "(", "field", ".", "data", ",", "with_deleted"...
Validate field identifier.
[ "Validate", "field", "identifier", "." ]
python
train
45.25
aliyun/aliyun-odps-python-sdk
odps/models/instance.py
https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/models/instance.py#L654-L690
def get_logview_address(self, hours=None): """ Get logview address of the instance object by hours. :param hours: :return: logview address :rtype: str """ hours = hours or options.log_view_hours project = self.project url = '%s/authorization' % p...
[ "def", "get_logview_address", "(", "self", ",", "hours", "=", "None", ")", ":", "hours", "=", "hours", "or", "options", ".", "log_view_hours", "project", "=", "self", ".", "project", "url", "=", "'%s/authorization'", "%", "project", ".", "resource", "(", "...
Get logview address of the instance object by hours. :param hours: :return: logview address :rtype: str
[ "Get", "logview", "address", "of", "the", "instance", "object", "by", "hours", "." ]
python
train
33.351351
azavea/python-omgeo
omgeo/services/base.py
https://github.com/azavea/python-omgeo/blob/40f4e006f087dbc795a5d954ffa2c0eab433f8c9/omgeo/services/base.py#L168-L174
def _get_xml_doc(self, endpoint, query, is_post=False): """ Return False if connection could not be made. Otherwise, return a minidom Document. """ response = self._get_response(endpoint, query, is_post=is_post) return minidom.parse(response.text)
[ "def", "_get_xml_doc", "(", "self", ",", "endpoint", ",", "query", ",", "is_post", "=", "False", ")", ":", "response", "=", "self", ".", "_get_response", "(", "endpoint", ",", "query", ",", "is_post", "=", "is_post", ")", "return", "minidom", ".", "parse...
Return False if connection could not be made. Otherwise, return a minidom Document.
[ "Return", "False", "if", "connection", "could", "not", "be", "made", ".", "Otherwise", "return", "a", "minidom", "Document", "." ]
python
train
41.285714
google/mobly
mobly/controllers/android_device.py
https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/android_device.py#L937-L954
def reboot(self): """Reboots the device. Generally one should use this method to reboot the device instead of directly calling `adb.reboot`. Because this method gracefully handles the teardown and restoration of running services. This method is blocking and only returns when th...
[ "def", "reboot", "(", "self", ")", ":", "if", "self", ".", "is_bootloader", ":", "self", ".", "fastboot", ".", "reboot", "(", ")", "return", "with", "self", ".", "handle_reboot", "(", ")", ":", "self", ".", "adb", ".", "reboot", "(", ")" ]
Reboots the device. Generally one should use this method to reboot the device instead of directly calling `adb.reboot`. Because this method gracefully handles the teardown and restoration of running services. This method is blocking and only returns when the reboot has completed ...
[ "Reboots", "the", "device", "." ]
python
train
32.888889
Erotemic/utool
utool/_internal/util_importer.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L410-L417
def make_initstr(modname, import_tuples, verbose=False): """ Just creates the string representation. Does no importing. """ imports = [tup[0] for tup in import_tuples] from_imports = __get_from_imports(import_tuples) inject_execstr = _inject_execstr(modname, import_tuples) return _initstr(mo...
[ "def", "make_initstr", "(", "modname", ",", "import_tuples", ",", "verbose", "=", "False", ")", ":", "imports", "=", "[", "tup", "[", "0", "]", "for", "tup", "in", "import_tuples", "]", "from_imports", "=", "__get_from_imports", "(", "import_tuples", ")", ...
Just creates the string representation. Does no importing.
[ "Just", "creates", "the", "string", "representation", ".", "Does", "no", "importing", "." ]
python
train
44.75
pavoni/pyvera
pyvera/subscribe.py
https://github.com/pavoni/pyvera/blob/e05e3d13f76153444787d31948feb5419d77a8c8/pyvera/subscribe.py#L41-L53
def register(self, device, callback): """Register a callback. device: device to be updated by subscription callback: callback for notification of changes """ if not device: logger.error("Received an invalid device: %r", device) return logger.debu...
[ "def", "register", "(", "self", ",", "device", ",", "callback", ")", ":", "if", "not", "device", ":", "logger", ".", "error", "(", "\"Received an invalid device: %r\"", ",", "device", ")", "return", "logger", ".", "debug", "(", "\"Subscribing to events for %s\""...
Register a callback. device: device to be updated by subscription callback: callback for notification of changes
[ "Register", "a", "callback", "." ]
python
train
35.615385
SHTOOLS/SHTOOLS
pyshtools/shclasses/shcoeffsgrid.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/shcoeffsgrid.py#L2475-L2498
def lats(self, degrees=True): """ Return the latitudes of each row of the gridded data. Usage ----- lats = x.lats([degrees]) Returns ------- lats : ndarray, shape (nlat) 1-D numpy array of size nlat containing the latitude of each row ...
[ "def", "lats", "(", "self", ",", "degrees", "=", "True", ")", ":", "if", "degrees", "is", "False", ":", "return", "_np", ".", "radians", "(", "self", ".", "_lats", "(", ")", ")", "else", ":", "return", "self", ".", "_lats", "(", ")" ]
Return the latitudes of each row of the gridded data. Usage ----- lats = x.lats([degrees]) Returns ------- lats : ndarray, shape (nlat) 1-D numpy array of size nlat containing the latitude of each row of the gridded data. Parameters ...
[ "Return", "the", "latitudes", "of", "each", "row", "of", "the", "gridded", "data", "." ]
python
train
26.833333
dailymuse/oz
oz/sqlalchemy/middleware.py
https://github.com/dailymuse/oz/blob/4329f6a207dc9d2a8fbeb4d16d415dbe4570b5bd/oz/sqlalchemy/middleware.py#L20-L30
def db(self, connection_string=None): """Gets the SQLALchemy session for this request""" connection_string = connection_string or self.settings["db"] if not hasattr(self, "_db_conns"): self._db_conns = {} if not connection_string in self._db_conns: self._db_conn...
[ "def", "db", "(", "self", ",", "connection_string", "=", "None", ")", ":", "connection_string", "=", "connection_string", "or", "self", ".", "settings", "[", "\"db\"", "]", "if", "not", "hasattr", "(", "self", ",", "\"_db_conns\"", ")", ":", "self", ".", ...
Gets the SQLALchemy session for this request
[ "Gets", "the", "SQLALchemy", "session", "for", "this", "request" ]
python
train
40.090909
spyder-ide/spyder
spyder/app/mainwindow.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L3274-L3318
def run_spyder(app, options, args): """ Create and show Spyder's main window Start QApplication event loop """ #TODO: insert here # Main window main = MainWindow(options) try: main.setup() except BaseException: if main.console is not None: try:...
[ "def", "run_spyder", "(", "app", ",", "options", ",", "args", ")", ":", "#TODO: insert here\r", "# Main window\r", "main", "=", "MainWindow", "(", "options", ")", "try", ":", "main", ".", "setup", "(", ")", "except", "BaseException", ":", "if", "main", "."...
Create and show Spyder's main window Start QApplication event loop
[ "Create", "and", "show", "Spyder", "s", "main", "window", "Start", "QApplication", "event", "loop" ]
python
train
28.066667
projectshift/shift-boiler
boiler/user/validators.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/validators.py#L9-L26
def validate(self, value, model=None, context=None): """ Perform validation """ from boiler.user.services import user_service self_id = None if model: if isinstance(model, dict): self_id = model.get('id') else: self_id = getattr(mo...
[ "def", "validate", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "from", "boiler", ".", "user", ".", "services", "import", "user_service", "self_id", "=", "None", "if", "model", ":", "if", "isinstance", "(...
Perform validation
[ "Perform", "validation" ]
python
train
29.944444
orbingol/NURBS-Python
geomdl/linalg.py
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/linalg.py#L538-L562
def frange(start, stop, step=1.0): """ Implementation of Python's ``range()`` function which works with floats. Reference to this implementation: https://stackoverflow.com/a/36091634 :param start: start value :type start: float :param stop: end value :type stop: float :param step: incremen...
[ "def", "frange", "(", "start", ",", "stop", ",", "step", "=", "1.0", ")", ":", "i", "=", "0.0", "x", "=", "float", "(", "start", ")", "# Prevent yielding integers.", "x0", "=", "x", "epsilon", "=", "step", "/", "2.0", "yield", "x", "# always yield firs...
Implementation of Python's ``range()`` function which works with floats. Reference to this implementation: https://stackoverflow.com/a/36091634 :param start: start value :type start: float :param stop: end value :type stop: float :param step: increment :type step: float :return: float ...
[ "Implementation", "of", "Python", "s", "range", "()", "function", "which", "works", "with", "floats", "." ]
python
train
25.28
delph-in/pydelphin
delphin/itsdb.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L1298-L1311
def _prepare_source(selector, source): """Normalize source rows and selectors.""" tablename, fields = get_data_specifier(selector) if len(fields) != 1: raise ItsdbError( 'Selector must specify exactly one data column: {}' .format(selector) ) if isinstance(source, ...
[ "def", "_prepare_source", "(", "selector", ",", "source", ")", ":", "tablename", ",", "fields", "=", "get_data_specifier", "(", "selector", ")", "if", "len", "(", "fields", ")", "!=", "1", ":", "raise", "ItsdbError", "(", "'Selector must specify exactly one data...
Normalize source rows and selectors.
[ "Normalize", "source", "rows", "and", "selectors", "." ]
python
train
36.428571
edibledinos/pwnypack
pwnypack/target.py
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/target.py#L112-L122
def bits(self): """ The target architecture word size. One of :class:`Target.Bits`. """ if self._bits is None: value = self._DEFAULT_BITS.get(self.arch) if value is None: raise NotImplementedError('Could not determine the default word size of %s ar...
[ "def", "bits", "(", "self", ")", ":", "if", "self", ".", "_bits", "is", "None", ":", "value", "=", "self", ".", "_DEFAULT_BITS", ".", "get", "(", "self", ".", "arch", ")", "if", "value", "is", "None", ":", "raise", "NotImplementedError", "(", "'Could...
The target architecture word size. One of :class:`Target.Bits`.
[ "The", "target", "architecture", "word", "size", ".", "One", "of", ":", "class", ":", "Target", ".", "Bits", "." ]
python
train
36.727273
blockcypher/blockcypher-python
blockcypher/api.py
https://github.com/blockcypher/blockcypher-python/blob/7601ea21916957ff279384fd699527ff9c28a56e/blockcypher/api.py#L1143-L1171
def get_wallet_addresses(wallet_name, api_key, is_hd_wallet=False, zero_balance=None, used=None, omit_addresses=False, coin_symbol='btc'): ''' Returns a list of wallet addresses as well as some meta-data ''' assert is_valid_coin_symbol(coin_symbol) assert api_key assert len(wallet_name) ...
[ "def", "get_wallet_addresses", "(", "wallet_name", ",", "api_key", ",", "is_hd_wallet", "=", "False", ",", "zero_balance", "=", "None", ",", "used", "=", "None", ",", "omit_addresses", "=", "False", ",", "coin_symbol", "=", "'btc'", ")", ":", "assert", "is_v...
Returns a list of wallet addresses as well as some meta-data
[ "Returns", "a", "list", "of", "wallet", "addresses", "as", "well", "as", "some", "meta", "-", "data" ]
python
train
35.896552
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAUtil/QADate.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAUtil/QADate.py#L111-L124
def QA_util_datetime_to_strdatetime(dt): """ :param dt: pythone datetime.datetime :return: 1999-02-01 09:30:91 string type """ strdatetime = "%04d-%02d-%02d %02d:%02d:%02d" % ( dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second ) return...
[ "def", "QA_util_datetime_to_strdatetime", "(", "dt", ")", ":", "strdatetime", "=", "\"%04d-%02d-%02d %02d:%02d:%02d\"", "%", "(", "dt", ".", "year", ",", "dt", ".", "month", ",", "dt", ".", "day", ",", "dt", ".", "hour", ",", "dt", ".", "minute", ",", "d...
:param dt: pythone datetime.datetime :return: 1999-02-01 09:30:91 string type
[ ":", "param", "dt", ":", "pythone", "datetime", ".", "datetime", ":", "return", ":", "1999", "-", "02", "-", "01", "09", ":", "30", ":", "91", "string", "type" ]
python
train
22.785714
materialsproject/pymatgen-db
matgendb/creator.py
https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/creator.py#L513-L587
def generate_doc(self, dir_name, vasprun_files): """ Process aflow style runs, where each run is actually a combination of two vasp runs. """ try: fullpath = os.path.abspath(dir_name) # Defensively copy the additional fields first. This is a MUST. ...
[ "def", "generate_doc", "(", "self", ",", "dir_name", ",", "vasprun_files", ")", ":", "try", ":", "fullpath", "=", "os", ".", "path", ".", "abspath", "(", "dir_name", ")", "# Defensively copy the additional fields first. This is a MUST.", "# Otherwise, parallel updates ...
Process aflow style runs, where each run is actually a combination of two vasp runs.
[ "Process", "aflow", "style", "runs", "where", "each", "run", "is", "actually", "a", "combination", "of", "two", "vasp", "runs", "." ]
python
train
49.706667
cdgriffith/puremagic
puremagic/main.py
https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L105-L113
def _magic(header, footer, mime, ext=None): """ Discover what type of file it is based on the incoming string """ if not header: raise ValueError("Input was empty") info = _identify_all(header, footer, ext)[0] if mime: return info.mime_type return info.extension if not \ isin...
[ "def", "_magic", "(", "header", ",", "footer", ",", "mime", ",", "ext", "=", "None", ")", ":", "if", "not", "header", ":", "raise", "ValueError", "(", "\"Input was empty\"", ")", "info", "=", "_identify_all", "(", "header", ",", "footer", ",", "ext", "...
Discover what type of file it is based on the incoming string
[ "Discover", "what", "type", "of", "file", "it", "is", "based", "on", "the", "incoming", "string" ]
python
train
40.333333
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/extensions_v1beta1_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/extensions_v1beta1_api.py#L6383-L6407
def read_namespaced_replica_set(self, name, namespace, **kwargs): # noqa: E501 """read_namespaced_replica_set # noqa: E501 read the specified ReplicaSet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=T...
[ "def", "read_namespaced_replica_set", "(", "self", ",", "name", ",", "namespace", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "retur...
read_namespaced_replica_set # noqa: E501 read the specified ReplicaSet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.read_namespaced_replica_set(name, namespace, async_req=True) ...
[ "read_namespaced_replica_set", "#", "noqa", ":", "E501" ]
python
train
56.08
robotools/fontParts
Lib/fontParts/base/info.py
https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/info.py#L182-L188
def _round(self, **kwargs): """ Subclasses may override this method. """ mathInfo = self._toMathInfo(guidelines=False) mathInfo = mathInfo.round() self._fromMathInfo(mathInfo, guidelines=False)
[ "def", "_round", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mathInfo", "=", "self", ".", "_toMathInfo", "(", "guidelines", "=", "False", ")", "mathInfo", "=", "mathInfo", ".", "round", "(", ")", "self", ".", "_fromMathInfo", "(", "mathInfo", ",",...
Subclasses may override this method.
[ "Subclasses", "may", "override", "this", "method", "." ]
python
train
33.571429
SmartTeleMax/iktomi
iktomi/utils/url.py
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/url.py#L64-L77
def uri_to_iri_parts(path, query, fragment): r""" Converts a URI parts to corresponding IRI parts in a given charset. Examples for URI versus IRI: :param path: The path of URI to convert. :param query: The query string of URI to convert. :param fragment: The fragment of URI to convert. """...
[ "def", "uri_to_iri_parts", "(", "path", ",", "query", ",", "fragment", ")", ":", "path", "=", "url_unquote", "(", "path", ",", "'%/;?'", ")", "query", "=", "url_unquote", "(", "query", ",", "'%;/?:@&=+,$#'", ")", "fragment", "=", "url_unquote", "(", "fragm...
r""" Converts a URI parts to corresponding IRI parts in a given charset. Examples for URI versus IRI: :param path: The path of URI to convert. :param query: The query string of URI to convert. :param fragment: The fragment of URI to convert.
[ "r", "Converts", "a", "URI", "parts", "to", "corresponding", "IRI", "parts", "in", "a", "given", "charset", "." ]
python
train
34.071429
iotile/coretools
transport_plugins/native_ble/iotile_transport_native_ble/virtual_ble.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/native_ble/iotile_transport_native_ble/virtual_ble.py#L503-L512
def process(self): """Periodic nonblocking processes""" super(NativeBLEVirtualInterface, self).process() if (not self._stream_sm_running) and (not self.reports.empty()): self._stream_data() if (not self._trace_sm_running) and (not self.traces.empty()): self._se...
[ "def", "process", "(", "self", ")", ":", "super", "(", "NativeBLEVirtualInterface", ",", "self", ")", ".", "process", "(", ")", "if", "(", "not", "self", ".", "_stream_sm_running", ")", "and", "(", "not", "self", ".", "reports", ".", "empty", "(", ")",...
Periodic nonblocking processes
[ "Periodic", "nonblocking", "processes" ]
python
train
32.1
edx/edx-enterprise
enterprise/views.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/views.py#L384-L552
def get(self, request): """ Render a form to collect user input about data sharing consent. """ enterprise_customer_uuid = request.GET.get('enterprise_customer_uuid') success_url = request.GET.get('next') failure_url = request.GET.get('failure_url') course_id = re...
[ "def", "get", "(", "self", ",", "request", ")", ":", "enterprise_customer_uuid", "=", "request", ".", "GET", ".", "get", "(", "'enterprise_customer_uuid'", ")", "success_url", "=", "request", ".", "GET", ".", "get", "(", "'next'", ")", "failure_url", "=", ...
Render a form to collect user input about data sharing consent.
[ "Render", "a", "form", "to", "collect", "user", "input", "about", "data", "sharing", "consent", "." ]
python
valid
48.514793
quantopian/alphalens
alphalens/utils.py
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L865-L895
def timedelta_to_string(timedelta): """ Utility that converts a pandas.Timedelta to a string representation compatible with pandas.Timedelta constructor format Parameters ---------- timedelta: pd.Timedelta Returns ------- string string representation of 'timedelta' """ ...
[ "def", "timedelta_to_string", "(", "timedelta", ")", ":", "c", "=", "timedelta", ".", "components", "format", "=", "''", "if", "c", ".", "days", "!=", "0", ":", "format", "+=", "'%dD'", "%", "c", ".", "days", "if", "c", ".", "hours", ">", "0", ":",...
Utility that converts a pandas.Timedelta to a string representation compatible with pandas.Timedelta constructor format Parameters ---------- timedelta: pd.Timedelta Returns ------- string string representation of 'timedelta'
[ "Utility", "that", "converts", "a", "pandas", ".", "Timedelta", "to", "a", "string", "representation", "compatible", "with", "pandas", ".", "Timedelta", "constructor", "format" ]
python
train
25.16129
econ-ark/HARK
HARK/ConsumptionSaving/ConsIndShockModel.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsIndShockModel.py#L1320-L1380
def prepareToCalcEndOfPrdvP(self): ''' Prepare to calculate end-of-period marginal value by creating an array of market resources that the agent could have next period, considering the grid of end-of-period assets and the distribution of shocks he might experience next period. T...
[ "def", "prepareToCalcEndOfPrdvP", "(", "self", ")", ":", "KinkBool", "=", "self", ".", "Rboro", ">", "self", ".", "Rsave", "# Boolean indicating that there is actually a kink.", "# When Rboro == Rsave, this method acts just like it did in IndShock.", "# When Rboro < Rsave, the solv...
Prepare to calculate end-of-period marginal value by creating an array of market resources that the agent could have next period, considering the grid of end-of-period assets and the distribution of shocks he might experience next period. This differs from the baseline case because diff...
[ "Prepare", "to", "calculate", "end", "-", "of", "-", "period", "marginal", "value", "by", "creating", "an", "array", "of", "market", "resources", "that", "the", "agent", "could", "have", "next", "period", "considering", "the", "grid", "of", "end", "-", "of...
python
train
50.590164
TorkamaniLab/metapipe
metapipe/models/grammar.py
https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/grammar.py#L64-L70
def file(): """ Grammar for files found in the overall input files. """ return ( Optional(Word(alphanums).setResultsName('alias') + Suppress(Literal('.'))) + Suppress(White()) + Word(approved_printables).setResultsName('filename') )
[ "def", "file", "(", ")", ":", "return", "(", "Optional", "(", "Word", "(", "alphanums", ")", ".", "setResultsName", "(", "'alias'", ")", "+", "Suppress", "(", "Literal", "(", "'.'", ")", ")", ")", "+", "Suppress", "(", "White", "(", ")", ")", "+", ...
Grammar for files found in the overall input files.
[ "Grammar", "for", "files", "found", "in", "the", "overall", "input", "files", "." ]
python
train
42
delph-in/pydelphin
delphin/mrs/compare.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/compare.py#L225-L284
def _node_isomorphic(a, b, check_varprops=True): """ Two Xmrs objects are isomorphic if they have the same structure as determined by variable linkages between preds. """ # first some quick checks a_var_refs = sorted(len(vd['refs']) for vd in a._vars.values()) b_var_refs = sorted(len(vd['ref...
[ "def", "_node_isomorphic", "(", "a", ",", "b", ",", "check_varprops", "=", "True", ")", ":", "# first some quick checks", "a_var_refs", "=", "sorted", "(", "len", "(", "vd", "[", "'refs'", "]", ")", "for", "vd", "in", "a", ".", "_vars", ".", "values", ...
Two Xmrs objects are isomorphic if they have the same structure as determined by variable linkages between preds.
[ "Two", "Xmrs", "objects", "are", "isomorphic", "if", "they", "have", "the", "same", "structure", "as", "determined", "by", "variable", "linkages", "between", "preds", "." ]
python
train
36.35
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L584-L613
def draw_markers(self, data, coordinates, style, label, mplobj=None): """ Draw a set of markers. By default, this is done by repeatedly calling draw_path(), but renderers should generally overload this method to provide a more efficient implementation. In matplotlib, markers are...
[ "def", "draw_markers", "(", "self", ",", "data", ",", "coordinates", ",", "style", ",", "label", ",", "mplobj", "=", "None", ")", ":", "vertices", ",", "pathcodes", "=", "style", "[", "'markerpath'", "]", "pathstyle", "=", "dict", "(", "(", "key", ",",...
Draw a set of markers. By default, this is done by repeatedly calling draw_path(), but renderers should generally overload this method to provide a more efficient implementation. In matplotlib, markers are created using the plt.plot() command. Parameters ---------- data...
[ "Draw", "a", "set", "of", "markers", ".", "By", "default", "this", "is", "done", "by", "repeatedly", "calling", "draw_path", "()", "but", "renderers", "should", "generally", "overload", "this", "method", "to", "provide", "a", "more", "efficient", "implementati...
python
train
47.1
floyernick/fleep-py
fleep/__init__.py
https://github.com/floyernick/fleep-py/blob/994bc2c274482d80ab13d89d8f7343eb316d3e44/fleep/__init__.py#L50-L82
def get(obj): """ Determines file format and picks suitable file types, extensions and MIME types Takes: obj (bytes) -> byte sequence (128 bytes are enough) Returns: (<class 'fleep.Info'>) -> Class instance """ if not isinstance(obj, bytes): raise TypeError("object typ...
[ "def", "get", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "bytes", ")", ":", "raise", "TypeError", "(", "\"object type must be bytes\"", ")", "info", "=", "{", "\"type\"", ":", "dict", "(", ")", ",", "\"extension\"", ":", "dict", ...
Determines file format and picks suitable file types, extensions and MIME types Takes: obj (bytes) -> byte sequence (128 bytes are enough) Returns: (<class 'fleep.Info'>) -> Class instance
[ "Determines", "file", "format", "and", "picks", "suitable", "file", "types", "extensions", "and", "MIME", "types" ]
python
train
30.151515
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/386asm.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/386asm.py#L42-L52
def generate(env): """Add Builders and construction variables for ar to an Environment.""" as_module.generate(env) env['AS'] = '386asm' env['ASFLAGS'] = SCons.Util.CLVar('') env['ASPPFLAGS'] = '$ASFLAGS' env['ASCOM'] = '$AS $ASFLAGS $SOURCES -o $TARGET' env['ASPPCOM'] = '$CC ...
[ "def", "generate", "(", "env", ")", ":", "as_module", ".", "generate", "(", "env", ")", "env", "[", "'AS'", "]", "=", "'386asm'", "env", "[", "'ASFLAGS'", "]", "=", "SCons", ".", "Util", ".", "CLVar", "(", "''", ")", "env", "[", "'ASPPFLAGS'", "]",...
Add Builders and construction variables for ar to an Environment.
[ "Add", "Builders", "and", "construction", "variables", "for", "ar", "to", "an", "Environment", "." ]
python
train
36.818182
eagleamon/pynetio
pynetio.py
https://github.com/eagleamon/pynetio/blob/3bc212cae18608de0214b964e395877d3ca4aa7b/pynetio.py#L46-L49
def update(self): """ Update all the switch values """ self.states = [bool(int(x)) for x in self.get('port list') or '0000']
[ "def", "update", "(", "self", ")", ":", "self", ".", "states", "=", "[", "bool", "(", "int", "(", "x", ")", ")", "for", "x", "in", "self", ".", "get", "(", "'port list'", ")", "or", "'0000'", "]" ]
Update all the switch values
[ "Update", "all", "the", "switch", "values" ]
python
train
34.5
h2non/filetype.py
filetype/filetype.py
https://github.com/h2non/filetype.py/blob/37e7fd1a9eed1a9eab55ac43f62da98f10970675/filetype/filetype.py#L67-L82
def get_type(mime=None, ext=None): """ Returns the file type instance searching by MIME type or file extension. Args: ext: file extension string. E.g: jpg, png, mp4, mp3 mime: MIME string. E.g: image/jpeg, video/mpeg Returns: The matched file type instance. Otherwise None. ...
[ "def", "get_type", "(", "mime", "=", "None", ",", "ext", "=", "None", ")", ":", "for", "kind", "in", "types", ":", "if", "kind", ".", "extension", "is", "ext", "or", "kind", ".", "mime", "is", "mime", ":", "return", "kind", "return", "None" ]
Returns the file type instance searching by MIME type or file extension. Args: ext: file extension string. E.g: jpg, png, mp4, mp3 mime: MIME string. E.g: image/jpeg, video/mpeg Returns: The matched file type instance. Otherwise None.
[ "Returns", "the", "file", "type", "instance", "searching", "by", "MIME", "type", "or", "file", "extension", "." ]
python
train
26.875
DLR-RM/RAFCON
source/rafcon/gui/models/selection.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/selection.py#L206-L229
def handle_prepared_selection_of_core_class_elements(self, core_class, models): """Handles the selection for TreeStore widgets maintaining lists of a specific `core_class` elements If widgets hold a TreeStore with elements of a specific `core_class`, the local selection of that element type is ...
[ "def", "handle_prepared_selection_of_core_class_elements", "(", "self", ",", "core_class", ",", "models", ")", ":", "if", "extend_selection", "(", ")", ":", "self", ".", "_selected", ".", "difference_update", "(", "self", ".", "get_selected_elements_of_core_class", "(...
Handles the selection for TreeStore widgets maintaining lists of a specific `core_class` elements If widgets hold a TreeStore with elements of a specific `core_class`, the local selection of that element type is handled by that widget. This method is called to integrate the local selection with the ove...
[ "Handles", "the", "selection", "for", "TreeStore", "widgets", "maintaining", "lists", "of", "a", "specific", "core_class", "elements" ]
python
train
54.541667
potash/drain
drain/aggregation.py
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregation.py#L121-L151
def select(self, df, args, inplace=False): """ After joining, selects a subset of arguments df: the result of a call to self.join(left) args: a collcetion of arguments to select, as accepted by drain.util.list_expand: - a tuple corresponding to concat_args, e....
[ "def", "select", "(", "self", ",", "df", ",", "args", ",", "inplace", "=", "False", ")", ":", "if", "self", ".", "prefix", "is", "None", ":", "raise", "ValueError", "(", "'Cannot do selection on an Aggregation without a prefix'", ")", "# run list_expand and ensure...
After joining, selects a subset of arguments df: the result of a call to self.join(left) args: a collcetion of arguments to select, as accepted by drain.util.list_expand: - a tuple corresponding to concat_args, e.g. [('District', '12h'), ('Distict', '24h')] - a di...
[ "After", "joining", "selects", "a", "subset", "of", "arguments", "df", ":", "the", "result", "of", "a", "call", "to", "self", ".", "join", "(", "left", ")", "args", ":", "a", "collcetion", "of", "arguments", "to", "select", "as", "accepted", "by", "dra...
python
train
41.096774
anti1869/sunhead
src/sunhead/events/transports/amqp.py
https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/events/transports/amqp.py#L87-L119
async def connect(self): """ Create new asynchronous connection to the RabbitMQ instance. This will connect, declare exchange and bind itself to the configured queue. After that, client is ready to publish or consume messages. :return: Does not return anything. """ ...
[ "async", "def", "connect", "(", "self", ")", ":", "if", "self", ".", "connected", "or", "self", ".", "is_connecting", ":", "return", "self", ".", "_is_connecting", "=", "True", "try", ":", "logger", ".", "info", "(", "\"Connecting to RabbitMQ...\"", ")", "...
Create new asynchronous connection to the RabbitMQ instance. This will connect, declare exchange and bind itself to the configured queue. After that, client is ready to publish or consume messages. :return: Does not return anything.
[ "Create", "new", "asynchronous", "connection", "to", "the", "RabbitMQ", "instance", ".", "This", "will", "connect", "declare", "exchange", "and", "bind", "itself", "to", "the", "configured", "queue", "." ]
python
train
40
insanum/gcalcli
gcalcli/validators.py
https://github.com/insanum/gcalcli/blob/428378a88f89d154c8d4046deb9bdb5eb4e81019/gcalcli/validators.py#L31-L45
def color_validator(input_str): """ A filter allowing only the particular colors used by the Google Calendar API Raises ValidationError otherwise. """ try: assert input_str in VALID_OVERRIDE_COLORS + [''] return input_str except AssertionError: raise ValidationError(...
[ "def", "color_validator", "(", "input_str", ")", ":", "try", ":", "assert", "input_str", "in", "VALID_OVERRIDE_COLORS", "+", "[", "''", "]", "return", "input_str", "except", "AssertionError", ":", "raise", "ValidationError", "(", "'Expected colors are: '", "+", "'...
A filter allowing only the particular colors used by the Google Calendar API Raises ValidationError otherwise.
[ "A", "filter", "allowing", "only", "the", "particular", "colors", "used", "by", "the", "Google", "Calendar", "API" ]
python
train
30.533333
czepluch/pysecp256k1
c_secp256k1/__init__.py
https://github.com/czepluch/pysecp256k1/blob/164cb305857c5ba7a26adb6bd85459c5ea32ddd1/c_secp256k1/__init__.py#L236-L266
def ecdsa_recover_compact(msg32, sig): """ Takes the a message and a parsed recoverable signature Returns the serialized public key from the private key in the sign function """ assert isinstance(msg32, bytes) assert len(msg32) == 32 _check_signature(sig) # Check that recid is of...
[ "def", "ecdsa_recover_compact", "(", "msg32", ",", "sig", ")", ":", "assert", "isinstance", "(", "msg32", ",", "bytes", ")", "assert", "len", "(", "msg32", ")", "==", "32", "_check_signature", "(", "sig", ")", "# Check that recid is of valid value", "recid", "...
Takes the a message and a parsed recoverable signature Returns the serialized public key from the private key in the sign function
[ "Takes", "the", "a", "message", "and", "a", "parsed", "recoverable", "signature", "Returns", "the", "serialized", "public", "key", "from", "the", "private", "key", "in", "the", "sign", "function" ]
python
train
25.83871
greenbone/ospd
ospd/ospd.py
https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L1040-L1055
def elements_as_text(self, elems, indent=2): """ Returns the elems dictionary as formatted plain text. """ assert elems text = "" for elename, eledesc in elems.items(): if isinstance(eledesc, dict): desc_txt = self.elements_as_text(eledesc, indent + 2) ...
[ "def", "elements_as_text", "(", "self", ",", "elems", ",", "indent", "=", "2", ")", ":", "assert", "elems", "text", "=", "\"\"", "for", "elename", ",", "eledesc", "in", "elems", ".", "items", "(", ")", ":", "if", "isinstance", "(", "eledesc", ",", "d...
Returns the elems dictionary as formatted plain text.
[ "Returns", "the", "elems", "dictionary", "as", "formatted", "plain", "text", "." ]
python
train
44.75
juju/charm-helpers
charmhelpers/contrib/charmsupport/nrpe.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/charmsupport/nrpe.py#L341-L352
def get_nagios_unit_name(relation_name='nrpe-external-master'): """ Return the nagios unit name prepended with host_context if needed :param str relation_name: Name of relation nrpe sub joined to """ host_context = get_nagios_hostcontext(relation_name) if host_context: unit = "%s:%s" % ...
[ "def", "get_nagios_unit_name", "(", "relation_name", "=", "'nrpe-external-master'", ")", ":", "host_context", "=", "get_nagios_hostcontext", "(", "relation_name", ")", "if", "host_context", ":", "unit", "=", "\"%s:%s\"", "%", "(", "host_context", ",", "local_unit", ...
Return the nagios unit name prepended with host_context if needed :param str relation_name: Name of relation nrpe sub joined to
[ "Return", "the", "nagios", "unit", "name", "prepended", "with", "host_context", "if", "needed" ]
python
train
32.583333
jingw/pyhdfs
pyhdfs.py
https://github.com/jingw/pyhdfs/blob/b382b34f7cb28b41559f5be73102beb1732cd933/pyhdfs.py#L568-L576
def set_permission(self, path, **kwargs): """Set permission of a path. :param permission: The permission of a file/directory. Any radix-8 integer (leading zeros may be omitted.) :type permission: octal """ response = self._put(path, 'SETPERMISSION', **kwargs) ...
[ "def", "set_permission", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_put", "(", "path", ",", "'SETPERMISSION'", ",", "*", "*", "kwargs", ")", "assert", "not", "response", ".", "content" ]
Set permission of a path. :param permission: The permission of a file/directory. Any radix-8 integer (leading zeros may be omitted.) :type permission: octal
[ "Set", "permission", "of", "a", "path", "." ]
python
train
37.777778
tcalmant/ipopo
pelix/ipopo/handlers/requires.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requires.py#L492-L500
def clear(self): """ Cleans up the manager. The manager can't be used after this method has been called """ self.services.clear() self.services = None self._future_value = None super(AggregateDependency, self).clear()
[ "def", "clear", "(", "self", ")", ":", "self", ".", "services", ".", "clear", "(", ")", "self", ".", "services", "=", "None", "self", ".", "_future_value", "=", "None", "super", "(", "AggregateDependency", ",", "self", ")", ".", "clear", "(", ")" ]
Cleans up the manager. The manager can't be used after this method has been called
[ "Cleans", "up", "the", "manager", ".", "The", "manager", "can", "t", "be", "used", "after", "this", "method", "has", "been", "called" ]
python
train
30.333333
lobocv/crashreporter
crashreporter/crashreporter.py
https://github.com/lobocv/crashreporter/blob/a5bbb3f37977dc64bc865dfedafc365fd5469ef8/crashreporter/crashreporter.py#L328-L352
def delete_offline_reports(self): """ Delete all stored offline reports :return: List of reports that still require submission """ reports = self.get_offline_reports() remaining_reports = reports[:] for report in reports: with open(report, 'r') as _f: ...
[ "def", "delete_offline_reports", "(", "self", ")", ":", "reports", "=", "self", ".", "get_offline_reports", "(", ")", "remaining_reports", "=", "reports", "[", ":", "]", "for", "report", "in", "reports", ":", "with", "open", "(", "report", ",", "'r'", ")",...
Delete all stored offline reports :return: List of reports that still require submission
[ "Delete", "all", "stored", "offline", "reports", ":", "return", ":", "List", "of", "reports", "that", "still", "require", "submission" ]
python
train
43.8
UpCloudLtd/upcloud-python-api
upcloud_api/cloud_manager/server_mixin.py
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/server_mixin.py#L80-L127
def create_server(self, server): """ Create a server and its storages based on a (locally created) Server object. Populates the given Server instance with the API response. 0.3.0: also supports giving the entire POST body as a dict that is directly serialised into JSON. Refer t...
[ "def", "create_server", "(", "self", ",", "server", ")", ":", "if", "isinstance", "(", "server", ",", "Server", ")", ":", "body", "=", "server", ".", "prepare_post_body", "(", ")", "else", ":", "server", "=", "Server", ".", "_create_server_obj", "(", "se...
Create a server and its storages based on a (locally created) Server object. Populates the given Server instance with the API response. 0.3.0: also supports giving the entire POST body as a dict that is directly serialised into JSON. Refer to the REST API documentation for correct format. ...
[ "Create", "a", "server", "and", "its", "storages", "based", "on", "a", "(", "locally", "created", ")", "Server", "object", "." ]
python
train
35.916667
Azure/azure-cosmos-python
azure/cosmos/range.py
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/range.py#L57-L68
def Contains(self, other): """Checks if the passed parameter is in the range of this object. """ if other is None: raise ValueError("other is None.") if isinstance(other, Range): if other.low >= self.low and other.high <= self.high: return True ...
[ "def", "Contains", "(", "self", ",", "other", ")", ":", "if", "other", "is", "None", ":", "raise", "ValueError", "(", "\"other is None.\"", ")", "if", "isinstance", "(", "other", ",", "Range", ")", ":", "if", "other", ".", "low", ">=", "self", ".", "...
Checks if the passed parameter is in the range of this object.
[ "Checks", "if", "the", "passed", "parameter", "is", "in", "the", "range", "of", "this", "object", "." ]
python
train
33.25
juju/python-libjuju
juju/client/_client1.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client1.py#L548-L561
async def Restore(self, backup_id): ''' backup_id : str Returns -> None ''' # map input types to rpc msg _params = dict() msg = dict(type='Backups', request='Restore', version=1, params=_params) _par...
[ "async", "def", "Restore", "(", "self", ",", "backup_id", ")", ":", "# map input types to rpc msg", "_params", "=", "dict", "(", ")", "msg", "=", "dict", "(", "type", "=", "'Backups'", ",", "request", "=", "'Restore'", ",", "version", "=", "1", ",", "par...
backup_id : str Returns -> None
[ "backup_id", ":", "str", "Returns", "-", ">", "None" ]
python
train
28
SmileyChris/easy-thumbnails
easy_thumbnails/templatetags/thumbnail.py
https://github.com/SmileyChris/easy-thumbnails/blob/b08ab44883bf7b221a98dadb9b589cb95d35b0bf/easy_thumbnails/templatetags/thumbnail.py#L287-L302
def thumbnail_url(source, alias): """ Return the thumbnail url for a source file using an aliased set of thumbnail options. If no matching alias is found, returns an empty string. Example usage:: <img src="{{ person.photo|thumbnail_url:'small' }}" alt=""> """ try: thumb = ...
[ "def", "thumbnail_url", "(", "source", ",", "alias", ")", ":", "try", ":", "thumb", "=", "get_thumbnailer", "(", "source", ")", "[", "alias", "]", "except", "Exception", ":", "return", "''", "return", "thumb", ".", "url" ]
Return the thumbnail url for a source file using an aliased set of thumbnail options. If no matching alias is found, returns an empty string. Example usage:: <img src="{{ person.photo|thumbnail_url:'small' }}" alt="">
[ "Return", "the", "thumbnail", "url", "for", "a", "source", "file", "using", "an", "aliased", "set", "of", "thumbnail", "options", "." ]
python
train
24.75
limix/limix-core
limix_core/mean/linear.py
https://github.com/limix/limix-core/blob/5c590b4d351409f83ca320844b4897ce92203814/limix_core/mean/linear.py#L567-L572
def getParams(self): """ get params """ rv = np.array([]) if self.n_terms>0: rv = np.concatenate([np.reshape(self.B[term_i],self.B[term_i].size, order='F') for term_i in range(self.n_terms)]) return rv
[ "def", "getParams", "(", "self", ")", ":", "rv", "=", "np", ".", "array", "(", "[", "]", ")", "if", "self", ".", "n_terms", ">", "0", ":", "rv", "=", "np", ".", "concatenate", "(", "[", "np", ".", "reshape", "(", "self", ".", "B", "[", "term_...
get params
[ "get", "params" ]
python
train
40
polyaxon/polyaxon
polyaxon/scheduler/spawners/templates/volumes.py
https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/scheduler/spawners/templates/volumes.py#L128-L144
def get_shm_volumes(): """ Mount an tmpfs volume to /dev/shm. This will set /dev/shm size to half of the RAM of node. By default, /dev/shm is very small, only 64MB. Some experiments will fail due to lack of share memory, such as some experiments running on Pytorch. """ volumes, volume_mo...
[ "def", "get_shm_volumes", "(", ")", ":", "volumes", ",", "volume_mounts", "=", "[", "]", ",", "[", "]", "shm_volume", "=", "client", ".", "V1Volume", "(", "name", "=", "constants", ".", "SHM_VOLUME", ",", "empty_dir", "=", "client", ".", "V1EmptyDirVolumeS...
Mount an tmpfs volume to /dev/shm. This will set /dev/shm size to half of the RAM of node. By default, /dev/shm is very small, only 64MB. Some experiments will fail due to lack of share memory, such as some experiments running on Pytorch.
[ "Mount", "an", "tmpfs", "volume", "to", "/", "dev", "/", "shm", ".", "This", "will", "set", "/", "dev", "/", "shm", "size", "to", "half", "of", "the", "RAM", "of", "node", ".", "By", "default", "/", "dev", "/", "shm", "is", "very", "small", "only...
python
train
38.470588
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L240-L253
def char(self): """ Read one character from the stream or queue if available. Return EOF when EOF is reached. """ # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF ...
[ "def", "char", "(", "self", ")", ":", "# Read a new chunk from the input stream if necessary", "if", "self", ".", "chunkOffset", ">=", "self", ".", "chunkSize", ":", "if", "not", "self", ".", "readChunk", "(", ")", ":", "return", "EOF", "chunkOffset", "=", "se...
Read one character from the stream or queue if available. Return EOF when EOF is reached.
[ "Read", "one", "character", "from", "the", "stream", "or", "queue", "if", "available", ".", "Return", "EOF", "when", "EOF", "is", "reached", "." ]
python
train
31.714286
praekelt/django-export
export/fields.py
https://github.com/praekelt/django-export/blob/e2facdd53c9cbfa84d1409c7f0efe5d638812946/export/fields.py#L506-L556
def to_python(self, value): """ Validates that the input can be converted to a time. Returns a Python datetime.time object. """ if value in validators.EMPTY_VALUES: return None if isinstance(value, datetime.datetime): return value.time() if...
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "in", "validators", ".", "EMPTY_VALUES", ":", "return", "None", "if", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "return", "value", ".", "time", "(", "...
Validates that the input can be converted to a time. Returns a Python datetime.time object.
[ "Validates", "that", "the", "input", "can", "be", "converted", "to", "a", "time", ".", "Returns", "a", "Python", "datetime", ".", "time", "object", "." ]
python
train
34.823529
APSL/transmanager
transmanager/manager.py
https://github.com/APSL/transmanager/blob/79157085840008e146b264521681913090197ed1/transmanager/manager.py#L257-L288
def get_languages(self, include_main=False): """ Get all the languages except the main. Try to get in order: 1.- item languages 2.- model languages 3.- application model languages # 4.- default languages :param master: :param incl...
[ "def", "get_languages", "(", "self", ",", "include_main", "=", "False", ")", ":", "if", "not", "self", ".", "master", ":", "raise", "Exception", "(", "'TransManager - No master set'", ")", "item_languages", "=", "self", ".", "get_languages_from_item", "(", "self...
Get all the languages except the main. Try to get in order: 1.- item languages 2.- model languages 3.- application model languages # 4.- default languages :param master: :param include_main: :return:
[ "Get", "all", "the", "languages", "except", "the", "main", "." ]
python
train
32.1875
JamesRamm/longclaw
longclaw/contrib/productrequests/api.py
https://github.com/JamesRamm/longclaw/blob/8bbf2e6d703271b815ec111813c7c5d1d4e4e810/longclaw/contrib/productrequests/api.py#L35-L40
def requests_for_variant(self, request, variant_id=None): """Get all the requests for a single variant """ requests = ProductRequest.objects.filter(variant__id=variant_id) serializer = self.serializer_class(requests, many=True) return Response(data=serializer.data, status=status....
[ "def", "requests_for_variant", "(", "self", ",", "request", ",", "variant_id", "=", "None", ")", ":", "requests", "=", "ProductRequest", ".", "objects", ".", "filter", "(", "variant__id", "=", "variant_id", ")", "serializer", "=", "self", ".", "serializer_clas...
Get all the requests for a single variant
[ "Get", "all", "the", "requests", "for", "a", "single", "variant" ]
python
train
54.5
Spinmob/spinmob
_pylab_colormap.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L488-L494
def _slider_changed(self, n): """ updates the colormap / plot """ self._button_save.setEnabled(True) self.modify_colorpoint(n, self._sliders[n].value()*0.001, self._colorpoint_list[n][1], self._colorpoint_list[n][2])
[ "def", "_slider_changed", "(", "self", ",", "n", ")", ":", "self", ".", "_button_save", ".", "setEnabled", "(", "True", ")", "self", ".", "modify_colorpoint", "(", "n", ",", "self", ".", "_sliders", "[", "n", "]", ".", "value", "(", ")", "*", "0.001"...
updates the colormap / plot
[ "updates", "the", "colormap", "/", "plot" ]
python
train
35.857143
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/cursor.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/cursor.py#L823-L848
def where(self, code): """Adds a $where clause to this query. The `code` argument must be an instance of :class:`basestring` (:class:`str` in python 3) or :class:`~bson.code.Code` containing a JavaScript expression. This expression will be evaluated for each document scanned. On...
[ "def", "where", "(", "self", ",", "code", ")", ":", "self", ".", "__check_okay_to_chain", "(", ")", "if", "not", "isinstance", "(", "code", ",", "Code", ")", ":", "code", "=", "Code", "(", "code", ")", "self", ".", "__spec", "[", "\"$where\"", "]", ...
Adds a $where clause to this query. The `code` argument must be an instance of :class:`basestring` (:class:`str` in python 3) or :class:`~bson.code.Code` containing a JavaScript expression. This expression will be evaluated for each document scanned. Only those documents for whi...
[ "Adds", "a", "$where", "clause", "to", "this", "query", "." ]
python
train
40.730769
cuihantao/andes
andes/utils/tab.py
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/tab.py#L65-L70
def add_left_space(self, nspace=1): """elem_add n cols of spaces before the first col. (for texttable 0.8.3)""" sp = ' ' * nspace for item in self._rows: item[0] = sp + item[0]
[ "def", "add_left_space", "(", "self", ",", "nspace", "=", "1", ")", ":", "sp", "=", "' '", "*", "nspace", "for", "item", "in", "self", ".", "_rows", ":", "item", "[", "0", "]", "=", "sp", "+", "item", "[", "0", "]" ]
elem_add n cols of spaces before the first col. (for texttable 0.8.3)
[ "elem_add", "n", "cols", "of", "spaces", "before", "the", "first", "col", ".", "(", "for", "texttable", "0", ".", "8", ".", "3", ")" ]
python
train
36.333333
minhhoit/yacms
yacms/generic/views.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/views.py#L26-L43
def admin_keywords_submit(request): """ Adds any new given keywords from the custom keywords field in the admin, and returns their IDs for use when saving a model with a keywords field. """ keyword_ids, titles = [], [] remove = punctuation.replace("-", "") # Strip punctuation, allow dashes....
[ "def", "admin_keywords_submit", "(", "request", ")", ":", "keyword_ids", ",", "titles", "=", "[", "]", ",", "[", "]", "remove", "=", "punctuation", ".", "replace", "(", "\"-\"", ",", "\"\"", ")", "# Strip punctuation, allow dashes.", "for", "title", "in", "r...
Adds any new given keywords from the custom keywords field in the admin, and returns their IDs for use when saving a model with a keywords field.
[ "Adds", "any", "new", "given", "keywords", "from", "the", "custom", "keywords", "field", "in", "the", "admin", "and", "returns", "their", "IDs", "for", "use", "when", "saving", "a", "model", "with", "a", "keywords", "field", "." ]
python
train
45.222222
tanghaibao/jcvi
jcvi/assembly/postprocess.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/postprocess.py#L87-L99
def fasta2bed(fastafile): """ Alternative BED generation from FASTA file. Used for sanity check. """ dustfasta = fastafile.rsplit(".", 1)[0] + ".dust.fasta" for name, seq in parse_fasta(dustfasta): for islower, ss in groupby(enumerate(seq), key=lambda x: x[-1].islower()): if not ...
[ "def", "fasta2bed", "(", "fastafile", ")", ":", "dustfasta", "=", "fastafile", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "0", "]", "+", "\".dust.fasta\"", "for", "name", ",", "seq", "in", "parse_fasta", "(", "dustfasta", ")", ":", "for", "islowe...
Alternative BED generation from FASTA file. Used for sanity check.
[ "Alternative", "BED", "generation", "from", "FASTA", "file", ".", "Used", "for", "sanity", "check", "." ]
python
train
37.384615
facebookresearch/fastText
python/fastText/FastText.py
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L163-L174
def get_words(self, include_freq=False, on_unicode_error='strict'): """ Get the entire list of words of the dictionary optionally including the frequency of the individual words. This does not include any subwords. For that please consult the function get_subwords. """ ...
[ "def", "get_words", "(", "self", ",", "include_freq", "=", "False", ",", "on_unicode_error", "=", "'strict'", ")", ":", "pair", "=", "self", ".", "f", ".", "getVocab", "(", "on_unicode_error", ")", "if", "include_freq", ":", "return", "(", "pair", "[", "...
Get the entire list of words of the dictionary optionally including the frequency of the individual words. This does not include any subwords. For that please consult the function get_subwords.
[ "Get", "the", "entire", "list", "of", "words", "of", "the", "dictionary", "optionally", "including", "the", "frequency", "of", "the", "individual", "words", ".", "This", "does", "not", "include", "any", "subwords", ".", "For", "that", "please", "consult", "t...
python
train
39.083333
pricingassistant/mongokat
mongokat/document.py
https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/document.py#L125-L146
def reload(self): """ allow to refresh the document, so after using update(), it could reload its value from the database. Be carreful : reload() will erase all unsaved values. If no _id is set in the document, a KeyError is raised. """ old_doc = self.mongokat...
[ "def", "reload", "(", "self", ")", ":", "old_doc", "=", "self", ".", "mongokat_collection", ".", "find_one", "(", "{", "\"_id\"", ":", "self", "[", "'_id'", "]", "}", ",", "read_use", "=", "\"primary\"", ")", "if", "not", "old_doc", ":", "raise", "Oper...
allow to refresh the document, so after using update(), it could reload its value from the database. Be carreful : reload() will erase all unsaved values. If no _id is set in the document, a KeyError is raised.
[ "allow", "to", "refresh", "the", "document", "so", "after", "using", "update", "()", "it", "could", "reload", "its", "value", "from", "the", "database", "." ]
python
train
34.272727
YosaiProject/yosai
yosai/core/subject/subject.py
https://github.com/YosaiProject/yosai/blob/7f96aa6b837ceae9bf3d7387cd7e35f5ab032575/yosai/core/subject/subject.py#L495-L507
def run_as(self, identifiers): """ :type identifiers: subject_abcs.IdentifierCollection """ if (not self.has_identifiers): msg = ("This subject does not yet have an identity. Assuming the " "identity of another Subject is only allowed for Subjects " ...
[ "def", "run_as", "(", "self", ",", "identifiers", ")", ":", "if", "(", "not", "self", ".", "has_identifiers", ")", ":", "msg", "=", "(", "\"This subject does not yet have an identity. Assuming the \"", "\"identity of another Subject is only allowed for Subjects \"", "\"wit...
:type identifiers: subject_abcs.IdentifierCollection
[ ":", "type", "identifiers", ":", "subject_abcs", ".", "IdentifierCollection" ]
python
train
48.461538
kobejohn/PQHelper
pqhelper/base.py
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L160-L179
def _board_from_game_image(self, game_image): """Return a board object matching the board in the game image. Return None if any tiles are not identified. """ # board image board_rect = self._board_tools['board_region'].region_in(game_image) t, l, b, r = board_rect ...
[ "def", "_board_from_game_image", "(", "self", ",", "game_image", ")", ":", "# board image", "board_rect", "=", "self", ".", "_board_tools", "[", "'board_region'", "]", ".", "region_in", "(", "game_image", ")", "t", ",", "l", ",", "b", ",", "r", "=", "board...
Return a board object matching the board in the game image. Return None if any tiles are not identified.
[ "Return", "a", "board", "object", "matching", "the", "board", "in", "the", "game", "image", ".", "Return", "None", "if", "any", "tiles", "are", "not", "identified", "." ]
python
train
43
notsorandomname/pytb
py-modules/cpython.py
https://github.com/notsorandomname/pytb/blob/8f3544b6b72917f6b9b493a3a06025f88671aff7/py-modules/cpython.py#L745-L759
def get_all_objects(self): "Return pointers to all GC tracked objects" for i, generation in enumerate(self.gc_generations): generation_head_ptr = pygc_head_ptr = generation.head.get_pointer() generation_head_addr = generation_head_ptr._value while True: ...
[ "def", "get_all_objects", "(", "self", ")", ":", "for", "i", ",", "generation", "in", "enumerate", "(", "self", ".", "gc_generations", ")", ":", "generation_head_ptr", "=", "pygc_head_ptr", "=", "generation", ".", "head", ".", "get_pointer", "(", ")", "gener...
Return pointers to all GC tracked objects
[ "Return", "pointers", "to", "all", "GC", "tracked", "objects" ]
python
train
51.466667
anttttti/Wordbatch
wordbatch/feature_union.py
https://github.com/anttttti/Wordbatch/blob/ef57b5c1d87d9c82fb096598125c2511f9819e4d/wordbatch/feature_union.py#L139-L171
def fit_transform(self, X, y=None, **fit_params): """Fit all transformers, transform the data and concatenate results. Parameters ---------- X : iterable or array-like, depending on transformers Input data to be transformed. y : array-like, shape (n_samples, ...), o...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "*", "*", "fit_params", ")", ":", "self", ".", "_validate_transformers", "(", ")", "with", "Pool", "(", "self", ".", "n_jobs", ")", "as", "pool", ":", "result", "=", "pool", ...
Fit all transformers, transform the data and concatenate results. Parameters ---------- X : iterable or array-like, depending on transformers Input data to be transformed. y : array-like, shape (n_samples, ...), optional Targets for supervised learning. ...
[ "Fit", "all", "transformers", "transform", "the", "data", "and", "concatenate", "results", "." ]
python
train
39.636364
sassoo/goldman
goldman/resources/models.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/resources/models.py#L20-L39
def on_get(resc, req, resp): """ Get the models identified by query parameters We return an empty list if no models are found. """ signals.pre_req.send(resc.model) signals.pre_req_search.send(resc.model) models = goldman.sess.store.search(resc.rtype, **{ 'filters': req.filters, ...
[ "def", "on_get", "(", "resc", ",", "req", ",", "resp", ")", ":", "signals", ".", "pre_req", ".", "send", "(", "resc", ".", "model", ")", "signals", ".", "pre_req_search", ".", "send", "(", "resc", ".", "model", ")", "models", "=", "goldman", ".", "...
Get the models identified by query parameters We return an empty list if no models are found.
[ "Get", "the", "models", "identified", "by", "query", "parameters" ]
python
train
26.3
Azure/azure-cosmos-table-python
azure-cosmosdb-table/samples/table/table_usage.py
https://github.com/Azure/azure-cosmos-table-python/blob/a7b618f6bddc465c9fdf899ea2971dfe4d04fcf0/azure-cosmosdb-table/samples/table/table_usage.py#L203-L225
def create_entity_class(self): ''' Creates a class-based entity with fixed values, using all of the supported data types. ''' entity = Entity() # Partition key and row key must be strings and are required entity.PartitionKey = 'pk{}'.format(str(uuid.uuid4()).replace('-',...
[ "def", "create_entity_class", "(", "self", ")", ":", "entity", "=", "Entity", "(", ")", "# Partition key and row key must be strings and are required", "entity", ".", "PartitionKey", "=", "'pk{}'", ".", "format", "(", "str", "(", "uuid", ".", "uuid4", "(", ")", ...
Creates a class-based entity with fixed values, using all of the supported data types.
[ "Creates", "a", "class", "-", "based", "entity", "with", "fixed", "values", "using", "all", "of", "the", "supported", "data", "types", "." ]
python
train
43.913043
dtmilano/AndroidViewClient
src/com/dtmilano/android/viewclient.py
https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/viewclient.py#L920-L967
def touch(self, eventType=adbclient.DOWN_AND_UP, deltaX=0, deltaY=0): ''' Touches the center of this C{View}. The touch can be displaced from the center by using C{deltaX} and C{deltaY} values. @param eventType: The event type @type eventType: L{adbclient.DOWN}, L{adbclient.UP} ...
[ "def", "touch", "(", "self", ",", "eventType", "=", "adbclient", ".", "DOWN_AND_UP", ",", "deltaX", "=", "0", ",", "deltaY", "=", "0", ")", ":", "(", "x", ",", "y", ")", "=", "self", ".", "getCenter", "(", ")", "if", "deltaX", ":", "x", "+=", "...
Touches the center of this C{View}. The touch can be displaced from the center by using C{deltaX} and C{deltaY} values. @param eventType: The event type @type eventType: L{adbclient.DOWN}, L{adbclient.UP} or L{adbclient.DOWN_AND_UP} @param deltaX: Displacement from center (X axis) ...
[ "Touches", "the", "center", "of", "this", "C", "{", "View", "}", ".", "The", "touch", "can", "be", "displaced", "from", "the", "center", "by", "using", "C", "{", "deltaX", "}", "and", "C", "{", "deltaY", "}", "values", "." ]
python
train
47.0625
fuzeman/PyUPnP
pyupnp/lict.py
https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/lict.py#L52-L72
def _get_object_key(self, p_object): """Get key from object""" matched_key = None matched_index = None if hasattr(p_object, self._searchNames[0]): return getattr(p_object, self._searchNames[0]) for x in xrange(len(self._searchNames)): key = self._searchN...
[ "def", "_get_object_key", "(", "self", ",", "p_object", ")", ":", "matched_key", "=", "None", "matched_index", "=", "None", "if", "hasattr", "(", "p_object", ",", "self", ".", "_searchNames", "[", "0", "]", ")", ":", "return", "getattr", "(", "p_object", ...
Get key from object
[ "Get", "key", "from", "object" ]
python
train
31.333333
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L213-L224
def get_python(cls): """ returns the python and pip version :return: python version, pip version """ python_version = sys.version_info[:3] v_string = [str(i) for i in python_version] python_version_s = '.'.join(v_string) # pip_version = pip.__version__ ...
[ "def", "get_python", "(", "cls", ")", ":", "python_version", "=", "sys", ".", "version_info", "[", ":", "3", "]", "v_string", "=", "[", "str", "(", "i", ")", "for", "i", "in", "python_version", "]", "python_version_s", "=", "'.'", ".", "join", "(", "...
returns the python and pip version :return: python version, pip version
[ "returns", "the", "python", "and", "pip", "version", ":", "return", ":", "python", "version", "pip", "version" ]
python
train
33.916667
PythonCharmers/python-future
src/future/backports/http/client.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/http/client.py#L852-L900
def send(self, data): """Send `data' to the server. ``data`` can be a string object, a bytes object, an array object, a file-like object that supports a .read() method, or an iterable object. """ if self.sock is None: if self.auto_open: self.connect()...
[ "def", "send", "(", "self", ",", "data", ")", ":", "if", "self", ".", "sock", "is", "None", ":", "if", "self", ".", "auto_open", ":", "self", ".", "connect", "(", ")", "else", ":", "raise", "NotConnected", "(", ")", "if", "self", ".", "debuglevel",...
Send `data' to the server. ``data`` can be a string object, a bytes object, an array object, a file-like object that supports a .read() method, or an iterable object.
[ "Send", "data", "to", "the", "server", ".", "data", "can", "be", "a", "string", "object", "a", "bytes", "object", "an", "array", "object", "a", "file", "-", "like", "object", "that", "supports", "a", ".", "read", "()", "method", "or", "an", "iterable",...
python
train
36.22449
pypa/pipenv
pipenv/vendor/urllib3/util/timeout.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/timeout.py#L196-L211
def connect_timeout(self): """ Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None ...
[ "def", "connect_timeout", "(", "self", ")", ":", "if", "self", ".", "total", "is", "None", ":", "return", "self", ".", "_connect", "if", "self", ".", "_connect", "is", "None", "or", "self", ".", "_connect", "is", "self", ".", "DEFAULT_TIMEOUT", ":", "r...
Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
[ "Get", "the", "value", "to", "use", "when", "setting", "a", "connection", "timeout", "." ]
python
train
33.3125
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L224-L248
def _flatten_location_translations(location_translations): """If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency ...
[ "def", "_flatten_location_translations", "(", "location_translations", ")", ":", "sources_to_process", "=", "set", "(", "six", ".", "iterkeys", "(", "location_translations", ")", ")", "def", "_update_translation", "(", "source", ")", ":", "\"\"\"Return the proper (fully...
If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency and simplicity of implementation.
[ "If", "location", "A", "translates", "to", "B", "and", "B", "to", "C", "then", "make", "A", "translate", "directly", "to", "C", "." ]
python
train
47.88
quantmind/pulsar
pulsar/async/monitor.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/async/monitor.py#L73-L87
def spawn(self, monitor, kind=None, **params): '''Spawn a new :class:`Actor` and return its :class:`.ActorProxyMonitor`. ''' proxy = _spawn_actor(kind, monitor, **params) # Add to the list of managed actors if this is a remote actor if isinstance(proxy, Actor): ...
[ "def", "spawn", "(", "self", ",", "monitor", ",", "kind", "=", "None", ",", "*", "*", "params", ")", ":", "proxy", "=", "_spawn_actor", "(", "kind", ",", "monitor", ",", "*", "*", "params", ")", "# Add to the list of managed actors if this is a remote actor", ...
Spawn a new :class:`Actor` and return its :class:`.ActorProxyMonitor`.
[ "Spawn", "a", "new", ":", "class", ":", "Actor", "and", "return", "its", ":", "class", ":", ".", "ActorProxyMonitor", "." ]
python
train
36.933333
google/grr
grr/client/grr_response_client/client_actions/standard.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/standard.py#L167-L179
def Run(self, args): """Lists a directory.""" try: directory = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress) except (IOError, OSError) as e: self.SetStatus(rdf_flows.GrrStatus.ReturnedStatus.IOERROR, e) return files = list(directory.ListFiles()) files.sort(key=lambda...
[ "def", "Run", "(", "self", ",", "args", ")", ":", "try", ":", "directory", "=", "vfs", ".", "VFSOpen", "(", "args", ".", "pathspec", ",", "progress_callback", "=", "self", ".", "Progress", ")", "except", "(", "IOError", ",", "OSError", ")", "as", "e"...
Lists a directory.
[ "Lists", "a", "directory", "." ]
python
train
29.769231
dgketchum/satellite_image
sat_image/image.py
https://github.com/dgketchum/satellite_image/blob/0207fbb7b2bbf14f4307db65489bb4d4c5b92f52/sat_image/image.py#L329-L336
def ndvi(self): """ Normalized difference vegetation index. :return: NDVI """ red, nir = self.reflectance(3), self.reflectance(4) ndvi = self._divide_zero((nir - red), (nir + red), nan) return ndvi
[ "def", "ndvi", "(", "self", ")", ":", "red", ",", "nir", "=", "self", ".", "reflectance", "(", "3", ")", ",", "self", ".", "reflectance", "(", "4", ")", "ndvi", "=", "self", ".", "_divide_zero", "(", "(", "nir", "-", "red", ")", ",", "(", "nir"...
Normalized difference vegetation index. :return: NDVI
[ "Normalized", "difference", "vegetation", "index", ".", ":", "return", ":", "NDVI" ]
python
train
29.875
viswa-swami/python-foscam
libpyfoscam/foscam.py
https://github.com/viswa-swami/python-foscam/blob/d76f2f7016959b7b758751637fad103c9032e488/libpyfoscam/foscam.py#L286-L292
def set_sub_stream_format(self, format, callback=None): ''' Set the stream fromat of sub stream???? ''' params = {'format': format} return self.execute_command('setSubStreamFormat', params, callback=callback)
[ "def", "set_sub_stream_format", "(", "self", ",", "format", ",", "callback", "=", "None", ")", ":", "params", "=", "{", "'format'", ":", "format", "}", "return", "self", ".", "execute_command", "(", "'setSubStreamFormat'", ",", "params", ",", "callback", "="...
Set the stream fromat of sub stream????
[ "Set", "the", "stream", "fromat", "of", "sub", "stream????" ]
python
train
40.285714
mikekatz04/BOWIE
snr_calculator_folder/gwsnrcalc/genconutils/forminput.py
https://github.com/mikekatz04/BOWIE/blob/a941342a3536cb57c817a1643896d99a3f354a86/snr_calculator_folder/gwsnrcalc/genconutils/forminput.py#L345-L365
def set_generation_type(self, num_processors=-1, num_splits=1000, verbose=-1): """Change generation type. Choose weather to generate the data in parallel or on a single processor. Args: num_processors (int or None, optional): Number of parallel processors to use. If...
[ "def", "set_generation_type", "(", "self", ",", "num_processors", "=", "-", "1", ",", "num_splits", "=", "1000", ",", "verbose", "=", "-", "1", ")", ":", "self", ".", "parallel_input", ".", "num_processors", "=", "num_processors", "self", ".", "parallel_inpu...
Change generation type. Choose weather to generate the data in parallel or on a single processor. Args: num_processors (int or None, optional): Number of parallel processors to use. If ``num_processors==-1``, this will use multiprocessing module and use avai...
[ "Change", "generation", "type", "." ]
python
train
50.904762
OpenMath/py-openmath
openmath/convert_pickle.py
https://github.com/OpenMath/py-openmath/blob/4906aa9ccf606f533675c28823772e07c30fd220/openmath/convert_pickle.py#L167-L178
def OMSymbol(self, module, name): r""" Helper function to build an OMS object EXAMPLES:: >>> from openmath.convert_pickle import PickleConverter >>> converter = PickleConverter() >>> o = converter.OMSymbol(module="foo.bar", name="baz"); o ...
[ "def", "OMSymbol", "(", "self", ",", "module", ",", "name", ")", ":", "return", "om", ".", "OMSymbol", "(", "cdbase", "=", "self", ".", "_cdbase", ",", "cd", "=", "module", ",", "name", "=", "name", ")" ]
r""" Helper function to build an OMS object EXAMPLES:: >>> from openmath.convert_pickle import PickleConverter >>> converter = PickleConverter() >>> o = converter.OMSymbol(module="foo.bar", name="baz"); o OMSymbol(name='baz', cd='foo.bar', id=Non...
[ "r", "Helper", "function", "to", "build", "an", "OMS", "object", "EXAMPLES", "::" ]
python
test
38.666667
exosite-labs/pyonep
pyonep/onep.py
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/onep.py#L438-L449
def recordbatch(self, auth, resource, entries, defer=False): """ Records a list of historical entries to the resource specified. Calls a function that bulids a request that writes a list of historical entries to the specified resource. Args: auth: Takes the device cik ...
[ "def", "recordbatch", "(", "self", ",", "auth", ",", "resource", ",", "entries", ",", "defer", "=", "False", ")", ":", "return", "self", ".", "_call", "(", "'recordbatch'", ",", "auth", ",", "[", "resource", ",", "entries", "]", ",", "defer", ")" ]
Records a list of historical entries to the resource specified. Calls a function that bulids a request that writes a list of historical entries to the specified resource. Args: auth: Takes the device cik resource: Takes the dataport alias or rid. entries: A ...
[ "Records", "a", "list", "of", "historical", "entries", "to", "the", "resource", "specified", "." ]
python
train
42.5
B2W-BIT/aiologger
aiologger/formatters/json.py
https://github.com/B2W-BIT/aiologger/blob/0b366597a8305d5577a267305e81d5e4784cd398/aiologger/formatters/json.py#L44-L59
def format(self, record: logging.LogRecord) -> str: """ Formats a record and serializes it as a JSON str. If record message isnt already a dict, initializes a new dict and uses `default_msg_fieldname` as a key as the record msg as the value. """ msg: Union[str, dict] = re...
[ "def", "format", "(", "self", ",", "record", ":", "logging", ".", "LogRecord", ")", "->", "str", ":", "msg", ":", "Union", "[", "str", ",", "dict", "]", "=", "record", ".", "msg", "if", "not", "isinstance", "(", "record", ".", "msg", ",", "dict", ...
Formats a record and serializes it as a JSON str. If record message isnt already a dict, initializes a new dict and uses `default_msg_fieldname` as a key as the record msg as the value.
[ "Formats", "a", "record", "and", "serializes", "it", "as", "a", "JSON", "str", ".", "If", "record", "message", "isnt", "already", "a", "dict", "initializes", "a", "new", "dict", "and", "uses", "default_msg_fieldname", "as", "a", "key", "as", "the", "record...
python
train
42.1875
saltstack/salt
salt/runners/vault.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/vault.py#L262-L269
def _get_token_create_url(config): ''' Create Vault url for token creation ''' role_name = config.get('role_name', None) auth_path = '/v1/auth/token/create' base_url = config['url'] return '/'.join(x.strip('/') for x in (base_url, auth_path, role_name) if x)
[ "def", "_get_token_create_url", "(", "config", ")", ":", "role_name", "=", "config", ".", "get", "(", "'role_name'", ",", "None", ")", "auth_path", "=", "'/v1/auth/token/create'", "base_url", "=", "config", "[", "'url'", "]", "return", "'/'", ".", "join", "(...
Create Vault url for token creation
[ "Create", "Vault", "url", "for", "token", "creation" ]
python
train
34.875
stevearc/dql
bin/install.py
https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/bin/install.py#L39-L55
def main(): """ Build a standalone dql executable """ venv_dir = tempfile.mkdtemp() try: make_virtualenv(venv_dir) print("Downloading dependencies") pip = os.path.join(venv_dir, "bin", "pip") subprocess.check_call([pip, "install", "pex"]) print("Building executable"...
[ "def", "main", "(", ")", ":", "venv_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "try", ":", "make_virtualenv", "(", "venv_dir", ")", "print", "(", "\"Downloading dependencies\"", ")", "pip", "=", "os", ".", "path", ".", "join", "(", "venv_dir", ",",...
Build a standalone dql executable
[ "Build", "a", "standalone", "dql", "executable" ]
python
train
32.235294
pandas-dev/pandas
doc/make.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/doc/make.py#L256-L262
def clean(): """ Clean documentation generated files. """ shutil.rmtree(BUILD_PATH, ignore_errors=True) shutil.rmtree(os.path.join(SOURCE_PATH, 'reference', 'api'), ignore_errors=True)
[ "def", "clean", "(", ")", ":", "shutil", ".", "rmtree", "(", "BUILD_PATH", ",", "ignore_errors", "=", "True", ")", "shutil", ".", "rmtree", "(", "os", ".", "path", ".", "join", "(", "SOURCE_PATH", ",", "'reference'", ",", "'api'", ")", ",", "ignore_err...
Clean documentation generated files.
[ "Clean", "documentation", "generated", "files", "." ]
python
train
34.285714
cloud9ers/gurumate
environment/lib/python2.7/site-packages/nose/suite.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/nose/suite.py#L196-L232
def run(self, result): """Run tests in suite inside of suite fixtures. """ # proxy the result for myself log.debug("suite %s (%s) run called, tests: %s", id(self), self, self._tests) #import pdb #pdb.set_trace() if self.resultProxy: result, orig = self...
[ "def", "run", "(", "self", ",", "result", ")", ":", "# proxy the result for myself", "log", ".", "debug", "(", "\"suite %s (%s) run called, tests: %s\"", ",", "id", "(", "self", ")", ",", "self", ",", "self", ".", "_tests", ")", "#import pdb", "#pdb.set_trace()"...
Run tests in suite inside of suite fixtures.
[ "Run", "tests", "in", "suite", "inside", "of", "suite", "fixtures", "." ]
python
test
33.108108
dcramer/logan
logan/runner.py
https://github.com/dcramer/logan/blob/8b18456802d631a822e2823bf9a4e9810a15a20e/logan/runner.py#L63-L141
def configure_app(config_path=None, project=None, default_config_path=None, default_settings=None, settings_initializer=None, settings_envvar=None, initializer=None, allow_extras=True, config_module_name=None, runner_name=None, on_configure=None): """ :param...
[ "def", "configure_app", "(", "config_path", "=", "None", ",", "project", "=", "None", ",", "default_config_path", "=", "None", ",", "default_settings", "=", "None", ",", "settings_initializer", "=", "None", ",", "settings_envvar", "=", "None", ",", "initializer"...
:param project: should represent the canonical name for the project, generally the same name it assigned in distutils. :param default_config_path: the default location for the configuration file. :param default_settings: default settings to load (think inheritence). :param settings_initializer: a ca...
[ ":", "param", "project", ":", "should", "represent", "the", "canonical", "name", "for", "the", "project", "generally", "the", "same", "name", "it", "assigned", "in", "distutils", ".", ":", "param", "default_config_path", ":", "the", "default", "location", "for...
python
train
37.025316
yunojuno/elasticsearch-django
elasticsearch_django/models.py
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L308-L342
def as_search_action(self, *, index, action): """ Return an object as represented in a bulk api operation. Bulk API operations have a very specific format. This function will call the standard `as_search_document` method on the object and then wrap that up in the correct format ...
[ "def", "as_search_action", "(", "self", ",", "*", ",", "index", ",", "action", ")", ":", "if", "action", "not", "in", "(", "\"index\"", ",", "\"update\"", ",", "\"delete\"", ")", ":", "raise", "ValueError", "(", "\"Action must be 'index', 'update' or 'delete'.\"...
Return an object as represented in a bulk api operation. Bulk API operations have a very specific format. This function will call the standard `as_search_document` method on the object and then wrap that up in the correct format for the action specified. https://www.elastic.co/guide/en...
[ "Return", "an", "object", "as", "represented", "in", "a", "bulk", "api", "operation", "." ]
python
train
37.085714
yyuu/botornado
boto/vpc/__init__.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/vpc/__init__.py#L489-L524
def get_all_subnets(self, subnet_ids=None, filters=None): """ Retrieve information about your Subnets. You can filter results to return information only about those Subnets that match your search parameters. Otherwise, all Subnets associated with your account are returned. ...
[ "def", "get_all_subnets", "(", "self", ",", "subnet_ids", "=", "None", ",", "filters", "=", "None", ")", ":", "params", "=", "{", "}", "if", "subnet_ids", ":", "self", ".", "build_list_params", "(", "params", ",", "subnet_ids", ",", "'SubnetId'", ")", "i...
Retrieve information about your Subnets. You can filter results to return information only about those Subnets that match your search parameters. Otherwise, all Subnets associated with your account are returned. :type subnet_ids: list :param subnet_ids: A list of strings with ...
[ "Retrieve", "information", "about", "your", "Subnets", ".", "You", "can", "filter", "results", "to", "return", "information", "only", "about", "those", "Subnets", "that", "match", "your", "search", "parameters", ".", "Otherwise", "all", "Subnets", "associated", ...
python
train
40.75
hapyak/flask-peewee-swagger
flask_peewee_swagger/swagger.py
https://github.com/hapyak/flask-peewee-swagger/blob/1b7dd54a5e823401b80e04ac421ee15c9fab3f06/flask_peewee_swagger/swagger.py#L181-L200
def get_listing_api(self, resource): """ Generates the meta descriptor for the resource listing api. """ get_all_params = self.get_listing_parameters(resource) get_all_api = { 'path': '/%s/' % resource.get_api_name(), 'description': 'Operations on %s' % resource.model._...
[ "def", "get_listing_api", "(", "self", ",", "resource", ")", ":", "get_all_params", "=", "self", ".", "get_listing_parameters", "(", "resource", ")", "get_all_api", "=", "{", "'path'", ":", "'/%s/'", "%", "resource", ".", "get_api_name", "(", ")", ",", "'des...
Generates the meta descriptor for the resource listing api.
[ "Generates", "the", "meta", "descriptor", "for", "the", "resource", "listing", "api", "." ]
python
train
33.75
google/grr
grr/server/grr_response_server/databases/mysql_flows.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_flows.py#L437-L498
def LeaseFlowForProcessing(self, client_id, flow_id, processing_time, cursor=None): """Marks a flow as being processed on this worker and returns it.""" query = ("SELECT " + self.FLOW_DB_FIELDS + ...
[ "def", "LeaseFlowForProcessing", "(", "self", ",", "client_id", ",", "flow_id", ",", "processing_time", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"SELECT \"", "+", "self", ".", "FLOW_DB_FIELDS", "+", "\"FROM flows WHERE client_id=%s AND flow_id=%s\"...
Marks a flow as being processed on this worker and returns it.
[ "Marks", "a", "flow", "as", "being", "processed", "on", "this", "worker", "and", "returns", "it", "." ]
python
train
39.758065
saltstack/salt
salt/modules/virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L170-L243
def __get_conn(**kwargs): ''' Detects what type of dom this node is and attempts to connect to the correct hypervisor via libvirt. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect w...
[ "def", "__get_conn", "(", "*", "*", "kwargs", ")", ":", "# This has only been tested on kvm and xen, it needs to be expanded to", "# support all vm layers supported by libvirt", "# Connection string works on bhyve, but auth is not tested.", "username", "=", "kwargs", ".", "get", "(",...
Detects what type of dom this node is and attempts to connect to the correct hypervisor via libvirt. :param connection: libvirt connection URI, overriding defaults :param username: username to connect with, overriding defaults :param password: password to connect with, overriding defaults
[ "Detects", "what", "type", "of", "dom", "this", "node", "is", "and", "attempts", "to", "connect", "to", "the", "correct", "hypervisor", "via", "libvirt", "." ]
python
train
41.689189
christophertbrown/bioscripts
ctbBio/cluster_ani.py
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/cluster_ani.py#L215-L235
def parse_checkM_tables(tables): """ convert checkM genome info tables to dictionary """ g2info = {} for table in tables: for line in open(table): line = line.strip().split('\t') if line[0].startswith('Bin Id'): header = line header[8] ...
[ "def", "parse_checkM_tables", "(", "tables", ")", ":", "g2info", "=", "{", "}", "for", "table", "in", "tables", ":", "for", "line", "in", "open", "(", "table", ")", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", ...
convert checkM genome info tables to dictionary
[ "convert", "checkM", "genome", "info", "tables", "to", "dictionary" ]
python
train
35.285714
dmwm/DBS
Server/Python/src/dbs/web/DBSWriterModel.py
https://github.com/dmwm/DBS/blob/9619bafce3783b3e77f0415f8f9a258e33dd1e6f/Server/Python/src/dbs/web/DBSWriterModel.py#L342-L400
def insertFile(self, qInserts=False): """ API to insert a list of file into DBS in DBS. Up to 10 files can be inserted in one request. :param qInserts: True means that inserts will be queued instead of done immediately. INSERT QUEUE Manager will perform the inserts, within few minutes. ...
[ "def", "insertFile", "(", "self", ",", "qInserts", "=", "False", ")", ":", "if", "qInserts", "in", "(", "False", ",", "'False'", ")", ":", "qInserts", "=", "False", "try", ":", "body", "=", "request", ".", "body", ".", "read", "(", ")", "indata", "...
API to insert a list of file into DBS in DBS. Up to 10 files can be inserted in one request. :param qInserts: True means that inserts will be queued instead of done immediately. INSERT QUEUE Manager will perform the inserts, within few minutes. :type qInserts: bool :param filesList: List of dic...
[ "API", "to", "insert", "a", "list", "of", "file", "into", "DBS", "in", "DBS", ".", "Up", "to", "10", "files", "can", "be", "inserted", "in", "one", "request", "." ]
python
train
60.372881
droope/droopescan
dscan/common/output.py
https://github.com/droope/droopescan/blob/424c48a0f9d12b4536dbef5a786f0fbd4ce9519a/dscan/common/output.py#L82-L107
def result(self, result, functionality): """ For the final result of the scan. @param result: as returned by BasePluginInternal.url_scan @param functionality: functionality as returned by BasePluginInternal._general_init """ for enumerate in result: ...
[ "def", "result", "(", "self", ",", "result", ",", "functionality", ")", ":", "for", "enumerate", "in", "result", ":", "# The host is a special header, we must not attempt to display it.", "if", "enumerate", "==", "\"host\"", "or", "enumerate", "==", "\"cms_name\"", ":...
For the final result of the scan. @param result: as returned by BasePluginInternal.url_scan @param functionality: functionality as returned by BasePluginInternal._general_init
[ "For", "the", "final", "result", "of", "the", "scan", "." ]
python
train
35.653846
ternaris/marv
marv/cli.py
https://github.com/ternaris/marv/blob/c221354d912ff869bbdb4f714a86a70be30d823e/marv/cli.py#L234-L244
def marvcli_undiscard(datasets): """Undiscard DATASETS previously discarded.""" create_app() setids = parse_setids(datasets, discarded=True) dataset = Dataset.__table__ stmt = dataset.update()\ .where(dataset.c.setid.in_(setids))\ .values(discarded=False) db....
[ "def", "marvcli_undiscard", "(", "datasets", ")", ":", "create_app", "(", ")", "setids", "=", "parse_setids", "(", "datasets", ",", "discarded", "=", "True", ")", "dataset", "=", "Dataset", ".", "__table__", "stmt", "=", "dataset", ".", "update", "(", ")",...
Undiscard DATASETS previously discarded.
[ "Undiscard", "DATASETS", "previously", "discarded", "." ]
python
train
32.272727
maweigert/gputools
gputools/transforms/scale.py
https://github.com/maweigert/gputools/blob/6ab26efeb05dceef74cf13aadeeeb9b009b529dd/gputools/transforms/scale.py#L23-L88
def scale(data, scale = (1.,1.,1.), interpolation = "linear"): """ returns a interpolated, scaled version of data the output shape is scaled too. Parameters ---------- data: ndarray 3d input array scale: float, tuple scaling factor along each axis (x,y,z) inter...
[ "def", "scale", "(", "data", ",", "scale", "=", "(", "1.", ",", "1.", ",", "1.", ")", ",", "interpolation", "=", "\"linear\"", ")", ":", "if", "not", "(", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", "and", "data", ".", "ndim", "=="...
returns a interpolated, scaled version of data the output shape is scaled too. Parameters ---------- data: ndarray 3d input array scale: float, tuple scaling factor along each axis (x,y,z) interpolation: str either "nearest" or "linear" Returns -------...
[ "returns", "a", "interpolated", "scaled", "version", "of", "data", "the", "output", "shape", "is", "scaled", "too", ".", "Parameters", "----------", "data", ":", "ndarray", "3d", "input", "array", "scale", ":", "float", "tuple", "scaling", "factor", "along", ...
python
train
28.439394
dturanski/springcloudstream
springcloudstream/component.py
https://github.com/dturanski/springcloudstream/blob/208b542f9eba82e97882d52703af8e965a62a980/springcloudstream/component.py#L47-L57
def get_message_handler(self, message_handlers): """ Create a MessageHandler for the configured Encoder :param message_handlers: a dictionart of MessageHandler keyed by encoder :return: a MessageHandler """ encoder = self.options.encoder try: return me...
[ "def", "get_message_handler", "(", "self", ",", "message_handlers", ")", ":", "encoder", "=", "self", ".", "options", ".", "encoder", "try", ":", "return", "message_handlers", "[", "encoder", "]", "except", "KeyError", ":", "raise", "NotImplementedError", "(", ...
Create a MessageHandler for the configured Encoder :param message_handlers: a dictionart of MessageHandler keyed by encoder :return: a MessageHandler
[ "Create", "a", "MessageHandler", "for", "the", "configured", "Encoder", ":", "param", "message_handlers", ":", "a", "dictionart", "of", "MessageHandler", "keyed", "by", "encoder", ":", "return", ":", "a", "MessageHandler" ]
python
train
41.727273
gem/oq-engine
openquake/risklib/scientific.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/risklib/scientific.py#L1369-L1378
def pair(self, array, stats): """ :return (array, array_stats) if stats, else (array, None) """ if len(self.weights) > 1 and stats: statnames, statfuncs = zip(*stats) array_stats = compute_stats2(array, statfuncs, self.weights) else: array_stat...
[ "def", "pair", "(", "self", ",", "array", ",", "stats", ")", ":", "if", "len", "(", "self", ".", "weights", ")", ">", "1", "and", "stats", ":", "statnames", ",", "statfuncs", "=", "zip", "(", "*", "stats", ")", "array_stats", "=", "compute_stats2", ...
:return (array, array_stats) if stats, else (array, None)
[ ":", "return", "(", "array", "array_stats", ")", "if", "stats", "else", "(", "array", "None", ")" ]
python
train
35.3
romanz/trezor-agent
libagent/util.py
https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/util.py#L201-L216
def memoize(func): """Simple caching decorator.""" cache = {} @functools.wraps(func) def wrapper(*args, **kwargs): """Caching wrapper.""" key = (args, tuple(sorted(kwargs.items()))) if key in cache: return cache[key] else: result = func(*args, **k...
[ "def", "memoize", "(", "func", ")", ":", "cache", "=", "{", "}", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Caching wrapper.\"\"\"", "key", "=", "(", "args", ",", ...
Simple caching decorator.
[ "Simple", "caching", "decorator", "." ]
python
train
24.3125