openfisca-core icon indicating copy to clipboard operation
openfisca-core copied to clipboard

Add support for dispatch/divide by days

Open bonjourmauko opened this issue 3 years ago • 7 comments

Fixes govzeroaotearoa/openfisca-aotearoa#15 Depends on #1141

New features

  • Introduce support for the day date unit in holders.set_input_dispatch_by_period and holders.set_input_divide_by_period
    • Allows for dispatching values per day, for example, to provide a daily (week, fortnight) to an yearly variable.
    • Inversely, allows for calculating the daily (week, fortnight) value of a yearly input.

bonjourmauko avatar Jul 31 '22 19:07 bonjourmauko

Coverage Status

Coverage increased (+0.07%) to 79.005% when pulling ab90087a82d84b37b113ca3d5d137379b8950170 on fix-day-periods into e18f23be34b5964e89ee65e33669da1a0996ee73 on master.

coveralls avatar Jul 31 '22 19:07 coveralls

I will postpone reviewing this PR until the one it depends on is approved, and suggest that this one is set to draft. Indeed, I fail to see how it could be approved when #1141 might not go through.

Do you truly need #1141 for this one to be reviewed? 🙂 As an alternative to switching to draft, I suggest to remove the dependency and rebase straight on master. Yes, test-docs might fail until #1141 is fixed, but that is true of all PRs, not only of this one. This would enable reviews to be parallelised and proper solutions found for #1140 without blocking all the others.

MattiSG avatar Aug 01 '22 08:08 MattiSG

Done!

bonjourmauko avatar Aug 01 '22 17:08 bonjourmauko

I'm not sure if this is a new feature, or a bug-fix as the behaviour this adds was introduced as a replacement of a behaviour that was deprecated, however the pull request forgot to include days in that migration.

bonjourmauko avatar Aug 26 '22 11:08 bonjourmauko

@maukoquiroga : looks very good to me. Just a question: how does this PR handles month day size, february and leeap year for divide_by_period ? It does not seem to be tested although there are a bunch of tests for that in Period and Instant.

benjello avatar Aug 26 '22 12:08 benjello

@maukoquiroga : looks very good to me. Just a question: how does this PR handles month day size, february and leeap year for divide_by_period ? It does not seem to be tested although there are a bunch of tests for that in Period and Instant.

I didn't do a lot more than «reenabling» a feature that already existed.

If you see in the tests, month days are handled appropriately (31 + 28 + 30).

Maybe test should be more precise about leap years.

bonjourmauko avatar Aug 26 '22 17:08 bonjourmauko

(By the way, I think that holders implements it's own logic in terms of equivalences between days, months and years. We should see which is better, and keep just one in periods, as holder should not handle that kind of logic IMHO).

bonjourmauko avatar Aug 26 '22 17:08 bonjourmauko

@benjello @MattiSG could you please take a look at this pull request again?

bonjourmauko avatar Nov 17 '22 21:11 bonjourmauko

cc @MattiSG @benjello

bonjourmauko avatar Nov 18 '22 13:11 bonjourmauko