Skip to content
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

Allow modification of AGraph attributes when copying #438

Open
rossbar opened this issue Sep 25, 2022 · 1 comment
Open

Allow modification of AGraph attributes when copying #438

rossbar opened this issue Sep 25, 2022 · 1 comment

Comments

@rossbar
Copy link
Contributor

rossbar commented Sep 25, 2022

As noted in #436, the AGraph.copy method creates new graphs that preserve attributes from the original graphs that can not otherwise be overwritten: the name attribute, for example.

>>> A = pgv.AGraph(name="test")
>>> B = A.copy()
>>> B.name == A.name
>>> B.name = "testB"
Traceback (most recent call last)
   ...
AttributeError: can't set attribute 'name'

The copy method should support renaming the graph instance. Similarly, there may be other read-only attributes of the AGraph instance that should be allowed to be modified when copying.

See #436 for further discussion.

@dschult
Copy link
Contributor

dschult commented Sep 26, 2022

It's actually slightly different (worse?) than that. B=A.copy() means that B has the empty string as the name. It is also strict even if A is not strict. Basically, B is created with the default attributes (except for directed which is copied over) and then all the nodes and edges and graph_attr values are copied over. I guess we should allow the static and name attributes to be copied over by default and maybe morphed during that process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants