Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for lsdb.to_hipscat #18

Merged
merged 1 commit into from
Apr 1, 2024
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
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def small_sky_order1_dir_local(local_data_dir):
return os.path.join(local_data_dir, SMALL_SKY_ORDER1_DIR_NAME)


@pytest.fixture
def small_sky_parts_dir_local(local_data_dir):
return os.path.join(local_data_dir, "small_sky_parts")


@pytest.fixture
def tmp_dir_cloud(example_cloud_path):
return os.path.join(example_cloud_path, "tmp")
Expand Down
5 changes: 0 additions & 5 deletions tests/hipscat_import/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@ def dask_client():
@pytest.fixture
def small_sky_parts_dir_cloud(example_cloud_path):
return os.path.join(example_cloud_path, "hipscat_import", "data", "small_sky_parts")


@pytest.fixture
def small_sky_parts_dir_local(local_data_dir):
return os.path.join(local_data_dir, "small_sky_parts")
33 changes: 33 additions & 0 deletions tests/lsdb/io/test_to_hipscat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os

import lsdb
import pandas as pd

from hipscat_cloudtests import TempCloudDirectory


def test_save_catalog_and_margin(local_data_dir, example_cloud_storage_options, tmp_dir_cloud):
pathway = os.path.join(local_data_dir, "xmatch", "xmatch_catalog_raw.csv")
input_df = pd.read_csv(pathway)
catalog = lsdb.from_dataframe(
input_df, margin_threshold=5000, catalog_name="small_sky_from_dataframe", catalog_type="object"
)

with TempCloudDirectory(
tmp_dir_cloud, "lsdb_save_catalog_and_margin", example_cloud_storage_options
) as temp_path:
base_catalog_path = f"{temp_path}/new_catalog_name"
catalog.to_hipscat(base_catalog_path, storage_options=example_cloud_storage_options)
expected_catalog = lsdb.read_hipscat(base_catalog_path, storage_options=example_cloud_storage_options)
assert expected_catalog.hc_structure.catalog_name == catalog.hc_structure.catalog_name
assert expected_catalog.hc_structure.catalog_info == catalog.hc_structure.catalog_info
assert expected_catalog.get_healpix_pixels() == catalog.get_healpix_pixels()
pd.testing.assert_frame_equal(expected_catalog.compute(), catalog._ddf.compute())

base_catalog_path = f"{temp_path}/new_margin_name"
catalog.margin.to_hipscat(base_catalog_path, storage_options=example_cloud_storage_options)
expected_catalog = lsdb.read_hipscat(base_catalog_path, storage_options=example_cloud_storage_options)
assert expected_catalog.hc_structure.catalog_name == catalog.margin.hc_structure.catalog_name
assert expected_catalog.hc_structure.catalog_info == catalog.margin.hc_structure.catalog_info
assert expected_catalog.get_healpix_pixels() == catalog.margin.get_healpix_pixels()
pd.testing.assert_frame_equal(expected_catalog.compute(), catalog.margin._ddf.compute())