我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用networkx.__version__()。
def check_dependencies(): try: import nose logger.debug("\tNose: %s\n" % str(nose.__version__)) except ImportError: raise ImportError("Nose cannot be imported. Are you sure it's " "installed?") try: import networkx logger.debug("\tnetworkx: %s\n" % str(networkx.__version__)) except ImportError: raise ImportError("Networkx cannot be imported. Are you sure it's " "installed?") try: import pymongo logger.debug("\tpymongo: %s\n" % str(pymongo.version)) from bson.objectid import ObjectId except ImportError: raise ImportError("Pymongo cannot be imported. Are you sure it's" " installed?") try: import numpy logger.debug("\tnumpy: %s" % str(numpy.__version__)) except ImportError: raise ImportError("Numpy cannot be imported. Are you sure that it's" " installed?") try: import scipy logger.debug("\tscipy: %s" % str(scipy.__version__)) except ImportError: raise ImportError("Scipy cannot be imported. Are you sure that it's" " installed?")
def __loadGMLFiles__(self): """ Iterates through all of the files inside of support directory merges these graphs with the whole gapGraph creates a dictionary of {"readName":[gapName or nodeName,...] } """ self.readSupport = defaultdict(list) for i in glob.glob(os.path.join(self.protocol.outDir,"support","*.gml")): truncNxVer = float('.'.join(networkx.__version__.split('.')[:2])) if truncNxVer >= 1.7: try: inputGml = networkx.read_gml(i, relabel=True) except ValueError: logging.warning("GML file %s is empty" % i) continue elif truncNxVer == 1.1: inputGml = networkx.read_gml(i) else: logging.warning("It is unknown if networkx version %s will work." % networkx.__version__) logging.warning("If you get an error here, please report it!!!") inputGml = networkx.read_gml(i) for node in inputGml.nodes_iter(): for readName in inputGml.node[node]['extenders'].split(':'): if readName == '': continue trimInfo = self.__cleanReadName__(readName) self.gapGraph.add_extend(node, trimInfo.name) self.readSupport[trimInfo.name].append((node, trimInfo)) for source, target, evidence in inputGml.edges_iter(data=True): for readName in evidence['evidence'].split(':'): if readName == '': continue trimInfo = self.__cleanReadName__(readName) self.gapGraph.add_evidence(source, target, trimInfo.name) self.readSupport[trimInfo.name].append((source, target, trimInfo)) self.readSupport = dict(self.readSupport)
def loadParameters(self): print("NetworkX version %s running" % nx.__version__) print("Matplotlib version %s running\n" % mplt.__version__) nxv = nx.__version__ vOK = checkVersion(nxv, 'NetworkX', 1, 9, 1) if not vOK: print("NetworkX 1.9.1 or greater required") os.sys.exit(1) mpltv = mplt.__version__ vOK = checkVersion(mpltv, 'Matplotlib', 1, 5, 1) if not vOK: print("Matplotlib 1.5.1 or greater required") os.sys.exit(1) mySeed = eval(input("random number seed (1 to get it from the clock) ")) if mySeed == 1: random.seed() else: random.seed(mySeed) self.nAgents = 0 print("No 'bland' agents") #self.worldXSize= input("X size of the world? ") self.worldXSize = 1 print("X size of the world not relevant") #self.worldYSize= input("Y size of the world? ") self.worldYSize = 50 print("y size of the world not relevant") # recipes common.maxLenght = 10 common.maxSector = 6 print( "recipes: max lenght", common.maxLenght, "and max sector number", common.maxSector) self.nCycles = eval(input("How many cycles? (0 = exit) ")) v = input("verbose? (y/[n]) ") if v == "y" or v == "Y": common.verbose = True # predefined False