taxcalc 4.3.5__py3-none-any.whl → 4.4.1__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.
- taxcalc/__init__.py +1 -1
- taxcalc/calcfunctions.py +326 -171
- taxcalc/calculator.py +35 -34
- taxcalc/cli/tc.py +6 -7
- taxcalc/consumption.py +14 -9
- taxcalc/data.py +8 -8
- taxcalc/decorators.py +3 -3
- taxcalc/growdiff.py +6 -6
- taxcalc/growfactors.py +1 -1
- taxcalc/parameters.py +91 -47
- taxcalc/policy.py +23 -7
- taxcalc/records.py +1 -0
- taxcalc/records_variables.json +6 -0
- taxcalc/reforms/ext.json +1 -1
- taxcalc/taxcalcio.py +88 -73
- taxcalc/tests/cmpi_cps_expect.txt +6 -6
- taxcalc/tests/cmpi_puf_expect.txt +6 -6
- taxcalc/tests/conftest.py +42 -41
- taxcalc/tests/test_4package.py +47 -3
- taxcalc/tests/test_benefits.py +9 -8
- taxcalc/tests/test_calcfunctions.py +55 -38
- taxcalc/tests/test_calculator.py +14 -10
- taxcalc/tests/test_compare.py +44 -50
- taxcalc/tests/test_compatible_data.py +9 -7
- taxcalc/tests/test_consumption.py +41 -22
- taxcalc/tests/test_cpscsv.py +81 -31
- taxcalc/tests/test_data.py +31 -24
- taxcalc/tests/test_decorators.py +84 -32
- taxcalc/tests/test_growdiff.py +20 -19
- taxcalc/tests/test_growfactors.py +8 -8
- taxcalc/tests/test_parameters.py +54 -58
- taxcalc/tests/test_policy.py +16 -14
- taxcalc/tests/test_puf_var_stats.py +14 -14
- taxcalc/tests/test_pufcsv.py +40 -40
- taxcalc/tests/test_records.py +73 -60
- taxcalc/tests/test_reforms.py +34 -31
- taxcalc/tests/test_responses.py +4 -4
- taxcalc/tests/test_taxcalcio.py +76 -62
- taxcalc/tests/test_utils.py +78 -46
- taxcalc/utils.py +49 -42
- taxcalc/validation/taxsim35/taxsim_emulation.json +1 -5
- {taxcalc-4.3.5.dist-info → taxcalc-4.4.1.dist-info}/METADATA +23 -11
- {taxcalc-4.3.5.dist-info → taxcalc-4.4.1.dist-info}/RECORD +47 -47
- {taxcalc-4.3.5.dist-info → taxcalc-4.4.1.dist-info}/WHEEL +1 -1
- {taxcalc-4.3.5.dist-info → taxcalc-4.4.1.dist-info}/LICENSE +0 -0
- {taxcalc-4.3.5.dist-info → taxcalc-4.4.1.dist-info}/entry_points.txt +0 -0
- {taxcalc-4.3.5.dist-info → taxcalc-4.4.1.dist-info}/top_level.txt +0 -0
@@ -12,7 +12,9 @@ plug-in pytest-xdist is able to run all parametrized functions in parallel
|
|
12
12
|
import copy
|
13
13
|
import pytest
|
14
14
|
import numpy as np
|
15
|
-
from taxcalc import Policy
|
15
|
+
from taxcalc.policy import Policy
|
16
|
+
from taxcalc.records import Records
|
17
|
+
from taxcalc.calculator import Calculator
|
16
18
|
|
17
19
|
|
18
20
|
@pytest.fixture(scope='module', name='allparams')
|
@@ -49,7 +51,7 @@ def test_compatible_data_presence(allparams):
|
|
49
51
|
return True
|
50
52
|
|
51
53
|
# Main logic of test_compatible_data_presence function
|
52
|
-
problem_pnames =
|
54
|
+
problem_pnames = []
|
53
55
|
for pname in allparams:
|
54
56
|
if 'compatible_data' in allparams[pname]:
|
55
57
|
compatible_data = allparams[pname]['compatible_data']
|
@@ -61,7 +63,7 @@ def test_compatible_data_presence(allparams):
|
|
61
63
|
msg = '{} has no or invalid compatible_data field'
|
62
64
|
for pname in problem_pnames:
|
63
65
|
print(msg.format(pname))
|
64
|
-
assert 'list of problem_pnames
|
66
|
+
assert False, 'ERROR: list of problem_pnames is above'
|
65
67
|
|
66
68
|
|
67
69
|
XX_YEAR = 2019
|
@@ -142,7 +144,7 @@ BATCHES = int(np.floor(NPARAMS / BATCHSIZE)) + 1
|
|
142
144
|
|
143
145
|
|
144
146
|
@pytest.fixture(scope='module', name='allparams_batch',
|
145
|
-
params=
|
147
|
+
params=list(range(0, BATCHES)))
|
146
148
|
def fixture_allparams_batch(request, allparams, sorted_param_names):
|
147
149
|
"""
|
148
150
|
Fixture for grouping Tax-Calculator parameters
|
@@ -229,8 +231,8 @@ def test_compatible_data(cps_subsample, puf_subsample,
|
|
229
231
|
at least one of these reforms when using datasets marked compatible
|
230
232
|
and does not differ when using datasets marked as incompatible.
|
231
233
|
"""
|
232
|
-
# pylint: disable=too-many-arguments,too-many-
|
233
|
-
# pylint: disable=too-many-statements,too-many-branches
|
234
|
+
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
235
|
+
# pylint: disable=too-many-statements,too-many-branches,too-many-locals
|
234
236
|
|
235
237
|
# Check NPARAMS value
|
236
238
|
assert NPARAMS == len(allparams)
|
@@ -335,4 +337,4 @@ def test_compatible_data(cps_subsample, puf_subsample,
|
|
335
337
|
# test failure if any errors
|
336
338
|
if errors:
|
337
339
|
print(errors)
|
338
|
-
assert 'compatible_data
|
340
|
+
assert False, 'ERROR: compatible_data is invalid; see errors above'
|
@@ -1,19 +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
|
11
|
+
import paramtools
|
8
12
|
from taxcalc import Policy, Records, Calculator, Consumption
|
9
13
|
|
10
14
|
|
11
|
-
def
|
15
|
+
def test_start_year_consistency():
|
16
|
+
"""Test docstring"""
|
12
17
|
assert Consumption.JSON_START_YEAR == Policy.JSON_START_YEAR
|
13
|
-
assert Consumption.DEFAULT_NUM_YEARS == Policy.DEFAULT_NUM_YEARS
|
14
18
|
|
15
19
|
|
16
20
|
def test_validity_of_consumption_vars_set():
|
21
|
+
"""Test docstring"""
|
17
22
|
records_varinfo = Records(data=None)
|
18
23
|
assert Consumption.RESPONSE_VARS.issubset(records_varinfo.USABLE_READ_VARS)
|
19
24
|
useable_vars = set(['housing', 'snap', 'tanf', 'vet', 'wic',
|
@@ -22,6 +27,7 @@ def test_validity_of_consumption_vars_set():
|
|
22
27
|
|
23
28
|
|
24
29
|
def test_update_consumption():
|
30
|
+
"""Test docstring"""
|
25
31
|
consump = Consumption()
|
26
32
|
consump.update_consumption({})
|
27
33
|
revision = {
|
@@ -31,24 +37,32 @@ def test_update_consumption():
|
|
31
37
|
2015: 0.80}
|
32
38
|
}
|
33
39
|
consump.update_consumption(revision)
|
34
|
-
expected_mpc_e20400 = np.full((
|
40
|
+
expected_mpc_e20400 = np.full((consump.num_years,), 0.06)
|
35
41
|
expected_mpc_e20400[0] = 0.0
|
36
42
|
expected_mpc_e20400[1] = 0.05
|
37
|
-
assert np.allclose(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
+
)
|
53
|
+
expected_ben_mcare_value = np.full((consump.num_years,), 0.80)
|
44
54
|
expected_ben_mcare_value[0] = 1.0
|
45
55
|
expected_ben_mcare_value[1] = 0.75
|
46
|
-
assert np.allclose(
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
+
)
|
52
66
|
consump.set_year(2015)
|
53
67
|
assert consump.current_year == 2015
|
54
68
|
assert consump.MPC_e20400 == 0.06
|
@@ -58,6 +72,7 @@ def test_update_consumption():
|
|
58
72
|
|
59
73
|
|
60
74
|
def test_incorrect_update_consumption():
|
75
|
+
"""Test docstring"""
|
61
76
|
with pytest.raises(paramtools.ValidationError):
|
62
77
|
Consumption().update_consumption([])
|
63
78
|
with pytest.raises(paramtools.ValidationError):
|
@@ -75,6 +90,7 @@ def test_incorrect_update_consumption():
|
|
75
90
|
|
76
91
|
|
77
92
|
def test_future_update_consumption():
|
93
|
+
"""Test docstring"""
|
78
94
|
consump = Consumption()
|
79
95
|
assert consump.current_year == consump.start_year
|
80
96
|
assert consump.has_response() is False
|
@@ -98,6 +114,7 @@ def test_future_update_consumption():
|
|
98
114
|
|
99
115
|
|
100
116
|
def test_consumption_default_data():
|
117
|
+
"""Test docstring"""
|
101
118
|
consump = Consumption()
|
102
119
|
pdata = consump.specification(meta_data=True, ignore_state=True)
|
103
120
|
for pname in pdata.keys():
|
@@ -108,24 +125,26 @@ def test_consumption_default_data():
|
|
108
125
|
|
109
126
|
|
110
127
|
def test_consumption_response(cps_subsample):
|
128
|
+
"""Test docstring"""
|
129
|
+
# pylint: disable=too-many-locals
|
111
130
|
consump = Consumption()
|
112
131
|
mpc = 0.5
|
113
132
|
consumption_response = {'MPC_e20400': {2013: mpc}}
|
114
133
|
consump.update_consumption(consumption_response)
|
115
134
|
# test incorrect call to response method
|
116
135
|
with pytest.raises(ValueError):
|
117
|
-
consump.response(
|
136
|
+
consump.response([], 1)
|
118
137
|
# test correct call to response method
|
119
138
|
rec = Records.cps_constructor(data=cps_subsample)
|
120
|
-
pre = copy.deepcopy(rec
|
139
|
+
pre = copy.deepcopy(getattr(rec, 'e20400'))
|
121
140
|
consump.response(rec, 1.0)
|
122
|
-
post = rec
|
141
|
+
post = getattr(rec, 'e20400')
|
123
142
|
actual_diff = post - pre
|
124
143
|
expected_diff = np.ones(rec.array_length) * mpc
|
125
144
|
assert np.allclose(actual_diff, expected_diff)
|
126
145
|
# compute earnings mtr with no consumption response
|
127
146
|
rec = Records.cps_constructor(data=cps_subsample)
|
128
|
-
ided0 = copy.deepcopy(rec
|
147
|
+
ided0 = copy.deepcopy(getattr(rec, 'e20400'))
|
129
148
|
calc0 = Calculator(policy=Policy(), records=rec, consumption=None)
|
130
149
|
(mtr0_ptax, mtr0_itax, _) = calc0.mtr(variable_str='e00200p',
|
131
150
|
wrt_full_compensation=False)
|
taxcalc/tests/test_cpscsv.py
CHANGED
@@ -17,8 +17,11 @@ import json
|
|
17
17
|
import pytest
|
18
18
|
import numpy as np
|
19
19
|
import pandas as pd
|
20
|
-
|
21
|
-
from taxcalc import
|
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 = '{
|
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
|
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 =
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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,22 +148,66 @@ 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
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
if
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
166
|
+
|
167
|
+
|
168
|
+
def test_flexible_last_budget_year(cps_fullsample):
|
169
|
+
"""
|
170
|
+
Test flexible LAST_BUDGET_YEAR logic using cps.csv file.
|
171
|
+
"""
|
172
|
+
tax_calc_year = Policy.LAST_BUDGET_YEAR - 1
|
173
|
+
growdiff_year = tax_calc_year - 1
|
174
|
+
growdiff_dict = {'AWAGE': {growdiff_year: 0.01, tax_calc_year: 0.0}}
|
175
|
+
|
176
|
+
def default_calculator(growdiff_dictionary):
|
177
|
+
"""
|
178
|
+
Return CPS-based Calculator object using default LAST_BUDGET_YEAR.
|
179
|
+
"""
|
180
|
+
g_factors = GrowFactors()
|
181
|
+
gdiff = GrowDiff()
|
182
|
+
gdiff.update_growdiff(growdiff_dictionary)
|
183
|
+
gdiff.apply_to(g_factors)
|
184
|
+
pol = Policy(gfactors=g_factors)
|
185
|
+
rec = Records.cps_constructor(data=cps_fullsample, gfactors=g_factors)
|
186
|
+
calc = Calculator(policy=pol, records=rec)
|
187
|
+
return calc
|
188
|
+
|
189
|
+
def flexible_calculator(growdiff_dictionary, last_b_year):
|
190
|
+
"""
|
191
|
+
Return CPS-based Calculator object using custom LAST_BUDGET_YEAR.
|
192
|
+
"""
|
193
|
+
g_factors = GrowFactors()
|
194
|
+
gdiff = GrowDiff(last_budget_year=last_b_year)
|
195
|
+
gdiff.update_growdiff(growdiff_dictionary)
|
196
|
+
gdiff.apply_to(g_factors)
|
197
|
+
pol = Policy(gfactors=g_factors, last_budget_year=last_b_year)
|
198
|
+
rec = Records.cps_constructor(data=cps_fullsample, gfactors=g_factors)
|
199
|
+
calc = Calculator(policy=pol, records=rec)
|
200
|
+
return calc
|
201
|
+
|
202
|
+
# begin main test logic
|
203
|
+
cdef = default_calculator(growdiff_dict)
|
204
|
+
cdef.advance_to_year(tax_calc_year)
|
205
|
+
cdef.calc_all()
|
206
|
+
iitax_def = round(cdef.weighted_total('iitax'))
|
207
|
+
|
208
|
+
cflx = flexible_calculator(growdiff_dict, tax_calc_year)
|
209
|
+
cflx.advance_to_year(tax_calc_year)
|
210
|
+
cflx.calc_all()
|
211
|
+
iitax_flx = round(cflx.weighted_total('iitax'))
|
212
|
+
|
213
|
+
assert np.allclose([iitax_flx], [iitax_def])
|
taxcalc/tests/test_data.py
CHANGED
@@ -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
|
-
|
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=
|
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=
|
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
|
101
|
-
assert
|
102
|
-
assert rec
|
103
|
-
|
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
|
107
|
-
assert rec
|
108
|
-
sum_e00300_in_syr_plus_one = rec
|
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
|
118
|
-
assert rec
|
119
|
-
assert rec
|
120
|
-
sum_s006_in_syr = rec
|
121
|
-
sum_e00300_in_syr = rec
|
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
|
124
|
-
assert rec
|
125
|
-
sum_s006_in_syr_plus_one = rec
|
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
|
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=
|
140
|
+
rec._read_weights(weights=[])
|