Closed fmamitrotta closed 10 months ago
I guess I don't really understand the deepcopy interface that well, but I guess my first question is why do you not have a log? It should be there.
Good question. Where should the log come from and what does it represent? If you give me an idea of this I can try to understand why I don't have a log.
ahhh...to make pickle/shelve work, getstate (from CaseControlDeck) is used.
def __getstate__(self):
# Copy the object's state from self.__dict__ which contains
# all our instance attributes. Always use the dict.copy()
# method to avoid modifying the original state.
state = self.__dict__.copy()
# Remove the unpicklable entries.
del state['log']
return state
Removing that fixes deepcopy, but breaks the other one :/
I think the solution is probably some other double underscore method. I looked at __reduce__
, but that doesn't seem to be it. __deepcopy__
is greek to me. I can copy stuff blindly, but that tends to not work
I added your deepcopy code. It was necessary cause getstate was messing it up.
The xref bit is in there too. It's slower and not guaranteed to work, but you can turn it off if you want.
Summary
These are actually two distinct issues:
BDF
object, the deep-copied object is not cross-referenced.BDF
object, the code fails with the following error:For the second issue I've seen that the problem is in the
__getstate__
method of theCaseControlDeck
class, when thestate
dictionary does not have the'log'
key.This should be easily solvable using
state.pop('log', None)
in place ofdel state['log']
. I can create a pull request if this is ok.As far as the first issue is concerned, I actually don't know whether not cross-referencing the deep-copied
BDF
object is done on purpose. If it's not done on purpose, I would propose to modify the__deepcopy__
method of theBDF
class in the following way:Also for this I can create a pull request if this solution is acceptable.
Reproduction
Run the following code with the attached bdf file:
euler_column_linear_buckling.zip
Versions
platform.python_version()
--> 3.9.16pyNastran.__version__
--> 1.4.0+dev.no.checksum.error (this commit)