Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
BaseNNEstimator.cdf | (self, X, Y) | Predicts the conditional cumulative probability p(Y<=y|X=x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional cumulative ... | Predicts the conditional cumulative probability p(Y<=y|X=x). Requires the model to be fitted. | def cdf(self, X, Y):
""" Predicts the conditional cumulative probability p(Y<=y|X=x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
... | [
"def",
"cdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted to compute likelihood score\"",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
",",
"fitting",
"=",
... | [
156,
4
] | [
171,
16
] | python | en | ['en', 'en', 'en'] | True |
BaseNNEstimator.log_pdf | (self, X, Y) | Predicts the conditional log-probability log p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
onditional log-probability log... | Predicts the conditional log-probability log p(y|x). Requires the model to be fitted. | def log_pdf(self, X, Y):
""" Predicts the conditional log-probability log p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
... | [
"def",
"log_pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted to compute likelihood score\"",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
",",
"fitting",
"=... | [
173,
4
] | [
188,
16
] | python | en | ['en', 'en', 'en'] | True |
_extract_field_data | (source, exclude_fields=None) |
Get dictionaries representing the model's field data.
This excludes many to many fields (which are handled by _copy_m2m_relations)'
|
Get dictionaries representing the model's field data. | def _extract_field_data(source, exclude_fields=None):
"""
Get dictionaries representing the model's field data.
This excludes many to many fields (which are handled by _copy_m2m_relations)'
"""
exclude_fields = exclude_fields or []
data_dict = {}
for field in source._meta.get_fields():
... | [
"def",
"_extract_field_data",
"(",
"source",
",",
"exclude_fields",
"=",
"None",
")",
":",
"exclude_fields",
"=",
"exclude_fields",
"or",
"[",
"]",
"data_dict",
"=",
"{",
"}",
"for",
"field",
"in",
"source",
".",
"_meta",
".",
"get_fields",
"(",
")",
":",
... | [
5,
0
] | [
50,
20
] | python | en | ['en', 'error', 'th'] | False |
_copy_m2m_relations | (source, target, exclude_fields=None, update_attrs=None) |
Copies non-ParentalManyToMany m2m relations
|
Copies non-ParentalManyToMany m2m relations
| def _copy_m2m_relations(source, target, exclude_fields=None, update_attrs=None):
"""
Copies non-ParentalManyToMany m2m relations
"""
update_attrs = update_attrs or {}
exclude_fields = exclude_fields or []
for field in source._meta.get_fields():
# Copy m2m relations. Ignore explicitly ex... | [
"def",
"_copy_m2m_relations",
"(",
"source",
",",
"target",
",",
"exclude_fields",
"=",
"None",
",",
"update_attrs",
"=",
"None",
")",
":",
"update_attrs",
"=",
"update_attrs",
"or",
"{",
"}",
"exclude_fields",
"=",
"exclude_fields",
"or",
"[",
"]",
"for",
"... | [
53,
0
] | [
77,
50
] | python | en | ['en', 'error', 'th'] | False |
attribute_rule | (allowed_attrs) |
Generator for functions that can be used as entries in Whitelister.element_rules.
These functions accept a tag, and modify its attributes by looking each attribute
up in the 'allowed_attrs' dict defined here:
* if the lookup fails, drop the attribute
* if the lookup returns a callable, replace the ... |
Generator for functions that can be used as entries in Whitelister.element_rules.
These functions accept a tag, and modify its attributes by looking each attribute
up in the 'allowed_attrs' dict defined here:
* if the lookup fails, drop the attribute
* if the lookup returns a callable, replace the ... | def attribute_rule(allowed_attrs):
"""
Generator for functions that can be used as entries in Whitelister.element_rules.
These functions accept a tag, and modify its attributes by looking each attribute
up in the 'allowed_attrs' dict defined here:
* if the lookup fails, drop the attribute
* if t... | [
"def",
"attribute_rule",
"(",
"allowed_attrs",
")",
":",
"def",
"fn",
"(",
"tag",
")",
":",
"for",
"attr",
",",
"val",
"in",
"list",
"(",
"tag",
".",
"attrs",
".",
"items",
"(",
")",
")",
":",
"rule",
"=",
"allowed_attrs",
".",
"get",
"(",
"attr",
... | [
33,
0
] | [
61,
13
] | python | en | ['en', 'error', 'th'] | False |
Whitelister.clean | (self, html) | Clean up an HTML string to contain just the allowed elements /
attributes | Clean up an HTML string to contain just the allowed elements /
attributes | def clean(self, html):
"""Clean up an HTML string to contain just the allowed elements /
attributes"""
doc = BeautifulSoup(html, 'html5lib')
self.clean_node(doc, doc)
# Pass strings through django.utils.html.escape when generating the final HTML.
# This differs from Beau... | [
"def",
"clean",
"(",
"self",
",",
"html",
")",
":",
"doc",
"=",
"BeautifulSoup",
"(",
"html",
",",
"'html5lib'",
")",
"self",
".",
"clean_node",
"(",
"doc",
",",
"doc",
")",
"# Pass strings through django.utils.html.escape when generating the final HTML.",
"# This d... | [
97,
4
] | [
108,
43
] | python | en | ['en', 'en', 'en'] | True |
Whitelister.clean_node | (self, doc, node) | Clean a BeautifulSoup document in-place | Clean a BeautifulSoup document in-place | def clean_node(self, doc, node):
"""Clean a BeautifulSoup document in-place"""
if isinstance(node, NavigableString):
self.clean_string_node(doc, node)
elif isinstance(node, Tag):
self.clean_tag_node(doc, node)
# This branch is here in case node is a BeautifulSoup ... | [
"def",
"clean_node",
"(",
"self",
",",
"doc",
",",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"NavigableString",
")",
":",
"self",
".",
"clean_string_node",
"(",
"doc",
",",
"node",
")",
"elif",
"isinstance",
"(",
"node",
",",
"Tag",
")",
... | [
110,
4
] | [
120,
46
] | python | en | ['en', 'en', 'en'] | True |
filter_ifdb | (string, dialect) |
Filters out the {% ifdb ... %} statements in a string. The surrounding
preprocess statement for the dialect are removed, for other dialects the
complete statement is removed.
:param string: the SQL string that may contain one or more ifdb statements
:param dialect: the sql dialect you want to filt... |
Filters out the {% ifdb ... %} statements in a string. The surrounding
preprocess statement for the dialect are removed, for other dialects the
complete statement is removed. | def filter_ifdb(string, dialect):
"""
Filters out the {% ifdb ... %} statements in a string. The surrounding
preprocess statement for the dialect are removed, for other dialects the
complete statement is removed.
:param string: the SQL string that may contain one or more ifdb statements
:param ... | [
"def",
"filter_ifdb",
"(",
"string",
",",
"dialect",
")",
":",
"# remove the condition around our dialect",
"pattern",
"=",
"ifdb_regexp",
"%",
"{",
"'dialect'",
":",
"dialect",
"}",
"step1",
"=",
"re",
".",
"sub",
"(",
"pattern",
",",
"r'\\1'",
",",
"string",... | [
23,
0
] | [
41,
16
] | python | en | ['en', 'error', 'th'] | False |
filter_tokens | (string, tokens) |
Replaces substrings of string.
:param string: a SQL string
:param tokens: a list of tupels of len 2 containing a mapping of what to
replace.
:return: a token-replaced string
|
Replaces substrings of string. | def filter_tokens(string, tokens):
"""
Replaces substrings of string.
:param string: a SQL string
:param tokens: a list of tupels of len 2 containing a mapping of what to
replace.
:return: a token-replaced string
"""
result = string
for (token, replacer) in tokens:
... | [
"def",
"filter_tokens",
"(",
"string",
",",
"tokens",
")",
":",
"result",
"=",
"string",
"for",
"(",
"token",
",",
"replacer",
")",
"in",
"tokens",
":",
"result",
"=",
"result",
".",
"replace",
"(",
"token",
",",
"replacer",
")",
"return",
"result"
] | [
44,
0
] | [
56,
17
] | python | en | ['en', 'error', 'th'] | False |
dialectise | (string, dialect, tokens=[]) |
Preprocess a SQL string, removes or manipulates all preprocess statements.
:param string: a string with possible SQL preprocessor content
:param dialect: what SQL dialect do you want?
:returns: a string containing only statements in the specified dialect
|
Preprocess a SQL string, removes or manipulates all preprocess statements. | def dialectise(string, dialect, tokens=[]):
"""
Preprocess a SQL string, removes or manipulates all preprocess statements.
:param string: a string with possible SQL preprocessor content
:param dialect: what SQL dialect do you want?
:returns: a string containing only statements in the specified dial... | [
"def",
"dialectise",
"(",
"string",
",",
"dialect",
",",
"tokens",
"=",
"[",
"]",
")",
":",
"dialected",
"=",
"filter_ifdb",
"(",
"string",
",",
"dialect",
")",
"tokenized",
"=",
"filter_tokens",
"(",
"dialected",
",",
"tokens",
")",
"return",
"tokenized"
... | [
59,
0
] | [
69,
20
] | python | en | ['en', 'error', 'th'] | False |
read_gstar_output | (gstar_fn) |
read the tsv file format produced by GSTAr in -t mode
|
read the tsv file format produced by GSTAr in -t mode
| def read_gstar_output(gstar_fn):
'''
read the tsv file format produced by GSTAr in -t mode
'''
gstar = pd.read_csv(
gstar_fn,
sep='\s+',
names=GSTAR_COLUMNS,
usecols=GSTAR_USECOLS,
skiprows=8,
comment='#'
)
gstar['start'] = gstar['start'] - 1
g... | [
"def",
"read_gstar_output",
"(",
"gstar_fn",
")",
":",
"gstar",
"=",
"pd",
".",
"read_csv",
"(",
"gstar_fn",
",",
"sep",
"=",
"'\\s+'",
",",
"names",
"=",
"GSTAR_COLUMNS",
",",
"usecols",
"=",
"GSTAR_USECOLS",
",",
"skiprows",
"=",
"8",
",",
"comment",
"... | [
65,
0
] | [
79,
16
] | python | en | ['en', 'error', 'th'] | False |
CheckRegistry.register | (self, check=None, *tags, **kwargs) |
Can be used as a function or a decorator. Register given function
`f` labeled with given `tags`. The function should receive **kwargs
and return list of Errors and Warnings.
Example::
registry = CheckRegistry()
@registry.register('mytag', 'anothertag')
... |
Can be used as a function or a decorator. Register given function
`f` labeled with given `tags`. The function should receive **kwargs
and return list of Errors and Warnings. | def register(self, check=None, *tags, **kwargs):
"""
Can be used as a function or a decorator. Register given function
`f` labeled with given `tags`. The function should receive **kwargs
and return list of Errors and Warnings.
Example::
registry = CheckRegistry()
... | [
"def",
"register",
"(",
"self",
",",
"check",
"=",
"None",
",",
"*",
"tags",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'deploy'",
",",
"False",
")",
"def",
"inner",
"(",
"check",
")",
":",
"check",
".",
"tags",
"=",
"t... | [
29,
4
] | [
61,
24
] | python | en | ['en', 'error', 'th'] | False |
CheckRegistry.run_checks | (self, app_configs=None, tags=None, include_deployment_checks=False) |
Run all registered checks and return list of Errors and Warnings.
|
Run all registered checks and return list of Errors and Warnings.
| def run_checks(self, app_configs=None, tags=None, include_deployment_checks=False):
"""
Run all registered checks and return list of Errors and Warnings.
"""
errors = []
checks = self.get_checks(include_deployment_checks)
if tags is not None:
checks = [check ... | [
"def",
"run_checks",
"(",
"self",
",",
"app_configs",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"include_deployment_checks",
"=",
"False",
")",
":",
"errors",
"=",
"[",
"]",
"checks",
"=",
"self",
".",
"get_checks",
"(",
"include_deployment_checks",
")",
... | [
63,
4
] | [
85,
21
] | python | en | ['en', 'error', 'th'] | False |
su_to_zulip | (save_suid: bool = False) | Warning: su_to_zulip assumes that the zulip checkout is owned by
the zulip user (or whatever normal user is running the Zulip
installation). It should never be run from the installer or other
production contexts before /home/zulip/deployments/current is
created. | Warning: su_to_zulip assumes that the zulip checkout is owned by
the zulip user (or whatever normal user is running the Zulip
installation). It should never be run from the installer or other
production contexts before /home/zulip/deployments/current is
created. | def su_to_zulip(save_suid: bool = False) -> None:
"""Warning: su_to_zulip assumes that the zulip checkout is owned by
the zulip user (or whatever normal user is running the Zulip
installation). It should never be run from the installer or other
production contexts before /home/zulip/deployments/current... | [
"def",
"su_to_zulip",
"(",
"save_suid",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"pwent",
"=",
"get_zulip_pwent",
"(",
")",
"os",
".",
"setgid",
"(",
"pwent",
".",
"pw_gid",
")",
"if",
"save_suid",
":",
"os",
".",
"setresuid",
"(",
"pwent",
... | [
144,
0
] | [
156,
37
] | python | en | ['en', 'en', 'en'] | True |
parse_os_release | () |
Example of the useful subset of the data:
{
'ID': 'ubuntu',
'VERSION_ID': '18.04',
'NAME': 'Ubuntu',
'VERSION': '18.04.3 LTS (Bionic Beaver)',
'PRETTY_NAME': 'Ubuntu 18.04.3 LTS',
}
VERSION_CODENAME (e.g. 'bionic') is nice and human-readable, but
we avoid using it, as it i... |
Example of the useful subset of the data:
{
'ID': 'ubuntu',
'VERSION_ID': '18.04',
'NAME': 'Ubuntu',
'VERSION': '18.04.3 LTS (Bionic Beaver)',
'PRETTY_NAME': 'Ubuntu 18.04.3 LTS',
} | def parse_os_release() -> Dict[str, str]:
"""
Example of the useful subset of the data:
{
'ID': 'ubuntu',
'VERSION_ID': '18.04',
'NAME': 'Ubuntu',
'VERSION': '18.04.3 LTS (Bionic Beaver)',
'PRETTY_NAME': 'Ubuntu 18.04.3 LTS',
}
VERSION_CODENAME (e.g. 'bionic') is nice and h... | [
"def",
"parse_os_release",
"(",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"distro_info",
"=",
"{",
"}",
"# type: Dict[str, str]",
"with",
"open",
"(",
"\"/etc/os-release\"",
")",
"as",
"fp",
":",
"for",
"line",
"in",
"fp",
":",
"line",
"=",
... | [
403,
0
] | [
432,
22
] | python | en | ['en', 'error', 'th'] | False |
os_families | () |
Known families:
debian (includes: debian, ubuntu)
ubuntu (includes: ubuntu)
fedora (includes: fedora, rhel, centos)
rhel (includes: rhel, centos)
centos (includes: centos)
|
Known families:
debian (includes: debian, ubuntu)
ubuntu (includes: ubuntu)
fedora (includes: fedora, rhel, centos)
rhel (includes: rhel, centos)
centos (includes: centos)
| def os_families() -> Set[str]:
"""
Known families:
debian (includes: debian, ubuntu)
ubuntu (includes: ubuntu)
fedora (includes: fedora, rhel, centos)
rhel (includes: rhel, centos)
centos (includes: centos)
"""
distro_info = parse_os_release()
return {distro_info["ID"], *distro_i... | [
"def",
"os_families",
"(",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"distro_info",
"=",
"parse_os_release",
"(",
")",
"return",
"{",
"distro_info",
"[",
"\"ID\"",
"]",
",",
"*",
"distro_info",
".",
"get",
"(",
"\"ID_LIKE\"",
",",
"\"\"",
")",
".",
"spli... | [
436,
0
] | [
446,
71
] | python | en | ['en', 'error', 'th'] | False |
is_digest_obsolete | (
hash_name: str, filenames: Sequence[str], extra_strings: Sequence[str] = []
) |
In order to determine if we need to run some
process, we calculate a digest of the important
files and strings whose respective contents
or values may indicate such a need.
filenames = files we should hash the contents of
extra_strings = strings we should hash directly
Grep for ca... |
In order to determine if we need to run some
process, we calculate a digest of the important
files and strings whose respective contents
or values may indicate such a need. | def is_digest_obsolete(
hash_name: str, filenames: Sequence[str], extra_strings: Sequence[str] = []
) -> bool:
"""
In order to determine if we need to run some
process, we calculate a digest of the important
files and strings whose respective contents
or values may indicate such a need.
... | [
"def",
"is_digest_obsolete",
"(",
"hash_name",
":",
"str",
",",
"filenames",
":",
"Sequence",
"[",
"str",
"]",
",",
"extra_strings",
":",
"Sequence",
"[",
"str",
"]",
"=",
"[",
"]",
")",
"->",
"bool",
":",
"last_hash_path",
"=",
"os",
".",
"path",
".",... | [
462,
0
] | [
494,
31
] | python | en | ['en', 'error', 'th'] | False |
deport | (netloc: str) | Remove the port from a hostname:port string. Brackets on a literal
IPv6 address are included. | Remove the port from a hostname:port string. Brackets on a literal
IPv6 address are included. | def deport(netloc: str) -> str:
"""Remove the port from a hostname:port string. Brackets on a literal
IPv6 address are included."""
r = SplitResult("", netloc, "", "", "")
assert r.hostname is not None
return "[" + r.hostname + "]" if ":" in r.hostname else r.hostname | [
"def",
"deport",
"(",
"netloc",
":",
"str",
")",
"->",
"str",
":",
"r",
"=",
"SplitResult",
"(",
"\"\"",
",",
"netloc",
",",
"\"\"",
",",
"\"\"",
",",
"\"\"",
")",
"assert",
"r",
".",
"hostname",
"is",
"not",
"None",
"return",
"\"[\"",
"+",
"r",
... | [
643,
0
] | [
648,
70
] | python | en | ['en', 'en', 'en'] | True |
CurrentThreadExecutor.run_until_future | (self, future) |
Runs the code in the work queue until a result is available from the future.
Should be run from the thread the executor is initialised in.
|
Runs the code in the work queue until a result is available from the future.
Should be run from the thread the executor is initialised in.
| def run_until_future(self, future):
"""
Runs the code in the work queue until a result is available from the future.
Should be run from the thread the executor is initialised in.
"""
# Check we're in the right thread
if threading.current_thread() != self._work_thread:
... | [
"def",
"run_until_future",
"(",
"self",
",",
"future",
")",
":",
"# Check we're in the right thread",
"if",
"threading",
".",
"current_thread",
"(",
")",
"!=",
"self",
".",
"_work_thread",
":",
"raise",
"RuntimeError",
"(",
"\"You cannot run CurrentThreadExecutor from a... | [
43,
4
] | [
69,
31
] | python | en | ['en', 'error', 'th'] | False |
Application.check_pull_refresh | (self, view, grid) | Check the amount of overscroll to decide if we want to trigger the
refresh or not.
| Check the amount of overscroll to decide if we want to trigger the
refresh or not.
| def check_pull_refresh(self, view, grid):
"""Check the amount of overscroll to decide if we want to trigger the
refresh or not.
"""
max_pixel = dp(200)
to_relative = max_pixel / (grid.height - view.height)
if view.scroll_y <= 1.0 + to_relative or self.refreshing:
... | [
"def",
"check_pull_refresh",
"(",
"self",
",",
"view",
",",
"grid",
")",
":",
"max_pixel",
"=",
"dp",
"(",
"200",
")",
"to_relative",
"=",
"max_pixel",
"/",
"(",
"grid",
".",
"height",
"-",
"view",
".",
"height",
")",
"if",
"view",
".",
"scroll_y",
"... | [
61,
4
] | [
70,
27
] | python | en | ['en', 'en', 'en'] | True |
split_unquoted_newlines | (stmt) | Split a string on all unquoted newlines.
Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite
character is inside of a string. | Split a string on all unquoted newlines. | def split_unquoted_newlines(stmt):
"""Split a string on all unquoted newlines.
Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite
character is inside of a string."""
text = str(stmt)
lines = SPLIT_REGEX.split(text)
outputlines = ['']
for line in lines:
if not lin... | [
"def",
"split_unquoted_newlines",
"(",
"stmt",
")",
":",
"text",
"=",
"str",
"(",
"stmt",
")",
"lines",
"=",
"SPLIT_REGEX",
".",
"split",
"(",
"text",
")",
"outputlines",
"=",
"[",
"''",
"]",
"for",
"line",
"in",
"lines",
":",
"if",
"not",
"line",
":... | [
35,
0
] | [
50,
22
] | python | en | ['en', 'en', 'en'] | True |
remove_quotes | (val) | Helper that removes surrounding quotes from strings. | Helper that removes surrounding quotes from strings. | def remove_quotes(val):
"""Helper that removes surrounding quotes from strings."""
if val is None:
return
if val[0] in ('"', "'") and val[0] == val[-1]:
val = val[1:-1]
return val | [
"def",
"remove_quotes",
"(",
"val",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"if",
"val",
"[",
"0",
"]",
"in",
"(",
"'\"'",
",",
"\"'\"",
")",
"and",
"val",
"[",
"0",
"]",
"==",
"val",
"[",
"-",
"1",
"]",
":",
"val",
"=",
"val",
... | [
53,
0
] | [
59,
14
] | python | en | ['en', 'en', 'en'] | True |
recurse | (*cls) | Function decorator to help with recursion
:param cls: Classes to not recurse over
:return: function
| Function decorator to help with recursion | def recurse(*cls):
"""Function decorator to help with recursion
:param cls: Classes to not recurse over
:return: function
"""
def wrap(f):
def wrapped_f(tlist):
for sgroup in tlist.get_sublists():
if not isinstance(sgroup, cls):
wrapped_f(sgro... | [
"def",
"recurse",
"(",
"*",
"cls",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"def",
"wrapped_f",
"(",
"tlist",
")",
":",
"for",
"sgroup",
"in",
"tlist",
".",
"get_sublists",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"sgroup",
",",
"cls",
... | [
62,
0
] | [
77,
15
] | python | en | ['en', 'en', 'en'] | True |
imt | (token, i=None, m=None, t=None) | Helper function to simplify comparisons Instance, Match and TokenType
:param token:
:param i: Class or Tuple/List of Classes
:param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
:param t: TokenType or Tuple/List of TokenTypes
:return: bool
| Helper function to simplify comparisons Instance, Match and TokenType
:param token:
:param i: Class or Tuple/List of Classes
:param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
:param t: TokenType or Tuple/List of TokenTypes
:return: bool
| def imt(token, i=None, m=None, t=None):
"""Helper function to simplify comparisons Instance, Match and TokenType
:param token:
:param i: Class or Tuple/List of Classes
:param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
:param t: TokenType or Tuple/List of TokenTypes
:return:... | [
"def",
"imt",
"(",
"token",
",",
"i",
"=",
"None",
",",
"m",
"=",
"None",
",",
"t",
"=",
"None",
")",
":",
"clss",
"=",
"i",
"types",
"=",
"[",
"t",
",",
"]",
"if",
"t",
"and",
"not",
"isinstance",
"(",
"t",
",",
"list",
")",
"else",
"t",
... | [
80,
0
] | [
101,
20
] | python | en | ['en', 'en', 'en'] | True |
consume | (iterator, n) | Advance the iterator n-steps ahead. If n is none, consume entirely. | Advance the iterator n-steps ahead. If n is none, consume entirely. | def consume(iterator, n):
"""Advance the iterator n-steps ahead. If n is none, consume entirely."""
deque(itertools.islice(iterator, n), maxlen=0) | [
"def",
"consume",
"(",
"iterator",
",",
"n",
")",
":",
"deque",
"(",
"itertools",
".",
"islice",
"(",
"iterator",
",",
"n",
")",
",",
"maxlen",
"=",
"0",
")"
] | [
104,
0
] | [
106,
50
] | python | en | ['en', 'en', 'en'] | True |
JpegImageFile.load_read | (self, read_bytes) |
internal: read more image data
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
so libjpeg can finish decoding
|
internal: read more image data
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
so libjpeg can finish decoding
| def load_read(self, read_bytes):
"""
internal: read more image data
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
so libjpeg can finish decoding
"""
s = self.fp.read(read_bytes)
if not s and ImageFile.LOAD_TRUNCATED_IMAGES:
# Premature E... | [
"def",
"load_read",
"(",
"self",
",",
"read_bytes",
")",
":",
"s",
"=",
"self",
".",
"fp",
".",
"read",
"(",
"read_bytes",
")",
"if",
"not",
"s",
"and",
"ImageFile",
".",
"LOAD_TRUNCATED_IMAGES",
":",
"# Premature EOF.",
"# Pretend file is finished adding EOI ma... | [
393,
4
] | [
406,
16
] | python | en | ['en', 'error', 'th'] | False |
Yogi.step | (self, closure: OptLossClosure = None) | r"""Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
| r"""Performs a single optimization step. | def step(self, closure: OptLossClosure = None) -> OptFloat:
r"""Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
"""
loss = None
if closure is not None:
loss = closure()
for group... | [
"def",
"step",
"(",
"self",
",",
"closure",
":",
"OptLossClosure",
"=",
"None",
")",
"->",
"OptFloat",
":",
"loss",
"=",
"None",
"if",
"closure",
"is",
"not",
"None",
":",
"loss",
"=",
"closure",
"(",
")",
"for",
"group",
"in",
"self",
".",
"param_gr... | [
75,
4
] | [
147,
19
] | python | en | ['en', 'en', 'en'] | True |
Scenario.get | (self, key, default=defaultdict) |
:param key:
:type default: object
:return:
| def get(self, key, default=defaultdict):
"""
:param key:
:type default: object
:return:
"""
return self.data.get(key, default) | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"defaultdict",
")",
":",
"return",
"self",
".",
"data",
".",
"get",
"(",
"key",
",",
"default",
")"
] | [
54,
4
] | [
61,
42
] | python | en | ['en', 'error', 'th'] | False | |
Scenario.get_headers | (self) |
Returns global headers
:rtype: dict[str,str]
|
Returns global headers | def get_headers(self):
"""
Returns global headers
:rtype: dict[str,str]
"""
scenario = self
headers = scenario.get("headers", {})
if headers is None:
headers = {}
return headers | [
"def",
"get_headers",
"(",
"self",
")",
":",
"scenario",
"=",
"self",
"headers",
"=",
"scenario",
".",
"get",
"(",
"\"headers\"",
",",
"{",
"}",
")",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"}",
"return",
"headers"
] | [
79,
4
] | [
89,
22
] | python | en | ['en', 'error', 'th'] | False |
Scenario.get_requests | (self, parser=RequestParser, require_url=True) |
Generator object to read requests
:type require_url: bool
:type parser: class
:rtype: list[bzt.requests_model.Request]
|
Generator object to read requests | def get_requests(self, parser=RequestParser, require_url=True):
"""
Generator object to read requests
:type require_url: bool
:type parser: class
:rtype: list[bzt.requests_model.Request]
"""
requests_parser = parser(self, self.engine)
return requests_pars... | [
"def",
"get_requests",
"(",
"self",
",",
"parser",
"=",
"RequestParser",
",",
"require_url",
"=",
"True",
")",
":",
"requests_parser",
"=",
"parser",
"(",
"self",
",",
"self",
".",
"engine",
")",
"return",
"requests_parser",
".",
"extract_requests",
"(",
"re... | [
114,
4
] | [
123,
74
] | python | en | ['en', 'error', 'th'] | False |
Configuration.load | (self, config_files, callback=None) |
Load and merge JSON/YAML files into current dict
:type callback: callable
:type config_files: list[str]
|
Load and merge JSON/YAML files into current dict | def load(self, config_files, callback=None):
"""
Load and merge JSON/YAML files into current dict
:type callback: callable
:type config_files: list[str]
"""
self.log.debug("Configs: %s", config_files)
for config_file in config_files:
try:
... | [
"def",
"load",
"(",
"self",
",",
"config_files",
",",
"callback",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Configs: %s\"",
",",
"config_files",
")",
"for",
"config_file",
"in",
"config_files",
":",
"try",
":",
"configs",
"=",
"[",... | [
142,
4
] | [
172,
37
] | python | en | ['en', 'error', 'th'] | False |
Configuration.set_dump_file | (self, filename) |
Set default file and format to be used by `dump` method
:type filename: str
|
Set default file and format to be used by `dump` method | def set_dump_file(self, filename):
"""
Set default file and format to be used by `dump` method
:type filename: str
"""
self.dump_filename = filename | [
"def",
"set_dump_file",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"dump_filename",
"=",
"filename"
] | [
197,
4
] | [
203,
37
] | python | en | ['en', 'error', 'th'] | False |
Configuration.write | (self, fds, fmt) |
Write config into opened file
:type fds: file
:type fmt: str
:raise TaurusInternalException:
|
Write config into opened file | def write(self, fds, fmt):
"""
Write config into opened file
:type fds: file
:type fmt: str
:raise TaurusInternalException:
"""
if fmt == self.JSON:
json_s = to_json(self)
fds.write(json_s.encode('utf-8'))
elif fmt == self.YAML:
... | [
"def",
"write",
"(",
"self",
",",
"fds",
",",
"fmt",
")",
":",
"if",
"fmt",
"==",
"self",
".",
"JSON",
":",
"json_s",
"=",
"to_json",
"(",
"self",
")",
"fds",
".",
"write",
"(",
"json_s",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"elif",
"fmt",
... | [
205,
4
] | [
222,
39
] | python | en | ['en', 'error', 'th'] | False |
Configuration.dump | (self, filename=None, fmt=None) |
Dump current state of dict into file. If no filename or format
specified, defaults are used
:type filename: str or NoneType
:type fmt: str or NoneType
|
Dump current state of dict into file. If no filename or format
specified, defaults are used | def dump(self, filename=None, fmt=None):
"""
Dump current state of dict into file. If no filename or format
specified, defaults are used
:type filename: str or NoneType
:type fmt: str or NoneType
"""
if not filename:
filename = self.dump_filename
... | [
"def",
"dump",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"fmt",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"filename",
"=",
"self",
".",
"dump_filename",
"if",
"filename",
":",
"if",
"not",
"fmt",
":",
"self",
".",
"dump",
"(",
"fil... | [
224,
4
] | [
246,
37
] | python | en | ['en', 'error', 'th'] | False |
Configuration.masq_sensitive | (value, key, container) |
Remove sensitive data from config
|
Remove sensitive data from config
| def masq_sensitive(value, key, container):
"""
Remove sensitive data from config
"""
if isinstance(key, str):
for suffix in ('password', 'secret', 'token',):
if key.lower().endswith(suffix):
if value and isinstance(value, str):
... | [
"def",
"masq_sensitive",
"(",
"value",
",",
"key",
",",
"container",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"for",
"suffix",
"in",
"(",
"'password'",
",",
"'secret'",
",",
"'token'",
",",
")",
":",
"if",
"key",
".",
"lower",
... | [
249,
4
] | [
257,
48
] | python | en | ['en', 'error', 'th'] | False |
Configuration.replace_infinities | (value, key, container) |
Remove non-string JSON values used by default JSON encoder (Infinity, -Infinity, NaN)
|
Remove non-string JSON values used by default JSON encoder (Infinity, -Infinity, NaN)
| def replace_infinities(value, key, container):
"""
Remove non-string JSON values used by default JSON encoder (Infinity, -Infinity, NaN)
"""
del value
if isinstance(container[key], float):
if math.isinf(container[key]) or math.isnan(container[key]):
co... | [
"def",
"replace_infinities",
"(",
"value",
",",
"key",
",",
"container",
")",
":",
"del",
"value",
"if",
"isinstance",
"(",
"container",
"[",
"key",
"]",
",",
"float",
")",
":",
"if",
"math",
".",
"isinf",
"(",
"container",
"[",
"key",
"]",
")",
"or"... | [
260,
4
] | [
267,
52
] | python | en | ['en', 'error', 'th'] | False |
Link.__init__ | (
self,
url, # type: str
comes_from=None, # type: Optional[Union[str, HTMLPage]]
requires_python=None, # type: Optional[str]
yanked_reason=None, # type: Optional[Text]
cache_link_parsing=True, # type: bool
) |
:param url: url of the resource pointed to (href of the link)
:param comes_from: instance of HTMLPage where the link was found,
or string.
:param requires_python: String containing the `Requires-Python`
metadata field, specified in PEP 345. This may be specified by
... |
:param url: url of the resource pointed to (href of the link)
:param comes_from: instance of HTMLPage where the link was found,
or string.
:param requires_python: String containing the `Requires-Python`
metadata field, specified in PEP 345. This may be specified by
... | def __init__(
self,
url, # type: str
comes_from=None, # type: Optional[Union[str, HTMLPage]]
requires_python=None, # type: Optional[str]
yanked_reason=None, # type: Optional[Text]
cache_link_parsing=True, # type: bool
):
# type: (.... | [
"def",
"__init__",
"(",
"self",
",",
"url",
",",
"# type: str",
"comes_from",
"=",
"None",
",",
"# type: Optional[Union[str, HTMLPage]]",
"requires_python",
"=",
"None",
",",
"# type: Optional[str]",
"yanked_reason",
"=",
"None",
",",
"# type: Optional[Text]",
"cache_li... | [
36,
4
] | [
81,
52
] | python | en | ['en', 'error', 'th'] | False |
Link.netloc | (self) |
This can contain auth information.
|
This can contain auth information.
| def netloc(self):
# type: () -> str
"""
This can contain auth information.
"""
return self._parsed_url.netloc | [
"def",
"netloc",
"(",
"self",
")",
":",
"# type: () -> str",
"return",
"self",
".",
"_parsed_url",
".",
"netloc"
] | [
131,
4
] | [
136,
38
] | python | en | ['en', 'error', 'th'] | False |
Link.is_hash_allowed | (self, hashes) |
Return True if the link has a hash and it is allowed.
|
Return True if the link has a hash and it is allowed.
| def is_hash_allowed(self, hashes):
# type: (Optional[Hashes]) -> bool
"""
Return True if the link has a hash and it is allowed.
"""
if hashes is None or not self.has_hash:
return False
# Assert non-None so mypy knows self.hash_name and self.hash are str.
... | [
"def",
"is_hash_allowed",
"(",
"self",
",",
"hashes",
")",
":",
"# type: (Optional[Hashes]) -> bool",
"if",
"hashes",
"is",
"None",
"or",
"not",
"self",
".",
"has_hash",
":",
"return",
"False",
"# Assert non-None so mypy knows self.hash_name and self.hash are str.",
"asse... | [
234,
4
] | [
245,
75
] | python | en | ['en', 'error', 'th'] | False |
SyncStore.peer_has_block | (self, header_hash: bytes32, peer_id: bytes32, weight: uint128, height: uint32, new_peak: bool) |
Adds a record that a certain peer has a block.
|
Adds a record that a certain peer has a block.
| def peer_has_block(self, header_hash: bytes32, peer_id: bytes32, weight: uint128, height: uint32, new_peak: bool):
"""
Adds a record that a certain peer has a block.
"""
if header_hash == self.sync_target_header_hash:
self.peers_changed.set()
if header_hash in self.p... | [
"def",
"peer_has_block",
"(",
"self",
",",
"header_hash",
":",
"bytes32",
",",
"peer_id",
":",
"bytes32",
",",
"weight",
":",
"uint128",
",",
"height",
":",
"uint32",
",",
"new_peak",
":",
"bool",
")",
":",
"if",
"header_hash",
"==",
"self",
".",
"sync_t... | [
61,
4
] | [
74,
70
] | python | en | ['en', 'error', 'th'] | False |
SyncStore.get_peers_that_have_peak | (self, header_hashes: List[bytes32]) |
Returns: peer ids of peers that have at least one of the header hashes.
|
Returns: peer ids of peers that have at least one of the header hashes.
| def get_peers_that_have_peak(self, header_hashes: List[bytes32]) -> Set[bytes32]:
"""
Returns: peer ids of peers that have at least one of the header hashes.
"""
node_ids: Set[bytes32] = set()
for header_hash in header_hashes:
if header_hash in self.peak_to_peer:
... | [
"def",
"get_peers_that_have_peak",
"(",
"self",
",",
"header_hashes",
":",
"List",
"[",
"bytes32",
"]",
")",
"->",
"Set",
"[",
"bytes32",
"]",
":",
"node_ids",
":",
"Set",
"[",
"bytes32",
"]",
"=",
"set",
"(",
")",
"for",
"header_hash",
"in",
"header_has... | [
76,
4
] | [
86,
23
] | python | en | ['en', 'error', 'th'] | False |
SyncStore.get_peak_of_each_peer | (self) |
Returns: dictionary of peer id to peak information.
|
Returns: dictionary of peer id to peak information.
| def get_peak_of_each_peer(self) -> Dict[bytes32, Tuple[bytes32, uint32, uint128]]:
"""
Returns: dictionary of peer id to peak information.
"""
ret = {}
for peer_id, v in self.peer_to_peak.items():
if v[0] not in self.peak_to_peer:
continue
... | [
"def",
"get_peak_of_each_peer",
"(",
"self",
")",
"->",
"Dict",
"[",
"bytes32",
",",
"Tuple",
"[",
"bytes32",
",",
"uint32",
",",
"uint128",
"]",
"]",
":",
"ret",
"=",
"{",
"}",
"for",
"peer_id",
",",
"v",
"in",
"self",
".",
"peer_to_peak",
".",
"ite... | [
88,
4
] | [
98,
18
] | python | en | ['en', 'error', 'th'] | False |
SyncStore.get_heaviest_peak | (self) |
Returns: the header_hash, height, and weight of the heaviest block that one of our peers has notified
us of.
|
Returns: the header_hash, height, and weight of the heaviest block that one of our peers has notified
us of.
| def get_heaviest_peak(self) -> Optional[Tuple[bytes32, uint32, uint128]]:
"""
Returns: the header_hash, height, and weight of the heaviest block that one of our peers has notified
us of.
"""
if len(self.peer_to_peak) == 0:
return None
heaviest_peak_hash: Opti... | [
"def",
"get_heaviest_peak",
"(",
"self",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"bytes32",
",",
"uint32",
",",
"uint128",
"]",
"]",
":",
"if",
"len",
"(",
"self",
".",
"peer_to_peak",
")",
"==",
"0",
":",
"return",
"None",
"heaviest_peak_hash",
":",
... | [
100,
4
] | [
119,
77
] | python | en | ['en', 'error', 'th'] | False |
SyncStore.clear_sync_info | (self) |
Clears the peak_to_peer info which can get quite large.
|
Clears the peak_to_peer info which can get quite large.
| async def clear_sync_info(self):
"""
Clears the peak_to_peer info which can get quite large.
"""
self.peak_to_peer = {} | [
"async",
"def",
"clear_sync_info",
"(",
"self",
")",
":",
"self",
".",
"peak_to_peer",
"=",
"{",
"}"
] | [
121,
4
] | [
125,
30
] | python | en | ['en', 'error', 'th'] | False |
NoFastDeleteCollector.can_fast_delete | (self, *args, **kwargs) |
Always load related objects to display them when showing confirmation.
|
Always load related objects to display them when showing confirmation.
| def can_fast_delete(self, *args, **kwargs):
"""
Always load related objects to display them when showing confirmation.
"""
return False | [
"def",
"can_fast_delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"False"
] | [
81,
4
] | [
85,
20
] | python | en | ['en', 'error', 'th'] | False |
init_cmd | (ctx: click.Context, create_certs: str) |
Create a new configuration or migrate from previous versions to current
\b
Follow these steps to create new certificates for a remote harvester:
- Make a copy of your Farming Machine CA directory: ~/.kale/[version]/config/ssl/ca
- Shut down all kale daemon processes with `kale stop all -d`
- R... |
Create a new configuration or migrate from previous versions to current | def init_cmd(ctx: click.Context, create_certs: str):
"""
Create a new configuration or migrate from previous versions to current
\b
Follow these steps to create new certificates for a remote harvester:
- Make a copy of your Farming Machine CA directory: ~/.kale/[version]/config/ssl/ca
- Shut do... | [
"def",
"init_cmd",
"(",
"ctx",
":",
"click",
".",
"Context",
",",
"create_certs",
":",
"str",
")",
":",
"from",
"pathlib",
"import",
"Path",
"from",
".",
"init_funcs",
"import",
"init",
"init",
"(",
"Path",
"(",
"create_certs",
")",
"if",
"create_certs",
... | [
12,
0
] | [
28,
88
] | python | en | ['en', 'error', 'th'] | False |
PosixUIDGroupType.user_groups | (self, ldap_user, group_search) |
Searches for any group that is either the user's primary or contains the
user as a member.
|
Searches for any group that is either the user's primary or contains the
user as a member.
| def user_groups(self, ldap_user, group_search):
"""
Searches for any group that is either the user's primary or contains the
user as a member.
"""
groups = []
try:
user_uid = ldap_user.attrs[self.ldap_group_user_attr][0]
if 'gidNumber' in ldap_us... | [
"def",
"user_groups",
"(",
"self",
",",
"ldap_user",
",",
"group_search",
")",
":",
"groups",
"=",
"[",
"]",
"try",
":",
"user_uid",
"=",
"ldap_user",
".",
"attrs",
"[",
"self",
".",
"ldap_group_user_attr",
"]",
"[",
"0",
"]",
"if",
"'gidNumber'",
"in",
... | [
22,
4
] | [
47,
21
] | python | en | ['en', 'error', 'th'] | False |
PosixUIDGroupType.is_member | (self, ldap_user, group_dn) |
Returns True if the group is the user's primary group or if the user is
listed in the group's memberUid attribute.
|
Returns True if the group is the user's primary group or if the user is
listed in the group's memberUid attribute.
| def is_member(self, ldap_user, group_dn):
"""
Returns True if the group is the user's primary group or if the user is
listed in the group's memberUid attribute.
"""
is_member = False
try:
user_uid = ldap_user.attrs[self.ldap_group_user_attr][0]
tr... | [
"def",
"is_member",
"(",
"self",
",",
"ldap_user",
",",
"group_dn",
")",
":",
"is_member",
"=",
"False",
"try",
":",
"user_uid",
"=",
"ldap_user",
".",
"attrs",
"[",
"self",
".",
"ldap_group_user_attr",
"]",
"[",
"0",
"]",
"try",
":",
"is_member",
"=",
... | [
49,
4
] | [
72,
24
] | python | en | ['en', 'error', 'th'] | False |
ensure_no_empty_passwords | (apps: StateApps, schema_editor: DatabaseSchemaEditor) | With CVE-2019-18933, it was possible for certain users created
using social login (e.g. Google/GitHub auth) to have the empty
string as their password in the Zulip database, rather than
Django's "unusable password" (i.e. no password at all). This was a
serious security issue for organizations with both... | With CVE-2019-18933, it was possible for certain users created
using social login (e.g. Google/GitHub auth) to have the empty
string as their password in the Zulip database, rather than
Django's "unusable password" (i.e. no password at all). This was a
serious security issue for organizations with both... | def ensure_no_empty_passwords(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
"""With CVE-2019-18933, it was possible for certain users created
using social login (e.g. Google/GitHub auth) to have the empty
string as their password in the Zulip database, rather than
Django's "unusable pas... | [
"def",
"ensure_no_empty_passwords",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"UserProfile",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"UserProfile\"",
")",
"RealmAuditLog",
"=",
"apps"... | [
17,
0
] | [
211,
13
] | python | en | ['en', 'en', 'en'] | True |
make_setuptools_shim_args | (
setup_py_path, # type: str
global_options=None, # type: Sequence[str]
no_user_config=False, # type: bool
unbuffered_output=False # type: bool
) |
Get setuptools command arguments with shim wrapped setup file invocation.
:param setup_py_path: The path to setup.py to be wrapped.
:param global_options: Additional global options.
:param no_user_config: If True, disables personal user configuration.
:param unbuffered_output: If True, adds the un... |
Get setuptools command arguments with shim wrapped setup file invocation. | def make_setuptools_shim_args(
setup_py_path, # type: str
global_options=None, # type: Sequence[str]
no_user_config=False, # type: bool
unbuffered_output=False # type: bool
):
# type: (...) -> List[str]
"""
Get setuptools command arguments with shim wrapped setup file invocation.
:p... | [
"def",
"make_setuptools_shim_args",
"(",
"setup_py_path",
",",
"# type: str",
"global_options",
"=",
"None",
",",
"# type: Sequence[str]",
"no_user_config",
"=",
"False",
",",
"# type: bool",
"unbuffered_output",
"=",
"False",
"# type: bool",
")",
":",
"# type: (...) -> L... | [
22,
0
] | [
46,
15
] | python | en | ['en', 'error', 'th'] | False |
regions | (sourcelist) |
Return a string containing a DS9-compatible region file describing all the
sources in sourcelist.
|
Return a string containing a DS9-compatible region file describing all the
sources in sourcelist.
| def regions(sourcelist):
"""
Return a string containing a DS9-compatible region file describing all the
sources in sourcelist.
"""
output = StringIO()
print >>output, "# Region file format: DS9 version 4.1"
print >>output, "global color=green dashlist=8 3 width=1 font=\"helvetica 10 normal\"... | [
"def",
"regions",
"(",
"sourcelist",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"print",
">>",
"output",
",",
"\"# Region file format: DS9 version 4.1\"",
"print",
">>",
"output",
",",
"\"global color=green dashlist=8 3 width=1 font=\\\"helvetica 10 normal\\\" select=1 hi... | [
37,
0
] | [
55,
28
] | python | en | ['en', 'error', 'th'] | False |
skymodel | (sourcelist, ref_freq=73800000) |
Return a string containing a skymodel from the extracted sources for use in self-calibration.
|
Return a string containing a skymodel from the extracted sources for use in self-calibration.
| def skymodel(sourcelist, ref_freq=73800000):
"""
Return a string containing a skymodel from the extracted sources for use in self-calibration.
"""
output = StringIO()
print >>output, "#(Name, Type, Ra, Dec, I, Q, U, V, MajorAxis, MinorAxis, Orientation, ReferenceFrequency='60e6', SpectralIndex='[0.0... | [
"def",
"skymodel",
"(",
"sourcelist",
",",
"ref_freq",
"=",
"73800000",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"print",
">>",
"output",
",",
"\"#(Name, Type, Ra, Dec, I, Q, U, V, MajorAxis, MinorAxis, Orientation, ReferenceFrequency='60e6', SpectralIndex='[0.0]') = form... | [
57,
0
] | [
74,
28
] | python | en | ['en', 'error', 'th'] | False |
csv | (sourcelist) |
Return a string containing a csv from the extracted sources.
|
Return a string containing a csv from the extracted sources.
| def csv(sourcelist):
"""
Return a string containing a csv from the extracted sources.
"""
output = StringIO()
print >> output, "ra, ra_err, dec, dec_err, smaj, smaj_err, smin, smin_err, pa, pa_err, int_flux, int_flux_err, pk_flux, pk_flux_err"
for source in sourcelist:
print >> output, "... | [
"def",
"csv",
"(",
"sourcelist",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"print",
">>",
"output",
",",
"\"ra, ra_err, dec, dec_err, smaj, smaj_err, smin, smin_err, pa, pa_err, int_flux, int_flux_err, pk_flux, pk_flux_err\"",
"for",
"source",
"in",
"sourcelist",
":",
... | [
76,
0
] | [
99,
28
] | python | en | ['en', 'error', 'th'] | False |
summary | (filename, sourcelist) |
Return a string containing a human-readable summary of all sources in
sourcelist.
|
Return a string containing a human-readable summary of all sources in
sourcelist.
| def summary(filename, sourcelist):
"""
Return a string containing a human-readable summary of all sources in
sourcelist.
"""
output = StringIO()
print >>output, "** %s **\n" % (filename)
for source in sourcelist:
print >>output, "RA: %s, dec: %s" % (str(source.ra), str(source.dec))
... | [
"def",
"summary",
"(",
"filename",
",",
"sourcelist",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"print",
">>",
"output",
",",
"\"** %s **\\n\"",
"%",
"(",
"filename",
")",
"for",
"source",
"in",
"sourcelist",
":",
"print",
">>",
"output",
",",
"\"RA... | [
101,
0
] | [
116,
28
] | python | en | ['en', 'error', 'th'] | False |
handle_args | (args=None) |
Parses command line options & arguments using OptionParser.
Options & default values for the script are defined herein.
|
Parses command line options & arguments using OptionParser.
Options & default values for the script are defined herein.
| def handle_args(args=None):
"""
Parses command line options & arguments using OptionParser.
Options & default values for the script are defined herein.
"""
parser = get_argparser()
options= parser.parse_args()
# Overwrite 'fixed_coords' with a parsed list of coords
# collated from both ... | [
"def",
"handle_args",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"get_argparser",
"(",
")",
"options",
"=",
"parser",
".",
"parse_args",
"(",
")",
"# Overwrite 'fixed_coords' with a parsed list of coords",
"# collated from both command line and file.",
"options",
... | [
181,
0
] | [
224,
33
] | python | en | ['en', 'error', 'th'] | False |
run_sourcefinder | (files, options) |
Iterate over the list of files, running a sourcefinding step on each in
turn. If specified, a DS9-compatible region file and/or a FITS file
showing the residuals after Gaussian fitting are dumped for each file.
A string containing a human readable list of sources is returned.
|
Iterate over the list of files, running a sourcefinding step on each in
turn. If specified, a DS9-compatible region file and/or a FITS file
showing the residuals after Gaussian fitting are dumped for each file.
A string containing a human readable list of sources is returned.
| def run_sourcefinder(files, options):
"""
Iterate over the list of files, running a sourcefinding step on each in
turn. If specified, a DS9-compatible region file and/or a FITS file
showing the residuals after Gaussian fitting are dumped for each file.
A string containing a human readable list of so... | [
"def",
"run_sourcefinder",
"(",
"files",
",",
"options",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"beam",
"=",
"get_beam",
"(",
"options",
".",
"bmaj",
",",
"options",
".",
"bmin",
",",
"options",
".",
"bpa",
")",
"configuration",
"=",
"get_sourcef... | [
272,
0
] | [
351,
28
] | python | en | ['en', 'error', 'th'] | False |
WheelDistribution.get_pkg_resources_distribution | (self) | Loads the metadata from the wheel file into memory and returns a
Distribution that uses it, not relying on the wheel file or
requirement.
| Loads the metadata from the wheel file into memory and returns a
Distribution that uses it, not relying on the wheel file or
requirement.
| def get_pkg_resources_distribution(self):
# type: () -> Distribution
"""Loads the metadata from the wheel file into memory and returns a
Distribution that uses it, not relying on the wheel file or
requirement.
"""
# Set as part of preparation during download.
asse... | [
"def",
"get_pkg_resources_distribution",
"(",
"self",
")",
":",
"# type: () -> Distribution",
"# Set as part of preparation during download.",
"assert",
"self",
".",
"req",
".",
"local_file_path",
"# Wheels are never unnamed.",
"assert",
"self",
".",
"req",
".",
"name",
"wi... | [
18,
4
] | [
32,
13
] | python | en | ['en', 'en', 'en'] | True |
DiffGrad.step | (self, closure: OptLossClosure = None) | r"""Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
| r"""Performs a single optimization step. | def step(self, closure: OptLossClosure = None) -> OptFloat:
r"""Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
"""
loss = None
if closure is not None:
loss = closure()
for group... | [
"def",
"step",
"(",
"self",
",",
"closure",
":",
"OptLossClosure",
"=",
"None",
")",
"->",
"OptFloat",
":",
"loss",
"=",
"None",
"if",
"closure",
"is",
"not",
"None",
":",
"loss",
"=",
"closure",
"(",
")",
"for",
"group",
"in",
"self",
".",
"param_gr... | [
67,
4
] | [
138,
19
] | python | en | ['en', 'en', 'en'] | True |
create_system_job_templates | (apps, schema_editor) |
Create default system job templates if not present. Create default schedules
only if new system job templates were created (i.e. new database).
|
Create default system job templates if not present. Create default schedules
only if new system job templates were created (i.e. new database).
| def create_system_job_templates(apps, schema_editor):
"""
Create default system job templates if not present. Create default schedules
only if new system job templates were created (i.e. new database).
"""
SystemJobTemplate = apps.get_model('main', 'SystemJobTemplate')
Schedule = apps.get_model... | [
"def",
"create_system_job_templates",
"(",
"apps",
",",
"schema_editor",
")",
":",
"SystemJobTemplate",
"=",
"apps",
".",
"get_model",
"(",
"'main'",
",",
"'SystemJobTemplate'",
")",
"Schedule",
"=",
"apps",
".",
"get_model",
"(",
"'main'",
",",
"'Schedule'",
")... | [
18,
0
] | [
102,
20
] | python | en | ['en', 'error', 'th'] | False |
parse_sexp_to_condition | (
sexp: Program,
) |
Takes a KaleLisp sexp and returns a ConditionWithArgs.
If it fails, returns an Error
|
Takes a KaleLisp sexp and returns a ConditionWithArgs.
If it fails, returns an Error
| def parse_sexp_to_condition(
sexp: Program,
) -> Tuple[Optional[Err], Optional[ConditionWithArgs]]:
"""
Takes a KaleLisp sexp and returns a ConditionWithArgs.
If it fails, returns an Error
"""
as_atoms = sexp.as_atom_list()
if len(as_atoms) < 1:
return Err.INVALID_CONDITION, None
... | [
"def",
"parse_sexp_to_condition",
"(",
"sexp",
":",
"Program",
",",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"Err",
"]",
",",
"Optional",
"[",
"ConditionWithArgs",
"]",
"]",
":",
"as_atoms",
"=",
"sexp",
".",
"as_atom_list",
"(",
")",
"if",
"len",
"(",
... | [
18,
0
] | [
35,
56
] | python | en | ['en', 'error', 'th'] | False |
parse_sexp_to_conditions | (
sexp: Program,
) |
Takes a KaleLisp sexp (list) and returns the list of ConditionWithArgss
If it fails, returns as Error
|
Takes a KaleLisp sexp (list) and returns the list of ConditionWithArgss
If it fails, returns as Error
| def parse_sexp_to_conditions(
sexp: Program,
) -> Tuple[Optional[Err], Optional[List[ConditionWithArgs]]]:
"""
Takes a KaleLisp sexp (list) and returns the list of ConditionWithArgss
If it fails, returns as Error
"""
results: List[ConditionWithArgs] = []
try:
for _ in sexp.as_iter():... | [
"def",
"parse_sexp_to_conditions",
"(",
"sexp",
":",
"Program",
",",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"Err",
"]",
",",
"Optional",
"[",
"List",
"[",
"ConditionWithArgs",
"]",
"]",
"]",
":",
"results",
":",
"List",
"[",
"ConditionWithArgs",
"]",
... | [
38,
0
] | [
54,
24
] | python | en | ['en', 'error', 'th'] | False |
conditions_by_opcode | (
conditions: List[ConditionWithArgs],
) |
Takes a list of ConditionWithArgss(CVP) and return dictionary of CVPs keyed of their opcode
|
Takes a list of ConditionWithArgss(CVP) and return dictionary of CVPs keyed of their opcode
| def conditions_by_opcode(
conditions: List[ConditionWithArgs],
) -> Dict[ConditionOpcode, List[ConditionWithArgs]]:
"""
Takes a list of ConditionWithArgss(CVP) and return dictionary of CVPs keyed of their opcode
"""
d: Dict[ConditionOpcode, List[ConditionWithArgs]] = {}
cvp: ConditionWithArgs
... | [
"def",
"conditions_by_opcode",
"(",
"conditions",
":",
"List",
"[",
"ConditionWithArgs",
"]",
",",
")",
"->",
"Dict",
"[",
"ConditionOpcode",
",",
"List",
"[",
"ConditionWithArgs",
"]",
"]",
":",
"d",
":",
"Dict",
"[",
"ConditionOpcode",
",",
"List",
"[",
... | [
57,
0
] | [
69,
12
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandler.format_subject | (self, subject) |
Escape CR and LF characters.
|
Escape CR and LF characters.
| def format_subject(self, subject):
"""
Escape CR and LF characters.
"""
return subject.replace('\n', '\\n').replace('\r', '\\r') | [
"def",
"format_subject",
"(",
"self",
",",
"subject",
")",
":",
"return",
"subject",
".",
"replace",
"(",
"'\\n'",
",",
"'\\\\n'",
")",
".",
"replace",
"(",
"'\\r'",
",",
"'\\\\r'",
")"
] | [
128,
4
] | [
132,
64
] | python | en | ['en', 'error', 'th'] | False |
LeNet.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
self.name = 'LeNet'
CifarModel.__init__(self, args) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"name",
"=",
"'LeNet'",
"CifarModel",
".",
"__init__",
"(",
"self",
",",
"args",
")"
] | [
10,
4
] | [
17,
39
] | python | en | ['en', 'error', 'th'] | False |
LeNet.network | (self, img_input) |
TODO: Write Comment
|
TODO: Write Comment
| def network(self, img_input):
"""
TODO: Write Comment
"""
from tensorflow.keras import initializers, layers, regularizers
weight_decay = 0.0001
x = layers.Conv2D(6, (5, 5), padding='valid', kernel_initializer=initializers.he_normal(), kernel_regularizer=regular... | [
"def",
"network",
"(",
"self",
",",
"img_input",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"initializers",
",",
"layers",
",",
"regularizers",
"weight_decay",
"=",
"0.0001",
"x",
"=",
"layers",
".",
"Conv2D",
"(",
"6",
",",
"(",
"5",
",",
... | [
19,
4
] | [
52,
16
] | python | en | ['en', 'error', 'th'] | False |
LeNet.scheduler | (self, epoch) |
TODO: Write Comment
|
TODO: Write Comment
| def scheduler(self, epoch):
"""
TODO: Write Comment
"""
if epoch < 100:
return 0.01
if epoch < 150:
return 0.005
return 0.001 | [
"def",
"scheduler",
"(",
"self",
",",
"epoch",
")",
":",
"if",
"epoch",
"<",
"100",
":",
"return",
"0.01",
"if",
"epoch",
"<",
"150",
":",
"return",
"0.005",
"return",
"0.001"
] | [
54,
4
] | [
63,
20
] | python | en | ['en', 'error', 'th'] | False |
SingleObjectMixin.get_object | (self, queryset=None) |
Returns the object the view is displaying.
By default this requires `self.queryset` and a `pk` or `slug` argument
in the URLconf, but subclasses can override this to return any object.
|
Returns the object the view is displaying. | def get_object(self, queryset=None):
"""
Returns the object the view is displaying.
By default this requires `self.queryset` and a `pk` or `slug` argument
in the URLconf, but subclasses can override this to return any object.
"""
# Use a custom queryset if provided; this... | [
"def",
"get_object",
"(",
"self",
",",
"queryset",
"=",
"None",
")",
":",
"# Use a custom queryset if provided; this is required for subclasses",
"# like DateDetailView",
"if",
"queryset",
"is",
"None",
":",
"queryset",
"=",
"self",
".",
"get_queryset",
"(",
")",
"# N... | [
21,
4
] | [
56,
18
] | python | en | ['en', 'error', 'th'] | False |
SingleObjectMixin.get_queryset | (self) |
Return the `QuerySet` that will be used to look up the object.
Note that this method is called by the default implementation of
`get_object` and may not be called if `get_object` is overridden.
|
Return the `QuerySet` that will be used to look up the object. | def get_queryset(self):
"""
Return the `QuerySet` that will be used to look up the object.
Note that this method is called by the default implementation of
`get_object` and may not be called if `get_object` is overridden.
"""
if self.queryset is None:
if self... | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"if",
"self",
".",
"queryset",
"is",
"None",
":",
"if",
"self",
".",
"model",
":",
"return",
"self",
".",
"model",
".",
"_default_manager",
".",
"all",
"(",
")",
"else",
":",
"raise",
"ImproperlyConfigured",
... | [
58,
4
] | [
76,
34
] | python | en | ['en', 'error', 'th'] | False |
SingleObjectMixin.get_slug_field | (self) |
Get the name of a slug field to be used to look up by slug.
|
Get the name of a slug field to be used to look up by slug.
| def get_slug_field(self):
"""
Get the name of a slug field to be used to look up by slug.
"""
return self.slug_field | [
"def",
"get_slug_field",
"(",
"self",
")",
":",
"return",
"self",
".",
"slug_field"
] | [
78,
4
] | [
82,
30
] | python | en | ['en', 'error', 'th'] | False |
SingleObjectMixin.get_context_object_name | (self, obj) |
Get the name to use for the object.
|
Get the name to use for the object.
| def get_context_object_name(self, obj):
"""
Get the name to use for the object.
"""
if self.context_object_name:
return self.context_object_name
elif isinstance(obj, models.Model):
return obj._meta.model_name
else:
return None | [
"def",
"get_context_object_name",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"context_object_name",
":",
"return",
"self",
".",
"context_object_name",
"elif",
"isinstance",
"(",
"obj",
",",
"models",
".",
"Model",
")",
":",
"return",
"obj",
".",
... | [
84,
4
] | [
93,
23
] | python | en | ['en', 'error', 'th'] | False |
SingleObjectMixin.get_context_data | (self, **kwargs) |
Insert the single object into the context dict.
|
Insert the single object into the context dict.
| def get_context_data(self, **kwargs):
"""
Insert the single object into the context dict.
"""
context = {}
if self.object:
context['object'] = self.object
context_object_name = self.get_context_object_name(self.object)
if context_object_name:
... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"{",
"}",
"if",
"self",
".",
"object",
":",
"context",
"[",
"'object'",
"]",
"=",
"self",
".",
"object",
"context_object_name",
"=",
"self",
".",
"get_context_obje... | [
95,
4
] | [
106,
73
] | python | en | ['en', 'error', 'th'] | False |
SingleObjectTemplateResponseMixin.get_template_names | (self) |
Return a list of template names to be used for the request. May not be
called if render_to_response is overridden. Returns the following list:
* the value of ``template_name`` on the view (if provided)
* the contents of the ``template_name_field`` field on the
object instance... |
Return a list of template names to be used for the request. May not be
called if render_to_response is overridden. Returns the following list: | def get_template_names(self):
"""
Return a list of template names to be used for the request. May not be
called if render_to_response is overridden. Returns the following list:
* the value of ``template_name`` on the view (if provided)
* the contents of the ``template_name_field... | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"try",
":",
"names",
"=",
"super",
"(",
"SingleObjectTemplateResponseMixin",
",",
"self",
")",
".",
"get_template_names",
"(",
")",
"except",
"ImproperlyConfigured",
":",
"# If template_name isn't specified, it's not a... | [
123,
4
] | [
169,
20
] | python | en | ['en', 'error', 'th'] | False |
Composable.as_string | (self, context) |
Return the string value of the object.
:param context: the context to evaluate the string into.
:type context: `connection` or `cursor`
The method is automatically invoked by `~cursor.execute()`,
`~cursor.executemany()`, `~cursor.copy_expert()` if a `!Composable` is
pa... |
Return the string value of the object. | def as_string(self, context):
"""
Return the string value of the object.
:param context: the context to evaluate the string into.
:type context: `connection` or `cursor`
The method is automatically invoked by `~cursor.execute()`,
`~cursor.executemany()`, `~cursor.copy_e... | [
"def",
"as_string",
"(",
"self",
",",
"context",
")",
":",
"raise",
"NotImplementedError"
] | [
54,
4
] | [
65,
33
] | python | en | ['en', 'error', 'th'] | False |
Composed.seq | (self) | The list of the content of the `!Composed`. | The list of the content of the `!Composed`. | def seq(self):
"""The list of the content of the `!Composed`."""
return list(self._wrapped) | [
"def",
"seq",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"_wrapped",
")"
] | [
114,
4
] | [
116,
34
] | python | en | ['en', 'en', 'en'] | True |
Composed.join | (self, joiner) |
Return a new `!Composed` interposing the *joiner* with the `!Composed` items.
The *joiner* must be a `SQL` or a string which will be interpreted as
an `SQL`.
Example::
>>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Composed
>>> print(fields.jo... |
Return a new `!Composed` interposing the *joiner* with the `!Composed` items. | def join(self, joiner):
"""
Return a new `!Composed` interposing the *joiner* with the `!Composed` items.
The *joiner* must be a `SQL` or a string which will be interpreted as
an `SQL`.
Example::
>>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Compo... | [
"def",
"join",
"(",
"self",
",",
"joiner",
")",
":",
"if",
"isinstance",
"(",
"joiner",
",",
"str",
")",
":",
"joiner",
"=",
"SQL",
"(",
"joiner",
")",
"elif",
"not",
"isinstance",
"(",
"joiner",
",",
"SQL",
")",
":",
"raise",
"TypeError",
"(",
"\"... | [
135,
4
] | [
155,
32
] | python | en | ['en', 'error', 'th'] | False |
SQL.string | (self) | The string wrapped by the `!SQL` object. | The string wrapped by the `!SQL` object. | def string(self):
"""The string wrapped by the `!SQL` object."""
return self._wrapped | [
"def",
"string",
"(",
"self",
")",
":",
"return",
"self",
".",
"_wrapped"
] | [
186,
4
] | [
188,
28
] | python | en | ['en', 'en', 'en'] | True |
SQL.format | (self, *args, **kwargs) |
Merge `Composable` objects into a template.
:param `Composable` args: parameters to replace to numbered
(``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders
:param `Composable` kwargs: parameters to replace to named (``{name}``)
placeholders
:return: the un... |
Merge `Composable` objects into a template. | def format(self, *args, **kwargs):
"""
Merge `Composable` objects into a template.
:param `Composable` args: parameters to replace to numbered
(``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders
:param `Composable` kwargs: parameters to replace to named (``{name}``)
... | [
"def",
"format",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"rv",
"=",
"[",
"]",
"autonum",
"=",
"0",
"for",
"pre",
",",
"name",
",",
"spec",
",",
"conv",
"in",
"_formatter",
".",
"parse",
"(",
"self",
".",
"_wrapped",
")... | [
193,
4
] | [
255,
27
] | python | en | ['en', 'error', 'th'] | False |
SQL.join | (self, seq) |
Join a sequence of `Composable`.
:param seq: the elements to join.
:type seq: iterable of `!Composable`
Use the `!SQL` object's *string* to separate the elements in *seq*.
Note that `Composed` objects are iterable too, so they can be used as
argument for this method.
... |
Join a sequence of `Composable`. | def join(self, seq):
"""
Join a sequence of `Composable`.
:param seq: the elements to join.
:type seq: iterable of `!Composable`
Use the `!SQL` object's *string* to separate the elements in *seq*.
Note that `Composed` objects are iterable too, so they can be used as
... | [
"def",
"join",
"(",
"self",
",",
"seq",
")",
":",
"rv",
"=",
"[",
"]",
"it",
"=",
"iter",
"(",
"seq",
")",
"try",
":",
"rv",
".",
"append",
"(",
"next",
"(",
"it",
")",
")",
"except",
"StopIteration",
":",
"pass",
"else",
":",
"for",
"i",
"in... | [
257,
4
] | [
286,
27
] | python | en | ['en', 'error', 'th'] | False |
Identifier.string | (self) | The string wrapped by the `Identifier`. | The string wrapped by the `Identifier`. | def string(self):
"""The string wrapped by the `Identifier`."""
return self._wrapped | [
"def",
"string",
"(",
"self",
")",
":",
"return",
"self",
".",
"_wrapped"
] | [
316,
4
] | [
318,
28
] | python | en | ['en', 'en', 'en'] | True |
Literal.wrapped | (self) | The object wrapped by the `!Literal`. | The object wrapped by the `!Literal`. | def wrapped(self):
"""The object wrapped by the `!Literal`."""
return self._wrapped | [
"def",
"wrapped",
"(",
"self",
")",
":",
"return",
"self",
".",
"_wrapped"
] | [
345,
4
] | [
347,
28
] | python | en | ['en', 'en', 'en'] | True |
Placeholder.name | (self) | The name of the `!Placeholder`. | The name of the `!Placeholder`. | def name(self):
"""The name of the `!Placeholder`."""
return self._wrapped | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_wrapped"
] | [
407,
4
] | [
409,
28
] | python | en | ['en', 'en', 'en'] | True |
LSConditionalDensityEstimation.fit | (self, X, Y, **kwargs) | Fits the conditional density model with provided data
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
| Fits the conditional density model with provided data | def fit(self, X, Y, **kwargs):
""" Fits the conditional density model with provided data
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
"""
# assert that both X an Y are 2D arrays with shape (n_samples,... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"Y",
",",
"*",
"*",
"kwargs",
")",
":",
"# assert that both X an Y are 2D arrays with shape (n_samples, n_dim)",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
",",
"fitting",
"=",... | [
76,
2
] | [
104,
22
] | python | en | ['en', 'en', 'en'] | True |
LSConditionalDensityEstimation.pdf | (self, X, Y) | Predicts the conditional density p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional probability density p(y|x) - numpy array of shape ... | Predicts the conditional density p(y|x). Requires the model to be fitted. | def pdf(self, X, Y):
""" Predicts the conditional density p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional probability density p(... | [
"def",
"pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted for predictions\"",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
")",
"n_samples",
"=",
"X",
".... | [
106,
2
] | [
125,
28
] | python | en | ['en', 'en', 'en'] | True |
LSConditionalDensityEstimation.log_pdf | (self, X, Y) | Predicts the conditional log-probability log p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional log-probability density... | Predicts the conditional log-probability log p(y|x). Requires the model to be fitted. | def log_pdf(self, X, Y):
""" Predicts the conditional log-probability log p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
con... | [
"def",
"log_pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"assert",
"self",
".",
"fitted",
",",
"\"model must be fitted for predictions\"",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
")",
"n_samples",
"=",
"X",
... | [
127,
2
] | [
146,
32
] | python | en | ['en', 'en', 'en'] | True |
LSConditionalDensityEstimation.mean_std | (self, X, n_samples=10 ** 6) | sample from the conditional mixture distributions - requires the model to be fitted
Args:
X: values to be conditioned on - numpy array of shape (n_instances, n_dim_x)
Returns: tuple (mean, stddev)
- mean - numpy array of shape (n_samples, ndim_y)
- stddev - - numpy array of shape (n_sampl... | sample from the conditional mixture distributions - requires the model to be fitted | def mean_std(self, X, n_samples=10 ** 6):
""" sample from the conditional mixture distributions - requires the model to be fitted
Args:
X: values to be conditioned on - numpy array of shape (n_instances, n_dim_x)
Returns: tuple (mean, stddev)
- mean - numpy array of shape (n_samples, ndim_y)... | [
"def",
"mean_std",
"(",
"self",
",",
"X",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"assert",
"self",
".",
"fitted",
"X",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
")",
"fact",
"=",
"np",
".",
"multiply",
"(",
"self",
".",
... | [
148,
2
] | [
169,
69
] | python | en | ['en', 'en', 'en'] | True |
LSConditionalDensityEstimation.sample | (self, X) | sample from the conditional mixture distributions - requires the model to be fitted
Args:
X: values to be conditioned on when sampling - numpy array of shape (n_instances, n_dim_x)
Returns: tuple (X, Y)
- X - the values to conditioned on that were provided as argument - numpy array of shape (n_sa... | sample from the conditional mixture distributions - requires the model to be fitted | def sample(self, X):
""" sample from the conditional mixture distributions - requires the model to be fitted
Args:
X: values to be conditioned on when sampling - numpy array of shape (n_instances, n_dim_x)
Returns: tuple (X, Y)
- X - the values to conditioned on that were provided as argument ... | [
"def",
"sample",
"(",
"self",
",",
"X",
")",
":",
"assert",
"self",
".",
"fitted",
"X",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
")",
"weights",
"=",
"np",
".",
"multiply",
"(",
"self",
".",
"alpha",
",",
"self",
".",
"_gaussian_kern... | [
171,
2
] | [
193,
15
] | python | en | ['en', 'en', 'en'] | True |
LSConditionalDensityEstimation._gaussian_kernel | (self, X, Y=None) |
if Y is set returns the product of the gaussian kernels for X and Y, else only the gaussian kernel for X
:param X: numpy array of size (n_samples, ndim_x)
:param Y: numpy array of size (n_samples, ndim_y)
:return: phi - numpy array of size (n_samples, n_centers)
|
if Y is set returns the product of the gaussian kernels for X and Y, else only the gaussian kernel for X
:param X: numpy array of size (n_samples, ndim_x)
:param Y: numpy array of size (n_samples, ndim_y)
:return: phi - numpy array of size (n_samples, n_centers)
| def _gaussian_kernel(self, X, Y=None):
"""
if Y is set returns the product of the gaussian kernels for X and Y, else only the gaussian kernel for X
:param X: numpy array of size (n_samples, ndim_x)
:param Y: numpy array of size (n_samples, ndim_y)
:return: phi - numpy array of size (n_samples, n_ce... | [
"def",
"_gaussian_kernel",
"(",
"self",
",",
"X",
",",
"Y",
"=",
"None",
")",
":",
"return",
"np",
".",
"exp",
"(",
"self",
".",
"_log_gaussian_kernel",
"(",
"X",
",",
"Y",
")",
")"
] | [
211,
2
] | [
218,
50
] | python | en | ['en', 'error', 'th'] | False |
LSConditionalDensityEstimation._log_gaussian_kernel | (self, X, Y=None) |
if Y is set returns the sum of the gaussian log-kernels for X and Y, else only the gaussian log-kernel for X
:param X: numpy array of size (n_samples, ndim_x)
:param Y: numpy array of size (n_samples, ndim_y)
:return: phi - numpy array of size (n_samples, n_centers)
|
if Y is set returns the sum of the gaussian log-kernels for X and Y, else only the gaussian log-kernel for X
:param X: numpy array of size (n_samples, ndim_x)
:param Y: numpy array of size (n_samples, ndim_y)
:return: phi - numpy array of size (n_samples, n_centers)
| def _log_gaussian_kernel(self, X, Y=None):
"""
if Y is set returns the sum of the gaussian log-kernels for X and Y, else only the gaussian log-kernel for X
:param X: numpy array of size (n_samples, ndim_x)
:param Y: numpy array of size (n_samples, ndim_y)
:return: phi - numpy array of size (n_sampl... | [
"def",
"_log_gaussian_kernel",
"(",
"self",
",",
"X",
",",
"Y",
"=",
"None",
")",
":",
"phi",
"=",
"np",
".",
"zeros",
"(",
"shape",
"=",
"(",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"self",
".",
"n_centers",
")",
")",
"if",
"Y",
"is",
"not",
... | [
220,
2
] | [
244,
14
] | python | en | ['en', 'error', 'th'] | False |
Writer.__init__ | (self, tool_file_path, name) | Initializes the tool file.
Args:
tool_file_path: Path to the tool file.
name: Name of the tool file.
| Initializes the tool file. | def __init__(self, tool_file_path, name):
"""Initializes the tool file.
Args:
tool_file_path: Path to the tool file.
name: Name of the tool file.
"""
self.tool_file_path = tool_file_path
self.name = name
self.rules_section = ["Rules"] | [
"def",
"__init__",
"(",
"self",
",",
"tool_file_path",
",",
"name",
")",
":",
"self",
".",
"tool_file_path",
"=",
"tool_file_path",
"self",
".",
"name",
"=",
"name",
"self",
".",
"rules_section",
"=",
"[",
"\"Rules\"",
"]"
] | [
12,
4
] | [
21,
38
] | python | en | ['en', 'en', 'en'] | True |
Writer.AddCustomBuildRule | (
self, name, cmd, description, additional_dependencies, outputs, extensions
) | Adds a rule to the tool file.
Args:
name: Name of the rule.
description: Description of the rule.
cmd: Command line of the rule.
additional_dependencies: other files which may trigger the rule.
outputs: outputs of the rule.
extensions: extensions handled by the rule.
| Adds a rule to the tool file. | def AddCustomBuildRule(
self, name, cmd, description, additional_dependencies, outputs, extensions
):
"""Adds a rule to the tool file.
Args:
name: Name of the rule.
description: Description of the rule.
cmd: Command line of the rule.
additional_dependencies: other files ... | [
"def",
"AddCustomBuildRule",
"(",
"self",
",",
"name",
",",
"cmd",
",",
"description",
",",
"additional_dependencies",
",",
"outputs",
",",
"extensions",
")",
":",
"rule",
"=",
"[",
"\"CustomBuildRule\"",
",",
"{",
"\"Name\"",
":",
"name",
",",
"\"ExecutionDes... | [
23,
4
] | [
47,
39
] | python | en | ['en', 'en', 'en'] | True |
Writer.WriteIfChanged | (self) | Writes the tool file. | Writes the tool file. | def WriteIfChanged(self):
"""Writes the tool file."""
content = [
"VisualStudioToolFile",
{"Version": "8.00", "Name": self.name},
self.rules_section,
]
easy_xml.WriteXmlIfChanged(
content, self.tool_file_path, encoding="Windows-1252"
... | [
"def",
"WriteIfChanged",
"(",
"self",
")",
":",
"content",
"=",
"[",
"\"VisualStudioToolFile\"",
",",
"{",
"\"Version\"",
":",
"\"8.00\"",
",",
"\"Name\"",
":",
"self",
".",
"name",
"}",
",",
"self",
".",
"rules_section",
",",
"]",
"easy_xml",
".",
"WriteX... | [
49,
4
] | [
58,
9
] | python | en | ['en', 'mi', 'en'] | True |
read_pkg_file | (self, file) | Reads the metadata values from a file object. | Reads the metadata values from a file object. | def read_pkg_file(self, file):
"""Reads the metadata values from a file object."""
msg = message_from_file(file)
def _read_field(name):
value = msg[name]
if value == 'UNKNOWN':
return None
return value
def _read_list(name):
values = msg.get_all(name, None)
... | [
"def",
"read_pkg_file",
"(",
"self",
",",
"file",
")",
":",
"msg",
"=",
"message_from_file",
"(",
"file",
")",
"def",
"_read_field",
"(",
"name",
")",
":",
"value",
"=",
"msg",
"[",
"name",
"]",
"if",
"value",
"==",
"'UNKNOWN'",
":",
"return",
"None",
... | [
67,
0
] | [
117,
29
] | python | en | ['en', 'en', 'en'] | True |
write_pkg_file | (self, file) | Write the PKG-INFO format data to a file object.
| Write the PKG-INFO format data to a file object.
| def write_pkg_file(self, file):
"""Write the PKG-INFO format data to a file object.
"""
version = self.get_metadata_version()
def write_field(key, value):
file.write("%s: %s\n" % (key, value))
write_field('Metadata-Version', str(version))
write_field('Name', self.get_name())
write_... | [
"def",
"write_pkg_file",
"(",
"self",
",",
"file",
")",
":",
"version",
"=",
"self",
".",
"get_metadata_version",
"(",
")",
"def",
"write_field",
"(",
"key",
",",
"value",
")",
":",
"file",
".",
"write",
"(",
"\"%s: %s\\n\"",
"%",
"(",
"key",
",",
"val... | [
121,
0
] | [
190,
48
] | python | en | ['en', 'en', 'en'] | True |
assert_string_list | (dist, attr, value) | Verify that value is a string list | Verify that value is a string list | def assert_string_list(dist, attr, value):
"""Verify that value is a string list"""
try:
# verify that value is a list or tuple to exclude unordered
# or single-use iterables
assert isinstance(value, (list, tuple))
# verify that elements of value are strings
assert ''.joi... | [
"def",
"assert_string_list",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"# verify that value is a list or tuple to exclude unordered",
"# or single-use iterables",
"assert",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
"# ... | [
207,
0
] | [
218,
16
] | python | en | ['en', 'en', 'en'] | True |
check_nsp | (dist, attr, value) | Verify that namespace packages are valid | Verify that namespace packages are valid | def check_nsp(dist, attr, value):
"""Verify that namespace packages are valid"""
ns_packages = value
assert_string_list(dist, attr, ns_packages)
for nsp in ns_packages:
if not dist.has_contents_for(nsp):
raise DistutilsSetupError(
"Distribution contains no modules or ... | [
"def",
"check_nsp",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"ns_packages",
"=",
"value",
"assert_string_list",
"(",
"dist",
",",
"attr",
",",
"ns_packages",
")",
"for",
"nsp",
"in",
"ns_packages",
":",
"if",
"not",
"dist",
".",
"has_contents_for"... | [
221,
0
] | [
236,
13
] | python | en | ['en', 'en', 'en'] | True |
check_extras | (dist, attr, value) | Verify that extras_require mapping is valid | Verify that extras_require mapping is valid | def check_extras(dist, attr, value):
"""Verify that extras_require mapping is valid"""
try:
list(itertools.starmap(_check_extra, value.items()))
except (TypeError, ValueError, AttributeError) as e:
raise DistutilsSetupError(
"'extras_require' must be a dictionary whose values are... | [
"def",
"check_extras",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"list",
"(",
"itertools",
".",
"starmap",
"(",
"_check_extra",
",",
"value",
".",
"items",
"(",
")",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
",",
"A... | [
239,
0
] | [
248,
16
] | python | en | ['en', 'en', 'en'] | True |
assert_bool | (dist, attr, value) | Verify that value is True, False, 0, or 1 | Verify that value is True, False, 0, or 1 | def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
tmpl = "{attr!r} must be a boolean value (got {value!r})"
raise DistutilsSetupError(tmpl.format(attr=attr, value=value)) | [
"def",
"assert_bool",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"if",
"bool",
"(",
"value",
")",
"!=",
"value",
":",
"tmpl",
"=",
"\"{attr!r} must be a boolean value (got {value!r})\"",
"raise",
"DistutilsSetupError",
"(",
"tmpl",
".",
"format",
"(",
"... | [
258,
0
] | [
262,
70
] | python | en | ['en', 'en', 'en'] | True |
check_requirements | (dist, attr, value) | Verify that install_requires is a valid requirements list | Verify that install_requires is a valid requirements list | def check_requirements(dist, attr, value):
"""Verify that install_requires is a valid requirements list"""
try:
list(pkg_resources.parse_requirements(value))
if isinstance(value, (dict, set)):
raise TypeError("Unordered types are not allowed")
except (TypeError, ValueError) as er... | [
"def",
"check_requirements",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"list",
"(",
"pkg_resources",
".",
"parse_requirements",
"(",
"value",
")",
")",
"if",
"isinstance",
"(",
"value",
",",
"(",
"dict",
",",
"set",
")",
")",
":",
... | [
265,
0
] | [
278,
20
] | python | en | ['en', 'en', 'en'] | True |
check_specifier | (dist, attr, value) | Verify that value is a valid version specifier | Verify that value is a valid version specifier | def check_specifier(dist, attr, value):
"""Verify that value is a valid version specifier"""
try:
packaging.specifiers.SpecifierSet(value)
except packaging.specifiers.InvalidSpecifier as error:
tmpl = (
"{attr!r} must be a string "
"containing valid version specifiers... | [
"def",
"check_specifier",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"packaging",
".",
"specifiers",
".",
"SpecifierSet",
"(",
"value",
")",
"except",
"packaging",
".",
"specifiers",
".",
"InvalidSpecifier",
"as",
"error",
":",
"tmpl",
"... | [
281,
0
] | [
292,
20
] | python | en | ['en', 'en', 'en'] | True |
check_entry_points | (dist, attr, value) | Verify that entry_points map is parseable | Verify that entry_points map is parseable | def check_entry_points(dist, attr, value):
"""Verify that entry_points map is parseable"""
try:
pkg_resources.EntryPoint.parse_map(value)
except ValueError as e:
raise DistutilsSetupError(e) from e | [
"def",
"check_entry_points",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"pkg_resources",
".",
"EntryPoint",
".",
"parse_map",
"(",
"value",
")",
"except",
"ValueError",
"as",
"e",
":",
"raise",
"DistutilsSetupError",
"(",
"e",
")",
"from... | [
295,
0
] | [
300,
43
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.