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

AssertExceptions in .draw() #7

Open
rlindholm opened this issue Apr 1, 2024 · 0 comments
Open

AssertExceptions in .draw() #7

rlindholm opened this issue Apr 1, 2024 · 0 comments

Comments

@rlindholm
Copy link

from causalgraphicalmodels import CausalGraphicalModel

M1Dag = CausalGraphicalModel(
nodes=["A", "B", "C", "U", "X", "Y", "V"],
edges=[
("A", "C"),
("A", "U"),
("U", "B"),
("C", "B"),
("C", "Y"),
("U", "X"),
("X", "Y"),
("V", "C"),
("V", "Y"),
],
)

M1Dag.draw()

Raises an assertionerror due to a new decorator in graphviz, @_tools.deprecate_positional_args

Updating draw() to this will resolve the issue:

def draw(self):
    """
    dot file representation of the CGM.
    """
    dot = graphviz.Digraph()

    for node in self.observed_variables:
        if node in self.set_nodes:
            dot.node(node, shape="ellipse", peripheries="2")
        else:
            dot.node(node, shape="ellipse")

    for a, b in self.dag.edges():
        if a in self.observed_variables and b in self.observed_variables:
            dot.edge(a, b)

    for n, (a, b) in self.unobserved_variable_edges.items():
        dot.node(n, shape="point")
        dot.edge(n, a, style="dashed")
        dot.edge(n, b, style="dashed")

    return dot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant