Skip to content

Commit

Permalink
chore: speed up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwa2710 committed Aug 3, 2024
1 parent 78c5838 commit 612020c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 60 deletions.
12 changes: 6 additions & 6 deletions bindings/python/test/solver/test_numerical_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def numerical_solver_default_inputs() -> (
log_type = NumericalSolver.LogType.NoLog
stepper_type = NumericalSolver.StepperType.RungeKuttaCashKarp54
initial_time_step = 5.0
relative_tolerance = 1.0e-15
absolute_tolerance = 1.0e-15
relative_tolerance = 1.0e-12
absolute_tolerance = 1.0e-12

return (
log_type,
Expand All @@ -53,8 +53,8 @@ def numerical_solver_conditional() -> NumericalSolver:
NumericalSolver.LogType.NoLog,
NumericalSolver.StepperType.RungeKuttaDopri5,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
)


Expand Down Expand Up @@ -133,7 +133,7 @@ def test_integrate_duration(
assert 5e-9 >= abs(state_vector[0] - math.sin(integration_duration))
assert 5e-9 >= abs(state_vector[1] - math.cos(integration_duration))

integration_durations = np.arange(100.0, 1000.0, 50.0)
integration_durations = np.arange(100.0, 200.0, 50.0)
solutions = numerical_solver.integrate_duration(
initial_state_vec, integration_durations, oscillator
)
Expand All @@ -157,7 +157,7 @@ def test_integrate_time(self, numerical_solver: NumericalSolver):
assert 5e-9 >= abs(state_vector[0] - math.sin(end_time))
assert 5e-9 >= abs(state_vector[1] - math.cos(end_time))

end_times = np.arange(600.0, 1000.0, 50.0)
end_times = np.arange(600.0, 700.0, 50.0)
solutions = numerical_solver.integrate_time(
initial_state_vec, start_time, end_times, oscillator
)
Expand Down
108 changes: 54 additions & 54 deletions test/OpenSpaceToolkit/Mathematics/Solver/NumericalSolver.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ using ostk::core::container::Array;
using ostk::core::container::Tuple;
using ostk::core::type::Integer;
using ostk::core::type::Real;
using ostk::core::type::String;
using ostk::core::type::Shared;
using ostk::core::type::String;

using ostk::mathematics::object::VectorXd;

Expand All @@ -38,24 +38,24 @@ class OpenSpaceToolkit_Mathematics_Solver_NumericalSolver : public ::testing::Te
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

NumericalSolver defaultRKF78_ = {
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaFehlberg78,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

NumericalSolver defaultRKD5_ = {
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaDopri5,
1e-3,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

NumericalSolver::StateVector defaultStateVector_;
Expand Down Expand Up @@ -112,7 +112,7 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, Constructor)
{
{
EXPECT_NO_THROW(NumericalSolver numericalsolver(
NumericalSolver::LogType::NoLog, NumericalSolver::StepperType::RungeKuttaCashKarp54, 5.0, 1.0e-15, 1.0e-15
NumericalSolver::LogType::NoLog, NumericalSolver::StepperType::RungeKuttaCashKarp54, 5.0, 1.0e-12, 1.0e-12
));
}
}
Expand All @@ -134,8 +134,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, EqualToOperator)
NumericalSolver::LogType::LogConstant,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};
EXPECT_FALSE(defaultRK54_ == numericalSolver_1);

Expand All @@ -144,8 +144,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, EqualToOperator)
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaFehlberg78,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};
EXPECT_FALSE(defaultRK54_ == numericalSolver_2);

Expand All @@ -154,8 +154,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, EqualToOperator)
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
4.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

EXPECT_FALSE(defaultRK54_ == numericalSolver_3);
Expand All @@ -166,7 +166,7 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, EqualToOperator)
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-14,
1.0e-15,
1.0e-12,
};

EXPECT_FALSE(defaultRK54_ == numericalSolver_4);
Expand All @@ -176,7 +176,7 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, EqualToOperator)
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-12,
1.0e-14,
};

Expand All @@ -198,8 +198,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, NotEqualToOperator)
NumericalSolver::LogType::LogConstant,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

EXPECT_TRUE(defaultRK54_ != numericalSolver_1);
Expand All @@ -209,8 +209,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, NotEqualToOperator)
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaFehlberg78,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};
EXPECT_TRUE(defaultRK54_ != numericalSolver_2);

