Skip to content

Commit 8052888

Browse files
chores: change case style for parameters, from nodeA to node_a for instance.
1 parent 13737ca commit 8052888

6 files changed

Lines changed: 123 additions & 121 deletions

File tree

notebooks/quickstart_demo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@
706706
"metadata": {},
707707
"outputs": [],
708708
"source": [
709-
"client_dummy_ontology.is_sibling(nodeA='F', nodeB='G')"
709+
"client_dummy_ontology.is_sibling(node_a='F', node_b='G')"
710710
]
711711
},
712712
{
@@ -745,7 +745,7 @@
745745
"metadata": {},
746746
"outputs": [],
747747
"source": [
748-
"client_dummy_ontology.get_path_between(nodeA='Q', nodeB='B')"
748+
"client_dummy_ontology.get_path_between(node_a='Q', node_b='B')"
749749
]
750750
},
751751
{

ontograph/client.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,23 @@ def is_descendant(self, descendant_node: str, ancestor_node: str) -> bool:
539539
ancestor_node=ancestor_node,
540540
)
541541

542-
def is_sibling(self, nodeA: str, nodeB: str) -> bool:
542+
def is_sibling(self, node_a: str, node_b: str) -> bool:
543543
"""Check if two terms are siblings.
544544
545545
Args:
546-
nodeA (str): First term ID.
547-
nodeB (str): Second term ID.
546+
node_a (str): First term ID.
547+
node_b (str): Second term ID.
548548
549549
Returns:
550-
bool: True if nodeA and nodeB are siblings.
550+
bool: True if node_a and node_b are siblings.
551551
552552
Example:
553553
>>> client = ClientOntology()
554554
>>> ontology = client.load(file_path_ontology="./tests/resources/dummy_ontology.obo")
555555
>>> client.is_sibling("E", "F")
556556
True
557557
"""
558-
return self._relations.is_sibling(nodeA=nodeA, nodeB=nodeB)
558+
return self._relations.is_sibling(node_a=node_a, node_b=node_b)
559559

560560
def get_common_ancestors(self, node_ids: list[str]) -> set:
561561
"""Get common ancestors of multiple terms.
@@ -610,12 +610,12 @@ def get_distance_from_root(self, term_id: str) -> int | None:
610610
"""
611611
return self._introspection.get_distance_from_root(term_id=term_id)
612612

613-
def get_path_between(self, nodeA: str, nodeB: str) -> list[dict]:
613+
def get_path_between(self, node_a: str, node_b: str) -> list[dict]:
614614
"""Get the path between two terms.
615615
616616
Args:
617-
nodeA (str): Start term ID.
618-
nodeB (str): End term ID.
617+
node_a (str): Start term ID.
618+
node_b (str): End term ID.
619619
620620
Returns:
621621
list[dict]: List of path steps.
@@ -628,7 +628,9 @@ def get_path_between(self, nodeA: str, nodeB: str) -> list[dict]:
628628
>>> client.get_path_between("N", "C")
629629
[]
630630
"""
631-
return self._introspection.get_path_between(nodeA=nodeA, nodeB=nodeB)
631+
return self._introspection.get_path_between(
632+
node_a=node_a, node_b=node_b
633+
)
632634

633635
def get_trajectories_from_root(self, term_id: str) -> list[dict]:
634636
"""Get all trajectories from the root to a term.

ontograph/queries/introspection.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ def get_distance_from_root(self, term_id: str) -> int | None:
6565

6666
return distance
6767

68-
def get_path_between(self, nodeA: str, nodeB: str) -> list[dict]:
68+
def get_path_between(self, node_a: str, node_b: str) -> list[dict]:
6969
"""Finds the trajectory (path) between two ontology terms if there is an ancestor-descendant relationship.
7070
7171
Args:
72-
nodeA (str): The ID of the first term.
73-
nodeB (str): The ID of the second term.
72+
node_a (str): The ID of the first term.
73+
node_b (str): The ID of the second term.
7474
7575
Returns:
7676
list[dict]: The path as a list of dictionaries with 'id' and 'distance' keys, or an empty list if no path exists.
@@ -79,15 +79,15 @@ def get_path_between(self, nodeA: str, nodeB: str) -> list[dict]:
7979
Exception: If an unexpected error occurs during path calculation.
8080
"""
8181
if self.__relations.is_ancestor(
82-
ancestor_node=nodeA, descendant_node=nodeB
82+
ancestor_node=node_a, descendant_node=node_b
8383
):
84-
start, end, step = nodeA, nodeB, 1
84+
start, end, step = node_a, node_b, 1
8585
elif self.__relations.is_ancestor(
86-
ancestor_node=nodeB, descendant_node=nodeA
86+
ancestor_node=node_b, descendant_node=node_a
8787
):
88-
start, end, step = nodeB, nodeA, 1
89-
elif nodeA == nodeB:
90-
return [{'id': nodeA, 'distance': 0}]
88+
start, end, step = node_b, node_a, 1
89+
elif node_a == node_b:
90+
return [{'id': node_a, 'distance': 0}]
9191
else:
9292
return []
9393

ontograph/queries/relations.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ def is_descendant(self, descendant_node: str, ancestor_node: str) -> bool:
6969
logger.error(f'Error checking descendant relationship: {e}')
7070
raise
7171

72-
def is_sibling(self, nodeA: str, nodeB: str) -> bool:
72+
def is_sibling(self, node_a: str, node_b: str) -> bool:
7373
"""Determine if two nodes are siblings (share at least one parent).
7474
7575
Args:
76-
nodeA (str): The ID of the first node.
77-
nodeB (str): The ID of the second node.
76+
node_a (str): The ID of the first node.
77+
node_b (str): The ID of the second node.
7878
7979
Returns:
8080
bool: True if the nodes are siblings (not the same node and share at least one parent), False otherwise.
@@ -83,11 +83,11 @@ def is_sibling(self, nodeA: str, nodeB: str) -> bool:
8383
Exception: If an error occurs during parent lookup.
8484
"""
8585
try:
86-
parentsA = set(self.__navigator.get_parents(term_id=nodeA))
87-
parentsB = set(self.__navigator.get_parents(term_id=nodeB))
86+
parentsA = set(self.__navigator.get_parents(term_id=node_a))
87+
parentsB = set(self.__navigator.get_parents(term_id=node_b))
8888

8989
# Siblings must not be the same node and must share at least one parent
90-
return nodeA != nodeB and bool(parentsA & parentsB)
90+
return node_a != node_b and bool(parentsA & parentsB)
9191
except Exception as e:
9292
logger.error(f'Error checking sibling relationship: {e}')
9393
raise

tests/test_queries/test_navigator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def navigator(dummy_ontology):
4242

4343
# ---- Function: __get_term()
4444
def test_get_term_valid_id(navigator):
45-
# Accessing the private method via name mangling
4645
term = navigator.get_term(term_id='G')
4746
assert term.id == 'G'
4847

0 commit comments

Comments
 (0)