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
sequence | start_point
sequence | end_point
sequence | language
stringclasses 1
value | docstring_language
stringlengths 2
7
| docstring_language_predictions
stringlengths 18
23
| is_langid_reliable
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|---|---|---|
Hoverlabel.bordercolorsrc | (self) |
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def bordercolorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["bordercolorsrc"] | [
"def",
"bordercolorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bordercolorsrc\"",
"]"
] | [
209,
4
] | [
221,
37
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.font | (self) |
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.mesh3d.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size .
Returns
-------
plotly.graph_objs.mesh3d.hoverlabel.Font
|
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.mesh3d.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size . | def font(self):
"""
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.mesh3d.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size .
Returns
-------
plotly.graph_objs.mesh3d.hoverlabel.Font
"""
return self["font"] | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
230,
4
] | [
277,
27
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.namelength | (self) |
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|numpy.ndarray
|
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above | def namelength(self):
"""
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|numpy.ndarray
"""
return self["namelength"] | [
"def",
"namelength",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"namelength\"",
"]"
] | [
286,
4
] | [
304,
33
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.namelengthsrc | (self) |
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def namelengthsrc(self):
"""
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["namelengthsrc"] | [
"def",
"namelengthsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"namelengthsrc\"",
"]"
] | [
313,
4
] | [
325,
36
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.__init__ | (
self,
arg=None,
align=None,
alignsrc=None,
bgcolor=None,
bgcolorsrc=None,
bordercolor=None,
bordercolorsrc=None,
font=None,
namelength=None,
namelengthsrc=None,
**kwargs
) |
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.mesh3d.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength .
Returns
-------
Hoverlabel
|
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.mesh3d.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength . | def __init__(
self,
arg=None,
align=None,
alignsrc=None,
bgcolor=None,
bgcolorsrc=None,
bordercolor=None,
bordercolorsrc=None,
font=None,
namelength=None,
namelengthsrc=None,
**kwargs
):
"""
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.mesh3d.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength .
Returns
-------
Hoverlabel
"""
super(Hoverlabel, self).__init__("hoverlabel")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.mesh3d.Hoverlabel
constructor must be a dict or
an instance of :class:`plotly.graph_objs.mesh3d.Hoverlabel`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("align", None)
_v = align if align is not None else _v
if _v is not None:
self["align"] = _v
_v = arg.pop("alignsrc", None)
_v = alignsrc if alignsrc is not None else _v
if _v is not None:
self["alignsrc"] = _v
_v = arg.pop("bgcolor", None)
_v = bgcolor if bgcolor is not None else _v
if _v is not None:
self["bgcolor"] = _v
_v = arg.pop("bgcolorsrc", None)
_v = bgcolorsrc if bgcolorsrc is not None else _v
if _v is not None:
self["bgcolorsrc"] = _v
_v = arg.pop("bordercolor", None)
_v = bordercolor if bordercolor is not None else _v
if _v is not None:
self["bordercolor"] = _v
_v = arg.pop("bordercolorsrc", None)
_v = bordercolorsrc if bordercolorsrc is not None else _v
if _v is not None:
self["bordercolorsrc"] = _v
_v = arg.pop("font", None)
_v = font if font is not None else _v
if _v is not None:
self["font"] = _v
_v = arg.pop("namelength", None)
_v = namelength if namelength is not None else _v
if _v is not None:
self["namelength"] = _v
_v = arg.pop("namelengthsrc", None)
_v = namelengthsrc if namelengthsrc is not None else _v
if _v is not None:
self["namelengthsrc"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"align",
"=",
"None",
",",
"alignsrc",
"=",
"None",
",",
"bgcolor",
"=",
"None",
",",
"bgcolorsrc",
"=",
"None",
",",
"bordercolor",
"=",
"None",
",",
"bordercolorsrc",
"=",
"None",
",",
"font",
"=",
"None",
",",
"namelength",
"=",
"None",
",",
"namelengthsrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Hoverlabel",
",",
"self",
")",
".",
"__init__",
"(",
"\"hoverlabel\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.mesh3d.Hoverlabel \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.mesh3d.Hoverlabel`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"align\"",
",",
"None",
")",
"_v",
"=",
"align",
"if",
"align",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"align\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"alignsrc\"",
",",
"None",
")",
"_v",
"=",
"alignsrc",
"if",
"alignsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"alignsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bgcolor\"",
",",
"None",
")",
"_v",
"=",
"bgcolor",
"if",
"bgcolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bgcolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bgcolorsrc\"",
",",
"None",
")",
"_v",
"=",
"bgcolorsrc",
"if",
"bgcolorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bgcolorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bordercolor\"",
",",
"None",
")",
"_v",
"=",
"bordercolor",
"if",
"bordercolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bordercolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bordercolorsrc\"",
",",
"None",
")",
"_v",
"=",
"bordercolorsrc",
"if",
"bordercolorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bordercolorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"font\"",
",",
"None",
")",
"_v",
"=",
"font",
"if",
"font",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"font\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"namelength\"",
",",
"None",
")",
"_v",
"=",
"namelength",
"if",
"namelength",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"namelength\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"namelengthsrc\"",
",",
"None",
")",
"_v",
"=",
"namelengthsrc",
"if",
"namelengthsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"namelengthsrc\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
370,
4
] | [
502,
34
] | python | en | ['en', 'error', 'th'] | False |
Gradient.color | (self) |
Sets the final color of the gradient fill: the center color for
radial, the right for horizontal, or the bottom for vertical.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
|
Sets the final color of the gradient fill: the center color for
radial, the right for horizontal, or the bottom for vertical.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above | def color(self):
"""
Sets the final color of the gradient fill: the center color for
radial, the right for horizontal, or the bottom for vertical.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["color"] | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
67,
28
] | python | en | ['en', 'error', 'th'] | False |
Gradient.colorsrc | (self) |
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def colorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["colorsrc"] | [
"def",
"colorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"colorsrc\"",
"]"
] | [
76,
4
] | [
87,
31
] | python | en | ['en', 'error', 'th'] | False |
Gradient.type | (self) |
Sets the type of gradient used to fill the markers
The 'type' property is an enumeration that may be specified as:
- One of the following enumeration values:
['radial', 'horizontal', 'vertical', 'none']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
|
Sets the type of gradient used to fill the markers
The 'type' property is an enumeration that may be specified as:
- One of the following enumeration values:
['radial', 'horizontal', 'vertical', 'none']
- A tuple, list, or one-dimensional numpy array of the above | def type(self):
"""
Sets the type of gradient used to fill the markers
The 'type' property is an enumeration that may be specified as:
- One of the following enumeration values:
['radial', 'horizontal', 'vertical', 'none']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
"""
return self["type"] | [
"def",
"type",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"type\"",
"]"
] | [
96,
4
] | [
109,
27
] | python | en | ['en', 'error', 'th'] | False |
Gradient.typesrc | (self) |
Sets the source reference on Chart Studio Cloud for type .
The 'typesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for type .
The 'typesrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def typesrc(self):
"""
Sets the source reference on Chart Studio Cloud for type .
The 'typesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["typesrc"] | [
"def",
"typesrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"typesrc\"",
"]"
] | [
118,
4
] | [
129,
30
] | python | en | ['en', 'error', 'th'] | False |
Gradient.__init__ | (
self, arg=None, color=None, colorsrc=None, type=None, typesrc=None, **kwargs
) |
Construct a new Gradient object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolar.marker.Gradient`
color
Sets the final color of the gradient fill: the center
color for radial, the right for horizontal, or the
bottom for vertical.
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
type
Sets the type of gradient used to fill the markers
typesrc
Sets the source reference on Chart Studio Cloud for
type .
Returns
-------
Gradient
|
Construct a new Gradient object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolar.marker.Gradient`
color
Sets the final color of the gradient fill: the center
color for radial, the right for horizontal, or the
bottom for vertical.
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
type
Sets the type of gradient used to fill the markers
typesrc
Sets the source reference on Chart Studio Cloud for
type . | def __init__(
self, arg=None, color=None, colorsrc=None, type=None, typesrc=None, **kwargs
):
"""
Construct a new Gradient object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolar.marker.Gradient`
color
Sets the final color of the gradient fill: the center
color for radial, the right for horizontal, or the
bottom for vertical.
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
type
Sets the type of gradient used to fill the markers
typesrc
Sets the source reference on Chart Studio Cloud for
type .
Returns
-------
Gradient
"""
super(Gradient, self).__init__("gradient")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.scatterpolar.marker.Gradient
constructor must be a dict or
an instance of :class:`plotly.graph_objs.scatterpolar.marker.Gradient`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("color", None)
_v = color if color is not None else _v
if _v is not None:
self["color"] = _v
_v = arg.pop("colorsrc", None)
_v = colorsrc if colorsrc is not None else _v
if _v is not None:
self["colorsrc"] = _v
_v = arg.pop("type", None)
_v = type if type is not None else _v
if _v is not None:
self["type"] = _v
_v = arg.pop("typesrc", None)
_v = typesrc if typesrc is not None else _v
if _v is not None:
self["typesrc"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"type",
"=",
"None",
",",
"typesrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Gradient",
",",
"self",
")",
".",
"__init__",
"(",
"\"gradient\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.scatterpolar.marker.Gradient \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scatterpolar.marker.Gradient`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"color\"",
",",
"None",
")",
"_v",
"=",
"color",
"if",
"color",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"color\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"colorsrc\"",
",",
"None",
")",
"_v",
"=",
"colorsrc",
"if",
"colorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"colorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"type\"",
",",
"None",
")",
"_v",
"=",
"type",
"if",
"type",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"type\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"typesrc\"",
",",
"None",
")",
"_v",
"=",
"typesrc",
"if",
"typesrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"typesrc\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
154,
4
] | [
235,
34
] | python | en | ['en', 'error', 'th'] | False |
create | (body) | Create a presentation. | Create a presentation. | def create(body):
"""Create a presentation."""
url = build_url(RESOURCE)
return request("post", url, json=body) | [
"def",
"create",
"(",
"body",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
")",
"return",
"request",
"(",
"\"post\"",
",",
"url",
",",
"json",
"=",
"body",
")"
] | [
10,
0
] | [
13,
42
] | python | en | ['en', 'co', 'en'] | True |
list | () | Returns the list of all users' presentations. | Returns the list of all users' presentations. | def list():
"""Returns the list of all users' presentations."""
url = build_url(RESOURCE)
return request("get", url) | [
"def",
"list",
"(",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
")",
"return",
"request",
"(",
"\"get\"",
",",
"url",
")"
] | [
16,
0
] | [
19,
30
] | python | en | ['en', 'en', 'en'] | True |
retrieve | (fid) | Retrieve a presentation from Plotly. | Retrieve a presentation from Plotly. | def retrieve(fid):
"""Retrieve a presentation from Plotly."""
url = build_url(RESOURCE, id=fid)
return request("get", url) | [
"def",
"retrieve",
"(",
"fid",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
")",
"return",
"request",
"(",
"\"get\"",
",",
"url",
")"
] | [
22,
0
] | [
25,
30
] | python | en | ['en', 'sk', 'en'] | True |
update | (fid, content) | Completely update the writable. | Completely update the writable. | def update(fid, content):
"""Completely update the writable."""
url = build_url(RESOURCE, id=fid)
return request("put", url, json=content) | [
"def",
"update",
"(",
"fid",
",",
"content",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"id",
"=",
"fid",
")",
"return",
"request",
"(",
"\"put\"",
",",
"url",
",",
"json",
"=",
"content",
")"
] | [
28,
0
] | [
31,
44
] | python | en | ['en', 'en', 'en'] | True |
finalize.__call__ | (self, _=None) | If alive then mark as dead and return func(*args, **kwargs);
otherwise return None | If alive then mark as dead and return func(*args, **kwargs);
otherwise return None | def __call__(self, _=None):
"""If alive then mark as dead and return func(*args, **kwargs);
otherwise return None"""
info = self._registry.pop(self, None)
if info and not self._shutdown:
return info.func(*info.args, **(info.kwargs or {})) | [
"def",
"__call__",
"(",
"self",
",",
"_",
"=",
"None",
")",
":",
"info",
"=",
"self",
".",
"_registry",
".",
"pop",
"(",
"self",
",",
"None",
")",
"if",
"info",
"and",
"not",
"self",
".",
"_shutdown",
":",
"return",
"info",
".",
"func",
"(",
"*",
"info",
".",
"args",
",",
"*",
"*",
"(",
"info",
".",
"kwargs",
"or",
"{",
"}",
")",
")"
] | [
58,
4
] | [
63,
63
] | python | en | ['en', 'en', 'en'] | True |
finalize.detach | (self) | If alive then mark as dead and return (obj, func, args, kwargs);
otherwise return None | If alive then mark as dead and return (obj, func, args, kwargs);
otherwise return None | def detach(self):
"""If alive then mark as dead and return (obj, func, args, kwargs);
otherwise return None"""
info = self._registry.get(self)
obj = info and info.weakref()
if obj is not None and self._registry.pop(self, None):
return (obj, info.func, info.args, info.kwargs or {}) | [
"def",
"detach",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"_registry",
".",
"get",
"(",
"self",
")",
"obj",
"=",
"info",
"and",
"info",
".",
"weakref",
"(",
")",
"if",
"obj",
"is",
"not",
"None",
"and",
"self",
".",
"_registry",
".",
"pop",
"(",
"self",
",",
"None",
")",
":",
"return",
"(",
"obj",
",",
"info",
".",
"func",
",",
"info",
".",
"args",
",",
"info",
".",
"kwargs",
"or",
"{",
"}",
")"
] | [
65,
4
] | [
71,
65
] | python | en | ['en', 'en', 'sw'] | True |
finalize.peek | (self) | If alive then return (obj, func, args, kwargs);
otherwise return None | If alive then return (obj, func, args, kwargs);
otherwise return None | def peek(self):
"""If alive then return (obj, func, args, kwargs);
otherwise return None"""
info = self._registry.get(self)
obj = info and info.weakref()
if obj is not None:
return (obj, info.func, info.args, info.kwargs or {}) | [
"def",
"peek",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"_registry",
".",
"get",
"(",
"self",
")",
"obj",
"=",
"info",
"and",
"info",
".",
"weakref",
"(",
")",
"if",
"obj",
"is",
"not",
"None",
":",
"return",
"(",
"obj",
",",
"info",
".",
"func",
",",
"info",
".",
"args",
",",
"info",
".",
"kwargs",
"or",
"{",
"}",
")"
] | [
73,
4
] | [
79,
65
] | python | en | ['en', 'fy', 'sw'] | False |
finalize.alive | (self) | Whether finalizer is alive | Whether finalizer is alive | def alive(self):
"""Whether finalizer is alive"""
return self in self._registry | [
"def",
"alive",
"(",
"self",
")",
":",
"return",
"self",
"in",
"self",
".",
"_registry"
] | [
82,
4
] | [
84,
37
] | python | en | ['en', 'en', 'en'] | True |
finalize.atexit | (self) | Whether finalizer should be called at exit | Whether finalizer should be called at exit | def atexit(self):
"""Whether finalizer should be called at exit"""
info = self._registry.get(self)
return bool(info) and info.atexit | [
"def",
"atexit",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"_registry",
".",
"get",
"(",
"self",
")",
"return",
"bool",
"(",
"info",
")",
"and",
"info",
".",
"atexit"
] | [
87,
4
] | [
90,
41
] | python | en | ['en', 'en', 'en'] | True |
Session.init_session | (self, protocol_key, address, sessionhandler) |
Initialize the Session. This should be called by the protocol when
a new session is established.
Args:
protocol_key (str): By default, one of 'telnet', 'telnet/ssl', 'ssh',
'webclient/websocket' or 'webclient/ajax'.
address (str): Client address.
sessionhandler (SessionHandler): Reference to the
main sessionhandler instance.
|
Initialize the Session. This should be called by the protocol when
a new session is established. | def init_session(self, protocol_key, address, sessionhandler):
"""
Initialize the Session. This should be called by the protocol when
a new session is established.
Args:
protocol_key (str): By default, one of 'telnet', 'telnet/ssl', 'ssh',
'webclient/websocket' or 'webclient/ajax'.
address (str): Client address.
sessionhandler (SessionHandler): Reference to the
main sessionhandler instance.
"""
# This is currently 'telnet', 'ssh', 'ssl' or 'web'
self.protocol_key = protocol_key
# Protocol address tied to this session
self.address = address
# suid is used by some protocols, it's a hex key.
self.suid = None
# unique id for this session
self.sessid = 0 # no sessid yet
# client session id, if given by the client
self.csessid = None
# database id for the user connected to this session
self.uid = None
# user name, for easier tracking of sessions
self.uname = None
# if user has authenticated already or not
self.logged_in = False
# database id of puppeted object (if any)
self.puid = None
# session time statistics
self.conn_time = time.time()
self.cmd_last_visible = self.conn_time
self.cmd_last = self.conn_time
self.cmd_total = 0
self.protocol_flags = {"ENCODING": "utf-8",
"SCREENREADER": False,
"INPUTDEBUG": False,
"RAW": False,
"NOCOLOR": False}
self.server_data = {}
# map of input data to session methods
self.datamap = {}
# a back-reference to the relevant sessionhandler this
# session is stored in.
self.sessionhandler = sessionhandler | [
"def",
"init_session",
"(",
"self",
",",
"protocol_key",
",",
"address",
",",
"sessionhandler",
")",
":",
"# This is currently 'telnet', 'ssh', 'ssl' or 'web'",
"self",
".",
"protocol_key",
"=",
"protocol_key",
"# Protocol address tied to this session",
"self",
".",
"address",
"=",
"address",
"# suid is used by some protocols, it's a hex key.",
"self",
".",
"suid",
"=",
"None",
"# unique id for this session",
"self",
".",
"sessid",
"=",
"0",
"# no sessid yet",
"# client session id, if given by the client",
"self",
".",
"csessid",
"=",
"None",
"# database id for the user connected to this session",
"self",
".",
"uid",
"=",
"None",
"# user name, for easier tracking of sessions",
"self",
".",
"uname",
"=",
"None",
"# if user has authenticated already or not",
"self",
".",
"logged_in",
"=",
"False",
"# database id of puppeted object (if any)",
"self",
".",
"puid",
"=",
"None",
"# session time statistics",
"self",
".",
"conn_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"cmd_last_visible",
"=",
"self",
".",
"conn_time",
"self",
".",
"cmd_last",
"=",
"self",
".",
"conn_time",
"self",
".",
"cmd_total",
"=",
"0",
"self",
".",
"protocol_flags",
"=",
"{",
"\"ENCODING\"",
":",
"\"utf-8\"",
",",
"\"SCREENREADER\"",
":",
"False",
",",
"\"INPUTDEBUG\"",
":",
"False",
",",
"\"RAW\"",
":",
"False",
",",
"\"NOCOLOR\"",
":",
"False",
"}",
"self",
".",
"server_data",
"=",
"{",
"}",
"# map of input data to session methods",
"self",
".",
"datamap",
"=",
"{",
"}",
"# a back-reference to the relevant sessionhandler this",
"# session is stored in.",
"self",
".",
"sessionhandler",
"=",
"sessionhandler"
] | [
42,
4
] | [
95,
44
] | python | en | ['en', 'error', 'th'] | False |
Session.get_sync_data | (self) |
Get all data relevant to sync the session.
Args:
syncdata (dict): All syncdata values, based on
the keys given by self._attrs_to_sync.
|
Get all data relevant to sync the session. | def get_sync_data(self):
"""
Get all data relevant to sync the session.
Args:
syncdata (dict): All syncdata values, based on
the keys given by self._attrs_to_sync.
"""
return dict((key, value) for key, value in self.__dict__.items()
if key in self._attrs_to_sync) | [
"def",
"get_sync_data",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
"if",
"key",
"in",
"self",
".",
"_attrs_to_sync",
")"
] | [
97,
4
] | [
107,
50
] | python | en | ['en', 'error', 'th'] | False |
Session.load_sync_data | (self, sessdata) |
Takes a session dictionary, as created by get_sync_data, and
loads it into the correct properties of the session.
Args:
sessdata (dict): Session data dictionary.
|
Takes a session dictionary, as created by get_sync_data, and
loads it into the correct properties of the session. | def load_sync_data(self, sessdata):
"""
Takes a session dictionary, as created by get_sync_data, and
loads it into the correct properties of the session.
Args:
sessdata (dict): Session data dictionary.
"""
for propname, value in sessdata.items():
if (propname == "protocol_flags" and isinstance(value, dict) and
hasattr(self, "protocol_flags") and
isinstance(self.protocol_flags, dict)):
# special handling to allow partial update of protocol flags
self.protocol_flags.update(value)
else:
setattr(self, propname, value) | [
"def",
"load_sync_data",
"(",
"self",
",",
"sessdata",
")",
":",
"for",
"propname",
",",
"value",
"in",
"sessdata",
".",
"items",
"(",
")",
":",
"if",
"(",
"propname",
"==",
"\"protocol_flags\"",
"and",
"isinstance",
"(",
"value",
",",
"dict",
")",
"and",
"hasattr",
"(",
"self",
",",
"\"protocol_flags\"",
")",
"and",
"isinstance",
"(",
"self",
".",
"protocol_flags",
",",
"dict",
")",
")",
":",
"# special handling to allow partial update of protocol flags",
"self",
".",
"protocol_flags",
".",
"update",
"(",
"value",
")",
"else",
":",
"setattr",
"(",
"self",
",",
"propname",
",",
"value",
")"
] | [
109,
4
] | [
125,
46
] | python | en | ['en', 'error', 'th'] | False |
Session.at_sync | (self) |
Called after a session has been fully synced (including
secondary operations such as setting self.account based
on uid etc).
|
Called after a session has been fully synced (including
secondary operations such as setting self.account based
on uid etc). | def at_sync(self):
"""
Called after a session has been fully synced (including
secondary operations such as setting self.account based
on uid etc).
"""
if self.account:
self.protocol_flags.update(self.account.attributes.get("_saved_protocol_flags", {})) | [
"def",
"at_sync",
"(",
"self",
")",
":",
"if",
"self",
".",
"account",
":",
"self",
".",
"protocol_flags",
".",
"update",
"(",
"self",
".",
"account",
".",
"attributes",
".",
"get",
"(",
"\"_saved_protocol_flags\"",
",",
"{",
"}",
")",
")"
] | [
127,
4
] | [
135,
96
] | python | en | ['en', 'error', 'th'] | False |
Session.disconnect | (self, reason=None) |
generic hook called from the outside to disconnect this session
should be connected to the protocols actual disconnect mechanism.
Args:
reason (str): Eventual text motivating the disconnect.
|
generic hook called from the outside to disconnect this session
should be connected to the protocols actual disconnect mechanism. | def disconnect(self, reason=None):
"""
generic hook called from the outside to disconnect this session
should be connected to the protocols actual disconnect mechanism.
Args:
reason (str): Eventual text motivating the disconnect.
"""
pass | [
"def",
"disconnect",
"(",
"self",
",",
"reason",
"=",
"None",
")",
":",
"pass"
] | [
139,
4
] | [
148,
12
] | python | en | ['en', 'error', 'th'] | False |
Session.data_out | (self, **kwargs) |
Generic hook for sending data out through the protocol. Server
protocols can use this right away. Portal sessions
should overload this to format/handle the outgoing data as needed.
Kwargs:
kwargs (any): Other data to the protocol.
|
Generic hook for sending data out through the protocol. Server
protocols can use this right away. Portal sessions
should overload this to format/handle the outgoing data as needed. | def data_out(self, **kwargs):
"""
Generic hook for sending data out through the protocol. Server
protocols can use this right away. Portal sessions
should overload this to format/handle the outgoing data as needed.
Kwargs:
kwargs (any): Other data to the protocol.
"""
pass | [
"def",
"data_out",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
150,
4
] | [
160,
12
] | python | en | ['en', 'error', 'th'] | False |
Session.data_in | (self, **kwargs) |
Hook for protocols to send incoming data to the engine.
Kwargs:
kwargs (any): Other data from the protocol.
|
Hook for protocols to send incoming data to the engine. | def data_in(self, **kwargs):
"""
Hook for protocols to send incoming data to the engine.
Kwargs:
kwargs (any): Other data from the protocol.
"""
pass | [
"def",
"data_in",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
162,
4
] | [
170,
12
] | python | en | ['en', 'error', 'th'] | False |
RandomCandidateAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command line arguments for this agent.
|
Add command line arguments for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command line arguments for this agent.
"""
parser = parser.add_argument_group('RandomCandidateAgent Arguments')
parser.add_argument(
'--label_candidates_file',
type=str,
default=None,
help='file of candidate responses to choose from',
)
return parser | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"parser",
"=",
"parser",
".",
"add_argument_group",
"(",
"'RandomCandidateAgent Arguments'",
")",
"parser",
".",
"add_argument",
"(",
"'--label_candidates_file'",
",",
"type",
"=",
"str",
",",
"default",
"=",
"None",
",",
"help",
"=",
"'file of candidate responses to choose from'",
",",
")",
"return",
"parser"
] | [
26,
4
] | [
39,
21
] | python | en | ['en', 'error', 'th'] | False |
RandomCandidateAgent.__init__ | (self, opt, shared=None) |
Initialize this agent.
|
Initialize this agent.
| def __init__(self, opt, shared=None):
"""
Initialize this agent.
"""
super().__init__(opt)
self.id = 'RandomCandidateAgent'
random.seed(42)
if opt.get('label_candidates_file'):
f = open(opt.get('label_candidates_file'))
self.label_candidates = f.read().split('\n') | [
"def",
"__init__",
"(",
"self",
",",
"opt",
",",
"shared",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"opt",
")",
"self",
".",
"id",
"=",
"'RandomCandidateAgent'",
"random",
".",
"seed",
"(",
"42",
")",
"if",
"opt",
".",
"get",
"(",
"'label_candidates_file'",
")",
":",
"f",
"=",
"open",
"(",
"opt",
".",
"get",
"(",
"'label_candidates_file'",
")",
")",
"self",
".",
"label_candidates",
"=",
"f",
".",
"read",
"(",
")",
".",
"split",
"(",
"'\\n'",
")"
] | [
41,
4
] | [
50,
56
] | python | en | ['en', 'error', 'th'] | False |
RandomCandidateAgent.act | (self) |
Generate response to last seen observation.
Replies with a randomly selected candidate if label_candidates or a
candidate file are available.
Otherwise, replies with the label if they are available.
Oterhwise, replies with generic hardcoded responses if the agent has
not observed any messages or if there are no replies to suggest.
:returns: message dict with reply
|
Generate response to last seen observation. | def act(self):
"""
Generate response to last seen observation.
Replies with a randomly selected candidate if label_candidates or a
candidate file are available.
Otherwise, replies with the label if they are available.
Oterhwise, replies with generic hardcoded responses if the agent has
not observed any messages or if there are no replies to suggest.
:returns: message dict with reply
"""
obs = self.observation
if obs is None:
return {'text': 'Nothing to reply to yet.'}
reply = {}
reply['id'] = self.getID()
label_candidates = obs.get('label_candidates')
if hasattr(self, 'label_candidates'):
# override label candidates with candidate file if set
label_candidates = self.label_candidates
if label_candidates:
label_candidates = list(label_candidates)
random.shuffle(label_candidates)
reply['text_candidates'] = label_candidates
reply['text'] = label_candidates[0]
else:
# reply with I don't know.
reply['text'] = "I don't know."
return reply | [
"def",
"act",
"(",
"self",
")",
":",
"obs",
"=",
"self",
".",
"observation",
"if",
"obs",
"is",
"None",
":",
"return",
"{",
"'text'",
":",
"'Nothing to reply to yet.'",
"}",
"reply",
"=",
"{",
"}",
"reply",
"[",
"'id'",
"]",
"=",
"self",
".",
"getID",
"(",
")",
"label_candidates",
"=",
"obs",
".",
"get",
"(",
"'label_candidates'",
")",
"if",
"hasattr",
"(",
"self",
",",
"'label_candidates'",
")",
":",
"# override label candidates with candidate file if set",
"label_candidates",
"=",
"self",
".",
"label_candidates",
"if",
"label_candidates",
":",
"label_candidates",
"=",
"list",
"(",
"label_candidates",
")",
"random",
".",
"shuffle",
"(",
"label_candidates",
")",
"reply",
"[",
"'text_candidates'",
"]",
"=",
"label_candidates",
"reply",
"[",
"'text'",
"]",
"=",
"label_candidates",
"[",
"0",
"]",
"else",
":",
"# reply with I don't know.",
"reply",
"[",
"'text'",
"]",
"=",
"\"I don't know.\"",
"return",
"reply"
] | [
52,
4
] | [
82,
20
] | python | en | ['en', 'error', 'th'] | False |
PointFPModule.forward | (self, target: torch.Tensor, source: torch.Tensor,
target_feats: torch.Tensor,
source_feats: torch.Tensor) | forward.
Args:
target (Tensor): (B, n, 3) tensor of the xyz positions of
the target features.
source (Tensor): (B, m, 3) tensor of the xyz positions of
the source features.
target_feats (Tensor): (B, C1, n) tensor of the features to be
propagated to.
source_feats (Tensor): (B, C2, m) tensor of features
to be propagated.
Return:
Tensor: (B, M, N) M = mlp[-1], tensor of the target features.
| forward. | def forward(self, target: torch.Tensor, source: torch.Tensor,
target_feats: torch.Tensor,
source_feats: torch.Tensor) -> torch.Tensor:
"""forward.
Args:
target (Tensor): (B, n, 3) tensor of the xyz positions of
the target features.
source (Tensor): (B, m, 3) tensor of the xyz positions of
the source features.
target_feats (Tensor): (B, C1, n) tensor of the features to be
propagated to.
source_feats (Tensor): (B, C2, m) tensor of features
to be propagated.
Return:
Tensor: (B, M, N) M = mlp[-1], tensor of the target features.
"""
if source is not None:
dist, idx = three_nn(target, source)
dist_reciprocal = 1.0 / (dist + 1e-8)
norm = torch.sum(dist_reciprocal, dim=2, keepdim=True)
weight = dist_reciprocal / norm
interpolated_feats = three_interpolate(source_feats, idx, weight)
else:
interpolated_feats = source_feats.expand(*source_feats.size()[0:2],
target.size(1))
if target_feats is not None:
new_features = torch.cat([interpolated_feats, target_feats],
dim=1) # (B, C2 + C1, n)
else:
new_features = interpolated_feats
new_features = new_features.unsqueeze(-1)
new_features = self.mlps(new_features)
return new_features.squeeze(-1) | [
"def",
"forward",
"(",
"self",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"source",
":",
"torch",
".",
"Tensor",
",",
"target_feats",
":",
"torch",
".",
"Tensor",
",",
"source_feats",
":",
"torch",
".",
"Tensor",
")",
"->",
"torch",
".",
"Tensor",
":",
"if",
"source",
"is",
"not",
"None",
":",
"dist",
",",
"idx",
"=",
"three_nn",
"(",
"target",
",",
"source",
")",
"dist_reciprocal",
"=",
"1.0",
"/",
"(",
"dist",
"+",
"1e-8",
")",
"norm",
"=",
"torch",
".",
"sum",
"(",
"dist_reciprocal",
",",
"dim",
"=",
"2",
",",
"keepdim",
"=",
"True",
")",
"weight",
"=",
"dist_reciprocal",
"/",
"norm",
"interpolated_feats",
"=",
"three_interpolate",
"(",
"source_feats",
",",
"idx",
",",
"weight",
")",
"else",
":",
"interpolated_feats",
"=",
"source_feats",
".",
"expand",
"(",
"*",
"source_feats",
".",
"size",
"(",
")",
"[",
"0",
":",
"2",
"]",
",",
"target",
".",
"size",
"(",
"1",
")",
")",
"if",
"target_feats",
"is",
"not",
"None",
":",
"new_features",
"=",
"torch",
".",
"cat",
"(",
"[",
"interpolated_feats",
",",
"target_feats",
"]",
",",
"dim",
"=",
"1",
")",
"# (B, C2 + C1, n)",
"else",
":",
"new_features",
"=",
"interpolated_feats",
"new_features",
"=",
"new_features",
".",
"unsqueeze",
"(",
"-",
"1",
")",
"new_features",
"=",
"self",
".",
"mlps",
"(",
"new_features",
")",
"return",
"new_features",
".",
"squeeze",
"(",
"-",
"1",
")"
] | [
38,
4
] | [
76,
39
] | python | en | ['en', 'cy', 'en'] | False |
Stream.maxpoints | (self) |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000]
Returns
-------
int|float
|
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000] | def maxpoints(self):
"""
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000]
Returns
-------
int|float
"""
return self["maxpoints"] | [
"def",
"maxpoints",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"maxpoints\"",
"]"
] | [
15,
4
] | [
28,
32
] | python | en | ['en', 'error', 'th'] | False |
Stream.token | (self) |
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
|
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string | def token(self):
"""
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
"""
return self["token"] | [
"def",
"token",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"token\"",
"]"
] | [
37,
4
] | [
50,
28
] | python | en | ['en', 'error', 'th'] | False |
Stream.__init__ | (self, arg=None, maxpoints=None, token=None, **kwargs) |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.pie.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
from an incoming stream. If `maxpoints` is set to 50,
only the newest 50 points will be displayed on the
plot.
token
The stream id number links a data trace on a plot with
a stream. See https://chart-studio.plotly.com/settings
for more details.
Returns
-------
Stream
|
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.pie.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
from an incoming stream. If `maxpoints` is set to 50,
only the newest 50 points will be displayed on the
plot.
token
The stream id number links a data trace on a plot with
a stream. See https://chart-studio.plotly.com/settings
for more details. | def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
"""
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.pie.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
from an incoming stream. If `maxpoints` is set to 50,
only the newest 50 points will be displayed on the
plot.
token
The stream id number links a data trace on a plot with
a stream. See https://chart-studio.plotly.com/settings
for more details.
Returns
-------
Stream
"""
super(Stream, self).__init__("stream")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.pie.Stream
constructor must be a dict or
an instance of :class:`plotly.graph_objs.pie.Stream`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("maxpoints", None)
_v = maxpoints if maxpoints is not None else _v
if _v is not None:
self["maxpoints"] = _v
_v = arg.pop("token", None)
_v = token if token is not None else _v
if _v is not None:
self["token"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"maxpoints",
"=",
"None",
",",
"token",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Stream",
",",
"self",
")",
".",
"__init__",
"(",
"\"stream\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.pie.Stream \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.pie.Stream`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"maxpoints\"",
",",
"None",
")",
"_v",
"=",
"maxpoints",
"if",
"maxpoints",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"maxpoints\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"token\"",
",",
"None",
")",
"_v",
"=",
"token",
"if",
"token",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"token\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
72,
4
] | [
139,
34
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.align | (self) |
Sets the horizontal alignment of the text content within hover
label box. Has an effect only if the hover label text spans
more two or more lines
The 'align' property is an enumeration that may be specified as:
- One of the following enumeration values:
['left', 'right', 'auto']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
|
Sets the horizontal alignment of the text content within hover
label box. Has an effect only if the hover label text spans
more two or more lines
The 'align' property is an enumeration that may be specified as:
- One of the following enumeration values:
['left', 'right', 'auto']
- A tuple, list, or one-dimensional numpy array of the above | def align(self):
"""
Sets the horizontal alignment of the text content within hover
label box. Has an effect only if the hover label text spans
more two or more lines
The 'align' property is an enumeration that may be specified as:
- One of the following enumeration values:
['left', 'right', 'auto']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
"""
return self["align"] | [
"def",
"align",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"align\"",
"]"
] | [
25,
4
] | [
40,
28
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.alignsrc | (self) |
Sets the source reference on Chart Studio Cloud for align .
The 'alignsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for align .
The 'alignsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def alignsrc(self):
"""
Sets the source reference on Chart Studio Cloud for align .
The 'alignsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["alignsrc"] | [
"def",
"alignsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"alignsrc\"",
"]"
] | [
49,
4
] | [
60,
31
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bgcolor | (self) |
Sets the background color of the hover labels for this trace
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
|
Sets the background color of the hover labels for this trace
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above | def bgcolor(self):
"""
Sets the background color of the hover labels for this trace
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["bgcolor"] | [
"def",
"bgcolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bgcolor\"",
"]"
] | [
69,
4
] | [
120,
30
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bgcolorsrc | (self) |
Sets the source reference on Chart Studio Cloud for bgcolor .
The 'bgcolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for bgcolor .
The 'bgcolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def bgcolorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for bgcolor .
The 'bgcolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["bgcolorsrc"] | [
"def",
"bgcolorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bgcolorsrc\"",
"]"
] | [
129,
4
] | [
140,
33
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bordercolor | (self) |
Sets the border color of the hover labels for this trace.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
|
Sets the border color of the hover labels for this trace.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above | def bordercolor(self):
"""
Sets the border color of the hover labels for this trace.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["bordercolor"] | [
"def",
"bordercolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bordercolor\"",
"]"
] | [
149,
4
] | [
200,
34
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bordercolorsrc | (self) |
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def bordercolorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["bordercolorsrc"] | [
"def",
"bordercolorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bordercolorsrc\"",
"]"
] | [
209,
4
] | [
221,
37
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.font | (self) |
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.box.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size .
Returns
-------
plotly.graph_objs.box.hoverlabel.Font
|
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.box.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size . | def font(self):
"""
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.box.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size .
Returns
-------
plotly.graph_objs.box.hoverlabel.Font
"""
return self["font"] | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
230,
4
] | [
277,
27
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.namelength | (self) |
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|numpy.ndarray
|
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above | def namelength(self):
"""
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|numpy.ndarray
"""
return self["namelength"] | [
"def",
"namelength",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"namelength\"",
"]"
] | [
286,
4
] | [
304,
33
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.namelengthsrc | (self) |
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def namelengthsrc(self):
"""
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["namelengthsrc"] | [
"def",
"namelengthsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"namelengthsrc\"",
"]"
] | [
313,
4
] | [
325,
36
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.__init__ | (
self,
arg=None,
align=None,
alignsrc=None,
bgcolor=None,
bgcolorsrc=None,
bordercolor=None,
bordercolorsrc=None,
font=None,
namelength=None,
namelengthsrc=None,
**kwargs
) |
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.box.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength .
Returns
-------
Hoverlabel
|
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.box.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength . | def __init__(
self,
arg=None,
align=None,
alignsrc=None,
bgcolor=None,
bgcolorsrc=None,
bordercolor=None,
bordercolorsrc=None,
font=None,
namelength=None,
namelengthsrc=None,
**kwargs
):
"""
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.box.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength .
Returns
-------
Hoverlabel
"""
super(Hoverlabel, self).__init__("hoverlabel")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.box.Hoverlabel
constructor must be a dict or
an instance of :class:`plotly.graph_objs.box.Hoverlabel`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("align", None)
_v = align if align is not None else _v
if _v is not None:
self["align"] = _v
_v = arg.pop("alignsrc", None)
_v = alignsrc if alignsrc is not None else _v
if _v is not None:
self["alignsrc"] = _v
_v = arg.pop("bgcolor", None)
_v = bgcolor if bgcolor is not None else _v
if _v is not None:
self["bgcolor"] = _v
_v = arg.pop("bgcolorsrc", None)
_v = bgcolorsrc if bgcolorsrc is not None else _v
if _v is not None:
self["bgcolorsrc"] = _v
_v = arg.pop("bordercolor", None)
_v = bordercolor if bordercolor is not None else _v
if _v is not None:
self["bordercolor"] = _v
_v = arg.pop("bordercolorsrc", None)
_v = bordercolorsrc if bordercolorsrc is not None else _v
if _v is not None:
self["bordercolorsrc"] = _v
_v = arg.pop("font", None)
_v = font if font is not None else _v
if _v is not None:
self["font"] = _v
_v = arg.pop("namelength", None)
_v = namelength if namelength is not None else _v
if _v is not None:
self["namelength"] = _v
_v = arg.pop("namelengthsrc", None)
_v = namelengthsrc if namelengthsrc is not None else _v
if _v is not None:
self["namelengthsrc"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"align",
"=",
"None",
",",
"alignsrc",
"=",
"None",
",",
"bgcolor",
"=",
"None",
",",
"bgcolorsrc",
"=",
"None",
",",
"bordercolor",
"=",
"None",
",",
"bordercolorsrc",
"=",
"None",
",",
"font",
"=",
"None",
",",
"namelength",
"=",
"None",
",",
"namelengthsrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Hoverlabel",
",",
"self",
")",
".",
"__init__",
"(",
"\"hoverlabel\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.box.Hoverlabel \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.box.Hoverlabel`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"align\"",
",",
"None",
")",
"_v",
"=",
"align",
"if",
"align",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"align\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"alignsrc\"",
",",
"None",
")",
"_v",
"=",
"alignsrc",
"if",
"alignsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"alignsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bgcolor\"",
",",
"None",
")",
"_v",
"=",
"bgcolor",
"if",
"bgcolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bgcolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bgcolorsrc\"",
",",
"None",
")",
"_v",
"=",
"bgcolorsrc",
"if",
"bgcolorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bgcolorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bordercolor\"",
",",
"None",
")",
"_v",
"=",
"bordercolor",
"if",
"bordercolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bordercolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bordercolorsrc\"",
",",
"None",
")",
"_v",
"=",
"bordercolorsrc",
"if",
"bordercolorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bordercolorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"font\"",
",",
"None",
")",
"_v",
"=",
"font",
"if",
"font",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"font\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"namelength\"",
",",
"None",
")",
"_v",
"=",
"namelength",
"if",
"namelength",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"namelength\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"namelengthsrc\"",
",",
"None",
")",
"_v",
"=",
"namelengthsrc",
"if",
"namelengthsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"namelengthsrc\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
370,
4
] | [
502,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseRoIHead.with_bbox | (self) | bool: whether the RoI head contains a `bbox_head` | bool: whether the RoI head contains a `bbox_head` | def with_bbox(self):
"""bool: whether the RoI head contains a `bbox_head`"""
return hasattr(self, 'bbox_head') and self.bbox_head is not None | [
"def",
"with_bbox",
"(",
"self",
")",
":",
"return",
"hasattr",
"(",
"self",
",",
"'bbox_head'",
")",
"and",
"self",
".",
"bbox_head",
"is",
"not",
"None"
] | [
33,
4
] | [
35,
72
] | python | en | ['en', 'gd', 'en'] | True |
BaseRoIHead.with_mask | (self) | bool: whether the RoI head contains a `mask_head` | bool: whether the RoI head contains a `mask_head` | def with_mask(self):
"""bool: whether the RoI head contains a `mask_head`"""
return hasattr(self, 'mask_head') and self.mask_head is not None | [
"def",
"with_mask",
"(",
"self",
")",
":",
"return",
"hasattr",
"(",
"self",
",",
"'mask_head'",
")",
"and",
"self",
".",
"mask_head",
"is",
"not",
"None"
] | [
38,
4
] | [
40,
72
] | python | en | ['en', 'en', 'en'] | True |
BaseRoIHead.with_shared_head | (self) | bool: whether the RoI head contains a `shared_head` | bool: whether the RoI head contains a `shared_head` | def with_shared_head(self):
"""bool: whether the RoI head contains a `shared_head`"""
return hasattr(self, 'shared_head') and self.shared_head is not None | [
"def",
"with_shared_head",
"(",
"self",
")",
":",
"return",
"hasattr",
"(",
"self",
",",
"'shared_head'",
")",
"and",
"self",
".",
"shared_head",
"is",
"not",
"None"
] | [
43,
4
] | [
45,
76
] | python | en | ['en', 'gd', 'en'] | True |
BaseRoIHead.init_weights | (self, pretrained) | Initialize the weights in head.
Args:
pretrained (str, optional): Path to pre-trained weights.
Defaults to None.
| Initialize the weights in head. | def init_weights(self, pretrained):
"""Initialize the weights in head.
Args:
pretrained (str, optional): Path to pre-trained weights.
Defaults to None.
"""
pass | [
"def",
"init_weights",
"(",
"self",
",",
"pretrained",
")",
":",
"pass"
] | [
48,
4
] | [
55,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseRoIHead.init_bbox_head | (self) | Initialize ``bbox_head`` | Initialize ``bbox_head`` | def init_bbox_head(self):
"""Initialize ``bbox_head``"""
pass | [
"def",
"init_bbox_head",
"(",
"self",
")",
":",
"pass"
] | [
58,
4
] | [
60,
12
] | python | en | ['en', 'pl', 'it'] | False |
BaseRoIHead.init_mask_head | (self) | Initialize ``mask_head`` | Initialize ``mask_head`` | def init_mask_head(self):
"""Initialize ``mask_head``"""
pass | [
"def",
"init_mask_head",
"(",
"self",
")",
":",
"pass"
] | [
63,
4
] | [
65,
12
] | python | en | ['en', 'en', 'it'] | False |
BaseRoIHead.init_assigner_sampler | (self) | Initialize assigner and sampler. | Initialize assigner and sampler. | def init_assigner_sampler(self):
"""Initialize assigner and sampler."""
pass | [
"def",
"init_assigner_sampler",
"(",
"self",
")",
":",
"pass"
] | [
68,
4
] | [
70,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseRoIHead.forward_train | (self,
x,
img_meta,
proposal_list,
gt_bboxes,
gt_labels,
gt_bboxes_ignore=None,
gt_masks=None,
**kwargs) | Forward function during training. | Forward function during training. | def forward_train(self,
x,
img_meta,
proposal_list,
gt_bboxes,
gt_labels,
gt_bboxes_ignore=None,
gt_masks=None,
**kwargs):
"""Forward function during training."""
pass | [
"def",
"forward_train",
"(",
"self",
",",
"x",
",",
"img_meta",
",",
"proposal_list",
",",
"gt_bboxes",
",",
"gt_labels",
",",
"gt_bboxes_ignore",
"=",
"None",
",",
"gt_masks",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
73,
4
] | [
83,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseRoIHead.async_simple_test | (self, x, img_meta, **kwargs) | Asynchronized test function. | Asynchronized test function. | async def async_simple_test(self, x, img_meta, **kwargs):
"""Asynchronized test function."""
raise NotImplementedError | [
"async",
"def",
"async_simple_test",
"(",
"self",
",",
"x",
",",
"img_meta",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
85,
4
] | [
87,
33
] | python | en | ['en', 'cy', 'en'] | True |
BaseRoIHead.simple_test | (self,
x,
proposal_list,
img_meta,
proposals=None,
rescale=False,
**kwargs) | Test without augmentation. | Test without augmentation. | def simple_test(self,
x,
proposal_list,
img_meta,
proposals=None,
rescale=False,
**kwargs):
"""Test without augmentation."""
pass | [
"def",
"simple_test",
"(",
"self",
",",
"x",
",",
"proposal_list",
",",
"img_meta",
",",
"proposals",
"=",
"None",
",",
"rescale",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
89,
4
] | [
97,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseRoIHead.aug_test | (self, x, proposal_list, img_metas, rescale=False, **kwargs) | Test with augmentations.
If rescale is False, then returned bboxes and masks will fit the scale
of imgs[0].
| Test with augmentations. | def aug_test(self, x, proposal_list, img_metas, rescale=False, **kwargs):
"""Test with augmentations.
If rescale is False, then returned bboxes and masks will fit the scale
of imgs[0].
"""
pass | [
"def",
"aug_test",
"(",
"self",
",",
"x",
",",
"proposal_list",
",",
"img_metas",
",",
"rescale",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
99,
4
] | [
105,
12
] | python | en | ['en', 'en', 'en'] | True |
setup | (bot) |
Mandatory function to add the Cog to the bot.
|
Mandatory function to add the Cog to the bot.
| def setup(bot):
"""
Mandatory function to add the Cog to the bot.
"""
bot.add_cog(ImageManipulationCog(bot)) | [
"def",
"setup",
"(",
"bot",
")",
":",
"bot",
".",
"add_cog",
"(",
"ImageManipulationCog",
"(",
"bot",
")",
")"
] | [
623,
0
] | [
627,
42
] | python | en | ['en', 'error', 'th'] | False |
ImageManipulationCog.stamp_image | (self, ctx, **flags) |
Stamps an image with a small image from the available stamps.
Needs to have the to stamp image as an attachment on the invoking message.
Usefull for watermarking images.
Get all available stamps with '@AntiPetros available_stamps'
Example:
@AntiPetros stamp_image -si ASLOGO -fp bottom -sp right -so 0.5 -f 0.25
|
Stamps an image with a small image from the available stamps. | async def stamp_image(self, ctx, **flags):
"""
Stamps an image with a small image from the available stamps.
Needs to have the to stamp image as an attachment on the invoking message.
Usefull for watermarking images.
Get all available stamps with '@AntiPetros available_stamps'
Example:
@AntiPetros stamp_image -si ASLOGO -fp bottom -sp right -so 0.5 -f 0.25
"""
async with ctx.channel.typing():
if len(ctx.message.attachments) == 0:
# TODO: make as embed
await ctx.send('! **there is NO image to antistasify** !')
return
if flags.get('stamp_image') not in self.stamps:
# TODO: make as embed
await ctx.send("! **There is NO stamp with that name** !")
return
first_pos = self.stamp_positions.get(flags.get("first_pos").casefold(), None)
second_pos = self.stamp_positions.get(flags.get("second_pos").casefold(), None)
if any(_pos is None for _pos in [first_pos, second_pos]) or first_pos | second_pos not in self.stamp_pos_functions:
# TODO: make as embed
await ctx.send("! **Those are NOT valid position combinations** !")
return
for _file in ctx.message.attachments:
# TODO: maybe make extra attribute for input format, check what is possible and working. else make a generic format list
if any(_file.filename.endswith(allowed_ext) for allowed_ext in self.allowed_stamp_formats):
_stamp = self._get_stamp_image(flags.get('stamp_image'), flags.get('stamp_opacity'))
_stamp = _stamp.copy()
with TemporaryDirectory(prefix='temp') as temp_dir:
temp_file = Path(pathmaker(temp_dir, 'temp_file.png'))
log.debug("Tempfile '%s' created", temp_file)
await _file.save(temp_file)
in_image = await asyncio.to_thread(Image.open, temp_file)
in_image = await asyncio.to_thread(in_image.copy)
factor = self.target_stamp_fraction if flags.get('factor') is None else flags.get('factor')
pos_function = self.stamp_pos_functions.get(first_pos | second_pos)
in_image = await asyncio.to_thread(pos_function, in_image, _stamp, factor)
name = 'antistasified_' + os.path.splitext(_file.filename)[0]
await ctx.message.delete()
# TODO: make as embed
await self._send_image(ctx, in_image, name, f"__**{name}**__") | [
"async",
"def",
"stamp_image",
"(",
"self",
",",
"ctx",
",",
"*",
"*",
"flags",
")",
":",
"async",
"with",
"ctx",
".",
"channel",
".",
"typing",
"(",
")",
":",
"if",
"len",
"(",
"ctx",
".",
"message",
".",
"attachments",
")",
"==",
"0",
":",
"# TODO: make as embed",
"await",
"ctx",
".",
"send",
"(",
"'! **there is NO image to antistasify** !'",
")",
"return",
"if",
"flags",
".",
"get",
"(",
"'stamp_image'",
")",
"not",
"in",
"self",
".",
"stamps",
":",
"# TODO: make as embed",
"await",
"ctx",
".",
"send",
"(",
"\"! **There is NO stamp with that name** !\"",
")",
"return",
"first_pos",
"=",
"self",
".",
"stamp_positions",
".",
"get",
"(",
"flags",
".",
"get",
"(",
"\"first_pos\"",
")",
".",
"casefold",
"(",
")",
",",
"None",
")",
"second_pos",
"=",
"self",
".",
"stamp_positions",
".",
"get",
"(",
"flags",
".",
"get",
"(",
"\"second_pos\"",
")",
".",
"casefold",
"(",
")",
",",
"None",
")",
"if",
"any",
"(",
"_pos",
"is",
"None",
"for",
"_pos",
"in",
"[",
"first_pos",
",",
"second_pos",
"]",
")",
"or",
"first_pos",
"|",
"second_pos",
"not",
"in",
"self",
".",
"stamp_pos_functions",
":",
"# TODO: make as embed",
"await",
"ctx",
".",
"send",
"(",
"\"! **Those are NOT valid position combinations** !\"",
")",
"return",
"for",
"_file",
"in",
"ctx",
".",
"message",
".",
"attachments",
":",
"# TODO: maybe make extra attribute for input format, check what is possible and working. else make a generic format list",
"if",
"any",
"(",
"_file",
".",
"filename",
".",
"endswith",
"(",
"allowed_ext",
")",
"for",
"allowed_ext",
"in",
"self",
".",
"allowed_stamp_formats",
")",
":",
"_stamp",
"=",
"self",
".",
"_get_stamp_image",
"(",
"flags",
".",
"get",
"(",
"'stamp_image'",
")",
",",
"flags",
".",
"get",
"(",
"'stamp_opacity'",
")",
")",
"_stamp",
"=",
"_stamp",
".",
"copy",
"(",
")",
"with",
"TemporaryDirectory",
"(",
"prefix",
"=",
"'temp'",
")",
"as",
"temp_dir",
":",
"temp_file",
"=",
"Path",
"(",
"pathmaker",
"(",
"temp_dir",
",",
"'temp_file.png'",
")",
")",
"log",
".",
"debug",
"(",
"\"Tempfile '%s' created\"",
",",
"temp_file",
")",
"await",
"_file",
".",
"save",
"(",
"temp_file",
")",
"in_image",
"=",
"await",
"asyncio",
".",
"to_thread",
"(",
"Image",
".",
"open",
",",
"temp_file",
")",
"in_image",
"=",
"await",
"asyncio",
".",
"to_thread",
"(",
"in_image",
".",
"copy",
")",
"factor",
"=",
"self",
".",
"target_stamp_fraction",
"if",
"flags",
".",
"get",
"(",
"'factor'",
")",
"is",
"None",
"else",
"flags",
".",
"get",
"(",
"'factor'",
")",
"pos_function",
"=",
"self",
".",
"stamp_pos_functions",
".",
"get",
"(",
"first_pos",
"|",
"second_pos",
")",
"in_image",
"=",
"await",
"asyncio",
".",
"to_thread",
"(",
"pos_function",
",",
"in_image",
",",
"_stamp",
",",
"factor",
")",
"name",
"=",
"'antistasified_'",
"+",
"os",
".",
"path",
".",
"splitext",
"(",
"_file",
".",
"filename",
")",
"[",
"0",
"]",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")",
"# TODO: make as embed",
"await",
"self",
".",
"_send_image",
"(",
"ctx",
",",
"in_image",
",",
"name",
",",
"f\"__**{name}**__\"",
")"
] | [
194,
4
] | [
243,
82
] | python | en | ['en', 'error', 'th'] | False |
ImageManipulationCog.available_stamps | (self, ctx) |
Posts all available stamps.
Removes them after 2min to keep channel clean.
Example:
@AntiPetros available_stamps
|
Posts all available stamps. | async def available_stamps(self, ctx):
"""
Posts all available stamps.
Removes them after 2min to keep channel clean.
Example:
@AntiPetros available_stamps
"""
await ctx.message.delete()
await ctx.send(embed=await make_basic_embed(title="__**Currently available Stamps are:**__", footer="These messages will be deleted in 120 seconds", symbol='photo'), delete_after=120)
for name, image_path in self.stamps.items():
thumb_image = Image.open(image_path)
thumb_image.thumbnail((128, 128))
with BytesIO() as image_binary:
await asyncio.sleep(0)
thumb_image.save(image_binary, 'PNG', optimize=True)
image_binary.seek(0)
_file = discord.File(image_binary, filename=name + '.png')
embed = discord.Embed(title="Available Stamp")
embed.add_field(name='Stamp Name:', value=name)
embed.set_image(url=f"attachment://{name}.png")
await ctx.send(embed=embed, file=_file, delete_after=120) | [
"async",
"def",
"available_stamps",
"(",
"self",
",",
"ctx",
")",
":",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")",
"await",
"ctx",
".",
"send",
"(",
"embed",
"=",
"await",
"make_basic_embed",
"(",
"title",
"=",
"\"__**Currently available Stamps are:**__\"",
",",
"footer",
"=",
"\"These messages will be deleted in 120 seconds\"",
",",
"symbol",
"=",
"'photo'",
")",
",",
"delete_after",
"=",
"120",
")",
"for",
"name",
",",
"image_path",
"in",
"self",
".",
"stamps",
".",
"items",
"(",
")",
":",
"thumb_image",
"=",
"Image",
".",
"open",
"(",
"image_path",
")",
"thumb_image",
".",
"thumbnail",
"(",
"(",
"128",
",",
"128",
")",
")",
"with",
"BytesIO",
"(",
")",
"as",
"image_binary",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"0",
")",
"thumb_image",
".",
"save",
"(",
"image_binary",
",",
"'PNG'",
",",
"optimize",
"=",
"True",
")",
"image_binary",
".",
"seek",
"(",
"0",
")",
"_file",
"=",
"discord",
".",
"File",
"(",
"image_binary",
",",
"filename",
"=",
"name",
"+",
"'.png'",
")",
"embed",
"=",
"discord",
".",
"Embed",
"(",
"title",
"=",
"\"Available Stamp\"",
")",
"embed",
".",
"add_field",
"(",
"name",
"=",
"'Stamp Name:'",
",",
"value",
"=",
"name",
")",
"embed",
".",
"set_image",
"(",
"url",
"=",
"f\"attachment://{name}.png\"",
")",
"await",
"ctx",
".",
"send",
"(",
"embed",
"=",
"embed",
",",
"file",
"=",
"_file",
",",
"delete_after",
"=",
"120",
")"
] | [
248,
4
] | [
271,
73
] | python | en | ['en', 'error', 'th'] | False |
ImageManipulationCog.member_avatar | (self, ctx) |
Stamps the avatar of a Member with the Antistasi Crest.
Returns the new stamped avatar as a .PNG image that the Member can save and replace his orginal avatar with.
Example:
@AntiPetros member_avatar
|
Stamps the avatar of a Member with the Antistasi Crest. | async def member_avatar(self, ctx):
"""
Stamps the avatar of a Member with the Antistasi Crest.
Returns the new stamped avatar as a .PNG image that the Member can save and replace his orginal avatar with.
Example:
@AntiPetros member_avatar
""" | [
"async",
"def",
"member_avatar",
"(",
"self",
",",
"ctx",
")",
":"
] | [
274,
4
] | [
282,
11
] | python | en | ['en', 'error', 'th'] | False |
ImageManipulationCog.add_stamp | (self, ctx: commands.Context) |
Adds a new stamp image to the available stamps.
This command needs to have the image as an attachment.
Example:
@AntiPetros add_stamp
|
Adds a new stamp image to the available stamps. | async def add_stamp(self, ctx: commands.Context):
"""
Adds a new stamp image to the available stamps.
This command needs to have the image as an attachment.
Example:
@AntiPetros add_stamp
"""
attachment = ctx.message.attachments[0]
file_name = attachment.filename
if file_name.casefold() in {file.casefold() for file in os.listdir(self.stamp_location)}:
await ctx.reply(f"A Stamp file with the name `{file_name}` already exists, aborting!")
return
path = pathmaker(self.stamp_location, file_name)
await attachment.save(path)
stamp_name = file_name.split('.')[0].replace(' ', '_').strip().upper()
await ctx.reply(f"successfully, saved new stamp. The stamp name to use is `{stamp_name}`")
await self.bot.creator.send(f"New stamp was added by `{ctx.author.name}`", file=await attachment.to_file())
self._get_stamps() | [
"async",
"def",
"add_stamp",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
")",
":",
"attachment",
"=",
"ctx",
".",
"message",
".",
"attachments",
"[",
"0",
"]",
"file_name",
"=",
"attachment",
".",
"filename",
"if",
"file_name",
".",
"casefold",
"(",
")",
"in",
"{",
"file",
".",
"casefold",
"(",
")",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"stamp_location",
")",
"}",
":",
"await",
"ctx",
".",
"reply",
"(",
"f\"A Stamp file with the name `{file_name}` already exists, aborting!\"",
")",
"return",
"path",
"=",
"pathmaker",
"(",
"self",
".",
"stamp_location",
",",
"file_name",
")",
"await",
"attachment",
".",
"save",
"(",
"path",
")",
"stamp_name",
"=",
"file_name",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
".",
"replace",
"(",
"' '",
",",
"'_'",
")",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"await",
"ctx",
".",
"reply",
"(",
"f\"successfully, saved new stamp. The stamp name to use is `{stamp_name}`\"",
")",
"await",
"self",
".",
"bot",
".",
"creator",
".",
"send",
"(",
"f\"New stamp was added by `{ctx.author.name}`\"",
",",
"file",
"=",
"await",
"attachment",
".",
"to_file",
"(",
")",
")",
"self",
".",
"_get_stamps",
"(",
")"
] | [
338,
4
] | [
357,
26
] | python | en | ['en', 'error', 'th'] | False |
mat_to_bcsm | (basename, write_rhs=True) | Write UF sparse collection .mat file to internal format.
NB: We probably ought to just hook up a Python front-end to the solver.
| Write UF sparse collection .mat file to internal format. | def mat_to_bcsm(basename, write_rhs=True):
"""Write UF sparse collection .mat file to internal format.
NB: We probably ought to just hook up a Python front-end to the solver.
"""
m = sio.loadmat('{0}.mat'.format(basename))
problem = m['Problem']
A = problem['A'][0,0]
# nnz, m, n are uint64; offsets/indices are int32; data is double
with gzip.open('{0}_system.bcsm.gz'.format(basename), 'wb') as f:
hdr = np.array([A.nnz, A.shape[0], A.shape[1]], dtype=np.uint64)
f.write(hdr.tostring())
f.write(A.indptr.tostring())
f.write(A.indices.tostring())
f.write(A.data.tostring())
if write_rhs:
if 'b' in problem:
b = problem['b'][0,0][:,0]
else:
b = np.ones((A.shape[0],))
with open('{0}_rhs.vector'.format(basename), 'wb') as f:
hdr = np.array([A.shape[0]], dtype=np.int32)
f.write(hdr)
f.write(b) | [
"def",
"mat_to_bcsm",
"(",
"basename",
",",
"write_rhs",
"=",
"True",
")",
":",
"m",
"=",
"sio",
".",
"loadmat",
"(",
"'{0}.mat'",
".",
"format",
"(",
"basename",
")",
")",
"problem",
"=",
"m",
"[",
"'Problem'",
"]",
"A",
"=",
"problem",
"[",
"'A'",
"]",
"[",
"0",
",",
"0",
"]",
"# nnz, m, n are uint64; offsets/indices are int32; data is double",
"with",
"gzip",
".",
"open",
"(",
"'{0}_system.bcsm.gz'",
".",
"format",
"(",
"basename",
")",
",",
"'wb'",
")",
"as",
"f",
":",
"hdr",
"=",
"np",
".",
"array",
"(",
"[",
"A",
".",
"nnz",
",",
"A",
".",
"shape",
"[",
"0",
"]",
",",
"A",
".",
"shape",
"[",
"1",
"]",
"]",
",",
"dtype",
"=",
"np",
".",
"uint64",
")",
"f",
".",
"write",
"(",
"hdr",
".",
"tostring",
"(",
")",
")",
"f",
".",
"write",
"(",
"A",
".",
"indptr",
".",
"tostring",
"(",
")",
")",
"f",
".",
"write",
"(",
"A",
".",
"indices",
".",
"tostring",
"(",
")",
")",
"f",
".",
"write",
"(",
"A",
".",
"data",
".",
"tostring",
"(",
")",
")",
"if",
"write_rhs",
":",
"if",
"'b'",
"in",
"problem",
":",
"b",
"=",
"problem",
"[",
"'b'",
"]",
"[",
"0",
",",
"0",
"]",
"[",
":",
",",
"0",
"]",
"else",
":",
"b",
"=",
"np",
".",
"ones",
"(",
"(",
"A",
".",
"shape",
"[",
"0",
"]",
",",
")",
")",
"with",
"open",
"(",
"'{0}_rhs.vector'",
".",
"format",
"(",
"basename",
")",
",",
"'wb'",
")",
"as",
"f",
":",
"hdr",
"=",
"np",
".",
"array",
"(",
"[",
"A",
".",
"shape",
"[",
"0",
"]",
"]",
",",
"dtype",
"=",
"np",
".",
"int32",
")",
"f",
".",
"write",
"(",
"hdr",
")",
"f",
".",
"write",
"(",
"b",
")"
] | [
14,
0
] | [
40,
22
] | python | en | ['en', 'en', 'en'] | True |
SetEnvVar | (env_var, value) | Sets the env variable to 'value'; unsets it when 'value' is None. | Sets the env variable to 'value'; unsets it when 'value' is None. | def SetEnvVar(env_var, value):
"""Sets the env variable to 'value'; unsets it when 'value' is None."""
if value is not None:
environ[env_var] = value
elif env_var in environ:
del environ[env_var] | [
"def",
"SetEnvVar",
"(",
"env_var",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"environ",
"[",
"env_var",
"]",
"=",
"value",
"elif",
"env_var",
"in",
"environ",
":",
"del",
"environ",
"[",
"env_var",
"]"
] | [
171,
0
] | [
177,
24
] | python | en | ['en', 'en', 'en'] | True |
RunAndReturnOutput | (args = None) | Runs the test program and returns its output. | Runs the test program and returns its output. | def RunAndReturnOutput(args = None):
"""Runs the test program and returns its output."""
return gtest_test_utils.Subprocess([COMMAND] + (args or []),
env=environ).output | [
"def",
"RunAndReturnOutput",
"(",
"args",
"=",
"None",
")",
":",
"return",
"gtest_test_utils",
".",
"Subprocess",
"(",
"[",
"COMMAND",
"]",
"+",
"(",
"args",
"or",
"[",
"]",
")",
",",
"env",
"=",
"environ",
")",
".",
"output"
] | [
180,
0
] | [
184,
56
] | python | en | ['en', 'en', 'en'] | True |
RunAndExtractTestList | (args = None) | Runs the test program and returns its exit code and a list of tests run. | Runs the test program and returns its exit code and a list of tests run. | def RunAndExtractTestList(args = None):
"""Runs the test program and returns its exit code and a list of tests run."""
p = gtest_test_utils.Subprocess([COMMAND] + (args or []), env=environ)
tests_run = []
test_case = ''
test = ''
for line in p.output.split('\n'):
match = TEST_CASE_REGEX.match(line)
if match is not None:
test_case = match.group(1)
else:
match = TEST_REGEX.match(line)
if match is not None:
test = match.group(1)
tests_run.append(test_case + '.' + test)
return (tests_run, p.exit_code) | [
"def",
"RunAndExtractTestList",
"(",
"args",
"=",
"None",
")",
":",
"p",
"=",
"gtest_test_utils",
".",
"Subprocess",
"(",
"[",
"COMMAND",
"]",
"+",
"(",
"args",
"or",
"[",
"]",
")",
",",
"env",
"=",
"environ",
")",
"tests_run",
"=",
"[",
"]",
"test_case",
"=",
"''",
"test",
"=",
"''",
"for",
"line",
"in",
"p",
".",
"output",
".",
"split",
"(",
"'\\n'",
")",
":",
"match",
"=",
"TEST_CASE_REGEX",
".",
"match",
"(",
"line",
")",
"if",
"match",
"is",
"not",
"None",
":",
"test_case",
"=",
"match",
".",
"group",
"(",
"1",
")",
"else",
":",
"match",
"=",
"TEST_REGEX",
".",
"match",
"(",
"line",
")",
"if",
"match",
"is",
"not",
"None",
":",
"test",
"=",
"match",
".",
"group",
"(",
"1",
")",
"tests_run",
".",
"append",
"(",
"test_case",
"+",
"'.'",
"+",
"test",
")",
"return",
"(",
"tests_run",
",",
"p",
".",
"exit_code",
")"
] | [
187,
0
] | [
203,
33
] | python | en | ['en', 'en', 'en'] | True |
InvokeWithModifiedEnv | (extra_env, function, *args, **kwargs) | Runs the given function and arguments in a modified environment. | Runs the given function and arguments in a modified environment. | def InvokeWithModifiedEnv(extra_env, function, *args, **kwargs):
"""Runs the given function and arguments in a modified environment."""
try:
original_env = environ.copy()
environ.update(extra_env)
return function(*args, **kwargs)
finally:
environ.clear()
environ.update(original_env) | [
"def",
"InvokeWithModifiedEnv",
"(",
"extra_env",
",",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"original_env",
"=",
"environ",
".",
"copy",
"(",
")",
"environ",
".",
"update",
"(",
"extra_env",
")",
"return",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"finally",
":",
"environ",
".",
"clear",
"(",
")",
"environ",
".",
"update",
"(",
"original_env",
")"
] | [
206,
0
] | [
214,
32
] | python | en | ['en', 'en', 'en'] | True |
RunWithSharding | (total_shards, shard_index, command) | Runs a test program shard and returns exit code and a list of tests run. | Runs a test program shard and returns exit code and a list of tests run. | def RunWithSharding(total_shards, shard_index, command):
"""Runs a test program shard and returns exit code and a list of tests run."""
extra_env = {SHARD_INDEX_ENV_VAR: str(shard_index),
TOTAL_SHARDS_ENV_VAR: str(total_shards)}
return InvokeWithModifiedEnv(extra_env, RunAndExtractTestList, command) | [
"def",
"RunWithSharding",
"(",
"total_shards",
",",
"shard_index",
",",
"command",
")",
":",
"extra_env",
"=",
"{",
"SHARD_INDEX_ENV_VAR",
":",
"str",
"(",
"shard_index",
")",
",",
"TOTAL_SHARDS_ENV_VAR",
":",
"str",
"(",
"total_shards",
")",
"}",
"return",
"InvokeWithModifiedEnv",
"(",
"extra_env",
",",
"RunAndExtractTestList",
",",
"command",
")"
] | [
217,
0
] | [
222,
73
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.AssertSetEqual | (self, lhs, rhs) | Asserts that two sets are equal. | Asserts that two sets are equal. | def AssertSetEqual(self, lhs, rhs):
"""Asserts that two sets are equal."""
for elem in lhs:
self.assert_(elem in rhs, '%s in %s' % (elem, rhs))
for elem in rhs:
self.assert_(elem in lhs, '%s in %s' % (elem, lhs)) | [
"def",
"AssertSetEqual",
"(",
"self",
",",
"lhs",
",",
"rhs",
")",
":",
"for",
"elem",
"in",
"lhs",
":",
"self",
".",
"assert_",
"(",
"elem",
"in",
"rhs",
",",
"'%s in %s'",
"%",
"(",
"elem",
",",
"rhs",
")",
")",
"for",
"elem",
"in",
"rhs",
":",
"self",
".",
"assert_",
"(",
"elem",
"in",
"lhs",
",",
"'%s in %s'",
"%",
"(",
"elem",
",",
"lhs",
")",
")"
] | [
232,
2
] | [
239,
57
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.AssertPartitionIsValid | (self, set_var, list_of_sets) | Asserts that list_of_sets is a valid partition of set_var. | Asserts that list_of_sets is a valid partition of set_var. | def AssertPartitionIsValid(self, set_var, list_of_sets):
"""Asserts that list_of_sets is a valid partition of set_var."""
full_partition = []
for slice_var in list_of_sets:
full_partition.extend(slice_var)
self.assertEqual(len(set_var), len(full_partition))
self.assertEqual(set(set_var), set(full_partition)) | [
"def",
"AssertPartitionIsValid",
"(",
"self",
",",
"set_var",
",",
"list_of_sets",
")",
":",
"full_partition",
"=",
"[",
"]",
"for",
"slice_var",
"in",
"list_of_sets",
":",
"full_partition",
".",
"extend",
"(",
"slice_var",
")",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"set_var",
")",
",",
"len",
"(",
"full_partition",
")",
")",
"self",
".",
"assertEqual",
"(",
"set",
"(",
"set_var",
")",
",",
"set",
"(",
"full_partition",
")",
")"
] | [
241,
2
] | [
248,
55
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.AdjustForParameterizedTests | (self, tests_to_run) | Adjust tests_to_run in case value parameterized tests are disabled. | Adjust tests_to_run in case value parameterized tests are disabled. | def AdjustForParameterizedTests(self, tests_to_run):
"""Adjust tests_to_run in case value parameterized tests are disabled."""
global param_tests_present
if not param_tests_present:
return list(set(tests_to_run) - set(PARAM_TESTS))
else:
return tests_to_run | [
"def",
"AdjustForParameterizedTests",
"(",
"self",
",",
"tests_to_run",
")",
":",
"global",
"param_tests_present",
"if",
"not",
"param_tests_present",
":",
"return",
"list",
"(",
"set",
"(",
"tests_to_run",
")",
"-",
"set",
"(",
"PARAM_TESTS",
")",
")",
"else",
":",
"return",
"tests_to_run"
] | [
250,
2
] | [
257,
25
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.RunAndVerify | (self, gtest_filter, tests_to_run) | Checks that the binary runs correct set of tests for a given filter. | Checks that the binary runs correct set of tests for a given filter. | def RunAndVerify(self, gtest_filter, tests_to_run):
"""Checks that the binary runs correct set of tests for a given filter."""
tests_to_run = self.AdjustForParameterizedTests(tests_to_run)
# First, tests using the environment variable.
# Windows removes empty variables from the environment when passing it
# to a new process. This means it is impossible to pass an empty filter
# into a process using the environment variable. However, we can still
# test the case when the variable is not supplied (i.e., gtest_filter is
# None).
# pylint: disable-msg=C6403
if CAN_TEST_EMPTY_FILTER or gtest_filter != '':
SetEnvVar(FILTER_ENV_VAR, gtest_filter)
tests_run = RunAndExtractTestList()[0]
SetEnvVar(FILTER_ENV_VAR, None)
self.AssertSetEqual(tests_run, tests_to_run)
# pylint: enable-msg=C6403
# Next, tests using the command line flag.
if gtest_filter is None:
args = []
else:
args = ['--%s=%s' % (FILTER_FLAG, gtest_filter)]
tests_run = RunAndExtractTestList(args)[0]
self.AssertSetEqual(tests_run, tests_to_run) | [
"def",
"RunAndVerify",
"(",
"self",
",",
"gtest_filter",
",",
"tests_to_run",
")",
":",
"tests_to_run",
"=",
"self",
".",
"AdjustForParameterizedTests",
"(",
"tests_to_run",
")",
"# First, tests using the environment variable.",
"# Windows removes empty variables from the environment when passing it",
"# to a new process. This means it is impossible to pass an empty filter",
"# into a process using the environment variable. However, we can still",
"# test the case when the variable is not supplied (i.e., gtest_filter is",
"# None).",
"# pylint: disable-msg=C6403",
"if",
"CAN_TEST_EMPTY_FILTER",
"or",
"gtest_filter",
"!=",
"''",
":",
"SetEnvVar",
"(",
"FILTER_ENV_VAR",
",",
"gtest_filter",
")",
"tests_run",
"=",
"RunAndExtractTestList",
"(",
")",
"[",
"0",
"]",
"SetEnvVar",
"(",
"FILTER_ENV_VAR",
",",
"None",
")",
"self",
".",
"AssertSetEqual",
"(",
"tests_run",
",",
"tests_to_run",
")",
"# pylint: enable-msg=C6403",
"# Next, tests using the command line flag.",
"if",
"gtest_filter",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"else",
":",
"args",
"=",
"[",
"'--%s=%s'",
"%",
"(",
"FILTER_FLAG",
",",
"gtest_filter",
")",
"]",
"tests_run",
"=",
"RunAndExtractTestList",
"(",
"args",
")",
"[",
"0",
"]",
"self",
".",
"AssertSetEqual",
"(",
"tests_run",
",",
"tests_to_run",
")"
] | [
259,
2
] | [
287,
48
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.RunAndVerifyWithSharding | (self, gtest_filter, total_shards, tests_to_run,
args=None, check_exit_0=False) | Checks that binary runs correct tests for the given filter and shard.
Runs all shards of gtest_filter_unittest_ with the given filter, and
verifies that the right set of tests were run. The union of tests run
on each shard should be identical to tests_to_run, without duplicates.
Args:
gtest_filter: A filter to apply to the tests.
total_shards: A total number of shards to split test run into.
tests_to_run: A set of tests expected to run.
args : Arguments to pass to the to the test binary.
check_exit_0: When set to a true value, make sure that all shards
return 0.
| Checks that binary runs correct tests for the given filter and shard. | def RunAndVerifyWithSharding(self, gtest_filter, total_shards, tests_to_run,
args=None, check_exit_0=False):
"""Checks that binary runs correct tests for the given filter and shard.
Runs all shards of gtest_filter_unittest_ with the given filter, and
verifies that the right set of tests were run. The union of tests run
on each shard should be identical to tests_to_run, without duplicates.
Args:
gtest_filter: A filter to apply to the tests.
total_shards: A total number of shards to split test run into.
tests_to_run: A set of tests expected to run.
args : Arguments to pass to the to the test binary.
check_exit_0: When set to a true value, make sure that all shards
return 0.
"""
tests_to_run = self.AdjustForParameterizedTests(tests_to_run)
# Windows removes empty variables from the environment when passing it
# to a new process. This means it is impossible to pass an empty filter
# into a process using the environment variable. However, we can still
# test the case when the variable is not supplied (i.e., gtest_filter is
# None).
# pylint: disable-msg=C6403
if CAN_TEST_EMPTY_FILTER or gtest_filter != '':
SetEnvVar(FILTER_ENV_VAR, gtest_filter)
partition = []
for i in range(0, total_shards):
(tests_run, exit_code) = RunWithSharding(total_shards, i, args)
if check_exit_0:
self.assertEqual(0, exit_code)
partition.append(tests_run)
self.AssertPartitionIsValid(tests_to_run, partition)
SetEnvVar(FILTER_ENV_VAR, None) | [
"def",
"RunAndVerifyWithSharding",
"(",
"self",
",",
"gtest_filter",
",",
"total_shards",
",",
"tests_to_run",
",",
"args",
"=",
"None",
",",
"check_exit_0",
"=",
"False",
")",
":",
"tests_to_run",
"=",
"self",
".",
"AdjustForParameterizedTests",
"(",
"tests_to_run",
")",
"# Windows removes empty variables from the environment when passing it",
"# to a new process. This means it is impossible to pass an empty filter",
"# into a process using the environment variable. However, we can still",
"# test the case when the variable is not supplied (i.e., gtest_filter is",
"# None).",
"# pylint: disable-msg=C6403",
"if",
"CAN_TEST_EMPTY_FILTER",
"or",
"gtest_filter",
"!=",
"''",
":",
"SetEnvVar",
"(",
"FILTER_ENV_VAR",
",",
"gtest_filter",
")",
"partition",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"total_shards",
")",
":",
"(",
"tests_run",
",",
"exit_code",
")",
"=",
"RunWithSharding",
"(",
"total_shards",
",",
"i",
",",
"args",
")",
"if",
"check_exit_0",
":",
"self",
".",
"assertEqual",
"(",
"0",
",",
"exit_code",
")",
"partition",
".",
"append",
"(",
"tests_run",
")",
"self",
".",
"AssertPartitionIsValid",
"(",
"tests_to_run",
",",
"partition",
")",
"SetEnvVar",
"(",
"FILTER_ENV_VAR",
",",
"None",
")"
] | [
289,
2
] | [
324,
37
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.RunAndVerifyAllowingDisabled | (self, gtest_filter, tests_to_run) | Checks that the binary runs correct set of tests for the given filter.
Runs gtest_filter_unittest_ with the given filter, and enables
disabled tests. Verifies that the right set of tests were run.
Args:
gtest_filter: A filter to apply to the tests.
tests_to_run: A set of tests expected to run.
| Checks that the binary runs correct set of tests for the given filter. | def RunAndVerifyAllowingDisabled(self, gtest_filter, tests_to_run):
"""Checks that the binary runs correct set of tests for the given filter.
Runs gtest_filter_unittest_ with the given filter, and enables
disabled tests. Verifies that the right set of tests were run.
Args:
gtest_filter: A filter to apply to the tests.
tests_to_run: A set of tests expected to run.
"""
tests_to_run = self.AdjustForParameterizedTests(tests_to_run)
# Construct the command line.
args = ['--%s' % ALSO_RUN_DISABED_TESTS_FLAG]
if gtest_filter is not None:
args.append('--%s=%s' % (FILTER_FLAG, gtest_filter))
tests_run = RunAndExtractTestList(args)[0]
self.AssertSetEqual(tests_run, tests_to_run) | [
"def",
"RunAndVerifyAllowingDisabled",
"(",
"self",
",",
"gtest_filter",
",",
"tests_to_run",
")",
":",
"tests_to_run",
"=",
"self",
".",
"AdjustForParameterizedTests",
"(",
"tests_to_run",
")",
"# Construct the command line.",
"args",
"=",
"[",
"'--%s'",
"%",
"ALSO_RUN_DISABED_TESTS_FLAG",
"]",
"if",
"gtest_filter",
"is",
"not",
"None",
":",
"args",
".",
"append",
"(",
"'--%s=%s'",
"%",
"(",
"FILTER_FLAG",
",",
"gtest_filter",
")",
")",
"tests_run",
"=",
"RunAndExtractTestList",
"(",
"args",
")",
"[",
"0",
"]",
"self",
".",
"AssertSetEqual",
"(",
"tests_run",
",",
"tests_to_run",
")"
] | [
327,
2
] | [
346,
48
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.setUp | (self) | Sets up test case.
Determines whether value-parameterized tests are enabled in the binary and
sets the flags accordingly.
| Sets up test case. | def setUp(self):
"""Sets up test case.
Determines whether value-parameterized tests are enabled in the binary and
sets the flags accordingly.
"""
global param_tests_present
if param_tests_present is None:
param_tests_present = PARAM_TEST_REGEX.search(
RunAndReturnOutput()) is not None | [
"def",
"setUp",
"(",
"self",
")",
":",
"global",
"param_tests_present",
"if",
"param_tests_present",
"is",
"None",
":",
"param_tests_present",
"=",
"PARAM_TEST_REGEX",
".",
"search",
"(",
"RunAndReturnOutput",
"(",
")",
")",
"is",
"not",
"None"
] | [
348,
2
] | [
358,
43
] | python | en | ['en', 'da', 'en'] | True |
GTestFilterUnitTest.testDefaultBehavior | (self) | Tests the behavior of not specifying the filter. | Tests the behavior of not specifying the filter. | def testDefaultBehavior(self):
"""Tests the behavior of not specifying the filter."""
self.RunAndVerify(None, ACTIVE_TESTS) | [
"def",
"testDefaultBehavior",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"None",
",",
"ACTIVE_TESTS",
")"
] | [
360,
2
] | [
363,
41
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testDefaultBehaviorWithShards | (self) | Tests the behavior without the filter, with sharding enabled. | Tests the behavior without the filter, with sharding enabled. | def testDefaultBehaviorWithShards(self):
"""Tests the behavior without the filter, with sharding enabled."""
self.RunAndVerifyWithSharding(None, 1, ACTIVE_TESTS)
self.RunAndVerifyWithSharding(None, 2, ACTIVE_TESTS)
self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS) - 1, ACTIVE_TESTS)
self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS), ACTIVE_TESTS)
self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS) + 1, ACTIVE_TESTS) | [
"def",
"testDefaultBehaviorWithShards",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"None",
",",
"1",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"None",
",",
"2",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"None",
",",
"len",
"(",
"ACTIVE_TESTS",
")",
"-",
"1",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"None",
",",
"len",
"(",
"ACTIVE_TESTS",
")",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"None",
",",
"len",
"(",
"ACTIVE_TESTS",
")",
"+",
"1",
",",
"ACTIVE_TESTS",
")"
] | [
365,
2
] | [
372,
76
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testEmptyFilter | (self) | Tests an empty filter. | Tests an empty filter. | def testEmptyFilter(self):
"""Tests an empty filter."""
self.RunAndVerify('', [])
self.RunAndVerifyWithSharding('', 1, [])
self.RunAndVerifyWithSharding('', 2, []) | [
"def",
"testEmptyFilter",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"''",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"''",
",",
"1",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"''",
",",
"2",
",",
"[",
"]",
")"
] | [
374,
2
] | [
379,
44
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testBadFilter | (self) | Tests a filter that matches nothing. | Tests a filter that matches nothing. | def testBadFilter(self):
"""Tests a filter that matches nothing."""
self.RunAndVerify('BadFilter', [])
self.RunAndVerifyAllowingDisabled('BadFilter', []) | [
"def",
"testBadFilter",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'BadFilter'",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'BadFilter'",
",",
"[",
"]",
")"
] | [
381,
2
] | [
385,
54
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testFullName | (self) | Tests filtering by full name. | Tests filtering by full name. | def testFullName(self):
"""Tests filtering by full name."""
self.RunAndVerify('FooTest.Xyz', ['FooTest.Xyz'])
self.RunAndVerifyAllowingDisabled('FooTest.Xyz', ['FooTest.Xyz'])
self.RunAndVerifyWithSharding('FooTest.Xyz', 5, ['FooTest.Xyz']) | [
"def",
"testFullName",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'FooTest.Xyz'",
",",
"[",
"'FooTest.Xyz'",
"]",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'FooTest.Xyz'",
",",
"[",
"'FooTest.Xyz'",
"]",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"'FooTest.Xyz'",
",",
"5",
",",
"[",
"'FooTest.Xyz'",
"]",
")"
] | [
387,
2
] | [
392,
68
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testUniversalFilters | (self) | Tests filters that match everything. | Tests filters that match everything. | def testUniversalFilters(self):
"""Tests filters that match everything."""
self.RunAndVerify('*', ACTIVE_TESTS)
self.RunAndVerify('*.*', ACTIVE_TESTS)
self.RunAndVerifyWithSharding('*.*', len(ACTIVE_TESTS) - 3, ACTIVE_TESTS)
self.RunAndVerifyAllowingDisabled('*', ACTIVE_TESTS + DISABLED_TESTS)
self.RunAndVerifyAllowingDisabled('*.*', ACTIVE_TESTS + DISABLED_TESTS) | [
"def",
"testUniversalFilters",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'*'",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerify",
"(",
"'*.*'",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerifyWithSharding",
"(",
"'*.*'",
",",
"len",
"(",
"ACTIVE_TESTS",
")",
"-",
"3",
",",
"ACTIVE_TESTS",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'*'",
",",
"ACTIVE_TESTS",
"+",
"DISABLED_TESTS",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'*.*'",
",",
"ACTIVE_TESTS",
"+",
"DISABLED_TESTS",
")"
] | [
394,
2
] | [
401,
75
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testFilterByTestCase | (self) | Tests filtering by test case name. | Tests filtering by test case name. | def testFilterByTestCase(self):
"""Tests filtering by test case name."""
self.RunAndVerify('FooTest.*', ['FooTest.Abc', 'FooTest.Xyz'])
BAZ_TESTS = ['BazTest.TestOne', 'BazTest.TestA', 'BazTest.TestB']
self.RunAndVerify('BazTest.*', BAZ_TESTS)
self.RunAndVerifyAllowingDisabled('BazTest.*',
BAZ_TESTS + ['BazTest.DISABLED_TestC']) | [
"def",
"testFilterByTestCase",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'FooTest.*'",
",",
"[",
"'FooTest.Abc'",
",",
"'FooTest.Xyz'",
"]",
")",
"BAZ_TESTS",
"=",
"[",
"'BazTest.TestOne'",
",",
"'BazTest.TestA'",
",",
"'BazTest.TestB'",
"]",
"self",
".",
"RunAndVerify",
"(",
"'BazTest.*'",
",",
"BAZ_TESTS",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'BazTest.*'",
",",
"BAZ_TESTS",
"+",
"[",
"'BazTest.DISABLED_TestC'",
"]",
")"
] | [
403,
2
] | [
411,
77
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testFilterByTest | (self) | Tests filtering by test name. | Tests filtering by test name. | def testFilterByTest(self):
"""Tests filtering by test name."""
self.RunAndVerify('*.TestOne', ['BarTest.TestOne', 'BazTest.TestOne']) | [
"def",
"testFilterByTest",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'*.TestOne'",
",",
"[",
"'BarTest.TestOne'",
",",
"'BazTest.TestOne'",
"]",
")"
] | [
413,
2
] | [
416,
74
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testFilterDisabledTests | (self) | Select only the disabled tests to run. | Select only the disabled tests to run. | def testFilterDisabledTests(self):
"""Select only the disabled tests to run."""
self.RunAndVerify('DISABLED_FoobarTest.Test1', [])
self.RunAndVerifyAllowingDisabled('DISABLED_FoobarTest.Test1',
['DISABLED_FoobarTest.Test1'])
self.RunAndVerify('*DISABLED_*', [])
self.RunAndVerifyAllowingDisabled('*DISABLED_*', DISABLED_TESTS)
self.RunAndVerify('*.DISABLED_*', [])
self.RunAndVerifyAllowingDisabled('*.DISABLED_*', [
'BarTest.DISABLED_TestFour',
'BarTest.DISABLED_TestFive',
'BazTest.DISABLED_TestC',
'DISABLED_FoobarTest.DISABLED_Test2',
])
self.RunAndVerify('DISABLED_*', [])
self.RunAndVerifyAllowingDisabled('DISABLED_*', [
'DISABLED_FoobarTest.Test1',
'DISABLED_FoobarTest.DISABLED_Test2',
'DISABLED_FoobarbazTest.TestA',
]) | [
"def",
"testFilterDisabledTests",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'DISABLED_FoobarTest.Test1'",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'DISABLED_FoobarTest.Test1'",
",",
"[",
"'DISABLED_FoobarTest.Test1'",
"]",
")",
"self",
".",
"RunAndVerify",
"(",
"'*DISABLED_*'",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'*DISABLED_*'",
",",
"DISABLED_TESTS",
")",
"self",
".",
"RunAndVerify",
"(",
"'*.DISABLED_*'",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'*.DISABLED_*'",
",",
"[",
"'BarTest.DISABLED_TestFour'",
",",
"'BarTest.DISABLED_TestFive'",
",",
"'BazTest.DISABLED_TestC'",
",",
"'DISABLED_FoobarTest.DISABLED_Test2'",
",",
"]",
")",
"self",
".",
"RunAndVerify",
"(",
"'DISABLED_*'",
",",
"[",
"]",
")",
"self",
".",
"RunAndVerifyAllowingDisabled",
"(",
"'DISABLED_*'",
",",
"[",
"'DISABLED_FoobarTest.Test1'",
",",
"'DISABLED_FoobarTest.DISABLED_Test2'",
",",
"'DISABLED_FoobarbazTest.TestA'",
",",
"]",
")"
] | [
418,
2
] | [
441,
10
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testWildcardInTestCaseName | (self) | Tests using wildcard in the test case name. | Tests using wildcard in the test case name. | def testWildcardInTestCaseName(self):
"""Tests using wildcard in the test case name."""
self.RunAndVerify('*a*.*', [
'BarTest.TestOne',
'BarTest.TestTwo',
'BarTest.TestThree',
'BazTest.TestOne',
'BazTest.TestA',
'BazTest.TestB', ] + DEATH_TESTS + PARAM_TESTS) | [
"def",
"testWildcardInTestCaseName",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'*a*.*'",
",",
"[",
"'BarTest.TestOne'",
",",
"'BarTest.TestTwo'",
",",
"'BarTest.TestThree'",
",",
"'BazTest.TestOne'",
",",
"'BazTest.TestA'",
",",
"'BazTest.TestB'",
",",
"]",
"+",
"DEATH_TESTS",
"+",
"PARAM_TESTS",
")"
] | [
443,
2
] | [
453,
55
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testWildcardInTestName | (self) | Tests using wildcard in the test name. | Tests using wildcard in the test name. | def testWildcardInTestName(self):
"""Tests using wildcard in the test name."""
self.RunAndVerify('*.*A*', ['FooTest.Abc', 'BazTest.TestA']) | [
"def",
"testWildcardInTestName",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'*.*A*'",
",",
"[",
"'FooTest.Abc'",
",",
"'BazTest.TestA'",
"]",
")"
] | [
455,
2
] | [
458,
64
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testFilterWithoutDot | (self) | Tests a filter that has no '.' in it. | Tests a filter that has no '.' in it. | def testFilterWithoutDot(self):
"""Tests a filter that has no '.' in it."""
self.RunAndVerify('*z*', [
'FooTest.Xyz',
'BazTest.TestOne',
'BazTest.TestA',
'BazTest.TestB',
]) | [
"def",
"testFilterWithoutDot",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'*z*'",
",",
"[",
"'FooTest.Xyz'",
",",
"'BazTest.TestOne'",
",",
"'BazTest.TestA'",
",",
"'BazTest.TestB'",
",",
"]",
")"
] | [
460,
2
] | [
469,
10
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testTwoPatterns | (self) | Tests filters that consist of two patterns. | Tests filters that consist of two patterns. | def testTwoPatterns(self):
"""Tests filters that consist of two patterns."""
self.RunAndVerify('Foo*.*:*A*', [
'FooTest.Abc',
'FooTest.Xyz',
'BazTest.TestA',
])
# An empty pattern + a non-empty one
self.RunAndVerify(':*A*', ['FooTest.Abc', 'BazTest.TestA']) | [
"def",
"testTwoPatterns",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'Foo*.*:*A*'",
",",
"[",
"'FooTest.Abc'",
",",
"'FooTest.Xyz'",
",",
"'BazTest.TestA'",
",",
"]",
")",
"# An empty pattern + a non-empty one",
"self",
".",
"RunAndVerify",
"(",
"':*A*'",
",",
"[",
"'FooTest.Abc'",
",",
"'BazTest.TestA'",
"]",
")"
] | [
471,
2
] | [
482,
63
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testThreePatterns | (self) | Tests filters that consist of three patterns. | Tests filters that consist of three patterns. | def testThreePatterns(self):
"""Tests filters that consist of three patterns."""
self.RunAndVerify('*oo*:*A*:*One', [
'FooTest.Abc',
'FooTest.Xyz',
'BarTest.TestOne',
'BazTest.TestOne',
'BazTest.TestA',
])
# The 2nd pattern is empty.
self.RunAndVerify('*oo*::*One', [
'FooTest.Abc',
'FooTest.Xyz',
'BarTest.TestOne',
'BazTest.TestOne',
])
# The last 2 patterns are empty.
self.RunAndVerify('*oo*::', [
'FooTest.Abc',
'FooTest.Xyz',
]) | [
"def",
"testThreePatterns",
"(",
"self",
")",
":",
"self",
".",
"RunAndVerify",
"(",
"'*oo*:*A*:*One'",
",",
"[",
"'FooTest.Abc'",
",",
"'FooTest.Xyz'",
",",
"'BarTest.TestOne'",
",",
"'BazTest.TestOne'",
",",
"'BazTest.TestA'",
",",
"]",
")",
"# The 2nd pattern is empty.",
"self",
".",
"RunAndVerify",
"(",
"'*oo*::*One'",
",",
"[",
"'FooTest.Abc'",
",",
"'FooTest.Xyz'",
",",
"'BarTest.TestOne'",
",",
"'BazTest.TestOne'",
",",
"]",
")",
"# The last 2 patterns are empty.",
"self",
".",
"RunAndVerify",
"(",
"'*oo*::'",
",",
"[",
"'FooTest.Abc'",
",",
"'FooTest.Xyz'",
",",
"]",
")"
] | [
484,
2
] | [
511,
10
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testFlagOverridesEnvVar | (self) | Tests that the filter flag overrides the filtering env. variable. | Tests that the filter flag overrides the filtering env. variable. | def testFlagOverridesEnvVar(self):
"""Tests that the filter flag overrides the filtering env. variable."""
SetEnvVar(FILTER_ENV_VAR, 'Foo*')
args = ['--%s=%s' % (FILTER_FLAG, '*One')]
tests_run = RunAndExtractTestList(args)[0]
SetEnvVar(FILTER_ENV_VAR, None)
self.AssertSetEqual(tests_run, ['BarTest.TestOne', 'BazTest.TestOne']) | [
"def",
"testFlagOverridesEnvVar",
"(",
"self",
")",
":",
"SetEnvVar",
"(",
"FILTER_ENV_VAR",
",",
"'Foo*'",
")",
"args",
"=",
"[",
"'--%s=%s'",
"%",
"(",
"FILTER_FLAG",
",",
"'*One'",
")",
"]",
"tests_run",
"=",
"RunAndExtractTestList",
"(",
"args",
")",
"[",
"0",
"]",
"SetEnvVar",
"(",
"FILTER_ENV_VAR",
",",
"None",
")",
"self",
".",
"AssertSetEqual",
"(",
"tests_run",
",",
"[",
"'BarTest.TestOne'",
",",
"'BazTest.TestOne'",
"]",
")"
] | [
565,
2
] | [
573,
74
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testShardStatusFileIsCreated | (self) | Tests that the shard file is created if specified in the environment. | Tests that the shard file is created if specified in the environment. | def testShardStatusFileIsCreated(self):
"""Tests that the shard file is created if specified in the environment."""
shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),
'shard_status_file')
self.assert_(not os.path.exists(shard_status_file))
extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}
try:
InvokeWithModifiedEnv(extra_env, RunAndReturnOutput)
finally:
self.assert_(os.path.exists(shard_status_file))
os.remove(shard_status_file) | [
"def",
"testShardStatusFileIsCreated",
"(",
"self",
")",
":",
"shard_status_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"gtest_test_utils",
".",
"GetTempDir",
"(",
")",
",",
"'shard_status_file'",
")",
"self",
".",
"assert_",
"(",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"shard_status_file",
")",
")",
"extra_env",
"=",
"{",
"SHARD_STATUS_FILE_ENV_VAR",
":",
"shard_status_file",
"}",
"try",
":",
"InvokeWithModifiedEnv",
"(",
"extra_env",
",",
"RunAndReturnOutput",
")",
"finally",
":",
"self",
".",
"assert_",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"shard_status_file",
")",
")",
"os",
".",
"remove",
"(",
"shard_status_file",
")"
] | [
575,
2
] | [
587,
34
] | python | en | ['en', 'en', 'en'] | True |
GTestFilterUnitTest.testShardStatusFileIsCreatedWithListTests | (self) | Tests that the shard file is created with the "list_tests" flag. | Tests that the shard file is created with the "list_tests" flag. | def testShardStatusFileIsCreatedWithListTests(self):
"""Tests that the shard file is created with the "list_tests" flag."""
shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),
'shard_status_file2')
self.assert_(not os.path.exists(shard_status_file))
extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}
try:
output = InvokeWithModifiedEnv(extra_env,
RunAndReturnOutput,
[LIST_TESTS_FLAG])
finally:
# This assertion ensures that Google Test enumerated the tests as
# opposed to running them.
self.assert_('[==========]' not in output,
'Unexpected output during test enumeration.\n'
'Please ensure that LIST_TESTS_FLAG is assigned the\n'
'correct flag value for listing Google Test tests.')
self.assert_(os.path.exists(shard_status_file))
os.remove(shard_status_file) | [
"def",
"testShardStatusFileIsCreatedWithListTests",
"(",
"self",
")",
":",
"shard_status_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"gtest_test_utils",
".",
"GetTempDir",
"(",
")",
",",
"'shard_status_file2'",
")",
"self",
".",
"assert_",
"(",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"shard_status_file",
")",
")",
"extra_env",
"=",
"{",
"SHARD_STATUS_FILE_ENV_VAR",
":",
"shard_status_file",
"}",
"try",
":",
"output",
"=",
"InvokeWithModifiedEnv",
"(",
"extra_env",
",",
"RunAndReturnOutput",
",",
"[",
"LIST_TESTS_FLAG",
"]",
")",
"finally",
":",
"# This assertion ensures that Google Test enumerated the tests as",
"# opposed to running them.",
"self",
".",
"assert_",
"(",
"'[==========]'",
"not",
"in",
"output",
",",
"'Unexpected output during test enumeration.\\n'",
"'Please ensure that LIST_TESTS_FLAG is assigned the\\n'",
"'correct flag value for listing Google Test tests.'",
")",
"self",
".",
"assert_",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"shard_status_file",
")",
")",
"os",
".",
"remove",
"(",
"shard_status_file",
")"
] | [
589,
2
] | [
610,
34
] | python | en | ['en', 'en', 'en'] | True |
create_supp | (opt) |
Evaluates a model.
:param opt: tells the evaluation function how to run
:return: the final result of calling report()
|
Evaluates a model. | def create_supp(opt):
"""
Evaluates a model.
:param opt: tells the evaluation function how to run
:return: the final result of calling report()
"""
# Create model and assign it to the specified task
agent = create_agent(opt, requireModelExists=True)
world = create_task(opt, agent)
# Extract supp examples from misses on deploy set
num_seen = 0
num_misses = 0
num_supp = 0
num_supp_correct = 0
examples = []
while not world.epoch_done():
world.parley()
# Examples are considered one at a time
num_seen += 1
if num_seen % 1000 == 0:
print(f"{num_seen}/{world.num_examples()}")
report = world.report()
if report['accuracy'] < 1.0:
# Example is a miss (i.e., model got it wrong)
num_misses += 1
if random.random() < opt['conversion_rate']:
# Example will be converted (e.g., bot recognized mistake and asked)
num_supp += 1
texts = world.acts[0]['text'].split('\n')
context = texts[-1]
memories = texts[:-1]
candidates = world.acts[0]['label_candidates']
# Reward of 1 indicates positive, -1 indicates negative (for training)
# For now, we only train with positives, and the reward field is unused
reward = 1
if random.random() < opt['conversion_acc']:
# Example will be converted correctly (e.g., good user response)
num_supp_correct += 1
response = world.acts[0]['eval_labels'][0]
else:
# Example will be converted incorrectly (e.g., bad user response)
response = random.choice(
world.acts[0]['label_candidates'][: NUM_INLINE_CANDS - 1]
)
example = Parley(context, response, reward, candidates, memories)
examples.append(example)
world.reset_metrics()
print("EPOCH DONE")
print(f"Model file: {opt['model_file']}")
print(f"Deploy file: {opt['task']}")
print(f"Supp file: {opt['outfile']}")
print(f"Deploy size (# examples seen): {num_seen}")
print(f"Supp size (# examples converted): {num_supp}")
acc = 1 - (num_misses / num_seen)
print(f"Accuracy (% of deploy): {acc * 100:.1f}% ({num_misses} misses)")
print(
f"Conversion rate (% of misses): {num_supp/num_misses * 100:.2f}% "
f"({num_supp}/{num_misses})"
)
print(
f"Conversion acc (% of converted): {num_supp_correct/num_supp * 100:.2f}% "
f"({num_supp_correct}/{num_supp})"
)
with PathManager.open(opt['outfile'], 'w') as outfile:
for ex in examples:
outfile.write(json.dumps(ex.to_dict()) + '\n') | [
"def",
"create_supp",
"(",
"opt",
")",
":",
"# Create model and assign it to the specified task",
"agent",
"=",
"create_agent",
"(",
"opt",
",",
"requireModelExists",
"=",
"True",
")",
"world",
"=",
"create_task",
"(",
"opt",
",",
"agent",
")",
"# Extract supp examples from misses on deploy set",
"num_seen",
"=",
"0",
"num_misses",
"=",
"0",
"num_supp",
"=",
"0",
"num_supp_correct",
"=",
"0",
"examples",
"=",
"[",
"]",
"while",
"not",
"world",
".",
"epoch_done",
"(",
")",
":",
"world",
".",
"parley",
"(",
")",
"# Examples are considered one at a time",
"num_seen",
"+=",
"1",
"if",
"num_seen",
"%",
"1000",
"==",
"0",
":",
"print",
"(",
"f\"{num_seen}/{world.num_examples()}\"",
")",
"report",
"=",
"world",
".",
"report",
"(",
")",
"if",
"report",
"[",
"'accuracy'",
"]",
"<",
"1.0",
":",
"# Example is a miss (i.e., model got it wrong)",
"num_misses",
"+=",
"1",
"if",
"random",
".",
"random",
"(",
")",
"<",
"opt",
"[",
"'conversion_rate'",
"]",
":",
"# Example will be converted (e.g., bot recognized mistake and asked)",
"num_supp",
"+=",
"1",
"texts",
"=",
"world",
".",
"acts",
"[",
"0",
"]",
"[",
"'text'",
"]",
".",
"split",
"(",
"'\\n'",
")",
"context",
"=",
"texts",
"[",
"-",
"1",
"]",
"memories",
"=",
"texts",
"[",
":",
"-",
"1",
"]",
"candidates",
"=",
"world",
".",
"acts",
"[",
"0",
"]",
"[",
"'label_candidates'",
"]",
"# Reward of 1 indicates positive, -1 indicates negative (for training)",
"# For now, we only train with positives, and the reward field is unused",
"reward",
"=",
"1",
"if",
"random",
".",
"random",
"(",
")",
"<",
"opt",
"[",
"'conversion_acc'",
"]",
":",
"# Example will be converted correctly (e.g., good user response)",
"num_supp_correct",
"+=",
"1",
"response",
"=",
"world",
".",
"acts",
"[",
"0",
"]",
"[",
"'eval_labels'",
"]",
"[",
"0",
"]",
"else",
":",
"# Example will be converted incorrectly (e.g., bad user response)",
"response",
"=",
"random",
".",
"choice",
"(",
"world",
".",
"acts",
"[",
"0",
"]",
"[",
"'label_candidates'",
"]",
"[",
":",
"NUM_INLINE_CANDS",
"-",
"1",
"]",
")",
"example",
"=",
"Parley",
"(",
"context",
",",
"response",
",",
"reward",
",",
"candidates",
",",
"memories",
")",
"examples",
".",
"append",
"(",
"example",
")",
"world",
".",
"reset_metrics",
"(",
")",
"print",
"(",
"\"EPOCH DONE\"",
")",
"print",
"(",
"f\"Model file: {opt['model_file']}\"",
")",
"print",
"(",
"f\"Deploy file: {opt['task']}\"",
")",
"print",
"(",
"f\"Supp file: {opt['outfile']}\"",
")",
"print",
"(",
"f\"Deploy size (# examples seen): {num_seen}\"",
")",
"print",
"(",
"f\"Supp size (# examples converted): {num_supp}\"",
")",
"acc",
"=",
"1",
"-",
"(",
"num_misses",
"/",
"num_seen",
")",
"print",
"(",
"f\"Accuracy (% of deploy): {acc * 100:.1f}% ({num_misses} misses)\"",
")",
"print",
"(",
"f\"Conversion rate (% of misses): {num_supp/num_misses * 100:.2f}% \"",
"f\"({num_supp}/{num_misses})\"",
")",
"print",
"(",
"f\"Conversion acc (% of converted): {num_supp_correct/num_supp * 100:.2f}% \"",
"f\"({num_supp_correct}/{num_supp})\"",
")",
"with",
"PathManager",
".",
"open",
"(",
"opt",
"[",
"'outfile'",
"]",
",",
"'w'",
")",
"as",
"outfile",
":",
"for",
"ex",
"in",
"examples",
":",
"outfile",
".",
"write",
"(",
"json",
".",
"dumps",
"(",
"ex",
".",
"to_dict",
"(",
")",
")",
"+",
"'\\n'",
")"
] | [
76,
0
] | [
148,
58
] | python | en | ['en', 'error', 'th'] | False |
current | () |
Retrieve information on the logged-in user from Plotly.
:returns: (requests.Response) Returns response directly from requests.
|
Retrieve information on the logged-in user from Plotly. | def current():
"""
Retrieve information on the logged-in user from Plotly.
:returns: (requests.Response) Returns response directly from requests.
"""
url = build_url(RESOURCE, route="current")
return request("get", url) | [
"def",
"current",
"(",
")",
":",
"url",
"=",
"build_url",
"(",
"RESOURCE",
",",
"route",
"=",
"\"current\"",
")",
"return",
"request",
"(",
"\"get\"",
",",
"url",
")"
] | [
8,
0
] | [
16,
30
] | python | en | ['en', 'error', 'th'] | False |
build_voxel_generator | (cfg, **kwargs) | Builder of voxel generator. | Builder of voxel generator. | def build_voxel_generator(cfg, **kwargs):
"""Builder of voxel generator."""
if isinstance(cfg, voxel_generator.VoxelGenerator):
return cfg
elif isinstance(cfg, dict):
return mmcv.runner.obj_from_dict(
cfg, voxel_generator, default_args=kwargs)
else:
raise TypeError('Invalid type {} for building a sampler'.format(
type(cfg))) | [
"def",
"build_voxel_generator",
"(",
"cfg",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"cfg",
",",
"voxel_generator",
".",
"VoxelGenerator",
")",
":",
"return",
"cfg",
"elif",
"isinstance",
"(",
"cfg",
",",
"dict",
")",
":",
"return",
"mmcv",
".",
"runner",
".",
"obj_from_dict",
"(",
"cfg",
",",
"voxel_generator",
",",
"default_args",
"=",
"kwargs",
")",
"else",
":",
"raise",
"TypeError",
"(",
"'Invalid type {} for building a sampler'",
".",
"format",
"(",
"type",
"(",
"cfg",
")",
")",
")"
] | [
5,
0
] | [
14,
23
] | python | en | ['en', 'nl', 'en'] | True |
ToUnixLineEnding | (s) | Changes all Windows/Mac line endings in s to UNIX line endings. | Changes all Windows/Mac line endings in s to UNIX line endings. | def ToUnixLineEnding(s):
"""Changes all Windows/Mac line endings in s to UNIX line endings."""
return s.replace('\r\n', '\n').replace('\r', '\n') | [
"def",
"ToUnixLineEnding",
"(",
"s",
")",
":",
"return",
"s",
".",
"replace",
"(",
"'\\r\\n'",
",",
"'\\n'",
")",
".",
"replace",
"(",
"'\\r'",
",",
"'\\n'",
")"
] | [
58,
0
] | [
61,
52
] | python | en | ['en', 'en', 'en'] | True |
RemoveReportHeaderAndFooter | (output) | Removes Google Test result report's header and footer from the output. | Removes Google Test result report's header and footer from the output. | def RemoveReportHeaderAndFooter(output):
"""Removes Google Test result report's header and footer from the output."""
output = re.sub(r'.*gtest_main.*\n', '', output)
output = re.sub(r'\[.*\d+ tests.*\n', '', output)
output = re.sub(r'\[.* test environment .*\n', '', output)
output = re.sub(r'\[=+\] \d+ tests .* ran.*', '', output)
output = re.sub(r'.* FAILED TESTS\n', '', output)
return output | [
"def",
"RemoveReportHeaderAndFooter",
"(",
"output",
")",
":",
"output",
"=",
"re",
".",
"sub",
"(",
"r'.*gtest_main.*\\n'",
",",
"''",
",",
"output",
")",
"output",
"=",
"re",
".",
"sub",
"(",
"r'\\[.*\\d+ tests.*\\n'",
",",
"''",
",",
"output",
")",
"output",
"=",
"re",
".",
"sub",
"(",
"r'\\[.* test environment .*\\n'",
",",
"''",
",",
"output",
")",
"output",
"=",
"re",
".",
"sub",
"(",
"r'\\[=+\\] \\d+ tests .* ran.*'",
",",
"''",
",",
"output",
")",
"output",
"=",
"re",
".",
"sub",
"(",
"r'.* FAILED TESTS\\n'",
",",
"''",
",",
"output",
")",
"return",
"output"
] | [
64,
0
] | [
72,
15
] | python | en | ['en', 'en', 'en'] | True |
RemoveLocations | (output) | Removes all file location info from a Google Test program's output.
Args:
output: the output of a Google Test program.
Returns:
output with all file location info (in the form of
'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or
'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by
'FILE:#: '.
| Removes all file location info from a Google Test program's output. | def RemoveLocations(output):
"""Removes all file location info from a Google Test program's output.
Args:
output: the output of a Google Test program.
Returns:
output with all file location info (in the form of
'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or
'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by
'FILE:#: '.
"""
return re.sub(r'.*[/\\](.+)(\:\d+|\(\d+\))\:', 'FILE:#:', output) | [
"def",
"RemoveLocations",
"(",
"output",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'.*[/\\\\](.+)(\\:\\d+|\\(\\d+\\))\\:'",
",",
"'FILE:#:'",
",",
"output",
")"
] | [
75,
0
] | [
88,
67
] | python | en | ['en', 'en', 'en'] | True |
NormalizeErrorMarker | (output) | Normalizes the error marker, which is different on Windows vs on Linux. | Normalizes the error marker, which is different on Windows vs on Linux. | def NormalizeErrorMarker(output):
"""Normalizes the error marker, which is different on Windows vs on Linux."""
return re.sub(r' error: ', ' Failure\n', output) | [
"def",
"NormalizeErrorMarker",
"(",
"output",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r' error: '",
",",
"' Failure\\n'",
",",
"output",
")"
] | [
91,
0
] | [
94,
50
] | python | en | ['en', 'en', 'en'] | True |
RemoveMemoryAddresses | (output) | Removes memory addresses from the test output. | Removes memory addresses from the test output. | def RemoveMemoryAddresses(output):
"""Removes memory addresses from the test output."""
return re.sub(r'@\w+', '@0x#', output) | [
"def",
"RemoveMemoryAddresses",
"(",
"output",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'@\\w+'",
",",
"'@0x#'",
",",
"output",
")"
] | [
97,
0
] | [
100,
40
] | python | en | ['en', 'en', 'en'] | True |
RemoveTestNamesOfLeakedMocks | (output) | Removes the test names of leaked mock objects from the test output. | Removes the test names of leaked mock objects from the test output. | def RemoveTestNamesOfLeakedMocks(output):
"""Removes the test names of leaked mock objects from the test output."""
return re.sub(r'\(used in test .+\) ', '', output) | [
"def",
"RemoveTestNamesOfLeakedMocks",
"(",
"output",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'\\(used in test .+\\) '",
",",
"''",
",",
"output",
")"
] | [
103,
0
] | [
106,
52
] | python | en | ['en', 'en', 'en'] | True |
GetLeakyTests | (output) | Returns a list of test names that leak mock objects. | Returns a list of test names that leak mock objects. | def GetLeakyTests(output):
"""Returns a list of test names that leak mock objects."""
# findall() returns a list of all matches of the regex in output.
# For example, if '(used in test FooTest.Bar)' is in output, the
# list will contain 'FooTest.Bar'.
return re.findall(r'\(used in test (.+)\)', output) | [
"def",
"GetLeakyTests",
"(",
"output",
")",
":",
"# findall() returns a list of all matches of the regex in output.",
"# For example, if '(used in test FooTest.Bar)' is in output, the",
"# list will contain 'FooTest.Bar'.",
"return",
"re",
".",
"findall",
"(",
"r'\\(used in test (.+)\\)'",
",",
"output",
")"
] | [
109,
0
] | [
115,
53
] | python | en | ['en', 'en', 'en'] | True |
GetNormalizedOutputAndLeakyTests | (output) | Normalizes the output of gmock_output_test_.
Args:
output: The test output.
Returns:
A tuple (the normalized test output, the list of test names that have
leaked mocks).
| Normalizes the output of gmock_output_test_. | def GetNormalizedOutputAndLeakyTests(output):
"""Normalizes the output of gmock_output_test_.
Args:
output: The test output.
Returns:
A tuple (the normalized test output, the list of test names that have
leaked mocks).
"""
output = ToUnixLineEnding(output)
output = RemoveReportHeaderAndFooter(output)
output = NormalizeErrorMarker(output)
output = RemoveLocations(output)
output = RemoveMemoryAddresses(output)
return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output)) | [
"def",
"GetNormalizedOutputAndLeakyTests",
"(",
"output",
")",
":",
"output",
"=",
"ToUnixLineEnding",
"(",
"output",
")",
"output",
"=",
"RemoveReportHeaderAndFooter",
"(",
"output",
")",
"output",
"=",
"NormalizeErrorMarker",
"(",
"output",
")",
"output",
"=",
"RemoveLocations",
"(",
"output",
")",
"output",
"=",
"RemoveMemoryAddresses",
"(",
"output",
")",
"return",
"(",
"RemoveTestNamesOfLeakedMocks",
"(",
"output",
")",
",",
"GetLeakyTests",
"(",
"output",
")",
")"
] | [
118,
0
] | [
134,
70
] | 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.