Skip to content

Commit

Permalink
fix: word spelling problem in XAgent/data_structure/plan.py (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
shouldnotappearcalm authored Mar 4, 2024
1 parent 95893d5 commit 3619c25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .project_hierarchy.json
Original file line number Diff line number Diff line change
Expand Up @@ -6774,7 +6774,7 @@
"code_end_line": 152,
"parent": null,
"have_return": true,
"code_content": "class Plan():\n \"\"\"Class representing a task plan.\n\n Attributes:\n father (Optional[Plan]): Parent task plan.\n children (List[Plan]): List of child task plans.\n data (TaskSaveItem): Data items related to the task plan.\n process_node (ToolNode): Node responsible for the task plan processing.\n \"\"\"\n \n def __init__(self, data: TaskSaveItem):\n \"\"\"Initialises a Plan object.\n\n Args:\n data (TaskSaveItem): Data related to the task plan.\n \"\"\"\n self.father: Optional[Plan] = None\n self.children: List[Plan] = []\n self.data: TaskSaveItem = data\n self.process_node: ToolNode = None \n \n def to_json(self, posterior=True):\n \"\"\"Converts Plan object to JSON.\n\n Args:\n posterior (bool): Determines whether the task's posterior data \n is also returned.\n\n Returns:\n root_json (dict): JSON format representation of the Plan object.\n \"\"\"\n root_json = self.data.to_json(posterior=posterior)\n if self.process_node:\n root_json[\"submit_result\"] = self.process_node.data[\"command\"][\"properties\"]\n\n # if self.father != None:\n root_json[\"task_id\"] = self.get_subtask_id(to_str=True)\n if len(self.children) > 0:\n root_json[\"subtask\"] = [ subtask.to_json() for subtask in self.children]\n return root_json\n \n def get_subtask_id(self, to_str=False):\n \"\"\"Gets the subtask ID.\n\n Args:\n to_str (bool): Determines if returned ID is string.\n\n Returns:\n subtask_id_list (list): List of subtask IDs.\n \"\"\"\n subtask_id_list = self.get_subtask_id_list()\n if to_str:\n subtask_id_list = [str(cont) for cont in subtask_id_list]\n return \".\".join(subtask_id_list)\n else:\n return subtask_id_list\n\n def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n fahter_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n fahter_subtask_id.append(child_id)\n return fahter_subtask_id\n \n @classmethod\n def make_relation(cls, father, child):\n \"\"\"Establishes a parent-child relationship between two plans.\n\n Args:\n father: Parent plan.\n child: Child plan.\n \"\"\"\n father.children.append(child)\n child.father = father\n\n def get_root(self):\n \"\"\"Fetches the root of the Plan tree.\n\n Returns:\n Root Plan object.\n \"\"\"\n if self.father == None:\n return self\n return self.father.get_root()\n\n def get_depth(self):\n \"\"\"Returns the depth of the Plan tree.\n\n Returns:\n Tree depth as an integer.\n \"\"\"\n if self.father == None:\n return 1\n return 1 + self.father.get_depth()\n\n @classmethod\n def get_inorder_travel(cls, now_plan):\n \"\"\"Performs an inorder traversal of the plan tree.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n All plans in the tree in inorder.\n \"\"\"\n result_list = [now_plan]\n for child in now_plan.children:\n result_list.extend(Plan.get_inorder_travel(child))\n return result_list\n\n @classmethod\n def pop_next_subtask(cls, now_plan):\n \"\"\"Fetches the next subtask in the queue.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Next subtask in the queue.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n for subtask in all_plans[order_id + 1:]:\n if subtask.data.status == TaskStatusCode.TODO:\n return subtask\n return None\n\n @classmethod\n def get_remaining_subtask(cls, now_plan):\n \"\"\"Gets all remaining subtasks from a given point.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Array of all remaining subtasks.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n return all_plans[order_id:]",
"code_content": "class Plan():\n \"\"\"Class representing a task plan.\n\n Attributes:\n father (Optional[Plan]): Parent task plan.\n children (List[Plan]): List of child task plans.\n data (TaskSaveItem): Data items related to the task plan.\n process_node (ToolNode): Node responsible for the task plan processing.\n \"\"\"\n \n def __init__(self, data: TaskSaveItem):\n \"\"\"Initialises a Plan object.\n\n Args:\n data (TaskSaveItem): Data related to the task plan.\n \"\"\"\n self.father: Optional[Plan] = None\n self.children: List[Plan] = []\n self.data: TaskSaveItem = data\n self.process_node: ToolNode = None \n \n def to_json(self, posterior=True):\n \"\"\"Converts Plan object to JSON.\n\n Args:\n posterior (bool): Determines whether the task's posterior data \n is also returned.\n\n Returns:\n root_json (dict): JSON format representation of the Plan object.\n \"\"\"\n root_json = self.data.to_json(posterior=posterior)\n if self.process_node:\n root_json[\"submit_result\"] = self.process_node.data[\"command\"][\"properties\"]\n\n # if self.father != None:\n root_json[\"task_id\"] = self.get_subtask_id(to_str=True)\n if len(self.children) > 0:\n root_json[\"subtask\"] = [ subtask.to_json() for subtask in self.children]\n return root_json\n \n def get_subtask_id(self, to_str=False):\n \"\"\"Gets the subtask ID.\n\n Args:\n to_str (bool): Determines if returned ID is string.\n\n Returns:\n subtask_id_list (list): List of subtask IDs.\n \"\"\"\n subtask_id_list = self.get_subtask_id_list()\n if to_str:\n subtask_id_list = [str(cont) for cont in subtask_id_list]\n return \".\".join(subtask_id_list)\n else:\n return subtask_id_list\n\n def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n father_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n father_subtask_id.append(child_id)\n return father_subtask_id\n \n @classmethod\n def make_relation(cls, father, child):\n \"\"\"Establishes a parent-child relationship between two plans.\n\n Args:\n father: Parent plan.\n child: Child plan.\n \"\"\"\n father.children.append(child)\n child.father = father\n\n def get_root(self):\n \"\"\"Fetches the root of the Plan tree.\n\n Returns:\n Root Plan object.\n \"\"\"\n if self.father == None:\n return self\n return self.father.get_root()\n\n def get_depth(self):\n \"\"\"Returns the depth of the Plan tree.\n\n Returns:\n Tree depth as an integer.\n \"\"\"\n if self.father == None:\n return 1\n return 1 + self.father.get_depth()\n\n @classmethod\n def get_inorder_travel(cls, now_plan):\n \"\"\"Performs an inorder traversal of the plan tree.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n All plans in the tree in inorder.\n \"\"\"\n result_list = [now_plan]\n for child in now_plan.children:\n result_list.extend(Plan.get_inorder_travel(child))\n return result_list\n\n @classmethod\n def pop_next_subtask(cls, now_plan):\n \"\"\"Fetches the next subtask in the queue.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Next subtask in the queue.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n for subtask in all_plans[order_id + 1:]:\n if subtask.data.status == TaskStatusCode.TODO:\n return subtask\n return None\n\n @classmethod\n def get_remaining_subtask(cls, now_plan):\n \"\"\"Gets all remaining subtasks from a given point.\n\n Args:\n now_plan: Current plan in the tree.\n\n Returns:\n Array of all remaining subtasks.\n \"\"\"\n root_plan = now_plan.get_root()\n all_plans = Plan.get_inorder_travel(root_plan)\n order_id = all_plans.index(now_plan)\n return all_plans[order_id:]",
"name_column": 6
},
"__init__": {
Expand Down Expand Up @@ -6818,7 +6818,7 @@
"code_end_line": 73,
"parent": "Plan",
"have_return": true,
"code_content": " def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n fahter_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n fahter_subtask_id.append(child_id)\n return fahter_subtask_id\n",
"code_content": " def get_subtask_id_list(self):\n \"\"\"Gets the subtask ID list.\n\n Returns:\n Array of subtask IDs if father is not none else [1].\n \"\"\"\n if self.father == None:\n return [1]\n father_subtask_id = self.father.get_subtask_id()\n child_id = self.father.children.index(self) + 1\n father_subtask_id.append(child_id)\n return father_subtask_id\n",
"name_column": 8
},
"make_relation": {
Expand Down
6 changes: 3 additions & 3 deletions XAgent/data_structure/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def get_subtask_id_list(self):
"""
if self.father == None:
return [1]
fahter_subtask_id = self.father.get_subtask_id()
father_subtask_id = self.father.get_subtask_id()
child_id = self.father.children.index(self) + 1
fahter_subtask_id.append(child_id)
return fahter_subtask_id
father_subtask_id.append(child_id)
return father_subtask_id

@classmethod
def make_relation(cls, father, child):
Expand Down

0 comments on commit 3619c25

Please sign in to comment.