def test_df2ecl_pvtw(): """Test generation of PVTW include statements""" pvtw_df = pd.DataFrame( columns=[ "PRESSURE", "VOLUMEFACTOR", "COMPRESSIBILITY", "VISCOSITY", "VISCOSIBILITY", "PVTNUM", ], data=[[327.3, 1.03, 4.51e-005, 0.25, 0.0, 1]], ) assert "PVTW" in pvt.df2ecl_pvtw(pvtw_df) # If PVTNUM is missing, the code gives up: assert "PVTW" not in pvt.df2ecl_pvtw( pd.concat([pvtw_df, pvtw_df]).drop("PVTNUM", axis="columns") ) # Unless there is only one row: assert "PVTW" in pvt.df2ecl_pvtw(pvtw_df.drop("PVTNUM", axis="columns")) # Missing column: with pytest.raises(KeyError, match="VOLUMEFACTOR"): pvt.df2ecl_pvtw(pvtw_df.drop("VOLUMEFACTOR", axis="columns"))
def test_pvtw(): """Test that PVTW can be parsed from a string""" deck = """PVTW 327.3 1.03 4.51E-005 0.25 0 /""" pvtw_df = pvt.pvtw_fromdeck(EclFiles.str2deck(deck)) pd.testing.assert_frame_equal( pvtw_df, pd.DataFrame( columns=[ "PRESSURE", "VOLUMEFACTOR", "COMPRESSIBILITY", "VISCOSITY", "VISCOSIBILITY", "PVTNUM", ], data=[[327.3, 1.03, 4.51e-005, 0.25, 0.0, 1]], ), check_like=True, ) deck = """PVTW 327.3 1.03 4.51E-005 0.25 0 / 300 1 0.0001 0.2 /""" pvtw_df = pvt.pvtw_fromdeck( deck) # Must give string, not deck, for NTPVT guessing assert len(pvtw_df) == 2 # Test emtpy data: inc = pvt.df2ecl_pvtw(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty
def test_pvtw(): """Test that PVTW can be parsed from a string""" deck = """PVTW 327.3 1.03 4.51E-005 0.25 0 /""" pvtw_df = pvt.pvtw_fromdeck(EclFiles.str2deck(deck)) assert len(pvtw_df) == 1 assert "VOLUMEFACTOR" in pvtw_df assert "PRESSURE" in pvtw_df assert "COMPRESSIBILITY" in pvtw_df assert "VISCOSIBILITY" in pvtw_df deck = """PVTW 327.3 1.03 4.51E-005 0.25 0 / 300 1 0.0001 0.2 /""" pvtw_df = pvt.pvtw_fromdeck( deck) # Must give string, not deck, for NTPVT guessing assert len(pvtw_df) == 2 # Test emtpy data: inc = pvt.df2ecl_pvtw(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty