Skip to content

Pose: add .copy() and .remove_components()  #147

@cleong110

Description

@cleong110

In pose_evaluation library we had implemented the following, but decided they ought to be in pose-format instead:

def copy_pose(pose: Pose) -> Pose:
    return pose.get_components([component.name for component in pose.header.components])

def remove_components(
    pose: Pose,
    components_to_remove: List[str] | str,
    points_to_remove: List[str] | str | None = None,
):
    if points_to_remove is None:
        points_to_remove = []
    if isinstance(components_to_remove, str):
        components_to_remove = [components_to_remove]
    if isinstance(points_to_remove, str):
        points_to_remove = [points_to_remove]
    components_to_keep = []
    points_dict = {}

    for component in pose.header.components:
        if component.name not in components_to_remove:
            components_to_keep.append(component.name)
            points_dict[component.name] = []
            for point in component.points:
                if point not in points_to_remove:
                    points_dict[component.name].append(point)

    return pose.get_components(components_to_keep, points_dict)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions