Skip to content

Commit

Permalink
Fix issue with black and mypy 1.0 (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe authored Feb 14, 2023
1 parent 281a1f3 commit 6ef26bf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 23 deletions.
8 changes: 4 additions & 4 deletions pyscal/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def create_wateroilgas_list(
PyscalList, consisting of WaterOilGas objects
"""
wogl = PyscalList()
for (row_idx, params) in relperm_params_df.sort_values("SATNUM").iterrows():
for row_idx, params in relperm_params_df.sort_values("SATNUM").iterrows():
if h is not None:
params["h"] = h
try:
Expand Down Expand Up @@ -959,7 +959,7 @@ def create_wateroil_list(
PyscalList, consisting of WaterOil objects
"""
wol = PyscalList()
for (_, params) in relperm_params_df.iterrows():
for _, params in relperm_params_df.iterrows():
if h is not None:
params["h"] = h
try:
Expand Down Expand Up @@ -987,7 +987,7 @@ def create_gasoil_list(
PyscalList, consisting of GasOil objects
"""
gol = PyscalList()
for (_, params) in relperm_params_df.iterrows():
for _, params in relperm_params_df.iterrows():
if h is not None:
params["h"] = h
try:
Expand Down Expand Up @@ -1015,7 +1015,7 @@ def create_gaswater_list(
PyscalList, consisting of GasWater objects
"""
gwl = PyscalList()
for (_, params) in relperm_params_df.iterrows():
for _, params in relperm_params_df.iterrows():
if h is not None:
params["h"] = h
try:
Expand Down
4 changes: 1 addition & 3 deletions pyscal/gasoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ def __init__(
)
sg_list.sort()
self.table = pd.DataFrame(sg_list, columns=["SG"])
self.table["sgint"] = list(
map(int, list(map(round, self.table["SG"] * SWINTEGERS)))
)
self.table["sgint"] = list(map(round, self.table["SG"] * SWINTEGERS))
self.table.drop_duplicates("sgint", inplace=True)

# Now sg=1-sorg-swl might be accidentally dropped, so make sure we
Expand Down
10 changes: 5 additions & 5 deletions pyscal/pyscallist.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def df(self) -> pd.DataFrame:

df_list = []
if self.pyscaltype == WaterOilGas:
for (satnum, wateroilgas) in enumerate(self.pyscal_list):
for satnum, wateroilgas in enumerate(self.pyscal_list):
assert isinstance(wateroilgas, WaterOilGas)
assert wateroilgas.wateroil is not None
assert wateroilgas.gasoil is not None
Expand All @@ -127,7 +127,7 @@ def df(self) -> pd.DataFrame:
.rename(wateroil_col_renamer, axis="columns")
)
elif self.pyscaltype == SCALrecommendation:
for (satnum, scalrec) in enumerate(self.pyscal_list):
for satnum, scalrec in enumerate(self.pyscal_list):
assert isinstance(scalrec, SCALrecommendation)
assert scalrec.low is not None
assert scalrec.base is not None
Expand Down Expand Up @@ -180,7 +180,7 @@ def df(self) -> pd.DataFrame:
.rename(wateroil_col_renamer, axis="columns")
)
elif self.pyscaltype == WaterOil:
for (satnum, wateroil) in enumerate(self.pyscal_list):
for satnum, wateroil in enumerate(self.pyscal_list):
assert isinstance(wateroil, WaterOil)
assert wateroil is not None
wateroil_cols = list(
Expand All @@ -192,7 +192,7 @@ def df(self) -> pd.DataFrame:
.rename(wateroil_col_renamer, axis="columns")
)
elif self.pyscaltype == GasOil:
for (satnum, gasoil) in enumerate(self.pyscal_list):
for satnum, gasoil in enumerate(self.pyscal_list):
assert isinstance(gasoil, GasOil)
assert gasoil is not None
gasoil_cols = list(
Expand Down Expand Up @@ -369,7 +369,7 @@ def interpolate(
f"Too many interpolation parameters given for GasOil {int_params_go}"
)
wog_list: PyscalList = PyscalList()
for (satnum, scalrec) in enumerate(self.pyscal_list):
for satnum, scalrec in enumerate(self.pyscal_list):
assert isinstance(scalrec, SCALrecommendation)
wog_list.append(
scalrec.interpolate(int_params_wo[satnum], int_params_go[satnum], h=h)
Expand Down
2 changes: 0 additions & 2 deletions pyscal/scalrecommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(
and isinstance(base, WaterOilGas)
and isinstance(high, WaterOilGas)
):

self.low = low
self.base = base
self.high = high
Expand All @@ -65,7 +64,6 @@ def __init__(
and isinstance(base, GasWater)
and isinstance(high, GasWater)
):

self.low = low
self.base = base
self.high = high
Expand Down
4 changes: 1 addition & 3 deletions pyscal/wateroil.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ def __init__(

# Ensure that we do not have sw values that are too close
# to each other, determined rougly by the distance 1/10000
self.table["swint"] = list(
map(int, list(map(round, self.table["SW"] * SWINTEGERS)))
)
self.table["swint"] = list(map(round, self.table["SW"] * SWINTEGERS))
self.table.drop_duplicates("swint", inplace=True)

# Now, sw=1-sorw might be accidentaly dropped, so make sure we
Expand Down
4 changes: 1 addition & 3 deletions pyscal/wateroilgas.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ def SOF3(self, header: bool = True, dataincommentrow: bool = True) -> str:
.fillna(method="bfill")
.reset_index()
)
sof3table["soint"] = list(
map(int, list(map(round, sof3table["SO"] * SWINTEGERS)))
)
sof3table["soint"] = list(map(round, sof3table["SO"] * SWINTEGERS))
sof3table.drop_duplicates("soint", inplace=True)

# The 'so' column has been calculated from floating point numbers
Expand Down
5 changes: 2 additions & 3 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ def test_xls_factory():

scalinput = pd.read_excel(xlsxfile, engine="openpyxl").set_index(["SATNUM", "CASE"])

for ((satnum, _), params) in scalinput.iterrows():
for (satnum, _), params in scalinput.iterrows():
assert satnum
wog = PyscalFactory.create_water_oil_gas(params.to_dict())
swof = wog.SWOF()
Expand Down Expand Up @@ -961,7 +961,6 @@ def test_scalrecommendation():
with pytest.raises(
ValueError, match="All values in parameter dict must be dictionaries"
):

pyscal_factory.create_scal_recommendation(
{"low": [1, 2], "base": {"swl": 0.1}, "high": {"swl": 0.1}}
)
Expand Down Expand Up @@ -1069,7 +1068,7 @@ def parse_gensatfuncline(conf_line):
raise ValueError("Too many items on gensatfunc confline")

params = {}
for (idx, value) in enumerate(conf_line.split()):
for idx, value in enumerate(conf_line.split()):
if idx > 0: # Avoid the CMD
params[line_syntax[idx]] = float(value)

Expand Down

0 comments on commit 6ef26bf

Please sign in to comment.