Skip to content

Commit

Permalink
Upgrade to ruff 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
alifbe committed Jan 10, 2025
1 parent ae09ae8 commit 39ef33b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/pyscal/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def create_water_oil(
logger.debug("Computed swl from swlwheight to %s", str(params["swl"]))
if "swcr" in params and params["swcr"] < params["swl"]:
raise ValueError(
f'Provided swcr={params["swcr"]} is lower than '
f'computed swl={params["swl"]}'
f"Provided swcr={params['swcr']} is lower than "
f"computed swl={params['swl']}"
)
elif set(WO_SWLHEIGHT).issubset(params):
raise ValueError(
Expand Down Expand Up @@ -1134,7 +1134,7 @@ def load_relperm_df(
@staticmethod
def alias_sgrw(params: Dict[str, Any]) -> Dict[str, Any]:
warnings.warn(
"PyscalFactory.alias_sgrw is deprecated. " "Please use alias_sgrw instead.",
"PyscalFactory.alias_sgrw is deprecated. Please use alias_sgrw instead.",
DeprecationWarning,
)
return alias_sgrw(params)
Expand Down
6 changes: 3 additions & 3 deletions src/pyscal/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def format_gaswater_table(model: GasWater) -> pd.DataFrame:
# Check if SW in the two models differs using an epsilon of 1E-6 If any
# absolute differences are greater than this threshold, an assertion error
# will be raised.
assert (
abs(gasoil["SW"] - wateroil["SW"]) < 1e-6
).all(), "SW for the GasOil model does not match SW for the WaterOil model"
assert (abs(gasoil["SW"] - wateroil["SW"]) < 1e-6).all(), (
"SW for the GasOil model does not match SW for the WaterOil model"
)

# Merge dataframes and format
gaswater = gasoil.merge(wateroil, left_index=True, right_index=True)
Expand Down
18 changes: 9 additions & 9 deletions src/pyscal/utils/monotonicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def modify_dframe_monotonicity(
while constants.any():
iterations += 1

assert iterations <= 2 * len(
dframe[col]
), "Too many iterations for monotonicity fix"
assert iterations <= 2 * len(dframe[col]), (
"Too many iterations for monotonicity fix"
)

dframe.loc[constants, col] = (
dframe.loc[constants, col] + sign / 10.0**digits - epsilon
Expand All @@ -140,13 +140,13 @@ def modify_dframe_monotonicity(
# Assert that we have successfully managed to force monotonicity
allowance = 1.0 / 10.0**digits
if sign > 0:
assert not (
dframe[col].round(digits).diff() < -allowance
).any(), "Not possible to make column monotonically increasing"
assert not (dframe[col].round(digits).diff() < -allowance).any(), (
"Not possible to make column monotonically increasing"
)
else:
assert not (
dframe[col].round(digits).diff() > allowance
).any(), "Not possible to make column monotonically decreasing"
assert not (dframe[col].round(digits).diff() > allowance).any(), (
"Not possible to make column monotonically decreasing"
)
return dframe


Expand Down
18 changes: 9 additions & 9 deletions src/pyscal/wateroil.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ def __init__(
_sgcr and _sgl are only to be used by the GasWater object.
"""

assert (
-epsilon - 1 < swirr < 1.0 + epsilon
), f"swirr = {swirr}, -1 <= swirr <= 1 is required"
assert -epsilon - 1 < swirr < 1.0 + epsilon, (
f"swirr = {swirr}, -1 <= swirr <= 1 is required"
)
assert -epsilon < swl < 1.0 + epsilon, f"swl = {swl}, 0 <= swl < 1 is required"
assert (
-epsilon < swcr < 1.0 + epsilon
), f"swcr = {swcr}, 0 <= swcr < 1 is required"
assert (
-epsilon < sorw < 1.0 + epsilon
), f"sorw = {sorw}, 0 <= sorw < 1 is required"
assert -epsilon < swcr < 1.0 + epsilon, (
f"swcr = {swcr}, 0 <= swcr < 1 is required"
)
assert -epsilon < sorw < 1.0 + epsilon, (
f"sorw = {sorw}, 0 <= sorw < 1 is required"
)
if socr is not None:
assert -epsilon < socr < 1.0 + epsilon, "0 <= socr < 1 is required"

Expand Down
24 changes: 12 additions & 12 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ def __init__(self, tag: str) -> None:
def test_pyscal_list_attr():
"""Check that the PyscalList class has an pyscal_list instance variable.
This is accessed by the plotting module to loop through models to plot."""
assert (
hasattr(PyscalList(), "pyscal_list") is True
), "The PyscalList object should have a pyscal_list instance variable.\
assert hasattr(PyscalList(), "pyscal_list") is True, (
"The PyscalList object should have a pyscal_list instance variable.\
This is accessed by the plotting module."
)


def test_plot_relperm():
Expand All @@ -102,9 +102,9 @@ def test_plot_relperm():
config = plotting.get_plot_config_options("WaterOil", **kwargs)
fig = plotting.plot_relperm(wateroil.table, 1, config, **kwargs)

assert isinstance(
fig, plt.Figure
), "Type of returned object is not a matplotlib.pyplot Figure"
assert isinstance(fig, plt.Figure), (
"Type of returned object is not a matplotlib.pyplot Figure"
)


def test_plot_pc():
Expand All @@ -118,9 +118,9 @@ def test_plot_pc():
config = plotting.get_plot_config_options("WaterOil", **kwargs)
fig = plotting.plot_pc(wateroil.table, 1, **config)

assert isinstance(
fig, plt.Figure
), "Type of returned object is not a matplotlib.pyplot Figure"
assert isinstance(fig, plt.Figure), (
"Type of returned object is not a matplotlib.pyplot Figure"
)


def test_wog_plotter(tmpdir):
Expand Down Expand Up @@ -184,9 +184,9 @@ def test_wo_plotter_relperm_only(tmpdir):
plotting.wo_plotter(wateroil, **kwargs)

assert Path.exists(Path(tmpdir).joinpath(kr_plot_name)), "Plot not created"
assert not Path.exists(
Path(tmpdir).joinpath(pc_plot_name)
), "Plot created when it shouldn't have been"
assert not Path.exists(Path(tmpdir).joinpath(pc_plot_name)), (
"Plot created when it shouldn't have been"
)


def test_go_plotter(tmpdir):
Expand Down

0 comments on commit 39ef33b

Please sign in to comment.