repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
mapnik/Cascadenik
cascadenik/compile.py
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L186-L206
def midpoint(self): """ Return a point guranteed to fall within this range, hopefully near the middle. """ minpoint = self.leftedge if self.leftop is gt: minpoint += 1 maxpoint = self.rightedge if self.rightop is lt: maxpoint -= 1 i...
[ "def", "midpoint", "(", "self", ")", ":", "minpoint", "=", "self", ".", "leftedge", "if", "self", ".", "leftop", "is", "gt", ":", "minpoint", "+=", "1", "maxpoint", "=", "self", ".", "rightedge", "if", "self", ".", "rightop", "is", "lt", ":", "maxpoi...
Return a point guranteed to fall within this range, hopefully near the middle.
[ "Return", "a", "point", "guranteed", "to", "fall", "within", "this", "range", "hopefully", "near", "the", "middle", "." ]
python
train
pyviz/holoviews
holoviews/core/element.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/element.py#L29-L61
def hist(self, dimension=None, num_bins=20, bin_range=None, adjoin=True, **kwargs): """Computes and adjoins histogram along specified dimension(s). Defaults to first value dimension if present otherwise falls back to first key dimension. Args: dimension: Dimens...
[ "def", "hist", "(", "self", ",", "dimension", "=", "None", ",", "num_bins", "=", "20", ",", "bin_range", "=", "None", ",", "adjoin", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "operation", "import", "histogram", "if", "not", ...
Computes and adjoins histogram along specified dimension(s). Defaults to first value dimension if present otherwise falls back to first key dimension. Args: dimension: Dimension(s) to compute histogram on num_bins (int, optional): Number of bins bin_range (t...
[ "Computes", "and", "adjoins", "histogram", "along", "specified", "dimension", "(", "s", ")", "." ]
python
train
zsimic/runez
src/runez/logsetup.py
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/logsetup.py#L418-L429
def _add_handler(cls, handler, fmt, level): """ Args: handler (logging.Handler): Handler to decorate fmt (str | unicode): Format to use """ handler.setFormatter(_get_formatter(fmt)) if level: handler.setLevel(level) logging.root.addHand...
[ "def", "_add_handler", "(", "cls", ",", "handler", ",", "fmt", ",", "level", ")", ":", "handler", ".", "setFormatter", "(", "_get_formatter", "(", "fmt", ")", ")", "if", "level", ":", "handler", ".", "setLevel", "(", "level", ")", "logging", ".", "root...
Args: handler (logging.Handler): Handler to decorate fmt (str | unicode): Format to use
[ "Args", ":", "handler", "(", "logging", ".", "Handler", ")", ":", "Handler", "to", "decorate", "fmt", "(", "str", "|", "unicode", ")", ":", "Format", "to", "use" ]
python
train
ghukill/pyfc4
pyfc4/models.py
https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L229-L266
def start_txn(self, txn_name=None): ''' Request new transaction from repository, init new Transaction, store in self.txns Args: txn_name (str): human name for transaction Return: (Transaction): returns intance of newly created transaction ''' # if no name provided, create one if not txn_name: ...
[ "def", "start_txn", "(", "self", ",", "txn_name", "=", "None", ")", ":", "# if no name provided, create one", "if", "not", "txn_name", ":", "txn_name", "=", "uuid", ".", "uuid4", "(", ")", ".", "hex", "# request new transaction", "txn_response", "=", "self", "...
Request new transaction from repository, init new Transaction, store in self.txns Args: txn_name (str): human name for transaction Return: (Transaction): returns intance of newly created transaction
[ "Request", "new", "transaction", "from", "repository", "init", "new", "Transaction", "store", "in", "self", ".", "txns" ]
python
train
gem/oq-engine
openquake/calculators/ucerf_event_based.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/ucerf_event_based.py#L41-L76
def generate_event_set(ucerf, background_sids, src_filter, ses_idx, seed): """ Generates the event set corresponding to a particular branch """ serial = seed + ses_idx * TWO16 # get rates from file with h5py.File(ucerf.source_file, 'r') as hdf5: occurrences = ucerf.tom.sample_number_of_o...
[ "def", "generate_event_set", "(", "ucerf", ",", "background_sids", ",", "src_filter", ",", "ses_idx", ",", "seed", ")", ":", "serial", "=", "seed", "+", "ses_idx", "*", "TWO16", "# get rates from file", "with", "h5py", ".", "File", "(", "ucerf", ".", "source...
Generates the event set corresponding to a particular branch
[ "Generates", "the", "event", "set", "corresponding", "to", "a", "particular", "branch" ]
python
train
scarface-4711/denonavr
denonavr/denonavr.py
https://github.com/scarface-4711/denonavr/blob/59a136e27b43cb1d1e140cf67705087b3aa377cd/denonavr/denonavr.py#L1611-L1622
def power_off(self): """Turn off receiver via HTTP get command.""" try: if self.send_get_command(self._urls.command_power_standby): self._power = POWER_STANDBY self._state = STATE_OFF return True else: return False ...
[ "def", "power_off", "(", "self", ")", ":", "try", ":", "if", "self", ".", "send_get_command", "(", "self", ".", "_urls", ".", "command_power_standby", ")", ":", "self", ".", "_power", "=", "POWER_STANDBY", "self", ".", "_state", "=", "STATE_OFF", "return",...
Turn off receiver via HTTP get command.
[ "Turn", "off", "receiver", "via", "HTTP", "get", "command", "." ]
python
train
shmir/PyIxExplorer
ixexplorer/ixe_port.py
https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_port.py#L344-L352
def set_phy_mode(self, mode=IxePhyMode.ignore): """ Set phy mode to copper or fiber. :param mode: requested PHY mode. """ if isinstance(mode, IxePhyMode): if mode.value: self.api.call_rc('port setPhyMode {} {}'.format(mode.value, self.uri)) else: ...
[ "def", "set_phy_mode", "(", "self", ",", "mode", "=", "IxePhyMode", ".", "ignore", ")", ":", "if", "isinstance", "(", "mode", ",", "IxePhyMode", ")", ":", "if", "mode", ".", "value", ":", "self", ".", "api", ".", "call_rc", "(", "'port setPhyMode {} {}'"...
Set phy mode to copper or fiber. :param mode: requested PHY mode.
[ "Set", "phy", "mode", "to", "copper", "or", "fiber", ".", ":", "param", "mode", ":", "requested", "PHY", "mode", "." ]
python
train
AbdealiJK/pycolorname
pycolorname/color_system.py
https://github.com/AbdealiJK/pycolorname/blob/d535de3d340a1673906cb484cc4c49c87d296ec0/pycolorname/color_system.py#L35-L70
def load(self, filename=None, refresh=False): """ Try to load the data from a pre existing data file if it exists. If the data file does not exist, refresh the data and save it in the data file for future use. The data file is a json file. :param filename: The filename t...
[ "def", "load", "(", "self", ",", "filename", "=", "None", ",", "refresh", "=", "False", ")", ":", "filename", "=", "filename", "or", "self", ".", "data_file", "(", ")", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "if", ...
Try to load the data from a pre existing data file if it exists. If the data file does not exist, refresh the data and save it in the data file for future use. The data file is a json file. :param filename: The filename to save or fetch the data from. :param refresh: Whether to...
[ "Try", "to", "load", "the", "data", "from", "a", "pre", "existing", "data", "file", "if", "it", "exists", ".", "If", "the", "data", "file", "does", "not", "exist", "refresh", "the", "data", "and", "save", "it", "in", "the", "data", "file", "for", "fu...
python
train
quantumlib/Cirq
cirq/ops/pauli_string_raw_types.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/pauli_string_raw_types.py#L42-L49
def map_qubits(self: TSelf_PauliStringGateOperation, qubit_map: Dict[raw_types.Qid, raw_types.Qid] ) -> TSelf_PauliStringGateOperation: """Return an equivalent operation on new qubits with its Pauli string mapped to new qubits. new_pauli_string = self.pauli_...
[ "def", "map_qubits", "(", "self", ":", "TSelf_PauliStringGateOperation", ",", "qubit_map", ":", "Dict", "[", "raw_types", ".", "Qid", ",", "raw_types", ".", "Qid", "]", ")", "->", "TSelf_PauliStringGateOperation", ":" ]
Return an equivalent operation on new qubits with its Pauli string mapped to new qubits. new_pauli_string = self.pauli_string.map_qubits(qubit_map)
[ "Return", "an", "equivalent", "operation", "on", "new", "qubits", "with", "its", "Pauli", "string", "mapped", "to", "new", "qubits", "." ]
python
train
jsommers/switchyard
switchyard/lib/socket/socketemu.py
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L314-L336
def bind(self, address): ''' Alter the local address with which this socket is associated. The address parameter is a 2-tuple consisting of an IP address and port number. NB: this method fails and returns -1 if the requested port to bind to is already in use but does *n...
[ "def", "bind", "(", "self", ",", "address", ")", ":", "portset", "=", "_gather_ports", "(", ")", ".", "union", "(", "ApplicationLayer", ".", "_emuports", "(", ")", ")", "if", "address", "[", "1", "]", "in", "portset", ":", "log_warn", "(", "\"Port is a...
Alter the local address with which this socket is associated. The address parameter is a 2-tuple consisting of an IP address and port number. NB: this method fails and returns -1 if the requested port to bind to is already in use but does *not* check that the address is valid.
[ "Alter", "the", "local", "address", "with", "which", "this", "socket", "is", "associated", ".", "The", "address", "parameter", "is", "a", "2", "-", "tuple", "consisting", "of", "an", "IP", "address", "and", "port", "number", "." ]
python
train
astropy/photutils
photutils/extern/sigma_clipping.py
https://github.com/astropy/photutils/blob/cc9bb4534ab76bac98cb5f374a348a2573d10401/photutils/extern/sigma_clipping.py#L315-L385
def _sigmaclip_withaxis(self, data, axis=None, masked=True, return_bounds=False, copy=True): """ Sigma clip the data when ``axis`` is specified. In this case, we replace clipped values with NaNs as placeholder values. """ # float array type i...
[ "def", "_sigmaclip_withaxis", "(", "self", ",", "data", ",", "axis", "=", "None", ",", "masked", "=", "True", ",", "return_bounds", "=", "False", ",", "copy", "=", "True", ")", ":", "# float array type is needed to insert nans into the array", "filtered_data", "="...
Sigma clip the data when ``axis`` is specified. In this case, we replace clipped values with NaNs as placeholder values.
[ "Sigma", "clip", "the", "data", "when", "axis", "is", "specified", "." ]
python
train
secdev/scapy
scapy/layers/ipsec.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L562-L598
def verify(self, pkt, key): """ Check that the integrity check value (icv) of a packet is valid. @param pkt: a packet that contains a valid encrypted ESP or AH layer @param key: the authentication key, a byte string @raise IPSecIntegrityError: if the integrity check fails...
[ "def", "verify", "(", "self", ",", "pkt", ",", "key", ")", ":", "if", "not", "self", ".", "mac", "or", "self", ".", "icv_size", "==", "0", ":", "return", "mac", "=", "self", ".", "new_mac", "(", "key", ")", "pkt_icv", "=", "'not found'", "computed_...
Check that the integrity check value (icv) of a packet is valid. @param pkt: a packet that contains a valid encrypted ESP or AH layer @param key: the authentication key, a byte string @raise IPSecIntegrityError: if the integrity check fails
[ "Check", "that", "the", "integrity", "check", "value", "(", "icv", ")", "of", "a", "packet", "is", "valid", "." ]
python
train
angr/angr
angr/engines/successors.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/engines/successors.py#L406-L493
def _eval_target_jumptable(state, ip, limit): """ A *very* fast method to evaluate symbolic jump targets if they are a) concrete targets, or b) targets coming from jump tables. :param state: A SimState instance. :param ip: The AST of the instruction pointer to evaluate. ...
[ "def", "_eval_target_jumptable", "(", "state", ",", "ip", ",", "limit", ")", ":", "if", "ip", ".", "symbolic", "is", "False", ":", "return", "[", "(", "claripy", ".", "ast", ".", "bool", ".", "true", ",", "ip", ")", "]", "# concrete", "# Detect whether...
A *very* fast method to evaluate symbolic jump targets if they are a) concrete targets, or b) targets coming from jump tables. :param state: A SimState instance. :param ip: The AST of the instruction pointer to evaluate. :param limit: The maximum number of concrete IPs. ...
[ "A", "*", "very", "*", "fast", "method", "to", "evaluate", "symbolic", "jump", "targets", "if", "they", "are", "a", ")", "concrete", "targets", "or", "b", ")", "targets", "coming", "from", "jump", "tables", "." ]
python
train
nickmckay/LiPD-utilities
Python/lipd/__init__.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L1026-L1040
def __disclaimer(opt=""): """ Print the disclaimers once. If they've already been shown, skip over. :return none: """ global settings if opt is "update": print("Disclaimer: LiPD files may be updated and modified to adhere to standards\n") settings["note_update"] = False if o...
[ "def", "__disclaimer", "(", "opt", "=", "\"\"", ")", ":", "global", "settings", "if", "opt", "is", "\"update\"", ":", "print", "(", "\"Disclaimer: LiPD files may be updated and modified to adhere to standards\\n\"", ")", "settings", "[", "\"note_update\"", "]", "=", "...
Print the disclaimers once. If they've already been shown, skip over. :return none:
[ "Print", "the", "disclaimers", "once", ".", "If", "they", "ve", "already", "been", "shown", "skip", "over", "." ]
python
train
gabstopper/smc-python
smc/elements/network.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/elements/network.py#L92-L107
def create(cls, name, ip_range, comment=None): """ Create an AddressRange element :param str name: Name of element :param str iprange: iprange of element :param str comment: comment (optional) :raises CreateElementFailed: element creation failed with reason :retu...
[ "def", "create", "(", "cls", ",", "name", ",", "ip_range", ",", "comment", "=", "None", ")", ":", "json", "=", "{", "'name'", ":", "name", ",", "'ip_range'", ":", "ip_range", ",", "'comment'", ":", "comment", "}", "return", "ElementCreator", "(", "cls"...
Create an AddressRange element :param str name: Name of element :param str iprange: iprange of element :param str comment: comment (optional) :raises CreateElementFailed: element creation failed with reason :return: instance with meta :rtype: AddressRange
[ "Create", "an", "AddressRange", "element" ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/pip/req/req_uninstall.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/req/req_uninstall.py#L90-L132
def remove(self, auto_confirm=False): """Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).""" if not self._can_uninstall(): return if not self.paths: logger.info( "Can't uninstall '%s'. No files were found to unins...
[ "def", "remove", "(", "self", ",", "auto_confirm", "=", "False", ")", ":", "if", "not", "self", ".", "_can_uninstall", "(", ")", ":", "return", "if", "not", "self", ".", "paths", ":", "logger", ".", "info", "(", "\"Can't uninstall '%s'. No files were found t...
Remove paths in ``self.paths`` with confirmation (unless ``auto_confirm`` is True).
[ "Remove", "paths", "in", "self", ".", "paths", "with", "confirmation", "(", "unless", "auto_confirm", "is", "True", ")", "." ]
python
test
teffland/pytorch-monitor
build/lib/pytorch_monitor/monitor.py
https://github.com/teffland/pytorch-monitor/blob/56dce63ba85c0f9faf9df11df78161ee60f5fae9/build/lib/pytorch_monitor/monitor.py#L46-L53
def remove_grad_hooks(module, input): """ Remove gradient hooks to all of the parameters and monitored vars """ for hook in list(module.param_hooks.keys()): module.param_hooks[hook].remove() module.param_hooks.pop(hook) for hook in list(module.var_hooks.keys()): module.var_hooks[hook...
[ "def", "remove_grad_hooks", "(", "module", ",", "input", ")", ":", "for", "hook", "in", "list", "(", "module", ".", "param_hooks", ".", "keys", "(", ")", ")", ":", "module", ".", "param_hooks", "[", "hook", "]", ".", "remove", "(", ")", "module", "."...
Remove gradient hooks to all of the parameters and monitored vars
[ "Remove", "gradient", "hooks", "to", "all", "of", "the", "parameters", "and", "monitored", "vars" ]
python
train
panosl/django-currencies
currencies/management/commands/_yahoofinance.py
https://github.com/panosl/django-currencies/blob/8d4c6c202ad7c4cc06263ab2c1b1f969bbe99acd/currencies/management/commands/_yahoofinance.py#L155-L171
def get_info(self, code): """Return a dict of information about the currency""" currency = self.get_currency(code) info = {} users = list(filter(None, currency['users'].split(','))) if users: info['Users'] = users alt = list(filter(None, currency['alternativ...
[ "def", "get_info", "(", "self", ",", "code", ")", ":", "currency", "=", "self", ".", "get_currency", "(", "code", ")", "info", "=", "{", "}", "users", "=", "list", "(", "filter", "(", "None", ",", "currency", "[", "'users'", "]", ".", "split", "(",...
Return a dict of information about the currency
[ "Return", "a", "dict", "of", "information", "about", "the", "currency" ]
python
train
hvac/hvac
hvac/api/secrets_engines/identity.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/identity.py#L585-L605
def read_group(self, group_id, mount_point=DEFAULT_MOUNT_POINT): """Query the group by its identifier. Supported methods: GET: /{mount_point}/group/id/{id}. Produces: 200 application/json :param group_id: Identifier of the group. :type group_id: str | unicode :param...
[ "def", "read_group", "(", "self", ",", "group_id", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ")", ":", "api_path", "=", "'/v1/{mount_point}/group/id/{id}'", ".", "format", "(", "mount_point", "=", "mount_point", ",", "id", "=", "group_id", ",", ")", "respo...
Query the group by its identifier. Supported methods: GET: /{mount_point}/group/id/{id}. Produces: 200 application/json :param group_id: Identifier of the group. :type group_id: str | unicode :param mount_point: The "path" the method/backend was mounted on. :type mo...
[ "Query", "the", "group", "by", "its", "identifier", "." ]
python
train
metagriffin/pysyncml
pysyncml/items/base.py
https://github.com/metagriffin/pysyncml/blob/a583fe0dbffa8b24e5a3e151524f84868b2382bb/pysyncml/items/base.py#L101-L108
def loads(cls, data, contentType=None, version=None): ''' [OPTIONAL] Identical to :meth:`load`, except the serialized form is provided as a string representation in `data` instead of as a stream. The default implementation just wraps :meth:`load`. ''' buf = six.StringIO(data) return cls.load...
[ "def", "loads", "(", "cls", ",", "data", ",", "contentType", "=", "None", ",", "version", "=", "None", ")", ":", "buf", "=", "six", ".", "StringIO", "(", "data", ")", "return", "cls", ".", "load", "(", "buf", ",", "contentType", ",", "version", ")"...
[OPTIONAL] Identical to :meth:`load`, except the serialized form is provided as a string representation in `data` instead of as a stream. The default implementation just wraps :meth:`load`.
[ "[", "OPTIONAL", "]", "Identical", "to", ":", "meth", ":", "load", "except", "the", "serialized", "form", "is", "provided", "as", "a", "string", "representation", "in", "data", "instead", "of", "as", "a", "stream", ".", "The", "default", "implementation", ...
python
valid
gitpython-developers/GitPython
git/repo/base.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/repo/base.py#L483-L486
def iter_trees(self, *args, **kwargs): """:return: Iterator yielding Tree objects :note: Takes all arguments known to iter_commits method""" return (c.tree for c in self.iter_commits(*args, **kwargs))
[ "def", "iter_trees", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "(", "c", ".", "tree", "for", "c", "in", "self", ".", "iter_commits", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
:return: Iterator yielding Tree objects :note: Takes all arguments known to iter_commits method
[ ":", "return", ":", "Iterator", "yielding", "Tree", "objects", ":", "note", ":", "Takes", "all", "arguments", "known", "to", "iter_commits", "method" ]
python
train
ailionx/cloudflare-ddns
cloudflare_ddns/cloudflare.py
https://github.com/ailionx/cloudflare-ddns/blob/e4808b8314e447f69fab77b5bd3880846e59adbe/cloudflare_ddns/cloudflare.py#L120-L134
def get_record(self, dns_type, name): """ Get a dns record :param dns_type: :param name: :return: """ try: record = [record for record in self.dns_records if record['type'] == dns_type and record['name'] == name][0] except...
[ "def", "get_record", "(", "self", ",", "dns_type", ",", "name", ")", ":", "try", ":", "record", "=", "[", "record", "for", "record", "in", "self", ".", "dns_records", "if", "record", "[", "'type'", "]", "==", "dns_type", "and", "record", "[", "'name'",...
Get a dns record :param dns_type: :param name: :return:
[ "Get", "a", "dns", "record", ":", "param", "dns_type", ":", ":", "param", "name", ":", ":", "return", ":" ]
python
train
axltxl/m2bk
m2bk/app.py
https://github.com/axltxl/m2bk/blob/980083dfd17e6e783753a946e9aa809714551141/m2bk/app.py#L187-L216
def main(argv=None): """ This is the main thread of execution :param argv: list of command line arguments """ # Exit code exit_code = 0 # First, we change main() to take an optional 'argv' # argument, which allows us to call it from the interactive # Python prompt if argv is No...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "# Exit code", "exit_code", "=", "0", "# First, we change main() to take an optional 'argv'", "# argument, which allows us to call it from the interactive", "# Python prompt", "if", "argv", "is", "None", ":", "argv", "=", ...
This is the main thread of execution :param argv: list of command line arguments
[ "This", "is", "the", "main", "thread", "of", "execution" ]
python
train
mk-fg/feedjack
feedjack/models.py
https://github.com/mk-fg/feedjack/blob/3fe65c0f66dc2cfdf45834aaa7235ec9f81b3ca3/feedjack/models.py#L654-L675
def similar(self, threshold, **criterias): '''Find text-based field matches with similarity (1-levenshtein/length) higher than specified threshold (0 to 1, 1 being an exact match)''' # XXX: use F from https://docs.djangoproject.com/en/1.8/ref/models/expressions/ meta = self.model._meta funcs, params = list()...
[ "def", "similar", "(", "self", ",", "threshold", ",", "*", "*", "criterias", ")", ":", "# XXX: use F from https://docs.djangoproject.com/en/1.8/ref/models/expressions/", "meta", "=", "self", ".", "model", ".", "_meta", "funcs", ",", "params", "=", "list", "(", ")"...
Find text-based field matches with similarity (1-levenshtein/length) higher than specified threshold (0 to 1, 1 being an exact match)
[ "Find", "text", "-", "based", "field", "matches", "with", "similarity", "(", "1", "-", "levenshtein", "/", "length", ")", "higher", "than", "specified", "threshold", "(", "0", "to", "1", "1", "being", "an", "exact", "match", ")" ]
python
train
SoftwareDefinedBuildings/XBOS
apps/Data_quality_analysis/Clean_Data.py
https://github.com/SoftwareDefinedBuildings/XBOS/blob/c12d4fb14518ea3ae98c471c28e0710fdf74dd25/apps/Data_quality_analysis/Clean_Data.py#L544-L563
def _find_outOfBound(self, data, lowBound, highBound): """ Mask for selecting data that is out of bounds. Parameters ---------- data : pd.DataFrame() Input dataframe. lowBound : float Lower bound for dataframe. highBound : flo...
[ "def", "_find_outOfBound", "(", "self", ",", "data", ",", "lowBound", ",", "highBound", ")", ":", "data", "=", "(", "(", "data", "<", "lowBound", ")", "|", "(", "data", ">", "highBound", ")", ")", "return", "data" ]
Mask for selecting data that is out of bounds. Parameters ---------- data : pd.DataFrame() Input dataframe. lowBound : float Lower bound for dataframe. highBound : float Higher bound for dataframe. Returns ...
[ "Mask", "for", "selecting", "data", "that", "is", "out", "of", "bounds", ".", "Parameters", "----------", "data", ":", "pd", ".", "DataFrame", "()", "Input", "dataframe", ".", "lowBound", ":", "float", "Lower", "bound", "for", "dataframe", ".", "highBound", ...
python
train
annoviko/pyclustering
pyclustering/nnet/dynamic_visualizer.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/dynamic_visualizer.py#L195-L210
def set_canvas_properties(self, canvas, x_title=None, y_title=None, x_lim=None, y_lim=None, x_labels=True, y_labels=True): """! @brief Set properties for specified canvas. @param[in] canvas (uint): Index of canvas whose properties should changed. @param[in] x_title (string): Title ...
[ "def", "set_canvas_properties", "(", "self", ",", "canvas", ",", "x_title", "=", "None", ",", "y_title", "=", "None", ",", "x_lim", "=", "None", ",", "y_lim", "=", "None", ",", "x_labels", "=", "True", ",", "y_labels", "=", "True", ")", ":", "self", ...
! @brief Set properties for specified canvas. @param[in] canvas (uint): Index of canvas whose properties should changed. @param[in] x_title (string): Title for X axis, if 'None', then nothing is displayed. @param[in] y_title (string): Title for Y axis, if 'None', then nothing is di...
[ "!" ]
python
valid
pandas-dev/pandas
pandas/io/formats/latex.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/formats/latex.py#L40-L163
def write_result(self, buf): """ Render a DataFrame to a LaTeX tabular/longtable environment output. """ # string representation of the columns if len(self.frame.columns) == 0 or len(self.frame.index) == 0: info_line = ('Empty {name}\nColumns: {col}\nIndex: {idx}' ...
[ "def", "write_result", "(", "self", ",", "buf", ")", ":", "# string representation of the columns", "if", "len", "(", "self", ".", "frame", ".", "columns", ")", "==", "0", "or", "len", "(", "self", ".", "frame", ".", "index", ")", "==", "0", ":", "info...
Render a DataFrame to a LaTeX tabular/longtable environment output.
[ "Render", "a", "DataFrame", "to", "a", "LaTeX", "tabular", "/", "longtable", "environment", "output", "." ]
python
train
CalebBell/thermo
thermo/volume.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/volume.py#L307-L372
def Bhirud_normal(T, Tc, Pc, omega): r'''Calculates saturation liquid density using the Bhirud [1]_ CSP method. Uses Critical temperature and pressure and acentric factor. The density of a liquid is given by: .. math:: &\ln \frac{P_c}{\rho RT} = \ln U^{(0)} + \omega\ln U^{(1)} &\ln U^...
[ "def", "Bhirud_normal", "(", "T", ",", "Tc", ",", "Pc", ",", "omega", ")", ":", "Tr", "=", "T", "/", "Tc", "if", "Tr", "<=", "0.98", ":", "lnU0", "=", "1.39644", "-", "24.076", "*", "Tr", "+", "102.615", "*", "Tr", "**", "2", "-", "255.719", ...
r'''Calculates saturation liquid density using the Bhirud [1]_ CSP method. Uses Critical temperature and pressure and acentric factor. The density of a liquid is given by: .. math:: &\ln \frac{P_c}{\rho RT} = \ln U^{(0)} + \omega\ln U^{(1)} &\ln U^{(0)} = 1.396 44 - 24.076T_r+ 102.615T_r^...
[ "r", "Calculates", "saturation", "liquid", "density", "using", "the", "Bhirud", "[", "1", "]", "_", "CSP", "method", ".", "Uses", "Critical", "temperature", "and", "pressure", "and", "acentric", "factor", "." ]
python
valid
RRZE-HPC/kerncraft
kerncraft/models/roofline.py
https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/models/roofline.py#L339-L386
def report(self, output_file=sys.stdout): """Print human readable report of model.""" cpu_perf = self.results['cpu bottleneck']['performance throughput'] if self.verbose >= 3: print('{}'.format(pformat(self.results)), file=output_file) if self.verbose >= 1: prin...
[ "def", "report", "(", "self", ",", "output_file", "=", "sys", ".", "stdout", ")", ":", "cpu_perf", "=", "self", ".", "results", "[", "'cpu bottleneck'", "]", "[", "'performance throughput'", "]", "if", "self", ".", "verbose", ">=", "3", ":", "print", "("...
Print human readable report of model.
[ "Print", "human", "readable", "report", "of", "model", "." ]
python
test
raiden-network/raiden
raiden/network/proxies/token_network.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L562-L597
def closing_address( self, participant1: Address, participant2: Address, block_identifier: BlockSpecification, channel_identifier: ChannelID = None, ) -> Optional[Address]: """ Returns the address of the closer, if the channel is closed and not set...
[ "def", "closing_address", "(", "self", ",", "participant1", ":", "Address", ",", "participant2", ":", "Address", ",", "block_identifier", ":", "BlockSpecification", ",", "channel_identifier", ":", "ChannelID", "=", "None", ",", ")", "->", "Optional", "[", "Addre...
Returns the address of the closer, if the channel is closed and not settled. None otherwise.
[ "Returns", "the", "address", "of", "the", "closer", "if", "the", "channel", "is", "closed", "and", "not", "settled", ".", "None", "otherwise", "." ]
python
train
saltstack/salt
salt/modules/pagerduty_util.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pagerduty_util.py#L312-L331
def delete_resource(resource_name, key, identifier_fields, profile='pagerduty', subdomain=None, api_key=None): ''' delete any pagerduty resource Helper method for absent() example: delete_resource("users", key, ["id","name","email"]) # delete by id or name or email ''' resource = ...
[ "def", "delete_resource", "(", "resource_name", ",", "key", ",", "identifier_fields", ",", "profile", "=", "'pagerduty'", ",", "subdomain", "=", "None", ",", "api_key", "=", "None", ")", ":", "resource", "=", "get_resource", "(", "resource_name", ",", "key", ...
delete any pagerduty resource Helper method for absent() example: delete_resource("users", key, ["id","name","email"]) # delete by id or name or email
[ "delete", "any", "pagerduty", "resource" ]
python
train
PyCQA/pylint
pylint/__init__.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/__init__.py#L15-L22
def run_pylint(): """run pylint""" from pylint.lint import Run try: Run(sys.argv[1:]) except KeyboardInterrupt: sys.exit(1)
[ "def", "run_pylint", "(", ")", ":", "from", "pylint", ".", "lint", "import", "Run", "try", ":", "Run", "(", "sys", ".", "argv", "[", "1", ":", "]", ")", "except", "KeyboardInterrupt", ":", "sys", ".", "exit", "(", "1", ")" ]
run pylint
[ "run", "pylint" ]
python
test
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/mavproxy.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/mavproxy.py#L401-L411
def clear_zipimport_cache(): """Clear out cached entries from _zip_directory_cache. See http://www.digi.com/wiki/developer/index.php/Error_messages""" import sys, zipimport syspath_backup = list(sys.path) zipimport._zip_directory_cache.clear() # load back items onto sys.path sys.path = sysp...
[ "def", "clear_zipimport_cache", "(", ")", ":", "import", "sys", ",", "zipimport", "syspath_backup", "=", "list", "(", "sys", ".", "path", ")", "zipimport", ".", "_zip_directory_cache", ".", "clear", "(", ")", "# load back items onto sys.path", "sys", ".", "path"...
Clear out cached entries from _zip_directory_cache. See http://www.digi.com/wiki/developer/index.php/Error_messages
[ "Clear", "out", "cached", "entries", "from", "_zip_directory_cache", ".", "See", "http", ":", "//", "www", ".", "digi", ".", "com", "/", "wiki", "/", "developer", "/", "index", ".", "php", "/", "Error_messages" ]
python
train
opendatateam/udata
udata/harvest/actions.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/harvest/actions.py#L138-L143
def run(ident): '''Launch or resume an harvesting for a given source if none is running''' source = get_source(ident) cls = backends.get(current_app, source.backend) backend = cls(source) backend.harvest()
[ "def", "run", "(", "ident", ")", ":", "source", "=", "get_source", "(", "ident", ")", "cls", "=", "backends", ".", "get", "(", "current_app", ",", "source", ".", "backend", ")", "backend", "=", "cls", "(", "source", ")", "backend", ".", "harvest", "(...
Launch or resume an harvesting for a given source if none is running
[ "Launch", "or", "resume", "an", "harvesting", "for", "a", "given", "source", "if", "none", "is", "running" ]
python
train
sampsyo/confuse
confuse.py
https://github.com/sampsyo/confuse/blob/9ff0992e30470f6822824711950e6dd906e253fb/confuse.py#L644-L660
def _package_path(name): """Returns the path to the package containing the named module or None if the path could not be identified (e.g., if ``name == "__main__"``). """ loader = pkgutil.get_loader(name) if loader is None or name == '__main__': return None if hasattr(loader, 'get_f...
[ "def", "_package_path", "(", "name", ")", ":", "loader", "=", "pkgutil", ".", "get_loader", "(", "name", ")", "if", "loader", "is", "None", "or", "name", "==", "'__main__'", ":", "return", "None", "if", "hasattr", "(", "loader", ",", "'get_filename'", ")...
Returns the path to the package containing the named module or None if the path could not be identified (e.g., if ``name == "__main__"``).
[ "Returns", "the", "path", "to", "the", "package", "containing", "the", "named", "module", "or", "None", "if", "the", "path", "could", "not", "be", "identified", "(", "e", ".", "g", ".", "if", "name", "==", "__main__", ")", "." ]
python
train
h2oai/h2o-3
h2o-py/h2o/utils/progressbar.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/utils/progressbar.py#L700-L703
def render(self, progress, width=None, status=None): """Render the widget.""" current_pct = int(progress * 100 + 0.1) return RenderResult(rendered="%3d%%" % current_pct, next_progress=(current_pct + 1) / 100)
[ "def", "render", "(", "self", ",", "progress", ",", "width", "=", "None", ",", "status", "=", "None", ")", ":", "current_pct", "=", "int", "(", "progress", "*", "100", "+", "0.1", ")", "return", "RenderResult", "(", "rendered", "=", "\"%3d%%\"", "%", ...
Render the widget.
[ "Render", "the", "widget", "." ]
python
test
robdmc/behold
behold/logger.py
https://github.com/robdmc/behold/blob/ac1b7707e2d7472a50d837dda78be1e23af8fce5/behold/logger.py#L236-L267
def when_values(self, **criteria): """ By default, ``Behold`` objects call ``str()`` on all variables before sending them to the output stream. This method enables you to filter on those extracted string representations. The syntax is exactly like that of the ``when_context()``...
[ "def", "when_values", "(", "self", ",", "*", "*", "criteria", ")", ":", "criteria", "=", "{", "k", ":", "str", "(", "v", ")", "for", "k", ",", "v", "in", "criteria", ".", "items", "(", ")", "}", "self", ".", "_add_value_filters", "(", "*", "*", ...
By default, ``Behold`` objects call ``str()`` on all variables before sending them to the output stream. This method enables you to filter on those extracted string representations. The syntax is exactly like that of the ``when_context()`` method. Here is an example. .. code-block:: ...
[ "By", "default", "Behold", "objects", "call", "str", "()", "on", "all", "variables", "before", "sending", "them", "to", "the", "output", "stream", ".", "This", "method", "enables", "you", "to", "filter", "on", "those", "extracted", "string", "representations",...
python
train
jjjake/internetarchive
internetarchive/api.py
https://github.com/jjjake/internetarchive/blob/7c0c71bfe52490927a37ade15bd09b2733fea660/internetarchive/api.py#L563-L579
def configure(username=None, password=None, config_file=None): """Configure internetarchive with your Archive.org credentials. :type username: str :param username: The email address associated with your Archive.org account. :type password: str :param password: Your Archive.org password. Usage...
[ "def", "configure", "(", "username", "=", "None", ",", "password", "=", "None", ",", "config_file", "=", "None", ")", ":", "username", "=", "input", "(", "'Email address: '", ")", "if", "not", "username", "else", "username", "password", "=", "getpass", "("...
Configure internetarchive with your Archive.org credentials. :type username: str :param username: The email address associated with your Archive.org account. :type password: str :param password: Your Archive.org password. Usage: >>> from internetarchive import configure >>> config...
[ "Configure", "internetarchive", "with", "your", "Archive", ".", "org", "credentials", "." ]
python
train
opencobra/memote
memote/suite/reporting/report.py
https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/suite/reporting/report.py#L114-L164
def compute_score(self): """Calculate the overall test score using the configuration.""" # LOGGER.info("Begin scoring") cases = self.get_configured_tests() | set(self.result.cases) scores = DataFrame({"score": 0.0, "max": 1.0}, index=sorted(cases)) self...
[ "def", "compute_score", "(", "self", ")", ":", "# LOGGER.info(\"Begin scoring\")", "cases", "=", "self", ".", "get_configured_tests", "(", ")", "|", "set", "(", "self", ".", "result", ".", "cases", ")", "scores", "=", "DataFrame", "(", "{", "\"score\"", ":",...
Calculate the overall test score using the configuration.
[ "Calculate", "the", "overall", "test", "score", "using", "the", "configuration", "." ]
python
train
kensho-technologies/grift
grift/property_types.py
https://github.com/kensho-technologies/grift/blob/b8767d1604c1a0a25eace6cdd04b53b57afa9757/grift/property_types.py#L101-L119
def validate_resource(self, value): """Validate the network resource with exponential backoff""" def do_backoff(*args, **kwargs): """Call self._test_connection with exponential backoff, for self._max_tries attempts""" attempts = 0 while True: try: ...
[ "def", "validate_resource", "(", "self", ",", "value", ")", ":", "def", "do_backoff", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Call self._test_connection with exponential backoff, for self._max_tries attempts\"\"\"", "attempts", "=", "0", "while", "...
Validate the network resource with exponential backoff
[ "Validate", "the", "network", "resource", "with", "exponential", "backoff" ]
python
train
jpscaletti/solution
solution/fields/splitted_datetime.py
https://github.com/jpscaletti/solution/blob/eabafd8e695bbb0209242e002dbcc05ffb327f43/solution/fields/splitted_datetime.py#L83-L90
def _str_to_datetime(self, str_value): """Parses a `YYYY-MM-DD` string into a datetime object.""" try: ldt = [int(f) for f in str_value.split('-')] dt = datetime.datetime(*ldt) except (ValueError, TypeError): return None return dt
[ "def", "_str_to_datetime", "(", "self", ",", "str_value", ")", ":", "try", ":", "ldt", "=", "[", "int", "(", "f", ")", "for", "f", "in", "str_value", ".", "split", "(", "'-'", ")", "]", "dt", "=", "datetime", ".", "datetime", "(", "*", "ldt", ")"...
Parses a `YYYY-MM-DD` string into a datetime object.
[ "Parses", "a", "YYYY", "-", "MM", "-", "DD", "string", "into", "a", "datetime", "object", "." ]
python
train
Pylons/plaster_pastedeploy
src/plaster_pastedeploy/__init__.py
https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L155-L174
def get_wsgi_filter(self, name=None, defaults=None): """Reads the configuration soruce and finds and loads a WSGI filter defined by the filter entry with the name ``name`` per the PasteDeploy configuration format and loading mechanism. :param name: The named WSGI filter to find, load an...
[ "def", "get_wsgi_filter", "(", "self", ",", "name", "=", "None", ",", "defaults", "=", "None", ")", ":", "name", "=", "self", ".", "_maybe_get_default_name", "(", "name", ")", "defaults", "=", "self", ".", "_get_defaults", "(", "defaults", ")", "return", ...
Reads the configuration soruce and finds and loads a WSGI filter defined by the filter entry with the name ``name`` per the PasteDeploy configuration format and loading mechanism. :param name: The named WSGI filter to find, load and return. Defaults to ``None`` which becomes ``main`...
[ "Reads", "the", "configuration", "soruce", "and", "finds", "and", "loads", "a", "WSGI", "filter", "defined", "by", "the", "filter", "entry", "with", "the", "name", "name", "per", "the", "PasteDeploy", "configuration", "format", "and", "loading", "mechanism", "...
python
train
google/grr
grr/server/grr_response_server/email_alerts.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/email_alerts.py#L42-L52
def SplitEmailsAndAppendEmailDomain(self, address_list): """Splits a string of comma-separated emails, appending default domain.""" result = [] # Process email addresses, and build up a list. if isinstance(address_list, rdf_standard.DomainEmailAddress): address_list = [str(address_list)] elif ...
[ "def", "SplitEmailsAndAppendEmailDomain", "(", "self", ",", "address_list", ")", ":", "result", "=", "[", "]", "# Process email addresses, and build up a list.", "if", "isinstance", "(", "address_list", ",", "rdf_standard", ".", "DomainEmailAddress", ")", ":", "address_...
Splits a string of comma-separated emails, appending default domain.
[ "Splits", "a", "string", "of", "comma", "-", "separated", "emails", "appending", "default", "domain", "." ]
python
train
SmileyChris/easy-thumbnails
easy_thumbnails/utils.py
https://github.com/SmileyChris/easy-thumbnails/blob/b08ab44883bf7b221a98dadb9b589cb95d35b0bf/easy_thumbnails/utils.py#L111-L137
def exif_orientation(im): """ Rotate and/or flip an image to respect the image's EXIF orientation data. """ try: exif = im._getexif() except Exception: # There are many ways that _getexif fails, we're just going to blanket # cover them all. exif = None if exif: ...
[ "def", "exif_orientation", "(", "im", ")", ":", "try", ":", "exif", "=", "im", ".", "_getexif", "(", ")", "except", "Exception", ":", "# There are many ways that _getexif fails, we're just going to blanket", "# cover them all.", "exif", "=", "None", "if", "exif", ":...
Rotate and/or flip an image to respect the image's EXIF orientation data.
[ "Rotate", "and", "/", "or", "flip", "an", "image", "to", "respect", "the", "image", "s", "EXIF", "orientation", "data", "." ]
python
train
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L10702-L10724
def separate_directions(di_block): """ Separates set of directions into two modes based on principal direction Parameters _______________ di_block : block of nested dec,inc pairs Return mode_1_block,mode_2_block : two lists of nested dec,inc pairs """ ppars = doprinc(di_block) ...
[ "def", "separate_directions", "(", "di_block", ")", ":", "ppars", "=", "doprinc", "(", "di_block", ")", "di_df", "=", "pd", ".", "DataFrame", "(", "di_block", ")", "# turn into a data frame for easy filtering", "di_df", ".", "columns", "=", "[", "'dec'", ",", ...
Separates set of directions into two modes based on principal direction Parameters _______________ di_block : block of nested dec,inc pairs Return mode_1_block,mode_2_block : two lists of nested dec,inc pairs
[ "Separates", "set", "of", "directions", "into", "two", "modes", "based", "on", "principal", "direction" ]
python
train
spyder-ide/conda-manager
conda_manager/api/client_api.py
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L342-L352
def set_domain(self, domain='https://api.anaconda.org'): """Reset current api domain.""" logger.debug(str((domain))) config = binstar_client.utils.get_config() config['url'] = domain binstar_client.utils.set_config(config) self._anaconda_client_api = binstar_client.utils...
[ "def", "set_domain", "(", "self", ",", "domain", "=", "'https://api.anaconda.org'", ")", ":", "logger", ".", "debug", "(", "str", "(", "(", "domain", ")", ")", ")", "config", "=", "binstar_client", ".", "utils", ".", "get_config", "(", ")", "config", "["...
Reset current api domain.
[ "Reset", "current", "api", "domain", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/shellapp.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/shellapp.py#L326-L347
def _run_cmd_line_code(self): """Run code or file specified at the command-line""" if self.code_to_run: line = self.code_to_run try: self.log.info("Running code given at command line (c=): %s" % line) self.shell.run_ce...
[ "def", "_run_cmd_line_code", "(", "self", ")", ":", "if", "self", ".", "code_to_run", ":", "line", "=", "self", ".", "code_to_run", "try", ":", "self", ".", "log", ".", "info", "(", "\"Running code given at command line (c=): %s\"", "%", "line", ")", "self", ...
Run code or file specified at the command-line
[ "Run", "code", "or", "file", "specified", "at", "the", "command", "-", "line" ]
python
test
bsmurphy/PyKrige
pykrige/ok.py
https://github.com/bsmurphy/PyKrige/blob/a4db3003b0b5688658c12faeb95a5a8b2b14b433/pykrige/ok.py#L459-L478
def _get_kriging_matrix(self, n): """Assembles the kriging matrix.""" if self.coordinates_type == 'euclidean': xy = np.concatenate((self.X_ADJUSTED[:, np.newaxis], self.Y_ADJUSTED[:, np.newaxis]), axis=1) d = cdist(xy, xy, 'euclidean') ...
[ "def", "_get_kriging_matrix", "(", "self", ",", "n", ")", ":", "if", "self", ".", "coordinates_type", "==", "'euclidean'", ":", "xy", "=", "np", ".", "concatenate", "(", "(", "self", ".", "X_ADJUSTED", "[", ":", ",", "np", ".", "newaxis", "]", ",", "...
Assembles the kriging matrix.
[ "Assembles", "the", "kriging", "matrix", "." ]
python
train
chewse/djangorestframework-signed-permissions
signedpermissions/signing.py
https://github.com/chewse/djangorestframework-signed-permissions/blob/b1cc4c57999fc5be8361f60f0ada1d777b27feab/signedpermissions/signing.py#L35-L38
def unsign_filters_and_actions(sign, dotted_model_name): """Return the list of filters and actions for dotted_model_name.""" permissions = signing.loads(sign) return permissions.get(dotted_model_name, [])
[ "def", "unsign_filters_and_actions", "(", "sign", ",", "dotted_model_name", ")", ":", "permissions", "=", "signing", ".", "loads", "(", "sign", ")", "return", "permissions", ".", "get", "(", "dotted_model_name", ",", "[", "]", ")" ]
Return the list of filters and actions for dotted_model_name.
[ "Return", "the", "list", "of", "filters", "and", "actions", "for", "dotted_model_name", "." ]
python
train
andymccurdy/redis-py
redis/client.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L2742-L2751
def eval(self, script, numkeys, *keys_and_args): """ Execute the Lua ``script``, specifying the ``numkeys`` the script will touch and the key names and argument values in ``keys_and_args``. Returns the result of the script. In practice, use the object returned by ``register_scri...
[ "def", "eval", "(", "self", ",", "script", ",", "numkeys", ",", "*", "keys_and_args", ")", ":", "return", "self", ".", "execute_command", "(", "'EVAL'", ",", "script", ",", "numkeys", ",", "*", "keys_and_args", ")" ]
Execute the Lua ``script``, specifying the ``numkeys`` the script will touch and the key names and argument values in ``keys_and_args``. Returns the result of the script. In practice, use the object returned by ``register_script``. This function exists purely for Redis API completion.
[ "Execute", "the", "Lua", "script", "specifying", "the", "numkeys", "the", "script", "will", "touch", "and", "the", "key", "names", "and", "argument", "values", "in", "keys_and_args", ".", "Returns", "the", "result", "of", "the", "script", "." ]
python
train
OpenKMIP/PyKMIP
kmip/core/objects.py
https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/core/objects.py#L2903-L2974
def read(self, input_stream, kmip_version=enums.KMIPVersion.KMIP_1_0): """ Read the data encoding the KeyWrappingSpecification struct and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporti...
[ "def", "read", "(", "self", ",", "input_stream", ",", "kmip_version", "=", "enums", ".", "KMIPVersion", ".", "KMIP_1_0", ")", ":", "super", "(", "KeyWrappingSpecification", ",", "self", ")", ".", "read", "(", "input_stream", ",", "kmip_version", "=", "kmip_v...
Read the data encoding the KeyWrappingSpecification struct and decode it into its constituent parts. Args: input_stream (stream): A data stream containing encoded object data, supporting a read method; usually a BytearrayStream object. kmip_versio...
[ "Read", "the", "data", "encoding", "the", "KeyWrappingSpecification", "struct", "and", "decode", "it", "into", "its", "constituent", "parts", "." ]
python
test
4Catalyzer/flask-resty
flask_resty/decorators.py
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/decorators.py#L31-L50
def request_cached_property(func): """Make the given method a per-request cached property. This caches the value on the request context rather than on the object itself, preventing problems if the object gets reused across multiple requests. """ @property @functools.wraps(func) def wrap...
[ "def", "request_cached_property", "(", "func", ")", ":", "@", "property", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "self", ")", ":", "cached_value", "=", "context", ".", "get_for_view", "(", "self", ",", "func", ".", "__na...
Make the given method a per-request cached property. This caches the value on the request context rather than on the object itself, preventing problems if the object gets reused across multiple requests.
[ "Make", "the", "given", "method", "a", "per", "-", "request", "cached", "property", "." ]
python
train
mozilla/amo-validator
validator/metadata_helpers.py
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/metadata_helpers.py#L53-L78
def validate_version(err, value, source): 'Tests a manifest version number' field_name = '<em:version>' if source == 'install.rdf' else 'version' err.metadata['version'] = value # May not be longer than 32 characters if len(value) > 32: err.error( ('metadata_helpers', '_test_...
[ "def", "validate_version", "(", "err", ",", "value", ",", "source", ")", ":", "field_name", "=", "'<em:version>'", "if", "source", "==", "'install.rdf'", "else", "'version'", "err", ".", "metadata", "[", "'version'", "]", "=", "value", "# May not be longer than ...
Tests a manifest version number
[ "Tests", "a", "manifest", "version", "number" ]
python
train
ev3dev/ev3dev-lang-python
ev3dev2/motor.py
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L1863-L1873
def on_for_rotations(self, left_speed, right_speed, rotations, brake=True, block=True): """ Rotate the motors at 'left_speed & right_speed' for 'rotations'. Speeds can be percentages or any SpeedValue implementation. If the left speed is not equal to the right speed (i.e., the robot wil...
[ "def", "on_for_rotations", "(", "self", ",", "left_speed", ",", "right_speed", ",", "rotations", ",", "brake", "=", "True", ",", "block", "=", "True", ")", ":", "MoveTank", ".", "on_for_degrees", "(", "self", ",", "left_speed", ",", "right_speed", ",", "ro...
Rotate the motors at 'left_speed & right_speed' for 'rotations'. Speeds can be percentages or any SpeedValue implementation. If the left speed is not equal to the right speed (i.e., the robot will turn), the motor on the outside of the turn will rotate for the full ``rotations`` while t...
[ "Rotate", "the", "motors", "at", "left_speed", "&", "right_speed", "for", "rotations", ".", "Speeds", "can", "be", "percentages", "or", "any", "SpeedValue", "implementation", "." ]
python
train
mozilla-releng/signtool
signtool/util/archives.py
https://github.com/mozilla-releng/signtool/blob/0a778778a181cb9cab424b29fa104b70345f53c2/signtool/util/archives.py#L186-L196
def unpackfile(filename, destdir): """Unpack a mar or exe into destdir""" if filename.endswith(".mar"): return unpackmar(filename, destdir) elif filename.endswith(".exe"): return unpackexe(filename, destdir) elif filename.endswith(".tar") or filename.endswith(".tar.gz") \ or ...
[ "def", "unpackfile", "(", "filename", ",", "destdir", ")", ":", "if", "filename", ".", "endswith", "(", "\".mar\"", ")", ":", "return", "unpackmar", "(", "filename", ",", "destdir", ")", "elif", "filename", ".", "endswith", "(", "\".exe\"", ")", ":", "re...
Unpack a mar or exe into destdir
[ "Unpack", "a", "mar", "or", "exe", "into", "destdir" ]
python
train
ymotongpoo/pysuddendeath
suddendeath/__init__.py
https://github.com/ymotongpoo/pysuddendeath/blob/2ce26d3229e60ce1f1fd5f032a7b0512dec25c5a/suddendeath/__init__.py#L50-L69
def suddendeathmessage(message): ''' suddendeathmessage returns "突然の死" like ascii art decorated message string. :param str message: random unicode mixed text :rtype: str ''' msg_len = message_length(message) header_len = msg_len // 2 + 2 footer_len = (msg_len // 2) * 2 + 1 footer_pa...
[ "def", "suddendeathmessage", "(", "message", ")", ":", "msg_len", "=", "message_length", "(", "message", ")", "header_len", "=", "msg_len", "//", "2", "+", "2", "footer_len", "=", "(", "msg_len", "//", "2", ")", "*", "2", "+", "1", "footer_pattern", "=",...
suddendeathmessage returns "突然の死" like ascii art decorated message string. :param str message: random unicode mixed text :rtype: str
[ "suddendeathmessage", "returns", "突然の死", "like", "ascii", "art", "decorated", "message", "string", "." ]
python
train
dslackw/slpkg
slpkg/sbo/slackbuild.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L224-L233
def sbo_version_source(self, slackbuilds): """Create sbo name with version """ sbo_versions, sources = [], [] for sbo in slackbuilds: status(0.02) sbo_ver = "{0}-{1}".format(sbo, SBoGrep(sbo).version()) sbo_versions.append(sbo_ver) sources....
[ "def", "sbo_version_source", "(", "self", ",", "slackbuilds", ")", ":", "sbo_versions", ",", "sources", "=", "[", "]", ",", "[", "]", "for", "sbo", "in", "slackbuilds", ":", "status", "(", "0.02", ")", "sbo_ver", "=", "\"{0}-{1}\"", ".", "format", "(", ...
Create sbo name with version
[ "Create", "sbo", "name", "with", "version" ]
python
train
Duke-GCB/DukeDSClient
ddsc/cmdparser.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/cmdparser.py#L98-L107
def _path_has_ok_chars(path): """ Validate path for invalid characters. :param path: str possible filesystem path :return: path if it was ok otherwise raises error """ basename = os.path.basename(path) if any([bad_char in basename for bad_char in INVALID_PATH_CHARS]): raise argpa...
[ "def", "_path_has_ok_chars", "(", "path", ")", ":", "basename", "=", "os", ".", "path", ".", "basename", "(", "path", ")", "if", "any", "(", "[", "bad_char", "in", "basename", "for", "bad_char", "in", "INVALID_PATH_CHARS", "]", ")", ":", "raise", "argpar...
Validate path for invalid characters. :param path: str possible filesystem path :return: path if it was ok otherwise raises error
[ "Validate", "path", "for", "invalid", "characters", ".", ":", "param", "path", ":", "str", "possible", "filesystem", "path", ":", "return", ":", "path", "if", "it", "was", "ok", "otherwise", "raises", "error" ]
python
train
python-constraint/python-constraint
constraint/__init__.py
https://github.com/python-constraint/python-constraint/blob/e23fe9852cddddf1c3e258e03f2175df24b4c702/constraint/__init__.py#L880-L919
def forwardCheck(self, variables, domains, assignments, _unassigned=Unassigned): """ Helper method for generic forward checking Currently, this method acts only when there's a single unassigned variable. @param variables: Variables affected by that constraint, in the ...
[ "def", "forwardCheck", "(", "self", ",", "variables", ",", "domains", ",", "assignments", ",", "_unassigned", "=", "Unassigned", ")", ":", "unassignedvariable", "=", "_unassigned", "for", "variable", "in", "variables", ":", "if", "variable", "not", "in", "assi...
Helper method for generic forward checking Currently, this method acts only when there's a single unassigned variable. @param variables: Variables affected by that constraint, in the same order provided by the user @type variables: sequence @param dom...
[ "Helper", "method", "for", "generic", "forward", "checking" ]
python
train
Grunny/zap-cli
zapcli/helpers.py
https://github.com/Grunny/zap-cli/blob/d58d4850ecfc5467badfac5e5bcc841d064bd419/zapcli/helpers.py#L19-L29
def validate_ids(ctx, param, value): """Validate a list of IDs and convert them to a list.""" if not value: return None ids = [x.strip() for x in value.split(',')] for id_item in ids: if not id_item.isdigit(): raise click.BadParameter('Non-numeric value "{0}" provided for an...
[ "def", "validate_ids", "(", "ctx", ",", "param", ",", "value", ")", ":", "if", "not", "value", ":", "return", "None", "ids", "=", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "value", ".", "split", "(", "','", ")", "]", "for", "id_item", ...
Validate a list of IDs and convert them to a list.
[ "Validate", "a", "list", "of", "IDs", "and", "convert", "them", "to", "a", "list", "." ]
python
train
schlamar/latexmk.py
latexmake.py
https://github.com/schlamar/latexmk.py/blob/88baba40ff3e844e4542de60d2032503e206d996/latexmake.py#L372-L426
def run(self): '''Run the LaTeX compilation.''' # store files self.old_dir = [] if self.opt.clean: self.old_dir = os.listdir('.') cite_counter, toc_file, gloss_files = self._read_latex_files() self.latex_run() self.read_glossaries() gloss_ch...
[ "def", "run", "(", "self", ")", ":", "# store files", "self", ".", "old_dir", "=", "[", "]", "if", "self", ".", "opt", ".", "clean", ":", "self", ".", "old_dir", "=", "os", ".", "listdir", "(", "'.'", ")", "cite_counter", ",", "toc_file", ",", "glo...
Run the LaTeX compilation.
[ "Run", "the", "LaTeX", "compilation", "." ]
python
train
dnanexus/dx-toolkit
src/python/dxpy/api.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L283-L289
def applet_remove_tags(object_id, input_params={}, always_retry=True, **kwargs): """ Invokes the /applet-xxxx/removeTags API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FremoveTags """ return DXHTTPRequest('/%s/removeTags' % objec...
[ "def", "applet_remove_tags", "(", "object_id", ",", "input_params", "=", "{", "}", ",", "always_retry", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "DXHTTPRequest", "(", "'/%s/removeTags'", "%", "object_id", ",", "input_params", ",", "always_retr...
Invokes the /applet-xxxx/removeTags API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FremoveTags
[ "Invokes", "the", "/", "applet", "-", "xxxx", "/", "removeTags", "API", "method", "." ]
python
train
FutunnOpen/futuquant
futuquant/examples/learn/get_realtime_data.py
https://github.com/FutunnOpen/futuquant/blob/1512b321845f92ec9c578ce2689aa4e8482669e4/futuquant/examples/learn/get_realtime_data.py#L8-L33
def _example_stock_quote(quote_ctx): """ 获取批量报价,输出 股票名称,时间,当前价,开盘价,最高价,最低价,昨天收盘价,成交量,成交额,换手率,振幅,股票状态 """ stock_code_list = ["US.AAPL", "HK.00700"] # subscribe "QUOTE" ret_status, ret_data = quote_ctx.subscribe(stock_code_list, ft.SubType.QUOTE) if ret_status != ft.RET_OK: print("%s ...
[ "def", "_example_stock_quote", "(", "quote_ctx", ")", ":", "stock_code_list", "=", "[", "\"US.AAPL\"", ",", "\"HK.00700\"", "]", "# subscribe \"QUOTE\"", "ret_status", ",", "ret_data", "=", "quote_ctx", ".", "subscribe", "(", "stock_code_list", ",", "ft", ".", "Su...
获取批量报价,输出 股票名称,时间,当前价,开盘价,最高价,最低价,昨天收盘价,成交量,成交额,换手率,振幅,股票状态
[ "获取批量报价,输出", "股票名称,时间,当前价,开盘价,最高价,最低价,昨天收盘价,成交量,成交额,换手率,振幅,股票状态" ]
python
train
oscarbranson/latools
latools/latools.py
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/latools.py#L3290-L3367
def trace_plots(self, analytes=None, samples=None, ranges=False, focus=None, outdir=None, filt=None, scale='log', figsize=[10, 4], stats=False, stat='nanmean', err='nanstd', subset='All_Analyses'): """ Plot analytes as a function of time. ...
[ "def", "trace_plots", "(", "self", ",", "analytes", "=", "None", ",", "samples", "=", "None", ",", "ranges", "=", "False", ",", "focus", "=", "None", ",", "outdir", "=", "None", ",", "filt", "=", "None", ",", "scale", "=", "'log'", ",", "figsize", ...
Plot analytes as a function of time. Parameters ---------- analytes : optional, array_like or str The analyte(s) to plot. Defaults to all analytes. samples: optional, array_like or str The sample(s) to plot. Defaults to all samples. ranges : bool ...
[ "Plot", "analytes", "as", "a", "function", "of", "time", "." ]
python
test
iotaledger/iota.lib.py
iota/api.py
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/api.py#L611-L708
def get_inputs( self, start=0, stop=None, threshold=None, security_level=None, ): # type: (int, Optional[int], Optional[int], Optional[int]) -> dict """ Gets all possible inputs of a seed and returns them, along with the tot...
[ "def", "get_inputs", "(", "self", ",", "start", "=", "0", ",", "stop", "=", "None", ",", "threshold", "=", "None", ",", "security_level", "=", "None", ",", ")", ":", "# type: (int, Optional[int], Optional[int], Optional[int]) -> dict", "return", "extended", ".", ...
Gets all possible inputs of a seed and returns them, along with the total balance. This is either done deterministically (by generating all addresses until :py:meth:`find_transactions` returns an empty result), or by providing a key range to search. :param start: St...
[ "Gets", "all", "possible", "inputs", "of", "a", "seed", "and", "returns", "them", "along", "with", "the", "total", "balance", "." ]
python
test
rbarrois/restricted_pkg
restricted_pkg/base.py
https://github.com/rbarrois/restricted_pkg/blob/abbd3cb33ed85af02fbb531fd85dda9c1b070c85/restricted_pkg/base.py#L153-L160
def get_clean_url(self): """Retrieve the clean, full URL - including username/password.""" if self.needs_auth: self.prompt_auth() url = RepositoryURL(self.url.full_url) url.username = self.username url.password = self.password return url
[ "def", "get_clean_url", "(", "self", ")", ":", "if", "self", ".", "needs_auth", ":", "self", ".", "prompt_auth", "(", ")", "url", "=", "RepositoryURL", "(", "self", ".", "url", ".", "full_url", ")", "url", ".", "username", "=", "self", ".", "username",...
Retrieve the clean, full URL - including username/password.
[ "Retrieve", "the", "clean", "full", "URL", "-", "including", "username", "/", "password", "." ]
python
train
saltstack/salt
salt/modules/virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3631-L3709
def vm_netstats(vm_=None, **kwargs): ''' Return combined network counters used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overr...
[ "def", "vm_netstats", "(", "vm_", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "_info", "(", "dom", ")", ":", "'''\n Compute network stats of a domain\n '''", "nics", "=", "_get_nics", "(", "dom", ")", "ret", "=", "{", "'rx_bytes'", "...
Return combined network counters used by the vms on this hyper in a list of dicts: :param vm_: domain name :param connection: libvirt connection URI, overriding defaults .. versionadded:: 2019.2.0 :param username: username to connect with, overriding defaults .. versionadded:: 2019.2....
[ "Return", "combined", "network", "counters", "used", "by", "the", "vms", "on", "this", "hyper", "in", "a", "list", "of", "dicts", ":" ]
python
train
etingof/pyasn1
pyasn1/type/univ.py
https://github.com/etingof/pyasn1/blob/25cf116ef8d11bb0e08454c0f3635c9f4002c2d6/pyasn1/type/univ.py#L581-L603
def fromHexString(cls, value, internalFormat=False, prepend=None): """Create a |ASN.1| object initialized from the hex string. Parameters ---------- value: :class:`str` Text string like 'DEADBEEF' """ try: value = SizedInteger(value, 16).setBitLen...
[ "def", "fromHexString", "(", "cls", ",", "value", ",", "internalFormat", "=", "False", ",", "prepend", "=", "None", ")", ":", "try", ":", "value", "=", "SizedInteger", "(", "value", ",", "16", ")", ".", "setBitLength", "(", "len", "(", "value", ")", ...
Create a |ASN.1| object initialized from the hex string. Parameters ---------- value: :class:`str` Text string like 'DEADBEEF'
[ "Create", "a", "|ASN", ".", "1|", "object", "initialized", "from", "the", "hex", "string", "." ]
python
train
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/aggregator_account_admin_api.py#L3842-L3864
def remove_users_from_account_group(self, account_id, group_id, **kwargs): # noqa: E501 """Remove users from a group. # noqa: E501 An endpoint for removing users from groups. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/policy-groups/{groupID}/users...
[ "def", "remove_users_from_account_group", "(", "self", ",", "account_id", ",", "group_id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'", ")", "...
Remove users from a group. # noqa: E501 An endpoint for removing users from groups. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/accounts/{accountID}/policy-groups/{groupID}/users -d '[0162056a9a1586f30242590700000000,0117056a9a1586f30242590700000000]' -H 'content-type: applicat...
[ "Remove", "users", "from", "a", "group", ".", "#", "noqa", ":", "E501" ]
python
train
idlesign/django-sitetree
sitetree/sitetreeapp.py
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L72-L83
def get_sitetree(): """Returns SiteTree (thread-singleton) object, implementing utility methods. :rtype: SiteTree """ sitetree = getattr(_THREAD_LOCAL, _THREAD_SITETREE, None) if sitetree is None: sitetree = SiteTree() setattr(_THREAD_LOCAL, _THREAD_SITETREE, sitetree) return ...
[ "def", "get_sitetree", "(", ")", ":", "sitetree", "=", "getattr", "(", "_THREAD_LOCAL", ",", "_THREAD_SITETREE", ",", "None", ")", "if", "sitetree", "is", "None", ":", "sitetree", "=", "SiteTree", "(", ")", "setattr", "(", "_THREAD_LOCAL", ",", "_THREAD_SITE...
Returns SiteTree (thread-singleton) object, implementing utility methods. :rtype: SiteTree
[ "Returns", "SiteTree", "(", "thread", "-", "singleton", ")", "object", "implementing", "utility", "methods", "." ]
python
test
BlackEarth/bxml
bxml/xlsx.py
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xlsx.py#L50-L57
def sheets(self): """return the sheets of data.""" data = Dict() for src in [src for src in self.zipfile.namelist() if 'xl/worksheets/' in src]: name = os.path.splitext(os.path.basename(src))[0] xml = self.xml(src) data[name] = xml return data
[ "def", "sheets", "(", "self", ")", ":", "data", "=", "Dict", "(", ")", "for", "src", "in", "[", "src", "for", "src", "in", "self", ".", "zipfile", ".", "namelist", "(", ")", "if", "'xl/worksheets/'", "in", "src", "]", ":", "name", "=", "os", ".",...
return the sheets of data.
[ "return", "the", "sheets", "of", "data", "." ]
python
train
saltstack/salt
salt/states/influxdb08_user.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/influxdb08_user.py#L25-L90
def present(name, passwd, database=None, user=None, password=None, host=None, port=None): ''' Ensure that the cluster admin or database user is present. name The name of the user to manage passwd The password of th...
[ "def", "present", "(", "name", ",", "passwd", ",", "database", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "host", "=", "None", ",", "port", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'chang...
Ensure that the cluster admin or database user is present. name The name of the user to manage passwd The password of the user database The database to create the user in user The user to connect as (must be able to create the user) password The password ...
[ "Ensure", "that", "the", "cluster", "admin", "or", "database", "user", "is", "present", "." ]
python
train
saltstack/salt
salt/modules/localemod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L65-L97
def _localectl_status(): ''' Parse localectl status into a dict. :return: dict ''' if salt.utils.path.which('localectl') is None: raise CommandExecutionError('Unable to find "localectl"') ret = {} locale_ctl_out = (__salt__['cmd.run']('localectl status') or '').strip() ctl_key =...
[ "def", "_localectl_status", "(", ")", ":", "if", "salt", ".", "utils", ".", "path", ".", "which", "(", "'localectl'", ")", "is", "None", ":", "raise", "CommandExecutionError", "(", "'Unable to find \"localectl\"'", ")", "ret", "=", "{", "}", "locale_ctl_out", ...
Parse localectl status into a dict. :return: dict
[ "Parse", "localectl", "status", "into", "a", "dict", ".", ":", "return", ":", "dict" ]
python
train
Azure/azure-event-hubs-python
azure/eventprocessorhost/partition_manager.py
https://github.com/Azure/azure-event-hubs-python/blob/737c5f966557ada2cf10fa0d8f3c19671ae96348/azure/eventprocessorhost/partition_manager.py#L63-L69
async def stop_async(self): """ Terminiates the partition manger. """ self.cancellation_token.cancel() if self.run_task and not self.run_task.done(): await self.run_task
[ "async", "def", "stop_async", "(", "self", ")", ":", "self", ".", "cancellation_token", ".", "cancel", "(", ")", "if", "self", ".", "run_task", "and", "not", "self", ".", "run_task", ".", "done", "(", ")", ":", "await", "self", ".", "run_task" ]
Terminiates the partition manger.
[ "Terminiates", "the", "partition", "manger", "." ]
python
train
urinieto/msaf
msaf/algorithms/sf/segmenter.py
https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/algorithms/sf/segmenter.py#L116-L209
def processFlat(self): """Main process. Returns ------- est_idxs : np.array(N) Estimated times for the segment boundaries in frame indeces. est_labels : np.array(N-1) Estimated labels for the segments. """ # Structural Features params ...
[ "def", "processFlat", "(", "self", ")", ":", "# Structural Features params", "Mp", "=", "self", ".", "config", "[", "\"Mp_adaptive\"", "]", "# Size of the adaptive threshold for", "# peak picking", "od", "=", "self", ".", "config", "[", "\"offset_thres\"", "]", "# O...
Main process. Returns ------- est_idxs : np.array(N) Estimated times for the segment boundaries in frame indeces. est_labels : np.array(N-1) Estimated labels for the segments.
[ "Main", "process", ".", "Returns", "-------", "est_idxs", ":", "np", ".", "array", "(", "N", ")", "Estimated", "times", "for", "the", "segment", "boundaries", "in", "frame", "indeces", ".", "est_labels", ":", "np", ".", "array", "(", "N", "-", "1", ")"...
python
test
bids-standard/pybids
bids/variables/variables.py
https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/variables.py#L315-L352
def to_dense(self, sampling_rate): ''' Convert the current sparse column to a dense representation. Returns: A DenseRunVariable. Args: sampling_rate (int, str): Sampling rate (in Hz) to use when constructing the DenseRunVariable. Returns: A Dense...
[ "def", "to_dense", "(", "self", ",", "sampling_rate", ")", ":", "duration", "=", "int", "(", "math", ".", "ceil", "(", "sampling_rate", "*", "self", ".", "get_duration", "(", ")", ")", ")", "ts", "=", "np", ".", "zeros", "(", "duration", ",", "dtype"...
Convert the current sparse column to a dense representation. Returns: A DenseRunVariable. Args: sampling_rate (int, str): Sampling rate (in Hz) to use when constructing the DenseRunVariable. Returns: A DenseRunVariable.
[ "Convert", "the", "current", "sparse", "column", "to", "a", "dense", "representation", ".", "Returns", ":", "A", "DenseRunVariable", "." ]
python
train
ray-project/ray
python/ray/experimental/tf_utils.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L139-L157
def set_flat(self, new_weights): """Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): ...
[ "def", "set_flat", "(", "self", ",", "new_weights", ")", ":", "self", ".", "_check_sess", "(", ")", "shapes", "=", "[", "v", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")", ...
Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): Flat array containing weights.
[ "Sets", "the", "weights", "to", "new_weights", "converting", "from", "a", "flat", "array", "." ]
python
train
idlesign/django-sitetree
sitetree/sitetreeapp.py
https://github.com/idlesign/django-sitetree/blob/61de4608e6e415247c75fe8691027d7c4ed0d1e7/sitetree/sitetreeapp.py#L1024-L1053
def filter_items(self, items, navigation_type=None): """Filters sitetree item's children if hidden and by navigation type. NB: We do not apply any filters to sitetree in admin app. :param list items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu :rtype: list ...
[ "def", "filter_items", "(", "self", ",", "items", ",", "navigation_type", "=", "None", ")", ":", "if", "self", ".", "current_app_is_admin", "(", ")", ":", "return", "items", "items_filtered", "=", "[", "]", "context", "=", "self", ".", "current_page_context"...
Filters sitetree item's children if hidden and by navigation type. NB: We do not apply any filters to sitetree in admin app. :param list items: :param str|unicode navigation_type: sitetree, breadcrumbs, menu :rtype: list
[ "Filters", "sitetree", "item", "s", "children", "if", "hidden", "and", "by", "navigation", "type", "." ]
python
test
Yelp/pyramid_zipkin
pyramid_zipkin/tween.py
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/tween.py#L143-L196
def zipkin_tween(handler, registry): """ Factory for pyramid tween to handle zipkin server logging. Note that even if the request isn't sampled, Zipkin attributes are generated and pushed into threadlocal storage, so `create_http_headers_for_new_span` and `zipkin_span` will have access to the proper...
[ "def", "zipkin_tween", "(", "handler", ",", "registry", ")", ":", "def", "tween", "(", "request", ")", ":", "zipkin_settings", "=", "_get_settings_from_request", "(", "request", ")", "tracer", "=", "get_default_tracer", "(", ")", "tween_kwargs", "=", "dict", "...
Factory for pyramid tween to handle zipkin server logging. Note that even if the request isn't sampled, Zipkin attributes are generated and pushed into threadlocal storage, so `create_http_headers_for_new_span` and `zipkin_span` will have access to the proper Zipkin state. Consumes custom create_zipkin...
[ "Factory", "for", "pyramid", "tween", "to", "handle", "zipkin", "server", "logging", ".", "Note", "that", "even", "if", "the", "request", "isn", "t", "sampled", "Zipkin", "attributes", "are", "generated", "and", "pushed", "into", "threadlocal", "storage", "so"...
python
train
KelSolaar/Umbra
umbra/ui/widgets/variable_QPushButton.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/variable_QPushButton.py#L175-L188
def labels(self, value): """ Setter for **self.__labels** attribute. :param value: Attribute value. :type value: tuple """ if value is not None: assert type(value) is tuple, "'{0}' attribute: '{1}' type is not 'tuple'!".format("labels", value) ass...
[ "def", "labels", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "tuple", ",", "\"'{0}' attribute: '{1}' type is not 'tuple'!\"", ".", "format", "(", "\"labels\"", ",", "value", ")", ...
Setter for **self.__labels** attribute. :param value: Attribute value. :type value: tuple
[ "Setter", "for", "**", "self", ".", "__labels", "**", "attribute", "." ]
python
train
gregmuellegger/django-superform
django_superform/fields.py
https://github.com/gregmuellegger/django-superform/blob/5f389911ad38932b6dad184cc7fa81f27db752f9/django_superform/fields.py#L87-L96
def get_kwargs(self, form, name): """ Return the keyword arguments that are used to instantiate the formset. """ kwargs = { 'prefix': self.get_prefix(form, name), 'initial': self.get_initial(form, name), } kwargs.update(self.default_kwargs) ...
[ "def", "get_kwargs", "(", "self", ",", "form", ",", "name", ")", ":", "kwargs", "=", "{", "'prefix'", ":", "self", ".", "get_prefix", "(", "form", ",", "name", ")", ",", "'initial'", ":", "self", ".", "get_initial", "(", "form", ",", "name", ")", "...
Return the keyword arguments that are used to instantiate the formset.
[ "Return", "the", "keyword", "arguments", "that", "are", "used", "to", "instantiate", "the", "formset", "." ]
python
train
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/namespace_range.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/namespace_range.py#L457-L460
def get_namespace_keys(app, limit): """Get namespace keys.""" ns_query = datastore.Query('__namespace__', keys_only=True, _app=app) return list(ns_query.Run(limit=limit, batch_size=limit))
[ "def", "get_namespace_keys", "(", "app", ",", "limit", ")", ":", "ns_query", "=", "datastore", ".", "Query", "(", "'__namespace__'", ",", "keys_only", "=", "True", ",", "_app", "=", "app", ")", "return", "list", "(", "ns_query", ".", "Run", "(", "limit",...
Get namespace keys.
[ "Get", "namespace", "keys", "." ]
python
train
twisted/mantissa
xmantissa/liveform.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/liveform.py#L481-L488
def _coerceSingleRepetition(self, dataSet): """ Make a new liveform with our parameters, and get it to coerce our data for us. """ # make a liveform because there is some logic in _coerced form = LiveForm(lambda **k: None, self.parameters, self.name) return form.f...
[ "def", "_coerceSingleRepetition", "(", "self", ",", "dataSet", ")", ":", "# make a liveform because there is some logic in _coerced", "form", "=", "LiveForm", "(", "lambda", "*", "*", "k", ":", "None", ",", "self", ".", "parameters", ",", "self", ".", "name", ")...
Make a new liveform with our parameters, and get it to coerce our data for us.
[ "Make", "a", "new", "liveform", "with", "our", "parameters", "and", "get", "it", "to", "coerce", "our", "data", "for", "us", "." ]
python
train
wavefrontHQ/python-client
wavefront_api_client/models/response_status.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/models/response_status.py#L117-L133
def result(self, result): """Sets the result of this ResponseStatus. :param result: The result of this ResponseStatus. # noqa: E501 :type: str """ if result is None: raise ValueError("Invalid value for `result`, must not be `None`") # noqa: E501 allowed_va...
[ "def", "result", "(", "self", ",", "result", ")", ":", "if", "result", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `result`, must not be `None`\"", ")", "# noqa: E501", "allowed_values", "=", "[", "\"OK\"", ",", "\"ERROR\"", "]", "# noqa: E...
Sets the result of this ResponseStatus. :param result: The result of this ResponseStatus. # noqa: E501 :type: str
[ "Sets", "the", "result", "of", "this", "ResponseStatus", "." ]
python
train
ray-project/ray
python/ray/node.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L289-L306
def _prepare_socket_file(self, socket_path, default_prefix): """Prepare the socket file for raylet and plasma. This method helps to prepare a socket file. 1. Make the directory if the directory does not exist. 2. If the socket file exists, raise exception. Args: soc...
[ "def", "_prepare_socket_file", "(", "self", ",", "socket_path", ",", "default_prefix", ")", ":", "if", "socket_path", "is", "not", "None", ":", "if", "os", ".", "path", ".", "exists", "(", "socket_path", ")", ":", "raise", "Exception", "(", "\"Socket file {}...
Prepare the socket file for raylet and plasma. This method helps to prepare a socket file. 1. Make the directory if the directory does not exist. 2. If the socket file exists, raise exception. Args: socket_path (string): the socket file to prepare.
[ "Prepare", "the", "socket", "file", "for", "raylet", "and", "plasma", "." ]
python
train
horazont/aioxmpp
aioxmpp/xml.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/xml.py#L1085-L1095
def make_parser(): """ Create a parser which is suitably configured for parsing an XMPP XML stream. It comes equipped with :class:`XMPPLexicalHandler`. """ p = xml.sax.make_parser() p.setFeature(xml.sax.handler.feature_namespaces, True) p.setFeature(xml.sax.handler.feature_external_ges, Fals...
[ "def", "make_parser", "(", ")", ":", "p", "=", "xml", ".", "sax", ".", "make_parser", "(", ")", "p", ".", "setFeature", "(", "xml", ".", "sax", ".", "handler", ".", "feature_namespaces", ",", "True", ")", "p", ".", "setFeature", "(", "xml", ".", "s...
Create a parser which is suitably configured for parsing an XMPP XML stream. It comes equipped with :class:`XMPPLexicalHandler`.
[ "Create", "a", "parser", "which", "is", "suitably", "configured", "for", "parsing", "an", "XMPP", "XML", "stream", ".", "It", "comes", "equipped", "with", ":", "class", ":", "XMPPLexicalHandler", "." ]
python
train
iotile/coretools
transport_plugins/websocket/iotile_transport_websocket/generic/async_client.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/generic/async_client.py#L192-L230
def register_event(self, name, callback, validator): """Register a callback to receive events. Every event with the matching name will have its payload validated using validator and then will be passed to callback if validation succeeds. Callback must be a normal callback funct...
[ "def", "register_event", "(", "self", ",", "name", ",", "callback", ",", "validator", ")", ":", "async", "def", "_validate_and_call", "(", "message", ")", ":", "payload", "=", "message", ".", "get", "(", "'payload'", ")", "try", ":", "payload", "=", "val...
Register a callback to receive events. Every event with the matching name will have its payload validated using validator and then will be passed to callback if validation succeeds. Callback must be a normal callback function, coroutines are not allowed. If you need to run a c...
[ "Register", "a", "callback", "to", "receive", "events", "." ]
python
train
jaywink/federation
federation/entities/activitypub/mappers.py
https://github.com/jaywink/federation/blob/59d31bb37e662891dbea72c1dee05dc53146c78b/federation/entities/activitypub/mappers.py#L15-L32
def element_to_objects(payload: Dict) -> List: """ Transform an Element to a list of entities recursively. """ entities = [] cls = MAPPINGS.get(payload.get('type')) if not cls: return [] transformed = transform_attributes(payload, cls) entity = cls(**transformed) if hasattr...
[ "def", "element_to_objects", "(", "payload", ":", "Dict", ")", "->", "List", ":", "entities", "=", "[", "]", "cls", "=", "MAPPINGS", ".", "get", "(", "payload", ".", "get", "(", "'type'", ")", ")", "if", "not", "cls", ":", "return", "[", "]", "tran...
Transform an Element to a list of entities recursively.
[ "Transform", "an", "Element", "to", "a", "list", "of", "entities", "recursively", "." ]
python
train
PmagPy/PmagPy
pmagpy/pmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1930-L1974
def upload_read(infile, table): """ Reads a table from a MagIC upload (or downloaded) txt file, puts data in a list of dictionaries """ delim = 'tab' hold, magic_data, magic_record, magic_keys = [], [], {}, [] f = open(infile, "r") # # look for right table # line = f.readline()[:-1] ...
[ "def", "upload_read", "(", "infile", ",", "table", ")", ":", "delim", "=", "'tab'", "hold", ",", "magic_data", ",", "magic_record", ",", "magic_keys", "=", "[", "]", ",", "[", "]", ",", "{", "}", ",", "[", "]", "f", "=", "open", "(", "infile", ",...
Reads a table from a MagIC upload (or downloaded) txt file, puts data in a list of dictionaries
[ "Reads", "a", "table", "from", "a", "MagIC", "upload", "(", "or", "downloaded", ")", "txt", "file", "puts", "data", "in", "a", "list", "of", "dictionaries" ]
python
train
arve0/leicaexperiment
leicaexperiment/experiment.py
https://github.com/arve0/leicaexperiment/blob/c0393c4d51984a506f813319efb66e54c4f2a426/leicaexperiment/experiment.py#L179-L197
def well_images(self, well_row, well_column): """Get list of paths to images in specified well. Parameters ---------- well_row : int Starts at 0. Same as --V in files. well_column : int Starts at 0. Save as --U in files. Returns ------- ...
[ "def", "well_images", "(", "self", ",", "well_row", ",", "well_column", ")", ":", "return", "list", "(", "i", "for", "i", "in", "self", ".", "images", "if", "attribute", "(", "i", ",", "'u'", ")", "==", "well_column", "and", "attribute", "(", "i", ",...
Get list of paths to images in specified well. Parameters ---------- well_row : int Starts at 0. Same as --V in files. well_column : int Starts at 0. Save as --U in files. Returns ------- list of strings Paths to images or em...
[ "Get", "list", "of", "paths", "to", "images", "in", "specified", "well", "." ]
python
valid
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/device_directory/device_directory.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/device_directory/device_directory.py#L54-L77
def list_devices(self, **kwargs): """List devices in the device catalog. Example usage, listing all registered devices in the catalog: .. code-block:: python filters = { 'state': {'$eq': 'registered' } } devices = api.list_devices(order='asc', filters=filters) ...
[ "def", "list_devices", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_verify_sort_options", "(", "kwargs", ")", "kwargs", "=", "self", ".", "_verify_filters", "(", "kwargs", ",", "Device", ",", "True", ")", "api", "=", "s...
List devices in the device catalog. Example usage, listing all registered devices in the catalog: .. code-block:: python filters = { 'state': {'$eq': 'registered' } } devices = api.list_devices(order='asc', filters=filters) for idx, d in enumerate(devices): ...
[ "List", "devices", "in", "the", "device", "catalog", "." ]
python
train
saltstack/salt
salt/modules/pf.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pf.py#L235-L310
def table(command, table, **kwargs): ''' Apply a command on the specified table. table: Name of the table. command: Command to apply to the table. Supported commands are: - add - delete - expire - flush - kill - replace - show ...
[ "def", "table", "(", "command", ",", "table", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "}", "all_commands", "=", "[", "'kill'", ",", "'flush'", ",", "'add'", ",", "'delete'", ",", "'expire'", ",", "'replace'", ",", "'show'", ",", "'test'",...
Apply a command on the specified table. table: Name of the table. command: Command to apply to the table. Supported commands are: - add - delete - expire - flush - kill - replace - show - test - zero Please refer...
[ "Apply", "a", "command", "on", "the", "specified", "table", "." ]
python
train
saltstack/salt
salt/modules/win_file.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_file.py#L1230-L1332
def mkdir(path, owner=None, grant_perms=None, deny_perms=None, inheritance=True, reset=False): ''' Ensure that the directory is available and permissions are set. Args: path (str): The full path to the directory. owner (str): ...
[ "def", "mkdir", "(", "path", ",", "owner", "=", "None", ",", "grant_perms", "=", "None", ",", "deny_perms", "=", "None", ",", "inheritance", "=", "True", ",", "reset", "=", "False", ")", ":", "# Make sure the drive is valid", "drive", "=", "os", ".", "pa...
Ensure that the directory is available and permissions are set. Args: path (str): The full path to the directory. owner (str): The owner of the directory. If not passed, it will be the account that created the directory, likely SYSTEM grant_perms (dict...
[ "Ensure", "that", "the", "directory", "is", "available", "and", "permissions", "are", "set", "." ]
python
train
saltstack/salt
salt/modules/bigip.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bigip.py#L162-L219
def _set_value(value): ''' A function to detect if user is trying to pass a dictionary or list. parse it and return a dictionary list or a string ''' #don't continue if already an acceptable data-type if isinstance(value, bool) or isinstance(value, dict) or isinstance(value, list): retu...
[ "def", "_set_value", "(", "value", ")", ":", "#don't continue if already an acceptable data-type", "if", "isinstance", "(", "value", ",", "bool", ")", "or", "isinstance", "(", "value", ",", "dict", ")", "or", "isinstance", "(", "value", ",", "list", ")", ":", ...
A function to detect if user is trying to pass a dictionary or list. parse it and return a dictionary list or a string
[ "A", "function", "to", "detect", "if", "user", "is", "trying", "to", "pass", "a", "dictionary", "or", "list", ".", "parse", "it", "and", "return", "a", "dictionary", "list", "or", "a", "string" ]
python
train
szastupov/aiotg
aiotg/bot.py
https://github.com/szastupov/aiotg/blob/eed81a6a728c02120f1d730a6e8b8fe50263c010/aiotg/bot.py#L155-L196
def run(self, debug=False, reload=None): """ Convenience method for running bots in getUpdates mode :param bool debug: Enable debug logging and automatic reloading :param bool reload: Automatically reload bot on code change :Example: >>> if __name__ == '__main__': ...
[ "def", "run", "(", "self", ",", "debug", "=", "False", ",", "reload", "=", "None", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", "if", "debug", "else", "l...
Convenience method for running bots in getUpdates mode :param bool debug: Enable debug logging and automatic reloading :param bool reload: Automatically reload bot on code change :Example: >>> if __name__ == '__main__': >>> bot.run()
[ "Convenience", "method", "for", "running", "bots", "in", "getUpdates", "mode" ]
python
train
JamesRamm/longclaw
longclaw/contrib/productrequests/views.py
https://github.com/JamesRamm/longclaw/blob/8bbf2e6d703271b815ec111813c7c5d1d4e4e810/longclaw/contrib/productrequests/views.py#L11-L31
def requests_admin(request, pk): """Table display of each request for a given product. Allows the given Page pk to refer to a direct parent of the ProductVariant model or be the ProductVariant model itself. This allows for the standard longclaw product modelling philosophy where ProductVariant refe...
[ "def", "requests_admin", "(", "request", ",", "pk", ")", ":", "page", "=", "Page", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", ".", "specific", "if", "hasattr", "(", "page", ",", "'variants'", ")", ":", "requests", "=", "ProductRequest", "...
Table display of each request for a given product. Allows the given Page pk to refer to a direct parent of the ProductVariant model or be the ProductVariant model itself. This allows for the standard longclaw product modelling philosophy where ProductVariant refers to the actual product (in the case wh...
[ "Table", "display", "of", "each", "request", "for", "a", "given", "product", "." ]
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/licensing/licensing_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/licensing/licensing_client.py#L176-L197
def get_account_entitlement_for_user(self, user_id, determine_rights=None, create_if_not_exists=None): """GetAccountEntitlementForUser. [Preview API] Get the entitlements for a user :param str user_id: The id of the user :param bool determine_rights: :param bool create_if_not_exi...
[ "def", "get_account_entitlement_for_user", "(", "self", ",", "user_id", ",", "determine_rights", "=", "None", ",", "create_if_not_exists", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "user_id", "is", "not", "None", ":", "route_values", "[", "'u...
GetAccountEntitlementForUser. [Preview API] Get the entitlements for a user :param str user_id: The id of the user :param bool determine_rights: :param bool create_if_not_exists: :rtype: :class:`<AccountEntitlement> <azure.devops.v5_1.licensing.models.AccountEntitlement>`
[ "GetAccountEntitlementForUser", ".", "[", "Preview", "API", "]", "Get", "the", "entitlements", "for", "a", "user", ":", "param", "str", "user_id", ":", "The", "id", "of", "the", "user", ":", "param", "bool", "determine_rights", ":", ":", "param", "bool", "...
python
train
SHTOOLS/SHTOOLS
pyshtools/shclasses/slepian.py
https://github.com/SHTOOLS/SHTOOLS/blob/9a115cf83002df2ddec6b7f41aeb6be688e285de/pyshtools/shclasses/slepian.py#L918-L943
def _to_array(self, alpha, normalization='4pi', csphase=1): """ Return the spherical harmonic coefficients of Slepian function i as an array, where i = 0 is the best concentrated function. """ if self.coeffs is None: coeffs = _np.copy(self._taper2coeffs(alpha)) ...
[ "def", "_to_array", "(", "self", ",", "alpha", ",", "normalization", "=", "'4pi'", ",", "csphase", "=", "1", ")", ":", "if", "self", ".", "coeffs", "is", "None", ":", "coeffs", "=", "_np", ".", "copy", "(", "self", ".", "_taper2coeffs", "(", "alpha",...
Return the spherical harmonic coefficients of Slepian function i as an array, where i = 0 is the best concentrated function.
[ "Return", "the", "spherical", "harmonic", "coefficients", "of", "Slepian", "function", "i", "as", "an", "array", "where", "i", "=", "0", "is", "the", "best", "concentrated", "function", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/controller/sqlitedb.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/controller/sqlitedb.py#L189-L214
def _check_table(self): """Ensure that an incorrect table doesn't exist If a bad (old) table does exist, return False """ cursor = self._db.execute("PRAGMA table_info(%s)"%self.table) lines = cursor.fetchall() if not lines: # table does not exist ...
[ "def", "_check_table", "(", "self", ")", ":", "cursor", "=", "self", ".", "_db", ".", "execute", "(", "\"PRAGMA table_info(%s)\"", "%", "self", ".", "table", ")", "lines", "=", "cursor", ".", "fetchall", "(", ")", "if", "not", "lines", ":", "# table does...
Ensure that an incorrect table doesn't exist If a bad (old) table does exist, return False
[ "Ensure", "that", "an", "incorrect", "table", "doesn", "t", "exist" ]
python
test
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_db.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_db.py#L1983-L1998
def connect_to_database_odbc_sqlserver(self, odbc_connection_string: str = None, dsn: str = None, database: str = None, user: str = None, ...
[ "def", "connect_to_database_odbc_sqlserver", "(", "self", ",", "odbc_connection_string", ":", "str", "=", "None", ",", "dsn", ":", "str", "=", "None", ",", "database", ":", "str", "=", "None", ",", "user", ":", "str", "=", "None", ",", "password", ":", "...
Connects to an SQL Server database via ODBC.
[ "Connects", "to", "an", "SQL", "Server", "database", "via", "ODBC", "." ]
python
train