-
Notifications
You must be signed in to change notification settings - Fork 134
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
- Grid2op version:
1.11.0 - System: Arch Linux
Bug description
Expect to find the attributes "load_theta", "gen_theta", "theta_or", "theta_ex", "storage_theta" in CompleteObservation.attr_list_vect. However it is only in CompleteObservation.attr_list_json.
from grid2op.Observation import CompleteObservation
print("load_theta" in CompleteObservation.attr_list_vect) # False
print(load_theta" in CompleteObservation.attr_list_json) # True
Expected behaviour would be to have all attributes in attr_list_vect, including the phase attributes.
I wondered if it might have to do with the to_json() conversion, but internally they seem to be concatenated. From GridObjects._convert_to_json(...):
@classmethod
def _convert_to_json(cls, dict_: Dict[str, Any]) -> None:
for attr_nm in cls.attr_list_vect + cls.attr_list_json: # Lists are concatenated
tmp = dict_[attr_nm]
dtype = tmp.dtype
if dtype == dt_float:
dict_[attr_nm] = [float(el) for el in tmp]
elif dtype == dt_int:
dict_[attr_nm] = [int(el) for el in tmp]
elif dtype == dt_bool:
dict_[attr_nm] = [bool(el) for el in tmp]
elif dtype == float:
dict_[attr_nm] = [float(el) for el in tmp]
elif dtype == int:
dict_[attr_nm] = [int(el) for el in tmp]
elif dtype == bool:
dict_[attr_nm] = [bool(el) for el in tmp]
In the docstring of the method GridObjects.to_json(), we get a partial explanation:
Concretely, if `obs` is an observation (:class:`grid2op.Observation.BaseObservation`)
then `obs.to_dict()` will have the keys `type(obs).attr_list_vect` and the values will
be numpy arrays whereas `obs.to_json()` will have the keys
`type(obs).attr_list_vect` and `type(obs).attr_list_json` and the values will be
lists (serializable)
However, obs.load_theta, for instance is a numpy array already, so I don't understand why it cannot be included in to_dict() by default.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working