MCPcopy Create free account
hub / github.com/ActiveState/code / _validate

Method _validate

recipes/Python/578615_graph/recipe-578615.py:591–605  ·  view source on GitHub ↗

Check graph invariants. >>> g = Graph() >>> g[1] = {2: 3, 3: 9} >>> g._validate() >>> dict.__setitem__(g, 1, {2: 3, 3: 9}) #bypass Graph >>> g._validate() Traceback (most recent call last): AssertionError: vertex type not found on 1

(self)

Source from the content-addressed store, hash-verified

589 def copy(self): raise NotImplementedError
590
591 def _validate(self):
592 """Check graph invariants.
593
594 >>> g = Graph()
595 >>> g[1] = {2: 3, 3: 9}
596 >>> g._validate()
597 >>> dict.__setitem__(g, 1, {2: 3, 3: 9}) #bypass Graph
598 >>> g._validate()
599 Traceback (most recent call last):
600 AssertionError: vertex type not found on 1
601 """
602 #NOTE: calling this after each add/discard slows things down considerably!
603 for vid, v in self.iteritems():
604 assert isinstance(v, self.VertexType), "vertex type not found on " + str(vid)
605 v._validate()
606
607
608def gprofile(g, size=100):

Callers 6

discardMethod · 0.95
__str__Method · 0.95
displayMethod · 0.95
_validateMethod · 0.45
_validateMethod · 0.45
__str__Method · 0.45

Calls 2

strFunction · 0.85
iteritemsMethod · 0.45

Tested by

no test coverage detected