taxcalc 5.1.0__py3-none-any.whl → 5.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. taxcalc/__init__.py +3 -3
  2. taxcalc/calcfunctions.py +21 -16
  3. taxcalc/calculator.py +3 -3
  4. taxcalc/cli/tc.py +15 -11
  5. taxcalc/data.py +1 -1
  6. taxcalc/decorators.py +9 -8
  7. taxcalc/growfactors.py +2 -1
  8. taxcalc/policy.py +13 -5
  9. taxcalc/policy_current_law.json +1191 -1395
  10. taxcalc/puf_ratios.csv +24 -24
  11. taxcalc/puf_weights.csv.gz +0 -0
  12. taxcalc/reforms/2017_law.json +2 -0
  13. taxcalc/reforms/ARPA.out.csv +9 -9
  14. taxcalc/taxcalcio.py +41 -26
  15. taxcalc/tests/conftest.py +1 -1
  16. taxcalc/tests/cpscsv_agg_expect.csv +26 -26
  17. taxcalc/tests/puf_var_correl_coeffs_2016.csv +24 -24
  18. taxcalc/tests/puf_var_wght_means_by_year.csv +80 -80
  19. taxcalc/tests/pufcsv_agg_expect.csv +26 -26
  20. taxcalc/tests/pufcsv_mtr_expect.txt +21 -21
  21. taxcalc/tests/reforms.json +3 -1
  22. taxcalc/tests/reforms_expect.csv +48 -48
  23. taxcalc/tests/test_4package.py +8 -9
  24. taxcalc/tests/test_calculator.py +152 -151
  25. taxcalc/tests/test_compare.py +2 -2
  26. taxcalc/tests/test_consumption.py +2 -2
  27. taxcalc/tests/test_cpscsv.py +4 -3
  28. taxcalc/tests/test_decorators.py +57 -52
  29. taxcalc/tests/test_growdiff.py +2 -2
  30. taxcalc/tests/test_parameters.py +59 -53
  31. taxcalc/tests/test_policy.py +229 -251
  32. taxcalc/tests/test_puf_var_stats.py +2 -2
  33. taxcalc/tests/test_pufcsv.py +5 -4
  34. taxcalc/tests/test_records.py +5 -1
  35. taxcalc/tests/test_reforms.py +101 -99
  36. taxcalc/tests/test_taxcalcio.py +10 -4
  37. taxcalc/utils.py +3 -3
  38. {taxcalc-5.1.0.dist-info → taxcalc-5.3.0.dist-info}/METADATA +3 -6
  39. {taxcalc-5.1.0.dist-info → taxcalc-5.3.0.dist-info}/RECORD +43 -44
  40. taxcalc/reforms/clp.out.csv +0 -10
  41. {taxcalc-5.1.0.dist-info → taxcalc-5.3.0.dist-info}/WHEEL +0 -0
  42. {taxcalc-5.1.0.dist-info → taxcalc-5.3.0.dist-info}/entry_points.txt +0 -0
  43. {taxcalc-5.1.0.dist-info → taxcalc-5.3.0.dist-info}/licenses/LICENSE +0 -0
  44. {taxcalc-5.1.0.dist-info → taxcalc-5.3.0.dist-info}/top_level.txt +0 -0
@@ -204,9 +204,9 @@ def comparison(cname, calc, cmpdata, ofile):
204
204
  vardf = add_income_table_row_variable(vardf, 'c00100', SOI_AGI_BINS)
205
205
  gbydf = vardf.groupby('table_row', as_index=False, observed=True)
206
206
  # write AGI table with ALL row at bottom of ofile
207
- ofile.write(f'TABLE for {cname.split(":")[1]}\n')
207
+ ofile.write(f"TABLE for {cname.split(':')[1]}\n")
208
208
  results = '{:23s}\t{:8.3f}\t{:8.3f}\t{:+6.1f}\n'
209
- colhead = f'{"AGIcategory":23s}\t{"T-C":>8s}\t{"SOI":>8s}\t{"%diff":>6s}\n'
209
+ colhead = f"{'AGIcategory':23s}\t{'T-C':>8s}\t{'SOI':>8s}\t{'%diff':>6s}\n"
210
210
  ofile.write(colhead)
