Utils
- gym_electric_motor.utils.set_state_array(input_values, state_names)[source]
Setting of the input values to a valid state array with the shape of the physical systems state.
The input values can be passed as dict with state_name: value pairs or as list / ndarray. In the latter case the shape of the list has to fit the state_names shape and the list will just be returned as array. If a float is passed as input value, then this value will be set onto all positions of the state array equally.
- Parameters:
- Returns:
An initialized state array with all values passed in input values set onto the corresponding position in the state_names and zero otherwise.
- gym_electric_motor.utils.state_dict_to_state_array(state_dict, state_array, state_names)[source]
Mapping of a passed state dictionary to a fitting state array.
This function is mainly used in the initialization phase to map a dictionary of passed state_name, state_value pairs to a numpy state array with the entries of the state_dict at the corresponding places of the state_names.
- gym_electric_motor.utils.update_parameter_dict(source_dict, update_dict, copy=True)[source]
Merges two dictionaries (source and update) together.
It is similar to pythons dict.update() method. Furthermore, it assures that all keys in the update dictionary are already present in the source dictionary. Otherwise a KeyError is thrown.
- Parameters:
- Returns:
The updated source dictionary.
- Return type:
- Exceptions:
KeyError: Thrown, if a key in the update dict is not available in the source dict.