Skip to content
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

Enforce simplify-periods PR from openfisca-core #685

Merged
merged 58 commits into from
Mar 6, 2017
Merged

Conversation

michelbl
Copy link

@michelbl michelbl commented Feb 16, 2017

Connected to openfisca/openfisca-core#442

Related to openfisca/openfisca-core#452

  • Add attribute period_behavior
  • Remove period = period.this_***
  • Resolve period missmatches
  • Resolve tricky cases

@@ -168,7 +166,9 @@ def nb_enf(famille, period, age_min, age_max):
Renvoie le nombre d'enfant au sens des allocations familiales dont l'âge est compris entre ag1 et ag2
"""

period = period.this_month
assert period.unit == u'month'
assert period.size == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you put those assertions here to replace period = period.this_month and not elsewhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because nb_enf is a helper function that is used in other modules. Do you see a better solution ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I did not see that because of the diff display. All right then.

I don't want to open here a debate on helpers vs variables, but we're right in here.

@michelbl
Copy link
Author

michelbl commented Feb 17, 2017

https://github.com/openfisca/openfisca-france/blob/master/openfisca_france/model/prestations/minima_sociaux/aah.py#L79

pensions_alimentaires_percues is a yearly variable that comes from CERFA. Its value is requested for a period of 3 months. I think this is a usage of "add_divide"

@benjello
Copy link
Member

When pensions_almimentaires_percues comes from fiscal data it is yearly (CERFA). When used for some prestations it is its monthly value that is needed .
When you need the value of a parameter at the month level it is better to use the smaller unit in the definition of the variable.
There might be problem arising from filling the value (initialisation) and or memory management (stock the same value) but it is be context dependent.

@michelbl
Copy link
Author

Because of the explicit period management that is now required, a month must be given to call a monthly variable from a yearly variable. I use janvier (same as before but explicit now) whenever it is needed :

janvier = period.this_month
age = simulation.calculate('age', janvier)

@michelbl
Copy link
Author

michelbl commented Feb 17, 2017

@benjello on second thought that is exactly what I concluded and what I implemented.

Filling the value is correctly handled by set_input_divide_by_period.

There is redondancy but this can be adressed by numpy references. However I am reluctant to address optimization issues in this PR.

@michelbl
Copy link
Author

michelbl commented Feb 24, 2017

All the tests pass in my development environment, however that is not the case for travis. Somebody has a hint ?

Edit : this is certainly caused by travis installing openfisca-core/master instead of the new version still not merged.

Edit : travis now installs the correct version, but a test fails. I can't understand why :

  • some tests are ran by travis but not in my dev environment
  • the first failure stops tests but not in my dev env
  • I get the name of the yaml test case in my dev env in case of failure, but not in the travis output 😕

Edit : I needed to install inversion_revenus in my dev environment.

@michelbl michelbl requested a review from fpagnoux February 24, 2017 14:00
@michelbl michelbl self-assigned this Feb 24, 2017
@fpagnoux fpagnoux self-assigned this Feb 24, 2017
@michelbl michelbl changed the title WIP: Enforce simplify-periods PR from openfisca-core Enforce simplify-periods PR from openfisca-core Feb 27, 2017
@MattiSG MattiSG changed the title Enforce simplify-periods PR from openfisca-core Enforce simplify-periods PR from openfisca-core Feb 28, 2017
@michelbl michelbl force-pushed the simplify-periods branch 2 times, most recently from e7872bd to 0cfc353 Compare March 2, 2017 17:24
@@ -748,9 +757,10 @@ class taille_entreprise(Variable):
entity = Individu
label = u"Catégorie de taille d'entreprise"
url = u"http://www.insee.fr/fr/themes/document.asp?ref_id=ip1321"
period_unit = MONTH
calculate_output = calculate_output_first_month
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si le seul but est de faire passer ce test, autant modifier le test, vu que la période y est arbitraire.



class age_en_mois(Variable):
base_function = missing_value
column = AgeCol(val_type = "months")
entity = Individu
label = u"Âge (en mois)"
period_unit = MONTH
calculate_output = calculate_output_first_month
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Y a-t-il vraiment un sens à calculer un age_en_mois pour une année ? Ce test le fait, mais le test sur les valeurs annuelles me paraît peu pertinent.



class enfant_a_charge(Variable):
column = BoolCol
entity = Individu
label = u"Enfant à charge non marié, de moins de 18 ans au 1er janvier de l'année de perception des" \
u" revenus, ou né durant la même année, ou handicapés quel que soit son âge"
period_unit = MONTH
calculate_output = calculate_output_first_month
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette variable semble très liée à l'impôt , et donc plutôt annuelle. Elle est appelée une seule fois par une variable mensuelle (dans cmu.py). Plutôt que de la définir en mensuelle et de rajouter un calculate_output, je suggère plutôt que l'unique appellant mensuel s'adapte et qu'on la définisse en annuel.

Copy link
Member

@fpagnoux fpagnoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besoin d'une discussion IRL pour voir si ces 4 tests sont vraiment à déprécier 😏 :

test_mes_aides_5591635b7ae4c40130761eb7
test_mes_aides_54c2259755fa25a535d69571
test_mes_aides_54be84abdee70bd172bf3ba3
test_mes_aides_5421322ffb35830200b3133b

requirements.txt Outdated
@@ -1,5 +1,5 @@
# Add Biryani extra requirement here because it is needed by OpenFisca-Core and installation from Git URL below
# does not take extras_require of Core setup.py into account.
Biryani[datetimeconv] >= 0.10.4
--editable git+https://github.com/openfisca/openfisca-core.git#egg=OpenFisca-Core
--editable git+https://github.com/openfisca/openfisca-core.git@simplify-periods#egg=OpenFisca-Core
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si c'est temporaire, attention à bien penser à le reverter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui bien vu ! Il faut surtout pas merger ça.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quand je commit ce genre de chose, j'ai pour habitude de préfixer le commit par un gros [TO REVERT], pour que ce soit plus facilement visible à la review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quand je commit ce genre de chose, j'ai pour habitude de préfixer le commit par un gros [TO REVERT], pour que ce soit plus facilement visible à la review.

@michelbl michelbl force-pushed the simplify-periods branch 2 times, most recently from 9510a58 to fcece09 Compare March 6, 2017 14:10
@fpagnoux fpagnoux mentioned this pull request Mar 6, 2017
@fpagnoux fpagnoux merged commit 97a8ba6 into master Mar 6, 2017
@fpagnoux fpagnoux deleted the simplify-periods branch March 6, 2017 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants