taxcalc 4.4.0__py3-none-any.whl → 4.5.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 (57) hide show
  1. taxcalc/__init__.py +1 -1
  2. taxcalc/calcfunctions.py +326 -171
  3. taxcalc/calculator.py +35 -34
  4. taxcalc/cli/tc.py +6 -7
  5. taxcalc/consumption.json +1 -1
  6. taxcalc/consumption.py +9 -4
  7. taxcalc/cps_weights.csv.gz +0 -0
  8. taxcalc/data.py +8 -8
  9. taxcalc/decorators.py +3 -3
  10. taxcalc/growdiff.json +1 -1
  11. taxcalc/growdiff.py +5 -0
  12. taxcalc/growfactors.csv +26 -25
  13. taxcalc/growfactors.py +1 -1
  14. taxcalc/parameters.py +85 -42
  15. taxcalc/policy.py +2 -2
  16. taxcalc/policy_current_law.json +87 -87
  17. taxcalc/puf_ratios.csv +15 -14
  18. taxcalc/puf_weights.csv.gz +0 -0
  19. taxcalc/records.py +1 -0
  20. taxcalc/records_variables.json +6 -0
  21. taxcalc/reforms/ext.json +21 -21
  22. taxcalc/taxcalcio.py +49 -44
  23. taxcalc/tests/cmpi_cps_expect.txt +6 -6
  24. taxcalc/tests/cmpi_puf_expect.txt +6 -6
  25. taxcalc/tests/conftest.py +43 -42
  26. taxcalc/tests/cpscsv_agg_expect.csv +22 -22
  27. taxcalc/tests/puf_var_wght_means_by_year.csv +70 -70
  28. taxcalc/tests/pufcsv_agg_expect.csv +22 -22
  29. taxcalc/tests/test_4package.py +9 -7
  30. taxcalc/tests/test_benefits.py +9 -8
  31. taxcalc/tests/test_calcfunctions.py +55 -38
  32. taxcalc/tests/test_calculator.py +11 -6
  33. taxcalc/tests/test_compare.py +45 -51
  34. taxcalc/tests/test_compatible_data.py +9 -7
  35. taxcalc/tests/test_consumption.py +38 -18
  36. taxcalc/tests/test_cpscsv.py +33 -31
  37. taxcalc/tests/test_data.py +31 -24
  38. taxcalc/tests/test_decorators.py +84 -32
  39. taxcalc/tests/test_growdiff.py +16 -13
  40. taxcalc/tests/test_growfactors.py +8 -8
  41. taxcalc/tests/test_parameters.py +55 -59
  42. taxcalc/tests/test_policy.py +14 -12
  43. taxcalc/tests/test_puf_var_stats.py +14 -14
  44. taxcalc/tests/test_pufcsv.py +40 -40
  45. taxcalc/tests/test_records.py +73 -60
  46. taxcalc/tests/test_reforms.py +35 -32
  47. taxcalc/tests/test_responses.py +4 -4
  48. taxcalc/tests/test_taxcalcio.py +76 -62
  49. taxcalc/tests/test_utils.py +78 -46
  50. taxcalc/utils.py +49 -42
  51. taxcalc/validation/taxsim35/taxsim_emulation.json +1 -5
  52. {taxcalc-4.4.0.dist-info → taxcalc-4.5.0.dist-info}/METADATA +19 -5
  53. {taxcalc-4.4.0.dist-info → taxcalc-4.5.0.dist-info}/RECORD +57 -57
  54. {taxcalc-4.4.0.dist-info → taxcalc-4.5.0.dist-info}/WHEEL +1 -1
  55. {taxcalc-4.4.0.dist-info → taxcalc-4.5.0.dist-info}/LICENSE +0 -0
  56. {taxcalc-4.4.0.dist-info → taxcalc-4.5.0.dist-info}/entry_points.txt +0 -0
  57. {taxcalc-4.4.0.dist-info → taxcalc-4.5.0.dist-info}/top_level.txt +0 -0
@@ -1,18 +1,24 @@
1
+ """
2
+ Test Consumption class and its methods.
3
+ """
1
4
  # CODING-STYLE CHECKS:
2
5
  # pycodestyle test_consumption.py
6
+ # pylint --disable=locally-disabled test_consumption.py
3
7
 
8
+ import copy
4
9
  import numpy as np
5
- import paramtools
6
10
  import pytest
