def test_nodata(): """Test when no data is found""" swofstr = "" satdf = satfunc.df(swofstr) assert len(satdf) == 0 inc = satfunc.df2ecl_swof(satdf) assert "No data" in inc df_from_inc = satfunc.df(inc) assert df_from_inc.empty
def test_str2df(): """Test parsing of a direct string""" swofstr = """ SWOF 0 0 1 1 1 1 0 0 / """ satdf = satfunc.df(swofstr) assert len(satdf) == 2 inc = satfunc.df2ecl_swof(satdf) df_from_inc = satfunc.df(inc) pd.testing.assert_frame_equal(satdf, df_from_inc) swofstr2 = """ -- RUNSPEC -- (this line is optional) TABDIMS 2 / -- PROPS -- (optional) SWOF 0 0 1 1 1 1 0 0 / 0 0 1 1 0.5 0.5 0.5 0.5 1 1 0 0 / """ satdf2 = satfunc.df(swofstr2) assert "SATNUM" in satdf assert len(satdf2["SATNUM"].unique()) == 2 assert len(satdf2) == 5 inc = satfunc.df2ecl(satdf) df_from_inc = satfunc.df(inc) pd.testing.assert_frame_equal(satdf, df_from_inc) # Try empty/bogus data: bogusdf = satfunc.deck2df("SWRF\n 0 /\n") # (warnings should be issued) assert bogusdf.empty # Test with bogus E100 keywords: tricky = satfunc.deck2df("FOO\n\nSWOF\n 0 0 0 1/ 1 1 1 0\n/\n") assert not tricky.empty assert len(tricky["SATNUM"].unique()) == 1