fix: deepcopy variables in clone of tax_benefit_system#1319
fix: deepcopy variables in clone of tax_benefit_system#1319bonjourmauko merged 4 commits intomasterfrom
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. |
|
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. |
| """ | ||
| indices = enum_class.indices | ||
| values = numpy.array(value, copy=False) | ||
| values = numpy.asarray(value) |
There was a problem hiding this comment.
Why do you need this here?
There was a problem hiding this comment.
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)
|
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 : |
|
Tu as le stack trace ici https://github.com/openfisca/openfisca-core/actions/runs/13264258879/job/37027895878?pr=1319 Ce |
c24f33d to
f7963dc
Compare
f7963dc to
e7ca4da
Compare
e7ca4da to
faf3f5b
Compare
Depends on #1321
Technical changes