diff --git a/changelog/383.trivial.rst b/changelog/383.trivial.rst new file mode 100644 index 00000000..cf51c4de --- /dev/null +++ b/changelog/383.trivial.rst @@ -0,0 +1 @@ +Run plotting benchmarks fewer times for more manageable CI, and add a benchmark for generate_celestial_transform. diff --git a/dkist/conftest.py b/dkist/conftest.py index 8c8e9e10..36c5ea94 100644 --- a/dkist/conftest.py +++ b/dkist/conftest.py @@ -329,3 +329,12 @@ def large_visp_dataset(large_visp_dataset_file): # dataset_from_fits(vispdir, "test_visp.asdf") return load_dataset(large_visp_dataset_file) + + +@pytest.fixture(scope="session") +def visp_dataset_no_headers(tmp_path_factory): + vispdir = tmp_path_factory.mktemp("data") + with gzip.open(Path(rootdir) / "visp_no_headers.asdf.gz", mode="rb") as gfo: + with open(vispdir / "test_visp_no_headers.asdf", mode="wb") as afo: + afo.write(gfo.read()) + return load_dataset(vispdir / "test_visp_no_headers.asdf") diff --git a/dkist/data/test/visp_no_headers.asdf.gz b/dkist/data/test/visp_no_headers.asdf.gz new file mode 100644 index 00000000..69263dfd Binary files /dev/null and b/dkist/data/test/visp_no_headers.asdf.gz differ diff --git a/dkist/tests/test_benchmarks.py b/dkist/tests/test_benchmarks.py index 44a2ecb7..25f0c6ed 100644 --- a/dkist/tests/test_benchmarks.py +++ b/dkist/tests/test_benchmarks.py @@ -1,4 +1,5 @@ import matplotlib.pyplot as plt +import numpy as np import pytest from dkist import load_dataset @@ -9,18 +10,28 @@ def test_load_asdf(benchmark, large_visp_dataset_file): benchmark(load_dataset, large_visp_dataset_file) +@pytest.mark.benchmark +def test_pixel_to_world(benchmark, visp_dataset_no_headers, large_visp_dataset): + ds = visp_dataset_no_headers + # pxcoords2 = [] + # for size in ds2.wcs.pixel_shape: + # pxcoords2.append(np.arange(size)) + + pxcoords = np.mgrid[:ds.wcs.pixel_shape[0]:50, + :ds.wcs.pixel_shape[1]:50, + :ds.wcs.pixel_shape[2]:50, + :ds.wcs.pixel_shape[3]:5] + + benchmark(ds.wcs.pixel_to_world_values, *pxcoords) + + @pytest.mark.benchmark @pytest.mark.parametrize("axes", [ - ["y", "x", None, None], - ["y", None, "x", None], ["y", None, None, "x"], - [None, "y", "x", None], - [None, "y", None, "x"], - [None, None, "y", "x"], ]) -def test_plot_dataset(benchmark, axes, large_visp_dataset): +def test_plot_dataset(benchmark, axes, visp_dataset_no_headers): @benchmark - def plot_and_save_fig(ds=large_visp_dataset, axes=axes): + def plot_and_save_fig(ds=visp_dataset_no_headers, axes=axes): ds.plot(plot_axes=axes) plt.savefig("tmpplot") plt.close()