Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions autoarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions test_autoarray/dataset/plot/test_imaging_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 8 additions & 4 deletions test_autoarray/dataset/plot/test_interferometer_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion test_autoarray/fit/plot/test_fit_imaging_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions test_autoarray/fit/plot/test_fit_interferometer_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ 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,
output_path=plot_path,
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
4 changes: 2 additions & 2 deletions test_autoarray/inversion/plot/test_inversion_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ 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,
pixelization_index=0,
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
2 changes: 1 addition & 1 deletion test_autoarray/inversion/plot/test_mapper_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading