Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Scattermapbox.__init__ | (
self,
arg=None,
below=None,
connectgaps=None,
customdata=None,
customdatasrc=None,
fill=None,
fillcolor=None,
hoverinfo=None,
hoverinfosrc=None,
hoverlabel=None,
hovertemplate=None,
hovertemplatesrc=None,
h... |
Construct a new Scattermapbox object
The data visualized as scatter point, lines or marker symbols
on a Mapbox GL geographic map is provided by longitude/latitude
pairs in `lon` and `lat`.
Parameters
----------
arg
dict of properties compati... |
Construct a new Scattermapbox object
The data visualized as scatter point, lines or marker symbols
on a Mapbox GL geographic map is provided by longitude/latitude
pairs in `lon` and `lat`. | def __init__(
self,
arg=None,
below=None,
connectgaps=None,
customdata=None,
customdatasrc=None,
fill=None,
fillcolor=None,
hoverinfo=None,
hoverinfosrc=None,
hoverlabel=None,
hovertemplate=None,
hovertemplatesrc=Non... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"below",
"=",
"None",
",",
"connectgaps",
"=",
"None",
",",
"customdata",
"=",
"None",
",",
"customdatasrc",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"fillcolor",
"=",
"None",
",",
"hov... | [
1527,
4
] | [
2016,
34
] | python | en | ['en', 'error', 'th'] | False |
Unselected.marker | (self) |
The 'marker' property is an instance of Marker
that may be specified as:
- An instance of :class:`plotly.graph_objs.bar.unselected.Marker`
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
... |
The 'marker' property is an instance of Marker
that may be specified as:
- An instance of :class:`plotly.graph_objs.bar.unselected.Marker`
- A dict of string/value properties that will be passed
to the Marker constructor
Supported dict properties:
... | def marker(self):
"""
The 'marker' property is an instance of Marker
that may be specified as:
- An instance of :class:`plotly.graph_objs.bar.unselected.Marker`
- A dict of string/value properties that will be passed
to the Marker constructor
Supp... | [
"def",
"marker",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"marker\"",
"]"
] | [
15,
4
] | [
36,
29
] | python | en | ['en', 'error', 'th'] | False |
Unselected.textfont | (self) |
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.bar.unselected.Textfont`
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties... |
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.bar.unselected.Textfont`
- A dict of string/value properties that will be passed
to the Textfont constructor
Supported dict properties... | def textfont(self):
"""
The 'textfont' property is an instance of Textfont
that may be specified as:
- An instance of :class:`plotly.graph_objs.bar.unselected.Textfont`
- A dict of string/value properties that will be passed
to the Textfont constructor
... | [
"def",
"textfont",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"textfont\"",
"]"
] | [
45,
4
] | [
63,
31
] | python | en | ['en', 'error', 'th'] | False |
Unselected.__init__ | (self, arg=None, marker=None, textfont=None, **kwargs) |
Construct a new Unselected object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.bar.Unselected`
marker
:class:`plotly.graph_objects.bar.unselected... |
Construct a new Unselected object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.bar.Unselected`
marker
:class:`plotly.graph_objects.bar.unselected... | def __init__(self, arg=None, marker=None, textfont=None, **kwargs):
"""
Construct a new Unselected object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.bar.Uns... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"marker",
"=",
"None",
",",
"textfont",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Unselected",
",",
"self",
")",
".",
"__init__",
"(",
"\"unselected\"",
")",
"if",
"... | [
82,
4
] | [
147,
34
] | python | en | ['en', 'error', 'th'] | False |
roll_init | (character) |
Rolls a number between 1-1000 to determine initiative.
Args:
character (obj): The character to determine initiative for
Returns:
initiative (int): The character's place in initiative - higher
numbers go first.
Notes:
By default, does not reference the character and si... |
Rolls a number between 1-1000 to determine initiative. | def roll_init(character):
"""
Rolls a number between 1-1000 to determine initiative.
Args:
character (obj): The character to determine initiative for
Returns:
initiative (int): The character's place in initiative - higher
numbers go first.
Notes:
By default, does n... | [
"def",
"roll_init",
"(",
"character",
")",
":",
"return",
"randint",
"(",
"1",
",",
"1000",
")"
] | [
104,
0
] | [
128,
27
] | python | en | ['en', 'error', 'th'] | False |
get_attack | (attacker, defender) |
Returns a value for an attack roll.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
attack_value (int): Attack roll value, compared against a defense value
to determine whether an attack hits or misses.
Notes:
... |
Returns a value for an attack roll. | def get_attack(attacker, defender):
"""
Returns a value for an attack roll.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
attack_value (int): Attack roll value, compared against a defense value
to determine whe... | [
"def",
"get_attack",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just return a random integer up to 100.",
"attack_value",
"=",
"randint",
"(",
"1",
",",
"100",
")",
"# Add to the roll if the attacker has the \"Accuracy Up\" condition.",
"if",
"\"Accuracy U... | [
131,
0
] | [
156,
23
] | python | en | ['en', 'error', 'th'] | False |
get_defense | (attacker, defender) |
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
defense_value (int): Defense value, compared against an attack roll
... |
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit. | def get_defense(attacker, defender):
"""
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Returns:
defense_value (int): Defense ... | [
"def",
"get_defense",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just return 50, for about a 50/50 chance of hit.",
"defense_value",
"=",
"50",
"# Add to defense if the defender has the \"Defense Up\" condition.",
"if",
"\"Defense Up\"",
"in",
"defender",
".",... | [
159,
0
] | [
183,
24
] | python | en | ['en', 'error', 'th'] | False |
get_damage | (attacker, defender) |
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being damaged
Returns:
damage_value (int): Damage value, which is to be deducted from the defending
... |
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit. | def get_damage(attacker, defender):
"""
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being damaged
Returns:
damage_value (int): Damage value, wh... | [
"def",
"get_damage",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just generate a number between 15 and 25.",
"damage_value",
"=",
"randint",
"(",
"15",
",",
"25",
")",
"# Add to damage roll if attacker has the \"Damage Up\" condition.",
"if",
"\"Damage Up\"... | [
186,
0
] | [
212,
23
] | python | en | ['en', 'error', 'th'] | False |
apply_damage | (defender, damage) |
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0.
Args:
defender (obj): Character taking damage
damage (int): Amount of damage being taken
|
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0. | def apply_damage(defender, damage):
"""
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0.
Args:
defender (obj): Character taking damage
damage (int): Amount of damage being taken
"""
defender.db.hp -= damage # Reduce defender's HP by the dama... | [
"def",
"apply_damage",
"(",
"defender",
",",
"damage",
")",
":",
"defender",
".",
"db",
".",
"hp",
"-=",
"damage",
"# Reduce defender's HP by the damage dealt.",
"# If this reduces it to 0 or less, set HP to 0.",
"if",
"defender",
".",
"db",
".",
"hp",
"<=",
"0",
":... | [
215,
0
] | [
227,
26
] | python | en | ['en', 'error', 'th'] | False |
at_defeat | (defeated) |
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
into a dying state or something si... |
Announces the defeat of a fighter in combat. | def at_defeat(defeated):
"""
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
in... | [
"def",
"at_defeat",
"(",
"defeated",
")",
":",
"defeated",
".",
"location",
".",
"msg_contents",
"(",
"\"%s has been defeated!\"",
"%",
"defeated",
")"
] | [
229,
0
] | [
242,
70
] | python | en | ['en', 'error', 'th'] | False |
resolve_attack | (attacker, defender, attack_value=None, defense_value=None,
damage_value=None, inflict_condition=[]) |
Resolves an attack and outputs the result.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Options:
attack_value (int): Override for attack roll
defense_value (int): Override for defense value
damage_value (int): Overrid... |
Resolves an attack and outputs the result. | def resolve_attack(attacker, defender, attack_value=None, defense_value=None,
damage_value=None, inflict_condition=[]):
"""
Resolves an attack and outputs the result.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
Options... | [
"def",
"resolve_attack",
"(",
"attacker",
",",
"defender",
",",
"attack_value",
"=",
"None",
",",
"defense_value",
"=",
"None",
",",
"damage_value",
"=",
"None",
",",
"inflict_condition",
"=",
"[",
"]",
")",
":",
"# Get an attack roll from the attacker.",
"if",
... | [
244,
0
] | [
284,
31
] | python | en | ['en', 'error', 'th'] | False |
combat_cleanup | (character) |
Cleans up all the temporary combat-related attributes on a character.
Args:
character (obj): Character to have their combat attributes removed
Notes:
Any attribute whose key begins with 'combat_' is temporary and no
longer needed once a fight ends.
|
Cleans up all the temporary combat-related attributes on a character. | def combat_cleanup(character):
"""
Cleans up all the temporary combat-related attributes on a character.
Args:
character (obj): Character to have their combat attributes removed
Notes:
Any attribute whose key begins with 'combat_' is temporary and no
longer needed once a fight ... | [
"def",
"combat_cleanup",
"(",
"character",
")",
":",
"for",
"attr",
"in",
"character",
".",
"attributes",
".",
"all",
"(",
")",
":",
"if",
"attr",
".",
"key",
"[",
":",
"7",
"]",
"==",
"\"combat_\"",
":",
"# If the attribute name starts with 'combat_'...",
"... | [
286,
0
] | [
299,
53
] | python | en | ['en', 'error', 'th'] | False |
is_in_combat | (character) |
Returns true if the given character is in combat.
Args:
character (obj): Character to determine if is in combat or not
Returns:
(bool): True if in combat or False if not in combat
|
Returns true if the given character is in combat. | def is_in_combat(character):
"""
Returns true if the given character is in combat.
Args:
character (obj): Character to determine if is in combat or not
Returns:
(bool): True if in combat or False if not in combat
"""
return bool(character.db.combat_turnhandler) | [
"def",
"is_in_combat",
"(",
"character",
")",
":",
"return",
"bool",
"(",
"character",
".",
"db",
".",
"combat_turnhandler",
")"
] | [
302,
0
] | [
312,
48
] | python | en | ['en', 'error', 'th'] | False |
is_turn | (character) |
Returns true if it's currently the given character's turn in combat.
Args:
character (obj): Character to determine if it is their turn or not
Returns:
(bool): True if it is their turn or False otherwise
|
Returns true if it's currently the given character's turn in combat. | def is_turn(character):
"""
Returns true if it's currently the given character's turn in combat.
Args:
character (obj): Character to determine if it is their turn or not
Returns:
(bool): True if it is their turn or False otherwise
"""
turnhandler = character.db.combat_turnhandl... | [
"def",
"is_turn",
"(",
"character",
")",
":",
"turnhandler",
"=",
"character",
".",
"db",
".",
"combat_turnhandler",
"currentchar",
"=",
"turnhandler",
".",
"db",
".",
"fighters",
"[",
"turnhandler",
".",
"db",
".",
"turn",
"]",
"return",
"bool",
"(",
"cha... | [
315,
0
] | [
327,
41
] | python | en | ['en', 'error', 'th'] | False |
spend_action | (character, actions, action_name=None) |
Spends a character's available combat actions and checks for end of turn.
Args:
character (obj): Character spending the action
actions (int) or 'all': Number of actions to spend, or 'all' to spend all actions
Kwargs:
action_name (str or None): If a string is given, sets character'... |
Spends a character's available combat actions and checks for end of turn. | def spend_action(character, actions, action_name=None):
"""
Spends a character's available combat actions and checks for end of turn.
Args:
character (obj): Character spending the action
actions (int) or 'all': Number of actions to spend, or 'all' to spend all actions
Kwargs:
a... | [
"def",
"spend_action",
"(",
"character",
",",
"actions",
",",
"action_name",
"=",
"None",
")",
":",
"if",
"action_name",
":",
"character",
".",
"db",
".",
"combat_lastaction",
"=",
"action_name",
"if",
"actions",
"==",
"'all'",
":",
"# If spending all actions",
... | [
330,
0
] | [
350,
61
] | python | en | ['en', 'error', 'th'] | False |
spend_item_use | (item, user) |
Spends one use on an item with limited uses.
Args:
item (obj): Item being used
user (obj): Character using the item
Notes:
If item.db.item_consumable is 'True', the item is destroyed if it
runs out of uses - if it's a string instead of 'True', it will also
spawn a ... |
Spends one use on an item with limited uses. | def spend_item_use(item, user):
"""
Spends one use on an item with limited uses.
Args:
item (obj): Item being used
user (obj): Character using the item
Notes:
If item.db.item_consumable is 'True', the item is destroyed if it
runs out of uses - if it's a string instead o... | [
"def",
"spend_item_use",
"(",
"item",
",",
"user",
")",
":",
"item",
".",
"db",
".",
"item_uses",
"-=",
"1",
"# Spend one use",
"if",
"item",
".",
"db",
".",
"item_uses",
">",
"0",
":",
"# Has uses remaining",
"# Inform the player",
"user",
".",
"msg",
"("... | [
352,
0
] | [
387,
29
] | python | en | ['en', 'error', 'th'] | False |
use_item | (user, item, target) |
Performs the action of using an item.
Args:
user (obj): Character using the item
item (obj): Item being used
target (obj): Target of the item use
|
Performs the action of using an item. | def use_item(user, item, target):
"""
Performs the action of using an item.
Args:
user (obj): Character using the item
item (obj): Item being used
target (obj): Target of the item use
"""
# If item is self only and no target given, set target to self.
if item.db.item_sel... | [
"def",
"use_item",
"(",
"user",
",",
"item",
",",
"target",
")",
":",
"# If item is self only and no target given, set target to self.",
"if",
"item",
".",
"db",
".",
"item_selfonly",
"and",
"target",
"==",
"None",
":",
"target",
"=",
"user",
"# If item is self only... | [
389,
0
] | [
432,
49
] | python | en | ['en', 'error', 'th'] | False |
condition_tickdown | (character, turnchar) |
Ticks down the duration of conditions on a character at the start of a given character's turn.
Args:
character (obj): Character to tick down the conditions of
turnchar (obj): Character whose turn it currently is
Notes:
In combat, this is called on every fighter at the start of eve... |
Ticks down the duration of conditions on a character at the start of a given character's turn. | def condition_tickdown(character, turnchar):
"""
Ticks down the duration of conditions on a character at the start of a given character's turn.
Args:
character (obj): Character to tick down the conditions of
turnchar (obj): Character whose turn it currently is
Notes:
In combat,... | [
"def",
"condition_tickdown",
"(",
"character",
",",
"turnchar",
")",
":",
"for",
"key",
"in",
"character",
".",
"db",
".",
"conditions",
":",
"# The first value is the remaining turns - the second value is whose turn to count down on.",
"condition_duration",
"=",
"character",... | [
434,
0
] | [
460,
48
] | python | en | ['en', 'error', 'th'] | False |
add_condition | (character, turnchar, condition, duration) |
Adds a condition to a fighter.
Args:
character (obj): Character to give the condition to
turnchar (obj): Character whose turn to tick down the condition on in combat
condition (str): Name of the condition
duration (int or True): Number of turns the condition lasts, or True for ... |
Adds a condition to a fighter. | def add_condition(character, turnchar, condition, duration):
"""
Adds a condition to a fighter.
Args:
character (obj): Character to give the condition to
turnchar (obj): Character whose turn to tick down the condition on in combat
condition (str): Name of the condition
durat... | [
"def",
"add_condition",
"(",
"character",
",",
"turnchar",
",",
"condition",
",",
"duration",
")",
":",
"# The first value is the remaining turns - the second value is whose turn to count down on.",
"character",
".",
"db",
".",
"conditions",
".",
"update",
"(",
"{",
"cond... | [
462,
0
] | [
475,
92
] | python | en | ['en', 'error', 'th'] | False |
itemfunc_heal | (item, user, target, **kwargs) |
Item function that heals HP.
kwargs:
min_healing(int): Minimum amount of HP recovered
max_healing(int): Maximum amount of HP recovered
|
Item function that heals HP. | def itemfunc_heal(item, user, target, **kwargs):
"""
Item function that heals HP.
kwargs:
min_healing(int): Minimum amount of HP recovered
max_healing(int): Maximum amount of HP recovered
"""
if not target:
target = user # Target user if none specified
if not target.att... | [
"def",
"itemfunc_heal",
"(",
"item",
",",
"user",
",",
"target",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"target",
":",
"target",
"=",
"user",
"# Target user if none specified",
"if",
"not",
"target",
".",
"attributes",
".",
"has",
"(",
"\"max_hp\"... | [
1103,
0
] | [
1135,
95
] | python | en | ['en', 'error', 'th'] | False |
itemfunc_add_condition | (item, user, target, **kwargs) |
Item function that gives the target one or more conditions.
kwargs:
conditions (list): Conditions added by the item
formatted as a list of tuples: (condition (str), duration (int or True))
Notes:
Should mostly be used for beneficial conditions - use itemfunc_attack
for ... |
Item function that gives the target one or more conditions. | def itemfunc_add_condition(item, user, target, **kwargs):
"""
Item function that gives the target one or more conditions.
kwargs:
conditions (list): Conditions added by the item
formatted as a list of tuples: (condition (str), duration (int or True))
Notes:
Should mostly be ... | [
"def",
"itemfunc_add_condition",
"(",
"item",
",",
"user",
",",
"target",
",",
"*",
"*",
"kwargs",
")",
":",
"conditions",
"=",
"[",
"(",
"\"Regeneration\"",
",",
"5",
")",
"]",
"if",
"not",
"target",
":",
"target",
"=",
"user",
"# Target user if none spec... | [
1137,
0
] | [
1166,
63
] | python | en | ['en', 'error', 'th'] | False |
itemfunc_cure_condition | (item, user, target, **kwargs) |
Item function that'll remove given conditions from a target.
kwargs:
to_cure(list): List of conditions (str) that the item cures when used
|
Item function that'll remove given conditions from a target. | def itemfunc_cure_condition(item, user, target, **kwargs):
"""
Item function that'll remove given conditions from a target.
kwargs:
to_cure(list): List of conditions (str) that the item cures when used
"""
to_cure = ["Poisoned"]
if not target:
target = user # Target user if non... | [
"def",
"itemfunc_cure_condition",
"(",
"item",
",",
"user",
",",
"target",
",",
"*",
"*",
"kwargs",
")",
":",
"to_cure",
"=",
"[",
"\"Poisoned\"",
"]",
"if",
"not",
"target",
":",
"target",
"=",
"user",
"# Target user if none specified",
"if",
"not",
"target... | [
1168,
0
] | [
1196,
40
] | python | en | ['en', 'error', 'th'] | False |
itemfunc_attack | (item, user, target, **kwargs) |
Item function that attacks a target.
kwargs:
min_damage(int): Minimum damage dealt by the attack
max_damage(int): Maximum damage dealth by the attack
accuracy(int): Bonus / penalty to attack accuracy roll
inflict_condition(list): List of conditions inflicted on hit,
... |
Item function that attacks a target. | def itemfunc_attack(item, user, target, **kwargs):
"""
Item function that attacks a target.
kwargs:
min_damage(int): Minimum damage dealt by the attack
max_damage(int): Maximum damage dealth by the attack
accuracy(int): Bonus / penalty to attack accuracy roll
inflict_conditi... | [
"def",
"itemfunc_attack",
"(",
"item",
",",
"user",
",",
"target",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"user",
")",
":",
"user",
".",
"msg",
"(",
"\"You can only use that in combat.\"",
")",
"return",
"False",
"# Returning fa... | [
1198,
0
] | [
1255,
82
] | python | en | ['en', 'error', 'th'] | False |
TBItemsCharacter.at_object_creation | (self) |
Called once, when this object is first created. This is the
normal hook to overload for most object types.
|
Called once, when this object is first created. This is the
normal hook to overload for most object types.
| def at_object_creation(self):
"""
Called once, when this object is first created. This is the
normal hook to overload for most object types.
"""
self.db.max_hp = 100 # Set maximum HP to 100
self.db.hp = self.db.max_hp # Set current HP to maximum
self.db.conditio... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"self",
".",
"db",
".",
"max_hp",
"=",
"100",
"# Set maximum HP to 100",
"self",
".",
"db",
".",
"hp",
"=",
"self",
".",
"db",
".",
"max_hp",
"# Set current HP to maximum",
"self",
".",
"db",
".",
"condit... | [
490,
4
] | [
512,
11
] | python | en | ['en', 'error', 'th'] | False |
TBItemsCharacter.at_before_move | (self, destination) |
Called just before starting to move this object to
destination.
Args:
destination (Object): The object we are moving to
Returns:
shouldmove (bool): If we should move or not.
Notes:
If this method returns False/None, the move is cancelled
... |
Called just before starting to move this object to
destination. | def at_before_move(self, destination):
"""
Called just before starting to move this object to
destination.
Args:
destination (Object): The object we are moving to
Returns:
shouldmove (bool): If we should move or not.
Notes:
If this m... | [
"def",
"at_before_move",
"(",
"self",
",",
"destination",
")",
":",
"# Keep the character from moving if at 0 HP or in combat.",
"if",
"is_in_combat",
"(",
"self",
")",
":",
"self",
".",
"msg",
"(",
"\"You can't exit a room while in combat!\"",
")",
"return",
"False",
"... | [
514,
4
] | [
537,
19
] | python | en | ['en', 'error', 'th'] | False |
TBItemsCharacter.at_turn_start | (self) |
Hook called at the beginning of this character's turn in combat.
|
Hook called at the beginning of this character's turn in combat.
| def at_turn_start(self):
"""
Hook called at the beginning of this character's turn in combat.
"""
# Prompt the character for their turn and give some information.
self.msg("|wIt's your turn! You have %i HP remaining.|n" % self.db.hp)
# Apply conditions that fire at the s... | [
"def",
"at_turn_start",
"(",
"self",
")",
":",
"# Prompt the character for their turn and give some information.",
"self",
".",
"msg",
"(",
"\"|wIt's your turn! You have %i HP remaining.|n\"",
"%",
"self",
".",
"db",
".",
"hp",
")",
"# Apply conditions that fire at the start of... | [
539,
4
] | [
547,
36
] | python | en | ['en', 'error', 'th'] | False |
TBItemsCharacter.apply_turn_conditions | (self) |
Applies the effect of conditions that occur at the start of each
turn in combat, or every 30 seconds out of combat.
|
Applies the effect of conditions that occur at the start of each
turn in combat, or every 30 seconds out of combat.
| def apply_turn_conditions(self):
"""
Applies the effect of conditions that occur at the start of each
turn in combat, or every 30 seconds out of combat.
"""
# Regeneration: restores 4 to 8 HP at the start of character's turn
if "Regeneration" in self.db.conditions:
... | [
"def",
"apply_turn_conditions",
"(",
"self",
")",
":",
"# Regeneration: restores 4 to 8 HP at the start of character's turn",
"if",
"\"Regeneration\"",
"in",
"self",
".",
"db",
".",
"conditions",
":",
"to_heal",
"=",
"randint",
"(",
"REGEN_RATE",
"[",
"0",
"]",
",",
... | [
549,
4
] | [
580,
59
] | python | en | ['en', 'error', 'th'] | False |
TBItemsCharacter.at_update | (self) |
Fires every 30 seconds.
|
Fires every 30 seconds.
| def at_update(self):
"""
Fires every 30 seconds.
"""
if not is_in_combat(self): # Not in combat
# Change all conditions to update on character's turn.
for key in self.db.conditions:
self.db.conditions[key][1] = self
# Apply conditions t... | [
"def",
"at_update",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
")",
":",
"# Not in combat",
"# Change all conditions to update on character's turn.",
"for",
"key",
"in",
"self",
".",
"db",
".",
"conditions",
":",
"self",
".",
"db",
".",
"... | [
582,
4
] | [
593,
42
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.at_script_creation | (self) |
Called once, when the script is created.
|
Called once, when the script is created.
| def at_script_creation(self):
"""
Called once, when the script is created.
"""
self.key = "Combat Turn Handler"
self.interval = 5 # Once every 5 seconds
self.persistent = True
self.db.fighters = []
# Add all fighters in the room with at least 1 HP to the... | [
"def",
"at_script_creation",
"(",
"self",
")",
":",
"self",
".",
"key",
"=",
"\"Combat Turn Handler\"",
"self",
".",
"interval",
"=",
"5",
"# Once every 5 seconds",
"self",
".",
"persistent",
"=",
"True",
"self",
".",
"db",
".",
"fighters",
"=",
"[",
"]",
... | [
625,
4
] | [
659,
36
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.at_stop | (self) |
Called at script termination.
|
Called at script termination.
| def at_stop(self):
"""
Called at script termination.
"""
for fighter in self.db.fighters:
combat_cleanup(fighter) # Clean up the combat attributes for every fighter.
self.obj.db.combat_turnhandler = None | [
"def",
"at_stop",
"(",
"self",
")",
":",
"for",
"fighter",
"in",
"self",
".",
"db",
".",
"fighters",
":",
"combat_cleanup",
"(",
"fighter",
")",
"# Clean up the combat attributes for every fighter.",
"self",
".",
"obj",
".",
"db",
".",
"combat_turnhandler",
"=",... | [
661,
4
] | [
667,
45
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.at_repeat | (self) |
Called once every self.interval seconds.
|
Called once every self.interval seconds.
| def at_repeat(self):
"""
Called once every self.interval seconds.
"""
currentchar = self.db.fighters[self.db.turn] # Note the current character in the turn order.
self.db.timer -= self.interval # Count down the timer.
if self.db.timer <= 0:
# Force current ... | [
"def",
"at_repeat",
"(",
"self",
")",
":",
"currentchar",
"=",
"self",
".",
"db",
".",
"fighters",
"[",
"self",
".",
"db",
".",
"turn",
"]",
"# Note the current character in the turn order.",
"self",
".",
"db",
".",
"timer",
"-=",
"self",
".",
"interval",
... | [
669,
4
] | [
684,
48
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.initialize_for_combat | (self, character) |
Prepares a character for combat when starting or entering a fight.
Args:
character (obj): Character to initialize for combat.
|
Prepares a character for combat when starting or entering a fight. | def initialize_for_combat(self, character):
"""
Prepares a character for combat when starting or entering a fight.
Args:
character (obj): Character to initialize for combat.
"""
combat_cleanup(character) # Clean up leftover combat attributes beforehand, just in case... | [
"def",
"initialize_for_combat",
"(",
"self",
",",
"character",
")",
":",
"combat_cleanup",
"(",
"character",
")",
"# Clean up leftover combat attributes beforehand, just in case.",
"character",
".",
"db",
".",
"combat_actionsleft",
"=",
"0",
"# Actions remaining - start of tu... | [
686,
4
] | [
696,
47
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.start_turn | (self, character) |
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up.
Args:
character (obj): Character to be readied.
Notes:
Here, you only get one action per turn, but you might want to allow mo... |
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up. | def start_turn(self, character):
"""
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up.
Args:
character (obj): Character to be readied.
Notes:
Here, you only get one act... | [
"def",
"start_turn",
"(",
"self",
",",
"character",
")",
":",
"character",
".",
"db",
".",
"combat_actionsleft",
"=",
"ACTIONS_PER_TURN",
"# Replenish actions",
"# Call character's at_turn_start() hook.",
"character",
".",
"at_turn_start",
"(",
")"
] | [
698,
4
] | [
715,
33
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.next_turn | (self) |
Advances to the next character in the turn order.
|
Advances to the next character in the turn order.
| def next_turn(self):
"""
Advances to the next character in the turn order.
"""
# Check to see if every character disengaged as their last action. If so, end combat.
disengage_check = True
for fighter in self.db.fighters:
if fighter.db.combat_lastaction != "di... | [
"def",
"next_turn",
"(",
"self",
")",
":",
"# Check to see if every character disengaged as their last action. If so, end combat.",
"disengage_check",
"=",
"True",
"for",
"fighter",
"in",
"self",
".",
"db",
".",
"fighters",
":",
"if",
"fighter",
".",
"db",
".",
"comba... | [
717,
4
] | [
760,
48
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.turn_end_check | (self, character) |
Tests to see if a character's turn is over, and cycles to the next turn if it is.
Args:
character (obj): Character to test for end of turn
|
Tests to see if a character's turn is over, and cycles to the next turn if it is. | def turn_end_check(self, character):
"""
Tests to see if a character's turn is over, and cycles to the next turn if it is.
Args:
character (obj): Character to test for end of turn
"""
if not character.db.combat_actionsleft: # Character has no actions remaining
... | [
"def",
"turn_end_check",
"(",
"self",
",",
"character",
")",
":",
"if",
"not",
"character",
".",
"db",
".",
"combat_actionsleft",
":",
"# Character has no actions remaining",
"self",
".",
"next_turn",
"(",
")",
"return"
] | [
762,
4
] | [
771,
18
] | python | en | ['en', 'error', 'th'] | False |
TBItemsTurnHandler.join_fight | (self, character) |
Adds a new character to a fight already in progress.
Args:
character (obj): Character to be added to the fight.
|
Adds a new character to a fight already in progress. | def join_fight(self, character):
"""
Adds a new character to a fight already in progress.
Args:
character (obj): Character to be added to the fight.
"""
# Inserts the fighter to the turn order, right behind whoever's turn it currently is.
self.db.fighters.ins... | [
"def",
"join_fight",
"(",
"self",
",",
"character",
")",
":",
"# Inserts the fighter to the turn order, right behind whoever's turn it currently is.",
"self",
".",
"db",
".",
"fighters",
".",
"insert",
"(",
"self",
".",
"db",
".",
"turn",
",",
"character",
")",
"# T... | [
773,
4
] | [
785,
45
] | python | en | ['en', 'error', 'th'] | False |
CmdFight.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
here = self.caller.location
fighters = []
if not self.caller.db.hp: # If you don't have any hp
self.caller.msg("You can't start a fight if you've been defeated!")
return
if is_in_c... | [
"def",
"func",
"(",
"self",
")",
":",
"here",
"=",
"self",
".",
"caller",
".",
"location",
"fighters",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"caller",
".",
"db",
".",
"hp",
":",
"# If you don't have any hp",
"self",
".",
"caller",
".",
"msg",
"(",... | [
809,
4
] | [
834,
74
] | python | en | ['en', 'error', 'th'] | False |
CmdAttack.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
"Set the attacker to the caller and the defender to the target."
if not is_in_combat(self.caller): # If not in combat, can't attack.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
... | [
"def",
"func",
"(",
"self",
")",
":",
"\"Set the attacker to the caller and the defender to the target.\"",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If not in combat, can't attack.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do... | [
852,
4
] | [
888,
58
] | python | en | ['en', 'en', 'en'] | True |
CmdPass.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
if not is_in_combat(self.caller): # Can only pass a turn in combat.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # Can only pass if it'... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# Can only pass a turn in combat.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"not... | [
906,
4
] | [
919,
60
] | python | en | ['en', 'error', 'th'] | False |
CmdDisengage.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
if not is_in_combat(self.caller): # If you're not in combat
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # If it's not your turn
... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If you're not in combat",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"not",
"is... | [
938,
4
] | [
955,
11
] | python | en | ['en', 'error', 'th'] | False |
CmdRest.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
if is_in_combat(self.caller): # If you're in combat
self.caller.msg("You can't rest while you're in combat.")
return
self.caller.db.hp = self.caller.db.max_hp # Set current HP to maximum
self.caller.location.... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If you're in combat",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can't rest while you're in combat.\"",
")",
"return",
"self",
".",
"caller",
".",
"db",
... | [
972,
4
] | [
983,
11
] | python | en | ['en', 'en', 'en'] | True |
CmdUse.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
# Search for item
item = self.caller.search(self.lhs, candidates=self.caller.contents)
if not item:
return
# Search for target, if any is given
target = None
if self.rhs:
... | [
"def",
"func",
"(",
"self",
")",
":",
"# Search for item",
"item",
"=",
"self",
".",
"caller",
".",
"search",
"(",
"self",
".",
"lhs",
",",
"candidates",
"=",
"self",
".",
"caller",
".",
"contents",
")",
"if",
"not",
"item",
":",
"return",
"# Search fo... | [
1027,
4
] | [
1059,
43
] | python | en | ['en', 'error', 'th'] | False |
BattleCmdSet.at_cmdset_creation | (self) |
Populates the cmdset
|
Populates the cmdset
| def at_cmdset_creation(self):
"""
Populates the cmdset
"""
self.add(CmdFight())
self.add(CmdAttack())
self.add(CmdRest())
self.add(CmdPass())
self.add(CmdDisengage())
self.add(CmdCombatHelp())
self.add(CmdUse()) | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"self",
".",
"add",
"(",
"CmdFight",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdAttack",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdRest",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdPass",
"(... | [
1068,
4
] | [
1078,
26
] | python | en | ['en', 'error', 'th'] | False |
CharacterCmdSet.at_cmdset_creation | (self) | Populates the cmdset | Populates the cmdset | def at_cmdset_creation(self):
"Populates the cmdset"
# The general commands
self.add(general.CmdLook())
self.add(general.CmdHome())
self.add(general.CmdInventory())
self.add(general.CmdPose())
self.add(general.CmdNick())
self.add(general.CmdSetDesc())
... | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"# The general commands",
"self",
".",
"add",
"(",
"general",
".",
"CmdLook",
"(",
")",
")",
"self",
".",
"add",
"(",
"general",
".",
"CmdHome",
"(",
")",
")",
"self",
".",
"add",
"(",
"general",
".",... | [
19,
4
] | [
89,
45
] | python | en | ['en', 'sr', 'en'] | True |
SetEnvVar | (env_var, value) | Sets the env variable to 'value'; unsets it when 'value' is None. | Sets the env variable to 'value'; unsets it when 'value' is None. | def SetEnvVar(env_var, value):
"""Sets the env variable to 'value'; unsets it when 'value' is None."""
if value is not None:
os.environ[env_var] = value
elif env_var in os.environ:
del os.environ[env_var] | [
"def",
"SetEnvVar",
"(",
"env_var",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"os",
".",
"environ",
"[",
"env_var",
"]",
"=",
"value",
"elif",
"env_var",
"in",
"os",
".",
"environ",
":",
"del",
"os",
".",
"environ",
"[",
"env... | [
46,
0
] | [
52,
27
] | python | en | ['en', 'en', 'en'] | True |
UsesColor | (term, color_env_var, color_flag) | Runs gtest_color_test_ and returns its exit code. | Runs gtest_color_test_ and returns its exit code. | def UsesColor(term, color_env_var, color_flag):
"""Runs gtest_color_test_ and returns its exit code."""
SetEnvVar('TERM', term)
SetEnvVar(COLOR_ENV_VAR, color_env_var)
if color_flag is None:
args = []
else:
args = ['--%s=%s' % (COLOR_FLAG, color_flag)]
p = gtest_test_utils.Subprocess([COMMAND] + a... | [
"def",
"UsesColor",
"(",
"term",
",",
"color_env_var",
",",
"color_flag",
")",
":",
"SetEnvVar",
"(",
"'TERM'",
",",
"term",
")",
"SetEnvVar",
"(",
"COLOR_ENV_VAR",
",",
"color_env_var",
")",
"if",
"color_flag",
"is",
"None",
":",
"args",
"=",
"[",
"]",
... | [
55,
0
] | [
66,
36
] | python | en | ['en', 'en', 'en'] | True |
GTestColorTest.testNoEnvVarNoFlag | (self) | Tests the case when there's neither GTEST_COLOR nor --gtest_color. | Tests the case when there's neither GTEST_COLOR nor --gtest_color. | def testNoEnvVarNoFlag(self):
"""Tests the case when there's neither GTEST_COLOR nor --gtest_color."""
if not IS_WINDOWS:
self.assert_(not UsesColor('dumb', None, None))
self.assert_(not UsesColor('emacs', None, None))
self.assert_(not UsesColor('xterm-mono', None, None))
self.assert_(n... | [
"def",
"testNoEnvVarNoFlag",
"(",
"self",
")",
":",
"if",
"not",
"IS_WINDOWS",
":",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'dumb'",
",",
"None",
",",
"None",
")",
")",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'emacs'",
","... | [
70,
2
] | [
83,
57
] | python | en | ['en', 'en', 'en'] | True |
GTestColorTest.testFlagOnly | (self) | Tests the case when there's --gtest_color but not GTEST_COLOR. | Tests the case when there's --gtest_color but not GTEST_COLOR. | def testFlagOnly(self):
"""Tests the case when there's --gtest_color but not GTEST_COLOR."""
self.assert_(not UsesColor('dumb', None, 'no'))
self.assert_(not UsesColor('xterm-color', None, 'no'))
if not IS_WINDOWS:
self.assert_(not UsesColor('emacs', None, 'auto'))
self.assert_(UsesColor('xte... | [
"def",
"testFlagOnly",
"(",
"self",
")",
":",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'dumb'",
",",
"None",
",",
"'no'",
")",
")",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'xterm-color'",
",",
"None",
",",
"'no'",
")",
")... | [
85,
2
] | [
94,
49
] | python | en | ['en', 'en', 'en'] | True |
GTestColorTest.testEnvVarOnly | (self) | Tests the case when there's GTEST_COLOR but not --gtest_color. | Tests the case when there's GTEST_COLOR but not --gtest_color. | def testEnvVarOnly(self):
"""Tests the case when there's GTEST_COLOR but not --gtest_color."""
self.assert_(not UsesColor('dumb', 'no', None))
self.assert_(not UsesColor('xterm-color', 'no', None))
if not IS_WINDOWS:
self.assert_(not UsesColor('dumb', 'auto', None))
self.assert_(UsesColor('xt... | [
"def",
"testEnvVarOnly",
"(",
"self",
")",
":",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'dumb'",
",",
"'no'",
",",
"None",
")",
")",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'xterm-color'",
",",
"'no'",
",",
"None",
")",
... | [
96,
2
] | [
105,
55
] | python | en | ['en', 'en', 'en'] | True |
GTestColorTest.testEnvVarAndFlag | (self) | Tests the case when there are both GTEST_COLOR and --gtest_color. | Tests the case when there are both GTEST_COLOR and --gtest_color. | def testEnvVarAndFlag(self):
"""Tests the case when there are both GTEST_COLOR and --gtest_color."""
self.assert_(not UsesColor('xterm-color', 'no', 'no'))
self.assert_(UsesColor('dumb', 'no', 'yes'))
self.assert_(UsesColor('xterm-color', 'no', 'auto')) | [
"def",
"testEnvVarAndFlag",
"(",
"self",
")",
":",
"self",
".",
"assert_",
"(",
"not",
"UsesColor",
"(",
"'xterm-color'",
",",
"'no'",
",",
"'no'",
")",
")",
"self",
".",
"assert_",
"(",
"UsesColor",
"(",
"'dumb'",
",",
"'no'",
",",
"'yes'",
")",
")",
... | [
107,
2
] | [
112,
56
] | python | en | ['en', 'en', 'en'] | True |
GTestColorTest.testAliasesOfYesAndNo | (self) | Tests using aliases in specifying --gtest_color. | Tests using aliases in specifying --gtest_color. | def testAliasesOfYesAndNo(self):
"""Tests using aliases in specifying --gtest_color."""
self.assert_(UsesColor('dumb', None, 'true'))
self.assert_(UsesColor('dumb', None, 'YES'))
self.assert_(UsesColor('dumb', None, 'T'))
self.assert_(UsesColor('dumb', None, '1'))
self.assert_(not UsesColor('x... | [
"def",
"testAliasesOfYesAndNo",
"(",
"self",
")",
":",
"self",
".",
"assert_",
"(",
"UsesColor",
"(",
"'dumb'",
",",
"None",
",",
"'true'",
")",
")",
"self",
".",
"assert_",
"(",
"UsesColor",
"(",
"'dumb'",
",",
"None",
",",
"'YES'",
")",
")",
"self",
... | [
114,
2
] | [
125,
57
] | python | en | ['en', 'en', 'en'] | True |
TestForwardInvitation.test_init | (self) | Test initialization. | Test initialization. | def test_init(self):
"""Test initialization."""
assert self.invitation.invitation == self.connection_invitation
assert self.invitation.message == self.test_message | [
"def",
"test_init",
"(",
"self",
")",
":",
"assert",
"self",
".",
"invitation",
".",
"invitation",
"==",
"self",
".",
"connection_invitation",
"assert",
"self",
".",
"invitation",
".",
"message",
"==",
"self",
".",
"test_message"
] | [
28,
4
] | [
31,
59
] | python | co | ['es', 'co', 'en'] | False |
TestForwardInvitation.test_deserialize | (self, mock_invitation_schema_load) |
Test deserialization.
|
Test deserialization.
| def test_deserialize(self, mock_invitation_schema_load):
"""
Test deserialization.
"""
obj = {"obj": "obj"}
invitation = ForwardInvitation.deserialize(obj)
mock_invitation_schema_load.assert_called_once_with(obj)
assert invitation is mock_invitation_schema_load.... | [
"def",
"test_deserialize",
"(",
"self",
",",
"mock_invitation_schema_load",
")",
":",
"obj",
"=",
"{",
"\"obj\"",
":",
"\"obj\"",
"}",
"invitation",
"=",
"ForwardInvitation",
".",
"deserialize",
"(",
"obj",
")",
"mock_invitation_schema_load",
".",
"assert_called_onc... | [
41,
4
] | [
50,
69
] | python | en | ['en', 'error', 'th'] | False |
TestForwardInvitation.test_serialize | (self, mock_invitation_schema_dump) |
Test serialization.
|
Test serialization.
| def test_serialize(self, mock_invitation_schema_dump):
"""
Test serialization.
"""
invitation_dict = self.invitation.serialize()
mock_invitation_schema_dump.assert_called_once_with(self.invitation)
assert invitation_dict is mock_invitation_schema_dump.return_value | [
"def",
"test_serialize",
"(",
"self",
",",
"mock_invitation_schema_dump",
")",
":",
"invitation_dict",
"=",
"self",
".",
"invitation",
".",
"serialize",
"(",
")",
"mock_invitation_schema_dump",
".",
"assert_called_once_with",
"(",
"self",
".",
"invitation",
")",
"as... | [
56,
4
] | [
63,
74
] | python | en | ['en', 'error', 'th'] | False |
test_init_state_from_ledger | (write_manager,
db_manager,
constraint_serializer,
prepare_request) | Add txn to ledger | Add txn to ledger | def test_init_state_from_ledger(write_manager,
db_manager,
constraint_serializer,
prepare_request):
reset_state(db_manager, CONFIG_LEDGER_ID)
req_count = 1
action, constraint, request = prepare_request
txn = ... | [
"def",
"test_init_state_from_ledger",
"(",
"write_manager",
",",
"db_manager",
",",
"constraint_serializer",
",",
"prepare_request",
")",
":",
"reset_state",
"(",
"db_manager",
",",
"CONFIG_LEDGER_ID",
")",
"req_count",
"=",
"1",
"action",
",",
"constraint",
",",
"r... | [
79,
0
] | [
113,
70
] | python | en | ['en', 'ht', 'en'] | True |
Marker.color | (self) |
Sets the marker color of unselected points, applied only when a
selection exists.
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%)')
... |
Sets the marker color of unselected points, applied only when a
selection exists.
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%)')
... | def color(self):
"""
Sets the marker color of unselected points, applied only when a
selection exists.
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 stri... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
66,
28
] | python | en | ['en', 'error', 'th'] | False |
Marker.opacity | (self) |
Sets the marker opacity of unselected points, applied only when
a selection exists.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
|
Sets the marker opacity of unselected points, applied only when
a selection exists.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1] | def opacity(self):
"""
Sets the marker opacity of unselected points, applied only when
a selection exists.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
"""
... | [
"def",
"opacity",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacity\"",
"]"
] | [
75,
4
] | [
87,
30
] | python | en | ['en', 'error', 'th'] | False |
Marker.__init__ | (self, arg=None, color=None, opacity=None, **kwargs) |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.histogram.unselected.Marker`
color
Sets the marker color of unselected... |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.histogram.unselected.Marker`
color
Sets the marker color of unselected... | def __init__(self, arg=None, color=None, opacity=None, **kwargs):
"""
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.histogram.uns... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"opacity",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Marker",
",",
"self",
")",
".",
"__init__",
"(",
"\"marker\"",
")",
"if",
"\"_parent\... | [
106,
4
] | [
171,
34
] | python | en | ['en', 'error', 'th'] | False |
_draw_points | (points,
vis,
points_size=2,
point_color=(0.5, 0.5, 0.5),
mode='xyz') | Draw points on visualizer.
Args:
points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize.
vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer.
points_size (int): the size of points to show on visualizer.
Default: 2.
point_color (t... | Draw points on visualizer. | def _draw_points(points,
vis,
points_size=2,
point_color=(0.5, 0.5, 0.5),
mode='xyz'):
"""Draw points on visualizer.
Args:
points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize.
vis (:obj:`open3d.... | [
"def",
"_draw_points",
"(",
"points",
",",
"vis",
",",
"points_size",
"=",
"2",
",",
"point_color",
"=",
"(",
"0.5",
",",
"0.5",
",",
"0.5",
")",
",",
"mode",
"=",
"'xyz'",
")",
":",
"vis",
".",
"get_render_option",
"(",
")",
".",
"point_size",
"=",
... | [
13,
0
] | [
52,
29
] | python | en | ['en', 'en', 'en'] | True |
_draw_bboxes | (bbox3d,
vis,
points_colors,
pcd=None,
bbox_color=(0, 1, 0),
points_in_box_color=(1, 0, 0),
rot_axis=2,
center_mode='lidar_bottom',
mode='xyz') | Draw bbox on visualizer and change the color of points inside bbox3d.
Args:
bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize.
vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer.
points_colors (numpy.array): color of ... | Draw bbox on visualizer and change the color of points inside bbox3d. | def _draw_bboxes(bbox3d,
vis,
points_colors,
pcd=None,
bbox_color=(0, 1, 0),
points_in_box_color=(1, 0, 0),
rot_axis=2,
center_mode='lidar_bottom',
mode='xyz'):
"""Draw bbox on vis... | [
"def",
"_draw_bboxes",
"(",
"bbox3d",
",",
"vis",
",",
"points_colors",
",",
"pcd",
"=",
"None",
",",
"bbox_color",
"=",
"(",
"0",
",",
"1",
",",
"0",
")",
",",
"points_in_box_color",
"=",
"(",
"1",
",",
"0",
",",
"0",
")",
",",
"rot_axis",
"=",
... | [
55,
0
] | [
115,
32
] | python | en | ['en', 'en', 'en'] | True |
show_pts_boxes | (points,
bbox3d=None,
show=True,
save_path=None,
points_size=2,
point_color=(0.5, 0.5, 0.5),
bbox_color=(0, 1, 0),
points_in_box_color=(1, 0, 0),
rot_axis=2,
... | Draw bbox and points on visualizer.
Args:
points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize.
bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize. Default: None.
show (bool): whether to show the vis... | Draw bbox and points on visualizer. | def show_pts_boxes(points,
bbox3d=None,
show=True,
save_path=None,
points_size=2,
point_color=(0.5, 0.5, 0.5),
bbox_color=(0, 1, 0),
points_in_box_color=(1, 0, 0),
rot_... | [
"def",
"show_pts_boxes",
"(",
"points",
",",
"bbox3d",
"=",
"None",
",",
"show",
"=",
"True",
",",
"save_path",
"=",
"None",
",",
"points_size",
"=",
"2",
",",
"point_color",
"=",
"(",
"0.5",
",",
"0.5",
",",
"0.5",
")",
",",
"bbox_color",
"=",
"(",
... | [
118,
0
] | [
177,
24
] | python | en | ['en', 'en', 'en'] | True |
_draw_bboxes_ind | (bbox3d,
vis,
indices,
points_colors,
pcd=None,
bbox_color=(0, 1, 0),
points_in_box_color=(1, 0, 0),
rot_axis=2,
center_mode='lidar_bottom',
... | Draw bbox on visualizer and change the color or points inside bbox3d
with indices.
Args:
bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize.
vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer.
indices (numpy.array ... | Draw bbox on visualizer and change the color or points inside bbox3d
with indices. | def _draw_bboxes_ind(bbox3d,
vis,
indices,
points_colors,
pcd=None,
bbox_color=(0, 1, 0),
points_in_box_color=(1, 0, 0),
rot_axis=2,
center_mode='lidar_... | [
"def",
"_draw_bboxes_ind",
"(",
"bbox3d",
",",
"vis",
",",
"indices",
",",
"points_colors",
",",
"pcd",
"=",
"None",
",",
"bbox_color",
"=",
"(",
"0",
",",
"1",
",",
"0",
")",
",",
"points_in_box_color",
"=",
"(",
"1",
",",
"0",
",",
"0",
")",
",",... | [
180,
0
] | [
247,
32
] | python | en | ['en', 'en', 'en'] | True |
show_pts_index_boxes | (points,
bbox3d=None,
show=True,
indices=None,
save_path=None,
points_size=2,
point_color=(0.5, 0.5, 0.5),
bbox_color=(0, 1, 0),
... | Draw bbox and points on visualizer with indices that indicate which
bbox3d that each point lies in.
Args:
points (numpy.array | torch.tensor, shape=[N, 3+C]):
points to visualize.
bbox3d (numpy.array | torch.tensor, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to vi... | Draw bbox and points on visualizer with indices that indicate which
bbox3d that each point lies in. | def show_pts_index_boxes(points,
bbox3d=None,
show=True,
indices=None,
save_path=None,
points_size=2,
point_color=(0.5, 0.5, 0.5),
bbox_color=(0,... | [
"def",
"show_pts_index_boxes",
"(",
"points",
",",
"bbox3d",
"=",
"None",
",",
"show",
"=",
"True",
",",
"indices",
"=",
"None",
",",
"save_path",
"=",
"None",
",",
"points_size",
"=",
"2",
",",
"point_color",
"=",
"(",
"0.5",
",",
"0.5",
",",
"0.5",
... | [
250,
0
] | [
313,
24
] | python | en | ['en', 'en', 'en'] | True |
project_pts_on_img | (points,
raw_img,
lidar2img_rt,
max_distance=70,
thickness=-1) | Project the 3D points cloud on 2D image.
Args:
points (numpy.array): 3D points cloud (x, y, z) to visualize.
raw_img (numpy.array): The numpy array of image.
lidar2img_rt (numpy.array, shape=[4, 4]): The projection matrix
according to the camera intrinsic parameters.
max... | Project the 3D points cloud on 2D image. | def project_pts_on_img(points,
raw_img,
lidar2img_rt,
max_distance=70,
thickness=-1):
"""Project the 3D points cloud on 2D image.
Args:
points (numpy.array): 3D points cloud (x, y, z) to visualize.
raw_i... | [
"def",
"project_pts_on_img",
"(",
"points",
",",
"raw_img",
",",
"lidar2img_rt",
",",
"max_distance",
"=",
"70",
",",
"thickness",
"=",
"-",
"1",
")",
":",
"img",
"=",
"raw_img",
".",
"copy",
"(",
")",
"num_points",
"=",
"points",
".",
"shape",
"[",
"0... | [
316,
0
] | [
364,
20
] | python | en | ['en', 'fr', 'en'] | True |
project_bbox3d_on_img | (bboxes3d,
raw_img,
lidar2img_rt,
color=(0, 255, 0),
thickness=1) | Project the 3D bbox on 2D image.
Args:
bboxes3d (numpy.array, shape=[M, 7]):
3d bbox (x, y, z, dx, dy, dz, yaw) to visualize.
raw_img (numpy.array): The numpy array of image.
lidar2img_rt (numpy.array, shape=[4, 4]): The projection matrix
according to the camera intr... | Project the 3D bbox on 2D image. | def project_bbox3d_on_img(bboxes3d,
raw_img,
lidar2img_rt,
color=(0, 255, 0),
thickness=1):
"""Project the 3D bbox on 2D image.
Args:
bboxes3d (numpy.array, shape=[M, 7]):
3d bbox (x, y, ... | [
"def",
"project_bbox3d_on_img",
"(",
"bboxes3d",
",",
"raw_img",
",",
"lidar2img_rt",
",",
"color",
"=",
"(",
"0",
",",
"255",
",",
"0",
")",
",",
"thickness",
"=",
"1",
")",
":",
"img",
"=",
"raw_img",
".",
"copy",
"(",
")",
"corners_3d",
"=",
"bbox... | [
367,
0
] | [
406,
18
] | python | en | ['en', 'en', 'en'] | True |
Visualizer.add_bboxes | (self, bbox3d, bbox_color=None, points_in_box_color=None) | Add bounding box to visualizer.
Args:
bbox3d (numpy.array, shape=[M, 7]):
3D bbox (x, y, z, dx, dy, dz, yaw) to be visualized.
The 3d bbox is in mode of Box3DMode.DEPTH with
gravity_center (please refer to core.structures.box_3d_mode).
bbo... | Add bounding box to visualizer. | def add_bboxes(self, bbox3d, bbox_color=None, points_in_box_color=None):
"""Add bounding box to visualizer.
Args:
bbox3d (numpy.array, shape=[M, 7]):
3D bbox (x, y, z, dx, dy, dz, yaw) to be visualized.
The 3d bbox is in mode of Box3DMode.DEPTH with
... | [
"def",
"add_bboxes",
"(",
"self",
",",
"bbox3d",
",",
"bbox_color",
"=",
"None",
",",
"points_in_box_color",
"=",
"None",
")",
":",
"if",
"bbox_color",
"is",
"None",
":",
"bbox_color",
"=",
"self",
".",
"bbox_color",
"if",
"points_in_box_color",
"is",
"None"... | [
476,
4
] | [
494,
49
] | python | en | ['en', 'ny', 'en'] | True |
Visualizer.show | (self, save_path=None) | Visualize the points cloud.
Args:
save_path (str): path to save image. Default: None.
| Visualize the points cloud. | def show(self, save_path=None):
"""Visualize the points cloud.
Args:
save_path (str): path to save image. Default: None.
"""
self.o3d_visualizer.run()
if save_path is not None:
self.o3d_visualizer.capture_screen_image(save_path)
self.o3d_visual... | [
"def",
"show",
"(",
"self",
",",
"save_path",
"=",
"None",
")",
":",
"self",
".",
"o3d_visualizer",
".",
"run",
"(",
")",
"if",
"save_path",
"is",
"not",
"None",
":",
"self",
".",
"o3d_visualizer",
".",
"capture_screen_image",
"(",
"save_path",
")",
"sel... | [
496,
4
] | [
509,
14
] | python | en | ['en', 'en', 'en'] | True |
Lobby.antiraid | (self, ctx) | Enable antiraid to prevent new users from accessing the rest of the server. | Enable antiraid to prevent new users from accessing the rest of the server. | async def antiraid(self, ctx):
"""Enable antiraid to prevent new users from accessing the rest of the server."""
try:
await ctx.message.delete()
except discord.errors.NotFound:
pass
channel = discord.utils.get(ctx.guild.channels, name=self.lobby_channel)
... | [
"async",
"def",
"antiraid",
"(",
"self",
",",
"ctx",
")",
":",
"try",
":",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")",
"except",
"discord",
".",
"errors",
".",
"NotFound",
":",
"pass",
"channel",
"=",
"discord",
".",
"utils",
".",
"get",... | [
58,
4
] | [
72,
43
] | python | en | ['en', 'en', 'en'] | True |
Lobby.antiraid_off | (self, ctx) | Disable antiraid. | Disable antiraid. | async def antiraid_off(self, ctx):
"""Disable antiraid."""
try:
await ctx.message.delete()
except discord.errors.NotFound:
pass
channel = discord.utils.get(ctx.guild.channels, name=self.lobby_channel)
overwrite = dict(channel.overwrites)[ctx.guild.defau... | [
"async",
"def",
"antiraid_off",
"(",
"self",
",",
"ctx",
")",
":",
"try",
":",
"await",
"ctx",
".",
"message",
".",
"delete",
"(",
")",
"except",
"discord",
".",
"errors",
".",
"NotFound",
":",
"pass",
"channel",
"=",
"discord",
".",
"utils",
".",
"g... | [
78,
4
] | [
92,
44
] | python | en | ['en', 'gd', 'en'] | False |
send_notification | (line) | Send a message to IRC channel via HTTP bridge.
Ars:
line (str): message to send
| Send a message to IRC channel via HTTP bridge. | def send_notification(line):
"""Send a message to IRC channel via HTTP bridge.
Ars:
line (str): message to send
"""
print('> ' + line)
try:
response = requests.post(SERENITY_BOT, data={'msg': line})
except BaseException as e:
print('Notification failed: {}: {}'.format(t... | [
"def",
"send_notification",
"(",
"line",
")",
":",
"print",
"(",
"'> '",
"+",
"line",
")",
"try",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"SERENITY_BOT",
",",
"data",
"=",
"{",
"'msg'",
":",
"line",
"}",
")",
"except",
"BaseException",
"as"... | [
84,
0
] | [
97,
74
] | python | en | ['en', 'fr', 'en'] | True |
FastAcuteExecutor.__init__ | (self, args: DictConfig, model_config: Optional[Dict[str, Any]] = None) |
Pass in model_config directly to override the model config file,
args.mephisto.blueprint, that would be read in otherwise.
|
Pass in model_config directly to override the model config file,
args.mephisto.blueprint, that would be read in otherwise.
| def __init__(self, args: DictConfig, model_config: Optional[Dict[str, Any]] = None):
"""
Pass in model_config directly to override the model config file,
args.mephisto.blueprint, that would be read in otherwise.
"""
self.args = args
self.fast_acute_args = self.args.mephi... | [
"def",
"__init__",
"(",
"self",
",",
"args",
":",
"DictConfig",
",",
"model_config",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
":",
"self",
".",
"args",
"=",
"args",
"self",
".",
"fast_acute_args",
"=",
"self",... | [
78,
4
] | [
106,
55
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._build_model_pairs | (self) |
Generate self.models and self.combos from self.args.
|
Generate self.models and self.combos from self.args.
| def _build_model_pairs(self):
"""
Generate self.models and self.combos from self.args.
"""
choices = self.model_config.keys()
combos: Set[Tuple[str, str]] = set()
models: Set[str] = set()
if (
self.fast_acute_args.models is None
and self.fa... | [
"def",
"_build_model_pairs",
"(",
"self",
")",
":",
"choices",
"=",
"self",
".",
"model_config",
".",
"keys",
"(",
")",
"combos",
":",
"Set",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
"=",
"set",
"(",
")",
"models",
":",
"Set",
"[",
"str",
... | [
111,
4
] | [
144,
66
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._print_progress | (self, msg: str) |
Format a msg to print to stdout well.
:param msg:
message to print
|
Format a msg to print to stdout well. | def _print_progress(self, msg: str):
"""
Format a msg to print to stdout well.
:param msg:
message to print
"""
print(f"\n{'-' * 60}\n {msg} \n {'-' * 60}") | [
"def",
"_print_progress",
"(",
"self",
",",
"msg",
":",
"str",
")",
":",
"print",
"(",
"f\"\\n{'-' * 60}\\n {msg} \\n {'-' * 60}\"",
")"
] | [
146,
4
] | [
153,
52
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._get_selfchat_config | (self, model: str) |
Return config for selfchat.
:param model:
model string
:return config:
dict config for self-chat
|
Return config for selfchat. | def _get_selfchat_config(self, model: str) -> Dict[str, Any]:
"""
Return config for selfchat.
:param model:
model string
:return config:
dict config for self-chat
"""
outfile = self._get_selfchat_log_path(model)
config = self.model_config... | [
"def",
"_get_selfchat_config",
"(",
"self",
",",
"model",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"outfile",
"=",
"self",
".",
"_get_selfchat_log_path",
"(",
"model",
")",
"config",
"=",
"self",
".",
"model_config",
"[",
"model",... | [
155,
4
] | [
178,
21
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._get_task_conversion_config | (self, model: str) |
Return config for task conversion to conversation format.
|
Return config for task conversion to conversation format.
| def _get_task_conversion_config(self, model: str) -> Dict[str, Any]:
"""
Return config for task conversion to conversation format.
"""
outfile = self._get_task_data_path(model)
config = self.model_config[model]
config.update(
{
'outfile': outfi... | [
"def",
"_get_task_conversion_config",
"(",
"self",
",",
"model",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"outfile",
"=",
"self",
".",
"_get_task_data_path",
"(",
"model",
")",
"config",
"=",
"self",
".",
"model_config",
"[",
"mod... | [
180,
4
] | [
194,
21
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor.get_relative_selfchat_log_path | (root_dir: str, model: str, task: str) |
Return path to selfchat log for a given model, given inputs.
Useful for getting selfchat log path without instantiating the exector.
|
Return path to selfchat log for a given model, given inputs. | def get_relative_selfchat_log_path(root_dir: str, model: str, task: str) -> str:
"""
Return path to selfchat log for a given model, given inputs.
Useful for getting selfchat log path without instantiating the exector.
"""
self_chats_folder = os.path.join(root_dir, 'self_chats')
... | [
"def",
"get_relative_selfchat_log_path",
"(",
"root_dir",
":",
"str",
",",
"model",
":",
"str",
",",
"task",
":",
"str",
")",
"->",
"str",
":",
"self_chats_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_dir",
",",
"'self_chats'",
")",
"os",
"."... | [
197,
4
] | [
207,
9
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._get_log_path | (self, model: str) |
Return path to chat logs for the given model.
|
Return path to chat logs for the given model.
| def _get_log_path(self, model: str) -> str:
"""
Return path to chat logs for the given model.
"""
config = self.model_config[model]
if 'log_path' in config:
path = config['log_path']
assert os.path.exists(
path
), f'Path provide... | [
"def",
"_get_log_path",
"(",
"self",
",",
"model",
":",
"str",
")",
"->",
"str",
":",
"config",
"=",
"self",
".",
"model_config",
"[",
"model",
"]",
"if",
"'log_path'",
"in",
"config",
":",
"path",
"=",
"config",
"[",
"'log_path'",
"]",
"assert",
"os",... | [
209,
4
] | [
226,
19
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._get_task_data_path | (self, model: str) |
Return path to task data as conversations for given task.
|
Return path to task data as conversations for given task.
| def _get_task_data_path(self, model: str) -> str:
"""
Return path to task data as conversations for given task.
"""
task_data_dir = os.path.join(
self.fast_acute_args.root_dir, 'tasks_as_conversations'
)
os.makedirs(task_data_dir, exist_ok=True)
return... | [
"def",
"_get_task_data_path",
"(",
"self",
",",
"model",
":",
"str",
")",
"->",
"str",
":",
"task_data_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"fast_acute_args",
".",
"root_dir",
",",
"'tasks_as_conversations'",
")",
"os",
".",
"makedi... | [
228,
4
] | [
236,
60
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._get_selfchat_log_path | (self, model: str) |
Return path to selfchat log for a given model.
:param model:
model string
|
Return path to selfchat log for a given model. | def _get_selfchat_log_path(self, model: str) -> str:
"""
Return path to selfchat log for a given model.
:param model:
model string
"""
return self.get_relative_selfchat_log_path(
root_dir=self.fast_acute_args.root_dir, model=model, task=self.task
... | [
"def",
"_get_selfchat_log_path",
"(",
"self",
",",
"model",
":",
"str",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_relative_selfchat_log_path",
"(",
"root_dir",
"=",
"self",
".",
"fast_acute_args",
".",
"root_dir",
",",
"model",
"=",
"model",
",",
"t... | [
238,
4
] | [
247,
9
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._acutify_convo | (
self, dialogue_dict: Dict[str, Any], model: str
) |
Format world-logged conversation to be ACUTE format.
:param dialogue_dict:
dictionary containing the dialogue for a model
:param model:
model string
:return conversation:
An ACUTE-Readable conversation
|
Format world-logged conversation to be ACUTE format. | def _acutify_convo(
self, dialogue_dict: Dict[str, Any], model: str
) -> Dict[str, List]:
"""
Format world-logged conversation to be ACUTE format.
:param dialogue_dict:
dictionary containing the dialogue for a model
:param model:
model string
... | [
"def",
"_acutify_convo",
"(",
"self",
",",
"dialogue_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"model",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"]",
":",
"is_selfchat",
"=",
"'model'",
"in",
"self",
".",
"model_config",
"[... | [
249,
4
] | [
286,
27
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._load_selfchats | (self) |
Load selfchats for models.
:return conversations:
A dictionary mapping model_id to self-chat dialogues
|
Load selfchats for models. | def _load_selfchats(self) -> Dict[str, List[Dict[str, Any]]]:
"""
Load selfchats for models.
:return conversations:
A dictionary mapping model_id to self-chat dialogues
"""
conversations = {}
for m in self.models:
model_fp = self.chat_files[m]
... | [
"def",
"_load_selfchats",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"]",
":",
"conversations",
"=",
"{",
"}",
"for",
"m",
"in",
"self",
".",
"models",
":",
"model_fp",
"=",
"self",
"."... | [
288,
4
] | [
302,
28
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._build_conversation_pairs | (
self, conversations: Dict[str, List[Dict[str, Any]]]
) |
Build a conversation pair to show during ACUTE Eval.
:param conversations:
A dictionary mapping model_id to self-chat dialogues
:return pairs:
A list of conversation pairs
|
Build a conversation pair to show during ACUTE Eval. | def _build_conversation_pairs(
self, conversations: Dict[str, List[Dict[str, Any]]]
) -> List[Dict[str, Any]]:
"""
Build a conversation pair to show during ACUTE Eval.
:param conversations:
A dictionary mapping model_id to self-chat dialogues
:return pairs:
... | [
"def",
"_build_conversation_pairs",
"(",
"self",
",",
"conversations",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"]",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"self",
".",
"... | [
311,
4
] | [
351,
20
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._build_pairings_file | (self, pairings_filepath: str) |
Build and save pairings to pairings file.
|
Build and save pairings to pairings file.
| def _build_pairings_file(self, pairings_filepath: str):
"""
Build and save pairings to pairings file.
"""
if self.fast_acute_args.onboarding_path is not None:
onboarding_path = self.fast_acute_args.onboarding_path
else:
# Default onboarding location
... | [
"def",
"_build_pairings_file",
"(",
"self",
",",
"pairings_filepath",
":",
"str",
")",
":",
"if",
"self",
".",
"fast_acute_args",
".",
"onboarding_path",
"is",
"not",
"None",
":",
"onboarding_path",
"=",
"self",
".",
"fast_acute_args",
".",
"onboarding_path",
"e... | [
353,
4
] | [
376,
48
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._load_pairings_file | (self) |
Build the pairings file for the two models.
If a pairings file already exists, we ask the user whether they would like to
overwrite the pairings file.
|
Build the pairings file for the two models. | def _load_pairings_file(self):
"""
Build the pairings file for the two models.
If a pairings file already exists, we ask the user whether they would like to
overwrite the pairings file.
"""
pairings_filepath = get_hashed_combo_path(
root_dir=self.fast_acute_a... | [
"def",
"_load_pairings_file",
"(",
"self",
")",
":",
"pairings_filepath",
"=",
"get_hashed_combo_path",
"(",
"root_dir",
"=",
"self",
".",
"fast_acute_args",
".",
"root_dir",
",",
"subdir",
"=",
"'pairings_files'",
",",
"task",
"=",
"self",
".",
"task",
",",
"... | [
378,
4
] | [
406,
50
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor._convert_task_to_conversations | (self, model: str) |
Convert task data to conversations format.
|
Convert task data to conversations format.
| def _convert_task_to_conversations(self, model: str):
"""
Convert task data to conversations format.
"""
self._print_progress(
f'Converting task data to conversations format for {model}'
)
config = self._get_task_conversion_config(model)
with capture_... | [
"def",
"_convert_task_to_conversations",
"(",
"self",
",",
"model",
":",
"str",
")",
":",
"self",
".",
"_print_progress",
"(",
"f'Converting task data to conversations format for {model}'",
")",
"config",
"=",
"self",
".",
"_get_task_conversion_config",
"(",
"model",
")... | [
408,
4
] | [
421,
30
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor.compile_chat_logs | (self) |
Compile chat logs.
Logs are generated depending on what is specified in the config for the model:
1. If a `model` is provided, run selfchat for model
2. If a `log_path` is provided, simply load the log path
3. If a `task` is provided, convert the task to ACUTE format and load t... |
Compile chat logs. | def compile_chat_logs(self):
"""
Compile chat logs.
Logs are generated depending on what is specified in the config for the model:
1. If a `model` is provided, run selfchat for model
2. If a `log_path` is provided, simply load the log path
3. If a `task` is provided, con... | [
"def",
"compile_chat_logs",
"(",
"self",
")",
":",
"for",
"model",
"in",
"self",
".",
"models",
":",
"try",
":",
"torch",
".",
"cuda",
".",
"empty_cache",
"(",
")",
"except",
"Exception",
":",
"pass",
"self",
".",
"_print_progress",
"(",
"f'Running self-ch... | [
426,
4
] | [
462,
44
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor.run_acute_eval | (self) |
Run ACUTE Eval.
|
Run ACUTE Eval.
| def run_acute_eval(self):
"""
Run ACUTE Eval.
"""
self.set_up_acute_eval()
db, cfg = load_db_and_process_config(self.args)
print(f'*** RUN ID: {cfg.mephisto.task.task_name} ***')
operator = Operator(db)
operator.validate_and_run_config(run_config=cfg.mephi... | [
"def",
"run_acute_eval",
"(",
"self",
")",
":",
"self",
".",
"set_up_acute_eval",
"(",
")",
"db",
",",
"cfg",
"=",
"load_db_and_process_config",
"(",
"self",
".",
"args",
")",
"print",
"(",
"f'*** RUN ID: {cfg.mephisto.task.task_name} ***'",
")",
"operator",
"=",
... | [
464,
4
] | [
475,
9
] | python | en | ['en', 'error', 'th'] | False |
FastAcuteExecutor.analyze_results | (self, args: Optional[str] = None) |
Analyze results of ACUTE Eval run, using the optional input args.
Save results to appropriate filepath.
|
Analyze results of ACUTE Eval run, using the optional input args. | def analyze_results(self, args: Optional[str] = None):
"""
Analyze results of ACUTE Eval run, using the optional input args.
Save results to appropriate filepath.
"""
self._print_progress(f'Analyzing Results for run id {self.run_id}')
parser = analysis_setup_args()
... | [
"def",
"analyze_results",
"(",
"self",
",",
"args",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
":",
"self",
".",
"_print_progress",
"(",
"f'Analyzing Results for run id {self.run_id}'",
")",
"parser",
"=",
"analysis_setup_args",
"(",
")",
"if",
"args",
... | [
501,
4
] | [
536,
75
] | 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.treemap.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.treemap.marker.colorbar.title.Font`
... | def font(self):
"""
Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.treemap.mark... | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
15,
4
] | [
53,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.side | (self) |
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the following enumeration values... |
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the following enumeration values... | def side(self):
"""
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the f... | [
"def",
"side",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"side\"",
"]"
] | [
62,
4
] | [
76,
27
] | python | en | ['en', 'error', 'th'] | False |
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 ... |
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 ... | 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:
... | [
"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.treemap.marker
.colorbar.Title`
font
Sets this color bar's title font. ... |
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.treemap.marker
.colorbar.Title`
font
Sets this color bar's title font. ... | 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.treemap.marker
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"font",
"=",
"None",
",",
"side",
"=",
"None",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Title",
",",
"self",
")",
".",
"__init__",
"(",
"\"title\"",
... | [
126,
4
] | [
203,
34
] | 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.choropleth.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.choropleth.colorbar.title.Font`
... | def font(self):
"""
Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.choropleth.c... | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
15,
4
] | [
53,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.side | (self) |
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the following enumeration values... |
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the following enumeration values... | def side(self):
"""
Determines the location of color bar's title with respect to
the color bar. Note that the title's location used to be set by
the now deprecated `titleside` attribute.
The 'side' property is an enumeration that may be specified as:
- One of the f... | [
"def",
"side",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"side\"",
"]"
] | [
62,
4
] | [
76,
27
] | python | en | ['en', 'error', 'th'] | False |
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 ... |
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 ... | 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:
... | [
"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.choropleth.colorbar.Title`
font
Sets this color bar's title font. Note ... |
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.choropleth.colorbar.Title`
font
Sets this color bar's title font. Note ... | 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.choropl... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"font",
"=",
"None",
",",
"side",
"=",
"None",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Title",
",",
"self",
")",
".",
"__init__",
"(",
"\"title\"",
... | [
126,
4
] | [
203,
34
] | python | en | ['en', 'error', 'th'] | False |
SelfFeedingAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
super().add_cmdline_args(parser, partial_opt=partial_opt)
SelfFeedingModel.add_cmdline_args(parser, pa... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"super",
"(",
")",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_opt",
"="... | [
60,
4
] | [
229,
20
] | python | en | ['en', 'error', 'th'] | False |
SelfFeedingAgent.upgrade_opt | (cls, opt_on_disk) |
Upgrade opts from older model files.
|
Upgrade opts from older model files.
| def upgrade_opt(cls, opt_on_disk):
"""
Upgrade opts from older model files.
"""
super(SelfFeedingAgent, cls).upgrade_opt(opt_on_disk)
# 2019-06-25: previous versions of the model did not add a CLS token
# to the beginning of text_vec.
if 'add_double_person_tokens... | [
"def",
"upgrade_opt",
"(",
"cls",
",",
"opt_on_disk",
")",
":",
"super",
"(",
"SelfFeedingAgent",
",",
"cls",
")",
".",
"upgrade_opt",
"(",
"opt_on_disk",
")",
"# 2019-06-25: previous versions of the model did not add a CLS token",
"# to the beginning of text_vec.",
"if",
... | [
289,
4
] | [
301,
26
] | python | en | ['en', 'error', 'th'] | False |
SelfFeedingAgent.observe | (self, observation) |
Add to history, concatenate history-size utterances, and add person tokens.
|
Add to history, concatenate history-size utterances, and add person tokens.
| def observe(self, observation):
"""
Add to history, concatenate history-size utterances, and add person tokens.
"""
# If their response is a response to a rating request, no work required
if self.status == RATING_REQUESTED:
self.last_rating = observation['text']
... | [
"def",
"observe",
"(",
"self",
",",
"observation",
")",
":",
"# If their response is a response to a rating request, no work required",
"if",
"self",
".",
"status",
"==",
"RATING_REQUESTED",
":",
"self",
".",
"last_rating",
"=",
"observation",
"[",
"'text'",
"]",
"ret... | [
368,
4
] | [
377,
43
] | python | en | ['en', 'error', 'th'] | False |
SelfFeedingAgent._set_text_vec | (self, obs, history, truncate) |
Set the 'text_vec' field in the observation.
|
Set the 'text_vec' field in the observation.
| def _set_text_vec(self, obs, history, truncate):
"""
Set the 'text_vec' field in the observation.
"""
if 'text' not in obs:
return obs
if 'text_vec' not in obs:
obs['text_vec'] = self.history.parse(obs["text"])
# check truncation
if 'text... | [
"def",
"_set_text_vec",
"(",
"self",
",",
"obs",
",",
"history",
",",
"truncate",
")",
":",
"if",
"'text'",
"not",
"in",
"obs",
":",
"return",
"obs",
"if",
"'text_vec'",
"not",
"in",
"obs",
":",
"obs",
"[",
"'text_vec'",
"]",
"=",
"self",
".",
"histo... | [
390,
4
] | [
412,
18
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.