Search is not available for this dataset
identifier
stringlengths 1
155
| parameters
stringlengths 2
6.09k
| docstring
stringlengths 11
63.4k
| docstring_summary
stringlengths 0
63.4k
| function
stringlengths 29
99.8k
| function_tokens
sequence | start_point
sequence | end_point
sequence | language
stringclasses 1
value | docstring_language
stringlengths 2
7
| docstring_language_predictions
stringlengths 18
23
| is_langid_reliable
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|---|---|---|
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.waterfall.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.waterfall.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.waterfall.hoverlabel.Font
constructor must be a dict or
an instance of :class:`plotly.graph_objs.waterfall.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.waterfall.hoverlabel.Font \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.waterfall.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 |
setup | (bot) |
Mandatory function to add the Cog to the bot.
|
Mandatory function to add the Cog to the bot.
| def setup(bot):
"""
Mandatory function to add the Cog to the bot.
"""
bot.add_cog(AdministrationCog(bot)) | [
"def",
"setup",
"(",
"bot",
")",
":",
"bot",
".",
"add_cog",
"(",
"AdministrationCog",
"(",
"bot",
")",
")"
] | [
300,
0
] | [
304,
39
] | python | en | ['en', 'error', 'th'] | False |
AdministrationCog.delete_msg | (self, ctx, *msgs: discord.Message) |
Deletes messages.
Can take several message Ids as input, as long as they are seperated by a single space.
Example:
@AntiPetros delete_msg 837700676872044604 837488218567475200
|
Deletes messages. | async def delete_msg(self, ctx, *msgs: discord.Message):
"""
Deletes messages.
Can take several message Ids as input, as long as they are seperated by a single space.
Example:
@AntiPetros delete_msg 837700676872044604 837488218567475200
"""
for msg in msgs:
await msg.delete()
await ctx.message.delete() | [
"async",
"def",
"delete_msg",
"(",
"self",
",",
"ctx",
",",
"*",
"msgs",
":",
"discord",
".",
"Message",
")",
":",
"for",
"msg",
"in",
"msgs",
":",
"await",
"msg",
".",
"delete",
"(",
")",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")"
] | [
114,
4
] | [
126,
34
] | python | en | ['en', 'error', 'th'] | False |
AdministrationCog.the_bots_new_clothes | (self, ctx: commands.Context, delete_after: int = None) |
Sends about a page worth of empty message to a channel, looks like channel got purged.
Optional deletes the empty message after specified seconds (defaults to not deleting)
Args:
delete_after (int, optional): time in seconds after which to delete the empty message. Defaults to None which means that it does not delete the empty message.
Example:
@AntiPetros the_bot_new_clothes 120
|
Sends about a page worth of empty message to a channel, looks like channel got purged. | async def the_bots_new_clothes(self, ctx: commands.Context, delete_after: int = None):
"""
Sends about a page worth of empty message to a channel, looks like channel got purged.
Optional deletes the empty message after specified seconds (defaults to not deleting)
Args:
delete_after (int, optional): time in seconds after which to delete the empty message. Defaults to None which means that it does not delete the empty message.
Example:
@AntiPetros the_bot_new_clothes 120
"""
msg = ZERO_WIDTH * 20 + '\n'
await ctx.send('THE BOTS NEW CLOTHES' + (msg * 60), delete_after=delete_after)
await delete_message_if_text_channel(ctx) | [
"async",
"def",
"the_bots_new_clothes",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"delete_after",
":",
"int",
"=",
"None",
")",
":",
"msg",
"=",
"ZERO_WIDTH",
"*",
"20",
"+",
"'\\n'",
"await",
"ctx",
".",
"send",
"(",
"'THE BOTS NEW CLOTHES'",
"+",
"(",
"msg",
"*",
"60",
")",
",",
"delete_after",
"=",
"delete_after",
")",
"await",
"delete_message_if_text_channel",
"(",
"ctx",
")"
] | [
130,
4
] | [
145,
49
] | python | en | ['en', 'error', 'th'] | False |
AdministrationCog.write_message | (self, ctx: commands.Context, channel: discord.TextChannel, *, message: str) |
Writes a message as the bot to a specific channel.
Args:
channel (discord.TextChannel): name or id of channel. Preferably use Id as it is failsafe.
message (str): The message you want to write, does not need any quotes and can be multiline
Example:
@AntiPetros write_message 645930607683174401 This is my message
|
Writes a message as the bot to a specific channel. | async def write_message(self, ctx: commands.Context, channel: discord.TextChannel, *, message: str):
"""
Writes a message as the bot to a specific channel.
Args:
channel (discord.TextChannel): name or id of channel. Preferably use Id as it is failsafe.
message (str): The message you want to write, does not need any quotes and can be multiline
Example:
@AntiPetros write_message 645930607683174401 This is my message
"""
await channel.send(message, allowed_mentions=discord.AllowedMentions.none())
await ctx.message.delete() | [
"async",
"def",
"write_message",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"channel",
":",
"discord",
".",
"TextChannel",
",",
"*",
",",
"message",
":",
"str",
")",
":",
"await",
"channel",
".",
"send",
"(",
"message",
",",
"allowed_mentions",
"=",
"discord",
".",
"AllowedMentions",
".",
"none",
"(",
")",
")",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")"
] | [
149,
4
] | [
162,
34
] | python | en | ['en', 'error', 'th'] | False |
AdministrationCog.edit_message | (self, ctx: commands.Context, channel: discord.TextChannel, msg_id: int, *, content: str) |
Writes a message as the bot to a specific channel.
Args:
channel (discord.TextChannel): name or id of channel. Preferably use Id as it is failsafe.
message (str): The message you want to write, does not need any quotes and can be multiline
Example:
@AntiPetros write_message 645930607683174401 This is my message
|
Writes a message as the bot to a specific channel. | async def edit_message(self, ctx: commands.Context, channel: discord.TextChannel, msg_id: int, *, content: str):
"""
Writes a message as the bot to a specific channel.
Args:
channel (discord.TextChannel): name or id of channel. Preferably use Id as it is failsafe.
message (str): The message you want to write, does not need any quotes and can be multiline
Example:
@AntiPetros write_message 645930607683174401 This is my message
"""
to_edit_msg = await channel.fetch_message(msg_id)
await to_edit_msg.edit(content=content)
await ctx.message.delete() | [
"async",
"def",
"edit_message",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"channel",
":",
"discord",
".",
"TextChannel",
",",
"msg_id",
":",
"int",
",",
"*",
",",
"content",
":",
"str",
")",
":",
"to_edit_msg",
"=",
"await",
"channel",
".",
"fetch_message",
"(",
"msg_id",
")",
"await",
"to_edit_msg",
".",
"edit",
"(",
"content",
"=",
"content",
")",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")"
] | [
166,
4
] | [
180,
34
] | python | en | ['en', 'error', 'th'] | False |
AdministrationCog.make_embed | (self, ctx: commands.Context, channel: discord.TextChannel, **flags) |
Creates a simple embed message in the specified channel.
No support for embed fields, as input would be to complicated.
Args:
channel (discord.TextChannel): either channel name or channel id (prefered), where the message should be posted.
--title (str):
--description (str):
--url (str):
--thumbnail (str):
--image (str):
--timestamp (str):
--author-name (str):
--author-url (str):
--author-icon (str):
--footer-text (str):
--footer-icon (str):
--thumbnail (str):
--image (str):
--disable-mentions (bool):
--delete-after (int):
Example:
@AntiPetros make_embed -t "My Title" -d "This is my description" -dis yes -da 120
|
Creates a simple embed message in the specified channel. | async def make_embed(self, ctx: commands.Context, channel: discord.TextChannel, **flags):
"""
Creates a simple embed message in the specified channel.
No support for embed fields, as input would be to complicated.
Args:
channel (discord.TextChannel): either channel name or channel id (prefered), where the message should be posted.
--title (str):
--description (str):
--url (str):
--thumbnail (str):
--image (str):
--timestamp (str):
--author-name (str):
--author-url (str):
--author-icon (str):
--footer-text (str):
--footer-icon (str):
--thumbnail (str):
--image (str):
--disable-mentions (bool):
--delete-after (int):
Example:
@AntiPetros make_embed -t "My Title" -d "This is my description" -dis yes -da 120
"""
allowed_mentions = discord.AllowedMentions.none() if flags.pop("disable_mentions") is True else None
delete_after = flags.pop('delete_after')
print(delete_after)
if flags.get('author_name', None) is not None:
flags["author"] = {"name": flags.pop('author_name', None), "url": flags.pop("author_url", None), "icon_url": flags.pop("author_icon", None)}
else:
flags["author"] = None
if flags.get('footer_text', None) is not None:
flags["footer"] = {"text": flags.pop("footer_text", None), "icon_url": flags.pop("footer_icon", None)}
else:
flags["footer"] = None
embed_data = await self.bot.make_generic_embed(**flags, color='random')
embed_message = await channel.send(**embed_data, allowed_mentions=allowed_mentions, delete_after=delete_after)
await ctx.send(f"__**Created Embed in Channel**__: {channel.mention}\n**__Link__**: {embed_message.jump_url}", allowed_mentions=discord.AllowedMentions.none(), delete_after=60)
await asyncio.sleep(60)
await delete_message_if_text_channel(ctx) | [
"async",
"def",
"make_embed",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
",",
"channel",
":",
"discord",
".",
"TextChannel",
",",
"*",
"*",
"flags",
")",
":",
"allowed_mentions",
"=",
"discord",
".",
"AllowedMentions",
".",
"none",
"(",
")",
"if",
"flags",
".",
"pop",
"(",
"\"disable_mentions\"",
")",
"is",
"True",
"else",
"None",
"delete_after",
"=",
"flags",
".",
"pop",
"(",
"'delete_after'",
")",
"print",
"(",
"delete_after",
")",
"if",
"flags",
".",
"get",
"(",
"'author_name'",
",",
"None",
")",
"is",
"not",
"None",
":",
"flags",
"[",
"\"author\"",
"]",
"=",
"{",
"\"name\"",
":",
"flags",
".",
"pop",
"(",
"'author_name'",
",",
"None",
")",
",",
"\"url\"",
":",
"flags",
".",
"pop",
"(",
"\"author_url\"",
",",
"None",
")",
",",
"\"icon_url\"",
":",
"flags",
".",
"pop",
"(",
"\"author_icon\"",
",",
"None",
")",
"}",
"else",
":",
"flags",
"[",
"\"author\"",
"]",
"=",
"None",
"if",
"flags",
".",
"get",
"(",
"'footer_text'",
",",
"None",
")",
"is",
"not",
"None",
":",
"flags",
"[",
"\"footer\"",
"]",
"=",
"{",
"\"text\"",
":",
"flags",
".",
"pop",
"(",
"\"footer_text\"",
",",
"None",
")",
",",
"\"icon_url\"",
":",
"flags",
".",
"pop",
"(",
"\"footer_icon\"",
",",
"None",
")",
"}",
"else",
":",
"flags",
"[",
"\"footer\"",
"]",
"=",
"None",
"embed_data",
"=",
"await",
"self",
".",
"bot",
".",
"make_generic_embed",
"(",
"*",
"*",
"flags",
",",
"color",
"=",
"'random'",
")",
"embed_message",
"=",
"await",
"channel",
".",
"send",
"(",
"*",
"*",
"embed_data",
",",
"allowed_mentions",
"=",
"allowed_mentions",
",",
"delete_after",
"=",
"delete_after",
")",
"await",
"ctx",
".",
"send",
"(",
"f\"__**Created Embed in Channel**__: {channel.mention}\\n**__Link__**: {embed_message.jump_url}\"",
",",
"allowed_mentions",
"=",
"discord",
".",
"AllowedMentions",
".",
"none",
"(",
")",
",",
"delete_after",
"=",
"60",
")",
"await",
"asyncio",
".",
"sleep",
"(",
"60",
")",
"await",
"delete_message_if_text_channel",
"(",
"ctx",
")"
] | [
198,
4
] | [
241,
49
] | python | en | ['en', 'error', 'th'] | False |
AdministrationCog.all_guild_emojis | (self, ctx: commands.Context) |
Collects all Guild emojis and sends them as zipped file.
Example:
@AntiPetros all_guild_emojis
|
Collects all Guild emojis and sends them as zipped file. | async def all_guild_emojis(self, ctx: commands.Context):
"""
Collects all Guild emojis and sends them as zipped file.
Example:
@AntiPetros all_guild_emojis
"""
async with ctx.typing():
start_message = await ctx.send('Please wait this could take a minute or more!')
with TemporaryDirectory() as tempdir:
zip_path = pathmaker(tempdir, 'all_guild_emojis.zip')
with ZipFile(zip_path, 'w', ZIP_LZMA) as zippy:
for emoji in self.bot.antistasi_guild.emojis:
emoji_asset = emoji.url_as()
save_path = pathmaker(tempdir, emoji.name + '_' + str(sum(int(num) for num in str(emoji.id))) + '.' + str(emoji_asset).split('.')[-1])
await emoji_asset.save(save_path)
zippy.write(save_path, os.path.basename(save_path))
file = discord.File(zip_path)
await ctx.send(file=file)
if ctx.channel.type is not discord.ChannelType.private:
await start_message.delete() | [
"async",
"def",
"all_guild_emojis",
"(",
"self",
",",
"ctx",
":",
"commands",
".",
"Context",
")",
":",
"async",
"with",
"ctx",
".",
"typing",
"(",
")",
":",
"start_message",
"=",
"await",
"ctx",
".",
"send",
"(",
"'Please wait this could take a minute or more!'",
")",
"with",
"TemporaryDirectory",
"(",
")",
"as",
"tempdir",
":",
"zip_path",
"=",
"pathmaker",
"(",
"tempdir",
",",
"'all_guild_emojis.zip'",
")",
"with",
"ZipFile",
"(",
"zip_path",
",",
"'w'",
",",
"ZIP_LZMA",
")",
"as",
"zippy",
":",
"for",
"emoji",
"in",
"self",
".",
"bot",
".",
"antistasi_guild",
".",
"emojis",
":",
"emoji_asset",
"=",
"emoji",
".",
"url_as",
"(",
")",
"save_path",
"=",
"pathmaker",
"(",
"tempdir",
",",
"emoji",
".",
"name",
"+",
"'_'",
"+",
"str",
"(",
"sum",
"(",
"int",
"(",
"num",
")",
"for",
"num",
"in",
"str",
"(",
"emoji",
".",
"id",
")",
")",
")",
"+",
"'.'",
"+",
"str",
"(",
"emoji_asset",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
")",
"await",
"emoji_asset",
".",
"save",
"(",
"save_path",
")",
"zippy",
".",
"write",
"(",
"save_path",
",",
"os",
".",
"path",
".",
"basename",
"(",
"save_path",
")",
")",
"file",
"=",
"discord",
".",
"File",
"(",
"zip_path",
")",
"await",
"ctx",
".",
"send",
"(",
"file",
"=",
"file",
")",
"if",
"ctx",
".",
"channel",
".",
"type",
"is",
"not",
"discord",
".",
"ChannelType",
".",
"private",
":",
"await",
"start_message",
".",
"delete",
"(",
")"
] | [
244,
4
] | [
264,
48
] | 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.scatterpolargl.marker.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size
Returns
-------
plotly.graph_objs.scatterpolargl.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.scatterpolargl.marker.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size | 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.scatterpolargl.marker.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size
Returns
-------
plotly.graph_objs.scatterpolargl.marker.colorbar.title.Font
"""
return self["font"] | [
"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:
['right', 'top', 'bottom']
Returns
-------
Any
|
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:
['right', 'top', 'bottom'] | 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 following enumeration values:
['right', 'top', 'bottom']
Returns
-------
Any
"""
return self["side"] | [
"def",
"side",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"side\"",
"]"
] | [
62,
4
] | [
76,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.text | (self) |
Sets the title of the color bar. 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 number that will be converted to a string
Returns
-------
str
|
Sets the title of the color bar. 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 number that will be converted to a string | def text(self):
"""
Sets the title of the color bar. 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 number that will be converted to a string
Returns
-------
str
"""
return self["text"] | [
"def",
"text",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"text\"",
"]"
] | [
85,
4
] | [
99,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.__init__ | (self, arg=None, font=None, side=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.scatterpolargl
.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.
side
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.
text
Sets the title of the color bar. 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.
Returns
-------
Title
|
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.scatterpolargl
.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.
side
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.
text
Sets the title of the color bar. 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. | def __init__(self, arg=None, font=None, side=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.scatterpolargl
.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.
side
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.
text
Sets the title of the color bar. 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.
Returns
-------
Title
"""
super(Title, self).__init__("title")
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.marker.colorbar.Title
constructor must be a dict or
an instance of :class:`plotly.graph_objs.scatterpolargl.marker.colorbar.Title`"""
)
# 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("font", None)
_v = font if font is not None else _v
if _v is not None:
self["font"] = _v
_v = arg.pop("side", None)
_v = side if side is not None else _v
if _v is not None:
self["side"] = _v
_v = arg.pop("text", None)
_v = text if text is not None else _v
if _v is not None:
self["text"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"font",
"=",
"None",
",",
"side",
"=",
"None",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Title",
",",
"self",
")",
".",
"__init__",
"(",
"\"title\"",
")",
"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.marker.colorbar.Title \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.scatterpolargl.marker.colorbar.Title`\"\"\"",
")",
"# 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",
"(",
"\"font\"",
",",
"None",
")",
"_v",
"=",
"font",
"if",
"font",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"font\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"side\"",
",",
"None",
")",
"_v",
"=",
"side",
"if",
"side",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"side\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"text\"",
",",
"None",
")",
"_v",
"=",
"text",
"if",
"text",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"text\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
126,
4
] | [
203,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseDenseHead.loss | (self, **kwargs) | Compute losses of the head. | Compute losses of the head. | def loss(self, **kwargs):
"""Compute losses of the head."""
pass | [
"def",
"loss",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
12,
4
] | [
14,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseDenseHead.get_bboxes | (self, **kwargs) | Transform network output for a batch into bbox predictions. | Transform network output for a batch into bbox predictions. | def get_bboxes(self, **kwargs):
"""Transform network output for a batch into bbox predictions."""
pass | [
"def",
"get_bboxes",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"pass"
] | [
17,
4
] | [
19,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseDenseHead.forward_train | (self,
x,
img_metas,
gt_bboxes,
gt_labels=None,
gt_bboxes_ignore=None,
proposal_cfg=None,
**kwargs) |
Args:
x (list[Tensor]): Features from FPN.
img_metas (list[dict]): Meta information of each image, e.g.,
image size, scaling factor, etc.
gt_bboxes (Tensor): Ground truth bboxes of the image,
shape (num_gts, 4).
gt_labels (Tensor): Ground truth labels of each box,
shape (num_gts,).
gt_bboxes_ignore (Tensor): Ground truth bboxes to be
ignored, shape (num_ignored_gts, 4).
proposal_cfg (mmcv.Config): Test / postprocessing configuration,
if None, test_cfg would be used
Returns:
tuple:
losses: (dict[str, Tensor]): A dictionary of loss components.
proposal_list (list[Tensor]): Proposals of each image.
|
Args:
x (list[Tensor]): Features from FPN.
img_metas (list[dict]): Meta information of each image, e.g.,
image size, scaling factor, etc.
gt_bboxes (Tensor): Ground truth bboxes of the image,
shape (num_gts, 4).
gt_labels (Tensor): Ground truth labels of each box,
shape (num_gts,).
gt_bboxes_ignore (Tensor): Ground truth bboxes to be
ignored, shape (num_ignored_gts, 4).
proposal_cfg (mmcv.Config): Test / postprocessing configuration,
if None, test_cfg would be used | def forward_train(self,
x,
img_metas,
gt_bboxes,
gt_labels=None,
gt_bboxes_ignore=None,
proposal_cfg=None,
**kwargs):
"""
Args:
x (list[Tensor]): Features from FPN.
img_metas (list[dict]): Meta information of each image, e.g.,
image size, scaling factor, etc.
gt_bboxes (Tensor): Ground truth bboxes of the image,
shape (num_gts, 4).
gt_labels (Tensor): Ground truth labels of each box,
shape (num_gts,).
gt_bboxes_ignore (Tensor): Ground truth bboxes to be
ignored, shape (num_ignored_gts, 4).
proposal_cfg (mmcv.Config): Test / postprocessing configuration,
if None, test_cfg would be used
Returns:
tuple:
losses: (dict[str, Tensor]): A dictionary of loss components.
proposal_list (list[Tensor]): Proposals of each image.
"""
outs = self(x)
if gt_labels is None:
loss_inputs = outs + (gt_bboxes, img_metas)
else:
loss_inputs = outs + (gt_bboxes, gt_labels, img_metas)
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
if proposal_cfg is None:
return losses
else:
proposal_list = self.get_bboxes(*outs, img_metas, cfg=proposal_cfg)
return losses, proposal_list | [
"def",
"forward_train",
"(",
"self",
",",
"x",
",",
"img_metas",
",",
"gt_bboxes",
",",
"gt_labels",
"=",
"None",
",",
"gt_bboxes_ignore",
"=",
"None",
",",
"proposal_cfg",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"outs",
"=",
"self",
"(",
"x",
")",
"if",
"gt_labels",
"is",
"None",
":",
"loss_inputs",
"=",
"outs",
"+",
"(",
"gt_bboxes",
",",
"img_metas",
")",
"else",
":",
"loss_inputs",
"=",
"outs",
"+",
"(",
"gt_bboxes",
",",
"gt_labels",
",",
"img_metas",
")",
"losses",
"=",
"self",
".",
"loss",
"(",
"*",
"loss_inputs",
",",
"gt_bboxes_ignore",
"=",
"gt_bboxes_ignore",
")",
"if",
"proposal_cfg",
"is",
"None",
":",
"return",
"losses",
"else",
":",
"proposal_list",
"=",
"self",
".",
"get_bboxes",
"(",
"*",
"outs",
",",
"img_metas",
",",
"cfg",
"=",
"proposal_cfg",
")",
"return",
"losses",
",",
"proposal_list"
] | [
21,
4
] | [
58,
40
] | 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.histogram2dcontour.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size
Returns
-------
plotly.graph_objs.histogram2dcontour.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.histogram2dcontour.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size | 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.histogram2dcontour.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size
Returns
-------
plotly.graph_objs.histogram2dcontour.colorbar.title.Font
"""
return self["font"] | [
"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:
['right', 'top', 'bottom']
Returns
-------
Any
|
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:
['right', 'top', 'bottom'] | 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 following enumeration values:
['right', 'top', 'bottom']
Returns
-------
Any
"""
return self["side"] | [
"def",
"side",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"side\"",
"]"
] | [
62,
4
] | [
76,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.text | (self) |
Sets the title of the color bar. 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 number that will be converted to a string
Returns
-------
str
|
Sets the title of the color bar. 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 number that will be converted to a string | def text(self):
"""
Sets the title of the color bar. 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 number that will be converted to a string
Returns
-------
str
"""
return self["text"] | [
"def",
"text",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"text\"",
"]"
] | [
85,
4
] | [
99,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.__init__ | (self, arg=None, font=None, side=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.histogram2dcon
tour.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.
side
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.
text
Sets the title of the color bar. 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.
Returns
-------
Title
|
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.histogram2dcon
tour.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.
side
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.
text
Sets the title of the color bar. 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. | def __init__(self, arg=None, font=None, side=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.histogram2dcon
tour.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.
side
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.
text
Sets the title of the color bar. 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.
Returns
-------
Title
"""
super(Title, self).__init__("title")
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.histogram2dcontour.colorbar.Title
constructor must be a dict or
an instance of :class:`plotly.graph_objs.histogram2dcontour.colorbar.Title`"""
)
# 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("font", None)
_v = font if font is not None else _v
if _v is not None:
self["font"] = _v
_v = arg.pop("side", None)
_v = side if side is not None else _v
if _v is not None:
self["side"] = _v
_v = arg.pop("text", None)
_v = text if text is not None else _v
if _v is not None:
self["text"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"font",
"=",
"None",
",",
"side",
"=",
"None",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Title",
",",
"self",
")",
".",
"__init__",
"(",
"\"title\"",
")",
"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.histogram2dcontour.colorbar.Title \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.histogram2dcontour.colorbar.Title`\"\"\"",
")",
"# 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",
"(",
"\"font\"",
",",
"None",
")",
"_v",
"=",
"font",
"if",
"font",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"font\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"side\"",
",",
"None",
")",
"_v",
"=",
"side",
"if",
"side",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"side\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"text\"",
",",
"None",
")",
"_v",
"=",
"text",
"if",
"text",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"text\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
126,
4
] | [
203,
34
] | python | en | ['en', 'error', 'th'] | False |
MockDict.__init__ | (self, opt, shared=None) |
Initialize idx for incremental indexing.
|
Initialize idx for incremental indexing.
| def __init__(self, opt, shared=None):
"""
Initialize idx for incremental indexing.
"""
self.idx = 0 | [
"def",
"__init__",
"(",
"self",
",",
"opt",
",",
"shared",
"=",
"None",
")",
":",
"self",
".",
"idx",
"=",
"0"
] | [
35,
4
] | [
39,
20
] | python | en | ['en', 'error', 'th'] | False |
MockDict.__getitem__ | (self, key) |
Return index of special token or return the token.
|
Return index of special token or return the token.
| def __getitem__(self, key):
"""
Return index of special token or return the token.
"""
if key == self.null_token:
return self.NULL_IDX
elif key == self.start_token:
return self.BEG_IDX
elif key == self.end_token:
return self.END_IDX
elif key == self.p1_token:
return self.P1_IDX
elif key == self.p2_token:
return self.P2_IDX
else:
self.idx += 1
return self.idx | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"==",
"self",
".",
"null_token",
":",
"return",
"self",
".",
"NULL_IDX",
"elif",
"key",
"==",
"self",
".",
"start_token",
":",
"return",
"self",
".",
"BEG_IDX",
"elif",
"key",
"==",
"self",
".",
"end_token",
":",
"return",
"self",
".",
"END_IDX",
"elif",
"key",
"==",
"self",
".",
"p1_token",
":",
"return",
"self",
".",
"P1_IDX",
"elif",
"key",
"==",
"self",
".",
"p2_token",
":",
"return",
"self",
".",
"P2_IDX",
"else",
":",
"self",
".",
"idx",
"+=",
"1",
"return",
"self",
".",
"idx"
] | [
41,
4
] | [
57,
27
] | python | en | ['en', 'error', 'th'] | False |
MockDict.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add CLI args.
|
Add CLI args.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add CLI args.
"""
pass
return parser | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"pass",
"return",
"parser"
] | [
66,
4
] | [
73,
21
] | python | en | ['en', 'error', 'th'] | False |
MockDict.txt2vec | (self, txt) |
Return index of special tokens or range from 1 for each token.
|
Return index of special tokens or range from 1 for each token.
| def txt2vec(self, txt):
"""
Return index of special tokens or range from 1 for each token.
"""
self.idx = 0
return [self[tok] for tok in txt.split()] | [
"def",
"txt2vec",
"(",
"self",
",",
"txt",
")",
":",
"self",
".",
"idx",
"=",
"0",
"return",
"[",
"self",
"[",
"tok",
"]",
"for",
"tok",
"in",
"txt",
".",
"split",
"(",
")",
"]"
] | [
75,
4
] | [
80,
49
] | python | en | ['en', 'error', 'th'] | False |
MockDict.save | (self, path, sort=False) |
Override to do nothing.
|
Override to do nothing.
| def save(self, path, sort=False):
"""
Override to do nothing.
"""
pass | [
"def",
"save",
"(",
"self",
",",
"path",
",",
"sort",
"=",
"False",
")",
":",
"pass"
] | [
82,
4
] | [
86,
12
] | python | en | ['en', 'error', 'th'] | False |
MockTorchAgent.dictionary_class | () |
Replace normal dictionary class with mock one.
|
Replace normal dictionary class with mock one.
| def dictionary_class():
"""
Replace normal dictionary class with mock one.
"""
return MockDict | [
"def",
"dictionary_class",
"(",
")",
":",
"return",
"MockDict"
] | [
95,
4
] | [
99,
23
] | python | en | ['en', 'error', 'th'] | False |
MockTorchAgent.train_step | (self, batch) |
Return confirmation of training.
|
Return confirmation of training.
| def train_step(self, batch):
"""
Return confirmation of training.
"""
return Output(['Training {}!'.format(i) for i in range(len(batch.text_vec))]) | [
"def",
"train_step",
"(",
"self",
",",
"batch",
")",
":",
"return",
"Output",
"(",
"[",
"'Training {}!'",
".",
"format",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"batch",
".",
"text_vec",
")",
")",
"]",
")"
] | [
112,
4
] | [
116,
85
] | python | en | ['en', 'error', 'th'] | False |
MockTorchAgent.eval_step | (self, batch) |
Return confirmation of evaluation.
|
Return confirmation of evaluation.
| def eval_step(self, batch):
"""
Return confirmation of evaluation.
"""
return Output(
[
'Evaluating {} (responding to {})!'.format(
i, batch.observations[i]['text']
)
for i in range(len(batch.text_vec))
]
) | [
"def",
"eval_step",
"(",
"self",
",",
"batch",
")",
":",
"return",
"Output",
"(",
"[",
"'Evaluating {} (responding to {})!'",
".",
"format",
"(",
"i",
",",
"batch",
".",
"observations",
"[",
"i",
"]",
"[",
"'text'",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"batch",
".",
"text_vec",
")",
")",
"]",
")"
] | [
118,
4
] | [
129,
9
] | python | en | ['en', 'error', 'th'] | False |
SilentTorchAgent.dictionary_class | () |
Replace normal dictionary class with mock one.
|
Replace normal dictionary class with mock one.
| def dictionary_class():
"""
Replace normal dictionary class with mock one.
"""
return MockDict | [
"def",
"dictionary_class",
"(",
")",
":",
"return",
"MockDict"
] | [
138,
4
] | [
142,
23
] | python | en | ['en', 'error', 'th'] | False |
SilentTorchAgent.train_step | (self, batch) |
Null output.
|
Null output.
| def train_step(self, batch):
"""
Null output.
"""
return Output() | [
"def",
"train_step",
"(",
"self",
",",
"batch",
")",
":",
"return",
"Output",
"(",
")"
] | [
155,
4
] | [
159,
23
] | python | en | ['en', 'error', 'th'] | False |
SilentTorchAgent.eval_step | (self, batch) |
Null output.
|
Null output.
| def eval_step(self, batch):
"""
Null output.
"""
return Output() | [
"def",
"eval_step",
"(",
"self",
",",
"batch",
")",
":",
"return",
"Output",
"(",
")"
] | [
161,
4
] | [
165,
23
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
Returns
-------
str
|
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
Returns
-------
str
"""
return self["color"] | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts if they aren't available on
the system. The Chart Studio Cloud (at https://chart-
studio.plotly.com or on-premise) generates images on a server,
where only a select number of fonts are installed and
supported. These include "Arial", "Balto", "Courier New",
"Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
The 'family' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
|
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts if they aren't available on
the system. The Chart Studio Cloud (at https://chart-
studio.plotly.com or on-premise) generates images on a server,
where only a select number of fonts are installed and
supported. These include "Arial", "Balto", "Courier New",
"Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
The 'family' property is a string and must be specified as:
- A non-empty string | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts if they aren't available on
the system. The Chart Studio Cloud (at https://chart-
studio.plotly.com or on-premise) generates images on a server,
where only a select number of fonts are installed and
supported. These include "Arial", "Balto", "Courier New",
"Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
The 'family' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
"""
return self["family"] | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickfont.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.cone.colorbar.Tickfont`
color
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The Chart
Studio Cloud (at https://chart-studio.plotly.com or on-
premise) generates images on a server, where only a
select number of fonts are installed and supported.
These include "Arial", "Balto", "Courier New", "Droid
Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT
Sans Narrow", "Raleway", "Times New Roman".
size
Returns
-------
Tickfont
|
Construct a new Tickfont object
Sets the color bar's tick label font | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Tickfont object
Sets the color bar's tick label font
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.cone.colorbar.Tickfont`
color
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The Chart
Studio Cloud (at https://chart-studio.plotly.com or on-
premise) generates images on a server, where only a
select number of fonts are installed and supported.
These include "Arial", "Balto", "Courier New", "Droid
Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT
Sans Narrow", "Raleway", "Times New Roman".
size
Returns
-------
Tickfont
"""
super(Tickfont, self).__init__("tickfont")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.cone.colorbar.Tickfont
constructor must be a dict or
an instance of :class:`plotly.graph_objs.cone.colorbar.Tickfont`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("color", None)
_v = color if color is not None else _v
if _v is not None:
self["color"] = _v
_v = arg.pop("family", None)
_v = family if family is not None else _v
if _v is not None:
self["family"] = _v
_v = arg.pop("size", None)
_v = size if size is not None else _v
if _v is not None:
self["size"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickfont",
",",
"self",
")",
".",
"__init__",
"(",
"\"tickfont\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.cone.colorbar.Tickfont \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.cone.colorbar.Tickfont`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"color\"",
",",
"None",
")",
"_v",
"=",
"color",
"if",
"color",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"color\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"family\"",
",",
"None",
")",
"_v",
"=",
"family",
"if",
"family",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"family\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"size\"",
",",
"None",
")",
"_v",
"=",
"size",
"if",
"size",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"size\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
143,
4
] | [
226,
34
] | python | en | ['en', 'error', 'th'] | False |
CredentialProposal.__init__ | (
self,
_id: str = None,
*,
comment: str = None,
credential_proposal: CredentialPreview = None,
schema_id: str = None,
schema_issuer_did: str = None,
schema_name: str = None,
schema_version: str = None,
cred_def_id: str = None,
issuer_did: str = None,
**kwargs,
) |
Initialize credential proposal object.
Args:
comment: optional human-readable comment
credential_proposal: proposed credential preview
schema_id: schema identifier
schema_issuer_did: schema issuer DID
schema_name: schema name
schema_version: schema version
cred_def_id: credential definition identifier
issuer_did: credential issuer DID
|
Initialize credential proposal object. | def __init__(
self,
_id: str = None,
*,
comment: str = None,
credential_proposal: CredentialPreview = None,
schema_id: str = None,
schema_issuer_did: str = None,
schema_name: str = None,
schema_version: str = None,
cred_def_id: str = None,
issuer_did: str = None,
**kwargs,
):
"""
Initialize credential proposal object.
Args:
comment: optional human-readable comment
credential_proposal: proposed credential preview
schema_id: schema identifier
schema_issuer_did: schema issuer DID
schema_name: schema name
schema_version: schema version
cred_def_id: credential definition identifier
issuer_did: credential issuer DID
"""
super().__init__(_id, **kwargs)
self.comment = comment
self.credential_proposal = (
credential_proposal if credential_proposal else CredentialPreview()
)
self.schema_id = schema_id
self.schema_issuer_did = schema_issuer_did
self.schema_name = schema_name
self.schema_version = schema_version
self.cred_def_id = cred_def_id
self.issuer_did = issuer_did | [
"def",
"__init__",
"(",
"self",
",",
"_id",
":",
"str",
"=",
"None",
",",
"*",
",",
"comment",
":",
"str",
"=",
"None",
",",
"credential_proposal",
":",
"CredentialPreview",
"=",
"None",
",",
"schema_id",
":",
"str",
"=",
"None",
",",
"schema_issuer_did",
":",
"str",
"=",
"None",
",",
"schema_name",
":",
"str",
"=",
"None",
",",
"schema_version",
":",
"str",
"=",
"None",
",",
"cred_def_id",
":",
"str",
"=",
"None",
",",
"issuer_did",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
",",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"_id",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"comment",
"=",
"comment",
"self",
".",
"credential_proposal",
"=",
"(",
"credential_proposal",
"if",
"credential_proposal",
"else",
"CredentialPreview",
"(",
")",
")",
"self",
".",
"schema_id",
"=",
"schema_id",
"self",
".",
"schema_issuer_did",
"=",
"schema_issuer_did",
"self",
".",
"schema_name",
"=",
"schema_name",
"self",
".",
"schema_version",
"=",
"schema_version",
"self",
".",
"cred_def_id",
"=",
"cred_def_id",
"self",
".",
"issuer_did",
"=",
"issuer_did"
] | [
33,
4
] | [
70,
36
] | python | en | ['en', 'error', 'th'] | False |
Increasing.fillcolor | (self) |
Sets the fill color. Defaults to a half-transparent variant of
the line color, marker color, or marker line color, whichever
is available.
The 'fillcolor' 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 fill color. Defaults to a half-transparent variant of
the line color, marker color, or marker line color, whichever
is available.
The 'fillcolor' 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 fillcolor(self):
"""
Sets the fill color. Defaults to a half-transparent variant of
the line color, marker color, or marker line color, whichever
is available.
The 'fillcolor' 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["fillcolor"] | [
"def",
"fillcolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"fillcolor\"",
"]"
] | [
15,
4
] | [
67,
32
] | python | en | ['en', 'error', 'th'] | False |
Increasing.line | (self) |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.candlestick.increasing.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
color
Sets the color of line bounding the box(es).
width
Sets the width (in px) of line bounding the
box(es).
Returns
-------
plotly.graph_objs.candlestick.increasing.Line
|
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.candlestick.increasing.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
color
Sets the color of line bounding the box(es).
width
Sets the width (in px) of line bounding the
box(es). | def line(self):
"""
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.candlestick.increasing.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
color
Sets the color of line bounding the box(es).
width
Sets the width (in px) of line bounding the
box(es).
Returns
-------
plotly.graph_objs.candlestick.increasing.Line
"""
return self["line"] | [
"def",
"line",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"line\"",
"]"
] | [
76,
4
] | [
96,
27
] | python | en | ['en', 'error', 'th'] | False |
Increasing.__init__ | (self, arg=None, fillcolor=None, line=None, **kwargs) |
Construct a new Increasing object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.candlestick.Increasing`
fillcolor
Sets the fill color. Defaults to a half-transparent
variant of the line color, marker color, or marker line
color, whichever is available.
line
:class:`plotly.graph_objects.candlestick.increasing.Lin
e` instance or dict with compatible properties
Returns
-------
Increasing
|
Construct a new Increasing object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.candlestick.Increasing`
fillcolor
Sets the fill color. Defaults to a half-transparent
variant of the line color, marker color, or marker line
color, whichever is available.
line
:class:`plotly.graph_objects.candlestick.increasing.Lin
e` instance or dict with compatible properties | def __init__(self, arg=None, fillcolor=None, line=None, **kwargs):
"""
Construct a new Increasing object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.candlestick.Increasing`
fillcolor
Sets the fill color. Defaults to a half-transparent
variant of the line color, marker color, or marker line
color, whichever is available.
line
:class:`plotly.graph_objects.candlestick.increasing.Lin
e` instance or dict with compatible properties
Returns
-------
Increasing
"""
super(Increasing, self).__init__("increasing")
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
constructor must be a dict or
an instance of :class:`plotly.graph_objs.candlestick.Increasing`"""
)
# 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("fillcolor", None)
_v = fillcolor if fillcolor is not None else _v
if _v is not None:
self["fillcolor"] = _v
_v = arg.pop("line", None)
_v = line if line is not None else _v
if _v is not None:
self["line"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"fillcolor",
"=",
"None",
",",
"line",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Increasing",
",",
"self",
")",
".",
"__init__",
"(",
"\"increasing\"",
")",
"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 \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.candlestick.Increasing`\"\"\"",
")",
"# 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",
"(",
"\"fillcolor\"",
",",
"None",
")",
"_v",
"=",
"fillcolor",
"if",
"fillcolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"fillcolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"line\"",
",",
"None",
")",
"_v",
"=",
"line",
"if",
"line",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"line\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
116,
4
] | [
182,
34
] | python | en | ['en', 'error', 'th'] | False |
imshow | (
img,
zmin=None,
zmax=None,
origin=None,
labels={},
x=None,
y=None,
color_continuous_scale=None,
color_continuous_midpoint=None,
range_color=None,
title=None,
template=None,
width=None,
height=None,
aspect=None,
) |
Display an image, i.e. data on a 2D regular raster.
Parameters
----------
img: array-like image, or xarray
The image data. Supported array shapes are
- (M, N): an image with scalar data. The data is visualized
using a colormap.
- (M, N, 3): an image with RGB values.
- (M, N, 4): an image with RGBA values, i.e. including transparency.
zmin, zmax : scalar or iterable, optional
zmin and zmax define the scalar range that the colormap covers. By default,
zmin and zmax correspond to the min and max values of the datatype for integer
datatypes (ie [0-255] for uint8 images, [0, 65535] for uint16 images, etc.). For
a multichannel image of floats, the max of the image is computed and zmax is the
smallest power of 256 (1, 255, 65535) greater than this max value,
with a 5% tolerance. For a single-channel image, the max of the image is used.
Overridden by range_color.
origin : str, 'upper' or 'lower' (default 'upper')
position of the [0, 0] pixel of the image array, in the upper left or lower left
corner. The convention 'upper' is typically used for matrices and images.
labels : dict with str keys and str values (default `{}`)
Sets names used in the figure for axis titles (keys ``x`` and ``y``),
colorbar title and hoverlabel (key ``color``). The values should correspond
to the desired label to be displayed. If ``img`` is an xarray, dimension
names are used for axis titles, and long name for the colorbar title
(unless overridden in ``labels``). Possible keys are: x, y, and color.
x, y: list-like, optional
x and y are used to label the axes of single-channel heatmap visualizations and
their lengths must match the lengths of the second and first dimensions of the
img argument. They are auto-populated if the input is an xarray.
color_continuous_scale : str or list of str
colormap used to map scalar data to colors (for a 2D image). This parameter is
not used for RGB or RGBA images. If a string is provided, it should be the name
of a known color scale, and if a list is provided, it should be a list of CSS-
compatible colors.
color_continuous_midpoint : number
If set, computes the bounds of the continuous color scale to have the desired
midpoint. Overridden by range_color or zmin and zmax.
range_color : list of two numbers
If provided, overrides auto-scaling on the continuous color scale, including
overriding `color_continuous_midpoint`. Also overrides zmin and zmax. Used only
for single-channel images.
title : str
The figure title.
template : str or dict or plotly.graph_objects.layout.Template instance
The figure template name or definition.
width : number
The figure width in pixels.
height: number
The figure height in pixels.
aspect: 'equal', 'auto', or None
- 'equal': Ensures an aspect ratio of 1 or pixels (square pixels)
- 'auto': The axes is kept fixed and the aspect ratio of pixels is
adjusted so that the data fit in the axes. In general, this will
result in non-square pixels.
- if None, 'equal' is used for numpy arrays and 'auto' for xarrays
(which have typically heterogeneous coordinates)
Returns
-------
fig : graph_objects.Figure containing the displayed image
See also
--------
plotly.graph_objects.Image : image trace
plotly.graph_objects.Heatmap : heatmap trace
Notes
-----
In order to update and customize the returned figure, use
`go.Figure.update_traces` or `go.Figure.update_layout`.
If an xarray is passed, dimensions names and coordinates are used for
axes labels and ticks.
|
Display an image, i.e. data on a 2D regular raster. | def imshow(
img,
zmin=None,
zmax=None,
origin=None,
labels={},
x=None,
y=None,
color_continuous_scale=None,
color_continuous_midpoint=None,
range_color=None,
title=None,
template=None,
width=None,
height=None,
aspect=None,
):
"""
Display an image, i.e. data on a 2D regular raster.
Parameters
----------
img: array-like image, or xarray
The image data. Supported array shapes are
- (M, N): an image with scalar data. The data is visualized
using a colormap.
- (M, N, 3): an image with RGB values.
- (M, N, 4): an image with RGBA values, i.e. including transparency.
zmin, zmax : scalar or iterable, optional
zmin and zmax define the scalar range that the colormap covers. By default,
zmin and zmax correspond to the min and max values of the datatype for integer
datatypes (ie [0-255] for uint8 images, [0, 65535] for uint16 images, etc.). For
a multichannel image of floats, the max of the image is computed and zmax is the
smallest power of 256 (1, 255, 65535) greater than this max value,
with a 5% tolerance. For a single-channel image, the max of the image is used.
Overridden by range_color.
origin : str, 'upper' or 'lower' (default 'upper')
position of the [0, 0] pixel of the image array, in the upper left or lower left
corner. The convention 'upper' is typically used for matrices and images.
labels : dict with str keys and str values (default `{}`)
Sets names used in the figure for axis titles (keys ``x`` and ``y``),
colorbar title and hoverlabel (key ``color``). The values should correspond
to the desired label to be displayed. If ``img`` is an xarray, dimension
names are used for axis titles, and long name for the colorbar title
(unless overridden in ``labels``). Possible keys are: x, y, and color.
x, y: list-like, optional
x and y are used to label the axes of single-channel heatmap visualizations and
their lengths must match the lengths of the second and first dimensions of the
img argument. They are auto-populated if the input is an xarray.
color_continuous_scale : str or list of str
colormap used to map scalar data to colors (for a 2D image). This parameter is
not used for RGB or RGBA images. If a string is provided, it should be the name
of a known color scale, and if a list is provided, it should be a list of CSS-
compatible colors.
color_continuous_midpoint : number
If set, computes the bounds of the continuous color scale to have the desired
midpoint. Overridden by range_color or zmin and zmax.
range_color : list of two numbers
If provided, overrides auto-scaling on the continuous color scale, including
overriding `color_continuous_midpoint`. Also overrides zmin and zmax. Used only
for single-channel images.
title : str
The figure title.
template : str or dict or plotly.graph_objects.layout.Template instance
The figure template name or definition.
width : number
The figure width in pixels.
height: number
The figure height in pixels.
aspect: 'equal', 'auto', or None
- 'equal': Ensures an aspect ratio of 1 or pixels (square pixels)
- 'auto': The axes is kept fixed and the aspect ratio of pixels is
adjusted so that the data fit in the axes. In general, this will
result in non-square pixels.
- if None, 'equal' is used for numpy arrays and 'auto' for xarrays
(which have typically heterogeneous coordinates)
Returns
-------
fig : graph_objects.Figure containing the displayed image
See also
--------
plotly.graph_objects.Image : image trace
plotly.graph_objects.Heatmap : heatmap trace
Notes
-----
In order to update and customize the returned figure, use
`go.Figure.update_traces` or `go.Figure.update_layout`.
If an xarray is passed, dimensions names and coordinates are used for
axes labels and ticks.
"""
args = locals()
apply_default_cascade(args)
labels = labels.copy()
if xarray_imported and isinstance(img, xarray.DataArray):
y_label, x_label = img.dims[0], img.dims[1]
# np.datetime64 is not handled correctly by go.Heatmap
for ax in [x_label, y_label]:
if np.issubdtype(img.coords[ax].dtype, np.datetime64):
img.coords[ax] = img.coords[ax].astype(str)
if x is None:
x = img.coords[x_label]
if y is None:
y = img.coords[y_label]
if aspect is None:
aspect = "auto"
if labels.get("x", None) is None:
labels["x"] = x_label
if labels.get("y", None) is None:
labels["y"] = y_label
if labels.get("color", None) is None:
labels["color"] = xarray.plot.utils.label_from_attrs(img)
labels["color"] = labels["color"].replace("\n", "<br>")
else:
if hasattr(img, "columns") and hasattr(img.columns, "__len__"):
if x is None:
x = img.columns
if labels.get("x", None) is None and hasattr(img.columns, "name"):
labels["x"] = img.columns.name or ""
if hasattr(img, "index") and hasattr(img.index, "__len__"):
if y is None:
y = img.index
if labels.get("y", None) is None and hasattr(img.index, "name"):
labels["y"] = img.index.name or ""
if labels.get("x", None) is None:
labels["x"] = ""
if labels.get("y", None) is None:
labels["y"] = ""
if labels.get("color", None) is None:
labels["color"] = ""
if aspect is None:
aspect = "equal"
img = np.asanyarray(img)
# Cast bools to uint8 (also one byte)
if img.dtype == np.bool:
img = 255 * img.astype(np.uint8)
# For 2d data, use Heatmap trace
if img.ndim == 2:
if y is not None and img.shape[0] != len(y):
raise ValueError(
"The length of the y vector must match the length of the first "
+ "dimension of the img matrix."
)
if x is not None and img.shape[1] != len(x):
raise ValueError(
"The length of the x vector must match the length of the second "
+ "dimension of the img matrix."
)
trace = go.Heatmap(x=x, y=y, z=img, coloraxis="coloraxis1")
autorange = True if origin == "lower" else "reversed"
layout = dict(yaxis=dict(autorange=autorange))
if aspect == "equal":
layout["xaxis"] = dict(scaleanchor="y", constrain="domain")
layout["yaxis"]["constrain"] = "domain"
colorscale_validator = ColorscaleValidator("colorscale", "imshow")
if zmin is not None and zmax is None:
zmax = img.max()
if zmax is not None and zmin is None:
zmin = img.min()
range_color = range_color or [zmin, zmax]
layout["coloraxis1"] = dict(
colorscale=colorscale_validator.validate_coerce(
args["color_continuous_scale"]
),
cmid=color_continuous_midpoint,
cmin=range_color[0],
cmax=range_color[1],
)
if labels["color"]:
layout["coloraxis1"]["colorbar"] = dict(title_text=labels["color"])
# For 2D+RGB data, use Image trace
elif img.ndim == 3 and img.shape[-1] in [3, 4]:
if zmax is None and img.dtype is not np.uint8:
zmax = _infer_zmax_from_type(img)
zmin, zmax = _vectorize_zvalue(zmin), _vectorize_zvalue(zmax)
trace = go.Image(z=img, zmin=zmin, zmax=zmax)
layout = {}
if origin == "lower":
layout["yaxis"] = dict(autorange=True)
else:
raise ValueError(
"px.imshow only accepts 2D single-channel, RGB or RGBA images. "
"An image of shape %s was provided" % str(img.shape)
)
layout_patch = dict()
for attr_name in ["height", "width"]:
if args[attr_name]:
layout_patch[attr_name] = args[attr_name]
if args["title"]:
layout_patch["title_text"] = args["title"]
elif args["template"].layout.margin.t is None:
layout_patch["margin"] = {"t": 60}
fig = go.Figure(data=trace, layout=layout)
fig.update_layout(layout_patch)
fig.update_traces(
hovertemplate="%s: %%{x}<br>%s: %%{y}<br>%s: %%{z}<extra></extra>"
% (labels["x"] or "x", labels["y"] or "y", labels["color"] or "color",)
)
if labels["x"]:
fig.update_xaxes(title_text=labels["x"])
if labels["y"]:
fig.update_yaxes(title_text=labels["y"])
fig.update_layout(template=args["template"], overwrite=True)
return fig | [
"def",
"imshow",
"(",
"img",
",",
"zmin",
"=",
"None",
",",
"zmax",
"=",
"None",
",",
"origin",
"=",
"None",
",",
"labels",
"=",
"{",
"}",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"color_continuous_scale",
"=",
"None",
",",
"color_continuous_midpoint",
"=",
"None",
",",
"range_color",
"=",
"None",
",",
"title",
"=",
"None",
",",
"template",
"=",
"None",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"aspect",
"=",
"None",
",",
")",
":",
"args",
"=",
"locals",
"(",
")",
"apply_default_cascade",
"(",
"args",
")",
"labels",
"=",
"labels",
".",
"copy",
"(",
")",
"if",
"xarray_imported",
"and",
"isinstance",
"(",
"img",
",",
"xarray",
".",
"DataArray",
")",
":",
"y_label",
",",
"x_label",
"=",
"img",
".",
"dims",
"[",
"0",
"]",
",",
"img",
".",
"dims",
"[",
"1",
"]",
"# np.datetime64 is not handled correctly by go.Heatmap",
"for",
"ax",
"in",
"[",
"x_label",
",",
"y_label",
"]",
":",
"if",
"np",
".",
"issubdtype",
"(",
"img",
".",
"coords",
"[",
"ax",
"]",
".",
"dtype",
",",
"np",
".",
"datetime64",
")",
":",
"img",
".",
"coords",
"[",
"ax",
"]",
"=",
"img",
".",
"coords",
"[",
"ax",
"]",
".",
"astype",
"(",
"str",
")",
"if",
"x",
"is",
"None",
":",
"x",
"=",
"img",
".",
"coords",
"[",
"x_label",
"]",
"if",
"y",
"is",
"None",
":",
"y",
"=",
"img",
".",
"coords",
"[",
"y_label",
"]",
"if",
"aspect",
"is",
"None",
":",
"aspect",
"=",
"\"auto\"",
"if",
"labels",
".",
"get",
"(",
"\"x\"",
",",
"None",
")",
"is",
"None",
":",
"labels",
"[",
"\"x\"",
"]",
"=",
"x_label",
"if",
"labels",
".",
"get",
"(",
"\"y\"",
",",
"None",
")",
"is",
"None",
":",
"labels",
"[",
"\"y\"",
"]",
"=",
"y_label",
"if",
"labels",
".",
"get",
"(",
"\"color\"",
",",
"None",
")",
"is",
"None",
":",
"labels",
"[",
"\"color\"",
"]",
"=",
"xarray",
".",
"plot",
".",
"utils",
".",
"label_from_attrs",
"(",
"img",
")",
"labels",
"[",
"\"color\"",
"]",
"=",
"labels",
"[",
"\"color\"",
"]",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"<br>\"",
")",
"else",
":",
"if",
"hasattr",
"(",
"img",
",",
"\"columns\"",
")",
"and",
"hasattr",
"(",
"img",
".",
"columns",
",",
"\"__len__\"",
")",
":",
"if",
"x",
"is",
"None",
":",
"x",
"=",
"img",
".",
"columns",
"if",
"labels",
".",
"get",
"(",
"\"x\"",
",",
"None",
")",
"is",
"None",
"and",
"hasattr",
"(",
"img",
".",
"columns",
",",
"\"name\"",
")",
":",
"labels",
"[",
"\"x\"",
"]",
"=",
"img",
".",
"columns",
".",
"name",
"or",
"\"\"",
"if",
"hasattr",
"(",
"img",
",",
"\"index\"",
")",
"and",
"hasattr",
"(",
"img",
".",
"index",
",",
"\"__len__\"",
")",
":",
"if",
"y",
"is",
"None",
":",
"y",
"=",
"img",
".",
"index",
"if",
"labels",
".",
"get",
"(",
"\"y\"",
",",
"None",
")",
"is",
"None",
"and",
"hasattr",
"(",
"img",
".",
"index",
",",
"\"name\"",
")",
":",
"labels",
"[",
"\"y\"",
"]",
"=",
"img",
".",
"index",
".",
"name",
"or",
"\"\"",
"if",
"labels",
".",
"get",
"(",
"\"x\"",
",",
"None",
")",
"is",
"None",
":",
"labels",
"[",
"\"x\"",
"]",
"=",
"\"\"",
"if",
"labels",
".",
"get",
"(",
"\"y\"",
",",
"None",
")",
"is",
"None",
":",
"labels",
"[",
"\"y\"",
"]",
"=",
"\"\"",
"if",
"labels",
".",
"get",
"(",
"\"color\"",
",",
"None",
")",
"is",
"None",
":",
"labels",
"[",
"\"color\"",
"]",
"=",
"\"\"",
"if",
"aspect",
"is",
"None",
":",
"aspect",
"=",
"\"equal\"",
"img",
"=",
"np",
".",
"asanyarray",
"(",
"img",
")",
"# Cast bools to uint8 (also one byte)",
"if",
"img",
".",
"dtype",
"==",
"np",
".",
"bool",
":",
"img",
"=",
"255",
"*",
"img",
".",
"astype",
"(",
"np",
".",
"uint8",
")",
"# For 2d data, use Heatmap trace",
"if",
"img",
".",
"ndim",
"==",
"2",
":",
"if",
"y",
"is",
"not",
"None",
"and",
"img",
".",
"shape",
"[",
"0",
"]",
"!=",
"len",
"(",
"y",
")",
":",
"raise",
"ValueError",
"(",
"\"The length of the y vector must match the length of the first \"",
"+",
"\"dimension of the img matrix.\"",
")",
"if",
"x",
"is",
"not",
"None",
"and",
"img",
".",
"shape",
"[",
"1",
"]",
"!=",
"len",
"(",
"x",
")",
":",
"raise",
"ValueError",
"(",
"\"The length of the x vector must match the length of the second \"",
"+",
"\"dimension of the img matrix.\"",
")",
"trace",
"=",
"go",
".",
"Heatmap",
"(",
"x",
"=",
"x",
",",
"y",
"=",
"y",
",",
"z",
"=",
"img",
",",
"coloraxis",
"=",
"\"coloraxis1\"",
")",
"autorange",
"=",
"True",
"if",
"origin",
"==",
"\"lower\"",
"else",
"\"reversed\"",
"layout",
"=",
"dict",
"(",
"yaxis",
"=",
"dict",
"(",
"autorange",
"=",
"autorange",
")",
")",
"if",
"aspect",
"==",
"\"equal\"",
":",
"layout",
"[",
"\"xaxis\"",
"]",
"=",
"dict",
"(",
"scaleanchor",
"=",
"\"y\"",
",",
"constrain",
"=",
"\"domain\"",
")",
"layout",
"[",
"\"yaxis\"",
"]",
"[",
"\"constrain\"",
"]",
"=",
"\"domain\"",
"colorscale_validator",
"=",
"ColorscaleValidator",
"(",
"\"colorscale\"",
",",
"\"imshow\"",
")",
"if",
"zmin",
"is",
"not",
"None",
"and",
"zmax",
"is",
"None",
":",
"zmax",
"=",
"img",
".",
"max",
"(",
")",
"if",
"zmax",
"is",
"not",
"None",
"and",
"zmin",
"is",
"None",
":",
"zmin",
"=",
"img",
".",
"min",
"(",
")",
"range_color",
"=",
"range_color",
"or",
"[",
"zmin",
",",
"zmax",
"]",
"layout",
"[",
"\"coloraxis1\"",
"]",
"=",
"dict",
"(",
"colorscale",
"=",
"colorscale_validator",
".",
"validate_coerce",
"(",
"args",
"[",
"\"color_continuous_scale\"",
"]",
")",
",",
"cmid",
"=",
"color_continuous_midpoint",
",",
"cmin",
"=",
"range_color",
"[",
"0",
"]",
",",
"cmax",
"=",
"range_color",
"[",
"1",
"]",
",",
")",
"if",
"labels",
"[",
"\"color\"",
"]",
":",
"layout",
"[",
"\"coloraxis1\"",
"]",
"[",
"\"colorbar\"",
"]",
"=",
"dict",
"(",
"title_text",
"=",
"labels",
"[",
"\"color\"",
"]",
")",
"# For 2D+RGB data, use Image trace",
"elif",
"img",
".",
"ndim",
"==",
"3",
"and",
"img",
".",
"shape",
"[",
"-",
"1",
"]",
"in",
"[",
"3",
",",
"4",
"]",
":",
"if",
"zmax",
"is",
"None",
"and",
"img",
".",
"dtype",
"is",
"not",
"np",
".",
"uint8",
":",
"zmax",
"=",
"_infer_zmax_from_type",
"(",
"img",
")",
"zmin",
",",
"zmax",
"=",
"_vectorize_zvalue",
"(",
"zmin",
")",
",",
"_vectorize_zvalue",
"(",
"zmax",
")",
"trace",
"=",
"go",
".",
"Image",
"(",
"z",
"=",
"img",
",",
"zmin",
"=",
"zmin",
",",
"zmax",
"=",
"zmax",
")",
"layout",
"=",
"{",
"}",
"if",
"origin",
"==",
"\"lower\"",
":",
"layout",
"[",
"\"yaxis\"",
"]",
"=",
"dict",
"(",
"autorange",
"=",
"True",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"px.imshow only accepts 2D single-channel, RGB or RGBA images. \"",
"\"An image of shape %s was provided\"",
"%",
"str",
"(",
"img",
".",
"shape",
")",
")",
"layout_patch",
"=",
"dict",
"(",
")",
"for",
"attr_name",
"in",
"[",
"\"height\"",
",",
"\"width\"",
"]",
":",
"if",
"args",
"[",
"attr_name",
"]",
":",
"layout_patch",
"[",
"attr_name",
"]",
"=",
"args",
"[",
"attr_name",
"]",
"if",
"args",
"[",
"\"title\"",
"]",
":",
"layout_patch",
"[",
"\"title_text\"",
"]",
"=",
"args",
"[",
"\"title\"",
"]",
"elif",
"args",
"[",
"\"template\"",
"]",
".",
"layout",
".",
"margin",
".",
"t",
"is",
"None",
":",
"layout_patch",
"[",
"\"margin\"",
"]",
"=",
"{",
"\"t\"",
":",
"60",
"}",
"fig",
"=",
"go",
".",
"Figure",
"(",
"data",
"=",
"trace",
",",
"layout",
"=",
"layout",
")",
"fig",
".",
"update_layout",
"(",
"layout_patch",
")",
"fig",
".",
"update_traces",
"(",
"hovertemplate",
"=",
"\"%s: %%{x}<br>%s: %%{y}<br>%s: %%{z}<extra></extra>\"",
"%",
"(",
"labels",
"[",
"\"x\"",
"]",
"or",
"\"x\"",
",",
"labels",
"[",
"\"y\"",
"]",
"or",
"\"y\"",
",",
"labels",
"[",
"\"color\"",
"]",
"or",
"\"color\"",
",",
")",
")",
"if",
"labels",
"[",
"\"x\"",
"]",
":",
"fig",
".",
"update_xaxes",
"(",
"title_text",
"=",
"labels",
"[",
"\"x\"",
"]",
")",
"if",
"labels",
"[",
"\"y\"",
"]",
":",
"fig",
".",
"update_yaxes",
"(",
"title_text",
"=",
"labels",
"[",
"\"y\"",
"]",
")",
"fig",
".",
"update_layout",
"(",
"template",
"=",
"args",
"[",
"\"template\"",
"]",
",",
"overwrite",
"=",
"True",
")",
"return",
"fig"
] | [
65,
0
] | [
293,
14
] | python | en | ['en', 'error', 'th'] | False |
TestInjector.test_settings_init | (self) | Test settings initialization. | Test settings initialization. | def test_settings_init(self):
"""Test settings initialization."""
for key in self.test_settings:
assert key in self.test_instance.settings
assert self.test_instance.settings[key] == self.test_settings[key] | [
"def",
"test_settings_init",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"test_settings",
":",
"assert",
"key",
"in",
"self",
".",
"test_instance",
".",
"settings",
"assert",
"self",
".",
"test_instance",
".",
"settings",
"[",
"key",
"]",
"==",
"self",
".",
"test_settings",
"[",
"key",
"]"
] | [
36,
4
] | [
40,
78
] | python | en | ['en', 'fy', 'en'] | True |
TestInjector.test_inject_simple | (self) | Test a basic injection. | Test a basic injection. | async def test_inject_simple(self):
"""Test a basic injection."""
assert (await self.test_instance.inject(str, required=False)) is None
with self.assertRaises(InjectorError):
await self.test_instance.inject(str)
with self.assertRaises(ValueError):
await self.test_instance.bind_instance(str, None)
self.test_instance.bind_instance(str, self.test_value)
assert (await self.test_instance.inject(str)) is self.test_value | [
"async",
"def",
"test_inject_simple",
"(",
"self",
")",
":",
"assert",
"(",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
",",
"required",
"=",
"False",
")",
")",
"is",
"None",
"with",
"self",
".",
"assertRaises",
"(",
"InjectorError",
")",
":",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
")",
"with",
"self",
".",
"assertRaises",
"(",
"ValueError",
")",
":",
"await",
"self",
".",
"test_instance",
".",
"bind_instance",
"(",
"str",
",",
"None",
")",
"self",
".",
"test_instance",
".",
"bind_instance",
"(",
"str",
",",
"self",
".",
"test_value",
")",
"assert",
"(",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
")",
")",
"is",
"self",
".",
"test_value"
] | [
42,
4
] | [
50,
72
] | python | en | ['sl', 'en', 'en'] | True |
TestInjector.test_inject_provider | (self) | Test a provider injection. | Test a provider injection. | async def test_inject_provider(self):
"""Test a provider injection."""
mock_provider = MockProvider(self.test_value)
self.test_instance.bind_provider(str, mock_provider)
assert self.test_instance.get_provider(str) is mock_provider
override_settings = {self.test_key: "NEWVAL"}
assert (
await self.test_instance.inject(str, override_settings)
) is self.test_value
assert mock_provider.settings[self.test_key] == override_settings[self.test_key]
assert mock_provider.injector is self.test_instance | [
"async",
"def",
"test_inject_provider",
"(",
"self",
")",
":",
"mock_provider",
"=",
"MockProvider",
"(",
"self",
".",
"test_value",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"str",
",",
"mock_provider",
")",
"assert",
"self",
".",
"test_instance",
".",
"get_provider",
"(",
"str",
")",
"is",
"mock_provider",
"override_settings",
"=",
"{",
"self",
".",
"test_key",
":",
"\"NEWVAL\"",
"}",
"assert",
"(",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
",",
"override_settings",
")",
")",
"is",
"self",
".",
"test_value",
"assert",
"mock_provider",
".",
"settings",
"[",
"self",
".",
"test_key",
"]",
"==",
"override_settings",
"[",
"self",
".",
"test_key",
"]",
"assert",
"mock_provider",
".",
"injector",
"is",
"self",
".",
"test_instance"
] | [
52,
4
] | [
62,
59
] | python | en | ['hr', 'en', 'en'] | True |
TestInjector.test_bad_provider | (self) | Test empty and invalid provider results. | Test empty and invalid provider results. | async def test_bad_provider(self):
"""Test empty and invalid provider results."""
self.test_instance.bind_provider(str, MockProvider(None))
with self.assertRaises(InjectorError):
await self.test_instance.inject(str)
await self.test_instance.inject(str, required=False)
self.test_instance.bind_provider(str, MockProvider(1))
self.test_instance.clear_binding(str)
assert self.test_instance.get_provider(str) is None
with self.assertRaises(InjectorError):
await self.test_instance.inject(str) | [
"async",
"def",
"test_bad_provider",
"(",
"self",
")",
":",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"str",
",",
"MockProvider",
"(",
"None",
")",
")",
"with",
"self",
".",
"assertRaises",
"(",
"InjectorError",
")",
":",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
")",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
",",
"required",
"=",
"False",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"str",
",",
"MockProvider",
"(",
"1",
")",
")",
"self",
".",
"test_instance",
".",
"clear_binding",
"(",
"str",
")",
"assert",
"self",
".",
"test_instance",
".",
"get_provider",
"(",
"str",
")",
"is",
"None",
"with",
"self",
".",
"assertRaises",
"(",
"InjectorError",
")",
":",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"str",
")"
] | [
64,
4
] | [
74,
48
] | python | en | ['en', 'en', 'en'] | True |
TestInjector.test_inject_class | (self) | Test a provider class injection. | Test a provider class injection. | async def test_inject_class(self):
"""Test a provider class injection."""
provider = ClassProvider(MockInstance, self.test_value, async_init="open")
self.test_instance.bind_provider(MockInstance, provider)
assert self.test_instance.get_provider(MockInstance) is provider
instance = await self.test_instance.inject(MockInstance)
assert isinstance(instance, MockInstance)
assert instance.value is self.test_value
assert instance.opened | [
"async",
"def",
"test_inject_class",
"(",
"self",
")",
":",
"provider",
"=",
"ClassProvider",
"(",
"MockInstance",
",",
"self",
".",
"test_value",
",",
"async_init",
"=",
"\"open\"",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"MockInstance",
",",
"provider",
")",
"assert",
"self",
".",
"test_instance",
".",
"get_provider",
"(",
"MockInstance",
")",
"is",
"provider",
"instance",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"MockInstance",
")",
"assert",
"isinstance",
"(",
"instance",
",",
"MockInstance",
")",
"assert",
"instance",
".",
"value",
"is",
"self",
".",
"test_value",
"assert",
"instance",
".",
"opened"
] | [
76,
4
] | [
84,
30
] | python | en | ['hr', 'en', 'en'] | True |
TestInjector.test_inject_class_name | (self) | Test a provider class injection with a named class. | Test a provider class injection with a named class. | async def test_inject_class_name(self):
"""Test a provider class injection with a named class."""
provider = ClassProvider("aries_cloudagent.config.settings.Settings")
self.test_instance.bind_provider(BaseSettings, provider)
instance = await self.test_instance.inject(BaseSettings)
assert (
isinstance(instance, BaseSettings)
and instance.__class__.__name__ == "Settings"
) | [
"async",
"def",
"test_inject_class_name",
"(",
"self",
")",
":",
"provider",
"=",
"ClassProvider",
"(",
"\"aries_cloudagent.config.settings.Settings\"",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"BaseSettings",
",",
"provider",
")",
"instance",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"BaseSettings",
")",
"assert",
"(",
"isinstance",
"(",
"instance",
",",
"BaseSettings",
")",
"and",
"instance",
".",
"__class__",
".",
"__name__",
"==",
"\"Settings\"",
")"
] | [
86,
4
] | [
94,
9
] | python | en | ['en', 'en', 'en'] | True |
TestInjector.test_inject_class_dependency | (self) | Test a provider class injection with a dependency. | Test a provider class injection with a dependency. | async def test_inject_class_dependency(self):
"""Test a provider class injection with a dependency."""
test_str = "TEST"
test_int = 1
self.test_instance.bind_instance(str, test_str)
self.test_instance.bind_instance(int, test_int)
provider = ClassProvider(
MockInstance, ClassProvider.Inject(str), param=ClassProvider.Inject(int)
)
self.test_instance.bind_provider(object, provider)
instance = await self.test_instance.inject(object)
assert instance.value is test_str
assert instance.kwargs["param"] is test_int | [
"async",
"def",
"test_inject_class_dependency",
"(",
"self",
")",
":",
"test_str",
"=",
"\"TEST\"",
"test_int",
"=",
"1",
"self",
".",
"test_instance",
".",
"bind_instance",
"(",
"str",
",",
"test_str",
")",
"self",
".",
"test_instance",
".",
"bind_instance",
"(",
"int",
",",
"test_int",
")",
"provider",
"=",
"ClassProvider",
"(",
"MockInstance",
",",
"ClassProvider",
".",
"Inject",
"(",
"str",
")",
",",
"param",
"=",
"ClassProvider",
".",
"Inject",
"(",
"int",
")",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"object",
",",
"provider",
")",
"instance",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"object",
")",
"assert",
"instance",
".",
"value",
"is",
"test_str",
"assert",
"instance",
".",
"kwargs",
"[",
"\"param\"",
"]",
"is",
"test_int"
] | [
96,
4
] | [
108,
51
] | python | en | ['en', 'en', 'en'] | True |
TestInjector.test_inject_cached | (self) | Test a provider class injection. | Test a provider class injection. | async def test_inject_cached(self):
"""Test a provider class injection."""
with self.assertRaises(ValueError):
CachedProvider(None)
provider = ClassProvider(MockInstance, self.test_value, async_init="open")
cached = CachedProvider(provider)
self.test_instance.bind_provider(MockInstance, cached)
assert self.test_instance.get_provider(MockInstance) is cached
i1 = await self.test_instance.inject(MockInstance)
i2 = await self.test_instance.inject(MockInstance)
assert i1 is i2
provider = ClassProvider(MockInstance, self.test_value, async_init="open")
self.test_instance.bind_provider(MockInstance, provider, cache=True)
i1 = await self.test_instance.inject(MockInstance)
i2 = await self.test_instance.inject(MockInstance)
assert i1 is i2 | [
"async",
"def",
"test_inject_cached",
"(",
"self",
")",
":",
"with",
"self",
".",
"assertRaises",
"(",
"ValueError",
")",
":",
"CachedProvider",
"(",
"None",
")",
"provider",
"=",
"ClassProvider",
"(",
"MockInstance",
",",
"self",
".",
"test_value",
",",
"async_init",
"=",
"\"open\"",
")",
"cached",
"=",
"CachedProvider",
"(",
"provider",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"MockInstance",
",",
"cached",
")",
"assert",
"self",
".",
"test_instance",
".",
"get_provider",
"(",
"MockInstance",
")",
"is",
"cached",
"i1",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"MockInstance",
")",
"i2",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"MockInstance",
")",
"assert",
"i1",
"is",
"i2",
"provider",
"=",
"ClassProvider",
"(",
"MockInstance",
",",
"self",
".",
"test_value",
",",
"async_init",
"=",
"\"open\"",
")",
"self",
".",
"test_instance",
".",
"bind_provider",
"(",
"MockInstance",
",",
"provider",
",",
"cache",
"=",
"True",
")",
"i1",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"MockInstance",
")",
"i2",
"=",
"await",
"self",
".",
"test_instance",
".",
"inject",
"(",
"MockInstance",
")",
"assert",
"i1",
"is",
"i2"
] | [
110,
4
] | [
126,
23
] | python | en | ['hr', 'en', 'en'] | True |
set_prefs | (prefs) | This function is called before opening the project | This function is called before opening the project | def set_prefs(prefs):
"""This function is called before opening the project"""
# Specify which files and folders to ignore in the project.
# Changes to ignored resources are not added to the history and
# VCSs. Also they are not returned in `Project.get_files()`.
# Note that ``?`` and ``*`` match all characters but slashes.
# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
# '.svn': matches 'pkg/.svn' and all of its children
# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
'.hg', '.svn', '_svn', '.git', '.tox']
# Specifies which files should be considered python files. It is
# useful when you have scripts inside your project. Only files
# ending with ``.py`` are considered to be python files by
# default.
# prefs['python_files'] = ['*.py']
# Custom source folders: By default rope searches the project
# for finding source folders (folders that should be searched
# for finding modules). You can add paths to that list. Note
# that rope guesses project source folders correctly most of the
# time; use this if you have any problems.
# The folders should be relative to project root and use '/' for
# separating folders regardless of the platform rope is running on.
# 'src/my_source_folder' for instance.
# prefs.add('source_folders', 'src')
# You can extend python path for looking up modules
# prefs.add('python_path', '~/python/')
# Should rope save object information or not.
prefs['save_objectdb'] = True
prefs['compress_objectdb'] = False
# If `True`, rope analyzes each module when it is being saved.
prefs['automatic_soa'] = True
# The depth of calls to follow in static object analysis
prefs['soa_followed_calls'] = 0
# If `False` when running modules or unit tests "dynamic object
# analysis" is turned off. This makes them much faster.
prefs['perform_doa'] = True
# Rope can check the validity of its object DB when running.
prefs['validate_objectdb'] = True
# How many undos to hold?
prefs['max_history_items'] = 32
# Shows whether to save history across sessions.
prefs['save_history'] = True
prefs['compress_history'] = False
# Set the number spaces used for indenting. According to
# :PEP:`8`, it is best to use 4 spaces. Since most of rope's
# unit-tests use 4 spaces it is more reliable, too.
prefs['indent_size'] = 4
# Builtin and c-extension modules that are allowed to be imported
# and inspected by rope.
prefs['extension_modules'] = []
# Add all standard c-extensions to extension_modules list.
prefs['import_dynload_stdmods'] = True
# If `True` modules with syntax errors are considered to be empty.
# The default value is `False`; When `False` syntax errors raise
# `rope.base.exceptions.ModuleSyntaxError` exception.
prefs['ignore_syntax_errors'] = False
# If `True`, rope ignores unresolvable imports. Otherwise, they
# appear in the importing namespace.
prefs['ignore_bad_imports'] = False
# If `True`, rope will insert new module imports as
# `from <package> import <module>` by default.
prefs['prefer_module_from_imports'] = False
# If `True`, rope will transform a comma list of imports into
# multiple separate import statements when organizing
# imports.
prefs['split_imports'] = False
# If `True`, rope will remove all top-level import statements and
# reinsert them at the top of the module when making changes.
prefs['pull_imports_to_top'] = True
# If `True`, rope will sort imports alphabetically by module name instead
# of alphabetically by import statement, with from imports after normal
# imports.
prefs['sort_imports_alphabetically'] = False
# Location of implementation of
# rope.base.oi.type_hinting.interfaces.ITypeHintingFactory In general
# case, you don't have to change this value, unless you're an rope expert.
# Change this value to inject you own implementations of interfaces
# listed in module rope.base.oi.type_hinting.providers.interfaces
# For example, you can add you own providers for Django Models, or disable
# the search type-hinting in a class hierarchy, etc.
prefs['type_hinting_factory'] = (
'rope.base.oi.type_hinting.factory.default_type_hinting_factory') | [
"def",
"set_prefs",
"(",
"prefs",
")",
":",
"# Specify which files and folders to ignore in the project.",
"# Changes to ignored resources are not added to the history and",
"# VCSs. Also they are not returned in `Project.get_files()`.",
"# Note that ``?`` and ``*`` match all characters but slashes.",
"# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'",
"# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'",
"# '.svn': matches 'pkg/.svn' and all of its children",
"# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'",
"# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'",
"prefs",
"[",
"'ignored_resources'",
"]",
"=",
"[",
"'*.pyc'",
",",
"'*~'",
",",
"'.ropeproject'",
",",
"'.hg'",
",",
"'.svn'",
",",
"'_svn'",
",",
"'.git'",
",",
"'.tox'",
"]",
"# Specifies which files should be considered python files. It is",
"# useful when you have scripts inside your project. Only files",
"# ending with ``.py`` are considered to be python files by",
"# default.",
"# prefs['python_files'] = ['*.py']",
"# Custom source folders: By default rope searches the project",
"# for finding source folders (folders that should be searched",
"# for finding modules). You can add paths to that list. Note",
"# that rope guesses project source folders correctly most of the",
"# time; use this if you have any problems.",
"# The folders should be relative to project root and use '/' for",
"# separating folders regardless of the platform rope is running on.",
"# 'src/my_source_folder' for instance.",
"# prefs.add('source_folders', 'src')",
"# You can extend python path for looking up modules",
"# prefs.add('python_path', '~/python/')",
"# Should rope save object information or not.",
"prefs",
"[",
"'save_objectdb'",
"]",
"=",
"True",
"prefs",
"[",
"'compress_objectdb'",
"]",
"=",
"False",
"# If `True`, rope analyzes each module when it is being saved.",
"prefs",
"[",
"'automatic_soa'",
"]",
"=",
"True",
"# The depth of calls to follow in static object analysis",
"prefs",
"[",
"'soa_followed_calls'",
"]",
"=",
"0",
"# If `False` when running modules or unit tests \"dynamic object",
"# analysis\" is turned off. This makes them much faster.",
"prefs",
"[",
"'perform_doa'",
"]",
"=",
"True",
"# Rope can check the validity of its object DB when running.",
"prefs",
"[",
"'validate_objectdb'",
"]",
"=",
"True",
"# How many undos to hold?",
"prefs",
"[",
"'max_history_items'",
"]",
"=",
"32",
"# Shows whether to save history across sessions.",
"prefs",
"[",
"'save_history'",
"]",
"=",
"True",
"prefs",
"[",
"'compress_history'",
"]",
"=",
"False",
"# Set the number spaces used for indenting. According to",
"# :PEP:`8`, it is best to use 4 spaces. Since most of rope's",
"# unit-tests use 4 spaces it is more reliable, too.",
"prefs",
"[",
"'indent_size'",
"]",
"=",
"4",
"# Builtin and c-extension modules that are allowed to be imported",
"# and inspected by rope.",
"prefs",
"[",
"'extension_modules'",
"]",
"=",
"[",
"]",
"# Add all standard c-extensions to extension_modules list.",
"prefs",
"[",
"'import_dynload_stdmods'",
"]",
"=",
"True",
"# If `True` modules with syntax errors are considered to be empty.",
"# The default value is `False`; When `False` syntax errors raise",
"# `rope.base.exceptions.ModuleSyntaxError` exception.",
"prefs",
"[",
"'ignore_syntax_errors'",
"]",
"=",
"False",
"# If `True`, rope ignores unresolvable imports. Otherwise, they",
"# appear in the importing namespace.",
"prefs",
"[",
"'ignore_bad_imports'",
"]",
"=",
"False",
"# If `True`, rope will insert new module imports as",
"# `from <package> import <module>` by default.",
"prefs",
"[",
"'prefer_module_from_imports'",
"]",
"=",
"False",
"# If `True`, rope will transform a comma list of imports into",
"# multiple separate import statements when organizing",
"# imports.",
"prefs",
"[",
"'split_imports'",
"]",
"=",
"False",
"# If `True`, rope will remove all top-level import statements and",
"# reinsert them at the top of the module when making changes.",
"prefs",
"[",
"'pull_imports_to_top'",
"]",
"=",
"True",
"# If `True`, rope will sort imports alphabetically by module name instead",
"# of alphabetically by import statement, with from imports after normal",
"# imports.",
"prefs",
"[",
"'sort_imports_alphabetically'",
"]",
"=",
"False",
"# Location of implementation of",
"# rope.base.oi.type_hinting.interfaces.ITypeHintingFactory In general",
"# case, you don't have to change this value, unless you're an rope expert.",
"# Change this value to inject you own implementations of interfaces",
"# listed in module rope.base.oi.type_hinting.providers.interfaces",
"# For example, you can add you own providers for Django Models, or disable",
"# the search type-hinting in a class hierarchy, etc.",
"prefs",
"[",
"'type_hinting_factory'",
"]",
"=",
"(",
"'rope.base.oi.type_hinting.factory.default_type_hinting_factory'",
")"
] | [
4,
0
] | [
108,
73
] | python | en | ['en', 'en', 'en'] | True |
project_opened | (project) | This function is called after opening the project | This function is called after opening the project | def project_opened(project):
"""This function is called after opening the project""" | [
"def",
"project_opened",
"(",
"project",
")",
":"
] | [
111,
0
] | [
112,
59
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.height | (self) | torch.Tensor: A vector with height of each box. | torch.Tensor: A vector with height of each box. | def height(self):
"""torch.Tensor: A vector with height of each box."""
return self.tensor[:, 4] | [
"def",
"height",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
"4",
"]"
] | [
73,
4
] | [
75,
32
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.top_height | (self) | torch.Tensor: A vector with the top height of each box. | torch.Tensor: A vector with the top height of each box. | def top_height(self):
"""torch.Tensor: A vector with the top height of each box."""
# the positive direction is down rather than up
return self.bottom_height - self.height | [
"def",
"top_height",
"(",
"self",
")",
":",
"# the positive direction is down rather than up",
"return",
"self",
".",
"bottom_height",
"-",
"self",
".",
"height"
] | [
78,
4
] | [
81,
47
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.bottom_height | (self) | torch.Tensor: A vector with bottom's height of each box. | torch.Tensor: A vector with bottom's height of each box. | def bottom_height(self):
"""torch.Tensor: A vector with bottom's height of each box."""
return self.tensor[:, 1] | [
"def",
"bottom_height",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
"1",
"]"
] | [
84,
4
] | [
86,
32
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.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[:, [0, 2]] = bottom_center[:, [0, 2]]
gravity_center[:, 1] = bottom_center[:, 1] - self.tensor[:, 4] * 0.5
return gravity_center | [
"def",
"gravity_center",
"(",
"self",
")",
":",
"bottom_center",
"=",
"self",
".",
"bottom_center",
"gravity_center",
"=",
"torch",
".",
"zeros_like",
"(",
"bottom_center",
")",
"gravity_center",
"[",
":",
",",
"[",
"0",
",",
"2",
"]",
"]",
"=",
"bottom_center",
"[",
":",
",",
"[",
"0",
",",
"2",
"]",
"]",
"gravity_center",
"[",
":",
",",
"1",
"]",
"=",
"bottom_center",
"[",
":",
",",
"1",
"]",
"-",
"self",
".",
"tensor",
"[",
":",
",",
"4",
"]",
"*",
"0.5",
"return",
"gravity_center"
] | [
89,
4
] | [
95,
29
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.corners | (self) | torch.Tensor: Coordinates of corners of all the boxes in
shape (N, 8, 3).
Convert the boxes to in clockwise order, in the form of
(x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0)
.. code-block:: none
front z
/
/
(x0, y0, z1) + ----------- + (x1, y0, z1)
/| / |
/ | / |
(x0, y0, z0) + ----------- + + (x1, y1, z1)
| / . | /
| / oriign | /
(x0, y1, z0) + ----------- + -------> x right
| (x1, y1, z0)
|
v
down y
| 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 in clockwise order, in the form of
(x0y0z0, x0y0z1, x0y1z1, x0y1z0, x1y0z0, x1y0z1, x1y1z1, x1y1z0)
.. code-block:: none
front z
/
/
(x0, y0, z1) + ----------- + (x1, y0, z1)
/| / |
/ | / |
(x0, y0, z0) + ----------- + + (x1, y1, z1)
| / . | /
| / oriign | /
(x0, y1, z0) + ----------- + -------> x right
| (x1, y1, z0)
|
v
down y
"""
# 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, 1, 0.5]
corners_norm = corners_norm - dims.new_tensor([0.5, 1, 0.5])
corners = dims.view([-1, 1, 3]) * corners_norm.reshape([1, 8, 3])
# rotate around y axis
corners = rotation_3d_in_axis(corners, self.tensor[:, 6], axis=1)
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, 1, 0.5]",
"corners_norm",
"=",
"corners_norm",
"-",
"dims",
".",
"new_tensor",
"(",
"[",
"0.5",
",",
"1",
",",
"0.5",
"]",
")",
"corners",
"=",
"dims",
".",
"view",
"(",
"[",
"-",
"1",
",",
"1",
",",
"3",
"]",
")",
"*",
"corners_norm",
".",
"reshape",
"(",
"[",
"1",
",",
"8",
",",
"3",
"]",
")",
"# rotate around y axis",
"corners",
"=",
"rotation_3d_in_axis",
"(",
"corners",
",",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
",",
"axis",
"=",
"1",
")",
"corners",
"+=",
"self",
".",
"tensor",
"[",
":",
",",
":",
"3",
"]",
".",
"view",
"(",
"-",
"1",
",",
"1",
",",
"3",
")",
"return",
"corners"
] | [
98,
4
] | [
138,
22
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.bev | (self) | torch.Tensor: A n x 5 tensor of 2D BEV box of each box
with rotation in XYWHR format. | torch.Tensor: A n x 5 tensor of 2D BEV box of each box
with rotation in XYWHR format. | def bev(self):
"""torch.Tensor: A n x 5 tensor of 2D BEV box of each box
with rotation in XYWHR format."""
return self.tensor[:, [0, 2, 3, 5, 6]] | [
"def",
"bev",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
"[",
"0",
",",
"2",
",",
"3",
",",
"5",
",",
"6",
"]",
"]"
] | [
141,
4
] | [
144,
46
] | python | en | ['en', 'vi', 'en'] | True |
CameraInstance3DBoxes.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 XZWHR 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 XZWHR 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"
] | [
147,
4
] | [
165,
24
] | python | en | ['en', 'vi', 'en'] | True |
CameraInstance3DBoxes.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, 0, -rot_sin], [0, 1, 0],
[rot_sin, 0, rot_cos]])
self.tensor[:, :3] = self.tensor[:, :3] @ rot_mat_T
self.tensor[:, 6] += angle
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):
# 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",
",",
"0",
",",
"-",
"rot_sin",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
"]",
",",
"[",
"rot_sin",
",",
"0",
",",
"rot_cos",
"]",
"]",
")",
"self",
".",
"tensor",
"[",
":",
",",
":",
"3",
"]",
"=",
"self",
".",
"tensor",
"[",
":",
",",
":",
"3",
"]",
"@",
"rot_mat_T",
"self",
".",
"tensor",
"[",
":",
",",
"6",
"]",
"+=",
"angle",
"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",
")",
":",
"# clockwise",
"points",
".",
"rotate",
"(",
"-",
"angle",
")",
"else",
":",
"raise",
"ValueError",
"return",
"points",
",",
"rot_mat_T"
] | [
167,
4
] | [
201,
36
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.flip | (self, bev_direction='horizontal', points=None) | Flip the boxes in BEV along given BEV direction.
In CAM coordinates, it flips the x (horizontal) or z (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 CAM coordinates, it flips the x (horizontal) or z (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[:, 2::7] = -self.tensor[:, 2::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[:, 2] = -points[:, 2]
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",
"[",
":",
",",
"2",
":",
":",
"7",
"]",
"=",
"-",
"self",
".",
"tensor",
"[",
":",
",",
"2",
":",
":",
"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",
"[",
":",
",",
"2",
"]",
"=",
"-",
"points",
"[",
":",
",",
"2",
"]",
"elif",
"isinstance",
"(",
"points",
",",
"BasePoints",
")",
":",
"points",
".",
"flip",
"(",
"bev_direction",
")",
"return",
"points"
] | [
203,
4
] | [
235,
25
] | python | en | ['en', 'da', 'en'] | True |
CameraInstance3DBoxes.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, z_min, x_max, z_max).
Note:
The original implementation of SECOND checks whether boxes in
a range by checking whether the points are in a convex
polygon, we reduce the burden 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, z_min, x_max, z_max).
Note:
The original implementation of SECOND checks whether boxes in
a range by checking whether the points are in a convex
polygon, we reduce the burden 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[:, 2] > box_range[1])
& (self.tensor[:, 0] < box_range[2])
& (self.tensor[:, 2] < 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",
"[",
":",
",",
"2",
"]",
">",
"box_range",
"[",
"1",
"]",
")",
"&",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"0",
"]",
"<",
"box_range",
"[",
"2",
"]",
")",
"&",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"2",
"]",
"<",
"box_range",
"[",
"3",
"]",
")",
")",
"return",
"in_range_flags"
] | [
237,
4
] | [
257,
29
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.height_overlaps | (cls, boxes1, boxes2, mode='iou') | Calculate height overlaps of two boxes.
This function calculates the height overlaps between ``boxes1`` and
``boxes2``, where ``boxes1`` and ``boxes2`` should be in the same type.
Args:
boxes1 (:obj:`CameraInstance3DBoxes`): Boxes 1 contain N boxes.
boxes2 (:obj:`CameraInstance3DBoxes`): Boxes 2 contain M boxes.
mode (str, optional): Mode of iou calculation. Defaults to 'iou'.
Returns:
torch.Tensor: Calculated iou of boxes' heights.
| Calculate height overlaps of two boxes. | def height_overlaps(cls, boxes1, boxes2, mode='iou'):
"""Calculate height overlaps of two boxes.
This function calculates the height overlaps between ``boxes1`` and
``boxes2``, where ``boxes1`` and ``boxes2`` should be in the same type.
Args:
boxes1 (:obj:`CameraInstance3DBoxes`): Boxes 1 contain N boxes.
boxes2 (:obj:`CameraInstance3DBoxes`): Boxes 2 contain M boxes.
mode (str, optional): Mode of iou calculation. Defaults to 'iou'.
Returns:
torch.Tensor: Calculated iou of boxes' heights.
"""
assert isinstance(boxes1, CameraInstance3DBoxes)
assert isinstance(boxes2, CameraInstance3DBoxes)
boxes1_top_height = boxes1.top_height.view(-1, 1)
boxes1_bottom_height = boxes1.bottom_height.view(-1, 1)
boxes2_top_height = boxes2.top_height.view(1, -1)
boxes2_bottom_height = boxes2.bottom_height.view(1, -1)
# In camera coordinate system
# from up to down is the positive direction
heighest_of_bottom = torch.min(boxes1_bottom_height,
boxes2_bottom_height)
lowest_of_top = torch.max(boxes1_top_height, boxes2_top_height)
overlaps_h = torch.clamp(heighest_of_bottom - lowest_of_top, min=0)
return overlaps_h | [
"def",
"height_overlaps",
"(",
"cls",
",",
"boxes1",
",",
"boxes2",
",",
"mode",
"=",
"'iou'",
")",
":",
"assert",
"isinstance",
"(",
"boxes1",
",",
"CameraInstance3DBoxes",
")",
"assert",
"isinstance",
"(",
"boxes2",
",",
"CameraInstance3DBoxes",
")",
"boxes1_top_height",
"=",
"boxes1",
".",
"top_height",
".",
"view",
"(",
"-",
"1",
",",
"1",
")",
"boxes1_bottom_height",
"=",
"boxes1",
".",
"bottom_height",
".",
"view",
"(",
"-",
"1",
",",
"1",
")",
"boxes2_top_height",
"=",
"boxes2",
".",
"top_height",
".",
"view",
"(",
"1",
",",
"-",
"1",
")",
"boxes2_bottom_height",
"=",
"boxes2",
".",
"bottom_height",
".",
"view",
"(",
"1",
",",
"-",
"1",
")",
"# In camera coordinate system",
"# from up to down is the positive direction",
"heighest_of_bottom",
"=",
"torch",
".",
"min",
"(",
"boxes1_bottom_height",
",",
"boxes2_bottom_height",
")",
"lowest_of_top",
"=",
"torch",
".",
"max",
"(",
"boxes1_top_height",
",",
"boxes2_top_height",
")",
"overlaps_h",
"=",
"torch",
".",
"clamp",
"(",
"heighest_of_bottom",
"-",
"lowest_of_top",
",",
"min",
"=",
"0",
")",
"return",
"overlaps_h"
] | [
260,
4
] | [
288,
25
] | python | en | ['en', 'en', 'en'] | True |
CameraInstance3DBoxes.convert_to | (self, dst, rt_mat=None) | Convert self to ``dst`` mode.
Args:
dst (:obj:`BoxMode`): The target Box mode.
rt_mat (np.dnarray | 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:`BaseInstance3DBoxes`: \
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.dnarray | 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:`BaseInstance3DBoxes`: \
The converted box of the same type in the ``dst`` mode.
"""
from .box_3d_mode import Box3DMode
return Box3DMode.convert(
box=self, src=Box3DMode.CAM, 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",
".",
"CAM",
",",
"dst",
"=",
"dst",
",",
"rt_mat",
"=",
"rt_mat",
")"
] | [
290,
4
] | [
307,
64
] | python | en | ['en', 'en', 'en'] | True |
Hoverlabel.align | (self) |
Sets the horizontal alignment of the text content within hover
label box. Has an effect only if the hover label text spans
more two or more lines
The 'align' property is an enumeration that may be specified as:
- One of the following enumeration values:
['left', 'right', 'auto']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
|
Sets the horizontal alignment of the text content within hover
label box. Has an effect only if the hover label text spans
more two or more lines
The 'align' property is an enumeration that may be specified as:
- One of the following enumeration values:
['left', 'right', 'auto']
- A tuple, list, or one-dimensional numpy array of the above | def align(self):
"""
Sets the horizontal alignment of the text content within hover
label box. Has an effect only if the hover label text spans
more two or more lines
The 'align' property is an enumeration that may be specified as:
- One of the following enumeration values:
['left', 'right', 'auto']
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
Any|numpy.ndarray
"""
return self["align"] | [
"def",
"align",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"align\"",
"]"
] | [
25,
4
] | [
40,
28
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.alignsrc | (self) |
Sets the source reference on Chart Studio Cloud for align .
The 'alignsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for align .
The 'alignsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def alignsrc(self):
"""
Sets the source reference on Chart Studio Cloud for align .
The 'alignsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["alignsrc"] | [
"def",
"alignsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"alignsrc\"",
"]"
] | [
49,
4
] | [
60,
31
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bgcolor | (self) |
Sets the background color of the hover labels for this trace
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
|
Sets the background color of the hover labels for this trace
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above | def bgcolor(self):
"""
Sets the background color of the hover labels for this trace
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["bgcolor"] | [
"def",
"bgcolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bgcolor\"",
"]"
] | [
69,
4
] | [
120,
30
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bgcolorsrc | (self) |
Sets the source reference on Chart Studio Cloud for bgcolor .
The 'bgcolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for bgcolor .
The 'bgcolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def bgcolorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for bgcolor .
The 'bgcolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["bgcolorsrc"] | [
"def",
"bgcolorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bgcolorsrc\"",
"]"
] | [
129,
4
] | [
140,
33
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bordercolor | (self) |
Sets the border color of the hover labels for this trace.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
|
Sets the border color of the hover labels for this trace.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above | def bordercolor(self):
"""
Sets the border color of the hover labels for this trace.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["bordercolor"] | [
"def",
"bordercolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bordercolor\"",
"]"
] | [
149,
4
] | [
200,
34
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.bordercolorsrc | (self) |
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def bordercolorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for
bordercolor .
The 'bordercolorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["bordercolorsrc"] | [
"def",
"bordercolorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bordercolorsrc\"",
"]"
] | [
209,
4
] | [
221,
37
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.font | (self) |
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.funnel.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size .
Returns
-------
plotly.graph_objs.funnel.hoverlabel.Font
|
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.funnel.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size . | def font(self):
"""
Sets the font used in hover labels.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.funnel.hoverlabel.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
colorsrc
Sets the source reference on Chart Studio Cloud
for color .
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud
for family .
size
sizesrc
Sets the source reference on Chart Studio Cloud
for size .
Returns
-------
plotly.graph_objs.funnel.hoverlabel.Font
"""
return self["font"] | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
230,
4
] | [
277,
27
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.namelength | (self) |
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|numpy.ndarray
|
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above | def namelength(self):
"""
Sets the default length (in number of characters) of the trace
name in the hover labels for all traces. -1 shows the whole
name regardless of length. 0-3 shows the first 0-3 characters,
and an integer >3 will show the whole name if it is less than
that many characters, but if it is longer, will truncate to
`namelength - 3` characters and add an ellipsis.
The 'namelength' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
in the interval [-1, 9223372036854775807]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|numpy.ndarray
"""
return self["namelength"] | [
"def",
"namelength",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"namelength\"",
"]"
] | [
286,
4
] | [
304,
33
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.namelengthsrc | (self) |
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def namelengthsrc(self):
"""
Sets the source reference on Chart Studio Cloud for namelength
.
The 'namelengthsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["namelengthsrc"] | [
"def",
"namelengthsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"namelengthsrc\"",
"]"
] | [
313,
4
] | [
325,
36
] | python | en | ['en', 'error', 'th'] | False |
Hoverlabel.__init__ | (
self,
arg=None,
align=None,
alignsrc=None,
bgcolor=None,
bgcolorsrc=None,
bordercolor=None,
bordercolorsrc=None,
font=None,
namelength=None,
namelengthsrc=None,
**kwargs
) |
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.funnel.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength .
Returns
-------
Hoverlabel
|
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.funnel.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength . | def __init__(
self,
arg=None,
align=None,
alignsrc=None,
bgcolor=None,
bgcolorsrc=None,
bordercolor=None,
bordercolorsrc=None,
font=None,
namelength=None,
namelengthsrc=None,
**kwargs
):
"""
Construct a new Hoverlabel object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.funnel.Hoverlabel`
align
Sets the horizontal alignment of the text content
within hover label box. Has an effect only if the hover
label text spans more two or more lines
alignsrc
Sets the source reference on Chart Studio Cloud for
align .
bgcolor
Sets the background color of the hover labels for this
trace
bgcolorsrc
Sets the source reference on Chart Studio Cloud for
bgcolor .
bordercolor
Sets the border color of the hover labels for this
trace.
bordercolorsrc
Sets the source reference on Chart Studio Cloud for
bordercolor .
font
Sets the font used in hover labels.
namelength
Sets the default length (in number of characters) of
the trace name in the hover labels for all traces. -1
shows the whole name regardless of length. 0-3 shows
the first 0-3 characters, and an integer >3 will show
the whole name if it is less than that many characters,
but if it is longer, will truncate to `namelength - 3`
characters and add an ellipsis.
namelengthsrc
Sets the source reference on Chart Studio Cloud for
namelength .
Returns
-------
Hoverlabel
"""
super(Hoverlabel, self).__init__("hoverlabel")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.funnel.Hoverlabel
constructor must be a dict or
an instance of :class:`plotly.graph_objs.funnel.Hoverlabel`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("align", None)
_v = align if align is not None else _v
if _v is not None:
self["align"] = _v
_v = arg.pop("alignsrc", None)
_v = alignsrc if alignsrc is not None else _v
if _v is not None:
self["alignsrc"] = _v
_v = arg.pop("bgcolor", None)
_v = bgcolor if bgcolor is not None else _v
if _v is not None:
self["bgcolor"] = _v
_v = arg.pop("bgcolorsrc", None)
_v = bgcolorsrc if bgcolorsrc is not None else _v
if _v is not None:
self["bgcolorsrc"] = _v
_v = arg.pop("bordercolor", None)
_v = bordercolor if bordercolor is not None else _v
if _v is not None:
self["bordercolor"] = _v
_v = arg.pop("bordercolorsrc", None)
_v = bordercolorsrc if bordercolorsrc is not None else _v
if _v is not None:
self["bordercolorsrc"] = _v
_v = arg.pop("font", None)
_v = font if font is not None else _v
if _v is not None:
self["font"] = _v
_v = arg.pop("namelength", None)
_v = namelength if namelength is not None else _v
if _v is not None:
self["namelength"] = _v
_v = arg.pop("namelengthsrc", None)
_v = namelengthsrc if namelengthsrc is not None else _v
if _v is not None:
self["namelengthsrc"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"align",
"=",
"None",
",",
"alignsrc",
"=",
"None",
",",
"bgcolor",
"=",
"None",
",",
"bgcolorsrc",
"=",
"None",
",",
"bordercolor",
"=",
"None",
",",
"bordercolorsrc",
"=",
"None",
",",
"font",
"=",
"None",
",",
"namelength",
"=",
"None",
",",
"namelengthsrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Hoverlabel",
",",
"self",
")",
".",
"__init__",
"(",
"\"hoverlabel\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.funnel.Hoverlabel \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.funnel.Hoverlabel`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"align\"",
",",
"None",
")",
"_v",
"=",
"align",
"if",
"align",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"align\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"alignsrc\"",
",",
"None",
")",
"_v",
"=",
"alignsrc",
"if",
"alignsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"alignsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bgcolor\"",
",",
"None",
")",
"_v",
"=",
"bgcolor",
"if",
"bgcolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bgcolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bgcolorsrc\"",
",",
"None",
")",
"_v",
"=",
"bgcolorsrc",
"if",
"bgcolorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bgcolorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bordercolor\"",
",",
"None",
")",
"_v",
"=",
"bordercolor",
"if",
"bordercolor",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bordercolor\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"bordercolorsrc\"",
",",
"None",
")",
"_v",
"=",
"bordercolorsrc",
"if",
"bordercolorsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"bordercolorsrc\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"font\"",
",",
"None",
")",
"_v",
"=",
"font",
"if",
"font",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"font\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"namelength\"",
",",
"None",
")",
"_v",
"=",
"namelength",
"if",
"namelength",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"namelength\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"namelengthsrc\"",
",",
"None",
")",
"_v",
"=",
"namelengthsrc",
"if",
"namelengthsrc",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"namelengthsrc\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
370,
4
] | [
502,
34
] | python | en | ['en', 'error', 'th'] | False |
_case_sensitive_replace | (string, old, new) |
Replace text, retaining exact case.
Args:
string (str): String in which to perform replacement.
old (str): Word or substring to replace.
new (str): What to replace `old` with.
Returns:
repl_string (str): Version of string where instances of
`old` has been replaced with `new`, retaining case.
|
Replace text, retaining exact case. | def _case_sensitive_replace(string, old, new):
"""
Replace text, retaining exact case.
Args:
string (str): String in which to perform replacement.
old (str): Word or substring to replace.
new (str): What to replace `old` with.
Returns:
repl_string (str): Version of string where instances of
`old` has been replaced with `new`, retaining case.
"""
def repl(match):
current = match.group()
# treat multi-word sentences word-by-word
old_words = current.split(" ")
new_words = new.split(" ")
out = []
for old_word, new_word in zip(old_words, new_words):
result = []
all_upper = True
for ind, chr in enumerate(old_word):
if ind >= len(new):
break
if chr.isupper():
result.append(new_word[ind].upper())
else:
result.append(new_word[ind].lower())
all_upper = False
# special cases - keep remaing case)
if new_word.lower() in CASE_WORD_EXCEPTIONS:
result.append(new_word[ind + 1:])
# append any remaining characters from new
elif all_upper:
result.append(new_word[ind + 1:].upper())
else:
result.append(new_word[ind + 1:].lower())
out.append("".join(result))
# if we have more new words than old ones, just add them verbatim
out.extend([new_word for ind, new_word in enumerate(new_words) if ind >= len(old_words)])
return " ".join(out)
if string is None:
return None
regex = re.compile(re.escape(old), re.I)
return regex.sub(repl, string) | [
"def",
"_case_sensitive_replace",
"(",
"string",
",",
"old",
",",
"new",
")",
":",
"def",
"repl",
"(",
"match",
")",
":",
"current",
"=",
"match",
".",
"group",
"(",
")",
"# treat multi-word sentences word-by-word",
"old_words",
"=",
"current",
".",
"split",
"(",
"\" \"",
")",
"new_words",
"=",
"new",
".",
"split",
"(",
"\" \"",
")",
"out",
"=",
"[",
"]",
"for",
"old_word",
",",
"new_word",
"in",
"zip",
"(",
"old_words",
",",
"new_words",
")",
":",
"result",
"=",
"[",
"]",
"all_upper",
"=",
"True",
"for",
"ind",
",",
"chr",
"in",
"enumerate",
"(",
"old_word",
")",
":",
"if",
"ind",
">=",
"len",
"(",
"new",
")",
":",
"break",
"if",
"chr",
".",
"isupper",
"(",
")",
":",
"result",
".",
"append",
"(",
"new_word",
"[",
"ind",
"]",
".",
"upper",
"(",
")",
")",
"else",
":",
"result",
".",
"append",
"(",
"new_word",
"[",
"ind",
"]",
".",
"lower",
"(",
")",
")",
"all_upper",
"=",
"False",
"# special cases - keep remaing case)",
"if",
"new_word",
".",
"lower",
"(",
")",
"in",
"CASE_WORD_EXCEPTIONS",
":",
"result",
".",
"append",
"(",
"new_word",
"[",
"ind",
"+",
"1",
":",
"]",
")",
"# append any remaining characters from new",
"elif",
"all_upper",
":",
"result",
".",
"append",
"(",
"new_word",
"[",
"ind",
"+",
"1",
":",
"]",
".",
"upper",
"(",
")",
")",
"else",
":",
"result",
".",
"append",
"(",
"new_word",
"[",
"ind",
"+",
"1",
":",
"]",
".",
"lower",
"(",
")",
")",
"out",
".",
"append",
"(",
"\"\"",
".",
"join",
"(",
"result",
")",
")",
"# if we have more new words than old ones, just add them verbatim",
"out",
".",
"extend",
"(",
"[",
"new_word",
"for",
"ind",
",",
"new_word",
"in",
"enumerate",
"(",
"new_words",
")",
"if",
"ind",
">=",
"len",
"(",
"old_words",
")",
"]",
")",
"return",
"\" \"",
".",
"join",
"(",
"out",
")",
"if",
"string",
"is",
"None",
":",
"return",
"None",
"regex",
"=",
"re",
".",
"compile",
"(",
"re",
".",
"escape",
"(",
"old",
")",
",",
"re",
".",
"I",
")",
"return",
"regex",
".",
"sub",
"(",
"repl",
",",
"string",
")"
] | [
10,
0
] | [
58,
34
] | python | en | ['en', 'error', 'th'] | False |
_get_corner_points | (x0, y0, x1, y1) |
Returns the corner points of a scatter rectangle
:param x0: x-start
:param y0: y-lower
:param x1: x-end
:param y1: y-upper
:return: ([x], [y]), tuple of lists containing the x and y values
|
Returns the corner points of a scatter rectangle | def _get_corner_points(x0, y0, x1, y1):
"""
Returns the corner points of a scatter rectangle
:param x0: x-start
:param y0: y-lower
:param x1: x-end
:param y1: y-upper
:return: ([x], [y]), tuple of lists containing the x and y values
"""
return ([x0, x1, x1, x0], [y0, y0, y1, y1]) | [
"def",
"_get_corner_points",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
")",
":",
"return",
"(",
"[",
"x0",
",",
"x1",
",",
"x1",
",",
"x0",
"]",
",",
"[",
"y0",
",",
"y0",
",",
"y1",
",",
"y1",
"]",
")"
] | [
16,
0
] | [
27,
47
] | python | en | ['en', 'error', 'th'] | False |
validate_gantt | (df) |
Validates the inputted dataframe or list
|
Validates the inputted dataframe or list
| def validate_gantt(df):
"""
Validates the inputted dataframe or list
"""
if pd and isinstance(df, pd.core.frame.DataFrame):
# validate that df has all the required keys
for key in REQUIRED_GANTT_KEYS:
if key not in df:
raise exceptions.PlotlyError(
"The columns in your dataframe must include the "
"following keys: {0}".format(", ".join(REQUIRED_GANTT_KEYS))
)
num_of_rows = len(df.index)
chart = []
for index in range(num_of_rows):
task_dict = {}
for key in df:
task_dict[key] = df.iloc[index][key]
chart.append(task_dict)
return chart
# validate if df is a list
if not isinstance(df, list):
raise exceptions.PlotlyError(
"You must input either a dataframe " "or a list of dictionaries."
)
# validate if df is empty
if len(df) <= 0:
raise exceptions.PlotlyError(
"Your list is empty. It must contain " "at least one dictionary."
)
if not isinstance(df[0], dict):
raise exceptions.PlotlyError("Your list must only " "include dictionaries.")
return df | [
"def",
"validate_gantt",
"(",
"df",
")",
":",
"if",
"pd",
"and",
"isinstance",
"(",
"df",
",",
"pd",
".",
"core",
".",
"frame",
".",
"DataFrame",
")",
":",
"# validate that df has all the required keys",
"for",
"key",
"in",
"REQUIRED_GANTT_KEYS",
":",
"if",
"key",
"not",
"in",
"df",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"The columns in your dataframe must include the \"",
"\"following keys: {0}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"REQUIRED_GANTT_KEYS",
")",
")",
")",
"num_of_rows",
"=",
"len",
"(",
"df",
".",
"index",
")",
"chart",
"=",
"[",
"]",
"for",
"index",
"in",
"range",
"(",
"num_of_rows",
")",
":",
"task_dict",
"=",
"{",
"}",
"for",
"key",
"in",
"df",
":",
"task_dict",
"[",
"key",
"]",
"=",
"df",
".",
"iloc",
"[",
"index",
"]",
"[",
"key",
"]",
"chart",
".",
"append",
"(",
"task_dict",
")",
"return",
"chart",
"# validate if df is a list",
"if",
"not",
"isinstance",
"(",
"df",
",",
"list",
")",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"You must input either a dataframe \"",
"\"or a list of dictionaries.\"",
")",
"# validate if df is empty",
"if",
"len",
"(",
"df",
")",
"<=",
"0",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"Your list is empty. It must contain \"",
"\"at least one dictionary.\"",
")",
"if",
"not",
"isinstance",
"(",
"df",
"[",
"0",
"]",
",",
"dict",
")",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"Your list must only \"",
"\"include dictionaries.\"",
")",
"return",
"df"
] | [
30,
0
] | [
66,
13
] | python | en | ['en', 'error', 'th'] | False |
gantt | (
chart,
colors,
title,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
show_colorbar=True,
) |
Refer to create_gantt() for docstring
|
Refer to create_gantt() for docstring
| def gantt(
chart,
colors,
title,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
show_colorbar=True,
):
"""
Refer to create_gantt() for docstring
"""
if tasks is None:
tasks = []
if task_names is None:
task_names = []
if data is None:
data = []
for index in range(len(chart)):
task = dict(
x0=chart[index]["Start"],
x1=chart[index]["Finish"],
name=chart[index]["Task"],
)
if "Description" in chart[index]:
task["description"] = chart[index]["Description"]
tasks.append(task)
# create a scatter trace for every task group
scatter_data_dict = dict()
marker_data_dict = dict()
if show_hover_fill:
hoverinfo = "name"
else:
hoverinfo = "skip"
scatter_data_template = {
"x": [],
"y": [],
"mode": "none",
"fill": "toself",
"hoverinfo": hoverinfo,
}
marker_data_template = {
"x": [],
"y": [],
"mode": "markers",
"text": [],
"marker": dict(color="", size=1, opacity=0),
"name": "",
"showlegend": False,
}
# create the list of task names
for index in range(len(tasks)):
tn = tasks[index]["name"]
# Is added to task_names if group_tasks is set to False,
# or if the option is used (True) it only adds them if the
# name is not already in the list
if not group_tasks or tn not in task_names:
task_names.append(tn)
# Guarantees that for grouped tasks the tasks that are inserted first
# are shown at the top
if group_tasks:
task_names.reverse()
color_index = 0
for index in range(len(tasks)):
tn = tasks[index]["name"]
del tasks[index]["name"]
# If group_tasks is True, all tasks with the same name belong
# to the same row.
groupID = index
if group_tasks:
groupID = task_names.index(tn)
tasks[index]["y0"] = groupID - bar_width
tasks[index]["y1"] = groupID + bar_width
# check if colors need to be looped
if color_index >= len(colors):
color_index = 0
tasks[index]["fillcolor"] = colors[color_index]
color_id = tasks[index]["fillcolor"]
if color_id not in scatter_data_dict:
scatter_data_dict[color_id] = copy.deepcopy(scatter_data_template)
scatter_data_dict[color_id]["fillcolor"] = color_id
scatter_data_dict[color_id]["name"] = str(tn)
scatter_data_dict[color_id]["legendgroup"] = color_id
# if there are already values append the gap
if len(scatter_data_dict[color_id]["x"]) > 0:
# a gap on the scatterplot separates the rectangles from each other
scatter_data_dict[color_id]["x"].append(
scatter_data_dict[color_id]["x"][-1]
)
scatter_data_dict[color_id]["y"].append(None)
xs, ys = _get_corner_points(
tasks[index]["x0"],
tasks[index]["y0"],
tasks[index]["x1"],
tasks[index]["y1"],
)
scatter_data_dict[color_id]["x"] += xs
scatter_data_dict[color_id]["y"] += ys
# append dummy markers for showing start and end of interval
if color_id not in marker_data_dict:
marker_data_dict[color_id] = copy.deepcopy(marker_data_template)
marker_data_dict[color_id]["marker"]["color"] = color_id
marker_data_dict[color_id]["legendgroup"] = color_id
marker_data_dict[color_id]["x"].append(tasks[index]["x0"])
marker_data_dict[color_id]["x"].append(tasks[index]["x1"])
marker_data_dict[color_id]["y"].append(groupID)
marker_data_dict[color_id]["y"].append(groupID)
if "description" in tasks[index]:
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
del tasks[index]["description"]
else:
marker_data_dict[color_id]["text"].append(None)
marker_data_dict[color_id]["text"].append(None)
color_index += 1
showlegend = show_colorbar
layout = dict(
title=title,
showlegend=showlegend,
height=height,
width=width,
shapes=[],
hovermode="closest",
yaxis=dict(
showgrid=showgrid_y,
ticktext=task_names,
tickvals=list(range(len(task_names))),
range=[-1, len(task_names) + 1],
autorange=False,
zeroline=False,
),
xaxis=dict(
showgrid=showgrid_x,
zeroline=False,
rangeselector=dict(
buttons=list(
[
dict(count=7, label="1w", step="day", stepmode="backward"),
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all"),
]
)
),
type="date",
),
)
data = [scatter_data_dict[k] for k in sorted(scatter_data_dict)]
data += [marker_data_dict[k] for k in sorted(marker_data_dict)]
# fig = dict(
# data=data, layout=layout
# )
fig = go.Figure(data=data, layout=layout)
return fig | [
"def",
"gantt",
"(",
"chart",
",",
"colors",
",",
"title",
",",
"bar_width",
",",
"showgrid_x",
",",
"showgrid_y",
",",
"height",
",",
"width",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"False",
",",
"show_hover_fill",
"=",
"True",
",",
"show_colorbar",
"=",
"True",
",",
")",
":",
"if",
"tasks",
"is",
"None",
":",
"tasks",
"=",
"[",
"]",
"if",
"task_names",
"is",
"None",
":",
"task_names",
"=",
"[",
"]",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"[",
"]",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"chart",
")",
")",
":",
"task",
"=",
"dict",
"(",
"x0",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Start\"",
"]",
",",
"x1",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Finish\"",
"]",
",",
"name",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Task\"",
"]",
",",
")",
"if",
"\"Description\"",
"in",
"chart",
"[",
"index",
"]",
":",
"task",
"[",
"\"description\"",
"]",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Description\"",
"]",
"tasks",
".",
"append",
"(",
"task",
")",
"# create a scatter trace for every task group",
"scatter_data_dict",
"=",
"dict",
"(",
")",
"marker_data_dict",
"=",
"dict",
"(",
")",
"if",
"show_hover_fill",
":",
"hoverinfo",
"=",
"\"name\"",
"else",
":",
"hoverinfo",
"=",
"\"skip\"",
"scatter_data_template",
"=",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"mode\"",
":",
"\"none\"",
",",
"\"fill\"",
":",
"\"toself\"",
",",
"\"hoverinfo\"",
":",
"hoverinfo",
",",
"}",
"marker_data_template",
"=",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"mode\"",
":",
"\"markers\"",
",",
"\"text\"",
":",
"[",
"]",
",",
"\"marker\"",
":",
"dict",
"(",
"color",
"=",
"\"\"",
",",
"size",
"=",
"1",
",",
"opacity",
"=",
"0",
")",
",",
"\"name\"",
":",
"\"\"",
",",
"\"showlegend\"",
":",
"False",
",",
"}",
"# create the list of task names",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# Is added to task_names if group_tasks is set to False,",
"# or if the option is used (True) it only adds them if the",
"# name is not already in the list",
"if",
"not",
"group_tasks",
"or",
"tn",
"not",
"in",
"task_names",
":",
"task_names",
".",
"append",
"(",
"tn",
")",
"# Guarantees that for grouped tasks the tasks that are inserted first",
"# are shown at the top",
"if",
"group_tasks",
":",
"task_names",
".",
"reverse",
"(",
")",
"color_index",
"=",
"0",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# If group_tasks is True, all tasks with the same name belong",
"# to the same row.",
"groupID",
"=",
"index",
"if",
"group_tasks",
":",
"groupID",
"=",
"task_names",
".",
"index",
"(",
"tn",
")",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
"=",
"groupID",
"-",
"bar_width",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
"=",
"groupID",
"+",
"bar_width",
"# check if colors need to be looped",
"if",
"color_index",
">=",
"len",
"(",
"colors",
")",
":",
"color_index",
"=",
"0",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"colors",
"[",
"color_index",
"]",
"color_id",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"if",
"color_id",
"not",
"in",
"scatter_data_dict",
":",
"scatter_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"scatter_data_template",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"color_id",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"name\"",
"]",
"=",
"str",
"(",
"tn",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"# if there are already values append the gap",
"if",
"len",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
")",
">",
"0",
":",
"# a gap on the scatterplot separates the rectangles from each other",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"[",
"-",
"1",
"]",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"None",
")",
"xs",
",",
"ys",
"=",
"_get_corner_points",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
",",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"+=",
"xs",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
"+=",
"ys",
"# append dummy markers for showing start and end of interval",
"if",
"color_id",
"not",
"in",
"marker_data_dict",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"marker_data_template",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"marker\"",
"]",
"[",
"\"color\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"if",
"\"description\"",
"in",
"tasks",
"[",
"index",
"]",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
"else",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"color_index",
"+=",
"1",
"showlegend",
"=",
"show_colorbar",
"layout",
"=",
"dict",
"(",
"title",
"=",
"title",
",",
"showlegend",
"=",
"showlegend",
",",
"height",
"=",
"height",
",",
"width",
"=",
"width",
",",
"shapes",
"=",
"[",
"]",
",",
"hovermode",
"=",
"\"closest\"",
",",
"yaxis",
"=",
"dict",
"(",
"showgrid",
"=",
"showgrid_y",
",",
"ticktext",
"=",
"task_names",
",",
"tickvals",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"task_names",
")",
")",
")",
",",
"range",
"=",
"[",
"-",
"1",
",",
"len",
"(",
"task_names",
")",
"+",
"1",
"]",
",",
"autorange",
"=",
"False",
",",
"zeroline",
"=",
"False",
",",
")",
",",
"xaxis",
"=",
"dict",
"(",
"showgrid",
"=",
"showgrid_x",
",",
"zeroline",
"=",
"False",
",",
"rangeselector",
"=",
"dict",
"(",
"buttons",
"=",
"list",
"(",
"[",
"dict",
"(",
"count",
"=",
"7",
",",
"label",
"=",
"\"1w\"",
",",
"step",
"=",
"\"day\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"1m\"",
",",
"step",
"=",
"\"month\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"6",
",",
"label",
"=",
"\"6m\"",
",",
"step",
"=",
"\"month\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"YTD\"",
",",
"step",
"=",
"\"year\"",
",",
"stepmode",
"=",
"\"todate\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"1y\"",
",",
"step",
"=",
"\"year\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"step",
"=",
"\"all\"",
")",
",",
"]",
")",
")",
",",
"type",
"=",
"\"date\"",
",",
")",
",",
")",
"data",
"=",
"[",
"scatter_data_dict",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"scatter_data_dict",
")",
"]",
"data",
"+=",
"[",
"marker_data_dict",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"marker_data_dict",
")",
"]",
"# fig = dict(",
"# data=data, layout=layout",
"# )",
"fig",
"=",
"go",
".",
"Figure",
"(",
"data",
"=",
"data",
",",
"layout",
"=",
"layout",
")",
"return",
"fig"
] | [
69,
0
] | [
253,
14
] | python | en | ['en', 'error', 'th'] | False |
gantt_colorscale | (
chart,
colors,
title,
index_col,
show_colorbar,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
) |
Refer to FigureFactory.create_gantt() for docstring
|
Refer to FigureFactory.create_gantt() for docstring
| def gantt_colorscale(
chart,
colors,
title,
index_col,
show_colorbar,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
):
"""
Refer to FigureFactory.create_gantt() for docstring
"""
if tasks is None:
tasks = []
if task_names is None:
task_names = []
if data is None:
data = []
showlegend = False
for index in range(len(chart)):
task = dict(
x0=chart[index]["Start"],
x1=chart[index]["Finish"],
name=chart[index]["Task"],
)
if "Description" in chart[index]:
task["description"] = chart[index]["Description"]
tasks.append(task)
# create a scatter trace for every task group
scatter_data_dict = dict()
# create scatter traces for the start- and endpoints
marker_data_dict = dict()
if show_hover_fill:
hoverinfo = "name"
else:
hoverinfo = "skip"
scatter_data_template = {
"x": [],
"y": [],
"mode": "none",
"fill": "toself",
"showlegend": False,
"hoverinfo": hoverinfo,
"legendgroup": "",
}
marker_data_template = {
"x": [],
"y": [],
"mode": "markers",
"text": [],
"marker": dict(color="", size=1, opacity=0),
"name": "",
"showlegend": False,
"legendgroup": "",
}
index_vals = []
for row in range(len(tasks)):
if chart[row][index_col] not in index_vals:
index_vals.append(chart[row][index_col])
index_vals.sort()
# compute the color for task based on indexing column
if isinstance(chart[0][index_col], Number):
# check that colors has at least 2 colors
if len(colors) < 2:
raise exceptions.PlotlyError(
"You must use at least 2 colors in 'colors' if you "
"are using a colorscale. However only the first two "
"colors given will be used for the lower and upper "
"bounds on the colormap."
)
# create the list of task names
for index in range(len(tasks)):
tn = tasks[index]["name"]
# Is added to task_names if group_tasks is set to False,
# or if the option is used (True) it only adds them if the
# name is not already in the list
if not group_tasks or tn not in task_names:
task_names.append(tn)
# Guarantees that for grouped tasks the tasks that are inserted
# first are shown at the top
if group_tasks:
task_names.reverse()
for index in range(len(tasks)):
tn = tasks[index]["name"]
del tasks[index]["name"]
# If group_tasks is True, all tasks with the same name belong
# to the same row.
groupID = index
if group_tasks:
groupID = task_names.index(tn)
tasks[index]["y0"] = groupID - bar_width
tasks[index]["y1"] = groupID + bar_width
# unlabel color
colors = clrs.color_parser(colors, clrs.unlabel_rgb)
lowcolor = colors[0]
highcolor = colors[1]
intermed = (chart[index][index_col]) / 100.0
intermed_color = clrs.find_intermediate_color(lowcolor, highcolor, intermed)
intermed_color = clrs.color_parser(intermed_color, clrs.label_rgb)
tasks[index]["fillcolor"] = intermed_color
color_id = tasks[index]["fillcolor"]
if color_id not in scatter_data_dict:
scatter_data_dict[color_id] = copy.deepcopy(scatter_data_template)
scatter_data_dict[color_id]["fillcolor"] = color_id
scatter_data_dict[color_id]["name"] = str(chart[index][index_col])
scatter_data_dict[color_id]["legendgroup"] = color_id
# relabel colors with 'rgb'
colors = clrs.color_parser(colors, clrs.label_rgb)
# if there are already values append the gap
if len(scatter_data_dict[color_id]["x"]) > 0:
# a gap on the scatterplot separates the rectangles from each other
scatter_data_dict[color_id]["x"].append(
scatter_data_dict[color_id]["x"][-1]
)
scatter_data_dict[color_id]["y"].append(None)
xs, ys = _get_corner_points(
tasks[index]["x0"],
tasks[index]["y0"],
tasks[index]["x1"],
tasks[index]["y1"],
)
scatter_data_dict[color_id]["x"] += xs
scatter_data_dict[color_id]["y"] += ys
# append dummy markers for showing start and end of interval
if color_id not in marker_data_dict:
marker_data_dict[color_id] = copy.deepcopy(marker_data_template)
marker_data_dict[color_id]["marker"]["color"] = color_id
marker_data_dict[color_id]["legendgroup"] = color_id
marker_data_dict[color_id]["x"].append(tasks[index]["x0"])
marker_data_dict[color_id]["x"].append(tasks[index]["x1"])
marker_data_dict[color_id]["y"].append(groupID)
marker_data_dict[color_id]["y"].append(groupID)
if "description" in tasks[index]:
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
del tasks[index]["description"]
else:
marker_data_dict[color_id]["text"].append(None)
marker_data_dict[color_id]["text"].append(None)
# add colorbar to one of the traces randomly just for display
if show_colorbar is True:
k = list(marker_data_dict.keys())[0]
marker_data_dict[k]["marker"].update(
dict(
colorscale=[[0, colors[0]], [1, colors[1]]],
showscale=True,
cmax=100,
cmin=0,
)
)
if isinstance(chart[0][index_col], str):
index_vals = []
for row in range(len(tasks)):
if chart[row][index_col] not in index_vals:
index_vals.append(chart[row][index_col])
index_vals.sort()
if len(colors) < len(index_vals):
raise exceptions.PlotlyError(
"Error. The number of colors in 'colors' must be no less "
"than the number of unique index values in your group "
"column."
)
# make a dictionary assignment to each index value
index_vals_dict = {}
# define color index
c_index = 0
for key in index_vals:
if c_index > len(colors) - 1:
c_index = 0
index_vals_dict[key] = colors[c_index]
c_index += 1
# create the list of task names
for index in range(len(tasks)):
tn = tasks[index]["name"]
# Is added to task_names if group_tasks is set to False,
# or if the option is used (True) it only adds them if the
# name is not already in the list
if not group_tasks or tn not in task_names:
task_names.append(tn)
# Guarantees that for grouped tasks the tasks that are inserted
# first are shown at the top
if group_tasks:
task_names.reverse()
for index in range(len(tasks)):
tn = tasks[index]["name"]
del tasks[index]["name"]
# If group_tasks is True, all tasks with the same name belong
# to the same row.
groupID = index
if group_tasks:
groupID = task_names.index(tn)
tasks[index]["y0"] = groupID - bar_width
tasks[index]["y1"] = groupID + bar_width
tasks[index]["fillcolor"] = index_vals_dict[chart[index][index_col]]
color_id = tasks[index]["fillcolor"]
if color_id not in scatter_data_dict:
scatter_data_dict[color_id] = copy.deepcopy(scatter_data_template)
scatter_data_dict[color_id]["fillcolor"] = color_id
scatter_data_dict[color_id]["legendgroup"] = color_id
scatter_data_dict[color_id]["name"] = str(chart[index][index_col])
# relabel colors with 'rgb'
colors = clrs.color_parser(colors, clrs.label_rgb)
# if there are already values append the gap
if len(scatter_data_dict[color_id]["x"]) > 0:
# a gap on the scatterplot separates the rectangles from each other
scatter_data_dict[color_id]["x"].append(
scatter_data_dict[color_id]["x"][-1]
)
scatter_data_dict[color_id]["y"].append(None)
xs, ys = _get_corner_points(
tasks[index]["x0"],
tasks[index]["y0"],
tasks[index]["x1"],
tasks[index]["y1"],
)
scatter_data_dict[color_id]["x"] += xs
scatter_data_dict[color_id]["y"] += ys
# append dummy markers for showing start and end of interval
if color_id not in marker_data_dict:
marker_data_dict[color_id] = copy.deepcopy(marker_data_template)
marker_data_dict[color_id]["marker"]["color"] = color_id
marker_data_dict[color_id]["legendgroup"] = color_id
marker_data_dict[color_id]["x"].append(tasks[index]["x0"])
marker_data_dict[color_id]["x"].append(tasks[index]["x1"])
marker_data_dict[color_id]["y"].append(groupID)
marker_data_dict[color_id]["y"].append(groupID)
if "description" in tasks[index]:
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
del tasks[index]["description"]
else:
marker_data_dict[color_id]["text"].append(None)
marker_data_dict[color_id]["text"].append(None)
if show_colorbar is True:
showlegend = True
for k in scatter_data_dict:
scatter_data_dict[k]["showlegend"] = showlegend
# add colorbar to one of the traces randomly just for display
# if show_colorbar is True:
# k = list(marker_data_dict.keys())[0]
# marker_data_dict[k]["marker"].update(
# dict(
# colorscale=[[0, colors[0]], [1, colors[1]]],
# showscale=True,
# cmax=100,
# cmin=0,
# )
# )
layout = dict(
title=title,
showlegend=showlegend,
height=height,
width=width,
shapes=[],
hovermode="closest",
yaxis=dict(
showgrid=showgrid_y,
ticktext=task_names,
tickvals=list(range(len(task_names))),
range=[-1, len(task_names) + 1],
autorange=False,
zeroline=False,
),
xaxis=dict(
showgrid=showgrid_x,
zeroline=False,
rangeselector=dict(
buttons=list(
[
dict(count=7, label="1w", step="day", stepmode="backward"),
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all"),
]
)
),
type="date",
),
)
data = [scatter_data_dict[k] for k in sorted(scatter_data_dict)]
data += [marker_data_dict[k] for k in sorted(marker_data_dict)]
# fig = dict(
# data=data, layout=layout
# )
fig = go.Figure(data=data, layout=layout)
return fig | [
"def",
"gantt_colorscale",
"(",
"chart",
",",
"colors",
",",
"title",
",",
"index_col",
",",
"show_colorbar",
",",
"bar_width",
",",
"showgrid_x",
",",
"showgrid_y",
",",
"height",
",",
"width",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"False",
",",
"show_hover_fill",
"=",
"True",
",",
")",
":",
"if",
"tasks",
"is",
"None",
":",
"tasks",
"=",
"[",
"]",
"if",
"task_names",
"is",
"None",
":",
"task_names",
"=",
"[",
"]",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"[",
"]",
"showlegend",
"=",
"False",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"chart",
")",
")",
":",
"task",
"=",
"dict",
"(",
"x0",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Start\"",
"]",
",",
"x1",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Finish\"",
"]",
",",
"name",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Task\"",
"]",
",",
")",
"if",
"\"Description\"",
"in",
"chart",
"[",
"index",
"]",
":",
"task",
"[",
"\"description\"",
"]",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Description\"",
"]",
"tasks",
".",
"append",
"(",
"task",
")",
"# create a scatter trace for every task group",
"scatter_data_dict",
"=",
"dict",
"(",
")",
"# create scatter traces for the start- and endpoints",
"marker_data_dict",
"=",
"dict",
"(",
")",
"if",
"show_hover_fill",
":",
"hoverinfo",
"=",
"\"name\"",
"else",
":",
"hoverinfo",
"=",
"\"skip\"",
"scatter_data_template",
"=",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"mode\"",
":",
"\"none\"",
",",
"\"fill\"",
":",
"\"toself\"",
",",
"\"showlegend\"",
":",
"False",
",",
"\"hoverinfo\"",
":",
"hoverinfo",
",",
"\"legendgroup\"",
":",
"\"\"",
",",
"}",
"marker_data_template",
"=",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"mode\"",
":",
"\"markers\"",
",",
"\"text\"",
":",
"[",
"]",
",",
"\"marker\"",
":",
"dict",
"(",
"color",
"=",
"\"\"",
",",
"size",
"=",
"1",
",",
"opacity",
"=",
"0",
")",
",",
"\"name\"",
":",
"\"\"",
",",
"\"showlegend\"",
":",
"False",
",",
"\"legendgroup\"",
":",
"\"\"",
",",
"}",
"index_vals",
"=",
"[",
"]",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"if",
"chart",
"[",
"row",
"]",
"[",
"index_col",
"]",
"not",
"in",
"index_vals",
":",
"index_vals",
".",
"append",
"(",
"chart",
"[",
"row",
"]",
"[",
"index_col",
"]",
")",
"index_vals",
".",
"sort",
"(",
")",
"# compute the color for task based on indexing column",
"if",
"isinstance",
"(",
"chart",
"[",
"0",
"]",
"[",
"index_col",
"]",
",",
"Number",
")",
":",
"# check that colors has at least 2 colors",
"if",
"len",
"(",
"colors",
")",
"<",
"2",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"You must use at least 2 colors in 'colors' if you \"",
"\"are using a colorscale. However only the first two \"",
"\"colors given will be used for the lower and upper \"",
"\"bounds on the colormap.\"",
")",
"# create the list of task names",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# Is added to task_names if group_tasks is set to False,",
"# or if the option is used (True) it only adds them if the",
"# name is not already in the list",
"if",
"not",
"group_tasks",
"or",
"tn",
"not",
"in",
"task_names",
":",
"task_names",
".",
"append",
"(",
"tn",
")",
"# Guarantees that for grouped tasks the tasks that are inserted",
"# first are shown at the top",
"if",
"group_tasks",
":",
"task_names",
".",
"reverse",
"(",
")",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# If group_tasks is True, all tasks with the same name belong",
"# to the same row.",
"groupID",
"=",
"index",
"if",
"group_tasks",
":",
"groupID",
"=",
"task_names",
".",
"index",
"(",
"tn",
")",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
"=",
"groupID",
"-",
"bar_width",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
"=",
"groupID",
"+",
"bar_width",
"# unlabel color",
"colors",
"=",
"clrs",
".",
"color_parser",
"(",
"colors",
",",
"clrs",
".",
"unlabel_rgb",
")",
"lowcolor",
"=",
"colors",
"[",
"0",
"]",
"highcolor",
"=",
"colors",
"[",
"1",
"]",
"intermed",
"=",
"(",
"chart",
"[",
"index",
"]",
"[",
"index_col",
"]",
")",
"/",
"100.0",
"intermed_color",
"=",
"clrs",
".",
"find_intermediate_color",
"(",
"lowcolor",
",",
"highcolor",
",",
"intermed",
")",
"intermed_color",
"=",
"clrs",
".",
"color_parser",
"(",
"intermed_color",
",",
"clrs",
".",
"label_rgb",
")",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"intermed_color",
"color_id",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"if",
"color_id",
"not",
"in",
"scatter_data_dict",
":",
"scatter_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"scatter_data_template",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"color_id",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"name\"",
"]",
"=",
"str",
"(",
"chart",
"[",
"index",
"]",
"[",
"index_col",
"]",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"# relabel colors with 'rgb'",
"colors",
"=",
"clrs",
".",
"color_parser",
"(",
"colors",
",",
"clrs",
".",
"label_rgb",
")",
"# if there are already values append the gap",
"if",
"len",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
")",
">",
"0",
":",
"# a gap on the scatterplot separates the rectangles from each other",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"[",
"-",
"1",
"]",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"None",
")",
"xs",
",",
"ys",
"=",
"_get_corner_points",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
",",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"+=",
"xs",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
"+=",
"ys",
"# append dummy markers for showing start and end of interval",
"if",
"color_id",
"not",
"in",
"marker_data_dict",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"marker_data_template",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"marker\"",
"]",
"[",
"\"color\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"if",
"\"description\"",
"in",
"tasks",
"[",
"index",
"]",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
"else",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"# add colorbar to one of the traces randomly just for display",
"if",
"show_colorbar",
"is",
"True",
":",
"k",
"=",
"list",
"(",
"marker_data_dict",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"marker_data_dict",
"[",
"k",
"]",
"[",
"\"marker\"",
"]",
".",
"update",
"(",
"dict",
"(",
"colorscale",
"=",
"[",
"[",
"0",
",",
"colors",
"[",
"0",
"]",
"]",
",",
"[",
"1",
",",
"colors",
"[",
"1",
"]",
"]",
"]",
",",
"showscale",
"=",
"True",
",",
"cmax",
"=",
"100",
",",
"cmin",
"=",
"0",
",",
")",
")",
"if",
"isinstance",
"(",
"chart",
"[",
"0",
"]",
"[",
"index_col",
"]",
",",
"str",
")",
":",
"index_vals",
"=",
"[",
"]",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"if",
"chart",
"[",
"row",
"]",
"[",
"index_col",
"]",
"not",
"in",
"index_vals",
":",
"index_vals",
".",
"append",
"(",
"chart",
"[",
"row",
"]",
"[",
"index_col",
"]",
")",
"index_vals",
".",
"sort",
"(",
")",
"if",
"len",
"(",
"colors",
")",
"<",
"len",
"(",
"index_vals",
")",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"Error. The number of colors in 'colors' must be no less \"",
"\"than the number of unique index values in your group \"",
"\"column.\"",
")",
"# make a dictionary assignment to each index value",
"index_vals_dict",
"=",
"{",
"}",
"# define color index",
"c_index",
"=",
"0",
"for",
"key",
"in",
"index_vals",
":",
"if",
"c_index",
">",
"len",
"(",
"colors",
")",
"-",
"1",
":",
"c_index",
"=",
"0",
"index_vals_dict",
"[",
"key",
"]",
"=",
"colors",
"[",
"c_index",
"]",
"c_index",
"+=",
"1",
"# create the list of task names",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# Is added to task_names if group_tasks is set to False,",
"# or if the option is used (True) it only adds them if the",
"# name is not already in the list",
"if",
"not",
"group_tasks",
"or",
"tn",
"not",
"in",
"task_names",
":",
"task_names",
".",
"append",
"(",
"tn",
")",
"# Guarantees that for grouped tasks the tasks that are inserted",
"# first are shown at the top",
"if",
"group_tasks",
":",
"task_names",
".",
"reverse",
"(",
")",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# If group_tasks is True, all tasks with the same name belong",
"# to the same row.",
"groupID",
"=",
"index",
"if",
"group_tasks",
":",
"groupID",
"=",
"task_names",
".",
"index",
"(",
"tn",
")",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
"=",
"groupID",
"-",
"bar_width",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
"=",
"groupID",
"+",
"bar_width",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"index_vals_dict",
"[",
"chart",
"[",
"index",
"]",
"[",
"index_col",
"]",
"]",
"color_id",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"if",
"color_id",
"not",
"in",
"scatter_data_dict",
":",
"scatter_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"scatter_data_template",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"color_id",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"name\"",
"]",
"=",
"str",
"(",
"chart",
"[",
"index",
"]",
"[",
"index_col",
"]",
")",
"# relabel colors with 'rgb'",
"colors",
"=",
"clrs",
".",
"color_parser",
"(",
"colors",
",",
"clrs",
".",
"label_rgb",
")",
"# if there are already values append the gap",
"if",
"len",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
")",
">",
"0",
":",
"# a gap on the scatterplot separates the rectangles from each other",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"[",
"-",
"1",
"]",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"None",
")",
"xs",
",",
"ys",
"=",
"_get_corner_points",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
",",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"+=",
"xs",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
"+=",
"ys",
"# append dummy markers for showing start and end of interval",
"if",
"color_id",
"not",
"in",
"marker_data_dict",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"marker_data_template",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"marker\"",
"]",
"[",
"\"color\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"if",
"\"description\"",
"in",
"tasks",
"[",
"index",
"]",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
"else",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"if",
"show_colorbar",
"is",
"True",
":",
"showlegend",
"=",
"True",
"for",
"k",
"in",
"scatter_data_dict",
":",
"scatter_data_dict",
"[",
"k",
"]",
"[",
"\"showlegend\"",
"]",
"=",
"showlegend",
"# add colorbar to one of the traces randomly just for display",
"# if show_colorbar is True:",
"# k = list(marker_data_dict.keys())[0]",
"# marker_data_dict[k][\"marker\"].update(",
"# dict(",
"# colorscale=[[0, colors[0]], [1, colors[1]]],",
"# showscale=True,",
"# cmax=100,",
"# cmin=0,",
"# )",
"# )",
"layout",
"=",
"dict",
"(",
"title",
"=",
"title",
",",
"showlegend",
"=",
"showlegend",
",",
"height",
"=",
"height",
",",
"width",
"=",
"width",
",",
"shapes",
"=",
"[",
"]",
",",
"hovermode",
"=",
"\"closest\"",
",",
"yaxis",
"=",
"dict",
"(",
"showgrid",
"=",
"showgrid_y",
",",
"ticktext",
"=",
"task_names",
",",
"tickvals",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"task_names",
")",
")",
")",
",",
"range",
"=",
"[",
"-",
"1",
",",
"len",
"(",
"task_names",
")",
"+",
"1",
"]",
",",
"autorange",
"=",
"False",
",",
"zeroline",
"=",
"False",
",",
")",
",",
"xaxis",
"=",
"dict",
"(",
"showgrid",
"=",
"showgrid_x",
",",
"zeroline",
"=",
"False",
",",
"rangeselector",
"=",
"dict",
"(",
"buttons",
"=",
"list",
"(",
"[",
"dict",
"(",
"count",
"=",
"7",
",",
"label",
"=",
"\"1w\"",
",",
"step",
"=",
"\"day\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"1m\"",
",",
"step",
"=",
"\"month\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"6",
",",
"label",
"=",
"\"6m\"",
",",
"step",
"=",
"\"month\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"YTD\"",
",",
"step",
"=",
"\"year\"",
",",
"stepmode",
"=",
"\"todate\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"1y\"",
",",
"step",
"=",
"\"year\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"step",
"=",
"\"all\"",
")",
",",
"]",
")",
")",
",",
"type",
"=",
"\"date\"",
",",
")",
",",
")",
"data",
"=",
"[",
"scatter_data_dict",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"scatter_data_dict",
")",
"]",
"data",
"+=",
"[",
"marker_data_dict",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"marker_data_dict",
")",
"]",
"# fig = dict(",
"# data=data, layout=layout",
"# )",
"fig",
"=",
"go",
".",
"Figure",
"(",
"data",
"=",
"data",
",",
"layout",
"=",
"layout",
")",
"return",
"fig"
] | [
256,
0
] | [
595,
14
] | python | en | ['en', 'error', 'th'] | False |
gantt_dict | (
chart,
colors,
title,
index_col,
show_colorbar,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
) |
Refer to FigureFactory.create_gantt() for docstring
|
Refer to FigureFactory.create_gantt() for docstring
| def gantt_dict(
chart,
colors,
title,
index_col,
show_colorbar,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
):
"""
Refer to FigureFactory.create_gantt() for docstring
"""
if tasks is None:
tasks = []
if task_names is None:
task_names = []
if data is None:
data = []
showlegend = False
for index in range(len(chart)):
task = dict(
x0=chart[index]["Start"],
x1=chart[index]["Finish"],
name=chart[index]["Task"],
)
if "Description" in chart[index]:
task["description"] = chart[index]["Description"]
tasks.append(task)
# create a scatter trace for every task group
scatter_data_dict = dict()
# create scatter traces for the start- and endpoints
marker_data_dict = dict()
if show_hover_fill:
hoverinfo = "name"
else:
hoverinfo = "skip"
scatter_data_template = {
"x": [],
"y": [],
"mode": "none",
"fill": "toself",
"hoverinfo": hoverinfo,
"legendgroup": "",
}
marker_data_template = {
"x": [],
"y": [],
"mode": "markers",
"text": [],
"marker": dict(color="", size=1, opacity=0),
"name": "",
"showlegend": False,
}
index_vals = []
for row in range(len(tasks)):
if chart[row][index_col] not in index_vals:
index_vals.append(chart[row][index_col])
index_vals.sort()
# verify each value in index column appears in colors dictionary
for key in index_vals:
if key not in colors:
raise exceptions.PlotlyError(
"If you are using colors as a dictionary, all of its "
"keys must be all the values in the index column."
)
# create the list of task names
for index in range(len(tasks)):
tn = tasks[index]["name"]
# Is added to task_names if group_tasks is set to False,
# or if the option is used (True) it only adds them if the
# name is not already in the list
if not group_tasks or tn not in task_names:
task_names.append(tn)
# Guarantees that for grouped tasks the tasks that are inserted first
# are shown at the top
if group_tasks:
task_names.reverse()
for index in range(len(tasks)):
tn = tasks[index]["name"]
del tasks[index]["name"]
# If group_tasks is True, all tasks with the same name belong
# to the same row.
groupID = index
if group_tasks:
groupID = task_names.index(tn)
tasks[index]["y0"] = groupID - bar_width
tasks[index]["y1"] = groupID + bar_width
tasks[index]["fillcolor"] = colors[chart[index][index_col]]
color_id = tasks[index]["fillcolor"]
if color_id not in scatter_data_dict:
scatter_data_dict[color_id] = copy.deepcopy(scatter_data_template)
scatter_data_dict[color_id]["legendgroup"] = color_id
scatter_data_dict[color_id]["fillcolor"] = color_id
# if there are already values append the gap
if len(scatter_data_dict[color_id]["x"]) > 0:
# a gap on the scatterplot separates the rectangles from each other
scatter_data_dict[color_id]["x"].append(
scatter_data_dict[color_id]["x"][-1]
)
scatter_data_dict[color_id]["y"].append(None)
xs, ys = _get_corner_points(
tasks[index]["x0"],
tasks[index]["y0"],
tasks[index]["x1"],
tasks[index]["y1"],
)
scatter_data_dict[color_id]["x"] += xs
scatter_data_dict[color_id]["y"] += ys
# append dummy markers for showing start and end of interval
if color_id not in marker_data_dict:
marker_data_dict[color_id] = copy.deepcopy(marker_data_template)
marker_data_dict[color_id]["marker"]["color"] = color_id
marker_data_dict[color_id]["legendgroup"] = color_id
marker_data_dict[color_id]["x"].append(tasks[index]["x0"])
marker_data_dict[color_id]["x"].append(tasks[index]["x1"])
marker_data_dict[color_id]["y"].append(groupID)
marker_data_dict[color_id]["y"].append(groupID)
if "description" in tasks[index]:
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
marker_data_dict[color_id]["text"].append(tasks[index]["description"])
del tasks[index]["description"]
else:
marker_data_dict[color_id]["text"].append(None)
marker_data_dict[color_id]["text"].append(None)
if show_colorbar is True:
showlegend = True
for index_value in index_vals:
scatter_data_dict[colors[index_value]]["name"] = str(index_value)
layout = dict(
title=title,
showlegend=showlegend,
height=height,
width=width,
shapes=[],
hovermode="closest",
yaxis=dict(
showgrid=showgrid_y,
ticktext=task_names,
tickvals=list(range(len(task_names))),
range=[-1, len(task_names) + 1],
autorange=False,
zeroline=False,
),
xaxis=dict(
showgrid=showgrid_x,
zeroline=False,
rangeselector=dict(
buttons=list(
[
dict(count=7, label="1w", step="day", stepmode="backward"),
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all"),
]
)
),
type="date",
),
)
data = [scatter_data_dict[k] for k in sorted(scatter_data_dict)]
data += [marker_data_dict[k] for k in sorted(marker_data_dict)]
# fig = dict(
# data=data, layout=layout
# )
fig = go.Figure(data=data, layout=layout)
return fig | [
"def",
"gantt_dict",
"(",
"chart",
",",
"colors",
",",
"title",
",",
"index_col",
",",
"show_colorbar",
",",
"bar_width",
",",
"showgrid_x",
",",
"showgrid_y",
",",
"height",
",",
"width",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"False",
",",
"show_hover_fill",
"=",
"True",
",",
")",
":",
"if",
"tasks",
"is",
"None",
":",
"tasks",
"=",
"[",
"]",
"if",
"task_names",
"is",
"None",
":",
"task_names",
"=",
"[",
"]",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"[",
"]",
"showlegend",
"=",
"False",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"chart",
")",
")",
":",
"task",
"=",
"dict",
"(",
"x0",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Start\"",
"]",
",",
"x1",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Finish\"",
"]",
",",
"name",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Task\"",
"]",
",",
")",
"if",
"\"Description\"",
"in",
"chart",
"[",
"index",
"]",
":",
"task",
"[",
"\"description\"",
"]",
"=",
"chart",
"[",
"index",
"]",
"[",
"\"Description\"",
"]",
"tasks",
".",
"append",
"(",
"task",
")",
"# create a scatter trace for every task group",
"scatter_data_dict",
"=",
"dict",
"(",
")",
"# create scatter traces for the start- and endpoints",
"marker_data_dict",
"=",
"dict",
"(",
")",
"if",
"show_hover_fill",
":",
"hoverinfo",
"=",
"\"name\"",
"else",
":",
"hoverinfo",
"=",
"\"skip\"",
"scatter_data_template",
"=",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"mode\"",
":",
"\"none\"",
",",
"\"fill\"",
":",
"\"toself\"",
",",
"\"hoverinfo\"",
":",
"hoverinfo",
",",
"\"legendgroup\"",
":",
"\"\"",
",",
"}",
"marker_data_template",
"=",
"{",
"\"x\"",
":",
"[",
"]",
",",
"\"y\"",
":",
"[",
"]",
",",
"\"mode\"",
":",
"\"markers\"",
",",
"\"text\"",
":",
"[",
"]",
",",
"\"marker\"",
":",
"dict",
"(",
"color",
"=",
"\"\"",
",",
"size",
"=",
"1",
",",
"opacity",
"=",
"0",
")",
",",
"\"name\"",
":",
"\"\"",
",",
"\"showlegend\"",
":",
"False",
",",
"}",
"index_vals",
"=",
"[",
"]",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"if",
"chart",
"[",
"row",
"]",
"[",
"index_col",
"]",
"not",
"in",
"index_vals",
":",
"index_vals",
".",
"append",
"(",
"chart",
"[",
"row",
"]",
"[",
"index_col",
"]",
")",
"index_vals",
".",
"sort",
"(",
")",
"# verify each value in index column appears in colors dictionary",
"for",
"key",
"in",
"index_vals",
":",
"if",
"key",
"not",
"in",
"colors",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"If you are using colors as a dictionary, all of its \"",
"\"keys must be all the values in the index column.\"",
")",
"# create the list of task names",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# Is added to task_names if group_tasks is set to False,",
"# or if the option is used (True) it only adds them if the",
"# name is not already in the list",
"if",
"not",
"group_tasks",
"or",
"tn",
"not",
"in",
"task_names",
":",
"task_names",
".",
"append",
"(",
"tn",
")",
"# Guarantees that for grouped tasks the tasks that are inserted first",
"# are shown at the top",
"if",
"group_tasks",
":",
"task_names",
".",
"reverse",
"(",
")",
"for",
"index",
"in",
"range",
"(",
"len",
"(",
"tasks",
")",
")",
":",
"tn",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"name\"",
"]",
"# If group_tasks is True, all tasks with the same name belong",
"# to the same row.",
"groupID",
"=",
"index",
"if",
"group_tasks",
":",
"groupID",
"=",
"task_names",
".",
"index",
"(",
"tn",
")",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
"=",
"groupID",
"-",
"bar_width",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
"=",
"groupID",
"+",
"bar_width",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"colors",
"[",
"chart",
"[",
"index",
"]",
"[",
"index_col",
"]",
"]",
"color_id",
"=",
"tasks",
"[",
"index",
"]",
"[",
"\"fillcolor\"",
"]",
"if",
"color_id",
"not",
"in",
"scatter_data_dict",
":",
"scatter_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"scatter_data_template",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"fillcolor\"",
"]",
"=",
"color_id",
"# if there are already values append the gap",
"if",
"len",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
")",
">",
"0",
":",
"# a gap on the scatterplot separates the rectangles from each other",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"[",
"-",
"1",
"]",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"None",
")",
"xs",
",",
"ys",
"=",
"_get_corner_points",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y0\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
",",
"tasks",
"[",
"index",
"]",
"[",
"\"y1\"",
"]",
",",
")",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
"+=",
"xs",
"scatter_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
"+=",
"ys",
"# append dummy markers for showing start and end of interval",
"if",
"color_id",
"not",
"in",
"marker_data_dict",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"marker_data_template",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"marker\"",
"]",
"[",
"\"color\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"legendgroup\"",
"]",
"=",
"color_id",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x0\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"x\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"x1\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"y\"",
"]",
".",
"append",
"(",
"groupID",
")",
"if",
"\"description\"",
"in",
"tasks",
"[",
"index",
"]",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
")",
"del",
"tasks",
"[",
"index",
"]",
"[",
"\"description\"",
"]",
"else",
":",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"marker_data_dict",
"[",
"color_id",
"]",
"[",
"\"text\"",
"]",
".",
"append",
"(",
"None",
")",
"if",
"show_colorbar",
"is",
"True",
":",
"showlegend",
"=",
"True",
"for",
"index_value",
"in",
"index_vals",
":",
"scatter_data_dict",
"[",
"colors",
"[",
"index_value",
"]",
"]",
"[",
"\"name\"",
"]",
"=",
"str",
"(",
"index_value",
")",
"layout",
"=",
"dict",
"(",
"title",
"=",
"title",
",",
"showlegend",
"=",
"showlegend",
",",
"height",
"=",
"height",
",",
"width",
"=",
"width",
",",
"shapes",
"=",
"[",
"]",
",",
"hovermode",
"=",
"\"closest\"",
",",
"yaxis",
"=",
"dict",
"(",
"showgrid",
"=",
"showgrid_y",
",",
"ticktext",
"=",
"task_names",
",",
"tickvals",
"=",
"list",
"(",
"range",
"(",
"len",
"(",
"task_names",
")",
")",
")",
",",
"range",
"=",
"[",
"-",
"1",
",",
"len",
"(",
"task_names",
")",
"+",
"1",
"]",
",",
"autorange",
"=",
"False",
",",
"zeroline",
"=",
"False",
",",
")",
",",
"xaxis",
"=",
"dict",
"(",
"showgrid",
"=",
"showgrid_x",
",",
"zeroline",
"=",
"False",
",",
"rangeselector",
"=",
"dict",
"(",
"buttons",
"=",
"list",
"(",
"[",
"dict",
"(",
"count",
"=",
"7",
",",
"label",
"=",
"\"1w\"",
",",
"step",
"=",
"\"day\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"1m\"",
",",
"step",
"=",
"\"month\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"6",
",",
"label",
"=",
"\"6m\"",
",",
"step",
"=",
"\"month\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"YTD\"",
",",
"step",
"=",
"\"year\"",
",",
"stepmode",
"=",
"\"todate\"",
")",
",",
"dict",
"(",
"count",
"=",
"1",
",",
"label",
"=",
"\"1y\"",
",",
"step",
"=",
"\"year\"",
",",
"stepmode",
"=",
"\"backward\"",
")",
",",
"dict",
"(",
"step",
"=",
"\"all\"",
")",
",",
"]",
")",
")",
",",
"type",
"=",
"\"date\"",
",",
")",
",",
")",
"data",
"=",
"[",
"scatter_data_dict",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"scatter_data_dict",
")",
"]",
"data",
"+=",
"[",
"marker_data_dict",
"[",
"k",
"]",
"for",
"k",
"in",
"sorted",
"(",
"marker_data_dict",
")",
"]",
"# fig = dict(",
"# data=data, layout=layout",
"# )",
"fig",
"=",
"go",
".",
"Figure",
"(",
"data",
"=",
"data",
",",
"layout",
"=",
"layout",
")",
"return",
"fig"
] | [
598,
0
] | [
799,
14
] | python | en | ['en', 'error', 'th'] | False |
create_gantt | (
df,
colors=None,
index_col=None,
show_colorbar=False,
reverse_colors=False,
title="Gantt Chart",
bar_width=0.2,
showgrid_x=False,
showgrid_y=False,
height=600,
width=None,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
) |
Returns figure for a gantt chart
:param (array|list) df: input data for gantt chart. Must be either a
a dataframe or a list. If dataframe, the columns must include
'Task', 'Start' and 'Finish'. Other columns can be included and
used for indexing. If a list, its elements must be dictionaries
with the same required column headers: 'Task', 'Start' and
'Finish'.
:param (str|list|dict|tuple) colors: either a plotly scale name, an
rgb or hex color, a color tuple or a list of colors. An rgb color
is of the form 'rgb(x, y, z)' where x, y, z belong to the interval
[0, 255] and a color tuple is a tuple of the form (a, b, c) where
a, b and c belong to [0, 1]. If colors is a list, it must
contain the valid color types aforementioned as its members.
If a dictionary, all values of the indexing column must be keys in
colors.
:param (str|float) index_col: the column header (if df is a data
frame) that will function as the indexing column. If df is a list,
index_col must be one of the keys in all the items of df.
:param (bool) show_colorbar: determines if colorbar will be visible.
Only applies if values in the index column are numeric.
:param (bool) show_hover_fill: enables/disables the hovertext for the
filled area of the chart.
:param (bool) reverse_colors: reverses the order of selected colors
:param (str) title: the title of the chart
:param (float) bar_width: the width of the horizontal bars in the plot
:param (bool) showgrid_x: show/hide the x-axis grid
:param (bool) showgrid_y: show/hide the y-axis grid
:param (float) height: the height of the chart
:param (float) width: the width of the chart
Example 1: Simple Gantt Chart
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-02-30'),
... dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
... dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')]
>>> # Create a figure
>>> fig = create_gantt(df)
>>> fig.show()
Example 2: Index by Column with Numerical Entries
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
... Finish='2009-02-30', Complete=10),
... dict(Task="Job B", Start='2009-03-05',
... Finish='2009-04-15', Complete=60),
... dict(Task="Job C", Start='2009-02-20',
... Finish='2009-05-30', Complete=95)]
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors='Blues', index_col='Complete',
... show_colorbar=True, bar_width=0.5,
... showgrid_x=True, showgrid_y=True)
>>> fig.show()
Example 3: Index by Column with String Entries
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
... Finish='2009-02-30', Resource='Apple'),
... dict(Task="Job B", Start='2009-03-05',
... Finish='2009-04-15', Resource='Grape'),
... dict(Task="Job C", Start='2009-02-20',
... Finish='2009-05-30', Resource='Banana')]
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors=['rgb(200, 50, 25)', (1, 0, 1), '#6c4774'],
... index_col='Resource', reverse_colors=True,
... show_colorbar=True)
>>> fig.show()
Example 4: Use a dictionary for colors
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
... Finish='2009-02-30', Resource='Apple'),
... dict(Task="Job B", Start='2009-03-05',
... Finish='2009-04-15', Resource='Grape'),
... dict(Task="Job C", Start='2009-02-20',
... Finish='2009-05-30', Resource='Banana')]
>>> # Make a dictionary of colors
>>> colors = {'Apple': 'rgb(255, 0, 0)',
... 'Grape': 'rgb(170, 14, 200)',
... 'Banana': (1, 1, 0.2)}
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors=colors, index_col='Resource',
... show_colorbar=True)
>>> fig.show()
Example 5: Use a pandas dataframe
>>> from plotly.figure_factory import create_gantt
>>> import pandas as pd
>>> # Make data as a dataframe
>>> df = pd.DataFrame([['Run', '2010-01-01', '2011-02-02', 10],
... ['Fast', '2011-01-01', '2012-06-05', 55],
... ['Eat', '2012-01-05', '2013-07-05', 94]],
... columns=['Task', 'Start', 'Finish', 'Complete'])
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors='Blues', index_col='Complete',
... show_colorbar=True, bar_width=0.5,
... showgrid_x=True, showgrid_y=True)
>>> fig.show()
|
Returns figure for a gantt chart | def create_gantt(
df,
colors=None,
index_col=None,
show_colorbar=False,
reverse_colors=False,
title="Gantt Chart",
bar_width=0.2,
showgrid_x=False,
showgrid_y=False,
height=600,
width=None,
tasks=None,
task_names=None,
data=None,
group_tasks=False,
show_hover_fill=True,
):
"""
Returns figure for a gantt chart
:param (array|list) df: input data for gantt chart. Must be either a
a dataframe or a list. If dataframe, the columns must include
'Task', 'Start' and 'Finish'. Other columns can be included and
used for indexing. If a list, its elements must be dictionaries
with the same required column headers: 'Task', 'Start' and
'Finish'.
:param (str|list|dict|tuple) colors: either a plotly scale name, an
rgb or hex color, a color tuple or a list of colors. An rgb color
is of the form 'rgb(x, y, z)' where x, y, z belong to the interval
[0, 255] and a color tuple is a tuple of the form (a, b, c) where
a, b and c belong to [0, 1]. If colors is a list, it must
contain the valid color types aforementioned as its members.
If a dictionary, all values of the indexing column must be keys in
colors.
:param (str|float) index_col: the column header (if df is a data
frame) that will function as the indexing column. If df is a list,
index_col must be one of the keys in all the items of df.
:param (bool) show_colorbar: determines if colorbar will be visible.
Only applies if values in the index column are numeric.
:param (bool) show_hover_fill: enables/disables the hovertext for the
filled area of the chart.
:param (bool) reverse_colors: reverses the order of selected colors
:param (str) title: the title of the chart
:param (float) bar_width: the width of the horizontal bars in the plot
:param (bool) showgrid_x: show/hide the x-axis grid
:param (bool) showgrid_y: show/hide the y-axis grid
:param (float) height: the height of the chart
:param (float) width: the width of the chart
Example 1: Simple Gantt Chart
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-02-30'),
... dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
... dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')]
>>> # Create a figure
>>> fig = create_gantt(df)
>>> fig.show()
Example 2: Index by Column with Numerical Entries
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
... Finish='2009-02-30', Complete=10),
... dict(Task="Job B", Start='2009-03-05',
... Finish='2009-04-15', Complete=60),
... dict(Task="Job C", Start='2009-02-20',
... Finish='2009-05-30', Complete=95)]
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors='Blues', index_col='Complete',
... show_colorbar=True, bar_width=0.5,
... showgrid_x=True, showgrid_y=True)
>>> fig.show()
Example 3: Index by Column with String Entries
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
... Finish='2009-02-30', Resource='Apple'),
... dict(Task="Job B", Start='2009-03-05',
... Finish='2009-04-15', Resource='Grape'),
... dict(Task="Job C", Start='2009-02-20',
... Finish='2009-05-30', Resource='Banana')]
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors=['rgb(200, 50, 25)', (1, 0, 1), '#6c4774'],
... index_col='Resource', reverse_colors=True,
... show_colorbar=True)
>>> fig.show()
Example 4: Use a dictionary for colors
>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
... Finish='2009-02-30', Resource='Apple'),
... dict(Task="Job B", Start='2009-03-05',
... Finish='2009-04-15', Resource='Grape'),
... dict(Task="Job C", Start='2009-02-20',
... Finish='2009-05-30', Resource='Banana')]
>>> # Make a dictionary of colors
>>> colors = {'Apple': 'rgb(255, 0, 0)',
... 'Grape': 'rgb(170, 14, 200)',
... 'Banana': (1, 1, 0.2)}
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors=colors, index_col='Resource',
... show_colorbar=True)
>>> fig.show()
Example 5: Use a pandas dataframe
>>> from plotly.figure_factory import create_gantt
>>> import pandas as pd
>>> # Make data as a dataframe
>>> df = pd.DataFrame([['Run', '2010-01-01', '2011-02-02', 10],
... ['Fast', '2011-01-01', '2012-06-05', 55],
... ['Eat', '2012-01-05', '2013-07-05', 94]],
... columns=['Task', 'Start', 'Finish', 'Complete'])
>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors='Blues', index_col='Complete',
... show_colorbar=True, bar_width=0.5,
... showgrid_x=True, showgrid_y=True)
>>> fig.show()
"""
# validate gantt input data
chart = validate_gantt(df)
if index_col:
if index_col not in chart[0]:
raise exceptions.PlotlyError(
"In order to use an indexing column and assign colors to "
"the values of the index, you must choose an actual "
"column name in the dataframe or key if a list of "
"dictionaries is being used."
)
# validate gantt index column
index_list = []
for dictionary in chart:
index_list.append(dictionary[index_col])
utils.validate_index(index_list)
# Validate colors
if isinstance(colors, dict):
colors = clrs.validate_colors_dict(colors, "rgb")
else:
colors = clrs.validate_colors(colors, "rgb")
if reverse_colors is True:
colors.reverse()
if not index_col:
if isinstance(colors, dict):
raise exceptions.PlotlyError(
"Error. You have set colors to a dictionary but have not "
"picked an index. An index is required if you are "
"assigning colors to particular values in a dictioanry."
)
fig = gantt(
chart,
colors,
title,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=group_tasks,
show_hover_fill=show_hover_fill,
show_colorbar=show_colorbar,
)
return fig
else:
if not isinstance(colors, dict):
fig = gantt_colorscale(
chart,
colors,
title,
index_col,
show_colorbar,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=group_tasks,
show_hover_fill=show_hover_fill,
)
return fig
else:
fig = gantt_dict(
chart,
colors,
title,
index_col,
show_colorbar,
bar_width,
showgrid_x,
showgrid_y,
height,
width,
tasks=None,
task_names=None,
data=None,
group_tasks=group_tasks,
show_hover_fill=show_hover_fill,
)
return fig | [
"def",
"create_gantt",
"(",
"df",
",",
"colors",
"=",
"None",
",",
"index_col",
"=",
"None",
",",
"show_colorbar",
"=",
"False",
",",
"reverse_colors",
"=",
"False",
",",
"title",
"=",
"\"Gantt Chart\"",
",",
"bar_width",
"=",
"0.2",
",",
"showgrid_x",
"=",
"False",
",",
"showgrid_y",
"=",
"False",
",",
"height",
"=",
"600",
",",
"width",
"=",
"None",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"False",
",",
"show_hover_fill",
"=",
"True",
",",
")",
":",
"# validate gantt input data",
"chart",
"=",
"validate_gantt",
"(",
"df",
")",
"if",
"index_col",
":",
"if",
"index_col",
"not",
"in",
"chart",
"[",
"0",
"]",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"In order to use an indexing column and assign colors to \"",
"\"the values of the index, you must choose an actual \"",
"\"column name in the dataframe or key if a list of \"",
"\"dictionaries is being used.\"",
")",
"# validate gantt index column",
"index_list",
"=",
"[",
"]",
"for",
"dictionary",
"in",
"chart",
":",
"index_list",
".",
"append",
"(",
"dictionary",
"[",
"index_col",
"]",
")",
"utils",
".",
"validate_index",
"(",
"index_list",
")",
"# Validate colors",
"if",
"isinstance",
"(",
"colors",
",",
"dict",
")",
":",
"colors",
"=",
"clrs",
".",
"validate_colors_dict",
"(",
"colors",
",",
"\"rgb\"",
")",
"else",
":",
"colors",
"=",
"clrs",
".",
"validate_colors",
"(",
"colors",
",",
"\"rgb\"",
")",
"if",
"reverse_colors",
"is",
"True",
":",
"colors",
".",
"reverse",
"(",
")",
"if",
"not",
"index_col",
":",
"if",
"isinstance",
"(",
"colors",
",",
"dict",
")",
":",
"raise",
"exceptions",
".",
"PlotlyError",
"(",
"\"Error. You have set colors to a dictionary but have not \"",
"\"picked an index. An index is required if you are \"",
"\"assigning colors to particular values in a dictioanry.\"",
")",
"fig",
"=",
"gantt",
"(",
"chart",
",",
"colors",
",",
"title",
",",
"bar_width",
",",
"showgrid_x",
",",
"showgrid_y",
",",
"height",
",",
"width",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"group_tasks",
",",
"show_hover_fill",
"=",
"show_hover_fill",
",",
"show_colorbar",
"=",
"show_colorbar",
",",
")",
"return",
"fig",
"else",
":",
"if",
"not",
"isinstance",
"(",
"colors",
",",
"dict",
")",
":",
"fig",
"=",
"gantt_colorscale",
"(",
"chart",
",",
"colors",
",",
"title",
",",
"index_col",
",",
"show_colorbar",
",",
"bar_width",
",",
"showgrid_x",
",",
"showgrid_y",
",",
"height",
",",
"width",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"group_tasks",
",",
"show_hover_fill",
"=",
"show_hover_fill",
",",
")",
"return",
"fig",
"else",
":",
"fig",
"=",
"gantt_dict",
"(",
"chart",
",",
"colors",
",",
"title",
",",
"index_col",
",",
"show_colorbar",
",",
"bar_width",
",",
"showgrid_x",
",",
"showgrid_y",
",",
"height",
",",
"width",
",",
"tasks",
"=",
"None",
",",
"task_names",
"=",
"None",
",",
"data",
"=",
"None",
",",
"group_tasks",
"=",
"group_tasks",
",",
"show_hover_fill",
"=",
"show_hover_fill",
",",
")",
"return",
"fig"
] | [
802,
0
] | [
1032,
22
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.dtickrange | (self) |
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The 'dtickrange[0]' property accepts values of any type
(1) The 'dtickrange[1]' property accepts values of any type
Returns
-------
list
|
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The 'dtickrange[0]' property accepts values of any type
(1) The 'dtickrange[1]' property accepts values of any type | def dtickrange(self):
"""
range [*min*, *max*], where "min", "max" - dtick values which
describe some zoom level, it is possible to omit "min" or "max"
value by passing "null"
The 'dtickrange' property is an info array that may be specified as:
* a list or tuple of 2 elements where:
(0) The 'dtickrange[0]' property accepts values of any type
(1) The 'dtickrange[1]' property accepts values of any type
Returns
-------
list
"""
return self["dtickrange"] | [
"def",
"dtickrange",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dtickrange\"",
"]"
] | [
15,
4
] | [
31,
33
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.enabled | (self) |
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False) | def enabled(self):
"""
Determines whether or not this stop is used. If `false`, this
stop is ignored even within its `dtickrange`.
The 'enabled' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["enabled"] | [
"def",
"enabled",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"enabled\"",
"]"
] | [
40,
4
] | [
52,
30
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.name | (self) |
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications (including `visible: false`
or `enabled: false` to hide it). Has no effect outside of a
template.
The 'name' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
|
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications (including `visible: false`
or `enabled: false` to hide it). Has no effect outside of a
template.
The 'name' property is a string and must be specified as:
- A string
- A number that will be converted to a string | def name(self):
"""
When used in a template, named items are created in the output
figure in addition to any items the figure already has in this
array. You can modify these items in the output figure by
making your own item with `templateitemname` matching this
`name` alongside your modifications (including `visible: false`
or `enabled: false` to hide it). Has no effect outside of a
template.
The 'name' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
"""
return self["name"] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"name\"",
"]"
] | [
61,
4
] | [
79,
27
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.templateitemname | (self) |
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (including `visible: false` or
`enabled: false` to hide it). If there is no template or no
matching item, this item will be hidden unless you explicitly
show it with `visible: true`.
The 'templateitemname' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
|
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (including `visible: false` or
`enabled: false` to hide it). If there is no template or no
matching item, this item will be hidden unless you explicitly
show it with `visible: true`.
The 'templateitemname' property is a string and must be specified as:
- A string
- A number that will be converted to a string | def templateitemname(self):
"""
Used to refer to a named item in this array in the template.
Named items from the template will be created even without a
matching item in the input figure, but you can modify one by
making an item with `templateitemname` matching its `name`,
alongside your modifications (including `visible: false` or
`enabled: false` to hide it). If there is no template or no
matching item, this item will be hidden unless you explicitly
show it with `visible: true`.
The 'templateitemname' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
"""
return self["templateitemname"] | [
"def",
"templateitemname",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"templateitemname\"",
"]"
] | [
88,
4
] | [
107,
39
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.value | (self) |
string - dtickformat for described zoom level, the same as
"tickformat"
The 'value' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
|
string - dtickformat for described zoom level, the same as
"tickformat"
The 'value' property is a string and must be specified as:
- A string
- A number that will be converted to a string | def value(self):
"""
string - dtickformat for described zoom level, the same as
"tickformat"
The 'value' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
"""
return self["value"] | [
"def",
"value",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"value\"",
"]"
] | [
116,
4
] | [
129,
28
] | python | en | ['en', 'error', 'th'] | False |
Tickformatstop.__init__ | (
self,
arg=None,
dtickrange=None,
enabled=None,
name=None,
templateitemname=None,
value=None,
**kwargs
) |
Construct a new Tickformatstop object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.cone.colorbar.Tickformatstop`
dtickrange
range [*min*, *max*], where "min", "max" - dtick values
which describe some zoom level, it is possible to omit
"min" or "max" value by passing "null"
enabled
Determines whether or not this stop is used. If
`false`, this stop is ignored even within its
`dtickrange`.
name
When used in a template, named items are created in the
output figure in addition to any items the figure
already has in this array. You can modify these items
in the output figure by making your own item with
`templateitemname` matching this `name` alongside your
modifications (including `visible: false` or `enabled:
false` to hide it). Has no effect outside of a
template.
templateitemname
Used to refer to a named item in this array in the
template. Named items from the template will be created
even without a matching item in the input figure, but
you can modify one by making an item with
`templateitemname` matching its `name`, alongside your
modifications (including `visible: false` or `enabled:
false` to hide it). If there is no template or no
matching item, this item will be hidden unless you
explicitly show it with `visible: true`.
value
string - dtickformat for described zoom level, the same
as "tickformat"
Returns
-------
Tickformatstop
|
Construct a new Tickformatstop object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.cone.colorbar.Tickformatstop`
dtickrange
range [*min*, *max*], where "min", "max" - dtick values
which describe some zoom level, it is possible to omit
"min" or "max" value by passing "null"
enabled
Determines whether or not this stop is used. If
`false`, this stop is ignored even within its
`dtickrange`.
name
When used in a template, named items are created in the
output figure in addition to any items the figure
already has in this array. You can modify these items
in the output figure by making your own item with
`templateitemname` matching this `name` alongside your
modifications (including `visible: false` or `enabled:
false` to hide it). Has no effect outside of a
template.
templateitemname
Used to refer to a named item in this array in the
template. Named items from the template will be created
even without a matching item in the input figure, but
you can modify one by making an item with
`templateitemname` matching its `name`, alongside your
modifications (including `visible: false` or `enabled:
false` to hide it). If there is no template or no
matching item, this item will be hidden unless you
explicitly show it with `visible: true`.
value
string - dtickformat for described zoom level, the same
as "tickformat" | def __init__(
self,
arg=None,
dtickrange=None,
enabled=None,
name=None,
templateitemname=None,
value=None,
**kwargs
):
"""
Construct a new Tickformatstop object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.cone.colorbar.Tickformatstop`
dtickrange
range [*min*, *max*], where "min", "max" - dtick values
which describe some zoom level, it is possible to omit
"min" or "max" value by passing "null"
enabled
Determines whether or not this stop is used. If
`false`, this stop is ignored even within its
`dtickrange`.
name
When used in a template, named items are created in the
output figure in addition to any items the figure
already has in this array. You can modify these items
in the output figure by making your own item with
`templateitemname` matching this `name` alongside your
modifications (including `visible: false` or `enabled:
false` to hide it). Has no effect outside of a
template.
templateitemname
Used to refer to a named item in this array in the
template. Named items from the template will be created
even without a matching item in the input figure, but
you can modify one by making an item with
`templateitemname` matching its `name`, alongside your
modifications (including `visible: false` or `enabled:
false` to hide it). If there is no template or no
matching item, this item will be hidden unless you
explicitly show it with `visible: true`.
value
string - dtickformat for described zoom level, the same
as "tickformat"
Returns
-------
Tickformatstop
"""
super(Tickformatstop, self).__init__("tickformatstops")
if "_parent" in kwargs:
self._parent = kwargs["_parent"]
return
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly.graph_objs.cone.colorbar.Tickformatstop
constructor must be a dict or
an instance of :class:`plotly.graph_objs.cone.colorbar.Tickformatstop`"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
self._validate = kwargs.pop("_validate", True)
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("dtickrange", None)
_v = dtickrange if dtickrange is not None else _v
if _v is not None:
self["dtickrange"] = _v
_v = arg.pop("enabled", None)
_v = enabled if enabled is not None else _v
if _v is not None:
self["enabled"] = _v
_v = arg.pop("name", None)
_v = name if name is not None else _v
if _v is not None:
self["name"] = _v
_v = arg.pop("templateitemname", None)
_v = templateitemname if templateitemname is not None else _v
if _v is not None:
self["templateitemname"] = _v
_v = arg.pop("value", None)
_v = value if value is not None else _v
if _v is not None:
self["value"] = _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"dtickrange",
"=",
"None",
",",
"enabled",
"=",
"None",
",",
"name",
"=",
"None",
",",
"templateitemname",
"=",
"None",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Tickformatstop",
",",
"self",
")",
".",
"__init__",
"(",
"\"tickformatstops\"",
")",
"if",
"\"_parent\"",
"in",
"kwargs",
":",
"self",
".",
"_parent",
"=",
"kwargs",
"[",
"\"_parent\"",
"]",
"return",
"# Validate arg",
"# ------------",
"if",
"arg",
"is",
"None",
":",
"arg",
"=",
"{",
"}",
"elif",
"isinstance",
"(",
"arg",
",",
"self",
".",
"__class__",
")",
":",
"arg",
"=",
"arg",
".",
"to_plotly_json",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"arg",
"=",
"_copy",
".",
"copy",
"(",
"arg",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"\"\"\\\nThe first argument to the plotly.graph_objs.cone.colorbar.Tickformatstop \nconstructor must be a dict or \nan instance of :class:`plotly.graph_objs.cone.colorbar.Tickformatstop`\"\"\"",
")",
"# Handle skip_invalid",
"# -------------------",
"self",
".",
"_skip_invalid",
"=",
"kwargs",
".",
"pop",
"(",
"\"skip_invalid\"",
",",
"False",
")",
"self",
".",
"_validate",
"=",
"kwargs",
".",
"pop",
"(",
"\"_validate\"",
",",
"True",
")",
"# Populate data dict with properties",
"# ----------------------------------",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"dtickrange\"",
",",
"None",
")",
"_v",
"=",
"dtickrange",
"if",
"dtickrange",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"dtickrange\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"enabled\"",
",",
"None",
")",
"_v",
"=",
"enabled",
"if",
"enabled",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"enabled\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"name\"",
",",
"None",
")",
"_v",
"=",
"name",
"if",
"name",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"name\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"templateitemname\"",
",",
"None",
")",
"_v",
"=",
"templateitemname",
"if",
"templateitemname",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"templateitemname\"",
"]",
"=",
"_v",
"_v",
"=",
"arg",
".",
"pop",
"(",
"\"value\"",
",",
"None",
")",
"_v",
"=",
"value",
"if",
"value",
"is",
"not",
"None",
"else",
"_v",
"if",
"_v",
"is",
"not",
"None",
":",
"self",
"[",
"\"value\"",
"]",
"=",
"_v",
"# Process unknown kwargs",
"# ----------------------",
"self",
".",
"_process_kwargs",
"(",
"*",
"*",
"dict",
"(",
"arg",
",",
"*",
"*",
"kwargs",
")",
")",
"# Reset skip_invalid",
"# ------------------",
"self",
".",
"_skip_invalid",
"=",
"False"
] | [
172,
4
] | [
282,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseIntroductionService.__init__ | (self, context: RequestContext) | Init admin service. | Init admin service. | def __init__(self, context: RequestContext):
"""Init admin service."""
self._context = context | [
"def",
"__init__",
"(",
"self",
",",
"context",
":",
"RequestContext",
")",
":",
"self",
".",
"_context",
"=",
"context"
] | [
17,
4
] | [
19,
31
] | python | en | ['en', 'it', 'en'] | True |
BaseIntroductionService.service_handler | (cls) | Quick accessor for conductor to use. | Quick accessor for conductor to use. | def service_handler(cls):
"""Quick accessor for conductor to use."""
async def get_instance(context: RequestContext):
"""Return registered server."""
return cls(context)
return get_instance | [
"def",
"service_handler",
"(",
"cls",
")",
":",
"async",
"def",
"get_instance",
"(",
"context",
":",
"RequestContext",
")",
":",
"\"\"\"Return registered server.\"\"\"",
"return",
"cls",
"(",
"context",
")",
"return",
"get_instance"
] | [
22,
4
] | [
29,
27
] | python | en | ['en', 'en', 'en'] | True |
BaseIntroductionService.start_introduction | (
self,
init_connection_id: str,
target_connection_id: str,
outbound_handler,
message: str = None,
) |
Start the introduction process between two connections.
Args:
init_connection_id: The connection initiating the request
target_connection_id: The connection which is asked for an invitation
outbound_handler: The outbound handler coroutine for sending a message
message: The message to use when requesting the invitation
|
Start the introduction process between two connections. | async def start_introduction(
self,
init_connection_id: str,
target_connection_id: str,
outbound_handler,
message: str = None,
):
"""
Start the introduction process between two connections.
Args:
init_connection_id: The connection initiating the request
target_connection_id: The connection which is asked for an invitation
outbound_handler: The outbound handler coroutine for sending a message
message: The message to use when requesting the invitation
""" | [
"async",
"def",
"start_introduction",
"(",
"self",
",",
"init_connection_id",
":",
"str",
",",
"target_connection_id",
":",
"str",
",",
"outbound_handler",
",",
"message",
":",
"str",
"=",
"None",
",",
")",
":"
] | [
32,
4
] | [
47,
11
] | python | en | ['en', 'error', 'th'] | False |
BaseIntroductionService.return_invitation | (
self, target_connection_id: str, invitation: Invitation, outbound_handler
) |
Handle the forwarding of an invitation to the responder.
Args:
target_connection_id: The ID of the connection sending the Invitation
invitation: The received Invitation message
outbound_handler: The outbound handler coroutine for sending a message
|
Handle the forwarding of an invitation to the responder. | async def return_invitation(
self, target_connection_id: str, invitation: Invitation, outbound_handler
):
"""
Handle the forwarding of an invitation to the responder.
Args:
target_connection_id: The ID of the connection sending the Invitation
invitation: The received Invitation message
outbound_handler: The outbound handler coroutine for sending a message
""" | [
"async",
"def",
"return_invitation",
"(",
"self",
",",
"target_connection_id",
":",
"str",
",",
"invitation",
":",
"Invitation",
",",
"outbound_handler",
")",
":"
] | [
50,
4
] | [
60,
11
] | python | en | ['en', 'error', 'th'] | False |
TestMenu.test_init | (self) | Test initialization. | Test initialization. | def test_init(self):
"""Test initialization."""
assert self.menu.title == self.test_menu_message["title"]
assert self.menu.description == self.test_menu_message["description"]
assert len(self.menu.options) == len(self.test_menu_message["options"]) | [
"def",
"test_init",
"(",
"self",
")",
":",
"assert",
"self",
".",
"menu",
".",
"title",
"==",
"self",
".",
"test_menu_message",
"[",
"\"title\"",
"]",
"assert",
"self",
".",
"menu",
".",
"description",
"==",
"self",
".",
"test_menu_message",
"[",
"\"description\"",
"]",
"assert",
"len",
"(",
"self",
".",
"menu",
".",
"options",
")",
"==",
"len",
"(",
"self",
".",
"test_menu_message",
"[",
"\"options\"",
"]",
")"
] | [
49,
4
] | [
53,
79
] | python | co | ['es', 'co', 'en'] | False |
TestMenu.test_deserialize | (self, mock_menu_schema_load) |
Test deserialization.
|
Test deserialization.
| def test_deserialize(self, mock_menu_schema_load):
"""
Test deserialization.
"""
obj = {"obj": "obj"}
menu = Menu.deserialize(obj)
mock_menu_schema_load.assert_called_once_with(obj)
assert menu is mock_menu_schema_load.return_value | [
"def",
"test_deserialize",
"(",
"self",
",",
"mock_menu_schema_load",
")",
":",
"obj",
"=",
"{",
"\"obj\"",
":",
"\"obj\"",
"}",
"menu",
"=",
"Menu",
".",
"deserialize",
"(",
"obj",
")",
"mock_menu_schema_load",
".",
"assert_called_once_with",
"(",
"obj",
")",
"assert",
"menu",
"is",
"mock_menu_schema_load",
".",
"return_value"
] | [
60,
4
] | [
69,
57
] | python | en | ['en', 'error', 'th'] | False |
TestMenu.test_serialize | (self, mock_menu_schema_dump) |
Test serialization.
|
Test serialization.
| def test_serialize(self, mock_menu_schema_dump):
"""
Test serialization.
"""
menu_dict = self.menu.serialize()
mock_menu_schema_dump.assert_called_once_with(self.menu)
assert menu_dict is mock_menu_schema_dump.return_value | [
"def",
"test_serialize",
"(",
"self",
",",
"mock_menu_schema_dump",
")",
":",
"menu_dict",
"=",
"self",
".",
"menu",
".",
"serialize",
"(",
")",
"mock_menu_schema_dump",
".",
"assert_called_once_with",
"(",
"self",
".",
"menu",
")",
"assert",
"menu_dict",
"is",
"mock_menu_schema_dump",
".",
"return_value"
] | [
72,
4
] | [
78,
62
] | python | en | ['en', 'error', 'th'] | False |
Match.report_live_scores | (self, scores_csv: str) | report scores without giving a winner yet
|methcoro|
Args:
scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2")
Raises:
ValueError: scores_csv has a wrong format
APIException
| report scores without giving a winner yet | async def report_live_scores(self, scores_csv: str):
""" report scores without giving a winner yet
|methcoro|
Args:
scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2")
Raises:
ValueError: scores_csv has a wrong format
APIException
"""
await self._report(scores_csv) | [
"async",
"def",
"report_live_scores",
"(",
"self",
",",
"scores_csv",
":",
"str",
")",
":",
"await",
"self",
".",
"_report",
"(",
"scores_csv",
")"
] | [
72,
4
] | [
85,
38
] | python | en | ['en', 'en', 'en'] | True |
Match.report_winner | (self, winner: Participant, scores_csv: str) | report scores and give a winner
|methcoro|
Args:
winner: :class:Participant instance
scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2")
Raises:
ValueError: scores_csv has a wrong format
APIException
| report scores and give a winner | async def report_winner(self, winner: Participant, scores_csv: str):
""" report scores and give a winner
|methcoro|
Args:
winner: :class:Participant instance
scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2")
Raises:
ValueError: scores_csv has a wrong format
APIException
"""
await self._report(scores_csv, winner._id) | [
"async",
"def",
"report_winner",
"(",
"self",
",",
"winner",
":",
"Participant",
",",
"scores_csv",
":",
"str",
")",
":",
"await",
"self",
".",
"_report",
"(",
"scores_csv",
",",
"winner",
".",
"_id",
")"
] | [
87,
4
] | [
101,
50
] | python | en | ['en', 'en', 'en'] | True |
Match.report_tie | (self, scores_csv: str) | report tie if applicable (Round Robin and Swiss)
|methcoro|
Args:
scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2")
Raises:
APIException
| report tie if applicable (Round Robin and Swiss) | async def report_tie(self, scores_csv: str):
""" report tie if applicable (Round Robin and Swiss)
|methcoro|
Args:
scores_csv: Comma separated set/game scores with player 1 score first (e.g. "1-3,3-0,3-2")
Raises:
APIException
"""
await self._report(scores_csv, 'tie') | [
"async",
"def",
"report_tie",
"(",
"self",
",",
"scores_csv",
":",
"str",
")",
":",
"await",
"self",
".",
"_report",
"(",
"scores_csv",
",",
"'tie'",
")"
] | [
103,
4
] | [
115,
45
] | python | en | ['en', 'en', 'en'] | True |
Match.reopen | (self) | Reopens a match that was marked completed, automatically resetting matches that follow it
|methcoro|
Raises:
APIException
| Reopens a match that was marked completed, automatically resetting matches that follow it | async def reopen(self):
""" Reopens a match that was marked completed, automatically resetting matches that follow it
|methcoro|
Raises:
APIException
"""
res = await self.connection('POST', 'tournaments/{}/matches/{}/reopen'.format(self._tournament_id, self._id))
self._refresh_from_json(res) | [
"async",
"def",
"reopen",
"(",
"self",
")",
":",
"res",
"=",
"await",
"self",
".",
"connection",
"(",
"'POST'",
",",
"'tournaments/{}/matches/{}/reopen'",
".",
"format",
"(",
"self",
".",
"_tournament_id",
",",
"self",
".",
"_id",
")",
")",
"self",
".",
"_refresh_from_json",
"(",
"res",
")"
] | [
117,
4
] | [
127,
36
] | python | en | ['en', 'en', 'en'] | True |
Match.mark_as_underway | (self) | Marks the match as underway
|methcoro|
Raises:
APIException
| Marks the match as underway | async def mark_as_underway(self):
""" Marks the match as underway
|methcoro|
Raises:
APIException
"""
res = await self.connection('POST', 'tournaments/{}/matches/{}/mark_as_underway'.format(self._tournament_id, self._id))
self._refresh_from_json(res) | [
"async",
"def",
"mark_as_underway",
"(",
"self",
")",
":",
"res",
"=",
"await",
"self",
".",
"connection",
"(",
"'POST'",
",",
"'tournaments/{}/matches/{}/mark_as_underway'",
".",
"format",
"(",
"self",
".",
"_tournament_id",
",",
"self",
".",
"_id",
")",
")",
"self",
".",
"_refresh_from_json",
"(",
"res",
")"
] | [
129,
4
] | [
139,
36
] | python | en | ['en', 'en', 'en'] | True |
Match.unmark_as_underway | (self) | Unmarks the match as underway
|methcoro|
Raises:
APIException
| Unmarks the match as underway | async def unmark_as_underway(self):
""" Unmarks the match as underway
|methcoro|
Raises:
APIException
"""
res = await self.connection('POST', 'tournaments/{}/matches/{}/unmark_as_underway'.format(self._tournament_id, self._id))
self._refresh_from_json(res) | [
"async",
"def",
"unmark_as_underway",
"(",
"self",
")",
":",
"res",
"=",
"await",
"self",
".",
"connection",
"(",
"'POST'",
",",
"'tournaments/{}/matches/{}/unmark_as_underway'",
".",
"format",
"(",
"self",
".",
"_tournament_id",
",",
"self",
".",
"_id",
")",
")",
"self",
".",
"_refresh_from_json",
"(",
"res",
")"
] | [
141,
4
] | [
151,
36
] | python | en | ['en', 'en', 'en'] | True |
Match.change_votes | (self, player1_votes: int = None, player2_votes: int = None, add: bool = False) | change the votes for either player
|methcoro|
The votes will be overriden by default,
If `add` is set to True, another API request call will be made to ensure the local is up to date with
the Challonge server. Then the votes given in argument will be added to those on the server
Args:
player1_votes: if set, the player 1 votes will be changed to this value, or added to the current value if `add` is set
player1_votes: if set, the player 2 votes will be changed to this value, or added to the current value if `add` is set
add: if set, votes in parameters will be added instead of overriden
Raises:
ValueError: one of the votes arguments must not be None
APIException
| change the votes for either player | async def change_votes(self, player1_votes: int = None, player2_votes: int = None, add: bool = False):
""" change the votes for either player
|methcoro|
The votes will be overriden by default,
If `add` is set to True, another API request call will be made to ensure the local is up to date with
the Challonge server. Then the votes given in argument will be added to those on the server
Args:
player1_votes: if set, the player 1 votes will be changed to this value, or added to the current value if `add` is set
player1_votes: if set, the player 2 votes will be changed to this value, or added to the current value if `add` is set
add: if set, votes in parameters will be added instead of overriden
Raises:
ValueError: one of the votes arguments must not be None
APIException
"""
assert_or_raise(player1_votes is not None or player2_votes is not None,
ValueError,
'One of the votes must not be None')
if add:
# order a fresh update of this match
res = await self.connection('GET', 'tournaments/{}/matches/{}'.format(self._tournament_id, self._id))
self._refresh_from_json(res)
if player1_votes is not None:
player1_votes += self._player1_votes or 0
if player2_votes is not None:
player2_votes += self._player2_votes or 0
params = {}
if player1_votes is not None:
params.update({'player1_votes': player1_votes})
if player2_votes is not None:
params.update({'player2_votes': player2_votes})
res = await self.connection('PUT',
'tournaments/{}/matches/{}'.format(self._tournament_id, self._id),
'match',
**params)
self._refresh_from_json(res) | [
"async",
"def",
"change_votes",
"(",
"self",
",",
"player1_votes",
":",
"int",
"=",
"None",
",",
"player2_votes",
":",
"int",
"=",
"None",
",",
"add",
":",
"bool",
"=",
"False",
")",
":",
"assert_or_raise",
"(",
"player1_votes",
"is",
"not",
"None",
"or",
"player2_votes",
"is",
"not",
"None",
",",
"ValueError",
",",
"'One of the votes must not be None'",
")",
"if",
"add",
":",
"# order a fresh update of this match",
"res",
"=",
"await",
"self",
".",
"connection",
"(",
"'GET'",
",",
"'tournaments/{}/matches/{}'",
".",
"format",
"(",
"self",
".",
"_tournament_id",
",",
"self",
".",
"_id",
")",
")",
"self",
".",
"_refresh_from_json",
"(",
"res",
")",
"if",
"player1_votes",
"is",
"not",
"None",
":",
"player1_votes",
"+=",
"self",
".",
"_player1_votes",
"or",
"0",
"if",
"player2_votes",
"is",
"not",
"None",
":",
"player2_votes",
"+=",
"self",
".",
"_player2_votes",
"or",
"0",
"params",
"=",
"{",
"}",
"if",
"player1_votes",
"is",
"not",
"None",
":",
"params",
".",
"update",
"(",
"{",
"'player1_votes'",
":",
"player1_votes",
"}",
")",
"if",
"player2_votes",
"is",
"not",
"None",
":",
"params",
".",
"update",
"(",
"{",
"'player2_votes'",
":",
"player2_votes",
"}",
")",
"res",
"=",
"await",
"self",
".",
"connection",
"(",
"'PUT'",
",",
"'tournaments/{}/matches/{}'",
".",
"format",
"(",
"self",
".",
"_tournament_id",
",",
"self",
".",
"_id",
")",
",",
"'match'",
",",
"*",
"*",
"params",
")",
"self",
".",
"_refresh_from_json",
"(",
"res",
")"
] | [
153,
4
] | [
193,
36
] | python | en | ['en', 'en', 'en'] | True |
Match.attach_file | (self, file_path: str, description: str = None) | add a file as an attachment
|methcoro|
Warning:
|unstable|
Args:
file_path: path to the file you want to add
description: *optional* description for your attachment
Returns:
Attachment:
Raises:
ValueError: file_path must not be None
APIException
| add a file as an attachment | async def attach_file(self, file_path: str, description: str = None) -> Attachment:
""" add a file as an attachment
|methcoro|
Warning:
|unstable|
Args:
file_path: path to the file you want to add
description: *optional* description for your attachment
Returns:
Attachment:
Raises:
ValueError: file_path must not be None
APIException
"""
with open(file_path, 'rb') as f:
return await self._attach(f.read(), description) | [
"async",
"def",
"attach_file",
"(",
"self",
",",
"file_path",
":",
"str",
",",
"description",
":",
"str",
"=",
"None",
")",
"->",
"Attachment",
":",
"with",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"as",
"f",
":",
"return",
"await",
"self",
".",
"_attach",
"(",
"f",
".",
"read",
"(",
")",
",",
"description",
")"
] | [
205,
4
] | [
226,
60
] | python | en | ['en', 'en', 'en'] | True |
Match.attach_url | (self, url: str, description: str = None) | add an url as an attachment
|methcoro|
Args:
url: url you want to add
description: *optional* description for your attachment
Returns:
Attachment:
Raises:
ValueError: url must not be None
APIException
| add an url as an attachment | async def attach_url(self, url: str, description: str = None) -> Attachment:
""" add an url as an attachment
|methcoro|
Args:
url: url you want to add
description: *optional* description for your attachment
Returns:
Attachment:
Raises:
ValueError: url must not be None
APIException
"""
return await self._attach(url=url, description=description) | [
"async",
"def",
"attach_url",
"(",
"self",
",",
"url",
":",
"str",
",",
"description",
":",
"str",
"=",
"None",
")",
"->",
"Attachment",
":",
"return",
"await",
"self",
".",
"_attach",
"(",
"url",
"=",
"url",
",",
"description",
"=",
"description",
")"
] | [
228,
4
] | [
245,
67
] | python | en | ['en', 'lb', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.