def convert_to()

in robogym/robot/utils/measurement_units.py [0:0]


    def convert_to(self, data: np.ndarray, to_units: MeasurementUnit) -> np.ndarray:
        """Poor man's conversion from self units to 'to_units' for supported parts. It may only support a
        subset of all possible conversions, and will raise an error if the requested one is not supported.

        :param data: Data to convert.
        :param to_units: Units to convert to.
        :return: Result of converting the data to the new units, from the current units.
        :raises RuntimeError: If the conversion pair is not supported.
        """
        if self == to_units:
            return data

        if self == MeasurementUnit.RADIANS and to_units == MeasurementUnit.DEGREES:
            return np.rad2deg(data)
        elif self == MeasurementUnit.DEGREES and to_units == MeasurementUnit.RADIANS:
            return np.deg2rad(data)
        elif self == MeasurementUnit.METERS and to_units == MeasurementUnit.MILLIMETERS:
            return np.multiply(data, 1000)
        elif self == MeasurementUnit.MILLIMETERS and to_units == MeasurementUnit.METERS:
            return np.multiply(data, 1e-3)
        elif (
            self == MeasurementUnit.SECONDS and to_units == MeasurementUnit.MILLISECONDS
        ):
            return np.multiply(data, 1000)
        raise RuntimeError(f"Can't convert between units from {self} to {to_units}")