Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 2, 2024
1 parent 2babff6 commit 590a596
Show file tree
Hide file tree
Showing 128 changed files with 261 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/source/estimagic/tutorials/bootstrap_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/source/estimagic/tutorials/likelihood_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
Expand Down
3 changes: 2 additions & 1 deletion docs/source/estimagic/tutorials/msm_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
Expand Down
5 changes: 3 additions & 2 deletions docs/source/explanation/why_optimization_is_hard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_algorithm_selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om"
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_bounds.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om"
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_criterion_function.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om\n",
"\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_derivatives.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om\n",
"\n",
"\n",
Expand Down
3 changes: 2 additions & 1 deletion docs/source/how_to/how_to_errors_during_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_logging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"from pathlib import Path\n",
"\n",
"import numpy as np\n",
"\n",
"import optimagic as om"
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_multistart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om\n",
"\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_slice_plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om"
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/source/how_to/how_to_visualize_histories.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import optimagic as om"
]
},
Expand Down
5 changes: 3 additions & 2 deletions docs/source/tutorials/numdiff_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/source/tutorials/optimization_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down
23 changes: 11 additions & 12 deletions src/estimagic/__init__.py
Original file line number Diff line number Diff line change
@@ -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__
Expand All @@ -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."
Expand Down
8 changes: 4 additions & 4 deletions src/estimagic/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/estimagic/bootstrap_outcomes.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
40 changes: 20 additions & 20 deletions src/estimagic/estimate_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
46 changes: 23 additions & 23 deletions src/estimagic/estimate_msm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/estimagic/estimation_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions src/estimagic/examples/logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pandas as pd

from optimagic import mark


Expand Down
Loading

0 comments on commit 590a596

Please sign in to comment.