|
4 | 4 | import autoarray as aa |
5 | 5 |
|
6 | 6 | from autoarray.inversion.mesh.border_relocator import ( |
| 7 | + ellipse_params_via_border_pca_from, |
7 | 8 | sub_border_pixel_slim_indexes_from, |
8 | 9 | ) |
9 | 10 |
|
@@ -376,3 +377,40 @@ def test__relocated_grid_from__positive_origin_included_in_relocate(): |
376 | 377 | relocated_grid = border_relocator.relocated_grid_from(grid=grid) |
377 | 378 |
|
378 | 379 | assert relocated_grid.over_sampled[1] == pytest.approx([1.95, 1.0], 1e-4) |
| 380 | + |
| 381 | +def test__ellipse_params__near_isotropic_border_uses_deterministic_axis(): |
| 382 | + border_grid = np.array( |
| 383 | + [ |
| 384 | + [-0.0960155108, 0.0960155108], |
| 385 | + [-0.55, 0.0], |
| 386 | + [-0.0960155108, -0.0960155108], |
| 387 | + [0.0, 0.55], |
| 388 | + [0.0, -0.55], |
| 389 | + [0.0960155108, 0.0960155108], |
| 390 | + [0.55, 0.0], |
| 391 | + [0.0960155108, -0.0960155108], |
| 392 | + ] |
| 393 | + ) |
| 394 | + |
| 395 | + _, a, b, phi = ellipse_params_via_border_pca_from(border_grid=border_grid) |
| 396 | + |
| 397 | + assert float(phi) == 0.0 |
| 398 | + assert float(a) == pytest.approx(0.55 + 1.0e-12) |
| 399 | + assert float(b) == pytest.approx(0.55 + 1.0e-12) |
| 400 | + |
| 401 | + |
| 402 | +def test__ellipse_params__anisotropic_border_retains_pca_major_axis(): |
| 403 | + border_grid = np.array( |
| 404 | + [ |
| 405 | + [-2.0, 0.0], |
| 406 | + [0.0, 1.0], |
| 407 | + [2.0, 0.0], |
| 408 | + [0.0, -1.0], |
| 409 | + ] |
| 410 | + ) |
| 411 | + |
| 412 | + _, a, b, phi = ellipse_params_via_border_pca_from(border_grid=border_grid) |
| 413 | + |
| 414 | + assert abs(float(phi)) == pytest.approx(np.pi / 2.0) |
| 415 | + assert float(a) > float(b) |
| 416 | + |
0 commit comments