Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/networkx/exception.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
| author | shellac |
|---|---|
| date | Mon, 01 Jun 2020 08:59:25 -0400 |
| parents | 79f47841a781 |
| children |
comparison
equal
deleted
inserted
replaced
| 4:79f47841a781 | 5:9b1c78e6ba9c |
|---|---|
| 1 # -*- coding: utf-8 -*- | |
| 2 # Copyright (C) 2004-2019 by | |
| 3 # Aric Hagberg <hagberg@lanl.gov> | |
| 4 # Dan Schult <dschult@colgate.edu> | |
| 5 # Pieter Swart <swart@lanl.gov> | |
| 6 # All rights reserved. | |
| 7 # BSD license. | |
| 8 # | |
| 9 # Authors: | |
| 10 # Aric Hagberg <hagberg@lanl.gov> | |
| 11 # Pieter Swart <swart@lanl.gov> | |
| 12 # Dan Schult <dschult@colgate.edu> | |
| 13 # Loïc Séguin-C. <loicseguin@gmail.com> | |
| 14 """ | |
| 15 ********** | |
| 16 Exceptions | |
| 17 ********** | |
| 18 | |
| 19 Base exceptions and errors for NetworkX. | |
| 20 """ | |
| 21 | |
| 22 __all__ = [ | |
| 23 'HasACycle', | |
| 24 'NodeNotFound', | |
| 25 'PowerIterationFailedConvergence', | |
| 26 'ExceededMaxIterations', | |
| 27 'AmbiguousSolution', | |
| 28 'NetworkXAlgorithmError', | |
| 29 'NetworkXException', | |
| 30 'NetworkXError', | |
| 31 'NetworkXNoCycle', | |
| 32 'NetworkXNoPath', | |
| 33 'NetworkXNotImplemented', | |
| 34 'NetworkXPointlessConcept', | |
| 35 'NetworkXUnbounded', | |
| 36 'NetworkXUnfeasible', | |
| 37 ] | |
| 38 | |
| 39 | |
| 40 class NetworkXException(Exception): | |
| 41 """Base class for exceptions in NetworkX.""" | |
| 42 | |
| 43 | |
| 44 class NetworkXError(NetworkXException): | |
| 45 """Exception for a serious error in NetworkX""" | |
| 46 | |
| 47 | |
| 48 class NetworkXPointlessConcept(NetworkXException): | |
| 49 """Raised when a null graph is provided as input to an algorithm | |
| 50 that cannot use it. | |
| 51 | |
| 52 The null graph is sometimes considered a pointless concept [1]_, | |
| 53 thus the name of the exception. | |
| 54 | |
| 55 References | |
| 56 ---------- | |
| 57 .. [1] Harary, F. and Read, R. "Is the Null Graph a Pointless | |
| 58 Concept?" In Graphs and Combinatorics Conference, George | |
| 59 Washington University. New York: Springer-Verlag, 1973. | |
| 60 | |
| 61 """ | |
| 62 | |
| 63 | |
| 64 class NetworkXAlgorithmError(NetworkXException): | |
| 65 """Exception for unexpected termination of algorithms.""" | |
| 66 | |
| 67 | |
| 68 class NetworkXUnfeasible(NetworkXAlgorithmError): | |
| 69 """Exception raised by algorithms trying to solve a problem | |
| 70 instance that has no feasible solution.""" | |
| 71 | |
| 72 | |
| 73 class NetworkXNoPath(NetworkXUnfeasible): | |
| 74 """Exception for algorithms that should return a path when running | |
| 75 on graphs where such a path does not exist.""" | |
| 76 | |
| 77 | |
| 78 class NetworkXNoCycle(NetworkXUnfeasible): | |
| 79 """Exception for algorithms that should return a cycle when running | |
| 80 on graphs where such a cycle does not exist.""" | |
| 81 | |
| 82 | |
| 83 class HasACycle(NetworkXException): | |
| 84 """Raised if a graph has a cycle when an algorithm expects that it | |
| 85 will have no cycles. | |
| 86 | |
| 87 """ | |
| 88 | |
| 89 | |
| 90 class NetworkXUnbounded(NetworkXAlgorithmError): | |
| 91 """Exception raised by algorithms trying to solve a maximization | |
| 92 or a minimization problem instance that is unbounded.""" | |
| 93 | |
| 94 | |
| 95 class NetworkXNotImplemented(NetworkXException): | |
| 96 """Exception raised by algorithms not implemented for a type of graph.""" | |
| 97 | |
| 98 | |
| 99 class NodeNotFound(NetworkXException): | |
| 100 """Exception raised if requested node is not present in the graph""" | |
| 101 | |
| 102 | |
| 103 class AmbiguousSolution(NetworkXException): | |
| 104 """Raised if more than one valid solution exists for an intermediary step | |
| 105 of an algorithm. | |
| 106 | |
| 107 In the face of ambiguity, refuse the temptation to guess. | |
| 108 This may occur, for example, when trying to determine the | |
| 109 bipartite node sets in a disconnected bipartite graph when | |
| 110 computing bipartite matchings. | |
| 111 | |
| 112 """ | |
| 113 | |
| 114 | |
| 115 class ExceededMaxIterations(NetworkXException): | |
| 116 """Raised if a loop iterates too many times without breaking. | |
| 117 | |
| 118 This may occur, for example, in an algorithm that computes | |
| 119 progressively better approximations to a value but exceeds an | |
| 120 iteration bound specified by the user. | |
| 121 | |
| 122 """ | |
| 123 | |
| 124 | |
| 125 class PowerIterationFailedConvergence(ExceededMaxIterations): | |
| 126 """Raised when the power iteration method fails to converge within a | |
| 127 specified iteration limit. | |
| 128 | |
| 129 `num_iterations` is the number of iterations that have been | |
| 130 completed when this exception was raised. | |
| 131 | |
| 132 """ | |
| 133 | |
| 134 def __init__(self, num_iterations, *args, **kw): | |
| 135 msg = 'power iteration failed to converge within {} iterations' | |
| 136 exception_message = msg.format(num_iterations) | |
| 137 superinit = super(PowerIterationFailedConvergence, self).__init__ | |
| 138 superinit(self, exception_message, *args, **kw) |
