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
PmagPy/PmagPy
pmagpy/ipmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/ipmag.py#L6411-L6424
def parse_fits(self, fit_name): '''USE PARSE_ALL_FITS unless otherwise necessary Isolate fits by the name of the fit; we also set 'specimen_tilt_correction' to zero in order to only include data in geographic coordinates - THIS NEEDS TO BE GENERALIZED ''' fits = self.fits.loc[sel...
[ "def", "parse_fits", "(", "self", ",", "fit_name", ")", ":", "fits", "=", "self", ".", "fits", ".", "loc", "[", "self", ".", "fits", ".", "specimen_comp_name", "==", "fit_name", "]", ".", "loc", "[", "self", ".", "fits", ".", "specimen_tilt_correction", ...
USE PARSE_ALL_FITS unless otherwise necessary Isolate fits by the name of the fit; we also set 'specimen_tilt_correction' to zero in order to only include data in geographic coordinates - THIS NEEDS TO BE GENERALIZED
[ "USE", "PARSE_ALL_FITS", "unless", "otherwise", "necessary", "Isolate", "fits", "by", "the", "name", "of", "the", "fit", ";", "we", "also", "set", "specimen_tilt_correction", "to", "zero", "in", "order", "to", "only", "include", "data", "in", "geographic", "co...
python
train
hustcc/wrapcache
wrapcache/__init__.py
https://github.com/hustcc/wrapcache/blob/3c6f52bb81a278e1dd60c27abe87d169cb4395aa/wrapcache/__init__.py#L41-L48
def get(key, adapter = MemoryAdapter): ''' get the cache value ''' try: return pickle.loads(adapter().get(key)) except CacheExpiredException: return None
[ "def", "get", "(", "key", ",", "adapter", "=", "MemoryAdapter", ")", ":", "try", ":", "return", "pickle", ".", "loads", "(", "adapter", "(", ")", ".", "get", "(", "key", ")", ")", "except", "CacheExpiredException", ":", "return", "None" ]
get the cache value
[ "get", "the", "cache", "value" ]
python
train
satellogic/telluric
telluric/georaster.py
https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/georaster.py#L1723-L1731
def mask_by_value(self, nodata): """ Return raster with a mask calculated based on provided value. Only pixels with value=nodata will be masked. :param nodata: value of the pixels that should be masked :return: GeoRaster2 """ return self.copy_with(image=np.ma.mas...
[ "def", "mask_by_value", "(", "self", ",", "nodata", ")", ":", "return", "self", ".", "copy_with", "(", "image", "=", "np", ".", "ma", ".", "masked_array", "(", "self", ".", "image", ".", "data", ",", "mask", "=", "self", ".", "image", ".", "data", ...
Return raster with a mask calculated based on provided value. Only pixels with value=nodata will be masked. :param nodata: value of the pixels that should be masked :return: GeoRaster2
[ "Return", "raster", "with", "a", "mask", "calculated", "based", "on", "provided", "value", ".", "Only", "pixels", "with", "value", "=", "nodata", "will", "be", "masked", "." ]
python
train
cherrypy/cheroot
cheroot/ssl/pyopenssl.py
https://github.com/cherrypy/cheroot/blob/2af3b1798d66da697957480d3a8b4831a405770b/cheroot/ssl/pyopenssl.py#L139-L145
def send(self, *args, **kwargs): """Send some part of message to the socket.""" return self._safe_call( False, super(SSLFileobjectMixin, self).send, *args, **kwargs )
[ "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_safe_call", "(", "False", ",", "super", "(", "SSLFileobjectMixin", ",", "self", ")", ".", "send", ",", "*", "args", ",", "*", "*", "kwargs", ...
Send some part of message to the socket.
[ "Send", "some", "part", "of", "message", "to", "the", "socket", "." ]
python
train
shoebot/shoebot
shoebot/data/bezier.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L372-L408
def point(self, t, segments=None): """ Returns the PathElement at time t (0.0-1.0) on the path. Returns coordinates for point at t on the path. Gets the length of the path, based on the length of each curve and line in the path. Determines in what segment t falls...
[ "def", "point", "(", "self", ",", "t", ",", "segments", "=", "None", ")", ":", "# Originally from nodebox-gl", "if", "len", "(", "self", ".", "_elements", ")", "==", "0", ":", "raise", "PathError", "(", "\"The given path is empty\"", ")", "if", "self", "."...
Returns the PathElement at time t (0.0-1.0) on the path. Returns coordinates for point at t on the path. Gets the length of the path, based on the length of each curve and line in the path. Determines in what segment t falls. Gets the point on that segment. When you supp...
[ "Returns", "the", "PathElement", "at", "time", "t", "(", "0", ".", "0", "-", "1", ".", "0", ")", "on", "the", "path", "." ]
python
valid
luckydonald/pytgbot
pytgbot/bot.py
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/bot.py#L3286-L3392
def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None, switch_pm_text=None, switch_pm_parameter=None): """ Use this method to send answers to an inline query. On success, True is returned. No more than 50 results p...
[ "def", "answer_inline_query", "(", "self", ",", "inline_query_id", ",", "results", ",", "cache_time", "=", "None", ",", "is_personal", "=", "None", ",", "next_offset", "=", "None", ",", "switch_pm_text", "=", "None", ",", "switch_pm_parameter", "=", "None", ")...
Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed. https://core.telegram.org/bots/api#answerinlinequery Parameters: :param inline_query_id: Unique identifier for the answered query :type inline_que...
[ "Use", "this", "method", "to", "send", "answers", "to", "an", "inline", "query", ".", "On", "success", "True", "is", "returned", ".", "No", "more", "than", "50", "results", "per", "query", "are", "allowed", "." ]
python
train
amsehili/auditok
auditok/io.py
https://github.com/amsehili/auditok/blob/df6eb1d80f8cd9034be47b24869ce59b74f5f4db/auditok/io.py#L261-L274
def append_data(self, data_buffer): """ Append data to this audio stream :Parameters: `data_buffer` : str, basestring, Bytes a buffer with a length multiple of (sample_width * channels) """ if len(data_buffer) % (self.sample_width * self.channels) != 0: ...
[ "def", "append_data", "(", "self", ",", "data_buffer", ")", ":", "if", "len", "(", "data_buffer", ")", "%", "(", "self", ".", "sample_width", "*", "self", ".", "channels", ")", "!=", "0", ":", "raise", "ValueError", "(", "\"length of data_buffer must be a mu...
Append data to this audio stream :Parameters: `data_buffer` : str, basestring, Bytes a buffer with a length multiple of (sample_width * channels)
[ "Append", "data", "to", "this", "audio", "stream" ]
python
train
althonos/pronto
pronto/parser/owl.py
https://github.com/althonos/pronto/blob/a768adcba19fb34f26f67cde4a03d317f932c274/pronto/parser/owl.py#L164-L171
def _extract_obo_relation(cls, rawterm): """Extract the relationships defined in the rawterm. """ relations = {} if 'subClassOf' in rawterm: relations[Relationship('is_a')] = l = [] l.extend(map(cls._get_id_from_url, rawterm.pop('subClassOf'))) return rela...
[ "def", "_extract_obo_relation", "(", "cls", ",", "rawterm", ")", ":", "relations", "=", "{", "}", "if", "'subClassOf'", "in", "rawterm", ":", "relations", "[", "Relationship", "(", "'is_a'", ")", "]", "=", "l", "=", "[", "]", "l", ".", "extend", "(", ...
Extract the relationships defined in the rawterm.
[ "Extract", "the", "relationships", "defined", "in", "the", "rawterm", "." ]
python
train
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/utils/winmanifest.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/utils/winmanifest.py#L884-L887
def update_resources(self, dstpath, names=None, languages=None): """ Update or add manifest resource in dll/exe file dstpath """ UpdateManifestResourcesFromXML(dstpath, self.toprettyxml(), names, languages)
[ "def", "update_resources", "(", "self", ",", "dstpath", ",", "names", "=", "None", ",", "languages", "=", "None", ")", ":", "UpdateManifestResourcesFromXML", "(", "dstpath", ",", "self", ".", "toprettyxml", "(", ")", ",", "names", ",", "languages", ")" ]
Update or add manifest resource in dll/exe file dstpath
[ "Update", "or", "add", "manifest", "resource", "in", "dll", "/", "exe", "file", "dstpath" ]
python
train
cltk/cltk
cltk/corpus/greek/tlg/parse_tlg_indices.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/corpus/greek/tlg/parse_tlg_indices.py#L43-L50
def select_authors_by_epithet(query): """Pass exact name (case insensitive) of epithet name, return ordered set of author ids. """ for epithet, ids in AUTHOR_EPITHET.items(): if epithet.casefold() == query.casefold(): return set(ids)
[ "def", "select_authors_by_epithet", "(", "query", ")", ":", "for", "epithet", ",", "ids", "in", "AUTHOR_EPITHET", ".", "items", "(", ")", ":", "if", "epithet", ".", "casefold", "(", ")", "==", "query", ".", "casefold", "(", ")", ":", "return", "set", "...
Pass exact name (case insensitive) of epithet name, return ordered set of author ids.
[ "Pass", "exact", "name", "(", "case", "insensitive", ")", "of", "epithet", "name", "return", "ordered", "set", "of", "author", "ids", "." ]
python
train
danielhrisca/asammdf
asammdf/blocks/utils.py
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L503-L555
def fmt_to_datatype_v4(fmt, shape, array=False): """convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and c...
[ "def", "fmt_to_datatype_v4", "(", "fmt", ",", "shape", ",", "array", "=", "False", ")", ":", "size", "=", "fmt", ".", "itemsize", "*", "8", "if", "not", "array", "and", "shape", "[", "1", ":", "]", "and", "fmt", ".", "itemsize", "==", "1", "and", ...
convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and channel array Returns ------- data_type, siz...
[ "convert", "numpy", "dtype", "format", "string", "to", "mdf", "version", "4", "channel", "data", "type", "and", "size" ]
python
train
docker/docker-py
docker/models/containers.py
https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/models/containers.py#L98-L112
def attach_socket(self, **kwargs): """ Like :py:meth:`attach`, but returns the underlying socket-like object for the HTTP request. Args: params (dict): Dictionary of request parameters (e.g. ``stdout``, ``stderr``, ``stream``). ws (bool): Use webs...
[ "def", "attach_socket", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "client", ".", "api", ".", "attach_socket", "(", "self", ".", "id", ",", "*", "*", "kwargs", ")" ]
Like :py:meth:`attach`, but returns the underlying socket-like object for the HTTP request. Args: params (dict): Dictionary of request parameters (e.g. ``stdout``, ``stderr``, ``stream``). ws (bool): Use websockets instead of raw HTTP. Raises: ...
[ "Like", ":", "py", ":", "meth", ":", "attach", "but", "returns", "the", "underlying", "socket", "-", "like", "object", "for", "the", "HTTP", "request", "." ]
python
train
tamasgal/km3pipe
km3pipe/db.py
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L894-L902
def base(self, du): """Return the base CLB for a given DU""" parameter = 'base' if parameter not in self._by: self._by[parameter] = {} for clb in self.upi.values(): if clb.floor == 0: self._by[parameter][clb.du] = clb return sel...
[ "def", "base", "(", "self", ",", "du", ")", ":", "parameter", "=", "'base'", "if", "parameter", "not", "in", "self", ".", "_by", ":", "self", ".", "_by", "[", "parameter", "]", "=", "{", "}", "for", "clb", "in", "self", ".", "upi", ".", "values",...
Return the base CLB for a given DU
[ "Return", "the", "base", "CLB", "for", "a", "given", "DU" ]
python
train
zetaops/pyoko
pyoko/db/adapter/db_riak.py
https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/adapter/db_riak.py#L182-L196
def _clear(self, wait): """ clear outs the all content of current bucket only for development purposes """ i = 0 t1 = time.time() for k in self.bucket.get_keys(): i += 1 self.bucket.get(k).delete() print("\nDELETION TOOK: %s" % roun...
[ "def", "_clear", "(", "self", ",", "wait", ")", ":", "i", "=", "0", "t1", "=", "time", ".", "time", "(", ")", "for", "k", "in", "self", ".", "bucket", ".", "get_keys", "(", ")", ":", "i", "+=", "1", "self", ".", "bucket", ".", "get", "(", "...
clear outs the all content of current bucket only for development purposes
[ "clear", "outs", "the", "all", "content", "of", "current", "bucket", "only", "for", "development", "purposes" ]
python
train
JamesPHoughton/pysd
pysd/py_backend/utils.py
https://github.com/JamesPHoughton/pysd/blob/bf1b1d03954e9ba5acac9ba4f1ada7cd93352eda/pysd/py_backend/utils.py#L138-L291
def make_python_identifier(string, namespace=None, reserved_words=None, convert='drop', handle='force'): """ Takes an arbitrary string and creates a valid Python identifier. If the input string is in the namespace, return its value. If the python identifier created is alread...
[ "def", "make_python_identifier", "(", "string", ",", "namespace", "=", "None", ",", "reserved_words", "=", "None", ",", "convert", "=", "'drop'", ",", "handle", "=", "'force'", ")", ":", "if", "namespace", "is", "None", ":", "namespace", "=", "dict", "(", ...
Takes an arbitrary string and creates a valid Python identifier. If the input string is in the namespace, return its value. If the python identifier created is already in the namespace, but the input string is not (ie, two similar strings resolve to the same python identifier) or if the identifie...
[ "Takes", "an", "arbitrary", "string", "and", "creates", "a", "valid", "Python", "identifier", "." ]
python
train
yyuu/botornado
boto/pyami/installers/ubuntu/installer.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/pyami/installers/ubuntu/installer.py#L82-L88
def create_user(self, user): """ Create a user on the local system """ self.run("useradd -m %s" % user) usr = getpwnam(user) return usr
[ "def", "create_user", "(", "self", ",", "user", ")", ":", "self", ".", "run", "(", "\"useradd -m %s\"", "%", "user", ")", "usr", "=", "getpwnam", "(", "user", ")", "return", "usr" ]
Create a user on the local system
[ "Create", "a", "user", "on", "the", "local", "system" ]
python
train
chaoss/grimoirelab-perceval
perceval/backends/core/askbot.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/askbot.py#L362-L390
def parse_question_container(html_question): """Parse the question info container of a given HTML question. The method parses the information available in the question information container. The container can have up to 2 elements: the first one contains the information related with the...
[ "def", "parse_question_container", "(", "html_question", ")", ":", "container_info", "=", "{", "}", "bs_question", "=", "bs4", ".", "BeautifulSoup", "(", "html_question", ",", "\"html.parser\"", ")", "question", "=", "AskbotParser", ".", "_find_question_container", ...
Parse the question info container of a given HTML question. The method parses the information available in the question information container. The container can have up to 2 elements: the first one contains the information related with the user who generated the question and the date (i...
[ "Parse", "the", "question", "info", "container", "of", "a", "given", "HTML", "question", "." ]
python
test
ccubed/Shosetsu
Shosetsu/Parsing.py
https://github.com/ccubed/Shosetsu/blob/eba01c058100ec8806129b11a2859f3126a1b101/Shosetsu/Parsing.py#L16-L35
async def parse_release_results(soup): """ Parse Releases search pages. :param soup: The BS4 class object :return: A list of dictionaries containing a release dictionary. This is the same as the one returned in get_novel. It contains a Date released, Platform, Ages group and Name. """ ...
[ "async", "def", "parse_release_results", "(", "soup", ")", ":", "soup", "=", "list", "(", "soup", ".", "find_all", "(", "'table'", ",", "class_", "=", "'stripe'", ")", "[", "0", "]", ".", "children", ")", "[", "1", ":", "]", "releases", "=", "[", "...
Parse Releases search pages. :param soup: The BS4 class object :return: A list of dictionaries containing a release dictionary. This is the same as the one returned in get_novel. It contains a Date released, Platform, Ages group and Name.
[ "Parse", "Releases", "search", "pages", "." ]
python
test
ttinies/sc2ladderMgmt
sc2ladderMgmt/functions.py
https://github.com/ttinies/sc2ladderMgmt/blob/230292e18c54e43129c162116bbdf743b3e9dcf1/sc2ladderMgmt/functions.py#L18-L23
def addLadder(settings): """define a new Ladder setting and save to disk file""" ladder = Ladder(settings) ladder.save() getKnownLadders()[ladder.name] = ladder return ladder
[ "def", "addLadder", "(", "settings", ")", ":", "ladder", "=", "Ladder", "(", "settings", ")", "ladder", ".", "save", "(", ")", "getKnownLadders", "(", ")", "[", "ladder", ".", "name", "]", "=", "ladder", "return", "ladder" ]
define a new Ladder setting and save to disk file
[ "define", "a", "new", "Ladder", "setting", "and", "save", "to", "disk", "file" ]
python
train
PyThaiNLP/pythainlp
pythainlp/tools/__init__.py
https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/tools/__init__.py#L21-L28
def get_pythainlp_data_path() -> str: """ Return full path where PyThaiNLP keeps its (downloaded) data """ path = os.path.join(os.path.expanduser("~"), PYTHAINLP_DATA_DIR) if not os.path.exists(path): os.makedirs(path) return path
[ "def", "get_pythainlp_data_path", "(", ")", "->", "str", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "PYTHAINLP_DATA_DIR", ")", "if", "not", "os", ".", "path", ".", "exists", "(...
Return full path where PyThaiNLP keeps its (downloaded) data
[ "Return", "full", "path", "where", "PyThaiNLP", "keeps", "its", "(", "downloaded", ")", "data" ]
python
train
runfalk/spans
spans/types.py
https://github.com/runfalk/spans/blob/59ed73407a569c3be86cfdb4b8f438cb8c794540/spans/types.py#L972-L1006
def offset(self, offset): """ Shift the range to the left or right with the given offset >>> intrange(0, 5).offset(5) intrange([5,10)) >>> intrange(5, 10).offset(-5) intrange([0,5)) >>> intrange.empty().offset(5) intrange(empty) ...
[ "def", "offset", "(", "self", ",", "offset", ")", ":", "# If range is empty it can't be offset", "if", "not", "self", ":", "return", "self", "offset_type", "=", "self", ".", "type", "if", "self", ".", "offset_type", "is", "None", "else", "self", ".", "offset...
Shift the range to the left or right with the given offset >>> intrange(0, 5).offset(5) intrange([5,10)) >>> intrange(5, 10).offset(-5) intrange([0,5)) >>> intrange.empty().offset(5) intrange(empty) Note that range objects are immutable a...
[ "Shift", "the", "range", "to", "the", "left", "or", "right", "with", "the", "given", "offset" ]
python
train
SheffieldML/GPy
GPy/inference/latent_function_inference/posterior.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/inference/latent_function_inference/posterior.py#L199-L209
def woodbury_vector(self): """ Woodbury vector in the gaussian likelihood case only is defined as $$ (K_{xx} + \Sigma)^{-1}Y \Sigma := \texttt{Likelihood.variance / Approximate likelihood covariance} $$ """ if self._woodbury_vector is None: sel...
[ "def", "woodbury_vector", "(", "self", ")", ":", "if", "self", ".", "_woodbury_vector", "is", "None", ":", "self", ".", "_woodbury_vector", ",", "_", "=", "dpotrs", "(", "self", ".", "K_chol", ",", "self", ".", "mean", "-", "self", ".", "_prior_mean", ...
Woodbury vector in the gaussian likelihood case only is defined as $$ (K_{xx} + \Sigma)^{-1}Y \Sigma := \texttt{Likelihood.variance / Approximate likelihood covariance} $$
[ "Woodbury", "vector", "in", "the", "gaussian", "likelihood", "case", "only", "is", "defined", "as", "$$", "(", "K_", "{", "xx", "}", "+", "\\", "Sigma", ")", "^", "{", "-", "1", "}", "Y", "\\", "Sigma", ":", "=", "\\", "texttt", "{", "Likelihood", ...
python
train
rootpy/rootpy
rootpy/plotting/utils.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/utils.py#L197-L378
def get_limits(plottables, xpadding=0, ypadding=0.1, xerror_in_padding=True, yerror_in_padding=True, snap=True, logx=False, logy=False, logx_crop_value=1E-5, logy_crop_value=1E-5, ...
[ "def", "get_limits", "(", "plottables", ",", "xpadding", "=", "0", ",", "ypadding", "=", "0.1", ",", "xerror_in_padding", "=", "True", ",", "yerror_in_padding", "=", "True", ",", "snap", "=", "True", ",", "logx", "=", "False", ",", "logy", "=", "False", ...
Get the axes limits that should be used for a 1D histogram, graph, or stack of histograms. Parameters ---------- plottables : Hist, Graph, HistStack, or list of such objects The object(s) for which visually pleasing plot boundaries are requested. xpadding : float or 2-tuple, optio...
[ "Get", "the", "axes", "limits", "that", "should", "be", "used", "for", "a", "1D", "histogram", "graph", "or", "stack", "of", "histograms", "." ]
python
train
saltstack/salt
salt/modules/extfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/extfs.py#L222-L285
def dump(device, args=None): ''' Return all contents of dumpe2fs for a specified device CLI Example: .. code-block:: bash salt '*' extfs.dump /dev/sda1 ''' cmd = 'dumpe2fs {0}'.format(device) if args: cmd = cmd + ' -' + args ret = {'attributes': {}, 'blocks': {}} o...
[ "def", "dump", "(", "device", ",", "args", "=", "None", ")", ":", "cmd", "=", "'dumpe2fs {0}'", ".", "format", "(", "device", ")", "if", "args", ":", "cmd", "=", "cmd", "+", "' -'", "+", "args", "ret", "=", "{", "'attributes'", ":", "{", "}", ","...
Return all contents of dumpe2fs for a specified device CLI Example: .. code-block:: bash salt '*' extfs.dump /dev/sda1
[ "Return", "all", "contents", "of", "dumpe2fs", "for", "a", "specified", "device" ]
python
train
dereneaton/ipyrad
ipyrad/analysis/bucky.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/analysis/bucky.py#L466-L538
def run_bucky(self, ipyclient, force=False, quiet=False, subname=False): """ Runs bucky for a given set of parameters and stores the result to the ipa.bucky object. The results will be stored by default with the name '{name}-{alpha}' unless a argument is passed for 'subname' to ...
[ "def", "run_bucky", "(", "self", ",", "ipyclient", ",", "force", "=", "False", ",", "quiet", "=", "False", ",", "subname", "=", "False", ")", ":", "## check for existing results files", "minidir", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", ...
Runs bucky for a given set of parameters and stores the result to the ipa.bucky object. The results will be stored by default with the name '{name}-{alpha}' unless a argument is passed for 'subname' to customize the output name. Parameters: ----------- subname (str): ...
[ "Runs", "bucky", "for", "a", "given", "set", "of", "parameters", "and", "stores", "the", "result", "to", "the", "ipa", ".", "bucky", "object", ".", "The", "results", "will", "be", "stored", "by", "default", "with", "the", "name", "{", "name", "}", "-",...
python
valid
mogproject/mog-commons-python
src/mog_commons/command.py
https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/command.py#L70-L85
def capture_command(args, shell=False, cwd=None, env=None, stdin=None, cmd_encoding='utf-8'): """ Execute external command and capture output :param args: command line arguments : [string] :param shell: True when using shell : boolean :param cwd: working directory : string :param env: environmen...
[ "def", "capture_command", "(", "args", ",", "shell", "=", "False", ",", "cwd", "=", "None", ",", "env", "=", "None", ",", "stdin", "=", "None", ",", "cmd_encoding", "=", "'utf-8'", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "__convert_args", ...
Execute external command and capture output :param args: command line arguments : [string] :param shell: True when using shell : boolean :param cwd: working directory : string :param env: environment variables : dict :param stdin: standard input :param cmd_encoding: command line encoding: string...
[ "Execute", "external", "command", "and", "capture", "output", ":", "param", "args", ":", "command", "line", "arguments", ":", "[", "string", "]", ":", "param", "shell", ":", "True", "when", "using", "shell", ":", "boolean", ":", "param", "cwd", ":", "wor...
python
train
iamjarret/pystockfish
pystockfish.py
https://github.com/iamjarret/pystockfish/blob/ae34a4b4d29c577c888b72691fcf0cb5a89b1792/pystockfish.py#L235-L254
def _bestmove_get_info(text): """ Parse stockfish evaluation output as dictionary. Examples of input: "info depth 2 seldepth 3 multipv 1 score cp -656 nodes 43 nps 43000 tbhits 0 \ time 1 pv g7g6 h3g3 g6f7" "info depth 10 seldepth 12 multipv 1 score mate 5 nodes 2378 n...
[ "def", "_bestmove_get_info", "(", "text", ")", ":", "result_dict", "=", "Engine", ".", "_get_info_pv", "(", "text", ")", "result_dict", ".", "update", "(", "Engine", ".", "_get_info_score", "(", "text", ")", ")", "single_value_fields", "=", "[", "'depth'", "...
Parse stockfish evaluation output as dictionary. Examples of input: "info depth 2 seldepth 3 multipv 1 score cp -656 nodes 43 nps 43000 tbhits 0 \ time 1 pv g7g6 h3g3 g6f7" "info depth 10 seldepth 12 multipv 1 score mate 5 nodes 2378 nps 1189000 tbhits 0 \ time 2 pv h3g3 g6f7 ...
[ "Parse", "stockfish", "evaluation", "output", "as", "dictionary", "." ]
python
train
noahbenson/neuropythy
neuropythy/util/core.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/util/core.py#L1344-L1367
def to_curve_spline(obj): ''' to_curve_spline(obj) obj if obj is a curve spline and otherwise attempts to coerce obj into a curve spline, raising an error if it cannot. ''' if is_curve_spline(obj): return obj elif is_tuple(obj) and len(obj) == 2: (crds,opts) = obj else: ...
[ "def", "to_curve_spline", "(", "obj", ")", ":", "if", "is_curve_spline", "(", "obj", ")", ":", "return", "obj", "elif", "is_tuple", "(", "obj", ")", "and", "len", "(", "obj", ")", "==", "2", ":", "(", "crds", ",", "opts", ")", "=", "obj", "else", ...
to_curve_spline(obj) obj if obj is a curve spline and otherwise attempts to coerce obj into a curve spline, raising an error if it cannot.
[ "to_curve_spline", "(", "obj", ")", "obj", "if", "obj", "is", "a", "curve", "spline", "and", "otherwise", "attempts", "to", "coerce", "obj", "into", "a", "curve", "spline", "raising", "an", "error", "if", "it", "cannot", "." ]
python
train
HttpRunner/HttpRunner
httprunner/utils.py
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/utils.py#L584-L595
def dump_logs(json_data, project_mapping, tag_name): """ dump tests data to json file. the dumped file is located in PWD/logs folder. Args: json_data (list/dict): json data to dump project_mapping (dict): project info tag_name (str): tag name, loaded/parsed/summary """ ...
[ "def", "dump_logs", "(", "json_data", ",", "project_mapping", ",", "tag_name", ")", ":", "pwd_dir_path", ",", "dump_file_name", "=", "_prepare_dump_info", "(", "project_mapping", ",", "tag_name", ")", "dump_json_file", "(", "json_data", ",", "pwd_dir_path", ",", "...
dump tests data to json file. the dumped file is located in PWD/logs folder. Args: json_data (list/dict): json data to dump project_mapping (dict): project info tag_name (str): tag name, loaded/parsed/summary
[ "dump", "tests", "data", "to", "json", "file", ".", "the", "dumped", "file", "is", "located", "in", "PWD", "/", "logs", "folder", "." ]
python
train
CI-WATER/gsshapy
gsshapy/orm/spn.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/spn.py#L181-L199
def _createSjunc(self, sjuncs): """ Create GSSHAPY SuperJunction Objects Method """ for sjunc in sjuncs: # Create GSSHAPY SuperJunction object superJunction = SuperJunction(sjuncNumber=sjunc['sjuncNumber'], groundSurfaceE...
[ "def", "_createSjunc", "(", "self", ",", "sjuncs", ")", ":", "for", "sjunc", "in", "sjuncs", ":", "# Create GSSHAPY SuperJunction object", "superJunction", "=", "SuperJunction", "(", "sjuncNumber", "=", "sjunc", "[", "'sjuncNumber'", "]", ",", "groundSurfaceElev", ...
Create GSSHAPY SuperJunction Objects Method
[ "Create", "GSSHAPY", "SuperJunction", "Objects", "Method" ]
python
train
gccxml/pygccxml
pygccxml/parser/project_reader.py
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L373-L417
def read_xml(self, file_configuration): """parses C++ code, defined on the file_configurations and returns GCCXML generated file content""" xml_file_path = None delete_xml_file = True fc = file_configuration reader = source_reader.source_reader_t( self.__conf...
[ "def", "read_xml", "(", "self", ",", "file_configuration", ")", ":", "xml_file_path", "=", "None", "delete_xml_file", "=", "True", "fc", "=", "file_configuration", "reader", "=", "source_reader", ".", "source_reader_t", "(", "self", ".", "__config", ",", "None",...
parses C++ code, defined on the file_configurations and returns GCCXML generated file content
[ "parses", "C", "++", "code", "defined", "on", "the", "file_configurations", "and", "returns", "GCCXML", "generated", "file", "content" ]
python
train
frictionlessdata/tableschema-pandas-py
tableschema_pandas/mapper.py
https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/mapper.py#L89-L117
def convert_type(self, type): """Convert type to Pandas """ # Mapping mapping = { 'any': np.dtype('O'), 'array': np.dtype(list), 'boolean': np.dtype(bool), 'date': np.dtype('O'), 'datetime': np.dtype('datetime64[ns]'), ...
[ "def", "convert_type", "(", "self", ",", "type", ")", ":", "# Mapping", "mapping", "=", "{", "'any'", ":", "np", ".", "dtype", "(", "'O'", ")", ",", "'array'", ":", "np", ".", "dtype", "(", "list", ")", ",", "'boolean'", ":", "np", ".", "dtype", ...
Convert type to Pandas
[ "Convert", "type", "to", "Pandas" ]
python
train
glitchassassin/lackey
lackey/RegionMatching.py
https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/RegionMatching.py#L1293-L1297
def saveLastScreenImage(self): """ Saves the last image taken on this region's screen to a temporary file """ bitmap = self.getLastScreenImage() _, target_file = tempfile.mkstemp(".png") cv2.imwrite(target_file, bitmap)
[ "def", "saveLastScreenImage", "(", "self", ")", ":", "bitmap", "=", "self", ".", "getLastScreenImage", "(", ")", "_", ",", "target_file", "=", "tempfile", ".", "mkstemp", "(", "\".png\"", ")", "cv2", ".", "imwrite", "(", "target_file", ",", "bitmap", ")" ]
Saves the last image taken on this region's screen to a temporary file
[ "Saves", "the", "last", "image", "taken", "on", "this", "region", "s", "screen", "to", "a", "temporary", "file" ]
python
train
softlayer/softlayer-python
SoftLayer/CLI/order/place_quote.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/order/place_quote.py#L30-L96
def cli(env, package_keyname, location, preset, name, send_email, complex_type, extras, order_items): """Place a quote. This CLI command is used for creating a quote of the specified package in the given location (denoted by a datacenter's long name). Orders made via the CLI can then be conver...
[ "def", "cli", "(", "env", ",", "package_keyname", ",", "location", ",", "preset", ",", "name", ",", "send_email", ",", "complex_type", ",", "extras", ",", "order_items", ")", ":", "manager", "=", "ordering", ".", "OrderingManager", "(", "env", ".", "client...
Place a quote. This CLI command is used for creating a quote of the specified package in the given location (denoted by a datacenter's long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_quote() with the same keynames. P...
[ "Place", "a", "quote", "." ]
python
train
twisted/txacme
src/txacme/client.py
https://github.com/twisted/txacme/blob/9478381cc63c6d53d14bf8db8407c923f472989a/src/txacme/client.py#L700-L748
def _check_response(cls, response, content_type=JSON_CONTENT_TYPE): """ Check response content and its type. .. note:: Unlike :mod:`acme.client`, checking is strict. :param bytes content_type: Expected Content-Type response header. If the response Content-Typ...
[ "def", "_check_response", "(", "cls", ",", "response", ",", "content_type", "=", "JSON_CONTENT_TYPE", ")", ":", "def", "_got_failure", "(", "f", ")", ":", "f", ".", "trap", "(", "ValueError", ")", "return", "None", "def", "_got_json", "(", "jobj", ")", "...
Check response content and its type. .. note:: Unlike :mod:`acme.client`, checking is strict. :param bytes content_type: Expected Content-Type response header. If the response Content-Type does not match, :exc:`ClientError` is raised. :raises .ServerErro...
[ "Check", "response", "content", "and", "its", "type", "." ]
python
train
chaoss/grimoirelab-sortinghat
sortinghat/parsing/sh.py
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/sh.py#L88-L124
def __parse_blacklist(self, json): """Parse blacklist entries using Sorting Hat format. The Sorting Hat blacklist format is a JSON stream that stores a list of blacklisted entries. Next, there is an example of a valid stream: { "blacklist": [ "John ...
[ "def", "__parse_blacklist", "(", "self", ",", "json", ")", ":", "try", ":", "for", "entry", "in", "json", "[", "'blacklist'", "]", ":", "if", "not", "entry", ":", "msg", "=", "\"invalid json format. Blacklist entries cannot be null or empty\"", "raise", "InvalidFo...
Parse blacklist entries using Sorting Hat format. The Sorting Hat blacklist format is a JSON stream that stores a list of blacklisted entries. Next, there is an example of a valid stream: { "blacklist": [ "John Doe", "John Smith", ...
[ "Parse", "blacklist", "entries", "using", "Sorting", "Hat", "format", "." ]
python
train
saltstack/salt
salt/modules/bigip.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bigip.py#L622-L773
def create_pool(hostname, username, password, name, members=None, allow_nat=None, allow_snat=None, description=None, gateway_failsafe_device=None, ignore_persisted_weight=None, ip_tos_to_client=None, ip_tos_t...
[ "def", "create_pool", "(", "hostname", ",", "username", ",", "password", ",", "name", ",", "members", "=", "None", ",", "allow_nat", "=", "None", ",", "allow_snat", "=", "None", ",", "description", "=", "None", ",", "gateway_failsafe_device", "=", "None", ...
A function to connect to a bigip device and create a pool. hostname The host/address of the bigip device username The iControl REST username password The iControl REST password name The name of the pool to create. members List of comma delimited pool members ...
[ "A", "function", "to", "connect", "to", "a", "bigip", "device", "and", "create", "a", "pool", "." ]
python
train
pandas-dev/pandas
pandas/core/panel.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/panel.py#L1308-L1330
def shift(self, periods=1, freq=None, axis='major'): """ Shift index by desired number of periods with an optional time freq. The shifted data will not include the dropped periods and the shifted axis will be smaller than the original. This is different from the behavior of Data...
[ "def", "shift", "(", "self", ",", "periods", "=", "1", ",", "freq", "=", "None", ",", "axis", "=", "'major'", ")", ":", "if", "freq", ":", "return", "self", ".", "tshift", "(", "periods", ",", "freq", ",", "axis", "=", "axis", ")", "return", "sup...
Shift index by desired number of periods with an optional time freq. The shifted data will not include the dropped periods and the shifted axis will be smaller than the original. This is different from the behavior of DataFrame.shift() Parameters ---------- periods : in...
[ "Shift", "index", "by", "desired", "number", "of", "periods", "with", "an", "optional", "time", "freq", "." ]
python
train
rene-aguirre/pywinusb
pywinusb/hid/core.py
https://github.com/rene-aguirre/pywinusb/blob/954c4b2105d9f01cb0c50e24500bb747d4ecdc43/pywinusb/hid/core.py#L266-L279
def get_parent_device(self): """Retreive parent device string id""" if not self.parent_instance_id: return "" dev_buffer_type = winapi.c_tchar * MAX_DEVICE_ID_LEN dev_buffer = dev_buffer_type() try: if winapi.CM_Get_Device_ID(self.parent_instance_id...
[ "def", "get_parent_device", "(", "self", ")", ":", "if", "not", "self", ".", "parent_instance_id", ":", "return", "\"\"", "dev_buffer_type", "=", "winapi", ".", "c_tchar", "*", "MAX_DEVICE_ID_LEN", "dev_buffer", "=", "dev_buffer_type", "(", ")", "try", ":", "i...
Retreive parent device string id
[ "Retreive", "parent", "device", "string", "id" ]
python
train
jlmadurga/permabots
permabots/views/api/bot.py
https://github.com/jlmadurga/permabots/blob/781a91702529a23fe7bc2aa84c5d88e961412466/permabots/views/api/bot.py#L172-L180
def delete(self, request, bot_id, id, format=None): """ Delete existing Telegram Bot --- responseMessages: - code: 401 message: Not authenticated """ return super(TelegramBotDetail, self).delete(request, bot_id, id, format)
[ "def", "delete", "(", "self", ",", "request", ",", "bot_id", ",", "id", ",", "format", "=", "None", ")", ":", "return", "super", "(", "TelegramBotDetail", ",", "self", ")", ".", "delete", "(", "request", ",", "bot_id", ",", "id", ",", "format", ")" ]
Delete existing Telegram Bot --- responseMessages: - code: 401 message: Not authenticated
[ "Delete", "existing", "Telegram", "Bot", "---", "responseMessages", ":", "-", "code", ":", "401", "message", ":", "Not", "authenticated" ]
python
train
thusoy/pwm
pwm/core.py
https://github.com/thusoy/pwm/blob/fff7d755c34f3a7235a8bf217ffa2ff5aed4926f/pwm/core.py#L166-L181
def get_domain(self, domain_name): """ Get the :class:`Domain <pwm.Domain>` object from a name. :param domain_name: The domain name to fetch the object for. :returns: The :class:`Domain <pwm.core.Domain>` class with this domain_name if found, else None. """ protocol ...
[ "def", "get_domain", "(", "self", ",", "domain_name", ")", ":", "protocol", "=", "self", ".", "database_uri", ".", "split", "(", "':'", ",", "1", ")", "[", "0", "]", "if", "protocol", "in", "(", "'https'", ",", "'http'", ")", ":", "return", "self", ...
Get the :class:`Domain <pwm.Domain>` object from a name. :param domain_name: The domain name to fetch the object for. :returns: The :class:`Domain <pwm.core.Domain>` class with this domain_name if found, else None.
[ "Get", "the", ":", "class", ":", "Domain", "<pwm", ".", "Domain", ">", "object", "from", "a", "name", "." ]
python
test
google/tangent
tangent/grads.py
https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/grads.py#L335-L341
def adet(z, x): """d|A|/dA = adj(A).T See Jacobi's formula: https://en.wikipedia.org/wiki/Jacobi%27s_formula """ adjugate = numpy.linalg.det(x) * numpy.linalg.pinv(x) d[x] = d[z] * numpy.transpose(adjugate)
[ "def", "adet", "(", "z", ",", "x", ")", ":", "adjugate", "=", "numpy", ".", "linalg", ".", "det", "(", "x", ")", "*", "numpy", ".", "linalg", ".", "pinv", "(", "x", ")", "d", "[", "x", "]", "=", "d", "[", "z", "]", "*", "numpy", ".", "tra...
d|A|/dA = adj(A).T See Jacobi's formula: https://en.wikipedia.org/wiki/Jacobi%27s_formula
[ "d|A|", "/", "dA", "=", "adj", "(", "A", ")", ".", "T" ]
python
train
google/grr
grr/server/grr_response_server/check_lib/checks.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/check_lib/checks.py#L138-L155
def Parse(self, rdf_data): """Process rdf data through the filter. Filters sift data according to filter rules. Data that passes the filter rule is kept, other data is dropped. If no filter method is provided, the data is returned as a list. Otherwise, a items that meet filter conditions are retur...
[ "def", "Parse", "(", "self", ",", "rdf_data", ")", ":", "if", "self", ".", "_filter", ":", "return", "list", "(", "self", ".", "_filter", ".", "Parse", "(", "rdf_data", ",", "self", ".", "expression", ")", ")", "return", "rdf_data" ]
Process rdf data through the filter. Filters sift data according to filter rules. Data that passes the filter rule is kept, other data is dropped. If no filter method is provided, the data is returned as a list. Otherwise, a items that meet filter conditions are returned in a list. Args: rd...
[ "Process", "rdf", "data", "through", "the", "filter", "." ]
python
train
mwhooker/jones
jones/jones.py
https://github.com/mwhooker/jones/blob/121e89572ca063f456b8e94cbb8cbee26c307a8f/jones/jones.py#L223-L237
def get_associations(self, env): """ Get all the associations for this env. Root cannot have associations, so return None for root. returns a map of hostnames to environments. """ if env.is_root: return None associations = self.associations.get_all...
[ "def", "get_associations", "(", "self", ",", "env", ")", ":", "if", "env", ".", "is_root", ":", "return", "None", "associations", "=", "self", ".", "associations", ".", "get_all", "(", ")", "return", "[", "assoc", "for", "assoc", "in", "associations", "i...
Get all the associations for this env. Root cannot have associations, so return None for root. returns a map of hostnames to environments.
[ "Get", "all", "the", "associations", "for", "this", "env", "." ]
python
train
dossier/dossier.web
dossier/web/interface.py
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L129-L141
def set_query_params(self, query_params): '''Set the query parameters. The query parameters should be a dictionary mapping keys to strings or lists of strings. :param query_params: query parameters :type query_params: ``name |--> (str | [str])`` :rtype: :class:`Queryabl...
[ "def", "set_query_params", "(", "self", ",", "query_params", ")", ":", "self", ".", "query_params", "=", "as_multi_dict", "(", "query_params", ")", "self", ".", "apply_param_schema", "(", ")", "return", "self" ]
Set the query parameters. The query parameters should be a dictionary mapping keys to strings or lists of strings. :param query_params: query parameters :type query_params: ``name |--> (str | [str])`` :rtype: :class:`Queryable`
[ "Set", "the", "query", "parameters", "." ]
python
train
spyder-ide/spyder
spyder/utils/workers.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/workers.py#L203-L210
def terminate(self): """Terminate running processes.""" if self._process.state() == QProcess.Running: try: self._process.terminate() except Exception: pass self._fired = True
[ "def", "terminate", "(", "self", ")", ":", "if", "self", ".", "_process", ".", "state", "(", ")", "==", "QProcess", ".", "Running", ":", "try", ":", "self", ".", "_process", ".", "terminate", "(", ")", "except", "Exception", ":", "pass", "self", ".",...
Terminate running processes.
[ "Terminate", "running", "processes", "." ]
python
train
slarse/pdfebc-core
pdfebc_core/config_utils.py
https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/config_utils.py#L150-L169
def get_attribute_from_config(config, section, attribute): """Try to parse an attribute of the config file. Args: config (defaultdict): A defaultdict. section (str): The section of the config file to get information from. attribute (str): The attribute of the section to fetch. Retur...
[ "def", "get_attribute_from_config", "(", "config", ",", "section", ",", "attribute", ")", ":", "section", "=", "config", ".", "get", "(", "section", ")", "if", "section", ":", "option", "=", "section", ".", "get", "(", "attribute", ")", "if", "option", "...
Try to parse an attribute of the config file. Args: config (defaultdict): A defaultdict. section (str): The section of the config file to get information from. attribute (str): The attribute of the section to fetch. Returns: str: The string corresponding to the section and attri...
[ "Try", "to", "parse", "an", "attribute", "of", "the", "config", "file", "." ]
python
train
opendatateam/udata
udata/core/spatial/models.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/spatial/models.py#L60-L81
def resolve(self, geoid, id_only=False): ''' Resolve a GeoZone given a GeoID. The start date is resolved from the given GeoID, ie. it find there is a zone valid a the geoid validity, resolve the `latest` alias or use `latest` when no validity is given. If `id_on...
[ "def", "resolve", "(", "self", ",", "geoid", ",", "id_only", "=", "False", ")", ":", "level", ",", "code", ",", "validity", "=", "geoids", ".", "parse", "(", "geoid", ")", "qs", "=", "self", "(", "level", "=", "level", ",", "code", "=", "code", "...
Resolve a GeoZone given a GeoID. The start date is resolved from the given GeoID, ie. it find there is a zone valid a the geoid validity, resolve the `latest` alias or use `latest` when no validity is given. If `id_only` is True, the result will be the resolved GeoID ...
[ "Resolve", "a", "GeoZone", "given", "a", "GeoID", "." ]
python
train
PyconUK/ConferenceScheduler
src/conference_scheduler/lp_problem/utils.py
https://github.com/PyconUK/ConferenceScheduler/blob/fb139f0ef2eab5ac8f4919aa4994d94d4e040030/src/conference_scheduler/lp_problem/utils.py#L33-L45
def tag_array(events): """ Return a numpy array mapping events to tags - Rows corresponds to events - Columns correspond to tags """ all_tags = sorted(set(tag for event in events for tag in event.tags)) array = np.zeros((len(events), len(all_tags))) for row, event in enumerate(events): ...
[ "def", "tag_array", "(", "events", ")", ":", "all_tags", "=", "sorted", "(", "set", "(", "tag", "for", "event", "in", "events", "for", "tag", "in", "event", ".", "tags", ")", ")", "array", "=", "np", ".", "zeros", "(", "(", "len", "(", "events", ...
Return a numpy array mapping events to tags - Rows corresponds to events - Columns correspond to tags
[ "Return", "a", "numpy", "array", "mapping", "events", "to", "tags" ]
python
train
twilio/twilio-python
twilio/rest/api/v2010/account/recording/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/recording/__init__.py#L165-L174
def get(self, sid): """ Constructs a RecordingContext :param sid: The unique string that identifies the resource :returns: twilio.rest.api.v2010.account.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.recording.RecordingContext """ return Record...
[ "def", "get", "(", "self", ",", "sid", ")", ":", "return", "RecordingContext", "(", "self", ".", "_version", ",", "account_sid", "=", "self", ".", "_solution", "[", "'account_sid'", "]", ",", "sid", "=", "sid", ",", ")" ]
Constructs a RecordingContext :param sid: The unique string that identifies the resource :returns: twilio.rest.api.v2010.account.recording.RecordingContext :rtype: twilio.rest.api.v2010.account.recording.RecordingContext
[ "Constructs", "a", "RecordingContext" ]
python
train
pantsbuild/pants
src/python/pants/engine/scheduler.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/engine/scheduler.py#L342-L346
def new_session(self, zipkin_trace_v2, v2_ui=False): """Creates a new SchedulerSession for this Scheduler.""" return SchedulerSession(self, self._native.new_session( self._scheduler, zipkin_trace_v2, v2_ui, multiprocessing.cpu_count()) )
[ "def", "new_session", "(", "self", ",", "zipkin_trace_v2", ",", "v2_ui", "=", "False", ")", ":", "return", "SchedulerSession", "(", "self", ",", "self", ".", "_native", ".", "new_session", "(", "self", ".", "_scheduler", ",", "zipkin_trace_v2", ",", "v2_ui",...
Creates a new SchedulerSession for this Scheduler.
[ "Creates", "a", "new", "SchedulerSession", "for", "this", "Scheduler", "." ]
python
train
sebp/scikit-survival
sksurv/nonparametric.py
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L170-L228
def kaplan_meier_estimator(event, time_exit, time_enter=None, time_min=None): """Kaplan-Meier estimator of survival function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time_exit : array-like, shape = (n_samples,) Contains event...
[ "def", "kaplan_meier_estimator", "(", "event", ",", "time_exit", ",", "time_enter", "=", "None", ",", "time_min", "=", "None", ")", ":", "event", ",", "time_enter", ",", "time_exit", "=", "check_y_survival", "(", "event", ",", "time_enter", ",", "time_exit", ...
Kaplan-Meier estimator of survival function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time_exit : array-like, shape = (n_samples,) Contains event/censoring times. time_enter : array-like, shape = (n_samples,), optional ...
[ "Kaplan", "-", "Meier", "estimator", "of", "survival", "function", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/textio.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L1064-L1069
def bk_blue(cls): "Make the text background color blue." wAttributes = cls._get_text_attributes() wAttributes &= ~win32.BACKGROUND_MASK wAttributes |= win32.BACKGROUND_BLUE cls._set_text_attributes(wAttributes)
[ "def", "bk_blue", "(", "cls", ")", ":", "wAttributes", "=", "cls", ".", "_get_text_attributes", "(", ")", "wAttributes", "&=", "~", "win32", ".", "BACKGROUND_MASK", "wAttributes", "|=", "win32", ".", "BACKGROUND_BLUE", "cls", ".", "_set_text_attributes", "(", ...
Make the text background color blue.
[ "Make", "the", "text", "background", "color", "blue", "." ]
python
train
Deathnerd/pyterp
pyterp/__init__.py
https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L188-L197
def _read_byte(self): """ Read a single byte from the user without waiting for the \n character """ from .getch import _Getch try: g = _Getch() self.tape[self.pointer] = ord(g()) except TypeError as e: print "Here's what _Getch() is giv...
[ "def", "_read_byte", "(", "self", ")", ":", "from", ".", "getch", "import", "_Getch", "try", ":", "g", "=", "_Getch", "(", ")", "self", ".", "tape", "[", "self", ".", "pointer", "]", "=", "ord", "(", "g", "(", ")", ")", "except", "TypeError", "as...
Read a single byte from the user without waiting for the \n character
[ "Read", "a", "single", "byte", "from", "the", "user", "without", "waiting", "for", "the", "\\", "n", "character" ]
python
train
malja/zroya
setup.py
https://github.com/malja/zroya/blob/41830133a54528e9cd9ef43d9637a576ac849c11/setup.py#L53-L67
def find_pyd_file(): """ Return path to .pyd after successful build command. :return: Path to .pyd file or None. """ if not os.path.isdir("./build"): raise NotADirectoryError for path, dirs, files in os.walk("./build"): for file_name in files: file_name_parts = os.p...
[ "def", "find_pyd_file", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "\"./build\"", ")", ":", "raise", "NotADirectoryError", "for", "path", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "\"./build\"", ")", ":", "for", ...
Return path to .pyd after successful build command. :return: Path to .pyd file or None.
[ "Return", "path", "to", ".", "pyd", "after", "successful", "build", "command", ".", ":", "return", ":", "Path", "to", ".", "pyd", "file", "or", "None", "." ]
python
train
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L3489-L3505
def schedule_forced_svc_check(self, service, check_time): """Schedule a forced check on a service Format of the line that triggers function call:: SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time> :param service: service to check :type service: alignak.ob...
[ "def", "schedule_forced_svc_check", "(", "self", ",", "service", ",", "check_time", ")", ":", "service", ".", "schedule", "(", "self", ".", "daemon", ".", "hosts", ",", "self", ".", "daemon", ".", "services", ",", "self", ".", "daemon", ".", "timeperiods",...
Schedule a forced check on a service Format of the line that triggers function call:: SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time> :param service: service to check :type service: alignak.object.service.Service :param check_time: time to check ...
[ "Schedule", "a", "forced", "check", "on", "a", "service", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
ArchiveTeam/wpull
wpull/application/hook.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/application/hook.py#L64-L69
def connect(self, name, callback): '''Add callback to hook.''' if not self._callbacks[name]: self._callbacks[name] = callback else: raise HookAlreadyConnectedError('Callback hook already connected.')
[ "def", "connect", "(", "self", ",", "name", ",", "callback", ")", ":", "if", "not", "self", ".", "_callbacks", "[", "name", "]", ":", "self", ".", "_callbacks", "[", "name", "]", "=", "callback", "else", ":", "raise", "HookAlreadyConnectedError", "(", ...
Add callback to hook.
[ "Add", "callback", "to", "hook", "." ]
python
train
pszafer/epson_projector
epson_projector/main.py
https://github.com/pszafer/epson_projector/blob/b8a10ace56e0a5cf858546041819c0e7ebca208f/epson_projector/main.py#L119-L141
async def send_request(self, params, timeout, type='json_query', command=False): """Send request to Epson.""" try: with async_timeout.timeout(timeout): url = '{url}{type}'.format( url=self._http_url, type=type...
[ "async", "def", "send_request", "(", "self", ",", "params", ",", "timeout", ",", "type", "=", "'json_query'", ",", "command", "=", "False", ")", ":", "try", ":", "with", "async_timeout", ".", "timeout", "(", "timeout", ")", ":", "url", "=", "'{url}{type}...
Send request to Epson.
[ "Send", "request", "to", "Epson", "." ]
python
train
waqasbhatti/astrobase
astrobase/lcfit/nonphysical.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcfit/nonphysical.py#L271-L484
def savgol_fit_magseries(times, mags, errs, period, windowlength=None, polydeg=2, sigclip=30.0, plotfit=False, magsarefluxes=False, verbose=True): '''Fit a Savitzky-...
[ "def", "savgol_fit_magseries", "(", "times", ",", "mags", ",", "errs", ",", "period", ",", "windowlength", "=", "None", ",", "polydeg", "=", "2", ",", "sigclip", "=", "30.0", ",", "plotfit", "=", "False", ",", "magsarefluxes", "=", "False", ",", "verbose...
Fit a Savitzky-Golay filter to the magnitude/flux time series. SG fits successive sub-sets (windows) of adjacent data points with a low-order polynomial via least squares. At each point (magnitude), it returns the value of the polynomial at that magnitude's time. This is made significantly cheaper tha...
[ "Fit", "a", "Savitzky", "-", "Golay", "filter", "to", "the", "magnitude", "/", "flux", "time", "series", "." ]
python
valid
pyviz/holoviews
holoviews/core/operation.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/operation.py#L113-L124
def _apply(self, element, key=None): """ Applies the operation to the element, executing any pre- and post-processor hooks if defined. """ kwargs = {} for hook in self._preprocess_hooks: kwargs.update(hook(self, element)) ret = self._process(element, k...
[ "def", "_apply", "(", "self", ",", "element", ",", "key", "=", "None", ")", ":", "kwargs", "=", "{", "}", "for", "hook", "in", "self", ".", "_preprocess_hooks", ":", "kwargs", ".", "update", "(", "hook", "(", "self", ",", "element", ")", ")", "ret"...
Applies the operation to the element, executing any pre- and post-processor hooks if defined.
[ "Applies", "the", "operation", "to", "the", "element", "executing", "any", "pre", "-", "and", "post", "-", "processor", "hooks", "if", "defined", "." ]
python
train
mila/pyoo
pyoo.py
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1636-L1646
def copy(self, old_name, new_name, index=None): """ Copies an old sheet with the old_name to a new sheet with new_name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet. """ if index is None: i...
[ "def", "copy", "(", "self", ",", "old_name", ",", "new_name", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "len", "(", "self", ")", "self", ".", "_copy", "(", "old_name", ",", "new_name", ",", "index", ")", ...
Copies an old sheet with the old_name to a new sheet with new_name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet.
[ "Copies", "an", "old", "sheet", "with", "the", "old_name", "to", "a", "new", "sheet", "with", "new_name", "." ]
python
train
empymod/empymod
empymod/scripts/fdesign.py
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/scripts/fdesign.py#L1057-L1066
def sin_3(a=1): r"""Fourier sine transform pair sin_3 ([Ande75]_).""" def lhs(x): return x/(a**2 + x**2) def rhs(b): return np.pi*np.exp(-a*b)/2 return Ghosh('sin', lhs, rhs)
[ "def", "sin_3", "(", "a", "=", "1", ")", ":", "def", "lhs", "(", "x", ")", ":", "return", "x", "/", "(", "a", "**", "2", "+", "x", "**", "2", ")", "def", "rhs", "(", "b", ")", ":", "return", "np", ".", "pi", "*", "np", ".", "exp", "(", ...
r"""Fourier sine transform pair sin_3 ([Ande75]_).
[ "r", "Fourier", "sine", "transform", "pair", "sin_3", "(", "[", "Ande75", "]", "_", ")", "." ]
python
train
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/magics.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/magics.py#L200-L218
def project(self): """str: Default project to use for queries performed through IPython magics Note: The project does not need to be explicitly defined if you have an environment default project set. If you do not have a default project set in your environmen...
[ "def", "project", "(", "self", ")", ":", "if", "self", ".", "_project", "is", "None", ":", "_", ",", "self", ".", "_project", "=", "google", ".", "auth", ".", "default", "(", ")", "return", "self", ".", "_project" ]
str: Default project to use for queries performed through IPython magics Note: The project does not need to be explicitly defined if you have an environment default project set. If you do not have a default project set in your environment, manually assign the project...
[ "str", ":", "Default", "project", "to", "use", "for", "queries", "performed", "through", "IPython", "magics" ]
python
train
Parsely/probably
probably/cdbf.py
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/cdbf.py#L75-L80
def compute_refresh_time(self): """ Compute the refresh period for the given expiration delay """ if self.z == 0: self.z = 1E-10 s = float(self.expiration) * (1.0/(self.nbr_bits)) * (1.0/(self.counter_init - 1 + (1.0/(self.z * (self.nbr_slices + 1))))) return s
[ "def", "compute_refresh_time", "(", "self", ")", ":", "if", "self", ".", "z", "==", "0", ":", "self", ".", "z", "=", "1E-10", "s", "=", "float", "(", "self", ".", "expiration", ")", "*", "(", "1.0", "/", "(", "self", ".", "nbr_bits", ")", ")", ...
Compute the refresh period for the given expiration delay
[ "Compute", "the", "refresh", "period", "for", "the", "given", "expiration", "delay" ]
python
train
Stewori/pytypes
pytypes/type_util.py
https://github.com/Stewori/pytypes/blob/b814d38709e84c0e0825caf8b721c20eb5a8ab3b/pytypes/type_util.py#L1778-L1815
def _issubclass_2(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check): """Helper for _issubclass, a.k.a pytypes.issubtype. """ if is_Tuple(superclass): return _issubclass_Tuple(subclass, superclass, bound_Generic, bound_typevar...
[ "def", "_issubclass_2", "(", "subclass", ",", "superclass", ",", "bound_Generic", ",", "bound_typevars", ",", "bound_typevars_readonly", ",", "follow_fwd_refs", ",", "_recursion_check", ")", ":", "if", "is_Tuple", "(", "superclass", ")", ":", "return", "_issubclass_...
Helper for _issubclass, a.k.a pytypes.issubtype.
[ "Helper", "for", "_issubclass", "a", ".", "k", ".", "a", "pytypes", ".", "issubtype", "." ]
python
train
nickpandolfi/Cyther
cyther/instructions.py
https://github.com/nickpandolfi/Cyther/blob/9fb0bd77af594008aa6ee8af460aa8c953abf5bc/cyther/instructions.py#L53-L82
def processAndSetDefaults(self): """ The heart of the 'Instruction' object. This method will make sure that all fields not entered will be defaulted to a correct value. Also checks for incongruities in the data entered, if it was by the user. """ # INPUT, OUTPUT, GIVEN + ...
[ "def", "processAndSetDefaults", "(", "self", ")", ":", "# INPUT, OUTPUT, GIVEN + BUILDABLE DEPS", "if", "not", "self", ".", "input", ":", "raise", "ValueError", "(", "NO_INPUT_FILE", ")", "if", "not", "self", ".", "output", ":", "# Build directory must exist, right?",...
The heart of the 'Instruction' object. This method will make sure that all fields not entered will be defaulted to a correct value. Also checks for incongruities in the data entered, if it was by the user.
[ "The", "heart", "of", "the", "Instruction", "object", ".", "This", "method", "will", "make", "sure", "that", "all", "fields", "not", "entered", "will", "be", "defaulted", "to", "a", "correct", "value", ".", "Also", "checks", "for", "incongruities", "in", "...
python
train
manns/pyspread
pyspread/src/lib/vlc.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L1806-L1817
def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop): '''Add a broadcast, with one input. @param psz_name: the name of the new broadcast. @param psz_input: the input MRL. @param psz_output: the output MRL (the parameter to the "sout" va...
[ "def", "vlm_add_broadcast", "(", "self", ",", "psz_name", ",", "psz_input", ",", "psz_output", ",", "i_options", ",", "ppsz_options", ",", "b_enabled", ",", "b_loop", ")", ":", "return", "libvlc_vlm_add_broadcast", "(", "self", ",", "str_to_bytes", "(", "psz_nam...
Add a broadcast, with one input. @param psz_name: the name of the new broadcast. @param psz_input: the input MRL. @param psz_output: the output MRL (the parameter to the "sout" variable). @param i_options: number of additional options. @param ppsz_options: additional options. ...
[ "Add", "a", "broadcast", "with", "one", "input", "." ]
python
train
richardkiss/pycoin
pycoin/merkle.py
https://github.com/richardkiss/pycoin/blob/1e8d0d9fe20ce0347b97847bb529cd1bd84c7442/pycoin/merkle.py#L12-L20
def merkle_pair(hashes, hash_f): """Take a list of hashes, and return the parent row in the tree of merkle hashes.""" if len(hashes) % 2 == 1: hashes = list(hashes) hashes.append(hashes[-1]) items = [] for i in range(0, len(hashes), 2): items.append(hash_f(hashes[i] + hashes[i+1]...
[ "def", "merkle_pair", "(", "hashes", ",", "hash_f", ")", ":", "if", "len", "(", "hashes", ")", "%", "2", "==", "1", ":", "hashes", "=", "list", "(", "hashes", ")", "hashes", ".", "append", "(", "hashes", "[", "-", "1", "]", ")", "items", "=", "...
Take a list of hashes, and return the parent row in the tree of merkle hashes.
[ "Take", "a", "list", "of", "hashes", "and", "return", "the", "parent", "row", "in", "the", "tree", "of", "merkle", "hashes", "." ]
python
train
CalebBell/fluids
fluids/flow_meter.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/flow_meter.py#L196-L257
def orifice_expansibility_1989(D, Do, P1, P2, k): r'''Calculates the expansibility factor for orifice plate calculations based on the geometry of the plate, measured pressures of the orifice, and the isentropic exponent of the fluid. .. math:: \epsilon = 1- (0.41 + 0.35\beta^4)\Delta P/\kap...
[ "def", "orifice_expansibility_1989", "(", "D", ",", "Do", ",", "P1", ",", "P2", ",", "k", ")", ":", "return", "1.0", "-", "(", "0.41", "+", "0.35", "*", "(", "Do", "/", "D", ")", "**", "4", ")", "*", "(", "P1", "-", "P2", ")", "/", "(", "k"...
r'''Calculates the expansibility factor for orifice plate calculations based on the geometry of the plate, measured pressures of the orifice, and the isentropic exponent of the fluid. .. math:: \epsilon = 1- (0.41 + 0.35\beta^4)\Delta P/\kappa/P_1 Parameters ---------- D : ...
[ "r", "Calculates", "the", "expansibility", "factor", "for", "orifice", "plate", "calculations", "based", "on", "the", "geometry", "of", "the", "plate", "measured", "pressures", "of", "the", "orifice", "and", "the", "isentropic", "exponent", "of", "the", "fluid",...
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L398-L411
def get_ip_interface_input_request_type_get_request_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_ip_interface = ET.Element("get_ip_interface") config = get_ip_interface input = ET.SubElement(get_ip_interface, "input") ...
[ "def", "get_ip_interface_input_request_type_get_request_interface_type", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_ip_interface", "=", "ET", ".", "Element", "(", "\"get_ip_interface\"", ")", "...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
SheffieldML/GPy
GPy/kern/src/stationary.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/kern/src/stationary.py#L151-L168
def _scaled_dist(self, X, X2=None): """ Efficiently compute the scaled distance, r. ..math:: r = \sqrt( \sum_{q=1}^Q (x_q - x'q)^2/l_q^2 ) Note that if thre is only one lengthscale, l comes outside the sum. In this case we compute the unscaled distance first (in a s...
[ "def", "_scaled_dist", "(", "self", ",", "X", ",", "X2", "=", "None", ")", ":", "if", "self", ".", "ARD", ":", "if", "X2", "is", "not", "None", ":", "X2", "=", "X2", "/", "self", ".", "lengthscale", "return", "self", ".", "_unscaled_dist", "(", "...
Efficiently compute the scaled distance, r. ..math:: r = \sqrt( \sum_{q=1}^Q (x_q - x'q)^2/l_q^2 ) Note that if thre is only one lengthscale, l comes outside the sum. In this case we compute the unscaled distance first (in a separate function for caching) and divide by leng...
[ "Efficiently", "compute", "the", "scaled", "distance", "r", "." ]
python
train
MillionIntegrals/vel
vel/rl/commands/record_movie_command.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/commands/record_movie_command.py#L47-L91
def record_take(self, model, env_instance, device, take_number): """ Record a single movie and store it on hard drive """ frames = [] observation = env_instance.reset() if model.is_recurrent: hidden_state = model.zero_state(1).to(device) frames.append(env_instance....
[ "def", "record_take", "(", "self", ",", "model", ",", "env_instance", ",", "device", ",", "take_number", ")", ":", "frames", "=", "[", "]", "observation", "=", "env_instance", ".", "reset", "(", ")", "if", "model", ".", "is_recurrent", ":", "hidden_state",...
Record a single movie and store it on hard drive
[ "Record", "a", "single", "movie", "and", "store", "it", "on", "hard", "drive" ]
python
train
boriel/zxbasic
symbols/number.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/symbols/number.py#L21-L31
def _get_val(other): """ Given a Number, a Numeric Constant or a python number return its value """ assert isinstance(other, (numbers.Number, SymbolNUMBER, SymbolCONST)) if isinstance(other, SymbolNUMBER): return other.value if isinstance(other, SymbolCONST): return other.expr.value...
[ "def", "_get_val", "(", "other", ")", ":", "assert", "isinstance", "(", "other", ",", "(", "numbers", ".", "Number", ",", "SymbolNUMBER", ",", "SymbolCONST", ")", ")", "if", "isinstance", "(", "other", ",", "SymbolNUMBER", ")", ":", "return", "other", "....
Given a Number, a Numeric Constant or a python number return its value
[ "Given", "a", "Number", "a", "Numeric", "Constant", "or", "a", "python", "number", "return", "its", "value" ]
python
train
inspirehep/inspire-json-merger
inspire_json_merger/pre_filters.py
https://github.com/inspirehep/inspire-json-merger/blob/6af3140fcf7c3f851141c0928eedfe99fddeeda0/inspire_json_merger/pre_filters.py#L33-L37
def remove_elements_with_source(source, field): """Remove all elements matching ``source`` in ``field``.""" return freeze( [element for element in field if element.get('source', '').lower() != source] )
[ "def", "remove_elements_with_source", "(", "source", ",", "field", ")", ":", "return", "freeze", "(", "[", "element", "for", "element", "in", "field", "if", "element", ".", "get", "(", "'source'", ",", "''", ")", ".", "lower", "(", ")", "!=", "source", ...
Remove all elements matching ``source`` in ``field``.
[ "Remove", "all", "elements", "matching", "source", "in", "field", "." ]
python
train
not-na/peng3d
peng3d/gui/layered.py
https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/gui/layered.py#L491-L506
def redraw_label(self): """ Re-draws the text by calculating its position. Currently, the text will always be centered on the position of the layer. """ # Convenience variables x,y,_,_ = self.getPos() sx,sy = self.getSize() self._label.x ...
[ "def", "redraw_label", "(", "self", ")", ":", "# Convenience variables", "x", ",", "y", ",", "_", ",", "_", "=", "self", ".", "getPos", "(", ")", "sx", ",", "sy", "=", "self", ".", "getSize", "(", ")", "self", ".", "_label", ".", "x", "=", "x", ...
Re-draws the text by calculating its position. Currently, the text will always be centered on the position of the layer.
[ "Re", "-", "draws", "the", "text", "by", "calculating", "its", "position", ".", "Currently", "the", "text", "will", "always", "be", "centered", "on", "the", "position", "of", "the", "layer", "." ]
python
test
wummel/dosage
scripts/creators.py
https://github.com/wummel/dosage/blob/a0109c3a46219f280e6e5e77183674e40da0f304/scripts/creators.py#L66-L79
def print_results(args): """Print comics.""" min_comics, filename = args with codecs.open(filename, 'a', 'utf-8') as fp: for name, url in sorted(load_result(json_file).items()): if name in exclude_comics: continue if has_gocomics_comic(name): p...
[ "def", "print_results", "(", "args", ")", ":", "min_comics", ",", "filename", "=", "args", "with", "codecs", ".", "open", "(", "filename", ",", "'a'", ",", "'utf-8'", ")", "as", "fp", ":", "for", "name", ",", "url", "in", "sorted", "(", "load_result", ...
Print comics.
[ "Print", "comics", "." ]
python
train
geomet/geomet
geomet/wkt.py
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkt.py#L203-L219
def _dump_point(obj, decimals): """ Dump a GeoJSON-like Point object to WKT. :param dict obj: A GeoJSON-like `dict` representing a Point. :param int decimals: int which indicates the number of digits to display after the decimal point when formatting coordinates. :returns: ...
[ "def", "_dump_point", "(", "obj", ",", "decimals", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "pt", "=", "'POINT (%s)'", "%", "' '", ".", "join", "(", "_round_and_pad", "(", "c", ",", "decimals", ")", "for", "c", "in", "coords", ")", ...
Dump a GeoJSON-like Point object to WKT. :param dict obj: A GeoJSON-like `dict` representing a Point. :param int decimals: int which indicates the number of digits to display after the decimal point when formatting coordinates. :returns: WKT representation of the input GeoJ...
[ "Dump", "a", "GeoJSON", "-", "like", "Point", "object", "to", "WKT", "." ]
python
train
mitsei/dlkit
dlkit/json_/assessment/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/sessions.py#L4764-L4782
def get_assessments_by_bank(self, bank_id): """Gets the list of ``Assessments`` associated with a ``Bank``. arg: bank_id (osid.id.Id): ``Id`` of the ``Bank`` return: (osid.assessment.AssessmentList) - list of related assessments raise: NotFound - ``bank_id`` is not f...
[ "def", "get_assessments_by_bank", "(", "self", ",", "bank_id", ")", ":", "# Implemented from template for", "# osid.resource.ResourceBinSession.get_resources_by_bin", "mgr", "=", "self", ".", "_get_provider_manager", "(", "'ASSESSMENT'", ",", "local", "=", "True", ")", "l...
Gets the list of ``Assessments`` associated with a ``Bank``. arg: bank_id (osid.id.Id): ``Id`` of the ``Bank`` return: (osid.assessment.AssessmentList) - list of related assessments raise: NotFound - ``bank_id`` is not found raise: NullArgument - ``bank_id`` is ``nu...
[ "Gets", "the", "list", "of", "Assessments", "associated", "with", "a", "Bank", "." ]
python
train
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/processing_controller/scheduler/scheduler.py
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/processing_controller/scheduler/scheduler.py#L44-L60
def _init_queue(): """Initialise the Processing Block queue from the database. This method should populate the queue from the current state of the Configuration Database. This needs to be based on the current set of Processing Blocks in the database and consider events on these...
[ "def", "_init_queue", "(", ")", ":", "LOG", ".", "info", "(", "'Initialising Processing Block queue.'", ")", "queue", "=", "ProcessingBlockQueue", "(", ")", "active_pb_ids", "=", "ProcessingBlockList", "(", ")", ".", "active", "LOG", ".", "info", "(", "'Initiali...
Initialise the Processing Block queue from the database. This method should populate the queue from the current state of the Configuration Database. This needs to be based on the current set of Processing Blocks in the database and consider events on these processing blocks.
[ "Initialise", "the", "Processing", "Block", "queue", "from", "the", "database", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py#L545-L562
def ip_rtm_config_route_static_route_nh_route_attributes_metric(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") ip = ET.SubElement(config, "ip", xmlns="urn:brocade.com:mgmt:brocade-common-def") rtm_config = ET.SubElement(ip, "rtm-config", xmlns="urn:broc...
[ "def", "ip_rtm_config_route_static_route_nh_route_attributes_metric", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "ip", "=", "ET", ".", "SubElement", "(", "config", ",", "\"ip\"", ",", "xmlns", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_notification_stream.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_notification_stream.py#L388-L397
def OSPFNeighborState_OSPFNeighborIpAddress(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") OSPFNeighborState = ET.SubElement(config, "OSPFNeighborState", xmlns="http://brocade.com/ns/brocade-notification-stream") OSPFNeighborIpAddress = ET.SubElement(OS...
[ "def", "OSPFNeighborState_OSPFNeighborIpAddress", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "OSPFNeighborState", "=", "ET", ".", "SubElement", "(", "config", ",", "\"OSPFNeighborState\"", ",", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
fabioz/PyDev.Debugger
third_party/pep8/lib2to3/lib2to3/pytree.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/third_party/pep8/lib2to3/lib2to3/pytree.py#L429-L445
def convert(gr, raw_node): """ Convert raw node information to a Node or Leaf instance. This is passed to the parser driver which calls it whenever a reduction of a grammar rule produces a new complete node, so that the tree is build strictly bottom-up. """ type, value, context, children = ...
[ "def", "convert", "(", "gr", ",", "raw_node", ")", ":", "type", ",", "value", ",", "context", ",", "children", "=", "raw_node", "if", "children", "or", "type", "in", "gr", ".", "number2symbol", ":", "# If there's exactly one child, return that child instead of", ...
Convert raw node information to a Node or Leaf instance. This is passed to the parser driver which calls it whenever a reduction of a grammar rule produces a new complete node, so that the tree is build strictly bottom-up.
[ "Convert", "raw", "node", "information", "to", "a", "Node", "or", "Leaf", "instance", "." ]
python
train
resonai/ybt
yabt/buildcontext.py
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L167-L181
def remove_target(self, target_name: str): """Remove (unregister) a `target` from this build context. Removes the target instance with the given name, if it exists, from both the `targets` map and the `targets_by_module` map. Doesn't do anything if no target with that name is found. ...
[ "def", "remove_target", "(", "self", ",", "target_name", ":", "str", ")", ":", "if", "target_name", "in", "self", ".", "targets", ":", "del", "self", ".", "targets", "[", "target_name", "]", "build_module", "=", "split_build_module", "(", "target_name", ")",...
Remove (unregister) a `target` from this build context. Removes the target instance with the given name, if it exists, from both the `targets` map and the `targets_by_module` map. Doesn't do anything if no target with that name is found. Doesn't touch the target graph, if it exists.
[ "Remove", "(", "unregister", ")", "a", "target", "from", "this", "build", "context", "." ]
python
train
pltrdy/rouge
rouge/rouge_score.py
https://github.com/pltrdy/rouge/blob/7bf8a83af5ca5c1677b93620b4e1f85ffd63b377/rouge/rouge_score.py#L270-L324
def rouge_l_summary_level(evaluated_sentences, reference_sentences): """ Computes ROUGE-L (summary level) of two text collections of sentences. http://research.microsoft.com/en-us/um/people/cyl/download/papers/ rouge-working-note-v1.3.1.pdf Calculated according to: R_lcs = SUM(1, u)[LCS<union>(...
[ "def", "rouge_l_summary_level", "(", "evaluated_sentences", ",", "reference_sentences", ")", ":", "if", "len", "(", "evaluated_sentences", ")", "<=", "0", "or", "len", "(", "reference_sentences", ")", "<=", "0", ":", "raise", "ValueError", "(", "\"Collections must...
Computes ROUGE-L (summary level) of two text collections of sentences. http://research.microsoft.com/en-us/um/people/cyl/download/papers/ rouge-working-note-v1.3.1.pdf Calculated according to: R_lcs = SUM(1, u)[LCS<union>(r_i,C)]/m P_lcs = SUM(1, u)[LCS<union>(r_i,C)]/n F_lcs = ((1 + beta^2)*R_...
[ "Computes", "ROUGE", "-", "L", "(", "summary", "level", ")", "of", "two", "text", "collections", "of", "sentences", ".", "http", ":", "//", "research", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "um", "/", "people", "/", "cyl", "/", "...
python
test
lsst-sqre/ltd-conveyor
ltdconveyor/s3/upload.py
https://github.com/lsst-sqre/ltd-conveyor/blob/c492937c4c1e050ccc4a0b9dcc38f9980d57e305/ltdconveyor/s3/upload.py#L434-L464
def delete_directory(self, dirname): """Delete a directory (and contents) from the bucket. Parameters ---------- dirname : `str` Name of the directory, relative to ``bucket_root/``. Raises ------ RuntimeError Raised when there are no obje...
[ "def", "delete_directory", "(", "self", ",", "dirname", ")", ":", "key", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_bucket_root", ",", "dirname", ")", "if", "not", "key", ".", "endswith", "(", "'/'", ")", ":", "key", "+=", "'/'", "key...
Delete a directory (and contents) from the bucket. Parameters ---------- dirname : `str` Name of the directory, relative to ``bucket_root/``. Raises ------ RuntimeError Raised when there are no objects to delete (directory does not ex...
[ "Delete", "a", "directory", "(", "and", "contents", ")", "from", "the", "bucket", "." ]
python
test
awslabs/serverless-application-model
samtranslator/policy_template_processor/template.py
https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/policy_template_processor/template.py#L102-L115
def from_dict(template_name, template_values_dict): """ Parses the input and returns an instance of this class. :param string template_name: Name of the template :param dict template_values_dict: Dictionary containing the value of the template. This dict must have passed the...
[ "def", "from_dict", "(", "template_name", ",", "template_values_dict", ")", ":", "parameters", "=", "template_values_dict", ".", "get", "(", "\"Parameters\"", ",", "{", "}", ")", "definition", "=", "template_values_dict", ".", "get", "(", "\"Definition\"", ",", ...
Parses the input and returns an instance of this class. :param string template_name: Name of the template :param dict template_values_dict: Dictionary containing the value of the template. This dict must have passed the JSON Schema validation. :return Template: Instance of this clas...
[ "Parses", "the", "input", "and", "returns", "an", "instance", "of", "this", "class", "." ]
python
train
jobovy/galpy
galpy/potential/Potential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/Potential.py#L1466-L1536
def ttensor(self,R,z,phi=0.,t=0.,eigenval=False): """ NAME: ttensor PURPOSE: Calculate the tidal tensor Tij=-d(Psi)(dxidxj) INPUT: R - Galactocentric radius (can be Quantity) ...
[ "def", "ttensor", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ",", "eigenval", "=", "False", ")", ":", "if", "self", ".", "isNonAxi", ":", "raise", "PotentialError", "(", "\"Tidal tensor calculation is currently only implem...
NAME: ttensor PURPOSE: Calculate the tidal tensor Tij=-d(Psi)(dxidxj) INPUT: R - Galactocentric radius (can be Quantity) z - height (can be Quantity) phi - azimuth (...
[ "NAME", ":", "ttensor", "PURPOSE", ":", "Calculate", "the", "tidal", "tensor", "Tij", "=", "-", "d", "(", "Psi", ")", "(", "dxidxj", ")", "INPUT", ":", "R", "-", "Galactocentric", "radius", "(", "can", "be", "Quantity", ")", "z", "-", "height", "(", ...
python
train
google/apitools
apitools/base/protorpclite/messages.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/protorpclite/messages.py#L1697-L1714
def value_to_message(self, value): """Convert a value instance to a message. Used by serializers to convert Python user types to underlying messages for transmission. Args: value: A value of type self.type. Returns: An instance of type self.message_type. ...
[ "def", "value_to_message", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "self", ".", "type", ")", ":", "raise", "EncodeError", "(", "'Expected type %s, got %s: %r'", "%", "(", "self", ".", "type", ".", "__name__", ",",...
Convert a value instance to a message. Used by serializers to convert Python user types to underlying messages for transmission. Args: value: A value of type self.type. Returns: An instance of type self.message_type.
[ "Convert", "a", "value", "instance", "to", "a", "message", "." ]
python
train
PyCQA/astroid
astroid/bases.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/bases.py#L120-L151
def _infer_stmts(stmts, context, frame=None): """Return an iterator on statements inferred by each statement in *stmts*.""" inferred = False if context is not None: name = context.lookupname context = context.clone() else: name = None context = contextmod.InferenceContext...
[ "def", "_infer_stmts", "(", "stmts", ",", "context", ",", "frame", "=", "None", ")", ":", "inferred", "=", "False", "if", "context", "is", "not", "None", ":", "name", "=", "context", ".", "lookupname", "context", "=", "context", ".", "clone", "(", ")",...
Return an iterator on statements inferred by each statement in *stmts*.
[ "Return", "an", "iterator", "on", "statements", "inferred", "by", "each", "statement", "in", "*", "stmts", "*", "." ]
python
train
inveniosoftware/invenio-marc21
invenio_marc21/serializers/marcxml.py
https://github.com/inveniosoftware/invenio-marc21/blob/b91347b5b000757b6dc9dc1be88d76ca09611905/invenio_marc21/serializers/marcxml.py#L44-L54
def dump(self, obj): """Serialize object with schema. :param obj: The object to serialize. :returns: The object serialized. """ if self.schema_class: obj = self.schema_class().dump(obj).data else: obj = obj['metadata'] return super(MARCXML...
[ "def", "dump", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "schema_class", ":", "obj", "=", "self", ".", "schema_class", "(", ")", ".", "dump", "(", "obj", ")", ".", "data", "else", ":", "obj", "=", "obj", "[", "'metadata'", "]", "retur...
Serialize object with schema. :param obj: The object to serialize. :returns: The object serialized.
[ "Serialize", "object", "with", "schema", "." ]
python
train
pypa/pipenv
pipenv/patched/notpip/_vendor/urllib3/contrib/pyopenssl.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/urllib3/contrib/pyopenssl.py#L157-L192
def _dnsname_to_stdlib(name): """ Converts a dNSName SubjectAlternativeName field to the form used by the standard library on the given Python version. Cryptography produces a dNSName as a unicode string that was idna-decoded from ASCII bytes. We need to idna-encode that string to get it back, and ...
[ "def", "_dnsname_to_stdlib", "(", "name", ")", ":", "def", "idna_encode", "(", "name", ")", ":", "\"\"\"\n Borrowed wholesale from the Python Cryptography Project. It turns out\n that we can't just safely call `idna.encode`: it can explode for\n wildcard names. This avoi...
Converts a dNSName SubjectAlternativeName field to the form used by the standard library on the given Python version. Cryptography produces a dNSName as a unicode string that was idna-decoded from ASCII bytes. We need to idna-encode that string to get it back, and then on Python 3 we also need to conve...
[ "Converts", "a", "dNSName", "SubjectAlternativeName", "field", "to", "the", "form", "used", "by", "the", "standard", "library", "on", "the", "given", "Python", "version", "." ]
python
train
The-Politico/politico-civic-geography
geography/models/division.py
https://github.com/The-Politico/politico-civic-geography/blob/032b3ee773b50b65cfe672f230dda772df0f89e0/geography/models/division.py#L84-L99
def add_intersecting(self, division, intersection=None, symm=True): """ Adds paired relationships between intersecting divisions. Optional intersection represents the portion of the area of the related division intersecting this division. You can only specify an intersection on ...
[ "def", "add_intersecting", "(", "self", ",", "division", ",", "intersection", "=", "None", ",", "symm", "=", "True", ")", ":", "relationship", ",", "created", "=", "IntersectRelationship", ".", "objects", ".", "update_or_create", "(", "from_division", "=", "se...
Adds paired relationships between intersecting divisions. Optional intersection represents the portion of the area of the related division intersecting this division. You can only specify an intersection on one side of the relationship when adding a peer.
[ "Adds", "paired", "relationships", "between", "intersecting", "divisions", "." ]
python
train
senaite/senaite.core
bika/lims/browser/client/views/analysisspecs.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/client/views/analysisspecs.py#L33-L41
def before_render(self): """Before template render hook """ # We want to display the nav tabs, so we do NOT want disable_border in # the request. Thus, do not call super.before_render mtool = api.get_tool("portal_membership") if not mtool.checkPermission(AddAnalysisSpec,...
[ "def", "before_render", "(", "self", ")", ":", "# We want to display the nav tabs, so we do NOT want disable_border in", "# the request. Thus, do not call super.before_render", "mtool", "=", "api", ".", "get_tool", "(", "\"portal_membership\"", ")", "if", "not", "mtool", ".", ...
Before template render hook
[ "Before", "template", "render", "hook" ]
python
train
saltstack/salt
salt/cloud/clouds/opennebula.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L3373-L3404
def vm_info(name, call=None): ''' Retrieves information for a given virtual machine. A VM name must be supplied. .. versionadded:: 2016.3.0 name The name of the VM for which to gather information. CLI Example: .. code-block:: bash salt-cloud -a vm_info my-vm ''' if c...
[ "def", "vm_info", "(", "name", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The vm_info action must be called with -a or --action.'", ")", "server", ",", "user", ",", "password", "=", "_get_xml_rpc...
Retrieves information for a given virtual machine. A VM name must be supplied. .. versionadded:: 2016.3.0 name The name of the VM for which to gather information. CLI Example: .. code-block:: bash salt-cloud -a vm_info my-vm
[ "Retrieves", "information", "for", "a", "given", "virtual", "machine", ".", "A", "VM", "name", "must", "be", "supplied", "." ]
python
train
SITools2/pySitools2_1.0
sitools2/core/query.py
https://github.com/SITools2/pySitools2_1.0/blob/acd13198162456ba401a0b923af989bb29feb3b6/sitools2/core/query.py#L228-L235
def _getParameters(self): """Returns the result of this decorator.""" param = self.query._getParameters() key = self.__PATTERN_KEY % (str(self._getIndex())) val = self.__PATTERN_VALUE % (self.__column, self.__value) #self.__column.getColumnAlias() param.update({key:val}) ...
[ "def", "_getParameters", "(", "self", ")", ":", "param", "=", "self", ".", "query", ".", "_getParameters", "(", ")", "key", "=", "self", ".", "__PATTERN_KEY", "%", "(", "str", "(", "self", ".", "_getIndex", "(", ")", ")", ")", "val", "=", "self", "...
Returns the result of this decorator.
[ "Returns", "the", "result", "of", "this", "decorator", "." ]
python
train
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L193-L212
def add_workflow(self, workflow, commit=False): """ Add a new workflow and optionally commit it to the database :param workflow: The workflow :param commit: Whether to commit the workflow to the database :type workflow: Workflow :type commit: bool :return: None ...
[ "def", "add_workflow", "(", "self", ",", "workflow", ",", "commit", "=", "False", ")", ":", "if", "workflow", ".", "workflow_id", "in", "self", ".", "workflows", ":", "raise", "KeyError", "(", "\"Workflow with id {} already exists\"", ".", "format", "(", "work...
Add a new workflow and optionally commit it to the database :param workflow: The workflow :param commit: Whether to commit the workflow to the database :type workflow: Workflow :type commit: bool :return: None
[ "Add", "a", "new", "workflow", "and", "optionally", "commit", "it", "to", "the", "database", ":", "param", "workflow", ":", "The", "workflow", ":", "param", "commit", ":", "Whether", "to", "commit", "the", "workflow", "to", "the", "database", ":", "type", ...
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/collections/base_collection.py#L22-L29
def next_power_of_2(n): """ Return next power of 2 greater than or equal to n """ n -= 1 # greater than OR EQUAL TO n shift = 1 while (n + 1) & n: # n+1 is not a power of 2 yet n |= n >> shift shift *= 2 return max(4, n + 1)
[ "def", "next_power_of_2", "(", "n", ")", ":", "n", "-=", "1", "# greater than OR EQUAL TO n", "shift", "=", "1", "while", "(", "n", "+", "1", ")", "&", "n", ":", "# n+1 is not a power of 2 yet", "n", "|=", "n", ">>", "shift", "shift", "*=", "2", "return"...
Return next power of 2 greater than or equal to n
[ "Return", "next", "power", "of", "2", "greater", "than", "or", "equal", "to", "n" ]
python
train
FujiMakoto/IPS-Vagrant
ips_vagrant/downloaders/ips.py
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/downloaders/ips.py#L71-L93
def _read_zip(self, filepath): """ Read an IPS installation zipfile and return the core version number @type filepath: str @rtype: Version """ with ZipFile(filepath) as zip: namelist = zip.namelist() if re.match(r'^ips_\w{5}/?$', namelist[0]): ...
[ "def", "_read_zip", "(", "self", ",", "filepath", ")", ":", "with", "ZipFile", "(", "filepath", ")", "as", "zip", ":", "namelist", "=", "zip", ".", "namelist", "(", ")", "if", "re", ".", "match", "(", "r'^ips_\\w{5}/?$'", ",", "namelist", "[", "0", "...
Read an IPS installation zipfile and return the core version number @type filepath: str @rtype: Version
[ "Read", "an", "IPS", "installation", "zipfile", "and", "return", "the", "core", "version", "number" ]
python
train
invoice-x/invoice2data
src/invoice2data/input/pdftotext.py
https://github.com/invoice-x/invoice2data/blob/d97fdc5db9c1844fd77fa64f8ea7c42fefd0ba20/src/invoice2data/input/pdftotext.py#L2-L31
def to_text(path): """Wrapper around Poppler pdftotext. Parameters ---------- path : str path of electronic invoice in PDF Returns ------- out : str returns extracted text from pdf Raises ------ EnvironmentError: If pdftotext library is not found ""...
[ "def", "to_text", "(", "path", ")", ":", "import", "subprocess", "from", "distutils", "import", "spawn", "# py2 compat", "if", "spawn", ".", "find_executable", "(", "\"pdftotext\"", ")", ":", "# shutil.which('pdftotext'):", "out", ",", "err", "=", "subprocess", ...
Wrapper around Poppler pdftotext. Parameters ---------- path : str path of electronic invoice in PDF Returns ------- out : str returns extracted text from pdf Raises ------ EnvironmentError: If pdftotext library is not found
[ "Wrapper", "around", "Poppler", "pdftotext", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/flows.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L254-L266
def set_workdir(self, workdir, chroot=False): """ Set the working directory. Cannot be set more than once unless chroot is True """ if not chroot and hasattr(self, "workdir") and self.workdir != workdir: raise ValueError("self.workdir != workdir: %s, %s" % (self.workdir, wor...
[ "def", "set_workdir", "(", "self", ",", "workdir", ",", "chroot", "=", "False", ")", ":", "if", "not", "chroot", "and", "hasattr", "(", "self", ",", "\"workdir\"", ")", "and", "self", ".", "workdir", "!=", "workdir", ":", "raise", "ValueError", "(", "\...
Set the working directory. Cannot be set more than once unless chroot is True
[ "Set", "the", "working", "directory", ".", "Cannot", "be", "set", "more", "than", "once", "unless", "chroot", "is", "True" ]
python
train