def cls_to_dict(self):
        """
        INTERNAL

        .. warning:: /!\\\\ Internal, do not use unless you know what you are doing /!\\\\
            This is used internally only to save action_space or observation_space for example. Do not
            attempt to use it in a different context.

        Serialize this object as a dictionary.

        Returns
        -------
        res: ``dict``
            A dictionary representing this object content. It can be loaded back with
            :func:`SerializableObservationSpace.cls_from_dict`

        """
        # TODO this is super weird that this is a regular method, but inherit from a class method !
        res = super().cls_to_dict()

        save_to_dict(
            res, self, "_init_subtype",
            lambda x: re.sub("(<class ')|(\\.init_grid\\.<locals>\\.res)|('>)",
                             "", "{}".format(x)))
        return res
Beispiel #2
0
    def to_dict(self):
        """
        Serialize this object as a dictionnary.

        Returns
        -------
        res: ``dict``
            A dictionnary representing this object content. It can be loaded back with
             :func:`SerializableObservationSpace.from_dict`
        """
        res = super().to_dict()

        save_to_dict(res, self, "_init_subtype",
                     lambda x: re.sub("(<class ')|(\\.init_grid\\.<locals>\\.res)|('>)", "", "{}".format(x)))
        return res