diff --git a/.gitignore b/.gitignore index e78910702..91a3457d3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ res2df/version.py .\#* venv* build +kenv* diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..7688f8212 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.testing.pytestArgs": [], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/res2df/common.py b/res2df/common.py index dc9c30670..cbaa353d5 100644 --- a/res2df/common.py +++ b/res2df/common.py @@ -417,10 +417,7 @@ def comment_formatter(multiline: Optional[str], prefix: str = "-- ") -> str: """ if multiline is None or not multiline.strip(): return "" - return ( - "\n".join([prefix + line.strip() for line in multiline.splitlines()]).strip() - + "\n" - ) + return "\n".join([prefix + line for line in multiline.splitlines()]) + "\n" def handle_wanted_keywords( diff --git a/res2df/vfp/_vfp.py b/res2df/vfp/_vfp.py index b077dd26e..4e2d35a58 100755 --- a/res2df/vfp/_vfp.py +++ b/res2df/vfp/_vfp.py @@ -408,7 +408,7 @@ def df2res( if filename: with open(filename, "w") as fout: - fout.write(str_vfp) + fout.write(str_vfps) return str_vfps diff --git a/res2df/vfp/_vfpcommon.py b/res2df/vfp/_vfpcommon.py index fadb4a090..aba209767 100755 --- a/res2df/vfp/_vfpcommon.py +++ b/res2df/vfp/_vfpcommon.py @@ -201,6 +201,8 @@ def _write_vfp_range( deck_str += format % value if (i + 1) % values_per_line == 0 and i < len(values) - 1: deck_str += "\n" + else: + deck_str += " " deck_str += " /\n" deck_str += "\n" diff --git a/res2df/vfp/_vfpinj.py b/res2df/vfp/_vfpinj.py index 34f69a187..4d94ba16e 100755 --- a/res2df/vfp/_vfpinj.py +++ b/res2df/vfp/_vfpinj.py @@ -642,11 +642,13 @@ def _write_table_records( if (n + 1) % values_per_line == 0: if n < no_flow_values - 1: deck_str += "\n" - deck_str += " " * 2 + deck_str += " " * 11 else: deck_str += "\n" elif n == no_flow_values - 1: deck_str += "\n" + else: + deck_str += " " deck_str += "/\n" diff --git a/res2df/vfp/_vfpprod.py b/res2df/vfp/_vfpprod.py index cca063574..fa03606bf 100755 --- a/res2df/vfp/_vfpprod.py +++ b/res2df/vfp/_vfpprod.py @@ -890,7 +890,7 @@ def _write_table_records( gfr_indices: np.ndarray, alq_indices: np.ndarray, table: np.ndarray, - format: str = "%10.3", + format: str = "%10.6g", values_per_line: int = 5, ) -> str: """Creates a :term:`include file` content string representing a @@ -931,6 +931,8 @@ def _write_table_records( deck_str += "\n" elif n == no_flow_values - 1: deck_str += "\n" + else: + deck_str += " " deck_str += "/\n" diff --git a/tests/test_vfp.py b/tests/test_vfp.py index 3d048a88a..1b91282eb 100644 --- a/tests/test_vfp.py +++ b/tests/test_vfp.py @@ -48,35 +48,35 @@ + """METRIC BHP / -- GAS units - sm3/day ( 3 values ) - 50000 500000 5e+06 / + 50000 500000 5e+06 / -- THP units - barsa ( 2 values ) - 40 100 / + 40 100 / -- WGR units - sm3/sm3 ( 2 values ) - 0 1e-05 / + 0 1e-05 / -- GOR units - sm3/sm3 ( 2 values ) - 500 4000 / + 500 4000 / -- '' units - ( 1 values ) - 0 / + 0 / - 1 1 1 1 160.11 130.21 180.31 + 1 1 1 1 160.11 130.21 180.31 / - 1 1 2 1 140.12 110.22 160.32 + 1 1 2 1 140.12 110.22 160.32 / - 1 2 1 1 165.13 135.23 185.33 + 1 2 1 1 165.13 135.23 185.33 / - 1 2 2 1 145.14 115.24 165.34 + 1 2 2 1 145.14 115.24 165.34 / - 2 1 1 1 240.15 210.25 260.35 + 2 1 1 1 240.15 210.25 260.35 / - 2 1 2 1 220.16 190.26 240.36 + 2 1 2 1 220.16 190.26 240.36 / - 2 2 1 1 245.17 215.27 265.37 + 2 2 1 1 245.17 215.27 265.37 / - 2 2 2 1 225.18 195.28 245.38 + 2 2 2 1 225.18 195.28 245.38 / """, pd.DataFrame( @@ -614,14 +614,14 @@ 3 3200.0 GAS THP METRIC BHP / -- GAS units - sm3/day ( 3 values ) - 50000 500000 5e+06 / + 50000 500000 5e+06 / -- THP units - barsa ( 2 values ) - 100 200 / + 100 200 / - 1 180.11 170.21 150.31 + 1 180.11 170.21 150.31 / - 2 270.12 260.22 240.32 + 2 270.12 260.22 240.32 / """, pd.DataFrame(