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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
RemovePrefix | (a, prefix) | Returns 'a' without 'prefix' if it starts with 'prefix'. | Returns 'a' without 'prefix' if it starts with 'prefix'. | def RemovePrefix(a, prefix):
"""Returns 'a' without 'prefix' if it starts with 'prefix'."""
return a[len(prefix):] if a.startswith(prefix) else a | [
"def",
"RemovePrefix",
"(",
"a",
",",
"prefix",
")",
":",
"return",
"a",
"[",
"len",
"(",
"prefix",
")",
":",
"]",
"if",
"a",
".",
"startswith",
"(",
"prefix",
")",
"else",
"a"
] | [
72,
0
] | [
74,
55
] | python | en | ['en', 'en', 'en'] | True |
CalculateVariables | (default_variables, params) | Calculate additional variables for use in the build (called by gyp). | Calculate additional variables for use in the build (called by gyp). | def CalculateVariables(default_variables, params):
"""Calculate additional variables for use in the build (called by gyp)."""
default_variables.setdefault('OS', gyp.common.GetFlavor(params)) | [
"def",
"CalculateVariables",
"(",
"default_variables",
",",
"params",
")",
":",
"default_variables",
".",
"setdefault",
"(",
"'OS'",
",",
"gyp",
".",
"common",
".",
"GetFlavor",
"(",
"params",
")",
")"
] | [
77,
0
] | [
79,
66
] | python | en | ['en', 'en', 'en'] | True |
Compilable | (filename) | Return true if the file is compilable (should be in OBJS). | Return true if the file is compilable (should be in OBJS). | def Compilable(filename):
"""Return true if the file is compilable (should be in OBJS)."""
return any(filename.endswith(e) for e in COMPILABLE_EXTENSIONS) | [
"def",
"Compilable",
"(",
"filename",
")",
":",
"return",
"any",
"(",
"filename",
".",
"endswith",
"(",
"e",
")",
"for",
"e",
"in",
"COMPILABLE_EXTENSIONS",
")"
] | [
82,
0
] | [
84,
65
] | python | en | ['en', 'en', 'en'] | True |
Linkable | (filename) | Return true if the file is linkable (should be on the link line). | Return true if the file is linkable (should be on the link line). | def Linkable(filename):
"""Return true if the file is linkable (should be on the link line)."""
return filename.endswith('.o') | [
"def",
"Linkable",
"(",
"filename",
")",
":",
"return",
"filename",
".",
"endswith",
"(",
"'.o'",
")"
] | [
87,
0
] | [
89,
32
] | python | en | ['en', 'en', 'en'] | True |
NormjoinPathForceCMakeSource | (base_path, rel_path) | Resolves rel_path against base_path and returns the result.
If rel_path is an absolute path it is returned unchanged.
Otherwise it is resolved against base_path and normalized.
If the result is a relative path, it is forced to be relative to the
CMakeLists.txt.
| Resolves rel_path against base_path and returns the result. | def NormjoinPathForceCMakeSource(base_path, rel_path):
"""Resolves rel_path against base_path and returns the result.
If rel_path is an absolute path it is returned unchanged.
Otherwise it is resolved against base_path and normalized.
If the result is a relative path, it is forced to be relative to the
CMake... | [
"def",
"NormjoinPathForceCMakeSource",
"(",
"base_path",
",",
"rel_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"rel_path",
")",
":",
"return",
"rel_path",
"if",
"any",
"(",
"[",
"rel_path",
".",
"startswith",
"(",
"var",
")",
"for",
"var... | [
92,
0
] | [
106,
74
] | python | en | ['en', 'en', 'en'] | True |
NormjoinPath | (base_path, rel_path) | Resolves rel_path against base_path and returns the result.
TODO: what is this really used for?
If rel_path begins with '$' it is returned unchanged.
Otherwise it is resolved against base_path if relative, then normalized.
| Resolves rel_path against base_path and returns the result.
TODO: what is this really used for?
If rel_path begins with '$' it is returned unchanged.
Otherwise it is resolved against base_path if relative, then normalized.
| def NormjoinPath(base_path, rel_path):
"""Resolves rel_path against base_path and returns the result.
TODO: what is this really used for?
If rel_path begins with '$' it is returned unchanged.
Otherwise it is resolved against base_path if relative, then normalized.
"""
if rel_path.startswith('$') and not rel... | [
"def",
"NormjoinPath",
"(",
"base_path",
",",
"rel_path",
")",
":",
"if",
"rel_path",
".",
"startswith",
"(",
"'$'",
")",
"and",
"not",
"rel_path",
".",
"startswith",
"(",
"'${configuration}'",
")",
":",
"return",
"rel_path",
"return",
"os",
".",
"path",
"... | [
109,
0
] | [
117,
60
] | python | en | ['en', 'en', 'en'] | True |
CMakeStringEscape | (a) | Escapes the string 'a' for use inside a CMake string.
This means escaping
'\' otherwise it may be seen as modifying the next character
'"' otherwise it will end the string
';' otherwise the string becomes a list
The following do not need to be escaped
'#' when the lexer is in string state, this does not s... | Escapes the string 'a' for use inside a CMake string. | def CMakeStringEscape(a):
"""Escapes the string 'a' for use inside a CMake string.
This means escaping
'\' otherwise it may be seen as modifying the next character
'"' otherwise it will end the string
';' otherwise the string becomes a list
The following do not need to be escaped
'#' when the lexer is i... | [
"def",
"CMakeStringEscape",
"(",
"a",
")",
":",
"return",
"a",
".",
"replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
".",
"replace",
"(",
"';'",
",",
"'\\\\;'",
")",
".",
"replace",
"(",
"'\"'",
",",
"'\\\\\"'",
")"
] | [
120,
0
] | [
136,
72
] | python | en | ['en', 'en', 'en'] | True |
SetFileProperty | (output, source_name, property_name, values, sep) | Given a set of source file, sets the given property on them. | Given a set of source file, sets the given property on them. | def SetFileProperty(output, source_name, property_name, values, sep):
"""Given a set of source file, sets the given property on them."""
output.write('set_source_files_properties(')
output.write(source_name)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
... | [
"def",
"SetFileProperty",
"(",
"output",
",",
"source_name",
",",
"property_name",
",",
"values",
",",
"sep",
")",
":",
"output",
".",
"write",
"(",
"'set_source_files_properties('",
")",
"output",
".",
"write",
"(",
"source_name",
")",
"output",
".",
"write",... | [
139,
0
] | [
149,
22
] | python | en | ['en', 'en', 'en'] | True |
SetFilesProperty | (output, variable, property_name, values, sep) | Given a set of source files, sets the given property on them. | Given a set of source files, sets the given property on them. | def SetFilesProperty(output, variable, property_name, values, sep):
"""Given a set of source files, sets the given property on them."""
output.write('set_source_files_properties(')
WriteVariable(output, variable)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in valu... | [
"def",
"SetFilesProperty",
"(",
"output",
",",
"variable",
",",
"property_name",
",",
"values",
",",
"sep",
")",
":",
"output",
".",
"write",
"(",
"'set_source_files_properties('",
")",
"WriteVariable",
"(",
"output",
",",
"variable",
")",
"output",
".",
"writ... | [
152,
0
] | [
162,
22
] | python | en | ['en', 'en', 'en'] | True |
SetTargetProperty | (output, target_name, property_name, values, sep='') | Given a target, sets the given property. | Given a target, sets the given property. | def SetTargetProperty(output, target_name, property_name, values, sep=''):
"""Given a target, sets the given property."""
output.write('set_target_properties(')
output.write(target_name)
output.write(' PROPERTIES ')
output.write(property_name)
output.write(' "')
for value in values:
output.write(CMake... | [
"def",
"SetTargetProperty",
"(",
"output",
",",
"target_name",
",",
"property_name",
",",
"values",
",",
"sep",
"=",
"''",
")",
":",
"output",
".",
"write",
"(",
"'set_target_properties('",
")",
"output",
".",
"write",
"(",
"target_name",
")",
"output",
".",... | [
165,
0
] | [
175,
22
] | python | en | ['en', 'en', 'en'] | True |
SetVariable | (output, variable_name, value) | Sets a CMake variable. | Sets a CMake variable. | def SetVariable(output, variable_name, value):
"""Sets a CMake variable."""
output.write('set(')
output.write(variable_name)
output.write(' "')
output.write(CMakeStringEscape(value))
output.write('")\n') | [
"def",
"SetVariable",
"(",
"output",
",",
"variable_name",
",",
"value",
")",
":",
"output",
".",
"write",
"(",
"'set('",
")",
"output",
".",
"write",
"(",
"variable_name",
")",
"output",
".",
"write",
"(",
"' \"'",
")",
"output",
".",
"write",
"(",
"C... | [
178,
0
] | [
184,
22
] | python | en | ['en', 'fil', 'en'] | True |
SetVariableList | (output, variable_name, values) | Sets a CMake variable to a list. | Sets a CMake variable to a list. | def SetVariableList(output, variable_name, values):
"""Sets a CMake variable to a list."""
if not values:
return SetVariable(output, variable_name, "")
if len(values) == 1:
return SetVariable(output, variable_name, values[0])
output.write('list(APPEND ')
output.write(variable_name)
output.write('\n ... | [
"def",
"SetVariableList",
"(",
"output",
",",
"variable_name",
",",
"values",
")",
":",
"if",
"not",
"values",
":",
"return",
"SetVariable",
"(",
"output",
",",
"variable_name",
",",
"\"\"",
")",
"if",
"len",
"(",
"values",
")",
"==",
"1",
":",
"return",... | [
187,
0
] | [
197,
22
] | python | en | ['en', 'en', 'en'] | True |
UnsetVariable | (output, variable_name) | Unsets a CMake variable. | Unsets a CMake variable. | def UnsetVariable(output, variable_name):
"""Unsets a CMake variable."""
output.write('unset(')
output.write(variable_name)
output.write(')\n') | [
"def",
"UnsetVariable",
"(",
"output",
",",
"variable_name",
")",
":",
"output",
".",
"write",
"(",
"'unset('",
")",
"output",
".",
"write",
"(",
"variable_name",
")",
"output",
".",
"write",
"(",
"')\\n'",
")"
] | [
200,
0
] | [
204,
21
] | python | en | ['en', 'en', 'en'] | True |
StringToCMakeTargetName | (a) | Converts the given string 'a' to a valid CMake target name.
All invalid characters are replaced by '_'.
Invalid for cmake: ' ', '/', '(', ')', '"'
Invalid for make: ':'
Invalid for unknown reasons but cause failures: '.'
| Converts the given string 'a' to a valid CMake target name. | def StringToCMakeTargetName(a):
"""Converts the given string 'a' to a valid CMake target name.
All invalid characters are replaced by '_'.
Invalid for cmake: ' ', '/', '(', ')', '"'
Invalid for make: ':'
Invalid for unknown reasons but cause failures: '.'
"""
return a.translate(string.maketrans(' /():."'... | [
"def",
"StringToCMakeTargetName",
"(",
"a",
")",
":",
"return",
"a",
".",
"translate",
"(",
"string",
".",
"maketrans",
"(",
"' /():.\"'",
",",
"'_______'",
")",
")"
] | [
231,
0
] | [
239,
60
] | python | en | ['en', 'en', 'en'] | True |
WriteActions | (target_name, actions, extra_sources, extra_deps,
path_to_gyp, output) | Write CMake for the 'actions' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
extra_deps: [<cmake_taget>] to append with generated targets.
... | Write CMake for the 'actions' in the target. | def WriteActions(target_name, actions, extra_sources, extra_deps,
path_to_gyp, output):
"""Write CMake for the 'actions' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_sources: [(<cmake_src>, <src>)... | [
"def",
"WriteActions",
"(",
"target_name",
",",
"actions",
",",
"extra_sources",
",",
"extra_deps",
",",
"path_to_gyp",
",",
"output",
")",
":",
"for",
"action",
"in",
"actions",
":",
"action_name",
"=",
"StringToCMakeTargetName",
"(",
"action",
"[",
"'action_na... | [
242,
0
] | [
318,
41
] | python | en | ['en', 'en', 'en'] | True |
WriteRules | (target_name, rules, extra_sources, extra_deps,
path_to_gyp, output) | Write CMake for the 'rules' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
extra_deps: [<cmake_taget>] to append with generated targets.
p... | Write CMake for the 'rules' in the target. | def WriteRules(target_name, rules, extra_sources, extra_deps,
path_to_gyp, output):
"""Write CMake for the 'rules' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_sources: [(<cmake_src>, <src>)] to app... | [
"def",
"WriteRules",
"(",
"target_name",
",",
"rules",
",",
"extra_sources",
",",
"extra_deps",
",",
"path_to_gyp",
",",
"output",
")",
":",
"for",
"rule",
"in",
"rules",
":",
"rule_name",
"=",
"StringToCMakeTargetName",
"(",
"target_name",
"+",
"'__'",
"+",
... | [
328,
0
] | [
439,
32
] | python | en | ['en', 'en', 'en'] | True |
WriteCopies | (target_name, copies, extra_deps, path_to_gyp, output) | Write CMake for the 'copies' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_deps: [<cmake_taget>] to append with generated targets.
path_to_gyp: relative path from CMakeLists.txt being generated to
the Gyp... | Write CMake for the 'copies' in the target. | def WriteCopies(target_name, copies, extra_deps, path_to_gyp, output):
"""Write CMake for the 'copies' in the target.
Args:
target_name: the name of the CMake target being generated.
actions: the Gyp 'actions' dict for this target.
extra_deps: [<cmake_taget>] to append with generated targets.
path_... | [
"def",
"WriteCopies",
"(",
"target_name",
",",
"copies",
",",
"extra_deps",
",",
"path_to_gyp",
",",
"output",
")",
":",
"copy_name",
"=",
"target_name",
"+",
"'__copies'",
"# CMake gets upset with custom targets with OUTPUT which specify no output.",
"have_copies",
"=",
... | [
442,
0
] | [
547,
30
] | python | en | ['en', 'en', 'en'] | True |
CreateCMakeTargetBaseName | (qualified_target) | This is the name we would like the target to have. | This is the name we would like the target to have. | def CreateCMakeTargetBaseName(qualified_target):
"""This is the name we would like the target to have."""
_, gyp_target_name, gyp_target_toolset = (
gyp.common.ParseQualifiedTarget(qualified_target))
cmake_target_base_name = gyp_target_name
if gyp_target_toolset and gyp_target_toolset != 'target':
cma... | [
"def",
"CreateCMakeTargetBaseName",
"(",
"qualified_target",
")",
":",
"_",
",",
"gyp_target_name",
",",
"gyp_target_toolset",
"=",
"(",
"gyp",
".",
"common",
".",
"ParseQualifiedTarget",
"(",
"qualified_target",
")",
")",
"cmake_target_base_name",
"=",
"gyp_target_na... | [
550,
0
] | [
557,
56
] | python | en | ['en', 'en', 'en'] | True |
CreateCMakeTargetFullName | (qualified_target) | An unambiguous name for the target. | An unambiguous name for the target. | def CreateCMakeTargetFullName(qualified_target):
"""An unambiguous name for the target."""
gyp_file, gyp_target_name, gyp_target_toolset = (
gyp.common.ParseQualifiedTarget(qualified_target))
cmake_target_full_name = gyp_file + ':' + gyp_target_name
if gyp_target_toolset and gyp_target_toolset != 'target'... | [
"def",
"CreateCMakeTargetFullName",
"(",
"qualified_target",
")",
":",
"gyp_file",
",",
"gyp_target_name",
",",
"gyp_target_toolset",
"=",
"(",
"gyp",
".",
"common",
".",
"ParseQualifiedTarget",
"(",
"qualified_target",
")",
")",
"cmake_target_full_name",
"=",
"gyp_fi... | [
560,
0
] | [
567,
56
] | python | en | ['en', 'en', 'en'] | True |
ExpectTableColumnsToMatchOrderedList.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... | [
81,
4
] | [
110,
19
] | python | en | ['en', 'error', 'th'] | False |
MetaFileDataAsset.file_lines_map_expectation | (cls, func) | Constructs an expectation using file lines map semantics.
The file_lines_map_expectations decorator handles boilerplate issues
surrounding the common pattern of evaluating truthiness of some
condition on an line by line basis in a file.
Args:
func (function): \
... | Constructs an expectation using file lines map semantics.
The file_lines_map_expectations decorator handles boilerplate issues
surrounding the common pattern of evaluating truthiness of some
condition on an line by line basis in a file. | def file_lines_map_expectation(cls, func):
"""Constructs an expectation using file lines map semantics.
The file_lines_map_expectations decorator handles boilerplate issues
surrounding the common pattern of evaluating truthiness of some
condition on an line by line basis in a file.
... | [
"def",
"file_lines_map_expectation",
"(",
"cls",
",",
"func",
")",
":",
"argspec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")",
"[",
"0",
"]",
"[",
"1",
":",
"]",
"@",
"cls",
".",
"expectation",
"(",
"argspec",
")",
"@",
"wraps",
"(",
"fu... | [
27,
4
] | [
155,
28
] | python | en | ['en', 'en', 'en'] | True |
FileDataAsset.expect_file_line_regex_match_count_to_be_between | (
self,
regex,
expected_min_count=0,
expected_max_count=None,
skip=None,
mostly=None,
null_lines_regex=r"^\s*$",
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
_lines=None,
) |
Expect the number of times a regular expression appears on each line of
a file to be between a maximum and minimum value.
Args:
regex: \
A string that can be compiled as valid regular expression to match
expected_min_count (None or nonnegative integer):... |
Expect the number of times a regular expression appears on each line of
a file to be between a maximum and minimum value. | def expect_file_line_regex_match_count_to_be_between(
self,
regex,
expected_min_count=0,
expected_max_count=None,
skip=None,
mostly=None,
null_lines_regex=r"^\s*$",
result_format=None,
include_config=True,
catch_exceptions=None,
met... | [
"def",
"expect_file_line_regex_match_count_to_be_between",
"(",
"self",
",",
"regex",
",",
"expected_min_count",
"=",
"0",
",",
"expected_max_count",
"=",
"None",
",",
"skip",
"=",
"None",
",",
"mostly",
"=",
"None",
",",
"null_lines_regex",
"=",
"r\"^\\s*$\"",
",... | [
172,
4
] | [
292,
25
] | python | en | ['en', 'error', 'th'] | False |
FileDataAsset.expect_file_line_regex_match_count_to_equal | (
self,
regex,
expected_count=0,
skip=None,
mostly=None,
nonnull_lines_regex=r"^\s*$",
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
_lines=None,
) |
Expect the number of times a regular expression appears on each line of
a file to be between a maximum and minimum value.
Args:
regex: \
A string that can be compiled as valid regular expression to match
expected_count (None or nonnegative integer): \
... |
Expect the number of times a regular expression appears on each line of
a file to be between a maximum and minimum value. | def expect_file_line_regex_match_count_to_equal(
self,
regex,
expected_count=0,
skip=None,
mostly=None,
nonnull_lines_regex=r"^\s*$",
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
_lines=None,
):
... | [
"def",
"expect_file_line_regex_match_count_to_equal",
"(",
"self",
",",
"regex",
",",
"expected_count",
"=",
"0",
",",
"skip",
"=",
"None",
",",
"mostly",
"=",
"None",
",",
"nonnull_lines_regex",
"=",
"r\"^\\s*$\"",
",",
"result_format",
"=",
"None",
",",
"inclu... | [
295,
4
] | [
370,
83
] | python | en | ['en', 'error', 'th'] | False |
FileDataAsset.expect_file_hash_to_equal | (
self,
value,
hash_alg="md5",
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
) |
Expect computed file hash to equal some given value.
Args:
value: A string to compare with the computed hash value
Keyword Args:
hash_alg (string): Indicates the hash algorithm to use
result_format (str or None): \
Which output mode to use... |
Expect computed file hash to equal some given value. | def expect_file_hash_to_equal(
self,
value,
hash_alg="md5",
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
):
"""
Expect computed file hash to equal some given value.
Args:
value: A string to co... | [
"def",
"expect_file_hash_to_equal",
"(",
"self",
",",
"value",
",",
"hash_alg",
"=",
"\"md5\"",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"True",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
",",
")",
":",
"success",
... | [
373,
4
] | [
430,
35
] | python | en | ['en', 'error', 'th'] | False |
FileDataAsset.expect_file_size_to_be_between | (
self,
minsize=0,
maxsize=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
) |
Expect file size to be between a user specified maxsize and minsize.
Args:
minsize(integer): minimum expected file size
maxsize(integer): maximum expected file size
Keyword Args:
result_format (str or None): \
Which output mode to use: `BOO... |
Expect file size to be between a user specified maxsize and minsize. | def expect_file_size_to_be_between(
self,
minsize=0,
maxsize=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
):
"""
Expect file size to be between a user specified maxsize and minsize.
Args:
... | [
"def",
"expect_file_size_to_be_between",
"(",
"self",
",",
"minsize",
"=",
"0",
",",
"maxsize",
"=",
"None",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"True",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
",",
")",
":... | [
433,
4
] | [
508,
71
] | python | en | ['en', 'error', 'th'] | False |
FileDataAsset.expect_file_to_exist | (
self,
filepath=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
) |
Checks to see if a file specified by the user actually exists
Args:
filepath (str or None): \
The filepath to evaluate. If none, will check the currently-configured path object
of this FileDataAsset.
Keyword Args:
result_format (str or ... |
Checks to see if a file specified by the user actually exists | def expect_file_to_exist(
self,
filepath=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
):
"""
Checks to see if a file specified by the user actually exists
Args:
filepath (str or None): \
... | [
"def",
"expect_file_to_exist",
"(",
"self",
",",
"filepath",
"=",
"None",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"True",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
",",
")",
":",
"if",
"filepath",
"is",
"not",
... | [
511,
4
] | [
561,
35
] | python | en | ['en', 'error', 'th'] | False |
FileDataAsset.expect_file_to_have_valid_table_header | (
self,
regex,
skip=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
) |
Checks to see if a file has a line with unique delimited values,
such a line may be used as a table header.
Keyword Args:
skip (nonnegative integer): \
Integer specifying the first lines in the file the method
should skip before assessing expectation... |
Checks to see if a file has a line with unique delimited values,
such a line may be used as a table header. | def expect_file_to_have_valid_table_header(
self,
regex,
skip=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
):
"""
Checks to see if a file has a line with unique delimited values,
such a line may be us... | [
"def",
"expect_file_to_have_valid_table_header",
"(",
"self",
",",
"regex",
",",
"skip",
"=",
"None",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"True",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
",",
")",
":",
"try",... | [
564,
4
] | [
639,
35
] | python | en | ['en', 'error', 'th'] | False |
FileDataAsset.expect_file_to_be_valid_json | (
self,
schema=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
) |
Args:
schema : string
optional JSON schema file on which JSON data file is validated against
result_format (str or None):
Which output mode to use: `BOOLEAN_ONLY`, `BASIC`, `COMPLETE`, or `SUMMARY`. \
For more detail, see :ref:`result_for... |
Args:
schema : string
optional JSON schema file on which JSON data file is validated against | def expect_file_to_be_valid_json(
self,
schema=None,
result_format=None,
include_config=True,
catch_exceptions=None,
meta=None,
):
"""
Args:
schema : string
optional JSON schema file on which JSON data file is validated aga... | [
"def",
"expect_file_to_be_valid_json",
"(",
"self",
",",
"schema",
"=",
"None",
",",
"result_format",
"=",
"None",
",",
"include_config",
"=",
"True",
",",
"catch_exceptions",
"=",
"None",
",",
"meta",
"=",
"None",
",",
")",
":",
"if",
"schema",
"is",
"Non... | [
642,
4
] | [
704,
35
] | python | en | ['en', 'error', 'th'] | False |
parse_bool | (s: Optional[Union[str, bool]]) |
Parse a boolean value from a string. T, True, Y, y, 1 return True;
other things return False.
|
Parse a boolean value from a string. T, True, Y, y, 1 return True;
other things return False.
| def parse_bool(s: Optional[Union[str, bool]]) -> bool:
"""
Parse a boolean value from a string. T, True, Y, y, 1 return True;
other things return False.
"""
# If `s` is already a bool, return its value.
#
# This allows a caller to not know or care whether their value is already
# a boo... | [
"def",
"parse_bool",
"(",
"s",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"bool",
"]",
"]",
")",
"->",
"bool",
":",
"# If `s` is already a bool, return its value.",
"#",
"# This allows a caller to not know or care whether their value is already",
"# a boolean, or if it... | [
152,
0
] | [
173,
20
] | python | en | ['en', 'ja', 'th'] | False |
Timer.__init__ | (self, name: str, prom_metrics_registry: Optional[Any]=None) |
Create a Timer, given a name. The Timer is initially stopped.
|
Create a Timer, given a name. The Timer is initially stopped.
| def __init__(self, name: str, prom_metrics_registry: Optional[Any]=None) -> None:
"""
Create a Timer, given a name. The Timer is initially stopped.
"""
self.name = name
if prom_metrics_registry:
metric_prefix = re.sub(r'\s+', '_', name).lower()
self._gau... | [
"def",
"__init__",
"(",
"self",
",",
"name",
":",
"str",
",",
"prom_metrics_registry",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"name",
"=",
"name",
"if",
"prom_metrics_registry",
":",
"metric_prefix",
"=",
"re"... | [
273,
4
] | [
285,
20
] | python | en | ['en', 'error', 'th'] | False |
Timer.__bool__ | (self) |
Timers test True in a boolean context if they have timed at least one
cycle.
|
Timers test True in a boolean context if they have timed at least one
cycle.
| def __bool__(self) -> bool:
"""
Timers test True in a boolean context if they have timed at least one
cycle.
"""
return self._cycles > 0 | [
"def",
"__bool__",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_cycles",
">",
"0"
] | [
303,
4
] | [
308,
31
] | python | en | ['en', 'error', 'th'] | False |
Timer.start | (self, when: Optional[float]=None) |
Start a Timer running.
:param when: Optional start time. If not supplied,
the current time is used.
|
Start a Timer running. | def start(self, when: Optional[float]=None) -> None:
"""
Start a Timer running.
:param when: Optional start time. If not supplied,
the current time is used.
"""
# If we're already running, this method silently discards the
# currently-running cycle. Why? Because... | [
"def",
"start",
"(",
"self",
",",
"when",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
")",
"->",
"None",
":",
"# If we're already running, this method silently discards the",
"# currently-running cycle. Why? Because otherwise, it's a little",
"# too easy to forget to stop ... | [
310,
4
] | [
326,
28
] | python | en | ['en', 'error', 'th'] | False |
Timer.stop | (self, when: Optional[float]=None) |
Stop a Timer, increment the cycle count, and update the
accumulated time with the amount of time since the Timer
was started.
:param when: Optional stop time. If not supplied,
the current time is used.
:return: The amount of time the Timer has accumulated
|
Stop a Timer, increment the cycle count, and update the
accumulated time with the amount of time since the Timer
was started. | def stop(self, when: Optional[float]=None) -> float:
"""
Stop a Timer, increment the cycle count, and update the
accumulated time with the amount of time since the Timer
was started.
:param when: Optional stop time. If not supplied,
the current time is used.
:ret... | [
"def",
"stop",
"(",
"self",
",",
"when",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
")",
"->",
"float",
":",
"# If we're already stopped, just return the same thing as the",
"# previous call to stop. See comments in start() for why this",
"# isn't an Exception...",
"if"... | [
328,
4
] | [
364,
32
] | python | en | ['en', 'error', 'th'] | False |
Timer.faketime | (self, faketime: float) |
Add fake time to a Timer. This is intended solely for
testing.
|
Add fake time to a Timer. This is intended solely for
testing.
| def faketime(self, faketime: float) -> None:
"""
Add fake time to a Timer. This is intended solely for
testing.
"""
if not self._running:
raise Exception(f"Timer {self.name}.faketime: not running")
self._faketime = faketime | [
"def",
"faketime",
"(",
"self",
",",
"faketime",
":",
"float",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_running",
":",
"raise",
"Exception",
"(",
"f\"Timer {self.name}.faketime: not running\"",
")",
"self",
".",
"_faketime",
"=",
"faketime"
] | [
366,
4
] | [
375,
33
] | python | en | ['en', 'error', 'th'] | False |
Timer.cycles | (self) |
The number of timing cycles this Timer has recorded.
|
The number of timing cycles this Timer has recorded.
| def cycles(self):
"""
The number of timing cycles this Timer has recorded.
"""
return self._cycles | [
"def",
"cycles",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cycles"
] | [
378,
4
] | [
382,
27
] | python | en | ['en', 'error', 'th'] | False |
Timer.starttime | (self) |
The time this Timer was last started, or 0 if it has
never been started.
|
The time this Timer was last started, or 0 if it has
never been started.
| def starttime(self):
"""
The time this Timer was last started, or 0 if it has
never been started.
"""
return self._starttime | [
"def",
"starttime",
"(",
"self",
")",
":",
"return",
"self",
".",
"_starttime"
] | [
385,
4
] | [
390,
30
] | python | en | ['en', 'error', 'th'] | False |
Timer.accumulated | (self) |
The amount of time this Timer has accumulated.
|
The amount of time this Timer has accumulated.
| def accumulated(self):
"""
The amount of time this Timer has accumulated.
"""
return self._accumulated | [
"def",
"accumulated",
"(",
"self",
")",
":",
"return",
"self",
".",
"_accumulated"
] | [
393,
4
] | [
397,
32
] | python | en | ['en', 'error', 'th'] | False |
Timer.minimum | (self) |
The minimum single-cycle time this Timer has recorded.
|
The minimum single-cycle time this Timer has recorded.
| def minimum(self):
"""
The minimum single-cycle time this Timer has recorded.
"""
return self._minimum | [
"def",
"minimum",
"(",
"self",
")",
":",
"return",
"self",
".",
"_minimum"
] | [
400,
4
] | [
404,
28
] | python | en | ['en', 'error', 'th'] | False |
Timer.maximum | (self) |
The maximum single-cycle time this Timer has recorded.
|
The maximum single-cycle time this Timer has recorded.
| def maximum(self):
"""
The maximum single-cycle time this Timer has recorded.
"""
return self._maximum | [
"def",
"maximum",
"(",
"self",
")",
":",
"return",
"self",
".",
"_maximum"
] | [
407,
4
] | [
411,
28
] | python | en | ['en', 'error', 'th'] | False |
Timer.average | (self) |
The average cycle time for this Timer.
|
The average cycle time for this Timer.
| def average(self):
"""
The average cycle time for this Timer.
"""
if self._cycles > 0:
return self._accumulated / self._cycles
raise Exception(f"Timer {self.name}.average: no cycles to average") | [
"def",
"average",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cycles",
">",
"0",
":",
"return",
"self",
".",
"_accumulated",
"/",
"self",
".",
"_cycles",
"raise",
"Exception",
"(",
"f\"Timer {self.name}.average: no cycles to average\"",
")"
] | [
414,
4
] | [
421,
75
] | python | en | ['en', 'error', 'th'] | False |
Timer.running | (self) |
Whether or not this Timer is running.
|
Whether or not this Timer is running.
| def running(self):
"""
Whether or not this Timer is running.
"""
return self._running | [
"def",
"running",
"(",
"self",
")",
":",
"return",
"self",
".",
"_running"
] | [
424,
4
] | [
428,
28
] | python | en | ['en', 'error', 'th'] | False |
Timer.summary | (self) |
Return a summary of this Timer.
|
Return a summary of this Timer.
| def summary(self) -> str:
"""
Return a summary of this Timer.
"""
return "TIMER %s: %d, %.3f/%.3f/%.3f" % (
self.name, self.cycles, self.minimum, self.average, self.maximum
) | [
"def",
"summary",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"TIMER %s: %d, %.3f/%.3f/%.3f\"",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"cycles",
",",
"self",
".",
"minimum",
",",
"self",
".",
"average",
",",
"self",
".",
"maximum",
")"
] | [
440,
4
] | [
447,
16
] | python | en | ['en', 'error', 'th'] | False |
SecretInfo.decode | (b64_pem: str) |
Do base64 decoding of a cryptographic element.
:param b64_pem: Base64-encoded PEM element
:return: Decoded PEM element
|
Do base64 decoding of a cryptographic element. | def decode(b64_pem: str) -> Optional[str]:
"""
Do base64 decoding of a cryptographic element.
:param b64_pem: Base64-encoded PEM element
:return: Decoded PEM element
"""
utf8_pem = None
pem = None
try:
utf8_pem = binascii.a2b_base64(b64_pem)
... | [
"def",
"decode",
"(",
"b64_pem",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"utf8_pem",
"=",
"None",
"pem",
"=",
"None",
"try",
":",
"utf8_pem",
"=",
"binascii",
".",
"a2b_base64",
"(",
"b64_pem",
")",
"except",
"binascii",
".",
"Error",
... | [
548,
4
] | [
568,
18
] | python | en | ['en', 'error', 'th'] | False |
SecretInfo.fingerprint | (pem: Optional[str]) |
Generate and return a cryptographic fingerprint of a PEM element.
The fingerprint is the uppercase hex SHA-1 signature of the element's UTF-8
representation.
:param pem: PEM element
:return: fingerprint string
|
Generate and return a cryptographic fingerprint of a PEM element. | def fingerprint(pem: Optional[str]) -> str:
"""
Generate and return a cryptographic fingerprint of a PEM element.
The fingerprint is the uppercase hex SHA-1 signature of the element's UTF-8
representation.
:param pem: PEM element
:return: fingerprint string
"""
... | [
"def",
"fingerprint",
"(",
"pem",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"str",
":",
"if",
"not",
"pem",
":",
"return",
"'<none>'",
"h",
"=",
"hashlib",
".",
"new",
"(",
"'sha1'",
")",
"h",
".",
"update",
"(",
"pem",
".",
"encode",
"(",
"'u... | [
571,
4
] | [
590,
33
] | python | en | ['en', 'error', 'th'] | False |
SecretInfo.to_dict | (self) |
Return the dictionary representation of this SecretInfo.
:return: dict
|
Return the dictionary representation of this SecretInfo. | def to_dict(self) -> Dict[str, Any]:
"""
Return the dictionary representation of this SecretInfo.
:return: dict
"""
return {
'name': self.name,
'namespace': self.namespace,
'secret_type': self.secret_type,
'tls_crt': self.fingerpri... | [
"def",
"to_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'namespace'",
":",
"self",
".",
"namespace",
",",
"'secret_type'",
":",
"self",
".",
"secret_type",
",",
"'tl... | [
592,
4
] | [
606,
9
] | python | en | ['en', 'error', 'th'] | False |
SecretInfo.from_aconf_secret | (cls, aconf_object: 'ACResource') |
Convert an ACResource containing a secret into a SecretInfo. This is used by the IR.save_secret_info()
to convert saved secrets into SecretInfos.
:param aconf_object: a ACResource containing a secret
:return: SecretInfo
|
Convert an ACResource containing a secret into a SecretInfo. This is used by the IR.save_secret_info()
to convert saved secrets into SecretInfos. | def from_aconf_secret(cls, aconf_object: 'ACResource') -> 'SecretInfo':
"""
Convert an ACResource containing a secret into a SecretInfo. This is used by the IR.save_secret_info()
to convert saved secrets into SecretInfos.
:param aconf_object: a ACResource containing a secret
:re... | [
"def",
"from_aconf_secret",
"(",
"cls",
",",
"aconf_object",
":",
"'ACResource'",
")",
"->",
"'SecretInfo'",
":",
"tls_crt",
"=",
"aconf_object",
".",
"get",
"(",
"'tls_crt'",
",",
"None",
")",
"if",
"not",
"tls_crt",
":",
"tls_crt",
"=",
"aconf_object",
"."... | [
609,
4
] | [
634,
9
] | python | en | ['en', 'error', 'th'] | False |
SecretInfo.from_dict | (cls, resource: 'IRResource',
secret_name: str, namespace: str, source: str,
cert_data: Optional[Dict[str, Any]], secret_type="kubernetes.io/tls") |
Given a secret's name and namespace, and a dictionary of configuration elements, return
a SecretInfo for the secret.
The "source" parameter needs some explanation. When working with secrets in most environments
where Ambassador runs, secrets will be loaded from some external system (e.... |
Given a secret's name and namespace, and a dictionary of configuration elements, return
a SecretInfo for the secret. | def from_dict(cls, resource: 'IRResource',
secret_name: str, namespace: str, source: str,
cert_data: Optional[Dict[str, Any]], secret_type="kubernetes.io/tls") -> Optional['SecretInfo']:
"""
Given a secret's name and namespace, and a dictionary of configuration elemen... | [
"def",
"from_dict",
"(",
"cls",
",",
"resource",
":",
"'IRResource'",
",",
"secret_name",
":",
"str",
",",
"namespace",
":",
"str",
",",
"source",
":",
"str",
",",
"cert_data",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"sec... | [
637,
4
] | [
690,
115
] | python | en | ['en', 'error', 'th'] | False |
SecretHandler.load_secret | (self, resource: 'IRResource', secret_name: str, namespace: str) |
load_secret: given a secret’s name and namespace, pull it from wherever it really lives,
write it to disk, and return a SecretInfo telling the rest of Ambassador where it got written.
This is the fallback load_secret implementation, which doesn't do anything: it is written
assuming tha... |
load_secret: given a secret’s name and namespace, pull it from wherever it really lives,
write it to disk, and return a SecretInfo telling the rest of Ambassador where it got written. | def load_secret(self, resource: 'IRResource', secret_name: str, namespace: str) -> Optional[SecretInfo]:
"""
load_secret: given a secret’s name and namespace, pull it from wherever it really lives,
write it to disk, and return a SecretInfo telling the rest of Ambassador where it got written.
... | [
"def",
"load_secret",
"(",
"self",
",",
"resource",
":",
"'IRResource'",
",",
"secret_name",
":",
"str",
",",
"namespace",
":",
"str",
")",
"->",
"Optional",
"[",
"SecretInfo",
"]",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"SecretHandler (%s %s): loa... | [
763,
4
] | [
782,
19
] | python | en | ['en', 'error', 'th'] | False |
SecretHandler.still_needed | (self, resource: 'IRResource', secret_name: str, namespace: str) |
still_needed: remember that a given secret is still needed, so that we can tell watt to
keep paying attention to it.
The default implementation doesn't do much of anything, because it assumes that we're
not running in the watch_hook, so watt has already been told everything it needs to... |
still_needed: remember that a given secret is still needed, so that we can tell watt to
keep paying attention to it. | def still_needed(self, resource: 'IRResource', secret_name: str, namespace: str) -> None:
"""
still_needed: remember that a given secret is still needed, so that we can tell watt to
keep paying attention to it.
The default implementation doesn't do much of anything, because it assumes t... | [
"def",
"still_needed",
"(",
"self",
",",
"resource",
":",
"'IRResource'",
",",
"secret_name",
":",
"str",
",",
"namespace",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"SecretHandler (%s %s): secret %s in namespace %s is still n... | [
784,
4
] | [
800,
81
] | python | en | ['en', 'error', 'th'] | False |
SecretHandler.cache_secret | (self, resource: 'IRResource', secret_info: SecretInfo) |
cache_secret: stash the SecretInfo from load_secret into Ambassador’s internal cache,
so that we don’t have to call load_secret again if we need it again.
The default implementation should be usable by everything that's not the watch_hook.
:param resource: referencing resource
... |
cache_secret: stash the SecretInfo from load_secret into Ambassador’s internal cache,
so that we don’t have to call load_secret again if we need it again. | def cache_secret(self, resource: 'IRResource', secret_info: SecretInfo) -> SavedSecret:
"""
cache_secret: stash the SecretInfo from load_secret into Ambassador’s internal cache,
so that we don’t have to call load_secret again if we need it again.
The default implementation should be usa... | [
"def",
"cache_secret",
"(",
"self",
",",
"resource",
":",
"'IRResource'",
",",
"secret_info",
":",
"SecretInfo",
")",
"->",
"SavedSecret",
":",
"name",
"=",
"secret_info",
".",
"name",
"namespace",
"=",
"secret_info",
".",
"namespace",
"tls_crt",
"=",
"secret_... | [
802,
4
] | [
821,
89
] | python | en | ['en', 'error', 'th'] | False |
SecretHandler.secret_info_from_k8s | (self, resource: 'IRResource',
secret_name: str, namespace: str, source: str,
serialization: Optional[str]) |
secret_info_from_k8s is NO LONGER USED.
|
secret_info_from_k8s is NO LONGER USED.
| def secret_info_from_k8s(self, resource: 'IRResource',
secret_name: str, namespace: str, source: str,
serialization: Optional[str]) -> Optional[SecretInfo]:
"""
secret_info_from_k8s is NO LONGER USED.
"""
objects: Optional[List[A... | [
"def",
"secret_info_from_k8s",
"(",
"self",
",",
"resource",
":",
"'IRResource'",
",",
"secret_name",
":",
"str",
",",
"namespace",
":",
"str",
",",
"source",
":",
"str",
",",
"serialization",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"Optional",
"[",
... | [
876,
4
] | [
938,
81
] | python | en | ['en', 'error', 'th'] | False |
NullSecretHandler.__init__ | (self, logger: logging.Logger, source_root: Optional[str], cache_dir: Optional[str], version: str) |
Returns a valid SecretInfo (with fake keys) for any requested secret. Also, you can pass
None for source_root and cache_dir to use random temporary directories for them.
|
Returns a valid SecretInfo (with fake keys) for any requested secret. Also, you can pass
None for source_root and cache_dir to use random temporary directories for them.
| def __init__(self, logger: logging.Logger, source_root: Optional[str], cache_dir: Optional[str], version: str) -> None:
"""
Returns a valid SecretInfo (with fake keys) for any requested secret. Also, you can pass
None for source_root and cache_dir to use random temporary directories for them.
... | [
"def",
"__init__",
"(",
"self",
",",
"logger",
":",
"logging",
".",
"Logger",
",",
"source_root",
":",
"Optional",
"[",
"str",
"]",
",",
"cache_dir",
":",
"Optional",
"[",
"str",
"]",
",",
"version",
":",
"str",
")",
"->",
"None",
":",
"if",
"not",
... | [
942,
4
] | [
958,
65
] | python | en | ['en', 'error', 'th'] | False |
_format_map_output | (
result_format,
success,
element_count,
nonnull_count,
unexpected_count,
unexpected_list,
unexpected_index_list,
) | Helper function to construct expectation result objects for map_expectations (such as column_map_expectation
and file_lines_map_expectation).
Expectations support four result_formats: BOOLEAN_ONLY, BASIC, SUMMARY, and COMPLETE.
In each case, the object returned has a different set of populated fields.
... | Helper function to construct expectation result objects for map_expectations (such as column_map_expectation
and file_lines_map_expectation). | def _format_map_output(
result_format,
success,
element_count,
nonnull_count,
unexpected_count,
unexpected_list,
unexpected_index_list,
):
"""Helper function to construct expectation result objects for map_expectations (such as column_map_expectation
and file_lines_map_expectation).
... | [
"def",
"_format_map_output",
"(",
"result_format",
",",
"success",
",",
"element_count",
",",
"nonnull_count",
",",
"unexpected_count",
",",
"unexpected_list",
",",
"unexpected_index_list",
",",
")",
":",
"# NB: unexpected_count parameter is explicit some implementing classes m... | [
1576,
0
] | [
1687,
88
] | python | en | ['en', 'en', 'en'] | True |
Expectation._build_evr | (self, raw_response, configuration) | _build_evr is a lightweight convenience wrapper handling cases where an Expectation implementor
fails to return an EVR but returns the necessary components in a dictionary. | _build_evr is a lightweight convenience wrapper handling cases where an Expectation implementor
fails to return an EVR but returns the necessary components in a dictionary. | def _build_evr(self, raw_response, configuration):
"""_build_evr is a lightweight convenience wrapper handling cases where an Expectation implementor
fails to return an EVR but returns the necessary components in a dictionary."""
if not isinstance(raw_response, ExpectationValidationResult):
... | [
"def",
"_build_evr",
"(",
"self",
",",
"raw_response",
",",
"configuration",
")",
":",
"if",
"not",
"isinstance",
"(",
"raw_response",
",",
"ExpectationValidationResult",
")",
":",
"if",
"isinstance",
"(",
"raw_response",
",",
"dict",
")",
":",
"evr",
"=",
"... | [
518,
4
] | [
530,
18
] | python | en | ['en', 'en', 'en'] | True |
Expectation.get_validation_dependencies | (
self,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[dict] = None,
) | Returns the result format and metrics required to validate this Expectation using the provided result format. | Returns the result format and metrics required to validate this Expectation using the provided result format. | def get_validation_dependencies(
self,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[dict] = None,
):
"""Returns the result format and metrics required to validate this Expectation... | [
"def",
"get_validation_dependencies",
"(",
"self",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
"=",
"None",
",",
"execution_engine",
":",
"Optional",
"[",
"ExecutionEngine",
"]",
"=",
"None",
",",
"runtime_configuration",
":",
"Optio... | [
532,
4
] | [
547,
9
] | python | en | ['en', 'en', 'en'] | True |
Expectation.run_diagnostics | (self, pretty_print=True) |
Produce a diagnostic report about this expectation.
The current uses for this method's output are
using the JSON structure to populate the Public Expectation Gallery
and enabling a fast devloop for developing new expectations where the
contributors can quickly check the complete... |
Produce a diagnostic report about this expectation.
The current uses for this method's output are
using the JSON structure to populate the Public Expectation Gallery
and enabling a fast devloop for developing new expectations where the
contributors can quickly check the complete... | def run_diagnostics(self, pretty_print=True):
"""
Produce a diagnostic report about this expectation.
The current uses for this method's output are
using the JSON structure to populate the Public Expectation Gallery
and enabling a fast devloop for developing new expectations wher... | [
"def",
"run_diagnostics",
"(",
"self",
",",
"pretty_print",
"=",
"True",
")",
":",
"camel_name",
"=",
"self",
".",
"__class__",
".",
"__name__",
"snake_name",
"=",
"camel_to_snake",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"docstring",
",",
"shor... | [
687,
4
] | [
811,
25
] | python | en | ['en', 'error', 'th'] | False |
Expectation._get_examples | (self, return_only_gallery_examples=True) |
Get a list of examples from the object's `examples` member variable.
:param return_only_gallery_examples: if True, include only test examples where `include_in_gallery` is true
:return: list of examples or [], if no examples exist
|
Get a list of examples from the object's `examples` member variable. | def _get_examples(self, return_only_gallery_examples=True) -> List[Dict]:
"""
Get a list of examples from the object's `examples` member variable.
:param return_only_gallery_examples: if True, include only test examples where `include_in_gallery` is true
:return: list of examples or [],... | [
"def",
"_get_examples",
"(",
"self",
",",
"return_only_gallery_examples",
"=",
"True",
")",
"->",
"List",
"[",
"Dict",
"]",
":",
"try",
":",
"all_examples",
"=",
"self",
".",
"examples",
"except",
"AttributeError",
":",
"return",
"[",
"]",
"included_examples",... | [
830,
4
] | [
859,
32
] | python | en | ['en', 'error', 'th'] | False |
ExpectColumnToExist.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... | [
71,
4
] | [
102,
19
] | python | en | ['en', 'error', 'th'] | False |
Explainer.__init__ | (self, method, control_name, X, tau, classes, model_tau=None,
features=None, normalize=True, test_size=0.3, random_state=None, override_checks=False,
r_learners=None) |
The Explainer class handles all feature explanation/interpretation functions, including plotting
feature importances, shapley value distributions, and shapley value dependency plots.
Currently supported methods are:
- auto (calculates importance based on estimator's default impleme... |
The Explainer class handles all feature explanation/interpretation functions, including plotting
feature importances, shapley value distributions, and shapley value dependency plots. | def __init__(self, method, control_name, X, tau, classes, model_tau=None,
features=None, normalize=True, test_size=0.3, random_state=None, override_checks=False,
r_learners=None):
"""
The Explainer class handles all feature explanation/interpretation functions, includin... | [
"def",
"__init__",
"(",
"self",
",",
"method",
",",
"control_name",
",",
"X",
",",
"tau",
",",
"classes",
",",
"model_tau",
"=",
"None",
",",
"features",
"=",
"None",
",",
"normalize",
"=",
"True",
",",
"test_size",
"=",
"0.3",
",",
"random_state",
"="... | [
14,
4
] | [
65,
39
] | python | en | ['en', 'error', 'th'] | False |
Explainer.check_conditions | (self) |
Checks for multiple conditions:
- method is valid
- X, tau, and classes are specified
- model_tau has feature_importances_ attribute after fitting
|
Checks for multiple conditions:
- method is valid
- X, tau, and classes are specified
- model_tau has feature_importances_ attribute after fitting
| def check_conditions(self):
"""
Checks for multiple conditions:
- method is valid
- X, tau, and classes are specified
- model_tau has feature_importances_ attribute after fitting
"""
assert self.method in VALID_METHODS, 'Current supported methods: {}'.... | [
"def",
"check_conditions",
"(",
"self",
")",
":",
"assert",
"self",
".",
"method",
"in",
"VALID_METHODS",
",",
"'Current supported methods: {}'",
".",
"format",
"(",
"', '",
".",
"join",
"(",
"VALID_METHODS",
")",
")",
"assert",
"all",
"(",
"obj",
"is",
"not... | [
67,
4
] | [
82,
81
] | python | en | ['en', 'error', 'th'] | False |
Explainer.create_feature_names | (self) |
Creates feature names (simple enumerated list) if not provided in __init__.
|
Creates feature names (simple enumerated list) if not provided in __init__.
| def create_feature_names(self):
"""
Creates feature names (simple enumerated list) if not provided in __init__.
"""
if self.features is None:
num_features = self.X.shape[1]
self.features = ['Feature_{:03d}'.format(i) for i in range(num_features)] | [
"def",
"create_feature_names",
"(",
"self",
")",
":",
"if",
"self",
".",
"features",
"is",
"None",
":",
"num_features",
"=",
"self",
".",
"X",
".",
"shape",
"[",
"1",
"]",
"self",
".",
"features",
"=",
"[",
"'Feature_{:03d}'",
".",
"format",
"(",
"i",
... | [
84,
4
] | [
90,
85
] | python | en | ['en', 'error', 'th'] | False |
Explainer.build_new_tau_models | (self) |
Builds tau models (using X to predict estimated/actual tau) for each treatment group.
|
Builds tau models (using X to predict estimated/actual tau) for each treatment group.
| def build_new_tau_models(self):
"""
Builds tau models (using X to predict estimated/actual tau) for each treatment group.
"""
if self.method in ('permutation'):
self.X_train, self.X_test, self.tau_train, self.tau_test = train_test_split(self.X,
... | [
"def",
"build_new_tau_models",
"(",
"self",
")",
":",
"if",
"self",
".",
"method",
"in",
"(",
"'permutation'",
")",
":",
"self",
".",
"X_train",
",",
"self",
".",
"X_test",
",",
"self",
".",
"tau_train",
",",
"self",
".",
"tau_test",
"=",
"train_test_spl... | [
92,
4
] | [
109,
80
] | python | en | ['en', 'error', 'th'] | False |
Explainer.get_importance | (self) |
Calculates feature importances for each treatment group, based on specified method in __init__.
|
Calculates feature importances for each treatment group, based on specified method in __init__.
| def get_importance(self):
"""
Calculates feature importances for each treatment group, based on specified method in __init__.
"""
importance_catalog = {'auto': self.default_importance, 'permutation': self.perm_importance}
importance_dict = importance_catalog[self.method]()
... | [
"def",
"get_importance",
"(",
"self",
")",
":",
"importance_catalog",
"=",
"{",
"'auto'",
":",
"self",
".",
"default_importance",
",",
"'permutation'",
":",
"self",
".",
"perm_importance",
"}",
"importance_dict",
"=",
"importance_catalog",
"[",
"self",
".",
"met... | [
111,
4
] | [
120,
30
] | python | en | ['en', 'error', 'th'] | False |
Explainer.default_importance | (self) |
Calculates feature importances for each treatment group, based on the model_tau's default implementation.
|
Calculates feature importances for each treatment group, based on the model_tau's default implementation.
| def default_importance(self):
"""
Calculates feature importances for each treatment group, based on the model_tau's default implementation.
"""
importance_dict = {}
if self.r_learners is not None:
self.models_tau = deepcopy(self.r_learners)
for group, idx in s... | [
"def",
"default_importance",
"(",
"self",
")",
":",
"importance_dict",
"=",
"{",
"}",
"if",
"self",
".",
"r_learners",
"is",
"not",
"None",
":",
"self",
".",
"models_tau",
"=",
"deepcopy",
"(",
"self",
".",
"r_learners",
")",
"for",
"group",
",",
"idx",
... | [
122,
4
] | [
134,
30
] | python | en | ['en', 'error', 'th'] | False |
Explainer.perm_importance | (self) |
Calculates feature importances for each treatment group, based on the permutation method.
|
Calculates feature importances for each treatment group, based on the permutation method.
| def perm_importance(self):
"""
Calculates feature importances for each treatment group, based on the permutation method.
"""
importance_dict = {}
if self.r_learners is not None:
self.models_tau = deepcopy(self.r_learners)
self.X_test, self.tau_test = self.... | [
"def",
"perm_importance",
"(",
"self",
")",
":",
"importance_dict",
"=",
"{",
"}",
"if",
"self",
".",
"r_learners",
"is",
"not",
"None",
":",
"self",
".",
"models_tau",
"=",
"deepcopy",
"(",
"self",
".",
"r_learners",
")",
"self",
".",
"X_test",
",",
"... | [
136,
4
] | [
151,
30
] | python | en | ['en', 'error', 'th'] | False |
Explainer.get_shap_values | (self) |
Calculates shapley values for each treatment group.
|
Calculates shapley values for each treatment group.
| def get_shap_values(self):
"""
Calculates shapley values for each treatment group.
"""
shap_dict = {}
for group, mod in self.models_tau.items():
explainer = shap.TreeExplainer(mod)
if self.r_learners is not None:
explainer.model.original_mo... | [
"def",
"get_shap_values",
"(",
"self",
")",
":",
"shap_dict",
"=",
"{",
"}",
"for",
"group",
",",
"mod",
"in",
"self",
".",
"models_tau",
".",
"items",
"(",
")",
":",
"explainer",
"=",
"shap",
".",
"TreeExplainer",
"(",
"mod",
")",
"if",
"self",
".",... | [
153,
4
] | [
165,
24
] | python | en | ['en', 'error', 'th'] | False |
Explainer.plot_importance | (self, importance_dict=None, title_prefix='') |
Calculates and plots feature importances for each treatment group, based on specified method in __init__.
Skips the calculation part if importance_dict is given.
|
Calculates and plots feature importances for each treatment group, based on specified method in __init__.
Skips the calculation part if importance_dict is given.
| def plot_importance(self, importance_dict=None, title_prefix=''):
"""
Calculates and plots feature importances for each treatment group, based on specified method in __init__.
Skips the calculation part if importance_dict is given.
"""
if importance_dict is None:
impo... | [
"def",
"plot_importance",
"(",
"self",
",",
"importance_dict",
"=",
"None",
",",
"title_prefix",
"=",
"''",
")",
":",
"if",
"importance_dict",
"is",
"None",
":",
"importance_dict",
"=",
"self",
".",
"get_importance",
"(",
")",
"for",
"group",
",",
"series",
... | [
167,
4
] | [
180,
28
] | python | en | ['en', 'error', 'th'] | False |
Explainer.plot_shap_values | (self, shap_dict=None) |
Calculates and plots the distribution of shapley values of each feature, for each treatment group.
Skips the calculation part if shap_dict is given.
|
Calculates and plots the distribution of shapley values of each feature, for each treatment group.
Skips the calculation part if shap_dict is given.
| def plot_shap_values(self, shap_dict=None):
"""
Calculates and plots the distribution of shapley values of each feature, for each treatment group.
Skips the calculation part if shap_dict is given.
"""
if shap_dict is None:
shap_dict = self.get_shap_values()
f... | [
"def",
"plot_shap_values",
"(",
"self",
",",
"shap_dict",
"=",
"None",
")",
":",
"if",
"shap_dict",
"is",
"None",
":",
"shap_dict",
"=",
"self",
".",
"get_shap_values",
"(",
")",
"for",
"group",
",",
"values",
"in",
"shap_dict",
".",
"items",
"(",
")",
... | [
182,
4
] | [
192,
83
] | python | en | ['en', 'error', 'th'] | False |
Explainer.plot_shap_dependence | (self, treatment_group, feature_idx, shap_dict=None, interaction_idx='auto', **kwargs) |
Plots dependency of shapley values for a specified feature, colored by an interaction feature.
Skips the calculation part if shap_dict is given.
This plots the value of the feature on the x-axis and the SHAP value of the same feature
on the y-axis. This shows how the model depends on t... |
Plots dependency of shapley values for a specified feature, colored by an interaction feature.
Skips the calculation part if shap_dict is given. | def plot_shap_dependence(self, treatment_group, feature_idx, shap_dict=None, interaction_idx='auto', **kwargs):
"""
Plots dependency of shapley values for a specified feature, colored by an interaction feature.
Skips the calculation part if shap_dict is given.
This plots the value of th... | [
"def",
"plot_shap_dependence",
"(",
"self",
",",
"treatment_group",
",",
"feature_idx",
",",
"shap_dict",
"=",
"None",
",",
"interaction_idx",
"=",
"'auto'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"shap_dict",
"is",
"None",
":",
"shap_dict",
"=",
"self",
... | [
194,
4
] | [
219,
67
] | python | en | ['en', 'error', 'th'] | False |
create_connection | (db_file) | create a database connection to the SQLite database
specified by the db_file
:param db_file: database file
:return: Connection object or None
| create a database connection to the SQLite database
specified by the db_file
:param db_file: database file
:return: Connection object or None
| def create_connection(db_file):
""" create a database connection to the SQLite database
specified by the db_file
:param db_file: database file
:return: Connection object or None
"""
try:
conn = sqlite3.connect(db_file)
return conn
except sqlite3.Error as e:
loggin... | [
"def",
"create_connection",
"(",
"db_file",
")",
":",
"try",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"db_file",
")",
"return",
"conn",
"except",
"sqlite3",
".",
"Error",
"as",
"e",
":",
"logging",
".",
"warn",
"(",
"'Sqlite3 connection Error: {}'",... | [
27,
0
] | [
40,
15
] | python | en | ['en', 'en', 'en'] | True |
select_dly_flows_by_station_ID | (conn, station) |
Query tasks by priority
:param conn: the Connection object
:param station: station number (ID) according to WSC convention
:return: dataframe object of daily flows
|
Query tasks by priority
:param conn: the Connection object
:param station: station number (ID) according to WSC convention
:return: dataframe object of daily flows
| def select_dly_flows_by_station_ID(conn, station):
"""
Query tasks by priority
:param conn: the Connection object
:param station: station number (ID) according to WSC convention
:return: dataframe object of daily flows
"""
time0 = time.time()
cur = conn.cursor()
cur.execute("SELECT *... | [
"def",
"select_dly_flows_by_station_ID",
"(",
"conn",
",",
"station",
")",
":",
"time0",
"=",
"time",
".",
"time",
"(",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"\"SELECT * FROM DLY_FLOWS WHERE STATION_NUMBER=?\"",
",",
"("... | [
71,
0
] | [
131,
19
] | python | en | ['en', 'error', 'th'] | False |
get_xyz_distance | (lat, lon, target) |
Converts lat/lon to x, y, z.
Does not account for elevation of target location.
Just assumes stations are at same elevation
|
Converts lat/lon to x, y, z.
Does not account for elevation of target location.
Just assumes stations are at same elevation
| def get_xyz_distance(lat, lon, target):
"""
Converts lat/lon to x, y, z.
Does not account for elevation of target location.
Just assumes stations are at same elevation
"""
r = 6378137 + target.Elevation
x = r * np.cos(deg2rad(lat)) * np.cos(deg2rad(lon))
y = r * np.cos(deg2rad(lat)) * np... | [
"def",
"get_xyz_distance",
"(",
"lat",
",",
"lon",
",",
"target",
")",
":",
"r",
"=",
"6378137",
"+",
"target",
".",
"Elevation",
"x",
"=",
"r",
"*",
"np",
".",
"cos",
"(",
"deg2rad",
"(",
"lat",
")",
")",
"*",
"np",
".",
"cos",
"(",
"deg2rad",
... | [
139,
0
] | [
150,
73
] | python | en | ['en', 'error', 'th'] | False |
export_slice_to_geotiff | (ds, path) |
Exports a single slice of an xarray.Dataset as a GeoTIFF.
ds: xarray.Dataset
The Dataset to export.
path: str
The path to store the exported GeoTIFF.
|
Exports a single slice of an xarray.Dataset as a GeoTIFF.
ds: xarray.Dataset
The Dataset to export.
path: str
The path to store the exported GeoTIFF.
| def export_slice_to_geotiff(ds, path):
"""
Exports a single slice of an xarray.Dataset as a GeoTIFF.
ds: xarray.Dataset
The Dataset to export.
path: str
The path to store the exported GeoTIFF.
"""
kwargs = dict(tif_path=path, dataset=ds.astype(np.float32), bands=list(ds.data... | [
"def",
"export_slice_to_geotiff",
"(",
"ds",
",",
"path",
")",
":",
"kwargs",
"=",
"dict",
"(",
"tif_path",
"=",
"path",
",",
"dataset",
"=",
"ds",
".",
"astype",
"(",
"np",
".",
"float32",
")",
",",
"bands",
"=",
"list",
"(",
"ds",
".",
"data_vars",... | [
10,
0
] | [
22,
48
] | python | en | ['en', 'error', 'th'] | False |
export_xarray_to_geotiff | (ds, path) |
Exports an xarray.Dataset as individual time slices.
Parameters
----------
ds: xarray.Dataset
The Dataset to export.
path: str
The path prefix to store the exported GeoTIFFs. For example, 'geotiffs/mydata' would result in files named like
'mydata_2016_12_05_12_31_36.tif... |
Exports an xarray.Dataset as individual time slices.
Parameters
----------
ds: xarray.Dataset
The Dataset to export.
path: str
The path prefix to store the exported GeoTIFFs. For example, 'geotiffs/mydata' would result in files named like
'mydata_2016_12_05_12_31_36.tif... | def export_xarray_to_geotiff(ds, path):
"""
Exports an xarray.Dataset as individual time slices.
Parameters
----------
ds: xarray.Dataset
The Dataset to export.
path: str
The path prefix to store the exported GeoTIFFs. For example, 'geotiffs/mydata' would result in files nam... | [
"def",
"export_xarray_to_geotiff",
"(",
"ds",
",",
"path",
")",
":",
"def",
"time_to_string",
"(",
"t",
")",
":",
"return",
"time",
".",
"strftime",
"(",
"\"%Y_%m_%d_%H_%M_%S\"",
",",
"time",
".",
"gmtime",
"(",
"t",
".",
"astype",
"(",
"int",
")",
"/",
... | [
24,
0
] | [
42,
72
] | python | en | ['en', 'error', 'th'] | False |
prepare_virtualenv | (packages=()) |
Prepares a virtual environment.
:rtype : VirtualEnvDescription
|
Prepares a virtual environment.
:rtype : VirtualEnvDescription
| def prepare_virtualenv(packages=()):
"""
Prepares a virtual environment.
:rtype : VirtualEnvDescription
"""
vroot = get_vroot()
env_key = get_env_key(packages)
vdir = os.path.join(vroot, env_key)
vbin = os.path.join(vdir, ('bin', 'Scripts')[_windows])
vpython = os.path.join(vbin, 'p... | [
"def",
"prepare_virtualenv",
"(",
"packages",
"=",
"(",
")",
")",
":",
"vroot",
"=",
"get_vroot",
"(",
")",
"env_key",
"=",
"get_env_key",
"(",
"packages",
")",
"vdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"vroot",
",",
"env_key",
")",
"vbin",
"... | [
44,
0
] | [
88,
27
] | python | en | ['en', 'error', 'th'] | False |
ColumnDistributionMatchesBenfordsLaw._pandas | (cls, column, **kwargs) |
listdata: length 10
matchvalues: length 10
chi square them with 90 percent confidence
|
listdata: length 10
matchvalues: length 10
chi square them with 90 percent confidence
| def _pandas(cls, column, **kwargs):
totalVals = (column.apply(lambda x: 1.0 if x is not None else 0.0)).sum()
num1 = (
column.apply(lambda x: matchFirstDigit(x, 1) if x is not None else 0.0)
).sum()
num2 = (
column.apply(lambda x: matchFirstDigit(x, 2) if x is not... | [
"def",
"_pandas",
"(",
"cls",
",",
"column",
",",
"*",
"*",
"kwargs",
")",
":",
"totalVals",
"=",
"(",
"column",
".",
"apply",
"(",
"lambda",
"x",
":",
"1.0",
"if",
"x",
"is",
"not",
"None",
"else",
"0.0",
")",
")",
".",
"sum",
"(",
")",
"num1"... | [
80,
4
] | [
137,
23
] | python | en | ['en', 'error', 'th'] | False |
ColumnDistributionMatchesBenfordsLaw._get_evaluation_dependencies | (
cls,
metric: MetricConfiguration,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[dict] = None,
) | This should return a dictionary:
{
"dependency_name": MetricConfiguration,
...
}
| This should return a dictionary: | def _get_evaluation_dependencies(
cls,
metric: MetricConfiguration,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[dict] = None,
):
"""This should return a dictionary:
... | [
"def",
"_get_evaluation_dependencies",
"(",
"cls",
",",
"metric",
":",
"MetricConfiguration",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
"=",
"None",
",",
"execution_engine",
":",
"Optional",
"[",
"ExecutionEngine",
"]",
"=",
"None"... | [
191,
4
] | [
230,
27
] | python | en | ['en', 'en', 'en'] | True |
ColumnMostCommonValue._get_evaluation_dependencies | (
cls,
metric: MetricConfiguration,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[Dict] = None,
) | Returns a dictionary of given metric names and their corresponding configuration,
specifying the metric types and their respective domains | Returns a dictionary of given metric names and their corresponding configuration,
specifying the metric types and their respective domains | def _get_evaluation_dependencies(
cls,
metric: MetricConfiguration,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[Dict] = None,
):
"""Returns a dictionary of given metric n... | [
"def",
"_get_evaluation_dependencies",
"(",
"cls",
",",
"metric",
":",
"MetricConfiguration",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
"=",
"None",
",",
"execution_engine",
":",
"Optional",
"[",
"ExecutionEngine",
"]",
"=",
"None"... | [
59,
4
] | [
87,
27
] | python | en | ['en', 'en', 'en'] | True |
MasterQA.auto_close_results | (self) | If this method is called, the results page will automatically close
at the end of the test run, rather than waiting on the user to close
the results page manually.
| If this method is called, the results page will automatically close
at the end of the test run, rather than waiting on the user to close
the results page manually.
| def auto_close_results(self):
''' If this method is called, the results page will automatically close
at the end of the test run, rather than waiting on the user to close
the results page manually.
'''
self.auto_close_results_page = True | [
"def",
"auto_close_results",
"(",
"self",
")",
":",
"self",
".",
"auto_close_results_page",
"=",
"True"
] | [
49,
4
] | [
54,
43
] | python | en | ['en', 'en', 'en'] | True |
ColumnValuesZScore._get_evaluation_dependencies | (
cls,
metric: MetricConfiguration,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[dict] = None,
) | Returns a dictionary of given metric names and their corresponding configuration, specifying the metric
types and their respective domains | Returns a dictionary of given metric names and their corresponding configuration, specifying the metric
types and their respective domains | def _get_evaluation_dependencies(
cls,
metric: MetricConfiguration,
configuration: Optional[ExpectationConfiguration] = None,
execution_engine: Optional[ExecutionEngine] = None,
runtime_configuration: Optional[dict] = None,
):
"""Returns a dictionary of given metric n... | [
"def",
"_get_evaluation_dependencies",
"(",
"cls",
",",
"metric",
":",
"MetricConfiguration",
",",
"configuration",
":",
"Optional",
"[",
"ExpectationConfiguration",
"]",
"=",
"None",
",",
"execution_engine",
":",
"Optional",
"[",
"ExecutionEngine",
"]",
"=",
"None"... | [
99,
4
] | [
131,
27
] | python | en | ['en', 'en', 'en'] | True |
SparkDFDatasource.build_configuration | (
cls,
data_asset_type=None,
batch_kwargs_generators=None,
spark_config=None,
force_reuse_spark_context=False,
**kwargs
) |
Build a full configuration object for a datasource, potentially including generators with defaults.
Args:
data_asset_type: A ClassConfig dictionary
batch_kwargs_generators: Generator configuration dictionary
spark_config: dictionary of key-value pairs to pass to the... |
Build a full configuration object for a datasource, potentially including generators with defaults. | def build_configuration(
cls,
data_asset_type=None,
batch_kwargs_generators=None,
spark_config=None,
force_reuse_spark_context=False,
**kwargs
):
"""
Build a full configuration object for a datasource, potentially including generators with defaults.
... | [
"def",
"build_configuration",
"(",
"cls",
",",
"data_asset_type",
"=",
"None",
",",
"batch_kwargs_generators",
"=",
"None",
",",
"spark_config",
"=",
"None",
",",
"force_reuse_spark_context",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"data_asset_typ... | [
64,
4
] | [
109,
28
] | python | en | ['en', 'error', 'th'] | False |
SparkDFDatasource.__init__ | (
self,
name="default",
data_context=None,
data_asset_type=None,
batch_kwargs_generators=None,
spark_config=None,
force_reuse_spark_context=False,
**kwargs
) | Build a new SparkDFDatasource instance.
Args:
name: the name of this datasource
data_context: the DataContext to which this datasource is connected
data_asset_type: ClassConfig describing the data_asset type to be constructed by this datasource
batch_kwargs_gener... | Build a new SparkDFDatasource instance. | def __init__(
self,
name="default",
data_context=None,
data_asset_type=None,
batch_kwargs_generators=None,
spark_config=None,
force_reuse_spark_context=False,
**kwargs
):
"""Build a new SparkDFDatasource instance.
Args:
nam... | [
"def",
"__init__",
"(",
"self",
",",
"name",
"=",
"\"default\"",
",",
"data_context",
"=",
"None",
",",
"data_asset_type",
"=",
"None",
",",
"batch_kwargs_generators",
"=",
"None",
",",
"spark_config",
"=",
"None",
",",
"force_reuse_spark_context",
"=",
"False",... | [
111,
4
] | [
158,
32
] | python | en | ['en', 'lb', 'en'] | True |
SparkDFDatasource.get_batch | (self, batch_kwargs, batch_parameters=None) | class-private implementation of get_data_asset | class-private implementation of get_data_asset | def get_batch(self, batch_kwargs, batch_parameters=None):
"""class-private implementation of get_data_asset"""
if self.spark is None:
logger.error("No spark session available")
return None
reader_options = batch_kwargs.get("reader_options", {})
# We need to buil... | [
"def",
"get_batch",
"(",
"self",
",",
"batch_kwargs",
",",
"batch_parameters",
"=",
"None",
")",
":",
"if",
"self",
".",
"spark",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"No spark session available\"",
")",
"return",
"None",
"reader_options",
"=",
... | [
180,
4
] | [
247,
9
] | python | en | ['en', 'en', 'en'] | True |
SparkDFDatasource._get_reader_fn | (self, reader, reader_method=None, path=None) | Static helper for providing reader_fn
Args:
reader: the base spark reader to use; this should have had reader_options applied already
reader_method: the name of the reader_method to use, if specified
path (str): the path to use to guess reader_method if it was not specified
... | Static helper for providing reader_fn | def _get_reader_fn(self, reader, reader_method=None, path=None):
"""Static helper for providing reader_fn
Args:
reader: the base spark reader to use; this should have had reader_options applied already
reader_method: the name of the reader_method to use, if specified
... | [
"def",
"_get_reader_fn",
"(",
"self",
",",
"reader",
",",
"reader_method",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"reader_method",
"is",
"None",
"and",
"path",
"is",
"None",
":",
"raise",
"BatchKwargsError",
"(",
"\"Unable to determine spark re... | [
260,
4
] | [
292,
13
] | python | en | ['en', 'no', 'en'] | True |
Logs.get_local_logger | (self, name, log_file) | Returns a local logger with a file handler. | Returns a local logger with a file handler. | def get_local_logger(self, name, log_file):
"""Returns a local logger with a file handler."""
handler = RotatingFileHandler(log_file, maxBytes=MAX_LOG_BYTES)
handler.setFormatter(Formatter(LOGS_FORMAT))
handler.setLevel(DEBUG)
logger = getLogger(name)
logger.setLevel(DE... | [
"def",
"get_local_logger",
"(",
"self",
",",
"name",
",",
"log_file",
")",
":",
"handler",
"=",
"RotatingFileHandler",
"(",
"log_file",
",",
"maxBytes",
"=",
"MAX_LOG_BYTES",
")",
"handler",
".",
"setFormatter",
"(",
"Formatter",
"(",
"LOGS_FORMAT",
")",
")",
... | [
52,
4
] | [
63,
32
] | python | en | ['en', 'en', 'en'] | True |
Logs.debug | (self, text) | Logs at the DEBUG level. | Logs at the DEBUG level. | def debug(self, text):
"""Logs at the DEBUG level."""
if self.to_cloud:
self.safe_cloud_log_text(text, severity='DEBUG')
else:
self.local_logger.debug(text) | [
"def",
"debug",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"to_cloud",
":",
"self",
".",
"safe_cloud_log_text",
"(",
"text",
",",
"severity",
"=",
"'DEBUG'",
")",
"else",
":",
"self",
".",
"local_logger",
".",
"debug",
"(",
"text",
")"
] | [
65,
4
] | [
71,
41
] | python | en | ['en', 'en', 'en'] | True |
Logs.info | (self, text) | Logs at the INFO level. | Logs at the INFO level. | def info(self, text):
"""Logs at the INFO level."""
if self.to_cloud:
self.safe_cloud_log_text(text, severity='INFO')
else:
self.local_logger.info(text) | [
"def",
"info",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"to_cloud",
":",
"self",
".",
"safe_cloud_log_text",
"(",
"text",
",",
"severity",
"=",
"'INFO'",
")",
"else",
":",
"self",
".",
"local_logger",
".",
"info",
"(",
"text",
")"
] | [
73,
4
] | [
79,
40
] | python | en | ['en', 'en', 'en'] | True |
Logs.warn | (self, text) | Logs at the WARNING level. | Logs at the WARNING level. | def warn(self, text):
"""Logs at the WARNING level."""
if self.to_cloud:
self.safe_cloud_log_text(text, severity='WARNING')
else:
self.local_logger.warning(text) | [
"def",
"warn",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"to_cloud",
":",
"self",
".",
"safe_cloud_log_text",
"(",
"text",
",",
"severity",
"=",
"'WARNING'",
")",
"else",
":",
"self",
".",
"local_logger",
".",
"warning",
"(",
"text",
")"
] | [
81,
4
] | [
87,
43
] | python | en | ['en', 'en', 'en'] | True |
Logs.error | (self, text) | Logs at the ERROR level. | Logs at the ERROR level. | def error(self, text):
"""Logs at the ERROR level."""
if self.to_cloud:
self.safe_cloud_log_text(text, severity='ERROR')
else:
self.local_logger.error(text) | [
"def",
"error",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"to_cloud",
":",
"self",
".",
"safe_cloud_log_text",
"(",
"text",
",",
"severity",
"=",
"'ERROR'",
")",
"else",
":",
"self",
".",
"local_logger",
".",
"error",
"(",
"text",
")"
] | [
89,
4
] | [
95,
41
] | python | en | ['en', 'en', 'en'] | True |
Logs.catch | (self) | Logs the latest exception. | Logs the latest exception. | def catch(self):
"""Logs the latest exception."""
exception_str = self.format_exception()
if self.to_cloud:
self.safe_report_exception(exception_str)
self.safe_cloud_log_text(exception_str, severity='CRITICAL')
else:
self.local_logger.critical(except... | [
"def",
"catch",
"(",
"self",
")",
":",
"exception_str",
"=",
"self",
".",
"format_exception",
"(",
")",
"if",
"self",
".",
"to_cloud",
":",
"self",
".",
"safe_report_exception",
"(",
"exception_str",
")",
"self",
".",
"safe_cloud_log_text",
"(",
"exception_str... | [
97,
4
] | [
106,
53
] | python | en | ['en', 'en', 'en'] | True |
Logs.safe_cloud_log_text | (self, text, severity) | Logs to the cloud, retries if necessary, and eventually fails over
to local logs.
| Logs to the cloud, retries if necessary, and eventually fails over
to local logs.
| def safe_cloud_log_text(self, text, severity):
"""Logs to the cloud, retries if necessary, and eventually fails over
to local logs.
"""
try:
self.retry_cloud_log_text(text, severity)
except Exception:
exception_str = self.format_exception()
se... | [
"def",
"safe_cloud_log_text",
"(",
"self",
",",
"text",
",",
"severity",
")",
":",
"try",
":",
"self",
".",
"retry_cloud_log_text",
"(",
"text",
",",
"severity",
")",
"except",
"Exception",
":",
"exception_str",
"=",
"self",
".",
"format_exception",
"(",
")"... | [
108,
4
] | [
118,
71
] | python | en | ['en', 'en', 'en'] | True |
Logs.retry_cloud_log_text | (self, text, severity) | Logs to the cloud and retries up to 10 times with exponential
backoff (51.2 seconds max total) if the upload fails.
| Logs to the cloud and retries up to 10 times with exponential
backoff (51.2 seconds max total) if the upload fails.
| def retry_cloud_log_text(self, text, severity):
"""Logs to the cloud and retries up to 10 times with exponential
backoff (51.2 seconds max total) if the upload fails.
"""
self.cloud_logger.log_text(text, severity=severity) | [
"def",
"retry_cloud_log_text",
"(",
"self",
",",
"text",
",",
"severity",
")",
":",
"self",
".",
"cloud_logger",
".",
"log_text",
"(",
"text",
",",
"severity",
"=",
"severity",
")"
] | [
121,
4
] | [
126,
59
] | python | en | ['en', 'en', 'en'] | True |
Logs.safe_report_exception | (self, exception_str) | Reports the exception, retries if necessary, and eventually fails
over to local logs.
| Reports the exception, retries if necessary, and eventually fails
over to local logs.
| def safe_report_exception(self, exception_str):
"""Reports the exception, retries if necessary, and eventually fails
over to local logs.
"""
try:
self.retry_report_exception(exception_str)
except Exception:
meta_exception_str = self.format_exception()
... | [
"def",
"safe_report_exception",
"(",
"self",
",",
"exception_str",
")",
":",
"try",
":",
"self",
".",
"retry_report_exception",
"(",
"exception_str",
")",
"except",
"Exception",
":",
"meta_exception_str",
"=",
"self",
".",
"format_exception",
"(",
")",
"self",
"... | [
128,
4
] | [
138,
75
] | python | en | ['en', 'en', 'en'] | True |
Logs.retry_report_exception | (self, exception_str) | Reports the exception and retries up to 10 times with exponential
backoff (51.2 seconds max total) if the upload fails.
| Reports the exception and retries up to 10 times with exponential
backoff (51.2 seconds max total) if the upload fails.
| def retry_report_exception(self, exception_str):
"""Reports the exception and retries up to 10 times with exponential
backoff (51.2 seconds max total) if the upload fails.
"""
self.error_client.report(exception_str) | [
"def",
"retry_report_exception",
"(",
"self",
",",
"exception_str",
")",
":",
"self",
".",
"error_client",
".",
"report",
"(",
"exception_str",
")"
] | [
141,
4
] | [
146,
47
] | python | en | ['en', 'en', 'en'] | True |
Logs.format_exception | (self) | Grabs the latest exception and formats it. | Grabs the latest exception and formats it. | def format_exception(self):
"""Grabs the latest exception and formats it."""
exc_type, exc_value, exc_traceback = exc_info()
exc_format = format_exception(exc_type, exc_value, exc_traceback)
return ''.join(exc_format).strip() | [
"def",
"format_exception",
"(",
"self",
")",
":",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
"=",
"exc_info",
"(",
")",
"exc_format",
"=",
"format_exception",
"(",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
")",
"return",
"''",
".",
"join",
... | [
148,
4
] | [
153,
42
] | python | en | ['en', 'en', 'en'] | True |
wrap | (func, *args, unsqueeze=False) |
Wrap a torch function so it can be called with NumPy arrays.
Input and return types are seamlessly converted.
|
Wrap a torch function so it can be called with NumPy arrays.
Input and return types are seamlessly converted.
| def wrap(func, *args, unsqueeze=False):
"""
Wrap a torch function so it can be called with NumPy arrays.
Input and return types are seamlessly converted.
"""
# Convert input types where applicable
args = list(args)
for i, arg in enumerate(args):
if type(arg) == np.ndarray:
... | [
"def",
"wrap",
"(",
"func",
",",
"*",
"args",
",",
"unsqueeze",
"=",
"False",
")",
":",
"# Convert input types where applicable",
"args",
"=",
"list",
"(",
"args",
")",
"for",
"i",
",",
"arg",
"in",
"enumerate",
"(",
"args",
")",
":",
"if",
"type",
"("... | [
4,
0
] | [
34,
21
] | python | en | ['en', 'error', 'th'] | False |
convert_to_dtype | (data, dtype) |
A utility function converting xarray, pandas, or NumPy data to a given dtype.
Parameters
----------
data: xarray.Dataset, xarray.DataArray, pandas.Series, pandas.DataFrame,
or numpy.ndarray
dtype: str or numpy.dtype
A string denoting a Python datatype name (e.g. int, float) or... |
A utility function converting xarray, pandas, or NumPy data to a given dtype. | def convert_to_dtype(data, dtype):
"""
A utility function converting xarray, pandas, or NumPy data to a given dtype.
Parameters
----------
data: xarray.Dataset, xarray.DataArray, pandas.Series, pandas.DataFrame,
or numpy.ndarray
dtype: str or numpy.dtype
A string denoting a... | [
"def",
"convert_to_dtype",
"(",
"data",
",",
"dtype",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"# Don't convert the data type.",
"return",
"data",
"return",
"data",
".",
"astype",
"(",
"dtype",
")"
] | [
34,
0
] | [
48,
29
] | python | en | ['en', 'error', 'th'] | False |
create_mosaic | (dataset_in, clean_mask=None, no_data=-9999, dtype=None, intermediate_product=None, **kwargs) |
Creates a most-recent-to-oldest mosaic of the input dataset.
Parameters
----------
dataset_in: xarray.Dataset
A dataset retrieved from the Data Cube; should contain:
coordinates: time, latitude, longitude
variables: variables to be mosaicked (e.g. red, green, and blue bands)
... |
Creates a most-recent-to-oldest mosaic of the input dataset. | def create_mosaic(dataset_in, clean_mask=None, no_data=-9999, dtype=None, intermediate_product=None, **kwargs):
"""
Creates a most-recent-to-oldest mosaic of the input dataset.
Parameters
----------
dataset_in: xarray.Dataset
A dataset retrieved from the Data Cube; should contain:
c... | [
"def",
"create_mosaic",
"(",
"dataset_in",
",",
"clean_mask",
"=",
"None",
",",
"no_data",
"=",
"-",
"9999",
",",
"dtype",
"=",
"None",
",",
"intermediate_product",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Default to masking nothing.",
"if",
"clean... | [
55,
0
] | [
117,
22
] | python | en | ['en', 'error', 'th'] | False |
create_mean_mosaic | (dataset_in, clean_mask=None, no_data=-9999, dtype=None, **kwargs) |
Method for calculating the mean pixel value for a given dataset.
Parameters
----------
dataset_in: xarray.Dataset
A dataset retrieved from the Data Cube; should contain:
coordinates: time, latitude, longitude
variables: variables to be mosaicked (e.g. red, green, and blue bands... |
Method for calculating the mean pixel value for a given dataset. | def create_mean_mosaic(dataset_in, clean_mask=None, no_data=-9999, dtype=None, **kwargs):
"""
Method for calculating the mean pixel value for a given dataset.
Parameters
----------
dataset_in: xarray.Dataset
A dataset retrieved from the Data Cube; should contain:
coordinates: time, ... | [
"def",
"create_mean_mosaic",
"(",
"dataset_in",
",",
"clean_mask",
"=",
"None",
",",
"no_data",
"=",
"-",
"9999",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Default to masking nothing.",
"if",
"clean_mask",
"is",
"None",
":",
"clean_mas... | [
119,
0
] | [
163,
22
] | python | en | ['en', 'error', 'th'] | False |
create_median_mosaic | (dataset_in, clean_mask=None, no_data=-9999, dtype=None, **kwargs) |
Method for calculating the median pixel value for a given dataset.
Parameters
----------
dataset_in: xarray.Dataset
A dataset retrieved from the Data Cube; should contain:
coordinates: time, latitude, longitude
variables: variables to be mosaicked (e.g. red, green, and blue ban... |
Method for calculating the median pixel value for a given dataset. | def create_median_mosaic(dataset_in, clean_mask=None, no_data=-9999, dtype=None, **kwargs):
"""
Method for calculating the median pixel value for a given dataset.
Parameters
----------
dataset_in: xarray.Dataset
A dataset retrieved from the Data Cube; should contain:
coordinates: ti... | [
"def",
"create_median_mosaic",
"(",
"dataset_in",
",",
"clean_mask",
"=",
"None",
",",
"no_data",
"=",
"-",
"9999",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Default to masking nothing.",
"if",
"clean_mask",
"is",
"None",
":",
"clean_m... | [
166,
0
] | [
210,
22
] | 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.