From b651439eb9bb002001829d10679fc21ca84c703b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 12:13:45 +0100 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#433) --- .envs/testenv-linkcheck.yml | 22 -------------- .envs/testenv-linux.yml | 17 ++++------- .envs/testenv-others.yml | 17 ++++------- .envs/update_envs.py | 4 +-- .github/workflows/main.yml | 5 ---- .github/workflows/publish-to-pypi.yml | 4 --- .pre-commit-config.yaml | 10 +++---- .readthedocs.yml | 3 -- .yamllint.yml | 1 - codecov.yml | 2 -- docs/rtd_environment.yml | 4 --- environment.yml | 29 ++++++++----------- pyproject.toml | 11 +++++-- .../benchmarking/get_benchmark_problems.py | 2 +- src/estimagic/benchmarking/run_benchmark.py | 1 - src/estimagic/decorators.py | 18 ++++++++++-- src/estimagic/differentiation/derivatives.py | 1 - src/estimagic/estimation/estimate_msm.py | 3 -- src/estimagic/examples/numdiff_functions.py | 3 +- src/estimagic/inference/bootstrap.py | 1 - src/estimagic/inference/bootstrap_ci.py | 5 ---- src/estimagic/inference/ml_covs.py | 1 - src/estimagic/inference/shared.py | 1 - src/estimagic/logging/database_utilities.py | 4 ++- src/estimagic/logging/read_log.py | 2 -- src/estimagic/optimization/get_algorithm.py | 1 - .../internal_criterion_template.py | 6 ---- src/estimagic/optimization/neldermead.py | 16 +--------- .../optimization/nlopt_optimizers.py | 4 --- src/estimagic/optimization/optimize.py | 2 -- .../subsolvers/_conjugate_gradient.py | 1 - .../subsolvers/_conjugate_gradient_fast.py | 1 - .../optimization/subsolvers/_trsbox_fast.py | 1 - .../optimization/subsolvers/bntr_fast.py | 1 - .../optimization/subsolvers/gqtpar.py | 2 -- .../optimization/subsolvers/gqtpar_fast.py | 3 -- src/estimagic/optimization/tiktak.py | 15 ++++++++-- .../optimization/tranquilo/poisedness.py | 3 -- .../optimization/tranquilo/sample_points.py | 1 - src/estimagic/parameters/block_trees.py | 1 - .../parameters/nonlinear_constraints.py | 5 ---- src/estimagic/parameters/parameter_bounds.py | 2 -- .../parameters/process_constraints.py | 1 - src/estimagic/parameters/process_selectors.py | 1 - src/estimagic/process_user_function.py | 1 - src/estimagic/shared/check_option_dicts.py | 2 -- .../visualization/convergence_plot.py | 3 -- .../visualization/derivative_plot.py | 2 +- .../visualization/estimation_table.py | 3 -- src/estimagic/visualization/history_plots.py | 5 ---- .../visualization/plotting_utilities.py | 1 - tests/estimation/test_estimate_ml.py | 3 -- tests/optimization/test_with_constraints.py | 1 - .../test_with_nonlinear_constraints.py | 8 ++--- .../optimization/tranquilo/test_poisedness.py | 2 -- tests/sensitivity/test_msm_sensitivity.py | 3 -- .../test_msm_sensitivity_via_estimate_msm.py | 2 -- tests/visualization/test_history_plots.py | 1 - 58 files changed, 78 insertions(+), 197 deletions(-) delete mode 100644 .envs/testenv-linkcheck.yml diff --git a/.envs/testenv-linkcheck.yml b/.envs/testenv-linkcheck.yml deleted file mode 100644 index 196b3221d..000000000 --- a/.envs/testenv-linkcheck.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: estimagic - -channels: - - conda-forge - - nodefaults - -dependencies: - - jupyterlab # dev, docs - - nb_black # dev, docs - - pip # dev, tests, docs - - - - pydata-sphinx-theme>=0.3.0 # docs - - myst-nb # docs - - sphinx # docs - - sphinx-copybutton # docs - - sphinx-panels # docs - - sphinxcontrib-bibtex # docs - - - pip: # dev, tests, docs - - -e ../ diff --git a/.envs/testenv-linux.yml b/.envs/testenv-linux.yml index 29e481681..205b92b63 100644 --- a/.envs/testenv-linux.yml +++ b/.envs/testenv-linux.yml @@ -1,10 +1,8 @@ --- name: estimagic - channels: - conda-forge - nodefaults - dependencies: - jax - pygmo @@ -14,7 +12,6 @@ dependencies: - pytest-cov # tests - pytest-xdist # dev, tests - statsmodels # dev, tests - - bokeh<=2.4.3 # run, tests - click # run, tests - cloudpickle # run, tests @@ -26,13 +23,11 @@ dependencies: - plotly # run, tests - pybaum >= 0.1.2 # run, tests - scipy>=1.2.1 # run, tests - - sqlalchemy <2.0 # run, tests - - + - sqlalchemy <2.0 # run, tests - pip: # dev, tests, docs - - DFO-LS # dev, tests - - Py-BOBYQA # dev, tests - - fides==0.7.4 # dev, tests - - kaleido # dev, tests - - simoptlib==1.0.1 # dev, tests + - DFO-LS # dev, tests + - Py-BOBYQA # dev, tests + - fides==0.7.4 # dev, tests + - kaleido # dev, tests + - simoptlib==1.0.1 # dev, tests - -e ../ diff --git a/.envs/testenv-others.yml b/.envs/testenv-others.yml index 66efcff60..995208d74 100644 --- a/.envs/testenv-others.yml +++ b/.envs/testenv-others.yml @@ -1,10 +1,8 @@ --- name: estimagic - channels: - conda-forge - nodefaults - dependencies: - cyipopt - nlopt # dev, tests @@ -13,7 +11,6 @@ dependencies: - pytest-cov # tests - pytest-xdist # dev, tests - statsmodels # dev, tests - - bokeh<=2.4.3 # run, tests - click # run, tests - cloudpickle # run, tests @@ -25,13 +22,11 @@ dependencies: - plotly # run, tests - pybaum >= 0.1.2 # run, tests - scipy>=1.2.1 # run, tests - - sqlalchemy <2.0 # run, tests - - + - sqlalchemy <2.0 # run, tests - pip: # dev, tests, docs - - DFO-LS # dev, tests - - Py-BOBYQA # dev, tests - - fides==0.7.4 # dev, tests - - kaleido # dev, tests - - simoptlib==1.0.1 # dev, tests + - DFO-LS # dev, tests + - Py-BOBYQA # dev, tests + - fides==0.7.4 # dev, tests + - kaleido # dev, tests + - simoptlib==1.0.1 # dev, tests - -e ../ diff --git a/.envs/update_envs.py b/.envs/update_envs.py index 5fbdc3258..8422b58e3 100644 --- a/.envs/update_envs.py +++ b/.envs/update_envs.py @@ -40,9 +40,7 @@ def main(): docs_env.append(" - -e ../") # add local installation # write environments - for name, env in zip( - ["linux", "others", "linkcheck"], [test_env_linux, test_env_others, docs_env] - ): + for name, env in zip(["linux", "others"], [test_env_linux, test_env_others]): Path(f".envs/testenv-{name}.yml").write_text("\n".join(env) + "\n") diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc5946186..895c6cfa5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,11 +1,9 @@ --- name: main - # Automatically cancel a previous run. concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true - on: push: branches: @@ -13,7 +11,6 @@ on: pull_request: branches: - '*' - jobs: run-tests-linux: name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }} @@ -47,7 +44,6 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - run-tests-win-and-mac: name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }} runs-on: ${{ matrix.os }} @@ -76,7 +72,6 @@ jobs: run: | micromamba activate estimagic pytest -m "not slow and not jax" - code-in-docs: name: Run code snippets in documentation runs-on: ubuntu-latest diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 564bdeb03..060d30675 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,20 +1,16 @@ --- name: PyPI - on: push - jobs: build-n-publish: name: Build and publish Python 🐍 distributions 📦 to PyPI runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: '3.10' - - name: Install pypa/build run: >- python -m diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86687c012..4325d4c0d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: check-useless-excludes # - id: identity # Prints all files passed to pre-commits. Debugging. - repo: https://github.com/lyz-code/yamlfix - rev: 1.2.0 + rev: 1.8.0 hooks: - id: yamlfix exclude: tests/optimization/fixtures @@ -18,7 +18,6 @@ repos: language: python always_run: true require_serial: true - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -53,12 +52,12 @@ repos: - id: check-docstring-first exclude: src/estimagic/optimization/algo_options.py - repo: https://github.com/adrienverge/yamllint.git - rev: v1.28.0 + rev: v1.29.0 hooks: - id: yamllint exclude: tests/optimization/fixtures - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black language_version: python3.10 @@ -79,7 +78,7 @@ repos: - '88' - --blank - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.230 + rev: v0.0.241 hooks: - id: ruff # args: @@ -131,6 +130,5 @@ repos: additional_dependencies: - setuptools-scm - toml - ci: autoupdate_schedule: monthly diff --git a/.readthedocs.yml b/.readthedocs.yml index 33f6f8749..e35e92185 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,14 +1,11 @@ --- version: 2 - build: os: ubuntu-22.04 tools: python: mambaforge-4.10 - conda: environment: docs/rtd_environment.yml - sphinx: builder: html configuration: docs/source/conf.py diff --git a/.yamllint.yml b/.yamllint.yml index 94867a7ea..72f64be10 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -3,7 +3,6 @@ yaml-files: - '*.yaml' - '*.yml' - .yamllint - rules: braces: enable brackets: enable diff --git a/codecov.yml b/codecov.yml index a192d2c84..dc34a5f68 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,7 +2,6 @@ codecov: notify: require_ci_to_pass: true - coverage: precision: 2 round: down @@ -14,7 +13,6 @@ coverage: project: default: target: 90% - ignore: - .tox/**/* - release.py diff --git a/docs/rtd_environment.yml b/docs/rtd_environment.yml index 8cc144eba..52ee7b80f 100644 --- a/docs/rtd_environment.yml +++ b/docs/rtd_environment.yml @@ -1,16 +1,13 @@ --- name: estimagic-docs - channels: - conda-forge - nodefaults - dependencies: - python=3.9 - pip - setuptools_scm - toml - - black - sphinx - sphinxcontrib-bibtex @@ -31,7 +28,6 @@ dependencies: - joblib - plotly - ipython - - pip: - ../ - kaleido diff --git a/environment.yml b/environment.yml index df84eed88..4915f898d 100644 --- a/environment.yml +++ b/environment.yml @@ -1,10 +1,8 @@ --- name: estimagic - channels: - conda-forge - nodefaults - dependencies: - python=3.10 # dev - cyipopt # dev @@ -20,7 +18,6 @@ dependencies: - setuptools_scm # dev - statsmodels # dev, tests - toml # dev - - bokeh<=2.4.3 # run, tests - click # run, tests - cloudpickle # run, tests @@ -32,24 +29,22 @@ dependencies: - plotly # run, tests - pybaum >= 0.1.2 # run, tests - scipy>=1.2.1 # run, tests - - sqlalchemy <2.0 # run, tests - + - sqlalchemy <2.0 # run, tests - pydata-sphinx-theme>=0.3.0 # docs - myst-nb # docs - sphinx # docs - sphinx-copybutton # docs - sphinx-panels # docs - sphinxcontrib-bibtex # docs - - pip: # dev, tests, docs - - DFO-LS # dev, tests - - Py-BOBYQA # dev, tests - - black # dev - - blackcellmagic # dev - - fides==0.7.4 # dev, tests - - gif # dev - - gif[matplotlib] # dev - - kaleido # dev, tests - - pre-commit # dev - - simoptlib==1.0.1 # dev, tests - - -e . # dev + - DFO-LS # dev, tests + - Py-BOBYQA # dev, tests + - black # dev + - blackcellmagic # dev + - fides==0.7.4 # dev, tests + - gif # dev + - gif[matplotlib] # dev + - kaleido # dev, tests + - pre-commit # dev + - simoptlib==1.0.1 # dev, tests + - -e . # dev diff --git a/pyproject.toml b/pyproject.toml index 3b7dcb24f..35d6fffaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,8 @@ extend-ignore = [ "S324", # Probable use of insecure hash function. "COM812", # trailing comma missing, but black takes care of that "PT007", # wrong type in parametrize, gave false positives + "EXE001", # Shebang is present but file is not executable + "PIE804", # unnecessary dict kwargs # Things we are not sure we want @@ -58,7 +60,12 @@ extend-ignore = [ "C901", # function too complex "PT011", # pytest raises without match statement "INP001", # implicit namespace packages without init. - "TRY300", # consider moving this statement to an else block + "TRY", + "PLR", + "TCH", + "RSE", + "SLF", + "PTH123", # ====================================== ] @@ -112,5 +119,5 @@ norecursedirs = ["docs", ".envs"] [tool.yamlfix] line_length = 88 -flow_style_sequence = false +sequence_style = "block_style" none_representation = "null" diff --git a/src/estimagic/benchmarking/get_benchmark_problems.py b/src/estimagic/benchmarking/get_benchmark_problems.py index ef853180f..fcfa80ffa 100644 --- a/src/estimagic/benchmarking/get_benchmark_problems.py +++ b/src/estimagic/benchmarking/get_benchmark_problems.py @@ -99,7 +99,7 @@ def get_benchmark_problems( if scaling: scaling_options = scaling_options if scaling_options is not None else {} - scaling_options = {**{"min_scale": 0.1, "max_scale": 10}, **scaling_options} + scaling_options = {"min_scale": 0.1, "max_scale": 10, **scaling_options} else: scaling_options = None diff --git a/src/estimagic/benchmarking/run_benchmark.py b/src/estimagic/benchmarking/run_benchmark.py index 6d69bdb95..499ef9bb9 100644 --- a/src/estimagic/benchmarking/run_benchmark.py +++ b/src/estimagic/benchmarking/run_benchmark.py @@ -159,7 +159,6 @@ def _get_results(names, raw_results, kwargs_list): results = {} for name, result, inputs in zip(names, raw_results, kwargs_list): - if isinstance(result, OptimizeResult): history = result.history params_history = pd.DataFrame( diff --git a/src/estimagic/decorators.py b/src/estimagic/decorators.py index c780df64f..419ebbd0d 100644 --- a/src/estimagic/decorators.py +++ b/src/estimagic/decorators.py @@ -3,11 +3,24 @@ There are two kinds of decorators defined in this module which consists of either two or three nested functions. The former are decorators without and the latter with arguments. -For more information on decorators, see this `guide`_ on https://realpython.com which +For more information on decorators, see this `guide +`_ on https://realpython.com + + + + + + + + + + +which provides a comprehensive overview. .. _guide: - https://realpython.com/primer-on-python-decorators/ + +https://realpython.com/primer-on-python-decorators/ """ import functools @@ -59,7 +72,6 @@ def wrapper_catch(*args, **kwargs): except exclude: raise except exception as e: - if onerror is not None: onerror(e) diff --git a/src/estimagic/differentiation/derivatives.py b/src/estimagic/differentiation/derivatives.py index e497fea35..76f9846c7 100644 --- a/src/estimagic/differentiation/derivatives.py +++ b/src/estimagic/differentiation/derivatives.py @@ -665,7 +665,6 @@ def _convert_evaluation_data_to_frame(steps, evals): dfs = [] for direction, step_arr, eval_arr in zip((1, -1), steps, evals): - df_steps = pd.DataFrame(step_arr, columns=range(dim_x)) df_steps = df_steps.reset_index() df_steps = df_steps.rename(columns={"index": "step_number"}) diff --git a/src/estimagic/estimation/estimate_msm.py b/src/estimagic/estimation/estimate_msm.py index 7a1289d72..e5fb23d11 100644 --- a/src/estimagic/estimation/estimate_msm.py +++ b/src/estimagic/estimation/estimate_msm.py @@ -913,7 +913,6 @@ def sensitivity( params_cov=params_cov, ) elif kind == "removal_fundamental": - raw = calculate_fundamental_sensitivity_to_removal( jac=jac, moments_cov=moments_cov, @@ -921,7 +920,6 @@ def sensitivity( ) elif kind == "weighting": - raw = calculate_sensitivity_to_weighting( jac=jac, weights=weights, @@ -977,7 +975,6 @@ def _calculate_free_cov_msm( bounds_handling, seed, ): - if method == "optimal": internal_cov = cov_optimal(internal_jacobian, internal_weights) else: diff --git a/src/estimagic/examples/numdiff_functions.py b/src/estimagic/examples/numdiff_functions.py index bc20f8514..a428ea3ea 100644 --- a/src/estimagic/examples/numdiff_functions.py +++ b/src/estimagic/examples/numdiff_functions.py @@ -3,7 +3,8 @@ All functions take a numpy array with parameters as their first argument. Example inputs for the binary choice functions are in binary_choice_inputs.pickle. -They come from the statsmodels documentation: https://tinyurl.com/y4x67vwl +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.py b/src/estimagic/inference/bootstrap.py index 0c0972c48..daf48151d 100644 --- a/src/estimagic/inference/bootstrap.py +++ b/src/estimagic/inference/bootstrap.py @@ -59,7 +59,6 @@ def bootstrap( """ if callable(outcome): - check_inputs(data=data, cluster_by=cluster_by) if outcome_kwargs is not None: diff --git a/src/estimagic/inference/bootstrap_ci.py b/src/estimagic/inference/bootstrap_ci.py index 043d52b9c..fc932935b 100644 --- a/src/estimagic/inference/bootstrap_ci.py +++ b/src/estimagic/inference/bootstrap_ci.py @@ -69,7 +69,6 @@ def _ci_percentile(estimates, alpha): cis = np.zeros((num_params, 2)) for k in range(num_params): - q = _eqf(estimates[:, k]) cis[k, :] = q(alpha / 2), q(1 - alpha / 2) @@ -95,7 +94,6 @@ def _ci_bc(estimates, base_outcome, alpha): cis = np.zeros((num_params, 2)) for k in range(num_params): - q = _eqf(estimates[:, k]) params = estimates[:, k] @@ -131,7 +129,6 @@ def _ci_t(estimates, base_outcome, alpha): cis = np.zeros((num_params, 2)) for k in range(num_params): - params = estimates[:, k] theta_std = np.std(params) @@ -164,7 +161,6 @@ def _ci_normal(estimates, base_outcome, alpha): cis = np.zeros((num_params, 2)) for k in range(num_params): - params = estimates[:, k] theta_std = np.std(params) t = norm.ppf(alpha / 2) @@ -193,7 +189,6 @@ def _ci_basic(estimates, base_outcome, alpha): cis = np.zeros((num_params, 2)) for k in range(num_params): - q = _eqf(estimates[:, k]) cis[k, :] = ( diff --git a/src/estimagic/inference/ml_covs.py b/src/estimagic/inference/ml_covs.py index 91b0198e2..de649e292 100644 --- a/src/estimagic/inference/ml_covs.py +++ b/src/estimagic/inference/ml_covs.py @@ -215,7 +215,6 @@ def _clustering(jac, design_info): the likelihood equation (Pg.557, 14-10, Greene 7th edition) """ - list_of_clusters = design_info["psu"].unique() meat = np.zeros([len(jac[0, :]), len(jac[0, :])]) for psu in list_of_clusters: diff --git a/src/estimagic/inference/shared.py b/src/estimagic/inference/shared.py index ae972add3..dbbce1100 100644 --- a/src/estimagic/inference/shared.py +++ b/src/estimagic/inference/shared.py @@ -177,7 +177,6 @@ def calculate_estimation_summary( # index for the resulting leaf. summary_flat = [] for index_leaf, params_leaf in zip(indices_flat, estimates_flat): - if np.isscalar(params_leaf): loc = [index_leaf] index = [0] diff --git a/src/estimagic/logging/database_utilities.py b/src/estimagic/logging/database_utilities.py index eccb394cc..d05525e1f 100644 --- a/src/estimagic/logging/database_utilities.py +++ b/src/estimagic/logging/database_utilities.py @@ -463,7 +463,9 @@ def _configure_engine(engine, fast_logging): """Configure the sqlite engine. The two functions that configure the emission of the begin statement are taken from - the sqlalchemy documentation the documentation: https://tinyurl.com/u9xea5z and are + the sqlalchemy documentation the documentation: + https://tinyurl.com/u9xea5z + and are the recommended way of working around a bug in the pysqlite driver. The other function speeds up the write process. If fast_logging is False, it does so diff --git a/src/estimagic/logging/read_log.py b/src/estimagic/logging/read_log.py index 8b22e5366..d8695bea3 100644 --- a/src/estimagic/logging/read_log.py +++ b/src/estimagic/logging/read_log.py @@ -48,7 +48,6 @@ def read_start_params(path_or_database): def _load_database(path_or_database): """Get an sqlalchemy.MetaDate object from path or database.""" - res = {"path": None, "metadata": None, "fast_logging": False} if isinstance(path_or_database, MetaData): res = path_or_database @@ -188,7 +187,6 @@ def _read_optimization_iteration(database, iteration, params_treedef, registry): def _read_optimization_history(database, params_treedef, registry): """Read a histories out values, parameters and other information.""" - raw_res, _ = read_new_rows( database=database, table_name="optimization_iterations", diff --git a/src/estimagic/optimization/get_algorithm.py b/src/estimagic/optimization/get_algorithm.py index 395957e02..4ec57c2fd 100644 --- a/src/estimagic/optimization/get_algorithm.py +++ b/src/estimagic/optimization/get_algorithm.py @@ -197,7 +197,6 @@ def wrapped_batch_evaluator(*args, **kwargs): # find out if func is our internal criterion function if isinstance(func, partial) and "history_container" in func.keywords: - # partial in None as history container to disable history collection via # criterion function, which would not work with parallelization anyways _func = partial(func, history_container=None, return_history_entry=True) diff --git a/src/estimagic/optimization/internal_criterion_template.py b/src/estimagic/optimization/internal_criterion_template.py index 7d87c2354..d8248f865 100644 --- a/src/estimagic/optimization/internal_criterion_template.py +++ b/src/estimagic/optimization/internal_criterion_template.py @@ -131,7 +131,6 @@ def func(x): ) raise UserFunctionRuntimeError(msg) from e else: - msg = ( "The following exception was caught when evaluating criterion to " f"calculate a numerical derivative during optimization:\n\n{tb}" @@ -155,7 +154,6 @@ def func(x): ) raise UserFunctionRuntimeError(msg) from e else: - msg = ( "The following exception was caught when evaluating " f"criterion_and_derivative during optimization:\n\n{tb}" @@ -178,7 +176,6 @@ def func(x): ) raise UserFunctionRuntimeError(msg) from e else: - msg = ( "The following exception was caught when evaluating " f"criterion during optimization:\n\n{tb}" @@ -200,7 +197,6 @@ def func(x): ) raise UserFunctionRuntimeError(msg) from e else: - msg = ( "The following exception was caught when evaluating " f"derivative during optimization:\n\n{tb}" @@ -227,7 +223,6 @@ def func(x): scalar_critval = None if (new_criterion is not None or new_derivative is not None) and logging: - _log_new_evaluations( new_criterion=new_external_criterion, new_derivative=new_derivative, @@ -352,7 +347,6 @@ def _get_output_for_optimizer( task, direction, ): - if "criterion" in task and direction == "maximize": new_criterion = -new_criterion diff --git a/src/estimagic/optimization/neldermead.py b/src/estimagic/optimization/neldermead.py index 4427d882a..5e4156bd2 100644 --- a/src/estimagic/optimization/neldermead.py +++ b/src/estimagic/optimization/neldermead.py @@ -116,20 +116,17 @@ def func_parallel(args): ) # calculate value of the criterion at the reflection point if f_s_j_r < f_s_0: # if the reflection point is better than the best point - s_j_e = m + gamma * (s_j_r - m) # calculate expansion point f_s_j_e = criterion( s_j_e ) # calculate value of the criterion at the expansion point if f_s_j_e < f_s_0: # if the expansion point is better than the best point - return np.hstack( [s_j_e, f_s_j_e, 0] ) # return the expansion point as a new point else: # if the expansion point is worse than the best point - return np.hstack( [s_j_r, f_s_j_r, 0] ) # return the reflection point as a new point @@ -137,13 +134,11 @@ def func_parallel(args): elif ( f_s_j_r < f_s_j_1 ): # if reflection point is better than the next worst point - return np.hstack( [s_j_r, f_s_j_r, 0] ) # return reflection point as a new point else: # if the reflection point is worse than the next worst point - if ( f_s_j_r < f_s_j ): # if value of the criterion at reflection point is better than @@ -167,7 +162,6 @@ def func_parallel(args): else: if f_s_j_r < f_s_j: - return np.hstack( [s_j_r, f_s_j_r, 1] ) # return reflection point as a new point @@ -183,7 +177,6 @@ def func_parallel(args): iterations = 0 # number of criterion evaluations while not optimal: - iterations += 1 # new iteration # sort points and arguments increasing @@ -240,14 +233,7 @@ def func_parallel(args): if ( np.max(np.abs(f_s[0, :] - f_s[1:, :])) <= convergence_absolute_criterion_tolerance - and np.max( - np.abs( - s[0, :] - - s[ - 1:, - ] - ) - ) + and np.max(np.abs(s[0, :] - s[1:,])) <= convergence_absolute_params_tolerance ): optimal = True diff --git a/src/estimagic/optimization/nlopt_optimizers.py b/src/estimagic/optimization/nlopt_optimizers.py index e53335b40..eaa93d54f 100644 --- a/src/estimagic/optimization/nlopt_optimizers.py +++ b/src/estimagic/optimization/nlopt_optimizers.py @@ -41,7 +41,6 @@ def nlopt_bobyqa( convergence_absolute_criterion_tolerance=CONVERGENCE_ABSOLUTE_CRITERION_TOLERANCE, stopping_max_criterion_evaluations=STOPPING_MAX_CRITERION_EVALUATIONS, ): - """Minimize a scalar function using the BOBYQA algorithm. For details see :ref:`list_of_nlopt_algorithms`. @@ -373,7 +372,6 @@ def nlopt_ccsaq( convergence_absolute_criterion_tolerance=CONVERGENCE_ABSOLUTE_CRITERION_TOLERANCE, stopping_max_criterion_evaluations=STOPPING_MAX_CRITERION_EVALUATIONS, ): - """Minimize a scalar function using CCSAQ algorithm. For details see :ref:`list_of_nlopt_algorithms`. @@ -416,7 +414,6 @@ def nlopt_mma( convergence_absolute_criterion_tolerance=CONVERGENCE_ABSOLUTE_CRITERION_TOLERANCE, stopping_max_criterion_evaluations=STOPPING_MAX_CRITERION_EVALUATIONS, ): - """Minimize a scalar function using the method of moving asymptotes (MMA). For details see :ref:`list_of_nlopt_algorithms`. @@ -463,7 +460,6 @@ def nlopt_var( stopping_max_criterion_evaluations=STOPPING_MAX_CRITERION_EVALUATIONS, rank_1_update=True, ): - """Minimize a scalar function limited memory switching variable-metric method. For details see :ref:`list_of_nlopt_algorithms`. diff --git a/src/estimagic/optimization/optimize.py b/src/estimagic/optimization/optimize.py index 74a378e61..b64583924 100644 --- a/src/estimagic/optimization/optimize.py +++ b/src/estimagic/optimization/optimize.py @@ -748,7 +748,6 @@ def _optimize( # Do actual optimization # ================================================================================== if not multistart: - steps = [{"type": "optimization", "name": "optimization"}] step_ids = log_scheduled_steps_and_get_ids( @@ -759,7 +758,6 @@ def _optimize( raw_res = internal_algorithm(**problem_functions, x=x, step_id=step_ids[0]) else: - multistart_options = _fill_multistart_options_with_defaults( options=multistart_options, params=params, diff --git a/src/estimagic/optimization/subsolvers/_conjugate_gradient.py b/src/estimagic/optimization/subsolvers/_conjugate_gradient.py index e9e2cc942..7f07cd57f 100644 --- a/src/estimagic/optimization/subsolvers/_conjugate_gradient.py +++ b/src/estimagic/optimization/subsolvers/_conjugate_gradient.py @@ -38,7 +38,6 @@ def minimize_trust_cg( stop_tol = max(gtol_abs, gtol_rel * gradient_norm) for _ in range(max_iter): - if gradient_norm <= stop_tol: break diff --git a/src/estimagic/optimization/subsolvers/_conjugate_gradient_fast.py b/src/estimagic/optimization/subsolvers/_conjugate_gradient_fast.py index cc88c3e0f..6e46215bb 100644 --- a/src/estimagic/optimization/subsolvers/_conjugate_gradient_fast.py +++ b/src/estimagic/optimization/subsolvers/_conjugate_gradient_fast.py @@ -40,7 +40,6 @@ def minimize_trust_cg_fast( stop_tol = max(gtol_abs, gtol_rel * gradient_norm) for _ in range(max_iter): - if gradient_norm <= stop_tol: break diff --git a/src/estimagic/optimization/subsolvers/_trsbox_fast.py b/src/estimagic/optimization/subsolvers/_trsbox_fast.py index c3822e5d7..c5cf22533 100644 --- a/src/estimagic/optimization/subsolvers/_trsbox_fast.py +++ b/src/estimagic/optimization/subsolvers/_trsbox_fast.py @@ -99,7 +99,6 @@ def minimize_trust_trsbox_fast( gradient_sumsq * np.array([delta_sq]) <= 1.0e-6 * total_reduction**2 and gradient_sumsq * np.array([delta_sq]) <= 1.0e-18 ): - need_alt_trust_step = False break diff --git a/src/estimagic/optimization/subsolvers/bntr_fast.py b/src/estimagic/optimization/subsolvers/bntr_fast.py index 5ec1bf47f..cf93900d8 100644 --- a/src/estimagic/optimization/subsolvers/bntr_fast.py +++ b/src/estimagic/optimization/subsolvers/bntr_fast.py @@ -1104,7 +1104,6 @@ def _update_trustregion_radius_and_gradient_descent( @njit def _get_fischer_burmeister_direction_vector(x, gradient, lower_bounds, upper_bounds): """Compute the constrained direction vector via the Fischer-Burmeister function.""" - direction = np.zeros(len(x)) for i, (x_, g_, l_, u_) in enumerate(zip(x, gradient, lower_bounds, upper_bounds)): fischer_scalar = _get_fischer_burmeister_scalar(u_ - x_, -g_) diff --git a/src/estimagic/optimization/subsolvers/gqtpar.py b/src/estimagic/optimization/subsolvers/gqtpar.py index 080774934..170040c24 100644 --- a/src/estimagic/optimization/subsolvers/gqtpar.py +++ b/src/estimagic/optimization/subsolvers/gqtpar.py @@ -90,7 +90,6 @@ def gqtpar(model, *, k_easy=0.1, k_hard=0.2, maxiter=200): converged = False for _niter in range(maxiter): - if hessian_info.already_factorized: hessian_info = hessian_info._replace(already_factorized=False) else: @@ -386,7 +385,6 @@ def _get_new_lambda_candidate(lower_bound, upper_bound): float: New candidate for the damping factor lambda. """ - lambda_new_candidate = max( np.sqrt(np.clip(lower_bound * upper_bound, 0, np.inf)), lower_bound + 0.01 * (upper_bound - lower_bound), diff --git a/src/estimagic/optimization/subsolvers/gqtpar_fast.py b/src/estimagic/optimization/subsolvers/gqtpar_fast.py index 287173031..a7b96f9ad 100644 --- a/src/estimagic/optimization/subsolvers/gqtpar_fast.py +++ b/src/estimagic/optimization/subsolvers/gqtpar_fast.py @@ -79,7 +79,6 @@ def gqtpar_fast(model, *, k_easy=0.1, k_hard=0.2, maxiter=200): converged = False for _niter in range(maxiter): - if hessian_already_factorized: hessian_already_factorized = False else: @@ -227,7 +226,6 @@ def _add_lambda_and_factorize_hessian(model_hessian, lambda_candidate): factorization_info (int): success flag returned by scipy.dpotrf """ - hessian_plus_lambda = model_hessian + lambda_candidate * _identity( model_hessian.shape[0] ) @@ -404,7 +402,6 @@ def _compute_gershgorin_bounds(model_hessian): upper_gershgorin (float): Upper Gregoshgorin bound. """ - hessian_diag = np.diag(model_hessian) hessian_diag_abs = np.abs(hessian_diag) hessian_row_sums = np.sum(np.abs(model_hessian), axis=1) diff --git a/src/estimagic/optimization/tiktak.py b/src/estimagic/optimization/tiktak.py index 143d9e6de..97a442deb 100644 --- a/src/estimagic/optimization/tiktak.py +++ b/src/estimagic/optimization/tiktak.py @@ -2,11 +2,23 @@ TikTak (`Arnoud, Guvenen, and Kleineberg `_) + + + + + + + + + + + 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 `_) +( +`GitHub Repository `_) """ import warnings @@ -151,7 +163,6 @@ def run_multistart_optimization( opt_counter = 0 for batch in batched_sample: - weight = weight_func(opt_counter, n_optimizations) starts = [weight * state["best_x"] + (1 - weight) * x for x in batch] diff --git a/src/estimagic/optimization/tranquilo/poisedness.py b/src/estimagic/optimization/tranquilo/poisedness.py index 04c33fce9..1359e0ddc 100644 --- a/src/estimagic/optimization/tranquilo/poisedness.py +++ b/src/estimagic/optimization/tranquilo/poisedness.py @@ -55,7 +55,6 @@ def get_poisedness_constant(sample, shape="sphere"): idx_max = None for idx, poly in enumerate(lagrange_mat): - intercept = poly[0] linear_terms = poly[1 : n_params + 1] _coef_square_terms = poly[n_params + 1 :] @@ -109,7 +108,6 @@ def improve_poisedness(sample, shape="sphere", maxiter=5): lambdas = [] for _ in range(maxiter): - lambda_, argmax, idx_max = get_poisedness_constant( sample=sample_improved, shape=shape ) @@ -189,7 +187,6 @@ def _reshape_coef_to_square_terms(coef, n_params): def _get_minimize_options(shape, n_params): """Get the minimizer options.""" - if shape == "sphere": nonlinear_constraint = NonlinearConstraint(lambda x: np.linalg.norm(x), 0, 1) options = {"method": "trust-constr", "constraints": [nonlinear_constraint]} diff --git a/src/estimagic/optimization/tranquilo/sample_points.py b/src/estimagic/optimization/tranquilo/sample_points.py index 481e3b80c..aaebde26b 100644 --- a/src/estimagic/optimization/tranquilo/sample_points.py +++ b/src/estimagic/optimization/tranquilo/sample_points.py @@ -300,7 +300,6 @@ def _optimal_hull_sampler( if existing_xs_unit is None and n_points == 1: opt_params = x0 else: - criterion_kwargs = { "existing_xs": existing_xs_unit, "order": order, diff --git a/src/estimagic/parameters/block_trees.py b/src/estimagic/parameters/block_trees.py index 37756a8cd..09ba8d985 100644 --- a/src/estimagic/parameters/block_trees.py +++ b/src/estimagic/parameters/block_trees.py @@ -207,7 +207,6 @@ def block_tree_to_hessian(block_hessian, f_tree, params_tree): inner_matrices = [] for outer_block_dim, list_inner_blocks in zip(size_f, outer_blocks): - block_rows_raw = [ list_inner_blocks[n_blocks_p * i : n_blocks_p * (i + 1)] for i in range(n_blocks_p) diff --git a/src/estimagic/parameters/nonlinear_constraints.py b/src/estimagic/parameters/nonlinear_constraints.py index 6b0d2f7a4..5b4f3d1fe 100644 --- a/src/estimagic/parameters/nonlinear_constraints.py +++ b/src/estimagic/parameters/nonlinear_constraints.py @@ -45,13 +45,11 @@ def process_nonlinear_constraints( # do checks first to fail fast constraint_evals = [] for _constraint in nonlinear_constraints: - _eval = _check_validity_and_return_evaluation(_constraint, params, skip_checks) constraint_evals.append(_eval) processed = [] for _constraint, _eval in zip(nonlinear_constraints, constraint_evals): - _processed_constraint = _process_nonlinear_constraint( _constraint, constraint_eval=_eval, @@ -137,7 +135,6 @@ def _internal_jacobian(x): _type = "eq" if "value" in c else "ineq" if _type == "eq": - # ============================================================================== # Equality constraints # @@ -156,7 +153,6 @@ def internal_constraint_func(x): n_constr = _n_constr else: - # ============================================================================== # Inequality constraints # @@ -493,7 +489,6 @@ def _check_validity_and_return_evaluation(c, params, skip_checks): constraint_eval = None if not skip_checks: - selector = _process_selector(c) try: diff --git a/src/estimagic/parameters/parameter_bounds.py b/src/estimagic/parameters/parameter_bounds.py index 999627066..b43548c5a 100644 --- a/src/estimagic/parameters/parameter_bounds.py +++ b/src/estimagic/parameters/parameter_bounds.py @@ -93,7 +93,6 @@ def _update_bounds_and_flatten(nan_tree, bounds, direction): flat_nan_tree = tree_leaves(nan_tree, registry=registry) if bounds is not None: - registry = get_registry(extended=True) flat_bounds = tree_leaves(bounds, registry=registry) @@ -105,7 +104,6 @@ def _update_bounds_and_flatten(nan_tree, bounds, direction): invalid = {"names": [], "bounds": []} for bounds_name, bounds_leaf in zip(bounds_names, flat_bounds): - # if a bounds leaf is None we treat it as saying the the corresponding # subtree of params has no bounds. if bounds_leaf is not None: diff --git a/src/estimagic/parameters/process_constraints.py b/src/estimagic/parameters/process_constraints.py index 61d5e7ea6..9d4284df0 100644 --- a/src/estimagic/parameters/process_constraints.py +++ b/src/estimagic/parameters/process_constraints.py @@ -153,7 +153,6 @@ def _process_linear_weights(constraints): processed = [] for constr in constraints: if constr["type"] == "linear": - raw_weights = constr["weights"] if isinstance(raw_weights, (np.ndarray, list, tuple, pd.Series)): diff --git a/src/estimagic/parameters/process_selectors.py b/src/estimagic/parameters/process_selectors.py index 594e1ba90..ee5c296be 100644 --- a/src/estimagic/parameters/process_selectors.py +++ b/src/estimagic/parameters/process_selectors.py @@ -96,7 +96,6 @@ def process_selectors(constraints, params, tree_converter, param_names): def _get_selection_field(constraint, selector_case, params_case): """Get the relevant selection field of a constraint.""" - selector_case = _get_selector_case(constraint) valid = { diff --git a/src/estimagic/process_user_function.py b/src/estimagic/process_user_function.py index 652dcbc15..a511b0df8 100644 --- a/src/estimagic/process_user_function.py +++ b/src/estimagic/process_user_function.py @@ -29,7 +29,6 @@ def process_func_of_params(func, kwargs, name="your function", skip_checks=False out = partial(func, **kept) if not skip_checks: - unpartialled_args = get_unpartialled_arguments(out) no_default_args = get_arguments_without_default(out) diff --git a/src/estimagic/shared/check_option_dicts.py b/src/estimagic/shared/check_option_dicts.py index 43cd45976..97b59b724 100644 --- a/src/estimagic/shared/check_option_dicts.py +++ b/src/estimagic/shared/check_option_dicts.py @@ -3,7 +3,6 @@ def check_optimization_options(options, usage, algorithm_mandatory=True): """Check optimize_options or maximize_options for usage in estimation functions.""" - options = {} if options is None else options if algorithm_mandatory: @@ -49,7 +48,6 @@ def check_optimization_options(options, usage, algorithm_mandatory=True): def check_numdiff_options(numdiff_options, usage): """Check numdiff_options for usage in estimation and optimization functions.""" - numdiff_options = {} if numdiff_options is None else numdiff_options internal_options = { diff --git a/src/estimagic/visualization/convergence_plot.py b/src/estimagic/visualization/convergence_plot.py index 17fcbcc57..0907be62d 100644 --- a/src/estimagic/visualization/convergence_plot.py +++ b/src/estimagic/visualization/convergence_plot.py @@ -148,12 +148,10 @@ def convergence_plot( # creating data traces for plotting faceted/individual plots # dropping usage of palette for algoritms, but use the built in pallete for prob_name in remaining_problems: - g_ind = [] # container for data for traces in individual plot to_plot = df[df["problem"] == prob_name] for i, alg in enumerate(to_plot["algorithm"].unique()): - temp = to_plot[to_plot["algorithm"] == alg] trace_1 = go.Scatter( x=temp[runtime_measure], @@ -207,7 +205,6 @@ def convergence_plot( # Dictionary for individual plots else: - ind_dict = create_ind_dict( **common_dependencies, kws={"height": 320, "width": 500, "title_x": 0.5, **common_layout}, diff --git a/src/estimagic/visualization/derivative_plot.py b/src/estimagic/visualization/derivative_plot.py index c35fd7af0..d1e9274a2 100644 --- a/src/estimagic/visualization/derivative_plot.py +++ b/src/estimagic/visualization/derivative_plot.py @@ -76,7 +76,7 @@ def derivative_plot( g_list = [] # creating data traces for plotting faceted/individual plots - for (row, col) in itertools.product(dim_x, dim_f): + for row, col in itertools.product(dim_x, dim_f): g_ind = [] # container for data for traces in individual plot # initial values and x grid diff --git a/src/estimagic/visualization/estimation_table.py b/src/estimagic/visualization/estimation_table.py index 2e34ce804..8ced8ef48 100644 --- a/src/estimagic/visualization/estimation_table.py +++ b/src/estimagic/visualization/estimation_table.py @@ -597,7 +597,6 @@ def _build_estimation_table_body( number_format, add_trailing_zeros, ): - """Create body bloc significance stars and inference values. Applies number formatting to parameters. Concatinates inference values @@ -771,7 +770,6 @@ def _get_cols_to_format(show_inference, confidence_intervals): def _apply_number_formatting_frames(dfs, columns, number_format, add_trailing_zeros): """Apply string formatter to specific columns of a list of DataFrames.""" - raw_formatted = [_apply_number_format(df[columns], number_format) for df in dfs] max_trail = int(max([_get_digits_after_decimal(df) for df in raw_formatted])) if add_trailing_zeros: @@ -1046,7 +1044,6 @@ def _combine_series(value_sr, inference_sr): series: combined string series of param and inference values """ - value_df = value_sr.to_frame(name="") original_cols = value_df.columns value_df.reset_index(drop=False, inplace=True) diff --git a/src/estimagic/visualization/history_plots.py b/src/estimagic/visualization/history_plots.py index 63830018d..ac2b8ae45 100644 --- a/src/estimagic/visualization/history_plots.py +++ b/src/estimagic/visualization/history_plots.py @@ -82,7 +82,6 @@ def criterion_plot( data = [] for name, res in results.items(): - if isinstance(res, OptimizeResult): _data = _extract_plotting_data_from_results_object( res, stack_multistart, show_exploration, plot_name="criterion_plot" @@ -113,14 +112,12 @@ def criterion_plot( # Plot multistart paths if plot_multistart: - scatter_kws = { "connectgaps": True, "showlegend": False, } for i, local_history in enumerate(data[0]["local_histories"]): - history = get_history_arrays(local_history, data[0]["direction"])[key] if max_evaluations is not None and len(history) > max_evaluations: @@ -140,7 +137,6 @@ def criterion_plot( # Plot main optimization objects for _data in data: - if stack_multistart and _data["stacked_local_histories"] is not None: _history = _data["stacked_local_histories"] else: @@ -357,7 +353,6 @@ def _extract_plotting_data_from_database(res, stack_multistart, show_exploration are stacked into a single one. """ - reader = OptimizeLogReader(res) _problem_table = read_optimization_problem_table(res) diff --git a/src/estimagic/visualization/plotting_utilities.py b/src/estimagic/visualization/plotting_utilities.py index 3014d9c0f..de6315f54 100644 --- a/src/estimagic/visualization/plotting_utilities.py +++ b/src/estimagic/visualization/plotting_utilities.py @@ -139,7 +139,6 @@ def create_grid_plot( x_min=None, x_max=None, ): - """Create a dictionary for a grid plot from a list of traces. Args: diff --git a/tests/estimation/test_estimate_ml.py b/tests/estimation/test_estimate_ml.py index d908ebfd3..b576eb92a 100644 --- a/tests/estimation/test_estimate_ml.py +++ b/tests/estimation/test_estimate_ml.py @@ -197,7 +197,6 @@ def test_estimate_ml_with_logit_no_constraints( aaae(got.params, exp.params, decimal=4) for method in methods: - # compare estimated standard errors exp_se = getattr(exp, f"bse{statsmodels_suffix_map[method]}") got_se = got.se(method=method) @@ -300,7 +299,6 @@ def test_estimate_ml_with_logit_constraints( aaae(got.params, exp.params, decimal=3) for method in methods: - # compare estimated standard errors exp_se = getattr(exp, f"bse{statsmodels_suffix_map[method]}") got_se = got.se(method=method, seed=seed) @@ -329,7 +327,6 @@ def test_estimate_ml_with_logit_constraints( def test_estimate_ml_optimize_options_false(fitted_logit_model, logit_np_inputs): """Test that estimate_ml computes correct covariances given correct params.""" - kwargs = {"y": logit_np_inputs["y"], "x": logit_np_inputs["x"]} params = pd.DataFrame({"value": fitted_logit_model.params}) diff --git a/tests/optimization/test_with_constraints.py b/tests/optimization/test_with_constraints.py index 59033876e..956bc94b8 100644 --- a/tests/optimization/test_with_constraints.py +++ b/tests/optimization/test_with_constraints.py @@ -134,7 +134,6 @@ def test_constrained_minimization( criterion_name, algorithm, derivative, constraint_name, params_type ): - constraints = CONSTR_INFO[constraint_name] criterion = FUNC_INFO[criterion_name]["criterion"] if params_type == "pandas": diff --git a/tests/optimization/test_with_nonlinear_constraints.py b/tests/optimization/test_with_nonlinear_constraints.py index 4be633cbe..9aabfc233 100644 --- a/tests/optimization/test_with_nonlinear_constraints.py +++ b/tests/optimization/test_with_nonlinear_constraints.py @@ -94,12 +94,12 @@ def constraint_jac(x): } kwargs = { - "flat": {**_kwargs, **{"constraints": constraints_flat}}, - "long": {**_kwargs, **{"constraints": constraints_long}}, - "equality": {**_kwargs, **{"constraints": constraints_equality}}, + "flat": {**_kwargs, "constraints": constraints_flat}, + "long": {**_kwargs, "constraints": constraints_long}, + "equality": {**_kwargs, "constraints": constraints_equality}, "equality_and_inequality": { **_kwargs, - **{"constraints": constraints_equality_and_inequality}, + "constraints": constraints_equality_and_inequality, }, } diff --git a/tests/optimization/tranquilo/test_poisedness.py b/tests/optimization/tranquilo/test_poisedness.py index a078437f7..2a846d0a2 100644 --- a/tests/optimization/tranquilo/test_poisedness.py +++ b/tests/optimization/tranquilo/test_poisedness.py @@ -196,7 +196,6 @@ def test_poisedness_constant_scaled(sample, expected): 99. """ - got, *_ = get_poisedness_constant(sample, shape="sphere") assert np.allclose(got, expected) @@ -251,7 +250,6 @@ def test_poisedness_constant_textbook_scaled(sample, expected): 99. """ - got, *_ = get_poisedness_constant(sample, shape="sphere") assert np.allclose(got, expected, rtol=1e-3) diff --git a/tests/sensitivity/test_msm_sensitivity.py b/tests/sensitivity/test_msm_sensitivity.py index e0657250a..b41831a93 100644 --- a/tests/sensitivity/test_msm_sensitivity.py +++ b/tests/sensitivity/test_msm_sensitivity.py @@ -18,7 +18,6 @@ def simulate_aggregated_moments(params, x, y): """Calculate aggregated moments for example from Honore, DePaula, Jorgensen.""" - mom_value = simulate_moment_contributions(params, x, y) moments = mom_value.mean(axis=1) @@ -27,7 +26,6 @@ def simulate_aggregated_moments(params, x, y): def simulate_moment_contributions(params, x, y): """Calculate moment contributions for example from Honore, DePaula, Jorgensen.""" - y_estimated = x.to_numpy() @ (params["value"].to_numpy()) x_np = x.T.to_numpy() @@ -156,7 +154,6 @@ def test_actual_sensitivity_to_noise(jac, weights, moments_cov, params_cov_opt, def test_actual_sensitivity_to_removal( jac, weights, moments_cov, params_cov_opt, params ): - calculated = calculate_actual_sensitivity_to_removal( jac, weights, moments_cov, params_cov_opt ) diff --git a/tests/sensitivity/test_msm_sensitivity_via_estimate_msm.py b/tests/sensitivity/test_msm_sensitivity_via_estimate_msm.py index 8d63a3eab..bc6bc17db 100644 --- a/tests/sensitivity/test_msm_sensitivity_via_estimate_msm.py +++ b/tests/sensitivity/test_msm_sensitivity_via_estimate_msm.py @@ -9,7 +9,6 @@ def simulate_aggregated_moments(params, x, y): """Calculate aggregated moments for example from Honore, DePaula, Jorgensen.""" - mom_value = simulate_moment_contributions(params, x, y) moments = mom_value.mean(axis=1) @@ -18,7 +17,6 @@ def simulate_aggregated_moments(params, x, y): def simulate_moment_contributions(params, x, y): """Calculate moment contributions for example from Honore, DePaula, Jorgensen.""" - y_estimated = x.to_numpy() @ (params["value"].to_numpy()) x_np = x.T.to_numpy() diff --git a/tests/visualization/test_history_plots.py b/tests/visualization/test_history_plots.py index d527534bb..2472cdfd7 100644 --- a/tests/visualization/test_history_plots.py +++ b/tests/visualization/test_history_plots.py @@ -73,7 +73,6 @@ def test_params_plot_multistart( def test_criterion_plot_list_input( minimize_result, multistart, monotone, stack_multistart, exploration ): - res = minimize_result[multistart] criterion_plot(