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
3 changes: 3 additions & 0 deletions autocti/charge_injection/plot/fit_ci_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,7 @@ def fits_fit(fit: FitImagingCI, output_path):
],
header_dict=fit.dataset.mask.header_dict,
)
# The fit subfolder may not exist yet: with PYAUTO_FAST_PLOTS=1 no figure is
# saved before this, and saving a figure is what used to create it.
Path(output_path).mkdir(parents=True, exist_ok=True)
hdu_list.writeto(Path(output_path) / "fit.fits", overwrite=True)
3 changes: 3 additions & 0 deletions autocti/dataset_1d/plot/fit_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,7 @@ def fits_fit(fit: FitDataset1D, output_path):
],
header_dict=fit.dataset.mask.header_dict,
)
# The fit subfolder may not exist yet: with PYAUTO_FAST_PLOTS=1 no figure is
# saved before this, and saving a figure is what used to create it.
Path(output_path).mkdir(parents=True, exist_ok=True)
hdu_list.writeto(Path(output_path) / "fit.fits", overwrite=True)
12 changes: 12 additions & 0 deletions test_autocti/charge_injection/plot/test_fit_ci_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,15 @@ def test__fits_fit(fit_ci_7x7, tmp_path):
aplt.fits_fit_ci(fit=fit_ci_7x7, output_path=tmp_path)

assert (Path(tmp_path) / "fit.fits").exists()


def test__fits_fit__creates_missing_output_directory(fit_ci_7x7, tmp_path):
# Under PYAUTO_FAST_PLOTS=1 no figure is saved first, so nothing else has
# created the fit's image subfolder when the FITS file is written.
from autocti.charge_injection.plot.fit_ci_plots import fits_fit

output_path = tmp_path / "image" / "fit_dataset"

fits_fit(fit=fit_ci_7x7, output_path=output_path)

assert (output_path / "fit.fits").is_file()
12 changes: 12 additions & 0 deletions test_autocti/dataset_1d/plot/test_fit_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ def test__fits_fit(fit_1d_7, plot_path, tmp_path):
aplt.fits_fit_dataset_1d(fit=fit_1d_7, output_path=tmp_path)

assert (Path(tmp_path) / "fit.fits").exists()


def test__fits_fit__creates_missing_output_directory(fit_1d_7, tmp_path):
# Under PYAUTO_FAST_PLOTS=1 no figure is saved first, so nothing else has
# created the fit's image subfolder when the FITS file is written.
from autocti.dataset_1d.plot.fit_plots import fits_fit

output_path = tmp_path / "image" / "fit_dataset"

fits_fit(fit=fit_1d_7, output_path=output_path)

assert (output_path / "fit.fits").is_file()
Loading