Expand All @@ -219,8 +219,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, NotEqualToOperator)
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
4.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

EXPECT_TRUE(defaultRK54_ != numericalSolver_3);
Expand All @@ -231,7 +231,7 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, NotEqualToOperator)
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-14,
1.0e-15,
1.0e-12,
};

EXPECT_TRUE(defaultRK54_ != numericalSolver_4);
Expand All @@ -241,7 +241,7 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, NotEqualToOperator)
NumericalSolver::LogType::NoLog,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-12,
1.0e-14,
};

Expand Down Expand Up @@ -294,17 +294,17 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, GetType)
NumericalSolver::LogType::LogConstant,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};
EXPECT_EQ(numericalSolver_LogConstant.getLogType(), NumericalSolver::LogType::LogConstant);

const NumericalSolver numericalSolver_LogAdaptive = {
NumericalSolver::LogType::LogAdaptive,
NumericalSolver::StepperType::RungeKuttaCashKarp54,
5.0,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};
EXPECT_EQ(numericalSolver_LogAdaptive.getLogType(), NumericalSolver::LogType::LogAdaptive);

Expand All @@ -322,8 +322,8 @@ TEST_F(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver, GetNumbers)
{
{
EXPECT_EQ(defaultRK54_.getTimeStep(), 5.0);
EXPECT_EQ(defaultRK54_.getRelativeTolerance(), 1.0e-15);
EXPECT_EQ(defaultRK54_.getAbsoluteTolerance(), 1.0e-15);
EXPECT_EQ(defaultRK54_.getRelativeTolerance(), 1.0e-12);
EXPECT_EQ(defaultRK54_.getAbsoluteTolerance(), 1.0e-12);
}

{
Expand Down Expand Up @@ -380,8 +380,8 @@ TEST_P(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver_Parametrized, integra
NumericalSolver::LogType::NoLog,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

{
Expand Down Expand Up @@ -421,16 +421,16 @@ TEST_P(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver_Parametrized, Integra
NumericalSolver numericalSolver_1 = {
NumericalSolver::LogType::LogAdaptive,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1e-1,
1.0e-12,
1.0e-12,
};
NumericalSolver numericalSolver_2 = {
NumericalSolver::LogType::LogConstant,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1e-1,
1.0e-12,
1.0e-12,
};

testing::internal::CaptureStdout();
Expand Down Expand Up @@ -458,13 +458,13 @@ TEST_P(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver_Parametrized, Integra
NumericalSolver::LogType::NoLog,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

const Array<Array<Real>> durationArrays = {
{10.0, 40.0, 70.0, 1000.0},
{-10.0, -40.0, -70.0, -1000.0},
{1.0, 4.0, 7.0, 10.0},
{-1.0, -4.0, -7.0, -10.0},
};

for (const Array<Real> &durationArray : durationArrays)
Expand All @@ -484,8 +484,8 @@ TEST_P(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver_Parametrized, Integra
NumericalSolver::LogType::NoLog,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

const Array<Real> endTimes = {
Expand Down Expand Up @@ -513,16 +513,16 @@ TEST_P(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver_Parametrized, Integra
NumericalSolver numericalSolver_1 = {
NumericalSolver::LogType::LogAdaptive,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1e-1,
1.0e-12,
1.0e-12,
};
NumericalSolver numericalSolver_2 = {
NumericalSolver::LogType::LogConstant,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1e-1,
1.0e-12,
1.0e-12,
};

testing::internal::CaptureStdout();
Expand Down Expand Up @@ -557,13 +557,13 @@ TEST_P(OpenSpaceToolkit_Mathematics_Solver_NumericalSolver_Parametrized, Integra
NumericalSolver::LogType::NoLog,
std::get<0>(parameters),
1e-3,
1.0e-15,
1.0e-15,
1.0e-12,
1.0e-12,
};

const Array<Array<Real>> timeArrays = {
{100.0, 400.0, 700.0, 1000.0},
{-100.0, -400.0, -700.0, -1000.0},
{1.0, 4.0, 7.0, 10.0},
{-1.0, -4.0, -7.0, -10.0},
};

for (const Array<Real> &timeArray : timeArrays)
Expand Down

0 comments on commit 612020c

Please sign in to comment.