Skip to content

Commit

Permalink
Fix warnings during testing (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe authored Mar 15, 2024
1 parent 98679e6 commit f56fde2
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
PYTHON: '3.8'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/subscript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:

steps:
- name: Checkout commit locally
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
6 changes: 3 additions & 3 deletions src/subscript/casegen_upcars/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def set_vug(
low=near_fracture_vug_fraction_dist[0],
high=near_fracture_vug_fraction_dist[1],
size=1,
)
)[0]
* self._total_matrix_cells
)
)
Expand Down Expand Up @@ -1020,7 +1020,7 @@ def set_vug(
low=near_streak_vug_fraction_dist[0],
high=near_streak_vug_fraction_dist[1],
size=1,
)
)[0]
* self._total_matrix_cells
)
)
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def set_vug(
low=random_vug_fraction_dist[0],
high=random_vug_fraction_dist[1],
size=1,
)
)[0]
* self._total_matrix_cells
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/subscript/csv_stack/csv_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def csv_stack(
# the rows that emerged from the stacking. If you use the
# 'all' pivottype, then you will get some NaN-values in the
# MultiIndex columns that are intentional.
dframe[nostackcolumnnames] = dframe[nostackcolumnnames].fillna(method="ffill")
dframe[nostackcolumnnames] = dframe[nostackcolumnnames].ffill()

dframe = dframe.reset_index()

Expand Down
2 changes: 1 addition & 1 deletion src/subscript/fmuobs/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,10 @@ def compute_date_from_days(dframe: pd.DataFrame, starttime: Optional[str] = None
dframe["DATE"] = np.nan
start = pd.to_datetime(starttime)
date_needed_rows = ~dframe["DAYS"].isna() & dframe["DATE"].isna()
dframe["DATE"] = pd.to_datetime(dframe["DATE"])
dframe.loc[date_needed_rows, "DATE"] = start + pd.to_timedelta(
dframe.loc[date_needed_rows, "DAYS"], "d"
)
dframe["DATE"] = pd.to_datetime(dframe["DATE"])
if "DATE" in dframe:
dframe["DATE"] = pd.to_datetime(dframe["DATE"])
return dframe
Expand Down
11 changes: 7 additions & 4 deletions src/subscript/fmuobs/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,13 @@ def convert_dframe_date_to_str(dframe: pd.DataFrame) -> pd.DataFrame:
"""
if "DATE" in dframe:
dframe = dframe.copy()
dframe["DATE"] = dframe["DATE"].astype(str)
dframe["DATE"].replace("NaT", np.nan, inplace=True)
dframe["DATE"].replace("NaN", np.nan, inplace=True)
dframe["DATE"].replace("nan", np.nan, inplace=True)
dframe["DATE"] = (
dframe["DATE"]
.astype(str)
.replace(["NaT", "NaN", "nan"], np.nan)
.infer_objects()
)

return dframe


Expand Down
4 changes: 2 additions & 2 deletions src/subscript/interp_relperm/interp_relperm.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def make_wateroilgas(dframe: pd.DataFrame, delta_s: float) -> pyscal.WaterOilGas
.sort_index()
.dropna(how="all")
.interpolate(method="index")
.fillna(method="bfill")
.bfill()
.round(8)
.drop_duplicates()
.reset_index()
Expand All @@ -197,7 +197,7 @@ def make_wateroilgas(dframe: pd.DataFrame, delta_s: float) -> pyscal.WaterOilGas
.sort_index()
.dropna(how="all")
.interpolate(method="index")
.fillna(method="bfill")
.bfill()
.round(8)
.drop_duplicates()
.reset_index()
Expand Down
4 changes: 2 additions & 2 deletions src/subscript/presentvalue/presentvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ def calc_presentvalue_df(
prodecon = pd.concat([summary_df, econ_df], axis=1, sort=True)
prodecon[["oilprice", "gasprice", "usdtonok", "discountrate"]] = prodecon[
["oilprice", "gasprice", "usdtonok", "discountrate"]
].fillna(method="ffill")
].ffill()
# Avoid ffilling costs...
# There could be situations where we need to bfill prices as well,
# if the user provided a econtable
prodecon[["oilprice", "gasprice", "usdtonok", "discountrate"]] = prodecon[
["oilprice", "gasprice", "usdtonok", "discountrate"]
].fillna(method="bfill")
].bfill()
prodecon.fillna(value=0, inplace=True) # Zero-pad other data (costs)

prodecon["deltayears"] = prodecon.index - discountto
Expand Down
6 changes: 5 additions & 1 deletion src/subscript/prtvol2csv/prtvol2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ def prtvol2df(
and add REGION and ZONE parameter.
"""
# Concatenate dataframes horizontally. Both are/must be indexed by FIPNUM:
volumes = pd.concat([simvolumes_df, resvolumes_df], axis=1).fillna(value=0.0)
volumes = (
pd.concat([simvolumes_df, resvolumes_df], axis=1)
.apply(pd.to_numeric)
.fillna(value=0.0)
)

if fipmapper is not None:
if fipmapper.has_fip2region:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_welltest_dpds.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_main(tmp_path, mocker):
suptimew = pd.read_csv("spt.csv")
# pylint: disable=no-member
# (false positive)
assert suptimew.iloc[0][0] == pytest.approx(-9.87037983)
assert suptimew.iloc[-1][0] == pytest.approx(-0.65693308)
assert suptimew.iloc[0, 0] == pytest.approx(-9.87037983)
assert suptimew.iloc[-1, 0] == pytest.approx(-0.65693308)
Path("welltest_output.csv").unlink()

# test --genobs_resultfile
Expand Down

0 comments on commit f56fde2

Please sign in to comment.