211
211
  # pylint: disable=consider-using-f-string
212
212
  txc_tot = 0.
@@ -119,9 +119,9 @@ def test_consumption_default_data():
119
119
  pdata = consump.specification(meta_data=True, ignore_state=True)
120
120
  for pname in pdata.keys():
121
121
  if pname.startswith('MPC'):
122
- assert pdata[pname]['value'] == [{"value": 0.0, "year": 2013}]
122
+ assert pdata[pname]['value'] == [{'value': 0.0, 'year': 2013}]
123
123
  elif pname.startswith('BEN'):
124
- assert pdata[pname]['value'] == [{"value": 1.0, "year": 2013}]
124
+ assert pdata[pname]['value'] == [{'value': 1.0, 'year': 2013}]
125
125
 
126
126
 
127
127
  def test_consumption_response(cps_subsample):
@@ -25,6 +25,7 @@ from taxcalc.calculator import Calculator
25
25
 
26
26
 
27
27
  START_YEAR = 2017
28
+ NUM_YEARS = 19
28
29
 
29
30
 
30
31
  @pytest.mark.cpscsv_agg
@@ -33,7 +34,7 @@ def test_agg(tests_path, cps_fullsample):
33
34
  Test current-law aggregate taxes using cps.csv file.
34
35
  """
35
36
  # pylint: disable=too-many-statements,too-many-locals
36
- nyrs = 10
37
+ nyrs = NUM_YEARS
37
38
  # create a baseline Policy object with current-law policy parameters
38
39
  baseline_policy = Policy()
39
40
  # create a Records object (rec) containing all cps.csv input records
@@ -44,7 +45,7 @@ def test_agg(tests_path, cps_fullsample):
44
45
  calc_start_year = calc.current_year
45
46
  # create aggregate diagnostic table (adt) as a Pandas DataFrame object
46
47
  adt = calc.diagnostic_table(nyrs).round(1) # column labels are int
47
- taxes_fullsample = adt.loc["Combined Liability ($b)"]
48
+ taxes_fullsample = adt.loc['Combined Liability ($b)']
48
49
  # compare actual DataFrame, adt, with the expected DataFrame, edt
49
50
  aggres_path = os.path.join(tests_path, 'cpscsv_agg_expect.csv')
50
51
  edt = pd.read_csv(aggres_path, index_col=False) # column labels are str
@@ -75,7 +76,7 @@ def test_agg(tests_path, cps_fullsample):
75
76
  calc_subsample.advance_to_year(START_YEAR)
76
77
  adt_subsample = calc_subsample.diagnostic_table(nyrs)
77
78
  # compare combined tax liability from full and sub samples for each year
78
- taxes_subsample = adt_subsample.loc["Combined Liability ($b)"]
79
+ taxes_subsample = adt_subsample.loc['Combined Liability ($b)']
79
80
  print('taxes_submsampe = ', taxes_subsample)
80
81
  print('TAXES full sample = ', taxes_fullsample)
81
82
  msg = ''
@@ -24,20 +24,20 @@ from taxcalc.decorators import (
24
24
  def test_create_apply_function_string():
25
25
  """Test docstring"""
26
26
  ans = create_apply_function_string(['a', 'b', 'c'], ['d', 'e'], [])
27
- exp = ("def ap_func(x_0,x_1,x_2,x_3,x_4):\n"
28
- " for i in range(len(x_0)):\n"
29
- " x_0[i],x_1[i],x_2[i] = jitted_f(x_3[i],x_4[i])\n"
30
- " return x_0,x_1,x_2\n")
27
+ exp = ('def ap_func(x_0,x_1,x_2,x_3,x_4):\n'
28
+ ' for i in range(len(x_0)):\n'
29
+ ' x_0[i],x_1[i],x_2[i] = jitted_f(x_3[i],x_4[i])\n'
30
+ ' return x_0,x_1,x_2\n')
31
31
  assert ans == exp
32
32
 
33
33
 
34
34
  def test_create_apply_function_string_with_params():
35
35
  """Test docstring"""
36
36
  ans = create_apply_function_string(['a', 'b', 'c'], ['d', 'e'], ['d'])
37
- exp = ("def ap_func(x_0,x_1,x_2,x_3,x_4):\n"
38
- " for i in range(len(x_0)):\n"
39
- " x_0[i],x_1[i],x_2[i] = jitted_f(x_3,x_4[i])\n"
40
- " return x_0,x_1,x_2\n")
37
+ exp = ('def ap_func(x_0,x_1,x_2,x_3,x_4):\n'
38
+ ' for i in range(len(x_0)):\n'
39
+ ' x_0[i],x_1[i],x_2[i] = jitted_f(x_3,x_4[i])\n'
40
+ ' return x_0,x_1,x_2\n')
41
41
  assert ans == exp
42
42
 
43
43
 
@@ -45,24 +45,26 @@ def test_create_toplevel_function_string_mult_outputs():
45
45
  """Test docstring"""
46
46
  ans = create_toplevel_function_string(['a', 'b'], ['d', 'e'],
47
47
  ['pm', 'pm', 'pf', 'pm'])
48
- exp = ''
49
- exp = ("def hl_func(pm, pf):\n"
50
- " from pandas import DataFrame\n"
51
- " import numpy as np\n"
52
- " import pandas as pd\n"
53
- " def get_values(x):\n"
54
- " if isinstance(x, pd.Series):\n"
55
- " return x.values\n"
56
- " else:\n"
57
- " return x\n"
58
- " outputs = \\\n"
59
- " (pm.a, pm.b) = \\\n"
60
- " applied_f(get_values(pm.a[0]), get_values(pm.b[0]), "
61
- "get_values(pf.d), get_values(pm.e[0]), )\n"
62
- " header = ['a', 'b']\n"
63
- " return DataFrame(data=np.column_stack(outputs),"
64
- "columns=header)")
65
-
48
+ # pylint: disable=inconsistent-quotes
49
+ exp = (
50
+ "def hl_func(pm, pf):\n"
51
+ " from pandas import DataFrame\n"
52
+ " import numpy as np\n"
53
+ " import pandas as pd\n"
54
+ " def get_values(x):\n"
55
+ " if isinstance(x, pd.Series):\n"
56
+ " return x.values\n"
57
+ " else:\n"
58
+ " return x\n"
59
+ " outputs = \\\n"
60
+ " (pm.a, pm.b) = \\\n"
61
+ " applied_f(get_values(pm.a[0]), get_values(pm.b[0]), "
62
+ "get_values(pf.d), get_values(pm.e[0]), )\n"
63
+ " header = ['a', 'b']\n"
64
+ " return DataFrame(data=np.column_stack(outputs),"
65
+ "columns=header)"
66
+ )
67
+ # pylint: enable=inconsistent-quotes
66
68
  assert ans == exp
67
69
 
68
70
 
@@ -70,23 +72,26 @@ def test_create_toplevel_function_string():
70
72
  """Test docstring"""
71
73
  ans = create_toplevel_function_string(['a'], ['d', 'e'],
72
74
  ['pm', 'pf', 'pm'])
73
- exp = ''
74
- exp = ("def hl_func(pm, pf):\n"
75
- " from pandas import DataFrame\n"
76
- " import numpy as np\n"
77
- " import pandas as pd\n"
78
- " def get_values(x):\n"
79
- " if isinstance(x, pd.Series):\n"
80
- " return x.values\n"
81
- " else:\n"
82
- " return x\n"
83
- " outputs = \\\n"
84
- " (pm.a) = \\\n"
85
- " applied_f(get_values(pm.a[0]), get_values(pf.d), "
86
- "get_values(pm.e[0]), )\n"
87
- " header = ['a']\n"
88
- " return DataFrame(data=outputs,"
89
- "columns=header)")
75
+ # pylint: disable=inconsistent-quotes
76
+ exp = (
77
+ "def hl_func(pm, pf):\n"
78
+ " from pandas import DataFrame\n"
79
+ " import numpy as np\n"
80
+ " import pandas as pd\n"
81
+ " def get_values(x):\n"
82
+ " if isinstance(x, pd.Series):\n"
83
+ " return x.values\n"
84
+ " else:\n"
85
+ " return x\n"
86
+ " outputs = \\\n"
87
+ " (pm.a) = \\\n"
88
+ " applied_f(get_values(pm.a[0]), get_values(pf.d), "
89
+ "get_values(pm.e[0]), )\n"
90
+ " header = ['a']\n"
91
+ " return DataFrame(data=outputs,"
92
+ "columns=header)"
93
+ )
94
+ # pylint: enable=inconsistent-quotes
90
95
  assert ans == exp
91
96
 
92
97
 
@@ -107,7 +112,7 @@ def test_make_apply_function():
107
112
  assert ans_no_jit
108
113
 
109
114
 
110
- @apply_jit(["a", "b"], ["x", "y", "z"], nopython=True)
115
+ @apply_jit(['a', 'b'], ['x', 'y', 'z'], nopython=True)
111
116
  def magic_calc(x, y, z):
112
117
  """Function docstring"""
113
118
  a = x + y
@@ -178,7 +183,7 @@ def test_magic_apply_jit():
178
183
  pf.y = np.ones((5,))
179
184
  pf.z = np.ones((5,))
180
185
  xx = magic(pm, pf)
181
- exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=["a", "b"])
186
+ exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=['a', 'b'])
182
187
  assert_frame_equal(xx, exp)
183
188
 
184
189
 
@@ -192,7 +197,7 @@ def test_magic_apply_jit_swap():
192
197
  pf.y = np.ones((5,))
193
198
  pf.z = np.ones((5,))
194
199
  xx = magic(pf, pm) # pylint: disable=arguments-out-of-order
195
- exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=["a", "b"])
200
+ exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=['a', 'b'])
196
201
  assert_frame_equal(xx, exp)
197
202
 
198
203
 
@@ -209,7 +214,7 @@ def test_magic_iterate_jit():
209
214
  pf.y = np.ones((5,))
210
215
  pf.z = np.ones((5,))
211
216
  xx = magic_calc2(pm, pf)
212
- exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=["a", "b"])
217
+ exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=['a', 'b'])
213
218
  assert_frame_equal(xx, exp)
214
219
 
215
220
 
@@ -236,7 +241,7 @@ def test_ret_everything_iterate_jit():
236
241
  pf.f = np.ones((5,))
237
242
  ans = ret_everything(pm, pf)
238
243
  exp = DataFrame(data=[[2.0, 2.0, 2.0, 2.0]] * 5,
239
- columns=["c", "d", "e", "f"])
244
+ columns=['c', 'd', 'e', 'f'])
240
245
  assert_frame_equal(ans, exp)
241
246
 
242
247
 
@@ -259,7 +264,7 @@ def test_function_takes_kwarg():
259
264
  pf.z = np.ones((5,))
260
265
  ans = magic_calc3(pm, pf)
261
266
  exp = DataFrame(data=[[2.0, 3.0]] * 5,
262
- columns=["a", "b"])
267
+ columns=['a', 'b'])
263
268
  assert_frame_equal(ans, exp)
264
269
 
265
270
 
@@ -282,7 +287,7 @@ def test_function_no_parameters_listed():
282
287
  pf.z = np.ones((5,))
283
288
  ans = magic_calc4(pm, pf)
284
289
  exp = DataFrame(data=[[2.0, 3.0]] * 5,
285
- columns=["a", "b"])
290
+ columns=['a', 'b'])
286
291
  assert_frame_equal(ans, exp)
287
292
 
288
293
 
@@ -306,7 +311,7 @@ def test_function_parameters_optional():
306
311
  pf.z = np.ones((5,))
307
312
  ans = magic_calc5(pm, pf)
308
313
  exp = DataFrame(data=[[2.0, 4.0]] * 5,
309
- columns=["a", "b"])
314
+ columns=['a', 'b'])
310
315
  assert_frame_equal(ans, exp)
311
316
 
312
317
 
@@ -377,7 +382,7 @@ def test_force_no_jit():
377
382
  pf.z = np.ones((5,))
378
383
  ans = magic_calc6_(pm, pf)
379
384
  exp = DataFrame(data=[[2.0, 4.0]] * 5,
380
- columns=["a", "b"])
385
+ columns=['a', 'b'])
381
386
  assert_frame_equal(ans, exp)
382
387
  # restore normal JIT operation of decorators module
383
388
  del os.environ['NOTAXCALCJIT']
@@ -67,7 +67,7 @@ def test_description_punctuation(tests_path):
67
67
  dct = json.load(jsonfile)
68
68
  all_desc_ok = True
69
69
  for param in dct.keys():
70
- if param == "schema":
70
+ if param == 'schema':
71
71
  continue
72
72
  if not dct[param]['description'].endswith('.'):
73
73
  all_desc_ok = False
@@ -86,7 +86,7 @@ def test_boolean_value_infomation(tests_path):
86
86
  with open(path, 'r', encoding='utf-8') as gddfile:
87
87
  gdd = json.load(gddfile)
88
88
  for param in gdd.keys():
89
- if param == "schema":
89
+ if param == 'schema':
90
90
  continue
91
91
  val = gdd[param]['value']
92
92
  if isinstance(val, list):
@@ -86,13 +86,13 @@ PARAMS_JSON = json.dumps({
86
86
  })
87
87
 
88
88
 
89
- @pytest.fixture(scope='module', name='params_json_file')
89
+ @pytest.fixture(scope="module", name="params_json_file")
90
90
  def fixture_params_json_file():
91
91
  """
