Search is not available for this dataset
identifier
stringlengths 1
155
| parameters
stringlengths 2
6.09k
| docstring
stringlengths 11
63.4k
| docstring_summary
stringlengths 0
63.4k
| function
stringlengths 29
99.8k
| function_tokens
list | start_point
list | end_point
list | language
stringclasses 1
value | docstring_language
stringlengths 2
7
| docstring_language_predictions
stringlengths 18
23
| is_langid_reliable
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|---|---|---|
Scatterpolar.subplot | (self) |
Sets a reference between this trace's data coordinates and a
polar subplot. If "polar" (the default value), the data refer
to `layout.polar`. If "polar2", the data refer to
`layout.polar2`, and so on.
The 'subplot' property is an identifier of a particular
subplot, of type 'polar', that may be specified as the string 'polar'
optionally followed by an integer >= 1
(e.g. 'polar', 'polar1', 'polar2', 'polar3', etc.)
Returns
-------
str
|
Sets a reference between this trace's data coordinates and a
polar subplot. If "polar" (the default value), the data refer
to `layout.polar`. If "polar2", the data refer to
`layout.polar2`, and so on.
The 'subplot' property is an identifier of a particular
subplot, of type 'polar', that may be specified as the string 'polar'
optionally followed by an integer >= 1
(e.g. 'polar', 'polar1', 'polar2', 'polar3', etc.) | def subplot(self):
"""
Sets a reference between this trace's data coordinates and a
polar subplot. If "polar" (the default value), the data refer
to `layout.polar`. If "polar2", the data refer to
`layout.polar2`, and so on.
The 'subplot' property is an identifier of a particular
subplot, of type 'polar', that may be specified as the string 'polar'
optionally followed by an integer >= 1
(e.g. 'polar', 'polar1', 'polar2', 'polar3', etc.)
Returns
-------
str
"""
return self["subplot"] | [
"def",
"subplot",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"subplot\"",
"]"
] | [
1078,
4
] | [
1094,
30
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.text | (self) |
Sets text elements associated with each (x,y) pair. If a single
string, the same string appears over all the data points. If an
array of string, the items are mapped in order to the this
trace's (x,y) coordinates. If trace `hoverinfo` contains a
"text" flag and "hovertext" is not set, these elements will be
seen in the hover labels.
The 'text' property is a string and must be specified as:
- A string
- A number that will be converted to a string
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
str|numpy.ndarray
|
Sets text elements associated with each (x,y) pair. If a single
string, the same string appears over all the data points. If an
array of string, the items are mapped in order to the this
trace's (x,y) coordinates. If trace `hoverinfo` contains a
"text" flag and "hovertext" is not set, these elements will be
seen in the hover labels.
The 'text' property is a string and must be specified as:
- A string
- A number that will be converted to a string
- A tuple, list, or one-dimensional numpy array of the above | def text(self):
"""
Sets text elements associated with each (x,y) pair. If a single
string, the same string appears over all the data points. If an
array of string, the items are mapped in order to the this
trace's (x,y) coordinates. If trace `hoverinfo` contains a
"text" flag and "hovertext" is not set, these elements will be
seen in the hover labels.
The 'text' property is a string and must be specified as:
- A string
- A number that will be converted to a string
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
str|numpy.ndarray
"""
return self["text"] | [
"def",
"text",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"text\"",
"]"
] | [
1103,
4
] | [
1121,
27
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.textfont | (self) |
Sets the text font.
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolar.Textfont`
- A dict of string/value properties that will be passed
to the Textfont 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.scatterpolar.Textfont
|
Sets the text font.
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolar.Textfont`
- A dict of string/value properties that will be passed
to the Textfont 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 textfont(self):
"""
Sets the text font.
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolar.Textfont`
- A dict of string/value properties that will be passed
to the Textfont 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.scatterpolar.Textfont
"""
return self["textfont"] | [
"def",
"textfont",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"textfont\"",
"]"
] | [
1130,
4
] | [
1177,
31
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.textposition | (self) |
Sets the positions of the `text` elements with respects to the
(x,y) coordinates.
The 'textposition' property is an enumeration that may be specified as:
- One of the following enumeration values:
['top left', 'top center', 'top right', 'middle left',
'middle center', 'middle right', 'bottom left', 'bottom
center', 'bottom right']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
|
Sets the positions of the `text` elements with respects to the
(x,y) coordinates.
The 'textposition' property is an enumeration that may be specified as:
- One of the following enumeration values:
['top left', 'top center', 'top right', 'middle left',
'middle center', 'middle right', 'bottom left', 'bottom
center', 'bottom right']
- A tuple, list, or one-dimensional numpy array of the above | def textposition(self):
"""
Sets the positions of the `text` elements with respects to the
(x,y) coordinates.
The 'textposition' property is an enumeration that may be specified as:
- One of the following enumeration values:
['top left', 'top center', 'top right', 'middle left',
'middle center', 'middle right', 'bottom left', 'bottom
center', 'bottom right']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
"""
return self["textposition"] | [
"def",
"textposition",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"textposition\"",
"]"
] | [
1186,
4
] | [
1202,
35
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.textpositionsrc | (self) |
Sets the source reference on Chart Studio Cloud for
textposition .
The 'textpositionsrc' 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
textposition .
The 'textpositionsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def textpositionsrc(self):
"""
Sets the source reference on Chart Studio Cloud for
textposition .
The 'textpositionsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["textpositionsrc"] | [
"def",
"textpositionsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"textpositionsrc\"",
"]"
] | [
1211,
4
] | [
1223,
38
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.textsrc | (self) |
Sets the source reference on Chart Studio Cloud for text .
The 'textsrc' 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 text .
The 'textsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def textsrc(self):
"""
Sets the source reference on Chart Studio Cloud for text .
The 'textsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["textsrc"] | [
"def",
"textsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"textsrc\"",
"]"
] | [
1232,
4
] | [
1243,
30
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.texttemplate | (self) |
Template string used for rendering the information text that
appear on points. Note that this will override `textinfo`.
Variables are inserted using %{variable}, for example "y:
%{y}". Numbers are formatted using d3-format's syntax
%{variable:d3-format}, for example "Price: %{y:$.2f}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for details on
the formatting syntax. Dates are formatted using d3-time-
format's syntax %{variable|d3-time-format}, for example "Day:
%{2019-01-01|%A}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for details on
the date formatting syntax. Every attributes that can be
specified per-point (the ones that are `arrayOk: true`) are
available. variables `r`, `theta` and `text`.
The 'texttemplate' property is a string and must be specified as:
- A string
- A number that will be converted to a string
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
str|numpy.ndarray
|
Template string used for rendering the information text that
appear on points. Note that this will override `textinfo`.
Variables are inserted using %{variable}, for example "y:
%{y}". Numbers are formatted using d3-format's syntax
%{variable:d3-format}, for example "Price: %{y:$.2f}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for details on
the formatting syntax. Dates are formatted using d3-time-
format's syntax %{variable|d3-time-format}, for example "Day:
%{2019-01-01|%A}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for details on
the date formatting syntax. Every attributes that can be
specified per-point (the ones that are `arrayOk: true`) are
available. variables `r`, `theta` and `text`.
The 'texttemplate' property is a string and must be specified as:
- A string
- A number that will be converted to a string
- A tuple, list, or one-dimensional numpy array of the above | def texttemplate(self):
"""
Template string used for rendering the information text that
appear on points. Note that this will override `textinfo`.
Variables are inserted using %{variable}, for example "y:
%{y}". Numbers are formatted using d3-format's syntax
%{variable:d3-format}, for example "Price: %{y:$.2f}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for details on
the formatting syntax. Dates are formatted using d3-time-
format's syntax %{variable|d3-time-format}, for example "Day:
%{2019-01-01|%A}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for details on
the date formatting syntax. Every attributes that can be
specified per-point (the ones that are `arrayOk: true`) are
available. variables `r`, `theta` and `text`.
The 'texttemplate' property is a string and must be specified as:
- A string
- A number that will be converted to a string
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
str|numpy.ndarray
"""
return self["texttemplate"] | [
"def",
"texttemplate",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"texttemplate\"",
"]"
] | [
1252,
4
] | [
1278,
35
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.texttemplatesrc | (self) |
Sets the source reference on Chart Studio Cloud for
texttemplate .
The 'texttemplatesrc' 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
texttemplate .
The 'texttemplatesrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def texttemplatesrc(self):
"""
Sets the source reference on Chart Studio Cloud for
texttemplate .
The 'texttemplatesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["texttemplatesrc"] | [
"def",
"texttemplatesrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"texttemplatesrc\"",
"]"
] | [
1287,
4
] | [
1299,
38
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.theta | (self) |
Sets the angular coordinates
The 'theta' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series
Returns
-------
numpy.ndarray
|
Sets the angular coordinates
The 'theta' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series | def theta(self):
"""
Sets the angular coordinates
The 'theta' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series
Returns
-------
numpy.ndarray
"""
return self["theta"] | [
"def",
"theta",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"theta\"",
"]"
] | [
1308,
4
] | [
1319,
28
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.theta0 | (self) |
Alternate to `theta`. Builds a linear space of theta
coordinates. Use with `dtheta` where `theta0` is the starting
coordinate and `dtheta` the step.
The 'theta0' property accepts values of any type
Returns
-------
Any
|
Alternate to `theta`. Builds a linear space of theta
coordinates. Use with `dtheta` where `theta0` is the starting
coordinate and `dtheta` the step.
The 'theta0' property accepts values of any type | def theta0(self):
"""
Alternate to `theta`. Builds a linear space of theta
coordinates. Use with `dtheta` where `theta0` is the starting
coordinate and `dtheta` the step.
The 'theta0' property accepts values of any type
Returns
-------
Any
"""
return self["theta0"] | [
"def",
"theta0",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"theta0\"",
"]"
] | [
1328,
4
] | [
1340,
29
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.thetasrc | (self) |
Sets the source reference on Chart Studio Cloud for theta .
The 'thetasrc' 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 theta .
The 'thetasrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def thetasrc(self):
"""
Sets the source reference on Chart Studio Cloud for theta .
The 'thetasrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["thetasrc"] | [
"def",
"thetasrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"thetasrc\"",
"]"
] | [
1349,
4
] | [
1360,
31
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.thetaunit | (self) |
Sets the unit of input "theta" values. Has an effect only when
on "linear" angular axes.
The 'thetaunit' property is an enumeration that may be specified as:
- One of the following enumeration values:
['radians', 'degrees', 'gradians']
Returns
-------
Any
|
Sets the unit of input "theta" values. Has an effect only when
on "linear" angular axes.
The 'thetaunit' property is an enumeration that may be specified as:
- One of the following enumeration values:
['radians', 'degrees', 'gradians'] | def thetaunit(self):
"""
Sets the unit of input "theta" values. Has an effect only when
on "linear" angular axes.
The 'thetaunit' property is an enumeration that may be specified as:
- One of the following enumeration values:
['radians', 'degrees', 'gradians']
Returns
-------
Any
"""
return self["thetaunit"] | [
"def",
"thetaunit",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"thetaunit\"",
"]"
] | [
1369,
4
] | [
1382,
32
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.uid | (self) |
Assign an id to this trace, Use this to provide object
constancy between traces during animations and transitions.
The 'uid' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
|
Assign an id to this trace, Use this to provide object
constancy between traces during animations and transitions.
The 'uid' property is a string and must be specified as:
- A string
- A number that will be converted to a string | def uid(self):
"""
Assign an id to this trace, Use this to provide object
constancy between traces during animations and transitions.
The 'uid' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
"""
return self["uid"] | [
"def",
"uid",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"uid\"",
"]"
] | [
1391,
4
] | [
1404,
26
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.uirevision | (self) |
Controls persistence of some user-driven changes to the trace:
`constraintrange` in `parcoords` traces, as well as some
`editable: true` modifications such as `name` and
`colorbar.title`. Defaults to `layout.uirevision`. Note that
other user-driven trace attribute changes are controlled by
`layout` attributes: `trace.visible` is controlled by
`layout.legend.uirevision`, `selectedpoints` is controlled by
`layout.selectionrevision`, and `colorbar.(x|y)` (accessible
with `config: {editable: true}`) is controlled by
`layout.editrevision`. Trace changes are tracked by `uid`,
which only falls back on trace index if no `uid` is provided.
So if your app can add/remove traces before the end of the
`data` array, such that the same trace has a different index,
you can still preserve user-driven changes if you give each
trace a `uid` that stays with it as it moves.
The 'uirevision' property accepts values of any type
Returns
-------
Any
|
Controls persistence of some user-driven changes to the trace:
`constraintrange` in `parcoords` traces, as well as some
`editable: true` modifications such as `name` and
`colorbar.title`. Defaults to `layout.uirevision`. Note that
other user-driven trace attribute changes are controlled by
`layout` attributes: `trace.visible` is controlled by
`layout.legend.uirevision`, `selectedpoints` is controlled by
`layout.selectionrevision`, and `colorbar.(x|y)` (accessible
with `config: {editable: true}`) is controlled by
`layout.editrevision`. Trace changes are tracked by `uid`,
which only falls back on trace index if no `uid` is provided.
So if your app can add/remove traces before the end of the
`data` array, such that the same trace has a different index,
you can still preserve user-driven changes if you give each
trace a `uid` that stays with it as it moves.
The 'uirevision' property accepts values of any type | def uirevision(self):
"""
Controls persistence of some user-driven changes to the trace:
`constraintrange` in `parcoords` traces, as well as some
`editable: true` modifications such as `name` and
`colorbar.title`. Defaults to `layout.uirevision`. Note that
other user-driven trace attribute changes are controlled by
`layout` attributes: `trace.visible` is controlled by
`layout.legend.uirevision`, `selectedpoints` is controlled by
`layout.selectionrevision`, and `colorbar.(x|y)` (accessible
with `config: {editable: true}`) is controlled by
`layout.editrevision`. Trace changes are tracked by `uid`,
which only falls back on trace index if no `uid` is provided.
So if your app can add/remove traces before the end of the
`data` array, such that the same trace has a different index,
you can still preserve user-driven changes if you give each
trace a `uid` that stays with it as it moves.
The 'uirevision' property accepts values of any type
Returns
-------
Any
"""
return self["uirevision"] | [
"def",
"uirevision",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"uirevision\"",
"]"
] | [
1413,
4
] | [
1437,
33
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.unselected | (self) |
The 'unselected' property is an instance of Unselected
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolar.Unselected`
- A dict of string/value properties that will be passed
to the Unselected constructor
Supported dict properties:
marker
:class:`plotly.graph_objects.scatterpolar.unsel
ected.Marker` instance or dict with compatible
properties
textfont
:class:`plotly.graph_objects.scatterpolar.unsel
ected.Textfont` instance or dict with
compatible properties
Returns
-------
plotly.graph_objs.scatterpolar.Unselected
|
The 'unselected' property is an instance of Unselected
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolar.Unselected`
- A dict of string/value properties that will be passed
to the Unselected constructor
Supported dict properties:
marker
:class:`plotly.graph_objects.scatterpolar.unsel
ected.Marker` instance or dict with compatible
properties
textfont
:class:`plotly.graph_objects.scatterpolar.unsel
ected.Textfont` instance or dict with
compatible properties | def unselected(self):
"""
The 'unselected' property is an instance of Unselected
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolar.Unselected`
- A dict of string/value properties that will be passed
to the Unselected constructor
Supported dict properties:
marker
:class:`plotly.graph_objects.scatterpolar.unsel
ected.Marker` instance or dict with compatible
properties
textfont
:class:`plotly.graph_objects.scatterpolar.unsel
ected.Textfont` instance or dict with
compatible properties
Returns
-------
plotly.graph_objs.scatterpolar.Unselected
"""
return self["unselected"] | [
"def",
"unselected",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"unselected\"",
"]"
] | [
1446,
4
] | [
1469,
33
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.visible | (self) |
Determines whether or not this trace is visible. If
"legendonly", the trace is not drawn, but can appear as a
legend item (provided that the legend itself is visible).
The 'visible' property is an enumeration that may be specified as:
- One of the following enumeration values:
[True, False, 'legendonly']
Returns
-------
Any
|
Determines whether or not this trace is visible. If
"legendonly", the trace is not drawn, but can appear as a
legend item (provided that the legend itself is visible).
The 'visible' property is an enumeration that may be specified as:
- One of the following enumeration values:
[True, False, 'legendonly'] | def visible(self):
"""
Determines whether or not this trace is visible. If
"legendonly", the trace is not drawn, but can appear as a
legend item (provided that the legend itself is visible).
The 'visible' property is an enumeration that may be specified as:
- One of the following enumeration values:
[True, False, 'legendonly']
Returns
-------
Any
"""
return self["visible"] | [
"def",
"visible",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"visible\"",
"]"
] | [
1478,
4
] | [
1492,
30
] | python | en | ['en', 'error', 'th'] | False |
Scatterpolar.__init__ | (
self,
arg=None,
cliponaxis=None,
connectgaps=None,
customdata=None,
customdatasrc=None,
dr=None,
dtheta=None,
fill=None,
fillcolor=None,
hoverinfo=None,
hoverinfosrc=None,
hoverlabel=None,
hoveron=None,
hovertemplate=None,
hovertemplatesrc=None,
hovertext=None,
hovertextsrc=None,
ids=None,
idssrc=None,
legendgroup=None,
line=None,
marker=None,
meta=None,
metasrc=None,
mode=None,
name=None,
opacity=None,
r=None,
r0=None,
rsrc=None,
selected=None,
selectedpoints=None,
showlegend=None,
stream=None,
subplot=None,
text=None,
textfont=None,
textposition=None,
textpositionsrc=None,
textsrc=None,
texttemplate=None,
texttemplatesrc=None,
theta=None,
theta0=None,
thetasrc=None,
thetaunit=None,
uid=None,
uirevision=None,
unselected=None,
visible=None,
**kwargs
) |
Construct a new Scatterpolar object
The scatterpolar trace type encompasses line charts, scatter
charts, text charts, and bubble charts in polar coordinates.
The data visualized as scatter point or lines is set in `r`
(radial) and `theta` (angular) coordinates Text (appearing
either on the chart or on hover only) is via `text`. Bubble
charts are achieved by setting `marker.size` and/or
`marker.color` to numerical arrays.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.Scatterpolar`
cliponaxis
Determines whether or not markers and text nodes are
clipped about the subplot axes. To show markers and
text nodes above axis lines and tick labels, make sure
to set `xaxis.layer` and `yaxis.layer` to *below
traces*.
connectgaps
Determines whether or not gaps (i.e. {nan} or missing
values) in the provided data arrays are connected.
customdata
Assigns extra data each datum. This may be useful when
listening to hover, click and selection events. Note
that, "scatter" traces also appends customdata items in
the markers DOM elements
customdatasrc
Sets the source reference on Chart Studio Cloud for
customdata .
dr
Sets the r coordinate step.
dtheta
Sets the theta coordinate step. By default, the
`dtheta` step equals the subplot's period divided by
the length of the `r` coordinates.
fill
Sets the area to fill with a solid color. Use with
`fillcolor` if not "none". scatterpolar has a subset of
the options available to scatter. "toself" connects the
endpoints of the trace (or each segment of the trace if
it has gaps) into a closed shape. "tonext" fills the
space between two traces if one completely encloses the
other (eg consecutive contour lines), and behaves like
"toself" if there is no trace before it. "tonext"
should not be used if one trace does not enclose the
other.
fillcolor
Sets the fill color. Defaults to a half-transparent
variant of the line color, marker color, or marker line
color, whichever is available.
hoverinfo
Determines which trace information appear on hover. If
`none` or `skip` are set, no information is displayed
upon hovering. But, if `none` is set, click and hover
events are still fired.
hoverinfosrc
Sets the source reference on Chart Studio Cloud for
hoverinfo .
hoverlabel
:class:`plotly.graph_objects.scatterpolar.Hoverlabel`
instance or dict with compatible properties
hoveron
Do the hover effects highlight individual points
(markers or line points) or do they highlight filled
regions? If the fill is "toself" or "tonext" and there
are no markers or text, then the default is "fills",
otherwise it is "points".
hovertemplate
Template string used for rendering the information that
appear on hover box. Note that this will override
`hoverinfo`. Variables are inserted using %{variable},
for example "y: %{y}". Numbers are formatted using
d3-format's syntax %{variable:d3-format}, for example
"Price: %{y:$.2f}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for
details on the formatting syntax. Dates are formatted
using d3-time-format's syntax %{variable|d3-time-
format}, for example "Day: %{2019-01-01|%A}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for
details on the date formatting syntax. The variables
available in `hovertemplate` are the ones emitted as
event data described at this link
https://plotly.com/javascript/plotlyjs-events/#event-
data. Additionally, every attributes that can be
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
hovertemplate .
hovertext
Sets hover text elements associated with each (x,y)
pair. If a single string, the same string appears over
all the data points. If an array of string, the items
are mapped in order to the this trace's (x,y)
coordinates. To be seen, trace `hoverinfo` must contain
a "text" flag.
hovertextsrc
Sets the source reference on Chart Studio Cloud for
hovertext .
ids
Assigns id labels to each datum. These ids for object
constancy of data points during animation. Should be an
array of strings, not numbers or any other type.
idssrc
Sets the source reference on Chart Studio Cloud for
ids .
legendgroup
Sets the legend group for this trace. Traces part of
the same legend group hide/show at the same time when
toggling legend items.
line
:class:`plotly.graph_objects.scatterpolar.Line`
instance or dict with compatible properties
marker
:class:`plotly.graph_objects.scatterpolar.Marker`
instance or dict with compatible properties
meta
Assigns extra meta information associated with this
trace that can be used in various text attributes.
Attributes such as trace `name`, graph, axis and
colorbar `title.text`, annotation `text`
`rangeselector`, `updatemenues` and `sliders` `label`
text all support `meta`. To access the trace `meta`
values in an attribute in the same trace, simply use
`%{meta[i]}` where `i` is the index or key of the
`meta` item in question. To access trace `meta` in
layout attributes, use `%{data[n[.meta[i]}` where `i`
is the index or key of the `meta` and `n` is the trace
index.
metasrc
Sets the source reference on Chart Studio Cloud for
meta .
mode
Determines the drawing mode for this scatter trace. If
the provided `mode` includes "text" then the `text`
elements appear at the coordinates. Otherwise, the
`text` elements appear on hover. If there are less than
20 points and the trace is not stacked then the default
is "lines+markers". Otherwise, "lines".
name
Sets the trace name. The trace name appear as the
legend item and on hover.
opacity
Sets the opacity of the trace.
r
Sets the radial coordinates
r0
Alternate to `r`. Builds a linear space of r
coordinates. Use with `dr` where `r0` is the starting
coordinate and `dr` the step.
rsrc
Sets the source reference on Chart Studio Cloud for r
.
selected
:class:`plotly.graph_objects.scatterpolar.Selected`
instance or dict with compatible properties
selectedpoints
Array containing integer indices of selected points.
Has an effect only for traces that support selections.
Note that an empty array means an empty selection where
the `unselected` are turned on for all points, whereas,
any other non-array values means no selection all where
the `selected` and `unselected` styles have no effect.
showlegend
Determines whether or not an item corresponding to this
trace is shown in the legend.
stream
:class:`plotly.graph_objects.scatterpolar.Stream`
instance or dict with compatible properties
subplot
Sets a reference between this trace's data coordinates
and a polar subplot. If "polar" (the default value),
the data refer to `layout.polar`. If "polar2", the data
refer to `layout.polar2`, and so on.
text
Sets text elements associated with each (x,y) pair. If
a single string, the same string appears over all the
data points. If an array of string, the items are
mapped in order to the this trace's (x,y) coordinates.
If trace `hoverinfo` contains a "text" flag and
"hovertext" is not set, these elements will be seen in
the hover labels.
textfont
Sets the text font.
textposition
Sets the positions of the `text` elements with respects
to the (x,y) coordinates.
textpositionsrc
Sets the source reference on Chart Studio Cloud for
textposition .
textsrc
Sets the source reference on Chart Studio Cloud for
text .
texttemplate
Template string used for rendering the information text
that appear on points. Note that this will override
`textinfo`. Variables are inserted using %{variable},
for example "y: %{y}". Numbers are formatted using
d3-format's syntax %{variable:d3-format}, for example
"Price: %{y:$.2f}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for
details on the formatting syntax. Dates are formatted
using d3-time-format's syntax %{variable|d3-time-
format}, for example "Day: %{2019-01-01|%A}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for
details on the date formatting syntax. Every attributes
that can be specified per-point (the ones that are
`arrayOk: true`) are available. variables `r`, `theta`
and `text`.
texttemplatesrc
Sets the source reference on Chart Studio Cloud for
texttemplate .
theta
Sets the angular coordinates
theta0
Alternate to `theta`. Builds a linear space of theta
coordinates. Use with `dtheta` where `theta0` is the
starting coordinate and `dtheta` the step.
thetasrc
Sets the source reference on Chart Studio Cloud for
theta .
thetaunit
Sets the unit of input "theta" values. Has an effect
only when on "linear" angular axes.
uid
Assign an id to this trace, Use this to provide object
constancy between traces during animations and
transitions.
uirevision
Controls persistence of some user-driven changes to the
trace: `constraintrange` in `parcoords` traces, as well
as some `editable: true` modifications such as `name`
and `colorbar.title`. Defaults to `layout.uirevision`.
Note that other user-driven trace attribute changes are
controlled by `layout` attributes: `trace.visible` is
controlled by `layout.legend.uirevision`,
`selectedpoints` is controlled by
`layout.selectionrevision`, and `colorbar.(x|y)`
(accessible with `config: {editable: true}`) is
controlled by `layout.editrevision`. Trace changes are
tracked by `uid`, which only falls back on trace index
if no `uid` is provided. So if your app can add/remove
traces before the end of the `data` array, such that
the same trace has a different index, you can still
preserve user-driven changes if you give each trace a
`uid` that stays with it as it moves.
unselected
:class:`plotly.graph_objects.scatterpolar.Unselected`
instance or dict with compatible properties
visible
Determines whether or not this trace is visible. If
"legendonly", the trace is not drawn, but can appear as
a legend item (provided that the legend itself is
visible).
Returns
-------
Scatterpolar
|
Construct a new Scatterpolar object
The scatterpolar trace type encompasses line charts, scatter
charts, text charts, and bubble charts in polar coordinates.
The data visualized as scatter point or lines is set in `r`
(radial) and `theta` (angular) coordinates Text (appearing
either on the chart or on hover only) is via `text`. Bubble
charts are achieved by setting `marker.size` and/or
`marker.color` to numerical arrays. | def __init__(
self,
arg=None,
cliponaxis=None,
connectgaps=None,
customdata=None,
customdatasrc=None,
dr=None,
dtheta=None,
fill=None,
fillcolor=None,
hoverinfo=None,
hoverinfosrc=None,
hoverlabel=None,
hoveron=None,
hovertemplate=None,
hovertemplatesrc=None,
hovertext=None,
hovertextsrc=None,
ids=None,
idssrc=None,
legendgroup=None,
line=None,
marker=None,
meta=None,
metasrc=None,
mode=None,
name=None,
opacity=None,
r=None,
r0=None,
rsrc=None,
selected=None,
selectedpoints=None,
showlegend=None,
stream=None,
subplot=None,
text=None,
textfont=None,
textposition=None,
textpositionsrc=None,
textsrc=None,
texttemplate=None,
texttemplatesrc=None,
theta=None,
theta0=None,
thetasrc=None,
thetaunit=None,
uid=None,
uirevision=None,
unselected=None,
visible=None,
**kwargs
):
"""
Construct a new Scatterpolar object
The scatterpolar trace type encompasses line charts, scatter
charts, text charts, and bubble charts in polar coordinates.
The data visualized as scatter point or lines is set in `r`
(radial) and `theta` (angular) coordinates Text (appearing
either on the chart or on hover only) is via `text`. Bubble
charts are achieved by setting `marker.size` and/or
`marker.color` to numerical arrays.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.Scatterpolar`
cliponaxis
Determines whether or not markers and text nodes are
clipped about the subplot axes. To show markers and
text nodes above axis lines and tick labels, make sure
to set `xaxis.layer` and `yaxis.layer` to *below
traces*.
connectgaps
Determines whether or not gaps (i.e. {nan} or missing
values) in the provided data arrays are connected.
customdata
Assigns extra data each datum. This may be useful when
listening to hover, click and selection events. Note
that, "scatter" traces also appends customdata items in
the markers DOM elements
customdatasrc
Sets the source reference on Chart Studio Cloud for
customdata .
dr
Sets the r coordinate step.
dtheta
Sets the theta coordinate step. By default, the
`dtheta` step equals the subplot's period divided by
the length of the `r` coordinates.
fill
Sets the area to fill with a solid color. Use with
`fillcolor` if not "none". scatterpolar has a subset of
the options available to scatter. "toself" connects the
endpoints of the trace (or each segment of the trace if
it has gaps) into a closed shape. "tonext" fills the
space between two traces if one completely encloses the
other (eg consecutive contour lines), and behaves like
"toself" if there is no trace before it. "tonext"
should not be used if one trace does not enclose the
other.
fillcolor
Sets the fill color. Defaults to a half-transparent
variant of the line color, marker color, or marker line
color, whichever is available.
hoverinfo
Determines which trace information appear on hover. If
`none` or `skip` are set, no information is displayed
upon hovering. But, if `none` is set, click and hover
events are still fired.
hoverinfosrc
Sets the source reference on Chart Studio Cloud for
hoverinfo .
hoverlabel
:class:`plotly.graph_objects.scatterpolar.Hoverlabel`
instance or dict with compatible properties
hoveron
Do the hover effects highlight individual points
(markers or line points) or do they highlight filled
regions? If the fill is "toself" or "tonext" and there
are no markers or text, then the default is "fills",
otherwise it is "points".
hovertemplate
Template string used for rendering the information that
appear on hover box. Note that this will override
`hoverinfo`. Variables are inserted using %{variable},
for example "y: %{y}". Numbers are formatted using
d3-format's syntax %{variable:d3-format}, for example
"Price: %{y:$.2f}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for
details on the formatting syntax. Dates are formatted
using d3-time-format's syntax %{variable|d3-time-
format}, for example "Day: %{2019-01-01|%A}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for
details on the date formatting syntax. The variables
available in `hovertemplate` are the ones emitted as
event data described at this link
https://plotly.com/javascript/plotlyjs-events/#event-
data. Additionally, every attributes that can be
specified per-point (the ones that are `arrayOk: true`)
are available. Anything contained in tag `<extra>` is
displayed in the secondary box, for example
"<extra>{fullData.name}</extra>". To hide the secondary
box completely, use an empty tag `<extra></extra>`.
hovertemplatesrc
Sets the source reference on Chart Studio Cloud for
hovertemplate .
hovertext
Sets hover text elements associated with each (x,y)
pair. If a single string, the same string appears over
all the data points. If an array of string, the items
are mapped in order to the this trace's (x,y)
coordinates. To be seen, trace `hoverinfo` must contain
a "text" flag.
hovertextsrc
Sets the source reference on Chart Studio Cloud for
hovertext .
ids
Assigns id labels to each datum. These ids for object
constancy of data points during animation. Should be an
array of strings, not numbers or any other type.
idssrc
Sets the source reference on Chart Studio Cloud for
ids .
legendgroup
Sets the legend group for this trace. Traces part of
the same legend group hide/show at the same time when
toggling legend items.
line
:class:`plotly.graph_objects.scatterpolar.Line`
instance or dict with compatible properties
marker
:class:`plotly.graph_objects.scatterpolar.Marker`
instance or dict with compatible properties
meta
Assigns extra meta information associated with this
trace that can be used in various text attributes.
Attributes such as trace `name`, graph, axis and
colorbar `title.text`, annotation `text`
`rangeselector`, `updatemenues` and `sliders` `label`
text all support `meta`. To access the trace `meta`
values in an attribute in the same trace, simply use
`%{meta[i]}` where `i` is the index or key of the
`meta` item in question. To access trace `meta` in
layout attributes, use `%{data[n[.meta[i]}` where `i`
is the index or key of the `meta` and `n` is the trace
index.
metasrc
Sets the source reference on Chart Studio Cloud for
meta .
mode
Determines the drawing mode for this scatter trace. If
the provided `mode` includes "text" then the `text`
elements appear at the coordinates. Otherwise, the
`text` elements appear on hover. If there are less than
20 points and the trace is not stacked then the default
is "lines+markers". Otherwise, "lines".
name
Sets the trace name. The trace name appear as the
legend item and on hover.
opacity
Sets the opacity of the trace.
r
Sets the radial coordinates
r0
Alternate to `r`. Builds a linear space of r
coordinates. Use with `dr` where `r0` is the starting
coordinate and `dr` the step.
rsrc
Sets the source reference on Chart Studio Cloud for r
.
selected
:class:`plotly.graph_objects.scatterpolar.Selected`
instance or dict with compatible properties
selectedpoints
Array containing integer indices of selected points.
Has an effect only for traces that support selections.
Note that an empty array means an empty selection where
the `unselected` are turned on for all points, whereas,
any other non-array values means no selection all where
the `selected` and `unselected` styles have no effect.
showlegend
Determines whether or not an item corresponding to this
trace is shown in the legend.
stream
:class:`plotly.graph_objects.scatterpolar.Stream`
instance or dict with compatible properties
subplot
Sets a reference between this trace's data coordinates
and a polar subplot. If "polar" (the default value),
the data refer to `layout.polar`. If "polar2", the data
refer to `layout.polar2`, and so on.
text
Sets text elements associated with each (x,y) pair. If
a single string, the same string appears over all the
data points. If an array of string, the items are
mapped in order to the this trace's (x,y) coordinates.
If trace `hoverinfo` contains a "text" flag and
"hovertext" is not set, these elements will be seen in
the hover labels.
textfont
Sets the text font.
textposition
Sets the positions of the `text` elements with respects
to the (x,y) coordinates.
textpositionsrc
Sets the source reference on Chart Studio Cloud for
textposition .
textsrc
Sets the source reference on Chart Studio Cloud for
text .
texttemplate
Template string used for rendering the information text
that appear on points. Note that this will override
`textinfo`. Variables are inserted using %{variable},
for example "y: %{y}". Numbers are formatted using
d3-format's syntax %{variable:d3-format}, for example
"Price: %{y:$.2f}". https://github.com/d3/d3-3.x-api-
reference/blob/master/Formatting.md#d3_format for
details on the formatting syntax. Dates are formatted
using d3-time-format's syntax %{variable|d3-time-
format}, for example "Day: %{2019-01-01|%A}".
https://github.com/d3/d3-3.x-api-
reference/blob/master/Time-Formatting.md#format for
details on the date formatting syntax. Every attributes
that can be specified per-point (the ones that are
`arrayOk: true`) are available. variables `r`, `theta`
and `text`.
texttemplatesrc
Sets the source reference on Chart Studio Cloud for
texttemplate .
theta
Sets the angular coordinates
theta0
Alternate to `theta`. Builds a linear space of theta
coordinates. Use with `dtheta` where `theta0` is the
starting coordinate and `dtheta` the step.
thetasrc
Sets the source reference on Chart Studio Cloud for
theta .
thetaunit
Sets the unit of input "theta" values. Has an effect
only when on "linear" angular axes.
uid
Assign an id to this trace, Use this to provide object
constancy between traces during animations and
transitions.
uirevision
Controls persistence of some user-driven changes to the
trace: `constraintrange` in `parcoords` traces, as well
as some `editable: true` modifications such as `name`
and `colorbar.title`. Defaults to `layout.uirevision`.
Note that other user-driven trace attribute changes are
controlled by `layout` attributes: `trace.visible` is
controlled by `layout.legend.uirevision`,
`selectedpoints` is controlled by
`layout.selectionrevision`, and `colorbar.(x|y)`
(accessible with `config: {editable: true}`) is
controlled by `layout.editrevision`. Trace changes are
tracked by `uid`, which only falls back on trace index
if no `uid` is provided. So if your app can add/remove
traces before the end of the `data` array, such that
the same trace has a different index, you can still
preserve user-driven changes if you give each trace a
`uid` that stays with it as it moves.
unselected
:class:`plotly.graph_objects.scatterpolar.Unselected`
instance or dict with compatible properties
visible
Determines whether or not this trace is visible. If
"legendonly", the trace is not drawn, but can appear as
a legend item (provided that the legend itself is
visible).
Returns
-------
Scatterpolar
"""
super(Scatterpolar, self).__init__("scatterpolar")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.Scatterpolar
constructor must be a dict or
an instance of :class:`plotly.graph_objs.Scatterpolar`"""
)
# 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("cliponaxis", None)
_v = cliponaxis if cliponaxis is not None else _v
if _v is not None:
self["cliponaxis"] = _v
_v = arg.pop("connectgaps", None)
_v = connectgaps if connectgaps is not None else _v
if _v is not None:
self["connectgaps"] = _v
_v = arg.pop("customdata", None)
_v = customdata if customdata is not None else _v
if _v is not None:
self["customdata"] = _v
_v = arg.pop("customdatasrc", None)
_v = customdatasrc if customdatasrc is not None else _v
if _v is not None:
self["customdatasrc"] = _v
_v = arg.pop("dr", None)
_v = dr if dr is not None else _v
if _v is not None:
self["dr"] = _v
_v = arg.pop("dtheta", None)
_v = dtheta if dtheta is not None else _v
if _v is not None:
self["dtheta"] = _v
_v = arg.pop("fill", None)
_v = fill if fill is not None else _v
if _v is not None:
self["fill"] = _v
_v = arg.pop("fillcolor", None)
_v = fillcolor if fillcolor is not None else _v
if _v is not None:
self["fillcolor"] = _v
_v = arg.pop("hoverinfo", None)
_v = hoverinfo if hoverinfo is not None else _v
if _v is not None:
self["hoverinfo"] = _v
_v = arg.pop("hoverinfosrc", None)
_v = hoverinfosrc if hoverinfosrc is not None else _v
if _v is not None:
self["hoverinfosrc"] = _v
_v = arg.pop("hoverlabel", None)
_v = hoverlabel if hoverlabel is not None else _v
if _v is not None:
self["hoverlabel"] = _v
_v = arg.pop("hoveron", None)
_v = hoveron if hoveron is not None else _v
if _v is not None:
self["hoveron"] = _v
_v = arg.pop("hovertemplate", None)
_v = hovertemplate if hovertemplate is not None else _v
if _v is not None:
self["hovertemplate"] = _v
_v = arg.pop("hovertemplatesrc", None)
_v = hovertemplatesrc if hovertemplatesrc is not None else _v
if _v is not None:
self["hovertemplatesrc"] = _v
_v = arg.pop("hovertext", None)
_v = hovertext if hovertext is not None else _v
if _v is not None:
self["hovertext"] = _v
_v = arg.pop("hovertextsrc", None)
_v = hovertextsrc if hovertextsrc is not None else _v
if _v is not None:
self["hovertextsrc"] = _v
_v = arg.pop("ids", None)
_v = ids if ids is not None else _v
if _v is not None:
self["ids"] = _v
_v = arg.pop("idssrc", None)
_v = idssrc if idssrc is not None else _v
if _v is not None:
self["idssrc"] = _v
_v = arg.pop("legendgroup", None)
_v = legendgroup if legendgroup is not None else _v
if _v is not None:
self["legendgroup"] = _v
_v = arg.pop("line", None)
_v = line if line is not None else _v
if _v is not None:
self["line"] = _v
_v = arg.pop("marker", None)
_v = marker if marker is not None else _v
if _v is not None:
self["marker"] = _v
_v = arg.pop("meta", None)
_v = meta if meta is not None else _v
if _v is not None:
self["meta"] = _v
_v = arg.pop("metasrc", None)
_v = metasrc if metasrc is not None else _v
if _v is not None:
self["metasrc"] = _v
_v = arg.pop("mode", None)
_v = mode if mode is not None else _v
if _v is not None:
self["mode"] = _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("opacity", None)
_v = opacity if opacity is not None else _v
if _v is not None:
self["opacity"] = _v
_v = arg.pop("r", None)
_v = r if r is not None else _v
if _v is not None:
self["r"] = _v
_v = arg.pop("r0", None)
_v = r0 if r0 is not None else _v
if _v is not None:
self["r0"] = _v
_v = arg.pop("rsrc", None)
_v = rsrc if rsrc is not None else _v
if _v is not None:
self["rsrc"] = _v
_v = arg.pop("selected", None)
_v = selected if selected is not None else _v
if _v is not None:
self["selected"] = _v
_v = arg.pop("selectedpoints", None)
_v = selectedpoints if selectedpoints is not None else _v
if _v is not None:
self["selectedpoints"] = _v
_v = arg.pop("showlegend", None)
_v = showlegend if showlegend is not None else _v
if _v is not None:
self["showlegend"] = _v
_v = arg.pop("stream", None)
_v = stream if stream is not None else _v
if _v is not None:
self["stream"] = _v
_v = arg.pop("subplot", None)
_v = subplot if subplot is not None else _v
if _v is not None:
self["subplot"] = _v
_v = arg.pop("text", None)
_v = text if text is not None else _v
if _v is not None:
self["text"] = _v
_v = arg.pop("textfont", None)
_v = textfont if textfont is not None else _v
if _v is not None:
self["textfont"] = _v
_v = arg.pop("textposition", None)
_v = textposition if textposition is not None else _v
if _v is not None:
self["textposition"] = _v
_v = arg.pop("textpositionsrc", None)
_v = textpositionsrc if textpositionsrc is not None else _v
if _v is not None:
self["textpositionsrc"] = _v
_v = arg.pop("textsrc", None)
_v = textsrc if textsrc is not None else _v
if _v is not None:
self["textsrc"] = _v
_v = arg.pop("texttemplate", None)
_v = texttemplate if texttemplate is not None else _v
if _v is not None:
self["texttemplate"] = _v
_v = arg.pop("texttemplatesrc", None)
_v = texttemplatesrc if texttemplatesrc is not None else _v
if _v is not None:
self["texttemplatesrc"] = _v
_v = arg.pop("theta", None)
_v = theta if theta is not None else _v
if _v is not None:
self["theta"] = _v
_v = arg.pop("theta0", None)
_v = theta0 if theta0 is not None else _v
if _v is not None:
self["theta0"] = _v
_v = arg.pop("thetasrc", None)
_v = thetasrc if thetasrc is not None else _v
if _v is not None:
self["thetasrc"] = _v
_v = arg.pop("thetaunit", None)
_v = thetaunit if thetaunit is not None else _v
if _v is not None:
self["thetaunit"] = _v
_v = arg.pop("uid", None)
_v = uid if uid is not None else _v
if _v is not None:
self["uid"] = _v
_v = arg.pop("uirevision", None)
_v = uirevision if uirevision is not None else _v
if _v is not None:
self["uirevision"] = _v
_v = arg.pop("unselected", None)
_v = unselected if unselected is not None else _v
if _v is not None:
self["unselected"] = _v
_v = arg.pop("visible", None)
_v = visible if visible is not None else _v
if _v is not None:
self["visible"] = _v
# Read-only literals
# ------------------
self._props["type"] = "scatterpolar"
arg.pop("type", None)
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"cliponaxis",
"=",
"None",
",",
"connectgaps",
"=",
"None",
",",
"customdata",
"=",
"None",
",",
"customdatasrc",
"=",
"None",
",",
"dr",
"=",
"None",
",",
"dtheta",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"fillcolor",
"=",
"None",
",",
"hoverinfo",
"=",
"None",
",",
"hoverinfosrc",
"=",
"None",
",",
"hoverlabel",
"=",
"None",
",",
"hoveron",
"=",
"None",
",",
"hovertemplate",
"=",
"None",
",",
"hovertemplatesrc",
"=",
"None",
",",
"hovertext",
"=",
"None",
",",
"hovertextsrc",
"=",
"None",
",",
"ids",
"=",
"None",
",",
"idssrc",
"=",
"None",
",",
"legendgroup",
"=",
"None",
",",
"line",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"meta",
"=",
"None",
",",
"metasrc",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"name",
"=",
"None",
",",
"opacity",
"=",
"None",
",",
"r",
"=",
"None",
",",
"r0",
"=",
"None",
",",
"rsrc",
"=",
"None",
",",
"selected",
"=",
"None",
",",
"selectedpoints",
"=",
"None",
",",
"showlegend",
"=",
"None",
",",
"stream",
"=",
"None",
",",
"subplot",
"=",
"None",
",",
"text",
"=",
"None",
",",
"textfont",
"=",
"None",
",",
"textposition",
"=",
"None",
",",
"textpositionsrc",
"=",
"None",
",",
"textsrc",
"=",
"None",
",",
"texttemplate",
"=",
"None",
",",
"texttemplatesrc",
"=",
"None",
",",
"theta",
"=",
"None",
",",
"theta0",
"=",
"None",
",",
"thetasrc",
"=",
"None",
",",
"thetaunit",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"uirevision",
"=",
"None",
",",
"unselected",
"=",
"None",
",",
"visible",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Scatterpolar",
",",
"self",
")",
".",
"__init__",
"(",
"\"scatterpolar\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.Scatterpolar \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.Scatterpolar`\"\"\"",
")",
"# 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",
"(",
"\"cliponaxis\"",
",",
"None",
")",
"_v",
"=",
"cliponaxis",
"if",
"cliponaxis",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"cliponaxis\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"connectgaps\"",
",",
"None",
")",
"_v",
"=",
"connectgaps",
"if",
"connectgaps",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"connectgaps\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"customdata\"",
",",
"None",
")",
"_v",
"=",
"customdata",
"if",
"customdata",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"customdata\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"customdatasrc\"",
",",
"None",
")",
"_v",
"=",
"customdatasrc",
"if",
"customdatasrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"customdatasrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"dr\"",
",",
"None",
")",
"_v",
"=",
"dr",
"if",
"dr",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"dr\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"dtheta\"",
",",
"None",
")",
"_v",
"=",
"dtheta",
"if",
"dtheta",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"dtheta\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"fill\"",
",",
"None",
")",
"_v",
"=",
"fill",
"if",
"fill",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"fill\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"fillcolor\"",
",",
"None",
")",
"_v",
"=",
"fillcolor",
"if",
"fillcolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"fillcolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hoverinfo\"",
",",
"None",
")",
"_v",
"=",
"hoverinfo",
"if",
"hoverinfo",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hoverinfo\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hoverinfosrc\"",
",",
"None",
")",
"_v",
"=",
"hoverinfosrc",
"if",
"hoverinfosrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hoverinfosrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hoverlabel\"",
",",
"None",
")",
"_v",
"=",
"hoverlabel",
"if",
"hoverlabel",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hoverlabel\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hoveron\"",
",",
"None",
")",
"_v",
"=",
"hoveron",
"if",
"hoveron",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hoveron\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hovertemplate\"",
",",
"None",
")",
"_v",
"=",
"hovertemplate",
"if",
"hovertemplate",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hovertemplate\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hovertemplatesrc\"",
",",
"None",
")",
"_v",
"=",
"hovertemplatesrc",
"if",
"hovertemplatesrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hovertemplatesrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hovertext\"",
",",
"None",
")",
"_v",
"=",
"hovertext",
"if",
"hovertext",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hovertext\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"hovertextsrc\"",
",",
"None",
")",
"_v",
"=",
"hovertextsrc",
"if",
"hovertextsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"hovertextsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"ids\"",
",",
"None",
")",
"_v",
"=",
"ids",
"if",
"ids",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"ids\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"idssrc\"",
",",
"None",
")",
"_v",
"=",
"idssrc",
"if",
"idssrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"idssrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"legendgroup\"",
",",
"None",
")",
"_v",
"=",
"legendgroup",
"if",
"legendgroup",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"legendgroup\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"line\"",
",",
"None",
")",
"_v",
"=",
"line",
"if",
"line",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"line\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"marker\"",
",",
"None",
")",
"_v",
"=",
"marker",
"if",
"marker",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"marker\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"meta\"",
",",
"None",
")",
"_v",
"=",
"meta",
"if",
"meta",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"meta\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"metasrc\"",
",",
"None",
")",
"_v",
"=",
"metasrc",
"if",
"metasrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"metasrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"mode\"",
",",
"None",
")",
"_v",
"=",
"mode",
"if",
"mode",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"mode\"",
"]",
"=",
"_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",
"(",
"\"opacity\"",
",",
"None",
")",
"_v",
"=",
"opacity",
"if",
"opacity",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"opacity\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"r\"",
",",
"None",
")",
"_v",
"=",
"r",
"if",
"r",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"r\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"r0\"",
",",
"None",
")",
"_v",
"=",
"r0",
"if",
"r0",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"r0\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"rsrc\"",
",",
"None",
")",
"_v",
"=",
"rsrc",
"if",
"rsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"rsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"selected\"",
",",
"None",
")",
"_v",
"=",
"selected",
"if",
"selected",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"selected\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"selectedpoints\"",
",",
"None",
")",
"_v",
"=",
"selectedpoints",
"if",
"selectedpoints",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"selectedpoints\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"showlegend\"",
",",
"None",
")",
"_v",
"=",
"showlegend",
"if",
"showlegend",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"showlegend\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"stream\"",
",",
"None",
")",
"_v",
"=",
"stream",
"if",
"stream",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"stream\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"subplot\"",
",",
"None",
")",
"_v",
"=",
"subplot",
"if",
"subplot",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"subplot\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"text\"",
",",
"None",
")",
"_v",
"=",
"text",
"if",
"text",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"text\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"textfont\"",
",",
"None",
")",
"_v",
"=",
"textfont",
"if",
"textfont",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"textfont\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"textposition\"",
",",
"None",
")",
"_v",
"=",
"textposition",
"if",
"textposition",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"textposition\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"textpositionsrc\"",
",",
"None",
")",
"_v",
"=",
"textpositionsrc",
"if",
"textpositionsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"textpositionsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"textsrc\"",
",",
"None",
")",
"_v",
"=",
"textsrc",
"if",
"textsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"textsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"texttemplate\"",
",",
"None",
")",
"_v",
"=",
"texttemplate",
"if",
"texttemplate",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"texttemplate\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"texttemplatesrc\"",
",",
"None",
")",
"_v",
"=",
"texttemplatesrc",
"if",
"texttemplatesrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"texttemplatesrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"theta\"",
",",
"None",
")",
"_v",
"=",
"theta",
"if",
"theta",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"theta\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"theta0\"",
",",
"None",
")",
"_v",
"=",
"theta0",
"if",
"theta0",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"theta0\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"thetasrc\"",
",",
"None",
")",
"_v",
"=",
"thetasrc",
"if",
"thetasrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"thetasrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"thetaunit\"",
",",
"None",
")",
"_v",
"=",
"thetaunit",
"if",
"thetaunit",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"thetaunit\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"uid\"",
",",
"None",
")",
"_v",
"=",
"uid",
"if",
"uid",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"uid\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"uirevision\"",
",",
"None",
")",
"_v",
"=",
"uirevision",
"if",
"uirevision",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"uirevision\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"unselected\"",
",",
"None",
")",
"_v",
"=",
"unselected",
"if",
"unselected",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"unselected\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"visible\"",
",",
"None",
")",
"_v",
"=",
"visible",
"if",
"visible",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"visible\"",
"]",
"=",
"_v",
"# Read-only literals",
"# ------------------",
"self",
".",
"_props",
"[",
"\"type\"",
"]",
"=",
"\"scatterpolar\"",
"arg",
".",
"pop",
"(",
"\"type\"",
",",
"None",
")",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
1758,
4
] | [
2318,
34
] | python | en | ['en', 'error', 'th'] | False |
Line.color | (self) |
Sets the color of line bounding the box(es).
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
|
Sets the color of line bounding the box(es).
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):
"""
Sets the color of line bounding the box(es).
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
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.width | (self) |
Sets the width (in px) of line bounding the box(es).
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
|
Sets the width (in px) of line bounding the box(es).
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def width(self):
"""
Sets the width (in px) of line bounding the box(es).
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
"""
return self["width"] | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
74,
4
] | [
85,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.__init__ | (self, arg=None, color=None, width=None, **kwargs) |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.candlestick.increasing.Line`
color
Sets the color of line bounding the box(es).
width
Sets the width (in px) of line bounding the box(es).
Returns
-------
Line
|
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.candlestick.increasing.Line`
color
Sets the color of line bounding the box(es).
width
Sets the width (in px) of line bounding the box(es). | def __init__(self, arg=None, color=None, width=None, **kwargs):
"""
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.candlestick.increasing.Line`
color
Sets the color of line bounding the box(es).
width
Sets the width (in px) of line bounding the box(es).
Returns
-------
Line
"""
super(Line, self).__init__("line")
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.candlestick.increasing.Line
constructor must be a dict or
an instance of :class:`plotly.graph_objs.candlestick.increasing.Line`"""
)
# 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("width", None)
_v = width if width is not None else _v
if _v is not None:
self["width"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"width",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Line",
",",
"self",
")",
".",
"__init__",
"(",
"\"line\"",
")",
"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.candlestick.increasing.Line \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.candlestick.increasing.Line`\"\"\"",
")",
"# 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",
"(",
"\"width\"",
",",
"None",
")",
"_v",
"=",
"width",
"if",
"width",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"width\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
102,
4
] | [
165,
34
] | python | en | ['en', 'error', 'th'] | False |
get_pairs | (word) | Return set of symbol pairs in a word.
word is represented as tuple of symbols (symbols being variable-length strings)
| Return set of symbol pairs in a word. | def get_pairs(word):
"""Return set of symbol pairs in a word.
word is represented as tuple of symbols (symbols being variable-length strings)
"""
pairs = set()
prev_char = word[0]
for char in word[1:]:
pairs.add((prev_char, char))
prev_char = char
return pairs | [
"def",
"get_pairs",
"(",
"word",
")",
":",
"pairs",
"=",
"set",
"(",
")",
"prev_char",
"=",
"word",
"[",
"0",
"]",
"for",
"char",
"in",
"word",
"[",
"1",
":",
"]",
":",
"pairs",
".",
"add",
"(",
"(",
"prev_char",
",",
"char",
")",
")",
"prev_char",
"=",
"char",
"return",
"pairs"
] | [
120,
0
] | [
130,
16
] | python | en | ['en', 'en', 'en'] | True |
encode | (orig, bpe_codes, bpe_codes_reverse, vocab, separator, version, cache, glossaries=None) | Encode word based on list of BPE merge operations, which are applied consecutively
| Encode word based on list of BPE merge operations, which are applied consecutively
| def encode(orig, bpe_codes, bpe_codes_reverse, vocab, separator, version, cache, glossaries=None):
"""Encode word based on list of BPE merge operations, which are applied consecutively
"""
if orig in cache:
return cache[orig]
if orig in glossaries:
cache[orig] = (orig,)
return (orig,)
if version == (0, 1):
word = tuple(orig) + ('</w>',)
elif version == (0, 2): # more consistent handling of word-final segments
word = tuple(orig[:-1]) + ( orig[-1] + '</w>',)
else:
raise NotImplementedError
pairs = get_pairs(word)
if not pairs:
return orig
while True:
bigram = min(pairs, key = lambda pair: bpe_codes.get(pair, float('inf')))
if bigram not in bpe_codes:
break
first, second = bigram
new_word = []
i = 0
while i < len(word):
try:
j = word.index(first, i)
new_word.extend(word[i:j])
i = j
except:
new_word.extend(word[i:])
break
if word[i] == first and i < len(word)-1 and word[i+1] == second:
new_word.append(first+second)
i += 2
else:
new_word.append(word[i])
i += 1
new_word = tuple(new_word)
word = new_word
if len(word) == 1:
break
else:
pairs = get_pairs(word)
# don't print end-of-word symbols
if word[-1] == '</w>':
word = word[:-1]
elif word[-1].endswith('</w>'):
word = word[:-1] + (word[-1].replace('</w>',''),)
if vocab:
word = check_vocab_and_split(word, bpe_codes_reverse, vocab, separator)
cache[orig] = word
return word | [
"def",
"encode",
"(",
"orig",
",",
"bpe_codes",
",",
"bpe_codes_reverse",
",",
"vocab",
",",
"separator",
",",
"version",
",",
"cache",
",",
"glossaries",
"=",
"None",
")",
":",
"if",
"orig",
"in",
"cache",
":",
"return",
"cache",
"[",
"orig",
"]",
"if",
"orig",
"in",
"glossaries",
":",
"cache",
"[",
"orig",
"]",
"=",
"(",
"orig",
",",
")",
"return",
"(",
"orig",
",",
")",
"if",
"version",
"==",
"(",
"0",
",",
"1",
")",
":",
"word",
"=",
"tuple",
"(",
"orig",
")",
"+",
"(",
"'</w>'",
",",
")",
"elif",
"version",
"==",
"(",
"0",
",",
"2",
")",
":",
"# more consistent handling of word-final segments",
"word",
"=",
"tuple",
"(",
"orig",
"[",
":",
"-",
"1",
"]",
")",
"+",
"(",
"orig",
"[",
"-",
"1",
"]",
"+",
"'</w>'",
",",
")",
"else",
":",
"raise",
"NotImplementedError",
"pairs",
"=",
"get_pairs",
"(",
"word",
")",
"if",
"not",
"pairs",
":",
"return",
"orig",
"while",
"True",
":",
"bigram",
"=",
"min",
"(",
"pairs",
",",
"key",
"=",
"lambda",
"pair",
":",
"bpe_codes",
".",
"get",
"(",
"pair",
",",
"float",
"(",
"'inf'",
")",
")",
")",
"if",
"bigram",
"not",
"in",
"bpe_codes",
":",
"break",
"first",
",",
"second",
"=",
"bigram",
"new_word",
"=",
"[",
"]",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"word",
")",
":",
"try",
":",
"j",
"=",
"word",
".",
"index",
"(",
"first",
",",
"i",
")",
"new_word",
".",
"extend",
"(",
"word",
"[",
"i",
":",
"j",
"]",
")",
"i",
"=",
"j",
"except",
":",
"new_word",
".",
"extend",
"(",
"word",
"[",
"i",
":",
"]",
")",
"break",
"if",
"word",
"[",
"i",
"]",
"==",
"first",
"and",
"i",
"<",
"len",
"(",
"word",
")",
"-",
"1",
"and",
"word",
"[",
"i",
"+",
"1",
"]",
"==",
"second",
":",
"new_word",
".",
"append",
"(",
"first",
"+",
"second",
")",
"i",
"+=",
"2",
"else",
":",
"new_word",
".",
"append",
"(",
"word",
"[",
"i",
"]",
")",
"i",
"+=",
"1",
"new_word",
"=",
"tuple",
"(",
"new_word",
")",
"word",
"=",
"new_word",
"if",
"len",
"(",
"word",
")",
"==",
"1",
":",
"break",
"else",
":",
"pairs",
"=",
"get_pairs",
"(",
"word",
")",
"# don't print end-of-word symbols",
"if",
"word",
"[",
"-",
"1",
"]",
"==",
"'</w>'",
":",
"word",
"=",
"word",
"[",
":",
"-",
"1",
"]",
"elif",
"word",
"[",
"-",
"1",
"]",
".",
"endswith",
"(",
"'</w>'",
")",
":",
"word",
"=",
"word",
"[",
":",
"-",
"1",
"]",
"+",
"(",
"word",
"[",
"-",
"1",
"]",
".",
"replace",
"(",
"'</w>'",
",",
"''",
")",
",",
")",
"if",
"vocab",
":",
"word",
"=",
"check_vocab_and_split",
"(",
"word",
",",
"bpe_codes_reverse",
",",
"vocab",
",",
"separator",
")",
"cache",
"[",
"orig",
"]",
"=",
"word",
"return",
"word"
] | [
132,
0
] | [
194,
15
] | python | en | ['en', 'en', 'en'] | True |
recursive_split | (segment, bpe_codes, vocab, separator, final=False) | Recursively split segment into smaller units (by reversing BPE merges)
until all units are either in-vocabulary, or cannot be split futher. | Recursively split segment into smaller units (by reversing BPE merges)
until all units are either in-vocabulary, or cannot be split futher. | def recursive_split(segment, bpe_codes, vocab, separator, final=False):
"""Recursively split segment into smaller units (by reversing BPE merges)
until all units are either in-vocabulary, or cannot be split futher."""
try:
if final:
left, right = bpe_codes[segment + '</w>']
right = right[:-4]
else:
left, right = bpe_codes[segment]
except:
#sys.stderr.write('cannot split {0} further.\n'.format(segment))
yield segment
return
if left + separator in vocab:
yield left
else:
for item in recursive_split(left, bpe_codes, vocab, separator, False):
yield item
if (final and right in vocab) or (not final and right + separator in vocab):
yield right
else:
for item in recursive_split(right, bpe_codes, vocab, separator, final):
yield item | [
"def",
"recursive_split",
"(",
"segment",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
",",
"final",
"=",
"False",
")",
":",
"try",
":",
"if",
"final",
":",
"left",
",",
"right",
"=",
"bpe_codes",
"[",
"segment",
"+",
"'</w>'",
"]",
"right",
"=",
"right",
"[",
":",
"-",
"4",
"]",
"else",
":",
"left",
",",
"right",
"=",
"bpe_codes",
"[",
"segment",
"]",
"except",
":",
"#sys.stderr.write('cannot split {0} further.\\n'.format(segment))",
"yield",
"segment",
"return",
"if",
"left",
"+",
"separator",
"in",
"vocab",
":",
"yield",
"left",
"else",
":",
"for",
"item",
"in",
"recursive_split",
"(",
"left",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
",",
"False",
")",
":",
"yield",
"item",
"if",
"(",
"final",
"and",
"right",
"in",
"vocab",
")",
"or",
"(",
"not",
"final",
"and",
"right",
"+",
"separator",
"in",
"vocab",
")",
":",
"yield",
"right",
"else",
":",
"for",
"item",
"in",
"recursive_split",
"(",
"right",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
",",
"final",
")",
":",
"yield",
"item"
] | [
196,
0
] | [
221,
22
] | python | en | ['en', 'no', 'en'] | True |
check_vocab_and_split | (orig, bpe_codes, vocab, separator) | Check for each segment in word if it is in-vocabulary,
and segment OOV segments into smaller units by reversing the BPE merge operations | Check for each segment in word if it is in-vocabulary,
and segment OOV segments into smaller units by reversing the BPE merge operations | def check_vocab_and_split(orig, bpe_codes, vocab, separator):
"""Check for each segment in word if it is in-vocabulary,
and segment OOV segments into smaller units by reversing the BPE merge operations"""
out = []
for segment in orig[:-1]:
if segment + separator in vocab:
out.append(segment)
else:
#sys.stderr.write('OOV: {0}\n'.format(segment))
for item in recursive_split(segment, bpe_codes, vocab, separator, False):
out.append(item)
segment = orig[-1]
if segment in vocab:
out.append(segment)
else:
#sys.stderr.write('OOV: {0}\n'.format(segment))
for item in recursive_split(segment, bpe_codes, vocab, separator, True):
out.append(item)
return out | [
"def",
"check_vocab_and_split",
"(",
"orig",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
")",
":",
"out",
"=",
"[",
"]",
"for",
"segment",
"in",
"orig",
"[",
":",
"-",
"1",
"]",
":",
"if",
"segment",
"+",
"separator",
"in",
"vocab",
":",
"out",
".",
"append",
"(",
"segment",
")",
"else",
":",
"#sys.stderr.write('OOV: {0}\\n'.format(segment))",
"for",
"item",
"in",
"recursive_split",
"(",
"segment",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
",",
"False",
")",
":",
"out",
".",
"append",
"(",
"item",
")",
"segment",
"=",
"orig",
"[",
"-",
"1",
"]",
"if",
"segment",
"in",
"vocab",
":",
"out",
".",
"append",
"(",
"segment",
")",
"else",
":",
"#sys.stderr.write('OOV: {0}\\n'.format(segment))",
"for",
"item",
"in",
"recursive_split",
"(",
"segment",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
",",
"True",
")",
":",
"out",
".",
"append",
"(",
"item",
")",
"return",
"out"
] | [
223,
0
] | [
245,
14
] | python | en | ['en', 'en', 'en'] | True |
read_vocabulary | (vocab_file, threshold) | read vocabulary file produced by get_vocab.py, and filter according to frequency threshold.
| read vocabulary file produced by get_vocab.py, and filter according to frequency threshold.
| def read_vocabulary(vocab_file, threshold):
"""read vocabulary file produced by get_vocab.py, and filter according to frequency threshold.
"""
vocabulary = set()
for line in vocab_file:
word, freq = line.split()
freq = int(freq)
if threshold == None or freq >= threshold:
vocabulary.add(word)
return vocabulary | [
"def",
"read_vocabulary",
"(",
"vocab_file",
",",
"threshold",
")",
":",
"vocabulary",
"=",
"set",
"(",
")",
"for",
"line",
"in",
"vocab_file",
":",
"word",
",",
"freq",
"=",
"line",
".",
"split",
"(",
")",
"freq",
"=",
"int",
"(",
"freq",
")",
"if",
"threshold",
"==",
"None",
"or",
"freq",
">=",
"threshold",
":",
"vocabulary",
".",
"add",
"(",
"word",
")",
"return",
"vocabulary"
] | [
248,
0
] | [
260,
21
] | python | en | ['en', 'en', 'en'] | True |
isolate_glossary | (word, glossary) |
Isolate a glossary present inside a word.
Returns a list of subwords. In which all 'glossary' glossaries are isolated
For example, if 'USA' is the glossary and '1934USABUSA' the word, the return value is:
['1934', 'USA', 'B', 'USA']
|
Isolate a glossary present inside a word. | def isolate_glossary(word, glossary):
"""
Isolate a glossary present inside a word.
Returns a list of subwords. In which all 'glossary' glossaries are isolated
For example, if 'USA' is the glossary and '1934USABUSA' the word, the return value is:
['1934', 'USA', 'B', 'USA']
"""
if word == glossary or glossary not in word:
return [word]
else:
splits = word.split(glossary)
segments = [segment.strip() for split in splits[:-1] for segment in [split, glossary] if segment != '']
return segments + [splits[-1].strip()] if splits[-1] != '' else segments | [
"def",
"isolate_glossary",
"(",
"word",
",",
"glossary",
")",
":",
"if",
"word",
"==",
"glossary",
"or",
"glossary",
"not",
"in",
"word",
":",
"return",
"[",
"word",
"]",
"else",
":",
"splits",
"=",
"word",
".",
"split",
"(",
"glossary",
")",
"segments",
"=",
"[",
"segment",
".",
"strip",
"(",
")",
"for",
"split",
"in",
"splits",
"[",
":",
"-",
"1",
"]",
"for",
"segment",
"in",
"[",
"split",
",",
"glossary",
"]",
"if",
"segment",
"!=",
"''",
"]",
"return",
"segments",
"+",
"[",
"splits",
"[",
"-",
"1",
"]",
".",
"strip",
"(",
")",
"]",
"if",
"splits",
"[",
"-",
"1",
"]",
"!=",
"''",
"else",
"segments"
] | [
262,
0
] | [
276,
80
] | python | en | ['en', 'error', 'th'] | False |
BPE.segment | (self, sentence) | segment single sentence (whitespace-tokenized string) with BPE encoding | segment single sentence (whitespace-tokenized string) with BPE encoding | def segment(self, sentence):
"""segment single sentence (whitespace-tokenized string) with BPE encoding"""
output = []
for word in sentence.split():
new_word = [out for segment in self._isolate_glossaries(word)
for out in encode(segment,
self.bpe_codes,
self.bpe_codes_reverse,
self.vocab,
self.separator,
self.version,
self.cache,
self.glossaries)]
for item in new_word[:-1]:
output.append(item + self.separator)
output.append(new_word[-1])
return ' '.join(output) | [
"def",
"segment",
"(",
"self",
",",
"sentence",
")",
":",
"output",
"=",
"[",
"]",
"for",
"word",
"in",
"sentence",
".",
"split",
"(",
")",
":",
"new_word",
"=",
"[",
"out",
"for",
"segment",
"in",
"self",
".",
"_isolate_glossaries",
"(",
"word",
")",
"for",
"out",
"in",
"encode",
"(",
"segment",
",",
"self",
".",
"bpe_codes",
",",
"self",
".",
"bpe_codes_reverse",
",",
"self",
".",
"vocab",
",",
"self",
".",
"separator",
",",
"self",
".",
"version",
",",
"self",
".",
"cache",
",",
"self",
".",
"glossaries",
")",
"]",
"for",
"item",
"in",
"new_word",
"[",
":",
"-",
"1",
"]",
":",
"output",
".",
"append",
"(",
"item",
"+",
"self",
".",
"separator",
")",
"output",
".",
"append",
"(",
"new_word",
"[",
"-",
"1",
"]",
")",
"return",
"' '",
".",
"join",
"(",
"output",
")"
] | [
52,
4
] | [
70,
31
] | python | en | ['en', 'el-Latn', 'en'] | True |
Unselected.marker | (self) |
The 'marker' property is an instance of Marker
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolargl.unselected.Marker`
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
color
Sets the marker color of unselected points,
applied only when a selection exists.
opacity
Sets the marker opacity of unselected points,
applied only when a selection exists.
size
Sets the marker size of unselected points,
applied only when a selection exists.
Returns
-------
plotly.graph_objs.scatterpolargl.unselected.Marker
|
The 'marker' property is an instance of Marker
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolargl.unselected.Marker`
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
color
Sets the marker color of unselected points,
applied only when a selection exists.
opacity
Sets the marker opacity of unselected points,
applied only when a selection exists.
size
Sets the marker size of unselected points,
applied only when a selection exists. | def marker(self):
"""
The 'marker' property is an instance of Marker
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolargl.unselected.Marker`
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
color
Sets the marker color of unselected points,
applied only when a selection exists.
opacity
Sets the marker opacity of unselected points,
applied only when a selection exists.
size
Sets the marker size of unselected points,
applied only when a selection exists.
Returns
-------
plotly.graph_objs.scatterpolargl.unselected.Marker
"""
return self["marker"] | [
"def",
"marker",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"marker\"",
"]"
] | [
15,
4
] | [
39,
29
] | python | en | ['en', 'error', 'th'] | False |
Unselected.textfont | (self) |
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolargl.unselected.Textfont`
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties:
color
Sets the text font color of unselected points,
applied only when a selection exists.
Returns
-------
plotly.graph_objs.scatterpolargl.unselected.Textfont
|
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolargl.unselected.Textfont`
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties:
color
Sets the text font color of unselected points,
applied only when a selection exists. | def textfont(self):
"""
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.scatterpolargl.unselected.Textfont`
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties:
color
Sets the text font color of unselected points,
applied only when a selection exists.
Returns
-------
plotly.graph_objs.scatterpolargl.unselected.Textfont
"""
return self["textfont"] | [
"def",
"textfont",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"textfont\"",
"]"
] | [
48,
4
] | [
66,
31
] | python | en | ['en', 'error', 'th'] | False |
Unselected.__init__ | (self, arg=None, marker=None, textfont=None, **kwargs) |
Construct a new Unselected object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolargl.Unselected`
marker
:class:`plotly.graph_objects.scatterpolargl.unselected.
Marker` instance or dict with compatible properties
textfont
:class:`plotly.graph_objects.scatterpolargl.unselected.
Textfont` instance or dict with compatible properties
Returns
-------
Unselected
|
Construct a new Unselected object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolargl.Unselected`
marker
:class:`plotly.graph_objects.scatterpolargl.unselected.
Marker` instance or dict with compatible properties
textfont
:class:`plotly.graph_objects.scatterpolargl.unselected.
Textfont` instance or dict with compatible properties | def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
"""
Construct a new Unselected object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolargl.Unselected`
marker
:class:`plotly.graph_objects.scatterpolargl.unselected.
Marker` instance or dict with compatible properties
textfont
:class:`plotly.graph_objects.scatterpolargl.unselected.
Textfont` instance or dict with compatible properties
Returns
-------
Unselected
"""
super(Unselected, self).__init__("unselected")
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.scatterpolargl.Unselected
constructor must be a dict or
an instance of :class:`plotly.graph_objs.scatterpolargl.Unselected`"""
)
# 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("marker", None)
_v = marker if marker is not None else _v
if _v is not None:
self["marker"] = _v
_v = arg.pop("textfont", None)
_v = textfont if textfont is not None else _v
if _v is not None:
self["textfont"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"textfont",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Unselected",
",",
"self",
")",
".",
"__init__",
"(",
"\"unselected\"",
")",
"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.scatterpolargl.Unselected \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scatterpolargl.Unselected`\"\"\"",
")",
"# 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",
"(",
"\"marker\"",
",",
"None",
")",
"_v",
"=",
"marker",
"if",
"marker",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"marker\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"textfont\"",
",",
"None",
")",
"_v",
"=",
"textfont",
"if",
"textfont",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"textfont\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
85,
4
] | [
150,
34
] | python | en | ['en', 'error', 'th'] | False |
BothEncoderRankerAgent.eval_step | (self, batch) |
We pass the batch first in the biencoder, then filter with crossencoder.
|
We pass the batch first in the biencoder, then filter with crossencoder.
| def eval_step(self, batch):
"""
We pass the batch first in the biencoder, then filter with crossencoder.
"""
output_biencoder = self.biencoder.eval_step(batch)
if output_biencoder is None:
return None
new_candidate_vecs = [
self.biencoder.vectorize_fixed_candidates(cands[0 : self.top_n_bi])
for cands in output_biencoder.text_candidates
]
new_candidates = [
[c for c in cands[0 : self.top_n_bi]]
for cands in output_biencoder.text_candidates
if cands is not None
]
copy_batch = Batch(
text_vec=batch.text_vec,
candidate_vecs=new_candidate_vecs,
candidates=new_candidates,
)
return self.crossencoder.eval_step(copy_batch) | [
"def",
"eval_step",
"(",
"self",
",",
"batch",
")",
":",
"output_biencoder",
"=",
"self",
".",
"biencoder",
".",
"eval_step",
"(",
"batch",
")",
"if",
"output_biencoder",
"is",
"None",
":",
"return",
"None",
"new_candidate_vecs",
"=",
"[",
"self",
".",
"biencoder",
".",
"vectorize_fixed_candidates",
"(",
"cands",
"[",
"0",
":",
"self",
".",
"top_n_bi",
"]",
")",
"for",
"cands",
"in",
"output_biencoder",
".",
"text_candidates",
"]",
"new_candidates",
"=",
"[",
"[",
"c",
"for",
"c",
"in",
"cands",
"[",
"0",
":",
"self",
".",
"top_n_bi",
"]",
"]",
"for",
"cands",
"in",
"output_biencoder",
".",
"text_candidates",
"if",
"cands",
"is",
"not",
"None",
"]",
"copy_batch",
"=",
"Batch",
"(",
"text_vec",
"=",
"batch",
".",
"text_vec",
",",
"candidate_vecs",
"=",
"new_candidate_vecs",
",",
"candidates",
"=",
"new_candidates",
",",
")",
"return",
"self",
".",
"crossencoder",
".",
"eval_step",
"(",
"copy_batch",
")"
] | [
107,
4
] | [
128,
54
] | python | en | ['en', 'error', 'th'] | False |
DepthInstance3DBoxes.gravity_center | (self) | torch.Tensor: A tensor with center of each box. | torch.Tensor: A tensor with center of each box. | def gravity_center(self):
"""torch.Tensor: A tensor with center of each box."""
bottom_center = self.bottom_center
gravity_center = torch.zeros_like(bottom_center)
gravity_center[:, :2] = bottom_center[:, :2]
gravity_center[:, 2] = bottom_center[:, 2] + self.tensor[:, 5] * 0.5
return gravity_center | [
"def",
"gravity_center",
"(",
"self",
")",
":",
"bottom_center",
"=",
"self",
".",
"bottom_center",
"gravity_center",
"=",
"torch",
".",
"zeros_like",
"(",
"bottom_center",
")",
"gravity_center",
"[",
":",
",",
":",
"2",
"]",
"=",
"bottom_center",
"[",
":",
",",
":",
"2",
"]",
"gravity_center",
"[",
":",
",",
"2",
"]",
"=",
"bottom_center",
"[",
":",
",",
"2",
"]",
"+",
"self",
".",
"tensor",
"[",
":",
",",
"5",
"]",
"*",
"0.5",
"return",
"gravity_center"
] | [
36,
4
] | [
42,
29
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.corners | (self) | torch.Tensor: Coordinates of corners of all the boxes
in shape (N, 8, 3).
Convert the boxes to corners in clockwise order, in form of
``(x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0)``
.. code-block:: none
up z
front y ^
/ |
/ |
(x0, y1, z1) + ----------- + (x1, y1, z1)
/| / |
/ | / |
(x0, y0, z1) + ----------- + + (x1, y1, z0)
| / . | /
| / oriign | /
(x0, y0, z0) + ----------- + --------> right x
(x1, y0, z0)
| torch.Tensor: Coordinates of corners of all the boxes
in shape (N, 8, 3). | def corners(self):
"""torch.Tensor: Coordinates of corners of all the boxes
in shape (N, 8, 3).
Convert the boxes to corners in clockwise order, in form of
``(x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0)``
.. code-block:: none
up z
front y ^
/ |
/ |
(x0, y1, z1) + ----------- + (x1, y1, z1)
/| / |
/ | / |
(x0, y0, z1) + ----------- + + (x1, y1, z0)
| / . | /
| / oriign | /
(x0, y0, z0) + ----------- + --------> right x
(x1, y0, z0)
"""
# TODO: rotation_3d_in_axis function do not support
# empty tensor currently.
assert len(self.tensor) != 0
dims = self.dims
corners_norm = torch.from_numpy(
np.stack(np.unravel_index(np.arange(8), [2] * 3), axis=1)).to(
device=dims.device, dtype=dims.dtype)
corners_norm = corners_norm[[0, 1, 3, 2, 4, 5, 7, 6]]
# use relative origin (0.5, 0.5, 0)
corners_norm = corners_norm - dims.new_tensor([0.5, 0.5, 0])
corners = dims.view([-1, 1, 3]) * corners_norm.reshape([1, 8, 3])
# rotate around z axis
corners = rotation_3d_in_axis(corners, self.tensor[:, 6], axis=2)
corners += self.tensor[:, :3].view(-1, 1, 3)
return corners | [
"def",
"corners",
"(",
"self",
")",
":",
"# TODO: rotation_3d_in_axis function do not support",
"# empty tensor currently.",
"assert",
"len",
"(",
"self",
".",
"tensor",
")",
"!=",
"0",
"dims",
"=",
"self",
".",
"dims",
"corners_norm",
"=",
"torch",
".",
"from_numpy",
"(",
"np",
".",
"stack",
"(",
"np",
".",
"unravel_index",
"(",
"np",
".",
"arange",
"(",
"8",
")",
",",
"[",
"2",
"]",
"*",
"3",
")",
",",
"axis",
"=",
"1",
")",
")",
".",
"to",
"(",
"device",
"=",
"dims",
".",
"device",
",",
"dtype",
"=",
"dims",
".",
"dtype",
")",
"corners_norm",
"=",
"corners_norm",
"[",
"[",
"0",
",",
"1",
",",
"3",
",",
"2",
",",
"4",
",",
"5",
",",
"7",
",",
"6",
"]",
"]",
"# use relative origin (0.5, 0.5, 0)",
"corners_norm",
"=",
"corners_norm",
"-",
"dims",
".",
"new_tensor",
"(",
"[",
"0.5",
",",
"0.5",
",",
"0",
"]",
")",
"corners",
"=",
"dims",
".",
"view",
"(",
"[",
"-",
"1",
",",
"1",
",",
"3",
"]",
")",
"*",
"corners_norm",
".",
"reshape",
"(",
"[",
"1",
",",
"8",
",",
"3",
"]",
")",
"# rotate around z axis",
"corners",
"=",
"rotation_3d_in_axis",
"(",
"corners",
",",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
",",
"axis",
"=",
"2",
")",
"corners",
"+=",
"self",
".",
"tensor",
"[",
":",
",",
":",
"3",
"]",
".",
"view",
"(",
"-",
"1",
",",
"1",
",",
"3",
")",
"return",
"corners"
] | [
45,
4
] | [
83,
22
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.bev | (self) | torch.Tensor: A n x 5 tensor of 2D BEV box of each box
in XYWHR format. | torch.Tensor: A n x 5 tensor of 2D BEV box of each box
in XYWHR format. | def bev(self):
"""torch.Tensor: A n x 5 tensor of 2D BEV box of each box
in XYWHR format."""
return self.tensor[:, [0, 1, 3, 4, 6]] | [
"def",
"bev",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
"[",
"0",
",",
"1",
",",
"3",
",",
"4",
",",
"6",
"]",
"]"
] | [
86,
4
] | [
89,
46
] | python | en | ['en', 'vi', 'en'] | True |
DepthInstance3DBoxes.nearest_bev | (self) | torch.Tensor: A tensor of 2D BEV box of each box
without rotation. | torch.Tensor: A tensor of 2D BEV box of each box
without rotation. | def nearest_bev(self):
"""torch.Tensor: A tensor of 2D BEV box of each box
without rotation."""
# Obtain BEV boxes with rotation in XYWHR format
bev_rotated_boxes = self.bev
# convert the rotation to a valid range
rotations = bev_rotated_boxes[:, -1]
normed_rotations = torch.abs(limit_period(rotations, 0.5, np.pi))
# find the center of boxes
conditions = (normed_rotations > np.pi / 4)[..., None]
bboxes_xywh = torch.where(conditions, bev_rotated_boxes[:,
[0, 1, 3, 2]],
bev_rotated_boxes[:, :4])
centers = bboxes_xywh[:, :2]
dims = bboxes_xywh[:, 2:]
bev_boxes = torch.cat([centers - dims / 2, centers + dims / 2], dim=-1)
return bev_boxes | [
"def",
"nearest_bev",
"(",
"self",
")",
":",
"# Obtain BEV boxes with rotation in XYWHR format",
"bev_rotated_boxes",
"=",
"self",
".",
"bev",
"# convert the rotation to a valid range",
"rotations",
"=",
"bev_rotated_boxes",
"[",
":",
",",
"-",
"1",
"]",
"normed_rotations",
"=",
"torch",
".",
"abs",
"(",
"limit_period",
"(",
"rotations",
",",
"0.5",
",",
"np",
".",
"pi",
")",
")",
"# find the center of boxes",
"conditions",
"=",
"(",
"normed_rotations",
">",
"np",
".",
"pi",
"/",
"4",
")",
"[",
"...",
",",
"None",
"]",
"bboxes_xywh",
"=",
"torch",
".",
"where",
"(",
"conditions",
",",
"bev_rotated_boxes",
"[",
":",
",",
"[",
"0",
",",
"1",
",",
"3",
",",
"2",
"]",
"]",
",",
"bev_rotated_boxes",
"[",
":",
",",
":",
"4",
"]",
")",
"centers",
"=",
"bboxes_xywh",
"[",
":",
",",
":",
"2",
"]",
"dims",
"=",
"bboxes_xywh",
"[",
":",
",",
"2",
":",
"]",
"bev_boxes",
"=",
"torch",
".",
"cat",
"(",
"[",
"centers",
"-",
"dims",
"/",
"2",
",",
"centers",
"+",
"dims",
"/",
"2",
"]",
",",
"dim",
"=",
"-",
"1",
")",
"return",
"bev_boxes"
] | [
92,
4
] | [
110,
24
] | python | en | ['en', 'vi', 'en'] | True |
DepthInstance3DBoxes.rotate | (self, angle, points=None) | Rotate boxes with points (optional) with the given angle.
Args:
angle (float, torch.Tensor): Rotation angle.
points (torch.Tensor, numpy.ndarray, :obj:`BasePoints`, optional):
Points to rotate. Defaults to None.
Returns:
tuple or None: When ``points`` is None, the function returns \
None, otherwise it returns the rotated points and the \
rotation matrix ``rot_mat_T``.
| Rotate boxes with points (optional) with the given angle. | def rotate(self, angle, points=None):
"""Rotate boxes with points (optional) with the given angle.
Args:
angle (float, torch.Tensor): Rotation angle.
points (torch.Tensor, numpy.ndarray, :obj:`BasePoints`, optional):
Points to rotate. Defaults to None.
Returns:
tuple or None: When ``points`` is None, the function returns \
None, otherwise it returns the rotated points and the \
rotation matrix ``rot_mat_T``.
"""
if not isinstance(angle, torch.Tensor):
angle = self.tensor.new_tensor(angle)
rot_sin = torch.sin(angle)
rot_cos = torch.cos(angle)
rot_mat_T = self.tensor.new_tensor([[rot_cos, -rot_sin, 0],
[rot_sin, rot_cos, 0], [0, 0,
1]]).T
self.tensor[:, 0:3] = self.tensor[:, 0:3] @ rot_mat_T
if self.with_yaw:
self.tensor[:, 6] -= angle
else:
corners_rot = self.corners @ rot_mat_T
new_x_size = corners_rot[..., 0].max(
dim=1, keepdim=True)[0] - corners_rot[..., 0].min(
dim=1, keepdim=True)[0]
new_y_size = corners_rot[..., 1].max(
dim=1, keepdim=True)[0] - corners_rot[..., 1].min(
dim=1, keepdim=True)[0]
self.tensor[:, 3:5] = torch.cat((new_x_size, new_y_size), dim=-1)
if points is not None:
if isinstance(points, torch.Tensor):
points[:, :3] = points[:, :3] @ rot_mat_T
elif isinstance(points, np.ndarray):
rot_mat_T = rot_mat_T.numpy()
points[:, :3] = np.dot(points[:, :3], rot_mat_T)
elif isinstance(points, BasePoints):
# anti-clockwise
points.rotate(angle)
else:
raise ValueError
return points, rot_mat_T | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"points",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"angle",
",",
"torch",
".",
"Tensor",
")",
":",
"angle",
"=",
"self",
".",
"tensor",
".",
"new_tensor",
"(",
"angle",
")",
"rot_sin",
"=",
"torch",
".",
"sin",
"(",
"angle",
")",
"rot_cos",
"=",
"torch",
".",
"cos",
"(",
"angle",
")",
"rot_mat_T",
"=",
"self",
".",
"tensor",
".",
"new_tensor",
"(",
"[",
"[",
"rot_cos",
",",
"-",
"rot_sin",
",",
"0",
"]",
",",
"[",
"rot_sin",
",",
"rot_cos",
",",
"0",
"]",
",",
"[",
"0",
",",
"0",
",",
"1",
"]",
"]",
")",
".",
"T",
"self",
".",
"tensor",
"[",
":",
",",
"0",
":",
"3",
"]",
"=",
"self",
".",
"tensor",
"[",
":",
",",
"0",
":",
"3",
"]",
"@",
"rot_mat_T",
"if",
"self",
".",
"with_yaw",
":",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
"-=",
"angle",
"else",
":",
"corners_rot",
"=",
"self",
".",
"corners",
"@",
"rot_mat_T",
"new_x_size",
"=",
"corners_rot",
"[",
"...",
",",
"0",
"]",
".",
"max",
"(",
"dim",
"=",
"1",
",",
"keepdim",
"=",
"True",
")",
"[",
"0",
"]",
"-",
"corners_rot",
"[",
"...",
",",
"0",
"]",
".",
"min",
"(",
"dim",
"=",
"1",
",",
"keepdim",
"=",
"True",
")",
"[",
"0",
"]",
"new_y_size",
"=",
"corners_rot",
"[",
"...",
",",
"1",
"]",
".",
"max",
"(",
"dim",
"=",
"1",
",",
"keepdim",
"=",
"True",
")",
"[",
"0",
"]",
"-",
"corners_rot",
"[",
"...",
",",
"1",
"]",
".",
"min",
"(",
"dim",
"=",
"1",
",",
"keepdim",
"=",
"True",
")",
"[",
"0",
"]",
"self",
".",
"tensor",
"[",
":",
",",
"3",
":",
"5",
"]",
"=",
"torch",
".",
"cat",
"(",
"(",
"new_x_size",
",",
"new_y_size",
")",
",",
"dim",
"=",
"-",
"1",
")",
"if",
"points",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"points",
",",
"torch",
".",
"Tensor",
")",
":",
"points",
"[",
":",
",",
":",
"3",
"]",
"=",
"points",
"[",
":",
",",
":",
"3",
"]",
"@",
"rot_mat_T",
"elif",
"isinstance",
"(",
"points",
",",
"np",
".",
"ndarray",
")",
":",
"rot_mat_T",
"=",
"rot_mat_T",
".",
"numpy",
"(",
")",
"points",
"[",
":",
",",
":",
"3",
"]",
"=",
"np",
".",
"dot",
"(",
"points",
"[",
":",
",",
":",
"3",
"]",
",",
"rot_mat_T",
")",
"elif",
"isinstance",
"(",
"points",
",",
"BasePoints",
")",
":",
"# anti-clockwise",
"points",
".",
"rotate",
"(",
"angle",
")",
"else",
":",
"raise",
"ValueError",
"return",
"points",
",",
"rot_mat_T"
] | [
112,
4
] | [
156,
36
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.flip | (self, bev_direction='horizontal', points=None) | Flip the boxes in BEV along given BEV direction.
In Depth coordinates, it flips x (horizontal) or y (vertical) axis.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
points (torch.Tensor, numpy.ndarray, :obj:`BasePoints`, None):
Points to flip. Defaults to None.
Returns:
torch.Tensor, numpy.ndarray or None: Flipped points.
| Flip the boxes in BEV along given BEV direction. | def flip(self, bev_direction='horizontal', points=None):
"""Flip the boxes in BEV along given BEV direction.
In Depth coordinates, it flips x (horizontal) or y (vertical) axis.
Args:
bev_direction (str): Flip direction (horizontal or vertical).
points (torch.Tensor, numpy.ndarray, :obj:`BasePoints`, None):
Points to flip. Defaults to None.
Returns:
torch.Tensor, numpy.ndarray or None: Flipped points.
"""
assert bev_direction in ('horizontal', 'vertical')
if bev_direction == 'horizontal':
self.tensor[:, 0::7] = -self.tensor[:, 0::7]
if self.with_yaw:
self.tensor[:, 6] = -self.tensor[:, 6] + np.pi
elif bev_direction == 'vertical':
self.tensor[:, 1::7] = -self.tensor[:, 1::7]
if self.with_yaw:
self.tensor[:, 6] = -self.tensor[:, 6]
if points is not None:
assert isinstance(points, (torch.Tensor, np.ndarray, BasePoints))
if isinstance(points, (torch.Tensor, np.ndarray)):
if bev_direction == 'horizontal':
points[:, 0] = -points[:, 0]
elif bev_direction == 'vertical':
points[:, 1] = -points[:, 1]
elif isinstance(points, BasePoints):
points.flip(bev_direction)
return points | [
"def",
"flip",
"(",
"self",
",",
"bev_direction",
"=",
"'horizontal'",
",",
"points",
"=",
"None",
")",
":",
"assert",
"bev_direction",
"in",
"(",
"'horizontal'",
",",
"'vertical'",
")",
"if",
"bev_direction",
"==",
"'horizontal'",
":",
"self",
".",
"tensor",
"[",
":",
",",
"0",
":",
":",
"7",
"]",
"=",
"-",
"self",
".",
"tensor",
"[",
":",
",",
"0",
":",
":",
"7",
"]",
"if",
"self",
".",
"with_yaw",
":",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
"=",
"-",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
"+",
"np",
".",
"pi",
"elif",
"bev_direction",
"==",
"'vertical'",
":",
"self",
".",
"tensor",
"[",
":",
",",
"1",
":",
":",
"7",
"]",
"=",
"-",
"self",
".",
"tensor",
"[",
":",
",",
"1",
":",
":",
"7",
"]",
"if",
"self",
".",
"with_yaw",
":",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
"=",
"-",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
"if",
"points",
"is",
"not",
"None",
":",
"assert",
"isinstance",
"(",
"points",
",",
"(",
"torch",
".",
"Tensor",
",",
"np",
".",
"ndarray",
",",
"BasePoints",
")",
")",
"if",
"isinstance",
"(",
"points",
",",
"(",
"torch",
".",
"Tensor",
",",
"np",
".",
"ndarray",
")",
")",
":",
"if",
"bev_direction",
"==",
"'horizontal'",
":",
"points",
"[",
":",
",",
"0",
"]",
"=",
"-",
"points",
"[",
":",
",",
"0",
"]",
"elif",
"bev_direction",
"==",
"'vertical'",
":",
"points",
"[",
":",
",",
"1",
"]",
"=",
"-",
"points",
"[",
":",
",",
"1",
"]",
"elif",
"isinstance",
"(",
"points",
",",
"BasePoints",
")",
":",
"points",
".",
"flip",
"(",
"bev_direction",
")",
"return",
"points"
] | [
158,
4
] | [
190,
25
] | python | en | ['en', 'da', 'en'] | True |
DepthInstance3DBoxes.in_range_bev | (self, box_range) | Check whether the boxes are in the given range.
Args:
box_range (list | torch.Tensor): The range of box
(x_min, y_min, x_max, y_max).
Note:
In the original implementation of SECOND, checking whether
a box in the range checks whether the points are in a convex
polygon, we try to reduce the burdun for simpler cases.
Returns:
torch.Tensor: Indicating whether each box is inside \
the reference range.
| Check whether the boxes are in the given range. | def in_range_bev(self, box_range):
"""Check whether the boxes are in the given range.
Args:
box_range (list | torch.Tensor): The range of box
(x_min, y_min, x_max, y_max).
Note:
In the original implementation of SECOND, checking whether
a box in the range checks whether the points are in a convex
polygon, we try to reduce the burdun for simpler cases.
Returns:
torch.Tensor: Indicating whether each box is inside \
the reference range.
"""
in_range_flags = ((self.tensor[:, 0] > box_range[0])
& (self.tensor[:, 1] > box_range[1])
& (self.tensor[:, 0] < box_range[2])
& (self.tensor[:, 1] < box_range[3]))
return in_range_flags | [
"def",
"in_range_bev",
"(",
"self",
",",
"box_range",
")",
":",
"in_range_flags",
"=",
"(",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"0",
"]",
">",
"box_range",
"[",
"0",
"]",
")",
"&",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"1",
"]",
">",
"box_range",
"[",
"1",
"]",
")",
"&",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"0",
"]",
"<",
"box_range",
"[",
"2",
"]",
")",
"&",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"1",
"]",
"<",
"box_range",
"[",
"3",
"]",
")",
")",
"return",
"in_range_flags"
] | [
192,
4
] | [
212,
29
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.convert_to | (self, dst, rt_mat=None) | Convert self to ``dst`` mode.
Args:
dst (:obj:`BoxMode`): The target Box mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation
matrix between different coordinates. Defaults to None.
The conversion from ``src`` coordinates to ``dst`` coordinates
usually comes along the change of sensors, e.g., from camera
to LiDAR. This requires a transformation matrix.
Returns:
:obj:`DepthInstance3DBoxes`: \
The converted box of the same type in the ``dst`` mode.
| Convert self to ``dst`` mode. | def convert_to(self, dst, rt_mat=None):
"""Convert self to ``dst`` mode.
Args:
dst (:obj:`BoxMode`): The target Box mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation
matrix between different coordinates. Defaults to None.
The conversion from ``src`` coordinates to ``dst`` coordinates
usually comes along the change of sensors, e.g., from camera
to LiDAR. This requires a transformation matrix.
Returns:
:obj:`DepthInstance3DBoxes`: \
The converted box of the same type in the ``dst`` mode.
"""
from .box_3d_mode import Box3DMode
return Box3DMode.convert(
box=self, src=Box3DMode.DEPTH, dst=dst, rt_mat=rt_mat) | [
"def",
"convert_to",
"(",
"self",
",",
"dst",
",",
"rt_mat",
"=",
"None",
")",
":",
"from",
".",
"box_3d_mode",
"import",
"Box3DMode",
"return",
"Box3DMode",
".",
"convert",
"(",
"box",
"=",
"self",
",",
"src",
"=",
"Box3DMode",
".",
"DEPTH",
",",
"dst",
"=",
"dst",
",",
"rt_mat",
"=",
"rt_mat",
")"
] | [
214,
4
] | [
231,
66
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.points_in_boxes | (self, points) | Find points that are in boxes (CUDA).
Args:
points (torch.Tensor): Points in shape [1, M, 3] or [M, 3], \
3 dimensions are [x, y, z] in LiDAR coordinate.
Returns:
torch.Tensor: The index of boxes each point lies in with shape \
of (B, M, T).
| Find points that are in boxes (CUDA). | def points_in_boxes(self, points):
"""Find points that are in boxes (CUDA).
Args:
points (torch.Tensor): Points in shape [1, M, 3] or [M, 3], \
3 dimensions are [x, y, z] in LiDAR coordinate.
Returns:
torch.Tensor: The index of boxes each point lies in with shape \
of (B, M, T).
"""
from .box_3d_mode import Box3DMode
# to lidar
points_lidar = points.clone()
points_lidar = points_lidar[..., [1, 0, 2]]
points_lidar[..., 1] *= -1
if points.dim() == 2:
points_lidar = points_lidar.unsqueeze(0)
else:
assert points.dim() == 3 and points_lidar.shape[0] == 1
boxes_lidar = self.convert_to(Box3DMode.LIDAR).tensor
boxes_lidar = boxes_lidar.to(points.device).unsqueeze(0)
box_idxs_of_pts = points_in_boxes_batch(points_lidar, boxes_lidar)
return box_idxs_of_pts.squeeze(0) | [
"def",
"points_in_boxes",
"(",
"self",
",",
"points",
")",
":",
"from",
".",
"box_3d_mode",
"import",
"Box3DMode",
"# to lidar",
"points_lidar",
"=",
"points",
".",
"clone",
"(",
")",
"points_lidar",
"=",
"points_lidar",
"[",
"...",
",",
"[",
"1",
",",
"0",
",",
"2",
"]",
"]",
"points_lidar",
"[",
"...",
",",
"1",
"]",
"*=",
"-",
"1",
"if",
"points",
".",
"dim",
"(",
")",
"==",
"2",
":",
"points_lidar",
"=",
"points_lidar",
".",
"unsqueeze",
"(",
"0",
")",
"else",
":",
"assert",
"points",
".",
"dim",
"(",
")",
"==",
"3",
"and",
"points_lidar",
".",
"shape",
"[",
"0",
"]",
"==",
"1",
"boxes_lidar",
"=",
"self",
".",
"convert_to",
"(",
"Box3DMode",
".",
"LIDAR",
")",
".",
"tensor",
"boxes_lidar",
"=",
"boxes_lidar",
".",
"to",
"(",
"points",
".",
"device",
")",
".",
"unsqueeze",
"(",
"0",
")",
"box_idxs_of_pts",
"=",
"points_in_boxes_batch",
"(",
"points_lidar",
",",
"boxes_lidar",
")",
"return",
"box_idxs_of_pts",
".",
"squeeze",
"(",
"0",
")"
] | [
233,
4
] | [
259,
41
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.enlarged_box | (self, extra_width) | Enlarge the length, width and height boxes.
Args:
extra_width (float | torch.Tensor): Extra width to enlarge the box.
Returns:
:obj:`LiDARInstance3DBoxes`: Enlarged boxes.
| Enlarge the length, width and height boxes. | def enlarged_box(self, extra_width):
"""Enlarge the length, width and height boxes.
Args:
extra_width (float | torch.Tensor): Extra width to enlarge the box.
Returns:
:obj:`LiDARInstance3DBoxes`: Enlarged boxes.
"""
enlarged_boxes = self.tensor.clone()
enlarged_boxes[:, 3:6] += extra_width * 2
# bottom center z minus extra_width
enlarged_boxes[:, 2] -= extra_width
return self.new_box(enlarged_boxes) | [
"def",
"enlarged_box",
"(",
"self",
",",
"extra_width",
")",
":",
"enlarged_boxes",
"=",
"self",
".",
"tensor",
".",
"clone",
"(",
")",
"enlarged_boxes",
"[",
":",
",",
"3",
":",
"6",
"]",
"+=",
"extra_width",
"*",
"2",
"# bottom center z minus extra_width",
"enlarged_boxes",
"[",
":",
",",
"2",
"]",
"-=",
"extra_width",
"return",
"self",
".",
"new_box",
"(",
"enlarged_boxes",
")"
] | [
261,
4
] | [
274,
43
] | python | en | ['en', 'en', 'en'] | True |
DepthInstance3DBoxes.get_surface_line_center | (self) | Compute surface and line center of bounding boxes.
Returns:
torch.Tensor: Surface and line center of bounding boxes.
| Compute surface and line center of bounding boxes. | def get_surface_line_center(self):
"""Compute surface and line center of bounding boxes.
Returns:
torch.Tensor: Surface and line center of bounding boxes.
"""
obj_size = self.dims
center = self.gravity_center.view(-1, 1, 3)
batch_size = center.shape[0]
rot_sin = torch.sin(-self.yaw)
rot_cos = torch.cos(-self.yaw)
rot_mat_T = self.yaw.new_zeros(tuple(list(self.yaw.shape) + [3, 3]))
rot_mat_T[..., 0, 0] = rot_cos
rot_mat_T[..., 0, 1] = -rot_sin
rot_mat_T[..., 1, 0] = rot_sin
rot_mat_T[..., 1, 1] = rot_cos
rot_mat_T[..., 2, 2] = 1
# Get the object surface center
offset = obj_size.new_tensor([[0, 0, 1], [0, 0, -1], [0, 1, 0],
[0, -1, 0], [1, 0, 0], [-1, 0, 0]])
offset = offset.view(1, 6, 3) / 2
surface_3d = (offset *
obj_size.view(batch_size, 1, 3).repeat(1, 6, 1)).reshape(
-1, 3)
# Get the object line center
offset = obj_size.new_tensor([[1, 0, 1], [-1, 0, 1], [0, 1, 1],
[0, -1, 1], [1, 0, -1], [-1, 0, -1],
[0, 1, -1], [0, -1, -1], [1, 1, 0],
[1, -1, 0], [-1, 1, 0], [-1, -1, 0]])
offset = offset.view(1, 12, 3) / 2
line_3d = (offset *
obj_size.view(batch_size, 1, 3).repeat(1, 12, 1)).reshape(
-1, 3)
surface_rot = rot_mat_T.repeat(6, 1, 1)
surface_3d = torch.matmul(
surface_3d.unsqueeze(-2), surface_rot.transpose(2, 1)).squeeze(-2)
surface_center = center.repeat(1, 6, 1).reshape(-1, 3) + surface_3d
line_rot = rot_mat_T.repeat(12, 1, 1)
line_3d = torch.matmul(
line_3d.unsqueeze(-2), line_rot.transpose(2, 1)).squeeze(-2)
line_center = center.repeat(1, 12, 1).reshape(-1, 3) + line_3d
return surface_center, line_center | [
"def",
"get_surface_line_center",
"(",
"self",
")",
":",
"obj_size",
"=",
"self",
".",
"dims",
"center",
"=",
"self",
".",
"gravity_center",
".",
"view",
"(",
"-",
"1",
",",
"1",
",",
"3",
")",
"batch_size",
"=",
"center",
".",
"shape",
"[",
"0",
"]",
"rot_sin",
"=",
"torch",
".",
"sin",
"(",
"-",
"self",
".",
"yaw",
")",
"rot_cos",
"=",
"torch",
".",
"cos",
"(",
"-",
"self",
".",
"yaw",
")",
"rot_mat_T",
"=",
"self",
".",
"yaw",
".",
"new_zeros",
"(",
"tuple",
"(",
"list",
"(",
"self",
".",
"yaw",
".",
"shape",
")",
"+",
"[",
"3",
",",
"3",
"]",
")",
")",
"rot_mat_T",
"[",
"...",
",",
"0",
",",
"0",
"]",
"=",
"rot_cos",
"rot_mat_T",
"[",
"...",
",",
"0",
",",
"1",
"]",
"=",
"-",
"rot_sin",
"rot_mat_T",
"[",
"...",
",",
"1",
",",
"0",
"]",
"=",
"rot_sin",
"rot_mat_T",
"[",
"...",
",",
"1",
",",
"1",
"]",
"=",
"rot_cos",
"rot_mat_T",
"[",
"...",
",",
"2",
",",
"2",
"]",
"=",
"1",
"# Get the object surface center",
"offset",
"=",
"obj_size",
".",
"new_tensor",
"(",
"[",
"[",
"0",
",",
"0",
",",
"1",
"]",
",",
"[",
"0",
",",
"0",
",",
"-",
"1",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
"]",
",",
"[",
"0",
",",
"-",
"1",
",",
"0",
"]",
",",
"[",
"1",
",",
"0",
",",
"0",
"]",
",",
"[",
"-",
"1",
",",
"0",
",",
"0",
"]",
"]",
")",
"offset",
"=",
"offset",
".",
"view",
"(",
"1",
",",
"6",
",",
"3",
")",
"/",
"2",
"surface_3d",
"=",
"(",
"offset",
"*",
"obj_size",
".",
"view",
"(",
"batch_size",
",",
"1",
",",
"3",
")",
".",
"repeat",
"(",
"1",
",",
"6",
",",
"1",
")",
")",
".",
"reshape",
"(",
"-",
"1",
",",
"3",
")",
"# Get the object line center",
"offset",
"=",
"obj_size",
".",
"new_tensor",
"(",
"[",
"[",
"1",
",",
"0",
",",
"1",
"]",
",",
"[",
"-",
"1",
",",
"0",
",",
"1",
"]",
",",
"[",
"0",
",",
"1",
",",
"1",
"]",
",",
"[",
"0",
",",
"-",
"1",
",",
"1",
"]",
",",
"[",
"1",
",",
"0",
",",
"-",
"1",
"]",
",",
"[",
"-",
"1",
",",
"0",
",",
"-",
"1",
"]",
",",
"[",
"0",
",",
"1",
",",
"-",
"1",
"]",
",",
"[",
"0",
",",
"-",
"1",
",",
"-",
"1",
"]",
",",
"[",
"1",
",",
"1",
",",
"0",
"]",
",",
"[",
"1",
",",
"-",
"1",
",",
"0",
"]",
",",
"[",
"-",
"1",
",",
"1",
",",
"0",
"]",
",",
"[",
"-",
"1",
",",
"-",
"1",
",",
"0",
"]",
"]",
")",
"offset",
"=",
"offset",
".",
"view",
"(",
"1",
",",
"12",
",",
"3",
")",
"/",
"2",
"line_3d",
"=",
"(",
"offset",
"*",
"obj_size",
".",
"view",
"(",
"batch_size",
",",
"1",
",",
"3",
")",
".",
"repeat",
"(",
"1",
",",
"12",
",",
"1",
")",
")",
".",
"reshape",
"(",
"-",
"1",
",",
"3",
")",
"surface_rot",
"=",
"rot_mat_T",
".",
"repeat",
"(",
"6",
",",
"1",
",",
"1",
")",
"surface_3d",
"=",
"torch",
".",
"matmul",
"(",
"surface_3d",
".",
"unsqueeze",
"(",
"-",
"2",
")",
",",
"surface_rot",
".",
"transpose",
"(",
"2",
",",
"1",
")",
")",
".",
"squeeze",
"(",
"-",
"2",
")",
"surface_center",
"=",
"center",
".",
"repeat",
"(",
"1",
",",
"6",
",",
"1",
")",
".",
"reshape",
"(",
"-",
"1",
",",
"3",
")",
"+",
"surface_3d",
"line_rot",
"=",
"rot_mat_T",
".",
"repeat",
"(",
"12",
",",
"1",
",",
"1",
")",
"line_3d",
"=",
"torch",
".",
"matmul",
"(",
"line_3d",
".",
"unsqueeze",
"(",
"-",
"2",
")",
",",
"line_rot",
".",
"transpose",
"(",
"2",
",",
"1",
")",
")",
".",
"squeeze",
"(",
"-",
"2",
")",
"line_center",
"=",
"center",
".",
"repeat",
"(",
"1",
",",
"12",
",",
"1",
")",
".",
"reshape",
"(",
"-",
"1",
",",
"3",
")",
"+",
"line_3d",
"return",
"surface_center",
",",
"line_center"
] | [
276,
4
] | [
324,
42
] | python | en | ['en', 'en', 'en'] | True |
PersonalityCaptionsTeacher.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command line args.
|
Add command line args.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command line args.
"""
agent = parser.add_argument_group('Personality-Captions arguments')
agent.add_argument(
'--include-personality',
type='bool',
default=True,
help='Whether to provide personality to agent',
)
agent.add_argument(
'--include-image',
type='bool',
default=True,
help='Whether to provide image to agent',
)
agent.add_argument(
'--num-test-labels',
type=int,
default=1,
choices=[1, 5],
help='Provide model with either 1 or 5 possible '
'labels for each test example. The number of label '
'candidates for each case is 100 and 500 '
'respectively.',
)
agent.add_argument(
'--yfcc-path',
type=str,
default=None,
help='Path to yfcc images (if not downloaded '
'via the provided download script)',
)
return parser | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"agent",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Personality-Captions arguments'",
")",
"agent",
".",
"add_argument",
"(",
"'--include-personality'",
",",
"type",
"=",
"'bool'",
",",
"default",
"=",
"True",
",",
"help",
"=",
"'Whether to provide personality to agent'",
",",
")",
"agent",
".",
"add_argument",
"(",
"'--include-image'",
",",
"type",
"=",
"'bool'",
",",
"default",
"=",
"True",
",",
"help",
"=",
"'Whether to provide image to agent'",
",",
")",
"agent",
".",
"add_argument",
"(",
"'--num-test-labels'",
",",
"type",
"=",
"int",
",",
"default",
"=",
"1",
",",
"choices",
"=",
"[",
"1",
",",
"5",
"]",
",",
"help",
"=",
"'Provide model with either 1 or 5 possible '",
"'labels for each test example. The number of label '",
"'candidates for each case is 100 and 500 '",
"'respectively.'",
",",
")",
"agent",
".",
"add_argument",
"(",
"'--yfcc-path'",
",",
"type",
"=",
"str",
",",
"default",
"=",
"None",
",",
"help",
"=",
"'Path to yfcc images (if not downloaded '",
"'via the provided download script)'",
",",
")",
"return",
"parser"
] | [
73,
4
] | [
109,
21
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.reset | (self) |
Reset teacher.
|
Reset teacher.
| def reset(self):
"""
Reset teacher.
"""
super().reset()
self.example = None | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"reset",
"(",
")",
"self",
".",
"example",
"=",
"None"
] | [
118,
4
] | [
123,
27
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.num_episodes | (self) |
Return number of episodes.
|
Return number of episodes.
| def num_episodes(self):
"""
Return number of episodes.
"""
return self.num_examples() | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_examples",
"(",
")"
] | [
125,
4
] | [
129,
34
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.num_examples | (self) |
Return number of examples.
|
Return number of examples.
| def num_examples(self):
"""
Return number of examples.
"""
return len(self.data) | [
"def",
"num_examples",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"data",
")"
] | [
131,
4
] | [
135,
29
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.submit_load_request | (self, image_id) |
Submit a load request to the image loader.
:param image_id:
id of image to load
|
Submit a load request to the image loader. | def submit_load_request(self, image_id):
"""
Submit a load request to the image loader.
:param image_id:
id of image to load
"""
img_path = os.path.join(self.image_path, '{}.jpg'.format(image_id))
self.data_loader.request_load(
self.receive_data, self.image_loader.load, (img_path,)
) | [
"def",
"submit_load_request",
"(",
"self",
",",
"image_id",
")",
":",
"img_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"image_path",
",",
"'{}.jpg'",
".",
"format",
"(",
"image_id",
")",
")",
"self",
".",
"data_loader",
".",
"request_load",
"(",
"self",
".",
"receive_data",
",",
"self",
".",
"image_loader",
".",
"load",
",",
"(",
"img_path",
",",
")",
")"
] | [
137,
4
] | [
147,
9
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.get | (self, episode_idx, entry_idx=0) |
Get an example.
:param episode_idx:
index of episode in self.data
:param entry_idx:
optional, which entry in the episode to get
:return:
an example
|
Get an example. | def get(self, episode_idx, entry_idx=0):
"""
Get an example.
:param episode_idx:
index of episode in self.data
:param entry_idx:
optional, which entry in the episode to get
:return:
an example
"""
data = self.data[episode_idx]
action = {
'text': data['personality'] if self.include_personality else '',
'image_id': data['image_hash'],
'episode_done': True,
'labels': [data['comment']],
}
if self.num_test_labels == 5 and 'test' in self.datatype:
action['labels'] += data['additional_comments']
if 'candidates' in data:
if self.num_test_labels == 5 and 'test' in self.datatype:
action['label_candidates'] = data['500_candidates']
else:
action['label_candidates'] = data['candidates']
return action | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"0",
")",
":",
"data",
"=",
"self",
".",
"data",
"[",
"episode_idx",
"]",
"action",
"=",
"{",
"'text'",
":",
"data",
"[",
"'personality'",
"]",
"if",
"self",
".",
"include_personality",
"else",
"''",
",",
"'image_id'",
":",
"data",
"[",
"'image_hash'",
"]",
",",
"'episode_done'",
":",
"True",
",",
"'labels'",
":",
"[",
"data",
"[",
"'comment'",
"]",
"]",
",",
"}",
"if",
"self",
".",
"num_test_labels",
"==",
"5",
"and",
"'test'",
"in",
"self",
".",
"datatype",
":",
"action",
"[",
"'labels'",
"]",
"+=",
"data",
"[",
"'additional_comments'",
"]",
"if",
"'candidates'",
"in",
"data",
":",
"if",
"self",
".",
"num_test_labels",
"==",
"5",
"and",
"'test'",
"in",
"self",
".",
"datatype",
":",
"action",
"[",
"'label_candidates'",
"]",
"=",
"data",
"[",
"'500_candidates'",
"]",
"else",
":",
"action",
"[",
"'label_candidates'",
"]",
"=",
"data",
"[",
"'candidates'",
"]",
"return",
"action"
] | [
149,
4
] | [
178,
21
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.next_example | (self) |
Return the next example from this dataset.
Queues next example.
|
Return the next example from this dataset. | def next_example(self):
"""
Return the next example from this dataset.
Queues next example.
"""
ready = None
load_image = self.image_mode != 'no_image_model' and self.include_image
# pull up the currently queued example
if self.example is not None:
# if self.image_mode != 'none' and 'image_id' in self.example:
if load_image and 'image_id' in self.example:
# move the image we loaded in the background into the example
image = self.data_queue.get()
self.example['image'] = image
ready = (self.example, self.imageEpochDone)
# get the next base example: super().next_example() calls self.get()
self.example, self.imageEpochDone = super().next_example()
# if self.image_mode != 'none' and 'image_id' in self.example:
if load_image and 'image_id' in self.example:
# load the next image in the background
image_id = self.example['image_id']
self.submit_load_request(image_id)
# Try to return the previously cached example
if ready is None:
return self.next_example()
else:
return ready | [
"def",
"next_example",
"(",
"self",
")",
":",
"ready",
"=",
"None",
"load_image",
"=",
"self",
".",
"image_mode",
"!=",
"'no_image_model'",
"and",
"self",
".",
"include_image",
"# pull up the currently queued example",
"if",
"self",
".",
"example",
"is",
"not",
"None",
":",
"# if self.image_mode != 'none' and 'image_id' in self.example:",
"if",
"load_image",
"and",
"'image_id'",
"in",
"self",
".",
"example",
":",
"# move the image we loaded in the background into the example",
"image",
"=",
"self",
".",
"data_queue",
".",
"get",
"(",
")",
"self",
".",
"example",
"[",
"'image'",
"]",
"=",
"image",
"ready",
"=",
"(",
"self",
".",
"example",
",",
"self",
".",
"imageEpochDone",
")",
"# get the next base example: super().next_example() calls self.get()",
"self",
".",
"example",
",",
"self",
".",
"imageEpochDone",
"=",
"super",
"(",
")",
".",
"next_example",
"(",
")",
"# if self.image_mode != 'none' and 'image_id' in self.example:",
"if",
"load_image",
"and",
"'image_id'",
"in",
"self",
".",
"example",
":",
"# load the next image in the background",
"image_id",
"=",
"self",
".",
"example",
"[",
"'image_id'",
"]",
"self",
".",
"submit_load_request",
"(",
"image_id",
")",
"# Try to return the previously cached example",
"if",
"ready",
"is",
"None",
":",
"return",
"self",
".",
"next_example",
"(",
")",
"else",
":",
"return",
"ready"
] | [
180,
4
] | [
207,
24
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTeacher.share | (self) |
Share appropriate attributes.
|
Share appropriate attributes.
| def share(self):
"""
Share appropriate attributes.
"""
shared = super().share()
shared['data'] = self.data
shared['image_loader'] = self.image_loader
return shared | [
"def",
"share",
"(",
"self",
")",
":",
"shared",
"=",
"super",
"(",
")",
".",
"share",
"(",
")",
"shared",
"[",
"'data'",
"]",
"=",
"self",
".",
"data",
"shared",
"[",
"'image_loader'",
"]",
"=",
"self",
".",
"image_loader",
"return",
"shared"
] | [
209,
4
] | [
216,
21
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTestTeacher.reset | (self) |
Reset teacher.
|
Reset teacher.
| def reset(self):
"""
Reset teacher.
"""
super().reset()
self.example = None | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"reset",
"(",
")",
"self",
".",
"example",
"=",
"None"
] | [
238,
4
] | [
243,
27
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTestTeacher.num_episodes | (self) |
Return number of episodes.
|
Return number of episodes.
| def num_episodes(self):
"""
Return number of episodes.
"""
return len(self.image_features) | [
"def",
"num_episodes",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"image_features",
")"
] | [
245,
4
] | [
249,
39
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTestTeacher.num_examples | (self) |
Return number of examples.
|
Return number of examples.
| def num_examples(self):
"""
Return number of examples.
"""
return len(self.image_features) | [
"def",
"num_examples",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"image_features",
")"
] | [
251,
4
] | [
255,
39
] | python | en | ['en', 'error', 'th'] | False |
PersonalityCaptionsTestTeacher.get | (self, episode_idx, entry_idx=0) |
Get an example.
:param episode_idx:
index of episode in self.data
:param entry_idx:
optional, which entry in the episode to get
:return:
an example
|
Get an example. | def get(self, episode_idx, entry_idx=0):
"""
Get an example.
:param episode_idx:
index of episode in self.data
:param entry_idx:
optional, which entry in the episode to get
:return:
an example
"""
data = self.data[episode_idx]
action = {
'text': data['personality'] if self.include_personality else '',
'image': self.image_features[data['image_hash']],
'episode_done': True,
'labels': [data['comment']],
}
if self.num_test_labels == 5 and 'test' in self.datatype:
action['labels'] += data['additional_comments']
if 'candidates' in data:
if self.num_test_labels == 5 and 'test' in self.datatype:
action['label_candidates'] = data['500_candidates']
else:
action['label_candidates'] = data['candidates']
return action | [
"def",
"get",
"(",
"self",
",",
"episode_idx",
",",
"entry_idx",
"=",
"0",
")",
":",
"data",
"=",
"self",
".",
"data",
"[",
"episode_idx",
"]",
"action",
"=",
"{",
"'text'",
":",
"data",
"[",
"'personality'",
"]",
"if",
"self",
".",
"include_personality",
"else",
"''",
",",
"'image'",
":",
"self",
".",
"image_features",
"[",
"data",
"[",
"'image_hash'",
"]",
"]",
",",
"'episode_done'",
":",
"True",
",",
"'labels'",
":",
"[",
"data",
"[",
"'comment'",
"]",
"]",
",",
"}",
"if",
"self",
".",
"num_test_labels",
"==",
"5",
"and",
"'test'",
"in",
"self",
".",
"datatype",
":",
"action",
"[",
"'labels'",
"]",
"+=",
"data",
"[",
"'additional_comments'",
"]",
"if",
"'candidates'",
"in",
"data",
":",
"if",
"self",
".",
"num_test_labels",
"==",
"5",
"and",
"'test'",
"in",
"self",
".",
"datatype",
":",
"action",
"[",
"'label_candidates'",
"]",
"=",
"data",
"[",
"'500_candidates'",
"]",
"else",
":",
"action",
"[",
"'label_candidates'",
"]",
"=",
"data",
"[",
"'candidates'",
"]",
"return",
"action"
] | [
257,
4
] | [
286,
21
] | python | en | ['en', 'error', 'th'] | False |
setup_args | () |
Set up args.
:return: A parser that takes in command line arguments for chat services (debug, config-path, password), and a port.
|
Set up args. | def setup_args():
"""
Set up args.
:return: A parser that takes in command line arguments for chat services (debug, config-path, password), and a port.
"""
parser = ParlaiParser(False, False)
parser.add_parlai_data_path()
parser.add_chatservice_args()
parser_grp = parser.add_argument_group('Browser Chat')
parser_grp.add_argument(
'--port', default=35496, type=int, help='Port to run the browser chat server'
)
return parser.parse_args() | [
"def",
"setup_args",
"(",
")",
":",
"parser",
"=",
"ParlaiParser",
"(",
"False",
",",
"False",
")",
"parser",
".",
"add_parlai_data_path",
"(",
")",
"parser",
".",
"add_chatservice_args",
"(",
")",
"parser_grp",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Browser Chat'",
")",
"parser_grp",
".",
"add_argument",
"(",
"'--port'",
",",
"default",
"=",
"35496",
",",
"type",
"=",
"int",
",",
"help",
"=",
"'Port to run the browser chat server'",
")",
"return",
"parser",
".",
"parse_args",
"(",
")"
] | [
19,
0
] | [
32,
30
] | python | en | ['en', 'error', 'th'] | False |
run | (opt) |
Run BrowserManager.
|
Run BrowserManager.
| def run(opt):
"""
Run BrowserManager.
"""
opt['service'] = SERVICE_NAME
manager = BrowserManager(opt)
try:
manager.start_task()
finally:
manager.shutdown() | [
"def",
"run",
"(",
"opt",
")",
":",
"opt",
"[",
"'service'",
"]",
"=",
"SERVICE_NAME",
"manager",
"=",
"BrowserManager",
"(",
"opt",
")",
"try",
":",
"manager",
".",
"start_task",
"(",
")",
"finally",
":",
"manager",
".",
"shutdown",
"(",
")"
] | [
35,
0
] | [
44,
26
] | python | en | ['en', 'error', 'th'] | False |
Bottleneck.__init__ | (self,
inplanes,
planes,
groups=1,
base_width=4,
base_channels=64,
**kwargs) | Bottleneck block for ResNeXt.
If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
it is "caffe", the stride-two layer is the first 1x1 conv layer.
| Bottleneck block for ResNeXt. | def __init__(self,
inplanes,
planes,
groups=1,
base_width=4,
base_channels=64,
**kwargs):
"""Bottleneck block for ResNeXt.
If style is "pytorch", the stride-two layer is the 3x3 conv layer, if
it is "caffe", the stride-two layer is the first 1x1 conv layer.
"""
super(Bottleneck, self).__init__(inplanes, planes, **kwargs)
if groups == 1:
width = self.planes
else:
width = math.floor(self.planes *
(base_width / base_channels)) * groups
self.norm1_name, norm1 = build_norm_layer(
self.norm_cfg, width, postfix=1)
self.norm2_name, norm2 = build_norm_layer(
self.norm_cfg, width, postfix=2)
self.norm3_name, norm3 = build_norm_layer(
self.norm_cfg, self.planes * self.expansion, postfix=3)
self.conv1 = build_conv_layer(
self.conv_cfg,
self.inplanes,
width,
kernel_size=1,
stride=self.conv1_stride,
bias=False)
self.add_module(self.norm1_name, norm1)
fallback_on_stride = False
self.with_modulated_dcn = False
if self.with_dcn:
fallback_on_stride = self.dcn.pop('fallback_on_stride', False)
if not self.with_dcn or fallback_on_stride:
self.conv2 = build_conv_layer(
self.conv_cfg,
width,
width,
kernel_size=3,
stride=self.conv2_stride,
padding=self.dilation,
dilation=self.dilation,
groups=groups,
bias=False)
else:
assert self.conv_cfg is None, 'conv_cfg must be None for DCN'
self.conv2 = build_conv_layer(
self.dcn,
width,
width,
kernel_size=3,
stride=self.conv2_stride,
padding=self.dilation,
dilation=self.dilation,
groups=groups,
bias=False)
self.add_module(self.norm2_name, norm2)
self.conv3 = build_conv_layer(
self.conv_cfg,
width,
self.planes * self.expansion,
kernel_size=1,
bias=False)
self.add_module(self.norm3_name, norm3) | [
"def",
"__init__",
"(",
"self",
",",
"inplanes",
",",
"planes",
",",
"groups",
"=",
"1",
",",
"base_width",
"=",
"4",
",",
"base_channels",
"=",
"64",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Bottleneck",
",",
"self",
")",
".",
"__init__",
"(",
"inplanes",
",",
"planes",
",",
"*",
"*",
"kwargs",
")",
"if",
"groups",
"==",
"1",
":",
"width",
"=",
"self",
".",
"planes",
"else",
":",
"width",
"=",
"math",
".",
"floor",
"(",
"self",
".",
"planes",
"*",
"(",
"base_width",
"/",
"base_channels",
")",
")",
"*",
"groups",
"self",
".",
"norm1_name",
",",
"norm1",
"=",
"build_norm_layer",
"(",
"self",
".",
"norm_cfg",
",",
"width",
",",
"postfix",
"=",
"1",
")",
"self",
".",
"norm2_name",
",",
"norm2",
"=",
"build_norm_layer",
"(",
"self",
".",
"norm_cfg",
",",
"width",
",",
"postfix",
"=",
"2",
")",
"self",
".",
"norm3_name",
",",
"norm3",
"=",
"build_norm_layer",
"(",
"self",
".",
"norm_cfg",
",",
"self",
".",
"planes",
"*",
"self",
".",
"expansion",
",",
"postfix",
"=",
"3",
")",
"self",
".",
"conv1",
"=",
"build_conv_layer",
"(",
"self",
".",
"conv_cfg",
",",
"self",
".",
"inplanes",
",",
"width",
",",
"kernel_size",
"=",
"1",
",",
"stride",
"=",
"self",
".",
"conv1_stride",
",",
"bias",
"=",
"False",
")",
"self",
".",
"add_module",
"(",
"self",
".",
"norm1_name",
",",
"norm1",
")",
"fallback_on_stride",
"=",
"False",
"self",
".",
"with_modulated_dcn",
"=",
"False",
"if",
"self",
".",
"with_dcn",
":",
"fallback_on_stride",
"=",
"self",
".",
"dcn",
".",
"pop",
"(",
"'fallback_on_stride'",
",",
"False",
")",
"if",
"not",
"self",
".",
"with_dcn",
"or",
"fallback_on_stride",
":",
"self",
".",
"conv2",
"=",
"build_conv_layer",
"(",
"self",
".",
"conv_cfg",
",",
"width",
",",
"width",
",",
"kernel_size",
"=",
"3",
",",
"stride",
"=",
"self",
".",
"conv2_stride",
",",
"padding",
"=",
"self",
".",
"dilation",
",",
"dilation",
"=",
"self",
".",
"dilation",
",",
"groups",
"=",
"groups",
",",
"bias",
"=",
"False",
")",
"else",
":",
"assert",
"self",
".",
"conv_cfg",
"is",
"None",
",",
"'conv_cfg must be None for DCN'",
"self",
".",
"conv2",
"=",
"build_conv_layer",
"(",
"self",
".",
"dcn",
",",
"width",
",",
"width",
",",
"kernel_size",
"=",
"3",
",",
"stride",
"=",
"self",
".",
"conv2_stride",
",",
"padding",
"=",
"self",
".",
"dilation",
",",
"dilation",
"=",
"self",
".",
"dilation",
",",
"groups",
"=",
"groups",
",",
"bias",
"=",
"False",
")",
"self",
".",
"add_module",
"(",
"self",
".",
"norm2_name",
",",
"norm2",
")",
"self",
".",
"conv3",
"=",
"build_conv_layer",
"(",
"self",
".",
"conv_cfg",
",",
"width",
",",
"self",
".",
"planes",
"*",
"self",
".",
"expansion",
",",
"kernel_size",
"=",
"1",
",",
"bias",
"=",
"False",
")",
"self",
".",
"add_module",
"(",
"self",
".",
"norm3_name",
",",
"norm3",
")"
] | [
13,
4
] | [
83,
47
] | python | en | ['en', 'no', '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
- 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.splom.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.splom.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.splom.hoverlabel.Font
constructor must be a dict or
an instance of :class:`plotly.graph_objs.splom.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.splom.hoverlabel.Font \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.splom.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 |
AccountDB.__cmdset_storage_get | (self) |
Getter. Allows for value = self.name. Returns a list of cmdset_storage.
|
Getter. Allows for value = self.name. Returns a list of cmdset_storage.
| def __cmdset_storage_get(self):
"""
Getter. Allows for value = self.name. Returns a list of cmdset_storage.
"""
storage = self.db_cmdset_storage
# we need to check so storage is not None
return [path.strip() for path in storage.split(',')] if storage else [] | [
"def",
"__cmdset_storage_get",
"(",
"self",
")",
":",
"storage",
"=",
"self",
".",
"db_cmdset_storage",
"# we need to check so storage is not None",
"return",
"[",
"path",
".",
"strip",
"(",
")",
"for",
"path",
"in",
"storage",
".",
"split",
"(",
"','",
")",
"]",
"if",
"storage",
"else",
"[",
"]"
] | [
109,
4
] | [
115,
79
] | python | en | ['en', 'error', 'th'] | False |
AccountDB.__cmdset_storage_set | (self, value) |
Setter. Allows for self.name = value. Stores as a comma-separated
string.
|
Setter. Allows for self.name = value. Stores as a comma-separated
string.
| def __cmdset_storage_set(self, value):
"""
Setter. Allows for self.name = value. Stores as a comma-separated
string.
"""
_SA(self, "db_cmdset_storage", ",".join(str(val).strip() for val in make_iter(value)))
_GA(self, "save")() | [
"def",
"__cmdset_storage_set",
"(",
"self",
",",
"value",
")",
":",
"_SA",
"(",
"self",
",",
"\"db_cmdset_storage\"",
",",
"\",\"",
".",
"join",
"(",
"str",
"(",
"val",
")",
".",
"strip",
"(",
")",
"for",
"val",
"in",
"make_iter",
"(",
"value",
")",
")",
")",
"_GA",
"(",
"self",
",",
"\"save\"",
")",
"(",
")"
] | [
118,
4
] | [
124,
27
] | python | en | ['en', 'error', 'th'] | False |
AccountDB.__cmdset_storage_del | (self) | Deleter. Allows for del self.name | Deleter. Allows for del self.name | def __cmdset_storage_del(self):
"Deleter. Allows for del self.name"
_SA(self, "db_cmdset_storage", None)
_GA(self, "save")() | [
"def",
"__cmdset_storage_del",
"(",
"self",
")",
":",
"_SA",
"(",
"self",
",",
"\"db_cmdset_storage\"",
",",
"None",
")",
"_GA",
"(",
"self",
",",
"\"save\"",
")",
"(",
")"
] | [
127,
4
] | [
130,
27
] | python | ca | ['ca', 'en', 'it'] | False |
AccountDB.__uid_get | (self) | Getter. Retrieves the user id | Getter. Retrieves the user id | def __uid_get(self):
"Getter. Retrieves the user id"
return self.id | [
"def",
"__uid_get",
"(",
"self",
")",
":",
"return",
"self",
".",
"id"
] | [
159,
4
] | [
161,
22
] | python | en | ['en', 'en', 'en'] | True |
build_figure_py | (
trace_node,
base_package,
base_classname,
fig_classname,
data_validator,
layout_validator,
frame_validator,
subplot_nodes,
layout_array_nodes,
) |
Parameters
----------
trace_node : PlotlyNode
Root trace node (the node that is the parent of all of the
individual trace nodes like bar, scatter, etc.)
base_package : str
Package that the figure's superclass resides in
base_classname : str
Name of the figure's superclass
fig_classname : str
Name of the Figure class to be generated
data_validator : BaseDataValidator
DataValidator instance
layout_validator : CompoundValidator
LayoutValidator instance
frame_validator : CompoundArrayValidator
FrameValidator instance
subplot_nodes: list of str
List of names of all of the layout subplot properties
layout_array_nodes: list of PlotlyNode
List of array nodes under layout that can be positioned using xref/yref
Returns
-------
str
Source code for figure class definition
| def build_figure_py(
trace_node,
base_package,
base_classname,
fig_classname,
data_validator,
layout_validator,
frame_validator,
subplot_nodes,
layout_array_nodes,
):
"""
Parameters
----------
trace_node : PlotlyNode
Root trace node (the node that is the parent of all of the
individual trace nodes like bar, scatter, etc.)
base_package : str
Package that the figure's superclass resides in
base_classname : str
Name of the figure's superclass
fig_classname : str
Name of the Figure class to be generated
data_validator : BaseDataValidator
DataValidator instance
layout_validator : CompoundValidator
LayoutValidator instance
frame_validator : CompoundArrayValidator
FrameValidator instance
subplot_nodes: list of str
List of names of all of the layout subplot properties
layout_array_nodes: list of PlotlyNode
List of array nodes under layout that can be positioned using xref/yref
Returns
-------
str
Source code for figure class definition
"""
# Initialize source code buffer
# -----------------------------
buffer = StringIO()
# Get list of trace type nodes
# ----------------------------
trace_nodes = trace_node.child_compound_datatypes
# Write imports
# -------------
# ### Import base class ###
buffer.write(f"from plotly.{base_package} import {base_classname}\n")
# Write class definition
# ----------------------
buffer.write(
f"""
class {fig_classname}({base_classname}):\n"""
)
# ### Constructor ###
# Build constructor description strings
data_description = reindent_validator_description(data_validator, 8)
layout_description = reindent_validator_description(layout_validator, 8)
frames_description = reindent_validator_description(frame_validator, 8)
buffer.write(
f"""
def __init__(self, data=None, layout=None,
frames=None, skip_invalid=False, **kwargs):
\"\"\"
Create a new :class:{fig_classname} instance
Parameters
----------
data
{data_description}
layout
{layout_description}
frames
{frames_description}
skip_invalid: bool
If True, invalid properties in the figure specification will be
skipped silently. If False (default) invalid properties in the
figure specification will result in a ValueError
Raises
------
ValueError
if a property in the specification of data, layout, or frames
is invalid AND skip_invalid is False
\"\"\"
super({fig_classname} ,self).__init__(data, layout,
frames, skip_invalid,
**kwargs)
"""
)
# ### add_trace methods for each trace type ###
for trace_node in trace_nodes:
include_secondary_y = bool(
[d for d in trace_node.child_datatypes if d.name_property == "yaxis"]
)
# #### Function signature ####
buffer.write(
f"""
def add_{trace_node.plotly_name}(self"""
)
# #### Function params####
param_extras = ["row", "col"]
if include_secondary_y:
param_extras.append("secondary_y")
add_constructor_params(
buffer, trace_node.child_datatypes, append_extras=param_extras
)
# #### Docstring ####
header = f"Add a new {trace_node.name_datatype_class} trace"
doc_extras = [
(
"row : int or None (default)",
"Subplot row index (starting from 1) for the trace to be "
"added. Only valid if figure was created using "
"`plotly.tools.make_subplots`",
),
(
"col : int or None (default)",
"Subplot col index (starting from 1) for the trace to be "
"added. Only valid if figure was created using "
"`plotly.tools.make_subplots`",
),
]
if include_secondary_y:
doc_extras.append(
(
"secondary_y: boolean or None (default None)",
"""\
If True, associate this trace with the secondary y-axis of the
subplot at the specified row and col. Only valid if all of the
following conditions are satisfied:
* The figure was created using `plotly.subplots.make_subplots`.
* The row and col arguments are not None
* The subplot at the specified row and col has type xy
(which is the default) and secondary_y True. These
properties are specified in the specs argument to
make_subplots. See the make_subplots docstring for more info.\
""",
)
)
add_docstring(
buffer,
trace_node,
header,
append_extras=doc_extras,
return_type=fig_classname,
)
# #### Function body ####
buffer.write(
f"""
from plotly.graph_objs import {trace_node.name_datatype_class}
new_trace = {trace_node.name_datatype_class}(
"""
)
for i, subtype_node in enumerate(trace_node.child_datatypes):
subtype_prop_name = subtype_node.name_property
buffer.write(
f"""
{subtype_prop_name}={subtype_prop_name},"""
)
buffer.write(
f"""
**kwargs)"""
)
if include_secondary_y:
secondary_y_kwarg = ", secondary_y=secondary_y"
else:
secondary_y_kwarg = ""
buffer.write(
f"""
return self.add_trace(
new_trace, row=row, col=col{secondary_y_kwarg})"""
)
# update layout subplots
# ----------------------
inflect_eng = inflect.engine()
for subplot_node in subplot_nodes:
singular_name = subplot_node.name_property
plural_name = inflect_eng.plural_noun(singular_name)
if singular_name == "yaxis":
secondary_y_1 = ", secondary_y=None"
secondary_y_2 = ", secondary_y=secondary_y"
secondary_y_docstring = f"""
secondary_y: boolean or None (default None)
* If True, only select yaxis objects associated with the secondary
y-axis of the subplot.
* If False, only select yaxis objects associated with the primary
y-axis of the subplot.
* If None (the default), do not filter yaxis objects based on
a secondary y-axis condition.
To select yaxis objects by secondary y-axis, the Figure must
have been created using plotly.subplots.make_subplots. See
the docstring for the specs argument to make_subplots for more
info on creating subplots with secondary y-axes."""
else:
secondary_y_1 = ""
secondary_y_2 = ""
secondary_y_docstring = ""
buffer.write(
f"""
def select_{plural_name}(
self, selector=None, row=None, col=None{secondary_y_1}):
\"\"\"
Select {singular_name} subplot objects from a particular subplot cell
and/or {singular_name} subplot objects that satisfy custom selection
criteria.
Parameters
----------
selector: dict or None (default None)
Dict to use as selection criteria.
{singular_name} objects will be selected if they contain
properties corresponding to all of the dictionary's keys, with
values that exactly match the supplied values. If None
(the default), all {singular_name} objects are selected.
row, col: int or None (default None)
Subplot row and column index of {singular_name} objects to select.
To select {singular_name} objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all {singular_name} objects are selected.\
{secondary_y_docstring}
Returns
-------
generator
Generator that iterates through all of the {singular_name}
objects that satisfy all of the specified selection criteria
\"\"\"
return self._select_layout_subplots_by_prefix(
'{singular_name}', selector, row, col{secondary_y_2})
def for_each_{singular_name}(
self, fn, selector=None, row=None, col=None{secondary_y_1}):
\"\"\"
Apply a function to all {singular_name} objects that satisfy the
specified selection criteria
Parameters
----------
fn:
Function that inputs a single {singular_name} object.
selector: dict or None (default None)
Dict to use as selection criteria.
{singular_name} objects will be selected if they contain
properties corresponding to all of the dictionary's keys, with
values that exactly match the supplied values. If None
(the default), all {singular_name} objects are selected.
row, col: int or None (default None)
Subplot row and column index of {singular_name} objects to select.
To select {singular_name} objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all {singular_name} objects are selected.\
{secondary_y_docstring}
Returns
-------
self
Returns the Figure object that the method was called on
\"\"\"
for obj in self.select_{plural_name}(
selector=selector, row=row, col=col{secondary_y_2}):
fn(obj)
return self
def update_{plural_name}(
self,
patch=None,
selector=None,
overwrite=False,
row=None, col=None{secondary_y_1},
**kwargs):
\"\"\"
Perform a property update operation on all {singular_name} objects
that satisfy the specified selection criteria
Parameters
----------
patch: dict
Dictionary of property updates to be applied to all
{singular_name} objects that satisfy the selection criteria.
selector: dict or None (default None)
Dict to use as selection criteria.
{singular_name} objects will be selected if they contain
properties corresponding to all of the dictionary's keys, with
values that exactly match the supplied values. If None
(the default), all {singular_name} objects are selected.
overwrite: bool
If True, overwrite existing properties. If False, apply updates
to existing properties recursively, preserving existing
properties that are not specified in the update operation.
row, col: int or None (default None)
Subplot row and column index of {singular_name} objects to select.
To select {singular_name} objects by row and column, the Figure
must have been created using plotly.subplots.make_subplots.
If None (the default), all {singular_name} objects are selected.\
{secondary_y_docstring}
**kwargs
Additional property updates to apply to each selected
{singular_name} object. If a property is specified in
both patch and in **kwargs then the one in **kwargs
takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
\"\"\"
for obj in self.select_{plural_name}(
selector=selector, row=row, col=col{secondary_y_2}):
obj.update(patch, overwrite=overwrite, **kwargs)
return self"""
)
# update annotations/shapes/images
# --------------------------------
for node in layout_array_nodes:
singular_name = node.plotly_name
plural_name = node.name_property
if singular_name == "image":
# Rename image to layout_image to avoid conflict with an image trace
method_prefix = "layout_"
else:
method_prefix = ""
buffer.write(
f"""
def select_{method_prefix}{plural_name}(
self, selector=None, row=None, col=None, secondary_y=None
):
\"\"\"
Select {plural_name} from a particular subplot cell and/or {plural_name}
that satisfy custom selection criteria.
Parameters
----------
selector: dict or None (default None)
Dict to use as selection criteria.
Annotations will be selected if they contain properties corresponding
to all of the dictionary's keys, with values that exactly match
the supplied values. If None (the default), all {plural_name} are
selected.
row, col: int or None (default None)
Subplot row and column index of {plural_name} to select.
To select {plural_name} by row and column, the Figure must have been
created using plotly.subplots.make_subplots. To select only those
{singular_name} that are in paper coordinates, set row and col to the
string 'paper'. If None (the default), all {plural_name} are selected.
secondary_y: boolean or None (default None)
* If True, only select {plural_name} associated with the secondary
y-axis of the subplot.
* If False, only select {plural_name} associated with the primary
y-axis of the subplot.
* If None (the default), do not filter {plural_name} based on secondary
y-axis.
To select {plural_name} by secondary y-axis, the Figure must have been
created using plotly.subplots.make_subplots. See the docstring
for the specs argument to make_subplots for more info on
creating subplots with secondary y-axes.
Returns
-------
generator
Generator that iterates through all of the {plural_name} that satisfy
all of the specified selection criteria
\"\"\"
return self._select_annotations_like(
"{plural_name}", selector=selector, row=row, col=col, secondary_y=secondary_y
)
def for_each_{method_prefix}{singular_name}(
self, fn, selector=None, row=None, col=None, secondary_y=None
):
\"\"\"
Apply a function to all {plural_name} that satisfy the specified selection
criteria
Parameters
----------
fn:
Function that inputs a single {singular_name} object.
selector: dict or None (default None)
Dict to use as selection criteria.
Traces will be selected if they contain properties corresponding
to all of the dictionary's keys, with values that exactly match
the supplied values. If None (the default), all {plural_name} are
selected.
row, col: int or None (default None)
Subplot row and column index of {plural_name} to select.
To select {plural_name} by row and column, the Figure must have been
created using plotly.subplots.make_subplots. To select only those
{plural_name} that are in paper coordinates, set row and col to the
string 'paper'. If None (the default), all {plural_name} are selected.
secondary_y: boolean or None (default None)
* If True, only select {plural_name} associated with the secondary
y-axis of the subplot.
* If False, only select {plural_name} associated with the primary
y-axis of the subplot.
* If None (the default), do not filter {plural_name} based on secondary
y-axis.
To select {plural_name} by secondary y-axis, the Figure must have been
created using plotly.subplots.make_subplots. See the docstring
for the specs argument to make_subplots for more info on
creating subplots with secondary y-axes.
Returns
-------
self
Returns the Figure object that the method was called on
\"\"\"
for obj in self._select_annotations_like(
prop='{plural_name}',
selector=selector,
row=row,
col=col,
secondary_y=secondary_y,
):
fn(obj)
return self
def update_{method_prefix}{plural_name}(
self,
patch=None,
selector=None,
row=None,
col=None,
secondary_y=None,
**kwargs
):
\"\"\"
Perform a property update operation on all {plural_name} that satisfy the
specified selection criteria
Parameters
----------
patch: dict or None (default None)
Dictionary of property updates to be applied to all {plural_name} that
satisfy the selection criteria.
selector: dict or None (default None)
Dict to use as selection criteria.
Traces will be selected if they contain properties corresponding
to all of the dictionary's keys, with values that exactly match
the supplied values. If None (the default), all {plural_name} are
selected.
row, col: int or None (default None)
Subplot row and column index of {plural_name} to select.
To select {plural_name} by row and column, the Figure must have been
created using plotly.subplots.make_subplots. To select only those
{singular_name} that are in paper coordinates, set row and col to the
string 'paper'. If None (the default), all {plural_name} are selected.
secondary_y: boolean or None (default None)
* If True, only select {plural_name} associated with the secondary
y-axis of the subplot.
* If False, only select {plural_name} associated with the primary
y-axis of the subplot.
* If None (the default), do not filter {plural_name} based on secondary
y-axis.
To select {plural_name} by secondary y-axis, the Figure must have been
created using plotly.subplots.make_subplots. See the docstring
for the specs argument to make_subplots for more info on
creating subplots with secondary y-axes.
**kwargs
Additional property updates to apply to each selected {singular_name}. If
a property is specified in both patch and in **kwargs then the
one in **kwargs takes precedence.
Returns
-------
self
Returns the Figure object that the method was called on
\"\"\"
for obj in self._select_annotations_like(
prop='{plural_name}',
selector=selector,
row=row,
col=col,
secondary_y=secondary_y,
):
obj.update(patch, **kwargs)
return self
"""
)
# Add layout array items
buffer.write(
f"""
def add_{method_prefix}{singular_name}(self"""
)
add_constructor_params(
buffer,
node.child_datatypes,
prepend_extras=["arg"],
append_extras=["row", "col", "secondary_y"],
)
prepend_extras = [
(
"arg",
f"instance of {node.name_datatype_class} or dict with "
"compatible properties",
)
]
append_extras = [
("row", f"Subplot row for {singular_name}"),
("col", f"Subplot column for {singular_name}"),
("secondary_y", f"Whether to add {singular_name} to secondary y-axis"),
]
add_docstring(
buffer,
node,
header=f"Create and add a new {singular_name} to the figure's layout",
prepend_extras=prepend_extras,
append_extras=append_extras,
return_type=fig_classname,
)
# #### Function body ####
buffer.write(
f"""
from plotly.graph_objs import layout as _layout
new_obj = _layout.{node.name_datatype_class}(arg,
"""
)
for i, subtype_node in enumerate(node.child_datatypes):
subtype_prop_name = subtype_node.name_property
buffer.write(
f"""
{subtype_prop_name}={subtype_prop_name},"""
)
buffer.write("""**kwargs)""")
buffer.write(
f"""
return self._add_annotation_like(
'{singular_name}',
'{plural_name}',
new_obj,
row=row,
col=col,
secondary_y=secondary_y,
)"""
)
# Return source string
# --------------------
buffer.write("\n")
return buffer.getvalue() | [
"def",
"build_figure_py",
"(",
"trace_node",
",",
"base_package",
",",
"base_classname",
",",
"fig_classname",
",",
"data_validator",
",",
"layout_validator",
",",
"frame_validator",
",",
"subplot_nodes",
",",
"layout_array_nodes",
",",
")",
":",
"# Initialize source code buffer",
"# -----------------------------",
"buffer",
"=",
"StringIO",
"(",
")",
"# Get list of trace type nodes",
"# ----------------------------",
"trace_nodes",
"=",
"trace_node",
".",
"child_compound_datatypes",
"# Write imports",
"# -------------",
"# ### Import base class ###",
"buffer",
".",
"write",
"(",
"f\"from plotly.{base_package} import {base_classname}\\n\"",
")",
"# Write class definition",
"# ----------------------",
"buffer",
".",
"write",
"(",
"f\"\"\"\n\nclass {fig_classname}({base_classname}):\\n\"\"\"",
")",
"# ### Constructor ###",
"# Build constructor description strings",
"data_description",
"=",
"reindent_validator_description",
"(",
"data_validator",
",",
"8",
")",
"layout_description",
"=",
"reindent_validator_description",
"(",
"layout_validator",
",",
"8",
")",
"frames_description",
"=",
"reindent_validator_description",
"(",
"frame_validator",
",",
"8",
")",
"buffer",
".",
"write",
"(",
"f\"\"\"\n def __init__(self, data=None, layout=None,\n frames=None, skip_invalid=False, **kwargs):\n \\\"\\\"\\\"\n Create a new :class:{fig_classname} instance\n \n Parameters\n ----------\n data\n {data_description}\n \n layout\n {layout_description}\n \n frames\n {frames_description}\n \n skip_invalid: bool\n If True, invalid properties in the figure specification will be\n skipped silently. If False (default) invalid properties in the\n figure specification will result in a ValueError\n\n Raises\n ------\n ValueError\n if a property in the specification of data, layout, or frames\n is invalid AND skip_invalid is False\n \\\"\\\"\\\"\n super({fig_classname} ,self).__init__(data, layout,\n frames, skip_invalid,\n **kwargs)\n \"\"\"",
")",
"# ### add_trace methods for each trace type ###",
"for",
"trace_node",
"in",
"trace_nodes",
":",
"include_secondary_y",
"=",
"bool",
"(",
"[",
"d",
"for",
"d",
"in",
"trace_node",
".",
"child_datatypes",
"if",
"d",
".",
"name_property",
"==",
"\"yaxis\"",
"]",
")",
"# #### Function signature ####",
"buffer",
".",
"write",
"(",
"f\"\"\"\n def add_{trace_node.plotly_name}(self\"\"\"",
")",
"# #### Function params####",
"param_extras",
"=",
"[",
"\"row\"",
",",
"\"col\"",
"]",
"if",
"include_secondary_y",
":",
"param_extras",
".",
"append",
"(",
"\"secondary_y\"",
")",
"add_constructor_params",
"(",
"buffer",
",",
"trace_node",
".",
"child_datatypes",
",",
"append_extras",
"=",
"param_extras",
")",
"# #### Docstring ####",
"header",
"=",
"f\"Add a new {trace_node.name_datatype_class} trace\"",
"doc_extras",
"=",
"[",
"(",
"\"row : int or None (default)\"",
",",
"\"Subplot row index (starting from 1) for the trace to be \"",
"\"added. Only valid if figure was created using \"",
"\"`plotly.tools.make_subplots`\"",
",",
")",
",",
"(",
"\"col : int or None (default)\"",
",",
"\"Subplot col index (starting from 1) for the trace to be \"",
"\"added. Only valid if figure was created using \"",
"\"`plotly.tools.make_subplots`\"",
",",
")",
",",
"]",
"if",
"include_secondary_y",
":",
"doc_extras",
".",
"append",
"(",
"(",
"\"secondary_y: boolean or None (default None)\"",
",",
"\"\"\"\\\n If True, associate this trace with the secondary y-axis of the\n subplot at the specified row and col. Only valid if all of the\n following conditions are satisfied:\n * The figure was created using `plotly.subplots.make_subplots`.\n * The row and col arguments are not None\n * The subplot at the specified row and col has type xy\n (which is the default) and secondary_y True. These\n properties are specified in the specs argument to\n make_subplots. See the make_subplots docstring for more info.\\\n\"\"\"",
",",
")",
")",
"add_docstring",
"(",
"buffer",
",",
"trace_node",
",",
"header",
",",
"append_extras",
"=",
"doc_extras",
",",
"return_type",
"=",
"fig_classname",
",",
")",
"# #### Function body ####",
"buffer",
".",
"write",
"(",
"f\"\"\"\n from plotly.graph_objs import {trace_node.name_datatype_class}\n new_trace = {trace_node.name_datatype_class}(\n \"\"\"",
")",
"for",
"i",
",",
"subtype_node",
"in",
"enumerate",
"(",
"trace_node",
".",
"child_datatypes",
")",
":",
"subtype_prop_name",
"=",
"subtype_node",
".",
"name_property",
"buffer",
".",
"write",
"(",
"f\"\"\"\n {subtype_prop_name}={subtype_prop_name},\"\"\"",
")",
"buffer",
".",
"write",
"(",
"f\"\"\"\n **kwargs)\"\"\"",
")",
"if",
"include_secondary_y",
":",
"secondary_y_kwarg",
"=",
"\", secondary_y=secondary_y\"",
"else",
":",
"secondary_y_kwarg",
"=",
"\"\"",
"buffer",
".",
"write",
"(",
"f\"\"\"\n return self.add_trace(\n new_trace, row=row, col=col{secondary_y_kwarg})\"\"\"",
")",
"# update layout subplots",
"# ----------------------",
"inflect_eng",
"=",
"inflect",
".",
"engine",
"(",
")",
"for",
"subplot_node",
"in",
"subplot_nodes",
":",
"singular_name",
"=",
"subplot_node",
".",
"name_property",
"plural_name",
"=",
"inflect_eng",
".",
"plural_noun",
"(",
"singular_name",
")",
"if",
"singular_name",
"==",
"\"yaxis\"",
":",
"secondary_y_1",
"=",
"\", secondary_y=None\"",
"secondary_y_2",
"=",
"\", secondary_y=secondary_y\"",
"secondary_y_docstring",
"=",
"f\"\"\"\n secondary_y: boolean or None (default None)\n * If True, only select yaxis objects associated with the secondary\n y-axis of the subplot.\n * If False, only select yaxis objects associated with the primary\n y-axis of the subplot.\n * If None (the default), do not filter yaxis objects based on\n a secondary y-axis condition. \n \n To select yaxis objects by secondary y-axis, the Figure must\n have been created using plotly.subplots.make_subplots. See\n the docstring for the specs argument to make_subplots for more\n info on creating subplots with secondary y-axes.\"\"\"",
"else",
":",
"secondary_y_1",
"=",
"\"\"",
"secondary_y_2",
"=",
"\"\"",
"secondary_y_docstring",
"=",
"\"\"",
"buffer",
".",
"write",
"(",
"f\"\"\"\n\n def select_{plural_name}(\n self, selector=None, row=None, col=None{secondary_y_1}):\n \\\"\\\"\\\"\n Select {singular_name} subplot objects from a particular subplot cell\n and/or {singular_name} subplot objects that satisfy custom selection\n criteria.\n\n Parameters\n ----------\n selector: dict or None (default None)\n Dict to use as selection criteria.\n {singular_name} objects will be selected if they contain\n properties corresponding to all of the dictionary's keys, with\n values that exactly match the supplied values. If None\n (the default), all {singular_name} objects are selected.\n row, col: int or None (default None)\n Subplot row and column index of {singular_name} objects to select.\n To select {singular_name} objects by row and column, the Figure\n must have been created using plotly.subplots.make_subplots.\n If None (the default), all {singular_name} objects are selected.\\\n{secondary_y_docstring}\n Returns\n -------\n generator\n Generator that iterates through all of the {singular_name}\n objects that satisfy all of the specified selection criteria\n \\\"\\\"\\\"\n\n return self._select_layout_subplots_by_prefix(\n '{singular_name}', selector, row, col{secondary_y_2})\n\n def for_each_{singular_name}(\n self, fn, selector=None, row=None, col=None{secondary_y_1}):\n \\\"\\\"\\\"\n Apply a function to all {singular_name} objects that satisfy the\n specified selection criteria\n \n Parameters\n ----------\n fn:\n Function that inputs a single {singular_name} object.\n selector: dict or None (default None)\n Dict to use as selection criteria.\n {singular_name} objects will be selected if they contain\n properties corresponding to all of the dictionary's keys, with\n values that exactly match the supplied values. If None\n (the default), all {singular_name} objects are selected.\n row, col: int or None (default None)\n Subplot row and column index of {singular_name} objects to select.\n To select {singular_name} objects by row and column, the Figure\n must have been created using plotly.subplots.make_subplots.\n If None (the default), all {singular_name} objects are selected.\\\n{secondary_y_docstring}\n Returns\n -------\n self\n Returns the Figure object that the method was called on\n \\\"\\\"\\\"\n for obj in self.select_{plural_name}(\n selector=selector, row=row, col=col{secondary_y_2}):\n fn(obj)\n\n return self\n\n def update_{plural_name}(\n self,\n patch=None,\n selector=None,\n overwrite=False,\n row=None, col=None{secondary_y_1},\n **kwargs):\n \\\"\\\"\\\"\n Perform a property update operation on all {singular_name} objects\n that satisfy the specified selection criteria\n \n Parameters\n ----------\n patch: dict\n Dictionary of property updates to be applied to all\n {singular_name} objects that satisfy the selection criteria.\n selector: dict or None (default None)\n Dict to use as selection criteria.\n {singular_name} objects will be selected if they contain\n properties corresponding to all of the dictionary's keys, with\n values that exactly match the supplied values. If None\n (the default), all {singular_name} objects are selected.\n overwrite: bool\n If True, overwrite existing properties. If False, apply updates\n to existing properties recursively, preserving existing\n properties that are not specified in the update operation.\n row, col: int or None (default None)\n Subplot row and column index of {singular_name} objects to select.\n To select {singular_name} objects by row and column, the Figure\n must have been created using plotly.subplots.make_subplots.\n If None (the default), all {singular_name} objects are selected.\\\n{secondary_y_docstring}\n **kwargs\n Additional property updates to apply to each selected\n {singular_name} object. If a property is specified in\n both patch and in **kwargs then the one in **kwargs\n takes precedence.\n Returns\n -------\n self\n Returns the Figure object that the method was called on\n \\\"\\\"\\\"\n for obj in self.select_{plural_name}(\n selector=selector, row=row, col=col{secondary_y_2}):\n obj.update(patch, overwrite=overwrite, **kwargs)\n\n return self\"\"\"",
")",
"# update annotations/shapes/images",
"# --------------------------------",
"for",
"node",
"in",
"layout_array_nodes",
":",
"singular_name",
"=",
"node",
".",
"plotly_name",
"plural_name",
"=",
"node",
".",
"name_property",
"if",
"singular_name",
"==",
"\"image\"",
":",
"# Rename image to layout_image to avoid conflict with an image trace",
"method_prefix",
"=",
"\"layout_\"",
"else",
":",
"method_prefix",
"=",
"\"\"",
"buffer",
".",
"write",
"(",
"f\"\"\"\n def select_{method_prefix}{plural_name}(\n self, selector=None, row=None, col=None, secondary_y=None\n ):\n \\\"\\\"\\\"\n Select {plural_name} from a particular subplot cell and/or {plural_name}\n that satisfy custom selection criteria.\n\n Parameters\n ----------\n selector: dict or None (default None)\n Dict to use as selection criteria.\n Annotations will be selected if they contain properties corresponding\n to all of the dictionary's keys, with values that exactly match\n the supplied values. If None (the default), all {plural_name} are\n selected.\n row, col: int or None (default None)\n Subplot row and column index of {plural_name} to select.\n To select {plural_name} by row and column, the Figure must have been\n created using plotly.subplots.make_subplots. To select only those\n {singular_name} that are in paper coordinates, set row and col to the\n string 'paper'. If None (the default), all {plural_name} are selected.\n secondary_y: boolean or None (default None)\n * If True, only select {plural_name} associated with the secondary\n y-axis of the subplot.\n * If False, only select {plural_name} associated with the primary\n y-axis of the subplot.\n * If None (the default), do not filter {plural_name} based on secondary\n y-axis.\n\n To select {plural_name} by secondary y-axis, the Figure must have been\n created using plotly.subplots.make_subplots. See the docstring\n for the specs argument to make_subplots for more info on\n creating subplots with secondary y-axes.\n Returns\n -------\n generator\n Generator that iterates through all of the {plural_name} that satisfy\n all of the specified selection criteria\n \\\"\\\"\\\"\n return self._select_annotations_like(\n \"{plural_name}\", selector=selector, row=row, col=col, secondary_y=secondary_y\n )\n\n def for_each_{method_prefix}{singular_name}(\n self, fn, selector=None, row=None, col=None, secondary_y=None\n ):\n \\\"\\\"\\\"\n Apply a function to all {plural_name} that satisfy the specified selection\n criteria\n\n Parameters\n ----------\n fn:\n Function that inputs a single {singular_name} object.\n selector: dict or None (default None)\n Dict to use as selection criteria.\n Traces will be selected if they contain properties corresponding\n to all of the dictionary's keys, with values that exactly match\n the supplied values. If None (the default), all {plural_name} are\n selected.\n row, col: int or None (default None)\n Subplot row and column index of {plural_name} to select.\n To select {plural_name} by row and column, the Figure must have been\n created using plotly.subplots.make_subplots. To select only those\n {plural_name} that are in paper coordinates, set row and col to the\n string 'paper'. If None (the default), all {plural_name} are selected.\n secondary_y: boolean or None (default None)\n * If True, only select {plural_name} associated with the secondary\n y-axis of the subplot.\n * If False, only select {plural_name} associated with the primary\n y-axis of the subplot.\n * If None (the default), do not filter {plural_name} based on secondary\n y-axis.\n\n To select {plural_name} by secondary y-axis, the Figure must have been\n created using plotly.subplots.make_subplots. See the docstring\n for the specs argument to make_subplots for more info on\n creating subplots with secondary y-axes.\n Returns\n -------\n self\n Returns the Figure object that the method was called on\n \\\"\\\"\\\"\n for obj in self._select_annotations_like(\n prop='{plural_name}',\n selector=selector,\n row=row,\n col=col,\n secondary_y=secondary_y,\n ):\n fn(obj)\n\n return self\n\n def update_{method_prefix}{plural_name}(\n self,\n patch=None,\n selector=None,\n row=None,\n col=None,\n secondary_y=None,\n **kwargs\n ):\n \\\"\\\"\\\"\n Perform a property update operation on all {plural_name} that satisfy the\n specified selection criteria\n\n Parameters\n ----------\n patch: dict or None (default None)\n Dictionary of property updates to be applied to all {plural_name} that\n satisfy the selection criteria.\n selector: dict or None (default None)\n Dict to use as selection criteria.\n Traces will be selected if they contain properties corresponding\n to all of the dictionary's keys, with values that exactly match\n the supplied values. If None (the default), all {plural_name} are\n selected.\n row, col: int or None (default None)\n Subplot row and column index of {plural_name} to select.\n To select {plural_name} by row and column, the Figure must have been\n created using plotly.subplots.make_subplots. To select only those\n {singular_name} that are in paper coordinates, set row and col to the\n string 'paper'. If None (the default), all {plural_name} are selected.\n secondary_y: boolean or None (default None)\n * If True, only select {plural_name} associated with the secondary\n y-axis of the subplot.\n * If False, only select {plural_name} associated with the primary\n y-axis of the subplot.\n * If None (the default), do not filter {plural_name} based on secondary\n y-axis.\n\n To select {plural_name} by secondary y-axis, the Figure must have been\n created using plotly.subplots.make_subplots. See the docstring\n for the specs argument to make_subplots for more info on\n creating subplots with secondary y-axes.\n **kwargs\n Additional property updates to apply to each selected {singular_name}. If\n a property is specified in both patch and in **kwargs then the\n one in **kwargs takes precedence.\n\n Returns\n -------\n self\n Returns the Figure object that the method was called on\n \\\"\\\"\\\"\n for obj in self._select_annotations_like(\n prop='{plural_name}',\n selector=selector,\n row=row,\n col=col,\n secondary_y=secondary_y,\n ):\n obj.update(patch, **kwargs)\n\n return self\n\"\"\"",
")",
"# Add layout array items",
"buffer",
".",
"write",
"(",
"f\"\"\"\n def add_{method_prefix}{singular_name}(self\"\"\"",
")",
"add_constructor_params",
"(",
"buffer",
",",
"node",
".",
"child_datatypes",
",",
"prepend_extras",
"=",
"[",
"\"arg\"",
"]",
",",
"append_extras",
"=",
"[",
"\"row\"",
",",
"\"col\"",
",",
"\"secondary_y\"",
"]",
",",
")",
"prepend_extras",
"=",
"[",
"(",
"\"arg\"",
",",
"f\"instance of {node.name_datatype_class} or dict with \"",
"\"compatible properties\"",
",",
")",
"]",
"append_extras",
"=",
"[",
"(",
"\"row\"",
",",
"f\"Subplot row for {singular_name}\"",
")",
",",
"(",
"\"col\"",
",",
"f\"Subplot column for {singular_name}\"",
")",
",",
"(",
"\"secondary_y\"",
",",
"f\"Whether to add {singular_name} to secondary y-axis\"",
")",
",",
"]",
"add_docstring",
"(",
"buffer",
",",
"node",
",",
"header",
"=",
"f\"Create and add a new {singular_name} to the figure's layout\"",
",",
"prepend_extras",
"=",
"prepend_extras",
",",
"append_extras",
"=",
"append_extras",
",",
"return_type",
"=",
"fig_classname",
",",
")",
"# #### Function body ####",
"buffer",
".",
"write",
"(",
"f\"\"\"\n from plotly.graph_objs import layout as _layout\n new_obj = _layout.{node.name_datatype_class}(arg,\n \"\"\"",
")",
"for",
"i",
",",
"subtype_node",
"in",
"enumerate",
"(",
"node",
".",
"child_datatypes",
")",
":",
"subtype_prop_name",
"=",
"subtype_node",
".",
"name_property",
"buffer",
".",
"write",
"(",
"f\"\"\"\n {subtype_prop_name}={subtype_prop_name},\"\"\"",
")",
"buffer",
".",
"write",
"(",
"\"\"\"**kwargs)\"\"\"",
")",
"buffer",
".",
"write",
"(",
"f\"\"\"\n return self._add_annotation_like(\n '{singular_name}',\n '{plural_name}',\n new_obj,\n row=row,\n col=col,\n secondary_y=secondary_y,\n )\"\"\"",
")",
"# Return source string",
"# --------------------",
"buffer",
".",
"write",
"(",
"\"\\n\"",
")",
"return",
"buffer",
".",
"getvalue",
"(",
")"
] | [
18,
0
] | [
597,
28
] | python | en | ['en', 'error', 'th'] | False |
|
write_figure_classes | (
outdir,
trace_node,
data_validator,
layout_validator,
frame_validator,
subplot_nodes,
layout_array_nodes,
) |
Construct source code for the Figure and FigureWidget classes and
write to graph_objs/_figure.py and graph_objs/_figurewidget.py
respectively
Parameters
----------
outdir : str
Root outdir in which the graph_objs package should reside
trace_node : PlotlyNode
Root trace node (the node that is the parent of all of the
individual trace nodes like bar, scatter, etc.)
data_validator : BaseDataValidator
DataValidator instance
layout_validator : CompoundValidator
LayoutValidator instance
frame_validator : CompoundArrayValidator
FrameValidator instance
subplot_nodes: list of PlotlyNode
List of names of all of the layout subplot properties
layout_array_nodes: list of PlotlyNode
List of array nodes under layout that can be positioned using xref/yref
Returns
-------
None
|
Construct source code for the Figure and FigureWidget classes and
write to graph_objs/_figure.py and graph_objs/_figurewidget.py
respectively | def write_figure_classes(
outdir,
trace_node,
data_validator,
layout_validator,
frame_validator,
subplot_nodes,
layout_array_nodes,
):
"""
Construct source code for the Figure and FigureWidget classes and
write to graph_objs/_figure.py and graph_objs/_figurewidget.py
respectively
Parameters
----------
outdir : str
Root outdir in which the graph_objs package should reside
trace_node : PlotlyNode
Root trace node (the node that is the parent of all of the
individual trace nodes like bar, scatter, etc.)
data_validator : BaseDataValidator
DataValidator instance
layout_validator : CompoundValidator
LayoutValidator instance
frame_validator : CompoundArrayValidator
FrameValidator instance
subplot_nodes: list of PlotlyNode
List of names of all of the layout subplot properties
layout_array_nodes: list of PlotlyNode
List of array nodes under layout that can be positioned using xref/yref
Returns
-------
None
"""
# Validate inputs
# ---------------
if trace_node.node_path:
raise ValueError(
f"Expected root trace node.\n"
f'Received node with path "{trace_node.path_str}"'
)
# Loop over figure types
# ----------------------
base_figures = [
("basewidget", "BaseFigureWidget", "FigureWidget"),
("basedatatypes", "BaseFigure", "Figure"),
]
for base_package, base_classname, fig_classname in base_figures:
# ### Build figure source code string ###
figure_source = build_figure_py(
trace_node,
base_package,
base_classname,
fig_classname,
data_validator,
layout_validator,
frame_validator,
subplot_nodes,
layout_array_nodes,
)
# ### Format and write to file###
filepath = opath.join(outdir, "graph_objs", f"_{fig_classname.lower()}.py")
write_source_py(figure_source, filepath) | [
"def",
"write_figure_classes",
"(",
"outdir",
",",
"trace_node",
",",
"data_validator",
",",
"layout_validator",
",",
"frame_validator",
",",
"subplot_nodes",
",",
"layout_array_nodes",
",",
")",
":",
"# Validate inputs",
"# ---------------",
"if",
"trace_node",
".",
"node_path",
":",
"raise",
"ValueError",
"(",
"f\"Expected root trace node.\\n\"",
"f'Received node with path \"{trace_node.path_str}\"'",
")",
"# Loop over figure types",
"# ----------------------",
"base_figures",
"=",
"[",
"(",
"\"basewidget\"",
",",
"\"BaseFigureWidget\"",
",",
"\"FigureWidget\"",
")",
",",
"(",
"\"basedatatypes\"",
",",
"\"BaseFigure\"",
",",
"\"Figure\"",
")",
",",
"]",
"for",
"base_package",
",",
"base_classname",
",",
"fig_classname",
"in",
"base_figures",
":",
"# ### Build figure source code string ###",
"figure_source",
"=",
"build_figure_py",
"(",
"trace_node",
",",
"base_package",
",",
"base_classname",
",",
"fig_classname",
",",
"data_validator",
",",
"layout_validator",
",",
"frame_validator",
",",
"subplot_nodes",
",",
"layout_array_nodes",
",",
")",
"# ### Format and write to file###",
"filepath",
"=",
"opath",
".",
"join",
"(",
"outdir",
",",
"\"graph_objs\"",
",",
"f\"_{fig_classname.lower()}.py\"",
")",
"write_source_py",
"(",
"figure_source",
",",
"filepath",
")"
] | [
600,
0
] | [
668,
48
] | python | en | ['en', 'error', 'th'] | False |
ForwardHandler.handle | (self, context: RequestContext, responder: BaseResponder) | Message handler implementation. | Message handler implementation. | async def handle(self, context: RequestContext, responder: BaseResponder):
"""Message handler implementation."""
self._logger.debug("ForwardHandler called with context %s", context)
assert isinstance(context.message, Forward)
if not context.message_receipt.recipient_verkey:
raise HandlerException("Cannot forward message: unknown recipient")
self._logger.info(
"Received forward for: %s", context.message_receipt.recipient_verkey
)
packed = context.message.msg.encode("ascii")
rt_mgr = RoutingManager(context)
target = context.message.to
try:
recipient = await rt_mgr.get_recipient(target)
except RoutingManagerError:
self._logger.exception("Error resolving recipient for forwarded message")
return
# Note: not currently vetting the state of the connection here
self._logger.info(
f"Forwarding message to connection: {recipient.connection_id}"
)
await responder.send(packed, connection_id=recipient.connection_id) | [
"async",
"def",
"handle",
"(",
"self",
",",
"context",
":",
"RequestContext",
",",
"responder",
":",
"BaseResponder",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"ForwardHandler called with context %s\"",
",",
"context",
")",
"assert",
"isinstance",
"(",
"context",
".",
"message",
",",
"Forward",
")",
"if",
"not",
"context",
".",
"message_receipt",
".",
"recipient_verkey",
":",
"raise",
"HandlerException",
"(",
"\"Cannot forward message: unknown recipient\"",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"Received forward for: %s\"",
",",
"context",
".",
"message_receipt",
".",
"recipient_verkey",
")",
"packed",
"=",
"context",
".",
"message",
".",
"msg",
".",
"encode",
"(",
"\"ascii\"",
")",
"rt_mgr",
"=",
"RoutingManager",
"(",
"context",
")",
"target",
"=",
"context",
".",
"message",
".",
"to",
"try",
":",
"recipient",
"=",
"await",
"rt_mgr",
".",
"get_recipient",
"(",
"target",
")",
"except",
"RoutingManagerError",
":",
"self",
".",
"_logger",
".",
"exception",
"(",
"\"Error resolving recipient for forwarded message\"",
")",
"return",
"# Note: not currently vetting the state of the connection here",
"self",
".",
"_logger",
".",
"info",
"(",
"f\"Forwarding message to connection: {recipient.connection_id}\"",
")",
"await",
"responder",
".",
"send",
"(",
"packed",
",",
"connection_id",
"=",
"recipient",
".",
"connection_id",
")"
] | [
16,
4
] | [
41,
75
] | python | da | ['da', 'da', 'en'] | True |
parse_webhook_url | (url) | Parse and check validity of Discord webhook URL
by performing a get request and checking existence
of 'id' and 'token' in the JSON response.
| Parse and check validity of Discord webhook URL
by performing a get request and checking existence
of 'id' and 'token' in the JSON response.
| def parse_webhook_url(url):
"""Parse and check validity of Discord webhook URL
by performing a get request and checking existence
of 'id' and 'token' in the JSON response.
"""
if not url:
return None, None
resp = requests.get(url, timeout=10).json()
_id = int(resp["id"])
token = resp["token"]
return _id, token | [
"def",
"parse_webhook_url",
"(",
"url",
")",
":",
"if",
"not",
"url",
":",
"return",
"None",
",",
"None",
"resp",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"timeout",
"=",
"10",
")",
".",
"json",
"(",
")",
"_id",
"=",
"int",
"(",
"resp",
"[",
"\"id\"",
"]",
")",
"token",
"=",
"resp",
"[",
"\"token\"",
"]",
"return",
"_id",
",",
"token"
] | [
53,
0
] | [
63,
21
] | python | en | ['en', 'en', 'en'] | True |
AWSAccess.__init__ | (
self,
resource_name: str = None,
profile_name: str = None,
aws_access_key_id: str = None,
aws_secret_access_key: str = None,
region_name: str = None,
) |
AWSAccess - takes care of basic AWS access (e.g. session, client, resource), getting some basic AWS information, and mock support for testing.
:param resource_name: AWS resource name (e.g. s3, dynamodb, sqs, sns, etc.). Can be None if just testing the connection.
# Provide either: profile name or access key ID/secret access key pair
:param profile_name: AWS profile name
:param aws_access_key_id: AWS access key (required if secret_access_key given)
:param aws_secret_access_key: AWS secret access key (required if access_key_id given)
:param region_name: AWS region (may be optional - see AWS docs)
|
AWSAccess - takes care of basic AWS access (e.g. session, client, resource), getting some basic AWS information, and mock support for testing. | def __init__(
self,
resource_name: str = None,
profile_name: str = None,
aws_access_key_id: str = None,
aws_secret_access_key: str = None,
region_name: str = None,
):
"""
AWSAccess - takes care of basic AWS access (e.g. session, client, resource), getting some basic AWS information, and mock support for testing.
:param resource_name: AWS resource name (e.g. s3, dynamodb, sqs, sns, etc.). Can be None if just testing the connection.
# Provide either: profile name or access key ID/secret access key pair
:param profile_name: AWS profile name
:param aws_access_key_id: AWS access key (required if secret_access_key given)
:param aws_secret_access_key: AWS secret access key (required if access_key_id given)
:param region_name: AWS region (may be optional - see AWS docs)
"""
import boto3 # import here to facilitate mocking
self.resource_name = resource_name
self.profile_name = profile_name
self.aws_access_key_id = aws_access_key_id
self.aws_secret_access_key = aws_secret_access_key
self.region_name = region_name
self._moto_mock = None
self._aws_keys_save = {}
# use keys in AWS config
# https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
kwargs = {}
for k in ["profile_name", "aws_access_key_id", "aws_secret_access_key", "region_name"]:
if getattr(self, k) is not None:
kwargs[k] = getattr(self, k)
self.session = boto3.session.Session(**kwargs)
if is_mock():
# moto mock AWS
for aws_key in ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SECURITY_TOKEN", "AWS_SESSION_TOKEN"]:
self._aws_keys_save[aws_key] = os.environ.get(aws_key) # will be None if not set
os.environ[aws_key] = "testing"
if self.resource_name == "s3":
from moto import mock_s3 as moto_mock
elif self.resource_name == "sns":
from moto import mock_sns as moto_mock
elif self.resource_name == "sqs":
from moto import mock_sqs as moto_mock
elif self.resource_name == "dynamodb":
from moto import mock_dynamodb2 as moto_mock
else:
from moto import mock_iam as moto_mock
self._moto_mock = moto_mock()
self._moto_mock.start()
region = "us-east-1"
self.resource = boto3.resource(self.resource_name, region_name=region) # type: ignore
self.client = boto3.client(self.resource_name, region_name=region) # type: ignore
if self.resource_name == "s3":
self.resource.create_bucket(Bucket="testawsimple") # todo: put this in the test code
elif self.resource_name is None:
# just the session, but not the client or resource
self.client = None
self.resource = None
else:
# real AWS (no mock)
self.client = self.session.client(self.resource_name, config=self._get_config()) # type: ignore
self.resource = self.session.resource(self.resource_name, config=self._get_config()) | [
"def",
"__init__",
"(",
"self",
",",
"resource_name",
":",
"str",
"=",
"None",
",",
"profile_name",
":",
"str",
"=",
"None",
",",
"aws_access_key_id",
":",
"str",
"=",
"None",
",",
"aws_secret_access_key",
":",
"str",
"=",
"None",
",",
"region_name",
":",
"str",
"=",
"None",
",",
")",
":",
"import",
"boto3",
"# import here to facilitate mocking",
"self",
".",
"resource_name",
"=",
"resource_name",
"self",
".",
"profile_name",
"=",
"profile_name",
"self",
".",
"aws_access_key_id",
"=",
"aws_access_key_id",
"self",
".",
"aws_secret_access_key",
"=",
"aws_secret_access_key",
"self",
".",
"region_name",
"=",
"region_name",
"self",
".",
"_moto_mock",
"=",
"None",
"self",
".",
"_aws_keys_save",
"=",
"{",
"}",
"# use keys in AWS config",
"# https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html",
"kwargs",
"=",
"{",
"}",
"for",
"k",
"in",
"[",
"\"profile_name\"",
",",
"\"aws_access_key_id\"",
",",
"\"aws_secret_access_key\"",
",",
"\"region_name\"",
"]",
":",
"if",
"getattr",
"(",
"self",
",",
"k",
")",
"is",
"not",
"None",
":",
"kwargs",
"[",
"k",
"]",
"=",
"getattr",
"(",
"self",
",",
"k",
")",
"self",
".",
"session",
"=",
"boto3",
".",
"session",
".",
"Session",
"(",
"*",
"*",
"kwargs",
")",
"if",
"is_mock",
"(",
")",
":",
"# moto mock AWS",
"for",
"aws_key",
"in",
"[",
"\"AWS_ACCESS_KEY_ID\"",
",",
"\"AWS_SECRET_ACCESS_KEY\"",
",",
"\"AWS_SECURITY_TOKEN\"",
",",
"\"AWS_SESSION_TOKEN\"",
"]",
":",
"self",
".",
"_aws_keys_save",
"[",
"aws_key",
"]",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"aws_key",
")",
"# will be None if not set",
"os",
".",
"environ",
"[",
"aws_key",
"]",
"=",
"\"testing\"",
"if",
"self",
".",
"resource_name",
"==",
"\"s3\"",
":",
"from",
"moto",
"import",
"mock_s3",
"as",
"moto_mock",
"elif",
"self",
".",
"resource_name",
"==",
"\"sns\"",
":",
"from",
"moto",
"import",
"mock_sns",
"as",
"moto_mock",
"elif",
"self",
".",
"resource_name",
"==",
"\"sqs\"",
":",
"from",
"moto",
"import",
"mock_sqs",
"as",
"moto_mock",
"elif",
"self",
".",
"resource_name",
"==",
"\"dynamodb\"",
":",
"from",
"moto",
"import",
"mock_dynamodb2",
"as",
"moto_mock",
"else",
":",
"from",
"moto",
"import",
"mock_iam",
"as",
"moto_mock",
"self",
".",
"_moto_mock",
"=",
"moto_mock",
"(",
")",
"self",
".",
"_moto_mock",
".",
"start",
"(",
")",
"region",
"=",
"\"us-east-1\"",
"self",
".",
"resource",
"=",
"boto3",
".",
"resource",
"(",
"self",
".",
"resource_name",
",",
"region_name",
"=",
"region",
")",
"# type: ignore",
"self",
".",
"client",
"=",
"boto3",
".",
"client",
"(",
"self",
".",
"resource_name",
",",
"region_name",
"=",
"region",
")",
"# type: ignore",
"if",
"self",
".",
"resource_name",
"==",
"\"s3\"",
":",
"self",
".",
"resource",
".",
"create_bucket",
"(",
"Bucket",
"=",
"\"testawsimple\"",
")",
"# todo: put this in the test code",
"elif",
"self",
".",
"resource_name",
"is",
"None",
":",
"# just the session, but not the client or resource",
"self",
".",
"client",
"=",
"None",
"self",
".",
"resource",
"=",
"None",
"else",
":",
"# real AWS (no mock)",
"self",
".",
"client",
"=",
"self",
".",
"session",
".",
"client",
"(",
"self",
".",
"resource_name",
",",
"config",
"=",
"self",
".",
"_get_config",
"(",
")",
")",
"# type: ignore",
"self",
".",
"resource",
"=",
"self",
".",
"session",
".",
"resource",
"(",
"self",
".",
"resource_name",
",",
"config",
"=",
"self",
".",
"_get_config",
"(",
")",
")"
] | [
17,
4
] | [
90,
96
] | python | en | ['en', 'error', 'th'] | False |
AWSAccess.get_region | (self) |
Get current selected AWS region
:return: region string
|
Get current selected AWS region | def get_region(self) -> Union[str, None]:
"""
Get current selected AWS region
:return: region string
"""
return self.session.region_name | [
"def",
"get_region",
"(",
"self",
")",
"->",
"Union",
"[",
"str",
",",
"None",
"]",
":",
"return",
"self",
".",
"session",
".",
"region_name"
] | [
99,
4
] | [
105,
39
] | python | en | ['en', 'error', 'th'] | False |
AWSAccess.get_access_key | (self) |
Get current access key string
:return: access key
|
Get current access key string | def get_access_key(self) -> Union[str, None]:
"""
Get current access key string
:return: access key
"""
return self.session.get_credentials().access_key | [
"def",
"get_access_key",
"(",
"self",
")",
"->",
"Union",
"[",
"str",
",",
"None",
"]",
":",
"return",
"self",
".",
"session",
".",
"get_credentials",
"(",
")",
".",
"access_key"
] | [
107,
4
] | [
113,
56
] | python | en | ['en', 'error', 'th'] | False |
AWSAccess.get_account_id | (self) |
Get AWS account ID
:return: account ID
|
Get AWS account ID | def get_account_id(self):
"""
Get AWS account ID
:return: account ID
"""
arn = self.session.resource("iam").CurrentUser().arn
log.info("current user {arn=}")
return arn.split(":")[4] | [
"def",
"get_account_id",
"(",
"self",
")",
":",
"arn",
"=",
"self",
".",
"session",
".",
"resource",
"(",
"\"iam\"",
")",
".",
"CurrentUser",
"(",
")",
".",
"arn",
"log",
".",
"info",
"(",
"\"current user {arn=}\"",
")",
"return",
"arn",
".",
"split",
"(",
"\":\"",
")",
"[",
"4",
"]"
] | [
115,
4
] | [
123,
32
] | python | en | ['en', 'error', 'th'] | False |
AWSAccess.test | (self) |
Basic connection/capability test
:return: True if connection OK
|
Basic connection/capability test | def test(self) -> bool:
"""
Basic connection/capability test
:return: True if connection OK
"""
resources = self.session.get_available_resources() # boto3 will throw an error if there's an issue here
if self.resource_name is not None and self.resource_name not in resources:
raise PermissionError(self.resource_name) # we don't have permission to the specified resource
return True | [
"def",
"test",
"(",
"self",
")",
"->",
"bool",
":",
"resources",
"=",
"self",
".",
"session",
".",
"get_available_resources",
"(",
")",
"# boto3 will throw an error if there's an issue here",
"if",
"self",
".",
"resource_name",
"is",
"not",
"None",
"and",
"self",
".",
"resource_name",
"not",
"in",
"resources",
":",
"raise",
"PermissionError",
"(",
"self",
".",
"resource_name",
")",
"# we don't have permission to the specified resource",
"return",
"True"
] | [
125,
4
] | [
135,
19
] | python | en | ['en', 'error', 'th'] | False |
AWSAccess.is_mocked | (self) |
Return True if currently mocking the AWS interface (e.g. for testing).
:return: True if mocked
|
Return True if currently mocking the AWS interface (e.g. for testing). | def is_mocked(self) -> bool:
"""
Return True if currently mocking the AWS interface (e.g. for testing).
:return: True if mocked
"""
return self._moto_mock is not None | [
"def",
"is_mocked",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_moto_mock",
"is",
"not",
"None"
] | [
137,
4
] | [
143,
42
] | python | en | ['en', 'error', 'th'] | False |
init_detector | (config, checkpoint=None, device='cuda:0') | Initialize a detector from config file.
Args:
config (str or :obj:`mmcv.Config`): Config file path or the config
object.
checkpoint (str, optional): Checkpoint path. If left as None, the model
will not load any weights.
Returns:
nn.Module: The constructed detector.
| Initialize a detector from config file. | def init_detector(config, checkpoint=None, device='cuda:0'):
"""Initialize a detector from config file.
Args:
config (str or :obj:`mmcv.Config`): Config file path or the config
object.
checkpoint (str, optional): Checkpoint path. If left as None, the model
will not load any weights.
Returns:
nn.Module: The constructed detector.
"""
if isinstance(config, str):
config = mmcv.Config.fromfile(config)
elif not isinstance(config, mmcv.Config):
raise TypeError('config must be a filename or Config object, '
f'but got {type(config)}')
config.model.pretrained = None
model = build_detector(config.model, test_cfg=config.test_cfg)
if checkpoint is not None:
checkpoint = load_checkpoint(model, checkpoint)
if 'CLASSES' in checkpoint['meta']:
model.CLASSES = checkpoint['meta']['CLASSES']
else:
warnings.simplefilter('once')
warnings.warn('Class names are not saved in the checkpoint\'s '
'meta data, use COCO classes by default.')
model.CLASSES = get_classes('coco')
model.cfg = config # save the config in the model for convenience
model.to(device)
model.eval()
return model | [
"def",
"init_detector",
"(",
"config",
",",
"checkpoint",
"=",
"None",
",",
"device",
"=",
"'cuda:0'",
")",
":",
"if",
"isinstance",
"(",
"config",
",",
"str",
")",
":",
"config",
"=",
"mmcv",
".",
"Config",
".",
"fromfile",
"(",
"config",
")",
"elif",
"not",
"isinstance",
"(",
"config",
",",
"mmcv",
".",
"Config",
")",
":",
"raise",
"TypeError",
"(",
"'config must be a filename or Config object, '",
"f'but got {type(config)}'",
")",
"config",
".",
"model",
".",
"pretrained",
"=",
"None",
"model",
"=",
"build_detector",
"(",
"config",
".",
"model",
",",
"test_cfg",
"=",
"config",
".",
"test_cfg",
")",
"if",
"checkpoint",
"is",
"not",
"None",
":",
"checkpoint",
"=",
"load_checkpoint",
"(",
"model",
",",
"checkpoint",
")",
"if",
"'CLASSES'",
"in",
"checkpoint",
"[",
"'meta'",
"]",
":",
"model",
".",
"CLASSES",
"=",
"checkpoint",
"[",
"'meta'",
"]",
"[",
"'CLASSES'",
"]",
"else",
":",
"warnings",
".",
"simplefilter",
"(",
"'once'",
")",
"warnings",
".",
"warn",
"(",
"'Class names are not saved in the checkpoint\\'s '",
"'meta data, use COCO classes by default.'",
")",
"model",
".",
"CLASSES",
"=",
"get_classes",
"(",
"'coco'",
")",
"model",
".",
"cfg",
"=",
"config",
"# save the config in the model for convenience",
"model",
".",
"to",
"(",
"device",
")",
"model",
".",
"eval",
"(",
")",
"return",
"model"
] | [
14,
0
] | [
45,
16
] | python | en | ['en', 'en', 'en'] | True |
inference_detector | (model, img) | Inference image(s) with the detector.
Args:
model (nn.Module): The loaded detector.
imgs (str/ndarray or list[str/ndarray]): Either image files or loaded
images.
Returns:
If imgs is a str, a generator will be returned, otherwise return the
detection results directly.
| Inference image(s) with the detector. | def inference_detector(model, img):
"""Inference image(s) with the detector.
Args:
model (nn.Module): The loaded detector.
imgs (str/ndarray or list[str/ndarray]): Either image files or loaded
images.
Returns:
If imgs is a str, a generator will be returned, otherwise return the
detection results directly.
"""
cfg = model.cfg
device = next(model.parameters()).device # model device
# build the data pipeline
test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:]
test_pipeline = Compose(test_pipeline)
# prepare data
data = dict(img=img)
data = test_pipeline(data)
data = collate([data], samples_per_gpu=1)
if next(model.parameters()).is_cuda:
# scatter to specified GPU
data = scatter(data, [device])[0]
else:
# Use torchvision ops for CPU mode instead
for m in model.modules():
if isinstance(m, (RoIPool, RoIAlign)):
if not m.aligned:
# aligned=False is not implemented on CPU
# set use_torchvision on-the-fly
m.use_torchvision = True
warnings.warn('We set use_torchvision=True in CPU mode.')
# just get the actual data from DataContainer
data['img_metas'] = data['img_metas'][0].data
# forward the model
with torch.no_grad():
result = model(return_loss=False, rescale=True, **data)
return result | [
"def",
"inference_detector",
"(",
"model",
",",
"img",
")",
":",
"cfg",
"=",
"model",
".",
"cfg",
"device",
"=",
"next",
"(",
"model",
".",
"parameters",
"(",
")",
")",
".",
"device",
"# model device",
"# build the data pipeline",
"test_pipeline",
"=",
"[",
"LoadImage",
"(",
")",
"]",
"+",
"cfg",
".",
"data",
".",
"test",
".",
"pipeline",
"[",
"1",
":",
"]",
"test_pipeline",
"=",
"Compose",
"(",
"test_pipeline",
")",
"# prepare data",
"data",
"=",
"dict",
"(",
"img",
"=",
"img",
")",
"data",
"=",
"test_pipeline",
"(",
"data",
")",
"data",
"=",
"collate",
"(",
"[",
"data",
"]",
",",
"samples_per_gpu",
"=",
"1",
")",
"if",
"next",
"(",
"model",
".",
"parameters",
"(",
")",
")",
".",
"is_cuda",
":",
"# scatter to specified GPU",
"data",
"=",
"scatter",
"(",
"data",
",",
"[",
"device",
"]",
")",
"[",
"0",
"]",
"else",
":",
"# Use torchvision ops for CPU mode instead",
"for",
"m",
"in",
"model",
".",
"modules",
"(",
")",
":",
"if",
"isinstance",
"(",
"m",
",",
"(",
"RoIPool",
",",
"RoIAlign",
")",
")",
":",
"if",
"not",
"m",
".",
"aligned",
":",
"# aligned=False is not implemented on CPU",
"# set use_torchvision on-the-fly",
"m",
".",
"use_torchvision",
"=",
"True",
"warnings",
".",
"warn",
"(",
"'We set use_torchvision=True in CPU mode.'",
")",
"# just get the actual data from DataContainer",
"data",
"[",
"'img_metas'",
"]",
"=",
"data",
"[",
"'img_metas'",
"]",
"[",
"0",
"]",
".",
"data",
"# forward the model",
"with",
"torch",
".",
"no_grad",
"(",
")",
":",
"result",
"=",
"model",
"(",
"return_loss",
"=",
"False",
",",
"rescale",
"=",
"True",
",",
"*",
"*",
"data",
")",
"return",
"result"
] | [
75,
0
] | [
114,
17
] | python | en | ['en', 'en', 'en'] | True |
async_inference_detector | (model, img) | Async inference image(s) with the detector.
Args:
model (nn.Module): The loaded detector.
imgs (str/ndarray or list[str/ndarray]): Either image files or loaded
images.
Returns:
Awaitable detection results.
| Async inference image(s) with the detector. | async def async_inference_detector(model, img):
"""Async inference image(s) with the detector.
Args:
model (nn.Module): The loaded detector.
imgs (str/ndarray or list[str/ndarray]): Either image files or loaded
images.
Returns:
Awaitable detection results.
"""
cfg = model.cfg
device = next(model.parameters()).device # model device
# build the data pipeline
test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:]
test_pipeline = Compose(test_pipeline)
# prepare data
data = dict(img=img)
data = test_pipeline(data)
data = scatter(collate([data], samples_per_gpu=1), [device])[0]
# We don't restore `torch.is_grad_enabled()` value during concurrent
# inference since execution can overlap
torch.set_grad_enabled(False)
result = await model.aforward_test(rescale=True, **data)
return result | [
"async",
"def",
"async_inference_detector",
"(",
"model",
",",
"img",
")",
":",
"cfg",
"=",
"model",
".",
"cfg",
"device",
"=",
"next",
"(",
"model",
".",
"parameters",
"(",
")",
")",
".",
"device",
"# model device",
"# build the data pipeline",
"test_pipeline",
"=",
"[",
"LoadImage",
"(",
")",
"]",
"+",
"cfg",
".",
"data",
".",
"test",
".",
"pipeline",
"[",
"1",
":",
"]",
"test_pipeline",
"=",
"Compose",
"(",
"test_pipeline",
")",
"# prepare data",
"data",
"=",
"dict",
"(",
"img",
"=",
"img",
")",
"data",
"=",
"test_pipeline",
"(",
"data",
")",
"data",
"=",
"scatter",
"(",
"collate",
"(",
"[",
"data",
"]",
",",
"samples_per_gpu",
"=",
"1",
")",
",",
"[",
"device",
"]",
")",
"[",
"0",
"]",
"# We don't restore `torch.is_grad_enabled()` value during concurrent",
"# inference since execution can overlap",
"torch",
".",
"set_grad_enabled",
"(",
"False",
")",
"result",
"=",
"await",
"model",
".",
"aforward_test",
"(",
"rescale",
"=",
"True",
",",
"*",
"*",
"data",
")",
"return",
"result"
] | [
117,
0
] | [
142,
17
] | python | en | ['en', 'en', 'en'] | True |
show_result_pyplot | (model, img, result, score_thr=0.3, fig_size=(15, 10)) | Visualize the detection results on the image.
Args:
model (nn.Module): The loaded detector.
img (str or np.ndarray): Image filename or loaded image.
result (tuple[list] or list): The detection result, can be either
(bbox, segm) or just bbox.
score_thr (float): The threshold to visualize the bboxes and masks.
fig_size (tuple): Figure size of the pyplot figure.
| Visualize the detection results on the image. | def show_result_pyplot(model, img, result, score_thr=0.3, fig_size=(15, 10)):
"""Visualize the detection results on the image.
Args:
model (nn.Module): The loaded detector.
img (str or np.ndarray): Image filename or loaded image.
result (tuple[list] or list): The detection result, can be either
(bbox, segm) or just bbox.
score_thr (float): The threshold to visualize the bboxes and masks.
fig_size (tuple): Figure size of the pyplot figure.
"""
if hasattr(model, 'module'):
model = model.module
img = model.show_result(img, result, score_thr=score_thr, show=False)
plt.figure(figsize=fig_size)
plt.imshow(mmcv.bgr2rgb(img))
plt.show() | [
"def",
"show_result_pyplot",
"(",
"model",
",",
"img",
",",
"result",
",",
"score_thr",
"=",
"0.3",
",",
"fig_size",
"=",
"(",
"15",
",",
"10",
")",
")",
":",
"if",
"hasattr",
"(",
"model",
",",
"'module'",
")",
":",
"model",
"=",
"model",
".",
"module",
"img",
"=",
"model",
".",
"show_result",
"(",
"img",
",",
"result",
",",
"score_thr",
"=",
"score_thr",
",",
"show",
"=",
"False",
")",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"fig_size",
")",
"plt",
".",
"imshow",
"(",
"mmcv",
".",
"bgr2rgb",
"(",
"img",
")",
")",
"plt",
".",
"show",
"(",
")"
] | [
145,
0
] | [
161,
14
] | python | en | ['en', 'en', 'en'] | True |
LoadImage.__call__ | (self, results) | Call function to load images into results.
Args:
results (dict): A result dict contains the file name
of the image to be read.
Returns:
dict: ``results`` will be returned containing loaded image.
| Call function to load images into results. | def __call__(self, results):
"""Call function to load images into results.
Args:
results (dict): A result dict contains the file name
of the image to be read.
Returns:
dict: ``results`` will be returned containing loaded image.
"""
if isinstance(results['img'], str):
results['filename'] = results['img']
results['ori_filename'] = results['img']
else:
results['filename'] = None
results['ori_filename'] = None
img = mmcv.imread(results['img'])
results['img'] = img
results['img_fields'] = ['img']
results['img_shape'] = img.shape
results['ori_shape'] = img.shape
return results | [
"def",
"__call__",
"(",
"self",
",",
"results",
")",
":",
"if",
"isinstance",
"(",
"results",
"[",
"'img'",
"]",
",",
"str",
")",
":",
"results",
"[",
"'filename'",
"]",
"=",
"results",
"[",
"'img'",
"]",
"results",
"[",
"'ori_filename'",
"]",
"=",
"results",
"[",
"'img'",
"]",
"else",
":",
"results",
"[",
"'filename'",
"]",
"=",
"None",
"results",
"[",
"'ori_filename'",
"]",
"=",
"None",
"img",
"=",
"mmcv",
".",
"imread",
"(",
"results",
"[",
"'img'",
"]",
")",
"results",
"[",
"'img'",
"]",
"=",
"img",
"results",
"[",
"'img_fields'",
"]",
"=",
"[",
"'img'",
"]",
"results",
"[",
"'img_shape'",
"]",
"=",
"img",
".",
"shape",
"results",
"[",
"'ori_shape'",
"]",
"=",
"img",
".",
"shape",
"return",
"results"
] | [
51,
4
] | [
72,
22
] | python | en | ['en', 'en', 'en'] | True |
DatatypeHelper.fold | (cls, datatype: str) |
Extract the fold part of the datatype.
:param datatype:
parlai datatype
:return: the fold
>>> DatatypeHelper.fold("train:ordered")
... "train"
|
Extract the fold part of the datatype. | def fold(cls, datatype: str) -> str:
"""
Extract the fold part of the datatype.
:param datatype:
parlai datatype
:return: the fold
>>> DatatypeHelper.fold("train:ordered")
... "train"
"""
return datatype.split(':')[0] | [
"def",
"fold",
"(",
"cls",
",",
"datatype",
":",
"str",
")",
"->",
"str",
":",
"return",
"datatype",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]"
] | [
16,
4
] | [
28,
37
] | python | en | ['en', 'error', 'th'] | False |
DatatypeHelper.should_cycle | (cls, datatype: str) |
Return whether we should cycle data based on the datatype.
:param datatype:
parlai datatype
:return should_cycle:
given datatype, return whether we should cycle
|
Return whether we should cycle data based on the datatype. | def should_cycle(cls, datatype: str) -> bool:
"""
Return whether we should cycle data based on the datatype.
:param datatype:
parlai datatype
:return should_cycle:
given datatype, return whether we should cycle
"""
assert datatype is not None, 'datatype must not be none'
return (
'train' in datatype
and 'evalmode' not in datatype
and 'ordered' not in datatype
) | [
"def",
"should_cycle",
"(",
"cls",
",",
"datatype",
":",
"str",
")",
"->",
"bool",
":",
"assert",
"datatype",
"is",
"not",
"None",
",",
"'datatype must not be none'",
"return",
"(",
"'train'",
"in",
"datatype",
"and",
"'evalmode'",
"not",
"in",
"datatype",
"and",
"'ordered'",
"not",
"in",
"datatype",
")"
] | [
31,
4
] | [
46,
9
] | python | en | ['en', 'error', 'th'] | False |
DatatypeHelper.should_shuffle | (cls, datatype: str) |
Return whether we should shuffle data based on the datatype.
:param datatype:
parlai datatype
:return should_shuffle:
given datatype, return whether we should shuffle
|
Return whether we should shuffle data based on the datatype. | def should_shuffle(cls, datatype: str) -> bool:
"""
Return whether we should shuffle data based on the datatype.
:param datatype:
parlai datatype
:return should_shuffle:
given datatype, return whether we should shuffle
"""
assert datatype is not None, 'datatype must not be none'
return (
'train' in datatype
and 'evalmode' not in datatype
and 'ordered' not in datatype
and 'stream' not in datatype
) | [
"def",
"should_shuffle",
"(",
"cls",
",",
"datatype",
":",
"str",
")",
"->",
"bool",
":",
"assert",
"datatype",
"is",
"not",
"None",
",",
"'datatype must not be none'",
"return",
"(",
"'train'",
"in",
"datatype",
"and",
"'evalmode'",
"not",
"in",
"datatype",
"and",
"'ordered'",
"not",
"in",
"datatype",
"and",
"'stream'",
"not",
"in",
"datatype",
")"
] | [
49,
4
] | [
65,
9
] | python | en | ['en', 'error', 'th'] | False |
DatatypeHelper.is_training | (cls, datatype: str) |
Return whether we should return eval_labels or labels.
:param datatype:
parlai datatype
:return is_training:
given datatype, return whether we should return eval_labels or labels
|
Return whether we should return eval_labels or labels. | def is_training(cls, datatype: str) -> bool:
"""
Return whether we should return eval_labels or labels.
:param datatype:
parlai datatype
:return is_training:
given datatype, return whether we should return eval_labels or labels
"""
assert datatype is not None, 'datatype must not be none'
return 'train' in datatype and 'evalmode' not in datatype | [
"def",
"is_training",
"(",
"cls",
",",
"datatype",
":",
"str",
")",
"->",
"bool",
":",
"assert",
"datatype",
"is",
"not",
"None",
",",
"'datatype must not be none'",
"return",
"'train'",
"in",
"datatype",
"and",
"'evalmode'",
"not",
"in",
"datatype"
] | [
68,
4
] | [
79,
65
] | python | en | ['en', 'error', 'th'] | False |
Line.autocolorscale | (self) |
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is true, the
default palette will be chosen according to whether numbers in
the `color` array are all positive, all negative or mixed.
The 'autocolorscale' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is true, the
default palette will be chosen according to whether numbers in
the `color` array are all positive, all negative or mixed.
The 'autocolorscale' property must be specified as a bool
(either True, or False) | def autocolorscale(self):
"""
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is true, the
default palette will be chosen according to whether numbers in
the `color` array are all positive, all negative or mixed.
The 'autocolorscale' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["autocolorscale"] | [
"def",
"autocolorscale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"autocolorscale\"",
"]"
] | [
28,
4
] | [
45,
37
] | python | en | ['en', 'error', 'th'] | False |
Line.cauto | (self) |
Determines whether or not the color domain is computed with
respect to the input data (here in `marker.line.color`) or the
bounds set in `marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a numerical
array. Defaults to `false` when `marker.line.cmin` and
`marker.line.cmax` are set by the user.
The 'cauto' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines whether or not the color domain is computed with
respect to the input data (here in `marker.line.color`) or the
bounds set in `marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a numerical
array. Defaults to `false` when `marker.line.cmin` and
`marker.line.cmax` are set by the user.
The 'cauto' property must be specified as a bool
(either True, or False) | def cauto(self):
"""
Determines whether or not the color domain is computed with
respect to the input data (here in `marker.line.color`) or the
bounds set in `marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a numerical
array. Defaults to `false` when `marker.line.cmin` and
`marker.line.cmax` are set by the user.
The 'cauto' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["cauto"] | [
"def",
"cauto",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cauto\"",
"]"
] | [
54,
4
] | [
70,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.cmax | (self) |
Sets the upper bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmin` must be set as well.
The 'cmax' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
Sets the upper bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmin` must be set as well.
The 'cmax' property is a number and may be specified as:
- An int or float | def cmax(self):
"""
Sets the upper bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmin` must be set as well.
The 'cmax' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["cmax"] | [
"def",
"cmax",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cmax\"",
"]"
] | [
79,
4
] | [
93,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.cmid | (self) |
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be equidistant
to this point. Has an effect only if in `marker.line.color`is
set to a numerical array. Value should have the same units as
in `marker.line.color`. Has no effect when `marker.line.cauto`
is `false`.
The 'cmid' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be equidistant
to this point. Has an effect only if in `marker.line.color`is
set to a numerical array. Value should have the same units as
in `marker.line.color`. Has no effect when `marker.line.cauto`
is `false`.
The 'cmid' property is a number and may be specified as:
- An int or float | def cmid(self):
"""
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be equidistant
to this point. Has an effect only if in `marker.line.color`is
set to a numerical array. Value should have the same units as
in `marker.line.color`. Has no effect when `marker.line.cauto`
is `false`.
The 'cmid' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["cmid"] | [
"def",
"cmid",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cmid\"",
"]"
] | [
102,
4
] | [
118,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.cmin | (self) |
Sets the lower bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmax` must be set as well.
The 'cmin' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
Sets the lower bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmax` must be set as well.
The 'cmin' property is a number and may be specified as:
- An int or float | def cmin(self):
"""
Sets the lower bound of the color domain. Has an effect only if
in `marker.line.color`is set to a numerical array. Value should
have the same units as in `marker.line.color` and if set,
`marker.line.cmax` must be set as well.
The 'cmin' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["cmin"] | [
"def",
"cmin",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"cmin\"",
"]"
] | [
127,
4
] | [
141,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.color | (self) |
Sets themarker.linecolor. It accepts either a specific color or
an array of numbers that are mapped to the colorscale relative
to the max and min values of the array or relative to
`marker.line.cmin` and `marker.line.cmax` if set.
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 number that will be interpreted as a color
according to scattergeo.marker.line.colorscale
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
|
Sets themarker.linecolor. It accepts either a specific color or
an array of numbers that are mapped to the colorscale relative
to the max and min values of the array or relative to
`marker.line.cmin` and `marker.line.cmax` if set.
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 number that will be interpreted as a color
according to scattergeo.marker.line.colorscale
- A list or array of any of the above | def color(self):
"""
Sets themarker.linecolor. It accepts either a specific color or
an array of numbers that are mapped to the colorscale relative
to the max and min values of the array or relative to
`marker.line.cmin` and `marker.line.cmax` if set.
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 number that will be interpreted as a color
according to scattergeo.marker.line.colorscale
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["color"] | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
150,
4
] | [
206,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.coloraxis | (self) |
Sets a reference to a shared color axis. References to these
shared color axes are "coloraxis", "coloraxis2", "coloraxis3",
etc. Settings for these shared color axes are set in the
layout, under `layout.coloraxis`, `layout.coloraxis2`, etc.
Note that multiple color scales can be linked to the same color
axis.
The 'coloraxis' property is an identifier of a particular
subplot, of type 'coloraxis', that may be specified as the string 'coloraxis'
optionally followed by an integer >= 1
(e.g. 'coloraxis', 'coloraxis1', 'coloraxis2', 'coloraxis3', etc.)
Returns
-------
str
|
Sets a reference to a shared color axis. References to these
shared color axes are "coloraxis", "coloraxis2", "coloraxis3",
etc. Settings for these shared color axes are set in the
layout, under `layout.coloraxis`, `layout.coloraxis2`, etc.
Note that multiple color scales can be linked to the same color
axis.
The 'coloraxis' property is an identifier of a particular
subplot, of type 'coloraxis', that may be specified as the string 'coloraxis'
optionally followed by an integer >= 1
(e.g. 'coloraxis', 'coloraxis1', 'coloraxis2', 'coloraxis3', etc.) | def coloraxis(self):
"""
Sets a reference to a shared color axis. References to these
shared color axes are "coloraxis", "coloraxis2", "coloraxis3",
etc. Settings for these shared color axes are set in the
layout, under `layout.coloraxis`, `layout.coloraxis2`, etc.
Note that multiple color scales can be linked to the same color
axis.
The 'coloraxis' property is an identifier of a particular
subplot, of type 'coloraxis', that may be specified as the string 'coloraxis'
optionally followed by an integer >= 1
(e.g. 'coloraxis', 'coloraxis1', 'coloraxis2', 'coloraxis3', etc.)
Returns
-------
str
"""
return self["coloraxis"] | [
"def",
"coloraxis",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"coloraxis\"",
"]"
] | [
215,
4
] | [
233,
32
] | python | en | ['en', 'error', 'th'] | False |
Line.colorscale | (self) |
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The colorscale
must be an array containing arrays mapping a normalized value
to an rgb, rgba, hex, hsl, hsv, or named color string. At
minimum, a mapping for the lowest (0) and highest (1) values
are required. For example, `[[0, 'rgb(0,0,255)'], [1,
'rgb(255,0,0)']]`. To control the bounds of the colorscale in
color space, use`marker.line.cmin` and `marker.line.cmax`.
Alternatively, `colorscale` may be a palette name string of the
following list: Greys,YlGnBu,Greens,YlOrRd,Bluered,RdBu,Reds,Bl
ues,Picnic,Rainbow,Portland,Jet,Hot,Blackbody,Earth,Electric,Vi
ridis,Cividis.
The 'colorscale' property is a colorscale and may be
specified as:
- A list of colors that will be spaced evenly to create the colorscale.
Many predefined colorscale lists are included in the sequential, diverging,
and cyclical modules in the plotly.colors package.
- A list of 2-element lists where the first element is the
normalized color level value (starting at 0 and ending at 1),
and the second item is a valid color string.
(e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])
- One of the following named colorscales:
['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',
'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',
'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',
'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',
'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',
'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',
'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',
'orrd', 'oryel', 'peach', 'phase', 'picnic', 'pinkyl', 'piyg',
'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn', 'puor',
'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu', 'rdgy',
'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar', 'spectral',
'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn', 'tealrose',
'tempo', 'temps', 'thermal', 'tropic', 'turbid', 'twilight',
'viridis', 'ylgn', 'ylgnbu', 'ylorbr', 'ylorrd'].
Appending '_r' to a named colorscale reverses it.
Returns
-------
str
|
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The colorscale
must be an array containing arrays mapping a normalized value
to an rgb, rgba, hex, hsl, hsv, or named color string. At
minimum, a mapping for the lowest (0) and highest (1) values
are required. For example, `[[0, 'rgb(0,0,255)'], [1,
'rgb(255,0,0)']]`. To control the bounds of the colorscale in
color space, use`marker.line.cmin` and `marker.line.cmax`.
Alternatively, `colorscale` may be a palette name string of the
following list: Greys,YlGnBu,Greens,YlOrRd,Bluered,RdBu,Reds,Bl
ues,Picnic,Rainbow,Portland,Jet,Hot,Blackbody,Earth,Electric,Vi
ridis,Cividis.
The 'colorscale' property is a colorscale and may be
specified as:
- A list of colors that will be spaced evenly to create the colorscale.
Many predefined colorscale lists are included in the sequential, diverging,
and cyclical modules in the plotly.colors package.
- A list of 2-element lists where the first element is the
normalized color level value (starting at 0 and ending at 1),
and the second item is a valid color string.
(e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])
- One of the following named colorscales:
['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',
'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',
'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',
'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',
'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',
'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',
'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',
'orrd', 'oryel', 'peach', 'phase', 'picnic', 'pinkyl', 'piyg',
'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn', 'puor',
'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu', 'rdgy',
'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar', 'spectral',
'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn', 'tealrose',
'tempo', 'temps', 'thermal', 'tropic', 'turbid', 'twilight',
'viridis', 'ylgn', 'ylgnbu', 'ylorbr', 'ylorrd'].
Appending '_r' to a named colorscale reverses it. | def colorscale(self):
"""
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The colorscale
must be an array containing arrays mapping a normalized value
to an rgb, rgba, hex, hsl, hsv, or named color string. At
minimum, a mapping for the lowest (0) and highest (1) values
are required. For example, `[[0, 'rgb(0,0,255)'], [1,
'rgb(255,0,0)']]`. To control the bounds of the colorscale in
color space, use`marker.line.cmin` and `marker.line.cmax`.
Alternatively, `colorscale` may be a palette name string of the
following list: Greys,YlGnBu,Greens,YlOrRd,Bluered,RdBu,Reds,Bl
ues,Picnic,Rainbow,Portland,Jet,Hot,Blackbody,Earth,Electric,Vi
ridis,Cividis.
The 'colorscale' property is a colorscale and may be
specified as:
- A list of colors that will be spaced evenly to create the colorscale.
Many predefined colorscale lists are included in the sequential, diverging,
and cyclical modules in the plotly.colors package.
- A list of 2-element lists where the first element is the
normalized color level value (starting at 0 and ending at 1),
and the second item is a valid color string.
(e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])
- One of the following named colorscales:
['aggrnyl', 'agsunset', 'algae', 'amp', 'armyrose', 'balance',
'blackbody', 'bluered', 'blues', 'blugrn', 'bluyl', 'brbg',
'brwnyl', 'bugn', 'bupu', 'burg', 'burgyl', 'cividis', 'curl',
'darkmint', 'deep', 'delta', 'dense', 'earth', 'edge', 'electric',
'emrld', 'fall', 'geyser', 'gnbu', 'gray', 'greens', 'greys',
'haline', 'hot', 'hsv', 'ice', 'icefire', 'inferno', 'jet',
'magenta', 'magma', 'matter', 'mint', 'mrybm', 'mygbm', 'oranges',
'orrd', 'oryel', 'peach', 'phase', 'picnic', 'pinkyl', 'piyg',
'plasma', 'plotly3', 'portland', 'prgn', 'pubu', 'pubugn', 'puor',
'purd', 'purp', 'purples', 'purpor', 'rainbow', 'rdbu', 'rdgy',
'rdpu', 'rdylbu', 'rdylgn', 'redor', 'reds', 'solar', 'spectral',
'speed', 'sunset', 'sunsetdark', 'teal', 'tealgrn', 'tealrose',
'tempo', 'temps', 'thermal', 'tropic', 'turbid', 'twilight',
'viridis', 'ylgn', 'ylgnbu', 'ylorbr', 'ylorrd'].
Appending '_r' to a named colorscale reverses it.
Returns
-------
str
"""
return self["colorscale"] | [
"def",
"colorscale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"colorscale\"",
"]"
] | [
242,
4
] | [
287,
33
] | python | en | ['en', 'error', 'th'] | False |
Line.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\"",
"]"
] | [
296,
4
] | [
307,
31
] | python | en | ['en', 'error', 'th'] | False |
Line.reversescale | (self) |
Reverses the color mapping if true. Has an effect only if in
`marker.line.color`is set to a numerical array. If true,
`marker.line.cmin` will correspond to the last color in the
array and `marker.line.cmax` will correspond to the first
color.
The 'reversescale' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Reverses the color mapping if true. Has an effect only if in
`marker.line.color`is set to a numerical array. If true,
`marker.line.cmin` will correspond to the last color in the
array and `marker.line.cmax` will correspond to the first
color.
The 'reversescale' property must be specified as a bool
(either True, or False) | def reversescale(self):
"""
Reverses the color mapping if true. Has an effect only if in
`marker.line.color`is set to a numerical array. If true,
`marker.line.cmin` will correspond to the last color in the
array and `marker.line.cmax` will correspond to the first
color.
The 'reversescale' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["reversescale"] | [
"def",
"reversescale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"reversescale\"",
"]"
] | [
316,
4
] | [
331,
35
] | python | en | ['en', 'error', 'th'] | False |
Line.width | (self) |
Sets the width (in px) of the lines bounding the marker points.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
|
Sets the width (in px) of the lines bounding the marker points.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above | def width(self):
"""
Sets the width (in px) of the lines bounding the marker points.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
"""
return self["width"] | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
340,
4
] | [
352,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.widthsrc | (self) |
Sets the source reference on Chart Studio Cloud for width .
The 'widthsrc' 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 width .
The 'widthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def widthsrc(self):
"""
Sets the source reference on Chart Studio Cloud for width .
The 'widthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["widthsrc"] | [
"def",
"widthsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"widthsrc\"",
"]"
] | [
361,
4
] | [
372,
31
] | python | en | ['en', 'error', 'th'] | False |
Line.__init__ | (
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmid=None,
cmin=None,
color=None,
coloraxis=None,
colorscale=None,
colorsrc=None,
reversescale=None,
width=None,
widthsrc=None,
**kwargs
) |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scattergeo.marker.Line`
autocolorscale
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is
true, the default palette will be chosen according to
whether numbers in the `color` array are all positive,
all negative or mixed.
cauto
Determines whether or not the color domain is computed
with respect to the input data (here in
`marker.line.color`) or the bounds set in
`marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a
numerical array. Defaults to `false` when
`marker.line.cmin` and `marker.line.cmax` are set by
the user.
cmax
Sets the upper bound of the color domain. Has an effect
only if in `marker.line.color`is set to a numerical
array. Value should have the same units as in
`marker.line.color` and if set, `marker.line.cmin` must
be set as well.
cmid
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be
equidistant to this point. Has an effect only if in
`marker.line.color`is set to a numerical array. Value
should have the same units as in `marker.line.color`.
Has no effect when `marker.line.cauto` is `false`.
cmin
Sets the lower bound of the color domain. Has an effect
only if in `marker.line.color`is set to a numerical
array. Value should have the same units as in
`marker.line.color` and if set, `marker.line.cmax` must
be set as well.
color
Sets themarker.linecolor. It accepts either a specific
color or an array of numbers that are mapped to the
colorscale relative to the max and min values of the
array or relative to `marker.line.cmin` and
`marker.line.cmax` if set.
coloraxis
Sets a reference to a shared color axis. References to
these shared color axes are "coloraxis", "coloraxis2",
"coloraxis3", etc. Settings for these shared color axes
are set in the layout, under `layout.coloraxis`,
`layout.coloraxis2`, etc. Note that multiple color
scales can be linked to the same color axis.
colorscale
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The
colorscale must be an array containing arrays mapping a
normalized value to an rgb, rgba, hex, hsl, hsv, or
named color string. At minimum, a mapping for the
lowest (0) and highest (1) values are required. For
example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`.
To control the bounds of the colorscale in color space,
use`marker.line.cmin` and `marker.line.cmax`.
Alternatively, `colorscale` may be a palette name
string of the following list: Greys,YlGnBu,Greens,YlOrR
d,Bluered,RdBu,Reds,Blues,Picnic,Rainbow,Portland,Jet,H
ot,Blackbody,Earth,Electric,Viridis,Cividis.
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
reversescale
Reverses the color mapping if true. Has an effect only
if in `marker.line.color`is set to a numerical array.
If true, `marker.line.cmin` will correspond to the last
color in the array and `marker.line.cmax` will
correspond to the first color.
width
Sets the width (in px) of the lines bounding the marker
points.
widthsrc
Sets the source reference on Chart Studio Cloud for
width .
Returns
-------
Line
|
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scattergeo.marker.Line`
autocolorscale
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is
true, the default palette will be chosen according to
whether numbers in the `color` array are all positive,
all negative or mixed.
cauto
Determines whether or not the color domain is computed
with respect to the input data (here in
`marker.line.color`) or the bounds set in
`marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a
numerical array. Defaults to `false` when
`marker.line.cmin` and `marker.line.cmax` are set by
the user.
cmax
Sets the upper bound of the color domain. Has an effect
only if in `marker.line.color`is set to a numerical
array. Value should have the same units as in
`marker.line.color` and if set, `marker.line.cmin` must
be set as well.
cmid
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be
equidistant to this point. Has an effect only if in
`marker.line.color`is set to a numerical array. Value
should have the same units as in `marker.line.color`.
Has no effect when `marker.line.cauto` is `false`.
cmin
Sets the lower bound of the color domain. Has an effect
only if in `marker.line.color`is set to a numerical
array. Value should have the same units as in
`marker.line.color` and if set, `marker.line.cmax` must
be set as well.
color
Sets themarker.linecolor. It accepts either a specific
color or an array of numbers that are mapped to the
colorscale relative to the max and min values of the
array or relative to `marker.line.cmin` and
`marker.line.cmax` if set.
coloraxis
Sets a reference to a shared color axis. References to
these shared color axes are "coloraxis", "coloraxis2",
"coloraxis3", etc. Settings for these shared color axes
are set in the layout, under `layout.coloraxis`,
`layout.coloraxis2`, etc. Note that multiple color
scales can be linked to the same color axis.
colorscale
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The
colorscale must be an array containing arrays mapping a
normalized value to an rgb, rgba, hex, hsl, hsv, or
named color string. At minimum, a mapping for the
lowest (0) and highest (1) values are required. For
example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`.
To control the bounds of the colorscale in color space,
use`marker.line.cmin` and `marker.line.cmax`.
Alternatively, `colorscale` may be a palette name
string of the following list: Greys,YlGnBu,Greens,YlOrR
d,Bluered,RdBu,Reds,Blues,Picnic,Rainbow,Portland,Jet,H
ot,Blackbody,Earth,Electric,Viridis,Cividis.
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
reversescale
Reverses the color mapping if true. Has an effect only
if in `marker.line.color`is set to a numerical array.
If true, `marker.line.cmin` will correspond to the last
color in the array and `marker.line.cmax` will
correspond to the first color.
width
Sets the width (in px) of the lines bounding the marker
points.
widthsrc
Sets the source reference on Chart Studio Cloud for
width . | def __init__(
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmid=None,
cmin=None,
color=None,
coloraxis=None,
colorscale=None,
colorsrc=None,
reversescale=None,
width=None,
widthsrc=None,
**kwargs
):
"""
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scattergeo.marker.Line`
autocolorscale
Determines whether the colorscale is a default palette
(`autocolorscale: true`) or the palette determined by
`marker.line.colorscale`. Has an effect only if in
`marker.line.color`is set to a numerical array. In case
`colorscale` is unspecified or `autocolorscale` is
true, the default palette will be chosen according to
whether numbers in the `color` array are all positive,
all negative or mixed.
cauto
Determines whether or not the color domain is computed
with respect to the input data (here in
`marker.line.color`) or the bounds set in
`marker.line.cmin` and `marker.line.cmax` Has an
effect only if in `marker.line.color`is set to a
numerical array. Defaults to `false` when
`marker.line.cmin` and `marker.line.cmax` are set by
the user.
cmax
Sets the upper bound of the color domain. Has an effect
only if in `marker.line.color`is set to a numerical
array. Value should have the same units as in
`marker.line.color` and if set, `marker.line.cmin` must
be set as well.
cmid
Sets the mid-point of the color domain by scaling
`marker.line.cmin` and/or `marker.line.cmax` to be
equidistant to this point. Has an effect only if in
`marker.line.color`is set to a numerical array. Value
should have the same units as in `marker.line.color`.
Has no effect when `marker.line.cauto` is `false`.
cmin
Sets the lower bound of the color domain. Has an effect
only if in `marker.line.color`is set to a numerical
array. Value should have the same units as in
`marker.line.color` and if set, `marker.line.cmax` must
be set as well.
color
Sets themarker.linecolor. It accepts either a specific
color or an array of numbers that are mapped to the
colorscale relative to the max and min values of the
array or relative to `marker.line.cmin` and
`marker.line.cmax` if set.
coloraxis
Sets a reference to a shared color axis. References to
these shared color axes are "coloraxis", "coloraxis2",
"coloraxis3", etc. Settings for these shared color axes
are set in the layout, under `layout.coloraxis`,
`layout.coloraxis2`, etc. Note that multiple color
scales can be linked to the same color axis.
colorscale
Sets the colorscale. Has an effect only if in
`marker.line.color`is set to a numerical array. The
colorscale must be an array containing arrays mapping a
normalized value to an rgb, rgba, hex, hsl, hsv, or
named color string. At minimum, a mapping for the
lowest (0) and highest (1) values are required. For
example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`.
To control the bounds of the colorscale in color space,
use`marker.line.cmin` and `marker.line.cmax`.
Alternatively, `colorscale` may be a palette name
string of the following list: Greys,YlGnBu,Greens,YlOrR
d,Bluered,RdBu,Reds,Blues,Picnic,Rainbow,Portland,Jet,H
ot,Blackbody,Earth,Electric,Viridis,Cividis.
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
reversescale
Reverses the color mapping if true. Has an effect only
if in `marker.line.color`is set to a numerical array.
If true, `marker.line.cmin` will correspond to the last
color in the array and `marker.line.cmax` will
correspond to the first color.
width
Sets the width (in px) of the lines bounding the marker
points.
widthsrc
Sets the source reference on Chart Studio Cloud for
width .
Returns
-------
Line
"""
super(Line, self).__init__("line")
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.scattergeo.marker.Line
constructor must be a dict or
an instance of :class:`plotly.graph_objs.scattergeo.marker.Line`"""
)
# 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("autocolorscale", None)
_v = autocolorscale if autocolorscale is not None else _v
if _v is not None:
self["autocolorscale"] = _v
_v = arg.pop("cauto", None)
_v = cauto if cauto is not None else _v
if _v is not None:
self["cauto"] = _v
_v = arg.pop("cmax", None)
_v = cmax if cmax is not None else _v
if _v is not None:
self["cmax"] = _v
_v = arg.pop("cmid", None)
_v = cmid if cmid is not None else _v
if _v is not None:
self["cmid"] = _v
_v = arg.pop("cmin", None)
_v = cmin if cmin is not None else _v
if _v is not None:
self["cmin"] = _v
_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("coloraxis", None)
_v = coloraxis if coloraxis is not None else _v
if _v is not None:
self["coloraxis"] = _v
_v = arg.pop("colorscale", None)
_v = colorscale if colorscale is not None else _v
if _v is not None:
self["colorscale"] = _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("reversescale", None)
_v = reversescale if reversescale is not None else _v
if _v is not None:
self["reversescale"] = _v
_v = arg.pop("width", None)
_v = width if width is not None else _v
if _v is not None:
self["width"] = _v
_v = arg.pop("widthsrc", None)
_v = widthsrc if widthsrc is not None else _v
if _v is not None:
self["widthsrc"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"autocolorscale",
"=",
"None",
",",
"cauto",
"=",
"None",
",",
"cmax",
"=",
"None",
",",
"cmid",
"=",
"None",
",",
"cmin",
"=",
"None",
",",
"color",
"=",
"None",
",",
"coloraxis",
"=",
"None",
",",
"colorscale",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"reversescale",
"=",
"None",
",",
"width",
"=",
"None",
",",
"widthsrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Line",
",",
"self",
")",
".",
"__init__",
"(",
"\"line\"",
")",
"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.scattergeo.marker.Line \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scattergeo.marker.Line`\"\"\"",
")",
"# 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",
"(",
"\"autocolorscale\"",
",",
"None",
")",
"_v",
"=",
"autocolorscale",
"if",
"autocolorscale",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"autocolorscale\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"cauto\"",
",",
"None",
")",
"_v",
"=",
"cauto",
"if",
"cauto",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"cauto\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"cmax\"",
",",
"None",
")",
"_v",
"=",
"cmax",
"if",
"cmax",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"cmax\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"cmid\"",
",",
"None",
")",
"_v",
"=",
"cmid",
"if",
"cmid",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"cmid\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"cmin\"",
",",
"None",
")",
"_v",
"=",
"cmin",
"if",
"cmin",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"cmin\"",
"]",
"=",
"_v",
"_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",
"(",
"\"coloraxis\"",
",",
"None",
")",
"_v",
"=",
"coloraxis",
"if",
"coloraxis",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"coloraxis\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"colorscale\"",
",",
"None",
")",
"_v",
"=",
"colorscale",
"if",
"colorscale",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"colorscale\"",
"]",
"=",
"_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",
"(",
"\"reversescale\"",
",",
"None",
")",
"_v",
"=",
"reversescale",
"if",
"reversescale",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"reversescale\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"width\"",
",",
"None",
")",
"_v",
"=",
"width",
"if",
"width",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"width\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"widthsrc\"",
",",
"None",
")",
"_v",
"=",
"widthsrc",
"if",
"widthsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"widthsrc\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
464,
4
] | [
658,
34
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.