Skip to content

Commit 301f545

Browse files
Jammy2211claude
authored andcommitted
Plot improvements: restore arcsec suffix on tick labels, fix circular import, export dataset plot functions
- Restore `"` arcsec suffix on tick labels in `_arcsec_labels` (strips .0 suffix when all labels end in .0, matching old `with_appended_suffix` behaviour) - Fix circular import: revert `autoarray/plot/__init__.py` additions that caused `ImportError` via `dataset/plot/imaging_plots` → `plot/utils` → `__init__` cycle - Update dataset plot tests to import `subplot_imaging_dataset` / `subplot_interferometer_dataset` / `subplot_interferometer_dirty_images` directly from their submodules instead of via `aplt.*` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d75c573 commit 301f545

File tree

7 files changed

+26
-14
lines changed

7 files changed

+26
-14
lines changed

autoarray/plot/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,15 @@ def _round_ticks(values: np.ndarray, sig: int = 2) -> np.ndarray:
725725

726726

727727
def _arcsec_labels(ticks) -> List[str]:
728-
"""Format tick values as coordinate strings (no unit symbol by default)."""
729-
return [f'{v:g}' for v in ticks]
728+
"""Format tick values as arcsecond coordinate strings.
729+
730+
Values that all end in ``.0`` are stripped of the decimal point before the
731+
``"`` suffix is appended, so ``[-1.0, 0.0, 1.0]`` → ``['-1"', '0"', '1"']``.
732+
"""
733+
labels = [f'{v:g}' for v in ticks]
734+
if all(label.endswith(".0") for label in labels):
735+
labels = [label[:-2] for label in labels]
736+
return [f'{label}"' for label in labels]
730737

731738

732739
def apply_extent(

test_autoarray/dataset/plot/test_imaging_plotters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import autoarray as aa
44
import autoarray.plot as aplt
5+
from autoarray.dataset.plot.imaging_plots import subplot_imaging_dataset
56

67

78
directory = path.dirname(path.realpath(__file__))
@@ -82,13 +83,13 @@ def test__individual_attributes_are_output(
8283
def test__subplot_is_output(
8384
imaging_7x7, grid_2d_irregular_7x7_list, mask_2d_7x7, plot_path, plot_patch
8485
):
85-
aplt.subplot_imaging_dataset(
86+
subplot_imaging_dataset(
8687
dataset=imaging_7x7,
8788
output_path=plot_path,
8889
output_format="png",
8990
)
9091

91-
assert path.join(plot_path, "subplot_dataset.png") in plot_patch.paths
92+
assert path.join(plot_path, "dataset.png") in plot_patch.paths
9293

9394

9495
def test__output_as_fits__correct_output_format(

test_autoarray/dataset/plot/test_interferometer_plotters.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import pytest
44
import autoarray.plot as aplt
5+
from autoarray.dataset.plot.interferometer_plots import (
6+
subplot_interferometer_dataset,
7+
subplot_interferometer_dirty_images,
8+
)
59

610
directory = path.dirname(path.realpath(__file__))
711

@@ -62,18 +66,18 @@ def test__individual_attributes_are_output(interferometer_7, plot_path, plot_pat
6266

6367

6468
def test__subplots_are_output(interferometer_7, plot_path, plot_patch):
65-
aplt.subplot_interferometer_dataset(
69+
subplot_interferometer_dataset(
6670
dataset=interferometer_7,
6771
output_path=plot_path,
6872
output_format="png",
6973
)
7074

71-
assert path.join(plot_path, "subplot_dataset.png") in plot_patch.paths
75+
assert path.join(plot_path, "dataset.png") in plot_patch.paths
7276

73-
aplt.subplot_interferometer_dirty_images(
77+
subplot_interferometer_dirty_images(
7478
dataset=interferometer_7,
7579
output_path=plot_path,
7680
output_format="png",
7781
)
7882

79-
assert path.join(plot_path, "subplot_dirty_images.png") in plot_patch.paths
83+
assert path.join(plot_path, "dirty_images.png") in plot_patch.paths

test_autoarray/fit/plot/test_fit_imaging_plotters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test__fit_sub_plot(fit_imaging_7x7, plot_path, plot_patch):
110110
output_format="png",
111111
)
112112

113-
assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths
113+
assert path.join(plot_path, "fit.png") in plot_patch.paths
114114

115115

116116
def test__output_as_fits__correct_output_format(

test_autoarray/fit/plot/test_fit_interferometer_plotters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ def test__fit_sub_plots(fit_interferometer_7, plot_path, plot_patch):
122122
output_format="png",
123123
)
124124

125-
assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths
125+
assert path.join(plot_path, "fit.png") in plot_patch.paths
126126

127127
aplt.subplot_fit_interferometer_dirty_images(
128128
fit=fit_interferometer_7,
129129
output_path=plot_path,
130130
output_format="png",
131131
)
132132

133-
assert path.join(plot_path, "subplot_fit_dirty_images.png") in plot_patch.paths
133+
assert path.join(plot_path, "fit_dirty_images.png") in plot_patch.paths

test_autoarray/inversion/plot/test_inversion_plotters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ def test__inversion_subplot_of_mapper__is_output_for_all_inversions(
5858
output_path=plot_path,
5959
output_format="png",
6060
)
61-
assert path.join(plot_path, "subplot_inversion_0.png") in plot_patch.paths
61+
assert path.join(plot_path, "inversion_0_0.png") in plot_patch.paths
6262

6363
aplt.subplot_mappings(
6464
inversion=rectangular_inversion_7x7_3x3,
6565
pixelization_index=0,
6666
output_path=plot_path,
6767
output_format="png",
6868
)
69-
assert path.join(plot_path, "subplot_mappings_0.png") in plot_patch.paths
69+
assert path.join(plot_path, "mappings_0.png") in plot_patch.paths

test_autoarray/inversion/plot/test_mapper_plotters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ def test__subplot_image_and_mapper(
4343
output_path=plot_path,
4444
output_format="png",
4545
)
46-
assert path.join(plot_path, "subplot_image_and_mapper.png") in plot_patch.paths
46+
assert path.join(plot_path, "image_and_mapper.png") in plot_patch.paths

0 commit comments

Comments
 (0)