-
Notifications
You must be signed in to change notification settings - Fork 75
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
Allow variable neutralization in YAML test files #1021
base: master
Are you sure you want to change the base?
Conversation
@benjello Do you have an example where you needed to neutralize a variable in a YAML test?
|
It is useful when you will use a specific "reform" of the tax benefit system consisting only of neutralizing some variables for example to avoid never ending spirals for example to focus on some specific domains. Our use case right now is France's assurance-chômage. |
@sandcha @maukoquiroga : can I merge this PR ? |
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.
Thank you @benjello for this new feature!
Here is a commit with a test example that fails. Could you fix it or update the way of testing the feature? 🤔
@benjello Is it also true to say that to check the French unemployment insurance (that, in its last reform, neutralizes some old incomes when a person becomes unemployed), it's useful to define YAML tests with the neutralized incomes to check the unemployment insurance formula? |
@sandcha : I was more concerned by neutralizing many resources that may induce spirals that needs a lot of initialisation to be circumvent. |
And I do not understand why the test is not passing since it passes locally on my computer ... |
@benjello in case we have a difference on the command, here is what I used: pytest tests/core/test_yaml.py
|
@sandcha : I used
and it pass. But if i try exactly what you did I do have a failure. Which is strange BTW. |
The error at The |
When we run Then, when we look further:
|
@sandcha : can I help you on this or are you still exploring ? |
@benjello Yes, of course it would be great if you looked into the holders difference between the pytest and the openfisca test command! That's why I shared the last debugging results above :) |
I am not sure I can help you a lot with the pytest machinery I never used ... Can't we, actually shoudn't we, align both ? @MattiSG @maukoquiroga we need you here ! |
@cbenz : could you help us here ? |
Yes, this is a major issue if both are expected to be used interchangeably. However, I only see references to @sandcha under which circumstances do you use |
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.
I don't have a strong opinion on the code, it seems of consistent quality and readability with the existing codebase.
I fail to understand two points:
- In which way is this different from forcing the value of a variable to some value in the tested situation?
- Can you please confirm this only makes available in YAML declarative tests a feature that already exists in the Python API (
neutralize_variable
)?
In any case, this behaviour should be documented (both Python and YAML).
Thanks @MattiSG for your questions:
I will open a companion doc if it is ok with you. |
It is actually documented on the pyhton API but the doc is broken as noted here. |
Thank you for these replies @benjello! Unblocking this PRI understand that:
I honestly start wondering if we should not get rid of the Makefile altogether and move the instructions in Syntax discussionIt is probably a good thing to enable further YAML / Python equivalence. - name: "Result outside neutralized variables"
period: 2021-01
neutralized_variables:
- housing_allowance
input:
age: 30
output:
basic_income: 600 Is “neutralising” the variable an economic domain term? If not, I would be more in favour of being more explicit and using something like - name: "Result outside neutralized variables"
period: 2021-01
input:
age: 30
output:
basic_income: 600
force_default:
- housing_allowance Alternatively, what about using a special - name: "Result outside neutralized variables"
period: 2021-01
input:
age: 30
output:
basic_income: 600
housing_allowance: default |
@MattiSG : I am not opposed to a change in terminology. |
Ah, that's an important point to note indeed! Then, there is a bit of an issue with the current syntax, as What about |
Then I would prefer
|
I think the use of |
27c7cfc
to
201db36
Compare
Most probably, and if there's some more work to do it is lost in the middle of #1031. By the way, yaml tests in core are not meant to be run "as-is" they're there to test the Yaml Test API (some of them are expected to fail). |
201db36
to
b9984f2
Compare
@maukoquiroga : I rebased after the recent fix of the doc but there are still problems with this PR I do not understand. |
@benjello I think it is because you have to rebase also the corresponding branch in the doc. |
@maukoquiroga : I do not understand what I am supposed to do to have the tests passing. Do you mean that I have to merge the doc branch first ? |
@maukoquiroga @MattiSG @sandcha : could you give me a hint of what I should fix to have this PR and its companion openfisca/openfisca-doc#252. Thanks ! |
Fix text for comparison with country-template parameter Bump Update CHANGELOG.md Co-authored-by: sandcha <sandcha@users.noreply.github.com> Test neutralized_variables new attribute for YAML tests Update CHANGELOG.md Co-authored-by: sandcha <sandcha@users.noreply.github.com> Add tbs with neutralized variables to yaml tbs cache fixup! Add tbs with neutralized variables to yaml tbs cache Add test on yaml runner on tbs cache with neutralized variable fixup! Add test on yaml runner on tbs cache with neutralized variable
1b8642e
to
e07cac4
Compare
@maukoquiroga : I rebased this branch and there is a broken test and I cannot understand why ! |
Connected to openfisca/openfisca-france#1481
New features