-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameters class API redesign #343
Parameters class API redesign #343
Conversation
These changes were required by the new signature of the Parameters class __init__ function.
Not sure why this error was not found before; perhaps something to do with the calculator factory function.
Not sure why this error was not found before; perhaps something to do with two Calculator objects in test with only one being used in test.
…s_dict. Not sure why this error was not found before; perhaps something to do with the calculator factory function.
Not sure why this test was using the calculator factory function when its former name makes clear that is testing the Calculator constructor. And again, not sure why this error was not found before; perhaps something to do with a flaw in the logic of the calculator factory function.
This classmethod appears to not be used in the webapp repo; dropping it causes six (out of 78) taxcalc tests to fail.
This classmethod appears to not be used in the webapp repo; dropping it does not change the four (out of 78) taxcalc test failures. Dropping Calculator.from_file requires minor changes to the Calculator.__init__ method, which now treats the params argument in the same way as the records argument is treated.
The first change is the elimination of the Calculator.from_files method; the second change is the new Calculator.__init__ method that requires a Parameters object be passed via the params argument. After the changes in the logic of four tests, there are no test failures among the 78 taxcalc tests.
There appear to be no uses of the old public Parameters.update method in the webapp repo.
There appear to be no uses of the Parameters.increment_year method in the webapp repo.
Add Parameters classmethod _params_dict_from_json_file() that incorporates params.json file read logic from global default_data() function. Then use this new classmethod in Parameters.__init__ instead of calling default_data(metadata=True)
Add Parameters classmethod default_data(cls, metadata=False, first_value_year=None) that is intended to replace the legacy global default_data function in the parameters.py file.
Add logic to tests that call the global default_data function so that they can continue to do that or they can call the new Parameters default_data classmethod. Both tests pass regardless of which default_data they call.
The new test confirms that every parameter in the params.json file has an attribute named "start_year" whose value is equal to Parameters.JSON_START_YEAR.
The "original" code means as of 11-Aug-2015 check-in e5cbc0e, except for the change from Parameters.PARAM_FILENAME to Parameters.PARAMS_FILENAME and the change from DEFAULT_START_YEAR to Parameters.JSON_START_YEAR.
np.array([1400, 1100, 1100, 1400, 1400, 1199])) | ||
|
||
|
||
def test_update_Parameters_raises_on_future_year(): | ||
p = Parameters(start_year=2013) | ||
def test_Parameters_reform_before_start_year(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above here, regarding 'raises' in the test name.
T.J. @talumbau (and @MattHJensen) would something like the following work?
|
@martinholmer for inline conversations, would you mind keeping the conversation inline using the Add a Line Note button? We have many inline conversations on this PR and if we use the main Conversation thread I think it will get too complicated. |
Adjust decorators.py code to call new Parameters default_data() static method.
Enforce correct row_label list content in modified test_params_json_content.
Drop checking of final_mods keys because that is now done in implement_reform.
I believe this PR is ready to be merged based on the following analysis: There are two outstanding lines of discussion that have not yet been fully addressed, but after conversing with @martinholmer on the phone this morning, I believe both of them ought to be dealt with in follow-on work. These two areas, and the reason for separating them from this PR, are as follows:
An additional reason for separating both these issues into follow on work is that they might both require quite a bit of discussion, and this PR is already quite cluttered. @talumbau, if this analysis seems reasonable to you, could you go ahead and merge this PR? |
@MattHJensen OK, I'll merge this and create follow-on issues. |
This pull request includes a redesign of the Parameters class API plus Sphinx-aware documentation. The new API is as described in issue #336. The old Parameters class had no documentation, but a combination of the source code, the tests in test_parameters.py and test_calculate.py, and the helpful discussion in issue #342, provided a basis for the redesign. The redesign includes a replacement for the old global default_data function, which passes all the tests and works as described in the issue #342 discussion. Several changes have been made on Sep 1 (see details below in commit history) in response to helpful suggestions made by T.J. Alumbaugh (@talumbau) and @MattHJensen.