-
Notifications
You must be signed in to change notification settings - Fork 76
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
Round up numbers #699
Comments
The Hypotheses :
|
It sounds reasonable to me to keep as high precision as possible until exporting values. Rounding errors can be quite problematic considering how many times formulas can be chained. Then again, there are already rounding errors… What about using the |
From my point of view there are two different problems here:
Tentative answers:
|
To give some more information : import openfisca_country_template
country = openfisca_country_template
tax_benefit_system = country.CountryTaxBenefitSystem()
scenario = tax_benefit_system.new_scenario().init_from_attributes(
period='2016-01',
input_variables={'salary': 1000},
)
simulation = scenario.new_simulation()
for i in range(100):
print(simulation.calculate('tax_incentive', period = '2016-01')) Has the following output :
The folowing test : - name: Someone making 1000 should get a 333 tax incentive
period: 2016-01
input_variables:
salary: 1000
output_variables:
tax_incentive:
2016-01: 333.3333 has the following output:
The following tests pass: - name: Someone making 1000 should get a 333 tax incentive
period: 2016-01
input_variables:
salary: 1000
output_variables:
tax_incentive:
2016-01: 333.33334
- name: Someone making 1000 should get a 333 tax incentive
period: 2016-01
input_variables:
salary: 1000
output_variables:
tax_incentive:
2016-01: 333.33333 |
After some work with @fpagnoux here is what we discovered :
Our proposed solution is to:
Finally, it seems strange to ask for a margin of error in most tests when the result is often in currency, that has a limited number of decimals. There could be the case of a 'currency' option in tests that rounds result (e.g. 2 decimal numbers for the Euro) |
@Anna-Livia @fpagnoux : please keep in mind that we want to allow the use of say float16 etc to save memory when needed. |
Right now the float precision is hard-coded in the Core to |
@fpagnoux : it was a long time ago (it might be for integers). For now it is not needed, but we may want control at some point in the future the bits used to code variables so I do not want have insert in the code elements that may forbids that. But it was worthing investigating it and I am definitively ok with the conclusions you (@Anna-Livia |
Some formula result have too many decimal numbers.
Impact :
The text was updated successfully, but these errors were encountered: