id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
49,500
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/rst/hilda.py
HILDARSTTree.hildatree2dgparentedtree
def hildatree2dgparentedtree(self): """Convert the tree from HILDA's format into a conventional binary tree, which can be easily converted into output formats like RS3. """ def transform(hilda_tree): """Transform a HILDA parse tree into a more conventional parse tree. ...
python
def hildatree2dgparentedtree(self): """Convert the tree from HILDA's format into a conventional binary tree, which can be easily converted into output formats like RS3. """ def transform(hilda_tree): """Transform a HILDA parse tree into a more conventional parse tree. ...
[ "def", "hildatree2dgparentedtree", "(", "self", ")", ":", "def", "transform", "(", "hilda_tree", ")", ":", "\"\"\"Transform a HILDA parse tree into a more conventional parse tree.\n\n The input tree::\n\n Contrast[S][N]\n __...
Convert the tree from HILDA's format into a conventional binary tree, which can be easily converted into output formats like RS3.
[ "Convert", "the", "tree", "from", "HILDA", "s", "format", "into", "a", "conventional", "binary", "tree", "which", "can", "be", "easily", "converted", "into", "output", "formats", "like", "RS3", "." ]
842f0068a3190be2c75905754521b176b25a54fb
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/hilda.py#L58-L96
49,501
jrderuiter/pybiomart
src/pybiomart/server.py
Server.marts
def marts(self): """List of available marts.""" if self._marts is None: self._marts = self._fetch_marts() return self._marts
python
def marts(self): """List of available marts.""" if self._marts is None: self._marts = self._fetch_marts() return self._marts
[ "def", "marts", "(", "self", ")", ":", "if", "self", ".", "_marts", "is", "None", ":", "self", ".", "_marts", "=", "self", ".", "_fetch_marts", "(", ")", "return", "self", ".", "_marts" ]
List of available marts.
[ "List", "of", "available", "marts", "." ]
7802d45fe88549ab0512d6f37f815fc43b172b39
https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/server.py#L58-L62
49,502
jrderuiter/pybiomart
src/pybiomart/server.py
Server.list_marts
def list_marts(self): """Lists available marts in a readable DataFrame format. Returns: pd.DataFrame: Frame listing available marts. """ def _row_gen(attributes): for attr in attributes.values(): yield (attr.name, attr.display_name) retu...
python
def list_marts(self): """Lists available marts in a readable DataFrame format. Returns: pd.DataFrame: Frame listing available marts. """ def _row_gen(attributes): for attr in attributes.values(): yield (attr.name, attr.display_name) retu...
[ "def", "list_marts", "(", "self", ")", ":", "def", "_row_gen", "(", "attributes", ")", ":", "for", "attr", "in", "attributes", ".", "values", "(", ")", ":", "yield", "(", "attr", ".", "name", ",", "attr", ".", "display_name", ")", "return", "pd", "."...
Lists available marts in a readable DataFrame format. Returns: pd.DataFrame: Frame listing available marts.
[ "Lists", "available", "marts", "in", "a", "readable", "DataFrame", "format", "." ]
7802d45fe88549ab0512d6f37f815fc43b172b39
https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/server.py#L64-L76
49,503
kata198/python-nonblock
nonblock/BackgroundRead.py
bgread
def bgread(stream, blockSizeLimit=65535, pollTime=.03, closeStream=True): ''' bgread - Start a thread which will read from the given stream in a non-blocking fashion, and automatically populate data in the returned object. @param stream <object> - A stream on which to read. Socket, file, etc. ...
python
def bgread(stream, blockSizeLimit=65535, pollTime=.03, closeStream=True): ''' bgread - Start a thread which will read from the given stream in a non-blocking fashion, and automatically populate data in the returned object. @param stream <object> - A stream on which to read. Socket, file, etc. ...
[ "def", "bgread", "(", "stream", ",", "blockSizeLimit", "=", "65535", ",", "pollTime", "=", ".03", ",", "closeStream", "=", "True", ")", ":", "try", ":", "pollTime", "=", "float", "(", "pollTime", ")", "except", "ValueError", ":", "raise", "ValueError", "...
bgread - Start a thread which will read from the given stream in a non-blocking fashion, and automatically populate data in the returned object. @param stream <object> - A stream on which to read. Socket, file, etc. @param blockSizeLimit <None/int> - Number of bytes. Default 65535. ...
[ "bgread", "-", "Start", "a", "thread", "which", "will", "read", "from", "the", "given", "stream", "in", "a", "non", "-", "blocking", "fashion", "and", "automatically", "populate", "data", "in", "the", "returned", "object", "." ]
3f011b3b3b494ccb44d48179e94167fb7382e4a4
https://github.com/kata198/python-nonblock/blob/3f011b3b3b494ccb44d48179e94167fb7382e4a4/nonblock/BackgroundRead.py#L19-L73
49,504
kata198/python-nonblock
nonblock/BackgroundRead.py
_do_bgread
def _do_bgread(stream, blockSizeLimit, pollTime, closeStream, results): ''' _do_bgread - Worker functon for the background read thread. @param stream <object> - Stream to read until closed @param results <BackgroundReadData> ''' # Put the whole function in a try instead of just the...
python
def _do_bgread(stream, blockSizeLimit, pollTime, closeStream, results): ''' _do_bgread - Worker functon for the background read thread. @param stream <object> - Stream to read until closed @param results <BackgroundReadData> ''' # Put the whole function in a try instead of just the...
[ "def", "_do_bgread", "(", "stream", ",", "blockSizeLimit", ",", "pollTime", ",", "closeStream", ",", "results", ")", ":", "# Put the whole function in a try instead of just the read portion for performance reasons.", "try", ":", "while", "True", ":", "nextData", "=", "non...
_do_bgread - Worker functon for the background read thread. @param stream <object> - Stream to read until closed @param results <BackgroundReadData>
[ "_do_bgread", "-", "Worker", "functon", "for", "the", "background", "read", "thread", "." ]
3f011b3b3b494ccb44d48179e94167fb7382e4a4
https://github.com/kata198/python-nonblock/blob/3f011b3b3b494ccb44d48179e94167fb7382e4a4/nonblock/BackgroundRead.py#L116-L141
49,505
texperience/django-bootstrap-ui
bootstrap_ui/views.py
set_theme
def set_theme(request): """ Redirect to a given url while setting the chosen theme in the session or cookie. The url and the theme identifier need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. I...
python
def set_theme(request): """ Redirect to a given url while setting the chosen theme in the session or cookie. The url and the theme identifier need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. I...
[ "def", "set_theme", "(", "request", ")", ":", "next", "=", "request", ".", "POST", ".", "get", "(", "'next'", ",", "request", ".", "GET", ".", "get", "(", "'next'", ")", ")", "if", "not", "is_safe_url", "(", "url", "=", "next", ",", "host", "=", ...
Redirect to a given url while setting the chosen theme in the session or cookie. The url and the theme identifier need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. If called as a GET request, it wi...
[ "Redirect", "to", "a", "given", "url", "while", "setting", "the", "chosen", "theme", "in", "the", "session", "or", "cookie", ".", "The", "url", "and", "the", "theme", "identifier", "need", "to", "be", "specified", "in", "the", "request", "parameters", "." ...
72b57ca8397ac2bf33ba03b31770dae4d4a6b264
https://github.com/texperience/django-bootstrap-ui/blob/72b57ca8397ac2bf33ba03b31770dae4d4a6b264/bootstrap_ui/views.py#L5-L33
49,506
codeinn/vcs
vcs/utils/baseui_config.py
make_ui
def make_ui(self, path='hgwebdir.config'): """ A funcion that will read python rc files and make an ui from read options :param path: path to mercurial config file """ #propagated from mercurial documentation sections = [ 'alias', 'auth', 'decode/...
python
def make_ui(self, path='hgwebdir.config'): """ A funcion that will read python rc files and make an ui from read options :param path: path to mercurial config file """ #propagated from mercurial documentation sections = [ 'alias', 'auth', 'decode/...
[ "def", "make_ui", "(", "self", ",", "path", "=", "'hgwebdir.config'", ")", ":", "#propagated from mercurial documentation", "sections", "=", "[", "'alias'", ",", "'auth'", ",", "'decode/encode'", ",", "'defaults'", ",", "'diff'", ",", "'email'", ",", "'extensions'...
A funcion that will read python rc files and make an ui from read options :param path: path to mercurial config file
[ "A", "funcion", "that", "will", "read", "python", "rc", "files", "and", "make", "an", "ui", "from", "read", "options" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/baseui_config.py#L4-L47
49,507
codeinn/vcs
vcs/backends/hg/changeset.py
MercurialChangeset.status
def status(self): """ Returns modified, added, removed, deleted files for current changeset """ return self.repository._repo.status(self._ctx.p1().node(), self._ctx.node())
python
def status(self): """ Returns modified, added, removed, deleted files for current changeset """ return self.repository._repo.status(self._ctx.p1().node(), self._ctx.node())
[ "def", "status", "(", "self", ")", ":", "return", "self", ".", "repository", ".", "_repo", ".", "status", "(", "self", ".", "_ctx", ".", "p1", "(", ")", ".", "node", "(", ")", ",", "self", ".", "_ctx", ".", "node", "(", ")", ")" ]
Returns modified, added, removed, deleted files for current changeset
[ "Returns", "modified", "added", "removed", "deleted", "files", "for", "current", "changeset" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/changeset.py#L65-L70
49,508
codeinn/vcs
vcs/backends/hg/changeset.py
MercurialChangeset._fix_path
def _fix_path(self, path): """ Paths are stored without trailing slash so we need to get rid off it if needed. Also mercurial keeps filenodes as str so we need to decode from unicode to str """ if path.endswith('/'): path = path.rstrip('/') return saf...
python
def _fix_path(self, path): """ Paths are stored without trailing slash so we need to get rid off it if needed. Also mercurial keeps filenodes as str so we need to decode from unicode to str """ if path.endswith('/'): path = path.rstrip('/') return saf...
[ "def", "_fix_path", "(", "self", ",", "path", ")", ":", "if", "path", ".", "endswith", "(", "'/'", ")", ":", "path", "=", "path", ".", "rstrip", "(", "'/'", ")", "return", "safe_str", "(", "path", ")" ]
Paths are stored without trailing slash so we need to get rid off it if needed. Also mercurial keeps filenodes as str so we need to decode from unicode to str
[ "Paths", "are", "stored", "without", "trailing", "slash", "so", "we", "need", "to", "get", "rid", "off", "it", "if", "needed", ".", "Also", "mercurial", "keeps", "filenodes", "as", "str", "so", "we", "need", "to", "decode", "from", "unicode", "to", "str"...
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/changeset.py#L161-L170
49,509
codeinn/vcs
vcs/backends/hg/changeset.py
MercurialChangeset.get_nodes
def get_nodes(self, path): """ Returns combined ``DirNode`` and ``FileNode`` objects list representing state of changeset at the given ``path``. If node at the given ``path`` is not instance of ``DirNode``, ChangesetError would be raised. """ if self._get_kind(path) != N...
python
def get_nodes(self, path): """ Returns combined ``DirNode`` and ``FileNode`` objects list representing state of changeset at the given ``path``. If node at the given ``path`` is not instance of ``DirNode``, ChangesetError would be raised. """ if self._get_kind(path) != N...
[ "def", "get_nodes", "(", "self", ",", "path", ")", ":", "if", "self", ".", "_get_kind", "(", "path", ")", "!=", "NodeKind", ".", "DIR", ":", "raise", "ChangesetError", "(", "\"Directory does not exist for revision %s at \"", "\" '%s'\"", "%", "(", "self", ".",...
Returns combined ``DirNode`` and ``FileNode`` objects list representing state of changeset at the given ``path``. If node at the given ``path`` is not instance of ``DirNode``, ChangesetError would be raised.
[ "Returns", "combined", "DirNode", "and", "FileNode", "objects", "list", "representing", "state", "of", "changeset", "at", "the", "given", "path", ".", "If", "node", "at", "the", "given", "path", "is", "not", "instance", "of", "DirNode", "ChangesetError", "woul...
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/changeset.py#L297-L329
49,510
codeinn/vcs
vcs/backends/hg/changeset.py
MercurialChangeset.get_node
def get_node(self, path): """ Returns ``Node`` object from the given ``path``. If there is no node at the given ``path``, ``ChangesetError`` would be raised. """ path = self._fix_path(path) if not path in self.nodes: if path in self._file_paths: ...
python
def get_node(self, path): """ Returns ``Node`` object from the given ``path``. If there is no node at the given ``path``, ``ChangesetError`` would be raised. """ path = self._fix_path(path) if not path in self.nodes: if path in self._file_paths: ...
[ "def", "get_node", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_fix_path", "(", "path", ")", "if", "not", "path", "in", "self", ".", "nodes", ":", "if", "path", "in", "self", ".", "_file_paths", ":", "node", "=", "FileNode", "(",...
Returns ``Node`` object from the given ``path``. If there is no node at the given ``path``, ``ChangesetError`` would be raised.
[ "Returns", "Node", "object", "from", "the", "given", "path", ".", "If", "there", "is", "no", "node", "at", "the", "given", "path", "ChangesetError", "would", "be", "raised", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/changeset.py#L331-L353
49,511
codeinn/vcs
vcs/nodes.py
FileNode.content
def content(self): """ Returns lazily content of the FileNode. If possible, would try to decode content from UTF-8. """ content = self._get_content() if bool(content and '\0' in content): return content return safe_unicode(content)
python
def content(self): """ Returns lazily content of the FileNode. If possible, would try to decode content from UTF-8. """ content = self._get_content() if bool(content and '\0' in content): return content return safe_unicode(content)
[ "def", "content", "(", "self", ")", ":", "content", "=", "self", ".", "_get_content", "(", ")", "if", "bool", "(", "content", "and", "'\\0'", "in", "content", ")", ":", "return", "content", "return", "safe_unicode", "(", "content", ")" ]
Returns lazily content of the FileNode. If possible, would try to decode content from UTF-8.
[ "Returns", "lazily", "content", "of", "the", "FileNode", ".", "If", "possible", "would", "try", "to", "decode", "content", "from", "UTF", "-", "8", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/nodes.py#L276-L285
49,512
codeinn/vcs
vcs/nodes.py
FileNode.lexer
def lexer(self): """ Returns pygment's lexer class. Would try to guess lexer taking file's content, name and mimetype. """ try: lexer = lexers.guess_lexer_for_filename(self.name, self.content, stripnl=False) except lexers.ClassNotFound: lexer = le...
python
def lexer(self): """ Returns pygment's lexer class. Would try to guess lexer taking file's content, name and mimetype. """ try: lexer = lexers.guess_lexer_for_filename(self.name, self.content, stripnl=False) except lexers.ClassNotFound: lexer = le...
[ "def", "lexer", "(", "self", ")", ":", "try", ":", "lexer", "=", "lexers", ".", "guess_lexer_for_filename", "(", "self", ".", "name", ",", "self", ".", "content", ",", "stripnl", "=", "False", ")", "except", "lexers", ".", "ClassNotFound", ":", "lexer", ...
Returns pygment's lexer class. Would try to guess lexer taking file's content, name and mimetype.
[ "Returns", "pygment", "s", "lexer", "class", ".", "Would", "try", "to", "guess", "lexer", "taking", "file", "s", "content", "name", "and", "mimetype", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/nodes.py#L348-L359
49,513
codeinn/vcs
vcs/nodes.py
FileNode.history
def history(self): """ Returns a list of changeset for this file in which the file was changed """ if self.changeset is None: raise NodeError('Unable to get changeset for this FileNode') return self.changeset.get_file_history(self.path)
python
def history(self): """ Returns a list of changeset for this file in which the file was changed """ if self.changeset is None: raise NodeError('Unable to get changeset for this FileNode') return self.changeset.get_file_history(self.path)
[ "def", "history", "(", "self", ")", ":", "if", "self", ".", "changeset", "is", "None", ":", "raise", "NodeError", "(", "'Unable to get changeset for this FileNode'", ")", "return", "self", ".", "changeset", ".", "get_file_history", "(", "self", ".", "path", ")...
Returns a list of changeset for this file in which the file was changed
[ "Returns", "a", "list", "of", "changeset", "for", "this", "file", "in", "which", "the", "file", "was", "changed" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/nodes.py#L369-L375
49,514
codeinn/vcs
vcs/nodes.py
FileNode.annotate
def annotate(self): """ Returns a list of three element tuples with lineno,changeset and line """ if self.changeset is None: raise NodeError('Unable to get changeset for this FileNode') return self.changeset.get_file_annotate(self.path)
python
def annotate(self): """ Returns a list of three element tuples with lineno,changeset and line """ if self.changeset is None: raise NodeError('Unable to get changeset for this FileNode') return self.changeset.get_file_annotate(self.path)
[ "def", "annotate", "(", "self", ")", ":", "if", "self", ".", "changeset", "is", "None", ":", "raise", "NodeError", "(", "'Unable to get changeset for this FileNode'", ")", "return", "self", ".", "changeset", ".", "get_file_annotate", "(", "self", ".", "path", ...
Returns a list of three element tuples with lineno,changeset and line
[ "Returns", "a", "list", "of", "three", "element", "tuples", "with", "lineno", "changeset", "and", "line" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/nodes.py#L378-L384
49,515
codeinn/vcs
vcs/nodes.py
SubModuleNode.name
def name(self): """ Returns name of the node so if its path then only last part is returned. """ org = safe_unicode(self.path.rstrip('/').split('/')[-1]) return u'%s @ %s' % (org, self.changeset.short_id)
python
def name(self): """ Returns name of the node so if its path then only last part is returned. """ org = safe_unicode(self.path.rstrip('/').split('/')[-1]) return u'%s @ %s' % (org, self.changeset.short_id)
[ "def", "name", "(", "self", ")", ":", "org", "=", "safe_unicode", "(", "self", ".", "path", ".", "rstrip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", ")", "return", "u'%s @ %s'", "%", "(", "org", ",", "self", ".", "chan...
Returns name of the node so if its path then only last part is returned.
[ "Returns", "name", "of", "the", "node", "so", "if", "its", "path", "then", "only", "last", "part", "is", "returned", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/nodes.py#L601-L607
49,516
NICTA/revrand
revrand/glm.py
GeneralizedLinearModel.predict
def predict(self, X, nsamples=200, likelihood_args=()): """ Predict target values from Bayesian generalized linear regression. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, d dimensions). nsamples : int, optional ...
python
def predict(self, X, nsamples=200, likelihood_args=()): """ Predict target values from Bayesian generalized linear regression. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, d dimensions). nsamples : int, optional ...
[ "def", "predict", "(", "self", ",", "X", ",", "nsamples", "=", "200", ",", "likelihood_args", "=", "(", ")", ")", ":", "Ey", ",", "_", "=", "self", ".", "predict_moments", "(", "X", ",", "nsamples", ",", "likelihood_args", ")", "return", "Ey" ]
Predict target values from Bayesian generalized linear regression. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, d dimensions). nsamples : int, optional Number of samples for sampling the expected target values from the ...
[ "Predict", "target", "values", "from", "Bayesian", "generalized", "linear", "regression", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/glm.py#L324-L347
49,517
NICTA/revrand
revrand/glm.py
GeneralizedLinearModel.predict_moments
def predict_moments(self, X, nsamples=200, likelihood_args=()): r""" Predictive moments, in particular mean and variance, of a Bayesian GLM. This function uses Monte-Carlo sampling to evaluate the predictive mean and variance of a Bayesian GLM. The exact expressions evaluated are, ...
python
def predict_moments(self, X, nsamples=200, likelihood_args=()): r""" Predictive moments, in particular mean and variance, of a Bayesian GLM. This function uses Monte-Carlo sampling to evaluate the predictive mean and variance of a Bayesian GLM. The exact expressions evaluated are, ...
[ "def", "predict_moments", "(", "self", ",", "X", ",", "nsamples", "=", "200", ",", "likelihood_args", "=", "(", ")", ")", ":", "# Get latent function samples", "N", "=", "X", ".", "shape", "[", "0", "]", "ys", "=", "np", ".", "empty", "(", "(", "N", ...
r""" Predictive moments, in particular mean and variance, of a Bayesian GLM. This function uses Monte-Carlo sampling to evaluate the predictive mean and variance of a Bayesian GLM. The exact expressions evaluated are, .. math :: \mathbb{E}[y^* | \mathbf{x^*}, \mathbf{X}, y...
[ "r", "Predictive", "moments", "in", "particular", "mean", "and", "variance", "of", "a", "Bayesian", "GLM", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/glm.py#L349-L418
49,518
NICTA/revrand
revrand/glm.py
GeneralizedLinearModel.predict_logpdf
def predict_logpdf(self, X, y, nsamples=200, likelihood_args=()): r""" Predictive log-probability density function of a Bayesian GLM. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, D dimensions). y : float or ndarray ...
python
def predict_logpdf(self, X, y, nsamples=200, likelihood_args=()): r""" Predictive log-probability density function of a Bayesian GLM. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, D dimensions). y : float or ndarray ...
[ "def", "predict_logpdf", "(", "self", ",", "X", ",", "y", ",", "nsamples", "=", "200", ",", "likelihood_args", "=", "(", ")", ")", ":", "X", ",", "y", "=", "check_X_y", "(", "X", ",", "y", ")", "# Get latent function samples", "N", "=", "X", ".", "...
r""" Predictive log-probability density function of a Bayesian GLM. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, D dimensions). y : float or ndarray The test observations of shape (N*,) to evaluate under, :ma...
[ "r", "Predictive", "log", "-", "probability", "density", "function", "of", "a", "Bayesian", "GLM", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/glm.py#L420-L466
49,519
NICTA/revrand
revrand/glm.py
GeneralizedLinearModel.predict_cdf
def predict_cdf(self, X, quantile, nsamples=200, likelihood_args=()): r""" Predictive cumulative density function of a Bayesian GLM. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, D dimensions). quantile : float Th...
python
def predict_cdf(self, X, quantile, nsamples=200, likelihood_args=()): r""" Predictive cumulative density function of a Bayesian GLM. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, D dimensions). quantile : float Th...
[ "def", "predict_cdf", "(", "self", ",", "X", ",", "quantile", ",", "nsamples", "=", "200", ",", "likelihood_args", "=", "(", ")", ")", ":", "# Get latent function samples", "N", "=", "X", ".", "shape", "[", "0", "]", "ps", "=", "np", ".", "empty", "(...
r""" Predictive cumulative density function of a Bayesian GLM. Parameters ---------- X : ndarray (N*,d) array query input dataset (N* samples, D dimensions). quantile : float The predictive probability, :math:`p(y^* \leq \text{quantile} | \mat...
[ "r", "Predictive", "cumulative", "density", "function", "of", "a", "Bayesian", "GLM", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/glm.py#L468-L516
49,520
dead-beef/markovchain
markovchain/cli/image.py
cmd_generate
def cmd_generate(args): """Generate images. Parameters ---------- args : `argparse.Namespace` Command arguments. """ check_output_format(args.output, args.count) markov = load(MarkovImage, args.state, args) if args.size is None: if markov.scanner.resize is None: ...
python
def cmd_generate(args): """Generate images. Parameters ---------- args : `argparse.Namespace` Command arguments. """ check_output_format(args.output, args.count) markov = load(MarkovImage, args.state, args) if args.size is None: if markov.scanner.resize is None: ...
[ "def", "cmd_generate", "(", "args", ")", ":", "check_output_format", "(", "args", ".", "output", ",", "args", ".", "count", ")", "markov", "=", "load", "(", "MarkovImage", ",", "args", ".", "state", ",", "args", ")", "if", "args", ".", "size", "is", ...
Generate images. Parameters ---------- args : `argparse.Namespace` Command arguments.
[ "Generate", "images", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/image.py#L286-L325
49,521
dead-beef/markovchain
markovchain/cli/image.py
cmd_filter
def cmd_filter(args): """Filter an image. Parameters ---------- args : `argparse.Namespace` Command arguments. """ check_output_format(args.output, args.count) img = Image.open(args.input) width, height = img.size if args.state is not None: markov = load(MarkovImag...
python
def cmd_filter(args): """Filter an image. Parameters ---------- args : `argparse.Namespace` Command arguments. """ check_output_format(args.output, args.count) img = Image.open(args.input) width, height = img.size if args.state is not None: markov = load(MarkovImag...
[ "def", "cmd_filter", "(", "args", ")", ":", "check_output_format", "(", "args", ".", "output", ",", "args", ".", "count", ")", "img", "=", "Image", ".", "open", "(", "args", ".", "input", ")", "width", ",", "height", "=", "img", ".", "size", "if", ...
Filter an image. Parameters ---------- args : `argparse.Namespace` Command arguments.
[ "Filter", "an", "image", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/image.py#L327-L375
49,522
dead-beef/markovchain
markovchain/text/util.py
lstrip_ws_and_chars
def lstrip_ws_and_chars(string, chars): """Remove leading whitespace and characters from a string. Parameters ---------- string : `str` String to strip. chars : `str` Characters to remove. Returns ------- `str` Stripped string. Examples -------- >>>...
python
def lstrip_ws_and_chars(string, chars): """Remove leading whitespace and characters from a string. Parameters ---------- string : `str` String to strip. chars : `str` Characters to remove. Returns ------- `str` Stripped string. Examples -------- >>>...
[ "def", "lstrip_ws_and_chars", "(", "string", ",", "chars", ")", ":", "res", "=", "string", ".", "lstrip", "(", ")", ".", "lstrip", "(", "chars", ")", "while", "len", "(", "res", ")", "!=", "len", "(", "string", ")", ":", "string", "=", "res", "res"...
Remove leading whitespace and characters from a string. Parameters ---------- string : `str` String to strip. chars : `str` Characters to remove. Returns ------- `str` Stripped string. Examples -------- >>> lstrip_ws_and_chars(' \\t.\\n , .x. ', '.,?!')...
[ "Remove", "leading", "whitespace", "and", "characters", "from", "a", "string", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/util.py#L114-L138
49,523
dead-beef/markovchain
markovchain/text/util.py
capitalize
def capitalize(string): """Capitalize a sentence. Parameters ---------- string : `str` String to capitalize. Returns ------- `str` Capitalized string. Examples -------- >>> capitalize('worD WORD WoRd') 'Word word word' """ if not string: ret...
python
def capitalize(string): """Capitalize a sentence. Parameters ---------- string : `str` String to capitalize. Returns ------- `str` Capitalized string. Examples -------- >>> capitalize('worD WORD WoRd') 'Word word word' """ if not string: ret...
[ "def", "capitalize", "(", "string", ")", ":", "if", "not", "string", ":", "return", "string", "if", "len", "(", "string", ")", "==", "1", ":", "return", "string", ".", "upper", "(", ")", "return", "string", "[", "0", "]", ".", "upper", "(", ")", ...
Capitalize a sentence. Parameters ---------- string : `str` String to capitalize. Returns ------- `str` Capitalized string. Examples -------- >>> capitalize('worD WORD WoRd') 'Word word word'
[ "Capitalize", "a", "sentence", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/util.py#L140-L162
49,524
dead-beef/markovchain
markovchain/text/util.py
re_flags
def re_flags(flags, custom=ReFlags): """Parse regexp flag string. Parameters ---------- flags: `str` Flag string. custom: `IntEnum`, optional Custom flag enum (default: None). Returns ------- (`int`, `int`) (flags for `re.compile`, custom flags) Raises ...
python
def re_flags(flags, custom=ReFlags): """Parse regexp flag string. Parameters ---------- flags: `str` Flag string. custom: `IntEnum`, optional Custom flag enum (default: None). Returns ------- (`int`, `int`) (flags for `re.compile`, custom flags) Raises ...
[ "def", "re_flags", "(", "flags", ",", "custom", "=", "ReFlags", ")", ":", "re_", ",", "custom_", "=", "0", ",", "0", "for", "flag", "in", "flags", ".", "upper", "(", ")", ":", "try", ":", "re_", "|=", "getattr", "(", "re", ",", "flag", ")", "ex...
Parse regexp flag string. Parameters ---------- flags: `str` Flag string. custom: `IntEnum`, optional Custom flag enum (default: None). Returns ------- (`int`, `int`) (flags for `re.compile`, custom flags) Raises ------ ValueError
[ "Parse", "regexp", "flag", "string", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/util.py#L165-L196
49,525
dead-beef/markovchain
markovchain/text/util.py
re_flags_str
def re_flags_str(flags, custom_flags): """Convert regexp flags to string. Parameters ---------- flags : `int` Flags. custom_flags : `int` Custom flags. Returns ------- `str` Flag string. """ res = '' for flag in RE_FLAGS: if flags & getattr(r...
python
def re_flags_str(flags, custom_flags): """Convert regexp flags to string. Parameters ---------- flags : `int` Flags. custom_flags : `int` Custom flags. Returns ------- `str` Flag string. """ res = '' for flag in RE_FLAGS: if flags & getattr(r...
[ "def", "re_flags_str", "(", "flags", ",", "custom_flags", ")", ":", "res", "=", "''", "for", "flag", "in", "RE_FLAGS", ":", "if", "flags", "&", "getattr", "(", "re", ",", "flag", ")", ":", "res", "+=", "flag", "for", "flag", "in", "RE_CUSTOM_FLAGS", ...
Convert regexp flags to string. Parameters ---------- flags : `int` Flags. custom_flags : `int` Custom flags. Returns ------- `str` Flag string.
[ "Convert", "regexp", "flags", "to", "string", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/util.py#L198-L220
49,526
dead-beef/markovchain
markovchain/text/util.py
re_sub
def re_sub(pattern, repl, string, count=0, flags=0, custom_flags=0): """Replace regular expression. Parameters ---------- pattern : `str` or `_sre.SRE_Pattern` Compiled regular expression. repl : `str` or `function` Replacement. string : `str` Input string. count: `i...
python
def re_sub(pattern, repl, string, count=0, flags=0, custom_flags=0): """Replace regular expression. Parameters ---------- pattern : `str` or `_sre.SRE_Pattern` Compiled regular expression. repl : `str` or `function` Replacement. string : `str` Input string. count: `i...
[ "def", "re_sub", "(", "pattern", ",", "repl", ",", "string", ",", "count", "=", "0", ",", "flags", "=", "0", ",", "custom_flags", "=", "0", ")", ":", "if", "custom_flags", "&", "ReFlags", ".", "OVERLAP", ":", "prev_string", "=", "None", "while", "str...
Replace regular expression. Parameters ---------- pattern : `str` or `_sre.SRE_Pattern` Compiled regular expression. repl : `str` or `function` Replacement. string : `str` Input string. count: `int` Maximum number of pattern occurrences. flags : `int` ...
[ "Replace", "regular", "expression", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/util.py#L222-L246
49,527
dead-beef/markovchain
markovchain/text/util.py
CharCase.convert
def convert(self, string): """Return a copy of string converted to case. Parameters ---------- string : `str` Returns ------- `str` Examples -------- >>> CharCase.LOWER.convert('sTr InG') 'str ing' >>> CharCase.UPPER.conv...
python
def convert(self, string): """Return a copy of string converted to case. Parameters ---------- string : `str` Returns ------- `str` Examples -------- >>> CharCase.LOWER.convert('sTr InG') 'str ing' >>> CharCase.UPPER.conv...
[ "def", "convert", "(", "self", ",", "string", ")", ":", "if", "self", "==", "self", ".", "__class__", ".", "TITLE", ":", "return", "capitalize", "(", "string", ")", "if", "self", "==", "self", ".", "__class__", ".", "UPPER", ":", "return", "string", ...
Return a copy of string converted to case. Parameters ---------- string : `str` Returns ------- `str` Examples -------- >>> CharCase.LOWER.convert('sTr InG') 'str ing' >>> CharCase.UPPER.convert('sTr InG') 'STR ING' ...
[ "Return", "a", "copy", "of", "string", "converted", "to", "case", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/util.py#L27-L55
49,528
NICTA/revrand
revrand/utils/rand.py
endless_permutations
def endless_permutations(N, random_state=None): """ Generate an endless sequence of random integers from permutations of the set [0, ..., N). If we call this N times, we will sweep through the entire set without replacement, on the (N+1)th call a new permutation will be created, etc. Parameter...
python
def endless_permutations(N, random_state=None): """ Generate an endless sequence of random integers from permutations of the set [0, ..., N). If we call this N times, we will sweep through the entire set without replacement, on the (N+1)th call a new permutation will be created, etc. Parameter...
[ "def", "endless_permutations", "(", "N", ",", "random_state", "=", "None", ")", ":", "generator", "=", "check_random_state", "(", "random_state", ")", "while", "True", ":", "batch_inds", "=", "generator", ".", "permutation", "(", "N", ")", "for", "b", "in", ...
Generate an endless sequence of random integers from permutations of the set [0, ..., N). If we call this N times, we will sweep through the entire set without replacement, on the (N+1)th call a new permutation will be created, etc. Parameters ---------- N: int the length of the set ...
[ "Generate", "an", "endless", "sequence", "of", "random", "integers", "from", "permutations", "of", "the", "set", "[", "0", "...", "N", ")", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/rand.py#L7-L31
49,529
codeinn/vcs
vcs/backends/__init__.py
get_repo
def get_repo(path=None, alias=None, create=False): """ Returns ``Repository`` object of type linked with given ``alias`` at the specified ``path``. If ``alias`` is not given it will try to guess it using get_scm method """ if create: if not (path or alias): raise TypeError("I...
python
def get_repo(path=None, alias=None, create=False): """ Returns ``Repository`` object of type linked with given ``alias`` at the specified ``path``. If ``alias`` is not given it will try to guess it using get_scm method """ if create: if not (path or alias): raise TypeError("I...
[ "def", "get_repo", "(", "path", "=", "None", ",", "alias", "=", "None", ",", "create", "=", "False", ")", ":", "if", "create", ":", "if", "not", "(", "path", "or", "alias", ")", ":", "raise", "TypeError", "(", "\"If create is specified, we need path and sc...
Returns ``Repository`` object of type linked with given ``alias`` at the specified ``path``. If ``alias`` is not given it will try to guess it using get_scm method
[ "Returns", "Repository", "object", "of", "type", "linked", "with", "given", "alias", "at", "the", "specified", "path", ".", "If", "alias", "is", "not", "given", "it", "will", "try", "to", "guess", "it", "using", "get_scm", "method" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/__init__.py#L11-L34
49,530
codeinn/vcs
vcs/backends/__init__.py
get_backend
def get_backend(alias): """ Returns ``Repository`` class identified by the given alias or raises VCSError if alias is not recognized or backend class cannot be imported. """ if alias not in settings.BACKENDS: raise VCSError("Given alias '%s' is not recognized! Allowed aliases:\n" ...
python
def get_backend(alias): """ Returns ``Repository`` class identified by the given alias or raises VCSError if alias is not recognized or backend class cannot be imported. """ if alias not in settings.BACKENDS: raise VCSError("Given alias '%s' is not recognized! Allowed aliases:\n" ...
[ "def", "get_backend", "(", "alias", ")", ":", "if", "alias", "not", "in", "settings", ".", "BACKENDS", ":", "raise", "VCSError", "(", "\"Given alias '%s' is not recognized! Allowed aliases:\\n\"", "\"%s\"", "%", "(", "alias", ",", "pformat", "(", "settings", ".", ...
Returns ``Repository`` class identified by the given alias or raises VCSError if alias is not recognized or backend class cannot be imported.
[ "Returns", "Repository", "class", "identified", "by", "the", "given", "alias", "or", "raises", "VCSError", "if", "alias", "is", "not", "recognized", "or", "backend", "class", "cannot", "be", "imported", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/__init__.py#L37-L47
49,531
codeinn/vcs
vcs/utils/helpers.py
get_scms_for_path
def get_scms_for_path(path): """ Returns all scm's found at the given path. If no scm is recognized - empty list is returned. :param path: path to directory which should be checked. May be callable. :raises VCSError: if given ``path`` is not a directory """ from vcs.backends import get_bac...
python
def get_scms_for_path(path): """ Returns all scm's found at the given path. If no scm is recognized - empty list is returned. :param path: path to directory which should be checked. May be callable. :raises VCSError: if given ``path`` is not a directory """ from vcs.backends import get_bac...
[ "def", "get_scms_for_path", "(", "path", ")", ":", "from", "vcs", ".", "backends", "import", "get_backend", "if", "hasattr", "(", "path", ",", "'__call__'", ")", ":", "path", "=", "path", "(", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "...
Returns all scm's found at the given path. If no scm is recognized - empty list is returned. :param path: path to directory which should be checked. May be callable. :raises VCSError: if given ``path`` is not a directory
[ "Returns", "all", "scm", "s", "found", "at", "the", "given", "path", ".", "If", "no", "scm", "is", "recognized", "-", "empty", "list", "is", "returned", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/helpers.py#L61-L94
49,532
codeinn/vcs
vcs/utils/helpers.py
get_repo_paths
def get_repo_paths(path): """ Returns path's subdirectories which seems to be a repository. """ repo_paths = [] dirnames = (os.path.abspath(dirname) for dirname in os.listdir(path)) for dirname in dirnames: try: get_scm(dirname) repo_paths.append(dirname) ...
python
def get_repo_paths(path): """ Returns path's subdirectories which seems to be a repository. """ repo_paths = [] dirnames = (os.path.abspath(dirname) for dirname in os.listdir(path)) for dirname in dirnames: try: get_scm(dirname) repo_paths.append(dirname) ...
[ "def", "get_repo_paths", "(", "path", ")", ":", "repo_paths", "=", "[", "]", "dirnames", "=", "(", "os", ".", "path", ".", "abspath", "(", "dirname", ")", "for", "dirname", "in", "os", ".", "listdir", "(", "path", ")", ")", "for", "dirname", "in", ...
Returns path's subdirectories which seems to be a repository.
[ "Returns", "path", "s", "subdirectories", "which", "seems", "to", "be", "a", "repository", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/helpers.py#L97-L109
49,533
codeinn/vcs
vcs/utils/helpers.py
run_command
def run_command(cmd, *args): """ Runs command on the system with given ``args``. """ command = ' '.join((cmd, args)) p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate() return p.retcode, stdout, stderr
python
def run_command(cmd, *args): """ Runs command on the system with given ``args``. """ command = ' '.join((cmd, args)) p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate() return p.retcode, stdout, stderr
[ "def", "run_command", "(", "cmd", ",", "*", "args", ")", ":", "command", "=", "' '", ".", "join", "(", "(", "cmd", ",", "args", ")", ")", "p", "=", "Popen", "(", "command", ",", "shell", "=", "True", ",", "stdout", "=", "PIPE", ",", "stderr", "...
Runs command on the system with given ``args``.
[ "Runs", "command", "on", "the", "system", "with", "given", "args", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/helpers.py#L112-L119
49,534
codeinn/vcs
vcs/utils/helpers.py
get_highlighted_code
def get_highlighted_code(name, code, type='terminal'): """ If pygments are available on the system then returned output is colored. Otherwise unchanged content is returned. """ import logging try: import pygments pygments except ImportError: return code from p...
python
def get_highlighted_code(name, code, type='terminal'): """ If pygments are available on the system then returned output is colored. Otherwise unchanged content is returned. """ import logging try: import pygments pygments except ImportError: return code from p...
[ "def", "get_highlighted_code", "(", "name", ",", "code", ",", "type", "=", "'terminal'", ")", ":", "import", "logging", "try", ":", "import", "pygments", "pygments", "except", "ImportError", ":", "return", "code", "from", "pygments", "import", "highlight", "fr...
If pygments are available on the system then returned output is colored. Otherwise unchanged content is returned.
[ "If", "pygments", "are", "available", "on", "the", "system", "then", "returned", "output", "is", "colored", ".", "Otherwise", "unchanged", "content", "is", "returned", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/helpers.py#L122-L145
49,535
codeinn/vcs
vcs/utils/helpers.py
parse_datetime
def parse_datetime(text): """ Parses given text and returns ``datetime.datetime`` instance or raises ``ValueError``. :param text: string of desired date/datetime or something more verbose, like *yesterday*, *2weeks 3days*, etc. """ text = text.strip().lower() INPUT_FORMATS = ( ...
python
def parse_datetime(text): """ Parses given text and returns ``datetime.datetime`` instance or raises ``ValueError``. :param text: string of desired date/datetime or something more verbose, like *yesterday*, *2weeks 3days*, etc. """ text = text.strip().lower() INPUT_FORMATS = ( ...
[ "def", "parse_datetime", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", ".", "lower", "(", ")", "INPUT_FORMATS", "=", "(", "'%Y-%m-%d %H:%M:%S'", ",", "'%Y-%m-%d %H:%M'", ",", "'%Y-%m-%d'", ",", "'%m/%d/%Y %H:%M:%S'", ",", "'%m/%d/%Y %H:%M...
Parses given text and returns ``datetime.datetime`` instance or raises ``ValueError``. :param text: string of desired date/datetime or something more verbose, like *yesterday*, *2weeks 3days*, etc.
[ "Parses", "given", "text", "and", "returns", "datetime", ".", "datetime", "instance", "or", "raises", "ValueError", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/helpers.py#L180-L233
49,536
codeinn/vcs
vcs/utils/helpers.py
get_dict_for_attrs
def get_dict_for_attrs(obj, attrs): """ Returns dictionary for each attribute from given ``obj``. """ data = {} for attr in attrs: data[attr] = getattr(obj, attr) return data
python
def get_dict_for_attrs(obj, attrs): """ Returns dictionary for each attribute from given ``obj``. """ data = {} for attr in attrs: data[attr] = getattr(obj, attr) return data
[ "def", "get_dict_for_attrs", "(", "obj", ",", "attrs", ")", ":", "data", "=", "{", "}", "for", "attr", "in", "attrs", ":", "data", "[", "attr", "]", "=", "getattr", "(", "obj", ",", "attr", ")", "return", "data" ]
Returns dictionary for each attribute from given ``obj``.
[ "Returns", "dictionary", "for", "each", "attribute", "from", "given", "obj", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/helpers.py#L236-L243
49,537
NICTA/revrand
revrand/likelihoods.py
Bernoulli.loglike
def loglike(self, y, f): r""" Bernoulli log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) ...
python
def loglike(self, y, f): r""" Bernoulli log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) ...
[ "def", "loglike", "(", "self", ",", "y", ",", "f", ")", ":", "# way faster than calling bernoulli.logpmf", "y", ",", "f", "=", "np", ".", "broadcast_arrays", "(", "y", ",", "f", ")", "ll", "=", "y", "*", "f", "-", "softplus", "(", "f", ")", "return",...
r""" Bernoulli log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns ------- l...
[ "r", "Bernoulli", "log", "likelihood", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L46-L67
49,538
NICTA/revrand
revrand/likelihoods.py
Binomial.loglike
def loglike(self, y, f, n): r""" Binomial log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) ...
python
def loglike(self, y, f, n): r""" Binomial log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) ...
[ "def", "loglike", "(", "self", ",", "y", ",", "f", ",", "n", ")", ":", "ll", "=", "binom", ".", "logpmf", "(", "y", ",", "n", "=", "n", ",", "p", "=", "expit", "(", "f", ")", ")", "return", "ll" ]
r""" Binomial log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) n: ndarray the total nu...
[ "r", "Binomial", "log", "likelihood", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L171-L192
49,539
NICTA/revrand
revrand/likelihoods.py
Binomial.df
def df(self, y, f, n): r""" Derivative of Binomial log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi ...
python
def df(self, y, f, n): r""" Derivative of Binomial log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi ...
[ "def", "df", "(", "self", ",", "y", ",", "f", ",", "n", ")", ":", "y", ",", "f", ",", "n", "=", "np", ".", "broadcast_arrays", "(", "y", ",", "f", ",", "n", ")", "return", "y", "-", "expit", "(", "f", ")", "*", "n" ]
r""" Derivative of Binomial log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) n: ndarray...
[ "r", "Derivative", "of", "Binomial", "log", "likelihood", "w", ".", "r", ".", "t", ".", "\\", "f", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L213-L233
49,540
NICTA/revrand
revrand/likelihoods.py
Gaussian.loglike
def loglike(self, y, f, var=None): r""" Gaussian log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) ...
python
def loglike(self, y, f, var=None): r""" Gaussian log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) ...
[ "def", "loglike", "(", "self", ",", "y", ",", "f", ",", "var", "=", "None", ")", ":", "# way faster than calling norm.logpdf", "var", "=", "self", ".", "_check_param", "(", "var", ")", "y", ",", "f", "=", "np", ".", "broadcast_arrays", "(", "y", ",", ...
r""" Gaussian log likelihood. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) var: float, ndarray, optional ...
[ "r", "Gaussian", "log", "likelihood", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L298-L323
49,541
NICTA/revrand
revrand/likelihoods.py
Gaussian.df
def df(self, y, f, var): r""" Derivative of Gaussian log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Ph...
python
def df(self, y, f, var): r""" Derivative of Gaussian log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Ph...
[ "def", "df", "(", "self", ",", "y", ",", "f", ",", "var", ")", ":", "var", "=", "self", ".", "_check_param", "(", "var", ")", "y", ",", "f", "=", "np", ".", "broadcast_arrays", "(", "y", ",", "f", ")", "return", "(", "y", "-", "f", ")", "/"...
r""" Derivative of Gaussian log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) var: float...
[ "r", "Derivative", "of", "Gaussian", "log", "likelihood", "w", ".", "r", ".", "t", ".", "\\", "f", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L346-L368
49,542
NICTA/revrand
revrand/likelihoods.py
Poisson.loglike
def loglike(self, y, f): r""" Poisson log likelihood. Parameters ---------- y: ndarray array of integer targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns --...
python
def loglike(self, y, f): r""" Poisson log likelihood. Parameters ---------- y: ndarray array of integer targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns --...
[ "def", "loglike", "(", "self", ",", "y", ",", "f", ")", ":", "y", ",", "f", "=", "np", ".", "broadcast_arrays", "(", "y", ",", "f", ")", "if", "self", ".", "tranfcn", "==", "'exp'", ":", "g", "=", "np", ".", "exp", "(", "f", ")", "logg", "=...
r""" Poisson log likelihood. Parameters ---------- y: ndarray array of integer targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns ------- logp: ndarray ...
[ "r", "Poisson", "log", "likelihood", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L456-L481
49,543
NICTA/revrand
revrand/likelihoods.py
Poisson.Ey
def Ey(self, f): r""" Expected value of the Poisson likelihood. Parameters ---------- f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns ------- Ey: ndarray expected...
python
def Ey(self, f): r""" Expected value of the Poisson likelihood. Parameters ---------- f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns ------- Ey: ndarray expected...
[ "def", "Ey", "(", "self", ",", "f", ")", ":", "return", "np", ".", "exp", "(", "f", ")", "if", "self", ".", "tranfcn", "==", "'exp'", "else", "softplus", "(", "f", ")" ]
r""" Expected value of the Poisson likelihood. Parameters ---------- f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns ------- Ey: ndarray expected value of y, :math:`\math...
[ "r", "Expected", "value", "of", "the", "Poisson", "likelihood", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L483-L498
49,544
NICTA/revrand
revrand/likelihoods.py
Poisson.df
def df(self, y, f): r""" Derivative of Poisson log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mat...
python
def df(self, y, f): r""" Derivative of Poisson log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mat...
[ "def", "df", "(", "self", ",", "y", ",", "f", ")", ":", "y", ",", "f", "=", "np", ".", "broadcast_arrays", "(", "y", ",", "f", ")", "if", "self", ".", "tranfcn", "==", "'exp'", ":", "return", "y", "-", "np", ".", "exp", "(", "f", ")", "else...
r""" Derivative of Poisson log likelihood w.r.t.\ f. Parameters ---------- y: ndarray array of 0, 1 valued integers of targets f: ndarray latent function from the GLM prior (:math:`\mathbf{f} = \boldsymbol\Phi \mathbf{w}`) Returns ...
[ "r", "Derivative", "of", "Poisson", "log", "likelihood", "w", ".", "r", ".", "t", ".", "\\", "f", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/likelihoods.py#L500-L521
49,545
dead-beef/markovchain
markovchain/parser.py
Parser.reset
def reset(self, state_size_changed=False): """Reset parser state. Parameters ---------- state_size_changed : `bool`, optional `True` if maximum state size changed (default: `False`). """ if state_size_changed: self.state = deque(repeat('', self.st...
python
def reset(self, state_size_changed=False): """Reset parser state. Parameters ---------- state_size_changed : `bool`, optional `True` if maximum state size changed (default: `False`). """ if state_size_changed: self.state = deque(repeat('', self.st...
[ "def", "reset", "(", "self", ",", "state_size_changed", "=", "False", ")", ":", "if", "state_size_changed", ":", "self", ".", "state", "=", "deque", "(", "repeat", "(", "''", ",", "self", ".", "state_size", ")", ",", "maxlen", "=", "self", ".", "state_...
Reset parser state. Parameters ---------- state_size_changed : `bool`, optional `True` if maximum state size changed (default: `False`).
[ "Reset", "parser", "state", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/parser.py#L127-L140
49,546
dead-beef/markovchain
markovchain/image/util.py
convert
def convert(ctype, img, palette_img, dither=False): """Convert an image to palette type. Parameters ---------- ctype : `int` Conversion type. img : `PIL.Image` Image to convert. palette_img : `PIL.Image` Palette source image. dither : `bool`, optional Enable ...
python
def convert(ctype, img, palette_img, dither=False): """Convert an image to palette type. Parameters ---------- ctype : `int` Conversion type. img : `PIL.Image` Image to convert. palette_img : `PIL.Image` Palette source image. dither : `bool`, optional Enable ...
[ "def", "convert", "(", "ctype", ",", "img", ",", "palette_img", ",", "dither", "=", "False", ")", ":", "if", "ctype", "==", "0", ":", "img2", "=", "img", ".", "convert", "(", "mode", "=", "'P'", ")", "img2", ".", "putpalette", "(", "palette_img", "...
Convert an image to palette type. Parameters ---------- ctype : `int` Conversion type. img : `PIL.Image` Image to convert. palette_img : `PIL.Image` Palette source image. dither : `bool`, optional Enable dithering (default: `False`). Raises ------ Va...
[ "Convert", "an", "image", "to", "palette", "type", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/image/util.py#L84-L118
49,547
codeinn/vcs
vcs/backends/git/config.py
_unescape_value
def _unescape_value(value): """Unescape a value.""" def unescape(c): return { "\\\\": "\\", "\\\"": "\"", "\\n": "\n", "\\t": "\t", "\\b": "\b", }[c.group(0)] return re.sub(r"(\\.)", unescape, value)
python
def _unescape_value(value): """Unescape a value.""" def unescape(c): return { "\\\\": "\\", "\\\"": "\"", "\\n": "\n", "\\t": "\t", "\\b": "\b", }[c.group(0)] return re.sub(r"(\\.)", unescape, value)
[ "def", "_unescape_value", "(", "value", ")", ":", "def", "unescape", "(", "c", ")", ":", "return", "{", "\"\\\\\\\\\"", ":", "\"\\\\\"", ",", "\"\\\\\\\"\"", ":", "\"\\\"\"", ",", "\"\\\\n\"", ":", "\"\\n\"", ",", "\"\\\\t\"", ":", "\"\\t\"", ",", "\"\\\\b...
Unescape a value.
[ "Unescape", "a", "value", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L153-L163
49,548
codeinn/vcs
vcs/backends/git/config.py
Config.get_boolean
def get_boolean(self, section, name, default=None): """Retrieve a configuration setting as boolean. :param section: Tuple with section name and optional subsection namee :param name: Name of the setting, including section and possible subsection. :return: Contents of the set...
python
def get_boolean(self, section, name, default=None): """Retrieve a configuration setting as boolean. :param section: Tuple with section name and optional subsection namee :param name: Name of the setting, including section and possible subsection. :return: Contents of the set...
[ "def", "get_boolean", "(", "self", ",", "section", ",", "name", ",", "default", "=", "None", ")", ":", "try", ":", "value", "=", "self", ".", "get", "(", "section", ",", "name", ")", "except", "KeyError", ":", "return", "default", "if", "value", ".",...
Retrieve a configuration setting as boolean. :param section: Tuple with section name and optional subsection namee :param name: Name of the setting, including section and possible subsection. :return: Contents of the setting :raise KeyError: if the value is not set
[ "Retrieve", "a", "configuration", "setting", "as", "boolean", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L50-L67
49,549
codeinn/vcs
vcs/backends/git/config.py
ConfigFile.from_file
def from_file(cls, f): """Read configuration from a file-like object.""" ret = cls() section = None setting = None for lineno, line in enumerate(f.readlines()): line = line.lstrip() if setting is None: if _strip_comments(line).strip() == ""...
python
def from_file(cls, f): """Read configuration from a file-like object.""" ret = cls() section = None setting = None for lineno, line in enumerate(f.readlines()): line = line.lstrip() if setting is None: if _strip_comments(line).strip() == ""...
[ "def", "from_file", "(", "cls", ",", "f", ")", ":", "ret", "=", "cls", "(", ")", "section", "=", "None", "setting", "=", "None", "for", "lineno", ",", "line", "in", "enumerate", "(", "f", ".", "readlines", "(", ")", ")", ":", "line", "=", "line",...
Read configuration from a file-like object.
[ "Read", "configuration", "from", "a", "file", "-", "like", "object", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L197-L264
49,550
codeinn/vcs
vcs/backends/git/config.py
ConfigFile.from_path
def from_path(cls, path): """Read configuration from a file on disk.""" f = GitFile(path, 'rb') try: ret = cls.from_file(f) ret.path = path return ret finally: f.close()
python
def from_path(cls, path): """Read configuration from a file on disk.""" f = GitFile(path, 'rb') try: ret = cls.from_file(f) ret.path = path return ret finally: f.close()
[ "def", "from_path", "(", "cls", ",", "path", ")", ":", "f", "=", "GitFile", "(", "path", ",", "'rb'", ")", "try", ":", "ret", "=", "cls", ".", "from_file", "(", "f", ")", "ret", ".", "path", "=", "path", "return", "ret", "finally", ":", "f", "....
Read configuration from a file on disk.
[ "Read", "configuration", "from", "a", "file", "on", "disk", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L267-L275
49,551
codeinn/vcs
vcs/backends/git/config.py
ConfigFile.write_to_path
def write_to_path(self, path=None): """Write configuration to a file on disk.""" if path is None: path = self.path f = GitFile(path, 'wb') try: self.write_to_file(f) finally: f.close()
python
def write_to_path(self, path=None): """Write configuration to a file on disk.""" if path is None: path = self.path f = GitFile(path, 'wb') try: self.write_to_file(f) finally: f.close()
[ "def", "write_to_path", "(", "self", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "self", ".", "path", "f", "=", "GitFile", "(", "path", ",", "'wb'", ")", "try", ":", "self", ".", "write_to_file", "(", "f", ")...
Write configuration to a file on disk.
[ "Write", "configuration", "to", "a", "file", "on", "disk", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L277-L285
49,552
codeinn/vcs
vcs/backends/git/config.py
ConfigFile.write_to_file
def write_to_file(self, f): """Write configuration to a file-like object.""" for section, values in self._values.iteritems(): try: section_name, subsection_name = section except ValueError: (section_name, ) = section subsection_name...
python
def write_to_file(self, f): """Write configuration to a file-like object.""" for section, values in self._values.iteritems(): try: section_name, subsection_name = section except ValueError: (section_name, ) = section subsection_name...
[ "def", "write_to_file", "(", "self", ",", "f", ")", ":", "for", "section", ",", "values", "in", "self", ".", "_values", ".", "iteritems", "(", ")", ":", "try", ":", "section_name", ",", "subsection_name", "=", "section", "except", "ValueError", ":", "(",...
Write configuration to a file-like object.
[ "Write", "configuration", "to", "a", "file", "-", "like", "object", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L287-L300
49,553
codeinn/vcs
vcs/backends/git/config.py
StackedConfig.default_backends
def default_backends(cls): """Retrieve the default configuration. This will look in the repository configuration (if for_path is specified), the users' home directory and the system configuration. """ paths = [] paths.append(os.path.expanduser("~/.gitconfig")) ...
python
def default_backends(cls): """Retrieve the default configuration. This will look in the repository configuration (if for_path is specified), the users' home directory and the system configuration. """ paths = [] paths.append(os.path.expanduser("~/.gitconfig")) ...
[ "def", "default_backends", "(", "cls", ")", ":", "paths", "=", "[", "]", "paths", ".", "append", "(", "os", ".", "path", ".", "expanduser", "(", "\"~/.gitconfig\"", ")", ")", "paths", ".", "append", "(", "\"/etc/gitconfig\"", ")", "backends", "=", "[", ...
Retrieve the default configuration. This will look in the repository configuration (if for_path is specified), the users' home directory and the system configuration.
[ "Retrieve", "the", "default", "configuration", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/config.py#L314-L334
49,554
NICTA/revrand
revrand/utils/datasets.py
make_regression
def make_regression(func, n_samples=100, n_features=1, bias=0.0, noise=0.0, random_state=None): """ Make dataset for a regression problem. Examples -------- >>> f = lambda x: 0.5*x + np.sin(2*x) >>> X, y = make_regression(f, bias=.5, noise=1., random_state=1) >>> X.shape...
python
def make_regression(func, n_samples=100, n_features=1, bias=0.0, noise=0.0, random_state=None): """ Make dataset for a regression problem. Examples -------- >>> f = lambda x: 0.5*x + np.sin(2*x) >>> X, y = make_regression(f, bias=.5, noise=1., random_state=1) >>> X.shape...
[ "def", "make_regression", "(", "func", ",", "n_samples", "=", "100", ",", "n_features", "=", "1", ",", "bias", "=", "0.0", ",", "noise", "=", "0.0", ",", "random_state", "=", "None", ")", ":", "generator", "=", "check_random_state", "(", "random_state", ...
Make dataset for a regression problem. Examples -------- >>> f = lambda x: 0.5*x + np.sin(2*x) >>> X, y = make_regression(f, bias=.5, noise=1., random_state=1) >>> X.shape (100, 1) >>> y.shape (100,) >>> X[:5].round(2) array([[ 1.62], [-0.61], [-0.53], ...
[ "Make", "dataset", "for", "a", "regression", "problem", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/datasets.py#L23-L54
49,555
NICTA/revrand
revrand/utils/datasets.py
make_polynomial
def make_polynomial(degree=3, n_samples=100, bias=0.0, noise=0.0, return_coefs=False, random_state=None): """ Generate a noisy polynomial for a regression problem Examples -------- >>> X, y, coefs = make_polynomial(degree=3, n_samples=200, noise=.5, ... ...
python
def make_polynomial(degree=3, n_samples=100, bias=0.0, noise=0.0, return_coefs=False, random_state=None): """ Generate a noisy polynomial for a regression problem Examples -------- >>> X, y, coefs = make_polynomial(degree=3, n_samples=200, noise=.5, ... ...
[ "def", "make_polynomial", "(", "degree", "=", "3", ",", "n_samples", "=", "100", ",", "bias", "=", "0.0", ",", "noise", "=", "0.0", ",", "return_coefs", "=", "False", ",", "random_state", "=", "None", ")", ":", "generator", "=", "check_random_state", "("...
Generate a noisy polynomial for a regression problem Examples -------- >>> X, y, coefs = make_polynomial(degree=3, n_samples=200, noise=.5, ... return_coefs=True, random_state=1)
[ "Generate", "a", "noisy", "polynomial", "for", "a", "regression", "problem" ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/datasets.py#L57-L78
49,556
NICTA/revrand
revrand/utils/datasets.py
get_data_home
def get_data_home(data_home=None): """ Return the path of the revrand data dir. This folder is used by some large dataset loaders to avoid downloading the data several times. By default the data dir is set to a folder named 'revrand_data' in the user home folder. Alternatively, it can be ...
python
def get_data_home(data_home=None): """ Return the path of the revrand data dir. This folder is used by some large dataset loaders to avoid downloading the data several times. By default the data dir is set to a folder named 'revrand_data' in the user home folder. Alternatively, it can be ...
[ "def", "get_data_home", "(", "data_home", "=", "None", ")", ":", "data_home_default", "=", "Path", "(", "__file__", ")", ".", "ancestor", "(", "3", ")", ".", "child", "(", "'demos'", ",", "'_revrand_data'", ")", "if", "data_home", "is", "None", ":", "dat...
Return the path of the revrand data dir. This folder is used by some large dataset loaders to avoid downloading the data several times. By default the data dir is set to a folder named 'revrand_data' in the user home folder. Alternatively, it can be set by the 'REVRAND_DATA' environment varia...
[ "Return", "the", "path", "of", "the", "revrand", "data", "dir", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/datasets.py#L81-L106
49,557
NICTA/revrand
revrand/utils/datasets.py
fetch_gpml_sarcos_data
def fetch_gpml_sarcos_data(transpose_data=True, data_home=None): """ Fetch the SARCOS dataset from the internet and parse appropriately into python arrays >>> gpml_sarcos = fetch_gpml_sarcos_data() >>> gpml_sarcos.train.data.shape (44484, 21) >>> gpml_sarcos.train.targets.shape (44484...
python
def fetch_gpml_sarcos_data(transpose_data=True, data_home=None): """ Fetch the SARCOS dataset from the internet and parse appropriately into python arrays >>> gpml_sarcos = fetch_gpml_sarcos_data() >>> gpml_sarcos.train.data.shape (44484, 21) >>> gpml_sarcos.train.targets.shape (44484...
[ "def", "fetch_gpml_sarcos_data", "(", "transpose_data", "=", "True", ",", "data_home", "=", "None", ")", ":", "train_src_url", "=", "\"http://www.gaussianprocess.org/gpml/data/sarcos_inv.mat\"", "test_src_url", "=", "(", "\"http://www.gaussianprocess.org/gpml/data/sarcos_inv_test...
Fetch the SARCOS dataset from the internet and parse appropriately into python arrays >>> gpml_sarcos = fetch_gpml_sarcos_data() >>> gpml_sarcos.train.data.shape (44484, 21) >>> gpml_sarcos.train.targets.shape (44484,) >>> gpml_sarcos.train.targets.round(2) # doctest: +ELLIPSIS array...
[ "Fetch", "the", "SARCOS", "dataset", "from", "the", "internet", "and", "parse", "appropriately", "into", "python", "arrays" ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/datasets.py#L109-L155
49,558
NICTA/revrand
revrand/utils/datasets.py
fetch_gpml_usps_resampled_data
def fetch_gpml_usps_resampled_data(transpose_data=True, data_home=None): """ Fetch the USPS handwritten digits dataset from the internet and parse appropriately into python arrays >>> usps_resampled = fetch_gpml_usps_resampled_data() >>> usps_resampled.train.targets.shape (4649,) >>> usps...
python
def fetch_gpml_usps_resampled_data(transpose_data=True, data_home=None): """ Fetch the USPS handwritten digits dataset from the internet and parse appropriately into python arrays >>> usps_resampled = fetch_gpml_usps_resampled_data() >>> usps_resampled.train.targets.shape (4649,) >>> usps...
[ "def", "fetch_gpml_usps_resampled_data", "(", "transpose_data", "=", "True", ",", "data_home", "=", "None", ")", ":", "data_home", "=", "get_data_home", "(", "data_home", "=", "data_home", ")", "data_filename", "=", "os", ".", "path", ".", "join", "(", "data_h...
Fetch the USPS handwritten digits dataset from the internet and parse appropriately into python arrays >>> usps_resampled = fetch_gpml_usps_resampled_data() >>> usps_resampled.train.targets.shape (4649,) >>> usps_resampled.train.targets # doctest: +ELLIPSIS array([6, 0, 1, ..., 9, 2, 7]) ...
[ "Fetch", "the", "USPS", "handwritten", "digits", "dataset", "from", "the", "internet", "and", "parse", "appropriately", "into", "python", "arrays" ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/datasets.py#L158-L224
49,559
dead-beef/markovchain
markovchain/storage/base.py
Storage.split_state
def split_state(self, state): """Split state string. Parameters ---------- state : `str` Returns ------- `list` of `str` """ if self.state_separator: return state.split(self.state_separator) return list(state)
python
def split_state(self, state): """Split state string. Parameters ---------- state : `str` Returns ------- `list` of `str` """ if self.state_separator: return state.split(self.state_separator) return list(state)
[ "def", "split_state", "(", "self", ",", "state", ")", ":", "if", "self", ".", "state_separator", ":", "return", "state", ".", "split", "(", "self", ".", "state_separator", ")", "return", "list", "(", "state", ")" ]
Split state string. Parameters ---------- state : `str` Returns ------- `list` of `str`
[ "Split", "state", "string", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/base.py#L44-L57
49,560
dead-beef/markovchain
markovchain/storage/base.py
Storage.random_link
def random_link(self, dataset, state, backward=False): """Get a random link. Parameters ---------- dataset : `object` Dataset from `self.get_dataset()`. state : `object` Link source. backward : `bool`, optional Link direction. ...
python
def random_link(self, dataset, state, backward=False): """Get a random link. Parameters ---------- dataset : `object` Dataset from `self.get_dataset()`. state : `object` Link source. backward : `bool`, optional Link direction. ...
[ "def", "random_link", "(", "self", ",", "dataset", ",", "state", ",", "backward", "=", "False", ")", ":", "links", "=", "self", ".", "get_links", "(", "dataset", ",", "state", ",", "backward", ")", "if", "not", "links", ":", "return", "None", ",", "N...
Get a random link. Parameters ---------- dataset : `object` Dataset from `self.get_dataset()`. state : `object` Link source. backward : `bool`, optional Link direction. Raises ------ ValueError If link coun...
[ "Get", "a", "random", "link", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/base.py#L72-L103
49,561
dead-beef/markovchain
markovchain/storage/base.py
Storage.save
def save(self, fp=None): """Update settings JSON data and save to file. Parameters ---------- fp : `file` or `str`, optional Output file. """ self.settings['storage'] = { 'state_separator': self.state_separator } self.do_save(fp)
python
def save(self, fp=None): """Update settings JSON data and save to file. Parameters ---------- fp : `file` or `str`, optional Output file. """ self.settings['storage'] = { 'state_separator': self.state_separator } self.do_save(fp)
[ "def", "save", "(", "self", ",", "fp", "=", "None", ")", ":", "self", ".", "settings", "[", "'storage'", "]", "=", "{", "'state_separator'", ":", "self", ".", "state_separator", "}", "self", ".", "do_save", "(", "fp", ")" ]
Update settings JSON data and save to file. Parameters ---------- fp : `file` or `str`, optional Output file.
[ "Update", "settings", "JSON", "data", "and", "save", "to", "file", "." ]
9bd10b2f01089341c4a875a0fa569d50caba22c7
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/base.py#L134-L145
49,562
codeinn/vcs
vcs/utils/termcolors.py
parse_color_setting
def parse_color_setting(config_string): """Parse a DJANGO_COLORS environment variable to produce the system palette The general form of a pallete definition is: "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option" where: palette is a named palette; one of 'light', '...
python
def parse_color_setting(config_string): """Parse a DJANGO_COLORS environment variable to produce the system palette The general form of a pallete definition is: "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option" where: palette is a named palette; one of 'light', '...
[ "def", "parse_color_setting", "(", "config_string", ")", ":", "if", "not", "config_string", ":", "return", "PALETTES", "[", "DEFAULT_PALETTE", "]", "# Split the color configuration into parts", "parts", "=", "config_string", ".", "lower", "(", ")", ".", "split", "("...
Parse a DJANGO_COLORS environment variable to produce the system palette The general form of a pallete definition is: "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option" where: palette is a named palette; one of 'light', 'dark', or 'nocolor'. role is a named st...
[ "Parse", "a", "DJANGO_COLORS", "environment", "variable", "to", "produce", "the", "system", "palette" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/termcolors.py#L123-L200
49,563
NICTA/revrand
revrand/utils/base.py
couple
def couple(f, g): r""" Compose a function thate returns two arguments. Given a pair of functions that take the same arguments, return a single function that returns a pair consisting of the return values of each function. Notes ----- Equivalent to:: lambda f, g: lambda *args, ...
python
def couple(f, g): r""" Compose a function thate returns two arguments. Given a pair of functions that take the same arguments, return a single function that returns a pair consisting of the return values of each function. Notes ----- Equivalent to:: lambda f, g: lambda *args, ...
[ "def", "couple", "(", "f", ",", "g", ")", ":", "def", "coupled", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "g", "(", "*", "args", ",", "*", "*", "kwargs", ")", ...
r""" Compose a function thate returns two arguments. Given a pair of functions that take the same arguments, return a single function that returns a pair consisting of the return values of each function. Notes ----- Equivalent to:: lambda f, g: lambda *args, **kwargs: (f(*args, **...
[ "r", "Compose", "a", "function", "thate", "returns", "two", "arguments", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L122-L148
49,564
NICTA/revrand
revrand/utils/base.py
decouple
def decouple(fn): """ Inverse operation of couple. Create two functions of one argument and one return from a function that takes two arguments and has two returns Examples -------- >>> h = lambda x: (2*x**3, 6*x**2) >>> f, g = decouple(h) >>> f(5) 250 >>> g(5) 150 ...
python
def decouple(fn): """ Inverse operation of couple. Create two functions of one argument and one return from a function that takes two arguments and has two returns Examples -------- >>> h = lambda x: (2*x**3, 6*x**2) >>> f, g = decouple(h) >>> f(5) 250 >>> g(5) 150 ...
[ "def", "decouple", "(", "fn", ")", ":", "def", "fst", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", "[", "0", "]", "def", "snd", "(", "*", "args", ",", "*", "*", "kwargs...
Inverse operation of couple. Create two functions of one argument and one return from a function that takes two arguments and has two returns Examples -------- >>> h = lambda x: (2*x**3, 6*x**2) >>> f, g = decouple(h) >>> f(5) 250 >>> g(5) 150
[ "Inverse", "operation", "of", "couple", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L151-L175
49,565
NICTA/revrand
revrand/utils/base.py
nwise
def nwise(iterable, n): r""" Sliding window iterator. Iterator that acts like a sliding window of size `n`; slides over some iterable `n` items at a time. If iterable has `m` elements, this function will return an iterator over `m-n+1` tuples. Parameters ---------- iterable : iterable ...
python
def nwise(iterable, n): r""" Sliding window iterator. Iterator that acts like a sliding window of size `n`; slides over some iterable `n` items at a time. If iterable has `m` elements, this function will return an iterator over `m-n+1` tuples. Parameters ---------- iterable : iterable ...
[ "def", "nwise", "(", "iterable", ",", "n", ")", ":", "iters", "=", "tee", "(", "iterable", ",", "n", ")", "for", "i", ",", "it", "in", "enumerate", "(", "iters", ")", ":", "for", "_", "in", "range", "(", "i", ")", ":", "next", "(", "it", ",",...
r""" Sliding window iterator. Iterator that acts like a sliding window of size `n`; slides over some iterable `n` items at a time. If iterable has `m` elements, this function will return an iterator over `m-n+1` tuples. Parameters ---------- iterable : iterable An iterable object. ...
[ "r", "Sliding", "window", "iterator", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L178-L258
49,566
NICTA/revrand
revrand/utils/base.py
scalar_reshape
def scalar_reshape(a, newshape, order='C'): """ Reshape, but also return scalars or empty lists. Identical to `numpy.reshape` except in the case where `newshape` is the empty tuple, in which case we return a scalar instead of a 0-dimensional array. Examples -------- >>> a = np.arange(6...
python
def scalar_reshape(a, newshape, order='C'): """ Reshape, but also return scalars or empty lists. Identical to `numpy.reshape` except in the case where `newshape` is the empty tuple, in which case we return a scalar instead of a 0-dimensional array. Examples -------- >>> a = np.arange(6...
[ "def", "scalar_reshape", "(", "a", ",", "newshape", ",", "order", "=", "'C'", ")", ":", "if", "newshape", "==", "(", ")", ":", "return", "np", ".", "asscalar", "(", "a", ")", "if", "newshape", "==", "(", "0", ",", ")", ":", "return", "[", "]", ...
Reshape, but also return scalars or empty lists. Identical to `numpy.reshape` except in the case where `newshape` is the empty tuple, in which case we return a scalar instead of a 0-dimensional array. Examples -------- >>> a = np.arange(6) >>> np.array_equal(np.reshape(a, (3, 2)), scalar_r...
[ "Reshape", "but", "also", "return", "scalars", "or", "empty", "lists", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L261-L290
49,567
NICTA/revrand
revrand/utils/base.py
flatten
def flatten(arys, returns_shapes=True, hstack=np.hstack, ravel=np.ravel, shape=np.shape): """ Flatten a potentially recursive list of multidimensional objects. .. note:: Not to be confused with `np.ndarray.flatten()` (a more befitting might be `chain` or `stack` or maybe somethin...
python
def flatten(arys, returns_shapes=True, hstack=np.hstack, ravel=np.ravel, shape=np.shape): """ Flatten a potentially recursive list of multidimensional objects. .. note:: Not to be confused with `np.ndarray.flatten()` (a more befitting might be `chain` or `stack` or maybe somethin...
[ "def", "flatten", "(", "arys", ",", "returns_shapes", "=", "True", ",", "hstack", "=", "np", ".", "hstack", ",", "ravel", "=", "np", ".", "ravel", ",", "shape", "=", "np", ".", "shape", ")", ":", "if", "issequence", "(", "arys", ")", "and", "len", ...
Flatten a potentially recursive list of multidimensional objects. .. note:: Not to be confused with `np.ndarray.flatten()` (a more befitting might be `chain` or `stack` or maybe something else entirely since this function is more than either `concatenate` or `np.flatten` itself. Rather...
[ "Flatten", "a", "potentially", "recursive", "list", "of", "multidimensional", "objects", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L293-L397
49,568
NICTA/revrand
revrand/utils/base.py
unflatten
def unflatten(ary, shapes, reshape=scalar_reshape): r""" Inverse opertation of flatten. Given a flat (1d) array, and a list of shapes (represented as tuples), return a list of ndarrays with the specified shapes. Parameters ---------- ary : a 1d array A flat (1d) array. shapes ...
python
def unflatten(ary, shapes, reshape=scalar_reshape): r""" Inverse opertation of flatten. Given a flat (1d) array, and a list of shapes (represented as tuples), return a list of ndarrays with the specified shapes. Parameters ---------- ary : a 1d array A flat (1d) array. shapes ...
[ "def", "unflatten", "(", "ary", ",", "shapes", ",", "reshape", "=", "scalar_reshape", ")", ":", "if", "isinstance", "(", "shapes", ",", "list", ")", ":", "sizes", "=", "list", "(", "map", "(", "sumprod", ",", "shapes", ")", ")", "ends", "=", "np", ...
r""" Inverse opertation of flatten. Given a flat (1d) array, and a list of shapes (represented as tuples), return a list of ndarrays with the specified shapes. Parameters ---------- ary : a 1d array A flat (1d) array. shapes : list of tuples A list of ndarray shapes (tuple...
[ "r", "Inverse", "opertation", "of", "flatten", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L400-L481
49,569
NICTA/revrand
revrand/utils/base.py
sumprod
def sumprod(seq): """ Product of tuple, or sum of products of lists of tuples. Parameters ---------- seq : tuple or list Returns ------- int : the product of input tuples, or the sum of products of lists of tuples, recursively. Examples -------- >>> tup = (...
python
def sumprod(seq): """ Product of tuple, or sum of products of lists of tuples. Parameters ---------- seq : tuple or list Returns ------- int : the product of input tuples, or the sum of products of lists of tuples, recursively. Examples -------- >>> tup = (...
[ "def", "sumprod", "(", "seq", ")", ":", "if", "isinstance", "(", "seq", ",", "tuple", ")", ":", "# important to make sure dtype is int", "# since prod on empty tuple is a float (1.0)", "return", "np", ".", "prod", "(", "seq", ",", "dtype", "=", "int", ")", "else...
Product of tuple, or sum of products of lists of tuples. Parameters ---------- seq : tuple or list Returns ------- int : the product of input tuples, or the sum of products of lists of tuples, recursively. Examples -------- >>> tup = (1, 2, 3) >>> sumprod(tup) ...
[ "Product", "of", "tuple", "or", "sum", "of", "products", "of", "lists", "of", "tuples", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L484-L517
49,570
NICTA/revrand
revrand/utils/base.py
map_recursive
def map_recursive(fn, iterable, output_type=None): """ Apply a function of a potentially nested list of lists. Parameters ---------- fn : callable The function to apply to each element (and sub elements) in iterable iterable : iterable An iterable, sequence, sequence of sequence...
python
def map_recursive(fn, iterable, output_type=None): """ Apply a function of a potentially nested list of lists. Parameters ---------- fn : callable The function to apply to each element (and sub elements) in iterable iterable : iterable An iterable, sequence, sequence of sequence...
[ "def", "map_recursive", "(", "fn", ",", "iterable", ",", "output_type", "=", "None", ")", ":", "def", "applyormap", "(", "it", ")", ":", "if", "issequence", "(", "it", ")", ":", "return", "map_recursive", "(", "fn", ",", "it", ",", "output_type", ")", ...
Apply a function of a potentially nested list of lists. Parameters ---------- fn : callable The function to apply to each element (and sub elements) in iterable iterable : iterable An iterable, sequence, sequence of sequences etc. :code:`fn` will be applied to each element in ea...
[ "Apply", "a", "function", "of", "a", "potentially", "nested", "list", "of", "lists", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L520-L560
49,571
NICTA/revrand
revrand/utils/base.py
map_indices
def map_indices(fn, iterable, indices): r""" Map a function across indices of an iterable. Notes ----- Roughly equivalent to, though more efficient than:: lambda fn, iterable, *indices: (fn(arg) if i in indices else arg for i, arg in enumerate(iterab...
python
def map_indices(fn, iterable, indices): r""" Map a function across indices of an iterable. Notes ----- Roughly equivalent to, though more efficient than:: lambda fn, iterable, *indices: (fn(arg) if i in indices else arg for i, arg in enumerate(iterab...
[ "def", "map_indices", "(", "fn", ",", "iterable", ",", "indices", ")", ":", "index_set", "=", "set", "(", "indices", ")", "for", "i", ",", "arg", "in", "enumerate", "(", "iterable", ")", ":", "if", "i", "in", "index_set", ":", "yield", "fn", "(", "...
r""" Map a function across indices of an iterable. Notes ----- Roughly equivalent to, though more efficient than:: lambda fn, iterable, *indices: (fn(arg) if i in indices else arg for i, arg in enumerate(iterable)) Examples -------- >>> a =...
[ "r", "Map", "a", "function", "across", "indices", "of", "an", "iterable", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/utils/base.py#L563-L608
49,572
codeinn/vcs
vcs/utils/archivers.py
get_archiver
def get_archiver(self, kind): """ Returns instance of archiver class specific to given kind :param kind: archive kind """ archivers = { 'tar': TarArchiver, 'tbz2': Tbz2Archiver, 'tgz': TgzArchiver, 'zip': ZipArchiver, } return archivers[kind]()
python
def get_archiver(self, kind): """ Returns instance of archiver class specific to given kind :param kind: archive kind """ archivers = { 'tar': TarArchiver, 'tbz2': Tbz2Archiver, 'tgz': TgzArchiver, 'zip': ZipArchiver, } return archivers[kind]()
[ "def", "get_archiver", "(", "self", ",", "kind", ")", ":", "archivers", "=", "{", "'tar'", ":", "TarArchiver", ",", "'tbz2'", ":", "Tbz2Archiver", ",", "'tgz'", ":", "TgzArchiver", ",", "'zip'", ":", "ZipArchiver", ",", "}", "return", "archivers", "[", "...
Returns instance of archiver class specific to given kind :param kind: archive kind
[ "Returns", "instance", "of", "archiver", "class", "specific", "to", "given", "kind" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/archivers.py#L44-L58
49,573
NICTA/revrand
revrand/basis_functions.py
slice_init
def slice_init(func): """ Decorator for adding partial application functionality to a basis object. This will add an "apply_ind" argument to a basis object initialiser that can be used to apply the basis function to only the dimensions specified in apply_ind. E.g., >>> X = np.ones((100, 20)) ...
python
def slice_init(func): """ Decorator for adding partial application functionality to a basis object. This will add an "apply_ind" argument to a basis object initialiser that can be used to apply the basis function to only the dimensions specified in apply_ind. E.g., >>> X = np.ones((100, 20)) ...
[ "def", "slice_init", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "new_init", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "apply_ind", "=", "kwargs", ".", "pop", "(", "'apply_ind'", ",", "None", ")", "if", "...
Decorator for adding partial application functionality to a basis object. This will add an "apply_ind" argument to a basis object initialiser that can be used to apply the basis function to only the dimensions specified in apply_ind. E.g., >>> X = np.ones((100, 20)) >>> base = LinearBasis(onescol=...
[ "Decorator", "for", "adding", "partial", "application", "functionality", "to", "a", "basis", "object", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L70-L93
49,574
NICTA/revrand
revrand/basis_functions.py
slice_transform
def slice_transform(func, self, X, *vargs, **kwargs): """ Decorator for implementing partial application. This must decorate the ``transform`` and ``grad`` methods of basis objects if the ``slice_init`` decorator was used. """ X = X if self.apply_ind is None else X[:, self.apply_ind] return...
python
def slice_transform(func, self, X, *vargs, **kwargs): """ Decorator for implementing partial application. This must decorate the ``transform`` and ``grad`` methods of basis objects if the ``slice_init`` decorator was used. """ X = X if self.apply_ind is None else X[:, self.apply_ind] return...
[ "def", "slice_transform", "(", "func", ",", "self", ",", "X", ",", "*", "vargs", ",", "*", "*", "kwargs", ")", ":", "X", "=", "X", "if", "self", ".", "apply_ind", "is", "None", "else", "X", "[", ":", ",", "self", ".", "apply_ind", "]", "return", ...
Decorator for implementing partial application. This must decorate the ``transform`` and ``grad`` methods of basis objects if the ``slice_init`` decorator was used.
[ "Decorator", "for", "implementing", "partial", "application", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L97-L105
49,575
NICTA/revrand
revrand/basis_functions.py
apply_grad
def apply_grad(fun, grad): """ Apply a function that takes a gradient matrix to a sequence of 2 or 3 dimensional gradients. This is partucularly useful when the gradient of a basis concatenation object is quite complex, eg. >>> X = np.random.randn(100, 3) >>> y = np.random.randn(100) >...
python
def apply_grad(fun, grad): """ Apply a function that takes a gradient matrix to a sequence of 2 or 3 dimensional gradients. This is partucularly useful when the gradient of a basis concatenation object is quite complex, eg. >>> X = np.random.randn(100, 3) >>> y = np.random.randn(100) >...
[ "def", "apply_grad", "(", "fun", ",", "grad", ")", ":", "if", "issequence", "(", "grad", ")", ":", "fgrad", "=", "[", "apply_grad", "(", "fun", ",", "g", ")", "for", "g", "in", "grad", "]", "return", "fgrad", "if", "len", "(", "fgrad", ")", "!=",...
Apply a function that takes a gradient matrix to a sequence of 2 or 3 dimensional gradients. This is partucularly useful when the gradient of a basis concatenation object is quite complex, eg. >>> X = np.random.randn(100, 3) >>> y = np.random.randn(100) >>> N, d = X.shape >>> base = Random...
[ "Apply", "a", "function", "that", "takes", "a", "gradient", "matrix", "to", "a", "sequence", "of", "2", "or", "3", "dimensional", "gradients", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L109-L152
49,576
NICTA/revrand
revrand/basis_functions.py
Basis.get_dim
def get_dim(self, X): """ Get the output dimensionality of this basis. This makes a cheap call to transform with the initial parameter values to ascertain the dimensionality of the output features. Parameters ---------- X : ndarray (N, d) array of ob...
python
def get_dim(self, X): """ Get the output dimensionality of this basis. This makes a cheap call to transform with the initial parameter values to ascertain the dimensionality of the output features. Parameters ---------- X : ndarray (N, d) array of ob...
[ "def", "get_dim", "(", "self", ",", "X", ")", ":", "# Cache", "if", "not", "hasattr", "(", "self", ",", "'_D'", ")", ":", "self", ".", "_D", "=", "self", ".", "transform", "(", "X", "[", "[", "0", "]", "]", ",", "*", "self", ".", "params_values...
Get the output dimensionality of this basis. This makes a cheap call to transform with the initial parameter values to ascertain the dimensionality of the output features. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of sample...
[ "Get", "the", "output", "dimensionality", "of", "this", "basis", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L276-L297
49,577
NICTA/revrand
revrand/basis_functions.py
Basis.params_values
def params_values(self): """ Get a list of the ``Parameter`` values if they have a value. This does not include the basis regularizer. """ return [p.value for p in atleast_list(self.params) if p.has_value]
python
def params_values(self): """ Get a list of the ``Parameter`` values if they have a value. This does not include the basis regularizer. """ return [p.value for p in atleast_list(self.params) if p.has_value]
[ "def", "params_values", "(", "self", ")", ":", "return", "[", "p", ".", "value", "for", "p", "in", "atleast_list", "(", "self", ".", "params", ")", "if", "p", ".", "has_value", "]" ]
Get a list of the ``Parameter`` values if they have a value. This does not include the basis regularizer.
[ "Get", "a", "list", "of", "the", "Parameter", "values", "if", "they", "have", "a", "value", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L299-L305
49,578
NICTA/revrand
revrand/basis_functions.py
RadialBasis.transform
def transform(self, X, lenscale=None): """ Apply the RBF to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional scal...
python
def transform(self, X, lenscale=None): """ Apply the RBF to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional scal...
[ "def", "transform", "(", "self", ",", "X", ",", "lenscale", "=", "None", ")", ":", "N", ",", "d", "=", "X", ".", "shape", "lenscale", "=", "self", ".", "_check_dim", "(", "d", ",", "lenscale", ")", "den", "=", "(", "2", "*", "lenscale", "**", "...
Apply the RBF to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional scalar or array of shape (d,) length scales (one for each dimen...
[ "Apply", "the", "RBF", "to", "X", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L663-L686
49,579
NICTA/revrand
revrand/basis_functions.py
SigmoidalBasis.transform
def transform(self, X, lenscale=None): r""" Apply the sigmoid basis function to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: float the le...
python
def transform(self, X, lenscale=None): r""" Apply the sigmoid basis function to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: float the le...
[ "def", "transform", "(", "self", ",", "X", ",", "lenscale", "=", "None", ")", ":", "N", ",", "d", "=", "X", ".", "shape", "lenscale", "=", "self", ".", "_check_dim", "(", "d", ",", "lenscale", ")", "return", "expit", "(", "cdist", "(", "X", "/", ...
r""" Apply the sigmoid basis function to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: float the length scale (scalar) of the RBFs to apply to X. ...
[ "r", "Apply", "the", "sigmoid", "basis", "function", "to", "X", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L763-L784
49,580
NICTA/revrand
revrand/basis_functions.py
_RandomKernelBasis.transform
def transform(self, X, lenscale=None): """ Apply the random basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional ...
python
def transform(self, X, lenscale=None): """ Apply the random basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional ...
[ "def", "transform", "(", "self", ",", "X", ",", "lenscale", "=", "None", ")", ":", "N", ",", "D", "=", "X", ".", "shape", "lenscale", "=", "self", ".", "_check_dim", "(", "D", ",", "lenscale", ")", "[", ":", ",", "np", ".", "newaxis", "]", "WX"...
Apply the random basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional scalar or array of shape (d,) length scales (one for e...
[ "Apply", "the", "random", "basis", "to", "X", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L839-L864
49,581
NICTA/revrand
revrand/basis_functions.py
_RandomKernelBasis.grad
def grad(self, X, lenscale=None): r""" Get the gradients of this basis w.r.t.\ the length scales. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or...
python
def grad(self, X, lenscale=None): r""" Get the gradients of this basis w.r.t.\ the length scales. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or...
[ "def", "grad", "(", "self", ",", "X", ",", "lenscale", "=", "None", ")", ":", "N", ",", "D", "=", "X", ".", "shape", "lenscale", "=", "self", ".", "_check_dim", "(", "D", ",", "lenscale", ")", "[", ":", ",", "np", ".", "newaxis", "]", "WX", "...
r""" Get the gradients of this basis w.r.t.\ the length scales. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional scalar or a...
[ "r", "Get", "the", "gradients", "of", "this", "basis", "w", ".", "r", ".", "t", ".", "\\", "the", "length", "scales", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L867-L901
49,582
NICTA/revrand
revrand/basis_functions.py
FastFoodRBF.transform
def transform(self, X, lenscale=None): """ Apply the Fast Food RBF basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional ...
python
def transform(self, X, lenscale=None): """ Apply the Fast Food RBF basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional ...
[ "def", "transform", "(", "self", ",", "X", ",", "lenscale", "=", "None", ")", ":", "lenscale", "=", "self", ".", "_check_dim", "(", "X", ".", "shape", "[", "1", "]", ",", "lenscale", ")", "VX", "=", "self", ".", "_makeVX", "(", "X", "/", "lenscal...
Apply the Fast Food RBF basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. lenscale: scalar or ndarray, optional scalar or array of shape (d,) length scales (on...
[ "Apply", "the", "Fast", "Food", "RBF", "basis", "to", "X", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L1264-L1289
49,583
NICTA/revrand
revrand/basis_functions.py
FastFoodGM.transform
def transform(self, X, mean=None, lenscale=None): """ Apply the spectral mixture component basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. mean: ndarray,...
python
def transform(self, X, mean=None, lenscale=None): """ Apply the spectral mixture component basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. mean: ndarray,...
[ "def", "transform", "(", "self", ",", "X", ",", "mean", "=", "None", ",", "lenscale", "=", "None", ")", ":", "mean", "=", "self", ".", "_check_dim", "(", "X", ".", "shape", "[", "1", "]", ",", "mean", ",", "paramind", "=", "0", ")", "lenscale", ...
Apply the spectral mixture component basis to X. Parameters ---------- X: ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. mean: ndarray, optional array of shape (d,) frequency means (one for eac...
[ "Apply", "the", "spectral", "mixture", "component", "basis", "to", "X", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L1444-L1475
49,584
NICTA/revrand
revrand/basis_functions.py
FastFoodGM.grad
def grad(self, X, mean=None, lenscale=None): r""" Get the gradients of this basis w.r.t.\ the mean and length scales. Parameters ---------- x: ndarray (n, d) array of observations where n is the number of samples, and d is the dimensionality of x. ...
python
def grad(self, X, mean=None, lenscale=None): r""" Get the gradients of this basis w.r.t.\ the mean and length scales. Parameters ---------- x: ndarray (n, d) array of observations where n is the number of samples, and d is the dimensionality of x. ...
[ "def", "grad", "(", "self", ",", "X", ",", "mean", "=", "None", ",", "lenscale", "=", "None", ")", ":", "d", "=", "X", ".", "shape", "[", "1", "]", "mean", "=", "self", ".", "_check_dim", "(", "d", ",", "mean", ",", "paramind", "=", "0", ")",...
r""" Get the gradients of this basis w.r.t.\ the mean and length scales. Parameters ---------- x: ndarray (n, d) array of observations where n is the number of samples, and d is the dimensionality of x. mean: ndarray, optional array of shape (...
[ "r", "Get", "the", "gradients", "of", "this", "basis", "w", ".", "r", ".", "t", ".", "\\", "the", "mean", "and", "length", "scales", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L1478-L1537
49,585
NICTA/revrand
revrand/basis_functions.py
BasisCat.transform
def transform(self, X, *params): """ Return the basis function applied to X. I.e. Phi(X, params), where params can also optionally be used and learned. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of samples, a...
python
def transform(self, X, *params): """ Return the basis function applied to X. I.e. Phi(X, params), where params can also optionally be used and learned. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of samples, a...
[ "def", "transform", "(", "self", ",", "X", ",", "*", "params", ")", ":", "Phi", "=", "[", "]", "args", "=", "list", "(", "params", ")", "for", "base", "in", "self", ".", "bases", ":", "phi", ",", "args", "=", "base", ".", "_transform_popargs", "(...
Return the basis function applied to X. I.e. Phi(X, params), where params can also optionally be used and learned. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. ...
[ "Return", "the", "basis", "function", "applied", "to", "X", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L1599-L1627
49,586
NICTA/revrand
revrand/basis_functions.py
BasisCat.grad
def grad(self, X, *params): """ Return the gradient of the basis function for each parameter. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. *params : optional ...
python
def grad(self, X, *params): """ Return the gradient of the basis function for each parameter. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. *params : optional ...
[ "def", "grad", "(", "self", ",", "X", ",", "*", "params", ")", ":", "# Establish a few dimensions", "N", "=", "X", ".", "shape", "[", "0", "]", "D", "=", "self", ".", "get_dim", "(", "X", ")", "endinds", "=", "self", ".", "__base_locations", "(", "...
Return the gradient of the basis function for each parameter. Parameters ---------- X : ndarray (N, d) array of observations where N is the number of samples, and d is the dimensionality of X. *params : optional parameter aguments, these are the param...
[ "Return", "the", "gradient", "of", "the", "basis", "function", "for", "each", "parameter", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L1629-L1677
49,587
NICTA/revrand
revrand/basis_functions.py
BasisCat.params
def params(self): """ Return a list of all of the ``Parameter`` objects. Or a just a single ``Parameter`` is there is only one, and single empty ``Parameter`` if there are no parameters. """ paramlist = [b.params for b in self.bases if b.params.has_value] if len...
python
def params(self): """ Return a list of all of the ``Parameter`` objects. Or a just a single ``Parameter`` is there is only one, and single empty ``Parameter`` if there are no parameters. """ paramlist = [b.params for b in self.bases if b.params.has_value] if len...
[ "def", "params", "(", "self", ")", ":", "paramlist", "=", "[", "b", ".", "params", "for", "b", "in", "self", ".", "bases", "if", "b", ".", "params", ".", "has_value", "]", "if", "len", "(", "paramlist", ")", "==", "0", ":", "return", "Parameter", ...
Return a list of all of the ``Parameter`` objects. Or a just a single ``Parameter`` is there is only one, and single empty ``Parameter`` if there are no parameters.
[ "Return", "a", "list", "of", "all", "of", "the", "Parameter", "objects", "." ]
4c1881b6c1772d2b988518e49dde954f165acfb6
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/basis_functions.py#L1751-L1763
49,588
codeinn/vcs
vcs/utils/diffs.py
get_udiff
def get_udiff(filenode_old, filenode_new, show_whitespace=True): """ Returns unified diff between given ``filenode_old`` and ``filenode_new``. """ try: filenode_old_date = filenode_old.changeset.date except NodeError: filenode_old_date = None try: filenode_new_date = fil...
python
def get_udiff(filenode_old, filenode_new, show_whitespace=True): """ Returns unified diff between given ``filenode_old`` and ``filenode_new``. """ try: filenode_old_date = filenode_old.changeset.date except NodeError: filenode_old_date = None try: filenode_new_date = fil...
[ "def", "get_udiff", "(", "filenode_old", ",", "filenode_new", ",", "show_whitespace", "=", "True", ")", ":", "try", ":", "filenode_old_date", "=", "filenode_old", ".", "changeset", ".", "date", "except", "NodeError", ":", "filenode_old_date", "=", "None", "try",...
Returns unified diff between given ``filenode_old`` and ``filenode_new``.
[ "Returns", "unified", "diff", "between", "given", "filenode_old", "and", "filenode_new", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L16-L46
49,589
codeinn/vcs
vcs/utils/diffs.py
get_gitdiff
def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True): """ Returns git style diff between given ``filenode_old`` and ``filenode_new``. :param ignore_whitespace: ignore whitespaces in diff """ for filenode in (filenode_old, filenode_new): if not isinstance(filenode, FileNode):...
python
def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True): """ Returns git style diff between given ``filenode_old`` and ``filenode_new``. :param ignore_whitespace: ignore whitespaces in diff """ for filenode in (filenode_old, filenode_new): if not isinstance(filenode, FileNode):...
[ "def", "get_gitdiff", "(", "filenode_old", ",", "filenode_new", ",", "ignore_whitespace", "=", "True", ")", ":", "for", "filenode", "in", "(", "filenode_old", ",", "filenode_new", ")", ":", "if", "not", "isinstance", "(", "filenode", ",", "FileNode", ")", ":...
Returns git style diff between given ``filenode_old`` and ``filenode_new``. :param ignore_whitespace: ignore whitespaces in diff
[ "Returns", "git", "style", "diff", "between", "given", "filenode_old", "and", "filenode_new", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L49-L68
49,590
codeinn/vcs
vcs/utils/diffs.py
DiffProcessor.copy_iterator
def copy_iterator(self): """ make a fresh copy of generator, we should not iterate thru an original as it's needed for repeating operations on this instance of DiffProcessor """ self.__udiff, iterator_copy = itertools.tee(self.__udiff) return iterator_copy
python
def copy_iterator(self): """ make a fresh copy of generator, we should not iterate thru an original as it's needed for repeating operations on this instance of DiffProcessor """ self.__udiff, iterator_copy = itertools.tee(self.__udiff) return iterator_copy
[ "def", "copy_iterator", "(", "self", ")", ":", "self", ".", "__udiff", ",", "iterator_copy", "=", "itertools", ".", "tee", "(", "self", ".", "__udiff", ")", "return", "iterator_copy" ]
make a fresh copy of generator, we should not iterate thru an original as it's needed for repeating operations on this instance of DiffProcessor
[ "make", "a", "fresh", "copy", "of", "generator", "we", "should", "not", "iterate", "thru", "an", "original", "as", "it", "s", "needed", "for", "repeating", "operations", "on", "this", "instance", "of", "DiffProcessor" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L112-L119
49,591
codeinn/vcs
vcs/utils/diffs.py
DiffProcessor._extract_rev
def _extract_rev(self, line1, line2): """ Extract the filename and revision hint from a line. """ try: if line1.startswith('--- ') and line2.startswith('+++ '): l1 = line1[4:].split(None, 1) old_filename = l1[0].lstrip('a/') if len(l1) >= 1 el...
python
def _extract_rev(self, line1, line2): """ Extract the filename and revision hint from a line. """ try: if line1.startswith('--- ') and line2.startswith('+++ '): l1 = line1[4:].split(None, 1) old_filename = l1[0].lstrip('a/') if len(l1) >= 1 el...
[ "def", "_extract_rev", "(", "self", ",", "line1", ",", "line2", ")", ":", "try", ":", "if", "line1", ".", "startswith", "(", "'--- '", ")", "and", "line2", ".", "startswith", "(", "'+++ '", ")", ":", "l1", "=", "line1", "[", "4", ":", "]", ".", "...
Extract the filename and revision hint from a line.
[ "Extract", "the", "filename", "and", "revision", "hint", "from", "a", "line", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L121-L143
49,592
codeinn/vcs
vcs/utils/diffs.py
DiffProcessor._parse_udiff
def _parse_udiff(self): """ Parse the diff an return data for the template. """ lineiter = self.lines files = [] try: line = lineiter.next() # skip first context skipfirst = True while 1: # continue until we ...
python
def _parse_udiff(self): """ Parse the diff an return data for the template. """ lineiter = self.lines files = [] try: line = lineiter.next() # skip first context skipfirst = True while 1: # continue until we ...
[ "def", "_parse_udiff", "(", "self", ")", ":", "lineiter", "=", "self", ".", "lines", "files", "=", "[", "]", "try", ":", "line", "=", "lineiter", ".", "next", "(", ")", "# skip first context", "skipfirst", "=", "True", "while", "1", ":", "# continue unti...
Parse the diff an return data for the template.
[ "Parse", "the", "diff", "an", "return", "data", "for", "the", "template", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L228-L333
49,593
codeinn/vcs
vcs/utils/diffs.py
DiffProcessor._safe_id
def _safe_id(self, idstring): """Make a string safe for including in an id attribute. The HTML spec says that id attributes 'must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and peri...
python
def _safe_id(self, idstring): """Make a string safe for including in an id attribute. The HTML spec says that id attributes 'must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and peri...
[ "def", "_safe_id", "(", "self", ",", "idstring", ")", ":", "# Transform all whitespace to underscore", "idstring", "=", "re", ".", "sub", "(", "r'\\s'", ",", "\"_\"", ",", "'%s'", "%", "idstring", ")", "# Remove everything that is not a hyphen or a member of \\w", "id...
Make a string safe for including in an id attribute. The HTML spec says that id attributes 'must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")'. These regexps are sli...
[ "Make", "a", "string", "safe", "for", "including", "in", "an", "id", "attribute", "." ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L342-L361
49,594
codeinn/vcs
vcs/utils/diffs.py
DiffProcessor.raw_diff
def raw_diff(self): """ Returns raw string as udiff """ udiff_copy = self.copy_iterator() if self.__format == 'gitdiff': udiff_copy = self._parse_gitdiff(udiff_copy) return u''.join(udiff_copy)
python
def raw_diff(self): """ Returns raw string as udiff """ udiff_copy = self.copy_iterator() if self.__format == 'gitdiff': udiff_copy = self._parse_gitdiff(udiff_copy) return u''.join(udiff_copy)
[ "def", "raw_diff", "(", "self", ")", ":", "udiff_copy", "=", "self", ".", "copy_iterator", "(", ")", "if", "self", ".", "__format", "==", "'gitdiff'", ":", "udiff_copy", "=", "self", ".", "_parse_gitdiff", "(", "udiff_copy", ")", "return", "u''", ".", "j...
Returns raw string as udiff
[ "Returns", "raw", "string", "as", "udiff" ]
e6cd94188e9c36d273411bf3adc0584ac6ab92a0
https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/diffs.py#L363-L370
49,595
deontologician/restnavigator
restnavigator/halnav.py
APICore.cache
def cache(self, link, nav): '''Stores a navigator in the identity map for the current api. Can take a link or a bare uri''' if link is None: return # We don't cache navigators without a Link elif hasattr(link, 'uri'): self.id_map[link.uri] = nav else: ...
python
def cache(self, link, nav): '''Stores a navigator in the identity map for the current api. Can take a link or a bare uri''' if link is None: return # We don't cache navigators without a Link elif hasattr(link, 'uri'): self.id_map[link.uri] = nav else: ...
[ "def", "cache", "(", "self", ",", "link", ",", "nav", ")", ":", "if", "link", "is", "None", ":", "return", "# We don't cache navigators without a Link", "elif", "hasattr", "(", "link", ",", "'uri'", ")", ":", "self", ".", "id_map", "[", "link", ".", "uri...
Stores a navigator in the identity map for the current api. Can take a link or a bare uri
[ "Stores", "a", "navigator", "in", "the", "identity", "map", "for", "the", "current", "api", ".", "Can", "take", "a", "link", "or", "a", "bare", "uri" ]
453b9de4e70e602009d3e3ffafcf77d23c8b07c5
https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/halnav.py#L63-L71
49,596
deontologician/restnavigator
restnavigator/halnav.py
APICore.get_cached
def get_cached(self, link, default=None): '''Retrieves a cached navigator from the id_map. Either a Link object or a bare uri string may be passed in.''' if hasattr(link, 'uri'): return self.id_map.get(link.uri, default) else: return self.id_map.get(link, default...
python
def get_cached(self, link, default=None): '''Retrieves a cached navigator from the id_map. Either a Link object or a bare uri string may be passed in.''' if hasattr(link, 'uri'): return self.id_map.get(link.uri, default) else: return self.id_map.get(link, default...
[ "def", "get_cached", "(", "self", ",", "link", ",", "default", "=", "None", ")", ":", "if", "hasattr", "(", "link", ",", "'uri'", ")", ":", "return", "self", ".", "id_map", ".", "get", "(", "link", ".", "uri", ",", "default", ")", "else", ":", "r...
Retrieves a cached navigator from the id_map. Either a Link object or a bare uri string may be passed in.
[ "Retrieves", "a", "cached", "navigator", "from", "the", "id_map", "." ]
453b9de4e70e602009d3e3ffafcf77d23c8b07c5
https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/halnav.py#L73-L80
49,597
deontologician/restnavigator
restnavigator/halnav.py
APICore.is_cached
def is_cached(self, link): '''Returns whether the current navigator is cached. Intended to be overwritten and customized by subclasses. ''' if link is None: return False elif hasattr(link, 'uri'): return link.uri in self.id_map else: re...
python
def is_cached(self, link): '''Returns whether the current navigator is cached. Intended to be overwritten and customized by subclasses. ''' if link is None: return False elif hasattr(link, 'uri'): return link.uri in self.id_map else: re...
[ "def", "is_cached", "(", "self", ",", "link", ")", ":", "if", "link", "is", "None", ":", "return", "False", "elif", "hasattr", "(", "link", ",", "'uri'", ")", ":", "return", "link", ".", "uri", "in", "self", ".", "id_map", "else", ":", "return", "l...
Returns whether the current navigator is cached. Intended to be overwritten and customized by subclasses.
[ "Returns", "whether", "the", "current", "navigator", "is", "cached", ".", "Intended", "to", "be", "overwritten", "and", "customized", "by", "subclasses", "." ]
453b9de4e70e602009d3e3ffafcf77d23c8b07c5
https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/halnav.py#L82-L91
49,598
deontologician/restnavigator
restnavigator/halnav.py
PartialNavigator.expand_uri
def expand_uri(self, **kwargs): '''Returns the template uri expanded with the current arguments''' kwargs = dict([(k, v if v != 0 else '0') for k, v in kwargs.items()]) return uritemplate.expand(self.link.uri, kwargs)
python
def expand_uri(self, **kwargs): '''Returns the template uri expanded with the current arguments''' kwargs = dict([(k, v if v != 0 else '0') for k, v in kwargs.items()]) return uritemplate.expand(self.link.uri, kwargs)
[ "def", "expand_uri", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "dict", "(", "[", "(", "k", ",", "v", "if", "v", "!=", "0", "else", "'0'", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", "]", ")", "ret...
Returns the template uri expanded with the current arguments
[ "Returns", "the", "template", "uri", "expanded", "with", "the", "current", "arguments" ]
453b9de4e70e602009d3e3ffafcf77d23c8b07c5
https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/halnav.py#L134-L137
49,599
deontologician/restnavigator
restnavigator/halnav.py
PartialNavigator.expand_link
def expand_link(self, **kwargs): '''Expands with the given arguments and returns a new untemplated Link object ''' props = self.link.props.copy() del props['templated'] return Link( uri=self.expand_uri(**kwargs), properties=props, )
python
def expand_link(self, **kwargs): '''Expands with the given arguments and returns a new untemplated Link object ''' props = self.link.props.copy() del props['templated'] return Link( uri=self.expand_uri(**kwargs), properties=props, )
[ "def", "expand_link", "(", "self", ",", "*", "*", "kwargs", ")", ":", "props", "=", "self", ".", "link", ".", "props", ".", "copy", "(", ")", "del", "props", "[", "'templated'", "]", "return", "Link", "(", "uri", "=", "self", ".", "expand_uri", "("...
Expands with the given arguments and returns a new untemplated Link object
[ "Expands", "with", "the", "given", "arguments", "and", "returns", "a", "new", "untemplated", "Link", "object" ]
453b9de4e70e602009d3e3ffafcf77d23c8b07c5
https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/halnav.py#L139-L148