コード例 #1
0
ファイル: test_pvt.py プロジェクト: anders-kiaer/ecl2df
def test_pvdo_string():
    """Test that PVDO can be parsed from a string"""
    string = """
PVDO
400 6 0.01
1000 1.3 0.15 /
200 8 0.013
8000 1.8 0.16 /
"""
    dframe = pvt.pvdo_fromdeck(string)
    pd.testing.assert_frame_equal(
        dframe,
        pd.DataFrame(
            columns=["PRESSURE", "VOLUMEFACTOR", "VISCOSITY", "PVTNUM"],
            data=[
                [400.0, 6, 0.01, 1],
                [1000.0, 1.3, 0.15, 1],
                [200.0, 8, 0.013, 2],
                [8000.0, 1.8, 0.16, 2],
            ],
        ),
    )

    # Test emtpy data:
    inc = pvt.df2ecl_pvdo(pvt.df(""))
    assert "No data" in inc
    assert pvt.df(inc).empty
コード例 #2
0
ファイル: test_pvt.py プロジェクト: berland/ecl2df
def test_df2ecl_pvdo():
    pvdo_df = pd.DataFrame(
        columns=["PRESSURE", "VOLUMEFACTOR", "VISCOSITY", "PVTNUM"],
        data=[
            [400.0, 6, 0.01, 1],
            [1000.0, 1.3, 0.15, 1],
            [200.0, 8, 0.013, 2],
            [8000.0, 1.8, 0.16, 2],
        ],
    )

    assert "PVDO" in pvt.df2ecl_pvdo(pvdo_df)
    assert "PVDO" in pvt.df2ecl_pvdo(pvdo_df.assign(KEYWORD="PVDO"))
    pd.testing.assert_frame_equal(
        pvt.df(pvt.df2ecl_pvdo(pvdo_df)).drop("KEYWORD", axis="columns"), pvdo_df
    )

    # If PVTNUM is missing, the code gives up:
    assert "PVDO" not in pvt.df2ecl_pvdo(
        pd.concat([pvdo_df, pvdo_df]).drop("PVTNUM", axis="columns")
    )

    # Unless there is only one row:
    assert "PVDO" in pvt.df2ecl_pvdo(pvdo_df.head(1).drop("PVTNUM", axis="columns"))

    # Missing column:
    with pytest.raises(KeyError, match="VOLUMEFACTOR"):
        pvt.df2ecl_pvdo(pvdo_df.drop("VOLUMEFACTOR", axis="columns"))
コード例 #3
0
ファイル: test_pvt.py プロジェクト: lindjoha/ecl2df
def test_df2ecl_pvdo_pvdg():
    """Test construction of PVDO and PVDG statements from dataframe.

    The keyword data and code is similar enough to warrant one test
    for both functions, with the same dataset."""
    pvdog_df = pd.DataFrame(
        columns=["PRESSURE", "VOLUMEFACTOR", "VISCOSITY", "PVTNUM"],
        data=[
            [400.0, 6, 0.01, 1],
            [1000.0, 1.3, 0.15, 1],
            [200.0, 8, 0.013, 2],
            [8000.0, 1.8, 0.16, 2],
        ],
    )

    assert "PVDO" in pvt.df2ecl_pvdo(pvdog_df)
    assert "PVDG" in pvt.df2ecl_pvdg(pvdog_df)

    assert "PVDO" in pvt.df2ecl_pvdo(pvdog_df.assign(KEYWORD="PVDO"))
    assert "PVDG" in pvt.df2ecl_pvdg(pvdog_df.assign(KEYWORD="PVDG"))

    pd.testing.assert_frame_equal(
        pvt.df(pvt.df2ecl_pvdo(pvdog_df)).drop("KEYWORD", axis="columns"), pvdog_df
    )
    pd.testing.assert_frame_equal(
        pvt.df(pvt.df2ecl_pvdg(pvdog_df)).drop("KEYWORD", axis="columns"), pvdog_df
    )

    # If PVTNUM is missing, the code gives up:
    assert "PVDO" not in pvt.df2ecl_pvdo(
        pd.concat([pvdog_df, pvdog_df]).drop("PVTNUM", axis="columns")
    )
    assert "PVDG" not in pvt.df2ecl_pvdg(
        pd.concat([pvdog_df, pvdog_df]).drop("PVTNUM", axis="columns")
    )

    # Unless there is only one row:
    assert "PVDO" in pvt.df2ecl_pvdo(pvdog_df.head(1).drop("PVTNUM", axis="columns"))
    assert "PVDG" in pvt.df2ecl_pvdg(pvdog_df.head(1).drop("PVTNUM", axis="columns"))

    # Missing column:
    with pytest.raises(KeyError, match="VOLUMEFACTOR"):
        pvt.df2ecl_pvdo(pvdog_df.drop("VOLUMEFACTOR", axis="columns"))
    with pytest.raises(KeyError, match="VOLUMEFACTOR"):
        pvt.df2ecl_pvdg(pvdog_df.drop("VOLUMEFACTOR", axis="columns"))
コード例 #4
0
def test_pvdo_string():
    """Test that PVDO can be parsed from a string"""
    string = """
PVDO
400 6 0.01
600 3 0.012
1000 1.3 0.15 /
200 8 0.013
300 4 0.014
8000 1.8 0.16 /
"""
    dframe = pvt.pvdo_fromdeck(string)
    assert len(dframe) == 6
    assert "PVTNUM" in dframe
    assert len(dframe["PVTNUM"].unique()) == 2
    assert "PRESSURE" in dframe
    assert "VOLUMEFACTOR" in dframe
    assert "VISCOSITY" in dframe

    # Test emtpy data:
    inc = pvt.df2ecl_pvdo(pvt.df(""))
    assert "No data" in inc
    assert pvt.df(inc).empty