當前位置: 首頁>>代碼示例>>Python>>正文


Python ASDFDataSet.provenance["test_provenance"]方法代碼示例

本文整理匯總了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__()
開發者ID:petrrr,項目名稱:pyasdf,代碼行數:37,代碼來源:test_asdf_data_set.py

示例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)]
開發者ID:petrrr,項目名稱:pyasdf,代碼行數:26,代碼來源:test_asdf_data_set.py


注:本文中的pyasdf.ASDFDataSet.provenance["test_provenance"]方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。