From d8bc5b1014501c99169c96dd1873e120f3551675 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:44:50 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/bayesian_fitting.ipynb | 23 +++++++++-------------- docs/flow.ipynb | 13 ++++--------- docs/fluids.ipynb | 9 +++++---- docs/forecast.ipynb | 17 ++++++++--------- docs/forecast_varying.ipynb | 7 ++++--- docs/getting_started.ipynb | 5 ++++- docs/oil_flow.ipynb | 18 +++++++----------- tests/flow/test_properties.py | 9 +++++---- tests/flow/test_reservoir.py | 4 +++- tests/fluids/test_fluid.py | 3 ++- tests/fluids/test_gas.py | 1 + tests/fluids/test_oil.py | 1 + tests/fluids/test_water.py | 1 + tests/forecast/test_forecast.py | 9 +++++---- tests/test_plots.py | 9 +++++---- 15 files changed, 64 insertions(+), 65 deletions(-) diff --git a/docs/bayesian_fitting.ipynb b/docs/bayesian_fitting.ipynb index fb4093e..2233b40 100644 --- a/docs/bayesian_fitting.ipynb +++ b/docs/bayesian_fitting.ipynb @@ -18,7 +18,8 @@ "outputs": [], "source": [ "# If necessary, install pymc\n", - "# %pip install pymc" + "# %pip install pymc\n", + "from __future__ import annotations" ] }, { @@ -27,25 +28,19 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", - "from scipy.interpolate import interp1d, UnivariateSpline\n", - "from scipy.integrate import cumulative_trapezoid\n", - "from scipy.misc import derivative\n", - "import pandas as pd\n", + "import arviz as az\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", "import pymc as pm\n", - "import arviz as az\n", "import seaborn as sns\n", + "from pymc.distributions.dist_math import SplineWrapper\n", + "from scipy.integrate import cumulative_trapezoid\n", + "from scipy.interpolate import UnivariateSpline, interp1d\n", + "from scipy.misc import derivative\n", "\n", - "import bluebonnet as bb\n", "from bluebonnet.flow import (\n", " IdealReservoir,\n", - " FlowProperties,\n", - " SinglePhaseReservoir,\n", - " RelPermParams,\n", - ")\n", - "from bluebonnet.forecast import Bounds, ForecasterOnePhase\n", - "from pymc.distributions.dist_math import SplineWrapper" + ")" ] }, { diff --git a/docs/flow.ipynb b/docs/flow.ipynb index bdc8dee..b3f1ed6 100644 --- a/docs/flow.ipynb +++ b/docs/flow.ipynb @@ -18,28 +18,23 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "%load_ext autoreload\n", "%autoreload 2\n", "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import scipy as sp\n", - "from scipy.interpolate import interp1d\n", "import pandas as pd\n", - "import matplotlib.pyplot as plt\n", "\n", "from bluebonnet.flow import (\n", - " IdealReservoir,\n", " FlowProperties,\n", - " FlowPropertiesTwoPhase,\n", + " IdealReservoir,\n", " SinglePhaseReservoir,\n", - " RelPermParams,\n", - " relative_permeabilities,\n", ")\n", - "from bluebonnet.fluids.fluid import Fluid, pseudopressure\n", "from bluebonnet.plotting import (\n", " plot_pseudopressure,\n", " plot_recovery_factor,\n", - " plot_recovery_rate,\n", ")\n", "\n", "plt.style.use(\"ggplot\")" diff --git a/docs/fluids.ipynb b/docs/fluids.ipynb index 48698e0..5da8543 100644 --- a/docs/fluids.ipynb +++ b/docs/fluids.ipynb @@ -18,16 +18,17 @@ "metadata": {}, "outputs": [], "source": [ - "import bluebonnet as bb\n", + "from __future__ import annotations\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "from bluebonnet.fluids.fluid import Fluid\n", "from bluebonnet.fluids.gas import (\n", " make_nonhydrocarbon_properties,\n", " pseudocritical_point_Sutton,\n", ")\n", "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "\n", "plt.style.use(\"ggplot\")" ] }, diff --git a/docs/forecast.ipynb b/docs/forecast.ipynb index 25765bc..7f35c4d 100644 --- a/docs/forecast.ipynb +++ b/docs/forecast.ipynb @@ -20,21 +20,21 @@ }, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "from scipy.interpolate import interp1d\n", - "from scipy.integrate import cumulative_trapezoid\n", - "from scipy.misc import derivative\n", "import pandas as pd\n", - "import matplotlib.pyplot as plt\n", + "from scipy.integrate import cumulative_trapezoid\n", + "from scipy.interpolate import interp1d\n", "\n", - "import bluebonnet as bb\n", "from bluebonnet.flow import (\n", - " IdealReservoir,\n", " FlowProperties,\n", - " SinglePhaseReservoir,\n", + " IdealReservoir,\n", " RelPermParams,\n", + " SinglePhaseReservoir,\n", ")\n", - "from bluebonnet.forecast import Bounds, ForecasterOnePhase" + "from bluebonnet.forecast import ForecasterOnePhase" ] }, { @@ -372,7 +372,6 @@ "source": [ "from bluebonnet.flow import (\n", " FlowPropertiesTwoPhase,\n", - " RelPermParams,\n", " relative_permeabilities,\n", ")\n", "\n", diff --git a/docs/forecast_varying.ipynb b/docs/forecast_varying.ipynb index d52899a..c0857bd 100644 --- a/docs/forecast_varying.ipynb +++ b/docs/forecast_varying.ipynb @@ -20,9 +20,11 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", - "import matplotlib.pyplot as plt\n", "from scipy import interpolate\n", "\n", "from bluebonnet.flow import FlowProperties, SinglePhaseReservoir\n", @@ -30,8 +32,7 @@ "from bluebonnet.forecast.forecast_pressure import (\n", " fit_production_pressure,\n", " plot_production_comparison,\n", - ")\n", - "from bluebonnet import plotting" + ")" ] }, { diff --git a/docs/getting_started.ipynb b/docs/getting_started.ipynb index d1a1a21..d3d7541 100644 --- a/docs/getting_started.ipynb +++ b/docs/getting_started.ipynb @@ -26,9 +26,12 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", + "from __future__ import annotations\n", + "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", "from scipy.interpolate import interp1d\n", + "\n", "from bluebonnet.flow import IdealReservoir\n", "from bluebonnet.forecast import Bounds, ForecasterOnePhase\n", "from bluebonnet.plotting import (\n", diff --git a/docs/oil_flow.ipynb b/docs/oil_flow.ipynb index 09fad31..e18b96e 100644 --- a/docs/oil_flow.ipynb +++ b/docs/oil_flow.ipynb @@ -20,25 +20,23 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import scipy as sp\n", - "from scipy.interpolate import interp1d\n", "import pandas as pd\n", - "import matplotlib.pyplot as plt\n", + "from scipy.interpolate import interp1d\n", "\n", "from bluebonnet.flow import (\n", - " IdealReservoir,\n", " FlowProperties,\n", " FlowPropertiesTwoPhase,\n", - " SinglePhaseReservoir,\n", " RelPermParams,\n", + " SinglePhaseReservoir,\n", " relative_permeabilities,\n", ")\n", - "from bluebonnet.fluids.fluid import Fluid, pseudopressure\n", + "from bluebonnet.fluids.fluid import pseudopressure\n", "from bluebonnet.plotting import (\n", " plot_pseudopressure,\n", - " plot_recovery_factor,\n", - " plot_recovery_rate,\n", ")\n", "\n", "plt.style.use(\"ggplot\")" @@ -63,9 +61,7 @@ "id": "53c603c9-a5df-485d-93f5-ffc307095a16", "metadata": {}, "outputs": [], - "source": [ - "from bluebonnet.flow.flowproperties import FlowPropertiesSimple" - ] + "source": [] }, { "cell_type": "code", diff --git a/tests/flow/test_properties.py b/tests/flow/test_properties.py index fefe08f..832d4a9 100644 --- a/tests/flow/test_properties.py +++ b/tests/flow/test_properties.py @@ -7,6 +7,8 @@ import numpy as np import pandas as pd import pytest +from scipy.interpolate import interp1d + from bluebonnet.flow.flowproperties import ( FlowPropertiesTwoPhase, RelPermParams, @@ -14,7 +16,6 @@ relative_permeabilities_twophase, rescale_pseudopressure, ) -from scipy.interpolate import interp1d pr = 8_000.0 Sw = 0.1 @@ -36,7 +37,7 @@ pvt_oil = pd.read_csv("tests/data/pvt_oil.csv").rename(columns=columns_renamer_oil) -@pytest.fixture() +@pytest.fixture def relperm_params(): return RelPermParams( n_o=1, @@ -51,7 +52,7 @@ def relperm_params(): ) -@pytest.fixture() +@pytest.fixture def saturations_test(): return pd.DataFrame( { @@ -62,7 +63,7 @@ def saturations_test(): ) -@pytest.fixture() +@pytest.fixture def df_pvt(): # get pvt tables pvt_oil = pd.read_csv("tests/data/pvt_oil.csv") diff --git a/tests/flow/test_reservoir.py b/tests/flow/test_reservoir.py index 5a33b3a..dab2c50 100644 --- a/tests/flow/test_reservoir.py +++ b/tests/flow/test_reservoir.py @@ -7,13 +7,14 @@ import numpy as np import pandas as pd import pytest +from scipy.optimize import curve_fit + from bluebonnet.flow import ( FlowProperties, IdealReservoir, MultiPhaseReservoir, SinglePhaseReservoir, ) -from scipy.optimize import curve_fit nx = (30,) nt = (1200,) @@ -110,6 +111,7 @@ def test_rf_late_asymptotes(self, nx, pf, pi, fluid, Reservoir, nt): reservoir.simulate(time) if False: import matplotlib.pyplot as plt + from bluebonnet.plotting import plot_pseudopressure, plot_recovery_factor fig, ax = plt.subplots() diff --git a/tests/fluids/test_fluid.py b/tests/fluids/test_fluid.py index fa66ab0..c6c425c 100644 --- a/tests/fluids/test_fluid.py +++ b/tests/fluids/test_fluid.py @@ -4,10 +4,11 @@ import numpy as np import pytest + from bluebonnet.fluids import Fluid -@pytest.fixture() +@pytest.fixture def fluid_instance(oil_properties): fluid = Fluid( oil_properties.temperature, diff --git a/tests/fluids/test_gas.py b/tests/fluids/test_gas.py index 2f7b01e..20b2d31 100644 --- a/tests/fluids/test_gas.py +++ b/tests/fluids/test_gas.py @@ -4,6 +4,7 @@ import numpy as np import pytest + from bluebonnet.fluids import gas TEMPERATURE_STANDARD = 60.0 diff --git a/tests/fluids/test_oil.py b/tests/fluids/test_oil.py index f4dedf6..9bccb7c 100644 --- a/tests/fluids/test_oil.py +++ b/tests/fluids/test_oil.py @@ -5,6 +5,7 @@ import math import pytest + from bluebonnet.fluids import oil TEMPERATURE_STANDARD = 60.0 diff --git a/tests/fluids/test_water.py b/tests/fluids/test_water.py index 2aed5b0..661413d 100644 --- a/tests/fluids/test_water.py +++ b/tests/fluids/test_water.py @@ -3,6 +3,7 @@ from __future__ import annotations import pytest + from bluebonnet.fluids import water TEMPERATURE_STANDARD = 60.0 diff --git a/tests/forecast/test_forecast.py b/tests/forecast/test_forecast.py index 306420d..f4bf39b 100644 --- a/tests/forecast/test_forecast.py +++ b/tests/forecast/test_forecast.py @@ -5,6 +5,8 @@ import numpy as np import pandas as pd import pytest +from lmfit import Parameters + from bluebonnet.flow import FlowProperties, IdealReservoir, SinglePhaseReservoir from bluebonnet.forecast import ( Bounds, @@ -12,7 +14,6 @@ fit_production_pressure, plot_production_comparison, ) -from lmfit import Parameters t_end = 6.0 nx = 40 @@ -22,7 +23,7 @@ time_scaled = np.linspace(0, np.sqrt(t_end), nt) ** 2 -@pytest.fixture() +@pytest.fixture def rf_curve(): """Return function for recovery factor from an ideal reservoir.""" reservoir = IdealReservoir(nx, pf, pi, None) @@ -31,7 +32,7 @@ def rf_curve(): return reservoir.recovery_factor_interpolator() -@pytest.fixture() +@pytest.fixture def pressure_varying_prod(): """Necessary data for a pressure-varying system.""" tau_in = 180.0 @@ -90,7 +91,7 @@ def test_fit_production_pressure(pressure_varying_prod): assert result.params["M"].value > 1e3, "is M increasing from the initial guess?" -@pytest.mark.mpl_image_compare() +@pytest.mark.mpl_image_compare def test_fit_plot(pressure_varying_prod): prod, pvt_table = pressure_varying_prod params = Parameters() diff --git a/tests/test_plots.py b/tests/test_plots.py index 83254fe..576ac74 100644 --- a/tests/test_plots.py +++ b/tests/test_plots.py @@ -4,6 +4,7 @@ import numpy as np import pandas as pd import pytest + from bluebonnet.flow import FlowProperties from bluebonnet.plotting import ( SinglePhaseReservoir, @@ -27,7 +28,7 @@ fluid = FlowProperties(pvt_gas, pi) -@pytest.fixture() +@pytest.fixture def reservoir(): reservoir = SinglePhaseReservoir( nx, pressure_fracface=pf, pressure_initial=pi, fluid=fluid @@ -38,7 +39,7 @@ def reservoir(): return reservoir -@pytest.mark.mpl_image_compare() +@pytest.mark.mpl_image_compare @pytest.mark.parametrize("rescale", [True, False]) def test_plot_pseudopressure(reservoir, rescale): fig, ax = plt.subplots() @@ -46,7 +47,7 @@ def test_plot_pseudopressure(reservoir, rescale): return fig -@pytest.mark.mpl_image_compare() +@pytest.mark.mpl_image_compare @pytest.mark.parametrize("change_ticks", [True, False]) def test_plot_recovery_rate(reservoir, change_ticks): fig, ax = plt.subplots() @@ -54,7 +55,7 @@ def test_plot_recovery_rate(reservoir, change_ticks): return fig -@pytest.mark.mpl_image_compare() +@pytest.mark.mpl_image_compare @pytest.mark.parametrize("change_ticks", [True, False]) def test_plot_recovery_factor(reservoir, change_ticks): fig, ax = plt.subplots()