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.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.funnelarea.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.funnelarea.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.funnelarea.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.funnelarea.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.funnelarea.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.funnelarea.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.funnelarea.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.funnelarea.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.funnelarea.Hoverlabel constructor must be a dict or an instance of :class:`plotly.graph_objs.funnelarea.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.funnelarea.Hoverlabel \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.funnelarea.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
get_direction_target
(anchors, reg_targets, dir_offset=0, num_bins=2, one_hot=True)
Encode direction to 0 ~ num_bins-1. Args: anchors (torch.Tensor): Concatenated multi-level anchor. reg_targets (torch.Tensor): Bbox regression targets. dir_offset (int): Direction offset. num_bins (int): Number of bins to divide 2*PI. one_hot (bool): Whether to encode as one hot. Returns: torch.Tensor: Encoded direction targets.
Encode direction to 0 ~ num_bins-1.
def get_direction_target(anchors, reg_targets, dir_offset=0, num_bins=2, one_hot=True): """Encode direction to 0 ~ num_bins-1. Args: anchors (torch.Tensor): Concatenated multi-level anchor. reg_targets (torch.Tensor): Bbox regression targets. dir_offset (int): Direction offset. num_bins (int): Number of bins to divide 2*PI. one_hot (bool): Whether to encode as one hot. Returns: torch.Tensor: Encoded direction targets. """ rot_gt = reg_targets[..., 6] + anchors[..., 6] offset_rot = limit_period(rot_gt - dir_offset, 0, 2 * np.pi) dir_cls_targets = torch.floor(offset_rot / (2 * np.pi / num_bins)).long() dir_cls_targets = torch.clamp(dir_cls_targets, min=0, max=num_bins - 1) if one_hot: dir_targets = torch.zeros( *list(dir_cls_targets.shape), num_bins, dtype=anchors.dtype, device=dir_cls_targets.device) dir_targets.scatter_(dir_cls_targets.unsqueeze(dim=-1).long(), 1.0) dir_cls_targets = dir_targets return dir_cls_targets
[ "def", "get_direction_target", "(", "anchors", ",", "reg_targets", ",", "dir_offset", "=", "0", ",", "num_bins", "=", "2", ",", "one_hot", "=", "True", ")", ":", "rot_gt", "=", "reg_targets", "[", "...", ",", "6", "]", "+", "anchors", "[", "...", ",", "6", "]", "offset_rot", "=", "limit_period", "(", "rot_gt", "-", "dir_offset", ",", "0", ",", "2", "*", "np", ".", "pi", ")", "dir_cls_targets", "=", "torch", ".", "floor", "(", "offset_rot", "/", "(", "2", "*", "np", ".", "pi", "/", "num_bins", ")", ")", ".", "long", "(", ")", "dir_cls_targets", "=", "torch", ".", "clamp", "(", "dir_cls_targets", ",", "min", "=", "0", ",", "max", "=", "num_bins", "-", "1", ")", "if", "one_hot", ":", "dir_targets", "=", "torch", ".", "zeros", "(", "*", "list", "(", "dir_cls_targets", ".", "shape", ")", ",", "num_bins", ",", "dtype", "=", "anchors", ".", "dtype", ",", "device", "=", "dir_cls_targets", ".", "device", ")", "dir_targets", ".", "scatter_", "(", "dir_cls_targets", ".", "unsqueeze", "(", "dim", "=", "-", "1", ")", ".", "long", "(", ")", ",", "1.0", ")", "dir_cls_targets", "=", "dir_targets", "return", "dir_cls_targets" ]
[ 316, 0 ]
[ 345, 26 ]
python
en
['en', 'en', 'en']
True
AnchorTrainMixin.anchor_target_3d
(self, anchor_list, gt_bboxes_list, input_metas, gt_bboxes_ignore_list=None, gt_labels_list=None, label_channels=1, num_classes=1, sampling=True)
Compute regression and classification targets for anchors. Args: anchor_list (list[list]): Multi level anchors of each image. gt_bboxes_list (list[:obj:`BaseInstance3DBoxes`]): Ground truth bboxes of each image. input_metas (list[dict]): Meta info of each image. gt_bboxes_ignore_list (None | list): Ignore list of gt bboxes. gt_labels_list (list[torch.Tensor]): Gt labels of batches. label_channels (int): The channel of labels. num_classes (int): The number of classes. sampling (bool): Whether to sample anchors. Returns: tuple (list, list, list, list, list, list, int, int): Anchor targets, including labels, label weights, bbox targets, bbox weights, direction targets, direction weights, number of postive anchors and number of negative anchors.
Compute regression and classification targets for anchors.
def anchor_target_3d(self, anchor_list, gt_bboxes_list, input_metas, gt_bboxes_ignore_list=None, gt_labels_list=None, label_channels=1, num_classes=1, sampling=True): """Compute regression and classification targets for anchors. Args: anchor_list (list[list]): Multi level anchors of each image. gt_bboxes_list (list[:obj:`BaseInstance3DBoxes`]): Ground truth bboxes of each image. input_metas (list[dict]): Meta info of each image. gt_bboxes_ignore_list (None | list): Ignore list of gt bboxes. gt_labels_list (list[torch.Tensor]): Gt labels of batches. label_channels (int): The channel of labels. num_classes (int): The number of classes. sampling (bool): Whether to sample anchors. Returns: tuple (list, list, list, list, list, list, int, int): Anchor targets, including labels, label weights, bbox targets, bbox weights, direction targets, direction weights, number of postive anchors and number of negative anchors. """ num_imgs = len(input_metas) assert len(anchor_list) == num_imgs if isinstance(anchor_list[0][0], list): # sizes of anchors are different # anchor number of a single level num_level_anchors = [ sum([anchor.size(0) for anchor in anchors]) for anchors in anchor_list[0] ] for i in range(num_imgs): anchor_list[i] = anchor_list[i][0] else: # anchor number of multi levels num_level_anchors = [ anchors.view(-1, self.box_code_size).size(0) for anchors in anchor_list[0] ] # concat all level anchors and flags to a single tensor for i in range(num_imgs): anchor_list[i] = torch.cat(anchor_list[i]) # compute targets for each image if gt_bboxes_ignore_list is None: gt_bboxes_ignore_list = [None for _ in range(num_imgs)] if gt_labels_list is None: gt_labels_list = [None for _ in range(num_imgs)] (all_labels, all_label_weights, all_bbox_targets, all_bbox_weights, all_dir_targets, all_dir_weights, pos_inds_list, neg_inds_list) = multi_apply( self.anchor_target_3d_single, anchor_list, gt_bboxes_list, gt_bboxes_ignore_list, gt_labels_list, input_metas, label_channels=label_channels, num_classes=num_classes, sampling=sampling) # no valid anchors if any([labels is None for labels in all_labels]): return None # sampled anchors of all images num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) # split targets to a list w.r.t. multiple levels labels_list = images_to_levels(all_labels, num_level_anchors) label_weights_list = images_to_levels(all_label_weights, num_level_anchors) bbox_targets_list = images_to_levels(all_bbox_targets, num_level_anchors) bbox_weights_list = images_to_levels(all_bbox_weights, num_level_anchors) dir_targets_list = images_to_levels(all_dir_targets, num_level_anchors) dir_weights_list = images_to_levels(all_dir_weights, num_level_anchors) return (labels_list, label_weights_list, bbox_targets_list, bbox_weights_list, dir_targets_list, dir_weights_list, num_total_pos, num_total_neg)
[ "def", "anchor_target_3d", "(", "self", ",", "anchor_list", ",", "gt_bboxes_list", ",", "input_metas", ",", "gt_bboxes_ignore_list", "=", "None", ",", "gt_labels_list", "=", "None", ",", "label_channels", "=", "1", ",", "num_classes", "=", "1", ",", "sampling", "=", "True", ")", ":", "num_imgs", "=", "len", "(", "input_metas", ")", "assert", "len", "(", "anchor_list", ")", "==", "num_imgs", "if", "isinstance", "(", "anchor_list", "[", "0", "]", "[", "0", "]", ",", "list", ")", ":", "# sizes of anchors are different", "# anchor number of a single level", "num_level_anchors", "=", "[", "sum", "(", "[", "anchor", ".", "size", "(", "0", ")", "for", "anchor", "in", "anchors", "]", ")", "for", "anchors", "in", "anchor_list", "[", "0", "]", "]", "for", "i", "in", "range", "(", "num_imgs", ")", ":", "anchor_list", "[", "i", "]", "=", "anchor_list", "[", "i", "]", "[", "0", "]", "else", ":", "# anchor number of multi levels", "num_level_anchors", "=", "[", "anchors", ".", "view", "(", "-", "1", ",", "self", ".", "box_code_size", ")", ".", "size", "(", "0", ")", "for", "anchors", "in", "anchor_list", "[", "0", "]", "]", "# concat all level anchors and flags to a single tensor", "for", "i", "in", "range", "(", "num_imgs", ")", ":", "anchor_list", "[", "i", "]", "=", "torch", ".", "cat", "(", "anchor_list", "[", "i", "]", ")", "# compute targets for each image", "if", "gt_bboxes_ignore_list", "is", "None", ":", "gt_bboxes_ignore_list", "=", "[", "None", "for", "_", "in", "range", "(", "num_imgs", ")", "]", "if", "gt_labels_list", "is", "None", ":", "gt_labels_list", "=", "[", "None", "for", "_", "in", "range", "(", "num_imgs", ")", "]", "(", "all_labels", ",", "all_label_weights", ",", "all_bbox_targets", ",", "all_bbox_weights", ",", "all_dir_targets", ",", "all_dir_weights", ",", "pos_inds_list", ",", "neg_inds_list", ")", "=", "multi_apply", "(", "self", ".", "anchor_target_3d_single", ",", "anchor_list", ",", "gt_bboxes_list", ",", "gt_bboxes_ignore_list", ",", "gt_labels_list", ",", "input_metas", ",", "label_channels", "=", "label_channels", ",", "num_classes", "=", "num_classes", ",", "sampling", "=", "sampling", ")", "# no valid anchors", "if", "any", "(", "[", "labels", "is", "None", "for", "labels", "in", "all_labels", "]", ")", ":", "return", "None", "# sampled anchors of all images", "num_total_pos", "=", "sum", "(", "[", "max", "(", "inds", ".", "numel", "(", ")", ",", "1", ")", "for", "inds", "in", "pos_inds_list", "]", ")", "num_total_neg", "=", "sum", "(", "[", "max", "(", "inds", ".", "numel", "(", ")", ",", "1", ")", "for", "inds", "in", "neg_inds_list", "]", ")", "# split targets to a list w.r.t. multiple levels", "labels_list", "=", "images_to_levels", "(", "all_labels", ",", "num_level_anchors", ")", "label_weights_list", "=", "images_to_levels", "(", "all_label_weights", ",", "num_level_anchors", ")", "bbox_targets_list", "=", "images_to_levels", "(", "all_bbox_targets", ",", "num_level_anchors", ")", "bbox_weights_list", "=", "images_to_levels", "(", "all_bbox_weights", ",", "num_level_anchors", ")", "dir_targets_list", "=", "images_to_levels", "(", "all_dir_targets", ",", "num_level_anchors", ")", "dir_weights_list", "=", "images_to_levels", "(", "all_dir_weights", ",", "num_level_anchors", ")", "return", "(", "labels_list", ",", "label_weights_list", ",", "bbox_targets_list", ",", "bbox_weights_list", ",", "dir_targets_list", ",", "dir_weights_list", ",", "num_total_pos", ",", "num_total_neg", ")" ]
[ 10, 4 ]
[ 98, 45 ]
python
en
['en', 'en', 'en']
True
AnchorTrainMixin.anchor_target_3d_single
(self, anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, label_channels=1, num_classes=1, sampling=True)
Compute targets of anchors in single batch. Args: anchors (torch.Tensor): Concatenated multi-level anchor. gt_bboxes (:obj:`BaseInstance3DBoxes`): Gt bboxes. gt_bboxes_ignore (torch.Tensor): Ignored gt bboxes. gt_labels (torch.Tensor): Gt class labels. input_meta (dict): Meta info of each image. label_channels (int): The channel of labels. num_classes (int): The number of classes. sampling (bool): Whether to sample anchors. Returns: tuple[torch.Tensor]: Anchor targets.
Compute targets of anchors in single batch.
def anchor_target_3d_single(self, anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, label_channels=1, num_classes=1, sampling=True): """Compute targets of anchors in single batch. Args: anchors (torch.Tensor): Concatenated multi-level anchor. gt_bboxes (:obj:`BaseInstance3DBoxes`): Gt bboxes. gt_bboxes_ignore (torch.Tensor): Ignored gt bboxes. gt_labels (torch.Tensor): Gt class labels. input_meta (dict): Meta info of each image. label_channels (int): The channel of labels. num_classes (int): The number of classes. sampling (bool): Whether to sample anchors. Returns: tuple[torch.Tensor]: Anchor targets. """ if isinstance(self.bbox_assigner, list) and (not isinstance(anchors, list)): feat_size = anchors.size(0) * anchors.size(1) * anchors.size(2) rot_angles = anchors.size(-2) assert len(self.bbox_assigner) == anchors.size(-3) (total_labels, total_label_weights, total_bbox_targets, total_bbox_weights, total_dir_targets, total_dir_weights, total_pos_inds, total_neg_inds) = [], [], [], [], [], [], [], [] current_anchor_num = 0 for i, assigner in enumerate(self.bbox_assigner): current_anchors = anchors[..., i, :, :].reshape( -1, self.box_code_size) current_anchor_num += current_anchors.size(0) if self.assign_per_class: gt_per_cls = (gt_labels == i) anchor_targets = self.anchor_target_single_assigner( assigner, current_anchors, gt_bboxes[gt_per_cls, :], gt_bboxes_ignore, gt_labels[gt_per_cls], input_meta, num_classes, sampling) else: anchor_targets = self.anchor_target_single_assigner( assigner, current_anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, num_classes, sampling) (labels, label_weights, bbox_targets, bbox_weights, dir_targets, dir_weights, pos_inds, neg_inds) = anchor_targets total_labels.append(labels.reshape(feat_size, 1, rot_angles)) total_label_weights.append( label_weights.reshape(feat_size, 1, rot_angles)) total_bbox_targets.append( bbox_targets.reshape(feat_size, 1, rot_angles, anchors.size(-1))) total_bbox_weights.append( bbox_weights.reshape(feat_size, 1, rot_angles, anchors.size(-1))) total_dir_targets.append( dir_targets.reshape(feat_size, 1, rot_angles)) total_dir_weights.append( dir_weights.reshape(feat_size, 1, rot_angles)) total_pos_inds.append(pos_inds) total_neg_inds.append(neg_inds) total_labels = torch.cat(total_labels, dim=-2).reshape(-1) total_label_weights = torch.cat( total_label_weights, dim=-2).reshape(-1) total_bbox_targets = torch.cat( total_bbox_targets, dim=-3).reshape(-1, anchors.size(-1)) total_bbox_weights = torch.cat( total_bbox_weights, dim=-3).reshape(-1, anchors.size(-1)) total_dir_targets = torch.cat( total_dir_targets, dim=-2).reshape(-1) total_dir_weights = torch.cat( total_dir_weights, dim=-2).reshape(-1) total_pos_inds = torch.cat(total_pos_inds, dim=0).reshape(-1) total_neg_inds = torch.cat(total_neg_inds, dim=0).reshape(-1) return (total_labels, total_label_weights, total_bbox_targets, total_bbox_weights, total_dir_targets, total_dir_weights, total_pos_inds, total_neg_inds) elif isinstance(self.bbox_assigner, list) and isinstance( anchors, list): # class-aware anchors with different feature map sizes assert len(self.bbox_assigner) == len(anchors), \ 'The number of bbox assigners and anchors should be the same.' (total_labels, total_label_weights, total_bbox_targets, total_bbox_weights, total_dir_targets, total_dir_weights, total_pos_inds, total_neg_inds) = [], [], [], [], [], [], [], [] current_anchor_num = 0 for i, assigner in enumerate(self.bbox_assigner): current_anchors = anchors[i] current_anchor_num += current_anchors.size(0) if self.assign_per_class: gt_per_cls = (gt_labels == i) anchor_targets = self.anchor_target_single_assigner( assigner, current_anchors, gt_bboxes[gt_per_cls, :], gt_bboxes_ignore, gt_labels[gt_per_cls], input_meta, num_classes, sampling) else: anchor_targets = self.anchor_target_single_assigner( assigner, current_anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, num_classes, sampling) (labels, label_weights, bbox_targets, bbox_weights, dir_targets, dir_weights, pos_inds, neg_inds) = anchor_targets total_labels.append(labels) total_label_weights.append(label_weights) total_bbox_targets.append( bbox_targets.reshape(-1, anchors[i].size(-1))) total_bbox_weights.append( bbox_weights.reshape(-1, anchors[i].size(-1))) total_dir_targets.append(dir_targets) total_dir_weights.append(dir_weights) total_pos_inds.append(pos_inds) total_neg_inds.append(neg_inds) total_labels = torch.cat(total_labels, dim=0) total_label_weights = torch.cat(total_label_weights, dim=0) total_bbox_targets = torch.cat(total_bbox_targets, dim=0) total_bbox_weights = torch.cat(total_bbox_weights, dim=0) total_dir_targets = torch.cat(total_dir_targets, dim=0) total_dir_weights = torch.cat(total_dir_weights, dim=0) total_pos_inds = torch.cat(total_pos_inds, dim=0) total_neg_inds = torch.cat(total_neg_inds, dim=0) return (total_labels, total_label_weights, total_bbox_targets, total_bbox_weights, total_dir_targets, total_dir_weights, total_pos_inds, total_neg_inds) else: return self.anchor_target_single_assigner(self.bbox_assigner, anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, num_classes, sampling)
[ "def", "anchor_target_3d_single", "(", "self", ",", "anchors", ",", "gt_bboxes", ",", "gt_bboxes_ignore", ",", "gt_labels", ",", "input_meta", ",", "label_channels", "=", "1", ",", "num_classes", "=", "1", ",", "sampling", "=", "True", ")", ":", "if", "isinstance", "(", "self", ".", "bbox_assigner", ",", "list", ")", "and", "(", "not", "isinstance", "(", "anchors", ",", "list", ")", ")", ":", "feat_size", "=", "anchors", ".", "size", "(", "0", ")", "*", "anchors", ".", "size", "(", "1", ")", "*", "anchors", ".", "size", "(", "2", ")", "rot_angles", "=", "anchors", ".", "size", "(", "-", "2", ")", "assert", "len", "(", "self", ".", "bbox_assigner", ")", "==", "anchors", ".", "size", "(", "-", "3", ")", "(", "total_labels", ",", "total_label_weights", ",", "total_bbox_targets", ",", "total_bbox_weights", ",", "total_dir_targets", ",", "total_dir_weights", ",", "total_pos_inds", ",", "total_neg_inds", ")", "=", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", "current_anchor_num", "=", "0", "for", "i", ",", "assigner", "in", "enumerate", "(", "self", ".", "bbox_assigner", ")", ":", "current_anchors", "=", "anchors", "[", "...", ",", "i", ",", ":", ",", ":", "]", ".", "reshape", "(", "-", "1", ",", "self", ".", "box_code_size", ")", "current_anchor_num", "+=", "current_anchors", ".", "size", "(", "0", ")", "if", "self", ".", "assign_per_class", ":", "gt_per_cls", "=", "(", "gt_labels", "==", "i", ")", "anchor_targets", "=", "self", ".", "anchor_target_single_assigner", "(", "assigner", ",", "current_anchors", ",", "gt_bboxes", "[", "gt_per_cls", ",", ":", "]", ",", "gt_bboxes_ignore", ",", "gt_labels", "[", "gt_per_cls", "]", ",", "input_meta", ",", "num_classes", ",", "sampling", ")", "else", ":", "anchor_targets", "=", "self", ".", "anchor_target_single_assigner", "(", "assigner", ",", "current_anchors", ",", "gt_bboxes", ",", "gt_bboxes_ignore", ",", "gt_labels", ",", "input_meta", ",", "num_classes", ",", "sampling", ")", "(", "labels", ",", "label_weights", ",", "bbox_targets", ",", "bbox_weights", ",", "dir_targets", ",", "dir_weights", ",", "pos_inds", ",", "neg_inds", ")", "=", "anchor_targets", "total_labels", ".", "append", "(", "labels", ".", "reshape", "(", "feat_size", ",", "1", ",", "rot_angles", ")", ")", "total_label_weights", ".", "append", "(", "label_weights", ".", "reshape", "(", "feat_size", ",", "1", ",", "rot_angles", ")", ")", "total_bbox_targets", ".", "append", "(", "bbox_targets", ".", "reshape", "(", "feat_size", ",", "1", ",", "rot_angles", ",", "anchors", ".", "size", "(", "-", "1", ")", ")", ")", "total_bbox_weights", ".", "append", "(", "bbox_weights", ".", "reshape", "(", "feat_size", ",", "1", ",", "rot_angles", ",", "anchors", ".", "size", "(", "-", "1", ")", ")", ")", "total_dir_targets", ".", "append", "(", "dir_targets", ".", "reshape", "(", "feat_size", ",", "1", ",", "rot_angles", ")", ")", "total_dir_weights", ".", "append", "(", "dir_weights", ".", "reshape", "(", "feat_size", ",", "1", ",", "rot_angles", ")", ")", "total_pos_inds", ".", "append", "(", "pos_inds", ")", "total_neg_inds", ".", "append", "(", "neg_inds", ")", "total_labels", "=", "torch", ".", "cat", "(", "total_labels", ",", "dim", "=", "-", "2", ")", ".", "reshape", "(", "-", "1", ")", "total_label_weights", "=", "torch", ".", "cat", "(", "total_label_weights", ",", "dim", "=", "-", "2", ")", ".", "reshape", "(", "-", "1", ")", "total_bbox_targets", "=", "torch", ".", "cat", "(", "total_bbox_targets", ",", "dim", "=", "-", "3", ")", ".", "reshape", "(", "-", "1", ",", "anchors", ".", "size", "(", "-", "1", ")", ")", "total_bbox_weights", "=", "torch", ".", "cat", "(", "total_bbox_weights", ",", "dim", "=", "-", "3", ")", ".", "reshape", "(", "-", "1", ",", "anchors", ".", "size", "(", "-", "1", ")", ")", "total_dir_targets", "=", "torch", ".", "cat", "(", "total_dir_targets", ",", "dim", "=", "-", "2", ")", ".", "reshape", "(", "-", "1", ")", "total_dir_weights", "=", "torch", ".", "cat", "(", "total_dir_weights", ",", "dim", "=", "-", "2", ")", ".", "reshape", "(", "-", "1", ")", "total_pos_inds", "=", "torch", ".", "cat", "(", "total_pos_inds", ",", "dim", "=", "0", ")", ".", "reshape", "(", "-", "1", ")", "total_neg_inds", "=", "torch", ".", "cat", "(", "total_neg_inds", ",", "dim", "=", "0", ")", ".", "reshape", "(", "-", "1", ")", "return", "(", "total_labels", ",", "total_label_weights", ",", "total_bbox_targets", ",", "total_bbox_weights", ",", "total_dir_targets", ",", "total_dir_weights", ",", "total_pos_inds", ",", "total_neg_inds", ")", "elif", "isinstance", "(", "self", ".", "bbox_assigner", ",", "list", ")", "and", "isinstance", "(", "anchors", ",", "list", ")", ":", "# class-aware anchors with different feature map sizes", "assert", "len", "(", "self", ".", "bbox_assigner", ")", "==", "len", "(", "anchors", ")", ",", "'The number of bbox assigners and anchors should be the same.'", "(", "total_labels", ",", "total_label_weights", ",", "total_bbox_targets", ",", "total_bbox_weights", ",", "total_dir_targets", ",", "total_dir_weights", ",", "total_pos_inds", ",", "total_neg_inds", ")", "=", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", "current_anchor_num", "=", "0", "for", "i", ",", "assigner", "in", "enumerate", "(", "self", ".", "bbox_assigner", ")", ":", "current_anchors", "=", "anchors", "[", "i", "]", "current_anchor_num", "+=", "current_anchors", ".", "size", "(", "0", ")", "if", "self", ".", "assign_per_class", ":", "gt_per_cls", "=", "(", "gt_labels", "==", "i", ")", "anchor_targets", "=", "self", ".", "anchor_target_single_assigner", "(", "assigner", ",", "current_anchors", ",", "gt_bboxes", "[", "gt_per_cls", ",", ":", "]", ",", "gt_bboxes_ignore", ",", "gt_labels", "[", "gt_per_cls", "]", ",", "input_meta", ",", "num_classes", ",", "sampling", ")", "else", ":", "anchor_targets", "=", "self", ".", "anchor_target_single_assigner", "(", "assigner", ",", "current_anchors", ",", "gt_bboxes", ",", "gt_bboxes_ignore", ",", "gt_labels", ",", "input_meta", ",", "num_classes", ",", "sampling", ")", "(", "labels", ",", "label_weights", ",", "bbox_targets", ",", "bbox_weights", ",", "dir_targets", ",", "dir_weights", ",", "pos_inds", ",", "neg_inds", ")", "=", "anchor_targets", "total_labels", ".", "append", "(", "labels", ")", "total_label_weights", ".", "append", "(", "label_weights", ")", "total_bbox_targets", ".", "append", "(", "bbox_targets", ".", "reshape", "(", "-", "1", ",", "anchors", "[", "i", "]", ".", "size", "(", "-", "1", ")", ")", ")", "total_bbox_weights", ".", "append", "(", "bbox_weights", ".", "reshape", "(", "-", "1", ",", "anchors", "[", "i", "]", ".", "size", "(", "-", "1", ")", ")", ")", "total_dir_targets", ".", "append", "(", "dir_targets", ")", "total_dir_weights", ".", "append", "(", "dir_weights", ")", "total_pos_inds", ".", "append", "(", "pos_inds", ")", "total_neg_inds", ".", "append", "(", "neg_inds", ")", "total_labels", "=", "torch", ".", "cat", "(", "total_labels", ",", "dim", "=", "0", ")", "total_label_weights", "=", "torch", ".", "cat", "(", "total_label_weights", ",", "dim", "=", "0", ")", "total_bbox_targets", "=", "torch", ".", "cat", "(", "total_bbox_targets", ",", "dim", "=", "0", ")", "total_bbox_weights", "=", "torch", ".", "cat", "(", "total_bbox_weights", ",", "dim", "=", "0", ")", "total_dir_targets", "=", "torch", ".", "cat", "(", "total_dir_targets", ",", "dim", "=", "0", ")", "total_dir_weights", "=", "torch", ".", "cat", "(", "total_dir_weights", ",", "dim", "=", "0", ")", "total_pos_inds", "=", "torch", ".", "cat", "(", "total_pos_inds", ",", "dim", "=", "0", ")", "total_neg_inds", "=", "torch", ".", "cat", "(", "total_neg_inds", ",", "dim", "=", "0", ")", "return", "(", "total_labels", ",", "total_label_weights", ",", "total_bbox_targets", ",", "total_bbox_weights", ",", "total_dir_targets", ",", "total_dir_weights", ",", "total_pos_inds", ",", "total_neg_inds", ")", "else", ":", "return", "self", ".", "anchor_target_single_assigner", "(", "self", ".", "bbox_assigner", ",", "anchors", ",", "gt_bboxes", ",", "gt_bboxes_ignore", ",", "gt_labels", ",", "input_meta", ",", "num_classes", ",", "sampling", ")" ]
[ 100, 4 ]
[ 234, 76 ]
python
en
['en', 'en', 'en']
True
AnchorTrainMixin.anchor_target_single_assigner
(self, bbox_assigner, anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, num_classes=1, sampling=True)
Assign anchors and encode positive anchors. Args: bbox_assigner (BaseAssigner): assign positive and negative boxes. anchors (torch.Tensor): Concatenated multi-level anchor. gt_bboxes (:obj:`BaseInstance3DBoxes`): Gt bboxes. gt_bboxes_ignore (torch.Tensor): Ignored gt bboxes. gt_labels (torch.Tensor): Gt class labels. input_meta (dict): Meta info of each image. num_classes (int): The number of classes. sampling (bool): Whether to sample anchors. Returns: tuple[torch.Tensor]: Anchor targets.
Assign anchors and encode positive anchors.
def anchor_target_single_assigner(self, bbox_assigner, anchors, gt_bboxes, gt_bboxes_ignore, gt_labels, input_meta, num_classes=1, sampling=True): """Assign anchors and encode positive anchors. Args: bbox_assigner (BaseAssigner): assign positive and negative boxes. anchors (torch.Tensor): Concatenated multi-level anchor. gt_bboxes (:obj:`BaseInstance3DBoxes`): Gt bboxes. gt_bboxes_ignore (torch.Tensor): Ignored gt bboxes. gt_labels (torch.Tensor): Gt class labels. input_meta (dict): Meta info of each image. num_classes (int): The number of classes. sampling (bool): Whether to sample anchors. Returns: tuple[torch.Tensor]: Anchor targets. """ anchors = anchors.reshape(-1, anchors.size(-1)) num_valid_anchors = anchors.shape[0] bbox_targets = torch.zeros_like(anchors) bbox_weights = torch.zeros_like(anchors) dir_targets = anchors.new_zeros((anchors.shape[0]), dtype=torch.long) dir_weights = anchors.new_zeros((anchors.shape[0]), dtype=torch.float) labels = anchors.new_zeros(num_valid_anchors, dtype=torch.long) label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) if len(gt_bboxes) > 0: if not isinstance(gt_bboxes, torch.Tensor): gt_bboxes = gt_bboxes.tensor.to(anchors.device) assign_result = bbox_assigner.assign(anchors, gt_bboxes, gt_bboxes_ignore, gt_labels) sampling_result = self.bbox_sampler.sample(assign_result, anchors, gt_bboxes) pos_inds = sampling_result.pos_inds neg_inds = sampling_result.neg_inds else: pos_inds = torch.nonzero( anchors.new_zeros((anchors.shape[0], ), dtype=torch.bool) > 0, as_tuple=False).squeeze(-1).unique() neg_inds = torch.nonzero( anchors.new_zeros((anchors.shape[0], ), dtype=torch.bool) == 0, as_tuple=False).squeeze(-1).unique() if gt_labels is not None: labels += num_classes if len(pos_inds) > 0: pos_bbox_targets = self.bbox_coder.encode( sampling_result.pos_bboxes, sampling_result.pos_gt_bboxes) pos_dir_targets = get_direction_target( sampling_result.pos_bboxes, pos_bbox_targets, self.dir_offset, one_hot=False) bbox_targets[pos_inds, :] = pos_bbox_targets bbox_weights[pos_inds, :] = 1.0 dir_targets[pos_inds] = pos_dir_targets dir_weights[pos_inds] = 1.0 if gt_labels is None: labels[pos_inds] = 1 else: labels[pos_inds] = gt_labels[ sampling_result.pos_assigned_gt_inds] if self.train_cfg.pos_weight <= 0: label_weights[pos_inds] = 1.0 else: label_weights[pos_inds] = self.train_cfg.pos_weight if len(neg_inds) > 0: label_weights[neg_inds] = 1.0 return (labels, label_weights, bbox_targets, bbox_weights, dir_targets, dir_weights, pos_inds, neg_inds)
[ "def", "anchor_target_single_assigner", "(", "self", ",", "bbox_assigner", ",", "anchors", ",", "gt_bboxes", ",", "gt_bboxes_ignore", ",", "gt_labels", ",", "input_meta", ",", "num_classes", "=", "1", ",", "sampling", "=", "True", ")", ":", "anchors", "=", "anchors", ".", "reshape", "(", "-", "1", ",", "anchors", ".", "size", "(", "-", "1", ")", ")", "num_valid_anchors", "=", "anchors", ".", "shape", "[", "0", "]", "bbox_targets", "=", "torch", ".", "zeros_like", "(", "anchors", ")", "bbox_weights", "=", "torch", ".", "zeros_like", "(", "anchors", ")", "dir_targets", "=", "anchors", ".", "new_zeros", "(", "(", "anchors", ".", "shape", "[", "0", "]", ")", ",", "dtype", "=", "torch", ".", "long", ")", "dir_weights", "=", "anchors", ".", "new_zeros", "(", "(", "anchors", ".", "shape", "[", "0", "]", ")", ",", "dtype", "=", "torch", ".", "float", ")", "labels", "=", "anchors", ".", "new_zeros", "(", "num_valid_anchors", ",", "dtype", "=", "torch", ".", "long", ")", "label_weights", "=", "anchors", ".", "new_zeros", "(", "num_valid_anchors", ",", "dtype", "=", "torch", ".", "float", ")", "if", "len", "(", "gt_bboxes", ")", ">", "0", ":", "if", "not", "isinstance", "(", "gt_bboxes", ",", "torch", ".", "Tensor", ")", ":", "gt_bboxes", "=", "gt_bboxes", ".", "tensor", ".", "to", "(", "anchors", ".", "device", ")", "assign_result", "=", "bbox_assigner", ".", "assign", "(", "anchors", ",", "gt_bboxes", ",", "gt_bboxes_ignore", ",", "gt_labels", ")", "sampling_result", "=", "self", ".", "bbox_sampler", ".", "sample", "(", "assign_result", ",", "anchors", ",", "gt_bboxes", ")", "pos_inds", "=", "sampling_result", ".", "pos_inds", "neg_inds", "=", "sampling_result", ".", "neg_inds", "else", ":", "pos_inds", "=", "torch", ".", "nonzero", "(", "anchors", ".", "new_zeros", "(", "(", "anchors", ".", "shape", "[", "0", "]", ",", ")", ",", "dtype", "=", "torch", ".", "bool", ")", ">", "0", ",", "as_tuple", "=", "False", ")", ".", "squeeze", "(", "-", "1", ")", ".", "unique", "(", ")", "neg_inds", "=", "torch", ".", "nonzero", "(", "anchors", ".", "new_zeros", "(", "(", "anchors", ".", "shape", "[", "0", "]", ",", ")", ",", "dtype", "=", "torch", ".", "bool", ")", "==", "0", ",", "as_tuple", "=", "False", ")", ".", "squeeze", "(", "-", "1", ")", ".", "unique", "(", ")", "if", "gt_labels", "is", "not", "None", ":", "labels", "+=", "num_classes", "if", "len", "(", "pos_inds", ")", ">", "0", ":", "pos_bbox_targets", "=", "self", ".", "bbox_coder", ".", "encode", "(", "sampling_result", ".", "pos_bboxes", ",", "sampling_result", ".", "pos_gt_bboxes", ")", "pos_dir_targets", "=", "get_direction_target", "(", "sampling_result", ".", "pos_bboxes", ",", "pos_bbox_targets", ",", "self", ".", "dir_offset", ",", "one_hot", "=", "False", ")", "bbox_targets", "[", "pos_inds", ",", ":", "]", "=", "pos_bbox_targets", "bbox_weights", "[", "pos_inds", ",", ":", "]", "=", "1.0", "dir_targets", "[", "pos_inds", "]", "=", "pos_dir_targets", "dir_weights", "[", "pos_inds", "]", "=", "1.0", "if", "gt_labels", "is", "None", ":", "labels", "[", "pos_inds", "]", "=", "1", "else", ":", "labels", "[", "pos_inds", "]", "=", "gt_labels", "[", "sampling_result", ".", "pos_assigned_gt_inds", "]", "if", "self", ".", "train_cfg", ".", "pos_weight", "<=", "0", ":", "label_weights", "[", "pos_inds", "]", "=", "1.0", "else", ":", "label_weights", "[", "pos_inds", "]", "=", "self", ".", "train_cfg", ".", "pos_weight", "if", "len", "(", "neg_inds", ")", ">", "0", ":", "label_weights", "[", "neg_inds", "]", "=", "1.0", "return", "(", "labels", ",", "label_weights", ",", "bbox_targets", ",", "bbox_weights", ",", "dir_targets", ",", "dir_weights", ",", "pos_inds", ",", "neg_inds", ")" ]
[ 236, 4 ]
[ 313, 48 ]
python
en
['en', 'en', 'en']
True
Font.color
(self)
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 Returns ------- str
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
def color(self): """ 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 Returns ------- str """ return self["color"]
[ "def", "color", "(", "self", ")", ":", "return", "self", "[", "\"color\"", "]" ]
[ 15, 4 ]
[ 63, 28 ]
python
en
['en', 'error', 'th']
False
Font.family
(self)
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". The 'family' property is a string and must be specified as: - A non-empty string Returns ------- str
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". The 'family' property is a string and must be specified as: - A non-empty string
def family(self): """ 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". The 'family' property is a string and must be specified as: - A non-empty string Returns ------- str """ return self["family"]
[ "def", "family", "(", "self", ")", ":", "return", "self", "[", "\"family\"", "]" ]
[ 72, 4 ]
[ 94, 29 ]
python
en
['en', 'error', 'th']
False
Font.size
(self)
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] Returns ------- int|float
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf]
def size(self): """ The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] Returns ------- int|float """ return self["size"]
[ "def", "size", "(", "self", ")", ":", "return", "self", "[", "\"size\"", "]" ]
[ 103, 4 ]
[ 112, 27 ]
python
en
['en', 'error', 'th']
False
Font.__init__
(self, arg=None, color=None, family=None, size=None, **kwargs)
Construct a new Font object Sets the font of the update menu button text. Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.updatemenu.Font` 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". size Returns ------- Font
Construct a new Font object Sets the font of the update menu button text.
def __init__(self, arg=None, color=None, family=None, size=None, **kwargs): """ Construct a new Font object Sets the font of the update menu button text. Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.updatemenu.Font` 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". size Returns ------- Font """ super(Font, self).__init__("font") 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.layout.updatemenu.Font constructor must be a dict or an instance of :class:`plotly.graph_objs.layout.updatemenu.Font`""" ) # 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("family", None) _v = family if family is not None else _v if _v is not None: self["family"] = _v _v = arg.pop("size", None) _v = size if size is not None else _v if _v is not None: self["size"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "color", "=", "None", ",", "family", "=", "None", ",", "size", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Font", ",", "self", ")", ".", "__init__", "(", "\"font\"", ")", "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.layout.updatemenu.Font \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.layout.updatemenu.Font`\"\"\"", ")", "# 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", "(", "\"family\"", ",", "None", ")", "_v", "=", "family", "if", "family", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"family\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"size\"", ",", "None", ")", "_v", "=", "size", "if", "size", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"size\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 143, 4 ]
[ 226, 34 ]
python
en
['en', 'error', 'th']
False
NodeMaintainer.lastActionEventInfo
(self)
action parameters of last performed action :returns: action parameters or None if there were no actions
action parameters of last performed action
def lastActionEventInfo(self): """ action parameters of last performed action :returns: action parameters or None if there were no actions """ return self._actionLog.last_event
[ "def", "lastActionEventInfo", "(", "self", ")", ":", "return", "self", ".", "_actionLog", ".", "last_event" ]
[ 66, 4 ]
[ 72, 41 ]
python
en
['en', 'error', 'th']
False
NodeMaintainer._unscheduleAction
(self)
Unschedule current action Note that it does not add record to action log and does not do required steps to resume previous action. If you need this - use _cancelScheduledAction
Unschedule current action
def _unscheduleAction(self): """ Unschedule current action Note that it does not add record to action log and does not do required steps to resume previous action. If you need this - use _cancelScheduledAction """ logger.trace("{} unscheduling actions".format(self)) self.aqStash = deque() self.scheduledAction = None
[ "def", "_unscheduleAction", "(", "self", ")", ":", "logger", ".", "trace", "(", "\"{} unscheduling actions\"", ".", "format", "(", "self", ")", ")", "self", ".", "aqStash", "=", "deque", "(", ")", "self", ".", "scheduledAction", "=", "None" ]
[ 74, 4 ]
[ 85, 35 ]
python
en
['en', 'error', 'th']
False
NodeMaintainer._defaultLog
(self, dataDir, config)
Default log for store action txns :param dataDir: :param config: :return: ActionLog
Default log for store action txns :param dataDir: :param config: :return: ActionLog
def _defaultLog(self, dataDir, config): """ Default log for store action txns :param dataDir: :param config: :return: ActionLog """
[ "def", "_defaultLog", "(", "self", ",", "dataDir", ",", "config", ")", ":" ]
[ 99, 4 ]
[ 105, 11 ]
python
en
['en', 'error', 'th']
False
KnowledgeRetrieverAgent.add_cmdline_args
( cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None )
Add command-line arguments specifically for this agent.
Add command-line arguments specifically for this agent.
def add_cmdline_args( cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None ) -> ParlaiParser: """ Add command-line arguments specifically for this agent. """ TorchRankerAgent.add_cmdline_args(parser, partial_opt=partial_opt) parser = parser.add_argument_group('KnowledgeRetriever Arguments') parser.add_argument('--retriever-model-file', type=str, default=RETRIEVER_FILE) parser.add_argument('--selector-model-file', type=str, default=SELECTOR_FILE) parser.add_argument( '--num-retrieved', type=int, default=7, help='how many passages to retrieve for each category', ) parser.add_argument( '--add-token-knowledge', type='bool', default=False, help='Add knowledge token to retrieved knowledge', ) parser.add_argument('--debug', type='bool', default=False) return parser
[ "def", "add_cmdline_args", "(", "cls", ",", "parser", ":", "ParlaiParser", ",", "partial_opt", ":", "Optional", "[", "Opt", "]", "=", "None", ")", "->", "ParlaiParser", ":", "TorchRankerAgent", ".", "add_cmdline_args", "(", "parser", ",", "partial_opt", "=", "partial_opt", ")", "parser", "=", "parser", ".", "add_argument_group", "(", "'KnowledgeRetriever Arguments'", ")", "parser", ".", "add_argument", "(", "'--retriever-model-file'", ",", "type", "=", "str", ",", "default", "=", "RETRIEVER_FILE", ")", "parser", ".", "add_argument", "(", "'--selector-model-file'", ",", "type", "=", "str", ",", "default", "=", "SELECTOR_FILE", ")", "parser", ".", "add_argument", "(", "'--num-retrieved'", ",", "type", "=", "int", ",", "default", "=", "7", ",", "help", "=", "'how many passages to retrieve for each category'", ",", ")", "parser", ".", "add_argument", "(", "'--add-token-knowledge'", ",", "type", "=", "'bool'", ",", "default", "=", "False", ",", "help", "=", "'Add knowledge token to retrieved knowledge'", ",", ")", "parser", ".", "add_argument", "(", "'--debug'", ",", "type", "=", "'bool'", ",", "default", "=", "False", ")", "return", "parser" ]
[ 29, 4 ]
[ 52, 21 ]
python
en
['en', 'error', 'th']
False
KnowledgeRetrieverAgent.maintain_retriever_history
(self, obs, actor_id='apprentice')
Maintain texts retrieved by the retriever to mimic the set-up from the data collection for the task.
Maintain texts retrieved by the retriever to mimic the set-up from the data collection for the task.
def maintain_retriever_history(self, obs, actor_id='apprentice'): """ Maintain texts retrieved by the retriever to mimic the set-up from the data collection for the task. """ if actor_id == 'apprentice': if self.retriever_history['episode_done']: # clear history self.retriever_history['chosen_topic'] = '' self.retriever_history['wizard'] = '' self.retriever_history['apprentice'] = '' self.retriever_history['episode_done'] = False self.dialogue_history = [] # save chosen topic if 'chosen_topic' in obs: self.retriever_history['chosen_topic'] = obs['chosen_topic'] if 'text' in obs: self.retriever_history['apprentice'] = obs['text'] self.retriever_history['episode_done'] = obs['episode_done'] elif not self.retriever_history['episode_done']: # only add the wizard item to the history if episode_done is not # True self.retriever_history['wizard'] = obs['text'] self.dialogue_history.append({'id': actor_id, 'text': obs['text']})
[ "def", "maintain_retriever_history", "(", "self", ",", "obs", ",", "actor_id", "=", "'apprentice'", ")", ":", "if", "actor_id", "==", "'apprentice'", ":", "if", "self", ".", "retriever_history", "[", "'episode_done'", "]", ":", "# clear history", "self", ".", "retriever_history", "[", "'chosen_topic'", "]", "=", "''", "self", ".", "retriever_history", "[", "'wizard'", "]", "=", "''", "self", ".", "retriever_history", "[", "'apprentice'", "]", "=", "''", "self", ".", "retriever_history", "[", "'episode_done'", "]", "=", "False", "self", ".", "dialogue_history", "=", "[", "]", "# save chosen topic", "if", "'chosen_topic'", "in", "obs", ":", "self", ".", "retriever_history", "[", "'chosen_topic'", "]", "=", "obs", "[", "'chosen_topic'", "]", "if", "'text'", "in", "obs", ":", "self", ".", "retriever_history", "[", "'apprentice'", "]", "=", "obs", "[", "'text'", "]", "self", ".", "retriever_history", "[", "'episode_done'", "]", "=", "obs", "[", "'episode_done'", "]", "elif", "not", "self", ".", "retriever_history", "[", "'episode_done'", "]", ":", "# only add the wizard item to the history if episode_done is not", "# True", "self", ".", "retriever_history", "[", "'wizard'", "]", "=", "obs", "[", "'text'", "]", "self", ".", "dialogue_history", ".", "append", "(", "{", "'id'", ":", "actor_id", ",", "'text'", ":", "obs", "[", "'text'", "]", "}", ")" ]
[ 124, 4 ]
[ 152, 75 ]
python
en
['en', 'error', 'th']
False
KnowledgeRetrieverAgent.get_passages
(self, act)
Format passages retrieved by taking the first paragraph of the top `num_retrieved` passages.
Format passages retrieved by taking the first paragraph of the top `num_retrieved` passages.
def get_passages(self, act): """ Format passages retrieved by taking the first paragraph of the top `num_retrieved` passages. """ retrieved_txt = act.get('text', '') cands = act.get('text_candidates', []) if len(cands) > 0: retrieved_txts = cands[: self.opt['num_retrieved']] else: retrieved_txts = [retrieved_txt] retrieved_txt_format = [] retrieved_txt_format_no_title = [] for ret_txt in retrieved_txts: paragraphs = ret_txt.split('\n') if len(paragraphs) > 2: sentences = self.sent_tok.tokenize(paragraphs[2]) for sent in sentences: if self.add_token_knowledge: delim = ' ' + TOKEN_KNOWLEDGE + ' ' else: delim = ' ' retrieved_txt_format.append(delim.join([paragraphs[0], sent])) retrieved_txt_format_no_title.append(sent) if len(retrieved_txt_format) > 0: passages = '\n'.join(retrieved_txt_format) passages_no_title = '\n'.join(retrieved_txt_format_no_title) else: passages = '' passages_no_title = '' return passages, passages_no_title
[ "def", "get_passages", "(", "self", ",", "act", ")", ":", "retrieved_txt", "=", "act", ".", "get", "(", "'text'", ",", "''", ")", "cands", "=", "act", ".", "get", "(", "'text_candidates'", ",", "[", "]", ")", "if", "len", "(", "cands", ")", ">", "0", ":", "retrieved_txts", "=", "cands", "[", ":", "self", ".", "opt", "[", "'num_retrieved'", "]", "]", "else", ":", "retrieved_txts", "=", "[", "retrieved_txt", "]", "retrieved_txt_format", "=", "[", "]", "retrieved_txt_format_no_title", "=", "[", "]", "for", "ret_txt", "in", "retrieved_txts", ":", "paragraphs", "=", "ret_txt", ".", "split", "(", "'\\n'", ")", "if", "len", "(", "paragraphs", ")", ">", "2", ":", "sentences", "=", "self", ".", "sent_tok", ".", "tokenize", "(", "paragraphs", "[", "2", "]", ")", "for", "sent", "in", "sentences", ":", "if", "self", ".", "add_token_knowledge", ":", "delim", "=", "' '", "+", "TOKEN_KNOWLEDGE", "+", "' '", "else", ":", "delim", "=", "' '", "retrieved_txt_format", ".", "append", "(", "delim", ".", "join", "(", "[", "paragraphs", "[", "0", "]", ",", "sent", "]", ")", ")", "retrieved_txt_format_no_title", ".", "append", "(", "sent", ")", "if", "len", "(", "retrieved_txt_format", ")", ">", "0", ":", "passages", "=", "'\\n'", ".", "join", "(", "retrieved_txt_format", ")", "passages_no_title", "=", "'\\n'", ".", "join", "(", "retrieved_txt_format_no_title", ")", "else", ":", "passages", "=", "''", "passages_no_title", "=", "''", "return", "passages", ",", "passages_no_title" ]
[ 186, 4 ]
[ 219, 42 ]
python
en
['en', 'error', 'th']
False
KnowledgeRetrieverAgent.tfidf_retriever_act
(self, history)
Combines and formats texts retrieved by the TFIDF retriever for the chosen topic, the last thing the wizard said, and the last thing the apprentice said.
Combines and formats texts retrieved by the TFIDF retriever for the chosen topic, the last thing the wizard said, and the last thing the apprentice said.
def tfidf_retriever_act(self, history): """ Combines and formats texts retrieved by the TFIDF retriever for the chosen topic, the last thing the wizard said, and the last thing the apprentice said. """ # retrieve on chosen topic chosen_topic_txts = None if self.retriever_history.get('chosen_topic'): ( chosen_topic_txts, chosen_topic_txts_no_title, ) = self.get_chosen_topic_passages(self.retriever_history['chosen_topic']) # retrieve on apprentice apprentice_txts = None if self.retriever_history.get('apprentice'): apprentice_act = { 'text': self.retriever_history['apprentice'], 'episode_done': True, } self.retriever.observe(apprentice_act) apprentice_txts, apprentice_txts_no_title = self.get_passages( self.retriever.act() ) # retrieve on wizard wizard_txts = None if self.retriever_history.get('wizard'): wizard_act = { 'text': self.retriever_history['wizard'], 'episode_done': True, } self.retriever.observe(wizard_act) wizard_txts, wizard_txts_no_title = self.get_passages(self.retriever.act()) # combine everything combined_txt = '' combined_txt_no_title = '' if chosen_topic_txts: combined_txt += chosen_topic_txts combined_txt_no_title += chosen_topic_txts_no_title if wizard_txts: combined_txt += '\n' + wizard_txts combined_txt_no_title += '\n' + wizard_txts_no_title if apprentice_txts: combined_txt += '\n' + apprentice_txts combined_txt_no_title += '\n' + apprentice_txts_no_title return combined_txt, combined_txt_no_title
[ "def", "tfidf_retriever_act", "(", "self", ",", "history", ")", ":", "# retrieve on chosen topic", "chosen_topic_txts", "=", "None", "if", "self", ".", "retriever_history", ".", "get", "(", "'chosen_topic'", ")", ":", "(", "chosen_topic_txts", ",", "chosen_topic_txts_no_title", ",", ")", "=", "self", ".", "get_chosen_topic_passages", "(", "self", ".", "retriever_history", "[", "'chosen_topic'", "]", ")", "# retrieve on apprentice", "apprentice_txts", "=", "None", "if", "self", ".", "retriever_history", ".", "get", "(", "'apprentice'", ")", ":", "apprentice_act", "=", "{", "'text'", ":", "self", ".", "retriever_history", "[", "'apprentice'", "]", ",", "'episode_done'", ":", "True", ",", "}", "self", ".", "retriever", ".", "observe", "(", "apprentice_act", ")", "apprentice_txts", ",", "apprentice_txts_no_title", "=", "self", ".", "get_passages", "(", "self", ".", "retriever", ".", "act", "(", ")", ")", "# retrieve on wizard", "wizard_txts", "=", "None", "if", "self", ".", "retriever_history", ".", "get", "(", "'wizard'", ")", ":", "wizard_act", "=", "{", "'text'", ":", "self", ".", "retriever_history", "[", "'wizard'", "]", ",", "'episode_done'", ":", "True", ",", "}", "self", ".", "retriever", ".", "observe", "(", "wizard_act", ")", "wizard_txts", ",", "wizard_txts_no_title", "=", "self", ".", "get_passages", "(", "self", ".", "retriever", ".", "act", "(", ")", ")", "# combine everything", "combined_txt", "=", "''", "combined_txt_no_title", "=", "''", "if", "chosen_topic_txts", ":", "combined_txt", "+=", "chosen_topic_txts", "combined_txt_no_title", "+=", "chosen_topic_txts_no_title", "if", "wizard_txts", ":", "combined_txt", "+=", "'\\n'", "+", "wizard_txts", "combined_txt_no_title", "+=", "'\\n'", "+", "wizard_txts_no_title", "if", "apprentice_txts", ":", "combined_txt", "+=", "'\\n'", "+", "apprentice_txts", "combined_txt_no_title", "+=", "'\\n'", "+", "apprentice_txts_no_title", "return", "combined_txt", ",", "combined_txt_no_title" ]
[ 221, 4 ]
[ 269, 50 ]
python
en
['en', 'error', 'th']
False
KnowledgeRetrieverAgent.observe
(self, observation, actor_id='apprentice')
Observe a dialogue act. Use `actor_id` to indicate whether dialogue acts are from the 'apprentice' or the 'wizard' agent.
Observe a dialogue act.
def observe(self, observation, actor_id='apprentice'): """ Observe a dialogue act. Use `actor_id` to indicate whether dialogue acts are from the 'apprentice' or the 'wizard' agent. """ if actor_id == 'apprentice': self.observation = observation self.maintain_retriever_history(observation, actor_id=actor_id) if 'labels' in observation or 'eval_labels' in observation: labels = 'labels' if 'labels' in observation else 'eval_labels' self.next_wizard = observation[labels][0] else: # NOTE: if we are in interactive mode, we need to make sure # to call observe again on the wizard's act self.next_wizard = None
[ "def", "observe", "(", "self", ",", "observation", ",", "actor_id", "=", "'apprentice'", ")", ":", "if", "actor_id", "==", "'apprentice'", ":", "self", ".", "observation", "=", "observation", "self", ".", "maintain_retriever_history", "(", "observation", ",", "actor_id", "=", "actor_id", ")", "if", "'labels'", "in", "observation", "or", "'eval_labels'", "in", "observation", ":", "labels", "=", "'labels'", "if", "'labels'", "in", "observation", "else", "'eval_labels'", "self", ".", "next_wizard", "=", "observation", "[", "labels", "]", "[", "0", "]", "else", ":", "# NOTE: if we are in interactive mode, we need to make sure", "# to call observe again on the wizard's act", "self", ".", "next_wizard", "=", "None" ]
[ 321, 4 ]
[ 337, 35 ]
python
en
['en', 'error', 'th']
False
Font.color
(self)
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
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): """ 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 ]
[ 64, 28 ]
python
en
['en', 'error', 'th']
False
Font.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\"", "]" ]
[ 73, 4 ]
[ 84, 31 ]
python
en
['en', 'error', 'th']
False
Font.family
(self)
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". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above Returns ------- str|numpy.ndarray
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". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above
def family(self): """ 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". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above Returns ------- str|numpy.ndarray """ return self["family"]
[ "def", "family", "(", "self", ")", ":", "return", "self", "[", "\"family\"", "]" ]
[ 93, 4 ]
[ 116, 29 ]
python
en
['en', 'error', 'th']
False
Font.familysrc
(self)
Sets the source reference on Chart Studio Cloud for family . The 'familysrc' 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 family . The 'familysrc' property must be specified as a string or as a plotly.grid_objs.Column object
def familysrc(self): """ Sets the source reference on Chart Studio Cloud for family . The 'familysrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self["familysrc"]
[ "def", "familysrc", "(", "self", ")", ":", "return", "self", "[", "\"familysrc\"", "]" ]
[ 125, 4 ]
[ 136, 32 ]
python
en
['en', 'error', 'th']
False
Font.size
(self)
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] - A tuple, list, or one-dimensional numpy array of the above Returns ------- int|float|numpy.ndarray
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] - A tuple, list, or one-dimensional numpy array of the above
def size(self): """ The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] - A tuple, list, or one-dimensional numpy array of the above Returns ------- int|float|numpy.ndarray """ return self["size"]
[ "def", "size", "(", "self", ")", ":", "return", "self", "[", "\"size\"", "]" ]
[ 145, 4 ]
[ 155, 27 ]
python
en
['en', 'error', 'th']
False
Font.sizesrc
(self)
Sets the source reference on Chart Studio Cloud for size . The 'sizesrc' 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 size . The 'sizesrc' property must be specified as a string or as a plotly.grid_objs.Column object
def sizesrc(self): """ Sets the source reference on Chart Studio Cloud for size . The 'sizesrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self["sizesrc"]
[ "def", "sizesrc", "(", "self", ")", ":", "return", "self", "[", "\"sizesrc\"", "]" ]
[ 164, 4 ]
[ 175, 30 ]
python
en
['en', 'error', 'th']
False
Font.__init__
( self, arg=None, color=None, colorsrc=None, family=None, familysrc=None, size=None, sizesrc=None, **kwargs )
Construct a new Font object Sets the font used in hover labels. Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.choroplethmapb ox.hoverlabel.Font` 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 ------- Font
Construct a new Font object Sets the font used in hover labels.
def __init__( self, arg=None, color=None, colorsrc=None, family=None, familysrc=None, size=None, sizesrc=None, **kwargs ): """ Construct a new Font object Sets the font used in hover labels. Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.choroplethmapb ox.hoverlabel.Font` 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 ------- Font """ super(Font, self).__init__("font") 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.choroplethmapbox.hoverlabel.Font constructor must be a dict or an instance of :class:`plotly.graph_objs.choroplethmapbox.hoverlabel.Font`""" ) # 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("family", None) _v = family if family is not None else _v if _v is not None: self["family"] = _v _v = arg.pop("familysrc", None) _v = familysrc if familysrc is not None else _v if _v is not None: self["familysrc"] = _v _v = arg.pop("size", None) _v = size if size is not None else _v if _v is not None: self["size"] = _v _v = arg.pop("sizesrc", None) _v = sizesrc if sizesrc is not None else _v if _v is not None: self["sizesrc"] = _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", ",", "family", "=", "None", ",", "familysrc", "=", "None", ",", "size", "=", "None", ",", "sizesrc", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Font", ",", "self", ")", ".", "__init__", "(", "\"font\"", ")", "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.choroplethmapbox.hoverlabel.Font \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.choroplethmapbox.hoverlabel.Font`\"\"\"", ")", "# 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", "(", "\"family\"", ",", "None", ")", "_v", "=", "family", "if", "family", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"family\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"familysrc\"", ",", "None", ")", "_v", "=", "familysrc", "if", "familysrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"familysrc\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"size\"", ",", "None", ")", "_v", "=", "size", "if", "size", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"size\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"sizesrc\"", ",", "None", ")", "_v", "=", "sizesrc", "if", "sizesrc", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"sizesrc\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 215, 4 ]
[ 329, 34 ]
python
en
['en', 'error', 'th']
False
Tickformatstop.dtickrange
(self)
range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" The 'dtickrange' property is an info array that may be specified as: * a list or tuple of 2 elements where: (0) The 'dtickrange[0]' property accepts values of any type (1) The 'dtickrange[1]' property accepts values of any type Returns ------- list
range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" The 'dtickrange' property is an info array that may be specified as: * a list or tuple of 2 elements where: (0) The 'dtickrange[0]' property accepts values of any type (1) The 'dtickrange[1]' property accepts values of any type
def dtickrange(self): """ range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" The 'dtickrange' property is an info array that may be specified as: * a list or tuple of 2 elements where: (0) The 'dtickrange[0]' property accepts values of any type (1) The 'dtickrange[1]' property accepts values of any type Returns ------- list """ return self["dtickrange"]
[ "def", "dtickrange", "(", "self", ")", ":", "return", "self", "[", "\"dtickrange\"", "]" ]
[ 15, 4 ]
[ 31, 33 ]
python
en
['en', 'error', 'th']
False
Tickformatstop.enabled
(self)
Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. The 'enabled' property must be specified as a bool (either True, or False) Returns ------- bool
Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. The 'enabled' property must be specified as a bool (either True, or False)
def enabled(self): """ Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. The 'enabled' property must be specified as a bool (either True, or False) Returns ------- bool """ return self["enabled"]
[ "def", "enabled", "(", "self", ")", ":", "return", "self", "[", "\"enabled\"", "]" ]
[ 40, 4 ]
[ 52, 30 ]
python
en
['en', 'error', 'th']
False
Tickformatstop.name
(self)
When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. The 'name' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. The 'name' property is a string and must be specified as: - A string - A number that will be converted to a string
def name(self): """ When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. The 'name' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["name"]
[ "def", "name", "(", "self", ")", ":", "return", "self", "[", "\"name\"", "]" ]
[ 61, 4 ]
[ 79, 27 ]
python
en
['en', 'error', 'th']
False
Tickformatstop.templateitemname
(self)
Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. The 'templateitemname' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. The 'templateitemname' property is a string and must be specified as: - A string - A number that will be converted to a string
def templateitemname(self): """ Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. The 'templateitemname' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["templateitemname"]
[ "def", "templateitemname", "(", "self", ")", ":", "return", "self", "[", "\"templateitemname\"", "]" ]
[ 88, 4 ]
[ 107, 39 ]
python
en
['en', 'error', 'th']
False
Tickformatstop.value
(self)
string - dtickformat for described zoom level, the same as "tickformat" The 'value' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str
string - dtickformat for described zoom level, the same as "tickformat" The 'value' property is a string and must be specified as: - A string - A number that will be converted to a string
def value(self): """ string - dtickformat for described zoom level, the same as "tickformat" The 'value' property is a string and must be specified as: - A string - A number that will be converted to a string Returns ------- str """ return self["value"]
[ "def", "value", "(", "self", ")", ":", "return", "self", "[", "\"value\"", "]" ]
[ 116, 4 ]
[ 129, 28 ]
python
en
['en', 'error', 'th']
False
Tickformatstop.__init__
( self, arg=None, dtickrange=None, enabled=None, name=None, templateitemname=None, value=None, **kwargs )
Construct a new Tickformatstop object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.scene.x axis.Tickformatstop` dtickrange range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat" Returns ------- Tickformatstop
Construct a new Tickformatstop object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.scene.x axis.Tickformatstop` dtickrange range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat"
def __init__( self, arg=None, dtickrange=None, enabled=None, name=None, templateitemname=None, value=None, **kwargs ): """ Construct a new Tickformatstop object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.layout.scene.x axis.Tickformatstop` dtickrange range [*min*, *max*], where "min", "max" - dtick values which describe some zoom level, it is possible to omit "min" or "max" value by passing "null" enabled Determines whether or not this stop is used. If `false`, this stop is ignored even within its `dtickrange`. name When used in a template, named items are created in the output figure in addition to any items the figure already has in this array. You can modify these items in the output figure by making your own item with `templateitemname` matching this `name` alongside your modifications (including `visible: false` or `enabled: false` to hide it). Has no effect outside of a template. templateitemname Used to refer to a named item in this array in the template. Named items from the template will be created even without a matching item in the input figure, but you can modify one by making an item with `templateitemname` matching its `name`, alongside your modifications (including `visible: false` or `enabled: false` to hide it). If there is no template or no matching item, this item will be hidden unless you explicitly show it with `visible: true`. value string - dtickformat for described zoom level, the same as "tickformat" Returns ------- Tickformatstop """ super(Tickformatstop, self).__init__("tickformatstops") 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.layout.scene.xaxis.Tickformatstop constructor must be a dict or an instance of :class:`plotly.graph_objs.layout.scene.xaxis.Tickformatstop`""" ) # 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("dtickrange", None) _v = dtickrange if dtickrange is not None else _v if _v is not None: self["dtickrange"] = _v _v = arg.pop("enabled", None) _v = enabled if enabled is not None else _v if _v is not None: self["enabled"] = _v _v = arg.pop("name", None) _v = name if name is not None else _v if _v is not None: self["name"] = _v _v = arg.pop("templateitemname", None) _v = templateitemname if templateitemname is not None else _v if _v is not None: self["templateitemname"] = _v _v = arg.pop("value", None) _v = value if value is not None else _v if _v is not None: self["value"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "dtickrange", "=", "None", ",", "enabled", "=", "None", ",", "name", "=", "None", ",", "templateitemname", "=", "None", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Tickformatstop", ",", "self", ")", ".", "__init__", "(", "\"tickformatstops\"", ")", "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.layout.scene.xaxis.Tickformatstop \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.layout.scene.xaxis.Tickformatstop`\"\"\"", ")", "# 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", "(", "\"dtickrange\"", ",", "None", ")", "_v", "=", "dtickrange", "if", "dtickrange", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"dtickrange\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"enabled\"", ",", "None", ")", "_v", "=", "enabled", "if", "enabled", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"enabled\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"name\"", ",", "None", ")", "_v", "=", "name", "if", "name", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"name\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"templateitemname\"", ",", "None", ")", "_v", "=", "templateitemname", "if", "templateitemname", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"templateitemname\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"value\"", ",", "None", ")", "_v", "=", "value", "if", "value", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"value\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 172, 4 ]
[ 282, 34 ]
python
en
['en', 'error', 'th']
False
Mssp.__init__
(self, protocol)
initialize MSSP by storing protocol on ourselves and calling the client to see if it supports MSSP. Args: protocol (Protocol): The active protocol instance.
initialize MSSP by storing protocol on ourselves and calling the client to see if it supports MSSP.
def __init__(self, protocol): """ initialize MSSP by storing protocol on ourselves and calling the client to see if it supports MSSP. Args: protocol (Protocol): The active protocol instance. """ self.protocol = protocol self.protocol.will(MSSP).addCallbacks(self.do_mssp, self.no_mssp)
[ "def", "__init__", "(", "self", ",", "protocol", ")", ":", "self", ".", "protocol", "=", "protocol", "self", ".", "protocol", ".", "will", "(", "MSSP", ")", ".", "addCallbacks", "(", "self", ".", "do_mssp", ",", "self", ".", "no_mssp", ")" ]
[ 32, 4 ]
[ 42, 73 ]
python
en
['en', 'error', 'th']
False
Mssp.get_player_count
(self)
Get number of logged-in players. Returns: count (int): The number of players in the MUD.
Get number of logged-in players.
def get_player_count(self): """ Get number of logged-in players. Returns: count (int): The number of players in the MUD. """ return str(self.protocol.sessionhandler.count_loggedin())
[ "def", "get_player_count", "(", "self", ")", ":", "return", "str", "(", "self", ".", "protocol", ".", "sessionhandler", ".", "count_loggedin", "(", ")", ")" ]
[ 44, 4 ]
[ 52, 65 ]
python
en
['en', 'error', 'th']
False
Mssp.get_uptime
(self)
Get how long the portal has been online (reloads are not counted). Returns: uptime (int): Number of seconds of uptime.
Get how long the portal has been online (reloads are not counted).
def get_uptime(self): """ Get how long the portal has been online (reloads are not counted). Returns: uptime (int): Number of seconds of uptime. """ return str(self.protocol.sessionhandler.uptime)
[ "def", "get_uptime", "(", "self", ")", ":", "return", "str", "(", "self", ".", "protocol", ".", "sessionhandler", ".", "uptime", ")" ]
[ 54, 4 ]
[ 62, 55 ]
python
en
['en', 'error', 'th']
False
Mssp.no_mssp
(self, option)
Called when mssp is not requested. This is the normal operation. Args: option (Option): Not used.
Called when mssp is not requested. This is the normal operation.
def no_mssp(self, option): """ Called when mssp is not requested. This is the normal operation. Args: option (Option): Not used. """ self.protocol.handshake_done()
[ "def", "no_mssp", "(", "self", ",", "option", ")", ":", "self", ".", "protocol", ".", "handshake_done", "(", ")" ]
[ 64, 4 ]
[ 73, 38 ]
python
en
['en', 'error', 'th']
False
Mssp.do_mssp
(self, option)
Negotiate all the information. Args: option (Option): Not used.
Negotiate all the information.
def do_mssp(self, option): """ Negotiate all the information. Args: option (Option): Not used. """ self.mssp_table = { # Required fields "NAME": "Evennia", "PLAYERS": self.get_player_count, "UPTIME": self.get_uptime, # Generic "CRAWL DELAY": "-1", "HOSTNAME": "", # current or new hostname "PORT": ["4000"], # most important port should be last in list "CODEBASE": "Evennia", "CONTACT": "", # email for contacting the mud "CREATED": "", # year MUD was created "ICON": "", # url to icon 32x32 or larger; <32kb. "IP": "", # current or new IP address "LANGUAGE": "", # name of language used, e.g. English "LOCATION": "", # full English name of server country "MINIMUM AGE": "0", # set to 0 if not applicable "WEBSITE": "www.evennia.com", # Categorisation "FAMILY": "Custom", # evennia goes under 'Custom' "GENRE": "None", # Adult, Fantasy, Historical, Horror, Modern, None, or Science Fiction "GAMEPLAY": "None", # Adventure, Educational, Hack and Slash, None, # Player versus Player, Player versus Environment, # Roleplaying, Simulation, Social or Strategy "STATUS": "Open Beta", # Alpha, Closed Beta, Open Beta, Live "GAMESYSTEM": "Custom", # D&D, d20 System, World of Darkness, etc. Use Custom if homebrew "SUBGENRE": "None", # LASG, Medieval Fantasy, World War II, Frankenstein, # Cyberpunk, Dragonlance, etc. Or None if not available. # World "AREAS": "0", "HELPFILES": "0", "MOBILES": "0", "OBJECTS": "0", "ROOMS": "0", # use 0 if room-less "CLASSES": "0", # use 0 if class-less "LEVELS": "0", # use 0 if level-less "RACES": "0", # use 0 if race-less "SKILLS": "0", # use 0 if skill-less # Protocols set to 1 or 0) "ANSI": "1", "GMCP": "0", "ATCP": "0", "MCCP": "0", "MCP": "0", "MSDP": "0", "MSP": "0", "MXP": "0", "PUEBLO": "0", "SSL": "1", "UTF-8": "1", "ZMP": "0", "VT100": "0", "XTERM 256 COLORS": "0", # Commercial set to 1 or 0) "PAY TO PLAY": "0", "PAY FOR PERKS": "0", # Hiring set to 1 or 0) "HIRING BUILDERS": "0", "HIRING CODERS": "0", # Extended variables # World "DBSIZE": "0", "EXITS": "0", "EXTRA DESCRIPTIONS": "0", "MUDPROGS": "0", "MUDTRIGS": "0", "RESETS": "0", # Game (set to 1, 0 or one of the given alternatives) "ADULT MATERIAL": "0", "MULTICLASSING": "0", "NEWBIE FRIENDLY": "0", "PLAYER CITIES": "0", "PLAYER CLANS": "0", "PLAYER CRAFTING": "0", "PLAYER GUILDS": "0", "EQUIPMENT SYSTEM": "None", # "None", "Level", "Skill", "Both" "MULTIPLAYING": "None", # "None", "Restricted", "Full" "PLAYERKILLING": "None", # "None", "Restricted", "Full" "QUEST SYSTEM": "None", # "None", "Immortal Run", "Automated", "Integrated" "ROLEPLAYING": "None", # "None", "Accepted", "Encouraged", "Enforced" "TRAINING SYSTEM": "None", # "None", "Level", "Skill", "Both" "WORLD ORIGINALITY": "None", # "All Stock", "Mostly Stock", "Mostly Original", "All Original" } # update the static table with the custom one if MSSPTable_CUSTOM: self.mssp_table.update(MSSPTable_CUSTOM) varlist = '' for variable, value in self.mssp_table.items(): if callable(value): value = value() if utils.is_iter(value): for partval in value: varlist += MSSP_VAR + str(variable) + MSSP_VAL + str(partval) else: varlist += MSSP_VAR + str(variable) + MSSP_VAL + str(value) # send to crawler by subnegotiation self.protocol.requestNegotiation(MSSP, varlist) self.protocol.handshake_done()
[ "def", "do_mssp", "(", "self", ",", "option", ")", ":", "self", ".", "mssp_table", "=", "{", "# Required fields", "\"NAME\"", ":", "\"Evennia\"", ",", "\"PLAYERS\"", ":", "self", ".", "get_player_count", ",", "\"UPTIME\"", ":", "self", ".", "get_uptime", ",", "# Generic", "\"CRAWL DELAY\"", ":", "\"-1\"", ",", "\"HOSTNAME\"", ":", "\"\"", ",", "# current or new hostname", "\"PORT\"", ":", "[", "\"4000\"", "]", ",", "# most important port should be last in list", "\"CODEBASE\"", ":", "\"Evennia\"", ",", "\"CONTACT\"", ":", "\"\"", ",", "# email for contacting the mud", "\"CREATED\"", ":", "\"\"", ",", "# year MUD was created", "\"ICON\"", ":", "\"\"", ",", "# url to icon 32x32 or larger; <32kb.", "\"IP\"", ":", "\"\"", ",", "# current or new IP address", "\"LANGUAGE\"", ":", "\"\"", ",", "# name of language used, e.g. English", "\"LOCATION\"", ":", "\"\"", ",", "# full English name of server country", "\"MINIMUM AGE\"", ":", "\"0\"", ",", "# set to 0 if not applicable", "\"WEBSITE\"", ":", "\"www.evennia.com\"", ",", "# Categorisation", "\"FAMILY\"", ":", "\"Custom\"", ",", "# evennia goes under 'Custom'", "\"GENRE\"", ":", "\"None\"", ",", "# Adult, Fantasy, Historical, Horror, Modern, None, or Science Fiction", "\"GAMEPLAY\"", ":", "\"None\"", ",", "# Adventure, Educational, Hack and Slash, None,", "# Player versus Player, Player versus Environment,", "# Roleplaying, Simulation, Social or Strategy", "\"STATUS\"", ":", "\"Open Beta\"", ",", "# Alpha, Closed Beta, Open Beta, Live", "\"GAMESYSTEM\"", ":", "\"Custom\"", ",", "# D&D, d20 System, World of Darkness, etc. Use Custom if homebrew", "\"SUBGENRE\"", ":", "\"None\"", ",", "# LASG, Medieval Fantasy, World War II, Frankenstein,", "# Cyberpunk, Dragonlance, etc. Or None if not available.", "# World", "\"AREAS\"", ":", "\"0\"", ",", "\"HELPFILES\"", ":", "\"0\"", ",", "\"MOBILES\"", ":", "\"0\"", ",", "\"OBJECTS\"", ":", "\"0\"", ",", "\"ROOMS\"", ":", "\"0\"", ",", "# use 0 if room-less", "\"CLASSES\"", ":", "\"0\"", ",", "# use 0 if class-less", "\"LEVELS\"", ":", "\"0\"", ",", "# use 0 if level-less", "\"RACES\"", ":", "\"0\"", ",", "# use 0 if race-less", "\"SKILLS\"", ":", "\"0\"", ",", "# use 0 if skill-less", "# Protocols set to 1 or 0)", "\"ANSI\"", ":", "\"1\"", ",", "\"GMCP\"", ":", "\"0\"", ",", "\"ATCP\"", ":", "\"0\"", ",", "\"MCCP\"", ":", "\"0\"", ",", "\"MCP\"", ":", "\"0\"", ",", "\"MSDP\"", ":", "\"0\"", ",", "\"MSP\"", ":", "\"0\"", ",", "\"MXP\"", ":", "\"0\"", ",", "\"PUEBLO\"", ":", "\"0\"", ",", "\"SSL\"", ":", "\"1\"", ",", "\"UTF-8\"", ":", "\"1\"", ",", "\"ZMP\"", ":", "\"0\"", ",", "\"VT100\"", ":", "\"0\"", ",", "\"XTERM 256 COLORS\"", ":", "\"0\"", ",", "# Commercial set to 1 or 0)", "\"PAY TO PLAY\"", ":", "\"0\"", ",", "\"PAY FOR PERKS\"", ":", "\"0\"", ",", "# Hiring set to 1 or 0)", "\"HIRING BUILDERS\"", ":", "\"0\"", ",", "\"HIRING CODERS\"", ":", "\"0\"", ",", "# Extended variables", "# World", "\"DBSIZE\"", ":", "\"0\"", ",", "\"EXITS\"", ":", "\"0\"", ",", "\"EXTRA DESCRIPTIONS\"", ":", "\"0\"", ",", "\"MUDPROGS\"", ":", "\"0\"", ",", "\"MUDTRIGS\"", ":", "\"0\"", ",", "\"RESETS\"", ":", "\"0\"", ",", "# Game (set to 1, 0 or one of the given alternatives)", "\"ADULT MATERIAL\"", ":", "\"0\"", ",", "\"MULTICLASSING\"", ":", "\"0\"", ",", "\"NEWBIE FRIENDLY\"", ":", "\"0\"", ",", "\"PLAYER CITIES\"", ":", "\"0\"", ",", "\"PLAYER CLANS\"", ":", "\"0\"", ",", "\"PLAYER CRAFTING\"", ":", "\"0\"", ",", "\"PLAYER GUILDS\"", ":", "\"0\"", ",", "\"EQUIPMENT SYSTEM\"", ":", "\"None\"", ",", "# \"None\", \"Level\", \"Skill\", \"Both\"", "\"MULTIPLAYING\"", ":", "\"None\"", ",", "# \"None\", \"Restricted\", \"Full\"", "\"PLAYERKILLING\"", ":", "\"None\"", ",", "# \"None\", \"Restricted\", \"Full\"", "\"QUEST SYSTEM\"", ":", "\"None\"", ",", "# \"None\", \"Immortal Run\", \"Automated\", \"Integrated\"", "\"ROLEPLAYING\"", ":", "\"None\"", ",", "# \"None\", \"Accepted\", \"Encouraged\", \"Enforced\"", "\"TRAINING SYSTEM\"", ":", "\"None\"", ",", "# \"None\", \"Level\", \"Skill\", \"Both\"", "\"WORLD ORIGINALITY\"", ":", "\"None\"", ",", "# \"All Stock\", \"Mostly Stock\", \"Mostly Original\", \"All Original\"", "}", "# update the static table with the custom one", "if", "MSSPTable_CUSTOM", ":", "self", ".", "mssp_table", ".", "update", "(", "MSSPTable_CUSTOM", ")", "varlist", "=", "''", "for", "variable", ",", "value", "in", "self", ".", "mssp_table", ".", "items", "(", ")", ":", "if", "callable", "(", "value", ")", ":", "value", "=", "value", "(", ")", "if", "utils", ".", "is_iter", "(", "value", ")", ":", "for", "partval", "in", "value", ":", "varlist", "+=", "MSSP_VAR", "+", "str", "(", "variable", ")", "+", "MSSP_VAL", "+", "str", "(", "partval", ")", "else", ":", "varlist", "+=", "MSSP_VAR", "+", "str", "(", "variable", ")", "+", "MSSP_VAL", "+", "str", "(", "value", ")", "# send to crawler by subnegotiation", "self", ".", "protocol", ".", "requestNegotiation", "(", "MSSP", ",", "varlist", ")", "self", ".", "protocol", ".", "handshake_done", "(", ")" ]
[ 75, 4 ]
[ 204, 38 ]
python
en
['en', 'error', 'th']
False
X.opacity
(self)
Sets the projection color. The 'opacity' property is a number and may be specified as: - An int or float in the interval [0, 1] Returns ------- int|float
Sets the projection color. The 'opacity' property is a number and may be specified as: - An int or float in the interval [0, 1]
def opacity(self): """ Sets the projection color. The 'opacity' property is a number and may be specified as: - An int or float in the interval [0, 1] Returns ------- int|float """ return self["opacity"]
[ "def", "opacity", "(", "self", ")", ":", "return", "self", "[", "\"opacity\"", "]" ]
[ 15, 4 ]
[ 26, 30 ]
python
en
['en', 'error', 'th']
False
X.scale
(self)
Sets the scale factor determining the size of the projection marker points. The 'scale' property is a number and may be specified as: - An int or float in the interval [0, 10] Returns ------- int|float
Sets the scale factor determining the size of the projection marker points. The 'scale' property is a number and may be specified as: - An int or float in the interval [0, 10]
def scale(self): """ Sets the scale factor determining the size of the projection marker points. The 'scale' property is a number and may be specified as: - An int or float in the interval [0, 10] Returns ------- int|float """ return self["scale"]
[ "def", "scale", "(", "self", ")", ":", "return", "self", "[", "\"scale\"", "]" ]
[ 35, 4 ]
[ 47, 28 ]
python
en
['en', 'error', 'th']
False
X.show
(self)
Sets whether or not projections are shown along the x axis. The 'show' property must be specified as a bool (either True, or False) Returns ------- bool
Sets whether or not projections are shown along the x axis. The 'show' property must be specified as a bool (either True, or False)
def show(self): """ Sets whether or not projections are shown along the x axis. The 'show' property must be specified as a bool (either True, or False) Returns ------- bool """ return self["show"]
[ "def", "show", "(", "self", ")", ":", "return", "self", "[", "\"show\"", "]" ]
[ 56, 4 ]
[ 67, 27 ]
python
en
['en', 'error', 'th']
False
X.__init__
(self, arg=None, opacity=None, scale=None, show=None, **kwargs)
Construct a new X object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter3d.projection.X` opacity Sets the projection color. scale Sets the scale factor determining the size of the projection marker points. show Sets whether or not projections are shown along the x axis. Returns ------- X
Construct a new X object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter3d.projection.X` opacity Sets the projection color. scale Sets the scale factor determining the size of the projection marker points. show Sets whether or not projections are shown along the x axis.
def __init__(self, arg=None, opacity=None, scale=None, show=None, **kwargs): """ Construct a new X object Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scatter3d.projection.X` opacity Sets the projection color. scale Sets the scale factor determining the size of the projection marker points. show Sets whether or not projections are shown along the x axis. Returns ------- X """ super(X, self).__init__("x") 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.scatter3d.projection.X constructor must be a dict or an instance of :class:`plotly.graph_objs.scatter3d.projection.X`""" ) # 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("opacity", None) _v = opacity if opacity is not None else _v if _v is not None: self["opacity"] = _v _v = arg.pop("scale", None) _v = scale if scale is not None else _v if _v is not None: self["scale"] = _v _v = arg.pop("show", None) _v = show if show is not None else _v if _v is not None: self["show"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "opacity", "=", "None", ",", "scale", "=", "None", ",", "show", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "X", ",", "self", ")", ".", "__init__", "(", "\"x\"", ")", "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.scatter3d.projection.X \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scatter3d.projection.X`\"\"\"", ")", "# 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", "(", "\"opacity\"", ",", "None", ")", "_v", "=", "opacity", "if", "opacity", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"opacity\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"scale\"", ",", "None", ")", "_v", "=", "scale", "if", "scale", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"scale\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"show\"", ",", "None", ")", "_v", "=", "show", "if", "show", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"show\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 88, 4 ]
[ 159, 34 ]
python
en
['en', 'error', 'th']
False
Tickfont.color
(self)
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 Returns ------- str
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
def color(self): """ 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 Returns ------- str """ return self["color"]
[ "def", "color", "(", "self", ")", ":", "return", "self", "[", "\"color\"", "]" ]
[ 15, 4 ]
[ 63, 28 ]
python
en
['en', 'error', 'th']
False
Tickfont.family
(self)
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". The 'family' property is a string and must be specified as: - A non-empty string Returns ------- str
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". The 'family' property is a string and must be specified as: - A non-empty string
def family(self): """ 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". The 'family' property is a string and must be specified as: - A non-empty string Returns ------- str """ return self["family"]
[ "def", "family", "(", "self", ")", ":", "return", "self", "[", "\"family\"", "]" ]
[ 72, 4 ]
[ 94, 29 ]
python
en
['en', 'error', 'th']
False
Tickfont.size
(self)
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] Returns ------- int|float
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf]
def size(self): """ The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] Returns ------- int|float """ return self["size"]
[ "def", "size", "(", "self", ")", ":", "return", "self", "[", "\"size\"", "]" ]
[ 103, 4 ]
[ 112, 27 ]
python
en
['en', 'error', 'th']
False
Tickfont.__init__
(self, arg=None, color=None, family=None, size=None, **kwargs)
Construct a new Tickfont object Sets the color bar's tick label font Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scattergl.mark er.colorbar.Tickfont` 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". size Returns ------- Tickfont
Construct a new Tickfont object Sets the color bar's tick label font
def __init__(self, arg=None, color=None, family=None, size=None, **kwargs): """ Construct a new Tickfont object Sets the color bar's tick label font Parameters ---------- arg dict of properties compatible with this constructor or an instance of :class:`plotly.graph_objs.scattergl.mark er.colorbar.Tickfont` 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". size Returns ------- Tickfont """ super(Tickfont, self).__init__("tickfont") 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.scattergl.marker.colorbar.Tickfont constructor must be a dict or an instance of :class:`plotly.graph_objs.scattergl.marker.colorbar.Tickfont`""" ) # 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("family", None) _v = family if family is not None else _v if _v is not None: self["family"] = _v _v = arg.pop("size", None) _v = size if size is not None else _v if _v is not None: self["size"] = _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs)) # Reset skip_invalid # ------------------ self._skip_invalid = False
[ "def", "__init__", "(", "self", ",", "arg", "=", "None", ",", "color", "=", "None", ",", "family", "=", "None", ",", "size", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Tickfont", ",", "self", ")", ".", "__init__", "(", "\"tickfont\"", ")", "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.scattergl.marker.colorbar.Tickfont \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scattergl.marker.colorbar.Tickfont`\"\"\"", ")", "# 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", "(", "\"family\"", ",", "None", ")", "_v", "=", "family", "if", "family", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"family\"", "]", "=", "_v", "_v", "=", "arg", ".", "pop", "(", "\"size\"", ",", "None", ")", "_v", "=", "size", "if", "size", "is", "not", "None", "else", "_v", "if", "_v", "is", "not", "None", ":", "self", "[", "\"size\"", "]", "=", "_v", "# Process unknown kwargs", "# ----------------------", "self", ".", "_process_kwargs", "(", "*", "*", "dict", "(", "arg", ",", "*", "*", "kwargs", ")", ")", "# Reset skip_invalid", "# ------------------", "self", ".", "_skip_invalid", "=", "False" ]
[ 143, 4 ]
[ 226, 34 ]
python
en
['en', 'error', 'th']
False
DefaultTeacher.act
(self)
Use DialogTeacher act but set id to "Teacher" for intro message.
Use DialogTeacher act but set id to "Teacher" for intro message.
def act(self): """ Use DialogTeacher act but set id to "Teacher" for intro message. """ reply = super().act() if reply.get('text', '').startswith('You have the following friends'): reply['id'] = 'Teacher' return reply
[ "def", "act", "(", "self", ")", ":", "reply", "=", "super", "(", ")", ".", "act", "(", ")", "if", "reply", ".", "get", "(", "'text'", ",", "''", ")", ".", "startswith", "(", "'You have the following friends'", ")", ":", "reply", "[", "'id'", "]", "=", "'Teacher'", "return", "reply" ]
[ 29, 4 ]
[ 36, 20 ]
python
en
['en', 'error', 'th']
False
DefaultTeacher.setup_data
(self, path)
Load json data of conversations.
Load json data of conversations.
def setup_data(self, path): """ Load json data of conversations. """ print('loading: ' + path) with PathManager.open(path) as data_file: self.loaded_data = json.load(data_file) for ex in self.loaded_data: if len(ex['events']) > 0: # TODO: add reverse conversation as well curr_agent = ex['events'][0]['agent'] conversation = [ ( 'You have the following friends:\n' + '\n'.join( ', '.join('{}={}'.format(k, v) for k, v in person.items()) for person in ex['scenario']['kbs'][int(curr_agent)] ) + '\nTry to find out which friend the other person has in common.' ) ] curr = '' idx = 0 while idx < len(ex['events']): msg = ex['events'][idx]['data'] if type(msg) == dict: msg = 'SELECT({})'.format( ', '.join('{}={}'.format(k, v) for k, v in msg.items()) ) next_agent = ex['events'][idx]['agent'] if curr_agent == next_agent: curr += '\n' + msg curr = curr.strip() else: conversation.append(curr) curr = msg curr_agent = next_agent idx += 1 conversation.append(curr) for i in range(0, len(conversation), 2): if i + 1 < len(conversation) - 1: yield (conversation[i], [conversation[i + 1]]), i == 0 elif i + 1 == len(conversation) - 1: yield ( (conversation[i], [conversation[i + 1]], ex['outcome']), False, ) else: yield (conversation[i], None, ex['outcome']), False
[ "def", "setup_data", "(", "self", ",", "path", ")", ":", "print", "(", "'loading: '", "+", "path", ")", "with", "PathManager", ".", "open", "(", "path", ")", "as", "data_file", ":", "self", ".", "loaded_data", "=", "json", ".", "load", "(", "data_file", ")", "for", "ex", "in", "self", ".", "loaded_data", ":", "if", "len", "(", "ex", "[", "'events'", "]", ")", ">", "0", ":", "# TODO: add reverse conversation as well", "curr_agent", "=", "ex", "[", "'events'", "]", "[", "0", "]", "[", "'agent'", "]", "conversation", "=", "[", "(", "'You have the following friends:\\n'", "+", "'\\n'", ".", "join", "(", "', '", ".", "join", "(", "'{}={}'", ".", "format", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "person", ".", "items", "(", ")", ")", "for", "person", "in", "ex", "[", "'scenario'", "]", "[", "'kbs'", "]", "[", "int", "(", "curr_agent", ")", "]", ")", "+", "'\\nTry to find out which friend the other person has in common.'", ")", "]", "curr", "=", "''", "idx", "=", "0", "while", "idx", "<", "len", "(", "ex", "[", "'events'", "]", ")", ":", "msg", "=", "ex", "[", "'events'", "]", "[", "idx", "]", "[", "'data'", "]", "if", "type", "(", "msg", ")", "==", "dict", ":", "msg", "=", "'SELECT({})'", ".", "format", "(", "', '", ".", "join", "(", "'{}={}'", ".", "format", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "msg", ".", "items", "(", ")", ")", ")", "next_agent", "=", "ex", "[", "'events'", "]", "[", "idx", "]", "[", "'agent'", "]", "if", "curr_agent", "==", "next_agent", ":", "curr", "+=", "'\\n'", "+", "msg", "curr", "=", "curr", ".", "strip", "(", ")", "else", ":", "conversation", ".", "append", "(", "curr", ")", "curr", "=", "msg", "curr_agent", "=", "next_agent", "idx", "+=", "1", "conversation", ".", "append", "(", "curr", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "conversation", ")", ",", "2", ")", ":", "if", "i", "+", "1", "<", "len", "(", "conversation", ")", "-", "1", ":", "yield", "(", "conversation", "[", "i", "]", ",", "[", "conversation", "[", "i", "+", "1", "]", "]", ")", ",", "i", "==", "0", "elif", "i", "+", "1", "==", "len", "(", "conversation", ")", "-", "1", ":", "yield", "(", "(", "conversation", "[", "i", "]", ",", "[", "conversation", "[", "i", "+", "1", "]", "]", ",", "ex", "[", "'outcome'", "]", ")", ",", "False", ",", ")", "else", ":", "yield", "(", "conversation", "[", "i", "]", ",", "None", ",", "ex", "[", "'outcome'", "]", ")", ",", "False" ]
[ 38, 4 ]
[ 86, 75 ]
python
en
['en', 'error', 'th']
False
StyleGenAgent.add_cmdline_args
( cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None )
Add command-line arguments specifically for this agent.
Add command-line arguments specifically for this agent.
def add_cmdline_args( cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None ) -> ParlaiParser: """ Add command-line arguments specifically for this agent. """ StyleAgentMixin.add_cmdline_args(parser, partial_opt=partial_opt) TransformerGeneratorAgent.add_cmdline_args(parser, partial_opt=partial_opt) return parser
[ "def", "add_cmdline_args", "(", "cls", ",", "parser", ":", "ParlaiParser", ",", "partial_opt", ":", "Optional", "[", "Opt", "]", "=", "None", ")", "->", "ParlaiParser", ":", "StyleAgentMixin", ".", "add_cmdline_args", "(", "parser", ",", "partial_opt", "=", "partial_opt", ")", "TransformerGeneratorAgent", ".", "add_cmdline_args", "(", "parser", ",", "partial_opt", "=", "partial_opt", ")", "return", "parser" ]
[ 22, 4 ]
[ 30, 21 ]
python
en
['en', 'error', 'th']
False
ModelImageChatWorld._run_initial_turn
(self)
Show the image to the human and bot, and show the bot's response to the human.
Show the image to the human and bot, and show the bot's response to the human.
def _run_initial_turn(self) -> None: """ Show the image to the human and bot, and show the bot's response to the human. """ system_id = 'SYSTEM' system_agent_idx = None # Show the image to the human image_act_for_human = { 'episode_done': False, 'id': system_id, 'text': f"""Welcome! You'll now have a conversation with your partner. <-- FIRST, YOUR PARTNER WILL SAY SOMETHING ABOUT THIS IMAGE TO YOUR LEFT. Be sure to talk about this image a little bit before discussing other things! """, 'task_data': {'image_src': self.image_src}, 'agent_idx': system_agent_idx, } self.agent.observe(validate(image_act_for_human)) # Show the image to the bot image_act = { **self.image_act, 'episode_done': False, 'id': system_id, 'agent_idx': system_agent_idx, } self.bot.observe(validate(image_act)) del image_act['image'] # Don't save the image features to disk # Have the bot respond bot_first_act_raw = self.bot.act() bot_first_act_raw = Compatibility.maybe_fix_act(bot_first_act_raw) if 'metrics' in bot_first_act_raw: del bot_first_act_raw['metrics'] # Metrics can't be saved to JSON and are not needed here self.agent.observe(validate(bot_first_act_raw)) bot_first_act = { 'episode_done': False, 'id': bot_first_act_raw['id'], 'text': bot_first_act_raw['text'], 'agent_idx': 1, } # Record lines of dialogue self.dialog.append(image_act) self.dialog.append(bot_first_act)
[ "def", "_run_initial_turn", "(", "self", ")", "->", "None", ":", "system_id", "=", "'SYSTEM'", "system_agent_idx", "=", "None", "# Show the image to the human", "image_act_for_human", "=", "{", "'episode_done'", ":", "False", ",", "'id'", ":", "system_id", ",", "'text'", ":", "f\"\"\"Welcome! You'll now have a conversation with your partner.\n\n<-- FIRST, YOUR PARTNER WILL SAY SOMETHING ABOUT THIS IMAGE TO YOUR LEFT.\n\nBe sure to talk about this image a little bit before discussing other things!\n\"\"\"", ",", "'task_data'", ":", "{", "'image_src'", ":", "self", ".", "image_src", "}", ",", "'agent_idx'", ":", "system_agent_idx", ",", "}", "self", ".", "agent", ".", "observe", "(", "validate", "(", "image_act_for_human", ")", ")", "# Show the image to the bot", "image_act", "=", "{", "*", "*", "self", ".", "image_act", ",", "'episode_done'", ":", "False", ",", "'id'", ":", "system_id", ",", "'agent_idx'", ":", "system_agent_idx", ",", "}", "self", ".", "bot", ".", "observe", "(", "validate", "(", "image_act", ")", ")", "del", "image_act", "[", "'image'", "]", "# Don't save the image features to disk", "# Have the bot respond", "bot_first_act_raw", "=", "self", ".", "bot", ".", "act", "(", ")", "bot_first_act_raw", "=", "Compatibility", ".", "maybe_fix_act", "(", "bot_first_act_raw", ")", "if", "'metrics'", "in", "bot_first_act_raw", ":", "del", "bot_first_act_raw", "[", "'metrics'", "]", "# Metrics can't be saved to JSON and are not needed here", "self", ".", "agent", ".", "observe", "(", "validate", "(", "bot_first_act_raw", ")", ")", "bot_first_act", "=", "{", "'episode_done'", ":", "False", ",", "'id'", ":", "bot_first_act_raw", "[", "'id'", "]", ",", "'text'", ":", "bot_first_act_raw", "[", "'text'", "]", ",", "'agent_idx'", ":", "1", ",", "}", "# Record lines of dialogue", "self", ".", "dialog", ".", "append", "(", "image_act", ")", "self", ".", "dialog", ".", "append", "(", "bot_first_act", ")" ]
[ 41, 4 ]
[ 91, 41 ]
python
en
['en', 'error', 'th']
False
ModelImageChatWorld._postprocess_acts
(self, acts: List[Message], agent_idx: int)
Show the bot the image again on every turn.
Show the bot the image again on every turn.
def _postprocess_acts(self, acts: List[Message], agent_idx: int): """ Show the bot the image again on every turn. """ if agent_idx == 0: # Add the image to every human act, seen by the bot. Also adds in any other # image-related fields needed by the model for key, value in self.image_act.items(): if key not in ['episode_done', 'id', 'text', 'agent_idx']: acts[agent_idx].force_set(key, value)
[ "def", "_postprocess_acts", "(", "self", ",", "acts", ":", "List", "[", "Message", "]", ",", "agent_idx", ":", "int", ")", ":", "if", "agent_idx", "==", "0", ":", "# Add the image to every human act, seen by the bot. Also adds in any other", "# image-related fields needed by the model", "for", "key", ",", "value", "in", "self", ".", "image_act", ".", "items", "(", ")", ":", "if", "key", "not", "in", "[", "'episode_done'", ",", "'id'", ",", "'text'", ",", "'agent_idx'", "]", ":", "acts", "[", "agent_idx", "]", ".", "force_set", "(", "key", ",", "value", ")" ]
[ 93, 4 ]
[ 102, 57 ]
python
en
['en', 'error', 'th']
False
ModelImageChatWorld.get_final_chat_data
(self)
Add image-specific fields to the final chat data.
Add image-specific fields to the final chat data.
def get_final_chat_data(self) -> Dict[str, Any]: """ Add image-specific fields to the final chat data. """ data = super().get_final_chat_data() data['image_idx'] = self.image_idx return data
[ "def", "get_final_chat_data", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "data", "=", "super", "(", ")", ".", "get_final_chat_data", "(", ")", "data", "[", "'image_idx'", "]", "=", "self", ".", "image_idx", "return", "data" ]
[ 104, 4 ]
[ 110, 19 ]
python
en
['en', 'error', 'th']
False
ModelImageChatWorld._prepare_acceptability_checking
(self)
Apply acceptability checking params specific to image-chat conversation. The conversation starts with an image, so the human shouldn't be starting their first message with "Hi", etc.
Apply acceptability checking params specific to image-chat conversation.
def _prepare_acceptability_checking(self) -> Tuple[List[str], List[str]]: """ Apply acceptability checking params specific to image-chat conversation. The conversation starts with an image, so the human shouldn't be starting their first message with "Hi", etc. """ human_messages, violation_types = super()._prepare_acceptability_checking() violation_types.append('penalize_greetings') return human_messages, violation_types
[ "def", "_prepare_acceptability_checking", "(", "self", ")", "->", "Tuple", "[", "List", "[", "str", "]", ",", "List", "[", "str", "]", "]", ":", "human_messages", ",", "violation_types", "=", "super", "(", ")", ".", "_prepare_acceptability_checking", "(", ")", "violation_types", ".", "append", "(", "'penalize_greetings'", ")", "return", "human_messages", ",", "violation_types" ]
[ 112, 4 ]
[ 121, 46 ]
python
en
['en', 'error', 'th']
False
validate
(observation)
Make sure the observation table is valid, or raise an error.
Make sure the observation table is valid, or raise an error.
def validate(observation): """ Make sure the observation table is valid, or raise an error. """ if observation is not None and isinstance(observation, dict): return observation else: raise RuntimeError('Must return dictionary or Message object from act().')
[ "def", "validate", "(", "observation", ")", ":", "if", "observation", "is", "not", "None", "and", "isinstance", "(", "observation", ",", "dict", ")", ":", "return", "observation", "else", ":", "raise", "RuntimeError", "(", "'Must return dictionary or Message object from act().'", ")" ]
[ 54, 0 ]
[ 61, 82 ]
python
en
['en', 'error', 'th']
False
_override_opts_in_shared
(table, overrides)
Override all shared dicts. Looks recursively for ``opt`` dictionaries within shared dict and overrides any key- value pairs with pairs from the overrides dict.
Override all shared dicts.
def _override_opts_in_shared(table, overrides): """ Override all shared dicts. Looks recursively for ``opt`` dictionaries within shared dict and overrides any key- value pairs with pairs from the overrides dict. """ if 'opt' in table: # change values if an 'opt' dict is available for k, v in overrides.items(): table['opt'][k] = v for k, v in table.items(): # look for sub-dictionaries which also might contain an 'opt' dict if type(v) == dict and k != 'opt' and 'opt' in v: _override_opts_in_shared(v, overrides) elif type(v) == list: for item in v: if type(item) == dict and 'opt' in item: # if this is a list of agent shared dicts, we want to iterate _override_opts_in_shared(item, overrides) else: # if this is e.g. list of candidate strings, stop right away break return table
[ "def", "_override_opts_in_shared", "(", "table", ",", "overrides", ")", ":", "if", "'opt'", "in", "table", ":", "# change values if an 'opt' dict is available", "for", "k", ",", "v", "in", "overrides", ".", "items", "(", ")", ":", "table", "[", "'opt'", "]", "[", "k", "]", "=", "v", "for", "k", ",", "v", "in", "table", ".", "items", "(", ")", ":", "# look for sub-dictionaries which also might contain an 'opt' dict", "if", "type", "(", "v", ")", "==", "dict", "and", "k", "!=", "'opt'", "and", "'opt'", "in", "v", ":", "_override_opts_in_shared", "(", "v", ",", "overrides", ")", "elif", "type", "(", "v", ")", "==", "list", ":", "for", "item", "in", "v", ":", "if", "type", "(", "item", ")", "==", "dict", "and", "'opt'", "in", "item", ":", "# if this is a list of agent shared dicts, we want to iterate", "_override_opts_in_shared", "(", "item", ",", "overrides", ")", "else", ":", "# if this is e.g. list of candidate strings, stop right away", "break", "return", "table" ]
[ 717, 0 ]
[ 740, 16 ]
python
en
['en', 'error', 'th']
False
_create_task_agents
(opt: Opt)
Create task agent(s) for the given task name. It does this by calling the create_agent function in agents.py of the given task. If create_agents function does not exist, it just looks for the teacher (agent) class defined by the task name directly. (This saves the task creator bothering to define the create_agents function when it is not needed.)
Create task agent(s) for the given task name.
def _create_task_agents(opt: Opt): """ Create task agent(s) for the given task name. It does this by calling the create_agent function in agents.py of the given task. If create_agents function does not exist, it just looks for the teacher (agent) class defined by the task name directly. (This saves the task creator bothering to define the create_agents function when it is not needed.) """ if opt.get('interactive_task', False) or opt.get('selfchat_task', False): # do not need task agents in interactive or self chat settings return [] try: # Tries to call the create_agent function in agents.py my_module = load_task_module(opt['task']) task_agents = my_module.create_agents(opt) # type: ignore except (ModuleNotFoundError, AttributeError): # Create_agent not found, so try to create the teacher directly. return create_task_agent_from_taskname(opt) if type(task_agents) != list: task_agents = [task_agents] return task_agents
[ "def", "_create_task_agents", "(", "opt", ":", "Opt", ")", ":", "if", "opt", ".", "get", "(", "'interactive_task'", ",", "False", ")", "or", "opt", ".", "get", "(", "'selfchat_task'", ",", "False", ")", ":", "# do not need task agents in interactive or self chat settings", "return", "[", "]", "try", ":", "# Tries to call the create_agent function in agents.py", "my_module", "=", "load_task_module", "(", "opt", "[", "'task'", "]", ")", "task_agents", "=", "my_module", ".", "create_agents", "(", "opt", ")", "# type: ignore", "except", "(", "ModuleNotFoundError", ",", "AttributeError", ")", ":", "# Create_agent not found, so try to create the teacher directly.", "return", "create_task_agent_from_taskname", "(", "opt", ")", "if", "type", "(", "task_agents", ")", "!=", "list", ":", "task_agents", "=", "[", "task_agents", "]", "return", "task_agents" ]
[ 1195, 0 ]
[ 1217, 22 ]
python
en
['en', 'error', 'th']
False
create_task_world
(opt: Opt, user_agents, default_world=None)
Instantiate a world with the supplied options and user agents. (A world factory.)
Instantiate a world with the supplied options and user agents.
def create_task_world(opt: Opt, user_agents, default_world=None): """ Instantiate a world with the supplied options and user agents. (A world factory.) """ task_agents = _create_task_agents(opt) world_class = load_world_module( opt['task'], interactive_task=opt.get('interactive_task', False), selfchat_task=opt.get('selfchat_task', False), num_agents=len(user_agents + task_agents), default_world=default_world, ) return world_class(opt, task_agents + user_agents)
[ "def", "create_task_world", "(", "opt", ":", "Opt", ",", "user_agents", ",", "default_world", "=", "None", ")", ":", "task_agents", "=", "_create_task_agents", "(", "opt", ")", "world_class", "=", "load_world_module", "(", "opt", "[", "'task'", "]", ",", "interactive_task", "=", "opt", ".", "get", "(", "'interactive_task'", ",", "False", ")", ",", "selfchat_task", "=", "opt", ".", "get", "(", "'selfchat_task'", ",", "False", ")", ",", "num_agents", "=", "len", "(", "user_agents", "+", "task_agents", ")", ",", "default_world", "=", "default_world", ",", ")", "return", "world_class", "(", "opt", ",", "task_agents", "+", "user_agents", ")" ]
[ 1220, 0 ]
[ 1235, 54 ]
python
en
['en', 'error', 'th']
False
create_task
(opt: Opt, user_agents, default_world=None)
Create a world + task_agents (aka a task). Assuming ``opt['task']="task_dir:teacher_class:options"`` e.g. ``"babi:Task1k:1"`` or ``"#babi-1k"`` or ``"#QA"``, see ``parlai/tasks/tasks.py`` and see ``parlai/tasks/task_list.py`` for list of tasks.
Create a world + task_agents (aka a task).
def create_task(opt: Opt, user_agents, default_world=None): """ Create a world + task_agents (aka a task). Assuming ``opt['task']="task_dir:teacher_class:options"`` e.g. ``"babi:Task1k:1"`` or ``"#babi-1k"`` or ``"#QA"``, see ``parlai/tasks/tasks.py`` and see ``parlai/tasks/task_list.py`` for list of tasks. """ task = opt.get('task') if not task: raise RuntimeError( 'No task specified. Please select a task with ' + '--task {task_name}.' ) if type(user_agents) != list: user_agents = [user_agents] # Convert any hashtag task labels to task directory path names. # (e.g. "#QA" to the list of tasks that are QA tasks). opt = copy.deepcopy(opt) opt['task'] = ids_to_tasks(opt['task']) logging.info(f"creating task(s): {opt['task']}") if ',' not in opt['task']: # Single task world = create_task_world(opt, user_agents, default_world=default_world) else: # Multitask teacher/agent # TODO: remove and replace with multiteachers only? world = MultiWorld(opt, user_agents, default_world=default_world) if opt.get('batchsize', 1) > 1 and opt.get('dynamic_batching'): world = DynamicBatchWorld(opt, world) elif opt.get('batchsize', 1) > 1: # otherwise check if should use batchworld world = BatchWorld(opt, world) return world
[ "def", "create_task", "(", "opt", ":", "Opt", ",", "user_agents", ",", "default_world", "=", "None", ")", ":", "task", "=", "opt", ".", "get", "(", "'task'", ")", "if", "not", "task", ":", "raise", "RuntimeError", "(", "'No task specified. Please select a task with '", "+", "'--task {task_name}.'", ")", "if", "type", "(", "user_agents", ")", "!=", "list", ":", "user_agents", "=", "[", "user_agents", "]", "# Convert any hashtag task labels to task directory path names.", "# (e.g. \"#QA\" to the list of tasks that are QA tasks).", "opt", "=", "copy", ".", "deepcopy", "(", "opt", ")", "opt", "[", "'task'", "]", "=", "ids_to_tasks", "(", "opt", "[", "'task'", "]", ")", "logging", ".", "info", "(", "f\"creating task(s): {opt['task']}\"", ")", "if", "','", "not", "in", "opt", "[", "'task'", "]", ":", "# Single task", "world", "=", "create_task_world", "(", "opt", ",", "user_agents", ",", "default_world", "=", "default_world", ")", "else", ":", "# Multitask teacher/agent", "# TODO: remove and replace with multiteachers only?", "world", "=", "MultiWorld", "(", "opt", ",", "user_agents", ",", "default_world", "=", "default_world", ")", "if", "opt", ".", "get", "(", "'batchsize'", ",", "1", ")", ">", "1", "and", "opt", ".", "get", "(", "'dynamic_batching'", ")", ":", "world", "=", "DynamicBatchWorld", "(", "opt", ",", "world", ")", "elif", "opt", ".", "get", "(", "'batchsize'", ",", "1", ")", ">", "1", ":", "# otherwise check if should use batchworld", "world", "=", "BatchWorld", "(", "opt", ",", "world", ")", "return", "world" ]
[ 1238, 0 ]
[ 1274, 16 ]
python
en
['en', 'error', 'th']
False
World.parley
(self)
Perform one step of actions for the agents in the world. This is empty in the base class.
Perform one step of actions for the agents in the world.
def parley(self): """ Perform one step of actions for the agents in the world. This is empty in the base class. """ # TODO: mark as abstract? pass
[ "def", "parley", "(", "self", ")", ":", "# TODO: mark as abstract?", "pass" ]
[ 86, 4 ]
[ 93, 12 ]
python
en
['en', 'error', 'th']
False
World.getID
(self)
Return the name of the world, typically the task the world encodes.
Return the name of the world, typically the task the world encodes.
def getID(self): """ Return the name of the world, typically the task the world encodes. """ return self.id
[ "def", "getID", "(", "self", ")", ":", "return", "self", ".", "id" ]
[ 95, 4 ]
[ 99, 22 ]
python
en
['en', 'error', 'th']
False
World.display
(self)
Return a string describing the current state of the world. Useful for monitoring and debugging. By default, display the messages between the agents.
Return a string describing the current state of the world.
def display(self): """ Return a string describing the current state of the world. Useful for monitoring and debugging. By default, display the messages between the agents. """ if not hasattr(self, 'acts'): return '' return display_messages( self.acts, ignore_agent_reply=self.opt.get('ignore_agent_reply', False), add_fields=self.opt.get('display_add_fields', ''), prettify=self.opt.get('display_prettify', False), max_len=self.opt.get('max_display_len', 1000), verbose=self.opt.get('verbose', False), )
[ "def", "display", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'acts'", ")", ":", "return", "''", "return", "display_messages", "(", "self", ".", "acts", ",", "ignore_agent_reply", "=", "self", ".", "opt", ".", "get", "(", "'ignore_agent_reply'", ",", "False", ")", ",", "add_fields", "=", "self", ".", "opt", ".", "get", "(", "'display_add_fields'", ",", "''", ")", ",", "prettify", "=", "self", ".", "opt", ".", "get", "(", "'display_prettify'", ",", "False", ")", ",", "max_len", "=", "self", ".", "opt", ".", "get", "(", "'max_display_len'", ",", "1000", ")", ",", "verbose", "=", "self", ".", "opt", ".", "get", "(", "'verbose'", ",", "False", ")", ",", ")" ]
[ 101, 4 ]
[ 117, 9 ]
python
en
['en', 'error', 'th']
False
World.episode_done
(self)
Whether the episode is done or not.
Whether the episode is done or not.
def episode_done(self): """ Whether the episode is done or not. """ return False
[ "def", "episode_done", "(", "self", ")", ":", "return", "False" ]
[ 119, 4 ]
[ 123, 20 ]
python
en
['en', 'error', 'th']
False
World.epoch_done
(self)
Whether the epoch is done or not. Not all worlds have the notion of an epoch, but this is useful for fixed training, validation or test sets.
Whether the epoch is done or not.
def epoch_done(self): """ Whether the epoch is done or not. Not all worlds have the notion of an epoch, but this is useful for fixed training, validation or test sets. """ return False
[ "def", "epoch_done", "(", "self", ")", ":", "return", "False" ]
[ 125, 4 ]
[ 132, 20 ]
python
en
['en', 'error', 'th']
False
World.share
(self)
Share the world.
Share the world.
def share(self): """ Share the world. """ shared_data = {} shared_data['world_class'] = type(self) shared_data['opt'] = self.opt shared_data['agents'] = self._share_agents() return shared_data
[ "def", "share", "(", "self", ")", ":", "shared_data", "=", "{", "}", "shared_data", "[", "'world_class'", "]", "=", "type", "(", "self", ")", "shared_data", "[", "'opt'", "]", "=", "self", ".", "opt", "shared_data", "[", "'agents'", "]", "=", "self", ".", "_share_agents", "(", ")", "return", "shared_data" ]
[ 134, 4 ]
[ 142, 26 ]
python
en
['en', 'error', 'th']
False
World.clone
(self)
Create a duplicate of the world.
Create a duplicate of the world.
def clone(self): """ Create a duplicate of the world. """ return type(self)(opt=self.opt, agents=None, shared=self.share())
[ "def", "clone", "(", "self", ")", ":", "return", "type", "(", "self", ")", "(", "opt", "=", "self", ".", "opt", ",", "agents", "=", "None", ",", "shared", "=", "self", ".", "share", "(", ")", ")" ]
[ 144, 4 ]
[ 148, 73 ]
python
en
['en', 'error', 'th']
False
World._share_agents
(self)
Create shared data for agents. Allows other classes to create the same agents without duplicating the data (i.e. sharing parameters).
Create shared data for agents.
def _share_agents(self): """ Create shared data for agents. Allows other classes to create the same agents without duplicating the data (i.e. sharing parameters). """ if not hasattr(self, 'agents'): return None shared_agents = [a.share() for a in self.agents] return shared_agents
[ "def", "_share_agents", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'agents'", ")", ":", "return", "None", "shared_agents", "=", "[", "a", ".", "share", "(", ")", "for", "a", "in", "self", ".", "agents", "]", "return", "shared_agents" ]
[ 150, 4 ]
[ 160, 28 ]
python
en
['en', 'error', 'th']
False
World.get_agents
(self)
Return the list of agents.
Return the list of agents.
def get_agents(self): """ Return the list of agents. """ return self.agents
[ "def", "get_agents", "(", "self", ")", ":", "return", "self", ".", "agents" ]
[ 162, 4 ]
[ 166, 26 ]
python
en
['en', 'error', 'th']
False
World.get_task_agent
(self)
Return task agent, if applicable.
Return task agent, if applicable.
def get_task_agent(self): """ Return task agent, if applicable. """ raise NotImplementedError('Implement in subworld')
[ "def", "get_task_agent", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Implement in subworld'", ")" ]
[ 168, 4 ]
[ 172, 58 ]
python
en
['en', 'error', 'th']
False
World.get_model_agent
(self)
Return model agent, if applicable.
Return model agent, if applicable.
def get_model_agent(self): """ Return model agent, if applicable. """ raise NotImplementedError('Implement in subworld')
[ "def", "get_model_agent", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'Implement in subworld'", ")" ]
[ 174, 4 ]
[ 178, 58 ]
python
en
['en', 'error', 'th']
False
World.get_acts
(self)
Return the last act of each agent.
Return the last act of each agent.
def get_acts(self): """ Return the last act of each agent. """ return self.acts
[ "def", "get_acts", "(", "self", ")", ":", "return", "self", ".", "acts" ]
[ 180, 4 ]
[ 184, 24 ]
python
en
['en', 'error', 'th']
False
World.get_time
(self)
Return total training time.
Return total training time.
def get_time(self): """ Return total training time. """ return self.time.time()
[ "def", "get_time", "(", "self", ")", ":", "return", "self", ".", "time", ".", "time", "(", ")" ]
[ 186, 4 ]
[ 190, 31 ]
python
en
['en', 'error', 'th']
False
World.get_total_exs
(self)
Return total amount of examples seen by world.
Return total amount of examples seen by world.
def get_total_exs(self): """ Return total amount of examples seen by world. """ return self.total_exs
[ "def", "get_total_exs", "(", "self", ")", ":", "return", "self", ".", "total_exs" ]
[ 192, 4 ]
[ 196, 29 ]
python
en
['en', 'error', 'th']
False
World.get_total_epochs
(self)
Return total amount of epochs on which the world has trained.
Return total amount of epochs on which the world has trained.
def get_total_epochs(self): """ Return total amount of epochs on which the world has trained. """ return self.total_epochs
[ "def", "get_total_epochs", "(", "self", ")", ":", "return", "self", ".", "total_epochs" ]
[ 198, 4 ]
[ 202, 32 ]
python
en
['en', 'error', 'th']
False
World.get_total_parleys
(self)
Return total number of parleys.
Return total number of parleys.
def get_total_parleys(self): """ Return total number of parleys. """ return self.total_parleys
[ "def", "get_total_parleys", "(", "self", ")", ":", "return", "self", ".", "total_parleys" ]
[ 204, 4 ]
[ 208, 33 ]
python
en
['en', 'error', 'th']
False
World.__enter__
(self)
Empty enter provided for use with ``with`` statement. e.g: .. code-block:: python with World() as world: for n in range(10): n.parley()
Empty enter provided for use with ``with`` statement.
def __enter__(self): """ Empty enter provided for use with ``with`` statement. e.g: .. code-block:: python with World() as world: for n in range(10): n.parley() """ return self
[ "def", "__enter__", "(", "self", ")", ":", "return", "self" ]
[ 210, 4 ]
[ 222, 19 ]
python
en
['en', 'error', 'th']
False
World.__exit__
(self, exc_type, exc_value, exc_traceback)
After ``with`` statement, call shutdown.
After ``with`` statement, call shutdown.
def __exit__(self, exc_type, exc_value, exc_traceback): """ After ``with`` statement, call shutdown. """ self.shutdown() return False
[ "def", "__exit__", "(", "self", ",", "exc_type", ",", "exc_value", ",", "exc_traceback", ")", ":", "self", ".", "shutdown", "(", ")", "return", "False" ]
[ 224, 4 ]
[ 229, 20 ]
python
en
['en', 'error', 'th']
False
World.num_examples
(self)
Return the number of examples. Always 0 in the abstract world.
Return the number of examples.
def num_examples(self): """ Return the number of examples. Always 0 in the abstract world. """ # TODO: mark as abstract? return 0
[ "def", "num_examples", "(", "self", ")", ":", "# TODO: mark as abstract?", "return", "0" ]
[ 231, 4 ]
[ 238, 16 ]
python
en
['en', 'error', 'th']
False
World.num_episodes
(self)
Return the number of episodes. Always 0 in the abstract world.
Return the number of episodes.
def num_episodes(self): """ Return the number of episodes. Always 0 in the abstract world. """ # TODO: mark as abstract? return 0
[ "def", "num_episodes", "(", "self", ")", ":", "# TODO: mark as abstract?", "return", "0" ]
[ 240, 4 ]
[ 247, 16 ]
python
en
['en', 'error', 'th']
False
World.reset
(self)
Reset all agents in the world, and world statistics.
Reset all agents in the world, and world statistics.
def reset(self): """ Reset all agents in the world, and world statistics. """ for a in self.agents: a.reset() self.max_exs = None self.total_exs = 0 self.total_epochs = 0 self.total_parleys = 0 self.time.reset()
[ "def", "reset", "(", "self", ")", ":", "for", "a", "in", "self", ".", "agents", ":", "a", ".", "reset", "(", ")", "self", ".", "max_exs", "=", "None", "self", ".", "total_exs", "=", "0", "self", ".", "total_epochs", "=", "0", "self", ".", "total_parleys", "=", "0", "self", ".", "time", ".", "reset", "(", ")" ]
[ 249, 4 ]
[ 259, 25 ]
python
en
['en', 'error', 'th']
False
World.reset_metrics
(self)
Reset metrics for all agents.
Reset metrics for all agents.
def reset_metrics(self): """ Reset metrics for all agents. """ for a in self.agents: a.reset_metrics()
[ "def", "reset_metrics", "(", "self", ")", ":", "for", "a", "in", "self", ".", "agents", ":", "a", ".", "reset_metrics", "(", ")" ]
[ 261, 4 ]
[ 266, 29 ]
python
en
['en', 'error', 'th']
False
World.shutdown
(self)
Perform any cleanup, if appropriate.
Perform any cleanup, if appropriate.
def shutdown(self): """ Perform any cleanup, if appropriate. """ pass
[ "def", "shutdown", "(", "self", ")", ":", "pass" ]
[ 268, 4 ]
[ 272, 12 ]
python
en
['en', 'error', 'th']
False
World.update_counters
(self)
Update how many epochs have completed.
Update how many epochs have completed.
def update_counters(self): """ Update how many epochs have completed. """ self.total_parleys += 1 if self.max_exs is None: if 'num_epochs' in self.opt and self.opt['num_epochs'] > 0: if self.num_examples: self.max_exs = self.num_examples() * self.opt['num_epochs'] else: self.max_exs = -1 else: self.max_exs = -1 # when we know the size of the data if self.max_exs > 0 or self.num_examples(): self.total_epochs = ( self.total_parleys * self.opt.get('batchsize', 1) / self.num_examples() ) # when we do not know the size of the data else: if self.epoch_done(): self.total_epochs += 1
[ "def", "update_counters", "(", "self", ")", ":", "self", ".", "total_parleys", "+=", "1", "if", "self", ".", "max_exs", "is", "None", ":", "if", "'num_epochs'", "in", "self", ".", "opt", "and", "self", ".", "opt", "[", "'num_epochs'", "]", ">", "0", ":", "if", "self", ".", "num_examples", ":", "self", ".", "max_exs", "=", "self", ".", "num_examples", "(", ")", "*", "self", ".", "opt", "[", "'num_epochs'", "]", "else", ":", "self", ".", "max_exs", "=", "-", "1", "else", ":", "self", ".", "max_exs", "=", "-", "1", "# when we know the size of the data", "if", "self", ".", "max_exs", ">", "0", "or", "self", ".", "num_examples", "(", ")", ":", "self", ".", "total_epochs", "=", "(", "self", ".", "total_parleys", "*", "self", ".", "opt", ".", "get", "(", "'batchsize'", ",", "1", ")", "/", "self", ".", "num_examples", "(", ")", ")", "# when we do not know the size of the data", "else", ":", "if", "self", ".", "epoch_done", "(", ")", ":", "self", ".", "total_epochs", "+=", "1" ]
[ 274, 4 ]
[ 295, 38 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.get_task_agent
(self)
Return task agent.
Return task agent.
def get_task_agent(self): """ Return task agent. """ return self.get_agents()[0]
[ "def", "get_task_agent", "(", "self", ")", ":", "return", "self", ".", "get_agents", "(", ")", "[", "0", "]" ]
[ 323, 4 ]
[ 327, 35 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.get_model_agent
(self)
Return model agent, if applicable.
Return model agent, if applicable.
def get_model_agent(self): """ Return model agent, if applicable. """ return self.get_agents()[1]
[ "def", "get_model_agent", "(", "self", ")", ":", "return", "self", ".", "get_agents", "(", ")", "[", "1", "]" ]
[ 329, 4 ]
[ 333, 35 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.parley
(self)
Agent 0 goes first. Alternate between the two agents.
Agent 0 goes first.
def parley(self): """ Agent 0 goes first. Alternate between the two agents. """ acts = self.acts agents = self.agents acts[0] = agents[0].act() agents[1].observe(validate(acts[0])) acts[1] = agents[1].act() agents[0].observe(validate(acts[1])) self.update_counters()
[ "def", "parley", "(", "self", ")", ":", "acts", "=", "self", ".", "acts", "agents", "=", "self", ".", "agents", "acts", "[", "0", "]", "=", "agents", "[", "0", "]", ".", "act", "(", ")", "agents", "[", "1", "]", ".", "observe", "(", "validate", "(", "acts", "[", "0", "]", ")", ")", "acts", "[", "1", "]", "=", "agents", "[", "1", "]", ".", "act", "(", ")", "agents", "[", "0", "]", ".", "observe", "(", "validate", "(", "acts", "[", "1", "]", ")", ")", "self", ".", "update_counters", "(", ")" ]
[ 335, 4 ]
[ 347, 30 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.episode_done
(self)
Only the first agent indicates when the episode is done.
Only the first agent indicates when the episode is done.
def episode_done(self): """ Only the first agent indicates when the episode is done. """ if self.acts[0] is not None: return self.acts[0].get('episode_done', False) else: return False
[ "def", "episode_done", "(", "self", ")", ":", "if", "self", ".", "acts", "[", "0", "]", "is", "not", "None", ":", "return", "self", ".", "acts", "[", "0", "]", ".", "get", "(", "'episode_done'", ",", "False", ")", "else", ":", "return", "False" ]
[ 349, 4 ]
[ 356, 24 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.epoch_done
(self)
Only the first agent indicates when the epoch is done.
Only the first agent indicates when the epoch is done.
def epoch_done(self): """ Only the first agent indicates when the epoch is done. """ return self.get_task_agent().epoch_done()
[ "def", "epoch_done", "(", "self", ")", ":", "return", "self", ".", "get_task_agent", "(", ")", ".", "epoch_done", "(", ")" ]
[ 358, 4 ]
[ 362, 49 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.report
(self)
Report all metrics of all subagents.
Report all metrics of all subagents.
def report(self): """ Report all metrics of all subagents. """ from parlai.core.metrics import Metric, LegacyMetric metrics = {} for a in self.agents: if hasattr(a, 'report'): m = a.report() for k, v in m.items(): if not isinstance(v, Metric): v = LegacyMetric(v) if k not in metrics: # first agent gets priority in settings values for keys # this way model can't e.g. override accuracy to 100% metrics[k] = v if metrics and 'exs' in metrics: self.total_exs += metrics['exs'].value() return metrics
[ "def", "report", "(", "self", ")", ":", "from", "parlai", ".", "core", ".", "metrics", "import", "Metric", ",", "LegacyMetric", "metrics", "=", "{", "}", "for", "a", "in", "self", ".", "agents", ":", "if", "hasattr", "(", "a", ",", "'report'", ")", ":", "m", "=", "a", ".", "report", "(", ")", "for", "k", ",", "v", "in", "m", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "v", ",", "Metric", ")", ":", "v", "=", "LegacyMetric", "(", "v", ")", "if", "k", "not", "in", "metrics", ":", "# first agent gets priority in settings values for keys", "# this way model can't e.g. override accuracy to 100%", "metrics", "[", "k", "]", "=", "v", "if", "metrics", "and", "'exs'", "in", "metrics", ":", "self", ".", "total_exs", "+=", "metrics", "[", "'exs'", "]", ".", "value", "(", ")", "return", "metrics" ]
[ 364, 4 ]
[ 383, 22 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.num_examples
(self)
Return number of examples.
Return number of examples.
def num_examples(self): """ Return number of examples. """ if hasattr(self.get_task_agent(), 'num_examples'): return self.get_task_agent().num_examples() return 0
[ "def", "num_examples", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "get_task_agent", "(", ")", ",", "'num_examples'", ")", ":", "return", "self", ".", "get_task_agent", "(", ")", ".", "num_examples", "(", ")", "return", "0" ]
[ 385, 4 ]
[ 391, 16 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.num_episodes
(self)
Return number of episodes.
Return number of episodes.
def num_episodes(self): """ Return number of episodes. """ if hasattr(self.get_task_agent(), 'num_episodes'): return self.get_task_agent().num_episodes() return 0
[ "def", "num_episodes", "(", "self", ")", ":", "if", "hasattr", "(", "self", ".", "get_task_agent", "(", ")", ",", "'num_episodes'", ")", ":", "return", "self", ".", "get_task_agent", "(", ")", ".", "num_episodes", "(", ")", "return", "0" ]
[ 393, 4 ]
[ 399, 16 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.shutdown
(self)
Shutdown each agent.
Shutdown each agent.
def shutdown(self): """ Shutdown each agent. """ for a in self.agents: a.shutdown()
[ "def", "shutdown", "(", "self", ")", ":", "for", "a", "in", "self", ".", "agents", ":", "a", ".", "shutdown", "(", ")" ]
[ 401, 4 ]
[ 406, 24 ]
python
en
['en', 'error', 'th']
False
DialogPartnerWorld.update_counters
(self)
Ensure all counters are synchronized across threads.
Ensure all counters are synchronized across threads.
def update_counters(self): """ Ensure all counters are synchronized across threads. """ super().update_counters() for a in self.agents: if hasattr(a, 'update_counters'): a.update_counters()
[ "def", "update_counters", "(", "self", ")", ":", "super", "(", ")", ".", "update_counters", "(", ")", "for", "a", "in", "self", ".", "agents", ":", "if", "hasattr", "(", "a", ",", "'update_counters'", ")", ":", "a", ".", "update_counters", "(", ")" ]
[ 408, 4 ]
[ 415, 35 ]
python
en
['en', 'error', 'th']
False
MultiAgentDialogWorld.parley
(self)
Perform a turn for every agent. For each agent, get an observation of the last action each of the other agents took. Then take an action yourself.
Perform a turn for every agent.
def parley(self): """ Perform a turn for every agent. For each agent, get an observation of the last action each of the other agents took. Then take an action yourself. """ acts = self.acts for index, agent in enumerate(self.agents): acts[index] = agent.act() for other_agent in self.agents: if other_agent != agent: other_agent.observe(validate(acts[index])) self.update_counters()
[ "def", "parley", "(", "self", ")", ":", "acts", "=", "self", ".", "acts", "for", "index", ",", "agent", "in", "enumerate", "(", "self", ".", "agents", ")", ":", "acts", "[", "index", "]", "=", "agent", ".", "act", "(", ")", "for", "other_agent", "in", "self", ".", "agents", ":", "if", "other_agent", "!=", "agent", ":", "other_agent", ".", "observe", "(", "validate", "(", "acts", "[", "index", "]", ")", ")", "self", ".", "update_counters", "(", ")" ]
[ 435, 4 ]
[ 448, 30 ]
python
en
['en', 'error', 'th']
False
MultiAgentDialogWorld.get_task_agent
(self)
Return task agent.
Return task agent.
def get_task_agent(self): """ Return task agent. """ return self.get_agents()[0]
[ "def", "get_task_agent", "(", "self", ")", ":", "return", "self", ".", "get_agents", "(", ")", "[", "0", "]" ]
[ 450, 4 ]
[ 454, 35 ]
python
en
['en', 'error', 'th']
False
MultiAgentDialogWorld.get_model_agent
(self)
Return model agent.
Return model agent.
def get_model_agent(self): """ Return model agent. """ return self.get_agents()[1]
[ "def", "get_model_agent", "(", "self", ")", ":", "return", "self", ".", "get_agents", "(", ")", "[", "1", "]" ]
[ 456, 4 ]
[ 460, 35 ]
python
en
['en', 'error', 'th']
False
MultiAgentDialogWorld.epoch_done
(self)
Return if the epoch is done for any subagent.
Return if the epoch is done for any subagent.
def epoch_done(self): """ Return if the epoch is done for any subagent. """ done = False for a in self.agents: if a.epoch_done(): done = True return done
[ "def", "epoch_done", "(", "self", ")", ":", "done", "=", "False", "for", "a", "in", "self", ".", "agents", ":", "if", "a", ".", "epoch_done", "(", ")", ":", "done", "=", "True", "return", "done" ]
[ 462, 4 ]
[ 470, 19 ]
python
en
['en', 'error', 'th']
False
MultiAgentDialogWorld.episode_done
(self)
Return if the episode is done for any subagent.
Return if the episode is done for any subagent.
def episode_done(self): """ Return if the episode is done for any subagent. """ done = False for a in self.agents: if a.episode_done(): done = True return done
[ "def", "episode_done", "(", "self", ")", ":", "done", "=", "False", "for", "a", "in", "self", ".", "agents", ":", "if", "a", ".", "episode_done", "(", ")", ":", "done", "=", "True", "return", "done" ]
[ 472, 4 ]
[ 480, 19 ]
python
en
['en', 'error', 'th']
False