当前位置: 首页>>代码示例>>Python>>正文


Python SchemaValidator.from_specfile方法代码示例

本文整理汇总了Python中pysemantic.validator.SchemaValidator.from_specfile方法的典型用法代码示例。如果您正苦于以下问题:Python SchemaValidator.from_specfile方法的具体用法?Python SchemaValidator.from_specfile怎么用?Python SchemaValidator.from_specfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysemantic.validator.SchemaValidator的用法示例。


在下文中一共展示了SchemaValidator.from_specfile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_specfile

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import from_specfile [as 别名]
 def test_from_specfile(self):
     """Test if the SchemaValidator.from_specfile constructor works."""
     validator = SchemaValidator.from_specfile(self.specfile, "iris")
     self.assertKwargsEqual(validator.get_parser_args(),
                            self.ideal_iris_parser_args)
     validator = SchemaValidator.from_specfile(self.specfile,
                                               "person_activity")
     self.assertKwargsEqual(validator.get_parser_args(),
                            self.ideal_activity_parser_args)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:11,代码来源:test_validator.py

示例2: test_pickled_arguments

# 需要导入模块: from pysemantic.validator import SchemaValidator [as 别名]
# 或者: from pysemantic.validator.SchemaValidator import from_specfile [as 别名]
 def test_pickled_arguments(self):
     """Test if the SchemaValidator correctly loads pickled arguments."""
     tempdir = tempfile.mkdtemp()
     outpath = op.join(tempdir, "iris_args.pkl")
     with open(outpath, 'w') as fid:
         cPickle.dump(self.ideal_iris_parser_args, fid)
     new_schema_path = op.join(tempdir, "pickle_schema.yml")
     with open(new_schema_path, 'w') as fid:
         yaml.dump(dict(iris=dict(pickle=outpath)), fid, Dumper=Dumper,
                   default_flow_style=False)
     org_data = pd.read_csv(self.ideal_iris_parser_args['filepath_or_buffer'])
     try:
         validator = SchemaValidator.from_specfile(new_schema_path, "iris",
                                                   is_pickled=True)
         loaded = pd.read_csv(**validator.get_parser_args())
         self.assertDataFrameEqual(loaded, org_data)
     finally:
         shutil.rmtree(tempdir)
开发者ID:abhishekarora12,项目名称:pysemantic,代码行数:20,代码来源:test_validator.py


注:本文中的pysemantic.validator.SchemaValidator.from_specfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。