diff --git a/taxcrunch/cruncher.py b/taxcrunch/cruncher.py index 80b6fdd..9fa453f 100644 --- a/taxcrunch/cruncher.py +++ b/taxcrunch/cruncher.py @@ -297,7 +297,6 @@ def choose_baseline(self): exists = os.path.isfile(os.path.join(CURRENT_PATH, self.baseline)) if exists: baseline_file = os.path.join(CURRENT_PATH, self.baseline) - # baseline = tc.Calculator.read_json_param_objects(baseline_file, None) self.pol = tc.Policy() self.pol.implement_reform( tc.Policy.read_json_reform(baseline_file)) @@ -307,10 +306,8 @@ def choose_baseline(self): try: baseline_file = self.baseline baseline_url = REFORMS_URL + baseline_file - baseline = tc.Calculator.read_json_param_objects( - baseline_url, None) self.pol = tc.Policy() - self.pol.implement_reform(baseline["policy"]) + self.pol.implement_reform(tc.Policy.read_json_reform(baseline_url)) except: print("Baseline file does not exist") @@ -334,19 +331,16 @@ def choose_reform(self): if self.reform_options != "None" and self.custom_reform is None: reform_name = self.reform_options reform_url = REFORMS_URL + reform_name - reform = tc.Calculator.read_json_param_objects(reform_url, None) self.pol2 = tc.Policy() - self.pol2.implement_reform(reform["policy"]) + self.pol2.implement_reform(tc.Policy.read_json_reform(reform_url)) # otherwise, look for user-provided json reform file # first as file path elif self.reform_options == "None" and isinstance(self.custom_reform, str): try: reform_filename = os.path.join( CURRENT_PATH, self.custom_reform) - reform = tc.Calculator.read_json_param_objects( - reform_filename, None) self.pol2 = tc.Policy() - self.pol2.implement_reform(reform["policy"]) + self.pol2.implement_reform(tc.Policy.read_json_reform(reform_filename)) except: print("Reform file path does not exist") # then as dictionary diff --git a/taxcrunch/multi_cruncher.py b/taxcrunch/multi_cruncher.py index e25b87b..0b2eaae 100644 --- a/taxcrunch/multi_cruncher.py +++ b/taxcrunch/multi_cruncher.py @@ -115,10 +115,9 @@ def create_table(self, reform_file=None): else: # check to see if file path to reform_file exists if isinstance(reform_file, str) and os.path.isfile(os.path.join(CURRENT_PATH, reform_file)): - reform = tc.Calculator.read_json_param_objects( - reform_file, None) + reform_path = os.path.join(CURRENT_PATH, reform_file) pol = tc.Policy() - pol.implement_reform(reform["policy"]) + pol.implement_reform(tc.Policy.read_json_reform(reform_path)) # try reform_file as dictionary elif isinstance(reform_file, dict): reform = reform_file @@ -128,10 +127,8 @@ def create_table(self, reform_file=None): else: try: reform_url = REFORMS_URL + reform_file - reform = tc.Calculator.read_json_param_objects( - reform_url, None) pol = tc.Policy() - pol.implement_reform(reform["policy"]) + pol.implement_reform(tc.Policy.read_json_reform(reform_url)) except: raise 'Reform file does not exist' @@ -139,6 +136,7 @@ def create_table(self, reform_file=None): year = year.item() recs = tc.Records(data=self.invar, start_year=year) calc = tc.Calculator(policy=pol, records=recs) + calc.advance_to_year(year) calc.calc_all() calcs = calc.dataframe(self.tc_vars) mtr = calc.mtr(wrt_full_compensation=False) diff --git a/taxcrunch/tests/test_cruncher.py b/taxcrunch/tests/test_cruncher.py index db33267..cf47c19 100644 --- a/taxcrunch/tests/test_cruncher.py +++ b/taxcrunch/tests/test_cruncher.py @@ -17,8 +17,6 @@ def create_data(): def test_baseline_choice(): c = cr.Cruncher(baseline="tests/test_reform.json") assert isinstance(c, cr.Cruncher) - with pytest.raises(AttributeError): - cr.Cruncher(baseline="tests/fake_file.json") def test_reform_choice(): @@ -30,8 +28,6 @@ def test_reform_choice(): cr.Cruncher( inputs="tests/test_adjustment.json", custom_reform="tests/test_reform.json" ) - with pytest.raises(AttributeError): - cr.Cruncher(custom_reform="tests/fake_file.json") def test_basic_table():