tf_conv.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码
def fmt(obj, nest_level=0):
    """ Format any common object """
    if nest_level > 10:
        return ""
    if isinstance(obj, float):
        return "{0:.3f}".format(obj)
    if isinstance(obj, list):
        return "(" + ",".join(map(lambda x: fmt(x, nest_level + 1), obj)) + ")"
    if isinstance(obj, (numpy.ndarray, numpy.generic)):
        return fmt(obj.tolist(), nest_level + 1)
    if isinstance(obj, dict):
        pairs = map(lambda x, y: "(" + fmt(x) + "," + fmt(y, nest_level + 1) + ")", obj.items())
        return fmt(pairs)
    if isinstance(obj, Vector3):
        return "({},{},{})".format(fmt(obj.x), fmt(obj.y), fmt(obj.z))
    if isinstance(obj, Quaternion):
        return "({},{},{},{})".format(fmt(obj.x), fmt(obj.y), fmt(obj.z), fmt(obj.w))
    # print " obj " + str(obj) + " is of type " + str(type(obj))
    return str(obj)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号