-
Notifications
You must be signed in to change notification settings - Fork 146
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
Python copy does not replicate PyDiGraph.copy() #836
Comments
The |
Here is a bandaid fix I made to add support for copy at the very least. import copyreg
import rustworkx as rx
def __pickle_pydigraph(net: rx.PyDiGraph):
return rx.PyDiGraph, (net.check_cycle,), net.__getstate__()
copyreg.pickle(rx.PyDiGraph, __pickle_pydigraph) Edit: Found a better way of doing this. |
Hmm, yeah the deep copy is a oversight and simple bug to fix, we just missed As for the shallow copy bug, I'm not sure why it's missing that attribute we don't define anything custom related to the Would you be interested in pushing a PR to fix these issues? |
From my own research into the issue, the default behavior of copy and deepcopy is to get the state using __getstate__ and set the state of a new object using __setstate__. Deepcopy further deepcopies the state in between.
The fix should only require adding check_cycle to both functions.
I can take a look at fixing it myself when I have the time, I don't imagine it will be hard.
|
Information
What is the current behavior?
check_cycles
is not copied when aPyDiGraph
is copied using the python nativecopy.copy
.What is the expected behavior?
copy.copy(PyDiGraph)
should produce identical results toPyDiGraph.copy()
.Steps to reproduce the problem
Edit: My original test used an object that
copy.deepcopy()
does not copy into a new object. Upon further testing, it behaves as expected.The text was updated successfully, but these errors were encountered: