Skip to content

Commit

Permalink
Use custom representation for catalog. (#235)
Browse files Browse the repository at this point in the history
* Use custom representation for catalog.

* Black formatting.
  • Loading branch information
delucchi-cmu authored Mar 15, 2024
1 parent 0d03ba9 commit e6ffb6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/notebooks/import_catalogs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
"outputs": [],
"source": [
"from_dataframe_catalog = lsdb.read_hipscat(catalog_from_dataframe)\n",
"from_dataframe_catalog._ddf"
"from_dataframe_catalog"
]
},
{
Expand All @@ -260,7 +260,7 @@
"outputs": [],
"source": [
"from_importer_catalog = lsdb.read_hipscat(catalog_from_importer)\n",
"from_importer_catalog._ddf"
"from_importer_catalog"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion src/lsdb/catalog/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def __repr__(self):
return self._ddf.__repr__()

def _repr_html_(self):
return self._ddf._repr_html_() # pylint: disable=protected-access
# pylint: disable=protected-access
data = self._ddf._repr_data().to_html(max_rows=5, show_dimensions=False, notebook=True)
return f"<div><strong>lsdb Catalog {self.name}:</strong></div>{data}"

def compute(self) -> pd.DataFrame:
"""Compute dask distributed dataframe to pandas dataframe"""
Expand Down
5 changes: 4 additions & 1 deletion tests/lsdb/catalog/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def test_catalog_repr_equals_ddf_repr(small_sky_order1_catalog):


def test_catalog_html_repr_equals_ddf_html_repr(small_sky_order1_catalog):
assert small_sky_order1_catalog._repr_html_() == small_sky_order1_catalog._ddf._repr_html_()
full_html = small_sky_order1_catalog._repr_html_()
assert small_sky_order1_catalog.name in full_html
# this is a _hipscat_index that's in the data
assert "12682136550675316736" in full_html


def test_catalog_compute_equals_ddf_compute(small_sky_order1_catalog):
Expand Down

0 comments on commit e6ffb6b

Please sign in to comment.