92
92
  Define JSON DEFAULTS file for Parameters-derived Params class.
93
93
  """
94
- with tempfile.NamedTemporaryFile(mode='a', delete=False) as pfile:
95
- pfile.write(PARAMS_JSON + '\n')
94
+ with tempfile.NamedTemporaryFile(mode="a", delete=False) as pfile:
95
+ pfile.write(PARAMS_JSON + "\n")
96
96
  pfile.close()
97
97
  yield pfile
98
98
  os.remove(pfile.name)
@@ -100,22 +100,22 @@ def fixture_params_json_file():
100
100
 
101
101
  @pytest.mark.parametrize("revision, expect", [
102
102
  ({}, ""),
103
- ({'real_param': {2004: 1.9}}, "error"),
104
- ({'int_param': {2004: [3.6]}}, "raise"),
103
+ ({"real_param": {2004: 1.9}}, "error"),
104
+ ({"int_param": {2004: [3.6]}}, "raise"),
105
105
  ({"int_param": {2004: [3]}}, "raise"),
106
106
  ({"label_param": {2004: [1, 2]}}, "noerror"),
107
107
  ({"label_param": {2004: [[1, 2]]}}, "raise"),
108
108
  ({"label_param": {2004: [1, 2, 3]}}, "raise"),
109
- ({'bool_param': {2004: [4.9]}}, "raise"),
110
- ({'str_param': {2004: [9]}}, "raise"),
111
- ({'str_param': {2004: 'nonlinear'}}, "noerror"),
112
- ({'str_param': {2004: 'unknownvalue'}}, "error"),
113
- ({'str_param': {2004: ['nonlinear']}}, "raise"),
114
- ({'real_param': {2004: 'linear'}}, "raise"),
115
- ({'real_param': {2004: [0.2, 0.3]}}, "raise"),
116
- ({'removed_param': {2004: 0.1}}, "raise"),
117
- ({'real_param-indexed': {2004: True}}, "raise"),
118
- ({'unknown_param-indexed': {2004: False}}, "raise")
109
+ ({"bool_param": {2004: [4.9]}}, "raise"),
110
+ ({"str_param": {2004: [9]}}, "raise"),
111
+ ({"str_param": {2004: "nonlinear"}}, "noerror"),
112
+ ({"str_param": {2004: "unknownvalue"}}, "error"),
113
+ ({"str_param": {2004: ["nonlinear"]}}, "raise"),
114
+ ({"real_param": {2004: "linear"}}, "raise"),
115
+ ({"real_param": {2004: [0.2, 0.3]}}, "raise"),
116
+ ({"removed_param": {2004: 0.1}}, "raise"),
117
+ ({"real_param-indexed": {2004: True}}, "raise"),
118
+ ({"unknown_param-indexed": {2004: False}}, "raise")
119
119
  ])
120
120
  def test_params_class(revision, expect, params_json_file):
121
121
  """
