本文整理汇总了Python中pyasdf.ASDFDataSet.provenance["test_provenance"]方法的典型用法代码示例。如果您正苦于以下问题:Python ASDFDataSet.provenance["test_provenance"]方法的具体用法?Python ASDFDataSet.provenance["test_provenance"]怎么用?Python ASDFDataSet.provenance["test_provenance"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasdf.ASDFDataSet
的用法示例。
在下文中一共展示了ASDFDataSet.provenance["test_provenance"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_provenance_document_for_id
# 需要导入模块: from pyasdf import ASDFDataSet [as 别名]
# 或者: from pyasdf.ASDFDataSet import provenance["test_provenance"] [as 别名]
def test_get_provenance_document_for_id(tmpdir):
asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
data_set = ASDFDataSet(asdf_filename)
filename = os.path.join(data_dir,
"example_schematic_processing_chain.xml")
doc = prov.read(filename)
data_set.provenance["test_provenance"] = doc
assert data_set.provenance.get_provenance_document_for_id(
'{http://seisprov.org/seis_prov/0.1/#}sp002_dt_f87sf7sf78') == \
{"name": "test_provenance", "document": doc}
assert data_set.provenance.get_provenance_document_for_id(
'{http://seisprov.org/seis_prov/0.1/#}sp004_lp_f87sf7sf78') == \
{"name": "test_provenance", "document": doc}
# Id not found.
with pytest.raises(ASDFValueError) as err:
data_set.provenance.get_provenance_document_for_id(
'{http://seisprov.org/seis_prov/0.1/#}bogus_id')
assert err.value.args[0] == (
"Document containing id "
"'{http://seisprov.org/seis_prov/0.1/#}bogus_id'"
" not found in the data set.")
# Not a qualified id.
with pytest.raises(ASDFValueError) as err:
data_set.provenance.get_provenance_document_for_id("bla")
assert err.value.args[0] == ("Not a valid qualified name.")
data_set.__del__()
示例2: test_provenance_dicionary_behaviour
# 需要导入模块: from pyasdf import ASDFDataSet [as 别名]
# 或者: from pyasdf.ASDFDataSet import provenance["test_provenance"] [as 别名]
def test_provenance_dicionary_behaviour(tmpdir):
asdf_filename = os.path.join(tmpdir.strpath, "test.h5")
data_set = ASDFDataSet(asdf_filename)
filename = os.path.join(data_dir,
"example_schematic_processing_chain.xml")
# Add it as a document.
doc = prov.read(filename, format="xml")
# Setting via setitem.
data_set.provenance["test_provenance"] = doc
data_set.__del__()
del data_set
new_data_set = ASDFDataSet(asdf_filename)
assert new_data_set.provenance.list() == ["test_provenance"]
assert new_data_set.provenance["test_provenance"] == doc
assert getattr(new_data_set.provenance, "test_provenance") == doc
assert list(new_data_set.provenance.keys()) == ["test_provenance"]
assert list(new_data_set.provenance.values()) == [doc]
assert list(new_data_set.provenance.items()) == [("test_provenance", doc)]