Skip to content

Commit

Permalink
chore: add sequence solution default constructor bindings (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Derollez authored Jan 2, 2024
1 parent bb710b4 commit e9c4d17
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
)doc"
)

.def(
init<Array<Segment::Solution>, bool>(),
R"doc(
Construct a new `Sequence.Solution` object.
Args:
segment_solutions (list[Segment.Solution]): The segment solutions.
execution_is_complete (bool): Whether the execution is complete.
Returns:
Sequence: The new `Sequence.Solution` object.
)doc",
arg("segment_solutions"),
arg("execution_is_complete")
)

.def("__str__", &(shiftToString<Sequence::Solution>))
.def("__repr__", &(shiftToString<Sequence::Solution>))

Expand Down
31 changes: 31 additions & 0 deletions bindings/python/test/trajectory/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,22 @@ def sequence(
)


@pytest.fixture
def segment_solution(
dynamics: list,
state: State,
):
return Segment.Solution(
name="A Segment Solution",
dynamics=dynamics,
states=[
state,
],
condition_is_satisfied=True,
segment_type=Segment.Type.Maneuver,
)


class TestSequence:
def test_get_segments(
self,
Expand Down Expand Up @@ -389,6 +405,21 @@ def test_add_maneuver_segment(

assert len(sequence.get_segments()) == segments_count + 1

def test_create_sequence_solution(
self,
segment_solution: Segment.Solution,
):
solution: Sequence.Solution = Sequence.Solution(
segment_solutions=[
segment_solution,
],
execution_is_complete=True,
)

assert solution is not None
assert len(solution.segment_solutions) == 1
assert solution.execution_is_complete

def test_solve(
self,
state: State,
Expand Down

0 comments on commit e9c4d17

Please sign in to comment.