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
NYUCCL/psiTurk
psiturk/psiturk_shell.py
https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/psiturk_shell.py#L1163-L1170
def tunnel_open(self): ''' Open tunnel ''' if (self.server.is_server_running() == 'no' or self.server.is_server_running() == 'maybe'): print("Error: Sorry, you need to have the server running to open a " "tunnel. Try 'server on' first.") else: ...
[ "def", "tunnel_open", "(", "self", ")", ":", "if", "(", "self", ".", "server", ".", "is_server_running", "(", ")", "==", "'no'", "or", "self", ".", "server", ".", "is_server_running", "(", ")", "==", "'maybe'", ")", ":", "print", "(", "\"Error: Sorry, yo...
Open tunnel
[ "Open", "tunnel" ]
python
train
ejeschke/ginga
ginga/ImageView.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/ImageView.py#L1899-L1919
def get_data_pct(self, xpct, ypct): """Calculate new data size for the given axis ratios. See :meth:`get_limits`. Parameters ---------- xpct, ypct : float Ratio for X and Y, respectively, where 1 is 100%. Returns ------- x, y : int ...
[ "def", "get_data_pct", "(", "self", ",", "xpct", ",", "ypct", ")", ":", "xy_mn", ",", "xy_mx", "=", "self", ".", "get_limits", "(", ")", "width", "=", "abs", "(", "xy_mx", "[", "0", "]", "-", "xy_mn", "[", "0", "]", ")", "height", "=", "abs", "...
Calculate new data size for the given axis ratios. See :meth:`get_limits`. Parameters ---------- xpct, ypct : float Ratio for X and Y, respectively, where 1 is 100%. Returns ------- x, y : int Scaled dimensions.
[ "Calculate", "new", "data", "size", "for", "the", "given", "axis", "ratios", ".", "See", ":", "meth", ":", "get_limits", "." ]
python
train
pmacosta/pexdoc
pexdoc/pcontracts.py
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L164-L171
def _get_custom_contract(param_contract): """Return True if parameter contract is a custom contract, False otherwise.""" if not isinstance(param_contract, str): return None for custom_contract in _CUSTOM_CONTRACTS: if re.search(r"\b{0}\b".format(custom_contract), param_contract): ...
[ "def", "_get_custom_contract", "(", "param_contract", ")", ":", "if", "not", "isinstance", "(", "param_contract", ",", "str", ")", ":", "return", "None", "for", "custom_contract", "in", "_CUSTOM_CONTRACTS", ":", "if", "re", ".", "search", "(", "r\"\\b{0}\\b\"", ...
Return True if parameter contract is a custom contract, False otherwise.
[ "Return", "True", "if", "parameter", "contract", "is", "a", "custom", "contract", "False", "otherwise", "." ]
python
train
senaite/senaite.core
bika/lims/utils/__init__.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/utils/__init__.py#L179-L194
def formatDateParms(context, date_id): """ Obtain and reformat the from and to dates into a printable date parameter construct """ from_date = context.REQUEST.get('%s_fromdate' % date_id, None) to_date = context.REQUEST.get('%s_todate' % date_id, None) date_parms = {} if from_date and t...
[ "def", "formatDateParms", "(", "context", ",", "date_id", ")", ":", "from_date", "=", "context", ".", "REQUEST", ".", "get", "(", "'%s_fromdate'", "%", "date_id", ",", "None", ")", "to_date", "=", "context", ".", "REQUEST", ".", "get", "(", "'%s_todate'", ...
Obtain and reformat the from and to dates into a printable date parameter construct
[ "Obtain", "and", "reformat", "the", "from", "and", "to", "dates", "into", "a", "printable", "date", "parameter", "construct" ]
python
train
ray-project/ray
python/ray/node.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L450-L463
def start_raylet_monitor(self): """Start the raylet monitor.""" stdout_file, stderr_file = self.new_log_files("raylet_monitor") process_info = ray.services.start_raylet_monitor( self._redis_address, stdout_file=stdout_file, stderr_file=stderr_file, ...
[ "def", "start_raylet_monitor", "(", "self", ")", ":", "stdout_file", ",", "stderr_file", "=", "self", ".", "new_log_files", "(", "\"raylet_monitor\"", ")", "process_info", "=", "ray", ".", "services", ".", "start_raylet_monitor", "(", "self", ".", "_redis_address"...
Start the raylet monitor.
[ "Start", "the", "raylet", "monitor", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xtreewidget/xtreewidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidget.py#L1160-L1211
def lockToColumn(self, index): """ Sets the column that the tree view will lock to. If None is supplied, then locking will be removed. :param index | <int> || None """ self._lockColumn = index if index is None: self.__...
[ "def", "lockToColumn", "(", "self", ",", "index", ")", ":", "self", ".", "_lockColumn", "=", "index", "if", "index", "is", "None", ":", "self", ".", "__destroyLockedView", "(", ")", "return", "else", ":", "if", "not", "self", ".", "_lockedView", ":", "...
Sets the column that the tree view will lock to. If None is supplied, then locking will be removed. :param index | <int> || None
[ "Sets", "the", "column", "that", "the", "tree", "view", "will", "lock", "to", ".", "If", "None", "is", "supplied", "then", "locking", "will", "be", "removed", ".", ":", "param", "index", "|", "<int", ">", "||", "None" ]
python
train
robinandeer/puzzle
puzzle/cli/cases.py
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/cli/cases.py#L16-L39
def cases(ctx, root): """ Show all cases in the database. If no database was found run puzzle init first. """ root = root or ctx.obj.get('root') or os.path.expanduser("~/.puzzle") if os.path.isfile(root): logger.error("'root' can't be a file") ctx.abort() logger.info("Root...
[ "def", "cases", "(", "ctx", ",", "root", ")", ":", "root", "=", "root", "or", "ctx", ".", "obj", ".", "get", "(", "'root'", ")", "or", "os", ".", "path", ".", "expanduser", "(", "\"~/.puzzle\"", ")", "if", "os", ".", "path", ".", "isfile", "(", ...
Show all cases in the database. If no database was found run puzzle init first.
[ "Show", "all", "cases", "in", "the", "database", "." ]
python
train
nicolargo/glances
glances/exports/glances_restful.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_restful.py#L57-L68
def init(self): """Init the connection to the RESTful server.""" if not self.export_enable: return None # Build the RESTful URL where the stats will be posted url = '{}://{}:{}{}'.format(self.protocol, self.host, ...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "# Build the RESTful URL where the stats will be posted", "url", "=", "'{}://{}:{}{}'", ".", "format", "(", "self", ".", "protocol", ",", "self", ".", "host",...
Init the connection to the RESTful server.
[ "Init", "the", "connection", "to", "the", "RESTful", "server", "." ]
python
train
orb-framework/orb
orb/core/schema.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/schema.py#L442-L451
def setIndexes(self, indexes): """ Sets the list of indexed lookups for this schema to the inputted list. :param indexes | [<orb.Index>, ..] """ self.__indexes = {} for name, index in indexes.items(): self.__indexes[name] = index ...
[ "def", "setIndexes", "(", "self", ",", "indexes", ")", ":", "self", ".", "__indexes", "=", "{", "}", "for", "name", ",", "index", "in", "indexes", ".", "items", "(", ")", ":", "self", ".", "__indexes", "[", "name", "]", "=", "index", "index", ".", ...
Sets the list of indexed lookups for this schema to the inputted list. :param indexes | [<orb.Index>, ..]
[ "Sets", "the", "list", "of", "indexed", "lookups", "for", "this", "schema", "to", "the", "inputted", "list", ".", ":", "param", "indexes", "|", "[", "<orb", ".", "Index", ">", "..", "]" ]
python
train
uber/rides-python-sdk
uber_rides/auth.py
https://github.com/uber/rides-python-sdk/blob/76ecd75ab5235d792ec1010e36eca679ba285127/uber_rides/auth.py#L423-L444
def get_session(self): """Create Session to store credentials. Returns (Session) A Session object with OAuth 2.0 credentials. """ response = _request_access_token( grant_type=auth.CLIENT_CREDENTIALS_GRANT, client_id=self.client_id, ...
[ "def", "get_session", "(", "self", ")", ":", "response", "=", "_request_access_token", "(", "grant_type", "=", "auth", ".", "CLIENT_CREDENTIALS_GRANT", ",", "client_id", "=", "self", ".", "client_id", ",", "client_secret", "=", "self", ".", "client_secret", ",",...
Create Session to store credentials. Returns (Session) A Session object with OAuth 2.0 credentials.
[ "Create", "Session", "to", "store", "credentials", "." ]
python
train
wbond/oscrypto
oscrypto/_win/symmetric.py
https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_win/symmetric.py#L556-L664
def _advapi32_create_handles(cipher, key, iv): """ Creates an HCRYPTPROV and HCRYPTKEY for symmetric encryption/decryption. The HCRYPTPROV must be released by close_context_handle() and the HCRYPTKEY must be released by advapi32.CryptDestroyKey() when done. :param cipher: A unicode string o...
[ "def", "_advapi32_create_handles", "(", "cipher", ",", "key", ",", "iv", ")", ":", "context_handle", "=", "None", "if", "cipher", "==", "'aes'", ":", "algorithm_id", "=", "{", "16", ":", "Advapi32Const", ".", "CALG_AES_128", ",", "24", ":", "Advapi32Const", ...
Creates an HCRYPTPROV and HCRYPTKEY for symmetric encryption/decryption. The HCRYPTPROV must be released by close_context_handle() and the HCRYPTKEY must be released by advapi32.CryptDestroyKey() when done. :param cipher: A unicode string of "aes", "des", "tripledes_2key", "tripledes_3key", ...
[ "Creates", "an", "HCRYPTPROV", "and", "HCRYPTKEY", "for", "symmetric", "encryption", "/", "decryption", ".", "The", "HCRYPTPROV", "must", "be", "released", "by", "close_context_handle", "()", "and", "the", "HCRYPTKEY", "must", "be", "released", "by", "advapi32", ...
python
valid
dannyzed/julian
julian/julian.py
https://github.com/dannyzed/julian/blob/7ca7e25afe2704f072b38f8e464bc4e7d4d7d0d7/julian/julian.py#L84-L134
def from_jd(jd: float, fmt: str = 'jd') -> datetime: """ Converts a Julian Date to a datetime object. Algorithm is from Fliegel and van Flandern (1968) Parameters ---------- jd: float Julian Date as type specified in the string fmt fmt: str Returns ------- dt: datetime...
[ "def", "from_jd", "(", "jd", ":", "float", ",", "fmt", ":", "str", "=", "'jd'", ")", "->", "datetime", ":", "jd", ",", "jdf", "=", "__from_format", "(", "jd", ",", "fmt", ")", "l", "=", "jd", "+", "68569", "n", "=", "4", "*", "l", "//", "1460...
Converts a Julian Date to a datetime object. Algorithm is from Fliegel and van Flandern (1968) Parameters ---------- jd: float Julian Date as type specified in the string fmt fmt: str Returns ------- dt: datetime
[ "Converts", "a", "Julian", "Date", "to", "a", "datetime", "object", ".", "Algorithm", "is", "from", "Fliegel", "and", "van", "Flandern", "(", "1968", ")" ]
python
train
KnightHawk3/Hummingbird
hummingbird/__init__.py
https://github.com/KnightHawk3/Hummingbird/blob/10b918534b112c95a93f04dd76bfb7479c4f3f21/hummingbird/__init__.py#L124-L134
def get_feed(self, username): """Gets a user's feed. :param str username: User to fetch feed from. """ r = self._query_('/users/%s/feed' % username, 'GET') results = [Story(item) for item in r.json()] return results
[ "def", "get_feed", "(", "self", ",", "username", ")", ":", "r", "=", "self", ".", "_query_", "(", "'/users/%s/feed'", "%", "username", ",", "'GET'", ")", "results", "=", "[", "Story", "(", "item", ")", "for", "item", "in", "r", ".", "json", "(", ")...
Gets a user's feed. :param str username: User to fetch feed from.
[ "Gets", "a", "user", "s", "feed", "." ]
python
train
hover2pi/svo_filters
svo_filters/svo.py
https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L733-L760
def wave_units(self, units): """ A setter for the wavelength units Parameters ---------- units: str, astropy.units.core.PrefixUnit The wavelength units """ # Make sure it's length units if not units.is_equivalent(q.m): raise ValueE...
[ "def", "wave_units", "(", "self", ",", "units", ")", ":", "# Make sure it's length units", "if", "not", "units", ".", "is_equivalent", "(", "q", ".", "m", ")", ":", "raise", "ValueError", "(", "units", ",", "\": New wavelength units must be a length.\"", ")", "#...
A setter for the wavelength units Parameters ---------- units: str, astropy.units.core.PrefixUnit The wavelength units
[ "A", "setter", "for", "the", "wavelength", "units" ]
python
train
VingtCinq/python-resize-image
resizeimage/resizeimage.py
https://github.com/VingtCinq/python-resize-image/blob/a4e645792ef30c5fcc558df6da6de18b1ecb95ea/resizeimage/resizeimage.py#L11-L35
def validate(validator): """ Return a decorator that validates arguments with provided `validator` function. This will also store the validator function as `func.validate`. The decorator returned by this function, can bypass the validator if `validate=False` is passed as argument otherwise the ...
[ "def", "validate", "(", "validator", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"Bound decorator to a particular validator function\"\"\"", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "image", ",", "size", ",", "validate", "=", "True",...
Return a decorator that validates arguments with provided `validator` function. This will also store the validator function as `func.validate`. The decorator returned by this function, can bypass the validator if `validate=False` is passed as argument otherwise the fucntion is called directly. ...
[ "Return", "a", "decorator", "that", "validates", "arguments", "with", "provided", "validator", "function", "." ]
python
test
mdickinson/bigfloat
bigfloat/context.py
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/context.py#L296-L327
def _apply_function_in_context(cls, f, args, context): """ Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context. """ rounding = context.rounding bf = mpfr.Mpfr_t.__new__(cls) mpfr.mp...
[ "def", "_apply_function_in_context", "(", "cls", ",", "f", ",", "args", ",", "context", ")", ":", "rounding", "=", "context", ".", "rounding", "bf", "=", "mpfr", ".", "Mpfr_t", ".", "__new__", "(", "cls", ")", "mpfr", ".", "mpfr_init2", "(", "bf", ",",...
Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context.
[ "Apply", "an", "MPFR", "function", "f", "to", "the", "given", "arguments", "args", "rounding", "to", "the", "given", "context", ".", "Returns", "a", "new", "Mpfr", "object", "with", "precision", "taken", "from", "the", "current", "context", "." ]
python
train
markovmodel/PyEMMA
pyemma/plots/plots2d.py
https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/plots/plots2d.py#L157-L192
def get_grid_data(xall, yall, zall, nbins=100, method='nearest'): """Interpolate unstructured two-dimensional data. Parameters ---------- xall : ndarray(T) Sample x-coordinates. yall : ndarray(T) Sample y-coordinates. zall : ndarray(T) Sample z-coordinates. nbins : i...
[ "def", "get_grid_data", "(", "xall", ",", "yall", ",", "zall", ",", "nbins", "=", "100", ",", "method", "=", "'nearest'", ")", ":", "from", "scipy", ".", "interpolate", "import", "griddata", "x", ",", "y", "=", "_np", ".", "meshgrid", "(", "_np", "."...
Interpolate unstructured two-dimensional data. Parameters ---------- xall : ndarray(T) Sample x-coordinates. yall : ndarray(T) Sample y-coordinates. zall : ndarray(T) Sample z-coordinates. nbins : int, optional, default=100 Number of histogram bins used in x/y-di...
[ "Interpolate", "unstructured", "two", "-", "dimensional", "data", "." ]
python
train
mushkevych/scheduler
synergy/supervisor/synergy_supervisor.py
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/supervisor/synergy_supervisor.py#L77-L98
def _poll_process(self, box_config): """ between killing a process and its actual termination lies poorly documented requirement - <purging process' io pipes and reading exit status>. this can be done either by os.wait() or process.wait() """ try: p = psutil.Process(b...
[ "def", "_poll_process", "(", "self", ",", "box_config", ")", ":", "try", ":", "p", "=", "psutil", ".", "Process", "(", "box_config", ".", "pid", ")", "return_code", "=", "p", ".", "wait", "(", "timeout", "=", "0.01", ")", "if", "return_code", "is", "...
between killing a process and its actual termination lies poorly documented requirement - <purging process' io pipes and reading exit status>. this can be done either by os.wait() or process.wait()
[ "between", "killing", "a", "process", "and", "its", "actual", "termination", "lies", "poorly", "documented", "requirement", "-", "<purging", "process", "io", "pipes", "and", "reading", "exit", "status", ">", ".", "this", "can", "be", "done", "either", "by", ...
python
train
spyder-ide/spyder
spyder/plugins/editor/panels/codefolding.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/codefolding.py#L630-L639
def expand_all(self): """Expands all fold triggers.""" block = self.editor.document().firstBlock() while block.isValid(): TextBlockHelper.set_collapsed(block, False) block.setVisible(True) block = block.next() self._clear_block_deco() self._ref...
[ "def", "expand_all", "(", "self", ")", ":", "block", "=", "self", ".", "editor", ".", "document", "(", ")", ".", "firstBlock", "(", ")", "while", "block", ".", "isValid", "(", ")", ":", "TextBlockHelper", ".", "set_collapsed", "(", "block", ",", "False...
Expands all fold triggers.
[ "Expands", "all", "fold", "triggers", "." ]
python
train
simion/pip-upgrader
pip_upgrader/packages_upgrader.py
https://github.com/simion/pip-upgrader/blob/716adca65d9ed56d4d416f94ede8a8e4fa8d640a/pip_upgrader/packages_upgrader.py#L30-L41
def _update_package(self, package): """ Update (install) the package in current environment, and if success, also replace version in file """ try: if not self.dry_run and not self.skip_package_installation: # pragma: nocover subprocess.check_call(['pip', 'install', '{}=={}'....
[ "def", "_update_package", "(", "self", ",", "package", ")", ":", "try", ":", "if", "not", "self", ".", "dry_run", "and", "not", "self", ".", "skip_package_installation", ":", "# pragma: nocover", "subprocess", ".", "check_call", "(", "[", "'pip'", ",", "'ins...
Update (install) the package in current environment, and if success, also replace version in file
[ "Update", "(", "install", ")", "the", "package", "in", "current", "environment", "and", "if", "success", "also", "replace", "version", "in", "file" ]
python
test
widdowquinn/pyani
pyani/pyani_tools.py
https://github.com/widdowquinn/pyani/blob/2b24ec971401e04024bba896e4011984fe3f53f0/pyani/pyani_tools.py#L131-L156
def get_labels(filename, logger=None): """Returns a dictionary of alternative sequence labels, or None - filename - path to file containing tab-separated table of labels Input files should be formatted as <key>\t<label>, one pair per line. """ labeldict = {} if filename is not None: if...
[ "def", "get_labels", "(", "filename", ",", "logger", "=", "None", ")", ":", "labeldict", "=", "{", "}", "if", "filename", "is", "not", "None", ":", "if", "logger", ":", "logger", ".", "info", "(", "\"Reading labels from %s\"", ",", "filename", ")", "with...
Returns a dictionary of alternative sequence labels, or None - filename - path to file containing tab-separated table of labels Input files should be formatted as <key>\t<label>, one pair per line.
[ "Returns", "a", "dictionary", "of", "alternative", "sequence", "labels", "or", "None" ]
python
train
kislyuk/aegea
aegea/packages/github3/repos/repo.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/repo.py#L1401-L1411
def iter_languages(self, number=-1, etag=None): """Iterate over the programming languages used in the repository. :param int number: (optional), number of languages to return. Default: -1 returns all used languages :param str etag: (optional), ETag from a previous request to the sam...
[ "def", "iter_languages", "(", "self", ",", "number", "=", "-", "1", ",", "etag", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'languages'", ",", "base_url", "=", "self", ".", "_api", ")", "return", "self", ".", "_iter", "(", ...
Iterate over the programming languages used in the repository. :param int number: (optional), number of languages to return. Default: -1 returns all used languages :param str etag: (optional), ETag from a previous request to the same endpoint :returns: generator of tuple...
[ "Iterate", "over", "the", "programming", "languages", "used", "in", "the", "repository", "." ]
python
train
KartikTalwar/Duolingo
duolingo.py
https://github.com/KartikTalwar/Duolingo/blob/0f7e9a0d4bfa864ade82890fca3789679ef38bee/duolingo.py#L50-L63
def _login(self): """ Authenticate through ``https://www.duolingo.com/login``. """ login_url = "https://www.duolingo.com/login" data = {"login": self.username, "password": self.password} request = self._make_req(login_url, data) attempt = request.json() i...
[ "def", "_login", "(", "self", ")", ":", "login_url", "=", "\"https://www.duolingo.com/login\"", "data", "=", "{", "\"login\"", ":", "self", ".", "username", ",", "\"password\"", ":", "self", ".", "password", "}", "request", "=", "self", ".", "_make_req", "("...
Authenticate through ``https://www.duolingo.com/login``.
[ "Authenticate", "through", "https", ":", "//", "www", ".", "duolingo", ".", "com", "/", "login", "." ]
python
train
asascience-open/paegan-transport
paegan/transport/particles/particle.py
https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/particles/particle.py#L176-L201
def get_age(self, **kwargs): """ Returns the particlees age (how long it has been forced) in a variety of units. Rounded to 8 decimal places. Parameters: units (optional) = 'days' (default), 'hours', 'minutes', or 'seconds' """ try: units = kwargs...
[ "def", "get_age", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "units", "=", "kwargs", ".", "get", "(", "'units'", ",", "None", ")", "if", "units", "is", "None", ":", "return", "self", ".", "_age", "units", "=", "units", ".", "lowe...
Returns the particlees age (how long it has been forced) in a variety of units. Rounded to 8 decimal places. Parameters: units (optional) = 'days' (default), 'hours', 'minutes', or 'seconds'
[ "Returns", "the", "particlees", "age", "(", "how", "long", "it", "has", "been", "forced", ")", "in", "a", "variety", "of", "units", ".", "Rounded", "to", "8", "decimal", "places", "." ]
python
train
matsui528/nanopq
nanopq/pq.py
https://github.com/matsui528/nanopq/blob/1ce68cad2e3cab62b409e6dd63f676ed7b443ee9/nanopq/pq.py#L114-L135
def decode(self, codes): """Given PQ-codes, reconstruct original D-dimensional vectors approximately by fetching the codewords. Args: codes (np.ndarray): PQ-cdoes with shape=(N, M) and dtype=self.code_dtype. Each row is a PQ-code Returns: np.ndar...
[ "def", "decode", "(", "self", ",", "codes", ")", ":", "assert", "codes", ".", "ndim", "==", "2", "N", ",", "M", "=", "codes", ".", "shape", "assert", "M", "==", "self", ".", "M", "assert", "codes", ".", "dtype", "==", "self", ".", "code_dtype", "...
Given PQ-codes, reconstruct original D-dimensional vectors approximately by fetching the codewords. Args: codes (np.ndarray): PQ-cdoes with shape=(N, M) and dtype=self.code_dtype. Each row is a PQ-code Returns: np.ndarray: Reconstructed vectors with shap...
[ "Given", "PQ", "-", "codes", "reconstruct", "original", "D", "-", "dimensional", "vectors", "approximately", "by", "fetching", "the", "codewords", "." ]
python
train
pygridtools/gridmap
examples/map_reduce.py
https://github.com/pygridtools/gridmap/blob/be4fb1478ab8d19fa3acddecdf1a5d8bd3789127/examples/map_reduce.py#L39-L48
def sleep_walk(secs): ''' Pass the time by adding numbers until the specified number of seconds has elapsed. Intended as a replacement for ``time.sleep`` that doesn't leave the CPU idle (which will make the job seem like it's stalled). ''' start_time = datetime.now() num = 0 while (datet...
[ "def", "sleep_walk", "(", "secs", ")", ":", "start_time", "=", "datetime", ".", "now", "(", ")", "num", "=", "0", "while", "(", "datetime", ".", "now", "(", ")", "-", "start_time", ")", ".", "seconds", "<", "secs", ":", "num", "=", "num", "+", "1...
Pass the time by adding numbers until the specified number of seconds has elapsed. Intended as a replacement for ``time.sleep`` that doesn't leave the CPU idle (which will make the job seem like it's stalled).
[ "Pass", "the", "time", "by", "adding", "numbers", "until", "the", "specified", "number", "of", "seconds", "has", "elapsed", ".", "Intended", "as", "a", "replacement", "for", "time", ".", "sleep", "that", "doesn", "t", "leave", "the", "CPU", "idle", "(", ...
python
train
cthorey/pdsimage
pdsimage/PDS_Extractor.py
https://github.com/cthorey/pdsimage/blob/f71de6dfddd3d538d76da229b4b9605c40f3fbac/pdsimage/PDS_Extractor.py#L276-L293
def lat_id(self, line): ''' Return the corresponding latitude Args: line (int): Line number Returns: Correponding latitude in degree ''' if self.grid == 'WAC': lat = ((1 + self.LINE_PROJECTION_OFFSET - line) * self.MAP_SCAL...
[ "def", "lat_id", "(", "self", ",", "line", ")", ":", "if", "self", ".", "grid", "==", "'WAC'", ":", "lat", "=", "(", "(", "1", "+", "self", ".", "LINE_PROJECTION_OFFSET", "-", "line", ")", "*", "self", ".", "MAP_SCALE", "*", "1e-3", "/", "self", ...
Return the corresponding latitude Args: line (int): Line number Returns: Correponding latitude in degree
[ "Return", "the", "corresponding", "latitude" ]
python
train
ethereum/py-trie
trie/utils/binaries.py
https://github.com/ethereum/py-trie/blob/d33108d21b54d59ee311f61d978496c84a6f1f8b/trie/utils/binaries.py#L56-L66
def decode_to_bin_keypath(path): """ Decodes bytes into a sequence of 0s and 1s Used in decoding key path of a KV-NODE """ path = encode_to_bin(path) if path[0] == 1: path = path[4:] assert path[0:2] == PREFIX_00 padded_len = TWO_BITS.index(path[2:4]) return path[4+((4 - padd...
[ "def", "decode_to_bin_keypath", "(", "path", ")", ":", "path", "=", "encode_to_bin", "(", "path", ")", "if", "path", "[", "0", "]", "==", "1", ":", "path", "=", "path", "[", "4", ":", "]", "assert", "path", "[", "0", ":", "2", "]", "==", "PREFIX_...
Decodes bytes into a sequence of 0s and 1s Used in decoding key path of a KV-NODE
[ "Decodes", "bytes", "into", "a", "sequence", "of", "0s", "and", "1s", "Used", "in", "decoding", "key", "path", "of", "a", "KV", "-", "NODE" ]
python
train
bwohlberg/sporco
sporco/dictlrn/prlcnscdl.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/dictlrn/prlcnscdl.py#L205-L214
def ccmod_xstep(k): """Do the X step of the ccmod stage. The only parameter is the slice index `k` and there are no return values; all inputs and outputs are from and to global variables. """ YU = mp_D_Y - mp_D_U[k] b = mp_ZSf[k] + mp_drho * sl.rfftn(YU, None, mp_cri.axisN) Xf = sl.solvedbi...
[ "def", "ccmod_xstep", "(", "k", ")", ":", "YU", "=", "mp_D_Y", "-", "mp_D_U", "[", "k", "]", "b", "=", "mp_ZSf", "[", "k", "]", "+", "mp_drho", "*", "sl", ".", "rfftn", "(", "YU", ",", "None", ",", "mp_cri", ".", "axisN", ")", "Xf", "=", "sl"...
Do the X step of the ccmod stage. The only parameter is the slice index `k` and there are no return values; all inputs and outputs are from and to global variables.
[ "Do", "the", "X", "step", "of", "the", "ccmod", "stage", ".", "The", "only", "parameter", "is", "the", "slice", "index", "k", "and", "there", "are", "no", "return", "values", ";", "all", "inputs", "and", "outputs", "are", "from", "and", "to", "global",...
python
train
Opentrons/opentrons
api/src/opentrons/drivers/smoothie_drivers/driver_3_0.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/drivers/smoothie_drivers/driver_3_0.py#L724-L742
def _generate_current_command(self): ''' Returns a constructed GCode string that contains this driver's axis-current settings, plus a small delay to wait for those settings to take effect. ''' values = ['{}{}'.format(axis, value) for axis, value in sorte...
[ "def", "_generate_current_command", "(", "self", ")", ":", "values", "=", "[", "'{}{}'", ".", "format", "(", "axis", ",", "value", ")", "for", "axis", ",", "value", "in", "sorted", "(", "self", ".", "current", ".", "items", "(", ")", ")", "]", "curre...
Returns a constructed GCode string that contains this driver's axis-current settings, plus a small delay to wait for those settings to take effect.
[ "Returns", "a", "constructed", "GCode", "string", "that", "contains", "this", "driver", "s", "axis", "-", "current", "settings", "plus", "a", "small", "delay", "to", "wait", "for", "those", "settings", "to", "take", "effect", "." ]
python
train
APSL/transmanager
transmanager/manager.py
https://github.com/APSL/transmanager/blob/79157085840008e146b264521681913090197ed1/transmanager/manager.py#L647-L678
def create_translations_for_item_and_its_children(self, item, languages=None): """ Creates the translations from an item and defined languages and return the id's of the created tasks :param item: (master) :param languages: :return: """ if not self.master: ...
[ "def", "create_translations_for_item_and_its_children", "(", "self", ",", "item", ",", "languages", "=", "None", ")", ":", "if", "not", "self", ".", "master", ":", "self", ".", "set_master", "(", "item", ")", "if", "not", "languages", ":", "languages", "=", ...
Creates the translations from an item and defined languages and return the id's of the created tasks :param item: (master) :param languages: :return:
[ "Creates", "the", "translations", "from", "an", "item", "and", "defined", "languages", "and", "return", "the", "id", "s", "of", "the", "created", "tasks" ]
python
train
ecell/ecell4
ecell4/util/decorator.py
https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/decorator.py#L143-L194
def get_model(is_netfree=False, without_reset=False, seeds=None, effective=False): """ Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES`` and ``REACTIONRULES``. Parameters ---------- is_netfree : bool, optional Return ``NetfreeModel`` if True, and ``NetworkMode...
[ "def", "get_model", "(", "is_netfree", "=", "False", ",", "without_reset", "=", "False", ",", "seeds", "=", "None", ",", "effective", "=", "False", ")", ":", "try", ":", "if", "seeds", "is", "not", "None", "or", "is_netfree", ":", "m", "=", "ecell4_bas...
Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES`` and ``REACTIONRULES``. Parameters ---------- is_netfree : bool, optional Return ``NetfreeModel`` if True, and ``NetworkModel`` if else. Default is False. without_reset : bool, optional Do not reset ...
[ "Generate", "a", "model", "with", "parameters", "in", "the", "global", "scope", "SPECIES_ATTRIBUTES", "and", "REACTIONRULES", "." ]
python
train
PyCQA/astroid
astroid/brain/brain_functools.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/brain/brain_functools.py#L121-L130
def _looks_like_lru_cache(node): """Check if the given function node is decorated with lru_cache.""" if not node.decorators: return False for decorator in node.decorators.nodes: if not isinstance(decorator, astroid.Call): continue if _looks_like_functools_member(decorator...
[ "def", "_looks_like_lru_cache", "(", "node", ")", ":", "if", "not", "node", ".", "decorators", ":", "return", "False", "for", "decorator", "in", "node", ".", "decorators", ".", "nodes", ":", "if", "not", "isinstance", "(", "decorator", ",", "astroid", ".",...
Check if the given function node is decorated with lru_cache.
[ "Check", "if", "the", "given", "function", "node", "is", "decorated", "with", "lru_cache", "." ]
python
train
numba/llvmlite
llvmlite/binding/module.py
https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/module.py#L30-L45
def parse_bitcode(bitcode, context=None): """ Create Module from a LLVM *bitcode* (a bytes object). """ if context is None: context = get_global_context() buf = c_char_p(bitcode) bufsize = len(bitcode) with ffi.OutputString() as errmsg: mod = ModuleRef(ffi.lib.LLVMPY_ParseBit...
[ "def", "parse_bitcode", "(", "bitcode", ",", "context", "=", "None", ")", ":", "if", "context", "is", "None", ":", "context", "=", "get_global_context", "(", ")", "buf", "=", "c_char_p", "(", "bitcode", ")", "bufsize", "=", "len", "(", "bitcode", ")", ...
Create Module from a LLVM *bitcode* (a bytes object).
[ "Create", "Module", "from", "a", "LLVM", "*", "bitcode", "*", "(", "a", "bytes", "object", ")", "." ]
python
train
argaen/aiocache
aiocache/serializers/serializers.py
https://github.com/argaen/aiocache/blob/fdd282f37283ca04e22209f4d2ae4900f29e1688/aiocache/serializers/serializers.py#L178-L188
def loads(self, value): """ Deserialize value using ``msgpack.loads``. :param value: bytes :returns: obj """ raw = False if self.encoding == "utf-8" else True if value is None: return None return msgpack.loads(value, raw=raw, use_list=self.use...
[ "def", "loads", "(", "self", ",", "value", ")", ":", "raw", "=", "False", "if", "self", ".", "encoding", "==", "\"utf-8\"", "else", "True", "if", "value", "is", "None", ":", "return", "None", "return", "msgpack", ".", "loads", "(", "value", ",", "raw...
Deserialize value using ``msgpack.loads``. :param value: bytes :returns: obj
[ "Deserialize", "value", "using", "msgpack", ".", "loads", "." ]
python
train
jxtech/wechatpy
wechatpy/client/api/card.py
https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/card.py#L453-L471
def update_movie_ticket(self, code, ticket_class, show_time, duration, screening_room, seat_number, card_id=None): """ 更新电影票 """ ticket = { 'code': code, 'ticket_class': ticket_class, 'show_time': show_time, 'dur...
[ "def", "update_movie_ticket", "(", "self", ",", "code", ",", "ticket_class", ",", "show_time", ",", "duration", ",", "screening_room", ",", "seat_number", ",", "card_id", "=", "None", ")", ":", "ticket", "=", "{", "'code'", ":", "code", ",", "'ticket_class'"...
更新电影票
[ "更新电影票" ]
python
train
westonplatter/fast_arrow
fast_arrow/resources/option_position.py
https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/option_position.py#L47-L61
def mergein_marketdata_list(cls, client, option_positions): """ Fetch and merge in Marketdata for each option position """ ids = cls._extract_ids(option_positions) mds = OptionMarketdata.quotes_by_instrument_ids(client, ids) results = [] for op in option_position...
[ "def", "mergein_marketdata_list", "(", "cls", ",", "client", ",", "option_positions", ")", ":", "ids", "=", "cls", ".", "_extract_ids", "(", "option_positions", ")", "mds", "=", "OptionMarketdata", ".", "quotes_by_instrument_ids", "(", "client", ",", "ids", ")",...
Fetch and merge in Marketdata for each option position
[ "Fetch", "and", "merge", "in", "Marketdata", "for", "each", "option", "position" ]
python
train
sibirrer/lenstronomy
lenstronomy/LensModel/single_plane.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/single_plane.py#L171-L189
def mass_3d(self, r, kwargs, bool_list=None): """ computes the mass within a 3d sphere of radius r :param r: radius (in angular units) :param kwargs: list of keyword arguments of lens model parameters matching the lens model classes :param bool_list: list of bools that are part ...
[ "def", "mass_3d", "(", "self", ",", "r", ",", "kwargs", ",", "bool_list", "=", "None", ")", ":", "bool_list", "=", "self", ".", "_bool_list", "(", "bool_list", ")", "mass_3d", "=", "0", "for", "i", ",", "func", "in", "enumerate", "(", "self", ".", ...
computes the mass within a 3d sphere of radius r :param r: radius (in angular units) :param kwargs: list of keyword arguments of lens model parameters matching the lens model classes :param bool_list: list of bools that are part of the output :return: mass (in angular units, modulo epsi...
[ "computes", "the", "mass", "within", "a", "3d", "sphere", "of", "radius", "r" ]
python
train
mozilla/treeherder
treeherder/seta/update_job_priority.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/seta/update_job_priority.py#L38-L46
def _unique_key(job): """Return a key to query our uniqueness mapping system. This makes sure that we use a consistent key between our code and selecting jobs from the table. """ return unique_key(testtype=str(job['testtype']), buildtype=str(job['platform_option']), ...
[ "def", "_unique_key", "(", "job", ")", ":", "return", "unique_key", "(", "testtype", "=", "str", "(", "job", "[", "'testtype'", "]", ")", ",", "buildtype", "=", "str", "(", "job", "[", "'platform_option'", "]", ")", ",", "platform", "=", "str", "(", ...
Return a key to query our uniqueness mapping system. This makes sure that we use a consistent key between our code and selecting jobs from the table.
[ "Return", "a", "key", "to", "query", "our", "uniqueness", "mapping", "system", "." ]
python
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L320-L326
def remove(self, document_id, namespace, timestamp): """Removes documents from Solr The input is a python dictionary that represents a mongo document. """ self.solr.delete(id=u(document_id), commit=(self.auto_commit_interval == 0))
[ "def", "remove", "(", "self", ",", "document_id", ",", "namespace", ",", "timestamp", ")", ":", "self", ".", "solr", ".", "delete", "(", "id", "=", "u", "(", "document_id", ")", ",", "commit", "=", "(", "self", ".", "auto_commit_interval", "==", "0", ...
Removes documents from Solr The input is a python dictionary that represents a mongo document.
[ "Removes", "documents", "from", "Solr" ]
python
train
hugapi/hug
hug/output_format.py
https://github.com/hugapi/hug/blob/080901c81576657f82e2432fd4a82f1d0d2f370c/hug/output_format.py#L83-L92
def json_convert(*kinds): """Registers the wrapped method as a JSON converter for the provided types. NOTE: custom converters are always globally applied """ def register_json_converter(function): for kind in kinds: json_converters[kind] = function return function return...
[ "def", "json_convert", "(", "*", "kinds", ")", ":", "def", "register_json_converter", "(", "function", ")", ":", "for", "kind", "in", "kinds", ":", "json_converters", "[", "kind", "]", "=", "function", "return", "function", "return", "register_json_converter" ]
Registers the wrapped method as a JSON converter for the provided types. NOTE: custom converters are always globally applied
[ "Registers", "the", "wrapped", "method", "as", "a", "JSON", "converter", "for", "the", "provided", "types", "." ]
python
train
reingart/pyafipws
wslpg.py
https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wslpg.py#L2620-L2650
def ConsultarTiposOperacion(self, sep="||"): "Consulta tipo de Operación por Actividad." ops = [] ret = self.client.tipoActividadConsultar( auth={ 'token': self.Token, 'sign': self.Sign, 'cuit': self.Cuit, }, ...
[ "def", "ConsultarTiposOperacion", "(", "self", ",", "sep", "=", "\"||\"", ")", ":", "ops", "=", "[", "]", "ret", "=", "self", ".", "client", ".", "tipoActividadConsultar", "(", "auth", "=", "{", "'token'", ":", "self", ".", "Token", ",", "'sign'", ":",...
Consulta tipo de Operación por Actividad.
[ "Consulta", "tipo", "de", "Operación", "por", "Actividad", "." ]
python
train
mitsei/dlkit
dlkit/records/assessment/mecqbank/mecqbank_base_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/mecqbank/mecqbank_base_records.py#L199-L224
def _init_metadata(self): """stub""" super(SimpleDifficultyItemFormRecord, self)._init_metadata() self._min_string_length = None self._max_string_length = None self._difficulty_metadata = { 'element_id': Id(self.my_osid_object_form._authority, ...
[ "def", "_init_metadata", "(", "self", ")", ":", "super", "(", "SimpleDifficultyItemFormRecord", ",", "self", ")", ".", "_init_metadata", "(", ")", "self", ".", "_min_string_length", "=", "None", "self", ".", "_max_string_length", "=", "None", "self", ".", "_di...
stub
[ "stub" ]
python
train
FujiMakoto/IPS-Vagrant
ips_vagrant/commands/enable/__init__.py
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/commands/enable/__init__.py#L14-L40
def cli(ctx, dname, site): """ Enable the <site> under the specified <domain> """ assert isinstance(ctx, Context) dname = domain_parse(dname).hostname domain = Session.query(Domain).filter(Domain.name == dname).first() if not domain: click.secho('No such domain: {dn}'.format(dn=dnam...
[ "def", "cli", "(", "ctx", ",", "dname", ",", "site", ")", ":", "assert", "isinstance", "(", "ctx", ",", "Context", ")", "dname", "=", "domain_parse", "(", "dname", ")", ".", "hostname", "domain", "=", "Session", ".", "query", "(", "Domain", ")", ".",...
Enable the <site> under the specified <domain>
[ "Enable", "the", "<site", ">", "under", "the", "specified", "<domain", ">" ]
python
train
dmbee/seglearn
seglearn/split.py
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/split.py#L132-L184
def temporal_split(X, y, test_size=0.25): ''' Split time series or sequence data along the time axis. Test data is drawn from the end of each series / sequence Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like...
[ "def", "temporal_split", "(", "X", ",", "y", ",", "test_size", "=", "0.25", ")", ":", "if", "test_size", "<=", "0.", "or", "test_size", ">=", "1.", ":", "raise", "ValueError", "(", "\"temporal_split: test_size must be >= 0.0 and <= 1.0\"", "\" (was %.1f)\"", "%", ...
Split time series or sequence data along the time axis. Test data is drawn from the end of each series / sequence Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like shape [n_series, ] target vector test_siz...
[ "Split", "time", "series", "or", "sequence", "data", "along", "the", "time", "axis", ".", "Test", "data", "is", "drawn", "from", "the", "end", "of", "each", "series", "/", "sequence" ]
python
train
couchbase/couchbase-python-client
couchbase/mutation_state.py
https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/mutation_state.py#L100-L108
def decode(cls, s): """ Create a :class:`MutationState` from the encoded string :param s: The encoded string :return: A new MutationState restored from the string """ d = couchbase._from_json(s) o = MutationState() o._sv = d
[ "def", "decode", "(", "cls", ",", "s", ")", ":", "d", "=", "couchbase", ".", "_from_json", "(", "s", ")", "o", "=", "MutationState", "(", ")", "o", ".", "_sv", "=", "d" ]
Create a :class:`MutationState` from the encoded string :param s: The encoded string :return: A new MutationState restored from the string
[ "Create", "a", ":", "class", ":", "MutationState", "from", "the", "encoded", "string", ":", "param", "s", ":", "The", "encoded", "string", ":", "return", ":", "A", "new", "MutationState", "restored", "from", "the", "string" ]
python
train
lvieirajr/mongorest
mongorest/collection.py
https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/collection.py#L228-L262
def delete(self, **kwargs): """ Deletes the document if it is saved in the collection. """ if self.is_valid: if '_id' in self._document: to_delete = self.find_one({'_id': self._id}) if to_delete: before = self.before_delete...
[ "def", "delete", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "is_valid", ":", "if", "'_id'", "in", "self", ".", "_document", ":", "to_delete", "=", "self", ".", "find_one", "(", "{", "'_id'", ":", "self", ".", "_id", "}", "...
Deletes the document if it is saved in the collection.
[ "Deletes", "the", "document", "if", "it", "is", "saved", "in", "the", "collection", "." ]
python
train
uploadcare/pyuploadcare
pyuploadcare/ucare_cli/__init__.py
https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/ucare_cli/__init__.py#L38-L59
def _list(api_list_class, arg_namespace, **extra): """ A common function for building methods of the "list showing". """ if arg_namespace.starting_point: ordering_field = (arg_namespace.ordering or '').lstrip('-') if ordering_field in ('', 'datetime_uploaded', 'datetime_created'): ...
[ "def", "_list", "(", "api_list_class", ",", "arg_namespace", ",", "*", "*", "extra", ")", ":", "if", "arg_namespace", ".", "starting_point", ":", "ordering_field", "=", "(", "arg_namespace", ".", "ordering", "or", "''", ")", ".", "lstrip", "(", "'-'", ")",...
A common function for building methods of the "list showing".
[ "A", "common", "function", "for", "building", "methods", "of", "the", "list", "showing", "." ]
python
test
reingart/pyafipws
wslpg.py
https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wslpg.py#L2605-L2618
def BuscarLocalidades(self, cod_prov, cod_localidad=None, consultar=True): "Devuelve la localidad o la consulta en AFIP (uso interno)" # si no se especifíca cod_localidad, es util para reconstruir la cache import wslpg_datos as datos if not str(cod_localidad) in datos.LOCALIDADES and con...
[ "def", "BuscarLocalidades", "(", "self", ",", "cod_prov", ",", "cod_localidad", "=", "None", ",", "consultar", "=", "True", ")", ":", "# si no se especifíca cod_localidad, es util para reconstruir la cache", "import", "wslpg_datos", "as", "datos", "if", "not", "str", ...
Devuelve la localidad o la consulta en AFIP (uso interno)
[ "Devuelve", "la", "localidad", "o", "la", "consulta", "en", "AFIP", "(", "uso", "interno", ")" ]
python
train
matthew-sochor/transfer
transfer/project.py
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L20-L143
def configure(): ''' Configure the transfer environment and store ''' completer = Completer() readline.set_completer_delims('\t') readline.parse_and_bind('tab: complete') readline.set_completer(completer.path_completer) home = os.path.expanduser('~') if os.path.isfile(os.path.join(h...
[ "def", "configure", "(", ")", ":", "completer", "=", "Completer", "(", ")", "readline", ".", "set_completer_delims", "(", "'\\t'", ")", "readline", ".", "parse_and_bind", "(", "'tab: complete'", ")", "readline", ".", "set_completer", "(", "completer", ".", "pa...
Configure the transfer environment and store
[ "Configure", "the", "transfer", "environment", "and", "store" ]
python
train
heroku/sf-suds
suds/sudsobject.py
https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sudsobject.py#L379-L390
def exclude(self, d, item): """ check metadata for excluded items """ try: md = d.__metadata__ pmd = getattr(md, '__print__', None) if pmd is None: return False excludes = getattr(pmd, 'excludes', []) return ( item[0] in exclude...
[ "def", "exclude", "(", "self", ",", "d", ",", "item", ")", ":", "try", ":", "md", "=", "d", ".", "__metadata__", "pmd", "=", "getattr", "(", "md", ",", "'__print__'", ",", "None", ")", "if", "pmd", "is", "None", ":", "return", "False", "excludes", ...
check metadata for excluded items
[ "check", "metadata", "for", "excluded", "items" ]
python
train
gbiggs/rtctree
rtctree/component.py
https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/component.py#L440-L448
def members(self): '''Member components if this component is composite.''' with self._mutex: if not self._members: self._members = {} for o in self.organisations: # TODO: Search for these in the tree self._members[o.org_...
[ "def", "members", "(", "self", ")", ":", "with", "self", ".", "_mutex", ":", "if", "not", "self", ".", "_members", ":", "self", ".", "_members", "=", "{", "}", "for", "o", "in", "self", ".", "organisations", ":", "# TODO: Search for these in the tree", "...
Member components if this component is composite.
[ "Member", "components", "if", "this", "component", "is", "composite", "." ]
python
train
ubyssey/dispatch
dispatch/modules/integrations/integrations.py
https://github.com/ubyssey/dispatch/blob/8da6084fe61726f20e9cf675190480cfc45ee764/dispatch/modules/integrations/integrations.py#L91-L119
def callback(cls, user, query): """Receive OAuth callback request from Facebook.""" # Get settings for this integration settings = cls.get_settings(show_hidden=True) fb = Facebook() payload = { 'client_id': settings['client_id'], 'client_secret': settin...
[ "def", "callback", "(", "cls", ",", "user", ",", "query", ")", ":", "# Get settings for this integration", "settings", "=", "cls", ".", "get_settings", "(", "show_hidden", "=", "True", ")", "fb", "=", "Facebook", "(", ")", "payload", "=", "{", "'client_id'",...
Receive OAuth callback request from Facebook.
[ "Receive", "OAuth", "callback", "request", "from", "Facebook", "." ]
python
test
rootpy/rootpy
rootpy/tree/cut.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/cut.py#L250-L262
def latex(self): """ Returns a string representation for use in LaTeX """ if not self: return "" s = str(self) s = s.replace("==", " = ") s = s.replace("<=", " \leq ") s = s.replace(">=", " \geq ") s = s.replace("&&", r" \text{ and } ")...
[ "def", "latex", "(", "self", ")", ":", "if", "not", "self", ":", "return", "\"\"", "s", "=", "str", "(", "self", ")", "s", "=", "s", ".", "replace", "(", "\"==\"", ",", "\" = \"", ")", "s", "=", "s", ".", "replace", "(", "\"<=\"", ",", "\" \\le...
Returns a string representation for use in LaTeX
[ "Returns", "a", "string", "representation", "for", "use", "in", "LaTeX" ]
python
train
JasonKessler/scattertext
scattertext/TermDocMatrix.py
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/TermDocMatrix.py#L733-L751
def use_categories_as_metadata_and_replace_terms(self): ''' Returns a TermDocMatrix which is identical to self except the metadata values are now identical to the categories present and term-doc-matrix is now the metadata matrix. :return: TermDocMatrix ''' new_metadata_...
[ "def", "use_categories_as_metadata_and_replace_terms", "(", "self", ")", ":", "new_metadata_factory", "=", "CSRMatrixFactory", "(", ")", "for", "i", ",", "category_idx", "in", "enumerate", "(", "self", ".", "get_category_ids", "(", ")", ")", ":", "new_metadata_facto...
Returns a TermDocMatrix which is identical to self except the metadata values are now identical to the categories present and term-doc-matrix is now the metadata matrix. :return: TermDocMatrix
[ "Returns", "a", "TermDocMatrix", "which", "is", "identical", "to", "self", "except", "the", "metadata", "values", "are", "now", "identical", "to", "the", "categories", "present", "and", "term", "-", "doc", "-", "matrix", "is", "now", "the", "metadata", "matr...
python
train
bcbio/bcbio-nextgen
bcbio/distributed/runfn.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/runfn.py#L124-L143
def _add_resources(data, runtime): """Merge input resources with current CWL runtime parameters. """ if "config" not in data: data["config"] = {} # Convert input resources, which may be a JSON string resources = data.get("resources", {}) or {} if isinstance(resources, six.string_types) a...
[ "def", "_add_resources", "(", "data", ",", "runtime", ")", ":", "if", "\"config\"", "not", "in", "data", ":", "data", "[", "\"config\"", "]", "=", "{", "}", "# Convert input resources, which may be a JSON string", "resources", "=", "data", ".", "get", "(", "\"...
Merge input resources with current CWL runtime parameters.
[ "Merge", "input", "resources", "with", "current", "CWL", "runtime", "parameters", "." ]
python
train
gem/oq-engine
openquake/hazardlib/gsim/abrahamson_2015.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/abrahamson_2015.py#L355-L365
def _compute_forearc_backarc_term(self, C, sites, dists): """ Computes the forearc/backarc scaling term given by equation (4). """ f_faba = np.zeros_like(dists.rhypo) # Term only applies to backarc sites (F_FABA = 0. for forearc) max_dist = dists.rhypo[sites.backarc] ...
[ "def", "_compute_forearc_backarc_term", "(", "self", ",", "C", ",", "sites", ",", "dists", ")", ":", "f_faba", "=", "np", ".", "zeros_like", "(", "dists", ".", "rhypo", ")", "# Term only applies to backarc sites (F_FABA = 0. for forearc)", "max_dist", "=", "dists", ...
Computes the forearc/backarc scaling term given by equation (4).
[ "Computes", "the", "forearc", "/", "backarc", "scaling", "term", "given", "by", "equation", "(", "4", ")", "." ]
python
train
anchore/anchore
anchore/cli/__init__.py
https://github.com/anchore/anchore/blob/8a4d5b9708e27856312d303aae3f04f3c72039d6/anchore/cli/__init__.py#L101-L186
def main_entry(ctx, verbose, debug, quiet, json, plain, html, config_override): """ Anchore is a tool to analyze, query, and curate container images. The options at this top level control stdout and stderr verbosity and format. After installation, the first command run should be: 'anchore feeds lis...
[ "def", "main_entry", "(", "ctx", ",", "verbose", ",", "debug", ",", "quiet", ",", "json", ",", "plain", ",", "html", ",", "config_override", ")", ":", "# Load the config into the context object", "logfile", "=", "None", "debug_logfile", "=", "None", "try", ":"...
Anchore is a tool to analyze, query, and curate container images. The options at this top level control stdout and stderr verbosity and format. After installation, the first command run should be: 'anchore feeds list' to initialize the system and load feed data. High-level example flows: Initial...
[ "Anchore", "is", "a", "tool", "to", "analyze", "query", "and", "curate", "container", "images", ".", "The", "options", "at", "this", "top", "level", "control", "stdout", "and", "stderr", "verbosity", "and", "format", "." ]
python
train
saltstack/salt
salt/log/handlers/__init__.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/handlers/__init__.py#L73-L87
def sync_with_handlers(self, handlers=()): ''' Sync the stored log records to the provided log handlers. ''' if not handlers: return while self.__messages: record = self.__messages.pop(0) for handler in handlers: if handler.lev...
[ "def", "sync_with_handlers", "(", "self", ",", "handlers", "=", "(", ")", ")", ":", "if", "not", "handlers", ":", "return", "while", "self", ".", "__messages", ":", "record", "=", "self", ".", "__messages", ".", "pop", "(", "0", ")", "for", "handler", ...
Sync the stored log records to the provided log handlers.
[ "Sync", "the", "stored", "log", "records", "to", "the", "provided", "log", "handlers", "." ]
python
train
Erotemic/utool
utool/util_iter.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_iter.py#L17-L24
def wrap_iterable(obj): """ Returns: wrapped_obj, was_scalar """ was_scalar = not isiterable(obj) wrapped_obj = [obj] if was_scalar else obj return wrapped_obj, was_scalar
[ "def", "wrap_iterable", "(", "obj", ")", ":", "was_scalar", "=", "not", "isiterable", "(", "obj", ")", "wrapped_obj", "=", "[", "obj", "]", "if", "was_scalar", "else", "obj", "return", "wrapped_obj", ",", "was_scalar" ]
Returns: wrapped_obj, was_scalar
[ "Returns", ":", "wrapped_obj", "was_scalar" ]
python
train
nugget/python-insteonplm
insteonplm/messages/messageFlags.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/messageFlags.py#L256-L275
def _normalize(self, flags): """Take any format of flags and turn it into a hex string.""" norm = None if isinstance(flags, MessageFlags): norm = flags.bytes elif isinstance(flags, bytearray): norm = binascii.hexlify(flags) elif isinstance(flags, int): ...
[ "def", "_normalize", "(", "self", ",", "flags", ")", ":", "norm", "=", "None", "if", "isinstance", "(", "flags", ",", "MessageFlags", ")", ":", "norm", "=", "flags", ".", "bytes", "elif", "isinstance", "(", "flags", ",", "bytearray", ")", ":", "norm", ...
Take any format of flags and turn it into a hex string.
[ "Take", "any", "format", "of", "flags", "and", "turn", "it", "into", "a", "hex", "string", "." ]
python
train
matthieugouel/gibica
gibica/parser.py
https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/parser.py#L218-L230
def logical_or_expr(self): """ logical_or_expr: logical_and_expr ('or' logical_and_expr)* """ node = self.logical_and_expr() while self.token.nature == Nature.OR: token = self.token self._process(Nature.OR) node = BinaryOperation(left=node, o...
[ "def", "logical_or_expr", "(", "self", ")", ":", "node", "=", "self", ".", "logical_and_expr", "(", ")", "while", "self", ".", "token", ".", "nature", "==", "Nature", ".", "OR", ":", "token", "=", "self", ".", "token", "self", ".", "_process", "(", "...
logical_or_expr: logical_and_expr ('or' logical_and_expr)*
[ "logical_or_expr", ":", "logical_and_expr", "(", "or", "logical_and_expr", ")", "*" ]
python
train
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L59-L105
def register_rml_def(self, location_type, location, filename=None, **kwargs): """ Registers the rml file locations for easy access Args: ----- location_type: ['package_all', ...
[ "def", "register_rml_def", "(", "self", ",", "location_type", ",", "location", ",", "filename", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "location_type", "==", "'directory'", ":", "self", ".", "register_directory", "(", "location", ",", "*", "...
Registers the rml file locations for easy access Args: ----- location_type: ['package_all', 'package_file', 'directory', 'filepath'] location: The correlated location string based on the location...
[ "Registers", "the", "rml", "file", "locations", "for", "easy", "access" ]
python
train
soasme/rio
rio/models/utils.py
https://github.com/soasme/rio/blob/f722eb0ff4b0382bceaff77737f0b87cb78429e7/rio/models/utils.py#L143-L150
def get_data_by_slug_or_404(model, slug, kind='', **kwargs): """Wrap get_data_by_slug, abort 404 if missing data.""" data = get_data_by_slug(model, slug, kind, **kwargs) if not data: abort(404) return data
[ "def", "get_data_by_slug_or_404", "(", "model", ",", "slug", ",", "kind", "=", "''", ",", "*", "*", "kwargs", ")", ":", "data", "=", "get_data_by_slug", "(", "model", ",", "slug", ",", "kind", ",", "*", "*", "kwargs", ")", "if", "not", "data", ":", ...
Wrap get_data_by_slug, abort 404 if missing data.
[ "Wrap", "get_data_by_slug", "abort", "404", "if", "missing", "data", "." ]
python
train
fmfn/BayesianOptimization
examples/sklearn_example.py
https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/sklearn_example.py#L21-L33
def svc_cv(C, gamma, data, targets): """SVC cross validation. This function will instantiate a SVC classifier with parameters C and gamma. Combined with data and targets this will in turn be used to perform cross validation. The result of cross validation is returned. Our goal is to find combinati...
[ "def", "svc_cv", "(", "C", ",", "gamma", ",", "data", ",", "targets", ")", ":", "estimator", "=", "SVC", "(", "C", "=", "C", ",", "gamma", "=", "gamma", ",", "random_state", "=", "2", ")", "cval", "=", "cross_val_score", "(", "estimator", ",", "dat...
SVC cross validation. This function will instantiate a SVC classifier with parameters C and gamma. Combined with data and targets this will in turn be used to perform cross validation. The result of cross validation is returned. Our goal is to find combinations of C and gamma that maximizes the roc_au...
[ "SVC", "cross", "validation", "." ]
python
train
synw/gencharts
gencharts/__init__.py
https://github.com/synw/gencharts/blob/fa35604a9445b399bb4f91bc91af488e8e8208fd/gencharts/__init__.py#L89-L100
def _patch_json(self, json_data): """ Patch the Altair generated json to the newest Vega Lite spec """ json_data = json.loads(json_data) # add schema json_data["$schema"] = "https://vega.github.io/schema/vega-lite/2.0.0-beta.15.json" # add top level width and heig...
[ "def", "_patch_json", "(", "self", ",", "json_data", ")", ":", "json_data", "=", "json", ".", "loads", "(", "json_data", ")", "# add schema", "json_data", "[", "\"$schema\"", "]", "=", "\"https://vega.github.io/schema/vega-lite/2.0.0-beta.15.json\"", "# add top level wi...
Patch the Altair generated json to the newest Vega Lite spec
[ "Patch", "the", "Altair", "generated", "json", "to", "the", "newest", "Vega", "Lite", "spec" ]
python
test
nugget/python-insteonplm
insteonplm/states/onOff.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L751-L778
def _set_status_data(self, userdata): """Set status properties from userdata response. Response values: d3: On Mask d4: Off Mask d5: X10 House Code d6: X10 Unit d7: Ramp Rate d8: On-Level d9: LED Brightness ...
[ "def", "_set_status_data", "(", "self", ",", "userdata", ")", ":", "self", ".", "_on_mask", "=", "userdata", "[", "'d3'", "]", "self", ".", "_off_mask", "=", "userdata", "[", "'d4'", "]", "self", ".", "_x10_house_code", "=", "userdata", "[", "'d5'", "]",...
Set status properties from userdata response. Response values: d3: On Mask d4: Off Mask d5: X10 House Code d6: X10 Unit d7: Ramp Rate d8: On-Level d9: LED Brightness d10: Non-Toggle Mask d11: LED ...
[ "Set", "status", "properties", "from", "userdata", "response", "." ]
python
train
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L5665-L5685
def GetCachedPattern(self, patternId: int, cache: bool): """ Get a pattern by patternId. patternId: int, a value in class `PatternId`. Return a pattern if it supports the pattern else None. cache: bool, if True, store the pattern for later use, if False, get a new pattern by `sel...
[ "def", "GetCachedPattern", "(", "self", ",", "patternId", ":", "int", ",", "cache", ":", "bool", ")", ":", "if", "cache", ":", "pattern", "=", "self", ".", "_supportedPatterns", ".", "get", "(", "patternId", ",", "None", ")", "if", "pattern", ":", "ret...
Get a pattern by patternId. patternId: int, a value in class `PatternId`. Return a pattern if it supports the pattern else None. cache: bool, if True, store the pattern for later use, if False, get a new pattern by `self.GetPattern`.
[ "Get", "a", "pattern", "by", "patternId", ".", "patternId", ":", "int", "a", "value", "in", "class", "PatternId", ".", "Return", "a", "pattern", "if", "it", "supports", "the", "pattern", "else", "None", ".", "cache", ":", "bool", "if", "True", "store", ...
python
valid
twilio/twilio-python
twilio/rest/preview/sync/service/sync_map/sync_map_item.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/sync/service/sync_map/sync_map_item.py#L391-L406
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SyncMapItemContext for this SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "SyncMapItemContext", "(", "self", ".", "_version", ",", "service_sid", "=", "self", ".", "_solution", "[", "'service_sid'", "]", ",",...
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: SyncMapItemContext for this SyncMapItemInstance :rtype: twilio.rest.preview.sync.service.sync_map.sync_map_item.SyncMapItemContext
[ "Generate", "an", "instance", "context", "for", "the", "instance", "the", "context", "is", "capable", "of", "performing", "various", "actions", ".", "All", "instance", "actions", "are", "proxied", "to", "the", "context" ]
python
train
limodou/uliweb
uliweb/utils/common.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/common.py#L147-L187
def walk_dirs(path, include=None, include_ext=None, exclude=None, exclude_ext=None, recursion=True, file_only=False, use_default_pattern=True, patterns=None): """ path directory path resursion True will extract all sub module of mod """ default_exclude = ['.svn', '_svn', '.git'] ...
[ "def", "walk_dirs", "(", "path", ",", "include", "=", "None", ",", "include_ext", "=", "None", ",", "exclude", "=", "None", ",", "exclude_ext", "=", "None", ",", "recursion", "=", "True", ",", "file_only", "=", "False", ",", "use_default_pattern", "=", "...
path directory path resursion True will extract all sub module of mod
[ "path", "directory", "path", "resursion", "True", "will", "extract", "all", "sub", "module", "of", "mod" ]
python
train
O365/python-o365
O365/excel.py
https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/excel.py#L1402-L1410
def _get_range(self, endpoint_name): """ Returns a Range based on the endpoint name """ url = self.build_url(self._endpoints.get(endpoint_name)) response = self.session.get(url) if not response: return None data = response.json() return self.range_constructor...
[ "def", "_get_range", "(", "self", ",", "endpoint_name", ")", ":", "url", "=", "self", ".", "build_url", "(", "self", ".", "_endpoints", ".", "get", "(", "endpoint_name", ")", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", ")", ...
Returns a Range based on the endpoint name
[ "Returns", "a", "Range", "based", "on", "the", "endpoint", "name" ]
python
train
markovmodel/msmtools
msmtools/estimation/api.py
https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/estimation/api.py#L458-L510
def largest_connected_set(C, directed=True): r"""Largest connected component for a directed graph with edge-weights given by the count matrix. Parameters ---------- C : scipy.sparse matrix Count matrix specifying edge weights. directed : bool, optional Whether to compute connecte...
[ "def", "largest_connected_set", "(", "C", ",", "directed", "=", "True", ")", ":", "if", "isdense", "(", "C", ")", ":", "return", "sparse", ".", "connectivity", ".", "largest_connected_set", "(", "csr_matrix", "(", "C", ")", ",", "directed", "=", "directed"...
r"""Largest connected component for a directed graph with edge-weights given by the count matrix. Parameters ---------- C : scipy.sparse matrix Count matrix specifying edge weights. directed : bool, optional Whether to compute connected components for a directed or undirected...
[ "r", "Largest", "connected", "component", "for", "a", "directed", "graph", "with", "edge", "-", "weights", "given", "by", "the", "count", "matrix", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/controllers/menu_bar.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/controllers/menu_bar.py#L379-L388
def remove_all_callbacks(self): """ Remove all callbacks registered to the shortcut manager :return: """ for action in self.registered_shortcut_callbacks.keys(): for callback in self.registered_shortcut_callbacks[action]: self.shortcut_manager.remove_c...
[ "def", "remove_all_callbacks", "(", "self", ")", ":", "for", "action", "in", "self", ".", "registered_shortcut_callbacks", ".", "keys", "(", ")", ":", "for", "callback", "in", "self", ".", "registered_shortcut_callbacks", "[", "action", "]", ":", "self", ".", ...
Remove all callbacks registered to the shortcut manager :return:
[ "Remove", "all", "callbacks", "registered", "to", "the", "shortcut", "manager", ":", "return", ":" ]
python
train
m32/endesive
endesive/pdf/fpdf/fpdf.py
https://github.com/m32/endesive/blob/973091dc69847fe2df594c80ac9235a8d08460ff/endesive/pdf/fpdf/fpdf.py#L1037-L1042
def set_x(self, x): "Set x position" if(x>=0): self.x=x else: self.x=self.w+x
[ "def", "set_x", "(", "self", ",", "x", ")", ":", "if", "(", "x", ">=", "0", ")", ":", "self", ".", "x", "=", "x", "else", ":", "self", ".", "x", "=", "self", ".", "w", "+", "x" ]
Set x position
[ "Set", "x", "position" ]
python
train
ska-sa/katcp-python
katcp/core.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/core.py#L295-L312
def format_argument(self, arg): """Format a Message argument to a string""" if isinstance(arg, float): return repr(arg) elif isinstance(arg, bool): return str(int(arg)) else: try: return str(arg) except UnicodeEncodeError: ...
[ "def", "format_argument", "(", "self", ",", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "float", ")", ":", "return", "repr", "(", "arg", ")", "elif", "isinstance", "(", "arg", ",", "bool", ")", ":", "return", "str", "(", "int", "(", "arg"...
Format a Message argument to a string
[ "Format", "a", "Message", "argument", "to", "a", "string" ]
python
train
SoCo/SoCo
soco/data_structures.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/data_structures.py#L151-L189
def from_element(cls, element): """Set the resource properties from a ``<res>`` element. Args: element (~xml.etree.ElementTree.Element): The ``<res>`` element """ def _int_helper(name): """Try to convert the name attribute to an int, or None.""" ...
[ "def", "from_element", "(", "cls", ",", "element", ")", ":", "def", "_int_helper", "(", "name", ")", ":", "\"\"\"Try to convert the name attribute to an int, or None.\"\"\"", "result", "=", "element", ".", "get", "(", "name", ")", "if", "result", "is", "not", "N...
Set the resource properties from a ``<res>`` element. Args: element (~xml.etree.ElementTree.Element): The ``<res>`` element
[ "Set", "the", "resource", "properties", "from", "a", "<res", ">", "element", "." ]
python
train
angr/angr
angr/engines/soot/values/thisref.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/engines/soot/values/thisref.py#L74-L86
def load_field(self, state, field_name, field_type): """ Load a field of a given object, without resolving hierachy :param state: angr state where we want to load the object attribute :type SimState :param field_name: name of the attribute :type str :param field_...
[ "def", "load_field", "(", "self", ",", "state", ",", "field_name", ",", "field_type", ")", ":", "field_ref", "=", "SimSootValue_InstanceFieldRef", "(", "self", ".", "heap_alloc_id", ",", "self", ".", "type", ",", "field_name", ",", "field_type", ")", "return",...
Load a field of a given object, without resolving hierachy :param state: angr state where we want to load the object attribute :type SimState :param field_name: name of the attribute :type str :param field_type: type of the attribute :type str
[ "Load", "a", "field", "of", "a", "given", "object", "without", "resolving", "hierachy" ]
python
train
google/grr
grr/server/grr_response_server/aff4_objects/cronjobs.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/cronjobs.py#L138-L164
def RunOnce(self, token=None, force=False, names=None): """Tries to lock and run cron jobs. Args: token: security token force: If True, force a run names: List of job names to run. If unset, run them all """ names = names or self.ListJobs(token=token) urns = [self.CRON_JOBS_PATH....
[ "def", "RunOnce", "(", "self", ",", "token", "=", "None", ",", "force", "=", "False", ",", "names", "=", "None", ")", ":", "names", "=", "names", "or", "self", ".", "ListJobs", "(", "token", "=", "token", ")", "urns", "=", "[", "self", ".", "CRON...
Tries to lock and run cron jobs. Args: token: security token force: If True, force a run names: List of job names to run. If unset, run them all
[ "Tries", "to", "lock", "and", "run", "cron", "jobs", "." ]
python
train
nickmckay/LiPD-utilities
Python/lipd/lpd_noaa.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L889-L918
def __get_overall_data(self, x): """ (recursive) Collect all "sensorGenus" and "sensorSpecies" fields, set data to self :param any x: Any data type :return none: """ if isinstance(x, dict): if "sensorGenus" in x: if x["sensorGenus"] and x["sens...
[ "def", "__get_overall_data", "(", "self", ",", "x", ")", ":", "if", "isinstance", "(", "x", ",", "dict", ")", ":", "if", "\"sensorGenus\"", "in", "x", ":", "if", "x", "[", "\"sensorGenus\"", "]", "and", "x", "[", "\"sensorGenus\"", "]", "not", "in", ...
(recursive) Collect all "sensorGenus" and "sensorSpecies" fields, set data to self :param any x: Any data type :return none:
[ "(", "recursive", ")", "Collect", "all", "sensorGenus", "and", "sensorSpecies", "fields", "set", "data", "to", "self", ":", "param", "any", "x", ":", "Any", "data", "type", ":", "return", "none", ":" ]
python
train
trailofbits/manticore
manticore/ethereum/detectors.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/detectors.py#L377-L392
def _unsigned_sub_overflow(state, a, b): """ Sign extend the value to 512 bits and check the result can be represented in 256. Following there is a 32 bit excerpt of this condition: a - b ffffffff bfffffff 80000001 00000000 00000001 3ffffffff 7fffffff ffffffff True ...
[ "def", "_unsigned_sub_overflow", "(", "state", ",", "a", ",", "b", ")", ":", "cond", "=", "Operators", ".", "UGT", "(", "b", ",", "a", ")", "return", "cond" ]
Sign extend the value to 512 bits and check the result can be represented in 256. Following there is a 32 bit excerpt of this condition: a - b ffffffff bfffffff 80000001 00000000 00000001 3ffffffff 7fffffff ffffffff True True True False True True True bff...
[ "Sign", "extend", "the", "value", "to", "512", "bits", "and", "check", "the", "result", "can", "be", "represented", "in", "256", ".", "Following", "there", "is", "a", "32", "bit", "excerpt", "of", "this", "condition", ":" ]
python
valid
apache/incubator-heron
third_party/python/cpplint/cpplint.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/third_party/python/cpplint/cpplint.py#L5059-L5085
def CheckPrintf(filename, clean_lines, linenum, error): """Check for printf related issues. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ l...
[ "def", "CheckPrintf", "(", "filename", ",", "clean_lines", ",", "linenum", ",", "error", ")", ":", "line", "=", "clean_lines", ".", "elided", "[", "linenum", "]", "# When snprintf is used, the second argument shouldn't be a literal.", "match", "=", "Search", "(", "r...
Check for printf related issues. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
[ "Check", "for", "printf", "related", "issues", "." ]
python
valid
BerkeleyAutomation/autolab_core
autolab_core/transformations.py
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/transformations.py#L1649-L1662
def concatenate_matrices(*matrices): """Return concatenation of series of transformation matrices. >>> M = numpy.random.rand(16).reshape((4, 4)) - 0.5 >>> numpy.allclose(M, concatenate_matrices(M)) True >>> numpy.allclose(numpy.dot(M, M.T), concatenate_matrices(M, M.T)) True """ M = nu...
[ "def", "concatenate_matrices", "(", "*", "matrices", ")", ":", "M", "=", "numpy", ".", "identity", "(", "4", ")", "for", "i", "in", "matrices", ":", "M", "=", "numpy", ".", "dot", "(", "M", ",", "i", ")", "return", "M" ]
Return concatenation of series of transformation matrices. >>> M = numpy.random.rand(16).reshape((4, 4)) - 0.5 >>> numpy.allclose(M, concatenate_matrices(M)) True >>> numpy.allclose(numpy.dot(M, M.T), concatenate_matrices(M, M.T)) True
[ "Return", "concatenation", "of", "series", "of", "transformation", "matrices", "." ]
python
train
raphaelvallat/pingouin
pingouin/plotting.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/plotting.py#L321-L486
def qqplot(x, dist='norm', sparams=(), confidence=.95, figsize=(5, 4), ax=None): """Quantile-Quantile plot. Parameters ---------- x : array_like Sample data. dist : str or stats.distributions instance, optional Distribution or distribution function name. The default is 'n...
[ "def", "qqplot", "(", "x", ",", "dist", "=", "'norm'", ",", "sparams", "=", "(", ")", ",", "confidence", "=", ".95", ",", "figsize", "=", "(", "5", ",", "4", ")", ",", "ax", "=", "None", ")", ":", "if", "isinstance", "(", "dist", ",", "str", ...
Quantile-Quantile plot. Parameters ---------- x : array_like Sample data. dist : str or stats.distributions instance, optional Distribution or distribution function name. The default is 'norm' for a normal probability plot. Objects that look enough like a `scipy.stats.di...
[ "Quantile", "-", "Quantile", "plot", "." ]
python
train
quantumlib/Cirq
cirq/circuits/text_diagram_drawer.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L239-L307
def render(self, horizontal_spacing: int = 1, vertical_spacing: int = 1, crossing_char: str = None, use_unicode_characters: bool = True) -> str: """Outputs text containing the diagram.""" block_diagram = BlockDiagramDrawer() w = self....
[ "def", "render", "(", "self", ",", "horizontal_spacing", ":", "int", "=", "1", ",", "vertical_spacing", ":", "int", "=", "1", ",", "crossing_char", ":", "str", "=", "None", ",", "use_unicode_characters", ":", "bool", "=", "True", ")", "->", "str", ":", ...
Outputs text containing the diagram.
[ "Outputs", "text", "containing", "the", "diagram", "." ]
python
train
HazardDede/dictmentor
dictmentor/extensions.py
https://github.com/HazardDede/dictmentor/blob/f50ca26ed04f7a924cde6e4d464c4f6ccba4e320/dictmentor/extensions.py#L220-L225
def _config(self) -> ExtensionConfig: """ Tells the processor to look for the specified pattern in node key only. Returns: The scanner configuration. """ return dict(pattern=self.__pattern__, search_in_keys=True, search_in_values=False)
[ "def", "_config", "(", "self", ")", "->", "ExtensionConfig", ":", "return", "dict", "(", "pattern", "=", "self", ".", "__pattern__", ",", "search_in_keys", "=", "True", ",", "search_in_values", "=", "False", ")" ]
Tells the processor to look for the specified pattern in node key only. Returns: The scanner configuration.
[ "Tells", "the", "processor", "to", "look", "for", "the", "specified", "pattern", "in", "node", "key", "only", ".", "Returns", ":", "The", "scanner", "configuration", "." ]
python
train
sernst/cauldron
cauldron/session/exposed.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L50-L52
def shared(self) -> typing.Union[None, SharedCache]: """The shared display object associated with this project.""" return self._project.shared if self._project else None
[ "def", "shared", "(", "self", ")", "->", "typing", ".", "Union", "[", "None", ",", "SharedCache", "]", ":", "return", "self", ".", "_project", ".", "shared", "if", "self", ".", "_project", "else", "None" ]
The shared display object associated with this project.
[ "The", "shared", "display", "object", "associated", "with", "this", "project", "." ]
python
train
git-afsantos/bonsai
bonsai/model.py
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L1350-L1354
def get_branches(self): """Return a list with the conditional branch and the default branch.""" if self.else_branch: return [self.then_branch, self.else_branch] return [self.then_branch]
[ "def", "get_branches", "(", "self", ")", ":", "if", "self", ".", "else_branch", ":", "return", "[", "self", ".", "then_branch", ",", "self", ".", "else_branch", "]", "return", "[", "self", ".", "then_branch", "]" ]
Return a list with the conditional branch and the default branch.
[ "Return", "a", "list", "with", "the", "conditional", "branch", "and", "the", "default", "branch", "." ]
python
train
softlayer/softlayer-python
SoftLayer/CLI/file/snapshot/order.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/file/snapshot/order.py#L27-L53
def cli(env, volume_id, capacity, tier, upgrade): """Order snapshot space for a file storage volume.""" file_manager = SoftLayer.FileStorageManager(env.client) if tier is not None: tier = float(tier) try: order = file_manager.order_snapshot_space( volume_id, cap...
[ "def", "cli", "(", "env", ",", "volume_id", ",", "capacity", ",", "tier", ",", "upgrade", ")", ":", "file_manager", "=", "SoftLayer", ".", "FileStorageManager", "(", "env", ".", "client", ")", "if", "tier", "is", "not", "None", ":", "tier", "=", "float...
Order snapshot space for a file storage volume.
[ "Order", "snapshot", "space", "for", "a", "file", "storage", "volume", "." ]
python
train
Azure/azure-cli-extensions
src/interactive/azext_interactive/azclishell/app.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/interactive/azext_interactive/azclishell/app.py#L431-L468
def example_repl(self, text, example, start_index, continue_flag): """ REPL for interactive tutorials """ if start_index: start_index = start_index + 1 cmd = ' '.join(text.split()[:start_index]) example_cli = CommandLineInterface( application=self.crea...
[ "def", "example_repl", "(", "self", ",", "text", ",", "example", ",", "start_index", ",", "continue_flag", ")", ":", "if", "start_index", ":", "start_index", "=", "start_index", "+", "1", "cmd", "=", "' '", ".", "join", "(", "text", ".", "split", "(", ...
REPL for interactive tutorials
[ "REPL", "for", "interactive", "tutorials" ]
python
train
apache/spark
python/pyspark/ml/param/__init__.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/ml/param/__init__.py#L138-L146
def toListInt(value): """ Convert a value to list of ints, if possible. """ if TypeConverters._can_convert_to_list(value): value = TypeConverters.toList(value) if all(map(lambda v: TypeConverters._is_integer(v), value)): return [int(v) for v in val...
[ "def", "toListInt", "(", "value", ")", ":", "if", "TypeConverters", ".", "_can_convert_to_list", "(", "value", ")", ":", "value", "=", "TypeConverters", ".", "toList", "(", "value", ")", "if", "all", "(", "map", "(", "lambda", "v", ":", "TypeConverters", ...
Convert a value to list of ints, if possible.
[ "Convert", "a", "value", "to", "list", "of", "ints", "if", "possible", "." ]
python
train
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L7333-L7337
def xpathEval(self, str): """Evaluate the XPath Location Path in the given context. """ ret = libxml2mod.xmlXPathEval(str, self._o) if ret is None:raise xpathError('xmlXPathEval() failed') return xpathObjectRet(ret)
[ "def", "xpathEval", "(", "self", ",", "str", ")", ":", "ret", "=", "libxml2mod", ".", "xmlXPathEval", "(", "str", ",", "self", ".", "_o", ")", "if", "ret", "is", "None", ":", "raise", "xpathError", "(", "'xmlXPathEval() failed'", ")", "return", "xpathObj...
Evaluate the XPath Location Path in the given context.
[ "Evaluate", "the", "XPath", "Location", "Path", "in", "the", "given", "context", "." ]
python
train
aws/aws-encryption-sdk-python
src/aws_encryption_sdk/internal/formatting/deserialize.py
https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/deserialize.py#L52-L73
def validate_header(header, header_auth, raw_header, data_key): """Validates the header using the header authentication data. :param header: Deserialized header :type header: aws_encryption_sdk.structures.MessageHeader :param header_auth: Deserialized header auth :type header_auth: aws_encryption_s...
[ "def", "validate_header", "(", "header", ",", "header_auth", ",", "raw_header", ",", "data_key", ")", ":", "_LOGGER", ".", "debug", "(", "\"Starting header validation\"", ")", "try", ":", "decrypt", "(", "algorithm", "=", "header", ".", "algorithm", ",", "key"...
Validates the header using the header authentication data. :param header: Deserialized header :type header: aws_encryption_sdk.structures.MessageHeader :param header_auth: Deserialized header auth :type header_auth: aws_encryption_sdk.internal.structures.MessageHeaderAuthentication :type stream: io...
[ "Validates", "the", "header", "using", "the", "header", "authentication", "data", "." ]
python
train
fulfilio/python-magento
magento/catalog.py
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L253-L270
def info(self, product, store_view=None, attributes=None, identifierType=None): """ Retrieve product data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defin...
[ "def", "info", "(", "self", ",", "product", ",", "store_view", "=", "None", ",", "attributes", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product.info'", ",", "[", "product", ",", "store_view", ...
Retrieve product data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter. ...
[ "Retrieve", "product", "data" ]
python
train
dereneaton/ipyrad
ipyrad/analysis/tetrad2.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/tetrad2.py#L1169-L1278
def store_equal(self): """ Takes a tetrad class object and populates array with random quartets sampled equally among splits of the tree so that deep splits are not overrepresented relative to rare splits, like those near the tips. """ with h5py.File(self.database.input, 'a') as io5: ...
[ "def", "store_equal", "(", "self", ")", ":", "with", "h5py", ".", "File", "(", "self", ".", "database", ".", "input", ",", "'a'", ")", "as", "io5", ":", "fillsets", "=", "io5", "[", "\"quartets\"", "]", "## require guidetree", "if", "not", "os", ".", ...
Takes a tetrad class object and populates array with random quartets sampled equally among splits of the tree so that deep splits are not overrepresented relative to rare splits, like those near the tips.
[ "Takes", "a", "tetrad", "class", "object", "and", "populates", "array", "with", "random", "quartets", "sampled", "equally", "among", "splits", "of", "the", "tree", "so", "that", "deep", "splits", "are", "not", "overrepresented", "relative", "to", "rare", "spli...
python
valid
adafruit/Adafruit_Python_MCP9808
Adafruit_MCP9808/MCP9808.py
https://github.com/adafruit/Adafruit_Python_MCP9808/blob/5524605a15cfce5668f259de72c88d5be74565f4/Adafruit_MCP9808/MCP9808.py#L67-L76
def begin(self): """Start taking temperature measurements. Returns True if the device is intialized, False otherwise. """ # Check manufacturer and device ID match expected values. mid = self._device.readU16BE(MCP9808_REG_MANUF_ID) did = self._device.readU16BE(MCP9808_REG_DEVICE_ID) self._logger.debug('Re...
[ "def", "begin", "(", "self", ")", ":", "# Check manufacturer and device ID match expected values.", "mid", "=", "self", ".", "_device", ".", "readU16BE", "(", "MCP9808_REG_MANUF_ID", ")", "did", "=", "self", ".", "_device", ".", "readU16BE", "(", "MCP9808_REG_DEVICE...
Start taking temperature measurements. Returns True if the device is intialized, False otherwise.
[ "Start", "taking", "temperature", "measurements", ".", "Returns", "True", "if", "the", "device", "is", "intialized", "False", "otherwise", "." ]
python
train
yougov/pmxbot
pmxbot/commands.py
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L28-L51
def google(rest): "Look up a phrase on google" API_URL = 'https://www.googleapis.com/customsearch/v1?' try: key = pmxbot.config['Google API key'] except KeyError: return "Configure 'Google API key' in config" # Use a custom search that searches everything normally # http://stackoverflow.com/a/11206266/70170 ...
[ "def", "google", "(", "rest", ")", ":", "API_URL", "=", "'https://www.googleapis.com/customsearch/v1?'", "try", ":", "key", "=", "pmxbot", ".", "config", "[", "'Google API key'", "]", "except", "KeyError", ":", "return", "\"Configure 'Google API key' in config\"", "# ...
Look up a phrase on google
[ "Look", "up", "a", "phrase", "on", "google" ]
python
train
timstaley/voeventdb
voeventdb/server/database/models.py
https://github.com/timstaley/voeventdb/blob/e37b176d65fced4ca4f059109a95d6974bb8a091/voeventdb/server/database/models.py#L18-L26
def _grab_xpath(root, xpath, converter=lambda x: x): """ XML convenience - grabs the first element at xpath if present, else returns None. """ elements = root.xpath(xpath) if elements: return converter(str(elements[0])) else: return None
[ "def", "_grab_xpath", "(", "root", ",", "xpath", ",", "converter", "=", "lambda", "x", ":", "x", ")", ":", "elements", "=", "root", ".", "xpath", "(", "xpath", ")", "if", "elements", ":", "return", "converter", "(", "str", "(", "elements", "[", "0", ...
XML convenience - grabs the first element at xpath if present, else returns None.
[ "XML", "convenience", "-", "grabs", "the", "first", "element", "at", "xpath", "if", "present", "else", "returns", "None", "." ]
python
train
vinci1it2000/schedula
schedula/utils/dsp.py
https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L275-L334
def selector(keys, dictionary, copy=False, output_type='dict', allow_miss=False): """ Selects the chosen dictionary keys from the given dictionary. :param keys: Keys to select. :type keys: list, tuple, set :param dictionary: A dictionary. :type dictionary: dict ...
[ "def", "selector", "(", "keys", ",", "dictionary", ",", "copy", "=", "False", ",", "output_type", "=", "'dict'", ",", "allow_miss", "=", "False", ")", ":", "if", "not", "allow_miss", ":", "# noinspection PyUnusedLocal", "def", "check", "(", "key", ")", ":"...
Selects the chosen dictionary keys from the given dictionary. :param keys: Keys to select. :type keys: list, tuple, set :param dictionary: A dictionary. :type dictionary: dict :param copy: If True the output contains deep-copies of the values. :type copy: bool :pa...
[ "Selects", "the", "chosen", "dictionary", "keys", "from", "the", "given", "dictionary", "." ]
python
train
LLNL/scraper
scraper/util.py
https://github.com/LLNL/scraper/blob/881a316e4c04dfa5a9cf491b7c7f9f997a7c56ea/scraper/util.py#L209-L220
def _prune_dict_null_str(dictionary): """ Prune the "None" or emptry string values from dictionary items """ for key, value in list(dictionary.items()): if value is None or str(value) == '': del dictionary[key] if isinstance(value, dict): dictionary[key] = _prune...
[ "def", "_prune_dict_null_str", "(", "dictionary", ")", ":", "for", "key", ",", "value", "in", "list", "(", "dictionary", ".", "items", "(", ")", ")", ":", "if", "value", "is", "None", "or", "str", "(", "value", ")", "==", "''", ":", "del", "dictionar...
Prune the "None" or emptry string values from dictionary items
[ "Prune", "the", "None", "or", "emptry", "string", "values", "from", "dictionary", "items" ]
python
test
elifesciences/elife-tools
elifetools/utils.py
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L268-L282
def node_contents_str(tag): """ Return the contents of a tag, including it's children, as a string. Does not include the root/parent of the tag. """ if not tag: return None tag_string = '' for child_tag in tag.children: if isinstance(child_tag, Comment): # Beautif...
[ "def", "node_contents_str", "(", "tag", ")", ":", "if", "not", "tag", ":", "return", "None", "tag_string", "=", "''", "for", "child_tag", "in", "tag", ".", "children", ":", "if", "isinstance", "(", "child_tag", ",", "Comment", ")", ":", "# BeautifulSoup do...
Return the contents of a tag, including it's children, as a string. Does not include the root/parent of the tag.
[ "Return", "the", "contents", "of", "a", "tag", "including", "it", "s", "children", "as", "a", "string", ".", "Does", "not", "include", "the", "root", "/", "parent", "of", "the", "tag", "." ]
python
train