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
232,700
nerdvegas/rez
src/rezplugins/build_system/custom.py
CustomBuildSystem.build
def build(self, context, variant, build_path, install_path, install=False, build_type=BuildType.local): """Perform the build. Note that most of the func args aren't used here - that's because this info is already passed to the custom build command via environment variables...
python
def build(self, context, variant, build_path, install_path, install=False, build_type=BuildType.local): """Perform the build. Note that most of the func args aren't used here - that's because this info is already passed to the custom build command via environment variables...
[ "def", "build", "(", "self", ",", "context", ",", "variant", ",", "build_path", ",", "install_path", ",", "install", "=", "False", ",", "build_type", "=", "BuildType", ".", "local", ")", ":", "ret", "=", "{", "}", "if", "self", ".", "write_build_scripts"...
Perform the build. Note that most of the func args aren't used here - that's because this info is already passed to the custom build command via environment variables.
[ "Perform", "the", "build", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/build_system/custom.py#L87-L176
232,701
nerdvegas/rez
src/rezplugins/release_vcs/hg.py
HgReleaseVCS._create_tag_highlevel
def _create_tag_highlevel(self, tag_name, message=None): """Create a tag on the toplevel repo if there is no patch repo, or a tag on the patch repo and bookmark on the top repo if there is a patch repo Returns a list where each entry is a dict for each bookmark or tag created, w...
python
def _create_tag_highlevel(self, tag_name, message=None): """Create a tag on the toplevel repo if there is no patch repo, or a tag on the patch repo and bookmark on the top repo if there is a patch repo Returns a list where each entry is a dict for each bookmark or tag created, w...
[ "def", "_create_tag_highlevel", "(", "self", ",", "tag_name", ",", "message", "=", "None", ")", ":", "results", "=", "[", "]", "if", "self", ".", "patch_path", ":", "# make a tag on the patch queue", "tagged", "=", "self", ".", "_create_tag_lowlevel", "(", "ta...
Create a tag on the toplevel repo if there is no patch repo, or a tag on the patch repo and bookmark on the top repo if there is a patch repo Returns a list where each entry is a dict for each bookmark or tag created, which looks like {'type': ('bookmark' or 'tag'), 'patch': bool}
[ "Create", "a", "tag", "on", "the", "toplevel", "repo", "if", "there", "is", "no", "patch", "repo", "or", "a", "tag", "on", "the", "patch", "repo", "and", "bookmark", "on", "the", "top", "repo", "if", "there", "is", "a", "patch", "repo" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L58-L82
232,702
nerdvegas/rez
src/rezplugins/release_vcs/hg.py
HgReleaseVCS._create_tag_lowlevel
def _create_tag_lowlevel(self, tag_name, message=None, force=True, patch=False): """Create a tag on the toplevel or patch repo If the tag exists, and force is False, no tag is made. If force is True, and a tag exists, but it is a direct ancestor of the current commi...
python
def _create_tag_lowlevel(self, tag_name, message=None, force=True, patch=False): """Create a tag on the toplevel or patch repo If the tag exists, and force is False, no tag is made. If force is True, and a tag exists, but it is a direct ancestor of the current commi...
[ "def", "_create_tag_lowlevel", "(", "self", ",", "tag_name", ",", "message", "=", "None", ",", "force", "=", "True", ",", "patch", "=", "False", ")", ":", "# check if tag already exists, and if it does, if it is a direct", "# ancestor, and there is NO difference in the file...
Create a tag on the toplevel or patch repo If the tag exists, and force is False, no tag is made. If force is True, and a tag exists, but it is a direct ancestor of the current commit, and there is no difference in filestate between the current commit and the tagged commit, no tag is ma...
[ "Create", "a", "tag", "on", "the", "toplevel", "or", "patch", "repo" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L84-L137
232,703
nerdvegas/rez
src/rezplugins/release_vcs/hg.py
HgReleaseVCS.is_ancestor
def is_ancestor(self, commit1, commit2, patch=False): """Returns True if commit1 is a direct ancestor of commit2, or False otherwise. This method considers a commit to be a direct ancestor of itself""" result = self.hg("log", "-r", "first(%s::%s)" % (commit1, commit2), ...
python
def is_ancestor(self, commit1, commit2, patch=False): """Returns True if commit1 is a direct ancestor of commit2, or False otherwise. This method considers a commit to be a direct ancestor of itself""" result = self.hg("log", "-r", "first(%s::%s)" % (commit1, commit2), ...
[ "def", "is_ancestor", "(", "self", ",", "commit1", ",", "commit2", ",", "patch", "=", "False", ")", ":", "result", "=", "self", ".", "hg", "(", "\"log\"", ",", "\"-r\"", ",", "\"first(%s::%s)\"", "%", "(", "commit1", ",", "commit2", ")", ",", "\"--temp...
Returns True if commit1 is a direct ancestor of commit2, or False otherwise. This method considers a commit to be a direct ancestor of itself
[ "Returns", "True", "if", "commit1", "is", "a", "direct", "ancestor", "of", "commit2", "or", "False", "otherwise", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/hg.py#L159-L166
232,704
nerdvegas/rez
src/rez/utils/patching.py
get_patched_request
def get_patched_request(requires, patchlist): """Apply patch args to a request. For example, consider: >>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"]) ["foo-6", "bah-8.1"] >>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"]) ["foo-5"] The following ...
python
def get_patched_request(requires, patchlist): """Apply patch args to a request. For example, consider: >>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"]) ["foo-6", "bah-8.1"] >>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"]) ["foo-5"] The following ...
[ "def", "get_patched_request", "(", "requires", ",", "patchlist", ")", ":", "# rules from table in docstring above", "rules", "=", "{", "''", ":", "(", "True", ",", "True", ",", "True", ")", ",", "'!'", ":", "(", "False", ",", "False", ",", "False", ")", ...
Apply patch args to a request. For example, consider: >>> print get_patched_request(["foo-5", "bah-8.1"], ["foo-6"]) ["foo-6", "bah-8.1"] >>> print get_patched_request(["foo-5", "bah-8.1"], ["^bah"]) ["foo-5"] The following rules apply wrt how normal/conflict/weak patches over...
[ "Apply", "patch", "args", "to", "a", "request", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/patching.py#L4-L78
232,705
nerdvegas/rez
src/support/shotgun_toolkit/rez_app_launch.py
AppLaunch.execute
def execute(self, app_path, app_args, version, **kwargs): """ The execute functon of the hook will be called to start the required application :param app_path: (str) The path of the application executable :param app_args: (str) Any arguments the application may require :param ve...
python
def execute(self, app_path, app_args, version, **kwargs): """ The execute functon of the hook will be called to start the required application :param app_path: (str) The path of the application executable :param app_args: (str) Any arguments the application may require :param ve...
[ "def", "execute", "(", "self", ",", "app_path", ",", "app_args", ",", "version", ",", "*", "*", "kwargs", ")", ":", "multi_launchapp", "=", "self", ".", "parent", "extra", "=", "multi_launchapp", ".", "get_setting", "(", "\"extra\"", ")", "use_rez", "=", ...
The execute functon of the hook will be called to start the required application :param app_path: (str) The path of the application executable :param app_args: (str) Any arguments the application may require :param version: (str) version of the application being run if set in the "versions" set...
[ "The", "execute", "functon", "of", "the", "hook", "will", "be", "called", "to", "start", "the", "required", "application" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/support/shotgun_toolkit/rez_app_launch.py#L37-L117
232,706
nerdvegas/rez
src/support/shotgun_toolkit/rez_app_launch.py
AppLaunch.check_rez
def check_rez(self, strict=True): """ Checks to see if a Rez package is available in the current environment. If it is available, add it to the system path, exposing the Rez Python API :param strict: (bool) If True, raise an error if Rez is not available as a package. ...
python
def check_rez(self, strict=True): """ Checks to see if a Rez package is available in the current environment. If it is available, add it to the system path, exposing the Rez Python API :param strict: (bool) If True, raise an error if Rez is not available as a package. ...
[ "def", "check_rez", "(", "self", ",", "strict", "=", "True", ")", ":", "system", "=", "sys", ".", "platform", "if", "system", "==", "\"win32\"", ":", "rez_cmd", "=", "'rez-env rez -- echo %REZ_REZ_ROOT%'", "else", ":", "rez_cmd", "=", "'rez-env rez -- printenv R...
Checks to see if a Rez package is available in the current environment. If it is available, add it to the system path, exposing the Rez Python API :param strict: (bool) If True, raise an error if Rez is not available as a package. This will prevent the app from being launc...
[ "Checks", "to", "see", "if", "a", "Rez", "package", "is", "available", "in", "the", "current", "environment", ".", "If", "it", "is", "available", "add", "it", "to", "the", "system", "path", "exposing", "the", "Rez", "Python", "API" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/support/shotgun_toolkit/rez_app_launch.py#L119-L155
232,707
nerdvegas/rez
src/rezplugins/release_vcs/svn.py
get_last_changed_revision
def get_last_changed_revision(client, url): """ util func, get last revision of url """ try: svn_entries = client.info2(url, pysvn.Revision(pysvn.opt_revision_kind.head), recurse=False) if not svn_entries: ...
python
def get_last_changed_revision(client, url): """ util func, get last revision of url """ try: svn_entries = client.info2(url, pysvn.Revision(pysvn.opt_revision_kind.head), recurse=False) if not svn_entries: ...
[ "def", "get_last_changed_revision", "(", "client", ",", "url", ")", ":", "try", ":", "svn_entries", "=", "client", ".", "info2", "(", "url", ",", "pysvn", ".", "Revision", "(", "pysvn", ".", "opt_revision_kind", ".", "head", ")", ",", "recurse", "=", "Fa...
util func, get last revision of url
[ "util", "func", "get", "last", "revision", "of", "url" ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/svn.py#L26-L38
232,708
nerdvegas/rez
src/rezplugins/release_vcs/svn.py
get_svn_login
def get_svn_login(realm, username, may_save): """ provide svn with permissions. @TODO this will have to be updated to take into account automated releases etc. """ import getpass print "svn requires a password for the user %s:" % username pwd = '' while not pwd.strip(): pwd = ge...
python
def get_svn_login(realm, username, may_save): """ provide svn with permissions. @TODO this will have to be updated to take into account automated releases etc. """ import getpass print "svn requires a password for the user %s:" % username pwd = '' while not pwd.strip(): pwd = ge...
[ "def", "get_svn_login", "(", "realm", ",", "username", ",", "may_save", ")", ":", "import", "getpass", "print", "\"svn requires a password for the user %s:\"", "%", "username", "pwd", "=", "''", "while", "not", "pwd", ".", "strip", "(", ")", ":", "pwd", "=", ...
provide svn with permissions. @TODO this will have to be updated to take into account automated releases etc.
[ "provide", "svn", "with", "permissions", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/release_vcs/svn.py#L41-L53
232,709
nerdvegas/rez
src/rez/vendor/pygraph/readwrite/markup.py
read
def read(string): """ Read a graph from a XML document and return it. Nodes and edges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: graph @return: Graph """ dom = parseS...
python
def read(string): """ Read a graph from a XML document and return it. Nodes and edges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: graph @return: Graph """ dom = parseS...
[ "def", "read", "(", "string", ")", ":", "dom", "=", "parseString", "(", "string", ")", "if", "dom", ".", "getElementsByTagName", "(", "\"graph\"", ")", ":", "G", "=", "graph", "(", ")", "elif", "dom", ".", "getElementsByTagName", "(", "\"digraph\"", ")",...
Read a graph from a XML document and return it. Nodes and edges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: graph @return: Graph
[ "Read", "a", "graph", "from", "a", "XML", "document", "and", "return", "it", ".", "Nodes", "and", "edges", "specified", "in", "the", "input", "will", "be", "added", "to", "the", "current", "graph", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/readwrite/markup.py#L91-L132
232,710
nerdvegas/rez
src/rez/vendor/pygraph/readwrite/markup.py
read_hypergraph
def read_hypergraph(string): """ Read a graph from a XML document. Nodes and hyperedges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: hypergraph @return: Hypergraph """ ...
python
def read_hypergraph(string): """ Read a graph from a XML document. Nodes and hyperedges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: hypergraph @return: Hypergraph """ ...
[ "def", "read_hypergraph", "(", "string", ")", ":", "hgr", "=", "hypergraph", "(", ")", "dom", "=", "parseString", "(", "string", ")", "for", "each_node", "in", "dom", ".", "getElementsByTagName", "(", "\"node\"", ")", ":", "hgr", ".", "add_node", "(", "e...
Read a graph from a XML document. Nodes and hyperedges specified in the input will be added to the current graph. @type string: string @param string: Input string in XML format specifying a graph. @rtype: hypergraph @return: Hypergraph
[ "Read", "a", "graph", "from", "a", "XML", "document", ".", "Nodes", "and", "hyperedges", "specified", "in", "the", "input", "will", "be", "added", "to", "the", "current", "graph", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/pygraph/readwrite/markup.py#L172-L195
232,711
nerdvegas/rez
src/rez/utils/diff_packages.py
diff_packages
def diff_packages(pkg1, pkg2=None): """Invoke a diff editor to show the difference between the source of two packages. Args: pkg1 (`Package`): Package to diff. pkg2 (`Package`): Package to diff against. If None, the next most recent package version is used. """ if pkg2 i...
python
def diff_packages(pkg1, pkg2=None): """Invoke a diff editor to show the difference between the source of two packages. Args: pkg1 (`Package`): Package to diff. pkg2 (`Package`): Package to diff against. If None, the next most recent package version is used. """ if pkg2 i...
[ "def", "diff_packages", "(", "pkg1", ",", "pkg2", "=", "None", ")", ":", "if", "pkg2", "is", "None", ":", "it", "=", "iter_packages", "(", "pkg1", ".", "name", ")", "pkgs", "=", "[", "x", "for", "x", "in", "it", "if", "x", ".", "version", "<", ...
Invoke a diff editor to show the difference between the source of two packages. Args: pkg1 (`Package`): Package to diff. pkg2 (`Package`): Package to diff against. If None, the next most recent package version is used.
[ "Invoke", "a", "diff", "editor", "to", "show", "the", "difference", "between", "the", "source", "of", "two", "packages", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/diff_packages.py#L10-L49
232,712
nerdvegas/rez
src/rez/cli/_util.py
sigint_handler
def sigint_handler(signum, frame): """Exit gracefully on ctrl-C.""" global _handled_int if not _handled_int: _handled_int = True if not _env_var_true("_REZ_QUIET_ON_SIG"): print >> sys.stderr, "Interrupted by user" sigbase_handler(signum, frame)
python
def sigint_handler(signum, frame): """Exit gracefully on ctrl-C.""" global _handled_int if not _handled_int: _handled_int = True if not _env_var_true("_REZ_QUIET_ON_SIG"): print >> sys.stderr, "Interrupted by user" sigbase_handler(signum, frame)
[ "def", "sigint_handler", "(", "signum", ",", "frame", ")", ":", "global", "_handled_int", "if", "not", "_handled_int", ":", "_handled_int", "=", "True", "if", "not", "_env_var_true", "(", "\"_REZ_QUIET_ON_SIG\"", ")", ":", "print", ">>", "sys", ".", "stderr", ...
Exit gracefully on ctrl-C.
[ "Exit", "gracefully", "on", "ctrl", "-", "C", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/cli/_util.py#L141-L148
232,713
nerdvegas/rez
src/rez/cli/_util.py
sigterm_handler
def sigterm_handler(signum, frame): """Exit gracefully on terminate.""" global _handled_term if not _handled_term: _handled_term = True if not _env_var_true("_REZ_QUIET_ON_SIG"): print >> sys.stderr, "Terminated by user" sigbase_handler(signum, frame)
python
def sigterm_handler(signum, frame): """Exit gracefully on terminate.""" global _handled_term if not _handled_term: _handled_term = True if not _env_var_true("_REZ_QUIET_ON_SIG"): print >> sys.stderr, "Terminated by user" sigbase_handler(signum, frame)
[ "def", "sigterm_handler", "(", "signum", ",", "frame", ")", ":", "global", "_handled_term", "if", "not", "_handled_term", ":", "_handled_term", "=", "True", "if", "not", "_env_var_true", "(", "\"_REZ_QUIET_ON_SIG\"", ")", ":", "print", ">>", "sys", ".", "stder...
Exit gracefully on terminate.
[ "Exit", "gracefully", "on", "terminate", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/cli/_util.py#L151-L158
232,714
nerdvegas/rez
src/rez/cli/_util.py
LazyArgumentParser.format_help
def format_help(self): """Sets up all sub-parsers when help is requested.""" if self._subparsers: for action in self._subparsers._actions: if isinstance(action, LazySubParsersAction): for parser_name, parser in action._name_parser_map.iteritems(): ...
python
def format_help(self): """Sets up all sub-parsers when help is requested.""" if self._subparsers: for action in self._subparsers._actions: if isinstance(action, LazySubParsersAction): for parser_name, parser in action._name_parser_map.iteritems(): ...
[ "def", "format_help", "(", "self", ")", ":", "if", "self", ".", "_subparsers", ":", "for", "action", "in", "self", ".", "_subparsers", ".", "_actions", ":", "if", "isinstance", "(", "action", ",", "LazySubParsersAction", ")", ":", "for", "parser_name", ","...
Sets up all sub-parsers when help is requested.
[ "Sets", "up", "all", "sub", "-", "parsers", "when", "help", "is", "requested", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/cli/_util.py#L110-L117
232,715
nerdvegas/rez
src/rez/utils/formatting.py
is_valid_package_name
def is_valid_package_name(name, raise_error=False): """Test the validity of a package name string. Args: name (str): Name to test. raise_error (bool): If True, raise an exception on failure Returns: bool. """ is_valid = PACKAGE_NAME_REGEX.match(name) if raise_error and ...
python
def is_valid_package_name(name, raise_error=False): """Test the validity of a package name string. Args: name (str): Name to test. raise_error (bool): If True, raise an exception on failure Returns: bool. """ is_valid = PACKAGE_NAME_REGEX.match(name) if raise_error and ...
[ "def", "is_valid_package_name", "(", "name", ",", "raise_error", "=", "False", ")", ":", "is_valid", "=", "PACKAGE_NAME_REGEX", ".", "match", "(", "name", ")", "if", "raise_error", "and", "not", "is_valid", ":", "raise", "PackageRequestError", "(", "\"Not a vali...
Test the validity of a package name string. Args: name (str): Name to test. raise_error (bool): If True, raise an exception on failure Returns: bool.
[ "Test", "the", "validity", "of", "a", "package", "name", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L27-L40
232,716
nerdvegas/rez
src/rez/utils/formatting.py
expand_abbreviations
def expand_abbreviations(txt, fields): """Expand abbreviations in a format string. If an abbreviation does not match a field, or matches multiple fields, it is left unchanged. Example: >>> fields = ("hey", "there", "dude") >>> expand_abbreviations("hello {d}", fields) 'hello d...
python
def expand_abbreviations(txt, fields): """Expand abbreviations in a format string. If an abbreviation does not match a field, or matches multiple fields, it is left unchanged. Example: >>> fields = ("hey", "there", "dude") >>> expand_abbreviations("hello {d}", fields) 'hello d...
[ "def", "expand_abbreviations", "(", "txt", ",", "fields", ")", ":", "def", "_expand", "(", "matchobj", ")", ":", "s", "=", "matchobj", ".", "group", "(", "\"var\"", ")", "if", "s", "not", "in", "fields", ":", "matches", "=", "[", "x", "for", "x", "...
Expand abbreviations in a format string. If an abbreviation does not match a field, or matches multiple fields, it is left unchanged. Example: >>> fields = ("hey", "there", "dude") >>> expand_abbreviations("hello {d}", fields) 'hello dude' Args: txt (str): Format stri...
[ "Expand", "abbreviations", "in", "a", "format", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L174-L200
232,717
nerdvegas/rez
src/rez/utils/formatting.py
dict_to_attributes_code
def dict_to_attributes_code(dict_): """Given a nested dict, generate a python code equivalent. Example: >>> d = {'foo': 'bah', 'colors': {'red': 1, 'blue': 2}} >>> print dict_to_attributes_code(d) foo = 'bah' colors.red = 1 colors.blue = 2 Returns: str. ...
python
def dict_to_attributes_code(dict_): """Given a nested dict, generate a python code equivalent. Example: >>> d = {'foo': 'bah', 'colors': {'red': 1, 'blue': 2}} >>> print dict_to_attributes_code(d) foo = 'bah' colors.red = 1 colors.blue = 2 Returns: str. ...
[ "def", "dict_to_attributes_code", "(", "dict_", ")", ":", "lines", "=", "[", "]", "for", "key", ",", "value", "in", "dict_", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "txt", "=", "dict_to_attributes_code", ...
Given a nested dict, generate a python code equivalent. Example: >>> d = {'foo': 'bah', 'colors': {'red': 1, 'blue': 2}} >>> print dict_to_attributes_code(d) foo = 'bah' colors.red = 1 colors.blue = 2 Returns: str.
[ "Given", "a", "nested", "dict", "generate", "a", "python", "code", "equivalent", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L247-L279
232,718
nerdvegas/rez
src/rez/utils/formatting.py
columnise
def columnise(rows, padding=2): """Print rows of entries in aligned columns.""" strs = [] maxwidths = {} for row in rows: for i, e in enumerate(row): se = str(e) nse = len(se) w = maxwidths.get(i, -1) if nse > w: maxwidths[i] = nse...
python
def columnise(rows, padding=2): """Print rows of entries in aligned columns.""" strs = [] maxwidths = {} for row in rows: for i, e in enumerate(row): se = str(e) nse = len(se) w = maxwidths.get(i, -1) if nse > w: maxwidths[i] = nse...
[ "def", "columnise", "(", "rows", ",", "padding", "=", "2", ")", ":", "strs", "=", "[", "]", "maxwidths", "=", "{", "}", "for", "row", "in", "rows", ":", "for", "i", ",", "e", "in", "enumerate", "(", "row", ")", ":", "se", "=", "str", "(", "e"...
Print rows of entries in aligned columns.
[ "Print", "rows", "of", "entries", "in", "aligned", "columns", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L282-L304
232,719
nerdvegas/rez
src/rez/utils/formatting.py
print_colored_columns
def print_colored_columns(printer, rows, padding=2): """Like `columnise`, but with colored rows. Args: printer (`colorize.Printer`): Printer object. Note: The last entry in each row is the row color, or None for no coloring. """ rows_ = [x[:-1] for x in rows] colors = [x[-1] fo...
python
def print_colored_columns(printer, rows, padding=2): """Like `columnise`, but with colored rows. Args: printer (`colorize.Printer`): Printer object. Note: The last entry in each row is the row color, or None for no coloring. """ rows_ = [x[:-1] for x in rows] colors = [x[-1] fo...
[ "def", "print_colored_columns", "(", "printer", ",", "rows", ",", "padding", "=", "2", ")", ":", "rows_", "=", "[", "x", "[", ":", "-", "1", "]", "for", "x", "in", "rows", "]", "colors", "=", "[", "x", "[", "-", "1", "]", "for", "x", "in", "r...
Like `columnise`, but with colored rows. Args: printer (`colorize.Printer`): Printer object. Note: The last entry in each row is the row color, or None for no coloring.
[ "Like", "columnise", "but", "with", "colored", "rows", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L307-L319
232,720
nerdvegas/rez
src/rez/utils/formatting.py
expanduser
def expanduser(path): """Expand '~' to home directory in the given string. Note that this function deliberately differs from the builtin os.path.expanduser() on Linux systems, which expands strings such as '~sclaus' to that user's homedir. This is problematic in rez because the string '~packagename...
python
def expanduser(path): """Expand '~' to home directory in the given string. Note that this function deliberately differs from the builtin os.path.expanduser() on Linux systems, which expands strings such as '~sclaus' to that user's homedir. This is problematic in rez because the string '~packagename...
[ "def", "expanduser", "(", "path", ")", ":", "if", "'~'", "not", "in", "path", ":", "return", "path", "if", "os", ".", "name", "==", "\"nt\"", ":", "if", "'HOME'", "in", "os", ".", "environ", ":", "userhome", "=", "os", ".", "environ", "[", "'HOME'"...
Expand '~' to home directory in the given string. Note that this function deliberately differs from the builtin os.path.expanduser() on Linux systems, which expands strings such as '~sclaus' to that user's homedir. This is problematic in rez because the string '~packagename' may inadvertently convert t...
[ "Expand", "~", "to", "home", "directory", "in", "the", "given", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L439-L473
232,721
nerdvegas/rez
src/rez/utils/formatting.py
as_block_string
def as_block_string(txt): """Return a string formatted as a python block comment string, like the one you're currently reading. Special characters are escaped if necessary. """ import json lines = [] for line in txt.split('\n'): line_ = json.dumps(line) line_ = line_[1:-1].rstri...
python
def as_block_string(txt): """Return a string formatted as a python block comment string, like the one you're currently reading. Special characters are escaped if necessary. """ import json lines = [] for line in txt.split('\n'): line_ = json.dumps(line) line_ = line_[1:-1].rstri...
[ "def", "as_block_string", "(", "txt", ")", ":", "import", "json", "lines", "=", "[", "]", "for", "line", "in", "txt", ".", "split", "(", "'\\n'", ")", ":", "line_", "=", "json", ".", "dumps", "(", "line", ")", "line_", "=", "line_", "[", "1", ":"...
Return a string formatted as a python block comment string, like the one you're currently reading. Special characters are escaped if necessary.
[ "Return", "a", "string", "formatted", "as", "a", "python", "block", "comment", "string", "like", "the", "one", "you", "re", "currently", "reading", ".", "Special", "characters", "are", "escaped", "if", "necessary", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L476-L488
232,722
nerdvegas/rez
src/rez/utils/formatting.py
StringFormatMixin.format
def format(self, s, pretty=None, expand=None): """Format a string. Args: s (str): String to format, eg "hello {name}" pretty (bool): If True, references to non-string attributes such as lists are converted to basic form, with characters such as br...
python
def format(self, s, pretty=None, expand=None): """Format a string. Args: s (str): String to format, eg "hello {name}" pretty (bool): If True, references to non-string attributes such as lists are converted to basic form, with characters such as br...
[ "def", "format", "(", "self", ",", "s", ",", "pretty", "=", "None", ",", "expand", "=", "None", ")", ":", "if", "pretty", "is", "None", ":", "pretty", "=", "self", ".", "format_pretty", "if", "expand", "is", "None", ":", "expand", "=", "self", ".",...
Format a string. Args: s (str): String to format, eg "hello {name}" pretty (bool): If True, references to non-string attributes such as lists are converted to basic form, with characters such as brackets and parenthesis removed. If None, defaults to the ...
[ "Format", "a", "string", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/formatting.py#L150-L171
232,723
nerdvegas/rez
src/rez/vendor/version/version.py
Version.copy
def copy(self): """Returns a copy of the version.""" other = Version(None) other.tokens = self.tokens[:] other.seps = self.seps[:] return other
python
def copy(self): """Returns a copy of the version.""" other = Version(None) other.tokens = self.tokens[:] other.seps = self.seps[:] return other
[ "def", "copy", "(", "self", ")", ":", "other", "=", "Version", "(", "None", ")", "other", ".", "tokens", "=", "self", ".", "tokens", "[", ":", "]", "other", ".", "seps", "=", "self", ".", "seps", "[", ":", "]", "return", "other" ]
Returns a copy of the version.
[ "Returns", "a", "copy", "of", "the", "version", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L297-L302
232,724
nerdvegas/rez
src/rez/vendor/version/version.py
Version.trim
def trim(self, len_): """Return a copy of the version, possibly with less tokens. Args: len_ (int): New version length. If >= current length, an unchanged copy of the version is returned. """ other = Version(None) other.tokens = self.tokens[:len_] ...
python
def trim(self, len_): """Return a copy of the version, possibly with less tokens. Args: len_ (int): New version length. If >= current length, an unchanged copy of the version is returned. """ other = Version(None) other.tokens = self.tokens[:len_] ...
[ "def", "trim", "(", "self", ",", "len_", ")", ":", "other", "=", "Version", "(", "None", ")", "other", ".", "tokens", "=", "self", ".", "tokens", "[", ":", "len_", "]", "other", ".", "seps", "=", "self", ".", "seps", "[", ":", "len_", "-", "1",...
Return a copy of the version, possibly with less tokens. Args: len_ (int): New version length. If >= current length, an unchanged copy of the version is returned.
[ "Return", "a", "copy", "of", "the", "version", "possibly", "with", "less", "tokens", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L304-L314
232,725
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.union
def union(self, other): """OR together version ranges. Calculates the union of this range with one or more other ranges. Args: other: VersionRange object (or list of) to OR with. Returns: New VersionRange object representing the union. """ if no...
python
def union(self, other): """OR together version ranges. Calculates the union of this range with one or more other ranges. Args: other: VersionRange object (or list of) to OR with. Returns: New VersionRange object representing the union. """ if no...
[ "def", "union", "(", "self", ",", "other", ")", ":", "if", "not", "hasattr", "(", "other", ",", "\"__iter__\"", ")", ":", "other", "=", "[", "other", "]", "bounds", "=", "self", ".", "bounds", "[", ":", "]", "for", "range", "in", "other", ":", "b...
OR together version ranges. Calculates the union of this range with one or more other ranges. Args: other: VersionRange object (or list of) to OR with. Returns: New VersionRange object representing the union.
[ "OR", "together", "version", "ranges", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L814-L834
232,726
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.intersection
def intersection(self, other): """AND together version ranges. Calculates the intersection of this range with one or more other ranges. Args: other: VersionRange object (or list of) to AND with. Returns: New VersionRange object representing the intersection, or...
python
def intersection(self, other): """AND together version ranges. Calculates the intersection of this range with one or more other ranges. Args: other: VersionRange object (or list of) to AND with. Returns: New VersionRange object representing the intersection, or...
[ "def", "intersection", "(", "self", ",", "other", ")", ":", "if", "not", "hasattr", "(", "other", ",", "\"__iter__\"", ")", ":", "other", "=", "[", "other", "]", "bounds", "=", "self", ".", "bounds", "for", "range", "in", "other", ":", "bounds", "=",...
AND together version ranges. Calculates the intersection of this range with one or more other ranges. Args: other: VersionRange object (or list of) to AND with. Returns: New VersionRange object representing the intersection, or None if no ranges intersect.
[ "AND", "together", "version", "ranges", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L836-L859
232,727
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.inverse
def inverse(self): """Calculate the inverse of the range. Returns: New VersionRange object representing the inverse of this range, or None if there is no inverse (ie, this range is the any range). """ if self.is_any(): return None else: ...
python
def inverse(self): """Calculate the inverse of the range. Returns: New VersionRange object representing the inverse of this range, or None if there is no inverse (ie, this range is the any range). """ if self.is_any(): return None else: ...
[ "def", "inverse", "(", "self", ")", ":", "if", "self", ".", "is_any", "(", ")", ":", "return", "None", "else", ":", "bounds", "=", "self", ".", "_inverse", "(", "self", ".", "bounds", ")", "range", "=", "VersionRange", "(", "None", ")", "range", "....
Calculate the inverse of the range. Returns: New VersionRange object representing the inverse of this range, or None if there is no inverse (ie, this range is the any range).
[ "Calculate", "the", "inverse", "of", "the", "range", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L861-L874
232,728
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.split
def split(self): """Split into separate contiguous ranges. Returns: A list of VersionRange objects. For example, the range "3|5+" will be split into ["3", "5+"]. """ ranges = [] for bound in self.bounds: range = VersionRange(None) ...
python
def split(self): """Split into separate contiguous ranges. Returns: A list of VersionRange objects. For example, the range "3|5+" will be split into ["3", "5+"]. """ ranges = [] for bound in self.bounds: range = VersionRange(None) ...
[ "def", "split", "(", "self", ")", ":", "ranges", "=", "[", "]", "for", "bound", "in", "self", ".", "bounds", ":", "range", "=", "VersionRange", "(", "None", ")", "range", ".", "bounds", "=", "[", "bound", "]", "ranges", ".", "append", "(", "range",...
Split into separate contiguous ranges. Returns: A list of VersionRange objects. For example, the range "3|5+" will be split into ["3", "5+"].
[ "Split", "into", "separate", "contiguous", "ranges", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L887-L899
232,729
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.as_span
def as_span(cls, lower_version=None, upper_version=None, lower_inclusive=True, upper_inclusive=True): """Create a range from lower_version..upper_version. Args: lower_version: Version object representing lower bound of the range. upper_version: Version object rep...
python
def as_span(cls, lower_version=None, upper_version=None, lower_inclusive=True, upper_inclusive=True): """Create a range from lower_version..upper_version. Args: lower_version: Version object representing lower bound of the range. upper_version: Version object rep...
[ "def", "as_span", "(", "cls", ",", "lower_version", "=", "None", ",", "upper_version", "=", "None", ",", "lower_inclusive", "=", "True", ",", "upper_inclusive", "=", "True", ")", ":", "lower", "=", "(", "None", "if", "lower_version", "is", "None", "else", ...
Create a range from lower_version..upper_version. Args: lower_version: Version object representing lower bound of the range. upper_version: Version object representing upper bound of the range. Returns: `VersionRange` object.
[ "Create", "a", "range", "from", "lower_version", "..", "upper_version", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L902-L921
232,730
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.from_version
def from_version(cls, version, op=None): """Create a range from a version. Args: version: Version object. This is used as the upper/lower bound of the range. op: Operation as a string. One of 'gt'/'>', 'gte'/'>=', lt'/'<', 'lte'/'<=', 'eq'/'=='. I...
python
def from_version(cls, version, op=None): """Create a range from a version. Args: version: Version object. This is used as the upper/lower bound of the range. op: Operation as a string. One of 'gt'/'>', 'gte'/'>=', lt'/'<', 'lte'/'<=', 'eq'/'=='. I...
[ "def", "from_version", "(", "cls", ",", "version", ",", "op", "=", "None", ")", ":", "lower", "=", "None", "upper", "=", "None", "if", "op", "is", "None", ":", "lower", "=", "_LowerBound", "(", "version", ",", "True", ")", "upper", "=", "_UpperBound"...
Create a range from a version. Args: version: Version object. This is used as the upper/lower bound of the range. op: Operation as a string. One of 'gt'/'>', 'gte'/'>=', lt'/'<', 'lte'/'<=', 'eq'/'=='. If None, a bounded range will be created ...
[ "Create", "a", "range", "from", "a", "version", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L924-L960
232,731
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.from_versions
def from_versions(cls, versions): """Create a range from a list of versions. This method creates a range that contains only the given versions and no other. Typically the range looks like (for eg) "==3|==4|==5.1". Args: versions: List of Version objects. Returns: ...
python
def from_versions(cls, versions): """Create a range from a list of versions. This method creates a range that contains only the given versions and no other. Typically the range looks like (for eg) "==3|==4|==5.1". Args: versions: List of Version objects. Returns: ...
[ "def", "from_versions", "(", "cls", ",", "versions", ")", ":", "range", "=", "cls", "(", "None", ")", "range", ".", "bounds", "=", "[", "]", "for", "version", "in", "dedup", "(", "sorted", "(", "versions", ")", ")", ":", "lower", "=", "_LowerBound", ...
Create a range from a list of versions. This method creates a range that contains only the given versions and no other. Typically the range looks like (for eg) "==3|==4|==5.1". Args: versions: List of Version objects. Returns: `VersionRange` object.
[ "Create", "a", "range", "from", "a", "list", "of", "versions", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L963-L982
232,732
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.to_versions
def to_versions(self): """Returns exact version ranges as Version objects, or None if there are no exact version ranges present. """ versions = [] for bound in self.bounds: if bound.lower.inclusive and bound.upper.inclusive \ and (bound.lower.versi...
python
def to_versions(self): """Returns exact version ranges as Version objects, or None if there are no exact version ranges present. """ versions = [] for bound in self.bounds: if bound.lower.inclusive and bound.upper.inclusive \ and (bound.lower.versi...
[ "def", "to_versions", "(", "self", ")", ":", "versions", "=", "[", "]", "for", "bound", "in", "self", ".", "bounds", ":", "if", "bound", ".", "lower", ".", "inclusive", "and", "bound", ".", "upper", ".", "inclusive", "and", "(", "bound", ".", "lower"...
Returns exact version ranges as Version objects, or None if there are no exact version ranges present.
[ "Returns", "exact", "version", "ranges", "as", "Version", "objects", "or", "None", "if", "there", "are", "no", "exact", "version", "ranges", "present", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L984-L994
232,733
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.contains_version
def contains_version(self, version): """Returns True if version is contained in this range.""" if len(self.bounds) < 5: # not worth overhead of binary search for bound in self.bounds: i = bound.version_containment(version) if i == 0: ...
python
def contains_version(self, version): """Returns True if version is contained in this range.""" if len(self.bounds) < 5: # not worth overhead of binary search for bound in self.bounds: i = bound.version_containment(version) if i == 0: ...
[ "def", "contains_version", "(", "self", ",", "version", ")", ":", "if", "len", "(", "self", ".", "bounds", ")", "<", "5", ":", "# not worth overhead of binary search", "for", "bound", "in", "self", ".", "bounds", ":", "i", "=", "bound", ".", "version_conta...
Returns True if version is contained in this range.
[ "Returns", "True", "if", "version", "is", "contained", "in", "this", "range", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L996-L1010
232,734
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.iter_intersecting
def iter_intersecting(self, iterable, key=None, descending=False): """Like `iter_intersect_test`, but returns intersections only. Returns: An iterator that returns items from `iterable` that intersect. """ return _ContainsVersionIterator(self, iterable, key, descending, ...
python
def iter_intersecting(self, iterable, key=None, descending=False): """Like `iter_intersect_test`, but returns intersections only. Returns: An iterator that returns items from `iterable` that intersect. """ return _ContainsVersionIterator(self, iterable, key, descending, ...
[ "def", "iter_intersecting", "(", "self", ",", "iterable", ",", "key", "=", "None", ",", "descending", "=", "False", ")", ":", "return", "_ContainsVersionIterator", "(", "self", ",", "iterable", ",", "key", ",", "descending", ",", "mode", "=", "_ContainsVersi...
Like `iter_intersect_test`, but returns intersections only. Returns: An iterator that returns items from `iterable` that intersect.
[ "Like", "iter_intersect_test", "but", "returns", "intersections", "only", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1033-L1040
232,735
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.iter_non_intersecting
def iter_non_intersecting(self, iterable, key=None, descending=False): """Like `iter_intersect_test`, but returns non-intersections only. Returns: An iterator that returns items from `iterable` that don't intersect. """ return _ContainsVersionIterator(self, iterable, key, de...
python
def iter_non_intersecting(self, iterable, key=None, descending=False): """Like `iter_intersect_test`, but returns non-intersections only. Returns: An iterator that returns items from `iterable` that don't intersect. """ return _ContainsVersionIterator(self, iterable, key, de...
[ "def", "iter_non_intersecting", "(", "self", ",", "iterable", ",", "key", "=", "None", ",", "descending", "=", "False", ")", ":", "return", "_ContainsVersionIterator", "(", "self", ",", "iterable", ",", "key", ",", "descending", ",", "mode", "=", "_ContainsV...
Like `iter_intersect_test`, but returns non-intersections only. Returns: An iterator that returns items from `iterable` that don't intersect.
[ "Like", "iter_intersect_test", "but", "returns", "non", "-", "intersections", "only", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1042-L1049
232,736
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.span
def span(self): """Return a contiguous range that is a superset of this range. Returns: A VersionRange object representing the span of this range. For example, the span of "2+<4|6+<8" would be "2+<8". """ other = VersionRange(None) bound = _Bound(self.bou...
python
def span(self): """Return a contiguous range that is a superset of this range. Returns: A VersionRange object representing the span of this range. For example, the span of "2+<4|6+<8" would be "2+<8". """ other = VersionRange(None) bound = _Bound(self.bou...
[ "def", "span", "(", "self", ")", ":", "other", "=", "VersionRange", "(", "None", ")", "bound", "=", "_Bound", "(", "self", ".", "bounds", "[", "0", "]", ".", "lower", ",", "self", ".", "bounds", "[", "-", "1", "]", ".", "upper", ")", "other", "...
Return a contiguous range that is a superset of this range. Returns: A VersionRange object representing the span of this range. For example, the span of "2+<4|6+<8" would be "2+<8".
[ "Return", "a", "contiguous", "range", "that", "is", "a", "superset", "of", "this", "range", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1051-L1061
232,737
nerdvegas/rez
src/rez/vendor/version/version.py
VersionRange.visit_versions
def visit_versions(self, func): """Visit each version in the range, and apply a function to each. This is for advanced usage only. If `func` returns a `Version`, this call will change the versions in place. It is possible to change versions in a way that is nonsensical - for ...
python
def visit_versions(self, func): """Visit each version in the range, and apply a function to each. This is for advanced usage only. If `func` returns a `Version`, this call will change the versions in place. It is possible to change versions in a way that is nonsensical - for ...
[ "def", "visit_versions", "(", "self", ",", "func", ")", ":", "for", "bound", "in", "self", ".", "bounds", ":", "if", "bound", ".", "lower", "is", "not", "_LowerBound", ".", "min", ":", "result", "=", "func", "(", "bound", ".", "lower", ".", "version"...
Visit each version in the range, and apply a function to each. This is for advanced usage only. If `func` returns a `Version`, this call will change the versions in place. It is possible to change versions in a way that is nonsensical - for example setting an upper bound to a ...
[ "Visit", "each", "version", "in", "the", "range", "and", "apply", "a", "function", "to", "each", "." ]
1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/vendor/version/version.py#L1065-L1092
232,738
getsentry/raven-python
raven/transport/http.py
HTTPTransport.send
def send(self, url, data, headers): """ Sends a request to a remote webserver using HTTP POST. """ req = urllib2.Request(url, headers=headers) try: response = urlopen( url=req, data=data, timeout=self.timeout, ...
python
def send(self, url, data, headers): """ Sends a request to a remote webserver using HTTP POST. """ req = urllib2.Request(url, headers=headers) try: response = urlopen( url=req, data=data, timeout=self.timeout, ...
[ "def", "send", "(", "self", ",", "url", ",", "data", ",", "headers", ")", ":", "req", "=", "urllib2", ".", "Request", "(", "url", ",", "headers", "=", "headers", ")", "try", ":", "response", "=", "urlopen", "(", "url", "=", "req", ",", "data", "=...
Sends a request to a remote webserver using HTTP POST.
[ "Sends", "a", "request", "to", "a", "remote", "webserver", "using", "HTTP", "POST", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/transport/http.py#L31-L58
232,739
getsentry/raven-python
raven/contrib/django/views.py
extract_auth_vars
def extract_auth_vars(request): """ raven-js will pass both Authorization and X-Sentry-Auth depending on the browser and server configurations. """ if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'): return request.META['HTTP_X_SENTRY_AUTH'] elif request.META.get('HTTP_AU...
python
def extract_auth_vars(request): """ raven-js will pass both Authorization and X-Sentry-Auth depending on the browser and server configurations. """ if request.META.get('HTTP_X_SENTRY_AUTH', '').startswith('Sentry'): return request.META['HTTP_X_SENTRY_AUTH'] elif request.META.get('HTTP_AU...
[ "def", "extract_auth_vars", "(", "request", ")", ":", "if", "request", ".", "META", ".", "get", "(", "'HTTP_X_SENTRY_AUTH'", ",", "''", ")", ".", "startswith", "(", "'Sentry'", ")", ":", "return", "request", ".", "META", "[", "'HTTP_X_SENTRY_AUTH'", "]", "...
raven-js will pass both Authorization and X-Sentry-Auth depending on the browser and server configurations.
[ "raven", "-", "js", "will", "pass", "both", "Authorization", "and", "X", "-", "Sentry", "-", "Auth", "depending", "on", "the", "browser", "and", "server", "configurations", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/views.py#L61-L79
232,740
getsentry/raven-python
raven/events.py
Exception._get_value
def _get_value(self, exc_type, exc_value, exc_traceback): """ Convert exception info to a value for the values list. """ stack_info = get_stack_info( iter_traceback_frames(exc_traceback), transformer=self.transform, capture_locals=self.client.capture_l...
python
def _get_value(self, exc_type, exc_value, exc_traceback): """ Convert exception info to a value for the values list. """ stack_info = get_stack_info( iter_traceback_frames(exc_traceback), transformer=self.transform, capture_locals=self.client.capture_l...
[ "def", "_get_value", "(", "self", ",", "exc_type", ",", "exc_value", ",", "exc_traceback", ")", ":", "stack_info", "=", "get_stack_info", "(", "iter_traceback_frames", "(", "exc_traceback", ")", ",", "transformer", "=", "self", ".", "transform", ",", "capture_lo...
Convert exception info to a value for the values list.
[ "Convert", "exception", "info", "to", "a", "value", "for", "the", "values", "list", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/events.py#L90-L110
232,741
getsentry/raven-python
raven/breadcrumbs.py
record
def record(message=None, timestamp=None, level=None, category=None, data=None, type=None, processor=None): """Records a breadcrumb for all active clients. This is what integration code should use rather than invoking the `captureBreadcrumb` method on a specific client. """ if timestamp i...
python
def record(message=None, timestamp=None, level=None, category=None, data=None, type=None, processor=None): """Records a breadcrumb for all active clients. This is what integration code should use rather than invoking the `captureBreadcrumb` method on a specific client. """ if timestamp i...
[ "def", "record", "(", "message", "=", "None", ",", "timestamp", "=", "None", ",", "level", "=", "None", ",", "category", "=", "None", ",", "data", "=", "None", ",", "type", "=", "None", ",", "processor", "=", "None", ")", ":", "if", "timestamp", "i...
Records a breadcrumb for all active clients. This is what integration code should use rather than invoking the `captureBreadcrumb` method on a specific client.
[ "Records", "a", "breadcrumb", "for", "all", "active", "clients", ".", "This", "is", "what", "integration", "code", "should", "use", "rather", "than", "invoking", "the", "captureBreadcrumb", "method", "on", "a", "specific", "client", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/breadcrumbs.py#L116-L126
232,742
getsentry/raven-python
raven/breadcrumbs.py
ignore_logger
def ignore_logger(name_or_logger, allow_level=None): """Ignores a logger during breadcrumb recording. """ def handler(logger, level, msg, args, kwargs): if allow_level is not None and \ level >= allow_level: return False return True register_special_log_handler(nam...
python
def ignore_logger(name_or_logger, allow_level=None): """Ignores a logger during breadcrumb recording. """ def handler(logger, level, msg, args, kwargs): if allow_level is not None and \ level >= allow_level: return False return True register_special_log_handler(nam...
[ "def", "ignore_logger", "(", "name_or_logger", ",", "allow_level", "=", "None", ")", ":", "def", "handler", "(", "logger", ",", "level", ",", "msg", ",", "args", ",", "kwargs", ")", ":", "if", "allow_level", "is", "not", "None", "and", "level", ">=", "...
Ignores a logger during breadcrumb recording.
[ "Ignores", "a", "logger", "during", "breadcrumb", "recording", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/breadcrumbs.py#L275-L283
232,743
getsentry/raven-python
raven/utils/serializer/manager.py
Serializer.transform
def transform(self, value, **kwargs): """ Primary function which handles recursively transforming values via their serializers """ if value is None: return None objid = id(value) if objid in self.context: return '<...>' self.contex...
python
def transform(self, value, **kwargs): """ Primary function which handles recursively transforming values via their serializers """ if value is None: return None objid = id(value) if objid in self.context: return '<...>' self.contex...
[ "def", "transform", "(", "self", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "value", "is", "None", ":", "return", "None", "objid", "=", "id", "(", "value", ")", "if", "objid", "in", "self", ".", "context", ":", "return", "'<...>'", "sel...
Primary function which handles recursively transforming values via their serializers
[ "Primary", "function", "which", "handles", "recursively", "transforming", "values", "via", "their", "serializers" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/serializer/manager.py#L52-L85
232,744
getsentry/raven-python
raven/contrib/tornado/__init__.py
AsyncSentryClient.send
def send(self, auth_header=None, callback=None, **data): """ Serializes the message and passes the payload onto ``send_encoded``. """ message = self.encode(data) return self.send_encoded(message, auth_header=auth_header, callback=callback)
python
def send(self, auth_header=None, callback=None, **data): """ Serializes the message and passes the payload onto ``send_encoded``. """ message = self.encode(data) return self.send_encoded(message, auth_header=auth_header, callback=callback)
[ "def", "send", "(", "self", ",", "auth_header", "=", "None", ",", "callback", "=", "None", ",", "*", "*", "data", ")", ":", "message", "=", "self", ".", "encode", "(", "data", ")", "return", "self", ".", "send_encoded", "(", "message", ",", "auth_hea...
Serializes the message and passes the payload onto ``send_encoded``.
[ "Serializes", "the", "message", "and", "passes", "the", "payload", "onto", "send_encoded", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/tornado/__init__.py#L47-L53
232,745
getsentry/raven-python
raven/contrib/tornado/__init__.py
AsyncSentryClient._send_remote
def _send_remote(self, url, data, headers=None, callback=None): """ Initialise a Tornado AsyncClient and send the request to the sentry server. If the callback is a callable, it will be called with the response. """ if headers is None: headers = {} re...
python
def _send_remote(self, url, data, headers=None, callback=None): """ Initialise a Tornado AsyncClient and send the request to the sentry server. If the callback is a callable, it will be called with the response. """ if headers is None: headers = {} re...
[ "def", "_send_remote", "(", "self", ",", "url", ",", "data", ",", "headers", "=", "None", ",", "callback", "=", "None", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "{", "}", "return", "AsyncHTTPClient", "(", ")", ".", "fetch", "(", ...
Initialise a Tornado AsyncClient and send the request to the sentry server. If the callback is a callable, it will be called with the response.
[ "Initialise", "a", "Tornado", "AsyncClient", "and", "send", "the", "request", "to", "the", "sentry", "server", ".", "If", "the", "callback", "is", "a", "callable", "it", "will", "be", "called", "with", "the", "response", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/tornado/__init__.py#L82-L94
232,746
getsentry/raven-python
raven/contrib/tornado/__init__.py
SentryMixin.get_sentry_data_from_request
def get_sentry_data_from_request(self): """ Extracts the data required for 'sentry.interfaces.Http' from the current request being handled by the request handler :param return: A dictionary. """ return { 'request': { 'url': self.request.full_u...
python
def get_sentry_data_from_request(self): """ Extracts the data required for 'sentry.interfaces.Http' from the current request being handled by the request handler :param return: A dictionary. """ return { 'request': { 'url': self.request.full_u...
[ "def", "get_sentry_data_from_request", "(", "self", ")", ":", "return", "{", "'request'", ":", "{", "'url'", ":", "self", ".", "request", ".", "full_url", "(", ")", ",", "'method'", ":", "self", ".", "request", ".", "method", ",", "'data'", ":", "self", ...
Extracts the data required for 'sentry.interfaces.Http' from the current request being handled by the request handler :param return: A dictionary.
[ "Extracts", "the", "data", "required", "for", "sentry", ".", "interfaces", ".", "Http", "from", "the", "current", "request", "being", "handled", "by", "the", "request", "handler" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/tornado/__init__.py#L147-L163
232,747
getsentry/raven-python
raven/base.py
Client.get_public_dsn
def get_public_dsn(self, scheme=None): """ Returns a public DSN which is consumable by raven-js >>> # Return scheme-less DSN >>> print client.get_public_dsn() >>> # Specify a scheme to use (http or https) >>> print client.get_public_dsn('https') """ if s...
python
def get_public_dsn(self, scheme=None): """ Returns a public DSN which is consumable by raven-js >>> # Return scheme-less DSN >>> print client.get_public_dsn() >>> # Specify a scheme to use (http or https) >>> print client.get_public_dsn('https') """ if s...
[ "def", "get_public_dsn", "(", "self", ",", "scheme", "=", "None", ")", ":", "if", "self", ".", "is_enabled", "(", ")", ":", "url", "=", "self", ".", "remote", ".", "get_public_dsn", "(", ")", "if", "scheme", ":", "return", "'%s:%s'", "%", "(", "schem...
Returns a public DSN which is consumable by raven-js >>> # Return scheme-less DSN >>> print client.get_public_dsn() >>> # Specify a scheme to use (http or https) >>> print client.get_public_dsn('https')
[ "Returns", "a", "public", "DSN", "which", "is", "consumable", "by", "raven", "-", "js" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L330-L345
232,748
getsentry/raven-python
raven/base.py
Client.capture
def capture(self, event_type, data=None, date=None, time_spent=None, extra=None, stack=None, tags=None, sample_rate=None, **kwargs): """ Captures and processes an event and pipes it off to SentryClient.send. To use structured data (interfaces) with capture: ...
python
def capture(self, event_type, data=None, date=None, time_spent=None, extra=None, stack=None, tags=None, sample_rate=None, **kwargs): """ Captures and processes an event and pipes it off to SentryClient.send. To use structured data (interfaces) with capture: ...
[ "def", "capture", "(", "self", ",", "event_type", ",", "data", "=", "None", ",", "date", "=", "None", ",", "time_spent", "=", "None", ",", "extra", "=", "None", ",", "stack", "=", "None", ",", "tags", "=", "None", ",", "sample_rate", "=", "None", "...
Captures and processes an event and pipes it off to SentryClient.send. To use structured data (interfaces) with capture: >>> capture('raven.events.Message', message='foo', data={ >>> 'request': { >>> 'url': '...', >>> 'data': {}, >>> 'query_s...
[ "Captures", "and", "processes", "an", "event", "and", "pipes", "it", "off", "to", "SentryClient", ".", "send", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L577-L657
232,749
getsentry/raven-python
raven/base.py
Client._log_failed_submission
def _log_failed_submission(self, data): """ Log a reasonable representation of an event that should have been sent to Sentry """ message = data.pop('message', '<no message value>') output = [message] if 'exception' in data and 'stacktrace' in data['exception']['va...
python
def _log_failed_submission(self, data): """ Log a reasonable representation of an event that should have been sent to Sentry """ message = data.pop('message', '<no message value>') output = [message] if 'exception' in data and 'stacktrace' in data['exception']['va...
[ "def", "_log_failed_submission", "(", "self", ",", "data", ")", ":", "message", "=", "data", ".", "pop", "(", "'message'", ",", "'<no message value>'", ")", "output", "=", "[", "message", "]", "if", "'exception'", "in", "data", "and", "'stacktrace'", "in", ...
Log a reasonable representation of an event that should have been sent to Sentry
[ "Log", "a", "reasonable", "representation", "of", "an", "event", "that", "should", "have", "been", "sent", "to", "Sentry" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L696-L712
232,750
getsentry/raven-python
raven/base.py
Client.send_encoded
def send_encoded(self, message, auth_header=None, **kwargs): """ Given an already serialized message, signs the message and passes the payload off to ``send_remote``. """ client_string = 'raven-python/%s' % (raven.VERSION,) if not auth_header: timestamp = tim...
python
def send_encoded(self, message, auth_header=None, **kwargs): """ Given an already serialized message, signs the message and passes the payload off to ``send_remote``. """ client_string = 'raven-python/%s' % (raven.VERSION,) if not auth_header: timestamp = tim...
[ "def", "send_encoded", "(", "self", ",", "message", ",", "auth_header", "=", "None", ",", "*", "*", "kwargs", ")", ":", "client_string", "=", "'raven-python/%s'", "%", "(", "raven", ".", "VERSION", ",", ")", "if", "not", "auth_header", ":", "timestamp", ...
Given an already serialized message, signs the message and passes the payload off to ``send_remote``.
[ "Given", "an", "already", "serialized", "message", "signs", "the", "message", "and", "passes", "the", "payload", "off", "to", "send_remote", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L752-L781
232,751
getsentry/raven-python
raven/base.py
Client.captureQuery
def captureQuery(self, query, params=(), engine=None, **kwargs): """ Creates an event for a SQL query. >>> client.captureQuery('SELECT * FROM foo') """ return self.capture( 'raven.events.Query', query=query, params=params, engine=engine, **kwargs)
python
def captureQuery(self, query, params=(), engine=None, **kwargs): """ Creates an event for a SQL query. >>> client.captureQuery('SELECT * FROM foo') """ return self.capture( 'raven.events.Query', query=query, params=params, engine=engine, **kwargs)
[ "def", "captureQuery", "(", "self", ",", "query", ",", "params", "=", "(", ")", ",", "engine", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "capture", "(", "'raven.events.Query'", ",", "query", "=", "query", ",", "params", "...
Creates an event for a SQL query. >>> client.captureQuery('SELECT * FROM foo')
[ "Creates", "an", "event", "for", "a", "SQL", "query", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L892-L900
232,752
getsentry/raven-python
raven/base.py
Client.captureBreadcrumb
def captureBreadcrumb(self, *args, **kwargs): """ Records a breadcrumb with the current context. They will be sent with the next event. """ # Note: framework integration should not call this method but # instead use the raven.breadcrumbs.record_breadcrumb function ...
python
def captureBreadcrumb(self, *args, **kwargs): """ Records a breadcrumb with the current context. They will be sent with the next event. """ # Note: framework integration should not call this method but # instead use the raven.breadcrumbs.record_breadcrumb function ...
[ "def", "captureBreadcrumb", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Note: framework integration should not call this method but", "# instead use the raven.breadcrumbs.record_breadcrumb function", "# which will record to the correct client automatically.", ...
Records a breadcrumb with the current context. They will be sent with the next event.
[ "Records", "a", "breadcrumb", "with", "the", "current", "context", ".", "They", "will", "be", "sent", "with", "the", "next", "event", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L908-L916
232,753
getsentry/raven-python
raven/transport/registry.py
TransportRegistry.register_scheme
def register_scheme(self, scheme, cls): """ It is possible to inject new schemes at runtime """ if scheme in self._schemes: raise DuplicateScheme() urlparse.register_scheme(scheme) # TODO (vng): verify the interface of the new class self._schemes[sche...
python
def register_scheme(self, scheme, cls): """ It is possible to inject new schemes at runtime """ if scheme in self._schemes: raise DuplicateScheme() urlparse.register_scheme(scheme) # TODO (vng): verify the interface of the new class self._schemes[sche...
[ "def", "register_scheme", "(", "self", ",", "scheme", ",", "cls", ")", ":", "if", "scheme", "in", "self", ".", "_schemes", ":", "raise", "DuplicateScheme", "(", ")", "urlparse", ".", "register_scheme", "(", "scheme", ")", "# TODO (vng): verify the interface of t...
It is possible to inject new schemes at runtime
[ "It", "is", "possible", "to", "inject", "new", "schemes", "at", "runtime" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/transport/registry.py#L40-L49
232,754
getsentry/raven-python
raven/contrib/flask.py
Sentry.get_http_info
def get_http_info(self, request): """ Determine how to retrieve actual data by using request.mimetype. """ if self.is_json_type(request.mimetype): retriever = self.get_json_data else: retriever = self.get_form_data return self.get_http_info_with_re...
python
def get_http_info(self, request): """ Determine how to retrieve actual data by using request.mimetype. """ if self.is_json_type(request.mimetype): retriever = self.get_json_data else: retriever = self.get_form_data return self.get_http_info_with_re...
[ "def", "get_http_info", "(", "self", ",", "request", ")", ":", "if", "self", ".", "is_json_type", "(", "request", ".", "mimetype", ")", ":", "retriever", "=", "self", ".", "get_json_data", "else", ":", "retriever", "=", "self", ".", "get_form_data", "retur...
Determine how to retrieve actual data by using request.mimetype.
[ "Determine", "how", "to", "retrieve", "actual", "data", "by", "using", "request", ".", "mimetype", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/flask.py#L194-L202
232,755
getsentry/raven-python
raven/conf/__init__.py
setup_logging
def setup_logging(handler, exclude=EXCLUDE_LOGGER_DEFAULTS): """ Configures logging to pipe to Sentry. - ``exclude`` is a list of loggers that shouldn't go to Sentry. For a typical Python install: >>> from raven.handlers.logging import SentryHandler >>> client = Sentry(...) >>> setup_logg...
python
def setup_logging(handler, exclude=EXCLUDE_LOGGER_DEFAULTS): """ Configures logging to pipe to Sentry. - ``exclude`` is a list of loggers that shouldn't go to Sentry. For a typical Python install: >>> from raven.handlers.logging import SentryHandler >>> client = Sentry(...) >>> setup_logg...
[ "def", "setup_logging", "(", "handler", ",", "exclude", "=", "EXCLUDE_LOGGER_DEFAULTS", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "if", "handler", ".", "__class__", "in", "map", "(", "type", ",", "logger", ".", "handlers", ")", ":", ...
Configures logging to pipe to Sentry. - ``exclude`` is a list of loggers that shouldn't go to Sentry. For a typical Python install: >>> from raven.handlers.logging import SentryHandler >>> client = Sentry(...) >>> setup_logging(SentryHandler(client)) Within Django: >>> from raven.contri...
[ "Configures", "logging", "to", "pipe", "to", "Sentry", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/conf/__init__.py#L26-L57
232,756
getsentry/raven-python
raven/utils/stacks.py
to_dict
def to_dict(dictish): """ Given something that closely resembles a dictionary, we attempt to coerce it into a propery dictionary. """ if hasattr(dictish, 'iterkeys'): m = dictish.iterkeys elif hasattr(dictish, 'keys'): m = dictish.keys else: raise ValueError(dictish) ...
python
def to_dict(dictish): """ Given something that closely resembles a dictionary, we attempt to coerce it into a propery dictionary. """ if hasattr(dictish, 'iterkeys'): m = dictish.iterkeys elif hasattr(dictish, 'keys'): m = dictish.keys else: raise ValueError(dictish) ...
[ "def", "to_dict", "(", "dictish", ")", ":", "if", "hasattr", "(", "dictish", ",", "'iterkeys'", ")", ":", "m", "=", "dictish", ".", "iterkeys", "elif", "hasattr", "(", "dictish", ",", "'keys'", ")", ":", "m", "=", "dictish", ".", "keys", "else", ":",...
Given something that closely resembles a dictionary, we attempt to coerce it into a propery dictionary.
[ "Given", "something", "that", "closely", "resembles", "a", "dictionary", "we", "attempt", "to", "coerce", "it", "into", "a", "propery", "dictionary", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/stacks.py#L96-L108
232,757
getsentry/raven-python
raven/utils/stacks.py
slim_frame_data
def slim_frame_data(frames, frame_allowance=25): """ Removes various excess metadata from middle frames which go beyond ``frame_allowance``. Returns ``frames``. """ frames_len = 0 app_frames = [] system_frames = [] for frame in frames: frames_len += 1 if frame.get('i...
python
def slim_frame_data(frames, frame_allowance=25): """ Removes various excess metadata from middle frames which go beyond ``frame_allowance``. Returns ``frames``. """ frames_len = 0 app_frames = [] system_frames = [] for frame in frames: frames_len += 1 if frame.get('i...
[ "def", "slim_frame_data", "(", "frames", ",", "frame_allowance", "=", "25", ")", ":", "frames_len", "=", "0", "app_frames", "=", "[", "]", "system_frames", "=", "[", "]", "for", "frame", "in", "frames", ":", "frames_len", "+=", "1", "if", "frame", ".", ...
Removes various excess metadata from middle frames which go beyond ``frame_allowance``. Returns ``frames``.
[ "Removes", "various", "excess", "metadata", "from", "middle", "frames", "which", "go", "beyond", "frame_allowance", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/stacks.py#L167-L215
232,758
getsentry/raven-python
raven/contrib/webpy/utils.py
get_data_from_request
def get_data_from_request(): """Returns request data extracted from web.ctx.""" return { 'request': { 'url': '%s://%s%s' % (web.ctx['protocol'], web.ctx['host'], web.ctx['path']), 'query_string': web.ctx.query, 'method': web.ctx.method, 'data': web.data(),...
python
def get_data_from_request(): """Returns request data extracted from web.ctx.""" return { 'request': { 'url': '%s://%s%s' % (web.ctx['protocol'], web.ctx['host'], web.ctx['path']), 'query_string': web.ctx.query, 'method': web.ctx.method, 'data': web.data(),...
[ "def", "get_data_from_request", "(", ")", ":", "return", "{", "'request'", ":", "{", "'url'", ":", "'%s://%s%s'", "%", "(", "web", ".", "ctx", "[", "'protocol'", "]", ",", "web", ".", "ctx", "[", "'host'", "]", ",", "web", ".", "ctx", "[", "'path'", ...
Returns request data extracted from web.ctx.
[ "Returns", "request", "data", "extracted", "from", "web", ".", "ctx", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/webpy/utils.py#L15-L26
232,759
getsentry/raven-python
raven/contrib/django/resolver.py
get_regex
def get_regex(resolver_or_pattern): """Utility method for django's deprecated resolver.regex""" try: regex = resolver_or_pattern.regex except AttributeError: regex = resolver_or_pattern.pattern.regex return regex
python
def get_regex(resolver_or_pattern): """Utility method for django's deprecated resolver.regex""" try: regex = resolver_or_pattern.regex except AttributeError: regex = resolver_or_pattern.pattern.regex return regex
[ "def", "get_regex", "(", "resolver_or_pattern", ")", ":", "try", ":", "regex", "=", "resolver_or_pattern", ".", "regex", "except", "AttributeError", ":", "regex", "=", "resolver_or_pattern", ".", "pattern", ".", "regex", "return", "regex" ]
Utility method for django's deprecated resolver.regex
[ "Utility", "method", "for", "django", "s", "deprecated", "resolver", ".", "regex" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/resolver.py#L11-L17
232,760
getsentry/raven-python
raven/utils/basic.py
once
def once(func): """Runs a thing once and once only.""" lock = threading.Lock() def new_func(*args, **kwargs): if new_func.called: return with lock: if new_func.called: return rv = func(*args, **kwargs) new_func.called = True ...
python
def once(func): """Runs a thing once and once only.""" lock = threading.Lock() def new_func(*args, **kwargs): if new_func.called: return with lock: if new_func.called: return rv = func(*args, **kwargs) new_func.called = True ...
[ "def", "once", "(", "func", ")", ":", "lock", "=", "threading", ".", "Lock", "(", ")", "def", "new_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "new_func", ".", "called", ":", "return", "with", "lock", ":", "if", "new_func", ...
Runs a thing once and once only.
[ "Runs", "a", "thing", "once", "and", "once", "only", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/utils/basic.py#L75-L91
232,761
getsentry/raven-python
raven/contrib/django/utils.py
get_host
def get_host(request): """ A reimplementation of Django's get_host, without the SuspiciousOperation check. """ # We try three options, in order of decreasing preference. if settings.USE_X_FORWARDED_HOST and ( 'HTTP_X_FORWARDED_HOST' in request.META): host = request.META['HTTP...
python
def get_host(request): """ A reimplementation of Django's get_host, without the SuspiciousOperation check. """ # We try three options, in order of decreasing preference. if settings.USE_X_FORWARDED_HOST and ( 'HTTP_X_FORWARDED_HOST' in request.META): host = request.META['HTTP...
[ "def", "get_host", "(", "request", ")", ":", "# We try three options, in order of decreasing preference.", "if", "settings", ".", "USE_X_FORWARDED_HOST", "and", "(", "'HTTP_X_FORWARDED_HOST'", "in", "request", ".", "META", ")", ":", "host", "=", "request", ".", "META"...
A reimplementation of Django's get_host, without the SuspiciousOperation check.
[ "A", "reimplementation", "of", "Django", "s", "get_host", "without", "the", "SuspiciousOperation", "check", "." ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/utils.py#L84-L101
232,762
getsentry/raven-python
raven/contrib/django/models.py
install_middleware
def install_middleware(middleware_name, lookup_names=None): """ Install specified middleware """ if lookup_names is None: lookup_names = (middleware_name,) # default settings.MIDDLEWARE is None middleware_attr = 'MIDDLEWARE' if getattr(settings, ...
python
def install_middleware(middleware_name, lookup_names=None): """ Install specified middleware """ if lookup_names is None: lookup_names = (middleware_name,) # default settings.MIDDLEWARE is None middleware_attr = 'MIDDLEWARE' if getattr(settings, ...
[ "def", "install_middleware", "(", "middleware_name", ",", "lookup_names", "=", "None", ")", ":", "if", "lookup_names", "is", "None", ":", "lookup_names", "=", "(", "middleware_name", ",", ")", "# default settings.MIDDLEWARE is None", "middleware_attr", "=", "'MIDDLEWA...
Install specified middleware
[ "Install", "specified", "middleware" ]
d891c20f0f930153f508e9d698d9de42e910face
https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/contrib/django/models.py#L222-L238
232,763
sebp/scikit-survival
sksurv/meta/base.py
_fit_and_score
def _fit_and_score(est, x, y, scorer, train_index, test_index, parameters, fit_params, predict_params): """Train survival model on given data and return its score on test data""" X_train, y_train = _safe_split(est, x, y, train_index) train_params = fit_params.copy() # Training est.set_params(**para...
python
def _fit_and_score(est, x, y, scorer, train_index, test_index, parameters, fit_params, predict_params): """Train survival model on given data and return its score on test data""" X_train, y_train = _safe_split(est, x, y, train_index) train_params = fit_params.copy() # Training est.set_params(**para...
[ "def", "_fit_and_score", "(", "est", ",", "x", ",", "y", ",", "scorer", ",", "train_index", ",", "test_index", ",", "parameters", ",", "fit_params", ",", "predict_params", ")", ":", "X_train", ",", "y_train", "=", "_safe_split", "(", "est", ",", "x", ","...
Train survival model on given data and return its score on test data
[ "Train", "survival", "model", "on", "given", "data", "and", "return", "its", "score", "on", "test", "data" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/base.py#L17-L35
232,764
sebp/scikit-survival
sksurv/linear_model/coxnet.py
CoxnetSurvivalAnalysis._interpolate_coefficients
def _interpolate_coefficients(self, alpha): """Interpolate coefficients by calculating the weighted average of coefficient vectors corresponding to neighbors of alpha in the list of alphas constructed during training.""" exact = False coef_idx = None for i, val in enumerate(self....
python
def _interpolate_coefficients(self, alpha): """Interpolate coefficients by calculating the weighted average of coefficient vectors corresponding to neighbors of alpha in the list of alphas constructed during training.""" exact = False coef_idx = None for i, val in enumerate(self....
[ "def", "_interpolate_coefficients", "(", "self", ",", "alpha", ")", ":", "exact", "=", "False", "coef_idx", "=", "None", "for", "i", ",", "val", "in", "enumerate", "(", "self", ".", "alphas_", ")", ":", "if", "val", ">", "alpha", ":", "coef_idx", "=", ...
Interpolate coefficients by calculating the weighted average of coefficient vectors corresponding to neighbors of alpha in the list of alphas constructed during training.
[ "Interpolate", "coefficients", "by", "calculating", "the", "weighted", "average", "of", "coefficient", "vectors", "corresponding", "to", "neighbors", "of", "alpha", "in", "the", "list", "of", "alphas", "constructed", "during", "training", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxnet.py#L239-L263
232,765
sebp/scikit-survival
sksurv/linear_model/coxnet.py
CoxnetSurvivalAnalysis.predict
def predict(self, X, alpha=None): """The linear predictor of the model. Parameters ---------- X : array-like, shape = (n_samples, n_features) Test data of which to calculate log-likelihood from alpha : float, optional Constant that multiplies the penalty...
python
def predict(self, X, alpha=None): """The linear predictor of the model. Parameters ---------- X : array-like, shape = (n_samples, n_features) Test data of which to calculate log-likelihood from alpha : float, optional Constant that multiplies the penalty...
[ "def", "predict", "(", "self", ",", "X", ",", "alpha", "=", "None", ")", ":", "X", "=", "check_array", "(", "X", ")", "coef", "=", "self", ".", "_get_coef", "(", "alpha", ")", "return", "numpy", ".", "dot", "(", "X", ",", "coef", ")" ]
The linear predictor of the model. Parameters ---------- X : array-like, shape = (n_samples, n_features) Test data of which to calculate log-likelihood from alpha : float, optional Constant that multiplies the penalty terms. If the same alpha was used during tra...
[ "The", "linear", "predictor", "of", "the", "model", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxnet.py#L265-L285
232,766
sebp/scikit-survival
sksurv/meta/ensemble_selection.py
BaseEnsembleSelection._create_base_ensemble
def _create_base_ensemble(self, out, n_estimators, n_folds): """For each base estimator collect models trained on each fold""" ensemble_scores = numpy.empty((n_estimators, n_folds)) base_ensemble = numpy.empty_like(ensemble_scores, dtype=numpy.object) for model, fold, score, est in out: ...
python
def _create_base_ensemble(self, out, n_estimators, n_folds): """For each base estimator collect models trained on each fold""" ensemble_scores = numpy.empty((n_estimators, n_folds)) base_ensemble = numpy.empty_like(ensemble_scores, dtype=numpy.object) for model, fold, score, est in out: ...
[ "def", "_create_base_ensemble", "(", "self", ",", "out", ",", "n_estimators", ",", "n_folds", ")", ":", "ensemble_scores", "=", "numpy", ".", "empty", "(", "(", "n_estimators", ",", "n_folds", ")", ")", "base_ensemble", "=", "numpy", ".", "empty_like", "(", ...
For each base estimator collect models trained on each fold
[ "For", "each", "base", "estimator", "collect", "models", "trained", "on", "each", "fold" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L152-L160
232,767
sebp/scikit-survival
sksurv/meta/ensemble_selection.py
BaseEnsembleSelection._create_cv_ensemble
def _create_cv_ensemble(self, base_ensemble, idx_models_included, model_names=None): """For each selected base estimator, average models trained on each fold""" fitted_models = numpy.empty(len(idx_models_included), dtype=numpy.object) for i, idx in enumerate(idx_models_included): mod...
python
def _create_cv_ensemble(self, base_ensemble, idx_models_included, model_names=None): """For each selected base estimator, average models trained on each fold""" fitted_models = numpy.empty(len(idx_models_included), dtype=numpy.object) for i, idx in enumerate(idx_models_included): mod...
[ "def", "_create_cv_ensemble", "(", "self", ",", "base_ensemble", ",", "idx_models_included", ",", "model_names", "=", "None", ")", ":", "fitted_models", "=", "numpy", ".", "empty", "(", "len", "(", "idx_models_included", ")", ",", "dtype", "=", "numpy", ".", ...
For each selected base estimator, average models trained on each fold
[ "For", "each", "selected", "base", "estimator", "average", "models", "trained", "on", "each", "fold" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L162-L170
232,768
sebp/scikit-survival
sksurv/meta/ensemble_selection.py
BaseEnsembleSelection._get_base_estimators
def _get_base_estimators(self, X): """Takes special care of estimators using custom kernel function Parameters ---------- X : array, shape = (n_samples, n_features) Samples to pre-compute kernel matrix from. Returns ------- base_estimators : list ...
python
def _get_base_estimators(self, X): """Takes special care of estimators using custom kernel function Parameters ---------- X : array, shape = (n_samples, n_features) Samples to pre-compute kernel matrix from. Returns ------- base_estimators : list ...
[ "def", "_get_base_estimators", "(", "self", ",", "X", ")", ":", "base_estimators", "=", "[", "]", "kernel_cache", "=", "{", "}", "kernel_fns", "=", "{", "}", "for", "i", ",", "(", "name", ",", "estimator", ")", "in", "enumerate", "(", "self", ".", "b...
Takes special care of estimators using custom kernel function Parameters ---------- X : array, shape = (n_samples, n_features) Samples to pre-compute kernel matrix from. Returns ------- base_estimators : list Same as `self.base_estimators`, expec...
[ "Takes", "special", "care", "of", "estimators", "using", "custom", "kernel", "function" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L172-L214
232,769
sebp/scikit-survival
sksurv/meta/ensemble_selection.py
BaseEnsembleSelection._restore_base_estimators
def _restore_base_estimators(self, kernel_cache, out, X, cv): """Restore custom kernel functions of estimators for predictions""" train_folds = {fold: train_index for fold, (train_index, _) in enumerate(cv)} for idx, fold, _, est in out: if idx in kernel_cache: if no...
python
def _restore_base_estimators(self, kernel_cache, out, X, cv): """Restore custom kernel functions of estimators for predictions""" train_folds = {fold: train_index for fold, (train_index, _) in enumerate(cv)} for idx, fold, _, est in out: if idx in kernel_cache: if no...
[ "def", "_restore_base_estimators", "(", "self", ",", "kernel_cache", ",", "out", ",", "X", ",", "cv", ")", ":", "train_folds", "=", "{", "fold", ":", "train_index", "for", "fold", ",", "(", "train_index", ",", "_", ")", "in", "enumerate", "(", "cv", ")...
Restore custom kernel functions of estimators for predictions
[ "Restore", "custom", "kernel", "functions", "of", "estimators", "for", "predictions" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L216-L230
232,770
sebp/scikit-survival
sksurv/meta/ensemble_selection.py
BaseEnsembleSelection._fit_and_score_ensemble
def _fit_and_score_ensemble(self, X, y, cv, **fit_params): """Create a cross-validated model by training a model for each fold with the same model parameters""" fit_params_steps = self._split_fit_params(fit_params) folds = list(cv.split(X, y)) # Take care of custom kernel functions ...
python
def _fit_and_score_ensemble(self, X, y, cv, **fit_params): """Create a cross-validated model by training a model for each fold with the same model parameters""" fit_params_steps = self._split_fit_params(fit_params) folds = list(cv.split(X, y)) # Take care of custom kernel functions ...
[ "def", "_fit_and_score_ensemble", "(", "self", ",", "X", ",", "y", ",", "cv", ",", "*", "*", "fit_params", ")", ":", "fit_params_steps", "=", "self", ".", "_split_fit_params", "(", "fit_params", ")", "folds", "=", "list", "(", "cv", ".", "split", "(", ...
Create a cross-validated model by training a model for each fold with the same model parameters
[ "Create", "a", "cross", "-", "validated", "model", "by", "training", "a", "model", "for", "each", "fold", "with", "the", "same", "model", "parameters" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L232-L257
232,771
sebp/scikit-survival
sksurv/meta/ensemble_selection.py
BaseEnsembleSelection.fit
def fit(self, X, y=None, **fit_params): """Fit ensemble of models Parameters ---------- X : array-like, shape = (n_samples, n_features) Training data. y : array-like, optional Target data if base estimators are supervised. Returns ------...
python
def fit(self, X, y=None, **fit_params): """Fit ensemble of models Parameters ---------- X : array-like, shape = (n_samples, n_features) Training data. y : array-like, optional Target data if base estimators are supervised. Returns ------...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ",", "*", "*", "fit_params", ")", ":", "self", ".", "_check_params", "(", ")", "cv", "=", "check_cv", "(", "self", ".", "cv", ",", "X", ")", "self", ".", "_fit", "(", "X", ",", "y", ...
Fit ensemble of models Parameters ---------- X : array-like, shape = (n_samples, n_features) Training data. y : array-like, optional Target data if base estimators are supervised. Returns ------- self
[ "Fit", "ensemble", "of", "models" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/ensemble_selection.py#L277-L297
232,772
sebp/scikit-survival
sksurv/io/arffwrite.py
writearff
def writearff(data, filename, relation_name=None, index=True): """Write ARFF file Parameters ---------- data : :class:`pandas.DataFrame` DataFrame containing data filename : string or file-like object Path to ARFF file or file-like object. In the latter case, the handle is ...
python
def writearff(data, filename, relation_name=None, index=True): """Write ARFF file Parameters ---------- data : :class:`pandas.DataFrame` DataFrame containing data filename : string or file-like object Path to ARFF file or file-like object. In the latter case, the handle is ...
[ "def", "writearff", "(", "data", ",", "filename", ",", "relation_name", "=", "None", ",", "index", "=", "True", ")", ":", "if", "isinstance", "(", "filename", ",", "str", ")", ":", "fp", "=", "open", "(", "filename", ",", "'w'", ")", "if", "relation_...
Write ARFF file Parameters ---------- data : :class:`pandas.DataFrame` DataFrame containing data filename : string or file-like object Path to ARFF file or file-like object. In the latter case, the handle is closed by calling this function. relation_name : string, optional...
[ "Write", "ARFF", "file" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L23-L57
232,773
sebp/scikit-survival
sksurv/io/arffwrite.py
_write_header
def _write_header(data, fp, relation_name, index): """Write header containing attribute names and types""" fp.write("@relation {0}\n\n".format(relation_name)) if index: data = data.reset_index() attribute_names = _sanitize_column_names(data) for column, series in data.iteritems(): ...
python
def _write_header(data, fp, relation_name, index): """Write header containing attribute names and types""" fp.write("@relation {0}\n\n".format(relation_name)) if index: data = data.reset_index() attribute_names = _sanitize_column_names(data) for column, series in data.iteritems(): ...
[ "def", "_write_header", "(", "data", ",", "fp", ",", "relation_name", ",", "index", ")", ":", "fp", ".", "write", "(", "\"@relation {0}\\n\\n\"", ".", "format", "(", "relation_name", ")", ")", "if", "index", ":", "data", "=", "data", ".", "reset_index", ...
Write header containing attribute names and types
[ "Write", "header", "containing", "attribute", "names", "and", "types" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L60-L85
232,774
sebp/scikit-survival
sksurv/io/arffwrite.py
_sanitize_column_names
def _sanitize_column_names(data): """Replace illegal characters with underscore""" new_names = {} for name in data.columns: new_names[name] = _ILLEGAL_CHARACTER_PAT.sub("_", name) return new_names
python
def _sanitize_column_names(data): """Replace illegal characters with underscore""" new_names = {} for name in data.columns: new_names[name] = _ILLEGAL_CHARACTER_PAT.sub("_", name) return new_names
[ "def", "_sanitize_column_names", "(", "data", ")", ":", "new_names", "=", "{", "}", "for", "name", "in", "data", ".", "columns", ":", "new_names", "[", "name", "]", "=", "_ILLEGAL_CHARACTER_PAT", ".", "sub", "(", "\"_\"", ",", "name", ")", "return", "new...
Replace illegal characters with underscore
[ "Replace", "illegal", "characters", "with", "underscore" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L88-L93
232,775
sebp/scikit-survival
sksurv/io/arffwrite.py
_write_data
def _write_data(data, fp): """Write the data section""" fp.write("@data\n") def to_str(x): if pandas.isnull(x): return '?' else: return str(x) data = data.applymap(to_str) n_rows = data.shape[0] for i in range(n_rows): str_values = list(data.iloc...
python
def _write_data(data, fp): """Write the data section""" fp.write("@data\n") def to_str(x): if pandas.isnull(x): return '?' else: return str(x) data = data.applymap(to_str) n_rows = data.shape[0] for i in range(n_rows): str_values = list(data.iloc...
[ "def", "_write_data", "(", "data", ",", "fp", ")", ":", "fp", ".", "write", "(", "\"@data\\n\"", ")", "def", "to_str", "(", "x", ")", ":", "if", "pandas", ".", "isnull", "(", "x", ")", ":", "return", "'?'", "else", ":", "return", "str", "(", "x",...
Write the data section
[ "Write", "the", "data", "section" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/io/arffwrite.py#L130-L146
232,776
sebp/scikit-survival
sksurv/meta/stacking.py
Stacking.fit
def fit(self, X, y=None, **fit_params): """Fit base estimators. Parameters ---------- X : array-like, shape = (n_samples, n_features) Training data. y : array-like, optional Target data if base estimators are supervised. Returns ------- ...
python
def fit(self, X, y=None, **fit_params): """Fit base estimators. Parameters ---------- X : array-like, shape = (n_samples, n_features) Training data. y : array-like, optional Target data if base estimators are supervised. Returns ------- ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ",", "*", "*", "fit_params", ")", ":", "X", "=", "numpy", ".", "asarray", "(", "X", ")", "self", ".", "_fit_estimators", "(", "X", ",", "y", ",", "*", "*", "fit_params", ")", "Xt", "...
Fit base estimators. Parameters ---------- X : array-like, shape = (n_samples, n_features) Training data. y : array-like, optional Target data if base estimators are supervised. Returns ------- self
[ "Fit", "base", "estimators", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/meta/stacking.py#L115-L135
232,777
sebp/scikit-survival
sksurv/column.py
standardize
def standardize(table, with_std=True): """ Perform Z-Normalization on each numeric column of the given table. Parameters ---------- table : pandas.DataFrame or numpy.ndarray Data to standardize. with_std : bool, optional, default: True If ``False`` data is only centered and not...
python
def standardize(table, with_std=True): """ Perform Z-Normalization on each numeric column of the given table. Parameters ---------- table : pandas.DataFrame or numpy.ndarray Data to standardize. with_std : bool, optional, default: True If ``False`` data is only centered and not...
[ "def", "standardize", "(", "table", ",", "with_std", "=", "True", ")", ":", "if", "isinstance", "(", "table", ",", "pandas", ".", "DataFrame", ")", ":", "cat_columns", "=", "table", ".", "select_dtypes", "(", "include", "=", "[", "'category'", "]", ")", ...
Perform Z-Normalization on each numeric column of the given table. Parameters ---------- table : pandas.DataFrame or numpy.ndarray Data to standardize. with_std : bool, optional, default: True If ``False`` data is only centered and not converted to unit variance. Returns -----...
[ "Perform", "Z", "-", "Normalization", "on", "each", "numeric", "column", "of", "the", "given", "table", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/column.py#L47-L77
232,778
sebp/scikit-survival
sksurv/column.py
encode_categorical
def encode_categorical(table, columns=None, **kwargs): """ Encode categorical columns with `M` categories into `M-1` columns according to the one-hot scheme. Parameters ---------- table : pandas.DataFrame Table with categorical columns to encode. columns : list-like, optional, defa...
python
def encode_categorical(table, columns=None, **kwargs): """ Encode categorical columns with `M` categories into `M-1` columns according to the one-hot scheme. Parameters ---------- table : pandas.DataFrame Table with categorical columns to encode. columns : list-like, optional, defa...
[ "def", "encode_categorical", "(", "table", ",", "columns", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "table", ",", "pandas", ".", "Series", ")", ":", "if", "not", "is_categorical_dtype", "(", "table", ".", "dtype", ")", "...
Encode categorical columns with `M` categories into `M-1` columns according to the one-hot scheme. Parameters ---------- table : pandas.DataFrame Table with categorical columns to encode. columns : list-like, optional, default: None Column names in the DataFrame to be encoded. ...
[ "Encode", "categorical", "columns", "with", "M", "categories", "into", "M", "-", "1", "columns", "according", "to", "the", "one", "-", "hot", "scheme", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/column.py#L97-L146
232,779
sebp/scikit-survival
sksurv/column.py
categorical_to_numeric
def categorical_to_numeric(table): """Encode categorical columns to numeric by converting each category to an integer value. Parameters ---------- table : pandas.DataFrame Table with categorical columns to encode. Returns ------- encoded : pandas.DataFrame Table with ca...
python
def categorical_to_numeric(table): """Encode categorical columns to numeric by converting each category to an integer value. Parameters ---------- table : pandas.DataFrame Table with categorical columns to encode. Returns ------- encoded : pandas.DataFrame Table with ca...
[ "def", "categorical_to_numeric", "(", "table", ")", ":", "def", "transform", "(", "column", ")", ":", "if", "is_categorical_dtype", "(", "column", ".", "dtype", ")", ":", "return", "column", ".", "cat", ".", "codes", "if", "column", ".", "dtype", ".", "c...
Encode categorical columns to numeric by converting each category to an integer value. Parameters ---------- table : pandas.DataFrame Table with categorical columns to encode. Returns ------- encoded : pandas.DataFrame Table with categorical columns encoded as numeric. ...
[ "Encode", "categorical", "columns", "to", "numeric", "by", "converting", "each", "category", "to", "an", "integer", "value", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/column.py#L171-L208
232,780
sebp/scikit-survival
sksurv/util.py
check_y_survival
def check_y_survival(y_or_event, *args, allow_all_censored=False): """Check that array correctly represents an outcome for survival analysis. Parameters ---------- y_or_event : structured array with two fields, or boolean array If a structured array, it must contain the binary event indicator ...
python
def check_y_survival(y_or_event, *args, allow_all_censored=False): """Check that array correctly represents an outcome for survival analysis. Parameters ---------- y_or_event : structured array with two fields, or boolean array If a structured array, it must contain the binary event indicator ...
[ "def", "check_y_survival", "(", "y_or_event", ",", "*", "args", ",", "allow_all_censored", "=", "False", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "y", "=", "y_or_event", "if", "not", "isinstance", "(", "y", ",", "numpy", ".", "ndarray",...
Check that array correctly represents an outcome for survival analysis. Parameters ---------- y_or_event : structured array with two fields, or boolean array If a structured array, it must contain the binary event indicator as first field, and time of event or time of censoring as s...
[ "Check", "that", "array", "correctly", "represents", "an", "outcome", "for", "survival", "analysis", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L104-L164
232,781
sebp/scikit-survival
sksurv/util.py
check_arrays_survival
def check_arrays_survival(X, y, **kwargs): """Check that all arrays have consistent first dimensions. Parameters ---------- X : array-like Data matrix containing feature vectors. y : structured array with two fields A structured array containing the binary event indicator a...
python
def check_arrays_survival(X, y, **kwargs): """Check that all arrays have consistent first dimensions. Parameters ---------- X : array-like Data matrix containing feature vectors. y : structured array with two fields A structured array containing the binary event indicator a...
[ "def", "check_arrays_survival", "(", "X", ",", "y", ",", "*", "*", "kwargs", ")", ":", "event", ",", "time", "=", "check_y_survival", "(", "y", ")", "kwargs", ".", "setdefault", "(", "\"dtype\"", ",", "numpy", ".", "float64", ")", "X", "=", "check_arra...
Check that all arrays have consistent first dimensions. Parameters ---------- X : array-like Data matrix containing feature vectors. y : structured array with two fields A structured array containing the binary event indicator as first field, and time of event or time of censor...
[ "Check", "that", "all", "arrays", "have", "consistent", "first", "dimensions", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L167-L198
232,782
sebp/scikit-survival
sksurv/util.py
Surv.from_arrays
def from_arrays(event, time, name_event=None, name_time=None): """Create structured array. Parameters ---------- event : array-like Event indicator. A boolean array or array with values 0/1. time : array-like Observed time. name_event : str|None ...
python
def from_arrays(event, time, name_event=None, name_time=None): """Create structured array. Parameters ---------- event : array-like Event indicator. A boolean array or array with values 0/1. time : array-like Observed time. name_event : str|None ...
[ "def", "from_arrays", "(", "event", ",", "time", ",", "name_event", "=", "None", ",", "name_time", "=", "None", ")", ":", "name_event", "=", "name_event", "or", "'event'", "name_time", "=", "name_time", "or", "'time'", "if", "name_time", "==", "name_event", ...
Create structured array. Parameters ---------- event : array-like Event indicator. A boolean array or array with values 0/1. time : array-like Observed time. name_event : str|None Name of event, optional, default: 'event' name_time : s...
[ "Create", "structured", "array", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L28-L73
232,783
sebp/scikit-survival
sksurv/util.py
Surv.from_dataframe
def from_dataframe(event, time, data): """Create structured array from data frame. Parameters ---------- event : object Identifier of column containing event indicator. time : object Identifier of column containing time. data : pandas.DataFrame ...
python
def from_dataframe(event, time, data): """Create structured array from data frame. Parameters ---------- event : object Identifier of column containing event indicator. time : object Identifier of column containing time. data : pandas.DataFrame ...
[ "def", "from_dataframe", "(", "event", ",", "time", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "pandas", ".", "DataFrame", ")", ":", "raise", "TypeError", "(", "\"exepected pandas.DataFrame, but got {!r}\"", ".", "format", "(", "type",...
Create structured array from data frame. Parameters ---------- event : object Identifier of column containing event indicator. time : object Identifier of column containing time. data : pandas.DataFrame Dataset. Returns ------...
[ "Create", "structured", "array", "from", "data", "frame", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/util.py#L76-L101
232,784
sebp/scikit-survival
sksurv/ensemble/survival_loss.py
CoxPH.update_terminal_regions
def update_terminal_regions(self, tree, X, y, residual, y_pred, sample_weight, sample_mask, learning_rate=1.0, k=0): """Least squares does not need to update terminal regions. But it has to update the predictions. """ # upd...
python
def update_terminal_regions(self, tree, X, y, residual, y_pred, sample_weight, sample_mask, learning_rate=1.0, k=0): """Least squares does not need to update terminal regions. But it has to update the predictions. """ # upd...
[ "def", "update_terminal_regions", "(", "self", ",", "tree", ",", "X", ",", "y", ",", "residual", ",", "y_pred", ",", "sample_weight", ",", "sample_mask", ",", "learning_rate", "=", "1.0", ",", "k", "=", "0", ")", ":", "# update predictions", "y_pred", "[",...
Least squares does not need to update terminal regions. But it has to update the predictions.
[ "Least", "squares", "does", "not", "need", "to", "update", "terminal", "regions", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/ensemble/survival_loss.py#L55-L63
232,785
sebp/scikit-survival
sksurv/setup.py
build_from_c_and_cpp_files
def build_from_c_and_cpp_files(extensions): """Modify the extensions to build from the .c and .cpp files. This is useful for releases, this way cython is not required to run python setup.py install. """ for extension in extensions: sources = [] for sfile in extension.sources: ...
python
def build_from_c_and_cpp_files(extensions): """Modify the extensions to build from the .c and .cpp files. This is useful for releases, this way cython is not required to run python setup.py install. """ for extension in extensions: sources = [] for sfile in extension.sources: ...
[ "def", "build_from_c_and_cpp_files", "(", "extensions", ")", ":", "for", "extension", "in", "extensions", ":", "sources", "=", "[", "]", "for", "sfile", "in", "extension", ".", "sources", ":", "path", ",", "ext", "=", "os", ".", "path", ".", "splitext", ...
Modify the extensions to build from the .c and .cpp files. This is useful for releases, this way cython is not required to run python setup.py install.
[ "Modify", "the", "extensions", "to", "build", "from", "the", ".", "c", "and", ".", "cpp", "files", ".", "This", "is", "useful", "for", "releases", "this", "way", "cython", "is", "not", "required", "to", "run", "python", "setup", ".", "py", "install", "...
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/setup.py#L20-L36
232,786
sebp/scikit-survival
sksurv/svm/survival_svm.py
SurvivalCounter._count_values
def _count_values(self): """Return dict mapping relevance level to sample index""" indices = {yi: [i] for i, yi in enumerate(self.y) if self.status[i]} return indices
python
def _count_values(self): """Return dict mapping relevance level to sample index""" indices = {yi: [i] for i, yi in enumerate(self.y) if self.status[i]} return indices
[ "def", "_count_values", "(", "self", ")", ":", "indices", "=", "{", "yi", ":", "[", "i", "]", "for", "i", ",", "yi", "in", "enumerate", "(", "self", ".", "y", ")", "if", "self", ".", "status", "[", "i", "]", "}", "return", "indices" ]
Return dict mapping relevance level to sample index
[ "Return", "dict", "mapping", "relevance", "level", "to", "sample", "index" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/svm/survival_svm.py#L134-L138
232,787
sebp/scikit-survival
sksurv/svm/survival_svm.py
BaseSurvivalSVM._create_optimizer
def _create_optimizer(self, X, y, status): """Samples are ordered by relevance""" if self.optimizer is None: self.optimizer = 'avltree' times, ranks = y if self.optimizer == 'simple': optimizer = SimpleOptimizer(X, status, self.alpha, self.rank_ratio, timeit=sel...
python
def _create_optimizer(self, X, y, status): """Samples are ordered by relevance""" if self.optimizer is None: self.optimizer = 'avltree' times, ranks = y if self.optimizer == 'simple': optimizer = SimpleOptimizer(X, status, self.alpha, self.rank_ratio, timeit=sel...
[ "def", "_create_optimizer", "(", "self", ",", "X", ",", "y", ",", "status", ")", ":", "if", "self", ".", "optimizer", "is", "None", ":", "self", ".", "optimizer", "=", "'avltree'", "times", ",", "ranks", "=", "y", "if", "self", ".", "optimizer", "=="...
Samples are ordered by relevance
[ "Samples", "are", "ordered", "by", "relevance" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/svm/survival_svm.py#L608-L633
232,788
sebp/scikit-survival
sksurv/svm/survival_svm.py
BaseSurvivalSVM._argsort_and_resolve_ties
def _argsort_and_resolve_ties(time, random_state): """Like numpy.argsort, but resolves ties uniformly at random""" n_samples = len(time) order = numpy.argsort(time, kind="mergesort") i = 0 while i < n_samples - 1: inext = i + 1 while inext < n_samples and...
python
def _argsort_and_resolve_ties(time, random_state): """Like numpy.argsort, but resolves ties uniformly at random""" n_samples = len(time) order = numpy.argsort(time, kind="mergesort") i = 0 while i < n_samples - 1: inext = i + 1 while inext < n_samples and...
[ "def", "_argsort_and_resolve_ties", "(", "time", ",", "random_state", ")", ":", "n_samples", "=", "len", "(", "time", ")", "order", "=", "numpy", ".", "argsort", "(", "time", ",", "kind", "=", "\"mergesort\"", ")", "i", "=", "0", "while", "i", "<", "n_...
Like numpy.argsort, but resolves ties uniformly at random
[ "Like", "numpy", ".", "argsort", "but", "resolves", "ties", "uniformly", "at", "random" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/svm/survival_svm.py#L702-L717
232,789
sebp/scikit-survival
sksurv/linear_model/aft.py
IPCRidge.fit
def fit(self, X, y): """Build an accelerated failure time model. Parameters ---------- X : array-like, shape = (n_samples, n_features) Data matrix. y : structured array, shape = (n_samples,) A structured array containing the binary event indicator ...
python
def fit(self, X, y): """Build an accelerated failure time model. Parameters ---------- X : array-like, shape = (n_samples, n_features) Data matrix. y : structured array, shape = (n_samples,) A structured array containing the binary event indicator ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", ")", ":", "X", ",", "event", ",", "time", "=", "check_arrays_survival", "(", "X", ",", "y", ")", "weights", "=", "ipc_weights", "(", "event", ",", "time", ")", "super", "(", ")", ".", "fit", "(", "...
Build an accelerated failure time model. Parameters ---------- X : array-like, shape = (n_samples, n_features) Data matrix. y : structured array, shape = (n_samples,) A structured array containing the binary event indicator as first field, and time o...
[ "Build", "an", "accelerated", "failure", "time", "model", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/aft.py#L52-L74
232,790
sebp/scikit-survival
sksurv/linear_model/coxph.py
BreslowEstimator.fit
def fit(self, linear_predictor, event, time): """Compute baseline cumulative hazard function. Parameters ---------- linear_predictor : array-like, shape = (n_samples,) Linear predictor of risk: `X @ coef`. event : array-like, shape = (n_samples,) Contain...
python
def fit(self, linear_predictor, event, time): """Compute baseline cumulative hazard function. Parameters ---------- linear_predictor : array-like, shape = (n_samples,) Linear predictor of risk: `X @ coef`. event : array-like, shape = (n_samples,) Contain...
[ "def", "fit", "(", "self", ",", "linear_predictor", ",", "event", ",", "time", ")", ":", "risk_score", "=", "numpy", ".", "exp", "(", "linear_predictor", ")", "order", "=", "numpy", ".", "argsort", "(", "time", ",", "kind", "=", "\"mergesort\"", ")", "...
Compute baseline cumulative hazard function. Parameters ---------- linear_predictor : array-like, shape = (n_samples,) Linear predictor of risk: `X @ coef`. event : array-like, shape = (n_samples,) Contains binary event indicators. time : array-like, sh...
[ "Compute", "baseline", "cumulative", "hazard", "function", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxph.py#L42-L81
232,791
sebp/scikit-survival
sksurv/linear_model/coxph.py
CoxPHOptimizer.nlog_likelihood
def nlog_likelihood(self, w): """Compute negative partial log-likelihood Parameters ---------- w : array, shape = (n_features,) Estimate of coefficients Returns ------- loss : float Average negative partial log-likelihood """ ...
python
def nlog_likelihood(self, w): """Compute negative partial log-likelihood Parameters ---------- w : array, shape = (n_features,) Estimate of coefficients Returns ------- loss : float Average negative partial log-likelihood """ ...
[ "def", "nlog_likelihood", "(", "self", ",", "w", ")", ":", "time", "=", "self", ".", "time", "n_samples", "=", "self", ".", "x", ".", "shape", "[", "0", "]", "xw", "=", "numpy", ".", "dot", "(", "self", ".", "x", ",", "w", ")", "loss", "=", "...
Compute negative partial log-likelihood Parameters ---------- w : array, shape = (n_features,) Estimate of coefficients Returns ------- loss : float Average negative partial log-likelihood
[ "Compute", "negative", "partial", "log", "-", "likelihood" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxph.py#L138-L168
232,792
sebp/scikit-survival
sksurv/linear_model/coxph.py
CoxPHOptimizer.update
def update(self, w, offset=0): """Compute gradient and Hessian matrix with respect to `w`.""" time = self.time x = self.x exp_xw = numpy.exp(offset + numpy.dot(x, w)) n_samples, n_features = x.shape gradient = numpy.zeros((1, n_features), dtype=float) hessian = n...
python
def update(self, w, offset=0): """Compute gradient and Hessian matrix with respect to `w`.""" time = self.time x = self.x exp_xw = numpy.exp(offset + numpy.dot(x, w)) n_samples, n_features = x.shape gradient = numpy.zeros((1, n_features), dtype=float) hessian = n...
[ "def", "update", "(", "self", ",", "w", ",", "offset", "=", "0", ")", ":", "time", "=", "self", ".", "time", "x", "=", "self", ".", "x", "exp_xw", "=", "numpy", ".", "exp", "(", "offset", "+", "numpy", ".", "dot", "(", "x", ",", "w", ")", "...
Compute gradient and Hessian matrix with respect to `w`.
[ "Compute", "gradient", "and", "Hessian", "matrix", "with", "respect", "to", "w", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxph.py#L170-L218
232,793
sebp/scikit-survival
sksurv/linear_model/coxph.py
CoxPHSurvivalAnalysis.fit
def fit(self, X, y): """Minimize negative partial log-likelihood for provided data. Parameters ---------- X : array-like, shape = (n_samples, n_features) Data matrix y : structured array, shape = (n_samples,) A structured array containing the binary even...
python
def fit(self, X, y): """Minimize negative partial log-likelihood for provided data. Parameters ---------- X : array-like, shape = (n_samples, n_features) Data matrix y : structured array, shape = (n_samples,) A structured array containing the binary even...
[ "def", "fit", "(", "self", ",", "X", ",", "y", ")", ":", "X", ",", "event", ",", "time", "=", "check_arrays_survival", "(", "X", ",", "y", ")", "if", "self", ".", "alpha", "<", "0", ":", "raise", "ValueError", "(", "\"alpha must be positive, but was %r...
Minimize negative partial log-likelihood for provided data. Parameters ---------- X : array-like, shape = (n_samples, n_features) Data matrix y : structured array, shape = (n_samples,) A structured array containing the binary event indicator as first...
[ "Minimize", "negative", "partial", "log", "-", "likelihood", "for", "provided", "data", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/linear_model/coxph.py#L292-L359
232,794
sebp/scikit-survival
sksurv/nonparametric.py
_compute_counts
def _compute_counts(event, time, order=None): """Count right censored and uncensored samples at each unique time point. Parameters ---------- event : array Boolean event indicator. time : array Survival time or time of censoring. order : array or None Indices to order ...
python
def _compute_counts(event, time, order=None): """Count right censored and uncensored samples at each unique time point. Parameters ---------- event : array Boolean event indicator. time : array Survival time or time of censoring. order : array or None Indices to order ...
[ "def", "_compute_counts", "(", "event", ",", "time", ",", "order", "=", "None", ")", ":", "n_samples", "=", "event", ".", "shape", "[", "0", "]", "if", "order", "is", "None", ":", "order", "=", "numpy", ".", "argsort", "(", "time", ",", "kind", "="...
Count right censored and uncensored samples at each unique time point. Parameters ---------- event : array Boolean event indicator. time : array Survival time or time of censoring. order : array or None Indices to order time in ascending order. If None, order will ...
[ "Count", "right", "censored", "and", "uncensored", "samples", "at", "each", "unique", "time", "point", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L28-L94
232,795
sebp/scikit-survival
sksurv/nonparametric.py
_compute_counts_truncated
def _compute_counts_truncated(event, time_enter, time_exit): """Compute counts for left truncated and right censored survival data. Parameters ---------- event : array Boolean event indicator. time_start : array Time when a subject entered the study. time_exit : array ...
python
def _compute_counts_truncated(event, time_enter, time_exit): """Compute counts for left truncated and right censored survival data. Parameters ---------- event : array Boolean event indicator. time_start : array Time when a subject entered the study. time_exit : array ...
[ "def", "_compute_counts_truncated", "(", "event", ",", "time_enter", ",", "time_exit", ")", ":", "if", "(", "time_enter", ">", "time_exit", ")", ".", "any", "(", ")", ":", "raise", "ValueError", "(", "\"exit time must be larger start time for all samples\"", ")", ...
Compute counts for left truncated and right censored survival data. Parameters ---------- event : array Boolean event indicator. time_start : array Time when a subject entered the study. time_exit : array Time when a subject left the study due to an event or censor...
[ "Compute", "counts", "for", "left", "truncated", "and", "right", "censored", "survival", "data", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L97-L167
232,796
sebp/scikit-survival
sksurv/nonparametric.py
kaplan_meier_estimator
def kaplan_meier_estimator(event, time_exit, time_enter=None, time_min=None): """Kaplan-Meier estimator of survival function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time_exit : array-like, shape = (n_samples,) Contains event...
python
def kaplan_meier_estimator(event, time_exit, time_enter=None, time_min=None): """Kaplan-Meier estimator of survival function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time_exit : array-like, shape = (n_samples,) Contains event...
[ "def", "kaplan_meier_estimator", "(", "event", ",", "time_exit", ",", "time_enter", "=", "None", ",", "time_min", "=", "None", ")", ":", "event", ",", "time_enter", ",", "time_exit", "=", "check_y_survival", "(", "event", ",", "time_enter", ",", "time_exit", ...
Kaplan-Meier estimator of survival function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time_exit : array-like, shape = (n_samples,) Contains event/censoring times. time_enter : array-like, shape = (n_samples,), optional ...
[ "Kaplan", "-", "Meier", "estimator", "of", "survival", "function", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L170-L228
232,797
sebp/scikit-survival
sksurv/nonparametric.py
nelson_aalen_estimator
def nelson_aalen_estimator(event, time): """Nelson-Aalen estimator of cumulative hazard function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time : array-like, shape = (n_samples,) Contains event/censoring times. Returns ...
python
def nelson_aalen_estimator(event, time): """Nelson-Aalen estimator of cumulative hazard function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time : array-like, shape = (n_samples,) Contains event/censoring times. Returns ...
[ "def", "nelson_aalen_estimator", "(", "event", ",", "time", ")", ":", "event", ",", "time", "=", "check_y_survival", "(", "event", ",", "time", ")", "check_consistent_length", "(", "event", ",", "time", ")", "uniq_times", ",", "n_events", ",", "n_at_risk", "...
Nelson-Aalen estimator of cumulative hazard function. Parameters ---------- event : array-like, shape = (n_samples,) Contains binary event indicators. time : array-like, shape = (n_samples,) Contains event/censoring times. Returns ------- time : array, shape = (n_times,) ...
[ "Nelson", "-", "Aalen", "estimator", "of", "cumulative", "hazard", "function", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L231-L264
232,798
sebp/scikit-survival
sksurv/nonparametric.py
ipc_weights
def ipc_weights(event, time): """Compute inverse probability of censoring weights Parameters ---------- event : array, shape = (n_samples,) Boolean event indicator. time : array, shape = (n_samples,) Time when a subject experienced an event or was censored. Returns -------...
python
def ipc_weights(event, time): """Compute inverse probability of censoring weights Parameters ---------- event : array, shape = (n_samples,) Boolean event indicator. time : array, shape = (n_samples,) Time when a subject experienced an event or was censored. Returns -------...
[ "def", "ipc_weights", "(", "event", ",", "time", ")", ":", "if", "event", ".", "all", "(", ")", ":", "return", "numpy", ".", "ones", "(", "time", ".", "shape", "[", "0", "]", ")", "unique_time", ",", "p", "=", "kaplan_meier_estimator", "(", "~", "e...
Compute inverse probability of censoring weights Parameters ---------- event : array, shape = (n_samples,) Boolean event indicator. time : array, shape = (n_samples,) Time when a subject experienced an event or was censored. Returns ------- weights : array, shape = (n_samp...
[ "Compute", "inverse", "probability", "of", "censoring", "weights" ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L267-L296
232,799
sebp/scikit-survival
sksurv/nonparametric.py
SurvivalFunctionEstimator.fit
def fit(self, y): """Estimate survival distribution from training data. Parameters ---------- y : structured array, shape = (n_samples,) A structured array containing the binary event indicator as first field, and time of event or time of censoring as ...
python
def fit(self, y): """Estimate survival distribution from training data. Parameters ---------- y : structured array, shape = (n_samples,) A structured array containing the binary event indicator as first field, and time of event or time of censoring as ...
[ "def", "fit", "(", "self", ",", "y", ")", ":", "event", ",", "time", "=", "check_y_survival", "(", "y", ",", "allow_all_censored", "=", "True", ")", "unique_time", ",", "prob", "=", "kaplan_meier_estimator", "(", "event", ",", "time", ")", "self", ".", ...
Estimate survival distribution from training data. Parameters ---------- y : structured array, shape = (n_samples,) A structured array containing the binary event indicator as first field, and time of event or time of censoring as second field. Retur...
[ "Estimate", "survival", "distribution", "from", "training", "data", "." ]
cfc99fd20454cdd6f4f20fe331b39f2191ccaabc
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/nonparametric.py#L305-L325