|
1 | 1 | """ |
2 | | -Tests for volestipy.VPolytope – construction, membership, sampling, volume. |
| 2 | +Tests for volestipy.VPolytope - construction, membership, sampling, volume. |
3 | 3 | """ |
4 | 4 | import math |
5 | 5 | import numpy as np |
@@ -105,7 +105,7 @@ def test_inner_ball_simplex(self): |
105 | 105 | # ── Sampling tests ──────────────────────────────────────────────────────────── |
106 | 106 |
|
107 | 107 | class TestVPolytopeUniformSampling: |
108 | | - @pytest.mark.parametrize("walk_type", ["cdhr", "rdhr", "ball_walk"]) |
| 108 | + @pytest.mark.parametrize("walk_type", ["cdhr", "rdhr", "ball_walk", "billiard"]) |
109 | 109 | def test_sample_shape(self, walk_type): |
110 | 110 | P = make_simplex_vpoly(3) |
111 | 111 | samples = P.sample(n_samples=100, walk_type=walk_type, seed=42) |
@@ -135,21 +135,25 @@ def test_sample_inside_square(self): |
135 | 135 | # ── Volume tests ────────────────────────────────────────────────────────────── |
136 | 136 |
|
137 | 137 | class TestVPolytopeVolume: |
138 | | - def test_simplex_volume_2d(self): |
| 138 | + #cooling_gaussians not applicable to V-polytopes |
| 139 | + @pytest.mark.parametrize("volume_algo", ["cooling_balls", "sequence_of_balls"]) |
| 140 | + def test_simplex_volume_2d(self, volume_algo): |
139 | 141 | # Vol(triangle with vertices (0,0),(1,0),(0,1)) = 0.5 |
140 | 142 | V = np.array([[0., 0.], [1., 0.], [0., 1.]]) |
141 | 143 | P = VPolytope(V) |
142 | | - vol = P.volume(error=0.3, algorithm="cooling_balls") |
| 144 | + vol = P.volume(error=0.3, algorithm=volume_algo) |
143 | 145 | expected = 0.5 |
144 | 146 | assert abs(vol - expected) / expected < 1.0, f"vol={vol:.4f}" |
145 | 147 |
|
146 | | - def test_square_volume(self): |
| 148 | + @pytest.mark.parametrize("volume_algo", ["cooling_balls", "sequence_of_balls"]) |
| 149 | + def test_square_volume(self, volume_algo): |
147 | 150 | P = make_cube_vpoly_2d() |
148 | | - vol = P.volume(error=0.3, algorithm="cooling_balls") |
| 151 | + vol = P.volume(error=0.3, algorithm=volume_algo) |
149 | 152 | expected = 4.0 # 2x2 square |
150 | 153 | assert abs(vol - expected) / expected < 0.5, f"vol={vol:.3f}" |
151 | 154 |
|
152 | | - def test_volume_positive(self): |
| 155 | + @pytest.mark.parametrize("volume_algo", ["cooling_balls", "sequence_of_balls"]) |
| 156 | + def test_volume_positive(self, volume_algo): |
153 | 157 | P = make_simplex_vpoly(3) |
154 | | - vol = P.volume(error=0.3) |
| 158 | + vol = P.volume(error=0.3, algorithm=volume_algo) |
155 | 159 | assert vol > 0 |
0 commit comments