wting / python-graph

Automatically exported from code.google.com/p/python-graph
Other
5 stars 4 forks source link

Using if(isinstance(G, graph)==True) instead of if (type(G) == graph) in dot.py #64

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If we define a new class foo(graph) which inherited from the class graph 
(or digraph) I can't use the write method since the new inherited class 
fail to pass the test type(G)==graph.

So instead of (in dot.py):

    if (type(G) == graph):
        dotG.set_type('graph')
        directed = False
    elif (type(G) == digraph):
        dotG.set_type('digraph')
        directed = True
    else:
        raise InvalidGraphType("Expected graph or digraph, got %s" %  
repr(G) )

I propose:

    if (isinstance(G, graph)==True):
        dotG.set_type('graph')
        directed = False
    elif (isinstance(G, digraph)==True):
        dotG.set_type('digraph')
        directed = True
    else:
        raise InvalidGraphType("Expected graph or digraph, got %s" %  
repr(G) )

Original issue reported on code.google.com by mlapr...@gmail.com on 12 Feb 2010 at 8:37

GoogleCodeExporter commented 9 years ago
It sounds reasonable. Should be in by the next release.

Original comment by pmatiello on 12 Feb 2010 at 9:55

GoogleCodeExporter commented 9 years ago
Thanks for the python-graph ... it's very useful.

Original comment by mlapr...@gmail.com on 13 Feb 2010 at 3:01

GoogleCodeExporter commented 9 years ago
Fixed in r677. I'm closing this issue as fixed. Let me know if this doesn't 
work for you.

Thank you for your report. I'm happy that you found this library useful.

Original comment by pmatiello on 14 Feb 2010 at 2:14

GoogleCodeExporter commented 9 years ago
Nice .. it's work !

Original comment by mlapr...@gmail.com on 15 Feb 2010 at 3:11