55import dask .dataframe as dd
66import hats as hc
77import hats .pixel_math .healpix_shim as hp
8- import matplotlib as mpl
9- import matplotlib .pyplot as plt
108import nested_pandas as npd
119import numpy as np
1210import numpy .testing as npt
1311import pandas as pd
1412import pytest
1513from astropy .coordinates import SkyCoord
1614from astropy .visualization .wcsaxes import WCSAxes
17- from hats .inspection .visualize_catalog import get_fov_moc_from_wcs
15+ from hats .inspection ._plotting import _get_fov_moc_from_wcs
1816from hats .pixel_math import HealpixPixel
1917from mocpy import WCS
2018from nested_pandas .datasets import generate_data
2422from lsdb import Catalog , MarginCatalog
2523from lsdb .core .search .region_search import MOCSearch
2624
27- mpl .use ("Agg" )
28-
2925
3026@pytest .fixture (autouse = True )
3127def reset_matplotlib ():
3228 yield
29+ mpl = pytest .importorskip ("matplotlib" )
30+ plt = pytest .importorskip ("matplotlib.pyplot" )
31+
32+ mpl .use ("Agg" )
3333 plt .close ("all" )
3434
3535
@@ -667,9 +667,9 @@ def test_filtered_catalog_has_undetermined_len(small_sky_order1_catalog, small_s
667667 len (small_sky_order1_catalog .pixel_search ([(0 , 11 )]))
668668
669669
670- @pytest .mark .sphgeom
671670def test_filtered_catalog_has_undetermined_len_polygon (small_sky_order1_catalog ):
672671 """Tests that filtered catalogs have an undetermined number of rows"""
672+ pytest .importorskip ("lsst.sphgeom" )
673673 with pytest .raises (ValueError , match = "undetermined" ):
674674 vertices = [(300 , - 50 ), (300 , - 55 ), (272 , - 55 ), (272 , - 50 )]
675675 len (small_sky_order1_catalog .polygon_search (vertices ))
@@ -736,12 +736,13 @@ def test_plot_points(small_sky_order1_catalog, mocker):
736736
737737
738738def test_plot_points_fov (small_sky_order1_catalog , mocker ):
739+ plt = pytest .importorskip ("matplotlib.pyplot" )
739740 mocker .patch ("astropy.visualization.wcsaxes.WCSAxes.scatter" )
740741 fig = plt .figure (figsize = (10 , 6 ))
741742 center = SkyCoord (350 , - 80 , unit = "deg" )
742743 fov = 10 * u .deg
743744 wcs = WCS (fig = fig , fov = fov , center = center , projection = "MOL" ).w
744- wcs_moc = get_fov_moc_from_wcs (wcs )
745+ wcs_moc = _get_fov_moc_from_wcs (wcs )
745746 _ , ax = small_sky_order1_catalog .plot_points (fov = fov , center = center )
746747 comp_cat = small_sky_order1_catalog .search (MOCSearch (wcs_moc )).compute ()
747748 WCSAxes .scatter .assert_called_once ()
@@ -751,12 +752,13 @@ def test_plot_points_fov(small_sky_order1_catalog, mocker):
751752
752753
753754def test_plot_points_wcs (small_sky_order1_catalog , mocker ):
755+ plt = pytest .importorskip ("matplotlib.pyplot" )
754756 mocker .patch ("astropy.visualization.wcsaxes.WCSAxes.scatter" )
755757 fig = plt .figure (figsize = (10 , 6 ))
756758 center = SkyCoord (350 , - 80 , unit = "deg" )
757759 fov = 10 * u .deg
758760 wcs = WCS (fig = fig , fov = fov , center = center ).w
759- wcs_moc = get_fov_moc_from_wcs (wcs )
761+ wcs_moc = _get_fov_moc_from_wcs (wcs )
760762 _ , ax = small_sky_order1_catalog .plot_points (wcs = wcs )
761763 comp_cat = small_sky_order1_catalog .search (MOCSearch (wcs_moc )).compute ()
762764 WCSAxes .scatter .assert_called_once ()
@@ -766,6 +768,7 @@ def test_plot_points_wcs(small_sky_order1_catalog, mocker):
766768
767769
768770def test_plot_points_colorcol (small_sky_order1_catalog , mocker ):
771+ plt = pytest .importorskip ("matplotlib.pyplot" )
769772 mocker .patch ("astropy.visualization.wcsaxes.WCSAxes.scatter" )
770773 mocker .patch ("matplotlib.pyplot.colorbar" )
771774 _ , ax = small_sky_order1_catalog .plot_points (color_col = "id" )
0 commit comments