repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
kislyuk/aegea | aegea/packages/github3/api.py | markdown | def markdown(text, mode='', context='', raw=False):
"""Render an arbitrary markdown document.
:param str text: (required), the text of the document to render
:param str mode: (optional), 'markdown' or 'gfm'
:param str context: (optional), only important when using mode 'gfm',
this is the reposi... | python | def markdown(text, mode='', context='', raw=False):
"""Render an arbitrary markdown document.
:param str text: (required), the text of the document to render
:param str mode: (optional), 'markdown' or 'gfm'
:param str context: (optional), only important when using mode 'gfm',
this is the reposi... | [
"def",
"markdown",
"(",
"text",
",",
"mode",
"=",
"''",
",",
"context",
"=",
"''",
",",
"raw",
"=",
"False",
")",
":",
"return",
"gh",
".",
"markdown",
"(",
"text",
",",
"mode",
",",
"context",
",",
"raw",
")"
] | Render an arbitrary markdown document.
:param str text: (required), the text of the document to render
:param str mode: (optional), 'markdown' or 'gfm'
:param str context: (optional), only important when using mode 'gfm',
this is the repository to use as the context for the rendering
:param boo... | [
"Render",
"an",
"arbitrary",
"markdown",
"document",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/api.py#L323-L335 | train |
kislyuk/aegea | aegea/packages/github3/api.py | search_repositories | def search_repositories(query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find repositories via various criteria.
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on th... | python | def search_repositories(query, sort=None, order=None, per_page=None,
text_match=False, number=-1, etag=None):
"""Find repositories via various criteria.
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on th... | [
"def",
"search_repositories",
"(",
"query",
",",
"sort",
"=",
"None",
",",
"order",
"=",
"None",
",",
"per_page",
"=",
"None",
",",
"text_match",
"=",
"False",
",",
"number",
"=",
"-",
"1",
",",
"etag",
"=",
"None",
")",
":",
"return",
"gh",
".",
"... | Find repositories via various criteria.
.. warning::
You will only be able to make 5 calls with this or other search
functions. To raise the rate-limit on this set of endpoints, create an
authenticated :class:`GitHub <github3.github.GitHub>` Session with
``login``.
The query c... | [
"Find",
"repositories",
"via",
"various",
"criteria",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/api.py#L488-L537 | train |
kislyuk/aegea | aegea/ls.py | limits | def limits(args):
"""
Describe limits in effect on your AWS account. See also https://console.aws.amazon.com/ec2/v2/home#Limits:
"""
# https://aws.amazon.com/about-aws/whats-new/2014/06/19/amazon-ec2-service-limits-report-now-available/
# Console-only APIs: getInstanceLimits, getAccountLimits, getAu... | python | def limits(args):
"""
Describe limits in effect on your AWS account. See also https://console.aws.amazon.com/ec2/v2/home#Limits:
"""
# https://aws.amazon.com/about-aws/whats-new/2014/06/19/amazon-ec2-service-limits-report-now-available/
# Console-only APIs: getInstanceLimits, getAccountLimits, getAu... | [
"def",
"limits",
"(",
"args",
")",
":",
"# https://aws.amazon.com/about-aws/whats-new/2014/06/19/amazon-ec2-service-limits-report-now-available/",
"# Console-only APIs: getInstanceLimits, getAccountLimits, getAutoscalingLimits, getHostLimits",
"# http://boto3.readthedocs.io/en/latest/reference/servi... | Describe limits in effect on your AWS account. See also https://console.aws.amazon.com/ec2/v2/home#Limits: | [
"Describe",
"limits",
"in",
"effect",
"on",
"your",
"AWS",
"account",
".",
"See",
"also",
"https",
":",
"//",
"console",
".",
"aws",
".",
"amazon",
".",
"com",
"/",
"ec2",
"/",
"v2",
"/",
"home#Limits",
":"
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/ls.py#L271-L280 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.add_labels | def add_labels(self, *args):
"""Add labels to this issue.
:param str args: (required), names of the labels you wish to add
:returns: list of :class:`Label`\ s
"""
url = self._build_url('labels', base_url=self._api)
json = self._json(self._post(url, data=args), 200)
... | python | def add_labels(self, *args):
"""Add labels to this issue.
:param str args: (required), names of the labels you wish to add
:returns: list of :class:`Label`\ s
"""
url = self._build_url('labels', base_url=self._api)
json = self._json(self._post(url, data=args), 200)
... | [
"def",
"add_labels",
"(",
"self",
",",
"*",
"args",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'labels'",
",",
"base_url",
"=",
"self",
".",
"_api",
")",
"json",
"=",
"self",
".",
"_json",
"(",
"self",
".",
"_post",
"(",
"url",
",",
"... | Add labels to this issue.
:param str args: (required), names of the labels you wish to add
:returns: list of :class:`Label`\ s | [
"Add",
"labels",
"to",
"this",
"issue",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L105-L113 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.assign | def assign(self, login):
"""Assigns user ``login`` to this issue. This is a short cut for
``issue.edit``.
:param str login: username of the person to assign this issue to
:returns: bool
"""
if not login:
return False
number = self.milestone.number if ... | python | def assign(self, login):
"""Assigns user ``login`` to this issue. This is a short cut for
``issue.edit``.
:param str login: username of the person to assign this issue to
:returns: bool
"""
if not login:
return False
number = self.milestone.number if ... | [
"def",
"assign",
"(",
"self",
",",
"login",
")",
":",
"if",
"not",
"login",
":",
"return",
"False",
"number",
"=",
"self",
".",
"milestone",
".",
"number",
"if",
"self",
".",
"milestone",
"else",
"None",
"labels",
"=",
"[",
"str",
"(",
"l",
")",
"f... | Assigns user ``login`` to this issue. This is a short cut for
``issue.edit``.
:param str login: username of the person to assign this issue to
:returns: bool | [
"Assigns",
"user",
"login",
"to",
"this",
"issue",
".",
"This",
"is",
"a",
"short",
"cut",
"for",
"issue",
".",
"edit",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L116-L128 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.comment | def comment(self, id_num):
"""Get a single comment by its id.
The catch here is that id is NOT a simple number to obtain. If
you were to look at the comments on issue #15 in
sigmavirus24/Todo.txt-python, the first comment's id is 4150787.
:param int id_num: (required), comment ... | python | def comment(self, id_num):
"""Get a single comment by its id.
The catch here is that id is NOT a simple number to obtain. If
you were to look at the comments on issue #15 in
sigmavirus24/Todo.txt-python, the first comment's id is 4150787.
:param int id_num: (required), comment ... | [
"def",
"comment",
"(",
"self",
",",
"id_num",
")",
":",
"json",
"=",
"None",
"if",
"int",
"(",
"id_num",
")",
">",
"0",
":",
"# Might as well check that it's positive",
"owner",
",",
"repo",
"=",
"self",
".",
"repository",
"url",
"=",
"self",
".",
"_buil... | Get a single comment by its id.
The catch here is that id is NOT a simple number to obtain. If
you were to look at the comments on issue #15 in
sigmavirus24/Todo.txt-python, the first comment's id is 4150787.
:param int id_num: (required), comment id, see example above
:returns... | [
"Get",
"a",
"single",
"comment",
"by",
"its",
"id",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L142-L158 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.create_comment | def create_comment(self, body):
"""Create a comment on this issue.
:param str body: (required), comment body
:returns: :class:`IssueComment <github3.issues.comment.IssueComment>`
"""
json = None
if body:
url = self._build_url('comments', base_url=self._api)
... | python | def create_comment(self, body):
"""Create a comment on this issue.
:param str body: (required), comment body
:returns: :class:`IssueComment <github3.issues.comment.IssueComment>`
"""
json = None
if body:
url = self._build_url('comments', base_url=self._api)
... | [
"def",
"create_comment",
"(",
"self",
",",
"body",
")",
":",
"json",
"=",
"None",
"if",
"body",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'comments'",
",",
"base_url",
"=",
"self",
".",
"_api",
")",
"json",
"=",
"self",
".",
"_json",
"(",
"... | Create a comment on this issue.
:param str body: (required), comment body
:returns: :class:`IssueComment <github3.issues.comment.IssueComment>` | [
"Create",
"a",
"comment",
"on",
"this",
"issue",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L161-L172 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.edit | def edit(self, title=None, body=None, assignee=None, state=None,
milestone=None, labels=None):
"""Edit this issue.
:param str title: Title of the issue
:param str body: markdown formatted body (description) of the issue
:param str assignee: login name of user the issue shou... | python | def edit(self, title=None, body=None, assignee=None, state=None,
milestone=None, labels=None):
"""Edit this issue.
:param str title: Title of the issue
:param str body: markdown formatted body (description) of the issue
:param str assignee: login name of user the issue shou... | [
"def",
"edit",
"(",
"self",
",",
"title",
"=",
"None",
",",
"body",
"=",
"None",
",",
"assignee",
"=",
"None",
",",
"state",
"=",
"None",
",",
"milestone",
"=",
"None",
",",
"labels",
"=",
"None",
")",
":",
"json",
"=",
"None",
"data",
"=",
"{",
... | Edit this issue.
:param str title: Title of the issue
:param str body: markdown formatted body (description) of the issue
:param str assignee: login name of user the issue should be assigned
to
:param str state: accepted values: ('open', 'closed')
:param int mileston... | [
"Edit",
"this",
"issue",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L175-L203 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.iter_comments | def iter_comments(self, number=-1):
"""Iterate over the comments on this issue.
:param int number: (optional), number of comments to iterate over
:returns: iterator of
:class:`IssueComment <github3.issues.comment.IssueComment>`\ s
"""
url = self._build_url('comments'... | python | def iter_comments(self, number=-1):
"""Iterate over the comments on this issue.
:param int number: (optional), number of comments to iterate over
:returns: iterator of
:class:`IssueComment <github3.issues.comment.IssueComment>`\ s
"""
url = self._build_url('comments'... | [
"def",
"iter_comments",
"(",
"self",
",",
"number",
"=",
"-",
"1",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'comments'",
",",
"base_url",
"=",
"self",
".",
"_api",
")",
"return",
"self",
".",
"_iter",
"(",
"int",
"(",
"number",
")",
"... | Iterate over the comments on this issue.
:param int number: (optional), number of comments to iterate over
:returns: iterator of
:class:`IssueComment <github3.issues.comment.IssueComment>`\ s | [
"Iterate",
"over",
"the",
"comments",
"on",
"this",
"issue",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L214-L222 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.iter_events | def iter_events(self, number=-1):
"""Iterate over events associated with this issue only.
:param int number: (optional), number of events to return. Default: -1
returns all events available.
:returns: generator of
:class:`IssueEvent <github3.issues.event.IssueEvent>`\ s
... | python | def iter_events(self, number=-1):
"""Iterate over events associated with this issue only.
:param int number: (optional), number of events to return. Default: -1
returns all events available.
:returns: generator of
:class:`IssueEvent <github3.issues.event.IssueEvent>`\ s
... | [
"def",
"iter_events",
"(",
"self",
",",
"number",
"=",
"-",
"1",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'events'",
",",
"base_url",
"=",
"self",
".",
"_api",
")",
"return",
"self",
".",
"_iter",
"(",
"int",
"(",
"number",
")",
",",
... | Iterate over events associated with this issue only.
:param int number: (optional), number of events to return. Default: -1
returns all events available.
:returns: generator of
:class:`IssueEvent <github3.issues.event.IssueEvent>`\ s | [
"Iterate",
"over",
"events",
"associated",
"with",
"this",
"issue",
"only",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L224-L233 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.remove_label | def remove_label(self, name):
"""Removes label ``name`` from this issue.
:param str name: (required), name of the label to remove
:returns: bool
"""
url = self._build_url('labels', name, base_url=self._api)
# Docs say it should be a list of strings returned, practice say... | python | def remove_label(self, name):
"""Removes label ``name`` from this issue.
:param str name: (required), name of the label to remove
:returns: bool
"""
url = self._build_url('labels', name, base_url=self._api)
# Docs say it should be a list of strings returned, practice say... | [
"def",
"remove_label",
"(",
"self",
",",
"name",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'labels'",
",",
"name",
",",
"base_url",
"=",
"self",
".",
"_api",
")",
"# Docs say it should be a list of strings returned, practice says it",
"# is just a 204/4... | Removes label ``name`` from this issue.
:param str name: (required), name of the label to remove
:returns: bool | [
"Removes",
"label",
"name",
"from",
"this",
"issue",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L248-L258 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.replace_labels | def replace_labels(self, labels):
"""Replace all labels on this issue with ``labels``.
:param list labels: label names
:returns: bool
"""
url = self._build_url('labels', base_url=self._api)
json = self._json(self._put(url, data=dumps(labels)), 200)
return [Label(... | python | def replace_labels(self, labels):
"""Replace all labels on this issue with ``labels``.
:param list labels: label names
:returns: bool
"""
url = self._build_url('labels', base_url=self._api)
json = self._json(self._put(url, data=dumps(labels)), 200)
return [Label(... | [
"def",
"replace_labels",
"(",
"self",
",",
"labels",
")",
":",
"url",
"=",
"self",
".",
"_build_url",
"(",
"'labels'",
",",
"base_url",
"=",
"self",
".",
"_api",
")",
"json",
"=",
"self",
".",
"_json",
"(",
"self",
".",
"_put",
"(",
"url",
",",
"da... | Replace all labels on this issue with ``labels``.
:param list labels: label names
:returns: bool | [
"Replace",
"all",
"labels",
"on",
"this",
"issue",
"with",
"labels",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L270-L278 | train |
kislyuk/aegea | aegea/packages/github3/issues/issue.py | Issue.reopen | def reopen(self):
"""Re-open a closed issue.
:returns: bool
"""
assignee = self.assignee.login if self.assignee else ''
number = self.milestone.number if self.milestone else None
labels = [str(l) for l in self.labels]
return self.edit(self.title, self.body, assig... | python | def reopen(self):
"""Re-open a closed issue.
:returns: bool
"""
assignee = self.assignee.login if self.assignee else ''
number = self.milestone.number if self.milestone else None
labels = [str(l) for l in self.labels]
return self.edit(self.title, self.body, assig... | [
"def",
"reopen",
"(",
"self",
")",
":",
"assignee",
"=",
"self",
".",
"assignee",
".",
"login",
"if",
"self",
".",
"assignee",
"else",
"''",
"number",
"=",
"self",
".",
"milestone",
".",
"number",
"if",
"self",
".",
"milestone",
"else",
"None",
"labels... | Re-open a closed issue.
:returns: bool | [
"Re",
"-",
"open",
"a",
"closed",
"issue",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L281-L290 | train |
kislyuk/aegea | aegea/packages/github3/models.py | GitHubObject._strptime | def _strptime(self, time_str):
"""Convert an ISO 8601 formatted string in UTC into a
timezone-aware datetime object."""
if time_str:
# Parse UTC string into naive datetime, then add timezone
dt = datetime.strptime(time_str, __timeformat__)
return dt.replace(tz... | python | def _strptime(self, time_str):
"""Convert an ISO 8601 formatted string in UTC into a
timezone-aware datetime object."""
if time_str:
# Parse UTC string into naive datetime, then add timezone
dt = datetime.strptime(time_str, __timeformat__)
return dt.replace(tz... | [
"def",
"_strptime",
"(",
"self",
",",
"time_str",
")",
":",
"if",
"time_str",
":",
"# Parse UTC string into naive datetime, then add timezone",
"dt",
"=",
"datetime",
".",
"strptime",
"(",
"time_str",
",",
"__timeformat__",
")",
"return",
"dt",
".",
"replace",
"("... | Convert an ISO 8601 formatted string in UTC into a
timezone-aware datetime object. | [
"Convert",
"an",
"ISO",
"8601",
"formatted",
"string",
"in",
"UTC",
"into",
"a",
"timezone",
"-",
"aware",
"datetime",
"object",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/models.py#L39-L46 | train |
kislyuk/aegea | aegea/packages/github3/models.py | GitHubCore._iter | def _iter(self, count, url, cls, params=None, etag=None):
"""Generic iterator for this project.
:param int count: How many items to return.
:param int url: First URL to start with
:param class cls: cls to return an object of
:param params dict: (optional) Parameters for the requ... | python | def _iter(self, count, url, cls, params=None, etag=None):
"""Generic iterator for this project.
:param int count: How many items to return.
:param int url: First URL to start with
:param class cls: cls to return an object of
:param params dict: (optional) Parameters for the requ... | [
"def",
"_iter",
"(",
"self",
",",
"count",
",",
"url",
",",
"cls",
",",
"params",
"=",
"None",
",",
"etag",
"=",
"None",
")",
":",
"from",
".",
"structs",
"import",
"GitHubIterator",
"return",
"GitHubIterator",
"(",
"count",
",",
"url",
",",
"cls",
"... | Generic iterator for this project.
:param int count: How many items to return.
:param int url: First URL to start with
:param class cls: cls to return an object of
:param params dict: (optional) Parameters for the request
:param str etag: (optional), ETag from the last call | [
"Generic",
"iterator",
"for",
"this",
"project",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/models.py#L163-L173 | train |
kislyuk/aegea | aegea/packages/github3/models.py | GitHubCore.ratelimit_remaining | def ratelimit_remaining(self):
"""Number of requests before GitHub imposes a ratelimit.
:returns: int
"""
json = self._json(self._get(self._github_url + '/rate_limit'), 200)
core = json.get('resources', {}).get('core', {})
self._remaining = core.get('remaining', 0)
... | python | def ratelimit_remaining(self):
"""Number of requests before GitHub imposes a ratelimit.
:returns: int
"""
json = self._json(self._get(self._github_url + '/rate_limit'), 200)
core = json.get('resources', {}).get('core', {})
self._remaining = core.get('remaining', 0)
... | [
"def",
"ratelimit_remaining",
"(",
"self",
")",
":",
"json",
"=",
"self",
".",
"_json",
"(",
"self",
".",
"_get",
"(",
"self",
".",
"_github_url",
"+",
"'/rate_limit'",
")",
",",
"200",
")",
"core",
"=",
"json",
".",
"get",
"(",
"'resources'",
",",
"... | Number of requests before GitHub imposes a ratelimit.
:returns: int | [
"Number",
"of",
"requests",
"before",
"GitHub",
"imposes",
"a",
"ratelimit",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/models.py#L176-L184 | train |
kislyuk/aegea | aegea/packages/github3/models.py | GitHubCore.refresh | def refresh(self, conditional=False):
"""Re-retrieve the information for this object and returns the
refreshed instance.
:param bool conditional: If True, then we will search for a stored
header ('Last-Modified', or 'ETag') on the object and send that
as described in the... | python | def refresh(self, conditional=False):
"""Re-retrieve the information for this object and returns the
refreshed instance.
:param bool conditional: If True, then we will search for a stored
header ('Last-Modified', or 'ETag') on the object and send that
as described in the... | [
"def",
"refresh",
"(",
"self",
",",
"conditional",
"=",
"False",
")",
":",
"headers",
"=",
"{",
"}",
"if",
"conditional",
":",
"if",
"self",
".",
"last_modified",
":",
"headers",
"[",
"'If-Modified-Since'",
"]",
"=",
"self",
".",
"last_modified",
"elif",
... | Re-retrieve the information for this object and returns the
refreshed instance.
:param bool conditional: If True, then we will search for a stored
header ('Last-Modified', or 'ETag') on the object and send that
as described in the `Conditional Requests`_ section of the docs
... | [
"Re",
"-",
"retrieve",
"the",
"information",
"for",
"this",
"object",
"and",
"returns",
"the",
"refreshed",
"instance",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/models.py#L186-L223 | train |
kislyuk/aegea | aegea/packages/github3/models.py | BaseComment.edit | def edit(self, body):
"""Edit this comment.
:param str body: (required), new body of the comment, Markdown
formatted
:returns: bool
"""
if body:
json = self._json(self._patch(self._api,
data=dumps({'body': body})), 200)
... | python | def edit(self, body):
"""Edit this comment.
:param str body: (required), new body of the comment, Markdown
formatted
:returns: bool
"""
if body:
json = self._json(self._patch(self._api,
data=dumps({'body': body})), 200)
... | [
"def",
"edit",
"(",
"self",
",",
"body",
")",
":",
"if",
"body",
":",
"json",
"=",
"self",
".",
"_json",
"(",
"self",
".",
"_patch",
"(",
"self",
".",
"_api",
",",
"data",
"=",
"dumps",
"(",
"{",
"'body'",
":",
"body",
"}",
")",
")",
",",
"20... | Edit this comment.
:param str body: (required), new body of the comment, Markdown
formatted
:returns: bool | [
"Edit",
"this",
"comment",
"."
] | 94957e9dba036eae3052e2662c208b259c08399a | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/models.py#L267-L280 | train |
quantmind/dynts | dynts/formatters/tsplot.py | toplot | def toplot(ts,
filename=None,
grid=True,
legend=True,
pargs=(),
**kwargs):
'''To plot formatter'''
fig = plt.figure()
ax = fig.add_subplot(111)
dates = list(ts.dates())
ax.plot(dates, ts.values(), *pargs)
ax.grid(grid)
# ro... | python | def toplot(ts,
filename=None,
grid=True,
legend=True,
pargs=(),
**kwargs):
'''To plot formatter'''
fig = plt.figure()
ax = fig.add_subplot(111)
dates = list(ts.dates())
ax.plot(dates, ts.values(), *pargs)
ax.grid(grid)
# ro... | [
"def",
"toplot",
"(",
"ts",
",",
"filename",
"=",
"None",
",",
"grid",
"=",
"True",
",",
"legend",
"=",
"True",
",",
"pargs",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
")",
"ax",
"=",
"fig",
".",... | To plot formatter | [
"To",
"plot",
"formatter"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/formatters/tsplot.py#L4-L33 | train |
doakey3/DashTable | dashtable/dashutils/check_table.py | check_table | def check_table(table):
"""
Ensure the table is valid for converting to grid table.
* The table must a list of lists
* Each row must contain the same number of columns
* The table must not be empty
Parameters
----------
table : list of lists of str
The list of rows of strings t... | python | def check_table(table):
"""
Ensure the table is valid for converting to grid table.
* The table must a list of lists
* Each row must contain the same number of columns
* The table must not be empty
Parameters
----------
table : list of lists of str
The list of rows of strings t... | [
"def",
"check_table",
"(",
"table",
")",
":",
"if",
"not",
"type",
"(",
"table",
")",
"is",
"list",
":",
"return",
"\"Table must be a list of lists\"",
"if",
"len",
"(",
"table",
")",
"==",
"0",
":",
"return",
"\"Table must contain at least one row and one column\... | Ensure the table is valid for converting to grid table.
* The table must a list of lists
* Each row must contain the same number of columns
* The table must not be empty
Parameters
----------
table : list of lists of str
The list of rows of strings to convert to a grid table
Retur... | [
"Ensure",
"the",
"table",
"is",
"valid",
"for",
"converting",
"to",
"grid",
"table",
"."
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/check_table.py#L1-L32 | train |
doakey3/DashTable | dashtable/dashutils/get_span.py | get_span | def get_span(spans, row, column):
"""
Gets the span containing the [row, column] pair
Parameters
----------
spans : list of lists of lists
A list containing spans, which are lists of [row, column] pairs
that define where a span is inside a table.
Returns
-------
span : ... | python | def get_span(spans, row, column):
"""
Gets the span containing the [row, column] pair
Parameters
----------
spans : list of lists of lists
A list containing spans, which are lists of [row, column] pairs
that define where a span is inside a table.
Returns
-------
span : ... | [
"def",
"get_span",
"(",
"spans",
",",
"row",
",",
"column",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"spans",
")",
")",
":",
"if",
"[",
"row",
",",
"column",
"]",
"in",
"spans",
"[",
"i",
"]",
":",
"return",
"spans",
"[",
"i",
"]... | Gets the span containing the [row, column] pair
Parameters
----------
spans : list of lists of lists
A list containing spans, which are lists of [row, column] pairs
that define where a span is inside a table.
Returns
-------
span : list of lists
A span containing the [r... | [
"Gets",
"the",
"span",
"containing",
"the",
"[",
"row",
"column",
"]",
"pair"
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span.py#L1-L20 | train |
doakey3/DashTable | dashtable/html2data/find_unassigned_table_cell.py | find_unassigned_table_cell | def find_unassigned_table_cell(table):
"""
Search through a table and return the first [row, column] pair
who's value is None.
Parameters
----------
table : list of lists of str
Returns
-------
list of int
The row column pair of the None type cell
"""
for row in ran... | python | def find_unassigned_table_cell(table):
"""
Search through a table and return the first [row, column] pair
who's value is None.
Parameters
----------
table : list of lists of str
Returns
-------
list of int
The row column pair of the None type cell
"""
for row in ran... | [
"def",
"find_unassigned_table_cell",
"(",
"table",
")",
":",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")",
")",
":",
"for",
"column",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"row",
"]",
")",
")",
":",
"if",
"table",
"[",
"row",
... | Search through a table and return the first [row, column] pair
who's value is None.
Parameters
----------
table : list of lists of str
Returns
-------
list of int
The row column pair of the None type cell | [
"Search",
"through",
"a",
"table",
"and",
"return",
"the",
"first",
"[",
"row",
"column",
"]",
"pair",
"who",
"s",
"value",
"is",
"None",
"."
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/find_unassigned_table_cell.py#L1-L19 | train |
quantmind/dynts | dynts/backends/np.py | Numpy.insert | def insert(self, dte, values):
'''insert *values* at date *dte*.'''
if len(values):
dte = self.dateconvert(dte)
if not self:
self._date = np.array([dte])
self._data = np.array([values])
else:
# search for the date
... | python | def insert(self, dte, values):
'''insert *values* at date *dte*.'''
if len(values):
dte = self.dateconvert(dte)
if not self:
self._date = np.array([dte])
self._data = np.array([values])
else:
# search for the date
... | [
"def",
"insert",
"(",
"self",
",",
"dte",
",",
"values",
")",
":",
"if",
"len",
"(",
"values",
")",
":",
"dte",
"=",
"self",
".",
"dateconvert",
"(",
"dte",
")",
"if",
"not",
"self",
":",
"self",
".",
"_date",
"=",
"np",
".",
"array",
"(",
"[",... | insert *values* at date *dte*. | [
"insert",
"*",
"values",
"*",
"at",
"date",
"*",
"dte",
"*",
"."
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/np.py#L89-L110 | train |
eaton-lab/toytree | toytree/etemini.py | _translate_nodes | def _translate_nodes(root, *nodes):
"""
Convert node names into node instances...
"""
#name2node = {[n, None] for n in nodes if type(n) is str}
name2node = dict([[n, None] for n in nodes if type(n) is str])
for n in root.traverse():
if n.name in name2node:
if name2node[n.name... | python | def _translate_nodes(root, *nodes):
"""
Convert node names into node instances...
"""
#name2node = {[n, None] for n in nodes if type(n) is str}
name2node = dict([[n, None] for n in nodes if type(n) is str])
for n in root.traverse():
if n.name in name2node:
if name2node[n.name... | [
"def",
"_translate_nodes",
"(",
"root",
",",
"*",
"nodes",
")",
":",
"#name2node = {[n, None] for n in nodes if type(n) is str}",
"name2node",
"=",
"dict",
"(",
"[",
"[",
"n",
",",
"None",
"]",
"for",
"n",
"in",
"nodes",
"if",
"type",
"(",
"n",
")",
"is",
... | Convert node names into node instances... | [
"Convert",
"node",
"names",
"into",
"node",
"instances",
"..."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L2075-L2104 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.add_feature | def add_feature(self, pr_name, pr_value):
""" Add or update a node's feature. """
setattr(self, pr_name, pr_value)
self.features.add(pr_name) | python | def add_feature(self, pr_name, pr_value):
""" Add or update a node's feature. """
setattr(self, pr_name, pr_value)
self.features.add(pr_name) | [
"def",
"add_feature",
"(",
"self",
",",
"pr_name",
",",
"pr_value",
")",
":",
"setattr",
"(",
"self",
",",
"pr_name",
",",
"pr_value",
")",
"self",
".",
"features",
".",
"add",
"(",
"pr_name",
")"
] | Add or update a node's feature. | [
"Add",
"or",
"update",
"a",
"node",
"s",
"feature",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L218-L221 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.add_features | def add_features(self, **features):
""" Add or update several features. """
for fname, fvalue in six.iteritems(features):
setattr(self, fname, fvalue)
self.features.add(fname) | python | def add_features(self, **features):
""" Add or update several features. """
for fname, fvalue in six.iteritems(features):
setattr(self, fname, fvalue)
self.features.add(fname) | [
"def",
"add_features",
"(",
"self",
",",
"*",
"*",
"features",
")",
":",
"for",
"fname",
",",
"fvalue",
"in",
"six",
".",
"iteritems",
"(",
"features",
")",
":",
"setattr",
"(",
"self",
",",
"fname",
",",
"fvalue",
")",
"self",
".",
"features",
".",
... | Add or update several features. | [
"Add",
"or",
"update",
"several",
"features",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L224-L228 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.del_feature | def del_feature(self, pr_name):
""" Permanently deletes a node's feature."""
if hasattr(self, pr_name):
delattr(self, pr_name)
self.features.remove(pr_name) | python | def del_feature(self, pr_name):
""" Permanently deletes a node's feature."""
if hasattr(self, pr_name):
delattr(self, pr_name)
self.features.remove(pr_name) | [
"def",
"del_feature",
"(",
"self",
",",
"pr_name",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"pr_name",
")",
":",
"delattr",
"(",
"self",
",",
"pr_name",
")",
"self",
".",
"features",
".",
"remove",
"(",
"pr_name",
")"
] | Permanently deletes a node's feature. | [
"Permanently",
"deletes",
"a",
"node",
"s",
"feature",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L231-L235 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.add_child | def add_child(self, child=None, name=None, dist=None, support=None):
"""
Adds a new child to this node. If child node is not suplied
as an argument, a new node instance will be created.
Parameters
----------
child:
the node instance to be added as a... | python | def add_child(self, child=None, name=None, dist=None, support=None):
"""
Adds a new child to this node. If child node is not suplied
as an argument, a new node instance will be created.
Parameters
----------
child:
the node instance to be added as a... | [
"def",
"add_child",
"(",
"self",
",",
"child",
"=",
"None",
",",
"name",
"=",
"None",
",",
"dist",
"=",
"None",
",",
"support",
"=",
"None",
")",
":",
"if",
"child",
"is",
"None",
":",
"child",
"=",
"self",
".",
"__class__",
"(",
")",
"if",
"name... | Adds a new child to this node. If child node is not suplied
as an argument, a new node instance will be created.
Parameters
----------
child:
the node instance to be added as a child.
name:
the name that will be given to the child.
dist... | [
"Adds",
"a",
"new",
"child",
"to",
"this",
"node",
".",
"If",
"child",
"node",
"is",
"not",
"suplied",
"as",
"an",
"argument",
"a",
"new",
"node",
"instance",
"will",
"be",
"created",
".",
"Parameters",
"----------"
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L241-L274 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.remove_child | def remove_child(self, child):
"""
Removes a child from this node (parent and child
nodes still exit but are no longer connected).
"""
try:
self.children.remove(child)
except ValueError as e:
raise TreeError("child not found")
else:
... | python | def remove_child(self, child):
"""
Removes a child from this node (parent and child
nodes still exit but are no longer connected).
"""
try:
self.children.remove(child)
except ValueError as e:
raise TreeError("child not found")
else:
... | [
"def",
"remove_child",
"(",
"self",
",",
"child",
")",
":",
"try",
":",
"self",
".",
"children",
".",
"remove",
"(",
"child",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"TreeError",
"(",
"\"child not found\"",
")",
"else",
":",
"child",
".",
... | Removes a child from this node (parent and child
nodes still exit but are no longer connected). | [
"Removes",
"a",
"child",
"from",
"this",
"node",
"(",
"parent",
"and",
"child",
"nodes",
"still",
"exit",
"but",
"are",
"no",
"longer",
"connected",
")",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L277-L288 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.add_sister | def add_sister(self, sister=None, name=None, dist=None):
"""
Adds a sister to this node. If sister node is not supplied
as an argument, a new TreeNode instance will be created and
returned.
"""
if self.up == None:
raise TreeError("A parent node is required to ... | python | def add_sister(self, sister=None, name=None, dist=None):
"""
Adds a sister to this node. If sister node is not supplied
as an argument, a new TreeNode instance will be created and
returned.
"""
if self.up == None:
raise TreeError("A parent node is required to ... | [
"def",
"add_sister",
"(",
"self",
",",
"sister",
"=",
"None",
",",
"name",
"=",
"None",
",",
"dist",
"=",
"None",
")",
":",
"if",
"self",
".",
"up",
"==",
"None",
":",
"raise",
"TreeError",
"(",
"\"A parent node is required to add a sister\"",
")",
"else",... | Adds a sister to this node. If sister node is not supplied
as an argument, a new TreeNode instance will be created and
returned. | [
"Adds",
"a",
"sister",
"to",
"this",
"node",
".",
"If",
"sister",
"node",
"is",
"not",
"supplied",
"as",
"an",
"argument",
"a",
"new",
"TreeNode",
"instance",
"will",
"be",
"created",
"and",
"returned",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L291-L300 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.remove_sister | def remove_sister(self, sister=None):
"""
Removes a sister node. It has the same effect as
**`TreeNode.up.remove_child(sister)`**
If a sister node is not supplied, the first sister will be deleted
and returned.
:argument sister: A node instance
:return: The nod... | python | def remove_sister(self, sister=None):
"""
Removes a sister node. It has the same effect as
**`TreeNode.up.remove_child(sister)`**
If a sister node is not supplied, the first sister will be deleted
and returned.
:argument sister: A node instance
:return: The nod... | [
"def",
"remove_sister",
"(",
"self",
",",
"sister",
"=",
"None",
")",
":",
"sisters",
"=",
"self",
".",
"get_sisters",
"(",
")",
"if",
"len",
"(",
"sisters",
")",
">",
"0",
":",
"if",
"sister",
"is",
"None",
":",
"sister",
"=",
"sisters",
".",
"pop... | Removes a sister node. It has the same effect as
**`TreeNode.up.remove_child(sister)`**
If a sister node is not supplied, the first sister will be deleted
and returned.
:argument sister: A node instance
:return: The node removed | [
"Removes",
"a",
"sister",
"node",
".",
"It",
"has",
"the",
"same",
"effect",
"as",
"**",
"TreeNode",
".",
"up",
".",
"remove_child",
"(",
"sister",
")",
"**"
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L303-L319 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.delete | def delete(self, prevent_nondicotomic=True, preserve_branch_length=False):
"""
Deletes node from the tree structure. Notice that this method
makes 'disappear' the node from the tree structure. This means
that children from the deleted node are transferred to the
next available pa... | python | def delete(self, prevent_nondicotomic=True, preserve_branch_length=False):
"""
Deletes node from the tree structure. Notice that this method
makes 'disappear' the node from the tree structure. This means
that children from the deleted node are transferred to the
next available pa... | [
"def",
"delete",
"(",
"self",
",",
"prevent_nondicotomic",
"=",
"True",
",",
"preserve_branch_length",
"=",
"False",
")",
":",
"parent",
"=",
"self",
".",
"up",
"if",
"parent",
":",
"if",
"preserve_branch_length",
":",
"if",
"len",
"(",
"self",
".",
"child... | Deletes node from the tree structure. Notice that this method
makes 'disappear' the node from the tree structure. This means
that children from the deleted node are transferred to the
next available parent.
Parameters:
-----------
prevent_nondicotomic:
When ... | [
"Deletes",
"node",
"from",
"the",
"tree",
"structure",
".",
"Notice",
"that",
"this",
"method",
"makes",
"disappear",
"the",
"node",
"from",
"the",
"tree",
"structure",
".",
"This",
"means",
"that",
"children",
"from",
"the",
"deleted",
"node",
"are",
"trans... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L322-L374 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.detach | def detach(self):
"""
Detachs this node (and all its descendants) from its parent
and returns the referent to itself.
Detached node conserves all its structure of descendants, and can
be attached to another node through the 'add_child' function. This
mechanism can be see... | python | def detach(self):
"""
Detachs this node (and all its descendants) from its parent
and returns the referent to itself.
Detached node conserves all its structure of descendants, and can
be attached to another node through the 'add_child' function. This
mechanism can be see... | [
"def",
"detach",
"(",
"self",
")",
":",
"if",
"self",
".",
"up",
":",
"self",
".",
"up",
".",
"children",
".",
"remove",
"(",
"self",
")",
"self",
".",
"up",
"=",
"None",
"return",
"self"
] | Detachs this node (and all its descendants) from its parent
and returns the referent to itself.
Detached node conserves all its structure of descendants, and can
be attached to another node through the 'add_child' function. This
mechanism can be seen as a cut and paste. | [
"Detachs",
"this",
"node",
"(",
"and",
"all",
"its",
"descendants",
")",
"from",
"its",
"parent",
"and",
"returns",
"the",
"referent",
"to",
"itself",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L377-L389 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.prune | def prune(self, nodes, preserve_branch_length=False):
"""
Prunes the topology of a node to conserve only a selected list of leaf
internal nodes. The minimum number of nodes that conserve the
topological relationships among the requested nodes will be
retained. Root node is always... | python | def prune(self, nodes, preserve_branch_length=False):
"""
Prunes the topology of a node to conserve only a selected list of leaf
internal nodes. The minimum number of nodes that conserve the
topological relationships among the requested nodes will be
retained. Root node is always... | [
"def",
"prune",
"(",
"self",
",",
"nodes",
",",
"preserve_branch_length",
"=",
"False",
")",
":",
"def",
"cmp_nodes",
"(",
"x",
",",
"y",
")",
":",
"# if several nodes are in the same path of two kept nodes,",
"# only one should be maintained. This prioritize internal",
"... | Prunes the topology of a node to conserve only a selected list of leaf
internal nodes. The minimum number of nodes that conserve the
topological relationships among the requested nodes will be
retained. Root node is always conserved.
Parameters:
-----------
nodes:
... | [
"Prunes",
"the",
"topology",
"of",
"a",
"node",
"to",
"conserve",
"only",
"a",
"selected",
"list",
"of",
"leaf",
"internal",
"nodes",
".",
"The",
"minimum",
"number",
"of",
"nodes",
"that",
"conserve",
"the",
"topological",
"relationships",
"among",
"the",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L392-L522 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_sisters | def get_sisters(self):
""" Returns an indepent list of sister nodes."""
if self.up != None:
return [ch for ch in self.up.children if ch != self]
else:
return [] | python | def get_sisters(self):
""" Returns an indepent list of sister nodes."""
if self.up != None:
return [ch for ch in self.up.children if ch != self]
else:
return [] | [
"def",
"get_sisters",
"(",
"self",
")",
":",
"if",
"self",
".",
"up",
"!=",
"None",
":",
"return",
"[",
"ch",
"for",
"ch",
"in",
"self",
".",
"up",
".",
"children",
"if",
"ch",
"!=",
"self",
"]",
"else",
":",
"return",
"[",
"]"
] | Returns an indepent list of sister nodes. | [
"Returns",
"an",
"indepent",
"list",
"of",
"sister",
"nodes",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L539-L544 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_leaves | def iter_leaves(self, is_leaf_fn=None):
""" Returns an iterator over the leaves under this node."""
for n in self.traverse(strategy="preorder", is_leaf_fn=is_leaf_fn):
if not is_leaf_fn:
if n.is_leaf():
yield n
else:
if is_leaf_... | python | def iter_leaves(self, is_leaf_fn=None):
""" Returns an iterator over the leaves under this node."""
for n in self.traverse(strategy="preorder", is_leaf_fn=is_leaf_fn):
if not is_leaf_fn:
if n.is_leaf():
yield n
else:
if is_leaf_... | [
"def",
"iter_leaves",
"(",
"self",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"for",
"n",
"in",
"self",
".",
"traverse",
"(",
"strategy",
"=",
"\"preorder\"",
",",
"is_leaf_fn",
"=",
"is_leaf_fn",
")",
":",
"if",
"not",
"is_leaf_fn",
":",
"if",
"n",
"."... | Returns an iterator over the leaves under this node. | [
"Returns",
"an",
"iterator",
"over",
"the",
"leaves",
"under",
"this",
"node",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L547-L555 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_leaf_names | def iter_leaf_names(self, is_leaf_fn=None):
"""Returns an iterator over the leaf names under this node."""
for n in self.iter_leaves(is_leaf_fn=is_leaf_fn):
yield n.name | python | def iter_leaf_names(self, is_leaf_fn=None):
"""Returns an iterator over the leaf names under this node."""
for n in self.iter_leaves(is_leaf_fn=is_leaf_fn):
yield n.name | [
"def",
"iter_leaf_names",
"(",
"self",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"for",
"n",
"in",
"self",
".",
"iter_leaves",
"(",
"is_leaf_fn",
"=",
"is_leaf_fn",
")",
":",
"yield",
"n",
".",
"name"
] | Returns an iterator over the leaf names under this node. | [
"Returns",
"an",
"iterator",
"over",
"the",
"leaf",
"names",
"under",
"this",
"node",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L563-L566 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_descendants | def iter_descendants(self, strategy="levelorder", is_leaf_fn=None):
""" Returns an iterator over all descendant nodes."""
for n in self.traverse(strategy=strategy, is_leaf_fn=is_leaf_fn):
if n is not self:
yield n | python | def iter_descendants(self, strategy="levelorder", is_leaf_fn=None):
""" Returns an iterator over all descendant nodes."""
for n in self.traverse(strategy=strategy, is_leaf_fn=is_leaf_fn):
if n is not self:
yield n | [
"def",
"iter_descendants",
"(",
"self",
",",
"strategy",
"=",
"\"levelorder\"",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"for",
"n",
"in",
"self",
".",
"traverse",
"(",
"strategy",
"=",
"strategy",
",",
"is_leaf_fn",
"=",
"is_leaf_fn",
")",
":",
"if",
"... | Returns an iterator over all descendant nodes. | [
"Returns",
"an",
"iterator",
"over",
"all",
"descendant",
"nodes",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L574-L578 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_descendants | def get_descendants(self, strategy="levelorder", is_leaf_fn=None):
""" Returns a list of all (leaves and internal) descendant nodes."""
return [n for n in self.iter_descendants(
strategy=strategy, is_leaf_fn=is_leaf_fn)] | python | def get_descendants(self, strategy="levelorder", is_leaf_fn=None):
""" Returns a list of all (leaves and internal) descendant nodes."""
return [n for n in self.iter_descendants(
strategy=strategy, is_leaf_fn=is_leaf_fn)] | [
"def",
"get_descendants",
"(",
"self",
",",
"strategy",
"=",
"\"levelorder\"",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"return",
"[",
"n",
"for",
"n",
"in",
"self",
".",
"iter_descendants",
"(",
"strategy",
"=",
"strategy",
",",
"is_leaf_fn",
"=",
"is_le... | Returns a list of all (leaves and internal) descendant nodes. | [
"Returns",
"a",
"list",
"of",
"all",
"(",
"leaves",
"and",
"internal",
")",
"descendant",
"nodes",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L581-L584 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.traverse | def traverse(self, strategy="levelorder", is_leaf_fn=None):
""" Returns an iterator to traverse tree under this node.
Parameters:
-----------
strategy:
set the way in which tree will be traversed. Possible
values are: "preorder" (first parent and then c... | python | def traverse(self, strategy="levelorder", is_leaf_fn=None):
""" Returns an iterator to traverse tree under this node.
Parameters:
-----------
strategy:
set the way in which tree will be traversed. Possible
values are: "preorder" (first parent and then c... | [
"def",
"traverse",
"(",
"self",
",",
"strategy",
"=",
"\"levelorder\"",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"if",
"strategy",
"==",
"\"preorder\"",
":",
"return",
"self",
".",
"_iter_descendants_preorder",
"(",
"is_leaf_fn",
"=",
"is_leaf_fn",
")",
"elif... | Returns an iterator to traverse tree under this node.
Parameters:
-----------
strategy:
set the way in which tree will be traversed. Possible
values are: "preorder" (first parent and then children)
'postorder' (first children and the parent) and
... | [
"Returns",
"an",
"iterator",
"to",
"traverse",
"tree",
"under",
"this",
"node",
".",
"Parameters",
":",
"-----------",
"strategy",
":",
"set",
"the",
"way",
"in",
"which",
"tree",
"will",
"be",
"traversed",
".",
"Possible",
"values",
"are",
":",
"preorder",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L587-L611 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_prepostorder | def iter_prepostorder(self, is_leaf_fn=None):
"""
Iterate over all nodes in a tree yielding every node in both
pre and post order. Each iteration returns a postorder flag
(True if node is being visited in postorder) and a node
instance.
"""
to_visit = [self]
... | python | def iter_prepostorder(self, is_leaf_fn=None):
"""
Iterate over all nodes in a tree yielding every node in both
pre and post order. Each iteration returns a postorder flag
(True if node is being visited in postorder) and a node
instance.
"""
to_visit = [self]
... | [
"def",
"iter_prepostorder",
"(",
"self",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"to_visit",
"=",
"[",
"self",
"]",
"if",
"is_leaf_fn",
"is",
"not",
"None",
":",
"_leaf",
"=",
"is_leaf_fn",
"else",
":",
"_leaf",
"=",
"self",
".",
"__class__",
".",
"i... | Iterate over all nodes in a tree yielding every node in both
pre and post order. Each iteration returns a postorder flag
(True if node is being visited in postorder) and a node
instance. | [
"Iterate",
"over",
"all",
"nodes",
"in",
"a",
"tree",
"yielding",
"every",
"node",
"in",
"both",
"pre",
"and",
"post",
"order",
".",
"Each",
"iteration",
"returns",
"a",
"postorder",
"flag",
"(",
"True",
"if",
"node",
"is",
"being",
"visited",
"in",
"pos... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L614-L639 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode._iter_descendants_levelorder | def _iter_descendants_levelorder(self, is_leaf_fn=None):
""" Iterate over all desdecendant nodes."""
tovisit = deque([self])
while len(tovisit) > 0:
node = tovisit.popleft()
yield node
if not is_leaf_fn or not is_leaf_fn(node):
tovisit.extend(n... | python | def _iter_descendants_levelorder(self, is_leaf_fn=None):
""" Iterate over all desdecendant nodes."""
tovisit = deque([self])
while len(tovisit) > 0:
node = tovisit.popleft()
yield node
if not is_leaf_fn or not is_leaf_fn(node):
tovisit.extend(n... | [
"def",
"_iter_descendants_levelorder",
"(",
"self",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"tovisit",
"=",
"deque",
"(",
"[",
"self",
"]",
")",
"while",
"len",
"(",
"tovisit",
")",
">",
"0",
":",
"node",
"=",
"tovisit",
".",
"popleft",
"(",
")",
"... | Iterate over all desdecendant nodes. | [
"Iterate",
"over",
"all",
"desdecendant",
"nodes",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L665-L672 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode._iter_descendants_preorder | def _iter_descendants_preorder(self, is_leaf_fn=None):
""" Iterator over all descendant nodes. """
to_visit = deque()
node = self
while node is not None:
yield node
if not is_leaf_fn or not is_leaf_fn(node):
to_visit.extendleft(reversed(node.childr... | python | def _iter_descendants_preorder(self, is_leaf_fn=None):
""" Iterator over all descendant nodes. """
to_visit = deque()
node = self
while node is not None:
yield node
if not is_leaf_fn or not is_leaf_fn(node):
to_visit.extendleft(reversed(node.childr... | [
"def",
"_iter_descendants_preorder",
"(",
"self",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"to_visit",
"=",
"deque",
"(",
")",
"node",
"=",
"self",
"while",
"node",
"is",
"not",
"None",
":",
"yield",
"node",
"if",
"not",
"is_leaf_fn",
"or",
"not",
"is_l... | Iterator over all descendant nodes. | [
"Iterator",
"over",
"all",
"descendant",
"nodes",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L675-L686 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_ancestors | def iter_ancestors(self):
"""
Iterates over the list of all ancestor nodes from
current node to the current tree root.
"""
node = self
while node.up is not None:
yield node.up
node = node.up | python | def iter_ancestors(self):
"""
Iterates over the list of all ancestor nodes from
current node to the current tree root.
"""
node = self
while node.up is not None:
yield node.up
node = node.up | [
"def",
"iter_ancestors",
"(",
"self",
")",
":",
"node",
"=",
"self",
"while",
"node",
".",
"up",
"is",
"not",
"None",
":",
"yield",
"node",
".",
"up",
"node",
"=",
"node",
".",
"up"
] | Iterates over the list of all ancestor nodes from
current node to the current tree root. | [
"Iterates",
"over",
"the",
"list",
"of",
"all",
"ancestor",
"nodes",
"from",
"current",
"node",
"to",
"the",
"current",
"tree",
"root",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L689-L697 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.write | def write(self,
features=None,
outfile=None,
format=0,
is_leaf_fn=None,
format_root_node=False,
dist_formatter=None,
support_formatter=None,
name_formatter=None):
"""
Returns the newick representation of current node. Several
... | python | def write(self,
features=None,
outfile=None,
format=0,
is_leaf_fn=None,
format_root_node=False,
dist_formatter=None,
support_formatter=None,
name_formatter=None):
"""
Returns the newick representation of current node. Several
... | [
"def",
"write",
"(",
"self",
",",
"features",
"=",
"None",
",",
"outfile",
"=",
"None",
",",
"format",
"=",
"0",
",",
"is_leaf_fn",
"=",
"None",
",",
"format_root_node",
"=",
"False",
",",
"dist_formatter",
"=",
"None",
",",
"support_formatter",
"=",
"No... | Returns the newick representation of current node. Several
arguments control the way in which extra data is shown for
every node:
Parameters:
-----------
features:
a list of feature names to be exported using the Extended Newick
Format (i.e. features=["... | [
"Returns",
"the",
"newick",
"representation",
"of",
"current",
"node",
".",
"Several",
"arguments",
"control",
"the",
"way",
"in",
"which",
"extra",
"data",
"is",
"shown",
"for",
"every",
"node",
":"
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L708-L759 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_tree_root | def get_tree_root(self):
""" Returns the absolute root node of current tree structure."""
root = self
while root.up is not None:
root = root.up
return root | python | def get_tree_root(self):
""" Returns the absolute root node of current tree structure."""
root = self
while root.up is not None:
root = root.up
return root | [
"def",
"get_tree_root",
"(",
"self",
")",
":",
"root",
"=",
"self",
"while",
"root",
".",
"up",
"is",
"not",
"None",
":",
"root",
"=",
"root",
".",
"up",
"return",
"root"
] | Returns the absolute root node of current tree structure. | [
"Returns",
"the",
"absolute",
"root",
"node",
"of",
"current",
"tree",
"structure",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L762-L767 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_common_ancestor | def get_common_ancestor(self, *target_nodes, **kargs):
"""
Returns the first common ancestor between this node and a given
list of 'target_nodes'.
**Examples:**
t = tree.Tree("(((A:0.1, B:0.01):0.001, C:0.0001):1.0[&&NHX:name=common], (D:0.00001):0.000001):2.0[&&NHX:name=root]... | python | def get_common_ancestor(self, *target_nodes, **kargs):
"""
Returns the first common ancestor between this node and a given
list of 'target_nodes'.
**Examples:**
t = tree.Tree("(((A:0.1, B:0.01):0.001, C:0.0001):1.0[&&NHX:name=common], (D:0.00001):0.000001):2.0[&&NHX:name=root]... | [
"def",
"get_common_ancestor",
"(",
"self",
",",
"*",
"target_nodes",
",",
"*",
"*",
"kargs",
")",
":",
"get_path",
"=",
"kargs",
".",
"get",
"(",
"\"get_path\"",
",",
"False",
")",
"if",
"len",
"(",
"target_nodes",
")",
"==",
"1",
"and",
"type",
"(",
... | Returns the first common ancestor between this node and a given
list of 'target_nodes'.
**Examples:**
t = tree.Tree("(((A:0.1, B:0.01):0.001, C:0.0001):1.0[&&NHX:name=common], (D:0.00001):0.000001):2.0[&&NHX:name=root];")
A = t.get_descendants_by_name("A")[0]
C = t.get_des... | [
"Returns",
"the",
"first",
"common",
"ancestor",
"between",
"this",
"node",
"and",
"a",
"given",
"list",
"of",
"target_nodes",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L770-L825 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_search_nodes | def iter_search_nodes(self, **conditions):
"""
Search nodes in an interative way. Matches are being yield as
they are being found. This avoids to scan the full tree
topology before returning the first matches. Useful when
dealing with huge trees.
"""
for n in self... | python | def iter_search_nodes(self, **conditions):
"""
Search nodes in an interative way. Matches are being yield as
they are being found. This avoids to scan the full tree
topology before returning the first matches. Useful when
dealing with huge trees.
"""
for n in self... | [
"def",
"iter_search_nodes",
"(",
"self",
",",
"*",
"*",
"conditions",
")",
":",
"for",
"n",
"in",
"self",
".",
"traverse",
"(",
")",
":",
"conditions_passed",
"=",
"0",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"conditions",
")",
... | Search nodes in an interative way. Matches are being yield as
they are being found. This avoids to scan the full tree
topology before returning the first matches. Useful when
dealing with huge trees. | [
"Search",
"nodes",
"in",
"an",
"interative",
"way",
".",
"Matches",
"are",
"being",
"yield",
"as",
"they",
"are",
"being",
"found",
".",
"This",
"avoids",
"to",
"scan",
"the",
"full",
"tree",
"topology",
"before",
"returning",
"the",
"first",
"matches",
".... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L828-L841 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.search_nodes | def search_nodes(self, **conditions):
"""
Returns the list of nodes matching a given set of conditions.
**Example:**
tree.search_nodes(dist=0.0, name="human")
"""
matching_nodes = []
for n in self.iter_search_nodes(**conditions):
matching_nodes.append(... | python | def search_nodes(self, **conditions):
"""
Returns the list of nodes matching a given set of conditions.
**Example:**
tree.search_nodes(dist=0.0, name="human")
"""
matching_nodes = []
for n in self.iter_search_nodes(**conditions):
matching_nodes.append(... | [
"def",
"search_nodes",
"(",
"self",
",",
"*",
"*",
"conditions",
")",
":",
"matching_nodes",
"=",
"[",
"]",
"for",
"n",
"in",
"self",
".",
"iter_search_nodes",
"(",
"*",
"*",
"conditions",
")",
":",
"matching_nodes",
".",
"append",
"(",
"n",
")",
"retu... | Returns the list of nodes matching a given set of conditions.
**Example:**
tree.search_nodes(dist=0.0, name="human") | [
"Returns",
"the",
"list",
"of",
"nodes",
"matching",
"a",
"given",
"set",
"of",
"conditions",
".",
"**",
"Example",
":",
"**",
"tree",
".",
"search_nodes",
"(",
"dist",
"=",
"0",
".",
"0",
"name",
"=",
"human",
")"
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L844-L853 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_distance | def get_distance(self, target, target2=None, topology_only=False):
"""
Returns the distance between two nodes. If only one target is
specified, it returns the distance bewtween the target and the
current node.
Parameters:
-----------
target:
a no... | python | def get_distance(self, target, target2=None, topology_only=False):
"""
Returns the distance between two nodes. If only one target is
specified, it returns the distance bewtween the target and the
current node.
Parameters:
-----------
target:
a no... | [
"def",
"get_distance",
"(",
"self",
",",
"target",
",",
"target2",
"=",
"None",
",",
"topology_only",
"=",
"False",
")",
":",
"if",
"target2",
"is",
"None",
":",
"target2",
"=",
"self",
"root",
"=",
"self",
".",
"get_tree_root",
"(",
")",
"else",
":",
... | Returns the distance between two nodes. If only one target is
specified, it returns the distance bewtween the target and the
current node.
Parameters:
-----------
target:
a node within the same tree structure.
target2:
a node within the sam... | [
"Returns",
"the",
"distance",
"between",
"two",
"nodes",
".",
"If",
"only",
"one",
"target",
"is",
"specified",
"it",
"returns",
"the",
"distance",
"bewtween",
"the",
"target",
"and",
"the",
"current",
"node",
".",
"Parameters",
":",
"-----------",
"target",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L879-L923 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_farthest_node | def get_farthest_node(self, topology_only=False):
"""
Returns the node's farthest descendant or ancestor node, and the
distance to it.
:argument False topology_only: If set to True, distance
between nodes will be referred to the number of nodes
between them. In other... | python | def get_farthest_node(self, topology_only=False):
"""
Returns the node's farthest descendant or ancestor node, and the
distance to it.
:argument False topology_only: If set to True, distance
between nodes will be referred to the number of nodes
between them. In other... | [
"def",
"get_farthest_node",
"(",
"self",
",",
"topology_only",
"=",
"False",
")",
":",
"# Init fasthest node to current farthest leaf",
"farthest_node",
",",
"farthest_dist",
"=",
"self",
".",
"get_farthest_leaf",
"(",
"topology_only",
"=",
"topology_only",
")",
"prev",... | Returns the node's farthest descendant or ancestor node, and the
distance to it.
:argument False topology_only: If set to True, distance
between nodes will be referred to the number of nodes
between them. In other words, topological distance will be
used instead of branch ... | [
"Returns",
"the",
"node",
"s",
"farthest",
"descendant",
"or",
"ancestor",
"node",
"and",
"the",
"distance",
"to",
"it",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L926-L969 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_farthest_leaf | def get_farthest_leaf(self, topology_only=False, is_leaf_fn=None):
"""
Returns node's farthest descendant node (which is always a leaf), and the
distance to it.
:argument False topology_only: If set to True, distance
between nodes will be referred to the number of nodes
... | python | def get_farthest_leaf(self, topology_only=False, is_leaf_fn=None):
"""
Returns node's farthest descendant node (which is always a leaf), and the
distance to it.
:argument False topology_only: If set to True, distance
between nodes will be referred to the number of nodes
... | [
"def",
"get_farthest_leaf",
"(",
"self",
",",
"topology_only",
"=",
"False",
",",
"is_leaf_fn",
"=",
"None",
")",
":",
"min_node",
",",
"min_dist",
",",
"max_node",
",",
"max_dist",
"=",
"self",
".",
"_get_farthest_and_closest_leaves",
"(",
"topology_only",
"=",... | Returns node's farthest descendant node (which is always a leaf), and the
distance to it.
:argument False topology_only: If set to True, distance
between nodes will be referred to the number of nodes
between them. In other words, topological distance will be
used instead o... | [
"Returns",
"node",
"s",
"farthest",
"descendant",
"node",
"(",
"which",
"is",
"always",
"a",
"leaf",
")",
"and",
"the",
"distance",
"to",
"it",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1001-L1016 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_midpoint_outgroup | def get_midpoint_outgroup(self):
"""
Returns the node that divides the current tree into two
distance-balanced partitions.
"""
# Gets the farthest node to the current root
root = self.get_tree_root()
nA, r2A_dist = root.get_farthest_leaf()
nB, A2B_dist = ... | python | def get_midpoint_outgroup(self):
"""
Returns the node that divides the current tree into two
distance-balanced partitions.
"""
# Gets the farthest node to the current root
root = self.get_tree_root()
nA, r2A_dist = root.get_farthest_leaf()
nB, A2B_dist = ... | [
"def",
"get_midpoint_outgroup",
"(",
"self",
")",
":",
"# Gets the farthest node to the current root",
"root",
"=",
"self",
".",
"get_tree_root",
"(",
")",
"nA",
",",
"r2A_dist",
"=",
"root",
".",
"get_farthest_leaf",
"(",
")",
"nB",
",",
"A2B_dist",
"=",
"nA",
... | Returns the node that divides the current tree into two
distance-balanced partitions. | [
"Returns",
"the",
"node",
"that",
"divides",
"the",
"current",
"tree",
"into",
"two",
"distance",
"-",
"balanced",
"partitions",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1038-L1058 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.populate | def populate(self,
size,
names_library=None,
reuse_names=False,
random_branches=False,
branch_range=(0, 1),
support_range=(0, 1)):
"""
Generates a random topology by populating current node.
:argument None names_library: If provided, names lib... | python | def populate(self,
size,
names_library=None,
reuse_names=False,
random_branches=False,
branch_range=(0, 1),
support_range=(0, 1)):
"""
Generates a random topology by populating current node.
:argument None names_library: If provided, names lib... | [
"def",
"populate",
"(",
"self",
",",
"size",
",",
"names_library",
"=",
"None",
",",
"reuse_names",
"=",
"False",
",",
"random_branches",
"=",
"False",
",",
"branch_range",
"=",
"(",
"0",
",",
"1",
")",
",",
"support_range",
"=",
"(",
"0",
",",
"1",
... | Generates a random topology by populating current node.
:argument None names_library: If provided, names library
(list, set, dict, etc.) will be used to name nodes.
:argument False reuse_names: If True, node names will not be
necessarily unique, which makes the process a bit more
... | [
"Generates",
"a",
"random",
"topology",
"by",
"populating",
"current",
"node",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1061-L1137 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.set_outgroup | def set_outgroup(self, outgroup):
"""
Sets a descendant node as the outgroup of a tree. This function
can be used to root a tree or even an internal node.
Parameters:
-----------
outgroup:
a node instance within the same tree structure that will be
... | python | def set_outgroup(self, outgroup):
"""
Sets a descendant node as the outgroup of a tree. This function
can be used to root a tree or even an internal node.
Parameters:
-----------
outgroup:
a node instance within the same tree structure that will be
... | [
"def",
"set_outgroup",
"(",
"self",
",",
"outgroup",
")",
":",
"outgroup",
"=",
"_translate_nodes",
"(",
"self",
",",
"outgroup",
")",
"if",
"self",
"==",
"outgroup",
":",
"##return",
"## why raise an error for this?",
"raise",
"TreeError",
"(",
"\"Cannot set myse... | Sets a descendant node as the outgroup of a tree. This function
can be used to root a tree or even an internal node.
Parameters:
-----------
outgroup:
a node instance within the same tree structure that will be
used as a basal node. | [
"Sets",
"a",
"descendant",
"node",
"as",
"the",
"outgroup",
"of",
"a",
"tree",
".",
"This",
"function",
"can",
"be",
"used",
"to",
"root",
"a",
"tree",
"or",
"even",
"an",
"internal",
"node",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1140-L1226 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.unroot | def unroot(self):
"""
Unroots current node. This function is expected to be used on
the absolute tree root node, but it can be also be applied to
any other internal node. It will convert a split into a
multifurcation.
"""
if len(self.children)==2:
if n... | python | def unroot(self):
"""
Unroots current node. This function is expected to be used on
the absolute tree root node, but it can be also be applied to
any other internal node. It will convert a split into a
multifurcation.
"""
if len(self.children)==2:
if n... | [
"def",
"unroot",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"children",
")",
"==",
"2",
":",
"if",
"not",
"self",
".",
"children",
"[",
"0",
"]",
".",
"is_leaf",
"(",
")",
":",
"self",
".",
"children",
"[",
"0",
"]",
".",
"delete",
... | Unroots current node. This function is expected to be used on
the absolute tree root node, but it can be also be applied to
any other internal node. It will convert a split into a
multifurcation. | [
"Unroots",
"current",
"node",
".",
"This",
"function",
"is",
"expected",
"to",
"be",
"used",
"on",
"the",
"absolute",
"tree",
"root",
"node",
"but",
"it",
"can",
"be",
"also",
"be",
"applied",
"to",
"any",
"other",
"internal",
"node",
".",
"It",
"will",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1229-L1242 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode._asciiArt | def _asciiArt(self, char1='-', show_internal=True, compact=False, attributes=None):
"""
Returns the ASCII representation of the tree.
Code based on the PyCogent GPL project.
"""
if not attributes:
attributes = ["name"]
# toytree edit:
# remove... | python | def _asciiArt(self, char1='-', show_internal=True, compact=False, attributes=None):
"""
Returns the ASCII representation of the tree.
Code based on the PyCogent GPL project.
"""
if not attributes:
attributes = ["name"]
# toytree edit:
# remove... | [
"def",
"_asciiArt",
"(",
"self",
",",
"char1",
"=",
"'-'",
",",
"show_internal",
"=",
"True",
",",
"compact",
"=",
"False",
",",
"attributes",
"=",
"None",
")",
":",
"if",
"not",
"attributes",
":",
"attributes",
"=",
"[",
"\"name\"",
"]",
"# toytree edit... | Returns the ASCII representation of the tree.
Code based on the PyCogent GPL project. | [
"Returns",
"the",
"ASCII",
"representation",
"of",
"the",
"tree",
".",
"Code",
"based",
"on",
"the",
"PyCogent",
"GPL",
"project",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1245-L1291 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_ascii | def get_ascii(self, show_internal=True, compact=False, attributes=None):
"""
Returns a string containing an ascii drawing of the tree.
Parameters:
-----------
show_internal:
include internal edge names.
compact:
use exactly one line per ... | python | def get_ascii(self, show_internal=True, compact=False, attributes=None):
"""
Returns a string containing an ascii drawing of the tree.
Parameters:
-----------
show_internal:
include internal edge names.
compact:
use exactly one line per ... | [
"def",
"get_ascii",
"(",
"self",
",",
"show_internal",
"=",
"True",
",",
"compact",
"=",
"False",
",",
"attributes",
"=",
"None",
")",
":",
"(",
"lines",
",",
"mid",
")",
"=",
"self",
".",
"_asciiArt",
"(",
"show_internal",
"=",
"show_internal",
",",
"... | Returns a string containing an ascii drawing of the tree.
Parameters:
-----------
show_internal:
include internal edge names.
compact:
use exactly one line per tip.
attributes:
A list of node attributes to shown in the ASCII represe... | [
"Returns",
"a",
"string",
"containing",
"an",
"ascii",
"drawing",
"of",
"the",
"tree",
".",
"Parameters",
":",
"-----------",
"show_internal",
":",
"include",
"internal",
"edge",
"names",
".",
"compact",
":",
"use",
"exactly",
"one",
"line",
"per",
"tip",
".... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1294-L1310 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.ladderize | def ladderize(self, direction=0):
"""
Sort the branches of a given tree (swapping children nodes)
according to the size of each partition.
"""
if not self.is_leaf():
n2s = {}
for n in self.get_children():
s = n.ladderize(direction=direction... | python | def ladderize(self, direction=0):
"""
Sort the branches of a given tree (swapping children nodes)
according to the size of each partition.
"""
if not self.is_leaf():
n2s = {}
for n in self.get_children():
s = n.ladderize(direction=direction... | [
"def",
"ladderize",
"(",
"self",
",",
"direction",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"is_leaf",
"(",
")",
":",
"n2s",
"=",
"{",
"}",
"for",
"n",
"in",
"self",
".",
"get_children",
"(",
")",
":",
"s",
"=",
"n",
".",
"ladderize",
"(",... | Sort the branches of a given tree (swapping children nodes)
according to the size of each partition. | [
"Sort",
"the",
"branches",
"of",
"a",
"given",
"tree",
"(",
"swapping",
"children",
"nodes",
")",
"according",
"to",
"the",
"size",
"of",
"each",
"partition",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1313-L1330 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.sort_descendants | def sort_descendants(self, attr="name"):
"""
This function sort the branches of a given tree by
considerening node names. After the tree is sorted, nodes are
labeled using ascendent numbers. This can be used to ensure
that nodes in a tree with the same node names are always
... | python | def sort_descendants(self, attr="name"):
"""
This function sort the branches of a given tree by
considerening node names. After the tree is sorted, nodes are
labeled using ascendent numbers. This can be used to ensure
that nodes in a tree with the same node names are always
... | [
"def",
"sort_descendants",
"(",
"self",
",",
"attr",
"=",
"\"name\"",
")",
":",
"node2content",
"=",
"self",
".",
"get_cached_content",
"(",
"store_attr",
"=",
"attr",
",",
"container_type",
"=",
"list",
")",
"for",
"n",
"in",
"self",
".",
"traverse",
"(",... | This function sort the branches of a given tree by
considerening node names. After the tree is sorted, nodes are
labeled using ascendent numbers. This can be used to ensure
that nodes in a tree with the same node names are always
labeled in the same way. Note that if duplicated names ar... | [
"This",
"function",
"sort",
"the",
"branches",
"of",
"a",
"given",
"tree",
"by",
"considerening",
"node",
"names",
".",
"After",
"the",
"tree",
"is",
"sorted",
"nodes",
"are",
"labeled",
"using",
"ascendent",
"numbers",
".",
"This",
"can",
"be",
"used",
"t... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1333-L1347 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_cached_content | def get_cached_content(self, store_attr=None, container_type=set, _store=None):
"""
Returns a dictionary pointing to the preloaded content of each
internal node under this tree. Such a dictionary is intended
to work as a cache for operations that require many traversal
operations... | python | def get_cached_content(self, store_attr=None, container_type=set, _store=None):
"""
Returns a dictionary pointing to the preloaded content of each
internal node under this tree. Such a dictionary is intended
to work as a cache for operations that require many traversal
operations... | [
"def",
"get_cached_content",
"(",
"self",
",",
"store_attr",
"=",
"None",
",",
"container_type",
"=",
"set",
",",
"_store",
"=",
"None",
")",
":",
"if",
"_store",
"is",
"None",
":",
"_store",
"=",
"{",
"}",
"for",
"ch",
"in",
"self",
".",
"children",
... | Returns a dictionary pointing to the preloaded content of each
internal node under this tree. Such a dictionary is intended
to work as a cache for operations that require many traversal
operations.
Parameters:
-----------
store_attr:
Specifies the no... | [
"Returns",
"a",
"dictionary",
"pointing",
"to",
"the",
"preloaded",
"content",
"of",
"each",
"internal",
"node",
"under",
"this",
"tree",
".",
"Such",
"a",
"dictionary",
"is",
"intended",
"to",
"work",
"as",
"a",
"cache",
"for",
"operations",
"that",
"requir... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1350-L1385 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.robinson_foulds | def robinson_foulds(self,
t2,
attr_t1="name",
attr_t2="name",
unrooted_trees=False,
expand_polytomies=False,
polytomy_size_limit=5,
skip_large_polytomies=False,
correct_by_polytomy_size=False,
min_support_t1=0.0,
min_support_t2=0.0):
... | python | def robinson_foulds(self,
t2,
attr_t1="name",
attr_t2="name",
unrooted_trees=False,
expand_polytomies=False,
polytomy_size_limit=5,
skip_large_polytomies=False,
correct_by_polytomy_size=False,
min_support_t1=0.0,
min_support_t2=0.0):
... | [
"def",
"robinson_foulds",
"(",
"self",
",",
"t2",
",",
"attr_t1",
"=",
"\"name\"",
",",
"attr_t2",
"=",
"\"name\"",
",",
"unrooted_trees",
"=",
"False",
",",
"expand_polytomies",
"=",
"False",
",",
"polytomy_size_limit",
"=",
"5",
",",
"skip_large_polytomies",
... | Returns the Robinson-Foulds symmetric distance between current
tree and a different tree instance.
Parameters:
-----------
t2:
reference tree
attr_t1:
Compare trees using a custom node attribute as a node name.
attr_t2:
Compare tree... | [
"Returns",
"the",
"Robinson",
"-",
"Foulds",
"symmetric",
"distance",
"between",
"current",
"tree",
"and",
"a",
"different",
"tree",
"instance",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1391-L1567 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.iter_edges | def iter_edges(self, cached_content=None):
"""
Iterate over the list of edges of a tree. Each egde is represented as a
tuple of two elements, each containing the list of nodes separated by
the edge.
"""
if not cached_content:
cached_content = self.get_cached_c... | python | def iter_edges(self, cached_content=None):
"""
Iterate over the list of edges of a tree. Each egde is represented as a
tuple of two elements, each containing the list of nodes separated by
the edge.
"""
if not cached_content:
cached_content = self.get_cached_c... | [
"def",
"iter_edges",
"(",
"self",
",",
"cached_content",
"=",
"None",
")",
":",
"if",
"not",
"cached_content",
":",
"cached_content",
"=",
"self",
".",
"get_cached_content",
"(",
")",
"all_leaves",
"=",
"cached_content",
"[",
"self",
"]",
"for",
"n",
",",
... | Iterate over the list of edges of a tree. Each egde is represented as a
tuple of two elements, each containing the list of nodes separated by
the edge. | [
"Iterate",
"over",
"the",
"list",
"of",
"edges",
"of",
"a",
"tree",
".",
"Each",
"egde",
"is",
"represented",
"as",
"a",
"tuple",
"of",
"two",
"elements",
"each",
"containing",
"the",
"list",
"of",
"nodes",
"separated",
"by",
"the",
"edge",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1755-L1765 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_topology_id | def get_topology_id(self, attr="name"):
"""
Returns the unique ID representing the topology of the current tree.
Two trees with the same topology will produce the same id. If trees are
unrooted, make sure that the root node is not binary or use the
tree.unroot() function before ... | python | def get_topology_id(self, attr="name"):
"""
Returns the unique ID representing the topology of the current tree.
Two trees with the same topology will produce the same id. If trees are
unrooted, make sure that the root node is not binary or use the
tree.unroot() function before ... | [
"def",
"get_topology_id",
"(",
"self",
",",
"attr",
"=",
"\"name\"",
")",
":",
"edge_keys",
"=",
"[",
"]",
"for",
"s1",
",",
"s2",
"in",
"self",
".",
"get_edges",
"(",
")",
":",
"k1",
"=",
"sorted",
"(",
"[",
"getattr",
"(",
"e",
",",
"attr",
")"... | Returns the unique ID representing the topology of the current tree.
Two trees with the same topology will produce the same id. If trees are
unrooted, make sure that the root node is not binary or use the
tree.unroot() function before generating the topology id.
This is useful to detec... | [
"Returns",
"the",
"unique",
"ID",
"representing",
"the",
"topology",
"of",
"the",
"current",
"tree",
".",
"Two",
"trees",
"with",
"the",
"same",
"topology",
"will",
"produce",
"the",
"same",
"id",
".",
"If",
"trees",
"are",
"unrooted",
"make",
"sure",
"tha... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1789-L1807 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.check_monophyly | def check_monophyly(self,
values,
target_attr,
ignore_missing=False,
unrooted=False):
"""
Returns True if a given target attribute is monophyletic under
this node for the provided set of values.
If not all values are represented in the current tree
... | python | def check_monophyly(self,
values,
target_attr,
ignore_missing=False,
unrooted=False):
"""
Returns True if a given target attribute is monophyletic under
this node for the provided set of values.
If not all values are represented in the current tree
... | [
"def",
"check_monophyly",
"(",
"self",
",",
"values",
",",
"target_attr",
",",
"ignore_missing",
"=",
"False",
",",
"unrooted",
"=",
"False",
")",
":",
"if",
"type",
"(",
"values",
")",
"!=",
"set",
":",
"values",
"=",
"set",
"(",
"values",
")",
"# Thi... | Returns True if a given target attribute is monophyletic under
this node for the provided set of values.
If not all values are represented in the current tree
structure, a ValueError exception will be raised to warn that
strict monophyly could never be reached (this behaviour can be
... | [
"Returns",
"True",
"if",
"a",
"given",
"target",
"attribute",
"is",
"monophyletic",
"under",
"this",
"node",
"for",
"the",
"provided",
"set",
"of",
"values",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1845-L1939 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.get_monophyletic | def get_monophyletic(self, values, target_attr):
"""
Returns a list of nodes matching the provided monophyly
criteria. For a node to be considered a match, all
`target_attr` values within and node, and exclusively them,
should be grouped.
:param values: a set of values f... | python | def get_monophyletic(self, values, target_attr):
"""
Returns a list of nodes matching the provided monophyly
criteria. For a node to be considered a match, all
`target_attr` values within and node, and exclusively them,
should be grouped.
:param values: a set of values f... | [
"def",
"get_monophyletic",
"(",
"self",
",",
"values",
",",
"target_attr",
")",
":",
"if",
"type",
"(",
"values",
")",
"!=",
"set",
":",
"values",
"=",
"set",
"(",
"values",
")",
"n2values",
"=",
"self",
".",
"get_cached_content",
"(",
"store_attr",
"=",... | Returns a list of nodes matching the provided monophyly
criteria. For a node to be considered a match, all
`target_attr` values within and node, and exclusively them,
should be grouped.
:param values: a set of values for which monophyly is
expected.
:param target_at... | [
"Returns",
"a",
"list",
"of",
"nodes",
"matching",
"the",
"provided",
"monophyly",
"criteria",
".",
"For",
"a",
"node",
"to",
"be",
"considered",
"a",
"match",
"all",
"target_attr",
"values",
"within",
"and",
"node",
"and",
"exclusively",
"them",
"should",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1942-L1964 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.expand_polytomies | def expand_polytomies(self,
map_attr="name",
polytomy_size_limit=5,
skip_large_polytomies=False):
"""
Given a tree with one or more polytomies, this functions returns the
list of all trees (in newick format) resulting from the combination of
all possible solutio... | python | def expand_polytomies(self,
map_attr="name",
polytomy_size_limit=5,
skip_large_polytomies=False):
"""
Given a tree with one or more polytomies, this functions returns the
list of all trees (in newick format) resulting from the combination of
all possible solutio... | [
"def",
"expand_polytomies",
"(",
"self",
",",
"map_attr",
"=",
"\"name\"",
",",
"polytomy_size_limit",
"=",
"5",
",",
"skip_large_polytomies",
"=",
"False",
")",
":",
"class",
"TipTuple",
"(",
"tuple",
")",
":",
"pass",
"def",
"add_leaf",
"(",
"tree",
",",
... | Given a tree with one or more polytomies, this functions returns the
list of all trees (in newick format) resulting from the combination of
all possible solutions of the multifurcated nodes.
.. warning:
Please note that the number of of possible binary trees grows
exponen... | [
"Given",
"a",
"tree",
"with",
"one",
"or",
"more",
"polytomies",
"this",
"functions",
"returns",
"the",
"list",
"of",
"all",
"trees",
"(",
"in",
"newick",
"format",
")",
"resulting",
"from",
"the",
"combination",
"of",
"all",
"possible",
"solutions",
"of",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L1967-L2029 | train |
eaton-lab/toytree | toytree/etemini.py | TreeNode.resolve_polytomy | def resolve_polytomy(self,
default_dist=0.0,
default_support=0.0,
recursive=True):
"""
Resolve all polytomies under current node by creating an
arbitrary dicotomic structure among the affected nodes. This
function randomly modifies current tree topology and shou... | python | def resolve_polytomy(self,
default_dist=0.0,
default_support=0.0,
recursive=True):
"""
Resolve all polytomies under current node by creating an
arbitrary dicotomic structure among the affected nodes. This
function randomly modifies current tree topology and shou... | [
"def",
"resolve_polytomy",
"(",
"self",
",",
"default_dist",
"=",
"0.0",
",",
"default_support",
"=",
"0.0",
",",
"recursive",
"=",
"True",
")",
":",
"def",
"_resolve",
"(",
"node",
")",
":",
"if",
"len",
"(",
"node",
".",
"children",
")",
">",
"2",
... | Resolve all polytomies under current node by creating an
arbitrary dicotomic structure among the affected nodes. This
function randomly modifies current tree topology and should
only be used for compatibility reasons (i.e. programs
rejecting multifurcated node in the newick representatio... | [
"Resolve",
"all",
"polytomies",
"under",
"current",
"node",
"by",
"creating",
"an",
"arbitrary",
"dicotomic",
"structure",
"among",
"the",
"affected",
"nodes",
".",
"This",
"function",
"randomly",
"modifies",
"current",
"tree",
"topology",
"and",
"should",
"only",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/etemini.py#L2032-L2071 | train |
doakey3/DashTable | dashtable/simple2data/truncate_empty_lines.py | truncate_empty_lines | def truncate_empty_lines(lines):
"""
Removes all empty lines from above and below the text.
We can't just use text.strip() because that would remove the leading
space for the table.
Parameters
----------
lines : list of str
Returns
-------
lines : list of str
The text ... | python | def truncate_empty_lines(lines):
"""
Removes all empty lines from above and below the text.
We can't just use text.strip() because that would remove the leading
space for the table.
Parameters
----------
lines : list of str
Returns
-------
lines : list of str
The text ... | [
"def",
"truncate_empty_lines",
"(",
"lines",
")",
":",
"while",
"lines",
"[",
"0",
"]",
".",
"rstrip",
"(",
")",
"==",
"''",
":",
"lines",
".",
"pop",
"(",
"0",
")",
"while",
"lines",
"[",
"len",
"(",
"lines",
")",
"-",
"1",
"]",
".",
"rstrip",
... | Removes all empty lines from above and below the text.
We can't just use text.strip() because that would remove the leading
space for the table.
Parameters
----------
lines : list of str
Returns
-------
lines : list of str
The text lines without empty lines above or below | [
"Removes",
"all",
"empty",
"lines",
"from",
"above",
"and",
"below",
"the",
"text",
"."
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/simple2data/truncate_empty_lines.py#L1-L21 | train |
quantmind/dynts | dynts/lib/fallback/dates.py | jstimestamp_slow | def jstimestamp_slow(dte):
'''Convert a date or datetime object into a javsacript timestamp'''
year, month, day, hour, minute, second = dte.timetuple()[:6]
days = date(year, month, 1).toordinal() - _EPOCH_ORD + day - 1
hours = days*24 + hour
minutes = hours*60 + minute
seconds = minutes*60... | python | def jstimestamp_slow(dte):
'''Convert a date or datetime object into a javsacript timestamp'''
year, month, day, hour, minute, second = dte.timetuple()[:6]
days = date(year, month, 1).toordinal() - _EPOCH_ORD + day - 1
hours = days*24 + hour
minutes = hours*60 + minute
seconds = minutes*60... | [
"def",
"jstimestamp_slow",
"(",
"dte",
")",
":",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
"=",
"dte",
".",
"timetuple",
"(",
")",
"[",
":",
"6",
"]",
"days",
"=",
"date",
"(",
"year",
",",
"month",
",",
"1",
... | Convert a date or datetime object into a javsacript timestamp | [
"Convert",
"a",
"date",
"or",
"datetime",
"object",
"into",
"a",
"javsacript",
"timestamp"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/dates.py#L7-L17 | train |
quantmind/dynts | dynts/lib/fallback/dates.py | jstimestamp | def jstimestamp(dte):
'''Convert a date or datetime object into a javsacript timestamp.'''
days = date(dte.year, dte.month, 1).toordinal() - _EPOCH_ORD + dte.day - 1
hours = days*24
if isinstance(dte,datetime):
hours += dte.hour
minutes = hours*60 + dte.minute
second... | python | def jstimestamp(dte):
'''Convert a date or datetime object into a javsacript timestamp.'''
days = date(dte.year, dte.month, 1).toordinal() - _EPOCH_ORD + dte.day - 1
hours = days*24
if isinstance(dte,datetime):
hours += dte.hour
minutes = hours*60 + dte.minute
second... | [
"def",
"jstimestamp",
"(",
"dte",
")",
":",
"days",
"=",
"date",
"(",
"dte",
".",
"year",
",",
"dte",
".",
"month",
",",
"1",
")",
".",
"toordinal",
"(",
")",
"-",
"_EPOCH_ORD",
"+",
"dte",
".",
"day",
"-",
"1",
"hours",
"=",
"days",
"*",
"24",... | Convert a date or datetime object into a javsacript timestamp. | [
"Convert",
"a",
"date",
"or",
"datetime",
"object",
"into",
"a",
"javsacript",
"timestamp",
"."
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/dates.py#L21-L32 | train |
doakey3/DashTable | dashtable/html2rst.py | html2rst | def html2rst(html_string, force_headers=False, center_cells=False,
center_headers=False):
"""
Convert a string or html file to an rst table string.
Parameters
----------
html_string : str
Either the html string, or the filepath to the html
force_headers : bool
Make ... | python | def html2rst(html_string, force_headers=False, center_cells=False,
center_headers=False):
"""
Convert a string or html file to an rst table string.
Parameters
----------
html_string : str
Either the html string, or the filepath to the html
force_headers : bool
Make ... | [
"def",
"html2rst",
"(",
"html_string",
",",
"force_headers",
"=",
"False",
",",
"center_cells",
"=",
"False",
",",
"center_headers",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"html_string",
")",
":",
"file",
"=",
"open",
"(",
... | Convert a string or html file to an rst table string.
Parameters
----------
html_string : str
Either the html string, or the filepath to the html
force_headers : bool
Make the first row become headers, whether or not they are
headers in the html file.
center_cells : bool
... | [
"Convert",
"a",
"string",
"or",
"html",
"file",
"to",
"an",
"rst",
"table",
"string",
"."
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2rst.py#L6-L91 | train |
doakey3/DashTable | dashtable/dashutils/make_span.py | make_span | def make_span(row, column, extra_rows, extra_columns):
"""
Create a list of rows and columns that will make up a span
Parameters
----------
row : int
The row of the first cell in the span
column : int
The column of the first cell in the span
extra_rows : int
The numb... | python | def make_span(row, column, extra_rows, extra_columns):
"""
Create a list of rows and columns that will make up a span
Parameters
----------
row : int
The row of the first cell in the span
column : int
The column of the first cell in the span
extra_rows : int
The numb... | [
"def",
"make_span",
"(",
"row",
",",
"column",
",",
"extra_rows",
",",
"extra_columns",
")",
":",
"span",
"=",
"[",
"[",
"row",
",",
"column",
"]",
"]",
"for",
"r",
"in",
"range",
"(",
"row",
",",
"row",
"+",
"extra_rows",
"+",
"1",
")",
":",
"sp... | Create a list of rows and columns that will make up a span
Parameters
----------
row : int
The row of the first cell in the span
column : int
The column of the first cell in the span
extra_rows : int
The number of rows that make up the span
extra_columns : int
Th... | [
"Create",
"a",
"list",
"of",
"rows",
"and",
"columns",
"that",
"will",
"make",
"up",
"a",
"span"
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/make_span.py#L1-L30 | train |
doakey3/DashTable | dashtable/data2rst/make_cell.py | make_cell | def make_cell(table, span, widths, heights, use_headers):
"""
Convert the contents of a span of the table to a grid table cell
Parameters
----------
table : list of lists of str
The table of rows containg strings to convert to a grid table
span : list of lists of int
list of [ro... | python | def make_cell(table, span, widths, heights, use_headers):
"""
Convert the contents of a span of the table to a grid table cell
Parameters
----------
table : list of lists of str
The table of rows containg strings to convert to a grid table
span : list of lists of int
list of [ro... | [
"def",
"make_cell",
"(",
"table",
",",
"span",
",",
"widths",
",",
"heights",
",",
"use_headers",
")",
":",
"width",
"=",
"get_span_char_width",
"(",
"span",
",",
"widths",
")",
"height",
"=",
"get_span_char_height",
"(",
"span",
",",
"heights",
")",
"text... | Convert the contents of a span of the table to a grid table cell
Parameters
----------
table : list of lists of str
The table of rows containg strings to convert to a grid table
span : list of lists of int
list of [row, column] pairs that make up a span in the table
widths : list of... | [
"Convert",
"the",
"contents",
"of",
"a",
"span",
"of",
"the",
"table",
"to",
"a",
"grid",
"table",
"cell"
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/make_cell.py#L9-L70 | train |
inveniosoftware/invenio-db | invenio_db/ext.py | InvenioDB.init_app | def init_app(self, app, **kwargs):
"""Initialize application object."""
self.init_db(app, **kwargs)
app.config.setdefault('ALEMBIC', {
'script_location': pkg_resources.resource_filename(
'invenio_db', 'alembic'
),
'version_locations': [
... | python | def init_app(self, app, **kwargs):
"""Initialize application object."""
self.init_db(app, **kwargs)
app.config.setdefault('ALEMBIC', {
'script_location': pkg_resources.resource_filename(
'invenio_db', 'alembic'
),
'version_locations': [
... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"init_db",
"(",
"app",
",",
"*",
"*",
"kwargs",
")",
"app",
".",
"config",
".",
"setdefault",
"(",
"'ALEMBIC'",
",",
"{",
"'script_location'",
":",
"pkg_resou... | Initialize application object. | [
"Initialize",
"application",
"object",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/ext.py#L34-L53 | train |
inveniosoftware/invenio-db | invenio_db/ext.py | InvenioDB.init_db | def init_db(self, app, entry_point_group='invenio_db.models', **kwargs):
"""Initialize Flask-SQLAlchemy extension."""
# Setup SQLAlchemy
app.config.setdefault(
'SQLALCHEMY_DATABASE_URI',
'sqlite:///' + os.path.join(app.instance_path, app.name + '.db')
)
ap... | python | def init_db(self, app, entry_point_group='invenio_db.models', **kwargs):
"""Initialize Flask-SQLAlchemy extension."""
# Setup SQLAlchemy
app.config.setdefault(
'SQLALCHEMY_DATABASE_URI',
'sqlite:///' + os.path.join(app.instance_path, app.name + '.db')
)
ap... | [
"def",
"init_db",
"(",
"self",
",",
"app",
",",
"entry_point_group",
"=",
"'invenio_db.models'",
",",
"*",
"*",
"kwargs",
")",
":",
"# Setup SQLAlchemy",
"app",
".",
"config",
".",
"setdefault",
"(",
"'SQLALCHEMY_DATABASE_URI'",
",",
"'sqlite:///'",
"+",
"os",
... | Initialize Flask-SQLAlchemy extension. | [
"Initialize",
"Flask",
"-",
"SQLAlchemy",
"extension",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/ext.py#L55-L88 | train |
inveniosoftware/invenio-db | invenio_db/ext.py | InvenioDB.init_versioning | def init_versioning(self, app, database, versioning_manager=None):
"""Initialize the versioning support using SQLAlchemy-Continuum."""
try:
pkg_resources.get_distribution('sqlalchemy_continuum')
except pkg_resources.DistributionNotFound: # pragma: no cover
default_versio... | python | def init_versioning(self, app, database, versioning_manager=None):
"""Initialize the versioning support using SQLAlchemy-Continuum."""
try:
pkg_resources.get_distribution('sqlalchemy_continuum')
except pkg_resources.DistributionNotFound: # pragma: no cover
default_versio... | [
"def",
"init_versioning",
"(",
"self",
",",
"app",
",",
"database",
",",
"versioning_manager",
"=",
"None",
")",
":",
"try",
":",
"pkg_resources",
".",
"get_distribution",
"(",
"'sqlalchemy_continuum'",
")",
"except",
"pkg_resources",
".",
"DistributionNotFound",
... | Initialize the versioning support using SQLAlchemy-Continuum. | [
"Initialize",
"the",
"versioning",
"support",
"using",
"SQLAlchemy",
"-",
"Continuum",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/ext.py#L90-L142 | train |
doakey3/DashTable | dashtable/html2data/extract_table.py | extract_table | def extract_table(html_string, row_count, column_count):
"""
Convert an html string to data table
Parameters
----------
html_string : str
row_count : int
column_count : int
Returns
-------
data_table : list of lists of str
"""
try:
from bs4 import BeautifulSoup
... | python | def extract_table(html_string, row_count, column_count):
"""
Convert an html string to data table
Parameters
----------
html_string : str
row_count : int
column_count : int
Returns
-------
data_table : list of lists of str
"""
try:
from bs4 import BeautifulSoup
... | [
"def",
"extract_table",
"(",
"html_string",
",",
"row_count",
",",
"column_count",
")",
":",
"try",
":",
"from",
"bs4",
"import",
"BeautifulSoup",
"from",
"bs4",
".",
"element",
"import",
"Tag",
"except",
"ImportError",
":",
"print",
"(",
"\"ERROR: You must have... | Convert an html string to data table
Parameters
----------
html_string : str
row_count : int
column_count : int
Returns
-------
data_table : list of lists of str | [
"Convert",
"an",
"html",
"string",
"to",
"data",
"table"
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/extract_table.py#L4-L92 | train |
inveniosoftware/invenio-db | invenio_db/shared.py | do_sqlite_connect | def do_sqlite_connect(dbapi_connection, connection_record):
"""Ensure SQLite checks foreign key constraints.
For further details see "Foreign key support" sections on
https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#foreign-key-support
"""
# Enable foreign key constraint checking
curs... | python | def do_sqlite_connect(dbapi_connection, connection_record):
"""Ensure SQLite checks foreign key constraints.
For further details see "Foreign key support" sections on
https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#foreign-key-support
"""
# Enable foreign key constraint checking
curs... | [
"def",
"do_sqlite_connect",
"(",
"dbapi_connection",
",",
"connection_record",
")",
":",
"# Enable foreign key constraint checking",
"cursor",
"=",
"dbapi_connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"'PRAGMA foreign_keys=ON'",
")",
"cursor",
"."... | Ensure SQLite checks foreign key constraints.
For further details see "Foreign key support" sections on
https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#foreign-key-support | [
"Ensure",
"SQLite",
"checks",
"foreign",
"key",
"constraints",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/shared.py#L82-L91 | train |
inveniosoftware/invenio-db | invenio_db/shared.py | SQLAlchemy.apply_driver_hacks | def apply_driver_hacks(self, app, info, options):
"""Call before engine creation."""
# Don't forget to apply hacks defined on parent object.
super(SQLAlchemy, self).apply_driver_hacks(app, info, options)
if info.drivername == 'sqlite':
connect_args = options.setdefault('conn... | python | def apply_driver_hacks(self, app, info, options):
"""Call before engine creation."""
# Don't forget to apply hacks defined on parent object.
super(SQLAlchemy, self).apply_driver_hacks(app, info, options)
if info.drivername == 'sqlite':
connect_args = options.setdefault('conn... | [
"def",
"apply_driver_hacks",
"(",
"self",
",",
"app",
",",
"info",
",",
"options",
")",
":",
"# Don't forget to apply hacks defined on parent object.",
"super",
"(",
"SQLAlchemy",
",",
"self",
")",
".",
"apply_driver_hacks",
"(",
"app",
",",
"info",
",",
"options"... | Call before engine creation. | [
"Call",
"before",
"engine",
"creation",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/shared.py#L32-L79 | train |
inveniosoftware/invenio-db | invenio_db/cli.py | create | def create(verbose):
"""Create tables."""
click.secho('Creating all tables!', fg='yellow', bold=True)
with click.progressbar(_db.metadata.sorted_tables) as bar:
for table in bar:
if verbose:
click.echo(' Creating table {0}'.format(table))
table.create(bind=_db... | python | def create(verbose):
"""Create tables."""
click.secho('Creating all tables!', fg='yellow', bold=True)
with click.progressbar(_db.metadata.sorted_tables) as bar:
for table in bar:
if verbose:
click.echo(' Creating table {0}'.format(table))
table.create(bind=_db... | [
"def",
"create",
"(",
"verbose",
")",
":",
"click",
".",
"secho",
"(",
"'Creating all tables!'",
",",
"fg",
"=",
"'yellow'",
",",
"bold",
"=",
"True",
")",
"with",
"click",
".",
"progressbar",
"(",
"_db",
".",
"metadata",
".",
"sorted_tables",
")",
"as",... | Create tables. | [
"Create",
"tables",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L49-L58 | train |
inveniosoftware/invenio-db | invenio_db/cli.py | drop | def drop(verbose):
"""Drop tables."""
click.secho('Dropping all tables!', fg='red', bold=True)
with click.progressbar(reversed(_db.metadata.sorted_tables)) as bar:
for table in bar:
if verbose:
click.echo(' Dropping table {0}'.format(table))
table.drop(bind=_d... | python | def drop(verbose):
"""Drop tables."""
click.secho('Dropping all tables!', fg='red', bold=True)
with click.progressbar(reversed(_db.metadata.sorted_tables)) as bar:
for table in bar:
if verbose:
click.echo(' Dropping table {0}'.format(table))
table.drop(bind=_d... | [
"def",
"drop",
"(",
"verbose",
")",
":",
"click",
".",
"secho",
"(",
"'Dropping all tables!'",
",",
"fg",
"=",
"'red'",
",",
"bold",
"=",
"True",
")",
"with",
"click",
".",
"progressbar",
"(",
"reversed",
"(",
"_db",
".",
"metadata",
".",
"sorted_tables"... | Drop tables. | [
"Drop",
"tables",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L67-L76 | train |
inveniosoftware/invenio-db | invenio_db/cli.py | init | def init():
"""Create database."""
click.secho('Creating database {0}'.format(_db.engine.url),
fg='green')
if not database_exists(str(_db.engine.url)):
create_database(str(_db.engine.url)) | python | def init():
"""Create database."""
click.secho('Creating database {0}'.format(_db.engine.url),
fg='green')
if not database_exists(str(_db.engine.url)):
create_database(str(_db.engine.url)) | [
"def",
"init",
"(",
")",
":",
"click",
".",
"secho",
"(",
"'Creating database {0}'",
".",
"format",
"(",
"_db",
".",
"engine",
".",
"url",
")",
",",
"fg",
"=",
"'green'",
")",
"if",
"not",
"database_exists",
"(",
"str",
"(",
"_db",
".",
"engine",
"."... | Create database. | [
"Create",
"database",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L81-L86 | train |
inveniosoftware/invenio-db | invenio_db/cli.py | destroy | def destroy():
"""Drop database."""
click.secho('Destroying database {0}'.format(_db.engine.url),
fg='red', bold=True)
if _db.engine.name == 'sqlite':
try:
drop_database(_db.engine.url)
except FileNotFoundError as e:
click.secho('Sqlite database has no... | python | def destroy():
"""Drop database."""
click.secho('Destroying database {0}'.format(_db.engine.url),
fg='red', bold=True)
if _db.engine.name == 'sqlite':
try:
drop_database(_db.engine.url)
except FileNotFoundError as e:
click.secho('Sqlite database has no... | [
"def",
"destroy",
"(",
")",
":",
"click",
".",
"secho",
"(",
"'Destroying database {0}'",
".",
"format",
"(",
"_db",
".",
"engine",
".",
"url",
")",
",",
"fg",
"=",
"'red'",
",",
"bold",
"=",
"True",
")",
"if",
"_db",
".",
"engine",
".",
"name",
"=... | Drop database. | [
"Drop",
"database",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L94-L105 | train |
quantmind/dynts | dynts/stats/rolling.py | rollingOperation.rolling | def rolling(self, op):
"""Fast rolling operation with O(log n) updates where n is the
window size
"""
missing = self.missing
ismissing = self.ismissing
window = self.window
it = iter(self.iterable)
queue = deque(islice(it, window))
ol = self.skip... | python | def rolling(self, op):
"""Fast rolling operation with O(log n) updates where n is the
window size
"""
missing = self.missing
ismissing = self.ismissing
window = self.window
it = iter(self.iterable)
queue = deque(islice(it, window))
ol = self.skip... | [
"def",
"rolling",
"(",
"self",
",",
"op",
")",
":",
"missing",
"=",
"self",
".",
"missing",
"ismissing",
"=",
"self",
".",
"ismissing",
"window",
"=",
"self",
".",
"window",
"it",
"=",
"iter",
"(",
"self",
".",
"iterable",
")",
"queue",
"=",
"deque",... | Fast rolling operation with O(log n) updates where n is the
window size | [
"Fast",
"rolling",
"operation",
"with",
"O",
"(",
"log",
"n",
")",
"updates",
"where",
"n",
"is",
"the",
"window",
"size"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/rolling.py#L65-L83 | train |
doakey3/DashTable | dashtable/dashutils/get_span_column_count.py | get_span_column_count | def get_span_column_count(span):
"""
Find the length of a colspan.
Parameters
----------
span : list of lists of int
The [row, column] pairs that make up the span
Returns
-------
columns : int
The number of columns included in the span
Example
-------
Consi... | python | def get_span_column_count(span):
"""
Find the length of a colspan.
Parameters
----------
span : list of lists of int
The [row, column] pairs that make up the span
Returns
-------
columns : int
The number of columns included in the span
Example
-------
Consi... | [
"def",
"get_span_column_count",
"(",
"span",
")",
":",
"columns",
"=",
"1",
"first_column",
"=",
"span",
"[",
"0",
"]",
"[",
"1",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"span",
")",
")",
":",
"if",
"span",
"[",
"i",
"]",
"[",
"1",
"]"... | Find the length of a colspan.
Parameters
----------
span : list of lists of int
The [row, column] pairs that make up the span
Returns
-------
columns : int
The number of columns included in the span
Example
-------
Consider this table::
+------+-----------... | [
"Find",
"the",
"length",
"of",
"a",
"colspan",
"."
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_column_count.py#L1-L39 | train |
eaton-lab/toytree | toytree/TreeStyle.py | TreeStyle.to_dict | def to_dict(self):
"returns self as a dictionary with _underscore subdicts corrected."
ndict = {}
for key, val in self.__dict__.items():
if key[0] == "_":
ndict[key[1:]] = val
else:
ndict[key] = val
return ndict | python | def to_dict(self):
"returns self as a dictionary with _underscore subdicts corrected."
ndict = {}
for key, val in self.__dict__.items():
if key[0] == "_":
ndict[key[1:]] = val
else:
ndict[key] = val
return ndict | [
"def",
"to_dict",
"(",
"self",
")",
":",
"ndict",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"key",
"[",
"0",
"]",
"==",
"\"_\"",
":",
"ndict",
"[",
"key",
"[",
"1",
":",
"]",
... | returns self as a dictionary with _underscore subdicts corrected. | [
"returns",
"self",
"as",
"a",
"dictionary",
"with",
"_underscore",
"subdicts",
"corrected",
"."
] | 0347ed2098acc5f707fadf52a0ecd411a6d1859c | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeStyle.py#L164-L172 | train |
doakey3/DashTable | dashtable/dashutils/get_span_char_width.py | get_span_char_width | def get_span_char_width(span, column_widths):
"""
Sum the widths of the columns that make up the span, plus the extra.
Parameters
----------
span : list of lists of int
list of [row, column] pairs that make up the span
column_widths : list of int
The widths of the columns that m... | python | def get_span_char_width(span, column_widths):
"""
Sum the widths of the columns that make up the span, plus the extra.
Parameters
----------
span : list of lists of int
list of [row, column] pairs that make up the span
column_widths : list of int
The widths of the columns that m... | [
"def",
"get_span_char_width",
"(",
"span",
",",
"column_widths",
")",
":",
"start_column",
"=",
"span",
"[",
"0",
"]",
"[",
"1",
"]",
"column_count",
"=",
"get_span_column_count",
"(",
"span",
")",
"total_width",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
... | Sum the widths of the columns that make up the span, plus the extra.
Parameters
----------
span : list of lists of int
list of [row, column] pairs that make up the span
column_widths : list of int
The widths of the columns that make up the table
Returns
-------
total_width ... | [
"Sum",
"the",
"widths",
"of",
"the",
"columns",
"that",
"make",
"up",
"the",
"span",
"plus",
"the",
"extra",
"."
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_char_width.py#L4-L30 | train |
inveniosoftware/invenio-db | invenio_db/utils.py | rebuild_encrypted_properties | def rebuild_encrypted_properties(old_key, model, properties):
"""Rebuild a model's EncryptedType properties when the SECRET_KEY is changed.
:param old_key: old SECRET_KEY.
:param model: the affected db model.
:param properties: list of properties to rebuild.
"""
inspector = reflection.Inspector... | python | def rebuild_encrypted_properties(old_key, model, properties):
"""Rebuild a model's EncryptedType properties when the SECRET_KEY is changed.
:param old_key: old SECRET_KEY.
:param model: the affected db model.
:param properties: list of properties to rebuild.
"""
inspector = reflection.Inspector... | [
"def",
"rebuild_encrypted_properties",
"(",
"old_key",
",",
"model",
",",
"properties",
")",
":",
"inspector",
"=",
"reflection",
".",
"Inspector",
".",
"from_engine",
"(",
"db",
".",
"engine",
")",
"primary_key_names",
"=",
"inspector",
".",
"get_primary_keys",
... | Rebuild a model's EncryptedType properties when the SECRET_KEY is changed.
:param old_key: old SECRET_KEY.
:param model: the affected db model.
:param properties: list of properties to rebuild. | [
"Rebuild",
"a",
"model",
"s",
"EncryptedType",
"properties",
"when",
"the",
"SECRET_KEY",
"is",
"changed",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L21-L58 | train |
inveniosoftware/invenio-db | invenio_db/utils.py | create_alembic_version_table | def create_alembic_version_table():
"""Create alembic_version table."""
alembic = current_app.extensions['invenio-db'].alembic
if not alembic.migration_context._has_version_table():
alembic.migration_context._ensure_version_table()
for head in alembic.script_directory.revision_map._real_head... | python | def create_alembic_version_table():
"""Create alembic_version table."""
alembic = current_app.extensions['invenio-db'].alembic
if not alembic.migration_context._has_version_table():
alembic.migration_context._ensure_version_table()
for head in alembic.script_directory.revision_map._real_head... | [
"def",
"create_alembic_version_table",
"(",
")",
":",
"alembic",
"=",
"current_app",
".",
"extensions",
"[",
"'invenio-db'",
"]",
".",
"alembic",
"if",
"not",
"alembic",
".",
"migration_context",
".",
"_has_version_table",
"(",
")",
":",
"alembic",
".",
"migrati... | Create alembic_version table. | [
"Create",
"alembic_version",
"table",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L61-L67 | train |
inveniosoftware/invenio-db | invenio_db/utils.py | drop_alembic_version_table | def drop_alembic_version_table():
"""Drop alembic_version table."""
if _db.engine.dialect.has_table(_db.engine, 'alembic_version'):
alembic_version = _db.Table('alembic_version', _db.metadata,
autoload_with=_db.engine)
alembic_version.drop(bind=_db.engine) | python | def drop_alembic_version_table():
"""Drop alembic_version table."""
if _db.engine.dialect.has_table(_db.engine, 'alembic_version'):
alembic_version = _db.Table('alembic_version', _db.metadata,
autoload_with=_db.engine)
alembic_version.drop(bind=_db.engine) | [
"def",
"drop_alembic_version_table",
"(",
")",
":",
"if",
"_db",
".",
"engine",
".",
"dialect",
".",
"has_table",
"(",
"_db",
".",
"engine",
",",
"'alembic_version'",
")",
":",
"alembic_version",
"=",
"_db",
".",
"Table",
"(",
"'alembic_version'",
",",
"_db"... | Drop alembic_version table. | [
"Drop",
"alembic_version",
"table",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L70-L75 | train |
inveniosoftware/invenio-db | invenio_db/utils.py | versioning_model_classname | def versioning_model_classname(manager, model):
"""Get the name of the versioned model class."""
if manager.options.get('use_module_name', True):
return '%s%sVersion' % (
model.__module__.title().replace('.', ''), model.__name__)
else:
return '%sVersion' % (model.__name__,) | python | def versioning_model_classname(manager, model):
"""Get the name of the versioned model class."""
if manager.options.get('use_module_name', True):
return '%s%sVersion' % (
model.__module__.title().replace('.', ''), model.__name__)
else:
return '%sVersion' % (model.__name__,) | [
"def",
"versioning_model_classname",
"(",
"manager",
",",
"model",
")",
":",
"if",
"manager",
".",
"options",
".",
"get",
"(",
"'use_module_name'",
",",
"True",
")",
":",
"return",
"'%s%sVersion'",
"%",
"(",
"model",
".",
"__module__",
".",
"title",
"(",
"... | Get the name of the versioned model class. | [
"Get",
"the",
"name",
"of",
"the",
"versioned",
"model",
"class",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L78-L84 | train |
inveniosoftware/invenio-db | invenio_db/utils.py | versioning_models_registered | def versioning_models_registered(manager, base):
"""Return True if all versioning models have been registered."""
declared_models = base._decl_class_registry.keys()
return all(versioning_model_classname(manager, c) in declared_models
for c in manager.pending_classes) | python | def versioning_models_registered(manager, base):
"""Return True if all versioning models have been registered."""
declared_models = base._decl_class_registry.keys()
return all(versioning_model_classname(manager, c) in declared_models
for c in manager.pending_classes) | [
"def",
"versioning_models_registered",
"(",
"manager",
",",
"base",
")",
":",
"declared_models",
"=",
"base",
".",
"_decl_class_registry",
".",
"keys",
"(",
")",
"return",
"all",
"(",
"versioning_model_classname",
"(",
"manager",
",",
"c",
")",
"in",
"declared_m... | Return True if all versioning models have been registered. | [
"Return",
"True",
"if",
"all",
"versioning",
"models",
"have",
"been",
"registered",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L87-L91 | train |
quantmind/dynts | dynts/stats/variates.py | vector_to_symmetric | def vector_to_symmetric(v):
'''Convert an iterable into a symmetric matrix.'''
np = len(v)
N = (int(sqrt(1 + 8*np)) - 1)//2
if N*(N+1)//2 != np:
raise ValueError('Cannot convert vector to symmetric matrix')
sym = ndarray((N,N))
iterable = iter(v)
for r in range(N):
f... | python | def vector_to_symmetric(v):
'''Convert an iterable into a symmetric matrix.'''
np = len(v)
N = (int(sqrt(1 + 8*np)) - 1)//2
if N*(N+1)//2 != np:
raise ValueError('Cannot convert vector to symmetric matrix')
sym = ndarray((N,N))
iterable = iter(v)
for r in range(N):
f... | [
"def",
"vector_to_symmetric",
"(",
"v",
")",
":",
"np",
"=",
"len",
"(",
"v",
")",
"N",
"=",
"(",
"int",
"(",
"sqrt",
"(",
"1",
"+",
"8",
"*",
"np",
")",
")",
"-",
"1",
")",
"//",
"2",
"if",
"N",
"*",
"(",
"N",
"+",
"1",
")",
"//",
"2",... | Convert an iterable into a symmetric matrix. | [
"Convert",
"an",
"iterable",
"into",
"a",
"symmetric",
"matrix",
"."
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/variates.py#L7-L18 | train |
quantmind/dynts | dynts/stats/variates.py | Variates.cov | def cov(self, ddof=None, bias=0):
'''The covariance matrix from the aggregate sample. It accepts an
optional parameter for the degree of freedoms.
:parameter ddof: If not ``None`` normalization is by (N - ddof), where N is
the number of observations; this overrides the value im... | python | def cov(self, ddof=None, bias=0):
'''The covariance matrix from the aggregate sample. It accepts an
optional parameter for the degree of freedoms.
:parameter ddof: If not ``None`` normalization is by (N - ddof), where N is
the number of observations; this overrides the value im... | [
"def",
"cov",
"(",
"self",
",",
"ddof",
"=",
"None",
",",
"bias",
"=",
"0",
")",
":",
"N",
"=",
"self",
".",
"n",
"M",
"=",
"N",
"if",
"bias",
"else",
"N",
"-",
"1",
"M",
"=",
"M",
"if",
"ddof",
"is",
"None",
"else",
"N",
"-",
"ddof",
"re... | The covariance matrix from the aggregate sample. It accepts an
optional parameter for the degree of freedoms.
:parameter ddof: If not ``None`` normalization is by (N - ddof), where N is
the number of observations; this overrides the value implied by bias.
The default value ... | [
"The",
"covariance",
"matrix",
"from",
"the",
"aggregate",
"sample",
".",
"It",
"accepts",
"an",
"optional",
"parameter",
"for",
"the",
"degree",
"of",
"freedoms",
".",
":",
"parameter",
"ddof",
":",
"If",
"not",
"None",
"normalization",
"is",
"by",
"(",
"... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/variates.py#L60-L71 | train |
quantmind/dynts | dynts/stats/variates.py | Variates.corr | def corr(self):
'''The correlation matrix'''
cov = self.cov()
N = cov.shape[0]
corr = ndarray((N,N))
for r in range(N):
for c in range(r):
corr[r,c] = corr[c,r] = cov[r,c]/sqrt(cov[r,r]*cov[c,c])
corr[r,r] = 1.
return corr | python | def corr(self):
'''The correlation matrix'''
cov = self.cov()
N = cov.shape[0]
corr = ndarray((N,N))
for r in range(N):
for c in range(r):
corr[r,c] = corr[c,r] = cov[r,c]/sqrt(cov[r,r]*cov[c,c])
corr[r,r] = 1.
return corr | [
"def",
"corr",
"(",
"self",
")",
":",
"cov",
"=",
"self",
".",
"cov",
"(",
")",
"N",
"=",
"cov",
".",
"shape",
"[",
"0",
"]",
"corr",
"=",
"ndarray",
"(",
"(",
"N",
",",
"N",
")",
")",
"for",
"r",
"in",
"range",
"(",
"N",
")",
":",
"for",... | The correlation matrix | [
"The",
"correlation",
"matrix"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/variates.py#L73-L82 | train |
quantmind/dynts | dynts/stats/functions.py | calmar | def calmar(sharpe, T = 1.0):
'''
Calculate the Calmar ratio for a Weiner process
@param sharpe: Annualized Sharpe ratio
@param T: Time interval in years
'''
x = 0.5*T*sharpe*sharpe
return x/qp(x) | python | def calmar(sharpe, T = 1.0):
'''
Calculate the Calmar ratio for a Weiner process
@param sharpe: Annualized Sharpe ratio
@param T: Time interval in years
'''
x = 0.5*T*sharpe*sharpe
return x/qp(x) | [
"def",
"calmar",
"(",
"sharpe",
",",
"T",
"=",
"1.0",
")",
":",
"x",
"=",
"0.5",
"*",
"T",
"*",
"sharpe",
"*",
"sharpe",
"return",
"x",
"/",
"qp",
"(",
"x",
")"
] | Calculate the Calmar ratio for a Weiner process
@param sharpe: Annualized Sharpe ratio
@param T: Time interval in years | [
"Calculate",
"the",
"Calmar",
"ratio",
"for",
"a",
"Weiner",
"process"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/functions.py#L9-L17 | train |
quantmind/dynts | dynts/stats/functions.py | calmarnorm | def calmarnorm(sharpe, T, tau = 1.0):
'''
Multiplicator for normalizing calmar ratio to period tau
'''
return calmar(sharpe,tau)/calmar(sharpe,T) | python | def calmarnorm(sharpe, T, tau = 1.0):
'''
Multiplicator for normalizing calmar ratio to period tau
'''
return calmar(sharpe,tau)/calmar(sharpe,T) | [
"def",
"calmarnorm",
"(",
"sharpe",
",",
"T",
",",
"tau",
"=",
"1.0",
")",
":",
"return",
"calmar",
"(",
"sharpe",
",",
"tau",
")",
"/",
"calmar",
"(",
"sharpe",
",",
"T",
")"
] | Multiplicator for normalizing calmar ratio to period tau | [
"Multiplicator",
"for",
"normalizing",
"calmar",
"ratio",
"to",
"period",
"tau"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/functions.py#L20-L24 | train |
inveniosoftware/invenio-db | invenio_db/alembic/35c1075e6360_force_naming_convention.py | upgrade | def upgrade():
"""Upgrade database."""
op.execute('COMMIT') # See https://bitbucket.org/zzzeek/alembic/issue/123
ctx = op.get_context()
metadata = ctx.opts['target_metadata']
metadata.naming_convention = NAMING_CONVENTION
metadata.bind = ctx.connection.engine
insp = Inspector.from_engine(ct... | python | def upgrade():
"""Upgrade database."""
op.execute('COMMIT') # See https://bitbucket.org/zzzeek/alembic/issue/123
ctx = op.get_context()
metadata = ctx.opts['target_metadata']
metadata.naming_convention = NAMING_CONVENTION
metadata.bind = ctx.connection.engine
insp = Inspector.from_engine(ct... | [
"def",
"upgrade",
"(",
")",
":",
"op",
".",
"execute",
"(",
"'COMMIT'",
")",
"# See https://bitbucket.org/zzzeek/alembic/issue/123",
"ctx",
"=",
"op",
".",
"get_context",
"(",
")",
"metadata",
"=",
"ctx",
".",
"opts",
"[",
"'target_metadata'",
"]",
"metadata",
... | Upgrade database. | [
"Upgrade",
"database",
"."
] | 9009a4cf79574083e129909cf3d2656568550184 | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/alembic/35c1075e6360_force_naming_convention.py#L31-L98 | train |
doakey3/DashTable | dashtable/data2simplerst/data2simplerst.py | data2simplerst | def data2simplerst(table, spans=[[[0, 0]]], use_headers=True, headers_row=0):
"""
Convert table data to a simple rst table
Parameters
----------
table : list of lists of str
A table of strings.
spans : list of lists of lists of int
A list of spans. A span is a list of [Row, Colu... | python | def data2simplerst(table, spans=[[[0, 0]]], use_headers=True, headers_row=0):
"""
Convert table data to a simple rst table
Parameters
----------
table : list of lists of str
A table of strings.
spans : list of lists of lists of int
A list of spans. A span is a list of [Row, Colu... | [
"def",
"data2simplerst",
"(",
"table",
",",
"spans",
"=",
"[",
"[",
"[",
"0",
",",
"0",
"]",
"]",
"]",
",",
"use_headers",
"=",
"True",
",",
"headers_row",
"=",
"0",
")",
":",
"table",
"=",
"copy",
".",
"deepcopy",
"(",
"table",
")",
"table_ok",
... | Convert table data to a simple rst table
Parameters
----------
table : list of lists of str
A table of strings.
spans : list of lists of lists of int
A list of spans. A span is a list of [Row, Column] pairs of
table cells that are joined together.
use_headers : bool, optiona... | [
"Convert",
"table",
"data",
"to",
"a",
"simple",
"rst",
"table"
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2simplerst/data2simplerst.py#L13-L153 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.