@@ -129,12 +129,12 @@ def test_params_class(revision, expect, params_json_file):
129
129
  # pylint: disable=abstract-method
130
130
 
131
131
  DEFAULTS_FILE_NAME = params_json_file.name
132
- DEFAULTS_FILE_PATH = ''
132
+ DEFAULTS_FILE_PATH = ""
133
133
  START_YEAR = 2001
134
134
  LAST_YEAR = 2010
135
135
  NUM_YEARS = LAST_YEAR - START_YEAR + 1
136
136
  REMOVED_PARAMS = {
137
- 'removed_param': 'has been removed'
137
+ "removed_param": "has been removed"
138
138
  }
139
139
 
140
140
  def __init__(self):
@@ -169,17 +169,17 @@ def test_params_class(revision, expect, params_json_file):
169
169
  prms.set_year(2011)
170
170
  return
171
171
 
172
- if expect == 'raise':
172
+ if expect == "raise":
173
173
  with pytest.raises(paramtools.ValidationError):
174
174
  prms.update_params(revision)
175
- elif expect == 'noerror':
175
+ elif expect == "noerror":
176
176
  prms.update_params(revision)
177
177
  assert not prms.errors
178
- elif expect == 'error':
178
+ elif expect == "error":
179
179
  with pytest.raises(paramtools.ValidationError):
