Skip to content

Commit

Permalink
[knowledge] Adjusted doc according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigul committed Nov 26, 2024
1 parent 2ea9641 commit 3716870
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/pycram/datastructures/partial_designator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def __iter__(self) -> Type[ActionDesignatorDescription.Action]:
@staticmethod
def generate_permutations(args: Iterable) -> List:
"""
Generates all possible permutations of the given arguments. This uses itertools.product to generate the
permutations.
Generates the cartesian product of the given arguments. Arguments can also be a list of lists of arguments.
:param args: An iterable with arguments
:yields: A list with a possible permutation of the given arguments
Expand Down
17 changes: 6 additions & 11 deletions src/pycram/datastructures/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def successful(self) -> bool:
@property
def resolved(self) -> bool:
"""
Returns True if all nodes in the tree are resolved. This is done by iterating over the tree and checking if all
nodes are either a ResolvedProperty or a PropertyOperator.
Returns True if all nodes in the tree are resolved and are either of type ResolvedProperty or PropertyOperator.
:return: True if all nodes in the tree are resolved, False otherwise
"""
Expand Down Expand Up @@ -140,8 +139,7 @@ def __init__(self, properties: List[Property]):

def simplify(self):
"""
Simplifies the tree structure by merging nodes of the same type. This is done by iterating over the tree and
merging nodes of the same type.
Simplifies the tree structure by merging nodes of the same type.
:return: Returns the root node of the tree
"""
Expand All @@ -166,8 +164,7 @@ def merge_nodes(node1: Node, node2: Node) -> None:

class And(PropertyOperator):
"""
Class to represent a logical and operator in a tree structure. This class inherits from PropertyOperator and adds a
method to evaluate the children as an and operator.
Represents a logical AND between multiple properties.
"""

def __init__(self, properties: List[Property]):
Expand Down Expand Up @@ -213,8 +210,7 @@ def __call__(self, *args, **kwargs) -> ReasoningResult:

class Or(PropertyOperator):
"""
Class to represent a logical or operator in a tree structure. This class inherits from PropertyOperator and adds a
method to evaluate the children as an or operator.
Represents a logical OR between multiple properties.
"""

def __init__(self, properties: List[Property]):
Expand Down Expand Up @@ -257,8 +253,7 @@ def __call__(self, *args, **kwargs) -> ReasoningResult:

class Not(PropertyOperator):
"""
Class to represent a logical not operator in a tree structure. This class inherits from PropertyOperator and adds a
method to evaluate the children as a not operator.
Represents a logical NOT of a single property.
"""

def __init__(self, property: Property):
Expand Down Expand Up @@ -295,7 +290,7 @@ def __call__(self, *args, **kwargs) -> ReasoningResult:

class ResolvedProperty(Property):
"""
Class to represent a executed property function. It holds the reference to the respective function in the knowledge
Represents a resolved property function. It holds the reference to the respective function in the knowledge
source and the exception that should be raised if the property is not fulfilled. Its main purpose is to manage the
call to the property function as well as handle the input and output variables.
"""
Expand Down
6 changes: 6 additions & 0 deletions test/knowledge_testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@


class TestProperty(Property):
"""
A Mock Property for testing the property implementation
"""
property_exception = ReasoningError

def __init__(self, pose: Pose):
Expand All @@ -23,6 +26,9 @@ def test(self, pose: Pose) -> ReasoningResult:


class TestKnowledge(KnowledgeSource, TestProperty):
"""
A Mock KnowledgeSource for testing the knowledge_source implementation
"""
def __init__(self):
super().__init__("test_source", 1)
self.parameter = {}
Expand Down

0 comments on commit 3716870

Please sign in to comment.