From dfc968c6d3479e98695d4088bdd0e46a40543461 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 May 2023 13:33:23 +0200 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#463) --- .pre-commit-config.yaml | 16 ++++------------ src/estimagic/differentiation/derivatives.py | 2 +- src/estimagic/examples/numdiff_functions.py | 1 - src/estimagic/inference/bootstrap_samples.py | 2 +- src/estimagic/optimization/algo_options.py | 1 - src/estimagic/optimization/tiktak.py | 8 +------- .../parameters/consolidate_constraints.py | 2 +- src/estimagic/sensitivity/msm_sensitivity.py | 12 ++++++------ tests/optimization/test_optimize.py | 6 +++--- 9 files changed, 17 insertions(+), 33 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba2d04a31..ec042684b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,7 +52,7 @@ repos: - id: check-docstring-first exclude: src/estimagic/optimization/algo_options.py - repo: https://github.com/adrienverge/yamllint.git - rev: v1.30.0 + rev: v1.31.0 hooks: - id: yamllint exclude: tests/optimization/fixtures @@ -67,7 +67,7 @@ repos: - id: blacken-docs exclude: docs/source/how_to_guides/optimization/how_to_specify_constraints.md - repo: https://github.com/PyCQA/docformatter - rev: v1.5.1 + rev: v1.6.4 hooks: - id: docformatter args: @@ -77,19 +77,11 @@ repos: - --wrap-descriptions - '88' - --blank + exclude: src/estimagic/optimization/algo_options.py - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.261 + rev: v0.0.263 hooks: - id: ruff - # args: - # - --verbose - # - repo: https://github.com/kynan/nbstripout - # rev: 0.6.1 - # hooks: - # - id: nbstripout - # args: - # - --extra-keys - # - metadata.kernelspec metadata.language_info.version metadata.vscode - repo: https://github.com/nbQA-dev/nbQA rev: 1.7.0 hooks: diff --git a/src/estimagic/differentiation/derivatives.py b/src/estimagic/differentiation/derivatives.py index 500be4505..8ea3bc1df 100644 --- a/src/estimagic/differentiation/derivatives.py +++ b/src/estimagic/differentiation/derivatives.py @@ -723,7 +723,7 @@ def _convert_richardson_candidates_to_frame(jac, err): def _convert_evals_to_numpy( raw_evals, key, registry, is_scalar_out=False, is_vector_out=False ): - """harmonize the output of the function evaluations. + """Harmonize the output of the function evaluations. The raw_evals might contain dictionaries of which we only need one entry, scalar np.nan where we need arrays filled with np.nan or pandas objects. The processed diff --git a/src/estimagic/examples/numdiff_functions.py b/src/estimagic/examples/numdiff_functions.py index ec9c5ee38..d99bf6b17 100644 --- a/src/estimagic/examples/numdiff_functions.py +++ b/src/estimagic/examples/numdiff_functions.py @@ -4,7 +4,6 @@ Example inputs for the binary choice functions are in binary_choice_inputs.pickle. They come from the statsmodels documentation: - https://tinyurl.com/y4x67vwl We pickled them so we don't need statsmodels as a dependency. diff --git a/src/estimagic/inference/bootstrap_samples.py b/src/estimagic/inference/bootstrap_samples.py index babc8f68a..4163eef56 100644 --- a/src/estimagic/inference/bootstrap_samples.py +++ b/src/estimagic/inference/bootstrap_samples.py @@ -75,7 +75,7 @@ def get_bootstrap_samples(data, rng, cluster_by=None, n_draws=1000): def _get_bootstrap_samples_from_indices(data, bootstrap_indices): - """convert bootstrap indices into actual bootstrap samples. + """Convert bootstrap indices into actual bootstrap samples. Args: data (pandas.DataFrame): original dataset. diff --git a/src/estimagic/optimization/algo_options.py b/src/estimagic/optimization/algo_options.py index d72ec309e..74085912a 100644 --- a/src/estimagic/optimization/algo_options.py +++ b/src/estimagic/optimization/algo_options.py @@ -187,7 +187,6 @@ """ - """ ------------------------- Trust Region Parameters diff --git a/src/estimagic/optimization/tiktak.py b/src/estimagic/optimization/tiktak.py index f11e8103a..c9e32d975 100644 --- a/src/estimagic/optimization/tiktak.py +++ b/src/estimagic/optimization/tiktak.py @@ -3,16 +3,10 @@ TikTak (`Arnoud, Guvenen, and Kleineberg `_) - - - - - -is an algorithm for solving global optimization problems. It performs local searches + is an algorithm for solving global optimization problems. It performs local searches from a set of carefully-selected points in the parameter space. First implemented in Python by Alisdair McKay ( - `GitHub Repository `_) """ diff --git a/src/estimagic/parameters/consolidate_constraints.py b/src/estimagic/parameters/consolidate_constraints.py index eaad33d8e..c31486522 100644 --- a/src/estimagic/parameters/consolidate_constraints.py +++ b/src/estimagic/parameters/consolidate_constraints.py @@ -215,7 +215,7 @@ def _consolidate_fixes_with_equality_constraints( def _consolidate_bounds_with_equality_constraints( equality_constraints, lower_bounds, upper_bounds ): - """consolidate bounds with equality constraints. + """Consolidate bounds with equality constraints. Check that there are no incompatible bounds on equality constrained parameters and set the bounds for equal parameters to the strictest bound encountered on any of diff --git a/src/estimagic/sensitivity/msm_sensitivity.py b/src/estimagic/sensitivity/msm_sensitivity.py index 8d3b1ba2a..ff689a22d 100644 --- a/src/estimagic/sensitivity/msm_sensitivity.py +++ b/src/estimagic/sensitivity/msm_sensitivity.py @@ -16,7 +16,7 @@ def calculate_sensitivity_to_bias(jac, weights): - """calculate the sensitivity to bias. + """Calculate the sensitivity to bias. The sensitivity measure is calculated for each parameter wrt each moment. @@ -47,7 +47,7 @@ def calculate_sensitivity_to_bias(jac, weights): def calculate_fundamental_sensitivity_to_noise( jac, weights, moments_cov, params_cov_opt ): - """calculate the fundamental sensitivity to noise. + """Calculate the fundamental sensitivity to noise. The sensitivity measure is calculated for each parameter wrt each moment. @@ -104,7 +104,7 @@ def calculate_fundamental_sensitivity_to_noise( def calculate_actual_sensitivity_to_noise( sensitivity_to_bias, weights, moments_cov, params_cov ): - """calculate the actual sensitivity to noise. + """Calculate the actual sensitivity to noise. The sensitivity measure is calculated for each parameter wrt each moment. @@ -159,7 +159,7 @@ def calculate_actual_sensitivity_to_noise( def calculate_actual_sensitivity_to_removal(jac, weights, moments_cov, params_cov): - """calculate the actual sensitivity to removal. + """Calculate the actual sensitivity to removal. The sensitivity measure is calculated for each parameter wrt each moment. @@ -211,7 +211,7 @@ def calculate_actual_sensitivity_to_removal(jac, weights, moments_cov, params_co def calculate_fundamental_sensitivity_to_removal(jac, moments_cov, params_cov_opt): - """calculate the fundamental sensitivity to removal. + """Calculate the fundamental sensitivity to removal. The sensitivity measure is calculated for each parameter wrt each moment. @@ -269,7 +269,7 @@ def calculate_fundamental_sensitivity_to_removal(jac, moments_cov, params_cov_op def calculate_sensitivity_to_weighting(jac, weights, moments_cov, params_cov): - """calculate the sensitivity to weighting. + """Calculate the sensitivity to weighting. The sensitivity measure is calculated for each parameter wrt each moment. diff --git a/tests/optimization/test_optimize.py b/tests/optimization/test_optimize.py index 7bd92d717..f0934ae2e 100644 --- a/tests/optimization/test_optimize.py +++ b/tests/optimization/test_optimize.py @@ -3,7 +3,7 @@ import pandas as pd import pytest from estimagic.examples.criterion_functions import sos_scalar_criterion -from estimagic.exceptions import InvalidKwargsError +from estimagic.exceptions import InvalidKwargsError, InvalidFunctionError from estimagic.optimization.optimize import maximize, minimize @@ -23,9 +23,9 @@ def test_scipy_lbfgsb_actually_calls_criterion_and_derivative(): params = pd.DataFrame(data=np.ones((10, 1)), columns=["value"]) def raising_crit_and_deriv(params): # noqa: ARG001 - raise Exception() + raise NotImplementedError("This should not be called.") - with pytest.raises(Exception): + with pytest.raises(InvalidFunctionError, match="Error while evaluating"): minimize( criterion=sos_scalar_criterion, params=params,