thelfer / tfel

Main repository of TFEL/MFront project
https://thelfer.github.io/tfel/web/index.html
Other
87 stars 40 forks source link

MTestCurrentState.copy() produces a shallow copy in python bindings #567

Closed LordKthulhu closed 4 months ago

LordKthulhu commented 4 months ago

Discussed in https://github.com/thelfer/tfel/discussions/564

Originally posted by **LordKthulhu** May 20, 2024 Hi Thomas, I'm trying to get a deep copy of the `mtest` state in the `python` module. I create a state `s`, initialize it, copy it (`backup = s.copy()`), and run some calculations on the state `s`. I'm expecting the backup to hold the values of the initial states, but to the contrary it is as if the copy is shallow. I made a MWE: [MWE.zip](https://github.com/thelfer/tfel/files/15378770/MWE.zip). I was expecting `backup` to have the same value that I pulled from the state `s` as it was being copied. Thanks in advance, Maxime
thelfer commented 4 months ago

@LordKthulhu Could you give branch 567-mtestcurre... a try ? I introduced a method named makeDeepCopy in the MTestCurrentState class. Seems working on your MWE.

LordKthulhu commented 4 months ago

Hi @thelfer, Thank you so much for the quick fix ! I tested it and it seems the new method produces a proper deep copy of the state.

thelfer commented 4 months ago

Great. I'll merge it to master ASAP.