From e5067e35bbc5b39ea041386b0e6516ba154ce206 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Wed, 1 Feb 2023 15:07:39 +0100 Subject: [PATCH 1/3] fix #508 - add logic for settings as dict --- pastas/decorators.py | 2 +- pastas/model.py | 1 - pastas/modelplots.py | 1 - pastas/modelstats.py | 16 ++++++++-------- pastas/plots.py | 1 - pastas/recharge.py | 8 ++++---- pastas/rfunc.py | 2 -- pastas/solver.py | 1 - pastas/stressmodels.py | 2 +- 9 files changed, 14 insertions(+), 20 deletions(-) diff --git a/pastas/decorators.py b/pastas/decorators.py index 364db185..df190e89 100644 --- a/pastas/decorators.py +++ b/pastas/decorators.py @@ -51,7 +51,7 @@ def _model_tmin_tmax( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, *args, - **kwargs + **kwargs, ): if tmin is None: tmin = self.ml.settings["tmin"] diff --git a/pastas/model.py b/pastas/model.py index 8ff703fe..e872edec 100644 --- a/pastas/model.py +++ b/pastas/model.py @@ -95,7 +95,6 @@ def __init__( metadata: Optional[dict] = None, freq: str = "D", ) -> None: - self.logger = getLogger(__name__) # Construct the different model components diff --git a/pastas/modelplots.py b/pastas/modelplots.py index dde474e9..d9d40b7e 100644 --- a/pastas/modelplots.py +++ b/pastas/modelplots.py @@ -844,7 +844,6 @@ def custom_sort(t): # loop over axes showing stressmodel contributions for i, sm in zip(range(3, 3 + 2 * nsm, 2), self.ml.stressmodels.keys()): - # Get the contributions for StressModels with multiple stresses contributions = [] sml = self.ml.stressmodels[sm] diff --git a/pastas/modelstats.py b/pastas/modelstats.py index b25dbebf..b627e7a1 100644 --- a/pastas/modelstats.py +++ b/pastas/modelstats.py @@ -79,7 +79,7 @@ def rmse( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Root mean squared error of the residuals. @@ -104,7 +104,7 @@ def rmsn( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Root mean squared error of the noise. @@ -155,7 +155,7 @@ def mae( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Mean Absolute Error (MAE) of the residuals. @@ -180,7 +180,7 @@ def nse( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Nash-Sutcliffe coefficient for model fit . @@ -206,7 +206,7 @@ def pearsonr( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Compute the (weighted) Pearson correlation (r). @@ -232,7 +232,7 @@ def evp( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Explained variance percentage. @@ -258,7 +258,7 @@ def rsq( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """R-squared. @@ -284,7 +284,7 @@ def kge_2012( tmin: Optional[TimestampType] = None, tmax: Optional[TimestampType] = None, weighted: bool = False, - **kwargs + **kwargs, ) -> float: """Kling-Gupta Efficiency. diff --git a/pastas/plots.py b/pastas/plots.py index e32dfc09..d8a4ffdd 100644 --- a/pastas/plots.py +++ b/pastas/plots.py @@ -564,7 +564,6 @@ def __init__( tmax: Optional[TimestampType] = None, update_iter: Optional[int] = None, ) -> None: - logger.warning( "TrackSolve feature under development. If you find any bugs please post " "an issue on GitHub: https://github.com/pastas/pastas/issues" diff --git a/pastas/recharge.py b/pastas/recharge.py index 3a9c90b7..26dce2c3 100644 --- a/pastas/recharge.py +++ b/pastas/recharge.py @@ -235,7 +235,7 @@ def simulate( p: ArrayLike, dt: float = 1.0, return_full: bool = False, - **kwargs + **kwargs, ) -> ArrayLike: """Simulate the soil water balance model. @@ -498,7 +498,7 @@ def get_water_balance( temp: ArrayLike, p: ArrayLike, dt: float = 1.0, - **kwargs + **kwargs, ) -> DataFrame: data = self.simulate( prec=prec, evap=evap, temp=temp, p=p, dt=dt, return_full=True, **kwargs @@ -611,7 +611,7 @@ def simulate( p: ArrayLike, dt: ArrayLike = 1.0, return_full: bool = False, - **kwargs + **kwargs, ) -> Union[ArrayLike, Tuple[ArrayLike, ArrayLike, ArrayLike, ArrayLike]]: """Simulate the recharge flux. @@ -760,7 +760,7 @@ def simulate( p: ArrayLike, dt: float = 1.0, return_full: bool = False, - **kwargs + **kwargs, ) -> Union[ArrayLike, Tuple[ArrayLike, ArrayLike, ArrayLike, ArrayLike]]: """Simulate the recharge flux. diff --git a/pastas/rfunc.py b/pastas/rfunc.py index a3bdc9fd..f5d8db2c 100644 --- a/pastas/rfunc.py +++ b/pastas/rfunc.py @@ -1277,7 +1277,6 @@ def step( cutoff: Optional[float] = None, maxtmax: Optional[int] = None, ) -> ArrayLike: - # Because Model.get_response_tmax() provides parameters for the stressmodel, # not only the response functions if len(p) > 4: @@ -1293,7 +1292,6 @@ def step( return s else: - t1 = -np.sqrt(3 / 5) t2 = 0 t3 = np.sqrt(3 / 5) diff --git a/pastas/solver.py b/pastas/solver.py index bbda39bd..0fae24ee 100644 --- a/pastas/solver.py +++ b/pastas/solver.py @@ -607,7 +607,6 @@ def solve( method: Optional[str] = "leastsq", **kwargs, ) -> Tuple[bool, ArrayLike, ArrayLike]: - # Deal with the parameters parameters = lmfit.Parameters() p = self.ml.parameters.loc[:, ["initial", "pmin", "pmax", "vary"]] diff --git a/pastas/stressmodels.py b/pastas/stressmodels.py index dd2338ea..558a756a 100644 --- a/pastas/stressmodels.py +++ b/pastas/stressmodels.py @@ -719,7 +719,7 @@ def __init__( distances = np.sort(distances) - if settings is None or isinstance(settings, str): + if settings is None or isinstance(settings, str) or isinstance(settings, dict): settings = len(stress) * [settings] # convert stresses to TimeSeries if necessary From e1ec7451e9b81936209c04f45a0aa39b39558712 Mon Sep 17 00:00:00 2001 From: dbrakenhoff Date: Wed, 1 Feb 2023 15:12:05 +0100 Subject: [PATCH 2/3] black formatting conf --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index cfb72c21..38ffc732 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -129,6 +129,7 @@ # -- Generating references and publications lists ------------------------- + # support Round brackets def bracket_style() -> BracketStyle: return BracketStyle( From 0779b7669c7ff04e18792a1962c2c9e4b12e0aa8 Mon Sep 17 00:00:00 2001 From: Raoul Collenteur Date: Thu, 2 Feb 2023 11:35:07 +0100 Subject: [PATCH 3/3] update version to 0.23.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 10b32ab2..1c53a047 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "pastas" -version = "0.23.0" +version = "0.23.1" description = "Pastas is an open-source Python framework for the analysis of groundwater time series." license = { file = "LICENSE" } readme = "README.rst"