nopasaran.primitives.action_primitives.data_manipulation.DataManipulationPrimitives¶
- class nopasaran.primitives.action_primitives.data_manipulation.DataManipulationPrimitives¶
Bases:
objectClass containing data manipulation primitives for the state machine.
- __init__()¶
Methods
__init__()add_element_to_dict(inputs, outputs, ...)Add an element to a dictionary stored in the machine's state.
create_dict(inputs, outputs, state_machine)Create an empty dictionary and store it in the machine's state.
decrement(inputs, outputs, state_machine)Decrement the value of a variable stored in the machine's state by a specified amount.
divide(inputs, outputs, state_machine)Divide the value of a variable stored in the machine's state by a specified divisor.
fetch_element_from_dict(inputs, outputs, ...)Fetch an element from a dictionary stored in the machine's state.
get_first_element(inputs, outputs, state_machine)Get the first element from a list stored in the machine's state.
increment(inputs, outputs, state_machine)Increment the value of a variable stored in the machine's state by a specified amount.
pop(inputs, outputs, state_machine)Remove the first element from a list stored in the machine's state.
remove_element_from_dict(inputs, outputs, ...)Remove an element from a dictionary stored in the machine's state.
set(inputs, outputs, state_machine)Set the value of an output variable in the machine's state.
set_integer(inputs, outputs, state_machine)Set the integer value of an output variable in the machine's state.
set_random_float(inputs, outputs, state_machine)Generate a random float between two input values and store it in an output variable in the machine's state.
set_random_int(inputs, outputs, state_machine)Generate a random integer between two input values and store it in an output variable in the machine's state.
string_to_integer(inputs, outputs, state_machine)Convert a string value to an integer and store it in the machine's state.
- static add_element_to_dict(inputs, outputs, state_machine)¶
Add an element to a dictionary stored in the machine’s state.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the dictionary variable.
The name of the variable whose value will be added as the value in the dictionary.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the dictionary variable to store the updated dictionary.
state_machine: The state machine object.
- Returns:
None
- static create_dict(inputs, outputs, state_machine)¶
Create an empty dictionary and store it in the machine’s state.
Number of input arguments: 0
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): No input arguments.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the empty dictionary.
state_machine: The state machine object.
- Returns:
None
- static decrement(inputs, outputs, state_machine)¶
Decrement the value of a variable stored in the machine’s state by a specified amount.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of a variable representing the value to be decremented.
The amount by which the value should be decremented.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument:
The name of the variable to store the result of the decrement operation.
state_machine: The state machine object.
- Returns:
None
- static divide(inputs, outputs, state_machine)¶
Divide the value of a variable stored in the machine’s state by a specified divisor.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of a variable representing the numerator.
The divisor by which the numerator should be divided.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument:
The name of the variable to store the result of the division operation.
state_machine: The state machine object.
- Returns:
None
- Raises:
ValueError: If the divisor is zero.
- static fetch_element_from_dict(inputs, outputs, state_machine)¶
Fetch an element from a dictionary stored in the machine’s state.
Number of input arguments: 2 Number of output arguments: 1 Optional input arguments: No Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the dictionary variable.
The name of the key whose value needs to be retrieved.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument,
which is the name of the variable to store the retrieved value.
state_machine: The state machine object.
- Returns:
None
- static get_first_element(inputs, outputs, state_machine)¶
Get the first element from a list stored in the machine’s state.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains one mandatory input argument,
which is the name of a variable representing the list.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument,
which is the name of the variable to store the first element.
state_machine: The state machine object.
- Returns:
None
- static increment(inputs, outputs, state_machine)¶
Increment the value of a variable stored in the machine’s state by a specified amount.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of a variable representing the value to be incremented.
The amount by which the value should be incremented.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument:
The name of the variable to store the result of the increment operation.
state_machine: The state machine object.
- Returns:
None
- static pop(inputs, outputs, state_machine)¶
Remove the first element from a list stored in the machine’s state.
Number of input arguments: 1
Number of output arguments: 0
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the name of a variable representing the list.
outputs (List[str]): The list of output variable names.
state_machine: The state machine object.
- Returns:
None
- static remove_element_from_dict(inputs, outputs, state_machine)¶
Remove an element from a dictionary stored in the machine’s state.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains two mandatory input arguments:
The name of the dictionary variable.
The name of the variable whose value will be removed from the dictionary.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the dictionary variable to store the updated dictionary.
state_machine: The state machine object.
- Returns:
None
- static set(inputs, outputs, state_machine)¶
Set the value of an output variable in the machine’s state.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the new value.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable with the modification.
state_machine: The state machine object.
- Returns:
None
- static set_integer(inputs, outputs, state_machine)¶
Set the integer value of an output variable in the machine’s state.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains one mandatory input argument, which is the new integer.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable with the modification.
state_machine: The state machine object.
- Returns:
None
- static set_random_float(inputs, outputs, state_machine)¶
Generate a random float between two input values and store it in an output variable in the machine’s state.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments, which are the lower bound and the upper bound.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the generated random float.
state_machine: The state machine object.
- Returns:
None
- static set_random_int(inputs, outputs, state_machine)¶
Generate a random integer between two input values and store it in an output variable in the machine’s state.
Number of input arguments: 2
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
inputs (List[str]): The list of input variable names. It contains two mandatory input arguments, which are the lower bound and the upper bound.
outputs (List[str]): The list of output variable names. It contains one mandatory output argument, which is the name of the variable to store the generated random integer.
state_machine: The state machine object.
- Returns:
None
- static string_to_integer(inputs, outputs, state_machine)¶
Convert a string value to an integer and store it in the machine’s state.
Number of input arguments: 1
Number of output arguments: 1
Optional input arguments: No
Optional output arguments: No
- Args:
- inputs (List[str]): The list of input variable names. It contains one mandatory input argument,
which is the name of a variable containing the string to be converted.
- outputs (List[str]): The list of output variable names. It contains one mandatory output argument,
which is the name of the variable to store the converted integer.
state_machine: The state machine object.
- Returns:
None
- Raises:
ValueError: If the input string cannot be converted to an integer.