|
2 | 2 |
|
3 | 3 | import astropy.units as u |
4 | 4 | import numpy as np |
| 5 | +import pandas as pd |
5 | 6 | import pytest |
6 | 7 | from astropy.coordinates import Angle, SkyCoord |
7 | 8 | from mocpy import MOC, WCS |
@@ -843,6 +844,37 @@ def test_plot_kwargs(): |
843 | 844 | np.testing.assert_array_equal(col.get_array(), pix_map) |
844 | 845 |
|
845 | 846 |
|
| 847 | +def test_plot_healpix_map_types(): |
| 848 | + """Pass healpix map, using various list-like types.""" |
| 849 | + pytest.importorskip("matplotlib.pyplot") |
| 850 | + |
| 851 | + # First, use all numpy arrays to get the golden value. |
| 852 | + length = 192 |
| 853 | + pix_map_np = np.arange(length) |
| 854 | + _, ax = plot_healpix_map(pix_map_np) |
| 855 | + num_np_paths = len(ax.collections[0].get_paths()) |
| 856 | + |
| 857 | + pix_map = list(np.arange(length)) |
| 858 | + _, ax = plot_healpix_map(pix_map) |
| 859 | + assert len(ax.collections) > 0 |
| 860 | + assert len(ax.collections[0].get_paths()) == num_np_paths |
| 861 | + |
| 862 | + order = 2 |
| 863 | + ipix = list(np.arange(length)) |
| 864 | + pix_map = list(range(0, length)) |
| 865 | + depth = list(np.full(length, fill_value=order)) |
| 866 | + _, ax = plot_healpix_map(pix_map, ipix=ipix, depth=depth) |
| 867 | + assert len(ax.collections) > 0 |
| 868 | + assert len(ax.collections[0].get_paths()) == num_np_paths |
| 869 | + |
| 870 | + ipix = pd.Series(range(0, length)) |
| 871 | + pix_map = range(0, length) |
| 872 | + depth = pd.Series(np.full(length, fill_value=order)) |
| 873 | + _, ax = plot_healpix_map(pix_map, ipix=ipix, depth=depth) |
| 874 | + assert len(ax.collections) > 0 |
| 875 | + assert len(ax.collections[0].get_paths()) == num_np_paths |
| 876 | + |
| 877 | + |
846 | 878 | def test_plot_existing_fig(): |
847 | 879 | plt = pytest.importorskip("matplotlib.pyplot") |
848 | 880 |
|
|
0 commit comments