Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Jul 2, 2024
1 parent e92e249 commit 6d62587
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions HARK/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def __new__(
mu: Union[float, np.ndarray] = 0.0,
sigma: Union[float, np.ndarray] = 1.0,
seed: Optional[int] = 0,
mean = None,
std = None
mean=None,
std=None,
):
"""
Create a new Lognormal distribution. If sigma is zero, return a
Expand Down Expand Up @@ -348,8 +348,8 @@ def __init__(
mu: Union[float, np.ndarray] = 0.0,
sigma: Union[float, np.ndarray] = 1.0,
seed: Optional[int] = 0,
mean = None,
std = None
mean=None,
std=None,
):
if mean is not None and sigma is not None:
mean_squared = mean**2
Expand Down
8 changes: 6 additions & 2 deletions HARK/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def discretized_shock_dstn(shocks, disc_params):

return all_shock_dstn


def construct_shocks(shock_data, scope):
"""
Returns a dictionary from shock labels to Distributions.
Expand Down Expand Up @@ -110,12 +111,14 @@ def construct_shocks(shock_data, scope):
if isinstance(sd[v], tuple):
dist_class = sd[v][0]

dist_args = sd[v][1] # should be a dictionary
dist_args = sd[v][1] # should be a dictionary

for a in dist_args:
if isinstance(dist_args[a], str):
arg_lambda = math_text_to_lambda(dist_args[a])
arg_value = arg_lambda(*[scope[var] for var in signature(arg_lambda).parameters])
arg_value = arg_lambda(
*[scope[var] for var in signature(arg_lambda).parameters]
)

dist_args[a] = arg_value

Expand All @@ -128,6 +131,7 @@ def construct_shocks(shock_data, scope):

return sd


def simulate_dynamics(
dynamics: Mapping[str, Union[Callable, Control]],
pre: Mapping[str, Any],
Expand Down
19 changes: 8 additions & 11 deletions HARK/models/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"LivPrb": 0.98,
"PermGroFac": 1.01,
"BoroCnstArt": None,
"TranShkStd" : 0.1,
"LivPrb" : 0.98,
"RiskyStd" : 0.1
"TranShkStd": 0.1,
"LivPrb": 0.98,
"RiskyStd": 0.1,
}

consumption_block = DBlock(
**{
"name": "consumption",
"shocks": {
"live": (Bernoulli, {'p' : 'LivPrb'}), # Move to tick or mortality block?
"theta": (MeanOneLogNormal, {'sigma' : 'TranShkStd'}),
"live": (Bernoulli, {"p": "LivPrb"}), # Move to tick or mortality block?
"theta": (MeanOneLogNormal, {"sigma": "TranShkStd"}),
},
"dynamics": {
"b": lambda k, R: k * R,
Expand All @@ -44,8 +44,8 @@
**{
"name": "consumption normalized",
"shocks": {
"live": (Bernoulli, {"p" : "LivPrb"}), # Move to tick or mortality block?
"theta": (MeanOneLogNormal, {"sigma" : "TranShkStd"}),
"live": (Bernoulli, {"p": "LivPrb"}), # Move to tick or mortality block?
"theta": (MeanOneLogNormal, {"sigma": "TranShkStd"}),
},
"dynamics": {
"b": lambda k, R, PermGroFac: k * R / PermGroFac,
Expand All @@ -61,10 +61,7 @@
**{
"name": "portfolio",
"shocks": {
"risky_return": (Lognormal,{
"mean" : "Rfree + EqP",
"std" : "RiskyStd"
})
"risky_return": (Lognormal, {"mean": "Rfree + EqP", "std": "RiskyStd"})
},
"dynamics": {
"stigma": Control(["a"]),
Expand Down

0 comments on commit 6d62587

Please sign in to comment.