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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Tickfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
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 ... | 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
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Tickfont object
Sets the tick font.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.carpet.aaxis.Tickfont`
color
family
... |
Construct a new Tickfont object
Sets the tick font. | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Tickfont object
Sets the tick font.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"tick... | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
Title.font | (self) |
Sets this axis' title font. Note that the title's font used to
be customized by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.xaxis.title.Font`
- A... |
Sets this axis' title font. Note that the title's font used to
be customized by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.xaxis.title.Font`
- A... | def font(self):
"""
Sets this axis' title font. Note that the title's font used to
be customized by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.xaxi... | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
15,
4
] | [
53,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.standoff | (self) |
Sets the standoff distance (in px) between the axis labels and
the title text The default value is a function of the axis tick
labels, the title `font.size` and the axis `linewidth`. Note
that the axis title position is always constrained within the
margins, so the actual stando... |
Sets the standoff distance (in px) between the axis labels and
the title text The default value is a function of the axis tick
labels, the title `font.size` and the axis `linewidth`. Note
that the axis title position is always constrained within the
margins, so the actual stando... | def standoff(self):
"""
Sets the standoff distance (in px) between the axis labels and
the title text The default value is a function of the axis tick
labels, the title `font.size` and the axis `linewidth`. Note
that the axis title position is always constrained within the
... | [
"def",
"standoff",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"standoff\"",
"]"
] | [
62,
4
] | [
80,
31
] | python | en | ['en', 'error', 'th'] | False |
Title.text | (self) |
Sets the title of this axis. Note that before the existence of
`title.text`, the title's contents used to be defined as the
`title` attribute itself. This behavior has been deprecated.
The 'text' property is a string and must be specified as:
- A string
- A numb... |
Sets the title of this axis. Note that before the existence of
`title.text`, the title's contents used to be defined as the
`title` attribute itself. This behavior has been deprecated.
The 'text' property is a string and must be specified as:
- A string
- A numb... | def text(self):
"""
Sets the title of this axis. Note that before the existence of
`title.text`, the title's contents used to be defined as the
`title` attribute itself. This behavior has been deprecated.
The 'text' property is a string and must be specified as:
- ... | [
"def",
"text",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"text\"",
"]"
] | [
89,
4
] | [
103,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.__init__ | (self, arg=None, font=None, standoff=None, text=None, **kwargs) |
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.xaxis.Title`
font
Sets this axis' title font. Note that the titl... |
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.xaxis.Title`
font
Sets this axis' title font. Note that the titl... | def __init__(self, arg=None, font=None, standoff=None, text=None, **kwargs):
"""
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.lay... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"font",
"=",
"None",
",",
"standoff",
"=",
"None",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Title",
",",
"self",
")",
".",
"__init__",
"(",
"\"title\... | [
135,
4
] | [
217,
34
] | python | en | ['en', 'error', 'th'] | False |
Font.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
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:
... | 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 name... | [
"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 ... |
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 ... | 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
prefer... | [
"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.violin.hoverlabel.Font`
color
... |
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
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"family",
"=",
"None",
",",
"familysrc",
"=",
"None",
",",
"size",
"=",
"None",
",",
"sizesrc",
"=",
"None",
",",
"*",
"*",
"kw... | [
215,
4
] | [
329,
34
] | python | en | ['en', 'error', 'th'] | False |
load_word_vector | (vector_path, word2id, dim=300) |
Read pretrained vectors
Make lookup table with vocabulary
Load vector at lookup table
|
Read pretrained vectors
Make lookup table with vocabulary
Load vector at lookup table
| def load_word_vector(vector_path, word2id, dim=300):
"""
Read pretrained vectors
Make lookup table with vocabulary
Load vector at lookup table
"""
vocab_size = len(word2id)
lookup_table = np.random.normal(size=[vocab_size, dim])
if 'glove' in str(vector_path):
n_total_vector = 4... | [
"def",
"load_word_vector",
"(",
"vector_path",
",",
"word2id",
",",
"dim",
"=",
"300",
")",
":",
"vocab_size",
"=",
"len",
"(",
"word2id",
")",
"lookup_table",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"size",
"=",
"[",
"vocab_size",
",",
"dim",
"]... | [
160,
0
] | [
187,
23
] | python | en | ['en', 'error', 'th'] | False |
TestCredentialOffer.test_init | (self) | Test initializer | Test initializer | def test_init(self):
"""Test initializer"""
credential_offer = CredentialOffer(
comment="shaken, not stirred",
credential_preview=self.preview,
offers_attach=[
AttachDecorator.from_indy_dict(
indy_dict=self.indy_offer, ident=ATTACH_... | [
"def",
"test_init",
"(",
"self",
")",
":",
"credential_offer",
"=",
"CredentialOffer",
"(",
"comment",
"=",
"\"shaken, not stirred\"",
",",
"credential_preview",
"=",
"self",
".",
"preview",
",",
"offers_attach",
"=",
"[",
"AttachDecorator",
".",
"from_indy_dict",
... | [
50,
4
] | [
63,
64
] | python | de | ['de', 'pl', 'en'] | False |
TestCredentialOffer.test_deserialize | (self, mock_credential_offer_schema_load) |
Test deserialize
|
Test deserialize
| def test_deserialize(self, mock_credential_offer_schema_load):
"""
Test deserialize
"""
obj = self.indy_offer
credential_offer = CredentialOffer.deserialize(obj)
mock_credential_offer_schema_load.assert_called_once_with(obj)
assert credential_offer is mock_crede... | [
"def",
"test_deserialize",
"(",
"self",
",",
"mock_credential_offer_schema_load",
")",
":",
"obj",
"=",
"self",
".",
"indy_offer",
"credential_offer",
"=",
"CredentialOffer",
".",
"deserialize",
"(",
"obj",
")",
"mock_credential_offer_schema_load",
".",
"assert_called_o... | [
82,
4
] | [
91,
81
] | python | en | ['en', 'error', 'th'] | False |
TestCredentialOffer.test_serialize | (self, mock_credential_offer_schema_dump) |
Test serialization.
|
Test serialization.
| def test_serialize(self, mock_credential_offer_schema_dump):
"""
Test serialization.
"""
credential_offer = CredentialOffer(
comment="shaken, not stirred",
credential_preview=self.preview,
offers_attach=[
AttachDecorator.from_indy_dict(... | [
"def",
"test_serialize",
"(",
"self",
",",
"mock_credential_offer_schema_dump",
")",
":",
"credential_offer",
"=",
"CredentialOffer",
"(",
"comment",
"=",
"\"shaken, not stirred\"",
",",
"credential_preview",
"=",
"self",
".",
"preview",
",",
"offers_attach",
"=",
"["... | [
96,
4
] | [
113,
86
] | python | en | ['en', 'error', 'th'] | False |
TestCredentialOfferSchema.test_make_model | (self) | Test making model. | Test making model. | def test_make_model(self):
"""Test making model."""
data = self.credential_offer.serialize()
model_instance = CredentialOffer.deserialize(data)
assert isinstance(model_instance, CredentialOffer) | [
"def",
"test_make_model",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"credential_offer",
".",
"serialize",
"(",
")",
"model_instance",
"=",
"CredentialOffer",
".",
"deserialize",
"(",
"data",
")",
"assert",
"isinstance",
"(",
"model_instance",
",",
"Cred... | [
125,
4
] | [
129,
58
] | python | en | ['en', 'no', 'en'] | True |
Ack.__init__ | (
self,
status: str = None,
**kwargs
) |
Initialize an explicit ack message instance.
Args:
status: Status (default OK)
|
Initialize an explicit ack message instance. | def __init__(
self,
status: str = None,
**kwargs
):
"""
Initialize an explicit ack message instance.
Args:
status: Status (default OK)
"""
super().__init__(**kwargs)
self.status = status or "OK" | [
"def",
"__init__",
"(",
"self",
",",
"status",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"status",
"=",
"status",
"or",
"\"OK\""
] | [
19,
4
] | [
32,
36
] | python | en | ['en', 'error', 'th'] | False |
Line.color | (self) |
Sets the color of the line enclosing each sector. Defaults to
the `paper_bgcolor` value.
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%,... |
Sets the color of the line enclosing each sector. Defaults to
the `paper_bgcolor` value.
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%,... | def color(self):
"""
Sets the color of the line enclosing each sector. Defaults to
the `paper_bgcolor` value.
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/hs... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
67,
28
] | 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\"",
"]"
] | [
76,
4
] | [
87,
31
] | python | en | ['en', 'error', 'th'] | False |
Line.width | (self) |
Sets the width (in px) of the line enclosing each sector.
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.n... |
Sets the width (in px) of the line enclosing each sector.
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 line enclosing each sector.
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
-----... | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
96,
4
] | [
108,
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\"",
"]"
] | [
117,
4
] | [
128,
31
] | python | en | ['en', 'error', 'th'] | False |
Line.__init__ | (
self, arg=None, color=None, colorsrc=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.sunburst.marker.Line`
color
Sets the color of the line enclosing each se... |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.sunburst.marker.Line`
color
Sets the color of the line enclosing each se... | def __init__(
self, arg=None, color=None, colorsrc=None, width=None, widthsrc=None, **kwargs
):
"""
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"width",
"=",
"None",
",",
"widthsrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Line",
",",
"self",
")",
... | [
153,
4
] | [
234,
34
] | python | en | ['en', 'error', 'th'] | False |
Pad.b | (self) |
The amount of padding (in px) along the bottom of the
component.
The 'b' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
The amount of padding (in px) along the bottom of the
component.
The 'b' property is a number and may be specified as:
- An int or float | def b(self):
"""
The amount of padding (in px) along the bottom of the
component.
The 'b' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["b"] | [
"def",
"b",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"b\"",
"]"
] | [
15,
4
] | [
27,
24
] | python | en | ['en', 'error', 'th'] | False |
Pad.l | (self) |
The amount of padding (in px) on the left side of the
component.
The 'l' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
The amount of padding (in px) on the left side of the
component.
The 'l' property is a number and may be specified as:
- An int or float | def l(self):
"""
The amount of padding (in px) on the left side of the
component.
The 'l' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["l"] | [
"def",
"l",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"l\"",
"]"
] | [
36,
4
] | [
48,
24
] | python | en | ['en', 'error', 'th'] | False |
Pad.r | (self) |
The amount of padding (in px) on the right side of the
component.
The 'r' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
The amount of padding (in px) on the right side of the
component.
The 'r' property is a number and may be specified as:
- An int or float | def r(self):
"""
The amount of padding (in px) on the right side of the
component.
The 'r' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["r"] | [
"def",
"r",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"r\"",
"]"
] | [
57,
4
] | [
69,
24
] | python | en | ['en', 'error', 'th'] | False |
Pad.t | (self) |
The amount of padding (in px) along the top of the component.
The 't' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
|
The amount of padding (in px) along the top of the component.
The 't' property is a number and may be specified as:
- An int or float | def t(self):
"""
The amount of padding (in px) along the top of the component.
The 't' property is a number and may be specified as:
- An int or float
Returns
-------
int|float
"""
return self["t"] | [
"def",
"t",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"t\"",
"]"
] | [
78,
4
] | [
89,
24
] | python | en | ['en', 'error', 'th'] | False |
Pad.__init__ | (self, arg=None, b=None, l=None, r=None, t=None, **kwargs) |
Construct a new Pad object
Sets the padding around the buttons or dropdown menu.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.updatemenu.Pad`
... |
Construct a new Pad object
Sets the padding around the buttons or dropdown menu. | def __init__(self, arg=None, b=None, l=None, r=None, t=None, **kwargs):
"""
Construct a new Pad object
Sets the padding around the buttons or dropdown menu.
Parameters
----------
arg
dict of properties compatible with this constructor or
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"b",
"=",
"None",
",",
"l",
"=",
"None",
",",
"r",
"=",
"None",
",",
"t",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Pad",
",",
"self",
")",
".",
"__init__",
... | [
114,
4
] | [
195,
34
] | python | en | ['en', 'error', 'th'] | False |
Marker.color | (self) |
Sets the marker color of selected points.
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%... |
Sets the marker color of selected points.
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%... | def color(self):
"""
Sets the marker color of selected points.
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/h... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Marker.opacity | (self) |
Sets the marker opacity of selected points.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
|
Sets the marker opacity of selected points.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1] | def opacity(self):
"""
Sets the marker opacity of selected points.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
"""
return self["opacity"] | [
"def",
"opacity",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacity\"",
"]"
] | [
74,
4
] | [
85,
30
] | python | en | ['en', 'error', 'th'] | False |
Marker.size | (self) |
Sets the marker size of selected points.
The 'size' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
|
Sets the marker size of selected points.
The 'size' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def size(self):
"""
Sets the marker size of selected points.
The 'size' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
94,
4
] | [
105,
27
] | python | en | ['en', 'error', 'th'] | False |
Marker.__init__ | (self, arg=None, color=None, opacity=None, size=None, **kwargs) |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scattergeo.selected.Marker`
color
Sets the marker color of selected po... |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scattergeo.selected.Marker`
color
Sets the marker color of selected po... | def __init__(self, arg=None, color=None, opacity=None, size=None, **kwargs):
"""
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.sc... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"opacity",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Marker",
",",
"self",
")",
".",
"__init__",
"(",
"\"marke... | [
124,
4
] | [
193,
34
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
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:
... | 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 name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
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 ... | 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
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.scatter3d.mark
er.colorbar.Tickfont`
... |
Construct a new Tickfont object
Sets the color bar's tick label font | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an insta... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"tick... | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
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:
... | 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 name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
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 ... | 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
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Tickfont object
Sets the tick font.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.layout.scene.xaxis.Tickfont`
color
family
... |
Construct a new Tickfont object
Sets the tick font. | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Tickfont object
Sets the tick font.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"tick... | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
VoteModule.forward | (self, seed_points, seed_feats) | forward.
Args:
seed_points (torch.Tensor): Coordinate of the seed
points in shape (B, N, 3).
seed_feats (torch.Tensor): Features of the seed points in shape
(B, C, N).
Returns:
tuple[torch.Tensor]:
- vote_points: Vote... | forward. | def forward(self, seed_points, seed_feats):
"""forward.
Args:
seed_points (torch.Tensor): Coordinate of the seed
points in shape (B, N, 3).
seed_feats (torch.Tensor): Features of the seed points in shape
(B, C, N).
Returns:
tu... | [
"def",
"forward",
"(",
"self",
",",
"seed_points",
",",
"seed_feats",
")",
":",
"if",
"self",
".",
"num_points",
"!=",
"-",
"1",
":",
"assert",
"self",
".",
"num_points",
"<",
"seed_points",
".",
"shape",
"[",
"1",
"]",
",",
"f'Number of vote points ({self... | [
84,
4
] | [
146,
46
] | python | en | ['en', 'cy', 'en'] | False |
VoteModule.get_loss | (self, seed_points, vote_points, seed_indices,
vote_targets_mask, vote_targets) | Calculate loss of voting module.
Args:
seed_points (torch.Tensor): Coordinate of the seed points.
vote_points (torch.Tensor): Coordinate of the vote points.
seed_indices (torch.Tensor): Indices of seed points in raw points.
vote_targets_mask (torch.Tensor): Mask ... | Calculate loss of voting module. | def get_loss(self, seed_points, vote_points, seed_indices,
vote_targets_mask, vote_targets):
"""Calculate loss of voting module.
Args:
seed_points (torch.Tensor): Coordinate of the seed points.
vote_points (torch.Tensor): Coordinate of the vote points.
... | [
"def",
"get_loss",
"(",
"self",
",",
"seed_points",
",",
"vote_points",
",",
"seed_indices",
",",
"vote_targets_mask",
",",
"vote_targets",
")",
":",
"batch_size",
",",
"num_seed",
"=",
"seed_points",
".",
"shape",
"[",
":",
"2",
"]",
"seed_gt_votes_mask",
"="... | [
148,
4
] | [
179,
24
] | python | en | ['en', 'en', 'en'] | True |
SelfFeedingTeacher._setup_data | (self, path) |
Reads data in the fbdialog format.
Returns ``((x,y,r,c), new_episode?)`` tuples.
|
Reads data in the fbdialog format. | def _setup_data(self, path): # Make private method for ParlAIDialogTeacher
"""
Reads data in the fbdialog format.
Returns ``((x,y,r,c), new_episode?)`` tuples.
"""
print("[ Loading Self-Feeding text data:" + path + "]")
self.episodes = []
self.num_exs = 0
... | [
"def",
"_setup_data",
"(",
"self",
",",
"path",
")",
":",
"# Make private method for ParlAIDialogTeacher",
"print",
"(",
"\"[ Loading Self-Feeding text data:\"",
"+",
"path",
"+",
"\"]\"",
")",
"self",
".",
"episodes",
"=",
"[",
"]",
"self",
".",
"num_exs",
"=",
... | [
166,
4
] | [
206,
47
] | python | en | ['en', 'error', 'th'] | False |
prepare_auth_map | (looper,
sdk_wallet_trustee,
sdk_pool_handle) | Adding new steward for old auth rules | Adding new steward for old auth rules | def prepare_auth_map(looper,
sdk_wallet_trustee,
sdk_pool_handle):
wh, _ = sdk_wallet_trustee
did1, verkey1 = create_verkey_did(looper, wh)
"""Adding new steward for old auth rules"""
add_new_nym(looper,
sdk_pool_handle,
[sdk_wall... | [
"def",
"prepare_auth_map",
"(",
"looper",
",",
"sdk_wallet_trustee",
",",
"sdk_pool_handle",
")",
":",
"wh",
",",
"_",
"=",
"sdk_wallet_trustee",
"did1",
",",
"verkey1",
"=",
"create_verkey_did",
"(",
"looper",
",",
"wh",
")",
"add_new_nym",
"(",
"looper",
","... | [
59,
0
] | [
74,
76
] | python | en | ['en', 'en', 'en'] | True |
neginf | (dtype: torch.dtype) |
Return a representable finite number near -inf for a dtype.
|
Return a representable finite number near -inf for a dtype.
| def neginf(dtype: torch.dtype) -> float:
"""
Return a representable finite number near -inf for a dtype.
"""
if dtype is torch.float16:
return -NEAR_INF_FP16
else:
return -NEAR_INF | [
"def",
"neginf",
"(",
"dtype",
":",
"torch",
".",
"dtype",
")",
"->",
"float",
":",
"if",
"dtype",
"is",
"torch",
".",
"float16",
":",
"return",
"-",
"NEAR_INF_FP16",
"else",
":",
"return",
"-",
"NEAR_INF"
] | [
36,
0
] | [
43,
24
] | python | en | ['en', 'error', 'th'] | False |
atomic_save | (state_dict: Any, path: str) |
Like torch.save, but atomic.
Useful for preventing trouble coming from being pre-empted or killed while writing
to disk. Works by writing to a temporary file, and then renaming the file to the
final name.
|
Like torch.save, but atomic. | def atomic_save(state_dict: Any, path: str) -> None:
"""
Like torch.save, but atomic.
Useful for preventing trouble coming from being pre-empted or killed while writing
to disk. Works by writing to a temporary file, and then renaming the file to the
final name.
"""
if io_utils.USE_ATOMIC_T... | [
"def",
"atomic_save",
"(",
"state_dict",
":",
"Any",
",",
"path",
":",
"str",
")",
"->",
"None",
":",
"if",
"io_utils",
".",
"USE_ATOMIC_TORCH_SAVE",
":",
"with",
"open",
"(",
"path",
"+",
"\".tmp\"",
",",
"\"wb\"",
")",
"as",
"f",
":",
"torch",
".",
... | [
46,
0
] | [
61,
37
] | python | en | ['en', 'error', 'th'] | False |
padded_tensor | (
items: List[Union[List[int], torch.LongTensor]],
pad_idx: int = 0,
use_cuda: bool = False,
left_padded: bool = False,
max_len: Optional[int] = None,
fp16friendly: bool = False,
device: int = -1,
) |
Create a padded matrix from an uneven list of lists.
Returns (padded, lengths), where padded is the padded matrix, and lengths
is a list containing the lengths of each row.
Matrix is right-padded (filled to the right) by default, but can be
left padded if the flag is set to True.
Matrix can ... |
Create a padded matrix from an uneven list of lists. | def padded_tensor(
items: List[Union[List[int], torch.LongTensor]],
pad_idx: int = 0,
use_cuda: bool = False,
left_padded: bool = False,
max_len: Optional[int] = None,
fp16friendly: bool = False,
device: int = -1,
) -> Tuple[torch.LongTensor, List[int]]:
"""
Create a padded matrix fr... | [
"def",
"padded_tensor",
"(",
"items",
":",
"List",
"[",
"Union",
"[",
"List",
"[",
"int",
"]",
",",
"torch",
".",
"LongTensor",
"]",
"]",
",",
"pad_idx",
":",
"int",
"=",
"0",
",",
"use_cuda",
":",
"bool",
"=",
"False",
",",
"left_padded",
":",
"bo... | [
64,
0
] | [
136,
23
] | python | en | ['en', 'error', 'th'] | False |
padded_3d | (
tensors: List[torch.LongTensor],
pad_idx: int = 0,
use_cuda: bool = False,
dtype: Optional[torch.dtype] = torch.long,
fp16friendly: bool = False,
) |
Make 3D padded tensor for list of lists of 1D tensors or lists.
:param tensors:
list of lists of 1D tensors (or lists)
:param pad_idx:
padding to fill tensor with
:param use_cuda:
whether to call cuda() before returning
:param bool fp16friendly:
if True, pads the fi... |
Make 3D padded tensor for list of lists of 1D tensors or lists. | def padded_3d(
tensors: List[torch.LongTensor],
pad_idx: int = 0,
use_cuda: bool = False,
dtype: Optional[torch.dtype] = torch.long,
fp16friendly: bool = False,
):
"""
Make 3D padded tensor for list of lists of 1D tensors or lists.
:param tensors:
list of lists of 1D tensors (or... | [
"def",
"padded_3d",
"(",
"tensors",
":",
"List",
"[",
"torch",
".",
"LongTensor",
"]",
",",
"pad_idx",
":",
"int",
"=",
"0",
",",
"use_cuda",
":",
"bool",
"=",
"False",
",",
"dtype",
":",
"Optional",
"[",
"torch",
".",
"dtype",
"]",
"=",
"torch",
"... | [
139,
0
] | [
184,
17
] | python | en | ['en', 'error', 'th'] | False |
concat_without_padding | (text_idx, cand_idx, use_cuda, null_idx=0) |
Concatenate two right padded tensors and move padding to the right.
For example,
if text_idx = [[1, 2, 3, 4, 0, 0 ]]
and cand_idx = [[5, 6, 7, 8, 0, 0 ]]:
Then result = (tokens, segments) where
tokens = [[1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0]]
segments = [[0, 0, 0, 0, 1, 1, ... |
Concatenate two right padded tensors and move padding to the right. | def concat_without_padding(text_idx, cand_idx, use_cuda, null_idx=0):
"""
Concatenate two right padded tensors and move padding to the right.
For example,
if text_idx = [[1, 2, 3, 4, 0, 0 ]]
and cand_idx = [[5, 6, 7, 8, 0, 0 ]]:
Then result = (tokens, segments) where
tokens = [... | [
"def",
"concat_without_padding",
"(",
"text_idx",
",",
"cand_idx",
",",
"use_cuda",
",",
"null_idx",
"=",
"0",
")",
":",
"assert",
"text_idx",
".",
"size",
"(",
"0",
")",
"==",
"cand_idx",
".",
"size",
"(",
"0",
")",
"assert",
"len",
"(",
"text_idx",
"... | [
187,
0
] | [
217,
27
] | python | en | ['en', 'error', 'th'] | False |
argsort | (keys: List[Any], *lists: List[List[Any]], descending: bool = False) |
Reorder each list in lists by the (descending) sorted order of keys.
:param iter keys:
Keys to order by.
:param list[list] lists:
Lists to reordered by keys's order. Correctly handles lists and 1-D
tensors.
:param bool descending:
Use descending order if true.
:re... |
Reorder each list in lists by the (descending) sorted order of keys. | def argsort(keys: List[Any], *lists: List[List[Any]], descending: bool = False):
"""
Reorder each list in lists by the (descending) sorted order of keys.
:param iter keys:
Keys to order by.
:param list[list] lists:
Lists to reordered by keys's order. Correctly handles lists and 1-D
... | [
"def",
"argsort",
"(",
"keys",
":",
"List",
"[",
"Any",
"]",
",",
"*",
"lists",
":",
"List",
"[",
"List",
"[",
"Any",
"]",
"]",
",",
"descending",
":",
"bool",
"=",
"False",
")",
":",
"ind_sorted",
"=",
"sorted",
"(",
"range",
"(",
"len",
"(",
... | [
220,
0
] | [
245,
17
] | python | en | ['en', 'error', 'th'] | False |
compute_grad_norm | (parameters, norm_type=2.0) |
Compute norm over gradients of model parameters.
:param parameters:
the model parameters for gradient norm calculation. Iterable of
Tensors or single Tensor
:param norm_type:
type of p-norm to use
:returns:
the computed gradient norm
|
Compute norm over gradients of model parameters. | def compute_grad_norm(parameters, norm_type=2.0):
"""
Compute norm over gradients of model parameters.
:param parameters:
the model parameters for gradient norm calculation. Iterable of
Tensors or single Tensor
:param norm_type:
type of p-norm to use
:returns:
the c... | [
"def",
"compute_grad_norm",
"(",
"parameters",
",",
"norm_type",
"=",
"2.0",
")",
":",
"if",
"isinstance",
"(",
"parameters",
",",
"torch",
".",
"Tensor",
")",
":",
"parameters",
"=",
"[",
"parameters",
"]",
"parameters",
"=",
"[",
"p",
"for",
"p",
"in",... | [
248,
0
] | [
268,
42
] | python | en | ['en', 'error', 'th'] | False |
total_parameters | (model: torch.nn.Module) |
Count the total number of parameters in the model.
:param model:
the model whose parameters we wish to count.
:return:
total number of parameters in the model.
|
Count the total number of parameters in the model. | def total_parameters(model: torch.nn.Module) -> int:
"""
Count the total number of parameters in the model.
:param model:
the model whose parameters we wish to count.
:return:
total number of parameters in the model.
"""
return sum(p.numel() for p in model.parameters()) | [
"def",
"total_parameters",
"(",
"model",
":",
"torch",
".",
"nn",
".",
"Module",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"p",
".",
"numel",
"(",
")",
"for",
"p",
"in",
"model",
".",
"parameters",
"(",
")",
")"
] | [
285,
0
] | [
295,
53
] | python | en | ['en', 'error', 'th'] | False |
trainable_parameters | (model: torch.nn.Module) |
Count the total number of trainable parameters in the model.
:param model:
the model whose parameters we wish to count.
:return:
total number of trainable parameters in the model.
|
Count the total number of trainable parameters in the model. | def trainable_parameters(model: torch.nn.Module) -> int:
"""
Count the total number of trainable parameters in the model.
:param model:
the model whose parameters we wish to count.
:return:
total number of trainable parameters in the model.
"""
return sum(p.numel() for p in mod... | [
"def",
"trainable_parameters",
"(",
"model",
":",
"torch",
".",
"nn",
".",
"Module",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"p",
".",
"numel",
"(",
")",
"for",
"p",
"in",
"model",
".",
"parameters",
"(",
")",
"if",
"p",
".",
"requires_grad",
... | [
298,
0
] | [
308,
72
] | python | en | ['en', 'error', 'th'] | False |
IdentityLayer.forward | (self, xs) |
Identity.
|
Identity.
| def forward(self, xs):
"""
Identity.
"""
return xs | [
"def",
"forward",
"(",
"self",
",",
"xs",
")",
":",
"return",
"xs"
] | [
278,
4
] | [
282,
17
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.check_compatibility | (self, opt) |
Check compatibility for opts.
Really just used to raise an error message if the user mixes multiprocessing and
model parallelism.
|
Check compatibility for opts. | def check_compatibility(self, opt):
"""
Check compatibility for opts.
Really just used to raise an error message if the user mixes multiprocessing and
model parallelism.
"""
if opt.get('multiprocessing') and not os.environ.get('PARLAI_FORCE_MP'):
raise Runtim... | [
"def",
"check_compatibility",
"(",
"self",
",",
"opt",
")",
":",
"if",
"opt",
".",
"get",
"(",
"'multiprocessing'",
")",
"and",
"not",
"os",
".",
"environ",
".",
"get",
"(",
"'PARLAI_FORCE_MP'",
")",
":",
"raise",
"RuntimeError",
"(",
"\"It looks like you ar... | [
342,
4
] | [
358,
13
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.make_parallel | (self, model: torch.nn.Module) |
Allocate specific layers in a model to be ModelParallel.
Limited to only ModuleLists within the model. Uses some heuristics to
attempt to evenly distribute layers across GPUs, in order to balance
memory usage. They are:
- Assume the 0th GPU will host the optimizer, word embed... |
Allocate specific layers in a model to be ModelParallel. | def make_parallel(self, model: torch.nn.Module) -> torch.nn.Module:
"""
Allocate specific layers in a model to be ModelParallel.
Limited to only ModuleLists within the model. Uses some heuristics to
attempt to evenly distribute layers across GPUs, in order to balance
memory usa... | [
"def",
"make_parallel",
"(",
"self",
",",
"model",
":",
"torch",
".",
"nn",
".",
"Module",
")",
"->",
"torch",
".",
"nn",
".",
"Module",
":",
"# first assume all layers will go onto gpu 0 as an optimizer. The",
"# optimizer and embeddings are not quite as expensive as the",... | [
360,
4
] | [
382,
20
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.guess_split_size | (item: Chunk, num_gpus: Optional[int] = None, dim=0) |
Estimate the number of chunks we should split the batch into via heuristics.
|
Estimate the number of chunks we should split the batch into via heuristics.
| def guess_split_size(item: Chunk, num_gpus: Optional[int] = None, dim=0) -> int:
"""
Estimate the number of chunks we should split the batch into via heuristics.
"""
if num_gpus is None:
num_gpus = torch.cuda.device_count() # type: ignore
if isinstance(item, torch.T... | [
"def",
"guess_split_size",
"(",
"item",
":",
"Chunk",
",",
"num_gpus",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"dim",
"=",
"0",
")",
"->",
"int",
":",
"if",
"num_gpus",
"is",
"None",
":",
"num_gpus",
"=",
"torch",
".",
"cuda",
".",
"dev... | [
434,
4
] | [
454,
72
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.split | (item: Chunk, split_size: Optional[int] = None, dim=0) |
Split a tensor or group of tensors into smaller chunks of the same type.
:param item:
The item being split. May be a Tensor, a tuple of Tensors, or a
dictionary mapping str -> Tensor.
:param split_size:
The maximum size of each output chunk. If None, we will... |
Split a tensor or group of tensors into smaller chunks of the same type. | def split(item: Chunk, split_size: Optional[int] = None, dim=0) -> List[Chunk]:
"""
Split a tensor or group of tensors into smaller chunks of the same type.
:param item:
The item being split. May be a Tensor, a tuple of Tensors, or a
dictionary mapping str -> Tensor.
... | [
"def",
"split",
"(",
"item",
":",
"Chunk",
",",
"split_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"dim",
"=",
"0",
")",
"->",
"List",
"[",
"Chunk",
"]",
":",
"if",
"split_size",
"is",
"None",
":",
"split_size",
"=",
"PipelineHelper",
... | [
457,
4
] | [
508,
62
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.join | (items: List[Chunk], dim=0) |
Join chunks back together, the inverse of split.
:param items:
All the output chunks. Each chunk may be a tensor or a group of
tensors.
:param dim:
The dimension to join along.
|
Join chunks back together, the inverse of split. | def join(items: List[Chunk], dim=0) -> Chunk:
"""
Join chunks back together, the inverse of split.
:param items:
All the output chunks. Each chunk may be a tensor or a group of
tensors.
:param dim:
The dimension to join along.
"""
if l... | [
"def",
"join",
"(",
"items",
":",
"List",
"[",
"Chunk",
"]",
",",
"dim",
"=",
"0",
")",
"->",
"Chunk",
":",
"if",
"len",
"(",
"items",
")",
"==",
"0",
":",
"raise",
"IndexError",
"(",
"\"Cannot rejoin an empty list of chunks.\"",
")",
"item0",
"=",
"it... | [
511,
4
] | [
538,
70
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.chunk_to | (chunk: Chunk, device: str) |
Move the chunk to the device.
Handles chunks which are groups of tensors.
|
Move the chunk to the device. | def chunk_to(chunk: Chunk, device: str) -> Chunk:
"""
Move the chunk to the device.
Handles chunks which are groups of tensors.
"""
if isinstance(chunk, torch.Tensor):
return chunk.to(device) # type: ignore
elif isinstance(chunk, tuple):
return t... | [
"def",
"chunk_to",
"(",
"chunk",
":",
"Chunk",
",",
"device",
":",
"str",
")",
"->",
"Chunk",
":",
"if",
"isinstance",
"(",
"chunk",
",",
"torch",
".",
"Tensor",
")",
":",
"return",
"chunk",
".",
"to",
"(",
"device",
")",
"# type: ignore",
"elif",
"i... | [
541,
4
] | [
558,
86
] | python | en | ['en', 'error', 'th'] | False |
PipelineHelper.schedule_work_items | (layers: torch.nn.ModuleList, chunks: List[Chunk]) |
Iterate through chunks and layers that should be pipelined.
Each iteration of this generator yields the following properties:
- layer_nos: a list of indices of layers for you to forward through
- chunk_idx: the index of the chunk we are manipulating. Use this
if ... |
Iterate through chunks and layers that should be pipelined. | def schedule_work_items(layers: torch.nn.ModuleList, chunks: List[Chunk]):
"""
Iterate through chunks and layers that should be pipelined.
Each iteration of this generator yields the following properties:
- layer_nos: a list of indices of layers for you to forward through
... | [
"def",
"schedule_work_items",
"(",
"layers",
":",
"torch",
".",
"nn",
".",
"ModuleList",
",",
"chunks",
":",
"List",
"[",
"Chunk",
"]",
")",
":",
"# We want to pipeline our computations so that each GPU is working on",
"# chunks of the problem at the same of the time. The loa... | [
561,
4
] | [
624,
21
] | python | en | ['en', 'error', 'th'] | False |
Line.color | (self) |
Sets the line color.
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%)')
- ... |
Sets the line color.
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%)')
- ... | def color(self):
"""
Sets the line color.
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... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.dash | (self) |
Sets the dash style of lines. Set to a dash type string
("solid", "dot", "dash", "longdash", "dashdot", or
"longdashdot") or a dash length list in px (eg
"5px,10px,2px,2px").
The 'dash' property is an enumeration that may be specified as:
- One of the following da... |
Sets the dash style of lines. Set to a dash type string
("solid", "dot", "dash", "longdash", "dashdot", or
"longdashdot") or a dash length list in px (eg
"5px,10px,2px,2px").
The 'dash' property is an enumeration that may be specified as:
- One of the following da... | def dash(self):
"""
Sets the dash style of lines. Set to a dash type string
("solid", "dot", "dash", "longdash", "dashdot", or
"longdashdot") or a dash length list in px (eg
"5px,10px,2px,2px").
The 'dash' property is an enumeration that may be specified as:
... | [
"def",
"dash",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dash\"",
"]"
] | [
74,
4
] | [
91,
27
] | python | en | ['en', 'error', 'th'] | False |
Line.shape | (self) |
Determines the line shape. With "spline" the lines are drawn
using spline interpolation. The other available values
correspond to step-wise line shapes.
The 'shape' property is an enumeration that may be specified as:
- One of the following enumeration values:
... |
Determines the line shape. With "spline" the lines are drawn
using spline interpolation. The other available values
correspond to step-wise line shapes.
The 'shape' property is an enumeration that may be specified as:
- One of the following enumeration values:
... | def shape(self):
"""
Determines the line shape. With "spline" the lines are drawn
using spline interpolation. The other available values
correspond to step-wise line shapes.
The 'shape' property is an enumeration that may be specified as:
- One of the following enu... | [
"def",
"shape",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"shape\"",
"]"
] | [
100,
4
] | [
114,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.smoothing | (self) |
Has an effect only if `shape` is set to "spline" Sets the
amount of smoothing. 0 corresponds to no smoothing (equivalent
to a "linear" shape).
The 'smoothing' property is a number and may be specified as:
- An int or float in the interval [0, 1.3]
Returns
... |
Has an effect only if `shape` is set to "spline" Sets the
amount of smoothing. 0 corresponds to no smoothing (equivalent
to a "linear" shape).
The 'smoothing' property is a number and may be specified as:
- An int or float in the interval [0, 1.3] | def smoothing(self):
"""
Has an effect only if `shape` is set to "spline" Sets the
amount of smoothing. 0 corresponds to no smoothing (equivalent
to a "linear" shape).
The 'smoothing' property is a number and may be specified as:
- An int or float in the interval [... | [
"def",
"smoothing",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"smoothing\"",
"]"
] | [
123,
4
] | [
136,
32
] | python | en | ['en', 'error', 'th'] | False |
Line.width | (self) |
Sets the line width (in px).
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 line width (in px).
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 line width (in px).
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\"",
"]"
] | [
145,
4
] | [
156,
28
] | python | en | ['en', 'error', 'th'] | False |
Line.__init__ | (
self,
arg=None,
color=None,
dash=None,
shape=None,
smoothing=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.scatterpolar.Line`
color
Sets the line color.
dash
S... |
Construct a new Line object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.scatterpolar.Line`
color
Sets the line color.
dash
S... | def __init__(
self,
arg=None,
color=None,
dash=None,
shape=None,
smoothing=None,
width=None,
**kwargs
):
"""
Construct a new Line object
Parameters
----------
arg
dict of properties compatibl... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"dash",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"smoothing",
"=",
"None",
",",
"width",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
... | [
186,
4
] | [
283,
34
] | python | en | ['en', 'error', 'th'] | False |
download | (datapath) |
Download the model.
|
Download the model.
| def download(datapath):
"""
Download the model.
"""
opt = {'datapath': datapath, 'model_type': 'transresnet_multimodal'}
fnames = ['transresnet_multimodal.tgz']
download_models(opt, fnames, 'image_chat') | [
"def",
"download",
"(",
"datapath",
")",
":",
"opt",
"=",
"{",
"'datapath'",
":",
"datapath",
",",
"'model_type'",
":",
"'transresnet_multimodal'",
"}",
"fnames",
"=",
"[",
"'transresnet_multimodal.tgz'",
"]",
"download_models",
"(",
"opt",
",",
"fnames",
",",
... | [
12,
0
] | [
18,
46
] | python | en | ['en', 'error', 'th'] | False |
TestSuperCommand.test_shortopt | (self) |
Tests whether short opts with multiple letters parse correctly.
Known tricky in python 3.8.
|
Tests whether short opts with multiple letters parse correctly. | def test_shortopt(self):
"""
Tests whether short opts with multiple letters parse correctly.
Known tricky in python 3.8.
"""
opt = script.superscript_main(args=['short_opt', '-m', 'repeat_query'])
assert opt.get('model') == 'repeat_query'
opt = script.superscrip... | [
"def",
"test_shortopt",
"(",
"self",
")",
":",
"opt",
"=",
"script",
".",
"superscript_main",
"(",
"args",
"=",
"[",
"'short_opt'",
",",
"'-m'",
",",
"'repeat_query'",
"]",
")",
"assert",
"opt",
".",
"get",
"(",
"'model'",
")",
"==",
"'repeat_query'",
"o... | [
100,
4
] | [
112,
45
] | python | en | ['en', 'error', 'th'] | False |
roll_init | (character) |
Rolls a number between 1-1000 to determine initiative.
Args:
character (obj): The character to determine initiative for
Returns:
initiative (int): The character's place in initiative - higher
numbers go first.
Notes:
By default, does not reference the character and si... |
Rolls a number between 1-1000 to determine initiative. | def roll_init(character):
"""
Rolls a number between 1-1000 to determine initiative.
Args:
character (obj): The character to determine initiative for
Returns:
initiative (int): The character's place in initiative - higher
numbers go first.
Notes:
By default, does n... | [
"def",
"roll_init",
"(",
"character",
")",
":",
"return",
"randint",
"(",
"1",
",",
"1000",
")"
] | [
63,
0
] | [
87,
27
] | python | en | ['en', 'error', 'th'] | False |
get_attack | (attacker, defender) |
Returns a value for an attack roll.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
attack_value (int): Attack roll value, compared against a defense value
to determine whether an attack hits or misses.
Notes:
... |
Returns a value for an attack roll. | def get_attack(attacker, defender):
"""
Returns a value for an attack roll.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
attack_value (int): Attack roll value, compared against a defense value
to determine whe... | [
"def",
"get_attack",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just return a random integer up to 100.",
"attack_value",
"=",
"randint",
"(",
"1",
",",
"100",
")",
"return",
"attack_value"
] | [
90,
0
] | [
112,
23
] | python | en | ['en', 'error', 'th'] | False |
get_defense | (attacker, defender) |
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
defense_value (int): Defense value, compared against an attack roll
... |
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit. | def get_defense(attacker, defender):
"""
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
defense_value (int): Defense ... | [
"def",
"get_defense",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just return 50, for about a 50/50 chance of hit.",
"defense_value",
"=",
"50",
"return",
"defense_value"
] | [
115,
0
] | [
136,
24
] | python | en | ['en', 'error', 'th'] | False |
get_damage | (attacker, defender) |
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being damaged
Returns:
damage_value (int): Damage value, which is to be deducted from the defending
... |
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit. | def get_damage(attacker, defender):
"""
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being damaged
Returns:
damage_value (int): Damage value, wh... | [
"def",
"get_damage",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just generate a number between 15 and 25.",
"damage_value",
"=",
"randint",
"(",
"15",
",",
"25",
")",
"return",
"damage_value"
] | [
139,
0
] | [
160,
23
] | python | en | ['en', 'error', 'th'] | False |
apply_damage | (defender, damage) |
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0.
Args:
defender (obj): Character taking damage
damage (int): Amount of damage being taken
|
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0. | def apply_damage(defender, damage):
"""
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0.
Args:
defender (obj): Character taking damage
damage (int): Amount of damage being taken
"""
defender.db.hp -= damage # Reduce defender's HP by the dama... | [
"def",
"apply_damage",
"(",
"defender",
",",
"damage",
")",
":",
"defender",
".",
"db",
".",
"hp",
"-=",
"damage",
"# Reduce defender's HP by the damage dealt.",
"# If this reduces it to 0 or less, set HP to 0.",
"if",
"defender",
".",
"db",
".",
"hp",
"<=",
"0",
":... | [
163,
0
] | [
175,
26
] | python | en | ['en', 'error', 'th'] | False |
at_defeat | (defeated) |
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
into a dying state or some... |
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
into a dying state or some... | def at_defeat(defeated):
"""
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
... | [
"def",
"at_defeat",
"(",
"defeated",
")",
":",
"defeated",
".",
"location",
".",
"msg_contents",
"(",
"\"%s has been defeated!\"",
"%",
"defeated",
")"
] | [
177,
0
] | [
190,
70
] | python | en | ['en', 'error', 'th'] | False |
resolve_attack | (attacker, defender, attack_value=None, defense_value=None) |
Resolves an attack and outputs the result.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Notes:
Even though the attack and defense values are calculated
extremely simply, they are separated out into their own functions
... |
Resolves an attack and outputs the result. | def resolve_attack(attacker, defender, attack_value=None, defense_value=None):
"""
Resolves an attack and outputs the result.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Notes:
Even though the attack and defense values are calcul... | [
"def",
"resolve_attack",
"(",
"attacker",
",",
"defender",
",",
"attack_value",
"=",
"None",
",",
"defense_value",
"=",
"None",
")",
":",
"# Get an attack roll from the attacker.",
"if",
"not",
"attack_value",
":",
"attack_value",
"=",
"get_attack",
"(",
"attacker",... | [
192,
0
] | [
221,
31
] | python | en | ['en', 'error', 'th'] | False |
combat_cleanup | (character) |
Cleans up all the temporary combat-related attributes on a character.
Args:
character (obj): Character to have their combat attributes removed
Notes:
Any attribute whose key begins with 'combat_' is temporary and no
longer needed once a fight ends.
|
Cleans up all the temporary combat-related attributes on a character. | def combat_cleanup(character):
"""
Cleans up all the temporary combat-related attributes on a character.
Args:
character (obj): Character to have their combat attributes removed
Notes:
Any attribute whose key begins with 'combat_' is temporary and no
longer needed once a fight ... | [
"def",
"combat_cleanup",
"(",
"character",
")",
":",
"for",
"attr",
"in",
"character",
".",
"attributes",
".",
"all",
"(",
")",
":",
"if",
"attr",
".",
"key",
"[",
":",
"7",
"]",
"==",
"\"combat_\"",
":",
"# If the attribute name starts with 'combat_'...",
"... | [
223,
0
] | [
236,
53
] | python | en | ['en', 'error', 'th'] | False |
is_in_combat | (character) |
Returns true if the given character is in combat.
Args:
character (obj): Character to determine if is in combat or not
Returns:
(bool): True if in combat or False if not in combat
|
Returns true if the given character is in combat. | def is_in_combat(character):
"""
Returns true if the given character is in combat.
Args:
character (obj): Character to determine if is in combat or not
Returns:
(bool): True if in combat or False if not in combat
"""
return bool(character.db.combat_turnhandler) | [
"def",
"is_in_combat",
"(",
"character",
")",
":",
"return",
"bool",
"(",
"character",
".",
"db",
".",
"combat_turnhandler",
")"
] | [
239,
0
] | [
249,
48
] | python | en | ['en', 'error', 'th'] | False |
is_turn | (character) |
Returns true if it's currently the given character's turn in combat.
Args:
character (obj): Character to determine if it is their turn or not
Returns:
(bool): True if it is their turn or False otherwise
|
Returns true if it's currently the given character's turn in combat. | def is_turn(character):
"""
Returns true if it's currently the given character's turn in combat.
Args:
character (obj): Character to determine if it is their turn or not
Returns:
(bool): True if it is their turn or False otherwise
"""
turnhandler = character.db.combat_turnhandl... | [
"def",
"is_turn",
"(",
"character",
")",
":",
"turnhandler",
"=",
"character",
".",
"db",
".",
"combat_turnhandler",
"currentchar",
"=",
"turnhandler",
".",
"db",
".",
"fighters",
"[",
"turnhandler",
".",
"db",
".",
"turn",
"]",
"return",
"bool",
"(",
"cha... | [
252,
0
] | [
264,
41
] | python | en | ['en', 'error', 'th'] | False |
spend_action | (character, actions, action_name=None) |
Spends a character's available combat actions and checks for end of turn.
Args:
character (obj): Character spending the action
actions (int) or 'all': Number of actions to spend, or 'all' to spend all actions
Kwargs:
action_name (str or None): If a string is given, sets character'... |
Spends a character's available combat actions and checks for end of turn. | def spend_action(character, actions, action_name=None):
"""
Spends a character's available combat actions and checks for end of turn.
Args:
character (obj): Character spending the action
actions (int) or 'all': Number of actions to spend, or 'all' to spend all actions
Kwargs:
a... | [
"def",
"spend_action",
"(",
"character",
",",
"actions",
",",
"action_name",
"=",
"None",
")",
":",
"if",
"action_name",
":",
"character",
".",
"db",
".",
"combat_lastaction",
"=",
"action_name",
"if",
"actions",
"==",
"'all'",
":",
"# If spending all actions",
... | [
267,
0
] | [
287,
61
] | python | en | ['en', 'error', 'th'] | False |
TBBasicCharacter.at_object_creation | (self) |
Called once, when this object is first created. This is the
normal hook to overload for most object types.
|
Called once, when this object is first created. This is the
normal hook to overload for most object types.
| def at_object_creation(self):
"""
Called once, when this object is first created. This is the
normal hook to overload for most object types.
"""
self.db.max_hp = 100 # Set maximum HP to 100
self.db.hp = self.db.max_hp # Set current HP to maximum
"""
Adds... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"self",
".",
"db",
".",
"max_hp",
"=",
"100",
"# Set maximum HP to 100",
"self",
".",
"db",
".",
"hp",
"=",
"self",
".",
"db",
".",
"max_hp",
"# Set current HP to maximum",
"\"\"\"\n Adds attributes for a ... | [
303,
4
] | [
316,
11
] | python | en | ['en', 'error', 'th'] | False |
TBBasicCharacter.at_before_move | (self, destination) |
Called just before starting to move this object to
destination.
Args:
destination (Object): The object we are moving to
Returns:
shouldmove (bool): If we should move or not.
Notes:
If this method returns False/None, the move is cancelled
... |
Called just before starting to move this object to
destination. | def at_before_move(self, destination):
"""
Called just before starting to move this object to
destination.
Args:
destination (Object): The object we are moving to
Returns:
shouldmove (bool): If we should move or not.
Notes:
If this m... | [
"def",
"at_before_move",
"(",
"self",
",",
"destination",
")",
":",
"# Keep the character from moving if at 0 HP or in combat.",
"if",
"is_in_combat",
"(",
"self",
")",
":",
"self",
".",
"msg",
"(",
"\"You can't exit a room while in combat!\"",
")",
"return",
"False",
"... | [
318,
4
] | [
341,
19
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.at_script_creation | (self) |
Called once, when the script is created.
|
Called once, when the script is created.
| def at_script_creation(self):
"""
Called once, when the script is created.
"""
self.key = "Combat Turn Handler"
self.interval = 5 # Once every 5 seconds
self.persistent = True
self.db.fighters = []
# Add all fighters in the room with at least 1 HP to the... | [
"def",
"at_script_creation",
"(",
"self",
")",
":",
"self",
".",
"key",
"=",
"\"Combat Turn Handler\"",
"self",
".",
"interval",
"=",
"5",
"# Once every 5 seconds",
"self",
".",
"persistent",
"=",
"True",
"self",
".",
"db",
".",
"fighters",
"=",
"[",
"]",
... | [
362,
4
] | [
396,
36
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.at_stop | (self) |
Called at script termination.
|
Called at script termination.
| def at_stop(self):
"""
Called at script termination.
"""
for fighter in self.db.fighters:
combat_cleanup(fighter) # Clean up the combat attributes for every fighter.
self.obj.db.combat_turnhandler = None | [
"def",
"at_stop",
"(",
"self",
")",
":",
"for",
"fighter",
"in",
"self",
".",
"db",
".",
"fighters",
":",
"combat_cleanup",
"(",
"fighter",
")",
"# Clean up the combat attributes for every fighter.",
"self",
".",
"obj",
".",
"db",
".",
"combat_turnhandler",
"=",... | [
398,
4
] | [
404,
45
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.at_repeat | (self) |
Called once every self.interval seconds.
|
Called once every self.interval seconds.
| def at_repeat(self):
"""
Called once every self.interval seconds.
"""
currentchar = self.db.fighters[self.db.turn] # Note the current character in the turn order.
self.db.timer -= self.interval # Count down the timer.
if self.db.timer <= 0:
# Force current ... | [
"def",
"at_repeat",
"(",
"self",
")",
":",
"currentchar",
"=",
"self",
".",
"db",
".",
"fighters",
"[",
"self",
".",
"db",
".",
"turn",
"]",
"# Note the current character in the turn order.",
"self",
".",
"db",
".",
"timer",
"-=",
"self",
".",
"interval",
... | [
406,
4
] | [
421,
48
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.initialize_for_combat | (self, character) |
Prepares a character for combat when starting or entering a fight.
Args:
character (obj): Character to initialize for combat.
|
Prepares a character for combat when starting or entering a fight. | def initialize_for_combat(self, character):
"""
Prepares a character for combat when starting or entering a fight.
Args:
character (obj): Character to initialize for combat.
"""
combat_cleanup(character) # Clean up leftover combat attributes beforehand, just in case... | [
"def",
"initialize_for_combat",
"(",
"self",
",",
"character",
")",
":",
"combat_cleanup",
"(",
"character",
")",
"# Clean up leftover combat attributes beforehand, just in case.",
"character",
".",
"db",
".",
"combat_actionsleft",
"=",
"0",
"# Actions remaining - start of tu... | [
423,
4
] | [
433,
47
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.start_turn | (self, character) |
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up.
Args:
character (obj): Character to be readied.
Notes:
Here, you only get one action per turn, but you might want to allow mo... |
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up. | def start_turn(self, character):
"""
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up.
Args:
character (obj): Character to be readied.
Notes:
Here, you only get one act... | [
"def",
"start_turn",
"(",
"self",
",",
"character",
")",
":",
"character",
".",
"db",
".",
"combat_actionsleft",
"=",
"ACTIONS_PER_TURN",
"# Replenish actions",
"# Prompt the character for their turn and give some information.",
"character",
".",
"msg",
"(",
"\"|wIt's your ... | [
435,
4
] | [
452,
88
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.next_turn | (self) |
Advances to the next character in the turn order.
|
Advances to the next character in the turn order.
| def next_turn(self):
"""
Advances to the next character in the turn order.
"""
# Check to see if every character disengaged as their last action. If so, end combat.
disengage_check = True
for fighter in self.db.fighters:
if fighter.db.combat_lastaction != "di... | [
"def",
"next_turn",
"(",
"self",
")",
":",
"# Check to see if every character disengaged as their last action. If so, end combat.",
"disengage_check",
"=",
"True",
"for",
"fighter",
"in",
"self",
".",
"db",
".",
"fighters",
":",
"if",
"fighter",
".",
"db",
".",
"comba... | [
454,
4
] | [
491,
32
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.turn_end_check | (self, character) |
Tests to see if a character's turn is over, and cycles to the next turn if it is.
Args:
character (obj): Character to test for end of turn
|
Tests to see if a character's turn is over, and cycles to the next turn if it is. | def turn_end_check(self, character):
"""
Tests to see if a character's turn is over, and cycles to the next turn if it is.
Args:
character (obj): Character to test for end of turn
"""
if not character.db.combat_actionsleft: # Character has no actions remaining
... | [
"def",
"turn_end_check",
"(",
"self",
",",
"character",
")",
":",
"if",
"not",
"character",
".",
"db",
".",
"combat_actionsleft",
":",
"# Character has no actions remaining",
"self",
".",
"next_turn",
"(",
")",
"return"
] | [
493,
4
] | [
502,
18
] | python | en | ['en', 'error', 'th'] | False |
TBBasicTurnHandler.join_fight | (self, character) |
Adds a new character to a fight already in progress.
Args:
character (obj): Character to be added to the fight.
|
Adds a new character to a fight already in progress. | def join_fight(self, character):
"""
Adds a new character to a fight already in progress.
Args:
character (obj): Character to be added to the fight.
"""
# Inserts the fighter to the turn order, right behind whoever's turn it currently is.
self.db.fighters.ins... | [
"def",
"join_fight",
"(",
"self",
",",
"character",
")",
":",
"# Inserts the fighter to the turn order, right behind whoever's turn it currently is.",
"self",
".",
"db",
".",
"fighters",
".",
"insert",
"(",
"self",
".",
"db",
".",
"turn",
",",
"character",
")",
"# T... | [
504,
4
] | [
516,
45
] | python | en | ['en', 'error', 'th'] | False |
CmdFight.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
here = self.caller.location
fighters = []
if not self.caller.db.hp: # If you don't have any hp
self.caller.msg("You can't start a fight if you've been defeated!")
return
if is_in_c... | [
"def",
"func",
"(",
"self",
")",
":",
"here",
"=",
"self",
".",
"caller",
".",
"location",
"fighters",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"caller",
".",
"db",
".",
"hp",
":",
"# If you don't have any hp",
"self",
".",
"caller",
".",
"msg",
"(",... | [
540,
4
] | [
565,
74
] | python | en | ['en', 'error', 'th'] | False |
CmdAttack.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
"Set the attacker to the caller and the defender to the target."
if not is_in_combat(self.caller): # If not in combat, can't attack.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
... | [
"def",
"func",
"(",
"self",
")",
":",
"\"Set the attacker to the caller and the defender to the target.\"",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If not in combat, can't attack.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do... | [
583,
4
] | [
615,
58
] | python | en | ['en', 'en', 'en'] | True |
CmdPass.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
if not is_in_combat(self.caller): # Can only pass a turn in combat.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # Can only pass if it'... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# Can only pass a turn in combat.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"not... | [
633,
4
] | [
646,
60
] | python | en | ['en', 'error', 'th'] | False |
CmdDisengage.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
if not is_in_combat(self.caller): # If you're not in combat
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # If it's not your turn
... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If you're not in combat",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"not",
"is... | [
665,
4
] | [
682,
11
] | python | en | ['en', 'error', 'th'] | False |
CmdRest.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
if is_in_combat(self.caller): # If you're in combat
self.caller.msg("You can't rest while you're in combat.")
return
self.caller.db.hp = self.caller.db.max_hp # Set current HP to maximum
self.caller.location.... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If you're in combat",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can't rest while you're in combat.\"",
")",
"return",
"self",
".",
"caller",
".",
"db",
... | [
699,
4
] | [
710,
11
] | python | en | ['en', 'en', 'en'] | True |
BattleCmdSet.at_cmdset_creation | (self) |
Populates the cmdset
|
Populates the cmdset
| def at_cmdset_creation(self):
"""
Populates the cmdset
"""
self.add(CmdFight())
self.add(CmdAttack())
self.add(CmdRest())
self.add(CmdPass())
self.add(CmdDisengage())
self.add(CmdCombatHelp()) | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"self",
".",
"add",
"(",
"CmdFight",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdAttack",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdRest",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdPass",
"(... | [
744,
4
] | [
753,
33
] | python | en | ['en', 'error', 'th'] | False |
Title.font | (self) |
Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.scattergl.marker.colorbar.title.Font`
... |
Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.scattergl.marker.colorbar.title.Font`
... | def font(self):
"""
Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.scattergl.ma... | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
15,
4
] | [
53,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.side | (self) |
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the following enumeration values... |
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the following enumeration values... | def side(self):
"""
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the f... | [
"def",
"side",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"side\"",
"]"
] | [
62,
4
] | [
76,
27
] | 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.