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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GetArrayViewFromVnlVector | (vnlVector) | Get an array view of vnlVector
| Get an array view of vnlVector
| def GetArrayViewFromVnlVector(vnlVector):
"""Get an array view of vnlVector
"""
return _GetArrayFromVnlObject(vnlVector, "GetArrayViewFromVnlVector") | [
"def",
"GetArrayViewFromVnlVector",
"(",
"vnlVector",
")",
":",
"return",
"_GetArrayFromVnlObject",
"(",
"vnlVector",
",",
"\"GetArrayViewFromVnlVector\"",
")"
] | [
304,
0
] | [
307,
73
] | python | en | ['en', 'en', 'en'] | True |
GetArrayFromVnlMatrix | (vnlMatrix) | Get an array with the content of vnlMatrix
| Get an array with the content of vnlMatrix
| def GetArrayFromVnlMatrix(vnlMatrix):
"""Get an array with the content of vnlMatrix
"""
return _GetArrayFromVnlObject(vnlMatrix, "GetArrayFromVnlMatrix") | [
"def",
"GetArrayFromVnlMatrix",
"(",
"vnlMatrix",
")",
":",
"return",
"_GetArrayFromVnlObject",
"(",
"vnlMatrix",
",",
"\"GetArrayFromVnlMatrix\"",
")"
] | [
309,
0
] | [
312,
69
] | python | en | ['en', 'en', 'en'] | True |
GetArrayViewFromVnlMatrix | (vnlMatrix) | Get an array view of vnlMatrix
| Get an array view of vnlMatrix
| def GetArrayViewFromVnlMatrix(vnlMatrix):
"""Get an array view of vnlMatrix
"""
return _GetArrayFromVnlObject(vnlMatrix, "GetArrayViewFromVnlMatrix") | [
"def",
"GetArrayViewFromVnlMatrix",
"(",
"vnlMatrix",
")",
":",
"return",
"_GetArrayFromVnlObject",
"(",
"vnlMatrix",
",",
"\"GetArrayViewFromVnlMatrix\"",
")"
] | [
314,
0
] | [
317,
73
] | python | en | ['en', 'lb', 'en'] | True |
_GetVnlObjectFromArray | (arr, function) | Get a vnl object from a Python array.
| Get a vnl object from a Python array.
| def _GetVnlObjectFromArray(arr, function):
"""Get a vnl object from a Python array.
"""
if not HAVE_NUMPY:
raise ImportError('Numpy not available.')
import itk
PixelType = _get_itk_pixelid(arr)
templatedFunction = getattr(itk.PyVnl[PixelType], function)
return templatedFunction(arr) | [
"def",
"_GetVnlObjectFromArray",
"(",
"arr",
",",
"function",
")",
":",
"if",
"not",
"HAVE_NUMPY",
":",
"raise",
"ImportError",
"(",
"'Numpy not available.'",
")",
"import",
"itk",
"PixelType",
"=",
"_get_itk_pixelid",
"(",
"arr",
")",
"templatedFunction",
"=",
... | [
319,
0
] | [
327,
33
] | python | en | ['en', 'en', 'en'] | True |
GetVnlVectorFromArray | (arr) | Get a vnl vector from a Python array.
| Get a vnl vector from a Python array.
| def GetVnlVectorFromArray(arr):
"""Get a vnl vector from a Python array.
"""
return _GetVnlObjectFromArray(arr, "GetVnlVectorFromArray") | [
"def",
"GetVnlVectorFromArray",
"(",
"arr",
")",
":",
"return",
"_GetVnlObjectFromArray",
"(",
"arr",
",",
"\"GetVnlVectorFromArray\"",
")"
] | [
329,
0
] | [
332,
63
] | python | en | ['en', 'lb', 'en'] | True |
GetVnlMatrixFromArray | (arr) | Get a vnl matrix from a Python array.
| Get a vnl matrix from a Python array.
| def GetVnlMatrixFromArray(arr):
"""Get a vnl matrix from a Python array.
"""
return _GetVnlObjectFromArray(arr, "GetVnlMatrixFromArray") | [
"def",
"GetVnlMatrixFromArray",
"(",
"arr",
")",
":",
"return",
"_GetVnlObjectFromArray",
"(",
"arr",
",",
"\"GetVnlMatrixFromArray\"",
")"
] | [
334,
0
] | [
337,
63
] | python | en | ['en', 'lb', 'en'] | True |
template | (cl) | Return the template of a class (or of the class of an object) and
its parameters
template() returns a tuple with 2 elements:
- the first one is the itkTemplate object
- the second is a tuple containing the template parameters
| Return the template of a class (or of the class of an object) and
its parameters | def template(cl):
"""Return the template of a class (or of the class of an object) and
its parameters
template() returns a tuple with 2 elements:
- the first one is the itkTemplate object
- the second is a tuple containing the template parameters
"""
from itkTemplate import itkTempl... | [
"def",
"template",
"(",
"cl",
")",
":",
"from",
"itkTemplate",
"import",
"itkTemplate",
"return",
"itkTemplate",
".",
"__class_to_template__",
"[",
"class_",
"(",
"cl",
")",
"]"
] | [
343,
0
] | [
352,
56
] | python | en | ['en', 'en', 'en'] | True |
ctype | (s) | Return the c type corresponding to the string passed in parameter
The string can contain some extra spaces.
see also itkCType
| Return the c type corresponding to the string passed in parameter | def ctype(s):
"""Return the c type corresponding to the string passed in parameter
The string can contain some extra spaces.
see also itkCType
"""
from itkTypes import itkCType
ret = itkCType.GetCType(" ".join(s.split()))
if ret is None:
raise KeyError("Unrecognized C type '%s'" % ... | [
"def",
"ctype",
"(",
"s",
")",
":",
"from",
"itkTypes",
"import",
"itkCType",
"ret",
"=",
"itkCType",
".",
"GetCType",
"(",
"\" \"",
".",
"join",
"(",
"s",
".",
"split",
"(",
")",
")",
")",
"if",
"ret",
"is",
"None",
":",
"raise",
"KeyError",
"(",
... | [
355,
0
] | [
366,
14
] | python | en | ['en', 'en', 'en'] | True |
class_ | (obj) | Return a class from an object
Often in itk, the __class__ is not what the user is expecting.
class_() should do a better job
| Return a class from an object | def class_(obj):
"""Return a class from an object
Often in itk, the __class__ is not what the user is expecting.
class_() should do a better job
"""
import inspect
if inspect.isclass(obj):
# obj is already a class !
return obj
else:
return obj.__class__ | [
"def",
"class_",
"(",
"obj",
")",
":",
"import",
"inspect",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")",
":",
"# obj is already a class !",
"return",
"obj",
"else",
":",
"return",
"obj",
".",
"__class__"
] | [
369,
0
] | [
380,
28
] | python | en | ['en', 'lb', 'en'] | True |
range | (imageOrFilter) | Return the range of values in a image of in the output image of a filter
The minimum and maximum values are returned in a tuple: (min, max)
range() take care of updating the pipeline
| Return the range of values in a image of in the output image of a filter | def range(imageOrFilter):
"""Return the range of values in a image of in the output image of a filter
The minimum and maximum values are returned in a tuple: (min, max)
range() take care of updating the pipeline
"""
import itk
img = output(imageOrFilter)
img.UpdateOutputInformation()
im... | [
"def",
"range",
"(",
"imageOrFilter",
")",
":",
"import",
"itk",
"img",
"=",
"output",
"(",
"imageOrFilter",
")",
"img",
".",
"UpdateOutputInformation",
"(",
")",
"img",
".",
"Update",
"(",
")",
"# don't put that calculator in the automatic pipeline",
"tmp_auto_pipe... | [
383,
0
] | [
399,
49
] | python | en | ['en', 'en', 'en'] | True |
imwrite | (imageOrFilter, fileName, compression=False) | Write a image or the output image of a filter to a file.
The writer is instantiated with the image type of the image in
parameter (or, again, with the output image of the filter in parameter).
| Write a image or the output image of a filter to a file. | def imwrite(imageOrFilter, fileName, compression=False):
"""Write a image or the output image of a filter to a file.
The writer is instantiated with the image type of the image in
parameter (or, again, with the output image of the filter in parameter).
"""
import itk
img = output(imageOrFilter)... | [
"def",
"imwrite",
"(",
"imageOrFilter",
",",
"fileName",
",",
"compression",
"=",
"False",
")",
":",
"import",
"itk",
"img",
"=",
"output",
"(",
"imageOrFilter",
")",
"img",
".",
"UpdateOutputInformation",
"(",
")",
"# don't put that writer in the automatic pipeline... | [
402,
0
] | [
419,
19
] | python | en | ['en', 'en', 'en'] | True |
imread | (fileName, pixelType=None) | Read an image from a file and return an itk.Image.
The reader is instantiated with the image type of the image file.
| Read an image from a file and return an itk.Image. | def imread(fileName, pixelType=None):
"""Read an image from a file and return an itk.Image.
The reader is instantiated with the image type of the image file.
"""
import itk
if pixelType:
imageIO = itk.ImageIOFactory.CreateImageIO( fileName, itk.ImageIOFactory.ReadMode )
if not image... | [
"def",
"imread",
"(",
"fileName",
",",
"pixelType",
"=",
"None",
")",
":",
"import",
"itk",
"if",
"pixelType",
":",
"imageIO",
"=",
"itk",
".",
"ImageIOFactory",
".",
"CreateImageIO",
"(",
"fileName",
",",
"itk",
".",
"ImageIOFactory",
".",
"ReadMode",
")"... | [
428,
0
] | [
446,
29
] | python | en | ['en', 'en', 'en'] | True |
search | (s, case_sensitive=False) | Search for a class name in the itk module.
| Search for a class name in the itk module.
| def search(s, case_sensitive=False): # , fuzzy=True):
"""Search for a class name in the itk module.
"""
s = s.replace(" ", "")
if not case_sensitive:
s = s.lower()
import itk
names = sorted(dir(itk))
# exact match first
if case_sensitive:
res = [n for n in names if s == ... | [
"def",
"search",
"(",
"s",
",",
"case_sensitive",
"=",
"False",
")",
":",
"# , fuzzy=True):",
"s",
"=",
"s",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
"if",
"not",
"case_sensitive",
":",
"s",
"=",
"s",
".",
"lower",
"(",
")",
"import",
"itk",
... | [
448,
0
] | [
476,
14
] | python | en | ['en', 'en', 'en'] | True |
set_inputs | (newItkObject, args=[], kargs={}) | Set the inputs of the given objects, according to the non named or the
named parameters in args and kargs
This function tries to assign all the non named parameters in the input of
the newItkObject
- the first non named parameter in the first input, etc.
The named parameters are used by calling th... | Set the inputs of the given objects, according to the non named or the
named parameters in args and kargs | def set_inputs(newItkObject, args=[], kargs={}):
"""Set the inputs of the given objects, according to the non named or the
named parameters in args and kargs
This function tries to assign all the non named parameters in the input of
the newItkObject
- the first non named parameter in the first inpu... | [
"def",
"set_inputs",
"(",
"newItkObject",
",",
"args",
"=",
"[",
"]",
",",
"kargs",
"=",
"{",
"}",
")",
":",
"# try to get the images from the filters in args",
"args",
"=",
"[",
"output",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
"]",
"# args without nam... | [
479,
0
] | [
559,
33
] | python | en | ['en', 'en', 'en'] | True |
show | (input, **kargs) | display an image
| display an image
| def show(input, **kargs):
"""display an image
"""
import itk
img = output(input)
if img.GetImageDimension() == 3 and "show3D" in dir(itk):
return itk.show3D(input, **kargs)
else:
# print("2D not supported yet, use the 3D viewer.")
return show2D(input, **kargs) | [
"def",
"show",
"(",
"input",
",",
"*",
"*",
"kargs",
")",
":",
"import",
"itk",
"img",
"=",
"output",
"(",
"input",
")",
"if",
"img",
".",
"GetImageDimension",
"(",
")",
"==",
"3",
"and",
"\"show3D\"",
"in",
"dir",
"(",
"itk",
")",
":",
"return",
... | [
562,
0
] | [
571,
37
] | python | en | ['en', 'ceb', 'en'] | True |
down_cast | (obj) | Down cast an itkLightObject (or a object of a subclass) to its most
specialized type.
| Down cast an itkLightObject (or a object of a subclass) to its most
specialized type.
| def down_cast(obj):
"""Down cast an itkLightObject (or a object of a subclass) to its most
specialized type.
"""
import itk
import itkTemplate
className = obj.GetNameOfClass()
t = getattr(itk, className)
if isinstance(t, itkTemplate.itkTemplate):
for c in t.values():
... | [
"def",
"down_cast",
"(",
"obj",
")",
":",
"import",
"itk",
"import",
"itkTemplate",
"className",
"=",
"obj",
".",
"GetNameOfClass",
"(",
")",
"t",
"=",
"getattr",
"(",
"itk",
",",
"className",
")",
"if",
"isinstance",
"(",
"t",
",",
"itkTemplate",
".",
... | [
1008,
0
] | [
1027,
26
] | python | en | ['en', 'en', 'en'] | True |
attribute_list | (i, name) | Returns a list of the specified attributes for the objects in the image.
i: the input LabelImage
name: the attribute name
| Returns a list of the specified attributes for the objects in the image. | def attribute_list(i, name):
"""Returns a list of the specified attributes for the objects in the image.
i: the input LabelImage
name: the attribute name
"""
import itk
i = itk.output(i)
relabel = itk.StatisticsRelabelLabelMapFilter[i].New(
i,
Attribute=name,
Reverse... | [
"def",
"attribute_list",
"(",
"i",
",",
"name",
")",
":",
"import",
"itk",
"i",
"=",
"itk",
".",
"output",
"(",
"i",
")",
"relabel",
"=",
"itk",
".",
"StatisticsRelabelLabelMapFilter",
"[",
"i",
"]",
".",
"New",
"(",
"i",
",",
"Attribute",
"=",
"name... | [
1030,
0
] | [
1048,
12
] | python | en | ['en', 'en', 'en'] | True |
attributes_list | (i, names) | Returns a list of the specified attributes for the objects in the image.
i: the input LabelImage
name: the attribute name
| Returns a list of the specified attributes for the objects in the image. | def attributes_list(i, names):
"""Returns a list of the specified attributes for the objects in the image.
i: the input LabelImage
name: the attribute name
"""
import itk
i = itk.output(i)
relabel = itk.StatisticsRelabelLabelMapFilter[i].New(
i,
Attribute=names[0],
R... | [
"def",
"attributes_list",
"(",
"i",
",",
"names",
")",
":",
"import",
"itk",
"i",
"=",
"itk",
".",
"output",
"(",
"i",
")",
"relabel",
"=",
"itk",
".",
"StatisticsRelabelLabelMapFilter",
"[",
"i",
"]",
".",
"New",
"(",
"i",
",",
"Attribute",
"=",
"na... | [
1051,
0
] | [
1072,
12
] | python | en | ['en', 'en', 'en'] | True |
attribute_dict | (i, name) | Returns a dict with the attribute values in keys and a list of the
corresponding objects in value
i: the input LabelImage
name: the name of the attribute
| Returns a dict with the attribute values in keys and a list of the
corresponding objects in value | def attribute_dict(i, name):
"""Returns a dict with the attribute values in keys and a list of the
corresponding objects in value
i: the input LabelImage
name: the name of the attribute
"""
import itk
i = itk.output(i)
relabel = itk.StatisticsRelabelLabelMapFilter[i].New(
i,
... | [
"def",
"attribute_dict",
"(",
"i",
",",
"name",
")",
":",
"import",
"itk",
"i",
"=",
"itk",
".",
"output",
"(",
"i",
")",
"relabel",
"=",
"itk",
".",
"StatisticsRelabelLabelMapFilter",
"[",
"i",
"]",
".",
"New",
"(",
"i",
",",
"Attribute",
"=",
"name... | [
1075,
0
] | [
1098,
12
] | python | en | ['en', 'en', 'en'] | True |
number_of_objects | (i) | Returns the number of objets in the image.
i: the input LabelImage
| Returns the number of objets in the image. | def number_of_objects(i):
"""Returns the number of objets in the image.
i: the input LabelImage
"""
import itk
i.UpdateLargestPossibleRegion()
i = itk.output(i)
return i.GetNumberOfLabelObjects() | [
"def",
"number_of_objects",
"(",
"i",
")",
":",
"import",
"itk",
"i",
".",
"UpdateLargestPossibleRegion",
"(",
")",
"i",
"=",
"itk",
".",
"output",
"(",
"i",
")",
"return",
"i",
".",
"GetNumberOfLabelObjects",
"(",
")"
] | [
1101,
0
] | [
1109,
38
] | python | en | ['en', 'en', 'en'] | True |
ipython_kw_matches | (text) | Match named ITK object's named parameters | Match named ITK object's named parameters | def ipython_kw_matches(text):
"""Match named ITK object's named parameters"""
import IPython
import itk
import re
import inspect
import itkTemplate
regexp = re.compile(r'''
'.*?' | # single quoted strings or
".*?" | # double quoted strings or
... | [
"def",
"ipython_kw_matches",
"(",
"text",
")",
":",
"import",
"IPython",
"import",
"itk",
"import",
"re",
"import",
"inspect",
"import",
"itkTemplate",
"regexp",
"=",
"re",
".",
"compile",
"(",
"r'''\n '.*?' | # single quoted strings or\n ... | [
1112,
0
] | [
1192,
21
] | python | en | ['en', 'en', 'en'] | True |
templated_class.__init__ | (self, cls) | cls is the custom class
| cls is the custom class
| def __init__(self, cls):
"""cls is the custom class
"""
self.__cls__ = cls
self.__templates__ = {} | [
"def",
"__init__",
"(",
"self",
",",
"cls",
")",
":",
"self",
".",
"__cls__",
"=",
"cls",
"self",
".",
"__templates__",
"=",
"{",
"}"
] | [
700,
4
] | [
704,
31
] | python | en | ['en', 'en', 'en'] | True |
templated_class.New | (self, *args, **kargs) | Use the parameters to infer the types of the template parameters.
| Use the parameters to infer the types of the template parameters.
| def New(self, *args, **kargs):
"""Use the parameters to infer the types of the template parameters.
"""
# extract the types from the arguments to instantiate the class
import itk
types = tuple(itk.class_(o) for o in args)
return self[types].New(*args, **kargs) | [
"def",
"New",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"# extract the types from the arguments to instantiate the class",
"import",
"itk",
"types",
"=",
"tuple",
"(",
"itk",
".",
"class_",
"(",
"o",
")",
"for",
"o",
"in",
"args",
")... | [
706,
4
] | [
712,
46
] | python | en | ['en', 'en', 'en'] | True |
templated_class.__getitem__ | (self, template_parameters) | Return a pair class-template parameters ready to be instantiated.
The template parameters may be validated if the custom class provide
the static method check_template_parameters(parameters).
| Return a pair class-template parameters ready to be instantiated. | def __getitem__(self, template_parameters):
"""Return a pair class-template parameters ready to be instantiated.
The template parameters may be validated if the custom class provide
the static method check_template_parameters(parameters).
"""
if not isinstance(template_parameter... | [
"def",
"__getitem__",
"(",
"self",
",",
"template_parameters",
")",
":",
"if",
"not",
"isinstance",
"(",
"template_parameters",
",",
"tuple",
")",
":",
"template_parameters",
"=",
"(",
"template_parameters",
",",
")",
"return",
"(",
"templated_class",
".",
"__te... | [
714,
4
] | [
726,
9
] | python | en | ['en', 'en', 'en'] | True |
templated_class.check_template_parameters | (self, template_parameters) | Check the template parameters passed in parameter.
| Check the template parameters passed in parameter.
| def check_template_parameters(self, template_parameters):
"""Check the template parameters passed in parameter.
"""
# this method is there mainly to make possible to reuse it in the
# custom class constructor after having used templated_class().
# Without that, the following exam... | [
"def",
"check_template_parameters",
"(",
"self",
",",
"template_parameters",
")",
":",
"# this method is there mainly to make possible to reuse it in the",
"# custom class constructor after having used templated_class().",
"# Without that, the following example doesn't work:",
"#",
"# class ... | [
728,
4
] | [
745,
67
] | python | en | ['en', 'en', 'en'] | True |
pipeline.connect | (self, filter) | Connect a new filter to the pipeline
The output of the first filter will be used as the input of this
one and the filter passed as parameter will be added to the list
| Connect a new filter to the pipeline | def connect(self, filter):
"""Connect a new filter to the pipeline
The output of the first filter will be used as the input of this
one and the filter passed as parameter will be added to the list
"""
if self.GetOutput() is not None:
set_inputs(filter, [self.GetOutpu... | [
"def",
"connect",
"(",
"self",
",",
"filter",
")",
":",
"if",
"self",
".",
"GetOutput",
"(",
")",
"is",
"not",
"None",
":",
"set_inputs",
"(",
"filter",
",",
"[",
"self",
".",
"GetOutput",
"(",
")",
"]",
")",
"self",
".",
"append",
"(",
"filter",
... | [
871,
4
] | [
879,
27
] | python | en | ['en', 'en', 'en'] | True |
pipeline.append | (self, filter) | Add a new filter to the pipeline
The new filter will not be connected. The user must connect it.
| Add a new filter to the pipeline | def append(self, filter):
"""Add a new filter to the pipeline
The new filter will not be connected. The user must connect it.
"""
self.filters.append(filter) | [
"def",
"append",
"(",
"self",
",",
"filter",
")",
":",
"self",
".",
"filters",
".",
"append",
"(",
"filter",
")"
] | [
881,
4
] | [
886,
35
] | python | en | ['en', 'en', 'en'] | True |
pipeline.clear | (self) | Clear the filter list
| Clear the filter list
| def clear(self):
"""Clear the filter list
"""
self.filters = [] | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"filters",
"=",
"[",
"]"
] | [
888,
4
] | [
891,
25
] | python | en | ['en', 'en', 'en'] | True |
pipeline.GetOutput | (self, index=0) | Return the output of the pipeline
If another output is needed, use
pipeline.filters[-1].GetAnotherOutput() instead of this method,
subclass pipeline to implement another GetOutput() method, or use
expose()
| Return the output of the pipeline | def GetOutput(self, index=0):
"""Return the output of the pipeline
If another output is needed, use
pipeline.filters[-1].GetAnotherOutput() instead of this method,
subclass pipeline to implement another GetOutput() method, or use
expose()
"""
if len(self.filters)... | [
"def",
"GetOutput",
"(",
"self",
",",
"index",
"=",
"0",
")",
":",
"if",
"len",
"(",
"self",
".",
"filters",
")",
"==",
"0",
":",
"return",
"self",
".",
"GetInput",
"(",
")",
"else",
":",
"filter",
"=",
"self",
".",
"filters",
"[",
"-",
"1",
"]... | [
893,
4
] | [
913,
74
] | python | en | ['en', 'en', 'en'] | True |
pipeline.SetInput | (self, input) | Set the input of the pipeline
| Set the input of the pipeline
| def SetInput(self, input):
"""Set the input of the pipeline
"""
if len(self.filters) != 0:
set_inputs(self.filters[0], [input])
self.input = input | [
"def",
"SetInput",
"(",
"self",
",",
"input",
")",
":",
"if",
"len",
"(",
"self",
".",
"filters",
")",
"!=",
"0",
":",
"set_inputs",
"(",
"self",
".",
"filters",
"[",
"0",
"]",
",",
"[",
"input",
"]",
")",
"self",
".",
"input",
"=",
"input"
] | [
915,
4
] | [
920,
26
] | python | en | ['en', 'en', 'en'] | True |
pipeline.GetInput | (self) | Get the input of the pipeline
| Get the input of the pipeline
| def GetInput(self):
"""Get the input of the pipeline
"""
return self.input | [
"def",
"GetInput",
"(",
"self",
")",
":",
"return",
"self",
".",
"input"
] | [
922,
4
] | [
925,
25
] | python | en | ['en', 'en', 'en'] | True |
pipeline.Update | (self) | Update the pipeline
| Update the pipeline
| def Update(self):
"""Update the pipeline
"""
if len(self.filters) > 0:
return self.filters[-1].Update() | [
"def",
"Update",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"filters",
")",
">",
"0",
":",
"return",
"self",
".",
"filters",
"[",
"-",
"1",
"]",
".",
"Update",
"(",
")"
] | [
927,
4
] | [
931,
44
] | python | en | ['en', 'en', 'en'] | True |
pipeline.UpdateLargestPossibleRegion | (self) | Update the pipeline
| Update the pipeline
| def UpdateLargestPossibleRegion(self):
"""Update the pipeline
"""
if len(self.filters) > 0:
return self.filters[-1].UpdateLargestPossibleRegion() | [
"def",
"UpdateLargestPossibleRegion",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"filters",
")",
">",
"0",
":",
"return",
"self",
".",
"filters",
"[",
"-",
"1",
"]",
".",
"UpdateLargestPossibleRegion",
"(",
")"
] | [
933,
4
] | [
937,
65
] | python | en | ['en', 'en', 'en'] | True |
pipeline.expose | (self, name, new_name=None, position=-1) | Expose an attribute from a filter of the minipeline.
Once called, the pipeline instance has a new Set/Get set of methods to
access directly the corresponding method of one of the filter of the
pipeline.
Ex: p.expose( "Radius" )
p.SetRadius( 5 )
p.GetRadiu... | Expose an attribute from a filter of the minipeline. | def expose(self, name, new_name=None, position=-1):
"""Expose an attribute from a filter of the minipeline.
Once called, the pipeline instance has a new Set/Get set of methods to
access directly the corresponding method of one of the filter of the
pipeline.
Ex: p.expose( "Radius... | [
"def",
"expose",
"(",
"self",
",",
"name",
",",
"new_name",
"=",
"None",
",",
"position",
"=",
"-",
"1",
")",
":",
"if",
"new_name",
"is",
"None",
":",
"new_name",
"=",
"name",
"src",
"=",
"self",
".",
"filters",
"[",
"position",
"]",
"ok",
"=",
... | [
959,
4
] | [
991,
33
] | python | en | ['en', 'en', 'en'] | True |
display_map | (latitude = None, longitude = None, resolution = None) | Generates a folium map with a lat-lon bounded rectangle drawn on it. Folium maps can be
Args:
latitude (float,float): a tuple of latitude bounds in (min,max) format
longitude ((float, float)): a tuple of longitude bounds in (min,max) format
resolution ((float, float)): tuple in (la... | Generates a folium map with a lat-lon bounded rectangle drawn on it. Folium maps can be
Args:
latitude (float,float): a tuple of latitude bounds in (min,max) format
longitude ((float, float)): a tuple of longitude bounds in (min,max) format
resolution ((float, float)): tuple in (la... | def display_map(latitude = None, longitude = None, resolution = None):
""" Generates a folium map with a lat-lon bounded rectangle drawn on it. Folium maps can be
Args:
latitude (float,float): a tuple of latitude bounds in (min,max) format
longitude ((float, float)): a tuple of longitud... | [
"def",
"display_map",
"(",
"latitude",
"=",
"None",
",",
"longitude",
"=",
"None",
",",
"resolution",
"=",
"None",
")",
":",
"assert",
"latitude",
"is",
"not",
"None",
"assert",
"longitude",
"is",
"not",
"None",
"###### ###### ###### CALC ZOOM LEVEL ###### #... | [
16,
0
] | [
99,
21
] | python | en | ['en', 'en', 'en'] | True |
SuiteProfileNotebookRenderer.render_to_disk | (self, notebook_file_path: str) |
Render a notebook to disk from an expectation suite.
|
Render a notebook to disk from an expectation suite.
| def render_to_disk(self, notebook_file_path: str):
"""
Render a notebook to disk from an expectation suite.
"""
self.render()
self.write_notebook_to_disk(
notebook=self._notebook, notebook_file_path=notebook_file_path
) | [
"def",
"render_to_disk",
"(",
"self",
",",
"notebook_file_path",
":",
"str",
")",
":",
"self",
".",
"render",
"(",
")",
"self",
".",
"write_notebook_to_disk",
"(",
"notebook",
"=",
"self",
".",
"_notebook",
",",
"notebook_file_path",
"=",
"notebook_file_path",
... | [
156,
4
] | [
163,
9
] | python | en | ['en', 'error', 'th'] | False |
merge_errors | (errors1, errors2) | Deeply merge two error messages.
The format of ``errors1`` and ``errors2`` matches the ``message``
parameter of :exc:`marshmallow.exceptions.ValidationError`.
| Deeply merge two error messages. | def merge_errors(errors1, errors2):
"""Deeply merge two error messages.
The format of ``errors1`` and ``errors2`` matches the ``message``
parameter of :exc:`marshmallow.exceptions.ValidationError`.
"""
if not errors1:
return errors2
if not errors2:
return errors1
if isinstan... | [
"def",
"merge_errors",
"(",
"errors1",
",",
"errors2",
")",
":",
"if",
"not",
"errors1",
":",
"return",
"errors2",
"if",
"not",
"errors2",
":",
"return",
"errors1",
"if",
"isinstance",
"(",
"errors1",
",",
"list",
")",
":",
"if",
"isinstance",
"(",
"erro... | [
27,
0
] | [
59,
29
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.__init__ | (self, src) | Initialize the instance given a source object (file or
filename).
| Initialize the instance given a source object (file or
filename). | def __init__(self, src):
"""Initialize the instance given a source object (file or
filename).
"""
f = my_open_read(src)
self.my_dir = os.path.dirname(f.name)
self.xmldoc = minidom.parse(f).documentElement
f.close()
self.pieces = []
self.pieces.ap... | [
"def",
"__init__",
"(",
"self",
",",
"src",
")",
":",
"f",
"=",
"my_open_read",
"(",
"src",
")",
"self",
".",
"my_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"f",
".",
"name",
")",
"self",
".",
"xmldoc",
"=",
"minidom",
".",
"parse",
"(",
... | [
54,
4
] | [
77,
42
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.generate | (self) | Parses the file set in the initialization. The resulting
data is stored in `self.pieces`.
| Parses the file set in the initialization. The resulting
data is stored in `self.pieces`. | def generate(self):
"""Parses the file set in the initialization. The resulting
data is stored in `self.pieces`.
"""
self.parse(self.xmldoc) | [
"def",
"generate",
"(",
"self",
")",
":",
"self",
".",
"parse",
"(",
"self",
".",
"xmldoc",
")"
] | [
80,
4
] | [
85,
31
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.parse | (self, node) | Parse a given node. This function in turn calls the
`parse_<nodeType>` functions which handle the respective
nodes.
| Parse a given node. This function in turn calls the
`parse_<nodeType>` functions which handle the respective
nodes. | def parse(self, node):
"""Parse a given node. This function in turn calls the
`parse_<nodeType>` functions which handle the respective
nodes.
"""
pm = getattr(self, "parse_%s"%node.__class__.__name__)
pm(node) | [
"def",
"parse",
"(",
"self",
",",
"node",
")",
":",
"pm",
"=",
"getattr",
"(",
"self",
",",
"\"parse_%s\"",
"%",
"node",
".",
"__class__",
".",
"__name__",
")",
"pm",
"(",
"node",
")"
] | [
87,
4
] | [
94,
16
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.parse_Element | (self, node) | Parse an `ELEMENT_NODE`. This calls specific
`do_<tagName>` handers for different elements. If no handler
is available the `generic_parse` method is called. All
tagNames specified in `self.ignores` are simply ignored.
| Parse an `ELEMENT_NODE`. This calls specific
`do_<tagName>` handers for different elements. If no handler
is available the `generic_parse` method is called. All
tagNames specified in `self.ignores` are simply ignored. | def parse_Element(self, node):
"""Parse an `ELEMENT_NODE`. This calls specific
`do_<tagName>` handers for different elements. If no handler
is available the `generic_parse` method is called. All
tagNames specified in `self.ignores` are simply ignored.
"""
name = node.... | [
"def",
"parse_Element",
"(",
"self",
",",
"node",
")",
":",
"name",
"=",
"node",
".",
"tagName",
"ignores",
"=",
"self",
".",
"ignores",
"if",
"name",
"in",
"ignores",
":",
"return",
"attr",
"=",
"\"do_%s\"",
"%",
"name",
"if",
"hasattr",
"(",
"self",
... | [
110,
4
] | [
126,
36
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.add_text | (self, value) | Adds text corresponding to `value` into `self.pieces`. | Adds text corresponding to `value` into `self.pieces`. | def add_text(self, value):
"""Adds text corresponding to `value` into `self.pieces`."""
if sys.version_info >= (3,0):
listTypes = (list, tuple)
else:
listTypes = (types.ListType, types.TupleType)
if type(value) in listTypes:
self.pieces.extend(value)
... | [
"def",
"add_text",
"(",
"self",
",",
"value",
")",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"0",
")",
":",
"listTypes",
"=",
"(",
"list",
",",
"tuple",
")",
"else",
":",
"listTypes",
"=",
"(",
"types",
".",
"ListType",
",",
"ty... | [
129,
4
] | [
138,
37
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.get_specific_nodes | (self, node, names) | Given a node and a sequence of strings in `names`, return a
dictionary containing the names as keys and child
`ELEMENT_NODEs`, that have a `tagName` equal to the name.
| Given a node and a sequence of strings in `names`, return a
dictionary containing the names as keys and child
`ELEMENT_NODEs`, that have a `tagName` equal to the name. | def get_specific_nodes(self, node, names):
"""Given a node and a sequence of strings in `names`, return a
dictionary containing the names as keys and child
`ELEMENT_NODEs`, that have a `tagName` equal to the name.
"""
nodes = [(x.tagName, x) for x in node.childNodes \
... | [
"def",
"get_specific_nodes",
"(",
"self",
",",
"node",
",",
"names",
")",
":",
"nodes",
"=",
"[",
"(",
"x",
".",
"tagName",
",",
"x",
")",
"for",
"x",
"in",
"node",
".",
"childNodes",
"if",
"x",
".",
"nodeType",
"==",
"x",
".",
"ELEMENT_NODE",
"and... | [
140,
4
] | [
149,
26
] | python | en | ['en', 'en', 'en'] | True |
Doxy2SWIG.generic_parse | (self, node, pad=0) | A Generic parser for arbitrary tags in a node.
Parameters:
- node: A node in the DOM.
- pad: `int` (default: 0)
If 0 the node data is not padded with newlines. If 1 it
appends a newline after parsing the childNodes. If 2 it
pads before and after the nodes... | A Generic parser for arbitrary tags in a node. | def generic_parse(self, node, pad=0):
"""A Generic parser for arbitrary tags in a node.
Parameters:
- node: A node in the DOM.
- pad: `int` (default: 0)
If 0 the node data is not padded with newlines. If 1 it
appends a newline after parsing the childNodes. I... | [
"def",
"generic_parse",
"(",
"self",
",",
"node",
",",
"pad",
"=",
"0",
")",
":",
"npiece",
"=",
"0",
"if",
"pad",
":",
"npiece",
"=",
"len",
"(",
"self",
".",
"pieces",
")",
"if",
"pad",
"==",
"2",
":",
"self",
".",
"add_text",
"(",
"'\\n'",
"... | [
151,
4
] | [
174,
35
] | python | en | ['en', 'en', 'it'] | True |
Doxy2SWIG.clean_pieces | (self, pieces) | Cleans the list of strings given as `pieces`. It replaces
multiple newlines by a maximum of 2 and returns a new list.
It also wraps the paragraphs nicely.
| Cleans the list of strings given as `pieces`. It replaces
multiple newlines by a maximum of 2 and returns a new list.
It also wraps the paragraphs nicely. | def clean_pieces(self, pieces):
"""Cleans the list of strings given as `pieces`. It replaces
multiple newlines by a maximum of 2 and returns a new list.
It also wraps the paragraphs nicely.
"""
ret = []
count = 0
for i in pieces:
if i == '\n':
... | [
"def",
"clean_pieces",
"(",
"self",
",",
"pieces",
")",
":",
"ret",
"=",
"[",
"]",
"count",
"=",
"0",
"for",
"i",
"in",
"pieces",
":",
"if",
"i",
"==",
"'\\n'",
":",
"count",
"=",
"count",
"+",
"1",
"else",
":",
"if",
"i",
"==",
"'\";'",
":",
... | [
329,
4
] | [
362,
18
] | python | en | ['en', 'en', 'en'] | True |
shapefile_mask | (dataset: xr.Dataset, shapefile) | Extracts a mask from a shapefile using dataset latitude and longitude extents.
Args:
dataset (xarray.Dataset): The dataset with the latitude and longitude extents.
shapefile (string): The shapefile to be used for extraction.
Returns:
A boolean mask array.
| Extracts a mask from a shapefile using dataset latitude and longitude extents. | def shapefile_mask(dataset: xr.Dataset, shapefile) -> np.array:
"""Extracts a mask from a shapefile using dataset latitude and longitude extents.
Args:
dataset (xarray.Dataset): The dataset with the latitude and longitude extents.
shapefile (string): The shapefile to be used for extraction.
... | [
"def",
"shapefile_mask",
"(",
"dataset",
":",
"xr",
".",
"Dataset",
",",
"shapefile",
")",
"->",
"np",
".",
"array",
":",
"with",
"fiona",
".",
"open",
"(",
"shapefile",
",",
"'r'",
")",
"as",
"source",
":",
"collection",
"=",
"list",
"(",
"source",
... | [
27,
0
] | [
55,
15
] | python | en | ['en', 'en', 'en'] | True |
step_impl | (context) |
:type context: behave.runner.Context
|
:type context: behave.runner.Context
| def step_impl(context):
"""
:type context: behave.runner.Context
"""
print("Hello") | [
"def",
"step_impl",
"(",
"context",
")",
":",
"print",
"(",
"\"Hello\"",
")"
] | [
7,
0
] | [
11,
18
] | python | en | ['en', 'error', 'th'] | False |
apply_visitor | (visitor, decl_inst) |
Applies a visitor on declaration instance.
:param visitor: instance
:type visitor: :class:`type_visitor_t` or :class:`decl_visitor_t`
|
Applies a visitor on declaration instance. | def apply_visitor(visitor, decl_inst):
"""
Applies a visitor on declaration instance.
:param visitor: instance
:type visitor: :class:`type_visitor_t` or :class:`decl_visitor_t`
"""
fname = 'visit_' + \
decl_inst.__class__.__name__[:-2] # removing '_t' from class name
if not hasat... | [
"def",
"apply_visitor",
"(",
"visitor",
",",
"decl_inst",
")",
":",
"fname",
"=",
"'visit_'",
"+",
"decl_inst",
".",
"__class__",
".",
"__name__",
"[",
":",
"-",
"2",
"]",
"# removing '_t' from class name",
"if",
"not",
"hasattr",
"(",
"visitor",
",",
"fname... | [
72,
0
] | [
86,
36
] | python | en | ['en', 'error', 'th'] | False |
match_declaration_t.does_match_exist | (self, inst) |
Returns True if inst does match one of specified criteria.
:param inst: declaration instance
:type inst: :class:`declaration_t`
:rtype: bool
|
Returns True if inst does match one of specified criteria. | def does_match_exist(self, inst):
"""
Returns True if inst does match one of specified criteria.
:param inst: declaration instance
:type inst: :class:`declaration_t`
:rtype: bool
"""
answer = True
if self._decl_type is not None:
answer &= i... | [
"def",
"does_match_exist",
"(",
"self",
",",
"inst",
")",
":",
"answer",
"=",
"True",
"if",
"self",
".",
"_decl_type",
"is",
"not",
"None",
":",
"answer",
"&=",
"isinstance",
"(",
"inst",
",",
"self",
".",
"_decl_type",
")",
"if",
"self",
".",
"name",
... | [
36,
4
] | [
59,
21
] | python | en | ['en', 'error', 'th'] | False |
match_declaration_t.__call__ | (self, inst) |
.. code-block:: python
return self.does_match_exist(inst)
|
.. code-block:: python | def __call__(self, inst):
"""
.. code-block:: python
return self.does_match_exist(inst)
"""
return self.does_match_exist(inst) | [
"def",
"__call__",
"(",
"self",
",",
"inst",
")",
":",
"return",
"self",
".",
"does_match_exist",
"(",
"inst",
")"
] | [
61,
4
] | [
69,
42
] | python | en | ['en', 'error', 'th'] | False |
point_confusion_matrix | (expected, observed, data=None, start=None, end=None) | Compute the confusion matrix between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: timestamp.
observed (DataFrame or list of timestamps):
... | Compute the confusion matrix between the ground truth and the detected anomalies. | def point_confusion_matrix(expected, observed, data=None, start=None, end=None):
"""Compute the confusion matrix between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
... | [
"def",
"point_confusion_matrix",
"(",
"expected",
",",
"observed",
",",
"data",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"def",
"_ws",
"(",
"x",
",",
"y",
",",
"z",
",",
"w",
")",
":",
"return",
"_weighted_segment",
... | [
29,
0
] | [
64,
46
] | python | en | ['en', 'en', 'en'] | True |
point_accuracy | (expected, observed, data=None, start=None, end=None) | Compute an accuracy score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: timestamp.
observed (DataFrame or list of timestamps):
De... | Compute an accuracy score between the ground truth and the detected anomalies. | def point_accuracy(expected, observed, data=None, start=None, end=None):
"""Compute an accuracy score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one colum... | [
"def",
"point_accuracy",
"(",
"expected",
",",
"observed",
",",
"data",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"return",
"_accuracy",
"(",
"expected",
",",
"observed",
",",
"data",
",",
"start",
",",
"end",
",",
"c... | [
67,
0
] | [
89,
85
] | python | en | ['en', 'en', 'en'] | True |
point_precision | (expected, observed, data=None, start=None, end=None) | Compute an precision score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: timestamp.
observed (DataFrame or list of timestamps):
D... | Compute an precision score between the ground truth and the detected anomalies. | def point_precision(expected, observed, data=None, start=None, end=None):
"""Compute an precision score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one col... | [
"def",
"point_precision",
"(",
"expected",
",",
"observed",
",",
"data",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"return",
"_precision",
"(",
"expected",
",",
"observed",
",",
"data",
",",
"start",
",",
"end",
",",
... | [
92,
0
] | [
114,
86
] | python | en | ['en', 'en', 'en'] | True |
point_recall | (expected, observed, data=None, start=None, end=None) | Compute an recall score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: timestamp.
observed (DataFrame or list of timestamps):
Dete... | Compute an recall score between the ground truth and the detected anomalies. | def point_recall(expected, observed, data=None, start=None, end=None):
"""Compute an recall score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: t... | [
"def",
"point_recall",
"(",
"expected",
",",
"observed",
",",
"data",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"return",
"_recall",
"(",
"expected",
",",
"observed",
",",
"data",
",",
"start",
",",
"end",
",",
"cm",
... | [
117,
0
] | [
139,
83
] | python | en | ['en', 'en', 'en'] | True |
point_f1_score | (expected, observed, data=None, start=None, end=None) | Compute an f1 score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: timestamp.
observed (DataFrame or list of timestamps):
Detected... | Compute an f1 score between the ground truth and the detected anomalies. | def point_f1_score(expected, observed, data=None, start=None, end=None):
"""Compute an f1 score between the ground truth and the detected anomalies.
Args:
expected (DataFrame or list of timestamps):
Ground truth passed as a ``pandas.DataFrame`` or list containing
one column: tim... | [
"def",
"point_f1_score",
"(",
"expected",
",",
"observed",
",",
"data",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"return",
"_f1_score",
"(",
"expected",
",",
"observed",
",",
"data",
",",
"start",
",",
"end",
",",
"c... | [
142,
0
] | [
164,
85
] | python | en | ['en', 'en', 'en'] | True |
ansiformat | (attr, text) |
Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color
|
Format ``text`` with a color and/or some attributes:: | def ansiformat(attr, text):
"""
Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color
"""
result = []
if attr[:1] == attr[-1:] == '+':
result.append(codes[... | [
"def",
"ansiformat",
"(",
"attr",
",",
"text",
")",
":",
"result",
"=",
"[",
"]",
"if",
"attr",
"[",
":",
"1",
"]",
"==",
"attr",
"[",
"-",
"1",
":",
"]",
"==",
"'+'",
":",
"result",
".",
"append",
"(",
"codes",
"[",
"'blink'",
"]",
")",
"att... | [
51,
0
] | [
73,
26
] | python | en | ['en', 'error', 'th'] | False |
swap_bbox_format | (bbox_tuple) | Swap between (row0, col0, row1, col1) and (x0, y0, x1, y1) formats. | Swap between (row0, col0, row1, col1) and (x0, y0, x1, y1) formats. | def swap_bbox_format(bbox_tuple):
"""Swap between (row0, col0, row1, col1) and (x0, y0, x1, y1) formats."""
assert len(bbox_tuple) >= 4
return (bbox_tuple[1], bbox_tuple[0], bbox_tuple[3], bbox_tuple[2]) | [
"def",
"swap_bbox_format",
"(",
"bbox_tuple",
")",
":",
"assert",
"len",
"(",
"bbox_tuple",
")",
">=",
"4",
"return",
"(",
"bbox_tuple",
"[",
"1",
"]",
",",
"bbox_tuple",
"[",
"0",
"]",
",",
"bbox_tuple",
"[",
"3",
"]",
",",
"bbox_tuple",
"[",
"2",
"... | [
12,
0
] | [
15,
71
] | python | en | ['en', 'es', 'en'] | True |
draw_on_file | (file_path : pathlib.Path, bbox_list : List, output_folder : pathlib.Path, save_images : bool = True) |
file_path: pathlib.Path to image file.
bbox_list: list of 4-tuples
output_folder: pathlib.Path to save out drawn-on image
|
file_path: pathlib.Path to image file.
bbox_list: list of 4-tuples
output_folder: pathlib.Path to save out drawn-on image
| def draw_on_file(file_path : pathlib.Path, bbox_list : List, output_folder : pathlib.Path, save_images : bool = True):
"""
file_path: pathlib.Path to image file.
bbox_list: list of 4-tuples
output_folder: pathlib.Path to save out drawn-on image
"""
# read image using PIL:
image = Image.open(... | [
"def",
"draw_on_file",
"(",
"file_path",
":",
"pathlib",
".",
"Path",
",",
"bbox_list",
":",
"List",
",",
"output_folder",
":",
"pathlib",
".",
"Path",
",",
"save_images",
":",
"bool",
"=",
"True",
")",
":",
"# read image using PIL:",
"image",
"=",
"Image",
... | [
45,
0
] | [
64,
31
] | python | en | ['en', 'error', 'th'] | False |
cli_message_list | (string_list, list_intro_string=None) | Simple util function for displaying simple lists in cli | Simple util function for displaying simple lists in cli | def cli_message_list(string_list, list_intro_string=None):
"""Simple util function for displaying simple lists in cli"""
if list_intro_string:
cli_message(list_intro_string)
for string in string_list:
cli_message(string) | [
"def",
"cli_message_list",
"(",
"string_list",
",",
"list_intro_string",
"=",
"None",
")",
":",
"if",
"list_intro_string",
":",
"cli_message",
"(",
"list_intro_string",
")",
"for",
"string",
"in",
"string_list",
":",
"cli_message",
"(",
"string",
")"
] | [
39,
0
] | [
44,
27
] | python | en | ['en', 'en', 'en'] | True |
action_list_to_string | (action_list) | Util function for turning an action list into pretty string | Util function for turning an action list into pretty string | def action_list_to_string(action_list):
"""Util function for turning an action list into pretty string"""
action_list_string = ""
for idx, action in enumerate(action_list):
action_list_string += "{} ({})".format(
action["name"], action["action"]["class_name"]
)
if idx == ... | [
"def",
"action_list_to_string",
"(",
"action_list",
")",
":",
"action_list_string",
"=",
"\"\"",
"for",
"idx",
",",
"action",
"in",
"enumerate",
"(",
"action_list",
")",
":",
"action_list_string",
"+=",
"\"{} ({})\"",
".",
"format",
"(",
"action",
"[",
"\"name\"... | [
47,
0
] | [
57,
29
] | python | en | ['en', 'en', 'en'] | True |
cli_message_dict | (
dict_, indent=3, bullet_char="-", message_list=None, recursion_flag=False
) | Util function for displaying nested dicts representing ge objects in cli | Util function for displaying nested dicts representing ge objects in cli | def cli_message_dict(
dict_, indent=3, bullet_char="-", message_list=None, recursion_flag=False
):
"""Util function for displaying nested dicts representing ge objects in cli"""
if message_list is None:
message_list = []
if dict_.get("name"):
name = dict_.pop("name")
message = "{... | [
"def",
"cli_message_dict",
"(",
"dict_",
",",
"indent",
"=",
"3",
",",
"bullet_char",
"=",
"\"-\"",
",",
"message_list",
"=",
"None",
",",
"recursion_flag",
"=",
"False",
")",
":",
"if",
"message_list",
"is",
"None",
":",
"message_list",
"=",
"[",
"]",
"... | [
60,
0
] | [
108,
38
] | python | en | ['en', 'en', 'en'] | True |
multiply | (a, b) |
'multiply' multiplies two numbers and returns the result.
>>> multiply(5, 10)
50
>>> multiply(-1, 1)
-1
>>> multiply(0.5, 1.5)
0.75
|
'multiply' multiplies two numbers and returns the result. | def multiply(a, b):
"""
'multiply' multiplies two numbers and returns the result.
>>> multiply(5, 10)
50
>>> multiply(-1, 1)
-1
>>> multiply(0.5, 1.5)
0.75
"""
return a*b | [
"def",
"multiply",
"(",
"a",
",",
"b",
")",
":",
"return",
"a",
"*",
"b"
] | [
0,
0
] | [
11,
12
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.__init__ | (self,
document_store: BaseDocumentStore,
query_embedding_model: Union[Path, str] = "facebook/dpr-question_encoder-single-nq-base",
passage_embedding_model: Union[Path, str] = "facebook/dpr-ctx_encoder-single-nq-base",
model_version: Optional[str] = No... |
Init the Retriever incl. the two encoder models from a local or remote model checkpoint.
The checkpoint format matches huggingface transformers' model format
**Example:**
```python
| # remote model from FAIR
| DensePassageRetriever(documen... |
Init the Retriever incl. the two encoder models from a local or remote model checkpoint.
The checkpoint format matches huggingface transformers' model format | def __init__(self,
document_store: BaseDocumentStore,
query_embedding_model: Union[Path, str] = "facebook/dpr-question_encoder-single-nq-base",
passage_embedding_model: Union[Path, str] = "facebook/dpr-ctx_encoder-single-nq-base",
model_version: Option... | [
"def",
"__init__",
"(",
"self",
",",
"document_store",
":",
"BaseDocumentStore",
",",
"query_embedding_model",
":",
"Union",
"[",
"Path",
",",
"str",
"]",
"=",
"\"facebook/dpr-question_encoder-single-nq-base\"",
",",
"passage_embedding_model",
":",
"Union",
"[",
"Path... | [
35,
4
] | [
162,
91
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.retrieve | (self, query: str, filters: dict = None, top_k: int = 10, index: str = None) |
Scan through documents in DocumentStore and return a small number documents
that are most relevant to the query.
:param query: The query
:param filters: A dictionary where the keys specify a metadata field and the value is a list of accepted values for that field
:param top_k: ... |
Scan through documents in DocumentStore and return a small number documents
that are most relevant to the query. | def retrieve(self, query: str, filters: dict = None, top_k: int = 10, index: str = None) -> List[Document]:
"""
Scan through documents in DocumentStore and return a small number documents
that are most relevant to the query.
:param query: The query
:param filters: A dictionary w... | [
"def",
"retrieve",
"(",
"self",
",",
"query",
":",
"str",
",",
"filters",
":",
"dict",
"=",
"None",
",",
"top_k",
":",
"int",
"=",
"10",
",",
"index",
":",
"str",
"=",
"None",
")",
"->",
"List",
"[",
"Document",
"]",
":",
"if",
"not",
"self",
"... | [
164,
4
] | [
181,
24
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever._get_predictions | (self, dicts) |
Feed a preprocessed dataset to the model and get the actual predictions (forward pass + formatting).
:param dicts: list of dictionaries
examples:[{'query': "where is florida?"}, {'query': "who wrote lord of the rings?"}, ...]
[{'passages': [{
"title": 'Big L... |
Feed a preprocessed dataset to the model and get the actual predictions (forward pass + formatting). | def _get_predictions(self, dicts):
"""
Feed a preprocessed dataset to the model and get the actual predictions (forward pass + formatting).
:param dicts: list of dictionaries
examples:[{'query': "where is florida?"}, {'query': "who wrote lord of the rings?"}, ...]
[{'pas... | [
"def",
"_get_predictions",
"(",
"self",
",",
"dicts",
")",
":",
"dataset",
",",
"tensor_names",
",",
"_",
",",
"baskets",
"=",
"self",
".",
"processor",
".",
"dataset_from_dicts",
"(",
"dicts",
",",
"indices",
"=",
"[",
"i",
"for",
"i",
"in",
"range",
... | [
183,
4
] | [
232,
29
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.embed_queries | (self, texts: List[str]) |
Create embeddings for a list of queries using the query encoder
:param texts: Queries to embed
:return: Embeddings, one per input queries
|
Create embeddings for a list of queries using the query encoder | def embed_queries(self, texts: List[str]) -> List[np.ndarray]:
"""
Create embeddings for a list of queries using the query encoder
:param texts: Queries to embed
:return: Embeddings, one per input queries
"""
queries = [{'query': q} for q in texts]
result = self.... | [
"def",
"embed_queries",
"(",
"self",
",",
"texts",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"queries",
"=",
"[",
"{",
"'query'",
":",
"q",
"}",
"for",
"q",
"in",
"texts",
"]",
"result",
"=",
"self",
... | [
234,
4
] | [
243,
21
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.embed_passages | (self, docs: List[Document]) |
Create embeddings for a list of passages using the passage encoder
:param docs: List of Document objects used to represent documents / passages in a standardized way within Haystack.
:return: Embeddings of documents / passages shape (batch_size, embedding_dim)
|
Create embeddings for a list of passages using the passage encoder | def embed_passages(self, docs: List[Document]) -> List[np.ndarray]:
"""
Create embeddings for a list of passages using the passage encoder
:param docs: List of Document objects used to represent documents / passages in a standardized way within Haystack.
:return: Embeddings of documents... | [
"def",
"embed_passages",
"(",
"self",
",",
"docs",
":",
"List",
"[",
"Document",
"]",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"passages",
"=",
"[",
"{",
"'passages'",
":",
"[",
"{",
"\"title\"",
":",
"d",
".",
"meta",
"[",
"\"name\"... | [
245,
4
] | [
260,
25
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.train | (self,
data_dir: str,
train_filename: str,
dev_filename: str = None,
test_filename: str = None,
batch_size: int = 2,
embed_title: bool = True,
num_hard_negatives: int = 1,
num_positives: int = 1,
... |
train a DensePassageRetrieval model
:param data_dir: Directory where training file, dev file and test file are present
:param train_filename: training filename
:param dev_filename: development set filename, file to be used by model in eval step of training
:param test_filename: ... |
train a DensePassageRetrieval model
:param data_dir: Directory where training file, dev file and test file are present
:param train_filename: training filename
:param dev_filename: development set filename, file to be used by model in eval step of training
:param test_filename: ... | def train(self,
data_dir: str,
train_filename: str,
dev_filename: str = None,
test_filename: str = None,
batch_size: int = 2,
embed_title: bool = True,
num_hard_negatives: int = 1,
num_positives: int = 1,
... | [
"def",
"train",
"(",
"self",
",",
"data_dir",
":",
"str",
",",
"train_filename",
":",
"str",
",",
"dev_filename",
":",
"str",
"=",
"None",
",",
"test_filename",
":",
"str",
"=",
"None",
",",
"batch_size",
":",
"int",
"=",
"2",
",",
"embed_title",
":",
... | [
262,
4
] | [
359,
88
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.save | (self, save_dir: Union[Path, str], query_encoder_dir: str = "query_encoder",
passage_encoder_dir: str = "passage_encoder") |
Save DensePassageRetriever to the specified directory.
:param save_dir: Directory to save to.
:param query_encoder_dir: Directory in save_dir that contains query encoder model.
:param passage_encoder_dir: Directory in save_dir that contains passage encoder model.
:return: None
... |
Save DensePassageRetriever to the specified directory. | def save(self, save_dir: Union[Path, str], query_encoder_dir: str = "query_encoder",
passage_encoder_dir: str = "passage_encoder"):
"""
Save DensePassageRetriever to the specified directory.
:param save_dir: Directory to save to.
:param query_encoder_dir: Directory in save_... | [
"def",
"save",
"(",
"self",
",",
"save_dir",
":",
"Union",
"[",
"Path",
",",
"str",
"]",
",",
"query_encoder_dir",
":",
"str",
"=",
"\"query_encoder\"",
",",
"passage_encoder_dir",
":",
"str",
"=",
"\"passage_encoder\"",
")",
":",
"save_dir",
"=",
"Path",
... | [
361,
4
] | [
375,
84
] | python | en | ['en', 'error', 'th'] | False |
DensePassageRetriever.load | (cls,
load_dir: Union[Path, str],
document_store: BaseDocumentStore,
max_seq_len_query: int = 64,
max_seq_len_passage: int = 256,
use_gpu: bool = True,
batch_size: int = 16,
embed_title: bool = True,
use_fast_tokeniz... |
Load DensePassageRetriever from the specified directory.
|
Load DensePassageRetriever from the specified directory.
| def load(cls,
load_dir: Union[Path, str],
document_store: BaseDocumentStore,
max_seq_len_query: int = 64,
max_seq_len_passage: int = 256,
use_gpu: bool = True,
batch_size: int = 16,
embed_title: bool = True,
use_fast... | [
"def",
"load",
"(",
"cls",
",",
"load_dir",
":",
"Union",
"[",
"Path",
",",
"str",
"]",
",",
"document_store",
":",
"BaseDocumentStore",
",",
"max_seq_len_query",
":",
"int",
"=",
"64",
",",
"max_seq_len_passage",
":",
"int",
"=",
"256",
",",
"use_gpu",
... | [
378,
4
] | [
410,
18
] | python | en | ['en', 'error', 'th'] | False |
EmbeddingRetriever.__init__ | (
self,
document_store: BaseDocumentStore,
embedding_model: str,
model_version: Optional[str] = None,
use_gpu: bool = True,
model_format: str = "farm",
pooling_strategy: str = "reduce_mean",
emb_extraction_layer: int = -1,
) |
:param document_store: An instance of DocumentStore from which to retrieve documents.
:param embedding_model: Local path or name of model in Hugging Face's model hub such as ``'deepset/sentence_bert'``
:param model_version: The version of model to use from the HuggingFace model hub. Can be tag ... |
:param document_store: An instance of DocumentStore from which to retrieve documents.
:param embedding_model: Local path or name of model in Hugging Face's model hub such as ``'deepset/sentence_bert'``
:param model_version: The version of model to use from the HuggingFace model hub. Can be tag ... | def __init__(
self,
document_store: BaseDocumentStore,
embedding_model: str,
model_version: Optional[str] = None,
use_gpu: bool = True,
model_format: str = "farm",
pooling_strategy: str = "reduce_mean",
emb_extraction_layer: int = -1,
):
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"document_store",
":",
"BaseDocumentStore",
",",
"embedding_model",
":",
"str",
",",
"model_version",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"use_gpu",
":",
"bool",
"=",
"True",
",",
"model_format",
":",
"s... | [
414,
4
] | [
488,
37
] | python | en | ['en', 'error', 'th'] | False |
EmbeddingRetriever.retrieve | (self, query: str, filters: dict = None, top_k: int = 10, index: str = None) |
Scan through documents in DocumentStore and return a small number documents
that are most relevant to the query.
:param query: The query
:param filters: A dictionary where the keys specify a metadata field and the value is a list of accepted values for that field
:param top_k: ... |
Scan through documents in DocumentStore and return a small number documents
that are most relevant to the query. | def retrieve(self, query: str, filters: dict = None, top_k: int = 10, index: str = None) -> List[Document]:
"""
Scan through documents in DocumentStore and return a small number documents
that are most relevant to the query.
:param query: The query
:param filters: A dictionary w... | [
"def",
"retrieve",
"(",
"self",
",",
"query",
":",
"str",
",",
"filters",
":",
"dict",
"=",
"None",
",",
"top_k",
":",
"int",
"=",
"10",
",",
"index",
":",
"str",
"=",
"None",
")",
"->",
"List",
"[",
"Document",
"]",
":",
"if",
"index",
"is",
"... | [
490,
4
] | [
505,
24
] | python | en | ['en', 'error', 'th'] | False |
EmbeddingRetriever.embed | (self, texts: Union[List[str], str]) |
Create embeddings for each text in a list of texts using the retrievers model (`self.embedding_model`)
:param texts: Texts to embed
:return: List of embeddings (one per input text). Each embedding is a list of floats.
|
Create embeddings for each text in a list of texts using the retrievers model (`self.embedding_model`) | def embed(self, texts: Union[List[str], str]) -> List[np.ndarray]:
"""
Create embeddings for each text in a list of texts using the retrievers model (`self.embedding_model`)
:param texts: Texts to embed
:return: List of embeddings (one per input text). Each embedding is a list of floats... | [
"def",
"embed",
"(",
"self",
",",
"texts",
":",
"Union",
"[",
"List",
"[",
"str",
"]",
",",
"str",
"]",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"# for backward compatibility: cast pure str input",
"if",
"isinstance",
"(",
"texts",
",",
"s... | [
507,
4
] | [
530,
18
] | python | en | ['en', 'error', 'th'] | False |
EmbeddingRetriever.embed_queries | (self, texts: List[str]) |
Create embeddings for a list of queries. For this Retriever type: The same as calling .embed()
:param texts: Queries to embed
:return: Embeddings, one per input queries
|
Create embeddings for a list of queries. For this Retriever type: The same as calling .embed() | def embed_queries(self, texts: List[str]) -> List[np.ndarray]:
"""
Create embeddings for a list of queries. For this Retriever type: The same as calling .embed()
:param texts: Queries to embed
:return: Embeddings, one per input queries
"""
return self.embed(texts) | [
"def",
"embed_queries",
"(",
"self",
",",
"texts",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"return",
"self",
".",
"embed",
"(",
"texts",
")"
] | [
532,
4
] | [
539,
32
] | python | en | ['en', 'error', 'th'] | False |
EmbeddingRetriever.embed_passages | (self, docs: List[Document]) |
Create embeddings for a list of passages. For this Retriever type: The same as calling .embed()
:param docs: List of documents to embed
:return: Embeddings, one per input passage
|
Create embeddings for a list of passages. For this Retriever type: The same as calling .embed() | def embed_passages(self, docs: List[Document]) -> List[np.ndarray]:
"""
Create embeddings for a list of passages. For this Retriever type: The same as calling .embed()
:param docs: List of documents to embed
:return: Embeddings, one per input passage
"""
texts = [d.text ... | [
"def",
"embed_passages",
"(",
"self",
",",
"docs",
":",
"List",
"[",
"Document",
"]",
")",
"->",
"List",
"[",
"np",
".",
"ndarray",
"]",
":",
"texts",
"=",
"[",
"d",
".",
"text",
"for",
"d",
"in",
"docs",
"]",
"return",
"self",
".",
"embed",
"(",... | [
541,
4
] | [
550,
32
] | python | en | ['en', 'error', 'th'] | False |
ManualBatchKwargsGenerator._build_batch_kwargs | (self, batch_parameters) | Build batch kwargs from a partition id. | Build batch kwargs from a partition id. | def _build_batch_kwargs(self, batch_parameters):
"""Build batch kwargs from a partition id."""
partition_id = batch_parameters.pop("partition_id", None)
batch_kwargs = self._datasource.process_batch_parameters(batch_parameters)
if partition_id:
asset_definition = self._get_da... | [
"def",
"_build_batch_kwargs",
"(",
"self",
",",
"batch_parameters",
")",
":",
"partition_id",
"=",
"batch_parameters",
".",
"pop",
"(",
"\"partition_id\"",
",",
"None",
")",
"batch_kwargs",
"=",
"self",
".",
"_datasource",
".",
"process_batch_parameters",
"(",
"ba... | [
106,
4
] | [
142,
13
] | python | en | ['en', 'en', 'sw'] | True |
Analysis.get_company_data | (self, mid) | Looks up stock ticker information for a company via its Freebase ID.
| Looks up stock ticker information for a company via its Freebase ID.
| def get_company_data(self, mid):
"""Looks up stock ticker information for a company via its Freebase ID.
"""
try:
ticker_bindings = self.make_wikidata_request(
MID_TO_TICKER_QUERY % mid)
crypto_bindings = self.make_wikidata_request(
MID_TO... | [
"def",
"get_company_data",
"(",
"self",
",",
"mid",
")",
":",
"try",
":",
"ticker_bindings",
"=",
"self",
".",
"make_wikidata_request",
"(",
"MID_TO_TICKER_QUERY",
"%",
"mid",
")",
"crypto_bindings",
"=",
"self",
".",
"make_wikidata_request",
"(",
"MID_TO_CRYPTO_Q... | [
78,
4
] | [
157,
24
] | python | en | ['en', 'en', 'en'] | True |
Analysis.find_companies | (self, tweet) | Finds mentions of companies in a tweet. | Finds mentions of companies in a tweet. | def find_companies(self, tweet):
"""Finds mentions of companies in a tweet."""
if not tweet:
self.logs.warn('No tweet to find companies.')
return None
# Use the text of the tweet with any mentions expanded to improve
# entity detection.
text = self.get_e... | [
"def",
"find_companies",
"(",
"self",
",",
"tweet",
")",
":",
"if",
"not",
"tweet",
":",
"self",
".",
"logs",
".",
"warn",
"(",
"'No tweet to find companies.'",
")",
"return",
"None",
"# Use the text of the tweet with any mentions expanded to improve",
"# entity detecti... | [
159,
4
] | [
228,
24
] | python | en | ['en', 'en', 'en'] | True |
Analysis.get_expanded_text | (self, tweet) | Retrieves the text from a tweet with any @mentions expanded to
their full names.
| Retrieves the text from a tweet with any | def get_expanded_text(self, tweet):
"""Retrieves the text from a tweet with any @mentions expanded to
their full names.
"""
if not tweet:
self.logs.warn('No tweet to expand text.')
return None
try:
text = self.twitter.get_tweet_text(tweet)
... | [
"def",
"get_expanded_text",
"(",
"self",
",",
"tweet",
")",
":",
"if",
"not",
"tweet",
":",
"self",
".",
"logs",
".",
"warn",
"(",
"'No tweet to expand text.'",
")",
"return",
"None",
"try",
":",
"text",
"=",
"self",
".",
"twitter",
".",
"get_tweet_text",
... | [
230,
4
] | [
267,
19
] | python | en | ['en', 'en', 'en'] | True |
Analysis.make_wikidata_request | (self, query) | Makes a request to the Wikidata SPARQL API. | Makes a request to the Wikidata SPARQL API. | def make_wikidata_request(self, query):
"""Makes a request to the Wikidata SPARQL API."""
query_url = WIKIDATA_QUERY_URL % quote_plus(query)
self.logs.debug('Wikidata query: %s' % query_url)
response = get(query_url, headers=WIKIDATA_QUERY_HEADERS)
response.raise_for_status()
... | [
"def",
"make_wikidata_request",
"(",
"self",
",",
"query",
")",
":",
"query_url",
"=",
"WIKIDATA_QUERY_URL",
"%",
"quote_plus",
"(",
"query",
")",
"self",
".",
"logs",
".",
"debug",
"(",
"'Wikidata query: %s'",
"%",
"query_url",
")",
"response",
"=",
"get",
... | [
270,
4
] | [
293,
23
] | python | en | ['en', 'en', 'en'] | True |
Analysis.get_sentiment | (self, text) | Extracts a sentiment score [-1, 1] from text. | Extracts a sentiment score [-1, 1] from text. | def get_sentiment(self, text):
"""Extracts a sentiment score [-1, 1] from text."""
if not text:
self.logs.warn('No sentiment for empty text.')
return 0
document = language.Document(
content=text,
type_=language.Document.Type.PLAIN_TEXT,
... | [
"def",
"get_sentiment",
"(",
"self",
",",
"text",
")",
":",
"if",
"not",
"text",
":",
"self",
".",
"logs",
".",
"warn",
"(",
"'No sentiment for empty text.'",
")",
"return",
"0",
"document",
"=",
"language",
".",
"Document",
"(",
"content",
"=",
"text",
... | [
295,
4
] | [
313,
30
] | python | en | ['en', 'en', 'en'] | True |
_filter_xpath_grouping | (xpath) |
This method removes the outer parentheses for xpath grouping.
The xpath converter will break otherwise.
Example:
"(//button[@type='submit'])[1]" becomes "//button[@type='submit'][1]"
|
This method removes the outer parentheses for xpath grouping.
The xpath converter will break otherwise.
Example:
"(//button[ | def _filter_xpath_grouping(xpath):
"""
This method removes the outer parentheses for xpath grouping.
The xpath converter will break otherwise.
Example:
"(//button[@type='submit'])[1]" becomes "//button[@type='submit'][1]"
"""
# First remove the first open parentheses
xpath = xpath[1:]
... | [
"def",
"_filter_xpath_grouping",
"(",
"xpath",
")",
":",
"# First remove the first open parentheses",
"xpath",
"=",
"xpath",
"[",
"1",
":",
"]",
"# Next remove the last closed parentheses",
"index",
"=",
"xpath",
".",
"rfind",
"(",
"')'",
")",
"if",
"index",
"==",
... | [
57,
0
] | [
73,
16
] | python | en | ['en', 'error', 'th'] | False |
create_2D_mosaic_clean_mask | (clean_mask) |
The clean mask of a mosaic should be determined by the compositing function (e.g. mean
mosaic, median mosaic, etc.). This is simply supposed to be a decent approximation of a
clean mask for a mosaic that has no time dimension.
Parameters
----------
clean_mask: np.ndarray
The 3D c... |
The clean mask of a mosaic should be determined by the compositing function (e.g. mean
mosaic, median mosaic, etc.). This is simply supposed to be a decent approximation of a
clean mask for a mosaic that has no time dimension.
Parameters
----------
clean_mask: np.ndarray
The 3D c... | def create_2D_mosaic_clean_mask(clean_mask):
"""
The clean mask of a mosaic should be determined by the compositing function (e.g. mean
mosaic, median mosaic, etc.). This is simply supposed to be a decent approximation of a
clean mask for a mosaic that has no time dimension.
Parameters
--... | [
"def",
"create_2D_mosaic_clean_mask",
"(",
"clean_mask",
")",
":",
"mosaic_clean_mask",
"=",
"clean_mask",
"[",
"0",
"]",
"# Take the logical OR of clean masks through time.",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"clean_mask",
".",
"shape",
"[",
"0",
"]",
")"... | [
9,
0
] | [
29,
28
] | python | en | ['en', 'error', 'th'] | False |
landsat_clean_mask_invalid | (dataset) |
Masks out invalid data according to the LANDSAT
surface reflectance specifications. See this document:
https://landsat.usgs.gov/sites/default/files/documents/ledaps_product_guide.pdf pages 19-20.
Parameters
----------
dataset: xarray.Dataset
An xarray `Dataset` containing bands such as... |
Masks out invalid data according to the LANDSAT
surface reflectance specifications. See this document:
https://landsat.usgs.gov/sites/default/files/documents/ledaps_product_guide.pdf pages 19-20. | def landsat_clean_mask_invalid(dataset):
"""
Masks out invalid data according to the LANDSAT
surface reflectance specifications. See this document:
https://landsat.usgs.gov/sites/default/files/documents/ledaps_product_guide.pdf pages 19-20.
Parameters
----------
dataset: xarray.Dataset
... | [
"def",
"landsat_clean_mask_invalid",
"(",
"dataset",
")",
":",
"invalid_mask",
"=",
"None",
"data_arr_names",
"=",
"[",
"arr_name",
"for",
"arr_name",
"in",
"list",
"(",
"dataset",
".",
"data_vars",
")",
"if",
"arr_name",
"not",
"in",
"[",
"'pixel_qa'",
",",
... | [
31,
0
] | [
54,
23
] | python | en | ['en', 'error', 'th'] | False |
landsat_qa_clean_mask | (dataset, platform, cover_types=['clear', 'water']) |
Returns a clean_mask for `dataset` that masks out various types of terrain cover using the
Landsat pixel_qa band. Note that Landsat masks specify what to keep, not what to remove.
This means that using `cover_types=['clear', 'water']` should keep only clear land and water.
See "pixel_qa band" here: ht... |
Returns a clean_mask for `dataset` that masks out various types of terrain cover using the
Landsat pixel_qa band. Note that Landsat masks specify what to keep, not what to remove.
This means that using `cover_types=['clear', 'water']` should keep only clear land and water. | def landsat_qa_clean_mask(dataset, platform, cover_types=['clear', 'water']):
"""
Returns a clean_mask for `dataset` that masks out various types of terrain cover using the
Landsat pixel_qa band. Note that Landsat masks specify what to keep, not what to remove.
This means that using `cover_types=['clear... | [
"def",
"landsat_qa_clean_mask",
"(",
"dataset",
",",
"platform",
",",
"cover_types",
"=",
"[",
"'clear'",
",",
"'water'",
"]",
")",
":",
"processing_options",
"=",
"{",
"\"LANDSAT_5\"",
":",
"ls5_unpack_qa",
",",
"\"LANDSAT_7\"",
":",
"ls7_unpack_qa",
",",
"\"LA... | [
57,
0
] | [
109,
21
] | python | en | ['en', 'error', 'th'] | False |
xarray_values_in | (data, values, data_vars=None) |
Returns a mask for an xarray Dataset or DataArray, with `True` wherever the value is in values.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
The data to check for value matches.
values: list-like
The values to check for.
data_vars: list-like
The names ... |
Returns a mask for an xarray Dataset or DataArray, with `True` wherever the value is in values. | def xarray_values_in(data, values, data_vars=None):
"""
Returns a mask for an xarray Dataset or DataArray, with `True` wherever the value is in values.
Parameters
----------
data: xarray.Dataset or xarray.DataArray
The data to check for value matches.
values: list-like
The value... | [
"def",
"xarray_values_in",
"(",
"data",
",",
"values",
",",
"data_vars",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"xr",
".",
"Dataset",
")",
":",
"mask",
"=",
"np",
".",
"full_like",
"(",
"list",
"(",
"data",
".",
"data_vars",
"."... | [
111,
0
] | [
139,
15
] | python | en | ['en', 'error', 'th'] | False |
ValidationResultIdentifier.__init__ | (self, expectation_suite_identifier, run_id, batch_identifier) | Constructs a ValidationResultIdentifier
Args:
expectation_suite_identifier (ExpectationSuiteIdentifier, list, tuple, or dict):
identifying information for the fully-qualified expectation suite used to validate
run_id (RunIdentifier): The run_id for which validation occur... | Constructs a ValidationResultIdentifier | def __init__(self, expectation_suite_identifier, run_id, batch_identifier):
"""Constructs a ValidationResultIdentifier
Args:
expectation_suite_identifier (ExpectationSuiteIdentifier, list, tuple, or dict):
identifying information for the fully-qualified expectation suite use... | [
"def",
"__init__",
"(",
"self",
",",
"expectation_suite_identifier",
",",
"run_id",
",",
"batch_identifier",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_expectation_suite_identifier",
"=",
"expectation_suite_identifier",
"if",
"isinstance"... | [
102,
4
] | [
132,
49
] | python | en | ['en', 'en', 'en'] | True |
__remove_alias | (type_) |
Implementation detail.
Args:
type_ (type_t): type
Returns:
type_t: the type associated to the inputted type
|
Implementation detail. | def __remove_alias(type_):
"""
Implementation detail.
Args:
type_ (type_t): type
Returns:
type_t: the type associated to the inputted type
"""
if isinstance(type_, cpptypes.declarated_t) and \
isinstance(type_.declaration, typedef.typedef_t):
return __remove... | [
"def",
"__remove_alias",
"(",
"type_",
")",
":",
"if",
"isinstance",
"(",
"type_",
",",
"cpptypes",
".",
"declarated_t",
")",
"and",
"isinstance",
"(",
"type_",
".",
"declaration",
",",
"typedef",
".",
"typedef_t",
")",
":",
"return",
"__remove_alias",
"(",
... | [
25,
0
] | [
41,
16
] | python | en | ['en', 'error', 'th'] | False |
remove_alias | (type_) |
Returns `type_t` without typedef
Args:
type_ (type_t | declaration_t): type or declaration
Returns:
type_t: the type associated to the inputted declaration
|
Returns `type_t` without typedef | def remove_alias(type_):
"""
Returns `type_t` without typedef
Args:
type_ (type_t | declaration_t): type or declaration
Returns:
type_t: the type associated to the inputted declaration
"""
if isinstance(type_, cpptypes.type_t):
type_ref = type_
elif isinstance(type_... | [
"def",
"remove_alias",
"(",
"type_",
")",
":",
"if",
"isinstance",
"(",
"type_",
",",
"cpptypes",
".",
"type_t",
")",
":",
"type_ref",
"=",
"type_",
"elif",
"isinstance",
"(",
"type_",
",",
"typedef",
".",
"typedef_t",
")",
":",
"type_ref",
"=",
"type_",... | [
44,
0
] | [
65,
19
] | python | en | ['en', 'error', 'th'] | False |
decompose_type | (tp) |
Implementation detail
|
Implementation detail
| def decompose_type(tp):
"""
Implementation detail
"""
if isinstance(tp, cpptypes.compound_t):
return [tp] + decompose_type(tp.base)
elif isinstance(tp, typedef.typedef_t):
return decompose_type(tp.decl_type)
elif isinstance(tp, cpptypes.declarated_t) and \
isinstance(... | [
"def",
"decompose_type",
"(",
"tp",
")",
":",
"if",
"isinstance",
"(",
"tp",
",",
"cpptypes",
".",
"compound_t",
")",
":",
"return",
"[",
"tp",
"]",
"+",
"decompose_type",
"(",
"tp",
".",
"base",
")",
"elif",
"isinstance",
"(",
"tp",
",",
"typedef",
... | [
68,
0
] | [
80,
19
] | python | en | ['en', 'error', 'th'] | False |
decompose_class | (type_) | implementation details | implementation details | def decompose_class(type_):
"""implementation details"""
types = decompose_type(type_)
return [tp.__class__ for tp in types] | [
"def",
"decompose_class",
"(",
"type_",
")",
":",
"types",
"=",
"decompose_type",
"(",
"type_",
")",
"return",
"[",
"tp",
".",
"__class__",
"for",
"tp",
"in",
"types",
"]"
] | [
83,
0
] | [
86,
41
] | python | da | ['eo', 'da', 'en'] | False |
base_type | (type_) | returns base type.
For `const int` will return `int`
| returns base type. | def base_type(type_):
"""returns base type.
For `const int` will return `int`
"""
types = decompose_type(type_)
return types[-1] | [
"def",
"base_type",
"(",
"type_",
")",
":",
"types",
"=",
"decompose_type",
"(",
"type_",
")",
"return",
"types",
"[",
"-",
"1",
"]"
] | [
89,
0
] | [
95,
20
] | python | en | ['en', 'jv', 'en'] | True |
_create_cv_types | (base) |
Implementation detail.
|
Implementation detail. | def _create_cv_types(base):
"""
Implementation detail.
"""
return (
[base,
cpptypes.const_t(base),
cpptypes.volatile_t(base),
cpptypes.volatile_t(cpptypes.const_t(base))]
) | [
"def",
"_create_cv_types",
"(",
"base",
")",
":",
"return",
"(",
"[",
"base",
",",
"cpptypes",
".",
"const_t",
"(",
"base",
")",
",",
"cpptypes",
".",
"volatile_t",
"(",
"base",
")",
",",
"cpptypes",
".",
"volatile_t",
"(",
"cpptypes",
".",
"const_t",
... | [
98,
0
] | [
108,
5
] | python | en | ['en', 'error', 'th'] | False |
does_match_definition | (given, main, secondary) | implementation details | implementation details | def does_match_definition(given, main, secondary):
"""implementation details"""
assert isinstance(secondary, tuple)
assert len(secondary) == 2 # general solution could be provided
types = decompose_type(given)
if isinstance(types[0], main):
return True
if len(types) >= 2:
cond... | [
"def",
"does_match_definition",
"(",
"given",
",",
"main",
",",
"secondary",
")",
":",
"assert",
"isinstance",
"(",
"secondary",
",",
"tuple",
")",
"assert",
"len",
"(",
"secondary",
")",
"==",
"2",
"# general solution could be provided",
"types",
"=",
"decompos... | [
138,
0
] | [
169,
20
] | python | da | ['eo', 'da', 'en'] | False |
is_bool | (type_) |
Check if type is of boolean type.
Args:
type_ (type_t): The type to be checked
Returns:
bool: True if type is a boolean, False otherwise.
|
Check if type is of boolean type. | def is_bool(type_):
"""
Check if type is of boolean type.
Args:
type_ (type_t): The type to be checked
Returns:
bool: True if type is a boolean, False otherwise.
"""
return remove_alias(type_) in _bool_def | [
"def",
"is_bool",
"(",
"type_",
")",
":",
"return",
"remove_alias",
"(",
"type_",
")",
"in",
"_bool_def"
] | [
172,
0
] | [
182,
43
] | python | en | ['en', 'error', 'th'] | False |
is_void | (type_) |
Check if type is of void type.
Args:
type_ (type_t): The type to be checked
Returns:
bool: True if type is void, False otherwise.
|
Check if type is of void type. | def is_void(type_):
"""
Check if type is of void type.
Args:
type_ (type_t): The type to be checked
Returns:
bool: True if type is void, False otherwise.
"""
return remove_alias(type_) in _void_def | [
"def",
"is_void",
"(",
"type_",
")",
":",
"return",
"remove_alias",
"(",
"type_",
")",
"in",
"_void_def"
] | [
185,
0
] | [
195,
43
] | python | en | ['en', 'error', 'th'] | False |
is_void_pointer | (type_) | returns True, if type represents `void*`, False otherwise | returns True, if type represents `void*`, False otherwise | def is_void_pointer(type_):
"""returns True, if type represents `void*`, False otherwise"""
return is_same(type_, cpptypes.pointer_t(cpptypes.void_t())) | [
"def",
"is_void_pointer",
"(",
"type_",
")",
":",
"return",
"is_same",
"(",
"type_",
",",
"cpptypes",
".",
"pointer_t",
"(",
"cpptypes",
".",
"void_t",
"(",
")",
")",
")"
] | [
198,
0
] | [
200,
64
] | python | en | ['en', 'en', 'en'] | True |
is_integral | (type_) |
Check if type is a C++ integral type
Args:
type_ (type_t): The type to be checked
Returns:
bool: True if type is a C++ integral type, False otherwise.
|
Check if type is a C++ integral type | def is_integral(type_):
"""
Check if type is a C++ integral type
Args:
type_ (type_t): The type to be checked
Returns:
bool: True if type is a C++ integral type, False otherwise.
"""
return remove_alias(type_) in _integral_def | [
"def",
"is_integral",
"(",
"type_",
")",
":",
"return",
"remove_alias",
"(",
"type_",
")",
"in",
"_integral_def"
] | [
203,
0
] | [
213,
47
] | python | en | ['en', 'error', 'th'] | False |
is_floating_point | (type_) | returns True, if type represents C++ floating point type,
False otherwise | returns True, if type represents C++ floating point type,
False otherwise | def is_floating_point(type_):
"""returns True, if type represents C++ floating point type,
False otherwise"""
return remove_alias(type_) in _float_def | [
"def",
"is_floating_point",
"(",
"type_",
")",
":",
"return",
"remove_alias",
"(",
"type_",
")",
"in",
"_float_def"
] | [
216,
0
] | [
220,
44
] | python | en | ['en', 'en', 'en'] | True |
is_arithmetic | (type_) | returns True, if type represents C++ integral or floating point type,
False otherwise | returns True, if type represents C++ integral or floating point type,
False otherwise | def is_arithmetic(type_):
"""returns True, if type represents C++ integral or floating point type,
False otherwise"""
return is_integral(type_) or is_floating_point(type_) | [
"def",
"is_arithmetic",
"(",
"type_",
")",
":",
"return",
"is_integral",
"(",
"type_",
")",
"or",
"is_floating_point",
"(",
"type_",
")"
] | [
223,
0
] | [
226,
57
] | 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.