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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
variable_t._get__cmp__items | (self) | implementation details | implementation details | def _get__cmp__items(self):
"""implementation details"""
return [self.decl_type, self.type_qualifiers, self.value] | [
"def",
"_get__cmp__items",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"decl_type",
",",
"self",
".",
"type_qualifiers",
",",
"self",
".",
"value",
"]"
] | [
34,
4
] | [
36,
65
] | python | da | ['eo', 'da', 'en'] | False |
variable_t.__eq__ | (self, other) | implementation details | implementation details | def __eq__(self, other):
"""implementation details"""
if not declaration.declaration_t.__eq__(self, other):
return False
return self.decl_type == other.decl_type \
and self.type_qualifiers == other.type_qualifiers \
and self.value == other.value \
... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"declaration",
".",
"declaration_t",
".",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"return",
"False",
"return",
"self",
".",
"decl_type",
"==",
"other",
".",
"decl_type",
"and",
"... | [
38,
4
] | [
45,
39
] | python | da | ['eo', 'da', 'en'] | False |
variable_t.decl_type | (self) | reference to the variable :class:`decl_type <type_t>` | reference to the variable :class:`decl_type <type_t>` | def decl_type(self):
"""reference to the variable :class:`decl_type <type_t>`"""
return self._decl_type | [
"def",
"decl_type",
"(",
"self",
")",
":",
"return",
"self",
".",
"_decl_type"
] | [
51,
4
] | [
53,
30
] | python | en | ['en', 'en', 'en'] | True |
variable_t.type_qualifiers | (self) | reference to the :class:`type_qualifiers_t` instance | reference to the :class:`type_qualifiers_t` instance | def type_qualifiers(self):
"""reference to the :class:`type_qualifiers_t` instance"""
return self._type_qualifiers | [
"def",
"type_qualifiers",
"(",
"self",
")",
":",
"return",
"self",
".",
"_type_qualifiers"
] | [
60,
4
] | [
62,
36
] | python | en | ['en', 'en', 'en'] | True |
variable_t.value | (self) | string, that contains the variable value | string, that contains the variable value | def value(self):
"""string, that contains the variable value"""
return self._value | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_value"
] | [
69,
4
] | [
71,
26
] | python | en | ['en', 'en', 'en'] | True |
variable_t.bits | (self) | integer, that contains information about how many bit takes
bit field | integer, that contains information about how many bit takes
bit field | def bits(self):
"""integer, that contains information about how many bit takes
bit field"""
return self._bits | [
"def",
"bits",
"(",
"self",
")",
":",
"return",
"self",
".",
"_bits"
] | [
78,
4
] | [
81,
25
] | python | en | ['en', 'en', 'en'] | True |
variable_t.byte_offset | (self) | integer, offset of the field from the beginning of class. | integer, offset of the field from the beginning of class. | def byte_offset(self):
"""integer, offset of the field from the beginning of class."""
return self._byte_offset | [
"def",
"byte_offset",
"(",
"self",
")",
":",
"return",
"self",
".",
"_byte_offset"
] | [
88,
4
] | [
90,
32
] | python | en | ['en', 'en', 'en'] | True |
variable_t.mangled | (self) |
Unique declaration name generated by the compiler.
:return: the mangled name
:rtype: str
|
Unique declaration name generated by the compiler. | def mangled(self):
"""
Unique declaration name generated by the compiler.
:return: the mangled name
:rtype: str
"""
return self.get_mangled_name() | [
"def",
"mangled",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_mangled_name",
"(",
")"
] | [
105,
4
] | [
114,
38
] | python | en | ['en', 'error', 'th'] | False |
parser_t.has_pattern | (self, decl_string) |
Implementation detail
|
Implementation detail | def has_pattern(self, decl_string):
"""
Implementation detail
"""
if self.__begin == "<":
# Cleanup parentheses blocks before checking for the pattern
# See also the args() method (in this file) for more explanations.
decl_string = re.sub("\\s\\(.*?\\... | [
"def",
"has_pattern",
"(",
"self",
",",
"decl_string",
")",
":",
"if",
"self",
".",
"__begin",
"==",
"\"<\"",
":",
"# Cleanup parentheses blocks before checking for the pattern",
"# See also the args() method (in this file) for more explanations.",
"decl_string",
"=",
"re",
"... | [
31,
4
] | [
45,
9
] | python | en | ['en', 'error', 'th'] | False |
parser_t.name | (self, decl_string) | implementation details | implementation details | def name(self, decl_string):
"""implementation details"""
if not self.has_pattern(decl_string):
return decl_string
args_begin = decl_string.find(self.__begin)
return decl_string[0: args_begin].strip() | [
"def",
"name",
"(",
"self",
",",
"decl_string",
")",
":",
"if",
"not",
"self",
".",
"has_pattern",
"(",
"decl_string",
")",
":",
"return",
"decl_string",
"args_begin",
"=",
"decl_string",
".",
"find",
"(",
"self",
".",
"__begin",
")",
"return",
"decl_strin... | [
47,
4
] | [
52,
49
] | python | da | ['eo', 'da', 'en'] | False |
parser_t.__find_args_separator | (self, decl_string, start_pos) | implementation details | implementation details | def __find_args_separator(self, decl_string, start_pos):
"""implementation details"""
bracket_depth = 0
for index, ch in enumerate(decl_string[start_pos:]):
if ch not in (self.__begin, self.__end, self.__separator):
continue # I am interested only in < and >
... | [
"def",
"__find_args_separator",
"(",
"self",
",",
"decl_string",
",",
"start_pos",
")",
":",
"bracket_depth",
"=",
"0",
"for",
"index",
",",
"ch",
"in",
"enumerate",
"(",
"decl_string",
"[",
"start_pos",
":",
"]",
")",
":",
"if",
"ch",
"not",
"in",
"(",
... | [
54,
4
] | [
69,
17
] | python | da | ['eo', 'da', 'en'] | False |
parser_t.args | (self, decl_string) |
Extracts a list of arguments from the provided declaration string.
Implementation detail. Example usages:
Input: myClass<std::vector<int>, std::vector<double>>
Output: [std::vector<int>, std::vector<double>]
Args:
decl_string (str): the full declaration string
... |
Extracts a list of arguments from the provided declaration string. | def args(self, decl_string):
"""
Extracts a list of arguments from the provided declaration string.
Implementation detail. Example usages:
Input: myClass<std::vector<int>, std::vector<double>>
Output: [std::vector<int>, std::vector<double>]
Args:
decl_string ... | [
"def",
"args",
"(",
"self",
",",
"decl_string",
")",
":",
"args_begin",
"=",
"decl_string",
".",
"find",
"(",
"self",
".",
"__begin",
")",
"args_end",
"=",
"decl_string",
".",
"rfind",
"(",
"self",
".",
"__end",
")",
"if",
"-",
"1",
"in",
"(",
"args_... | [
71,
4
] | [
149,
19
] | python | en | ['en', 'error', 'th'] | False |
parser_t.find_args | (self, text, start=None) | implementation details | implementation details | def find_args(self, text, start=None):
"""implementation details"""
if start is None:
start = 0
first_occurance = text.find(self.__begin, start)
if first_occurance == -1:
return self.NOT_FOUND
previous_found, found = first_occurance + 1, 0
while Tr... | [
"def",
"find_args",
"(",
"self",
",",
"text",
",",
"start",
"=",
"None",
")",
":",
"if",
"start",
"is",
"None",
":",
"start",
"=",
"0",
"first_occurance",
"=",
"text",
".",
"find",
"(",
"self",
".",
"__begin",
",",
"start",
")",
"if",
"first_occuranc... | [
154,
4
] | [
169,
42
] | python | da | ['eo', 'da', 'en'] | False |
parser_t.split | (self, decl_string) | implementation details | implementation details | def split(self, decl_string):
"""implementation details"""
assert self.has_pattern(decl_string)
return self.name(decl_string), self.args(decl_string) | [
"def",
"split",
"(",
"self",
",",
"decl_string",
")",
":",
"assert",
"self",
".",
"has_pattern",
"(",
"decl_string",
")",
"return",
"self",
".",
"name",
"(",
"decl_string",
")",
",",
"self",
".",
"args",
"(",
"decl_string",
")"
] | [
171,
4
] | [
174,
61
] | python | da | ['eo', 'da', 'en'] | False |
parser_t.split_recursive | (self, decl_string) | implementation details | implementation details | def split_recursive(self, decl_string):
"""implementation details"""
assert self.has_pattern(decl_string)
to_go = [decl_string]
while to_go:
name, args = self.split(to_go.pop())
for arg in args:
if self.has_pattern(arg):
to_go.a... | [
"def",
"split_recursive",
"(",
"self",
",",
"decl_string",
")",
":",
"assert",
"self",
".",
"has_pattern",
"(",
"decl_string",
")",
"to_go",
"=",
"[",
"decl_string",
"]",
"while",
"to_go",
":",
"name",
",",
"args",
"=",
"self",
".",
"split",
"(",
"to_go"... | [
176,
4
] | [
185,
28
] | python | da | ['eo', 'da', 'en'] | False |
parser_t.join | (self, name, args, arg_separator=None) | implementation details | implementation details | def join(self, name, args, arg_separator=None):
"""implementation details"""
if None is arg_separator:
arg_separator = ', '
args = [_f for _f in args if _f]
if not args:
args_str = ' '
elif len(args) == 1:
args_str = ' ' + args[0] + ' '
... | [
"def",
"join",
"(",
"self",
",",
"name",
",",
"args",
",",
"arg_separator",
"=",
"None",
")",
":",
"if",
"None",
"is",
"arg_separator",
":",
"arg_separator",
"=",
"', '",
"args",
"=",
"[",
"_f",
"for",
"_f",
"in",
"args",
"if",
"_f",
"]",
"if",
"no... | [
187,
4
] | [
200,
66
] | python | da | ['eo', 'da', 'en'] | False |
parser_t.normalize | (self, decl_string, arg_separator=None) | implementation details | implementation details | def normalize(self, decl_string, arg_separator=None):
"""implementation details"""
if not self.has_pattern(decl_string):
return decl_string
name, args = self.split(decl_string)
for i, arg in enumerate(args):
args[i] = self.normalize(arg)
return self.join(n... | [
"def",
"normalize",
"(",
"self",
",",
"decl_string",
",",
"arg_separator",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"has_pattern",
"(",
"decl_string",
")",
":",
"return",
"decl_string",
"name",
",",
"args",
"=",
"self",
".",
"split",
"(",
"decl_s... | [
202,
4
] | [
209,
51
] | python | da | ['eo', 'da', 'en'] | False |
tutorial8_preprocessing | () |
## Converters
Haystack's converter classes are designed to help you turn files on your computer into the documents
that can be processed by the Haystack pipeline.
There are file converters for txt, pdf, docx files as well as a converter that is powered by Apache Tika.
|
## Converters
Haystack's converter classes are designed to help you turn files on your computer into the documents
that can be processed by the Haystack pipeline.
There are file converters for txt, pdf, docx files as well as a converter that is powered by Apache Tika.
| def tutorial8_preprocessing():
# This fetches some sample files to work with
doc_dir = "data/preprocessing_tutorial"
s3_url = "https://s3.eu-central-1.amazonaws.com/deepset.ai-farm-qa/datasets/documents/preprocessing_tutorial.zip"
fetch_archive_from_http(url=s3_url, output_dir=doc_dir)
"""
## ... | [
"def",
"tutorial8_preprocessing",
"(",
")",
":",
"# This fetches some sample files to work with",
"doc_dir",
"=",
"\"data/preprocessing_tutorial\"",
"s3_url",
"=",
"\"https://s3.eu-central-1.amazonaws.com/deepset.ai-farm-qa/datasets/documents/preprocessing_tutorial.zip\"",
"fetch_archive_fro... | [
29,
0
] | [
141,
44
] | python | en | ['en', 'error', 'th'] | False |
reverse_array_dict | (dictionary) |
Returns a reversed version a dictionary of keys to list-like objects. Each value in each list-like
becomes a key in the returned dictionary mapping to its key in the provided dictionary.
|
Returns a reversed version a dictionary of keys to list-like objects. Each value in each list-like
becomes a key in the returned dictionary mapping to its key in the provided dictionary.
| def reverse_array_dict(dictionary):
"""
Returns a reversed version a dictionary of keys to list-like objects. Each value in each list-like
becomes a key in the returned dictionary mapping to its key in the provided dictionary.
"""
return_dict = {}
for label, values in dictionary.items():
... | [
"def",
"reverse_array_dict",
"(",
"dictionary",
")",
":",
"return_dict",
"=",
"{",
"}",
"for",
"label",
",",
"values",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"for",
"value",
"in",
"values",
":",
"return_dict",
"[",
"value",
"]",
"=",
"label",
... | [
35,
0
] | [
44,
22
] | python | en | ['en', 'ja', 'th'] | False |
list_prod | (lst) | Takes the product of elements in a list. | Takes the product of elements in a list. | def list_prod(lst):
"""Takes the product of elements in a list."""
return functools.reduce(operator.mul, lst) | [
"def",
"list_prod",
"(",
"lst",
")",
":",
"return",
"functools",
".",
"reduce",
"(",
"operator",
".",
"mul",
",",
"lst",
")"
] | [
46,
0
] | [
48,
46
] | python | en | ['en', 'en', 'en'] | True |
check_for_float | (array) |
Check if a NumPy array-like contains floats.
Parameters
----------
array : numpy.ndarray or convertible
The array to check.
|
Check if a NumPy array-like contains floats.
Parameters
----------
array : numpy.ndarray or convertible
The array to check.
| def check_for_float(array):
"""
Check if a NumPy array-like contains floats.
Parameters
----------
array : numpy.ndarray or convertible
The array to check.
"""
try:
return array.dtype.kind == 'f'
except AttributeError:
# in case it's not a numpy array... | [
"def",
"check_for_float",
"(",
"array",
")",
":",
"try",
":",
"return",
"array",
".",
"dtype",
".",
"kind",
"==",
"'f'",
"except",
"AttributeError",
":",
"# in case it's not a numpy array it will probably have no dtype.\r",
"return",
"np",
".",
"asarray",
"(",
"arra... | [
50,
0
] | [
63,
68
] | python | en | ['en', 'ja', 'th'] | False |
create_cfmask_clean_mask | (cfmask) |
Description:
Create a clean mask for clear land/water pixels,
i.e. mask out shadow, snow, cloud, and no data
-----
Input:
cfmask (xarray) - cf_mask from the ledaps products
Output:
clean_mask (boolean numpy array) - clear land/water mask
|
Description:
Create a clean mask for clear land/water pixels,
i.e. mask out shadow, snow, cloud, and no data
-----
Input:
cfmask (xarray) - cf_mask from the ledaps products
Output:
clean_mask (boolean numpy array) - clear land/water mask
| def create_cfmask_clean_mask(cfmask):
"""
Description:
Create a clean mask for clear land/water pixels,
i.e. mask out shadow, snow, cloud, and no data
-----
Input:
cfmask (xarray) - cf_mask from the ledaps products
Output:
clean_mask (boolean numpy array) - clear lan... | [
"def",
"create_cfmask_clean_mask",
"(",
"cfmask",
")",
":",
"#########################\r",
"# cfmask values: #\r",
"# 0 - clear #\r",
"# 1 - water #\r",
"# 2 - cloud shadow #\r",
"# 3 - snow #\r",
"# 4 - cloud #\r",
"# 255 - fi... | [
65,
0
] | [
88,
28
] | python | en | ['en', 'ja', 'th'] | False |
create_default_clean_mask | (dataset_in) |
Description:
Creates a data mask that masks nothing.
-----
Inputs:
dataset_in (xarray.Dataset) - dataset retrieved from the Data Cube.
Throws:
ValueError - if dataset_in is an empty xarray.Dataset.
|
Description:
Creates a data mask that masks nothing.
-----
Inputs:
dataset_in (xarray.Dataset) - dataset retrieved from the Data Cube.
Throws:
ValueError - if dataset_in is an empty xarray.Dataset.
| def create_default_clean_mask(dataset_in):
"""
Description:
Creates a data mask that masks nothing.
-----
Inputs:
dataset_in (xarray.Dataset) - dataset retrieved from the Data Cube.
Throws:
ValueError - if dataset_in is an empty xarray.Dataset.
"""
data_vars... | [
"def",
"create_default_clean_mask",
"(",
"dataset_in",
")",
":",
"data_vars",
"=",
"dataset_in",
".",
"data_vars",
"if",
"len",
"(",
"data_vars",
")",
"!=",
"0",
":",
"first_data_var",
"=",
"next",
"(",
"iter",
"(",
"data_vars",
")",
")",
"clean_mask",
"=",
... | [
90,
0
] | [
106,
53
] | python | en | ['en', 'ja', 'th'] | False |
get_spatial_ref | (crs) |
Description:
Get the spatial reference of a given crs
-----
Input:
crs (datacube.model.CRS) - Example: CRS('EPSG:4326')
Output:
ref (str) - spatial reference of given crs
|
Description:
Get the spatial reference of a given crs
-----
Input:
crs (datacube.model.CRS) - Example: CRS('EPSG:4326')
Output:
ref (str) - spatial reference of given crs
| def get_spatial_ref(crs):
"""
Description:
Get the spatial reference of a given crs
-----
Input:
crs (datacube.model.CRS) - Example: CRS('EPSG:4326')
Output:
ref (str) - spatial reference of given crs
"""
crs_str = str(crs)
epsg_code = int(crs_str.split(':'... | [
"def",
"get_spatial_ref",
"(",
"crs",
")",
":",
"crs_str",
"=",
"str",
"(",
"crs",
")",
"epsg_code",
"=",
"int",
"(",
"crs_str",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
")",
"ref",
"=",
"osr",
".",
"SpatialReference",
"(",
")",
"ref",
".",
... | [
108,
0
] | [
123,
19
] | python | en | ['en', 'ja', 'th'] | False |
perform_timeseries_analysis | (dataset_in, band_name, intermediate_product=None, no_data=-9999, operation="mean") |
Description:
-----
Input:
dataset_in (xarray.DataSet) - dataset with one variable to perform timeseries on
band_name: name of the band to create stats for.
intermediate_product: result of this function for previous data, to be combined here
Output:
dataset_out (xarray.... |
Description:
-----
Input:
dataset_in (xarray.DataSet) - dataset with one variable to perform timeseries on
band_name: name of the band to create stats for.
intermediate_product: result of this function for previous data, to be combined here
Output:
dataset_out (xarray.... | def perform_timeseries_analysis(dataset_in, band_name, intermediate_product=None, no_data=-9999, operation="mean"):
"""
Description:
-----
Input:
dataset_in (xarray.DataSet) - dataset with one variable to perform timeseries on
band_name: name of the band to create stats for.
i... | [
"def",
"perform_timeseries_analysis",
"(",
"dataset_in",
",",
"band_name",
",",
"intermediate_product",
"=",
"None",
",",
"no_data",
"=",
"-",
"9999",
",",
"operation",
"=",
"\"mean\"",
")",
":",
"assert",
"operation",
"in",
"[",
"'mean'",
",",
"'max'",
",",
... | [
125,
0
] | [
173,
22
] | python | en | ['en', 'ja', 'th'] | False |
nan_to_num | (data, number) |
Converts all nan values in `data` to `number`.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
|
Converts all nan values in `data` to `number`.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
| def nan_to_num(data, number):
"""
Converts all nan values in `data` to `number`.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
"""
if isinstance(data, xr.Dataset):
for key in list(data.data_vars):
data[key].values[np.isnan(data[key].values)] = ... | [
"def",
"nan_to_num",
"(",
"data",
",",
"number",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"xr",
".",
"Dataset",
")",
":",
"for",
"key",
"in",
"list",
"(",
"data",
".",
"data_vars",
")",
":",
"data",
"[",
"key",
"]",
".",
"values",
"[",
"np... | [
176,
0
] | [
188,
51
] | python | en | ['en', 'ja', 'th'] | False |
clear_attrs | (dataset) | Clear out all attributes on an xarray dataset to write to disk. | Clear out all attributes on an xarray dataset to write to disk. | def clear_attrs(dataset):
"""Clear out all attributes on an xarray dataset to write to disk."""
dataset.attrs = collections.OrderedDict()
for band in dataset.data_vars:
dataset[band].attrs = collections.OrderedDict() | [
"def",
"clear_attrs",
"(",
"dataset",
")",
":",
"dataset",
".",
"attrs",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"band",
"in",
"dataset",
".",
"data_vars",
":",
"dataset",
"[",
"band",
"]",
".",
"attrs",
"=",
"collections",
".",
"Ordered... | [
191,
0
] | [
195,
55
] | python | en | ['en', 'en', 'en'] | True |
create_bit_mask | (data_array, valid_bits, no_data=-9999) | Create a boolean bit mask from a list of valid bits
Args:
data_array: xarray data array to extract bit information for.
valid_bits: array of ints representing what bits should be considered valid.
no_data: no_data value for the data array.
Returns:
Boolean mask signifyi... | Create a boolean bit mask from a list of valid bits
Args:
data_array: xarray data array to extract bit information for.
valid_bits: array of ints representing what bits should be considered valid.
no_data: no_data value for the data array.
Returns:
Boolean mask signifyi... | def create_bit_mask(data_array, valid_bits, no_data=-9999):
"""Create a boolean bit mask from a list of valid bits
Args:
data_array: xarray data array to extract bit information for.
valid_bits: array of ints representing what bits should be considered valid.
no_data: no_data valu... | [
"def",
"create_bit_mask",
"(",
"data_array",
",",
"valid_bits",
",",
"no_data",
"=",
"-",
"9999",
")",
":",
"assert",
"isinstance",
"(",
"valid_bits",
",",
"list",
")",
"and",
"isinstance",
"(",
"valid_bits",
"[",
"0",
"]",
",",
"int",
")",
",",
"\"Valid... | [
198,
0
] | [
214,
28
] | python | en | ['en', 'en', 'en'] | True |
add_timestamp_data_to_xr | (dataset) | Add timestamp data to an xarray dataset using the time dimension.
Adds both a timestamp and a human readable date int to a dataset - int32 format required.
modifies the dataset in place.
| Add timestamp data to an xarray dataset using the time dimension.
Adds both a timestamp and a human readable date int to a dataset - int32 format required.
modifies the dataset in place.
| def add_timestamp_data_to_xr(dataset):
"""Add timestamp data to an xarray dataset using the time dimension.
Adds both a timestamp and a human readable date int to a dataset - int32 format required.
modifies the dataset in place.
"""
dims_data_var = list(dataset.data_vars)[0]
timestamp_... | [
"def",
"add_timestamp_data_to_xr",
"(",
"dataset",
")",
":",
"dims_data_var",
"=",
"list",
"(",
"dataset",
".",
"data_vars",
")",
"[",
"0",
"]",
"timestamp_data",
"=",
"np",
".",
"full",
"(",
"dataset",
"[",
"dims_data_var",
"]",
".",
"values",
".",
"shape... | [
217,
0
] | [
242,
38
] | python | en | ['en', 'en', 'en'] | True |
write_geotiff_from_xr | (tif_path, data, bands=None, no_data=-9999, crs="EPSG:4326",
x_coord='longitude', y_coord='latitude') |
NOTE: Instead of this function, please use `import_export.export_xarray_to_geotiff()`.
Export a GeoTIFF from an `xarray.Dataset`.
Parameters
----------
tif_path: string
The path to write the GeoTIFF file to. You should include the file extension.
data: xarray.Dataset or xarra... |
NOTE: Instead of this function, please use `import_export.export_xarray_to_geotiff()`.
Export a GeoTIFF from an `xarray.Dataset`.
Parameters
----------
tif_path: string
The path to write the GeoTIFF file to. You should include the file extension.
data: xarray.Dataset or xarra... | def write_geotiff_from_xr(tif_path, data, bands=None, no_data=-9999, crs="EPSG:4326",
x_coord='longitude', y_coord='latitude'):
"""
NOTE: Instead of this function, please use `import_export.export_xarray_to_geotiff()`.
Export a GeoTIFF from an `xarray.Dataset`.
Paramet... | [
"def",
"write_geotiff_from_xr",
"(",
"tif_path",
",",
"data",
",",
"bands",
"=",
"None",
",",
"no_data",
"=",
"-",
"9999",
",",
"crs",
"=",
"\"EPSG:4326\"",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
")",
":",
"if",
"isinstance"... | [
245,
0
] | [
295,
15
] | python | en | ['en', 'ja', 'th'] | False |
write_png_from_xr | (png_path, dataset, bands, png_filled_path=None, fill_color='red', scale=None, low_res=False,
no_data=-9999, crs="EPSG:4326") | Write a rgb png from an xarray dataset.
Note that using `low_res==True` currently causes the file(s)
for `png_path` and `png_filled_path` to not be created.
Args:
png_path: path for the png to be written to.
dataset: dataset to use for the png creation.
bands: a list of three... | Write a rgb png from an xarray dataset.
Note that using `low_res==True` currently causes the file(s)
for `png_path` and `png_filled_path` to not be created.
Args:
png_path: path for the png to be written to.
dataset: dataset to use for the png creation.
bands: a list of three... | def write_png_from_xr(png_path, dataset, bands, png_filled_path=None, fill_color='red', scale=None, low_res=False,
no_data=-9999, crs="EPSG:4326"):
"""Write a rgb png from an xarray dataset.
Note that using `low_res==True` currently causes the file(s)
for `png_path` and `png_filled... | [
"def",
"write_png_from_xr",
"(",
"png_path",
",",
"dataset",
",",
"bands",
",",
"png_filled_path",
"=",
"None",
",",
"fill_color",
"=",
"'red'",
",",
"scale",
"=",
"None",
",",
"low_res",
"=",
"False",
",",
"no_data",
"=",
"-",
"9999",
",",
"crs",
"=",
... | [
298,
0
] | [
337,
23
] | python | en | ['en', 'en', 'en'] | True |
write_single_band_png_from_xr | (png_path, dataset, band, color_scale=None, fill_color=None, interpolate=True,
no_data=-9999, crs="EPSG:4326") | Write a pseudocolor png from an xarray dataset.
Args:
png_path: path for the png to be written to.
dataset: dataset to use for the png creation.
band: The band to write to a png
png_filled_path: optional png with no_data values filled
fill_color: color to use as the n... | Write a pseudocolor png from an xarray dataset.
Args:
png_path: path for the png to be written to.
dataset: dataset to use for the png creation.
band: The band to write to a png
png_filled_path: optional png with no_data values filled
fill_color: color to use as the n... | def write_single_band_png_from_xr(png_path, dataset, band, color_scale=None, fill_color=None, interpolate=True,
no_data=-9999, crs="EPSG:4326"):
"""Write a pseudocolor png from an xarray dataset.
Args:
png_path: path for the png to be written to.
dataset:... | [
"def",
"write_single_band_png_from_xr",
"(",
"png_path",
",",
"dataset",
",",
"band",
",",
"color_scale",
"=",
"None",
",",
"fill_color",
"=",
"None",
",",
"interpolate",
"=",
"True",
",",
"no_data",
"=",
"-",
"9999",
",",
"crs",
"=",
"\"EPSG:4326\"",
")",
... | [
340,
0
] | [
372,
23
] | python | en | ['en', 'en', 'en'] | True |
_get_transform_from_xr | (data, x_coord='longitude', y_coord='latitude') | Create a geotransform from an xarray.Dataset or xarray.DataArray.
| Create a geotransform from an xarray.Dataset or xarray.DataArray.
| def _get_transform_from_xr(data, x_coord='longitude', y_coord='latitude'):
"""Create a geotransform from an xarray.Dataset or xarray.DataArray.
"""
from rasterio.transform import from_bounds
geotransform = from_bounds(data[x_coord][0], data[y_coord][-1],
data[x_coor... | [
"def",
"_get_transform_from_xr",
"(",
"data",
",",
"x_coord",
"=",
"'longitude'",
",",
"y_coord",
"=",
"'latitude'",
")",
":",
"from",
"rasterio",
".",
"transform",
"import",
"from_bounds",
"geotransform",
"=",
"from_bounds",
"(",
"data",
"[",
"x_coord",
"]",
... | [
374,
0
] | [
382,
23
] | python | en | ['en', 'ga', 'en'] | True |
ignore_warnings | (func, *args, **kwargs) | Runs a function while ignoring warnings | Runs a function while ignoring warnings | def ignore_warnings(func, *args, **kwargs):
"""Runs a function while ignoring warnings"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
ret = func(*args, **kwargs)
return ret | [
"def",
"ignore_warnings",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"ret",
"=",
"func",
"(",
"*",
"args",
",",
... | [
390,
0
] | [
395,
14
] | python | en | ['en', 'en', 'en'] | True |
initialized_sqlite_project | (
mock_webbrowser, caplog, tmp_path_factory, titanic_sqlite_db_file, sa
) | This is an initialized project through the CLI. | This is an initialized project through the CLI. | def initialized_sqlite_project(
mock_webbrowser, caplog, tmp_path_factory, titanic_sqlite_db_file, sa
):
"""This is an initialized project through the CLI."""
project_dir = str(tmp_path_factory.mktemp("my_rad_project"))
engine = sa.create_engine(
"sqlite:///{}".format(titanic_sqlite_db_file), p... | [
"def",
"initialized_sqlite_project",
"(",
"mock_webbrowser",
",",
"caplog",
",",
"tmp_path_factory",
",",
"titanic_sqlite_db_file",
",",
"sa",
")",
":",
"project_dir",
"=",
"str",
"(",
"tmp_path_factory",
".",
"mktemp",
"(",
"\"my_rad_project\"",
")",
")",
"engine",... | [
411,
0
] | [
467,
22
] | python | en | ['en', 'en', 'en'] | True |
_compute_critic_score | (critics, smooth_window) | Compute an array of anomaly scores.
Args:
critics (ndarray):
Critic values.
smooth_window (int):
Smooth window that will be applied to compute smooth errors.
Returns:
ndarray:
Array of anomaly scores.
| Compute an array of anomaly scores. | def _compute_critic_score(critics, smooth_window):
"""Compute an array of anomaly scores.
Args:
critics (ndarray):
Critic values.
smooth_window (int):
Smooth window that will be applied to compute smooth errors.
Returns:
ndarray:
Array of anomaly... | [
"def",
"_compute_critic_score",
"(",
"critics",
",",
"smooth_window",
")",
":",
"critics",
"=",
"np",
".",
"asarray",
"(",
"critics",
")",
"l_quantile",
"=",
"np",
".",
"quantile",
"(",
"critics",
",",
"0.25",
")",
"u_quantile",
"=",
"np",
".",
"quantile",... | [
275,
0
] | [
299,
19
] | python | en | ['en', 'en', 'en'] | True |
score_anomalies | (y, y_hat, critic, index, score_window=10, critic_smooth_window=None,
error_smooth_window=None, smooth=True, rec_error_type="point", comb="mult",
lambda_rec=0.5) | Compute an array of anomaly scores.
Anomaly scores are calculated using a combination of reconstruction error and critic score.
Args:
y (ndarray):
Ground truth.
y_hat (ndarray):
Predicted values. Each timestamp has multiple predictions.
index (ndarray):
... | Compute an array of anomaly scores. | def score_anomalies(y, y_hat, critic, index, score_window=10, critic_smooth_window=None,
error_smooth_window=None, smooth=True, rec_error_type="point", comb="mult",
lambda_rec=0.5):
"""Compute an array of anomaly scores.
Anomaly scores are calculated using a combination ... | [
"def",
"score_anomalies",
"(",
"y",
",",
"y_hat",
",",
"critic",
",",
"index",
",",
"score_window",
"=",
"10",
",",
"critic_smooth_window",
"=",
"None",
",",
"error_smooth_window",
"=",
"None",
",",
"smooth",
"=",
"True",
",",
"rec_error_type",
"=",
"\"point... | [
302,
0
] | [
408,
54
] | python | en | ['en', 'en', 'en'] | True |
RandomWeightedAverage._merge_function | (self, inputs) |
Args:
inputs[0] x original input
inputs[1] x_ predicted input
|
Args:
inputs[0] x original input
inputs[1] x_ predicted input
| def _merge_function(self, inputs):
"""
Args:
inputs[0] x original input
inputs[1] x_ predicted input
"""
alpha = K.random_uniform((64, 1, 1))
return (alpha * inputs[0]) + ((1 - alpha) * inputs[1]) | [
"def",
"_merge_function",
"(",
"self",
",",
"inputs",
")",
":",
"alpha",
"=",
"K",
".",
"random_uniform",
"(",
"(",
"64",
",",
"1",
",",
"1",
")",
")",
"return",
"(",
"alpha",
"*",
"inputs",
"[",
"0",
"]",
")",
"+",
"(",
"(",
"1",
"-",
"alpha",... | [
24,
4
] | [
31,
62
] | python | en | ['en', 'error', 'th'] | False |
TadGAN.fit | (self, X, **kwargs) | Fit the TadGAN.
Args:
X (ndarray):
N-dimensional array containing the input training sequences for the model.
| Fit the TadGAN. | def fit(self, X, **kwargs):
"""Fit the TadGAN.
Args:
X (ndarray):
N-dimensional array containing the input training sequences for the model.
"""
self._build_tadgan(**kwargs)
X = X.reshape((-1, self.shape[0], 1))
self._fit(X) | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_build_tadgan",
"(",
"*",
"*",
"kwargs",
")",
"X",
"=",
"X",
".",
"reshape",
"(",
"(",
"-",
"1",
",",
"self",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
... | [
242,
4
] | [
251,
20
] | python | en | ['en', 'mt', 'en'] | True |
TadGAN.predict | (self, X) | Predict values using the initialized object.
Args:
X (ndarray):
N-dimensional array containing the input sequences for the model.
Returns:
ndarray:
N-dimensional array containing the reconstructions for each input sequence.
ndarray:
... | Predict values using the initialized object. | def predict(self, X):
"""Predict values using the initialized object.
Args:
X (ndarray):
N-dimensional array containing the input sequences for the model.
Returns:
ndarray:
N-dimensional array containing the reconstructions for each input... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"X",
".",
"reshape",
"(",
"(",
"-",
"1",
",",
"self",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
")",
"z_",
"=",
"self",
".",
"encoder",
".",
"predict",
"(",
"X",
")",
"y_hat",
... | [
253,
4
] | [
272,
28
] | python | en | ['en', 'en', 'en'] | True |
find_docusaurus_refs | (dir: str) | Finds any Docusaurus links within a target directory (i.e. ```python file=...#L10-20) | Finds any Docusaurus links within a target directory (i.e. ```python file=...#L10-20) | def find_docusaurus_refs(dir: str) -> List[str]:
""" Finds any Docusaurus links within a target directory (i.e. ```python file=...#L10-20) """
linked_files: Set[str] = set()
pattern: str = (
r"\`\`\`[a-zA-Z]+ file" # Format of internal links used by Docusaurus
)
for doc in glob.glob(f"{dir... | [
"def",
"find_docusaurus_refs",
"(",
"dir",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"linked_files",
":",
"Set",
"[",
"str",
"]",
"=",
"set",
"(",
")",
"pattern",
":",
"str",
"=",
"(",
"r\"\\`\\`\\`[a-zA-Z]+ file\"",
"# Format of internal links us... | [
36,
0
] | [
50,
42
] | python | en | ['en', 'en', 'en'] | True |
get_local_imports | (files: List[str]) | Parses a list of files to determine local imports; external dependencies are discarded | Parses a list of files to determine local imports; external dependencies are discarded | def get_local_imports(files: List[str]) -> List[str]:
""" Parses a list of files to determine local imports; external dependencies are discarded """
imports: Set[str] = set()
for file in files:
with open(file) as f:
root: ast.Module = ast.parse(f.read(), file)
for node in ast.w... | [
"def",
"get_local_imports",
"(",
"files",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"imports",
":",
"Set",
"[",
"str",
"]",
"=",
"set",
"(",
")",
"for",
"file",
"in",
"files",
":",
"with",
"open",
"(",
"file",
")",
... | [
59,
0
] | [
80,
35
] | python | en | ['en', 'en', 'en'] | True |
get_import_paths | (imports: List[str]) | Takes a list of imports and determines the relative path to each source file or module | Takes a list of imports and determines the relative path to each source file or module | def get_import_paths(imports: List[str]) -> List[str]:
""" Takes a list of imports and determines the relative path to each source file or module """
paths: List[str] = []
for imp in imports:
path: str = imp.replace(
".", "/"
) # AST nodes are formatted as great_expectations.mo... | [
"def",
"get_import_paths",
"(",
"imports",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"paths",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"]",
"for",
"imp",
"in",
"imports",
":",
"path",
":",
"str",
"=",
"imp",
".",
"re... | [
83,
0
] | [
93,
16
] | python | en | ['en', 'en', 'en'] | True |
test_snapshot_render_section_page_with_fixture_data | (validation_operator_result) |
Make sure the appropriate markdown rendering is done for the applied fixture.
Args:
validation_operator_result: test fixture
Returns: None
|
Make sure the appropriate markdown rendering is done for the applied fixture.
Args:
validation_operator_result: test fixture | def test_snapshot_render_section_page_with_fixture_data(validation_operator_result):
"""
Make sure the appropriate markdown rendering is done for the applied fixture.
Args:
validation_operator_result: test fixture
Returns: None
"""
validation_operator_result = ValidationOperatorResult(... | [
"def",
"test_snapshot_render_section_page_with_fixture_data",
"(",
"validation_operator_result",
")",
":",
"validation_operator_result",
"=",
"ValidationOperatorResult",
"(",
"*",
"*",
"validation_operator_result",
")",
"validation_results_page_renderer",
"=",
"ValidationResultsPageR... | [
137,
0
] | [
304,
5
] | python | en | ['en', 'error', 'th'] | False |
test_render_section_page_with_fixture_data_multiple_validations | (
validation_operator_result,
) |
Make sure the appropriate markdown rendering is done for the applied fixture.
:param validation_operator_result: test fixture
:return: None
|
Make sure the appropriate markdown rendering is done for the applied fixture.
:param validation_operator_result: test fixture
:return: None
| def test_render_section_page_with_fixture_data_multiple_validations(
validation_operator_result,
):
"""
Make sure the appropriate markdown rendering is done for the applied fixture.
:param validation_operator_result: test fixture
:return: None
"""
validation_operator_result = ValidationOper... | [
"def",
"test_render_section_page_with_fixture_data_multiple_validations",
"(",
"validation_operator_result",
",",
")",
":",
"validation_operator_result",
"=",
"ValidationOperatorResult",
"(",
"*",
"*",
"validation_operator_result",
")",
"validation_results_page_renderer",
"=",
"Val... | [
307,
0
] | [
476,
5
] | python | en | ['en', 'error', 'th'] | False |
_GetLargePdbShimCcPath | () | Returns the path of the large_pdb_shim.cc file. | Returns the path of the large_pdb_shim.cc file. | def _GetLargePdbShimCcPath():
"""Returns the path of the large_pdb_shim.cc file."""
this_dir = os.path.abspath(os.path.dirname(__file__))
src_dir = os.path.abspath(os.path.join(this_dir, '..', '..'))
win_data_dir = os.path.join(src_dir, 'data', 'win')
large_pdb_shim_cc = os.path.join(win_data_dir, 'large-pdb-... | [
"def",
"_GetLargePdbShimCcPath",
"(",
")",
":",
"this_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"src_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"... | [
19,
0
] | [
25,
26
] | python | en | ['en', 'en', 'en'] | True |
_DeepCopySomeKeys | (in_dict, keys) | Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|.
Arguments:
in_dict: The dictionary to copy.
keys: The keys to be copied. If a key is in this list and doesn't exist in
|in_dict| this is not an error.
Returns:
The partially deep-copied dictionary.
| Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|. | def _DeepCopySomeKeys(in_dict, keys):
"""Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|.
Arguments:
in_dict: The dictionary to copy.
keys: The keys to be copied. If a key is in this list and doesn't exist in
|in_dict| this is not an error.
Returns:
The partially de... | [
"def",
"_DeepCopySomeKeys",
"(",
"in_dict",
",",
"keys",
")",
":",
"d",
"=",
"{",
"}",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"not",
"in",
"in_dict",
":",
"continue",
"d",
"[",
"key",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"in_dict",
"[",
... | [
28,
0
] | [
43,
10
] | python | en | ['en', 'en', 'en'] | True |
_SuffixName | (name, suffix) | Add a suffix to the end of a target.
Arguments:
name: name of the target (foo#target)
suffix: the suffix to be added
Returns:
Target name with suffix added (foo_suffix#target)
| Add a suffix to the end of a target. | def _SuffixName(name, suffix):
"""Add a suffix to the end of a target.
Arguments:
name: name of the target (foo#target)
suffix: the suffix to be added
Returns:
Target name with suffix added (foo_suffix#target)
"""
parts = name.rsplit('#', 1)
parts[0] = '%s_%s' % (parts[0], suffix)
return '#'.... | [
"def",
"_SuffixName",
"(",
"name",
",",
"suffix",
")",
":",
"parts",
"=",
"name",
".",
"rsplit",
"(",
"'#'",
",",
"1",
")",
"parts",
"[",
"0",
"]",
"=",
"'%s_%s'",
"%",
"(",
"parts",
"[",
"0",
"]",
",",
"suffix",
")",
"return",
"'#'",
".",
"joi... | [
46,
0
] | [
57,
24
] | python | en | ['en', 'en', 'en'] | True |
_ShardName | (name, number) | Add a shard number to the end of a target.
Arguments:
name: name of the target (foo#target)
number: shard number
Returns:
Target name with shard added (foo_1#target)
| Add a shard number to the end of a target. | def _ShardName(name, number):
"""Add a shard number to the end of a target.
Arguments:
name: name of the target (foo#target)
number: shard number
Returns:
Target name with shard added (foo_1#target)
"""
return _SuffixName(name, str(number)) | [
"def",
"_ShardName",
"(",
"name",
",",
"number",
")",
":",
"return",
"_SuffixName",
"(",
"name",
",",
"str",
"(",
"number",
")",
")"
] | [
60,
0
] | [
69,
39
] | python | en | ['en', 'en', 'en'] | True |
ShardTargets | (target_list, target_dicts) | Shard some targets apart to work around the linkers limits.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of target properties keyed on target pair.
Returns:
Tuple of the new sharded versions of the inputs.
| Shard some targets apart to work around the linkers limits. | def ShardTargets(target_list, target_dicts):
"""Shard some targets apart to work around the linkers limits.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of target properties keyed on target pair.
Returns:
Tuple of the new sharded versions of the inputs.
"""... | [
"def",
"ShardTargets",
"(",
"target_list",
",",
"target_dicts",
")",
":",
"# Gather the targets to shard, and how many pieces.",
"targets_to_shard",
"=",
"{",
"}",
"for",
"t",
"in",
"target_dicts",
":",
"shards",
"=",
"int",
"(",
"target_dicts",
"[",
"t",
"]",
"."... | [
72,
0
] | [
124,
44
] | python | en | ['en', 'en', 'en'] | True |
_GetPdbPath | (target_dict, config_name, vars) | Returns the path to the PDB file that will be generated by a given
configuration.
The lookup proceeds as follows:
- Look for an explicit path in the VCLinkerTool configuration block.
- Look for an 'msvs_large_pdb_path' variable.
- Use '<(PRODUCT_DIR)/<(product_name).(exe|dll).pdb' if 'product_name' is
... | Returns the path to the PDB file that will be generated by a given
configuration. | def _GetPdbPath(target_dict, config_name, vars):
"""Returns the path to the PDB file that will be generated by a given
configuration.
The lookup proceeds as follows:
- Look for an explicit path in the VCLinkerTool configuration block.
- Look for an 'msvs_large_pdb_path' variable.
- Use '<(PRODUCT_DIR... | [
"def",
"_GetPdbPath",
"(",
"target_dict",
",",
"config_name",
",",
"vars",
")",
":",
"config",
"=",
"target_dict",
"[",
"'configurations'",
"]",
"[",
"config_name",
"]",
"msvs",
"=",
"config",
".",
"setdefault",
"(",
"'msvs_settings'",
",",
"{",
"}",
")",
... | [
127,
0
] | [
164,
17
] | python | en | ['en', 'en', 'en'] | True |
InsertLargePdbShims | (target_list, target_dicts, vars) | Insert a shim target that forces the linker to use 4KB pagesize PDBs.
This is a workaround for targets with PDBs greater than 1GB in size, the
limit for the 1KB pagesize PDBs created by the linker by default.
Arguments:
target_list: List of target pairs: 'base/base.gyp:base'.
target_dicts: Dict of targe... | Insert a shim target that forces the linker to use 4KB pagesize PDBs. | def InsertLargePdbShims(target_list, target_dicts, vars):
"""Insert a shim target that forces the linker to use 4KB pagesize PDBs.
This is a workaround for targets with PDBs greater than 1GB in size, the
limit for the 1KB pagesize PDBs created by the linker by default.
Arguments:
target_list: List of targ... | [
"def",
"InsertLargePdbShims",
"(",
"target_list",
",",
"target_dicts",
",",
"vars",
")",
":",
"# Determine which targets need shimming.",
"targets_to_shim",
"=",
"[",
"]",
"for",
"t",
"in",
"target_dicts",
":",
"target_dict",
"=",
"target_dicts",
"[",
"t",
"]",
"#... | [
167,
0
] | [
269,
36
] | python | en | ['en', 'en', 'en'] | True |
test_cli_datasource_list | (
mock_emit, empty_data_context, empty_sqlite_db, caplog, monkeypatch
) | Test an empty project and after adding a single datasource. | Test an empty project and after adding a single datasource. | def test_cli_datasource_list(
mock_emit, empty_data_context, empty_sqlite_db, caplog, monkeypatch
):
"""Test an empty project and after adding a single datasource."""
monkeypatch.delenv(
"GE_USAGE_STATS", raising=False
) # Undo the project-wide test default
context: DataContext = empty_data... | [
"def",
"test_cli_datasource_list",
"(",
"mock_emit",
",",
"empty_data_context",
",",
"empty_sqlite_db",
",",
"caplog",
",",
"monkeypatch",
")",
":",
"monkeypatch",
".",
"delenv",
"(",
"\"GE_USAGE_STATS\"",
",",
"raising",
"=",
"False",
")",
"# Undo the project-wide te... | [
16,
0
] | [
83,
62
] | python | en | ['en', 'en', 'en'] | True |
CallToActionRenderer.render | (cls, cta_object) |
:param cta_object: dict
{
"header": # optional, can be a string or string template
"buttons": # list of CallToActionButtons
}
:return: dict
{
"header": # optional, can be a string or string template
"but... |
:param cta_object: dict
{
"header": # optional, can be a string or string template
"buttons": # list of CallToActionButtons
}
:return: dict
{
"header": # optional, can be a string or string template
"but... | def render(cls, cta_object):
"""
:param cta_object: dict
{
"header": # optional, can be a string or string template
"buttons": # list of CallToActionButtons
}
:return: dict
{
"header": # optional, can be a string... | [
"def",
"render",
"(",
"cls",
",",
"cta_object",
")",
":",
"if",
"not",
"cta_object",
".",
"get",
"(",
"\"header\"",
")",
":",
"cta_object",
"[",
"\"header\"",
"]",
"=",
"cls",
".",
"_document_defaults",
".",
"get",
"(",
"\"header\"",
")",
"cta_object",
"... | [
22,
4
] | [
56,
25
] | python | en | ['en', 'error', 'th'] | False |
IRResource.lookup_default | (self, key: str, default_value: Optional[Any]=None, lookup_class: Optional[str]=None) |
Look up a key in the Ambassador module's "defaults" element.
The "lookup class" is
- the lookup_class parameter if one was passed, else
- self.default_class if that's set, else
- None.
We can look in two places for key -- the first match wins:
1. defaults[loo... |
Look up a key in the Ambassador module's "defaults" element. | def lookup_default(self, key: str, default_value: Optional[Any]=None, lookup_class: Optional[str]=None) -> Any:
"""
Look up a key in the Ambassador module's "defaults" element.
The "lookup class" is
- the lookup_class parameter if one was passed, else
- self.default_class if th... | [
"def",
"lookup_default",
"(",
"self",
",",
"key",
":",
"str",
",",
"default_value",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"lookup_class",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Any",
":",
"defaults",
"=",
"self",
"."... | [
87,
4
] | [
132,
28
] | python | en | ['en', 'error', 'th'] | False |
IRResource.lookup | (self, key: str, *args, default_class: Optional[str]=None, default_key: Optional[str]=None) |
Look up a key in this IRResource, with a fallback to the Ambassador module's "defaults"
element.
Here's the resolution order:
- if key is present in self, use its value.
- if not, use lookup_default above to try to find a value in the Ambassador module
- if we don't fi... |
Look up a key in this IRResource, with a fallback to the Ambassador module's "defaults"
element. | def lookup(self, key: str, *args, default_class: Optional[str]=None, default_key: Optional[str]=None) -> Any:
"""
Look up a key in this IRResource, with a fallback to the Ambassador module's "defaults"
element.
Here's the resolution order:
- if key is present in self, use its v... | [
"def",
"lookup",
"(",
"self",
",",
"key",
":",
"str",
",",
"*",
"args",
",",
"default_class",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"default_key",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Any",
":",
"value",
"=",
"... | [
134,
4
] | [
166,
20
] | python | en | ['en', 'error', 'th'] | False |
XephyrDisplay.__init__ | (self, size=(1024, 768), color_depth=24, bgcolor='black') |
:param bgcolor: 'black' or 'white'
|
:param bgcolor: 'black' or 'white'
| def __init__(self, size=(1024, 768), color_depth=24, bgcolor='black'):
'''
:param bgcolor: 'black' or 'white'
'''
self.color_depth = color_depth
self.size = size
self.bgcolor = bgcolor
self.screen = 0
self.process = None
self.display = None
... | [
"def",
"__init__",
"(",
"self",
",",
"size",
"=",
"(",
"1024",
",",
"768",
")",
",",
"color_depth",
"=",
"24",
",",
"bgcolor",
"=",
"'black'",
")",
":",
"self",
".",
"color_depth",
"=",
"color_depth",
"self",
".",
"size",
"=",
"size",
"self",
".",
... | [
12,
4
] | [
22,
38
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector.fit | (self, data, treatment, outcome) |
Fits the class.
|
Fits the class.
| def fit(self, data, treatment, outcome):
'''
Fits the class.
'''
if self._gain_equality_check():
self._fit_segment_model(data, treatment, outcome)
else:
self._fit_segment_model(data, treatment, outcome)
self._fit_condprob_models(data, treat... | [
"def",
"fit",
"(",
"self",
",",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"if",
"self",
".",
"_gain_equality_check",
"(",
")",
":",
"self",
".",
"_fit_segment_model",
"(",
"data",
",",
"treatment",
",",
"outcome",
")",
"else",
":",
"self",
".... | [
65,
4
] | [
77,
63
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector.predict | (self, data, treatment, outcome) |
Predicts an individual-level payoff. If gain equality is satisfied, uses
the exact function; if not, uses the midpoint between bounds.
|
Predicts an individual-level payoff. If gain equality is satisfied, uses
the exact function; if not, uses the midpoint between bounds.
| def predict(self, data, treatment, outcome):
'''
Predicts an individual-level payoff. If gain equality is satisfied, uses
the exact function; if not, uses the midpoint between bounds.
'''
if self._gain_equality_check():
est_payoff = self._get_exact_benefit(data, tre... | [
"def",
"predict",
"(",
"self",
",",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"if",
"self",
".",
"_gain_equality_check",
"(",
")",
":",
"est_payoff",
"=",
"self",
".",
"_get_exact_benefit",
"(",
"data",
",",
"treatment",
",",
"outcome",
")",
"e... | [
79,
4
] | [
93,
25
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector._gain_equality_check | (self) |
Checks if gain equality is satisfied. If so, the optimization task can
be simplified.
|
Checks if gain equality is satisfied. If so, the optimization task can
be simplified.
| def _gain_equality_check(self):
'''
Checks if gain equality is satisfied. If so, the optimization task can
be simplified.
'''
return self.complier_payoff + self.defier_payoff == \
self.alwaystaker_payoff + self.nevertaker_payoff | [
"def",
"_gain_equality_check",
"(",
"self",
")",
":",
"return",
"self",
".",
"complier_payoff",
"+",
"self",
".",
"defier_payoff",
"==",
"self",
".",
"alwaystaker_payoff",
"+",
"self",
".",
"nevertaker_payoff"
] | [
95,
4
] | [
102,
60
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector._make_segments | (data, treatment, outcome) |
Constructs the following segments:
* AC = Pr(Y = 1, W = 1 /mid X)
* AD = Pr(Y = 1, W = 0 /mid X)
* ND = Pr(Y = 0, W = 1 /mid X)
* ND = Pr(Y = 0, W = 0 /mid X)
where the names of the outcomes correspond the combinations of
the relevant segments, eg AC = Always-t... |
Constructs the following segments: | def _make_segments(data, treatment, outcome):
'''
Constructs the following segments:
* AC = Pr(Y = 1, W = 1 /mid X)
* AD = Pr(Y = 1, W = 0 /mid X)
* ND = Pr(Y = 0, W = 1 /mid X)
* ND = Pr(Y = 0, W = 0 /mid X)
where the names of the outcomes correspond the combin... | [
"def",
"_make_segments",
"(",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"segments",
"=",
"np",
".",
"empty",
"(",
"data",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"'object'",
")",
"segments",
"[",
"(",
"data",
"[",
"treatment",
"]",
... | [
105,
4
] | [
125,
23
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector._fit_segment_model | (self, data, treatment, outcome) |
Fits a classifier for estimating the probabilities for the unit
segment combinations.
|
Fits a classifier for estimating the probabilities for the unit
segment combinations.
| def _fit_segment_model(self, data, treatment, outcome):
'''
Fits a classifier for estimating the probabilities for the unit
segment combinations.
'''
model = clone(self.learner)
X = data.drop([treatment, outcome], axis=1)
y = self._make_segments(data, tr... | [
"def",
"_fit_segment_model",
"(",
"self",
",",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"model",
"=",
"clone",
"(",
"self",
".",
"learner",
")",
"X",
"=",
"data",
".",
"drop",
"(",
"[",
"treatment",
",",
"outcome",
"]",
",",
"axis",
"=",
... | [
127,
4
] | [
138,
44
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector._fit_condprob_models | (self, data, treatment, outcome) |
Fits two classifiers to estimate conversion probabilities conditional
on the treatment.
|
Fits two classifiers to estimate conversion probabilities conditional
on the treatment.
| def _fit_condprob_models(self, data, treatment, outcome):
'''
Fits two classifiers to estimate conversion probabilities conditional
on the treatment.
'''
trt_learner = clone(self.learner)
ctr_learner = clone(self.learner)
treated = data[treatment] == 1
... | [
"def",
"_fit_condprob_models",
"(",
"self",
",",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"trt_learner",
"=",
"clone",
"(",
"self",
".",
"learner",
")",
"ctr_learner",
"=",
"clone",
"(",
"self",
".",
"learner",
")",
"treated",
"=",
"data",
"["... | [
140,
4
] | [
155,
66
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector._get_exact_benefit | (self, data, treatment, outcome) |
Calculates the exact benefit function of Theorem 4 in Li and Pearl (2019).
Returns the exact benefit.
|
Calculates the exact benefit function of Theorem 4 in Li and Pearl (2019).
Returns the exact benefit.
| def _get_exact_benefit(self, data, treatment, outcome):
'''
Calculates the exact benefit function of Theorem 4 in Li and Pearl (2019).
Returns the exact benefit.
'''
beta = self.complier_payoff
gamma = self.alwaystaker_payoff
theta = self.nevertaker_payoff
... | [
"def",
"_get_exact_benefit",
"(",
"self",
",",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"beta",
"=",
"self",
".",
"complier_payoff",
"gamma",
"=",
"self",
".",
"alwaystaker_payoff",
"theta",
"=",
"self",
".",
"nevertaker_payoff",
"X",
"=",
"data",... | [
157,
4
] | [
174,
22
] | python | en | ['en', 'error', 'th'] | False |
CounterfactualUnitSelector._obj_func_midp | (self, data, treatment, outcome) |
Calculates bounds for the objective function. Returns the midpoint
between bounds.
Parameters
----------
pr_y1_w1 : float
The probability of conversion given treatment assignment.
pr_y1_w0 : float
The probability of conversion given control assi... |
Calculates bounds for the objective function. Returns the midpoint
between bounds. | def _obj_func_midp(self, data, treatment, outcome):
'''
Calculates bounds for the objective function. Returns the midpoint
between bounds.
Parameters
----------
pr_y1_w1 : float
The probability of conversion given treatment assignment.
pr_y1_w0 : flo... | [
"def",
"_obj_func_midp",
"(",
"self",
",",
"data",
",",
"treatment",
",",
"outcome",
")",
":",
"X",
"=",
"data",
".",
"drop",
"(",
"[",
"treatment",
",",
"outcome",
"]",
",",
"axis",
"=",
"1",
")",
"beta",
"=",
"self",
".",
"complier_payoff",
"gamma"... | [
176,
4
] | [
271,
46
] | python | en | ['en', 'error', 'th'] | False |
cs | (arg1, arg2=None) | cs returns a formatted 'control sequence' (ECMA-48 §5.4).
This only supports text/ASCII ("7-bit") control seqences, and does
support binary ("8-bit") control seqeneces.
This only supports standard parameters (ECMA-48 §5.4.1.a /
§5.4.2), and does NOT support "experimental"/"private" parameters
(ECMA-... | cs returns a formatted 'control sequence' (ECMA-48 §5.4).
This only supports text/ASCII ("7-bit") control seqences, and does
support binary ("8-bit") control seqeneces.
This only supports standard parameters (ECMA-48 §5.4.1.a /
§5.4.2), and does NOT support "experimental"/"private" parameters
(ECMA-... | def cs(arg1, arg2=None): # type: ignore
"""cs returns a formatted 'control sequence' (ECMA-48 §5.4).
This only supports text/ASCII ("7-bit") control seqences, and does
support binary ("8-bit") control seqeneces.
This only supports standard parameters (ECMA-48 §5.4.1.a /
§5.4.2), and does NOT suppor... | [
"def",
"cs",
"(",
"arg1",
",",
"arg2",
"=",
"None",
")",
":",
"# type: ignore",
"csi",
"=",
"'\\033['",
"if",
"arg2",
":",
"params",
":",
"List",
"[",
"_number",
"]",
"=",
"arg1",
"op",
":",
"str",
"=",
"arg2",
"else",
":",
"params",
"=",
"[",
"]... | [
32,
0
] | [
47,
74
] | python | en | ['ca', 'en', 'en'] | True |
cursor_up | (lines: int = 1) | Generate the "CUU" ("CUrsor Up") control sequence (ECMA-48 §8.3.22). | Generate the "CUU" ("CUrsor Up") control sequence (ECMA-48 §8.3.22). | def cursor_up(lines: int = 1) -> str:
"""Generate the "CUU" ("CUrsor Up") control sequence (ECMA-48 §8.3.22)."""
if lines == 1:
return cs('A')
return cs([lines], 'A') | [
"def",
"cursor_up",
"(",
"lines",
":",
"int",
"=",
"1",
")",
"->",
"str",
":",
"if",
"lines",
"==",
"1",
":",
"return",
"cs",
"(",
"'A'",
")",
"return",
"cs",
"(",
"[",
"lines",
"]",
",",
"'A'",
")"
] | [
59,
0
] | [
63,
27
] | python | en | ['en', 'ca', 'en'] | True |
Base.__log_all_options_if_none_specified | (self, test) |
When testing_base is specified, but none of the log options to save are
specified (basic_test_info, screen_shots, page_source), then save them
all by default. Otherwise, save only selected ones from their plugins.
|
When testing_base is specified, but none of the log options to save are
specified (basic_test_info, screen_shots, page_source), then save them
all by default. Otherwise, save only selected ones from their plugins.
| def __log_all_options_if_none_specified(self, test):
"""
When testing_base is specified, but none of the log options to save are
specified (basic_test_info, screen_shots, page_source), then save them
all by default. Otherwise, save only selected ones from their plugins.
"""
... | [
"def",
"__log_all_options_if_none_specified",
"(",
"self",
",",
"test",
")",
":",
"if",
"(",
"(",
"not",
"self",
".",
"options",
".",
"enable_plugin_basic_test_info",
")",
"and",
"(",
"not",
"self",
".",
"options",
".",
"enable_plugin_screen_shots",
")",
"and",
... | [
167,
4
] | [
180,
65
] | python | en | ['en', 'error', 'th'] | False |
Base.addError | (self, test, err, capt=None) |
Since Skip, Blocked, and Deprecated are all technically errors, but not
error states, we want to make sure that they don't show up in
the nose output as errors.
|
Since Skip, Blocked, and Deprecated are all technically errors, but not
error states, we want to make sure that they don't show up in
the nose output as errors.
| def addError(self, test, err, capt=None):
"""
Since Skip, Blocked, and Deprecated are all technically errors, but not
error states, we want to make sure that they don't show up in
the nose output as errors.
"""
if (err[0] == errors.BlockedTest or (
err[0] ... | [
"def",
"addError",
"(",
"self",
",",
"test",
",",
"err",
",",
"capt",
"=",
"None",
")",
":",
"if",
"(",
"err",
"[",
"0",
"]",
"==",
"errors",
".",
"BlockedTest",
"or",
"(",
"err",
"[",
"0",
"]",
"==",
"errors",
".",
"SkipTest",
")",
"or",
"(",
... | [
210,
4
] | [
225,
38
] | python | en | ['en', 'error', 'th'] | False |
Base.handleError | (self, test, err, capt=None) |
If the database plugin is not present, we have to handle capturing
"errors" that shouldn't be reported as such in base.
|
If the database plugin is not present, we have to handle capturing
"errors" that shouldn't be reported as such in base.
| def handleError(self, test, err, capt=None):
"""
If the database plugin is not present, we have to handle capturing
"errors" that shouldn't be reported as such in base.
"""
if not hasattr(test.test, "testcase_guid"):
if err[0] == errors.BlockedTest:
ra... | [
"def",
"handleError",
"(",
"self",
",",
"test",
",",
"err",
",",
"capt",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"test",
".",
"test",
",",
"\"testcase_guid\"",
")",
":",
"if",
"err",
"[",
"0",
"]",
"==",
"errors",
".",
"BlockedTest",
":... | [
227,
4
] | [
243,
27
] | python | en | ['en', 'error', 'th'] | False |
IVRegressor.__init__ | (self) |
Initializes the class.
|
Initializes the class.
| def __init__(self):
'''
Initializes the class.
'''
self.method = '2SLS' | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"method",
"=",
"'2SLS'"
] | [
14,
4
] | [
19,
28
] | python | en | ['en', 'error', 'th'] | False |
IVRegressor.fit | (self, X, treatment, y, w) | Fits the 2SLS model.
Args:
X (np.matrix or np.array or pd.Dataframe): a feature matrix
treatment (np.array or pd.Series): a treatment vector
y (np.array or pd.Series): an outcome vector
w (np.array or pd.Series): an instrument vector
| Fits the 2SLS model. | def fit(self, X, treatment, y, w):
''' Fits the 2SLS model.
Args:
X (np.matrix or np.array or pd.Dataframe): a feature matrix
treatment (np.array or pd.Series): a treatment vector
y (np.array or pd.Series): an outcome vector
w (np.array or pd.Series): an ... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"treatment",
",",
"y",
",",
"w",
")",
":",
"X",
",",
"treatment",
",",
"y",
",",
"w",
"=",
"convert_pd_to_np",
"(",
"X",
",",
"treatment",
",",
"y",
",",
"w",
")",
"exog",
"=",
"sm",
".",
"add_constant"... | [
21,
4
] | [
38,
41
] | python | en | ['en', 'ca', 'en'] | True |
IVRegressor.predict | (self) | Returns the average treatment effect and its estimated standard error
Returns:
(float): average treatment effect
(float): standard error of the estimation
| Returns the average treatment effect and its estimated standard error | def predict(self):
'''Returns the average treatment effect and its estimated standard error
Returns:
(float): average treatment effect
(float): standard error of the estimation
'''
return self.iv_fit.params[-1], self.iv_fit.bse[-1] | [
"def",
"predict",
"(",
"self",
")",
":",
"return",
"self",
".",
"iv_fit",
".",
"params",
"[",
"-",
"1",
"]",
",",
"self",
".",
"iv_fit",
".",
"bse",
"[",
"-",
"1",
"]"
] | [
40,
4
] | [
48,
58
] | python | en | ['en', 'en', 'en'] | True |
MultiPartForm.add_field | (self, name, value) | Add a simple field to the form data. | Add a simple field to the form data. | def add_field(self, name, value):
"""Add a simple field to the form data."""
if not isinstance(value, str):
value = json.dumps(value, ensure_ascii=False)
self.form_fields.append((name, value))
return | [
"def",
"add_field",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"value",
"=",
"json",
".",
"dumps",
"(",
"value",
",",
"ensure_ascii",
"=",
"False",
")",
"self",
".",
"form_fields",... | [
44,
4
] | [
49,
14
] | python | en | ['en', 'en', 'en'] | True |
MultiPartForm.add_file | (self, field_name, file_name, file_content, mimetype=None) | Add a file to be uploaded. | Add a file to be uploaded. | def add_file(self, field_name, file_name, file_content, mimetype=None):
"""Add a file to be uploaded."""
if mimetype is None:
mimetype = mimetypes.guess_type(file_name)[0] or 'application/octet-stream'
self.files.append((field_name, file_name, mimetype, file_content))
return | [
"def",
"add_file",
"(",
"self",
",",
"field_name",
",",
"file_name",
",",
"file_content",
",",
"mimetype",
"=",
"None",
")",
":",
"if",
"mimetype",
"is",
"None",
":",
"mimetype",
"=",
"mimetypes",
".",
"guess_type",
"(",
"file_name",
")",
"[",
"0",
"]",
... | [
51,
4
] | [
56,
14
] | python | en | ['en', 'en', 'en'] | True |
MultiPartForm.build_body | (self) | Return a string representing the form data, including attached files. | Return a string representing the form data, including attached files. | def build_body(self):
"""Return a string representing the form data, including attached files."""
# Build a list of lists, each containing "lines" of the
# request. Each part is separated by a boundary string.
# Once the list is built, return a string where each
# line is separa... | [
"def",
"build_body",
"(",
"self",
")",
":",
"# Build a list of lists, each containing \"lines\" of the",
"# request. Each part is separated by a boundary string.",
"# Once the list is built, return a string where each",
"# line is separated by '\\r\\n'.",
"parts",
"=",
"[",
"]",
"part_b... | [
58,
4
] | [
98,
65
] | python | en | ['en', 'en', 'en'] | True |
get_index | (subjects, ra) |
Usage: sort input poses by the distance to [mean pose] from train data
sorted from large to small
:param subjects: e.g. Test set
:return: Reversed Index in the Test set
|
Usage: sort input poses by the distance to [mean pose] from train data
sorted from large to small
:param subjects: e.g. Test set
:return: Reversed Index in the Test set
| def get_index(subjects, ra):
"""
Usage: sort input poses by the distance to [mean pose] from train data
sorted from large to small
:param subjects: e.g. Test set
:return: Reversed Index in the Test set
"""
train_pose_3d = []
for subject in subjects:
#print('subject',subjec... | [
"def",
"get_index",
"(",
"subjects",
",",
"ra",
")",
":",
"train_pose_3d",
"=",
"[",
"]",
"for",
"subject",
"in",
"subjects",
":",
"#print('subject',subject)",
"for",
"action",
"in",
"dataset",
"[",
"subject",
"]",
".",
"keys",
"(",
")",
":",
"#print('acti... | [
113,
0
] | [
159,
17
] | python | en | ['en', 'error', 'th'] | False |
split_data | (index) |
Partition index into a list, make one more dimension
:param index: a so long list
:return out: splited index, type: List
|
Partition index into a list, make one more dimension
:param index: a so long list
:return out: splited index, type: List
| def split_data(index):
"""
Partition index into a list, make one more dimension
:param index: a so long list
:return out: splited index, type: List
"""
out = []
j = 0
for i in index:
if i < len(index)-1:
if index[i+1] - index[i]>5:
print('Split index i... | [
"def",
"split_data",
"(",
"index",
")",
":",
"out",
"=",
"[",
"]",
"j",
"=",
"0",
"for",
"i",
"in",
"index",
":",
"if",
"i",
"<",
"len",
"(",
"index",
")",
"-",
"1",
":",
"if",
"index",
"[",
"i",
"+",
"1",
"]",
"-",
"index",
"[",
"i",
"]"... | [
179,
0
] | [
196,
14
] | python | en | ['en', 'error', 'th'] | False |
SocketStream.setsockopt | (self, level, option, value) | Set an option on the underlying socket.
See :meth:`socket.socket.setsockopt` for details.
| Set an option on the underlying socket. | def setsockopt(self, level, option, value):
"""Set an option on the underlying socket.
See :meth:`socket.socket.setsockopt` for details.
"""
return self.socket.setsockopt(level, option, value) | [
"def",
"setsockopt",
"(",
"self",
",",
"level",
",",
"option",
",",
"value",
")",
":",
"return",
"self",
".",
"socket",
".",
"setsockopt",
"(",
"level",
",",
"option",
",",
"value",
")"
] | [
143,
4
] | [
149,
59
] | python | en | ['en', 'no', 'en'] | True |
SocketStream.getsockopt | (self, level, option, buffersize=0) | Check the current value of an option on the underlying socket.
See :meth:`socket.socket.getsockopt` for details.
| Check the current value of an option on the underlying socket. | def getsockopt(self, level, option, buffersize=0):
"""Check the current value of an option on the underlying socket.
See :meth:`socket.socket.getsockopt` for details.
"""
# This is to work around
# https://bitbucket.org/pypy/pypy/issues/2561
# We should be able to dro... | [
"def",
"getsockopt",
"(",
"self",
",",
"level",
",",
"option",
",",
"buffersize",
"=",
"0",
")",
":",
"# This is to work around",
"# https://bitbucket.org/pypy/pypy/issues/2561",
"# We should be able to drop it when the next PyPy3 beta is released.",
"if",
"buffersize",
"==",... | [
151,
4
] | [
163,
68
] | python | en | ['en', 'en', 'en'] | True |
SocketListener.accept | (self) | Accept an incoming connection.
Returns:
:class:`SocketStream`
Raises:
OSError: if the underlying call to ``accept`` raises an unexpected
error.
ClosedResourceError: if you already closed the socket.
This method handles routine errors like ``ECONNABO... | Accept an incoming connection. | async def accept(self):
"""Accept an incoming connection.
Returns:
:class:`SocketStream`
Raises:
OSError: if the underlying call to ``accept`` raises an unexpected
error.
ClosedResourceError: if you already closed the socket.
This method han... | [
"async",
"def",
"accept",
"(",
"self",
")",
":",
"while",
"True",
":",
"try",
":",
"sock",
",",
"_",
"=",
"await",
"self",
".",
"socket",
".",
"accept",
"(",
")",
"except",
"OSError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"in",
"_closed_stre... | [
350,
4
] | [
376,
41
] | python | en | ['en', 'en', 'en'] | True |
SocketListener.aclose | (self) | Close this listener and its underlying socket. | Close this listener and its underlying socket. | async def aclose(self):
"""Close this listener and its underlying socket."""
self.socket.close()
await trio.lowlevel.checkpoint() | [
"async",
"def",
"aclose",
"(",
"self",
")",
":",
"self",
".",
"socket",
".",
"close",
"(",
")",
"await",
"trio",
".",
"lowlevel",
".",
"checkpoint",
"(",
")"
] | [
378,
4
] | [
381,
40
] | python | en | ['en', 'en', 'en'] | True |
current_statistics | () | Returns an object containing run-loop-level debugging information.
Currently the following fields are defined:
* ``tasks_living`` (int): The number of tasks that have been spawned
and not yet exited.
* ``tasks_runnable`` (int): The number of tasks that are currently
queued ... | Returns an object containing run-loop-level debugging information. | def current_statistics():
"""Returns an object containing run-loop-level debugging information.
Currently the following fields are defined:
* ``tasks_living`` (int): The number of tasks that have been spawned
and not yet exited.
* ``tasks_runnable`` (int): The number of tasks tha... | [
"def",
"current_statistics",
"(",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"current_statistics",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"... | [
10,
0
] | [
37,
63
] | python | en | ['en', 'en', 'en'] | True |
current_time | () | Returns the current time according to Trio's internal clock.
Returns:
float: The current time.
Raises:
RuntimeError: if not inside a call to :func:`trio.run`.
| Returns the current time according to Trio's internal clock. | def current_time():
"""Returns the current time according to Trio's internal clock.
Returns:
float: The current time.
Raises:
RuntimeError: if not inside a call to :func:`trio.run`.
"""
locals()[LOCALS_KEY_KI_PROTECTION_ENABLED] = True
try:
return G... | [
"def",
"current_time",
"(",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"current_time",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"RuntimeError... | [
40,
0
] | [
54,
63
] | python | en | ['en', 'en', 'en'] | True |
current_clock | () | Returns the current :class:`~trio.abc.Clock`. | Returns the current :class:`~trio.abc.Clock`. | def current_clock():
"""Returns the current :class:`~trio.abc.Clock`."""
locals()[LOCALS_KEY_KI_PROTECTION_ENABLED] = True
try:
return GLOBAL_RUN_CONTEXT.runner.current_clock()
except AttributeError:
raise RuntimeError("must be called from async context") | [
"def",
"current_clock",
"(",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"current_clock",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"RuntimeErr... | [
57,
0
] | [
63,
63
] | python | en | ['en', 'la', 'en'] | True |
current_root_task | () | Returns the current root :class:`Task`.
This is the task that is the ultimate parent of all other tasks.
| Returns the current root :class:`Task`. | def current_root_task():
"""Returns the current root :class:`Task`.
This is the task that is the ultimate parent of all other tasks.
"""
locals()[LOCALS_KEY_KI_PROTECTION_ENABLED] = True
try:
return GLOBAL_RUN_CONTEXT.runner.current_root_task()
except AttributeError:
ra... | [
"def",
"current_root_task",
"(",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"current_root_task",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"Ru... | [
66,
0
] | [
76,
63
] | python | en | ['en', 'en', 'en'] | True |
reschedule | (task, next_send=_NO_SEND) | Reschedule the given task with the given
:class:`outcome.Outcome`.
See :func:`wait_task_rescheduled` for the gory details.
There must be exactly one call to :func:`reschedule` for every call to
:func:`wait_task_rescheduled`. (And when counting, keep in mind that
returning :data... | Reschedule the given task with the given
:class:`outcome.Outcome`. | def reschedule(task, next_send=_NO_SEND):
"""Reschedule the given task with the given
:class:`outcome.Outcome`.
See :func:`wait_task_rescheduled` for the gory details.
There must be exactly one call to :func:`reschedule` for every call to
:func:`wait_task_rescheduled`. (And when co... | [
"def",
"reschedule",
"(",
"task",
",",
"next_send",
"=",
"_NO_SEND",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"reschedule",
"(",
"task",
",",
"nex... | [
79,
0
] | [
101,
63
] | python | en | ['en', 'en', 'en'] | True |
spawn_system_task | (async_fn, *args, name=None) | Spawn a "system" task.
System tasks have a few differences from regular tasks:
* They don't need an explicit nursery; instead they go into the
internal "system nursery".
* If a system task raises an exception, then it's converted into a
:exc:`~trio.TrioInternalError` and *... | Spawn a "system" task. | def spawn_system_task(async_fn, *args, name=None):
"""Spawn a "system" task.
System tasks have a few differences from regular tasks:
* They don't need an explicit nursery; instead they go into the
internal "system nursery".
* If a system task raises an exception, then it's conve... | [
"def",
"spawn_system_task",
"(",
"async_fn",
",",
"*",
"args",
",",
"name",
"=",
"None",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"spawn_system_task... | [
104,
0
] | [
156,
63
] | python | cy | ['cy', 'cy', 'en'] | True |
current_trio_token | () | Retrieve the :class:`TrioToken` for the current call to
:func:`trio.run`.
| Retrieve the :class:`TrioToken` for the current call to
:func:`trio.run`. | def current_trio_token():
"""Retrieve the :class:`TrioToken` for the current call to
:func:`trio.run`.
"""
locals()[LOCALS_KEY_KI_PROTECTION_ENABLED] = True
try:
return GLOBAL_RUN_CONTEXT.runner.current_trio_token()
except AttributeError:
raise RuntimeError("must be call... | [
"def",
"current_trio_token",
"(",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"GLOBAL_RUN_CONTEXT",
".",
"runner",
".",
"current_trio_token",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"... | [
159,
0
] | [
168,
63
] | python | en | ['en', 'pt', 'en'] | True |
wait_all_tasks_blocked | (cushion=0.0, tiebreaker='deprecated') | Block until there are no runnable tasks.
This is useful in testing code when you want to give other tasks a
chance to "settle down". The calling task is blocked, and doesn't wake
up until all other tasks are also blocked for at least ``cushion``
seconds. (Setting a non-zero ``cushion`` ... | Block until there are no runnable tasks. | async def wait_all_tasks_blocked(cushion=0.0, tiebreaker='deprecated'):
"""Block until there are no runnable tasks.
This is useful in testing code when you want to give other tasks a
chance to "settle down". The calling task is blocked, and doesn't wake
up until all other tasks are also blo... | [
"async",
"def",
"wait_all_tasks_blocked",
"(",
"cushion",
"=",
"0.0",
",",
"tiebreaker",
"=",
"'deprecated'",
")",
":",
"locals",
"(",
")",
"[",
"LOCALS_KEY_KI_PROTECTION_ENABLED",
"]",
"=",
"True",
"try",
":",
"return",
"await",
"GLOBAL_RUN_CONTEXT",
".",
"runn... | [
171,
0
] | [
233,
63
] | python | en | ['en', 'en', 'en'] | True |
ExpandXcodeVariables | (string, expansions) | Expands Xcode-style $(VARIABLES) in string per the expansions dict.
In some rare cases, it is appropriate to expand Xcode variables when a
project file is generated. For any substring $(VAR) in string, if VAR is a
key in the expansions dict, $(VAR) will be replaced with expansions[VAR].
Any $(VAR) substring i... | Expands Xcode-style $(VARIABLES) in string per the expansions dict. | def ExpandXcodeVariables(string, expansions):
"""Expands Xcode-style $(VARIABLES) in string per the expansions dict.
In some rare cases, it is appropriate to expand Xcode variables when a
project file is generated. For any substring $(VAR) in string, if VAR is a
key in the expansions dict, $(VAR) will be repl... | [
"def",
"ExpandXcodeVariables",
"(",
"string",
",",
"expansions",
")",
":",
"matches",
"=",
"_xcode_variable_re",
".",
"findall",
"(",
"string",
")",
"if",
"matches",
"==",
"None",
":",
"return",
"string",
"matches",
".",
"reverse",
"(",
")",
"for",
"match",
... | [
529,
0
] | [
552,
15
] | python | en | ['en', 'en', 'en'] | True |
EscapeXcodeDefine | (s) | We must escape the defines that we give to XCode so that it knows not to
split on spaces and to respect backslash and quote literals. However, we
must not quote the define, or Xcode will incorrectly intepret variables
especially $(inherited). | We must escape the defines that we give to XCode so that it knows not to
split on spaces and to respect backslash and quote literals. However, we
must not quote the define, or Xcode will incorrectly intepret variables
especially $(inherited). | def EscapeXcodeDefine(s):
"""We must escape the defines that we give to XCode so that it knows not to
split on spaces and to respect backslash and quote literals. However, we
must not quote the define, or Xcode will incorrectly intepret variables
especially $(inherited)."""
return re.sub(_xcode_defin... | [
"def",
"EscapeXcodeDefine",
"(",
"s",
")",
":",
"return",
"re",
".",
"sub",
"(",
"_xcode_define_re",
",",
"r'\\\\\\1'",
",",
"s",
")"
] | [
556,
0
] | [
561,
45
] | python | en | ['en', 'en', 'en'] | True |
render_multiple_validation_result_pages_markdown | (
validation_operator_result: ValidationOperatorResult,
run_info_at_end: bool = True,
) |
Loop through and render multiple validation results to markdown.
Args:
validation_operator_result: (ValidationOperatorResult) Result of validation operator run
run_info_at_end: move run info below expectation results
Returns:
string containing formatted markdown validation results
... |
Loop through and render multiple validation results to markdown.
Args:
validation_operator_result: (ValidationOperatorResult) Result of validation operator run
run_info_at_end: move run info below expectation results
Returns:
string containing formatted markdown validation results
... | def render_multiple_validation_result_pages_markdown(
validation_operator_result: ValidationOperatorResult,
run_info_at_end: bool = True,
) -> str:
"""
Loop through and render multiple validation results to markdown.
Args:
validation_operator_result: (ValidationOperatorResult) Result of vali... | [
"def",
"render_multiple_validation_result_pages_markdown",
"(",
"validation_operator_result",
":",
"ValidationOperatorResult",
",",
"run_info_at_end",
":",
"bool",
"=",
"True",
",",
")",
"->",
"str",
":",
"warnings",
".",
"warn",
"(",
"\"This 'render_multiple_validation_res... | [
9,
0
] | [
46,
85
] | python | en | ['en', 'error', 'th'] | False |
MockClock.jump | (self, seconds) | Manually advance the clock by the given number of seconds.
Args:
seconds (float): the number of seconds to jump the clock forward.
Raises:
ValueError: if you try to pass a negative value for ``seconds``.
| Manually advance the clock by the given number of seconds. | def jump(self, seconds):
"""Manually advance the clock by the given number of seconds.
Args:
seconds (float): the number of seconds to jump the clock forward.
Raises:
ValueError: if you try to pass a negative value for ``seconds``.
"""
if seconds < 0:
... | [
"def",
"jump",
"(",
"self",
",",
"seconds",
")",
":",
"if",
"seconds",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"time can't go backwards\"",
")",
"self",
".",
"_virtual_base",
"+=",
"seconds"
] | [
152,
4
] | [
164,
37
] | python | en | ['en', 'en', 'en'] | True |
escape_html | (text) | Escape &, <, > as well as single and double quotes for HTML. | Escape &, <, > as well as single and double quotes for HTML. | def escape_html(text):
"""Escape &, <, > as well as single and double quotes for HTML."""
return text.replace('&', '&'). \
replace('<', '<'). \
replace('>', '>'). \
replace('"', '"'). \
replace("'", ''') | [
"def",
"escape_html",
"(",
"text",
")",
":",
"return",
"text",
".",
"replace",
"(",
"'&'",
",",
"'&'",
")",
".",
"replace",
"(",
"'<'",
",",
"'<'",
")",
".",
"replace",
"(",
"'>'",
",",
"'>'",
")",
".",
"replace",
"(",
"'\"'",
",",
"'&quo... | [
17,
0
] | [
23,
37
] | python | en | ['en', 'en', 'en'] | True |
SvgFormatter.format_unencoded | (self, tokensource, outfile) |
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``.
For our implementation we put all lines in their own 'line group'.
|
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``. | def format_unencoded(self, tokensource, outfile):
"""
Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
tuples and write it into ``outfile``.
For our implementation we put all lines in their own 'line group'.
"""
x = self.xoffset
y = self.yoffse... | [
"def",
"format_unencoded",
"(",
"self",
",",
"tokensource",
",",
"outfile",
")",
":",
"x",
"=",
"self",
".",
"xoffset",
"y",
"=",
"self",
".",
"yoffset",
"if",
"not",
"self",
".",
"nowrap",
":",
"if",
"self",
".",
"encoding",
":",
"outfile",
".",
"wr... | [
96,
4
] | [
135,
41
] | python | en | ['en', 'error', 'th'] | False |
ColumnStandardDeviation._pandas | (cls, column, **kwargs) | Pandas Standard Deviation implementation | Pandas Standard Deviation implementation | def _pandas(cls, column, **kwargs):
"""Pandas Standard Deviation implementation"""
return column.std() | [
"def",
"_pandas",
"(",
"cls",
",",
"column",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"column",
".",
"std",
"(",
")"
] | [
34,
4
] | [
36,
27
] | python | en | ['pt', 'fr', 'en'] | False |
ColumnStandardDeviation._sqlalchemy | (cls, column, _dialect, **kwargs) | SqlAlchemy Standard Deviation implementation | SqlAlchemy Standard Deviation implementation | def _sqlalchemy(cls, column, _dialect, **kwargs):
"""SqlAlchemy Standard Deviation implementation"""
if _dialect.name.lower() == "mssql":
standard_deviation = sa.func.stdev(column)
else:
standard_deviation = sa.func.stddev_samp(column)
return standard_deviation | [
"def",
"_sqlalchemy",
"(",
"cls",
",",
"column",
",",
"_dialect",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"_dialect",
".",
"name",
".",
"lower",
"(",
")",
"==",
"\"mssql\"",
":",
"standard_deviation",
"=",
"sa",
".",
"func",
".",
"stdev",
"(",
"colu... | [
39,
4
] | [
45,
33
] | python | en | ['en', 'de', 'en'] | True |
ColumnStandardDeviation._spark | (cls, column, **kwargs) | Spark Standard Deviation implementation | Spark Standard Deviation implementation | def _spark(cls, column, **kwargs):
"""Spark Standard Deviation implementation"""
return F.stddev_samp(column) | [
"def",
"_spark",
"(",
"cls",
",",
"column",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"F",
".",
"stddev_samp",
"(",
"column",
")"
] | [
48,
4
] | [
50,
36
] | python | en | ['en', 'da', 'en'] | True |
build_anomaly_intervals | (X, y, time_column, severity=True, indices=False) | Group together consecutive anomalous samples in anomaly intervals.
This is a dummy boundary detection function that groups together
samples that have been consecutively flagged as anomalous and
returns boundaries of anomalous intervals.
Optionally, it computes the average severity of each interval.
... | Group together consecutive anomalous samples in anomaly intervals. | def build_anomaly_intervals(X, y, time_column, severity=True, indices=False):
"""Group together consecutive anomalous samples in anomaly intervals.
This is a dummy boundary detection function that groups together
samples that have been consecutively flagged as anomalous and
returns boundaries of anomal... | [
"def",
"build_anomaly_intervals",
"(",
"X",
",",
"y",
",",
"time_column",
",",
"severity",
"=",
"True",
",",
"indices",
"=",
"False",
")",
":",
"timestamps",
"=",
"X",
"[",
"time_column",
"]",
"start",
"=",
"None",
"start_ts",
"=",
"None",
"intervals",
"... | [
3,
0
] | [
54,
30
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.