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

[7/17] Improve periods module doctests, documentation, and type hints #1043

Closed
wants to merge 18 commits into from

Conversation

bonjourmauko
Copy link
Member

@bonjourmauko bonjourmauko commented Sep 16, 2021

Part of #1061

@@ -0,0 +1,259 @@
from __future__ import annotations

Copy link
Member Author

Choose a reason for hiding this comment

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

@benjello My idea to abstract date units from periods, so to facilitate their extension (weeks and so on), based on indexed enums. What do you think?


"""

return DateUnit.DAY, DateUnit.MONTH, DateUnit.YEAR
Copy link
Member Author

Choose a reason for hiding this comment

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

If these were int rather than str, we could use bitwise operations, I guess that could help vectorize period operations?


.. versionadded:: 35.9.0

"""
Copy link
Member Author

Choose a reason for hiding this comment

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

This has two benefits:

  1. We consolidate the definition of date units in just one place, instead of using literals everywhere.

  2. We can, at some point, use DateUnit.Day.index instead of day or DateUnit.value. So to be able to pass from:

if period.unit == "eternity"
period.unit in ["eternirty", ...]

To :

allowed_periods = DateUnit.DAY | DateUnit.MONTH

definition_period = [0, 1, 0, 0]

isperiod = definition_period[allowed_periods]

@bonjourmauko bonjourmauko changed the title [5/10] Improve entities module doctests [5/10] Improve periods module doctests Sep 16, 2021
@bonjourmauko bonjourmauko force-pushed the fix-enum-scalar-array-bug branch 3 times, most recently from 3539db1 to 1e88559 Compare September 21, 2021 14:15
@bonjourmauko bonjourmauko added this to Inbox in OpenFisca International via automation Sep 29, 2021
@bonjourmauko bonjourmauko added kind:improvement Refactoring and code cleanup kind:theme A group of issues, directly tied to an OKR labels Sep 29, 2021
@bonjourmauko bonjourmauko modified the milestone: Doc/tests Sep 29, 2021
@bonjourmauko bonjourmauko added the kind:roadmap A group of issues, constituting a delivery roadmap label Sep 29, 2021
@bonjourmauko bonjourmauko added this to the Improved testing milestone Sep 29, 2021
@bonjourmauko bonjourmauko mentioned this pull request Oct 7, 2021
17 tasks
@bonjourmauko bonjourmauko changed the title [5/10] Improve periods module doctests [7/17] Improve periods module doctests Oct 7, 2021
@bonjourmauko bonjourmauko removed kind:theme A group of issues, directly tied to an OKR kind:roadmap A group of issues, constituting a delivery roadmap labels Oct 7, 2021
@bonjourmauko bonjourmauko changed the title [7/17] Improve periods module doctests [7/17] Improve periods module doctests, documentation, and type hints Jul 28, 2022
@bonjourmauko
Copy link
Member Author

Superseded by #1138 and #1139

OpenFisca International automation moved this from Inbox to Abandoned Dec 14, 2022
@bonjourmauko bonjourmauko deleted the doctests/periods branch December 14, 2022 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:improvement Refactoring and code cleanup
Projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant