Skip to content

Commit

Permalink
fix: addSegment method on Sequence (#275)
Browse files Browse the repository at this point in the history
* fix: remove overload on addSegment for Sequence and use addSegments for array input

* test: adapt cpp and python tests
  • Loading branch information
Derollez authored Nov 20, 2023
1 parent a77605d commit aaed350
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
Instant: The instant at which the access starts.
)doc"
)
.def(
Expand Down Expand Up @@ -94,7 +94,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
float: The initial mass.
)doc"
)
.def(
Expand All @@ -116,7 +116,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
Duration: The propagation duration.
)doc"
)

Expand All @@ -128,7 +128,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
float: The delta mass.
)doc"
)
.def(
Expand All @@ -142,7 +142,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
float: The delta V.
)doc",
arg("specific_impulse")
)
Expand Down Expand Up @@ -203,7 +203,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
list[Segment]: The segments.
)doc"
)
.def(
Expand Down Expand Up @@ -236,13 +236,13 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
Returns:
Duration: The maximum propagation duration.
)doc"
)

.def(
"add_segment",
overload_cast<const Segment&>(&Sequence::addSegment),
&Sequence::addSegment,
R"doc(
Add a segment.
Expand All @@ -253,8 +253,8 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Sequence(pybind11::module
arg("segment")
)
.def(
"add_segment",
overload_cast<const Array<Segment>&>(&Sequence::addSegment),
"add_segments",
&Sequence::addSegments,
arg("segments"),
R"doc(
Add segments.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/test/trajectory/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def test_add_segment(

segments_count = len(sequence.get_segments())

sequence.add_segment([coast_duration_segment, coast_duration_segment])
sequence.add_segments([coast_duration_segment, coast_duration_segment])

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Sequence
///
/// @param [in] aTrajectorySegmentArray An array of trajectory segments.

void addSegment(const Array<Segment>& aTrajectorySegmentArray);
void addSegments(const Array<Segment>& aTrajectorySegmentArray);

/// @brief Add a coast segment.
///
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSpaceToolkit/Astrodynamics/Trajectory/Sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ void Sequence::addSegment(const Segment& aSegment)
segments_.add(aSegment);
}

void Sequence::addSegment(const Array<Segment>& someSegments)
void Sequence::addSegments(const Array<Segment>& aTrajectorySegmentArray)
{
segments_.add(someSegments);
segments_.add(aTrajectorySegmentArray);
}

void Sequence::addCoastSegment(const Shared<EventCondition>& anEventConditionSPtr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Trajectory_Sequence, AddSegment)
}

{
EXPECT_NO_THROW(defaultSequence_.addSegment({coastSegment_, coastSegment_}));
EXPECT_NO_THROW(defaultSequence_.addSegments({coastSegment_, coastSegment_}));
}
}

Expand Down

0 comments on commit aaed350

Please sign in to comment.