Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sgofstr = """
SGOF
0 0 1 1
1 1 0 0
/
0 0 1 1
0.5 0.5 0.5 0.5
1 1 0 0
/
0 0 1 0
0.1 0.1 0.1 0.1
1 1 0 0
/
"""
tmpdir.chdir()
assert inferdims.guess_dim(sgofstr, "TABDIMS", 0) == 3
sgofdf = satfunc.df(sgofstr)
assert "SATNUM" in sgofdf
assert len(sgofdf["SATNUM"].unique()) == 3
assert len(sgofdf) == 8
inc = satfunc.df2ecl(sgofdf)
df_from_inc = satfunc.df(inc)
pd.testing.assert_frame_equal(sgofdf, df_from_inc)
# Write to file and try to parse it with command line:
sgoffile = "__sgof_tmp.txt"
with open(sgoffile, "w") as sgof_f:
sgof_f.write(sgofstr)
sys.argv = ["ecl2csv", "satfunc", "-v", sgoffile, "-o", sgoffile + ".csv"]
ecl2csv.main()
parsed_sgof = pd.read_csv(sgoffile + ".csv")
def test_guess_satnumcount():
"""Test that we are able to guess the SATUM count in difficult cases"""
# We always require a newline after a "/" in the Eclipse syntax
# (anything between a / and \n is ignored)
assert inferdims.guess_dim("SWOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SWOF\n0/\n0/ \n0/\n", "TABDIMS", 0) == 3
assert inferdims.guess_dim("SWFN\n0/\n\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n", "TABDIMS", 0) == 1
assert inferdims.guess_dim("SGOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n0/\n0/\n", "TABDIMS", 0) == 3
assert (
inferdims.guess_dim("SGOF\n0 0 0 0/\n0 0 0 0/\n0 0 0 0/\n", "TABDIMS", 0) == 3
)
assert (
inferdims.guess_dim(
"SGOF\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1/\n", "TABDIMS", 0
)
== 3
)
def test_guess_satnumcount():
"""Test that we are able to guess the SATUM count in difficult cases"""
# We always require a newline after a "/" in the Eclipse syntax
# (anything between a / and \n is ignored)
assert inferdims.guess_dim("SWOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SWOF\n0/\n0/ \n0/\n", "TABDIMS", 0) == 3
assert inferdims.guess_dim("SWFN\n0/\n\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n", "TABDIMS", 0) == 1
assert inferdims.guess_dim("SGOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n0/\n0/\n", "TABDIMS", 0) == 3
assert (
inferdims.guess_dim("SGOF\n0 0 0 0/\n0 0 0 0/\n0 0 0 0/\n", "TABDIMS", 0) == 3
)
assert (
inferdims.guess_dim(
"SGOF\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1/\n", "TABDIMS", 0
)
== 3
)
def test_guess_ntequil():
"""Test inferring the correct NTEQUIL"""
assert inferdims.guess_dim("EQUIL\n200 2000/\n2000 2000/\n", "EQLDIMS", 0) == 2
assert inferdims.guess_dim("EQUIL\n200 2000/\n", "EQLDIMS", 0) == 1
assert inferdims.guess_dim("EQUIL\n200 2000 333/\n0 0/\n1 1/\n", "EQLDIMS", 0) == 3
def test_guess_satnumcount():
"""Test that we are able to guess the SATUM count in difficult cases"""
# We always require a newline after a "/" in the Eclipse syntax
# (anything between a / and \n is ignored)
assert inferdims.guess_dim("SWOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SWOF\n0/\n0/ \n0/\n", "TABDIMS", 0) == 3
assert inferdims.guess_dim("SWFN\n0/\n\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n", "TABDIMS", 0) == 1
assert inferdims.guess_dim("SGOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n0/\n0/\n", "TABDIMS", 0) == 3
assert (
inferdims.guess_dim("SGOF\n0 0 0 0/\n0 0 0 0/\n0 0 0 0/\n", "TABDIMS", 0) == 3
)
assert (
inferdims.guess_dim(
"SGOF\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1/\n", "TABDIMS", 0
)
== 3
)
def test_guess_satnumcount():
"""Test that we are able to guess the SATUM count in difficult cases"""
# We always require a newline after a "/" in the Eclipse syntax
# (anything between a / and \n is ignored)
assert inferdims.guess_dim("SWOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SWOF\n0/\n0/ \n0/\n", "TABDIMS", 0) == 3
assert inferdims.guess_dim("SWFN\n0/\n\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n", "TABDIMS", 0) == 1
assert inferdims.guess_dim("SGOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n0/\n0/\n", "TABDIMS", 0) == 3
assert (
inferdims.guess_dim("SGOF\n0 0 0 0/\n0 0 0 0/\n0 0 0 0/\n", "TABDIMS", 0) == 3
)
assert (
inferdims.guess_dim(
"SGOF\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1/\n", "TABDIMS", 0
)
== 3
)
def test_guess_satnumcount():
"""Test that we are able to guess the SATUM count in difficult cases"""
# We always require a newline after a "/" in the Eclipse syntax
# (anything between a / and \n is ignored)
assert inferdims.guess_dim("SWOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SWOF\n0/\n0/ \n0/\n", "TABDIMS", 0) == 3
assert inferdims.guess_dim("SWFN\n0/\n\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n", "TABDIMS", 0) == 1
assert inferdims.guess_dim("SGOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n0/\n0/\n", "TABDIMS", 0) == 3
assert (
inferdims.guess_dim("SGOF\n0 0 0 0/\n0 0 0 0/\n0 0 0 0/\n", "TABDIMS", 0) == 3
)
assert (
inferdims.guess_dim(
"SGOF\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1/\n", "TABDIMS", 0
)
== 3
)
def test_guess_ntequil():
"""Test inferring the correct NTEQUIL"""
assert inferdims.guess_dim("EQUIL\n200 2000/\n2000 2000/\n", "EQLDIMS", 0) == 2
assert inferdims.guess_dim("EQUIL\n200 2000/\n", "EQLDIMS", 0) == 1
assert inferdims.guess_dim("EQUIL\n200 2000 333/\n0 0/\n1 1/\n", "EQLDIMS", 0) == 3
def test_guess_satnumcount():
"""Test that we are able to guess the SATUM count in difficult cases"""
# We always require a newline after a "/" in the Eclipse syntax
# (anything between a / and \n is ignored)
assert inferdims.guess_dim("SWOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SWOF\n0/\n0/ \n0/\n", "TABDIMS", 0) == 3
assert inferdims.guess_dim("SWFN\n0/\n\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n", "TABDIMS", 0) == 1
assert inferdims.guess_dim("SGOF\n0/\n0/\n", "TABDIMS", 0) == 2
assert inferdims.guess_dim("SGOF\n0/\n0/\n0/\n", "TABDIMS", 0) == 3
assert (
inferdims.guess_dim("SGOF\n0 0 0 0/\n0 0 0 0/\n0 0 0 0/\n", "TABDIMS", 0) == 3
)
assert (
inferdims.guess_dim(
"SGOF\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1 1/\n0 0 0 0 1 1 1/\n", "TABDIMS", 0
)
== 3
)