本文整理汇总了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)
示例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)