POMDPPlanners.tests.test_environments.test_push_pomdp package
Tests for Push POMDP environments.
This package contains test modules for the Push POMDP environments: - test_push_pomdp.py: Discrete Push POMDP environment tests - test_continuous_push_pomdp.py: Continuous Push POMDP environment tests - test_continuous_push_geometry.py: Continuous Push geometry utility tests - test_push_pomdp_beliefs/: Belief factory and vectorized updater tests
Subpackages
- POMDPPlanners.tests.test_environments.test_push_pomdp.test_push_pomdp_beliefs package
- Submodules
- POMDPPlanners.tests.test_environments.test_push_pomdp.test_push_pomdp_beliefs.test_continuous_push_belief_factory module
- POMDPPlanners.tests.test_environments.test_push_pomdp.test_push_pomdp_beliefs.test_continuous_push_vectorized_updater module
TestBeliefEquivalenceWithBaselineTestContinuousPushVectorizedUpdaterTestContinuousPushVectorizedUpdater.setup_method()TestContinuousPushVectorizedUpdater.test_batch_obs_log_likelihood_matches_per_particle_loop()TestContinuousPushVectorizedUpdater.test_batch_observation_log_likelihood_shape()TestContinuousPushVectorizedUpdater.test_batch_transition_matches_per_particle_loop()TestContinuousPushVectorizedUpdater.test_batch_transition_shape()TestContinuousPushVectorizedUpdater.test_batch_transition_target_preserved()TestContinuousPushVectorizedUpdater.test_batch_transition_with_string_action()TestContinuousPushVectorizedUpdater.test_config_id_deterministic()TestContinuousPushVectorizedUpdater.test_from_environment_discrete()TestContinuousPushVectorizedUpdater.test_log_likelihood_finite()
- POMDPPlanners.tests.test_environments.test_push_pomdp.test_push_pomdp_beliefs.test_push_belief_factory module
- POMDPPlanners.tests.test_environments.test_push_pomdp.test_push_pomdp_beliefs.test_push_vectorized_updater module
Submodules
POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_geometry module
Tests for Continuous Push POMDP geometry utilities.
This module tests circle-AABB overlap, point-inside-AABB, collision resolution, and grid clamping functions, including their batch variants.
- class POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_geometry.TestContinuousPushGeometry[source]
Bases:
objectTest circle-AABB and point-AABB geometry utilities.
- test_batch_clamp_circle_to_grid_shapes()[source]
Test batch circle grid clamping output shape.
Purpose: Validates output shape of batch circle clamping.
Given: 10 random positions. When: batch_clamp_circle_to_grid is called. Then: Output shape matches (10, 2) and values are in range.
Test type: unit
- test_batch_clamp_point_to_grid()[source]
Test batch point grid clamping.
Purpose: Validates batch point clamping bounds.
Given: Points at (-1, 20) and (5, 5). When: batch_clamp_point_to_grid is called with grid_size=10. Then: First is clamped to (0, 9), second unchanged.
Test type: unit
- test_batch_point_inside_aabb()[source]
Test batch point-inside-AABB detection.
Purpose: Validates batch point-inside-AABB returns correct booleans.
Given: Points at (5, 5) inside and (0, 0) outside the AABB. When: batch_point_inside_aabb is called. Then: First is True, second is False.
Test type: unit
- test_batch_resolve_circle_wall_collision_shapes()[source]
Test batch circle-wall collision resolution output shape.
Purpose: Validates output shape of batch collision resolution.
Given: 10 random positions with radius 0.5 and one wall. When: batch_resolve_circle_wall_collision is called. Then: Output shape matches input shape (10, 2).
Test type: unit
- test_circle_aabb_overlap_false()[source]
Test that non-overlapping circle-AABB returns False.
Purpose: Validates that distant circles are not detected as overlapping.
- Given: A circle centered at (1.0, 1.0) with radius 0.3 and an AABB
centered at (5, 5) with half-extent 1.
When: circle_aabb_overlap is called. Then: Returns False.
Test type: unit
- test_circle_aabb_overlap_true()[source]
Test that overlapping circle-AABB returns True.
Purpose: Validates circle-AABB overlap detection.
- Given: A circle centered at (3.5, 5.0) with radius 1.0 and
an AABB centered at (5, 5) with half-extent 1.
When: circle_aabb_overlap is called. Then: Returns True because the circle reaches into the AABB.
Test type: unit
- test_clamp_circle_to_grid()[source]
Test that circle clamping keeps circle within grid.
Purpose: Validates grid clamping for circles.
Given: A circle centered at (-1, 12) with radius 0.3 on a grid of size 10. When: clamp_circle_to_grid is called. Then: Center is clamped to [radius, grid_size - 1 - radius].
Test type: unit
- test_clamp_point_to_grid()[source]
Test that point clamping keeps point within [0, grid_size-1].
Purpose: Validates grid clamping for points.
Given: A point at (-2, 15) on a grid of size 10. When: clamp_point_to_grid is called. Then: Point is clamped to [0, 9].
Test type: unit
- test_point_inside_aabb_false()[source]
Test that a point outside an AABB is not detected.
Purpose: Validates point-outside-AABB.
Given: A point at (1.0, 1.0) outside the AABB [4, 6] x [4, 6]. When: point_inside_aabb is called. Then: Returns False.
Test type: unit
- test_point_inside_aabb_true()[source]
Test that a point inside an AABB is detected.
Purpose: Validates point-inside-AABB test.
Given: A point at (5.0, 5.0) inside the AABB [4, 6] x [4, 6]. When: point_inside_aabb is called. Then: Returns True.
Test type: unit
- test_resolve_circle_wall_collision_no_walls()[source]
Test collision resolution with no walls returns copy.
Purpose: Validates no-op when there are no walls.
Given: Empty walls array. When: resolve_circle_wall_collision is called. Then: Returns a copy of the original position.
Test type: unit
- test_resolve_circle_wall_collision_pushes_out()[source]
Test that collision resolution pushes circle away from AABB.
Purpose: Validates that an overlapping circle is pushed out.
- Given: A circle centered at (4.5, 5.0) with radius 0.3 overlapping
the AABB [4, 6] x [4, 6].
When: resolve_circle_wall_collision is called. Then: The returned position moves the circle center away from
the original overlap.
Test type: unit
POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_pomdp module
Tests for the Continuous Push POMDP environment.
This module tests the state transition model, observation model, environment, and discrete actions wrapper for the Continuous Push POMDP.
- class POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_pomdp.TestContinuousPushObservation[source]
Bases:
objectTest the continuous push observation model.
- test_object_position_noisy()[source]
Test that object position observation includes noise.
Purpose: Validates that object position is noisy.
Given: Observation noise = 1.0 (large). When: Multiple samples are drawn. Then: Object position varies across samples.
Test type: unit
- test_observation_shape()[source]
Test that observation has shape (6,).
Purpose: Validates observation vector shape.
Given: A state with 6 elements. When: sample() is called. Then: Observation has shape (6,).
Test type: unit
- test_probability_returns_positive()[source]
Test that observation probability is positive for plausible observations.
Purpose: Validates probability calculation.
Given: An observation close to the true state. When: probability() is called. Then: Returns positive probability.
Test type: unit
- test_robot_and_target_exact()[source]
Test that robot and target positions are observed exactly.
Purpose: Validates that robot and target are noiseless in observations.
Given: State with known robot and target positions. When: sample() is called. Then: Observation indices 0:2 and 4:6 match state exactly.
Test type: unit
- class POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_pomdp.TestContinuousPushPOMDP[source]
Bases:
objectTest the ContinuousPushPOMDP environment.
- test_compute_metrics()[source]
Test compute_metrics returns expected metric names.
Purpose: Validates metric computation.
Given: A short simulated history. When: compute_metrics is called. Then: Returns list of MetricValue with correct names.
Test type: integration
- test_config_id_deterministic()[source]
Test that two identical environments have the same config_id.
Purpose: Validates deterministic config identification.
Given: Two environments with identical parameters. When: config_id is accessed. Then: Both return the same string.
Test type: unit
- test_fixed_initial_state()[source]
Test that fixed initial state works.
Purpose: Validates fixed initial state distribution.
Given: Environment with fixed initial_state. When: initial_state_dist().sample() is called. Then: Returns the fixed state.
Test type: unit
- test_initial_state_shape()[source]
Test that initial state has shape (6,).
Purpose: Validates initial state distribution.
Given: Environment with default settings. When: initial_state_dist().sample() is called. Then: Returns array of shape (6,).
Test type: unit
- test_no_obstacles_environment()[source]
Test environment works with no obstacles.
Purpose: Validates obstacle-free configuration.
Given: Environment with no obstacles. When: sample_next_step is called. Then: Works without error.
Test type: unit
- test_not_terminal_far_from_target()[source]
Test that is_terminal returns False when object is far from target.
Purpose: Validates non-terminal condition.
Given: Object far from target. When: is_terminal is called. Then: Returns False.
Test type: unit
- test_obstacle_penalty_applied()[source]
Test that obstacle collision incurs penalty.
Purpose: Validates obstacle penalty.
Given: Robot at position that will collide with obstacle after action. When: reward is called with action into obstacle. Then: Reward is lower than without collision.
Test type: unit
- test_reward_batch_shape()[source]
Test that reward_batch returns correct shape.
Purpose: Validates vectorized reward computation.
Given: 5 states and one action. When: reward_batch is called. Then: Returns array of shape (5,).
Test type: unit
- test_reward_positive_at_goal()[source]
Test that reward includes bonus when object reaches target.
Purpose: Validates goal reward bonus.
Given: Object very close to target. When: reward is called. Then: Reward is high (includes +100 bonus).
Test type: unit
- test_sample_next_step()[source]
Test that sample_next_step returns valid tuple.
Purpose: Validates full POMDP step.
Given: An initial state and continuous action. When: sample_next_step is called. Then: Returns (next_state, observation, reward).
Test type: unit
- class POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_pomdp.TestContinuousPushPOMDPDiscreteActions[source]
Bases:
objectTest the discrete-action wrapper.
- test_action_mapping_directions()[source]
Test that each action moves robot in expected direction.
Purpose: Validates action direction mapping.
Given: Robot at center, very low noise. When: Each directional action is taken. Then: Robot moves in the expected direction.
Test type: unit
- test_actions_list()[source]
Test that get_actions returns expected string actions.
Purpose: Validates discrete action set.
Given: A ContinuousPushPOMDPDiscreteActions environment. When: get_actions() is called. Then: Returns [“up”, “down”, “right”, “left”].
Test type: unit
- test_sample_next_step_with_string_action()[source]
Test that string actions work in sample_next_step.
Purpose: Validates string-to-vector action mapping.
Given: Initial state and “right” action. When: sample_next_step is called. Then: Returns valid (next_state, observation, reward).
Test type: unit
- class POMDPPlanners.tests.test_environments.test_push_pomdp.test_continuous_push_pomdp.TestContinuousPushStateTransition[source]
Bases:
objectTest the continuous push state transition model.
- test_friction_reduces_push()[source]
Test that friction reduces push displacement.
Purpose: Validates friction effect on pushing.
Given: Friction = 0.5 vs friction = 0.0. When: Same action applied. Then: Higher friction produces smaller object displacement.
Test type: unit
- test_grid_clamping()[source]
Test that positions are clamped to grid.
Purpose: Validates grid boundary enforcement.
Given: Robot at (8.5, 8.5) with action pushing out of grid. When: sample() is called. Then: Robot stays within valid bounds.
Test type: unit
- test_no_push_beyond_threshold()[source]
Test that object is NOT pushed when robot is beyond threshold.
Purpose: Validates that push only occurs within threshold.
Given: Robot at (0, 0), object at (5, 5), threshold=1.0. When: Robot moves right. Then: Object position unchanged.
Test type: unit
- test_obstacle_blocks_object_push()[source]
Test that obstacles block object push.
Purpose: Validates that object stays put when pushed into obstacle.
Given: Object at (4.5, 5.0), obstacle AABB at (5, 5) half=0.5. When: Robot pushes object rightward into obstacle. Then: Object position unchanged.
Test type: unit
- test_probability_returns_positive()[source]
Test that probability returns positive densities.
Purpose: Validates probability method.
Given: A transition model and a plausible next state. When: probability() is called. Then: Returns a positive probability.
Test type: unit
- test_push_force_capped()[source]
Test that push force is capped at max_push.
Purpose: Validates capped push scaling.
Given: Large action (10, 0), max_push=2.0, friction=0.3. When: Push is applied to nearby object. Then: Push magnitude <= max_push * (1 - friction).
Test type: unit
- test_push_within_threshold()[source]
Test that object is pushed when robot is within threshold.
Purpose: Validates push mechanics.
Given: Robot at (2, 3), object at (2.5, 3.0), within threshold=1.0. When: Robot moves right with action (1, 0). Then: Object x increases in the action direction.
Test type: unit
- test_robot_moves_in_action_direction()[source]
Test that the robot moves approximately in the action direction.
Purpose: Validates that action vector translates to movement.
Given: Robot at (2, 3), action = (1, 0), small noise. When: sample() is called. Then: Robot x increases, y stays roughly constant.
Test type: unit