From 301f5457cd15d1bc113a52570bbee66caf9bb01d Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 26 Mar 2026 10:48:19 +0000 Subject: [PATCH] Plot improvements: restore arcsec suffix on tick labels, fix circular import, export dataset plot functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- autoarray/plot/utils.py | 11 +++++++++-- test_autoarray/dataset/plot/test_imaging_plotters.py | 5 +++-- .../dataset/plot/test_interferometer_plotters.py | 12 ++++++++---- test_autoarray/fit/plot/test_fit_imaging_plotters.py | 2 +- .../fit/plot/test_fit_interferometer_plotters.py | 4 ++-- .../inversion/plot/test_inversion_plotters.py | 4 ++-- .../inversion/plot/test_mapper_plotters.py | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/autoarray/plot/utils.py b/autoarray/plot/utils.py index f6dd11fd..27d0f5c2 100644 --- a/autoarray/plot/utils.py +++ b/autoarray/plot/utils.py @@ -725,8 +725,15 @@ def _round_ticks(values: np.ndarray, sig: int = 2) -> np.ndarray: def _arcsec_labels(ticks) -> List[str]: - """Format tick values as coordinate strings (no unit symbol by default).""" - return [f'{v:g}' for v in ticks] + """Format tick values as arcsecond coordinate strings. + + Values that all end in ``.0`` are stripped of the decimal point before the + ``"`` suffix is appended, so ``[-1.0, 0.0, 1.0]`` → ``['-1"', '0"', '1"']``. + """ + labels = [f'{v:g}' for v in ticks] + if all(label.endswith(".0") for label in labels): + labels = [label[:-2] for label in labels] + return [f'{label}"' for label in labels] def apply_extent( diff --git a/test_autoarray/dataset/plot/test_imaging_plotters.py b/test_autoarray/dataset/plot/test_imaging_plotters.py index fdd07196..76ebabc8 100644 --- a/test_autoarray/dataset/plot/test_imaging_plotters.py +++ b/test_autoarray/dataset/plot/test_imaging_plotters.py @@ -2,6 +2,7 @@ import pytest import autoarray as aa import autoarray.plot as aplt +from autoarray.dataset.plot.imaging_plots import subplot_imaging_dataset directory = path.dirname(path.realpath(__file__)) @@ -82,13 +83,13 @@ def test__individual_attributes_are_output( def test__subplot_is_output( imaging_7x7, grid_2d_irregular_7x7_list, mask_2d_7x7, plot_path, plot_patch ): - aplt.subplot_imaging_dataset( + subplot_imaging_dataset( dataset=imaging_7x7, output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_dataset.png") in plot_patch.paths + assert path.join(plot_path, "dataset.png") in plot_patch.paths def test__output_as_fits__correct_output_format( diff --git a/test_autoarray/dataset/plot/test_interferometer_plotters.py b/test_autoarray/dataset/plot/test_interferometer_plotters.py index 1715c1d4..cedf5d3b 100644 --- a/test_autoarray/dataset/plot/test_interferometer_plotters.py +++ b/test_autoarray/dataset/plot/test_interferometer_plotters.py @@ -2,6 +2,10 @@ import pytest import autoarray.plot as aplt +from autoarray.dataset.plot.interferometer_plots import ( + subplot_interferometer_dataset, + subplot_interferometer_dirty_images, +) directory = path.dirname(path.realpath(__file__)) @@ -62,18 +66,18 @@ def test__individual_attributes_are_output(interferometer_7, plot_path, plot_pat def test__subplots_are_output(interferometer_7, plot_path, plot_patch): - aplt.subplot_interferometer_dataset( + subplot_interferometer_dataset( dataset=interferometer_7, output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_dataset.png") in plot_patch.paths + assert path.join(plot_path, "dataset.png") in plot_patch.paths - aplt.subplot_interferometer_dirty_images( + subplot_interferometer_dirty_images( dataset=interferometer_7, output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_dirty_images.png") in plot_patch.paths + assert path.join(plot_path, "dirty_images.png") in plot_patch.paths diff --git a/test_autoarray/fit/plot/test_fit_imaging_plotters.py b/test_autoarray/fit/plot/test_fit_imaging_plotters.py index 7930f1a8..a0fa8438 100644 --- a/test_autoarray/fit/plot/test_fit_imaging_plotters.py +++ b/test_autoarray/fit/plot/test_fit_imaging_plotters.py @@ -110,7 +110,7 @@ def test__fit_sub_plot(fit_imaging_7x7, plot_path, plot_patch): output_format="png", ) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths def test__output_as_fits__correct_output_format( diff --git a/test_autoarray/fit/plot/test_fit_interferometer_plotters.py b/test_autoarray/fit/plot/test_fit_interferometer_plotters.py index c9f7decd..e9f27644 100644 --- a/test_autoarray/fit/plot/test_fit_interferometer_plotters.py +++ b/test_autoarray/fit/plot/test_fit_interferometer_plotters.py @@ -122,7 +122,7 @@ def test__fit_sub_plots(fit_interferometer_7, plot_path, plot_patch): output_format="png", ) - assert path.join(plot_path, "subplot_fit.png") in plot_patch.paths + assert path.join(plot_path, "fit.png") in plot_patch.paths aplt.subplot_fit_interferometer_dirty_images( fit=fit_interferometer_7, @@ -130,4 +130,4 @@ def test__fit_sub_plots(fit_interferometer_7, plot_path, plot_patch): output_format="png", ) - assert path.join(plot_path, "subplot_fit_dirty_images.png") in plot_patch.paths + assert path.join(plot_path, "fit_dirty_images.png") in plot_patch.paths diff --git a/test_autoarray/inversion/plot/test_inversion_plotters.py b/test_autoarray/inversion/plot/test_inversion_plotters.py index d9787416..7e921a0e 100644 --- a/test_autoarray/inversion/plot/test_inversion_plotters.py +++ b/test_autoarray/inversion/plot/test_inversion_plotters.py @@ -58,7 +58,7 @@ def test__inversion_subplot_of_mapper__is_output_for_all_inversions( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_inversion_0.png") in plot_patch.paths + assert path.join(plot_path, "inversion_0_0.png") in plot_patch.paths aplt.subplot_mappings( inversion=rectangular_inversion_7x7_3x3, @@ -66,4 +66,4 @@ def test__inversion_subplot_of_mapper__is_output_for_all_inversions( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_mappings_0.png") in plot_patch.paths + assert path.join(plot_path, "mappings_0.png") in plot_patch.paths diff --git a/test_autoarray/inversion/plot/test_mapper_plotters.py b/test_autoarray/inversion/plot/test_mapper_plotters.py index dc60c302..9bc02c56 100644 --- a/test_autoarray/inversion/plot/test_mapper_plotters.py +++ b/test_autoarray/inversion/plot/test_mapper_plotters.py @@ -43,4 +43,4 @@ def test__subplot_image_and_mapper( output_path=plot_path, output_format="png", ) - assert path.join(plot_path, "subplot_image_and_mapper.png") in plot_patch.paths + assert path.join(plot_path, "image_and_mapper.png") in plot_patch.paths