def radius_from_volume(volume: float, dim: int) -> float:
    """Return the radius of a sphere with a given volume

    Args:
        volume (float): Volume of the sphere
        dim (int): Dimension of the space

    Returns:
        float: Radius of the sphere
    """
    if dim == 1:
        return volume / 2
    elif dim == 2:
        return np.sqrt(volume / π)  # type: ignore
    elif dim == 3:
        return (3 * volume / (4 * π)) ** (1 / 3)  # type: ignore
    else:
        raise NotImplementedError(f"Cannot calculate the radius in {dim} dimensions")