diff --git a/docs/tutorials/margins.ipynb b/docs/tutorials/margins.ipynb index fc2f35c1..77f5ef33 100644 --- a/docs/tutorials/margins.ipynb +++ b/docs/tutorials/margins.ipynb @@ -352,7 +352,7 @@ }, "outputs": [], "source": [ - "small_sky_box_filter = ztf_object.box(ra=[179.9, 180], dec=[9.5, 9.7])\n", + "small_sky_box_filter = ztf_object.box_search(ra=[179.9, 180], dec=[9.5, 9.7])\n", "\n", "# Plot the points from the filtered ztf pixel in green, and from the pixel's margin cache in red\n", "plot_points(\n", diff --git a/docs/tutorials/pre_executed/des-gaia.ipynb b/docs/tutorials/pre_executed/des-gaia.ipynb index daed18a3..48c0291c 100644 --- a/docs/tutorials/pre_executed/des-gaia.ipynb +++ b/docs/tutorials/pre_executed/des-gaia.ipynb @@ -4209,9 +4209,9 @@ "ra_range = [0.0, 0.1]\n", "dec_range = [2.45, 2.55]\n", "\n", - "des_box = des_catalog.box(ra=ra_range, dec=dec_range).compute()\n", - "gaia_box = gaia_catalog.box(ra=ra_range, dec=dec_range).compute()\n", - "xmatch_box = xmatched.box(ra=ra_range, dec=dec_range).compute()\n", + "des_box = des_catalog.box_search(ra=ra_range, dec=dec_range).compute()\n", + "gaia_box = gaia_catalog.box_search(ra=ra_range, dec=dec_range).compute()\n", + "xmatch_box = xmatched.box_search(ra=ra_range, dec=dec_range).compute()\n", "\n", "ra_des = np.where(des_box[\"RA\"] > 180, des_box[\"RA\"] - 360, des_box[\"RA\"])\n", "ra_gaia = np.where(gaia_box[\"ra\"] > 180, gaia_box[\"ra\"] - 360, gaia_box[\"ra\"])\n", diff --git a/docs/tutorials/working_with_large_catalogs.ipynb b/docs/tutorials/working_with_large_catalogs.ipynb index 01b92fe7..15aeb687 100644 --- a/docs/tutorials/working_with_large_catalogs.ipynb +++ b/docs/tutorials/working_with_large_catalogs.ipynb @@ -143,7 +143,7 @@ "The `fine` parameter allows us to specify whether or not we desire to run the fine stage, for each search. It brings some overhead, so if your intention is to get a rough estimate of the data points for a region, you may disable it. It is always executed by default.\n", "\n", "```\n", - "catalog.box(..., fine=False)\n", + "catalog.box_search(..., fine=False)\n", "catalog.cone_search(..., fine=False)\n", "catalog.polygon_search(..., fine=False)\n", "```" @@ -259,7 +259,7 @@ "metadata": {}, "outputs": [], "source": [ - "ztf_object_box_ra = ztf_object.box(ra=[-65, -60])\n", + "ztf_object_box_ra = ztf_object.box_search(ra=[-65, -60])\n", "ztf_object_box_ra" ] }, @@ -288,7 +288,7 @@ "metadata": {}, "outputs": [], "source": [ - "ztf_object_box_dec = ztf_object.box(dec=[12, 15])\n", + "ztf_object_box_dec = ztf_object.box_search(dec=[12, 15])\n", "ztf_object_box_dec" ] }, @@ -319,7 +319,7 @@ "metadata": {}, "outputs": [], "source": [ - "ztf_object_box = ztf_object.box(ra=[-65, -60], dec=[12, 15])\n", + "ztf_object_box = ztf_object.box_search(ra=[-65, -60], dec=[12, 15])\n", "ztf_object_box" ] }, @@ -338,7 +338,7 @@ "id": "9a887b31", "metadata": {}, "source": [ - "We can stack a several number of filters, which are applied in sequence. For example, `catalog.box().polygon_search()` should result in a perfectly valid HiPSCat catalog containing the objects that match both filters." + "We can stack a several number of filters, which are applied in sequence. For example, `catalog.box_search().polygon_search()` should result in a perfectly valid HiPSCat catalog containing the objects that match both filters." ] }, { diff --git a/src/lsdb/catalog/catalog.py b/src/lsdb/catalog/catalog.py index cd2ec62e..1b733c1a 100644 --- a/src/lsdb/catalog/catalog.py +++ b/src/lsdb/catalog/catalog.py @@ -213,9 +213,9 @@ def cone_search(self, ra: float, dec: float, radius_arcsec: float, fine: bool = A new Catalog containing the points filtered to those within the cone, and the partitions that overlap the cone. """ - return self._search(ConeSearch(ra, dec, radius_arcsec), fine) + return self.search(ConeSearch(ra, dec, radius_arcsec, fine)) - def box( + def box_search( self, ra: Tuple[float, float] | None = None, dec: Tuple[float, float] | None = None, @@ -235,7 +235,7 @@ def box( A new catalog containing the points filtered to those within the region, and the partitions that have some overlap with it. """ - return self._search(BoxSearch(ra=ra, dec=dec), fine) + return self.search(BoxSearch(ra, dec, fine)) def polygon_search(self, vertices: List[SphericalCoordinates], fine: bool = True) -> Catalog: """Perform a polygonal search to filter the catalog. @@ -252,7 +252,7 @@ def polygon_search(self, vertices: List[SphericalCoordinates], fine: bool = True A new catalog containing the points filtered to those within the polygonal region, and the partitions that have some overlap with it. """ - return self._search(PolygonSearch(vertices), fine) + return self.search(PolygonSearch(vertices, fine)) def index_search(self, ids, catalog_index: HCIndexCatalog, fine: bool = True) -> Catalog: """Find rows by ids (or other value indexed by a catalog index). @@ -270,7 +270,7 @@ def index_search(self, ids, catalog_index: HCIndexCatalog, fine: bool = True) -> Returns: A new Catalog containing the points filtered to those matching the ids. """ - return self._search(IndexSearch(ids, catalog_index), fine) + return self.search(IndexSearch(ids, catalog_index, fine)) def order_search(self, min_order: int = 0, max_order: int | None = None) -> Catalog: """Filter catalog by order of HEALPix. @@ -282,7 +282,7 @@ def order_search(self, min_order: int = 0, max_order: int | None = None) -> Cata Returns: A new Catalog containing only the pixels of orders specified (inclusive). """ - return self._search(OrderSearch(min_order, max_order), fine=False) + return self.search(OrderSearch(min_order, max_order)) def pixel_search(self, pixels: List[Tuple[int, int]]) -> Catalog: """Finds all catalog pixels that overlap with the requested pixel set. @@ -294,9 +294,9 @@ def pixel_search(self, pixels: List[Tuple[int, int]]) -> Catalog: Returns: A new Catalog containing only the pixels that overlap with the requested pixel set. """ - return self._search(PixelSearch(pixels), fine=False) + return self.search(PixelSearch(pixels)) - def _search(self, search: AbstractSearch, fine: bool = True): + def search(self, search: AbstractSearch): """Find rows by reusable search algorithm. Filters partitions in the catalog to those that match some rough criteria. @@ -304,16 +304,15 @@ def _search(self, search: AbstractSearch, fine: bool = True): Args: search (AbstractSearch): Instance of AbstractSearch. - fine (bool): True if points are to be filtered, False if not. Defaults to True. Returns: A new Catalog containing the points filtered to those matching the search parameters. """ filtered_hc_structure = search.filter_hc_catalog(self.hc_structure) ddf_partition_map, search_ddf = self._perform_search( - filtered_hc_structure, filtered_hc_structure.get_healpix_pixels(), search, fine + filtered_hc_structure, filtered_hc_structure.get_healpix_pixels(), search ) - margin = self.margin._search(filtered_hc_structure, search, fine) if self.margin is not None else None + margin = self.margin.search(filtered_hc_structure, search) if self.margin is not None else None return Catalog(search_ddf, ddf_partition_map, filtered_hc_structure, margin=margin) def merge( diff --git a/src/lsdb/catalog/dataset/healpix_dataset.py b/src/lsdb/catalog/dataset/healpix_dataset.py index c4d15830..52c0684d 100644 --- a/src/lsdb/catalog/dataset/healpix_dataset.py +++ b/src/lsdb/catalog/dataset/healpix_dataset.py @@ -133,7 +133,6 @@ def _perform_search( metadata: hc.catalog.Catalog, filtered_pixels: List[HealpixPixel], search: AbstractSearch, - fine: bool = True, ): """Performs a search on the catalog from a list of pixels to search in @@ -141,7 +140,6 @@ def _perform_search( metadata (hc.catalog.Catalog): The metadata of the hipscat catalog. filtered_pixels (List[HealpixPixel]): List of pixels in the catalog to be searched. search (AbstractSearch): Instance of AbstractSearch. - fine (bool): True if points are to be filtered, False if not. Defaults to True. Returns: A tuple containing a dictionary mapping pixel to partition index and a dask dataframe @@ -151,7 +149,7 @@ def _perform_search( targeted_partitions = [partitions[self._ddf_pixel_map[pixel]] for pixel in filtered_pixels] filtered_partitions = ( [search.search_points(partition, metadata.catalog_info) for partition in targeted_partitions] - if fine + if search.fine else targeted_partitions ) return self._construct_search_ddf(filtered_pixels, filtered_partitions) diff --git a/src/lsdb/catalog/margin_catalog.py b/src/lsdb/catalog/margin_catalog.py index b5893ea1..b0eb5815 100644 --- a/src/lsdb/catalog/margin_catalog.py +++ b/src/lsdb/catalog/margin_catalog.py @@ -25,25 +25,23 @@ def __init__( ): super().__init__(ddf, ddf_pixel_map, hc_structure) - def _search(self, metadata: hc.catalog.Catalog, search: AbstractSearch, fine: bool = True): + def search(self, metadata: hc.catalog.Catalog, search: AbstractSearch): """Find rows by reusable search algorithm. Filters partitions in the catalog to those that match some rough criteria and their neighbors. Filters to points that match some finer criteria. Args: + metadata (hc.catalog.Catalog): The metadata of the hipscat catalog corresponding to the margin. search (AbstractSearch): Instance of AbstractSearch. - fine (bool): True if points are to be filtered, False if not. Defaults to True. Returns: A new Catalog containing the points filtered to those matching the search parameters. """ - # if the margin size is greater than the size of a pixel, this is an invalid search margin_search_moc = metadata.pixel_tree.to_moc() - filtered_hc_structure = self.hc_structure.filter_by_moc(margin_search_moc) ddf_partition_map, search_ddf = self._perform_search( - metadata, filtered_hc_structure.get_healpix_pixels(), search, fine + metadata, filtered_hc_structure.get_healpix_pixels(), search ) return self.__class__(search_ddf, ddf_partition_map, filtered_hc_structure) diff --git a/src/lsdb/core/search/abstract_search.py b/src/lsdb/core/search/abstract_search.py index f1b06701..79bee750 100644 --- a/src/lsdb/core/search/abstract_search.py +++ b/src/lsdb/core/search/abstract_search.py @@ -23,6 +23,9 @@ class AbstractSearch(ABC): individual rows matching the query terms. """ + def __init__(self, fine: bool = True): + self.fine = fine + def filter_hc_catalog(self, hc_structure: HCCatalogTypeVar) -> HCCatalogTypeVar: """Filters the hispcat catalog object to the partitions included in the search""" max_order = hc_structure.get_max_coverage_order() diff --git a/src/lsdb/core/search/box_search.py b/src/lsdb/core/search/box_search.py index 95d44617..ed88a8b9 100644 --- a/src/lsdb/core/search/box_search.py +++ b/src/lsdb/core/search/box_search.py @@ -21,7 +21,13 @@ class BoxSearch(AbstractSearch): Filters partitions in the catalog to those that have some overlap with the region. """ - def __init__(self, ra: Tuple[float, float] | None = None, dec: Tuple[float, float] | None = None): + def __init__( + self, + ra: Tuple[float, float] | None = None, + dec: Tuple[float, float] | None = None, + fine: bool = True, + ): + super().__init__(fine) ra = tuple(wrap_ra_angles(ra)) if ra else None validate_box_search(ra, dec) self.ra, self.dec = ra, dec diff --git a/src/lsdb/core/search/cone_search.py b/src/lsdb/core/search/cone_search.py index 9527f784..ab16312b 100644 --- a/src/lsdb/core/search/cone_search.py +++ b/src/lsdb/core/search/cone_search.py @@ -16,10 +16,10 @@ class ConeSearch(AbstractSearch): Filters partitions in the catalog to those that have some overlap with the cone. """ - def __init__(self, ra, dec, radius_arcsec): + def __init__(self, ra: float, dec: float, radius_arcsec: float, fine: bool = True): + super().__init__(fine) validate_radius(radius_arcsec) validate_declination_values(dec) - self.ra = ra self.dec = dec self.radius_arcsec = radius_arcsec diff --git a/src/lsdb/core/search/index_search.py b/src/lsdb/core/search/index_search.py index 80faa2d7..9bc4b18d 100644 --- a/src/lsdb/core/search/index_search.py +++ b/src/lsdb/core/search/index_search.py @@ -20,7 +20,8 @@ class IndexSearch(AbstractSearch): NB: This requires a previously-computed catalog index table. """ - def __init__(self, ids, catalog_index: IndexCatalog): + def __init__(self, ids, catalog_index: IndexCatalog, fine: bool = True): + super().__init__(fine) self.ids = ids self.catalog_index = catalog_index diff --git a/src/lsdb/core/search/order_search.py b/src/lsdb/core/search/order_search.py index 302a09ba..c7746043 100644 --- a/src/lsdb/core/search/order_search.py +++ b/src/lsdb/core/search/order_search.py @@ -18,6 +18,7 @@ class OrderSearch(AbstractSearch): """ def __init__(self, min_order: int = 0, max_order: int | None = None): + super().__init__(fine=False) if max_order and min_order > max_order: raise ValueError("The minimum order should be lower than or equal to the maximum order") self.min_order = min_order diff --git a/src/lsdb/core/search/pixel_search.py b/src/lsdb/core/search/pixel_search.py index 9a1174c5..a54e0a32 100644 --- a/src/lsdb/core/search/pixel_search.py +++ b/src/lsdb/core/search/pixel_search.py @@ -20,6 +20,7 @@ class PixelSearch(AbstractSearch): """ def __init__(self, pixels: List[Tuple[int, int]]): + super().__init__(fine=False) self.pixels = [HealpixPixel(o, p) for o, p in set(pixels)] def filter_hc_catalog(self, hc_structure: HCCatalogTypeVar) -> HCCatalogTypeVar: diff --git a/src/lsdb/core/search/polygon_search.py b/src/lsdb/core/search/polygon_search.py index 92483868..71c65f42 100644 --- a/src/lsdb/core/search/polygon_search.py +++ b/src/lsdb/core/search/polygon_search.py @@ -20,7 +20,8 @@ class PolygonSearch(AbstractSearch): Filters partitions in the catalog to those that have some overlap with the region. """ - def __init__(self, vertices: List[SphericalCoordinates]): + def __init__(self, vertices: List[SphericalCoordinates], fine: bool = True): + super().__init__(fine) _, dec = np.array(vertices).T validate_declination_values(dec) self.vertices = np.array(vertices) diff --git a/src/lsdb/dask/partition_indexer.py b/src/lsdb/dask/partition_indexer.py index 1bdbb66d..e4444114 100644 --- a/src/lsdb/dask/partition_indexer.py +++ b/src/lsdb/dask/partition_indexer.py @@ -1,9 +1,8 @@ from __future__ import annotations -from typing import List +from typing import List, Tuple import numpy as np -from hipscat.pixel_math import HealpixPixel from lsdb.core.search.pixel_search import PixelSearch @@ -18,7 +17,7 @@ def __init__(self, catalog): def __getitem__(self, item): indices = self._parse_partition_indices(item) pixels = self._get_pixels_from_partition_indices(indices) - return self.catalog._search(PixelSearch(pixels), fine=False) + return self.catalog.search(PixelSearch(pixels)) def _parse_partition_indices(self, item: int | List[int]) -> List[int]: """Parses the partition indices provided in the square brackets accessor. @@ -28,9 +27,9 @@ def _parse_partition_indices(self, item: int | List[int]) -> List[int]: indices = np.arange(len(self.catalog._ddf_pixel_map), dtype=object)[item].tolist() return indices - def _get_pixels_from_partition_indices(self, indices: List[int]) -> List[HealpixPixel]: + def _get_pixels_from_partition_indices(self, indices: List[int]) -> List[Tuple[int, int]]: """Performs a reverse-lookup in the catalog pixel-to-partition map and returns the pixels for the specified partition `indices`.""" inverted_pixel_map = {i: pixel for pixel, i in self.catalog._ddf_pixel_map.items()} filtered_pixels = [inverted_pixel_map[key] for key in indices] - return filtered_pixels + return [(p.order, p.pixel) for p in filtered_pixels] diff --git a/src/lsdb/loaders/hipscat/hipscat_catalog_loader.py b/src/lsdb/loaders/hipscat/hipscat_catalog_loader.py index 01fa0360..2b9a4973 100644 --- a/src/lsdb/loaders/hipscat/hipscat_catalog_loader.py +++ b/src/lsdb/loaders/hipscat/hipscat_catalog_loader.py @@ -49,7 +49,7 @@ def _load_margin_catalog(self, metadata: hc.catalog.Catalog) -> MarginCatalog | margin_catalog = self.config.margin_cache if self.config.search_filter is not None: # pylint: disable=protected-access - margin_catalog = margin_catalog._search(metadata, self.config.search_filter, fine=False) + margin_catalog = margin_catalog.search(metadata, self.config.search_filter) elif isinstance(self.config.margin_cache, str): margin_catalog = lsdb.read_hipscat( path=self.config.margin_cache, diff --git a/tests/lsdb/catalog/test_box_search.py b/tests/lsdb/catalog/test_box_search.py index de5402fb..4e776517 100644 --- a/tests/lsdb/catalog/test_box_search.py +++ b/tests/lsdb/catalog/test_box_search.py @@ -4,7 +4,7 @@ def test_box_search_ra_filters_correct_points(small_sky_order1_catalog, assert_divisions_are_correct): - ra_search_catalog = small_sky_order1_catalog.box(ra=(280, 300)) + ra_search_catalog = small_sky_order1_catalog.box_search(ra=(280, 300)) ra_search_df = ra_search_catalog.compute() ra_values = ra_search_df[small_sky_order1_catalog.hc_structure.catalog_info.ra_column] assert len(ra_search_df) < len(small_sky_order1_catalog.compute()) @@ -15,7 +15,7 @@ def test_box_search_ra_filters_correct_points(small_sky_order1_catalog, assert_d def test_box_search_ra_filters_correct_points_margin( small_sky_order1_source_with_margin, assert_divisions_are_correct ): - ra_search_catalog = small_sky_order1_source_with_margin.box(ra=(280, 300)) + ra_search_catalog = small_sky_order1_source_with_margin.box_search(ra=(280, 300)) ra_search_df = ra_search_catalog.compute() ra_values = ra_search_df[small_sky_order1_source_with_margin.hc_structure.catalog_info.ra_column] assert len(ra_search_df) < len(small_sky_order1_source_with_margin.compute()) @@ -33,12 +33,12 @@ def test_box_search_ra_filters_correct_points_margin( def test_box_search_ra_complement(small_sky_order1_catalog): ra_column = small_sky_order1_catalog.hc_structure.catalog_info.ra_column - ra_search_catalog = small_sky_order1_catalog.box(ra=(280, 300)) + ra_search_catalog = small_sky_order1_catalog.box_search(ra=(280, 300)) filtered_ra_values = ra_search_catalog.compute()[ra_column] assert len(filtered_ra_values) == 34 # The complement search contains the remaining catalog points - complement_search_catalog = small_sky_order1_catalog.box(ra=(300, 280)) + complement_search_catalog = small_sky_order1_catalog.box_search(ra=(300, 280)) complement_search_ra_values = complement_search_catalog.compute()[ra_column] assert len(complement_search_ra_values) == 97 @@ -49,18 +49,18 @@ def test_box_search_ra_complement(small_sky_order1_catalog): def test_box_search_ra_wrapped_filters_correct_points(small_sky_order1_catalog): ra_column = small_sky_order1_catalog.hc_structure.catalog_info.ra_column - ra_search_catalog = small_sky_order1_catalog.box(ra=(330, 30)) + ra_search_catalog = small_sky_order1_catalog.box_search(ra=(330, 30)) filtered_ra_values = ra_search_catalog.compute()[ra_column] # Some other options with values that need to be wrapped for ra_range in [(-30, 30), (330, 390), (330, -330)]: - catalog = small_sky_order1_catalog.box(ra=ra_range) + catalog = small_sky_order1_catalog.box_search(ra=ra_range) ra_values = catalog.compute()[ra_column] assert all((0 <= ra <= 30 or 330 <= ra <= 360) for ra in ra_values) assert np.array_equal(ra_values, filtered_ra_values) def test_box_search_dec_filters_correct_points(small_sky_order1_catalog, assert_divisions_are_correct): - dec_search_catalog = small_sky_order1_catalog.box(dec=(0, 30)) + dec_search_catalog = small_sky_order1_catalog.box_search(dec=(0, 30)) dec_search_df = dec_search_catalog.compute() dec_values = dec_search_df[small_sky_order1_catalog.hc_structure.catalog_info.dec_column] assert len(dec_search_df) < len(small_sky_order1_catalog.compute()) @@ -69,7 +69,7 @@ def test_box_search_dec_filters_correct_points(small_sky_order1_catalog, assert_ def test_box_search_ra_and_dec_filters_correct_points(small_sky_order1_catalog, assert_divisions_are_correct): - search_catalog = small_sky_order1_catalog.box(ra=(280, 300), dec=(-40, -30)) + search_catalog = small_sky_order1_catalog.box_search(ra=(280, 300), dec=(-40, -30)) search_df = search_catalog.compute() ra_values = search_df[small_sky_order1_catalog.hc_structure.catalog_info.ra_column] dec_values = search_df[small_sky_order1_catalog.hc_structure.catalog_info.dec_column] @@ -83,7 +83,7 @@ def test_box_search_filters_partitions(small_sky_order1_catalog): ra = (280, 300) dec = (-40, -30) hc_box_search = small_sky_order1_catalog.hc_structure.filter_by_box(ra, dec) - box_search_catalog = small_sky_order1_catalog.box(ra, dec, fine=False) + box_search_catalog = small_sky_order1_catalog.box_search(ra, dec, fine=False) assert len(hc_box_search.get_healpix_pixels()) == len(box_search_catalog.get_healpix_pixels()) assert len(hc_box_search.get_healpix_pixels()) == box_search_catalog._ddf.npartitions for pixel in hc_box_search.get_healpix_pixels(): @@ -93,8 +93,8 @@ def test_box_search_filters_partitions(small_sky_order1_catalog): def test_box_search_coarse_versus_fine(small_sky_order1_catalog): ra = (280, 300) dec = (-40, -30) - coarse_box_search = small_sky_order1_catalog.box(ra, dec, fine=False) - fine_box_search = small_sky_order1_catalog.box(ra, dec) + coarse_box_search = small_sky_order1_catalog.box_search(ra, dec, fine=False) + fine_box_search = small_sky_order1_catalog.box_search(ra, dec) assert coarse_box_search.get_healpix_pixels() == fine_box_search.get_healpix_pixels() assert coarse_box_search._ddf.npartitions == fine_box_search._ddf.npartitions assert len(coarse_box_search.compute()) > len(fine_box_search.compute()) @@ -103,31 +103,31 @@ def test_box_search_coarse_versus_fine(small_sky_order1_catalog): def test_box_search_invalid_args(small_sky_order1_catalog): # Some declination values are out of the [-90,90] bounds with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_DEC): - small_sky_order1_catalog.box(ra=(0, 30), dec=(-100, -70)) + small_sky_order1_catalog.box_search(ra=(0, 30), dec=(-100, -70)) # Declination values should be in ascending order with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(dec=(0, -10)) + small_sky_order1_catalog.box_search(dec=(0, -10)) # One or more ranges are defined with more than 2 values with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(ra=(0, 30), dec=(-30, -40, 10)) + small_sky_order1_catalog.box_search(ra=(0, 30), dec=(-30, -40, 10)) with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(ra=(0, 30, 40), dec=(-40, 10)) + small_sky_order1_catalog.box_search(ra=(0, 30, 40), dec=(-40, 10)) # The range values coincide (for ra, values are wrapped) with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(ra=(100, 100)) + small_sky_order1_catalog.box_search(ra=(100, 100)) with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(ra=(0, 360)) + small_sky_order1_catalog.box_search(ra=(0, 360)) with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(dec=(50, 50)) + small_sky_order1_catalog.box_search(dec=(50, 50)) # No range values were provided with pytest.raises(ValueError, match=ValidatorsErrors.INVALID_RADEC_RANGE): - small_sky_order1_catalog.box(ra=None, dec=None) + small_sky_order1_catalog.box_search(ra=None, dec=None) def test_empty_box_search_with_margin(small_sky_order1_source_with_margin): ra = (80, 100) dec = (0, 10) - box = small_sky_order1_source_with_margin.box(ra, dec, fine=False) + box = small_sky_order1_source_with_margin.box_search(ra, dec, fine=False) small_sky_order1_source_with_margin.plot_pixels() assert len(box._ddf_pixel_map) == 0 assert len(box.margin._ddf_pixel_map) == 0 diff --git a/tests/lsdb/loaders/hipscat/test_read_hipscat.py b/tests/lsdb/loaders/hipscat/test_read_hipscat.py index 397416df..3ec47c92 100644 --- a/tests/lsdb/loaders/hipscat/test_read_hipscat.py +++ b/tests/lsdb/loaders/hipscat/test_read_hipscat.py @@ -113,7 +113,7 @@ def test_read_hipscat_subset_with_cone_search(small_sky_order1_dir, small_sky_or def test_read_hipscat_subset_with_box_search(small_sky_order1_dir, small_sky_order1_catalog): box_search = BoxSearch(ra=(0, 10), dec=(-20, 10)) # Filtering using catalog's box_search - box_search_catalog = small_sky_order1_catalog.box(ra=(0, 10), dec=(-20, 10)) + box_search_catalog = small_sky_order1_catalog.box_search(ra=(0, 10), dec=(-20, 10)) # Filtering when calling `read_hipscat` box_search_catalog_2 = lsdb.read_hipscat(small_sky_order1_dir, search_filter=box_search) assert isinstance(box_search_catalog_2, lsdb.Catalog)