core.test_solver_mask

Tests for solver mask building function.

Tests the pure function in f.domains.hedge.core.solver:

  • build_variation_include_mask

3 tests covering different scenarios.

@pytest.fixture
def sample_variations():

Sample variation list for testing.

def test_variation_mask_with_max_only(sample_variations):

Test: Build mask with only max bound (include negative variations).

NUMERICAL EXAMPLE

Input: variations = [-0.30, -0.20, -0.10, 0, 0.10, 0.20] range_max = 0 (include up to zero)

Expected: mask = [True, True, True, True, False, False] Includes: -0.30, -0.20, -0.10, 0 Excludes: 0.10, 0.20

def test_variation_mask_with_min_only(sample_variations):

Test: Build mask with only min bound (exclude deep negative variations).

NUMERICAL EXAMPLE

Input: variations = [-0.30, -0.20, -0.10, 0, 0.10, 0.20] range_min = -0.15 (exclude below -0.15)

Expected: mask = [False, False, True, True, True, True] Excludes: -0.30, -0.20 Includes: -0.10, 0, 0.10, 0.20

def test_variation_mask_with_both_bounds(sample_variations):

Test: Build mask with both min and max bounds.

NUMERICAL EXAMPLE

Input: variations = [-0.30, -0.20, -0.10, 0, 0.10, 0.20] range_min = -0.25 range_max = 0.15

Expected: mask = [False, True, True, True, True, False] Excludes: -0.30 (below min), 0.20 (above max) Includes: -0.20, -0.10, 0, 0.10