diff --git a/docs/usage/equil.rst b/docs/usage/equil.rst index eebacb641..4aaa2ec4a 100644 --- a/docs/usage/equil.rst +++ b/docs/usage/equil.rst @@ -59,7 +59,7 @@ Eclipse from your modified data by issuing .. code-block:: python - equil.df2ecl(dframe, filename="solution.inc") + equil.df2res(dframe, filename="solution.inc") The last step can also be done using the ``csv2res`` command line utility if you dump to CSV from your Python code instead. diff --git a/docs/usage/grid.rst b/docs/usage/grid.rst index 633ef27a9..902ae76b0 100644 --- a/docs/usage/grid.rst +++ b/docs/usage/grid.rst @@ -147,7 +147,7 @@ Generating Eclipse include files from grid data If you have loaded grid data into a Pandas frame, some operations are easily performed, scaling porosity, permeability etc. Or remapping some region parameters. Using the -:func:`res2df.grid.df2ecl()` function these manipulated vectors can be written back as +:func:`res2df.grid.df2res()` function these manipulated vectors can be written back as include files to Eclipse. Say you want to change the FIPNUM, and that FIPNUM 6 should be removed, and set @@ -165,11 +165,11 @@ it to FIPNUM 5. This can be accomplished using dframe.loc[rows_to_touch, "FIPNUM"] = 5 # Write back to new include file, ensure datatype is integer. - grid.df2ecl(dframe, "FIPNUM", dtype=int, filename="fipnum.inc", resdatafiles=resdatafiles) + grid.df2res(dframe, "FIPNUM", dtype=int, filename="fipnum.inc", resdatafiles=resdatafiles) This will produce the file `fipnum.inc` with the contents: .. literalinclude:: fipnum.inc -It is recommended to supply the ``resdatafiles`` object to ``df2ecl``, if not, correct grid +It is recommended to supply the ``resdatafiles`` object to ``df2res``, if not, correct grid size can not be ensured. diff --git a/docs/usage/nnc.rst b/docs/usage/nnc.rst index 21ed2aa60..71b49f6f5 100644 --- a/docs/usage/nnc.rst +++ b/docs/usage/nnc.rst @@ -55,12 +55,12 @@ to an Eclipse include file: nnc_df = nnc.df(resdatafiles) nnc_df["TRANM"] = 0.1 # Reduce all NNC transmissibilities - nnc.df2ecl_editnnc(nnc_df, filename="editnnc.inc") + nnc.df2res_editnnc(nnc_df, filename="editnnc.inc") and the contents of the exported file can be: .. - print(nnc.df2ecl_editnnc(nnc.df(resdatafiles).head(4).assign(TRANM=0.1))) + print(nnc.df2res_editnnc(nnc.df(resdatafiles).head(4).assign(TRANM=0.1))) .. code-block:: console diff --git a/docs/usage/pvt.rst b/docs/usage/pvt.rst index 2e81ed1df..1b940d026 100644 --- a/docs/usage/pvt.rst +++ b/docs/usage/pvt.rst @@ -75,7 +75,7 @@ Eclipse from your modified data by issuing .. code-block:: python - pvt.df2ecl(dframe, filename="pvt.inc") + pvt.df2res(dframe, filename="pvt.inc") When injecting this produced ``pvt.inc`` into any new input deck, ensure you check which keywords have been written out, compared to what you gave in to diff --git a/docs/usage/satfunc.rst b/docs/usage/satfunc.rst index f4b2ad493..688c4dcc9 100644 --- a/docs/usage/satfunc.rst +++ b/docs/usage/satfunc.rst @@ -57,7 +57,7 @@ the command For a dataframe or a CSV file in the format provided by this module, an Eclipse include file can be generated either with the Python API -:func:`res2df.satfunc.df2ecl` function or the command +:func:`res2df.satfunc.df2res` function or the command .. code-block:: console @@ -117,5 +117,5 @@ Pyscal can create initialize its relperm objects from Eclipse include files though the parsing capabilities of res2df.satfunc. The function ``pyscal.pyscallist.df()`` is analogous to ``res2df.satfunc.df()`` in -what it produces, and the :func:`res2df.satfunc.df2ecl()` can be used on both +what it produces, and the :func:`res2df.satfunc.df2res()` can be used on both (potentially with some filtering needed.). diff --git a/res2df/common.py b/res2df/common.py index 122ddd273..164cbcb86 100644 --- a/res2df/common.py +++ b/res2df/common.py @@ -508,7 +508,7 @@ def fill_reverse_parser( return parser -def df2ecl( +def df2res( dataframe: pd.DataFrame, keywords: Optional[Union[str, List[str], List[Optional[str]]]] = None, comments: Optional[Dict[str, str]] = None, @@ -519,7 +519,7 @@ def df2ecl( """Generate resdata include strings from dataframes in res2df format. This function hands over the actual text generation pr. keyword - to functions named df2ecl_ in the calling module. + to functions named df2res_ in the calling module. These functions may again use generic_ecltable() from this module for the actual string construction. @@ -611,7 +611,7 @@ def df2ecl( string += comment_formatter(comments["master"]) for keyword in keywords: # Construct the associated function names - function_name = "df2ecl_" + keyword.lower() + function_name = "df2res_" + keyword.lower() function = getattr(calling_module, function_name) if keyword in comments: string += function(dataframe, comments[keyword]) diff --git a/res2df/equil.py b/res2df/equil.py index fc3df876e..a7f47ce33 100644 --- a/res2df/equil.py +++ b/res2df/equil.py @@ -348,11 +348,11 @@ def equil_reverse_main(args) -> None: ) equil_df = pd.read_csv(args.csvfile) logger.info("Parsed %s", args.csvfile) - inc_string = df2ecl(equil_df, keywords=args.keywords) + inc_string = df2res(equil_df, keywords=args.keywords) common.write_inc_stdout_file(inc_string, args.output) -def df2ecl( +def df2res( equil_df: pd.DataFrame, keywords: Optional[List[str]] = None, comments: Optional[Dict[str, str]] = None, @@ -381,7 +381,7 @@ def df2ecl( string += ( phases_from_columns(equil_df.columns).upper().replace("-", "\n") + "\n\n" ) - string += common.df2ecl( + string += common.df2res( equil_df, keywords=keywords, comments=comments, @@ -392,7 +392,7 @@ def df2ecl( return string -def df2ecl_equil(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_equil(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print EQUIL keyword with data Args: @@ -427,7 +427,7 @@ def df2ecl_equil(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: ) -def df2ecl_rsvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_rsvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print RSVD keyword with data This data consists of one table (rs as a function @@ -437,10 +437,10 @@ def df2ecl_rsvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: dframe: Containing RSVD data comment Text that will be included as a comment """ - return _df2ecl_equilfuncs("RSVD", dframe, comment) + return _df2res_equilfuncs("RSVD", dframe, comment) -def df2ecl_rvvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_rvvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print RVVD keyword with data This data consists of one table (rv as a function @@ -450,10 +450,10 @@ def df2ecl_rvvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: dframe: Containing RVVD data comment: Text that will be included as a comment """ - return _df2ecl_equilfuncs("RVVD", dframe, comment) + return _df2res_equilfuncs("RVVD", dframe, comment) -def df2ecl_pbvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_pbvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print PBVD keyword with data Bubble-point versus depth @@ -465,10 +465,10 @@ def df2ecl_pbvd(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: dframe: Containing PBVD data comment: Text that will be included as a comment """ - return _df2ecl_equilfuncs("PBVD", dframe, comment) + return _df2res_equilfuncs("PBVD", dframe, comment) -def df2ecl_pdvd(dframe: pd.DataFrame, comment: Optional[str] = None): +def df2res_pdvd(dframe: pd.DataFrame, comment: Optional[str] = None): """Print PDVD keyword with data. Dew-point versus depth. @@ -480,13 +480,13 @@ def df2ecl_pdvd(dframe: pd.DataFrame, comment: Optional[str] = None): dframe: Containing PDVD data comment: Text that will be included as a comment """ - return _df2ecl_equilfuncs("PDVD", dframe, comment) + return _df2res_equilfuncs("PDVD", dframe, comment) -def _df2ecl_equilfuncs( +def _df2res_equilfuncs( keyword: str, dframe: pd.DataFrame, comment: Optional[str] = None ) -> str: - """Internal function to be used by df2ecl_() functions""" + """Internal function to be used by df2res_() functions""" if dframe.empty: return "-- No data!" string = f"{keyword}\n" @@ -500,7 +500,7 @@ def _df2ecl_equilfuncs( else: subset = dframe[dframe["KEYWORD"] == keyword] - def _df2ecl_equilfuncs_eqlnum(dframe: pd.DataFrame) -> str: + def _df2res_equilfuncs_eqlnum(dframe: pd.DataFrame) -> str: """Print one equilibriation function table for a specific EQLNUM @@ -519,5 +519,5 @@ def _df2ecl_equilfuncs_eqlnum(dframe: pd.DataFrame) -> str: subset = subset.set_index("EQLNUM").sort_index() for eqlnum in subset.index.unique(): string += f"-- EQLNUM: {eqlnum}\n" - string += _df2ecl_equilfuncs_eqlnum(subset[subset.index == eqlnum]) + string += _df2res_equilfuncs_eqlnum(subset[subset.index == eqlnum]) return string + "\n" diff --git a/res2df/grid.py b/res2df/grid.py index 2153d2f3b..5f72aa7f3 100644 --- a/res2df/grid.py +++ b/res2df/grid.py @@ -616,7 +616,7 @@ def drop_constant_columns( return dframe.drop(columnstodelete, axis=1) -def df2ecl( +def df2res( grid_df: pd.DataFrame, keywords: Union[str, List[str]], resdatafiles: Optional[ResdataFiles] = None, @@ -730,7 +730,7 @@ def df2ecl( logger.warning( ( "Mismatch between dumped vector length " - "%d from df2ecl and assumed grid size %d" + "%d from df2res and assumed grid size %d" ), len(vector), global_size, diff --git a/res2df/nnc.py b/res2df/nnc.py index a798bc78e..015c28cf2 100644 --- a/res2df/nnc.py +++ b/res2df/nnc.py @@ -200,7 +200,7 @@ def fill_parser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: return parser -def df2ecl_editnnc( +def df2res_editnnc( nnc_df: pd.DataFrame, filename: Optional[str] = None, nocomments: bool = False ) -> str: """Write an EDITNNC keyword diff --git a/res2df/pvt.py b/res2df/pvt.py index 864c1c536..c10fc6355 100644 --- a/res2df/pvt.py +++ b/res2df/pvt.py @@ -319,11 +319,11 @@ def pvt_reverse_main(args) -> None: ) pvt_df = pd.read_csv(args.csvfile) logger.info("Parsed %s", args.csvfile) - inc_string = df2ecl(pvt_df, keywords=args.keywords) + inc_string = df2res(pvt_df, keywords=args.keywords) common.write_inc_stdout_file(inc_string, args.output) -def df2ecl( +def df2res( pvt_df: pd.DataFrame, keywords: Optional[Union[str, List[str]]] = None, comments: Optional[Dict[str, str]] = None, @@ -341,7 +341,7 @@ def df2ecl( filename: If supplied, the generated text will also be dumped to file. """ - return common.df2ecl( + return common.df2res( pvt_df, keywords, comments, @@ -351,7 +351,7 @@ def df2ecl( ) -def df2ecl_rock(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_rock(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print ROCK keyword with data Args: @@ -379,7 +379,7 @@ def df2ecl_rock(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: return string + "\n" -def df2ecl_density(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_density(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print DENSITY keyword with data Args: @@ -408,7 +408,7 @@ def df2ecl_density(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: return string + "\n" -def df2ecl_pvtw(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_pvtw(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print PVTW keyword with data PVTW is one line/record with data for a reference pressure @@ -444,7 +444,7 @@ def df2ecl_pvtw(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: return string + "\n" -def df2ecl_pvtg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_pvtg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print PVTG keyword with data Args: @@ -503,7 +503,7 @@ def _pvtg_pvtnum_pg(dframe): return string + "\n" -def df2ecl_pvdg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_pvdg(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print PVDG keyword with data This data consists of one table (volumefactor and visosity @@ -553,7 +553,7 @@ def _pvdg_pvtnum(dframe): return string + "\n" -def df2ecl_pvdo(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_pvdo(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print PVDO keyword with data Args: @@ -600,7 +600,7 @@ def _pvdo_pvtnum(dframe: pd.DataFrame) -> str: return string + "\n" -def df2ecl_pvto(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res_pvto(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Print PVTO-data from a dataframe Args: diff --git a/res2df/satfunc.py b/res2df/satfunc.py index a7ba81b56..849661a23 100644 --- a/res2df/satfunc.py +++ b/res2df/satfunc.py @@ -228,11 +228,11 @@ def satfunc_reverse_main(args) -> None: ) satfunc_df = pd.read_csv(args.csvfile) logger.info("Parsed %s", args.csvfile) - inc_string = df2ecl(satfunc_df, keywords=args.keywords) + inc_string = df2res(satfunc_df, keywords=args.keywords) common.write_inc_stdout_file(inc_string, args.output) -def df2ecl( +def df2res( satfunc_df: pd.DataFrame, keywords: Optional[List[str]] = None, comments: Optional[Dict[str, str]] = None, @@ -257,7 +257,7 @@ def df2ecl( """ string = "" - string += common.df2ecl( + string += common.df2res( satfunc_df, keywords=keywords, comments=comments, @@ -268,87 +268,87 @@ def df2ecl( return string -def df2ecl_swof(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SWOF data. Used by df2ecl(). +def df2res_swof(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SWOF data. Used by df2res(). Args: dframe: Containing SWOF data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SWOF", dframe, comment) + return _df2res_satfuncs("SWOF", dframe, comment) -def df2ecl_sgof(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SGOF data. Used by df2ecl(). +def df2res_sgof(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SGOF data. Used by df2res(). Args: dframe: Containing SGOF data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SGOF", dframe, comment) + return _df2res_satfuncs("SGOF", dframe, comment) -def df2ecl_sgfn(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SGFN data. Used by df2ecl(). +def df2res_sgfn(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SGFN data. Used by df2res(). Args: dframe: Containing SGFN data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SGFN", dframe, comment) + return _df2res_satfuncs("SGFN", dframe, comment) -def df2ecl_sgwfn(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SGWFN data. Used by df2ecl(). +def df2res_sgwfn(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SGWFN data. Used by df2res(). Args: dframe: Containing SGWFN data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SGWFN", dframe, comment) + return _df2res_satfuncs("SGWFN", dframe, comment) -def df2ecl_swfn(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SWFN data. Used by df2ecl(). +def df2res_swfn(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SWFN data. Used by df2res(). Args: dframe: Containing SWFN data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SWFN", dframe, comment) + return _df2res_satfuncs("SWFN", dframe, comment) -def df2ecl_slgof(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SLGOF data. Used by df2ecl(). +def df2res_slgof(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SLGOF data. Used by df2res(). Args: dframe: Containing SLGOF data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SLGOF", dframe, comment) + return _df2res_satfuncs("SLGOF", dframe, comment) -def df2ecl_sof2(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SOF2 data. Used by df2ecl(). +def df2res_sof2(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SOF2 data. Used by df2res(). Args: dframe: Containing SOF2 data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SOF2", dframe, comment) + return _df2res_satfuncs("SOF2", dframe, comment) -def df2ecl_sof3(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: - """Print SOF3 data. Used by df2ecl(). +def df2res_sof3(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: + """Print SOF3 data. Used by df2res(). Args: dframe: Containing SOF3 data comment: Text that will be included as a comment """ - return _df2ecl_satfuncs("SOF3", dframe, comment) + return _df2res_satfuncs("SOF3", dframe, comment) -def _df2ecl_satfuncs( +def _df2res_satfuncs( keyword: str, dframe: pd.DataFrame, comment: Optional[str] = None ) -> str: if dframe.empty: @@ -366,7 +366,7 @@ def _df2ecl_satfuncs( subset = subset.set_index("SATNUM").sort_index() # Make a function that is to be called for each SATNUM - def _df2ecl_satfuncs_satnum(keyword, dframe): + def _df2res_satfuncs_satnum(keyword, dframe): """Print one saturation function for one specific SATNUM""" col_headers = RENAMERS[keyword]["DATA"] string = ( @@ -380,5 +380,5 @@ def _df2ecl_satfuncs_satnum(keyword, dframe): # Loop over every SATNUM for satnum in subset.index.unique(): string += f"-- SATNUM: {satnum}\n" - string += _df2ecl_satfuncs_satnum(keyword, subset[subset.index == satnum]) + string += _df2res_satfuncs_satnum(keyword, subset[subset.index == satnum]) return string + "\n" diff --git a/res2df/summary.py b/res2df/summary.py index 008a09808..bcf228a46 100644 --- a/res2df/summary.py +++ b/res2df/summary.py @@ -679,7 +679,7 @@ def _fix_dframe_for_libecl(dframe: pd.DataFrame) -> pd.DataFrame: return dframe -def df2eclsum( +def df2ressum( dframe: pd.DataFrame, casename: str = "SYNTHETIC", ) -> Summary: @@ -938,7 +938,7 @@ def summary_reverse_main(args) -> None: # Summary.fwrite() can only write to current directory: cwd = os.getcwd() - eclsum = df2eclsum(summary_df, eclbase) + eclsum = df2ressum(summary_df, eclbase) try: os.chdir(outputdir) Summary.fwrite(eclsum) diff --git a/res2df/vfp/__init__.py b/res2df/vfp/__init__.py index 6f3a7dd8e..4fd957cbf 100644 --- a/res2df/vfp/__init__.py +++ b/res2df/vfp/__init__.py @@ -7,8 +7,8 @@ basic_data2pyarrow, df, df2basic_data, - df2ecl, - df2ecls, + df2res, + df2ress, dfs, fill_parser, fill_reverse_parser, diff --git a/res2df/vfp/_vfp.py b/res2df/vfp/_vfp.py index 048f9a54e..a5c3b0664 100755 --- a/res2df/vfp/_vfp.py +++ b/res2df/vfp/_vfp.py @@ -326,7 +326,7 @@ def pyarrow_tables( return pyarrow_tables_vfp -def df2ecls( +def df2ress( dframe: pd.DataFrame, keyword: str = "VFPPROD", comments: Optional[Dict[str, str]] = None, @@ -355,14 +355,14 @@ def df2ecls( if np.all(df_vfp["VFP_TYPE"] == keyword): if comments and keyword in comments.keys(): if keyword == "VFPPROD": - vfp_strs.append(vfpprod.df2ecl(df_vfp, comments["VFPPROD"])) + vfp_strs.append(vfpprod.df2res(df_vfp, comments["VFPPROD"])) elif keyword == "VFPINJ": - vfp_strs.append(vfpinj.df2ecl(df_vfp, comments["VFPINJ"])) + vfp_strs.append(vfpinj.df2res(df_vfp, comments["VFPINJ"])) else: if keyword == "VFPPROD": - vfp_strs.append(vfpprod.df2ecl(df_vfp)) + vfp_strs.append(vfpprod.df2res(df_vfp)) elif keyword == "VFPINJ": - vfp_strs.append(vfpinj.df2ecl(df_vfp)) + vfp_strs.append(vfpinj.df2res(df_vfp)) else: raise ValueError( f"VFP number {vfpno} does not have consistent " @@ -372,7 +372,7 @@ def df2ecls( return vfp_strs -def df2ecl( +def df2res( dframe: pd.DataFrame, keyword: str = "VFPPROD", comments: Optional[Dict[str, str]] = None, @@ -392,7 +392,7 @@ def df2ecl( to file. """ - strs_vfp = df2ecls(dframe, keyword=keyword, comments=comments) + strs_vfp = df2ress(dframe, keyword=keyword, comments=comments) str_vfps = "" if comments and "master" in comments.keys(): @@ -529,6 +529,6 @@ def vfp_reverse_main(args) -> None: ) vfp_df = pd.read_csv(args.csvfile) logger.info("Parsed {args.csvfile}") - inc_string = df2ecl(vfp_df, args.keyword) + inc_string = df2res(vfp_df, args.keyword) if args.output: common.write_inc_stdout_file(inc_string, args.output) diff --git a/res2df/vfp/_vfpinj.py b/res2df/vfp/_vfpinj.py index 76e75af88..7771e5bc2 100755 --- a/res2df/vfp/_vfpinj.py +++ b/res2df/vfp/_vfpinj.py @@ -651,7 +651,7 @@ def _write_table_records( return ecl_str -def df2ecl(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Produce a string defining single VFPINJ Eclipse input from a dataframe All data for the keywords VFPINJ will be returned. diff --git a/res2df/vfp/_vfpprod.py b/res2df/vfp/_vfpprod.py index 4e2573127..0a0d62393 100755 --- a/res2df/vfp/_vfpprod.py +++ b/res2df/vfp/_vfpprod.py @@ -935,7 +935,7 @@ def _write_table_records( return ecl_str -def df2ecl(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: +def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str: """Produce a string defining single VFPPROD Eclipse input from a dataframe All data for the keywords VFPPROD will be returned. diff --git a/tests/test_common.py b/tests/test_common.py index 284c3525b..f09d0f681 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -151,15 +151,15 @@ def test_handle_wanted_keywords(wanted, deckstr, supported, expected): assert common.handle_wanted_keywords(wanted, deck, supported) == expected -def df2ecl_equil(dframe, comment: str = None): - """Wrapper function to be able to test df2ecl +def df2res_equil(dframe, comment: str = None): + """Wrapper function to be able to test df2res (it asks for a function in the calling module)""" - return equil.df2ecl_equil(dframe, comment) + return equil.df2res_equil(dframe, comment) -def test_df2ecl(): - """Test general properties of df2ecl. +def test_df2res(): + """Test general properties of df2res. This function is mainly tested in each submodule.""" dframe = pd.DataFrame( @@ -177,33 +177,33 @@ def test_df2ecl(): ) with pytest.raises(AssertionError): # supported keywords are not supplied - common.df2ecl(dframe) + common.df2res(dframe) with pytest.raises(AssertionError): - common.df2ecl(dframe, supported=None) + common.df2res(dframe, supported=None) with pytest.raises(ValueError, match="KEYWORD must be in the dataframe"): - common.df2ecl( + common.df2res( dframe.drop("KEYWORD", axis=1), keywords=["EQUIL"], supported=["EQUIL"] ) - string = common.df2ecl(dframe, supported=["EQUIL"]) + string = common.df2res(dframe, supported=["EQUIL"]) # The next calls differ only in timestamp: assert len(string) == len( - common.df2ecl(dframe, keywords="EQUIL", supported=["EQUIL"]) + common.df2res(dframe, keywords="EQUIL", supported=["EQUIL"]) ) assert len(string) == len( - common.df2ecl(dframe, keywords=["EQUIL"], supported=["EQUIL"]) + common.df2res(dframe, keywords=["EQUIL"], supported=["EQUIL"]) ) assert "EQUIL\n" in string assert "2469" in string assert "-- Output file printed by tests.test_common" in string - assert common.df2ecl(dframe, supported=["PORO"]) == "" + assert common.df2res(dframe, supported=["PORO"]) == "" - assert "EQUIL\n-- foobar" in common.df2ecl( + assert "EQUIL\n-- foobar" in common.df2res( dframe, comments={"EQUIL": "foobar"}, supported=["EQUIL"] ) - assert "\n\n-- masterfoobar\nEQUIL" in common.df2ecl( + assert "\n\n-- masterfoobar\nEQUIL" in common.df2res( dframe, comments={"master": "masterfoobar"}, supported=["EQUIL"] ) @@ -211,16 +211,16 @@ def test_df2ecl(): tworows["EQLNUM"] = [3, 1] tworows["PRESSURE"] = [3456, 1234] with pytest.raises(ValueError): - common.df2ecl(tworows, supported=["EQUIL"], consecutive="EQLNUM") + common.df2res(tworows, supported=["EQUIL"], consecutive="EQLNUM") # This would be a bug if client code did this, because the wrong # consecutive column is set: - assert "3456" in common.df2ecl(tworows, supported=["EQUIL"], consecutive="PVTNUM") + assert "3456" in common.df2res(tworows, supported=["EQUIL"], consecutive="PVTNUM") tworows["EQLNUM"] = [1, 3] with pytest.raises(ValueError): - common.df2ecl(tworows, supported=["EQUIL"], consecutive="EQLNUM") + common.df2res(tworows, supported=["EQUIL"], consecutive="EQLNUM") tworows["EQLNUM"] = [2, 1] # Passes because the frame is sorted on EQLNUM: - string = common.df2ecl(tworows, supported=["EQUIL"], consecutive="EQLNUM") + string = common.df2res(tworows, supported=["EQUIL"], consecutive="EQLNUM") assert "EQUIL" in string assert string.find("3456") > string.find("1234") diff --git a/tests/test_equil.py b/tests/test_equil.py index 45bb4e54d..698d3c9a4 100644 --- a/tests/test_equil.py +++ b/tests/test_equil.py @@ -77,25 +77,25 @@ def test_equil2df(): # Check that we can dump from dataframe to include file # and reparse to the same dataframe: - inc = equil.df2ecl(equildf, withphases=True) + inc = equil.df2res(equildf, withphases=True) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(equildf, df_from_inc, check_dtype=False) -def test_df2ecl(tmp_path): +def test_df2res(tmp_path): """Test that we can write include files to disk""" os.chdir(tmp_path) resdatafiles = ResdataFiles(EIGHTCELLS) equildf = equil.df(resdatafiles) - equil.df2ecl(equildf, filename="equil.inc") + equil.df2res(equildf, filename="equil.inc") assert Path("equil.inc").is_file() # Test automatic directory creation: - equil.df2ecl(equildf, filename="eclipse/include/equil.inc") + equil.df2res(equildf, filename="eclipse/include/equil.inc") assert Path("eclipse/include/equil.inc").is_file() -def test_df2ecl_equil(): +def test_df2res_equil(): """Test the underlying function directly""" dframe = pd.DataFrame( [ @@ -111,18 +111,18 @@ def test_df2ecl_equil(): ] ) # Check that we don't need the KEYWORD in the underlying function - assert equil.df2ecl_equil(dframe) == equil.df2ecl_equil( + assert equil.df2res_equil(dframe) == equil.df2res_equil( dframe.drop("KEYWORD", axis="columns") ) # Can also drop EQLNUM since we have only one row: - assert equil.df2ecl_equil(dframe) == equil.df2ecl_equil( + assert equil.df2res_equil(dframe) == equil.df2res_equil( dframe.drop("EQLNUM", axis="columns") ) # Problem if we have two rows, nothing is returned and a critical error is logged assert ( - equil.df2ecl_equil(pd.concat([dframe, dframe]).drop("EQLNUM", axis="columns")) + equil.df2res_equil(pd.concat([dframe, dframe]).drop("EQLNUM", axis="columns")) == "" ) @@ -142,22 +142,22 @@ def test_decks(): assert len(df) == 1 assert "IGNORE1" not in df assert df["EQLNUM"].unique()[0] == 1 - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) # 0 columns can be both integers and floats. pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) # Test empty data: - inc = equil.df2ecl_equil(equil.df("")) + inc = equil.df2res_equil(equil.df("")) assert "No data" in inc assert equil.df(inc).empty # Test more empty data: - assert "No data" in equil.df2ecl_equil(equil.df("")) - assert "No data" in equil.df2ecl_rsvd(equil.df("")) - assert "No data" in equil.df2ecl_rvvd(equil.df("")) - assert "No data" in equil.df2ecl_pbvd(equil.df("")) - assert "No data" in equil.df2ecl_pdvd(equil.df("")) + assert "No data" in equil.df2res_equil(equil.df("")) + assert "No data" in equil.df2res_rsvd(equil.df("")) + assert "No data" in equil.df2res_rvvd(equil.df("")) + assert "No data" in equil.df2res_pbvd(equil.df("")) + assert "No data" in equil.df2res_pdvd(equil.df("")) deckstr = """ OIL @@ -170,7 +170,7 @@ def test_decks(): assert df["OWC"].values == 2200 assert len(df) == 1 assert "IGNORE1" not in df - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) # 0 columns can be both integers and floats. pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) @@ -187,7 +187,7 @@ def test_decks(): assert "OWC" not in df assert len(df) == 1 assert "IGNORE2" not in df - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) # 0 columns can be both integers and floats. pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) @@ -205,7 +205,7 @@ def test_decks(): assert "OWC" not in df assert len(df) == 1 assert "IGNORE2" not in df - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) # 0 columns can be both integers and floats. pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) @@ -229,7 +229,7 @@ def test_decks(): assert "OWC" in df assert len(df) == 2 assert "IGNORE2" not in df - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) # 0 columns can be both integers and floats. pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) @@ -294,7 +294,7 @@ def test_rsvd(): assert max(rsvd_df["EQLNUM"]) == 3 assert set(rsvd_df["Z"].values) == {10, 30, 50} assert set(rsvd_df["RS"].values) == {100, 400} - inc = equil.df2ecl(rsvd_df) + inc = equil.df2res(rsvd_df) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(rsvd_df, df_from_inc) @@ -317,7 +317,7 @@ def test_rsvd(): assert max(rsvd_df["EQLNUM"]) == 2 assert set(rsvd_df["Z"].values) == {10, 30, 50, 60} assert set(rsvd_df["RS"].values) == {100, 400, 1000} - inc = equil.df2ecl(rsvd_df) + inc = equil.df2res(rsvd_df) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(rsvd_df, df_from_inc) @@ -340,7 +340,7 @@ def test_rvvd(): assert set(rvvd_df["Z"].values) == {10, 30, 50} assert set(rvvd_df["RV"].values) == {100, 400} - inc = equil.df2ecl(rvvd_df) + inc = equil.df2res(rvvd_df) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(rvvd_df, df_from_inc) @@ -364,7 +364,7 @@ def test_rvvd(): assert set(rvvd_df["Z"].values) == {10, 30, 50, 60} assert set(rvvd_df["RV"].values) == {100, 400, 1000} - inc = equil.df2ecl(rvvd_df) + inc = equil.df2res(rvvd_df) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(rvvd_df, df_from_inc) @@ -383,7 +383,7 @@ def test_pbvd(): assert set(pbvd_df["Z"].values) == {10, 30, 50} assert set(pbvd_df["PB"].values) == {100, 400} - inc = equil.df2ecl(pbvd_df) + inc = equil.df2res(pbvd_df) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(pbvd_df, df_from_inc) @@ -394,14 +394,14 @@ def test_pbvd(): pd.testing.assert_frame_equal(pbvd_df.drop("KEYWORD", axis="columns"), pbvd_df2) # Check that we don't need the KEYWORD column for the underlying function: - assert equil.df2ecl_pbvd(pbvd_df) == equil.df2ecl_pbvd( + assert equil.df2res_pbvd(pbvd_df) == equil.df2res_pbvd( pbvd_df.drop("KEYWORD", axis="columns") ) # If EQLNUM column is dropped it is not possible to guess the # correct include file, so the code must fail: with pytest.raises(KeyError): - equil.df2ecl_pbvd(pbvd_df.drop("EQLNUM", axis="columns")) + equil.df2res_pbvd(pbvd_df.drop("EQLNUM", axis="columns")) def test_pdvd(): @@ -418,7 +418,7 @@ def test_pdvd(): assert set(pdvd_df["Z"].values) == {10, 30, 50} assert set(pdvd_df["PD"].values) == {100, 400} - inc = equil.df2ecl(pdvd_df) + inc = equil.df2res(pdvd_df) df_from_inc = equil.df(inc) pdvd_df2 = equil.pdvd_fromdeck(deckstr) pd.testing.assert_frame_equal(pdvd_df, df_from_inc) @@ -467,7 +467,7 @@ def test_ntequl(): df = equil.df(deckstr, ntequl=2) assert len(df) == 2 - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) @@ -494,7 +494,7 @@ def test_ntequl(): assert set(df["GOC"].values) == set([2100, 2100]) assert len(df) == 2 - inc = equil.df2ecl(df, withphases=True) + inc = equil.df2res(df, withphases=True) df_from_inc = equil.df(inc) pd.testing.assert_frame_equal(df, df_from_inc, check_dtype=False) @@ -536,7 +536,7 @@ def test_eclipse_rounding(somefloat, expected): } ] ) - assert expected in equil.df2ecl(dframe, withphases=False) + assert expected in equil.df2res(dframe, withphases=False) def test_main_subparser(tmp_path, mocker): diff --git a/tests/test_grid.py b/tests/test_grid.py index 400782997..7116e917e 100644 --- a/tests/test_grid.py +++ b/tests/test_grid.py @@ -188,17 +188,17 @@ def test_grid_df(): ) -def test_df2ecl(tmp_path): +def test_df2res(tmp_path): """Test if we are able to output include files for grid data""" resdatafiles = ResdataFiles(REEK) grid_df = grid.df(resdatafiles) - fipnum_str = grid.df2ecl(grid_df, "FIPNUM", dtype=int) - assert grid.df2ecl(grid_df, "FIPNUM", dtype="int", nocomments=True) == grid.df2ecl( + fipnum_str = grid.df2res(grid_df, "FIPNUM", dtype=int) + assert grid.df2res(grid_df, "FIPNUM", dtype="int", nocomments=True) == grid.df2res( grid_df, "FIPNUM", dtype=int, nocomments=True ) with pytest.raises(ValueError, match="Wrong dtype argument foo"): - grid.df2ecl(grid_df, "FIPNUM", dtype="foo") + grid.df2res(grid_df, "FIPNUM", dtype="foo") assert "FIPNUM" in fipnum_str assert "-- Output file printed by res2df.grid" in fipnum_str @@ -206,51 +206,51 @@ def test_df2ecl(tmp_path): assert "35840 total cell count" in fipnum_str # (comment at the end) assert len(fipnum_str) > 100 - fipnum_str_nocomment = grid.df2ecl(grid_df, "FIPNUM", dtype=int, nocomments=True) + fipnum_str_nocomment = grid.df2res(grid_df, "FIPNUM", dtype=int, nocomments=True) assert "--" not in fipnum_str_nocomment - fipnum2_str = grid.df2ecl( + fipnum2_str = grid.df2res( grid_df, "FIPNUM", dtype=int, resdatafiles=resdatafiles, nocomments=True ) # This would mean that we guessed the correct global size in the first run assert fipnum_str_nocomment == fipnum2_str - float_fipnum_str = grid.df2ecl(grid_df, "FIPNUM", dtype=float) + float_fipnum_str = grid.df2res(grid_df, "FIPNUM", dtype=float) assert len(float_fipnum_str) > len(fipnum_str) # lots of .0 in the string. - fipsatnum_str = grid.df2ecl(grid_df, ["FIPNUM", "SATNUM"], dtype=int) + fipsatnum_str = grid.df2res(grid_df, ["FIPNUM", "SATNUM"], dtype=int) assert "FIPNUM" in fipsatnum_str assert "SATNUM" in fipsatnum_str grid_df["FIPNUM"] = grid_df["FIPNUM"] * 3333 - fipnum_big_str = grid.df2ecl(grid_df, "FIPNUM", dtype=int) + fipnum_big_str = grid.df2res(grid_df, "FIPNUM", dtype=int) assert "3333" in fipnum_big_str assert len(fipnum_big_str) > len(fipnum_str) os.chdir(tmp_path) - grid.df2ecl(grid_df, ["PERMX", "PERMY", "PERMZ"], dtype=float, filename="perm.inc") + grid.df2res(grid_df, ["PERMX", "PERMY", "PERMZ"], dtype=float, filename="perm.inc") assert Path("perm.inc").is_file() incstring = Path("perm.inc").read_text(encoding="utf8").splitlines() assert sum([1 for line in incstring if "PERM" in line]) == 6 - assert grid.df2ecl(grid_df, ["PERMX"], dtype=float, nocomments=True) == grid.df2ecl( + assert grid.df2res(grid_df, ["PERMX"], dtype=float, nocomments=True) == grid.df2res( grid_df, ["PERMX"], dtype="float", nocomments=True ) # with pytest.raises(ValueError, match="Wrong dtype argument"): - grid.df2ecl(grid_df, ["PERMX"], dtype=dict) + grid.df2res(grid_df, ["PERMX"], dtype=dict) with pytest.raises(ValueError): - grid.df2ecl(grid_df, ["PERMRR"]) + grid.df2res(grid_df, ["PERMRR"]) # Check when we have restart info included: gr_rst = grid.df(resdatafiles, rstdates="all") - fipnum_str_rst = grid.df2ecl(gr_rst, "FIPNUM", dtype=int, nocomments=True) + fipnum_str_rst = grid.df2res(gr_rst, "FIPNUM", dtype=int, nocomments=True) assert fipnum_str_rst == fipnum_str_nocomment # When dates are stacked, there are NaN's in the FIPNUM column, # which should be gracefully ignored. gr_rst_stacked = grid.df(resdatafiles, rstdates="all", stackdates=True) - fipnum_str_rst = grid.df2ecl(gr_rst_stacked, "FIPNUM", dtype=int, nocomments=True) + fipnum_str_rst = grid.df2res(gr_rst_stacked, "FIPNUM", dtype=int, nocomments=True) assert fipnum_str_rst == fipnum_str_nocomment # dateinheaders here will be ignored due to stackdates: @@ -260,10 +260,10 @@ def test_df2ecl(tmp_path): ) -def test_df2ecl_mock(): - """Test that we can use df2ecl for mocked minimal dataframes""" +def test_df2res_mock(): + """Test that we can use df2res for mocked minimal dataframes""" a_grid = pd.DataFrame(columns=["FIPNUM"], data=[[1], [2], [3]]) - simple_fipnum_inc = grid.df2ecl( + simple_fipnum_inc = grid.df2res( a_grid, keywords="FIPNUM", dtype=int, nocomments=True ) # (A warning is printed, that warning is warranted) diff --git a/tests/test_nnc.py b/tests/test_nnc.py index 48a64b94c..c6fa545a8 100644 --- a/tests/test_nnc.py +++ b/tests/test_nnc.py @@ -87,14 +87,14 @@ def test_nnc2df_faultnames(): # Remove I_x, J_x, K_x (and _y) which is not needed -def test_df2ecl_editnnc(tmp_path): +def test_df2res_editnnc(tmp_path): """Test generation of EDITNNC keyword""" resdatafiles = ResdataFiles(REEK) nncdf = nnc.df(resdatafiles) os.chdir(tmp_path) nncdf["TRANM"] = 2 - editnnc = nnc.df2ecl_editnnc(nncdf, filename="editnnc.inc") + editnnc = nnc.df2res_editnnc(nncdf, filename="editnnc.inc") editnnc_fromfile = Path("editnnc.inc").read_text(encoding="utf8") assert editnnc == editnnc_fromfile assert "EDITNNC" in editnnc @@ -103,17 +103,17 @@ def test_df2ecl_editnnc(tmp_path): # Fails when columns are missing with pytest.raises((KeyError, ValueError)): - nnc.df2ecl_editnnc(nncdf[["I1", "I2"]]) + nnc.df2res_editnnc(nncdf[["I1", "I2"]]) - editnnc = nnc.df2ecl_editnnc(nncdf, nocomments=True) + editnnc = nnc.df2res_editnnc(nncdf, nocomments=True) assert "avg multiplier" not in editnnc # Test compatibility with trans module: trans_df = trans.df(resdatafiles, addnnc=True) - editnnc = nnc.df2ecl_editnnc(trans_df.assign(TRANM=0.3)) + editnnc = nnc.df2res_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(resdatafiles).head(4).assign(TRANM=0.1))) + print(nnc.df2res_editnnc(nnc.df(resdatafiles).head(4).assign(TRANM=0.1))) @pytest.mark.skipif(not HAVE_OPM, reason="Requires OPM") diff --git a/tests/test_pvt.py b/tests/test_pvt.py index 6b77beda2..e31aa7495 100644 --- a/tests/test_pvt.py +++ b/tests/test_pvt.py @@ -47,7 +47,7 @@ def test_pvto_strings(): assert set(dframe["PVTNUM"].values) == {1} assert max(dframe["PRESSURE"]) == 200 - dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe)) + dframe_via_string = pvt.pvto_fromdeck(pvt.df2res_pvto(dframe)) pd.testing.assert_frame_equal(dframe_via_string, dframe) # Provide TABDIMS in first test.. Infer later @@ -72,7 +72,7 @@ def test_pvto_strings(): assert len(dframe["PRESSURE"].unique()) == 6 assert len(dframe["VOLUMEFACTOR"].unique()) == 3 - dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe)) + dframe_via_string = pvt.pvto_fromdeck(pvt.df2res_pvto(dframe)) pd.testing.assert_frame_equal(dframe_via_string, dframe) # Now test the same but without TABDIMS: @@ -94,11 +94,11 @@ def test_pvto_strings(): assert len(dframe["RS"].unique()) == 4 assert len(dframe["PRESSURE"].unique()) == 6 assert len(dframe["VOLUMEFACTOR"].unique()) == 3 - dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe)) + dframe_via_string = pvt.pvto_fromdeck(pvt.df2res_pvto(dframe)) pd.testing.assert_frame_equal(dframe_via_string, dframe) # Test emtpy data: - inc = pvt.df2ecl_pvto(pvt.df("")) + inc = pvt.df2res_pvto(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -123,7 +123,7 @@ def test_pvdg_string(): assert "VISCOSITY" in dframe # Test emtpy data: - inc = pvt.df2ecl_pvdg(pvt.df("")) + inc = pvt.df2res_pvdg(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -152,7 +152,7 @@ def test_pvdo_string(): ) # Test emtpy data: - inc = pvt.df2ecl_pvdo(pvt.df("")) + inc = pvt.df2res_pvdo(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -177,7 +177,7 @@ def test_pvt_reek(): assert pvto_df["VOLUMEFACTOR"].max() == 2.851 assert pvto_df["VISCOSITY"].max() == 1.0001 - dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(pvto_df)) + dframe_via_string = pvt.pvto_fromdeck(pvt.df2res_pvto(pvto_df)) pd.testing.assert_frame_equal(dframe_via_string, pvto_df) density_df = pvt.density_fromdeck(resdatafiles.get_ecldeck()) @@ -189,7 +189,7 @@ def test_pvt_reek(): ), check_like=True, ) - dframe_via_string = pvt.density_fromdeck(pvt.df2ecl_density(density_df)) + dframe_via_string = pvt.density_fromdeck(pvt.df2res_density(density_df)) pd.testing.assert_frame_equal(dframe_via_string, density_df) rock_df = pvt.rock_fromdeck(resdatafiles.get_ecldeck()) @@ -263,7 +263,7 @@ def test_pvtg_string(): assert max(pvtg_df["VISCOSITY"]) == 0.0393 # Test empty data: - inc = pvt.df2ecl_pvtg(pvt.df("")) + inc = pvt.df2res_pvtg(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -300,7 +300,7 @@ def test_density(): assert "WATERDENSITY" in density_df assert "GASDENSITY" in density_df - dframe_via_string = pvt.density_fromdeck(pvt.df2ecl_density(density_df)) + dframe_via_string = pvt.density_fromdeck(pvt.df2res_density(density_df)) pd.testing.assert_frame_equal(dframe_via_string, density_df) two_pvtnum_deck = """DENSITY @@ -316,11 +316,11 @@ def test_density(): assert density_df["PVTNUM"].max() == 2 assert density_df["PVTNUM"].min() == 1 assert "OILDENSITY" in density_df - dframe_via_string = pvt.density_fromdeck(pvt.df2ecl_density(density_df)) + dframe_via_string = pvt.density_fromdeck(pvt.df2res_density(density_df)) pd.testing.assert_frame_equal(dframe_via_string, density_df) # Test emtpy data: - inc = pvt.df2ecl_density(pvt.df("")) + inc = pvt.df2res_density(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -353,7 +353,7 @@ def test_pvtw(): assert len(pvtw_df) == 2 # Test emtpy data: - inc = pvt.df2ecl_pvtw(pvt.df("")) + inc = pvt.df2res_pvtw(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -366,11 +366,11 @@ def test_rock(): assert len(rock_df) == 1 assert "PRESSURE" in rock_df assert "COMPRESSIBILITY" in rock_df - dframe_via_string = pvt.rock_fromdeck(pvt.df2ecl_rock(rock_df)) + dframe_via_string = pvt.rock_fromdeck(pvt.df2res_rock(rock_df)) pd.testing.assert_frame_equal(dframe_via_string, rock_df) # Test emtpy data: - inc = pvt.df2ecl_rock(pvt.df("")) + inc = pvt.df2res_rock(pvt.df("")) assert "No data" in inc assert pvt.df(inc).empty @@ -475,22 +475,22 @@ def test_magic_stdout(tmp_path): assert not dframe.empty -def test_df2ecl(): - """df2ecl is a wrapper around the df2ecl_* functions +def test_df2res(): + """df2res is a wrapper around the df2res_* functions The validity of produced dataframes is tested in other test functions herein, here we mainly test for the API and error handling""" with pytest.raises(ValueError): - pvt.df2ecl(pd.DataFrame()) + pvt.df2res(pd.DataFrame()) -def test_df2ecl_pvto(): +def test_df2res_pvto(): """Test that we can print a PVTO dataframe to E100 include file""" dframe = pd.DataFrame( columns=["PVTNUM", "RS", "PRESSURE", "VOLUMEFACTOR", "VISCOSITY"], data=[[1, 50, 100, 2, 1.04]], ) - pvto_string = pvt.df2ecl_pvto(dframe) + pvto_string = pvt.df2res_pvto(dframe) assert "PVTO" in pvto_string assert "1.04" in pvto_string assert "100" in pvto_string @@ -506,7 +506,7 @@ def test_df2ecl_pvto(): columns=["PVTNUM", "RS", "PRESSURE", "VOLUMEFACTOR", "VISCOSITY"], data=[[1, 50, 100, 2, 1.04], [1, 50, 120, 3, 1.05]], ) - pvto_string = pvt.df2ecl_pvto(dframe) + pvto_string = pvt.df2res_pvto(dframe) assert "PVTO" in pvto_string assert "1.05" in pvto_string assert "120" in pvto_string @@ -519,17 +519,17 @@ def test_df2ecl_pvto(): ) # If PVTNUM is missing, the code gives up if there are many rows. - assert "PVTO" not in pvt.df2ecl_pvto( + assert "PVTO" not in pvt.df2res_pvto( pd.concat([dframe, dframe]).drop("PVTNUM", axis="columns") ) # If only one row, this is accepted: - assert "PVTO" in pvt.df2ecl_pvto(dframe.head(1).drop("PVTNUM", axis="columns")) + assert "PVTO" in pvt.df2res_pvto(dframe.head(1).drop("PVTNUM", axis="columns")) # (the corner case with only one row is not very meaningful, but at # least it is well defined how to treat it) -def test_df2ecl_rock(tmp_path): +def test_df2res_rock(tmp_path): """Test generation of ROCK include files from dataframes""" os.chdir(tmp_path) @@ -538,14 +538,14 @@ def test_df2ecl_rock(tmp_path): data=[[1, "ROCK", 100, 0.001]], ) - rock_inc = pvt.df2ecl(rock_df) + rock_inc = pvt.df2res(rock_df) assert "ROCK" in rock_inc - rock_inc = pvt.df2ecl(rock_df, comments=dict(ROCK="foo")) + rock_inc = pvt.df2res(rock_df, comments=dict(ROCK="foo")) assert "foo" in rock_inc - rock_inc = pvt.df2ecl(rock_df, comments=dict(DENSITY="foo")) + rock_inc = pvt.df2res(rock_df, comments=dict(DENSITY="foo")) assert "foo" not in rock_inc - rock_inc = pvt.df2ecl(rock_df, comments=dict(ROCK="foo\nbar"), filename="foo.inc") + rock_inc = pvt.df2res(rock_df, comments=dict(ROCK="foo\nbar"), filename="foo.inc") assert Path("foo.inc").is_file() assert "foo" in rock_inc assert "bar" in rock_inc @@ -559,15 +559,15 @@ def test_df2ecl_rock(tmp_path): rock_df = rock_df_from_inc.reindex(sorted(rock_df.columns), axis=1) pd.testing.assert_frame_equal(rock_df_from_inc, rock_df) - rock_inc = pvt.df2ecl(rock_df, keywords=["DENSITY"]) + rock_inc = pvt.df2res(rock_df, keywords=["DENSITY"]) assert not rock_inc - rock_inc = pvt.df2ecl(rock_df, keywords="DENSITY") + rock_inc = pvt.df2res(rock_df, keywords="DENSITY") assert not rock_inc - rock_inc = pvt.df2ecl(rock_df, keywords=["ROCK", "DENSITY"]) + rock_inc = pvt.df2res(rock_df, keywords=["ROCK", "DENSITY"]) assert "ROCK" in rock_inc assert "DENSITY" not in rock_inc - rock_inc = pvt.df2ecl(rock_df, keywords="ROCK") + rock_inc = pvt.df2res(rock_df, keywords="ROCK") assert "ROCK" in rock_inc # This dataframe is ignored, if we miss PVTNUM: @@ -575,40 +575,40 @@ def test_df2ecl_rock(tmp_path): columns=["KEYWORD", "PRESSURE", "COMPRESSIBILITY"], data=[["ROCK", 100, 0.001], ["ROCK", 200, 0.002]], ) - assert "ROCK" not in pvt.df2ecl_rock(ambig_rock_df) + assert "ROCK" not in pvt.df2res_rock(ambig_rock_df) # But if only one row, it is ok: - assert "ROCK" in pvt.df2ecl_rock(ambig_rock_df.head(1)) + assert "ROCK" in pvt.df2res_rock(ambig_rock_df.head(1)) # If we don't want the ROCK keyword, we won't get it: - nonrock_inc = pvt.df2ecl(rock_df, keywords=["PVTO"]) + nonrock_inc = pvt.df2res(rock_df, keywords=["PVTO"]) assert "ROCK" not in nonrock_inc -def test_df2ecl_density(): +def test_df2res_density(): """Test generation of PVT density include files from dataframes""" density_df = pd.DataFrame( columns=["PVTNUM", "OILDENSITY", "WATERDENSITY", "GASDENSITY"], data=[[1, 827.64, 999.04, 1.1427]], ) - dens_inc = pvt.df2ecl_density(density_df) + dens_inc = pvt.df2res_density(density_df) assert "DENSITY" in dens_inc # If PVTNUM is missing, the code gives up: - assert "DENSITY" not in pvt.df2ecl_density( + assert "DENSITY" not in pvt.df2res_density( pd.concat([density_df, density_df]).drop("PVTNUM", axis="columns") ) # Unless there is only one row: - assert "DENSITY" in pvt.df2ecl_density(density_df.drop("PVTNUM", axis="columns")) + assert "DENSITY" in pvt.df2res_density(density_df.drop("PVTNUM", axis="columns")) # Missing column: with pytest.raises(KeyError, match="OILDENSITY"): - pvt.df2ecl_density(density_df.drop("OILDENSITY", axis="columns")) + pvt.df2res_density(density_df.drop("OILDENSITY", axis="columns")) -def test_df2ecl_pvtw(): +def test_df2res_pvtw(): """Test generation of PVTW include statements""" pvtw_df = pd.DataFrame( columns=[ @@ -621,22 +621,22 @@ def test_df2ecl_pvtw(): ], data=[[327.3, 1.03, 4.51e-005, 0.25, 0.0, 1]], ) - assert "PVTW" in pvt.df2ecl_pvtw(pvtw_df) + assert "PVTW" in pvt.df2res_pvtw(pvtw_df) # If PVTNUM is missing, the code gives up: - assert "PVTW" not in pvt.df2ecl_pvtw( + assert "PVTW" not in pvt.df2res_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")) + assert "PVTW" in pvt.df2res_pvtw(pvtw_df.drop("PVTNUM", axis="columns")) # Missing column: with pytest.raises(KeyError, match="VOLUMEFACTOR"): - pvt.df2ecl_pvtw(pvtw_df.drop("VOLUMEFACTOR", axis="columns")) + pvt.df2res_pvtw(pvtw_df.drop("VOLUMEFACTOR", axis="columns")) -def test_df2ecl_pvtg(): +def test_df2res_pvtg(): """Test generation of PVTG include statements""" pvtg_df = pd.DataFrame( columns=["OGR", "VOLUMEFACTOR", "VISCOSITY", "PRESSURE", "PVTNUM"], @@ -646,26 +646,26 @@ def test_df2ecl_pvtg(): [0.00014, 0.0523, 0.0234, 60.0, 2], ], ) - assert "PVTG" in pvt.df2ecl_pvtg(pvtg_df) - assert "PVTG" in pvt.df2ecl_pvtg(pvtg_df.assign(KEYWORD="PVTG")) + assert "PVTG" in pvt.df2res_pvtg(pvtg_df) + assert "PVTG" in pvt.df2res_pvtg(pvtg_df.assign(KEYWORD="PVTG")) pd.testing.assert_frame_equal( - pvt.df(pvt.df2ecl_pvtg(pvtg_df)).drop("KEYWORD", axis="columns"), pvtg_df + pvt.df(pvt.df2res_pvtg(pvtg_df)).drop("KEYWORD", axis="columns"), pvtg_df ) # If PVTNUM is missing, the code gives up: - assert "PVTG" not in pvt.df2ecl_pvtg( + assert "PVTG" not in pvt.df2res_pvtg( pd.concat([pvtg_df, pvtg_df]).drop("PVTNUM", axis="columns") ) # Unless there is only one row: - assert "PVTG" in pvt.df2ecl_pvtg(pvtg_df.head(1).drop("PVTNUM", axis="columns")) + assert "PVTG" in pvt.df2res_pvtg(pvtg_df.head(1).drop("PVTNUM", axis="columns")) # Missing column: with pytest.raises(KeyError, match="VOLUMEFACTOR"): - pvt.df2ecl_pvtg(pvtg_df.drop("VOLUMEFACTOR", axis="columns")) + pvt.df2res_pvtg(pvtg_df.drop("VOLUMEFACTOR", axis="columns")) -def test_df2ecl_pvdo_pvdg(): +def test_df2res_pvdo_pvdg(): """Test construction of PVDO and PVDG statements from dataframe. The keyword data and code is similar enough to warrant one test @@ -680,33 +680,33 @@ def test_df2ecl_pvdo_pvdg(): ], ) - assert "PVDO" in pvt.df2ecl_pvdo(pvdog_df) - assert "PVDG" in pvt.df2ecl_pvdg(pvdog_df) + assert "PVDO" in pvt.df2res_pvdo(pvdog_df) + assert "PVDG" in pvt.df2res_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")) + assert "PVDO" in pvt.df2res_pvdo(pvdog_df.assign(KEYWORD="PVDO")) + assert "PVDG" in pvt.df2res_pvdg(pvdog_df.assign(KEYWORD="PVDG")) pd.testing.assert_frame_equal( - pvt.df(pvt.df2ecl_pvdo(pvdog_df)).drop("KEYWORD", axis="columns"), pvdog_df + pvt.df(pvt.df2res_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 + pvt.df(pvt.df2res_pvdg(pvdog_df)).drop("KEYWORD", axis="columns"), pvdog_df ) # If PVTNUM is missing, the code gives up: - assert "PVDO" not in pvt.df2ecl_pvdo( + assert "PVDO" not in pvt.df2res_pvdo( pd.concat([pvdog_df, pvdog_df]).drop("PVTNUM", axis="columns") ) - assert "PVDG" not in pvt.df2ecl_pvdg( + assert "PVDG" not in pvt.df2res_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")) + assert "PVDO" in pvt.df2res_pvdo(pvdog_df.head(1).drop("PVTNUM", axis="columns")) + assert "PVDG" in pvt.df2res_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")) + pvt.df2res_pvdo(pvdog_df.drop("VOLUMEFACTOR", axis="columns")) with pytest.raises(KeyError, match="VOLUMEFACTOR"): - pvt.df2ecl_pvdg(pvdog_df.drop("VOLUMEFACTOR", axis="columns")) + pvt.df2res_pvdg(pvdog_df.drop("VOLUMEFACTOR", axis="columns")) diff --git a/tests/test_satfunc.py b/tests/test_satfunc.py index 90579ce32..583c007fb 100644 --- a/tests/test_satfunc.py +++ b/tests/test_satfunc.py @@ -58,7 +58,7 @@ def test_satfunc_roundtrip(): it back to an include file, and then reinterpret it to the same""" resdatafiles = ResdataFiles(EIGHTCELLS) satdf = satfunc.df(resdatafiles.get_ecldeck()) - inc = satfunc.df2ecl(satdf) + inc = satfunc.df2res(satdf) df_from_inc = satfunc.df(inc) pd.testing.assert_frame_equal( satdf.sort_values(["SATNUM", "KEYWORD"]), @@ -66,20 +66,20 @@ def test_satfunc_roundtrip(): ) -def test_df2ecl_order(): +def test_df2res_order(): """Test that we can control the keyword order in generated strings by the list supplied in keywords argument""" resdatafiles = ResdataFiles(REEK) satdf = satfunc.df(resdatafiles.get_ecldeck()) - swof_sgof = satfunc.df2ecl(satdf, keywords=["SWOF", "SGOF"]) + swof_sgof = satfunc.df2res(satdf, keywords=["SWOF", "SGOF"]) assert swof_sgof.find("SWOF") < swof_sgof.find("SGOF") - sgof_swof = satfunc.df2ecl(satdf, keywords=["SGOF", "SWOF"]) + sgof_swof = satfunc.df2res(satdf, keywords=["SGOF", "SWOF"]) assert sgof_swof.find("SGOF") < sgof_swof.find("SWOF") - only_swof = satfunc.df2ecl(satdf, keywords=["SWOF"]) + only_swof = satfunc.df2res(satdf, keywords=["SWOF"]) assert "SGOF" not in only_swof - only_sgof = satfunc.df2ecl(satdf, keywords="SGOF") + only_sgof = satfunc.df2res(satdf, keywords="SGOF") assert "SWOF" not in only_sgof @@ -90,7 +90,7 @@ def test_nodata(): satdf = satfunc.df(swofstr) assert len(satdf) == 0 - inc = satfunc.df2ecl_swof(satdf) + inc = satfunc.df2res_swof(satdf) assert "No data" in inc df_from_inc = satfunc.df(inc) assert df_from_inc.empty @@ -245,7 +245,7 @@ def test_str2df(string, expected_df): if expected_df.empty: return - inc = satfunc.df2ecl(satdf) + inc = satfunc.df2res(satdf) df_from_inc = satfunc.df(inc) pd.testing.assert_frame_equal(df_from_inc, expected_df) @@ -272,7 +272,7 @@ def test_sgof_satnuminferrer(tmp_path, mocker): assert "SATNUM" in sgofdf assert len(sgofdf["SATNUM"].unique()) == 3 assert len(sgofdf) == 8 - inc = satfunc.df2ecl(sgofdf) + inc = satfunc.df2res(sgofdf) df_from_inc = satfunc.df(inc) pd.testing.assert_frame_equal(sgofdf, df_from_inc) diff --git a/tests/test_summary.py b/tests/test_summary.py index 2fc3f4a05..80a0269f9 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -18,7 +18,7 @@ _fix_dframe_for_libecl, date_range, df, - df2eclsum, + df2ressum, resample_smry_dates, smry_meta, ) @@ -411,7 +411,7 @@ def test_foreseeable_future(tmp_path): {"DATE": "2500-01-01", "FPR": 180}, ] ) - eclsum = df2eclsum(src_dframe, casename="PLUGABANDON") + eclsum = df2ressum(src_dframe, casename="PLUGABANDON") dframe = summary.df(eclsum) assert ( @@ -437,7 +437,7 @@ def test_foreseeable_future(tmp_path): "FPR": range(70), } ) - eclsum = df2eclsum(src_dframe, casename="PLUGABANDON") + eclsum = df2ressum(src_dframe, casename="PLUGABANDON") dframe = summary.df(eclsum) # Still buggy: assert dframe.index[-1] == dt(2068, 12, 31, 23, 57, 52) @@ -449,7 +449,7 @@ def test_foreseeable_future(tmp_path): "FPR": range(69), } ) - eclsum = df2eclsum(src_dframe, casename="PLUGABANDON") + eclsum = df2ressum(src_dframe, casename="PLUGABANDON") dframe = summary.df(eclsum) # Works fine when stepping only 68 years: assert dframe.index[-1] == dt(2468, 1, 1, 0, 0, 0) @@ -850,7 +850,7 @@ def test_smry_meta_synthetic(): {"DATE": np.datetime64("2016-01-01"), "FOPT": 1000, "FOPR": 100}, ] ).set_index("DATE") - synt_meta = smry_meta(df2eclsum(dframe)) + synt_meta = smry_meta(df2ressum(dframe)) # Dummy unit provided by EclSum: assert synt_meta["FOPT"]["unit"] == "UNIT" @@ -944,7 +944,7 @@ def test_smry_meta_synthetic(): ], ) def test_fix_dframe_for_libecl(dframe, expected_dframe): - """Test the dataframe preprocessor/validator for df2eclsum works""" + """Test the dataframe preprocessor/validator for df2ressum works""" pd.testing.assert_frame_equal( _fix_dframe_for_libecl(dframe), expected_dframe, check_index_type=False ) @@ -1019,14 +1019,14 @@ def test_fix_dframe_for_libecl(dframe, expected_dframe): ), ], ) -def test_df2eclsum(dframe): +def test_df2ressum(dframe): """Test that a dataframe can be converted to an EclSum object, and then read back again""" # Massage the dframe first so we can assert on equivalence after. dframe = _fix_dframe_for_libecl(dframe) - eclsum = df2eclsum(dframe) + eclsum = df2ressum(dframe) if dframe.empty: assert eclsum is None return @@ -1039,7 +1039,7 @@ def test_df2eclsum(dframe): ) -def test_df2eclsum_datetimeindex(): +def test_df2ressum_datetimeindex(): """Test that providing a dataframe with a datetimeindex also works""" dframe = pd.DataFrame( [ @@ -1049,7 +1049,7 @@ def test_df2eclsum_datetimeindex(): dframe["DATE"] = pd.to_datetime(dframe["DATE"]) dframe.set_index("DATE") - roundtrip = df(df2eclsum(dframe)) + roundtrip = df(df2ressum(dframe)) assert isinstance(roundtrip.index, pd.DatetimeIndex) assert roundtrip["FOPR"].values == [100] assert roundtrip["FOPT"].values == [1000] @@ -1063,7 +1063,7 @@ def test_duplicated_summary_vectors(caplog): res2df.summary.df() should deduplicate this, and give a warning. """ - # res2df.df2eclsum() is not able to mock such a UNSMRY file. + # res2df.df2ressum() is not able to mock such a UNSMRY file. dupe_datafile = ( TESTDIR / "data" @@ -1182,7 +1182,7 @@ def test_res2df_errors(tmp_path): assert df(ResdataFiles("FOO")).empty -def test_df2eclsum_errors(): +def test_df2ressum_errors(): """Test various error conditions, checking that the correct error message is emitted""" dframe = pd.DataFrame( @@ -1191,18 +1191,18 @@ def test_df2eclsum_errors(): ] ) with pytest.raises(ValueError, match="casename foobar must be UPPER CASE"): - df2eclsum(dframe, casename="foobar") + df2ressum(dframe, casename="foobar") with pytest.raises(ValueError, match="Do not use dots in casename"): - df2eclsum(dframe, casename="FOOBAR.UNSMRY") # .UNSMRY should not be included + df2ressum(dframe, casename="FOOBAR.UNSMRY") # .UNSMRY should not be included # No date included: with pytest.raises(ValueError, match="dataframe must have a datetime index"): - df2eclsum(pd.DataFrame([{"FOPT": 1000}])) + df2ressum(pd.DataFrame([{"FOPT": 1000}])) @pytest.mark.integration def test_csv2res_summary(tmp_path, mocker): - """Check that we can call df2eclsum through the csv2res command line + """Check that we can call df2ressum through the csv2res command line utility""" dframe = pd.DataFrame( [ diff --git a/tests/test_vfp.py b/tests/test_vfp.py index c3f94c7b2..3d048a88a 100644 --- a/tests/test_vfp.py +++ b/tests/test_vfp.py @@ -1015,9 +1015,9 @@ def test_res2pyarrow_vfpprod(test_input, expected): @pytest.mark.parametrize("test_input, expected", [VFPPROD_CASES[0]]) -def test_df2ecl_vfpprod(test_input, expected): - """Test df2ecl for VFPPROD (case without default values)""" - ecl_vfpprod = vfp.df2ecl(expected, "VFPPROD") +def test_df2res_vfpprod(test_input, expected): + """Test df2res for VFPPROD (case without default values)""" + ecl_vfpprod = vfp.df2res(expected, "VFPPROD") assert ecl_vfpprod.strip() == test_input.strip() @@ -1025,13 +1025,13 @@ def test_df2ecl_vfpprod(test_input, expected): @pytest.mark.parametrize("test_input, expected", [VFPPROD_CASES[0]]) def test_pyarrow2ecl_vfpprod(test_input, expected): """Test pyarrow2ecl for VFPPROD (case without default values)""" - deck = ResdataFiles.str2deck(vfp.df2ecl(expected, "VFPPROD")) + deck = ResdataFiles.str2deck(vfp.df2res(expected, "VFPPROD")) vfpprod_df = vfp.df(deck, "VFPPROD") vfpprod_data = vfp.df2basic_data(vfpprod_df) vfpprod_pa = vfp.basic_data2pyarrow(vfpprod_data) vfpprod_data = vfp.pyarrow2basic_data(vfpprod_pa) vfpprod_df = vfp.basic_data2df(vfpprod_data) - vfpprod_ecl = vfp.df2ecl(vfpprod_df, "VFPPROD") + vfpprod_ecl = vfp.df2res(vfpprod_df, "VFPPROD") assert vfpprod_ecl.strip() == test_input.strip() @@ -1046,9 +1046,9 @@ def test_res2df_vfpinj(test_input, expected): @pytest.mark.parametrize("test_input, expected", [VFPINJ_CASES[0]]) -def test_df2ecl_vfpinj(test_input, expected): - """Test df2ecl for VFPINJ (case without default values)""" - ecl_vfpinj = vfp.df2ecl(expected, "VFPINJ") +def test_df2res_vfpinj(test_input, expected): + """Test df2res for VFPINJ (case without default values)""" + ecl_vfpinj = vfp.df2res(expected, "VFPINJ") assert ecl_vfpinj.strip() == test_input.strip() @@ -1056,13 +1056,13 @@ def test_df2ecl_vfpinj(test_input, expected): @pytest.mark.parametrize("test_input, expected", [VFPINJ_CASES[0]]) def test_pyarrow2ecl_vfpinj(test_input, expected): """Test pyarrow2ecl for VFPPROD (case without default values)""" - deck = ResdataFiles.str2deck(vfp.df2ecl(expected, "VFPINJ")) + deck = ResdataFiles.str2deck(vfp.df2res(expected, "VFPINJ")) vfpinj_df = vfp.df(deck, "VFPINJ") vfpinj_data = vfp.df2basic_data(vfpinj_df) vfpinj_pa = vfp.basic_data2pyarrow(vfpinj_data) vfpinj_data = vfp.pyarrow2basic_data(vfpinj_pa) vfpinj_df = vfp.basic_data2df(vfpinj_data) - vfpinj_ecl = vfp.df2ecl(vfpinj_df, "VFPINJ") + vfpinj_ecl = vfp.df2res(vfpinj_df, "VFPINJ") assert vfpinj_ecl.strip() == test_input.strip()