Skip to content

AssertExceptions in .draw() #7

@rlindholm

Description

@rlindholm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions