dataset.py 文件源码

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

项目:odin 作者: imito 项目源码 文件源码
def add_recipes(self, recipes, name, override=False):
    """
    Parameters
    ----------
    """
    # ====== validate arguments ====== #
    if not is_string(name):
      raise ValueError("`name` must be string, but given: %s" % str(type(name)))
    if name in self._saved_recipes and not override:
      raise ValueError("Cannot override pre-defined RECIPE with name: '%s'"
                      % name)
    # ====== validate recipes list ====== #
    if isinstance(recipes, RecipeList):
      recipes = tuple(recipes._recipes)
    else:
      tmp = []
      for rcp in as_tuple(recipes, t=FeederRecipe):
        if isinstance(rcp, RecipeList):
          tmp += list(rcp._recipes)
        else:
          tmp.append(rcp)
      recipes = tuple(tmp)
    # ====== store the recipes to disk ====== #
    path = os.path.join(self.recipe_path, name)
    with open(path, 'wb') as f:
      cPickle.dump(recipes, f, protocol=cPickle.HIGHEST_PROTOCOL)
    # ====== update local recipes list ====== #
    self._saved_recipes[name] = recipes
    return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号