def test_grouptrans(): """Test grouping of transmissibilities""" eclfiles = EclFiles(REEK) trans_df = trans.df(eclfiles, vectors="FIPNUM", group=True, coords=True) assert "FIPNUMPAIR" in trans_df assert "FIPNUM1" in trans_df assert "FIPNUM2" in trans_df assert (trans_df["FIPNUM1"] < trans_df["FIPNUM2"]).all() assert len(trans_df) == 7 assert "X" in trans_df # (average X coord for that FIPNUM interface) # This gives a logged error: assert trans.df(eclfiles, vectors=["FIPNUM", "EQLNUM"], group=True).empty
def test_df2ecl_editnnc(tmpdir): """Test generation of EDITNNC keyword""" eclfiles = EclFiles(DATAFILE) nncdf = nnc.df(eclfiles) tmpdir.chdir() nncdf["TRANM"] = 2 editnnc = nnc.df2ecl_editnnc(nncdf, filename="editnnc.inc") editnnc_fromfile = "".join(open("editnnc.inc").readlines()) assert editnnc == editnnc_fromfile assert "EDITNNC" in editnnc assert editnnc.count("/") == len(nncdf) + 1 assert "avg multiplier" in editnnc # Fails when columns are missing with pytest.raises((KeyError, ValueError)): nnc.df2ecl_editnnc(nncdf[["I1", "I2"]]) editnnc = nnc.df2ecl_editnnc(nncdf, nocomments=True) assert "avg multiplier" not in editnnc # Test compatibility with trans module: trans_df = trans.df(eclfiles, addnnc=True) editnnc = nnc.df2ecl_editnnc(trans_df.assign(TRANM=0.3)) assert "avg multiplier 0.3" in editnnc or "avg multiplier 0.29999" in editnnc print(nnc.df2ecl_editnnc(nnc.df(eclfiles).head(4).assign(TRANM=0.1)))
def test_grouptrans(): """Test grouping of transmissibilities""" eclfiles = EclFiles(DATAFILE) trans_df = trans.df(eclfiles, vectors="FIPNUM", group=True, coords=True) assert "FIPNUMPAIR" in trans_df assert "FIPNUM1" in trans_df assert "FIPNUM2" in trans_df assert (trans_df["FIPNUM1"] < trans_df["FIPNUM2"]).all() assert len(trans_df) == 7 assert "X" in trans_df # (average X coord for that FIPNUM interface)
def test_trans(): """Test that we can build a dataframe of transmissibilities""" eclfiles = EclFiles(DATAFILE) trans_df = trans.df(eclfiles) assert "TRAN" in trans_df assert "DIR" in trans_df assert set(trans_df["DIR"].unique()) == set(["I", "J", "K"]) assert trans_df["TRAN"].sum() > 0 trans_full_length = len(trans_df) # Try including some vectors: trans_df = trans.df(eclfiles, vectors="FIPNUM") assert "FIPNUM" not in trans_df assert "FIPNUM1" in trans_df assert "EQLNUM2" not in trans_df trans_df = trans.df(eclfiles, vectors=["FIPNUM", "EQLNUM"]) assert "FIPNUM1" in trans_df assert "EQLNUM2" in trans_df trans_df = trans.df(eclfiles, vectors="BOGUS") assert "BOGUS1" not in trans_df assert "TRAN" in trans_df # (we should have gotten a warning only) assert "K" not in trans.df(eclfiles, onlyijdir=True)["DIR"] assert "I" not in trans.df(eclfiles, onlykdir=True)["DIR"] transnnc_df = trans.df(eclfiles, addnnc=True) assert len(transnnc_df) > trans_full_length trans_df = trans.df(eclfiles, vectors=["FIPNUM", "EQLNUM"], boundaryfilter=True) assert trans_df.empty trans_df = trans.df(eclfiles, vectors="FIPNUM", boundaryfilter=True) assert len(trans_df) < trans_full_length trans_df = trans.df(eclfiles, coords=True) assert "X" in trans_df assert "Y" in trans_df
def test_trans(): """Test that we can build a dataframe of transmissibilities""" eclfiles = EclFiles(REEK) trans_df = trans.df(eclfiles) assert "TRAN" in trans_df assert "DIR" in trans_df assert set(trans_df["DIR"].unique()) == set(["I", "J", "K"]) assert trans_df["TRAN"].sum() > 0 trans_full_length = len(trans_df) # Try including some vectors: trans_df = trans.df(eclfiles, vectors="FIPNUM") assert "FIPNUM" not in trans_df assert "FIPNUM1" in trans_df assert "EQLNUM2" not in trans_df trans_df = trans.df(eclfiles, vectors=["FIPNUM", "EQLNUM"]) assert "FIPNUM1" in trans_df assert "EQLNUM2" in trans_df trans_df = trans.df(eclfiles, vectors="BOGUS") assert "BOGUS1" not in trans_df assert "TRAN" in trans_df # (we should have gotten a warning only) assert "K" not in trans.df(eclfiles, onlyijdir=True)["DIR"] assert "I" not in trans.df(eclfiles, onlykdir=True)["DIR"] # A warning is logged, seems strange to filter on both, but # the answer (empty) makes sense given the instruction. Alternative # would be a ValueError. assert trans.df(eclfiles, onlykdir=True, onlyijdir=True).empty transnnc_df = trans.df(eclfiles, addnnc=True) assert len(transnnc_df) > trans_full_length trans_df = trans.df(eclfiles, vectors=["FIPNUM", "EQLNUM"], boundaryfilter=True) assert trans_df.empty trans_df = trans.df(eclfiles, vectors="FIPNUM", boundaryfilter=True) assert len(trans_df) < trans_full_length trans_df = trans.df(eclfiles, coords=True) assert "X" in trans_df assert "Y" in trans_df