Skip to content

Commit

Permalink
fixing tests and package versions. test work only black import is buggy.
Browse files Browse the repository at this point in the history
  • Loading branch information
mo2561057 committed Dec 19, 2022
1 parent 511df87 commit 629cff6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- conda-build
- conda-verify
- doc8
- estimagic>=0.1.2
- estimagic=0.4.3
- fastparquet
- hypothesis
- joblib
Expand Down Expand Up @@ -49,4 +49,4 @@ dependencies:
- bump2version
- pytest-randomly
- sphinx-tabs
- chaospy>=4.2.3
- chaospy==3.3.8
4 changes: 2 additions & 2 deletions respy/conditional_draws.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Everything related to conditional draws for the maximum likelihood estimation."""
import numpy as np
from estimagic.optimization.utilities import robust_cholesky
from estimagic.utilities import robust_cholesky
from numba import guvectorize

from respy.config import MAX_FLOAT
Expand Down Expand Up @@ -177,7 +177,7 @@ def update_mean_and_evaluate_likelihood(
invariant
- log_wage_observed
- np.log(sigma)
- shock ** 2 / (2 * sigma_squared)
- shock**2 / (2 * sigma_squared)
)
else:
for i in range(n_choices):
Expand Down
18 changes: 9 additions & 9 deletions respy/pre_processing/model_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import numpy as np
import pandas as pd
import yaml
from estimagic.optimization.utilities import chol_params_to_lower_triangular_matrix
from estimagic.optimization.utilities import cov_params_to_matrix
from estimagic.optimization.utilities import robust_cholesky
from estimagic.optimization.utilities import sdcorr_params_to_matrix
from estimagic.utilities import chol_params_to_lower_triangular_matrix
from estimagic.utilities import cov_params_to_matrix
from estimagic.utilities import robust_cholesky
from estimagic.utilities import sdcorr_params_to_matrix

from respy.config import DEFAULT_OPTIONS
from respy.config import MAX_FLOAT
Expand Down Expand Up @@ -189,7 +189,7 @@ def _parse_exogenous_processes(optim_paras, params):
names = _parse_observable_or_exog_process_names(params, "exogenous_process")

for exog_proc in names:
regex_pattern = fr"\bexogenous_process_{exog_proc}_([0-9a-z_]+)\b"
regex_pattern = rf"\bexogenous_process_{exog_proc}_([0-9a-z_]+)\b"
parsed_parameters = _parse_probabilities_or_logit_coefficients(
params, regex_pattern
)
Expand All @@ -205,7 +205,7 @@ def _parse_observables(optim_paras, params):
names = _parse_observable_or_exog_process_names(params, "observable")

for observable in names:
regex_pattern = fr"\bobservable_{observable}_([0-9a-z_]+)\b"
regex_pattern = rf"\bobservable_{observable}_([0-9a-z_]+)\b"
parsed_parameters = _parse_probabilities_or_logit_coefficients(
params, regex_pattern
)
Expand Down Expand Up @@ -286,7 +286,7 @@ def _parse_choice_parameters(optim_paras, params):
def _parse_initial_and_max_experience(optim_paras, params, options):
"""Process initial experience distributions and maximum experience."""
for choice in optim_paras["choices_w_exp"]:
regex_for_levels = fr"\binitial_exp_{choice}_([0-9]+)\b"
regex_for_levels = rf"\binitial_exp_{choice}_([0-9]+)\b"
parsed_parameters = _parse_probabilities_or_logit_coefficients(
params, regex_for_levels
)
Expand Down Expand Up @@ -470,7 +470,7 @@ def _infer_choices_with_prefix(params, prefix):
"""
return sorted(
params.index.get_level_values(0)
.str.extract(fr"\b{prefix}_([A-Za-z_]+)\b", expand=False)
.str.extract(rf"\b{prefix}_([A-Za-z_]+)\b", expand=False)
.dropna()
.unique()
)
Expand Down Expand Up @@ -544,7 +544,7 @@ def _parse_lagged_choices(optim_paras, options, params):
# Add existing lagged choice parameters to ``optim_paras``.
for lag in range(1, n_lc_covariates + 1):
parsed_parameters = _parse_probabilities_or_logit_coefficients(
params, fr"lagged_choice_{lag}_([A-Za-z_]+)"
params, rf"lagged_choice_{lag}_([A-Za-z_]+)"
)

# If there are no parameters for the specific lag, assume equiprobable choices.
Expand Down
6 changes: 3 additions & 3 deletions respy/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def calculate_expected_value_functions(
The underlying process in this function is called `Monte Carlo integration
<https://en.wikipedia.org/wiki/Monte_Carlo_integration>`_. The goal is to
approximate an integral by evaluating the integrand at randomly chosen points. In
this setting, one wants to approximate the expected maximum utility of the current
this setting, one wants to approximate the m maximum utility of the current
state.
Note that ``wages`` have the same length as ``nonpecs`` despite that wages are only
Expand Down Expand Up @@ -589,8 +589,8 @@ def pandas_dot(x, beta, out=None):
if not received_out:
out = np.zeros(x.shape[0])

for covariate, beta in beta.items():
out += beta * x[covariate].values
for covariate, beta_ in beta.items():
out += beta_ * x[covariate].values

if not received_out:
return out
Expand Down
2 changes: 1 addition & 1 deletion respy/state_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def create_is_inadmissible(df, optim_paras, options):
for formula in options["negative_choice_set"][choice]:
try:
df[f"_{choice}"] |= df.eval(formula)
except pd.core.computation.ops.UndefinedVariableError:
except pd.errors.UndefinedVariableError:
pass

return df
Expand Down
8 changes: 4 additions & 4 deletions respy/tests/random_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import numpy as np
import pandas as pd
from estimagic.optimization.utilities import cov_matrix_to_params
from estimagic.optimization.utilities import cov_matrix_to_sdcorr_params
from estimagic.optimization.utilities import number_of_triangular_elements_to_dimension
from estimagic.utilities import cov_matrix_to_params
from estimagic.utilities import cov_matrix_to_sdcorr_params
from estimagic.utilities import number_of_triangular_elements_to_dimension

from respy.config import DEFAULT_OPTIONS
from respy.config import ROOT_DIR
Expand Down Expand Up @@ -264,7 +264,7 @@ def _update_nested_dictionary(dict_, other):
"""
for key, value in other.items():
if isinstance(value, collections.Mapping):
if isinstance(value, collections.abc.Mapping):
dict_[key] = _update_nested_dictionary(dict_.get(key, {}), value)
else:
dict_[key] = value
Expand Down

0 comments on commit 629cff6

Please sign in to comment.