Skip to content

Commit

Permalink
pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Nov 13, 2023
1 parent c4feeb3 commit 1a33be6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions HARK/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
problem by finding a general equilibrium dynamic rule.
"""
# Set logging and define basic functions
# Set logging and define basic functions
import logging
import sys
from collections import defaultdict, namedtuple
Expand All @@ -29,8 +30,6 @@
from HARK.parallel import multi_thread_commands, multi_thread_commands_fake
from HARK.utilities import NullFunc, get_arg_names

# Set logging and define basic functions
import logging
logging.basicConfig(format="%(message)s")
_log = logging.getLogger("HARK")
_log.setLevel(logging.ERROR)
Expand Down Expand Up @@ -1063,7 +1062,7 @@ def simulate(self, sim_periods=None):
elif var_name in self.controls:
self.history[var_name][self.t_sim, :] = self.controls[var_name]
else:
if var_name is "who_dies" and self.t_sim > 1:
if var_name == "who_dies" and self.t_sim > 1:
self.history[var_name][self.t_sim - 1, :] = getattr(

Check warning on line 1066 in HARK/core.py

View check run for this annotation

Codecov / codecov/patch

HARK/core.py#L1066

Added line #L1066 was not covered by tests
self, var_name
)
Expand Down
8 changes: 5 additions & 3 deletions HARK/simulation/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
Functions to support Monte Carlo simulation of models.
"""
from copy import copy
from inspect import signature
from typing import Any, Callable, Mapping, Sequence, Union

import numpy as np

from HARK.distribution import (
Distribution,
IndexDistribution,
TimeVaryingDiscreteDistribution,
)
from HARK.model import Aggregate, Control
from inspect import signature
import numpy as np
from typing import Any, Callable, Mapping, Sequence, Union


def draw_shocks(shocks: Mapping[str, Distribution], conditions: Sequence[int]):
Expand Down
6 changes: 1 addition & 5 deletions HARK/simulation/test_monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import unittest

from HARK.distribution import Bernoulli, MeanOneLogNormal, IndexDistribution
from HARK.distribution import Bernoulli, IndexDistribution, MeanOneLogNormal
from HARK.model import Aggregate, Control
from HARK.simulation.monte_carlo import *

Expand Down Expand Up @@ -36,7 +36,6 @@

class test_draw_shocks(unittest.TestCase):
def test_draw_shocks(self):

drawn = draw_shocks(cons_shocks, np.array([0, 1]))

self.assertEqual(len(drawn["theta"]), 2)
Expand All @@ -46,15 +45,13 @@ def test_draw_shocks(self):

class test_simulate_dynamics(unittest.TestCase):
def test_simulate_dynamics(self):

post = simulate_dynamics(cons_dynamics, cons_pre, cons_dr)

self.assertAlmostEqual(post["cNrm"], 0.98388429)


class test_AgentTypeMonteCarloSimulator(unittest.TestCase):
def setUp(self):

self.shocks = {
"theta": MeanOneLogNormal(1),
"agg_R": Aggregate(MeanOneLogNormal(1)),
Expand Down Expand Up @@ -122,7 +119,6 @@ def test_make_shock_history(self):

class test_AgentTypeMonteCarloSimulatorAgeVariance(unittest.TestCase):
def setUp(self):

self.shocks = {
"theta": MeanOneLogNormal(1),
"agg_R": Aggregate(MeanOneLogNormal(1)),
Expand Down

0 comments on commit 1a33be6

Please sign in to comment.