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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
scopedef_t.typedefs | (
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None) | returns a set of typedef declarations, that are matched
defined criteria | returns a set of typedef declarations, that are matched
defined criteria | def typedefs(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of typedef declarations, that are matched
defined criteria"""
return (
... | [
"def",
"typedefs",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
... | [
1186,
4
] | [
1207,
9
] | python | en | ['en', 'en', 'en'] | True |
scopedef_t.__getitem__ | (self, name_or_function) |
Allow simple name based find of declarations. Internally just calls
`decls` method.
:param name_or_function: Name of `decl` to lookup or finder function.
|
Allow simple name based find of declarations. Internally just calls
`decls` method.
:param name_or_function: Name of `decl` to lookup or finder function.
| def __getitem__(self, name_or_function):
"""
Allow simple name based find of declarations. Internally just calls
`decls` method.
:param name_or_function: Name of `decl` to lookup or finder function.
"""
return self.decls(name_or_function) | [
"def",
"__getitem__",
"(",
"self",
",",
"name_or_function",
")",
":",
"return",
"self",
".",
"decls",
"(",
"name_or_function",
")"
] | [
1209,
4
] | [
1215,
43
] | python | en | ['en', 'error', 'th'] | False |
colored | (text, color=None, on_color=None, attrs=None) | Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, underline, blink, reverse, concealed.
Example:
color... | Colorize text. | def colored(text, color=None, on_color=None, attrs=None):
"""Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, ... | [
"def",
"colored",
"(",
"text",
",",
"color",
"=",
"None",
",",
"on_color",
"=",
"None",
",",
"attrs",
"=",
"None",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"'ANSI_COLORS_DISABLED'",
")",
"is",
"None",
":",
"fmt_str",
"=",
"'\\033[%dm%s'",
"if",
"color... | [
85,
0
] | [
114,
15
] | python | en | ['en', 'fr', 'en'] | False |
cprint | (text, color=None, on_color=None, attrs=None, **kwargs) | Print colorize text.
It accepts arguments of print function.
| Print colorize text. | def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
"""Print colorize text.
It accepts arguments of print function.
"""
print((colored(text, color, on_color, attrs)), **kwargs) | [
"def",
"cprint",
"(",
"text",
",",
"color",
"=",
"None",
",",
"on_color",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"(",
"(",
"colored",
"(",
"text",
",",
"color",
",",
"on_color",
",",
"attrs",
")",
")",... | [
117,
0
] | [
123,
60
] | python | en | ['en', 'fr', 'it'] | False |
smart_pointer_traits.is_smart_pointer | (type_) | returns True, if type represents instantiation of
`boost::shared_ptr` or `std::shared_ptr`, False otherwise | returns True, if type represents instantiation of
`boost::shared_ptr` or `std::shared_ptr`, False otherwise | def is_smart_pointer(type_):
"""returns True, if type represents instantiation of
`boost::shared_ptr` or `std::shared_ptr`, False otherwise"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
type_ = type_traits.remove_declarated(type_)
if not ... | [
"def",
"is_smart_pointer",
"(",
"type_",
")",
":",
"type_",
"=",
"type_traits",
".",
"remove_alias",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_cv",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_declarated",
"(",
"type_",
")"... | [
46,
4
] | [
63,
62
] | python | en | ['en', 'nl', 'en'] | True |
smart_pointer_traits.value_type | (type_) | returns reference to `boost::shared_ptr` \
or `std::shared_ptr` value type | returns reference to `boost::shared_ptr` \
or `std::shared_ptr` value type | def value_type(type_):
"""returns reference to `boost::shared_ptr` \
or `std::shared_ptr` value type"""
if not smart_pointer_traits.is_smart_pointer(type_):
raise TypeError(
'Type "%s" is not an instantiation of \
boost::shared_ptr or std::shared_ptr' ... | [
"def",
"value_type",
"(",
"type_",
")",
":",
"if",
"not",
"smart_pointer_traits",
".",
"is_smart_pointer",
"(",
"type_",
")",
":",
"raise",
"TypeError",
"(",
"'Type \"%s\" is not an instantiation of \\\n boost::shared_ptr or std::shared_ptr'",
"%",
"type_",
"... | [
66,
4
] | [
74,
68
] | python | en | ['en', 'en', 'en'] | True |
auto_ptr_traits.is_smart_pointer | (type_) | returns True, if type represents instantiation of
`boost::shared_ptr`, False otherwise | returns True, if type represents instantiation of
`boost::shared_ptr`, False otherwise | def is_smart_pointer(type_):
"""returns True, if type represents instantiation of
`boost::shared_ptr`, False otherwise"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
type_ = type_traits.remove_declarated(type_)
if not isinstance(type_,
... | [
"def",
"is_smart_pointer",
"(",
"type_",
")",
":",
"type_",
"=",
"type_traits",
".",
"remove_alias",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_cv",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_declarated",
"(",
"type_",
")"... | [
83,
4
] | [
96,
63
] | python | en | ['en', 'nl', 'en'] | True |
auto_ptr_traits.value_type | (type_) | returns reference to `boost::shared_ptr` value type | returns reference to `boost::shared_ptr` value type | def value_type(type_):
"""returns reference to `boost::shared_ptr` value type"""
if not auto_ptr_traits.is_smart_pointer(type_):
raise TypeError(
'Type "%s" is not instantiation of std::auto_ptr' %
type_.decl_string)
return internal_type_traits.get_by_... | [
"def",
"value_type",
"(",
"type_",
")",
":",
"if",
"not",
"auto_ptr_traits",
".",
"is_smart_pointer",
"(",
"type_",
")",
":",
"raise",
"TypeError",
"(",
"'Type \"%s\" is not instantiation of std::auto_ptr'",
"%",
"type_",
".",
"decl_string",
")",
"return",
"internal... | [
99,
4
] | [
105,
70
] | python | en | ['en', 'en', 'en'] | True |
TeamCityReporter.report_message_type | (self, msg) | Issues an `inspectionType` service message to define generic properties of a given PyLint message type.
:param utils.Message msg: a PyLint message
| Issues an `inspectionType` service message to define generic properties of a given PyLint message type.
:param utils.Message msg: a PyLint message
| def report_message_type(self, msg):
"""Issues an `inspectionType` service message to define generic properties of a given PyLint message type.
:param utils.Message msg: a PyLint message
"""
desc = get_message_description(self.linter, msg.msg_id)
self.tc.message('inspectionType', ... | [
"def",
"report_message_type",
"(",
"self",
",",
"msg",
")",
":",
"desc",
"=",
"get_message_description",
"(",
"self",
".",
"linter",
",",
"msg",
".",
"msg_id",
")",
"self",
".",
"tc",
".",
"message",
"(",
"'inspectionType'",
",",
"id",
"=",
"msg",
".",
... | [
61,
4
] | [
66,
138
] | python | en | ['en', 'en', 'en'] | True |
TeamCityReporter.handle_message | (self, msg) | Issues an `inspection` service message based on a PyLint message.
Registers each message type upon first encounter.
:param utils.Message msg: a PyLint message
| Issues an `inspection` service message based on a PyLint message.
Registers each message type upon first encounter. | def handle_message(self, msg):
"""Issues an `inspection` service message based on a PyLint message.
Registers each message type upon first encounter.
:param utils.Message msg: a PyLint message
"""
if msg.msg_id not in self.msg_types:
self.report_message_type(msg)
... | [
"def",
"handle_message",
"(",
"self",
",",
"msg",
")",
":",
"if",
"msg",
".",
"msg_id",
"not",
"in",
"self",
".",
"msg_types",
":",
"self",
".",
"report_message_type",
"(",
"msg",
")",
"self",
".",
"msg_types",
".",
"add",
"(",
"msg",
".",
"msg_id",
... | [
68,
4
] | [
81,
63
] | python | en | ['en', 'en', 'en'] | True |
TeamCityReporter.display_reports | (self, layout) | Issues the final PyLint score as a TeamCity build statistic value | Issues the final PyLint score as a TeamCity build statistic value | def display_reports(self, layout):
"""Issues the final PyLint score as a TeamCity build statistic value"""
try:
score = self.linter.stats['global_note']
except (AttributeError, KeyError):
pass
else:
self.tc.message('buildStatisticValue', key='PyLintSco... | [
"def",
"display_reports",
"(",
"self",
",",
"layout",
")",
":",
"try",
":",
"score",
"=",
"self",
".",
"linter",
".",
"stats",
"[",
"'global_note'",
"]",
"except",
"(",
"AttributeError",
",",
"KeyError",
")",
":",
"pass",
"else",
":",
"self",
".",
"tc"... | [
83,
4
] | [
90,
87
] | python | en | ['en', 'en', 'en'] | True |
unique_proportion | (_metrics) | Computes the proportion of unique non-null values out of all non-null values | Computes the proportion of unique non-null values out of all non-null values | def unique_proportion(_metrics):
"""Computes the proportion of unique non-null values out of all non-null values"""
total_values = _metrics.get("table.row_count")
unique_values = _metrics.get("column.distinct_values.count")
null_count = _metrics.get("column_values.nonnull.unexpected_count")
# Ensur... | [
"def",
"unique_proportion",
"(",
"_metrics",
")",
":",
"total_values",
"=",
"_metrics",
".",
"get",
"(",
"\"table.row_count\"",
")",
"unique_values",
"=",
"_metrics",
".",
"get",
"(",
"\"column.distinct_values.count\"",
")",
"null_count",
"=",
"_metrics",
".",
"ge... | [
22,
0
] | [
32,
16
] | python | en | ['en', 'en', 'en'] | True |
test_query_store_store_backend_id | (basic_sqlalchemy_query_store) |
What does this test and why?
A Store should be able to report it's store_backend_id
which is set when the StoreBackend is instantiated.
|
What does this test and why?
A Store should be able to report it's store_backend_id
which is set when the StoreBackend is instantiated.
| def test_query_store_store_backend_id(basic_sqlalchemy_query_store):
"""
What does this test and why?
A Store should be able to report it's store_backend_id
which is set when the StoreBackend is instantiated.
"""
# Check that store_backend_id exists can be read
assert basic_sqlalchemy_query_... | [
"def",
"test_query_store_store_backend_id",
"(",
"basic_sqlalchemy_query_store",
")",
":",
"# Check that store_backend_id exists can be read",
"assert",
"basic_sqlalchemy_query_store",
".",
"store_backend_id",
"is",
"not",
"None",
"# Check that store_backend_id is a valid UUID",
"asser... | [
61,
0
] | [
70,
83
] | python | en | ['en', 'error', 'th'] | False |
MetricParameterBuilder.__init__ | (
self,
parameter_name: str,
metric_name: str,
metric_domain_kwargs: Optional[Union[str, dict]] = None,
metric_value_kwargs: Optional[Union[str, dict]] = None,
enforce_numeric_metric: Optional[Union[str, bool]] = False,
replace_nan_with_zero: Optional[Union[str, b... |
Args:
parameter_name: the name of this parameter -- this is user-specified parameter name (from configuration);
it is not the fully-qualified parameter name; a fully-qualified parameter name must start with "$parameter."
and may contain one or more subsequent parts (e.g., "$... |
Args:
parameter_name: the name of this parameter -- this is user-specified parameter name (from configuration);
it is not the fully-qualified parameter name; a fully-qualified parameter name must start with "$parameter."
and may contain one or more subsequent parts (e.g., "$... | def __init__(
self,
parameter_name: str,
metric_name: str,
metric_domain_kwargs: Optional[Union[str, dict]] = None,
metric_value_kwargs: Optional[Union[str, dict]] = None,
enforce_numeric_metric: Optional[Union[str, bool]] = False,
replace_nan_with_zero: Optional[... | [
"def",
"__init__",
"(",
"self",
",",
"parameter_name",
":",
"str",
",",
"metric_name",
":",
"str",
",",
"metric_domain_kwargs",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"dict",
"]",
"]",
"=",
"None",
",",
"metric_value_kwargs",
":",
"Optional",
"[",... | [
19,
4
] | [
55,
59
] | python | en | ['en', 'error', 'th'] | False |
MetricParameterBuilder._build_parameters | (
self,
parameter_container: ParameterContainer,
domain: Domain,
*,
variables: Optional[ParameterContainer] = None,
parameters: Optional[Dict[str, ParameterContainer]] = None,
) |
Builds ParameterContainer object that holds ParameterNode objects with attribute name-value pairs and optional details.
Args:
:return: a ParameterContainer object that holds ParameterNode objects with attribute name-value pairs and optional details
|
Builds ParameterContainer object that holds ParameterNode objects with attribute name-value pairs and optional details.
Args:
:return: a ParameterContainer object that holds ParameterNode objects with attribute name-value pairs and optional details
| def _build_parameters(
self,
parameter_container: ParameterContainer,
domain: Domain,
*,
variables: Optional[ParameterContainer] = None,
parameters: Optional[Dict[str, ParameterContainer]] = None,
):
"""
Builds ParameterContainer object that holds Para... | [
"def",
"_build_parameters",
"(",
"self",
",",
"parameter_container",
":",
"ParameterContainer",
",",
"domain",
":",
"Domain",
",",
"*",
",",
"variables",
":",
"Optional",
"[",
"ParameterContainer",
"]",
"=",
"None",
",",
"parameters",
":",
"Optional",
"[",
"Di... | [
57,
4
] | [
99,
9
] | python | en | ['en', 'error', 'th'] | False |
ExpectColumnValueZScoresToBeLessThan.validate_configuration | (self, configuration: Optional[ExpectationConfiguration]) |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
Args:
configuration (OPTIONAL[ExpectationConfiguration]): \
An opt... |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation. | def validate_configuration(self, configuration: Optional[ExpectationConfiguration]):
"""
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
... | [
"def",
"validate_configuration",
"(",
"self",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
")",
":",
"# Setting up a configuration",
"super",
"(",
")",
".",
"validate_configuration",
"(",
"configuration",
")",
"if",
"configuration",
"is... | [
83,
4
] | [
121,
19
] | python | en | ['en', 'error', 'th'] | False |
test_cli_datasource_list | (empty_data_context, empty_sqlite_db, caplog) | Test an empty project and after adding a single datasource. | Test an empty project and after adding a single datasource. | def test_cli_datasource_list(empty_data_context, empty_sqlite_db, caplog):
"""Test an empty project and after adding a single datasource."""
project_root_dir = empty_data_context.root_directory
context = DataContext(project_root_dir)
runner = CliRunner(mix_stderr=False)
result = runner.invoke(
... | [
"def",
"test_cli_datasource_list",
"(",
"empty_data_context",
",",
"empty_sqlite_db",
",",
"caplog",
")",
":",
"project_root_dir",
"=",
"empty_data_context",
".",
"root_directory",
"context",
"=",
"DataContext",
"(",
"project_root_dir",
")",
"runner",
"=",
"CliRunner",
... | [
15,
0
] | [
60,
60
] | python | en | ['en', 'en', 'en'] | True |
test_cli_datasource_profile_answering_no | (
empty_data_context, titanic_sqlite_db, caplog
) |
When datasource profile command is called without additional arguments,
the command must prompt the user with a confirm (y/n) before profiling.
We are verifying that it does that and respects user's "no".
|
When datasource profile command is called without additional arguments,
the command must prompt the user with a confirm (y/n) before profiling.
We are verifying that it does that and respects user's "no".
| def test_cli_datasource_profile_answering_no(
empty_data_context, titanic_sqlite_db, caplog
):
"""
When datasource profile command is called without additional arguments,
the command must prompt the user with a confirm (y/n) before profiling.
We are verifying that it does that and respects user's "... | [
"def",
"test_cli_datasource_profile_answering_no",
"(",
"empty_data_context",
",",
"titanic_sqlite_db",
",",
"caplog",
")",
":",
"project_root_dir",
"=",
"empty_data_context",
".",
"root_directory",
"context",
"=",
"DataContext",
"(",
"project_root_dir",
")",
"datasource_na... | [
195,
0
] | [
223,
60
] | python | en | ['en', 'error', 'th'] | False |
test_cli_datasource_profile_on_empty_database | (
empty_data_context, empty_sqlite_db, caplog
) |
We run the datasource profile command against an empty database (no tables).
This means that no generator can "see" a list of available data assets.
The command must exit with an error message saying that no generator can see
any assets.
|
We run the datasource profile command against an empty database (no tables).
This means that no generator can "see" a list of available data assets.
The command must exit with an error message saying that no generator can see
any assets.
| def test_cli_datasource_profile_on_empty_database(
empty_data_context, empty_sqlite_db, caplog
):
"""
We run the datasource profile command against an empty database (no tables).
This means that no generator can "see" a list of available data assets.
The command must exit with an error message sayin... | [
"def",
"test_cli_datasource_profile_on_empty_database",
"(",
"empty_data_context",
",",
"empty_sqlite_db",
",",
"caplog",
")",
":",
"project_root_dir",
"=",
"empty_data_context",
".",
"root_directory",
"context",
"=",
"DataContext",
"(",
"project_root_dir",
")",
"datasource... | [
226,
0
] | [
256,
60
] | python | en | ['en', 'error', 'th'] | False |
test_cli_datasource_profile_with_datasource_arg_and_generator_name_arg | (
empty_data_context, titanic_sqlite_db, caplog
) |
Here we are verifying that when generator_name argument is passed to
the methods down the stack.
We use a datasource with two generators. This way we can check that the
name of the expectation suite created by the profiler corresponds to
the name of the data asset listed by the generator that we t... |
Here we are verifying that when generator_name argument is passed to
the methods down the stack. | def test_cli_datasource_profile_with_datasource_arg_and_generator_name_arg(
empty_data_context, titanic_sqlite_db, caplog
):
"""
Here we are verifying that when generator_name argument is passed to
the methods down the stack.
We use a datasource with two generators. This way we can check that the
... | [
"def",
"test_cli_datasource_profile_with_datasource_arg_and_generator_name_arg",
"(",
"empty_data_context",
",",
"titanic_sqlite_db",
",",
"caplog",
")",
":",
"project_root_dir",
"=",
"empty_data_context",
".",
"root_directory",
"context",
"=",
"DataContext",
"(",
"project_root... | [
316,
0
] | [
372,
32
] | python | en | ['en', 'error', 'th'] | False |
test_cli_datasource_profile_with_data_asset_and_additional_batch_kwargs_with_limit | (
empty_data_context, titanic_sqlite_db, caplog
) |
User can pass additional batch kwargs (e.g., limit) to a sql backend.
Here we are verifying that passing "limit" affects the query correctly -
the row count in the batch that the profiler uses to profile the data asset
must match the limit passed by the user.
|
User can pass additional batch kwargs (e.g., limit) to a sql backend.
Here we are verifying that passing "limit" affects the query correctly -
the row count in the batch that the profiler uses to profile the data asset
must match the limit passed by the user.
| def test_cli_datasource_profile_with_data_asset_and_additional_batch_kwargs_with_limit(
empty_data_context, titanic_sqlite_db, caplog
):
"""
User can pass additional batch kwargs (e.g., limit) to a sql backend.
Here we are verifying that passing "limit" affects the query correctly -
the row count in... | [
"def",
"test_cli_datasource_profile_with_data_asset_and_additional_batch_kwargs_with_limit",
"(",
"empty_data_context",
",",
"titanic_sqlite_db",
",",
"caplog",
")",
":",
"project_root_dir",
"=",
"empty_data_context",
".",
"root_directory",
"context",
"=",
"DataContext",
"(",
"... | [
426,
0
] | [
499,
32
] | python | en | ['en', 'error', 'th'] | False |
ExpectColumnValuesToBeBetween.validate_configuration | (self, configuration: Optional[ExpectationConfiguration]) |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
Args:
configuration (OPTIONAL[ExpectationConfiguration]): \
An opt... |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation. | def validate_configuration(self, configuration: Optional[ExpectationConfiguration]):
"""
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
... | [
"def",
"validate_configuration",
"(",
"self",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
")",
":",
"# Setting up a configuration",
"super",
"(",
")",
".",
"validate_configuration",
"(",
"configuration",
")",
"min_val",
"=",
"None",
... | [
113,
4
] | [
138,
85
] | python | en | ['en', 'error', 'th'] | False |
_add_chrome_proxy_extension | (
chrome_options, proxy_string, proxy_user, proxy_pass) | Implementation of https://stackoverflow.com/a/35293284 for
https://stackoverflow.com/questions/12848327/
(Run Selenium on a proxy server that requires authentication.) | Implementation of https://stackoverflow.com/a/35293284 for
https://stackoverflow.com/questions/12848327/
(Run Selenium on a proxy server that requires authentication.) | def _add_chrome_proxy_extension(
chrome_options, proxy_string, proxy_user, proxy_pass):
""" Implementation of https://stackoverflow.com/a/35293284 for
https://stackoverflow.com/questions/12848327/
(Run Selenium on a proxy server that requires authentication.) """
arg_join = " ".join(sys.... | [
"def",
"_add_chrome_proxy_extension",
"(",
"chrome_options",
",",
"proxy_string",
",",
"proxy_user",
",",
"proxy_pass",
")",
":",
"arg_join",
"=",
"\" \"",
".",
"join",
"(",
"sys",
".",
"argv",
")",
"if",
"not",
"(",
"\"-n\"",
"in",
"sys",
".",
"argv",
"or... | [
95,
0
] | [
119,
25
] | python | en | ['en', 'en', 'en'] | True |
_add_chrome_disable_csp_extension | (chrome_options) | Disable Chrome's Content-Security-Policy with a browser extension.
See https://github.com/PhilGrayson/chrome-csp-disable for details. | Disable Chrome's Content-Security-Policy with a browser extension.
See https://github.com/PhilGrayson/chrome-csp-disable for details. | def _add_chrome_disable_csp_extension(chrome_options):
""" Disable Chrome's Content-Security-Policy with a browser extension.
See https://github.com/PhilGrayson/chrome-csp-disable for details. """
disable_csp_zip = DISABLE_CSP_ZIP_PATH
chrome_options.add_extension(disable_csp_zip)
return chrome_... | [
"def",
"_add_chrome_disable_csp_extension",
"(",
"chrome_options",
")",
":",
"disable_csp_zip",
"=",
"DISABLE_CSP_ZIP_PATH",
"chrome_options",
".",
"add_extension",
"(",
"disable_csp_zip",
")",
"return",
"chrome_options"
] | [
122,
0
] | [
127,
25
] | python | en | ['en', 'en', 'en'] | True |
get_local_driver | (
browser_name, headless, servername,
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
disable_csp, enable_sync, use_auto_ext, no_sandbox, disable_gpu,
incognito, guest_mode, devtools,
user_data_dir, extension_zip, extension_dir,
mobile_emulator, device_width... |
Spins up a new web browser and returns the driver.
Can also be used to spin up additional browsers for the same test.
|
Spins up a new web browser and returns the driver.
Can also be used to spin up additional browsers for the same test.
| def get_local_driver(
browser_name, headless, servername,
proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent,
disable_csp, enable_sync, use_auto_ext, no_sandbox, disable_gpu,
incognito, guest_mode, devtools,
user_data_dir, extension_zip, extension_dir,
mobile_em... | [
"def",
"get_local_driver",
"(",
"browser_name",
",",
"headless",
",",
"servername",
",",
"proxy_string",
",",
"proxy_auth",
",",
"proxy_user",
",",
"proxy_pass",
",",
"user_agent",
",",
"disable_csp",
",",
"enable_sync",
",",
"use_auto_ext",
",",
"no_sandbox",
","... | [
565,
0
] | [
759,
79
] | python | en | ['en', 'error', 'th'] | False |
Document.__init__ | (self, text: str,
id: Optional[str] = None,
score: Optional[float] = None,
probability: Optional[float] = None,
question: Optional[str] = None,
meta: Dict[str, Any] = None,
embedding: Optional[np.ndarray] = None) |
Object used to represent documents / passages in a standardized way within Haystack.
For example, this is what the retriever will return from the DocumentStore,
regardless if it's ElasticsearchDocumentStore or InMemoryDocumentStore.
Note that there can be multiple Documents originating... |
Object used to represent documents / passages in a standardized way within Haystack.
For example, this is what the retriever will return from the DocumentStore,
regardless if it's ElasticsearchDocumentStore or InMemoryDocumentStore. | def __init__(self, text: str,
id: Optional[str] = None,
score: Optional[float] = None,
probability: Optional[float] = None,
question: Optional[str] = None,
meta: Dict[str, Any] = None,
embedding: Optional[np.ndarray] =... | [
"def",
"__init__",
"(",
"self",
",",
"text",
":",
"str",
",",
"id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"score",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
",",
"probability",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
... | [
6,
4
] | [
41,
34
] | python | en | ['en', 'error', 'th'] | False |
Label.__init__ | (self, question: str,
answer: str,
is_correct_answer: bool,
is_correct_document: bool,
origin: str,
id: Optional[str] = None,
document_id: Optional[str] = None,
offset_start_in_doc: Optional[int] = Non... |
Object used to represent label/feedback in a standardized way within Haystack.
This includes labels from dataset like SQuAD, annotations from labeling tools,
or, user-feedback from the Haystack REST API.
:param question: the question(or query) for finding answers.
:param answer... |
Object used to represent label/feedback in a standardized way within Haystack.
This includes labels from dataset like SQuAD, annotations from labeling tools,
or, user-feedback from the Haystack REST API. | def __init__(self, question: str,
answer: str,
is_correct_answer: bool,
is_correct_document: bool,
origin: str,
id: Optional[str] = None,
document_id: Optional[str] = None,
offset_start_in_doc: Optiona... | [
"def",
"__init__",
"(",
"self",
",",
"question",
":",
"str",
",",
"answer",
":",
"str",
",",
"is_correct_answer",
":",
"bool",
",",
"is_correct_document",
":",
"bool",
",",
"origin",
":",
"str",
",",
"id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",... | [
80,
4
] | [
131,
32
] | python | en | ['en', 'error', 'th'] | False |
MultiLabel.__init__ | (self, question: str,
multiple_answers: List[str],
is_correct_answer: bool,
is_correct_document: bool,
origin: str,
multiple_document_ids: List[Any],
multiple_offset_start_in_docs: List[Any],
no_answer... |
Object used to aggregate multiple possible answers for the same question
:param question: the question(or query) for finding answers.
:param multiple_answers: list of possible answer strings
:param is_correct_answer: whether the sample is positive or negative.
:param is_correct... |
Object used to aggregate multiple possible answers for the same question | def __init__(self, question: str,
multiple_answers: List[str],
is_correct_answer: bool,
is_correct_document: bool,
origin: str,
multiple_document_ids: List[Any],
multiple_offset_start_in_docs: List[Any],
... | [
"def",
"__init__",
"(",
"self",
",",
"question",
":",
"str",
",",
"multiple_answers",
":",
"List",
"[",
"str",
"]",
",",
"is_correct_answer",
":",
"bool",
",",
"is_correct_document",
":",
"bool",
",",
"origin",
":",
"str",
",",
"multiple_document_ids",
":",
... | [
174,
4
] | [
206,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseComponent.__init_subclass__ | (cls, **kwargs) | This automatically keeps track of all available subclasses.
Enables generic load() for all specific component implementations.
| This automatically keeps track of all available subclasses.
Enables generic load() for all specific component implementations.
| def __init_subclass__(cls, **kwargs):
""" This automatically keeps track of all available subclasses.
Enables generic load() for all specific component implementations.
"""
super().__init_subclass__(**kwargs)
cls.subclasses[cls.__name__] = cls | [
"def",
"__init_subclass__",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init_subclass__",
"(",
"*",
"*",
"kwargs",
")",
"cls",
".",
"subclasses",
"[",
"cls",
".",
"__name__",
"]",
"=",
"cls"
] | [
230,
4
] | [
235,
42
] | python | en | ['en', 'en', 'en'] | True |
BaseComponent.load_from_args | (cls, component_type: str, **kwargs) |
Load a component instance of the given type using the kwargs.
:param component_type: name of the component class to load.
:param kwargs: parameters to pass to the __init__() for the component.
|
Load a component instance of the given type using the kwargs.
:param component_type: name of the component class to load.
:param kwargs: parameters to pass to the __init__() for the component.
| def load_from_args(cls, component_type: str, **kwargs):
"""
Load a component instance of the given type using the kwargs.
:param component_type: name of the component class to load.
:param kwargs: parameters to pass to the __init__() for the component.
"""
if co... | [
"def",
"load_from_args",
"(",
"cls",
",",
"component_type",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"component_type",
"not",
"in",
"cls",
".",
"subclasses",
".",
"keys",
"(",
")",
":",
"raise",
"Exception",
"(",
"f\"Haystack component with the n... | [
238,
4
] | [
248,
23
] | python | en | ['en', 'error', 'th'] | False |
Twitter.start_streaming | (self, callback) | Starts streaming tweets and returning data to the callback. | Starts streaming tweets and returning data to the callback. | def start_streaming(self, callback):
"""Starts streaming tweets and returning data to the callback."""
self.twitter_listener = TwitterListener(
callback=callback, logs_to_cloud=self.logs_to_cloud)
twitter_stream = Stream(self.twitter_auth, self.twitter_listener)
self.logs.d... | [
"def",
"start_streaming",
"(",
"self",
",",
"callback",
")",
":",
"self",
".",
"twitter_listener",
"=",
"TwitterListener",
"(",
"callback",
"=",
"callback",
",",
"logs_to_cloud",
"=",
"self",
".",
"logs_to_cloud",
")",
"twitter_stream",
"=",
"Stream",
"(",
"se... | [
77,
4
] | [
90,
69
] | python | en | ['en', 'en', 'en'] | True |
Twitter.stop_streaming | (self) | Stops the current stream. | Stops the current stream. | def stop_streaming(self):
"""Stops the current stream."""
if not self.twitter_listener:
self.logs.warn('No stream to stop.')
return
self.logs.debug('Stopping stream.')
self.twitter_listener.stop_queue()
self.twitter_listener = None | [
"def",
"stop_streaming",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"twitter_listener",
":",
"self",
".",
"logs",
".",
"warn",
"(",
"'No stream to stop.'",
")",
"return",
"self",
".",
"logs",
".",
"debug",
"(",
"'Stopping stream.'",
")",
"self",
".",... | [
92,
4
] | [
101,
36
] | python | en | ['en', 'en', 'en'] | True |
Twitter.tweet | (self, companies, tweet) | Posts a tweet listing the companies, their ticker symbols, and a
quote of the original tweet.
| Posts a tweet listing the companies, their ticker symbols, and a
quote of the original tweet.
| def tweet(self, companies, tweet):
"""Posts a tweet listing the companies, their ticker symbols, and a
quote of the original tweet.
"""
link = self.get_tweet_link(tweet)
text = self.make_tweet_text(companies, link)
self.logs.info('Tweeting: %s' % text)
self.twit... | [
"def",
"tweet",
"(",
"self",
",",
"companies",
",",
"tweet",
")",
":",
"link",
"=",
"self",
".",
"get_tweet_link",
"(",
"tweet",
")",
"text",
"=",
"self",
".",
"make_tweet_text",
"(",
"companies",
",",
"link",
")",
"self",
".",
"logs",
".",
"info",
"... | [
103,
4
] | [
112,
44
] | python | en | ['en', 'en', 'en'] | True |
Twitter.make_tweet_text | (self, companies, link) | Generates the text for a tweet. | Generates the text for a tweet. | def make_tweet_text(self, companies, link):
"""Generates the text for a tweet."""
# Find all distinct company names.
names = []
for company in companies:
name = company['name']
if name not in names:
names.append(name)
# Collect the ticker... | [
"def",
"make_tweet_text",
"(",
"self",
",",
"companies",
",",
"link",
")",
":",
"# Find all distinct company names.",
"names",
"=",
"[",
"]",
"for",
"company",
"in",
"companies",
":",
"name",
"=",
"company",
"[",
"'name'",
"]",
"if",
"name",
"not",
"in",
"... | [
114,
4
] | [
156,
19
] | python | en | ['en', 'en', 'en'] | True |
Twitter.get_sentiment_emoji | (self, sentiment) | Returns the emoji matching the sentiment. | Returns the emoji matching the sentiment. | def get_sentiment_emoji(self, sentiment):
"""Returns the emoji matching the sentiment."""
if not sentiment:
return EMOJI_SHRUG
if sentiment > 0:
return EMOJI_THUMBS_UP
if sentiment < 0:
return EMOJI_THUMBS_DOWN
self.logs.warn('Unknown senti... | [
"def",
"get_sentiment_emoji",
"(",
"self",
",",
"sentiment",
")",
":",
"if",
"not",
"sentiment",
":",
"return",
"EMOJI_SHRUG",
"if",
"sentiment",
">",
"0",
":",
"return",
"EMOJI_THUMBS_UP",
"if",
"sentiment",
"<",
"0",
":",
"return",
"EMOJI_THUMBS_DOWN",
"self... | [
158,
4
] | [
171,
26
] | python | en | ['en', 'sn', 'en'] | True |
Twitter.get_tweet | (self, tweet_id) | Looks up metadata for a single tweet. | Looks up metadata for a single tweet. | def get_tweet(self, tweet_id):
"""Looks up metadata for a single tweet."""
try:
# Use tweet_mode=extended so we get the full text.
status = self.twitter_api.get_status(tweet_id,
tweet_mode='extended')
if not status:
... | [
"def",
"get_tweet",
"(",
"self",
",",
"tweet_id",
")",
":",
"try",
":",
"# Use tweet_mode=extended so we get the full text.",
"status",
"=",
"self",
".",
"twitter_api",
".",
"get_status",
"(",
"tweet_id",
",",
"tweet_mode",
"=",
"'extended'",
")",
"if",
"not",
"... | [
173,
4
] | [
189,
27
] | python | en | ['en', 'en', 'en'] | True |
Twitter.get_all_tweets | (self) | Looks up metadata for the most recent Trump tweets. | Looks up metadata for the most recent Trump tweets. | def get_all_tweets(self):
"""Looks up metadata for the most recent Trump tweets."""
tweets = []
# Only the 3,200 most recent tweets are available through the API. Use
# the @Trump2Cash account to filter down to the relevant ones.
for status in Cursor(self.twitter_api.user_timel... | [
"def",
"get_all_tweets",
"(",
"self",
")",
":",
"tweets",
"=",
"[",
"]",
"# Only the 3,200 most recent tweets are available through the API. Use",
"# the @Trump2Cash account to filter down to the relevant ones.",
"for",
"status",
"in",
"Cursor",
"(",
"self",
".",
"twitter_api",... | [
191,
4
] | [
216,
21
] | python | en | ['en', 'en', 'en'] | True |
Twitter.get_tweet_text | (self, tweet) | Returns the full text of a tweet. | Returns the full text of a tweet. | def get_tweet_text(self, tweet):
"""Returns the full text of a tweet."""
# The format for getting at the full text is different depending on
# whether the tweet came through the REST API or the Streaming API:
# https://dev.twitter.com/overview/api/upcoming-changes-to-tweets
try:... | [
"def",
"get_tweet_text",
"(",
"self",
",",
"tweet",
")",
":",
"# The format for getting at the full text is different depending on",
"# whether the tweet came through the REST API or the Streaming API:",
"# https://dev.twitter.com/overview/api/upcoming-changes-to-tweets",
"try",
":",
"if",... | [
218,
4
] | [
236,
23
] | python | en | ['en', 'en', 'en'] | True |
Twitter.get_tweet_link | (self, tweet) | Creates the link URL to a tweet. | Creates the link URL to a tweet. | def get_tweet_link(self, tweet):
"""Creates the link URL to a tweet."""
if not tweet:
self.logs.error('No tweet to get link.')
return None
try:
screen_name = tweet['user']['screen_name']
id_str = tweet['id_str']
except KeyError:
... | [
"def",
"get_tweet_link",
"(",
"self",
",",
"tweet",
")",
":",
"if",
"not",
"tweet",
":",
"self",
".",
"logs",
".",
"error",
"(",
"'No tweet to get link.'",
")",
"return",
"None",
"try",
":",
"screen_name",
"=",
"tweet",
"[",
"'user'",
"]",
"[",
"'screen_... | [
238,
4
] | [
253,
19
] | python | en | ['en', 'en', 'en'] | True |
TwitterListener.start_queue | (self) | Creates a queue and starts the worker threads. | Creates a queue and starts the worker threads. | def start_queue(self):
"""Creates a queue and starts the worker threads."""
self.queue = Queue()
self.stop_event = Event()
self.logs.debug('Starting %s worker threads.' % NUM_THREADS)
self.workers = []
for worker_id in range(NUM_THREADS):
worker = Thread(targ... | [
"def",
"start_queue",
"(",
"self",
")",
":",
"self",
".",
"queue",
"=",
"Queue",
"(",
")",
"self",
".",
"stop_event",
"=",
"Event",
"(",
")",
"self",
".",
"logs",
".",
"debug",
"(",
"'Starting %s worker threads.'",
"%",
"NUM_THREADS",
")",
"self",
".",
... | [
266,
4
] | [
277,
39
] | python | en | ['en', 'en', 'en'] | True |
TwitterListener.stop_queue | (self) | Shuts down the queue and worker threads. | Shuts down the queue and worker threads. | def stop_queue(self):
"""Shuts down the queue and worker threads."""
# First stop the queue.
if self.queue:
self.logs.debug('Stopping queue.')
self.queue.join()
else:
self.logs.warn('No queue to stop.')
# Then stop the worker threads.
... | [
"def",
"stop_queue",
"(",
"self",
")",
":",
"# First stop the queue.",
"if",
"self",
".",
"queue",
":",
"self",
".",
"logs",
".",
"debug",
"(",
"'Stopping queue.'",
")",
"self",
".",
"queue",
".",
"join",
"(",
")",
"else",
":",
"self",
".",
"logs",
"."... | [
279,
4
] | [
297,
56
] | python | en | ['en', 'en', 'en'] | True |
TwitterListener.process_queue | (self, worker_id) | Continuously processes tasks on the queue. | Continuously processes tasks on the queue. | def process_queue(self, worker_id):
"""Continuously processes tasks on the queue."""
# Create a new logs instance (with its own httplib2 instance) so that
# there is a separate one for each thread.
logs = Logs('twitter-listener-worker-%s' % worker_id,
to_cloud=self.l... | [
"def",
"process_queue",
"(",
"self",
",",
"worker_id",
")",
":",
"# Create a new logs instance (with its own httplib2 instance) so that",
"# there is a separate one for each thread.",
"logs",
"=",
"Logs",
"(",
"'twitter-listener-worker-%s'",
"%",
"worker_id",
",",
"to_cloud",
"... | [
299,
4
] | [
326,
59
] | python | en | ['en', 'en', 'en'] | True |
TwitterListener.on_error | (self, status) | Handles any API errors. | Handles any API errors. | def on_error(self, status):
"""Handles any API errors."""
self.logs.error('Twitter error: %s' % status)
self.error_status = status
self.stop_queue()
return False | [
"def",
"on_error",
"(",
"self",
",",
"status",
")",
":",
"self",
".",
"logs",
".",
"error",
"(",
"'Twitter error: %s'",
"%",
"status",
")",
"self",
".",
"error_status",
"=",
"status",
"self",
".",
"stop_queue",
"(",
")",
"return",
"False"
] | [
328,
4
] | [
334,
20
] | python | en | ['en', 'mg', 'en'] | True |
TwitterListener.get_error_status | (self) | Returns the API error status, if there was one. | Returns the API error status, if there was one. | def get_error_status(self):
"""Returns the API error status, if there was one."""
return self.error_status | [
"def",
"get_error_status",
"(",
"self",
")",
":",
"return",
"self",
".",
"error_status"
] | [
336,
4
] | [
338,
32
] | python | en | ['en', 'en', 'en'] | True |
TwitterListener.on_data | (self, data) | Puts a task to process the new data on the queue. | Puts a task to process the new data on the queue. | def on_data(self, data):
"""Puts a task to process the new data on the queue."""
# Stop streaming if requested.
if self.stop_event.is_set():
return False
# Put the task on the queue and keep streaming.
self.queue.put(data)
return True | [
"def",
"on_data",
"(",
"self",
",",
"data",
")",
":",
"# Stop streaming if requested.",
"if",
"self",
".",
"stop_event",
".",
"is_set",
"(",
")",
":",
"return",
"False",
"# Put the task on the queue and keep streaming.",
"self",
".",
"queue",
".",
"put",
"(",
"d... | [
340,
4
] | [
349,
19
] | python | en | ['en', 'en', 'en'] | True |
TwitterListener.handle_data | (self, logs, data) | Sanity-checks and extracts the data before sending it to the
callback.
| Sanity-checks and extracts the data before sending it to the
callback.
| def handle_data(self, logs, data):
"""Sanity-checks and extracts the data before sending it to the
callback.
"""
try:
tweet = loads(data)
except ValueError:
logs.error('Failed to decode JSON data: %s' % data)
return
try:
u... | [
"def",
"handle_data",
"(",
"self",
",",
"logs",
",",
"data",
")",
":",
"try",
":",
"tweet",
"=",
"loads",
"(",
"data",
")",
"except",
"ValueError",
":",
"logs",
".",
"error",
"(",
"'Failed to decode JSON data: %s'",
"%",
"data",
")",
"return",
"try",
":"... | [
351,
4
] | [
379,
28
] | python | en | ['en', 'en', 'en'] | True |
parse_service_messages | (text) |
Parses service messages from the given build log.
:type text: str
:rtype: list[ServiceMessage]
|
Parses service messages from the given build log.
:type text: str
:rtype: list[ServiceMessage]
| def parse_service_messages(text):
"""
Parses service messages from the given build log.
:type text: str
:rtype: list[ServiceMessage]
"""
messages = list()
for line in text.splitlines():
r = line.strip()
index = r.find("##teamcity[")
if index != -1:
m = _pa... | [
"def",
"parse_service_messages",
"(",
"text",
")",
":",
"messages",
"=",
"list",
"(",
")",
"for",
"line",
"in",
"text",
".",
"splitlines",
"(",
")",
":",
"r",
"=",
"line",
".",
"strip",
"(",
")",
"index",
"=",
"r",
".",
"find",
"(",
"\"##teamcity[\""... | [
47,
0
] | [
60,
19
] | python | en | ['en', 'error', 'th'] | False |
service_messages_to_string | (messages) |
:type messages: list[ServiceMessage]
|
:type messages: list[ServiceMessage]
| def service_messages_to_string(messages):
"""
:type messages: list[ServiceMessage]
"""
return u"\n".join([x.as_unicode() for x in messages]) | [
"def",
"service_messages_to_string",
"(",
"messages",
")",
":",
"return",
"u\"\\n\"",
".",
"join",
"(",
"[",
"x",
".",
"as_unicode",
"(",
")",
"for",
"x",
"in",
"messages",
"]",
")"
] | [
63,
0
] | [
67,
57
] | python | en | ['en', 'error', 'th'] | False |
_parse_one_service_message | (s) |
Parses one service message.
:type s: str
:rtype: service_message
|
Parses one service message.
:type s: str
:rtype: service_message
| def _parse_one_service_message(s):
"""
Parses one service message.
:type s: str
:rtype: service_message
"""
b1 = s.index('[')
b2 = s.rindex(']', b1)
inner = s[b1 + 1:b2].strip()
space1 = inner.find(' ')
if space1 >= 0:
name_len = space1
else:
name_len = inner.... | [
"def",
"_parse_one_service_message",
"(",
"s",
")",
":",
"b1",
"=",
"s",
".",
"index",
"(",
"'['",
")",
"b2",
"=",
"s",
".",
"rindex",
"(",
"']'",
",",
"b1",
")",
"inner",
"=",
"s",
"[",
"b1",
"+",
"1",
":",
"b2",
"]",
".",
"strip",
"(",
")",... | [
70,
0
] | [
110,
39
] | python | en | ['en', 'error', 'th'] | False |
match | (messages, message) |
:type messages: list[ServiceMessage]
:type message: ServiceMessage
|
:type messages: list[ServiceMessage]
:type message: ServiceMessage
| def match(messages, message):
"""
:type messages: list[ServiceMessage]
:type message: ServiceMessage
"""
candidates = [x for x in messages if x >= message]
if len(candidates) == 0:
raise AssertionError("No messages match " + message.as_unicode() + " across " + service_messages_to_string(... | [
"def",
"match",
"(",
"messages",
",",
"message",
")",
":",
"candidates",
"=",
"[",
"x",
"for",
"x",
"in",
"messages",
"if",
"x",
">=",
"message",
"]",
"if",
"len",
"(",
"candidates",
")",
"==",
"0",
":",
"raise",
"AssertionError",
"(",
"\"No messages m... | [
118,
0
] | [
129,
24
] | python | en | ['en', 'error', 'th'] | False |
assert_service_messages | (actual_messages_string, expected_messages, actual_messages_predicate=lambda x: True) |
:type expected_messages: list[ServiceMessage]
|
:type expected_messages: list[ServiceMessage]
| def assert_service_messages(actual_messages_string, expected_messages, actual_messages_predicate=lambda x: True):
"""
:type expected_messages: list[ServiceMessage]
"""
expected_messages = [x for x in expected_messages if x is not None]
actual_messages = [x for x in parse_service_messages(actual_mess... | [
"def",
"assert_service_messages",
"(",
"actual_messages_string",
",",
"expected_messages",
",",
"actual_messages_predicate",
"=",
"lambda",
"x",
":",
"True",
")",
":",
"expected_messages",
"=",
"[",
"x",
"for",
"x",
"in",
"expected_messages",
"if",
"x",
"is",
"not... | [
132,
0
] | [
151,
26
] | python | en | ['en', 'error', 'th'] | False |
ServiceMessage.__init__ | (self, name, params) |
:type name: string
:type params: dict[string, string]
|
:type name: string
:type params: dict[string, string]
| def __init__(self, name, params):
"""
:type name: string
:type params: dict[string, string]
"""
self.name = name
self.params = params | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"params",
")",
":",
"self",
".",
"name",
"=",
"name",
"self",
".",
"params",
"=",
"params"
] | [
6,
4
] | [
12,
28
] | python | en | ['en', 'error', 'th'] | False |
ServiceMessage.__ge__ | (self, other) |
:type self: service_message
:type other: service_message
:rtype: bool
|
:type self: service_message
:type other: service_message
:rtype: bool
| def __ge__(self, other):
"""
:type self: service_message
:type other: service_message
:rtype: bool
"""
if self.name != other.name:
return False
for p in other.params:
if p in self.params:
v1 = self.params[p]
... | [
"def",
"__ge__",
"(",
"self",
",",
"other",
")",
":",
"if",
"self",
".",
"name",
"!=",
"other",
".",
"name",
":",
"return",
"False",
"for",
"p",
"in",
"other",
".",
"params",
":",
"if",
"p",
"in",
"self",
".",
"params",
":",
"v1",
"=",
"self",
... | [
14,
4
] | [
31,
19
] | python | en | ['en', 'error', 'th'] | False |
TupleFilesystemStoreBackend.rrmdir | (self, mroot, curpath) |
recursively removes empty dirs between curpath and mroot inclusive
|
recursively removes empty dirs between curpath and mroot inclusive
| def rrmdir(self, mroot, curpath):
"""
recursively removes empty dirs between curpath and mroot inclusive
"""
try:
while (
not os.listdir(curpath) and os.path.exists(curpath) and mroot != curpath
):
f2 = os.path.dirname(curpath)
... | [
"def",
"rrmdir",
"(",
"self",
",",
"mroot",
",",
"curpath",
")",
":",
"try",
":",
"while",
"(",
"not",
"os",
".",
"listdir",
"(",
"curpath",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"curpath",
")",
"and",
"mroot",
"!=",
"curpath",
")",
... | [
373,
4
] | [
385,
16
] | python | en | ['en', 'error', 'th'] | False |
impute_missing_data_1D | (data1D) |
This function returns the data in the same format as it was
passed in, but with missing values either masked out or imputed with appropriate values
(currently only using a linear trend). Many linear plotting functions for 1D data often
(and should) only connect contiguous, non-nan data points. This... |
This function returns the data in the same format as it was
passed in, but with missing values either masked out or imputed with appropriate values
(currently only using a linear trend). Many linear plotting functions for 1D data often
(and should) only connect contiguous, non-nan data points. This... | def impute_missing_data_1D(data1D):
"""
This function returns the data in the same format as it was
passed in, but with missing values either masked out or imputed with appropriate values
(currently only using a linear trend). Many linear plotting functions for 1D data often
(and should) only con... | [
"def",
"impute_missing_data_1D",
"(",
"data1D",
")",
":",
"nan_mask",
"=",
"~",
"np",
".",
"isnan",
"(",
"data1D",
")",
"x",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"data1D",
")",
")",
"x_no_nan",
"=",
"x",
"[",
"nan_mask",
"]",
"data_no_nan",
"="... | [
43,
0
] | [
74,
21
] | python | en | ['en', 'error', 'th'] | False |
np_dt64_to_str | (np_datetime, fmt='%Y-%m-%d') | Converts a NumPy datetime64 object to a string based on a format string supplied to pandas strftime. | Converts a NumPy datetime64 object to a string based on a format string supplied to pandas strftime. | def np_dt64_to_str(np_datetime, fmt='%Y-%m-%d'):
"""Converts a NumPy datetime64 object to a string based on a format string supplied to pandas strftime."""
return pd.to_datetime(str(np_datetime)).strftime(fmt) | [
"def",
"np_dt64_to_str",
"(",
"np_datetime",
",",
"fmt",
"=",
"'%Y-%m-%d'",
")",
":",
"return",
"pd",
".",
"to_datetime",
"(",
"str",
"(",
"np_datetime",
")",
")",
".",
"strftime",
"(",
"fmt",
")"
] | [
85,
0
] | [
87,
57
] | python | en | ['en', 'en', 'en'] | True |
xarray_plot_data_vars_over_time | (dataset, colors=['orange', 'blue']) |
Plot a line plot of all data variables in an xarray.Dataset on a shared set of axes.
Parameters
----------
dataset: xarray.Dataset
The Dataset containing data variables to plot. The only dimension and coordinate must be 'time'.
colors: list
A list of strings denoting colors for... |
Plot a line plot of all data variables in an xarray.Dataset on a shared set of axes.
Parameters
----------
dataset: xarray.Dataset
The Dataset containing data variables to plot. The only dimension and coordinate must be 'time'.
colors: list
A list of strings denoting colors for... | def xarray_plot_data_vars_over_time(dataset, colors=['orange', 'blue']):
"""
Plot a line plot of all data variables in an xarray.Dataset on a shared set of axes.
Parameters
----------
dataset: xarray.Dataset
The Dataset containing data variables to plot. The only dimension and coordinat... | [
"def",
"xarray_plot_data_vars_over_time",
"(",
"dataset",
",",
"colors",
"=",
"[",
"'orange'",
",",
"'blue'",
"]",
")",
":",
"data_var_names",
"=",
"sorted",
"(",
"list",
"(",
"dataset",
".",
"data_vars",
")",
")",
"len_dataset",
"=",
"dataset",
".",
"time",... | [
122,
0
] | [
149,
14
] | python | en | ['en', 'error', 'th'] | False |
xarray_scatterplot_data_vars | (dataset, figure_kwargs={'figsize':(12,6)}, colors=['blue', 'orange'], markersize=5) |
Plot a scatterplot of all data variables in an xarray.Dataset on a shared set of axes.
Currently requires a 'time' coordinate, which constitutes the x-axis.
Parameters
----------
dataset: xarray.Dataset
The Dataset containing data variables to plot.
frac_dates: float
The fracti... |
Plot a scatterplot of all data variables in an xarray.Dataset on a shared set of axes.
Currently requires a 'time' coordinate, which constitutes the x-axis. | def xarray_scatterplot_data_vars(dataset, figure_kwargs={'figsize':(12,6)}, colors=['blue', 'orange'], markersize=5):
"""
Plot a scatterplot of all data variables in an xarray.Dataset on a shared set of axes.
Currently requires a 'time' coordinate, which constitutes the x-axis.
Parameters
---------... | [
"def",
"xarray_scatterplot_data_vars",
"(",
"dataset",
",",
"figure_kwargs",
"=",
"{",
"'figsize'",
":",
"(",
"12",
",",
"6",
")",
"}",
",",
"colors",
"=",
"[",
"'blue'",
",",
"'orange'",
"]",
",",
"markersize",
"=",
"5",
")",
":",
"plt",
".",
"figure"... | [
151,
0
] | [
191,
14
] | python | en | ['en', 'error', 'th'] | False |
xarray_plot_ndvi_boxplot_wofs_lineplot_over_time | (dataset, resolution=None, colors=['orange', 'blue']) |
For an xarray.Dataset, plot a boxplot of NDVI and line plot of WOFS across time.
Parameters
----------
dataset: xarray.Dataset
A Dataset formatted as follows:
coordinates: time, latitude, longitude.
data variables: ndvi, wofs
resolution: str
Denotes the... |
For an xarray.Dataset, plot a boxplot of NDVI and line plot of WOFS across time.
Parameters
----------
dataset: xarray.Dataset
A Dataset formatted as follows:
coordinates: time, latitude, longitude.
data variables: ndvi, wofs
resolution: str
Denotes the... | def xarray_plot_ndvi_boxplot_wofs_lineplot_over_time(dataset, resolution=None, colors=['orange', 'blue']):
"""
For an xarray.Dataset, plot a boxplot of NDVI and line plot of WOFS across time.
Parameters
----------
dataset: xarray.Dataset
A Dataset formatted as follows:
coor... | [
"def",
"xarray_plot_ndvi_boxplot_wofs_lineplot_over_time",
"(",
"dataset",
",",
"resolution",
"=",
"None",
",",
"colors",
"=",
"[",
"'orange'",
",",
"'blue'",
"]",
")",
":",
"plotting_data",
"=",
"dataset",
".",
"stack",
"(",
"lat_lon",
"=",
"(",
"'latitude'",
... | [
193,
0
] | [
256,
14
] | python | en | ['en', 'error', 'th'] | False |
xarray_time_series_plot | (dataset, plot_descs, x_coord='longitude',
y_coord='latitude', fig_params=None,
scale_params=None, fig=None, ax=None,
max_times_per_plot=None, show_legend=True,
title=None) |
Plot data variables in an xarray.Dataset together in one figure, with different
plot types for each (e.g. box-and-whisker plot, line plot, scatter plot), and
optional curve fitting to aggregations along time. Handles data binned with
xarray.Dataset methods resample() and groupby(). That is, it handl... |
Plot data variables in an xarray.Dataset together in one figure, with different
plot types for each (e.g. box-and-whisker plot, line plot, scatter plot), and
optional curve fitting to aggregations along time. Handles data binned with
xarray.Dataset methods resample() and groupby(). That is, it handl... | def xarray_time_series_plot(dataset, plot_descs, x_coord='longitude',
y_coord='latitude', fig_params=None,
scale_params=None, fig=None, ax=None,
max_times_per_plot=None, show_legend=True,
title=None):
... | [
"def",
"xarray_time_series_plot",
"(",
"dataset",
",",
"plot_descs",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
",",
"fig_params",
"=",
"None",
",",
"scale_params",
"=",
"None",
",",
"fig",
"=",
"None",
",",
"ax",
"=",
"None",
"... | [
258,
0
] | [
552,
14
] | python | en | ['en', 'error', 'th'] | False |
plot_curvefit | (x, y, fit_type, x_smooth=None, n_pts=200, fig_params={}, plot_kwargs={}, fig=None, ax=None) |
Plots a curve fit given x values, y values, a type of curve to plot, and parameters for that curve.
Parameters
----------
x: np.ndarray
A 1D NumPy array. The x values to fit to.
y: np.ndarray
A 1D NumPy array. The y values to fit to.
fit_type: str
The type of curve ... |
Plots a curve fit given x values, y values, a type of curve to plot, and parameters for that curve.
Parameters
----------
x: np.ndarray
A 1D NumPy array. The x values to fit to.
y: np.ndarray
A 1D NumPy array. The y values to fit to.
fit_type: str
The type of curve ... | def plot_curvefit(x, y, fit_type, x_smooth=None, n_pts=200, fig_params={}, plot_kwargs={}, fig=None, ax=None):
"""
Plots a curve fit given x values, y values, a type of curve to plot, and parameters for that curve.
Parameters
----------
x: np.ndarray
A 1D NumPy array. The x values to fi... | [
"def",
"plot_curvefit",
"(",
"x",
",",
"y",
",",
"fit_type",
",",
"x_smooth",
"=",
"None",
",",
"n_pts",
"=",
"200",
",",
"fig_params",
"=",
"{",
"}",
",",
"plot_kwargs",
"=",
"{",
"}",
",",
"fig",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
... | [
556,
0
] | [
615,
56
] | python | en | ['en', 'error', 'th'] | False |
plot_band | (dataset, figsize=(20,15), fontsize=24, legend_fontsize=24) |
Plots several statistics over time - including mean, median, linear regression of the
means, Gaussian smoothed curve of means, and the band enclosing the 25th and 75th percentiles.
This is very similar to the output of the Comet Time Series Toolset (https://github.com/CosmiQ/CometTS).
Parameter... |
Plots several statistics over time - including mean, median, linear regression of the
means, Gaussian smoothed curve of means, and the band enclosing the 25th and 75th percentiles.
This is very similar to the output of the Comet Time Series Toolset (https://github.com/CosmiQ/CometTS).
Parameter... | def plot_band(dataset, figsize=(20,15), fontsize=24, legend_fontsize=24):
"""
Plots several statistics over time - including mean, median, linear regression of the
means, Gaussian smoothed curve of means, and the band enclosing the 25th and 75th percentiles.
This is very similar to the output of the C... | [
"def",
"plot_band",
"(",
"dataset",
",",
"figsize",
"=",
"(",
"20",
",",
"15",
")",
",",
"fontsize",
"=",
"24",
",",
"legend_fontsize",
"=",
"24",
")",
":",
"# Calculations",
"times",
"=",
"dataset",
".",
"time",
".",
"values",
"epochs",
"=",
"np",
"... | [
619,
0
] | [
695,
14
] | python | en | ['en', 'error', 'th'] | False |
convert_name_rgb_255 | (color) |
Converts a name of a matplotlib color to a list of rgb values in the range [0,255].
Else, returns the original argument.
Parameters
----------
color: str or list (size 3)
The color name to convert or a list of red, green, and blue already in range [0,255].
|
Converts a name of a matplotlib color to a list of rgb values in the range [0,255].
Else, returns the original argument. | def convert_name_rgb_255(color):
"""
Converts a name of a matplotlib color to a list of rgb values in the range [0,255].
Else, returns the original argument.
Parameters
----------
color: str or list (size 3)
The color name to convert or a list of red, green, and blue already in range [... | [
"def",
"convert_name_rgb_255",
"(",
"color",
")",
":",
"return",
"[",
"255",
"*",
"rgb",
"for",
"rgb",
"in",
"mpl",
".",
"colors",
".",
"to_rgb",
"(",
"color",
")",
"]",
"if",
"isinstance",
"(",
"color",
",",
"str",
")",
"else",
"color"
] | [
748,
0
] | [
758,
92
] | python | en | ['en', 'error', 'th'] | False |
norm_color | (color) |
Converts either a string name of a matplotlib color or a 3-tuple of rgb values
in the range [0,255] to a 3-tuple of rgb values in the range [0,1].
Parameters
----------
color: str or list-like of numeric
The name of a matplolib color or a .
|
Converts either a string name of a matplotlib color or a 3-tuple of rgb values
in the range [0,255] to a 3-tuple of rgb values in the range [0,1].
Parameters
----------
color: str or list-like of numeric
The name of a matplolib color or a .
| def norm_color(color):
"""
Converts either a string name of a matplotlib color or a 3-tuple of rgb values
in the range [0,255] to a 3-tuple of rgb values in the range [0,1].
Parameters
----------
color: str or list-like of numeric
The name of a matplolib color or a .
"""
co... | [
"def",
"norm_color",
"(",
"color",
")",
":",
"color",
"=",
"convert_name_rgb_255",
"(",
"color",
")",
"if",
"len",
"(",
"color",
")",
"==",
"3",
":",
"color",
"=",
"[",
"rgb",
"/",
"255",
"for",
"rgb",
"in",
"color",
"]",
"return",
"color"
] | [
760,
0
] | [
773,
16
] | python | en | ['en', 'error', 'th'] | False |
create_discrete_color_map | (data_range=None, colors=None, cmap=None,
th=None, pts=None, cmap_name='my_cmap',
data_range_fmt=None, pts_fmt=None) |
Creates a discrete matplotlib LinearSegmentedColormap with thresholds for color changes.
Exclusively either `colors` or `cmap` must be specified (i.e. one and only one).
At least one of the parameters `th` or `pts` may be specified, but not both.
Parameters
----------
data_range: list
... |
Creates a discrete matplotlib LinearSegmentedColormap with thresholds for color changes.
Exclusively either `colors` or `cmap` must be specified (i.e. one and only one).
At least one of the parameters `th` or `pts` may be specified, but not both.
Parameters
----------
data_range: list
... | def create_discrete_color_map(data_range=None, colors=None, cmap=None,
th=None, pts=None, cmap_name='my_cmap',
data_range_fmt=None, pts_fmt=None):
"""
Creates a discrete matplotlib LinearSegmentedColormap with thresholds for color changes.
Exclus... | [
"def",
"create_discrete_color_map",
"(",
"data_range",
"=",
"None",
",",
"colors",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"th",
"=",
"None",
",",
"pts",
"=",
"None",
",",
"cmap_name",
"=",
"'my_cmap'",
",",
"data_range_fmt",
"=",
"None",
",",
"pts_f... | [
779,
0
] | [
885,
15
] | python | en | ['en', 'error', 'th'] | False |
create_gradient_color_map | (data_range, colors, positions=None, cmap_name='my_cmap') |
Creates a gradient colormap with a LinearSegmentedColormap. Currently only creates linear gradients.
Parameters
----------
data_range: list-like
A 2-tuple of the minimum and maximum values the data may take.
colors: list of str or list of tuple
Colors can be string names of mat... |
Creates a gradient colormap with a LinearSegmentedColormap. Currently only creates linear gradients.
Parameters
----------
data_range: list-like
A 2-tuple of the minimum and maximum values the data may take.
colors: list of str or list of tuple
Colors can be string names of mat... | def create_gradient_color_map(data_range, colors, positions=None, cmap_name='my_cmap'):
"""
Creates a gradient colormap with a LinearSegmentedColormap. Currently only creates linear gradients.
Parameters
----------
data_range: list-like
A 2-tuple of the minimum and maximum values the da... | [
"def",
"create_gradient_color_map",
"(",
"data_range",
",",
"colors",
",",
"positions",
"=",
"None",
",",
"cmap_name",
"=",
"'my_cmap'",
")",
":",
"# Normalize position values based on the data range.",
"if",
"positions",
"is",
"None",
":",
"range_size",
"=",
"data_ra... | [
887,
0
] | [
934,
52
] | python | en | ['en', 'error', 'th'] | False |
binary_class_change_plot | (dataarrays, mask=None, x_coord='longitude', y_coord='latitude',
colors=None, class_legend_label=None, width=10, fig=None, ax=None,
title=None, fig_kwargs={}, title_kwargs={}, imshow_kwargs={},
x_label_kwargs={}, y_label_kwargs={}... |
Creates a figure showing one of the following, depending on the format of arguments:
1. The change in the extents of a binary pixel classification in a region over time.
Pixels are colored based on never, sometimes, or always being a member of the class.
In this case, there are 3 regi... |
Creates a figure showing one of the following, depending on the format of arguments:
1. The change in the extents of a binary pixel classification in a region over time.
Pixels are colored based on never, sometimes, or always being a member of the class.
In this case, there are 3 regi... | def binary_class_change_plot(dataarrays, mask=None, x_coord='longitude', y_coord='latitude',
colors=None, class_legend_label=None, width=10, fig=None, ax=None,
title=None, fig_kwargs={}, title_kwargs={}, imshow_kwargs={},
x_label_... | [
"def",
"binary_class_change_plot",
"(",
"dataarrays",
",",
"mask",
"=",
"None",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
",",
"colors",
"=",
"None",
",",
"class_legend_label",
"=",
"None",
",",
"width",
"=",
"10",
",",
"fig",
... | [
940,
0
] | [
1105,
25
] | python | en | ['en', 'error', 'th'] | False |
intersection_threshold_plot | (first, second, th, mask = None, color_none='black',
color_first='green', color_second='red',
color_both='white', color_mask='gray',
width = 10, fig=None, ax=None, *args, **kwargs) |
Given two dataarrays, create a threshold plot showing where zero, one, or both are within a threshold.
Parameters
----------
first, second: xarray.DataArray
The DataArrays to compare.
th: tuple
A 2-tuple of the minimum (inclusive) and maximum (exclusive) threshold values, respe... |
Given two dataarrays, create a threshold plot showing where zero, one, or both are within a threshold.
Parameters
----------
first, second: xarray.DataArray
The DataArrays to compare.
th: tuple
A 2-tuple of the minimum (inclusive) and maximum (exclusive) threshold values, respe... | def intersection_threshold_plot(first, second, th, mask = None, color_none='black',
color_first='green', color_second='red',
color_both='white', color_mask='gray',
width = 10, fig=None, ax=None, *args, **kwargs):
"""
... | [
"def",
"intersection_threshold_plot",
"(",
"first",
",",
"second",
",",
"th",
",",
"mask",
"=",
"None",
",",
"color_none",
"=",
"'black'",
",",
"color_first",
"=",
"'green'",
",",
"color_second",
"=",
"'red'",
",",
"color_both",
"=",
"'white'",
",",
"color_m... | [
1109,
0
] | [
1203,
14
] | python | en | ['en', 'error', 'th'] | False |
print_matrix | (cell_value_mtx, cell_label_mtx=None, row_labels=None, col_labels=None,
show_row_labels=True, show_col_labels=True, show_cell_labels=True,
cmap=None, cell_val_fmt='2g', annot_kwargs={}, tick_fontsize=14,
x_axis_tick_kwargs=None, y_axis_tick_kwargs=None,
... |
Prints a matrix as a heatmap.
Inspired by https://gist.github.com/shaypal5/94c53d765083101efc0240d776a23823.
Arguments
---------
cell_value_mtx: numpy.ndarray
A 2D NumPy array to be used as the cell values when coloring with the colormap.
cell_label_mtx: numpy.ndarray
A 2D ... |
Prints a matrix as a heatmap.
Inspired by https://gist.github.com/shaypal5/94c53d765083101efc0240d776a23823.
Arguments
---------
cell_value_mtx: numpy.ndarray
A 2D NumPy array to be used as the cell values when coloring with the colormap.
cell_label_mtx: numpy.ndarray
A 2D ... | def print_matrix(cell_value_mtx, cell_label_mtx=None, row_labels=None, col_labels=None,
show_row_labels=True, show_col_labels=True, show_cell_labels=True,
cmap=None, cell_val_fmt='2g', annot_kwargs={}, tick_fontsize=14,
x_axis_tick_kwargs=None, y_axis_tick_kwargs=No... | [
"def",
"print_matrix",
"(",
"cell_value_mtx",
",",
"cell_label_mtx",
"=",
"None",
",",
"row_labels",
"=",
"None",
",",
"col_labels",
"=",
"None",
",",
"show_row_labels",
"=",
"True",
",",
"show_col_labels",
"=",
"True",
",",
"show_cell_labels",
"=",
"True",
",... | [
1211,
0
] | [
1294,
18
] | python | en | ['en', 'error', 'th'] | False |
get_ax_size | (fig, ax) |
Given matplotlib Figure (fig) and Axes (ax) objects, return
the width and height of the Axes object in inches as a list.
|
Given matplotlib Figure (fig) and Axes (ax) objects, return
the width and height of the Axes object in inches as a list.
| def get_ax_size(fig, ax):
"""
Given matplotlib Figure (fig) and Axes (ax) objects, return
the width and height of the Axes object in inches as a list.
"""
# Credit goes to https://stackoverflow.com/a/19306776/5449970.
bbox = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
... | [
"def",
"get_ax_size",
"(",
"fig",
",",
"ax",
")",
":",
"# Credit goes to https://stackoverflow.com/a/19306776/5449970.",
"bbox",
"=",
"ax",
".",
"get_window_extent",
"(",
")",
".",
"transformed",
"(",
"fig",
".",
"dpi_scale_trans",
".",
"inverted",
"(",
")",
")",
... | [
1296,
0
] | [
1303,
36
] | python | en | ['en', 'error', 'th'] | False |
xarray_imshow | (data, x_coord='longitude', y_coord='latitude', width=10,
fig=None, ax=None, use_colorbar=True, cbar_labels=None,
use_legend=False, legend_labels=None, fig_kwargs=None,
imshow_kwargs=None, x_label_kwargs=None, y_label_kwargs=None,
cbar_kwargs=N... |
Shows a heatmap of an xarray DataArray with only latitude and longitude dimensions.
Unlike `data.plot.imshow()`, this sets axes ticks and labels - including
labeling "Latitude" and "Longitude". It also simplifies creating a colorbar and legend.
Parameters
----------
data: xarray.DataArray
... |
Shows a heatmap of an xarray DataArray with only latitude and longitude dimensions.
Unlike `data.plot.imshow()`, this sets axes ticks and labels - including
labeling "Latitude" and "Longitude". It also simplifies creating a colorbar and legend.
Parameters
----------
data: xarray.DataArray
... | def xarray_imshow(data, x_coord='longitude', y_coord='latitude', width=10,
fig=None, ax=None, use_colorbar=True, cbar_labels=None,
use_legend=False, legend_labels=None, fig_kwargs=None,
imshow_kwargs=None, x_label_kwargs=None, y_label_kwargs=None,
... | [
"def",
"xarray_imshow",
"(",
"data",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
",",
"width",
"=",
"10",
",",
"fig",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"use_colorbar",
"=",
"True",
",",
"cbar_labels",
"=",
"None",
","... | [
1305,
0
] | [
1496,
28
] | python | en | ['en', 'error', 'th'] | False |
xarray_set_axes_labels | (data, ax, x_coord='longitude', y_coord='latitude',
x_label_kwargs=None, y_label_kwargs=None,
ax_tick_label_kwargs=None,
x_tick_label_kwargs=None, y_tick_label_kwargs=None) |
Sets tick locations and labels for x and y axes on a `matplotlib.axes.Axes`
object such that the tick labels do not overlap. This currently only supports
numeric coordinates.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
The xarray Dataset or DataArray containing ... |
Sets tick locations and labels for x and y axes on a `matplotlib.axes.Axes`
object such that the tick labels do not overlap. This currently only supports
numeric coordinates.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
The xarray Dataset or DataArray containing ... | def xarray_set_axes_labels(data, ax, x_coord='longitude', y_coord='latitude',
x_label_kwargs=None, y_label_kwargs=None,
ax_tick_label_kwargs=None,
x_tick_label_kwargs=None, y_tick_label_kwargs=None):
"""
Sets tick locations and la... | [
"def",
"xarray_set_axes_labels",
"(",
"data",
",",
"ax",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
",",
"x_label_kwargs",
"=",
"None",
",",
"y_label_kwargs",
"=",
"None",
",",
"ax_tick_label_kwargs",
"=",
"None",
",",
"x_tick_label_k... | [
1498,
0
] | [
1571,
55
] | python | en | ['en', 'error', 'th'] | False |
figure_ratio | (data, x_coord='longitude', y_coord='latitude',
fixed_width=8, fixed_height=None,
num_cols=1, num_rows=1) |
Returns a list of the width and height that match constraints on height
and width for a figure while maintaining aspect ratio if possible.
Also handles a grid of plots of identically sized cells.
Parameters
----------
data: xarray.Dataset or xarray.DataArray or list-like
Can b... |
Returns a list of the width and height that match constraints on height
and width for a figure while maintaining aspect ratio if possible.
Also handles a grid of plots of identically sized cells.
Parameters
----------
data: xarray.Dataset or xarray.DataArray or list-like
Can b... | def figure_ratio(data, x_coord='longitude', y_coord='latitude',
fixed_width=8, fixed_height=None,
num_cols=1, num_rows=1):
"""
Returns a list of the width and height that match constraints on height
and width for a figure while maintaining aspect ratio if possible.
A... | [
"def",
"figure_ratio",
"(",
"data",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
",",
"fixed_width",
"=",
"8",
",",
"fixed_height",
"=",
"None",
",",
"num_cols",
"=",
"1",
",",
"num_rows",
"=",
"1",
")",
":",
"assert",
"(",
"f... | [
1573,
0
] | [
1618,
44
] | python | en | ['en', 'error', 'th'] | False |
retrieve_or_create_fig_ax | (fig=None, ax=None, **fig_params) |
Returns appropriate matplotlib Figure and Axes objects given Figure and/or Axes objects.
If neither is supplied, a new figure will be created with associated axes.
If only `fig` is supplied, `(fig,fig.axes[0])` is returned. That is, the first Axes object will be used (and created if necessary).
If `ax`... |
Returns appropriate matplotlib Figure and Axes objects given Figure and/or Axes objects.
If neither is supplied, a new figure will be created with associated axes.
If only `fig` is supplied, `(fig,fig.axes[0])` is returned. That is, the first Axes object will be used (and created if necessary).
If `ax`... | def retrieve_or_create_fig_ax(fig=None, ax=None, **fig_params):
"""
Returns appropriate matplotlib Figure and Axes objects given Figure and/or Axes objects.
If neither is supplied, a new figure will be created with associated axes.
If only `fig` is supplied, `(fig,fig.axes[0])` is returned. That is, the... | [
"def",
"retrieve_or_create_fig_ax",
"(",
"fig",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"fig_params",
")",
":",
"if",
"ax",
"is",
"None",
":",
"if",
"fig",
"is",
"None",
":",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
"*",
"*... | [
1620,
0
] | [
1639,
18
] | python | en | ['en', 'error', 'th'] | False |
skip_plot | (n_pts, plot_type, kwargs={}) | Returns a boolean denoting whether to skip plotting data given the number of points it contains. | Returns a boolean denoting whether to skip plotting data given the number of points it contains. | def skip_plot(n_pts, plot_type, kwargs={}):
"""Returns a boolean denoting whether to skip plotting data given the number of points it contains."""
min_pts_dict = {'scatter': 1, 'box': 1, 'gaussian': 3, 'poly': 1, 'cubic_spline': 3, 'line':2}
min_pts = min_pts_dict[plot_type]
if plot_type == 'poly':
... | [
"def",
"skip_plot",
"(",
"n_pts",
",",
"plot_type",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"min_pts_dict",
"=",
"{",
"'scatter'",
":",
"1",
",",
"'box'",
":",
"1",
",",
"'gaussian'",
":",
"3",
",",
"'poly'",
":",
"1",
",",
"'cubic_spline'",
":",
"... | [
1641,
0
] | [
1650,
26
] | python | en | ['en', 'en', 'en'] | True |
remove_non_unique_ordered_list_str | (ordered_list) |
Sets all occurrences of a value in an ordered list after its first occurence to ''.
For example, ['a', 'a', 'b', 'b', 'c'] would become ['a', '', 'b', '', 'c'].
|
Sets all occurrences of a value in an ordered list after its first occurence to ''.
For example, ['a', 'a', 'b', 'b', 'c'] would become ['a', '', 'b', '', 'c'].
| def remove_non_unique_ordered_list_str(ordered_list):
"""
Sets all occurrences of a value in an ordered list after its first occurence to ''.
For example, ['a', 'a', 'b', 'b', 'c'] would become ['a', '', 'b', '', 'c'].
"""
prev_unique_str = ""
for i in range(len(ordered_list)):
current_s... | [
"def",
"remove_non_unique_ordered_list_str",
"(",
"ordered_list",
")",
":",
"prev_unique_str",
"=",
"\"\"",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"ordered_list",
")",
")",
":",
"current_str",
"=",
"ordered_list",
"[",
"i",
"]",
"if",
"current_str",
"!=",... | [
1652,
0
] | [
1664,
23
] | python | en | ['en', 'error', 'th'] | False |
get_weeks_per_month | (num_weeks) |
Including January, give 5 weeks to every third month - accounting for
variation between 52 and 54 weeks in a year by adding weeks to the last 3 months.
|
Including January, give 5 weeks to every third month - accounting for
variation between 52 and 54 weeks in a year by adding weeks to the last 3 months.
| def get_weeks_per_month(num_weeks):
"""
Including January, give 5 weeks to every third month - accounting for
variation between 52 and 54 weeks in a year by adding weeks to the last 3 months.
"""
last_months_num_weeks = None
if num_weeks <= 52:
last_months_num_weeks = [5,4,4]
elif n... | [
"def",
"get_weeks_per_month",
"(",
"num_weeks",
")",
":",
"last_months_num_weeks",
"=",
"None",
"if",
"num_weeks",
"<=",
"52",
":",
"last_months_num_weeks",
"=",
"[",
"5",
",",
"4",
",",
"4",
"]",
"elif",
"num_weeks",
"==",
"53",
":",
"last_months_num_weeks",
... | [
1670,
0
] | [
1682,
121
] | python | en | ['en', 'error', 'th'] | False |
month_ints_to_month_names | (month_ints) |
Converts ordinal numbers for months (in range [1,12]) to their 3-letter names.
|
Converts ordinal numbers for months (in range [1,12]) to their 3-letter names.
| def month_ints_to_month_names(month_ints):
"""
Converts ordinal numbers for months (in range [1,12]) to their 3-letter names.
"""
return [month_names[i-1] for i in month_ints] | [
"def",
"month_ints_to_month_names",
"(",
"month_ints",
")",
":",
"return",
"[",
"month_names",
"[",
"i",
"-",
"1",
"]",
"for",
"i",
"in",
"month_ints",
"]"
] | [
1687,
0
] | [
1691,
49
] | python | en | ['en', 'error', 'th'] | False |
week_ints_to_month_names | (week_ints) |
Converts ordinal numbers for weeks (in range [1,54]) to their months' 3-letter names.
|
Converts ordinal numbers for weeks (in range [1,54]) to their months' 3-letter names.
| def week_ints_to_month_names(week_ints):
"""
Converts ordinal numbers for weeks (in range [1,54]) to their months' 3-letter names.
"""
weeks_per_month = get_weeks_per_month(max(week_ints))
week_month_strs = []
for week_int in week_ints:
month_int = -1
for current_month_int, curre... | [
"def",
"week_ints_to_month_names",
"(",
"week_ints",
")",
":",
"weeks_per_month",
"=",
"get_weeks_per_month",
"(",
"max",
"(",
"week_ints",
")",
")",
"week_month_strs",
"=",
"[",
"]",
"for",
"week_int",
"in",
"week_ints",
":",
"month_int",
"=",
"-",
"1",
"for"... | [
1693,
0
] | [
1707,
26
] | python | en | ['en', 'error', 'th'] | False |
naive_months_ticks_by_week | (week_ints=None) |
Given a list of week numbers (in range [1,54]), returns a list of month strings separated by spaces.
Covers 54 weeks if no list-like of week numbers is given.
This is only intended to be used for labeling axes in plotting.
|
Given a list of week numbers (in range [1,54]), returns a list of month strings separated by spaces.
Covers 54 weeks if no list-like of week numbers is given.
This is only intended to be used for labeling axes in plotting.
| def naive_months_ticks_by_week(week_ints=None):
"""
Given a list of week numbers (in range [1,54]), returns a list of month strings separated by spaces.
Covers 54 weeks if no list-like of week numbers is given.
This is only intended to be used for labeling axes in plotting.
"""
month_ticks_by_we... | [
"def",
"naive_months_ticks_by_week",
"(",
"week_ints",
"=",
"None",
")",
":",
"month_ticks_by_week",
"=",
"[",
"]",
"if",
"week_ints",
"is",
"None",
":",
"# Give month ticks for all weeks.",
"month_ticks_by_week",
"=",
"week_ints_to_month_names",
"(",
"list",
"(",
"ra... | [
1709,
0
] | [
1720,
30
] | python | en | ['en', 'error', 'th'] | False |
HtmlSiteStore.get_url_for_resource | (self, resource_identifier=None, only_if_exists=True) |
Return the URL of the HTML document that renders a resource
(e.g., an expectation suite or a validation result).
:param resource_identifier: ExpectationSuiteIdentifier, ValidationResultIdentifier
or any other type's identifier. The argument is optional - when
no... |
Return the URL of the HTML document that renders a resource
(e.g., an expectation suite or a validation result). | def get_url_for_resource(self, resource_identifier=None, only_if_exists=True):
"""
Return the URL of the HTML document that renders a resource
(e.g., an expectation suite or a validation result).
:param resource_identifier: ExpectationSuiteIdentifier, ValidationResultIdentifier
... | [
"def",
"get_url_for_resource",
"(",
"self",
",",
"resource_identifier",
"=",
"None",
",",
"only_if_exists",
"=",
"True",
")",
":",
"if",
"resource_identifier",
"is",
"None",
":",
"store_backend",
"=",
"self",
".",
"store_backends",
"[",
"\"index_page\"",
"]",
"k... | [
238,
4
] | [
289,
57
] | python | en | ['en', 'error', 'th'] | False |
HtmlSiteStore.write_index_page | (self, page) | This third param_store has a special method, which uses a zero-length tuple as a key. | This third param_store has a special method, which uses a zero-length tuple as a key. | def write_index_page(self, page):
"""This third param_store has a special method, which uses a zero-length tuple as a key."""
return self.store_backends["index_page"].set(
(),
page,
content_encoding="utf-8",
content_type="text/html; " "charset=utf-8",
... | [
"def",
"write_index_page",
"(",
"self",
",",
"page",
")",
":",
"return",
"self",
".",
"store_backends",
"[",
"\"index_page\"",
"]",
".",
"set",
"(",
"(",
")",
",",
"page",
",",
"content_encoding",
"=",
"\"utf-8\"",
",",
"content_type",
"=",
"\"text/html; \""... | [
333,
4
] | [
340,
9
] | python | en | ['en', 'en', 'en'] | True |
HtmlSiteStore.copy_static_assets | (self, static_assets_source_dir=None) |
Copies static assets, using a special "static_assets" backend store that accepts variable-length tuples as
keys, with no filepath_template.
|
Copies static assets, using a special "static_assets" backend store that accepts variable-length tuples as
keys, with no filepath_template.
| def copy_static_assets(self, static_assets_source_dir=None):
"""
Copies static assets, using a special "static_assets" backend store that accepts variable-length tuples as
keys, with no filepath_template.
"""
file_exclusions = [".DS_Store"]
dir_exclusions = []
if... | [
"def",
"copy_static_assets",
"(",
"self",
",",
"static_assets_source_dir",
"=",
"None",
")",
":",
"file_exclusions",
"=",
"[",
"\".DS_Store\"",
"]",
"dir_exclusions",
"=",
"[",
"]",
"if",
"not",
"static_assets_source_dir",
":",
"static_assets_source_dir",
"=",
"file... | [
348,
4
] | [
399,
21
] | python | en | ['en', 'error', 'th'] | False |
test_checkpoint_new_raises_error_on_existing_checkpoint | (
mock_emit,
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_stats_enabled_with_checkpoints_v1_with_templates,
) |
What does this test and why?
The `checkpoint new` CLI flow should raise an error if the Checkpoint name being created already exists in your checkpoint store.
|
What does this test and why?
The `checkpoint new` CLI flow should raise an error if the Checkpoint name being created already exists in your checkpoint store.
| def test_checkpoint_new_raises_error_on_existing_checkpoint(
mock_emit,
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_stats_enabled_with_checkpoints_v1_with_templates,
):
"""
What does this test and why?
The `checkpoint new` CLI flow should raise an error if the Check... | [
"def",
"test_checkpoint_new_raises_error_on_existing_checkpoint",
"(",
"mock_emit",
",",
"caplog",
",",
"monkeypatch",
",",
"titanic_pandas_data_context_with_v013_datasource_stats_enabled_with_checkpoints_v1_with_templates",
",",
")",
":",
"context",
":",
"DataContext",
"=",
"titan... | [
600,
0
] | [
652,
5
] | python | en | ['en', 'error', 'th'] | False |
test_checkpoint_new_happy_path_generates_a_notebook_and_checkpoint | (
mock_webbroser,
mock_subprocess,
mock_emit,
caplog,
monkeypatch,
deterministic_asset_dataconnector_context,
titanic_expectation_suite,
) |
What does this test and why?
The v3 (Batch Request) API `checkpoint new` CLI flow includes creating a notebook to configure the Checkpoint.
This test builds that notebook and runs it to generate a Checkpoint and then tests the resulting configuration in the Checkpoint file.
The notebook that is generat... |
What does this test and why?
The v3 (Batch Request) API `checkpoint new` CLI flow includes creating a notebook to configure the Checkpoint.
This test builds that notebook and runs it to generate a Checkpoint and then tests the resulting configuration in the Checkpoint file.
The notebook that is generat... | def test_checkpoint_new_happy_path_generates_a_notebook_and_checkpoint(
mock_webbroser,
mock_subprocess,
mock_emit,
caplog,
monkeypatch,
deterministic_asset_dataconnector_context,
titanic_expectation_suite,
):
"""
What does this test and why?
The v3 (Batch Request) API `checkpoin... | [
"def",
"test_checkpoint_new_happy_path_generates_a_notebook_and_checkpoint",
"(",
"mock_webbroser",
",",
"mock_subprocess",
",",
"mock_emit",
",",
"caplog",
",",
"monkeypatch",
",",
"deterministic_asset_dataconnector_context",
",",
"titanic_expectation_suite",
",",
")",
":",
"c... | [
660,
0
] | [
783,
5
] | python | en | ['en', 'error', 'th'] | False |
test_checkpoint_script_happy_path_executable_successful_validation_pandas | (
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled,
) |
We call the "checkpoint script" command on a project with a Checkpoint.
The command should:
- create the script (note output is tested in other tests)
When run the script should:
- execute
- return a 0 status code
- print a success message
|
We call the "checkpoint script" command on a project with a Checkpoint. | def test_checkpoint_script_happy_path_executable_successful_validation_pandas(
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled,
):
"""
We call the "checkpoint script" command on a project with a Checkpoint.
The command sho... | [
"def",
"test_checkpoint_script_happy_path_executable_successful_validation_pandas",
"(",
"caplog",
",",
"monkeypatch",
",",
"titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled",
",",
")",
":",
"monkeypatch",
".",
"setenv",
"(",
"\"VAR\""... | [
2654,
0
] | [
2764,
44
] | python | en | ['en', 'error', 'th'] | False |
test_checkpoint_script_happy_path_executable_failed_validation_pandas | (
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled,
titanic_expectation_suite,
) |
We call the "checkpoint script" command on a project with a Checkpoint.
The command should:
- create the script (note output is tested in other tests)
When run the script should:
- execute
- return a 1 status code
- print a failure message
|
We call the "checkpoint script" command on a project with a Checkpoint. | def test_checkpoint_script_happy_path_executable_failed_validation_pandas(
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled,
titanic_expectation_suite,
):
"""
We call the "checkpoint script" command on a project with a Check... | [
"def",
"test_checkpoint_script_happy_path_executable_failed_validation_pandas",
"(",
"caplog",
",",
"monkeypatch",
",",
"titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled",
",",
"titanic_expectation_suite",
",",
")",
":",
"monkeypatch",
"... | [
2767,
0
] | [
2885,
41
] | python | en | ['en', 'error', 'th'] | False |
test_checkpoint_script_happy_path_executable_failed_validation_due_to_bad_data_pandas | (
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled,
titanic_expectation_suite,
) |
We call the "checkpoint script" command on a project with a Checkpoint.
The command should:
- create the script (note output is tested in other tests)
When run the script should:
- execute
- return a 1 status code
- print a failure message
|
We call the "checkpoint script" command on a project with a Checkpoint. | def test_checkpoint_script_happy_path_executable_failed_validation_due_to_bad_data_pandas(
caplog,
monkeypatch,
titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled,
titanic_expectation_suite,
):
"""
We call the "checkpoint script" command on a proj... | [
"def",
"test_checkpoint_script_happy_path_executable_failed_validation_due_to_bad_data_pandas",
"(",
"caplog",
",",
"monkeypatch",
",",
"titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled",
",",
"titanic_expectation_suite",
",",
")",
":",
"m... | [
2888,
0
] | [
3008,
5
] | python | en | ['en', 'error', 'th'] | False |
retry_on_exception | (tries=6, delay=1, backoff=2, max_delay=32) |
Decorator for implementing exponential backoff for retrying on failures.
tries: Max number of tries to execute the wrapped function before failing.
delay: Delay time in seconds before the FIRST retry.
backoff: Multiplier to extend the initial delay by for each retry.
max_delay: Max time in seconds... |
Decorator for implementing exponential backoff for retrying on failures. | def retry_on_exception(tries=6, delay=1, backoff=2, max_delay=32):
'''
Decorator for implementing exponential backoff for retrying on failures.
tries: Max number of tries to execute the wrapped function before failing.
delay: Delay time in seconds before the FIRST retry.
backoff: Multiplier to exte... | [
"def",
"retry_on_exception",
"(",
"tries",
"=",
"6",
",",
"delay",
"=",
"1",
",",
"backoff",
"=",
"2",
",",
"max_delay",
"=",
"32",
")",
":",
"tries",
"=",
"math",
".",
"floor",
"(",
"tries",
")",
"if",
"tries",
"<",
"1",
":",
"raise",
"ValueError"... | [
10,
0
] | [
46,
40
] | python | en | ['en', 'error', 'th'] | False |
rate_limited | (max_per_second) | This decorator limits how often a method can get called in a second.
If the limit is exceeded, the call will be held in a queue until
enough time has passed.
Useful when trying to avoid overloading a system with rapid calls. | This decorator limits how often a method can get called in a second.
If the limit is exceeded, the call will be held in a queue until
enough time has passed.
Useful when trying to avoid overloading a system with rapid calls. | def rate_limited(max_per_second):
""" This decorator limits how often a method can get called in a second.
If the limit is exceeded, the call will be held in a queue until
enough time has passed.
Useful when trying to avoid overloading a system with rapid calls. """
min_interval = 1.0 / ... | [
"def",
"rate_limited",
"(",
"max_per_second",
")",
":",
"min_interval",
"=",
"1.0",
"/",
"float",
"(",
"max_per_second",
")",
"def",
"decorate",
"(",
"func",
")",
":",
"last_time_called",
"=",
"[",
"0.0",
"]",
"rate_lock",
"=",
"threading",
".",
"Lock",
"(... | [
49,
0
] | [
79,
19
] | python | en | ['en', 'en', 'en'] | True |
deprecated | (message=None) | This decorator marks methods as deprecated.
A warning is displayed if the method is called. | This decorator marks methods as deprecated.
A warning is displayed if the method is called. | def deprecated(message=None):
""" This decorator marks methods as deprecated.
A warning is displayed if the method is called. """
def decorated_method_to_deprecate(func):
if inspect.isclass(func):
# Handle a deprecated class differently from a deprecated method
msg = "Cl... | [
"def",
"deprecated",
"(",
"message",
"=",
"None",
")",
":",
"def",
"decorated_method_to_deprecate",
"(",
"func",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"func",
")",
":",
"# Handle a deprecated class differently from a deprecated method",
"msg",
"=",
"\"Clas... | [
82,
0
] | [
107,
40
] | python | en | ['en', 'en', 'en'] | True |
benchmark_querying | (n_docs_options,
retriever_doc_stores,
data_dir,
data_s3_url,
filename_gold,
filename_negative,
n_queries,
embeddings_filenames,
embeddi... | Benchmark the time it takes to perform querying. Doc embeddings are loaded from file. | Benchmark the time it takes to perform querying. Doc embeddings are loaded from file. | def benchmark_querying(n_docs_options,
retriever_doc_stores,
data_dir,
data_s3_url,
filename_gold,
filename_negative,
n_queries,
embeddings_filenames,
... | [
"def",
"benchmark_querying",
"(",
"n_docs_options",
",",
"retriever_doc_stores",
",",
"data_dir",
",",
"data_s3_url",
",",
"filename_gold",
",",
"filename_negative",
",",
"n_queries",
",",
"embeddings_filenames",
",",
"embeddings_dir",
",",
"update_json",
",",
"save_mar... | [
117,
0
] | [
220,
33
] | python | en | ['en', 'en', 'en'] | True |
prepare_data | (data_dir, filename_gold, filename_negative, data_s3_url, embeddings_filenames, embeddings_dir, n_docs=None, n_queries=None, add_precomputed=False) |
filename_gold points to a squad format file.
filename_negative points to a csv file where the first column is doc_id and second is document text.
If add_precomputed is True, this fn will look in the embeddings files for precomputed embeddings to add to each Document
|
filename_gold points to a squad format file.
filename_negative points to a csv file where the first column is doc_id and second is document text.
If add_precomputed is True, this fn will look in the embeddings files for precomputed embeddings to add to each Document
| def prepare_data(data_dir, filename_gold, filename_negative, data_s3_url, embeddings_filenames, embeddings_dir, n_docs=None, n_queries=None, add_precomputed=False):
"""
filename_gold points to a squad format file.
filename_negative points to a csv file where the first column is doc_id and second is documen... | [
"def",
"prepare_data",
"(",
"data_dir",
",",
"filename_gold",
",",
"filename_negative",
",",
"data_s3_url",
",",
"embeddings_filenames",
",",
"embeddings_dir",
",",
"n_docs",
"=",
"None",
",",
"n_queries",
"=",
"None",
",",
"add_precomputed",
"=",
"False",
")",
... | [
256,
0
] | [
292,
23
] | python | en | ['en', 'error', 'th'] | False |
recipe_image_file_path | (instance, filename) | Generate file path for new recipe image | Generate file path for new recipe image | def recipe_image_file_path(instance, filename):
"""Generate file path for new recipe image"""
ext = filename.split('.')[-1]
filename = f'{uuid.uuid4()}.{ext}'
return os.path.join('upload/recipe/', filename) | [
"def",
"recipe_image_file_path",
"(",
"instance",
",",
"filename",
")",
":",
"ext",
"=",
"filename",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"filename",
"=",
"f'{uuid.uuid4()}.{ext}'",
"return",
"os",
".",
"path",
".",
"join",
"(",
"'upload/reci... | [
9,
0
] | [
14,
51
] | python | en | ['en', 'en', 'en'] | True |
UserManager.create_user | (self, email, password=None, **extra_fields) | Creates and saves a new user | Creates and saves a new user | def create_user(self, email, password=None, **extra_fields):
"""Creates and saves a new user"""
if not email:
raise ValueError('Users must have an email address')
user = self.model(email=self.normalize_email(email), **extra_fields)
user.set_password(password)
user.sav... | [
"def",
"create_user",
"(",
"self",
",",
"email",
",",
"password",
"=",
"None",
",",
"*",
"*",
"extra_fields",
")",
":",
"if",
"not",
"email",
":",
"raise",
"ValueError",
"(",
"'Users must have an email address'",
")",
"user",
"=",
"self",
".",
"model",
"("... | [
19,
4
] | [
27,
19
] | python | en | ['en', 'en', 'en'] | True |
UserManager.create_superuser | (self, email, password) | Creates and saves a new super user | Creates and saves a new super user | def create_superuser(self, email, password):
"""Creates and saves a new super user"""
user = self.create_user(email, password)
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user | [
"def",
"create_superuser",
"(",
"self",
",",
"email",
",",
"password",
")",
":",
"user",
"=",
"self",
".",
"create_user",
"(",
"email",
",",
"password",
")",
"user",
".",
"is_staff",
"=",
"True",
"user",
".",
"is_superuser",
"=",
"True",
"user",
".",
"... | [
29,
4
] | [
36,
19
] | python | en | ['en', 'en', 'en'] | True |
ExpectTableColumnsToMatchSet.validate_configuration | (self, configuration: Optional[ExpectationConfiguration]) |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
Args:
configuration (OPTIONAL[ExpectationConfiguration]): \
An opt... |
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation. | def validate_configuration(self, configuration: Optional[ExpectationConfiguration]):
"""
Validates that a configuration has been set, and sets a configuration if it has yet to be set. Ensures that
necessary configuration arguments have been provided for the validation of the expectation.
... | [
"def",
"validate_configuration",
"(",
"self",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
")",
":",
"# Setting up a configuration",
"super",
"(",
")",
".",
"validate_configuration",
"(",
"configuration",
")",
"# Ensuring that a proper valu... | [
70,
4
] | [
98,
19
] | python | en | ['en', 'error', 'th'] | False |
UnboundedQueue.qsize | (self) | Returns the number of items currently in the queue. | Returns the number of items currently in the queue. | def qsize(self):
"""Returns the number of items currently in the queue."""
return len(self._data) | [
"def",
"qsize",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"_data",
")"
] | [
58,
4
] | [
60,
30
] | python | en | ['en', 'en', 'en'] | True |
UnboundedQueue.empty | (self) | Returns True if the queue is empty, False otherwise.
There is some subtlety to interpreting this method's return value: see
`issue #63 <https://github.com/python-trio/trio/issues/63>`__.
| Returns True if the queue is empty, False otherwise. | def empty(self):
"""Returns True if the queue is empty, False otherwise.
There is some subtlety to interpreting this method's return value: see
`issue #63 <https://github.com/python-trio/trio/issues/63>`__.
"""
return not self._data | [
"def",
"empty",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"_data"
] | [
62,
4
] | [
69,
29
] | python | en | ['en', 'en', 'en'] | True |
UnboundedQueue.put_nowait | (self, obj) | Put an object into the queue, without blocking.
This always succeeds, because the queue is unbounded. We don't provide
a blocking ``put`` method, because it would never need to block.
Args:
obj (object): The object to enqueue.
| Put an object into the queue, without blocking. | def put_nowait(self, obj):
"""Put an object into the queue, without blocking.
This always succeeds, because the queue is unbounded. We don't provide
a blocking ``put`` method, because it would never need to block.
Args:
obj (object): The object to enqueue.
"""
... | [
"def",
"put_nowait",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"self",
".",
"_data",
":",
"assert",
"not",
"self",
".",
"_can_get",
"if",
"self",
".",
"_lot",
":",
"self",
".",
"_lot",
".",
"unpark",
"(",
"count",
"=",
"1",
")",
"else",
":"... | [
72,
4
] | [
88,
30
] | 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.