From 8f45b797b6a40eec45c59af16dc822d62ce8d906 Mon Sep 17 00:00:00 2001 From: sb Date: Thu, 14 Nov 2024 10:43:22 -0500 Subject: [PATCH] rufff fixes --- HARK/algos/tests/test_vbi.py | 3 +-- HARK/algos/vbi.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/HARK/algos/tests/test_vbi.py b/HARK/algos/tests/test_vbi.py index ff15a76be..fa9b5399d 100644 --- a/HARK/algos/tests/test_vbi.py +++ b/HARK/algos/tests/test_vbi.py @@ -21,7 +21,7 @@ } ) -block_2 = DBlock( # has no control variable +block_2 = DBlock( # has no control variable **{ "name": "vbi_test_1", "shocks": { @@ -36,7 +36,6 @@ ) - class test_vbi(unittest.TestCase): # def setUp(self): # pass diff --git a/HARK/algos/vbi.py b/HARK/algos/vbi.py index 9d06712d3..3deba378b 100644 --- a/HARK/algos/vbi.py +++ b/HARK/algos/vbi.py @@ -114,7 +114,7 @@ def negated_value(a): # old! (should be negative) # negative, for minimization later return -srv_function(pre_states, dr) - if len(controls) == 0: + if len(controls) == 0: # if no controls, no optimization is necessary pass elif len(controls) == 1: @@ -123,14 +123,18 @@ def negated_value(a): # old! (should be negative) lower_bound = -1e-6 ## a really low number! feq = block.dynamics[controls[0]].lower_bound if feq is not None: - lower_bound = feq(*[pre_states[var] for var in signature(feq).parameters]) + lower_bound = feq( + *[pre_states[var] for var in signature(feq).parameters] + ) ## get upper bound ## assumes only one control currently upper_bound = 1e-12 # a very high number feq = block.dynamics[controls[0]].upper_bound if feq is not None: - upper_bound = feq(*[pre_states[var] for var in signature(feq).parameters]) + upper_bound = feq( + *[pre_states[var] for var in signature(feq).parameters] + ) bounds = ((lower_bound, upper_bound),) @@ -160,7 +164,9 @@ def negated_value(a): # old! (should be negative) 0, srv_function(pre_states, dr_best) ) elif len(controls) > 1: - raise Exception(f"Value backup iteration is not yet implemented for stages with {len(controls)} > 1 control variables.") + raise Exception( + f"Value backup iteration is not yet implemented for stages with {len(controls)} > 1 control variables." + ) # use the xarray interpolator to create a decision rule. dr_from_data = {