From 1a33be6badf25b6747de5051e7889c0102b839c6 Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 13 Nov 2023 13:20:03 -0500 Subject: [PATCH] pre-commit fixes --- HARK/core.py | 5 ++--- HARK/simulation/monte_carlo.py | 8 +++++--- HARK/simulation/test_monte_carlo.py | 6 +----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/HARK/core.py b/HARK/core.py index ab2560859..71a79e2a9 100644 --- a/HARK/core.py +++ b/HARK/core.py @@ -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 @@ -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) @@ -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( self, var_name ) diff --git a/HARK/simulation/monte_carlo.py b/HARK/simulation/monte_carlo.py index eaf544148..6ec22a196 100644 --- a/HARK/simulation/monte_carlo.py +++ b/HARK/simulation/monte_carlo.py @@ -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]): diff --git a/HARK/simulation/test_monte_carlo.py b/HARK/simulation/test_monte_carlo.py index 9b5a5dad2..bb1620c3c 100644 --- a/HARK/simulation/test_monte_carlo.py +++ b/HARK/simulation/test_monte_carlo.py @@ -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 * @@ -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) @@ -46,7 +45,6 @@ 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) @@ -54,7 +52,6 @@ def test_simulate_dynamics(self): class test_AgentTypeMonteCarloSimulator(unittest.TestCase): def setUp(self): - self.shocks = { "theta": MeanOneLogNormal(1), "agg_R": Aggregate(MeanOneLogNormal(1)), @@ -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)),