-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
networkx add_node silently updates existing nodes. networkx add_edge silently addes missing nodes and updates existing edges. Add NXOntology methods that raise errors for these dangerous situations.
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from nxontology import exceptions | ||
from nxontology.ontology import NXOntology | ||
|
||
__all__ = ["NXOntology"] | ||
__all__ = ["NXOntology", "exceptions"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import networkx.exception as nx_exception | ||
|
||
|
||
class NXO_Exception(Exception): | ||
"""Base class for exceptions in nxontology.""" | ||
|
||
|
||
class DuplicateError(NXO_Exception): | ||
""" | ||
A node or edge is being added to the graph when it already exists. | ||
NetworkX add_* methods silently update existing nodes or edges, | ||
but duplicate additions often arise from dirty input data | ||
that should be explicitly addressed before graph creation. | ||
""" | ||
|
||
|
||
class NodeNotFound(NXO_Exception, nx_exception.NodeNotFound): # type: ignore [misc] | ||
"""Exception raised if requested node is not present in the graph.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters