From e3fc71104088d312db0c2a1e72efc0f6cda76870 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:46:18 +0200 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#529) --- .pre-commit-config.yaml | 6 +-- .../bootstrap_montecarlo_comparison.ipynb | 5 +- .../tutorials/bootstrap_overview.ipynb | 5 +- .../estimation_tables_overview.ipynb | 7 +-- .../tutorials/likelihood_overview.ipynb | 3 +- .../estimagic/tutorials/msm_overview.ipynb | 3 +- .../why_optimization_is_hard.ipynb | 5 +- .../how_to/how_to_algorithm_selection.ipynb | 1 + docs/source/how_to/how_to_bounds.ipynb | 1 + .../how_to/how_to_criterion_function.ipynb | 1 + docs/source/how_to/how_to_derivatives.ipynb | 1 + .../how_to_errors_during_optimization.ipynb | 3 +- docs/source/how_to/how_to_logging.ipynb | 1 + docs/source/how_to/how_to_multistart.ipynb | 1 + docs/source/how_to/how_to_slice_plot.ipynb | 1 + .../how_to/how_to_visualize_histories.ipynb | 1 + docs/source/tutorials/numdiff_overview.ipynb | 5 +- .../tutorials/optimization_overview.ipynb | 5 +- src/estimagic/__init__.py | 23 +++++----- src/estimagic/bootstrap.py | 8 ++-- src/estimagic/bootstrap_outcomes.py | 3 +- src/estimagic/estimate_ml.py | 40 ++++++++-------- src/estimagic/estimate_msm.py | 46 +++++++++---------- src/estimagic/estimation_table.py | 4 +- src/estimagic/examples/logit.py | 1 + src/estimagic/lollipop_plot.py | 1 + src/estimagic/ml_covs.py | 4 +- src/estimagic/msm_covs.py | 4 +- src/estimagic/msm_sensitivity.py | 4 +- src/estimagic/msm_weighting.py | 6 +-- src/estimagic/shared_covs.py | 3 +- tests/estimagic/examples/test_logit.py | 3 +- tests/estimagic/test_bootstrap.py | 1 + tests/estimagic/test_bootstrap_ci.py | 3 +- tests/estimagic/test_bootstrap_outcomes.py | 3 +- tests/estimagic/test_bootstrap_samples.py | 5 +- tests/estimagic/test_estimate_ml.py | 9 ++-- tests/estimagic/test_estimate_msm.py | 3 +- ...st_estimate_msm_dict_params_and_moments.py | 5 +- tests/estimagic/test_estimation_table.py | 5 +- tests/estimagic/test_lollipop_plot.py | 1 + tests/estimagic/test_ml_covs.py | 3 +- tests/estimagic/test_msm_covs.py | 5 +- tests/estimagic/test_msm_sensitivity.py | 5 +- .../test_msm_sensitivity_via_estimate_msm.py | 5 +- tests/estimagic/test_msm_weighting.py | 3 +- tests/estimagic/test_shared.py | 5 +- .../benchmarking/test_benchmark_reports.py | 1 + .../benchmarking/test_cartis_roberts.py | 1 + .../test_get_benchmark_problems.py | 1 + .../optimagic/benchmarking/test_more_wild.py | 1 + .../benchmarking/test_noise_distributions.py | 1 + .../benchmarking/test_run_benchmark.py | 1 + .../test_compare_derivatives_with_jax.py | 3 +- .../differentiation/test_derivatives.py | 5 +- .../test_finite_differences.py | 1 + .../differentiation/test_generate_steps.py | 1 + .../differentiation/test_numdiff_options.py | 1 + .../examples/test_criterion_functions.py | 3 +- tests/optimagic/logging/test_base.py | 1 + tests/optimagic/logging/test_logger.py | 3 +- tests/optimagic/logging/test_sqlalchemy.py | 3 +- tests/optimagic/logging/test_types.py | 1 + .../optimagic/optimization/test_algorithm.py | 1 + .../optimization/test_convergence_report.py | 1 + .../test_create_optimization_problem.py | 1 + .../optimization/test_error_penalty.py | 1 + .../optimagic/optimization/test_fun_value.py | 1 + .../optimization/test_function_formats_ls.py | 1 + .../test_function_formats_scalar.py | 1 + tests/optimagic/optimization/test_history.py | 1 + .../optimization/test_history_collection.py | 1 + .../optimization/test_history_tools.py | 1 + .../test_internal_optimization_problem.py | 1 + .../optimization/test_jax_derivatives.py | 1 + .../optimization/test_many_algorithms.py | 1 + .../optimagic/optimization/test_multistart.py | 1 + .../optimization/test_multistart_options.py | 1 + tests/optimagic/optimization/test_optimize.py | 1 + .../optimization/test_optimize_result.py | 1 + .../optimization/test_params_versions.py | 3 +- .../optimization/test_pygmo_optimizers.py | 1 + .../optimization/test_scipy_aliases.py | 3 +- .../optimization/test_useful_exceptions.py | 1 + .../test_with_advanced_constraints.py | 3 +- .../optimization/test_with_bounds.py | 3 +- .../optimization/test_with_constraints.py | 3 +- .../optimization/test_with_logging.py | 3 +- .../optimization/test_with_multistart.py | 3 +- .../test_with_nonlinear_constraints.py | 3 +- .../optimization/test_with_scaling.py | 3 +- .../_pounders/test_linear_subsolvers.py | 1 + .../_pounders/test_pounders_history.py | 1 + .../_pounders/test_pounders_unit.py | 1 + .../_pounders/test_quadratic_subsolvers.py | 1 + tests/optimagic/optimizers/test_bhhh.py | 3 +- .../optimizers/test_fides_options.py | 2 + .../optimizers/test_ipopt_options.py | 1 + .../optimizers/test_nag_optimizers.py | 1 + tests/optimagic/optimizers/test_neldermead.py | 1 + .../optimizers/test_pounders_integration.py | 2 +- .../optimizers/test_tao_optimizers.py | 1 + .../optimagic/parameters/test_block_trees.py | 5 +- tests/optimagic/parameters/test_bounds.py | 1 + .../parameters/test_check_constraints.py | 3 +- .../parameters/test_constraint_tools.py | 3 +- tests/optimagic/parameters/test_conversion.py | 1 + .../parameters/test_kernel_transformations.py | 3 +- .../parameters/test_nonlinear_constraints.py | 5 +- .../parameters/test_process_constraints.py | 3 +- .../parameters/test_process_selectors.py | 3 +- .../parameters/test_scale_conversion.py | 1 + tests/optimagic/parameters/test_scaling.py | 1 + .../parameters/test_space_conversion.py | 1 + .../parameters/test_tree_conversion.py | 1 + .../parameters/test_tree_registry.py | 3 +- .../shared/test_process_user_functions.py | 1 + tests/optimagic/test_batch_evaluators.py | 1 + tests/optimagic/test_constraints.py | 1 + tests/optimagic/test_decorators.py | 1 + tests/optimagic/test_deprecations.py | 7 +-- tests/optimagic/test_mark.py | 3 +- tests/optimagic/test_type_conversion.py | 1 + tests/optimagic/test_utilities.py | 1 + .../visualization/test_convergence_plot.py | 1 + .../visualization/test_deviation_plot.py | 1 + .../visualization/test_history_plots.py | 3 +- .../visualization/test_profile_plot.py | 1 + .../visualization/test_slice_plot.py | 1 + 129 files changed, 264 insertions(+), 148 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b22b11601..1fdef3c43 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.16.0 + rev: 1.17.0 hooks: - id: yamlfix exclude: tests/optimagic/optimizers/_pounders/fixtures @@ -68,7 +68,7 @@ repos: - --blank exclude: src/optimagic/optimization/algo_options.py - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.6.3 hooks: # Run the linter. - id: ruff @@ -119,7 +119,7 @@ repos: args: - --drop-empty-cells - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy files: src|tests diff --git a/docs/source/estimagic/explanation/bootstrap_montecarlo_comparison.ipynb b/docs/source/estimagic/explanation/bootstrap_montecarlo_comparison.ipynb index 8162fc476..7cd6f36b2 100644 --- a/docs/source/estimagic/explanation/bootstrap_montecarlo_comparison.ipynb +++ b/docs/source/estimagic/explanation/bootstrap_montecarlo_comparison.ipynb @@ -42,13 +42,14 @@ "metadata": {}, "outputs": [], "source": [ - "import estimagic as em\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import scipy\n", "import statsmodels.api as sm\n", - "from joblib import Parallel, delayed" + "from joblib import Parallel, delayed\n", + "\n", + "import estimagic as em" ] }, { diff --git a/docs/source/estimagic/tutorials/bootstrap_overview.ipynb b/docs/source/estimagic/tutorials/bootstrap_overview.ipynb index 7d5121f41..ed669c4b1 100644 --- a/docs/source/estimagic/tutorials/bootstrap_overview.ipynb +++ b/docs/source/estimagic/tutorials/bootstrap_overview.ipynb @@ -19,11 +19,12 @@ "metadata": {}, "outputs": [], "source": [ - "import estimagic as em\n", "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns\n", - "import statsmodels.api as sm" + "import statsmodels.api as sm\n", + "\n", + "import estimagic as em" ] }, { diff --git a/docs/source/estimagic/tutorials/estimation_tables_overview.ipynb b/docs/source/estimagic/tutorials/estimation_tables_overview.ipynb index 632fd9c29..f3a99aec6 100644 --- a/docs/source/estimagic/tutorials/estimation_tables_overview.ipynb +++ b/docs/source/estimagic/tutorials/estimation_tables_overview.ipynb @@ -24,11 +24,12 @@ "outputs": [], "source": [ "# Make necessary imports\n", - "import estimagic as em\n", "import pandas as pd\n", "import statsmodels.formula.api as sm\n", - "from estimagic.config import EXAMPLE_DIR\n", - "from IPython.core.display import HTML" + "from IPython.core.display import HTML\n", + "\n", + "import estimagic as em\n", + "from estimagic.config import EXAMPLE_DIR" ] }, { diff --git a/docs/source/estimagic/tutorials/likelihood_overview.ipynb b/docs/source/estimagic/tutorials/likelihood_overview.ipynb index 46820fe1b..958e02f2e 100644 --- a/docs/source/estimagic/tutorials/likelihood_overview.ipynb +++ b/docs/source/estimagic/tutorials/likelihood_overview.ipynb @@ -34,11 +34,12 @@ "metadata": {}, "outputs": [], "source": [ - "import estimagic as em\n", "import numpy as np\n", "import pandas as pd\n", "from scipy.stats import norm\n", "\n", + "import estimagic as em\n", + "\n", "rng = np.random.default_rng(seed=0)" ] }, diff --git a/docs/source/estimagic/tutorials/msm_overview.ipynb b/docs/source/estimagic/tutorials/msm_overview.ipynb index 0687884f9..e2c0fc104 100644 --- a/docs/source/estimagic/tutorials/msm_overview.ipynb +++ b/docs/source/estimagic/tutorials/msm_overview.ipynb @@ -42,10 +42,11 @@ "metadata": {}, "outputs": [], "source": [ - "import estimagic as em\n", "import numpy as np\n", "import pandas as pd\n", "\n", + "import estimagic as em\n", + "\n", "rng = np.random.default_rng(seed=0)" ] }, diff --git a/docs/source/explanation/why_optimization_is_hard.ipynb b/docs/source/explanation/why_optimization_is_hard.ipynb index caf6a8519..57bc18b25 100644 --- a/docs/source/explanation/why_optimization_is_hard.ipynb +++ b/docs/source/explanation/why_optimization_is_hard.ipynb @@ -28,8 +28,9 @@ "outputs": [], "source": [ "import numpy as np\n", - "import optimagic as om\n", - "import seaborn as sns" + "import seaborn as sns\n", + "\n", + "import optimagic as om" ] }, { diff --git a/docs/source/how_to/how_to_algorithm_selection.ipynb b/docs/source/how_to/how_to_algorithm_selection.ipynb index b91a7e8f3..1620e7225 100644 --- a/docs/source/how_to/how_to_algorithm_selection.ipynb +++ b/docs/source/how_to/how_to_algorithm_selection.ipynb @@ -34,6 +34,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om" ] }, diff --git a/docs/source/how_to/how_to_bounds.ipynb b/docs/source/how_to/how_to_bounds.ipynb index f5dcae403..b87a15be2 100644 --- a/docs/source/how_to/how_to_bounds.ipynb +++ b/docs/source/how_to/how_to_bounds.ipynb @@ -32,6 +32,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om" ] }, diff --git a/docs/source/how_to/how_to_criterion_function.ipynb b/docs/source/how_to/how_to_criterion_function.ipynb index 98afbf877..8d99020e0 100644 --- a/docs/source/how_to/how_to_criterion_function.ipynb +++ b/docs/source/how_to/how_to_criterion_function.ipynb @@ -25,6 +25,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om\n", "\n", "\n", diff --git a/docs/source/how_to/how_to_derivatives.ipynb b/docs/source/how_to/how_to_derivatives.ipynb index 6e079f508..0dda5e7fd 100644 --- a/docs/source/how_to/how_to_derivatives.ipynb +++ b/docs/source/how_to/how_to_derivatives.ipynb @@ -38,6 +38,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om\n", "\n", "\n", diff --git a/docs/source/how_to/how_to_errors_during_optimization.ipynb b/docs/source/how_to/how_to_errors_during_optimization.ipynb index 647000a95..8a69f85c3 100644 --- a/docs/source/how_to/how_to_errors_during_optimization.ipynb +++ b/docs/source/how_to/how_to_errors_during_optimization.ipynb @@ -49,9 +49,10 @@ "import warnings\n", "\n", "import numpy as np\n", - "import optimagic as om\n", "from scipy.optimize import minimize as scipy_minimize\n", "\n", + "import optimagic as om\n", + "\n", "warnings.simplefilter(\"ignore\")" ] }, diff --git a/docs/source/how_to/how_to_logging.ipynb b/docs/source/how_to/how_to_logging.ipynb index c957341d9..dea47d11f 100644 --- a/docs/source/how_to/how_to_logging.ipynb +++ b/docs/source/how_to/how_to_logging.ipynb @@ -30,6 +30,7 @@ "from pathlib import Path\n", "\n", "import numpy as np\n", + "\n", "import optimagic as om" ] }, diff --git a/docs/source/how_to/how_to_multistart.ipynb b/docs/source/how_to/how_to_multistart.ipynb index a4506d4ac..6c1589967 100644 --- a/docs/source/how_to/how_to_multistart.ipynb +++ b/docs/source/how_to/how_to_multistart.ipynb @@ -36,6 +36,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om\n", "\n", "\n", diff --git a/docs/source/how_to/how_to_slice_plot.ipynb b/docs/source/how_to/how_to_slice_plot.ipynb index bd4d0e9f6..b30de384a 100644 --- a/docs/source/how_to/how_to_slice_plot.ipynb +++ b/docs/source/how_to/how_to_slice_plot.ipynb @@ -31,6 +31,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om" ] }, diff --git a/docs/source/how_to/how_to_visualize_histories.ipynb b/docs/source/how_to/how_to_visualize_histories.ipynb index 37b3e43a1..b9da50889 100644 --- a/docs/source/how_to/how_to_visualize_histories.ipynb +++ b/docs/source/how_to/how_to_visualize_histories.ipynb @@ -23,6 +23,7 @@ "outputs": [], "source": [ "import numpy as np\n", + "\n", "import optimagic as om" ] }, diff --git a/docs/source/tutorials/numdiff_overview.ipynb b/docs/source/tutorials/numdiff_overview.ipynb index 5068523a7..b9c3b24bb 100644 --- a/docs/source/tutorials/numdiff_overview.ipynb +++ b/docs/source/tutorials/numdiff_overview.ipynb @@ -17,8 +17,9 @@ "outputs": [], "source": [ "import numpy as np\n", - "import optimagic as om\n", - "import pandas as pd" + "import pandas as pd\n", + "\n", + "import optimagic as om" ] }, { diff --git a/docs/source/tutorials/optimization_overview.ipynb b/docs/source/tutorials/optimization_overview.ipynb index 31e6b46b4..691c89a19 100644 --- a/docs/source/tutorials/optimization_overview.ipynb +++ b/docs/source/tutorials/optimization_overview.ipynb @@ -16,8 +16,9 @@ "outputs": [], "source": [ "import numpy as np\n", - "import optimagic as om\n", - "import pandas as pd" + "import pandas as pd\n", + "\n", + "import optimagic as om" ] }, { diff --git a/src/estimagic/__init__.py b/src/estimagic/__init__.py index e3fa3e908..44a640486 100644 --- a/src/estimagic/__init__.py +++ b/src/estimagic/__init__.py @@ -1,6 +1,17 @@ import warnings from dataclasses import dataclass +from estimagic import utilities +from estimagic.bootstrap import BootstrapResult, bootstrap +from estimagic.estimate_ml import LikelihoodResult, estimate_ml +from estimagic.estimate_msm import MomentsResult, estimate_msm +from estimagic.estimation_table import ( + estimation_table, + render_html, + render_latex, +) +from estimagic.lollipop_plot import lollipop_plot +from estimagic.msm_weighting import get_moments_cov from optimagic import OptimizeLogReader as _OptimizeLogReader from optimagic import OptimizeResult as _OptimizeResult from optimagic import __version__ @@ -22,18 +33,6 @@ from optimagic import traceback_report as _traceback_report from optimagic.decorators import deprecated -from estimagic import utilities -from estimagic.bootstrap import BootstrapResult, bootstrap -from estimagic.estimate_ml import LikelihoodResult, estimate_ml -from estimagic.estimate_msm import MomentsResult, estimate_msm -from estimagic.estimation_table import ( - estimation_table, - render_html, - render_latex, -) -from estimagic.lollipop_plot import lollipop_plot -from estimagic.msm_weighting import get_moments_cov - MSG = ( "estimagic.{name} has been deprecated in version 0.5.0. Use optimagic.{name} " "instead. This function will be removed in version 0.6.0." diff --git a/src/estimagic/bootstrap.py b/src/estimagic/bootstrap.py index 68dde6405..179b4e5cc 100644 --- a/src/estimagic/bootstrap.py +++ b/src/estimagic/bootstrap.py @@ -5,16 +5,16 @@ import numpy as np import pandas as pd -from optimagic.batch_evaluators import joblib_batch_evaluator -from optimagic.parameters.block_trees import matrix_to_block_tree -from optimagic.parameters.tree_registry import get_registry -from optimagic.utilities import get_rng from pybaum import leaf_names, tree_flatten, tree_just_flatten, tree_unflatten from estimagic.bootstrap_ci import calculate_ci from estimagic.bootstrap_helpers import check_inputs from estimagic.bootstrap_outcomes import get_bootstrap_outcomes from estimagic.shared_covs import calculate_estimation_summary +from optimagic.batch_evaluators import joblib_batch_evaluator +from optimagic.parameters.block_trees import matrix_to_block_tree +from optimagic.parameters.tree_registry import get_registry +from optimagic.utilities import get_rng def bootstrap( diff --git a/src/estimagic/bootstrap_outcomes.py b/src/estimagic/bootstrap_outcomes.py index f9caf1c7d..5ba5e6bea 100644 --- a/src/estimagic/bootstrap_outcomes.py +++ b/src/estimagic/bootstrap_outcomes.py @@ -1,7 +1,6 @@ -from optimagic.batch_evaluators import process_batch_evaluator - from estimagic.bootstrap_helpers import check_inputs from estimagic.bootstrap_samples import get_bootstrap_indices +from optimagic.batch_evaluators import process_batch_evaluator def get_bootstrap_outcomes( diff --git a/src/estimagic/estimate_ml.py b/src/estimagic/estimate_ml.py index 4199eeb85..39383c6a4 100644 --- a/src/estimagic/estimate_ml.py +++ b/src/estimagic/estimate_ml.py @@ -5,6 +5,26 @@ import numpy as np import pandas as pd + +from estimagic.ml_covs import ( + cov_cluster_robust, + cov_hessian, + cov_jacobian, + cov_robust, + cov_strata_robust, +) +from estimagic.shared_covs import ( + FreeParams, + calculate_ci, + calculate_estimation_summary, + calculate_free_estimates, + calculate_p_values, + calculate_summary_data_estimation, + get_derivative_case, + transform_covariance, + transform_free_cov_to_cov, + transform_free_values_to_params_tree, +) from optimagic import deprecations, mark from optimagic.deprecations import ( replace_and_warn_about_deprecated_bounds, @@ -32,26 +52,6 @@ from optimagic.typing import AggregationLevel from optimagic.utilities import get_rng, to_pickle -from estimagic.ml_covs import ( - cov_cluster_robust, - cov_hessian, - cov_jacobian, - cov_robust, - cov_strata_robust, -) -from estimagic.shared_covs import ( - FreeParams, - calculate_ci, - calculate_estimation_summary, - calculate_free_estimates, - calculate_p_values, - calculate_summary_data_estimation, - get_derivative_case, - transform_covariance, - transform_free_cov_to_cov, - transform_free_values_to_params_tree, -) - def estimate_ml( loglike, diff --git a/src/estimagic/estimate_msm.py b/src/estimagic/estimate_msm.py index 0ec6933b8..57430bb99 100644 --- a/src/estimagic/estimate_msm.py +++ b/src/estimagic/estimate_msm.py @@ -9,29 +9,6 @@ import numpy as np import pandas as pd -from optimagic import deprecations, mark -from optimagic.deprecations import ( - replace_and_warn_about_deprecated_bounds, -) -from optimagic.differentiation.derivatives import first_derivative -from optimagic.differentiation.numdiff_options import ( - NumdiffPurpose, - get_default_numdiff_options, - pre_process_numdiff_options, -) -from optimagic.exceptions import InvalidFunctionError -from optimagic.optimization.fun_value import LeastSquaresFunctionValue -from optimagic.optimization.optimize import minimize -from optimagic.optimization.optimize_result import OptimizeResult -from optimagic.parameters.block_trees import block_tree_to_matrix, matrix_to_block_tree -from optimagic.parameters.bounds import Bounds, pre_process_bounds -from optimagic.parameters.conversion import Converter, get_converter -from optimagic.parameters.space_conversion import InternalParams -from optimagic.parameters.tree_registry import get_registry -from optimagic.shared.check_option_dicts import ( - check_optimization_options, -) -from optimagic.utilities import get_rng, to_pickle from pybaum import leaf_names, tree_just_flatten from estimagic.msm_covs import cov_optimal, cov_robust @@ -56,6 +33,29 @@ transform_free_cov_to_cov, transform_free_values_to_params_tree, ) +from optimagic import deprecations, mark +from optimagic.deprecations import ( + replace_and_warn_about_deprecated_bounds, +) +from optimagic.differentiation.derivatives import first_derivative +from optimagic.differentiation.numdiff_options import ( + NumdiffPurpose, + get_default_numdiff_options, + pre_process_numdiff_options, +) +from optimagic.exceptions import InvalidFunctionError +from optimagic.optimization.fun_value import LeastSquaresFunctionValue +from optimagic.optimization.optimize import minimize +from optimagic.optimization.optimize_result import OptimizeResult +from optimagic.parameters.block_trees import block_tree_to_matrix, matrix_to_block_tree +from optimagic.parameters.bounds import Bounds, pre_process_bounds +from optimagic.parameters.conversion import Converter, get_converter +from optimagic.parameters.space_conversion import InternalParams +from optimagic.parameters.tree_registry import get_registry +from optimagic.shared.check_option_dicts import ( + check_optimization_options, +) +from optimagic.utilities import get_rng, to_pickle def estimate_msm( diff --git a/src/estimagic/estimation_table.py b/src/estimagic/estimation_table.py index 85d75199a..9c953007c 100644 --- a/src/estimagic/estimation_table.py +++ b/src/estimagic/estimation_table.py @@ -6,6 +6,7 @@ import numpy as np import pandas as pd + from optimagic.shared.compat import pd_df_map suppress_performance_warnings = np.testing.suppress_warnings() @@ -1473,8 +1474,7 @@ def _get_digits_after_decimal(df): ) except KeyError: trail_length = 0 - if trail_length > max_trail: - max_trail = trail_length + max_trail = max(trail_length, max_trail) return max_trail diff --git a/src/estimagic/examples/logit.py b/src/estimagic/examples/logit.py index 890bb9e7c..925356c5c 100644 --- a/src/estimagic/examples/logit.py +++ b/src/estimagic/examples/logit.py @@ -2,6 +2,7 @@ import numpy as np import pandas as pd + from optimagic import mark diff --git a/src/estimagic/lollipop_plot.py b/src/estimagic/lollipop_plot.py index beea44c0d..f787a0b31 100644 --- a/src/estimagic/lollipop_plot.py +++ b/src/estimagic/lollipop_plot.py @@ -2,6 +2,7 @@ import pandas as pd import plotly.graph_objects as go + from optimagic.config import PLOTLY_PALETTE, PLOTLY_TEMPLATE from optimagic.visualization.plotting_utilities import create_grid_plot, create_ind_dict diff --git a/src/estimagic/ml_covs.py b/src/estimagic/ml_covs.py index d61abafae..39e445501 100644 --- a/src/estimagic/ml_covs.py +++ b/src/estimagic/ml_covs.py @@ -2,10 +2,10 @@ import numpy as np import pandas as pd -from optimagic.exceptions import INVALID_INFERENCE_MSG -from optimagic.utilities import robust_inverse from estimagic.shared_covs import process_pandas_arguments +from optimagic.exceptions import INVALID_INFERENCE_MSG +from optimagic.utilities import robust_inverse def cov_hessian(hess): diff --git a/src/estimagic/msm_covs.py b/src/estimagic/msm_covs.py index 9e61d93c6..958bde683 100644 --- a/src/estimagic/msm_covs.py +++ b/src/estimagic/msm_covs.py @@ -1,8 +1,8 @@ import pandas as pd -from optimagic.exceptions import INVALID_INFERENCE_MSG -from optimagic.utilities import robust_inverse from estimagic.shared_covs import process_pandas_arguments +from optimagic.exceptions import INVALID_INFERENCE_MSG +from optimagic.utilities import robust_inverse def cov_robust(jac, weights, moments_cov): diff --git a/src/estimagic/msm_sensitivity.py b/src/estimagic/msm_sensitivity.py index 188c29847..e8147fc29 100644 --- a/src/estimagic/msm_sensitivity.py +++ b/src/estimagic/msm_sensitivity.py @@ -10,11 +10,11 @@ import numpy as np import pandas as pd -from optimagic.exceptions import INVALID_SENSITIVITY_MSG -from optimagic.utilities import robust_inverse from estimagic.msm_covs import cov_robust from estimagic.shared_covs import process_pandas_arguments +from optimagic.exceptions import INVALID_SENSITIVITY_MSG +from optimagic.utilities import robust_inverse def calculate_sensitivity_to_bias(jac, weights): diff --git a/src/estimagic/msm_weighting.py b/src/estimagic/msm_weighting.py index dd00028eb..4b26a7e42 100644 --- a/src/estimagic/msm_weighting.py +++ b/src/estimagic/msm_weighting.py @@ -2,13 +2,13 @@ import numpy as np import pandas as pd -from optimagic.parameters.block_trees import block_tree_to_matrix, matrix_to_block_tree -from optimagic.parameters.tree_registry import get_registry -from optimagic.utilities import robust_inverse from pybaum import tree_just_flatten from scipy.linalg import block_diag from estimagic.bootstrap import bootstrap +from optimagic.parameters.block_trees import block_tree_to_matrix, matrix_to_block_tree +from optimagic.parameters.tree_registry import get_registry +from optimagic.utilities import robust_inverse def get_moments_cov( diff --git a/src/estimagic/shared_covs.py b/src/estimagic/shared_covs.py index e6a993d16..c4cccc3a2 100644 --- a/src/estimagic/shared_covs.py +++ b/src/estimagic/shared_covs.py @@ -3,9 +3,10 @@ import numpy as np import pandas as pd import scipy +from pybaum import tree_just_flatten, tree_unflatten + from optimagic.parameters.block_trees import matrix_to_block_tree from optimagic.parameters.tree_registry import get_registry -from pybaum import tree_just_flatten, tree_unflatten def transform_covariance( diff --git a/tests/estimagic/examples/test_logit.py b/tests/estimagic/examples/test_logit.py index a2c150ad1..03175e68e 100644 --- a/tests/estimagic/examples/test_logit.py +++ b/tests/estimagic/examples/test_logit.py @@ -1,8 +1,9 @@ """Tests for the logit example.""" -from estimagic.examples.logit import logit_grad, logit_hess, logit_jac, logit_loglike from numpy.testing import assert_array_almost_equal as aaae +from estimagic.examples.logit import logit_grad, logit_hess, logit_jac, logit_loglike + def test_logit_loglikes(logit_inputs, logit_object): x = logit_inputs["params"]["value"].to_numpy() diff --git a/tests/estimagic/test_bootstrap.py b/tests/estimagic/test_bootstrap.py index 726a7d72a..7fa1380e2 100644 --- a/tests/estimagic/test_bootstrap.py +++ b/tests/estimagic/test_bootstrap.py @@ -3,6 +3,7 @@ import pytest import seaborn as sns import statsmodels.api as sm + from estimagic import bootstrap diff --git a/tests/estimagic/test_bootstrap_ci.py b/tests/estimagic/test_bootstrap_ci.py index 797fd77df..a6684b3a2 100644 --- a/tests/estimagic/test_bootstrap_ci.py +++ b/tests/estimagic/test_bootstrap_ci.py @@ -3,9 +3,10 @@ import numpy as np import pandas as pd import pytest +from pybaum import tree_just_flatten + from estimagic.bootstrap_ci import calculate_ci, check_inputs from optimagic.parameters.tree_registry import get_registry -from pybaum import tree_just_flatten def aaae(obj1, obj2, decimal=6): diff --git a/tests/estimagic/test_bootstrap_outcomes.py b/tests/estimagic/test_bootstrap_outcomes.py index f3bdd1080..987deaf55 100644 --- a/tests/estimagic/test_bootstrap_outcomes.py +++ b/tests/estimagic/test_bootstrap_outcomes.py @@ -3,11 +3,12 @@ import numpy as np import pandas as pd import pytest +from numpy.testing import assert_array_almost_equal as aaae + from estimagic.bootstrap_outcomes import ( _get_bootstrap_outcomes_from_indices, get_bootstrap_outcomes, ) -from numpy.testing import assert_array_almost_equal as aaae from optimagic.batch_evaluators import joblib_batch_evaluator from optimagic.utilities import get_rng diff --git a/tests/estimagic/test_bootstrap_samples.py b/tests/estimagic/test_bootstrap_samples.py index a645253a7..3abf5920e 100644 --- a/tests/estimagic/test_bootstrap_samples.py +++ b/tests/estimagic/test_bootstrap_samples.py @@ -1,15 +1,16 @@ import numpy as np import pandas as pd import pytest +from numpy.testing import assert_array_equal as aae +from pandas.testing import assert_frame_equal as afe + from estimagic.bootstrap_samples import ( _convert_cluster_ids_to_indices, _get_bootstrap_samples_from_indices, get_bootstrap_indices, get_bootstrap_samples, ) -from numpy.testing import assert_array_equal as aae from optimagic.utilities import get_rng -from pandas.testing import assert_frame_equal as afe @pytest.fixture() diff --git a/tests/estimagic/test_estimate_ml.py b/tests/estimagic/test_estimate_ml.py index e3667a6d2..01714bee8 100644 --- a/tests/estimagic/test_estimate_ml.py +++ b/tests/estimagic/test_estimate_ml.py @@ -1,11 +1,15 @@ import itertools import numpy as np -import optimagic as om import pandas as pd import pytest import scipy as sp import statsmodels.api as sm +from numpy.testing import assert_array_equal +from scipy.stats import multivariate_normal +from statsmodels.base.model import GenericLikelihoodModel + +import optimagic as om from estimagic.estimate_ml import estimate_ml from estimagic.examples.logit import ( logit_hess, @@ -13,11 +17,8 @@ logit_loglike, scalar_logit_fun_and_jac, ) -from numpy.testing import assert_array_equal from optimagic import mark from optimagic.parameters.bounds import Bounds -from scipy.stats import multivariate_normal -from statsmodels.base.model import GenericLikelihoodModel def aaae(obj1, obj2, decimal=3): diff --git a/tests/estimagic/test_estimate_msm.py b/tests/estimagic/test_estimate_msm.py index bfda6c957..0c7a2d775 100644 --- a/tests/estimagic/test_estimate_msm.py +++ b/tests/estimagic/test_estimate_msm.py @@ -5,9 +5,10 @@ import numpy as np import pandas as pd import pytest -from estimagic.estimate_msm import estimate_msm from numpy.testing import assert_array_almost_equal as aaae from numpy.testing import assert_array_equal + +from estimagic.estimate_msm import estimate_msm from optimagic.optimization.optimize_result import OptimizeResult from optimagic.shared.check_option_dicts import ( check_optimization_options, diff --git a/tests/estimagic/test_estimate_msm_dict_params_and_moments.py b/tests/estimagic/test_estimate_msm_dict_params_and_moments.py index 2852d23eb..b1cbcd250 100644 --- a/tests/estimagic/test_estimate_msm_dict_params_and_moments.py +++ b/tests/estimagic/test_estimate_msm_dict_params_and_moments.py @@ -2,11 +2,12 @@ import numpy as np import pandas as pd -from estimagic.estimate_msm import estimate_msm from numpy.testing import assert_array_almost_equal as aaae -from optimagic.parameters.tree_registry import get_registry from pybaum import tree_just_flatten +from estimagic.estimate_msm import estimate_msm +from optimagic.parameters.tree_registry import get_registry + def test_estimate_msm_dict_params_and_moments(): def simulate_moments(params): diff --git a/tests/estimagic/test_estimation_table.py b/tests/estimagic/test_estimation_table.py index da1e1aa29..6e1b3baae 100644 --- a/tests/estimagic/test_estimation_table.py +++ b/tests/estimagic/test_estimation_table.py @@ -5,6 +5,9 @@ import pandas as pd import pytest import statsmodels.api as sm +from pandas.testing import assert_frame_equal as afe +from pandas.testing import assert_series_equal as ase + from estimagic.config import EXAMPLE_DIR from estimagic.estimation_table import ( _apply_number_format, @@ -25,8 +28,6 @@ render_html, render_latex, ) -from pandas.testing import assert_frame_equal as afe -from pandas.testing import assert_series_equal as ase # ====================================================================================== diff --git a/tests/estimagic/test_lollipop_plot.py b/tests/estimagic/test_lollipop_plot.py index 06a4552b3..c83e9fb00 100644 --- a/tests/estimagic/test_lollipop_plot.py +++ b/tests/estimagic/test_lollipop_plot.py @@ -1,5 +1,6 @@ import numpy as np import pandas as pd + from estimagic.lollipop_plot import lollipop_plot diff --git a/tests/estimagic/test_ml_covs.py b/tests/estimagic/test_ml_covs.py index 084a4912e..9d752cf51 100644 --- a/tests/estimagic/test_ml_covs.py +++ b/tests/estimagic/test_ml_covs.py @@ -4,6 +4,8 @@ import numpy as np import pandas as pd import pytest +from numpy.testing import assert_array_almost_equal as aaae + from estimagic import ml_covs from estimagic.ml_covs import ( _clustering, @@ -15,7 +17,6 @@ cov_robust, cov_strata_robust, ) -from numpy.testing import assert_array_almost_equal as aaae @pytest.fixture() diff --git a/tests/estimagic/test_msm_covs.py b/tests/estimagic/test_msm_covs.py index a9261184a..a72501e63 100644 --- a/tests/estimagic/test_msm_covs.py +++ b/tests/estimagic/test_msm_covs.py @@ -3,11 +3,12 @@ import numpy as np import pandas as pd import pytest -from estimagic.msm_covs import cov_optimal, cov_robust from numpy.testing import assert_array_almost_equal as aaae -from optimagic.utilities import get_rng from pandas.testing import assert_frame_equal +from estimagic.msm_covs import cov_optimal, cov_robust +from optimagic.utilities import get_rng + rng = get_rng(seed=1234) jac_np = rng.uniform(size=(10, 5)) diff --git a/tests/estimagic/test_msm_sensitivity.py b/tests/estimagic/test_msm_sensitivity.py index 92a438422..fd2d0c1da 100644 --- a/tests/estimagic/test_msm_sensitivity.py +++ b/tests/estimagic/test_msm_sensitivity.py @@ -1,6 +1,9 @@ import numpy as np import pandas as pd import pytest +from numpy.testing import assert_array_almost_equal as aaae +from scipy import stats + from estimagic.config import EXAMPLE_DIR from estimagic.msm_covs import cov_optimal from estimagic.msm_sensitivity import ( @@ -11,9 +14,7 @@ calculate_sensitivity_to_bias, calculate_sensitivity_to_weighting, ) -from numpy.testing import assert_array_almost_equal as aaae from optimagic.differentiation.derivatives import first_derivative -from scipy import stats def simulate_aggregated_moments(params, x, y): diff --git a/tests/estimagic/test_msm_sensitivity_via_estimate_msm.py b/tests/estimagic/test_msm_sensitivity_via_estimate_msm.py index 994b6c526..98d38ec7e 100644 --- a/tests/estimagic/test_msm_sensitivity_via_estimate_msm.py +++ b/tests/estimagic/test_msm_sensitivity_via_estimate_msm.py @@ -1,11 +1,12 @@ import numpy as np import pandas as pd import pytest -from estimagic.config import EXAMPLE_DIR -from estimagic.estimate_msm import estimate_msm from numpy.testing import assert_array_almost_equal as aaae from scipy import stats +from estimagic.config import EXAMPLE_DIR +from estimagic.estimate_msm import estimate_msm + def simulate_aggregated_moments(params, x, y): """Calculate aggregated moments for example from Honore, DePaula, Jorgensen.""" diff --git a/tests/estimagic/test_msm_weighting.py b/tests/estimagic/test_msm_weighting.py index 18fff92fd..ac8255607 100644 --- a/tests/estimagic/test_msm_weighting.py +++ b/tests/estimagic/test_msm_weighting.py @@ -3,12 +3,13 @@ import numpy as np import pandas as pd import pytest +from numpy.testing import assert_array_almost_equal as aaae + from estimagic.msm_weighting import ( _assemble_block_diagonal_matrix, get_moments_cov, get_weighting_matrix, ) -from numpy.testing import assert_array_almost_equal as aaae from optimagic.parameters.block_trees import block_tree_to_matrix from optimagic.utilities import get_rng diff --git a/tests/estimagic/test_shared.py b/tests/estimagic/test_shared.py index 9aaaa9ae7..9a4240c74 100644 --- a/tests/estimagic/test_shared.py +++ b/tests/estimagic/test_shared.py @@ -3,6 +3,9 @@ import numpy as np import pandas as pd import pytest +from numpy.testing import assert_array_almost_equal as aaae +from pybaum import leaf_names, tree_equal + from estimagic.shared_covs import ( _to_numpy, calculate_estimation_summary, @@ -12,10 +15,8 @@ transform_free_cov_to_cov, transform_free_values_to_params_tree, ) -from numpy.testing import assert_array_almost_equal as aaae from optimagic.parameters.tree_registry import get_registry from optimagic.utilities import get_rng -from pybaum import leaf_names, tree_equal @pytest.fixture() diff --git a/tests/optimagic/benchmarking/test_benchmark_reports.py b/tests/optimagic/benchmarking/test_benchmark_reports.py index 29cead39a..d069966bd 100644 --- a/tests/optimagic/benchmarking/test_benchmark_reports.py +++ b/tests/optimagic/benchmarking/test_benchmark_reports.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from optimagic import ( OptimizeResult, convergence_report, diff --git a/tests/optimagic/benchmarking/test_cartis_roberts.py b/tests/optimagic/benchmarking/test_cartis_roberts.py index 8fdf71998..c399d89d7 100644 --- a/tests/optimagic/benchmarking/test_cartis_roberts.py +++ b/tests/optimagic/benchmarking/test_cartis_roberts.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal + from optimagic.benchmarking.cartis_roberts import ( CARTIS_ROBERTS_PROBLEMS, get_start_points_bdvalues, diff --git a/tests/optimagic/benchmarking/test_get_benchmark_problems.py b/tests/optimagic/benchmarking/test_get_benchmark_problems.py index 821d77deb..134ae4f41 100644 --- a/tests/optimagic/benchmarking/test_get_benchmark_problems.py +++ b/tests/optimagic/benchmarking/test_get_benchmark_problems.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from optimagic.benchmarking.get_benchmark_problems import ( _step_func, get_benchmark_problems, diff --git a/tests/optimagic/benchmarking/test_more_wild.py b/tests/optimagic/benchmarking/test_more_wild.py index b7427cca0..bb3515574 100644 --- a/tests/optimagic/benchmarking/test_more_wild.py +++ b/tests/optimagic/benchmarking/test_more_wild.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from optimagic.benchmarking.more_wild import ( MORE_WILD_PROBLEMS, get_start_points_mancino, diff --git a/tests/optimagic/benchmarking/test_noise_distributions.py b/tests/optimagic/benchmarking/test_noise_distributions.py index d8e2183ad..f3d549a36 100644 --- a/tests/optimagic/benchmarking/test_noise_distributions.py +++ b/tests/optimagic/benchmarking/test_noise_distributions.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd import pytest + from optimagic.benchmarking.get_benchmark_problems import _sample_from_distribution from optimagic.benchmarking.noise_distributions import NOISE_DISTRIBUTIONS from optimagic.utilities import get_rng diff --git a/tests/optimagic/benchmarking/test_run_benchmark.py b/tests/optimagic/benchmarking/test_run_benchmark.py index 26e827bbb..d501dd17e 100644 --- a/tests/optimagic/benchmarking/test_run_benchmark.py +++ b/tests/optimagic/benchmarking/test_run_benchmark.py @@ -1,4 +1,5 @@ import pytest + from optimagic import get_benchmark_problems from optimagic.benchmarking.run_benchmark import run_benchmark diff --git a/tests/optimagic/differentiation/test_compare_derivatives_with_jax.py b/tests/optimagic/differentiation/test_compare_derivatives_with_jax.py index ffa08e388..87b5554d8 100644 --- a/tests/optimagic/differentiation/test_compare_derivatives_with_jax.py +++ b/tests/optimagic/differentiation/test_compare_derivatives_with_jax.py @@ -7,9 +7,10 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae +from pybaum import tree_equal + from optimagic.config import IS_JAX_INSTALLED from optimagic.differentiation.derivatives import first_derivative, second_derivative -from pybaum import tree_equal if not IS_JAX_INSTALLED: pytestmark = pytest.mark.skip(reason="jax is not installed.") diff --git a/tests/optimagic/differentiation/test_derivatives.py b/tests/optimagic/differentiation/test_derivatives.py index cfdd73197..670c1c0ab 100644 --- a/tests/optimagic/differentiation/test_derivatives.py +++ b/tests/optimagic/differentiation/test_derivatives.py @@ -7,6 +7,9 @@ import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae +from pandas.testing import assert_frame_equal +from scipy.optimize._numdiff import approx_derivative + from optimagic.differentiation.derivatives import ( Evals, NumdiffResult, @@ -31,8 +34,6 @@ logit_loglikeobs_jacobian, ) from optimagic.parameters.bounds import Bounds -from pandas.testing import assert_frame_equal -from scipy.optimize._numdiff import approx_derivative @pytest.fixture() diff --git a/tests/optimagic/differentiation/test_finite_differences.py b/tests/optimagic/differentiation/test_finite_differences.py index 11f4d676a..3e55aabfb 100644 --- a/tests/optimagic/differentiation/test_finite_differences.py +++ b/tests/optimagic/differentiation/test_finite_differences.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.differentiation.derivatives import Evals from optimagic.differentiation.finite_differences import jacobian from optimagic.differentiation.generate_steps import Steps diff --git a/tests/optimagic/differentiation/test_generate_steps.py b/tests/optimagic/differentiation/test_generate_steps.py index 4999ceb40..bf85261b1 100644 --- a/tests/optimagic/differentiation/test_generate_steps.py +++ b/tests/optimagic/differentiation/test_generate_steps.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.differentiation.generate_steps import ( _calculate_or_validate_base_steps, _fillna, diff --git a/tests/optimagic/differentiation/test_numdiff_options.py b/tests/optimagic/differentiation/test_numdiff_options.py index b4245aeab..9ffc37616 100644 --- a/tests/optimagic/differentiation/test_numdiff_options.py +++ b/tests/optimagic/differentiation/test_numdiff_options.py @@ -1,4 +1,5 @@ import pytest + from optimagic.differentiation.numdiff_options import ( NumdiffOptions, pre_process_numdiff_options, diff --git a/tests/optimagic/examples/test_criterion_functions.py b/tests/optimagic/examples/test_criterion_functions.py index 8fdf5d038..b709b38dc 100644 --- a/tests/optimagic/examples/test_criterion_functions.py +++ b/tests/optimagic/examples/test_criterion_functions.py @@ -3,6 +3,8 @@ import pytest from numpy.testing import assert_array_almost_equal as aaae from numpy.testing import assert_array_equal +from pandas.testing import assert_frame_equal + from optimagic.examples.criterion_functions import ( rhe_fun_and_gradient, rhe_function_value, @@ -26,7 +28,6 @@ trid_scalar, ) from optimagic.optimization.fun_value import FunctionValue -from pandas.testing import assert_frame_equal TRID_GRAD = pd.DataFrame({"value": [7, 1, -6, 11, -19.0]}) RHE_GRAD = pd.DataFrame({"value": [90, 72, 36, 28, -10.0]}) diff --git a/tests/optimagic/logging/test_base.py b/tests/optimagic/logging/test_base.py index be3f123d6..1d903cecd 100644 --- a/tests/optimagic/logging/test_base.py +++ b/tests/optimagic/logging/test_base.py @@ -1,6 +1,7 @@ from dataclasses import dataclass import pytest + from optimagic.logging.base import InputType, NonUpdatableKeyValueStore, OutputType from optimagic.typing import DictLikeAccess diff --git a/tests/optimagic/logging/test_logger.py b/tests/optimagic/logging/test_logger.py index 87f37caeb..ff099d55f 100644 --- a/tests/optimagic/logging/test_logger.py +++ b/tests/optimagic/logging/test_logger.py @@ -3,6 +3,8 @@ import numpy as np import pandas as pd import pytest +from pybaum import tree_equal, tree_just_flatten + from optimagic.logging.logger import ( LogOptions, LogReader, @@ -13,7 +15,6 @@ from optimagic.optimization.optimize import minimize from optimagic.parameters.tree_registry import get_registry from optimagic.typing import Direction -from pybaum import tree_equal, tree_just_flatten @pytest.fixture() diff --git a/tests/optimagic/logging/test_sqlalchemy.py b/tests/optimagic/logging/test_sqlalchemy.py index 589a66c9d..49571fcf6 100644 --- a/tests/optimagic/logging/test_sqlalchemy.py +++ b/tests/optimagic/logging/test_sqlalchemy.py @@ -4,6 +4,8 @@ import numpy as np import pytest +from sqlalchemy import inspect + from optimagic.logging import ExistenceStrategy from optimagic.logging.logger import LogStore, SQLiteLogOptions from optimagic.logging.sqlalchemy import IterationStore, StepStore @@ -13,7 +15,6 @@ StepStatus, StepType, ) -from sqlalchemy import inspect class TestIterationStore: diff --git a/tests/optimagic/logging/test_types.py b/tests/optimagic/logging/test_types.py index 466a5e278..0c43ee7a8 100644 --- a/tests/optimagic/logging/test_types.py +++ b/tests/optimagic/logging/test_types.py @@ -1,4 +1,5 @@ import pytest + from optimagic.logging.types import ( IterationStateWithId, ProblemInitializationWithId, diff --git a/tests/optimagic/optimization/test_algorithm.py b/tests/optimagic/optimization/test_algorithm.py index 51cf1e2b3..7d78c02da 100644 --- a/tests/optimagic/optimization/test_algorithm.py +++ b/tests/optimagic/optimization/test_algorithm.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from optimagic.exceptions import InvalidAlgoInfoError, InvalidAlgoOptionError from optimagic.optimization.algorithm import AlgoInfo, Algorithm, InternalOptimizeResult from optimagic.optimization.history import HistoryEntry diff --git a/tests/optimagic/optimization/test_convergence_report.py b/tests/optimagic/optimization/test_convergence_report.py index ac7148dc7..058698a58 100644 --- a/tests/optimagic/optimization/test_convergence_report.py +++ b/tests/optimagic/optimization/test_convergence_report.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimization.convergence_report import get_convergence_report from optimagic.typing import Direction diff --git a/tests/optimagic/optimization/test_create_optimization_problem.py b/tests/optimagic/optimization/test_create_optimization_problem.py index fb34728f3..48b3d8a5d 100644 --- a/tests/optimagic/optimization/test_create_optimization_problem.py +++ b/tests/optimagic/optimization/test_create_optimization_problem.py @@ -1,4 +1,5 @@ import pytest + from optimagic.optimization.create_optimization_problem import ( pre_process_user_algorithm, ) diff --git a/tests/optimagic/optimization/test_error_penalty.py b/tests/optimagic/optimization/test_error_penalty.py index 4f23bf962..d1100cf31 100644 --- a/tests/optimagic/optimization/test_error_penalty.py +++ b/tests/optimagic/optimization/test_error_penalty.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.differentiation.derivatives import first_derivative from optimagic.optimization.error_penalty import ( _likelihood_penalty, diff --git a/tests/optimagic/optimization/test_fun_value.py b/tests/optimagic/optimization/test_fun_value.py index fd5ef9ea5..a6de8c611 100644 --- a/tests/optimagic/optimization/test_fun_value.py +++ b/tests/optimagic/optimization/test_fun_value.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_almost_equal as aae + from optimagic.exceptions import InvalidFunctionError from optimagic.optimization.fun_value import ( FunctionValue, diff --git a/tests/optimagic/optimization/test_function_formats_ls.py b/tests/optimagic/optimization/test_function_formats_ls.py index 7abcb361f..83e087404 100644 --- a/tests/optimagic/optimization/test_function_formats_ls.py +++ b/tests/optimagic/optimization/test_function_formats_ls.py @@ -7,6 +7,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic import mark, maximize, minimize from optimagic.exceptions import InvalidFunctionError from optimagic.optimization.fun_value import ( diff --git a/tests/optimagic/optimization/test_function_formats_scalar.py b/tests/optimagic/optimization/test_function_formats_scalar.py index 36e845267..2134bf8a8 100644 --- a/tests/optimagic/optimization/test_function_formats_scalar.py +++ b/tests/optimagic/optimization/test_function_formats_scalar.py @@ -4,6 +4,7 @@ import pytest from numpy.testing import assert_array_almost_equal as aaae from numpy.typing import NDArray + from optimagic import mark, maximize, minimize from optimagic.exceptions import InvalidFunctionError from optimagic.optimization.fun_value import FunctionValue, ScalarFunctionValue diff --git a/tests/optimagic/optimization/test_history.py b/tests/optimagic/optimization/test_history.py index c7fd3623a..bd6dae3dd 100644 --- a/tests/optimagic/optimization/test_history.py +++ b/tests/optimagic/optimization/test_history.py @@ -1,5 +1,6 @@ import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimization.history import History, HistoryEntry from optimagic.typing import EvalTask diff --git a/tests/optimagic/optimization/test_history_collection.py b/tests/optimagic/optimization/test_history_collection.py index 8ac2edd18..b94d097db 100644 --- a/tests/optimagic/optimization/test_history_collection.py +++ b/tests/optimagic/optimization/test_history_collection.py @@ -5,6 +5,7 @@ import pytest from numpy.testing import assert_array_almost_equal as aaae from numpy.testing import assert_array_equal as aae + from optimagic import SQLiteLogReader, mark from optimagic.algorithms import AVAILABLE_ALGORITHMS from optimagic.logging import SQLiteLogOptions diff --git a/tests/optimagic/optimization/test_history_tools.py b/tests/optimagic/optimization/test_history_tools.py index 2bfcbac2c..4b4f4d100 100644 --- a/tests/optimagic/optimization/test_history_tools.py +++ b/tests/optimagic/optimization/test_history_tools.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimization.history_tools import get_history_arrays from optimagic.typing import Direction diff --git a/tests/optimagic/optimization/test_internal_optimization_problem.py b/tests/optimagic/optimization/test_internal_optimization_problem.py index 0526f2b84..a0bb24a25 100644 --- a/tests/optimagic/optimization/test_internal_optimization_problem.py +++ b/tests/optimagic/optimization/test_internal_optimization_problem.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic import NumdiffOptions from optimagic.batch_evaluators import process_batch_evaluator from optimagic.config import CRITERION_PENALTY_CONSTANT, CRITERION_PENALTY_SLOPE diff --git a/tests/optimagic/optimization/test_jax_derivatives.py b/tests/optimagic/optimization/test_jax_derivatives.py index 94bd7fbc9..92433afae 100644 --- a/tests/optimagic/optimization/test_jax_derivatives.py +++ b/tests/optimagic/optimization/test_jax_derivatives.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.config import IS_JAX_INSTALLED from optimagic.optimization.optimize import minimize diff --git a/tests/optimagic/optimization/test_many_algorithms.py b/tests/optimagic/optimization/test_many_algorithms.py index 30abc86a4..52b7df33c 100644 --- a/tests/optimagic/optimization/test_many_algorithms.py +++ b/tests/optimagic/optimization/test_many_algorithms.py @@ -10,6 +10,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic import mark from optimagic.algorithms import AVAILABLE_ALGORITHMS, GLOBAL_ALGORITHMS from optimagic.optimization.optimize import minimize diff --git a/tests/optimagic/optimization/test_multistart.py b/tests/optimagic/optimization/test_multistart.py index c06b74909..06ec00236 100644 --- a/tests/optimagic/optimization/test_multistart.py +++ b/tests/optimagic/optimization/test_multistart.py @@ -5,6 +5,7 @@ import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimization.algorithm import InternalOptimizeResult from optimagic.optimization.multistart import ( _draw_exploration_sample, diff --git a/tests/optimagic/optimization/test_multistart_options.py b/tests/optimagic/optimization/test_multistart_options.py index 20785fdb9..a8f356fb8 100644 --- a/tests/optimagic/optimization/test_multistart_options.py +++ b/tests/optimagic/optimization/test_multistart_options.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from optimagic.exceptions import InvalidMultistartError from optimagic.optimization.multistart_options import ( MultistartOptions, diff --git a/tests/optimagic/optimization/test_optimize.py b/tests/optimagic/optimization/test_optimize.py index e3f565bc0..7e4cb4184 100644 --- a/tests/optimagic/optimization/test_optimize.py +++ b/tests/optimagic/optimization/test_optimize.py @@ -3,6 +3,7 @@ import numpy as np import pandas as pd import pytest + from optimagic.examples.criterion_functions import sos_scalar from optimagic.exceptions import InvalidFunctionError, InvalidNumdiffOptionsError from optimagic.optimization.optimize import maximize, minimize diff --git a/tests/optimagic/optimization/test_optimize_result.py b/tests/optimagic/optimization/test_optimize_result.py index 24100bf6b..6716252c0 100644 --- a/tests/optimagic/optimization/test_optimize_result.py +++ b/tests/optimagic/optimization/test_optimize_result.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd import pytest + from optimagic.optimization.optimize_result import OptimizeResult, _create_stars from optimagic.utilities import get_rng diff --git a/tests/optimagic/optimization/test_params_versions.py b/tests/optimagic/optimization/test_params_versions.py index 9aab8d861..f3399cb12 100644 --- a/tests/optimagic/optimization/test_params_versions.py +++ b/tests/optimagic/optimization/test_params_versions.py @@ -2,6 +2,8 @@ import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae +from pybaum import tree_just_flatten + from optimagic.examples.criterion_functions import ( sos_gradient, sos_ls, @@ -10,7 +12,6 @@ ) from optimagic.optimization.optimize import minimize from optimagic.parameters.tree_registry import get_registry -from pybaum import tree_just_flatten REGISTRY = get_registry(extended=True) diff --git a/tests/optimagic/optimization/test_pygmo_optimizers.py b/tests/optimagic/optimization/test_pygmo_optimizers.py index 751ac3cc0..a615ead31 100644 --- a/tests/optimagic/optimization/test_pygmo_optimizers.py +++ b/tests/optimagic/optimization/test_pygmo_optimizers.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from optimagic.optimizers.pygmo_optimizers import ( _convert_str_to_int, get_population_size, diff --git a/tests/optimagic/optimization/test_scipy_aliases.py b/tests/optimagic/optimization/test_scipy_aliases.py index fe8e5984c..0402d596a 100644 --- a/tests/optimagic/optimization/test_scipy_aliases.py +++ b/tests/optimagic/optimization/test_scipy_aliases.py @@ -1,7 +1,8 @@ import numpy as np -import optimagic as om import pytest from numpy.testing import assert_array_almost_equal as aaae + +import optimagic as om from optimagic.exceptions import AliasError diff --git a/tests/optimagic/optimization/test_useful_exceptions.py b/tests/optimagic/optimization/test_useful_exceptions.py index fa5e3c470..e972db761 100644 --- a/tests/optimagic/optimization/test_useful_exceptions.py +++ b/tests/optimagic/optimization/test_useful_exceptions.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd import pytest + from optimagic.exceptions import ( InvalidFunctionError, InvalidKwargsError, diff --git a/tests/optimagic/optimization/test_with_advanced_constraints.py b/tests/optimagic/optimization/test_with_advanced_constraints.py index 3d6c6432d..df3372199 100644 --- a/tests/optimagic/optimization/test_with_advanced_constraints.py +++ b/tests/optimagic/optimization/test_with_advanced_constraints.py @@ -9,10 +9,11 @@ import itertools import numpy as np -import optimagic as om import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae + +import optimagic as om from optimagic.examples.criterion_functions import sos_gradient, sos_scalar from optimagic.optimization.optimize import minimize diff --git a/tests/optimagic/optimization/test_with_bounds.py b/tests/optimagic/optimization/test_with_bounds.py index 487feaba2..ed29665f9 100644 --- a/tests/optimagic/optimization/test_with_bounds.py +++ b/tests/optimagic/optimization/test_with_bounds.py @@ -1,7 +1,8 @@ import numpy as np -from optimagic.optimization.optimize import maximize, minimize from scipy.optimize import Bounds as ScipyBounds +from optimagic.optimization.optimize import maximize, minimize + def test_minimize_with_scipy_bounds(): minimize( diff --git a/tests/optimagic/optimization/test_with_constraints.py b/tests/optimagic/optimization/test_with_constraints.py index 832e5ec81..8c2836857 100644 --- a/tests/optimagic/optimization/test_with_constraints.py +++ b/tests/optimagic/optimization/test_with_constraints.py @@ -10,11 +10,12 @@ from copy import deepcopy import numpy as np -import optimagic as om import pandas as pd import pytest import statsmodels.api as sm from numpy.testing import assert_array_almost_equal as aaae + +import optimagic as om from optimagic import mark from optimagic.examples.criterion_functions import ( rhe_function_value, diff --git a/tests/optimagic/optimization/test_with_logging.py b/tests/optimagic/optimization/test_with_logging.py index 94fb8aed9..b279f5202 100644 --- a/tests/optimagic/optimization/test_with_logging.py +++ b/tests/optimagic/optimization/test_with_logging.py @@ -11,6 +11,8 @@ import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae +from pybaum import tree_just_flatten + from optimagic import mark from optimagic.examples.criterion_functions import ( sos_derivatives, @@ -20,7 +22,6 @@ from optimagic.logging.types import ExistenceStrategy from optimagic.optimization.optimize import minimize from optimagic.parameters.tree_registry import get_registry -from pybaum import tree_just_flatten @mark.least_squares diff --git a/tests/optimagic/optimization/test_with_multistart.py b/tests/optimagic/optimization/test_with_multistart.py index 332de6447..d9f8325d7 100644 --- a/tests/optimagic/optimization/test_with_multistart.py +++ b/tests/optimagic/optimization/test_with_multistart.py @@ -1,10 +1,11 @@ import functools import numpy as np -import optimagic as om import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae + +import optimagic as om from optimagic.examples.criterion_functions import ( sos_ls, sos_scalar, diff --git a/tests/optimagic/optimization/test_with_nonlinear_constraints.py b/tests/optimagic/optimization/test_with_nonlinear_constraints.py index 59e036e5f..123cebe86 100644 --- a/tests/optimagic/optimization/test_with_nonlinear_constraints.py +++ b/tests/optimagic/optimization/test_with_nonlinear_constraints.py @@ -2,9 +2,10 @@ import warnings import numpy as np -import optimagic as om import pytest from numpy.testing import assert_array_almost_equal as aaae + +import optimagic as om from optimagic import maximize, minimize from optimagic.algorithms import AVAILABLE_ALGORITHMS from optimagic.config import IS_CYIPOPT_INSTALLED diff --git a/tests/optimagic/optimization/test_with_scaling.py b/tests/optimagic/optimization/test_with_scaling.py index 8d9f378ef..1cddd6df8 100644 --- a/tests/optimagic/optimization/test_with_scaling.py +++ b/tests/optimagic/optimization/test_with_scaling.py @@ -1,6 +1,7 @@ import numpy as np -import optimagic as om from numpy.testing import assert_array_almost_equal as aaae + +import optimagic as om from optimagic.optimization.optimize import maximize, minimize from optimagic.parameters.scaling import ScalingOptions diff --git a/tests/optimagic/optimizers/_pounders/test_linear_subsolvers.py b/tests/optimagic/optimizers/_pounders/test_linear_subsolvers.py index 3fa78a9f8..a6f5bf43b 100644 --- a/tests/optimagic/optimizers/_pounders/test_linear_subsolvers.py +++ b/tests/optimagic/optimizers/_pounders/test_linear_subsolvers.py @@ -5,6 +5,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimizers._pounders.linear_subsolvers import ( LinearModel, improve_geomtery_trsbox_linear, diff --git a/tests/optimagic/optimizers/_pounders/test_pounders_history.py b/tests/optimagic/optimizers/_pounders/test_pounders_history.py index 38d3d3711..f02d7df99 100644 --- a/tests/optimagic/optimizers/_pounders/test_pounders_history.py +++ b/tests/optimagic/optimizers/_pounders/test_pounders_history.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimizers._pounders.pounders_history import LeastSquaresHistory ENTRIES = [ diff --git a/tests/optimagic/optimizers/_pounders/test_pounders_unit.py b/tests/optimagic/optimizers/_pounders/test_pounders_unit.py index e17ffe262..fc60e850d 100644 --- a/tests/optimagic/optimizers/_pounders/test_pounders_unit.py +++ b/tests/optimagic/optimizers/_pounders/test_pounders_unit.py @@ -9,6 +9,7 @@ import pytest import yaml from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimizers._pounders.pounders_auxiliary import ( add_geomtery_points_to_make_main_model_fully_linear, create_initial_residual_model, diff --git a/tests/optimagic/optimizers/_pounders/test_quadratic_subsolvers.py b/tests/optimagic/optimizers/_pounders/test_quadratic_subsolvers.py index c7a890f8a..5a3818d0f 100644 --- a/tests/optimagic/optimizers/_pounders/test_quadratic_subsolvers.py +++ b/tests/optimagic/optimizers/_pounders/test_quadratic_subsolvers.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.optimizers._pounders._conjugate_gradient import ( minimize_trust_cg, ) diff --git a/tests/optimagic/optimizers/test_bhhh.py b/tests/optimagic/optimizers/test_bhhh.py index d686f5375..14bdd0f31 100644 --- a/tests/optimagic/optimizers/test_bhhh.py +++ b/tests/optimagic/optimizers/test_bhhh.py @@ -6,10 +6,11 @@ import pytest import statsmodels.api as sm from numpy.testing import assert_array_almost_equal as aaae +from scipy.stats import norm + from optimagic import mark, minimize from optimagic.optimizers.bhhh import bhhh_internal from optimagic.utilities import get_rng -from scipy.stats import norm def generate_test_data(): diff --git a/tests/optimagic/optimizers/test_fides_options.py b/tests/optimagic/optimizers/test_fides_options.py index cb7b020be..44c8caa5b 100644 --- a/tests/optimagic/optimizers/test_fides_options.py +++ b/tests/optimagic/optimizers/test_fides_options.py @@ -3,12 +3,14 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.config import IS_FIDES_INSTALLED from optimagic.optimization.optimize import minimize from optimagic.parameters.bounds import Bounds if IS_FIDES_INSTALLED: from fides.hessian_approximation import FX, SR1, Broyden + from optimagic.optimizers.fides import Fides else: FX = lambda: None diff --git a/tests/optimagic/optimizers/test_ipopt_options.py b/tests/optimagic/optimizers/test_ipopt_options.py index 24ffdf60c..888392a20 100644 --- a/tests/optimagic/optimizers/test_ipopt_options.py +++ b/tests/optimagic/optimizers/test_ipopt_options.py @@ -3,6 +3,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.config import IS_CYIPOPT_INSTALLED from optimagic.optimization.optimize import minimize from optimagic.optimizers.ipopt import Ipopt diff --git a/tests/optimagic/optimizers/test_nag_optimizers.py b/tests/optimagic/optimizers/test_nag_optimizers.py index 5562d5333..b01f06123 100644 --- a/tests/optimagic/optimizers/test_nag_optimizers.py +++ b/tests/optimagic/optimizers/test_nag_optimizers.py @@ -1,4 +1,5 @@ import pytest + from optimagic.optimizers.nag_optimizers import ( _build_options_dict, _change_evals_per_point_interface, diff --git a/tests/optimagic/optimizers/test_neldermead.py b/tests/optimagic/optimizers/test_neldermead.py index 62ece7a81..8ece1e830 100644 --- a/tests/optimagic/optimizers/test_neldermead.py +++ b/tests/optimagic/optimizers/test_neldermead.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from optimagic.optimizers.neldermead import ( _gao_han, _init_algo_params, diff --git a/tests/optimagic/optimizers/test_pounders_integration.py b/tests/optimagic/optimizers/test_pounders_integration.py index b87160865..c83a697bd 100644 --- a/tests/optimagic/optimizers/test_pounders_integration.py +++ b/tests/optimagic/optimizers/test_pounders_integration.py @@ -8,8 +8,8 @@ import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae -from optimagic.optimizers.pounders import internal_solve_pounders +from optimagic.optimizers.pounders import internal_solve_pounders from tests.optimagic.optimizers._pounders.test_pounders_unit import FIXTURES_DIR diff --git a/tests/optimagic/optimizers/test_tao_optimizers.py b/tests/optimagic/optimizers/test_tao_optimizers.py index c2e560a6c..897f8347a 100644 --- a/tests/optimagic/optimizers/test_tao_optimizers.py +++ b/tests/optimagic/optimizers/test_tao_optimizers.py @@ -5,6 +5,7 @@ import numpy as np import pandas as pd import pytest + from optimagic.config import IS_PETSC4PY_INSTALLED from optimagic.optimization.optimize import minimize from optimagic.utilities import get_rng diff --git a/tests/optimagic/parameters/test_block_trees.py b/tests/optimagic/parameters/test_block_trees.py index 27642854d..08b2307cd 100644 --- a/tests/optimagic/parameters/test_block_trees.py +++ b/tests/optimagic/parameters/test_block_trees.py @@ -2,6 +2,9 @@ import pandas as pd import pytest from numpy.testing import assert_array_equal +from pybaum import tree_equal +from pybaum import tree_just_flatten as tree_leaves + from optimagic import second_derivative from optimagic.parameters.block_trees import ( block_tree_to_hessian, @@ -10,8 +13,6 @@ matrix_to_block_tree, ) from optimagic.parameters.tree_registry import get_registry -from pybaum import tree_equal -from pybaum import tree_just_flatten as tree_leaves def test_matrix_to_block_tree_array_and_scalar(): diff --git a/tests/optimagic/parameters/test_bounds.py b/tests/optimagic/parameters/test_bounds.py index ccb3ca959..791706d56 100644 --- a/tests/optimagic/parameters/test_bounds.py +++ b/tests/optimagic/parameters/test_bounds.py @@ -2,6 +2,7 @@ import pandas as pd import pytest from numpy.testing import assert_array_equal + from optimagic.exceptions import InvalidBoundsError from optimagic.parameters.bounds import Bounds, get_internal_bounds, pre_process_bounds diff --git a/tests/optimagic/parameters/test_check_constraints.py b/tests/optimagic/parameters/test_check_constraints.py index 79f3ea121..85952336f 100644 --- a/tests/optimagic/parameters/test_check_constraints.py +++ b/tests/optimagic/parameters/test_check_constraints.py @@ -1,6 +1,7 @@ import numpy as np -import optimagic as om import pytest + +import optimagic as om from optimagic.exceptions import InvalidParamsError from optimagic.parameters.check_constraints import _iloc from optimagic.parameters.constraint_tools import check_constraints diff --git a/tests/optimagic/parameters/test_constraint_tools.py b/tests/optimagic/parameters/test_constraint_tools.py index 3b2151762..29e511c6d 100644 --- a/tests/optimagic/parameters/test_constraint_tools.py +++ b/tests/optimagic/parameters/test_constraint_tools.py @@ -1,5 +1,6 @@ -import optimagic as om import pytest + +import optimagic as om from optimagic.exceptions import InvalidParamsError from optimagic.parameters.constraint_tools import check_constraints, count_free_params diff --git a/tests/optimagic/parameters/test_conversion.py b/tests/optimagic/parameters/test_conversion.py index f03dbbe99..da4942443 100644 --- a/tests/optimagic/parameters/test_conversion.py +++ b/tests/optimagic/parameters/test_conversion.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.parameters.bounds import Bounds from optimagic.parameters.conversion import ( _is_fast_deriv_eval, diff --git a/tests/optimagic/parameters/test_kernel_transformations.py b/tests/optimagic/parameters/test_kernel_transformations.py index a7aab19ee..0c81599cf 100644 --- a/tests/optimagic/parameters/test_kernel_transformations.py +++ b/tests/optimagic/parameters/test_kernel_transformations.py @@ -2,9 +2,10 @@ from itertools import product import numpy as np -import optimagic.parameters.kernel_transformations as kt import pytest from numpy.testing import assert_array_almost_equal as aaae + +import optimagic.parameters.kernel_transformations as kt from optimagic.differentiation.derivatives import first_derivative from optimagic.parameters.kernel_transformations import cov_matrix_to_sdcorr_params from optimagic.utilities import get_rng diff --git a/tests/optimagic/parameters/test_nonlinear_constraints.py b/tests/optimagic/parameters/test_nonlinear_constraints.py index 44c607f5e..67af8678d 100644 --- a/tests/optimagic/parameters/test_nonlinear_constraints.py +++ b/tests/optimagic/parameters/test_nonlinear_constraints.py @@ -5,6 +5,9 @@ import pandas as pd import pytest from numpy.testing import assert_array_equal +from pandas.testing import assert_frame_equal +from pybaum import tree_just_flatten + from optimagic.differentiation.numdiff_options import NumdiffOptions from optimagic.exceptions import InvalidConstraintError from optimagic.parameters.nonlinear_constraints import ( @@ -20,8 +23,6 @@ vector_as_list_of_scalar_constraints, ) from optimagic.parameters.tree_registry import get_registry -from pandas.testing import assert_frame_equal -from pybaum import tree_just_flatten @dataclass diff --git a/tests/optimagic/parameters/test_process_constraints.py b/tests/optimagic/parameters/test_process_constraints.py index 469b485bd..66eb42fc1 100644 --- a/tests/optimagic/parameters/test_process_constraints.py +++ b/tests/optimagic/parameters/test_process_constraints.py @@ -1,9 +1,10 @@ """Test the pc processing.""" import numpy as np -import optimagic as om import pandas as pd import pytest + +import optimagic as om from optimagic.exceptions import InvalidConstraintError from optimagic.parameters.bounds import Bounds from optimagic.parameters.constraint_tools import check_constraints diff --git a/tests/optimagic/parameters/test_process_selectors.py b/tests/optimagic/parameters/test_process_selectors.py index b40c39879..7ad9c78e6 100644 --- a/tests/optimagic/parameters/test_process_selectors.py +++ b/tests/optimagic/parameters/test_process_selectors.py @@ -2,11 +2,12 @@ import pandas as pd import pytest from numpy.testing import assert_array_equal as aae +from pybaum import tree_flatten, tree_just_flatten, tree_unflatten + from optimagic.exceptions import InvalidConstraintError from optimagic.parameters.process_selectors import process_selectors from optimagic.parameters.tree_conversion import TreeConverter from optimagic.parameters.tree_registry import get_registry -from pybaum import tree_flatten, tree_just_flatten, tree_unflatten @pytest.mark.parametrize("constraints", [None, []]) diff --git a/tests/optimagic/parameters/test_scale_conversion.py b/tests/optimagic/parameters/test_scale_conversion.py index aaa73310d..0b64da03a 100644 --- a/tests/optimagic/parameters/test_scale_conversion.py +++ b/tests/optimagic/parameters/test_scale_conversion.py @@ -2,6 +2,7 @@ import pytest from numpy.testing import assert_array_almost_equal as aaae from numpy.testing import assert_array_equal as aae + from optimagic import first_derivative from optimagic.parameters.conversion import InternalParams from optimagic.parameters.scale_conversion import get_scale_converter diff --git a/tests/optimagic/parameters/test_scaling.py b/tests/optimagic/parameters/test_scaling.py index 2ae0395f0..13be92823 100644 --- a/tests/optimagic/parameters/test_scaling.py +++ b/tests/optimagic/parameters/test_scaling.py @@ -1,4 +1,5 @@ import pytest + from optimagic.exceptions import InvalidScalingError from optimagic.parameters.scaling import ( ScalingOptions, diff --git a/tests/optimagic/parameters/test_space_conversion.py b/tests/optimagic/parameters/test_space_conversion.py index 9a87924ca..0c4b22365 100644 --- a/tests/optimagic/parameters/test_space_conversion.py +++ b/tests/optimagic/parameters/test_space_conversion.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic import first_derivative from optimagic.parameters.space_conversion import ( InternalParams, diff --git a/tests/optimagic/parameters/test_tree_conversion.py b/tests/optimagic/parameters/test_tree_conversion.py index 41129f085..7f22c918e 100644 --- a/tests/optimagic/parameters/test_tree_conversion.py +++ b/tests/optimagic/parameters/test_tree_conversion.py @@ -2,6 +2,7 @@ import pandas as pd import pytest from numpy.testing import assert_array_equal as aae + from optimagic.parameters.bounds import Bounds from optimagic.parameters.tree_conversion import get_tree_converter from optimagic.typing import AggregationLevel diff --git a/tests/optimagic/parameters/test_tree_registry.py b/tests/optimagic/parameters/test_tree_registry.py index 9c3ca7720..6f7362538 100644 --- a/tests/optimagic/parameters/test_tree_registry.py +++ b/tests/optimagic/parameters/test_tree_registry.py @@ -1,10 +1,11 @@ import numpy as np import pandas as pd import pytest -from optimagic.parameters.tree_registry import get_registry from pandas.testing import assert_frame_equal from pybaum import leaf_names, tree_flatten, tree_unflatten +from optimagic.parameters.tree_registry import get_registry + @pytest.fixture() def value_df(): diff --git a/tests/optimagic/shared/test_process_user_functions.py b/tests/optimagic/shared/test_process_user_functions.py index a1cad7a3f..742573283 100644 --- a/tests/optimagic/shared/test_process_user_functions.py +++ b/tests/optimagic/shared/test_process_user_functions.py @@ -1,6 +1,7 @@ import numpy as np import pytest from numpy.typing import NDArray + from optimagic import mark from optimagic.exceptions import InvalidKwargsError from optimagic.optimization.fun_value import ( diff --git a/tests/optimagic/test_batch_evaluators.py b/tests/optimagic/test_batch_evaluators.py index 8006eb523..aaf07d054 100644 --- a/tests/optimagic/test_batch_evaluators.py +++ b/tests/optimagic/test_batch_evaluators.py @@ -2,6 +2,7 @@ import warnings import pytest + from optimagic.batch_evaluators import process_batch_evaluator batch_evaluators = ["joblib"] diff --git a/tests/optimagic/test_constraints.py b/tests/optimagic/test_constraints.py index 56250fb9a..075591591 100644 --- a/tests/optimagic/test_constraints.py +++ b/tests/optimagic/test_constraints.py @@ -1,4 +1,5 @@ import pytest + from optimagic.constraints import ( Constraint, DecreasingConstraint, diff --git a/tests/optimagic/test_decorators.py b/tests/optimagic/test_decorators.py index c0db497b0..63927aa22 100644 --- a/tests/optimagic/test_decorators.py +++ b/tests/optimagic/test_decorators.py @@ -1,4 +1,5 @@ import pytest + from optimagic.decorators import ( catch, unpack, diff --git a/tests/optimagic/test_deprecations.py b/tests/optimagic/test_deprecations.py index 3240fb8e8..b7fcbeb71 100644 --- a/tests/optimagic/test_deprecations.py +++ b/tests/optimagic/test_deprecations.py @@ -6,10 +6,12 @@ import warnings -import estimagic as em import numpy as np -import optimagic as om import pytest +from numpy.testing import assert_almost_equal as aaae + +import estimagic as em +import optimagic as om from estimagic import ( OptimizeLogReader, OptimizeResult, @@ -32,7 +34,6 @@ traceback_report, utilities, ) -from numpy.testing import assert_almost_equal as aaae from optimagic.deprecations import ( convert_dict_to_function_value, handle_log_options_throw_deprecated_warning, diff --git a/tests/optimagic/test_mark.py b/tests/optimagic/test_mark.py index 6231f9ad9..f13b2c1ff 100644 --- a/tests/optimagic/test_mark.py +++ b/tests/optimagic/test_mark.py @@ -1,8 +1,9 @@ import functools from dataclasses import dataclass -import optimagic as om import pytest + +import optimagic as om from optimagic.optimization.algorithm import AlgoInfo, Algorithm from optimagic.typing import AggregationLevel diff --git a/tests/optimagic/test_type_conversion.py b/tests/optimagic/test_type_conversion.py index e0d11aebc..c2d9e657d 100644 --- a/tests/optimagic/test_type_conversion.py +++ b/tests/optimagic/test_type_conversion.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from optimagic.type_conversion import TYPE_CONVERTERS from optimagic.typing import ( GtOneFloat, diff --git a/tests/optimagic/test_utilities.py b/tests/optimagic/test_utilities.py index c5bd0e873..08a4e53d0 100644 --- a/tests/optimagic/test_utilities.py +++ b/tests/optimagic/test_utilities.py @@ -2,6 +2,7 @@ import pandas as pd import pytest from numpy.testing import assert_array_almost_equal as aaae + from optimagic.config import IS_JAX_INSTALLED from optimagic.utilities import ( calculate_trustregion_initial_radius, diff --git a/tests/optimagic/visualization/test_convergence_plot.py b/tests/optimagic/visualization/test_convergence_plot.py index 45c28ce48..c6d119573 100644 --- a/tests/optimagic/visualization/test_convergence_plot.py +++ b/tests/optimagic/visualization/test_convergence_plot.py @@ -1,4 +1,5 @@ import pytest + from optimagic import get_benchmark_problems from optimagic.benchmarking.run_benchmark import run_benchmark from optimagic.visualization.convergence_plot import ( diff --git a/tests/optimagic/visualization/test_deviation_plot.py b/tests/optimagic/visualization/test_deviation_plot.py index e7060c313..41ec73907 100644 --- a/tests/optimagic/visualization/test_deviation_plot.py +++ b/tests/optimagic/visualization/test_deviation_plot.py @@ -1,4 +1,5 @@ import pytest + from optimagic import get_benchmark_problems from optimagic.benchmarking.run_benchmark import run_benchmark from optimagic.visualization.deviation_plot import ( diff --git a/tests/optimagic/visualization/test_history_plots.py b/tests/optimagic/visualization/test_history_plots.py index 81ed33824..70078b137 100644 --- a/tests/optimagic/visualization/test_history_plots.py +++ b/tests/optimagic/visualization/test_history_plots.py @@ -1,8 +1,9 @@ import itertools import numpy as np -import optimagic as om import pytest + +import optimagic as om from optimagic.logging import SQLiteLogOptions from optimagic.optimization.optimize import minimize from optimagic.parameters.bounds import Bounds diff --git a/tests/optimagic/visualization/test_profile_plot.py b/tests/optimagic/visualization/test_profile_plot.py index 929e914c5..30f84a9b4 100644 --- a/tests/optimagic/visualization/test_profile_plot.py +++ b/tests/optimagic/visualization/test_profile_plot.py @@ -1,6 +1,7 @@ import numpy as np import pandas as pd import pytest + from optimagic import get_benchmark_problems from optimagic.benchmarking.run_benchmark import run_benchmark from optimagic.visualization.profile_plot import ( diff --git a/tests/optimagic/visualization/test_slice_plot.py b/tests/optimagic/visualization/test_slice_plot.py index 5acb0d255..1eebd27d5 100644 --- a/tests/optimagic/visualization/test_slice_plot.py +++ b/tests/optimagic/visualization/test_slice_plot.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from optimagic import mark from optimagic.parameters.bounds import Bounds from optimagic.visualization.slice_plot import slice_plot