causalgraphicalmodels icon indicating copy to clipboard operation
causalgraphicalmodels copied to clipboard

AssertExceptions in .draw()

Open rlindholm opened this issue 1 year ago • 0 comments

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

rlindholm avatar Apr 01 '24 23:04 rlindholm