-
Notifications
You must be signed in to change notification settings - Fork 82
Allow array parameters #982
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
Conversation
CI should be fixed by #981. |
Output from web-api should be checked before merging. |
63447bd
to
f6172d9
Compare
f6172d9
to
4e66961
Compare
@benjello can you please confirm this should not damage vectorial computation performance? |
Documentation update can be reviewed at openfisca/openfisca-doc#234. |
I do not see how this could damage vectorial computation. LGTM. |
API output tested manually on a fork of the country template, got the following result: {
"description": "Array types should be allowed.",
"id": "general.array_type",
"metadata": {},
"source": "https://github.com/openfisca/country-template/blob/3.12.4/openfisca_country_template/parameters/general/array_type.yaml",
"values": {
"2018-06-01": ["ES", "FR", "IT", "NZ"],
"2013-01-01": ["FR"]
}
} Not sure about how the legislation explorer will format these results, though. |
openfisca_core/parameters.py
Outdated
# It is now recommended to include them in metadata, until a common consensus emerges. | ||
COMMON_KEYS = {'description', 'metadata', 'unit', 'reference', 'documentation'} | ||
ALLOWED_PARAM_TYPES = (float, int, bool, type(None)) | ||
ALLOWED_PARAM_TYPES = (float, int, bool, type(None), typing.List) |
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.
Any preference between typing.List
and just List
? Asking just for consistency (current usage is from typing import XXX
, but that is not consistent with other libraries usage, for example numpy
and so on).
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.
No preference.
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.
Could you use from typing import List
just for consistency? Otherwise GTM :)
|
||
def test_array_type(): | ||
path = os.path.join(BASE_DIR, 'array_type.yaml') | ||
load_parameter_file(path, 'array_type') |
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.
load_parameter_file(path, 'array_type') | |
assert load_parameter_file(path, 'array_type') |
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.
It will anyway pass as it is a truthy value -otherwise it would fail. Just a proposition for reader's clarity.
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.
Thanks for this contribution! Looks good to me ✨
Co-authored-by: Mauko Quiroga <[email protected]>
Co-authored-by: Mauko Quiroga <[email protected]>
f646d36
to
77d5808
Compare
@maukoquiroga @benjello you approved this PR —thanks again! 🙂 Would you mind spending 3 minutes reviewing the associated doc update? It's really short and would avoid an outdated documentation to create confusion: openfisca/openfisca-doc#234 |
Technical changes
This was added to move more constants into parameters. For example, in OpenFisca-France: https://github.com/openfisca/openfisca-france/blob/master/openfisca_france/model/caracteristiques_socio_demographiques/demographie.py#L3-L35
TODO :