180
180
  prms.update_params(revision)
181
181
  assert prms.errors
182
- elif expect == 'warn':
182
+ elif expect == "warn":
183
183
  with pytest.raises(paramtools.ValidationError):
184
184
  prms.update_params(revision)
185
185
  assert prms.warnings
@@ -198,9 +198,9 @@ def test_json_file_contents(tests_path, fname):
198
198
  last_known_year = Policy.LAST_KNOWN_YEAR # for indexed parameter values
199
199
  known_years = set(range(first_year, last_known_year + 1))
200
200
  # check elements in each parameter sub-dictionary
201
- failures = ''
201
+ failures = ""
202
202
  path = os.path.join(tests_path, "..", fname)
203
- with open(path, 'r', encoding='utf-8') as f:
203
+ with open(path, "r", encoding="utf-8") as f:
204
204
  allparams = json.loads(f.read())
205
205
  for pname in allparams:
206
206
  if pname == "schema":
@@ -208,31 +208,37 @@ def test_json_file_contents(tests_path, fname):
208
208
  # check that param contains required keys
209
209
  param = allparams[pname]
210
210
  # check that indexable and indexed are False in many files
211
- if fname != 'policy_current_law.json':
212
- assert param.get('indexable', False) is False
213
- assert param.get('indexed', False) is False
211
+ if fname != "policy_current_law.json":
212
+ assert param.get("indexable", False) is False
213
+ assert param.get("indexed", False) is False
214
214
  # check that indexable is True when indexed is True
