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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_instantiate_datasource_from_config | (
self, name: str, config: dict
) | Instantiate a new datasource to the data context, with configuration provided as kwargs.
Args:
name(str): name of datasource
config(dict): dictionary of configuration
Returns:
datasource (Datasource)
| Instantiate a new datasource to the data context, with configuration provided as kwargs.
Args:
name(str): name of datasource
config(dict): dictionary of configuration | def _instantiate_datasource_from_config(
self, name: str, config: dict
) -> Union[LegacyDatasource, BaseDatasource]:
"""Instantiate a new datasource to the data context, with configuration provided as kwargs.
Args:
name(str): name of datasource
config(dict): dictionar... | [
"def",
"_instantiate_datasource_from_config",
"(",
"self",
",",
"name",
":",
"str",
",",
"config",
":",
"dict",
")",
"->",
"Union",
"[",
"LegacyDatasource",
",",
"BaseDatasource",
"]",
":",
"# We perform variable substitution in the datasource's config here before using the... | [
1863,
4
] | [
1886,
25
] | python | en | ['en', 'en', 'en'] | True |
add_batch_kwargs_generator | (
self, datasource_name, batch_kwargs_generator_name, class_name, **kwargs
) |
Add a batch kwargs generator to the named datasource, using the provided
configuration.
Args:
datasource_name: name of datasource to which to add the new batch kwargs generator
batch_kwargs_generator_name: name of the generator to add
class_name: class of th... |
Add a batch kwargs generator to the named datasource, using the provided
configuration. | def add_batch_kwargs_generator(
self, datasource_name, batch_kwargs_generator_name, class_name, **kwargs
):
"""
Add a batch kwargs generator to the named datasource, using the provided
configuration.
Args:
datasource_name: name of datasource to which to add the n... | [
"def",
"add_batch_kwargs_generator",
"(",
"self",
",",
"datasource_name",
",",
"batch_kwargs_generator_name",
",",
"class_name",
",",
"*",
"*",
"kwargs",
")",
":",
"datasource_obj",
"=",
"self",
".",
"get_datasource",
"(",
"datasource_name",
")",
"generator",
"=",
... | [
1888,
4
] | [
1908,
24
] | python | en | ['en', 'error', 'th'] | False |
get_datasource | (
self, datasource_name: str = "default"
) | Get the named datasource
Args:
datasource_name (str): the name of the datasource from the configuration
Returns:
datasource (Datasource)
| Get the named datasource | def get_datasource(
self, datasource_name: str = "default"
) -> Optional[Union[LegacyDatasource, BaseDatasource]]:
"""Get the named datasource
Args:
datasource_name (str): the name of the datasource from the configuration
Returns:
datasource (Datasource)
... | [
"def",
"get_datasource",
"(",
"self",
",",
"datasource_name",
":",
"str",
"=",
"\"default\"",
")",
"->",
"Optional",
"[",
"Union",
"[",
"LegacyDatasource",
",",
"BaseDatasource",
"]",
"]",
":",
"if",
"datasource_name",
"in",
"self",
".",
"_cached_datasources",
... | [
1960,
4
] | [
1993,
25
] | python | en | ['en', 'en', 'en'] | True |
list_expectation_suites | (self) | Return a list of available expectation suite names. | Return a list of available expectation suite names. | def list_expectation_suites(self):
"""Return a list of available expectation suite names."""
try:
keys = self.expectations_store.list_keys()
except KeyError as e:
raise ge_exceptions.InvalidConfigError(
"Unable to find configured store: %s" % str(e)
... | [
"def",
"list_expectation_suites",
"(",
"self",
")",
":",
"try",
":",
"keys",
"=",
"self",
".",
"expectations_store",
".",
"list_keys",
"(",
")",
"except",
"KeyError",
"as",
"e",
":",
"raise",
"ge_exceptions",
".",
"InvalidConfigError",
"(",
"\"Unable to find con... | [
1995,
4
] | [
2003,
19
] | python | en | ['en', 'en', 'en'] | True |
list_datasources | (self) | List currently-configured datasources on this context. Masks passwords.
Returns:
List(dict): each dictionary includes "name", "class_name", and "module_name" keys
| List currently-configured datasources on this context. Masks passwords. | def list_datasources(self):
"""List currently-configured datasources on this context. Masks passwords.
Returns:
List(dict): each dictionary includes "name", "class_name", and "module_name" keys
"""
datasources = []
for (
key,
value,
) ... | [
"def",
"list_datasources",
"(",
"self",
")",
":",
"datasources",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
",",
")",
"in",
"self",
".",
"project_config_with_variables_substituted",
".",
"datasources",
".",
"items",
"(",
")",
":",
"value",
"[",
"\"nam... | [
2005,
4
] | [
2029,
26
] | python | en | ['en', 'en', 'en'] | True |
list_stores | (self) | List currently-configured Stores on this context | List currently-configured Stores on this context | def list_stores(self):
"""List currently-configured Stores on this context"""
stores = []
for (
name,
value,
) in self.project_config_with_variables_substituted.stores.items():
value["name"] = name
stores.append(value)
return store... | [
"def",
"list_stores",
"(",
"self",
")",
":",
"stores",
"=",
"[",
"]",
"for",
"(",
"name",
",",
"value",
",",
")",
"in",
"self",
".",
"project_config_with_variables_substituted",
".",
"stores",
".",
"items",
"(",
")",
":",
"value",
"[",
"\"name\"",
"]",
... | [
2031,
4
] | [
2041,
21
] | python | en | ['en', 'en', 'en'] | True |
list_active_stores | (self) |
List active Stores on this context. Active stores are identified by setting the following parameters:
expectations_store_name,
validations_store_name,
evaluation_parameter_store_name,
checkpoint_store_name
|
List active Stores on this context. Active stores are identified by setting the following parameters:
expectations_store_name,
validations_store_name,
evaluation_parameter_store_name,
checkpoint_store_name
| def list_active_stores(self):
"""
List active Stores on this context. Active stores are identified by setting the following parameters:
expectations_store_name,
validations_store_name,
evaluation_parameter_store_name,
checkpoint_store_name
"""
... | [
"def",
"list_active_stores",
"(",
"self",
")",
":",
"active_store_names",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"self",
".",
"expectations_store_name",
",",
"self",
".",
"validations_store_name",
",",
"self",
".",
"evaluation_parameter_store_name",
",",
"]",
"... | [
2043,
4
] | [
2063,
9
] | python | en | ['en', 'error', 'th'] | False |
list_validation_operators | (self) | List currently-configured Validation Operators on this context | List currently-configured Validation Operators on this context | def list_validation_operators(self):
"""List currently-configured Validation Operators on this context"""
validation_operators = []
for (
name,
value,
) in (
self.project_config_with_variables_substituted.validation_operators.items()
):
... | [
"def",
"list_validation_operators",
"(",
"self",
")",
":",
"validation_operators",
"=",
"[",
"]",
"for",
"(",
"name",
",",
"value",
",",
")",
"in",
"(",
"self",
".",
"project_config_with_variables_substituted",
".",
"validation_operators",
".",
"items",
"(",
")"... | [
2065,
4
] | [
2077,
35
] | python | en | ['en', 'en', 'en'] | True |
create_expectation_suite | (
self, expectation_suite_name: str, overwrite_existing: Optional[bool] = False
) | Build a new expectation suite and save it into the data_context expectation store.
Args:
expectation_suite_name: The name of the expectation_suite to create
overwrite_existing (boolean): Whether to overwrite expectation suite if expectation suite with given name
already ... | Build a new expectation suite and save it into the data_context expectation store. | def create_expectation_suite(
self, expectation_suite_name: str, overwrite_existing: Optional[bool] = False
) -> ExpectationSuite:
"""Build a new expectation suite and save it into the data_context expectation store.
Args:
expectation_suite_name: The name of the expectation_suit... | [
"def",
"create_expectation_suite",
"(",
"self",
",",
"expectation_suite_name",
":",
"str",
",",
"overwrite_existing",
":",
"Optional",
"[",
"bool",
"]",
"=",
"False",
")",
"->",
"ExpectationSuite",
":",
"if",
"not",
"isinstance",
"(",
"overwrite_existing",
",",
... | [
2079,
4
] | [
2112,
32
] | python | en | ['en', 'en', 'en'] | True |
delete_expectation_suite | (self, expectation_suite_name) | Delete specified expectation suite from data_context expectation store.
Args:
expectation_suite_name: The name of the expectation_suite to create
Returns:
True for Success and False for Failure.
| Delete specified expectation suite from data_context expectation store. | def delete_expectation_suite(self, expectation_suite_name):
"""Delete specified expectation suite from data_context expectation store.
Args:
expectation_suite_name: The name of the expectation_suite to create
Returns:
True for Success and False for Failure.
"""
... | [
"def",
"delete_expectation_suite",
"(",
"self",
",",
"expectation_suite_name",
")",
":",
"key",
"=",
"ExpectationSuiteIdentifier",
"(",
"expectation_suite_name",
")",
"if",
"not",
"self",
".",
"expectations_store",
".",
"has_key",
"(",
"key",
")",
":",
"raise",
"g... | [
2114,
4
] | [
2130,
23
] | python | en | ['en', 'en', 'en'] | True |
get_expectation_suite | (self, expectation_suite_name: str) | Get a named expectation suite for the provided data_asset_name.
Args:
expectation_suite_name (str): the name for the expectation suite
Returns:
expectation_suite
| Get a named expectation suite for the provided data_asset_name. | def get_expectation_suite(self, expectation_suite_name: str) -> ExpectationSuite:
"""Get a named expectation suite for the provided data_asset_name.
Args:
expectation_suite_name (str): the name for the expectation suite
Returns:
expectation_suite
"""
key... | [
"def",
"get_expectation_suite",
"(",
"self",
",",
"expectation_suite_name",
":",
"str",
")",
"->",
"ExpectationSuite",
":",
"key",
":",
"ExpectationSuiteIdentifier",
"=",
"ExpectationSuiteIdentifier",
"(",
"expectation_suite_name",
"=",
"expectation_suite_name",
")",
"if"... | [
2132,
4
] | [
2150,
13
] | python | en | ['en', 'en', 'en'] | True |
list_expectation_suite_names | (self) | Lists the available expectation suite names | Lists the available expectation suite names | def list_expectation_suite_names(self):
"""Lists the available expectation suite names"""
sorted_expectation_suite_names = [
i.expectation_suite_name for i in self.list_expectation_suites()
]
sorted_expectation_suite_names.sort()
return sorted_expectation_suite_names | [
"def",
"list_expectation_suite_names",
"(",
"self",
")",
":",
"sorted_expectation_suite_names",
"=",
"[",
"i",
".",
"expectation_suite_name",
"for",
"i",
"in",
"self",
".",
"list_expectation_suites",
"(",
")",
"]",
"sorted_expectation_suite_names",
".",
"sort",
"(",
... | [
2152,
4
] | [
2158,
45
] | python | en | ['en', 'en', 'en'] | True |
save_expectation_suite | (self, expectation_suite, expectation_suite_name=None) | Save the provided expectation suite into the DataContext.
Args:
expectation_suite: the suite to save
expectation_suite_name: the name of this expectation suite. If no name is provided the name will \
be read from the suite
Returns:
None
| Save the provided expectation suite into the DataContext. | def save_expectation_suite(self, expectation_suite, expectation_suite_name=None):
"""Save the provided expectation suite into the DataContext.
Args:
expectation_suite: the suite to save
expectation_suite_name: the name of this expectation suite. If no name is provided the name w... | [
"def",
"save_expectation_suite",
"(",
"self",
",",
"expectation_suite",
",",
"expectation_suite_name",
"=",
"None",
")",
":",
"if",
"expectation_suite_name",
"is",
"None",
":",
"key",
"=",
"ExpectationSuiteIdentifier",
"(",
"expectation_suite_name",
"=",
"expectation_su... | [
2164,
4
] | [
2186,
64
] | python | en | ['en', 'en', 'en'] | True |
_store_metrics | (self, requested_metrics, validation_results, target_store_name) |
requested_metrics is a dictionary like this:
requested_metrics:
*: # The asterisk here matches *any* expectation suite name
# use the 'kwargs' key to request metrics that are defined by kwargs,
# for example because they are defined only for a... |
requested_metrics is a dictionary like this: | def _store_metrics(self, requested_metrics, validation_results, target_store_name):
"""
requested_metrics is a dictionary like this:
requested_metrics:
*: # The asterisk here matches *any* expectation suite name
# use the 'kwargs' key to request metrics ... | [
"def",
"_store_metrics",
"(",
"self",
",",
"requested_metrics",
",",
"validation_results",
",",
"target_store_name",
")",
":",
"expectation_suite_name",
"=",
"validation_results",
".",
"meta",
"[",
"\"expectation_suite_name\"",
"]",
"run_id",
"=",
"validation_results",
... | [
2188,
4
] | [
2256,
25
] | python | en | ['en', 'error', 'th'] | False |
get_validation_result | (
self,
expectation_suite_name,
run_id=None,
batch_identifier=None,
validations_store_name=None,
failed_only=False,
) | Get validation results from a configured store.
Args:
expectation_suite_name: expectation_suite name for which to get validation result (default: "default")
run_id: run_id for which to get validation result (if None, fetch the latest result by alphanumeric sort)
validations_... | Get validation results from a configured store. | def get_validation_result(
self,
expectation_suite_name,
run_id=None,
batch_identifier=None,
validations_store_name=None,
failed_only=False,
):
"""Get validation results from a configured store.
Args:
expectation_suite_name: expectation_su... | [
"def",
"get_validation_result",
"(",
"self",
",",
"expectation_suite_name",
",",
"run_id",
"=",
"None",
",",
"batch_identifier",
"=",
"None",
",",
"validations_store_name",
"=",
"None",
",",
"failed_only",
"=",
"False",
",",
")",
":",
"if",
"validations_store_name... | [
2307,
4
] | [
2377,
31
] | python | en | ['en', 'en', 'en'] | True |
update_return_obj | (self, data_asset, return_obj) | Helper called by data_asset.
Args:
data_asset: The data_asset whose validation produced the current return object
return_obj: the return object to update
Returns:
return_obj: the return object, potentially changed into a widget by the configured expectation explorer... | Helper called by data_asset. | def update_return_obj(self, data_asset, return_obj):
"""Helper called by data_asset.
Args:
data_asset: The data_asset whose validation produced the current return object
return_obj: the return object to update
Returns:
return_obj: the return object, potentia... | [
"def",
"update_return_obj",
"(",
"self",
",",
"data_asset",
",",
"return_obj",
")",
":",
"return",
"return_obj"
] | [
2379,
4
] | [
2389,
25
] | python | en | ['en', 'lb', 'en'] | True |
With_all_joints.__init__ | (self, *args, **kwargs) |
Usage: Inputs are all joints information, which can be used to generate three different learnable values:
1.Global modulation; 2.Group-wise modulation. 3.Channel-wise modulation.
For each of the above format, it can be combined with group convolution by [Addition] and [Multiply... |
Usage: Inputs are all joints information, which can be used to generate three different learnable values:
1.Global modulation; 2.Group-wise modulation. 3.Channel-wise modulation.
For each of the above format, it can be combined with group convolution by [Addition] and [Multiply... | def __init__(self, *args, **kwargs):
super(With_all_joints, self).__init__(*args, **kwargs)
"""
Usage: Inputs are all joints information, which can be used to generate three different learnable values:
1.Global modulation; 2.Group-wise modulation. 3.Channel-wise modulation.
... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"With_all_joints",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"modulation",
":",
"print",
... | [
54,
4
] | [
101,
60
] | python | en | ['en', 'error', 'th'] | False |
With_other_joints.__init__ | (self, inc, outc, out_seq, kernel_size, padding, dilation, stride, split_modulation,
recombine, repeat_concat, in_c, mean_func, mean_dim, ups_mean) |
Usage: Inputs from [Out of the group] Joints to get their information that can divided into two formats:
1.Learnable local modulation. 2. Manual function,e.g. Mean opertation
For each of the above format, it can be combined with group convolution by [Addition], [Multiply] and [C... |
Usage: Inputs from [Out of the group] Joints to get their information that can divided into two formats:
1.Learnable local modulation. 2. Manual function,e.g. Mean opertation
For each of the above format, it can be combined with group convolution by [Addition], [Multiply] and [C... | def __init__(self, inc, outc, out_seq, kernel_size, padding, dilation, stride, split_modulation,
recombine, repeat_concat, in_c, mean_func, mean_dim, ups_mean):
"""
Usage: Inputs from [Out of the group] Joints to get their information that can divided into two formats:
1... | [
"def",
"__init__",
"(",
"self",
",",
"inc",
",",
"outc",
",",
"out_seq",
",",
"kernel_size",
",",
"padding",
",",
"dilation",
",",
"stride",
",",
"split_modulation",
",",
"recombine",
",",
"repeat_concat",
",",
"in_c",
",",
"mean_func",
",",
"mean_dim",
",... | [
182,
4
] | [
236,
47
] | python | en | ['en', 'error', 'th'] | False |
With_other_joints._mean_func | (self, x, cat_num, x_self) |
Get mean value of each group from all other joints
:param x: a list with [other joints] of the group
:param cat_num: the repeat channel size
:param x_self: a list with [itself joints] of the group
:return: the processed mean value
|
Get mean value of each group from all other joints
:param x: a list with [other joints] of the group
:param cat_num: the repeat channel size
:param x_self: a list with [itself joints] of the group
:return: the processed mean value
| def _mean_func(self, x, cat_num, x_self):
"""
Get mean value of each group from all other joints
:param x: a list with [other joints] of the group
:param cat_num: the repeat channel size
:param x_self: a list with [itself joints] of the group
:return: the processed mean v... | [
"def",
"_mean_func",
"(",
"self",
",",
"x",
",",
"cat_num",
",",
"x_self",
")",
":",
"out_mean",
"=",
"[",
"]",
"for",
"i",
",",
"x_g",
"in",
"enumerate",
"(",
"x",
")",
":",
"m_mean",
"=",
"torch",
".",
"mean",
"(",
"x_g",
",",
"dim",
"=",
"1"... | [
291,
4
] | [
310,
23
] | python | en | ['en', 'error', 'th'] | False |
open_file | (
file,
mode="r",
buffering=-1,
encoding=None,
errors=None,
newline=None,
closefd=True,
opener=None,
) | Asynchronous version of :func:`io.open`.
Returns:
An :term:`asynchronous file object`
Example::
async with await trio.open_file(filename) as f:
async for line in f:
pass
assert f.closed
See also:
:func:`trio.Path.open`
| Asynchronous version of :func:`io.open`. | async def open_file(
file,
mode="r",
buffering=-1,
encoding=None,
errors=None,
newline=None,
closefd=True,
opener=None,
):
"""Asynchronous version of :func:`io.open`.
Returns:
An :term:`asynchronous file object`
Example::
async with await trio.open_file(fil... | [
"async",
"def",
"open_file",
"(",
"file",
",",
"mode",
"=",
"\"r\"",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
",",
"closefd",
"=",
"True",
",",
"opener",
"=",
"None",
",... | [
128,
0
] | [
160,
16
] | python | en | ['en', 'el-Latn', 'en'] | True |
wrap_file | (file) | This wraps any file object in a wrapper that provides an asynchronous
file object interface.
Args:
file: a :term:`file object`
Returns:
An :term:`asynchronous file object` that wraps ``file``
Example::
async_file = trio.wrap_file(StringIO('asdf'))
assert await async_... | This wraps any file object in a wrapper that provides an asynchronous
file object interface. | def wrap_file(file):
"""This wraps any file object in a wrapper that provides an asynchronous
file object interface.
Args:
file: a :term:`file object`
Returns:
An :term:`asynchronous file object` that wraps ``file``
Example::
async_file = trio.wrap_file(StringIO('asdf'))
... | [
"def",
"wrap_file",
"(",
"file",
")",
":",
"def",
"has",
"(",
"attr",
")",
":",
"return",
"hasattr",
"(",
"file",
",",
"attr",
")",
"and",
"callable",
"(",
"getattr",
"(",
"file",
",",
"attr",
")",
")",
"if",
"not",
"(",
"has",
"(",
"\"close\"",
... | [
163,
0
] | [
190,
31
] | python | en | ['en', 'en', 'en'] | True |
AsyncIOWrapper.wrapped | (self) | object: A reference to the wrapped file object | object: A reference to the wrapped file object | def wrapped(self):
"""object: A reference to the wrapped file object"""
return self._wrapped | [
"def",
"wrapped",
"(",
"self",
")",
":",
"return",
"self",
".",
"_wrapped"
] | [
64,
4
] | [
67,
28
] | python | en | ['en', 'en', 'en'] | True |
AsyncIOWrapper.detach | (self) | Like :meth:`io.BufferedIOBase.detach`, but async.
This also re-wraps the result in a new :term:`asynchronous file object`
wrapper.
| Like :meth:`io.BufferedIOBase.detach`, but async. | async def detach(self):
"""Like :meth:`io.BufferedIOBase.detach`, but async.
This also re-wraps the result in a new :term:`asynchronous file object`
wrapper.
"""
raw = await trio.to_thread.run_sync(self._wrapped.detach)
return wrap_file(raw) | [
"async",
"def",
"detach",
"(",
"self",
")",
":",
"raw",
"=",
"await",
"trio",
".",
"to_thread",
".",
"run_sync",
"(",
"self",
".",
"_wrapped",
".",
"detach",
")",
"return",
"wrap_file",
"(",
"raw",
")"
] | [
102,
4
] | [
111,
29
] | python | en | ['en', 'cy', 'en'] | True |
AsyncIOWrapper.aclose | (self) | Like :meth:`io.IOBase.close`, but async.
This is also shielded from cancellation; if a cancellation scope is
cancelled, the wrapped file object will still be safely closed.
| Like :meth:`io.IOBase.close`, but async. | async def aclose(self):
"""Like :meth:`io.IOBase.close`, but async.
This is also shielded from cancellation; if a cancellation scope is
cancelled, the wrapped file object will still be safely closed.
"""
# ensure the underling file is closed during cancellation
with tr... | [
"async",
"def",
"aclose",
"(",
"self",
")",
":",
"# ensure the underling file is closed during cancellation",
"with",
"trio",
".",
"CancelScope",
"(",
"shield",
"=",
"True",
")",
":",
"await",
"trio",
".",
"to_thread",
".",
"run_sync",
"(",
"self",
".",
"_wrappe... | [
113,
4
] | [
125,
53
] | python | en | ['en', 'hmn', 'en'] | True |
LoadModule | (name, namespace=None) | This function causes a SWIG module to be loaded into memory after its
dependencies are satisfied. Information about the templates defined therein
is looked up from a config file, and PyTemplate instances for each are
created. These template instances are placed in a module with the given
name that is ei... | This function causes a SWIG module to be loaded into memory after its
dependencies are satisfied. Information about the templates defined therein
is looked up from a config file, and PyTemplate instances for each are
created. These template instances are placed in a module with the given
name that is ei... | def LoadModule(name, namespace=None):
"""This function causes a SWIG module to be loaded into memory after its
dependencies are satisfied. Information about the templates defined therein
is looked up from a config file, and PyTemplate instances for each are
created. These template instances are placed i... | [
"def",
"LoadModule",
"(",
"name",
",",
"namespace",
"=",
"None",
")",
":",
"# find the module's name in sys.modules, or create a new module so named",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"4",
")",
":",
"this_module",
"=",
"sys",
".",
"modules",
... | [
33,
0
] | [
213,
41
] | python | en | ['en', 'en', 'en'] | True |
TextConverter.__init__ | (self, remove_numeric_tables: bool = False, valid_languages: Optional[List[str]] = None) |
:param remove_numeric_tables: This option uses heuristics to remove numeric rows from the tables.
The tabular structures in documents might be noise for the reader model if it
does not have table parsing capability for finding answers.... |
:param remove_numeric_tables: This option uses heuristics to remove numeric rows from the tables.
The tabular structures in documents might be noise for the reader model if it
does not have table parsing capability for finding answers.... | def __init__(self, remove_numeric_tables: bool = False, valid_languages: Optional[List[str]] = None):
"""
:param remove_numeric_tables: This option uses heuristics to remove numeric rows from the tables.
The tabular structures in documents might be noise for the rea... | [
"def",
"__init__",
"(",
"self",
",",
"remove_numeric_tables",
":",
"bool",
"=",
"False",
",",
"valid_languages",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"remove_numeric_tables",
... | [
10,
4
] | [
24,
102
] | python | en | ['en', 'error', 'th'] | False |
TextConverter.convert | (
self,
file_path: Path,
meta: Optional[Dict[str, str]] = None,
remove_numeric_tables: Optional[bool] = None,
valid_languages: Optional[List[str]] = None,
encoding: str = "utf-8",
) |
Reads text from a txt file and executes optional preprocessing steps.
:param file_path: path of the file to convert
:param meta: dictionary of meta data key-value pairs to append in the returned document.
:param remove_numeric_tables: This option uses heuristics to remove numeric rows ... |
Reads text from a txt file and executes optional preprocessing steps. | def convert(
self,
file_path: Path,
meta: Optional[Dict[str, str]] = None,
remove_numeric_tables: Optional[bool] = None,
valid_languages: Optional[List[str]] = None,
encoding: str = "utf-8",
) -> Dict[str, Any]:
"""
Reads text from a txt file and execu... | [
"def",
"convert",
"(",
"self",
",",
"file_path",
":",
"Path",
",",
"meta",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
"=",
"None",
",",
"remove_numeric_tables",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"valid_languages"... | [
26,
4
] | [
91,
23
] | python | en | ['en', 'error', 'th'] | False |
ColumnHistogram._sqlalchemy | (
cls,
execution_engine: SqlAlchemyExecutionEngine,
metric_domain_kwargs: Dict,
metric_value_kwargs: Dict,
metrics: Dict[Tuple, Any],
runtime_configuration: Dict,
) | return a list of counts corresponding to bins
Args:
column: the name of the column for which to get the histogram
bins: tuple of bin edges for which to get histogram values; *must* be tuple to support caching
| return a list of counts corresponding to bins | def _sqlalchemy(
cls,
execution_engine: SqlAlchemyExecutionEngine,
metric_domain_kwargs: Dict,
metric_value_kwargs: Dict,
metrics: Dict[Tuple, Any],
runtime_configuration: Dict,
):
"""return a list of counts corresponding to bins
Args:
col... | [
"def",
"_sqlalchemy",
"(",
"cls",
",",
"execution_engine",
":",
"SqlAlchemyExecutionEngine",
",",
"metric_domain_kwargs",
":",
"Dict",
",",
"metric_value_kwargs",
":",
"Dict",
",",
"metrics",
":",
"Dict",
"[",
"Tuple",
",",
"Any",
"]",
",",
"runtime_configuration"... | [
47,
4
] | [
157,
19
] | python | en | ['en', 'en', 'en'] | True |
ColumnHistogram._spark | (
cls,
execution_engine: SparkDFExecutionEngine,
metric_domain_kwargs: Dict,
metric_value_kwargs: Dict,
metrics: Dict[Tuple, Any],
runtime_configuration: Dict,
) | return a list of counts corresponding to bins | return a list of counts corresponding to bins | def _spark(
cls,
execution_engine: SparkDFExecutionEngine,
metric_domain_kwargs: Dict,
metric_value_kwargs: Dict,
metrics: Dict[Tuple, Any],
runtime_configuration: Dict,
):
df, _, accessor_domain_kwargs = execution_engine.get_compute_domain(
domain... | [
"def",
"_spark",
"(",
"cls",
",",
"execution_engine",
":",
"SparkDFExecutionEngine",
",",
"metric_domain_kwargs",
":",
"Dict",
",",
"metric_value_kwargs",
":",
"Dict",
",",
"metrics",
":",
"Dict",
"[",
"Tuple",
",",
"Any",
"]",
",",
"runtime_configuration",
":",... | [
160,
4
] | [
233,
19
] | python | en | ['en', 'en', 'en'] | True |
MetaSparkDFDataset.column_map_expectation | (cls, func) | Constructs an expectation using column-map semantics.
The MetaSparkDFDataset implementation replaces the "column" parameter supplied by the user with a Spark Dataframe
with the actual column data. The current approach for functions implementing expectation logic is to append
a column named "__... | Constructs an expectation using column-map semantics. | def column_map_expectation(cls, func):
"""Constructs an expectation using column-map semantics.
The MetaSparkDFDataset implementation replaces the "column" parameter supplied by the user with a Spark Dataframe
with the actual column data. The current approach for functions implementing expecta... | [
"def",
"column_map_expectation",
"(",
"cls",
",",
"func",
")",
":",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"[",
"0",
"]",
"[",
"1",
":",
"]",
"@",
"cls",
".",
"expectation",
"(",
"argspec",
")",
"@",
"wraps",
"(",
"func",... | [
67,
4
] | [
210,
28
] | python | en | ['en', 'lb', 'en'] | True |
MetaSparkDFDataset.column_pair_map_expectation | (cls, func) |
The column_pair_map_expectation decorator handles boilerplate issues surrounding the common pattern of evaluating
truthiness of some condition on a per row basis across a pair of columns.
|
The column_pair_map_expectation decorator handles boilerplate issues surrounding the common pattern of evaluating
truthiness of some condition on a per row basis across a pair of columns.
| def column_pair_map_expectation(cls, func):
"""
The column_pair_map_expectation decorator handles boilerplate issues surrounding the common pattern of evaluating
truthiness of some condition on a per row basis across a pair of columns.
"""
argspec = inspect.getfullargspec(func)[0... | [
"def",
"column_pair_map_expectation",
"(",
"cls",
",",
"func",
")",
":",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"[",
"0",
"]",
"[",
"1",
":",
"]",
"@",
"cls",
".",
"expectation",
"(",
"argspec",
")",
"@",
"wraps",
"(",
"f... | [
213,
4
] | [
379,
28
] | python | en | ['en', 'error', 'th'] | False |
MetaSparkDFDataset.multicolumn_map_expectation | (cls, func) |
The multicolumn_map_expectation decorator handles boilerplate issues surrounding the common pattern of
evaluating truthiness of some condition on a per row basis across a set of columns.
|
The multicolumn_map_expectation decorator handles boilerplate issues surrounding the common pattern of
evaluating truthiness of some condition on a per row basis across a set of columns.
| def multicolumn_map_expectation(cls, func):
"""
The multicolumn_map_expectation decorator handles boilerplate issues surrounding the common pattern of
evaluating truthiness of some condition on a per row basis across a set of columns.
"""
argspec = inspect.getfullargspec(func)[0]... | [
"def",
"multicolumn_map_expectation",
"(",
"cls",
",",
"func",
")",
":",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"[",
"0",
"]",
"[",
"1",
":",
"]",
"@",
"cls",
".",
"expectation",
"(",
"argspec",
")",
"@",
"wraps",
"(",
"f... | [
382,
4
] | [
524,
28
] | python | en | ['en', 'error', 'th'] | False |
SparkDFDataset.head | (self, n=5) | Returns a *PandasDataset* with the first *n* rows of the given Dataset | Returns a *PandasDataset* with the first *n* rows of the given Dataset | def head(self, n=5):
"""Returns a *PandasDataset* with the first *n* rows of the given Dataset"""
return PandasDataset(
self.spark_df.limit(n).toPandas(),
expectation_suite=self.get_expectation_suite(
discard_failed_expectations=False,
discard_resu... | [
"def",
"head",
"(",
"self",
",",
"n",
"=",
"5",
")",
":",
"return",
"PandasDataset",
"(",
"self",
".",
"spark_df",
".",
"limit",
"(",
"n",
")",
".",
"toPandas",
"(",
")",
",",
"expectation_suite",
"=",
"self",
".",
"get_expectation_suite",
"(",
"discar... | [
615,
4
] | [
625,
9
] | python | en | ['en', 'en', 'en'] | True |
SparkDFDataset.get_column_modes | (self, column) | leverages computation done in _get_column_value_counts | leverages computation done in _get_column_value_counts | def get_column_modes(self, column):
"""leverages computation done in _get_column_value_counts"""
s = self.get_column_value_counts(column)
return list(s[s == s.max()].index) | [
"def",
"get_column_modes",
"(",
"self",
",",
"column",
")",
":",
"s",
"=",
"self",
".",
"get_column_value_counts",
"(",
"column",
")",
"return",
"list",
"(",
"s",
"[",
"s",
"==",
"s",
".",
"max",
"(",
")",
"]",
".",
"index",
")"
] | [
708,
4
] | [
711,
42
] | python | en | ['en', 'en', 'en'] | True |
SparkDFDataset.get_column_hist | (self, column, bins) | return a list of counts corresponding to bins | return a list of counts corresponding to bins | def get_column_hist(self, column, bins):
"""return a list of counts corresponding to bins"""
bins = list(
copy.deepcopy(bins)
) # take a copy since we are inserting and popping
if bins[0] == -np.inf or bins[0] == -float("inf"):
added_min = False
bins[... | [
"def",
"get_column_hist",
"(",
"self",
",",
"column",
",",
"bins",
")",
":",
"bins",
"=",
"list",
"(",
"copy",
".",
"deepcopy",
"(",
"bins",
")",
")",
"# take a copy since we are inserting and popping",
"if",
"bins",
"[",
"0",
"]",
"==",
"-",
"np",
".",
... | [
745,
4
] | [
805,
19
] | python | en | ['en', 'en', 'en'] | True |
SparkDFDataset.expect_multicolumn_sum_to_equal | (
self,
column_list,
sum_total,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
) | Multi-Column Map Expectation
Expects that sum of all rows for a set of columns is equal to a specific value
Args:
column_list (List[str]): \
Set of columns to be checked
sum_total (int): \
expected sum of columns
| Multi-Column Map Expectation | def expect_multicolumn_sum_to_equal(
self,
column_list,
sum_total,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
):
""" Multi-Column Map Expectation
Expects that sum of all rows for a set of columns is equal to a s... | [
"def",
"expect_multicolumn_sum_to_equal",
"(",
"self",
",",
"column_list",
",",
"sum_total",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"True",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
",",
")",
":",
"expression",
"="... | [
1621,
4
] | [
1647,
9
] | python | en | ['es', 'en', 'en'] | True |
validates | (field_name: str) | Register a field validator.
:param str field_name: Name of the field that the method validates.
| Register a field validator. | def validates(field_name: str):
"""Register a field validator.
:param str field_name: Name of the field that the method validates.
"""
return set_hook(None, VALIDATES, field_name=field_name) | [
"def",
"validates",
"(",
"field_name",
":",
"str",
")",
":",
"return",
"set_hook",
"(",
"None",
",",
"VALIDATES",
",",
"field_name",
"=",
"field_name",
")"
] | [
70,
0
] | [
75,
59
] | python | en | ['en', 'sv', 'en'] | True |
validates_schema | (
fn=None, pass_many=False, pass_original=False, skip_on_field_errors=True
) | Register a schema-level validator.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s :func:`~marshmallow.Schema.validate` call.
If ``pass_many=True``, the raw data (which may be a collection) is passed.
If ``pass_original=True``, th... | Register a schema-level validator. | def validates_schema(
fn=None, pass_many=False, pass_original=False, skip_on_field_errors=True
):
"""Register a schema-level validator.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s :func:`~marshmallow.Schema.validate` call.
... | [
"def",
"validates_schema",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
",",
"pass_original",
"=",
"False",
",",
"skip_on_field_errors",
"=",
"True",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"VALIDATES_SCHEMA",
",",
"pass_many",
")",
... | [
78,
0
] | [
105,
5
] | python | de | ['nl', 'de', 'en'] | False |
pre_dump | (fn=None, pass_many=False) | Register a method to invoke before serializing an object. The method
receives the object to be serialized and returns the processed object.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s :func:`~marshmallow.Schema.dump` call.
If `... | Register a method to invoke before serializing an object. The method
receives the object to be serialized and returns the processed object. | def pre_dump(fn=None, pass_many=False):
"""Register a method to invoke before serializing an object. The method
receives the object to be serialized and returns the processed object.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s ... | [
"def",
"pre_dump",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"PRE_DUMP",
",",
"pass_many",
")",
")"
] | [
108,
0
] | [
119,
46
] | python | en | ['en', 'en', 'en'] | True |
post_dump | (fn=None, pass_many=False, pass_original=False) | Register a method to invoke after serializing an object. The method
receives the serialized object and returns the processed object.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s :func:`~marshmallow.Schema.dump` call.
If ``pass_m... | Register a method to invoke after serializing an object. The method
receives the serialized object and returns the processed object. | def post_dump(fn=None, pass_many=False, pass_original=False):
"""Register a method to invoke after serializing an object. The method
receives the serialized object and returns the processed object.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to ... | [
"def",
"post_dump",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
",",
"pass_original",
"=",
"False",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"POST_DUMP",
",",
"pass_many",
")",
",",
"pass_original",
"=",
"pass_original",
")"
] | [
122,
0
] | [
136,
76
] | python | en | ['en', 'en', 'en'] | True |
pre_load | (fn=None, pass_many=False) | Register a method to invoke before deserializing an object. The method
receives the data to be deserialized and returns the processed data.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s :func:`~marshmallow.Schema.load` call.
If `... | Register a method to invoke before deserializing an object. The method
receives the data to be deserialized and returns the processed data. | def pre_load(fn=None, pass_many=False):
"""Register a method to invoke before deserializing an object. The method
receives the data to be deserialized and returns the processed data.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s ... | [
"def",
"pre_load",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"PRE_LOAD",
",",
"pass_many",
")",
")"
] | [
139,
0
] | [
151,
46
] | python | en | ['en', 'en', 'en'] | True |
post_load | (fn=None, pass_many=False, pass_original=False) | Register a method to invoke after deserializing an object. The method
receives the deserialized data and returns the processed data.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to the `Schema`'s :func:`~marshmallow.Schema.load` call.
If ``pass_m... | Register a method to invoke after deserializing an object. The method
receives the deserialized data and returns the processed data. | def post_load(fn=None, pass_many=False, pass_original=False):
"""Register a method to invoke after deserializing an object. The method
receives the deserialized data and returns the processed data.
By default it receives a single object at a time, transparently handling the ``many``
argument passed to ... | [
"def",
"post_load",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
",",
"pass_original",
"=",
"False",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"POST_LOAD",
",",
"pass_many",
")",
",",
"pass_original",
"=",
"pass_original",
")"
] | [
154,
0
] | [
169,
76
] | python | en | ['en', 'en', 'en'] | True |
set_hook | (fn, key, **kwargs) | Mark decorated function as a hook to be picked up later.
You should not need to use this method directly.
.. note::
Currently only works with functions and instance methods. Class and
static methods are not supported.
:return: Decorated function if supplied, else this decorator with its ar... | Mark decorated function as a hook to be picked up later.
You should not need to use this method directly. | def set_hook(fn, key, **kwargs):
"""Mark decorated function as a hook to be picked up later.
You should not need to use this method directly.
.. note::
Currently only works with functions and instance methods. Class and
static methods are not supported.
:return: Decorated function if s... | [
"def",
"set_hook",
"(",
"fn",
",",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"# Allow using this as either a decorator or a decorator factory.",
"if",
"fn",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"set_hook",
",",
"key",
"=",
"key",
",",... | [
172,
0
] | [
197,
13
] | python | en | ['en', 'en', 'en'] | True |
_fn_matches | (fn, glob) | Return whether the supplied file name fn matches pattern filename. | Return whether the supplied file name fn matches pattern filename. | def _fn_matches(fn, glob):
"""Return whether the supplied file name fn matches pattern filename."""
if glob not in _pattern_cache:
pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob))
return pattern.match(fn)
return _pattern_cache[glob].match(fn) | [
"def",
"_fn_matches",
"(",
"fn",
",",
"glob",
")",
":",
"if",
"glob",
"not",
"in",
"_pattern_cache",
":",
"pattern",
"=",
"_pattern_cache",
"[",
"glob",
"]",
"=",
"re",
".",
"compile",
"(",
"fnmatch",
".",
"translate",
"(",
"glob",
")",
")",
"return",
... | [
28,
0
] | [
33,
41
] | python | en | ['en', 'en', 'en'] | True |
_load_formatters | (module_name) | Load a formatter (and all others in the module too). | Load a formatter (and all others in the module too). | def _load_formatters(module_name):
"""Load a formatter (and all others in the module too)."""
mod = __import__(module_name, None, None, ['__all__'])
for formatter_name in mod.__all__:
cls = getattr(mod, formatter_name)
_formatter_cache[cls.name] = cls | [
"def",
"_load_formatters",
"(",
"module_name",
")",
":",
"mod",
"=",
"__import__",
"(",
"module_name",
",",
"None",
",",
"None",
",",
"[",
"'__all__'",
"]",
")",
"for",
"formatter_name",
"in",
"mod",
".",
"__all__",
":",
"cls",
"=",
"getattr",
"(",
"mod"... | [
36,
0
] | [
41,
40
] | python | en | ['en', 'en', 'en'] | True |
get_all_formatters | () | Return a generator for all formatter classes. | Return a generator for all formatter classes. | def get_all_formatters():
"""Return a generator for all formatter classes."""
# NB: this returns formatter classes, not info like get_all_lexers().
for info in itervalues(FORMATTERS):
if info[1] not in _formatter_cache:
_load_formatters(info[0])
yield _formatter_cache[info[1]]
... | [
"def",
"get_all_formatters",
"(",
")",
":",
"# NB: this returns formatter classes, not info like get_all_lexers().",
"for",
"info",
"in",
"itervalues",
"(",
"FORMATTERS",
")",
":",
"if",
"info",
"[",
"1",
"]",
"not",
"in",
"_formatter_cache",
":",
"_load_formatters",
... | [
44,
0
] | [
52,
23
] | python | en | ['en', 'en', 'en'] | True |
find_formatter_class | (alias) | Lookup a formatter by alias.
Returns None if not found.
| Lookup a formatter by alias. | def find_formatter_class(alias):
"""Lookup a formatter by alias.
Returns None if not found.
"""
for module_name, name, aliases, _, _ in itervalues(FORMATTERS):
if alias in aliases:
if name not in _formatter_cache:
_load_formatters(module_name)
return _for... | [
"def",
"find_formatter_class",
"(",
"alias",
")",
":",
"for",
"module_name",
",",
"name",
",",
"aliases",
",",
"_",
",",
"_",
"in",
"itervalues",
"(",
"FORMATTERS",
")",
":",
"if",
"alias",
"in",
"aliases",
":",
"if",
"name",
"not",
"in",
"_formatter_cac... | [
55,
0
] | [
67,
22
] | python | en | ['en', 'en', 'en'] | True |
get_formatter_by_name | (_alias, **options) | Lookup and instantiate a formatter by alias.
Raises ClassNotFound if not found.
| Lookup and instantiate a formatter by alias. | def get_formatter_by_name(_alias, **options):
"""Lookup and instantiate a formatter by alias.
Raises ClassNotFound if not found.
"""
cls = find_formatter_class(_alias)
if cls is None:
raise ClassNotFound("no formatter found for name %r" % _alias)
return cls(**options) | [
"def",
"get_formatter_by_name",
"(",
"_alias",
",",
"*",
"*",
"options",
")",
":",
"cls",
"=",
"find_formatter_class",
"(",
"_alias",
")",
"if",
"cls",
"is",
"None",
":",
"raise",
"ClassNotFound",
"(",
"\"no formatter found for name %r\"",
"%",
"_alias",
")",
... | [
70,
0
] | [
78,
25
] | python | en | ['en', 'en', 'en'] | True |
get_formatter_for_filename | (fn, **options) | Lookup and instantiate a formatter by filename pattern.
Raises ClassNotFound if not found.
| Lookup and instantiate a formatter by filename pattern. | def get_formatter_for_filename(fn, **options):
"""Lookup and instantiate a formatter by filename pattern.
Raises ClassNotFound if not found.
"""
fn = basename(fn)
for modname, name, _, filenames, _ in itervalues(FORMATTERS):
for filename in filenames:
if _fn_matches(fn, filename... | [
"def",
"get_formatter_for_filename",
"(",
"fn",
",",
"*",
"*",
"options",
")",
":",
"fn",
"=",
"basename",
"(",
"fn",
")",
"for",
"modname",
",",
"name",
",",
"_",
",",
"filenames",
",",
"_",
"in",
"itervalues",
"(",
"FORMATTERS",
")",
":",
"for",
"f... | [
81,
0
] | [
97,
67
] | python | en | ['en', 'en', 'en'] | True |
logloss | (y, p) | Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error
| Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error
| def logloss(y, p):
"""Bounded log loss error.
Args:
y (numpy.array): target
p (numpy.array): prediction
Returns:
bounded log loss error
"""
p[p < EPS] = EPS
p[p > 1 - EPS] = 1 - EPS
return log_loss(y, p) | [
"def",
"logloss",
"(",
"y",
",",
"p",
")",
":",
"p",
"[",
"p",
"<",
"EPS",
"]",
"=",
"EPS",
"p",
"[",
"p",
">",
"1",
"-",
"EPS",
"]",
"=",
"1",
"-",
"EPS",
"return",
"log_loss",
"(",
"y",
",",
"p",
")"
] | [
10,
0
] | [
21,
25
] | python | en | ['en', 'no', 'en'] | True |
classification_metrics | (y, p, w=None, metrics={'AUC': roc_auc_score, 'Log Loss': logloss}) | Log metrics for classifiers.
Args:
y (numpy.array): target
p (numpy.array): prediction
w (numpy.array, optional): a treatment vector (1 or True: treatment, 0 or False: control). If given, log
metrics for the treatment and control group separately
metrics (dict, optional)... | Log metrics for classifiers. | def classification_metrics(y, p, w=None, metrics={'AUC': roc_auc_score, 'Log Loss': logloss}):
"""Log metrics for classifiers.
Args:
y (numpy.array): target
p (numpy.array): prediction
w (numpy.array, optional): a treatment vector (1 or True: treatment, 0 or False: control). If given, l... | [
"def",
"classification_metrics",
"(",
"y",
",",
"p",
",",
"w",
"=",
"None",
",",
"metrics",
"=",
"{",
"'AUC'",
":",
"roc_auc_score",
",",
"'Log Loss'",
":",
"logloss",
"}",
")",
":",
"regression_metrics",
"(",
"y",
"=",
"y",
",",
"p",
"=",
"p",
",",
... | [
24,
0
] | [
34,
54
] | python | bg | ['no', 'bg', 'en'] | False |
XvncDisplay.__init__ | (self, size=(1024, 768), color_depth=24,
bgcolor='black', rfbport=5900) |
:param bgcolor: 'black' or 'white'
:param rfbport: Specifies the TCP port on which Xvnc listens for
connections from viewers (the protocol used in VNC is called
RFB - "remote framebuffer").
The default is 5900 plus the display number.
|
:param bgcolor: 'black' or 'white'
:param rfbport: Specifies the TCP port on which Xvnc listens for
connections from viewers (the protocol used in VNC is called
RFB - "remote framebuffer").
The default is 5900 plus the display number.
| def __init__(self, size=(1024, 768), color_depth=24,
bgcolor='black', rfbport=5900):
'''
:param bgcolor: 'black' or 'white'
:param rfbport: Specifies the TCP port on which Xvnc listens for
connections from viewers (the protocol used in VNC is called
RFB - "remo... | [
"def",
"__init__",
"(",
"self",
",",
"size",
"=",
"(",
"1024",
",",
"768",
")",
",",
"color_depth",
"=",
"24",
",",
"bgcolor",
"=",
"'black'",
",",
"rfbport",
"=",
"5900",
")",
":",
"self",
".",
"screen",
"=",
"0",
"self",
".",
"size",
"=",
"size... | [
10,
4
] | [
26,
38
] | python | en | ['en', 'error', 'th'] | False |
get_treatment_costs | (treatment, control_name, cc_dict, ic_dict) |
Set the conversion and impression costs based on a dict of parameters.
Calculate the actual cost of targeting a user with the actual treatment
group using the above parameters.
Params
------
treatment : array, shape = (num_samples, )
Treatment array.
control_name, str
Con... |
Set the conversion and impression costs based on a dict of parameters. | def get_treatment_costs(treatment, control_name, cc_dict, ic_dict):
'''
Set the conversion and impression costs based on a dict of parameters.
Calculate the actual cost of targeting a user with the actual treatment
group using the above parameters.
Params
------
treatment : array, shape = ... | [
"def",
"get_treatment_costs",
"(",
"treatment",
",",
"control_name",
",",
"cc_dict",
",",
"ic_dict",
")",
":",
"# Set the conversion costs of the treatments",
"conversion_cost",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"treatment",
")",
",",
"len",
"(",
"c... | [
3,
0
] | [
52,
62
] | python | en | ['en', 'error', 'th'] | False |
get_actual_value | (treatment, observed_outcome, conversion_value,
conditions, conversion_cost, impression_cost) |
Set the conversion and impression costs based on a dict of parameters.
Calculate the actual value of targeting a user with the actual treatment group
using the above parameters.
Params
------
treatment : array, shape = (num_samples, )
Treatment array.
observed_outcome : array, sh... |
Set the conversion and impression costs based on a dict of parameters. | def get_actual_value(treatment, observed_outcome, conversion_value,
conditions, conversion_cost, impression_cost):
'''
Set the conversion and impression costs based on a dict of parameters.
Calculate the actual value of targeting a user with the actual treatment group
using the abo... | [
"def",
"get_actual_value",
"(",
"treatment",
",",
"observed_outcome",
",",
"conversion_value",
",",
"conditions",
",",
"conversion_cost",
",",
"impression_cost",
")",
":",
"cost_filter",
"=",
"[",
"actual_group",
"==",
"possible_group",
"for",
"actual_group",
"in",
... | [
55,
0
] | [
105,
23
] | python | en | ['en', 'error', 'th'] | False |
get_uplift_best | (cate, conditions) |
Takes the CATE prediction from a learner, adds the control
outcome array and finds the name of the argmax conditon.
Params
------
cate : array, shape = (num_samples, )
The conditional average treatment effect prediction.
conditions : list, len = len(set(treatment))
Returns
--... |
Takes the CATE prediction from a learner, adds the control
outcome array and finds the name of the argmax conditon. | def get_uplift_best(cate, conditions):
'''
Takes the CATE prediction from a learner, adds the control
outcome array and finds the name of the argmax conditon.
Params
------
cate : array, shape = (num_samples, )
The conditional average treatment effect prediction.
conditions : list,... | [
"def",
"get_uplift_best",
"(",
"cate",
",",
"conditions",
")",
":",
"cate_with_control",
"=",
"np",
".",
"c_",
"[",
"np",
".",
"zeros",
"(",
"cate",
".",
"shape",
"[",
"0",
"]",
")",
",",
"cate",
"]",
"uplift_best_idx",
"=",
"np",
".",
"argmax",
"(",... | [
108,
0
] | [
129,
27
] | python | en | ['en', 'error', 'th'] | False |
assert_dict_key_and_val_in_stdout | (dict_, stdout) | Use when stdout contains color info and command chars | Use when stdout contains color info and command chars | def assert_dict_key_and_val_in_stdout(dict_, stdout):
"""Use when stdout contains color info and command chars"""
for key, val in dict_.items():
if isinstance(val, dict):
assert key in stdout
assert_dict_key_and_val_in_stdout(val, stdout)
else:
assert key in s... | [
"def",
"assert_dict_key_and_val_in_stdout",
"(",
"dict_",
",",
"stdout",
")",
":",
"for",
"key",
",",
"val",
"in",
"dict_",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"assert",
"key",
"in",
"stdout",
"assert_dict_... | [
12,
0
] | [
20,
37
] | python | en | ['en', 'en', 'en'] | True |
assert_no_logging_messages_or_tracebacks | (
my_caplog, click_result, allowed_deprecation_message=None
) |
Use this assertion in all CLI tests unless you have a very good reason.
Without this assertion, it is easy to let errors and tracebacks bubble up
to users without being detected, unless you are manually inspecting the
console output (stderr and stdout), as well as logging output from every
test.
... |
Use this assertion in all CLI tests unless you have a very good reason. | def assert_no_logging_messages_or_tracebacks(
my_caplog, click_result, allowed_deprecation_message=None
):
"""
Use this assertion in all CLI tests unless you have a very good reason.
Without this assertion, it is easy to let errors and tracebacks bubble up
to users without being detected, unless yo... | [
"def",
"assert_no_logging_messages_or_tracebacks",
"(",
"my_caplog",
",",
"click_result",
",",
"allowed_deprecation_message",
"=",
"None",
")",
":",
"if",
"allowed_deprecation_message",
":",
"assert_logging_message_present",
"(",
"my_caplog",
"=",
"my_caplog",
",",
"message... | [
23,
0
] | [
54,
38
] | python | en | ['en', 'error', 'th'] | False |
assert_logging_message_present | (my_caplog, message) |
Assert presence of message in logging output messages.
:param my_caplog: the caplog pytest fixutre
:param message: message to be searched in caplog
|
Assert presence of message in logging output messages. | def assert_logging_message_present(my_caplog, message):
"""
Assert presence of message in logging output messages.
:param my_caplog: the caplog pytest fixutre
:param message: message to be searched in caplog
"""
assert isinstance(
my_caplog, LogCaptureFixture
), "Please pass in the ... | [
"def",
"assert_logging_message_present",
"(",
"my_caplog",
",",
"message",
")",
":",
"assert",
"isinstance",
"(",
"my_caplog",
",",
"LogCaptureFixture",
")",
",",
"\"Please pass in the caplog object from your test.\"",
"messages",
"=",
"my_caplog",
".",
"messages",
"asser... | [
57,
0
] | [
72,
60
] | python | en | ['en', 'error', 'th'] | False |
assert_no_logging_messages | (my_caplog) |
Assert no logging output messages.
:param my_caplog: the caplog pytest fixutre
|
Assert no logging output messages. | def assert_no_logging_messages(my_caplog):
"""
Assert no logging output messages.
:param my_caplog: the caplog pytest fixutre
"""
assert isinstance(
my_caplog, LogCaptureFixture
), "Please pass in the caplog object from your test."
messages = my_caplog.messages
assert isinstance... | [
"def",
"assert_no_logging_messages",
"(",
"my_caplog",
")",
":",
"assert",
"isinstance",
"(",
"my_caplog",
",",
"LogCaptureFixture",
")",
",",
"\"Please pass in the caplog object from your test.\"",
"messages",
"=",
"my_caplog",
".",
"messages",
"assert",
"isinstance",
"(... | [
75,
0
] | [
89,
23
] | python | en | ['en', 'error', 'th'] | False |
assert_no_tracebacks | (click_result) |
Assert no tracebacks.
:param click_result: the Result object returned from click runner.invoke()
|
Assert no tracebacks. | def assert_no_tracebacks(click_result):
"""
Assert no tracebacks.
:param click_result: the Result object returned from click runner.invoke()
"""
assert isinstance(
click_result, Result
), "Please pass in the click runner invoke result object from your test."
if click_result.exc_inf... | [
"def",
"assert_no_tracebacks",
"(",
"click_result",
")",
":",
"assert",
"isinstance",
"(",
"click_result",
",",
"Result",
")",
",",
"\"Please pass in the click runner invoke result object from your test.\"",
"if",
"click_result",
".",
"exc_info",
":",
"# introspect the call s... | [
92,
0
] | [
129,
12
] | python | en | ['en', 'error', 'th'] | False |
BatchDefinition.__hash__ | (self) | Overrides the default implementation | Overrides the default implementation | def __hash__(self) -> int:
"""Overrides the default implementation"""
_result_hash: int = (
hash(self.datasource_name)
^ hash(self.data_connector_name)
^ hash(self.data_asset_name)
)
if self.batch_identifiers is not None:
for key, value in ... | [
"def",
"__hash__",
"(",
"self",
")",
"->",
"int",
":",
"_result_hash",
":",
"int",
"=",
"(",
"hash",
"(",
"self",
".",
"datasource_name",
")",
"^",
"hash",
"(",
"self",
".",
"data_connector_name",
")",
"^",
"hash",
"(",
"self",
".",
"data_asset_name",
... | [
146,
4
] | [
156,
27
] | python | en | ['en', 'fr', 'en'] | True |
MilvusDocumentStore.__init__ | (
self,
sql_url: str = "sqlite:///",
milvus_url: str = "tcp://localhost:19530",
connection_pool: str = "SingletonThread",
index: str = "document",
vector_dim: int = 768,
index_file_size: int = 1024,
similarity: str = "dot_pr... |
:param sql_url: SQL connection URL for storing document texts and metadata. It defaults to a local, file based SQLite DB. For large scale
deployment, Postgres is recommended. If using MySQL then same server can also be used for
Milvus metadata. For more details s... |
:param sql_url: SQL connection URL for storing document texts and metadata. It defaults to a local, file based SQLite DB. For large scale
deployment, Postgres is recommended. If using MySQL then same server can also be used for
Milvus metadata. For more details s... | def __init__(
self,
sql_url: str = "sqlite:///",
milvus_url: str = "tcp://localhost:19530",
connection_pool: str = "SingletonThread",
index: str = "document",
vector_dim: int = 768,
index_file_size: int = 1024,
similarity: s... | [
"def",
"__init__",
"(",
"self",
",",
"sql_url",
":",
"str",
"=",
"\"sqlite:///\"",
",",
"milvus_url",
":",
"str",
"=",
"\"tcp://localhost:19530\"",
",",
"connection_pool",
":",
"str",
"=",
"\"SingletonThread\"",
",",
"index",
":",
"str",
"=",
"\"document\"",
"... | [
36,
4
] | [
119,
9
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.write_documents | (
self, documents: Union[List[dict], List[Document]], index: Optional[str] = None, batch_size: int = 10_000
) |
Add new documents to the DocumentStore.
:param documents: List of `Dicts` or List of `Documents`. If they already contain the embeddings, we'll index
them right away in Milvus. If not, you can later call update_embeddings() to create & index them.
:param index... |
Add new documents to the DocumentStore. | def write_documents(
self, documents: Union[List[dict], List[Document]], index: Optional[str] = None, batch_size: int = 10_000
):
"""
Add new documents to the DocumentStore.
:param documents: List of `Dicts` or List of `Documents`. If they already contain the embeddings, we'll i... | [
"def",
"write_documents",
"(",
"self",
",",
"documents",
":",
"Union",
"[",
"List",
"[",
"dict",
"]",
",",
"List",
"[",
"Document",
"]",
"]",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"batch_size",
":",
"int",
"=",
"10_000",
... | [
154,
4
] | [
216,
61
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.update_embeddings | (
self,
retriever: BaseRetriever,
index: Optional[str] = None,
batch_size: int = 10_000,
update_existing_embeddings: bool = True,
filters: Optional[Dict[str, List[str]]] = None,
) |
Updates the embeddings in the the document store using the encoding model specified in the retriever.
This can be useful if want to add or change the embeddings for your documents (e.g. after changing the retriever config).
:param retriever: Retriever to use to get embeddings for text
... |
Updates the embeddings in the the document store using the encoding model specified in the retriever.
This can be useful if want to add or change the embeddings for your documents (e.g. after changing the retriever config). | def update_embeddings(
self,
retriever: BaseRetriever,
index: Optional[str] = None,
batch_size: int = 10_000,
update_existing_embeddings: bool = True,
filters: Optional[Dict[str, List[str]]] = None,
):
"""
Updates the embeddings in the the document sto... | [
"def",
"update_embeddings",
"(",
"self",
",",
"retriever",
":",
"BaseRetriever",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"batch_size",
":",
"int",
"=",
"10_000",
",",
"update_existing_embeddings",
":",
"bool",
"=",
"True",
",",
"f... | [
218,
4
] | [
280,
57
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.query_by_embedding | (self,
query_emb: np.ndarray,
filters: Optional[dict] = None,
top_k: int = 10,
index: Optional[str] = None,
return_embedding: Optional[bool] = None) |
Find the document that is most similar to the provided `query_emb` by using a vector similarity metric.
:param query_emb: Embedding of the query (e.g. gathered from DPR)
:param filters: Optional filters to narrow down the search space.
Example: {"name": ["some", "more"]... |
Find the document that is most similar to the provided `query_emb` by using a vector similarity metric. | def query_by_embedding(self,
query_emb: np.ndarray,
filters: Optional[dict] = None,
top_k: int = 10,
index: Optional[str] = None,
return_embedding: Optional[bool] = None) -> List[Docume... | [
"def",
"query_by_embedding",
"(",
"self",
",",
"query_emb",
":",
"np",
".",
"ndarray",
",",
"filters",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
",",
"top_k",
":",
"int",
"=",
"10",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
... | [
282,
4
] | [
339,
24
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.delete_all_documents | (self, index: Optional[str] = None, filters: Optional[Dict[str, List[str]]] = None) |
Delete all documents (from SQL AND Milvus).
:param index: (SQL) index name for storing the docs and metadata
:param filters: Optional filters to narrow down the search space.
Example: {"name": ["some", "more"], "category": ["only_one"]}
:return: None
|
Delete all documents (from SQL AND Milvus).
:param index: (SQL) index name for storing the docs and metadata
:param filters: Optional filters to narrow down the search space.
Example: {"name": ["some", "more"], "category": ["only_one"]}
:return: None
| def delete_all_documents(self, index: Optional[str] = None, filters: Optional[Dict[str, List[str]]] = None):
"""
Delete all documents (from SQL AND Milvus).
:param index: (SQL) index name for storing the docs and metadata
:param filters: Optional filters to narrow down the search space.
... | [
"def",
"delete_all_documents",
"(",
"self",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"filters",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
"]",
"=",
"None",
")",
":",
"index",
"=",
"index",... | [
341,
4
] | [
360,
61
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.get_all_documents_generator | (
self,
index: Optional[str] = None,
filters: Optional[Dict[str, List[str]]] = None,
return_embedding: Optional[bool] = None,
batch_size: int = 10_000,
) |
Get all documents from the document store. Under-the-hood, documents are fetched in batches from the
document store and yielded as individual documents. This method can be used to iteratively process
a large number of documents without having to load all documents in memory.
:param ind... |
Get all documents from the document store. Under-the-hood, documents are fetched in batches from the
document store and yielded as individual documents. This method can be used to iteratively process
a large number of documents without having to load all documents in memory. | def get_all_documents_generator(
self,
index: Optional[str] = None,
filters: Optional[Dict[str, List[str]]] = None,
return_embedding: Optional[bool] = None,
batch_size: int = 10_000,
) -> Generator[Document, None, None]:
"""
Get all documents from the document... | [
"def",
"get_all_documents_generator",
"(",
"self",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"filters",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
"]",
"=",
"None",
",",
"return_embedding",
":",... | [
362,
4
] | [
391,
21
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.get_all_documents | (
self,
index: Optional[str] = None,
filters: Optional[Dict[str, List[str]]] = None,
return_embedding: Optional[bool] = None,
batch_size: int = 10_000,
) |
Get documents from the document store (optionally using filter criteria).
:param index: Name of the index to get the documents from. If None, the
DocumentStore's default index (self.index) will be used.
:param filters: Optional filters to narrow down the documents to retu... |
Get documents from the document store (optionally using filter criteria). | def get_all_documents(
self,
index: Optional[str] = None,
filters: Optional[Dict[str, List[str]]] = None,
return_embedding: Optional[bool] = None,
batch_size: int = 10_000,
) -> List[Document]:
"""
Get documents from the document store (opt... | [
"def",
"get_all_documents",
"(",
"self",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"filters",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
"]",
"=",
"None",
",",
"return_embedding",
":",
"Option... | [
393,
4
] | [
416,
24
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.get_document_by_id | (self, id: str, index: Optional[str] = None) |
Fetch a document by specifying its text id string
:param id: ID of the document
:param index: Name of the index to get the documents from. If None, the
DocumentStore's default index (self.index) will be used.
|
Fetch a document by specifying its text id string | def get_document_by_id(self, id: str, index: Optional[str] = None) -> Optional[Document]:
"""
Fetch a document by specifying its text id string
:param id: ID of the document
:param index: Name of the index to get the documents from. If None, the
DocumentStore's def... | [
"def",
"get_document_by_id",
"(",
"self",
",",
"id",
":",
"str",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"Document",
"]",
":",
"documents",
"=",
"self",
".",
"get_documents_by_id",
"(",
"[",
"id",
"]",
... | [
418,
4
] | [
428,
23
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.get_documents_by_id | (
self, ids: List[str], index: Optional[str] = None, batch_size: int = 10_000
) |
Fetch multiple documents by specifying their IDs (strings)
:param ids: List of IDs of the documents
:param index: Name of the index to get the documents from. If None, the
DocumentStore's default index (self.index) will be used.
:param batch_size: When working wit... |
Fetch multiple documents by specifying their IDs (strings) | def get_documents_by_id(
self, ids: List[str], index: Optional[str] = None, batch_size: int = 10_000
) -> List[Document]:
"""
Fetch multiple documents by specifying their IDs (strings)
:param ids: List of IDs of the documents
:param index: Name of the index to get the do... | [
"def",
"get_documents_by_id",
"(",
"self",
",",
"ids",
":",
"List",
"[",
"str",
"]",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"batch_size",
":",
"int",
"=",
"10_000",
")",
"->",
"List",
"[",
"Document",
"]",
":",
"index",
"... | [
430,
4
] | [
446,
24
] | python | en | ['en', 'error', 'th'] | False |
MilvusDocumentStore.get_all_vectors | (self, index: Optional[str] = None) |
Helper function to dump all vectors stored in Milvus server.
:param index: Name of the index to get the documents from. If None, the
DocumentStore's default index (self.index) will be used.
:return: List[np.array]: List of vectors.
|
Helper function to dump all vectors stored in Milvus server. | def get_all_vectors(self, index: Optional[str] = None) -> List[np.ndarray]:
"""
Helper function to dump all vectors stored in Milvus server.
:param index: Name of the index to get the documents from. If None, the
DocumentStore's default index (self.index) will be used.
... | [
"def",
"get_all_vectors",
"(",
"self",
",",
"index",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"index",
"=",
"index",
"or",
"self",
".",
"index",
"status",
",",
"collection_info",
"=",
"sel... | [
483,
4
] | [
520,
22
] | python | en | ['en', 'error', 'th'] | False |
ExpectationValidationResult.__eq__ | (self, other) | ExpectationValidationResult equality ignores instance identity, relying only on properties. | ExpectationValidationResult equality ignores instance identity, relying only on properties. | def __eq__(self, other):
"""ExpectationValidationResult equality ignores instance identity, relying only on properties."""
# NOTE: JPC - 20200213 - need to spend some time thinking about whether we want to
# consistently allow dict as a comparison alternative in situations like these...
... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"# NOTE: JPC - 20200213 - need to spend some time thinking about whether we want to",
"# consistently allow dict as a comparison alternative in situations like these...",
"# if isinstance(other, dict):",
"# try:",
"# other = E... | [
66,
4
] | [
103,
24
] | python | en | ['en', 'en', 'en'] | True |
ExpectationSuiteValidationResult.__eq__ | (self, other) | ExpectationSuiteValidationResult equality ignores instance identity, relying only on properties. | ExpectationSuiteValidationResult equality ignores instance identity, relying only on properties. | def __eq__(self, other):
"""ExpectationSuiteValidationResult equality ignores instance identity, relying only on properties."""
if not isinstance(other, self.__class__):
# Delegate comparison to the other instance's __eq__.
return NotImplemented
return all(
(
... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"# Delegate comparison to the other instance's __eq__.",
"return",
"NotImplemented",
"return",
"all",
"(",
"(",
"self",
".",
... | [
285,
4
] | [
298,
9
] | python | en | ['en', 'en', 'en'] | True |
image_upload_url | (recipe_id) | Return url for recipe image upload | Return url for recipe image upload | def image_upload_url(recipe_id):
"""Return url for recipe image upload"""
return reverse('recipe:recipe-upload-image', args=[recipe_id]) | [
"def",
"image_upload_url",
"(",
"recipe_id",
")",
":",
"return",
"reverse",
"(",
"'recipe:recipe-upload-image'",
",",
"args",
"=",
"[",
"recipe_id",
"]",
")"
] | [
20,
0
] | [
22,
66
] | python | en | ['en', 'da', 'en'] | True |
detail_url | (recipe_id) | Return recipe detail url | Return recipe detail url | def detail_url(recipe_id):
"""Return recipe detail url"""
return reverse('recipe:recipe-detail', args=[recipe_id]) | [
"def",
"detail_url",
"(",
"recipe_id",
")",
":",
"return",
"reverse",
"(",
"'recipe:recipe-detail'",
",",
"args",
"=",
"[",
"recipe_id",
"]",
")"
] | [
25,
0
] | [
27,
60
] | python | co | ['it', 'co', 'en'] | False |
sample_tag | (user, name='Main course') | Create and return a sample tag | Create and return a sample tag | def sample_tag(user, name='Main course'):
"""Create and return a sample tag"""
return Tag.objects.create(user=user, name=name) | [
"def",
"sample_tag",
"(",
"user",
",",
"name",
"=",
"'Main course'",
")",
":",
"return",
"Tag",
".",
"objects",
".",
"create",
"(",
"user",
"=",
"user",
",",
"name",
"=",
"name",
")"
] | [
30,
0
] | [
32,
51
] | python | en | ['en', 'sm', 'en'] | True |
sample_ingredient | (user, name='Cinnamon') | Create and return a sample ingredient | Create and return a sample ingredient | def sample_ingredient(user, name='Cinnamon'):
"""Create and return a sample ingredient"""
return Ingredient.objects.create(user=user, name=name) | [
"def",
"sample_ingredient",
"(",
"user",
",",
"name",
"=",
"'Cinnamon'",
")",
":",
"return",
"Ingredient",
".",
"objects",
".",
"create",
"(",
"user",
"=",
"user",
",",
"name",
"=",
"name",
")"
] | [
35,
0
] | [
37,
58
] | python | en | ['en', 'en', 'en'] | True |
sample_recipe | (user, **params) | Create and return a sample recipe | Create and return a sample recipe | def sample_recipe(user, **params):
"""Create and return a sample recipe"""
defaults = {
'title': 'Sample recipe',
'time_minutes': 10,
'price': 5.00
}
defaults.update(params)
return Recipe.objects.create(user=user, **defaults) | [
"def",
"sample_recipe",
"(",
"user",
",",
"*",
"*",
"params",
")",
":",
"defaults",
"=",
"{",
"'title'",
":",
"'Sample recipe'",
",",
"'time_minutes'",
":",
"10",
",",
"'price'",
":",
"5.00",
"}",
"defaults",
".",
"update",
"(",
"params",
")",
"return",
... | [
40,
0
] | [
49,
55
] | python | en | ['en', 'co', 'en'] | True |
PublicRecipeApiTests.test_auth_required | (self) | Test that authentication is required | Test that authentication is required | def test_auth_required(self):
"""Test that authentication is required"""
res = self.client.get(RECIPES_URL)
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED) | [
"def",
"test_auth_required",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"client",
".",
"get",
"(",
"RECIPES_URL",
")",
"self",
".",
"assertEqual",
"(",
"res",
".",
"status_code",
",",
"status",
".",
"HTTP_401_UNAUTHORIZED",
")"
] | [
58,
4
] | [
62,
71
] | python | en | ['en', 'en', 'en'] | True |
PrivateRecipeApiTests.test_retrieve_recipes | (self) | Test retrieving a list of recipes | Test retrieving a list of recipes | def test_retrieve_recipes(self):
"""Test retrieving a list of recipes"""
sample_recipe(user=self.user)
sample_recipe(user=self.user)
res = self.client.get(RECIPES_URL)
recipes = Recipe.objects.all().order_by('-id')
serializer = RecipeSerializer(recipes, many=True)
... | [
"def",
"test_retrieve_recipes",
"(",
"self",
")",
":",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
")",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
")",
"res",
"=",
"self",
".",
"client",
".",
"get",
"(",
"RECIPES_URL",
")",
"re... | [
76,
4
] | [
86,
51
] | python | en | ['en', 'pt', 'en'] | True |
PrivateRecipeApiTests.test_recipes_limited_to_user | (self) | Test retrieving recipes for user | Test retrieving recipes for user | def test_recipes_limited_to_user(self):
"""Test retrieving recipes for user"""
user2 = get_user_model().objects.create_user(
'test2@testmail.com',
'testpass'
)
sample_recipe(user=user2)
sample_recipe(user=self.user)
res = self.client.get(RECIPES_U... | [
"def",
"test_recipes_limited_to_user",
"(",
"self",
")",
":",
"user2",
"=",
"get_user_model",
"(",
")",
".",
"objects",
".",
"create_user",
"(",
"'test2@testmail.com'",
",",
"'testpass'",
")",
"sample_recipe",
"(",
"user",
"=",
"user2",
")",
"sample_recipe",
"("... | [
88,
4
] | [
103,
51
] | python | en | ['en', 'pt', 'en'] | True |
PrivateRecipeApiTests.test_view_recipe_detail | (self) | Test viewing a recipe detail | Test viewing a recipe detail | def test_view_recipe_detail(self):
"""Test viewing a recipe detail"""
recipe = sample_recipe(user=self.user)
recipe.tags.add(sample_tag(user=self.user))
recipe.ingredients.add(sample_ingredient(user=self.user))
url = detail_url(recipe.id)
res = self.client.get(url)
... | [
"def",
"test_view_recipe_detail",
"(",
"self",
")",
":",
"recipe",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
")",
"recipe",
".",
"tags",
".",
"add",
"(",
"sample_tag",
"(",
"user",
"=",
"self",
".",
"user",
")",
")",
"recipe",
".",
... | [
105,
4
] | [
115,
51
] | python | en | ['en', 'en', 'en'] | True |
PrivateRecipeApiTests.test_create_basic_recipe | (self) | Test creating recipe | Test creating recipe | def test_create_basic_recipe(self):
"""Test creating recipe"""
payload = {
'title': 'Chocolate cheesecake',
'time_minutes': 30,
'price': 5.00
}
res = self.client.post(RECIPES_URL, payload)
self.assertEqual(res.status_code, status.HTTP_201_CREA... | [
"def",
"test_create_basic_recipe",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"'title'",
":",
"'Chocolate cheesecake'",
",",
"'time_minutes'",
":",
"30",
",",
"'price'",
":",
"5.00",
"}",
"res",
"=",
"self",
".",
"client",
".",
"post",
"(",
"RECIPES_URL",
... | [
117,
4
] | [
129,
64
] | python | en | ['en', 'la', 'en'] | True |
PrivateRecipeApiTests.test_create_recipe_with_tags | (self) | Test creating a recipe with tags | Test creating a recipe with tags | def test_create_recipe_with_tags(self):
"""Test creating a recipe with tags"""
tag1 = sample_tag(user=self.user, name='Vegan')
tag2 = sample_tag(user=self.user, name='Dessert')
payload = {
'title': 'Lime cheesecake',
'tags': [tag1.id, tag2.id],
'time_m... | [
"def",
"test_create_recipe_with_tags",
"(",
"self",
")",
":",
"tag1",
"=",
"sample_tag",
"(",
"user",
"=",
"self",
".",
"user",
",",
"name",
"=",
"'Vegan'",
")",
"tag2",
"=",
"sample_tag",
"(",
"user",
"=",
"self",
".",
"user",
",",
"name",
"=",
"'Dess... | [
131,
4
] | [
148,
33
] | python | en | ['en', 'en', 'en'] | True |
PrivateRecipeApiTests.test_create_recipe_with_ingredients | (self) | Test creating a recipe with ingredients | Test creating a recipe with ingredients | def test_create_recipe_with_ingredients(self):
"""Test creating a recipe with ingredients"""
ingredients1 = sample_ingredient(user=self.user, name='Ginger')
ingredients2 = sample_ingredient(user=self.user, name='Prawns')
payload = {
'title': 'Thai prawn red curry',
... | [
"def",
"test_create_recipe_with_ingredients",
"(",
"self",
")",
":",
"ingredients1",
"=",
"sample_ingredient",
"(",
"user",
"=",
"self",
".",
"user",
",",
"name",
"=",
"'Ginger'",
")",
"ingredients2",
"=",
"sample_ingredient",
"(",
"user",
"=",
"self",
".",
"u... | [
150,
4
] | [
167,
48
] | python | en | ['en', 'en', 'en'] | True |
PrivateRecipeApiTests.test_partial_update_recipe | (self) | Test updating a recipe with PATCH | Test updating a recipe with PATCH | def test_partial_update_recipe(self):
"""Test updating a recipe with PATCH"""
recipe = sample_recipe(user=self.user)
recipe.tags.add(sample_tag(user=self.user))
new_tag = sample_tag(user=self.user, name='Curry')
payload = {
'title': 'Chicken tikka',
'tags... | [
"def",
"test_partial_update_recipe",
"(",
"self",
")",
":",
"recipe",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
")",
"recipe",
".",
"tags",
".",
"add",
"(",
"sample_tag",
"(",
"user",
"=",
"self",
".",
"user",
")",
")",
"new_tag",
"=... | [
169,
4
] | [
186,
36
] | python | en | ['en', 'en', 'en'] | True |
PrivateRecipeApiTests.test_full_update_recipe | (self) | Test updating a recipe with PUT | Test updating a recipe with PUT | def test_full_update_recipe(self):
"""Test updating a recipe with PUT"""
recipe = sample_recipe(user=self.user)
recipe.tags.add(sample_tag(user=self.user))
payload = {
'title': 'Spaghetti carbonara',
'time_minutes': 25,
'price': 10.00
}
... | [
"def",
"test_full_update_recipe",
"(",
"self",
")",
":",
"recipe",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
")",
"recipe",
".",
"tags",
".",
"add",
"(",
"sample_tag",
"(",
"user",
"=",
"self",
".",
"user",
")",
")",
"payload",
"=",
... | [
188,
4
] | [
205,
38
] | python | en | ['en', 'en', 'en'] | True |
RecipeImageUploadTests.test_upload_image_to_recipe | (self) | Test uploading an image to recipe | Test uploading an image to recipe | def test_upload_image_to_recipe(self):
"""Test uploading an image to recipe"""
url = image_upload_url(self.recipe.id)
with tempfile.NamedTemporaryFile(suffix='.jpg') as ntf:
img = Image.new('RGB', (10, 10))
img.save(ntf, format='JPEG')
ntf.seek(0)
... | [
"def",
"test_upload_image_to_recipe",
"(",
"self",
")",
":",
"url",
"=",
"image_upload_url",
"(",
"self",
".",
"recipe",
".",
"id",
")",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"'.jpg'",
")",
"as",
"ntf",
":",
"img",
"=",
"Image"... | [
222,
4
] | [
234,
63
] | python | en | ['en', 'en', 'en'] | True |
RecipeImageUploadTests.test_upload_image_bad_request | (self) | Test uploading an invalid image | Test uploading an invalid image | def test_upload_image_bad_request(self):
"""Test uploading an invalid image"""
url = image_upload_url(self.recipe.id)
res = self.client.post(url, {'image': 'noimage'}, format='multipart')
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) | [
"def",
"test_upload_image_bad_request",
"(",
"self",
")",
":",
"url",
"=",
"image_upload_url",
"(",
"self",
".",
"recipe",
".",
"id",
")",
"res",
"=",
"self",
".",
"client",
".",
"post",
"(",
"url",
",",
"{",
"'image'",
":",
"'noimage'",
"}",
",",
"for... | [
236,
4
] | [
241,
70
] | python | en | ['en', 'zu', 'en'] | True |
RecipeImageUploadTests.test_filter_recipe_by_tags | (self) | Test returning recipes with specific tags | Test returning recipes with specific tags | def test_filter_recipe_by_tags(self):
"""Test returning recipes with specific tags"""
recipe1 = sample_recipe(user=self.user, title='Thai vegetable curry')
recipe2 = sample_recipe(user=self.user, title='Aubergine with tahini')
recipe3 = sample_recipe(user=self.user, title='Fish and chips... | [
"def",
"test_filter_recipe_by_tags",
"(",
"self",
")",
":",
"recipe1",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
",",
"title",
"=",
"'Thai vegetable curry'",
")",
"recipe2",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
",",... | [
243,
4
] | [
263,
52
] | python | en | ['en', 'en', 'en'] | True |
RecipeImageUploadTests.test_filter_recipes_by_ingredients | (self) | Test returning recipes with specific ingredients | Test returning recipes with specific ingredients | def test_filter_recipes_by_ingredients(self):
"""Test returning recipes with specific ingredients"""
recipe1 = sample_recipe(user=self.user, title='Posh beans on toast')
recipe2 = sample_recipe(user=self.user, title='Chicken cacciatore')
recipe3 = sample_recipe(user=self.user, title='St... | [
"def",
"test_filter_recipes_by_ingredients",
"(",
"self",
")",
":",
"recipe1",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",
",",
"title",
"=",
"'Posh beans on toast'",
")",
"recipe2",
"=",
"sample_recipe",
"(",
"user",
"=",
"self",
".",
"user",... | [
265,
4
] | [
285,
52
] | python | en | ['en', 'en', 'en'] | True |
validation_operator | () | Validation Operator operations | Validation Operator operations | def validation_operator():
"""Validation Operator operations"""
pass | [
"def",
"validation_operator",
"(",
")",
":",
"pass"
] | [
25,
0
] | [
27,
8
] | python | en | ['en', 'ky', 'en'] | True |
validation_operator_list | (directory) | List known Validation Operators. | List known Validation Operators. | def validation_operator_list(directory):
"""List known Validation Operators."""
try:
context = DataContext(directory)
except ge_exceptions.ConfigNotFoundError as err:
cli_message("<red>{}</red>".format(err.message))
return
try:
validation_operators = context.list_validat... | [
"def",
"validation_operator_list",
"(",
"directory",
")",
":",
"try",
":",
"context",
"=",
"DataContext",
"(",
"directory",
")",
"except",
"ge_exceptions",
".",
"ConfigNotFoundError",
"as",
"err",
":",
"cli_message",
"(",
"\"<red>{}</red>\"",
".",
"format",
"(",
... | [
38,
0
] | [
70,
15
] | python | en | ['en', 'et', 'en'] | True |
validation_operator_run | (name, run_name, validation_config_file, suite, directory) |
Run a validation operator against some data.
There are two modes to run this command:
1. Interactive (good for development):
Specify the name of the validation operator using the --name argument
and the name of the expectation suite using the --suite argument.
The cli will help ... |
Run a validation operator against some data. | def validation_operator_run(name, run_name, validation_config_file, suite, directory):
# Note though the long lines here aren't pythonic, they look best if Click does the line wraps.
"""
Run a validation operator against some data.
There are two modes to run this command:
1. Interactive (good for ... | [
"def",
"validation_operator_run",
"(",
"name",
",",
"run_name",
",",
"validation_config_file",
",",
"suite",
",",
"directory",
")",
":",
"# Note though the long lines here aren't pythonic, they look best if Click does the line wraps.",
"try",
":",
"context",
"=",
"DataContext",... | [
110,
0
] | [
335,
15
] | python | en | ['en', 'error', 'th'] | False |
DBReporting.begin | (self) | At the start of the run, we want to record the test
execution information in the database. | At the start of the run, we want to record the test
execution information in the database. | def begin(self):
""" At the start of the run, we want to record the test
execution information in the database. """
exec_payload = ExecutionQueryPayload()
exec_payload.execution_start_time = int(time.time() * 1000)
self.execution_start_time = exec_payload.execution_start_time... | [
"def",
"begin",
"(",
"self",
")",
":",
"exec_payload",
"=",
"ExecutionQueryPayload",
"(",
")",
"exec_payload",
".",
"execution_start_time",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
"*",
"1000",
")",
"self",
".",
"execution_start_time",
"=",
"exec_payl... | [
55,
4
] | [
63,
65
] | python | en | ['en', 'en', 'en'] | True |
DBReporting.startTest | (self, test) | At the start of the test, set the testcase details. | At the start of the test, set the testcase details. | def startTest(self, test):
""" At the start of the test, set the testcase details. """
data_payload = TestcaseDataPayload()
self.testcase_guid = str(uuid.uuid4())
data_payload.guid = self.testcase_guid
data_payload.execution_guid = self.execution_guid
if hasattr(test, "br... | [
"def",
"startTest",
"(",
"self",
",",
"test",
")",
":",
"data_payload",
"=",
"TestcaseDataPayload",
"(",
")",
"self",
".",
"testcase_guid",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"data_payload",
".",
"guid",
"=",
"self",
".",
"testcase_gui... | [
65,
4
] | [
83,
47
] | python | en | ['en', 'en', 'en'] | True |
DBReporting.finalize | (self, result) | At the end of the run, we want to
update the DB row with the execution time. | At the end of the run, we want to
update the DB row with the execution time. | def finalize(self, result):
""" At the end of the run, we want to
update the DB row with the execution time. """
runtime = int(time.time() * 1000) - self.execution_start_time
self.testcase_manager.update_execution_data(self.execution_guid,
... | [
"def",
"finalize",
"(",
"self",
",",
"result",
")",
":",
"runtime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
"*",
"1000",
")",
"-",
"self",
".",
"execution_start_time",
"self",
".",
"testcase_manager",
".",
"update_execution_data",
"(",
"self",
".... | [
85,
4
] | [
90,
60
] | python | en | ['en', 'en', 'en'] | True |
DBReporting.addSuccess | (self, test, capt) |
After test completion, we want to record testcase run information.
|
After test completion, we want to record testcase run information.
| def addSuccess(self, test, capt):
"""
After test completion, we want to record testcase run information.
"""
self.__insert_test_result(constants.State.PASS, test) | [
"def",
"addSuccess",
"(",
"self",
",",
"test",
",",
"capt",
")",
":",
"self",
".",
"__insert_test_result",
"(",
"constants",
".",
"State",
".",
"PASS",
",",
"test",
")"
] | [
92,
4
] | [
96,
61
] | python | en | ['en', 'error', 'th'] | False |
DBReporting.addError | (self, test, err, capt=None) |
After a test error, we want to record testcase run information.
|
After a test error, we want to record testcase run information.
| def addError(self, test, err, capt=None):
"""
After a test error, we want to record testcase run information.
"""
self.__insert_test_result(constants.State.ERROR, test, err) | [
"def",
"addError",
"(",
"self",
",",
"test",
",",
"err",
",",
"capt",
"=",
"None",
")",
":",
"self",
".",
"__insert_test_result",
"(",
"constants",
".",
"State",
".",
"ERROR",
",",
"test",
",",
"err",
")"
] | [
98,
4
] | [
102,
67
] | python | en | ['en', 'error', 'th'] | False |
DBReporting.handleError | (self, test, err, capt=None) |
After a test error, we want to record testcase run information.
"Error" also encompasses any states other than Pass or Fail, so we
check for those first.
|
After a test error, we want to record testcase run information.
"Error" also encompasses any states other than Pass or Fail, so we
check for those first.
| def handleError(self, test, err, capt=None):
"""
After a test error, we want to record testcase run information.
"Error" also encompasses any states other than Pass or Fail, so we
check for those first.
"""
if err[0] == errors.BlockedTest:
self.__insert_test_r... | [
"def",
"handleError",
"(",
"self",
",",
"test",
",",
"err",
",",
"capt",
"=",
"None",
")",
":",
"if",
"err",
"[",
"0",
"]",
"==",
"errors",
".",
"BlockedTest",
":",
"self",
".",
"__insert_test_result",
"(",
"constants",
".",
"State",
".",
"BLOCKED",
... | [
104,
4
] | [
126,
23
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.