-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix: deepcopy variables in clone of tax_benefit_system #1319
base: master
Are you sure you want to change the base?
Conversation
I think this is mainly used in survey-manager, @clallemand do you think it is appropriate ? I need it when creating a reform based on inflate_parameters (an openfisca-survey-manager function), otherwise I have a problem with variables losing their end_date. |
A simple copy creates a new object but references the same memory addresses for nested objects. Changes to nested objects in the copy will affect the original. Maybe you changed the variable on the original (or the copy) and got side effects. But I agree, I cannot see situation where we want attributes changes transmitted between the copy and the original of a tbs. |
I have no objection ! |
Thanks for your feedback ! The idea is that it is still possible to make the change in variables before cloning, and after it is possible to change only one of them. I don't think this transmission of changes is intentionally used by anyone, so I think it can be a minor version change even if it is technically breaking. |
setup.py
Outdated
@@ -70,7 +70,7 @@ | |||
|
|||
setup( | |||
name="OpenFisca-Core", | |||
version="43.2.7", | |||
version="43.2.8", |
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 is a minor change not a bugfix (semver).
Hi @bonjourmauko, there are some errors in the tests due to default value of arrays, do you think it is linked to your recent changes ? I can't figure why it appears here and not in the previous PR (maybe new dependencies ?), but as you worked recently on it I wondered if you had an easy fix. |
Hi @sylvainipp, my first impression is that there is a casting problem only afecting conda. As testing in conda was recently introduced, it may well be the case that the error is pre-existing. |
@@ -117,7 +117,7 @@ def _int_to_index( | |||
|
|||
""" | |||
indices = enum_class.indices | |||
values = numpy.array(value, copy=False) | |||
values = numpy.asarray(value) |
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.
Why do you need this here?
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 has no link with the original modification, it was to fix one of the errors in the conda test (here : https://github.com/openfisca/openfisca-core/actions/runs/13202963909/job/36859430121)
@@ -171,7 +171,7 @@ def _str_to_index( | |||
array([1, 1], dtype=uint8) | |||
|
|||
""" | |||
values = numpy.array(value, copy=False) | |||
values = numpy.asarray(value) |
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.
Why do you need this here?
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.
Idem
The changes look ok. The (Be aware that there is no right answer, and it depends a lot on the specs of the machine runing it.) For the test, I can see that it is wrong, because we should not mix DTypes within an array. This part looks like a hack: choicelist = [array('first_parent', dtype='<U12'), array('second_parent', dtype='<U13'), array('child', dtype='<U5'), 0]
condlist = [array([ True, False]), array([False, True]), array([False, False])] Have you tried replacing I bet there is a platform-level (low level) casting done differently within conda, or something of the sort. Or! Another option that I can think of, is that In either case, we should never have as a result a mixed DType array. Let me know how it goes :) |
Thank you for the feedback ! The code lines definitely look like the source of the error that concerns the absence of common dtype, my problem is that I can't find those lines, even with a search in vscode. Could you please tell me where it is written so I can try to fix it ? |
tests/core/parameters_fancy_indexing/test_fancy_indexing.py:177 |
Looking at the message given by NumPy, it looks like we're on the right track about the cause:
|
Thanks ! I don't understand how it is possible but I see other lines at those place : |
Technical changes