215
- if param.get('indexed', False) and not param.get('indexable', False):
215
+ if param.get("indexed", False) and not param.get("indexable", False):
216
+ pindexed = param.get("indexed", False)
217
+ pindexable = param.get("indexable", False)
216
218
  msg = (
217
- f'param:<{pname}>; '
218
- f'indexed={param.get("indexed", False)}; '
219
- f'indexable={param.get("indexable", False)}\n'
219
+ f"param:<{pname}>; "
220
+ f"indexed={pindexed}; "
221
+ f"indexable={pindexable}\n"
220
222
  )
221
223
  failures += msg
222
224
  # check that indexable param has value_type float
223
- if param.get('indexable', False) and param['type'] != 'float':
225
+ if param.get("indexable", False) and param["type"] != "float":
226
+ ptype = param["type"]
227
+ pindexable = param.get("indexable", False)
224
228
  msg = (
225
- f'param:<{pname}>; '
226
- f'type={param["type"]}; '
227
- f'indexable={param.get("indexable", False)}\n'
229
+ f"param:<{pname}>; "
230
+ f"type={ptype}; "
231
+ f"indexable={pindexable}\n"
228
232
  )
229
233
  failures += msg
230
234
  # ensure that indexable is False when value_type is not real
231
- if param.get('indexable', False) and param['type'] != 'float':
235
+ if param.get("indexable", False) and param["type"] != "float":
236
+ pindexable = param.get("indexable", False)
237
+ ptype = param["value_type"]
232
238
  msg = (
233
- f'param:<{pname}>; '
234
- f'indexable={param.get("indexable", False)}; '
235
- f'type={param["value_type"]}\n'
239
+ f"param:<{pname}>; "
240
+ f"indexable={pindexable}; "
241
+ f"type={ptype}\n"
236
242
  )
