PSLmodels / Business-Taxation

USA Corporate and Pass-Through Business Tax Model
11 stars 10 forks source link

Add and use named constants instead of the "magic numbers" in the code #80

Closed martinholmer closed 5 years ago

martinholmer commented 5 years ago

This pull request adds a years.py file (and imports it into the other modules) so that the magic numbers 2014, 2027, 2028, and 14 can be replaced with named constants. This makes the code easier to read and, more importantly, easier to maintain because the last simulation year will be increased in the future. Using these named constants is also essential for developing a Business-Taxation Policy class.

So, all these changes are cosmetic in the sense that there is no change in Business-Taxation logic. This means that the pytest results and the results generated by the example.py script are unchanged.

Since using the named constants required cosmetic editing of each biztax/*py file, it seemed sensible to also begin bringing the code closer to being in compliance with the PEP8 coding style (which focuses mostly on the vertical and horizontal placement of code elements). Eventually, this coding-style test will be part of the GitHub check-in testing (along with running the pytest suite and code-coverage calculations). The code in this pull request generates these coding-style errors:

iMac:Business-Taxation mrh$ pycodestyle biztax | grep -v E501 | grep -v preTCJA
biztax/btaxmini.py:114:13: E741 ambiguous variable name 'I'
biztax/btaxmini.py:116:13: E741 ambiguous variable name 'I'
biztax/debt.py:128:9: E741 ambiguous variable name 'O'
biztax/debt.py:148:13: E741 ambiguous variable name 'O'
iMac:Business-Taxation mrh$ 

The grep statements weed out the E501 errors (lines longer than 79 characters) and weed out spacing errors in the biztax/brcparams_preTCJA.json and biztax/brcparams_preTCJA_special.json files, which appear to be unused in the Business-Taxation code.

@codykallen, I'm not planning any additional changes to this pull request unless you identify needed changes.

codykallen commented 5 years ago

@martinholmer, these changes seem fine to me.