test_box_polar_utils¶
Classes¶
Tests for BoxCartesianDistribution. |
|
End-to-end tests for the Cartesian Box implementation. |
|
Tests for the Box environment with Cartesian semantics. |
|
Tests for BoxCartesianPBDistribution (backward policy). |
Functions¶
|
Tests the DistributionWrapper class. |
Module Contents¶
- class test_box_polar_utils.TestBoxCartesianDistribution¶
Tests for BoxCartesianDistribution.
- env()¶
- pf_estimator(env, pf_module)¶
- pf_module()¶
- test_log_prob_exit_at_boundary(env, pf_estimator)¶
Exit at boundary should have finite log_prob (learned Bernoulli).
- test_log_prob_finite(env, pf_estimator)¶
Log probabilities should be finite for valid actions.
- test_no_exit_from_s0(env, pf_estimator)¶
Exit from s0 should have log_prob = -inf.
- test_sample_non_s0_in_range(env, pf_estimator)¶
From non-s0, sampled actions should be >= delta.
- test_sample_s0_in_range(env, pf_estimator)¶
From s0, sampled actions should be in [0, 1] (full space coverage).
- test_sample_shape(env, pf_estimator)¶
Sampled actions should have correct shape.
- class test_box_polar_utils.TestBoxCartesianEndToEnd¶
End-to-end tests for the Cartesian Box implementation.
- env()¶
- pb_estimator(env)¶
- pf_estimator(env)¶
- test_backward_trajectory_reaches_s0(env, pb_estimator)¶
A backward trajectory should reach s0.
- test_reward_function(env)¶
Reward function should return expected values.
- test_trajectory_stays_in_bounds(env, pf_estimator)¶
A trajectory should stay within [0, 1]^2.
- class test_box_polar_utils.TestBoxCartesianEnvironment¶
Tests for the Box environment with Cartesian semantics.
- env()¶
- test_backward_step_subtracts_action(env)¶
Backward step should subtract action from state.
- test_exit_action_valid(env)¶
Exit actions should be valid for non-s0 states.
- test_forward_backward_roundtrip(env)¶
Forward then backward should return to original state.
- test_forward_step_adds_action(env)¶
Forward step should add action to state.
- test_is_action_valid_boundary(env)¶
Actions shouldn’t push state past boundary.
- test_is_action_valid_non_s0_forward(env)¶
From non-s0, forward actions should be >= delta.
- test_is_action_valid_s0_forward(env)¶
From s0, forward actions should be in [0, 1] (full space coverage).
- class test_box_polar_utils.TestBoxCartesianPBDistribution¶
Tests for BoxCartesianPBDistribution (backward policy).
- env()¶
- pb_estimator(env, pb_module)¶
- pb_module()¶
- test_log_prob_near_origin(env, pb_estimator)¶
Log prob for near-origin states going to s0 should be 0.
When near origin (any dimension <= delta), BTS is forced and log_prob = 0. For numerical robustness, any action from a near-origin state is treated as BTS since that’s the only valid action anyway.
- test_sample_mixed_dims_near_origin(env, pb_estimator)¶
States with mixed dims (some < delta, some >= delta) should handle correctly.
- test_sample_near_origin_to_s0(env, pb_estimator)¶
States near origin should go directly to s0.
- test_sample_non_origin_valid(env, pb_estimator)¶
Backward actions from non-origin should be valid.
- test_sample_shape(env, pb_estimator)¶
Sampled backward actions should have correct shape.
- test_box_polar_utils.test_mixed_distributions(n_components, n_components_s0)¶
Tests the DistributionWrapper class.
- Parameters:
n_components (int) – The number of components for non-s0 states.
n_components_s0 (int) – The number of components for s0.