237
243
  failures += msg
238
244
  o = None
@@ -250,7 +256,7 @@ def test_json_file_contents(tests_path, fname):
250
256
  for y in known_years:
251
257
  o.set_year(y)
252
258
  if np.isnan(getattr(o, param)).any():
253
- msg = f'param:<{param}>; not found in year={y}\n'
259
+ msg = f"param:<{param}>; not found in year={y}\n"
254
260
  failures += msg
255
261
  if failures:
256
262
  raise ValueError(failures)
@@ -265,28 +271,28 @@ def test_parameters_mentioned(tests_path, jfname, pfname):
265
271
  Make sure each JSON parameter is mentioned in PYTHON code file.
266
272
  """
267
273
  # read JSON parameter file into a dictionary
268
- path = os.path.join(tests_path, '..', jfname)
269
- with open(path, 'r', encoding='utf-8') as pfile:
274
+ path = os.path.join(tests_path, "..", jfname)
275
+ with open(path, "r", encoding="utf-8") as pfile:
270
276
  allparams = json.load(pfile)
271
277
  assert isinstance(allparams, dict)
272
278
  # read PYTHON code file text
273
279
  # pylint: disable=consider-using-join
274
- if pfname == 'consumption.py':
280
+ if pfname == "consumption.py":
275
281
  # consumption.py does not explicitly name the parameters
276
- code_text = ''
282
+ code_text = ""
277
283
  for var in Consumption.RESPONSE_VARS:
278
- code_text += f'MPC_{var}\n'
284
+ code_text += f"MPC_{var}\n"
279
285
  for var in Consumption.BENEFIT_VARS:
280
- code_text += f'BEN_{var}_value\n'
281
- elif pfname == 'growdiff.py':
286
+ code_text += f"BEN_{var}_value\n"
287
+ elif pfname == "growdiff.py":
282
288
  # growdiff.py does not explicitly name the parameters
283
- code_text = ''
289
+ code_text = ""
284
290
  for var in GrowFactors.VALID_NAMES:
285
- code_text += f'{var}\n'
291
+ code_text += f"{var}\n"
286
292
  else:
287
293
  # parameters are explicitly named in PYTHON file
288
- path = os.path.join(tests_path, '..', pfname)
289
- with open(path, 'r', encoding='utf-8') as pfile:
294
+ path = os.path.join(tests_path, "..", pfname)
295
+ with open(path, "r", encoding="utf-8") as pfile:
290
296
  code_text = pfile.read()
291
297
  # check that each param (without leading _) is mentioned in code text
292
298
  for pname in allparams:
@@ -491,7 +497,7 @@ def test_expand_2d_variable_rates():
491
497
  for i in range(0, 4):
492
498
  idx = i + len(ary) - 1
493
499
  cur = np.array(cur * (1.0 + irates[idx]))
494
- print('cur is ', cur)
500
+ print("cur is ", cur)
495
501
  exp2.append(cur)
496
502
  exp1 = np.array([1., 2., 3., 4.])
497
503
  exp = np.zeros((5, 4))
@@ -597,13 +603,13 @@ def test_read_json_revision(good_revision):
597
603
  # pllint: disable=private-method
598
604
  with pytest.raises(TypeError):
599
605
  # error because first obj argument is neither None nor a string
600
- Parameters._read_json_revision([], '')
606
+ Parameters._read_json_revision([], "")
601
607
  with pytest.raises(ValueError):
602
608
  # error because second topkey argument must be a string
603
609
  Parameters._read_json_revision(good_revision, 999)
604
610
  with pytest.raises(ValueError):
605
611
  # error because second topkey argument is not in good_revision
606
- Parameters._read_json_revision(good_revision, 'unknown_topkey')
612
+ Parameters._read_json_revision(good_revision, "unknown_topkey")
607
613
 
608
614
 
609
615
  @pytest.mark.parametrize("params,is_paramtools", [