7
- import copy
11
+ import paramtools
8
12
  from taxcalc import Policy, Records, Calculator, Consumption
9
13
 
10
14
 
11
15
  def test_start_year_consistency():
16
+ """Test docstring"""
12
17
  assert Consumption.JSON_START_YEAR == Policy.JSON_START_YEAR
13
18
 
14
19
 
15
20
  def test_validity_of_consumption_vars_set():
21
+ """Test docstring"""
16
22
  records_varinfo = Records(data=None)
17
23
  assert Consumption.RESPONSE_VARS.issubset(records_varinfo.USABLE_READ_VARS)
18
24
  useable_vars = set(['housing', 'snap', 'tanf', 'vet', 'wic',
@@ -21,6 +27,7 @@ def test_validity_of_consumption_vars_set():
21
27
 
22
28
 
23
29
  def test_update_consumption():
30
+ """Test docstring"""
24
31
  consump = Consumption()
25
32
  consump.update_consumption({})
26
33
  revision = {
@@ -33,21 +40,29 @@ def test_update_consumption():
33
40
  expected_mpc_e20400 = np.full((consump.num_years,), 0.06)
34
41
  expected_mpc_e20400[0] = 0.0
35
42
  expected_mpc_e20400[1] = 0.05
36
- assert np.allclose(consump._MPC_e20400,
37
- expected_mpc_e20400,
38
- rtol=0.0)
39
- assert np.allclose(consump._MPC_e17500,
40
- np.zeros((consump.num_years,)),
41
- rtol=0.0)
43
+ assert np.allclose(
44
+ consump._MPC_e20400, # pylint: disable=protected-access
45
+ expected_mpc_e20400,
46
+ rtol=0.0
47
+ )
48
+ assert np.allclose(
49
+ consump._MPC_e17500, # pylint: disable=protected-access
50
+ np.zeros((consump.num_years,)),
51
+ rtol=0.0
52
+ )
42
53
  expected_ben_mcare_value = np.full((consump.num_years,), 0.80)
43
54
  expected_ben_mcare_value[0] = 1.0
44
55
  expected_ben_mcare_value[1] = 0.75
45
- assert np.allclose(consump._BEN_mcare_value,
46
- expected_ben_mcare_value,
47
- rtol=0.0)
48
- assert np.allclose(consump._BEN_snap_value,
49
- np.ones((consump.num_years,)),
50
- rtol=0.0)
56
+ assert np.allclose(
57
+ consump._BEN_mcare_value, # pylint: disable=protected-access
58
+ expected_ben_mcare_value,
59
+ rtol=0.0
60
+ )
61
+ assert np.allclose(
62
+ consump._BEN_snap_value, # pylint: disable=protected-access
63
+ np.ones((consump.num_years,)),
64
+ rtol=0.0
65
+ )
51
66
  consump.set_year(2015)
52
67
  assert consump.current_year == 2015
53
68
  assert consump.MPC_e20400 == 0.06
@@ -57,6 +72,7 @@ def test_update_consumption():
57
72
 
58
73
 
59
74
  def test_incorrect_update_consumption():
75
+ """Test docstring"""
60
76
  with pytest.raises(paramtools.ValidationError):
61
77
  Consumption().update_consumption([])
62
78
  with pytest.raises(paramtools.ValidationError):
@@ -74,6 +90,7 @@ def test_incorrect_update_consumption():
74
90
 
75
91
 
76
92
  def test_future_update_consumption():
93
+ """Test docstring"""
77
94
  consump = Consumption()
78
95
  assert consump.current_year == consump.start_year
79
96
  assert consump.has_response() is False
@@ -97,6 +114,7 @@ def test_future_update_consumption():
97
114
 
98
115
 
99
116
  def test_consumption_default_data():
117
+ """Test docstring"""
100
118
  consump = Consumption()
101
119
  pdata = consump.specification(meta_data=True, ignore_state=True)
102
120
  for pname in pdata.keys():
@@ -107,24 +125,26 @@ def test_consumption_default_data():
107
125
 
108
126
 
109
127
  def test_consumption_response(cps_subsample):
128
+ """Test docstring"""
129
+ # pylint: disable=too-many-locals
110
130
  consump = Consumption()
111
131
  mpc = 0.5
112
132
  consumption_response = {'MPC_e20400': {2013: mpc}}
113
133
  consump.update_consumption(consumption_response)
114
134
  # test incorrect call to response method
115
135
  with pytest.raises(ValueError):
116
- consump.response(list(), 1)
136
+ consump.response([], 1)
117
137
  # test correct call to response method
118
138
  rec = Records.cps_constructor(data=cps_subsample)
119
- pre = copy.deepcopy(rec.e20400)
139
+ pre = copy.deepcopy(getattr(rec, 'e20400'))
120
140
  consump.response(rec, 1.0)
121
- post = rec.e20400
141
+ post = getattr(rec, 'e20400')
122
142
  actual_diff = post - pre
123
143
  expected_diff = np.ones(rec.array_length) * mpc
124
144
  assert np.allclose(actual_diff, expected_diff)
125
145
  # compute earnings mtr with no consumption response
126
146
  rec = Records.cps_constructor(data=cps_subsample)
127
- ided0 = copy.deepcopy(rec.e20400)
147
+ ided0 = copy.deepcopy(getattr(rec, 'e20400'))
128
148
  calc0 = Calculator(policy=Policy(), records=rec, consumption=None)
129
149
  (mtr0_ptax, mtr0_itax, _) = calc0.mtr(variable_str='e00200p',
130
150
  wrt_full_compensation=False)
@@ -17,8 +17,11 @@ import json
17
17
  import pytest
18
18
  import numpy as np
19
19
  import pandas as pd
20
- # pylint: disable=import-error
21
- from taxcalc import GrowFactors, GrowDiff, Policy, Records, Calculator
20
+ from taxcalc.growfactors import GrowFactors
21
+ from taxcalc.growdiff import GrowDiff
22
+ from taxcalc.policy import Policy
23
+ from taxcalc.records import Records
24
+ from taxcalc.calculator import Calculator
22
25
 
23
26
 
24
27
  START_YEAR = 2017
@@ -52,7 +55,7 @@ def test_agg(tests_path, cps_fullsample):
52
55
  if not np.allclose(adt[icol], edt[str(icol)]):
53
56
  diffs = True
54
57
  if diffs:
55
- new_filename = '{}{}'.format(aggres_path[:-10], 'actual.csv')
58
+ new_filename = f'{aggres_path[:-10]}actual.csv'
56
59
  adt.to_csv(new_filename, float_format='%.1f')
57
60
  msg = 'CPSCSV AGG RESULTS DIFFER\n'
58
61
  msg += '-------------------------------------------------\n'
@@ -65,7 +68,7 @@ def test_agg(tests_path, cps_fullsample):
65
68
  raise ValueError(msg)
66
69
  # create aggregate diagnostic table using unweighted sub-sample of records
67
70
  rn_seed = 180 # to ensure sub-sample is always the same
68
- subfrac = 0.07# 0.03 # sub-sample fraction
71
+ subfrac = 0.07 # sub-sample fraction
69
72
  subsample = cps_fullsample.sample(frac=subfrac, random_state=rn_seed)
70
73
  recs_subsample = Records.cps_constructor(data=subsample)
71
74
  calc_subsample = Calculator(policy=baseline_policy, records=recs_subsample)
@@ -84,14 +87,17 @@ def test_agg(tests_path, cps_fullsample):
84
87
  if not np.allclose(taxes_subsample[cyr], taxes_fullsample[cyr],
85
88
  atol=0.0, rtol=reltol):
86
89
  reldiff = (taxes_subsample[cyr] / taxes_fullsample[cyr]) - 1.
87
- line1 = '\nCPSCSV AGG SUB-vs-FULL RESULTS DIFFER IN {}'
88
- line2 = '\n when subfrac={:.3f}, rtol={:.4f}, seed={}'
89
- line3 = '\n with sub={:.3f}, full={:.3f}, rdiff={:.4f}'
90
- msg += line1.format(cyr)
91
- msg += line2.format(subfrac, reltol, rn_seed)
92
- msg += line3.format(taxes_subsample[cyr],
93
- taxes_fullsample[cyr],
94
- reldiff)
90
+ line1 = f'\nCPSCSV AGG SUB-vs-FULL RESULTS DIFFER IN {cyr}'
91
+ line2 = (
92
+ f'\n when subfrac={subfrac:.3f}, rtol={reltol:.4f}, '
93
+ f'seed={rn_seed}'
94
+ )
95
+ line3 = (
96
+ f'\n with sub={taxes_subsample[cyr]:.3f}, '
97
+ f'full={taxes_fullsample[cyr]:.3f}, '
98
+ f'rdiff={reldiff:.4f}'
99
+ )
100
+ msg += line1 + line2 + line3
95
101
  if msg:
96
102
  raise ValueError(msg)
97
103
 
@@ -104,7 +110,7 @@ def test_cps_availability(tests_path, cps_path):
104
110
  cpsvars = set(list(cpsdf))
105
111
  # make set of variable names that are marked as cps.csv available
106
112
  rvpath = os.path.join(tests_path, '..', 'records_variables.json')
107
- with open(rvpath, 'r') as rvfile:
113
+ with open(rvpath, 'r', encoding='utf-8') as rvfile:
108
114
  rvdict = json.load(rvfile)
109
115
  recvars = set()
110
116
  for vname, vdict in rvdict['read'].items():
@@ -142,24 +148,20 @@ def nonsmall_diffs(linelist1, linelist2, small=0.0):
142
148
  for line1, line2 in zip(linelist1, linelist2):
143
149
  if line1 == line2:
144
150
  continue
145
- else:
146
- tokens1 = line1.replace(',', '').split()
147
- tokens2 = line2.replace(',', '').split()
148
- for tok1, tok2 in zip(tokens1, tokens2):
149
- tok1_isfloat = isfloat(tok1)
150
- tok2_isfloat = isfloat(tok2)
151
- if tok1_isfloat and tok2_isfloat:
152
- if abs(float(tok1) - float(tok2)) <= smallamt:
153
- continue
154
- else:
155
- return True
156
- elif not tok1_isfloat and not tok2_isfloat:
157
- if tok1 == tok2:
158
- continue
159
- else:
160
- return True
161
- else:
162
- return True
151
+ tokens1 = line1.replace(',', '').split()
152
+ tokens2 = line2.replace(',', '').split()
153
+ for tok1, tok2 in zip(tokens1, tokens2):
154
+ tok1_isfloat = isfloat(tok1)
155
+ tok2_isfloat = isfloat(tok2)
156
+ if tok1_isfloat and tok2_isfloat:
157
+ if abs(float(tok1) - float(tok2)) <= smallamt:
158
+ continue
159
+ return True
160
+ if not tok1_isfloat and not tok2_isfloat:
161
+ if tok1 == tok2:
162
+ continue
163
+ return True
164
+ return True
163
165
  return False
164
166
 
165
167
 
@@ -1,5 +1,9 @@
1
+ """
2
+ Test Data class and its methods.
3
+ """
1
4
  # CODING-STYLE CHECKS:
2
5
  # pycodestyle test_data.py
6
+ # pylint --disable=locally-disabled test_data.py
3
7
 
4
8
  import os
5
9
  import tempfile
@@ -75,14 +79,17 @@ def test_recs_class(recs_varinfo_file, cps_subsample):
75
79
  super().__init__(data, start_year, gfactors, weights)
76
80
 
77
81
  def _extrapolate(self, year):
78
- self.e00300 *= self.gfactors.factor_value('AINTS', year)
82
+ val = getattr(self, 'e00300')
83
+ setattr(
84
+ self, 'e00300', val * self.gfactors.factor_value('AINTS', year)
85
+ )
79
86
 
80
- # test Recs class for incorrect instantiation
87
+ # test Recs class for incorrect instantiation:
81
88
  with pytest.raises(ValueError):
82
- Recs(data=list(), start_year=2000,
89
+ Recs(data=[], start_year=2000,
83
90
  gfactors=None, weights=None)
84
91
  with pytest.raises(ValueError):
85
- Recs(data=cps_subsample, start_year=list(),
92
+ Recs(data=cps_subsample, start_year=[],
86
93
  gfactors=None, weights=None)
87
94
  with pytest.raises(ValueError):
88
95
  Recs(data=cps_subsample, start_year=2000,
@@ -93,19 +100,18 @@ def test_recs_class(recs_varinfo_file, cps_subsample):
93
100
  with pytest.raises(ValueError):
94
101
  Recs(data=cps_subsample, start_year=2000,
95
102
  gfactors='', weights='')
96
- # test Recs class for correct instantiation with no aging of data
103
+ # test Recs class for correct instantiation with no aging of data:
97
104
  syr = 2014
98
105
  rec = Recs(data=cps_subsample, start_year=syr,
99
106
  gfactors=None, weights=None)
100
- assert isinstance(rec, Recs)
101
- assert np.all(rec.MARS != 0)
102
- assert rec.data_year == syr
103
- assert rec.current_year == syr
104
- sum_e00300_in_syr = rec.e00300.sum()
107
+ assert np.all(getattr(rec, 'MARS') != 0)
108
+ assert getattr(rec, 'data_year') == syr
109
+ assert getattr(rec, 'current_year') == syr
110
+ sum_e00300_in_syr = getattr(rec, 'e00300').sum()
105
111
  rec.increment_year()
106
- assert rec.data_year == syr
107
- assert rec.current_year == syr + 1
108
- sum_e00300_in_syr_plus_one = rec.e00300.sum()
112
+ assert getattr(rec, 'data_year') == syr
113
+ assert getattr(rec, 'current_year') == syr + 1
114
+ sum_e00300_in_syr_plus_one = getattr(rec, 'e00300').sum()
109
115
  assert np.allclose([sum_e00300_in_syr], [sum_e00300_in_syr_plus_one])
110
116
  del rec
111
117
  # test Recs class for correct instantiation with aging of data
@@ -114,20 +120,21 @@ def test_recs_class(recs_varinfo_file, cps_subsample):
114
120
  rec = Recs(data=cps_subsample, start_year=syr,
115
121
  gfactors=GrowFactors(), weights=wghts_df)
116
122
  assert isinstance(rec, Recs)
117
- assert np.all(rec.MARS != 0)
118
- assert rec.data_year == syr
119
- assert rec.current_year == syr
120
- sum_s006_in_syr = rec.s006.sum()
121
- sum_e00300_in_syr = rec.e00300.sum()
123
+ assert np.all(getattr(rec, 'MARS') != 0)
124
+ assert getattr(rec, 'data_year') == syr
125
+ assert getattr(rec, 'current_year') == syr
126
+ sum_s006_in_syr = getattr(rec, 's006').sum()
127
+ sum_e00300_in_syr = getattr(rec, 'e00300').sum()
122
128
  rec.increment_year()
123
- assert rec.data_year == syr
124
- assert rec.current_year == syr + 1
125
- sum_s006_in_syr_plus_one = rec.s006.sum()
129
+ assert getattr(rec, 'data_year') == syr
130
+ assert getattr(rec, 'current_year') == syr + 1
131
+ sum_s006_in_syr_plus_one = getattr(rec, 's006').sum()
126
132
  assert sum_s006_in_syr_plus_one > sum_s006_in_syr
127
- sum_e00300_in_syr_plus_one = rec.e00300.sum()
133
+ sum_e00300_in_syr_plus_one = getattr(rec, 'e00300').sum()
128
134
  assert sum_e00300_in_syr_plus_one > sum_e00300_in_syr
129
- # test private methods
135
+ # test private methods:
136
+ # pylint: disable=protected-access
130
137
  rec._read_data(data=None)
131
138
  rec._read_weights(weights=None)
132
139
  with pytest.raises(ValueError):
133
- rec._read_weights(weights=list())
140
+ rec._read_weights(weights=[])
@@ -1,18 +1,28 @@
1
+ """
2
+ Test decorators.
3
+ """
1
4
  # CODING-STYLE CHECKS:
2
5
  # pycodestyle test_decorators.py
6
+ # pylint --disable=locally-disabled test_decorators.py
3
7
 
4
8
  import os
5
- import sys
6
- import pytest
7
9
  import importlib
8
10
  import numpy as np
9
11
  from pandas import DataFrame
10
12
  from pandas.testing import assert_frame_equal
13
+ import pytest
11
14
  import taxcalc
12
- from taxcalc.decorators import *
15
+ from taxcalc.decorators import (
16
+ iterate_jit,
17
+ apply_jit,
18
+ create_apply_function_string,
19
+ create_toplevel_function_string,
20
+ make_apply_function,
21
+ )
13
22
 
14
23
 
15
24
  def test_create_apply_function_string():
25
+ """Test docstring"""
16
26
  ans = create_apply_function_string(['a', 'b', 'c'], ['d', 'e'], [])
17
27
  exp = ("def ap_func(x_0,x_1,x_2,x_3,x_4):\n"
18
28
  " for i in range(len(x_0)):\n"
@@ -22,6 +32,7 @@ def test_create_apply_function_string():
22
32
 
23
33
 
24
34
  def test_create_apply_function_string_with_params():
35
+ """Test docstring"""
25
36
  ans = create_apply_function_string(['a', 'b', 'c'], ['d', 'e'], ['d'])
26
37
  exp = ("def ap_func(x_0,x_1,x_2,x_3,x_4):\n"
27
38
  " for i in range(len(x_0)):\n"
@@ -31,6 +42,7 @@ def test_create_apply_function_string_with_params():
31
42
 
32
43
 
33
44
  def test_create_toplevel_function_string_mult_outputs():
45
+ """Test docstring"""
34
46
  ans = create_toplevel_function_string(['a', 'b'], ['d', 'e'],
35
47
  ['pm', 'pm', 'pf', 'pm'])
36
48
  exp = ''
@@ -55,6 +67,7 @@ def test_create_toplevel_function_string_mult_outputs():
55
67
 
56
68
 
57
69
  def test_create_toplevel_function_string():
70
+ """Test docstring"""
58
71
  ans = create_toplevel_function_string(['a'], ['d', 'e'],
59
72
  ['pm', 'pf', 'pm'])
60
73
  exp = ''
@@ -78,12 +91,14 @@ def test_create_toplevel_function_string():
78
91
 
79
92
 
80
93
  def some_calc(x, y, z):
94
+ """Function docstring"""
81
95
  a = x + y
82
96
  b = x + y + z
83
97
  return (a, b)
84
98
 
85
99
 
86
100
  def test_make_apply_function():
101
+ """Test docstring"""
87
102
  ans_do_jit = make_apply_function(some_calc, ['a', 'b'], ['x', 'y', 'z'],
88
103
  [], do_jit=True, no_python=True)
89
104
  assert ans_do_jit
@@ -93,33 +108,45 @@ def test_make_apply_function():
93
108
 
94
109
 
95
110
  @apply_jit(["a", "b"], ["x", "y", "z"], nopython=True)
96
- def Magic_calc(x, y, z):
111
+ def magic_calc(x, y, z):
112
+ """Function docstring"""
97
113
  a = x + y
98
114
  b = x + y + z
99
115
  return (a, b)
100
116
 
101
117
 
102
- def Magic(pm, pf):
118
+ def magic(pm, pf):
119
+ """Function docstring"""
103
120
  # Adjustments
104
- outputs = pf.a, pf.b = Magic_calc(pm, pf)
121
+ # pylint: disable=no-value-for-parameter
122
+ outputs = pf.a, pf.b = magic_calc(pm, pf)
123
+ # pylint: enable=no-value-for-parameter
105
124
  header = ['a', 'b']
106
125
  return DataFrame(data=np.column_stack(outputs), columns=header)
107
126
 
108
127
 
109
128
  @iterate_jit(nopython=True)
110
- def Magic_calc2(x, y, z):
129
+ def magic_calc2(x, y, z):
130
+ """Function docstring"""
111
131
  a = x + y
112
132
  b = x + y + z
113
133
  return (a, b)
114
134
 
115
135
 
116
- class Foo(object):
117
- pass
136
+ class Foo: # pylint: disable=too-many-instance-attributes
137
+ """Foo class"""
138
+
139
+ def faux_method1(self):
140
+ """ Foo method"""
141
+
142
+ def faux_method2(self):
143
+ """ Foo method"""
118
144
 
119
145
 
120
146
  @iterate_jit(nopython=True)
121
- def faux_function(MARS):
122
- if MARS == 1:
147
+ def faux_function(mars):
148
+ """Function docstring"""
149
+ if mars == 1:
123
150
  var = 2
124
151
  else:
125
152
  var = 1
@@ -128,17 +155,21 @@ def faux_function(MARS):
128
155
 
129
156
  @iterate_jit(nopython=True)
130
157
  def ret_everything(a, b, c, d, e, f):
131
-
158
+ """Function docstring"""
159
+ # pylint: disable=too-many-arguments,too-many-positional-arguments
132
160
  c = a + b
133
161
  d = a + b
134
162
  e = a + b
135
163
  f = a + b
136
-
137
164
  return (c, d, e,
138
165
  f)
139
166
 
140
167
 
168
+ # pylint: disable=attribute-defined-outside-init
169
+
170
+
141
171
  def test_magic_apply_jit():
172
+ """Test docstring"""
142
173
  pm = Foo()
143
174
  pf = Foo()
144
175
  pm.a = np.ones((5,))
@@ -146,12 +177,13 @@ def test_magic_apply_jit():
146
177
  pf.x = np.ones((5,))
147
178
  pf.y = np.ones((5,))
148
179
  pf.z = np.ones((5,))
149
- xx = Magic(pm, pf)
180
+ xx = magic(pm, pf)
150
181
  exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=["a", "b"])
151
182
  assert_frame_equal(xx, exp)
152
183
 
153
184
 
154
185
  def test_magic_apply_jit_swap():
186
+ """Test docstring"""
155
187
  pm = Foo()
156
188
  pf = Foo()
157
189
  pm.a = np.ones((5,))
@@ -159,12 +191,16 @@ def test_magic_apply_jit_swap():
159
191
  pf.x = np.ones((5,))
160
192
  pf.y = np.ones((5,))
161
193
  pf.z = np.ones((5,))
162
- xx = Magic(pf, pm)
194
+ xx = magic(pf, pm) # pylint: disable=arguments-out-of-order
163
195
  exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=["a", "b"])
164
196
  assert_frame_equal(xx, exp)
165
197
 
166
198
 
199
+ # pylint: disable=no-value-for-parameter
200
+
201
+
167
202
  def test_magic_iterate_jit():
203
+ """Test docstring"""
168
204
  pm = Foo()
169
205
  pf = Foo()
170
206
  pm.a = np.ones((1, 5))
@@ -172,22 +208,24 @@ def test_magic_iterate_jit():
172
208
  pf.x = np.ones((5,))
173
209
  pf.y = np.ones((5,))
174
210
  pf.z = np.ones((5,))
175
- xx = Magic_calc2(pm, pf)
211
+ xx = magic_calc2(pm, pf)
176
212
  exp = DataFrame(data=[[2.0, 3.0]] * 5, columns=["a", "b"])
177
213
  assert_frame_equal(xx, exp)
178
214
 
179
215
 
180
216
  def test_faux_function_iterate_jit():
217
+ """Test docstring"""
181
218
  pm = Foo()
182
219
  pf = Foo()
183
- pf.MARS = np.ones((5,))
220
+ pf.mars = np.ones((5,))
184
221
  pf.var = np.ones((5,))
185
- ans = faux_function(pm, pf)
222
+ ans = faux_function(pm, pf) # pylint: disable=too-many-function-args
186
223
  exp = DataFrame(data=[2.0] * 5, columns=['var'])
187
224
  assert_frame_equal(ans, exp)
188
225
 
189
226
 
190
227
  def test_ret_everything_iterate_jit():
228
+ """Test docstring"""
191
229
  pm = Foo()
192
230
  pf = Foo()
193
231
  pf.a = np.ones((5,))
@@ -203,13 +241,15 @@ def test_ret_everything_iterate_jit():
203
241
 
204
242
 
205
243
  @iterate_jit(nopython=True)
206
- def Magic_calc3(x, y, z):
244
+ def magic_calc3(x, y, z):
245
+ """Function docstring"""
207
246
  a = x + y
208
247
  b = a + z
209
248
  return (a, b)
210
249
 
211
250
 
212
251
  def test_function_takes_kwarg():
252
+ """Test docstring"""
213
253
  pm = Foo()
214
254
  pf = Foo()
215
255
  pm.a = np.ones((1, 5))
@@ -217,20 +257,22 @@ def test_function_takes_kwarg():
217
257
  pf.x = np.ones((5,))
218
258
  pf.y = np.ones((5,))
219
259
  pf.z = np.ones((5,))
220
- ans = Magic_calc3(pm, pf)
260
+ ans = magic_calc3(pm, pf)
221
261
  exp = DataFrame(data=[[2.0, 3.0]] * 5,
222
262
  columns=["a", "b"])
223
263
  assert_frame_equal(ans, exp)
224
264
 
225
265
 
226
266
  @iterate_jit(nopython=True)
227
- def Magic_calc4(x, y, z):
267
+ def magic_calc4(x, y, z):
268
+ """Function docstring"""
228
269
  a = x + y
229
270
  b = a + z
230
271
  return (a, b)
231
272
 
232
273
 
233
274
  def test_function_no_parameters_listed():
275
+ """Test docstring"""
234
276
  pm = Foo()
235
277
  pf = Foo()
236
278
  pm.a = np.ones((1, 5))
@@ -238,20 +280,22 @@ def test_function_no_parameters_listed():
238
280
  pf.x = np.ones((5,))
239
281
  pf.y = np.ones((5,))
240
282
  pf.z = np.ones((5,))
241
- ans = Magic_calc4(pm, pf)
283
+ ans = magic_calc4(pm, pf)
242
284
  exp = DataFrame(data=[[2.0, 3.0]] * 5,
243
285
  columns=["a", "b"])
244
286
  assert_frame_equal(ans, exp)
245
287
 
246
288
 
247
289
  @iterate_jit(parameters=['w'], nopython=True)
248
- def Magic_calc5(w, x, y, z):
290
+ def magic_calc5(w, x, y, z):
291
+ """Function docstring"""
249
292
  a = x + y
250
293
  b = w[0] + x + y + z
251
294
  return (a, b)
252
295
 
253
296
 
254
297
  def test_function_parameters_optional():
298
+ """Test docstring"""
255
299
  pm = Foo()
256
300
  pf = Foo()
257
301
  pm.a = np.ones((1, 5))
@@ -260,30 +304,37 @@ def test_function_parameters_optional():
260
304
  pf.x = np.ones((5,))
261
305
  pf.y = np.ones((5,))
262
306
  pf.z = np.ones((5,))
263
- ans = Magic_calc5(pm, pf)
307
+ ans = magic_calc5(pm, pf)
264
308
  exp = DataFrame(data=[[2.0, 4.0]] * 5,
265
309
  columns=["a", "b"])
266
310
  assert_frame_equal(ans, exp)
267
311
 
268
312
 
313
+ # pylint: enable=no-value-for-parameter
314
+
315
+
269
316
  def unjittable_function1(w, x, y, z):
270
- a = x + y
271
- b = w[0] + x + y + z
317
+ """Function docstring"""
318
+ a = x + y # pylint: disable=unused-variable
319
+ b = w[0] + x + y + z # pylint: disable=unused-variable
272
320
 
273
321
 
274
322
  def unjittable_function2(w, x, y, z):
323
+ """Function docstring"""
275
324
  a = x + y
276
325
  b = w[0] + x + y + z
277
- return (a, b, c)
326
+ return (a, b, c) # pylint: disable=undefined-variable
278
327
 
279
328
 
280
329
  def test_iterate_jit_raises_on_no_return():
330
+ """Test docstring"""
281
331
  with pytest.raises(ValueError):
282
332
  ij = iterate_jit(parameters=['w'], nopython=True)
283
333
  ij(unjittable_function1)
284
334
 
285
335
 
286
336
  def test_iterate_jit_raises_on_unknown_return_argument():
337
+ """Test docstring"""
287
338
  ij = iterate_jit(parameters=['w'], nopython=True)
288
339
  uf2 = ij(unjittable_function2)
289
340
  pm = Foo()
@@ -295,10 +346,11 @@ def test_iterate_jit_raises_on_unknown_return_argument():
295
346
  pf.y = np.ones((5,))
296
347
  pf.z = np.ones((5,))
297
348
  with pytest.raises(AttributeError):
298
- ans = uf2(pm, pf)
349
+ ans = uf2(pm, pf) # pylint: disable=unused-variable
299
350
 
300
351
 
301
- def Magic_calc6(w, x, y, z):
352
+ def magic_calc6(w, x, y, z):
353
+ """Function docstring"""
302
354
  a = x + y
303
355
  b = w[0] + x + y + z
304
356
  return (a, b)
@@ -313,8 +365,8 @@ def test_force_no_jit():
313
365
  os.environ['NOTAXCALCJIT'] = 'NOJIT'
314
366
  # reload the decorators module
315
367
  importlib.reload(taxcalc.decorators)
316
- # verify Magic_calc6 function works as expected
317
- Magic_calc6_ = iterate_jit(parameters=['w'], nopython=True)(Magic_calc6)
368
+ # verify magic_calc6 function works as expected
369
+ magic_calc6_ = iterate_jit(parameters=['w'], nopython=True)(magic_calc6)
318
370
  pm = Foo()
319
371
  pf = Foo()
320
372
  pm.a = np.ones((1, 5))
@@ -323,7 +375,7 @@ def test_force_no_jit():
323
375
  pf.x = np.ones((5,))
324
376
  pf.y = np.ones((5,))
325
377
  pf.z = np.ones((5,))
326
- ans = Magic_calc6_(pm, pf)
378
+ ans = magic_calc6_(pm, pf)
327
379
  exp = DataFrame(data=[[2.0, 4.0]] * 5,
328
380
  columns=["a", "b"])
329
381
  assert_frame_equal(ans, exp)