From 91d8fb66f245bb5244c46c582d082749f803a53b Mon Sep 17 00:00:00 2001 From: vishwa shah Date: Sat, 4 Jan 2025 23:02:24 +0000 Subject: [PATCH] feat: fix tests --- .../test/access/test_visibility_criterion.py | 18 ++++++++++++------ .../solvers/test_temporal_condition_solver.py | 10 +++++++++- bindings/python/test/test_display.py | 14 ++++++++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/bindings/python/test/access/test_visibility_criterion.py b/bindings/python/test/access/test_visibility_criterion.py index b69df963e..ee5f66894 100644 --- a/bindings/python/test/access/test_visibility_criterion.py +++ b/bindings/python/test/access/test_visibility_criterion.py @@ -136,11 +136,15 @@ def test_aer_interval_is_satisfied( aer_interval = VisibilityCriterion.AERInterval( azimuth_interval, elevation_interval, range_interval ) - aer = AER(azimuth=np.pi / 4, elevation=np.pi / 8, range=5e6) - assert aer_interval.is_satisfied(aer) is True + assert ( + aer_interval.is_satisfied(azimuth=np.pi / 4, elevation=np.pi / 8, range=5e6) + is True + ) - aer_invalid = AER(azimuth=np.pi, elevation=np.pi / 2, range=1e8) - assert aer_interval.is_satisfied(aer_invalid) is False + assert ( + aer_interval.is_satisfied(azimuth=np.pi, elevation=np.pi / 2, range=1e8) + is False + ) def test_elevation_interval_is_satisfied( self, @@ -159,8 +163,10 @@ def test_line_of_sight_is_satisfied( ): line_of_sight = VisibilityCriterion.LineOfSight(environment) instant = Instant.now() - from_position = np.array([7000e3, 0.0, 0.0]) # 7000 km altitude - to_position = np.array([0.0, 7000e3, 0.0]) # 7000 km altitude + + from_position = np.array([7000e3, 0.0, 0.0]) + to_position = np.array([7005e3, 0.0, 0.0]) + assert line_of_sight.is_satisfied(instant, from_position, to_position) is True def test_visibility_criterion_type_checks( diff --git a/bindings/python/test/solvers/test_temporal_condition_solver.py b/bindings/python/test/solvers/test_temporal_condition_solver.py index dd78db82b..efc052eb5 100644 --- a/bindings/python/test/solvers/test_temporal_condition_solver.py +++ b/bindings/python/test/solvers/test_temporal_condition_solver.py @@ -16,6 +16,8 @@ from ostk.astrodynamics.trajectory.orbit.model.kepler import COE from ostk.astrodynamics.access import Generator from ostk.astrodynamics.solver import TemporalConditionSolver +from ostk.astrodynamics.access import AccessTarget +from ostk.astrodynamics.access import VisibilityCriterion @pytest.fixture @@ -141,9 +143,15 @@ def test_solve_success_using_access_generator( celestial_object=earth, ) + visibility_criterion: VisibilityCriterion = ( + VisibilityCriterion.from_line_of_sight(environment) + ) + + access_target = AccessTarget.from_trajectory(visibility_criterion, trajectory) + solution: list[Interval] = temporal_condition_solver.solve( condition=generator.get_condition_function( - from_trajectory=trajectory, + access_target=access_target, to_trajectory=trajectory, ), interval=interval, diff --git a/bindings/python/test/test_display.py b/bindings/python/test/test_display.py index 5de0b8ab1..1546f23f9 100644 --- a/bindings/python/test/test_display.py +++ b/bindings/python/test/test_display.py @@ -15,12 +15,13 @@ from ostk.physics.unit import Length from ostk.physics.unit import Angle -from ostk.astrodynamics import Trajectory from ostk.astrodynamics import display from ostk.astrodynamics.access import Generator as AccessGenerator from ostk.astrodynamics.trajectory import Orbit from ostk.astrodynamics.trajectory.orbit.model import SGP4 from ostk.astrodynamics.trajectory.orbit.model.sgp4 import TLE +from ostk.astrodynamics.access import AccessTarget +from ostk.astrodynamics.access import VisibilityCriterion class TestDisplay: @@ -52,7 +53,12 @@ def test_accesses_plot(self): environment: Environment = Environment.default() earth: Celestial = environment.access_celestial_object_with_name("Earth") - ground_station_trajectory: Trajectory = Trajectory.position( + visibility_criterion: VisibilityCriterion = ( + VisibilityCriterion.from_line_of_sight(environment) + ) + + access_target: AccessTarget = AccessTarget.from_position( + visibility_criterion, Position.meters( ground_station_lla.to_cartesian( earth.get_equatorial_radius(), @@ -76,7 +82,7 @@ def test_accesses_plot(self): accesses_1 = generator.compute_accesses( interval=search_interval, - from_trajectory=ground_station_trajectory, + access_target=access_target, to_trajectory=orbit_1, ) @@ -84,7 +90,7 @@ def test_accesses_plot(self): accesses_2 = generator.compute_accesses( interval=search_interval, - from_trajectory=ground_station_trajectory, + access_target=access_target, to_trajectory=orbit_2, )